mcp-probe-kit 3.2.0 → 3.6.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.
Files changed (180) hide show
  1. package/README.md +25 -7
  2. package/build/index.js +45 -79
  3. package/build/lib/__tests__/agents-md-template.unit.test.js +1 -0
  4. package/build/lib/__tests__/dev-workflow.unit.test.js +22 -0
  5. package/build/lib/__tests__/handles.unit.test.js +19 -0
  6. package/build/lib/__tests__/mcp-apps.unit.test.d.ts +1 -0
  7. package/build/lib/__tests__/mcp-apps.unit.test.js +52 -0
  8. package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.d.ts +1 -0
  9. package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.js +18 -0
  10. package/build/lib/__tests__/memory-client.unit.test.js +105 -0
  11. package/build/lib/__tests__/memory-orchestration.unit.test.d.ts +1 -0
  12. package/build/lib/__tests__/memory-orchestration.unit.test.js +88 -0
  13. package/build/lib/__tests__/memory-payload.unit.test.d.ts +1 -0
  14. package/build/lib/__tests__/memory-payload.unit.test.js +35 -0
  15. package/build/lib/__tests__/quality-constraints.unit.test.d.ts +1 -0
  16. package/build/lib/__tests__/quality-constraints.unit.test.js +54 -0
  17. package/build/lib/__tests__/spec-gate.unit.test.d.ts +1 -0
  18. package/build/lib/__tests__/spec-gate.unit.test.js +54 -0
  19. package/build/lib/__tests__/spec-validator.unit.test.js +106 -74
  20. package/build/lib/__tests__/task-defaults.unit.test.d.ts +1 -0
  21. package/build/lib/__tests__/task-defaults.unit.test.js +27 -0
  22. package/build/lib/__tests__/workflow-skill-installer.unit.test.d.ts +1 -0
  23. package/build/lib/__tests__/workflow-skill-installer.unit.test.js +110 -0
  24. package/build/lib/agents-md-template.js +40 -32
  25. package/build/lib/cursor-history-client.d.ts +54 -0
  26. package/build/lib/cursor-history-client.js +240 -0
  27. package/build/lib/dev-workflow.d.ts +36 -0
  28. package/build/lib/dev-workflow.js +497 -0
  29. package/build/lib/handles.d.ts +31 -0
  30. package/build/lib/handles.js +36 -0
  31. package/build/lib/mcp-apps.d.ts +14 -0
  32. package/build/lib/mcp-apps.js +234 -0
  33. package/build/lib/mcp-tool-skill-registry.d.ts +46 -0
  34. package/build/lib/mcp-tool-skill-registry.js +256 -0
  35. package/build/lib/memory-client.d.ts +19 -0
  36. package/build/lib/memory-client.js +69 -0
  37. package/build/lib/memory-orchestration.d.ts +5 -0
  38. package/build/lib/memory-orchestration.js +20 -0
  39. package/build/lib/merge-agents-md.d.ts +2 -2
  40. package/build/lib/merge-agents-md.js +7 -4
  41. package/build/lib/output-schema-registry.d.ts +11 -0
  42. package/build/lib/output-schema-registry.js +80 -0
  43. package/build/lib/quality-constraints.d.ts +54 -0
  44. package/build/lib/quality-constraints.js +155 -0
  45. package/build/lib/skill-bridge.js +12 -12
  46. package/build/lib/spec-gate.d.ts +32 -0
  47. package/build/lib/spec-gate.js +83 -0
  48. package/build/lib/spec-validator.js +16 -3
  49. package/build/lib/task-defaults.d.ts +6 -0
  50. package/build/lib/task-defaults.js +20 -0
  51. package/build/lib/template-loader.js +83 -23
  52. package/build/lib/tool-annotations.js +3 -0
  53. package/build/lib/toolset-manager.js +2 -0
  54. package/build/lib/workflow-skill-installer.d.ts +38 -0
  55. package/build/lib/workflow-skill-installer.js +158 -0
  56. package/build/lib/workflow-skill-template.d.ts +9 -0
  57. package/build/lib/workflow-skill-template.js +85 -0
  58. package/build/lib/workflow-skill-version.d.ts +15 -0
  59. package/build/lib/workflow-skill-version.js +68 -0
  60. package/build/resources/ui-ux-data/guidelines/vercel-web-interface.json +1632 -1632
  61. package/build/resources/ui-ux-data/metadata.json +30 -30
  62. package/build/resources/ui-ux-data/shadcn/blocks.json +2541 -2541
  63. package/build/resources/ui-ux-data/shadcn/components.json +997 -997
  64. package/build/resources/ui-ux-data/themes/presets.json +483 -483
  65. package/build/schemas/index.d.ts +110 -0
  66. package/build/schemas/index.js +1 -0
  67. package/build/schemas/memory-tools.d.ts +83 -0
  68. package/build/schemas/memory-tools.js +43 -0
  69. package/build/schemas/orchestration-tools.d.ts +8 -0
  70. package/build/schemas/orchestration-tools.js +8 -0
  71. package/build/schemas/output/code-insight-tools.d.ts +65 -0
  72. package/build/schemas/output/code-insight-tools.js +42 -0
  73. package/build/schemas/output/memory-tools.d.ts +576 -0
  74. package/build/schemas/output/memory-tools.js +148 -0
  75. package/build/schemas/project-tools.d.ts +19 -0
  76. package/build/schemas/project-tools.js +20 -0
  77. package/build/tools/__tests__/cursor-history.unit.test.d.ts +1 -0
  78. package/build/tools/__tests__/cursor-history.unit.test.js +38 -0
  79. package/build/tools/__tests__/delete_memory_asset.unit.test.d.ts +1 -0
  80. package/build/tools/__tests__/delete_memory_asset.unit.test.js +87 -0
  81. package/build/tools/__tests__/search_memory.unit.test.js +1 -0
  82. package/build/tools/__tests__/start_bugfix.unit.test.js +34 -1
  83. package/build/tools/__tests__/update_memory_asset.unit.test.d.ts +1 -0
  84. package/build/tools/__tests__/update_memory_asset.unit.test.js +82 -0
  85. package/build/tools/__tests__/workflow.unit.test.d.ts +1 -0
  86. package/build/tools/__tests__/workflow.unit.test.js +24 -0
  87. package/build/tools/check_spec.js +16 -16
  88. package/build/tools/code_insight.js +46 -42
  89. package/build/tools/code_review.js +11 -4
  90. package/build/tools/cursor_read_conversation.d.ts +7 -0
  91. package/build/tools/cursor_read_conversation.js +36 -0
  92. package/build/tools/delete_memory_asset.d.ts +7 -0
  93. package/build/tools/delete_memory_asset.js +57 -0
  94. package/build/tools/fix_bug.js +161 -161
  95. package/build/tools/gencommit.js +60 -60
  96. package/build/tools/index.d.ts +3 -0
  97. package/build/tools/index.js +3 -0
  98. package/build/tools/init_project_context.js +432 -432
  99. package/build/tools/search_memory.js +5 -2
  100. package/build/tools/start_bugfix.js +37 -4
  101. package/build/tools/start_feature.js +4 -3
  102. package/build/tools/start_product.js +1 -1
  103. package/build/tools/start_ui.js +22 -4
  104. package/build/tools/ui-ux-tools.d.ts +3 -0
  105. package/build/tools/ui-ux-tools.js +302 -290
  106. package/build/tools/update_memory_asset.d.ts +7 -0
  107. package/build/tools/update_memory_asset.js +98 -0
  108. package/build/tools/workflow.d.ts +13 -0
  109. package/build/tools/workflow.js +69 -0
  110. package/build/utils/__tests__/vercel-guidelines-sync.unit.test.js +12 -12
  111. package/build/utils/design-reasoning-engine.d.ts +2 -0
  112. package/build/utils/design-reasoning-engine.js +3 -0
  113. package/build/utils/themes-sync.js +8 -8
  114. package/package.json +6 -3
  115. package/build/resources/index.d.ts +0 -4
  116. package/build/resources/index.js +0 -4
  117. package/build/resources/tool-params-guide.d.ts +0 -571
  118. package/build/resources/tool-params-guide.js +0 -488
  119. package/build/tools/analyze_project.d.ts +0 -1
  120. package/build/tools/analyze_project.js +0 -527
  121. package/build/tools/check_deps.d.ts +0 -13
  122. package/build/tools/check_deps.js +0 -204
  123. package/build/tools/convert.d.ts +0 -13
  124. package/build/tools/convert.js +0 -599
  125. package/build/tools/css_order.d.ts +0 -13
  126. package/build/tools/css_order.js +0 -81
  127. package/build/tools/debug.d.ts +0 -13
  128. package/build/tools/debug.js +0 -131
  129. package/build/tools/design2code.d.ts +0 -20
  130. package/build/tools/design2code.js +0 -426
  131. package/build/tools/detect_shell.d.ts +0 -6
  132. package/build/tools/detect_shell.js +0 -151
  133. package/build/tools/explain.d.ts +0 -13
  134. package/build/tools/explain.js +0 -390
  135. package/build/tools/fix.d.ts +0 -13
  136. package/build/tools/fix.js +0 -303
  137. package/build/tools/gen_mock.d.ts +0 -22
  138. package/build/tools/gen_mock.js +0 -269
  139. package/build/tools/gen_skill.d.ts +0 -13
  140. package/build/tools/gen_skill.js +0 -560
  141. package/build/tools/genapi.d.ts +0 -13
  142. package/build/tools/genapi.js +0 -174
  143. package/build/tools/genchangelog.d.ts +0 -13
  144. package/build/tools/genchangelog.js +0 -250
  145. package/build/tools/gendoc.d.ts +0 -13
  146. package/build/tools/gendoc.js +0 -232
  147. package/build/tools/genpr.d.ts +0 -13
  148. package/build/tools/genpr.js +0 -194
  149. package/build/tools/genreadme.d.ts +0 -13
  150. package/build/tools/genreadme.js +0 -626
  151. package/build/tools/gensql.d.ts +0 -13
  152. package/build/tools/gensql.js +0 -320
  153. package/build/tools/genui.d.ts +0 -13
  154. package/build/tools/genui.js +0 -803
  155. package/build/tools/init_component_catalog.d.ts +0 -22
  156. package/build/tools/init_component_catalog.js +0 -809
  157. package/build/tools/init_setting.d.ts +0 -13
  158. package/build/tools/init_setting.js +0 -47
  159. package/build/tools/perf.d.ts +0 -13
  160. package/build/tools/perf.js +0 -409
  161. package/build/tools/render_ui.d.ts +0 -22
  162. package/build/tools/render_ui.js +0 -384
  163. package/build/tools/resolve_conflict.d.ts +0 -13
  164. package/build/tools/resolve_conflict.js +0 -349
  165. package/build/tools/security_scan.d.ts +0 -22
  166. package/build/tools/security_scan.js +0 -323
  167. package/build/tools/split.d.ts +0 -13
  168. package/build/tools/split.js +0 -599
  169. package/build/tools/start_api.d.ts +0 -13
  170. package/build/tools/start_api.js +0 -193
  171. package/build/tools/start_doc.d.ts +0 -13
  172. package/build/tools/start_doc.js +0 -207
  173. package/build/tools/start_refactor.d.ts +0 -13
  174. package/build/tools/start_refactor.js +0 -188
  175. package/build/tools/start_release.d.ts +0 -13
  176. package/build/tools/start_release.js +0 -167
  177. package/build/tools/start_review.d.ts +0 -13
  178. package/build/tools/start_review.js +0 -175
  179. /package/build/{utils/design-docs-generator.d.ts → lib/__tests__/dev-workflow.unit.test.d.ts} +0 -0
  180. /package/build/{utils/design-docs-generator.js → lib/__tests__/handles.unit.test.d.ts} +0 -0
@@ -14,8 +14,8 @@ const TEMPLATE_VALIDATORS = {
14
14
  requiredFields: ['技术选型'],
15
15
  },
16
16
  'specs/feature/tasks.md': {
17
- requiredSections: ['概述', '任务列表', '检查点', '文件变更清单'],
18
- requiredFields: ['阶段 1', '阶段 2', '阶段 3'],
17
+ requiredSections: ['概述', '交付物清单', '任务列表', '检查点', '文件变更清单'],
18
+ requiredFields: ['阶段 1', '阶段 2', '阶段 3', '证据块'],
19
19
  },
20
20
  };
21
21
  const EMBEDDED_TEMPLATES = {
@@ -214,36 +214,60 @@ const EMBEDDED_TEMPLATES = {
214
214
 
215
215
  实现 {feature_name} 功能的任务分解。每条任务都要回链到需求(FR)与设计章节,确保不漏、不越界。
216
216
 
217
+ > **二元禁令(零容忍)**:本文件及后续实现的交付物中,禁止出现 \`[填写]\`、\`TODO\`、\`// ...\`、省略号占位。
218
+ > 这不是"尽量",是"零"。任何用占位符代替真实内容的行为都视为未完成。
219
+
220
+ ---
221
+
222
+ ## 交付物清单(Scope-lock)
223
+
224
+ > 先数清楚要产出什么,锁定数量。实现完成前必须回读本清单逐项核对,数量对不上即未完成。
225
+
226
+ - **预计新建文件数**: [填写:N 个]
227
+ - **预计修改文件数**: [填写:N 个]
228
+ - **预计新增/修改函数数**: [填写:约 N 个]
229
+ - **交付物逐项列举**:
230
+ 1. [填写:交付物 1,如 src/auth/login.ts]
231
+ 2. [填写:交付物 2]
232
+
217
233
  ---
218
234
 
219
235
  ## 任务列表
220
236
 
221
- > 每条任务:动词开头、单一明确、可在一次提交内完成,并标注 _需求_ 与 _设计_。
222
- > 示例:2.1 实现登录接口 POST /api/login — _需求: FR-1_ | _设计: API 设计_
237
+ > **每条任务的硬性结构**(缺一不可):
238
+ > 1. **标题**:[动词] + [对象] + [约束/验收点]。如"实现登录接口 POST /api/login,校验邮箱格式并返回 JWT"。
239
+ > - ❌ 反例(过于宽泛,会被打回):"优化登录"、"处理用户模块"
240
+ > 2. **证据块**:动手前先读相关代码,贴出关键原文片段(文件:行号 + 代码),证明已理解现状再改。
241
+ > 3. **涉及文件 + 行数预算**:列出本任务触及的文件;单文件预计超 500 行时,必须在此写明拆分方案(拆成哪些模块/组件)。
242
+ > 4. **回链**:标注 _需求: FR-n_ 与 _设计: 章节_。
223
243
 
224
244
  ### 阶段 1: 准备工作
225
245
 
226
- - [ ] 1.1 [填写:任务标题]
227
- - [填写:具体操作说明]
246
+ - [ ] 1.1 [填写:动词+对象+约束的具体标题]
247
+ - **证据块**: [填写:先读 \`文件:行号\`,贴出现状关键片段]
248
+ - **涉及文件**: [填写:路径 + 行数预算;超 500 行写拆分方案]
228
249
  - _需求: [填写:FR-n]_ | _设计: [填写:design.md 章节]_
229
250
 
230
251
  ---
231
252
 
232
253
  ### 阶段 2: 核心实现
233
254
 
234
- - [ ] 2.1 [填写:任务标题]
235
- - [填写:具体操作说明]
255
+ - [ ] 2.1 [填写:动词+对象+约束的具体标题]
256
+ - **证据块**: [填写:先读 \`文件:行号\`,贴出现状关键片段]
257
+ - **涉及文件**: [填写:路径 + 行数预算;超 500 行写拆分方案]
236
258
  - _需求: [填写:FR-n]_ | _设计: [填写:design.md 章节]_
237
- - [ ] 2.2 [填写:任务标题]
238
- - [填写:具体操作说明]
259
+ - [ ] 2.2 [填写:动词+对象+约束的具体标题]
260
+ - **证据块**: [填写:先读 \`文件:行号\`,贴出现状关键片段]
261
+ - **涉及文件**: [填写:路径 + 行数预算;超 500 行写拆分方案]
239
262
  - _需求: [填写:FR-n]_ | _设计: [填写:design.md 章节]_
240
263
 
241
264
  ---
242
265
 
243
266
  ### 阶段 3: 集成测试
244
267
 
245
- - [ ] 3.1 [填写:任务标题(对照验收标准逐条核验)]
246
- - [填写:具体操作说明]
268
+ - [ ] 3.1 [填写:动词+对象+约束的标题(对照验收标准逐条核验)]
269
+ - **证据块**: [填写:先读相关测试/接口现状]
270
+ - **涉及文件**: [填写:测试文件路径]
247
271
  - _需求: [填写:FR-n]_ | _设计: [填写:design.md 章节]_
248
272
 
249
273
  ---
@@ -269,19 +293,23 @@ const EMBEDDED_TEMPLATES = {
269
293
 
270
294
  ## 文件变更清单
271
295
 
272
- | 文件 | 操作 | 说明 |
273
- |------|------|------|
274
- | [填写:文件路径] | 新建/修改 | [填写:说明] |
296
+ | 文件 | 操作 | 行数预算 | 说明 |
297
+ |------|------|----------|------|
298
+ | [填写:文件路径] | 新建/修改 | [填写:预计行数] | [填写:说明] |
275
299
 
276
300
  ---
277
301
 
278
302
  ## 检查清单
279
303
 
304
+ - [ ] 交付物清单(Scope-lock)已填,实现后数量已逐项核对
305
+ - [ ] 每条任务标题是"动词+对象+约束"的具体描述,无宽泛标题
306
+ - [ ] 每条任务含证据块(先读后写)
307
+ - [ ] 每条任务标注涉及文件与行数预算,超 500 行的有拆分方案
280
308
  - [ ] 任务分阶段合理,粒度可在单次提交内完成
281
- - [ ] 每项任务可执行且可验证
282
309
  - [ ] 每条任务都回链到 FR 与 design 章节
283
310
  - [ ] 需求覆盖矩阵已填,无遗漏的 FR
284
311
  - [ ] 阶段 3 包含"对照验收标准核验"
312
+ - [ ] 全文无 \`[填写]\` / \`TODO\` / 省略号占位(二元禁令)
285
313
  `,
286
314
  'specs/feature/strict/requirements.md': `# 需求文档:{feature_name}
287
315
 
@@ -399,26 +427,50 @@ const EMBEDDED_TEMPLATES = {
399
427
 
400
428
  实现 {feature_name} 的任务分解;每条任务回链 FR 与 design 章节。
401
429
 
430
+ > **二元禁令**:交付物中零容忍 \`[填写]\` / \`TODO\` / \`// ...\` 等占位。动手前先读相关代码贴出证据,再写实现。单文件超 500 行必须拆分。
431
+
432
+ ---
433
+
434
+ ## 交付物清单(Scope-lock)
435
+
436
+ - 预计文件数: [填写:N]
437
+ - 预计任务数: [填写:N]
438
+
439
+ > 实现完成前回读本清单逐项核对,数量不符即未完成。
440
+
402
441
  ---
403
442
 
404
443
  ## 任务列表
405
444
 
445
+ > 每条任务标题须为「[动词]+[对象]+[约束]」的具体写法(如「新建 auth.service.ts 实现 JWT 签发,≤120 行」),禁止「优化登录」式宽泛描述。
446
+
406
447
  ### 阶段 1: 准备工作
407
448
 
408
- - [ ] 1.1 [填写:任务标题] — _需求: [填写:FR-n]_ | _设计: [填写:章节]_
449
+ - [ ] 1.1 [填写:动词+对象+约束]
450
+ - 证据块: [填写:动手前需读的文件:行号]
451
+ - 文件: [填写:路径](预算 [填写] 行,超 500 行拆分)
452
+ - _需求: [填写:FR-n]_ · _设计: [填写:章节]_
409
453
 
410
454
  ---
411
455
 
412
456
  ### 阶段 2: 核心实现
413
457
 
414
- - [ ] 2.1 [填写:任务标题] — _需求: [填写:FR-n]_ | _设计: [填写:章节]_
415
- - [ ] 2.2 [填写:任务标题] — _需求: [填写:FR-n]_ | _设计: [填写:章节]_
458
+ - [ ] 2.1 [填写:动词+对象+约束]
459
+ - 证据块: [填写:文件:行号]
460
+ - 文件: [填写:路径](预算 [填写] 行)
461
+ - _需求: [填写:FR-n]_ · _设计: [填写:章节]_
462
+ - [ ] 2.2 [填写:动词+对象+约束]
463
+ - 证据块: [填写:文件:行号]
464
+ - 文件: [填写:路径](预算 [填写] 行)
465
+ - _需求: [填写:FR-n]_ · _设计: [填写:章节]_
416
466
 
417
467
  ---
418
468
 
419
469
  ### 阶段 3: 集成测试
420
470
 
421
- - [ ] 3.1 [填写:任务标题(对照验收标准核验)] — _需求: [填写:FR-n]_
471
+ - [ ] 3.1 [填写:动词+对象+约束(对照验收标准逐条核验)]
472
+ - 验收点: [填写:对应哪条验收标准]
473
+ - _需求: [填写:FR-n]_
422
474
 
423
475
  ---
424
476
 
@@ -440,9 +492,17 @@ const EMBEDDED_TEMPLATES = {
440
492
 
441
493
  ## 文件变更清单
442
494
 
443
- | 文件 | 操作 | 说明 |
444
- |------|------|------|
445
- | [填写:文件路径] | 新建/修改 | [填写:说明] |
495
+ | 文件 | 操作 | 行数预算 | 说明 |
496
+ |------|------|----------|------|
497
+ | [填写:文件路径] | 新建/修改 | [填写:≤500] | [填写:说明] |
498
+
499
+ ---
500
+
501
+ ## 交付前自检
502
+
503
+ - [ ] 无占位符 / TODO / 省略注释
504
+ - [ ] 交付物数量与 Scope-lock 一致
505
+ - [ ] 每个文件 ≤ 500 行、每条任务回链 FR
446
506
  `,
447
507
  };
448
508
  export function normalizeTemplateProfile(input) {
@@ -15,6 +15,7 @@
15
15
  export const TOOL_ANNOTATIONS = {
16
16
  // —— 只读指南型(可安全自动放行)——
17
17
  init_project: { title: '初始化项目', readOnlyHint: true, idempotentHint: true, openWorldHint: false },
18
+ workflow: { title: '开发工作流路由', readOnlyHint: true, idempotentHint: true, openWorldHint: false },
18
19
  gencommit: { title: '生成提交信息', readOnlyHint: true, idempotentHint: true, openWorldHint: false },
19
20
  code_review: { title: '代码审查', readOnlyHint: true, idempotentHint: true, openWorldHint: false },
20
21
  gentest: { title: '生成测试', readOnlyHint: true, idempotentHint: true, openWorldHint: false },
@@ -44,6 +45,8 @@ export const TOOL_ANNOTATIONS = {
44
45
  // —— 写型(工具自身落盘 / 写记忆 / 写缓存,非破坏)——
45
46
  init_project_context: { title: '生成项目上下文', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }, // 自己写 docs/.mcp-probe/layout.json(其余为指令)
46
47
  memorize_asset: { title: '沉淀记忆资产', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }, // 写 Qdrant
48
+ delete_memory_asset: { title: '删除记忆资产', readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true }, // 删 Qdrant
49
+ update_memory_asset: { title: '更新记忆资产', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }, // 写 Qdrant
47
50
  sync_ui_data: { title: '同步 UI 数据', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }, // 下载 + 写缓存
48
51
  };
49
52
  /**
@@ -14,6 +14,7 @@ import { allToolSchemas } from '../schemas/index.js';
14
14
  export const TOOLSET_DEFINITIONS = {
15
15
  // 核心工具集 - 日常高频工具
16
16
  core: [
17
+ 'workflow',
17
18
  'gencommit',
18
19
  'code_review',
19
20
  'code_insight',
@@ -35,6 +36,7 @@ export const TOOLSET_DEFINITIONS = {
35
36
  ],
36
37
  // 工作流工具集 - 包含核心 + 编排 + 交互
37
38
  workflow: [
39
+ 'workflow',
38
40
  // 核心工具
39
41
  'gencommit',
40
42
  'code_review',
@@ -0,0 +1,38 @@
1
+ export interface SkillEnsureResult {
2
+ skillPath: string;
3
+ skillRelPath: string;
4
+ existed: boolean;
5
+ created: boolean;
6
+ updated: boolean;
7
+ version: string;
8
+ previousVersion: string | null;
9
+ }
10
+ export interface AgentsMdEnsureResult {
11
+ path: string;
12
+ existed: boolean;
13
+ created: boolean;
14
+ updated: boolean;
15
+ }
16
+ export interface McpProbeKitBootstrapResult {
17
+ projectRoot: string;
18
+ skill: SkillEnsureResult;
19
+ agentsMd: AgentsMdEnsureResult;
20
+ }
21
+ export declare function resolveProjectRootFromToolArgs(args: unknown): string;
22
+ /**
23
+ * 同步用户项目 Skill:缺失则创建;已安装版本落后于 kit 则覆盖升级。
24
+ */
25
+ export declare function ensureMcpProbeSkill(projectRoot: string): SkillEnsureResult;
26
+ /**
27
+ * 确保 AGENTS.md 存在且含 mcp-probe 块与 Skill 引用;无则创建,有则按版本合并更新。
28
+ */
29
+ export declare function ensureAgentsMdSkillReference(projectRoot: string): AgentsMdEnsureResult;
30
+ /**
31
+ * 任意 MCP 工具调用前的项目增强:安装 Skill + 同步 AGENTS.md 引用(始终开启)。
32
+ */
33
+ export declare function ensureMcpProbeKitBootstrap(projectRoot: string): McpProbeKitBootstrapResult;
34
+ export declare function ensureMcpProbeKitBootstrapForToolCall(_toolName: string, args: unknown): McpProbeKitBootstrapResult | null;
35
+ /** @deprecated 使用 ensureMcpProbeKitBootstrap */
36
+ export declare function ensureProjectWorkflowSkill(projectRoot: string): McpProbeKitBootstrapResult;
37
+ /** @deprecated 使用 ensureMcpProbeKitBootstrapForToolCall */
38
+ export declare function ensureWorkflowSkillForToolCall(toolName: string, args: unknown): McpProbeKitBootstrapResult | null;
@@ -0,0 +1,158 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { generateAgentsMdInner } from "./agents-md-template.js";
4
+ import { mergeAgentsMdBlock } from "./merge-agents-md.js";
5
+ import { detectDocumentLocale, resolveProjectContextLayout, toPosixPath, } from "./project-context-layout.js";
6
+ import { generateWorkflowSkillContent, LEGACY_WORKFLOW_SKILL_REL_PATH, MCP_PROBE_SKILL_REL_PATH, } from "./workflow-skill-template.js";
7
+ import { agentsContextNeedsUpgrade, getMcpProbeSkillVersion, parseSkillVersionMarker, skillContentNeedsUpgrade, } from "./workflow-skill-version.js";
8
+ import { isLikelyProjectNamedRelativePath, resolveWorkspaceRoot, } from "./workspace-root.js";
9
+ function flattenToolArgs(args) {
10
+ if (!args || typeof args !== "object" || Array.isArray(args)) {
11
+ return {};
12
+ }
13
+ const base = args;
14
+ const nested = base.input && typeof base.input === "object" && !Array.isArray(base.input)
15
+ ? base.input
16
+ : {};
17
+ return { ...base, ...nested };
18
+ }
19
+ export function resolveProjectRootFromToolArgs(args) {
20
+ const record = flattenToolArgs(args);
21
+ const explicit = (typeof record.project_root === "string" ? record.project_root.trim() : "") ||
22
+ (typeof record.projectRoot === "string" ? record.projectRoot.trim() : "") ||
23
+ (typeof record.project_path === "string" ? record.project_path.trim() : "");
24
+ if (explicit && !isLikelyProjectNamedRelativePath(explicit)) {
25
+ return resolveWorkspaceRoot(explicit);
26
+ }
27
+ return resolveWorkspaceRoot("");
28
+ }
29
+ function buildAgentsMdInner(projectRoot, existingAgentsContent) {
30
+ const layout = resolveProjectContextLayout(projectRoot);
31
+ const locale = detectDocumentLocale(projectRoot, existingAgentsContent);
32
+ const graphReady = fs.existsSync(path.join(projectRoot, layout.latestMarkdownPath));
33
+ return generateAgentsMdInner({
34
+ layout,
35
+ locale,
36
+ projectName: path.basename(projectRoot),
37
+ projectVersion: "0.0.0",
38
+ description: "",
39
+ language: "",
40
+ category: "app",
41
+ docs: [],
42
+ projectRootPosix: toPosixPath(projectRoot),
43
+ graphReady,
44
+ });
45
+ }
46
+ function agentsMdNeedsUpdate(content, skillRelPath, targetVersion) {
47
+ if (!content?.trim()) {
48
+ return true;
49
+ }
50
+ if (!content.includes("mcp-probe:context")) {
51
+ return true;
52
+ }
53
+ if (content.includes(LEGACY_WORKFLOW_SKILL_REL_PATH)) {
54
+ return true;
55
+ }
56
+ if (!content.includes(skillRelPath)) {
57
+ return true;
58
+ }
59
+ if (agentsContextNeedsUpgrade(content, targetVersion)) {
60
+ return true;
61
+ }
62
+ return false;
63
+ }
64
+ function writeSkillFile(skillPath, version) {
65
+ fs.mkdirSync(path.dirname(skillPath), { recursive: true });
66
+ fs.writeFileSync(skillPath, generateWorkflowSkillContent(version), "utf8");
67
+ }
68
+ /**
69
+ * 同步用户项目 Skill:缺失则创建;已安装版本落后于 kit 则覆盖升级。
70
+ */
71
+ export function ensureMcpProbeSkill(projectRoot) {
72
+ const root = path.resolve(projectRoot);
73
+ const skillPath = path.join(root, MCP_PROBE_SKILL_REL_PATH);
74
+ const targetVersion = getMcpProbeSkillVersion();
75
+ const existing = fs.existsSync(skillPath) ? fs.readFileSync(skillPath, "utf8") : null;
76
+ const previousVersion = existing ? parseSkillVersionMarker(existing) : null;
77
+ if (!skillContentNeedsUpgrade(existing, targetVersion)) {
78
+ return {
79
+ skillPath,
80
+ skillRelPath: MCP_PROBE_SKILL_REL_PATH,
81
+ existed: Boolean(existing?.trim()),
82
+ created: false,
83
+ updated: false,
84
+ version: targetVersion,
85
+ previousVersion,
86
+ };
87
+ }
88
+ writeSkillFile(skillPath, targetVersion);
89
+ const hadContent = Boolean(existing?.trim());
90
+ return {
91
+ skillPath,
92
+ skillRelPath: MCP_PROBE_SKILL_REL_PATH,
93
+ existed: hadContent,
94
+ created: !hadContent,
95
+ updated: hadContent,
96
+ version: targetVersion,
97
+ previousVersion,
98
+ };
99
+ }
100
+ /**
101
+ * 确保 AGENTS.md 存在且含 mcp-probe 块与 Skill 引用;无则创建,有则按版本合并更新。
102
+ */
103
+ export function ensureAgentsMdSkillReference(projectRoot) {
104
+ const root = path.resolve(projectRoot);
105
+ const layout = resolveProjectContextLayout(root);
106
+ const agentsPath = path.join(root, layout.indexPath);
107
+ const existing = fs.existsSync(agentsPath) ? fs.readFileSync(agentsPath, "utf8") : null;
108
+ const targetVersion = getMcpProbeSkillVersion();
109
+ if (!agentsMdNeedsUpdate(existing, MCP_PROBE_SKILL_REL_PATH, targetVersion)) {
110
+ return {
111
+ path: layout.indexPath,
112
+ existed: Boolean(existing?.trim()),
113
+ created: false,
114
+ updated: false,
115
+ };
116
+ }
117
+ const inner = buildAgentsMdInner(root, existing ?? undefined);
118
+ const { content, mergeMode } = mergeAgentsMdBlock(existing, inner, targetVersion);
119
+ fs.mkdirSync(path.dirname(agentsPath), { recursive: true });
120
+ fs.writeFileSync(agentsPath, content, "utf8");
121
+ const hadContent = Boolean(existing?.trim());
122
+ return {
123
+ path: layout.indexPath,
124
+ existed: hadContent,
125
+ created: !hadContent,
126
+ updated: hadContent && mergeMode !== "skipped-empty",
127
+ };
128
+ }
129
+ /**
130
+ * 任意 MCP 工具调用前的项目增强:安装 Skill + 同步 AGENTS.md 引用(始终开启)。
131
+ */
132
+ export function ensureMcpProbeKitBootstrap(projectRoot) {
133
+ const root = path.resolve(projectRoot);
134
+ return {
135
+ projectRoot: root,
136
+ skill: ensureMcpProbeSkill(root),
137
+ agentsMd: ensureAgentsMdSkillReference(root),
138
+ };
139
+ }
140
+ export function ensureMcpProbeKitBootstrapForToolCall(_toolName, args) {
141
+ try {
142
+ const projectRoot = resolveProjectRootFromToolArgs(args);
143
+ return ensureMcpProbeKitBootstrap(projectRoot);
144
+ }
145
+ catch (error) {
146
+ const message = error instanceof Error ? error.message : String(error);
147
+ console.error(`[MCP Probe Kit] mcp-probe-kit bootstrap failed: ${message}`);
148
+ return null;
149
+ }
150
+ }
151
+ /** @deprecated 使用 ensureMcpProbeKitBootstrap */
152
+ export function ensureProjectWorkflowSkill(projectRoot) {
153
+ return ensureMcpProbeKitBootstrap(projectRoot);
154
+ }
155
+ /** @deprecated 使用 ensureMcpProbeKitBootstrapForToolCall */
156
+ export function ensureWorkflowSkillForToolCall(toolName, args) {
157
+ return ensureMcpProbeKitBootstrapForToolCall(toolName, args);
158
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 由 mcp-tool-skill-registry 生成 Skill 正文(勿在此硬编码工具表)。
3
+ * 本仓库 dogfood 文件由 `npm run sync-workflow-skill`(prebuild)自动写入。
4
+ */
5
+ export declare const MCP_PROBE_SKILL_REL_PATH = ".agents/skills/mcp-probe-kit/SKILL.md";
6
+ /** @deprecated 旧路径,仅用于检测并升级 AGENTS.md 引用 */
7
+ export declare const LEGACY_WORKFLOW_SKILL_REL_PATH = ".agents/skills/workflow/SKILL.md";
8
+ export declare function generateWorkflowSkillBody(skillVersion?: string): string;
9
+ export declare function generateWorkflowSkillContent(skillVersion?: string): string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 由 mcp-tool-skill-registry 生成 Skill 正文(勿在此硬编码工具表)。
3
+ * 本仓库 dogfood 文件由 `npm run sync-workflow-skill`(prebuild)自动写入。
4
+ */
5
+ import { VERSION } from "../version.js";
6
+ import { MCP_INTENT_QUICK_LOOKUP, MCP_SKILL_AVOID_RULES, MCP_SKILL_COMMON_FLOWS, MCP_TOOL_SKILL_GROUPS, } from "./mcp-tool-skill-registry.js";
7
+ import { formatSkillVersionMarker } from "./workflow-skill-version.js";
8
+ export const MCP_PROBE_SKILL_REL_PATH = ".agents/skills/mcp-probe-kit/SKILL.md";
9
+ /** @deprecated 旧路径,仅用于检测并升级 AGENTS.md 引用 */
10
+ export const LEGACY_WORKFLOW_SKILL_REL_PATH = ".agents/skills/workflow/SKILL.md";
11
+ function renderIntentQuickLookup() {
12
+ const rows = MCP_INTENT_QUICK_LOOKUP.map((entry) => `| ${entry.signal} | \`${entry.firstTool}\` |`).join("\n");
13
+ return `| 用户说什么 / 什么情况 | 第一个 MCP |
14
+ |----------------------|------------|
15
+ ${rows}`;
16
+ }
17
+ function renderToolGroups() {
18
+ return MCP_TOOL_SKILL_GROUPS.map((group) => {
19
+ const rows = group.tools
20
+ .map((tool) => `| \`${tool.name}\` | ${tool.whenToCall} |`)
21
+ .join("\n");
22
+ const note = group.note ? `\n\n*${group.note}*` : "";
23
+ return `### ${group.title}
24
+
25
+ | MCP | 何时调用 |
26
+ |-----|----------|
27
+ ${rows}${note}`;
28
+ }).join("\n\n");
29
+ }
30
+ function renderCommonFlows() {
31
+ return MCP_SKILL_COMMON_FLOWS.map((flow) => `**${flow.label}**:\`${flow.chain}\``).join("\n\n");
32
+ }
33
+ function renderAvoidRules() {
34
+ return MCP_SKILL_AVOID_RULES.map((rule) => `- ${rule}`).join("\n");
35
+ }
36
+ export function generateWorkflowSkillBody(skillVersion = VERSION) {
37
+ return `# MCP 调用时机 — mcp-probe-kit
38
+
39
+ > 本 Skill 只回答一件事:**什么情况 → 调哪个 MCP**。不是开发流程剧本。
40
+ > 由 mcp-probe-kit 自动安装;Cursor 从 \`.agents/skills/\` 加载。
41
+
42
+ ## 总规则
43
+
44
+ 1. **先查下表**,有对应 MCP 就先调,再写代码 / 改文件
45
+ 2. **拿不准** → \`workflow\`:\`{ "intent": "<用户原话>" }\`
46
+ 3. \`start_*\` 会列出后续该调的 MCP;按返回逐步调用即可
47
+
48
+ ---
49
+
50
+ ## 意图速查(第一个该调的 MCP)
51
+
52
+ ${renderIntentQuickLookup()}
53
+
54
+ ---
55
+
56
+ ## 全工具:何时调用
57
+
58
+ ${renderToolGroups()}
59
+
60
+ ---
61
+
62
+ ## 常见链路(只是调用顺序参考)
63
+
64
+ ${renderCommonFlows()}
65
+
66
+ ---
67
+
68
+ ## 不要
69
+
70
+ ${renderAvoidRules()}
71
+
72
+ ---
73
+
74
+ *mcp-probe-kit 按版本自动同步(当前 \`${skillVersion}\`)。路径:\`${MCP_PROBE_SKILL_REL_PATH}\`*
75
+ `;
76
+ }
77
+ export function generateWorkflowSkillContent(skillVersion = VERSION) {
78
+ const versionMarker = formatSkillVersionMarker(skillVersion);
79
+ return `${versionMarker}
80
+
81
+ ${generateWorkflowSkillBody(skillVersion)}
82
+
83
+ ${versionMarker}
84
+ `;
85
+ }
@@ -0,0 +1,15 @@
1
+ /** Skill 文件首行版本标记:`<!-- mcp-probe-kit-skill-version: 3.5.0 -->` */
2
+ export declare const SKILL_VERSION_MARKER = "mcp-probe-kit-skill-version";
3
+ /** AGENTS.md mcp-probe 块内版本标记 */
4
+ export declare const AGENTS_CONTEXT_VERSION_MARKER = "mcp-probe:context-version";
5
+ export declare function getMcpProbeSkillVersion(): string;
6
+ export declare function formatSkillVersionMarker(version?: string): string;
7
+ export declare function formatAgentsContextVersionMarker(version?: string): string;
8
+ export declare function parseSkillVersionMarker(content: string): string | null;
9
+ export declare function parseAgentsContextVersion(content: string): string | null;
10
+ /** 比较 semver(仅主版本号段,忽略 prerelease 后缀) */
11
+ export declare function compareSemver(a: string, b: string): number;
12
+ /** 已安装 Skill 是否落后于当前 kit 版本(无标记视为过期) */
13
+ export declare function skillContentNeedsUpgrade(existing: string | null | undefined, targetVersion?: string): boolean;
14
+ /** AGENTS.md mcp-probe 块是否落后于当前 kit 版本 */
15
+ export declare function agentsContextNeedsUpgrade(existing: string | null | undefined, targetVersion?: string): boolean;
@@ -0,0 +1,68 @@
1
+ import { VERSION } from "../version.js";
2
+ /** Skill 文件首行版本标记:`<!-- mcp-probe-kit-skill-version: 3.5.0 -->` */
3
+ export const SKILL_VERSION_MARKER = "mcp-probe-kit-skill-version";
4
+ /** AGENTS.md mcp-probe 块内版本标记 */
5
+ export const AGENTS_CONTEXT_VERSION_MARKER = "mcp-probe:context-version";
6
+ export function getMcpProbeSkillVersion() {
7
+ return VERSION;
8
+ }
9
+ export function formatSkillVersionMarker(version = VERSION) {
10
+ return `<!-- ${SKILL_VERSION_MARKER}: ${version} -->`;
11
+ }
12
+ export function formatAgentsContextVersionMarker(version = VERSION) {
13
+ return `<!-- ${AGENTS_CONTEXT_VERSION_MARKER}: ${version} -->`;
14
+ }
15
+ export function parseSkillVersionMarker(content) {
16
+ const pattern = new RegExp(`<!--\\s*${SKILL_VERSION_MARKER}:\\s*([^\\s>]+)\\s*-->`, "i");
17
+ const match = content.match(pattern);
18
+ return match?.[1]?.trim() ?? null;
19
+ }
20
+ export function parseAgentsContextVersion(content) {
21
+ const pattern = new RegExp(`<!--\\s*${AGENTS_CONTEXT_VERSION_MARKER}:\\s*([^\\s>]+)\\s*-->`, "i");
22
+ const match = content.match(pattern);
23
+ return match?.[1]?.trim() ?? null;
24
+ }
25
+ /** 比较 semver(仅主版本号段,忽略 prerelease 后缀) */
26
+ export function compareSemver(a, b) {
27
+ const normalize = (value) => value
28
+ .trim()
29
+ .replace(/^v/i, "")
30
+ .split("-")[0]
31
+ .split(".")
32
+ .map((part) => {
33
+ const n = Number.parseInt(part, 10);
34
+ return Number.isFinite(n) ? n : 0;
35
+ });
36
+ const left = normalize(a);
37
+ const right = normalize(b);
38
+ const length = Math.max(left.length, right.length);
39
+ for (let i = 0; i < length; i += 1) {
40
+ const diff = (left[i] ?? 0) - (right[i] ?? 0);
41
+ if (diff !== 0) {
42
+ return diff > 0 ? 1 : -1;
43
+ }
44
+ }
45
+ return 0;
46
+ }
47
+ /** 已安装 Skill 是否落后于当前 kit 版本(无标记视为过期) */
48
+ export function skillContentNeedsUpgrade(existing, targetVersion = VERSION) {
49
+ if (!existing?.trim()) {
50
+ return true;
51
+ }
52
+ const installed = parseSkillVersionMarker(existing);
53
+ if (!installed) {
54
+ return true;
55
+ }
56
+ return compareSemver(installed, targetVersion) < 0;
57
+ }
58
+ /** AGENTS.md mcp-probe 块是否落后于当前 kit 版本 */
59
+ export function agentsContextNeedsUpgrade(existing, targetVersion = VERSION) {
60
+ if (!existing?.trim()) {
61
+ return true;
62
+ }
63
+ const installed = parseAgentsContextVersion(existing);
64
+ if (!installed) {
65
+ return true;
66
+ }
67
+ return compareSemver(installed, targetVersion) < 0;
68
+ }