@girardelli/architect 2.2.0 → 4.0.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 (296) hide show
  1. package/README.md +105 -116
  2. package/__test_agent_output__/INDEX.md +1 -0
  3. package/__test_agent_output__/agents/AGENT-ORCHESTRATOR.md +1 -0
  4. package/__test_agent_output__/agents/DATABASE-ENGINEER.md +174 -0
  5. package/__test_agent_output__/agents/QA-TEST-ENGINEER.md +138 -0
  6. package/__test_agent_output__/agents/SECURITY-AUDITOR.md +106 -0
  7. package/__test_agent_output__/agents/TECH-DEBT-CONTROLLER.md +104 -0
  8. package/__test_agent_output__/agents/TYPESCRIPT-BACKEND-DEVELOPER.md +135 -0
  9. package/__test_agent_output__/guards/CODE-REVIEW-CHECKLIST.md +95 -0
  10. package/__test_agent_output__/guards/PREFLIGHT.md +200 -0
  11. package/__test_agent_output__/guards/QUALITY-GATES.md +1 -0
  12. package/__test_agent_output__/rules/00-general.md +229 -0
  13. package/__test_agent_output__/rules/01-architecture.md +191 -0
  14. package/__test_agent_output__/rules/02-security.md +402 -0
  15. package/__test_agent_output__/rules/03-nestjs.md +124 -0
  16. package/__test_agent_output__/templates/ADR.md +95 -0
  17. package/__test_agent_output__/templates/BDD.md +58 -0
  18. package/__test_agent_output__/templates/C4.md +68 -0
  19. package/__test_agent_output__/templates/TDD.md +86 -0
  20. package/__test_agent_output__/templates/THREAT-MODEL.md +82 -0
  21. package/__test_agent_output__/workflows/fix-bug.md +228 -0
  22. package/__test_agent_output__/workflows/new-feature.md +311 -0
  23. package/__test_agent_output__/workflows/review.md +95 -0
  24. package/__test_context_7RvUrO/src/modules/empty/empty.ts +0 -0
  25. package/__test_context_Rf5fNJ/src/modules/mixed/mixed.ts +5 -0
  26. package/__test_context_WRCnYH/src/modules/test/test.ts +10 -0
  27. package/__test_context_YsnVS3/src/modules/test/test.ts +10 -0
  28. package/__test_context_w7XZeH/src/modules/mixed/mixed.ts +5 -0
  29. package/__test_context_y5noh6/src/modules/empty/empty.ts +0 -0
  30. package/__test_framework__24OjAu/package.json +1 -0
  31. package/__test_framework__3ZDZsx/pyproject.toml +8 -0
  32. package/__test_framework__4T54Jn/package.json +1 -0
  33. package/__test_framework__4tlXu9/pyproject.toml +8 -0
  34. package/__test_framework__6boWqQ/Pipfile +6 -0
  35. package/__test_framework__6gygMU/pom.xml +10 -0
  36. package/__test_framework__6kxj0N/go.mod +8 -0
  37. package/__test_framework__7CEoXw/pom.xml +10 -0
  38. package/__test_framework__85DDz0/Pipfile +6 -0
  39. package/__test_framework__9WrRIr/pom.xml +7 -0
  40. package/__test_framework__ANqGKl/Gemfile +5 -0
  41. package/__test_framework__BCXTEM/go.mod +3 -0
  42. package/__test_framework__BHiPNq/setup.py +2 -0
  43. package/__test_framework__BqkiKv/package.json +1 -0
  44. package/__test_framework__C5yd8X/Pipfile.lock +1 -0
  45. package/__test_framework__C5yd8X/requirements.txt +1 -0
  46. package/__test_framework__C87d3a/manage.py +1 -0
  47. package/__test_framework__C87d3a/requirements.txt +2 -0
  48. package/__test_framework__DXNwc5/build.gradle +7 -0
  49. package/__test_framework__GhHSt3/build.gradle.kts +4 -0
  50. package/__test_framework__GzklJP/Cargo.toml +7 -0
  51. package/__test_framework__H4hd13/go.mod +8 -0
  52. package/__test_framework__HKjOXO/composer.json +1 -0
  53. package/__test_framework__HaDN45/Gemfile +3 -0
  54. package/__test_framework__IBO7YG/pyproject.toml +9 -0
  55. package/__test_framework__JwSOyF/pyproject.toml +6 -0
  56. package/__test_framework__K6HrCr/build.gradle +2 -0
  57. package/__test_framework__KzRPlh/pubspec.yaml +9 -0
  58. package/__test_framework__L6uIym/pyproject.toml +6 -0
  59. package/__test_framework__LOdoGK/requirements.txt +4 -0
  60. package/__test_framework__LgHzss/package.json +1 -0
  61. package/__test_framework__M76M6q/Gemfile +5 -0
  62. package/__test_framework__Mr9vWW/composer.json +1 -0
  63. package/__test_framework__N03Gnv/package.json +1 -0
  64. package/__test_framework__Num4UE/requirements +1 -0
  65. package/__test_framework__OAGw3Y/build.gradle +7 -0
  66. package/__test_framework__OQc8yG/pubspec.yaml +9 -0
  67. package/__test_framework__OwKZcd/requirements.txt +3 -0
  68. package/__test_framework__P0gFv7/requirements +1 -0
  69. package/__test_framework__PN55Rq/package.json +1 -0
  70. package/__test_framework__PQiqX8/pubspec.yaml +3 -0
  71. package/__test_framework__RBHsg7/composer.json +1 -0
  72. package/__test_framework__RHxif4/Cargo.toml +7 -0
  73. package/__test_framework__T0v0p1/Cargo.toml +4 -0
  74. package/__test_framework__Tu0clt/Pipfile.lock +1 -0
  75. package/__test_framework__Tu0clt/requirements.txt +1 -0
  76. package/__test_framework__TwDj9P/Cargo.toml +4 -0
  77. package/__test_framework__VQJNC4/pom.xml +7 -0
  78. package/__test_framework__W6sm05/package.json +1 -0
  79. package/__test_framework__W7vBLy/pyproject.toml +4 -0
  80. package/__test_framework__WNJOWT/setup.py +2 -0
  81. package/__test_framework__WSJs7U/package.json +1 -0
  82. package/__test_framework__YQ5VpA/build.gradle.kts +4 -0
  83. package/__test_framework__ZNEUEs/package.json +1 -0
  84. package/__test_framework__Znt922/pom.xml +7 -0
  85. package/__test_framework__azyg0h/pom.xml +7 -0
  86. package/__test_framework__c6otLr/package.json +1 -0
  87. package/__test_framework__cl9S9G/build.gradle +2 -0
  88. package/__test_framework__eilvV4/composer.json +1 -0
  89. package/__test_framework__gQZxXO/manage.py +1 -0
  90. package/__test_framework__gQZxXO/requirements.txt +2 -0
  91. package/__test_framework__ghvl26/poetry.lock +1 -0
  92. package/__test_framework__ghvl26/pyproject.toml +2 -0
  93. package/__test_framework__hR7b9U/Makefile +11 -0
  94. package/__test_framework__iESVsi/composer.json +1 -0
  95. package/__test_framework__jm6TJy/package.json +1 -0
  96. package/__test_framework__kBUpjs/pyproject.toml +9 -0
  97. package/__test_framework__kqoZrw/requirements.txt +4 -0
  98. package/__test_framework__lWkoyO/pyproject.toml +4 -0
  99. package/__test_framework__mTKnUO/package.json +1 -0
  100. package/__test_framework__nCeZwe/Makefile +11 -0
  101. package/__test_framework__oljsU0/package.json +1 -0
  102. package/__test_framework__osRG4q/go.mod +3 -0
  103. package/__test_framework__pCHH4F/package.json +1 -0
  104. package/__test_framework__pExx6E/Gemfile +3 -0
  105. package/__test_framework__pyBoGd/pyproject.toml +5 -0
  106. package/__test_framework__qw16VQ/package.json +1 -0
  107. package/__test_framework__rRayrG/package.json +1 -0
  108. package/__test_framework__s82zO5/package.json +1 -0
  109. package/__test_framework__tp8MFK/pyproject.toml +5 -0
  110. package/__test_framework__w44k4w/composer.json +1 -0
  111. package/__test_framework__yefPZY/poetry.lock +1 -0
  112. package/__test_framework__yefPZY/pyproject.toml +2 -0
  113. package/__test_framework__zCiyDT/requirements.txt +3 -0
  114. package/__test_framework__zGZN3j/pubspec.yaml +3 -0
  115. package/__test_framework__zXpnxL/package.json +1 -0
  116. package/architect-run.sh +431 -0
  117. package/assets/banner-v3.html +561 -0
  118. package/dist/agent-generator/context-enricher.d.ts +58 -0
  119. package/dist/agent-generator/context-enricher.d.ts.map +1 -0
  120. package/dist/agent-generator/context-enricher.js +581 -0
  121. package/dist/agent-generator/context-enricher.js.map +1 -0
  122. package/dist/agent-generator/domain-inferrer.d.ts +52 -0
  123. package/dist/agent-generator/domain-inferrer.d.ts.map +1 -0
  124. package/dist/agent-generator/domain-inferrer.js +575 -0
  125. package/dist/agent-generator/domain-inferrer.js.map +1 -0
  126. package/dist/agent-generator/framework-detector.d.ts +40 -0
  127. package/dist/agent-generator/framework-detector.d.ts.map +1 -0
  128. package/dist/agent-generator/framework-detector.js +611 -0
  129. package/dist/agent-generator/framework-detector.js.map +1 -0
  130. package/dist/agent-generator/index.d.ts +33 -0
  131. package/dist/agent-generator/index.d.ts.map +1 -0
  132. package/dist/agent-generator/index.js +477 -0
  133. package/dist/agent-generator/index.js.map +1 -0
  134. package/dist/agent-generator/stack-detector.d.ts +12 -0
  135. package/dist/agent-generator/stack-detector.d.ts.map +1 -0
  136. package/dist/agent-generator/stack-detector.js +128 -0
  137. package/dist/agent-generator/stack-detector.js.map +1 -0
  138. package/dist/agent-generator/templates/core/agents.d.ts +17 -0
  139. package/dist/agent-generator/templates/core/agents.d.ts.map +1 -0
  140. package/dist/agent-generator/templates/core/agents.js +1252 -0
  141. package/dist/agent-generator/templates/core/agents.js.map +1 -0
  142. package/dist/agent-generator/templates/core/architecture-rules.d.ts +7 -0
  143. package/dist/agent-generator/templates/core/architecture-rules.d.ts.map +1 -0
  144. package/dist/agent-generator/templates/core/architecture-rules.js +274 -0
  145. package/dist/agent-generator/templates/core/architecture-rules.js.map +1 -0
  146. package/dist/agent-generator/templates/core/general-rules.d.ts +8 -0
  147. package/dist/agent-generator/templates/core/general-rules.d.ts.map +1 -0
  148. package/dist/agent-generator/templates/core/general-rules.js +301 -0
  149. package/dist/agent-generator/templates/core/general-rules.js.map +1 -0
  150. package/dist/agent-generator/templates/core/index-md.d.ts +7 -0
  151. package/dist/agent-generator/templates/core/index-md.d.ts.map +1 -0
  152. package/dist/agent-generator/templates/core/index-md.js +246 -0
  153. package/dist/agent-generator/templates/core/index-md.js.map +1 -0
  154. package/dist/agent-generator/templates/core/orchestrator.d.ts +8 -0
  155. package/dist/agent-generator/templates/core/orchestrator.d.ts.map +1 -0
  156. package/dist/agent-generator/templates/core/orchestrator.js +422 -0
  157. package/dist/agent-generator/templates/core/orchestrator.js.map +1 -0
  158. package/dist/agent-generator/templates/core/preflight.d.ts +8 -0
  159. package/dist/agent-generator/templates/core/preflight.d.ts.map +1 -0
  160. package/dist/agent-generator/templates/core/preflight.js +213 -0
  161. package/dist/agent-generator/templates/core/preflight.js.map +1 -0
  162. package/dist/agent-generator/templates/core/quality-gates.d.ts +11 -0
  163. package/dist/agent-generator/templates/core/quality-gates.d.ts.map +1 -0
  164. package/dist/agent-generator/templates/core/quality-gates.js +254 -0
  165. package/dist/agent-generator/templates/core/quality-gates.js.map +1 -0
  166. package/dist/agent-generator/templates/core/security-rules.d.ts +7 -0
  167. package/dist/agent-generator/templates/core/security-rules.d.ts.map +1 -0
  168. package/dist/agent-generator/templates/core/security-rules.js +528 -0
  169. package/dist/agent-generator/templates/core/security-rules.js.map +1 -0
  170. package/dist/agent-generator/templates/core/skills-generator.d.ts +6 -0
  171. package/dist/agent-generator/templates/core/skills-generator.d.ts.map +1 -0
  172. package/dist/agent-generator/templates/core/skills-generator.js +207 -0
  173. package/dist/agent-generator/templates/core/skills-generator.js.map +1 -0
  174. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts +7 -0
  175. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts.map +1 -0
  176. package/dist/agent-generator/templates/core/workflow-fix-bug.js +237 -0
  177. package/dist/agent-generator/templates/core/workflow-fix-bug.js.map +1 -0
  178. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts +8 -0
  179. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts.map +1 -0
  180. package/dist/agent-generator/templates/core/workflow-new-feature.js +321 -0
  181. package/dist/agent-generator/templates/core/workflow-new-feature.js.map +1 -0
  182. package/dist/agent-generator/templates/core/workflow-review.d.ts +7 -0
  183. package/dist/agent-generator/templates/core/workflow-review.d.ts.map +1 -0
  184. package/dist/agent-generator/templates/core/workflow-review.js +104 -0
  185. package/dist/agent-generator/templates/core/workflow-review.js.map +1 -0
  186. package/dist/agent-generator/templates/domain/index.d.ts +22 -0
  187. package/dist/agent-generator/templates/domain/index.d.ts.map +1 -0
  188. package/dist/agent-generator/templates/domain/index.js +1176 -0
  189. package/dist/agent-generator/templates/domain/index.js.map +1 -0
  190. package/dist/agent-generator/templates/stack/index.d.ts +8 -0
  191. package/dist/agent-generator/templates/stack/index.d.ts.map +1 -0
  192. package/dist/agent-generator/templates/stack/index.js +695 -0
  193. package/dist/agent-generator/templates/stack/index.js.map +1 -0
  194. package/dist/agent-generator/templates/template-helpers.d.ts +75 -0
  195. package/dist/agent-generator/templates/template-helpers.d.ts.map +1 -0
  196. package/dist/agent-generator/templates/template-helpers.js +726 -0
  197. package/dist/agent-generator/templates/template-helpers.js.map +1 -0
  198. package/dist/agent-generator/types.d.ts +196 -0
  199. package/dist/agent-generator/types.d.ts.map +1 -0
  200. package/dist/agent-generator/types.js +27 -0
  201. package/dist/agent-generator/types.js.map +1 -0
  202. package/dist/analyzer.d.ts +5 -0
  203. package/dist/analyzer.d.ts.map +1 -1
  204. package/dist/analyzer.js +35 -4
  205. package/dist/analyzer.js.map +1 -1
  206. package/dist/analyzers/forecast.d.ts +85 -0
  207. package/dist/analyzers/forecast.d.ts.map +1 -0
  208. package/dist/analyzers/forecast.js +337 -0
  209. package/dist/analyzers/forecast.js.map +1 -0
  210. package/dist/analyzers/git-cache.d.ts +7 -0
  211. package/dist/analyzers/git-cache.d.ts.map +1 -0
  212. package/dist/analyzers/git-cache.js +41 -0
  213. package/dist/analyzers/git-cache.js.map +1 -0
  214. package/dist/analyzers/git-history.d.ts +113 -0
  215. package/dist/analyzers/git-history.d.ts.map +1 -0
  216. package/dist/analyzers/git-history.js +333 -0
  217. package/dist/analyzers/git-history.js.map +1 -0
  218. package/dist/analyzers/index.d.ts +10 -0
  219. package/dist/analyzers/index.d.ts.map +1 -0
  220. package/dist/analyzers/index.js +7 -0
  221. package/dist/analyzers/index.js.map +1 -0
  222. package/dist/analyzers/temporal-scorer.d.ts +72 -0
  223. package/dist/analyzers/temporal-scorer.d.ts.map +1 -0
  224. package/dist/analyzers/temporal-scorer.js +140 -0
  225. package/dist/analyzers/temporal-scorer.js.map +1 -0
  226. package/dist/cli.d.ts +2 -3
  227. package/dist/cli.d.ts.map +1 -1
  228. package/dist/cli.js +275 -113
  229. package/dist/cli.js.map +1 -1
  230. package/dist/html-reporter.d.ts +3 -1
  231. package/dist/html-reporter.d.ts.map +1 -1
  232. package/dist/html-reporter.js +248 -12
  233. package/dist/html-reporter.js.map +1 -1
  234. package/dist/index.d.ts +16 -3
  235. package/dist/index.d.ts.map +1 -1
  236. package/dist/index.js +63 -4
  237. package/dist/index.js.map +1 -1
  238. package/dist/project-summarizer.d.ts +18 -0
  239. package/dist/project-summarizer.d.ts.map +1 -0
  240. package/dist/project-summarizer.js +306 -0
  241. package/dist/project-summarizer.js.map +1 -0
  242. package/dist/refactor-reporter.js +1 -1
  243. package/dist/types.d.ts +13 -0
  244. package/dist/types.d.ts.map +1 -1
  245. package/package.json +12 -3
  246. package/src/agent-generator/context-enricher.ts +643 -0
  247. package/src/agent-generator/domain-inferrer.ts +625 -0
  248. package/src/agent-generator/framework-detector.ts +669 -0
  249. package/src/agent-generator/index.ts +555 -0
  250. package/src/agent-generator/stack-detector.ts +103 -0
  251. package/src/agent-generator/templates/core/agents.ts +1293 -0
  252. package/src/agent-generator/templates/core/architecture-rules.ts +287 -0
  253. package/src/agent-generator/templates/core/general-rules.ts +306 -0
  254. package/src/agent-generator/templates/core/index-md.ts +260 -0
  255. package/src/agent-generator/templates/core/orchestrator.ts +459 -0
  256. package/src/agent-generator/templates/core/preflight.ts +215 -0
  257. package/src/agent-generator/templates/core/quality-gates.ts +256 -0
  258. package/src/agent-generator/templates/core/security-rules.ts +543 -0
  259. package/src/agent-generator/templates/core/skills-generator.ts +236 -0
  260. package/src/agent-generator/templates/core/workflow-fix-bug.ts +239 -0
  261. package/src/agent-generator/templates/core/workflow-new-feature.ts +323 -0
  262. package/src/agent-generator/templates/core/workflow-review.ts +106 -0
  263. package/src/agent-generator/templates/domain/index.ts +1201 -0
  264. package/src/agent-generator/templates/stack/index.ts +705 -0
  265. package/src/agent-generator/templates/template-helpers.ts +776 -0
  266. package/src/agent-generator/types.ts +232 -0
  267. package/src/analyzer.ts +38 -4
  268. package/src/analyzers/forecast.ts +496 -0
  269. package/src/analyzers/git-cache.ts +52 -0
  270. package/src/analyzers/git-history.ts +488 -0
  271. package/src/analyzers/index.ts +33 -0
  272. package/src/analyzers/temporal-scorer.ts +227 -0
  273. package/src/cli.ts +316 -117
  274. package/src/html-reporter.ts +263 -13
  275. package/src/index.ts +92 -9
  276. package/src/project-summarizer.ts +347 -0
  277. package/src/refactor-reporter.ts +1 -1
  278. package/src/types.ts +10 -0
  279. package/tests/agent-generator.test.ts +411 -0
  280. package/tests/analyzers-integration.test.ts +174 -0
  281. package/tests/architect-adapter-enrichment.test.ts +9 -0
  282. package/tests/context-enricher.test.ts +971 -0
  283. package/tests/forecast.test.ts +509 -0
  284. package/tests/framework-detector.test.ts +1172 -0
  285. package/tests/git-history.test.ts +254 -0
  286. package/tests/scanner.test.ts +7 -8
  287. package/tests/scorer.test.ts +588 -0
  288. package/tests/stack-detector.test.ts +241 -0
  289. package/tests/template-generation.test.ts +706 -0
  290. package/tests/template-helpers.test.ts +1152 -0
  291. package/tests/temporal-scorer.test.ts +307 -0
  292. package/dist/agent-generator.d.ts +0 -106
  293. package/dist/agent-generator.d.ts.map +0 -1
  294. package/dist/agent-generator.js +0 -1398
  295. package/dist/agent-generator.js.map +0 -1
  296. package/src/agent-generator.ts +0 -1526
@@ -0,0 +1,669 @@
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { AnalysisReport } from '../types.js';
4
+ import { FrameworkInfo, DetectedToolchain } from './types.js';
5
+
6
+ /**
7
+ * FrameworkDetector — Detects actual frameworks and toolchain from dependency files.
8
+ *
9
+ * Reads requirements.txt, pyproject.toml, package.json, pom.xml, build.gradle,
10
+ * composer.json, go.mod, Gemfile, pubspec.yaml, Cargo.toml, Makefile, etc.
11
+ *
12
+ * Returns structured framework info with versions, categories, and
13
+ * auto-detected toolchain commands (build, test, lint, run).
14
+ */
15
+ export class FrameworkDetector {
16
+
17
+ // ═══════════════════════════════════════════════════════════════════════
18
+ // FRAMEWORK PATTERNS — Maps dependency names to framework metadata
19
+ // ═══════════════════════════════════════════════════════════════════════
20
+
21
+ private static readonly FRAMEWORK_MAP: Record<string, { name: string; category: FrameworkInfo['category'] }> = {
22
+ // Python Web
23
+ 'fastapi': { name: 'FastAPI', category: 'web' },
24
+ 'django': { name: 'Django', category: 'web' },
25
+ 'flask': { name: 'Flask', category: 'web' },
26
+ 'starlette': { name: 'Starlette', category: 'web' },
27
+ 'tornado': { name: 'Tornado', category: 'web' },
28
+ 'sanic': { name: 'Sanic', category: 'web' },
29
+ 'aiohttp': { name: 'aiohttp', category: 'web' },
30
+ 'litestar': { name: 'Litestar', category: 'web' },
31
+ // Python ORM
32
+ 'sqlalchemy': { name: 'SQLAlchemy', category: 'orm' },
33
+ 'tortoise-orm': { name: 'Tortoise ORM', category: 'orm' },
34
+ 'peewee': { name: 'Peewee', category: 'orm' },
35
+ 'sqlmodel': { name: 'SQLModel', category: 'orm' },
36
+ 'prisma': { name: 'Prisma', category: 'orm' },
37
+ 'django-rest-framework': { name: 'DRF', category: 'web' },
38
+ 'djangorestframework': { name: 'DRF', category: 'web' },
39
+ // Python Test
40
+ 'pytest': { name: 'pytest', category: 'test' },
41
+ 'unittest': { name: 'unittest', category: 'test' },
42
+ 'hypothesis': { name: 'Hypothesis', category: 'test' },
43
+ // Python Lint
44
+ 'ruff': { name: 'Ruff', category: 'lint' },
45
+ 'flake8': { name: 'Flake8', category: 'lint' },
46
+ 'pylint': { name: 'Pylint', category: 'lint' },
47
+ 'black': { name: 'Black', category: 'lint' },
48
+ 'mypy': { name: 'mypy', category: 'lint' },
49
+ // Node.js Web
50
+ '@nestjs/core': { name: 'NestJS', category: 'web' },
51
+ 'express': { name: 'Express', category: 'web' },
52
+ 'fastify': { name: 'Fastify', category: 'web' },
53
+ 'koa': { name: 'Koa', category: 'web' },
54
+ 'hapi': { name: 'Hapi', category: 'web' },
55
+ '@hapi/hapi': { name: 'Hapi', category: 'web' },
56
+ 'next': { name: 'Next.js', category: 'web' },
57
+ 'nuxt': { name: 'Nuxt', category: 'web' },
58
+ // Node.js ORM
59
+ 'typeorm': { name: 'TypeORM', category: 'orm' },
60
+ '@prisma/client': { name: 'Prisma', category: 'orm' },
61
+ 'sequelize': { name: 'Sequelize', category: 'orm' },
62
+ 'mongoose': { name: 'Mongoose', category: 'orm' },
63
+ 'knex': { name: 'Knex', category: 'orm' },
64
+ 'drizzle-orm': { name: 'Drizzle', category: 'orm' },
65
+ // Node.js Test
66
+ 'jest': { name: 'Jest', category: 'test' },
67
+ 'vitest': { name: 'Vitest', category: 'test' },
68
+ 'mocha': { name: 'Mocha', category: 'test' },
69
+ // Node.js Lint
70
+ 'eslint': { name: 'ESLint', category: 'lint' },
71
+ 'biome': { name: 'Biome', category: 'lint' },
72
+ '@biomejs/biome': { name: 'Biome', category: 'lint' },
73
+ 'prettier': { name: 'Prettier', category: 'lint' },
74
+ // Java/Kotlin
75
+ 'spring-boot-starter-web': { name: 'Spring Boot', category: 'web' },
76
+ 'spring-boot-starter': { name: 'Spring Boot', category: 'web' },
77
+ 'quarkus': { name: 'Quarkus', category: 'web' },
78
+ 'micronaut': { name: 'Micronaut', category: 'web' },
79
+ 'ktor': { name: 'Ktor', category: 'web' },
80
+ // PHP
81
+ 'laravel/framework': { name: 'Laravel', category: 'web' },
82
+ 'symfony/framework-bundle': { name: 'Symfony', category: 'web' },
83
+ 'slim/slim': { name: 'Slim', category: 'web' },
84
+ // Ruby
85
+ 'rails': { name: 'Ruby on Rails', category: 'web' },
86
+ // Go — detected from imports
87
+ 'gin-gonic/gin': { name: 'Gin', category: 'web' },
88
+ 'labstack/echo': { name: 'Echo', category: 'web' },
89
+ 'gofiber/fiber': { name: 'Fiber', category: 'web' },
90
+ 'gorilla/mux': { name: 'Gorilla Mux', category: 'web' },
91
+ 'go-chi/chi': { name: 'Chi', category: 'web' },
92
+ // Dart/Flutter
93
+ 'flutter': { name: 'Flutter', category: 'web' },
94
+ 'shelf': { name: 'Shelf', category: 'web' },
95
+ 'dart_frog': { name: 'Dart Frog', category: 'web' },
96
+ // Rust
97
+ 'actix-web': { name: 'Actix Web', category: 'web' },
98
+ 'rocket': { name: 'Rocket', category: 'web' },
99
+ 'axum': { name: 'Axum', category: 'web' },
100
+ };
101
+
102
+ // ═══════════════════════════════════════════════════════════════════════
103
+ // DETECTION — Main entry point
104
+ // ═══════════════════════════════════════════════════════════════════════
105
+
106
+ /**
107
+ * Detect frameworks and toolchain from project path and report.
108
+ */
109
+ detect(projectPath: string, report: AnalysisReport): {
110
+ frameworks: FrameworkInfo[];
111
+ primaryFramework: FrameworkInfo | null;
112
+ toolchain: DetectedToolchain;
113
+ projectStructure: 'clean-architecture' | 'mvc' | 'modular' | 'flat' | 'monorepo' | 'unknown';
114
+ } {
115
+ const frameworks: FrameworkInfo[] = [];
116
+
117
+ // Try each dependency source
118
+ this.detectFromPython(projectPath, frameworks);
119
+ this.detectFromNodejs(projectPath, frameworks);
120
+ this.detectFromJava(projectPath, frameworks);
121
+ this.detectFromPhp(projectPath, frameworks);
122
+ this.detectFromGo(projectPath, frameworks);
123
+ this.detectFromRuby(projectPath, frameworks);
124
+ this.detectFromDart(projectPath, frameworks);
125
+ this.detectFromRust(projectPath, frameworks);
126
+
127
+ // Deduplicate by name
128
+ const seen = new Set<string>();
129
+ const unique = frameworks.filter(f => {
130
+ if (seen.has(f.name)) return false;
131
+ seen.add(f.name);
132
+ return true;
133
+ });
134
+
135
+ // Sort: web frameworks first, then by confidence
136
+ unique.sort((a, b) => {
137
+ if (a.category === 'web' && b.category !== 'web') return -1;
138
+ if (a.category !== 'web' && b.category === 'web') return 1;
139
+ return b.confidence - a.confidence;
140
+ });
141
+
142
+ const primaryFramework = unique.find(f => f.category === 'web') || null;
143
+ const toolchain = this.detectToolchain(projectPath, report, primaryFramework, unique);
144
+ const projectStructure = this.detectProjectStructure(report);
145
+
146
+ return { frameworks: unique, primaryFramework, toolchain, projectStructure };
147
+ }
148
+
149
+ // ═══════════════════════════════════════════════════════════════════════
150
+ // PYTHON
151
+ // ═══════════════════════════════════════════════════════════════════════
152
+
153
+ private detectFromPython(projectPath: string, out: FrameworkInfo[]): void {
154
+ // requirements.txt
155
+ const reqFiles = ['requirements.txt', 'requirements/base.txt', 'requirements/prod.txt'];
156
+ for (const reqFile of reqFiles) {
157
+ const path = join(projectPath, reqFile);
158
+ if (existsSync(path)) {
159
+ const content = this.safeReadFile(path);
160
+ this.parsePythonRequirements(content, out);
161
+ }
162
+ }
163
+
164
+ // pyproject.toml
165
+ const pyproject = join(projectPath, 'pyproject.toml');
166
+ if (existsSync(pyproject)) {
167
+ const content = this.safeReadFile(pyproject);
168
+ this.parsePyprojectToml(content, out);
169
+ }
170
+
171
+ // setup.py / setup.cfg
172
+ const setupPy = join(projectPath, 'setup.py');
173
+ if (existsSync(setupPy)) {
174
+ const content = this.safeReadFile(setupPy);
175
+ this.parsePythonRequirements(content, out);
176
+ }
177
+
178
+ // Pipfile
179
+ const pipfile = join(projectPath, 'Pipfile');
180
+ if (existsSync(pipfile)) {
181
+ const content = this.safeReadFile(pipfile);
182
+ this.parsePythonRequirements(content, out);
183
+ }
184
+ }
185
+
186
+ private parsePythonRequirements(content: string, out: FrameworkInfo[]): void {
187
+ const lines = content.toLowerCase().split('\n');
188
+ for (const line of lines) {
189
+ const cleaned = line.replace(/#.*$/, '').trim();
190
+ if (!cleaned) continue;
191
+
192
+ // Match: package==1.0.0, package>=1.0, package~=1.0, package[extras]
193
+ const match = cleaned.match(/^([a-z0-9_-]+)(?:\[.*?\])?\s*(?:[=<>~!]+\s*([0-9][0-9.]*\S*))?/);
194
+ if (match) {
195
+ const pkg = match[1].replace(/-/g, '-');
196
+ const version = match[2] || null;
197
+ const fwInfo = FrameworkDetector.FRAMEWORK_MAP[pkg];
198
+ if (fwInfo) {
199
+ out.push({ name: fwInfo.name, version, category: fwInfo.category, confidence: 0.95 });
200
+ }
201
+ }
202
+ }
203
+ }
204
+
205
+ private parsePyprojectToml(content: string, out: FrameworkInfo[]): void {
206
+ // Strategy 1: [project.dependencies] section (legacy format)
207
+ const depSection = content.match(/\[(?:project\.)?dependencies\]([\s\S]*?)(?:\n\[|$)/);
208
+ if (depSection) {
209
+ this.parsePythonRequirements(depSection[1], out);
210
+ }
211
+
212
+ // Strategy 2: [project] section with inline `dependencies = [...]` (PEP 621 format)
213
+ // This is the standard pyproject.toml format used by most modern Python projects
214
+ const projectSection = content.match(/\[project\]\s*\n([\s\S]*?)(?:\n\[(?!project\.)|$)/);
215
+ if (projectSection) {
216
+ // Extract the dependencies array: dependencies = [ "pkg>=1.0", ... ]
217
+ const depsArrayMatch = projectSection[1].match(/dependencies\s*=\s*\[([\s\S]*?)\]/);
218
+ if (depsArrayMatch) {
219
+ // Extract quoted strings from the array
220
+ const deps = depsArrayMatch[1].match(/"([^"]+)"/g);
221
+ if (deps) {
222
+ const depsAsLines = deps.map(d => d.replace(/"/g, '')).join('\n');
223
+ this.parsePythonRequirements(depsAsLines, out);
224
+ }
225
+ }
226
+ }
227
+
228
+ // Strategy 3: [project.optional-dependencies] sections (dev, test, etc.)
229
+ const optionalDeps = content.match(/\[project\.optional-dependencies\]\s*\n([\s\S]*?)(?:\n\[(?!project\.)|$)/);
230
+ if (optionalDeps) {
231
+ // Parse each group: dev = ["pkg>=1.0", ...], test = [...]
232
+ const groupMatches = optionalDeps[1].matchAll(/\w+\s*=\s*\[([\s\S]*?)\]/g);
233
+ for (const groupMatch of groupMatches) {
234
+ const deps = groupMatch[1].match(/"([^"]+)"/g);
235
+ if (deps) {
236
+ const depsAsLines = deps.map(d => d.replace(/"/g, '')).join('\n');
237
+ this.parsePythonRequirements(depsAsLines, out);
238
+ }
239
+ }
240
+ }
241
+
242
+ // Strategy 4: tool.poetry.dependencies
243
+ const poetrySection = content.match(/\[tool\.poetry\.dependencies\]([\s\S]*?)(?:\n\[|$)/);
244
+ if (poetrySection) {
245
+ const lines = poetrySection[1].split('\n');
246
+ for (const line of lines) {
247
+ const match = line.match(/^([a-z0-9_-]+)\s*=\s*"?([^"]*)"?/i);
248
+ if (match) {
249
+ const pkg = match[1].toLowerCase();
250
+ const fwInfo = FrameworkDetector.FRAMEWORK_MAP[pkg];
251
+ if (fwInfo) {
252
+ const versionMatch = match[2].match(/([0-9][0-9.]*)/);
253
+ out.push({ name: fwInfo.name, version: versionMatch?.[1] || null, category: fwInfo.category, confidence: 0.95 });
254
+ }
255
+ }
256
+ }
257
+ }
258
+
259
+ // Deduplicate by framework name (keep highest confidence)
260
+ const seen = new Map<string, number>();
261
+ for (let i = out.length - 1; i >= 0; i--) {
262
+ const key = out[i].name;
263
+ if (seen.has(key)) {
264
+ out.splice(i, 1);
265
+ } else {
266
+ seen.set(key, i);
267
+ }
268
+ }
269
+ }
270
+
271
+ // ═══════════════════════════════════════════════════════════════════════
272
+ // NODE.JS / TypeScript
273
+ // ═══════════════════════════════════════════════════════════════════════
274
+
275
+ private detectFromNodejs(projectPath: string, out: FrameworkInfo[]): void {
276
+ const pkgPath = join(projectPath, 'package.json');
277
+ if (!existsSync(pkgPath)) return;
278
+
279
+ const content = this.safeReadFile(pkgPath);
280
+ try {
281
+ const pkg = JSON.parse(content);
282
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
283
+ for (const [name, version] of Object.entries(allDeps)) {
284
+ const fwInfo = FrameworkDetector.FRAMEWORK_MAP[name];
285
+ if (fwInfo) {
286
+ const vStr = typeof version === 'string' ? version : '';
287
+ const vMatch = vStr.match(/([0-9][0-9.]*)/);
288
+ out.push({ name: fwInfo.name, version: vMatch?.[1] || null, category: fwInfo.category, confidence: 0.95 });
289
+ }
290
+ }
291
+ } catch {
292
+ // Invalid JSON
293
+ }
294
+ }
295
+
296
+ // ═══════════════════════════════════════════════════════════════════════
297
+ // JAVA / Kotlin
298
+ // ═══════════════════════════════════════════════════════════════════════
299
+
300
+ private detectFromJava(projectPath: string, out: FrameworkInfo[]): void {
301
+ // pom.xml
302
+ const pomPath = join(projectPath, 'pom.xml');
303
+ if (existsSync(pomPath)) {
304
+ const content = this.safeReadFile(pomPath);
305
+ const deps = content.match(/<artifactId>([^<]+)<\/artifactId>/gi) || [];
306
+ for (const dep of deps) {
307
+ const match = dep.match(/<artifactId>([^<]+)<\/artifactId>/i);
308
+ if (match) {
309
+ const artifact = match[1].toLowerCase();
310
+ const fwInfo = FrameworkDetector.FRAMEWORK_MAP[artifact];
311
+ if (fwInfo) {
312
+ out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.85 });
313
+ }
314
+ }
315
+ }
316
+ }
317
+
318
+ // build.gradle / build.gradle.kts
319
+ for (const gradleFile of ['build.gradle', 'build.gradle.kts']) {
320
+ const gradlePath = join(projectPath, gradleFile);
321
+ if (existsSync(gradlePath)) {
322
+ const content = this.safeReadFile(gradlePath);
323
+ if (content.includes('spring-boot')) {
324
+ out.push({ name: 'Spring Boot', version: null, category: 'web', confidence: 0.9 });
325
+ }
326
+ if (content.includes('quarkus')) {
327
+ out.push({ name: 'Quarkus', version: null, category: 'web', confidence: 0.9 });
328
+ }
329
+ if (content.includes('micronaut')) {
330
+ out.push({ name: 'Micronaut', version: null, category: 'web', confidence: 0.9 });
331
+ }
332
+ if (content.includes('ktor')) {
333
+ out.push({ name: 'Ktor', version: null, category: 'web', confidence: 0.9 });
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ // ═══════════════════════════════════════════════════════════════════════
340
+ // PHP
341
+ // ═══════════════════════════════════════════════════════════════════════
342
+
343
+ private detectFromPhp(projectPath: string, out: FrameworkInfo[]): void {
344
+ const composerPath = join(projectPath, 'composer.json');
345
+ if (!existsSync(composerPath)) return;
346
+
347
+ const content = this.safeReadFile(composerPath);
348
+ try {
349
+ const pkg = JSON.parse(content);
350
+ const allDeps = { ...pkg.require, ...pkg['require-dev'] };
351
+ for (const [name, version] of Object.entries(allDeps)) {
352
+ const fwInfo = FrameworkDetector.FRAMEWORK_MAP[name];
353
+ if (fwInfo) {
354
+ const vStr = typeof version === 'string' ? version : '';
355
+ const vMatch = vStr.match(/([0-9][0-9.]*)/);
356
+ out.push({ name: fwInfo.name, version: vMatch?.[1] || null, category: fwInfo.category, confidence: 0.9 });
357
+ }
358
+ }
359
+ } catch {
360
+ // Invalid JSON
361
+ }
362
+ }
363
+
364
+ // ═══════════════════════════════════════════════════════════════════════
365
+ // Go
366
+ // ═══════════════════════════════════════════════════════════════════════
367
+
368
+ private detectFromGo(projectPath: string, out: FrameworkInfo[]): void {
369
+ const goModPath = join(projectPath, 'go.mod');
370
+ if (!existsSync(goModPath)) return;
371
+
372
+ const content = this.safeReadFile(goModPath);
373
+ const lines = content.split('\n');
374
+ for (const line of lines) {
375
+ const match = line.match(/^\s*(github\.com\/[^\s]+)/);
376
+ if (match) {
377
+ const modPath = match[1].toLowerCase();
378
+ for (const [key, fwInfo] of Object.entries(FrameworkDetector.FRAMEWORK_MAP)) {
379
+ if (modPath.includes(key.toLowerCase())) {
380
+ out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.9 });
381
+ }
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ // ═══════════════════════════════════════════════════════════════════════
388
+ // Ruby
389
+ // ═══════════════════════════════════════════════════════════════════════
390
+
391
+ private detectFromRuby(projectPath: string, out: FrameworkInfo[]): void {
392
+ const gemfilePath = join(projectPath, 'Gemfile');
393
+ if (!existsSync(gemfilePath)) return;
394
+
395
+ const content = this.safeReadFile(gemfilePath);
396
+ if (content.includes("'rails'") || content.includes('"rails"')) {
397
+ const vMatch = content.match(/['"]rails['"],\s*['"]~?>\s*([0-9.]+)['"]/);
398
+ out.push({ name: 'Ruby on Rails', version: vMatch?.[1] || null, category: 'web', confidence: 0.95 });
399
+ }
400
+ if (content.includes("'sinatra'") || content.includes('"sinatra"')) {
401
+ out.push({ name: 'Sinatra', category: 'web', version: null, confidence: 0.9 });
402
+ }
403
+ if (content.includes("'rspec'") || content.includes('"rspec"')) {
404
+ out.push({ name: 'RSpec', category: 'test', version: null, confidence: 0.9 });
405
+ }
406
+ }
407
+
408
+ // ═══════════════════════════════════════════════════════════════════════
409
+ // Dart / Flutter
410
+ // ═══════════════════════════════════════════════════════════════════════
411
+
412
+ private detectFromDart(projectPath: string, out: FrameworkInfo[]): void {
413
+ const pubspecPath = join(projectPath, 'pubspec.yaml');
414
+ if (!existsSync(pubspecPath)) return;
415
+
416
+ const content = this.safeReadFile(pubspecPath);
417
+ if (content.includes('flutter:')) {
418
+ out.push({ name: 'Flutter', version: null, category: 'web', confidence: 0.95 });
419
+ }
420
+ }
421
+
422
+ // ═══════════════════════════════════════════════════════════════════════
423
+ // Rust
424
+ // ═══════════════════════════════════════════════════════════════════════
425
+
426
+ private detectFromRust(projectPath: string, out: FrameworkInfo[]): void {
427
+ const cargoPath = join(projectPath, 'Cargo.toml');
428
+ if (!existsSync(cargoPath)) return;
429
+
430
+ const content = this.safeReadFile(cargoPath);
431
+ for (const [key, fwInfo] of Object.entries(FrameworkDetector.FRAMEWORK_MAP)) {
432
+ if (content.includes(`"${key}"`) || content.includes(`'${key}'`) || content.includes(`${key} =`)) {
433
+ out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.85 });
434
+ }
435
+ }
436
+ }
437
+
438
+ // ═══════════════════════════════════════════════════════════════════════
439
+ // TOOLCHAIN DETECTION
440
+ // ═══════════════════════════════════════════════════════════════════════
441
+
442
+ /**
443
+ * Detect build/test/lint/run commands based on project files.
444
+ */
445
+ private detectToolchain(
446
+ projectPath: string,
447
+ report: AnalysisReport,
448
+ primaryFw: FrameworkInfo | null,
449
+ allFrameworks: FrameworkInfo[],
450
+ ): DetectedToolchain {
451
+ const lang = report.projectInfo.primaryLanguages[0] || 'Unknown';
452
+ const hasMakefile = existsSync(join(projectPath, 'Makefile'));
453
+ const hasDockerCompose = existsSync(join(projectPath, 'docker-compose.yml')) || existsSync(join(projectPath, 'docker-compose.yaml'));
454
+
455
+ const hasTest = (name: string) => allFrameworks.some(f => f.name === name);
456
+ const hasLint = (name: string) => allFrameworks.some(f => f.name === name && f.category === 'lint');
457
+
458
+ // Python
459
+ if (lang === 'Python') {
460
+ const fwName = primaryFw?.name || 'Python';
461
+ const hasPytest = hasTest('pytest');
462
+ const hasRuff = hasLint('Ruff');
463
+ const hasPoetry = existsSync(join(projectPath, 'poetry.lock'));
464
+ const hasPipenv = existsSync(join(projectPath, 'Pipfile.lock'));
465
+
466
+ let runCmd = 'python -m main';
467
+ if (fwName === 'FastAPI') runCmd = 'uvicorn app.main:app --reload';
468
+ else if (fwName === 'Django') runCmd = 'python manage.py runserver';
469
+ else if (fwName === 'Flask') runCmd = 'flask run --debug';
470
+
471
+ let installCmd = 'pip install -r requirements.txt';
472
+ if (hasPoetry) installCmd = 'poetry install';
473
+ else if (hasPipenv) installCmd = 'pipenv install';
474
+
475
+ return {
476
+ buildCmd: hasMakefile ? 'make build' : (fwName === 'Django' ? 'python manage.py check' : 'python -m py_compile main.py'),
477
+ testCmd: hasPytest ? 'pytest' : 'python -m unittest discover',
478
+ lintCmd: hasRuff ? 'ruff check .' : (hasLint('Flake8') ? 'flake8 .' : (hasLint('Pylint') ? 'pylint src/' : 'ruff check .')),
479
+ runCmd,
480
+ coverageCmd: hasPytest ? 'pytest --cov' : 'coverage run -m pytest',
481
+ installCmd,
482
+ migrateCmd: fwName === 'Django' ? 'python manage.py migrate' : (fwName === 'FastAPI' ? 'alembic upgrade head' : null),
483
+ depsFile: hasPoetry ? 'pyproject.toml' : (hasPipenv ? 'Pipfile' : 'requirements.txt'),
484
+ };
485
+ }
486
+
487
+ // TypeScript / JavaScript
488
+ if (lang === 'TypeScript' || lang === 'JavaScript') {
489
+ const hasYarn = existsSync(join(projectPath, 'yarn.lock'));
490
+ const hasPnpm = existsSync(join(projectPath, 'pnpm-lock.yaml'));
491
+ const pm = hasPnpm ? 'pnpm' : (hasYarn ? 'yarn' : 'npm');
492
+
493
+ return {
494
+ buildCmd: `${pm} run build`,
495
+ testCmd: hasTest('Vitest') ? `${pm} run test` : (hasTest('Jest') ? `${pm} test` : `${pm} test`),
496
+ lintCmd: hasLint('Biome') ? `${pm} run lint` : (hasLint('ESLint') ? `${pm} run lint` : 'npx eslint .'),
497
+ runCmd: `${pm} run dev`,
498
+ coverageCmd: `${pm} run test -- --coverage`,
499
+ installCmd: `${pm} install`,
500
+ migrateCmd: primaryFw?.name === 'NestJS' ? 'npx typeorm migration:run' : null,
501
+ depsFile: 'package.json',
502
+ };
503
+ }
504
+
505
+ // Java / Kotlin
506
+ if (lang === 'Java' || lang === 'Kotlin') {
507
+ const hasMaven = existsSync(join(projectPath, 'pom.xml'));
508
+ const hasGradle = existsSync(join(projectPath, 'build.gradle')) || existsSync(join(projectPath, 'build.gradle.kts'));
509
+
510
+ if (hasMaven) {
511
+ return {
512
+ buildCmd: 'mvn clean package',
513
+ testCmd: 'mvn test',
514
+ lintCmd: 'mvn checkstyle:check',
515
+ runCmd: 'mvn spring-boot:run',
516
+ coverageCmd: 'mvn jacoco:report',
517
+ installCmd: 'mvn install',
518
+ migrateCmd: 'mvn flyway:migrate',
519
+ depsFile: 'pom.xml',
520
+ };
521
+ }
522
+ if (hasGradle) {
523
+ return {
524
+ buildCmd: './gradlew build',
525
+ testCmd: './gradlew test',
526
+ lintCmd: './gradlew check',
527
+ runCmd: './gradlew bootRun',
528
+ coverageCmd: './gradlew jacocoTestReport',
529
+ installCmd: './gradlew dependencies',
530
+ migrateCmd: './gradlew flywayMigrate',
531
+ depsFile: existsSync(join(projectPath, 'build.gradle.kts')) ? 'build.gradle.kts' : 'build.gradle',
532
+ };
533
+ }
534
+ }
535
+
536
+ // PHP
537
+ if (lang === 'PHP') {
538
+ return {
539
+ buildCmd: 'composer install --no-dev',
540
+ testCmd: primaryFw?.name === 'Laravel' ? 'php artisan test' : 'vendor/bin/phpunit',
541
+ lintCmd: 'vendor/bin/phpstan analyse',
542
+ runCmd: primaryFw?.name === 'Laravel' ? 'php artisan serve' : 'php -S localhost:8000',
543
+ coverageCmd: 'vendor/bin/phpunit --coverage-text',
544
+ installCmd: 'composer install',
545
+ migrateCmd: primaryFw?.name === 'Laravel' ? 'php artisan migrate' : null,
546
+ depsFile: 'composer.json',
547
+ };
548
+ }
549
+
550
+ // Go
551
+ if (lang === 'Go') {
552
+ return {
553
+ buildCmd: 'go build ./...',
554
+ testCmd: 'go test ./...',
555
+ lintCmd: 'golangci-lint run',
556
+ runCmd: 'go run .',
557
+ coverageCmd: 'go test -coverprofile=coverage.out ./...',
558
+ installCmd: 'go mod download',
559
+ migrateCmd: null,
560
+ depsFile: 'go.mod',
561
+ };
562
+ }
563
+
564
+ // Ruby
565
+ if (lang === 'Ruby') {
566
+ return {
567
+ buildCmd: 'bundle exec rake build',
568
+ testCmd: hasTest('RSpec') ? 'bundle exec rspec' : 'bundle exec rake test',
569
+ lintCmd: 'bundle exec rubocop',
570
+ runCmd: primaryFw?.name === 'Ruby on Rails' ? 'rails server' : 'ruby app.rb',
571
+ coverageCmd: 'bundle exec rspec --format documentation',
572
+ installCmd: 'bundle install',
573
+ migrateCmd: primaryFw?.name === 'Ruby on Rails' ? 'rails db:migrate' : null,
574
+ depsFile: 'Gemfile',
575
+ };
576
+ }
577
+
578
+ // Dart
579
+ if (lang === 'Dart') {
580
+ return {
581
+ buildCmd: 'flutter build',
582
+ testCmd: 'flutter test',
583
+ lintCmd: 'dart analyze',
584
+ runCmd: 'flutter run',
585
+ coverageCmd: 'flutter test --coverage',
586
+ installCmd: 'flutter pub get',
587
+ migrateCmd: null,
588
+ depsFile: 'pubspec.yaml',
589
+ };
590
+ }
591
+
592
+ // Rust
593
+ if (lang === 'Rust') {
594
+ return {
595
+ buildCmd: 'cargo build',
596
+ testCmd: 'cargo test',
597
+ lintCmd: 'cargo clippy',
598
+ runCmd: 'cargo run',
599
+ coverageCmd: 'cargo tarpaulin',
600
+ installCmd: 'cargo build',
601
+ migrateCmd: null,
602
+ depsFile: 'Cargo.toml',
603
+ };
604
+ }
605
+
606
+ // Fallback
607
+ return {
608
+ buildCmd: hasMakefile ? 'make build' : 'echo "No build command detected"',
609
+ testCmd: hasMakefile ? 'make test' : 'echo "No test command detected"',
610
+ lintCmd: hasMakefile ? 'make lint' : 'echo "No lint command detected"',
611
+ runCmd: hasMakefile ? 'make run' : 'echo "No run command detected"',
612
+ coverageCmd: 'echo "No coverage command detected"',
613
+ installCmd: 'echo "No install command detected"',
614
+ migrateCmd: null,
615
+ depsFile: 'unknown',
616
+ };
617
+ }
618
+
619
+ // ═══════════════════════════════════════════════════════════════════════
620
+ // PROJECT STRUCTURE DETECTION
621
+ // ═══════════════════════════════════════════════════════════════════════
622
+
623
+ private detectProjectStructure(report: AnalysisReport): 'clean-architecture' | 'mvc' | 'modular' | 'flat' | 'monorepo' | 'unknown' {
624
+ const paths = report.dependencyGraph.nodes.map(n => n.toLowerCase());
625
+
626
+ // Clean Architecture / DDD
627
+ const hasDomain = paths.some(p => p.includes('/domain/'));
628
+ const hasApplication = paths.some(p => p.includes('/application/'));
629
+ const hasInfrastructure = paths.some(p => p.includes('/infrastructure/'));
630
+ const hasPresentation = paths.some(p => p.includes('/presentation/'));
631
+ if ((hasDomain && hasInfrastructure) || (hasDomain && hasApplication && hasPresentation)) {
632
+ return 'clean-architecture';
633
+ }
634
+
635
+ // MVC
636
+ const hasModels = paths.some(p => p.includes('/models/'));
637
+ const hasViews = paths.some(p => p.includes('/views/'));
638
+ const hasControllers = paths.some(p => p.includes('/controllers/'));
639
+ if (hasModels && hasViews && hasControllers) return 'mvc';
640
+
641
+ // Modular (NestJS, feature-based)
642
+ const hasModules = paths.some(p => p.includes('/modules/'));
643
+ const hasFeatures = paths.some(p => p.includes('/features/'));
644
+ if (hasModules || hasFeatures) return 'modular';
645
+
646
+ // Monorepo
647
+ const hasPackages = paths.some(p => p.includes('/packages/'));
648
+ const hasApps = paths.some(p => p.includes('/apps/'));
649
+ if (hasPackages || hasApps) return 'monorepo';
650
+
651
+ // Flat
652
+ const maxDepth = Math.max(...paths.map(p => p.split('/').length));
653
+ if (maxDepth <= 3) return 'flat';
654
+
655
+ return 'unknown';
656
+ }
657
+
658
+ // ═══════════════════════════════════════════════════════════════════════
659
+ // UTILS
660
+ // ═══════════════════════════════════════════════════════════════════════
661
+
662
+ private safeReadFile(path: string): string {
663
+ try {
664
+ return readFileSync(path, 'utf-8');
665
+ } catch {
666
+ return '';
667
+ }
668
+ }
669
+ }