@girardelli/architect-core 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 (217) hide show
  1. package/dist/src/core/analyzer.d.ts +42 -0
  2. package/dist/src/core/analyzer.js +431 -0
  3. package/dist/src/core/analyzer.js.map +1 -0
  4. package/dist/src/core/analyzers/forecast.d.ts +84 -0
  5. package/dist/src/core/analyzers/forecast.js +338 -0
  6. package/dist/src/core/analyzers/forecast.js.map +1 -0
  7. package/dist/src/core/analyzers/index.d.ts +9 -0
  8. package/dist/src/core/analyzers/index.js +7 -0
  9. package/dist/src/core/analyzers/index.js.map +1 -0
  10. package/dist/src/core/analyzers/temporal-scorer.d.ts +71 -0
  11. package/dist/src/core/analyzers/temporal-scorer.js +141 -0
  12. package/dist/src/core/analyzers/temporal-scorer.js.map +1 -0
  13. package/dist/src/core/anti-patterns.d.ts +28 -0
  14. package/dist/src/core/anti-patterns.js +264 -0
  15. package/dist/src/core/anti-patterns.js.map +1 -0
  16. package/dist/src/core/ast/ast-parser.interface.d.ts +20 -0
  17. package/dist/src/core/ast/ast-parser.interface.js +2 -0
  18. package/dist/src/core/ast/ast-parser.interface.js.map +1 -0
  19. package/dist/src/core/ast/path-resolver.d.ts +13 -0
  20. package/dist/src/core/ast/path-resolver.js +54 -0
  21. package/dist/src/core/ast/path-resolver.js.map +1 -0
  22. package/dist/src/core/ast/tree-sitter-parser.d.ts +10 -0
  23. package/dist/src/core/ast/tree-sitter-parser.js +142 -0
  24. package/dist/src/core/ast/tree-sitter-parser.js.map +1 -0
  25. package/dist/src/core/config.d.ts +11 -0
  26. package/dist/src/core/config.js +112 -0
  27. package/dist/src/core/config.js.map +1 -0
  28. package/dist/src/core/diagram.d.ts +9 -0
  29. package/dist/src/core/diagram.js +101 -0
  30. package/dist/src/core/diagram.js.map +1 -0
  31. package/dist/src/core/i18n.d.ts +14 -0
  32. package/dist/src/core/i18n.js +54 -0
  33. package/dist/src/core/i18n.js.map +1 -0
  34. package/dist/src/core/locales/en.d.ts +2 -0
  35. package/dist/src/core/locales/en.js +337 -0
  36. package/dist/src/core/locales/en.js.map +1 -0
  37. package/dist/src/core/locales/pt-BR.d.ts +172 -0
  38. package/dist/src/core/locales/pt-BR.js +337 -0
  39. package/dist/src/core/locales/pt-BR.js.map +1 -0
  40. package/dist/src/core/locales/types.d.ts +86 -0
  41. package/dist/src/core/locales/types.js +2 -0
  42. package/dist/src/core/locales/types.js.map +1 -0
  43. package/dist/src/core/plugin-loader.d.ts +11 -0
  44. package/dist/src/core/plugin-loader.js +67 -0
  45. package/dist/src/core/plugin-loader.js.map +1 -0
  46. package/dist/src/core/project-summarizer.d.ts +16 -0
  47. package/dist/src/core/project-summarizer.js +37 -0
  48. package/dist/src/core/project-summarizer.js.map +1 -0
  49. package/dist/src/core/refactor-engine.d.ts +18 -0
  50. package/dist/src/core/refactor-engine.js +87 -0
  51. package/dist/src/core/refactor-engine.js.map +1 -0
  52. package/dist/src/core/rules/barrel-optimizer.d.ts +13 -0
  53. package/dist/src/core/rules/barrel-optimizer.js +76 -0
  54. package/dist/src/core/rules/barrel-optimizer.js.map +1 -0
  55. package/dist/src/core/rules/dead-code-detector.d.ts +21 -0
  56. package/dist/src/core/rules/dead-code-detector.js +116 -0
  57. package/dist/src/core/rules/dead-code-detector.js.map +1 -0
  58. package/dist/src/core/rules/hub-splitter.d.ts +13 -0
  59. package/dist/src/core/rules/hub-splitter.js +117 -0
  60. package/dist/src/core/rules/hub-splitter.js.map +1 -0
  61. package/dist/src/core/rules/import-organizer.d.ts +13 -0
  62. package/dist/src/core/rules/import-organizer.js +84 -0
  63. package/dist/src/core/rules/import-organizer.js.map +1 -0
  64. package/dist/src/core/rules/module-grouper.d.ts +13 -0
  65. package/dist/src/core/rules/module-grouper.js +116 -0
  66. package/dist/src/core/rules/module-grouper.js.map +1 -0
  67. package/dist/src/core/rules-engine.d.ts +7 -0
  68. package/dist/src/core/rules-engine.js +89 -0
  69. package/dist/src/core/rules-engine.js.map +1 -0
  70. package/dist/src/core/scorer.d.ts +15 -0
  71. package/dist/src/core/scorer.js +165 -0
  72. package/dist/src/core/scorer.js.map +1 -0
  73. package/dist/src/core/summarizer/keyword-extractor.d.ts +6 -0
  74. package/dist/src/core/summarizer/keyword-extractor.js +38 -0
  75. package/dist/src/core/summarizer/keyword-extractor.js.map +1 -0
  76. package/dist/src/core/summarizer/module-inferrer.d.ts +11 -0
  77. package/dist/src/core/summarizer/module-inferrer.js +171 -0
  78. package/dist/src/core/summarizer/module-inferrer.js.map +1 -0
  79. package/dist/src/core/summarizer/package-reader.d.ts +3 -0
  80. package/dist/src/core/summarizer/package-reader.js +33 -0
  81. package/dist/src/core/summarizer/package-reader.js.map +1 -0
  82. package/dist/src/core/summarizer/purpose-inferrer.d.ts +8 -0
  83. package/dist/src/core/summarizer/purpose-inferrer.js +179 -0
  84. package/dist/src/core/summarizer/purpose-inferrer.js.map +1 -0
  85. package/dist/src/core/summarizer/readme-reader.d.ts +3 -0
  86. package/dist/src/core/summarizer/readme-reader.js +24 -0
  87. package/dist/src/core/summarizer/readme-reader.js.map +1 -0
  88. package/dist/src/core/types/architect-rules.d.ts +27 -0
  89. package/dist/src/core/types/architect-rules.js +2 -0
  90. package/dist/src/core/types/architect-rules.js.map +1 -0
  91. package/dist/src/core/types/core.d.ts +87 -0
  92. package/dist/src/core/types/core.js +2 -0
  93. package/dist/src/core/types/core.js.map +1 -0
  94. package/dist/src/core/types/infrastructure.d.ts +38 -0
  95. package/dist/src/core/types/infrastructure.js +2 -0
  96. package/dist/src/core/types/infrastructure.js.map +1 -0
  97. package/dist/src/core/types/plugin.d.ts +12 -0
  98. package/dist/src/core/types/plugin.js +2 -0
  99. package/dist/src/core/types/plugin.js.map +1 -0
  100. package/dist/src/core/types/rules.d.ts +53 -0
  101. package/dist/src/core/types/rules.js +2 -0
  102. package/dist/src/core/types/rules.js.map +1 -0
  103. package/dist/src/core/types/summarizer.d.ts +12 -0
  104. package/dist/src/core/types/summarizer.js +2 -0
  105. package/dist/src/core/types/summarizer.js.map +1 -0
  106. package/dist/src/infrastructure/git-cache.d.ts +6 -0
  107. package/dist/src/infrastructure/git-cache.js +41 -0
  108. package/dist/src/infrastructure/git-cache.js.map +1 -0
  109. package/dist/src/infrastructure/git-history.d.ts +112 -0
  110. package/dist/src/infrastructure/git-history.js +340 -0
  111. package/dist/src/infrastructure/git-history.js.map +1 -0
  112. package/dist/src/infrastructure/logger.d.ts +20 -0
  113. package/dist/src/infrastructure/logger.js +57 -0
  114. package/dist/src/infrastructure/logger.js.map +1 -0
  115. package/dist/src/infrastructure/scanner.d.ts +31 -0
  116. package/dist/src/infrastructure/scanner.js +334 -0
  117. package/dist/src/infrastructure/scanner.js.map +1 -0
  118. package/dist/tests/analyzers-integration.test.d.ts +7 -0
  119. package/dist/tests/analyzers-integration.test.js +140 -0
  120. package/dist/tests/analyzers-integration.test.js.map +1 -0
  121. package/dist/tests/anti-patterns.test.d.ts +1 -0
  122. package/dist/tests/anti-patterns.test.js +81 -0
  123. package/dist/tests/anti-patterns.test.js.map +1 -0
  124. package/dist/tests/ast-parser.test.d.ts +1 -0
  125. package/dist/tests/ast-parser.test.js +94 -0
  126. package/dist/tests/ast-parser.test.js.map +1 -0
  127. package/dist/tests/fixtures/monorepo/packages/app/src/index.d.ts +1 -0
  128. package/dist/tests/fixtures/monorepo/packages/app/src/index.js +9 -0
  129. package/dist/tests/fixtures/monorepo/packages/app/src/index.js.map +1 -0
  130. package/dist/tests/fixtures/monorepo/packages/core/src/index.d.ts +2 -0
  131. package/dist/tests/fixtures/monorepo/packages/core/src/index.js +11 -0
  132. package/dist/tests/fixtures/monorepo/packages/core/src/index.js.map +1 -0
  133. package/dist/tests/forecast.test.d.ts +7 -0
  134. package/dist/tests/forecast.test.js +380 -0
  135. package/dist/tests/forecast.test.js.map +1 -0
  136. package/dist/tests/git-history.test.d.ts +7 -0
  137. package/dist/tests/git-history.test.js +193 -0
  138. package/dist/tests/git-history.test.js.map +1 -0
  139. package/dist/tests/i18n.test.d.ts +1 -0
  140. package/dist/tests/i18n.test.js +39 -0
  141. package/dist/tests/i18n.test.js.map +1 -0
  142. package/dist/tests/monorepo-scan.test.d.ts +11 -0
  143. package/dist/tests/monorepo-scan.test.js +143 -0
  144. package/dist/tests/monorepo-scan.test.js.map +1 -0
  145. package/dist/tests/plugin-loader.test.d.ts +1 -0
  146. package/dist/tests/plugin-loader.test.js +31 -0
  147. package/dist/tests/plugin-loader.test.js.map +1 -0
  148. package/dist/tests/rules-engine.test.d.ts +1 -0
  149. package/dist/tests/rules-engine.test.js +112 -0
  150. package/dist/tests/rules-engine.test.js.map +1 -0
  151. package/dist/tests/scanner.test.d.ts +1 -0
  152. package/dist/tests/scanner.test.js +44 -0
  153. package/dist/tests/scanner.test.js.map +1 -0
  154. package/dist/tests/scorer.test.d.ts +1 -0
  155. package/dist/tests/scorer.test.js +610 -0
  156. package/dist/tests/scorer.test.js.map +1 -0
  157. package/dist/tests/temporal-scorer.test.d.ts +7 -0
  158. package/dist/tests/temporal-scorer.test.js +239 -0
  159. package/dist/tests/temporal-scorer.test.js.map +1 -0
  160. package/package.json +29 -0
  161. package/src/core/analyzer.ts +499 -0
  162. package/src/core/analyzers/forecast.ts +497 -0
  163. package/src/core/analyzers/index.ts +33 -0
  164. package/src/core/analyzers/temporal-scorer.ts +227 -0
  165. package/src/core/anti-patterns.ts +324 -0
  166. package/src/core/ast/ast-parser.interface.ts +21 -0
  167. package/src/core/ast/path-resolver.ts +61 -0
  168. package/src/core/ast/tree-sitter-parser.ts +158 -0
  169. package/src/core/config.ts +125 -0
  170. package/src/core/diagram.ts +129 -0
  171. package/src/core/i18n.ts +64 -0
  172. package/src/core/locales/en.ts +340 -0
  173. package/src/core/locales/pt-BR.ts +341 -0
  174. package/src/core/locales/types.ts +95 -0
  175. package/src/core/plugin-loader.ts +80 -0
  176. package/src/core/project-summarizer.ts +42 -0
  177. package/src/core/refactor-engine.ts +112 -0
  178. package/src/core/rules/barrel-optimizer.ts +99 -0
  179. package/src/core/rules/dead-code-detector.ts +134 -0
  180. package/src/core/rules/hub-splitter.ts +135 -0
  181. package/src/core/rules/import-organizer.ts +100 -0
  182. package/src/core/rules/module-grouper.ts +133 -0
  183. package/src/core/rules-engine.ts +100 -0
  184. package/src/core/scorer.ts +181 -0
  185. package/src/core/summarizer/keyword-extractor.ts +53 -0
  186. package/src/core/summarizer/module-inferrer.ts +194 -0
  187. package/src/core/summarizer/package-reader.ts +34 -0
  188. package/src/core/summarizer/purpose-inferrer.ts +197 -0
  189. package/src/core/summarizer/readme-reader.ts +24 -0
  190. package/src/core/types/architect-rules.ts +29 -0
  191. package/src/core/types/core.ts +94 -0
  192. package/src/core/types/infrastructure.ts +41 -0
  193. package/src/core/types/plugin.ts +19 -0
  194. package/src/core/types/rules.ts +51 -0
  195. package/src/core/types/summarizer.ts +8 -0
  196. package/src/infrastructure/git-cache.ts +52 -0
  197. package/src/infrastructure/git-history.ts +496 -0
  198. package/src/infrastructure/logger.ts +68 -0
  199. package/src/infrastructure/scanner.ts +349 -0
  200. package/tests/analyzers-integration.test.ts +174 -0
  201. package/tests/anti-patterns.test.ts +95 -0
  202. package/tests/ast-parser.test.ts +102 -0
  203. package/tests/fixtures/monorepo/package.json +6 -0
  204. package/tests/fixtures/monorepo/packages/app/package.json +12 -0
  205. package/tests/fixtures/monorepo/packages/app/src/index.ts +6 -0
  206. package/tests/fixtures/monorepo/packages/core/package.json +7 -0
  207. package/tests/fixtures/monorepo/packages/core/src/index.ts +7 -0
  208. package/tests/forecast.test.ts +504 -0
  209. package/tests/git-history.test.ts +254 -0
  210. package/tests/i18n.test.ts +47 -0
  211. package/tests/monorepo-scan.test.ts +170 -0
  212. package/tests/plugin-loader.test.ts +40 -0
  213. package/tests/rules-engine.test.ts +131 -0
  214. package/tests/scanner.test.ts +54 -0
  215. package/tests/scorer.test.ts +675 -0
  216. package/tests/temporal-scorer.test.ts +306 -0
  217. package/tsconfig.json +9 -0
@@ -0,0 +1,338 @@
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
+ const DEFAULT_CONFIG = {
15
+ antiPatternThreshold: 40,
16
+ godClassChurnThreshold: 150,
17
+ shotgunCouplingThreshold: 5,
18
+ busFatorRiskThreshold: 1,
19
+ forecastWeeks: 26,
20
+ };
21
+ // ═══════════════════════════════════════════════════════════════
22
+ // FORECAST ENGINE
23
+ // ═══════════════════════════════════════════════════════════════
24
+ export class ForecastEngine {
25
+ config;
26
+ constructor(config) {
27
+ this.config = { ...DEFAULT_CONFIG, ...config };
28
+ }
29
+ /**
30
+ * Generate architecture weather forecast.
31
+ */
32
+ forecast(gitReport, temporalReport) {
33
+ const preAntiPatterns = [];
34
+ const moduleForecastMap = new Map();
35
+ // Detect pre-anti-patterns for each module
36
+ for (const module of gitReport.modules) {
37
+ const temporal = temporalReport.modules.find(m => m.module === module.modulePath);
38
+ if (!temporal)
39
+ continue;
40
+ const patterns = this.detectPreAntiPatterns(module, temporal, gitReport.changeCouplings);
41
+ preAntiPatterns.push(...patterns);
42
+ const forecast = this.forecastModule(module, temporal, patterns);
43
+ moduleForecastMap.set(module.modulePath, forecast);
44
+ }
45
+ // Sort by risk
46
+ const modules = Array.from(moduleForecastMap.values())
47
+ .sort((a, b) => b.bottleneckProbability - a.bottleneckProbability);
48
+ const outlook = this.classifyOutlook(temporalReport, preAntiPatterns);
49
+ const headline = this.generateHeadline(outlook, preAntiPatterns, modules);
50
+ const topRisks = this.identifyTopRisks(modules, preAntiPatterns);
51
+ const recommendations = this.generateRecommendations(modules, preAntiPatterns);
52
+ return {
53
+ projectPath: gitReport.projectPath,
54
+ generatedAt: new Date().toISOString(),
55
+ overallOutlook: outlook,
56
+ headline,
57
+ modules,
58
+ preAntiPatterns: preAntiPatterns.sort((a, b) => a.weeksToThreshold - b.weeksToThreshold),
59
+ topRisks,
60
+ recommendations,
61
+ };
62
+ }
63
+ // ── Pre-Anti-Pattern Detection ──
64
+ detectPreAntiPatterns(module, temporal, couplings) {
65
+ const patterns = [];
66
+ patterns.push(...this.detectEmergingGodClass(module, temporal));
67
+ patterns.push(...this.detectEmergingShotgunSurgery(module, couplings));
68
+ patterns.push(...this.detectBusFactorRisk(module, temporal));
69
+ patterns.push(...this.detectComplexitySpiral(module, temporal));
70
+ patterns.push(...this.detectCouplingMagnet(module, couplings, temporal));
71
+ return patterns;
72
+ }
73
+ detectEmergingGodClass(module, temporal) {
74
+ const patterns = [];
75
+ for (const file of module.files) {
76
+ if (file.churnRate < this.config.godClassChurnThreshold)
77
+ continue;
78
+ if (temporal.velocity.churnTrend <= 0)
79
+ continue;
80
+ // Project when churn will exceed critical threshold
81
+ const weeklyGrowth = file.churnRate * (temporal.velocity.churnTrend / 100) / 4;
82
+ const criticalChurn = this.config.godClassChurnThreshold * 2;
83
+ const weeksToThreshold = weeklyGrowth > 0
84
+ ? Math.ceil((criticalChurn - file.churnRate) / weeklyGrowth)
85
+ : Infinity;
86
+ if (weeksToThreshold <= this.config.forecastWeeks) {
87
+ patterns.push({
88
+ type: 'emerging-god-class',
89
+ module: module.modulePath,
90
+ severity: weeksToThreshold <= 8 ? 'alert' : weeksToThreshold <= 16 ? 'warning' : 'watch',
91
+ currentScore: temporal.staticScore,
92
+ projectedScore: temporal.projectedScore,
93
+ weeksToThreshold,
94
+ threshold: criticalChurn,
95
+ description: `File '${file.path}' has churn rate ${Math.round(file.churnRate)} lines/commit and growing ${Math.round(temporal.velocity.churnTrend)}%`,
96
+ evidence: [
97
+ `Current churn: ${Math.round(file.churnRate)} lines/commit`,
98
+ `Growth rate: ${Math.round(temporal.velocity.churnTrend)}%`,
99
+ `${file.commits} commits in analysis period`,
100
+ `${file.authors.size} contributor(s)`,
101
+ ],
102
+ recommendation: 'Split into smaller, focused modules before complexity makes refactoring prohibitively expensive.',
103
+ confidence: Math.min(0.9, 0.5 + (file.commits / 50)),
104
+ });
105
+ }
106
+ }
107
+ return patterns;
108
+ }
109
+ detectEmergingShotgunSurgery(module, couplings) {
110
+ // Count how many files this module is coupled with
111
+ const moduleCouplings = couplings.filter(c => c.fileA.startsWith(module.modulePath) || c.fileB.startsWith(module.modulePath));
112
+ if (moduleCouplings.length < this.config.shotgunCouplingThreshold)
113
+ return [];
114
+ const avgConfidence = moduleCouplings.reduce((s, c) => s + c.confidence, 0) / moduleCouplings.length;
115
+ return [{
116
+ type: 'emerging-shotgun-surgery',
117
+ module: module.modulePath,
118
+ severity: moduleCouplings.length > 10 ? 'alert' : 'warning',
119
+ currentScore: 0,
120
+ projectedScore: 0,
121
+ weeksToThreshold: 4,
122
+ threshold: this.config.shotgunCouplingThreshold,
123
+ description: `Module '${module.modulePath}' has ${moduleCouplings.length} change-coupled files — changes here ripple across the codebase`,
124
+ evidence: [
125
+ `${moduleCouplings.length} files change together with this module`,
126
+ `Average coupling confidence: ${Math.round(avgConfidence * 100)}%`,
127
+ ...moduleCouplings.slice(0, 3).map(c => `${c.fileA} ↔ ${c.fileB} (${c.cochangeCount} co-changes)`),
128
+ ],
129
+ recommendation: 'Extract shared concerns into a dedicated module. Introduce interfaces to decouple.',
130
+ confidence: avgConfidence,
131
+ }];
132
+ }
133
+ detectBusFactorRisk(module, temporal) {
134
+ if (module.busFactor > this.config.busFatorRiskThreshold)
135
+ return [];
136
+ if (module.aggregateCommits < 5)
137
+ return []; // too few commits to judge
138
+ return [{
139
+ type: 'bus-factor-risk',
140
+ module: module.modulePath,
141
+ severity: temporal.trend === 'degrading' ? 'alert' : 'warning',
142
+ currentScore: temporal.staticScore,
143
+ projectedScore: temporal.projectedScore,
144
+ weeksToThreshold: this.config.forecastWeeks,
145
+ threshold: 2,
146
+ description: `Module '${module.modulePath}' has bus factor of ${module.busFactor} — all knowledge in one person`,
147
+ evidence: [
148
+ `Only ${module.busFactor} contributor(s)`,
149
+ `${module.aggregateCommits} total commits`,
150
+ `${module.files.length} files in module`,
151
+ ],
152
+ recommendation: 'Pair programming or code review rotation to spread knowledge. Document critical decisions.',
153
+ confidence: 0.8,
154
+ }];
155
+ }
156
+ detectComplexitySpiral(module, temporal) {
157
+ if (temporal.velocity.churnTrend <= 20)
158
+ return [];
159
+ if (temporal.velocity.direction !== 'accelerating')
160
+ return [];
161
+ // Accelerating churn + increasing commit rate = complexity spiral
162
+ const weeklyScoreDecay = (temporal.staticScore - temporal.projectedScore) / temporal.projectionWeeks;
163
+ const weeksToThreshold = weeklyScoreDecay > 0
164
+ ? Math.ceil((temporal.temporalScore - this.config.antiPatternThreshold) / weeklyScoreDecay)
165
+ : Infinity;
166
+ if (weeksToThreshold > this.config.forecastWeeks)
167
+ return [];
168
+ return [{
169
+ type: 'complexity-spiral',
170
+ module: module.modulePath,
171
+ severity: weeksToThreshold <= 8 ? 'alert' : 'warning',
172
+ currentScore: temporal.temporalScore,
173
+ projectedScore: temporal.projectedScore,
174
+ weeksToThreshold,
175
+ threshold: this.config.antiPatternThreshold,
176
+ description: `Module '${module.modulePath}' is in a complexity spiral — accelerating churn with increasing commit frequency`,
177
+ evidence: [
178
+ `Churn trend: +${Math.round(temporal.velocity.churnTrend)}%`,
179
+ `Commit acceleration: +${Math.round(temporal.velocity.commitAcceleration)}%`,
180
+ `Current temporal score: ${temporal.temporalScore}/100`,
181
+ `Projected score in ${temporal.projectionWeeks} weeks: ${temporal.projectedScore}/100`,
182
+ ],
183
+ recommendation: 'Stop adding features to this module. Invest in refactoring and test coverage first.',
184
+ confidence: temporal.projectionConfidence,
185
+ }];
186
+ }
187
+ detectCouplingMagnet(module, couplings, temporal) {
188
+ // Files that are increasingly coupled with many others
189
+ const inboundCouplings = couplings.filter(c => c.fileB.startsWith(module.modulePath) && c.confidence > 0.5);
190
+ if (inboundCouplings.length < 3)
191
+ return [];
192
+ if (temporal.velocity.commitAcceleration <= 0)
193
+ return [];
194
+ return [{
195
+ type: 'coupling-magnet',
196
+ module: module.modulePath,
197
+ severity: 'watch',
198
+ currentScore: temporal.staticScore,
199
+ projectedScore: temporal.projectedScore,
200
+ weeksToThreshold: 12,
201
+ threshold: 10,
202
+ description: `Module '${module.modulePath}' is becoming a coupling magnet — ${inboundCouplings.length} high-confidence inbound dependencies`,
203
+ evidence: [
204
+ `${inboundCouplings.length} modules depend on changes here`,
205
+ `Module commit rate accelerating: +${Math.round(temporal.velocity.commitAcceleration)}%`,
206
+ ],
207
+ recommendation: 'Extract stable interfaces. Consider the Dependency Inversion Principle to break inbound coupling.',
208
+ confidence: 0.6,
209
+ }];
210
+ }
211
+ // ── Module Forecast ──
212
+ forecastModule(module, temporal, patterns) {
213
+ const health = this.classifyHealth(temporal);
214
+ const forecast6m = this.classify6MonthForecast(temporal, patterns);
215
+ const bottleneckProb = this.calculateBottleneckProbability(temporal, patterns, module);
216
+ const riskFactors = [];
217
+ if (temporal.trend === 'degrading')
218
+ riskFactors.push('Score degrading');
219
+ if (module.busFactor <= 1)
220
+ riskFactors.push('Single contributor');
221
+ if (temporal.velocity.churnTrend > 30)
222
+ riskFactors.push('Churn increasing');
223
+ if (patterns.length > 0)
224
+ riskFactors.push(`${patterns.length} pre-anti-pattern(s)`);
225
+ const topAction = patterns.length > 0
226
+ ? patterns[0].recommendation
227
+ : temporal.trend === 'degrading'
228
+ ? 'Review recent changes and stabilize'
229
+ : 'No action needed';
230
+ return {
231
+ module: module.modulePath,
232
+ currentHealth: health,
233
+ forecast6Months: forecast6m,
234
+ preAntiPatterns: patterns,
235
+ bottleneckProbability: bottleneckProb,
236
+ riskFactors,
237
+ topAction,
238
+ };
239
+ }
240
+ classifyHealth(temporal) {
241
+ if (temporal.temporalScore < 30)
242
+ return 'critical';
243
+ if (temporal.temporalScore < 50 || temporal.trend === 'degrading')
244
+ return 'degrading';
245
+ if (temporal.temporalScore < 70)
246
+ return 'at-risk';
247
+ return 'healthy';
248
+ }
249
+ classify6MonthForecast(temporal, patterns) {
250
+ const alerts = patterns.filter(p => p.severity === 'alert');
251
+ if (alerts.length > 0 || temporal.projectedScore < 30)
252
+ return 'breakdown';
253
+ if (temporal.trend === 'degrading' || patterns.length > 0)
254
+ return 'declining';
255
+ return 'stable';
256
+ }
257
+ calculateBottleneckProbability(temporal, patterns, module) {
258
+ let prob = 0;
259
+ // Low score → higher probability
260
+ if (temporal.temporalScore < 50)
261
+ prob += 0.3;
262
+ else if (temporal.temporalScore < 70)
263
+ prob += 0.1;
264
+ // Degrading trend
265
+ if (temporal.trend === 'degrading')
266
+ prob += 0.2;
267
+ // Pre-anti-patterns
268
+ prob += Math.min(0.3, patterns.length * 0.1);
269
+ // Low bus factor
270
+ if (module.busFactor <= 1)
271
+ prob += 0.1;
272
+ // High churn
273
+ if (temporal.velocity.churnTrend > 30)
274
+ prob += 0.1;
275
+ return Math.min(1, Math.round(prob * 100) / 100);
276
+ }
277
+ // ── Overall Analysis ──
278
+ classifyOutlook(temporal, patterns) {
279
+ const alerts = patterns.filter(p => p.severity === 'alert');
280
+ if (alerts.length >= 2 || temporal.overallTrend === 'degrading')
281
+ return 'stormy';
282
+ if (alerts.length >= 1 || patterns.length >= 3)
283
+ return 'cloudy';
284
+ return 'sunny';
285
+ }
286
+ generateHeadline(outlook, patterns, modules) {
287
+ const critical = modules.filter(m => m.currentHealth === 'critical').length;
288
+ const degrading = modules.filter(m => m.currentHealth === 'degrading').length;
289
+ switch (outlook) {
290
+ case 'stormy':
291
+ return `${critical + degrading} module(s) at risk. ${patterns.length} pre-anti-pattern(s) detected. Immediate action recommended.`;
292
+ case 'cloudy':
293
+ return `Architecture trending stable with ${patterns.length} emerging concern(s). Proactive refactoring recommended.`;
294
+ case 'sunny':
295
+ return 'Architecture is healthy and stable. Continue current practices.';
296
+ }
297
+ }
298
+ identifyTopRisks(modules, patterns) {
299
+ const risks = [];
300
+ const breakdowns = modules.filter(m => m.forecast6Months === 'breakdown');
301
+ if (breakdowns.length > 0) {
302
+ risks.push(`${breakdowns.length} module(s) projected to break down within 6 months: ${breakdowns.map(m => m.module).join(', ')}`);
303
+ }
304
+ const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
305
+ if (busRisks.length > 0) {
306
+ risks.push(`Bus factor risk in ${busRisks.length} module(s) — knowledge concentrated in single contributors`);
307
+ }
308
+ const spirals = patterns.filter(p => p.type === 'complexity-spiral');
309
+ if (spirals.length > 0) {
310
+ risks.push(`Complexity spiral detected in: ${spirals.map(p => p.module).join(', ')}`);
311
+ }
312
+ return risks.slice(0, 5);
313
+ }
314
+ generateRecommendations(modules, patterns) {
315
+ const recs = [];
316
+ const critical = modules.filter(m => m.currentHealth === 'critical');
317
+ if (critical.length > 0) {
318
+ recs.push(`Immediate: Stabilize ${critical.map(m => m.module).join(', ')} — freeze features, invest in refactoring`);
319
+ }
320
+ const godClasses = patterns.filter(p => p.type === 'emerging-god-class');
321
+ if (godClasses.length > 0) {
322
+ recs.push(`Split growing files before they become god classes: ${godClasses.map(p => p.module).join(', ')}`);
323
+ }
324
+ const shotgun = patterns.filter(p => p.type === 'emerging-shotgun-surgery');
325
+ if (shotgun.length > 0) {
326
+ recs.push(`Decouple modules with high change coupling to prevent shotgun surgery`);
327
+ }
328
+ const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
329
+ if (busRisks.length > 0) {
330
+ recs.push(`Spread knowledge: pair programming or rotation for ${busRisks.map(p => p.module).join(', ')}`);
331
+ }
332
+ if (recs.length === 0) {
333
+ recs.push('Architecture is healthy. Continue monitoring temporal trends.');
334
+ }
335
+ return recs.slice(0, 5);
336
+ }
337
+ }
338
+ //# sourceMappingURL=forecast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forecast.js","sourceRoot":"","sources":["../../../../src/core/analyzers/forecast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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AC,IAAI,CAAC,uEAAuE,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC;QACpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,sDAAsD,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5G,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Architect v4.0 Analyzers — Temporal & Predictive
3
+ */
4
+ export { GitHistoryAnalyzer } from '../../infrastructure/git-history.js';
5
+ export type { GitCommit, FileChange, FileHistory, ModuleHistory, VelocityVector, ChangeCoupling, GitHistoryReport, WeeklySnapshot, GitAnalyzerConfig, } from '../../infrastructure/git-history.js';
6
+ export { TemporalScorer } from './temporal-scorer.js';
7
+ export type { Trend, TemporalScore, TemporalReport, TemporalScorerConfig, } from './temporal-scorer.js';
8
+ export { ForecastEngine } from './forecast.js';
9
+ export type { PreAntiPatternType, PreAntiPattern, ModuleForecast, WeatherForecast, ForecastConfig, } from './forecast.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Architect v4.0 Analyzers — Temporal & Predictive
3
+ */
4
+ export { GitHistoryAnalyzer } from '../../infrastructure/git-history.js';
5
+ export { TemporalScorer } from './temporal-scorer.js';
6
+ export { ForecastEngine } from './forecast.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/analyzers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAazE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Temporal Score Dimension — Adds time-series awareness to architecture scoring
3
+ *
4
+ * Combines current static score with historical velocity to produce:
5
+ * - Trend per module (improving / stable / degrading)
6
+ * - Temporal risk score (static score penalized by negative velocity)
7
+ * - Projected score in N weeks
8
+ *
9
+ * @author Camilo Girardelli — Girardelli Tecnologia
10
+ * @license MIT
11
+ */
12
+ import type { VelocityVector, GitHistoryReport } from '../../infrastructure/git-history.js';
13
+ export type Trend = 'improving' | 'stable' | 'degrading';
14
+ export interface TemporalScore {
15
+ /** Module or file path */
16
+ module: string;
17
+ /** Current static score (from ArchitectureScorer) */
18
+ staticScore: number;
19
+ /** Temporal-adjusted score (penalizes degrading trends) */
20
+ temporalScore: number;
21
+ /** Direction of change */
22
+ trend: Trend;
23
+ /** Projected score in projectionWeeks */
24
+ projectedScore: number;
25
+ /** Confidence in the projection (0-1) */
26
+ projectionConfidence: number;
27
+ /** Weeks used for projection */
28
+ projectionWeeks: number;
29
+ /** Risk level derived from temporal analysis */
30
+ riskLevel: 'low' | 'medium' | 'high' | 'critical';
31
+ /** Velocity data */
32
+ velocity: VelocityVector;
33
+ }
34
+ export interface TemporalReport {
35
+ projectPath: string;
36
+ analyzedAt: string;
37
+ overallTrend: Trend;
38
+ overallTemporalScore: number;
39
+ modules: TemporalScore[];
40
+ degradingModules: TemporalScore[];
41
+ improvingModules: TemporalScore[];
42
+ }
43
+ export interface TemporalScorerConfig {
44
+ /** Weeks ahead to project (default: 12) */
45
+ projectionWeeks?: number;
46
+ /** Weight of churn trend in temporal penalty (0-1, default: 0.6) */
47
+ churnWeight?: number;
48
+ /** Weight of commit acceleration in temporal penalty (0-1, default: 0.4) */
49
+ commitWeight?: number;
50
+ /** Threshold for trend classification: accelerating if > threshold % */
51
+ acceleratingThreshold?: number;
52
+ /** Threshold for trend classification: decelerating if < -threshold % */
53
+ deceleratingThreshold?: number;
54
+ }
55
+ export declare class TemporalScorer {
56
+ private config;
57
+ constructor(config?: TemporalScorerConfig);
58
+ /**
59
+ * Score modules temporally using git history + static scores.
60
+ *
61
+ * @param gitReport - Output from GitHistoryAnalyzer
62
+ * @param staticScores - Map of modulePath → static score (0-100)
63
+ */
64
+ score(gitReport: GitHistoryReport, staticScores: Map<string, number>): TemporalReport;
65
+ private scoreModule;
66
+ private classifyTrend;
67
+ private classifyRisk;
68
+ private classifyOverallTrend;
69
+ /** Infer a static score when none is provided (based on churn metrics) */
70
+ private inferStaticScore;
71
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Temporal Score Dimension — Adds time-series awareness to architecture scoring
3
+ *
4
+ * Combines current static score with historical velocity to produce:
5
+ * - Trend per module (improving / stable / degrading)
6
+ * - Temporal risk score (static score penalized by negative velocity)
7
+ * - Projected score in N weeks
8
+ *
9
+ * @author Camilo Girardelli — Girardelli Tecnologia
10
+ * @license MIT
11
+ */
12
+ const DEFAULT_CONFIG = {
13
+ projectionWeeks: 12,
14
+ churnWeight: 0.6,
15
+ commitWeight: 0.4,
16
+ acceleratingThreshold: 15,
17
+ deceleratingThreshold: -15,
18
+ };
19
+ // ═══════════════════════════════════════════════════════════════
20
+ // TEMPORAL SCORER
21
+ // ═══════════════════════════════════════════════════════════════
22
+ export class TemporalScorer {
23
+ config;
24
+ constructor(config) {
25
+ this.config = { ...DEFAULT_CONFIG, ...config };
26
+ }
27
+ /**
28
+ * Score modules temporally using git history + static scores.
29
+ *
30
+ * @param gitReport - Output from GitHistoryAnalyzer
31
+ * @param staticScores - Map of modulePath → static score (0-100)
32
+ */
33
+ score(gitReport, staticScores) {
34
+ const modules = [];
35
+ for (const moduleHistory of gitReport.modules) {
36
+ const staticScore = staticScores.get(moduleHistory.modulePath)
37
+ ?? this.inferStaticScore(moduleHistory);
38
+ const ts = this.scoreModule(moduleHistory, staticScore);
39
+ modules.push(ts);
40
+ }
41
+ // Sort by risk (worst first)
42
+ modules.sort((a, b) => a.temporalScore - b.temporalScore);
43
+ const degrading = modules.filter(m => m.trend === 'degrading');
44
+ const improving = modules.filter(m => m.trend === 'improving');
45
+ const overallTrend = this.classifyOverallTrend(modules);
46
+ const overallScore = modules.length > 0
47
+ ? Math.round(modules.reduce((s, m) => s + m.temporalScore, 0) / modules.length)
48
+ : 0;
49
+ return {
50
+ projectPath: gitReport.projectPath,
51
+ analyzedAt: new Date().toISOString(),
52
+ overallTrend: overallTrend,
53
+ overallTemporalScore: overallScore,
54
+ modules,
55
+ degradingModules: degrading,
56
+ improvingModules: improving,
57
+ };
58
+ }
59
+ scoreModule(module, staticScore) {
60
+ const velocity = module.velocityVector;
61
+ // Calculate temporal penalty based on velocity
62
+ const churnPenalty = velocity.churnTrend > 0
63
+ ? velocity.churnTrend * this.config.churnWeight * 0.3 // 30% impact per 100% churn increase
64
+ : velocity.churnTrend * this.config.churnWeight * 0.1; // 10% bonus per 100% churn decrease
65
+ const commitPenalty = velocity.commitAcceleration > 20
66
+ ? (velocity.commitAcceleration - 20) * this.config.commitWeight * 0.2 // penalty for excessive churn
67
+ : 0;
68
+ const totalPenalty = Math.max(-20, Math.min(30, churnPenalty + commitPenalty));
69
+ const temporalScore = Math.max(0, Math.min(100, Math.round(staticScore - totalPenalty)));
70
+ // Trend classification
71
+ const trend = this.classifyTrend(velocity);
72
+ // Linear projection
73
+ const weeklyDelta = totalPenalty / Math.max(this.config.projectionWeeks, 1);
74
+ const projectedScore = Math.max(0, Math.min(100, Math.round(temporalScore - (weeklyDelta * this.config.projectionWeeks))));
75
+ // Confidence decreases with projection distance and instability
76
+ const instability = Math.abs(velocity.churnTrend) + Math.abs(velocity.commitAcceleration);
77
+ const projectionConfidence = Math.max(0.1, Math.min(1, 1 - (instability / 200) - (this.config.projectionWeeks / 52)));
78
+ const riskLevel = this.classifyRisk(temporalScore, trend, module.busFactor);
79
+ return {
80
+ module: module.modulePath,
81
+ staticScore,
82
+ temporalScore,
83
+ trend,
84
+ projectedScore,
85
+ projectionConfidence: Math.round(projectionConfidence * 100) / 100,
86
+ projectionWeeks: this.config.projectionWeeks,
87
+ riskLevel,
88
+ velocity,
89
+ };
90
+ }
91
+ classifyTrend(velocity) {
92
+ // Degrading: churn increasing significantly or commit acceleration very high
93
+ if (velocity.churnTrend > 30 || velocity.commitAcceleration > 50) {
94
+ return 'degrading';
95
+ }
96
+ // Improving: churn decreasing and stable or decelerating
97
+ if (velocity.churnTrend < -10 && velocity.direction !== 'accelerating') {
98
+ return 'improving';
99
+ }
100
+ return 'stable';
101
+ }
102
+ classifyRisk(temporalScore, trend, busFactor) {
103
+ if (temporalScore < 30 || (temporalScore < 50 && trend === 'degrading')) {
104
+ return 'critical';
105
+ }
106
+ if (temporalScore < 50 || (trend === 'degrading' && busFactor <= 1)) {
107
+ return 'high';
108
+ }
109
+ if (temporalScore < 70 || trend === 'degrading') {
110
+ return 'medium';
111
+ }
112
+ return 'low';
113
+ }
114
+ classifyOverallTrend(modules) {
115
+ if (modules.length === 0)
116
+ return 'stable';
117
+ const degrading = modules.filter(m => m.trend === 'degrading').length;
118
+ const improving = modules.filter(m => m.trend === 'improving').length;
119
+ const degradingRatio = degrading / modules.length;
120
+ const improvingRatio = improving / modules.length;
121
+ if (degradingRatio > 0.3)
122
+ return 'degrading';
123
+ if (improvingRatio > 0.3)
124
+ return 'improving';
125
+ return 'stable';
126
+ }
127
+ /** Infer a static score when none is provided (based on churn metrics) */
128
+ inferStaticScore(module) {
129
+ const avgChurn = module.aggregateChurn / Math.max(module.aggregateCommits, 1);
130
+ if (avgChurn < 20)
131
+ return 85;
132
+ if (avgChurn < 50)
133
+ return 75;
134
+ if (avgChurn < 100)
135
+ return 65;
136
+ if (avgChurn < 200)
137
+ return 50;
138
+ return 35;
139
+ }
140
+ }
141
+ //# sourceMappingURL=temporal-scorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal-scorer.js","sourceRoot":"","sources":["../../../../src/core/analyzers/temporal-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0DH,MAAM,cAAc,GAAmC;IACrD,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,GAAG;IACjB,qBAAqB,EAAE,EAAE;IACzB,qBAAqB,EAAE,CAAC,EAAE;CAC3B,CAAC;AAEF,kEAAkE;AAClE,kBAAkB;AAClB,kEAAkE;AAElE,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiC;IAE/C,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CACH,SAA2B,EAC3B,YAAiC;QAEjC,MAAM,OAAO,GAAoB,EAAE,CAAC;QAEpC,KAAK,MAAM,aAAa,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YAC9C,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC;mBACzD,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;YAE1C,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;QAED,6BAA6B;QAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;QAE1D,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KA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QAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;QACtE,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;QAEtE,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;QAClD,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;QAElD,IAAI,cAAc,GAAG,GAAG;YAAE,OAAO,WAAW,CAAC;QAC7C,IAAI,cAAc,GAAG,GAAG;YAAE,OAAO,WAAW,CAAC;QAC7C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,0EAA0E;IAClE,gBAAgB,CAAC,MAAqB;QAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;QAC9E,IAAI,QAAQ,GAAG,EAAE;YAAE,OAAO,EAAE,CAAC;QAC7B,IAAI,QAAQ,GAAG,EAAE;YAAE,OAAO,EAAE,CAAC;QAC7B,IAAI,QAAQ,GAAG,GAAG;YAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,QAAQ,GAAG,GAAG;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import { AntiPattern, ArchitectConfig } from './types/core.js';
2
+ import { FileNode } from './types/infrastructure.js';
3
+ import type { CustomAntiPatternDetector } from './types/plugin.js';
4
+ export declare class AntiPatternDetector {
5
+ private config;
6
+ private dependencyGraph;
7
+ /** Paths that indicate third-party or build artifacts — never report anti-patterns here */
8
+ private static readonly EXCLUDED_PATH_SEGMENTS;
9
+ private customDetectors;
10
+ private pluginContext?;
11
+ constructor(config: ArchitectConfig);
12
+ setCustomDetectors(detectors: CustomAntiPatternDetector[]): void;
13
+ /**
14
+ * Check if a file path belongs to the project's own source code.
15
+ * Returns false for node_modules, dist, build artifacts, etc.
16
+ */
17
+ private isProjectFile;
18
+ detect(fileTree: FileNode, dependencies: Map<string, Set<string>>): Promise<AntiPattern[]>;
19
+ private detectGodClasses;
20
+ private detectCircularDependencies;
21
+ private findCycle;
22
+ private detectLeakyAbstractions;
23
+ private detectFeatureEnvy;
24
+ private detectShotgunSurgery;
25
+ private countMethods;
26
+ private countInternalExports;
27
+ private walkFileTree;
28
+ }