ai-first-cli 1.2.2 → 1.3.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 (475) hide show
  1. package/CHANGELOG.md +292 -6
  2. package/README.md +24 -4
  3. package/dist/analyzers/symbols.d.ts.map +1 -1
  4. package/dist/analyzers/symbols.js +9 -7
  5. package/dist/analyzers/symbols.js.map +1 -1
  6. package/dist/analyzers/techStack.d.ts.map +1 -1
  7. package/dist/analyzers/techStack.js +198 -3
  8. package/dist/analyzers/techStack.js.map +1 -1
  9. package/dist/commands/ai-first.d.ts.map +1 -1
  10. package/dist/commands/ai-first.js +14 -13
  11. package/dist/commands/ai-first.js.map +1 -1
  12. package/dist/core/adapters/baseAdapter.d.ts +1 -1
  13. package/dist/core/adapters/baseAdapter.d.ts.map +1 -1
  14. package/dist/core/adapters/baseAdapter.js +50 -12
  15. package/dist/core/adapters/baseAdapter.js.map +1 -1
  16. package/dist/core/analysis/architectureDetector.d.ts +37 -0
  17. package/dist/core/analysis/architectureDetector.d.ts.map +1 -0
  18. package/dist/core/analysis/architectureDetector.js +316 -0
  19. package/dist/core/analysis/architectureDetector.js.map +1 -0
  20. package/dist/core/analysis/callGraphBuilder.d.ts +37 -0
  21. package/dist/core/analysis/callGraphBuilder.d.ts.map +1 -0
  22. package/dist/core/analysis/callGraphBuilder.js +101 -0
  23. package/dist/core/analysis/callGraphBuilder.js.map +1 -0
  24. package/dist/core/analysis/dependencyAnalyzer.d.ts +45 -0
  25. package/dist/core/analysis/dependencyAnalyzer.d.ts.map +1 -0
  26. package/dist/core/analysis/dependencyAnalyzer.js +98 -0
  27. package/dist/core/analysis/dependencyAnalyzer.js.map +1 -0
  28. package/dist/core/analysis/index.d.ts +5 -0
  29. package/dist/core/analysis/index.d.ts.map +1 -0
  30. package/dist/core/analysis/index.js +5 -0
  31. package/dist/core/analysis/index.js.map +1 -0
  32. package/dist/core/analysis/inheritanceAnalyzer.d.ts +35 -0
  33. package/dist/core/analysis/inheritanceAnalyzer.d.ts.map +1 -0
  34. package/dist/core/analysis/inheritanceAnalyzer.js +115 -0
  35. package/dist/core/analysis/inheritanceAnalyzer.js.map +1 -0
  36. package/dist/core/ccp.d.ts.map +1 -1
  37. package/dist/core/ccp.js +3 -2
  38. package/dist/core/ccp.js.map +1 -1
  39. package/dist/core/generation/aiContextGenerator.d.ts +71 -0
  40. package/dist/core/generation/aiContextGenerator.d.ts.map +1 -0
  41. package/dist/core/generation/aiContextGenerator.js +217 -0
  42. package/dist/core/generation/aiContextGenerator.js.map +1 -0
  43. package/dist/core/generation/architectureGenerator.d.ts +17 -0
  44. package/dist/core/generation/architectureGenerator.d.ts.map +1 -0
  45. package/dist/core/generation/architectureGenerator.js +160 -0
  46. package/dist/core/generation/architectureGenerator.js.map +1 -0
  47. package/dist/core/generation/flowGenerator.d.ts +52 -0
  48. package/dist/core/generation/flowGenerator.d.ts.map +1 -0
  49. package/dist/core/generation/flowGenerator.js +164 -0
  50. package/dist/core/generation/flowGenerator.js.map +1 -0
  51. package/dist/core/generation/index.d.ts +4 -0
  52. package/dist/core/generation/index.d.ts.map +1 -0
  53. package/dist/core/generation/index.js +4 -0
  54. package/dist/core/generation/index.js.map +1 -0
  55. package/dist/core/hierarchyGenerator.d.ts.map +1 -1
  56. package/dist/core/hierarchyGenerator.js +3 -2
  57. package/dist/core/hierarchyGenerator.js.map +1 -1
  58. package/dist/core/parsers/index.d.ts +20 -0
  59. package/dist/core/parsers/index.d.ts.map +1 -0
  60. package/dist/core/parsers/index.js +76 -0
  61. package/dist/core/parsers/index.js.map +1 -0
  62. package/dist/core/parsers/pythonParser.d.ts +37 -0
  63. package/dist/core/parsers/pythonParser.d.ts.map +1 -0
  64. package/dist/core/parsers/pythonParser.js +229 -0
  65. package/dist/core/parsers/pythonParser.js.map +1 -0
  66. package/dist/core/parsers/typescriptParser.d.ts +54 -0
  67. package/dist/core/parsers/typescriptParser.d.ts.map +1 -0
  68. package/dist/core/parsers/typescriptParser.js +291 -0
  69. package/dist/core/parsers/typescriptParser.js.map +1 -0
  70. package/dist/core/pipeline.d.ts +42 -0
  71. package/dist/core/pipeline.d.ts.map +1 -0
  72. package/dist/core/pipeline.js +172 -0
  73. package/dist/core/pipeline.js.map +1 -0
  74. package/dist/core/semanticContexts.d.ts.map +1 -1
  75. package/dist/core/semanticContexts.js +23 -61
  76. package/dist/core/semanticContexts.js.map +1 -1
  77. package/dist/utils/constants.d.ts +46 -0
  78. package/dist/utils/constants.d.ts.map +1 -0
  79. package/dist/utils/constants.js +67 -0
  80. package/dist/utils/constants.js.map +1 -0
  81. package/install.sh +143 -17
  82. package/package.json +1 -1
  83. package/run-all-tests.sh +184 -0
  84. package/src/analyzers/symbols.ts +12 -7
  85. package/src/analyzers/techStack.ts +203 -3
  86. package/src/commands/ai-first.ts +14 -13
  87. package/src/core/adapters/baseAdapter.ts +61 -12
  88. package/src/core/analysis/architectureDetector.ts +487 -0
  89. package/src/core/analysis/callGraphBuilder.ts +158 -0
  90. package/src/core/analysis/dependencyAnalyzer.ts +167 -0
  91. package/src/core/analysis/index.ts +28 -0
  92. package/src/core/analysis/inheritanceAnalyzer.ts +169 -0
  93. package/src/core/ccp.ts +3 -2
  94. package/src/core/generation/aiContextGenerator.ts +335 -0
  95. package/src/core/generation/architectureGenerator.ts +200 -0
  96. package/src/core/generation/flowGenerator.ts +238 -0
  97. package/src/core/generation/index.ts +16 -0
  98. package/src/core/hierarchyGenerator.ts +3 -2
  99. package/src/core/parsers/index.ts +99 -0
  100. package/src/core/parsers/pythonParser.ts +302 -0
  101. package/src/core/parsers/typescriptParser.ts +445 -0
  102. package/src/core/pipeline.ts +241 -0
  103. package/src/core/semanticContexts.ts +25 -67
  104. package/src/utils/constants.ts +78 -0
  105. package/tests/analysis.test.ts +283 -0
  106. package/tests/architectureDetector.test.ts +137 -0
  107. package/tests/generation.test.ts +216 -0
  108. package/tests/parserRegistry.test.ts +139 -0
  109. package/tests/pipeline.integration.test.ts +245 -0
  110. package/tests/pythonParser.test.ts +210 -0
  111. package/tests/typescriptParser.test.ts +197 -0
  112. package/.ai-dev/index.db +0 -0
  113. package/ANALISIS_COMPLETO.md +0 -424
  114. package/ANALISIS_MEJORAS.md +0 -327
  115. package/BUGS.md +0 -455
  116. package/PLAN_MEJORAS.md +0 -216
  117. package/STATUS_ADAPTADORES +0 -126
  118. package/TEST_RESULTS.md +0 -198
  119. package/TEST_RESULTS_COMPARATIVE.md +0 -159
  120. package/TEST_RESULTS_COMPLETE.md +0 -127
  121. package/TEST_RESULTS_COMPREHENSIVE.md +0 -208
  122. package/TEST_RESULTS_PHASE1.md +0 -420
  123. package/ai-context/ai_context.md +0 -130
  124. package/ai-context/ai_rules.md +0 -54
  125. package/ai-context/architecture.md +0 -136
  126. package/ai-context/cache.json +0 -2349
  127. package/ai-context/ccp/jira-123/context.json +0 -7
  128. package/ai-context/context/features/commands.json +0 -18
  129. package/ai-context/context/features/src.json +0 -61
  130. package/ai-context/context/features/test-projects.json +0 -69
  131. package/ai-context/context/flows/account.json +0 -9
  132. package/ai-context/context/flows/ai-first.json +0 -9
  133. package/ai-context/context/flows/api.json +0 -9
  134. package/ai-context/context/flows/auth.json +0 -13
  135. package/ai-context/context/flows/category.json +0 -12
  136. package/ai-context/context/flows/comment.json +0 -16
  137. package/ai-context/context/flows/dashboard.json +0 -9
  138. package/ai-context/context/flows/doctor.json +0 -9
  139. package/ai-context/context/flows/explore.json +0 -9
  140. package/ai-context/context/flows/login.json +0 -9
  141. package/ai-context/context/flows/opportunity.json +0 -9
  142. package/ai-context/context/flows/post.json +0 -18
  143. package/ai-context/context/flows/routes.json +0 -19
  144. package/ai-context/context/flows/user.json +0 -20
  145. package/ai-context/context/flows/users.json +0 -9
  146. package/ai-context/context/flows/views.json +0 -14
  147. package/ai-context/context/repo.json +0 -56
  148. package/ai-context/context/utils.json +0 -7
  149. package/ai-context/conventions.md +0 -53
  150. package/ai-context/dependencies.json +0 -2946
  151. package/ai-context/embeddings.json +0 -23828
  152. package/ai-context/entrypoints.md +0 -42
  153. package/ai-context/files.json +0 -2944
  154. package/ai-context/git/commit-activity.json +0 -8646
  155. package/ai-context/git/recent-features.json +0 -1
  156. package/ai-context/git/recent-files.json +0 -52
  157. package/ai-context/git/recent-flows.json +0 -1
  158. package/ai-context/graph/knowledge-graph.json +0 -44314
  159. package/ai-context/graph/module-graph.json +0 -866
  160. package/ai-context/graph/symbol-graph.json +0 -200622
  161. package/ai-context/graph/symbol-references.json +0 -6778
  162. package/ai-context/hierarchy.json +0 -20
  163. package/ai-context/index-state.json +0 -4340
  164. package/ai-context/index.db +0 -0
  165. package/ai-context/modules.json +0 -532
  166. package/ai-context/project.json +0 -30
  167. package/ai-context/repo_map.json +0 -5818
  168. package/ai-context/repo_map.md +0 -1327
  169. package/ai-context/schema.json +0 -5
  170. package/ai-context/summary.md +0 -42
  171. package/ai-context/symbols.json +0 -7
  172. package/ai-context/tech_stack.md +0 -46
  173. package/ai-context/tools.json +0 -10
  174. package/test-projects/django-app/.ai-dev/index.db +0 -0
  175. package/test-projects/django-app/ai-context/ai_context.md +0 -92
  176. package/test-projects/django-app/ai-context/ai_rules.md +0 -47
  177. package/test-projects/django-app/ai-context/architecture.md +0 -57
  178. package/test-projects/django-app/ai-context/cache.json +0 -169
  179. package/test-projects/django-app/ai-context/context/flows/views.json +0 -10
  180. package/test-projects/django-app/ai-context/conventions.md +0 -51
  181. package/test-projects/django-app/ai-context/dependencies.json +0 -312
  182. package/test-projects/django-app/ai-context/entrypoints.md +0 -4
  183. package/test-projects/django-app/ai-context/files.json +0 -209
  184. package/test-projects/django-app/ai-context/graph/knowledge-graph.json +0 -36
  185. package/test-projects/django-app/ai-context/graph/module-graph.json +0 -145
  186. package/test-projects/django-app/ai-context/graph/symbol-graph.json +0 -1488
  187. package/test-projects/django-app/ai-context/graph/symbol-references.json +0 -1
  188. package/test-projects/django-app/ai-context/index-state.json +0 -294
  189. package/test-projects/django-app/ai-context/index.db +0 -0
  190. package/test-projects/django-app/ai-context/modules.json +0 -35
  191. package/test-projects/django-app/ai-context/project.json +0 -11
  192. package/test-projects/django-app/ai-context/repo_map.json +0 -412
  193. package/test-projects/django-app/ai-context/repo_map.md +0 -105
  194. package/test-projects/django-app/ai-context/schema.json +0 -5
  195. package/test-projects/django-app/ai-context/summary.md +0 -15
  196. package/test-projects/django-app/ai-context/symbols.json +0 -1
  197. package/test-projects/django-app/ai-context/tech_stack.md +0 -32
  198. package/test-projects/django-app/ai-context/tools.json +0 -10
  199. package/test-projects/express-api/ai-context/ai_context.md +0 -112
  200. package/test-projects/express-api/ai-context/ai_rules.md +0 -50
  201. package/test-projects/express-api/ai-context/architecture.md +0 -62
  202. package/test-projects/express-api/ai-context/context/features/controllers.json +0 -13
  203. package/test-projects/express-api/ai-context/context/features/services.json +0 -13
  204. package/test-projects/express-api/ai-context/context/flows/auth.json +0 -12
  205. package/test-projects/express-api/ai-context/context/flows/user.json +0 -13
  206. package/test-projects/express-api/ai-context/conventions.md +0 -51
  207. package/test-projects/express-api/ai-context/dependencies.json +0 -54
  208. package/test-projects/express-api/ai-context/entrypoints.md +0 -17
  209. package/test-projects/express-api/ai-context/modules.json +0 -30
  210. package/test-projects/express-api/ai-context/project.json +0 -15
  211. package/test-projects/express-api/ai-context/repo_map.json +0 -100
  212. package/test-projects/express-api/ai-context/repo_map.md +0 -36
  213. package/test-projects/express-api/ai-context/schema.json +0 -5
  214. package/test-projects/express-api/ai-context/summary.md +0 -14
  215. package/test-projects/express-api/ai-context/symbols.json +0 -7
  216. package/test-projects/express-api/ai-context/tech_stack.md +0 -38
  217. package/test-projects/express-api/ai-context/tools.json +0 -10
  218. package/test-projects/fastapi-app/.ai-dev/index.db +0 -0
  219. package/test-projects/fastapi-app/ai-context/ai_context.md +0 -89
  220. package/test-projects/fastapi-app/ai-context/ai_rules.md +0 -47
  221. package/test-projects/fastapi-app/ai-context/architecture.md +0 -39
  222. package/test-projects/fastapi-app/ai-context/cache.json +0 -125
  223. package/test-projects/fastapi-app/ai-context/conventions.md +0 -51
  224. package/test-projects/fastapi-app/ai-context/dependencies.json +0 -244
  225. package/test-projects/fastapi-app/ai-context/entrypoints.md +0 -4
  226. package/test-projects/fastapi-app/ai-context/files.json +0 -154
  227. package/test-projects/fastapi-app/ai-context/graph/knowledge-graph.json +0 -15
  228. package/test-projects/fastapi-app/ai-context/graph/module-graph.json +0 -78
  229. package/test-projects/fastapi-app/ai-context/graph/symbol-graph.json +0 -1724
  230. package/test-projects/fastapi-app/ai-context/graph/symbol-references.json +0 -51
  231. package/test-projects/fastapi-app/ai-context/index-state.json +0 -217
  232. package/test-projects/fastapi-app/ai-context/index.db +0 -0
  233. package/test-projects/fastapi-app/ai-context/modules.json +0 -16
  234. package/test-projects/fastapi-app/ai-context/project.json +0 -9
  235. package/test-projects/fastapi-app/ai-context/repo_map.json +0 -298
  236. package/test-projects/fastapi-app/ai-context/repo_map.md +0 -74
  237. package/test-projects/fastapi-app/ai-context/schema.json +0 -5
  238. package/test-projects/fastapi-app/ai-context/summary.md +0 -12
  239. package/test-projects/fastapi-app/ai-context/symbols.json +0 -1
  240. package/test-projects/fastapi-app/ai-context/tech_stack.md +0 -32
  241. package/test-projects/fastapi-app/ai-context/tools.json +0 -10
  242. package/test-projects/flask-app/.ai-dev/index.db +0 -0
  243. package/test-projects/flask-app/ai-context/ai_context.md +0 -94
  244. package/test-projects/flask-app/ai-context/ai_rules.md +0 -47
  245. package/test-projects/flask-app/ai-context/architecture.md +0 -49
  246. package/test-projects/flask-app/ai-context/cache.json +0 -157
  247. package/test-projects/flask-app/ai-context/context/features/app.json +0 -25
  248. package/test-projects/flask-app/ai-context/context/flows/routes.json +0 -14
  249. package/test-projects/flask-app/ai-context/conventions.md +0 -51
  250. package/test-projects/flask-app/ai-context/dependencies.json +0 -298
  251. package/test-projects/flask-app/ai-context/entrypoints.md +0 -4
  252. package/test-projects/flask-app/ai-context/files.json +0 -194
  253. package/test-projects/flask-app/ai-context/graph/knowledge-graph.json +0 -60
  254. package/test-projects/flask-app/ai-context/graph/module-graph.json +0 -95
  255. package/test-projects/flask-app/ai-context/graph/symbol-graph.json +0 -1448
  256. package/test-projects/flask-app/ai-context/graph/symbol-references.json +0 -45
  257. package/test-projects/flask-app/ai-context/index-state.json +0 -273
  258. package/test-projects/flask-app/ai-context/index.db +0 -0
  259. package/test-projects/flask-app/ai-context/modules.json +0 -21
  260. package/test-projects/flask-app/ai-context/project.json +0 -13
  261. package/test-projects/flask-app/ai-context/repo_map.json +0 -400
  262. package/test-projects/flask-app/ai-context/repo_map.md +0 -98
  263. package/test-projects/flask-app/ai-context/schema.json +0 -5
  264. package/test-projects/flask-app/ai-context/summary.md +0 -13
  265. package/test-projects/flask-app/ai-context/symbols.json +0 -1
  266. package/test-projects/flask-app/ai-context/tech_stack.md +0 -32
  267. package/test-projects/flask-app/ai-context/tools.json +0 -10
  268. package/test-projects/laravel-app/.ai-dev/index.db +0 -0
  269. package/test-projects/laravel-app/ai-context/ai_context.md +0 -97
  270. package/test-projects/laravel-app/ai-context/ai_rules.md +0 -47
  271. package/test-projects/laravel-app/ai-context/architecture.md +0 -60
  272. package/test-projects/laravel-app/ai-context/cache.json +0 -161
  273. package/test-projects/laravel-app/ai-context/context/features/app.json +0 -21
  274. package/test-projects/laravel-app/ai-context/context/flows/.json +0 -9
  275. package/test-projects/laravel-app/ai-context/context/flows/category.json +0 -12
  276. package/test-projects/laravel-app/ai-context/context/flows/comment.json +0 -12
  277. package/test-projects/laravel-app/ai-context/context/flows/post.json +0 -12
  278. package/test-projects/laravel-app/ai-context/context/flows/unnamed.json +0 -9
  279. package/test-projects/laravel-app/ai-context/conventions.md +0 -51
  280. package/test-projects/laravel-app/ai-context/dependencies.json +0 -6
  281. package/test-projects/laravel-app/ai-context/entrypoints.md +0 -4
  282. package/test-projects/laravel-app/ai-context/files.json +0 -199
  283. package/test-projects/laravel-app/ai-context/graph/knowledge-graph.json +0 -98
  284. package/test-projects/laravel-app/ai-context/graph/module-graph.json +0 -30
  285. package/test-projects/laravel-app/ai-context/graph/symbol-graph.json +0 -5
  286. package/test-projects/laravel-app/ai-context/graph/symbol-references.json +0 -1
  287. package/test-projects/laravel-app/ai-context/index-state.json +0 -280
  288. package/test-projects/laravel-app/ai-context/index.db +0 -0
  289. package/test-projects/laravel-app/ai-context/modules.json +0 -29
  290. package/test-projects/laravel-app/ai-context/project.json +0 -17
  291. package/test-projects/laravel-app/ai-context/repo_map.json +0 -419
  292. package/test-projects/laravel-app/ai-context/repo_map.md +0 -106
  293. package/test-projects/laravel-app/ai-context/schema.json +0 -5
  294. package/test-projects/laravel-app/ai-context/summary.md +0 -15
  295. package/test-projects/laravel-app/ai-context/symbols.json +0 -1
  296. package/test-projects/laravel-app/ai-context/tech_stack.md +0 -34
  297. package/test-projects/laravel-app/ai-context/tools.json +0 -10
  298. package/test-projects/nestjs-backend/.ai-dev/index.db +0 -0
  299. package/test-projects/nestjs-backend/ai-context/ai_context.md +0 -111
  300. package/test-projects/nestjs-backend/ai-context/ai_rules.md +0 -52
  301. package/test-projects/nestjs-backend/ai-context/architecture.md +0 -49
  302. package/test-projects/nestjs-backend/ai-context/cache.json +0 -169
  303. package/test-projects/nestjs-backend/ai-context/context/features/src.json +0 -23
  304. package/test-projects/nestjs-backend/ai-context/context/flows/auth.controller.json +0 -14
  305. package/test-projects/nestjs-backend/ai-context/context/flows/auth.json +0 -10
  306. package/test-projects/nestjs-backend/ai-context/context/flows/users..json +0 -10
  307. package/test-projects/nestjs-backend/ai-context/context/flows/users.controller.json +0 -14
  308. package/test-projects/nestjs-backend/ai-context/context/flows/users.json +0 -10
  309. package/test-projects/nestjs-backend/ai-context/conventions.md +0 -52
  310. package/test-projects/nestjs-backend/ai-context/dependencies.json +0 -152
  311. package/test-projects/nestjs-backend/ai-context/entrypoints.md +0 -18
  312. package/test-projects/nestjs-backend/ai-context/files.json +0 -209
  313. package/test-projects/nestjs-backend/ai-context/graph/knowledge-graph.json +0 -132
  314. package/test-projects/nestjs-backend/ai-context/graph/module-graph.json +0 -29
  315. package/test-projects/nestjs-backend/ai-context/graph/symbol-graph.json +0 -304
  316. package/test-projects/nestjs-backend/ai-context/graph/symbol-references.json +0 -5
  317. package/test-projects/nestjs-backend/ai-context/index-state.json +0 -294
  318. package/test-projects/nestjs-backend/ai-context/index.db +0 -0
  319. package/test-projects/nestjs-backend/ai-context/modules.json +0 -19
  320. package/test-projects/nestjs-backend/ai-context/project.json +0 -18
  321. package/test-projects/nestjs-backend/ai-context/repo_map.json +0 -427
  322. package/test-projects/nestjs-backend/ai-context/repo_map.md +0 -104
  323. package/test-projects/nestjs-backend/ai-context/schema.json +0 -5
  324. package/test-projects/nestjs-backend/ai-context/summary.md +0 -13
  325. package/test-projects/nestjs-backend/ai-context/symbols.json +0 -1
  326. package/test-projects/nestjs-backend/ai-context/tech_stack.md +0 -38
  327. package/test-projects/nestjs-backend/ai-context/tools.json +0 -10
  328. package/test-projects/python-cli/.ai-dev/index.db +0 -0
  329. package/test-projects/python-cli/ai-context/ai_context.md +0 -95
  330. package/test-projects/python-cli/ai-context/ai_rules.md +0 -47
  331. package/test-projects/python-cli/ai-context/architecture.md +0 -55
  332. package/test-projects/python-cli/ai-context/cache.json +0 -149
  333. package/test-projects/python-cli/ai-context/context/features/cli.json +0 -16
  334. package/test-projects/python-cli/ai-context/context/flows/list_.json +0 -9
  335. package/test-projects/python-cli/ai-context/context/flows/remove_.json +0 -9
  336. package/test-projects/python-cli/ai-context/conventions.md +0 -51
  337. package/test-projects/python-cli/ai-context/dependencies.json +0 -66
  338. package/test-projects/python-cli/ai-context/entrypoints.md +0 -4
  339. package/test-projects/python-cli/ai-context/files.json +0 -184
  340. package/test-projects/python-cli/ai-context/graph/knowledge-graph.json +0 -83
  341. package/test-projects/python-cli/ai-context/graph/module-graph.json +0 -31
  342. package/test-projects/python-cli/ai-context/graph/symbol-graph.json +0 -358
  343. package/test-projects/python-cli/ai-context/graph/symbol-references.json +0 -11
  344. package/test-projects/python-cli/ai-context/index-state.json +0 -259
  345. package/test-projects/python-cli/ai-context/index.db +0 -0
  346. package/test-projects/python-cli/ai-context/modules.json +0 -21
  347. package/test-projects/python-cli/ai-context/project.json +0 -15
  348. package/test-projects/python-cli/ai-context/repo_map.json +0 -367
  349. package/test-projects/python-cli/ai-context/repo_map.md +0 -93
  350. package/test-projects/python-cli/ai-context/schema.json +0 -5
  351. package/test-projects/python-cli/ai-context/summary.md +0 -14
  352. package/test-projects/python-cli/ai-context/symbols.json +0 -1
  353. package/test-projects/python-cli/ai-context/tech_stack.md +0 -32
  354. package/test-projects/python-cli/ai-context/tools.json +0 -10
  355. package/test-projects/rails-app/.ai-dev/index.db +0 -0
  356. package/test-projects/rails-app/ai-context/ai_context.md +0 -94
  357. package/test-projects/rails-app/ai-context/ai_rules.md +0 -47
  358. package/test-projects/rails-app/ai-context/architecture.md +0 -49
  359. package/test-projects/rails-app/ai-context/cache.json +0 -193
  360. package/test-projects/rails-app/ai-context/context/features/app.json +0 -24
  361. package/test-projects/rails-app/ai-context/context/features/config.json +0 -13
  362. package/test-projects/rails-app/ai-context/context/flows/application.json +0 -9
  363. package/test-projects/rails-app/ai-context/context/flows/application_.json +0 -9
  364. package/test-projects/rails-app/ai-context/context/flows/comments.json +0 -11
  365. package/test-projects/rails-app/ai-context/context/flows/comments_.json +0 -11
  366. package/test-projects/rails-app/ai-context/context/flows/posts.json +0 -11
  367. package/test-projects/rails-app/ai-context/context/flows/posts_.json +0 -11
  368. package/test-projects/rails-app/ai-context/context/flows/routes.json +0 -9
  369. package/test-projects/rails-app/ai-context/context/flows/users.json +0 -11
  370. package/test-projects/rails-app/ai-context/context/flows/users_.json +0 -11
  371. package/test-projects/rails-app/ai-context/conventions.md +0 -51
  372. package/test-projects/rails-app/ai-context/dependencies.json +0 -6
  373. package/test-projects/rails-app/ai-context/entrypoints.md +0 -4
  374. package/test-projects/rails-app/ai-context/files.json +0 -239
  375. package/test-projects/rails-app/ai-context/graph/knowledge-graph.json +0 -130
  376. package/test-projects/rails-app/ai-context/graph/module-graph.json +0 -27
  377. package/test-projects/rails-app/ai-context/graph/symbol-graph.json +0 -5
  378. package/test-projects/rails-app/ai-context/graph/symbol-references.json +0 -1
  379. package/test-projects/rails-app/ai-context/index-state.json +0 -336
  380. package/test-projects/rails-app/ai-context/index.db +0 -0
  381. package/test-projects/rails-app/ai-context/modules.json +0 -26
  382. package/test-projects/rails-app/ai-context/project.json +0 -22
  383. package/test-projects/rails-app/ai-context/repo_map.json +0 -486
  384. package/test-projects/rails-app/ai-context/repo_map.md +0 -117
  385. package/test-projects/rails-app/ai-context/schema.json +0 -5
  386. package/test-projects/rails-app/ai-context/summary.md +0 -13
  387. package/test-projects/rails-app/ai-context/symbols.json +0 -1
  388. package/test-projects/rails-app/ai-context/tech_stack.md +0 -32
  389. package/test-projects/rails-app/ai-context/tools.json +0 -10
  390. package/test-projects/react-app/.ai-dev/index.db +0 -0
  391. package/test-projects/react-app/ai-context/ai_context.md +0 -96
  392. package/test-projects/react-app/ai-context/ai_rules.md +0 -49
  393. package/test-projects/react-app/ai-context/architecture.md +0 -39
  394. package/test-projects/react-app/ai-context/cache.json +0 -153
  395. package/test-projects/react-app/ai-context/context/features/src.json +0 -18
  396. package/test-projects/react-app/ai-context/context/flows/UsersPage.json +0 -14
  397. package/test-projects/react-app/ai-context/context/flows/dashboard.json +0 -9
  398. package/test-projects/react-app/ai-context/context/flows/login.json +0 -9
  399. package/test-projects/react-app/ai-context/context/flows/users.json +0 -9
  400. package/test-projects/react-app/ai-context/conventions.md +0 -52
  401. package/test-projects/react-app/ai-context/dependencies.json +0 -128
  402. package/test-projects/react-app/ai-context/entrypoints.md +0 -4
  403. package/test-projects/react-app/ai-context/files.json +0 -189
  404. package/test-projects/react-app/ai-context/graph/knowledge-graph.json +0 -112
  405. package/test-projects/react-app/ai-context/graph/module-graph.json +0 -31
  406. package/test-projects/react-app/ai-context/graph/symbol-graph.json +0 -868
  407. package/test-projects/react-app/ai-context/graph/symbol-references.json +0 -31
  408. package/test-projects/react-app/ai-context/index-state.json +0 -266
  409. package/test-projects/react-app/ai-context/index.db +0 -0
  410. package/test-projects/react-app/ai-context/modules.json +0 -17
  411. package/test-projects/react-app/ai-context/project.json +0 -16
  412. package/test-projects/react-app/ai-context/repo_map.json +0 -391
  413. package/test-projects/react-app/ai-context/repo_map.md +0 -94
  414. package/test-projects/react-app/ai-context/schema.json +0 -5
  415. package/test-projects/react-app/ai-context/summary.md +0 -13
  416. package/test-projects/react-app/ai-context/symbols.json +0 -1
  417. package/test-projects/react-app/ai-context/tech_stack.md +0 -39
  418. package/test-projects/react-app/ai-context/tools.json +0 -10
  419. package/test-projects/salesforce-cli/.ai-dev/index.db +0 -0
  420. package/test-projects/salesforce-cli/ai-context/ai_context.md +0 -89
  421. package/test-projects/salesforce-cli/ai-context/ai_rules.md +0 -47
  422. package/test-projects/salesforce-cli/ai-context/architecture.md +0 -39
  423. package/test-projects/salesforce-cli/ai-context/cache.json +0 -125
  424. package/test-projects/salesforce-cli/ai-context/context/features/force-app.json +0 -14
  425. package/test-projects/salesforce-cli/ai-context/context/flows/account.json +0 -9
  426. package/test-projects/salesforce-cli/ai-context/context/flows/opportunity.json +0 -9
  427. package/test-projects/salesforce-cli/ai-context/conventions.md +0 -51
  428. package/test-projects/salesforce-cli/ai-context/dependencies.json +0 -6
  429. package/test-projects/salesforce-cli/ai-context/entrypoints.md +0 -4
  430. package/test-projects/salesforce-cli/ai-context/files.json +0 -154
  431. package/test-projects/salesforce-cli/ai-context/graph/knowledge-graph.json +0 -64
  432. package/test-projects/salesforce-cli/ai-context/graph/module-graph.json +0 -13
  433. package/test-projects/salesforce-cli/ai-context/graph/symbol-graph.json +0 -148
  434. package/test-projects/salesforce-cli/ai-context/graph/symbol-references.json +0 -1
  435. package/test-projects/salesforce-cli/ai-context/index-state.json +0 -217
  436. package/test-projects/salesforce-cli/ai-context/index.db +0 -0
  437. package/test-projects/salesforce-cli/ai-context/modules.json +0 -12
  438. package/test-projects/salesforce-cli/ai-context/project.json +0 -14
  439. package/test-projects/salesforce-cli/ai-context/repo_map.json +0 -328
  440. package/test-projects/salesforce-cli/ai-context/repo_map.md +0 -80
  441. package/test-projects/salesforce-cli/ai-context/schema.json +0 -5
  442. package/test-projects/salesforce-cli/ai-context/summary.md +0 -13
  443. package/test-projects/salesforce-cli/ai-context/symbols.json +0 -1
  444. package/test-projects/salesforce-cli/ai-context/tech_stack.md +0 -31
  445. package/test-projects/salesforce-cli/ai-context/tools.json +0 -10
  446. package/test-projects/spring-boot-app/.ai-dev/index.db +0 -0
  447. package/test-projects/spring-boot-app/ai-context/ai_context.md +0 -91
  448. package/test-projects/spring-boot-app/ai-context/ai_rules.md +0 -48
  449. package/test-projects/spring-boot-app/ai-context/architecture.md +0 -39
  450. package/test-projects/spring-boot-app/ai-context/cache.json +0 -173
  451. package/test-projects/spring-boot-app/ai-context/context/features/src.json +0 -26
  452. package/test-projects/spring-boot-app/ai-context/context/flows/PostController.json +0 -19
  453. package/test-projects/spring-boot-app/ai-context/context/flows/UserController.json +0 -19
  454. package/test-projects/spring-boot-app/ai-context/context/flows/comment.json +0 -11
  455. package/test-projects/spring-boot-app/ai-context/context/flows/post.json +0 -14
  456. package/test-projects/spring-boot-app/ai-context/context/flows/user.json +0 -14
  457. package/test-projects/spring-boot-app/ai-context/conventions.md +0 -52
  458. package/test-projects/spring-boot-app/ai-context/dependencies.json +0 -326
  459. package/test-projects/spring-boot-app/ai-context/entrypoints.md +0 -4
  460. package/test-projects/spring-boot-app/ai-context/files.json +0 -214
  461. package/test-projects/spring-boot-app/ai-context/graph/knowledge-graph.json +0 -231
  462. package/test-projects/spring-boot-app/ai-context/graph/module-graph.json +0 -22
  463. package/test-projects/spring-boot-app/ai-context/graph/symbol-graph.json +0 -794
  464. package/test-projects/spring-boot-app/ai-context/graph/symbol-references.json +0 -70
  465. package/test-projects/spring-boot-app/ai-context/index-state.json +0 -301
  466. package/test-projects/spring-boot-app/ai-context/index.db +0 -0
  467. package/test-projects/spring-boot-app/ai-context/modules.json +0 -21
  468. package/test-projects/spring-boot-app/ai-context/project.json +0 -17
  469. package/test-projects/spring-boot-app/ai-context/repo_map.json +0 -461
  470. package/test-projects/spring-boot-app/ai-context/repo_map.md +0 -109
  471. package/test-projects/spring-boot-app/ai-context/schema.json +0 -5
  472. package/test-projects/spring-boot-app/ai-context/summary.md +0 -12
  473. package/test-projects/spring-boot-app/ai-context/symbols.json +0 -1
  474. package/test-projects/spring-boot-app/ai-context/tech_stack.md +0 -32
  475. package/test-projects/spring-boot-app/ai-context/tools.json +0 -10
@@ -0,0 +1,445 @@
1
+ import * as ts from "typescript";
2
+
3
+ export interface ParsedSymbol {
4
+ name: string;
5
+ type: "class" | "interface" | "function" | "method" | "property" | "enum" | "type" | "const" | "variable";
6
+ line: number;
7
+ character: number;
8
+ isExported: boolean;
9
+ modifiers?: string[];
10
+ heritage?: {
11
+ extends?: string[];
12
+ implements?: string[];
13
+ };
14
+ members?: ParsedSymbol[];
15
+ parameters?: {
16
+ name: string;
17
+ type?: string;
18
+ optional?: boolean;
19
+ }[];
20
+ returnType?: string;
21
+ jsDoc?: string;
22
+ }
23
+
24
+ export interface ParsedFile {
25
+ filePath: string;
26
+ symbols: ParsedSymbol[];
27
+ imports: {
28
+ name: string;
29
+ module: string;
30
+ isDefault?: boolean;
31
+ isNamespace?: boolean;
32
+ }[];
33
+ exports: string[];
34
+ }
35
+
36
+ export class TypeScriptParser {
37
+ private program: ts.Program | null = null;
38
+
39
+ parseFile(filePath: string, sourceText: string): ParsedFile {
40
+ const sourceFile = ts.createSourceFile(
41
+ filePath,
42
+ sourceText,
43
+ ts.ScriptTarget.Latest,
44
+ true,
45
+ ts.ScriptKind.TS
46
+ );
47
+
48
+ const symbols: ParsedSymbol[] = [];
49
+ const imports: ParsedFile["imports"] = [];
50
+ const exports: string[] = [];
51
+
52
+ this.visitNode(sourceFile, sourceFile, symbols, imports, exports);
53
+
54
+ return {
55
+ filePath,
56
+ symbols,
57
+ imports,
58
+ exports,
59
+ };
60
+ }
61
+
62
+ private visitNode(
63
+ node: ts.Node,
64
+ sourceFile: ts.SourceFile,
65
+ symbols: ParsedSymbol[],
66
+ imports: ParsedFile["imports"],
67
+ exports: string[]
68
+ ): void {
69
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
70
+
71
+ switch (node.kind) {
72
+ case ts.SyntaxKind.ClassDeclaration:
73
+ this.handleClassDeclaration(node as ts.ClassDeclaration, line, character, sourceFile, symbols);
74
+ break;
75
+
76
+ case ts.SyntaxKind.InterfaceDeclaration:
77
+ this.handleInterfaceDeclaration(node as ts.InterfaceDeclaration, line, character, sourceFile, symbols);
78
+ break;
79
+
80
+ case ts.SyntaxKind.FunctionDeclaration:
81
+ this.handleFunctionDeclaration(node as ts.FunctionDeclaration, line, character, sourceFile, symbols, exports);
82
+ break;
83
+
84
+ case ts.SyntaxKind.EnumDeclaration:
85
+ this.handleEnumDeclaration(node as ts.EnumDeclaration, line, character, sourceFile, symbols);
86
+ break;
87
+
88
+ case ts.SyntaxKind.TypeAliasDeclaration:
89
+ this.handleTypeAliasDeclaration(node as ts.TypeAliasDeclaration, line, character, sourceFile, symbols);
90
+ break;
91
+
92
+ case ts.SyntaxKind.VariableStatement:
93
+ this.handleVariableStatement(node as ts.VariableStatement, line, character, sourceFile, symbols, exports);
94
+ break;
95
+
96
+ case ts.SyntaxKind.ImportDeclaration:
97
+ this.handleImportDeclaration(node as ts.ImportDeclaration, sourceFile, imports);
98
+ break;
99
+
100
+ case ts.SyntaxKind.ExportAssignment:
101
+ case ts.SyntaxKind.ExportDeclaration:
102
+ this.handleExport(node, sourceFile, exports);
103
+ break;
104
+ }
105
+
106
+ ts.forEachChild(node, (child) =>
107
+ this.visitNode(child, sourceFile, symbols, imports, exports)
108
+ );
109
+ }
110
+
111
+ private handleClassDeclaration(
112
+ node: ts.ClassDeclaration,
113
+ line: number,
114
+ character: number,
115
+ sourceFile: ts.SourceFile,
116
+ symbols: ParsedSymbol[]
117
+ ): void {
118
+ if (!node.name) return;
119
+
120
+ const symbol: ParsedSymbol = {
121
+ name: node.name.text,
122
+ type: "class",
123
+ line: line + 1,
124
+ character: character + 1,
125
+ isExported: this.hasExportModifier(node),
126
+ modifiers: this.getModifiers(node),
127
+ heritage: this.getHeritage(node),
128
+ members: [],
129
+ jsDoc: this.getJsDoc(node, sourceFile),
130
+ };
131
+
132
+ node.members.forEach((member) => {
133
+ const memberSymbol = this.extractClassMember(member, sourceFile);
134
+ if (memberSymbol) {
135
+ symbol.members!.push(memberSymbol);
136
+ }
137
+ });
138
+
139
+ symbols.push(symbol);
140
+ }
141
+
142
+ private handleInterfaceDeclaration(
143
+ node: ts.InterfaceDeclaration,
144
+ line: number,
145
+ character: number,
146
+ sourceFile: ts.SourceFile,
147
+ symbols: ParsedSymbol[]
148
+ ): void {
149
+ const symbol: ParsedSymbol = {
150
+ name: node.name.text,
151
+ type: "interface",
152
+ line: line + 1,
153
+ character: character + 1,
154
+ isExported: this.hasExportModifier(node),
155
+ modifiers: this.getModifiers(node),
156
+ heritage: { extends: node.heritageClauses?.flatMap((h) =>
157
+ h.types.map((t) => t.getText(sourceFile))
158
+ ) },
159
+ members: [],
160
+ jsDoc: this.getJsDoc(node, sourceFile),
161
+ };
162
+
163
+ node.members.forEach((member) => {
164
+ const memberSymbol = this.extractInterfaceMember(member, sourceFile);
165
+ if (memberSymbol) {
166
+ symbol.members!.push(memberSymbol);
167
+ }
168
+ });
169
+
170
+ symbols.push(symbol);
171
+ }
172
+
173
+ private handleFunctionDeclaration(
174
+ node: ts.FunctionDeclaration,
175
+ line: number,
176
+ character: number,
177
+ sourceFile: ts.SourceFile,
178
+ symbols: ParsedSymbol[],
179
+ exports: string[]
180
+ ): void {
181
+ if (!node.name) return;
182
+
183
+ const symbol: ParsedSymbol = {
184
+ name: node.name.text,
185
+ type: "function",
186
+ line: line + 1,
187
+ character: character + 1,
188
+ isExported: this.hasExportModifier(node),
189
+ modifiers: this.getModifiers(node),
190
+ parameters: this.getParameters(node.parameters, sourceFile),
191
+ returnType: node.type?.getText(sourceFile),
192
+ jsDoc: this.getJsDoc(node, sourceFile),
193
+ };
194
+
195
+ symbols.push(symbol);
196
+
197
+ if (symbol.isExported) {
198
+ exports.push(symbol.name);
199
+ }
200
+ }
201
+
202
+ private handleEnumDeclaration(
203
+ node: ts.EnumDeclaration,
204
+ line: number,
205
+ character: number,
206
+ sourceFile: ts.SourceFile,
207
+ symbols: ParsedSymbol[]
208
+ ): void {
209
+ const symbol: ParsedSymbol = {
210
+ name: node.name.text,
211
+ type: "enum",
212
+ line: line + 1,
213
+ character: character + 1,
214
+ isExported: this.hasExportModifier(node),
215
+ modifiers: this.getModifiers(node),
216
+ jsDoc: this.getJsDoc(node, sourceFile),
217
+ };
218
+
219
+ symbols.push(symbol);
220
+ }
221
+
222
+ private handleTypeAliasDeclaration(
223
+ node: ts.TypeAliasDeclaration,
224
+ line: number,
225
+ character: number,
226
+ sourceFile: ts.SourceFile,
227
+ symbols: ParsedSymbol[]
228
+ ): void {
229
+ const symbol: ParsedSymbol = {
230
+ name: node.name.text,
231
+ type: "type",
232
+ line: line + 1,
233
+ character: character + 1,
234
+ isExported: this.hasExportModifier(node),
235
+ modifiers: this.getModifiers(node),
236
+ jsDoc: this.getJsDoc(node, sourceFile),
237
+ };
238
+
239
+ symbols.push(symbol);
240
+ }
241
+
242
+ private handleVariableStatement(
243
+ node: ts.VariableStatement,
244
+ line: number,
245
+ character: number,
246
+ sourceFile: ts.SourceFile,
247
+ symbols: ParsedSymbol[],
248
+ exports: string[]
249
+ ): void {
250
+ const isExported = this.hasExportModifier(node);
251
+
252
+ node.declarationList.declarations.forEach((decl) => {
253
+ if (ts.isIdentifier(decl.name)) {
254
+ const symbol: ParsedSymbol = {
255
+ name: decl.name.text,
256
+ type: this.isConst(node) ? "const" : "variable",
257
+ line: line + 1,
258
+ character: character + 1,
259
+ isExported,
260
+ modifiers: this.getModifiers(node),
261
+ jsDoc: this.getJsDoc(node, sourceFile),
262
+ };
263
+
264
+ symbols.push(symbol);
265
+
266
+ if (isExported) {
267
+ exports.push(symbol.name);
268
+ }
269
+ }
270
+ });
271
+ }
272
+
273
+ private handleImportDeclaration(
274
+ node: ts.ImportDeclaration,
275
+ sourceFile: ts.SourceFile,
276
+ imports: ParsedFile["imports"]
277
+ ): void {
278
+ const moduleSpecifier = (node.moduleSpecifier as ts.StringLiteral).text;
279
+
280
+ if (node.importClause) {
281
+ if (node.importClause.name) {
282
+ imports.push({
283
+ name: node.importClause.name.text,
284
+ module: moduleSpecifier,
285
+ isDefault: true,
286
+ });
287
+ }
288
+
289
+ if (node.importClause.namedBindings) {
290
+ if (ts.isNamedImports(node.importClause.namedBindings)) {
291
+ node.importClause.namedBindings.elements.forEach((element) => {
292
+ imports.push({
293
+ name: element.name.text,
294
+ module: moduleSpecifier,
295
+ isDefault: false,
296
+ });
297
+ });
298
+ } else if (ts.isNamespaceImport(node.importClause.namedBindings)) {
299
+ imports.push({
300
+ name: node.importClause.namedBindings.name.text,
301
+ module: moduleSpecifier,
302
+ isNamespace: true,
303
+ });
304
+ }
305
+ }
306
+ }
307
+ }
308
+
309
+ private handleExport(
310
+ node: ts.Node,
311
+ sourceFile: ts.SourceFile,
312
+ exports: string[]
313
+ ): void {
314
+ if (ts.isExportAssignment(node)) {
315
+ if (ts.isIdentifier(node.expression)) {
316
+ exports.push(node.expression.text);
317
+ }
318
+ }
319
+ }
320
+
321
+ private extractClassMember(
322
+ member: ts.ClassElement,
323
+ sourceFile: ts.SourceFile
324
+ ): ParsedSymbol | null {
325
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(member.getStart());
326
+
327
+ if (ts.isMethodDeclaration(member) && member.name) {
328
+ return {
329
+ name: member.name.getText(sourceFile),
330
+ type: "method",
331
+ line: line + 1,
332
+ character: character + 1,
333
+ isExported: false,
334
+ modifiers: this.getModifiers(member),
335
+ parameters: this.getParameters(member.parameters, sourceFile),
336
+ returnType: member.type?.getText(sourceFile),
337
+ };
338
+ }
339
+
340
+ if (ts.isPropertyDeclaration(member) && member.name) {
341
+ return {
342
+ name: member.name.getText(sourceFile),
343
+ type: "property",
344
+ line: line + 1,
345
+ character: character + 1,
346
+ isExported: false,
347
+ modifiers: this.getModifiers(member),
348
+ };
349
+ }
350
+
351
+ return null;
352
+ }
353
+
354
+ private extractInterfaceMember(
355
+ member: ts.TypeElement,
356
+ sourceFile: ts.SourceFile
357
+ ): ParsedSymbol | null {
358
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(member.getStart());
359
+
360
+ if (ts.isMethodSignature(member) && member.name) {
361
+ return {
362
+ name: member.name.getText(sourceFile),
363
+ type: "method",
364
+ line: line + 1,
365
+ character: character + 1,
366
+ isExported: false,
367
+ parameters: this.getParameters(member.parameters, sourceFile),
368
+ returnType: member.type?.getText(sourceFile),
369
+ };
370
+ }
371
+
372
+ if (ts.isPropertySignature(member) && member.name) {
373
+ return {
374
+ name: member.name.getText(sourceFile),
375
+ type: "property",
376
+ line: line + 1,
377
+ character: character + 1,
378
+ isExported: false,
379
+ };
380
+ }
381
+
382
+ return null;
383
+ }
384
+
385
+ private getModifiers(node: ts.Node): string[] {
386
+ const modifiers: string[] = [];
387
+ if (ts.canHaveModifiers(node)) {
388
+ const nodeModifiers = ts.getModifiers(node);
389
+ nodeModifiers?.forEach((mod) => {
390
+ modifiers.push(ts.SyntaxKind[mod.kind].toLowerCase().replace("keyword", ""));
391
+ });
392
+ }
393
+ return modifiers;
394
+ }
395
+
396
+ private hasExportModifier(node: ts.Node): boolean {
397
+ if (ts.canHaveModifiers(node)) {
398
+ const modifiers = ts.getModifiers(node);
399
+ return modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword) ?? false;
400
+ }
401
+ return false;
402
+ }
403
+
404
+ private isConst(node: ts.VariableStatement): boolean {
405
+ return (node.declarationList.flags & ts.NodeFlags.Const) !== 0;
406
+ }
407
+
408
+ private getHeritage(node: ts.ClassDeclaration): { extends?: string[]; implements?: string[] } {
409
+ const heritage: { extends?: string[]; implements?: string[] } = {};
410
+
411
+ if (node.heritageClauses) {
412
+ node.heritageClauses.forEach((clause) => {
413
+ const types = clause.types.map((t) => t.getText());
414
+ if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
415
+ heritage.extends = types;
416
+ } else if (clause.token === ts.SyntaxKind.ImplementsKeyword) {
417
+ heritage.implements = types;
418
+ }
419
+ });
420
+ }
421
+
422
+ return heritage;
423
+ }
424
+
425
+ private getParameters(
426
+ params: ts.NodeArray<ts.ParameterDeclaration>,
427
+ sourceFile: ts.SourceFile
428
+ ): { name: string; type?: string; optional?: boolean }[] {
429
+ return params.map((param) => ({
430
+ name: param.name.getText(sourceFile),
431
+ type: param.type?.getText(sourceFile),
432
+ optional: !!param.questionToken,
433
+ }));
434
+ }
435
+
436
+ private getJsDoc(node: ts.Node, sourceFile: ts.SourceFile): string | undefined {
437
+ const jsDoc = ts.getJSDocCommentsAndTags(node);
438
+ if (jsDoc && jsDoc.length > 0) {
439
+ return jsDoc[0].getText(sourceFile);
440
+ }
441
+ return undefined;
442
+ }
443
+ }
444
+
445
+ export const typescriptParser = new TypeScriptParser();
@@ -0,0 +1,241 @@
1
+ import { FileInfo } from "./repoScanner.js";
2
+ import { extractSymbols, type SymbolsAnalysis, type Symbol as CodeSymbol } from "../analyzers/symbols.js";
3
+ import { parserRegistry, createSymbolFromParsed } from "./parsers/index.js";
4
+ import { architectureDetector, type ArchitectureAnalysis } from "./analysis/architectureDetector.js";
5
+ import { dependencyAnalyzer, type DependencyGraph } from "./analysis/dependencyAnalyzer.js";
6
+ import { aiContextGenerator } from "./generation/aiContextGenerator.js";
7
+ import { flowGenerator } from "./generation/flowGenerator.js";
8
+ import { architectureGenerator } from "./generation/architectureGenerator.js";
9
+ import { readFile } from "../utils/fileUtils.js";
10
+
11
+ export interface AnalysisResult {
12
+ symbols: SymbolsAnalysis;
13
+ architecture: ArchitectureAnalysis;
14
+ dependencyGraph: DependencyGraph;
15
+ aiContext: string;
16
+ architectureDoc: string;
17
+ flows: Array<{
18
+ name: string;
19
+ type: string;
20
+ files: string[];
21
+ layers: string[];
22
+ }>;
23
+ metrics: {
24
+ duration: number;
25
+ filesProcessed: number;
26
+ symbolsExtracted: number;
27
+ cacheHitRate: number;
28
+ };
29
+ }
30
+
31
+ interface CacheEntry {
32
+ symbols: CodeSymbol[];
33
+ mtime: number;
34
+ }
35
+
36
+ export class AnalysisPipeline {
37
+ private cache: Map<string, CacheEntry> = new Map();
38
+ private stats = { cacheHits: 0, cacheMisses: 0 };
39
+
40
+ async run(files: FileInfo[], projectName: string): Promise<AnalysisResult> {
41
+ const startTime = Date.now();
42
+
43
+ try {
44
+ const symbols = this.extractSymbolsWithAST(files);
45
+
46
+ const cacheHitRate = this.stats.cacheHits + this.stats.cacheMisses > 0
47
+ ? Math.round((this.stats.cacheHits / (this.stats.cacheHits + this.stats.cacheMisses)) * 100)
48
+ : 0;
49
+
50
+ const dependencyGraph = this.buildDependencyGraph(symbols);
51
+
52
+ const architecture = architectureDetector.detect(
53
+ symbols.symbols,
54
+ { edges: dependencyGraph.edges }
55
+ );
56
+
57
+ const flows = flowGenerator.generateFlows(
58
+ architecture.entryPoints,
59
+ symbols.symbols,
60
+ { edges: dependencyGraph.edges },
61
+ { edges: [] },
62
+ { edges: [] }
63
+ );
64
+
65
+ const aiContext = aiContextGenerator.generate({
66
+ architecture,
67
+ symbols: symbols.symbols,
68
+ dependencies: {
69
+ totalDependencies: dependencyGraph.edges.length,
70
+ dependencies: dependencyGraph.edges.map((e) => ({
71
+ source: e.from,
72
+ target: e.to,
73
+ type: e.type,
74
+ })),
75
+ },
76
+ projectName,
77
+ });
78
+
79
+ const architectureDoc = architectureGenerator.generate(architecture, dependencyGraph);
80
+
81
+ const duration = Date.now() - startTime;
82
+
83
+ return {
84
+ symbols,
85
+ architecture,
86
+ dependencyGraph,
87
+ aiContext,
88
+ architectureDoc,
89
+ flows: flows.map((f) => ({
90
+ name: f.name,
91
+ type: f.type,
92
+ files: f.files.map((fi) => fi.path),
93
+ layers: f.layers,
94
+ })),
95
+ metrics: {
96
+ duration,
97
+ filesProcessed: files.length,
98
+ symbolsExtracted: symbols.symbols.length,
99
+ cacheHitRate,
100
+ },
101
+ };
102
+ } catch (error) {
103
+ console.error("Analysis pipeline failed:", error);
104
+ throw error;
105
+ }
106
+ }
107
+
108
+ private extractSymbolsWithAST(files: FileInfo[]): SymbolsAnalysis {
109
+ const allSymbols: SymbolsAnalysis["symbols"] = [];
110
+ const byFile: Record<string, SymbolsAnalysis["symbols"]> = {};
111
+
112
+ const BATCH_SIZE = 50;
113
+ for (let i = 0; i < files.length; i += BATCH_SIZE) {
114
+ const batch = files.slice(i, i + BATCH_SIZE);
115
+
116
+ const batchResults = batch.map(file => {
117
+ const cached = this.getCachedSymbols(file);
118
+ if (cached) {
119
+ return { filePath: file.relativePath, symbols: cached };
120
+ }
121
+ return this.processFile(file);
122
+ });
123
+
124
+ for (const result of batchResults) {
125
+ if (result && result.symbols.length > 0) {
126
+ allSymbols.push(...result.symbols);
127
+ byFile[result.filePath] = result.symbols;
128
+ }
129
+ }
130
+ }
131
+
132
+ const byId: Record<string, (typeof allSymbols)[0]> = {};
133
+ for (const sym of allSymbols) {
134
+ byId[sym.id] = sym;
135
+ }
136
+
137
+ const byType: Record<string, typeof allSymbols> = {};
138
+ for (const sym of allSymbols) {
139
+ if (!byType[sym.type]) byType[sym.type] = [];
140
+ byType[sym.type].push(sym);
141
+ }
142
+
143
+ return {
144
+ symbols: allSymbols,
145
+ byId,
146
+ byFile,
147
+ byType,
148
+ };
149
+ }
150
+
151
+ private getCachedSymbols(file: FileInfo): CodeSymbol[] | null {
152
+ const cached = this.cache.get(file.path);
153
+ if (cached) {
154
+ this.stats.cacheHits++;
155
+ return cached.symbols;
156
+ }
157
+ return null;
158
+ }
159
+
160
+ private processFile(file: FileInfo): { filePath: string; symbols: CodeSymbol[] } | null {
161
+ this.stats.cacheMisses++;
162
+ const ext = "." + file.extension;
163
+ let symbols: CodeSymbol[] = [];
164
+
165
+ try {
166
+ if (parserRegistry.hasParser(ext)) {
167
+ const content = readFile(file.path);
168
+ const parsed = parserRegistry.parse(file.relativePath, content, ext);
169
+
170
+ if (parsed) {
171
+ symbols = createSymbolFromParsed(parsed, file.relativePath);
172
+ }
173
+ } else {
174
+ const existing = extractSymbols([file]);
175
+ symbols = existing.symbols;
176
+ }
177
+
178
+ this.cache.set(file.path, { symbols, mtime: Date.now() });
179
+
180
+ if (this.cache.size > 1000) {
181
+ const firstKey = this.cache.keys().next().value;
182
+ if (firstKey !== undefined) {
183
+ this.cache.delete(firstKey);
184
+ }
185
+ }
186
+
187
+ return { filePath: file.relativePath, symbols };
188
+ } catch (error) {
189
+ console.warn(`Failed to process ${file.path}:`, error);
190
+ const fallbackSymbols = this.fallbackToRegex(file);
191
+ return { filePath: file.relativePath, symbols: fallbackSymbols };
192
+ }
193
+ }
194
+
195
+ private fallbackToRegex(file: FileInfo): CodeSymbol[] {
196
+ const existing = extractSymbols([file]);
197
+ return existing.symbols;
198
+ }
199
+
200
+ private buildDependencyGraph(symbols: SymbolsAnalysis): DependencyGraph {
201
+ const files: Array<{ filePath: string; imports: Array<{ name: string; module: string; isDefault?: boolean }>; exports: string[] }> = [];
202
+
203
+ for (const [filePath, fileSymbols] of Object.entries(symbols.byFile)) {
204
+ const imports: Array<{ name: string; module: string; isDefault?: boolean }> = [];
205
+ const exports: string[] = [];
206
+
207
+ for (const sym of fileSymbols) {
208
+ if (sym.export) {
209
+ exports.push(sym.name);
210
+ }
211
+ }
212
+
213
+ files.push({ filePath, imports, exports });
214
+ }
215
+
216
+ return dependencyAnalyzer.buildDependencyGraph(files);
217
+ }
218
+
219
+ clearCache(): void {
220
+ this.cache.clear();
221
+ this.stats = { cacheHits: 0, cacheMisses: 0 };
222
+ }
223
+
224
+ getMetrics(): {
225
+ cacheSize: number;
226
+ cacheHits: number;
227
+ cacheMisses: number;
228
+ cacheHitRate: number;
229
+ } {
230
+ const total = this.stats.cacheHits + this.stats.cacheMisses;
231
+ const cacheHitRate = total > 0 ? Math.round((this.stats.cacheHits / total) * 100) : 0;
232
+ return {
233
+ cacheSize: this.cache.size,
234
+ cacheHits: this.stats.cacheHits,
235
+ cacheMisses: this.stats.cacheMisses,
236
+ cacheHitRate,
237
+ };
238
+ }
239
+ }
240
+
241
+ export const analysisPipeline = new AnalysisPipeline();