@mycodemap/mycodemap 0.1.1 → 0.3.4

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 (328) hide show
  1. package/CHANGELOG.md +163 -0
  2. package/README.md +241 -67
  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/export.d.ts +6 -0
  8. package/dist/cli/commands/export.d.ts.map +1 -0
  9. package/dist/cli/commands/export.js +108 -0
  10. package/dist/cli/commands/export.js.map +1 -0
  11. package/dist/cli/commands/generate.d.ts.map +1 -1
  12. package/dist/cli/commands/generate.js +96 -0
  13. package/dist/cli/commands/generate.js.map +1 -1
  14. package/dist/cli/commands/server.d.ts +9 -0
  15. package/dist/cli/commands/server.d.ts.map +1 -0
  16. package/dist/cli/commands/server.js +68 -0
  17. package/dist/cli/commands/server.js.map +1 -0
  18. package/dist/cli/commands/ship/analyzer.d.ts +26 -0
  19. package/dist/cli/commands/ship/analyzer.d.ts.map +1 -0
  20. package/dist/cli/commands/ship/analyzer.js +143 -0
  21. package/dist/cli/commands/ship/analyzer.js.map +1 -0
  22. package/dist/cli/commands/ship/checker.d.ts +20 -0
  23. package/dist/cli/commands/ship/checker.d.ts.map +1 -0
  24. package/dist/cli/commands/ship/checker.js +86 -0
  25. package/dist/cli/commands/ship/checker.js.map +1 -0
  26. package/dist/cli/commands/ship/index.d.ts +17 -0
  27. package/dist/cli/commands/ship/index.d.ts.map +1 -0
  28. package/dist/cli/commands/ship/index.js +51 -0
  29. package/dist/cli/commands/ship/index.js.map +1 -0
  30. package/dist/cli/commands/ship/monitor.d.ts +19 -0
  31. package/dist/cli/commands/ship/monitor.d.ts.map +1 -0
  32. package/dist/cli/commands/ship/monitor.js +105 -0
  33. package/dist/cli/commands/ship/monitor.js.map +1 -0
  34. package/dist/cli/commands/ship/pipeline.d.ts +23 -0
  35. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -0
  36. package/dist/cli/commands/ship/pipeline.js +146 -0
  37. package/dist/cli/commands/ship/pipeline.js.map +1 -0
  38. package/dist/cli/commands/ship/publisher.d.ts +11 -0
  39. package/dist/cli/commands/ship/publisher.d.ts.map +1 -0
  40. package/dist/cli/commands/ship/publisher.js +75 -0
  41. package/dist/cli/commands/ship/publisher.js.map +1 -0
  42. package/dist/cli/commands/ship/rules/confidence-rules.d.ts +48 -0
  43. package/dist/cli/commands/ship/rules/confidence-rules.d.ts.map +1 -0
  44. package/dist/cli/commands/ship/rules/confidence-rules.js +122 -0
  45. package/dist/cli/commands/ship/rules/confidence-rules.js.map +1 -0
  46. package/dist/cli/commands/ship/rules/quality-rules.d.ts +25 -0
  47. package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -0
  48. package/dist/cli/commands/ship/rules/quality-rules.js +134 -0
  49. package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -0
  50. package/dist/cli/commands/ship/rules/version-rules.d.ts +24 -0
  51. package/dist/cli/commands/ship/rules/version-rules.d.ts.map +1 -0
  52. package/dist/cli/commands/ship/rules/version-rules.js +75 -0
  53. package/dist/cli/commands/ship/rules/version-rules.js.map +1 -0
  54. package/dist/cli/commands/ship/versioner.d.ts +12 -0
  55. package/dist/cli/commands/ship/versioner.d.ts.map +1 -0
  56. package/dist/cli/commands/ship/versioner.js +92 -0
  57. package/dist/cli/commands/ship/versioner.js.map +1 -0
  58. package/dist/cli/index.js +31 -1
  59. package/dist/cli/index.js.map +1 -1
  60. package/dist/cli-new/commands/export.d.ts +15 -0
  61. package/dist/cli-new/commands/export.d.ts.map +1 -0
  62. package/dist/cli-new/commands/export.js +107 -0
  63. package/dist/cli-new/commands/export.js.map +1 -0
  64. package/dist/cli-new/commands/query.d.ts +14 -0
  65. package/dist/cli-new/commands/query.d.ts.map +1 -0
  66. package/dist/cli-new/commands/query.js +120 -0
  67. package/dist/cli-new/commands/query.js.map +1 -0
  68. package/dist/cli-new/commands/server.d.ts +13 -0
  69. package/dist/cli-new/commands/server.d.ts.map +1 -0
  70. package/dist/cli-new/commands/server.js +94 -0
  71. package/dist/cli-new/commands/server.js.map +1 -0
  72. package/dist/cli-new/index.d.ts +11 -0
  73. package/dist/cli-new/index.d.ts.map +1 -0
  74. package/dist/cli-new/index.js +63 -0
  75. package/dist/cli-new/index.js.map +1 -0
  76. package/dist/cli-new/types/index.d.ts +88 -0
  77. package/dist/cli-new/types/index.d.ts.map +1 -0
  78. package/dist/cli-new/types/index.js +7 -0
  79. package/dist/cli-new/types/index.js.map +1 -0
  80. package/dist/domain/entities/CodeGraph.d.ts +134 -0
  81. package/dist/domain/entities/CodeGraph.d.ts.map +1 -0
  82. package/dist/domain/entities/CodeGraph.js +316 -0
  83. package/dist/domain/entities/CodeGraph.js.map +1 -0
  84. package/dist/domain/entities/Dependency.d.ts +78 -0
  85. package/dist/domain/entities/Dependency.d.ts.map +1 -0
  86. package/dist/domain/entities/Dependency.js +132 -0
  87. package/dist/domain/entities/Dependency.js.map +1 -0
  88. package/dist/domain/entities/Module.d.ts +75 -0
  89. package/dist/domain/entities/Module.d.ts.map +1 -0
  90. package/dist/domain/entities/Module.js +151 -0
  91. package/dist/domain/entities/Module.js.map +1 -0
  92. package/dist/domain/entities/Project.d.ts +50 -0
  93. package/dist/domain/entities/Project.d.ts.map +1 -0
  94. package/dist/domain/entities/Project.js +99 -0
  95. package/dist/domain/entities/Project.js.map +1 -0
  96. package/dist/domain/entities/Symbol.d.ts +75 -0
  97. package/dist/domain/entities/Symbol.d.ts.map +1 -0
  98. package/dist/domain/entities/Symbol.js +130 -0
  99. package/dist/domain/entities/Symbol.js.map +1 -0
  100. package/dist/domain/events/DomainEvent.d.ts +76 -0
  101. package/dist/domain/events/DomainEvent.d.ts.map +1 -0
  102. package/dist/domain/events/DomainEvent.js +153 -0
  103. package/dist/domain/events/DomainEvent.js.map +1 -0
  104. package/dist/domain/index.d.ts +10 -0
  105. package/dist/domain/index.d.ts.map +1 -0
  106. package/dist/domain/index.js +18 -0
  107. package/dist/domain/index.js.map +1 -0
  108. package/dist/domain/repositories/CodeGraphRepository.d.ts +58 -0
  109. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -0
  110. package/dist/domain/repositories/CodeGraphRepository.js +37 -0
  111. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -0
  112. package/dist/domain/services/CodeGraphBuilder.d.ts +50 -0
  113. package/dist/domain/services/CodeGraphBuilder.d.ts.map +1 -0
  114. package/dist/domain/services/CodeGraphBuilder.js +121 -0
  115. package/dist/domain/services/CodeGraphBuilder.js.map +1 -0
  116. package/dist/infrastructure/parser/implementations/GoParser.d.ts +25 -0
  117. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -0
  118. package/dist/infrastructure/parser/implementations/GoParser.js +158 -0
  119. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -0
  120. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +30 -0
  121. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -0
  122. package/dist/infrastructure/parser/implementations/PythonParser.js +201 -0
  123. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -0
  124. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +63 -0
  125. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -0
  126. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +420 -0
  127. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -0
  128. package/dist/infrastructure/parser/index.d.ts +13 -0
  129. package/dist/infrastructure/parser/index.d.ts.map +1 -0
  130. package/dist/infrastructure/parser/index.js +32 -0
  131. package/dist/infrastructure/parser/index.js.map +1 -0
  132. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts +124 -0
  133. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -0
  134. package/dist/infrastructure/parser/interfaces/ParserBase.js +200 -0
  135. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -0
  136. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts +68 -0
  137. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts.map +1 -0
  138. package/dist/infrastructure/parser/registry/ParserRegistry.js +116 -0
  139. package/dist/infrastructure/parser/registry/ParserRegistry.js.map +1 -0
  140. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +44 -0
  141. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -0
  142. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +129 -0
  143. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -0
  144. package/dist/infrastructure/repositories/index.d.ts +3 -0
  145. package/dist/infrastructure/repositories/index.d.ts.map +1 -0
  146. package/dist/infrastructure/repositories/index.js +7 -0
  147. package/dist/infrastructure/repositories/index.js.map +1 -0
  148. package/dist/infrastructure/storage/StorageFactory.d.ts +53 -0
  149. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -0
  150. package/dist/infrastructure/storage/StorageFactory.js +150 -0
  151. package/dist/infrastructure/storage/StorageFactory.js.map +1 -0
  152. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +52 -0
  153. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -0
  154. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +315 -0
  155. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -0
  156. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +52 -0
  157. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -0
  158. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +235 -0
  159. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -0
  160. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +37 -0
  161. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -0
  162. package/dist/infrastructure/storage/adapters/MemoryStorage.js +229 -0
  163. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -0
  164. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +49 -0
  165. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
  166. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +222 -0
  167. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
  168. package/dist/infrastructure/storage/index.d.ts +6 -0
  169. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  170. package/dist/infrastructure/storage/index.js +13 -0
  171. package/dist/infrastructure/storage/index.js.map +1 -0
  172. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +76 -0
  173. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -0
  174. package/dist/infrastructure/storage/interfaces/StorageBase.js +116 -0
  175. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -0
  176. package/dist/interface/config/index.d.ts +102 -0
  177. package/dist/interface/config/index.d.ts.map +1 -0
  178. package/dist/interface/config/index.js +7 -0
  179. package/dist/interface/config/index.js.map +1 -0
  180. package/dist/interface/types/index.d.ts +425 -0
  181. package/dist/interface/types/index.d.ts.map +1 -0
  182. package/dist/interface/types/index.js +8 -0
  183. package/dist/interface/types/index.js.map +1 -0
  184. package/dist/interface/types/parser.d.ts +103 -0
  185. package/dist/interface/types/parser.d.ts.map +1 -0
  186. package/dist/interface/types/parser.js +7 -0
  187. package/dist/interface/types/parser.js.map +1 -0
  188. package/dist/interface/types/storage.d.ts +98 -0
  189. package/dist/interface/types/storage.d.ts.map +1 -0
  190. package/dist/interface/types/storage.js +7 -0
  191. package/dist/interface/types/storage.js.map +1 -0
  192. package/dist/orchestrator/test-linker.js +1 -1
  193. package/dist/orchestrator/test-linker.js.map +1 -1
  194. package/dist/server/CodeMapServer.d.ts +51 -0
  195. package/dist/server/CodeMapServer.d.ts.map +1 -0
  196. package/dist/server/CodeMapServer.js +146 -0
  197. package/dist/server/CodeMapServer.js.map +1 -0
  198. package/dist/server/handlers/AnalysisHandler.d.ts +82 -0
  199. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -0
  200. package/dist/server/handlers/AnalysisHandler.js +196 -0
  201. package/dist/server/handlers/AnalysisHandler.js.map +1 -0
  202. package/dist/server/handlers/QueryHandler.d.ts +57 -0
  203. package/dist/server/handlers/QueryHandler.d.ts.map +1 -0
  204. package/dist/server/handlers/QueryHandler.js +260 -0
  205. package/dist/server/handlers/QueryHandler.js.map +1 -0
  206. package/dist/server/index.d.ts +7 -0
  207. package/dist/server/index.d.ts.map +1 -0
  208. package/dist/server/index.js +13 -0
  209. package/dist/server/index.js.map +1 -0
  210. package/dist/server/routes/api.d.ts +8 -0
  211. package/dist/server/routes/api.d.ts.map +1 -0
  212. package/dist/server/routes/api.js +372 -0
  213. package/dist/server/routes/api.js.map +1 -0
  214. package/dist/server/types/index.d.ts +171 -0
  215. package/dist/server/types/index.d.ts.map +1 -0
  216. package/dist/server/types/index.js +7 -0
  217. package/dist/server/types/index.js.map +1 -0
  218. package/dist/types/index.d.ts +6 -372
  219. package/dist/types/index.d.ts.map +1 -1
  220. package/dist/types/index.js +9 -3
  221. package/dist/types/index.js.map +1 -1
  222. package/docs/AI_ASSISTANT_SETUP.md +68 -0
  223. package/docs/PUBLISHING.md +472 -0
  224. package/docs/README.md +37 -0
  225. package/docs/SETUP_GUIDE.md +91 -5
  226. package/docs/ai-guide/COMMANDS.md +403 -0
  227. package/docs/ai-guide/INTEGRATION.md +513 -0
  228. package/docs/ai-guide/OUTPUT.md +465 -0
  229. package/docs/ai-guide/PATTERNS.md +409 -0
  230. package/docs/ai-guide/PROMPTS.md +414 -0
  231. package/docs/ai-guide/QUICKSTART.md +114 -0
  232. package/docs/ai-guide/README.md +66 -0
  233. package/docs/archive/AI_INTEGRATION_GUIDE_ARCHIVED.md +7 -1
  234. package/docs/archive/ARCHIVE.md +39 -0
  235. package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
  236. package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +6 -0
  237. package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +6 -0
  238. package/docs/archive/README.md +29 -0
  239. package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +6 -0
  240. package/docs/archive/TEST_SUMMARY.md +140 -0
  241. package/docs/archive/comprehensive_test_report.md +337 -0
  242. package/docs/{CI_GATEWAY_DESIGN.md → archive/design-docs/CI_GATEWAY_DESIGN.md} +6 -0
  243. package/docs/{PUBLISH_NPM_DESIGN_FINAL.md → archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md} +7 -1
  244. package/docs/{REFACTOR_ARCHITECTURE_OVERVIEW.md → archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md} +8 -2
  245. package/docs/{REFACTOR_CONFIDENCE_DESIGN.md → archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md} +6 -0
  246. package/docs/{REFACTOR_GIT_ANALYZER_DESIGN.md → archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md} +8 -2
  247. package/docs/{REFACTOR_ORCHESTRATOR_DESIGN.md → archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md} +6 -0
  248. package/docs/{REFACTOR_RESULT_FUSION_DESIGN.md → archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md} +6 -0
  249. package/docs/{REFACTOR_TEST_LINKER_DESIGN.md → archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md} +6 -0
  250. package/docs/archive/myclaude.md +1084 -0
  251. package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
  252. package/docs/{REFACTOR_REQUIREMENTS.md → archive/product-specs/REFACTOR_REQUIREMENTS.md} +11 -5
  253. package/docs/archive/scenario-2-deps-analysis.md +353 -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/{plans/POST_TASK_PLAN.md → exec-plans/completed/2026-03-03-post-task-plan.md} +9 -3
  260. package/docs/exec-plans/completed/harness-engineering-rollout.md +184 -0
  261. package/docs/exec-plans/tech-debt/.gitkeep +0 -0
  262. package/docs/exec-plans/tech-debt/2026-03-15-lint-guardrail-gap.md +30 -0
  263. package/docs/generated/README.md +19 -0
  264. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +504 -0
  265. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +322 -0
  266. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +1374 -0
  267. package/docs/product-specs/README.md +22 -0
  268. package/docs/references/README.md +15 -0
  269. package/docs/references/tmp.md +527 -0
  270. package/docs/rules/README.md +16 -0
  271. package/docs/rules/architecture-guardrails.md +349 -0
  272. package/docs/rules/code-quality-redlines.md +321 -0
  273. package/docs/rules/deployment.md +23 -0
  274. package/docs/rules/engineering-with-codex-openai.md +202 -0
  275. package/docs/rules/pre-release-checklist.md +426 -0
  276. package/docs/rules/testing.md +73 -0
  277. package/docs/rules/validation.md +39 -0
  278. package/package.json +26 -7
  279. package/scripts/.githooks/commit-msg +31 -0
  280. package/scripts/.githooks/pre-commit +55 -0
  281. package/scripts/benchmark.ts +209 -0
  282. package/scripts/hooks/commit-msg +24 -0
  283. package/scripts/hooks/install-hooks.sh +29 -0
  284. package/scripts/hooks/pre-commit +60 -0
  285. package/scripts/pre-release-check.js +717 -0
  286. package/scripts/release.sh +142 -0
  287. package/scripts/run-benchmark.sh +29 -0
  288. package/scripts/validate-ai-docs.js +294 -0
  289. package/scripts/validate-docs.js +238 -0
  290. package/scripts/validate-pack.js +86 -0
  291. package/dist/ai/claude.d.ts +0 -38
  292. package/dist/ai/claude.d.ts.map +0 -1
  293. package/dist/ai/claude.js +0 -169
  294. package/dist/ai/claude.js.map +0 -1
  295. package/dist/ai/codex.d.ts +0 -38
  296. package/dist/ai/codex.d.ts.map +0 -1
  297. package/dist/ai/codex.js +0 -169
  298. package/dist/ai/codex.js.map +0 -1
  299. package/dist/ai/factory.d.ts +0 -48
  300. package/dist/ai/factory.d.ts.map +0 -1
  301. package/dist/ai/factory.js +0 -95
  302. package/dist/ai/factory.js.map +0 -1
  303. package/dist/ai/index.d.ts +0 -12
  304. package/dist/ai/index.d.ts.map +0 -1
  305. package/dist/ai/index.js +0 -29
  306. package/dist/ai/index.js.map +0 -1
  307. package/dist/ai/provider.d.ts +0 -70
  308. package/dist/ai/provider.d.ts.map +0 -1
  309. package/dist/ai/provider.js +0 -31
  310. package/dist/ai/provider.js.map +0 -1
  311. package/dist/ai/subagent-caller.d.ts +0 -90
  312. package/dist/ai/subagent-caller.d.ts.map +0 -1
  313. package/dist/ai/subagent-caller.js +0 -280
  314. package/dist/ai/subagent-caller.js.map +0 -1
  315. package/dist/ai/types.d.ts +0 -70
  316. package/dist/ai/types.d.ts.map +0 -1
  317. package/dist/ai/types.js +0 -5
  318. package/dist/ai/types.js.map +0 -1
  319. package/dist/generator/ai-overview.d.ts +0 -51
  320. package/dist/generator/ai-overview.d.ts.map +0 -1
  321. package/dist/generator/ai-overview.js +0 -160
  322. package/dist/generator/ai-overview.js.map +0 -1
  323. package/dist/orchestrator/ai-feed-generator.d.ts +0 -210
  324. package/dist/orchestrator/ai-feed-generator.d.ts.map +0 -1
  325. package/dist/orchestrator/ai-feed-generator.js +0 -377
  326. package/dist/orchestrator/ai-feed-generator.js.map +0 -1
  327. package/docs/OMC_TEAM_DEBUG_REPORT.md +0 -285
  328. /package/docs/{plans/archive → exec-plans/completed}/2026-03-03-deps-path-extension-fix.md +0 -0
@@ -0,0 +1,504 @@
1
+ # MVP3 架构对比:Before vs After
2
+
3
+ > 本文档对比展示 CodeMap MVP3 架构重构前后的差异
4
+
5
+ ---
6
+
7
+ ## 1. 架构总览对比
8
+
9
+ ### Before (当前架构)
10
+
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
+ ```
60
+
61
+ ### After (MVP3 架构)
62
+
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
+ ```
133
+
134
+ ---
135
+
136
+ ## 2. 存储层对比
137
+
138
+ ### Before: 硬编码文件系统
139
+
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
+ }
161
+
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
+ }
170
+ ```
171
+
172
+ ### After: 存储抽象接口
173
+
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
+ }
187
+
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
+ }
202
+
203
+ // 存储选择
204
+ const storage = await storageFactory.create({
205
+ type: 'auto', // 根据项目规模自动选择
206
+ autoThresholds: {
207
+ useGraphDBWhenFileCount: 500
208
+ }
209
+ });
210
+ // < 500 文件: FileSystemStorage
211
+ // >= 500 文件: KuzuDBStorage
212
+ ```
213
+
214
+ ---
215
+
216
+ ## 3. 语言支持对比
217
+
218
+ ### Before: 硬编码 TypeScript
219
+
220
+ ```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
+ }
240
+ ```
241
+
242
+ ### After: 可插拔语言解析器
243
+
244
+ ```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[]>;
254
+ }
255
+
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
+ }
270
+
271
+ // 注册新语言只需一行
272
+ parserRegistry.register(new PythonParser());
273
+ parserRegistry.register(new JavaParser());
274
+ parserRegistry.register(new RustParser());
275
+ // ... 共 14 种语言
276
+ ```
277
+
278
+ ---
279
+
280
+ ## 4. CLI 对比
281
+
282
+ ### Before: 功能有限
283
+
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
+ ```
295
+
296
+ ### After: 丰富的 CLI 可视化
297
+
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
324
+ ```
325
+
326
+ ---
327
+
328
+ ## 5. 依赖关系对比
329
+
330
+ ### Before: 混乱的依赖
331
+
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
+ ```
342
+
343
+ ### After: 清晰的依赖
344
+
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
+ └──────────────────────────────────────────────────────────┘
377
+ ```
378
+
379
+ ---
380
+
381
+ ## 6. 测试对比
382
+
383
+ ### Before: 难以测试
384
+
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
+ // 测试慢,依赖外部环境
397
+ ```
398
+
399
+ ### After: 易于测试
400
+
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
+ ```
435
+
436
+ ---
437
+
438
+ ## 7. 性能对比
439
+
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% |
447
+
448
+ ---
449
+
450
+ ## 8. 扩展性对比
451
+
452
+ ### 添加新存储后端
453
+
454
+ | 步骤 | Before | After |
455
+ |------|--------|-------|
456
+ | 1 | 修改多处代码 | 实现 `IStorage` 接口 |
457
+ | 2 | 处理兼容性问题 | 注册到 `StorageFactory` |
458
+ | 3 | 测试回归 | 复用现有测试套件 |
459
+ | **工作量** | **2-3 天** | **2-3 小时** |
460
+
461
+ ### 添加新语言支持
462
+
463
+ | 步骤 | Before | After |
464
+ |------|--------|-------|
465
+ | 1 | 创建新文件,复制粘贴修改 | 实现 `ILanguageParser` |
466
+ | 2 | 修改 parser/index.ts | 注册到 `ParserRegistry` |
467
+ | 3 | 修改 cli 命令 | 自动识别文件扩展名 |
468
+ | **工作量** | **1-2 天** | **4-8 小时** |
469
+
470
+ ---
471
+
472
+ ## 9. 总结
473
+
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
+ ```