@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,555 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { AnalysisReport, RefactoringPlan } from '../types.js';
|
|
4
|
+
import {
|
|
5
|
+
StackInfo,
|
|
6
|
+
AgentAuditFinding,
|
|
7
|
+
AgentItem,
|
|
8
|
+
AgentItemStatus,
|
|
9
|
+
AgentSuggestion,
|
|
10
|
+
TemplateContext,
|
|
11
|
+
EnrichedTemplateContext,
|
|
12
|
+
DomainInsights,
|
|
13
|
+
ModuleDetail,
|
|
14
|
+
DetectedEndpoint,
|
|
15
|
+
FrameworkInfo,
|
|
16
|
+
DetectedToolchain,
|
|
17
|
+
AgentGeneratorConfig,
|
|
18
|
+
DEFAULT_AGENT_CONFIG,
|
|
19
|
+
} from './types.js';
|
|
20
|
+
import { StackDetector } from './stack-detector.js';
|
|
21
|
+
import { ContextEnricher } from './context-enricher.js';
|
|
22
|
+
|
|
23
|
+
// ── Core Templates (Enterprise-Grade) ──
|
|
24
|
+
import { generateIndexMd } from './templates/core/index-md.js';
|
|
25
|
+
import { generateOrchestrator } from './templates/core/orchestrator.js';
|
|
26
|
+
import { generatePreflight } from './templates/core/preflight.js';
|
|
27
|
+
import { generateQualityGates } from './templates/core/quality-gates.js';
|
|
28
|
+
import { generateGeneralRules } from './templates/core/general-rules.js';
|
|
29
|
+
import { generateArchitectureRules } from './templates/core/architecture-rules.js';
|
|
30
|
+
import { generateSecurityRules } from './templates/core/security-rules.js';
|
|
31
|
+
import { generateNewFeatureWorkflow } from './templates/core/workflow-new-feature.js';
|
|
32
|
+
import { generateFixBugWorkflow } from './templates/core/workflow-fix-bug.js';
|
|
33
|
+
import { generateReviewWorkflow } from './templates/core/workflow-review.js';
|
|
34
|
+
import {
|
|
35
|
+
generateBackendAgent,
|
|
36
|
+
generateFrontendAgent,
|
|
37
|
+
generateSecurityAgent,
|
|
38
|
+
generateQAAgent,
|
|
39
|
+
generateTechDebtAgent,
|
|
40
|
+
generateCodeReviewChecklist,
|
|
41
|
+
generateDatabaseAgent,
|
|
42
|
+
generateMobileAgent,
|
|
43
|
+
} from './templates/core/agents.js';
|
|
44
|
+
|
|
45
|
+
// ── Stack-Specific Templates ──
|
|
46
|
+
import { generateStackRules, getStackRuleFileName } from './templates/stack/index.js';
|
|
47
|
+
|
|
48
|
+
// ── Domain Templates ──
|
|
49
|
+
import {
|
|
50
|
+
generateC4Template,
|
|
51
|
+
generateBddTemplate,
|
|
52
|
+
generateTddTemplate,
|
|
53
|
+
generateAdrTemplate,
|
|
54
|
+
generateThreatModelTemplate,
|
|
55
|
+
} from './templates/domain/index.js';
|
|
56
|
+
|
|
57
|
+
// ── Skills Generator ──
|
|
58
|
+
import { generateProjectSkills } from './templates/core/skills-generator.js';
|
|
59
|
+
|
|
60
|
+
// Re-export types for backward compatibility
|
|
61
|
+
export type { StackInfo, AgentAuditFinding, AgentItem, AgentItemStatus, AgentSuggestion, EnrichedTemplateContext, DomainInsights, ModuleDetail, DetectedEndpoint, FrameworkInfo, DetectedToolchain };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Agent Generator v3.1 — Enterprise-Grade
|
|
65
|
+
*
|
|
66
|
+
* Generates or audits .agent/ directories with enterprise-grade
|
|
67
|
+
* agent frameworks: detailed workflows, approval gates, quality enforcement,
|
|
68
|
+
* stack-specific agents, and domain templates.
|
|
69
|
+
*/
|
|
70
|
+
export class AgentGenerator {
|
|
71
|
+
private stackDetector = new StackDetector();
|
|
72
|
+
private contextEnricher = new ContextEnricher();
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Suggest agents without writing files — for unified report.
|
|
76
|
+
*/
|
|
77
|
+
suggest(
|
|
78
|
+
report: AnalysisReport,
|
|
79
|
+
plan: RefactoringPlan,
|
|
80
|
+
projectPath: string,
|
|
81
|
+
): AgentSuggestion {
|
|
82
|
+
const stack = this.stackDetector.detect(report);
|
|
83
|
+
const agentDir = join(projectPath, '.agent');
|
|
84
|
+
const isExisting = existsSync(agentDir);
|
|
85
|
+
|
|
86
|
+
const existingFiles = (subdir: string): Set<string> => {
|
|
87
|
+
const dir = join(agentDir, subdir);
|
|
88
|
+
if (!existsSync(dir)) return new Set();
|
|
89
|
+
return new Set(readdirSync(dir).map(f => f.replace(/\.md$/, '')));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
let audit: AgentAuditFinding[] = [];
|
|
93
|
+
if (isExisting) {
|
|
94
|
+
audit = this.auditExisting(agentDir, stack, report, plan);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const ctx = this.buildContext(report, plan, stack, projectPath);
|
|
98
|
+
|
|
99
|
+
const existingAgents = existingFiles('agents');
|
|
100
|
+
const existingRules = existingFiles('rules');
|
|
101
|
+
const existingGuards = existingFiles('guards');
|
|
102
|
+
const existingWorkflows = existingFiles('workflows');
|
|
103
|
+
const existingSkillsDir = join(agentDir, 'skills');
|
|
104
|
+
const existingSkillNames = existsSync(existingSkillsDir)
|
|
105
|
+
? new Set(readdirSync(existingSkillsDir).filter(f => {
|
|
106
|
+
try { return statSync(join(existingSkillsDir, f)).isDirectory(); } catch { return false; }
|
|
107
|
+
}))
|
|
108
|
+
: new Set<string>();
|
|
109
|
+
|
|
110
|
+
const itemStatus = (name: string, existing: Set<string>): AgentItemStatus => {
|
|
111
|
+
const found = [...existing].some(e => e.toLowerCase() === name.toLowerCase());
|
|
112
|
+
if (!found) return 'CREATE';
|
|
113
|
+
const hasImprovement = audit.some(
|
|
114
|
+
f => f.file.toLowerCase().includes(name.toLowerCase()) && (f.type === 'IMPROVEMENT' || f.type === 'OUTDATED')
|
|
115
|
+
);
|
|
116
|
+
return hasImprovement ? 'MODIFY' : 'KEEP';
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ── Agent definitions ──
|
|
120
|
+
const agentDefs: { name: string; desc: string }[] = [
|
|
121
|
+
{ name: 'AGENT-ORCHESTRATOR', desc: 'Centro de comando — decompõe requisições, enforça gates, coordena agentes' },
|
|
122
|
+
];
|
|
123
|
+
if (stack.hasBackend) agentDefs.push({
|
|
124
|
+
name: `${stack.primary.toUpperCase()}-BACKEND-DEVELOPER`,
|
|
125
|
+
desc: `Especialista em ${stack.primary} — APIs, serviços, lógica de negócio, integration docs`,
|
|
126
|
+
});
|
|
127
|
+
if (stack.hasFrontend) {
|
|
128
|
+
const fw = stack.frameworks.find(f => ['Angular', 'Vue', 'Next.js', 'React'].includes(f)) || 'FRONTEND';
|
|
129
|
+
agentDefs.push({
|
|
130
|
+
name: `${fw.toUpperCase().replace('.', '')}-FRONTEND-DEVELOPER`,
|
|
131
|
+
desc: `Componentes ${fw}, state management, UX responsiva, todos os estados UI`,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (stack.hasMobile) agentDefs.push({
|
|
135
|
+
name: 'FLUTTER-UI-DEVELOPER',
|
|
136
|
+
desc: 'Screens mobile, widgets, navegação, integração API, padrão visual do app',
|
|
137
|
+
});
|
|
138
|
+
if (stack.hasDatabase) agentDefs.push({
|
|
139
|
+
name: 'DATABASE-ENGINEER',
|
|
140
|
+
desc: 'Schema design, migrations reversíveis, indexação, performance de queries',
|
|
141
|
+
});
|
|
142
|
+
agentDefs.push(
|
|
143
|
+
{ name: 'SECURITY-AUDITOR', desc: 'OWASP Top 10, STRIDE threat model, compliance, vulnerabilidades' },
|
|
144
|
+
{ name: 'QA-TEST-ENGINEER', desc: 'BDD/TDD, cobertura mínima, planos de teste, regressão' },
|
|
145
|
+
{ name: 'TECH-DEBT-CONTROLLER', desc: 'Score tracking, anti-patterns, refatorações, metas de qualidade' },
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const ruleDefs: { name: string; desc: string }[] = [
|
|
149
|
+
{ name: '00-general', desc: '9 Regras de Ouro, Git Flow, naming conventions, ações proibidas' },
|
|
150
|
+
{ name: '01-architecture', desc: 'Separação de camadas, dependency rules, padrões de módulo' },
|
|
151
|
+
{ name: '02-security', desc: 'Sanitização, secrets management, validação, OWASP' },
|
|
152
|
+
];
|
|
153
|
+
const stackRuleName = getStackRuleFileName(ctx);
|
|
154
|
+
if (stackRuleName) {
|
|
155
|
+
const fwLabel = stack.frameworks[0] || stack.primary;
|
|
156
|
+
ruleDefs.push({ name: stackRuleName, desc: `Regras específicas ${fwLabel} — patterns, anti-patterns, checklist` });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const guardDefs = [
|
|
160
|
+
{ name: 'PREFLIGHT', desc: '6-phase checklist pré-ação: ambiente → leitura → negócio → camada → commit → done' },
|
|
161
|
+
{ name: 'QUALITY-GATES', desc: '3 níveis (CRITICAL/IMPORTANT/DESIRABLE), métricas, blockers, verificação em 4 estágios' },
|
|
162
|
+
{ name: 'CODE-REVIEW-CHECKLIST', desc: 'Review em 6 dimensões: funcional, qualidade, testes, segurança, performance, arquitetura' },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
const workflowDefs = [
|
|
166
|
+
{ name: 'new-feature', desc: '10 steps com 6 approval gates, mockup-first, backend-first, integration doc' },
|
|
167
|
+
{ name: 'fix-bug', desc: '10 steps: diagnóstico → root cause → RED test → fix mínimo → regressão → docs' },
|
|
168
|
+
{ name: 'review', desc: 'Code review em 6 dimensões com checklist estruturado' },
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
// Build items
|
|
172
|
+
const suggestedAgents: AgentItem[] = agentDefs.map(({ name, desc }) => ({
|
|
173
|
+
name, status: itemStatus(name, existingAgents), description: desc,
|
|
174
|
+
}));
|
|
175
|
+
for (const existing of existingAgents) {
|
|
176
|
+
if (!agentDefs.some(d => d.name.toLowerCase() === existing.toLowerCase())) {
|
|
177
|
+
suggestedAgents.push({ name: existing, status: 'KEEP', reason: 'Custom agent', description: 'Agente customizado do projeto' });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const suggestedRules: AgentItem[] = ruleDefs.map(({ name, desc }) => ({
|
|
182
|
+
name, status: itemStatus(name, existingRules), description: desc,
|
|
183
|
+
}));
|
|
184
|
+
for (const existing of existingRules) {
|
|
185
|
+
if (!ruleDefs.some(d => d.name.toLowerCase() === existing.toLowerCase())) {
|
|
186
|
+
suggestedRules.push({ name: existing, status: 'KEEP', reason: 'Custom rule' });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const suggestedGuards: AgentItem[] = guardDefs.map(({ name, desc }) => ({
|
|
191
|
+
name, status: itemStatus(name, existingGuards), description: desc,
|
|
192
|
+
}));
|
|
193
|
+
|
|
194
|
+
const suggestedWorkflows: AgentItem[] = workflowDefs.map(({ name, desc }) => ({
|
|
195
|
+
name, status: itemStatus(name, existingWorkflows), description: desc,
|
|
196
|
+
}));
|
|
197
|
+
for (const existing of existingWorkflows) {
|
|
198
|
+
if (!workflowDefs.some(d => d.name.toLowerCase() === existing.toLowerCase())) {
|
|
199
|
+
suggestedWorkflows.push({ name: existing, status: 'KEEP', reason: 'Custom workflow' });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Skills
|
|
204
|
+
const skillEntries = this.buildSkillEntries(stack, existingSkillNames);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
stack,
|
|
208
|
+
hasExistingAgents: isExisting,
|
|
209
|
+
suggestedAgents,
|
|
210
|
+
suggestedRules,
|
|
211
|
+
suggestedGuards,
|
|
212
|
+
suggestedWorkflows,
|
|
213
|
+
suggestedSkills: skillEntries,
|
|
214
|
+
audit,
|
|
215
|
+
command: `architect agents ${projectPath}`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Generate or audit .agent/ directory for a project.
|
|
221
|
+
*/
|
|
222
|
+
generate(
|
|
223
|
+
report: AnalysisReport,
|
|
224
|
+
plan: RefactoringPlan,
|
|
225
|
+
projectPath: string,
|
|
226
|
+
outputDir?: string
|
|
227
|
+
): { generated: string[]; audit: AgentAuditFinding[] } {
|
|
228
|
+
const stack = this.stackDetector.detect(report);
|
|
229
|
+
const agentDir = outputDir || join(projectPath, '.agent');
|
|
230
|
+
const isExisting = existsSync(agentDir);
|
|
231
|
+
|
|
232
|
+
if (isExisting) {
|
|
233
|
+
const audit = this.auditExisting(agentDir, stack, report, plan);
|
|
234
|
+
const generated = this.generateMissing(agentDir, audit, report, plan, stack, projectPath);
|
|
235
|
+
return { generated, audit };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const generated = this.generateFull(agentDir, report, plan, stack, projectPath);
|
|
239
|
+
return { generated, audit: [] };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ── Private: Build Template Context ──
|
|
243
|
+
|
|
244
|
+
private buildContext(report: AnalysisReport, plan: RefactoringPlan, stack: StackInfo, projectPath?: string): EnrichedTemplateContext {
|
|
245
|
+
if (projectPath) {
|
|
246
|
+
return this.contextEnricher.enrich(report, plan, stack, projectPath);
|
|
247
|
+
}
|
|
248
|
+
// Fallback to basic enriched context for backward compatibility
|
|
249
|
+
return {
|
|
250
|
+
report,
|
|
251
|
+
plan,
|
|
252
|
+
stack,
|
|
253
|
+
projectName: report.projectInfo.name || 'Project',
|
|
254
|
+
stackLabel: [...stack.languages, ...stack.frameworks].join(' + '),
|
|
255
|
+
config: DEFAULT_AGENT_CONFIG,
|
|
256
|
+
domain: {
|
|
257
|
+
domain: 'general',
|
|
258
|
+
subDomain: 'general',
|
|
259
|
+
description: '',
|
|
260
|
+
businessEntities: [],
|
|
261
|
+
compliance: [],
|
|
262
|
+
integrations: [],
|
|
263
|
+
keywords: [],
|
|
264
|
+
confidence: 0,
|
|
265
|
+
},
|
|
266
|
+
modules: [],
|
|
267
|
+
endpoints: [],
|
|
268
|
+
untestedModules: [],
|
|
269
|
+
criticalPaths: [],
|
|
270
|
+
projectDepth: 'small',
|
|
271
|
+
detectedFrameworks: [],
|
|
272
|
+
primaryFramework: null,
|
|
273
|
+
toolchain: {
|
|
274
|
+
buildCmd: 'echo "No build command detected"',
|
|
275
|
+
testCmd: 'echo "No test command detected"',
|
|
276
|
+
lintCmd: 'echo "No lint command detected"',
|
|
277
|
+
runCmd: 'echo "No run command detected"',
|
|
278
|
+
coverageCmd: 'echo "No coverage command detected"',
|
|
279
|
+
installCmd: 'echo "No install command detected"',
|
|
280
|
+
migrateCmd: null,
|
|
281
|
+
depsFile: 'unknown',
|
|
282
|
+
},
|
|
283
|
+
projectStructure: 'unknown',
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ── Private: Full Generation ──
|
|
288
|
+
|
|
289
|
+
private generateFull(agentDir: string, report: AnalysisReport, plan: RefactoringPlan, stack: StackInfo, projectPath: string): string[] {
|
|
290
|
+
const generated: string[] = [];
|
|
291
|
+
const ctx = this.buildContext(report, plan, stack, projectPath);
|
|
292
|
+
|
|
293
|
+
// Create directories
|
|
294
|
+
const dirs = ['agents', 'rules', 'guards', 'workflows', 'templates', 'skills'];
|
|
295
|
+
for (const d of dirs) mkdirSync(join(agentDir, d), { recursive: true });
|
|
296
|
+
|
|
297
|
+
// ── Core files (Enterprise-Grade) ──
|
|
298
|
+
const coreFiles: Record<string, string> = {
|
|
299
|
+
'INDEX.md': generateIndexMd(ctx),
|
|
300
|
+
'agents/AGENT-ORCHESTRATOR.md': generateOrchestrator(ctx),
|
|
301
|
+
'guards/PREFLIGHT.md': generatePreflight(ctx),
|
|
302
|
+
'guards/QUALITY-GATES.md': generateQualityGates(ctx),
|
|
303
|
+
'guards/CODE-REVIEW-CHECKLIST.md': generateCodeReviewChecklist(ctx),
|
|
304
|
+
'rules/00-general.md': generateGeneralRules(ctx),
|
|
305
|
+
'rules/01-architecture.md': generateArchitectureRules(ctx),
|
|
306
|
+
'rules/02-security.md': generateSecurityRules(ctx),
|
|
307
|
+
'workflows/new-feature.md': generateNewFeatureWorkflow(ctx),
|
|
308
|
+
'workflows/fix-bug.md': generateFixBugWorkflow(ctx),
|
|
309
|
+
'workflows/review.md': generateReviewWorkflow(ctx),
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// ── Stack-specific agents ──
|
|
313
|
+
if (stack.hasBackend) {
|
|
314
|
+
coreFiles[`agents/${stack.primary.toUpperCase()}-BACKEND-DEVELOPER.md`] = generateBackendAgent(ctx);
|
|
315
|
+
}
|
|
316
|
+
if (stack.hasFrontend) {
|
|
317
|
+
const fwName = stack.frameworks.find(f =>
|
|
318
|
+
['Angular', 'Vue', 'Next.js', 'React'].includes(f)) || 'Frontend';
|
|
319
|
+
coreFiles[`agents/${fwName.toUpperCase().replace('.', '')}-FRONTEND-DEVELOPER.md`] = generateFrontendAgent(ctx);
|
|
320
|
+
}
|
|
321
|
+
if (stack.hasMobile) {
|
|
322
|
+
coreFiles['agents/FLUTTER-UI-DEVELOPER.md'] = generateMobileAgent(ctx);
|
|
323
|
+
}
|
|
324
|
+
if (stack.hasDatabase) {
|
|
325
|
+
coreFiles['agents/DATABASE-ENGINEER.md'] = generateDatabaseAgent(ctx);
|
|
326
|
+
}
|
|
327
|
+
coreFiles['agents/SECURITY-AUDITOR.md'] = generateSecurityAgent(ctx);
|
|
328
|
+
coreFiles['agents/QA-TEST-ENGINEER.md'] = generateQAAgent(ctx);
|
|
329
|
+
coreFiles['agents/TECH-DEBT-CONTROLLER.md'] = generateTechDebtAgent(ctx);
|
|
330
|
+
|
|
331
|
+
// ── Stack-specific rules ──
|
|
332
|
+
const stackRuleContent = generateStackRules(ctx);
|
|
333
|
+
const stackRuleFile = getStackRuleFileName(ctx);
|
|
334
|
+
if (stackRuleContent && stackRuleFile) {
|
|
335
|
+
coreFiles[`rules/${stackRuleFile}.md`] = stackRuleContent;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// ── Domain templates ──
|
|
339
|
+
coreFiles['templates/C4.md'] = generateC4Template(ctx);
|
|
340
|
+
coreFiles['templates/BDD.md'] = generateBddTemplate(ctx);
|
|
341
|
+
coreFiles['templates/TDD.md'] = generateTddTemplate(ctx);
|
|
342
|
+
coreFiles['templates/ADR.md'] = generateAdrTemplate(ctx);
|
|
343
|
+
coreFiles['templates/THREAT-MODEL.md'] = generateThreatModelTemplate(ctx);
|
|
344
|
+
|
|
345
|
+
// ── Project Skills (padrões detectados) ──
|
|
346
|
+
const skillsContent = generateProjectSkills(ctx);
|
|
347
|
+
if (skillsContent) {
|
|
348
|
+
coreFiles['skills/PROJECT-PATTERNS.md'] = skillsContent;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// ── Write all files ──
|
|
352
|
+
for (const [path, content] of Object.entries(coreFiles)) {
|
|
353
|
+
const fullPath = join(agentDir, path);
|
|
354
|
+
const dir = join(fullPath, '..');
|
|
355
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
356
|
+
writeFileSync(fullPath, content);
|
|
357
|
+
generated.push(path);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return generated;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ── Private: Generate Missing (for existing .agent/) ──
|
|
364
|
+
|
|
365
|
+
private generateMissing(
|
|
366
|
+
agentDir: string,
|
|
367
|
+
audit: AgentAuditFinding[],
|
|
368
|
+
report: AnalysisReport,
|
|
369
|
+
plan: RefactoringPlan,
|
|
370
|
+
stack: StackInfo,
|
|
371
|
+
projectPath: string,
|
|
372
|
+
): string[] {
|
|
373
|
+
const generated: string[] = [];
|
|
374
|
+
const missing = audit.filter(f => f.type === 'MISSING');
|
|
375
|
+
const ctx = this.buildContext(report, plan, stack, projectPath);
|
|
376
|
+
|
|
377
|
+
for (const finding of missing) {
|
|
378
|
+
const fullPath = join(agentDir, finding.file);
|
|
379
|
+
const dir = join(fullPath, '..');
|
|
380
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
381
|
+
|
|
382
|
+
const content = this.getTemplateFor(finding.file, ctx);
|
|
383
|
+
if (content) {
|
|
384
|
+
writeFileSync(fullPath, content);
|
|
385
|
+
generated.push(finding.file);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return generated;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private getTemplateFor(file: string, ctx: EnrichedTemplateContext): string | null {
|
|
393
|
+
if (file.includes('INDEX')) return generateIndexMd(ctx);
|
|
394
|
+
if (file.includes('ORCHESTRATOR')) return generateOrchestrator(ctx);
|
|
395
|
+
if (file.includes('PREFLIGHT')) return generatePreflight(ctx);
|
|
396
|
+
if (file.includes('QUALITY-GATES')) return generateQualityGates(ctx);
|
|
397
|
+
if (file.includes('CODE-REVIEW')) return generateCodeReviewChecklist(ctx);
|
|
398
|
+
if (file.includes('SECURITY')) return generateSecurityAgent(ctx);
|
|
399
|
+
if (file.includes('QA')) return generateQAAgent(ctx);
|
|
400
|
+
if (file.includes('TECH-DEBT')) return generateTechDebtAgent(ctx);
|
|
401
|
+
if (file.includes('BACKEND')) return generateBackendAgent(ctx);
|
|
402
|
+
if (file.includes('FRONTEND')) return generateFrontendAgent(ctx);
|
|
403
|
+
if (file.includes('FLUTTER')) return generateMobileAgent(ctx);
|
|
404
|
+
if (file.includes('DATABASE')) return generateDatabaseAgent(ctx);
|
|
405
|
+
if (file.includes('00-general')) return generateGeneralRules(ctx);
|
|
406
|
+
if (file.includes('01-architecture')) return generateArchitectureRules(ctx);
|
|
407
|
+
if (file.includes('02-security')) return generateSecurityRules(ctx);
|
|
408
|
+
if (file.includes('03-')) return generateStackRules(ctx);
|
|
409
|
+
if (file.includes('new-feature') || file.includes('develop')) return generateNewFeatureWorkflow(ctx);
|
|
410
|
+
if (file.includes('fix-bug')) return generateFixBugWorkflow(ctx);
|
|
411
|
+
if (file.includes('review')) return generateReviewWorkflow(ctx);
|
|
412
|
+
if (file.includes('C4')) return generateC4Template(ctx);
|
|
413
|
+
if (file.includes('BDD')) return generateBddTemplate(ctx);
|
|
414
|
+
if (file.includes('TDD')) return generateTddTemplate(ctx);
|
|
415
|
+
if (file.includes('ADR')) return generateAdrTemplate(ctx);
|
|
416
|
+
if (file.includes('THREAT')) return generateThreatModelTemplate(ctx);
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// ── Private: Audit ──
|
|
421
|
+
|
|
422
|
+
private auditExisting(
|
|
423
|
+
agentDir: string,
|
|
424
|
+
stack: StackInfo,
|
|
425
|
+
report: AnalysisReport,
|
|
426
|
+
plan: RefactoringPlan,
|
|
427
|
+
): AgentAuditFinding[] {
|
|
428
|
+
const findings: AgentAuditFinding[] = [];
|
|
429
|
+
|
|
430
|
+
const checkExists = (subpath: string, category: string, desc: string): void => {
|
|
431
|
+
const full = join(agentDir, subpath);
|
|
432
|
+
if (!existsSync(full)) {
|
|
433
|
+
findings.push({ type: 'MISSING', category, file: subpath, description: desc });
|
|
434
|
+
} else {
|
|
435
|
+
findings.push({ type: 'OK', category, file: subpath, description: `${subpath} exists` });
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// Core structure
|
|
440
|
+
checkExists('INDEX.md', 'core', 'Master navigation guide');
|
|
441
|
+
checkExists('agents/AGENT-ORCHESTRATOR.md', 'agents', 'Orchestrator agent with approval gates');
|
|
442
|
+
checkExists('rules/00-general.md', 'rules', 'Golden rules and conventions');
|
|
443
|
+
checkExists('rules/01-architecture.md', 'rules', 'Layer rules, dependency direction, module patterns');
|
|
444
|
+
checkExists('rules/02-security.md', 'rules', 'OWASP, input validation, secrets management');
|
|
445
|
+
checkExists('guards/PREFLIGHT.md', 'guards', '6-phase preflight checklist');
|
|
446
|
+
checkExists('guards/QUALITY-GATES.md', 'guards', '3-level quality gates');
|
|
447
|
+
checkExists('guards/CODE-REVIEW-CHECKLIST.md', 'guards', 'Structured code review checklist');
|
|
448
|
+
checkExists('workflows/new-feature.md', 'workflows', '10-step feature workflow with approval gates');
|
|
449
|
+
checkExists('workflows/fix-bug.md', 'workflows', 'Diagnostic bug fix workflow');
|
|
450
|
+
|
|
451
|
+
// Domain templates
|
|
452
|
+
checkExists('templates/C4.md', 'templates', 'C4 architecture template');
|
|
453
|
+
checkExists('templates/BDD.md', 'templates', 'BDD scenario template');
|
|
454
|
+
checkExists('templates/TDD.md', 'templates', 'TDD test template');
|
|
455
|
+
checkExists('templates/ADR.md', 'templates', 'ADR decision record template');
|
|
456
|
+
checkExists('templates/THREAT-MODEL.md', 'templates', 'STRIDE threat model template');
|
|
457
|
+
|
|
458
|
+
// Stack-specific agents
|
|
459
|
+
if (stack.hasBackend) {
|
|
460
|
+
const found = this.findAgentByRole(agentDir, 'backend');
|
|
461
|
+
if (!found) {
|
|
462
|
+
findings.push({
|
|
463
|
+
type: 'MISSING', category: 'agents',
|
|
464
|
+
file: `agents/${stack.primary.toUpperCase()}-BACKEND-DEVELOPER.md`,
|
|
465
|
+
description: `No backend developer agent for ${stack.primary}`,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (stack.hasFrontend) {
|
|
470
|
+
const found = this.findAgentByRole(agentDir, 'frontend');
|
|
471
|
+
if (!found) {
|
|
472
|
+
findings.push({
|
|
473
|
+
type: 'MISSING', category: 'agents',
|
|
474
|
+
file: 'agents/FRONTEND-DEVELOPER.md',
|
|
475
|
+
description: 'No frontend developer agent',
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Quality improvements
|
|
481
|
+
if (plan.steps.length > 0) {
|
|
482
|
+
const found = this.findAgentByRole(agentDir, 'tech-debt');
|
|
483
|
+
if (!found) {
|
|
484
|
+
findings.push({
|
|
485
|
+
type: 'IMPROVEMENT', category: 'agents',
|
|
486
|
+
file: 'agents/TECH-DEBT-CONTROLLER.md',
|
|
487
|
+
description: `${plan.steps.length} refactoring steps found but no Tech Debt agent`,
|
|
488
|
+
suggestion: 'Create a Tech Debt Controller to track and prioritize refactoring',
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (report.score.overall < 80) {
|
|
494
|
+
findings.push({
|
|
495
|
+
type: 'IMPROVEMENT', category: 'guards',
|
|
496
|
+
file: 'guards/QUALITY-GATES.md',
|
|
497
|
+
description: `Score is ${report.score.overall}/100 — quality gates should enforce improvement`,
|
|
498
|
+
suggestion: `Set minimum score threshold to ${report.score.overall + 5} and add regression guards`,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return findings;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private findAgentByRole(agentDir: string, role: string): string | null {
|
|
506
|
+
const dir = join(agentDir, 'agents');
|
|
507
|
+
if (!existsSync(dir)) return null;
|
|
508
|
+
const files = readdirSync(dir);
|
|
509
|
+
for (const file of files) {
|
|
510
|
+
const content = readFileSync(join(dir, file), 'utf-8').toLowerCase();
|
|
511
|
+
if (content.includes(role)) return file;
|
|
512
|
+
}
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// ── Private: Skills ──
|
|
517
|
+
|
|
518
|
+
private buildSkillEntries(stack: StackInfo, existing: Set<string>) {
|
|
519
|
+
const entries: { name: string; source: string; description: string; status: AgentItemStatus }[] = [
|
|
520
|
+
{ name: 'test-driven-development', source: 'anthropic/courses/test-driven-development', description: 'TDD: Red → Green → Refactor', status: 'CREATE' },
|
|
521
|
+
{ name: 'systematic-debugging', source: 'anthropic/courses/systematic-debugging', description: 'Structured debugging methodology', status: 'CREATE' },
|
|
522
|
+
{ name: 'code-review', source: 'anthropic/courses/requesting-code-review', description: 'Code review best practices', status: 'CREATE' },
|
|
523
|
+
{ name: 'security-best-practices', source: 'anthropic/courses/security-best-practices', description: 'Security patterns and vulnerability prevention', status: 'CREATE' },
|
|
524
|
+
{ name: 'performance-optimization', source: 'anthropic/courses/performance-optimization', description: 'Performance analysis and optimization', status: 'CREATE' },
|
|
525
|
+
{ name: 'git-workflow', source: 'anthropic/courses/git-workflow', description: 'Git branching, commits, collaboration', status: 'CREATE' },
|
|
526
|
+
];
|
|
527
|
+
|
|
528
|
+
// Stack-specific skills
|
|
529
|
+
if (stack.languages.includes('TypeScript') || stack.languages.includes('JavaScript')) {
|
|
530
|
+
entries.push({ name: 'api-design-principles', source: 'anthropic/courses/api-design-principles', description: 'REST/GraphQL API design', status: 'CREATE' });
|
|
531
|
+
}
|
|
532
|
+
if (stack.frameworks.includes('Angular') || stack.frameworks.includes('Vue') || stack.frameworks.includes('React') || stack.frameworks.includes('Next.js')) {
|
|
533
|
+
entries.push(
|
|
534
|
+
{ name: 'frontend-design', source: 'anthropic/courses/frontend-design', description: 'Modern frontend patterns', status: 'CREATE' },
|
|
535
|
+
{ name: 'web-accessibility', source: 'anthropic/courses/web-accessibility', description: 'WCAG accessibility standards', status: 'CREATE' },
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
if (stack.languages.includes('Dart') || stack.frameworks.includes('Flutter')) {
|
|
539
|
+
entries.push({ name: 'flutter-animations', source: 'anthropic/courses/flutter-animations', description: 'Flutter animation patterns', status: 'CREATE' });
|
|
540
|
+
}
|
|
541
|
+
if (stack.languages.includes('Python')) {
|
|
542
|
+
entries.push({ name: 'python-performance', source: 'anthropic/courses/python-performance-optimization', description: 'Python optimization and profiling', status: 'CREATE' });
|
|
543
|
+
}
|
|
544
|
+
if (stack.hasDatabase) {
|
|
545
|
+
entries.push({ name: 'database-schema-design', source: 'anthropic/courses/database-schema-design', description: 'Schema design, indexing, migrations', status: 'CREATE' });
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Update status based on existing
|
|
549
|
+
for (const entry of entries) {
|
|
550
|
+
if (existing.has(entry.name)) entry.status = 'KEEP';
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return entries;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AnalysisReport } from '../types.js';
|
|
2
|
+
import { StackInfo } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Detects the technology stack from an AnalysisReport.
|
|
6
|
+
* Extracted from the monolithic AgentGenerator for single-responsibility.
|
|
7
|
+
*/
|
|
8
|
+
export class StackDetector {
|
|
9
|
+
detect(report: AnalysisReport): StackInfo {
|
|
10
|
+
const files = report.dependencyGraph.nodes;
|
|
11
|
+
const extensions = new Set<string>();
|
|
12
|
+
const languages = new Set<string>();
|
|
13
|
+
const frameworks = new Set<string>();
|
|
14
|
+
|
|
15
|
+
for (const file of files) {
|
|
16
|
+
const ext = file.split('.').pop()?.toLowerCase() || '';
|
|
17
|
+
extensions.add(ext);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ── Language Detection ──
|
|
21
|
+
if (extensions.has('py')) languages.add('Python');
|
|
22
|
+
if (extensions.has('ts') || extensions.has('tsx')) languages.add('TypeScript');
|
|
23
|
+
if (extensions.has('js') || extensions.has('jsx')) languages.add('JavaScript');
|
|
24
|
+
if (extensions.has('dart')) languages.add('Dart');
|
|
25
|
+
if (extensions.has('go')) languages.add('Go');
|
|
26
|
+
if (extensions.has('rs')) languages.add('Rust');
|
|
27
|
+
if (extensions.has('java') || extensions.has('kt')) languages.add('Java/Kotlin');
|
|
28
|
+
if (extensions.has('rb')) languages.add('Ruby');
|
|
29
|
+
if (extensions.has('php')) languages.add('PHP');
|
|
30
|
+
if (extensions.has('cs')) languages.add('C#');
|
|
31
|
+
|
|
32
|
+
// ── Framework Detection from file patterns ──
|
|
33
|
+
const allFiles = files.join(' ');
|
|
34
|
+
if (allFiles.includes('manage.py') || allFiles.includes('django')) frameworks.add('Django');
|
|
35
|
+
if (allFiles.includes('flask') || allFiles.includes('app.py')) frameworks.add('Flask');
|
|
36
|
+
if (allFiles.includes('fastapi')) frameworks.add('FastAPI');
|
|
37
|
+
if (allFiles.includes('.module.ts') || allFiles.includes('nest')) frameworks.add('NestJS');
|
|
38
|
+
if (allFiles.includes('.component.ts') || allFiles.includes('angular')) frameworks.add('Angular');
|
|
39
|
+
if (allFiles.includes('.vue')) frameworks.add('Vue');
|
|
40
|
+
if (allFiles.includes('.tsx') && allFiles.includes('next')) frameworks.add('Next.js');
|
|
41
|
+
if (allFiles.includes('.dart')) frameworks.add('Flutter');
|
|
42
|
+
if (allFiles.includes('go.mod')) frameworks.add('Go Modules');
|
|
43
|
+
if (allFiles.includes('Cargo.toml')) frameworks.add('Cargo');
|
|
44
|
+
if (allFiles.includes('pom.xml') || allFiles.includes('build.gradle')) frameworks.add('Spring');
|
|
45
|
+
if (allFiles.includes('rails') || allFiles.includes('Gemfile')) frameworks.add('Rails');
|
|
46
|
+
if (allFiles.includes('laravel') || allFiles.includes('artisan')) frameworks.add('Laravel');
|
|
47
|
+
|
|
48
|
+
// ── Derived Properties ──
|
|
49
|
+
const primary = languages.size > 0 ? [...languages][0] : 'Unknown';
|
|
50
|
+
|
|
51
|
+
const hasBackend = languages.has('Python') || languages.has('TypeScript') ||
|
|
52
|
+
languages.has('Go') || languages.has('Java/Kotlin') || languages.has('Ruby') ||
|
|
53
|
+
languages.has('PHP') || languages.has('C#') || languages.has('Rust');
|
|
54
|
+
|
|
55
|
+
const hasFrontend = frameworks.has('Angular') || frameworks.has('Vue') ||
|
|
56
|
+
frameworks.has('Next.js') || frameworks.has('React') || extensions.has('html');
|
|
57
|
+
|
|
58
|
+
const hasMobile = languages.has('Dart') || frameworks.has('Flutter');
|
|
59
|
+
|
|
60
|
+
const hasDatabase = allFiles.includes('migration') || allFiles.includes('entity') ||
|
|
61
|
+
allFiles.includes('model') || allFiles.includes('schema') ||
|
|
62
|
+
allFiles.includes('prisma') || allFiles.includes('typeorm');
|
|
63
|
+
|
|
64
|
+
const testFramework = this.detectTestFramework(languages, frameworks);
|
|
65
|
+
const packageManager = this.detectPackageManager(languages);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
primary,
|
|
69
|
+
languages: [...languages],
|
|
70
|
+
frameworks: [...frameworks],
|
|
71
|
+
hasBackend,
|
|
72
|
+
hasFrontend,
|
|
73
|
+
hasMobile,
|
|
74
|
+
hasDatabase,
|
|
75
|
+
testFramework,
|
|
76
|
+
packageManager,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private detectTestFramework(languages: Set<string>, frameworks: Set<string>): string {
|
|
81
|
+
if (languages.has('Dart')) return 'flutter_test';
|
|
82
|
+
if (languages.has('Python')) return 'pytest';
|
|
83
|
+
if (languages.has('Go')) return 'go test';
|
|
84
|
+
if (languages.has('Java/Kotlin')) return 'JUnit';
|
|
85
|
+
if (languages.has('Ruby')) return 'RSpec';
|
|
86
|
+
if (languages.has('C#')) return 'xUnit';
|
|
87
|
+
if (languages.has('Rust')) return 'cargo test';
|
|
88
|
+
if (frameworks.has('Angular')) return 'Jest + Jasmine';
|
|
89
|
+
return 'Jest';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private detectPackageManager(languages: Set<string>): string {
|
|
93
|
+
if (languages.has('Python')) return 'pip';
|
|
94
|
+
if (languages.has('Go')) return 'go mod';
|
|
95
|
+
if (languages.has('Dart')) return 'pub';
|
|
96
|
+
if (languages.has('Ruby')) return 'bundler';
|
|
97
|
+
if (languages.has('Java/Kotlin')) return 'gradle/maven';
|
|
98
|
+
if (languages.has('Rust')) return 'cargo';
|
|
99
|
+
if (languages.has('PHP')) return 'composer';
|
|
100
|
+
if (languages.has('C#')) return 'nuget';
|
|
101
|
+
return 'npm';
|
|
102
|
+
}
|
|
103
|
+
}
|