@mycodemap/mycodemap 0.4.2 → 0.5.1

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 (288) hide show
  1. package/CHANGELOG.md +105 -3
  2. package/README.md +192 -53
  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.d.ts +18 -0
  32. package/dist/cli/commands/analyze.d.ts.map +1 -1
  33. package/dist/cli/commands/analyze.js +239 -6
  34. package/dist/cli/commands/analyze.js.map +1 -1
  35. package/dist/cli/commands/check.d.ts +22 -0
  36. package/dist/cli/commands/check.d.ts.map +1 -0
  37. package/dist/cli/commands/check.js +168 -0
  38. package/dist/cli/commands/check.js.map +1 -0
  39. package/dist/cli/commands/ci.d.ts +25 -0
  40. package/dist/cli/commands/ci.d.ts.map +1 -1
  41. package/dist/cli/commands/ci.js +139 -36
  42. package/dist/cli/commands/ci.js.map +1 -1
  43. package/dist/cli/commands/complexity.d.ts.map +1 -1
  44. package/dist/cli/commands/complexity.js +6 -0
  45. package/dist/cli/commands/complexity.js.map +1 -1
  46. package/dist/cli/commands/design.d.ts +52 -0
  47. package/dist/cli/commands/design.d.ts.map +1 -0
  48. package/dist/cli/commands/design.js +274 -0
  49. package/dist/cli/commands/design.js.map +1 -0
  50. package/dist/cli/commands/generate.d.ts +1 -0
  51. package/dist/cli/commands/generate.d.ts.map +1 -1
  52. package/dist/cli/commands/generate.js +121 -8
  53. package/dist/cli/commands/generate.js.map +1 -1
  54. package/dist/cli/commands/history.d.ts +26 -0
  55. package/dist/cli/commands/history.d.ts.map +1 -0
  56. package/dist/cli/commands/history.js +92 -0
  57. package/dist/cli/commands/history.js.map +1 -0
  58. package/dist/cli/commands/mcp.d.ts +13 -0
  59. package/dist/cli/commands/mcp.d.ts.map +1 -0
  60. package/dist/cli/commands/mcp.js +108 -0
  61. package/dist/cli/commands/mcp.js.map +1 -0
  62. package/dist/cli/commands/server.d.ts +9 -0
  63. package/dist/cli/commands/server.d.ts.map +1 -0
  64. package/dist/cli/commands/server.js +65 -0
  65. package/dist/cli/commands/server.js.map +1 -0
  66. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
  67. package/dist/cli/commands/ship/pipeline.js +8 -1
  68. package/dist/cli/commands/ship/pipeline.js.map +1 -1
  69. package/dist/cli/commands/ship/publisher.d.ts +9 -1
  70. package/dist/cli/commands/ship/publisher.d.ts.map +1 -1
  71. package/dist/cli/commands/ship/publisher.js +149 -6
  72. package/dist/cli/commands/ship/publisher.js.map +1 -1
  73. package/dist/cli/commands/workflow.d.ts.map +1 -1
  74. package/dist/cli/commands/workflow.js +22 -2
  75. package/dist/cli/commands/workflow.js.map +1 -1
  76. package/dist/cli/config-loader.d.ts.map +1 -1
  77. package/dist/cli/config-loader.js +3 -2
  78. package/dist/cli/config-loader.js.map +1 -1
  79. package/dist/cli/contract-checker.d.ts +33 -0
  80. package/dist/cli/contract-checker.d.ts.map +1 -0
  81. package/dist/cli/contract-checker.js +719 -0
  82. package/dist/cli/contract-checker.js.map +1 -0
  83. package/dist/cli/contract-diff-scope.d.ts +14 -0
  84. package/dist/cli/contract-diff-scope.d.ts.map +1 -0
  85. package/dist/cli/contract-diff-scope.js +127 -0
  86. package/dist/cli/contract-diff-scope.js.map +1 -0
  87. package/dist/cli/contract-gate-thresholds.d.ts +14 -0
  88. package/dist/cli/contract-gate-thresholds.d.ts.map +1 -0
  89. package/dist/cli/contract-gate-thresholds.js +19 -0
  90. package/dist/cli/contract-gate-thresholds.js.map +1 -0
  91. package/dist/cli/design-contract-loader.d.ts +15 -0
  92. package/dist/cli/design-contract-loader.d.ts.map +1 -0
  93. package/dist/cli/design-contract-loader.js +527 -0
  94. package/dist/cli/design-contract-loader.js.map +1 -0
  95. package/dist/cli/design-contract-schema.d.ts +11 -0
  96. package/dist/cli/design-contract-schema.d.ts.map +1 -0
  97. package/dist/cli/design-contract-schema.js +75 -0
  98. package/dist/cli/design-contract-schema.js.map +1 -0
  99. package/dist/cli/design-handoff-builder.d.ts +15 -0
  100. package/dist/cli/design-handoff-builder.d.ts.map +1 -0
  101. package/dist/cli/design-handoff-builder.js +345 -0
  102. package/dist/cli/design-handoff-builder.js.map +1 -0
  103. package/dist/cli/design-scope-resolver.d.ts +8 -0
  104. package/dist/cli/design-scope-resolver.d.ts.map +1 -0
  105. package/dist/cli/design-scope-resolver.js +760 -0
  106. package/dist/cli/design-scope-resolver.js.map +1 -0
  107. package/dist/cli/design-verification-builder.d.ts +8 -0
  108. package/dist/cli/design-verification-builder.d.ts.map +1 -0
  109. package/dist/cli/design-verification-builder.js +369 -0
  110. package/dist/cli/design-verification-builder.js.map +1 -0
  111. package/dist/cli/index.js +20 -6
  112. package/dist/cli/index.js.map +1 -1
  113. package/dist/cli/paths.d.ts.map +1 -1
  114. package/dist/cli/paths.js +30 -7
  115. package/dist/cli/paths.js.map +1 -1
  116. package/dist/cli-new/commands/server.d.ts +13 -0
  117. package/dist/cli-new/commands/server.d.ts.map +1 -0
  118. package/dist/cli-new/commands/server.js +90 -0
  119. package/dist/cli-new/commands/server.js.map +1 -0
  120. package/dist/core/analyzer.d.ts.map +1 -1
  121. package/dist/core/analyzer.js +16 -0
  122. package/dist/core/analyzer.js.map +1 -1
  123. package/dist/domain/entities/CodeGraph.d.ts +5 -1
  124. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  125. package/dist/domain/entities/CodeGraph.js +29 -12
  126. package/dist/domain/entities/CodeGraph.js.map +1 -1
  127. package/dist/domain/entities/Dependency.d.ts +8 -1
  128. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  129. package/dist/domain/entities/Dependency.js +19 -4
  130. package/dist/domain/entities/Dependency.js.map +1 -1
  131. package/dist/domain/entities/Symbol.d.ts +2 -1
  132. package/dist/domain/entities/Symbol.d.ts.map +1 -1
  133. package/dist/domain/entities/Symbol.js +6 -3
  134. package/dist/domain/entities/Symbol.js.map +1 -1
  135. package/dist/generator/ai-overview.d.ts +51 -0
  136. package/dist/generator/ai-overview.d.ts.map +1 -0
  137. package/dist/generator/ai-overview.js +160 -0
  138. package/dist/generator/ai-overview.js.map +1 -0
  139. package/dist/infrastructure/storage/StorageFactory.d.ts +13 -5
  140. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  141. package/dist/infrastructure/storage/StorageFactory.js +62 -16
  142. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  143. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +3 -1
  144. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  145. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +10 -2
  146. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  147. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +3 -1
  148. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  149. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +9 -1
  150. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  151. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +3 -1
  152. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  153. package/dist/infrastructure/storage/adapters/MemoryStorage.js +9 -1
  154. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  155. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +41 -0
  156. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
  157. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +162 -0
  158. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
  159. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +53 -0
  160. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -0
  161. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +879 -0
  162. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -0
  163. package/dist/infrastructure/storage/graph-helpers.d.ts +3 -1
  164. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  165. package/dist/infrastructure/storage/graph-helpers.js +90 -0
  166. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  167. package/dist/infrastructure/storage/index.d.ts +1 -1
  168. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  169. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +3 -1
  170. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  171. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  172. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +27 -0
  173. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -0
  174. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +246 -0
  175. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -0
  176. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts +25 -0
  177. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts.map +1 -0
  178. package/dist/infrastructure/storage/sqlite/perf-thresholds.js +25 -0
  179. package/dist/infrastructure/storage/sqlite/perf-thresholds.js.map +1 -0
  180. package/dist/infrastructure/storage/sqlite/schema.d.ts +4 -0
  181. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
  182. package/dist/infrastructure/storage/sqlite/schema.js +111 -0
  183. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
  184. package/dist/interface/types/design-check.d.ts +73 -0
  185. package/dist/interface/types/design-check.d.ts.map +1 -0
  186. package/dist/interface/types/design-check.js +4 -0
  187. package/dist/interface/types/design-check.js.map +1 -0
  188. package/dist/interface/types/design-contract.d.ts +123 -0
  189. package/dist/interface/types/design-contract.d.ts.map +1 -0
  190. package/dist/interface/types/design-contract.js +7 -0
  191. package/dist/interface/types/design-contract.js.map +1 -0
  192. package/dist/interface/types/design-handoff.d.ts +68 -0
  193. package/dist/interface/types/design-handoff.d.ts.map +1 -0
  194. package/dist/interface/types/design-handoff.js +4 -0
  195. package/dist/interface/types/design-handoff.js.map +1 -0
  196. package/dist/interface/types/design-mapping.d.ts +51 -0
  197. package/dist/interface/types/design-mapping.d.ts.map +1 -0
  198. package/dist/interface/types/design-mapping.js +4 -0
  199. package/dist/interface/types/design-mapping.js.map +1 -0
  200. package/dist/interface/types/design-verification.d.ts +49 -0
  201. package/dist/interface/types/design-verification.d.ts.map +1 -0
  202. package/dist/interface/types/design-verification.js +4 -0
  203. package/dist/interface/types/design-verification.js.map +1 -0
  204. package/dist/interface/types/history-risk.d.ts +90 -0
  205. package/dist/interface/types/history-risk.d.ts.map +1 -0
  206. package/dist/interface/types/history-risk.js +4 -0
  207. package/dist/interface/types/history-risk.js.map +1 -0
  208. package/dist/interface/types/index.d.ts +20 -1
  209. package/dist/interface/types/index.d.ts.map +1 -1
  210. package/dist/interface/types/storage.d.ts +28 -1
  211. package/dist/interface/types/storage.d.ts.map +1 -1
  212. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +10 -0
  213. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -1
  214. package/dist/orchestrator/adapters/ast-grep-adapter.js +46 -17
  215. package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -1
  216. package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -1
  217. package/dist/orchestrator/adapters/codemap-adapter.js +2 -22
  218. package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -1
  219. package/dist/orchestrator/ai-feed-generator.d.ts +210 -0
  220. package/dist/orchestrator/ai-feed-generator.d.ts.map +1 -0
  221. package/dist/orchestrator/ai-feed-generator.js +377 -0
  222. package/dist/orchestrator/ai-feed-generator.js.map +1 -0
  223. package/dist/orchestrator/history-risk-service.d.ts +55 -0
  224. package/dist/orchestrator/history-risk-service.d.ts.map +1 -0
  225. package/dist/orchestrator/history-risk-service.js +680 -0
  226. package/dist/orchestrator/history-risk-service.js.map +1 -0
  227. package/dist/orchestrator/types.d.ts +19 -1
  228. package/dist/orchestrator/types.d.ts.map +1 -1
  229. package/dist/orchestrator/types.js +19 -0
  230. package/dist/orchestrator/types.js.map +1 -1
  231. package/dist/server/mcp/index.d.ts +4 -0
  232. package/dist/server/mcp/index.d.ts.map +1 -0
  233. package/dist/server/mcp/index.js +5 -0
  234. package/dist/server/mcp/index.js.map +1 -0
  235. package/dist/server/mcp/server.d.ts +17 -0
  236. package/dist/server/mcp/server.d.ts.map +1 -0
  237. package/dist/server/mcp/server.js +84 -0
  238. package/dist/server/mcp/server.js.map +1 -0
  239. package/dist/server/mcp/service.d.ts +22 -0
  240. package/dist/server/mcp/service.d.ts.map +1 -0
  241. package/dist/server/mcp/service.js +177 -0
  242. package/dist/server/mcp/service.js.map +1 -0
  243. package/dist/server/mcp/types.d.ts +56 -0
  244. package/dist/server/mcp/types.d.ts.map +1 -0
  245. package/dist/server/mcp/types.js +4 -0
  246. package/dist/server/mcp/types.js.map +1 -0
  247. package/docs/AI_ASSISTANT_SETUP.md +1 -1
  248. package/docs/SETUP_GUIDE.md +6 -6
  249. package/docs/ai-guide/COMMANDS.md +171 -4
  250. package/docs/ai-guide/INTEGRATION.md +137 -433
  251. package/docs/ai-guide/OUTPUT.md +890 -5
  252. package/docs/ai-guide/PATTERNS.md +54 -14
  253. package/docs/ai-guide/PROMPTS.md +17 -6
  254. package/docs/archive/test-report-symbol-search.md +384 -0
  255. package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
  256. package/docs/archive/test_report_scenario5.md +615 -0
  257. package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
  258. package/docs/backlog.md +177 -0
  259. package/docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md +231 -0
  260. package/docs/exec-plans/completed/2026-04-17-eatdogfood-codemap-cli.md +103 -0
  261. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +102 -0
  262. package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +126 -0
  263. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +11 -10
  264. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +10 -10
  265. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +17 -12
  266. package/docs/product-specs/README.md +2 -1
  267. package/docs/rules/README.md +16 -11
  268. package/docs/rules/architecture-guardrails.md +24 -336
  269. package/docs/rules/code-quality-redlines.md +25 -311
  270. package/docs/rules/engineering-with-codex-openai.md +20 -3
  271. package/docs/rules/validation.md +90 -37
  272. package/mycodemap.config.schema.json +3 -3
  273. package/package.json +7 -2
  274. package/scripts/benchmark-governance-graph.mjs +132 -0
  275. package/scripts/calibrate-contract-gate.mjs +221 -0
  276. package/scripts/capability-report.py +255 -0
  277. package/scripts/experiments/arcadedb-http-smoke.mjs +90 -0
  278. package/scripts/qa-rule-control.sh +254 -0
  279. package/scripts/report-high-risk-files.mjs +395 -0
  280. package/scripts/rule-context.mjs +155 -0
  281. package/scripts/smoke-sqlite-impact.mjs +85 -0
  282. package/scripts/sync-analyze-docs.js +1 -0
  283. package/scripts/tests/test_capability_report.py +89 -0
  284. package/scripts/tests/test_rule_control_workflow.py +51 -0
  285. package/scripts/tests/test_validate_rules.py +81 -0
  286. package/scripts/validate-ai-docs.js +283 -1
  287. package/scripts/validate-docs.js +479 -25
  288. package/scripts/validate-rules.py +254 -0
package/CHANGELOG.md CHANGED
@@ -2,16 +2,118 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.5.1] - 2026-04-19 - Rule Control Hardening & Release Sync
6
+
7
+ ### 🚀 New Features
8
+
9
+ - **rules**: 发布 repo-local rule control baseline,包括 capability report、validator exit-code contract、hooks/CI backstop、scoped subagent rule context 与 executable QA
10
+ - **workflow**: Claude / Codex 执行流现在会在常见执行路径中注入 scoped `<rule_context>`,减少规则遗漏与 prompt 串味
11
+
12
+ ### 📝 Documentation
13
+
14
+ - **release**: 同步 `llms.txt`、`AI_GUIDE.md`、`AI_DISCOVERY.md`、`ai-document-index.yaml` 到 `v0.5.1`
15
+ - **changelog**: 补齐本版本发布条目,确保 pre-release guardrail 与 GitHub Release notes 可用
16
+ - **claude**: 补齐 `CLAUDE.md` 对 `docs/ai-guide/` 的入口引用,消除发布前 AI 文档交叉引用 warning
17
+
18
+ ## [0.5.0] - 2026-04-15 - Design Contract Surface
19
+
20
+ ### 🏗️ v1.4 Milestone: Design-to-Code Mapping & Handoff Package
21
+
22
+ v1.4 milestone 完成,新增完整的 design contract 公共 CLI 表面,支持人类设计到 AI 执行的标准化 handoff。
23
+
24
+ #### Phase 17: Design Contract Validation
25
+ - **feature**: 发布 `design validate` 命令,校验 `mycodemap.design.md` 必填 sections
26
+ - **feature**: 返回结构化 diagnostics(missing-section、duplicate-section、empty-section 等)
27
+
28
+ #### Phase 18: Design-to-Code Mapping
29
+ - **feature**: 发布 `design map` 命令,将 design contract 解析为 candidate code scope
30
+ - **feature**: 支持 `no-candidates`、`over-broad-scope`、`high-risk-scope` 自动阻断
31
+
32
+ #### Phase 19: Handoff Package & Human Gates
33
+ - **feature**: 发布 `design handoff` 命令,生成 reviewer / AI agent 共用的 handoff artifact
34
+ - **feature**: 输出 `readyForExecution`、`approvals`、`assumptions`、`openQuestions`
35
+
36
+ #### Phase 20: Design Drift Verification
37
+ - **feature**: 发布 `design verify` 命令,基于 reviewed handoff truth 做 checklist / drift 检查
38
+ - **feature**: `needs-review` 保持零退出码,仅 blocker diagnostics 返回非零 exit code
39
+
40
+ ### 🚀 New Features
41
+
42
+ - **design**: 新增 design contract 四阶段 CLI 命令(validate / map / handoff / verify)
43
+ - **docs**: 同步 AI_GUIDE.md、README.md 和 docs/ai-guide 中的 design 类型定义与 workflow 命令
44
+ - **ci**: 更新文档一致性校验脚本,覆盖 design contract 测试与 fixture
45
+
46
+ ### 🐛 Bug Fixes
47
+
48
+ - **storage**: 修复 `kuzu` 可选依赖在 CI typecheck 中的模块缺失错误
49
+ - **publish**: 移除 GitHub Actions 中不稳定的 `npm install -g npm@latest` 步骤
50
+
5
51
  ## [0.4.2] - 2026-03-25 - Test Infrastructure Fix
6
52
 
53
+ ### 🏗️ v1.3 Milestone: Kùzu-only Convergence & High-Signal Debt Cleanup
54
+
55
+ v1.3 milestone 完成,核心产品面收敛为 Kùzu-only,清偿多项技术债务。
56
+
57
+ #### Phase 13: Storage Backend Convergence
58
+ - **refactor**: 移除 neo4j 运行时表面 (`8957fca`)
59
+ - **docs**: 同步 kuzu-only public contract (`d07524e`)
60
+
61
+ #### Phase 14: CLI Surface & Documentation Alignment
62
+ - **refactor**: 收口 analyze 和 server 过渡差距 (`4a756d7`)
63
+ - **docs**: 移除 workflow 过渡性 public 措辞 (`e5b9560`)
64
+
65
+ #### Phase 15: Analysis Intent & Workflow Runtime
66
+ - **feature**: 发布 public intent contract 和 outputs (`f4abfa6`)
67
+ - **refactor**: 对齐 workflow 运行时编排核心 (`ddd1c80`)
68
+ - **bugfix**: 扩展 quality 和回归测试覆盖 (`5eb38f7`)
69
+
70
+ #### Phase 16: Core Debt Cleanup & Final Guardrails
71
+ - **refactor**: 实现 plugin 真实 reload 生命周期 (`3a5fbc6`)
72
+ - **refactor**: 收口 parser index 和 resolution 债务 (`f64432a`)
73
+ - **refactor**: 使 analysis write paths 显式化 (`27458cd`)
74
+ - **docs**: 同步 kuzu-only 和 docs gate contract (`a4c8e12`)
75
+
76
+ #### Milestone Archive
77
+ - **docs**: 归档 v1.0 CI 和 docs phases (`7d474df`)
78
+ - **docs**: 归档 v1.0 analyze 和 workflow phases (`b3e43e4`)
79
+ - **docs**: 归档 v1.0 kickoff 和 cli cleanup (`bb80e4b`)
80
+ - **docs**: 归档 v1.1 plugin rollout phases (`35cfd60`)
81
+ - **docs**: 归档 v1.1 docs 和 v1.2 activation (`0aed09c`)
82
+ - **docs**: 归档 v1.2 backend validation (`a27bfb0`)
83
+ - **docs**: 完成 v1.3 milestone 关闭 (`ccb7d12`)
84
+
85
+ ### 🚀 New Features
86
+
87
+ - **storage**: 新增 adapter parity 和 validation (`b051dd8`)
88
+ - **storage**: 接入 generate export 和共享 helpers (`f625596`)
89
+ - **analyze**: 发布 public intent contract 和标准化输出 (`f4abfa6`)
90
+ - **plugins**: 新增 runtime config 和 diagnostics surface (`74d7905`)
91
+ - **workflow**: 扩展 quality 和回归测试覆盖 (`5eb38f7`)
92
+ - **claude**: 引入完整的 GSD (Get Shit Done) workflow agents 和命令 (`ef537e2`)
93
+ - **claude/gstack**: 新增 Docker 配置和 agent 定义 (`b83c000`)
94
+ - **claude/gstack**: 新增 GitHub Actions workflows (`7ef301b`)
95
+
7
96
  ### 🐛 Bug Fixes
8
97
 
9
- - **test**: 修复 validate-docs 测试缺少 product-specs 文件的问题
98
+ - **test**: 修复 validate-docs 测试缺少 product-specs 文件的问题 (`20d4293`)
99
+ - **hooks**: 解决 vitest 跨 node_modules 布局的查找问题 (`d53a5ac`)
100
+ - **hooks**: 添加本地 vitest entry 回退 (`d6542b5`)
101
+ - **adapter**: 增加 method signature 测试超时 (`4e97ca5`)
10
102
 
11
103
  ### 📚 Documentation
12
104
 
13
- - **docs**: 同步 MVP3 产品规格文档基线
14
- - **docs**: 完成 v1.3 milestone 归档
105
+ - **docs**: 同步 MVP3 产品规格文档基线 (`0c75108`)
106
+ - **docs**: 完成 v1.3 milestone 归档 (`ccb7d12`)
107
+ - **ai-guide**: 新增 ship troubleshooting section (`b7fe6d4`)
108
+ - **guardrails**: 同步 hooks 和 validation 文档 (`38b1964`)
109
+ - **planning**: 添加当前状态和 codebase map (`0bbd4ac`)
110
+
111
+ ### 🔧 Maintenance
112
+
113
+ - **config**: 同步所有 AI 文档到 v0.4.2 (`43c7b17`)
114
+ - **config**: 版本升级到 v0.4.2 (`d1f55c6`)
115
+ - **config**: vitest 添加 lcov coverage reporter (`a4da751`)
116
+ - **tooling**: checkpoint milestone metadata (`851ecf6`)
15
117
 
16
118
  ## [0.4.1] - 2026-03-23 - Ship Workflow Fixes
17
119
 
package/README.md CHANGED
@@ -7,7 +7,7 @@ CodeMap 是一个面向 TypeScript/JavaScript/Go 项目的 AI-first 代码地图
7
7
  ## 特性
8
8
 
9
9
  - **AI-first 代码地图** - 生成 `AI_MAP.md`、`CONTEXT.md`、`codemap.json` 等 AI/Agent 可直接消费的上下文
10
- - **核心分析命令** - 提供 `generate`、`query`、`deps`、`impact`、`complexity`、`cycles`、`analyze`、`export`、`ci`
10
+ - **核心分析命令** - 提供 `generate`、`query`、`deps`、`impact`、`complexity`、`cycles`、`analyze`、`design`、`export`、`ci`,并提供 experimental `mcp`
11
11
  - **机器可读优先** - 结构化输出是产品基线;当前 CLI 过渡期仍主要通过 `--json` 暴露机器可读结果
12
12
  - **分层架构 (MVP3)** - 保持 `Interface → Infrastructure → Domain → Server → CLI` 的明确边界
13
13
  - **双层解析模式** - 提供 `fast`(快速正则)和 `smart`(TypeScript AST)两种解析模式
@@ -25,7 +25,7 @@ CodeMap 是一个面向 TypeScript/JavaScript/Go 项目的 AI-first 代码地图
25
25
  | 输出契约 | 目标是机器可读优先;`当前 CLI 现实` 是多数命令通过 `--json` 提供结构化结果,`analyze` 额外支持 `--output-mode machine|human` |
26
26
  | 架构边界 | `Server Layer` 是内部架构层,不等于公共 `mycodemap server` 命令 |
27
27
 
28
- 当前公共 CLI 聚焦 `init`、`generate`、`query`、`deps`、`cycles`、`complexity`、`impact`、`analyze`、`ci`、`workflow`、`export`、`ship`;`server`、`watch`、`report`、`logs` 已从 public CLI 移除,并在调用时给出迁移提示。
28
+ 当前公共 CLI 聚焦 `init`、`generate`、`query`、`deps`、`cycles`、`complexity`、`impact`、`analyze`、`design`、`ci`、`workflow`、`export`、`ship`,以及 experimental 的 `mcp`;`server`、`watch`、`report`、`logs` 已从 public CLI 移除,并在调用时给出迁移提示。
29
29
 
30
30
  ## 安装
31
31
 
@@ -73,6 +73,13 @@ mycodemap impact -f src/cli/index.ts -j
73
73
 
74
74
  # analyze 额外支持显式 machine/human 模式
75
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
76
83
  ```
77
84
 
78
85
  生成后,将 `.mycodemap/AI_MAP.md` 的内容提供给 AI 助手即可让其快速理解你的项目结构;需要结构化结果继续处理时,优先使用 JSON / machine 模式。
@@ -138,6 +145,7 @@ mycodemap init -y # 使用默认配置直接创建
138
145
  mycodemap generate # 使用默认 hybrid 模式
139
146
  mycodemap generate -m smart # 使用 smart 模式(AST 深度分析)
140
147
  mycodemap generate -o ./docs/codemap # 指定输出目录
148
+ mycodemap generate --symbol-level # 额外 materialize symbol-level 调用依赖(实验性首期切片)
141
149
 
142
150
  # 别名:codemap generate 也可以使用
143
151
  ```
@@ -146,8 +154,12 @@ mycodemap generate -o ./docs/codemap # 指定输出目录
146
154
  |------|------|--------|
147
155
  | `-m, --mode <mode>` | 分析模式:`fast`(正则匹配)、`smart`(TypeScript AST)或 `hybrid`(自动选择) | `hybrid` |
148
156
  | `-o, --output <dir>` | 输出目录 | `.mycodemap` |
157
+ | `--symbol-level` | 额外把可解析的 symbol-level `call` 依赖写入图存储;默认 generate 行为不变 | `false` |
149
158
  | `--ai-context` | 为每个文件生成描述 | - |
150
159
 
160
+ - `codemap.json` 现在会显式写出 `graphStatus`、`failedFileCount` 与可选 `parseFailureFiles`。
161
+ - 当某些发现到的文件没有成功进入最终图时,`graphStatus` 会降级为 `partial`;不要把这种结果当成完整图继续做自动化决策。
162
+
151
163
  **模式说明:**
152
164
 
153
165
  | 模式 | 速度 | 精度 | 适用场景 |
@@ -234,6 +246,30 @@ mycodemap impact -f src/cli/index.ts -j # JSON 格式输出
234
246
  | `-t, --transitive` | 包含传递依赖(间接影响) | - |
235
247
  | `-j, --json` | 以 JSON 格式输出 | - |
236
248
 
249
+ ### `mycodemap mcp`(experimental)
250
+
251
+ 本地只读的 stdio MCP 薄切片。当前只提供两个工具:`codemap_query`、`codemap_impact`。
252
+
253
+ ```bash
254
+ # 先生成 symbol-level 图
255
+ mycodemap generate --symbol-level
256
+
257
+ # 把当前仓库写入本地 MCP host 配置
258
+ mycodemap mcp install
259
+
260
+ # 由 MCP host 启动 stdio server
261
+ mycodemap mcp start
262
+ ```
263
+
264
+ | 子命令 | 说明 |
265
+ |--------|------|
266
+ | `mcp install` | 把 experimental 本地 server 写入当前仓库 `.mcp.json` |
267
+ | `mcp start` | 启动本地 stdio MCP server;`stdout` 仅承载协议帧 |
268
+
269
+ - `mcp` 当前是 **experimental / local-only / read-only** surface,不是稳定长期 public API。
270
+ - 使用前必须先执行 `mycodemap generate --symbol-level`;否则工具会返回 `GRAPH_NOT_FOUND`。
271
+ - canonical 集成文档见 `docs/ai-guide/INTEGRATION.md`;若宿主暂时不支持真正 MCP,可先回退到传统 CLI wrapper 方式。
272
+
237
273
  ### 已移除的公共 CLI 命令
238
274
 
239
275
  以下命令已从 public CLI 移除;直接调用时,CLI 会显式失败并给出迁移提示,而不是继续执行旧功能。
@@ -284,6 +320,39 @@ mycodemap export json -o ./out # 指定输出路径
284
320
 
285
321
  > 内置模板(`refactoring` / `bugfix` / `feature` / `hotfix`)共享同一 4 阶段顺序,只通过不同的阶段阈值和适用场景调整体验。
286
322
 
323
+ ## 设计契约输入面
324
+
325
+ `design` 是给“人类负责设计、AI 负责执行”协作链路准备的正式输入面。
326
+ 先把设计写成 `mycodemap.design.md`,再用 CLI 校验必填 sections、空段、重复 heading 和未知 heading。
327
+
328
+ ```bash
329
+ # 从 canonical template 起步
330
+ cp docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md mycodemap.design.md
331
+
332
+ # 使用默认文件名校验
333
+ mycodemap design validate mycodemap.design.md --json
334
+
335
+ # 校验通过后生成 candidate scope
336
+ mycodemap design map mycodemap.design.md --json
337
+
338
+ # 把 scope 打包成 handoff artifact,供 reviewer / AI agent 消费
339
+ mycodemap design handoff mycodemap.design.md --json
340
+
341
+ # 基于 reviewed handoff truth 做 verification / drift 检查
342
+ mycodemap design verify mycodemap.design.md --json
343
+
344
+ # 也可以显式传入其他路径
345
+ mycodemap design validate docs/designs/login.design.md
346
+ ```
347
+
348
+ 必填 sections:
349
+ - `## Goal`
350
+ - `## Constraints`
351
+ - `## Acceptance Criteria`
352
+ - `## Non-Goals`
353
+
354
+ > 建议最小工作流:`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 才会阻断。
355
+
287
356
  ### 工作流 CLI 命令
288
357
 
289
358
  ```bash
@@ -379,6 +448,8 @@ mycodemap ci assess-risk -f src/cache/lru-cache.ts
379
448
  mycodemap ci check-output-contract
380
449
  ```
381
450
 
451
+ > `ci assess-risk` 现在输出 `status/confidence/freshness/source` 与统一 risk level;若 Git history 不可用,会显式打印 `unavailable` / warning,并说明阈值未被应用。
452
+
382
453
  ## 配置说明
383
454
 
384
455
  通过 `mycodemap init` 生成的 `mycodemap.config.json` 配置文件支持以下选项:
@@ -435,9 +506,9 @@ mycodemap ci check-output-contract
435
506
  | `exclude` | `string[]` | 排除的文件 glob 模式 | `["node_modules/**", "dist/**", ...]` |
436
507
  | `output` | `string` | 输出目录路径 | `".mycodemap"` |
437
508
  | `watch` | `boolean` | 监听模式预留配置 | `false` |
438
- | `storage.type` | `"filesystem" \| "kuzudb" \| "memory" \| "auto"` | 图存储后端类型 | `"filesystem"` |
509
+ | `storage.type` | `"filesystem" \| "sqlite" \| "memory" \| "auto"` | 图存储后端类型 | `"filesystem"` |
439
510
  | `storage.outputPath` | `string` | 文件系统存储目录 | `".codemap/storage"` |
440
- | `storage.databasePath` | `string` | KùzuDB 数据目录(相对项目根目录) | - |
511
+ | `storage.databasePath` | `string` | SQLite 数据目录(相对项目根目录) | `".codemap/governance.sqlite"` |
441
512
  | `storage.autoThresholds` | `object` | `auto` 后端选择阈值 | - |
442
513
  | `plugins.builtInPlugins` | `boolean` | 是否启用内置插件 | `true` |
443
514
  | `plugins.pluginDir` | `string` | 额外插件目录 | - |
@@ -449,16 +520,16 @@ mycodemap ci check-output-contract
449
520
  ```jsonc
450
521
  {
451
522
  "storage": {
452
- "type": "kuzudb",
453
- "databasePath": ".codemap/kuzu"
523
+ "type": "sqlite",
524
+ "databasePath": ".codemap/governance.sqlite"
454
525
  }
455
526
  }
456
527
  ```
457
528
 
458
529
  - `generate` 会把 CodeGraph 写入配置的 `storage` 后端,`export` 与内部 `Server Layer` handler 会读取同一份后端数据。
459
- - `neo4j` 已不再是正式支持的 backend;旧配置会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
460
- - 选择 `kuzudb` 前先安装 `npm install kuzu`;缺少依赖时会返回显式错误。
461
- - `storage.type = "auto"` 当前仍以 `filesystem` 为保守默认值;阈值字段先作为显式契约保留,不伪装成已完成的自动切换能力。
530
+ - `neo4j` 与 `kuzudb` 已不再是正式支持的 backend;旧配置会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
531
+ - 显式选择 `sqlite` 且运行时缺少 `better-sqlite3` Node.js `<20` 时,会返回显式错误。
532
+ - `storage.type = "auto"` 当前优先选择 `sqlite`;若运行时缺少 `better-sqlite3` 或 Node.js `<20` 导致 SQLite 不可用,则 warning 后回退到 `filesystem`。
462
533
  - 图存储后端生产化不等于重新开放公共 HTTP API 产品面;`Server Layer` 仍是内部架构层。
463
534
 
464
535
  ### 插件运行时说明
@@ -632,6 +703,72 @@ cp examples/codex/codemap-agent.md .agents/skills/codemap/SKILL.md
632
703
 
633
704
  ## 新增 CLI 命令
634
705
 
706
+ ### `mycodemap design`
707
+
708
+ 校验、映射并验证 human-authored design contract,默认读取仓库根目录的 `mycodemap.design.md`。
709
+
710
+ ```bash
711
+ # validate: 使用默认路径校验
712
+ mycodemap design validate mycodemap.design.md --json
713
+
714
+ # validate: 显式指定文件
715
+ mycodemap design validate docs/designs/login.design.md
716
+
717
+ # map: 生成 candidate code scope
718
+ mycodemap design map mycodemap.design.md --json
719
+
720
+ # handoff: 生成 reviewer + agent 共用的 handoff package
721
+ mycodemap design handoff mycodemap.design.md --json
722
+
723
+ # verify: 基于 reviewed handoff truth 做 checklist / drift 校验
724
+ mycodemap design verify mycodemap.design.md --json
725
+ ```
726
+
727
+ | 选项 | 说明 |
728
+ |------|------|
729
+ | `-j, --json` | 输出纯 JSON diagnostics,适合 AI/CI 消费 |
730
+
731
+ > canonical 模板位于 `docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md`。
732
+ > 缺失必填 section、重复 section、空 section 或未知 heading 时,CLI 会返回结构化 diagnostics,而不是继续猜测设计意图。
733
+ > `design map` 会基于 design contract 返回 `candidates`、`diagnostics` 与 `unknowns`;若命中 `no-candidates`、`over-broad-scope` 或 `high-risk-scope`,命令会直接阻断。
734
+ > `design handoff` 会基于 validated design contract + mapping truth 返回 `readyForExecution`、`approvals`、`assumptions`、`openQuestions`;human mode 默认写出 `.mycodemap/handoffs/{stem}.handoff.md|json`。
735
+ > `design verify` 会把 `Acceptance Criteria` 固定映射为 `checklist`,并输出 `drift` / `diagnostics`;当结果只是 `needs-review` 时保持零退出码,只有 `ok=false` 或 blocker diagnostics 才返回非零 exit code。
736
+
737
+ ### `mycodemap check`
738
+
739
+ 执行 design contract contract gate,默认输出机器可读 JSON。
740
+
741
+ ```bash
742
+ # 默认 full scan
743
+ mycodemap check --contract mycodemap.design.md --against src
744
+
745
+ # GitHub PR annotations
746
+ mycodemap check --contract mycodemap.design.md --against src --base origin/main --annotation-format github
747
+
748
+ # GitLab code quality artifact
749
+ mycodemap check --contract mycodemap.design.md --against src --base origin/main --annotation-format gitlab --annotation-file gl-code-quality-report.json
750
+
751
+ # 校准当前仓库是否允许默认 hard gate
752
+ node scripts/calibrate-contract-gate.mjs --max-changed-files 10 --max-false-positive-rate 0.10
753
+ ```
754
+
755
+ > PR 默认 hard gate 只在 calibration 通过且 `changed files <= 10` 时开启;超窗、`diff-scope-fallback` 或 `false-positive rate >10%` 时必须显式切回 `warn-only / fallback`。
756
+
757
+ ### `mycodemap history`
758
+
759
+ 符号级 Git history / risk 查询:
760
+
761
+ ```bash
762
+ # 默认输出 machine-first JSON
763
+ mycodemap history --symbol createCheckCommand
764
+
765
+ # 查询某个符号的历史轨迹与风险摘要
766
+ mycodemap history --symbol createCheckCommand
767
+
768
+ # 人类可读摘要
769
+ mycodemap history --symbol createCheckCommand --human
770
+ ```
771
+
635
772
  ### `mycodemap analyze`
636
773
 
637
774
  统一分析入口,当前公共契约只暴露四个 intent,并统一返回结构化输出:
@@ -681,51 +818,9 @@ mycodemap analyze -i link -t src/index.ts --structured --json
681
818
  > 产品目标是机器可读优先;当前实现仍以显式 `--json` / `--output-mode` 作为主要入口。
682
819
  >
683
820
  > legacy 兼容映射:`search → find`、`impact/complexity → read`、`dependency/reference → link`、`overview/documentation → show`;`refactor` 会返回 `E0001_INVALID_INTENT`。
821
+ >
822
+ > `--include-git-history` 现在只会在 `read` intent 上附加统一的 Git history enrichment;其他 intent 会显式给出 warning,而不是 silent noop。
684
823
 
685
- ### `mycodemap ci`
686
-
687
- CI Gateway - 代码质量门禁工具:
688
-
689
- ```bash
690
- # 验证工作区是否干净(ship 的发布前检查也复用这条规则)
691
- mycodemap ci check-working-tree
692
-
693
- # 验证当前分支是否允许执行发布前检查
694
- mycodemap ci check-branch
695
- mycodemap ci check-branch --allow main,release/*
696
-
697
- # 运行发布前脚本集合(docs/typecheck/lint/test/build/pack)
698
- mycodemap ci check-scripts
699
-
700
- # 验证提交格式([TAG] scope: message)
701
- mycodemap ci check-commits
702
- mycodemap ci check-commits -c 5
703
- mycodemap ci check-commits -r origin/main..HEAD
704
-
705
- # 验证文件头注释([META], [WHY])
706
- mycodemap ci check-headers
707
- mycodemap ci check-headers -d src/domain
708
- mycodemap ci check-headers -f "src/index.ts,src/cli/index.ts"
709
-
710
- # 评估变更风险
711
- mycodemap ci assess-risk
712
- mycodemap ci assess-risk -t 0.5
713
-
714
- # 验证文档同步(含 analyze generated block 校验)
715
- mycodemap ci check-docs-sync
716
-
717
- # 验证输出契约
718
- mycodemap ci check-output-contract
719
-
720
- # 检查提交文件数量(限制 10 个文件)
721
- mycodemap ci check-commit-size
722
- mycodemap ci check-commit-size -m 15
723
- ```
724
-
725
- > `mycodemap ship` 的 CHECK 阶段现在复用 `ci check-working-tree`、`ci check-branch`、`ci check-scripts` 作为 must-pass 事实源,而不是重复实现这些检查。
726
- > `mycodemap ci check-headers -d <dir>` 与 `generate` / `analyze` 共享同一套 `.gitignore` 感知排除模块;若仓库没有 `.gitignore`,则回退到默认 `exclude` 列表。
727
-
728
- 支持的提交 TAG 类型:`[REFACTOR]`, `[TEST]`, `[DOCS]`, `[FEAT]`, `[FIX]`, `[CHORE]`, `[PERF]`, `[SECURITY]`, `[BREAKING]`, `[HOTFIX]`, `[MIGRATION]`, `[WIP]`
729
824
 
730
825
  ## 贡献指南
731
826
 
@@ -816,3 +911,47 @@ DELETE 删除代码/文件
816
911
  ## 许可证
817
912
 
818
913
  [MIT](LICENSE)
914
+ ### `mycodemap ci`
915
+
916
+ CI Gateway - 代码质量门禁工具:
917
+
918
+ ```bash
919
+ # 验证工作区是否干净(ship 的发布前检查也复用这条规则)
920
+ mycodemap ci check-working-tree
921
+
922
+ # 验证当前分支是否允许执行发布前检查
923
+ mycodemap ci check-branch
924
+ mycodemap ci check-branch --allow main,release/*
925
+
926
+ # 运行发布前脚本集合(docs/typecheck/lint/test/build/pack)
927
+ mycodemap ci check-scripts
928
+
929
+ # 验证提交格式([TAG] scope: message)
930
+ mycodemap ci check-commits
931
+ mycodemap ci check-commits -c 5
932
+ mycodemap ci check-commits -r origin/main..HEAD
933
+
934
+ # 验证文件头注释([META], [WHY])
935
+ mycodemap ci check-headers
936
+ mycodemap ci check-headers -d src/domain
937
+ mycodemap ci check-headers -f "src/index.ts,src/cli/index.ts"
938
+
939
+ # 评估变更风险
940
+ mycodemap ci assess-risk
941
+ mycodemap ci assess-risk -t 0.5
942
+
943
+ # 验证文档同步(含 analyze generated block 校验)
944
+ mycodemap ci check-docs-sync
945
+
946
+ # 验证输出契约
947
+ mycodemap ci check-output-contract
948
+
949
+ # 检查提交文件数量(限制 10 个文件)
950
+ mycodemap ci check-commit-size
951
+ mycodemap ci check-commit-size -m 15
952
+ ```
953
+
954
+ > `mycodemap ship` 的 CHECK 阶段现在复用 `ci check-working-tree`、`ci check-branch`、`ci check-scripts` 作为 must-pass 事实源,而不是重复实现这些检查。
955
+ > `mycodemap ci check-headers -d <dir>` 与 `generate` / `analyze` 共享同一套 `.gitignore` 感知排除模块;若仓库没有 `.gitignore`,则回退到默认 `exclude` 列表。
956
+
957
+ 支持的提交 TAG 类型:`[REFACTOR]`, `[TEST]`, `[DOCS]`, `[FEAT]`, `[FIX]`, `[CHORE]`, `[PERF]`, `[SECURITY]`, `[BREAKING]`, `[HOTFIX]`, `[MIGRATION]`, `[WIP]`
@@ -0,0 +1,38 @@
1
+ import { AIProvider, type AIProviderConfig, type AIResponse } from './provider.js';
2
+ import type { CodeMap } from '../types/index.js';
3
+ /**
4
+ * Claude Provider 配置
5
+ */
6
+ export interface ClaudeProviderConfig extends AIProviderConfig {
7
+ /** CLI 路径,默认 claude */
8
+ cliPath?: string;
9
+ }
10
+ /**
11
+ * Claude Provider - 通过 CLI 调用 Claude
12
+ */
13
+ export declare class ClaudeProvider extends AIProvider {
14
+ readonly name: "claude";
15
+ private cliPath;
16
+ constructor(config?: ClaudeProviderConfig);
17
+ /**
18
+ * 执行 AI 推理
19
+ */
20
+ execute(prompt: string, context?: CodeMap): Promise<AIResponse>;
21
+ /**
22
+ * 检查 Claude CLI 是否可用
23
+ */
24
+ isAvailable(): Promise<boolean>;
25
+ /**
26
+ * 构建提示词
27
+ */
28
+ private buildPrompt;
29
+ /**
30
+ * 总结 CodeMap 上下文
31
+ */
32
+ private summarizeContext;
33
+ /**
34
+ * 解析 Claude CLI JSON 响应
35
+ */
36
+ private parseResponse;
37
+ }
38
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ai/claude.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAWjD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAgB,IAAI,EAAG,QAAQ,CAAU;IACzC,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,GAAE,oBAAyB;IAK7C;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAoErE;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAsBrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsCxB;;OAEG;IACH,OAAO,CAAC,aAAa;CA6BtB"}
@@ -0,0 +1,169 @@
1
+ // ============================================
2
+ // Claude CLI Provider 实现
3
+ // ============================================
4
+ import { spawn } from 'child_process';
5
+ import { AIProvider } from './provider.js';
6
+ /**
7
+ * Claude Provider - 通过 CLI 调用 Claude
8
+ */
9
+ export class ClaudeProvider extends AIProvider {
10
+ name = 'claude';
11
+ cliPath;
12
+ constructor(config = {}) {
13
+ super(config);
14
+ this.cliPath = config.cliPath || 'claude';
15
+ }
16
+ /**
17
+ * 执行 AI 推理
18
+ */
19
+ async execute(prompt, context) {
20
+ const timeout = this.config.timeout || 60000;
21
+ // 构建包含上下文的完整提示词
22
+ const fullPrompt = this.buildPrompt(prompt, context);
23
+ return new Promise((resolve, reject) => {
24
+ const args = [
25
+ '-p',
26
+ '--output-format', 'json',
27
+ '--dangerously-skip-permissions'
28
+ ];
29
+ let stdout = '';
30
+ let stderr = '';
31
+ let killed = false;
32
+ const proc = spawn(this.cliPath, args, {
33
+ stdio: ['pipe', 'pipe', 'pipe'],
34
+ timeout
35
+ });
36
+ // 超时处理
37
+ const timeoutId = setTimeout(() => {
38
+ killed = true;
39
+ proc.kill('SIGTERM');
40
+ reject(new Error(`Claude 执行超时(${timeout / 1000}秒)`));
41
+ }, timeout);
42
+ proc.stdout.on('data', (data) => {
43
+ stdout += data.toString();
44
+ });
45
+ proc.stderr.on('data', (data) => {
46
+ stderr += data.toString();
47
+ });
48
+ proc.on('close', (code) => {
49
+ clearTimeout(timeoutId);
50
+ if (killed)
51
+ return;
52
+ if (code !== 0 && code !== null) {
53
+ reject(new Error(`Claude CLI 错误: ${stderr || `exit code ${code}`}`));
54
+ return;
55
+ }
56
+ try {
57
+ const response = this.parseResponse(stdout);
58
+ resolve(response);
59
+ }
60
+ catch (error) {
61
+ reject(new Error(`解析 Claude 响应失败: ${error instanceof Error ? error.message : String(error)}`));
62
+ }
63
+ });
64
+ proc.on('error', (error) => {
65
+ clearTimeout(timeoutId);
66
+ if (!killed) {
67
+ reject(new Error(`Claude CLI 执行失败: ${error.message}`));
68
+ }
69
+ });
70
+ // 发送提示词
71
+ proc.stdin.write(fullPrompt);
72
+ proc.stdin.end();
73
+ });
74
+ }
75
+ /**
76
+ * 检查 Claude CLI 是否可用
77
+ */
78
+ async isAvailable() {
79
+ return new Promise((resolve) => {
80
+ const proc = spawn(this.cliPath, ['--version'], {
81
+ stdio: 'ignore'
82
+ });
83
+ proc.on('close', (code) => {
84
+ resolve(code === 0);
85
+ });
86
+ proc.on('error', () => {
87
+ resolve(false);
88
+ });
89
+ // 2 秒超时
90
+ setTimeout(() => {
91
+ proc.kill();
92
+ resolve(false);
93
+ }, 2000);
94
+ });
95
+ }
96
+ /**
97
+ * 构建提示词
98
+ */
99
+ buildPrompt(prompt, context) {
100
+ let fullPrompt = prompt;
101
+ if (context) {
102
+ const contextInfo = this.summarizeContext(context);
103
+ fullPrompt = `${contextInfo}\n\n---\n\n${prompt}`;
104
+ }
105
+ return fullPrompt;
106
+ }
107
+ /**
108
+ * 总结 CodeMap 上下文
109
+ */
110
+ summarizeContext(codeMap) {
111
+ const lines = [];
112
+ lines.push('# Project Context');
113
+ lines.push('');
114
+ lines.push(`Project: ${codeMap.project.name}`);
115
+ lines.push(`Total Files: ${codeMap.summary.totalFiles}`);
116
+ lines.push(`Total Modules: ${codeMap.summary.totalModules}`);
117
+ lines.push('');
118
+ // 入口点
119
+ const entryPoints = codeMap.modules.filter(m => {
120
+ const basename = require('path').basename(m.path);
121
+ return basename === 'index.ts' || basename === 'main.ts' || basename === 'app.ts';
122
+ });
123
+ if (entryPoints.length > 0) {
124
+ lines.push('## Entry Points');
125
+ for (const ep of entryPoints.slice(0, 5)) {
126
+ lines.push(`- ${ep.path}`);
127
+ }
128
+ lines.push('');
129
+ }
130
+ // 模块列表
131
+ lines.push('## Modules');
132
+ for (const mod of codeMap.modules.slice(0, 20)) {
133
+ const exports = mod.exports.map(e => e.name).join(', ');
134
+ lines.push(`- ${mod.path}: ${exports || '(no exports)'}`);
135
+ }
136
+ if (codeMap.modules.length > 20) {
137
+ lines.push(`- ... and ${codeMap.modules.length - 20} more`);
138
+ }
139
+ return lines.join('\n');
140
+ }
141
+ /**
142
+ * 解析 Claude CLI JSON 响应
143
+ */
144
+ parseResponse(stdout) {
145
+ // Claude 可能输出多行 JSON,需要找到有效的 JSON
146
+ const lines = stdout.trim().split('\n');
147
+ let jsonStr = '';
148
+ // 从后往前找有效的 JSON 对象
149
+ for (let i = lines.length - 1; i >= 0; i--) {
150
+ const line = lines[i].trim();
151
+ if (line.startsWith('{') && line.endsWith('}')) {
152
+ jsonStr = line;
153
+ break;
154
+ }
155
+ }
156
+ if (!jsonStr) {
157
+ // 如果没有 JSON,直接返回原始输出
158
+ return { content: stdout.trim() };
159
+ }
160
+ const parsed = JSON.parse(jsonStr);
161
+ if (parsed.error) {
162
+ throw new Error(parsed.error);
163
+ }
164
+ return {
165
+ content: parsed.result || stdout.trim()
166
+ };
167
+ }
168
+ }
169
+ //# sourceMappingURL=claude.js.map