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,158 @@
1
+ export interface Call {
2
+ caller: string;
3
+ callee: string;
4
+ location: {
5
+ file: string;
6
+ line: number;
7
+ character: number;
8
+ };
9
+ arguments?: string[];
10
+ }
11
+
12
+ export interface CallGraph {
13
+ nodes: string[];
14
+ edges: Call[];
15
+ callsByFunction: Map<string, Call[]>;
16
+ calledBy: Map<string, Call[]>;
17
+ }
18
+
19
+ export class CallGraphBuilder {
20
+ buildCallGraph(
21
+ symbols: Array<{
22
+ id: string;
23
+ name: string;
24
+ file: string;
25
+ type: string;
26
+ }>,
27
+ callExpressions: Array<{
28
+ caller: string;
29
+ callee: string;
30
+ line: number;
31
+ character: number;
32
+ args?: string[];
33
+ }>
34
+ ): CallGraph {
35
+ const graph: CallGraph = {
36
+ nodes: symbols.map((s) => s.id),
37
+ edges: [],
38
+ callsByFunction: new Map(),
39
+ calledBy: new Map(),
40
+ };
41
+
42
+ for (const expr of callExpressions) {
43
+ const call: Call = {
44
+ caller: expr.caller,
45
+ callee: expr.callee,
46
+ location: {
47
+ file: expr.caller.split("#")[0],
48
+ line: expr.line,
49
+ character: expr.character,
50
+ },
51
+ arguments: expr.args,
52
+ };
53
+
54
+ graph.edges.push(call);
55
+
56
+ const callerCalls = graph.callsByFunction.get(expr.caller) || [];
57
+ callerCalls.push(call);
58
+ graph.callsByFunction.set(expr.caller, callerCalls);
59
+
60
+ const calleeCalled = graph.calledBy.get(expr.callee) || [];
61
+ calleeCalled.push(call);
62
+ graph.calledBy.set(expr.callee, calleeCalled);
63
+ }
64
+
65
+ return graph;
66
+ }
67
+
68
+ findUnusedFunctions(graph: CallGraph): string[] {
69
+ const unused: string[] = [];
70
+
71
+ for (const node of graph.nodes) {
72
+ const calledBy = graph.calledBy.get(node);
73
+ const isEntryPoint = this.isEntryPoint(node);
74
+
75
+ if ((!calledBy || calledBy.length === 0) && !isEntryPoint) {
76
+ unused.push(node);
77
+ }
78
+ }
79
+
80
+ return unused;
81
+ }
82
+
83
+ findDeadCode(graph: CallGraph, entryPoints: string[]): string[] {
84
+ const reachable = new Set<string>();
85
+
86
+ const traverse = (node: string) => {
87
+ if (reachable.has(node)) return;
88
+ reachable.add(node);
89
+
90
+ const calls = graph.callsByFunction.get(node) || [];
91
+ for (const call of calls) {
92
+ traverse(call.callee);
93
+ }
94
+ };
95
+
96
+ for (const entry of entryPoints) {
97
+ traverse(entry);
98
+ }
99
+
100
+ return graph.nodes.filter((n) => !reachable.has(n));
101
+ }
102
+
103
+ getCallChain(graph: CallGraph, startFunction: string, depth: number = 5): string[] {
104
+ const chain: string[] = [];
105
+ const visited = new Set<string>();
106
+
107
+ const traverse = (func: string, currentDepth: number) => {
108
+ if (currentDepth > depth || visited.has(func)) return;
109
+
110
+ visited.add(func);
111
+ chain.push(func);
112
+
113
+ const calls = graph.callsByFunction.get(func) || [];
114
+ for (const call of calls) {
115
+ traverse(call.callee, currentDepth + 1);
116
+ }
117
+ };
118
+
119
+ traverse(startFunction, 0);
120
+ return chain;
121
+ }
122
+
123
+ calculateComplexity(graph: CallGraph, functionId: string): number {
124
+ const outgoing = graph.callsByFunction.get(functionId) || [];
125
+ const incoming = graph.calledBy.get(functionId) || [];
126
+
127
+ return outgoing.length + incoming.length * 2;
128
+ }
129
+
130
+ private isEntryPoint(symbolId: string): boolean {
131
+ const name = symbolId.split("#")[1] || "";
132
+ const file = symbolId.split("#")[0] || "";
133
+
134
+ const entryPatterns = [
135
+ /main$/,
136
+ /index$/,
137
+ /init$/,
138
+ /start$/,
139
+ /handler$/,
140
+ /controller$/,
141
+ /route$/,
142
+ ];
143
+
144
+ if (entryPatterns.some((p) => p.test(name))) return true;
145
+
146
+ if (
147
+ file.includes("main.") ||
148
+ file.includes("index.") ||
149
+ file.includes("app.")
150
+ ) {
151
+ return true;
152
+ }
153
+
154
+ return false;
155
+ }
156
+ }
157
+
158
+ export const callGraphBuilder = new CallGraphBuilder();
@@ -0,0 +1,167 @@
1
+ export interface ImportRelation {
2
+ from: string;
3
+ to: string;
4
+ type: "import" | "export" | "re-export";
5
+ symbols?: string[];
6
+ isDefault?: boolean;
7
+ isNamespace?: boolean;
8
+ }
9
+
10
+ export interface DependencyGraph {
11
+ nodes: string[];
12
+ edges: ImportRelation[];
13
+ importsByFile: Map<string, ImportRelation[]>;
14
+ exportsByFile: Map<string, string[]>;
15
+ }
16
+
17
+ export class DependencyAnalyzer {
18
+ analyzeImports(
19
+ filePath: string,
20
+ imports: Array<{
21
+ name: string;
22
+ module: string;
23
+ isDefault?: boolean;
24
+ isNamespace?: boolean;
25
+ }>,
26
+ exports: string[]
27
+ ): ImportRelation[] {
28
+ const relations: ImportRelation[] = [];
29
+
30
+ for (const imp of imports) {
31
+ relations.push({
32
+ from: filePath,
33
+ to: imp.module,
34
+ type: "import",
35
+ symbols: [imp.name],
36
+ isDefault: imp.isDefault,
37
+ isNamespace: imp.isNamespace,
38
+ });
39
+ }
40
+
41
+ for (const exp of exports) {
42
+ relations.push({
43
+ from: filePath,
44
+ to: "exports",
45
+ type: "export",
46
+ symbols: [exp],
47
+ });
48
+ }
49
+
50
+ return relations;
51
+ }
52
+
53
+ buildDependencyGraph(
54
+ parsedFiles: Array<{
55
+ filePath: string;
56
+ imports: Array<{
57
+ name: string;
58
+ module: string;
59
+ isDefault?: boolean;
60
+ isNamespace?: boolean;
61
+ }>;
62
+ exports: string[];
63
+ }>
64
+ ): DependencyGraph {
65
+ const graph: DependencyGraph = {
66
+ nodes: [],
67
+ edges: [],
68
+ importsByFile: new Map(),
69
+ exportsByFile: new Map(),
70
+ };
71
+
72
+ for (const file of parsedFiles) {
73
+ graph.nodes.push(file.filePath);
74
+
75
+ const relations = this.analyzeImports(
76
+ file.filePath,
77
+ file.imports,
78
+ file.exports
79
+ );
80
+
81
+ graph.edges.push(...relations);
82
+
83
+ const imports = relations.filter((r) => r.type === "import");
84
+ graph.importsByFile.set(file.filePath, imports);
85
+
86
+ const exports = relations
87
+ .filter((r) => r.type === "export")
88
+ .flatMap((r) => r.symbols || []);
89
+ graph.exportsByFile.set(file.filePath, exports);
90
+ }
91
+
92
+ return graph;
93
+ }
94
+
95
+ detectCircularDependencies(graph: DependencyGraph): string[][] {
96
+ const cycles: string[][] = [];
97
+ const visited = new Set<string>();
98
+ const recursionStack = new Set<string>();
99
+
100
+ const dfs = (node: string, path: string[]) => {
101
+ if (recursionStack.has(node)) {
102
+ const cycleStart = path.indexOf(node);
103
+ cycles.push(path.slice(cycleStart).concat([node]));
104
+ return;
105
+ }
106
+
107
+ if (visited.has(node)) return;
108
+
109
+ visited.add(node);
110
+ recursionStack.add(node);
111
+ path.push(node);
112
+
113
+ const outgoingEdges = graph.edges.filter((e) => e.from === node);
114
+ for (const edge of outgoingEdges) {
115
+ if (edge.type === "import") {
116
+ dfs(edge.to, [...path]);
117
+ }
118
+ }
119
+
120
+ recursionStack.delete(node);
121
+ };
122
+
123
+ for (const node of graph.nodes) {
124
+ if (!visited.has(node)) {
125
+ dfs(node, []);
126
+ }
127
+ }
128
+
129
+ return cycles;
130
+ }
131
+
132
+ calculateMetrics(graph: DependencyGraph): {
133
+ totalFiles: number;
134
+ totalImports: number;
135
+ totalExports: number;
136
+ avgImportsPerFile: number;
137
+ mostImported: { module: string; count: number }[];
138
+ } {
139
+ const moduleImportCounts = new Map<string, number>();
140
+
141
+ for (const edge of graph.edges) {
142
+ if (edge.type === "import") {
143
+ const count = moduleImportCounts.get(edge.to) || 0;
144
+ moduleImportCounts.set(edge.to, count + 1);
145
+ }
146
+ }
147
+
148
+ const mostImported = Array.from(moduleImportCounts.entries())
149
+ .map(([module, count]) => ({ module, count }))
150
+ .sort((a, b) => b.count - a.count)
151
+ .slice(0, 10);
152
+
153
+ const importEdges = graph.edges.filter((e) => e.type === "import");
154
+ const exportEdges = graph.edges.filter((e) => e.type === "export");
155
+
156
+ return {
157
+ totalFiles: graph.nodes.length,
158
+ totalImports: importEdges.length,
159
+ totalExports: exportEdges.length,
160
+ avgImportsPerFile:
161
+ graph.nodes.length > 0 ? importEdges.length / graph.nodes.length : 0,
162
+ mostImported,
163
+ };
164
+ }
165
+ }
166
+
167
+ export const dependencyAnalyzer = new DependencyAnalyzer();
@@ -0,0 +1,28 @@
1
+ export {
2
+ DependencyAnalyzer,
3
+ dependencyAnalyzer,
4
+ type ImportRelation,
5
+ type DependencyGraph,
6
+ } from "./dependencyAnalyzer.js";
7
+
8
+ export {
9
+ CallGraphBuilder,
10
+ callGraphBuilder,
11
+ type Call,
12
+ type CallGraph,
13
+ } from "./callGraphBuilder.js";
14
+
15
+ export {
16
+ InheritanceAnalyzer,
17
+ inheritanceAnalyzer,
18
+ type InheritanceRelation,
19
+ type InheritanceGraph,
20
+ } from "./inheritanceAnalyzer.js";
21
+
22
+ export {
23
+ ArchitectureDetector,
24
+ architectureDetector,
25
+ type ArchitecturePattern,
26
+ type Layer,
27
+ type ArchitectureAnalysis,
28
+ } from "./architectureDetector.js";
@@ -0,0 +1,169 @@
1
+ export interface InheritanceRelation {
2
+ child: string;
3
+ parent: string;
4
+ type: "extends" | "implements";
5
+ }
6
+
7
+ export interface InheritanceGraph {
8
+ nodes: string[];
9
+ edges: InheritanceRelation[];
10
+ classHierarchy: Map<string, string[]>;
11
+ implementations: Map<string, string[]>;
12
+ }
13
+
14
+ export class InheritanceAnalyzer {
15
+ buildHierarchy(
16
+ symbols: Array<{
17
+ id: string;
18
+ name: string;
19
+ type: string;
20
+ heritage?: {
21
+ extends?: string[];
22
+ implements?: string[];
23
+ };
24
+ }>
25
+ ): InheritanceGraph {
26
+ const graph: InheritanceGraph = {
27
+ nodes: symbols.filter((s) => s.type === "class" || s.type === "interface").map((s) => s.id),
28
+ edges: [],
29
+ classHierarchy: new Map(),
30
+ implementations: new Map(),
31
+ };
32
+
33
+ for (const symbol of symbols) {
34
+ if (symbol.type !== "class" && symbol.type !== "interface") continue;
35
+
36
+ const parents: string[] = [];
37
+
38
+ if (symbol.heritage?.extends) {
39
+ for (const parent of symbol.heritage.extends) {
40
+ graph.edges.push({
41
+ child: symbol.id,
42
+ parent,
43
+ type: "extends",
44
+ });
45
+ parents.push(parent);
46
+ }
47
+ }
48
+
49
+ if (symbol.heritage?.implements) {
50
+ for (const iface of symbol.heritage.implements) {
51
+ graph.edges.push({
52
+ child: symbol.id,
53
+ parent: iface,
54
+ type: "implements",
55
+ });
56
+
57
+ const impls = graph.implementations.get(iface) || [];
58
+ impls.push(symbol.id);
59
+ graph.implementations.set(iface, impls);
60
+ }
61
+ }
62
+
63
+ if (parents.length > 0) {
64
+ graph.classHierarchy.set(symbol.id, parents);
65
+ }
66
+ }
67
+
68
+ return graph;
69
+ }
70
+
71
+ getAncestors(graph: InheritanceGraph, classId: string): string[] {
72
+ const ancestors: string[] = [];
73
+ const visited = new Set<string>();
74
+
75
+ const traverse = (current: string) => {
76
+ if (visited.has(current)) return;
77
+ visited.add(current);
78
+
79
+ const edges = graph.edges.filter((e) => e.child === current);
80
+ for (const edge of edges) {
81
+ ancestors.push(edge.parent);
82
+ traverse(edge.parent);
83
+ }
84
+ };
85
+
86
+ traverse(classId);
87
+ return ancestors;
88
+ }
89
+
90
+ getDescendants(graph: InheritanceGraph, classId: string): string[] {
91
+ const descendants: string[] = [];
92
+ const visited = new Set<string>();
93
+
94
+ const traverse = (current: string) => {
95
+ if (visited.has(current)) return;
96
+ visited.add(current);
97
+
98
+ const edges = graph.edges.filter(
99
+ (e) => e.parent === current && e.type === "extends"
100
+ );
101
+ for (const edge of edges) {
102
+ descendants.push(edge.child);
103
+ traverse(edge.child);
104
+ }
105
+ };
106
+
107
+ traverse(classId);
108
+ return descendants;
109
+ }
110
+
111
+ getImplementations(graph: InheritanceGraph, interfaceName: string): string[] {
112
+ return graph.implementations.get(interfaceName) || [];
113
+ }
114
+
115
+ detectInheritanceDepth(graph: InheritanceGraph): Map<string, number> {
116
+ const depths = new Map<string, number>();
117
+
118
+ const calculateDepth = (classId: string): number => {
119
+ if (depths.has(classId)) return depths.get(classId)!;
120
+
121
+ const parents = graph.classHierarchy.get(classId) || [];
122
+ if (parents.length === 0) {
123
+ depths.set(classId, 0);
124
+ return 0;
125
+ }
126
+
127
+ const parentDepths = parents.map((p) => calculateDepth(p));
128
+ const depth = Math.max(...parentDepths) + 1;
129
+ depths.set(classId, depth);
130
+ return depth;
131
+ };
132
+
133
+ for (const node of graph.nodes) {
134
+ calculateDepth(node);
135
+ }
136
+
137
+ return depths;
138
+ }
139
+
140
+ findBaseClasses(graph: InheritanceGraph): string[] {
141
+ return graph.nodes.filter((node) => {
142
+ const parents = graph.classHierarchy.get(node);
143
+ return !parents || parents.length === 0;
144
+ });
145
+ }
146
+
147
+ calculateInheritanceMetrics(graph: InheritanceGraph): {
148
+ totalClasses: number;
149
+ totalInterfaces: number;
150
+ inheritanceDepth: number;
151
+ multipleInheritance: number;
152
+ } {
153
+ const depths = this.detectInheritanceDepth(graph);
154
+ const maxDepth = Math.max(...depths.values(), 0);
155
+
156
+ const multipleInheritance = Array.from(graph.classHierarchy.values()).filter(
157
+ (parents) => parents.length > 1
158
+ ).length;
159
+
160
+ return {
161
+ totalClasses: graph.nodes.length,
162
+ totalInterfaces: graph.implementations.size,
163
+ inheritanceDepth: maxDepth,
164
+ multipleInheritance,
165
+ };
166
+ }
167
+ }
168
+
169
+ export const inheritanceAnalyzer = new InheritanceAnalyzer();
package/src/core/ccp.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { ensureDir, writeFile, readJsonFile } from "../utils/fileUtils.js";
4
+ import { getCcpDir, getCcpPath } from "../utils/constants.js";
4
5
 
5
6
  export interface ContextModule {
6
7
  name: string;
@@ -206,7 +207,7 @@ export function createCCP(
206
207
  * List all CCPs
207
208
  */
208
209
  export function listCCPs(rootDir: string): string[] {
209
- const ccpDir = path.join(rootDir, "ai", "ccp");
210
+ const ccpDir = getCcpDir(rootDir);
210
211
 
211
212
  if (!fs.existsSync(ccpDir)) {
212
213
  return [];
@@ -222,7 +223,7 @@ export function listCCPs(rootDir: string): string[] {
222
223
  * Get CCP details
223
224
  */
224
225
  export function getCCP(rootDir: string, name: string): CCPContext | null {
225
- const contextPath = path.join(rootDir, "ai", "ccp", name, "context.json");
226
+ const contextPath = getCcpPath(rootDir, name);
226
227
 
227
228
  if (!fs.existsSync(contextPath)) {
228
229
  return null;