@@ -62,7 +62,7 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
6262 await this . _handleGetHistory ( ) ;
6363 break ;
6464 case "copyBugs" :
65- await this . _handleCopyBugs ( msg . report ) ;
65+ await this . _handleCopyBugs ( msg . report , msg . blueprintPath || "" ) ;
6666 break ;
6767 case "launchEngine" :
6868 vscode . commands . executeCommand ( "testpilot-ai.launchEngine" ) ;
@@ -338,7 +338,7 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
338338 }
339339 }
340340
341- private _formatBugText ( report : Record < string , unknown > ) : string {
341+ private _formatBugText ( report : Record < string , unknown > , blueprintPath : string = "" ) : string {
342342 const bugCount = report . bug_count as number || 0 ;
343343 const lines : string [ ] = [
344344 `TestPilot AI 发现 ${ bugCount } 个Bug,请修复:` ,
@@ -381,13 +381,24 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
381381 "- [蓝本问题]:testpilot.json蓝本写错了(选择器错、动作类型错等),请修正蓝本文件" ,
382382 "- 无标签:需要你自行判断是应用问题还是蓝本问题" ,
383383 "" ,
384- "请逐个修复以上Bug(蓝本错改蓝本,应用错改应用),修复后调用 run_blueprint_test 重新测试,直到全部通过为止。" ,
385384 ) ;
385+ // 闭环指令:包含蓝本路径,让编程AI能直接调用MCP工具重测
386+ if ( blueprintPath ) {
387+ lines . push (
388+ `请逐个修复以上Bug(蓝本错改蓝本,应用错改应用),修复后调用 run_blueprint_test 重新测试:` ,
389+ ` blueprint_path: "${ blueprintPath } "` ,
390+ `重复修复+测试,直到全部通过为止。` ,
391+ ) ;
392+ } else {
393+ lines . push (
394+ "请逐个修复以上Bug(蓝本错改蓝本,应用错改应用),修复后调用 run_blueprint_test 重新测试,直到全部通过为止。" ,
395+ ) ;
396+ }
386397 return lines . join ( "\n" ) ;
387398 }
388399
389- private async _handleCopyBugs ( report : Record < string , unknown > ) : Promise < void > {
390- const bugText = this . _formatBugText ( report ) ;
400+ private async _handleCopyBugs ( report : Record < string , unknown > , blueprintPath : string = "" ) : Promise < void > {
401+ const bugText = this . _formatBugText ( report , blueprintPath ) ;
391402
392403 // 尝试直接发送到 Cascade/Copilot 聊天
393404 try {
@@ -1520,7 +1531,9 @@ ${commonRules}`;
15201531 // 复制Bug给AI
15211532 document.getElementById("btnCopyBugs").addEventListener("click", () => {
15221533 if (!lastReport) { addLog("暂无测试报告", "error"); return; }
1523- vscode.postMessage({ command: "copyBugs", report: lastReport });
1534+ // 附带蓝本路径,让编程AI知道调run_blueprint_test时传什么路径
1535+ var bpPath = document.getElementById("inputBlueprintPath").value.trim();
1536+ vscode.postMessage({ command: "copyBugs", report: lastReport, blueprintPath: bpPath });
15241537 });
15251538
15261539 // 重测按钮
0 commit comments