@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
@@ -77,15 +77,33 @@ interface CodeMap {
77
77
  summary: ProjectSummary;
78
78
  modules: ModuleInfo[];
79
79
  dependencies: DependencyGraph;
80
+ graphStatus?: "complete" | "partial";
81
+ failedFileCount?: number;
82
+ parseFailureFiles?: string[];
80
83
  actualMode?: "fast" | "smart";
81
84
  pluginReport?: PluginExecutionReport;
82
85
  }
83
86
  ```
84
87
 
88
+ ### graph integrity 语义
89
+
90
+ | 字段 | 含义 | 何时出现 |
91
+ |------|------|----------|
92
+ | `graphStatus` | 当前图是否完整:`complete` / `partial` | `generate` 输出总会写入 |
93
+ | `failedFileCount` | 发现到但未成功进入最终图的文件数 | `generate` 输出总会写入 |
94
+ | `parseFailureFiles` | 失败文件路径列表 | 仅当 `failedFileCount > 0` 时出现 |
95
+
96
+ - `summary.totalFiles` 仍表示**成功进入最终图**的模块数,不代表发现阶段的总文件数。
97
+ - 若 `graphStatus = "partial"`,Agent / 自动化流程必须把图视为**降级结果**,不能伪装成完整 truth。
98
+ - `generate --symbol-level` 与默认 generate 都遵守同一套 `graphStatus` 语义;差别只在是否 materialize symbol-level `call` 依赖。
99
+
85
100
  ### 示例
86
101
 
87
102
  ```json
88
103
  {
104
+ "graphStatus": "partial",
105
+ "failedFileCount": 1,
106
+ "parseFailureFiles": ["src/broken.ts"],
89
107
  "pluginReport": {
90
108
  "loadedPlugins": ["complexity-analyzer", "my-local-plugin"],
91
109
  "generatedFiles": ["plugins/good.txt"],
@@ -110,6 +128,144 @@ interface CodeMap {
110
128
 
111
129
  ---
112
130
 
131
+ ## experimental MCP tool 输出结构
132
+
133
+ > canonical MCP path 是 `generate --symbol-level → mcp install → host 启动 mcp start`。当前只暴露 `codemap_query` / `codemap_impact` 两个工具。
134
+
135
+ ```typescript
136
+ type McpToolStatus = "ok" | "not_found" | "ambiguous" | "unavailable";
137
+ type McpToolConfidence = "high" | "ambiguous" | "unavailable";
138
+ type McpGraphStatus = "complete" | "partial" | "missing";
139
+ type McpErrorCode = "GRAPH_NOT_FOUND" | "SYMBOL_NOT_FOUND" | "AMBIGUOUS_EDGE";
140
+
141
+ interface McpSymbolRef {
142
+ id: string;
143
+ module_id: string;
144
+ name: string;
145
+ kind: string;
146
+ visibility: "public" | "private" | "protected" | "internal";
147
+ file_path: string;
148
+ line: number;
149
+ column: number;
150
+ signature?: string;
151
+ }
152
+
153
+ interface McpQueryResult {
154
+ status: McpToolStatus;
155
+ confidence: McpToolConfidence;
156
+ graph_status: McpGraphStatus;
157
+ generated_at: string | null;
158
+ failed_file_count: number;
159
+ parse_failure_files: string[];
160
+ symbol?: McpSymbolRef;
161
+ callers: McpSymbolRef[];
162
+ callees: McpSymbolRef[];
163
+ error?: {
164
+ code: McpErrorCode;
165
+ message: string;
166
+ details?: Record<string, unknown>;
167
+ };
168
+ }
169
+
170
+ interface McpImpactResult {
171
+ status: McpToolStatus;
172
+ confidence: McpToolConfidence;
173
+ graph_status: McpGraphStatus;
174
+ generated_at: string | null;
175
+ failed_file_count: number;
176
+ parse_failure_files: string[];
177
+ root_symbol?: McpSymbolRef;
178
+ affected_symbols: Array<{
179
+ symbol: McpSymbolRef;
180
+ depth: number;
181
+ path: string[];
182
+ }>;
183
+ depth: number;
184
+ limit: number;
185
+ truncated: boolean;
186
+ error?: {
187
+ code: McpErrorCode;
188
+ message: string;
189
+ details?: Record<string, unknown>;
190
+ };
191
+ }
192
+ ```
193
+
194
+ ### `codemap_query`
195
+
196
+ 输入:
197
+
198
+ ```typescript
199
+ interface CodemapQueryInput {
200
+ symbol: string;
201
+ filePath?: string;
202
+ }
203
+ ```
204
+
205
+ 语义:
206
+ - `status = "ok"`:返回 `symbol`、`callers`、`callees`
207
+ - `status = "unavailable"` + `GRAPH_NOT_FOUND`:还没生成 symbol-level 图
208
+ - `status = "not_found"` + `SYMBOL_NOT_FOUND`:目标符号不存在
209
+ - `status = "ambiguous"` + `AMBIGUOUS_EDGE`:同名符号无法仅靠 `symbol` / `filePath` 消歧
210
+
211
+ ### `codemap_impact`
212
+
213
+ 输入:
214
+
215
+ ```typescript
216
+ interface CodemapImpactInput {
217
+ symbol: string;
218
+ filePath?: string;
219
+ depth?: number;
220
+ limit?: number;
221
+ }
222
+ ```
223
+
224
+ 语义:
225
+ - `affected_symbols` 按 caller impact 链返回,`path` 从 root symbol id 开始
226
+ - `depth` / `limit` 会被收敛到首期限额,防止 host 挂起
227
+ - `truncated = true` 说明结果已命中 `limit`
228
+
229
+ ### MCP 结果示例
230
+
231
+ ```json
232
+ {
233
+ "status": "ok",
234
+ "confidence": "high",
235
+ "graph_status": "partial",
236
+ "generated_at": "2026-04-19T00:00:00.000Z",
237
+ "failed_file_count": 1,
238
+ "parse_failure_files": ["src/broken.ts"],
239
+ "symbol": {
240
+ "id": "sym-target",
241
+ "module_id": "mod-target",
242
+ "name": "target",
243
+ "kind": "function",
244
+ "visibility": "public",
245
+ "file_path": "src/target.ts",
246
+ "line": 1,
247
+ "column": 1,
248
+ "signature": "target() => void"
249
+ },
250
+ "callers": [
251
+ {
252
+ "id": "sym-caller",
253
+ "module_id": "mod-caller",
254
+ "name": "caller",
255
+ "kind": "function",
256
+ "visibility": "public",
257
+ "file_path": "src/caller.ts",
258
+ "line": 1,
259
+ "column": 1,
260
+ "signature": "caller() => void"
261
+ }
262
+ ],
263
+ "callees": []
264
+ }
265
+ ```
266
+
267
+ ---
268
+
113
269
  ## query 命令输出结构
114
270
 
115
271
  ### JSON 输出 (-j)
@@ -211,6 +367,7 @@ interface AnalyzeOutput {
211
367
  };
212
368
  results: AnalyzeResult[];
213
369
  warnings?: AnalyzeWarning[];
370
+ diagnostics?: AnalyzeDiagnostics;
214
371
  analysis?: ReadAnalysis | LinkAnalysis | ShowAnalysis;
215
372
  metadata: {
216
373
  total: number;
@@ -219,13 +376,35 @@ interface AnalyzeOutput {
219
376
  };
220
377
  }
221
378
 
379
+ interface AnalyzeDiagnostics {
380
+ status: "success" | "partialFailure" | "failure";
381
+ items: AnalyzeDiagnostic[];
382
+ failedTools?: string[];
383
+ degradedTools?: string[];
384
+ }
385
+
386
+ interface AnalyzeDiagnostic {
387
+ code: string;
388
+ severity: "info" | "warning" | "error";
389
+ message: string;
390
+ source: string;
391
+ recoverable: boolean;
392
+ details?: Record<string, unknown>;
393
+ }
394
+
222
395
  interface AnalyzeWarning {
223
- code: "deprecated-intent";
396
+ code:
397
+ | "deprecated-intent"
398
+ | "git-history-unavailable"
399
+ | "git-history-precompute-recommended"
400
+ | "git-history-stale"
401
+ | "git-history-unsupported-intent";
224
402
  severity: "warning";
225
403
  message: string;
226
- deprecatedIntent: "impact" | "dependency" | "search" | "documentation" | "complexity" | "overview" | "reference";
227
- replacementIntent: AnalyzeIntent;
228
- sunsetPolicy: "2-minor-window";
404
+ details?: Record<string, string | number | boolean | null>;
405
+ deprecatedIntent?: "impact" | "dependency" | "search" | "documentation" | "complexity" | "overview" | "reference";
406
+ replacementIntent?: AnalyzeIntent;
407
+ sunsetPolicy?: "2-minor-window";
229
408
  }
230
409
 
231
410
  interface AnalyzeResult {
@@ -241,6 +420,15 @@ interface AnalyzeResult {
241
420
  testFile?: string; // 关联的测试文件
242
421
  dependencies?: string[];
243
422
  impactCount?: number;
423
+ historyRisk?: {
424
+ status: "ok" | "ambiguous" | "not_found" | "unavailable";
425
+ level: "high" | "medium" | "low" | "unavailable";
426
+ confidence: "high" | "medium" | "low" | "unavailable";
427
+ freshness: "fresh" | "stale" | "expired" | "unknown";
428
+ score: number | null;
429
+ factors: string[];
430
+ analyzedAt: string | null;
431
+ };
244
432
  complexityMetrics?: {
245
433
  cyclomatic: number;
246
434
  cognitive: number;
@@ -269,6 +457,22 @@ interface ReadAnalysis {
269
457
  };
270
458
  risk: "high" | "medium" | "low";
271
459
  }>;
460
+ history?: Array<{
461
+ file: string;
462
+ status: "ok" | "ambiguous" | "not_found" | "unavailable";
463
+ confidence: "high" | "medium" | "low" | "unavailable";
464
+ freshness: "fresh" | "stale" | "expired" | "unknown";
465
+ source: "git-live" | "sqlite-materialized" | "sqlite-cache" | "unavailable";
466
+ scopeMode: "full" | "partial" | "top-files-only" | "precompute-required";
467
+ analyzedAt: string | null;
468
+ risk: {
469
+ level: "high" | "medium" | "low" | "unavailable";
470
+ score: number | null;
471
+ gravity: number | null;
472
+ impact: number | null;
473
+ factors: string[];
474
+ };
475
+ }>;
272
476
  }
273
477
 
274
478
  interface LinkAnalysis {
@@ -301,6 +505,13 @@ interface ShowAnalysis {
301
505
  }
302
506
  ```
303
507
 
508
+ ### analyze find failure semantics
509
+
510
+ - `diagnostics.status = "success"` 且 `results=[]`:扫描链路可信完成,表示真实 0 命中。
511
+ - `diagnostics.status = "partialFailure"`:主扫描退化,但配置感知 fallback 已返回可用结果;读取 `degradedTools[]` 和 `items[]`。
512
+ - `diagnostics.status = "failure"`:主扫描与 fallback 都失败,不能把 `results=[]` 当作“代码不存在”;JSON/machine 模式会设置非零 exit code。
513
+ - 通用查找默认仍推荐 `query -S "XXX" -j`;`analyze -i find -k "XXX" --json --structured` 用于需要统一 analyze schema 与 diagnostics 的 Agent 流程。
514
+
304
515
  ### 纯结构化输出 (--structured --json)
305
516
 
306
517
  移除了 `content` 字段,只保留结构化数据:
@@ -375,7 +586,16 @@ interface StructuredResult {
375
586
  "dependencies": [
376
587
  "src/orchestrator/intent-router.ts"
377
588
  ],
378
- "riskLevel": "medium"
589
+ "riskLevel": "medium",
590
+ "historyRisk": {
591
+ "status": "ok",
592
+ "level": "high",
593
+ "confidence": "high",
594
+ "freshness": "fresh",
595
+ "score": 0.82,
596
+ "factors": ["recent bugfixes"],
597
+ "analyzedAt": "2026-04-15T00:00:00.000Z"
598
+ }
379
599
  }
380
600
  }
381
601
  ],
@@ -393,6 +613,24 @@ interface StructuredResult {
393
613
  "impactCount": 3,
394
614
  "risk": "medium"
395
615
  }
616
+ ],
617
+ "history": [
618
+ {
619
+ "file": "src/cli/commands/analyze.ts",
620
+ "status": "ok",
621
+ "confidence": "high",
622
+ "freshness": "fresh",
623
+ "source": "git-live",
624
+ "scopeMode": "full",
625
+ "analyzedAt": "2026-04-15T00:00:00.000Z",
626
+ "risk": {
627
+ "level": "high",
628
+ "score": 0.82,
629
+ "gravity": 0.6,
630
+ "impact": 0.8,
631
+ "factors": ["recent bugfixes"]
632
+ }
633
+ }
396
634
  ]
397
635
  },
398
636
  "metadata": {
@@ -405,6 +643,653 @@ interface StructuredResult {
405
643
 
406
644
  ---
407
645
 
646
+ ## design validate 命令输出结构
647
+
648
+ ### JSON 输出 (--json)
649
+
650
+ ```typescript
651
+ type DesignContractSectionId =
652
+ | "goal"
653
+ | "constraints"
654
+ | "acceptanceCriteria"
655
+ | "nonGoals"
656
+ | "context"
657
+ | "openQuestions"
658
+ | "notes";
659
+
660
+ type DesignContractDiagnosticCode =
661
+ | "file-not-found"
662
+ | "missing-section"
663
+ | "duplicate-section"
664
+ | "empty-section"
665
+ | "unknown-section"
666
+ | "ambiguous-heading"
667
+ | "invalid-frontmatter"
668
+ | "invalid-rules-root"
669
+ | "invalid-rule-type"
670
+ | "missing-rule-field"
671
+ | "invalid-rule-severity"
672
+ | "unknown-rule-field"
673
+ | "unknown-frontmatter-field";
674
+
675
+ interface DesignValidateOutput {
676
+ ok: boolean;
677
+ exists: boolean;
678
+ filePath: string;
679
+ title?: string;
680
+ missingRequiredSections: Array<"goal" | "constraints" | "acceptanceCriteria" | "nonGoals">;
681
+ diagnostics: DesignContractDiagnostic[];
682
+ rules: Array<{
683
+ name: string;
684
+ type: "layer_direction" | "forbidden_imports" | "module_public_api_only";
685
+ severity: "error" | "warn";
686
+ }>;
687
+ sections: Array<{
688
+ id: DesignContractSectionId;
689
+ title: string;
690
+ line: number;
691
+ itemCount: number;
692
+ }>;
693
+ }
694
+
695
+ interface DesignContractDiagnostic {
696
+ code: DesignContractDiagnosticCode;
697
+ severity: "error" | "warning" | "info";
698
+ message: string;
699
+ section?: DesignContractSectionId;
700
+ heading?: string;
701
+ line?: number;
702
+ suggestion?: string;
703
+ }
704
+ ```
705
+
706
+ ### 示例
707
+
708
+ ```json
709
+ {
710
+ "ok": false,
711
+ "exists": true,
712
+ "filePath": "/repo/mycodemap.design.md",
713
+ "title": "Design Contract: Missing acceptance example",
714
+ "missingRequiredSections": [
715
+ "acceptanceCriteria"
716
+ ],
717
+ "rules": [],
718
+ "diagnostics": [
719
+ {
720
+ "code": "missing-section",
721
+ "severity": "error",
722
+ "message": "缺少必填 section: Acceptance Criteria",
723
+ "section": "acceptanceCriteria"
724
+ }
725
+ ],
726
+ "sections": [
727
+ {
728
+ "id": "goal",
729
+ "title": "Goal",
730
+ "line": 3,
731
+ "itemCount": 1
732
+ }
733
+ ]
734
+ }
735
+ ```
736
+
737
+ > `design validate --json` 必须保持纯 JSON;不要在前后拼接说明性 prose。
738
+
739
+ ---
740
+
741
+ ## check 命令输出结构
742
+
743
+ ### JSON 输出(默认)
744
+
745
+ ```typescript
746
+ interface ContractCheckResult {
747
+ passed: boolean;
748
+ scan_mode: "full" | "diff";
749
+ contract_path: string;
750
+ against_path: string;
751
+ changed_files: string[];
752
+ scanned_files: string[];
753
+ warnings: Array<{
754
+ code: string;
755
+ message: string;
756
+ details?: Record<string, string | number | boolean | null>;
757
+ }>;
758
+ history?: {
759
+ status: "ok" | "ambiguous" | "not_found" | "unavailable";
760
+ confidence: "high" | "medium" | "low" | "unavailable";
761
+ freshness: "fresh" | "stale" | "expired" | "unknown";
762
+ scope_mode: "full" | "partial" | "top-files-only" | "precompute-required";
763
+ enriched_file_count: number;
764
+ unavailable_count: number;
765
+ stale_count: number;
766
+ low_confidence_count: number;
767
+ requires_precompute: boolean;
768
+ };
769
+ violations: Array<{
770
+ rule: string;
771
+ rule_type: "layer_direction" | "forbidden_imports" | "module_public_api_only" | "complexity_threshold";
772
+ severity: "error" | "warn";
773
+ location: string;
774
+ message: string;
775
+ dependency_chain: string[];
776
+ hard_fail: boolean;
777
+ diagnostic?: {
778
+ file?: string;
779
+ line?: number;
780
+ column?: number;
781
+ endLine?: number;
782
+ endColumn?: number;
783
+ scope: "line" | "file" | "general";
784
+ source: "dependency-cruiser" | "custom-evaluator";
785
+ category: "dependency" | "module_boundary" | "complexity";
786
+ degraded: boolean;
787
+ };
788
+ risk?: {
789
+ status: "ok" | "ambiguous" | "not_found" | "unavailable";
790
+ level: "high" | "medium" | "low" | "unavailable";
791
+ confidence: "high" | "medium" | "low" | "unavailable";
792
+ freshness: "fresh" | "stale" | "expired" | "unknown";
793
+ score: number | null;
794
+ factors: string[];
795
+ analyzed_at: string | null;
796
+ };
797
+ }>;
798
+ summary: {
799
+ total_violations: number;
800
+ error_count: number;
801
+ warn_count: number;
802
+ scanned_file_count: number;
803
+ rule_count: number;
804
+ };
805
+ }
806
+ ```
807
+
808
+ ### 示例
809
+
810
+ ```json
811
+ {
812
+ "passed": false,
813
+ "scan_mode": "diff",
814
+ "contract_path": "/repo/mycodemap.design.md",
815
+ "against_path": "src",
816
+ "changed_files": ["src/domain/index.ts"],
817
+ "scanned_files": ["src/app/use-domain.ts", "src/domain/index.ts"],
818
+ "warnings": [
819
+ {
820
+ "code": "hard-gate-window-exceeded",
821
+ "message": "changed files=11 超出 calibrated hard-gate window <=10",
822
+ "details": {
823
+ "calibrated": false,
824
+ "changed_files": 11,
825
+ "max_changed_files": 10,
826
+ "recommended_mode": "warn-only"
827
+ }
828
+ }
829
+ ],
830
+ "history": {
831
+ "status": "ok",
832
+ "confidence": "high",
833
+ "freshness": "fresh",
834
+ "scope_mode": "full",
835
+ "enriched_file_count": 1,
836
+ "unavailable_count": 0,
837
+ "stale_count": 0,
838
+ "low_confidence_count": 0,
839
+ "requires_precompute": false
840
+ },
841
+ "violations": [
842
+ {
843
+ "rule": "app 不可依赖 domain barrel",
844
+ "rule_type": "layer_direction",
845
+ "severity": "error",
846
+ "location": "src/app/use-domain.ts",
847
+ "message": "src/app/use-domain.ts 依赖 src/domain/index.ts,违反规则 app 不可依赖 domain barrel",
848
+ "dependency_chain": ["src/app/use-domain.ts", "src/domain/index.ts"],
849
+ "hard_fail": true,
850
+ "diagnostic": {
851
+ "file": "src/app/use-domain.ts",
852
+ "line": 3,
853
+ "column": 1,
854
+ "scope": "line",
855
+ "source": "dependency-cruiser",
856
+ "category": "dependency",
857
+ "degraded": false
858
+ },
859
+ "risk": {
860
+ "status": "ok",
861
+ "level": "high",
862
+ "confidence": "high",
863
+ "freshness": "fresh",
864
+ "score": 0.88,
865
+ "factors": ["recent bugfixes", "high blast radius"],
866
+ "analyzed_at": "2026-04-15T00:00:00.000Z"
867
+ }
868
+ }
869
+ ],
870
+ "summary": {
871
+ "total_violations": 1,
872
+ "error_count": 1,
873
+ "warn_count": 0,
874
+ "scanned_file_count": 2,
875
+ "rule_count": 1
876
+ }
877
+ }
878
+ ```
879
+
880
+ > `check` 默认就是纯 JSON;`--human` 只改变渲染,不改变底层 `ContractCheckResult` truth。
881
+ > Git history risk 是 additive enrichment:它补充 `history` 与 `violations[].risk`,但不会改变 `severity:error` / exit 语义。history 不可用时应显式返回 `unavailable` / warning,而不是伪装成低风险。
882
+ > CI-native truth:PR 默认 hard gate 仅在 calibration 通过且 `changed files <= 10` 时启用;若出现 `diff-scope-fallback`、`hard-gate-window-exceeded` 或 `false-positive rate >10%`,CI 必须回退 `warn-only / fallback`。校准命令:`node scripts/calibrate-contract-gate.mjs --max-changed-files 10 --max-false-positive-rate 0.10`
883
+
884
+ ### Annotation-friendly diagnostics
885
+
886
+ ```typescript
887
+ interface ContractViolationDiagnostic {
888
+ file?: string;
889
+ line?: number;
890
+ column?: number;
891
+ endLine?: number;
892
+ endColumn?: number;
893
+ scope: "line" | "file" | "general";
894
+ source: "dependency-cruiser" | "custom-evaluator";
895
+ category: "dependency" | "module_boundary" | "complexity";
896
+ degraded: boolean;
897
+ }
898
+
899
+ type ContractGateRecommendation = "hard-gate-ok" | "warn-only" | "re-scope";
900
+
901
+ interface GitLabContractAnnotation {
902
+ description: string;
903
+ check_name: string;
904
+ fingerprint: string;
905
+ severity: "major" | "minor";
906
+ location: {
907
+ path: string;
908
+ lines: {
909
+ begin: number;
910
+ };
911
+ };
912
+ }
913
+ ```
914
+
915
+ - `--annotation-format github` 会直接输出 GitHub Actions annotations;允许 file-scoped degraded diagnostics,但不会伪造不存在的行号。
916
+ - `--annotation-format gitlab --annotation-file gl-code-quality-report.json` 会输出 GitLab Code Quality artifact;只包含 `scope="line"` 且有 `line` 的 diagnostics。
917
+ - `recommended_mode` 是 CI 编排 truth:当 calibration 失败、`changed files <= 10` 条件不满足或 false-positive 漂移时,workflow 必须走 `warn-only / fallback`。
918
+
919
+ ---
920
+
921
+ ## history 命令输出结构
922
+
923
+ ### JSON 输出(默认)
924
+
925
+ ```typescript
926
+ interface HistoryCommandResult {
927
+ query: string;
928
+ status: "ok" | "ambiguous" | "not_found" | "unavailable";
929
+ symbol: null | {
930
+ name: string;
931
+ kind: string;
932
+ file: string;
933
+ line: number;
934
+ };
935
+ candidates: Array<{
936
+ symbolId: string;
937
+ name: string;
938
+ file: string;
939
+ line: number;
940
+ }>;
941
+ files: string[];
942
+ warnings: string[];
943
+ risk: {
944
+ level: "high" | "medium" | "low" | "unavailable";
945
+ score: number | null;
946
+ riskFactors: string[];
947
+ };
948
+ }
949
+ ```
950
+
951
+ ### 失败语义
952
+
953
+ - `ok`: 找到唯一 symbol,并返回 timeline + risk
954
+ - `ambiguous`: 找到多个候选 symbol,不自动合并
955
+ - `not_found`: storage 中找不到 symbol
956
+ - `unavailable`: Git history 不可用或无持久化快照
957
+
958
+ ---
959
+
960
+ ## design map 命令输出结构
961
+
962
+ ### JSON 输出 (--json)
963
+
964
+ ```typescript
965
+ type DesignMappingCandidateKind = "file" | "module" | "symbol";
966
+
967
+ type DesignMappingDiagnosticCode =
968
+ | "no-candidates"
969
+ | "over-broad-scope"
970
+ | "high-risk-scope"
971
+ | string;
972
+
973
+ interface DesignMappingReason {
974
+ section: DesignContractSectionId;
975
+ matchedText: string;
976
+ evidenceType: string;
977
+ }
978
+
979
+ interface DesignMappingCandidate {
980
+ kind: DesignMappingCandidateKind;
981
+ path: string;
982
+ moduleName?: string;
983
+ symbolName?: string;
984
+ reasons: DesignMappingReason[];
985
+ dependencies: string[];
986
+ testImpact: string[];
987
+ risk: "high" | "medium" | "low";
988
+ confidence: {
989
+ score: number;
990
+ level: "high" | "medium" | "low";
991
+ };
992
+ unknowns: string[];
993
+ }
994
+
995
+ interface DesignMappingDiagnostic {
996
+ code: DesignMappingDiagnosticCode;
997
+ severity: "error" | "warning" | "info";
998
+ blocker: boolean;
999
+ message: string;
1000
+ candidatePaths?: string[];
1001
+ }
1002
+
1003
+ interface DesignMapOutput {
1004
+ ok: boolean;
1005
+ filePath: string;
1006
+ summary: {
1007
+ candidateCount: number;
1008
+ blocked: boolean;
1009
+ unknownCount: number;
1010
+ diagnosticCount: number;
1011
+ };
1012
+ candidates: DesignMappingCandidate[];
1013
+ diagnostics: DesignMappingDiagnostic[];
1014
+ }
1015
+ ```
1016
+
1017
+ ### 示例
1018
+
1019
+ ```json
1020
+ {
1021
+ "ok": false,
1022
+ "filePath": "/repo/mycodemap.design.md",
1023
+ "summary": {
1024
+ "candidateCount": 1,
1025
+ "blocked": true,
1026
+ "unknownCount": 0,
1027
+ "diagnosticCount": 1
1028
+ },
1029
+ "candidates": [
1030
+ {
1031
+ "kind": "file",
1032
+ "path": "src/cli/commands/analyze.ts",
1033
+ "reasons": [
1034
+ {
1035
+ "section": "goal",
1036
+ "matchedText": "src/cli/commands/analyze.ts",
1037
+ "evidenceType": "path-anchor"
1038
+ }
1039
+ ],
1040
+ "dependencies": [],
1041
+ "testImpact": [],
1042
+ "risk": "high",
1043
+ "confidence": {
1044
+ "score": 0.92,
1045
+ "level": "high"
1046
+ },
1047
+ "unknowns": []
1048
+ }
1049
+ ],
1050
+ "diagnostics": [
1051
+ {
1052
+ "code": "high-risk-scope",
1053
+ "severity": "error",
1054
+ "blocker": true,
1055
+ "message": "候选范围命中了高 blast-radius 文件;请先补充更具体的 design scope,再继续执行。"
1056
+ }
1057
+ ]
1058
+ }
1059
+ ```
1060
+
1061
+ > `design map --json` 必须保持纯 JSON;不要在前后拼接说明性 prose。`unknowns` 与 `diagnostics` 都属于正式契约,不是可选注释。
1062
+
1063
+ ---
1064
+
1065
+ ## design handoff 命令输出结构
1066
+
1067
+ ### JSON 输出 (--json)
1068
+
1069
+ ```typescript
1070
+ type DesignHandoffApprovalStatus = "approved" | "needs-review";
1071
+
1072
+ interface DesignHandoffTraceItem {
1073
+ id: string;
1074
+ text: string;
1075
+ sourceRefs: string[];
1076
+ }
1077
+
1078
+ interface DesignHandoffOutput {
1079
+ ok: boolean;
1080
+ filePath: string;
1081
+ outputDir: string;
1082
+ readyForExecution: boolean;
1083
+ artifacts: {
1084
+ markdownPath: string;
1085
+ jsonPath: string;
1086
+ };
1087
+ summary: {
1088
+ approvalCount: number;
1089
+ assumptionCount: number;
1090
+ openQuestionCount: number;
1091
+ requiresReview: boolean;
1092
+ };
1093
+ handoff: {
1094
+ touchedFiles: string[];
1095
+ constraints: string[];
1096
+ tests: string[];
1097
+ approvals: Array<DesignHandoffTraceItem & {
1098
+ status: DesignHandoffApprovalStatus;
1099
+ }>;
1100
+ assumptions: DesignHandoffTraceItem[];
1101
+ openQuestions: DesignHandoffTraceItem[];
1102
+ };
1103
+ diagnostics: Array<{
1104
+ code: "blocked-mapping" | "review-required" | string;
1105
+ blocker: boolean;
1106
+ message: string;
1107
+ }>;
1108
+ }
1109
+ ```
1110
+
1111
+ ### 示例
1112
+
1113
+ ```json
1114
+ {
1115
+ "ok": true,
1116
+ "filePath": "/repo/mycodemap.design.md",
1117
+ "outputDir": "/repo/.mycodemap/handoffs",
1118
+ "readyForExecution": false,
1119
+ "artifacts": {
1120
+ "markdownPath": "/repo/.mycodemap/handoffs/mycodemap.handoff.md",
1121
+ "jsonPath": "/repo/.mycodemap/handoffs/mycodemap.handoff.json"
1122
+ },
1123
+ "summary": {
1124
+ "approvalCount": 4,
1125
+ "assumptionCount": 1,
1126
+ "openQuestionCount": 1,
1127
+ "requiresReview": true
1128
+ },
1129
+ "handoff": {
1130
+ "touchedFiles": [
1131
+ "src/cli/design-handoff-builder.ts"
1132
+ ],
1133
+ "constraints": [
1134
+ "默认 artifact path 必须复用 src/cli/paths.ts"
1135
+ ],
1136
+ "tests": [
1137
+ "src/cli/__tests__/design-handoff-builder.test.ts"
1138
+ ],
1139
+ "approvals": [
1140
+ {
1141
+ "id": "approved-goal",
1142
+ "status": "approved",
1143
+ "text": "Goal 已被纳入 handoff 事实输入",
1144
+ "sourceRefs": ["design:goal"]
1145
+ }
1146
+ ],
1147
+ "assumptions": [
1148
+ {
1149
+ "id": "assumption-1-1",
1150
+ "text": "需要补充 reviewer 对未知范围的确认",
1151
+ "sourceRefs": ["candidate:src/cli/design-handoff-builder.ts"]
1152
+ }
1153
+ ],
1154
+ "openQuestions": [
1155
+ {
1156
+ "id": "open-question-1",
1157
+ "text": "低风险 assumptions 是否也必须显式批准?",
1158
+ "sourceRefs": ["design:openQuestions"]
1159
+ }
1160
+ ]
1161
+ },
1162
+ "diagnostics": [
1163
+ {
1164
+ "code": "review-required",
1165
+ "blocker": false,
1166
+ "message": "Handoff generated successfully but still requires human review before execution."
1167
+ }
1168
+ ]
1169
+ }
1170
+ ```
1171
+
1172
+ > `design handoff --json` 必须保持纯 JSON;`readyForExecution`、`approvals`、`assumptions`、`openQuestions` 都属于正式契约。human mode 默认写出 `.mycodemap/handoffs/{stem}.handoff.md|json`。
1173
+
1174
+ ---
1175
+
1176
+ ## design verify 命令输出结构
1177
+
1178
+ ### JSON 输出 (--json)
1179
+
1180
+ ```typescript
1181
+ type DesignVerificationStatus =
1182
+ | "satisfied"
1183
+ | "needs-review"
1184
+ | "violated"
1185
+ | "blocked";
1186
+
1187
+ type DesignDriftKind =
1188
+ | "scope-extra"
1189
+ | "acceptance-unverified"
1190
+ | "handoff-missing"
1191
+ | "blocked-input";
1192
+
1193
+ interface DesignVerificationOutput {
1194
+ ok: boolean;
1195
+ filePath: string;
1196
+ readyForExecution: boolean;
1197
+ summary: {
1198
+ checklistCount: number;
1199
+ satisfiedCount: number;
1200
+ needsReviewCount: number;
1201
+ violatedCount: number;
1202
+ blockedCount: number;
1203
+ driftCount: number;
1204
+ diagnosticCount: number;
1205
+ reviewRequired: boolean;
1206
+ blocked: boolean;
1207
+ };
1208
+ checklist: Array<{
1209
+ id: string;
1210
+ text: string;
1211
+ status: DesignVerificationStatus;
1212
+ evidenceRefs: string[];
1213
+ }>;
1214
+ drift: Array<{
1215
+ kind: DesignDriftKind;
1216
+ severity: "error" | "warning" | "info";
1217
+ message: string;
1218
+ sourceRefs: string[];
1219
+ }>;
1220
+ diagnostics: Array<{
1221
+ code: "handoff-missing" | "handoff-invalid" | "blocked-input" | string;
1222
+ blocker: boolean;
1223
+ message: string;
1224
+ sourceRefs: string[];
1225
+ }>;
1226
+ }
1227
+ ```
1228
+
1229
+ ### 示例
1230
+
1231
+ ```json
1232
+ {
1233
+ "ok": true,
1234
+ "filePath": "/repo/tests/fixtures/design-contracts/verify-ready.design.md",
1235
+ "readyForExecution": false,
1236
+ "summary": {
1237
+ "checklistCount": 3,
1238
+ "satisfiedCount": 1,
1239
+ "needsReviewCount": 2,
1240
+ "violatedCount": 0,
1241
+ "blockedCount": 0,
1242
+ "driftCount": 3,
1243
+ "diagnosticCount": 1,
1244
+ "reviewRequired": true,
1245
+ "blocked": false
1246
+ },
1247
+ "checklist": [
1248
+ {
1249
+ "id": "acceptance-1",
1250
+ "text": "src/cli/design-verification-builder.ts 会产出 conservative verification result",
1251
+ "status": "satisfied",
1252
+ "evidenceRefs": [
1253
+ "candidate:src/cli/design-verification-builder.ts",
1254
+ "diagnostic:handoff-missing"
1255
+ ]
1256
+ },
1257
+ {
1258
+ "id": "acceptance-2",
1259
+ "text": "src/interface/types/design-verification.ts 会定义正式 verification schema",
1260
+ "status": "needs-review",
1261
+ "evidenceRefs": [
1262
+ "design:acceptanceCriteria"
1263
+ ]
1264
+ }
1265
+ ],
1266
+ "drift": [
1267
+ {
1268
+ "kind": "handoff-missing",
1269
+ "severity": "warning",
1270
+ "message": "Canonical handoff artifact is missing, so verification remains review-needed even though a live handoff was rebuilt.",
1271
+ "sourceRefs": [
1272
+ "diagnostic:handoff-missing"
1273
+ ]
1274
+ }
1275
+ ],
1276
+ "diagnostics": [
1277
+ {
1278
+ "code": "handoff-missing",
1279
+ "blocker": false,
1280
+ "message": "Canonical handoff artifact is missing, so verification remains review-needed even though a live handoff was rebuilt.",
1281
+ "sourceRefs": [
1282
+ "diagnostic:handoff-missing"
1283
+ ]
1284
+ }
1285
+ ]
1286
+ }
1287
+ ```
1288
+
1289
+ > `design verify --json` 必须保持纯 JSON;`checklist` 与 `drift` 都属于正式契约。`readyForExecution=false` 不等于 blocker,只有 `ok=false` 或 blocker diagnostics 才应返回非零 exit code。
1290
+
1291
+ ---
1292
+
408
1293
  ## impact 命令输出结构
409
1294
 
410
1295
  ### JSON 输出 (-j)