mcp-probe-kit 3.0.5 → 3.0.7
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 +458 -431
- package/build/index.js +875 -141
- package/build/lib/gitnexus-bridge.d.ts +58 -0
- package/build/lib/gitnexus-bridge.js +379 -0
- package/build/lib/template-loader.js +317 -317
- package/build/lib/tool-execution-context.d.ts +8 -0
- package/build/lib/tool-execution-context.js +20 -0
- package/build/lib/toolset-manager.d.ts +1 -1
- package/build/lib/toolset-manager.js +7 -5
- package/build/schemas/code-analysis-tools.d.ts +46 -0
- package/build/schemas/code-analysis-tools.js +47 -0
- package/build/schemas/git-tools.js +16 -16
- package/build/schemas/index.d.ts +46 -0
- package/build/tools/__tests__/code_insight.unit.test.d.ts +1 -0
- package/build/tools/__tests__/code_insight.unit.test.js +35 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +14 -14
- package/build/tools/__tests__/start_ui.unit.test.js +11 -11
- package/build/tools/add_feature.js +79 -79
- package/build/tools/ask_user.js +5 -5
- package/build/tools/code_insight.d.ts +8 -0
- package/build/tools/code_insight.js +129 -0
- package/build/tools/index.d.ts +1 -0
- package/build/tools/index.js +1 -0
- package/build/tools/interview.js +9 -9
- package/build/tools/start_bugfix.d.ts +2 -1
- package/build/tools/start_bugfix.js +170 -126
- package/build/tools/start_feature.d.ts +2 -1
- package/build/tools/start_feature.js +156 -112
- package/build/tools/start_onboard.d.ts +2 -1
- package/build/tools/start_onboard.js +57 -51
- package/build/tools/start_product.d.ts +2 -1
- package/build/tools/start_product.js +9 -1
- package/build/tools/start_ralph.d.ts +2 -1
- package/build/tools/start_ralph.js +9 -3
- package/build/tools/start_ui.d.ts +2 -1
- package/build/tools/start_ui.js +102 -88
- package/build/tools/ui-ux-tools.d.ts +2 -1
- package/build/tools/ui-ux-tools.js +19 -3
- package/build/utils/ui-sync.d.ts +6 -2
- package/build/utils/ui-sync.js +125 -29
- package/docs/assets/font/MaterialSymbolsOutlined.codepoints +4102 -0
- package/docs/assets/font/MaterialSymbolsOutlined.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-400.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-700.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-900.ttf +0 -0
- package/docs/assets/js/i18n.js +122 -21
- package/docs/assets/js/tailwind.js +83 -83
- package/docs/data/tools.js +419 -399
- package/docs/debug-i18n.html +163 -0
- package/docs/i18n/all-tools/en.json +157 -0
- package/docs/i18n/all-tools/ja.json +157 -0
- package/docs/i18n/all-tools/ko.json +157 -0
- package/docs/i18n/all-tools/zh-CN.json +157 -0
- package/docs/pages/all-tools.html +514 -352
- package/docs/pages/examples.html +689 -689
- package/docs/pages/getting-started.html +589 -589
- package/docs/pages/migration.html +298 -298
- package/docs/specs/user-auth/design.md +82 -0
- package/docs/specs/user-auth/requirements.md +52 -0
- package/docs/specs/user-auth/tasks.md +55 -0
- package/package.json +5 -5
- package/docs/project-context/architecture.md +0 -0
- package/docs/project-context/how-to-develop.md +0 -313
- package/docs/project-context/how-to-test.md +0 -457
- package/docs/project-context/tech-stack.md +0 -96
- package/docs/project-context.md +0 -53
- package/docs/specs/git-work-report/design.md +0 -568
- package/docs/specs/git-work-report/requirements.md +0 -131
- package/docs/specs/git-work-report/tasks.md +0 -197
|
@@ -2,6 +2,8 @@ import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
|
2
2
|
import { okStructured } from "../lib/response.js";
|
|
3
3
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
4
4
|
import { FeatureReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
5
|
+
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
6
|
+
import { buildFeatureGraphContext } from "../lib/gitnexus-bridge.js";
|
|
5
7
|
/**
|
|
6
8
|
* start_feature 智能编排工具
|
|
7
9
|
*
|
|
@@ -48,110 +50,110 @@ function extractFeatureInfo(input) {
|
|
|
48
50
|
description: input,
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
const PROMPT_TEMPLATE = `# 🚀 新功能开发编排(委托式)
|
|
52
|
-
|
|
53
|
-
本工具仅生成 **执行计划(steps)**。AI 需要按顺序调用对应工具并落盘文档。
|
|
54
|
-
|
|
55
|
-
## 🎯 目标
|
|
56
|
-
开发新功能:**{feature_name}**
|
|
57
|
-
功能描述:{description}
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## ✅ 执行计划(按顺序)
|
|
62
|
-
|
|
63
|
-
### 0) 项目上下文(如缺失)
|
|
64
|
-
**检查**: \`{docs_dir}/project-context.md\`
|
|
65
|
-
**缺失则调用**: \`init_project_context\`
|
|
66
|
-
\`\`\`json
|
|
67
|
-
{ "docs_dir": "{docs_dir}" }
|
|
68
|
-
\`\`\`
|
|
69
|
-
|
|
70
|
-
### 1) 生成功能规格
|
|
71
|
-
**调用**: \`add_feature\`
|
|
72
|
-
\`\`\`json
|
|
73
|
-
{
|
|
74
|
-
"feature_name": "{feature_name}",
|
|
75
|
-
"description": "{description}",
|
|
76
|
-
"docs_dir": "{docs_dir}",
|
|
77
|
-
"template_profile": "{template_profile}"
|
|
78
|
-
}
|
|
79
|
-
\`\`\`
|
|
80
|
-
**预期输出**:
|
|
81
|
-
- \`{docs_dir}/specs/{feature_name}/requirements.md\`
|
|
82
|
-
- \`{docs_dir}/specs/{feature_name}/design.md\`
|
|
83
|
-
- \`{docs_dir}/specs/{feature_name}/tasks.md\`
|
|
84
|
-
|
|
85
|
-
### 2) 工作量估算
|
|
86
|
-
**调用**: \`estimate\`
|
|
87
|
-
\`\`\`json
|
|
88
|
-
{
|
|
89
|
-
"task_description": "实现 {feature_name} 功能:{description}",
|
|
90
|
-
"code_context": "参考生成的 tasks.md 中的任务列表"
|
|
91
|
-
}
|
|
92
|
-
\`\`\`
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## ✅ 输出汇总(执行完成后)
|
|
97
|
-
1. 规格文档位置: \`{docs_dir}/specs/{feature_name}/\`
|
|
98
|
-
2. 估算结果: 故事点 + 时间区间
|
|
99
|
-
3. 主要风险(如有)
|
|
100
|
-
4. 下一步: 按 tasks.md 开始开发
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
53
|
+
const PROMPT_TEMPLATE = `# 🚀 新功能开发编排(委托式)
|
|
54
|
+
|
|
55
|
+
本工具仅生成 **执行计划(steps)**。AI 需要按顺序调用对应工具并落盘文档。
|
|
56
|
+
|
|
57
|
+
## 🎯 目标
|
|
58
|
+
开发新功能:**{feature_name}**
|
|
59
|
+
功能描述:{description}
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ✅ 执行计划(按顺序)
|
|
64
|
+
|
|
65
|
+
### 0) 项目上下文(如缺失)
|
|
66
|
+
**检查**: \`{docs_dir}/project-context.md\`
|
|
67
|
+
**缺失则调用**: \`init_project_context\`
|
|
68
|
+
\`\`\`json
|
|
69
|
+
{ "docs_dir": "{docs_dir}" }
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
### 1) 生成功能规格
|
|
73
|
+
**调用**: \`add_feature\`
|
|
74
|
+
\`\`\`json
|
|
75
|
+
{
|
|
76
|
+
"feature_name": "{feature_name}",
|
|
77
|
+
"description": "{description}",
|
|
78
|
+
"docs_dir": "{docs_dir}",
|
|
79
|
+
"template_profile": "{template_profile}"
|
|
80
|
+
}
|
|
81
|
+
\`\`\`
|
|
82
|
+
**预期输出**:
|
|
83
|
+
- \`{docs_dir}/specs/{feature_name}/requirements.md\`
|
|
84
|
+
- \`{docs_dir}/specs/{feature_name}/design.md\`
|
|
85
|
+
- \`{docs_dir}/specs/{feature_name}/tasks.md\`
|
|
86
|
+
|
|
87
|
+
### 2) 工作量估算
|
|
88
|
+
**调用**: \`estimate\`
|
|
89
|
+
\`\`\`json
|
|
90
|
+
{
|
|
91
|
+
"task_description": "实现 {feature_name} 功能:{description}",
|
|
92
|
+
"code_context": "参考生成的 tasks.md 中的任务列表"
|
|
93
|
+
}
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ✅ 输出汇总(执行完成后)
|
|
99
|
+
1. 规格文档位置: \`{docs_dir}/specs/{feature_name}/\`
|
|
100
|
+
2. 估算结果: 故事点 + 时间区间
|
|
101
|
+
3. 主要风险(如有)
|
|
102
|
+
4. 下一步: 按 tasks.md 开始开发
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
104
106
|
*编排工具: MCP Probe Kit - start_feature*`;
|
|
105
|
-
const LOOP_PROMPT_TEMPLATE = `# 🧭 需求澄清与补全(Requirements Loop)
|
|
106
|
-
|
|
107
|
-
本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐关键要素,并输出可审计的结构化结果。
|
|
108
|
-
|
|
109
|
-
## 🎯 目标
|
|
110
|
-
开发新功能:**{feature_name}**
|
|
111
|
-
功能描述:{description}
|
|
112
|
-
|
|
113
|
-
## ✅ 规则
|
|
114
|
-
1. **不覆盖用户原始需求**
|
|
115
|
-
2. **补全内容必须标注来源**(User / Derived / Assumption)
|
|
116
|
-
3. **假设必须进入待确认列表**
|
|
117
|
-
4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## 🔁 执行步骤(每轮)
|
|
122
|
-
|
|
123
|
-
### 1) 生成待确认问题
|
|
124
|
-
使用 \`ask_user\` 提问,问题来源于“功能需求补全清单”(角色/触发/约束/异常/依赖等)。
|
|
125
|
-
|
|
126
|
-
**调用示例**:
|
|
127
|
-
\`\`\`json
|
|
128
|
-
{
|
|
129
|
-
"questions": [
|
|
130
|
-
{ "question": "目标用户或角色是谁?", "context": "角色定义", "required": true },
|
|
131
|
-
{ "question": "触发场景是什么?", "context": "业务场景", "required": true }
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
\`\`\`
|
|
135
|
-
|
|
136
|
-
### 2) 更新结构化输出
|
|
137
|
-
将回答补入 \`requirements\`,并标注来源:
|
|
138
|
-
- User:用户明确回答
|
|
139
|
-
- Derived:合理推导
|
|
140
|
-
- Assumption:无法确认但补全(需确认)
|
|
141
|
-
|
|
142
|
-
### 3) 自检与结束
|
|
143
|
-
若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入规格生成与估算。
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## ✅ 结束后继续
|
|
148
|
-
当满足结束条件时,执行:
|
|
149
|
-
1. 调用 \`add_feature\` 生成规格文档
|
|
150
|
-
2. 调用 \`estimate\` 进行工作量估算
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
*编排工具: MCP Probe Kit - start_feature (requirements loop)*
|
|
107
|
+
const LOOP_PROMPT_TEMPLATE = `# 🧭 需求澄清与补全(Requirements Loop)
|
|
108
|
+
|
|
109
|
+
本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐关键要素,并输出可审计的结构化结果。
|
|
110
|
+
|
|
111
|
+
## 🎯 目标
|
|
112
|
+
开发新功能:**{feature_name}**
|
|
113
|
+
功能描述:{description}
|
|
114
|
+
|
|
115
|
+
## ✅ 规则
|
|
116
|
+
1. **不覆盖用户原始需求**
|
|
117
|
+
2. **补全内容必须标注来源**(User / Derived / Assumption)
|
|
118
|
+
3. **假设必须进入待确认列表**
|
|
119
|
+
4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🔁 执行步骤(每轮)
|
|
124
|
+
|
|
125
|
+
### 1) 生成待确认问题
|
|
126
|
+
使用 \`ask_user\` 提问,问题来源于“功能需求补全清单”(角色/触发/约束/异常/依赖等)。
|
|
127
|
+
|
|
128
|
+
**调用示例**:
|
|
129
|
+
\`\`\`json
|
|
130
|
+
{
|
|
131
|
+
"questions": [
|
|
132
|
+
{ "question": "目标用户或角色是谁?", "context": "角色定义", "required": true },
|
|
133
|
+
{ "question": "触发场景是什么?", "context": "业务场景", "required": true }
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
### 2) 更新结构化输出
|
|
139
|
+
将回答补入 \`requirements\`,并标注来源:
|
|
140
|
+
- User:用户明确回答
|
|
141
|
+
- Derived:合理推导
|
|
142
|
+
- Assumption:无法确认但补全(需确认)
|
|
143
|
+
|
|
144
|
+
### 3) 自检与结束
|
|
145
|
+
若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入规格生成与估算。
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## ✅ 结束后继续
|
|
150
|
+
当满足结束条件时,执行:
|
|
151
|
+
1. 调用 \`add_feature\` 生成规格文档
|
|
152
|
+
2. 调用 \`estimate\` 进行工作量估算
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
*编排工具: MCP Probe Kit - start_feature (requirements loop)*
|
|
155
157
|
`;
|
|
156
158
|
function buildOpenQuestions(questionBudget) {
|
|
157
159
|
const base = [
|
|
@@ -163,8 +165,10 @@ function buildOpenQuestions(questionBudget) {
|
|
|
163
165
|
];
|
|
164
166
|
return base.slice(0, Math.max(0, questionBudget));
|
|
165
167
|
}
|
|
166
|
-
export async function startFeature(args) {
|
|
168
|
+
export async function startFeature(args, context) {
|
|
167
169
|
try {
|
|
170
|
+
throwIfAborted(context?.signal, "start_feature 已取消");
|
|
171
|
+
await reportToolProgress(context, 10, "start_feature: 解析参数");
|
|
168
172
|
// 智能参数解析,支持自然语言输入
|
|
169
173
|
const parsedArgs = parseArgs(args, {
|
|
170
174
|
defaultValues: {
|
|
@@ -197,6 +201,8 @@ export async function startFeature(args) {
|
|
|
197
201
|
const maxRounds = getNumber(parsedArgs.loop_max_rounds, 2);
|
|
198
202
|
const questionBudget = getNumber(parsedArgs.loop_question_budget, 5);
|
|
199
203
|
const assumptionCap = getNumber(parsedArgs.loop_assumption_cap, 3);
|
|
204
|
+
throwIfAborted(context?.signal, "start_feature 已取消");
|
|
205
|
+
await reportToolProgress(context, 35, "start_feature: 参数解析完成");
|
|
200
206
|
// 如果是纯自然语言输入(input 字段有值但 feature_name 和 description 为空)
|
|
201
207
|
const input = getString(parsedArgs.input);
|
|
202
208
|
if (input && !featureName && !description) {
|
|
@@ -220,7 +226,39 @@ export async function startFeature(args) {
|
|
|
220
226
|
"- 详细描述:'实现用户登录、注册和密码重置功能'\n" +
|
|
221
227
|
"- JSON格式:{\"feature_name\": \"user-auth\", \"description\": \"用户认证功能\"}");
|
|
222
228
|
}
|
|
229
|
+
throwIfAborted(context?.signal, "start_feature 已取消");
|
|
230
|
+
await reportToolProgress(context, 55, "start_feature: 获取代码图谱上下文");
|
|
231
|
+
const graphContext = await buildFeatureGraphContext({
|
|
232
|
+
featureName,
|
|
233
|
+
description,
|
|
234
|
+
signal: context?.signal,
|
|
235
|
+
});
|
|
236
|
+
const graphStatusNote = graphContext.available
|
|
237
|
+
? `图谱增强: 可用(${graphContext.mode})`
|
|
238
|
+
: "图谱增强: 已降级(自动回退)";
|
|
239
|
+
const graphGuideSection = `
|
|
240
|
+
|
|
241
|
+
## 🧠 代码图谱上下文(可选增强)
|
|
242
|
+
- 状态: ${graphContext.available ? "可用" : "降级"}
|
|
243
|
+
- 摘要: ${graphContext.summary}
|
|
244
|
+
${graphContext.highlights.length > 0
|
|
245
|
+
? `- 线索:\n${graphContext.highlights.slice(0, 3).map((item) => ` - ${item}`).join("\n")}`
|
|
246
|
+
: "- 线索: 无"}
|
|
247
|
+
`;
|
|
248
|
+
const estimateCodeContext = [
|
|
249
|
+
`参考生成的 ${docsDir}/specs/${featureName}/tasks.md`,
|
|
250
|
+
...(graphContext.available
|
|
251
|
+
? [
|
|
252
|
+
graphContext.summary ? `图谱摘要: ${graphContext.summary}` : "",
|
|
253
|
+
...graphContext.highlights.slice(0, 2).map((item) => `图谱线索: ${item}`),
|
|
254
|
+
]
|
|
255
|
+
: []),
|
|
256
|
+
]
|
|
257
|
+
.filter(Boolean)
|
|
258
|
+
.join("\n");
|
|
223
259
|
if (requirementsMode === "loop") {
|
|
260
|
+
throwIfAborted(context?.signal, "start_feature(loop) 已取消");
|
|
261
|
+
await reportToolProgress(context, 70, "start_feature: 生成 loop 计划");
|
|
224
262
|
const openQuestions = buildOpenQuestions(questionBudget).map((q, index) => ({
|
|
225
263
|
id: `Q-${index + 1}`,
|
|
226
264
|
...q,
|
|
@@ -277,7 +315,7 @@ export async function startFeature(args) {
|
|
|
277
315
|
when: 'stopConditions.ready=true',
|
|
278
316
|
args: {
|
|
279
317
|
task_description: `实现 ${featureName} 功能:${description}`,
|
|
280
|
-
code_context:
|
|
318
|
+
code_context: estimateCodeContext,
|
|
281
319
|
},
|
|
282
320
|
outputs: [],
|
|
283
321
|
},
|
|
@@ -290,13 +328,14 @@ export async function startFeature(args) {
|
|
|
290
328
|
'按 Requirements Loop 规则提问并更新结构化输出',
|
|
291
329
|
'满足结束条件后生成规格并完成估算',
|
|
292
330
|
],
|
|
293
|
-
notes: [`模板档位: ${templateProfile}
|
|
331
|
+
notes: [`模板档位: ${templateProfile}`, graphStatusNote],
|
|
294
332
|
});
|
|
295
|
-
const guide = header + LOOP_PROMPT_TEMPLATE
|
|
333
|
+
const guide = (header + LOOP_PROMPT_TEMPLATE
|
|
296
334
|
.replace(/{feature_name}/g, featureName)
|
|
297
335
|
.replace(/{description}/g, description)
|
|
298
336
|
.replace(/{question_budget}/g, String(questionBudget))
|
|
299
|
-
.replace(/{assumption_cap}/g, String(assumptionCap))
|
|
337
|
+
.replace(/{assumption_cap}/g, String(assumptionCap)))
|
|
338
|
+
+ graphGuideSection;
|
|
300
339
|
const loopReport = {
|
|
301
340
|
mode: 'loop',
|
|
302
341
|
round: 1,
|
|
@@ -322,8 +361,10 @@ export async function startFeature(args) {
|
|
|
322
361
|
},
|
|
323
362
|
metadata: {
|
|
324
363
|
plan,
|
|
364
|
+
graphContext,
|
|
325
365
|
},
|
|
326
366
|
};
|
|
367
|
+
await reportToolProgress(context, 95, "start_feature: loop 输出已生成");
|
|
327
368
|
return okStructured(guide, loopReport, {
|
|
328
369
|
schema: RequirementsLoopSchema,
|
|
329
370
|
note: 'AI 应按轮次澄清需求并更新结构化输出,满足结束条件后再进入 add_feature / estimate',
|
|
@@ -336,13 +377,14 @@ export async function startFeature(args) {
|
|
|
336
377
|
'按 delegated plan 顺序调用工具',
|
|
337
378
|
'生成规格文档并完成工作量估算',
|
|
338
379
|
],
|
|
339
|
-
notes: [`模板档位: ${templateProfile}
|
|
380
|
+
notes: [`模板档位: ${templateProfile}`, graphStatusNote],
|
|
340
381
|
});
|
|
341
|
-
const guide = header + PROMPT_TEMPLATE
|
|
382
|
+
const guide = (header + PROMPT_TEMPLATE
|
|
342
383
|
.replace(/{feature_name}/g, featureName)
|
|
343
384
|
.replace(/{description}/g, description)
|
|
344
385
|
.replace(/{docs_dir}/g, docsDir)
|
|
345
|
-
.replace(/{template_profile}/g, templateProfile)
|
|
386
|
+
.replace(/{template_profile}/g, templateProfile))
|
|
387
|
+
+ graphGuideSection;
|
|
346
388
|
const plan = {
|
|
347
389
|
mode: 'delegated',
|
|
348
390
|
steps: [
|
|
@@ -368,7 +410,7 @@ export async function startFeature(args) {
|
|
|
368
410
|
tool: 'estimate',
|
|
369
411
|
args: {
|
|
370
412
|
task_description: `实现 ${featureName} 功能:${description}`,
|
|
371
|
-
code_context:
|
|
413
|
+
code_context: estimateCodeContext,
|
|
372
414
|
},
|
|
373
415
|
outputs: [],
|
|
374
416
|
},
|
|
@@ -424,8 +466,10 @@ export async function startFeature(args) {
|
|
|
424
466
|
dependencies: [],
|
|
425
467
|
metadata: {
|
|
426
468
|
plan,
|
|
469
|
+
graphContext,
|
|
427
470
|
},
|
|
428
471
|
};
|
|
472
|
+
await reportToolProgress(context, 95, "start_feature: 执行计划输出已生成");
|
|
429
473
|
return okStructured(guide, featureReport, {
|
|
430
474
|
schema: FeatureReportSchema,
|
|
431
475
|
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent 中的状态和估算信息',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ToolExecutionContext } from "../lib/tool-execution-context.js";
|
|
2
|
+
export declare function startOnboard(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse | {
|
|
2
3
|
content: {
|
|
3
4
|
type: string;
|
|
4
5
|
text: string;
|
|
@@ -2,47 +2,48 @@ import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
|
2
2
|
import { okStructured } from "../lib/response.js";
|
|
3
3
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
4
4
|
import { OnboardingReportSchema } from "../schemas/structured-output.js";
|
|
5
|
+
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
5
6
|
/**
|
|
6
7
|
* start_onboard 智能编排工具
|
|
7
8
|
*
|
|
8
9
|
* 场景:快速上手项目
|
|
9
10
|
* 编排:init_project_context
|
|
10
11
|
*/
|
|
11
|
-
const PROMPT_TEMPLATE = `# 📚 快速上手编排指南
|
|
12
|
-
|
|
13
|
-
## 🎯 目标
|
|
14
|
-
|
|
15
|
-
快速了解并上手当前项目
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 📝 步骤 1: 生成项目上下文
|
|
20
|
-
|
|
21
|
-
**调用工具**: \`init_project_context\`
|
|
22
|
-
|
|
23
|
-
**参数**:
|
|
24
|
-
\`\`\`json
|
|
25
|
-
{
|
|
26
|
-
"docs_dir": "{docs_dir}",
|
|
27
|
-
"project_root": "{project_path}"
|
|
28
|
-
}
|
|
29
|
-
\`\`\`
|
|
30
|
-
|
|
31
|
-
**生成内容**:
|
|
32
|
-
- 技术栈文档
|
|
33
|
-
- 架构说明
|
|
34
|
-
- 编码规范
|
|
35
|
-
- 开发指南
|
|
36
|
-
|
|
37
|
-
**产出**: \`{docs_dir}/project-context.md\`
|
|
12
|
+
const PROMPT_TEMPLATE = `# 📚 快速上手编排指南
|
|
13
|
+
|
|
14
|
+
## 🎯 目标
|
|
15
|
+
|
|
16
|
+
快速了解并上手当前项目
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📝 步骤 1: 生成项目上下文
|
|
21
|
+
|
|
22
|
+
**调用工具**: \`init_project_context\`
|
|
23
|
+
|
|
24
|
+
**参数**:
|
|
25
|
+
\`\`\`json
|
|
26
|
+
{
|
|
27
|
+
"docs_dir": "{docs_dir}",
|
|
28
|
+
"project_root": "{project_path}"
|
|
29
|
+
}
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
**生成内容**:
|
|
33
|
+
- 技术栈文档
|
|
34
|
+
- 架构说明
|
|
35
|
+
- 编码规范
|
|
36
|
+
- 开发指南
|
|
37
|
+
|
|
38
|
+
**产出**: \`{docs_dir}/project-context.md\`
|
|
38
39
|
|
|
39
40
|
---
|
|
40
41
|
|
|
41
42
|
## ✅ 完成检查
|
|
42
43
|
|
|
43
|
-
- [ ] 技术栈已识别
|
|
44
|
-
- [ ] 项目上下文已生成
|
|
45
|
-
- [ ] 文档已保存
|
|
44
|
+
- [ ] 技术栈已识别
|
|
45
|
+
- [ ] 项目上下文已生成
|
|
46
|
+
- [ ] 文档已保存
|
|
46
47
|
|
|
47
48
|
---
|
|
48
49
|
|
|
@@ -50,25 +51,25 @@ const PROMPT_TEMPLATE = `# 📚 快速上手编排指南
|
|
|
50
51
|
|
|
51
52
|
完成后,向用户提供:
|
|
52
53
|
|
|
53
|
-
### 1. 项目概览
|
|
54
|
-
|
|
55
|
-
| 项目 | 内容 |
|
|
56
|
-
|------|------|
|
|
57
|
-
| 项目名称 | [名称] |
|
|
58
|
-
| 项目类型 | [前端/后端/全栈/库] |
|
|
59
|
-
| 主要语言 | [语言] |
|
|
60
|
-
| 框架 | [框架] |
|
|
61
|
-
|
|
62
|
-
### 2. 技术栈
|
|
63
|
-
|
|
64
|
-
| 类别 | 技术 |
|
|
65
|
-
|------|------|
|
|
66
|
-
| 语言 | [语言列表] |
|
|
67
|
-
| 框架 | [框架列表] |
|
|
68
|
-
| 构建工具 | [工具列表] |
|
|
69
|
-
| 测试框架 | [框架列表] |
|
|
70
|
-
|
|
71
|
-
### 3. 快速开始
|
|
54
|
+
### 1. 项目概览
|
|
55
|
+
|
|
56
|
+
| 项目 | 内容 |
|
|
57
|
+
|------|------|
|
|
58
|
+
| 项目名称 | [名称] |
|
|
59
|
+
| 项目类型 | [前端/后端/全栈/库] |
|
|
60
|
+
| 主要语言 | [语言] |
|
|
61
|
+
| 框架 | [框架] |
|
|
62
|
+
|
|
63
|
+
### 2. 技术栈
|
|
64
|
+
|
|
65
|
+
| 类别 | 技术 |
|
|
66
|
+
|------|------|
|
|
67
|
+
| 语言 | [语言列表] |
|
|
68
|
+
| 框架 | [框架列表] |
|
|
69
|
+
| 构建工具 | [工具列表] |
|
|
70
|
+
| 测试框架 | [框架列表] |
|
|
71
|
+
|
|
72
|
+
### 3. 快速开始
|
|
72
73
|
|
|
73
74
|
\`\`\`bash
|
|
74
75
|
# 安装依赖
|
|
@@ -81,7 +82,7 @@ const PROMPT_TEMPLATE = `# 📚 快速上手编排指南
|
|
|
81
82
|
[测试命令]
|
|
82
83
|
\`\`\`
|
|
83
84
|
|
|
84
|
-
### 4. 下一步建议
|
|
85
|
+
### 4. 下一步建议
|
|
85
86
|
|
|
86
87
|
1. 阅读 \`{docs_dir}/project-context.md\` 了解详细信息
|
|
87
88
|
2. 查看 README.md 了解项目背景
|
|
@@ -92,8 +93,10 @@ const PROMPT_TEMPLATE = `# 📚 快速上手编排指南
|
|
|
92
93
|
|
|
93
94
|
*编排工具: MCP Probe Kit - start_onboard*
|
|
94
95
|
`;
|
|
95
|
-
export async function startOnboard(args) {
|
|
96
|
+
export async function startOnboard(args, context) {
|
|
96
97
|
try {
|
|
98
|
+
throwIfAborted(context?.signal, "start_onboard 已取消");
|
|
99
|
+
await reportToolProgress(context, 10, "start_onboard: 解析参数");
|
|
97
100
|
// 智能参数解析,支持自然语言输入
|
|
98
101
|
const parsedArgs = parseArgs(args, {
|
|
99
102
|
defaultValues: {
|
|
@@ -108,6 +111,8 @@ export async function startOnboard(args) {
|
|
|
108
111
|
});
|
|
109
112
|
const projectPath = getString(parsedArgs.project_path) || ".";
|
|
110
113
|
const docsDir = getString(parsedArgs.docs_dir) || "docs";
|
|
114
|
+
throwIfAborted(context?.signal, "start_onboard 已取消");
|
|
115
|
+
await reportToolProgress(context, 85, "start_onboard: 生成执行计划");
|
|
111
116
|
const header = renderOrchestrationHeader({
|
|
112
117
|
tool: 'start_onboard',
|
|
113
118
|
goal: '快速了解并上手项目',
|
|
@@ -165,6 +170,7 @@ export async function startOnboard(args) {
|
|
|
165
170
|
plan,
|
|
166
171
|
},
|
|
167
172
|
};
|
|
173
|
+
await reportToolProgress(context, 95, "start_onboard: 输出已生成");
|
|
168
174
|
return okStructured(guide, onboardingReport, {
|
|
169
175
|
schema: OnboardingReportSchema,
|
|
170
176
|
note: 'AI 应该按照指南执行步骤,并在上下文生成后更新 structuredContent 中的项目信息',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type ToolExecutionContext } from "../lib/tool-execution-context.js";
|
|
1
2
|
/**
|
|
2
3
|
* start_product - 产品设计完整工作流指导
|
|
3
4
|
*
|
|
4
5
|
* 返回从需求到 HTML 原型的完整工作流执行指导,由 AI 按步骤调用工具并创建文件
|
|
5
6
|
*/
|
|
6
|
-
export declare function startProduct(args: any): Promise<import("../lib/response.js").ToolResponse | {
|
|
7
|
+
export declare function startProduct(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse | {
|
|
7
8
|
content: {
|
|
8
9
|
type: string;
|
|
9
10
|
text: string;
|
|
@@ -3,13 +3,16 @@ import { promises as fs } from "fs";
|
|
|
3
3
|
import { okStructured } from "../lib/response.js";
|
|
4
4
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
5
5
|
import { WorkflowReportSchema } from "../schemas/structured-output.js";
|
|
6
|
+
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
6
7
|
/**
|
|
7
8
|
* start_product - 产品设计完整工作流指导
|
|
8
9
|
*
|
|
9
10
|
* 返回从需求到 HTML 原型的完整工作流执行指导,由 AI 按步骤调用工具并创建文件
|
|
10
11
|
*/
|
|
11
|
-
export async function startProduct(args) {
|
|
12
|
+
export async function startProduct(args, context) {
|
|
12
13
|
try {
|
|
14
|
+
throwIfAborted(context?.signal, "start_product 已取消");
|
|
15
|
+
await reportToolProgress(context, 10, "start_product: 解析参数");
|
|
13
16
|
// 使用智能参数解析
|
|
14
17
|
const parsedArgs = parseArgs(args, {
|
|
15
18
|
defaultValues: {
|
|
@@ -36,9 +39,13 @@ export async function startProduct(args) {
|
|
|
36
39
|
const productType = getString(parsedArgs.product_type) || "SaaS";
|
|
37
40
|
const skipDesignSystem = getBoolean(parsedArgs.skip_design_system);
|
|
38
41
|
const docsDir = getString(parsedArgs.docs_dir) || "docs";
|
|
42
|
+
throwIfAborted(context?.signal, "start_product 已取消");
|
|
43
|
+
await reportToolProgress(context, 35, "start_product: 参数解析完成");
|
|
39
44
|
// 如果提供了需求文件,读取文件内容
|
|
40
45
|
let requirementsSource = '';
|
|
41
46
|
if (requirementsFile) {
|
|
47
|
+
throwIfAborted(context?.signal, "start_product 已取消");
|
|
48
|
+
await reportToolProgress(context, 55, "start_product: 读取需求文档");
|
|
42
49
|
try {
|
|
43
50
|
description = await fs.readFile(requirementsFile, 'utf-8');
|
|
44
51
|
requirementsSource = `需求文档文件: ${requirementsFile}`;
|
|
@@ -468,6 +475,7 @@ ${!skipDesignSystem ? `├── design-system.json # 设计系统配
|
|
|
468
475
|
plan,
|
|
469
476
|
},
|
|
470
477
|
};
|
|
478
|
+
await reportToolProgress(context, 95, "start_product: 工作流输出已生成");
|
|
471
479
|
return okStructured(guidanceText, report, {
|
|
472
480
|
schema: WorkflowReportSchema,
|
|
473
481
|
note: 'AI 应该严格按照执行计划调用工具并创建文档',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type ToolExecutionContext } from "../lib/tool-execution-context.js";
|
|
1
2
|
/**
|
|
2
3
|
* start_ralph 主函数
|
|
3
4
|
*/
|
|
4
|
-
export declare function startRalph(args: any): Promise<import("../lib/response.js").ToolResponse | {
|
|
5
|
+
export declare function startRalph(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse | {
|
|
5
6
|
content: {
|
|
6
7
|
type: string;
|
|
7
8
|
text: string;
|
|
@@ -2,6 +2,7 @@ import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
|
2
2
|
import { okStructured } from "../lib/response.js";
|
|
3
3
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
4
4
|
import { RalphLoopReportSchema } from "../schemas/structured-output.js";
|
|
5
|
+
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
5
6
|
// 默认值(保守安全)
|
|
6
7
|
const DEFAULTS = {
|
|
7
8
|
mode: "safe",
|
|
@@ -664,8 +665,10 @@ cat .ralph/last_output_*.txt
|
|
|
664
665
|
/**
|
|
665
666
|
* start_ralph 主函数
|
|
666
667
|
*/
|
|
667
|
-
export async function startRalph(args) {
|
|
668
|
+
export async function startRalph(args, context) {
|
|
668
669
|
try {
|
|
670
|
+
throwIfAborted(context?.signal, "start_ralph 已取消");
|
|
671
|
+
await reportToolProgress(context, 10, "start_ralph: 解析参数");
|
|
669
672
|
const parsedArgs = parseArgs(args, {
|
|
670
673
|
defaultValues: DEFAULTS,
|
|
671
674
|
primaryField: "goal",
|
|
@@ -705,6 +708,8 @@ export async function startRalph(args) {
|
|
|
705
708
|
};
|
|
706
709
|
// 检测操作系统
|
|
707
710
|
const isWindows = process.platform === "win32";
|
|
711
|
+
throwIfAborted(context?.signal, "start_ralph 已取消");
|
|
712
|
+
await reportToolProgress(context, 60, "start_ralph: 生成脚本模板");
|
|
708
713
|
// 生成所有文件内容
|
|
709
714
|
const promptMd = generatePromptTemplate(params.goal, params.completion_promise, params.test_command);
|
|
710
715
|
const fixPlanMd = generateFixPlanTemplate(params.goal);
|
|
@@ -724,7 +729,7 @@ export async function startRalph(args) {
|
|
|
724
729
|
'按指南运行 loop 并监控结果',
|
|
725
730
|
],
|
|
726
731
|
});
|
|
727
|
-
const output = `${header}${guide}
|
|
732
|
+
const output = `${header}${guide}
|
|
728
733
|
|
|
729
734
|
---
|
|
730
735
|
|
|
@@ -774,7 +779,7 @@ ${normalScript}
|
|
|
774
779
|
5. Run \`ralph_loop_safe.${scriptExt}\`
|
|
775
780
|
6. Monitor progress and logs
|
|
776
781
|
|
|
777
|
-
**Happy coding! 🚀**
|
|
782
|
+
**Happy coding! 🚀**
|
|
778
783
|
`;
|
|
779
784
|
const plan = {
|
|
780
785
|
mode: 'delegated',
|
|
@@ -899,6 +904,7 @@ ${normalScript}
|
|
|
899
904
|
plan,
|
|
900
905
|
},
|
|
901
906
|
};
|
|
907
|
+
await reportToolProgress(context, 95, "start_ralph: 输出已生成");
|
|
902
908
|
return okStructured(output, ralphReport, {
|
|
903
909
|
schema: RalphLoopReportSchema,
|
|
904
910
|
note: 'AI 应该帮助用户创建 .ralph/ 目录并复制文件,然后指导用户启动循环',
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* 3. 搜索/生成 UI 模板
|
|
8
8
|
* 4. 渲染最终代码
|
|
9
9
|
*/
|
|
10
|
+
import { type ToolExecutionContext } from "../lib/tool-execution-context.js";
|
|
10
11
|
/**
|
|
11
12
|
* 统一 UI 开发编排工具
|
|
12
13
|
*/
|
|
13
|
-
export declare function startUi(args: any): Promise<import("../lib/response.js").ToolResponse | {
|
|
14
|
+
export declare function startUi(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse | {
|
|
14
15
|
content: {
|
|
15
16
|
type: string;
|
|
16
17
|
text: string;
|