@girardelli/architect 2.2.0 → 5.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/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 +613 -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 +585 -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 +47 -0
- package/dist/agent-generator/index.d.ts.map +1 -0
- package/dist/agent-generator/index.js +545 -0
- package/dist/agent-generator/index.js.map +1 -0
- package/dist/agent-generator/stack-detector.d.ts +14 -0
- package/dist/agent-generator/stack-detector.d.ts.map +1 -0
- package/dist/agent-generator/stack-detector.js +124 -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 +1256 -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/hooks-generator.d.ts +21 -0
- package/dist/agent-generator/templates/core/hooks-generator.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/hooks-generator.js +233 -0
- package/dist/agent-generator/templates/core/hooks-generator.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 +19 -0
- package/dist/agent-generator/templates/core/skills-generator.d.ts.map +1 -0
- package/dist/agent-generator/templates/core/skills-generator.js +546 -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 +46 -5
- 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/anti-patterns.d.ts +7 -0
- package/dist/anti-patterns.d.ts.map +1 -1
- package/dist/anti-patterns.js +25 -6
- package/dist/anti-patterns.js.map +1 -1
- 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/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +48 -11
- package/dist/config.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 +38 -0
- package/dist/project-summarizer.d.ts.map +1 -0
- package/dist/project-summarizer.js +463 -0
- package/dist/project-summarizer.js.map +1 -0
- package/dist/refactor-reporter.js +1 -1
- package/dist/scanner.d.ts +8 -2
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +153 -113
- package/dist/scanner.js.map +1 -1
- package/dist/scorer.d.ts.map +1 -1
- package/dist/scorer.js +24 -11
- package/dist/scorer.js.map +1 -1
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -3
- package/src/agent-generator/context-enricher.ts +672 -0
- package/src/agent-generator/domain-inferrer.ts +635 -0
- package/src/agent-generator/framework-detector.ts +669 -0
- package/src/agent-generator/index.ts +634 -0
- package/src/agent-generator/stack-detector.ts +115 -0
- package/src/agent-generator/templates/core/agents.ts +1296 -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/hooks-generator.ts +242 -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 +585 -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 +51 -5
- 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/anti-patterns.ts +29 -6
- package/src/cli.ts +316 -117
- package/src/config.ts +52 -11
- package/src/html-reporter.ts +263 -13
- package/src/index.ts +93 -10
- package/src/project-summarizer.ts +521 -0
- package/src/refactor-reporter.ts +1 -1
- package/src/scanner.ts +136 -90
- package/src/scorer.ts +26 -11
- package/src/types.ts +27 -0
- package/tests/agent-generator.test.ts +427 -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/fixtures/monorepo/package.json +6 -0
- package/tests/fixtures/monorepo/packages/app/package.json +12 -0
- package/tests/fixtures/monorepo/packages/app/src/index.ts +6 -0
- package/tests/fixtures/monorepo/packages/core/package.json +7 -0
- package/tests/fixtures/monorepo/packages/core/src/index.ts +7 -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/monorepo-scan.test.ts +170 -0
- package/tests/scanner.test.ts +7 -8
- package/tests/scorer.test.ts +594 -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,40 @@
|
|
|
1
|
+
import { AnalysisReport } from '../types.js';
|
|
2
|
+
import { FrameworkInfo, DetectedToolchain } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* FrameworkDetector — Detects actual frameworks and toolchain from dependency files.
|
|
5
|
+
*
|
|
6
|
+
* Reads requirements.txt, pyproject.toml, package.json, pom.xml, build.gradle,
|
|
7
|
+
* composer.json, go.mod, Gemfile, pubspec.yaml, Cargo.toml, Makefile, etc.
|
|
8
|
+
*
|
|
9
|
+
* Returns structured framework info with versions, categories, and
|
|
10
|
+
* auto-detected toolchain commands (build, test, lint, run).
|
|
11
|
+
*/
|
|
12
|
+
export declare class FrameworkDetector {
|
|
13
|
+
private static readonly FRAMEWORK_MAP;
|
|
14
|
+
/**
|
|
15
|
+
* Detect frameworks and toolchain from project path and report.
|
|
16
|
+
*/
|
|
17
|
+
detect(projectPath: string, report: AnalysisReport): {
|
|
18
|
+
frameworks: FrameworkInfo[];
|
|
19
|
+
primaryFramework: FrameworkInfo | null;
|
|
20
|
+
toolchain: DetectedToolchain;
|
|
21
|
+
projectStructure: 'clean-architecture' | 'mvc' | 'modular' | 'flat' | 'monorepo' | 'unknown';
|
|
22
|
+
};
|
|
23
|
+
private detectFromPython;
|
|
24
|
+
private parsePythonRequirements;
|
|
25
|
+
private parsePyprojectToml;
|
|
26
|
+
private detectFromNodejs;
|
|
27
|
+
private detectFromJava;
|
|
28
|
+
private detectFromPhp;
|
|
29
|
+
private detectFromGo;
|
|
30
|
+
private detectFromRuby;
|
|
31
|
+
private detectFromDart;
|
|
32
|
+
private detectFromRust;
|
|
33
|
+
/**
|
|
34
|
+
* Detect build/test/lint/run commands based on project files.
|
|
35
|
+
*/
|
|
36
|
+
private detectToolchain;
|
|
37
|
+
private detectProjectStructure;
|
|
38
|
+
private safeReadFile;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=framework-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-detector.d.ts","sourceRoot":"","sources":["../../src/agent-generator/framework-detector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAM5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CA+EnC;IAMF;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG;QACnD,UAAU,EAAE,aAAa,EAAE,CAAC;QAC5B,gBAAgB,EAAE,aAAa,GAAG,IAAI,CAAC;QACvC,SAAS,EAAE,iBAAiB,CAAC;QAC7B,gBAAgB,EAAE,oBAAoB,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;KAC9F;IAuCD,OAAO,CAAC,gBAAgB;IAiCxB,OAAO,CAAC,uBAAuB;IAmB/B,OAAO,CAAC,kBAAkB;IAsE1B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,cAAc;IAgBtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAkLvB,OAAO,CAAC,sBAAsB;IAuC9B,OAAO,CAAC,YAAY;CAOrB"}
|
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* FrameworkDetector — Detects actual frameworks and toolchain from dependency files.
|
|
5
|
+
*
|
|
6
|
+
* Reads requirements.txt, pyproject.toml, package.json, pom.xml, build.gradle,
|
|
7
|
+
* composer.json, go.mod, Gemfile, pubspec.yaml, Cargo.toml, Makefile, etc.
|
|
8
|
+
*
|
|
9
|
+
* Returns structured framework info with versions, categories, and
|
|
10
|
+
* auto-detected toolchain commands (build, test, lint, run).
|
|
11
|
+
*/
|
|
12
|
+
export class FrameworkDetector {
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
14
|
+
// DETECTION — Main entry point
|
|
15
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
16
|
+
/**
|
|
17
|
+
* Detect frameworks and toolchain from project path and report.
|
|
18
|
+
*/
|
|
19
|
+
detect(projectPath, report) {
|
|
20
|
+
const frameworks = [];
|
|
21
|
+
// Try each dependency source
|
|
22
|
+
this.detectFromPython(projectPath, frameworks);
|
|
23
|
+
this.detectFromNodejs(projectPath, frameworks);
|
|
24
|
+
this.detectFromJava(projectPath, frameworks);
|
|
25
|
+
this.detectFromPhp(projectPath, frameworks);
|
|
26
|
+
this.detectFromGo(projectPath, frameworks);
|
|
27
|
+
this.detectFromRuby(projectPath, frameworks);
|
|
28
|
+
this.detectFromDart(projectPath, frameworks);
|
|
29
|
+
this.detectFromRust(projectPath, frameworks);
|
|
30
|
+
// Deduplicate by name
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const unique = frameworks.filter(f => {
|
|
33
|
+
if (seen.has(f.name))
|
|
34
|
+
return false;
|
|
35
|
+
seen.add(f.name);
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
// Sort: web frameworks first, then by confidence
|
|
39
|
+
unique.sort((a, b) => {
|
|
40
|
+
if (a.category === 'web' && b.category !== 'web')
|
|
41
|
+
return -1;
|
|
42
|
+
if (a.category !== 'web' && b.category === 'web')
|
|
43
|
+
return 1;
|
|
44
|
+
return b.confidence - a.confidence;
|
|
45
|
+
});
|
|
46
|
+
const primaryFramework = unique.find(f => f.category === 'web') || null;
|
|
47
|
+
const toolchain = this.detectToolchain(projectPath, report, primaryFramework, unique);
|
|
48
|
+
const projectStructure = this.detectProjectStructure(report);
|
|
49
|
+
return { frameworks: unique, primaryFramework, toolchain, projectStructure };
|
|
50
|
+
}
|
|
51
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
52
|
+
// PYTHON
|
|
53
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
54
|
+
detectFromPython(projectPath, out) {
|
|
55
|
+
// requirements.txt
|
|
56
|
+
const reqFiles = ['requirements.txt', 'requirements/base.txt', 'requirements/prod.txt'];
|
|
57
|
+
for (const reqFile of reqFiles) {
|
|
58
|
+
const path = join(projectPath, reqFile);
|
|
59
|
+
if (existsSync(path)) {
|
|
60
|
+
const content = this.safeReadFile(path);
|
|
61
|
+
this.parsePythonRequirements(content, out);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// pyproject.toml
|
|
65
|
+
const pyproject = join(projectPath, 'pyproject.toml');
|
|
66
|
+
if (existsSync(pyproject)) {
|
|
67
|
+
const content = this.safeReadFile(pyproject);
|
|
68
|
+
this.parsePyprojectToml(content, out);
|
|
69
|
+
}
|
|
70
|
+
// setup.py / setup.cfg
|
|
71
|
+
const setupPy = join(projectPath, 'setup.py');
|
|
72
|
+
if (existsSync(setupPy)) {
|
|
73
|
+
const content = this.safeReadFile(setupPy);
|
|
74
|
+
this.parsePythonRequirements(content, out);
|
|
75
|
+
}
|
|
76
|
+
// Pipfile
|
|
77
|
+
const pipfile = join(projectPath, 'Pipfile');
|
|
78
|
+
if (existsSync(pipfile)) {
|
|
79
|
+
const content = this.safeReadFile(pipfile);
|
|
80
|
+
this.parsePythonRequirements(content, out);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
parsePythonRequirements(content, out) {
|
|
84
|
+
const lines = content.toLowerCase().split('\n');
|
|
85
|
+
for (const line of lines) {
|
|
86
|
+
const cleaned = line.replace(/#.*$/, '').trim();
|
|
87
|
+
if (!cleaned)
|
|
88
|
+
continue;
|
|
89
|
+
// Match: package==1.0.0, package>=1.0, package~=1.0, package[extras]
|
|
90
|
+
const match = cleaned.match(/^([a-z0-9_-]+)(?:\[.*?\])?\s*(?:[=<>~!]+\s*([0-9][0-9.]*\S*))?/);
|
|
91
|
+
if (match) {
|
|
92
|
+
const pkg = match[1].replace(/-/g, '-');
|
|
93
|
+
const version = match[2] || null;
|
|
94
|
+
const fwInfo = FrameworkDetector.FRAMEWORK_MAP[pkg];
|
|
95
|
+
if (fwInfo) {
|
|
96
|
+
out.push({ name: fwInfo.name, version, category: fwInfo.category, confidence: 0.95 });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
parsePyprojectToml(content, out) {
|
|
102
|
+
// Strategy 1: [project.dependencies] section (legacy format)
|
|
103
|
+
const depSection = content.match(/\[(?:project\.)?dependencies\]([\s\S]*?)(?:\n\[|$)/);
|
|
104
|
+
if (depSection) {
|
|
105
|
+
this.parsePythonRequirements(depSection[1], out);
|
|
106
|
+
}
|
|
107
|
+
// Strategy 2: [project] section with inline `dependencies = [...]` (PEP 621 format)
|
|
108
|
+
// This is the standard pyproject.toml format used by most modern Python projects
|
|
109
|
+
const projectSection = content.match(/\[project\]\s*\n([\s\S]*?)(?:\n\[(?!project\.)|$)/);
|
|
110
|
+
if (projectSection) {
|
|
111
|
+
// Extract the dependencies array: dependencies = [ "pkg>=1.0", ... ]
|
|
112
|
+
const depsArrayMatch = projectSection[1].match(/dependencies\s*=\s*\[([\s\S]*?)\]/);
|
|
113
|
+
if (depsArrayMatch) {
|
|
114
|
+
// Extract quoted strings from the array
|
|
115
|
+
const deps = depsArrayMatch[1].match(/"([^"]+)"/g);
|
|
116
|
+
if (deps) {
|
|
117
|
+
const depsAsLines = deps.map(d => d.replace(/"/g, '')).join('\n');
|
|
118
|
+
this.parsePythonRequirements(depsAsLines, out);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Strategy 3: [project.optional-dependencies] sections (dev, test, etc.)
|
|
123
|
+
const optionalDeps = content.match(/\[project\.optional-dependencies\]\s*\n([\s\S]*?)(?:\n\[(?!project\.)|$)/);
|
|
124
|
+
if (optionalDeps) {
|
|
125
|
+
// Parse each group: dev = ["pkg>=1.0", ...], test = [...]
|
|
126
|
+
const groupMatches = optionalDeps[1].matchAll(/\w+\s*=\s*\[([\s\S]*?)\]/g);
|
|
127
|
+
for (const groupMatch of groupMatches) {
|
|
128
|
+
const deps = groupMatch[1].match(/"([^"]+)"/g);
|
|
129
|
+
if (deps) {
|
|
130
|
+
const depsAsLines = deps.map(d => d.replace(/"/g, '')).join('\n');
|
|
131
|
+
this.parsePythonRequirements(depsAsLines, out);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Strategy 4: tool.poetry.dependencies
|
|
136
|
+
const poetrySection = content.match(/\[tool\.poetry\.dependencies\]([\s\S]*?)(?:\n\[|$)/);
|
|
137
|
+
if (poetrySection) {
|
|
138
|
+
const lines = poetrySection[1].split('\n');
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
const match = line.match(/^([a-z0-9_-]+)\s*=\s*"?([^"]*)"?/i);
|
|
141
|
+
if (match) {
|
|
142
|
+
const pkg = match[1].toLowerCase();
|
|
143
|
+
const fwInfo = FrameworkDetector.FRAMEWORK_MAP[pkg];
|
|
144
|
+
if (fwInfo) {
|
|
145
|
+
const versionMatch = match[2].match(/([0-9][0-9.]*)/);
|
|
146
|
+
out.push({ name: fwInfo.name, version: versionMatch?.[1] || null, category: fwInfo.category, confidence: 0.95 });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Deduplicate by framework name (keep highest confidence)
|
|
152
|
+
const seen = new Map();
|
|
153
|
+
for (let i = out.length - 1; i >= 0; i--) {
|
|
154
|
+
const key = out[i].name;
|
|
155
|
+
if (seen.has(key)) {
|
|
156
|
+
out.splice(i, 1);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
seen.set(key, i);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
164
|
+
// NODE.JS / TypeScript
|
|
165
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
166
|
+
detectFromNodejs(projectPath, out) {
|
|
167
|
+
const pkgPath = join(projectPath, 'package.json');
|
|
168
|
+
if (!existsSync(pkgPath))
|
|
169
|
+
return;
|
|
170
|
+
const content = this.safeReadFile(pkgPath);
|
|
171
|
+
try {
|
|
172
|
+
const pkg = JSON.parse(content);
|
|
173
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
174
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
175
|
+
const fwInfo = FrameworkDetector.FRAMEWORK_MAP[name];
|
|
176
|
+
if (fwInfo) {
|
|
177
|
+
const vStr = typeof version === 'string' ? version : '';
|
|
178
|
+
const vMatch = vStr.match(/([0-9][0-9.]*)/);
|
|
179
|
+
out.push({ name: fwInfo.name, version: vMatch?.[1] || null, category: fwInfo.category, confidence: 0.95 });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// Invalid JSON
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
188
|
+
// JAVA / Kotlin
|
|
189
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
190
|
+
detectFromJava(projectPath, out) {
|
|
191
|
+
// pom.xml
|
|
192
|
+
const pomPath = join(projectPath, 'pom.xml');
|
|
193
|
+
if (existsSync(pomPath)) {
|
|
194
|
+
const content = this.safeReadFile(pomPath);
|
|
195
|
+
const deps = content.match(/<artifactId>([^<]+)<\/artifactId>/gi) || [];
|
|
196
|
+
for (const dep of deps) {
|
|
197
|
+
const match = dep.match(/<artifactId>([^<]+)<\/artifactId>/i);
|
|
198
|
+
if (match) {
|
|
199
|
+
const artifact = match[1].toLowerCase();
|
|
200
|
+
const fwInfo = FrameworkDetector.FRAMEWORK_MAP[artifact];
|
|
201
|
+
if (fwInfo) {
|
|
202
|
+
out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.85 });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// build.gradle / build.gradle.kts
|
|
208
|
+
for (const gradleFile of ['build.gradle', 'build.gradle.kts']) {
|
|
209
|
+
const gradlePath = join(projectPath, gradleFile);
|
|
210
|
+
if (existsSync(gradlePath)) {
|
|
211
|
+
const content = this.safeReadFile(gradlePath);
|
|
212
|
+
if (content.includes('spring-boot')) {
|
|
213
|
+
out.push({ name: 'Spring Boot', version: null, category: 'web', confidence: 0.9 });
|
|
214
|
+
}
|
|
215
|
+
if (content.includes('quarkus')) {
|
|
216
|
+
out.push({ name: 'Quarkus', version: null, category: 'web', confidence: 0.9 });
|
|
217
|
+
}
|
|
218
|
+
if (content.includes('micronaut')) {
|
|
219
|
+
out.push({ name: 'Micronaut', version: null, category: 'web', confidence: 0.9 });
|
|
220
|
+
}
|
|
221
|
+
if (content.includes('ktor')) {
|
|
222
|
+
out.push({ name: 'Ktor', version: null, category: 'web', confidence: 0.9 });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
228
|
+
// PHP
|
|
229
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
230
|
+
detectFromPhp(projectPath, out) {
|
|
231
|
+
const composerPath = join(projectPath, 'composer.json');
|
|
232
|
+
if (!existsSync(composerPath))
|
|
233
|
+
return;
|
|
234
|
+
const content = this.safeReadFile(composerPath);
|
|
235
|
+
try {
|
|
236
|
+
const pkg = JSON.parse(content);
|
|
237
|
+
const allDeps = { ...pkg.require, ...pkg['require-dev'] };
|
|
238
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
239
|
+
const fwInfo = FrameworkDetector.FRAMEWORK_MAP[name];
|
|
240
|
+
if (fwInfo) {
|
|
241
|
+
const vStr = typeof version === 'string' ? version : '';
|
|
242
|
+
const vMatch = vStr.match(/([0-9][0-9.]*)/);
|
|
243
|
+
out.push({ name: fwInfo.name, version: vMatch?.[1] || null, category: fwInfo.category, confidence: 0.9 });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// Invalid JSON
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
252
|
+
// Go
|
|
253
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
254
|
+
detectFromGo(projectPath, out) {
|
|
255
|
+
const goModPath = join(projectPath, 'go.mod');
|
|
256
|
+
if (!existsSync(goModPath))
|
|
257
|
+
return;
|
|
258
|
+
const content = this.safeReadFile(goModPath);
|
|
259
|
+
const lines = content.split('\n');
|
|
260
|
+
for (const line of lines) {
|
|
261
|
+
const match = line.match(/^\s*(github\.com\/[^\s]+)/);
|
|
262
|
+
if (match) {
|
|
263
|
+
const modPath = match[1].toLowerCase();
|
|
264
|
+
for (const [key, fwInfo] of Object.entries(FrameworkDetector.FRAMEWORK_MAP)) {
|
|
265
|
+
if (modPath.includes(key.toLowerCase())) {
|
|
266
|
+
out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.9 });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
273
|
+
// Ruby
|
|
274
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
275
|
+
detectFromRuby(projectPath, out) {
|
|
276
|
+
const gemfilePath = join(projectPath, 'Gemfile');
|
|
277
|
+
if (!existsSync(gemfilePath))
|
|
278
|
+
return;
|
|
279
|
+
const content = this.safeReadFile(gemfilePath);
|
|
280
|
+
if (content.includes("'rails'") || content.includes('"rails"')) {
|
|
281
|
+
const vMatch = content.match(/['"]rails['"],\s*['"]~?>\s*([0-9.]+)['"]/);
|
|
282
|
+
out.push({ name: 'Ruby on Rails', version: vMatch?.[1] || null, category: 'web', confidence: 0.95 });
|
|
283
|
+
}
|
|
284
|
+
if (content.includes("'sinatra'") || content.includes('"sinatra"')) {
|
|
285
|
+
out.push({ name: 'Sinatra', category: 'web', version: null, confidence: 0.9 });
|
|
286
|
+
}
|
|
287
|
+
if (content.includes("'rspec'") || content.includes('"rspec"')) {
|
|
288
|
+
out.push({ name: 'RSpec', category: 'test', version: null, confidence: 0.9 });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
292
|
+
// Dart / Flutter
|
|
293
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
294
|
+
detectFromDart(projectPath, out) {
|
|
295
|
+
const pubspecPath = join(projectPath, 'pubspec.yaml');
|
|
296
|
+
if (!existsSync(pubspecPath))
|
|
297
|
+
return;
|
|
298
|
+
const content = this.safeReadFile(pubspecPath);
|
|
299
|
+
if (content.includes('flutter:')) {
|
|
300
|
+
out.push({ name: 'Flutter', version: null, category: 'web', confidence: 0.95 });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
304
|
+
// Rust
|
|
305
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
306
|
+
detectFromRust(projectPath, out) {
|
|
307
|
+
const cargoPath = join(projectPath, 'Cargo.toml');
|
|
308
|
+
if (!existsSync(cargoPath))
|
|
309
|
+
return;
|
|
310
|
+
const content = this.safeReadFile(cargoPath);
|
|
311
|
+
for (const [key, fwInfo] of Object.entries(FrameworkDetector.FRAMEWORK_MAP)) {
|
|
312
|
+
if (content.includes(`"${key}"`) || content.includes(`'${key}'`) || content.includes(`${key} =`)) {
|
|
313
|
+
out.push({ name: fwInfo.name, version: null, category: fwInfo.category, confidence: 0.85 });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
318
|
+
// TOOLCHAIN DETECTION
|
|
319
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
320
|
+
/**
|
|
321
|
+
* Detect build/test/lint/run commands based on project files.
|
|
322
|
+
*/
|
|
323
|
+
detectToolchain(projectPath, report, primaryFw, allFrameworks) {
|
|
324
|
+
const lang = report.projectInfo.primaryLanguages[0] || 'Unknown';
|
|
325
|
+
const hasMakefile = existsSync(join(projectPath, 'Makefile'));
|
|
326
|
+
const hasDockerCompose = existsSync(join(projectPath, 'docker-compose.yml')) || existsSync(join(projectPath, 'docker-compose.yaml'));
|
|
327
|
+
const hasTest = (name) => allFrameworks.some(f => f.name === name);
|
|
328
|
+
const hasLint = (name) => allFrameworks.some(f => f.name === name && f.category === 'lint');
|
|
329
|
+
// Python
|
|
330
|
+
if (lang === 'Python') {
|
|
331
|
+
const fwName = primaryFw?.name || 'Python';
|
|
332
|
+
const hasPytest = hasTest('pytest');
|
|
333
|
+
const hasRuff = hasLint('Ruff');
|
|
334
|
+
const hasPoetry = existsSync(join(projectPath, 'poetry.lock'));
|
|
335
|
+
const hasPipenv = existsSync(join(projectPath, 'Pipfile.lock'));
|
|
336
|
+
let runCmd = 'python -m main';
|
|
337
|
+
if (fwName === 'FastAPI')
|
|
338
|
+
runCmd = 'uvicorn app.main:app --reload';
|
|
339
|
+
else if (fwName === 'Django')
|
|
340
|
+
runCmd = 'python manage.py runserver';
|
|
341
|
+
else if (fwName === 'Flask')
|
|
342
|
+
runCmd = 'flask run --debug';
|
|
343
|
+
let installCmd = 'pip install -r requirements.txt';
|
|
344
|
+
if (hasPoetry)
|
|
345
|
+
installCmd = 'poetry install';
|
|
346
|
+
else if (hasPipenv)
|
|
347
|
+
installCmd = 'pipenv install';
|
|
348
|
+
return {
|
|
349
|
+
buildCmd: hasMakefile ? 'make build' : (fwName === 'Django' ? 'python manage.py check' : 'python -m py_compile main.py'),
|
|
350
|
+
testCmd: hasPytest ? 'pytest' : 'python -m unittest discover',
|
|
351
|
+
lintCmd: hasRuff ? 'ruff check .' : (hasLint('Flake8') ? 'flake8 .' : (hasLint('Pylint') ? 'pylint src/' : 'ruff check .')),
|
|
352
|
+
runCmd,
|
|
353
|
+
coverageCmd: hasPytest ? 'pytest --cov' : 'coverage run -m pytest',
|
|
354
|
+
installCmd,
|
|
355
|
+
migrateCmd: fwName === 'Django' ? 'python manage.py migrate' : (fwName === 'FastAPI' ? 'alembic upgrade head' : null),
|
|
356
|
+
depsFile: hasPoetry ? 'pyproject.toml' : (hasPipenv ? 'Pipfile' : 'requirements.txt'),
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
// TypeScript / JavaScript
|
|
360
|
+
if (lang === 'TypeScript' || lang === 'JavaScript') {
|
|
361
|
+
const hasYarn = existsSync(join(projectPath, 'yarn.lock'));
|
|
362
|
+
const hasPnpm = existsSync(join(projectPath, 'pnpm-lock.yaml'));
|
|
363
|
+
const pm = hasPnpm ? 'pnpm' : (hasYarn ? 'yarn' : 'npm');
|
|
364
|
+
return {
|
|
365
|
+
buildCmd: `${pm} run build`,
|
|
366
|
+
testCmd: hasTest('Vitest') ? `${pm} run test` : (hasTest('Jest') ? `${pm} test` : `${pm} test`),
|
|
367
|
+
lintCmd: hasLint('Biome') ? `${pm} run lint` : (hasLint('ESLint') ? `${pm} run lint` : 'npx eslint .'),
|
|
368
|
+
runCmd: `${pm} run dev`,
|
|
369
|
+
coverageCmd: `${pm} run test -- --coverage`,
|
|
370
|
+
installCmd: `${pm} install`,
|
|
371
|
+
migrateCmd: primaryFw?.name === 'NestJS' ? 'npx typeorm migration:run' : null,
|
|
372
|
+
depsFile: 'package.json',
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
// Java / Kotlin
|
|
376
|
+
if (lang === 'Java' || lang === 'Kotlin') {
|
|
377
|
+
const hasMaven = existsSync(join(projectPath, 'pom.xml'));
|
|
378
|
+
const hasGradle = existsSync(join(projectPath, 'build.gradle')) || existsSync(join(projectPath, 'build.gradle.kts'));
|
|
379
|
+
if (hasMaven) {
|
|
380
|
+
return {
|
|
381
|
+
buildCmd: 'mvn clean package',
|
|
382
|
+
testCmd: 'mvn test',
|
|
383
|
+
lintCmd: 'mvn checkstyle:check',
|
|
384
|
+
runCmd: 'mvn spring-boot:run',
|
|
385
|
+
coverageCmd: 'mvn jacoco:report',
|
|
386
|
+
installCmd: 'mvn install',
|
|
387
|
+
migrateCmd: 'mvn flyway:migrate',
|
|
388
|
+
depsFile: 'pom.xml',
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
if (hasGradle) {
|
|
392
|
+
return {
|
|
393
|
+
buildCmd: './gradlew build',
|
|
394
|
+
testCmd: './gradlew test',
|
|
395
|
+
lintCmd: './gradlew check',
|
|
396
|
+
runCmd: './gradlew bootRun',
|
|
397
|
+
coverageCmd: './gradlew jacocoTestReport',
|
|
398
|
+
installCmd: './gradlew dependencies',
|
|
399
|
+
migrateCmd: './gradlew flywayMigrate',
|
|
400
|
+
depsFile: existsSync(join(projectPath, 'build.gradle.kts')) ? 'build.gradle.kts' : 'build.gradle',
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// PHP
|
|
405
|
+
if (lang === 'PHP') {
|
|
406
|
+
return {
|
|
407
|
+
buildCmd: 'composer install --no-dev',
|
|
408
|
+
testCmd: primaryFw?.name === 'Laravel' ? 'php artisan test' : 'vendor/bin/phpunit',
|
|
409
|
+
lintCmd: 'vendor/bin/phpstan analyse',
|
|
410
|
+
runCmd: primaryFw?.name === 'Laravel' ? 'php artisan serve' : 'php -S localhost:8000',
|
|
411
|
+
coverageCmd: 'vendor/bin/phpunit --coverage-text',
|
|
412
|
+
installCmd: 'composer install',
|
|
413
|
+
migrateCmd: primaryFw?.name === 'Laravel' ? 'php artisan migrate' : null,
|
|
414
|
+
depsFile: 'composer.json',
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
// Go
|
|
418
|
+
if (lang === 'Go') {
|
|
419
|
+
return {
|
|
420
|
+
buildCmd: 'go build ./...',
|
|
421
|
+
testCmd: 'go test ./...',
|
|
422
|
+
lintCmd: 'golangci-lint run',
|
|
423
|
+
runCmd: 'go run .',
|
|
424
|
+
coverageCmd: 'go test -coverprofile=coverage.out ./...',
|
|
425
|
+
installCmd: 'go mod download',
|
|
426
|
+
migrateCmd: null,
|
|
427
|
+
depsFile: 'go.mod',
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
// Ruby
|
|
431
|
+
if (lang === 'Ruby') {
|
|
432
|
+
return {
|
|
433
|
+
buildCmd: 'bundle exec rake build',
|
|
434
|
+
testCmd: hasTest('RSpec') ? 'bundle exec rspec' : 'bundle exec rake test',
|
|
435
|
+
lintCmd: 'bundle exec rubocop',
|
|
436
|
+
runCmd: primaryFw?.name === 'Ruby on Rails' ? 'rails server' : 'ruby app.rb',
|
|
437
|
+
coverageCmd: 'bundle exec rspec --format documentation',
|
|
438
|
+
installCmd: 'bundle install',
|
|
439
|
+
migrateCmd: primaryFw?.name === 'Ruby on Rails' ? 'rails db:migrate' : null,
|
|
440
|
+
depsFile: 'Gemfile',
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
// Dart
|
|
444
|
+
if (lang === 'Dart') {
|
|
445
|
+
return {
|
|
446
|
+
buildCmd: 'flutter build',
|
|
447
|
+
testCmd: 'flutter test',
|
|
448
|
+
lintCmd: 'dart analyze',
|
|
449
|
+
runCmd: 'flutter run',
|
|
450
|
+
coverageCmd: 'flutter test --coverage',
|
|
451
|
+
installCmd: 'flutter pub get',
|
|
452
|
+
migrateCmd: null,
|
|
453
|
+
depsFile: 'pubspec.yaml',
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
// Rust
|
|
457
|
+
if (lang === 'Rust') {
|
|
458
|
+
return {
|
|
459
|
+
buildCmd: 'cargo build',
|
|
460
|
+
testCmd: 'cargo test',
|
|
461
|
+
lintCmd: 'cargo clippy',
|
|
462
|
+
runCmd: 'cargo run',
|
|
463
|
+
coverageCmd: 'cargo tarpaulin',
|
|
464
|
+
installCmd: 'cargo build',
|
|
465
|
+
migrateCmd: null,
|
|
466
|
+
depsFile: 'Cargo.toml',
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
// Fallback
|
|
470
|
+
return {
|
|
471
|
+
buildCmd: hasMakefile ? 'make build' : 'echo "No build command detected"',
|
|
472
|
+
testCmd: hasMakefile ? 'make test' : 'echo "No test command detected"',
|
|
473
|
+
lintCmd: hasMakefile ? 'make lint' : 'echo "No lint command detected"',
|
|
474
|
+
runCmd: hasMakefile ? 'make run' : 'echo "No run command detected"',
|
|
475
|
+
coverageCmd: 'echo "No coverage command detected"',
|
|
476
|
+
installCmd: 'echo "No install command detected"',
|
|
477
|
+
migrateCmd: null,
|
|
478
|
+
depsFile: 'unknown',
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
482
|
+
// PROJECT STRUCTURE DETECTION
|
|
483
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
484
|
+
detectProjectStructure(report) {
|
|
485
|
+
const paths = report.dependencyGraph.nodes.map(n => n.toLowerCase());
|
|
486
|
+
// Clean Architecture / DDD
|
|
487
|
+
const hasDomain = paths.some(p => p.includes('/domain/'));
|
|
488
|
+
const hasApplication = paths.some(p => p.includes('/application/'));
|
|
489
|
+
const hasInfrastructure = paths.some(p => p.includes('/infrastructure/'));
|
|
490
|
+
const hasPresentation = paths.some(p => p.includes('/presentation/'));
|
|
491
|
+
if ((hasDomain && hasInfrastructure) || (hasDomain && hasApplication && hasPresentation)) {
|
|
492
|
+
return 'clean-architecture';
|
|
493
|
+
}
|
|
494
|
+
// MVC
|
|
495
|
+
const hasModels = paths.some(p => p.includes('/models/'));
|
|
496
|
+
const hasViews = paths.some(p => p.includes('/views/'));
|
|
497
|
+
const hasControllers = paths.some(p => p.includes('/controllers/'));
|
|
498
|
+
if (hasModels && hasViews && hasControllers)
|
|
499
|
+
return 'mvc';
|
|
500
|
+
// Modular (NestJS, feature-based)
|
|
501
|
+
const hasModules = paths.some(p => p.includes('/modules/'));
|
|
502
|
+
const hasFeatures = paths.some(p => p.includes('/features/'));
|
|
503
|
+
if (hasModules || hasFeatures)
|
|
504
|
+
return 'modular';
|
|
505
|
+
// Monorepo
|
|
506
|
+
const hasPackages = paths.some(p => p.includes('/packages/'));
|
|
507
|
+
const hasApps = paths.some(p => p.includes('/apps/'));
|
|
508
|
+
if (hasPackages || hasApps)
|
|
509
|
+
return 'monorepo';
|
|
510
|
+
// Flat
|
|
511
|
+
const maxDepth = Math.max(...paths.map(p => p.split('/').length));
|
|
512
|
+
if (maxDepth <= 3)
|
|
513
|
+
return 'flat';
|
|
514
|
+
return 'unknown';
|
|
515
|
+
}
|
|
516
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
517
|
+
// UTILS
|
|
518
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
519
|
+
safeReadFile(path) {
|
|
520
|
+
try {
|
|
521
|
+
return readFileSync(path, 'utf-8');
|
|
522
|
+
}
|
|
523
|
+
catch {
|
|
524
|
+
return '';
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
529
|
+
// FRAMEWORK PATTERNS — Maps dependency names to framework metadata
|
|
530
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
531
|
+
FrameworkDetector.FRAMEWORK_MAP = {
|
|
532
|
+
// Python Web
|
|
533
|
+
'fastapi': { name: 'FastAPI', category: 'web' },
|
|
534
|
+
'django': { name: 'Django', category: 'web' },
|
|
535
|
+
'flask': { name: 'Flask', category: 'web' },
|
|
536
|
+
'starlette': { name: 'Starlette', category: 'web' },
|
|
537
|
+
'tornado': { name: 'Tornado', category: 'web' },
|
|
538
|
+
'sanic': { name: 'Sanic', category: 'web' },
|
|
539
|
+
'aiohttp': { name: 'aiohttp', category: 'web' },
|
|
540
|
+
'litestar': { name: 'Litestar', category: 'web' },
|
|
541
|
+
// Python ORM
|
|
542
|
+
'sqlalchemy': { name: 'SQLAlchemy', category: 'orm' },
|
|
543
|
+
'tortoise-orm': { name: 'Tortoise ORM', category: 'orm' },
|
|
544
|
+
'peewee': { name: 'Peewee', category: 'orm' },
|
|
545
|
+
'sqlmodel': { name: 'SQLModel', category: 'orm' },
|
|
546
|
+
'prisma': { name: 'Prisma', category: 'orm' },
|
|
547
|
+
'django-rest-framework': { name: 'DRF', category: 'web' },
|
|
548
|
+
'djangorestframework': { name: 'DRF', category: 'web' },
|
|
549
|
+
// Python Test
|
|
550
|
+
'pytest': { name: 'pytest', category: 'test' },
|
|
551
|
+
'unittest': { name: 'unittest', category: 'test' },
|
|
552
|
+
'hypothesis': { name: 'Hypothesis', category: 'test' },
|
|
553
|
+
// Python Lint
|
|
554
|
+
'ruff': { name: 'Ruff', category: 'lint' },
|
|
555
|
+
'flake8': { name: 'Flake8', category: 'lint' },
|
|
556
|
+
'pylint': { name: 'Pylint', category: 'lint' },
|
|
557
|
+
'black': { name: 'Black', category: 'lint' },
|
|
558
|
+
'mypy': { name: 'mypy', category: 'lint' },
|
|
559
|
+
// Node.js Web
|
|
560
|
+
'@nestjs/core': { name: 'NestJS', category: 'web' },
|
|
561
|
+
'express': { name: 'Express', category: 'web' },
|
|
562
|
+
'fastify': { name: 'Fastify', category: 'web' },
|
|
563
|
+
'koa': { name: 'Koa', category: 'web' },
|
|
564
|
+
'hapi': { name: 'Hapi', category: 'web' },
|
|
565
|
+
'@hapi/hapi': { name: 'Hapi', category: 'web' },
|
|
566
|
+
'next': { name: 'Next.js', category: 'web' },
|
|
567
|
+
'nuxt': { name: 'Nuxt', category: 'web' },
|
|
568
|
+
// Node.js ORM
|
|
569
|
+
'typeorm': { name: 'TypeORM', category: 'orm' },
|
|
570
|
+
'@prisma/client': { name: 'Prisma', category: 'orm' },
|
|
571
|
+
'sequelize': { name: 'Sequelize', category: 'orm' },
|
|
572
|
+
'mongoose': { name: 'Mongoose', category: 'orm' },
|
|
573
|
+
'knex': { name: 'Knex', category: 'orm' },
|
|
574
|
+
'drizzle-orm': { name: 'Drizzle', category: 'orm' },
|
|
575
|
+
// Node.js Test
|
|
576
|
+
'jest': { name: 'Jest', category: 'test' },
|
|
577
|
+
'vitest': { name: 'Vitest', category: 'test' },
|
|
578
|
+
'mocha': { name: 'Mocha', category: 'test' },
|
|
579
|
+
// Node.js Lint
|
|
580
|
+
'eslint': { name: 'ESLint', category: 'lint' },
|
|
581
|
+
'biome': { name: 'Biome', category: 'lint' },
|
|
582
|
+
'@biomejs/biome': { name: 'Biome', category: 'lint' },
|
|
583
|
+
'prettier': { name: 'Prettier', category: 'lint' },
|
|
584
|
+
// Java/Kotlin
|
|
585
|
+
'spring-boot-starter-web': { name: 'Spring Boot', category: 'web' },
|
|
586
|
+
'spring-boot-starter': { name: 'Spring Boot', category: 'web' },
|
|
587
|
+
'quarkus': { name: 'Quarkus', category: 'web' },
|
|
588
|
+
'micronaut': { name: 'Micronaut', category: 'web' },
|
|
589
|
+
'ktor': { name: 'Ktor', category: 'web' },
|
|
590
|
+
// PHP
|
|
591
|
+
'laravel/framework': { name: 'Laravel', category: 'web' },
|
|
592
|
+
'symfony/framework-bundle': { name: 'Symfony', category: 'web' },
|
|
593
|
+
'slim/slim': { name: 'Slim', category: 'web' },
|
|
594
|
+
// Ruby
|
|
595
|
+
'rails': { name: 'Ruby on Rails', category: 'web' },
|
|
596
|
+
// Go — detected from imports
|
|
597
|
+
'gin-gonic/gin': { name: 'Gin', category: 'web' },
|
|
598
|
+
'labstack/echo': { name: 'Echo', category: 'web' },
|
|
599
|
+
'gofiber/fiber': { name: 'Fiber', category: 'web' },
|
|
600
|
+
'gorilla/mux': { name: 'Gorilla Mux', category: 'web' },
|
|
601
|
+
'go-chi/chi': { name: 'Chi', category: 'web' },
|
|
602
|
+
// Dart/Flutter
|
|
603
|
+
'flutter': { name: 'Flutter', category: 'web' },
|
|
604
|
+
'shelf': { name: 'Shelf', category: 'web' },
|
|
605
|
+
'dart_frog': { name: 'Dart Frog', category: 'web' },
|
|
606
|
+
// Rust
|
|
607
|
+
'actix-web': { name: 'Actix Web', category: 'web' },
|
|
608
|
+
'rocket': { name: 'Rocket', category: 'web' },
|
|
609
|
+
'axum': { name: 'Axum', category: 'web' },
|
|
610
|
+
};
|
|
611
|
+
//# sourceMappingURL=framework-detector.js.map
|