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,216 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ aiContextGenerator,
4
+ flowGenerator,
5
+ architectureGenerator,
6
+ } from "../src/core/generation/index.js";
7
+
8
+ describe("AI Context Generator", () => {
9
+ it("should generate enriched context", () => {
10
+ const analysis = {
11
+ architecture: {
12
+ primary: {
13
+ name: "Layered Architecture",
14
+ confidence: 0.85,
15
+ evidence: ["Found 3 layers", "Clear separation of concerns"],
16
+ },
17
+ secondary: [],
18
+ layers: [
19
+ {
20
+ name: "API",
21
+ symbols: ["src/controller.ts#UserController"],
22
+ files: ["src/controller.ts"],
23
+ responsibility: "Handle HTTP requests",
24
+ },
25
+ {
26
+ name: "Service",
27
+ symbols: ["src/service.ts#UserService"],
28
+ files: ["src/service.ts"],
29
+ responsibility: "Business logic",
30
+ },
31
+ ],
32
+ entryPoints: ["src/main.ts#main"],
33
+ },
34
+ symbols: [
35
+ { id: "src/controller.ts#UserController", name: "UserController", type: "class", file: "src/controller.ts" },
36
+ { id: "src/service.ts#UserService", name: "UserService", type: "class", file: "src/service.ts" },
37
+ { id: "src/main.ts#main", name: "main", type: "function", file: "src/main.ts" },
38
+ ],
39
+ dependencies: {
40
+ totalDependencies: 10,
41
+ dependencies: [
42
+ { source: "src/controller.ts", target: "src/service.ts", type: "import" },
43
+ ],
44
+ },
45
+ projectName: "TestApp",
46
+ };
47
+
48
+ const context = aiContextGenerator.generate(analysis);
49
+
50
+ expect(context).toContain("# AI Context: TestApp");
51
+ expect(context).toContain("Layered Architecture");
52
+ expect(context).toContain("85%");
53
+ expect(context).toContain("API");
54
+ expect(context).toContain("Service");
55
+ expect(context).toContain("main");
56
+ expect(context).toContain("Total Files");
57
+ expect(context).toContain("Total Symbols");
58
+ });
59
+
60
+ it("should detect project type", () => {
61
+ const analysis = {
62
+ architecture: {
63
+ primary: null,
64
+ secondary: [],
65
+ layers: [],
66
+ entryPoints: [],
67
+ },
68
+ symbols: [
69
+ { id: "src/controller.ts#Test", name: "Test", type: "class", file: "src/controller.ts" },
70
+ ],
71
+ dependencies: { totalDependencies: 0, dependencies: [] },
72
+ projectName: "Test",
73
+ };
74
+
75
+ const context = aiContextGenerator.generate(analysis);
76
+
77
+ expect(context).toContain("MVC Web Application");
78
+ });
79
+ });
80
+
81
+ describe("Flow Generator", () => {
82
+ it("should generate enriched flows", () => {
83
+ const entryPoints = ["src/auth.ts#login"];
84
+ const symbols = [
85
+ { id: "src/auth.ts#login", name: "login", type: "function", file: "src/auth.ts" },
86
+ { id: "src/service.ts#validate", name: "validate", type: "function", file: "src/service.ts" },
87
+ ];
88
+ const dependencyGraph = {
89
+ edges: [{ from: "src/auth.ts#login", to: "src/service.ts#validate", type: "import" }],
90
+ };
91
+ const callGraph = {
92
+ edges: [{ caller: "src/auth.ts#login", callee: "src/service.ts#validate" }],
93
+ };
94
+ const inheritanceGraph = { edges: [] };
95
+
96
+ const flows = flowGenerator.generateFlows(
97
+ entryPoints,
98
+ symbols,
99
+ dependencyGraph,
100
+ callGraph,
101
+ inheritanceGraph
102
+ );
103
+
104
+ expect(flows).toHaveLength(1);
105
+ expect(flows[0].name).toBe("login");
106
+ expect(flows[0].type).toBe("API Endpoint");
107
+ expect(flows[0].files).toHaveLength(2);
108
+ expect(flows[0].dependencies.calls).toContain("src/service.ts#validate");
109
+ });
110
+
111
+ it("should detect layers in flow", () => {
112
+ const entryPoints = ["src/controller.ts#getUser"];
113
+ const symbols = [
114
+ { id: "src/controller.ts#getUser", name: "getUser", type: "function", file: "src/controller.ts" },
115
+ { id: "src/service.ts#findUser", name: "findUser", type: "function", file: "src/service.ts" },
116
+ ];
117
+
118
+ const callGraph = {
119
+ edges: [{ caller: "src/controller.ts#getUser", callee: "src/service.ts#findUser" }],
120
+ };
121
+
122
+ const flows = flowGenerator.generateFlows(
123
+ entryPoints,
124
+ symbols,
125
+ { edges: [] },
126
+ callGraph,
127
+ { edges: [] }
128
+ );
129
+
130
+ expect(flows[0].layers).toContain("api");
131
+ expect(flows[0].layers).toContain("service");
132
+ });
133
+
134
+ it("should calculate complexity", () => {
135
+ const entryPoints = ["src/simple.ts#simple"];
136
+ const symbols = [{ id: "src/simple.ts#simple", name: "simple", type: "function", file: "src/simple.ts" }];
137
+
138
+ const flows = flowGenerator.generateFlows(
139
+ entryPoints,
140
+ symbols,
141
+ { edges: [] },
142
+ { edges: [] },
143
+ { edges: [] }
144
+ );
145
+
146
+ expect(flows[0].complexity).toBe("low");
147
+ expect(flows[0].depth).toBe(1);
148
+ });
149
+ });
150
+
151
+ describe("Architecture Generator", () => {
152
+ it("should generate architecture markdown", () => {
153
+ const analysis = {
154
+ primary: {
155
+ name: "MVC",
156
+ confidence: 0.9,
157
+ evidence: ["Found controllers", "Found models"],
158
+ },
159
+ secondary: [],
160
+ layers: [
161
+ { name: "Controller", symbols: ["ctrl1", "ctrl2"], files: ["ctrl.ts"], responsibility: "Handle requests" },
162
+ { name: "Model", symbols: ["model1"], files: ["model.ts"], responsibility: "Data" },
163
+ ],
164
+ entryPoints: ["main"],
165
+ };
166
+
167
+ const dependencyGraph = {
168
+ nodes: ["ctrl1", "model1"],
169
+ edges: [{ from: "ctrl1", to: "model1", type: "import" }],
170
+ };
171
+
172
+ const markdown = architectureGenerator.generate(analysis, dependencyGraph);
173
+
174
+ expect(markdown).toContain("# Architecture");
175
+ expect(markdown).toContain("MVC");
176
+ expect(markdown).toContain("90%");
177
+ expect(markdown).toContain("Controller");
178
+ expect(markdown).toContain("Model");
179
+ expect(markdown).toContain("Architecture Diagram");
180
+ expect(markdown).toContain("mermaid");
181
+ });
182
+
183
+ it("should generate mermaid diagram", () => {
184
+ const analysis = {
185
+ primary: { name: "Layered", confidence: 0.8, evidence: [] },
186
+ secondary: [],
187
+ layers: [{ name: "API", symbols: ["api1"], files: ["api.ts"], responsibility: "" }],
188
+ entryPoints: [],
189
+ };
190
+
191
+ const dependencyGraph = {
192
+ nodes: ["api1", "svc1"],
193
+ edges: [{ from: "api1", to: "svc1", type: "import" }],
194
+ };
195
+
196
+ const markdown = architectureGenerator.generate(analysis, dependencyGraph);
197
+
198
+ expect(markdown).toContain("graph TD");
199
+ expect(markdown).toContain("api1");
200
+ expect(markdown).toContain("svc1");
201
+ });
202
+
203
+ it("should handle unknown patterns", () => {
204
+ const analysis = {
205
+ primary: null,
206
+ secondary: [],
207
+ layers: [],
208
+ entryPoints: [],
209
+ };
210
+
211
+ const markdown = architectureGenerator.generate(analysis, { nodes: [], edges: [] });
212
+
213
+ expect(markdown).toContain("Unknown");
214
+ expect(markdown).toContain("No strong pattern detected");
215
+ });
216
+ });
@@ -0,0 +1,139 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { parserRegistry, createSymbolFromParsed } from "../src/core/parsers/index.js";
3
+
4
+ describe("Parser Registry", () => {
5
+ it("should return TypeScript parser for .ts files", () => {
6
+ const parser = parserRegistry.getParser(".ts");
7
+ expect(parser).toBeDefined();
8
+ });
9
+
10
+ it("should return TypeScript parser for .tsx files", () => {
11
+ const parser = parserRegistry.getParser(".tsx");
12
+ expect(parser).toBeDefined();
13
+ });
14
+
15
+ it("should return TypeScript parser for .js files", () => {
16
+ const parser = parserRegistry.getParser(".js");
17
+ expect(parser).toBeDefined();
18
+ });
19
+
20
+ it("should return Python parser for .py files", () => {
21
+ const parser = parserRegistry.getParser(".py");
22
+ expect(parser).toBeDefined();
23
+ });
24
+
25
+ it("should return undefined for unsupported extensions", () => {
26
+ const parser = parserRegistry.getParser(".unknown");
27
+ expect(parser).toBeUndefined();
28
+ });
29
+
30
+ it("should be case insensitive", () => {
31
+ const parserLower = parserRegistry.getParser(".ts");
32
+ const parserUpper = parserRegistry.getParser(".TS");
33
+ expect(parserLower).toBe(parserUpper);
34
+ });
35
+
36
+ it("should check if parser exists", () => {
37
+ expect(parserRegistry.hasParser(".ts")).toBe(true);
38
+ expect(parserRegistry.hasParser(".py")).toBe(true);
39
+ expect(parserRegistry.hasParser(".unknown")).toBe(false);
40
+ });
41
+
42
+ it("should return list of supported extensions", () => {
43
+ const extensions = parserRegistry.getSupportedExtensions();
44
+ expect(extensions).toContain(".ts");
45
+ expect(extensions).toContain(".tsx");
46
+ expect(extensions).toContain(".js");
47
+ expect(extensions).toContain(".py");
48
+ });
49
+
50
+ it("should parse TypeScript file", () => {
51
+ const source = `
52
+ export class UserService {
53
+ async findById(id: string) {
54
+ return null;
55
+ }
56
+ }
57
+ `;
58
+
59
+ const result = parserRegistry.parse("test.ts", source);
60
+ expect(result).toBeDefined();
61
+ expect(result?.symbols).toHaveLength(1);
62
+ expect(result?.symbols[0].name).toBe("UserService");
63
+ });
64
+
65
+ it("should parse Python file", () => {
66
+ const source = `
67
+ class UserService:
68
+ def find_by_id(self, id):
69
+ return None
70
+ `;
71
+
72
+ const result = parserRegistry.parse("test.py", source);
73
+ expect(result).toBeDefined();
74
+ expect(result?.symbols).toHaveLength(1);
75
+ expect(result?.symbols[0].name).toBe("UserService");
76
+ });
77
+
78
+ it("should return null for unsupported files", () => {
79
+ const result = parserRegistry.parse("test.unknown", "content");
80
+ expect(result).toBeNull();
81
+ });
82
+
83
+ it("should create symbols from parsed TypeScript", () => {
84
+ const source = `
85
+ export class UserService {
86
+ async findById(id: string): Promise<User | null> {
87
+ return null;
88
+ }
89
+ }
90
+
91
+ export interface User {
92
+ id: string;
93
+ name: string;
94
+ }
95
+ `;
96
+
97
+ const parsed = parserRegistry.parse("test.ts", source);
98
+ expect(parsed).toBeDefined();
99
+
100
+ const symbols = createSymbolFromParsed(parsed!, "test.ts");
101
+
102
+ expect(symbols.length).toBeGreaterThanOrEqual(2);
103
+
104
+ const userService = symbols.find(s => s.name === "UserService");
105
+ expect(userService).toBeDefined();
106
+ expect(userService?.type).toBe("class");
107
+ expect(userService?.export).toBe(true);
108
+
109
+ const userInterface = symbols.find(s => s.name === "User");
110
+ expect(userInterface).toBeDefined();
111
+ expect(userInterface?.type).toBe("interface");
112
+ });
113
+
114
+ it("should create symbols from parsed Python", () => {
115
+ const source = `
116
+ class UserService:
117
+ def find_by_id(self, id: str):
118
+ return None
119
+
120
+ def helper_function():
121
+ pass
122
+ `;
123
+
124
+ const parsed = parserRegistry.parse("test.py", source);
125
+ expect(parsed).toBeDefined();
126
+
127
+ const symbols = createSymbolFromParsed(parsed!, "test.py");
128
+
129
+ expect(symbols.length).toBeGreaterThanOrEqual(2);
130
+
131
+ const userService = symbols.find(s => s.name === "UserService");
132
+ expect(userService).toBeDefined();
133
+ expect(userService?.type).toBe("class");
134
+
135
+ const helperFunc = symbols.find(s => s.name === "helper_function");
136
+ expect(helperFunc).toBeDefined();
137
+ expect(helperFunc?.type).toBe("function");
138
+ });
139
+ });
@@ -0,0 +1,245 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import { AnalysisPipeline } from "../src/core/pipeline";
3
+ import type { FileInfo } from "../src/core/repoScanner";
4
+
5
+ describe("AnalysisPipeline Integration", () => {
6
+ let pipeline: AnalysisPipeline;
7
+
8
+ beforeEach(() => {
9
+ pipeline = new AnalysisPipeline();
10
+ });
11
+
12
+ it("should analyze TypeScript files with AST parser", async () => {
13
+ const files: FileInfo[] = [
14
+ {
15
+ path: "/project/src/user.ts",
16
+ relativePath: "src/user.ts",
17
+ name: "user.ts",
18
+ extension: "ts",
19
+ },
20
+ ];
21
+
22
+ const content = `
23
+ export class User {
24
+ name: string;
25
+ constructor(name: string) {
26
+ this.name = name;
27
+ }
28
+ }
29
+
30
+ export function createUser(name: string): User {
31
+ return new User(name);
32
+ }
33
+
34
+ export interface IUser {
35
+ name: string;
36
+ }
37
+
38
+ export type UserId = string;
39
+ `;
40
+
41
+ const fs = await import("node:fs");
42
+ const tempFile = "/tmp/test-user.ts";
43
+ fs.writeFileSync(tempFile, content);
44
+
45
+ files[0].path = tempFile;
46
+
47
+ const result = await pipeline.run(files, "TestProject");
48
+
49
+ expect(result.symbols.symbols.length).toBeGreaterThan(0);
50
+ expect(result.symbols.symbols.some(s => s.name === "User" && s.type === "class")).toBe(true);
51
+ expect(result.symbols.symbols.some(s => s.name === "createUser" && s.type === "function")).toBe(true);
52
+ expect(result.symbols.symbols.some(s => s.name === "IUser" && s.type === "interface")).toBe(true);
53
+ expect(result.symbols.symbols.some(s => s.name === "UserId" && s.type === "type")).toBe(true);
54
+
55
+ expect(result.metrics.duration).toBeGreaterThan(0);
56
+ expect(result.metrics.filesProcessed).toBe(1);
57
+
58
+ fs.unlinkSync(tempFile);
59
+ });
60
+
61
+ it("should detect architecture pattern", async () => {
62
+ const files: FileInfo[] = [
63
+ {
64
+ path: "/project/src/controllers/userController.ts",
65
+ relativePath: "src/controllers/userController.ts",
66
+ name: "userController.ts",
67
+ extension: "ts",
68
+ },
69
+ {
70
+ path: "/project/src/services/userService.ts",
71
+ relativePath: "src/services/userService.ts",
72
+ name: "userService.ts",
73
+ extension: "ts",
74
+ },
75
+ {
76
+ path: "/project/src/repositories/userRepository.ts",
77
+ relativePath: "src/repositories/userRepository.ts",
78
+ name: "userRepository.ts",
79
+ extension: "ts",
80
+ },
81
+ ];
82
+
83
+ const controllerContent = `
84
+ export class UserController {
85
+ constructor(private userService: UserService) {}
86
+ async getUser(id: string) {
87
+ return this.userService.findById(id);
88
+ }
89
+ }
90
+ `;
91
+
92
+ const serviceContent = `
93
+ export class UserService {
94
+ constructor(private userRepo: UserRepository) {}
95
+ async findById(id: string) {
96
+ return this.userRepo.findOne(id);
97
+ }
98
+ }
99
+ `;
100
+
101
+ const repoContent = `
102
+ export class UserRepository {
103
+ async findOne(id: string) {
104
+ return { id, name: "Test" };
105
+ }
106
+ }
107
+ `;
108
+
109
+ const fs = await import("node:fs");
110
+ const filesWithContent = [
111
+ { path: "/tmp/test-controller.ts", content: controllerContent },
112
+ { path: "/tmp/test-service.ts", content: serviceContent },
113
+ { path: "/tmp/test-repo.ts", content: repoContent },
114
+ ];
115
+
116
+ filesWithContent.forEach(({ path, content }) => {
117
+ fs.writeFileSync(path, content);
118
+ });
119
+
120
+ files[0].path = "/tmp/test-controller.ts";
121
+ files[1].path = "/tmp/test-service.ts";
122
+ files[2].path = "/tmp/test-repo.ts";
123
+
124
+ const result = await pipeline.run(files, "TestProject");
125
+
126
+ expect(result.architecture.primary !== null || result.architecture.secondary.length > 0).toBe(true);
127
+ expect(result.architecture.layers.length).toBeGreaterThan(0);
128
+ expect(result.metrics.filesProcessed).toBe(3);
129
+
130
+ filesWithContent.forEach(({ path }) => {
131
+ fs.unlinkSync(path);
132
+ });
133
+ });
134
+
135
+ it("should generate AI context", async () => {
136
+ const files: FileInfo[] = [
137
+ {
138
+ path: "/project/src/auth.ts",
139
+ relativePath: "src/auth.ts",
140
+ name: "auth.ts",
141
+ extension: "ts",
142
+ },
143
+ ];
144
+
145
+ const content = `
146
+ export function authenticate(token: string): boolean {
147
+ return token.length > 0;
148
+ }
149
+
150
+ export class AuthMiddleware {
151
+ handle(req: any, res: any, next: any) {
152
+ next();
153
+ }
154
+ }
155
+ `;
156
+
157
+ const fs = await import("node:fs");
158
+ fs.writeFileSync("/tmp/test-auth.ts", content);
159
+ files[0].path = "/tmp/test-auth.ts";
160
+
161
+ const result = await pipeline.run(files, "AuthService");
162
+
163
+ expect(result.aiContext).toContain("AuthService");
164
+ expect(result.aiContext.length).toBeGreaterThan(100);
165
+ expect(result.architectureDoc.length).toBeGreaterThan(0);
166
+
167
+ fs.unlinkSync("/tmp/test-auth.ts");
168
+ });
169
+
170
+ it("should cache and clear cache correctly", async () => {
171
+ const pipeline = new AnalysisPipeline();
172
+
173
+ expect(pipeline.getMetrics().cacheSize).toBe(0);
174
+
175
+ pipeline.clearCache();
176
+ expect(pipeline.getMetrics().cacheSize).toBe(0);
177
+ });
178
+
179
+ it("should handle empty file list", async () => {
180
+ const result = await pipeline.run([], "EmptyProject");
181
+
182
+ expect(result.symbols.symbols).toEqual([]);
183
+ expect(result.metrics.filesProcessed).toBe(0);
184
+ expect(result.metrics.duration).toBeGreaterThanOrEqual(0);
185
+ });
186
+
187
+ it("should handle unsupported file types gracefully", async () => {
188
+ const files: FileInfo[] = [
189
+ {
190
+ path: "/project/readme.md",
191
+ relativePath: "readme.md",
192
+ name: "readme.md",
193
+ extension: "md",
194
+ },
195
+ {
196
+ path: "/project/config.yaml",
197
+ relativePath: "config.yaml",
198
+ name: "config.yaml",
199
+ extension: "yaml",
200
+ },
201
+ ];
202
+
203
+ const result = await pipeline.run(files, "MixedProject");
204
+
205
+ expect(result.metrics.filesProcessed).toBe(2);
206
+ expect(result.symbols.symbols.length).toBe(0);
207
+ });
208
+
209
+ it("should generate dependency graph", async () => {
210
+ const files: FileInfo[] = [
211
+ {
212
+ path: "/project/src/app.ts",
213
+ relativePath: "src/app.ts",
214
+ name: "app.ts",
215
+ extension: "ts",
216
+ },
217
+ ];
218
+
219
+ const content = `
220
+ import { UserService } from './services/userService';
221
+ import { Config } from './config';
222
+
223
+ export class App {
224
+ constructor(private userService: UserService) {}
225
+ start() {
226
+ console.log('Starting...');
227
+ }
228
+ }
229
+
230
+ export const app = new App();
231
+ `;
232
+
233
+ const fs = await import("node:fs");
234
+ fs.writeFileSync("/tmp/test-app.ts", content);
235
+ files[0].path = "/tmp/test-app.ts";
236
+
237
+ const result = await pipeline.run(files, "TestApp");
238
+
239
+ expect(result.dependencyGraph).toBeDefined();
240
+ expect(result.dependencyGraph.edges).toBeDefined();
241
+ expect(result.dependencyGraph.nodes).toBeDefined();
242
+
243
+ fs.unlinkSync("/tmp/test-app.ts");
244
+ });
245
+ });