@mycodemap/mycodemap 0.5.2-beta.1 → 2.0.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 (272) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +138 -854
  3. package/README.zh-CN.md +1096 -0
  4. package/dist/cli/commands/analyze-options.d.ts.map +1 -1
  5. package/dist/cli/commands/analyze-options.js +8 -0
  6. package/dist/cli/commands/analyze-options.js.map +1 -1
  7. package/dist/cli/commands/analyze.d.ts.map +1 -1
  8. package/dist/cli/commands/analyze.js +60 -41
  9. package/dist/cli/commands/analyze.js.map +1 -1
  10. package/dist/cli/commands/benchmark.d.ts +8 -0
  11. package/dist/cli/commands/benchmark.d.ts.map +1 -0
  12. package/dist/cli/commands/benchmark.js +150 -0
  13. package/dist/cli/commands/benchmark.js.map +1 -0
  14. package/dist/cli/commands/deps.d.ts +2 -1
  15. package/dist/cli/commands/deps.d.ts.map +1 -1
  16. package/dist/cli/commands/deps.js +107 -78
  17. package/dist/cli/commands/deps.js.map +1 -1
  18. package/dist/cli/commands/doctor.d.ts +3 -0
  19. package/dist/cli/commands/doctor.d.ts.map +1 -0
  20. package/dist/cli/commands/doctor.js +34 -0
  21. package/dist/cli/commands/doctor.js.map +1 -0
  22. package/dist/cli/commands/init.d.ts +7 -2
  23. package/dist/cli/commands/init.d.ts.map +1 -1
  24. package/dist/cli/commands/init.js +22 -34
  25. package/dist/cli/commands/init.js.map +1 -1
  26. package/dist/cli/commands/publish-status.d.ts +31 -0
  27. package/dist/cli/commands/publish-status.d.ts.map +1 -0
  28. package/dist/cli/commands/publish-status.js +101 -0
  29. package/dist/cli/commands/publish-status.js.map +1 -0
  30. package/dist/cli/commands/query.d.ts +1 -0
  31. package/dist/cli/commands/query.d.ts.map +1 -1
  32. package/dist/cli/commands/query.js +123 -140
  33. package/dist/cli/commands/query.js.map +1 -1
  34. package/dist/cli/commands/readiness-gate.d.ts +25 -0
  35. package/dist/cli/commands/readiness-gate.d.ts.map +1 -0
  36. package/dist/cli/commands/readiness-gate.js +197 -0
  37. package/dist/cli/commands/readiness-gate.js.map +1 -0
  38. package/dist/cli/commands/ship/checker.d.ts +4 -9
  39. package/dist/cli/commands/ship/checker.d.ts.map +1 -1
  40. package/dist/cli/commands/ship/checker.js +60 -22
  41. package/dist/cli/commands/ship/checker.js.map +1 -1
  42. package/dist/cli/commands/ship/monitor.d.ts +6 -1
  43. package/dist/cli/commands/ship/monitor.d.ts.map +1 -1
  44. package/dist/cli/commands/ship/monitor.js +223 -46
  45. package/dist/cli/commands/ship/monitor.js.map +1 -1
  46. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
  47. package/dist/cli/commands/ship/pipeline.js +14 -5
  48. package/dist/cli/commands/ship/pipeline.js.map +1 -1
  49. package/dist/cli/commands/ship/rules/quality-rules.d.ts +12 -8
  50. package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -1
  51. package/dist/cli/commands/ship/rules/quality-rules.js +49 -34
  52. package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -1
  53. package/dist/cli/config-loader.js +1 -1
  54. package/dist/cli/config-loader.js.map +1 -1
  55. package/dist/cli/doctor/check-agent.d.ts +3 -0
  56. package/dist/cli/doctor/check-agent.d.ts.map +1 -0
  57. package/dist/cli/doctor/check-agent.js +60 -0
  58. package/dist/cli/doctor/check-agent.js.map +1 -0
  59. package/dist/cli/doctor/check-ghost-commands.d.ts +3 -0
  60. package/dist/cli/doctor/check-ghost-commands.d.ts.map +1 -0
  61. package/dist/cli/doctor/check-ghost-commands.js +86 -0
  62. package/dist/cli/doctor/check-ghost-commands.js.map +1 -0
  63. package/dist/cli/doctor/check-native-deps.d.ts +3 -0
  64. package/dist/cli/doctor/check-native-deps.d.ts.map +1 -0
  65. package/dist/cli/doctor/check-native-deps.js +54 -0
  66. package/dist/cli/doctor/check-native-deps.js.map +1 -0
  67. package/dist/cli/doctor/check-workspace-drift.d.ts +3 -0
  68. package/dist/cli/doctor/check-workspace-drift.d.ts.map +1 -0
  69. package/dist/cli/doctor/check-workspace-drift.js +83 -0
  70. package/dist/cli/doctor/check-workspace-drift.js.map +1 -0
  71. package/dist/cli/doctor/formatter.d.ts +20 -0
  72. package/dist/cli/doctor/formatter.d.ts.map +1 -0
  73. package/dist/cli/doctor/formatter.js +91 -0
  74. package/dist/cli/doctor/formatter.js.map +1 -0
  75. package/dist/cli/doctor/index.d.ts +8 -0
  76. package/dist/cli/doctor/index.d.ts.map +1 -0
  77. package/dist/cli/doctor/index.js +9 -0
  78. package/dist/cli/doctor/index.js.map +1 -0
  79. package/dist/cli/doctor/orchestrator.d.ts +3 -0
  80. package/dist/cli/doctor/orchestrator.d.ts.map +1 -0
  81. package/dist/cli/doctor/orchestrator.js +37 -0
  82. package/dist/cli/doctor/orchestrator.js.map +1 -0
  83. package/dist/cli/doctor/types.d.ts +19 -0
  84. package/dist/cli/doctor/types.d.ts.map +1 -0
  85. package/dist/cli/doctor/types.js +4 -0
  86. package/dist/cli/doctor/types.js.map +1 -0
  87. package/dist/cli/first-run-guide.d.ts.map +1 -1
  88. package/dist/cli/first-run-guide.js +10 -12
  89. package/dist/cli/first-run-guide.js.map +1 -1
  90. package/dist/cli/index.js +80 -21
  91. package/dist/cli/index.js.map +1 -1
  92. package/dist/cli/init/hooks.d.ts +17 -0
  93. package/dist/cli/init/hooks.d.ts.map +1 -0
  94. package/dist/cli/init/hooks.js +220 -0
  95. package/dist/cli/init/hooks.js.map +1 -0
  96. package/dist/cli/init/receipt.d.ts +4 -0
  97. package/dist/cli/init/receipt.d.ts.map +1 -0
  98. package/dist/cli/init/receipt.js +117 -0
  99. package/dist/cli/init/receipt.js.map +1 -0
  100. package/dist/cli/init/reconciler.d.ts +44 -0
  101. package/dist/cli/init/reconciler.d.ts.map +1 -0
  102. package/dist/cli/init/reconciler.js +377 -0
  103. package/dist/cli/init/reconciler.js.map +1 -0
  104. package/dist/cli/init/rule-templates.d.ts +9 -0
  105. package/dist/cli/init/rule-templates.d.ts.map +1 -0
  106. package/dist/cli/init/rule-templates.js +105 -0
  107. package/dist/cli/init/rule-templates.js.map +1 -0
  108. package/dist/cli/init/rules.d.ts +13 -0
  109. package/dist/cli/init/rules.d.ts.map +1 -0
  110. package/dist/cli/init/rules.js +113 -0
  111. package/dist/cli/init/rules.js.map +1 -0
  112. package/dist/cli/interface-contract/commands/analyze.d.ts +3 -0
  113. package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -0
  114. package/dist/cli/interface-contract/commands/analyze.js +138 -0
  115. package/dist/cli/interface-contract/commands/analyze.js.map +1 -0
  116. package/dist/cli/interface-contract/commands/benchmark.d.ts +3 -0
  117. package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -0
  118. package/dist/cli/interface-contract/commands/benchmark.js +107 -0
  119. package/dist/cli/interface-contract/commands/benchmark.js.map +1 -0
  120. package/dist/cli/interface-contract/commands/deps.d.ts +3 -0
  121. package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -0
  122. package/dist/cli/interface-contract/commands/deps.js +129 -0
  123. package/dist/cli/interface-contract/commands/deps.js.map +1 -0
  124. package/dist/cli/interface-contract/commands/doctor.d.ts +3 -0
  125. package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -0
  126. package/dist/cli/interface-contract/commands/doctor.js +59 -0
  127. package/dist/cli/interface-contract/commands/doctor.js.map +1 -0
  128. package/dist/cli/interface-contract/commands/index.d.ts +9 -0
  129. package/dist/cli/interface-contract/commands/index.d.ts.map +1 -0
  130. package/dist/cli/interface-contract/commands/index.js +18 -0
  131. package/dist/cli/interface-contract/commands/index.js.map +1 -0
  132. package/dist/cli/interface-contract/commands/init.d.ts +3 -0
  133. package/dist/cli/interface-contract/commands/init.d.ts.map +1 -0
  134. package/dist/cli/interface-contract/commands/init.js +87 -0
  135. package/dist/cli/interface-contract/commands/init.js.map +1 -0
  136. package/dist/cli/interface-contract/commands/query.d.ts +3 -0
  137. package/dist/cli/interface-contract/commands/query.d.ts.map +1 -0
  138. package/dist/cli/interface-contract/commands/query.js +185 -0
  139. package/dist/cli/interface-contract/commands/query.js.map +1 -0
  140. package/dist/cli/interface-contract/index.d.ts +22 -0
  141. package/dist/cli/interface-contract/index.d.ts.map +1 -0
  142. package/dist/cli/interface-contract/index.js +41 -0
  143. package/dist/cli/interface-contract/index.js.map +1 -0
  144. package/dist/cli/interface-contract/schema.d.ts +30 -0
  145. package/dist/cli/interface-contract/schema.d.ts.map +1 -0
  146. package/dist/cli/interface-contract/schema.js +72 -0
  147. package/dist/cli/interface-contract/schema.js.map +1 -0
  148. package/dist/cli/interface-contract/types.d.ts +76 -0
  149. package/dist/cli/interface-contract/types.d.ts.map +1 -0
  150. package/dist/cli/interface-contract/types.js +4 -0
  151. package/dist/cli/interface-contract/types.js.map +1 -0
  152. package/dist/cli/output/apply-suggestion.d.ts +12 -0
  153. package/dist/cli/output/apply-suggestion.d.ts.map +1 -0
  154. package/dist/cli/output/apply-suggestion.js +29 -0
  155. package/dist/cli/output/apply-suggestion.js.map +1 -0
  156. package/dist/cli/output/error-codes.d.ts +22 -0
  157. package/dist/cli/output/error-codes.d.ts.map +1 -0
  158. package/dist/cli/output/error-codes.js +82 -0
  159. package/dist/cli/output/error-codes.js.map +1 -0
  160. package/dist/cli/output/errors.d.ts +14 -0
  161. package/dist/cli/output/errors.d.ts.map +1 -0
  162. package/dist/cli/output/errors.js +170 -0
  163. package/dist/cli/output/errors.js.map +1 -0
  164. package/dist/cli/output/index.d.ts +13 -0
  165. package/dist/cli/output/index.d.ts.map +1 -0
  166. package/dist/cli/output/index.js +11 -0
  167. package/dist/cli/output/index.js.map +1 -0
  168. package/dist/cli/output/mode.d.ts +12 -0
  169. package/dist/cli/output/mode.d.ts.map +1 -0
  170. package/dist/cli/output/mode.js +23 -0
  171. package/dist/cli/output/mode.js.map +1 -0
  172. package/dist/cli/output/progress.d.ts +9 -0
  173. package/dist/cli/output/progress.d.ts.map +1 -0
  174. package/dist/cli/output/progress.js +65 -0
  175. package/dist/cli/output/progress.js.map +1 -0
  176. package/dist/cli/output/render.d.ts +11 -0
  177. package/dist/cli/output/render.d.ts.map +1 -0
  178. package/dist/cli/output/render.js +18 -0
  179. package/dist/cli/output/render.js.map +1 -0
  180. package/dist/cli/output/types.d.ts +53 -0
  181. package/dist/cli/output/types.d.ts.map +1 -0
  182. package/dist/cli/output/types.js +14 -0
  183. package/dist/cli/output/types.js.map +1 -0
  184. package/dist/cli/output/wasm-fallback.d.ts +13 -0
  185. package/dist/cli/output/wasm-fallback.d.ts.map +1 -0
  186. package/dist/cli/output/wasm-fallback.js +92 -0
  187. package/dist/cli/output/wasm-fallback.js.map +1 -0
  188. package/dist/cli/paths.d.ts +4 -2
  189. package/dist/cli/paths.d.ts.map +1 -1
  190. package/dist/cli/paths.js +13 -5
  191. package/dist/cli/paths.js.map +1 -1
  192. package/dist/cli/tree-sitter-check.d.ts +6 -1
  193. package/dist/cli/tree-sitter-check.d.ts.map +1 -1
  194. package/dist/cli/tree-sitter-check.js +23 -1
  195. package/dist/cli/tree-sitter-check.js.map +1 -1
  196. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
  197. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +2 -2
  198. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
  199. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +23 -0
  200. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -0
  201. package/dist/infrastructure/storage/adapters/sqlite-loader.js +210 -0
  202. package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -0
  203. package/dist/orchestrator/test-linker.d.ts.map +1 -1
  204. package/dist/orchestrator/test-linker.js +5 -36
  205. package/dist/orchestrator/test-linker.js.map +1 -1
  206. package/dist/orchestrator/types.d.ts +2 -0
  207. package/dist/orchestrator/types.d.ts.map +1 -1
  208. package/dist/orchestrator/types.js.map +1 -1
  209. package/dist/parser/implementations/tree-sitter-loader.d.ts +16 -0
  210. package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -0
  211. package/dist/parser/implementations/tree-sitter-loader.js +105 -0
  212. package/dist/parser/implementations/tree-sitter-loader.js.map +1 -0
  213. package/dist/parser/implementations/tree-sitter-parser.d.ts +3 -0
  214. package/dist/parser/implementations/tree-sitter-parser.d.ts.map +1 -1
  215. package/dist/parser/implementations/tree-sitter-parser.js +8 -3
  216. package/dist/parser/implementations/tree-sitter-parser.js.map +1 -1
  217. package/dist/server/mcp/schema-adapter.d.ts +45 -0
  218. package/dist/server/mcp/schema-adapter.d.ts.map +1 -0
  219. package/dist/server/mcp/schema-adapter.js +290 -0
  220. package/dist/server/mcp/schema-adapter.js.map +1 -0
  221. package/dist/server/mcp/server.d.ts.map +1 -1
  222. package/dist/server/mcp/server.js +32 -2
  223. package/dist/server/mcp/server.js.map +1 -1
  224. package/docs/AI_ASSISTANT_SETUP.md +173 -14
  225. package/docs/README.md +40 -1
  226. package/docs/SETUP_GUIDE.md +23 -26
  227. package/docs/agents/domain.md +36 -0
  228. package/docs/agents/issue-tracker.md +22 -0
  229. package/docs/agents/triage-labels.md +15 -0
  230. package/docs/ai-guide/COMMANDS.md +125 -13
  231. package/docs/ai-guide/INTEGRATION.md +78 -11
  232. package/docs/ai-guide/OUTPUT.md +295 -2
  233. package/docs/ai-guide/PATTERNS.md +3 -3
  234. package/docs/ai-guide/PROMPTS.md +2 -2
  235. package/docs/ai-guide/QUICKSTART.md +41 -5
  236. package/docs/ai-guide/README.md +9 -9
  237. package/docs/archive/ideation/2026-04-15-executable-architecture-constitution-ideation-archive.md +70 -0
  238. package/docs/archive/ideation/2026-04-20-mycodemap-init-enhancements-ideation-archive.md +109 -0
  239. package/docs/archive/ideation/2026-04-22-harness-rules-entry-docs-optimization-ideation.md +102 -0
  240. package/docs/archive/ideation/2026-04-22-rules-claude-agents-optimization-ideation.md +107 -0
  241. package/docs/archive/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation-archive.md +54 -0
  242. package/docs/brainstorms/2026-04-22-rules-entry-docs-phase1-structure-consolidation-requirements.md +110 -0
  243. package/docs/brainstorms/999.1-mycodemap-init-enhancements-requirements.md +166 -0
  244. package/docs/exec-plans/README.md +3 -0
  245. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +10 -22
  246. package/docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md +51 -0
  247. package/docs/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation.md +114 -0
  248. package/docs/ideation/2026-04-29-ux-install-agent-experience-ideation.md +256 -0
  249. package/docs/lesson-learn/2026-04-19-prerelease-trusted-publishing-fix.md +119 -0
  250. package/docs/lesson-learn/image.png +0 -0
  251. package/docs/plans/2026-04-30-install-guide-and-repo-analyzer-design.md +394 -0
  252. package/docs/rules/README.md +5 -1
  253. package/docs/rules/architecture-guardrails.md +2 -1
  254. package/docs/rules/deployment.md +7 -0
  255. package/docs/rules/engineering-with-codex-openai.md +48 -9
  256. package/docs/rules/harness.md +106 -0
  257. package/docs/rules/pre-release-checklist.md +72 -33
  258. package/docs/rules/release.md +303 -0
  259. package/docs/rules/testing.md +70 -0
  260. package/docs/rules/validation.md +16 -7
  261. package/examples/claude/skills/mycodemap-repo-analyzer/SKILL.md +294 -0
  262. package/examples/claude/skills/mycodemap-repo-analyzer/references/analysis-guide.md +166 -0
  263. package/examples/claude/skills/mycodemap-repo-analyzer/references/module-analysis-guide.md +150 -0
  264. package/mycodemap.config.schema.json +1 -1
  265. package/package.json +9 -6
  266. package/scripts/hooks/templates/commit-msg +38 -0
  267. package/scripts/hooks/templates/pre-commit +224 -0
  268. package/scripts/pre-release-check.js +4 -4
  269. package/scripts/release.sh +1 -1
  270. package/scripts/sync-analyze-docs.js +2 -2
  271. package/scripts/validate-docs.js +395 -29
  272. package/docs/references/tmp.md +0 -527
package/docs/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # docs/ - 文档信息架构
2
2
 
3
- 本目录采用“入口文档短、细节文档分层”的结构。
3
+ > **v2.0 里程碑上下文**:当前文档体系对应 CodeMap v2.0(”agent-native-foundation”)。v2.0 引入了 CLI-as-MCP 自动网关、接口契约 Schema、WASM-first 构建基础等核心能力。详见下方 [v2.0 文档索引](#v20-文档索引)。
4
+
5
+ 本目录采用”入口文档短、细节文档分层”的结构。
4
6
 
5
7
  ## 目录职责
6
8
 
@@ -11,6 +13,8 @@
11
13
  - `docs/product-specs/`:当前仍有效的产品规格与验收边界。
12
14
  - `docs/references/`:外部参考、设计系统、工具链资料。
13
15
  - `docs/archive/`:历史方案、迁移遗留、过期文档索引。
16
+ - `docs/ai-guide/`:AI / Agent 集成指南(v2.0 新增)。
17
+ - `src/cli/interface-contract/`:接口契约 Schema 定义(单一 Schema 生成 parser、MCP tool 定义、`--help-json`、shell 补全)。
14
18
 
15
19
  ## 当前状态
16
20
 
@@ -19,6 +23,20 @@
19
23
  - `docs/design-docs/` 与 `docs/product-specs/` 当前不再保留旧稿;历史内容请从 `docs/archive/README.md` 进入。
20
24
  - 新增内容优先写入分层目录,不再把新设计或新计划继续堆到根层。
21
25
 
26
+ ### v2.0 功能状态
27
+
28
+ v2.0("agent-native-foundation")已引入以下核心能力,相关文档已就位:
29
+
30
+ | 功能 | 状态 | 文档位置 |
31
+ |------|------|----------|
32
+ | **CLI-as-MCP 自动网关** | 已交付 | `docs/ai-guide/INTEGRATION.md` |
33
+ | `codemap doctor` 持续健康诊断 | 已交付 | `AI_GUIDE.md` + `src/cli/doctor/` |
34
+ | `codemap benchmark` WASM/Native 性能对比 | 已交付 | `AI_GUIDE.md` |
35
+ | `--schema` 接口契约输出 | 已交付 | `AI_GUIDE.md` + `src/cli/interface-contract/` |
36
+ | WASM-first 构建基础 | 已交付 | `AI_GUIDE.md` + `src/cli/loaders/` |
37
+ | AI-First 默认输出(JSON/NDJSON) | 已交付 | `AI_GUIDE.md` |
38
+ | Failure-to-Action 协议 | 已交付 | `docs/rules/harness.md` |
39
+
22
40
  ## 建议阅读顺序
23
41
 
24
42
  1. `../AGENTS.md`
@@ -28,6 +46,27 @@
28
46
  5. 与任务最相关的现行文档;如需历史背景,再看 `docs/archive/README.md`
29
47
  6. 如需过程信息,再看 `docs/exec-plans/*`
30
48
 
49
+ ## v2.0 文档索引
50
+
51
+ 以下文档涵盖 v2.0 核心功能,按主题分类:
52
+
53
+ ### AI / Agent 集成
54
+ - `docs/ai-guide/INTEGRATION.md` — CLI-as-MCP 自动网关配置指南(动态 tool 注册、20+ 命令自动暴露)
55
+ - `docs/ai-guide/AI_ASSISTANT_SETUP.md` — AI 助手(Kimi、Claude、Codex、Cursor、Copilot)集成配置
56
+ - `AI_GUIDE.md` — CodeMap CLI / MCP / AI 使用总览(含 `doctor`、`benchmark`、`--schema` 用法)
57
+
58
+ ### 接口契约与 Schema
59
+ - `src/cli/interface-contract/` — 单一 Schema 源文件(生成 parser、MCP tool 定义、`--help-json`、shell 补全)
60
+ - 运行 `codemap --schema` 可输出完整契约 JSON,供 Agent 自省
61
+
62
+ ### Harness 与 Agent 控制
63
+ - `docs/rules/harness.md` — Harness 设计、Agent 控制、上下文分层、权限升级策略
64
+ - `docs/rules/harness.md` — Failure-to-Action 协议(每个错误返回 `rootCause` + `remediationPlan` + `confidence` + `nextCommand`)
65
+
66
+ ### 架构与构建
67
+ - `ARCHITECTURE.md` — 架构分层、依赖方向、模块边界
68
+ - `src/cli/loaders/` — WASM-first 构建基础(`tree-sitter` → `web-tree-sitter`;`better-sqlite3` → `node:sqlite` / `sql.js`)
69
+
31
70
  ## 维护规则
32
71
 
33
72
  - 入口文档只做导航,不复述大段细节。
@@ -84,11 +84,7 @@ npx @mycodemap/mycodemap --help
84
84
  mycodemap init
85
85
  ```
86
86
 
87
- 会询问以下问题:
88
- - 分析模式(fast/smart/hybrid)
89
- - 包含的文件路径
90
- - 排除的文件路径
91
- - 输出目录
87
+ 默认会显示 reconciliation preview,并说明哪些资产会被创建、迁移、跳过或需要人工处理。
92
88
 
93
89
  ### 使用默认配置
94
90
 
@@ -96,7 +92,11 @@ mycodemap init
96
92
  mycodemap init -y
97
93
  ```
98
94
 
99
- 生成的配置文件 `mycodemap.config.json`:
95
+ 执行后会收敛 canonical 配置 `.mycodemap/config.json`,并把 receipt 写入 `.mycodemap/status/init-last.json`。
96
+
97
+ `init` 会同步 `.mycodemap/hooks/` 与 `.mycodemap/rules/`,但不会自动改写 `CLAUDE.md` / `AGENTS.md`;相关引用片段会通过 receipt 提示你手动加入。
98
+
99
+ 生成的 canonical 配置文件 `.mycodemap/config.json`:
100
100
 
101
101
  ```json
102
102
  {
@@ -116,7 +116,7 @@ mycodemap init -y
116
116
  "watch": false,
117
117
  "storage": {
118
118
  "type": "filesystem",
119
- "outputPath": ".codemap/storage"
119
+ "outputPath": ".mycodemap/storage"
120
120
  },
121
121
  "plugins": {
122
122
  "builtInPlugins": true,
@@ -136,8 +136,8 @@ mycodemap init -y
136
136
  | `output` | string | `".mycodemap"` | 输出目录路径 |
137
137
  | `watch` | boolean | `false` | 监听模式预留配置 |
138
138
  | `storage.type` | string | `"filesystem"` | 图存储后端类型:`filesystem` / `sqlite` / `memory` / `auto` |
139
- | `storage.outputPath` | string | `".codemap/storage"` | 文件系统存储目录 |
140
- | `storage.databasePath` | string | `".codemap/governance.sqlite"` | SQLite 数据库文件路径(相对项目根目录) |
139
+ | `storage.outputPath` | string | `".mycodemap/storage"` | 文件系统存储目录 |
140
+ | `storage.databasePath` | string | `".mycodemap/governance.sqlite"` | SQLite 数据库文件路径(相对项目根目录,建议放在 `.mycodemap/` 下) |
141
141
  | `plugins.builtInPlugins` | boolean | `true` | 是否启用内置插件 |
142
142
  | `plugins.pluginDir` | string | - | 额外插件目录 |
143
143
  | `plugins.plugins` | string[] | `[]` | 显式加载的插件名称列表 |
@@ -146,7 +146,7 @@ mycodemap init -y
146
146
  ### 图存储后端配置
147
147
 
148
148
  - `generate` 会把 CodeGraph 写入 `storage` 指定的后端;`export json|graphml|dot` 会从同一后端读取。
149
- - 选择 `sqlite` 时默认落盘到 `.codemap/governance.sqlite`;也可通过 `storage.databasePath` 覆盖。
149
+ - 选择 `sqlite` 时建议落盘到 `.mycodemap/governance.sqlite`;也可通过 `storage.databasePath` 覆盖。
150
150
  - 旧的 `neo4j` / `kuzudb` 配置已不再受支持,会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
151
151
  - 显式选择 `sqlite` 且运行时缺少 `better-sqlite3` 或 Node.js `<20` 时,会返回显式错误。
152
152
  - `storage.type = "auto"` 当前优先选择 `sqlite`;仅当 SQLite 运行时不可用时才 warning 后回退到 `filesystem`。
@@ -210,24 +210,21 @@ mycodemap impact -f src/cli/index.ts --transitive
210
210
  ### 统一分析(analyze)
211
211
 
212
212
  ```bash
213
- # 影响分析
214
- mycodemap analyze -i impact -t src/cli/index.ts
215
- mycodemap analyze -i impact -t src/cli/index.ts --scope transitive --include-tests
213
+ # 搜索符号或文件
214
+ mycodemap analyze -i find -k "UnifiedResult" --topK 10
216
215
 
217
- # 依赖分析
218
- mycodemap analyze -i dependency -t src/orchestrator
216
+ # 读取代码范围
217
+ mycodemap analyze -i read -t src/cli/index.ts
218
+ mycodemap analyze -i read -t src/cli/index.ts --scope transitive --include-tests
219
219
 
220
- # 复杂度分析
221
- mycodemap analyze -i complexity -t src/domain
220
+ # 查看模块依赖关系
221
+ mycodemap analyze -i link -t src/orchestrator
222
222
 
223
- # 搜索分析
224
- mycodemap analyze -i search -k "UnifiedResult" --topK 10
223
+ # 展示项目概览或复杂度
224
+ mycodemap analyze -i show -t src/
225
225
 
226
- # 项目概览
227
- mycodemap analyze -i overview -t src/
228
-
229
- # JSON 输出
230
- mycodemap analyze -i impact -t src/index.ts --json
226
+ # JSON 结构化输出
227
+ mycodemap analyze -i find -k "UnifiedResult" --json --structured
231
228
  ```
232
229
 
233
230
  ### 工作流编排(workflow)
@@ -457,8 +454,8 @@ npx mycodemap --help
457
454
  #### 2. 配置文件未找到
458
455
 
459
456
  ```bash
460
- # 确认配置文件存在
461
- ls mycodemap.config.json
457
+ # 确认 canonical 配置文件存在
458
+ ls .mycodemap/config.json
462
459
 
463
460
  # 重新初始化
464
461
  mycodemap init -y
@@ -0,0 +1,36 @@
1
+ # Domain Docs
2
+
3
+ How the engineering skills should consume this repo's domain documentation when exploring the codebase.
4
+
5
+ ## Before exploring, read these
6
+
7
+ - **`CONTEXT.md`** at the repo root, or
8
+ - **`CONTEXT-MAP.md`** at the repo root if it exists — it points at one `CONTEXT.md` per context. Read each one relevant to the topic.
9
+ - **`docs/adr/`** — read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
10
+
11
+ If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The producer skill (`/grill-with-docs`) creates them lazily when terms or decisions actually get resolved.
12
+
13
+ ## File structure
14
+
15
+ Single-context repo:
16
+
17
+ ```
18
+ /
19
+ ├── CONTEXT.md
20
+ ├── docs/adr/
21
+ │ ├── 0001-event-sourced-orders.md
22
+ │ └── 0002-postgres-for-write-model.md
23
+ └── src/
24
+ ```
25
+
26
+ ## Use the glossary's vocabulary
27
+
28
+ When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids.
29
+
30
+ If the concept you need isn't in the glossary yet, that's a signal — either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/grill-with-docs`).
31
+
32
+ ## Flag ADR conflicts
33
+
34
+ If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
35
+
36
+ > _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because…_
@@ -0,0 +1,22 @@
1
+ # Issue tracker: GitHub
2
+
3
+ Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
4
+
5
+ ## Conventions
6
+
7
+ - **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
8
+ - **Read an issue**: `gh issue view <number> --comments`, filtering comments by `jq` and also fetching labels.
9
+ - **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
10
+ - **Comment on an issue**: `gh issue comment <number> --body "..."`
11
+ - **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
12
+ - **Close**: `gh issue close <number> --comment "..."`
13
+
14
+ Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
15
+
16
+ ## When a skill says "publish to the issue tracker"
17
+
18
+ Create a GitHub issue.
19
+
20
+ ## When a skill says "fetch the relevant ticket"
21
+
22
+ Run `gh issue view <number> --comments`.
@@ -0,0 +1,15 @@
1
+ # Triage Labels
2
+
3
+ The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
4
+
5
+ | Label in mattpocock/skills | Label in our tracker | Meaning |
6
+ | -------------------------- | -------------------- | ---------------------------------------- |
7
+ | `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
8
+ | `needs-info` | `needs-info` | Waiting on reporter for more information |
9
+ | `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
10
+ | `ready-for-human` | `ready-for-human` | Requires human implementation |
11
+ | `wontfix` | `wontfix` | Will not be actioned |
12
+
13
+ When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
14
+
15
+ Edit the right-hand column to match whatever vocabulary you actually use.
@@ -2,13 +2,29 @@
2
2
 
3
3
  > 完整的 CLI 命令详解
4
4
  >
5
- > CodeMap 是 AI-first 代码地图工具。以下文档记录当前公开命令,并补充已移除命令的迁移提示。
6
- > 当前 CLI 过渡现实:多数命令显式使用 `--json` 输出机器可读结果;`analyze` 额外支持 `--output-mode machine|human`。
5
+ > CodeMap 是 AI-Native 优先、人类友好的代码架构治理基础设施。以下文档记录当前公开命令,并补充已移除命令的迁移提示。
6
+ > 命名规范:公开命令示例统一使用 `mycodemap`;`codemap` 只作为兼容别名保留,不作为新示例首选。
7
+ > v2.0 AI-First Default Output:默认输出 JSON/NDJSON(非 TTY 或显式 `--json`),人类阅读使用 `--human` 或 TTY 自动检测。
7
8
 
8
9
  ---
9
10
 
10
11
  ## 核心命令
11
12
 
13
+ ### init - 收敛项目状态
14
+
15
+ ```bash
16
+ mycodemap init # 默认显示 reconciliation preview
17
+ mycodemap init --interactive # 显式显示 preview(不写入)
18
+ mycodemap init -y # 使用默认选择直接写入
19
+ ```
20
+
21
+ **行为说明**:
22
+
23
+ - `init` 会收敛 `.mycodemap/config.json`、`.mycodemap/status/init-last.json`、`.mycodemap/hooks/` 与 `.mycodemap/rules/`
24
+ - 默认先显示 receipt preview;只有 `-y/--yes` 才真正写入
25
+ - 若 receipt 中仍有 `manual action`,请先处理这些动作,再继续自动化流程
26
+ - `init` 不会自动改写 `CLAUDE.md` 或 `AGENTS.md`,只会输出可复制的 rules 引用片段
27
+
12
28
  ### generate - 生成代码地图
13
29
 
14
30
  ```bash
@@ -35,12 +51,12 @@ mycodemap generate --ai-context # 生成 AI 描述
35
51
  - `generate` 完成后,`codemap.json` 会带 `graphStatus`、`failedFileCount` 与可选 `parseFailureFiles`;若 `graphStatus = "partial"`,不要把结果当成完整图。
36
52
 
37
53
  **插件运行时说明**:
38
- - `generate` 不提供独立 `--plugin` flags;插件通过 `mycodemap.config.json` 的 `plugins` 段声明。
54
+ - `generate` 不提供独立 `--plugin` flags;插件通过 `.mycodemap/config.json` 的 `plugins` 段声明。
39
55
  - 只有显式存在 `plugins` 段时,`generate` 才会加载插件并运行 analyze / generate hooks。
40
56
  - `AI_MAP.md` 会增加 `Plugin Summary`,`codemap.json` 会增加 `pluginReport`,stdout 会输出插件诊断摘要。
41
57
 
42
58
  **图存储运行时说明**:
43
- - `generate` 会读取 `mycodemap.config.json.storage`,并把 CodeGraph 写入所选后端。
59
+ - `generate` 会读取 `.mycodemap/config.json` 的 `storage` 段,并把 CodeGraph 写入所选后端。
44
60
  - `storage.type` 支持 `filesystem`、`sqlite`、`memory`、`auto`;默认是 `filesystem`。
45
61
  - 旧的 `neo4j` / `kuzudb` 配置会直接报迁移错误;显式选择 `sqlite` 但运行时缺少 `better-sqlite3` 或 Node.js `<20` 时也会直接报错,不会静默 fallback 到 `filesystem`。
46
62
  - `storage.type = "auto"` 当前优先走 `sqlite`;只有 SQLite 不可用时才 warning 后回退 `filesystem`。
@@ -109,7 +125,9 @@ mycodemap impact -f "src/cli/index.ts" -j # JSON 输出
109
125
 
110
126
  ---
111
127
 
112
- ### mcp - experimental 本地 MCP 集成
128
+ ### mcp - MCP 集成 (CLI-as-MCP Automatic Gateway)
129
+
130
+ > v2.0 升级为 CLI-as-MCP Automatic Gateway。所有 20+ schema 定义的 CLI 命令自动暴露为 MCP tools;动态 tool 注册。
113
131
 
114
132
  ```bash
115
133
  mycodemap mcp install # 把当前仓库写入 .mcp.json
@@ -119,14 +137,14 @@ mycodemap generate --symbol-level # 使用前必须先生成 symbol-leve
119
137
 
120
138
  | 子命令 | 说明 |
121
139
  |--------|------|
122
- | `install` | 更新当前仓库根目录 `.mcp.json`,追加 `mycodemap-experimental` server entry |
123
- | `start` | 启动 local-only / read-only / stdio-first experimental MCP server |
140
+ | `install` | 更新当前仓库根目录 `.mcp.json`,追加 `mycodemap` server entry |
141
+ | `start` | 启动 local-only / read-only / stdio-first MCP server |
124
142
 
125
- **首期规则**:
126
- - `mcp` experimental surface,不要把它当成稳定长期 public API
143
+ **v2.0 行为**:
144
+ - CLI-as-MCP Automatic Gateway:所有 schema 定义的命令(`generate`、`query`、`deps`、`impact`、`analyze`、`doctor`、`benchmark`、`design`、`check`、`ci`、`history`、`workflow` 等)自动映射为 MCP tools
145
+ - 动态 tool 注册:新增命令无需手动更新 MCP server,schema 变更后自动生效。
127
146
  - `mcp start` 的 `stdout` 只能承载 MCP 协议帧;欢迎信息、迁移提示与 runtime log 不会走这条流。
128
- - 当前只暴露两个工具:`codemap_query`、`codemap_impact`。
129
- - `codemap_query` / `codemap_impact` 都会返回 `graph_status`、`generated_at` 与显式 `error.code`。
147
+ - 所有 MCP tools 返回 `graph_status`、`generated_at` 与显式 `error.code`。
130
148
  - 若图尚未生成,会返回 `GRAPH_NOT_FOUND`;若符号不存在,返回 `SYMBOL_NOT_FOUND`;若同名符号无法消歧,返回 `AMBIGUOUS_EDGE`。
131
149
  - 详细安装步骤见 `docs/ai-guide/INTEGRATION.md`;完整 output contract 见 `docs/ai-guide/OUTPUT.md`。
132
150
 
@@ -233,6 +251,7 @@ mycodemap analyze -i show -t "src/index.ts" --output-mode human
233
251
  | `--include-tests` | 包含测试文件关联 | - |
234
252
  | `--include-git-history` | 包含 Git 历史分析 | - |
235
253
  | `--json` | JSON 格式输出 | - |
254
+ | `--human` | 强制人类可读输出(覆盖非 TTY 默认 JSON 行为) | - |
236
255
  | `--structured` | 纯结构化输出(移除自然语言字段,配合 `--json` 使用) | - |
237
256
  | `--output-mode <mode>` | 输出模式:`machine`/`human` | `human` |
238
257
  <!-- END GENERATED: analyze-commands-options -->
@@ -500,6 +519,60 @@ mycodemap workflow template recommend "任务" # 推荐模板
500
519
 
501
520
  ---
502
521
 
522
+ ## doctor - 持续健康诊断
523
+
524
+ > v2.0 新增。检测 ghost 命令、native 依赖问题、workspace drift、agent 连通性。
525
+
526
+ ```bash
527
+ mycodemap doctor # 人类可读摘要
528
+ mycodemap doctor --json # 机器可读完整诊断
529
+ ```
530
+
531
+ | 类别 | 检查项 | 说明 |
532
+ |------|--------|------|
533
+ | `install` | native 依赖完整性 | 检查 `better-sqlite3` 等 native 模块是否可加载 |
534
+ | `config` | workspace 完整性 | 检查 `.mycodemap/config.json`、图存储后端配置 |
535
+ | `runtime` | ghost 命令检测 | 检测已注册但无实际实现的命令 |
536
+ | `agent` | MCP 连通性 | 检查 MCP server 注册与工具发现是否正常 |
537
+
538
+ - 每个类别独立返回 `ok` / `warn` / `error` 状态
539
+ - `--json` 输出纯结构化 diagnostics,包含 `categories[]`、`summary`、`recommendations`
540
+ - `error` 级别诊断会设置非零 exit code
541
+
542
+ ---
543
+
544
+ ## benchmark - WASM vs Native 性能对比
545
+
546
+ > v2.0 新增。对比 WASM fallback 与 Native 实现的性能差异。
547
+
548
+ ```bash
549
+ mycodemap benchmark # 完整对比(WASM + Native)
550
+ mycodemap benchmark --wasm # 仅 WASM 性能
551
+ mycodemap benchmark --native # 仅 Native 性能
552
+ mycodemap benchmark --json # JSON 输出
553
+ ```
554
+
555
+ - 输出包含各分析阶段的耗时对比(generate、query、deps、impact 等)
556
+ - `--json` 输出结构化 benchmark 结果,便于 CI 集成与回归检测
557
+ - 用于决定是否启用 WASM fallback 或排查性能退化
558
+
559
+ ---
560
+
561
+ ## --schema - 接口契约输出
562
+
563
+ > v2.0 新增。输出完整的 Interface Contract Schema JSON,供 agent 自省与动态 tool 注册。
564
+
565
+ ```bash
566
+ mycodemap --schema # 输出完整 schema JSON
567
+ mycodemap --schema | jq '.' # 格式化查看
568
+ ```
569
+
570
+ - 单一 schema 同时生成:parser、MCP tools、`--help-json`、shell completions
571
+ - Agent 可通过读取 schema 动态发现所有可用命令及其参数契约
572
+ - 输出包含所有 20+ 命令的完整接口定义(参数、类型、返回值结构)
573
+
574
+ ---
575
+
503
576
  ## 已移除的公共命令
504
577
 
505
578
  以下命令已从 public CLI 移除;直接调用时,CLI 会显式失败并给出迁移提示,而不是继续执行旧功能。
@@ -521,7 +594,7 @@ mycodemap export mermaid # Mermaid 语法
521
594
  mycodemap export json -o ./output.json # 指定输出
522
595
  ```
523
596
 
524
- - `export json|graphml|dot` 会从 `mycodemap.config.json.storage` 指定的后端读取 CodeGraph。
597
+ - `export json|graphml|dot` 会从 `.mycodemap/config.json` 的 `storage` 段指定后端读取 CodeGraph。
525
598
  - `export mermaid` 仍直接读取 `.mycodemap/codemap.json`,这是当前保留的文件出口,不代表 graph backend 未接入主路径。
526
599
  - 图存储后端收口不等于重新开放公共 `mycodemap server` 产品面;`Server Layer` 仍是内部层。
527
600
 
@@ -529,7 +602,7 @@ mycodemap export json -o ./output.json # 指定输出
529
602
 
530
603
  ### ship - 一键智能发布(非代码地图首屏能力)
531
604
 
532
- > `ship` 负责发布整合,不是 AI-first 代码地图工具的首屏入口;首次接触项目时优先使用分析命令而非发布命令。
605
+ > `ship` 负责发布整合,不是 CodeMap 代码分析的首屏入口;首次接触项目时优先使用分析命令而非发布命令。
533
606
 
534
607
  ```bash
535
608
  mycodemap ship # 完整发布流程
@@ -563,6 +636,45 @@ mycodemap ship --yes # 置信度 60-75 时自动确认
563
636
 
564
637
  ---
565
638
 
639
+ ### publish-status - 发布后的只读 snapshot 复核
640
+
641
+ > `publish-status` 是 `ship` / `/release` 之后的 follow-up observability surface;它不触发发布、不重跑 workflow,也不猜“最新一条 run”。
642
+
643
+ ```bash
644
+ mycodemap publish-status --tag v1.9.0 --sha abcdef123456
645
+ mycodemap publish-status --tag v1.9.0 --sha abcdef123456 --json
646
+ mycodemap publish-status --tag v1.9.0 --sha abcdef123456 --json --structured
647
+ mycodemap publish-status --tag v1.9.0 --sha abcdef123456 --workflow-file publish.yml
648
+ ```
649
+
650
+ | 选项 | 说明 | 默认值 |
651
+ |------|------|--------|
652
+ | `--tag <tag>` | 发布 tag,必须精确提供 | - |
653
+ | `--sha <sha>` | 发布 commit SHA,必须精确提供 | - |
654
+ | `--workflow-file <file>` | GitHub Actions workflow 文件名 | `publish.yml` |
655
+ | `--json` | 输出 machine-readable JSON | `false` |
656
+ | `--structured` | 去掉自然语言 `content`,需配合 `--json` 使用 | `false` |
657
+
658
+ **状态语义:**
659
+ - `success`:找到唯一精确匹配 run,且 workflow 成功
660
+ - `failure`:找到唯一精确匹配 run,且 workflow 明确失败
661
+ - `pending`:还没观察到精确匹配 run,或 run 仍在执行中
662
+ - `ambiguous`:出现多个同时匹配 `tag + sha` 的 runs;不会猜哪一个才是“最新”
663
+ - `unavailable`:repo slug、GitHub API、权限或最终 truth 无法精确确认
664
+
665
+ **输出契约:**
666
+ - 默认输出终端摘要
667
+ - `--json` 输出 machine-readable payload,并保留 `content`
668
+ - `--json --structured` 移除自然语言字段,仅保留结构化 truth
669
+ - payload 至少包含 `status`、`workflowUrl`、`releaseUrl`、`runId`、`failedJobs`、`reason`、`details`
670
+
671
+ **边界:**
672
+ - 只做一次 snapshot read,不内置轮询
673
+ - 只读;不会 rerun workflow、dispatch workflow、`npm publish`、`git push`
674
+ - 它不会替代 `ship` 或 `/release`,发布 authority 仍在 `docs/rules/release.md`
675
+
676
+ ---
677
+
566
678
  ## 全局选项
567
679
 
568
680
  所有命令支持:
@@ -1,6 +1,6 @@
1
1
  # AI Guide - MCP / Agent 集成
2
2
 
3
- > 当前 canonical integration path:**真实本地 stdio MCP server**。旧 CLI wrapper 只作为 fallback
3
+ > v2.0 更新:CLI-as-MCP Automatic Gateway。所有 schema 定义的 CLI 命令自动暴露为 MCP tools
4
4
 
5
5
  ---
6
6
 
@@ -11,11 +11,16 @@
11
11
  | transport | 本地 `stdio` |
12
12
  | 读写权限 | **只读** |
13
13
  | public surface | `mycodemap mcp install`、`mycodemap mcp start` |
14
- | MCP tools | `codemap_query`、`codemap_impact` |
14
+ | MCP tools | **ALL 20+ schema 定义的 CLI 命令** |
15
15
  | 图前置条件 | 先执行 `mycodemap generate --symbol-level` |
16
- | 稳定性 | **experimental** |
16
+ | 稳定性 | **stable (v2.0)** |
17
17
  | 非目标 | HTTP MCP、远程 transport、写操作、全局 host lifecycle |
18
18
 
19
+ ### 动态 Tool 注册
20
+
21
+ - 向 `Interface Contract Schema` 添加新命令 → 重启 MCP server → 新 tool 自动出现在 host 中
22
+ - 无需手写 tool 定义、无需修改 MCP server 代码、无需重新安装
23
+
19
24
  ---
20
25
 
21
26
  ## 1.1 速查表
@@ -44,7 +49,7 @@ mycodemap generate --symbol-level
44
49
  mycodemap mcp install
45
50
  ```
46
51
 
47
- 该命令当前只做一件事:在**当前仓库根目录**的 `.mcp.json` 里写入一个 experimental server entry。
52
+ 该命令在当前仓库根目录的 `.mcp.json` 里写入一个 v2.0 server entry。
48
53
 
49
54
  ### Step 3: 让 MCP host 启动 stdio server
50
55
 
@@ -57,6 +62,8 @@ mycodemap mcp start
57
62
  - `stdout` 只承载 MCP 协议帧
58
63
  - 欢迎信息、迁移提示、runtime log 不会混入 `stdout`
59
64
 
65
+ > **v2.0 关键变更**:所有在 `Interface Contract Schema` 中定义的命令自动作为 MCP tools 可用。无需手写 tool 定义,无需逐个注册。
66
+
60
67
  ---
61
68
 
62
69
  ## 3. `.mcp.json` 参考配置
@@ -66,7 +73,7 @@ mycodemap mcp start
66
73
  ```json
67
74
  {
68
75
  "mcpServers": {
69
- "mycodemap-experimental": {
76
+ "mycodemap": {
70
77
  "command": "node",
71
78
  "args": ["dist/cli/index.js", "mcp", "start"],
72
79
  "cwd": "/absolute/path/to/repo",
@@ -80,7 +87,7 @@ mycodemap mcp start
80
87
 
81
88
  ### 当前宿主支持边界
82
89
 
83
- - 当前文档只保证**repo-local `.mcp.json`** 这一路径
90
+ - 当前文档只保证 **repo-local `.mcp.json`** 这一路径
84
91
  - 不承诺全局安装、升级覆盖策略或卸载命令
85
92
  - 若你的 host 不读取 `.mcp.json`,请手动拷贝上面的 server entry 到宿主自己的 MCP 配置文件
86
93
 
@@ -88,7 +95,25 @@ mycodemap mcp start
88
95
 
89
96
  ## 4. MCP tool contract
90
97
 
91
- ### `codemap_query`
98
+ ### Gateway 模式
99
+
100
+ CLI-as-MCP Automatic Gateway 将所有 CLI 命令统一映射为 MCP tools:
101
+
102
+ | CLI 命令 | MCP tool 名 | 输入参数 |
103
+ |----------|-------------|----------|
104
+ | `mycodemap query -s X` | `codemap_query` | `{ symbol: string, filePath?: string }` |
105
+ | `mycodemap impact -f X` | `codemap_impact` | `{ symbol: string, filePath?: string, depth?: number, limit?: number }` |
106
+ | `mycodemap doctor` | `codemap_doctor` | `{ category?: string, json?: boolean }` |
107
+ | `mycodemap benchmark` | `codemap_benchmark` | `{ command?: string, json?: boolean }` |
108
+ | `mycodemap analyze -i find -k X` | `codemap_analyze` | `{ intent: string, keyword: string, ... }` |
109
+ | ... | ... | ... |
110
+
111
+ 映射规则:
112
+ - CLI 命令名 → MCP tool 名前缀为 `codemap_`
113
+ - CLI 短选项(`-s`)和长选项(`--symbol`)→ MCP tool 参数名使用长选项名
114
+ - CLI 输出结构 → MCP tool 返回结构完全一致
115
+
116
+ ### `codemap_query`(示例之一)
92
117
 
93
118
  输入:
94
119
 
@@ -107,7 +132,7 @@ interface CodemapQueryInput {
107
132
  - `generated_at`
108
133
  - `error.code`(若失败)
109
134
 
110
- ### `codemap_impact`
135
+ ### `codemap_impact`(示例之一)
111
136
 
112
137
  输入:
113
138
 
@@ -128,7 +153,7 @@ interface CodemapImpactInput {
128
153
  - `generated_at`
129
154
  - `error.code`(若失败)
130
155
 
131
- > 完整输出类型见 `docs/ai-guide/OUTPUT.md`。
156
+ > 完整输出类型见 `docs/ai-guide/OUTPUT.md`。以上仅为 20+ tools 中的两个示例。
132
157
 
133
158
  ---
134
159
 
@@ -140,6 +165,40 @@ interface CodemapImpactInput {
140
165
  | `SYMBOL_NOT_FOUND` | 请求的 symbol 不存在 | 检查拼写,或先用 `query -S` / `analyze -i find` 搜索 |
141
166
  | `AMBIGUOUS_EDGE` | 同名 symbol 无法仅靠 `symbol` / `filePath` 消歧 | 补充更具体的 `filePath` |
142
167
 
168
+ ### Failure-to-Action Protocol
169
+
170
+ v2.0 错误响应包含可执行的修复指引:
171
+
172
+ ```typescript
173
+ interface McpError {
174
+ code: string;
175
+ message: string;
176
+ details?: Record<string, unknown>;
177
+ // Failure-to-Action Protocol 字段
178
+ rootCause?: string; // 根因分析
179
+ remediationPlan?: string[]; // 修复步骤(按优先级)
180
+ confidence: "high" | "medium" | "low";
181
+ nextCommand?: string; // 建议执行的下一步命令
182
+ }
183
+ ```
184
+
185
+ 示例:
186
+
187
+ ```json
188
+ {
189
+ "code": "GRAPH_NOT_FOUND",
190
+ "message": "symbol-level 图不存在",
191
+ "rootCause": "未执行 mycodemap generate --symbol-level",
192
+ "remediationPlan": [
193
+ "mycodemap generate --symbol-level",
194
+ "mycodemap mcp install",
195
+ "重启 MCP host"
196
+ ],
197
+ "confidence": "high",
198
+ "nextCommand": "mycodemap generate --symbol-level"
199
+ }
200
+ ```
201
+
143
202
  ### `graph_status` 解读
144
203
 
145
204
  | 值 | 含义 |
@@ -158,6 +217,8 @@ interface CodemapImpactInput {
158
217
  mycodemap query -s "SymbolName" -j
159
218
  mycodemap impact -f "src/file.ts" -j
160
219
  mycodemap analyze -i find -k "SymbolName" --json --structured
220
+ mycodemap doctor --json
221
+ mycodemap benchmark --json
161
222
  ```
162
223
 
163
224
  但要注意:
@@ -178,7 +239,7 @@ mycodemap generate --symbol-level
178
239
  ### `mcp install` 后看不到 server
179
240
 
180
241
  - 确认 host 会读取当前仓库根目录的 `.mcp.json`
181
- - 不会读取的话,手动复制 `mycodemap-experimental` entry 到宿主配置
242
+ - 不会读取的话,手动复制 `mycodemap` entry 到宿主配置
182
243
 
183
244
  ### `mcp start` 无法启动
184
245
 
@@ -200,6 +261,12 @@ npm ls better-sqlite3
200
261
  - 先检查 `graph_status` 是否为 `partial`
201
262
  - 再检查 symbol 是否真的唯一;必要时补 `filePath`
202
263
 
264
+ ### 新增命令后 MCP host 看不到新 tool
265
+
266
+ - 确认新命令已注册到 `Interface Contract Schema`(`mycodemap --schema` 检查)
267
+ - 重启 MCP server(host 侧或 `mycodemap mcp start`)
268
+ - 不需要重新运行 `mcp install`,除非 server entry 本身有变更
269
+
203
270
  ### storage 运行时错误速查表
204
271
 
205
272
  | 错误 / 信号 | 含义 | 处理方式 |
@@ -216,4 +283,4 @@ npm ls better-sqlite3
216
283
  - 命令参考:`docs/ai-guide/COMMANDS.md`
217
284
  - 输出契约:`docs/ai-guide/OUTPUT.md`
218
285
  - 主索引:`AI_GUIDE.md`
219
- - 执行手册:`CLAUDE.md`
286
+ - 入口路由:`CLAUDE.md`