@girardelli/architect 5.0.0 → 8.1.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 (335) hide show
  1. package/dist/{cli.d.ts → src/adapters/cli.d.ts} +1 -2
  2. package/dist/{cli.js → src/adapters/cli.js} +191 -213
  3. package/dist/src/adapters/cli.js.map +1 -0
  4. package/dist/src/adapters/github-action.d.ts +9 -0
  5. package/dist/src/adapters/github-action.js +94 -0
  6. package/dist/src/adapters/github-action.js.map +1 -0
  7. package/dist/src/adapters/html-reporter/scripts.d.ts +5 -0
  8. package/dist/src/adapters/html-reporter/scripts.js +400 -0
  9. package/dist/src/adapters/html-reporter/scripts.js.map +1 -0
  10. package/dist/src/adapters/html-reporter/sections/agents.d.ts +2 -0
  11. package/dist/src/adapters/html-reporter/sections/agents.js +260 -0
  12. package/dist/src/adapters/html-reporter/sections/agents.js.map +1 -0
  13. package/dist/src/adapters/html-reporter/sections/anti-patterns.d.ts +13 -0
  14. package/dist/src/adapters/html-reporter/sections/anti-patterns.js +64 -0
  15. package/dist/src/adapters/html-reporter/sections/anti-patterns.js.map +1 -0
  16. package/dist/src/adapters/html-reporter/sections/header.d.ts +3 -0
  17. package/dist/src/adapters/html-reporter/sections/header.js +30 -0
  18. package/dist/src/adapters/html-reporter/sections/header.js.map +1 -0
  19. package/dist/src/adapters/html-reporter/sections/layers.d.ts +9 -0
  20. package/dist/src/adapters/html-reporter/sections/layers.js +143 -0
  21. package/dist/src/adapters/html-reporter/sections/layers.js.map +1 -0
  22. package/dist/src/adapters/html-reporter/sections/overview.d.ts +2 -0
  23. package/dist/src/adapters/html-reporter/sections/overview.js +58 -0
  24. package/dist/src/adapters/html-reporter/sections/overview.js.map +1 -0
  25. package/dist/src/adapters/html-reporter/sections/refactoring-plan.d.ts +3 -0
  26. package/dist/src/adapters/html-reporter/sections/refactoring-plan.js +151 -0
  27. package/dist/src/adapters/html-reporter/sections/refactoring-plan.js.map +1 -0
  28. package/dist/src/adapters/html-reporter/sections/score.d.ts +7 -0
  29. package/dist/src/adapters/html-reporter/sections/score.js +70 -0
  30. package/dist/src/adapters/html-reporter/sections/score.js.map +1 -0
  31. package/dist/src/adapters/html-reporter/sections/suggestions.d.ts +7 -0
  32. package/dist/src/adapters/html-reporter/sections/suggestions.js +34 -0
  33. package/dist/src/adapters/html-reporter/sections/suggestions.js.map +1 -0
  34. package/dist/src/adapters/html-reporter/styles.d.ts +1 -0
  35. package/dist/src/adapters/html-reporter/styles.js +526 -0
  36. package/dist/src/adapters/html-reporter/styles.js.map +1 -0
  37. package/dist/src/adapters/html-reporter/utils_adapters.d.ts +20 -0
  38. package/dist/src/adapters/html-reporter/utils_adapters.js +32 -0
  39. package/dist/src/adapters/html-reporter/utils_adapters.js.map +1 -0
  40. package/dist/src/adapters/html-reporter/utils_sections.d.ts +7 -0
  41. package/dist/src/adapters/html-reporter/utils_sections.js +58 -0
  42. package/dist/src/adapters/html-reporter/utils_sections.js.map +1 -0
  43. package/dist/src/adapters/html-reporter.d.ts +10 -0
  44. package/dist/src/adapters/html-reporter.js +97 -0
  45. package/dist/src/adapters/html-reporter.js.map +1 -0
  46. package/dist/src/adapters/progress-logger.d.ts +55 -0
  47. package/dist/src/adapters/progress-logger.js +200 -0
  48. package/dist/src/adapters/progress-logger.js.map +1 -0
  49. package/dist/{refactor-reporter.d.ts → src/adapters/refactor-reporter.d.ts} +1 -2
  50. package/dist/{refactor-reporter.js → src/adapters/refactor-reporter.js} +1 -1
  51. package/dist/src/adapters/refactor-reporter.js.map +1 -0
  52. package/dist/{reporter.d.ts → src/adapters/reporter.d.ts} +1 -2
  53. package/dist/src/adapters/reporter.js.map +1 -0
  54. package/dist/src/core/GenesisTerminal.d.ts +8 -0
  55. package/dist/src/core/GenesisTerminal.js +105 -0
  56. package/dist/src/core/GenesisTerminal.js.map +1 -0
  57. package/dist/{index.d.ts → src/core/architect.d.ts} +4 -18
  58. package/dist/{index.js → src/core/architect.js} +22 -21
  59. package/dist/src/core/architect.js.map +1 -0
  60. package/dist/tests/architect-adapter-enrichment.test.d.ts +1 -0
  61. package/dist/tests/architect-adapter-enrichment.test.js +11 -0
  62. package/dist/tests/architect-adapter-enrichment.test.js.map +1 -0
  63. package/dist/tests/github-action.test.d.ts +1 -0
  64. package/dist/tests/github-action.test.js +92 -0
  65. package/dist/tests/github-action.test.js.map +1 -0
  66. package/package.json +15 -65
  67. package/src/adapters/cli.ts +492 -0
  68. package/src/adapters/github-action.ts +109 -0
  69. package/src/adapters/html-reporter/scripts.ts +402 -0
  70. package/src/adapters/html-reporter/sections/agents.ts +267 -0
  71. package/src/adapters/html-reporter/sections/anti-patterns.ts +81 -0
  72. package/src/adapters/html-reporter/sections/header.ts +35 -0
  73. package/src/adapters/html-reporter/sections/layers.ts +165 -0
  74. package/src/adapters/html-reporter/sections/overview.ts +64 -0
  75. package/src/adapters/html-reporter/sections/refactoring-plan.ts +166 -0
  76. package/src/adapters/html-reporter/sections/score.ts +80 -0
  77. package/src/adapters/html-reporter/sections/suggestions.ts +39 -0
  78. package/src/adapters/html-reporter/styles.ts +525 -0
  79. package/src/adapters/html-reporter/utils_adapters.ts +39 -0
  80. package/src/adapters/html-reporter/utils_sections.ts +55 -0
  81. package/src/adapters/html-reporter.ts +102 -0
  82. package/src/adapters/progress-logger.ts +236 -0
  83. package/src/{refactor-reporter.ts → adapters/refactor-reporter.ts} +2 -2
  84. package/src/{reporter.ts → adapters/reporter.ts} +1 -1
  85. package/src/core/GenesisTerminal.ts +127 -0
  86. package/src/{index.ts → core/architect.ts} +27 -45
  87. package/tests/github-action.test.ts +109 -0
  88. package/tsconfig.json +12 -19
  89. package/CONTRIBUTING.md +0 -140
  90. package/LICENSE +0 -21
  91. package/PROJECT_STRUCTURE.txt +0 -168
  92. package/README.md +0 -257
  93. package/architect-run.sh +0 -431
  94. package/assets/banner-v3.html +0 -561
  95. package/dist/agent-generator/context-enricher.d.ts +0 -58
  96. package/dist/agent-generator/context-enricher.d.ts.map +0 -1
  97. package/dist/agent-generator/context-enricher.js +0 -613
  98. package/dist/agent-generator/context-enricher.js.map +0 -1
  99. package/dist/agent-generator/domain-inferrer.d.ts +0 -52
  100. package/dist/agent-generator/domain-inferrer.d.ts.map +0 -1
  101. package/dist/agent-generator/domain-inferrer.js +0 -585
  102. package/dist/agent-generator/domain-inferrer.js.map +0 -1
  103. package/dist/agent-generator/framework-detector.d.ts +0 -40
  104. package/dist/agent-generator/framework-detector.d.ts.map +0 -1
  105. package/dist/agent-generator/framework-detector.js +0 -611
  106. package/dist/agent-generator/framework-detector.js.map +0 -1
  107. package/dist/agent-generator/index.d.ts +0 -47
  108. package/dist/agent-generator/index.d.ts.map +0 -1
  109. package/dist/agent-generator/index.js +0 -545
  110. package/dist/agent-generator/index.js.map +0 -1
  111. package/dist/agent-generator/stack-detector.d.ts +0 -14
  112. package/dist/agent-generator/stack-detector.d.ts.map +0 -1
  113. package/dist/agent-generator/stack-detector.js +0 -124
  114. package/dist/agent-generator/stack-detector.js.map +0 -1
  115. package/dist/agent-generator/templates/core/agents.d.ts +0 -17
  116. package/dist/agent-generator/templates/core/agents.d.ts.map +0 -1
  117. package/dist/agent-generator/templates/core/agents.js +0 -1256
  118. package/dist/agent-generator/templates/core/agents.js.map +0 -1
  119. package/dist/agent-generator/templates/core/architecture-rules.d.ts +0 -7
  120. package/dist/agent-generator/templates/core/architecture-rules.d.ts.map +0 -1
  121. package/dist/agent-generator/templates/core/architecture-rules.js +0 -274
  122. package/dist/agent-generator/templates/core/architecture-rules.js.map +0 -1
  123. package/dist/agent-generator/templates/core/general-rules.d.ts +0 -8
  124. package/dist/agent-generator/templates/core/general-rules.d.ts.map +0 -1
  125. package/dist/agent-generator/templates/core/general-rules.js +0 -301
  126. package/dist/agent-generator/templates/core/general-rules.js.map +0 -1
  127. package/dist/agent-generator/templates/core/hooks-generator.d.ts +0 -21
  128. package/dist/agent-generator/templates/core/hooks-generator.d.ts.map +0 -1
  129. package/dist/agent-generator/templates/core/hooks-generator.js +0 -233
  130. package/dist/agent-generator/templates/core/hooks-generator.js.map +0 -1
  131. package/dist/agent-generator/templates/core/index-md.d.ts +0 -7
  132. package/dist/agent-generator/templates/core/index-md.d.ts.map +0 -1
  133. package/dist/agent-generator/templates/core/index-md.js +0 -246
  134. package/dist/agent-generator/templates/core/index-md.js.map +0 -1
  135. package/dist/agent-generator/templates/core/orchestrator.d.ts +0 -8
  136. package/dist/agent-generator/templates/core/orchestrator.d.ts.map +0 -1
  137. package/dist/agent-generator/templates/core/orchestrator.js +0 -422
  138. package/dist/agent-generator/templates/core/orchestrator.js.map +0 -1
  139. package/dist/agent-generator/templates/core/preflight.d.ts +0 -8
  140. package/dist/agent-generator/templates/core/preflight.d.ts.map +0 -1
  141. package/dist/agent-generator/templates/core/preflight.js +0 -213
  142. package/dist/agent-generator/templates/core/preflight.js.map +0 -1
  143. package/dist/agent-generator/templates/core/quality-gates.d.ts +0 -11
  144. package/dist/agent-generator/templates/core/quality-gates.d.ts.map +0 -1
  145. package/dist/agent-generator/templates/core/quality-gates.js +0 -254
  146. package/dist/agent-generator/templates/core/quality-gates.js.map +0 -1
  147. package/dist/agent-generator/templates/core/security-rules.d.ts +0 -7
  148. package/dist/agent-generator/templates/core/security-rules.d.ts.map +0 -1
  149. package/dist/agent-generator/templates/core/security-rules.js +0 -528
  150. package/dist/agent-generator/templates/core/security-rules.js.map +0 -1
  151. package/dist/agent-generator/templates/core/skills-generator.d.ts +0 -19
  152. package/dist/agent-generator/templates/core/skills-generator.d.ts.map +0 -1
  153. package/dist/agent-generator/templates/core/skills-generator.js +0 -546
  154. package/dist/agent-generator/templates/core/skills-generator.js.map +0 -1
  155. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts +0 -7
  156. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts.map +0 -1
  157. package/dist/agent-generator/templates/core/workflow-fix-bug.js +0 -237
  158. package/dist/agent-generator/templates/core/workflow-fix-bug.js.map +0 -1
  159. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts +0 -8
  160. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts.map +0 -1
  161. package/dist/agent-generator/templates/core/workflow-new-feature.js +0 -321
  162. package/dist/agent-generator/templates/core/workflow-new-feature.js.map +0 -1
  163. package/dist/agent-generator/templates/core/workflow-review.d.ts +0 -7
  164. package/dist/agent-generator/templates/core/workflow-review.d.ts.map +0 -1
  165. package/dist/agent-generator/templates/core/workflow-review.js +0 -104
  166. package/dist/agent-generator/templates/core/workflow-review.js.map +0 -1
  167. package/dist/agent-generator/templates/domain/index.d.ts +0 -22
  168. package/dist/agent-generator/templates/domain/index.d.ts.map +0 -1
  169. package/dist/agent-generator/templates/domain/index.js +0 -1176
  170. package/dist/agent-generator/templates/domain/index.js.map +0 -1
  171. package/dist/agent-generator/templates/stack/index.d.ts +0 -8
  172. package/dist/agent-generator/templates/stack/index.d.ts.map +0 -1
  173. package/dist/agent-generator/templates/stack/index.js +0 -695
  174. package/dist/agent-generator/templates/stack/index.js.map +0 -1
  175. package/dist/agent-generator/templates/template-helpers.d.ts +0 -75
  176. package/dist/agent-generator/templates/template-helpers.d.ts.map +0 -1
  177. package/dist/agent-generator/templates/template-helpers.js +0 -726
  178. package/dist/agent-generator/templates/template-helpers.js.map +0 -1
  179. package/dist/agent-generator/types.d.ts +0 -196
  180. package/dist/agent-generator/types.d.ts.map +0 -1
  181. package/dist/agent-generator/types.js +0 -27
  182. package/dist/agent-generator/types.js.map +0 -1
  183. package/dist/analyzer.d.ts +0 -38
  184. package/dist/analyzer.d.ts.map +0 -1
  185. package/dist/analyzer.js +0 -383
  186. package/dist/analyzer.js.map +0 -1
  187. package/dist/analyzers/forecast.d.ts +0 -85
  188. package/dist/analyzers/forecast.d.ts.map +0 -1
  189. package/dist/analyzers/forecast.js +0 -337
  190. package/dist/analyzers/forecast.js.map +0 -1
  191. package/dist/analyzers/git-cache.d.ts +0 -7
  192. package/dist/analyzers/git-cache.d.ts.map +0 -1
  193. package/dist/analyzers/git-cache.js +0 -41
  194. package/dist/analyzers/git-cache.js.map +0 -1
  195. package/dist/analyzers/git-history.d.ts +0 -113
  196. package/dist/analyzers/git-history.d.ts.map +0 -1
  197. package/dist/analyzers/git-history.js +0 -333
  198. package/dist/analyzers/git-history.js.map +0 -1
  199. package/dist/analyzers/index.d.ts +0 -10
  200. package/dist/analyzers/index.d.ts.map +0 -1
  201. package/dist/analyzers/index.js +0 -7
  202. package/dist/analyzers/index.js.map +0 -1
  203. package/dist/analyzers/temporal-scorer.d.ts +0 -72
  204. package/dist/analyzers/temporal-scorer.d.ts.map +0 -1
  205. package/dist/analyzers/temporal-scorer.js +0 -140
  206. package/dist/analyzers/temporal-scorer.js.map +0 -1
  207. package/dist/anti-patterns.d.ts +0 -24
  208. package/dist/anti-patterns.d.ts.map +0 -1
  209. package/dist/anti-patterns.js +0 -230
  210. package/dist/anti-patterns.js.map +0 -1
  211. package/dist/cli.d.ts.map +0 -1
  212. package/dist/cli.js.map +0 -1
  213. package/dist/config.d.ts +0 -12
  214. package/dist/config.d.ts.map +0 -1
  215. package/dist/config.js +0 -110
  216. package/dist/config.js.map +0 -1
  217. package/dist/diagram.d.ts +0 -9
  218. package/dist/diagram.d.ts.map +0 -1
  219. package/dist/diagram.js +0 -116
  220. package/dist/diagram.js.map +0 -1
  221. package/dist/html-reporter.d.ts +0 -47
  222. package/dist/html-reporter.d.ts.map +0 -1
  223. package/dist/html-reporter.js +0 -1747
  224. package/dist/html-reporter.js.map +0 -1
  225. package/dist/index.d.ts.map +0 -1
  226. package/dist/index.js.map +0 -1
  227. package/dist/project-summarizer.d.ts +0 -38
  228. package/dist/project-summarizer.d.ts.map +0 -1
  229. package/dist/project-summarizer.js +0 -463
  230. package/dist/project-summarizer.js.map +0 -1
  231. package/dist/refactor-engine.d.ts +0 -18
  232. package/dist/refactor-engine.d.ts.map +0 -1
  233. package/dist/refactor-engine.js +0 -86
  234. package/dist/refactor-engine.js.map +0 -1
  235. package/dist/refactor-reporter.d.ts.map +0 -1
  236. package/dist/refactor-reporter.js.map +0 -1
  237. package/dist/reporter.d.ts.map +0 -1
  238. package/dist/reporter.js.map +0 -1
  239. package/dist/rules/barrel-optimizer.d.ts +0 -13
  240. package/dist/rules/barrel-optimizer.d.ts.map +0 -1
  241. package/dist/rules/barrel-optimizer.js +0 -77
  242. package/dist/rules/barrel-optimizer.js.map +0 -1
  243. package/dist/rules/dead-code-detector.d.ts +0 -21
  244. package/dist/rules/dead-code-detector.d.ts.map +0 -1
  245. package/dist/rules/dead-code-detector.js +0 -117
  246. package/dist/rules/dead-code-detector.js.map +0 -1
  247. package/dist/rules/hub-splitter.d.ts +0 -13
  248. package/dist/rules/hub-splitter.d.ts.map +0 -1
  249. package/dist/rules/hub-splitter.js +0 -110
  250. package/dist/rules/hub-splitter.js.map +0 -1
  251. package/dist/rules/import-organizer.d.ts +0 -13
  252. package/dist/rules/import-organizer.d.ts.map +0 -1
  253. package/dist/rules/import-organizer.js +0 -85
  254. package/dist/rules/import-organizer.js.map +0 -1
  255. package/dist/rules/module-grouper.d.ts +0 -13
  256. package/dist/rules/module-grouper.d.ts.map +0 -1
  257. package/dist/rules/module-grouper.js +0 -110
  258. package/dist/rules/module-grouper.js.map +0 -1
  259. package/dist/scanner.d.ts +0 -31
  260. package/dist/scanner.d.ts.map +0 -1
  261. package/dist/scanner.js +0 -328
  262. package/dist/scanner.js.map +0 -1
  263. package/dist/scorer.d.ts +0 -27
  264. package/dist/scorer.d.ts.map +0 -1
  265. package/dist/scorer.js +0 -229
  266. package/dist/scorer.js.map +0 -1
  267. package/dist/types.d.ts +0 -186
  268. package/dist/types.d.ts.map +0 -1
  269. package/dist/types.js +0 -2
  270. package/dist/types.js.map +0 -1
  271. package/examples/sample-report.md +0 -207
  272. package/jest.config.js +0 -18
  273. package/src/agent-generator/context-enricher.ts +0 -672
  274. package/src/agent-generator/domain-inferrer.ts +0 -635
  275. package/src/agent-generator/framework-detector.ts +0 -669
  276. package/src/agent-generator/index.ts +0 -634
  277. package/src/agent-generator/stack-detector.ts +0 -115
  278. package/src/agent-generator/templates/core/agents.ts +0 -1296
  279. package/src/agent-generator/templates/core/architecture-rules.ts +0 -287
  280. package/src/agent-generator/templates/core/general-rules.ts +0 -306
  281. package/src/agent-generator/templates/core/hooks-generator.ts +0 -242
  282. package/src/agent-generator/templates/core/index-md.ts +0 -260
  283. package/src/agent-generator/templates/core/orchestrator.ts +0 -459
  284. package/src/agent-generator/templates/core/preflight.ts +0 -215
  285. package/src/agent-generator/templates/core/quality-gates.ts +0 -256
  286. package/src/agent-generator/templates/core/security-rules.ts +0 -543
  287. package/src/agent-generator/templates/core/skills-generator.ts +0 -585
  288. package/src/agent-generator/templates/core/workflow-fix-bug.ts +0 -239
  289. package/src/agent-generator/templates/core/workflow-new-feature.ts +0 -323
  290. package/src/agent-generator/templates/core/workflow-review.ts +0 -106
  291. package/src/agent-generator/templates/domain/index.ts +0 -1201
  292. package/src/agent-generator/templates/stack/index.ts +0 -705
  293. package/src/agent-generator/templates/template-helpers.ts +0 -776
  294. package/src/agent-generator/types.ts +0 -232
  295. package/src/analyzer.ts +0 -447
  296. package/src/analyzers/forecast.ts +0 -496
  297. package/src/analyzers/git-cache.ts +0 -52
  298. package/src/analyzers/git-history.ts +0 -488
  299. package/src/analyzers/index.ts +0 -33
  300. package/src/analyzers/temporal-scorer.ts +0 -227
  301. package/src/anti-patterns.ts +0 -287
  302. package/src/cli.ts +0 -517
  303. package/src/config.ts +0 -123
  304. package/src/diagram.ts +0 -144
  305. package/src/html-reporter.ts +0 -1830
  306. package/src/project-summarizer.ts +0 -521
  307. package/src/refactor-engine.ts +0 -117
  308. package/src/rules/barrel-optimizer.ts +0 -97
  309. package/src/rules/dead-code-detector.ts +0 -132
  310. package/src/rules/hub-splitter.ts +0 -123
  311. package/src/rules/import-organizer.ts +0 -98
  312. package/src/rules/module-grouper.ts +0 -124
  313. package/src/scanner.ts +0 -344
  314. package/src/scorer.ts +0 -254
  315. package/src/types.ts +0 -193
  316. package/tests/agent-generator.test.ts +0 -427
  317. package/tests/analyzers-integration.test.ts +0 -174
  318. package/tests/anti-patterns.test.ts +0 -94
  319. package/tests/context-enricher.test.ts +0 -971
  320. package/tests/fixtures/monorepo/package.json +0 -6
  321. package/tests/fixtures/monorepo/packages/app/package.json +0 -12
  322. package/tests/fixtures/monorepo/packages/app/src/index.ts +0 -6
  323. package/tests/fixtures/monorepo/packages/core/package.json +0 -7
  324. package/tests/fixtures/monorepo/packages/core/src/index.ts +0 -7
  325. package/tests/forecast.test.ts +0 -509
  326. package/tests/framework-detector.test.ts +0 -1172
  327. package/tests/git-history.test.ts +0 -254
  328. package/tests/monorepo-scan.test.ts +0 -170
  329. package/tests/scanner.test.ts +0 -54
  330. package/tests/scorer.test.ts +0 -674
  331. package/tests/stack-detector.test.ts +0 -241
  332. package/tests/template-generation.test.ts +0 -706
  333. package/tests/template-helpers.test.ts +0 -1152
  334. package/tests/temporal-scorer.test.ts +0 -307
  335. /package/dist/{reporter.js → src/adapters/reporter.js} +0 -0
@@ -1,669 +0,0 @@
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
- }