@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,227 @@
|
|
|
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
|
+
|
|
13
|
+
import type {
|
|
14
|
+
ModuleHistory,
|
|
15
|
+
VelocityVector,
|
|
16
|
+
GitHistoryReport,
|
|
17
|
+
} from './git-history.js';
|
|
18
|
+
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════
|
|
20
|
+
// TYPES
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════
|
|
22
|
+
|
|
23
|
+
export type Trend = 'improving' | 'stable' | 'degrading';
|
|
24
|
+
|
|
25
|
+
export interface TemporalScore {
|
|
26
|
+
/** Module or file path */
|
|
27
|
+
module: string;
|
|
28
|
+
/** Current static score (from ArchitectureScorer) */
|
|
29
|
+
staticScore: number;
|
|
30
|
+
/** Temporal-adjusted score (penalizes degrading trends) */
|
|
31
|
+
temporalScore: number;
|
|
32
|
+
/** Direction of change */
|
|
33
|
+
trend: Trend;
|
|
34
|
+
/** Projected score in projectionWeeks */
|
|
35
|
+
projectedScore: number;
|
|
36
|
+
/** Confidence in the projection (0-1) */
|
|
37
|
+
projectionConfidence: number;
|
|
38
|
+
/** Weeks used for projection */
|
|
39
|
+
projectionWeeks: number;
|
|
40
|
+
/** Risk level derived from temporal analysis */
|
|
41
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
42
|
+
/** Velocity data */
|
|
43
|
+
velocity: VelocityVector;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TemporalReport {
|
|
47
|
+
projectPath: string;
|
|
48
|
+
analyzedAt: string;
|
|
49
|
+
overallTrend: Trend;
|
|
50
|
+
overallTemporalScore: number;
|
|
51
|
+
modules: TemporalScore[];
|
|
52
|
+
degradingModules: TemporalScore[];
|
|
53
|
+
improvingModules: TemporalScore[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TemporalScorerConfig {
|
|
57
|
+
/** Weeks ahead to project (default: 12) */
|
|
58
|
+
projectionWeeks?: number;
|
|
59
|
+
/** Weight of churn trend in temporal penalty (0-1, default: 0.6) */
|
|
60
|
+
churnWeight?: number;
|
|
61
|
+
/** Weight of commit acceleration in temporal penalty (0-1, default: 0.4) */
|
|
62
|
+
commitWeight?: number;
|
|
63
|
+
/** Threshold for trend classification: accelerating if > threshold % */
|
|
64
|
+
acceleratingThreshold?: number;
|
|
65
|
+
/** Threshold for trend classification: decelerating if < -threshold % */
|
|
66
|
+
deceleratingThreshold?: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const DEFAULT_CONFIG: Required<TemporalScorerConfig> = {
|
|
70
|
+
projectionWeeks: 12,
|
|
71
|
+
churnWeight: 0.6,
|
|
72
|
+
commitWeight: 0.4,
|
|
73
|
+
acceleratingThreshold: 15,
|
|
74
|
+
deceleratingThreshold: -15,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// ═══════════════════════════════════════════════════════════════
|
|
78
|
+
// TEMPORAL SCORER
|
|
79
|
+
// ═══════════════════════════════════════════════════════════════
|
|
80
|
+
|
|
81
|
+
export class TemporalScorer {
|
|
82
|
+
private config: Required<TemporalScorerConfig>;
|
|
83
|
+
|
|
84
|
+
constructor(config?: TemporalScorerConfig) {
|
|
85
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Score modules temporally using git history + static scores.
|
|
90
|
+
*
|
|
91
|
+
* @param gitReport - Output from GitHistoryAnalyzer
|
|
92
|
+
* @param staticScores - Map of modulePath → static score (0-100)
|
|
93
|
+
*/
|
|
94
|
+
score(
|
|
95
|
+
gitReport: GitHistoryReport,
|
|
96
|
+
staticScores: Map<string, number>,
|
|
97
|
+
): TemporalReport {
|
|
98
|
+
const modules: TemporalScore[] = [];
|
|
99
|
+
|
|
100
|
+
for (const moduleHistory of gitReport.modules) {
|
|
101
|
+
const staticScore = staticScores.get(moduleHistory.modulePath)
|
|
102
|
+
?? this.inferStaticScore(moduleHistory);
|
|
103
|
+
|
|
104
|
+
const ts = this.scoreModule(moduleHistory, staticScore);
|
|
105
|
+
modules.push(ts);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Sort by risk (worst first)
|
|
109
|
+
modules.sort((a, b) => a.temporalScore - b.temporalScore);
|
|
110
|
+
|
|
111
|
+
const degrading = modules.filter(m => m.trend === 'degrading');
|
|
112
|
+
const improving = modules.filter(m => m.trend === 'improving');
|
|
113
|
+
|
|
114
|
+
const overallTrend = this.classifyOverallTrend(modules);
|
|
115
|
+
const overallScore = modules.length > 0
|
|
116
|
+
? Math.round(modules.reduce((s, m) => s + m.temporalScore, 0) / modules.length)
|
|
117
|
+
: 0;
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
projectPath: gitReport.projectPath,
|
|
121
|
+
analyzedAt: new Date().toISOString(),
|
|
122
|
+
overallTrend: overallTrend,
|
|
123
|
+
overallTemporalScore: overallScore,
|
|
124
|
+
modules,
|
|
125
|
+
degradingModules: degrading,
|
|
126
|
+
improvingModules: improving,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private scoreModule(module: ModuleHistory, staticScore: number): TemporalScore {
|
|
131
|
+
const velocity = module.velocityVector;
|
|
132
|
+
|
|
133
|
+
// Calculate temporal penalty based on velocity
|
|
134
|
+
const churnPenalty = velocity.churnTrend > 0
|
|
135
|
+
? velocity.churnTrend * this.config.churnWeight * 0.3 // 30% impact per 100% churn increase
|
|
136
|
+
: velocity.churnTrend * this.config.churnWeight * 0.1; // 10% bonus per 100% churn decrease
|
|
137
|
+
|
|
138
|
+
const commitPenalty = velocity.commitAcceleration > 20
|
|
139
|
+
? (velocity.commitAcceleration - 20) * this.config.commitWeight * 0.2 // penalty for excessive churn
|
|
140
|
+
: 0;
|
|
141
|
+
|
|
142
|
+
const totalPenalty = Math.max(-20, Math.min(30, churnPenalty + commitPenalty));
|
|
143
|
+
const temporalScore = Math.max(0, Math.min(100, Math.round(staticScore - totalPenalty)));
|
|
144
|
+
|
|
145
|
+
// Trend classification
|
|
146
|
+
const trend = this.classifyTrend(velocity);
|
|
147
|
+
|
|
148
|
+
// Linear projection
|
|
149
|
+
const weeklyDelta = totalPenalty / Math.max(this.config.projectionWeeks, 1);
|
|
150
|
+
const projectedScore = Math.max(0, Math.min(100,
|
|
151
|
+
Math.round(temporalScore - (weeklyDelta * this.config.projectionWeeks))
|
|
152
|
+
));
|
|
153
|
+
|
|
154
|
+
// Confidence decreases with projection distance and instability
|
|
155
|
+
const instability = Math.abs(velocity.churnTrend) + Math.abs(velocity.commitAcceleration);
|
|
156
|
+
const projectionConfidence = Math.max(0.1, Math.min(1,
|
|
157
|
+
1 - (instability / 200) - (this.config.projectionWeeks / 52)
|
|
158
|
+
));
|
|
159
|
+
|
|
160
|
+
const riskLevel = this.classifyRisk(temporalScore, trend, module.busFactor);
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
module: module.modulePath,
|
|
164
|
+
staticScore,
|
|
165
|
+
temporalScore,
|
|
166
|
+
trend,
|
|
167
|
+
projectedScore,
|
|
168
|
+
projectionConfidence: Math.round(projectionConfidence * 100) / 100,
|
|
169
|
+
projectionWeeks: this.config.projectionWeeks,
|
|
170
|
+
riskLevel,
|
|
171
|
+
velocity,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private classifyTrend(velocity: VelocityVector): Trend {
|
|
176
|
+
// Degrading: churn increasing significantly or commit acceleration very high
|
|
177
|
+
if (velocity.churnTrend > 30 || velocity.commitAcceleration > 50) {
|
|
178
|
+
return 'degrading';
|
|
179
|
+
}
|
|
180
|
+
// Improving: churn decreasing and stable or decelerating
|
|
181
|
+
if (velocity.churnTrend < -10 && velocity.direction !== 'accelerating') {
|
|
182
|
+
return 'improving';
|
|
183
|
+
}
|
|
184
|
+
return 'stable';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private classifyRisk(
|
|
188
|
+
temporalScore: number,
|
|
189
|
+
trend: Trend,
|
|
190
|
+
busFactor: number,
|
|
191
|
+
): TemporalScore['riskLevel'] {
|
|
192
|
+
if (temporalScore < 30 || (temporalScore < 50 && trend === 'degrading')) {
|
|
193
|
+
return 'critical';
|
|
194
|
+
}
|
|
195
|
+
if (temporalScore < 50 || (trend === 'degrading' && busFactor <= 1)) {
|
|
196
|
+
return 'high';
|
|
197
|
+
}
|
|
198
|
+
if (temporalScore < 70 || trend === 'degrading') {
|
|
199
|
+
return 'medium';
|
|
200
|
+
}
|
|
201
|
+
return 'low';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private classifyOverallTrend(modules: TemporalScore[]): Trend {
|
|
205
|
+
if (modules.length === 0) return 'stable';
|
|
206
|
+
|
|
207
|
+
const degrading = modules.filter(m => m.trend === 'degrading').length;
|
|
208
|
+
const improving = modules.filter(m => m.trend === 'improving').length;
|
|
209
|
+
|
|
210
|
+
const degradingRatio = degrading / modules.length;
|
|
211
|
+
const improvingRatio = improving / modules.length;
|
|
212
|
+
|
|
213
|
+
if (degradingRatio > 0.3) return 'degrading';
|
|
214
|
+
if (improvingRatio > 0.3) return 'improving';
|
|
215
|
+
return 'stable';
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Infer a static score when none is provided (based on churn metrics) */
|
|
219
|
+
private inferStaticScore(module: ModuleHistory): number {
|
|
220
|
+
const avgChurn = module.aggregateChurn / Math.max(module.aggregateCommits, 1);
|
|
221
|
+
if (avgChurn < 20) return 85;
|
|
222
|
+
if (avgChurn < 50) return 75;
|
|
223
|
+
if (avgChurn < 100) return 65;
|
|
224
|
+
if (avgChurn < 200) return 50;
|
|
225
|
+
return 35;
|
|
226
|
+
}
|
|
227
|
+
}
|