@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,496 +0,0 @@
1
- /**
2
- * Architecture Weather Forecast — Predictive analysis
3
- *
4
- * Combines temporal scores + velocity vectors + change coupling
5
- * to predict which modules will become anti-patterns.
6
- *
7
- * Key concept: Pre-Anti-Pattern
8
- * A module isn't an anti-pattern yet, but its trajectory says it will be.
9
- * "Your code doesn't have a problem — it WILL have one in 3 months."
10
- *
11
- * @author Camilo Girardelli — Girardelli Tecnologia
12
- * @license MIT
13
- */
14
-
15
- import type {
16
- GitHistoryReport,
17
- ModuleHistory,
18
- ChangeCoupling,
19
- FileHistory,
20
- } from './git-history.js';
21
- import type { TemporalReport, TemporalScore } from './temporal-scorer.js';
22
-
23
- // ═══════════════════════════════════════════════════════════════
24
- // TYPES
25
- // ═══════════════════════════════════════════════════════════════
26
-
27
- export type PreAntiPatternType =
28
- | 'emerging-god-class'
29
- | 'emerging-shotgun-surgery'
30
- | 'emerging-feature-envy'
31
- | 'bus-factor-risk'
32
- | 'complexity-spiral'
33
- | 'coupling-magnet';
34
-
35
- export interface PreAntiPattern {
36
- type: PreAntiPatternType;
37
- module: string;
38
- severity: 'warning' | 'watch' | 'alert';
39
- currentScore: number;
40
- projectedScore: number;
41
- /** Estimated weeks until threshold breach */
42
- weeksToThreshold: number;
43
- /** What threshold will be crossed */
44
- threshold: number;
45
- description: string;
46
- evidence: string[];
47
- recommendation: string;
48
- confidence: number;
49
- }
50
-
51
- export interface ModuleForecast {
52
- module: string;
53
- currentHealth: 'healthy' | 'at-risk' | 'degrading' | 'critical';
54
- forecast6Months: 'stable' | 'declining' | 'breakdown';
55
- preAntiPatterns: PreAntiPattern[];
56
- bottleneckProbability: number; // 0-1
57
- riskFactors: string[];
58
- topAction: string;
59
- }
60
-
61
- export interface WeatherForecast {
62
- projectPath: string;
63
- generatedAt: string;
64
- overallOutlook: 'sunny' | 'cloudy' | 'stormy';
65
- headline: string;
66
- modules: ModuleForecast[];
67
- preAntiPatterns: PreAntiPattern[];
68
- topRisks: string[];
69
- recommendations: string[];
70
- }
71
-
72
- export interface ForecastConfig {
73
- /** Score threshold for anti-pattern (default: 40) */
74
- antiPatternThreshold?: number;
75
- /** Churn rate threshold for god class emergence (default: 150 lines/commit) */
76
- godClassChurnThreshold?: number;
77
- /** Co-change count for shotgun surgery (default: 5) */
78
- shotgunCouplingThreshold?: number;
79
- /** Max bus factor for risk (default: 1) */
80
- busFatorRiskThreshold?: number;
81
- /** Weeks for projection (default: 26 — 6 months) */
82
- forecastWeeks?: number;
83
- }
84
-
85
- const DEFAULT_CONFIG: Required<ForecastConfig> = {
86
- antiPatternThreshold: 40,
87
- godClassChurnThreshold: 150,
88
- shotgunCouplingThreshold: 5,
89
- busFatorRiskThreshold: 1,
90
- forecastWeeks: 26,
91
- };
92
-
93
- // ═══════════════════════════════════════════════════════════════
94
- // FORECAST ENGINE
95
- // ═══════════════════════════════════════════════════════════════
96
-
97
- export class ForecastEngine {
98
- private config: Required<ForecastConfig>;
99
-
100
- constructor(config?: ForecastConfig) {
101
- this.config = { ...DEFAULT_CONFIG, ...config };
102
- }
103
-
104
- /**
105
- * Generate architecture weather forecast.
106
- */
107
- forecast(
108
- gitReport: GitHistoryReport,
109
- temporalReport: TemporalReport,
110
- ): WeatherForecast {
111
- const preAntiPatterns: PreAntiPattern[] = [];
112
- const moduleForecastMap = new Map<string, ModuleForecast>();
113
-
114
- // Detect pre-anti-patterns for each module
115
- for (const module of gitReport.modules) {
116
- const temporal = temporalReport.modules.find(m => m.module === module.modulePath);
117
- if (!temporal) continue;
118
-
119
- const patterns = this.detectPreAntiPatterns(module, temporal, gitReport.changeCouplings);
120
- preAntiPatterns.push(...patterns);
121
-
122
- const forecast = this.forecastModule(module, temporal, patterns);
123
- moduleForecastMap.set(module.modulePath, forecast);
124
- }
125
-
126
- // Sort by risk
127
- const modules = Array.from(moduleForecastMap.values())
128
- .sort((a, b) => b.bottleneckProbability - a.bottleneckProbability);
129
-
130
- const outlook = this.classifyOutlook(temporalReport, preAntiPatterns);
131
- const headline = this.generateHeadline(outlook, preAntiPatterns, modules);
132
- const topRisks = this.identifyTopRisks(modules, preAntiPatterns);
133
- const recommendations = this.generateRecommendations(modules, preAntiPatterns);
134
-
135
- return {
136
- projectPath: gitReport.projectPath,
137
- generatedAt: new Date().toISOString(),
138
- overallOutlook: outlook,
139
- headline,
140
- modules,
141
- preAntiPatterns: preAntiPatterns.sort((a, b) => a.weeksToThreshold - b.weeksToThreshold),
142
- topRisks,
143
- recommendations,
144
- };
145
- }
146
-
147
- // ── Pre-Anti-Pattern Detection ──
148
-
149
- private detectPreAntiPatterns(
150
- module: ModuleHistory,
151
- temporal: TemporalScore,
152
- couplings: ChangeCoupling[],
153
- ): PreAntiPattern[] {
154
- const patterns: PreAntiPattern[] = [];
155
-
156
- patterns.push(...this.detectEmergingGodClass(module, temporal));
157
- patterns.push(...this.detectEmergingShotgunSurgery(module, couplings));
158
- patterns.push(...this.detectBusFactorRisk(module, temporal));
159
- patterns.push(...this.detectComplexitySpiral(module, temporal));
160
- patterns.push(...this.detectCouplingMagnet(module, couplings, temporal));
161
-
162
- return patterns;
163
- }
164
-
165
- private detectEmergingGodClass(
166
- module: ModuleHistory,
167
- temporal: TemporalScore,
168
- ): PreAntiPattern[] {
169
- const patterns: PreAntiPattern[] = [];
170
-
171
- for (const file of module.files) {
172
- if (file.churnRate < this.config.godClassChurnThreshold) continue;
173
- if (temporal.velocity.churnTrend <= 0) continue;
174
-
175
- // Project when churn will exceed critical threshold
176
- const weeklyGrowth = file.churnRate * (temporal.velocity.churnTrend / 100) / 4;
177
- const criticalChurn = this.config.godClassChurnThreshold * 2;
178
- const weeksToThreshold = weeklyGrowth > 0
179
- ? Math.ceil((criticalChurn - file.churnRate) / weeklyGrowth)
180
- : Infinity;
181
-
182
- if (weeksToThreshold <= this.config.forecastWeeks) {
183
- patterns.push({
184
- type: 'emerging-god-class',
185
- module: module.modulePath,
186
- severity: weeksToThreshold <= 8 ? 'alert' : weeksToThreshold <= 16 ? 'warning' : 'watch',
187
- currentScore: temporal.staticScore,
188
- projectedScore: temporal.projectedScore,
189
- weeksToThreshold,
190
- threshold: criticalChurn,
191
- description: `File '${file.path}' has churn rate ${Math.round(file.churnRate)} lines/commit and growing ${Math.round(temporal.velocity.churnTrend)}%`,
192
- evidence: [
193
- `Current churn: ${Math.round(file.churnRate)} lines/commit`,
194
- `Growth rate: ${Math.round(temporal.velocity.churnTrend)}%`,
195
- `${file.commits} commits in analysis period`,
196
- `${file.authors.size} contributor(s)`,
197
- ],
198
- recommendation: 'Split into smaller, focused modules before complexity makes refactoring prohibitively expensive.',
199
- confidence: Math.min(0.9, 0.5 + (file.commits / 50)),
200
- });
201
- }
202
- }
203
-
204
- return patterns;
205
- }
206
-
207
- private detectEmergingShotgunSurgery(
208
- module: ModuleHistory,
209
- couplings: ChangeCoupling[],
210
- ): PreAntiPattern[] {
211
- // Count how many files this module is coupled with
212
- const moduleCouplings = couplings.filter(
213
- c => c.fileA.startsWith(module.modulePath) || c.fileB.startsWith(module.modulePath)
214
- );
215
-
216
- if (moduleCouplings.length < this.config.shotgunCouplingThreshold) return [];
217
-
218
- const avgConfidence = moduleCouplings.reduce((s, c) => s + c.confidence, 0) / moduleCouplings.length;
219
-
220
- return [{
221
- type: 'emerging-shotgun-surgery',
222
- module: module.modulePath,
223
- severity: moduleCouplings.length > 10 ? 'alert' : 'warning',
224
- currentScore: 0,
225
- projectedScore: 0,
226
- weeksToThreshold: 4,
227
- threshold: this.config.shotgunCouplingThreshold,
228
- description: `Module '${module.modulePath}' has ${moduleCouplings.length} change-coupled files — changes here ripple across the codebase`,
229
- evidence: [
230
- `${moduleCouplings.length} files change together with this module`,
231
- `Average coupling confidence: ${Math.round(avgConfidence * 100)}%`,
232
- ...moduleCouplings.slice(0, 3).map(c =>
233
- `${c.fileA} ↔ ${c.fileB} (${c.cochangeCount} co-changes)`
234
- ),
235
- ],
236
- recommendation: 'Extract shared concerns into a dedicated module. Introduce interfaces to decouple.',
237
- confidence: avgConfidence,
238
- }];
239
- }
240
-
241
- private detectBusFactorRisk(
242
- module: ModuleHistory,
243
- temporal: TemporalScore,
244
- ): PreAntiPattern[] {
245
- if (module.busFactor > this.config.busFatorRiskThreshold) return [];
246
- if (module.aggregateCommits < 5) return []; // too few commits to judge
247
-
248
- return [{
249
- type: 'bus-factor-risk',
250
- module: module.modulePath,
251
- severity: temporal.trend === 'degrading' ? 'alert' : 'warning',
252
- currentScore: temporal.staticScore,
253
- projectedScore: temporal.projectedScore,
254
- weeksToThreshold: this.config.forecastWeeks,
255
- threshold: 2,
256
- description: `Module '${module.modulePath}' has bus factor of ${module.busFactor} — all knowledge in one person`,
257
- evidence: [
258
- `Only ${module.busFactor} contributor(s)`,
259
- `${module.aggregateCommits} total commits`,
260
- `${module.files.length} files in module`,
261
- ],
262
- recommendation: 'Pair programming or code review rotation to spread knowledge. Document critical decisions.',
263
- confidence: 0.8,
264
- }];
265
- }
266
-
267
- private detectComplexitySpiral(
268
- module: ModuleHistory,
269
- temporal: TemporalScore,
270
- ): PreAntiPattern[] {
271
- if (temporal.velocity.churnTrend <= 20) return [];
272
- if (temporal.velocity.direction !== 'accelerating') return [];
273
-
274
- // Accelerating churn + increasing commit rate = complexity spiral
275
- const weeklyScoreDecay = (temporal.staticScore - temporal.projectedScore) / temporal.projectionWeeks;
276
- const weeksToThreshold = weeklyScoreDecay > 0
277
- ? Math.ceil((temporal.temporalScore - this.config.antiPatternThreshold) / weeklyScoreDecay)
278
- : Infinity;
279
-
280
- if (weeksToThreshold > this.config.forecastWeeks) return [];
281
-
282
- return [{
283
- type: 'complexity-spiral',
284
- module: module.modulePath,
285
- severity: weeksToThreshold <= 8 ? 'alert' : 'warning',
286
- currentScore: temporal.temporalScore,
287
- projectedScore: temporal.projectedScore,
288
- weeksToThreshold,
289
- threshold: this.config.antiPatternThreshold,
290
- description: `Module '${module.modulePath}' is in a complexity spiral — accelerating churn with increasing commit frequency`,
291
- evidence: [
292
- `Churn trend: +${Math.round(temporal.velocity.churnTrend)}%`,
293
- `Commit acceleration: +${Math.round(temporal.velocity.commitAcceleration)}%`,
294
- `Current temporal score: ${temporal.temporalScore}/100`,
295
- `Projected score in ${temporal.projectionWeeks} weeks: ${temporal.projectedScore}/100`,
296
- ],
297
- recommendation: 'Stop adding features to this module. Invest in refactoring and test coverage first.',
298
- confidence: temporal.projectionConfidence,
299
- }];
300
- }
301
-
302
- private detectCouplingMagnet(
303
- module: ModuleHistory,
304
- couplings: ChangeCoupling[],
305
- temporal: TemporalScore,
306
- ): PreAntiPattern[] {
307
- // Files that are increasingly coupled with many others
308
- const inboundCouplings = couplings.filter(
309
- c => c.fileB.startsWith(module.modulePath) && c.confidence > 0.5
310
- );
311
-
312
- if (inboundCouplings.length < 3) return [];
313
- if (temporal.velocity.commitAcceleration <= 0) return [];
314
-
315
- return [{
316
- type: 'coupling-magnet',
317
- module: module.modulePath,
318
- severity: 'watch',
319
- currentScore: temporal.staticScore,
320
- projectedScore: temporal.projectedScore,
321
- weeksToThreshold: 12,
322
- threshold: 10,
323
- description: `Module '${module.modulePath}' is becoming a coupling magnet — ${inboundCouplings.length} high-confidence inbound dependencies`,
324
- evidence: [
325
- `${inboundCouplings.length} modules depend on changes here`,
326
- `Module commit rate accelerating: +${Math.round(temporal.velocity.commitAcceleration)}%`,
327
- ],
328
- recommendation: 'Extract stable interfaces. Consider the Dependency Inversion Principle to break inbound coupling.',
329
- confidence: 0.6,
330
- }];
331
- }
332
-
333
- // ── Module Forecast ──
334
-
335
- private forecastModule(
336
- module: ModuleHistory,
337
- temporal: TemporalScore,
338
- patterns: PreAntiPattern[],
339
- ): ModuleForecast {
340
- const health = this.classifyHealth(temporal);
341
- const forecast6m = this.classify6MonthForecast(temporal, patterns);
342
- const bottleneckProb = this.calculateBottleneckProbability(temporal, patterns, module);
343
-
344
- const riskFactors: string[] = [];
345
- if (temporal.trend === 'degrading') riskFactors.push('Score degrading');
346
- if (module.busFactor <= 1) riskFactors.push('Single contributor');
347
- if (temporal.velocity.churnTrend > 30) riskFactors.push('Churn increasing');
348
- if (patterns.length > 0) riskFactors.push(`${patterns.length} pre-anti-pattern(s)`);
349
-
350
- const topAction = patterns.length > 0
351
- ? patterns[0].recommendation
352
- : temporal.trend === 'degrading'
353
- ? 'Review recent changes and stabilize'
354
- : 'No action needed';
355
-
356
- return {
357
- module: module.modulePath,
358
- currentHealth: health,
359
- forecast6Months: forecast6m,
360
- preAntiPatterns: patterns,
361
- bottleneckProbability: bottleneckProb,
362
- riskFactors,
363
- topAction,
364
- };
365
- }
366
-
367
- private classifyHealth(temporal: TemporalScore): ModuleForecast['currentHealth'] {
368
- if (temporal.temporalScore < 30) return 'critical';
369
- if (temporal.temporalScore < 50 || temporal.trend === 'degrading') return 'degrading';
370
- if (temporal.temporalScore < 70) return 'at-risk';
371
- return 'healthy';
372
- }
373
-
374
- private classify6MonthForecast(
375
- temporal: TemporalScore,
376
- patterns: PreAntiPattern[],
377
- ): ModuleForecast['forecast6Months'] {
378
- const alerts = patterns.filter(p => p.severity === 'alert');
379
- if (alerts.length > 0 || temporal.projectedScore < 30) return 'breakdown';
380
- if (temporal.trend === 'degrading' || patterns.length > 0) return 'declining';
381
- return 'stable';
382
- }
383
-
384
- private calculateBottleneckProbability(
385
- temporal: TemporalScore,
386
- patterns: PreAntiPattern[],
387
- module: ModuleHistory,
388
- ): number {
389
- let prob = 0;
390
-
391
- // Low score → higher probability
392
- if (temporal.temporalScore < 50) prob += 0.3;
393
- else if (temporal.temporalScore < 70) prob += 0.1;
394
-
395
- // Degrading trend
396
- if (temporal.trend === 'degrading') prob += 0.2;
397
-
398
- // Pre-anti-patterns
399
- prob += Math.min(0.3, patterns.length * 0.1);
400
-
401
- // Low bus factor
402
- if (module.busFactor <= 1) prob += 0.1;
403
-
404
- // High churn
405
- if (temporal.velocity.churnTrend > 30) prob += 0.1;
406
-
407
- return Math.min(1, Math.round(prob * 100) / 100);
408
- }
409
-
410
- // ── Overall Analysis ──
411
-
412
- private classifyOutlook(
413
- temporal: TemporalReport,
414
- patterns: PreAntiPattern[],
415
- ): WeatherForecast['overallOutlook'] {
416
- const alerts = patterns.filter(p => p.severity === 'alert');
417
- if (alerts.length >= 2 || temporal.overallTrend === 'degrading') return 'stormy';
418
- if (alerts.length >= 1 || patterns.length >= 3) return 'cloudy';
419
- return 'sunny';
420
- }
421
-
422
- private generateHeadline(
423
- outlook: WeatherForecast['overallOutlook'],
424
- patterns: PreAntiPattern[],
425
- modules: ModuleForecast[],
426
- ): string {
427
- const critical = modules.filter(m => m.currentHealth === 'critical').length;
428
- const degrading = modules.filter(m => m.currentHealth === 'degrading').length;
429
-
430
- switch (outlook) {
431
- case 'stormy':
432
- return `${critical + degrading} module(s) at risk. ${patterns.length} pre-anti-pattern(s) detected. Immediate action recommended.`;
433
- case 'cloudy':
434
- return `Architecture trending stable with ${patterns.length} emerging concern(s). Proactive refactoring recommended.`;
435
- case 'sunny':
436
- return 'Architecture is healthy and stable. Continue current practices.';
437
- }
438
- }
439
-
440
- private identifyTopRisks(
441
- modules: ModuleForecast[],
442
- patterns: PreAntiPattern[],
443
- ): string[] {
444
- const risks: string[] = [];
445
-
446
- const breakdowns = modules.filter(m => m.forecast6Months === 'breakdown');
447
- if (breakdowns.length > 0) {
448
- risks.push(`${breakdowns.length} module(s) projected to break down within 6 months: ${breakdowns.map(m => m.module).join(', ')}`);
449
- }
450
-
451
- const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
452
- if (busRisks.length > 0) {
453
- risks.push(`Bus factor risk in ${busRisks.length} module(s) — knowledge concentrated in single contributors`);
454
- }
455
-
456
- const spirals = patterns.filter(p => p.type === 'complexity-spiral');
457
- if (spirals.length > 0) {
458
- risks.push(`Complexity spiral detected in: ${spirals.map(p => p.module).join(', ')}`);
459
- }
460
-
461
- return risks.slice(0, 5);
462
- }
463
-
464
- private generateRecommendations(
465
- modules: ModuleForecast[],
466
- patterns: PreAntiPattern[],
467
- ): string[] {
468
- const recs: string[] = [];
469
-
470
- const critical = modules.filter(m => m.currentHealth === 'critical');
471
- if (critical.length > 0) {
472
- recs.push(`Immediate: Stabilize ${critical.map(m => m.module).join(', ')} — freeze features, invest in refactoring`);
473
- }
474
-
475
- const godClasses = patterns.filter(p => p.type === 'emerging-god-class');
476
- if (godClasses.length > 0) {
477
- recs.push(`Split growing files before they become god classes: ${godClasses.map(p => p.module).join(', ')}`);
478
- }
479
-
480
- const shotgun = patterns.filter(p => p.type === 'emerging-shotgun-surgery');
481
- if (shotgun.length > 0) {
482
- recs.push(`Decouple modules with high change coupling to prevent shotgun surgery`);
483
- }
484
-
485
- const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
486
- if (busRisks.length > 0) {
487
- recs.push(`Spread knowledge: pair programming or rotation for ${busRisks.map(p => p.module).join(', ')}`);
488
- }
489
-
490
- if (recs.length === 0) {
491
- recs.push('Architecture is healthy. Continue monitoring temporal trends.');
492
- }
493
-
494
- return recs.slice(0, 5);
495
- }
496
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * Git History Cache — Serialize/deserialize GitHistoryReport
3
- */
4
-
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import type { GitHistoryReport } from './git-history.js';
8
-
9
- export function saveToCache(
10
- report: GitHistoryReport,
11
- projectPath: string,
12
- cacheDir = '.architect-cache',
13
- ): void {
14
- const dir = path.join(projectPath, cacheDir);
15
- fs.mkdirSync(dir, { recursive: true });
16
-
17
- const serializable = {
18
- ...report,
19
- modules: report.modules.map(m => ({
20
- ...m,
21
- files: m.files.map(f => ({
22
- ...f,
23
- authors: Array.from(f.authors),
24
- lastModified: f.lastModified.toISOString(),
25
- })),
26
- })),
27
- hotspots: report.hotspots.map(f => ({
28
- ...f,
29
- authors: Array.from(f.authors),
30
- lastModified: f.lastModified.toISOString(),
31
- })),
32
- };
33
-
34
- fs.writeFileSync(path.join(dir, 'git-history.json'), JSON.stringify(serializable, null, 2));
35
- }
36
-
37
- export function loadFromCache(
38
- projectPath: string,
39
- cacheDir = '.architect-cache',
40
- maxAgeMs = 3600000,
41
- ): GitHistoryReport | null {
42
- const cachePath = path.join(projectPath, cacheDir, 'git-history.json');
43
- if (!fs.existsSync(cachePath)) return null;
44
-
45
- try {
46
- const raw = JSON.parse(fs.readFileSync(cachePath, 'utf-8'));
47
- if (Date.now() - new Date(raw.analyzedAt).getTime() > maxAgeMs) return null;
48
- return raw;
49
- } catch {
50
- return null;
51
- }
52
- }