@girardelli/architect 2.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -116
- package/__test_agent_output__/INDEX.md +1 -0
- package/__test_agent_output__/agents/AGENT-ORCHESTRATOR.md +1 -0
- package/__test_agent_output__/agents/DATABASE-ENGINEER.md +174 -0
- package/__test_agent_output__/agents/QA-TEST-ENGINEER.md +138 -0
- package/__test_agent_output__/agents/SECURITY-AUDITOR.md +106 -0
- package/__test_agent_output__/agents/TECH-DEBT-CONTROLLER.md +104 -0
- package/__test_agent_output__/agents/TYPESCRIPT-BACKEND-DEVELOPER.md +135 -0
- package/__test_agent_output__/guards/CODE-REVIEW-CHECKLIST.md +95 -0
- package/__test_agent_output__/guards/PREFLIGHT.md +200 -0
- package/__test_agent_output__/guards/QUALITY-GATES.md +1 -0
- package/__test_agent_output__/rules/00-general.md +229 -0
- package/__test_agent_output__/rules/01-architecture.md +191 -0
- package/__test_agent_output__/rules/02-security.md +402 -0
- package/__test_agent_output__/rules/03-nestjs.md +124 -0
- package/__test_agent_output__/templates/ADR.md +95 -0
- package/__test_agent_output__/templates/BDD.md +58 -0
- package/__test_agent_output__/templates/C4.md +68 -0
- package/__test_agent_output__/templates/TDD.md +86 -0
- package/__test_agent_output__/templates/THREAT-MODEL.md +82 -0
- package/__test_agent_output__/workflows/fix-bug.md +228 -0
- package/__test_agent_output__/workflows/new-feature.md +311 -0
- package/__test_agent_output__/workflows/review.md +95 -0
- package/__test_context_7RvUrO/src/modules/empty/empty.ts +0 -0
- package/__test_context_Rf5fNJ/src/modules/mixed/mixed.ts +5 -0
- package/__test_context_WRCnYH/src/modules/test/test.ts +10 -0
- package/__test_context_YsnVS3/src/modules/test/test.ts +10 -0
- package/__test_context_w7XZeH/src/modules/mixed/mixed.ts +5 -0
- package/__test_context_y5noh6/src/modules/empty/empty.ts +0 -0
- package/__test_framework__24OjAu/package.json +1 -0
- package/__test_framework__3ZDZsx/pyproject.toml +8 -0
- package/__test_framework__4T54Jn/package.json +1 -0
- package/__test_framework__4tlXu9/pyproject.toml +8 -0
- package/__test_framework__6boWqQ/Pipfile +6 -0
- package/__test_framework__6gygMU/pom.xml +10 -0
- package/__test_framework__6kxj0N/go.mod +8 -0
- package/__test_framework__7CEoXw/pom.xml +10 -0
- package/__test_framework__85DDz0/Pipfile +6 -0
- package/__test_framework__9WrRIr/pom.xml +7 -0
- package/__test_framework__ANqGKl/Gemfile +5 -0
- package/__test_framework__BCXTEM/go.mod +3 -0
- package/__test_framework__BHiPNq/setup.py +2 -0
- package/__test_framework__BqkiKv/package.json +1 -0
- package/__test_framework__C5yd8X/Pipfile.lock +1 -0
- package/__test_framework__C5yd8X/requirements.txt +1 -0
- package/__test_framework__C87d3a/manage.py +1 -0
- package/__test_framework__C87d3a/requirements.txt +2 -0
- package/__test_framework__DXNwc5/build.gradle +7 -0
- package/__test_framework__GhHSt3/build.gradle.kts +4 -0
- package/__test_framework__GzklJP/Cargo.toml +7 -0
- package/__test_framework__H4hd13/go.mod +8 -0
- package/__test_framework__HKjOXO/composer.json +1 -0
- package/__test_framework__HaDN45/Gemfile +3 -0
- package/__test_framework__IBO7YG/pyproject.toml +9 -0
- package/__test_framework__JwSOyF/pyproject.toml +6 -0
- package/__test_framework__K6HrCr/build.gradle +2 -0
- package/__test_framework__KzRPlh/pubspec.yaml +9 -0
- package/__test_framework__L6uIym/pyproject.toml +6 -0
- package/__test_framework__LOdoGK/requirements.txt +4 -0
- package/__test_framework__LgHzss/package.json +1 -0
- package/__test_framework__M76M6q/Gemfile +5 -0
- package/__test_framework__Mr9vWW/composer.json +1 -0
- package/__test_framework__N03Gnv/package.json +1 -0
- package/__test_framework__Num4UE/requirements +1 -0
- package/__test_framework__OAGw3Y/build.gradle +7 -0
- package/__test_framework__OQc8yG/pubspec.yaml +9 -0
- package/__test_framework__OwKZcd/requirements.txt +3 -0
- package/__test_framework__P0gFv7/requirements +1 -0
- package/__test_framework__PN55Rq/package.json +1 -0
- package/__test_framework__PQiqX8/pubspec.yaml +3 -0
- package/__test_framework__RBHsg7/composer.json +1 -0
- package/__test_framework__RHxif4/Cargo.toml +7 -0
- package/__test_framework__T0v0p1/Cargo.toml +4 -0
- package/__test_framework__Tu0clt/Pipfile.lock +1 -0
- package/__test_framework__Tu0clt/requirements.txt +1 -0
- package/__test_framework__TwDj9P/Cargo.toml +4 -0
- package/__test_framework__VQJNC4/pom.xml +7 -0
- package/__test_framework__W6sm05/package.json +1 -0
- package/__test_framework__W7vBLy/pyproject.toml +4 -0
- package/__test_framework__WNJOWT/setup.py +2 -0
- package/__test_framework__WSJs7U/package.json +1 -0
- package/__test_framework__YQ5VpA/build.gradle.kts +4 -0
- package/__test_framework__ZNEUEs/package.json +1 -0
- package/__test_framework__Znt922/pom.xml +7 -0
- package/__test_framework__azyg0h/pom.xml +7 -0
- package/__test_framework__c6otLr/package.json +1 -0
- package/__test_framework__cl9S9G/build.gradle +2 -0
- package/__test_framework__eilvV4/composer.json +1 -0
- package/__test_framework__gQZxXO/manage.py +1 -0
- package/__test_framework__gQZxXO/requirements.txt +2 -0
- package/__test_framework__ghvl26/poetry.lock +1 -0
- package/__test_framework__ghvl26/pyproject.toml +2 -0
- package/__test_framework__hR7b9U/Makefile +11 -0
- package/__test_framework__iESVsi/composer.json +1 -0
- package/__test_framework__jm6TJy/package.json +1 -0
- package/__test_framework__kBUpjs/pyproject.toml +9 -0
- package/__test_framework__kqoZrw/requirements.txt +4 -0
- package/__test_framework__lWkoyO/pyproject.toml +4 -0
- package/__test_framework__mTKnUO/package.json +1 -0
- package/__test_framework__nCeZwe/Makefile +11 -0
- package/__test_framework__oljsU0/package.json +1 -0
- package/__test_framework__osRG4q/go.mod +3 -0
- package/__test_framework__pCHH4F/package.json +1 -0
- package/__test_framework__pExx6E/Gemfile +3 -0
- package/__test_framework__pyBoGd/pyproject.toml +5 -0
- package/__test_framework__qw16VQ/package.json +1 -0
- package/__test_framework__rRayrG/package.json +1 -0
- package/__test_framework__s82zO5/package.json +1 -0
- package/__test_framework__tp8MFK/pyproject.toml +5 -0
- package/__test_framework__w44k4w/composer.json +1 -0
- package/__test_framework__yefPZY/poetry.lock +1 -0
- package/__test_framework__yefPZY/pyproject.toml +2 -0
- package/__test_framework__zCiyDT/requirements.txt +3 -0
- package/__test_framework__zGZN3j/pubspec.yaml +3 -0
- package/__test_framework__zXpnxL/package.json +1 -0
- package/architect-run.sh +431 -0
- package/assets/banner-v3.html +561 -0
- package/dist/agent-generator/context-enricher.d.ts +58 -0
- package/dist/agent-generator/context-enricher.d.ts.map +1 -0
- package/dist/agent-generator/context-enricher.js +581 -0
- package/dist/agent-generator/context-enricher.js.map +1 -0
- package/dist/agent-generator/domain-inferrer.d.ts +52 -0
- package/dist/agent-generator/domain-inferrer.d.ts.map +1 -0
- package/dist/agent-generator/domain-inferrer.js +575 -0
- package/dist/agent-generator/domain-inferrer.js.map +1 -0
- package/dist/agent-generator/framework-detector.d.ts +40 -0
- package/dist/agent-generator/framework-detector.d.ts.map +1 -0
- package/dist/agent-generator/framework-detector.js +611 -0
- package/dist/agent-generator/framework-detector.js.map +1 -0
- package/dist/agent-generator/index.d.ts +33 -0
- package/dist/agent-generator/index.d.ts.map +1 -0
- package/dist/agent-generator/index.js +477 -0
- package/dist/agent-generator/index.js.map +1 -0
- package/dist/agent-generator/stack-detector.d.ts +12 -0
- package/dist/agent-generator/stack-detector.d.ts.map +1 -0
- package/dist/agent-generator/stack-detector.js +128 -0
- package/dist/agent-generator/stack-detector.js.map +1 -0
- package/dist/agent-generator/templates/core/agents.d.ts +17 -0
- package/dist/agent-generator/templates/core/agents.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/agents.js +1252 -0
- package/dist/agent-generator/templates/core/agents.js.map +1 -0
- package/dist/agent-generator/templates/core/architecture-rules.d.ts +7 -0
- package/dist/agent-generator/templates/core/architecture-rules.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/architecture-rules.js +274 -0
- package/dist/agent-generator/templates/core/architecture-rules.js.map +1 -0
- package/dist/agent-generator/templates/core/general-rules.d.ts +8 -0
- package/dist/agent-generator/templates/core/general-rules.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/general-rules.js +301 -0
- package/dist/agent-generator/templates/core/general-rules.js.map +1 -0
- package/dist/agent-generator/templates/core/index-md.d.ts +7 -0
- package/dist/agent-generator/templates/core/index-md.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/index-md.js +246 -0
- package/dist/agent-generator/templates/core/index-md.js.map +1 -0
- package/dist/agent-generator/templates/core/orchestrator.d.ts +8 -0
- package/dist/agent-generator/templates/core/orchestrator.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/orchestrator.js +422 -0
- package/dist/agent-generator/templates/core/orchestrator.js.map +1 -0
- package/dist/agent-generator/templates/core/preflight.d.ts +8 -0
- package/dist/agent-generator/templates/core/preflight.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/preflight.js +213 -0
- package/dist/agent-generator/templates/core/preflight.js.map +1 -0
- package/dist/agent-generator/templates/core/quality-gates.d.ts +11 -0
- package/dist/agent-generator/templates/core/quality-gates.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/quality-gates.js +254 -0
- package/dist/agent-generator/templates/core/quality-gates.js.map +1 -0
- package/dist/agent-generator/templates/core/security-rules.d.ts +7 -0
- package/dist/agent-generator/templates/core/security-rules.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/security-rules.js +528 -0
- package/dist/agent-generator/templates/core/security-rules.js.map +1 -0
- package/dist/agent-generator/templates/core/skills-generator.d.ts +6 -0
- package/dist/agent-generator/templates/core/skills-generator.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/skills-generator.js +207 -0
- package/dist/agent-generator/templates/core/skills-generator.js.map +1 -0
- package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts +7 -0
- package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/workflow-fix-bug.js +237 -0
- package/dist/agent-generator/templates/core/workflow-fix-bug.js.map +1 -0
- package/dist/agent-generator/templates/core/workflow-new-feature.d.ts +8 -0
- package/dist/agent-generator/templates/core/workflow-new-feature.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/workflow-new-feature.js +321 -0
- package/dist/agent-generator/templates/core/workflow-new-feature.js.map +1 -0
- package/dist/agent-generator/templates/core/workflow-review.d.ts +7 -0
- package/dist/agent-generator/templates/core/workflow-review.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/workflow-review.js +104 -0
- package/dist/agent-generator/templates/core/workflow-review.js.map +1 -0
- package/dist/agent-generator/templates/domain/index.d.ts +22 -0
- package/dist/agent-generator/templates/domain/index.d.ts.map +1 -0
- package/dist/agent-generator/templates/domain/index.js +1176 -0
- package/dist/agent-generator/templates/domain/index.js.map +1 -0
- package/dist/agent-generator/templates/stack/index.d.ts +8 -0
- package/dist/agent-generator/templates/stack/index.d.ts.map +1 -0
- package/dist/agent-generator/templates/stack/index.js +695 -0
- package/dist/agent-generator/templates/stack/index.js.map +1 -0
- package/dist/agent-generator/templates/template-helpers.d.ts +75 -0
- package/dist/agent-generator/templates/template-helpers.d.ts.map +1 -0
- package/dist/agent-generator/templates/template-helpers.js +726 -0
- package/dist/agent-generator/templates/template-helpers.js.map +1 -0
- package/dist/agent-generator/types.d.ts +196 -0
- package/dist/agent-generator/types.d.ts.map +1 -0
- package/dist/agent-generator/types.js +27 -0
- package/dist/agent-generator/types.js.map +1 -0
- package/dist/analyzer.d.ts +5 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +35 -4
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzers/forecast.d.ts +85 -0
- package/dist/analyzers/forecast.d.ts.map +1 -0
- package/dist/analyzers/forecast.js +337 -0
- package/dist/analyzers/forecast.js.map +1 -0
- package/dist/analyzers/git-cache.d.ts +7 -0
- package/dist/analyzers/git-cache.d.ts.map +1 -0
- package/dist/analyzers/git-cache.js +41 -0
- package/dist/analyzers/git-cache.js.map +1 -0
- package/dist/analyzers/git-history.d.ts +113 -0
- package/dist/analyzers/git-history.d.ts.map +1 -0
- package/dist/analyzers/git-history.js +333 -0
- package/dist/analyzers/git-history.js.map +1 -0
- package/dist/analyzers/index.d.ts +10 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +7 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/temporal-scorer.d.ts +72 -0
- package/dist/analyzers/temporal-scorer.d.ts.map +1 -0
- package/dist/analyzers/temporal-scorer.js +140 -0
- package/dist/analyzers/temporal-scorer.js.map +1 -0
- package/dist/cli.d.ts +2 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +275 -113
- package/dist/cli.js.map +1 -1
- package/dist/html-reporter.d.ts +3 -1
- package/dist/html-reporter.d.ts.map +1 -1
- package/dist/html-reporter.js +248 -12
- package/dist/html-reporter.js.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -4
- package/dist/index.js.map +1 -1
- package/dist/project-summarizer.d.ts +18 -0
- package/dist/project-summarizer.d.ts.map +1 -0
- package/dist/project-summarizer.js +306 -0
- package/dist/project-summarizer.js.map +1 -0
- package/dist/refactor-reporter.js +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -3
- package/src/agent-generator/context-enricher.ts +643 -0
- package/src/agent-generator/domain-inferrer.ts +625 -0
- package/src/agent-generator/framework-detector.ts +669 -0
- package/src/agent-generator/index.ts +555 -0
- package/src/agent-generator/stack-detector.ts +103 -0
- package/src/agent-generator/templates/core/agents.ts +1293 -0
- package/src/agent-generator/templates/core/architecture-rules.ts +287 -0
- package/src/agent-generator/templates/core/general-rules.ts +306 -0
- package/src/agent-generator/templates/core/index-md.ts +260 -0
- package/src/agent-generator/templates/core/orchestrator.ts +459 -0
- package/src/agent-generator/templates/core/preflight.ts +215 -0
- package/src/agent-generator/templates/core/quality-gates.ts +256 -0
- package/src/agent-generator/templates/core/security-rules.ts +543 -0
- package/src/agent-generator/templates/core/skills-generator.ts +236 -0
- package/src/agent-generator/templates/core/workflow-fix-bug.ts +239 -0
- package/src/agent-generator/templates/core/workflow-new-feature.ts +323 -0
- package/src/agent-generator/templates/core/workflow-review.ts +106 -0
- package/src/agent-generator/templates/domain/index.ts +1201 -0
- package/src/agent-generator/templates/stack/index.ts +705 -0
- package/src/agent-generator/templates/template-helpers.ts +776 -0
- package/src/agent-generator/types.ts +232 -0
- package/src/analyzer.ts +38 -4
- package/src/analyzers/forecast.ts +496 -0
- package/src/analyzers/git-cache.ts +52 -0
- package/src/analyzers/git-history.ts +488 -0
- package/src/analyzers/index.ts +33 -0
- package/src/analyzers/temporal-scorer.ts +227 -0
- package/src/cli.ts +316 -117
- package/src/html-reporter.ts +263 -13
- package/src/index.ts +92 -9
- package/src/project-summarizer.ts +347 -0
- package/src/refactor-reporter.ts +1 -1
- package/src/types.ts +10 -0
- package/tests/agent-generator.test.ts +411 -0
- package/tests/analyzers-integration.test.ts +174 -0
- package/tests/architect-adapter-enrichment.test.ts +9 -0
- package/tests/context-enricher.test.ts +971 -0
- package/tests/forecast.test.ts +509 -0
- package/tests/framework-detector.test.ts +1172 -0
- package/tests/git-history.test.ts +254 -0
- package/tests/scanner.test.ts +7 -8
- package/tests/scorer.test.ts +588 -0
- package/tests/stack-detector.test.ts +241 -0
- package/tests/template-generation.test.ts +706 -0
- package/tests/template-helpers.test.ts +1152 -0
- package/tests/temporal-scorer.test.ts +307 -0
- package/dist/agent-generator.d.ts +0 -106
- package/dist/agent-generator.d.ts.map +0 -1
- package/dist/agent-generator.js +0 -1398
- package/dist/agent-generator.js.map +0 -1
- package/src/agent-generator.ts +0 -1526
|
@@ -0,0 +1,337 @@
|
|
|
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
|
+
constructor(config) {
|
|
26
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate architecture weather forecast.
|
|
30
|
+
*/
|
|
31
|
+
forecast(gitReport, temporalReport) {
|
|
32
|
+
const preAntiPatterns = [];
|
|
33
|
+
const moduleForecastMap = new Map();
|
|
34
|
+
// Detect pre-anti-patterns for each module
|
|
35
|
+
for (const module of gitReport.modules) {
|
|
36
|
+
const temporal = temporalReport.modules.find(m => m.module === module.modulePath);
|
|
37
|
+
if (!temporal)
|
|
38
|
+
continue;
|
|
39
|
+
const patterns = this.detectPreAntiPatterns(module, temporal, gitReport.changeCouplings);
|
|
40
|
+
preAntiPatterns.push(...patterns);
|
|
41
|
+
const forecast = this.forecastModule(module, temporal, patterns);
|
|
42
|
+
moduleForecastMap.set(module.modulePath, forecast);
|
|
43
|
+
}
|
|
44
|
+
// Sort by risk
|
|
45
|
+
const modules = Array.from(moduleForecastMap.values())
|
|
46
|
+
.sort((a, b) => b.bottleneckProbability - a.bottleneckProbability);
|
|
47
|
+
const outlook = this.classifyOutlook(temporalReport, preAntiPatterns);
|
|
48
|
+
const headline = this.generateHeadline(outlook, preAntiPatterns, modules);
|
|
49
|
+
const topRisks = this.identifyTopRisks(modules, preAntiPatterns);
|
|
50
|
+
const recommendations = this.generateRecommendations(modules, preAntiPatterns);
|
|
51
|
+
return {
|
|
52
|
+
projectPath: gitReport.projectPath,
|
|
53
|
+
generatedAt: new Date().toISOString(),
|
|
54
|
+
overallOutlook: outlook,
|
|
55
|
+
headline,
|
|
56
|
+
modules,
|
|
57
|
+
preAntiPatterns: preAntiPatterns.sort((a, b) => a.weeksToThreshold - b.weeksToThreshold),
|
|
58
|
+
topRisks,
|
|
59
|
+
recommendations,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// ── Pre-Anti-Pattern Detection ──
|
|
63
|
+
detectPreAntiPatterns(module, temporal, couplings) {
|
|
64
|
+
const patterns = [];
|
|
65
|
+
patterns.push(...this.detectEmergingGodClass(module, temporal));
|
|
66
|
+
patterns.push(...this.detectEmergingShotgunSurgery(module, couplings));
|
|
67
|
+
patterns.push(...this.detectBusFactorRisk(module, temporal));
|
|
68
|
+
patterns.push(...this.detectComplexitySpiral(module, temporal));
|
|
69
|
+
patterns.push(...this.detectCouplingMagnet(module, couplings, temporal));
|
|
70
|
+
return patterns;
|
|
71
|
+
}
|
|
72
|
+
detectEmergingGodClass(module, temporal) {
|
|
73
|
+
const patterns = [];
|
|
74
|
+
for (const file of module.files) {
|
|
75
|
+
if (file.churnRate < this.config.godClassChurnThreshold)
|
|
76
|
+
continue;
|
|
77
|
+
if (temporal.velocity.churnTrend <= 0)
|
|
78
|
+
continue;
|
|
79
|
+
// Project when churn will exceed critical threshold
|
|
80
|
+
const weeklyGrowth = file.churnRate * (temporal.velocity.churnTrend / 100) / 4;
|
|
81
|
+
const criticalChurn = this.config.godClassChurnThreshold * 2;
|
|
82
|
+
const weeksToThreshold = weeklyGrowth > 0
|
|
83
|
+
? Math.ceil((criticalChurn - file.churnRate) / weeklyGrowth)
|
|
84
|
+
: Infinity;
|
|
85
|
+
if (weeksToThreshold <= this.config.forecastWeeks) {
|
|
86
|
+
patterns.push({
|
|
87
|
+
type: 'emerging-god-class',
|
|
88
|
+
module: module.modulePath,
|
|
89
|
+
severity: weeksToThreshold <= 8 ? 'alert' : weeksToThreshold <= 16 ? 'warning' : 'watch',
|
|
90
|
+
currentScore: temporal.staticScore,
|
|
91
|
+
projectedScore: temporal.projectedScore,
|
|
92
|
+
weeksToThreshold,
|
|
93
|
+
threshold: criticalChurn,
|
|
94
|
+
description: `File '${file.path}' has churn rate ${Math.round(file.churnRate)} lines/commit and growing ${Math.round(temporal.velocity.churnTrend)}%`,
|
|
95
|
+
evidence: [
|
|
96
|
+
`Current churn: ${Math.round(file.churnRate)} lines/commit`,
|
|
97
|
+
`Growth rate: ${Math.round(temporal.velocity.churnTrend)}%`,
|
|
98
|
+
`${file.commits} commits in analysis period`,
|
|
99
|
+
`${file.authors.size} contributor(s)`,
|
|
100
|
+
],
|
|
101
|
+
recommendation: 'Split into smaller, focused modules before complexity makes refactoring prohibitively expensive.',
|
|
102
|
+
confidence: Math.min(0.9, 0.5 + (file.commits / 50)),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return patterns;
|
|
107
|
+
}
|
|
108
|
+
detectEmergingShotgunSurgery(module, couplings) {
|
|
109
|
+
// Count how many files this module is coupled with
|
|
110
|
+
const moduleCouplings = couplings.filter(c => c.fileA.startsWith(module.modulePath) || c.fileB.startsWith(module.modulePath));
|
|
111
|
+
if (moduleCouplings.length < this.config.shotgunCouplingThreshold)
|
|
112
|
+
return [];
|
|
113
|
+
const avgConfidence = moduleCouplings.reduce((s, c) => s + c.confidence, 0) / moduleCouplings.length;
|
|
114
|
+
return [{
|
|
115
|
+
type: 'emerging-shotgun-surgery',
|
|
116
|
+
module: module.modulePath,
|
|
117
|
+
severity: moduleCouplings.length > 10 ? 'alert' : 'warning',
|
|
118
|
+
currentScore: 0,
|
|
119
|
+
projectedScore: 0,
|
|
120
|
+
weeksToThreshold: 4,
|
|
121
|
+
threshold: this.config.shotgunCouplingThreshold,
|
|
122
|
+
description: `Module '${module.modulePath}' has ${moduleCouplings.length} change-coupled files — changes here ripple across the codebase`,
|
|
123
|
+
evidence: [
|
|
124
|
+
`${moduleCouplings.length} files change together with this module`,
|
|
125
|
+
`Average coupling confidence: ${Math.round(avgConfidence * 100)}%`,
|
|
126
|
+
...moduleCouplings.slice(0, 3).map(c => `${c.fileA} ↔ ${c.fileB} (${c.cochangeCount} co-changes)`),
|
|
127
|
+
],
|
|
128
|
+
recommendation: 'Extract shared concerns into a dedicated module. Introduce interfaces to decouple.',
|
|
129
|
+
confidence: avgConfidence,
|
|
130
|
+
}];
|
|
131
|
+
}
|
|
132
|
+
detectBusFactorRisk(module, temporal) {
|
|
133
|
+
if (module.busFactor > this.config.busFatorRiskThreshold)
|
|
134
|
+
return [];
|
|
135
|
+
if (module.aggregateCommits < 5)
|
|
136
|
+
return []; // too few commits to judge
|
|
137
|
+
return [{
|
|
138
|
+
type: 'bus-factor-risk',
|
|
139
|
+
module: module.modulePath,
|
|
140
|
+
severity: temporal.trend === 'degrading' ? 'alert' : 'warning',
|
|
141
|
+
currentScore: temporal.staticScore,
|
|
142
|
+
projectedScore: temporal.projectedScore,
|
|
143
|
+
weeksToThreshold: this.config.forecastWeeks,
|
|
144
|
+
threshold: 2,
|
|
145
|
+
description: `Module '${module.modulePath}' has bus factor of ${module.busFactor} — all knowledge in one person`,
|
|
146
|
+
evidence: [
|
|
147
|
+
`Only ${module.busFactor} contributor(s)`,
|
|
148
|
+
`${module.aggregateCommits} total commits`,
|
|
149
|
+
`${module.files.length} files in module`,
|
|
150
|
+
],
|
|
151
|
+
recommendation: 'Pair programming or code review rotation to spread knowledge. Document critical decisions.',
|
|
152
|
+
confidence: 0.8,
|
|
153
|
+
}];
|
|
154
|
+
}
|
|
155
|
+
detectComplexitySpiral(module, temporal) {
|
|
156
|
+
if (temporal.velocity.churnTrend <= 20)
|
|
157
|
+
return [];
|
|
158
|
+
if (temporal.velocity.direction !== 'accelerating')
|
|
159
|
+
return [];
|
|
160
|
+
// Accelerating churn + increasing commit rate = complexity spiral
|
|
161
|
+
const weeklyScoreDecay = (temporal.staticScore - temporal.projectedScore) / temporal.projectionWeeks;
|
|
162
|
+
const weeksToThreshold = weeklyScoreDecay > 0
|
|
163
|
+
? Math.ceil((temporal.temporalScore - this.config.antiPatternThreshold) / weeklyScoreDecay)
|
|
164
|
+
: Infinity;
|
|
165
|
+
if (weeksToThreshold > this.config.forecastWeeks)
|
|
166
|
+
return [];
|
|
167
|
+
return [{
|
|
168
|
+
type: 'complexity-spiral',
|
|
169
|
+
module: module.modulePath,
|
|
170
|
+
severity: weeksToThreshold <= 8 ? 'alert' : 'warning',
|
|
171
|
+
currentScore: temporal.temporalScore,
|
|
172
|
+
projectedScore: temporal.projectedScore,
|
|
173
|
+
weeksToThreshold,
|
|
174
|
+
threshold: this.config.antiPatternThreshold,
|
|
175
|
+
description: `Module '${module.modulePath}' is in a complexity spiral — accelerating churn with increasing commit frequency`,
|
|
176
|
+
evidence: [
|
|
177
|
+
`Churn trend: +${Math.round(temporal.velocity.churnTrend)}%`,
|
|
178
|
+
`Commit acceleration: +${Math.round(temporal.velocity.commitAcceleration)}%`,
|
|
179
|
+
`Current temporal score: ${temporal.temporalScore}/100`,
|
|
180
|
+
`Projected score in ${temporal.projectionWeeks} weeks: ${temporal.projectedScore}/100`,
|
|
181
|
+
],
|
|
182
|
+
recommendation: 'Stop adding features to this module. Invest in refactoring and test coverage first.',
|
|
183
|
+
confidence: temporal.projectionConfidence,
|
|
184
|
+
}];
|
|
185
|
+
}
|
|
186
|
+
detectCouplingMagnet(module, couplings, temporal) {
|
|
187
|
+
// Files that are increasingly coupled with many others
|
|
188
|
+
const inboundCouplings = couplings.filter(c => c.fileB.startsWith(module.modulePath) && c.confidence > 0.5);
|
|
189
|
+
if (inboundCouplings.length < 3)
|
|
190
|
+
return [];
|
|
191
|
+
if (temporal.velocity.commitAcceleration <= 0)
|
|
192
|
+
return [];
|
|
193
|
+
return [{
|
|
194
|
+
type: 'coupling-magnet',
|
|
195
|
+
module: module.modulePath,
|
|
196
|
+
severity: 'watch',
|
|
197
|
+
currentScore: temporal.staticScore,
|
|
198
|
+
projectedScore: temporal.projectedScore,
|
|
199
|
+
weeksToThreshold: 12,
|
|
200
|
+
threshold: 10,
|
|
201
|
+
description: `Module '${module.modulePath}' is becoming a coupling magnet — ${inboundCouplings.length} high-confidence inbound dependencies`,
|
|
202
|
+
evidence: [
|
|
203
|
+
`${inboundCouplings.length} modules depend on changes here`,
|
|
204
|
+
`Module commit rate accelerating: +${Math.round(temporal.velocity.commitAcceleration)}%`,
|
|
205
|
+
],
|
|
206
|
+
recommendation: 'Extract stable interfaces. Consider the Dependency Inversion Principle to break inbound coupling.',
|
|
207
|
+
confidence: 0.6,
|
|
208
|
+
}];
|
|
209
|
+
}
|
|
210
|
+
// ── Module Forecast ──
|
|
211
|
+
forecastModule(module, temporal, patterns) {
|
|
212
|
+
const health = this.classifyHealth(temporal);
|
|
213
|
+
const forecast6m = this.classify6MonthForecast(temporal, patterns);
|
|
214
|
+
const bottleneckProb = this.calculateBottleneckProbability(temporal, patterns, module);
|
|
215
|
+
const riskFactors = [];
|
|
216
|
+
if (temporal.trend === 'degrading')
|
|
217
|
+
riskFactors.push('Score degrading');
|
|
218
|
+
if (module.busFactor <= 1)
|
|
219
|
+
riskFactors.push('Single contributor');
|
|
220
|
+
if (temporal.velocity.churnTrend > 30)
|
|
221
|
+
riskFactors.push('Churn increasing');
|
|
222
|
+
if (patterns.length > 0)
|
|
223
|
+
riskFactors.push(`${patterns.length} pre-anti-pattern(s)`);
|
|
224
|
+
const topAction = patterns.length > 0
|
|
225
|
+
? patterns[0].recommendation
|
|
226
|
+
: temporal.trend === 'degrading'
|
|
227
|
+
? 'Review recent changes and stabilize'
|
|
228
|
+
: 'No action needed';
|
|
229
|
+
return {
|
|
230
|
+
module: module.modulePath,
|
|
231
|
+
currentHealth: health,
|
|
232
|
+
forecast6Months: forecast6m,
|
|
233
|
+
preAntiPatterns: patterns,
|
|
234
|
+
bottleneckProbability: bottleneckProb,
|
|
235
|
+
riskFactors,
|
|
236
|
+
topAction,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
classifyHealth(temporal) {
|
|
240
|
+
if (temporal.temporalScore < 30)
|
|
241
|
+
return 'critical';
|
|
242
|
+
if (temporal.temporalScore < 50 || temporal.trend === 'degrading')
|
|
243
|
+
return 'degrading';
|
|
244
|
+
if (temporal.temporalScore < 70)
|
|
245
|
+
return 'at-risk';
|
|
246
|
+
return 'healthy';
|
|
247
|
+
}
|
|
248
|
+
classify6MonthForecast(temporal, patterns) {
|
|
249
|
+
const alerts = patterns.filter(p => p.severity === 'alert');
|
|
250
|
+
if (alerts.length > 0 || temporal.projectedScore < 30)
|
|
251
|
+
return 'breakdown';
|
|
252
|
+
if (temporal.trend === 'degrading' || patterns.length > 0)
|
|
253
|
+
return 'declining';
|
|
254
|
+
return 'stable';
|
|
255
|
+
}
|
|
256
|
+
calculateBottleneckProbability(temporal, patterns, module) {
|
|
257
|
+
let prob = 0;
|
|
258
|
+
// Low score → higher probability
|
|
259
|
+
if (temporal.temporalScore < 50)
|
|
260
|
+
prob += 0.3;
|
|
261
|
+
else if (temporal.temporalScore < 70)
|
|
262
|
+
prob += 0.1;
|
|
263
|
+
// Degrading trend
|
|
264
|
+
if (temporal.trend === 'degrading')
|
|
265
|
+
prob += 0.2;
|
|
266
|
+
// Pre-anti-patterns
|
|
267
|
+
prob += Math.min(0.3, patterns.length * 0.1);
|
|
268
|
+
// Low bus factor
|
|
269
|
+
if (module.busFactor <= 1)
|
|
270
|
+
prob += 0.1;
|
|
271
|
+
// High churn
|
|
272
|
+
if (temporal.velocity.churnTrend > 30)
|
|
273
|
+
prob += 0.1;
|
|
274
|
+
return Math.min(1, Math.round(prob * 100) / 100);
|
|
275
|
+
}
|
|
276
|
+
// ── Overall Analysis ──
|
|
277
|
+
classifyOutlook(temporal, patterns) {
|
|
278
|
+
const alerts = patterns.filter(p => p.severity === 'alert');
|
|
279
|
+
if (alerts.length >= 2 || temporal.overallTrend === 'degrading')
|
|
280
|
+
return 'stormy';
|
|
281
|
+
if (alerts.length >= 1 || patterns.length >= 3)
|
|
282
|
+
return 'cloudy';
|
|
283
|
+
return 'sunny';
|
|
284
|
+
}
|
|
285
|
+
generateHeadline(outlook, patterns, modules) {
|
|
286
|
+
const critical = modules.filter(m => m.currentHealth === 'critical').length;
|
|
287
|
+
const degrading = modules.filter(m => m.currentHealth === 'degrading').length;
|
|
288
|
+
switch (outlook) {
|
|
289
|
+
case 'stormy':
|
|
290
|
+
return `${critical + degrading} module(s) at risk. ${patterns.length} pre-anti-pattern(s) detected. Immediate action recommended.`;
|
|
291
|
+
case 'cloudy':
|
|
292
|
+
return `Architecture trending stable with ${patterns.length} emerging concern(s). Proactive refactoring recommended.`;
|
|
293
|
+
case 'sunny':
|
|
294
|
+
return 'Architecture is healthy and stable. Continue current practices.';
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
identifyTopRisks(modules, patterns) {
|
|
298
|
+
const risks = [];
|
|
299
|
+
const breakdowns = modules.filter(m => m.forecast6Months === 'breakdown');
|
|
300
|
+
if (breakdowns.length > 0) {
|
|
301
|
+
risks.push(`${breakdowns.length} module(s) projected to break down within 6 months: ${breakdowns.map(m => m.module).join(', ')}`);
|
|
302
|
+
}
|
|
303
|
+
const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
|
|
304
|
+
if (busRisks.length > 0) {
|
|
305
|
+
risks.push(`Bus factor risk in ${busRisks.length} module(s) — knowledge concentrated in single contributors`);
|
|
306
|
+
}
|
|
307
|
+
const spirals = patterns.filter(p => p.type === 'complexity-spiral');
|
|
308
|
+
if (spirals.length > 0) {
|
|
309
|
+
risks.push(`Complexity spiral detected in: ${spirals.map(p => p.module).join(', ')}`);
|
|
310
|
+
}
|
|
311
|
+
return risks.slice(0, 5);
|
|
312
|
+
}
|
|
313
|
+
generateRecommendations(modules, patterns) {
|
|
314
|
+
const recs = [];
|
|
315
|
+
const critical = modules.filter(m => m.currentHealth === 'critical');
|
|
316
|
+
if (critical.length > 0) {
|
|
317
|
+
recs.push(`Immediate: Stabilize ${critical.map(m => m.module).join(', ')} — freeze features, invest in refactoring`);
|
|
318
|
+
}
|
|
319
|
+
const godClasses = patterns.filter(p => p.type === 'emerging-god-class');
|
|
320
|
+
if (godClasses.length > 0) {
|
|
321
|
+
recs.push(`Split growing files before they become god classes: ${godClasses.map(p => p.module).join(', ')}`);
|
|
322
|
+
}
|
|
323
|
+
const shotgun = patterns.filter(p => p.type === 'emerging-shotgun-surgery');
|
|
324
|
+
if (shotgun.length > 0) {
|
|
325
|
+
recs.push(`Decouple modules with high change coupling to prevent shotgun surgery`);
|
|
326
|
+
}
|
|
327
|
+
const busRisks = patterns.filter(p => p.type === 'bus-factor-risk');
|
|
328
|
+
if (busRisks.length > 0) {
|
|
329
|
+
recs.push(`Spread knowledge: pair programming or rotation for ${busRisks.map(p => p.module).join(', ')}`);
|
|
330
|
+
}
|
|
331
|
+
if (recs.length === 0) {
|
|
332
|
+
recs.push('Architecture is healthy. Continue monitoring temporal trends.');
|
|
333
|
+
}
|
|
334
|
+
return recs.slice(0, 5);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=forecast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forecast.js","sourceRoot":"","sources":["../../src/analyzers/forecast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwEH,MAAM,cAAc,GAA6B;IAC/C,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,GAAG;IAC3B,wBAAwB,EAAE,CAAC;IAC3B,qBAAqB,EAAE,CAAC;IACxB,aAAa,EAAE,EAAE;CAClB,CA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AC,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,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git History Cache — Serialize/deserialize GitHistoryReport
|
|
3
|
+
*/
|
|
4
|
+
import type { GitHistoryReport } from './git-history.js';
|
|
5
|
+
export declare function saveToCache(report: GitHistoryReport, projectPath: string, cacheDir?: string): void;
|
|
6
|
+
export declare function loadFromCache(projectPath: string, cacheDir?: string, maxAgeMs?: number): GitHistoryReport | null;
|
|
7
|
+
//# sourceMappingURL=git-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cache.d.ts","sourceRoot":"","sources":["../../src/analyzers/git-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,WAAW,CACzB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAqB,GAC5B,IAAI,CAsBN;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAqB,EAC7B,QAAQ,SAAU,GACjB,gBAAgB,GAAG,IAAI,CAWzB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git History Cache — Serialize/deserialize GitHistoryReport
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
export function saveToCache(report, projectPath, cacheDir = '.architect-cache') {
|
|
7
|
+
const dir = path.join(projectPath, cacheDir);
|
|
8
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
9
|
+
const serializable = {
|
|
10
|
+
...report,
|
|
11
|
+
modules: report.modules.map(m => ({
|
|
12
|
+
...m,
|
|
13
|
+
files: m.files.map(f => ({
|
|
14
|
+
...f,
|
|
15
|
+
authors: Array.from(f.authors),
|
|
16
|
+
lastModified: f.lastModified.toISOString(),
|
|
17
|
+
})),
|
|
18
|
+
})),
|
|
19
|
+
hotspots: report.hotspots.map(f => ({
|
|
20
|
+
...f,
|
|
21
|
+
authors: Array.from(f.authors),
|
|
22
|
+
lastModified: f.lastModified.toISOString(),
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
fs.writeFileSync(path.join(dir, 'git-history.json'), JSON.stringify(serializable, null, 2));
|
|
26
|
+
}
|
|
27
|
+
export function loadFromCache(projectPath, cacheDir = '.architect-cache', maxAgeMs = 3600000) {
|
|
28
|
+
const cachePath = path.join(projectPath, cacheDir, 'git-history.json');
|
|
29
|
+
if (!fs.existsSync(cachePath))
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
const raw = JSON.parse(fs.readFileSync(cachePath, 'utf-8'));
|
|
33
|
+
if (Date.now() - new Date(raw.analyzedAt).getTime() > maxAgeMs)
|
|
34
|
+
return null;
|
|
35
|
+
return raw;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=git-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cache.js","sourceRoot":"","sources":["../../src/analyzers/git-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OA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IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACvE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QAC5D,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC5E,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git History Analyzer — Temporal analysis of codebase evolution
|
|
3
|
+
*
|
|
4
|
+
* Reads git log to build velocity vectors, churn rates, and hotspot maps.
|
|
5
|
+
* Enables Architect v4's predictive capabilities.
|
|
6
|
+
*
|
|
7
|
+
* Key metrics per module:
|
|
8
|
+
* - Commit frequency (commits/week rolling 4-week average)
|
|
9
|
+
* - Churn rate (lines added + deleted per commit)
|
|
10
|
+
* - Author diversity (bus factor proxy)
|
|
11
|
+
* - Change coupling (files that change together)
|
|
12
|
+
*
|
|
13
|
+
* @author Camilo Girardelli — Girardelli Tecnologia
|
|
14
|
+
* @license MIT
|
|
15
|
+
*/
|
|
16
|
+
export interface GitCommit {
|
|
17
|
+
hash: string;
|
|
18
|
+
author: string;
|
|
19
|
+
date: Date;
|
|
20
|
+
message: string;
|
|
21
|
+
files: FileChange[];
|
|
22
|
+
}
|
|
23
|
+
export interface FileChange {
|
|
24
|
+
path: string;
|
|
25
|
+
additions: number;
|
|
26
|
+
deletions: number;
|
|
27
|
+
}
|
|
28
|
+
export interface FileHistory {
|
|
29
|
+
path: string;
|
|
30
|
+
commits: number;
|
|
31
|
+
totalAdditions: number;
|
|
32
|
+
totalDeletions: number;
|
|
33
|
+
churnRate: number;
|
|
34
|
+
authors: Set<string>;
|
|
35
|
+
busFactor: number;
|
|
36
|
+
lastModified: Date;
|
|
37
|
+
weeklyCommitRate: number;
|
|
38
|
+
isHotspot: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ModuleHistory {
|
|
41
|
+
modulePath: string;
|
|
42
|
+
files: FileHistory[];
|
|
43
|
+
aggregateCommits: number;
|
|
44
|
+
aggregateChurn: number;
|
|
45
|
+
avgWeeklyRate: number;
|
|
46
|
+
topHotspots: FileHistory[];
|
|
47
|
+
velocityVector: VelocityVector;
|
|
48
|
+
busFactor: number;
|
|
49
|
+
}
|
|
50
|
+
export interface VelocityVector {
|
|
51
|
+
/** Commit rate trend: positive = accelerating, negative = decelerating */
|
|
52
|
+
commitAcceleration: number;
|
|
53
|
+
/** Churn trend: positive = increasing complexity, negative = stabilizing */
|
|
54
|
+
churnTrend: number;
|
|
55
|
+
/** Overall direction: "accelerating" | "stable" | "decelerating" */
|
|
56
|
+
direction: 'accelerating' | 'stable' | 'decelerating';
|
|
57
|
+
}
|
|
58
|
+
export interface ChangeCoupling {
|
|
59
|
+
fileA: string;
|
|
60
|
+
fileB: string;
|
|
61
|
+
cochangeCount: number;
|
|
62
|
+
confidence: number;
|
|
63
|
+
}
|
|
64
|
+
export interface GitHistoryReport {
|
|
65
|
+
projectPath: string;
|
|
66
|
+
analyzedAt: string;
|
|
67
|
+
periodWeeks: number;
|
|
68
|
+
totalCommits: number;
|
|
69
|
+
totalAuthors: number;
|
|
70
|
+
modules: ModuleHistory[];
|
|
71
|
+
hotspots: FileHistory[];
|
|
72
|
+
changeCouplings: ChangeCoupling[];
|
|
73
|
+
commitTimeline: WeeklySnapshot[];
|
|
74
|
+
}
|
|
75
|
+
export interface WeeklySnapshot {
|
|
76
|
+
weekStart: string;
|
|
77
|
+
commits: number;
|
|
78
|
+
churn: number;
|
|
79
|
+
activeFiles: number;
|
|
80
|
+
}
|
|
81
|
+
export interface GitAnalyzerConfig {
|
|
82
|
+
/** How many weeks of history to analyze (default: 24) */
|
|
83
|
+
periodWeeks?: number;
|
|
84
|
+
/** Rolling window for averages (default: 4 weeks) */
|
|
85
|
+
rollingWindowWeeks?: number;
|
|
86
|
+
/** Churn threshold to flag as hotspot (default: 500 lines) */
|
|
87
|
+
hotspotChurnThreshold?: number;
|
|
88
|
+
/** Minimum co-change count for coupling (default: 3) */
|
|
89
|
+
couplingMinCochanges?: number;
|
|
90
|
+
/** Path to cache dir (default: .architect-cache/) */
|
|
91
|
+
cacheDir?: string;
|
|
92
|
+
}
|
|
93
|
+
export declare class GitHistoryAnalyzer {
|
|
94
|
+
private config;
|
|
95
|
+
constructor(config?: GitAnalyzerConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Analyze git history for the project at the given path.
|
|
98
|
+
* Returns a comprehensive GitHistoryReport.
|
|
99
|
+
*/
|
|
100
|
+
analyze(projectPath: string): GitHistoryReport;
|
|
101
|
+
private parseGitLog;
|
|
102
|
+
private parseLogOutput;
|
|
103
|
+
private buildFileHistories;
|
|
104
|
+
private groupByModule;
|
|
105
|
+
private calculateVelocity;
|
|
106
|
+
private detectHotspots;
|
|
107
|
+
private detectChangeCoupling;
|
|
108
|
+
private buildTimeline;
|
|
109
|
+
private validateGitRepo;
|
|
110
|
+
private getSinceDate;
|
|
111
|
+
private getModulePath;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=git-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-history.d.ts","sourceRoot":"","sources":["../../src/analyzers/git-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,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