@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,200 @@
1
+ // [META] since:2026-03 | owner:architecture-team | stable:true
2
+ // [WHY] Parser base class - provides common functionality for all language parsers
3
+ // ============================================
4
+ // 解析器基类 - 为所有语言解析器提供通用功能
5
+ // ============================================
6
+ /**
7
+ * 解析错误
8
+ */
9
+ export class ParseError extends Error {
10
+ filePath;
11
+ line;
12
+ column;
13
+ constructor(message, filePath, line, column) {
14
+ super(message);
15
+ this.filePath = filePath;
16
+ this.line = line;
17
+ this.column = column;
18
+ this.name = 'ParseError';
19
+ }
20
+ }
21
+ /**
22
+ * 解析器基类
23
+ *
24
+ * 为所有语言解析器提供:
25
+ * - 通用的初始化和资源管理
26
+ * - 批量解析的默认实现
27
+ * - 特性支持检测框架
28
+ * - 性能统计
29
+ */
30
+ export class ParserBase {
31
+ /** 是否已初始化 */
32
+ isInitialized = false;
33
+ /** 解析统计 */
34
+ stats = {
35
+ totalParsed: 0,
36
+ totalErrors: 0,
37
+ totalTime: 0,
38
+ };
39
+ /**
40
+ * 初始化解析器
41
+ */
42
+ async initialize() {
43
+ await this.doInitialize();
44
+ this.isInitialized = true;
45
+ }
46
+ /**
47
+ * 释放解析器资源
48
+ */
49
+ async dispose() {
50
+ await this.doDispose();
51
+ this.isInitialized = false;
52
+ }
53
+ /**
54
+ * 确保已初始化
55
+ */
56
+ ensureInitialized() {
57
+ if (!this.isInitialized) {
58
+ throw new ParseError(`Parser ${this.name} not initialized. Call initialize() first.`);
59
+ }
60
+ }
61
+ /**
62
+ * 批量解析文件(默认实现)
63
+ */
64
+ async parseFiles(files, options) {
65
+ this.ensureInitialized();
66
+ const results = [];
67
+ for (const file of files) {
68
+ try {
69
+ const result = await this.parseFile(file.path, file.content, options);
70
+ results.push(result);
71
+ }
72
+ catch (error) {
73
+ // 记录错误但继续解析其他文件
74
+ this.stats.totalErrors++;
75
+ results.push(this.createErrorResult(file.path, error));
76
+ }
77
+ }
78
+ return results;
79
+ }
80
+ /**
81
+ * 构建调用图(可选实现)
82
+ */
83
+ async buildCallGraph(content) {
84
+ // 默认空实现
85
+ return {
86
+ calls: [],
87
+ recursive: [],
88
+ };
89
+ }
90
+ /**
91
+ * 计算复杂度(可选实现)
92
+ */
93
+ async calculateComplexity(content) {
94
+ // 默认实现:基础统计
95
+ const lines = content.split('\n').length;
96
+ return {
97
+ cyclomatic: 1,
98
+ cognitive: 1,
99
+ maintainability: 100,
100
+ details: {
101
+ functions: [{
102
+ name: '<file>',
103
+ cyclomatic: 1,
104
+ cognitive: 1,
105
+ lines,
106
+ }],
107
+ },
108
+ };
109
+ }
110
+ /**
111
+ * 检测是否支持某特性
112
+ */
113
+ supportsFeature(feature) {
114
+ return this.supportedFeatures.has(feature);
115
+ }
116
+ /**
117
+ * 获取支持的特性列表
118
+ */
119
+ getSupportedFeatures() {
120
+ return Array.from(this.supportedFeatures);
121
+ }
122
+ /**
123
+ * 获取解析统计
124
+ */
125
+ getStats() {
126
+ return { ...this.stats };
127
+ }
128
+ /**
129
+ * 重置统计
130
+ */
131
+ resetStats() {
132
+ this.stats = { totalParsed: 0, totalErrors: 0, totalTime: 0 };
133
+ }
134
+ /**
135
+ * 创建错误结果
136
+ */
137
+ createErrorResult(filePath, error) {
138
+ return {
139
+ filePath,
140
+ language: this.languageId,
141
+ module: this.createEmptyModule(filePath),
142
+ symbols: [],
143
+ imports: [],
144
+ exports: [],
145
+ dependencies: [],
146
+ parseTime: 0,
147
+ errors: [{
148
+ line: 0,
149
+ column: 0,
150
+ message: error instanceof Error ? error.message : String(error),
151
+ severity: 'error',
152
+ }],
153
+ };
154
+ }
155
+ /**
156
+ * 创建空模块
157
+ */
158
+ createEmptyModule(filePath) {
159
+ return {
160
+ id: `mod_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`,
161
+ projectId: '',
162
+ path: filePath,
163
+ language: this.languageId,
164
+ stats: {
165
+ lines: 0,
166
+ codeLines: 0,
167
+ commentLines: 0,
168
+ blankLines: 0,
169
+ },
170
+ };
171
+ }
172
+ /**
173
+ * 统计代码行数
174
+ */
175
+ countLines(content) {
176
+ const lines = content.split('\n');
177
+ let code = 0;
178
+ let comment = 0;
179
+ let blank = 0;
180
+ for (const line of lines) {
181
+ const trimmed = line.trim();
182
+ if (trimmed.length === 0) {
183
+ blank++;
184
+ }
185
+ else if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
186
+ comment++;
187
+ }
188
+ else {
189
+ code++;
190
+ }
191
+ }
192
+ return {
193
+ total: lines.length,
194
+ code,
195
+ comment,
196
+ blank,
197
+ };
198
+ }
199
+ }
200
+ //# sourceMappingURL=ParserBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserBase.js","sourceRoot":"","sources":["../../../../src/infrastructure/parser/interfaces/ParserBase.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,mFAAmF;AACnF,+CAA+C;AAC/C,yBAAyB;AACzB,+CAA+C;AAkB/C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGjB;IACA;IACA;IAJlB,YACE,OAAe,EACC,QAAiB,EACjB,IAAa,EACb,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,aAAQ,GAAR,QAAQ,CAAS;QACjB,SAAI,GAAJ,IAAI,CAAS;QACb,WAAM,GAAN,MA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AK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3F,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,IAAI,EAAE,CAAC;YACT,CAAC;QACH,CAAC;QAED,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,IAAI;YACJ,OAAO;YACP,KAAK;SACN,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,68 @@
1
+ import type { ILanguageParser, IParserRegistry, LanguageId } from '../../../interface/types/parser.js';
2
+ /**
3
+ * 解析器未找到错误
4
+ */
5
+ export declare class ParserNotFoundError extends Error {
6
+ constructor(identifier: string);
7
+ }
8
+ /**
9
+ * 解析器注册表实现
10
+ *
11
+ * 职责:
12
+ * - 管理所有注册的解析器
13
+ * - 根据语言 ID 或文件扩展名查找解析器
14
+ * - 提供支持的语言和扩展名列表
15
+ */
16
+ export declare class ParserRegistry implements IParserRegistry {
17
+ private parsers;
18
+ private extensionMap;
19
+ /**
20
+ * 注册解析器
21
+ */
22
+ register(parser: ILanguageParser): void;
23
+ /**
24
+ * 根据语言 ID 获取解析器
25
+ */
26
+ getParser(language: LanguageId): ILanguageParser | undefined;
27
+ /**
28
+ * 根据文件路径获取解析器
29
+ */
30
+ getParserByFile(filePath: string): ILanguageParser | undefined;
31
+ /**
32
+ * 获取所有支持的扩展名
33
+ */
34
+ getSupportedExtensions(): string[];
35
+ /**
36
+ * 获取所有支持的语言
37
+ */
38
+ getSupportedLanguages(): LanguageId[];
39
+ /**
40
+ * 检查是否支持某语言
41
+ */
42
+ hasLanguage(language: LanguageId): boolean;
43
+ /**
44
+ * 检查是否支持某文件扩展名
45
+ */
46
+ hasExtension(ext: string): boolean;
47
+ /**
48
+ * 取消注册解析器
49
+ */
50
+ unregister(language: LanguageId): void;
51
+ /**
52
+ * 清空所有解析器
53
+ */
54
+ clear(): void;
55
+ /**
56
+ * 获取已注册解析器数量
57
+ */
58
+ get size(): number;
59
+ /**
60
+ * 提取文件扩展名
61
+ */
62
+ private extractExtension;
63
+ }
64
+ /**
65
+ * 默认解析器注册表实例
66
+ */
67
+ export declare const parserRegistry: ParserRegistry;
68
+ //# sourceMappingURL=ParserRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserRegistry.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/parser/registry/ParserRegistry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,UAAU,EACX,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,UAAU,EAAE,MAAM;CAI/B;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,YAAY,CAAiC;IAErD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IASvC;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS;IAI5D;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAU9D;;OAEG;IACH,sBAAsB,IAAI,MAAM,EAAE;IAIlC;;OAEG;IACH,qBAAqB,IAAI,UAAU,EAAE;IAIrC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO;IAI1C;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIlC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IAWtC;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAIzB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,116 @@
1
+ // [META] since:2026-03 | owner:architecture-team | stable:true
2
+ // [WHY] Parser registry - manages language parsers and file extension mappings
3
+ // ============================================
4
+ // 解析器注册表 - 管理语言解析器和文件扩展名映射
5
+ // ============================================
6
+ /**
7
+ * 解析器未找到错误
8
+ */
9
+ export class ParserNotFoundError extends Error {
10
+ constructor(identifier) {
11
+ super(`No parser found for: ${identifier}`);
12
+ this.name = 'ParserNotFoundError';
13
+ }
14
+ }
15
+ /**
16
+ * 解析器注册表实现
17
+ *
18
+ * 职责:
19
+ * - 管理所有注册的解析器
20
+ * - 根据语言 ID 或文件扩展名查找解析器
21
+ * - 提供支持的语言和扩展名列表
22
+ */
23
+ export class ParserRegistry {
24
+ parsers = new Map();
25
+ extensionMap = new Map();
26
+ /**
27
+ * 注册解析器
28
+ */
29
+ register(parser) {
30
+ this.parsers.set(parser.languageId, parser);
31
+ // 注册扩展名映射
32
+ for (const ext of parser.fileExtensions) {
33
+ this.extensionMap.set(ext.toLowerCase(), parser.languageId);
34
+ }
35
+ }
36
+ /**
37
+ * 根据语言 ID 获取解析器
38
+ */
39
+ getParser(language) {
40
+ return this.parsers.get(language);
41
+ }
42
+ /**
43
+ * 根据文件路径获取解析器
44
+ */
45
+ getParserByFile(filePath) {
46
+ const ext = this.extractExtension(filePath);
47
+ if (!ext)
48
+ return undefined;
49
+ const languageId = this.extensionMap.get(ext.toLowerCase());
50
+ if (!languageId)
51
+ return undefined;
52
+ return this.parsers.get(languageId);
53
+ }
54
+ /**
55
+ * 获取所有支持的扩展名
56
+ */
57
+ getSupportedExtensions() {
58
+ return Array.from(this.extensionMap.keys());
59
+ }
60
+ /**
61
+ * 获取所有支持的语言
62
+ */
63
+ getSupportedLanguages() {
64
+ return Array.from(this.parsers.keys());
65
+ }
66
+ /**
67
+ * 检查是否支持某语言
68
+ */
69
+ hasLanguage(language) {
70
+ return this.parsers.has(language);
71
+ }
72
+ /**
73
+ * 检查是否支持某文件扩展名
74
+ */
75
+ hasExtension(ext) {
76
+ return this.extensionMap.has(ext.toLowerCase());
77
+ }
78
+ /**
79
+ * 取消注册解析器
80
+ */
81
+ unregister(language) {
82
+ const parser = this.parsers.get(language);
83
+ if (parser) {
84
+ // 清理扩展名映射
85
+ for (const ext of parser.fileExtensions) {
86
+ this.extensionMap.delete(ext.toLowerCase());
87
+ }
88
+ this.parsers.delete(language);
89
+ }
90
+ }
91
+ /**
92
+ * 清空所有解析器
93
+ */
94
+ clear() {
95
+ this.parsers.clear();
96
+ this.extensionMap.clear();
97
+ }
98
+ /**
99
+ * 获取已注册解析器数量
100
+ */
101
+ get size() {
102
+ return this.parsers.size;
103
+ }
104
+ /**
105
+ * 提取文件扩展名
106
+ */
107
+ extractExtension(filePath) {
108
+ const match = filePath.match(/\.([^.]+)$/);
109
+ return match?.[1];
110
+ }
111
+ }
112
+ /**
113
+ * 默认解析器注册表实例
114
+ */
115
+ export const parserRegistry = new ParserRegistry();
116
+ //# sourceMappingURL=ParserRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserRegistry.js","sourceRoot":"","sources":["../../../../src/infrastructure/parser/registry/ParserRegistry.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+EAA+E;AAC/E,+CAA+C;AAC/C,2BAA2B;AAC3B,+CAA+C;AAQ/C;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,UAAkB;QAC5B,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACjB,OAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;IACjD,YAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;IAErD;;OAEG;IACH,QAAQ,CAAC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C,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,QAAoB;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,UAAU;YACV,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;gBACxC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,QAAgB;QACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3C,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { IStorage } from '../storage/index.js';
2
+ import { CodeGraph } from '../../domain/entities/CodeGraph.js';
3
+ import type { CodeGraphRepository } from '../../domain/repositories/CodeGraphRepository.js';
4
+ /**
5
+ * CodeGraphRepository 实现
6
+ *
7
+ * 职责:
8
+ * - 实现领域层定义的仓库接口
9
+ * - 使用 Infrastructure 层的存储适配器进行持久化
10
+ * - 处理实体转换和一致性维护
11
+ */
12
+ export declare class CodeGraphRepositoryImpl implements CodeGraphRepository {
13
+ private storage;
14
+ constructor(storage: IStorage);
15
+ /**
16
+ * 保存代码图
17
+ */
18
+ save(graph: CodeGraph): Promise<void>;
19
+ /**
20
+ * 根据项目 ID 查找代码图
21
+ */
22
+ findByProjectId(projectId: string): Promise<CodeGraph | null>;
23
+ /**
24
+ * 根据项目路径查找代码图
25
+ */
26
+ findByProjectPath(projectPath: string): Promise<CodeGraph | null>;
27
+ /**
28
+ * 检查项目是否存在
29
+ */
30
+ exists(projectId: string): Promise<boolean>;
31
+ /**
32
+ * 删除项目代码图
33
+ */
34
+ delete(projectId: string): Promise<void>;
35
+ /**
36
+ * 获取所有保存的项目 ID
37
+ */
38
+ getAllProjectIds(): Promise<string[]>;
39
+ /**
40
+ * 创建仓库实例的工厂方法
41
+ */
42
+ static create(storage: IStorage): CodeGraphRepositoryImpl;
43
+ }
44
+ //# sourceMappingURL=CodeGraphRepositoryImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeGraphRepositoryImpl.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CodeGraphRepositoryImpl.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAG5F;;;;;;;GAOG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACrD,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IAErC;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAyBnE;;OAEG;IACG,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAuBvE;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASjD;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAc3C;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,uBAAuB;CAG1D"}
@@ -0,0 +1,129 @@
1
+ // [META] since:2026-03 | owner:architecture-team | stable:true
2
+ // [WHY] CodeGraphRepository implementation - bridges Domain and Infrastructure layers
3
+ // ============================================
4
+ // CodeGraphRepository 实现 - 连接 Domain 层和 Infrastructure 层
5
+ // ============================================
6
+ import { CodeGraph } from '../../domain/entities/CodeGraph.js';
7
+ import { RepositoryError, EntityNotFoundError } from '../../domain/repositories/CodeGraphRepository.js';
8
+ /**
9
+ * CodeGraphRepository 实现
10
+ *
11
+ * 职责:
12
+ * - 实现领域层定义的仓库接口
13
+ * - 使用 Infrastructure 层的存储适配器进行持久化
14
+ * - 处理实体转换和一致性维护
15
+ */
16
+ export class CodeGraphRepositoryImpl {
17
+ storage;
18
+ constructor(storage) {
19
+ this.storage = storage;
20
+ }
21
+ /**
22
+ * 保存代码图
23
+ */
24
+ async save(graph) {
25
+ try {
26
+ await this.storage.saveCodeGraph(graph.toInterface());
27
+ }
28
+ catch (error) {
29
+ throw new RepositoryError('Failed to save code graph', 'SAVE_FAILED', error);
30
+ }
31
+ }
32
+ /**
33
+ * 根据项目 ID 查找代码图
34
+ */
35
+ async findByProjectId(projectId) {
36
+ try {
37
+ // 加载完整图数据
38
+ const graphData = await this.storage.loadCodeGraph();
39
+ // 检查项目 ID 是否匹配
40
+ if (graphData.project.id !== projectId) {
41
+ return null;
42
+ }
43
+ // 转换为领域实体
44
+ return CodeGraph.fromInterface(graphData);
45
+ }
46
+ catch (error) {
47
+ if (error.code === 'ENOENT' ||
48
+ error.message?.includes('not found')) {
49
+ return null;
50
+ }
51
+ throw new RepositoryError(`Failed to find code graph for project ${projectId}`, 'FIND_FAILED', error);
52
+ }
53
+ }
54
+ /**
55
+ * 根据项目路径查找代码图
56
+ */
57
+ async findByProjectPath(projectPath) {
58
+ try {
59
+ const graphData = await this.storage.loadCodeGraph();
60
+ // 检查项目路径是否匹配
61
+ if (graphData.project.rootPath !== projectPath) {
62
+ return null;
63
+ }
64
+ return CodeGraph.fromInterface(graphData);
65
+ }
66
+ catch (error) {
67
+ if (error.code === 'ENOENT' ||
68
+ error.message?.includes('not found')) {
69
+ return null;
70
+ }
71
+ throw new RepositoryError(`Failed to find code graph for path ${projectPath}`, 'FIND_FAILED', error);
72
+ }
73
+ }
74
+ /**
75
+ * 检查项目是否存在
76
+ */
77
+ async exists(projectId) {
78
+ try {
79
+ const graph = await this.findByProjectId(projectId);
80
+ return graph !== null;
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ }
86
+ /**
87
+ * 删除项目代码图
88
+ */
89
+ async delete(projectId) {
90
+ try {
91
+ // 验证项目存在
92
+ const exists = await this.exists(projectId);
93
+ if (!exists) {
94
+ throw new EntityNotFoundError('Project', projectId);
95
+ }
96
+ await this.storage.deleteProject();
97
+ }
98
+ catch (error) {
99
+ if (error instanceof EntityNotFoundError) {
100
+ throw error;
101
+ }
102
+ throw new RepositoryError(`Failed to delete project ${projectId}`, 'DELETE_FAILED', error);
103
+ }
104
+ }
105
+ /**
106
+ * 获取所有保存的项目 ID
107
+ */
108
+ async getAllProjectIds() {
109
+ try {
110
+ const graphData = await this.storage.loadCodeGraph();
111
+ // 单个存储实例只对应一个项目
112
+ // 过滤掉空 ID(未初始化的空图)
113
+ if (graphData.project.id && graphData.project.id.trim() !== '') {
114
+ return [graphData.project.id];
115
+ }
116
+ return [];
117
+ }
118
+ catch {
119
+ return [];
120
+ }
121
+ }
122
+ /**
123
+ * 创建仓库实例的工厂方法
124
+ */
125
+ static create(storage) {
126
+ return new CodeGraphRepositoryImpl(storage);
127
+ }
128
+ }
129
+ //# sourceMappingURL=CodeGraphRepositoryImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeGraphRepositoryImpl.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CodeGraphRepositoryImpl.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sFAAsF;AACtF,+CAA+C;AAC/C,yDAAyD;AACzD,+CAA+C;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAExG;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAuB;IACd;IAApB,YAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,KAAgB;QACzB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,eAAe,CACvB,2BAA2B,EAC3B,aAAa,EACb,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB;QACrC,IAAI,CAAC;YACH,UAAU;YACV,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YAErD,eAAe;YACf,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,UAAU;YACV,OAAO,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA2B,CAAC,IAAI,KAAK,QAAQ;gBAC7C,KAAe,CAAC,OAAO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Z,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACtD,CAAC;YAED,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;gBACzC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,eAAe,CACvB,4BAA4B,SAAS,EAAE,EACvC,eAAe,EACf,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB;QACpB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACrD,gBAAgB;YAChB,mBAAmB;YACnB,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC/D,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAiB;QAC7B,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { CodeGraphRepositoryImpl } from './CodeGraphRepositoryImpl.js';
2
+ export type { CodeGraphRepository, RepositoryError, EntityNotFoundError, ConcurrencyConflictError, } from '../../domain/repositories/CodeGraphRepository.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,kDAAkD,CAAC"}
@@ -0,0 +1,7 @@
1
+ // [META] since:2026-03 | owner:architecture-team | stable:true
2
+ // [WHY] Repository module exports - persistence layer implementations
3
+ // ============================================
4
+ // Repository 模块导出 - 持久化层实现
5
+ // ============================================
6
+ export { CodeGraphRepositoryImpl } from './CodeGraphRepositoryImpl.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sEAAsE;AACtE,+CAA+C;AAC/C,2BAA2B;AAC3B,+CAA+C;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { IStorage, IStorageFactory, StorageConfig, StorageType } from '../../interface/types/storage.js';
2
+ /**
3
+ * 存储工厂实现
4
+ *
5
+ * 根据配置自动选择合适的存储后端:
6
+ * - filesystem: 文件系统存储(默认,无需额外依赖)
7
+ * - memory: 内存存储(用于测试)
8
+ * - kuzudb: KùzuDB 图数据库
9
+ * - neo4j: Neo4j 图数据库
10
+ * - auto: 根据项目规模自动选择
11
+ */
12
+ export declare class StorageFactory implements IStorageFactory {
13
+ /**
14
+ * 创建存储实例
15
+ * @param config - 存储配置
16
+ * @returns 存储实例
17
+ */
18
+ create(config: StorageConfig): Promise<IStorage>;
19
+ /**
20
+ * 为项目创建存储实例
21
+ * @param projectPath - 项目路径
22
+ * @param config - 存储配置
23
+ * @returns 初始化的存储实例
24
+ */
25
+ createForProject(projectPath: string, config: StorageConfig): Promise<IStorage>;
26
+ /**
27
+ * 自动确定存储类型
28
+ *
29
+ * 策略:
30
+ * - 小项目(<100文件): 文件系统
31
+ * - 中等项目(100-1000文件): 文件系统
32
+ * - 大项目(>1000文件): KùzuDB
33
+ *
34
+ * 可通过配置调整阈值
35
+ */
36
+ private determineStorageType;
37
+ /**
38
+ * 检查存储类型是否可用
39
+ * @param type - 存储类型
40
+ * @returns 是否可用
41
+ */
42
+ static isStorageTypeAvailable(type: StorageType): boolean;
43
+ /**
44
+ * 获取可用的存储类型列表
45
+ * @returns 可用存储类型数组
46
+ */
47
+ static getAvailableStorageTypes(): StorageType[];
48
+ }
49
+ /**
50
+ * 默认存储工厂实例
51
+ */
52
+ export declare const storageFactory: StorageFactory;
53
+ //# sourceMappingURL=StorageFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageFactory.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/StorageFactory.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,aAAa,EACb,WAAW,EACZ,MAAM,kCAAkC,CAAC;AA+B1C;;;;;;;;;GASG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0CtD;;;;;OAKG;IACG,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMrF;;;;;;;;;OASG;YACW,oBAAoB;IAWlC;;;;OAIG;IACH,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IA0BzD;;;OAGG;IACH,MAAM,CAAC,wBAAwB,IAAI,WAAW,EAAE;CAIjD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAC"}