mcp-probe-kit 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/build/lib/__tests__/memory-orchestration.unit.test.js +88 -0
- package/build/lib/__tests__/memory-payload.unit.test.js +35 -0
- package/build/lib/__tests__/quality-constraints.unit.test.d.ts +1 -0
- package/build/lib/__tests__/quality-constraints.unit.test.js +54 -0
- package/build/lib/__tests__/spec-validator.unit.test.js +106 -74
- package/build/lib/agents-md-template.js +32 -32
- package/build/lib/cursor-history-client.d.ts +54 -0
- package/build/lib/cursor-history-client.js +240 -0
- package/build/lib/quality-constraints.d.ts +54 -0
- package/build/lib/quality-constraints.js +155 -0
- package/build/lib/skill-bridge.js +12 -12
- package/build/lib/spec-validator.js +16 -3
- package/build/lib/template-loader.js +83 -23
- package/build/resources/ui-ux-data/guidelines/vercel-web-interface.json +1632 -1632
- package/build/resources/ui-ux-data/metadata.json +30 -30
- package/build/resources/ui-ux-data/shadcn/blocks.json +2541 -2541
- package/build/resources/ui-ux-data/shadcn/components.json +997 -997
- package/build/resources/ui-ux-data/themes/presets.json +483 -483
- package/build/tools/__tests__/cursor-history.unit.test.d.ts +1 -0
- package/build/tools/__tests__/cursor-history.unit.test.js +38 -0
- package/build/tools/check_spec.js +16 -16
- package/build/tools/code_insight.js +41 -41
- package/build/tools/code_review.js +11 -4
- package/build/tools/cursor_read_conversation.d.ts +7 -0
- package/build/tools/cursor_read_conversation.js +36 -0
- package/build/tools/fix_bug.js +161 -161
- package/build/tools/gencommit.js +60 -60
- package/build/tools/init_project_context.js +432 -432
- package/build/tools/start_product.js +1 -1
- package/build/tools/start_ui.js +17 -0
- package/build/tools/ui-ux-tools.d.ts +3 -0
- package/build/tools/ui-ux-tools.js +302 -290
- package/build/utils/__tests__/vercel-guidelines-sync.unit.test.js +12 -12
- package/build/utils/design-reasoning-engine.d.ts +2 -0
- package/build/utils/design-reasoning-engine.js +3 -0
- package/build/utils/themes-sync.js +8 -8
- package/package.json +3 -2
- package/build/resources/index.d.ts +0 -4
- package/build/resources/index.js +0 -4
- package/build/resources/tool-params-guide.d.ts +0 -571
- package/build/resources/tool-params-guide.js +0 -488
- package/build/tools/analyze_project.d.ts +0 -1
- package/build/tools/analyze_project.js +0 -527
- package/build/tools/check_deps.d.ts +0 -13
- package/build/tools/check_deps.js +0 -204
- package/build/tools/convert.d.ts +0 -13
- package/build/tools/convert.js +0 -599
- package/build/tools/css_order.d.ts +0 -13
- package/build/tools/css_order.js +0 -81
- package/build/tools/debug.d.ts +0 -13
- package/build/tools/debug.js +0 -131
- package/build/tools/design2code.d.ts +0 -20
- package/build/tools/design2code.js +0 -426
- package/build/tools/detect_shell.d.ts +0 -6
- package/build/tools/detect_shell.js +0 -151
- package/build/tools/explain.d.ts +0 -13
- package/build/tools/explain.js +0 -390
- package/build/tools/fix.d.ts +0 -13
- package/build/tools/fix.js +0 -303
- package/build/tools/gen_mock.d.ts +0 -22
- package/build/tools/gen_mock.js +0 -269
- package/build/tools/gen_skill.d.ts +0 -13
- package/build/tools/gen_skill.js +0 -560
- package/build/tools/genapi.d.ts +0 -13
- package/build/tools/genapi.js +0 -174
- package/build/tools/genchangelog.d.ts +0 -13
- package/build/tools/genchangelog.js +0 -250
- package/build/tools/gendoc.d.ts +0 -13
- package/build/tools/gendoc.js +0 -232
- package/build/tools/genpr.d.ts +0 -13
- package/build/tools/genpr.js +0 -194
- package/build/tools/genreadme.d.ts +0 -13
- package/build/tools/genreadme.js +0 -626
- package/build/tools/gensql.d.ts +0 -13
- package/build/tools/gensql.js +0 -320
- package/build/tools/genui.d.ts +0 -13
- package/build/tools/genui.js +0 -803
- package/build/tools/init_component_catalog.d.ts +0 -22
- package/build/tools/init_component_catalog.js +0 -809
- package/build/tools/init_setting.d.ts +0 -13
- package/build/tools/init_setting.js +0 -47
- package/build/tools/perf.d.ts +0 -13
- package/build/tools/perf.js +0 -409
- package/build/tools/render_ui.d.ts +0 -22
- package/build/tools/render_ui.js +0 -384
- package/build/tools/resolve_conflict.d.ts +0 -13
- package/build/tools/resolve_conflict.js +0 -349
- package/build/tools/security_scan.d.ts +0 -22
- package/build/tools/security_scan.js +0 -323
- package/build/tools/split.d.ts +0 -13
- package/build/tools/split.js +0 -599
- package/build/tools/start_api.d.ts +0 -13
- package/build/tools/start_api.js +0 -193
- package/build/tools/start_doc.d.ts +0 -13
- package/build/tools/start_doc.js +0 -207
- package/build/tools/start_refactor.d.ts +0 -13
- package/build/tools/start_refactor.js +0 -188
- package/build/tools/start_release.d.ts +0 -13
- package/build/tools/start_release.js +0 -167
- package/build/tools/start_review.d.ts +0 -13
- package/build/tools/start_review.js +0 -175
- /package/build/{utils/design-docs-generator.d.ts → lib/__tests__/memory-orchestration.unit.test.d.ts} +0 -0
- /package/build/{utils/design-docs-generator.js → lib/__tests__/memory-payload.unit.test.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
+
const readConversationMock = vi.fn();
|
|
3
|
+
vi.mock('../../lib/cursor-history-client.js', () => ({
|
|
4
|
+
createCursorHistoryClient: () => ({
|
|
5
|
+
readConversation: readConversationMock,
|
|
6
|
+
}),
|
|
7
|
+
}));
|
|
8
|
+
import { cursorReadConversation } from '../cursor_read_conversation.js';
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
readConversationMock.mockReset();
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.clearAllMocks();
|
|
14
|
+
});
|
|
15
|
+
describe('cursor history tools', () => {
|
|
16
|
+
test('cursor_read_conversation 返回消息时间线', async () => {
|
|
17
|
+
readConversationMock.mockResolvedValue({
|
|
18
|
+
composerId: 'c1',
|
|
19
|
+
messages: [
|
|
20
|
+
{ bubbleId: 'b1', type: 1, text: '我们先聊需求' },
|
|
21
|
+
{ bubbleId: 'b2', type: 2, text: '听懂了' },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
const result = await cursorReadConversation({ composer_id: 'c1', limit: 50, include_empty: true });
|
|
25
|
+
expect(result.isError).toBe(false);
|
|
26
|
+
expect('structuredContent' in result).toBe(true);
|
|
27
|
+
if (!('structuredContent' in result)) {
|
|
28
|
+
throw new Error('structuredContent 缺失');
|
|
29
|
+
}
|
|
30
|
+
expect(result.content[0].text).toContain('共 2 条消息');
|
|
31
|
+
expect(result.structuredContent.messageCount).toBe(2);
|
|
32
|
+
expect(readConversationMock).toHaveBeenCalledWith({
|
|
33
|
+
composerId: 'c1',
|
|
34
|
+
limit: 50,
|
|
35
|
+
includeEmpty: true,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -55,23 +55,23 @@ export async function checkSpec(args) {
|
|
|
55
55
|
? report.issues.map(formatIssue).join('\n')
|
|
56
56
|
: '- 无';
|
|
57
57
|
const text = report.passed
|
|
58
|
-
? `# ✅ 规格校验通过:${featureName}
|
|
59
|
-
|
|
60
|
-
${report.summary}
|
|
61
|
-
|
|
62
|
-
**需求清单**: ${report.frIds.join(', ') || '(未发现 FR)'}
|
|
63
|
-
${report.warningCount > 0 ? `\n仍有 ${report.warningCount} 个提醒(非阻塞,建议处理):\n${issueLines}\n` : ''}
|
|
58
|
+
? `# ✅ 规格校验通过:${featureName}
|
|
59
|
+
|
|
60
|
+
${report.summary}
|
|
61
|
+
|
|
62
|
+
**需求清单**: ${report.frIds.join(', ') || '(未发现 FR)'}
|
|
63
|
+
${report.warningCount > 0 ? `\n仍有 ${report.warningCount} 个提醒(非阻塞,建议处理):\n${issueLines}\n` : ''}
|
|
64
64
|
**下一步**: 规格已具备可实现性,可进入实现/估算阶段。`
|
|
65
|
-
: `# ❌ 规格校验未通过:${featureName}
|
|
66
|
-
|
|
67
|
-
${report.summary}
|
|
68
|
-
|
|
69
|
-
## 待修复(${relDir})
|
|
70
|
-
${issueLines}
|
|
71
|
-
|
|
72
|
-
## 处理方式
|
|
73
|
-
1. 按上述每一条补全 \`${relDir}/\` 下的 requirements.md / design.md / tasks.md
|
|
74
|
-
2. **重新运行** \`check_spec\`(同样的 feature_name)直到通过
|
|
65
|
+
: `# ❌ 规格校验未通过:${featureName}
|
|
66
|
+
|
|
67
|
+
${report.summary}
|
|
68
|
+
|
|
69
|
+
## 待修复(${relDir})
|
|
70
|
+
${issueLines}
|
|
71
|
+
|
|
72
|
+
## 处理方式
|
|
73
|
+
1. 按上述每一条补全 \`${relDir}/\` 下的 requirements.md / design.md / tasks.md
|
|
74
|
+
2. **重新运行** \`check_spec\`(同样的 feature_name)直到通过
|
|
75
75
|
3. **校验通过前不要开始写实现代码** —— 这是为了确保需求被完整实现,而不是写到一半才发现规格有缺口`;
|
|
76
76
|
return okStructured(text, report);
|
|
77
77
|
}
|
|
@@ -136,10 +136,10 @@ function createProjectDocsPlan(layout, docsSnapshot) {
|
|
|
136
136
|
latestJsonFilePath: layout.latestJsonPath,
|
|
137
137
|
archiveMarkdownFilePath: docsSnapshot.markdownFilePath,
|
|
138
138
|
archiveJsonFilePath: docsSnapshot.jsonFilePath,
|
|
139
|
-
navigationSnippet: `### [代码图谱洞察](./graph-insights/latest.md)
|
|
140
|
-
最近一次 code_insight 分析结果,包含调用链、上下文与影响面摘要
|
|
139
|
+
navigationSnippet: `### [代码图谱洞察](./graph-insights/latest.md)
|
|
140
|
+
最近一次 code_insight 分析结果,包含调用链、上下文与影响面摘要
|
|
141
141
|
`,
|
|
142
|
-
devGuideSnippet: `- **代码图谱洞察**: [graph-insights/latest.md](./graph-insights/latest.md) - 需要理解模块依赖、调用链和影响面时优先查看
|
|
142
|
+
devGuideSnippet: `- **代码图谱洞察**: [graph-insights/latest.md](./graph-insights/latest.md) - 需要理解模块依赖、调用链和影响面时优先查看
|
|
143
143
|
`,
|
|
144
144
|
};
|
|
145
145
|
}
|
|
@@ -187,15 +187,15 @@ export function buildCodeInsightDelegatedPlan(input) {
|
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
function renderUsageGuide() {
|
|
190
|
-
return `## 使用场景指南
|
|
191
|
-
- 探索调用链: \`{ mode: "query", query: "login", goal: "理解登录认证流程" }\`
|
|
192
|
-
- 深入函数上下文: \`{ mode: "context", target: "login", file_path: "src/auth/login.ts" }\`
|
|
193
|
-
- 评估影响范围: \`{ mode: "impact", target: "login", direction: "upstream", file_path: "..." }\`
|
|
194
|
-
- 查看代码内容: \`{ mode: "context", target: "login", include_content: true }\`
|
|
195
|
-
|
|
196
|
-
## 下一步建议
|
|
197
|
-
- 查询不精确: 增加 \`goal\`(例如“理解登录认证流程”)
|
|
198
|
-
- 出现歧义: 传入 \`uid\` 或 \`file_path\` 重新执行
|
|
190
|
+
return `## 使用场景指南
|
|
191
|
+
- 探索调用链: \`{ mode: "query", query: "login", goal: "理解登录认证流程" }\`
|
|
192
|
+
- 深入函数上下文: \`{ mode: "context", target: "login", file_path: "src/auth/login.ts" }\`
|
|
193
|
+
- 评估影响范围: \`{ mode: "impact", target: "login", direction: "upstream", file_path: "..." }\`
|
|
194
|
+
- 查看代码内容: \`{ mode: "context", target: "login", include_content: true }\`
|
|
195
|
+
|
|
196
|
+
## 下一步建议
|
|
197
|
+
- 查询不精确: 增加 \`goal\`(例如“理解登录认证流程”)
|
|
198
|
+
- 出现歧义: 传入 \`uid\` 或 \`file_path\` 重新执行
|
|
199
199
|
- 需要落盘: 传 \`save_to_docs: true\`,再按 delegated plan 写入 docs/graph-insights`;
|
|
200
200
|
}
|
|
201
201
|
export function resolveCodeInsightQuery(input) {
|
|
@@ -307,22 +307,22 @@ export async function codeInsight(args, context) {
|
|
|
307
307
|
status: item.status,
|
|
308
308
|
})));
|
|
309
309
|
const ambiguityText = formatAmbiguities(result.ambiguities);
|
|
310
|
-
const message = `# code_insight 图谱分析结果
|
|
311
|
-
|
|
312
|
-
状态: ${formatStatusLabel(status)}
|
|
313
|
-
模式: ${result.modeRequested} -> ${result.modeResolved}
|
|
314
|
-
来源: ${result.provider}
|
|
315
|
-
启动策略: ${result.launcherStrategy}
|
|
316
|
-
工作区: ${result.workspaceMode}
|
|
317
|
-
源目录: ${result.sourceRoot}
|
|
318
|
-
|
|
319
|
-
摘要:
|
|
320
|
-
${result.summary}
|
|
321
|
-
|
|
322
|
-
执行详情:
|
|
323
|
-
${executionSummary}
|
|
324
|
-
|
|
325
|
-
${ambiguityText ? `歧义候选:\n${ambiguityText}\n\n` : ""}\
|
|
310
|
+
const message = `# code_insight 图谱分析结果
|
|
311
|
+
|
|
312
|
+
状态: ${formatStatusLabel(status)}
|
|
313
|
+
模式: ${result.modeRequested} -> ${result.modeResolved}
|
|
314
|
+
来源: ${result.provider}
|
|
315
|
+
启动策略: ${result.launcherStrategy}
|
|
316
|
+
工作区: ${result.workspaceMode}
|
|
317
|
+
源目录: ${result.sourceRoot}
|
|
318
|
+
|
|
319
|
+
摘要:
|
|
320
|
+
${result.summary}
|
|
321
|
+
|
|
322
|
+
执行详情:
|
|
323
|
+
${executionSummary}
|
|
324
|
+
|
|
325
|
+
${ambiguityText ? `歧义候选:\n${ambiguityText}\n\n` : ""}\
|
|
326
326
|
${result.warnings.length > 0 ? `警告: ${result.warnings.join(", ")}` : ""}`.trim();
|
|
327
327
|
const usageGuide = renderUsageGuide();
|
|
328
328
|
const structured = {
|
|
@@ -391,20 +391,20 @@ ${result.warnings.length > 0 ? `警告: ${result.warnings.join(", ")}` : ""}`.tr
|
|
|
391
391
|
`工作区模式: ${result.workspaceMode}`,
|
|
392
392
|
`来源目录: ${result.sourceRoot}`,
|
|
393
393
|
],
|
|
394
|
-
})}${message}
|
|
395
|
-
|
|
396
|
-
## delegated plan
|
|
397
|
-
${renderPlanSteps(delegatedPlan.steps)}
|
|
398
|
-
|
|
399
|
-
${delegatedPlan.kind === "docs" && projectDocs ? `后续操作:
|
|
400
|
-
- 如需落盘,写入 ${projectDocs.latestMarkdownFilePath} 与 ${projectDocs.latestJsonFilePath}
|
|
401
|
-
- 如需长期沉淀,可再补充 ${projectDocs.projectContextFilePath} 的图谱入口` : `后续操作:
|
|
402
|
-
- 请先从 candidates 中选定唯一符号
|
|
403
|
-
- 重新传入 uid 或 file_path 后再继续 context / impact 分析`}
|
|
404
|
-
|
|
394
|
+
})}${message}
|
|
395
|
+
|
|
396
|
+
## delegated plan
|
|
397
|
+
${renderPlanSteps(delegatedPlan.steps)}
|
|
398
|
+
|
|
399
|
+
${delegatedPlan.kind === "docs" && projectDocs ? `后续操作:
|
|
400
|
+
- 如需落盘,写入 ${projectDocs.latestMarkdownFilePath} 与 ${projectDocs.latestJsonFilePath}
|
|
401
|
+
- 如需长期沉淀,可再补充 ${projectDocs.projectContextFilePath} 的图谱入口` : `后续操作:
|
|
402
|
+
- 请先从 candidates 中选定唯一符号
|
|
403
|
+
- 重新传入 uid 或 file_path 后再继续 context / impact 分析`}
|
|
404
|
+
|
|
405
405
|
${usageGuide}`
|
|
406
|
-
: `${message}
|
|
407
|
-
|
|
406
|
+
: `${message}
|
|
407
|
+
|
|
408
408
|
${usageGuide}`, structured);
|
|
409
409
|
}
|
|
410
410
|
catch (error) {
|
|
@@ -2,6 +2,7 @@ import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
|
2
2
|
import { okText } from "../lib/response.js";
|
|
3
3
|
import { renderGuidanceHeader } from "../lib/guidance.js";
|
|
4
4
|
import { handleToolError } from "../utils/error-handler.js";
|
|
5
|
+
import { renderCodeLimits, renderBannedPatterns, CODE_LIMITS } from "../lib/quality-constraints.js";
|
|
5
6
|
// code_review 工具实现
|
|
6
7
|
export async function codeReview(args) {
|
|
7
8
|
try {
|
|
@@ -38,11 +39,13 @@ ${code || "请提供需要审查的代码"}
|
|
|
38
39
|
|
|
39
40
|
### 1️⃣ 代码质量检查
|
|
40
41
|
|
|
42
|
+
${renderCodeLimits()}
|
|
43
|
+
|
|
41
44
|
**代码坏味道(Code Smells)**:
|
|
42
45
|
- [ ] 重复代码(Duplicated Code)
|
|
43
|
-
- [ ] 过长函数(Long Function)>
|
|
44
|
-
- [ ] 过长参数列表(Long Parameter List)>
|
|
45
|
-
- [ ] 复杂条件判断(Complex Conditional)>
|
|
46
|
+
- [ ] 过长函数(Long Function)> ${CODE_LIMITS.maxFunctionLines} 行
|
|
47
|
+
- [ ] 过长参数列表(Long Parameter List)> ${CODE_LIMITS.maxParameters} 个
|
|
48
|
+
- [ ] 复杂条件判断(Complex Conditional)> ${CODE_LIMITS.maxNestingDepth} 层嵌套
|
|
46
49
|
- [ ] 魔法数字(Magic Numbers)
|
|
47
50
|
- [ ] 命名不清晰(Poor Naming)
|
|
48
51
|
|
|
@@ -88,7 +91,11 @@ ${code || "请提供需要审查的代码"}
|
|
|
88
91
|
- [ ] 大列表未虚拟化
|
|
89
92
|
- [ ] 状态管理不当
|
|
90
93
|
|
|
91
|
-
### 4️⃣
|
|
94
|
+
### 4️⃣ 完整性检查
|
|
95
|
+
|
|
96
|
+
${renderBannedPatterns()}
|
|
97
|
+
|
|
98
|
+
### 5️⃣ 最佳实践检查
|
|
92
99
|
|
|
93
100
|
**TypeScript/JavaScript**:
|
|
94
101
|
- [ ] 类型定义完整(避免 any)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { parseArgs, getString, getNumber, getBoolean } from '../utils/parseArgs.js';
|
|
2
|
+
import { okStructured } from '../lib/response.js';
|
|
3
|
+
import { handleToolError } from '../utils/error-handler.js';
|
|
4
|
+
import { createCursorHistoryClient } from '../lib/cursor-history-client.js';
|
|
5
|
+
export async function cursorReadConversation(args) {
|
|
6
|
+
try {
|
|
7
|
+
const parsed = parseArgs(args, {
|
|
8
|
+
defaultValues: {
|
|
9
|
+
composer_id: '',
|
|
10
|
+
limit: 200,
|
|
11
|
+
include_empty: false,
|
|
12
|
+
},
|
|
13
|
+
fieldAliases: {
|
|
14
|
+
composer_id: ['conversation_id', 'chat_id'],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const composerId = getString(parsed.composer_id).trim();
|
|
18
|
+
if (!composerId) {
|
|
19
|
+
throw new Error('缺少必填参数: composer_id');
|
|
20
|
+
}
|
|
21
|
+
const client = createCursorHistoryClient();
|
|
22
|
+
const conversation = await client.readConversation({
|
|
23
|
+
composerId,
|
|
24
|
+
limit: getNumber(parsed.limit, 200),
|
|
25
|
+
includeEmpty: getBoolean(parsed.include_empty, false),
|
|
26
|
+
});
|
|
27
|
+
return okStructured(`已读取 Cursor 会话 ${composerId},共 ${conversation.messages.length} 条消息。`, {
|
|
28
|
+
composerId,
|
|
29
|
+
messageCount: conversation.messages.length,
|
|
30
|
+
conversation,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return handleToolError(error, 'cursor_read_conversation');
|
|
35
|
+
}
|
|
36
|
+
}
|
package/build/tools/fix_bug.js
CHANGED
|
@@ -10,167 +10,167 @@ import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
|
10
10
|
import { okStructured } from "../lib/response.js";
|
|
11
11
|
import { renderGuidanceHeader } from "../lib/guidance.js";
|
|
12
12
|
import { handleToolError } from "../utils/error-handler.js";
|
|
13
|
-
const PROMPT_TEMPLATE = `# TBP 8 步 Bug 真因分析与修复指南
|
|
14
|
-
|
|
15
|
-
## 🐛 Bug 信息
|
|
16
|
-
|
|
17
|
-
**错误信息**:
|
|
18
|
-
\`\`\`
|
|
19
|
-
{error_message}
|
|
20
|
-
\`\`\`
|
|
21
|
-
|
|
22
|
-
{stack_trace_section}
|
|
23
|
-
|
|
24
|
-
{reproduce_section}
|
|
25
|
-
|
|
26
|
-
{behavior_section}
|
|
27
|
-
|
|
28
|
-
{code_context_section}
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## TBP-1 现象
|
|
33
|
-
|
|
34
|
-
先把用户可见的问题定义准确,避免“坏了/卡了/有问题”这类泛化描述。
|
|
35
|
-
|
|
36
|
-
要求:
|
|
37
|
-
1. 用 1-2 句定义现象
|
|
38
|
-
2. 明确是“慢”“停滞”“失败”“回归”还是“未生效”
|
|
39
|
-
3. 如果提供了期望/实际行为,必须纳入现象定义
|
|
40
|
-
|
|
41
|
-
## TBP-2 时间线
|
|
42
|
-
|
|
43
|
-
基于现有信息复盘事件顺序,至少回答:
|
|
44
|
-
1. 什么时候开始
|
|
45
|
-
2. 中间发生了什么
|
|
46
|
-
3. 最后停在什么状态
|
|
47
|
-
|
|
48
|
-
优先记录:
|
|
49
|
-
- 用户输入 / 复现步骤
|
|
50
|
-
- first progress / first error
|
|
51
|
-
- tool call / stack / stop / timeout
|
|
52
|
-
- 关键文件或模块
|
|
53
|
-
|
|
54
|
-
## TBP-3 不是这个
|
|
55
|
-
|
|
56
|
-
列出当前应优先排除的错误方向,并说明需要什么证据排除。
|
|
57
|
-
|
|
58
|
-
常见排除项:
|
|
59
|
-
- 不是单纯网络慢
|
|
60
|
-
- 不是前端展示截断
|
|
61
|
-
- 不是消息没转发
|
|
62
|
-
- 不是纯粹的超时表象
|
|
63
|
-
- 不是用户输入丢失
|
|
64
|
-
|
|
65
|
-
## TBP-4 共同模式
|
|
66
|
-
|
|
67
|
-
对比成功/失败样本,找出从哪一步开始分叉。
|
|
68
|
-
|
|
69
|
-
重点检查:
|
|
70
|
-
- 传输层
|
|
71
|
-
- 会话状态机
|
|
72
|
-
- 完成态判定
|
|
73
|
-
- 工具执行
|
|
74
|
-
- 文件写入
|
|
75
|
-
- 重试策略
|
|
76
|
-
|
|
77
|
-
## TBP-5 边界
|
|
78
|
-
|
|
79
|
-
明确指出问题失控落在哪一层:
|
|
80
|
-
- 上游模型 / SDK
|
|
81
|
-
- 网关状态机
|
|
82
|
-
- session 复用
|
|
83
|
-
- tool 执行层
|
|
84
|
-
- 文件系统
|
|
85
|
-
- 环境配置
|
|
86
|
-
- UI 展示层
|
|
87
|
-
|
|
88
|
-
## TBP-6 真因
|
|
89
|
-
|
|
90
|
-
真因必须写成因果句:
|
|
91
|
-
\`A + B 在条件 D 下导致了 C\`
|
|
92
|
-
|
|
93
|
-
不允许只写:
|
|
94
|
-
- 超时了
|
|
95
|
-
- SDK 有 bug
|
|
96
|
-
- 返回慢
|
|
97
|
-
|
|
98
|
-
## TBP-7 证据链
|
|
99
|
-
|
|
100
|
-
说明:
|
|
101
|
-
1. 哪些证据支持真因
|
|
102
|
-
2. 哪些现象若出现会推翻它,但现场没有出现
|
|
103
|
-
3. 为什么其他解释更弱
|
|
104
|
-
|
|
105
|
-
## TBP-8 修复
|
|
106
|
-
|
|
107
|
-
只有在证据链闭合后,才开始设计修复。
|
|
108
|
-
|
|
109
|
-
每个修复方案都要说明:
|
|
110
|
-
- 改哪一层
|
|
111
|
-
- 为什么这是修真因,不是补症状
|
|
112
|
-
- 风险是什么
|
|
113
|
-
- 怎么验证
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## 📤 输出格式要求
|
|
118
|
-
|
|
119
|
-
请严格按以下 JSON 格式输出修复指南:
|
|
120
|
-
|
|
121
|
-
\`\`\`json
|
|
122
|
-
{
|
|
123
|
-
"bug_summary": "Bug 简述(一句话)",
|
|
124
|
-
"analysis_mode": "tbp8",
|
|
125
|
-
"analysis": {
|
|
126
|
-
"error_type": "错误类型",
|
|
127
|
-
"direct_cause": "直接原因",
|
|
128
|
-
"root_cause": "根本原因",
|
|
129
|
-
"affected_scope": "影响范围"
|
|
130
|
-
},
|
|
131
|
-
"tbp": {
|
|
132
|
-
"phenomenon": "TBP-1 现象",
|
|
133
|
-
"timeline": [],
|
|
134
|
-
"ruled_out": [],
|
|
135
|
-
"common_pattern": "TBP-4 共同模式",
|
|
136
|
-
"boundary": "TBP-5 边界",
|
|
137
|
-
"root_cause_statement": "A + B 在条件 D 下导致 C",
|
|
138
|
-
"evidence": [],
|
|
139
|
-
"repair": []
|
|
140
|
-
},
|
|
141
|
-
"location": {
|
|
142
|
-
"file": "问题文件路径",
|
|
143
|
-
"line": 42,
|
|
144
|
-
"function": "问题函数名",
|
|
145
|
-
"code_snippet": "问题代码片段"
|
|
146
|
-
},
|
|
147
|
-
"fix_plan": {
|
|
148
|
-
"chosen_solution": "选择的修复方案",
|
|
149
|
-
"reason": "选择理由",
|
|
150
|
-
"steps": [
|
|
151
|
-
{ "step": 1, "action": "修复步骤", "file": "文件", "change": "变更内容" }
|
|
152
|
-
],
|
|
153
|
-
"code_before": "修改前代码",
|
|
154
|
-
"code_after": "修改后代码"
|
|
155
|
-
},
|
|
156
|
-
"verification": {
|
|
157
|
-
"test_cases": ["测试用例1", "测试用例2"],
|
|
158
|
-
"manual_checks": ["手动验证项1", "手动验证项2"]
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
\`\`\`
|
|
162
|
-
|
|
163
|
-
## ⚠️ 护栏
|
|
164
|
-
|
|
165
|
-
- 不要一看到新现象就补一个新分支,先判断是不是同一类根因在换表现
|
|
166
|
-
- 不要把“超时”直接当真因,要先分清是没进展、慢进展,还是结果已出现但判定过严
|
|
167
|
-
- 不要只看单一样本就下结论,有对比样本时必须做对比
|
|
168
|
-
- 如果证据不足,要明确说明还缺什么证据
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
*指南版本: 2.0.0*
|
|
173
|
-
*工具: MCP Probe Kit - fix_bug*
|
|
13
|
+
const PROMPT_TEMPLATE = `# TBP 8 步 Bug 真因分析与修复指南
|
|
14
|
+
|
|
15
|
+
## 🐛 Bug 信息
|
|
16
|
+
|
|
17
|
+
**错误信息**:
|
|
18
|
+
\`\`\`
|
|
19
|
+
{error_message}
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
{stack_trace_section}
|
|
23
|
+
|
|
24
|
+
{reproduce_section}
|
|
25
|
+
|
|
26
|
+
{behavior_section}
|
|
27
|
+
|
|
28
|
+
{code_context_section}
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## TBP-1 现象
|
|
33
|
+
|
|
34
|
+
先把用户可见的问题定义准确,避免“坏了/卡了/有问题”这类泛化描述。
|
|
35
|
+
|
|
36
|
+
要求:
|
|
37
|
+
1. 用 1-2 句定义现象
|
|
38
|
+
2. 明确是“慢”“停滞”“失败”“回归”还是“未生效”
|
|
39
|
+
3. 如果提供了期望/实际行为,必须纳入现象定义
|
|
40
|
+
|
|
41
|
+
## TBP-2 时间线
|
|
42
|
+
|
|
43
|
+
基于现有信息复盘事件顺序,至少回答:
|
|
44
|
+
1. 什么时候开始
|
|
45
|
+
2. 中间发生了什么
|
|
46
|
+
3. 最后停在什么状态
|
|
47
|
+
|
|
48
|
+
优先记录:
|
|
49
|
+
- 用户输入 / 复现步骤
|
|
50
|
+
- first progress / first error
|
|
51
|
+
- tool call / stack / stop / timeout
|
|
52
|
+
- 关键文件或模块
|
|
53
|
+
|
|
54
|
+
## TBP-3 不是这个
|
|
55
|
+
|
|
56
|
+
列出当前应优先排除的错误方向,并说明需要什么证据排除。
|
|
57
|
+
|
|
58
|
+
常见排除项:
|
|
59
|
+
- 不是单纯网络慢
|
|
60
|
+
- 不是前端展示截断
|
|
61
|
+
- 不是消息没转发
|
|
62
|
+
- 不是纯粹的超时表象
|
|
63
|
+
- 不是用户输入丢失
|
|
64
|
+
|
|
65
|
+
## TBP-4 共同模式
|
|
66
|
+
|
|
67
|
+
对比成功/失败样本,找出从哪一步开始分叉。
|
|
68
|
+
|
|
69
|
+
重点检查:
|
|
70
|
+
- 传输层
|
|
71
|
+
- 会话状态机
|
|
72
|
+
- 完成态判定
|
|
73
|
+
- 工具执行
|
|
74
|
+
- 文件写入
|
|
75
|
+
- 重试策略
|
|
76
|
+
|
|
77
|
+
## TBP-5 边界
|
|
78
|
+
|
|
79
|
+
明确指出问题失控落在哪一层:
|
|
80
|
+
- 上游模型 / SDK
|
|
81
|
+
- 网关状态机
|
|
82
|
+
- session 复用
|
|
83
|
+
- tool 执行层
|
|
84
|
+
- 文件系统
|
|
85
|
+
- 环境配置
|
|
86
|
+
- UI 展示层
|
|
87
|
+
|
|
88
|
+
## TBP-6 真因
|
|
89
|
+
|
|
90
|
+
真因必须写成因果句:
|
|
91
|
+
\`A + B 在条件 D 下导致了 C\`
|
|
92
|
+
|
|
93
|
+
不允许只写:
|
|
94
|
+
- 超时了
|
|
95
|
+
- SDK 有 bug
|
|
96
|
+
- 返回慢
|
|
97
|
+
|
|
98
|
+
## TBP-7 证据链
|
|
99
|
+
|
|
100
|
+
说明:
|
|
101
|
+
1. 哪些证据支持真因
|
|
102
|
+
2. 哪些现象若出现会推翻它,但现场没有出现
|
|
103
|
+
3. 为什么其他解释更弱
|
|
104
|
+
|
|
105
|
+
## TBP-8 修复
|
|
106
|
+
|
|
107
|
+
只有在证据链闭合后,才开始设计修复。
|
|
108
|
+
|
|
109
|
+
每个修复方案都要说明:
|
|
110
|
+
- 改哪一层
|
|
111
|
+
- 为什么这是修真因,不是补症状
|
|
112
|
+
- 风险是什么
|
|
113
|
+
- 怎么验证
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 📤 输出格式要求
|
|
118
|
+
|
|
119
|
+
请严格按以下 JSON 格式输出修复指南:
|
|
120
|
+
|
|
121
|
+
\`\`\`json
|
|
122
|
+
{
|
|
123
|
+
"bug_summary": "Bug 简述(一句话)",
|
|
124
|
+
"analysis_mode": "tbp8",
|
|
125
|
+
"analysis": {
|
|
126
|
+
"error_type": "错误类型",
|
|
127
|
+
"direct_cause": "直接原因",
|
|
128
|
+
"root_cause": "根本原因",
|
|
129
|
+
"affected_scope": "影响范围"
|
|
130
|
+
},
|
|
131
|
+
"tbp": {
|
|
132
|
+
"phenomenon": "TBP-1 现象",
|
|
133
|
+
"timeline": [],
|
|
134
|
+
"ruled_out": [],
|
|
135
|
+
"common_pattern": "TBP-4 共同模式",
|
|
136
|
+
"boundary": "TBP-5 边界",
|
|
137
|
+
"root_cause_statement": "A + B 在条件 D 下导致 C",
|
|
138
|
+
"evidence": [],
|
|
139
|
+
"repair": []
|
|
140
|
+
},
|
|
141
|
+
"location": {
|
|
142
|
+
"file": "问题文件路径",
|
|
143
|
+
"line": 42,
|
|
144
|
+
"function": "问题函数名",
|
|
145
|
+
"code_snippet": "问题代码片段"
|
|
146
|
+
},
|
|
147
|
+
"fix_plan": {
|
|
148
|
+
"chosen_solution": "选择的修复方案",
|
|
149
|
+
"reason": "选择理由",
|
|
150
|
+
"steps": [
|
|
151
|
+
{ "step": 1, "action": "修复步骤", "file": "文件", "change": "变更内容" }
|
|
152
|
+
],
|
|
153
|
+
"code_before": "修改前代码",
|
|
154
|
+
"code_after": "修改后代码"
|
|
155
|
+
},
|
|
156
|
+
"verification": {
|
|
157
|
+
"test_cases": ["测试用例1", "测试用例2"],
|
|
158
|
+
"manual_checks": ["手动验证项1", "手动验证项2"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
\`\`\`
|
|
162
|
+
|
|
163
|
+
## ⚠️ 护栏
|
|
164
|
+
|
|
165
|
+
- 不要一看到新现象就补一个新分支,先判断是不是同一类根因在换表现
|
|
166
|
+
- 不要把“超时”直接当真因,要先分清是没进展、慢进展,还是结果已出现但判定过严
|
|
167
|
+
- 不要只看单一样本就下结论,有对比样本时必须做对比
|
|
168
|
+
- 如果证据不足,要明确说明还缺什么证据
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
*指南版本: 2.0.0*
|
|
173
|
+
*工具: MCP Probe Kit - fix_bug*
|
|
174
174
|
`;
|
|
175
175
|
function inferBugType(text) {
|
|
176
176
|
if (/timeout|latency|slow|卡|慢|超时/i.test(text))
|