@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
@@ -16,6 +16,7 @@ mycodemap generate # hybrid 模式(推荐)
16
16
  mycodemap generate -m smart # AST 深度分析
17
17
  mycodemap generate -m fast # 快速正则分析
18
18
  mycodemap generate -o ./output # 指定输出目录
19
+ mycodemap generate --symbol-level # 额外 materialize symbol-level call 依赖
19
20
  mycodemap generate --ai-context # 生成 AI 描述
20
21
  ```
21
22
 
@@ -23,12 +24,15 @@ mycodemap generate --ai-context # 生成 AI 描述
23
24
  |------|------|--------|
24
25
  | `-m, --mode <mode>` | 分析模式: fast/smart/hybrid | `hybrid` |
25
26
  | `-o, --output <dir>` | 输出目录 | `.mycodemap` |
27
+ | `--symbol-level` | 仅在显式开启时把可解析的 symbol-level `call` 依赖写入图存储 | `false` |
26
28
  | `--ai-context` | 为每个文件生成描述 | - |
27
29
 
28
30
  **模式说明**:
29
31
  - `fast`: 正则匹配,极快,适合大型项目
30
32
  - `smart`: AST 分析,较慢,信息完整
31
33
  - `hybrid`: 自动选择,文件<50用fast,≥50用smart
34
+ - `--symbol-level` 是首期实验性切片;默认 generate 仍只保证现有模块级行为兼容
35
+ - `generate` 完成后,`codemap.json` 会带 `graphStatus`、`failedFileCount` 与可选 `parseFailureFiles`;若 `graphStatus = "partial"`,不要把结果当成完整图。
32
36
 
33
37
  **插件运行时说明**:
34
38
  - `generate` 不提供独立 `--plugin` flags;插件通过 `mycodemap.config.json` 的 `plugins` 段声明。
@@ -37,9 +41,9 @@ mycodemap generate --ai-context # 生成 AI 描述
37
41
 
38
42
  **图存储运行时说明**:
39
43
  - `generate` 会读取 `mycodemap.config.json.storage`,并把 CodeGraph 写入所选后端。
40
- - `storage.type` 支持 `filesystem`、`kuzudb`、`memory`、`auto`;默认是 `filesystem`。
41
- - 旧的 `neo4j` 配置会直接报迁移错误;缺少 `kuzu` 时也会直接报错,不会静默 fallback 到 `filesystem`。
42
- - `storage.type = "auto"` 当前仍保守走 `filesystem`;阈值字段是配置契约,不代表自动切换已完成。
44
+ - `storage.type` 支持 `filesystem`、`sqlite`、`memory`、`auto`;默认是 `filesystem`。
45
+ - 旧的 `neo4j` / `kuzudb` 配置会直接报迁移错误;显式选择 `sqlite` 但运行时缺少 `better-sqlite3` 或 Node.js `<20` 时也会直接报错,不会静默 fallback 到 `filesystem`。
46
+ - `storage.type = "auto"` 当前优先走 `sqlite`;只有 SQLite 不可用时才 warning 后回退 `filesystem`。
43
47
 
44
48
  ---
45
49
 
@@ -105,11 +109,35 @@ mycodemap impact -f "src/cli/index.ts" -j # JSON 输出
105
109
 
106
110
  ---
107
111
 
112
+ ### mcp - experimental 本地 MCP 集成
113
+
114
+ ```bash
115
+ mycodemap mcp install # 把当前仓库写入 .mcp.json
116
+ mycodemap mcp start # 启动本地 stdio MCP server
117
+ mycodemap generate --symbol-level # 使用前必须先生成 symbol-level 图
118
+ ```
119
+
120
+ | 子命令 | 说明 |
121
+ |--------|------|
122
+ | `install` | 更新当前仓库根目录 `.mcp.json`,追加 `mycodemap-experimental` server entry |
123
+ | `start` | 启动 local-only / read-only / stdio-first experimental MCP server |
124
+
125
+ **首期规则**:
126
+ - `mcp` 是 experimental surface,不要把它当成稳定长期 public API。
127
+ - `mcp start` 的 `stdout` 只能承载 MCP 协议帧;欢迎信息、迁移提示与 runtime log 不会走这条流。
128
+ - 当前只暴露两个工具:`codemap_query`、`codemap_impact`。
129
+ - `codemap_query` / `codemap_impact` 都会返回 `graph_status`、`generated_at` 与显式 `error.code`。
130
+ - 若图尚未生成,会返回 `GRAPH_NOT_FOUND`;若符号不存在,返回 `SYMBOL_NOT_FOUND`;若同名符号无法消歧,返回 `AMBIGUOUS_EDGE`。
131
+ - 详细安装步骤见 `docs/ai-guide/INTEGRATION.md`;完整 output contract 见 `docs/ai-guide/OUTPUT.md`。
132
+
133
+ ---
134
+
108
135
  ### complexity - 复杂度分析
109
136
 
110
137
  ```bash
111
138
  mycodemap complexity # 项目整体
112
139
  mycodemap complexity -f "src/cli/index.ts" # 指定文件
140
+ mycodemap complexity -f "src/cli/index.ts" -j # 单文件 JSON,顶层返回 file
113
141
  mycodemap complexity -d # 函数级详情
114
142
  mycodemap complexity -j # JSON 输出
115
143
  ```
@@ -121,6 +149,8 @@ mycodemap complexity -j # JSON 输出
121
149
  | `-j, --json` | JSON 格式输出 | - |
122
150
  | `--structured` | 纯结构化输出 | - |
123
151
 
152
+ > `complexity -f "src/file.ts" -j` 的 JSON 顶层只返回 `file`;不会返回全项目 `modules` 数组。
153
+
124
154
  ---
125
155
 
126
156
  ### cycles - 循环依赖检测
@@ -148,10 +178,13 @@ mycodemap cycles -j # JSON 输出
148
178
  | 输出契约 | 多数命令显式 `--json`,`analyze` 额外提供 `--output-mode machine|human` | `--structured --json` 会移除自然语言 `content` |
149
179
  | analyze 意图 | `find` / `read` / `link` / `show` | legacy alias 会在输出中返回 `warnings[]`;`refactor` 直接报 `E0001_INVALID_INTENT` |
150
180
 
181
+ > 通用搜索仍优先使用 `query -S "XXX" -j`。需要统一 analyze schema 时使用 `analyze -i find -k "XXX" --json --structured`,并读取 stdout JSON 的 `diagnostics.status` 区分真实 0 命中、`partialFailure` 降级与 `failure`。
182
+
151
183
  <!-- BEGIN GENERATED: analyze-commands-intents -->
152
184
  ```bash
153
185
  # 1. find - 查找符号 / 文本
154
186
  mycodemap analyze -i find -k "UnifiedResult"
187
+ mycodemap analyze -i find -k "SourceLocation" --json --structured
155
188
  mycodemap analyze -i find -t "src/orchestrator" -k "IntentRouter" --topK 20
156
189
 
157
190
  # 2. read - 阅读文件(影响 + 复杂度)
@@ -214,6 +247,118 @@ mycodemap analyze -i show -t "src/index.ts" --output-mode human
214
247
 
215
248
  ---
216
249
 
250
+ ## design - 设计契约输入、范围映射与验证
251
+
252
+ > `design` 为 human-authored design contract 提供正式输入面。默认文件名是 `mycodemap.design.md`,canonical 模板位于 `docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md`。
253
+
254
+ ### validate
255
+
256
+ ```bash
257
+ # 使用默认文件名
258
+ mycodemap design validate mycodemap.design.md --json
259
+
260
+ # 显式指定文件
261
+ mycodemap design validate docs/designs/login.design.md
262
+ ```
263
+
264
+ ### 必填 sections
265
+
266
+ | Section | 作用 |
267
+ |---------|------|
268
+ | `Goal` | 定义本次要达成的结果 |
269
+ | `Constraints` | 定义边界、兼容性和约束 |
270
+ | `Acceptance Criteria` | 定义可验证的成功标准 |
271
+ | `Non-Goals` | 明确本次不做什么,防止 scope drift |
272
+
273
+ ### 输出与失败语义
274
+
275
+ - `--json` 输出纯结构化 diagnostics
276
+ - 缺失必填 section、重复 section、空 section、未知 heading 都会被显式报告
277
+ - blocker diagnostics 存在时命令返回非零 exit code
278
+
279
+ ### map
280
+
281
+ ```bash
282
+ # 先校验,再映射 candidate scope
283
+ mycodemap design validate mycodemap.design.md --json
284
+ mycodemap design map mycodemap.design.md --json
285
+ ```
286
+
287
+ - `design map` 返回 `summary`、`candidates`、`diagnostics`、`unknowns`
288
+ - `candidates[]` 会同时暴露 `kind`、`path`、`reasons`、`dependencies`、`testImpact`、`risk`、`confidence`
289
+ - blocker diagnostics 包括 `no-candidates`、`over-broad-scope`、`high-risk-scope`
290
+ - 若 diagnostics 中存在 blocker,命令返回非零 exit code
291
+
292
+ ### handoff
293
+
294
+ ```bash
295
+ # 先固定 design input / scope,再生成 handoff package
296
+ mycodemap design validate mycodemap.design.md --json
297
+ mycodemap design map mycodemap.design.md --json
298
+ mycodemap design handoff mycodemap.design.md --json
299
+ ```
300
+
301
+ - `design handoff` 返回 `readyForExecution`、`approvals`、`assumptions`、`openQuestions`
302
+ - human mode 默认写入 `.mycodemap/handoffs/{stem}.handoff.md|json`
303
+ - `--json` 保持纯 JSON,不混入 prose
304
+ - review-needed 通过 `readyForExecution=false` 表达;只有 blocker diagnostics 才返回非零 exit code
305
+
306
+ ### verify
307
+
308
+ ```bash
309
+ # 使用 reviewed handoff truth 做 checklist / drift 校验
310
+ mycodemap design validate mycodemap.design.md --json
311
+ mycodemap design map mycodemap.design.md --json
312
+ mycodemap design handoff mycodemap.design.md --json
313
+ mycodemap design verify mycodemap.design.md --json
314
+ ```
315
+
316
+ - `design verify` 返回 `summary`、`checklist`、`drift`、`diagnostics`
317
+ - `checklist[]` 直接来自 `Acceptance Criteria`,并保留 `status` + `evidenceRefs`
318
+ - `drift[]` 至少区分 `scope-extra`、`acceptance-unverified`、`handoff-missing`
319
+ - review-needed 通过 `readyForExecution=false` + warning diagnostics 表达;只有 `ok=false` 或 blocker diagnostics 才返回非零 exit code
320
+
321
+ ---
322
+
323
+ ## check - 执行 contract gate
324
+
325
+ ```bash
326
+ # 默认 full scan
327
+ mycodemap check --contract mycodemap.design.md --against src
328
+
329
+ # 人类可读渲染
330
+ mycodemap check --contract mycodemap.design.md --against src --human
331
+
332
+ # PR / CI 显式 diff
333
+ mycodemap check --contract mycodemap.design.md --against src --base origin/main
334
+
335
+ # 显式 changed files
336
+ mycodemap check --contract mycodemap.design.md --against src --changed-files src/core/service.ts
337
+
338
+ # GitHub PR annotations
339
+ mycodemap check --contract mycodemap.design.md --against src --base origin/main --annotation-format github
340
+
341
+ # GitLab code quality artifact
342
+ mycodemap check --contract mycodemap.design.md --against src --base origin/main --annotation-format gitlab --annotation-file gl-code-quality-report.json
343
+
344
+ # 校准当前仓库是否允许默认 hard gate
345
+ node scripts/calibrate-contract-gate.mjs --max-changed-files 10 --max-false-positive-rate 0.10
346
+ ```
347
+
348
+ - 默认输出 `ContractCheckResult` JSON;`--human` 只改变渲染,不改变底层 truth
349
+ - JSON 默认包含 `passed` 与 `summary`,Agent 不需要解析 prose 判断通过状态
350
+ - `severity:error` 返回非零退出码,`severity:warn` 不阻断
351
+ - diff-aware 只在显式提供 `--base` 或 `--changed-files` 时启用
352
+ - 坏掉的 diff base 或越界 changed files 会回退 full scan,并把原因写进 `warnings[]`
353
+ - 当前 rule families 为 `layer_direction` / `forbidden_imports` / `module_public_api_only` / `complexity_threshold`
354
+ - `--annotation-format github` 会输出 GitHub Actions annotations;`gitlab` 需要配合 `--annotation-file gl-code-quality-report.json`,并只保留 line-scoped diagnostics
355
+ - PR 默认 hard gate 只在 calibration 通过且 `changed files <= 10` 时开启;超窗、`diff-scope-fallback` 或 `false-positive rate >10%` 时必须显式切回 `warn-only / fallback`
356
+ - calibration 输出的 recommendation 目前是 `hard-gate-ok` / `warn-only` / `re-scope`;fallback 不应伪装成稳定 hard gate
357
+ - Git history risk 是 additive enrichment:会附加 `violations[].risk` 与顶层 `history`,但不会改变 `severity:error` / exit 语义
358
+ - 仓库根 `mycodemap.design.md` 是当前 canonical contract truth
359
+
360
+ ---
361
+
217
362
  ## ci - CI 门禁
218
363
 
219
364
  ### 子命令
@@ -239,10 +384,11 @@ mycodemap ci check-headers
239
384
  mycodemap ci check-headers -d "src/domain" # 指定目录
240
385
  mycodemap ci check-headers -f "file1.ts,file2.ts"
241
386
 
242
- # 评估变更风险
387
+ # 评估变更风险(与 `check` / `history` 共用同一套 Git history risk truth)
243
388
  mycodemap ci assess-risk
244
389
  mycodemap ci assess-risk -t 0.5 # 设置阈值 0.5
245
390
  mycodemap ci assess-risk -f "changed.ts"
391
+ mycodemap ci assess-risk --files "changed.ts" --json
246
392
 
247
393
  # 验证文档同步
248
394
  mycodemap ci check-docs-sync
@@ -261,6 +407,24 @@ mycodemap ci check-commit-size -m 15
261
407
 
262
408
  > `ship` 的 CHECK 阶段会复用 `ci check-working-tree`、`ci check-branch`、`ci check-scripts` 这三条发布前 gate checks。
263
409
  > `ci check-branch --allow` 支持 `*` 通配;`ci check-headers -d` 与 `generate` / `analyze` 共享同一套 `.gitignore` 感知排除规则,在没有 `.gitignore` 时回退到默认 `exclude`。
410
+ > `ci assess-risk` 现在输出 `status / confidence / freshness / source / score / level`;若 Git history 不可用,会显式给出 `unavailable` / warning,并说明阈值未被应用。
411
+ > `ci assess-risk --json` 顶层输出 `status: "passed" | "failed" | "skipped"`;`failed` 会设置非零 exit code,但 stdout 保持可解析 JSON。
412
+
413
+ ---
414
+
415
+ ## history - 符号级 Git history / risk 查询
416
+
417
+ ```bash
418
+ # 默认输出 machine-first JSON
419
+ mycodemap history --symbol createCheckCommand
420
+
421
+ # 人类可读渲染
422
+ mycodemap history --symbol createCheckCommand --human
423
+ ```
424
+
425
+ - 返回 `ok` / `ambiguous` / `not_found` / `unavailable` 四种状态
426
+ - `--human` 只改变展示,不改变结构化 truth
427
+ - 与 `check` / `ci assess-risk` 共用同一套 history risk service;历史缺失时会显式返回 `unavailable`
264
428
 
265
429
  ### 支持的提交 TAG
266
430
 
@@ -287,6 +451,7 @@ mycodemap ci check-commit-size -m 15
287
451
  # 启动工作流
288
452
  mycodemap workflow start "实现用户认证模块"
289
453
  mycodemap workflow start "修复登录接口" --template bugfix
454
+ mycodemap workflow start "inspect analyze find" --json
290
455
 
291
456
  # 查看状态
292
457
  mycodemap workflow status
@@ -312,6 +477,8 @@ mycodemap workflow resume
312
477
  mycodemap workflow resume "workflow-id"
313
478
  ```
314
479
 
480
+ > `workflow start --json` 输出 `{ status, task, id, currentPhase, template, nextSteps }`,不改变 workflow 的 analysis-only 边界。
481
+
315
482
  ### 模板管理
316
483
 
317
484
  ```bash