@mycodemap/mycodemap 0.4.0 → 0.4.2

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 (246) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +214 -221
  3. package/dist/cli/commands/analyze-options.d.ts +36 -0
  4. package/dist/cli/commands/analyze-options.d.ts.map +1 -0
  5. package/dist/cli/commands/analyze-options.js +147 -0
  6. package/dist/cli/commands/analyze-options.js.map +1 -0
  7. package/dist/cli/commands/analyze.d.ts +93 -4
  8. package/dist/cli/commands/analyze.d.ts.map +1 -1
  9. package/dist/cli/commands/analyze.js +592 -176
  10. package/dist/cli/commands/analyze.js.map +1 -1
  11. package/dist/cli/commands/ci.d.ts +47 -1
  12. package/dist/cli/commands/ci.d.ts.map +1 -1
  13. package/dist/cli/commands/ci.js +208 -1
  14. package/dist/cli/commands/ci.js.map +1 -1
  15. package/dist/cli/commands/export.d.ts.map +1 -1
  16. package/dist/cli/commands/export.js +2 -2
  17. package/dist/cli/commands/export.js.map +1 -1
  18. package/dist/cli/commands/generate.d.ts +8 -2
  19. package/dist/cli/commands/generate.d.ts.map +1 -1
  20. package/dist/cli/commands/generate.js +151 -22
  21. package/dist/cli/commands/generate.js.map +1 -1
  22. package/dist/cli/commands/init.d.ts.map +1 -1
  23. package/dist/cli/commands/init.js +2 -13
  24. package/dist/cli/commands/init.js.map +1 -1
  25. package/dist/cli/commands/ship/analyzer.d.ts +1 -1
  26. package/dist/cli/commands/ship/analyzer.d.ts.map +1 -1
  27. package/dist/cli/commands/ship/analyzer.js +8 -1
  28. package/dist/cli/commands/ship/analyzer.js.map +1 -1
  29. package/dist/cli/commands/ship/checker.d.ts +1 -1
  30. package/dist/cli/commands/ship/checker.d.ts.map +1 -1
  31. package/dist/cli/commands/ship/checker.js +17 -6
  32. package/dist/cli/commands/ship/checker.js.map +1 -1
  33. package/dist/cli/commands/ship/index.js +2 -2
  34. package/dist/cli/commands/ship/index.js.map +1 -1
  35. package/dist/cli/commands/ship/monitor.d.ts +17 -2
  36. package/dist/cli/commands/ship/monitor.d.ts.map +1 -1
  37. package/dist/cli/commands/ship/monitor.js +116 -29
  38. package/dist/cli/commands/ship/monitor.js.map +1 -1
  39. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
  40. package/dist/cli/commands/ship/pipeline.js +97 -18
  41. package/dist/cli/commands/ship/pipeline.js.map +1 -1
  42. package/dist/cli/commands/ship/publisher.d.ts +12 -2
  43. package/dist/cli/commands/ship/publisher.d.ts.map +1 -1
  44. package/dist/cli/commands/ship/publisher.js +217 -37
  45. package/dist/cli/commands/ship/publisher.js.map +1 -1
  46. package/dist/cli/commands/ship/rules/quality-rules.d.ts +2 -2
  47. package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -1
  48. package/dist/cli/commands/ship/rules/quality-rules.js +53 -54
  49. package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -1
  50. package/dist/cli/commands/ship/versioner.d.ts +1 -1
  51. package/dist/cli/commands/ship/versioner.d.ts.map +1 -1
  52. package/dist/cli/commands/ship/versioner.js +4 -2
  53. package/dist/cli/commands/ship/versioner.js.map +1 -1
  54. package/dist/cli/commands/workflow.js +4 -4
  55. package/dist/cli/commands/workflow.js.map +1 -1
  56. package/dist/cli/config-loader.d.ts +31 -0
  57. package/dist/cli/config-loader.d.ts.map +1 -0
  58. package/dist/cli/config-loader.js +235 -0
  59. package/dist/cli/config-loader.js.map +1 -0
  60. package/dist/cli/index.js +19 -64
  61. package/dist/cli/index.js.map +1 -1
  62. package/dist/cli/removed-commands.d.ts +9 -0
  63. package/dist/cli/removed-commands.d.ts.map +1 -0
  64. package/dist/cli/removed-commands.js +48 -0
  65. package/dist/cli/removed-commands.js.map +1 -0
  66. package/dist/cli/storage-runtime.d.ts +8 -0
  67. package/dist/cli/storage-runtime.d.ts.map +1 -0
  68. package/dist/cli/storage-runtime.js +14 -0
  69. package/dist/cli/storage-runtime.js.map +1 -0
  70. package/dist/cli/tree-sitter-check.d.ts.map +1 -1
  71. package/dist/cli/tree-sitter-check.js +0 -1
  72. package/dist/cli/tree-sitter-check.js.map +1 -1
  73. package/dist/cli-new/commands/export.d.ts.map +1 -1
  74. package/dist/cli-new/commands/export.js +2 -2
  75. package/dist/cli-new/commands/export.js.map +1 -1
  76. package/dist/cli-new/commands/query.d.ts.map +1 -1
  77. package/dist/cli-new/commands/query.js +5 -4
  78. package/dist/cli-new/commands/query.js.map +1 -1
  79. package/dist/cli-new/index.d.ts.map +1 -1
  80. package/dist/cli-new/index.js +0 -2
  81. package/dist/cli-new/index.js.map +1 -1
  82. package/dist/core/analyzer.d.ts.map +1 -1
  83. package/dist/core/analyzer.js +7 -39
  84. package/dist/core/analyzer.js.map +1 -1
  85. package/dist/core/file-discovery.d.ts +17 -0
  86. package/dist/core/file-discovery.d.ts.map +1 -0
  87. package/dist/core/file-discovery.js +75 -0
  88. package/dist/core/file-discovery.js.map +1 -0
  89. package/dist/core/global-index.d.ts +5 -0
  90. package/dist/core/global-index.d.ts.map +1 -1
  91. package/dist/core/global-index.js +71 -21
  92. package/dist/core/global-index.js.map +1 -1
  93. package/dist/generator/index.d.ts.map +1 -1
  94. package/dist/generator/index.js +8 -0
  95. package/dist/generator/index.js.map +1 -1
  96. package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -5
  97. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
  98. package/dist/infrastructure/parser/implementations/GoParser.js +2 -5
  99. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
  100. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +1 -5
  101. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -1
  102. package/dist/infrastructure/parser/implementations/PythonParser.js +1 -5
  103. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -1
  104. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +1 -5
  105. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
  106. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +1 -5
  107. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
  108. package/dist/infrastructure/storage/StorageFactory.d.ts +0 -1
  109. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  110. package/dist/infrastructure/storage/StorageFactory.js +4 -29
  111. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  112. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  113. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +24 -137
  114. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  115. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +10 -18
  116. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  117. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +103 -146
  118. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  119. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +0 -1
  120. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  121. package/dist/infrastructure/storage/adapters/MemoryStorage.js +16 -136
  122. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  123. package/dist/infrastructure/storage/graph-helpers.d.ts +16 -0
  124. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -0
  125. package/dist/infrastructure/storage/graph-helpers.js +161 -0
  126. package/dist/infrastructure/storage/graph-helpers.js.map +1 -0
  127. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  128. package/dist/interface/config/index.d.ts +10 -1
  129. package/dist/interface/config/index.d.ts.map +1 -1
  130. package/dist/interface/types/index.d.ts +13 -0
  131. package/dist/interface/types/index.d.ts.map +1 -1
  132. package/dist/interface/types/storage.d.ts +1 -4
  133. package/dist/interface/types/storage.d.ts.map +1 -1
  134. package/dist/orchestrator/confidence.d.ts +9 -9
  135. package/dist/orchestrator/confidence.d.ts.map +1 -1
  136. package/dist/orchestrator/confidence.js +44 -67
  137. package/dist/orchestrator/confidence.js.map +1 -1
  138. package/dist/orchestrator/file-header-scanner.d.ts.map +1 -1
  139. package/dist/orchestrator/file-header-scanner.js +22 -31
  140. package/dist/orchestrator/file-header-scanner.js.map +1 -1
  141. package/dist/orchestrator/intent-router.d.ts +2 -11
  142. package/dist/orchestrator/intent-router.d.ts.map +1 -1
  143. package/dist/orchestrator/intent-router.js +58 -49
  144. package/dist/orchestrator/intent-router.js.map +1 -1
  145. package/dist/orchestrator/tool-orchestrator.d.ts.map +1 -1
  146. package/dist/orchestrator/tool-orchestrator.js +6 -4
  147. package/dist/orchestrator/tool-orchestrator.js.map +1 -1
  148. package/dist/orchestrator/types.d.ts +113 -2
  149. package/dist/orchestrator/types.d.ts.map +1 -1
  150. package/dist/orchestrator/types.js +29 -0
  151. package/dist/orchestrator/types.js.map +1 -1
  152. package/dist/orchestrator/workflow/config.d.ts +4 -12
  153. package/dist/orchestrator/workflow/config.d.ts.map +1 -1
  154. package/dist/orchestrator/workflow/config.js +4 -6
  155. package/dist/orchestrator/workflow/config.js.map +1 -1
  156. package/dist/orchestrator/workflow/git-analyzer.d.ts.map +1 -1
  157. package/dist/orchestrator/workflow/git-analyzer.js +9 -19
  158. package/dist/orchestrator/workflow/git-analyzer.js.map +1 -1
  159. package/dist/orchestrator/workflow/phase-inheritance.d.ts.map +1 -1
  160. package/dist/orchestrator/workflow/phase-inheritance.js +14 -23
  161. package/dist/orchestrator/workflow/phase-inheritance.js.map +1 -1
  162. package/dist/orchestrator/workflow/result-fusion.d.ts.map +1 -1
  163. package/dist/orchestrator/workflow/result-fusion.js +9 -11
  164. package/dist/orchestrator/workflow/result-fusion.js.map +1 -1
  165. package/dist/orchestrator/workflow/templates.d.ts +4 -1
  166. package/dist/orchestrator/workflow/templates.d.ts.map +1 -1
  167. package/dist/orchestrator/workflow/templates.js +49 -207
  168. package/dist/orchestrator/workflow/templates.js.map +1 -1
  169. package/dist/orchestrator/workflow/test-linker.d.ts.map +1 -1
  170. package/dist/orchestrator/workflow/test-linker.js +12 -24
  171. package/dist/orchestrator/workflow/test-linker.js.map +1 -1
  172. package/dist/orchestrator/workflow/types.d.ts +11 -8
  173. package/dist/orchestrator/workflow/types.d.ts.map +1 -1
  174. package/dist/orchestrator/workflow/types.js +8 -1
  175. package/dist/orchestrator/workflow/types.js.map +1 -1
  176. package/dist/orchestrator/workflow/visualizer.d.ts.map +1 -1
  177. package/dist/orchestrator/workflow/visualizer.js +7 -9
  178. package/dist/orchestrator/workflow/visualizer.js.map +1 -1
  179. package/dist/orchestrator/workflow/workflow-context.d.ts.map +1 -1
  180. package/dist/orchestrator/workflow/workflow-context.js +3 -5
  181. package/dist/orchestrator/workflow/workflow-context.js.map +1 -1
  182. package/dist/orchestrator/workflow/workflow-orchestrator.d.ts +0 -4
  183. package/dist/orchestrator/workflow/workflow-orchestrator.d.ts.map +1 -1
  184. package/dist/orchestrator/workflow/workflow-orchestrator.js +7 -99
  185. package/dist/orchestrator/workflow/workflow-orchestrator.js.map +1 -1
  186. package/dist/parser/index.d.ts.map +1 -1
  187. package/dist/parser/index.js +2 -2
  188. package/dist/parser/index.js.map +1 -1
  189. package/dist/plugins/index.d.ts +5 -3
  190. package/dist/plugins/index.d.ts.map +1 -1
  191. package/dist/plugins/index.js +19 -8
  192. package/dist/plugins/index.js.map +1 -1
  193. package/dist/plugins/plugin-loader.d.ts +21 -6
  194. package/dist/plugins/plugin-loader.d.ts.map +1 -1
  195. package/dist/plugins/plugin-loader.js +170 -54
  196. package/dist/plugins/plugin-loader.js.map +1 -1
  197. package/dist/plugins/plugin-registry.d.ts +7 -4
  198. package/dist/plugins/plugin-registry.d.ts.map +1 -1
  199. package/dist/plugins/plugin-registry.js +62 -14
  200. package/dist/plugins/plugin-registry.js.map +1 -1
  201. package/dist/plugins/types.d.ts +16 -6
  202. package/dist/plugins/types.d.ts.map +1 -1
  203. package/dist/plugins/types.js +2 -0
  204. package/dist/plugins/types.js.map +1 -1
  205. package/dist/server/handlers/AnalysisHandler.d.ts +16 -2
  206. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
  207. package/dist/server/handlers/AnalysisHandler.js +31 -47
  208. package/dist/server/handlers/AnalysisHandler.js.map +1 -1
  209. package/dist/server/routes/api.d.ts.map +1 -1
  210. package/dist/server/routes/api.js +31 -12
  211. package/dist/server/routes/api.js.map +1 -1
  212. package/docs/AI_ASSISTANT_SETUP.md +3 -1
  213. package/docs/PUBLISHING.md +18 -4
  214. package/docs/SETUP_GUIDE.md +41 -17
  215. package/docs/ai-guide/COMMANDS.md +107 -103
  216. package/docs/ai-guide/INTEGRATION.md +23 -21
  217. package/docs/ai-guide/OUTPUT.md +206 -10
  218. package/docs/ai-guide/PATTERNS.md +64 -15
  219. package/docs/ai-guide/PROMPTS.md +50 -12
  220. package/docs/ai-guide/QUICKSTART.md +35 -19
  221. package/docs/ai-guide/README.md +22 -4
  222. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +159 -434
  223. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +169 -261
  224. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +201 -1259
  225. package/docs/product-specs/README.md +8 -1
  226. package/docs/rules/architecture-guardrails.md +1 -2
  227. package/docs/rules/engineering-with-codex-openai.md +15 -9
  228. package/docs/rules/validation.md +26 -4
  229. package/mycodemap.config.schema.json +76 -5
  230. package/package.json +1 -1
  231. package/scripts/pre-release-check.js +21 -3
  232. package/scripts/sync-analyze-docs.js +500 -0
  233. package/scripts/validate-ai-docs.js +54 -1
  234. package/scripts/validate-docs.js +746 -26
  235. package/dist/cli/commands/server.d.ts +0 -9
  236. package/dist/cli/commands/server.d.ts.map +0 -1
  237. package/dist/cli/commands/server.js +0 -68
  238. package/dist/cli/commands/server.js.map +0 -1
  239. package/dist/cli-new/commands/server.d.ts +0 -13
  240. package/dist/cli-new/commands/server.d.ts.map +0 -1
  241. package/dist/cli-new/commands/server.js +0 -94
  242. package/dist/cli-new/commands/server.js.map +0 -1
  243. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +0 -49
  244. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +0 -1
  245. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +0 -222
  246. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +0 -1
@@ -1,504 +1,229 @@
1
- # MVP3 架构对比:Before vs After
1
+ # MVP3 架构对比:历史设计目标 vs v1.3 已落地基线
2
2
 
3
- > 本文档对比展示 CodeMap MVP3 架构重构前后的差异
3
+ > **状态**: Synced with v1.3 shipped reality
4
+ > **最后同步**: 2026-03-25
5
+ > **适用范围**: 用于区分“历史设计目标”和“当前仓库已落地事实”
4
6
 
5
7
  ---
6
8
 
7
- ## 1. 架构总览对比
9
+ ## 1. 阅读说明
8
10
 
9
- ### Before (当前架构)
11
+ 本文档不再把早期 MVP3 设计稿里的所有目标都当成“当前已实现”。
10
12
 
11
- ```
12
- ┌─────────────────────────────────────────────────────────────────┐
13
- │ 当前架构 (v2.5) │
14
- ├─────────────────────────────────────────────────────────────────┤
15
- │ │
16
- │ ┌─────────────────────────────────────────────────────────┐ │
17
- │ │ CLI Layer │ │
18
- │ │ (命令解析 + 业务逻辑 + 输出格式化 混合在一起) │ │
19
- │ │ │ │
20
- │ │ cli/commands/generate.ts ──────┐ │ │
21
- │ │ cli/commands/query.ts ────────┼── 直接调用核心 │ │
22
- │ │ cli/commands/impact.ts ────────┘ │ │
23
- │ └─────────────────────────────────────────────────────────┘ │
24
- │ │ │
25
- │ ▼ │
26
- │ ┌─────────────────────────────────────────────────────────┐ │
27
- │ │ Core Layer │ │
28
- │ │ (分析器 + 依赖图构建 混合在一起) │ │
29
- │ │ │ │
30
- │ │ core/analyzer.ts ────── 直接操作文件系统 │ │
31
- │ │ core/global-index.ts │ │
32
- │ └─────────────────────────────────────────────────────────┘ │
33
- │ │ │
34
- │ ▼ │
35
- │ ┌─────────────────────────────────────────────────────────┐ │
36
- │ │ Parser Layer │ │
37
- │ │ (仅支持 TS/JS/Go,扩展困难) │ │
38
- │ │ │ │
39
- │ │ parser/index.ts ──────── 硬编码 TypeScript 逻辑 │ │
40
- │ │ parser/smart-parser.ts │ │
41
- │ │ parser/fast-parser.ts │ │
42
- │ └─────────────────────────────────────────────────────────┘ │
43
- │ │ │
44
- │ ▼ │
45
- │ ┌─────────────────────────────────────────────────────────┐ │
46
- │ │ Generator Layer │ │
47
- │ │ (直接输出 JSON/Markdown,无抽象) │ │
48
- │ │ │ │
49
- │ │ generator/index.ts ──── 硬编码文件输出 │ │
50
- │ └─────────────────────────────────────────────────────────┘ │
51
- │ │
52
- │ ❌ 问题: │
53
- │ - CLI 直接依赖 Core,难以测试 │
54
- │ - 存储硬编码,无法切换图数据库 │
55
- │ - 语言解析器扩展困难 │
56
- │ - 业务逻辑分散在各命令中 │
57
- │ │
58
- └─────────────────────────────────────────────────────────────────┘
59
- ```
13
+ - **Before**: 指 MVP3 重构前的 legacy 形态
14
+ - **After**: 指 `v1.3` 收口后的当前仓库基线
15
+ - **Deferred**: 指仍保留为未来候选、但尚未作为当前产品事实交付的能力
60
16
 
61
- ### After (MVP3 架构)
17
+ ---
62
18
 
63
- ```
64
- ┌─────────────────────────────────────────────────────────────────┐
65
- │ MVP3 架构 (v3.0)
66
- ├─────────────────────────────────────────────────────────────────┤
67
- │ │
68
- │ ┌─────────────────────────────────────────────────────────┐ │
69
- │ │ Layer 5: CLI Layer │ │
70
- │ │ - 仅负责: 命令解析、参数校验、格式化输出 │ │
71
- │ │ - 通过 Server Layer 执行业务 │ │
72
- │ │ │ │
73
- │ │ cli/commands/generate.ts ──────┐ │ │
74
- │ │ cli/commands/query.ts ────────┼── 调用 Server 用例 │ │
75
- │ │ cli/commands/viz.ts ──────────┘ │ │
76
- │ └─────────────────────────────────────────────────────────┘ │
77
- │ │ │
78
- │ ▼ │
79
- │ ┌─────────────────────────────────────────────────────────┐ │
80
- │ │ Layer 4: Server Layer ⭐ 新增 │ │
81
- │ │ - 用例编排: GenerateCodeMap, QuerySymbol, etc. │ │
82
- │ │ - 应用服务: CodeMapService, QueryService │ │
83
- │ │ - DTO 转换: Request/Response 映射 │ │
84
- │ │ │ │
85
- │ │ server/usecases/GenerateCodeMap.ts │ │
86
- │ │ server/services/CodeMapService.ts │ │
87
- │ │ server/dto/GenerateRequest.ts │ │
88
- │ └─────────────────────────────────────────────────────────┘ │
89
- │ │ │
90
- │ ▼ │
91
- │ ┌─────────────────────────────────────────────────────────┐ │
92
- │ │ Layer 3: Domain Layer │ │
93
- │ │ - 核心实体: Project, Module, Symbol, Dependency │ │
94
- │ │ - 领域服务: AnalysisService (纯业务逻辑) │ │
95
- │ │ - 仓储接口: ICodeGraphRepository │ │
96
- │ │ │ │
97
- │ │ domain/entities/*.ts │ │
98
- │ │ domain/services/AnalysisService.ts │ │
99
- │ └─────────────────────────────────────────────────────────┘ │
100
- │ │ │
101
- │ ▼ │
102
- │ ┌─────────────────────────────────────────────────────────┐ │
103
- │ │ Layer 2: Infrastructure Layer │ │
104
- │ │ │ │
105
- │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
106
- │ │ │ Storage │ │ Parser │ │ Cache │ │ │
107
- │ │ │ (可插拔) │ │ (14 种语言) │ │ (多层) │ │ │
108
- │ │ │ │ │ │ │ │ │ │
109
- │ │ │ • FileSystem │ │ • TypeScript │ │ • LRU │ │ │
110
- │ │ │ • KùzuDB ⭐ │ │ • Python ⭐ │ │ • File │ │ │
111
- │ │ │ • Neo4j ⭐ │ │ • Java ⭐ │ │ • Incremental│ │ │
112
- │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
113
- │ └─────────────────────────────────────────────────────────┘ │
114
- │ │ │
115
- │ ▼ │
116
- │ ┌─────────────────────────────────────────────────────────┐ │
117
- │ │ Layer 1: Interface Layer │ │
118
- │ │ - 类型定义、接口契约、配置类型 │ │
119
- │ │ │ │
120
- │ │ interface/types/*.ts │ │
121
- │ │ interface/config/*.ts │ │
122
- │ └─────────────────────────────────────────────────────────┘ │
123
- │ │
124
- │ ✅ 优势: │
125
- │ - 依赖方向清晰: Interface → Infrastructure → Domain → Server → CLI │
126
- │ - 存储可插拔: 支持文件系统、KùzuDB、Neo4j │
127
- │ - 语言易扩展: 实现 ILanguageParser 即可添加新语言 │
128
- │ - 业务内聚: Server Layer 统一管理用例 │
129
- │ - 可测试性: 每层可独立单元测试 │
130
- │ │
131
- └─────────────────────────────────────────────────────────────────┘
132
- ```
19
+ ## 2. 总览对比
20
+
21
+ | 维度 | Before | After (`v1.3`) |
22
+ |------|--------|----------------|
23
+ | CLI | 多个命令直接碰核心实现 | 公共 CLI 收口为分析优先的命令面,命名边界清晰 |
24
+ | Server Layer | 设计概念模糊,易与公共 `server` 命令混淆 | `src/server/` 保留为**内部架构层**;公共 `server` 命令已移除 |
25
+ | Storage | 以文件输出为中心,图存储路径不稳定 | `filesystem` / `memory` / `kuzudb` / `auto` 为正式 surface;`neo4j` 已退出正式支持 |
26
+ | Parser | 以 TypeScript 逻辑为主,扩展能力弱 | `ParserRegistry` + `TypeScript/JavaScript`、`Go`、`Python` 三类已落地实现 |
27
+ | Workflow | 设计上曾试图扩到更多工程阶段 | 当前公开能力仅保留 analysis-only:`find read link → show` |
28
+ | Docs / CI | 文档与实现容易漂移 | `docs:check` + `ci check-docs-sync` + CI gateway 固定当前契约 |
133
29
 
134
30
  ---
135
31
 
136
- ## 2. 存储层对比
32
+ ## 3. 架构总览对比
137
33
 
138
- ### Before: 硬编码文件系统
34
+ ### Before(重构前)
139
35
 
140
- ```typescript
141
- // ❌ 问题: 直接操作文件系统,无法扩展
142
-
143
- // src/core/analyzer.ts
144
- export async function analyze(options: AnalysisOptions): Promise<CodeMap> {
145
- // ... 分析逻辑
146
-
147
- // 直接写 JSON 文件
148
- await fs.writeFile(
149
- path.join(outputDir, 'codemap.json'),
150
- JSON.stringify(codeMap)
151
- );
152
-
153
- // 直接写 Markdown
154
- await fs.writeFile(
155
- path.join(outputDir, 'AI_MAP.md'),
156
- generateAIMap(codeMap)
157
- );
158
-
159
- return codeMap;
160
- }
36
+ ```text
37
+ CLI commands
38
+ ├─ 直接调用 analyzer / parser / generator
39
+ ├─ 命令职责与业务逻辑混杂
40
+ └─ 命名边界不稳定
161
41
 
162
- // ❌ 查询时重新读取文件
163
- export async function querySymbol(name: string) {
164
- const codeMap = JSON.parse(
165
- await fs.readFile('codemap.json', 'utf-8')
166
- );
167
- // 线性扫描
168
- return codeMap.modules.flatMap(m => m.symbols).filter(s => s.name === name);
169
- }
42
+ core/*
43
+ ├─ 分析、索引、依赖图构建耦合
44
+ └─ 测试与替换实现成本高
45
+
46
+ parser/*
47
+ ├─ 以 TypeScript 逻辑为中心
48
+ └─ 新语言扩展成本高
170
49
  ```
171
50
 
172
- ### After: 存储抽象接口
51
+ ### After(`v1.3` 当前基线)
173
52
 
174
- ```typescript
175
- // 通过接口抽象,支持多种后端
176
-
177
- // src/infrastructure/storage/interfaces/IStorage.ts
178
- export interface IStorage {
179
- saveCodeGraph(graph: CodeGraph): Promise<void>;
180
- loadCodeGraph(): Promise<CodeMap>;
181
- findSymbolByName(name: string): Promise<Symbol[]>;
182
- findCallers(functionId: string): Promise<Symbol[]>;
183
- calculateImpact(moduleId: string, depth: number): Promise<ImpactResult>;
184
- detectCycles(): Promise<Cycle[]>;
185
- // ...
186
- }
53
+ ```text
54
+ CLI Layer (`src/cli/`)
55
+ ├─ 公共命令面:init / generate / query / deps / cycles
56
+ ├─ analyze / ci / workflow / export / ship
57
+ └─ public `server` / `watch` / `report` / `logs` 已移除
187
58
 
188
- // 使用方代码
189
- export class CodeMapService {
190
- constructor(private storage: IStorage) {}
191
-
192
- async generate(request: GenerateRequest) {
193
- const codeGraph = await this.buildCodeGraph(request);
194
- await this.storage.saveCodeGraph(codeGraph); // 不关心具体存储
195
- return codeGraph;
196
- }
197
-
198
- async querySymbol(name: string) {
199
- return this.storage.findSymbolByName(name); // 可能走图数据库查询
200
- }
201
- }
59
+ Server Layer (`src/server/`)
60
+ ├─ `CodeMapServer.ts`
61
+ ├─ `handlers/QueryHandler.ts`
62
+ ├─ `handlers/AnalysisHandler.ts`
63
+ ├─ `routes/api.ts`
64
+ └─ internal-only transport / handler boundary
202
65
 
203
- // 存储选择
204
- const storage = await storageFactory.create({
205
- type: 'auto', // 根据项目规模自动选择
206
- autoThresholds: {
207
- useGraphDBWhenFileCount: 500
208
- }
209
- });
210
- // < 500 文件: FileSystemStorage
211
- // >= 500 文件: KuzuDBStorage
66
+ Domain Layer (`src/domain/`)
67
+ ├─ 实体、仓储接口、领域服务
68
+ └─ 面向业务模型,不直接暴露 CLI 细节
69
+
70
+ Infrastructure Layer (`src/infrastructure/`)
71
+ ├─ storage: FileSystem / Memory / KùzuDB
72
+ ├─ parser: TypeScript(JS) / Go / Python
73
+ └─ repositories / shared graph helpers
74
+
75
+ Interface Layer (`src/interface/`)
76
+ ├─ 类型定义
77
+ └─ 配置与接口契约
212
78
  ```
213
79
 
80
+ ### 当前架构要点
81
+
82
+ - `Server Layer` 是内部架构层,不等于公共 `mycodemap server`
83
+ - 图存储正式产品面已收敛为 Kùzu-only 主线,不再把 `neo4j` 当成受支持 backend
84
+ - `workflow` 是公开能力,但仅编排分析阶段,不再混入实现/提交/CI 阶段
85
+
214
86
  ---
215
87
 
216
- ## 3. 语言支持对比
88
+ ## 4. 存储层对比
217
89
 
218
- ### Before: 硬编码 TypeScript
90
+ ### Before:以文件输出为主
219
91
 
220
92
  ```typescript
221
- // 问题: 解析逻辑硬编码,难以扩展新语言
222
-
223
- // src/parser/index.ts
224
- export async function parseFile(filePath: string): Promise<ModuleInfo> {
225
- const content = await readFileContent(filePath);
226
-
227
- // 只能解析 TypeScript
228
- const sourceFile = ts.createSourceFile(
229
- path.basename(filePath),
230
- content,
231
- ts.ScriptTarget.ES2022,
232
- true
233
- );
234
-
235
- const imports = extractImports(sourceFile); // TS 专用逻辑
236
- const exports = extractExports(sourceFile); // TS 专用逻辑
237
-
238
- return { imports, exports, ... };
239
- }
93
+ await fs.writeFile(path.join(outputDir, 'codemap.json'), json);
94
+ await fs.writeFile(path.join(outputDir, 'AI_MAP.md'), markdown);
240
95
  ```
241
96
 
242
- ### After: 可插拔语言解析器
97
+ 特点:
98
+
99
+ - 文件输出是唯一稳定路径
100
+ - 查询能力依赖重新读取本地文件
101
+ - 图存储能力即使存在,也没有稳定产品面
102
+
103
+ ### After:存储契约已稳定,但产品面已收敛
243
104
 
244
105
  ```typescript
245
- // 通过注册表管理,支持 14 种语言
246
-
247
- // src/infrastructure/parser/interfaces/ILanguageParser.ts
248
- export interface ILanguageParser {
249
- readonly languageId: LanguageId;
250
- readonly fileExtensions: string[];
251
- parseFile(filePath: string, content: string): Promise<ParseResult>;
252
- extractImports(content: string): Promise<Import[]>;
253
- extractSymbols(content: string): Promise<Symbol[]>;
106
+ export type StorageType = 'filesystem' | 'kuzudb' | 'memory';
107
+
108
+ export interface StorageConfig {
109
+ type: StorageType | 'auto';
110
+ outputPath?: string;
111
+ databasePath?: string;
112
+ autoThresholds?: {
113
+ useGraphDBWhenFileCount: number;
114
+ useGraphDBWhenNodeCount: number;
115
+ };
254
116
  }
117
+ ```
255
118
 
256
- // 使用方代码
257
- export class AnalysisService {
258
- constructor(private parserRegistry: IParserRegistry) {}
259
-
260
- async analyzeFile(filePath: string, content: string) {
261
- // 自动根据扩展名选择解析器
262
- const parser = this.parserRegistry.getParserByFile(filePath);
263
- if (!parser) {
264
- throw new Error(`No parser for ${filePath}`);
265
- }
266
-
267
- return parser.parseFile(filePath, content);
268
- }
269
- }
119
+ 当前事实:
270
120
 
271
- // 注册新语言只需一行
272
- parserRegistry.register(new PythonParser());
273
- parserRegistry.register(new JavaParser());
274
- parserRegistry.register(new RustParser());
275
- // ... 共 14 种语言
276
- ```
121
+ - **正式支持**:`filesystem`、`memory`、`kuzudb`、`auto`
122
+ - **不再正式支持**:`neo4j`
123
+ - **迁移语义**:旧 `neo4j` 配置会返回显式错误,不会静默 fallback
124
+ - **`auto` 现状**:配置面存在,但当前仍保守落到 `filesystem`;阈值字段是契约,不代表已完成智能切换
277
125
 
278
126
  ---
279
127
 
280
- ## 4. CLI 对比
128
+ ## 5. 语言支持对比
281
129
 
282
- ### Before: 功能有限
130
+ ### Before:TypeScript 中心化实现
283
131
 
284
- ```bash
285
- # 基础命令
286
- $ mycodemap generate
287
- $ mycodemap query -s "symbolName"
288
- $ mycodemap deps
289
-
290
- # 输出: 静态文本文件
291
- # - AI_MAP.md
292
- # - CONTEXT.md
293
- # - codemap.json
294
- ```
132
+ - 解析路径主要围绕 TypeScript/JavaScript 展开
133
+ - Go 能力存在,但注册与扩展策略不统一
134
+ - Python/更多语言更多停留在设计愿景
295
135
 
296
- ### After: 丰富的 CLI 可视化
136
+ ### After:可扩展契约已建立,当前落地 3 类实现
297
137
 
298
- ```bash
299
- # 树形视图
300
- $ mycodemap viz tree --depth 3
301
- 📁 src/
302
- ├── 📁 cli/
303
- │ ├── 📄 index.ts
304
- │ └── 📁 commands/
305
- └── 📁 core/
306
- └── 📄 analyzer.ts
307
-
308
- # ASCII 依赖图
309
- $ mycodemap viz deps --module src/core/analyzer.ts
310
- src/core/analyzer.ts
311
- ├── src/parser/index.ts
312
- ├── src/cache/index.ts
313
- └── src/types/index.ts
314
-
315
- # 复杂度热力图
316
- $ mycodemap viz heatmap --metric complexity
317
- 🔴 src/orchestrator/workflow.ts ████████████████ 45
318
- 🟡 src/cli/commands/query.ts ██████████ 28
319
- 🟢 src/cache/lru-cache.ts ████ 12
320
-
321
- # 带进度条的生成
322
- $ mycodemap generate
323
- [████████████████████] 85% | 正在分析 src/core/analyzer.ts
138
+ ```typescript
139
+ export function createDefaultParserRegistry(): ParserRegistry {
140
+ const registry = new ParserRegistry();
141
+ registry.register(new TypeScriptParser()); // ts/tsx/js/jsx/mjs/cjs
142
+ registry.register(new GoParser()); // go
143
+ registry.register(new PythonParser()); // py
144
+ return registry;
145
+ }
324
146
  ```
325
147
 
326
- ---
148
+ 当前事实:
327
149
 
328
- ## 5. 依赖关系对比
150
+ - **当前已落地实现**:TypeScript/JavaScript、Go、Python
151
+ - **接口仍预留未来语言 ID**:Java、Rust、C/C++ 等仍属于未来扩展空间
152
+ - **当前文档不再把“14 种语言”描述为已交付事实**
329
153
 
330
- ### Before: 混乱的依赖
154
+ ---
331
155
 
332
- ```
333
- cli/commands/generate.ts ─────┬─────▶ core/analyzer.ts
334
-
335
- cli/commands/query.ts ────────┤─────▶ core/analyzer.ts (重复依赖)
336
-
337
- cli/commands/impact.ts ───────┘─────▶ core/analyzer.ts (重复依赖)
338
-
339
-
340
- 难以测试,难以替换实现
341
- ```
156
+ ## 6. CLI 对比
342
157
 
343
- ### After: 清晰的依赖
158
+ ### Before:命令面宽、边界混
344
159
 
345
- ```
346
- ┌──────────────────────────────────────────────────────────┐
347
- │ CLI Layer │
348
- │ ↓ │
349
- │ 依赖: Server Layer 接口 │
350
- └──────────────────────────────────────────────────────────┘
351
-
352
-
353
- ┌──────────────────────────────────────────────────────────┐
354
- │ Server Layer │
355
- │ ↓ │
356
- │ 依赖: Domain Layer 接口 │
357
- └──────────────────────────────────────────────────────────┘
358
-
359
-
360
- ┌──────────────────────────────────────────────────────────┐
361
- │ Domain Layer │
362
- │ ↓ │
363
- │ 依赖: Interface Layer (类型定义) │
364
- └──────────────────────────────────────────────────────────┘
365
-
366
-
367
- ┌──────────────────────────────────────────────────────────┐
368
- │ Infrastructure Layer │
369
- │ ↓ │
370
- │ 依赖: Interface Layer (实现接口) │
371
- └──────────────────────────────────────────────────────────┘
372
-
373
-
374
- ┌──────────────────────────────────────────────────────────┐
375
- │ Interface Layer (无依赖,纯类型定义) │
376
- └──────────────────────────────────────────────────────────┘
160
+ ```bash
161
+ mycodemap generate
162
+ mycodemap query
163
+ mycodemap deps
377
164
  ```
378
165
 
379
- ---
166
+ 问题:
380
167
 
381
- ## 6. 测试对比
168
+ - CLI 直接携带业务逻辑
169
+ - 命令与内部能力命名边界不稳定
170
+ - 容易把工具误解成 watcher / report / server 工具箱
382
171
 
383
- ### Before: 难以测试
172
+ ### After:分析优先的公共 CLI
384
173
 
385
- ```typescript
386
- // ❌ 直接依赖文件系统,难以 mock
387
- // cli/commands/generate.test.ts
388
-
389
- it('should generate code map', async () => {
390
- // 无法隔离测试,必须操作真实文件
391
- await generateCommand({ output: '/tmp/test' });
392
-
393
- // 验证文件存在
394
- expect(fs.existsSync('/tmp/test/AI_MAP.md')).toBe(true);
395
- });
396
- // 测试慢,依赖外部环境
174
+ ```bash
175
+ mycodemap generate
176
+ mycodemap analyze find --keywords storage
177
+ mycodemap workflow start "trace auth dependency"
178
+ mycodemap export json
179
+ mycodemap ci check-docs-sync
397
180
  ```
398
181
 
399
- ### After: 易于测试
182
+ 当前事实:
400
183
 
401
- ```typescript
402
- // 通过接口注入依赖,易于 mock
403
- // server/usecases/GenerateCodeMap.test.ts
404
-
405
- it('should generate code map', async () => {
406
- // Mock 存储
407
- const mockStorage = {
408
- saveCodeGraph: vi.fn(),
409
- loadCodeGraph: vi.fn()
410
- };
411
-
412
- // Mock 解析器
413
- const mockParser = {
414
- parseFile: vi.fn().mockResolvedValue({ ... })
415
- };
416
-
417
- // 注入依赖
418
- const useCase = new GenerateCodeMapUseCase(
419
- mockStorage,
420
- mockParser
421
- );
422
-
423
- // 执行
424
- const result = await useCase.execute({
425
- projectPath: '/tmp/test',
426
- mode: 'fast'
427
- });
428
-
429
- // 验证
430
- expect(mockStorage.saveCodeGraph).toHaveBeenCalled();
431
- expect(result.success).toBe(true);
432
- });
433
- // 测试快,完全隔离
434
- ```
184
+ - `workflow` 是**analysis-only** 工作流能力,只保留 `find → read → link → show`
185
+ - `server`、`watch`、`report`、`logs` 已从 public CLI 移除,并提供迁移提示
186
+ - 文档不再把 `viz`、`tui` 等未落地命令写成当前产品事实
435
187
 
436
188
  ---
437
189
 
438
- ## 7. 性能对比
190
+ ## 7. 测试与验证对比
439
191
 
440
- | 指标 | Before | After | 提升 |
441
- |------|--------|-------|------|
442
- | 首次索引 (1000 文件) | ~30s | < 20s | 33% |
443
- | 符号查询 | ~500ms | < 10ms (GraphDB) | 50x |
444
- | 循环依赖检测 | ~3s | < 100ms (GraphDB) | 30x |
445
- | 影响分析 | ~2s | < 50ms (GraphDB) | 40x |
446
- | 内存占用 | ~500MB | ~400MB | 20% |
192
+ ### Before
447
193
 
448
- ---
194
+ - 很多能力只能通过端到端地操作真实文件验证
195
+ - 文档与实现边界更容易漂移
449
196
 
450
- ## 8. 扩展性对比
197
+ ### After
451
198
 
452
- ### 添加新存储后端
199
+ - `StorageFactory`、parser、plugin loader、server handlers/routes 都有定点测试
200
+ - `docs:check` 与 `ci check-docs-sync` 进入 must-pass / CI 路径
201
+ - `v1.3` 里程碑审计确认:`12/12` requirements、`4/4` phases、`4/4` integration、`4/4` flows
453
202
 
454
- | 步骤 | Before | After |
455
- |------|--------|-------|
456
- | 1 | 修改多处代码 | 实现 `IStorage` 接口 |
457
- | 2 | 处理兼容性问题 | 注册到 `StorageFactory` |
458
- | 3 | 测试回归 | 复用现有测试套件 |
459
- | **工作量** | **2-3 天** | **2-3 小时** |
203
+ ---
204
+
205
+ ## 8. 当前未交付 / Deferred
460
206
 
461
- ### 添加新语言支持
207
+ 以下能力属于历史设计目标或未来候选,不应再被理解为当前产品事实:
462
208
 
463
- | 步骤 | Before | After |
464
- |------|--------|-------|
465
- | 1 | 创建新文件,复制粘贴修改 | 实现 `ILanguageParser` |
466
- | 2 | 修改 parser/index.ts | 注册到 `ParserRegistry` |
467
- | 3 | 修改 cli 命令 | 自动识别文件扩展名 |
468
- | **工作量** | **1-2 天** | **4-8 小时** |
209
+ | 能力 | 当前状态 |
210
+ |------|----------|
211
+ | `neo4j` 正式支持 | 已移除出正式产品面 |
212
+ | 更丰富的自动后端切换启发式 | deferred;`auto` 当前保守落到 `filesystem` |
213
+ | Java / Rust / C/C++ 等更多 parser 实现 | 接口预留,未作为当前 shipped reality |
214
+ | `viz` / `tui` / CLI 可视化套件 | 未作为当前 public CLI 基线交付 |
215
+ | 公共 HTTP API / `mycodemap server` 产品面 | 未开放;`Server Layer` 仍是 internal-only |
469
216
 
470
217
  ---
471
218
 
472
219
  ## 9. 总结
473
220
 
474
- ```
475
- ┌─────────────────────────────────────────────────────────────────┐
476
- │ MVP3 架构重构价值 │
477
- ├─────────────────────────────────────────────────────────────────┤
478
- │ │
479
- │ 🎯 架构清晰性 │
480
- - 5 层架构,每层职责单一 │
481
- │ - 依赖方向明确,内层不依赖外层 │
482
- │ │
483
- │ 🔌 可扩展性 │
484
- │ - 存储可插拔: 文件系统 / KùzuDB / Neo4j │
485
- │ - 语言可扩展: 14 种语言支持 │
486
- │ - 可视化可扩展: CLI / TUI / Web │
487
- │ │
488
- │ 🧪 可测试性 │
489
- │ - 每层可独立单元测试 │
490
- │ - 依赖注入,易于 mock │
491
- │ - 测试覆盖率提升至 > 80% │
492
- │ │
493
- │ 🚀 性能提升 │
494
- │ - 图数据库加速复杂查询 (10-50x) │
495
- │ - Worker 线程并行解析 │
496
- │ - 智能存储选择策略 │
497
- │ │
498
- │ 👥 开发者体验 │
499
- │ - 丰富的 CLI 可视化 │
500
- │ - 进度条和实时反馈 │
501
- │ - 向后兼容,零成本迁移 │
502
- │ │
503
- └─────────────────────────────────────────────────────────────────┘
504
- ```
221
+ `MVP3` 的核心价值已经从“理想化设计图”收口成了当前可验证的产品基线:
222
+
223
+ - 5 层架构已在目录结构与职责边界上落地
224
+ - 存储面已稳定为 Kùzu-only 主线
225
+ - 解析器已具备可扩展注册机制,并落地 3 类实现
226
+ - 公共 CLI 已回到分析优先的可维护命令面
227
+ - 文档、测试与 CI 已能共同约束这些边界
228
+
229
+ 后续若要重新打开更多语言、公共 API、可视化或更激进的自动切换逻辑,应以**新 milestone** 的形式推进,而不是继续把设计愿景伪装成当前现实。