@mycodemap/mycodemap 0.5.0 → 0.5.2-beta.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 (254) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +77 -9
  3. package/dist/cli/commands/analyze.d.ts +18 -0
  4. package/dist/cli/commands/analyze.d.ts.map +1 -1
  5. package/dist/cli/commands/analyze.js +239 -6
  6. package/dist/cli/commands/analyze.js.map +1 -1
  7. package/dist/cli/commands/check.d.ts +22 -0
  8. package/dist/cli/commands/check.d.ts.map +1 -0
  9. package/dist/cli/commands/check.js +168 -0
  10. package/dist/cli/commands/check.js.map +1 -0
  11. package/dist/cli/commands/ci.d.ts +25 -0
  12. package/dist/cli/commands/ci.d.ts.map +1 -1
  13. package/dist/cli/commands/ci.js +139 -36
  14. package/dist/cli/commands/ci.js.map +1 -1
  15. package/dist/cli/commands/complexity.d.ts.map +1 -1
  16. package/dist/cli/commands/complexity.js +6 -0
  17. package/dist/cli/commands/complexity.js.map +1 -1
  18. package/dist/cli/commands/design.d.ts +5 -0
  19. package/dist/cli/commands/design.d.ts.map +1 -1
  20. package/dist/cli/commands/design.js +6 -0
  21. package/dist/cli/commands/design.js.map +1 -1
  22. package/dist/cli/commands/generate.d.ts +1 -0
  23. package/dist/cli/commands/generate.d.ts.map +1 -1
  24. package/dist/cli/commands/generate.js +121 -8
  25. package/dist/cli/commands/generate.js.map +1 -1
  26. package/dist/cli/commands/history.d.ts +26 -0
  27. package/dist/cli/commands/history.d.ts.map +1 -0
  28. package/dist/cli/commands/history.js +92 -0
  29. package/dist/cli/commands/history.js.map +1 -0
  30. package/dist/cli/commands/mcp.d.ts +13 -0
  31. package/dist/cli/commands/mcp.d.ts.map +1 -0
  32. package/dist/cli/commands/mcp.js +108 -0
  33. package/dist/cli/commands/mcp.js.map +1 -0
  34. package/dist/cli/commands/workflow.d.ts.map +1 -1
  35. package/dist/cli/commands/workflow.js +22 -2
  36. package/dist/cli/commands/workflow.js.map +1 -1
  37. package/dist/cli/config-loader.d.ts.map +1 -1
  38. package/dist/cli/config-loader.js +3 -2
  39. package/dist/cli/config-loader.js.map +1 -1
  40. package/dist/cli/contract-checker.d.ts +33 -0
  41. package/dist/cli/contract-checker.d.ts.map +1 -0
  42. package/dist/cli/contract-checker.js +719 -0
  43. package/dist/cli/contract-checker.js.map +1 -0
  44. package/dist/cli/contract-diff-scope.d.ts +14 -0
  45. package/dist/cli/contract-diff-scope.d.ts.map +1 -0
  46. package/dist/cli/contract-diff-scope.js +127 -0
  47. package/dist/cli/contract-diff-scope.js.map +1 -0
  48. package/dist/cli/contract-gate-thresholds.d.ts +14 -0
  49. package/dist/cli/contract-gate-thresholds.d.ts.map +1 -0
  50. package/dist/cli/contract-gate-thresholds.js +19 -0
  51. package/dist/cli/contract-gate-thresholds.js.map +1 -0
  52. package/dist/cli/design-contract-loader.d.ts.map +1 -1
  53. package/dist/cli/design-contract-loader.js +355 -3
  54. package/dist/cli/design-contract-loader.js.map +1 -1
  55. package/dist/cli/design-scope-resolver.d.ts.map +1 -1
  56. package/dist/cli/design-scope-resolver.js +89 -41
  57. package/dist/cli/design-scope-resolver.js.map +1 -1
  58. package/dist/cli/index.js +18 -6
  59. package/dist/cli/index.js.map +1 -1
  60. package/dist/cli/paths.d.ts.map +1 -1
  61. package/dist/cli/paths.js +30 -7
  62. package/dist/cli/paths.js.map +1 -1
  63. package/dist/core/analyzer.d.ts.map +1 -1
  64. package/dist/core/analyzer.js +16 -0
  65. package/dist/core/analyzer.js.map +1 -1
  66. package/dist/domain/entities/CodeGraph.d.ts +5 -1
  67. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  68. package/dist/domain/entities/CodeGraph.js +29 -12
  69. package/dist/domain/entities/CodeGraph.js.map +1 -1
  70. package/dist/domain/entities/Dependency.d.ts +8 -1
  71. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  72. package/dist/domain/entities/Dependency.js +19 -4
  73. package/dist/domain/entities/Dependency.js.map +1 -1
  74. package/dist/domain/entities/Symbol.d.ts +2 -1
  75. package/dist/domain/entities/Symbol.d.ts.map +1 -1
  76. package/dist/domain/entities/Symbol.js +6 -3
  77. package/dist/domain/entities/Symbol.js.map +1 -1
  78. package/dist/infrastructure/storage/StorageFactory.d.ts +1 -0
  79. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  80. package/dist/infrastructure/storage/StorageFactory.js +7 -2
  81. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  82. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +3 -1
  83. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  84. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +10 -2
  85. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  86. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +3 -1
  87. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  88. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +9 -1
  89. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  90. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +3 -1
  91. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  92. package/dist/infrastructure/storage/adapters/MemoryStorage.js +9 -1
  93. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  94. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +53 -0
  95. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -0
  96. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +879 -0
  97. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -0
  98. package/dist/infrastructure/storage/graph-helpers.d.ts +3 -1
  99. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  100. package/dist/infrastructure/storage/graph-helpers.js +90 -0
  101. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  102. package/dist/infrastructure/storage/index.d.ts +1 -1
  103. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  104. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +3 -1
  105. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  106. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  107. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +27 -0
  108. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -0
  109. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +246 -0
  110. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -0
  111. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts +25 -0
  112. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts.map +1 -0
  113. package/dist/infrastructure/storage/sqlite/perf-thresholds.js +25 -0
  114. package/dist/infrastructure/storage/sqlite/perf-thresholds.js.map +1 -0
  115. package/dist/infrastructure/storage/sqlite/schema.d.ts +4 -0
  116. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
  117. package/dist/infrastructure/storage/sqlite/schema.js +111 -0
  118. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
  119. package/dist/interface/types/design-check.d.ts +73 -0
  120. package/dist/interface/types/design-check.d.ts.map +1 -0
  121. package/dist/interface/types/design-check.js +4 -0
  122. package/dist/interface/types/design-check.js.map +1 -0
  123. package/dist/interface/types/design-contract.d.ts +56 -1
  124. package/dist/interface/types/design-contract.d.ts.map +1 -1
  125. package/dist/interface/types/history-risk.d.ts +90 -0
  126. package/dist/interface/types/history-risk.d.ts.map +1 -0
  127. package/dist/interface/types/history-risk.js +4 -0
  128. package/dist/interface/types/history-risk.js.map +1 -0
  129. package/dist/interface/types/index.d.ts +17 -2
  130. package/dist/interface/types/index.d.ts.map +1 -1
  131. package/dist/interface/types/storage.d.ts +28 -1
  132. package/dist/interface/types/storage.d.ts.map +1 -1
  133. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +10 -0
  134. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -1
  135. package/dist/orchestrator/adapters/ast-grep-adapter.js +46 -17
  136. package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -1
  137. package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -1
  138. package/dist/orchestrator/adapters/codemap-adapter.js +2 -22
  139. package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -1
  140. package/dist/orchestrator/history-risk-service.d.ts +55 -0
  141. package/dist/orchestrator/history-risk-service.d.ts.map +1 -0
  142. package/dist/orchestrator/history-risk-service.js +680 -0
  143. package/dist/orchestrator/history-risk-service.js.map +1 -0
  144. package/dist/orchestrator/types.d.ts +19 -1
  145. package/dist/orchestrator/types.d.ts.map +1 -1
  146. package/dist/orchestrator/types.js +19 -0
  147. package/dist/orchestrator/types.js.map +1 -1
  148. package/dist/server/mcp/index.d.ts +4 -0
  149. package/dist/server/mcp/index.d.ts.map +1 -0
  150. package/dist/server/mcp/index.js +5 -0
  151. package/dist/server/mcp/index.js.map +1 -0
  152. package/dist/server/mcp/server.d.ts +17 -0
  153. package/dist/server/mcp/server.d.ts.map +1 -0
  154. package/dist/server/mcp/server.js +84 -0
  155. package/dist/server/mcp/server.js.map +1 -0
  156. package/dist/server/mcp/service.d.ts +22 -0
  157. package/dist/server/mcp/service.d.ts.map +1 -0
  158. package/dist/server/mcp/service.js +177 -0
  159. package/dist/server/mcp/service.js.map +1 -0
  160. package/dist/server/mcp/types.d.ts +56 -0
  161. package/dist/server/mcp/types.d.ts.map +1 -0
  162. package/dist/server/mcp/types.js +4 -0
  163. package/dist/server/mcp/types.js.map +1 -0
  164. package/docs/AI_ASSISTANT_SETUP.md +1 -1
  165. package/docs/PUBLISHING.md +41 -12
  166. package/docs/SETUP_GUIDE.md +6 -6
  167. package/docs/ai-guide/COMMANDS.md +98 -4
  168. package/docs/ai-guide/INTEGRATION.md +137 -433
  169. package/docs/ai-guide/OUTPUT.md +476 -6
  170. package/docs/ai-guide/PATTERNS.md +41 -11
  171. package/docs/ai-guide/PROMPTS.md +11 -6
  172. package/docs/backlog.md +177 -0
  173. package/docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md +231 -0
  174. package/docs/exec-plans/completed/2026-04-17-eatdogfood-codemap-cli.md +103 -0
  175. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +102 -0
  176. package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +47 -0
  177. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +11 -10
  178. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +10 -10
  179. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +17 -12
  180. package/docs/rules/README.md +16 -11
  181. package/docs/rules/architecture-guardrails.md +24 -336
  182. package/docs/rules/code-quality-redlines.md +25 -311
  183. package/docs/rules/engineering-with-codex-openai.md +14 -1
  184. package/docs/rules/pre-release-checklist.md +9 -4
  185. package/docs/rules/validation.md +91 -40
  186. package/mycodemap.config.schema.json +3 -3
  187. package/package.json +7 -2
  188. package/scripts/benchmark-governance-graph.mjs +132 -0
  189. package/scripts/calibrate-contract-gate.mjs +221 -0
  190. package/scripts/capability-report.py +255 -0
  191. package/scripts/pre-release-check.js +2 -2
  192. package/scripts/qa-rule-control.sh +254 -0
  193. package/scripts/report-high-risk-files.mjs +395 -0
  194. package/scripts/rule-context.mjs +155 -0
  195. package/scripts/smoke-sqlite-impact.mjs +85 -0
  196. package/scripts/sync-analyze-docs.js +1 -0
  197. package/scripts/tests/test_capability_report.py +89 -0
  198. package/scripts/tests/test_rule_control_workflow.py +51 -0
  199. package/scripts/tests/test_validate_rules.py +81 -0
  200. package/scripts/validate-ai-docs.js +283 -1
  201. package/scripts/validate-docs.js +249 -42
  202. package/scripts/validate-rules.py +254 -0
  203. package/dist/ai/claude.d.ts +0 -38
  204. package/dist/ai/claude.d.ts.map +0 -1
  205. package/dist/ai/claude.js +0 -169
  206. package/dist/ai/claude.js.map +0 -1
  207. package/dist/ai/codex.d.ts +0 -38
  208. package/dist/ai/codex.d.ts.map +0 -1
  209. package/dist/ai/codex.js +0 -169
  210. package/dist/ai/codex.js.map +0 -1
  211. package/dist/ai/factory.d.ts +0 -48
  212. package/dist/ai/factory.d.ts.map +0 -1
  213. package/dist/ai/factory.js +0 -95
  214. package/dist/ai/factory.js.map +0 -1
  215. package/dist/ai/index.d.ts +0 -12
  216. package/dist/ai/index.d.ts.map +0 -1
  217. package/dist/ai/index.js +0 -29
  218. package/dist/ai/index.js.map +0 -1
  219. package/dist/ai/provider.d.ts +0 -70
  220. package/dist/ai/provider.d.ts.map +0 -1
  221. package/dist/ai/provider.js +0 -31
  222. package/dist/ai/provider.js.map +0 -1
  223. package/dist/ai/subagent-caller.d.ts +0 -90
  224. package/dist/ai/subagent-caller.d.ts.map +0 -1
  225. package/dist/ai/subagent-caller.js +0 -280
  226. package/dist/ai/subagent-caller.js.map +0 -1
  227. package/dist/ai/types.d.ts +0 -70
  228. package/dist/ai/types.d.ts.map +0 -1
  229. package/dist/ai/types.js +0 -5
  230. package/dist/ai/types.js.map +0 -1
  231. package/dist/cli/commands/server.d.ts +0 -9
  232. package/dist/cli/commands/server.d.ts.map +0 -1
  233. package/dist/cli/commands/server.js +0 -65
  234. package/dist/cli/commands/server.js.map +0 -1
  235. package/dist/cli-new/commands/server.d.ts +0 -13
  236. package/dist/cli-new/commands/server.d.ts.map +0 -1
  237. package/dist/cli-new/commands/server.js +0 -90
  238. package/dist/cli-new/commands/server.js.map +0 -1
  239. package/dist/generator/ai-overview.d.ts +0 -51
  240. package/dist/generator/ai-overview.d.ts.map +0 -1
  241. package/dist/generator/ai-overview.js +0 -160
  242. package/dist/generator/ai-overview.js.map +0 -1
  243. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +0 -41
  244. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +0 -1
  245. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +0 -162
  246. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +0 -1
  247. package/dist/orchestrator/ai-feed-generator.d.ts +0 -210
  248. package/dist/orchestrator/ai-feed-generator.d.ts.map +0 -1
  249. package/dist/orchestrator/ai-feed-generator.js +0 -377
  250. package/dist/orchestrator/ai-feed-generator.js.map +0 -1
  251. package/docs/archive/test-report-symbol-search.md +0 -384
  252. package/docs/archive/test-scenario-4-complexity-analysis.md +0 -460
  253. package/docs/archive/test_report_scenario5.md +0 -615
  254. package/docs/archive/test_scenario_3_impact_analysis_report.md +0 -520
@@ -23,13 +23,12 @@ codemap ship / release.sh → 创建版本提交 → 推送 tag → GitHub Actio
23
23
  - **Workflow Name**: `publish.yml`
24
24
  - **GitHub Environment**: (留空)
25
25
 
26
- 2. **确保没有设置 NPM_TOKEN**
26
+ 2. **默认使用 OIDC;需要时可保留 NPM_TOKEN fallback**
27
27
  ```bash
28
28
  # 检查是否设置了 NPM_TOKEN
29
29
  gh secret list | grep NPM_TOKEN
30
30
 
31
- # 如果存在,删除它
32
- gh secret remove NPM_TOKEN
31
+ # 默认推荐留空;如果需要 fallback,确保它是 Automation token
33
32
  ```
34
33
 
35
34
  3. **验证权限配置**
@@ -63,6 +62,8 @@ codemap ship --yes
63
62
 
64
63
  `codemap ship` **不会在本地执行 `npm publish`**;它会创建版本提交、推送 tag,然后由 `.github/workflows/publish.yml` 完成真正的 OIDC 发布。
65
64
 
65
+ 预发布版本(如 `0.5.2-beta.1`)会自动从版本号推导 npm dist-tag(如 `beta`);稳定版本默认发布到 `latest`。
66
+
66
67
  ### 方法 1: 使用发布脚本
67
68
 
68
69
  ```bash
@@ -200,17 +201,28 @@ jobs:
200
201
 
201
202
  steps:
202
203
  - name: Checkout code
203
- uses: actions/checkout@v4
204
+ uses: actions/checkout@v6
204
205
  with:
205
206
  fetch-depth: 0 # 获取完整历史用于生成 changelog
206
207
 
207
208
  - name: Setup Node.js
208
- uses: actions/setup-node@v4
209
+ uses: actions/setup-node@v6
209
210
  with:
210
- node-version: '20'
211
+ node-version: '24'
211
212
  cache: 'npm'
212
213
  registry-url: 'https://registry.npmjs.org'
213
214
 
215
+ - name: Determine npm dist-tag
216
+ id: npm-tag
217
+ run: |
218
+ VERSION="${{ steps.package-version.outputs.version }}"
219
+ DIST_TAG="latest"
220
+ if [[ "$VERSION" == *-* ]]; then
221
+ DIST_TAG="${VERSION#*-}"
222
+ DIST_TAG="${DIST_TAG%%.*}"
223
+ fi
224
+ echo "dist-tag=$DIST_TAG" >> $GITHUB_OUTPUT
225
+
214
226
  - name: Get version from package.json
215
227
  id: package-version
216
228
  run: |
@@ -259,10 +271,18 @@ jobs:
259
271
  - name: Validate package contents
260
272
  run: npm run validate-pack
261
273
 
262
- # 使用 OIDC Trusted Publishing 发布
263
- # OIDC 通过 id-token: write 权限自动获取认证,不需要 NPM_TOKEN
274
+ # 使用 OIDC Trusted Publishing 或 NPM_TOKEN fallback 发布
264
275
  - name: Publish to NPM
265
- run: npm publish --access public --provenance
276
+ env:
277
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
278
+ run: |
279
+ DIST_TAG="${{ steps.npm-tag.outputs.dist-tag }}"
280
+ if [ -n "$NPM_TOKEN" ]; then
281
+ export NODE_AUTH_TOKEN="$NPM_TOKEN"
282
+ npx npm@11.5.1 publish --access public --tag "$DIST_TAG" --provenance --registry https://registry.npmjs.org
283
+ else
284
+ npx npm@11.5.1 publish --access public --tag "$DIST_TAG" --registry https://registry.npmjs.org
285
+ fi
266
286
 
267
287
  - name: Generate Release Notes
268
288
  if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
@@ -350,13 +370,13 @@ npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@mycodemap%2fmycodem
350
370
  **原因**:
351
371
  1. NPM 端未正确配置 Trusted Publisher
352
372
  2. `id-token: write` 权限未设置
353
- 3. 设置了 `NODE_AUTH_TOKEN` 环境变量干扰了 OIDC
373
+ 3. workflow 没有为 prerelease 显式传 `--tag`(例如 `0.5.2-beta.1` 需要 `--tag beta`)
354
374
 
355
375
  **解决**:
356
376
  1. 检查 NPM 配置: https://www.npmjs.com/package/@mycodemap/mycodemap/access
357
377
  2. 确保 workflow 中有 `id-token: write` 权限
358
- 3. 确保没有设置 `NODE_AUTH_TOKEN` 环境变量
359
- 4. 确保没有设置 `NPM_TOKEN` secret
378
+ 3. 确保没有设置错误的 `NODE_AUTH_TOKEN` 环境变量
379
+ 4. 如果配置了 `NPM_TOKEN`,确保它是 Automation token
360
380
 
361
381
  ### 发布失败: "ENEEDAUTH"
362
382
 
@@ -393,6 +413,15 @@ npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@mycodemap%2fmycodem
393
413
  1. 检查 package.json 中的版本号
394
414
  2. npm 版本号不可重复,需要递增
395
415
 
416
+ ### 发布失败: "You must specify a tag using --tag"
417
+
418
+ **原因**: 发布的是 prerelease 版本,但 `npm publish` 没有显式传 dist-tag
419
+
420
+ **解决**:
421
+ 1. 确认 workflow 会从版本号推导 dist-tag
422
+ 2. `0.5.2-beta.1` 应发布到 `beta`
423
+ 3. `0.5.2-rc.1` 应发布到 `rc`
424
+
396
425
  ### GitHub Actions 未触发
397
426
 
398
427
  **原因**: tag 格式不正确或 workflow 配置错误
@@ -135,9 +135,9 @@ mycodemap init -y
135
135
  | `exclude` | string[] | 见上 | 排除的文件 glob 模式 |
136
136
  | `output` | string | `".mycodemap"` | 输出目录路径 |
137
137
  | `watch` | boolean | `false` | 监听模式预留配置 |
138
- | `storage.type` | string | `"filesystem"` | 图存储后端类型:`filesystem` / `kuzudb` / `memory` / `auto` |
138
+ | `storage.type` | string | `"filesystem"` | 图存储后端类型:`filesystem` / `sqlite` / `memory` / `auto` |
139
139
  | `storage.outputPath` | string | `".codemap/storage"` | 文件系统存储目录 |
140
- | `storage.databasePath` | string | - | KùzuDB 数据目录(相对项目根目录) |
140
+ | `storage.databasePath` | string | `".codemap/governance.sqlite"` | SQLite 数据库文件路径(相对项目根目录) |
141
141
  | `plugins.builtInPlugins` | boolean | `true` | 是否启用内置插件 |
142
142
  | `plugins.pluginDir` | string | - | 额外插件目录 |
143
143
  | `plugins.plugins` | string[] | `[]` | 显式加载的插件名称列表 |
@@ -146,10 +146,10 @@ mycodemap init -y
146
146
  ### 图存储后端配置
147
147
 
148
148
  - `generate` 会把 CodeGraph 写入 `storage` 指定的后端;`export json|graphml|dot` 会从同一后端读取。
149
- - 选择 `kuzudb` 前先安装 `npm install kuzu`。
150
- - 旧的 `neo4j` 配置已不再受支持,会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
151
- - 缺少依赖时会返回显式错误,不会静默 fallback `filesystem`。
152
- - `storage.type = "auto"` 当前仍保守使用 `filesystem`,阈值字段先作为配置契约保留。
149
+ - 选择 `sqlite` 时默认落盘到 `.codemap/governance.sqlite`;也可通过 `storage.databasePath` 覆盖。
150
+ - 旧的 `neo4j` / `kuzudb` 配置已不再受支持,会返回显式迁移错误,不会静默 fallback 到 `filesystem`。
151
+ - 显式选择 `sqlite` 且运行时缺少 `better-sqlite3` 或 Node.js `<20` 时,会返回显式错误。
152
+ - `storage.type = "auto"` 当前优先选择 `sqlite`;仅当 SQLite 运行时不可用时才 warning 后回退到 `filesystem`。
153
153
 
154
154
  ---
155
155
 
@@ -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 - 阅读文件(影响 + 复杂度)
@@ -287,6 +320,45 @@ mycodemap design verify mycodemap.design.md --json
287
320
 
288
321
  ---
289
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
+
290
362
  ## ci - CI 门禁
291
363
 
292
364
  ### 子命令
@@ -312,10 +384,11 @@ mycodemap ci check-headers
312
384
  mycodemap ci check-headers -d "src/domain" # 指定目录
313
385
  mycodemap ci check-headers -f "file1.ts,file2.ts"
314
386
 
315
- # 评估变更风险
387
+ # 评估变更风险(与 `check` / `history` 共用同一套 Git history risk truth)
316
388
  mycodemap ci assess-risk
317
389
  mycodemap ci assess-risk -t 0.5 # 设置阈值 0.5
318
390
  mycodemap ci assess-risk -f "changed.ts"
391
+ mycodemap ci assess-risk --files "changed.ts" --json
319
392
 
320
393
  # 验证文档同步
321
394
  mycodemap ci check-docs-sync
@@ -334,6 +407,24 @@ mycodemap ci check-commit-size -m 15
334
407
 
335
408
  > `ship` 的 CHECK 阶段会复用 `ci check-working-tree`、`ci check-branch`、`ci check-scripts` 这三条发布前 gate checks。
336
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`
337
428
 
338
429
  ### 支持的提交 TAG
339
430
 
@@ -360,6 +451,7 @@ mycodemap ci check-commit-size -m 15
360
451
  # 启动工作流
361
452
  mycodemap workflow start "实现用户认证模块"
362
453
  mycodemap workflow start "修复登录接口" --template bugfix
454
+ mycodemap workflow start "inspect analyze find" --json
363
455
 
364
456
  # 查看状态
365
457
  mycodemap workflow status
@@ -385,6 +477,8 @@ mycodemap workflow resume
385
477
  mycodemap workflow resume "workflow-id"
386
478
  ```
387
479
 
480
+ > `workflow start --json` 输出 `{ status, task, id, currentPhase, template, nextSteps }`,不改变 workflow 的 analysis-only 边界。
481
+
388
482
  ### 模板管理
389
483
 
390
484
  ```bash