@mycodemap/mycodemap 0.4.1 → 0.5.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 (309) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +307 -243
  3. package/dist/ai/claude.d.ts +38 -0
  4. package/dist/ai/claude.d.ts.map +1 -0
  5. package/dist/ai/claude.js +169 -0
  6. package/dist/ai/claude.js.map +1 -0
  7. package/dist/ai/codex.d.ts +38 -0
  8. package/dist/ai/codex.d.ts.map +1 -0
  9. package/dist/ai/codex.js +169 -0
  10. package/dist/ai/codex.js.map +1 -0
  11. package/dist/ai/factory.d.ts +48 -0
  12. package/dist/ai/factory.d.ts.map +1 -0
  13. package/dist/ai/factory.js +95 -0
  14. package/dist/ai/factory.js.map +1 -0
  15. package/dist/ai/index.d.ts +12 -0
  16. package/dist/ai/index.d.ts.map +1 -0
  17. package/dist/ai/index.js +29 -0
  18. package/dist/ai/index.js.map +1 -0
  19. package/dist/ai/provider.d.ts +70 -0
  20. package/dist/ai/provider.d.ts.map +1 -0
  21. package/dist/ai/provider.js +31 -0
  22. package/dist/ai/provider.js.map +1 -0
  23. package/dist/ai/subagent-caller.d.ts +90 -0
  24. package/dist/ai/subagent-caller.d.ts.map +1 -0
  25. package/dist/ai/subagent-caller.js +280 -0
  26. package/dist/ai/subagent-caller.js.map +1 -0
  27. package/dist/ai/types.d.ts +70 -0
  28. package/dist/ai/types.d.ts.map +1 -0
  29. package/dist/ai/types.js +5 -0
  30. package/dist/ai/types.js.map +1 -0
  31. package/dist/cli/commands/analyze-options.d.ts +36 -0
  32. package/dist/cli/commands/analyze-options.d.ts.map +1 -0
  33. package/dist/cli/commands/analyze-options.js +147 -0
  34. package/dist/cli/commands/analyze-options.js.map +1 -0
  35. package/dist/cli/commands/analyze.d.ts +93 -4
  36. package/dist/cli/commands/analyze.d.ts.map +1 -1
  37. package/dist/cli/commands/analyze.js +592 -176
  38. package/dist/cli/commands/analyze.js.map +1 -1
  39. package/dist/cli/commands/ci.d.ts +47 -1
  40. package/dist/cli/commands/ci.d.ts.map +1 -1
  41. package/dist/cli/commands/ci.js +208 -1
  42. package/dist/cli/commands/ci.js.map +1 -1
  43. package/dist/cli/commands/design.d.ts +47 -0
  44. package/dist/cli/commands/design.d.ts.map +1 -0
  45. package/dist/cli/commands/design.js +268 -0
  46. package/dist/cli/commands/design.js.map +1 -0
  47. package/dist/cli/commands/export.d.ts.map +1 -1
  48. package/dist/cli/commands/export.js +2 -2
  49. package/dist/cli/commands/export.js.map +1 -1
  50. package/dist/cli/commands/generate.d.ts +8 -2
  51. package/dist/cli/commands/generate.d.ts.map +1 -1
  52. package/dist/cli/commands/generate.js +151 -22
  53. package/dist/cli/commands/generate.js.map +1 -1
  54. package/dist/cli/commands/init.d.ts.map +1 -1
  55. package/dist/cli/commands/init.js +2 -13
  56. package/dist/cli/commands/init.js.map +1 -1
  57. package/dist/cli/commands/server.d.ts.map +1 -1
  58. package/dist/cli/commands/server.js +2 -5
  59. package/dist/cli/commands/server.js.map +1 -1
  60. package/dist/cli/commands/ship/checker.d.ts.map +1 -1
  61. package/dist/cli/commands/ship/checker.js +0 -3
  62. package/dist/cli/commands/ship/checker.js.map +1 -1
  63. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
  64. package/dist/cli/commands/ship/pipeline.js +8 -1
  65. package/dist/cli/commands/ship/pipeline.js.map +1 -1
  66. package/dist/cli/commands/ship/publisher.d.ts +9 -1
  67. package/dist/cli/commands/ship/publisher.d.ts.map +1 -1
  68. package/dist/cli/commands/ship/publisher.js +149 -6
  69. package/dist/cli/commands/ship/publisher.js.map +1 -1
  70. package/dist/cli/commands/ship/rules/quality-rules.d.ts +0 -1
  71. package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -1
  72. package/dist/cli/commands/ship/rules/quality-rules.js +4 -76
  73. package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -1
  74. package/dist/cli/commands/workflow.js +4 -4
  75. package/dist/cli/commands/workflow.js.map +1 -1
  76. package/dist/cli/config-loader.d.ts +31 -0
  77. package/dist/cli/config-loader.d.ts.map +1 -0
  78. package/dist/cli/config-loader.js +235 -0
  79. package/dist/cli/config-loader.js.map +1 -0
  80. package/dist/cli/design-contract-loader.d.ts +15 -0
  81. package/dist/cli/design-contract-loader.d.ts.map +1 -0
  82. package/dist/cli/design-contract-loader.js +175 -0
  83. package/dist/cli/design-contract-loader.js.map +1 -0
  84. package/dist/cli/design-contract-schema.d.ts +11 -0
  85. package/dist/cli/design-contract-schema.d.ts.map +1 -0
  86. package/dist/cli/design-contract-schema.js +75 -0
  87. package/dist/cli/design-contract-schema.js.map +1 -0
  88. package/dist/cli/design-handoff-builder.d.ts +15 -0
  89. package/dist/cli/design-handoff-builder.d.ts.map +1 -0
  90. package/dist/cli/design-handoff-builder.js +345 -0
  91. package/dist/cli/design-handoff-builder.js.map +1 -0
  92. package/dist/cli/design-scope-resolver.d.ts +8 -0
  93. package/dist/cli/design-scope-resolver.d.ts.map +1 -0
  94. package/dist/cli/design-scope-resolver.js +712 -0
  95. package/dist/cli/design-scope-resolver.js.map +1 -0
  96. package/dist/cli/design-verification-builder.d.ts +8 -0
  97. package/dist/cli/design-verification-builder.d.ts.map +1 -0
  98. package/dist/cli/design-verification-builder.js +369 -0
  99. package/dist/cli/design-verification-builder.js.map +1 -0
  100. package/dist/cli/index.js +20 -63
  101. package/dist/cli/index.js.map +1 -1
  102. package/dist/cli/removed-commands.d.ts +9 -0
  103. package/dist/cli/removed-commands.d.ts.map +1 -0
  104. package/dist/cli/removed-commands.js +48 -0
  105. package/dist/cli/removed-commands.js.map +1 -0
  106. package/dist/cli/storage-runtime.d.ts +8 -0
  107. package/dist/cli/storage-runtime.d.ts.map +1 -0
  108. package/dist/cli/storage-runtime.js +14 -0
  109. package/dist/cli/storage-runtime.js.map +1 -0
  110. package/dist/cli/tree-sitter-check.d.ts.map +1 -1
  111. package/dist/cli/tree-sitter-check.js +0 -1
  112. package/dist/cli/tree-sitter-check.js.map +1 -1
  113. package/dist/cli-new/commands/export.d.ts.map +1 -1
  114. package/dist/cli-new/commands/export.js +2 -2
  115. package/dist/cli-new/commands/export.js.map +1 -1
  116. package/dist/cli-new/commands/query.d.ts.map +1 -1
  117. package/dist/cli-new/commands/query.js +5 -4
  118. package/dist/cli-new/commands/query.js.map +1 -1
  119. package/dist/cli-new/commands/server.d.ts.map +1 -1
  120. package/dist/cli-new/commands/server.js +2 -6
  121. package/dist/cli-new/commands/server.js.map +1 -1
  122. package/dist/cli-new/index.d.ts.map +1 -1
  123. package/dist/cli-new/index.js +0 -2
  124. package/dist/cli-new/index.js.map +1 -1
  125. package/dist/core/analyzer.d.ts.map +1 -1
  126. package/dist/core/analyzer.js +7 -39
  127. package/dist/core/analyzer.js.map +1 -1
  128. package/dist/core/file-discovery.d.ts +17 -0
  129. package/dist/core/file-discovery.d.ts.map +1 -0
  130. package/dist/core/file-discovery.js +75 -0
  131. package/dist/core/file-discovery.js.map +1 -0
  132. package/dist/core/global-index.d.ts +5 -0
  133. package/dist/core/global-index.d.ts.map +1 -1
  134. package/dist/core/global-index.js +71 -21
  135. package/dist/core/global-index.js.map +1 -1
  136. package/dist/generator/ai-overview.d.ts +51 -0
  137. package/dist/generator/ai-overview.d.ts.map +1 -0
  138. package/dist/generator/ai-overview.js +160 -0
  139. package/dist/generator/ai-overview.js.map +1 -0
  140. package/dist/generator/index.d.ts.map +1 -1
  141. package/dist/generator/index.js +8 -0
  142. package/dist/generator/index.js.map +1 -1
  143. package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -5
  144. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
  145. package/dist/infrastructure/parser/implementations/GoParser.js +2 -5
  146. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
  147. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +1 -5
  148. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -1
  149. package/dist/infrastructure/parser/implementations/PythonParser.js +1 -5
  150. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -1
  151. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +1 -5
  152. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
  153. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +1 -5
  154. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
  155. package/dist/infrastructure/storage/StorageFactory.d.ts +12 -6
  156. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  157. package/dist/infrastructure/storage/StorageFactory.js +59 -43
  158. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  159. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  160. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +24 -137
  161. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  162. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +10 -18
  163. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  164. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +103 -146
  165. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  166. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +0 -1
  167. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  168. package/dist/infrastructure/storage/adapters/MemoryStorage.js +16 -136
  169. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  170. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +9 -17
  171. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -1
  172. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +78 -138
  173. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -1
  174. package/dist/infrastructure/storage/graph-helpers.d.ts +16 -0
  175. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -0
  176. package/dist/infrastructure/storage/graph-helpers.js +161 -0
  177. package/dist/infrastructure/storage/graph-helpers.js.map +1 -0
  178. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  179. package/dist/interface/config/index.d.ts +10 -1
  180. package/dist/interface/config/index.d.ts.map +1 -1
  181. package/dist/interface/types/design-contract.d.ts +68 -0
  182. package/dist/interface/types/design-contract.d.ts.map +1 -0
  183. package/dist/interface/types/design-contract.js +7 -0
  184. package/dist/interface/types/design-contract.js.map +1 -0
  185. package/dist/interface/types/design-handoff.d.ts +68 -0
  186. package/dist/interface/types/design-handoff.d.ts.map +1 -0
  187. package/dist/interface/types/design-handoff.js +4 -0
  188. package/dist/interface/types/design-handoff.js.map +1 -0
  189. package/dist/interface/types/design-mapping.d.ts +51 -0
  190. package/dist/interface/types/design-mapping.d.ts.map +1 -0
  191. package/dist/interface/types/design-mapping.js +4 -0
  192. package/dist/interface/types/design-mapping.js.map +1 -0
  193. package/dist/interface/types/design-verification.d.ts +49 -0
  194. package/dist/interface/types/design-verification.d.ts.map +1 -0
  195. package/dist/interface/types/design-verification.js +4 -0
  196. package/dist/interface/types/design-verification.js.map +1 -0
  197. package/dist/interface/types/index.d.ts +17 -0
  198. package/dist/interface/types/index.d.ts.map +1 -1
  199. package/dist/interface/types/storage.d.ts +1 -4
  200. package/dist/interface/types/storage.d.ts.map +1 -1
  201. package/dist/orchestrator/ai-feed-generator.d.ts +210 -0
  202. package/dist/orchestrator/ai-feed-generator.d.ts.map +1 -0
  203. package/dist/orchestrator/ai-feed-generator.js +377 -0
  204. package/dist/orchestrator/ai-feed-generator.js.map +1 -0
  205. package/dist/orchestrator/confidence.d.ts +9 -9
  206. package/dist/orchestrator/confidence.d.ts.map +1 -1
  207. package/dist/orchestrator/confidence.js +44 -67
  208. package/dist/orchestrator/confidence.js.map +1 -1
  209. package/dist/orchestrator/file-header-scanner.d.ts.map +1 -1
  210. package/dist/orchestrator/file-header-scanner.js +22 -31
  211. package/dist/orchestrator/file-header-scanner.js.map +1 -1
  212. package/dist/orchestrator/intent-router.d.ts +2 -11
  213. package/dist/orchestrator/intent-router.d.ts.map +1 -1
  214. package/dist/orchestrator/intent-router.js +58 -49
  215. package/dist/orchestrator/intent-router.js.map +1 -1
  216. package/dist/orchestrator/tool-orchestrator.d.ts.map +1 -1
  217. package/dist/orchestrator/tool-orchestrator.js +6 -4
  218. package/dist/orchestrator/tool-orchestrator.js.map +1 -1
  219. package/dist/orchestrator/types.d.ts +113 -2
  220. package/dist/orchestrator/types.d.ts.map +1 -1
  221. package/dist/orchestrator/types.js +29 -0
  222. package/dist/orchestrator/types.js.map +1 -1
  223. package/dist/orchestrator/workflow/config.d.ts +4 -12
  224. package/dist/orchestrator/workflow/config.d.ts.map +1 -1
  225. package/dist/orchestrator/workflow/config.js +4 -6
  226. package/dist/orchestrator/workflow/config.js.map +1 -1
  227. package/dist/orchestrator/workflow/git-analyzer.d.ts.map +1 -1
  228. package/dist/orchestrator/workflow/git-analyzer.js +9 -19
  229. package/dist/orchestrator/workflow/git-analyzer.js.map +1 -1
  230. package/dist/orchestrator/workflow/phase-inheritance.d.ts.map +1 -1
  231. package/dist/orchestrator/workflow/phase-inheritance.js +14 -23
  232. package/dist/orchestrator/workflow/phase-inheritance.js.map +1 -1
  233. package/dist/orchestrator/workflow/result-fusion.d.ts.map +1 -1
  234. package/dist/orchestrator/workflow/result-fusion.js +9 -11
  235. package/dist/orchestrator/workflow/result-fusion.js.map +1 -1
  236. package/dist/orchestrator/workflow/templates.d.ts +4 -1
  237. package/dist/orchestrator/workflow/templates.d.ts.map +1 -1
  238. package/dist/orchestrator/workflow/templates.js +49 -207
  239. package/dist/orchestrator/workflow/templates.js.map +1 -1
  240. package/dist/orchestrator/workflow/test-linker.d.ts.map +1 -1
  241. package/dist/orchestrator/workflow/test-linker.js +12 -24
  242. package/dist/orchestrator/workflow/test-linker.js.map +1 -1
  243. package/dist/orchestrator/workflow/types.d.ts +11 -8
  244. package/dist/orchestrator/workflow/types.d.ts.map +1 -1
  245. package/dist/orchestrator/workflow/types.js +8 -1
  246. package/dist/orchestrator/workflow/types.js.map +1 -1
  247. package/dist/orchestrator/workflow/visualizer.d.ts.map +1 -1
  248. package/dist/orchestrator/workflow/visualizer.js +7 -9
  249. package/dist/orchestrator/workflow/visualizer.js.map +1 -1
  250. package/dist/orchestrator/workflow/workflow-context.d.ts.map +1 -1
  251. package/dist/orchestrator/workflow/workflow-context.js +3 -5
  252. package/dist/orchestrator/workflow/workflow-context.js.map +1 -1
  253. package/dist/orchestrator/workflow/workflow-orchestrator.d.ts +0 -4
  254. package/dist/orchestrator/workflow/workflow-orchestrator.d.ts.map +1 -1
  255. package/dist/orchestrator/workflow/workflow-orchestrator.js +7 -99
  256. package/dist/orchestrator/workflow/workflow-orchestrator.js.map +1 -1
  257. package/dist/parser/index.d.ts.map +1 -1
  258. package/dist/parser/index.js +2 -2
  259. package/dist/parser/index.js.map +1 -1
  260. package/dist/plugins/index.d.ts +5 -3
  261. package/dist/plugins/index.d.ts.map +1 -1
  262. package/dist/plugins/index.js +19 -8
  263. package/dist/plugins/index.js.map +1 -1
  264. package/dist/plugins/plugin-loader.d.ts +21 -6
  265. package/dist/plugins/plugin-loader.d.ts.map +1 -1
  266. package/dist/plugins/plugin-loader.js +170 -54
  267. package/dist/plugins/plugin-loader.js.map +1 -1
  268. package/dist/plugins/plugin-registry.d.ts +7 -4
  269. package/dist/plugins/plugin-registry.d.ts.map +1 -1
  270. package/dist/plugins/plugin-registry.js +62 -14
  271. package/dist/plugins/plugin-registry.js.map +1 -1
  272. package/dist/plugins/types.d.ts +16 -6
  273. package/dist/plugins/types.d.ts.map +1 -1
  274. package/dist/plugins/types.js +2 -0
  275. package/dist/plugins/types.js.map +1 -1
  276. package/dist/server/handlers/AnalysisHandler.d.ts +16 -2
  277. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
  278. package/dist/server/handlers/AnalysisHandler.js +31 -47
  279. package/dist/server/handlers/AnalysisHandler.js.map +1 -1
  280. package/dist/server/routes/api.d.ts.map +1 -1
  281. package/dist/server/routes/api.js +31 -12
  282. package/dist/server/routes/api.js.map +1 -1
  283. package/docs/AI_ASSISTANT_SETUP.md +3 -1
  284. package/docs/SETUP_GUIDE.md +41 -17
  285. package/docs/ai-guide/COMMANDS.md +179 -102
  286. package/docs/ai-guide/INTEGRATION.md +23 -21
  287. package/docs/ai-guide/OUTPUT.md +621 -10
  288. package/docs/ai-guide/PATTERNS.md +77 -18
  289. package/docs/ai-guide/PROMPTS.md +24 -18
  290. package/docs/ai-guide/QUICKSTART.md +35 -19
  291. package/docs/ai-guide/README.md +22 -4
  292. package/docs/archive/test-report-symbol-search.md +384 -0
  293. package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
  294. package/docs/archive/test_report_scenario5.md +615 -0
  295. package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
  296. package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +79 -0
  297. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +159 -434
  298. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +169 -261
  299. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +201 -1259
  300. package/docs/product-specs/README.md +9 -1
  301. package/docs/rules/architecture-guardrails.md +1 -2
  302. package/docs/rules/engineering-with-codex-openai.md +20 -10
  303. package/docs/rules/validation.md +29 -4
  304. package/mycodemap.config.schema.json +76 -5
  305. package/package.json +1 -1
  306. package/scripts/experiments/arcadedb-http-smoke.mjs +90 -0
  307. package/scripts/sync-analyze-docs.js +500 -0
  308. package/scripts/validate-ai-docs.js +54 -1
  309. package/scripts/validate-docs.js +992 -25
package/README.md CHANGED
@@ -1,26 +1,31 @@
1
1
  # CodeMap
2
2
 
3
- > TypeScript 代码地图工具 - 为 AI 辅助开发提供结构化上下文
3
+ > AI-first 代码地图工具 - 为 AI/Agent 提供结构化、可预测的代码上下文
4
4
 
5
- CodeMap 是一个专为 TypeScript/JavaScript/Go 项目设计的代码分析工具。它通过静态分析自动生成项目的结构化代码地图,帮助 AI 编程助手(如 Claude、Copilot)快速理解项目架构、模块关系和代码上下文。
5
+ CodeMap 是一个面向 TypeScript/JavaScript/Go 项目的 AI-first 代码地图工具。它通过静态分析生成稳定的项目地图、依赖关系和结构化结果,帮助 AI/Agent 更快理解代码结构、定位影响范围,并把分析结果交给人类开发者继续判断与维护。
6
6
 
7
7
  ## 特性
8
8
 
9
- - **分层架构 (MVP3)** - 清晰的分层设计:Interface Infrastructure Domain Server → CLI
10
- - **双层解析模式** - 提供 `fast`(快速正则)和 `smart`(TypeScript AST)两种解析模式,按需平衡速度与精度
9
+ - **AI-first 代码地图** - 生成 `AI_MAP.md`、`CONTEXT.md`、`codemap.json` AI/Agent 可直接消费的上下文
10
+ - **核心分析命令** - 提供 `generate`、`query`、`deps`、`impact`、`complexity`、`cycles`、`analyze`、`design`、`export`、`ci`
11
+ - **机器可读优先** - 结构化输出是产品基线;当前 CLI 过渡期仍主要通过 `--json` 暴露机器可读结果
12
+ - **分层架构 (MVP3)** - 保持 `Interface → Infrastructure → Domain → Server → CLI` 的明确边界
13
+ - **双层解析模式** - 提供 `fast`(快速正则)和 `smart`(TypeScript AST)两种解析模式
11
14
  - **多语言支持** - 支持 TypeScript/JavaScript、Go、Python(可扩展架构)
12
- - **HTTP API 服务器** - 内置 REST API 服务器,支持查询、分析、导出
13
- - **多格式输出** - 自动生成 `AI_MAP.md`(全局概览)、`CONTEXT.md` + `context/`(模块上下文)、`codemap.json`(结构化数据)
14
- - **依赖图可视化** - 生成 Mermaid 格式的模块依赖关系图
15
- - **增量缓存** - 基于文件哈希的 LRU 缓存机制,仅重新分析变更文件
16
- - **Watch 模式** - 监听文件变更并自动增量更新代码地图,支持后台守护进程
17
- - **交互式查询** - 支持按符号、模块、依赖进行精确或模糊查询
18
- - **复杂度分析** - 计算圈复杂度、认知复杂度和可维护性指数
19
- - **调用图分析** - 分析函数/方法间的调用关系
20
- - **工作流编排** - v2.5 新增:6 阶段智能工作流 (reference impact → risk → implementation → commit → ci)
21
- - **CI 门禁** - v2.5 新增:提交格式检查、风险评估、输出契约验证
22
- - **插件系统** - 可扩展的插件架构,支持自定义分析和输出
23
- - **存储抽象** - 支持文件系统、内存、KùzuDB、Neo4j 多种存储后端
15
+ - **依赖/影响/复杂度分析** - 适合变更影响评估、重构盘点和架构回溯
16
+ - **CI 门禁与文档护栏** - 提供提交格式、文件头、风险评估、文档/输出契约检查
17
+ - **多格式导出与存储抽象** - 支持导出图数据,并保留文件系统/内存/图数据库后端接口
18
+
19
+ ## 产品定位
20
+
21
+ | 维度 | 当前基线 |
22
+ |------|----------|
23
+ | 产品是谁 | `CodeMap` AI-first 代码地图工具,而不是泛化的实现/发布/HTTP 工具箱 |
24
+ | 主要消费者 | `AI/Agent 是主要消费者`;人类开发者负责配置、维护与按需阅读输出 |
25
+ | 输出契约 | 目标是机器可读优先;`当前 CLI 现实` 是多数命令通过 `--json` 提供结构化结果,`analyze` 额外支持 `--output-mode machine|human` |
26
+ | 架构边界 | `Server Layer` 是内部架构层,不等于公共 `mycodemap server` 命令 |
27
+
28
+ 当前公共 CLI 聚焦 `init`、`generate`、`query`、`deps`、`cycles`、`complexity`、`impact`、`analyze`、`design`、`ci`、`workflow`、`export`、`ship`;`server`、`watch`、`report`、`logs` 已从 public CLI 移除,并在调用时给出迁移提示。
24
29
 
25
30
  ## 安装
26
31
 
@@ -62,7 +67,22 @@ ls .mycodemap/
62
67
  # dependency-graph.md - Mermaid 依赖图
63
68
  ```
64
69
 
65
- 生成后,将 `.mycodemap/AI_MAP.md` 的内容提供给 AI 助手即可让其快速理解你的项目结构。
70
+ ```bash
71
+ # 4. 当前 CLI 过渡现实:给 AI/Agent 时优先请求机器可读结果
72
+ mycodemap impact -f src/cli/index.ts -j
73
+
74
+ # analyze 额外支持显式 machine/human 模式
75
+ mycodemap analyze -i read -t src/cli/index.ts --output-mode human
76
+
77
+ # 人类设计先落成 design contract,再交给 AI/Agent 消费
78
+ cp docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md mycodemap.design.md
79
+ mycodemap design validate mycodemap.design.md --json
80
+ mycodemap design map mycodemap.design.md --json
81
+ mycodemap design handoff mycodemap.design.md --json
82
+ mycodemap design verify mycodemap.design.md --json
83
+ ```
84
+
85
+ 生成后,将 `.mycodemap/AI_MAP.md` 的内容提供给 AI 助手即可让其快速理解你的项目结构;需要结构化结果继续处理时,优先使用 JSON / machine 模式。
66
86
 
67
87
  ## 文档导航
68
88
 
@@ -92,18 +112,20 @@ ls .mycodemap/
92
112
  | **[🛡️ AGENTS.md](AGENTS.md)** | 仓库级强约束、任务分级、代码红线 |
93
113
  | **[⚡ CLAUDE.md](CLAUDE.md)** | AI 执行手册、验收清单 |
94
114
  | **[🤖 docs/AI_ASSISTANT_SETUP.md](docs/AI_ASSISTANT_SETUP.md)** | AI 助手配置指引 |
95
- | **[🛠️ docs/rules/engineering-with-codex-openai.md](docs/rules/engineering-with-codex-openai.md) | 面向 agent 的工程约束 |
115
+ | **[🛠️ docs/rules/engineering-with-codex-openai.md](docs/rules/engineering-with-codex-openai.md)** | 面向 agent 的工程约束 |
96
116
 
97
117
  **AI 快速入口**: `.cursorrules` | `.github/copilot-instructions.md`
98
118
 
99
119
  ## CLI 命令
100
120
 
121
+ > 说明:以下章节记录当前公开的公共命令面。`workflow` 是公开的 analysis-only 工作流能力,`ship` 仍是过渡能力;`server`、`watch`、`report`、`logs` 已从 public CLI 移除,并在调用时输出迁移提示。
122
+
101
123
  ### `mycodemap init`
102
124
 
103
125
  初始化项目的 CodeMap 配置文件。
104
126
 
105
127
  ```bash
106
- mycodemap init # 交互式创建配置
128
+ mycodemap init # 创建默认配置文件
107
129
  mycodemap init -y # 使用默认配置直接创建
108
130
 
109
131
  # 别名:codemap init 也可以使用
@@ -111,9 +133,9 @@ mycodemap init -y # 使用默认配置直接创建
111
133
 
112
134
  | 选项 | 说明 |
113
135
  |------|------|
114
- | `-y, --yes` | 跳过交互,使用默认配置 |
136
+ | `-y, --yes` | 使用默认配置 |
115
137
 
116
- 执行后会在项目根目录生成 `codemap.config.json` 配置文件。
138
+ 执行后会在项目根目录生成 `mycodemap.config.json` 配置文件。
117
139
 
118
140
  ### `mycodemap generate`
119
141
 
@@ -141,26 +163,6 @@ mycodemap generate -o ./docs/codemap # 指定输出目录
141
163
  | `smart` | 较慢 | 完整语义 | 深度分析、复杂度评估、类型推导 |
142
164
  | `hybrid` | 自动 | 自适应 | **推荐** - 文件数<50用fast,≥50用smart |
143
165
 
144
- ### `mycodemap watch`
145
-
146
- 监听文件变更并自动增量更新代码地图。
147
-
148
- ```bash
149
- mycodemap watch # 前台运行
150
- mycodemap watch -d # 以后台守护进程运行
151
- mycodemap watch -s # 停止后台守护进程
152
- mycodemap watch -t # 查看守护进程状态
153
- mycodemap watch -m smart # 使用 smart 模式监听
154
- ```
155
-
156
- | 选项 | 说明 | 默认值 |
157
- |------|------|--------|
158
- | `-m, --mode <mode>` | 分析模式 (fast/smart/hybrid) | `hybrid` |
159
- | `-o, --output <dir>` | 输出目录 | `.mycodemap` |
160
- | `-d, --detach` | 以后台守护进程方式运行 | - |
161
- | `-s, --stop` | 停止后台守护进程 | - |
162
- | `-t, --status` | 查看后台守护进程状态 | - |
163
-
164
166
  ### `mycodemap query`
165
167
 
166
168
  查询代码地图中的符号、模块和依赖信息。
@@ -239,80 +241,16 @@ mycodemap impact -f src/cli/index.ts -j # JSON 格式输出
239
241
  | `-t, --transitive` | 包含传递依赖(间接影响) | - |
240
242
  | `-j, --json` | 以 JSON 格式输出 | - |
241
243
 
242
- ### `mycodemap report`
243
-
244
- 生成代码地图分析报告,汇总分析结果和运行日志。
245
-
246
- ```bash
247
- mycodemap report # 生成最近 7 天的报告
248
- mycodemap report -d 14 # 生成最近 14 天的报告
249
- mycodemap report -o ./reports # 指定输出目录
250
- mycodemap report -v # 显示详细信息
251
- ```
252
-
253
- | 选项 | 说明 | 默认值 |
254
- |------|------|------|
255
- | `-o, --output <dir>` | 输出目录 | `.mycodemap` |
256
- | `-d, --days <number>` | 报告覆盖的天数 | `7` |
257
- | `-j, --json` | JSON 格式输出 | - |
258
- | `-v, --verbose` | 显示详细信息 | - |
259
-
260
- ### `mycodemap logs`
261
-
262
- 管理代码地图运行时日志(列出、导出、清理)。
244
+ ### 已移除的公共 CLI 命令
263
245
 
264
- ```bash
265
- # 列出日志
266
- mycodemap logs list # 列出最近 10 条日志
267
- mycodemap logs list -l 20 # 列出最近 20 条
268
- mycodemap logs list --level ERROR # 仅列出错误日志
269
- mycodemap logs list -j # JSON 格式输出
246
+ 以下命令已从 public CLI 移除;直接调用时,CLI 会显式失败并给出迁移提示,而不是继续执行旧功能。
270
247
 
271
- # 导出日志
272
- mycodemap logs export # 导出最近 7 天的日志
273
- mycodemap logs export -d 30 # 导出最近 30 天的日志
274
- mycodemap logs export -o ./logs.zip # 指定导出文件
275
- mycodemap logs export --format txt # 导出为文本格式
276
-
277
- # 清理日志
278
- mycodemap logs clear -d 30 --confirm # 清理 30 天前的日志
279
- ```
280
-
281
- | 选项 | 说明 | 默认值 |
282
- |------|------|------|
283
- | `-l, --limit <number>` | 限制显示数量 | `10` |
284
- | `--level <level>` | 按级别过滤 (`INFO`/`WARN`/`ERROR`/`DEBUG`) | - |
285
- | `-j, --json` | JSON 格式输出 | - |
286
- | `-o, --output <file>` | 导出文件路径 | - |
287
- | `-d, --days <number>` | 天数 | 视子命令而定 |
288
- | `--format <format>` | 导出格式 (`json`/`txt`) | `json` |
289
- | `-c, --confirm` | 确认清理操作 | - |
290
-
291
- ### `mycodemap server` (MVP3)
292
-
293
- 启动 CodeMap HTTP API 服务器。
294
-
295
- ```bash
296
- mycodemap server # 启动服务器 (默认端口 3000)
297
- mycodemap server -p 8080 # 指定端口
298
- mycodemap server -p 3000 --open # 自动打开浏览器
299
- mycodemap server --cors # 启用 CORS
300
- ```
301
-
302
- | 选项 | 说明 | 默认值 |
303
- |------|------|--------|
304
- | `-p, --port <number>` | 服务器端口 | `3000` |
305
- | `-h, --host <string>` | 服务器主机 | `0.0.0.0` |
306
- | `--cors` | 启用 CORS | `false` |
307
- | `--open` | 自动打开浏览器 | `false` |
308
-
309
- **API 端点:**
310
- - `GET /api/v1/health` - 健康检查
311
- - `GET /api/v1/stats` - 项目统计
312
- - `GET /api/v1/search/symbols?q=` - 符号搜索
313
- - `GET /api/v1/modules/:id` - 模块详情
314
- - `POST /api/v1/analysis/impact` - 影响分析
315
- - `GET /api/v1/export/:format` - 导出数据
248
+ | 已移除命令 | 当前迁移方式 |
249
+ |------------|--------------|
250
+ | `watch` | 改用一次性的 `mycodemap generate` 刷新代码地图 |
251
+ | `report` | 直接读取 `.mycodemap/AI_MAP.md`,或使用 `mycodemap export <format>` 导出结果 |
252
+ | `logs` | 直接读取 `.mycodemap/logs/` 下的日志文件 |
253
+ | `server` | 公共 CLI 已移除;`Server Layer` 仍是内部架构层,不等于公开 `mycodemap server` 命令 |
316
254
 
317
255
  ### `mycodemap export` (MVP3)
318
256
 
@@ -330,39 +268,68 @@ mycodemap export json -o ./out # 指定输出路径
330
268
  |------|------|--------|
331
269
  | `-o, --output <path>` | 输出文件路径 | 自动根据格式生成 |
332
270
 
333
- ## 工作流编排 (v2.5)
271
+ ## 工作流编排(分析型 workflow)
334
272
 
335
- CodeMap v2.5 引入智能工作流编排系统,将复杂任务分解为 6 个有序阶段,每个阶段自动分析并传递上下文。
273
+ `workflow` 是公开的 analysis-only 工作流能力,只编排分析阶段:`find → read → link → show`。
274
+ 代码实现、commit 检查和 CI 运行不再属于 workflow phase;这些职责分别回到常规开发流程、`mycodemap ci` 与 `mycodemap ship`。
336
275
 
337
276
  ### 工作流阶段
338
277
 
339
278
  ```
340
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
341
- reference │ → │ impact │ → │ risk
342
- 参考搜索 │ │ 影响分析 │ │ 风险评估
343
- └─────────────┘ └─────────────┘ └─────────────┘
344
-
345
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
346
- │ ci │ ← │ commit │ ← │implementation│
347
- │ CI验证 │ │ 提交验证 │ │ 代码实现 │
348
- └─────────────┘ └─────────────┘ └─────────────┘
279
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
280
+ find │ → │ read │ → │ link → │ show │
281
+ 查找代码线索 │ │ 阅读影响范围 │ │ 关联依赖引用 │ 展示概览结果 │
282
+ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
349
283
  ```
350
284
 
351
- | 阶段 | 说明 | 自动分析 | 交付物 |
352
- |------|------|----------|--------|
353
- | **reference** | 参考搜索:查找相关代码和文档 | 符号搜索、依赖分析 | 相关文件列表 |
354
- | **impact** | 影响分析:评估变更影响范围 | 依赖图分析、传递依赖 | 影响文件清单 |
355
- | **risk** | 风险评估:基于 Git 历史评估风险 | 文件热度、修改频率、风险评分 | 风险报告 |
356
- | **implementation** | 代码实现:执行具体修改 | - | 代码变更 |
357
- | **commit** | 提交验证:验证提交格式 | Commit 格式检查 | 验证报告 |
358
- | **ci** | CI验证:运行测试和检查 | 单元测试、类型检查、契约验证 | CI 报告 |
285
+ | 阶段 | 对应意图 | 说明 | 典型产物 |
286
+ |------|----------|------|----------|
287
+ | **find** | `analyze --intent find` | 查找符号、关键词与候选文件 | 相关文件 / 符号列表 |
288
+ | **read** | `analyze --intent read` | 阅读影响范围、复杂度与上下文 | 影响与复杂度摘要 |
289
+ | **link** | `analyze --intent link` | 汇总依赖、引用与关联关系 | 依赖 / 引用结果 |
290
+ | **show** | `analyze --intent show` | 生成模块概览与展示型摘要 | overview / summary 输出 |
291
+
292
+ > 内置模板(`refactoring` / `bugfix` / `feature` / `hotfix`)共享同一 4 阶段顺序,只通过不同的阶段阈值和适用场景调整体验。
293
+
294
+ ## 设计契约输入面
295
+
296
+ `design` 是给“人类负责设计、AI 负责执行”协作链路准备的正式输入面。
297
+ 先把设计写成 `mycodemap.design.md`,再用 CLI 校验必填 sections、空段、重复 heading 和未知 heading。
298
+
299
+ ```bash
300
+ # 从 canonical template 起步
301
+ cp docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md mycodemap.design.md
302
+
303
+ # 使用默认文件名校验
304
+ mycodemap design validate mycodemap.design.md --json
305
+
306
+ # 校验通过后生成 candidate scope
307
+ mycodemap design map mycodemap.design.md --json
308
+
309
+ # 把 scope 打包成 handoff artifact,供 reviewer / AI agent 消费
310
+ mycodemap design handoff mycodemap.design.md --json
311
+
312
+ # 基于 reviewed handoff truth 做 verification / drift 检查
313
+ mycodemap design verify mycodemap.design.md --json
314
+
315
+ # 也可以显式传入其他路径
316
+ mycodemap design validate docs/designs/login.design.md
317
+ ```
318
+
319
+ 必填 sections:
320
+ - `## Goal`
321
+ - `## Constraints`
322
+ - `## Acceptance Criteria`
323
+ - `## Non-Goals`
324
+
325
+ > 建议最小工作流:`design validate → design map → design handoff → design verify`。`design map --json` 会返回 `summary`、`candidates`、`diagnostics` 与 `unknowns`;`design handoff --json` 会继续返回 `readyForExecution`、`approvals`、`assumptions` 与 `openQuestions`,默认 artifact 路径为 `.mycodemap/handoffs/{stem}.handoff.md|json`;`design verify --json` 会返回 `checklist`、`drift`、`diagnostics` 与 `readyForExecution`,其中 review-needed 不会直接变成非零退出,只有 blocker diagnostics 才会阻断。
359
326
 
360
327
  ### 工作流 CLI 命令
361
328
 
362
329
  ```bash
363
330
  # 启动工作流
364
331
  mycodemap workflow start "实现用户认证模块"
365
- # 启动工作流并指定模板(会直接影响阶段推进顺序)
332
+ # 启动工作流并指定模板(会保留 4 阶段顺序)
366
333
  mycodemap workflow start "修复登录接口 500" --template bugfix
367
334
 
368
335
  # 查看当前工作流状态
@@ -397,51 +364,35 @@ mycodemap workflow template recommend "紧急修复支付超时"
397
364
  ### 工作流使用示例
398
365
 
399
366
  ```bash
400
- # 示例:实现新功能
401
- $ mycodemap workflow start "添加缓存过期机制"
402
- 🚀 启动工作流: 添加缓存过期机制
403
- 📍 当前阶段: reference
404
-
405
- # 系统会自动分析相关代码,生成参考搜索结果
406
- # 确认后进入下一阶段
407
- $ mycodemap workflow proceed
408
- 📍 进入阶段: impact
409
- 📊 影响范围: 3 个文件
410
- - src/cache/lru-cache.ts
411
- - src/cache/index.ts
412
- - src/cli/commands/query.ts
413
-
414
- # 继续推进
367
+ # 示例:围绕一个模块逐步收敛上下文
368
+ $ mycodemap workflow start "梳理缓存模块上下文"
369
+ [WORKFLOW STARTED]
370
+ Task: 梳理缓存模块上下文
371
+ Phase: find
372
+
373
+ # 查看当前分析阶段与进度
374
+ $ mycodemap workflow status
375
+ Phase: find
376
+
377
+ # 可视化 4 阶段分析流水线
378
+ $ mycodemap workflow visualize
379
+ 🔍 【Find】
380
+
381
+ 📖 Read
382
+
383
+ ○ 🔗 Link
384
+
385
+ ○ 🧭 Show
386
+
387
+ # 当前阶段完成后推进到下一阶段
415
388
  $ mycodemap workflow proceed
416
- 📍 进入阶段: risk
417
- ⚠️ 风险等级: medium
418
- - src/cache/lru-cache.ts: 近期频繁修改 (5次/30天)
389
+ Next phase: read
419
390
 
420
- # 实现代码后
421
- $ mycodemap workflow proceed
422
- 📍 进入阶段: implementation
423
- ✅ 代码实现完成
424
-
425
- # 提交前验证
426
- $ mycodemap workflow proceed
427
- 📍 进入阶段: commit
428
- ✅ Commit 格式验证通过
429
-
430
- # CI 验证
431
- $ mycodemap workflow proceed
432
- 📍 进入阶段: ci
433
- ✅ 所有检查通过
434
- 🎉 工作流完成!
435
-
436
- # 示例:模板会改变阶段推进顺序
437
- $ mycodemap workflow start "修复线上缓存失效" --template bugfix
438
- $ mycodemap workflow proceed --force
439
- 📍 下一阶段: implementation # bugfix 模板: reference -> implementation
440
-
441
- # 示例:对当前活动工作流应用模板
391
+ # 示例:对当前活动工作流应用模板(阶段顺序不变)
442
392
  $ mycodemap workflow template apply bugfix
443
393
  Applied template: bugfix
444
- Current phase: reference
394
+ Phases: find → read → link → show
395
+ Current phase: find
445
396
  ```
446
397
 
447
398
  ## CI 门禁 (v2.5)
@@ -470,15 +421,15 @@ mycodemap ci check-output-contract
470
421
 
471
422
  ## 配置说明
472
423
 
473
- 通过 `codemap init` 生成的 `codemap.config.json` 配置文件支持以下选项:
424
+ 通过 `mycodemap init` 生成的 `mycodemap.config.json` 配置文件支持以下选项:
474
425
 
475
426
  ```jsonc
476
427
  {
477
428
  // JSON Schema(可选,提供编辑器智能提示)
478
- "$schema": "https://codemap.dev/schema.json",
429
+ "$schema": "https://mycodemap.dev/schema/config.json",
479
430
 
480
- // 分析模式:"fast" 或 "smart"
481
- "mode": "fast",
431
+ // 分析模式:"fast"、"smart" 或 "hybrid"
432
+ "mode": "hybrid",
482
433
 
483
434
  // 包含的文件 glob 模式
484
435
  "include": [
@@ -490,21 +441,84 @@ mycodemap ci check-output-contract
490
441
  "node_modules/**",
491
442
  "dist/**",
492
443
  "build/**",
493
- "*.test.ts",
494
- "*.spec.ts"
444
+ "coverage/**",
445
+ "**/*.test.ts",
446
+ "**/*.spec.ts",
447
+ "**/*.d.ts"
495
448
  ],
496
449
 
497
450
  // 输出目录
498
- "output": ".mycodemap"
451
+ "output": ".mycodemap",
452
+
453
+ // 监听模式预留配置
454
+ "watch": false,
455
+
456
+ // 图存储后端配置
457
+ "storage": {
458
+ "type": "filesystem",
459
+ "outputPath": ".codemap/storage"
460
+ },
461
+
462
+ // 插件加载配置
463
+ "plugins": {
464
+ "builtInPlugins": true,
465
+ "plugins": [],
466
+ "debug": false
467
+ }
499
468
  }
500
469
  ```
501
470
 
502
471
  | 配置项 | 类型 | 说明 | 默认值 |
503
472
  |--------|------|------|--------|
504
- | `mode` | `"fast" \| "smart"` | 分析模式 | `"fast"` |
473
+ | `mode` | `"fast" \| "smart" \| "hybrid"` | 分析模式 | `"hybrid"` |
505
474
  | `include` | `string[]` | 包含的文件 glob 模式 | `["src/**/*.ts"]` |
506
475
  | `exclude` | `string[]` | 排除的文件 glob 模式 | `["node_modules/**", "dist/**", ...]` |
507
476
  | `output` | `string` | 输出目录路径 | `".mycodemap"` |
477
+ | `watch` | `boolean` | 监听模式预留配置 | `false` |
478
+ | `storage.type` | `"filesystem" \| "kuzudb" \| "memory" \| "auto"` | 图存储后端类型 | `"filesystem"` |
479
+ | `storage.outputPath` | `string` | 文件系统存储目录 | `".codemap/storage"` |
480
+ | `storage.databasePath` | `string` | KùzuDB 数据目录(相对项目根目录) | - |
481
+ | `storage.autoThresholds` | `object` | `auto` 后端选择阈值 | - |
482
+ | `plugins.builtInPlugins` | `boolean` | 是否启用内置插件 | `true` |
483
+ | `plugins.pluginDir` | `string` | 额外插件目录 | - |
484
+ | `plugins.plugins` | `string[]` | 显式加载的插件名称列表 | `[]` |
485
+ | `plugins.debug` | `boolean` | 是否输出插件调试日志 | `false` |
486
+
487
+ ### 图存储后端说明
488
+
489
+ ```jsonc
490
+ {
491
+ "storage": {
492
+ "type": "kuzudb",
493
+ "databasePath": ".codemap/kuzu"
494
+ }
495
+ }
496
+ ```
497
+
498
+ - `generate` 会把 CodeGraph 写入配置的 `storage` 后端,`export` 与内部 `Server Layer` handler 会读取同一份后端数据。
499
+ - `neo4j` 已不再是正式支持的 backend;旧配置会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
500
+ - 选择 `kuzudb` 前先安装 `npm install kuzu`;缺少依赖时会返回显式错误。
501
+ - `storage.type = "auto"` 当前仍以 `filesystem` 为保守默认值;阈值字段先作为显式契约保留,不伪装成已完成的自动切换能力。
502
+ - 图存储后端生产化不等于重新开放公共 HTTP API 产品面;`Server Layer` 仍是内部架构层。
503
+
504
+ ### 插件运行时说明
505
+
506
+ ```jsonc
507
+ {
508
+ "plugins": {
509
+ "builtInPlugins": false,
510
+ "pluginDir": "./codemap-plugins",
511
+ "plugins": ["complexity-analyzer", "my-local-plugin"],
512
+ "debug": true
513
+ }
514
+ }
515
+ ```
516
+
517
+ - 只有**显式声明了** `plugins` 段时,`generate` 才会启用插件 runtime;没有该段的旧项目保持原有行为。
518
+ - 插件加载结果、诊断信息和插件生成文件会写入 `AI_MAP.md` 的 `Plugin Summary` 与 `codemap.json` 的 `pluginReport`。
519
+ - 非法插件配置、插件初始化失败、generate hook 失败都会被收口为结构化 diagnostics,而不是静默忽略。
520
+
521
+ > 文件发现契约:`generate`、`analyze` 与 `ci check-headers -d` 等扫描类命令共享同一套 `.gitignore` 感知排除规则;若仓库没有 `.gitignore`,则回退到默认 `exclude`(即 `node_modules/dist/build/coverage/**` 与 `**/*.test.ts` / `**/*.spec.ts` / `**/*.d.ts`),并在 Git worktree 场景下避免误扫描 `.git` 目录。
508
522
 
509
523
  ## 输出文件说明
510
524
 
@@ -514,6 +528,7 @@ mycodemap ci check-output-contract
514
528
 
515
529
  项目全局概览文件,专为 AI 助手设计,包含:
516
530
  - 项目基本信息(文件数、代码行数、模块数等)
531
+ - 已加载插件、插件生成文件数量与插件诊断摘要(仅当显式启用 plugins runtime)
517
532
  - 入口点列表
518
533
  - 模块组织表(导出数、依赖数、类型)
519
534
  - Mermaid 格式的依赖关系图
@@ -535,6 +550,7 @@ mycodemap ci check-output-contract
535
550
  - `summary` - 统计摘要
536
551
  - `modules` - 模块详情数组(符号、导入、导出、复杂度等)
537
552
  - `dependencies` - 依赖图(节点和边)
553
+ - `pluginReport` - 插件运行摘要(`loadedPlugins`、`generatedFiles`、`metrics`、`diagnostics`)
538
554
 
539
555
  ### `dependency-graph.md`
540
556
 
@@ -548,7 +564,7 @@ CodeMap 采用清晰的分层架构设计(MVP3),各层职责明确:
548
564
  ┌─────────────────────────────────────────────────────────────┐
549
565
  │ CLI Layer │
550
566
  │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
551
- │ │ server │ │ export │ │ 原有命令(generate..)│ │
567
+ │ │workflow/ship│ │ export │ │ 原有命令(generate..)│ │
552
568
  │ └─────────────┘ └─────────────┘ └─────────────────────┘ │
553
569
  ├─────────────────────────────────────────────────────────────┤
554
570
  │ Server Layer │
@@ -563,7 +579,7 @@ CodeMap 采用清晰的分层架构设计(MVP3),各层职责明确:
563
579
  │ │ - FileSystem │ │ - TypeScript │ │
564
580
  │ │ - Memory │ │ - Go │ │
565
581
  │ │ - KùzuDB │ │ - Python │ │
566
- │ │ - Neo4j │ │ - Registry │ │
582
+ │ │ - Auto Select │ │ - Registry │ │
567
583
  │ └──────────────────┘ └──────────────────┘ │
568
584
  │ ┌──────────────────┐ │
569
585
  │ │ Repository │ CodeGraphRepositoryImpl │
@@ -574,12 +590,14 @@ CodeMap 采用清晰的分层架构设计(MVP3),各层职责明确:
574
590
  └─────────────────────────────────────────────────────────────┘
575
591
  ```
576
592
 
593
+ > 命名边界:`Server Layer` 是内部架构层,不等于公共 `mycodemap server` 命令。
594
+
577
595
  ### 架构层说明
578
596
 
579
597
  | 层级 | 路径 | 职责 | 关键组件 |
580
598
  |------|------|------|----------|
581
- | **CLI** | `src/cli/` | 命令行接口 | `server`, `export`, `generate` 命令 |
582
- | **Server** | `src/server/` | HTTP API | `CodeMapServer`, `QueryHandler` |
599
+ | **CLI** | `src/cli/` | 命令行接口(核心分析命令 + `workflow` / `ship` 扩展 surface) | `generate`, `query`, `impact`, `export` |
600
+ | **Server** | `src/server/` | 内部 Server Layer / HTTP transport | `CodeMapServer`, `QueryHandler` |
583
601
  | **Domain** | `src/domain/` | 核心业务逻辑 | `Project`, `Module`, `CodeGraph` |
584
602
  | **Infrastructure** | `src/infrastructure/` | 技术实现 | `Storage`, `Parser`, `Repository` |
585
603
  | **Interface** | `src/interface/` | 类型契约 | `types/`, `config/` |
@@ -607,7 +625,7 @@ src/
607
625
  │ └── repositories/ # 仓库接口
608
626
  ├── infrastructure/ # MVP3: 基础设施层
609
627
  │ ├── storage/ # 存储适配器
610
- │ │ ├── adapters/ # FileSystem, Memory, KùzuDB, Neo4j
628
+ │ │ ├── adapters/ # FileSystem, Memory, KùzuDB
611
629
  │ │ └── StorageFactory.ts
612
630
  │ ├── parser/ # 解析器
613
631
  │ │ ├── interfaces/ # ParserBase
@@ -654,47 +672,74 @@ cp examples/codex/codemap-agent.md .agents/skills/codemap/SKILL.md
654
672
 
655
673
  ## 新增 CLI 命令
656
674
 
657
- ### `mycodemap analyze`
675
+ ### `mycodemap design`
658
676
 
659
- 统一分析入口,支持多意图路由和结构化输出:
677
+ 校验、映射并验证 human-authored design contract,默认读取仓库根目录的 `mycodemap.design.md`。
660
678
 
661
679
  ```bash
662
- # 影响分析(查看文件变更影响范围)
663
- mycodemap analyze -i impact -t src/cli/index.ts
664
- mycodemap analyze -i impact -t src/cli/index.ts --scope transitive
665
- mycodemap analyze -i impact -t src/cli/index.ts --include-tests
680
+ # validate: 使用默认路径校验
681
+ mycodemap design validate mycodemap.design.md --json
682
+
683
+ # validate: 显式指定文件
684
+ mycodemap design validate docs/designs/login.design.md
666
685
 
667
- # 依赖分析
668
- mycodemap analyze -i dependency -t src/cli/index.ts
686
+ # map: 生成 candidate code scope
687
+ mycodemap design map mycodemap.design.md --json
669
688
 
670
- # 项目概览
671
- mycodemap analyze -i overview -t src/orchestrator
689
+ # handoff: 生成 reviewer + agent 共用的 handoff package
690
+ mycodemap design handoff mycodemap.design.md --json
672
691
 
673
- # 复杂度分析
674
- mycodemap analyze -i complexity -t src/domain
692
+ # verify: 基于 reviewed handoff truth 做 checklist / drift 校验
693
+ mycodemap design verify mycodemap.design.md --json
694
+ ```
675
695
 
676
- # 搜索分析
677
- mycodemap analyze -i search -k UnifiedResult
696
+ | 选项 | 说明 |
697
+ |------|------|
698
+ | `-j, --json` | 输出纯 JSON diagnostics,适合 AI/CI 消费 |
678
699
 
679
- # 重构建议
680
- mycodemap analyze -i refactor -t src/cache
700
+ > canonical 模板位于 `docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md`。
701
+ > 缺失必填 section、重复 section、空 section 或未知 heading 时,CLI 会返回结构化 diagnostics,而不是继续猜测设计意图。
702
+ > `design map` 会基于 design contract 返回 `candidates`、`diagnostics` 与 `unknowns`;若命中 `no-candidates`、`over-broad-scope` 或 `high-risk-scope`,命令会直接阻断。
703
+ > `design handoff` 会基于 validated design contract + mapping truth 返回 `readyForExecution`、`approvals`、`assumptions`、`openQuestions`;human mode 默认写出 `.mycodemap/handoffs/{stem}.handoff.md|json`。
704
+ > `design verify` 会把 `Acceptance Criteria` 固定映射为 `checklist`,并输出 `drift` / `diagnostics`;当结果只是 `needs-review` 时保持零退出码,只有 `ok=false` 或 blocker diagnostics 才返回非零 exit code。
705
+
706
+ ### `mycodemap analyze`
681
707
 
682
- # 引用查找
683
- mycodemap analyze -i reference -t src/interface/types
708
+ 统一分析入口,当前公共契约只暴露四个 intent,并统一返回结构化输出:
684
709
 
685
- # 文档生成
686
- mycodemap analyze -i documentation -t src/domain/services
710
+ > 当前 public analyze contract 为 `find` / `read` / `link` / `show`;兼容期内 legacy intent 会在输出中通过 `warnings[]` 提示迁移,其中 `refactor` 已不再接受。
687
711
 
688
- # 机器可读输出(JSON)
689
- mycodemap analyze -i impact -t src/index.ts --json
690
- mycodemap analyze -i impact -t src/index.ts --structured --json
712
+ <!-- BEGIN GENERATED: analyze-readme-examples -->
713
+ ```bash
714
+ # 查找符号 / 文本
715
+ mycodemap analyze -i find -k SourceLocation
716
+ mycodemap analyze -i find -t src/orchestrator -k IntentRouter --json
717
+
718
+ # 阅读文件(影响 + 复杂度聚合)
719
+ mycodemap analyze -i read -t src/cli/index.ts
720
+ mycodemap analyze -i read -t src/cli/index.ts --scope transitive
721
+ mycodemap analyze -i read -t src/cli/index.ts --include-tests --json
722
+
723
+ # 关联关系(依赖 + 引用聚合)
724
+ mycodemap analyze -i link -t src/cli/index.ts
725
+ mycodemap analyze -i link -t src/interface/types.ts --json
726
+
727
+ # 展示模块概览 / 文档
728
+ mycodemap analyze -i show -t src/orchestrator
729
+ mycodemap analyze -i show -t src/domain/services --output-mode human
730
+
731
+ # 机器可读输出(JSON / structured)
732
+ mycodemap analyze -i read -t src/index.ts --json
733
+ mycodemap analyze -i link -t src/index.ts --structured --json
691
734
  ```
735
+ <!-- END GENERATED: analyze-readme-examples -->
692
736
 
737
+ <!-- BEGIN GENERATED: analyze-readme-options -->
693
738
  | 选项 | 说明 | 默认值 |
694
739
  |------|------|--------|
695
- | `-i, --intent <type>` | 分析类型:`impact`/`dependency`/`search`/`documentation`/`complexity`/`overview`/`refactor`/`reference` | `impact` |
696
- | `-t, --targets <paths...>` | 目标文件/模块路径(必填) | - |
697
- | `-k, --keywords <words...>` | 搜索关键词(用于 search/documentation 意图) | - |
740
+ | `-i, --intent <type>` | 分析类型:`find`/`read`/`link`/`show`(必填) | - |
741
+ | `-t, --targets <paths...>` | 目标路径(`read`/`link`/`show` 必填,`find` 可选) | - |
742
+ | `-k, --keywords <words...>` | 搜索关键词(主要用于 `find`) | - |
698
743
  | `-s, --scope <scope>` | 范围:`direct`(直接)/`transitive`(传递) | `direct` |
699
744
  | `-n, --topK <number>` | 返回结果数量 | `8` |
700
745
  | `--include-tests` | 包含测试文件关联 | - |
@@ -702,38 +747,12 @@ mycodemap analyze -i impact -t src/index.ts --structured --json
702
747
  | `--json` | JSON 格式输出 | - |
703
748
  | `--structured` | 纯结构化输出(移除自然语言字段,配合 `--json` 使用) | - |
704
749
  | `--output-mode <mode>` | 输出模式:`machine`/`human` | `human` |
750
+ <!-- END GENERATED: analyze-readme-options -->
705
751
 
706
- ### `mycodemap ci`
707
-
708
- CI Gateway - 代码质量门禁工具:
709
-
710
- ```bash
711
- # 验证提交格式([TAG] scope: message)
712
- mycodemap ci check-commits
713
- mycodemap ci check-commits -c 5
714
- mycodemap ci check-commits -r origin/main..HEAD
715
-
716
- # 验证文件头注释([META], [WHY])
717
- mycodemap ci check-headers
718
- mycodemap ci check-headers -d src/domain
719
- mycodemap ci check-headers -f "src/index.ts,src/cli/index.ts"
720
-
721
- # 评估变更风险
722
- mycodemap ci assess-risk
723
- mycodemap ci assess-risk -t 0.5
724
-
725
- # 验证文档同步
726
- mycodemap ci check-docs-sync
727
-
728
- # 验证输出契约
729
- mycodemap ci check-output-contract
730
-
731
- # 检查提交文件数量(限制 10 个文件)
732
- mycodemap ci check-commit-size
733
- mycodemap ci check-commit-size -m 15
734
- ```
752
+ > 产品目标是机器可读优先;当前实现仍以显式 `--json` / `--output-mode` 作为主要入口。
753
+ >
754
+ > legacy 兼容映射:`search → find`、`impact/complexity → read`、`dependency/reference → link`、`overview/documentation → show`;`refactor` 会返回 `E0001_INVALID_INTENT`。
735
755
 
736
- 支持的提交 TAG 类型:`[REFACTOR]`, `[TEST]`, `[DOCS]`, `[FEAT]`, `[FIX]`, `[CHORE]`, `[PERF]`, `[SECURITY]`, `[BREAKING]`, `[HOTFIX]`, `[MIGRATION]`, `[WIP]`
737
756
 
738
757
  ## 贡献指南
739
758
 
@@ -762,6 +781,7 @@ npm run test:all # 功能 + 基准(串联执行)
762
781
 
763
782
  # 文档 / CLI 示例护栏
764
783
  npm run docs:check
784
+ # `ci check-docs-sync` 会额外校验 analyze generated block
765
785
  node dist/cli/index.js ci check-docs-sync
766
786
 
767
787
  # 类型检查
@@ -823,3 +843,47 @@ DELETE 删除代码/文件
823
843
  ## 许可证
824
844
 
825
845
  [MIT](LICENSE)
846
+ ### `mycodemap ci`
847
+
848
+ CI Gateway - 代码质量门禁工具:
849
+
850
+ ```bash
851
+ # 验证工作区是否干净(ship 的发布前检查也复用这条规则)
852
+ mycodemap ci check-working-tree
853
+
854
+ # 验证当前分支是否允许执行发布前检查
855
+ mycodemap ci check-branch
856
+ mycodemap ci check-branch --allow main,release/*
857
+
858
+ # 运行发布前脚本集合(docs/typecheck/lint/test/build/pack)
859
+ mycodemap ci check-scripts
860
+
861
+ # 验证提交格式([TAG] scope: message)
862
+ mycodemap ci check-commits
863
+ mycodemap ci check-commits -c 5
864
+ mycodemap ci check-commits -r origin/main..HEAD
865
+
866
+ # 验证文件头注释([META], [WHY])
867
+ mycodemap ci check-headers
868
+ mycodemap ci check-headers -d src/domain
869
+ mycodemap ci check-headers -f "src/index.ts,src/cli/index.ts"
870
+
871
+ # 评估变更风险
872
+ mycodemap ci assess-risk
873
+ mycodemap ci assess-risk -t 0.5
874
+
875
+ # 验证文档同步(含 analyze generated block 校验)
876
+ mycodemap ci check-docs-sync
877
+
878
+ # 验证输出契约
879
+ mycodemap ci check-output-contract
880
+
881
+ # 检查提交文件数量(限制 10 个文件)
882
+ mycodemap ci check-commit-size
883
+ mycodemap ci check-commit-size -m 15
884
+ ```
885
+
886
+ > `mycodemap ship` 的 CHECK 阶段现在复用 `ci check-working-tree`、`ci check-branch`、`ci check-scripts` 作为 must-pass 事实源,而不是重复实现这些检查。
887
+ > `mycodemap ci check-headers -d <dir>` 与 `generate` / `analyze` 共享同一套 `.gitignore` 感知排除模块;若仓库没有 `.gitignore`,则回退到默认 `exclude` 列表。
888
+
889
+ 支持的提交 TAG 类型:`[REFACTOR]`, `[TEST]`, `[DOCS]`, `[FEAT]`, `[FIX]`, `[CHORE]`, `[PERF]`, `[SECURITY]`, `[BREAKING]`, `[HOTFIX]`, `[MIGRATION]`, `[WIP]`