@mycodemap/mycodemap 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/CHANGELOG.md +164 -6
  2. package/README.md +407 -141
  3. package/dist/cli/commands/ci.d.ts +7 -1
  4. package/dist/cli/commands/ci.d.ts.map +1 -1
  5. package/dist/cli/commands/ci.js +38 -0
  6. package/dist/cli/commands/ci.js.map +1 -1
  7. package/dist/cli/commands/cycles.d.ts.map +1 -1
  8. package/dist/cli/commands/cycles.js +2 -0
  9. package/dist/cli/commands/cycles.js.map +1 -1
  10. package/dist/cli/commands/export.d.ts +6 -0
  11. package/dist/cli/commands/export.d.ts.map +1 -0
  12. package/dist/cli/commands/export.js +108 -0
  13. package/dist/cli/commands/export.js.map +1 -0
  14. package/dist/cli/commands/generate.d.ts.map +1 -1
  15. package/dist/cli/commands/generate.js +96 -0
  16. package/dist/cli/commands/generate.js.map +1 -1
  17. package/dist/cli/commands/init.d.ts.map +1 -1
  18. package/dist/cli/commands/init.js +3 -1
  19. package/dist/cli/commands/init.js.map +1 -1
  20. package/dist/cli/commands/logs.d.ts +5 -0
  21. package/dist/cli/commands/logs.d.ts.map +1 -0
  22. package/dist/cli/commands/logs.js +189 -0
  23. package/dist/cli/commands/logs.js.map +1 -0
  24. package/dist/cli/commands/report.d.ts +12 -0
  25. package/dist/cli/commands/report.d.ts.map +1 -0
  26. package/dist/cli/commands/report.js +158 -0
  27. package/dist/cli/commands/report.js.map +1 -0
  28. package/dist/cli/commands/server.d.ts +9 -0
  29. package/dist/cli/commands/server.d.ts.map +1 -0
  30. package/dist/cli/commands/server.js +68 -0
  31. package/dist/cli/commands/server.js.map +1 -0
  32. package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
  33. package/dist/cli/commands/watch-foreground.js +2 -0
  34. package/dist/cli/commands/watch-foreground.js.map +1 -1
  35. package/dist/cli/commands/watch.d.ts.map +1 -1
  36. package/dist/cli/commands/watch.js +2 -0
  37. package/dist/cli/commands/watch.js.map +1 -1
  38. package/dist/cli/first-run-guide.d.ts +23 -0
  39. package/dist/cli/first-run-guide.d.ts.map +1 -0
  40. package/dist/cli/first-run-guide.js +83 -0
  41. package/dist/cli/first-run-guide.js.map +1 -0
  42. package/dist/cli/index.js +85 -1
  43. package/dist/cli/index.js.map +1 -1
  44. package/dist/cli/platform-check.d.ts +21 -0
  45. package/dist/cli/platform-check.d.ts.map +1 -0
  46. package/dist/cli/platform-check.js +94 -0
  47. package/dist/cli/platform-check.js.map +1 -0
  48. package/dist/cli/tree-sitter-check.d.ts +35 -0
  49. package/dist/cli/tree-sitter-check.d.ts.map +1 -0
  50. package/dist/cli/tree-sitter-check.js +133 -0
  51. package/dist/cli/tree-sitter-check.js.map +1 -0
  52. package/dist/cli/utils/sanitize.d.ts +54 -0
  53. package/dist/cli/utils/sanitize.d.ts.map +1 -0
  54. package/dist/cli/utils/sanitize.js +131 -0
  55. package/dist/cli/utils/sanitize.js.map +1 -0
  56. package/dist/cli-new/commands/export.d.ts +15 -0
  57. package/dist/cli-new/commands/export.d.ts.map +1 -0
  58. package/dist/cli-new/commands/export.js +107 -0
  59. package/dist/cli-new/commands/export.js.map +1 -0
  60. package/dist/cli-new/commands/query.d.ts +14 -0
  61. package/dist/cli-new/commands/query.d.ts.map +1 -0
  62. package/dist/cli-new/commands/query.js +120 -0
  63. package/dist/cli-new/commands/query.js.map +1 -0
  64. package/dist/cli-new/commands/server.d.ts +13 -0
  65. package/dist/cli-new/commands/server.d.ts.map +1 -0
  66. package/dist/cli-new/commands/server.js +94 -0
  67. package/dist/cli-new/commands/server.js.map +1 -0
  68. package/dist/cli-new/index.d.ts +11 -0
  69. package/dist/cli-new/index.d.ts.map +1 -0
  70. package/dist/cli-new/index.js +63 -0
  71. package/dist/cli-new/index.js.map +1 -0
  72. package/dist/cli-new/types/index.d.ts +88 -0
  73. package/dist/cli-new/types/index.d.ts.map +1 -0
  74. package/dist/cli-new/types/index.js +7 -0
  75. package/dist/cli-new/types/index.js.map +1 -0
  76. package/dist/domain/entities/CodeGraph.d.ts +134 -0
  77. package/dist/domain/entities/CodeGraph.d.ts.map +1 -0
  78. package/dist/domain/entities/CodeGraph.js +316 -0
  79. package/dist/domain/entities/CodeGraph.js.map +1 -0
  80. package/dist/domain/entities/Dependency.d.ts +78 -0
  81. package/dist/domain/entities/Dependency.d.ts.map +1 -0
  82. package/dist/domain/entities/Dependency.js +132 -0
  83. package/dist/domain/entities/Dependency.js.map +1 -0
  84. package/dist/domain/entities/Module.d.ts +75 -0
  85. package/dist/domain/entities/Module.d.ts.map +1 -0
  86. package/dist/domain/entities/Module.js +151 -0
  87. package/dist/domain/entities/Module.js.map +1 -0
  88. package/dist/domain/entities/Project.d.ts +50 -0
  89. package/dist/domain/entities/Project.d.ts.map +1 -0
  90. package/dist/domain/entities/Project.js +99 -0
  91. package/dist/domain/entities/Project.js.map +1 -0
  92. package/dist/domain/entities/Symbol.d.ts +75 -0
  93. package/dist/domain/entities/Symbol.d.ts.map +1 -0
  94. package/dist/domain/entities/Symbol.js +130 -0
  95. package/dist/domain/entities/Symbol.js.map +1 -0
  96. package/dist/domain/events/DomainEvent.d.ts +76 -0
  97. package/dist/domain/events/DomainEvent.d.ts.map +1 -0
  98. package/dist/domain/events/DomainEvent.js +153 -0
  99. package/dist/domain/events/DomainEvent.js.map +1 -0
  100. package/dist/domain/index.d.ts +10 -0
  101. package/dist/domain/index.d.ts.map +1 -0
  102. package/dist/domain/index.js +18 -0
  103. package/dist/domain/index.js.map +1 -0
  104. package/dist/domain/repositories/CodeGraphRepository.d.ts +58 -0
  105. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -0
  106. package/dist/domain/repositories/CodeGraphRepository.js +37 -0
  107. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -0
  108. package/dist/domain/services/CodeGraphBuilder.d.ts +50 -0
  109. package/dist/domain/services/CodeGraphBuilder.d.ts.map +1 -0
  110. package/dist/domain/services/CodeGraphBuilder.js +121 -0
  111. package/dist/domain/services/CodeGraphBuilder.js.map +1 -0
  112. package/dist/infrastructure/parser/implementations/GoParser.d.ts +25 -0
  113. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -0
  114. package/dist/infrastructure/parser/implementations/GoParser.js +158 -0
  115. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -0
  116. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +30 -0
  117. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -0
  118. package/dist/infrastructure/parser/implementations/PythonParser.js +201 -0
  119. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -0
  120. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +63 -0
  121. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -0
  122. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +420 -0
  123. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -0
  124. package/dist/infrastructure/parser/index.d.ts +13 -0
  125. package/dist/infrastructure/parser/index.d.ts.map +1 -0
  126. package/dist/infrastructure/parser/index.js +32 -0
  127. package/dist/infrastructure/parser/index.js.map +1 -0
  128. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts +124 -0
  129. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -0
  130. package/dist/infrastructure/parser/interfaces/ParserBase.js +200 -0
  131. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -0
  132. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts +68 -0
  133. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts.map +1 -0
  134. package/dist/infrastructure/parser/registry/ParserRegistry.js +116 -0
  135. package/dist/infrastructure/parser/registry/ParserRegistry.js.map +1 -0
  136. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +44 -0
  137. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -0
  138. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +129 -0
  139. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -0
  140. package/dist/infrastructure/repositories/index.d.ts +3 -0
  141. package/dist/infrastructure/repositories/index.d.ts.map +1 -0
  142. package/dist/infrastructure/repositories/index.js +7 -0
  143. package/dist/infrastructure/repositories/index.js.map +1 -0
  144. package/dist/infrastructure/storage/StorageFactory.d.ts +53 -0
  145. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -0
  146. package/dist/infrastructure/storage/StorageFactory.js +150 -0
  147. package/dist/infrastructure/storage/StorageFactory.js.map +1 -0
  148. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +52 -0
  149. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -0
  150. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +315 -0
  151. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -0
  152. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +52 -0
  153. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -0
  154. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +235 -0
  155. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -0
  156. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +37 -0
  157. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -0
  158. package/dist/infrastructure/storage/adapters/MemoryStorage.js +229 -0
  159. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -0
  160. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +49 -0
  161. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
  162. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +222 -0
  163. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
  164. package/dist/infrastructure/storage/index.d.ts +6 -0
  165. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  166. package/dist/infrastructure/storage/index.js +13 -0
  167. package/dist/infrastructure/storage/index.js.map +1 -0
  168. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +76 -0
  169. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -0
  170. package/dist/infrastructure/storage/interfaces/StorageBase.js +116 -0
  171. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -0
  172. package/dist/interface/config/index.d.ts +102 -0
  173. package/dist/interface/config/index.d.ts.map +1 -0
  174. package/dist/interface/config/index.js +7 -0
  175. package/dist/interface/config/index.js.map +1 -0
  176. package/dist/interface/types/index.d.ts +425 -0
  177. package/dist/interface/types/index.d.ts.map +1 -0
  178. package/dist/interface/types/index.js +8 -0
  179. package/dist/interface/types/index.js.map +1 -0
  180. package/dist/interface/types/parser.d.ts +103 -0
  181. package/dist/interface/types/parser.d.ts.map +1 -0
  182. package/dist/interface/types/parser.js +7 -0
  183. package/dist/interface/types/parser.js.map +1 -0
  184. package/dist/interface/types/storage.d.ts +98 -0
  185. package/dist/interface/types/storage.d.ts.map +1 -0
  186. package/dist/interface/types/storage.js +7 -0
  187. package/dist/interface/types/storage.js.map +1 -0
  188. package/dist/orchestrator/test-linker.js +1 -1
  189. package/dist/orchestrator/test-linker.js.map +1 -1
  190. package/dist/server/CodeMapServer.d.ts +51 -0
  191. package/dist/server/CodeMapServer.d.ts.map +1 -0
  192. package/dist/server/CodeMapServer.js +146 -0
  193. package/dist/server/CodeMapServer.js.map +1 -0
  194. package/dist/server/handlers/AnalysisHandler.d.ts +82 -0
  195. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -0
  196. package/dist/server/handlers/AnalysisHandler.js +196 -0
  197. package/dist/server/handlers/AnalysisHandler.js.map +1 -0
  198. package/dist/server/handlers/QueryHandler.d.ts +57 -0
  199. package/dist/server/handlers/QueryHandler.d.ts.map +1 -0
  200. package/dist/server/handlers/QueryHandler.js +260 -0
  201. package/dist/server/handlers/QueryHandler.js.map +1 -0
  202. package/dist/server/index.d.ts +7 -0
  203. package/dist/server/index.d.ts.map +1 -0
  204. package/dist/server/index.js +13 -0
  205. package/dist/server/index.js.map +1 -0
  206. package/dist/server/routes/api.d.ts +8 -0
  207. package/dist/server/routes/api.d.ts.map +1 -0
  208. package/dist/server/routes/api.js +372 -0
  209. package/dist/server/routes/api.js.map +1 -0
  210. package/dist/server/types/index.d.ts +171 -0
  211. package/dist/server/types/index.d.ts.map +1 -0
  212. package/dist/server/types/index.js +7 -0
  213. package/dist/server/types/index.js.map +1 -0
  214. package/dist/types/index.d.ts +6 -372
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/types/index.js +9 -3
  217. package/dist/types/index.js.map +1 -1
  218. package/docs/AI_ASSISTANT_SETUP.md +811 -0
  219. package/docs/PUBLISHING.md +162 -0
  220. package/docs/README.md +37 -0
  221. package/docs/SETUP_GUIDE.md +493 -0
  222. package/docs/ai-guide/COMMANDS.md +369 -0
  223. package/docs/ai-guide/INTEGRATION.md +513 -0
  224. package/docs/ai-guide/OUTPUT.md +465 -0
  225. package/docs/ai-guide/PATTERNS.md +409 -0
  226. package/docs/ai-guide/PROMPTS.md +414 -0
  227. package/docs/ai-guide/QUICKSTART.md +114 -0
  228. package/docs/ai-guide/README.md +66 -0
  229. package/docs/archive/AI_INTEGRATION_GUIDE_ARCHIVED.md +391 -0
  230. package/docs/archive/ARCHIVE.md +39 -0
  231. package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
  232. package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +1699 -0
  233. package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +396 -0
  234. package/docs/archive/README.md +29 -0
  235. package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +320 -0
  236. package/docs/archive/TEST_SUMMARY.md +140 -0
  237. package/docs/archive/comprehensive_test_report.md +337 -0
  238. package/docs/archive/design-docs/CI_GATEWAY_DESIGN.md +790 -0
  239. package/docs/archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md +491 -0
  240. package/docs/archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md +558 -0
  241. package/docs/archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md +250 -0
  242. package/docs/archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md +791 -0
  243. package/docs/archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md +1071 -0
  244. package/docs/archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md +321 -0
  245. package/docs/archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md +317 -0
  246. package/docs/archive/myclaude.md +1084 -0
  247. package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
  248. package/docs/archive/product-specs/REFACTOR_REQUIREMENTS.md +976 -0
  249. package/docs/archive/scenario-2-deps-analysis.md +353 -0
  250. package/docs/archive/test-report-symbol-search.md +384 -0
  251. package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
  252. package/docs/archive/test_report_scenario5.md +615 -0
  253. package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
  254. package/docs/design-docs/README.md +26 -0
  255. package/docs/exec-plans/MVP3-IMPLEMENTATION-ROADMAP.md +524 -0
  256. package/docs/exec-plans/README.md +29 -0
  257. package/docs/exec-plans/active/.gitkeep +0 -0
  258. package/docs/exec-plans/completed/.gitkeep +0 -0
  259. package/docs/exec-plans/completed/2026-03-03-deps-path-extension-fix.md +186 -0
  260. package/docs/exec-plans/completed/2026-03-03-post-task-plan.md +135 -0
  261. package/docs/exec-plans/completed/harness-engineering-rollout.md +184 -0
  262. package/docs/exec-plans/tech-debt/.gitkeep +0 -0
  263. package/docs/exec-plans/tech-debt/2026-03-15-lint-guardrail-gap.md +30 -0
  264. package/docs/generated/README.md +19 -0
  265. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +504 -0
  266. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +322 -0
  267. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +1374 -0
  268. package/docs/product-specs/README.md +22 -0
  269. package/docs/references/README.md +15 -0
  270. package/docs/references/tmp.md +527 -0
  271. package/docs/rules/README.md +16 -0
  272. package/docs/rules/architecture-guardrails.md +349 -0
  273. package/docs/rules/code-quality-redlines.md +321 -0
  274. package/docs/rules/deployment.md +23 -0
  275. package/docs/rules/engineering-with-codex-openai.md +202 -0
  276. package/docs/rules/testing.md +73 -0
  277. package/docs/rules/validation.md +39 -0
  278. package/examples/README.md +61 -0
  279. package/examples/claude/codemap-skill.md +94 -0
  280. package/examples/codex/codemap-agent.md +66 -0
  281. package/examples/copilot/copilot-instructions.md +24 -0
  282. package/examples/kimi/codemap-skill.md +92 -0
  283. package/package.json +22 -7
@@ -0,0 +1,202 @@
1
+ # 基于 Codex 的工程落地规则
2
+
3
+ > 目标:把 OpenAI《Engineering with Codex》里的高信号原则,转成当前 CodeMap 仓库可执行的开发与交付规则。
4
+ > 适用范围:本仓库内使用 Codex / Claude / 其他 agent 进行分析、修改、验证、提交流程。
5
+
6
+ ## 1. 先说边界
7
+
8
+ - 本项目当前主要交付形态是 npm 包与 CLI,不是长期运行的 Web 服务。
9
+ - 因此这里强调的是 `CLI` / `CI` 护栏,而不是 preview 环境或部署沙箱。
10
+ - 涉及长期稳定知识时,优先写入仓库文档与生成物;不要把关键约束留在聊天记录、口头约定或临时笔记里。
11
+
12
+ ## 2. 核心原则
13
+
14
+ - 人类掌舵,agent 执行:人类负责定义目标、限制、DoD、依赖和验收;agent 负责检索、实现、验证和补文档。
15
+ - 地图优于手册:入口文档保持短小,只做路由;细节下沉到 `ARCHITECTURE.md`、`docs/rules/`、`docs/design-docs/`、`docs/exec-plans/`。
16
+ - 仓库是记录系统:规则、设计权衡、执行计划、生成产物、失败复盘都应进入版本控制。
17
+ - 检索优先于记忆:优先使用 `node dist/cli/index.js query|analyze|deps|impact` 获取事实,再回退到 `rg`、`find`、直接读文件。
18
+ - 规则优先编码:重复出现的评审意见、输出约束、结构边界,优先落为 CLI 子命令、hook、CI 检查或生成契约,而不是停留在 prose。
19
+
20
+ ## 3. 渐进式上下文披露(Harness 规范)
21
+
22
+ **原则**:不向 AI 提供超过当前任务决策所需的信息,避免注意力稀释。
23
+
24
+ **上下文层级**(AI 按优先级读取):
25
+
26
+ 1. **T0-地图层**(始终提供):架构说明、类型定义、关键约束文件
27
+ - `AGENTS.md`(仓库级强约束)
28
+ - `CLAUDE.md`(执行手册)
29
+ - `src/types/index.ts`(核心类型)
30
+
31
+ 2. **T1-任务相关层**(动态检索):通过 CodeMap CLI 或文件路径匹配提供
32
+ - 当前修改文件的依赖图谱(直接上下游)
33
+ - 相关测试文件(同名 `.test.ts` 或 `.spec.ts`)
34
+ - 接口定义(如果实现类,提供接口)
35
+
36
+ 3. **T2-按需获取层**(工具调用):AI 明确请求时才提供
37
+ - 具体业务逻辑实现细节
38
+ - 历史提交记录
39
+ - 第三方库文档
40
+
41
+ **禁止行为**:不要将整个 `node_modules` 目录或上千行无关代码粘贴给 AI。
42
+
43
+ ## 4. 当前项目的 CLI 护栏
44
+
45
+ - 仓库内调试与验证优先使用 `node dist/cli/index.js <command>`,因为当前真实 CLI 入口是 `dist/cli/index.js`。
46
+ - 需求澄清、影响分析、引用定位优先走 `query`、`analyze`、`deps`、`impact`,不要直接全仓漫游。
47
+ - 修改 `analyze`、`query`、`ci`、`workflow` 等高影响命令时,至少验证:
48
+ - `--help` 输出与文档示例一致;
49
+ - 受影响的真实子命令可以在当前仓库运行;
50
+ - 若涉及机器输出,`--output-mode machine --json` 仍保持纯 JSON 契约。
51
+ - 若改动会影响 agent 执行手册、README 示例、测试事实或入口路由,先执行 `npm run docs:check`。
52
+ - 若希望通过统一 CLI 护栏入口执行同一检查,使用 `node dist/cli/index.js ci check-docs-sync`。
53
+ - 涉及发布边界时,再补 `npm run build` 与 `npm run validate-pack`;不要把本地临时产物当成发布事实。
54
+
55
+ ## 5. 当前项目的 CI 护栏
56
+
57
+ - 本地护栏:
58
+ - `.githooks/pre-commit` 会执行变更相关测试、文件头检查,并尝试生成 AI feed。
59
+ - 当变更涉及 README、`docs/`、CLI 入口、测试配置或 CI 配置时,`.githooks/pre-commit` 还会执行 `npm run docs:check`。
60
+ - `.githooks/commit-msg` 会校验 `[TAG] scope: message` 格式与单次 commit 文件数量。
61
+ - 服务端护栏:
62
+ - `.github/workflows/ci-gateway.yml` 会执行 `npm run docs:check`、`npm run typecheck`、`npm test`、`npm run build`,然后再通过 `node dist/cli/index.js ci ...` 执行 `check-docs-sync`、`check-commits`、`check-commit-size`、`check-headers`、`assess-risk`、`check-output-contract` 与 AI feed 同步检查。
63
+ - `.github/workflows/publish.yml` 会在发布前执行 `npm test` 与 `npm run build`。
64
+ - 仓库协议仍然禁止通过 `--no-verify`、关闭 hook、放宽阈值、删除检查项来"修复"问题。
65
+
66
+ ## 6. 代码生成红线详细规范(Harness 规范)
67
+
68
+ AI 生成代码时,以下模式触发**硬性阻断**:
69
+
70
+ | 红线规则 | 检测方式 | 阻断标准 | 修复策略 |
71
+ |---------|---------|---------|---------|
72
+ | **敏感信息硬编码** | 正则检测 `"password"`, `"secret"`, `"api_key"`, `"token"` 字面量 | 生产代码中出现明文凭证 | 替换为 `process.env.XXX` 读取 + env 类型声明 |
73
+ | **`any` 类型使用** | `tsc --noImplicitAny` + ESLint `@typescript-eslint/no-explicit-any` | 非边界文件使用 `any` | 推导具体类型或使用 `unknown` + 类型守卫 |
74
+ | **函数超过 50 行** | 代码行数统计(不含空行和注释) | 单函数 >50 行 | 拆分为子函数,保持单一职责 |
75
+ | **未处理 Promise** | ESLint `@typescript-eslint/no-floating-promises` | 异步调用无 `await` 或错误处理 | 添加 `await` 或 `.catch()` 处理 |
76
+ | **`console.log` 遗留** | ESLint `no-console` | 非调试代码包含 `console.log` | 使用 `src/cli/runtime-logger.ts` 替代 |
77
+ | **未使用 import** | ESLint `@typescript-eslint/no-unused-vars` | 存在未引用 import | 自动删除或标记为使用 |
78
+ | **缺少文件头** | `.githooks/pre-commit` 检查 | TS 源文件缺少 `[META]` 或 `[WHY]` | 添加标准文件头注释 |
79
+
80
+ ## 7. 依赖流向规则(Harness 规范)
81
+
82
+ **第一性原理**:业务逻辑必须与实现细节解耦,确保可测试性和技术栈可替换性。
83
+
84
+ 当前项目采用 **MVP3 分层架构**(从上至下依赖):
85
+
86
+ ```
87
+ ┌─────────────────────────────────────────────────────────────┐
88
+ │ CLI Layer │
89
+ │ src/cli/ - 命令行接口,注册命令、参数解析、用户交互 │
90
+ ├─────────────────────────────────────────────────────────────┤
91
+ │ Server Layer │
92
+ │ src/server/ - HTTP API 服务器,RESTful 端点,Handler 处理 │
93
+ ├─────────────────────────────────────────────────────────────┤
94
+ │ Domain Layer │
95
+ │ src/domain/ - 核心业务逻辑,领域实体与服务 │
96
+ │ - entities/: Project, Module, Symbol, Dependency, CodeGraph │
97
+ │ - services/: CodeGraphBuilder │
98
+ │ - events/: DomainEvent │
99
+ │ - repositories/: 仓库接口 │
100
+ ├─────────────────────────────────────────────────────────────┤
101
+ │ Infrastructure Layer │
102
+ │ src/infrastructure/ - 技术实现细节 │
103
+ │ - storage/: FileSystemStorage, MemoryStorage, KuzuDBStorage, Neo4jStorage
104
+ │ - parser/: TypeScriptParser, GoParser, PythonParser, ParserRegistry
105
+ │ - repositories/: CodeGraphRepositoryImpl │
106
+ ├─────────────────────────────────────────────────────────────┤
107
+ │ Interface Layer │
108
+ │ src/interface/ - 类型定义与契约,跨层共享的接口 │
109
+ │ - types/: 核心类型定义 │
110
+ │ - config/: 配置接口 │
111
+ └─────────────────────────────────────────────────────────────┘
112
+ ```
113
+
114
+ **分层依赖规则**(严格自上而下):
115
+ - CLI → Server → Domain → Infrastructure → Interface
116
+ - **禁止跨层依赖**(如 Domain 层不得导入 CLI 模块)
117
+ - 同层内可以相互依赖
118
+
119
+ **Enforcement 规则**:
120
+ 1. **Domain 层禁止导入**:CLI、Server 层模块
121
+ 2. **Infrastructure 层禁止导入**:CLI、Server、Domain 中的具体实现
122
+ 3. **Server 层禁止导入**:CLI 层模块
123
+ 4. **跨层调用必须通过接口**,依赖 Interface 层契约
124
+
125
+ **历史架构说明**:
126
+ - MVP3 之前的旧架构(cli→orchestrator→core→parser→generator)已完成迁移
127
+ - 原有 `src/orchestrator/` 部分功能已整合到 Server 层和 CLI 层
128
+ - 原有 `src/core/`、`src/parser/`、`src/generator/` 已迁移到 Domain/Infrastructure 层
129
+
130
+ **违规检测**:使用 `dependency-cruiser` 或 CodeMap 自身的 `deps` 命令检查跨层依赖。
131
+
132
+ **违规示例**:
133
+ ```typescript
134
+ // ❌ 违规:Domain 层直接依赖 Infrastructure 具体实现
135
+ // src/domain/services/CodeGraphBuilder.ts
136
+ import { FileSystemStorage } from '../infrastructure/storage/FileSystemStorage'; // 错误!
137
+
138
+ // ✅ 合规:通过 Interface 层契约依赖
139
+ // src/domain/services/CodeGraphBuilder.ts
140
+ import type { IStorage } from '../interface/types/storage'; // 正确:只依赖接口
141
+ ```
142
+
143
+ ## 8. 文档与知识落点
144
+
145
+ - 规则变化:写入 `docs/rules/`
146
+ - 设计权衡:写入 `docs/design-docs/`
147
+ - 执行计划、复盘、技术债:写入 `docs/exec-plans/`
148
+ - 生成物、快照、报告:写入 `docs/generated/`
149
+ - 外部资料摘要:写入 `docs/references/`
150
+
151
+ 如果一次任务无法在 1 天内稳定完成,先拆成更小的执行单元;复杂任务的过程信息不要只留在对话里。
152
+
153
+ ## 9. 失败预演
154
+
155
+ 至少预演一个失败模式,而不是只验证 happy path。当前仓库已经出现过两类高信号风险:
156
+
157
+ - 文档漂移:例如测试规则曾与真实 `vitest.config.ts` 不一致,导致 agent 按旧规则执行错误命令。
158
+ - 文档检索盲区:当 `analyze documentation` 无法命中文档时,agent 需要立即回退到 `rg` / 直接读文件,并在适用时记录 CodeMap 缺陷,而不是假装"没问题"。
159
+
160
+ ## 10. 最小交付清单(更新版 - Harness 规范)
161
+
162
+ ### 10.1 交付内容
163
+
164
+ 每次 agent 交付至少要说明:
165
+
166
+ 1. **改了什么**:文件清单 + 变更摘要
167
+ 2. **为什么改**:需求背景 + 设计决策
168
+ 3. **按什么护栏验证**:执行的检查命令和结果
169
+ 4. **失败场景或风险模式**:至少一个预演的失败场景
170
+ 5. **可信度自评**(见 AGENTS.md 5.1 格式):确定/推测/需验证/风险
171
+ 6. **文档同步说明**:是否更新了相关文档及原因
172
+
173
+ ### 10.2 必须同步文档的触发条件
174
+
175
+ 以下情况**必须**更新对应文档:
176
+
177
+ | 你的改动 | 必须更新的文档 |
178
+ |---------|--------------|
179
+ | 新增/修改 CLI 命令或参数 | `CLAUDE.md`、`docs/rules/engineering-with-codex-openai.md` |
180
+ | 新增/修改配置项或 Schema | `README.md`、相关配置示例 |
181
+ | 修改类型定义/公共接口 | 接口注释、`docs/rules/` 中相关文档 |
182
+ | 修改 CI/CD 流程 | `docs/rules/validation.md`、`.github/workflows/` |
183
+ | 修改 Git Hooks | `docs/rules/validation.md` |
184
+ | 修改测试规则/覆盖率要求 | `docs/rules/testing.md` |
185
+ | 修改架构分层或依赖规则 | `ARCHITECTURE.md`、`docs/rules/architecture-guardrails.md` |
186
+ | 新增代码质量红线 | `docs/rules/code-quality-redlines.md` |
187
+ | 修改提交格式规范 | `AGENTS.md` |
188
+ | 发现文档与代码不符 | 立即修复对应文档 |
189
+
190
+ **原则**:若改动会影响其他开发者或 AI 的行为,就必须更新文档。
191
+
192
+ ## 11. 参考来源
193
+
194
+ - OpenAI Engineering: https://openai.com/engineering/codex/
195
+ - Harness Engineering 方法论:`docs/references/tmp.md`
196
+ - 仓库入口协议:`AGENTS.md`
197
+ - 最小执行手册:`CLAUDE.md`
198
+ - 架构地图:`ARCHITECTURE.md`
199
+ - 当前验证规则:`docs/rules/validation.md`
200
+ - 当前发布规则:`docs/rules/deployment.md`
201
+ - 代码质量红线:`docs/rules/code-quality-redlines.md`
202
+ - 架构护栏:`docs/rules/architecture-guardrails.md`
@@ -0,0 +1,73 @@
1
+ # 测试规则
2
+
3
+ > 测试框架、覆盖率要求、基准测试
4
+
5
+ ---
6
+
7
+ ## 测试框架
8
+
9
+ | 项目 | 配置 |
10
+ |------|------|
11
+ | 框架 | Vitest |
12
+ | 覆盖率工具 | @vitest/coverage-v8 |
13
+ | 目标覆盖率 | >= 80% |
14
+
15
+ ## 测试文件位置
16
+
17
+ | 类型 | 路径 |
18
+ |------|------|
19
+ | 常规测试 | `src/**/*.test.ts` |
20
+ | 集成测试 | `tests/` 目录(如存在单独集成测试编排) |
21
+ | 基准测试 | `refer/benchmark-quality.test.ts` |
22
+
23
+ ## 测试配置
24
+
25
+ ```typescript
26
+ // vitest.config.ts
27
+ export default defineConfig({
28
+ test: {
29
+ globals: true,
30
+ environment: 'node',
31
+ include: ['src/**/*.test.ts'],
32
+ exclude: ['node_modules', 'dist', 'refer/**/*.test.ts'],
33
+ testTimeout: 10000,
34
+ hookTimeout: 10000,
35
+ pool: 'threads'
36
+ }
37
+ });
38
+ ```
39
+
40
+ ## 测试要求
41
+
42
+ - 所有新功能必须附带测试
43
+ - 测试文件命名:`* .test.ts`
44
+ - 使用 `describe` 和 `it` 组织测试用例
45
+ - 使用 `beforeEach`/`afterEach` 管理测试状态
46
+
47
+ ## 基准测试
48
+
49
+ - 基准查询集:`refer/benchmark-quality.ts`(30 条预定义查询)
50
+ - 基准测试配置:`vitest.benchmark.config.ts`
51
+ - 关键指标:
52
+ - Token 消耗降低 >= 40%
53
+ - Hit@8 >= 90%
54
+
55
+ ## 常用命令
56
+
57
+ ```bash
58
+ # 运行所有测试
59
+ npm test
60
+ npx vitest run
61
+
62
+ # 运行特定测试文件
63
+ npx vitest run src/orchestrator/__tests__/confidence.test.ts
64
+
65
+ # 运行与变更相关的测试
66
+ npx vitest run --changed
67
+
68
+ # 运行覆盖率
69
+ npx vitest run --coverage
70
+
71
+ # 监视模式
72
+ npx vitest watch
73
+ ```
@@ -0,0 +1,39 @@
1
+ # 验证规则
2
+
3
+ ## 最小验证顺序
4
+
5
+ 1. 先验证与你改动最相关的命令、测试或模块。
6
+ 2. 若改动影响 agent 路由、CLI 示例、规则文档或测试事实,先执行 `npm run docs:check`。
7
+ 3. 若改动同时影响 CLI 护栏入口,再补 `node dist/cli/index.js ci check-docs-sync`。
8
+ 4. 再扩大到 `npm run typecheck`、`npm run lint`、`npm test`。
9
+ 5. 涉及发布或打包时,再执行 `npm run build` 与 `npm run validate-pack`。
10
+
11
+ ## CI Gateway 验证流程
12
+
13
+ CI Gateway 已集成以下自动检查(按执行顺序):
14
+
15
+ 1. `npm run docs:check` - 文档护栏检查
16
+ 2. `npm run typecheck` - TypeScript 类型检查
17
+ 3. `npm run lint` - ESLint 代码质量检查(渐进式规则,0 error 通过)
18
+ 4. `npm test` - 单元测试
19
+ 5. `npm run build` - 构建验证
20
+ 6. CLI 相关检查(commit 格式、文件头等)
21
+
22
+ ## 强约束
23
+
24
+ - 没有验证,不得声称“已解决”。
25
+ - 失败时优先修根因,不绕过护栏。
26
+ - 涉及 CI / hooks / 输出契约时,必须给出失败场景与修复验证证据。
27
+ - 严禁使用 `--no-verify`、禁用 hooks、删除检查项规避失败。
28
+
29
+ ## 常用命令
30
+
31
+ ```bash
32
+ npm run docs:check
33
+ node dist/cli/index.js ci check-docs-sync
34
+ npm run typecheck
35
+ npm test
36
+ npm run lint
37
+ npm run build
38
+ npm run validate-pack
39
+ ```
@@ -0,0 +1,61 @@
1
+ # MyCodeMap 配置示例
2
+
3
+ 本目录包含各种 AI 助手和开发环境的配置示例。
4
+
5
+ ## 目录结构
6
+
7
+ ```
8
+ examples/
9
+ ├── kimi/ # Kimi CLI 配置
10
+ │ └── codemap-skill.md # Skill 定义文件
11
+ ├── claude/ # Claude Code 配置
12
+ │ └── codemap-skill.md # Skill 定义文件
13
+ ├── codex/ # Codex CLI 配置
14
+ │ └── codemap-agent.md # Agent 定义文件
15
+ ├── copilot/ # GitHub Copilot 配置
16
+ │ └── copilot-instructions.md # 提示词文件
17
+ └── README.md # 本文件
18
+ ```
19
+
20
+ ## 快速使用
21
+
22
+ ### Kimi CLI
23
+
24
+ ```bash
25
+ mkdir -p .kimi/skills/codemap
26
+ cp examples/kimi/codemap-skill.md .kimi/skills/codemap/SKILL.md
27
+ ```
28
+
29
+ ### Claude Code
30
+
31
+ ```bash
32
+ mkdir -p .claude/skills/codemap
33
+ cp examples/claude/codemap-skill.md .claude/skills/codemap/SKILL.md
34
+ ```
35
+
36
+ ### Codex CLI
37
+
38
+ ```bash
39
+ mkdir -p .agents/skills/codemap
40
+ cp examples/codex/codemap-agent.md .agents/skills/codemap/SKILL.md
41
+ ```
42
+
43
+ ### GitHub Copilot
44
+
45
+ ```bash
46
+ mkdir -p .github
47
+ cp examples/copilot/copilot-instructions.md .github/copilot-instructions.md
48
+ ```
49
+
50
+ ## 自定义配置
51
+
52
+ 复制示例文件后,可以根据项目需求进行调整:
53
+
54
+ 1. **修改命令别名** - 如果项目中使用了不同的命令别名
55
+ 2. **添加项目特定规则** - 针对项目结构的特殊处理
56
+ 3. **调整输出格式** - 根据 AI 助手的解析能力调整
57
+
58
+ ## 更多信息
59
+
60
+ - [安装配置指南](../docs/SETUP_GUIDE.md)
61
+ - [AI 助手集成指南](../docs/AI_ASSISTANT_SETUP.md)
@@ -0,0 +1,94 @@
1
+ # MyCodeMap Code Analysis
2
+
3
+ ## Overview
4
+
5
+ Use MyCodeMap to analyze TypeScript/JavaScript project structure, query symbols, analyze dependencies, and assess change impact.
6
+
7
+ ## CLI Detection
8
+
9
+ Detect MyCodeMap CLI availability:
10
+
11
+ ```bash
12
+ # Check global installation
13
+ if command -v mycodemap &> /dev/null; then
14
+ CODEMAP="mycodemap"
15
+ # Check local installation
16
+ elif [ -f "./node_modules/.bin/mycodemap" ]; then
17
+ CODEMAP="./node_modules/.bin/mycodemap"
18
+ # Fallback to npx
19
+ else
20
+ CODEMAP="npx @mycodemap/mycodemap"
21
+ fi
22
+ ```
23
+
24
+ ## Commands
25
+
26
+ ### Generate Code Map
27
+ ```bash
28
+ $CODEMAP generate
29
+ ```
30
+ Generates: `.mycodemap/AI_MAP.md`, `.mycodemap/CONTEXT.md`, `.mycodemap/codemap.json`
31
+
32
+ ### Query Symbol
33
+ ```bash
34
+ $CODEMAP query -s "<symbol-name>"
35
+ $CODEMAP query -s "<symbol-name>" -j # JSON output
36
+ ```
37
+
38
+ ### Query Module
39
+ ```bash
40
+ $CODEMAP query -m "<module-path>"
41
+ ```
42
+
43
+ ### Search
44
+ ```bash
45
+ $CODEMAP query -S "<keyword>" -l 10
46
+ ```
47
+
48
+ ### Dependency Analysis
49
+ ```bash
50
+ $CODEMAP deps -m "<module-path>"
51
+ $CODEMAP deps -m "<module-path>" -j
52
+ ```
53
+
54
+ ### Impact Analysis
55
+ ```bash
56
+ $CODEMAP impact -f "<file-path>"
57
+ $CODEMAP impact -f "<file-path>" --transitive
58
+ ```
59
+
60
+ ### Cycle Detection
61
+ ```bash
62
+ $CODEMAP cycles
63
+ ```
64
+
65
+ ### Complexity Analysis
66
+ ```bash
67
+ $CODEMAP complexity
68
+ $CODEMAP complexity -f "<file-path>"
69
+ ```
70
+
71
+ ## Workflows
72
+
73
+ ### Understanding Project Structure
74
+
75
+ 1. Generate code map: `$CODEMAP generate`
76
+ 2. Read `.mycodemap/AI_MAP.md` for overview
77
+ 3. Query specific modules as needed
78
+
79
+ ### Before Code Changes
80
+
81
+ 1. Run impact analysis: `$CODEMAP impact -f "<file>" --transitive`
82
+ 2. Review affected files
83
+ 3. Suggest test cases based on impact
84
+
85
+ ### Finding Code
86
+
87
+ 1. Search symbol: `$CODEMAP query -s "<name>"`
88
+ 2. If not found, fuzzy search: `$CODEMAP query -S "<name>"`
89
+ 3. Check module context: `$CODEMAP query -m "<path>"`
90
+
91
+ ## Output Format
92
+
93
+ - Default: Human-readable text
94
+ - JSON: Add `-j` flag for structured data
@@ -0,0 +1,66 @@
1
+ # MyCodeMap Skill
2
+
3
+ ## Description
4
+
5
+ Code analysis tool for TypeScript/JavaScript projects. Provides project structure analysis, symbol querying, dependency analysis, and impact assessment.
6
+
7
+ ## CLI Command Detection
8
+
9
+ ```bash
10
+ # Priority: global > local > npx
11
+ if command -v mycodemap &> /dev/null; then
12
+ CODEMAP_CMD="mycodemap"
13
+ elif [ -f "./node_modules/.bin/mycodemap" ]; then
14
+ CODEMAP_CMD="./node_modules/.bin/mycodemap"
15
+ else
16
+ CODEMAP_CMD="npx @mycodemap/mycodemap"
17
+ fi
18
+ ```
19
+
20
+ ## Available Commands
21
+
22
+ | Command | Purpose | Example |
23
+ |---------|---------|---------|
24
+ | `generate` | Generate code map | `$CODEMAP_CMD generate` |
25
+ | `query -s` | Query symbol | `$CODEMAP_CMD query -s "ClassName"` |
26
+ | `query -m` | Query module | `$CODEMAP_CMD query -m "src/parser"` |
27
+ | `query -S` | Fuzzy search | `$CODEMAP_CMD query -S "keyword"` |
28
+ | `deps` | Dependency analysis | `$CODEMAP_CMD deps -m "src/core"` |
29
+ | `impact` | Impact analysis | `$CODEMAP_CMD impact -f "src/index.ts"` |
30
+ | `cycles` | Cycle detection | `$CODEMAP_CMD cycles` |
31
+ | `complexity` | Complexity metrics | `$CODEMAP_CMD complexity` |
32
+
33
+ ## Usage Patterns
34
+
35
+ ### Pattern 1: Project Onboarding
36
+ ```
37
+ User: "Explain this project structure"
38
+ Agent:
39
+ 1. $CODEMAP_CMD generate
40
+ 2. Read .mycodemap/AI_MAP.md
41
+ 3. Summarize key components
42
+ ```
43
+
44
+ ### Pattern 2: Change Impact
45
+ ```
46
+ User: "What happens if I modify X?"
47
+ Agent:
48
+ 1. $CODEMAP_CMD impact -f "<path>" --transitive
49
+ 2. Analyze output
50
+ 3. List affected files and suggest tests
51
+ ```
52
+
53
+ ### Pattern 3: Code Navigation
54
+ ```
55
+ User: "Where is function Y defined?"
56
+ Agent:
57
+ 1. $CODEMAP_CMD query -s "Y"
58
+ 2. Report location
59
+ 3. Offer to show code context
60
+ ```
61
+
62
+ ## Best Practices
63
+
64
+ - Always generate code map before queries if `.mycodemap/` is stale
65
+ - Use `-j` flag for programmatic processing
66
+ - Use `--transitive` for complete impact analysis
@@ -0,0 +1,24 @@
1
+ # MyCodeMap Integration
2
+
3
+ This project uses MyCodeMap for code analysis.
4
+
5
+ ## Available Commands
6
+
7
+ Before answering questions about project structure, run:
8
+ ```bash
9
+ mycodemap generate
10
+ ```
11
+
12
+ Then read `.mycodemap/AI_MAP.md` for context.
13
+
14
+ ## Common Queries
15
+
16
+ - Find symbol: `mycodemap query -s "<name>"`
17
+ - Check dependencies: `mycodemap deps -m "<path>"`
18
+ - Impact analysis: `mycodemap impact -f "<path>"`
19
+
20
+ ## When Answering
21
+
22
+ 1. Always check the code map first for structural questions
23
+ 2. Use impact analysis before suggesting changes
24
+ 3. Reference specific files and line numbers
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: codemap
3
+ description: MyCodeMap 代码分析技能,用于项目结构分析、符号查询、依赖分析和影响评估。
4
+ ---
5
+
6
+ # MyCodeMap Skill
7
+
8
+ ## 环境检测
9
+
10
+ 首先检测 CLI 是否可用:
11
+
12
+ ```bash
13
+ # 检测全局安装的 mycodemap
14
+ if command -v mycodemap &> /dev/null; then
15
+ CODEMAP_CMD="mycodemap"
16
+ # 检测本地安装的 mycodemap
17
+ elif [ -f "./node_modules/.bin/mycodemap" ]; then
18
+ CODEMAP_CMD="./node_modules/.bin/mycodemap"
19
+ # 使用 npx
20
+ else
21
+ CODEMAP_CMD="npx @mycodemap/mycodemap"
22
+ fi
23
+ ```
24
+
25
+ ## 常用命令
26
+
27
+ ### 生成代码地图
28
+ ```bash
29
+ $CODEMAP_CMD generate
30
+ ```
31
+
32
+ ### 查询符号
33
+ ```bash
34
+ $CODEMAP_CMD query -s "<symbol-name>"
35
+ ```
36
+
37
+ ### 查询模块
38
+ ```bash
39
+ $CODEMAP_CMD query -m "<module-path>"
40
+ ```
41
+
42
+ ### 模糊搜索
43
+ ```bash
44
+ $CODEMAP_CMD query -S "<keyword>" -l 10
45
+ ```
46
+
47
+ ### 依赖分析
48
+ ```bash
49
+ $CODEMAP_CMD deps -m "<module-path>"
50
+ ```
51
+
52
+ ### 影响范围分析
53
+ ```bash
54
+ $CODEMAP_CMD impact -f "<file-path>"
55
+ ```
56
+
57
+ ### 循环依赖检测
58
+ ```bash
59
+ $CODEMAP_CMD cycles
60
+ ```
61
+
62
+ ### 复杂度分析
63
+ ```bash
64
+ $CODEMAP_CMD complexity -f "<file-path>"
65
+ ```
66
+
67
+ ## 使用场景
68
+
69
+ ### 场景 1:理解项目结构
70
+
71
+ 当用户询问项目结构或特定模块时:
72
+ 1. 运行 `$CODEMAP_CMD generate` 生成最新代码地图
73
+ 2. 阅读 `.mycodemap/AI_MAP.md` 获取项目概览
74
+ 3. 根据需要使用 `query` 或 `deps` 获取详细信息
75
+
76
+ ### 场景 2:代码变更影响分析
77
+
78
+ 当用户要修改某个文件时:
79
+ 1. 运行 `$CODEMAP_CMD impact -f "<file-path>" --transitive`
80
+ 2. 分析输出结果,告知用户受影响的模块和文件
81
+
82
+ ### 场景 3:查找代码定义
83
+
84
+ 当用户询问某个类/函数的位置时:
85
+ 1. 运行 `$CODEMAP_CMD query -s "<symbol-name>"`
86
+ 2. 根据结果提供精确的文件路径和行号
87
+
88
+ ## 输出处理
89
+
90
+ - 直接返回 CLI 输出给用户
91
+ - 使用 `-j` 参数获取 JSON 格式便于解析
92
+ - 复杂输出可重定向到临时文件分析