@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,411 @@
|
|
|
1
|
+
import { AgentGenerator } from '../src/agent-generator/index.js';
|
|
2
|
+
import { AnalysisReport, RefactoringPlan } from '../src/types.js';
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
// ── Test Data Factories ──
|
|
7
|
+
|
|
8
|
+
function makeReport(overrides: Partial<AnalysisReport> = {}): AnalysisReport {
|
|
9
|
+
return {
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
projectInfo: {
|
|
12
|
+
path: '/test',
|
|
13
|
+
name: 'test-project',
|
|
14
|
+
frameworks: ['NestJS'],
|
|
15
|
+
totalFiles: 50,
|
|
16
|
+
totalLines: 5000,
|
|
17
|
+
primaryLanguages: ['TypeScript'],
|
|
18
|
+
},
|
|
19
|
+
score: {
|
|
20
|
+
overall: 72,
|
|
21
|
+
components: [],
|
|
22
|
+
breakdown: { modularity: 80, coupling: 65, cohesion: 70, layering: 75 },
|
|
23
|
+
},
|
|
24
|
+
antiPatterns: [
|
|
25
|
+
{
|
|
26
|
+
name: 'God Class',
|
|
27
|
+
severity: 'CRITICAL',
|
|
28
|
+
location: 'src/AppService.ts',
|
|
29
|
+
description: 'Class with 800 lines',
|
|
30
|
+
suggestion: 'Split into smaller services',
|
|
31
|
+
affectedFiles: ['src/AppService.ts'],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
layers: [
|
|
35
|
+
{ name: 'API', files: ['src/controller.ts'], description: 'API layer' },
|
|
36
|
+
{ name: 'Service', files: ['src/service.ts'], description: 'Service layer' },
|
|
37
|
+
],
|
|
38
|
+
dependencyGraph: {
|
|
39
|
+
nodes: ['src/app.module.ts', 'src/app.controller.ts', 'src/app.service.ts', 'src/entity/user.entity.ts'],
|
|
40
|
+
edges: [
|
|
41
|
+
{ from: 'src/app.controller.ts', to: 'src/app.service.ts', type: 'import', weight: 1 },
|
|
42
|
+
{ from: 'src/app.service.ts', to: 'src/entity/user.entity.ts', type: 'import', weight: 1 },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
suggestions: [],
|
|
46
|
+
diagram: { mermaid: '', type: 'layer' },
|
|
47
|
+
...overrides,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function makePlan(overrides: Partial<RefactoringPlan> = {}): RefactoringPlan {
|
|
52
|
+
return {
|
|
53
|
+
timestamp: new Date().toISOString(),
|
|
54
|
+
projectPath: '/test',
|
|
55
|
+
currentScore: {
|
|
56
|
+
overall: 72,
|
|
57
|
+
components: [],
|
|
58
|
+
breakdown: { modularity: 80, coupling: 65, cohesion: 70, layering: 75 },
|
|
59
|
+
},
|
|
60
|
+
estimatedScoreAfter: { overall: 82, breakdown: { modularity: 85, coupling: 75, cohesion: 80, layering: 80 } },
|
|
61
|
+
steps: [
|
|
62
|
+
{
|
|
63
|
+
id: 1,
|
|
64
|
+
tier: 1,
|
|
65
|
+
rule: 'hub-splitter',
|
|
66
|
+
priority: 'HIGH',
|
|
67
|
+
title: 'Split AppService',
|
|
68
|
+
description: 'Split monolith service',
|
|
69
|
+
rationale: 'Reduce coupling',
|
|
70
|
+
operations: [],
|
|
71
|
+
scoreImpact: [{ metric: 'modularity', before: 80, after: 85 }],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
totalOperations: 1,
|
|
75
|
+
tier1Steps: 1,
|
|
76
|
+
tier2Steps: 0,
|
|
77
|
+
...overrides,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ── Test Suite ──
|
|
82
|
+
|
|
83
|
+
describe('AgentGenerator', () => {
|
|
84
|
+
const generator = new AgentGenerator();
|
|
85
|
+
const testOutputDir = join(process.cwd(), '__test_agent_output__');
|
|
86
|
+
|
|
87
|
+
afterEach(() => {
|
|
88
|
+
// Clean up generated test directories
|
|
89
|
+
if (existsSync(testOutputDir)) {
|
|
90
|
+
rmSync(testOutputDir, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('suggest()', () => {
|
|
95
|
+
it('should return a valid AgentSuggestion', () => {
|
|
96
|
+
const report = makeReport();
|
|
97
|
+
const plan = makePlan();
|
|
98
|
+
|
|
99
|
+
const result = generator.suggest(report, plan, '/test');
|
|
100
|
+
|
|
101
|
+
expect(result).toBeDefined();
|
|
102
|
+
expect(result.stack).toBeDefined();
|
|
103
|
+
expect(result.suggestedAgents).toBeDefined();
|
|
104
|
+
expect(result.suggestedRules).toBeDefined();
|
|
105
|
+
expect(result.suggestedGuards).toBeDefined();
|
|
106
|
+
expect(result.suggestedWorkflows).toBeDefined();
|
|
107
|
+
expect(result.suggestedSkills).toBeDefined();
|
|
108
|
+
expect(result.command).toBeDefined();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should detect TypeScript + NestJS stack', () => {
|
|
112
|
+
const report = makeReport();
|
|
113
|
+
const plan = makePlan();
|
|
114
|
+
|
|
115
|
+
const result = generator.suggest(report, plan, '/test');
|
|
116
|
+
|
|
117
|
+
expect(result.stack.primary).toBe('TypeScript');
|
|
118
|
+
expect(result.stack.frameworks).toContain('NestJS');
|
|
119
|
+
expect(result.stack.hasBackend).toBe(true);
|
|
120
|
+
expect(result.stack.hasDatabase).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should suggest backend agent for backend stack', () => {
|
|
124
|
+
const report = makeReport();
|
|
125
|
+
const plan = makePlan();
|
|
126
|
+
|
|
127
|
+
const result = generator.suggest(report, plan, '/test');
|
|
128
|
+
|
|
129
|
+
const backendAgent = result.suggestedAgents.find(a => a.name.includes('BACKEND'));
|
|
130
|
+
expect(backendAgent).toBeDefined();
|
|
131
|
+
expect(backendAgent!.status).toBe('CREATE');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should suggest database agent when database detected', () => {
|
|
135
|
+
const report = makeReport();
|
|
136
|
+
const plan = makePlan();
|
|
137
|
+
|
|
138
|
+
const result = generator.suggest(report, plan, '/test');
|
|
139
|
+
|
|
140
|
+
const dbAgent = result.suggestedAgents.find(a => a.name.includes('DATABASE'));
|
|
141
|
+
expect(dbAgent).toBeDefined();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should always suggest orchestrator, security, QA, and tech debt agents', () => {
|
|
145
|
+
const report = makeReport();
|
|
146
|
+
const plan = makePlan();
|
|
147
|
+
|
|
148
|
+
const result = generator.suggest(report, plan, '/test');
|
|
149
|
+
const names = result.suggestedAgents.map(a => a.name);
|
|
150
|
+
|
|
151
|
+
expect(names).toContain('AGENT-ORCHESTRATOR');
|
|
152
|
+
expect(names.some(n => n.includes('SECURITY'))).toBe(true);
|
|
153
|
+
expect(names.some(n => n.includes('QA'))).toBe(true);
|
|
154
|
+
expect(names.some(n => n.includes('TECH-DEBT'))).toBe(true);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should suggest 3+ rules including architecture and security', () => {
|
|
158
|
+
const report = makeReport();
|
|
159
|
+
const plan = makePlan();
|
|
160
|
+
|
|
161
|
+
const result = generator.suggest(report, plan, '/test');
|
|
162
|
+
const ruleNames = result.suggestedRules.map(r => r.name);
|
|
163
|
+
|
|
164
|
+
expect(ruleNames).toContain('00-general');
|
|
165
|
+
expect(ruleNames).toContain('01-architecture');
|
|
166
|
+
expect(ruleNames).toContain('02-security');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should suggest stack-specific rule for NestJS', () => {
|
|
170
|
+
const report = makeReport();
|
|
171
|
+
const plan = makePlan();
|
|
172
|
+
|
|
173
|
+
const result = generator.suggest(report, plan, '/test');
|
|
174
|
+
const ruleNames = result.suggestedRules.map(r => r.name);
|
|
175
|
+
|
|
176
|
+
expect(ruleNames.some(n => n.includes('03-nestjs'))).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should suggest 3 guards', () => {
|
|
180
|
+
const report = makeReport();
|
|
181
|
+
const plan = makePlan();
|
|
182
|
+
|
|
183
|
+
const result = generator.suggest(report, plan, '/test');
|
|
184
|
+
|
|
185
|
+
expect(result.suggestedGuards.length).toBe(3);
|
|
186
|
+
const names = result.suggestedGuards.map(g => g.name);
|
|
187
|
+
expect(names).toContain('PREFLIGHT');
|
|
188
|
+
expect(names).toContain('QUALITY-GATES');
|
|
189
|
+
expect(names).toContain('CODE-REVIEW-CHECKLIST');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should suggest 3 workflows', () => {
|
|
193
|
+
const report = makeReport();
|
|
194
|
+
const plan = makePlan();
|
|
195
|
+
|
|
196
|
+
const result = generator.suggest(report, plan, '/test');
|
|
197
|
+
|
|
198
|
+
expect(result.suggestedWorkflows.length).toBe(3);
|
|
199
|
+
const names = result.suggestedWorkflows.map(w => w.name);
|
|
200
|
+
expect(names).toContain('new-feature');
|
|
201
|
+
expect(names).toContain('fix-bug');
|
|
202
|
+
expect(names).toContain('review');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('should suggest skills including stack-specific ones', () => {
|
|
206
|
+
const report = makeReport();
|
|
207
|
+
const plan = makePlan();
|
|
208
|
+
|
|
209
|
+
const result = generator.suggest(report, plan, '/test');
|
|
210
|
+
|
|
211
|
+
expect(result.suggestedSkills.length).toBeGreaterThan(5);
|
|
212
|
+
const skillNames = result.suggestedSkills.map(s => s.name);
|
|
213
|
+
expect(skillNames).toContain('test-driven-development');
|
|
214
|
+
expect(skillNames).toContain('security-best-practices');
|
|
215
|
+
// TypeScript-specific
|
|
216
|
+
expect(skillNames).toContain('api-design-principles');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should mark hasExistingAgents false for non-existing directory', () => {
|
|
220
|
+
const report = makeReport();
|
|
221
|
+
const plan = makePlan();
|
|
222
|
+
|
|
223
|
+
const result = generator.suggest(report, plan, '/non-existing-path');
|
|
224
|
+
|
|
225
|
+
expect(result.hasExistingAgents).toBe(false);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('generate() — full generation', () => {
|
|
230
|
+
it('should create .agent/ directory structure', () => {
|
|
231
|
+
const report = makeReport();
|
|
232
|
+
const plan = makePlan();
|
|
233
|
+
|
|
234
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
235
|
+
|
|
236
|
+
expect(result.generated.length).toBeGreaterThan(15);
|
|
237
|
+
expect(result.audit).toHaveLength(0); // No audit for fresh generation
|
|
238
|
+
|
|
239
|
+
// Verify directory structure
|
|
240
|
+
expect(existsSync(join(testOutputDir, 'agents'))).toBe(true);
|
|
241
|
+
expect(existsSync(join(testOutputDir, 'rules'))).toBe(true);
|
|
242
|
+
expect(existsSync(join(testOutputDir, 'guards'))).toBe(true);
|
|
243
|
+
expect(existsSync(join(testOutputDir, 'workflows'))).toBe(true);
|
|
244
|
+
expect(existsSync(join(testOutputDir, 'templates'))).toBe(true);
|
|
245
|
+
expect(existsSync(join(testOutputDir, 'skills'))).toBe(true);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should generate core files', () => {
|
|
249
|
+
const report = makeReport();
|
|
250
|
+
const plan = makePlan();
|
|
251
|
+
|
|
252
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
253
|
+
|
|
254
|
+
expect(result.generated).toContain('INDEX.md');
|
|
255
|
+
expect(result.generated).toContain('agents/AGENT-ORCHESTRATOR.md');
|
|
256
|
+
expect(result.generated).toContain('guards/PREFLIGHT.md');
|
|
257
|
+
expect(result.generated).toContain('guards/QUALITY-GATES.md');
|
|
258
|
+
expect(result.generated).toContain('rules/00-general.md');
|
|
259
|
+
expect(result.generated).toContain('rules/01-architecture.md');
|
|
260
|
+
expect(result.generated).toContain('rules/02-security.md');
|
|
261
|
+
expect(result.generated).toContain('workflows/new-feature.md');
|
|
262
|
+
expect(result.generated).toContain('workflows/fix-bug.md');
|
|
263
|
+
expect(result.generated).toContain('workflows/review.md');
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should generate stack-specific agents for NestJS', () => {
|
|
267
|
+
const report = makeReport();
|
|
268
|
+
const plan = makePlan();
|
|
269
|
+
|
|
270
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
271
|
+
|
|
272
|
+
expect(result.generated.some(f => f.includes('TYPESCRIPT-BACKEND-DEVELOPER'))).toBe(true);
|
|
273
|
+
expect(result.generated.some(f => f.includes('DATABASE-ENGINEER'))).toBe(true);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should generate stack-specific rules for NestJS', () => {
|
|
277
|
+
const report = makeReport();
|
|
278
|
+
const plan = makePlan();
|
|
279
|
+
|
|
280
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
281
|
+
|
|
282
|
+
expect(result.generated.some(f => f.includes('03-nestjs'))).toBe(true);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('should generate domain templates', () => {
|
|
286
|
+
const report = makeReport();
|
|
287
|
+
const plan = makePlan();
|
|
288
|
+
|
|
289
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
290
|
+
|
|
291
|
+
expect(result.generated).toContain('templates/C4.md');
|
|
292
|
+
expect(result.generated).toContain('templates/BDD.md');
|
|
293
|
+
expect(result.generated).toContain('templates/TDD.md');
|
|
294
|
+
expect(result.generated).toContain('templates/ADR.md');
|
|
295
|
+
expect(result.generated).toContain('templates/THREAT-MODEL.md');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should generate frontend agent when frontend detected', () => {
|
|
299
|
+
const report = makeReport({
|
|
300
|
+
dependencyGraph: {
|
|
301
|
+
nodes: ['src/app.component.ts', 'src/app.module.ts', 'src/angular.json'],
|
|
302
|
+
edges: [],
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
const plan = makePlan();
|
|
306
|
+
|
|
307
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
308
|
+
|
|
309
|
+
expect(result.generated.some(f => f.includes('FRONTEND-DEVELOPER'))).toBe(true);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should generate mobile agent when Dart detected', () => {
|
|
313
|
+
const report = makeReport({
|
|
314
|
+
dependencyGraph: {
|
|
315
|
+
nodes: ['lib/main.dart', 'lib/app.dart'],
|
|
316
|
+
edges: [],
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
const plan = makePlan();
|
|
320
|
+
|
|
321
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
322
|
+
|
|
323
|
+
expect(result.generated.some(f => f.includes('FLUTTER-UI-DEVELOPER'))).toBe(true);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should generate 18+ files total for a full NestJS project', () => {
|
|
327
|
+
const report = makeReport();
|
|
328
|
+
const plan = makePlan();
|
|
329
|
+
|
|
330
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
331
|
+
|
|
332
|
+
// Core: INDEX + ORCHESTRATOR + PREFLIGHT + QUALITY-GATES + CODE-REVIEW +
|
|
333
|
+
// 00-general + 01-architecture + 02-security + 03-nestjs +
|
|
334
|
+
// new-feature + fix-bug + review = 12
|
|
335
|
+
// Agents: BACKEND + DATABASE + SECURITY + QA + TECH-DEBT = 5
|
|
336
|
+
// Templates: C4 + BDD + TDD + ADR + THREAT-MODEL = 5
|
|
337
|
+
// Total: 22+
|
|
338
|
+
expect(result.generated.length).toBeGreaterThanOrEqual(18);
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
describe('generate() — audit existing', () => {
|
|
343
|
+
it('should audit and generate missing files', () => {
|
|
344
|
+
// Create a partial .agent/ directory
|
|
345
|
+
mkdirSync(join(testOutputDir, 'agents'), { recursive: true });
|
|
346
|
+
mkdirSync(join(testOutputDir, 'rules'), { recursive: true });
|
|
347
|
+
writeFileSync(join(testOutputDir, 'INDEX.md'), '# Existing Index');
|
|
348
|
+
writeFileSync(join(testOutputDir, 'agents/AGENT-ORCHESTRATOR.md'), '# Existing Orchestrator');
|
|
349
|
+
|
|
350
|
+
const report = makeReport();
|
|
351
|
+
const plan = makePlan();
|
|
352
|
+
|
|
353
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
354
|
+
|
|
355
|
+
// Should have audit findings
|
|
356
|
+
expect(result.audit.length).toBeGreaterThan(0);
|
|
357
|
+
|
|
358
|
+
// Should have found some files OK
|
|
359
|
+
const okFindings = result.audit.filter(f => f.type === 'OK');
|
|
360
|
+
expect(okFindings.length).toBeGreaterThanOrEqual(2); // INDEX.md + ORCHESTRATOR
|
|
361
|
+
|
|
362
|
+
// Should have found some missing
|
|
363
|
+
const missingFindings = result.audit.filter(f => f.type === 'MISSING');
|
|
364
|
+
expect(missingFindings.length).toBeGreaterThan(0);
|
|
365
|
+
|
|
366
|
+
// Should have generated the missing files
|
|
367
|
+
expect(result.generated.length).toBeGreaterThan(0);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('should suggest improvement when score is low', () => {
|
|
371
|
+
mkdirSync(join(testOutputDir, 'agents'), { recursive: true });
|
|
372
|
+
mkdirSync(join(testOutputDir, 'guards'), { recursive: true });
|
|
373
|
+
writeFileSync(join(testOutputDir, 'INDEX.md'), '# Index');
|
|
374
|
+
writeFileSync(join(testOutputDir, 'guards/QUALITY-GATES.md'), '# Gates');
|
|
375
|
+
|
|
376
|
+
const report = makeReport({
|
|
377
|
+
score: {
|
|
378
|
+
overall: 50,
|
|
379
|
+
components: [],
|
|
380
|
+
breakdown: { modularity: 50, coupling: 45, cohesion: 55, layering: 50 },
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
const plan = makePlan();
|
|
384
|
+
|
|
385
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
386
|
+
|
|
387
|
+
const improvements = result.audit.filter(f => f.type === 'IMPROVEMENT');
|
|
388
|
+
expect(improvements.length).toBeGreaterThan(0);
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
describe('Python stack generation', () => {
|
|
393
|
+
it('should generate Python-specific agents and rules', () => {
|
|
394
|
+
const report = makeReport({
|
|
395
|
+
dependencyGraph: {
|
|
396
|
+
nodes: ['manage.py', 'app/views.py', 'app/models.py', 'app/serializers.py'],
|
|
397
|
+
edges: [
|
|
398
|
+
{ from: 'app/views.py', to: 'app/models.py', type: 'import', weight: 1 },
|
|
399
|
+
],
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
const plan = makePlan();
|
|
403
|
+
|
|
404
|
+
const result = generator.generate(report, plan, '/test', testOutputDir);
|
|
405
|
+
|
|
406
|
+
// Should detect Python + Django
|
|
407
|
+
expect(result.generated.some(f => f.includes('PYTHON-BACKEND-DEVELOPER'))).toBe(true);
|
|
408
|
+
expect(result.generated.some(f => f.includes('03-django'))).toBe(true);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
});
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Tests — Full pipeline: GitHistory → TemporalScorer → ForecastEngine
|
|
3
|
+
*
|
|
4
|
+
* Validates end-to-end flow with a real git repo and type contracts
|
|
5
|
+
* between the three analyzer stages.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { GitHistoryAnalyzer } from '../src/analyzers/git-history.js';
|
|
9
|
+
import { TemporalScorer } from '../src/analyzers/temporal-scorer.js';
|
|
10
|
+
import { ForecastEngine } from '../src/analyzers/forecast.js';
|
|
11
|
+
import { saveToCache, loadFromCache } from '../src/analyzers/git-cache.js';
|
|
12
|
+
import type { GitHistoryReport } from '../src/analyzers/git-history.js';
|
|
13
|
+
import type { TemporalReport } from '../src/analyzers/temporal-scorer.js';
|
|
14
|
+
import type { WeatherForecast } from '../src/analyzers/forecast.js';
|
|
15
|
+
import { execSync } from 'child_process';
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════
|
|
20
|
+
// SETUP
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════
|
|
22
|
+
|
|
23
|
+
const TEST_DIR = path.join('/tmp', 'architect-integration-test');
|
|
24
|
+
|
|
25
|
+
function setupRealRepo(): void {
|
|
26
|
+
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
27
|
+
fs.mkdirSync(TEST_DIR, { recursive: true });
|
|
28
|
+
|
|
29
|
+
execSync('git init', { cwd: TEST_DIR, stdio: 'pipe' });
|
|
30
|
+
execSync('git config user.email "dev@test.com"', { cwd: TEST_DIR, stdio: 'pipe' });
|
|
31
|
+
execSync('git config user.name "Dev"', { cwd: TEST_DIR, stdio: 'pipe' });
|
|
32
|
+
|
|
33
|
+
// Build a realistic repo with multiple modules
|
|
34
|
+
const files = [
|
|
35
|
+
{ path: 'src/api/routes.ts', content: 'export const routes = [];' },
|
|
36
|
+
{ path: 'src/api/middleware.ts', content: 'export function auth() {}' },
|
|
37
|
+
{ path: 'src/service/user.ts', content: 'export class UserService {}' },
|
|
38
|
+
{ path: 'src/data/repo.ts', content: 'export class UserRepo {}' },
|
|
39
|
+
{ path: 'lib/utils.ts', content: 'export function log() {}' },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
for (const f of files) {
|
|
43
|
+
const dir = path.dirname(path.join(TEST_DIR, f.path));
|
|
44
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
45
|
+
fs.writeFileSync(path.join(TEST_DIR, f.path), f.content);
|
|
46
|
+
}
|
|
47
|
+
execSync('git add . && git commit -m "initial"', { cwd: TEST_DIR, stdio: 'pipe' });
|
|
48
|
+
|
|
49
|
+
// Simulate some activity
|
|
50
|
+
for (let i = 0; i < 5; i++) {
|
|
51
|
+
fs.writeFileSync(
|
|
52
|
+
path.join(TEST_DIR, 'src/api/routes.ts'),
|
|
53
|
+
`export const routes = [${i}];\n`.repeat(i + 1),
|
|
54
|
+
);
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
path.join(TEST_DIR, 'src/service/user.ts'),
|
|
57
|
+
`export class UserService { v${i}() {} }`,
|
|
58
|
+
);
|
|
59
|
+
execSync(`git add . && git commit -m "iteration ${i}"`, { cwd: TEST_DIR, stdio: 'pipe' });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ═══════════════════════════════════════════════════════════════
|
|
64
|
+
// TESTS
|
|
65
|
+
// ═══════════════════════════════════════════════════════════════
|
|
66
|
+
|
|
67
|
+
describe('Analyzer Pipeline Integration', () => {
|
|
68
|
+
let gitReport: GitHistoryReport;
|
|
69
|
+
let temporalReport: TemporalReport;
|
|
70
|
+
let forecast: WeatherForecast;
|
|
71
|
+
|
|
72
|
+
beforeAll(() => {
|
|
73
|
+
setupRealRepo();
|
|
74
|
+
|
|
75
|
+
// Stage 1: Git History
|
|
76
|
+
const gitAnalyzer = new GitHistoryAnalyzer({ periodWeeks: 52 });
|
|
77
|
+
gitReport = gitAnalyzer.analyze(TEST_DIR);
|
|
78
|
+
|
|
79
|
+
// Stage 2: Temporal Scoring
|
|
80
|
+
const scorer = new TemporalScorer({ projectionWeeks: 12 });
|
|
81
|
+
const staticScores = new Map<string, number>();
|
|
82
|
+
for (const mod of gitReport.modules) {
|
|
83
|
+
staticScores.set(mod.modulePath, 70); // assume 70 baseline
|
|
84
|
+
}
|
|
85
|
+
temporalReport = scorer.score(gitReport, staticScores);
|
|
86
|
+
|
|
87
|
+
// Stage 3: Forecast
|
|
88
|
+
const engine = new ForecastEngine();
|
|
89
|
+
forecast = engine.forecast(gitReport, temporalReport);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
afterAll(() => {
|
|
93
|
+
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('Stage 1 → Stage 2 contract', () => {
|
|
97
|
+
it('git report modules should have matching temporal scores', () => {
|
|
98
|
+
for (const mod of gitReport.modules) {
|
|
99
|
+
const ts = temporalReport.modules.find(m => m.module === mod.modulePath);
|
|
100
|
+
expect(ts).toBeDefined();
|
|
101
|
+
expect(ts!.staticScore).toBeDefined();
|
|
102
|
+
expect(ts!.temporalScore).toBeDefined();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('Stage 2 → Stage 3 contract', () => {
|
|
108
|
+
it('temporal modules should have matching forecast modules', () => {
|
|
109
|
+
for (const ts of temporalReport.modules) {
|
|
110
|
+
const fm = forecast.modules.find(m => m.module === ts.module);
|
|
111
|
+
expect(fm).toBeDefined();
|
|
112
|
+
expect(fm!.currentHealth).toMatch(/^(healthy|at-risk|degrading|critical)$/);
|
|
113
|
+
expect(fm!.forecast6Months).toMatch(/^(stable|declining|breakdown)$/);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('end-to-end output', () => {
|
|
119
|
+
it('forecast should have valid outlook', () => {
|
|
120
|
+
expect(['sunny', 'cloudy', 'stormy']).toContain(forecast.overallOutlook);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('forecast should have a headline', () => {
|
|
124
|
+
expect(forecast.headline.length).toBeGreaterThan(0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('all pre-anti-patterns should have valid types', () => {
|
|
128
|
+
const validTypes = [
|
|
129
|
+
'emerging-god-class',
|
|
130
|
+
'emerging-shotgun-surgery',
|
|
131
|
+
'emerging-feature-envy',
|
|
132
|
+
'bus-factor-risk',
|
|
133
|
+
'complexity-spiral',
|
|
134
|
+
'coupling-magnet',
|
|
135
|
+
];
|
|
136
|
+
for (const p of forecast.preAntiPatterns) {
|
|
137
|
+
expect(validTypes).toContain(p.type);
|
|
138
|
+
expect(p.confidence).toBeGreaterThan(0);
|
|
139
|
+
expect(p.confidence).toBeLessThanOrEqual(1);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('modules should have bottleneck probability between 0 and 1', () => {
|
|
144
|
+
for (const m of forecast.modules) {
|
|
145
|
+
expect(m.bottleneckProbability).toBeGreaterThanOrEqual(0);
|
|
146
|
+
expect(m.bottleneckProbability).toBeLessThanOrEqual(1);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('git cache', () => {
|
|
152
|
+
it('should save and load cache correctly', () => {
|
|
153
|
+
saveToCache(gitReport, TEST_DIR);
|
|
154
|
+
|
|
155
|
+
const loaded = loadFromCache(TEST_DIR, '.architect-cache', 3600000);
|
|
156
|
+
expect(loaded).not.toBeNull();
|
|
157
|
+
expect(loaded!.projectPath).toBe(gitReport.projectPath);
|
|
158
|
+
expect(loaded!.totalCommits).toBe(gitReport.totalCommits);
|
|
159
|
+
expect(loaded!.totalAuthors).toBe(gitReport.totalAuthors);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should return null for expired cache', () => {
|
|
163
|
+
saveToCache(gitReport, TEST_DIR);
|
|
164
|
+
|
|
165
|
+
const loaded = loadFromCache(TEST_DIR, '.architect-cache', 0); // 0ms = expired
|
|
166
|
+
expect(loaded).toBeNull();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should return null when cache does not exist', () => {
|
|
170
|
+
const loaded = loadFromCache('/tmp/nonexistent-path');
|
|
171
|
+
expect(loaded).toBeNull();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This test has been moved to the nexus package where it can resolve @nexus/* imports.
|
|
3
|
+
* See: nexus/packages/bridge/src/__tests__/architect-adapter-enrichment.test.ts
|
|
4
|
+
*/
|
|
5
|
+
describe('ArchitectAdapter enrichment', () => {
|
|
6
|
+
it('tests moved to nexus/packages/bridge — run from nexus root', () => {
|
|
7
|
+
expect(true).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
});
|