mcp-probe-kit 3.0.18 → 3.0.19
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 +75 -50
- package/build/lib/__tests__/agents-md-template.unit.test.d.ts +1 -0
- package/build/lib/__tests__/agents-md-template.unit.test.js +25 -0
- package/build/lib/__tests__/project-context-layout.unit.test.d.ts +1 -0
- package/build/lib/__tests__/project-context-layout.unit.test.js +80 -0
- package/build/lib/agents-md-template.d.ts +25 -0
- package/build/lib/agents-md-template.js +55 -0
- package/build/lib/memory-orchestration.d.ts +3 -1
- package/build/lib/memory-orchestration.js +71 -5
- package/build/lib/merge-agents-md.d.ts +6 -0
- package/build/lib/merge-agents-md.js +51 -0
- package/build/lib/project-context-layout.d.ts +78 -0
- package/build/lib/project-context-layout.js +350 -0
- package/build/lib/workspace-root.js +6 -1
- package/build/resources/ui-ux-data/metadata.json +1 -1
- package/build/schemas/index.d.ts +25 -3
- package/build/schemas/memory-tools.d.ts +1 -1
- package/build/schemas/memory-tools.js +1 -1
- package/build/schemas/project-tools.d.ts +24 -2
- package/build/schemas/project-tools.js +24 -2
- package/build/tools/__tests__/code_insight.unit.test.js +3 -3
- package/build/tools/__tests__/init_project_context.unit.test.js +32 -21
- package/build/tools/__tests__/start_feature.unit.test.js +2 -1
- package/build/tools/code_insight.js +11 -9
- package/build/tools/init_project_context.js +563 -506
- package/build/tools/start_bugfix.js +254 -248
- package/build/tools/start_feature.js +137 -131
- package/build/tools/start_ui.js +402 -402
- package/docs/.mcp-probe/layout.json +11 -0
- package/docs/i18n/en.json +36 -5
- package/docs/i18n/ja.json +9 -2
- package/docs/i18n/ko.json +9 -2
- package/docs/i18n/zh-CN.json +36 -5
- package/docs/memory-local-setup.md +314 -0
- package/docs/memory-local-setup.zh-CN.md +280 -0
- package/docs/pages/getting-started.html +249 -31
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
2
|
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
4
3
|
import { okStructured } from "../lib/response.js";
|
|
5
4
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
@@ -8,6 +7,7 @@ import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-conte
|
|
|
8
7
|
import { buildBugfixGraphContext } from "../lib/gitnexus-bridge.js";
|
|
9
8
|
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, } from "../lib/memory-orchestration.js";
|
|
10
9
|
import { resolveWorkspaceRoot, isLikelyProjectNamedRelativePath, buildProjectRootRetryHint } from "../lib/workspace-root.js";
|
|
10
|
+
import { layoutAbsPath, parseLayoutArgsFromRecord, resolveProjectContextLayout, } from "../lib/project-context-layout.js";
|
|
11
11
|
function decideTemplateProfile(description) {
|
|
12
12
|
const text = description || '';
|
|
13
13
|
const lengthScore = text.length >= 200 ? 2 : text.length >= 120 ? 1 : 0;
|
|
@@ -46,232 +46,232 @@ function resolveTemplateProfile(rawProfile, description) {
|
|
|
46
46
|
warning: `模板档位 "${rawProfile}" 不支持,已回退为 ${fallback}`,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
const PROMPT_TEMPLATE_GUIDED = `# 🐛 Bug 修复编排指南(TBP 8 步真因分析)
|
|
50
|
-
|
|
51
|
-
## 🎯 目标
|
|
52
|
-
|
|
53
|
-
修复以下 Bug:
|
|
54
|
-
|
|
55
|
-
**错误信息**:
|
|
56
|
-
\`\`\`
|
|
57
|
-
{error_message}
|
|
58
|
-
\`\`\`
|
|
59
|
-
|
|
60
|
-
{stack_trace_section}
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## 📋 步骤 0: 项目上下文与取证基线(自动处理)
|
|
65
|
-
|
|
66
|
-
**操作**:
|
|
67
|
-
1. 检查 \`docs/project-context.md\` 是否存在
|
|
68
|
-
2. 检查 \`docs/graph-insights/latest.md\` 和 \`docs/graph-insights/latest.json\` 是否存在
|
|
69
|
-
3. **如果任一缺失**:
|
|
70
|
-
- 调用 \`init_project_context\` 工具
|
|
71
|
-
- 等待生成完成
|
|
72
|
-
4. **读取** \`docs/project-context.md\` 与图谱文档
|
|
73
|
-
5. 了解项目的技术栈、架构、测试框架和调用链
|
|
74
|
-
6. 后续步骤参考此上下文
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## 🔍 步骤 1: 先做 TBP 1-7,再决定修复
|
|
79
|
-
|
|
80
|
-
**调用工具**: \`fix_bug\`
|
|
81
|
-
|
|
82
|
-
**参数**:
|
|
83
|
-
\`\`\`json
|
|
84
|
-
{
|
|
85
|
-
"error_message": "{error_message}",
|
|
86
|
-
"stack_trace": "{stack_trace}"
|
|
87
|
-
}
|
|
88
|
-
\`\`\`
|
|
89
|
-
|
|
90
|
-
**执行要点**:
|
|
91
|
-
1. 先定义现象,不能泛化
|
|
92
|
-
2. 复盘时间线,尽量带时间/步骤/状态
|
|
93
|
-
3. 明确排除错误方向,并说明为什么不是
|
|
94
|
-
4. 对比成功/失败样本,找分叉点
|
|
95
|
-
5. 定位问题边界(模型 / 状态机 / 工具 / 文件 / 环境)
|
|
96
|
-
6. 用因果句陈述真因:A + B 在条件 D 下导致 C
|
|
97
|
-
7. 闭合证据链后,才进入修复设计
|
|
98
|
-
8. 修复必须说明风险与验证方式
|
|
99
|
-
|
|
100
|
-
**产出**: 修复后的代码
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## 🧪 步骤 2: 生成回归测试
|
|
105
|
-
|
|
106
|
-
**调用工具**: \`gentest\`
|
|
107
|
-
|
|
108
|
-
**参数**:
|
|
109
|
-
\`\`\`json
|
|
110
|
-
{
|
|
111
|
-
"code": "[修复后的代码]",
|
|
112
|
-
"framework": "[根据项目上下文选择: jest/vitest/mocha]"
|
|
113
|
-
}
|
|
114
|
-
\`\`\`
|
|
115
|
-
|
|
116
|
-
**执行要点**:
|
|
117
|
-
1. 为修复的代码生成测试
|
|
118
|
-
2. 包含 Bug 场景的测试用例
|
|
119
|
-
3. 包含边界情况测试
|
|
120
|
-
|
|
121
|
-
**产出**: 测试代码
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## ✅ 完成检查
|
|
126
|
-
|
|
127
|
-
- [ ] 项目上下文已读取
|
|
128
|
-
- [ ] TBP-1~TBP-7 已闭合
|
|
129
|
-
- [ ] 真因已写成因果句
|
|
130
|
-
- [ ] 代码已修复
|
|
131
|
-
- [ ] 测试已添加
|
|
132
|
-
- [ ] 测试已通过
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## 📝 输出汇总
|
|
137
|
-
|
|
138
|
-
完成后,向用户汇总:
|
|
139
|
-
|
|
140
|
-
1. **TBP 现象**: [精确定义的问题]
|
|
141
|
-
2. **TBP 时间线**: [关键事件顺序]
|
|
142
|
-
3. **已排除方向**: [不是哪些原因]
|
|
143
|
-
4. **问题边界**: [失控发生在哪一层]
|
|
144
|
-
5. **Bug 真因**: [根本原因]
|
|
145
|
-
6. **修复方案**: [修复说明]
|
|
146
|
-
7. **修改文件**: [文件列表]
|
|
147
|
-
8. **测试覆盖**: [测试情况]
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
*编排工具: MCP Probe Kit - start_bugfix*
|
|
49
|
+
const PROMPT_TEMPLATE_GUIDED = `# 🐛 Bug 修复编排指南(TBP 8 步真因分析)
|
|
50
|
+
|
|
51
|
+
## 🎯 目标
|
|
52
|
+
|
|
53
|
+
修复以下 Bug:
|
|
54
|
+
|
|
55
|
+
**错误信息**:
|
|
56
|
+
\`\`\`
|
|
57
|
+
{error_message}
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
{stack_trace_section}
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 📋 步骤 0: 项目上下文与取证基线(自动处理)
|
|
65
|
+
|
|
66
|
+
**操作**:
|
|
67
|
+
1. 检查 \`docs/project-context.md\` 是否存在
|
|
68
|
+
2. 检查 \`docs/graph-insights/latest.md\` 和 \`docs/graph-insights/latest.json\` 是否存在
|
|
69
|
+
3. **如果任一缺失**:
|
|
70
|
+
- 调用 \`init_project_context\` 工具
|
|
71
|
+
- 等待生成完成
|
|
72
|
+
4. **读取** \`docs/project-context.md\` 与图谱文档
|
|
73
|
+
5. 了解项目的技术栈、架构、测试框架和调用链
|
|
74
|
+
6. 后续步骤参考此上下文
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🔍 步骤 1: 先做 TBP 1-7,再决定修复
|
|
79
|
+
|
|
80
|
+
**调用工具**: \`fix_bug\`
|
|
81
|
+
|
|
82
|
+
**参数**:
|
|
83
|
+
\`\`\`json
|
|
84
|
+
{
|
|
85
|
+
"error_message": "{error_message}",
|
|
86
|
+
"stack_trace": "{stack_trace}"
|
|
87
|
+
}
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
**执行要点**:
|
|
91
|
+
1. 先定义现象,不能泛化
|
|
92
|
+
2. 复盘时间线,尽量带时间/步骤/状态
|
|
93
|
+
3. 明确排除错误方向,并说明为什么不是
|
|
94
|
+
4. 对比成功/失败样本,找分叉点
|
|
95
|
+
5. 定位问题边界(模型 / 状态机 / 工具 / 文件 / 环境)
|
|
96
|
+
6. 用因果句陈述真因:A + B 在条件 D 下导致 C
|
|
97
|
+
7. 闭合证据链后,才进入修复设计
|
|
98
|
+
8. 修复必须说明风险与验证方式
|
|
99
|
+
|
|
100
|
+
**产出**: 修复后的代码
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🧪 步骤 2: 生成回归测试
|
|
105
|
+
|
|
106
|
+
**调用工具**: \`gentest\`
|
|
107
|
+
|
|
108
|
+
**参数**:
|
|
109
|
+
\`\`\`json
|
|
110
|
+
{
|
|
111
|
+
"code": "[修复后的代码]",
|
|
112
|
+
"framework": "[根据项目上下文选择: jest/vitest/mocha]"
|
|
113
|
+
}
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
**执行要点**:
|
|
117
|
+
1. 为修复的代码生成测试
|
|
118
|
+
2. 包含 Bug 场景的测试用例
|
|
119
|
+
3. 包含边界情况测试
|
|
120
|
+
|
|
121
|
+
**产出**: 测试代码
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## ✅ 完成检查
|
|
126
|
+
|
|
127
|
+
- [ ] 项目上下文已读取
|
|
128
|
+
- [ ] TBP-1~TBP-7 已闭合
|
|
129
|
+
- [ ] 真因已写成因果句
|
|
130
|
+
- [ ] 代码已修复
|
|
131
|
+
- [ ] 测试已添加
|
|
132
|
+
- [ ] 测试已通过
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📝 输出汇总
|
|
137
|
+
|
|
138
|
+
完成后,向用户汇总:
|
|
139
|
+
|
|
140
|
+
1. **TBP 现象**: [精确定义的问题]
|
|
141
|
+
2. **TBP 时间线**: [关键事件顺序]
|
|
142
|
+
3. **已排除方向**: [不是哪些原因]
|
|
143
|
+
4. **问题边界**: [失控发生在哪一层]
|
|
144
|
+
5. **Bug 真因**: [根本原因]
|
|
145
|
+
6. **修复方案**: [修复说明]
|
|
146
|
+
7. **修改文件**: [文件列表]
|
|
147
|
+
8. **测试覆盖**: [测试情况]
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
*编排工具: MCP Probe Kit - start_bugfix*
|
|
152
152
|
`;
|
|
153
|
-
const PROMPT_TEMPLATE_STRICT = `# 🐛 Bug 修复编排(严格 | TBP 8 步)
|
|
154
|
-
|
|
155
|
-
## 🎯 目标
|
|
156
|
-
修复 Bug:{error_message}
|
|
157
|
-
|
|
158
|
-
{stack_trace_section}
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## ✅ 执行计划(按顺序)
|
|
163
|
-
|
|
164
|
-
1) 检查 \`docs/project-context.md\` 与 \`docs/graph-insights/latest.*\`,任一缺失则调用 \`init_project_context\`
|
|
165
|
-
2) 调用 \`fix_bug\`
|
|
166
|
-
\`\`\`json
|
|
167
|
-
{
|
|
168
|
-
"error_message": "{error_message}",
|
|
169
|
-
"stack_trace": "{stack_trace}",
|
|
170
|
-
"analysis_mode": "{analysis_mode}"
|
|
171
|
-
}
|
|
172
|
-
\`\`\`
|
|
173
|
-
3) 调用 \`gentest\`
|
|
174
|
-
\`\`\`json
|
|
175
|
-
{
|
|
176
|
-
"code": "[修复后的代码]",
|
|
177
|
-
"framework": "[根据项目上下文选择: jest/vitest/mocha]"
|
|
178
|
-
}
|
|
179
|
-
\`\`\`
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## ✅ 输出汇总
|
|
184
|
-
1. TBP 现象
|
|
185
|
-
2. TBP 时间线
|
|
186
|
-
3. 已排除方向
|
|
187
|
-
4. 问题边界
|
|
188
|
-
5. Bug 真因
|
|
189
|
-
6. 修复方案
|
|
190
|
-
7. 修改文件
|
|
191
|
-
8. 测试覆盖
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
*编排工具: MCP Probe Kit - start_bugfix*
|
|
153
|
+
const PROMPT_TEMPLATE_STRICT = `# 🐛 Bug 修复编排(严格 | TBP 8 步)
|
|
154
|
+
|
|
155
|
+
## 🎯 目标
|
|
156
|
+
修复 Bug:{error_message}
|
|
157
|
+
|
|
158
|
+
{stack_trace_section}
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## ✅ 执行计划(按顺序)
|
|
163
|
+
|
|
164
|
+
1) 检查 \`docs/project-context.md\` 与 \`docs/graph-insights/latest.*\`,任一缺失则调用 \`init_project_context\`
|
|
165
|
+
2) 调用 \`fix_bug\`
|
|
166
|
+
\`\`\`json
|
|
167
|
+
{
|
|
168
|
+
"error_message": "{error_message}",
|
|
169
|
+
"stack_trace": "{stack_trace}",
|
|
170
|
+
"analysis_mode": "{analysis_mode}"
|
|
171
|
+
}
|
|
172
|
+
\`\`\`
|
|
173
|
+
3) 调用 \`gentest\`
|
|
174
|
+
\`\`\`json
|
|
175
|
+
{
|
|
176
|
+
"code": "[修复后的代码]",
|
|
177
|
+
"framework": "[根据项目上下文选择: jest/vitest/mocha]"
|
|
178
|
+
}
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## ✅ 输出汇总
|
|
184
|
+
1. TBP 现象
|
|
185
|
+
2. TBP 时间线
|
|
186
|
+
3. 已排除方向
|
|
187
|
+
4. 问题边界
|
|
188
|
+
5. Bug 真因
|
|
189
|
+
6. 修复方案
|
|
190
|
+
7. 修改文件
|
|
191
|
+
8. 测试覆盖
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
*编排工具: MCP Probe Kit - start_bugfix*
|
|
196
196
|
`;
|
|
197
|
-
const LOOP_PROMPT_TEMPLATE_GUIDED = `# 🧭 Bug 需求澄清与补全(TBP RCA Loop)
|
|
198
|
-
|
|
199
|
-
本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐 TBP 8 步真因分析所需证据。
|
|
200
|
-
|
|
201
|
-
## 🎯 目标
|
|
202
|
-
修复 Bug:{error_message}
|
|
203
|
-
|
|
204
|
-
## ✅ 规则
|
|
205
|
-
1. **不覆盖用户原始描述**
|
|
206
|
-
2. **补全内容必须标注来源**(User / Derived / Assumption)
|
|
207
|
-
3. **假设必须进入待确认列表**
|
|
208
|
-
4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 🔁 执行步骤(每轮)
|
|
213
|
-
|
|
214
|
-
### 1) 生成待确认问题
|
|
215
|
-
使用 \`ask_user\` 提问,问题来源于 TBP 清单(现象/时间线/对比样本/边界/验证)。
|
|
216
|
-
|
|
217
|
-
**调用示例**:
|
|
218
|
-
\`\`\`json
|
|
219
|
-
{
|
|
220
|
-
"questions": [
|
|
221
|
-
{ "question": "复现步骤是什么?", "context": "复现步骤", "required": true },
|
|
222
|
-
{ "question": "期望行为是什么?", "context": "期望行为", "required": true }
|
|
223
|
-
]
|
|
224
|
-
}
|
|
225
|
-
\`\`\`
|
|
226
|
-
|
|
227
|
-
### 2) 更新结构化输出
|
|
228
|
-
将回答补入 \`requirements\`,并标注来源:
|
|
229
|
-
- User:用户明确回答
|
|
230
|
-
- Derived:合理推导
|
|
231
|
-
- Assumption:无法确认但补全(需确认)
|
|
232
|
-
|
|
233
|
-
### 3) 自检与结束
|
|
234
|
-
若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入 TBP-6/7/8 修复流程。
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## ✅ 结束后继续
|
|
239
|
-
当满足结束条件时,执行:
|
|
240
|
-
1. 调用 \`fix_bug\` 完成 TBP 8 步分析与修复方案
|
|
241
|
-
2. 调用 \`gentest\` 生成回归测试
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
*编排工具: MCP Probe Kit - start_bugfix (requirements loop)*
|
|
197
|
+
const LOOP_PROMPT_TEMPLATE_GUIDED = `# 🧭 Bug 需求澄清与补全(TBP RCA Loop)
|
|
198
|
+
|
|
199
|
+
本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐 TBP 8 步真因分析所需证据。
|
|
200
|
+
|
|
201
|
+
## 🎯 目标
|
|
202
|
+
修复 Bug:{error_message}
|
|
203
|
+
|
|
204
|
+
## ✅ 规则
|
|
205
|
+
1. **不覆盖用户原始描述**
|
|
206
|
+
2. **补全内容必须标注来源**(User / Derived / Assumption)
|
|
207
|
+
3. **假设必须进入待确认列表**
|
|
208
|
+
4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🔁 执行步骤(每轮)
|
|
213
|
+
|
|
214
|
+
### 1) 生成待确认问题
|
|
215
|
+
使用 \`ask_user\` 提问,问题来源于 TBP 清单(现象/时间线/对比样本/边界/验证)。
|
|
216
|
+
|
|
217
|
+
**调用示例**:
|
|
218
|
+
\`\`\`json
|
|
219
|
+
{
|
|
220
|
+
"questions": [
|
|
221
|
+
{ "question": "复现步骤是什么?", "context": "复现步骤", "required": true },
|
|
222
|
+
{ "question": "期望行为是什么?", "context": "期望行为", "required": true }
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
\`\`\`
|
|
226
|
+
|
|
227
|
+
### 2) 更新结构化输出
|
|
228
|
+
将回答补入 \`requirements\`,并标注来源:
|
|
229
|
+
- User:用户明确回答
|
|
230
|
+
- Derived:合理推导
|
|
231
|
+
- Assumption:无法确认但补全(需确认)
|
|
232
|
+
|
|
233
|
+
### 3) 自检与结束
|
|
234
|
+
若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入 TBP-6/7/8 修复流程。
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## ✅ 结束后继续
|
|
239
|
+
当满足结束条件时,执行:
|
|
240
|
+
1. 调用 \`fix_bug\` 完成 TBP 8 步分析与修复方案
|
|
241
|
+
2. 调用 \`gentest\` 生成回归测试
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
*编排工具: MCP Probe Kit - start_bugfix (requirements loop)*
|
|
246
246
|
`;
|
|
247
|
-
const LOOP_PROMPT_TEMPLATE_STRICT = `# 🧭 Bug 需求澄清与补全(TBP RCA Loop | 严格)
|
|
248
|
-
|
|
249
|
-
本模式用于稳健补全关键信息,不改变用户意图。
|
|
250
|
-
|
|
251
|
-
## 🎯 目标
|
|
252
|
-
修复 Bug:{error_message}
|
|
253
|
-
|
|
254
|
-
## ✅ 规则
|
|
255
|
-
1. 不覆盖用户原始描述
|
|
256
|
-
2. 补全内容标注来源(User / Derived / Assumption)
|
|
257
|
-
3. 假设进入待确认列表
|
|
258
|
-
4. 每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}
|
|
259
|
-
|
|
260
|
-
---
|
|
261
|
-
|
|
262
|
-
## 🔁 执行步骤(每轮)
|
|
263
|
-
1) 使用 \`ask_user\` 提问补全关键信息
|
|
264
|
-
2) 更新结构化输出并标注来源
|
|
265
|
-
3) 若 \`openQuestions\` 为空且无高风险假设则结束
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
|
-
## ✅ 结束后继续
|
|
270
|
-
当满足结束条件时,调用 \`fix_bug\` 与 \`gentest\`
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
*编排工具: MCP Probe Kit - start_bugfix (requirements loop)*
|
|
247
|
+
const LOOP_PROMPT_TEMPLATE_STRICT = `# 🧭 Bug 需求澄清与补全(TBP RCA Loop | 严格)
|
|
248
|
+
|
|
249
|
+
本模式用于稳健补全关键信息,不改变用户意图。
|
|
250
|
+
|
|
251
|
+
## 🎯 目标
|
|
252
|
+
修复 Bug:{error_message}
|
|
253
|
+
|
|
254
|
+
## ✅ 规则
|
|
255
|
+
1. 不覆盖用户原始描述
|
|
256
|
+
2. 补全内容标注来源(User / Derived / Assumption)
|
|
257
|
+
3. 假设进入待确认列表
|
|
258
|
+
4. 每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 🔁 执行步骤(每轮)
|
|
263
|
+
1) 使用 \`ask_user\` 提问补全关键信息
|
|
264
|
+
2) 更新结构化输出并标注来源
|
|
265
|
+
3) 若 \`openQuestions\` 为空且无高风险假设则结束
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## ✅ 结束后继续
|
|
270
|
+
当满足结束条件时,调用 \`fix_bug\` 与 \`gentest\`
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
*编排工具: MCP Probe Kit - start_bugfix (requirements loop)*
|
|
275
275
|
`;
|
|
276
276
|
function buildBugfixQuestions(questionBudget) {
|
|
277
277
|
const base = [
|
|
@@ -319,6 +319,7 @@ export async function startBugfix(args, context) {
|
|
|
319
319
|
const stackTrace = getString(parsedArgs.stack_trace);
|
|
320
320
|
const codeContext = getString(parsedArgs.code_context);
|
|
321
321
|
const projectRoot = getString(parsedArgs.project_root);
|
|
322
|
+
const docsDir = getString(parsedArgs.docs_dir) || "docs";
|
|
322
323
|
if (isLikelyProjectNamedRelativePath(projectRoot)) {
|
|
323
324
|
return {
|
|
324
325
|
content: [{
|
|
@@ -371,15 +372,20 @@ export async function startBugfix(args, context) {
|
|
|
371
372
|
}
|
|
372
373
|
throwIfAborted(context?.signal, "start_bugfix 已取消");
|
|
373
374
|
await reportToolProgress(context, 55, "start_bugfix: 刷新图谱并收敛问题范围");
|
|
375
|
+
const resolvedProjectRoot = resolveWorkspaceRoot(projectRoot);
|
|
376
|
+
const layout = resolveProjectContextLayout(resolvedProjectRoot, parseLayoutArgsFromRecord({ docs_dir: docsDir }));
|
|
374
377
|
const graphDocs = {
|
|
375
|
-
latestMarkdownPath:
|
|
376
|
-
latestJsonPath:
|
|
378
|
+
latestMarkdownPath: layout.latestMarkdownPath,
|
|
379
|
+
latestJsonPath: layout.latestJsonPath,
|
|
377
380
|
};
|
|
378
|
-
const resolvedProjectRoot = resolveWorkspaceRoot(projectRoot);
|
|
379
381
|
const bootstrapState = {
|
|
380
|
-
projectContextExists: fs.existsSync(
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
projectContextExists: fs.existsSync(layoutAbsPath(layout, layout.indexPath)) ||
|
|
383
|
+
fs.existsSync(layoutAbsPath(layout, layout.legacyIndexPath)),
|
|
384
|
+
latestMarkdownExists: fs.existsSync(layoutAbsPath(layout, layout.latestMarkdownPath)),
|
|
385
|
+
latestJsonExists: fs.existsSync(layoutAbsPath(layout, layout.latestJsonPath)),
|
|
386
|
+
indexPath: layout.indexPath,
|
|
387
|
+
projectRoot: layout.projectRootPosix,
|
|
388
|
+
layoutManifest: layout.manifestPath,
|
|
383
389
|
};
|
|
384
390
|
const graphDocsMissing = !bootstrapState.latestMarkdownExists || !bootstrapState.latestJsonExists;
|
|
385
391
|
const graphContext = await buildBugfixGraphContext({
|
|
@@ -404,18 +410,18 @@ export async function startBugfix(args, context) {
|
|
|
404
410
|
]
|
|
405
411
|
.filter(Boolean)
|
|
406
412
|
.join("\n\n");
|
|
407
|
-
const graphGuideSection = `
|
|
408
|
-
|
|
409
|
-
## 🧠 代码图谱上下文
|
|
410
|
-
- 基线入口: ${graphDocs.latestMarkdownPath}
|
|
411
|
-
- 基线结构化副本: ${graphDocs.latestJsonPath}
|
|
412
|
-
- 基线状态: ${graphDocsMissing ? "缺失(需要补初始化)" : "可用"}
|
|
413
|
-
- 任务级收敛: ${graphContext.available ? "可用" : "降级"}
|
|
414
|
-
- 任务级摘要: ${graphContext.summary}
|
|
413
|
+
const graphGuideSection = `
|
|
414
|
+
|
|
415
|
+
## 🧠 代码图谱上下文
|
|
416
|
+
- 基线入口: ${graphDocs.latestMarkdownPath}
|
|
417
|
+
- 基线结构化副本: ${graphDocs.latestJsonPath}
|
|
418
|
+
- 基线状态: ${graphDocsMissing ? "缺失(需要补初始化)" : "可用"}
|
|
419
|
+
- 任务级收敛: ${graphContext.available ? "可用" : "降级"}
|
|
420
|
+
- 任务级摘要: ${graphContext.summary}
|
|
415
421
|
${graphContext.highlights.length > 0
|
|
416
422
|
? `- 任务级线索:\n${graphContext.highlights.slice(0, 3).map((item) => ` - ${item}`).join("\n")}`
|
|
417
|
-
: "- 任务级线索: 无"}
|
|
418
|
-
- 使用方式: 先读取基线图谱,再用本次任务图谱做 TBP-4 / TBP-5 / TBP-6 的边界与真因收敛
|
|
423
|
+
: "- 任务级线索: 无"}
|
|
424
|
+
- 使用方式: 先读取基线图谱,再用本次任务图谱做 TBP-4 / TBP-5 / TBP-6 的边界与真因收敛
|
|
419
425
|
`;
|
|
420
426
|
const memoryContext = await loadMemoryInjectionContext([errorMessage, stackTrace, codeContext].filter(Boolean).join("\n"));
|
|
421
427
|
const memoryGuideSection = renderMemoryGuideSection(memoryContext);
|
|
@@ -447,12 +453,12 @@ ${graphContext.highlights.length > 0
|
|
|
447
453
|
{
|
|
448
454
|
id: 'context',
|
|
449
455
|
tool: 'init_project_context',
|
|
450
|
-
when: `缺少
|
|
456
|
+
when: `缺少 ${layout.indexPath} 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
|
|
451
457
|
args: {
|
|
452
458
|
docs_dir: 'docs',
|
|
453
459
|
...(projectRoot ? { project_root: projectRoot } : {}),
|
|
454
460
|
},
|
|
455
|
-
outputs: [
|
|
461
|
+
outputs: [layout.indexPath, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
|
|
456
462
|
note: `兼容老项目:如果旧项目没有 graph-insights/latest.*,先补齐图谱初始化再进入 bug 收敛`,
|
|
457
463
|
},
|
|
458
464
|
{
|
|
@@ -494,7 +500,7 @@ ${graphContext.highlights.length > 0
|
|
|
494
500
|
},
|
|
495
501
|
outputs: [],
|
|
496
502
|
},
|
|
497
|
-
...(memoryContext.enabled ? [buildMemoryPlanStep()] : []),
|
|
503
|
+
...(memoryContext.enabled ? [buildMemoryPlanStep('bugfix')] : []),
|
|
498
504
|
],
|
|
499
505
|
};
|
|
500
506
|
const header = renderOrchestrationHeader({
|
|
@@ -590,12 +596,12 @@ ${graphContext.highlights.length > 0
|
|
|
590
596
|
{
|
|
591
597
|
id: 'context',
|
|
592
598
|
tool: 'init_project_context',
|
|
593
|
-
when: `缺少
|
|
599
|
+
when: `缺少 ${layout.indexPath} 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
|
|
594
600
|
args: {
|
|
595
|
-
docs_dir:
|
|
601
|
+
docs_dir: layout.contextRoot,
|
|
596
602
|
...(projectRoot ? { project_root: projectRoot } : {}),
|
|
597
603
|
},
|
|
598
|
-
outputs: [
|
|
604
|
+
outputs: [layout.indexPath, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
|
|
599
605
|
note: `兼容老项目:如果旧项目没有 graph-insights/latest.*,先补齐图谱初始化再进入 bug 收敛`,
|
|
600
606
|
},
|
|
601
607
|
{
|
|
@@ -618,7 +624,7 @@ ${graphContext.highlights.length > 0
|
|
|
618
624
|
},
|
|
619
625
|
outputs: [],
|
|
620
626
|
},
|
|
621
|
-
...(memoryContext.enabled ? [buildMemoryPlanStep()] : []),
|
|
627
|
+
...(memoryContext.enabled ? [buildMemoryPlanStep('bugfix')] : []),
|
|
622
628
|
],
|
|
623
629
|
};
|
|
624
630
|
// 创建结构化的 Bug 修复报告
|
|
@@ -630,7 +636,7 @@ ${graphContext.highlights.length > 0
|
|
|
630
636
|
{
|
|
631
637
|
name: '检查项目上下文',
|
|
632
638
|
status: 'pending',
|
|
633
|
-
description:
|
|
639
|
+
description: `检查 ${layout.indexPath} 与 graph-insights/latest.* 是否存在,缺失则调用 init_project_context`,
|
|
634
640
|
},
|
|
635
641
|
{
|
|
636
642
|
name: 'Bug 分析与修复',
|