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.
Files changed (37) hide show
  1. package/README.md +75 -50
  2. package/build/lib/__tests__/agents-md-template.unit.test.d.ts +1 -0
  3. package/build/lib/__tests__/agents-md-template.unit.test.js +25 -0
  4. package/build/lib/__tests__/project-context-layout.unit.test.d.ts +1 -0
  5. package/build/lib/__tests__/project-context-layout.unit.test.js +80 -0
  6. package/build/lib/agents-md-template.d.ts +25 -0
  7. package/build/lib/agents-md-template.js +55 -0
  8. package/build/lib/memory-orchestration.d.ts +3 -1
  9. package/build/lib/memory-orchestration.js +71 -5
  10. package/build/lib/merge-agents-md.d.ts +6 -0
  11. package/build/lib/merge-agents-md.js +51 -0
  12. package/build/lib/project-context-layout.d.ts +78 -0
  13. package/build/lib/project-context-layout.js +350 -0
  14. package/build/lib/workspace-root.js +6 -1
  15. package/build/resources/ui-ux-data/metadata.json +1 -1
  16. package/build/schemas/index.d.ts +25 -3
  17. package/build/schemas/memory-tools.d.ts +1 -1
  18. package/build/schemas/memory-tools.js +1 -1
  19. package/build/schemas/project-tools.d.ts +24 -2
  20. package/build/schemas/project-tools.js +24 -2
  21. package/build/tools/__tests__/code_insight.unit.test.js +3 -3
  22. package/build/tools/__tests__/init_project_context.unit.test.js +32 -21
  23. package/build/tools/__tests__/start_feature.unit.test.js +2 -1
  24. package/build/tools/code_insight.js +11 -9
  25. package/build/tools/init_project_context.js +563 -506
  26. package/build/tools/start_bugfix.js +254 -248
  27. package/build/tools/start_feature.js +137 -131
  28. package/build/tools/start_ui.js +402 -402
  29. package/docs/.mcp-probe/layout.json +11 -0
  30. package/docs/i18n/en.json +36 -5
  31. package/docs/i18n/ja.json +9 -2
  32. package/docs/i18n/ko.json +9 -2
  33. package/docs/i18n/zh-CN.json +36 -5
  34. package/docs/memory-local-setup.md +314 -0
  35. package/docs/memory-local-setup.zh-CN.md +280 -0
  36. package/docs/pages/getting-started.html +249 -31
  37. 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 { buildFeatureGraphContext } from "../lib/gitnexus-bridge.js";
9
8
  import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, } from "../lib/memory-orchestration.js";
10
9
  import { resolveWorkspaceRoot, toWorkspacePath, isLikelyProjectNamedRelativePath, buildProjectRootRetryHint } from "../lib/workspace-root.js";
10
+ import { layoutAbsPath, parseLayoutArgsFromRecord, resolveProjectContextLayout, } from "../lib/project-context-layout.js";
11
11
  /**
12
12
  * start_feature 智能编排工具
13
13
  *
@@ -54,114 +54,114 @@ function extractFeatureInfo(input) {
54
54
  description: input,
55
55
  };
56
56
  }
57
- const PROMPT_TEMPLATE = `# 🚀 新功能开发编排(委托式)
58
-
59
- 本工具仅生成 **执行计划(steps)**。AI 需要按顺序调用对应工具并落盘文档。
60
-
61
- ## 🎯 目标
62
- 开发新功能:**{feature_name}**
63
- 功能描述:{description}
64
-
65
- ---
66
-
67
- ## ✅ 执行计划(按顺序)
68
-
69
- ### 0) 项目上下文(如缺失)
70
- **检查**:
71
- - \`{docs_dir}/project-context.md\`
72
- - \`{docs_dir}/graph-insights/latest.md\`
73
- - \`{docs_dir}/graph-insights/latest.json\`
74
- **缺失则调用**: \`init_project_context\`
75
- \`\`\`json
76
- { "docs_dir": "{docs_dir}", "project_root": "{project_root}" }
77
- \`\`\`
78
-
79
- ### 1) 生成功能规格
80
- **调用**: \`add_feature\`
81
- \`\`\`json
82
- {
83
- "feature_name": "{feature_name}",
84
- "description": "{description}",
85
- "docs_dir": "{docs_dir}",
86
- "template_profile": "{template_profile}"
87
- }
88
- \`\`\`
89
- **预期输出**:
90
- - \`{docs_dir}/specs/{feature_name}/requirements.md\`
91
- - \`{docs_dir}/specs/{feature_name}/design.md\`
92
- - \`{docs_dir}/specs/{feature_name}/tasks.md\`
93
-
94
- ### 2) 工作量估算
95
- **调用**: \`estimate\`
96
- \`\`\`json
97
- {
98
- "task_description": "实现 {feature_name} 功能:{description}",
99
- "code_context": "参考生成的 tasks.md 中的任务列表"
100
- }
101
- \`\`\`
102
-
103
- ---
104
-
105
- ## ✅ 输出汇总(执行完成后)
106
- 1. 规格文档位置: \`{docs_dir}/specs/{feature_name}/\`
107
- 2. 图谱入口: \`{docs_dir}/graph-insights/latest.md\`
108
- 3. 估算结果: 故事点 + 时间区间
109
- 4. 主要风险(如有)
110
- 5. 下一步: 按 tasks.md 开始开发
111
-
112
- ---
113
-
57
+ const PROMPT_TEMPLATE = `# 🚀 新功能开发编排(委托式)
58
+
59
+ 本工具仅生成 **执行计划(steps)**。AI 需要按顺序调用对应工具并落盘文档。
60
+
61
+ ## 🎯 目标
62
+ 开发新功能:**{feature_name}**
63
+ 功能描述:{description}
64
+
65
+ ---
66
+
67
+ ## ✅ 执行计划(按顺序)
68
+
69
+ ### 0) 项目上下文(如缺失)
70
+ **检查**:
71
+ - \`{docs_dir}/project-context.md\`
72
+ - \`{docs_dir}/graph-insights/latest.md\`
73
+ - \`{docs_dir}/graph-insights/latest.json\`
74
+ **缺失则调用**: \`init_project_context\`
75
+ \`\`\`json
76
+ { "docs_dir": "{docs_dir}", "project_root": "{project_root}" }
77
+ \`\`\`
78
+
79
+ ### 1) 生成功能规格
80
+ **调用**: \`add_feature\`
81
+ \`\`\`json
82
+ {
83
+ "feature_name": "{feature_name}",
84
+ "description": "{description}",
85
+ "docs_dir": "{docs_dir}",
86
+ "template_profile": "{template_profile}"
87
+ }
88
+ \`\`\`
89
+ **预期输出**:
90
+ - \`{docs_dir}/specs/{feature_name}/requirements.md\`
91
+ - \`{docs_dir}/specs/{feature_name}/design.md\`
92
+ - \`{docs_dir}/specs/{feature_name}/tasks.md\`
93
+
94
+ ### 2) 工作量估算
95
+ **调用**: \`estimate\`
96
+ \`\`\`json
97
+ {
98
+ "task_description": "实现 {feature_name} 功能:{description}",
99
+ "code_context": "参考生成的 tasks.md 中的任务列表"
100
+ }
101
+ \`\`\`
102
+
103
+ ---
104
+
105
+ ## ✅ 输出汇总(执行完成后)
106
+ 1. 规格文档位置: \`{docs_dir}/specs/{feature_name}/\`
107
+ 2. 图谱入口: \`{docs_dir}/graph-insights/latest.md\`
108
+ 3. 估算结果: 故事点 + 时间区间
109
+ 4. 主要风险(如有)
110
+ 5. 下一步: 按 tasks.md 开始开发
111
+
112
+ ---
113
+
114
114
  *编排工具: MCP Probe Kit - start_feature*`;
115
- const LOOP_PROMPT_TEMPLATE = `# 🧭 需求澄清与补全(Requirements Loop)
116
-
117
- 本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐关键要素,并输出可审计的结构化结果。
118
-
119
- ## 🎯 目标
120
- 开发新功能:**{feature_name}**
121
- 功能描述:{description}
122
-
123
- ## ✅ 规则
124
- 1. **不覆盖用户原始需求**
125
- 2. **补全内容必须标注来源**(User / Derived / Assumption)
126
- 3. **假设必须进入待确认列表**
127
- 4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
128
-
129
- ---
130
-
131
- ## 🔁 执行步骤(每轮)
132
-
133
- ### 1) 生成待确认问题
134
- 使用 \`ask_user\` 提问,问题来源于“功能需求补全清单”(角色/触发/约束/异常/依赖等)。
135
-
136
- **调用示例**:
137
- \`\`\`json
138
- {
139
- "questions": [
140
- { "question": "目标用户或角色是谁?", "context": "角色定义", "required": true },
141
- { "question": "触发场景是什么?", "context": "业务场景", "required": true }
142
- ]
143
- }
144
- \`\`\`
145
-
146
- ### 2) 更新结构化输出
147
- 将回答补入 \`requirements\`,并标注来源:
148
- - User:用户明确回答
149
- - Derived:合理推导
150
- - Assumption:无法确认但补全(需确认)
151
-
152
- ### 3) 自检与结束
153
- 若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入规格生成与估算。
154
-
155
- ---
156
-
157
- ## ✅ 结束后继续
158
- 当满足结束条件时,执行:
159
- 1. 调用 \`add_feature\` 生成规格文档
160
- 2. 调用 \`estimate\` 进行工作量估算
161
-
162
- ---
163
-
164
- *编排工具: MCP Probe Kit - start_feature (requirements loop)*
115
+ const LOOP_PROMPT_TEMPLATE = `# 🧭 需求澄清与补全(Requirements Loop)
116
+
117
+ 本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐关键要素,并输出可审计的结构化结果。
118
+
119
+ ## 🎯 目标
120
+ 开发新功能:**{feature_name}**
121
+ 功能描述:{description}
122
+
123
+ ## ✅ 规则
124
+ 1. **不覆盖用户原始需求**
125
+ 2. **补全内容必须标注来源**(User / Derived / Assumption)
126
+ 3. **假设必须进入待确认列表**
127
+ 4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
128
+
129
+ ---
130
+
131
+ ## 🔁 执行步骤(每轮)
132
+
133
+ ### 1) 生成待确认问题
134
+ 使用 \`ask_user\` 提问,问题来源于“功能需求补全清单”(角色/触发/约束/异常/依赖等)。
135
+
136
+ **调用示例**:
137
+ \`\`\`json
138
+ {
139
+ "questions": [
140
+ { "question": "目标用户或角色是谁?", "context": "角色定义", "required": true },
141
+ { "question": "触发场景是什么?", "context": "业务场景", "required": true }
142
+ ]
143
+ }
144
+ \`\`\`
145
+
146
+ ### 2) 更新结构化输出
147
+ 将回答补入 \`requirements\`,并标注来源:
148
+ - User:用户明确回答
149
+ - Derived:合理推导
150
+ - Assumption:无法确认但补全(需确认)
151
+
152
+ ### 3) 自检与结束
153
+ 若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入规格生成与估算。
154
+
155
+ ---
156
+
157
+ ## ✅ 结束后继续
158
+ 当满足结束条件时,执行:
159
+ 1. 调用 \`add_feature\` 生成规格文档
160
+ 2. 调用 \`estimate\` 进行工作量估算
161
+
162
+ ---
163
+
164
+ *编排工具: MCP Probe Kit - start_feature (requirements loop)*
165
165
  `;
166
166
  function buildOpenQuestions(questionBudget) {
167
167
  const base = [
@@ -252,15 +252,21 @@ export async function startFeature(args, context) {
252
252
  }
253
253
  throwIfAborted(context?.signal, "start_feature 已取消");
254
254
  await reportToolProgress(context, 55, "start_feature: 刷新图谱并收敛需求范围");
255
+ const resolvedProjectRoot = resolveWorkspaceRoot(projectRoot);
256
+ const layout = resolveProjectContextLayout(resolvedProjectRoot, parseLayoutArgsFromRecord({ docs_dir: docsDir }));
257
+ const projectRootAbs = layout.projectRoot;
255
258
  const graphDocs = {
256
- latestMarkdownPath: `${docsDir}/graph-insights/latest.md`,
257
- latestJsonPath: `${docsDir}/graph-insights/latest.json`,
259
+ latestMarkdownPath: layout.latestMarkdownPath,
260
+ latestJsonPath: layout.latestJsonPath,
258
261
  };
259
- const resolvedProjectRoot = resolveWorkspaceRoot(projectRoot);
260
262
  const bootstrapState = {
261
- projectContextExists: fs.existsSync(path.join(resolvedProjectRoot, docsDir, "project-context.md")),
262
- latestMarkdownExists: fs.existsSync(path.join(resolvedProjectRoot, docsDir, "graph-insights", "latest.md")),
263
- latestJsonExists: fs.existsSync(path.join(resolvedProjectRoot, docsDir, "graph-insights", "latest.json")),
263
+ projectContextExists: fs.existsSync(layoutAbsPath(layout, layout.indexPath)) ||
264
+ fs.existsSync(layoutAbsPath(layout, layout.legacyIndexPath)),
265
+ latestMarkdownExists: fs.existsSync(layoutAbsPath(layout, layout.latestMarkdownPath)),
266
+ latestJsonExists: fs.existsSync(layoutAbsPath(layout, layout.latestJsonPath)),
267
+ indexPath: layout.indexPath,
268
+ projectRoot: layout.projectRootPosix,
269
+ layoutManifest: layout.manifestPath,
264
270
  };
265
271
  const graphDocsMissing = !bootstrapState.latestMarkdownExists || !bootstrapState.latestJsonExists;
266
272
  const graphContext = await buildFeatureGraphContext({
@@ -272,18 +278,18 @@ export async function startFeature(args, context) {
272
278
  const graphStatusNote = graphContext.available
273
279
  ? `任务图谱收敛: 可用(${graphContext.mode})`
274
280
  : "任务图谱收敛: 已降级(自动回退)";
275
- const graphGuideSection = `
276
-
277
- ## 🧠 代码图谱上下文
278
- - 基线入口: ${graphDocs.latestMarkdownPath}
279
- - 基线结构化副本: ${graphDocs.latestJsonPath}
280
- - 基线状态: ${graphDocsMissing ? "缺失(需要补初始化)" : "可用"}
281
- - 任务级收敛: ${graphContext.available ? "可用" : "降级"}
282
- - 任务级摘要: ${graphContext.summary}
281
+ const graphGuideSection = `
282
+
283
+ ## 🧠 代码图谱上下文
284
+ - 基线入口: ${graphDocs.latestMarkdownPath}
285
+ - 基线结构化副本: ${graphDocs.latestJsonPath}
286
+ - 基线状态: ${graphDocsMissing ? "缺失(需要补初始化)" : "可用"}
287
+ - 任务级收敛: ${graphContext.available ? "可用" : "降级"}
288
+ - 任务级摘要: ${graphContext.summary}
283
289
  ${graphContext.highlights.length > 0
284
290
  ? `- 任务级线索:\n${graphContext.highlights.slice(0, 3).map((item) => ` - ${item}`).join("\n")}`
285
- : "- 任务级线索: 无"}
286
- - 使用方式: 先参考基线图谱,再使用本次任务图谱线索约束模块边界和改动范围
291
+ : "- 任务级线索: 无"}
292
+ - 使用方式: 先参考基线图谱,再使用本次任务图谱线索约束模块边界和改动范围
287
293
  `;
288
294
  const estimateCodeContext = [
289
295
  `参考生成的 ${docsDir}/specs/${featureName}/tasks.md`,
@@ -327,12 +333,12 @@ ${graphContext.highlights.length > 0
327
333
  {
328
334
  id: 'context',
329
335
  tool: 'init_project_context',
330
- when: `缺少 ${docsDir}/project-context.md 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
336
+ when: `缺少 ${layout.indexPath} 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
331
337
  args: {
332
338
  docs_dir: docsDir,
333
339
  ...(projectRoot ? { project_root: projectRoot } : {}),
334
340
  },
335
- outputs: [`${docsDir}/project-context.md`, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
341
+ outputs: [layout.indexPath, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
336
342
  note: `兼容老项目:即使已有旧版 project-context,只要缺少图谱文档,也要先补齐 ${graphDocs.latestMarkdownPath}`,
337
343
  },
338
344
  {
@@ -373,7 +379,7 @@ ${graphContext.highlights.length > 0
373
379
  },
374
380
  outputs: [],
375
381
  },
376
- ...(memoryContext.enabled ? [buildMemoryPlanStep()] : []),
382
+ ...(memoryContext.enabled ? [buildMemoryPlanStep('feature')] : []),
377
383
  ],
378
384
  };
379
385
  const header = renderOrchestrationHeader({
@@ -463,12 +469,12 @@ ${graphContext.highlights.length > 0
463
469
  {
464
470
  id: 'context',
465
471
  tool: 'init_project_context',
466
- when: `缺少 ${docsDir}/project-context.md 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
472
+ when: `缺少 ${layout.indexPath} 或 ${graphDocs.latestMarkdownPath} / ${graphDocs.latestJsonPath}`,
467
473
  args: {
468
474
  docs_dir: docsDir,
469
475
  ...(projectRoot ? { project_root: projectRoot } : {}),
470
476
  },
471
- outputs: [`${docsDir}/project-context.md`, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
477
+ outputs: [layout.indexPath, graphDocs.latestMarkdownPath, graphDocs.latestJsonPath],
472
478
  note: `兼容老项目:即使已有旧版 project-context,只要缺少图谱文档,也要先补齐 ${graphDocs.latestMarkdownPath}`,
473
479
  },
474
480
  {
@@ -490,7 +496,7 @@ ${graphContext.highlights.length > 0
490
496
  },
491
497
  outputs: [],
492
498
  },
493
- ...(memoryContext.enabled ? [buildMemoryPlanStep()] : []),
499
+ ...(memoryContext.enabled ? [buildMemoryPlanStep('feature')] : []),
494
500
  ],
495
501
  };
496
502
  // 创建结构化的功能开发报告
@@ -501,7 +507,7 @@ ${graphContext.highlights.length > 0
501
507
  {
502
508
  name: '检查项目上下文',
503
509
  status: 'pending',
504
- description: `检查 ${docsDir}/project-context.md 与 graph-insights/latest.* 是否存在,缺失则调用 init_project_context`,
510
+ description: `检查 ${layout.indexPath} 与 graph-insights/latest.* 是否存在,缺失则调用 init_project_context`,
505
511
  },
506
512
  {
507
513
  name: '生成功能规格',