Compare commits
3 Commits
4a790b5aca
...
2af79cf1dc
| Author | SHA1 | Date | |
|---|---|---|---|
| 2af79cf1dc | |||
| 5b225126f1 | |||
| 4abb979eab |
@ -341,7 +341,8 @@ export async function showICHelperPanel(
|
|||||||
panel,
|
panel,
|
||||||
message.planTitle || "计划",
|
message.planTitle || "计划",
|
||||||
context.extensionPath,
|
context.extensionPath,
|
||||||
taskId
|
taskId,
|
||||||
|
message.model // 传递服务等级
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|||||||
@ -369,6 +369,8 @@ export class DialogSession {
|
|||||||
const knowledgeData = await this.loadKnowledgeData();
|
const knowledgeData = await this.loadKnowledgeData();
|
||||||
console.log('[DialogSession] knowledgeData 加载结果:', knowledgeData ? `${knowledgeData.length} 字符` : 'null');
|
console.log('[DialogSession] knowledgeData 加载结果:', knowledgeData ? `${knowledgeData.length} 字符` : 'null');
|
||||||
|
|
||||||
|
console.log('[DialogSession] serviceTier 参数:', serviceTier, '-> 使用:', serviceTier || config.serviceTier);
|
||||||
|
|
||||||
const request: DialogRequest = {
|
const request: DialogRequest = {
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
message,
|
message,
|
||||||
@ -908,6 +910,7 @@ class DialogManager {
|
|||||||
*/
|
*/
|
||||||
abortCurrentSession(): void {
|
abortCurrentSession(): void {
|
||||||
this.currentSession?.abort();
|
this.currentSession?.abort();
|
||||||
|
this.currentSession = null; // 清空会话,确保下次创建新会话
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import type {
|
|||||||
FileDeleteArgs,
|
FileDeleteArgs,
|
||||||
FileListArgs,
|
FileListArgs,
|
||||||
SyntaxCheckArgs,
|
SyntaxCheckArgs,
|
||||||
|
IverilogArgs,
|
||||||
SimulationArgs,
|
SimulationArgs,
|
||||||
WaveformSummaryArgs,
|
WaveformSummaryArgs,
|
||||||
KnowledgeSaveArgs,
|
KnowledgeSaveArgs,
|
||||||
@ -75,6 +76,9 @@ export async function executeToolCall(
|
|||||||
case 'syntax_check':
|
case 'syntax_check':
|
||||||
resultText = await executeSyntaxCheck(args as unknown as SyntaxCheckArgs, context);
|
resultText = await executeSyntaxCheck(args as unknown as SyntaxCheckArgs, context);
|
||||||
break;
|
break;
|
||||||
|
case 'iverilog':
|
||||||
|
resultText = await executeIverilog(args as unknown as IverilogArgs, context);
|
||||||
|
break;
|
||||||
case 'simulation':
|
case 'simulation':
|
||||||
resultText = await executeSimulation(args as unknown as SimulationArgs, context);
|
resultText = await executeSimulation(args as unknown as SimulationArgs, context);
|
||||||
break;
|
break;
|
||||||
@ -270,6 +274,71 @@ async function executeSyntaxCheck(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行 iverilog 工具
|
||||||
|
* 直接执行 iverilog 命令
|
||||||
|
*/
|
||||||
|
async function executeIverilog(
|
||||||
|
args: IverilogArgs,
|
||||||
|
context: ToolExecutorContext
|
||||||
|
): Promise<string> {
|
||||||
|
// 检查 iverilog 是否可用
|
||||||
|
const iverilogCheck = await checkIverilogAvailable(context.extensionPath);
|
||||||
|
if (!iverilogCheck.available) {
|
||||||
|
throw new Error(`iverilog 不可用: ${iverilogCheck.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取工作目录
|
||||||
|
const workspaceFolders = vscode.workspace.workspaceFolders;
|
||||||
|
if (!workspaceFolders || workspaceFolders.length === 0) {
|
||||||
|
throw new Error('没有打开的工作区');
|
||||||
|
}
|
||||||
|
const projectPath = workspaceFolders[0].uri.fsPath;
|
||||||
|
const workDir = args.workDir
|
||||||
|
? path.join(projectPath, args.workDir)
|
||||||
|
: projectPath;
|
||||||
|
|
||||||
|
// 解析参数
|
||||||
|
const iverilogPath = getIverilogPath(context.extensionPath);
|
||||||
|
const cmdArgs = args.args.split(/\s+/).filter(a => a.length > 0);
|
||||||
|
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const child = spawn(iverilogPath, cmdArgs, {
|
||||||
|
cwd: workDir,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
IVERILOG_ROOT: path.join(context.extensionPath, 'tools', 'iverilog')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
child.stdout.on('data', (data: Buffer) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
child.stderr.on('data', (data: Buffer) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('close', (code: number) => {
|
||||||
|
const output = stderr || stdout || '(无输出)';
|
||||||
|
if (code === 0) {
|
||||||
|
resolve(`执行成功\n${output}`);
|
||||||
|
} else {
|
||||||
|
resolve(`执行失败 (exit code: ${code})\n${output}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('error', (error: Error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行 simulation 工具
|
* 执行 simulation 工具
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -518,6 +518,12 @@ export interface SyntaxCheckArgs {
|
|||||||
code: string;
|
code: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** iverilog 工具参数 */
|
||||||
|
export interface IverilogArgs {
|
||||||
|
args: string;
|
||||||
|
workDir?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/** simulation 工具参数 */
|
/** simulation 工具参数 */
|
||||||
export interface SimulationArgs {
|
export interface SimulationArgs {
|
||||||
rtlPath: string;
|
rtlPath: string;
|
||||||
@ -566,6 +572,7 @@ export type ToolArgs =
|
|||||||
| FileDeleteArgs
|
| FileDeleteArgs
|
||||||
| FileListArgs
|
| FileListArgs
|
||||||
| SyntaxCheckArgs
|
| SyntaxCheckArgs
|
||||||
|
| IverilogArgs
|
||||||
| SimulationArgs
|
| SimulationArgs
|
||||||
| WaveformSummaryArgs
|
| WaveformSummaryArgs
|
||||||
| WaveformTraceArgs
|
| WaveformTraceArgs
|
||||||
|
|||||||
@ -36,6 +36,7 @@ let pendingPlanExecution: {
|
|||||||
planTitle: string;
|
planTitle: string;
|
||||||
extensionPath: string;
|
extensionPath: string;
|
||||||
taskId: string; // 保存 taskId 以便复用
|
taskId: string; // 保存 taskId 以便复用
|
||||||
|
serviceTier?: ServiceTier; // 保存服务等级
|
||||||
} | null = null;
|
} | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,10 +46,11 @@ export function setPendingPlanExecution(
|
|||||||
panel: vscode.WebviewPanel,
|
panel: vscode.WebviewPanel,
|
||||||
planTitle: string,
|
planTitle: string,
|
||||||
extensionPath: string,
|
extensionPath: string,
|
||||||
taskId: string
|
taskId: string,
|
||||||
|
serviceTier?: ServiceTier
|
||||||
): void {
|
): void {
|
||||||
pendingPlanExecution = { panel, planTitle, extensionPath, taskId };
|
pendingPlanExecution = { panel, planTitle, extensionPath, taskId, serviceTier };
|
||||||
console.log("[MessageHandler] 设置待执行计划:", planTitle, "taskId:", taskId);
|
console.log("[MessageHandler] 设置待执行计划:", planTitle, "taskId:", taskId, "serviceTier:", serviceTier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,13 +231,16 @@ async function handleUserMessageWithBackend(
|
|||||||
planTitle,
|
planTitle,
|
||||||
extensionPath: execPath,
|
extensionPath: execPath,
|
||||||
taskId: reuseTaskId,
|
taskId: reuseTaskId,
|
||||||
|
serviceTier: savedServiceTier,
|
||||||
} = pendingPlanExecution;
|
} = pendingPlanExecution;
|
||||||
pendingPlanExecution = null;
|
pendingPlanExecution = null;
|
||||||
console.log(
|
console.log(
|
||||||
"[MessageHandler] 自动执行计划:",
|
"[MessageHandler] 自动执行计划:",
|
||||||
planTitle,
|
planTitle,
|
||||||
"复用 taskId:",
|
"复用 taskId:",
|
||||||
reuseTaskId
|
reuseTaskId,
|
||||||
|
"serviceTier:",
|
||||||
|
savedServiceTier
|
||||||
);
|
);
|
||||||
|
|
||||||
// 延迟一小段时间确保当前对话完全结束
|
// 延迟一小段时间确保当前对话完全结束
|
||||||
@ -247,7 +252,8 @@ async function handleUserMessageWithBackend(
|
|||||||
`请按照刚才的计划执行:${planTitle}`,
|
`请按照刚才的计划执行:${planTitle}`,
|
||||||
execPath,
|
execPath,
|
||||||
"agent",
|
"agent",
|
||||||
reuseTaskId // 复用 Plan 模式的 taskId
|
reuseTaskId, // 复用 Plan 模式的 taskId
|
||||||
|
savedServiceTier // 传递保存的服务等级
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[MessageHandler] 自动执行计划失败:", err);
|
console.error("[MessageHandler] 自动执行计划失败:", err);
|
||||||
@ -400,9 +406,10 @@ export async function handlePlanAction(
|
|||||||
panel: vscode.WebviewPanel,
|
panel: vscode.WebviewPanel,
|
||||||
action: string,
|
action: string,
|
||||||
planTitle: string,
|
planTitle: string,
|
||||||
extensionPath: string
|
extensionPath: string,
|
||||||
|
serviceTier?: ServiceTier
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
console.log("[handlePlanAction] action:", action, "planTitle:", planTitle);
|
console.log("[handlePlanAction] action:", action, "planTitle:", planTitle, "serviceTier:", serviceTier);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "confirm":
|
case "confirm":
|
||||||
@ -416,7 +423,8 @@ export async function handlePlanAction(
|
|||||||
panel,
|
panel,
|
||||||
`请按照刚才的计划执行:${planTitle}`,
|
`请按照刚才的计划执行:${planTitle}`,
|
||||||
extensionPath,
|
extensionPath,
|
||||||
"agent"
|
"agent",
|
||||||
|
serviceTier
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -432,7 +440,8 @@ export async function handlePlanAction(
|
|||||||
panel,
|
panel,
|
||||||
`请根据以下建议修改计划:${modification}`,
|
`请根据以下建议修改计划:${modification}`,
|
||||||
extensionPath,
|
extensionPath,
|
||||||
"plan"
|
"plan",
|
||||||
|
serviceTier
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -646,7 +646,8 @@ export function getPlanCardScript(): string {
|
|||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
command: 'planAction',
|
command: 'planAction',
|
||||||
action: actionMap[option] || option,
|
action: actionMap[option] || option,
|
||||||
planTitle: segment.planTitle
|
planTitle: segment.planTitle,
|
||||||
|
model: getCurrentModel()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -720,7 +721,8 @@ export function getPlanCardScript(): string {
|
|||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
command: 'planAction',
|
command: 'planAction',
|
||||||
action: action,
|
action: action,
|
||||||
planTitle: segment.planTitle
|
planTitle: segment.planTitle,
|
||||||
|
model: getCurrentModel()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user