@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,347 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, basename, dirname } from 'path';
|
|
3
|
+
import { AnalysisReport, ProjectSummary, FileNode } from './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ProjectSummarizer — infers what a project does from its metadata,
|
|
7
|
+
* structure, README, package.json, and file naming conventions.
|
|
8
|
+
*/
|
|
9
|
+
export class ProjectSummarizer {
|
|
10
|
+
summarize(projectPath: string, report: AnalysisReport): ProjectSummary {
|
|
11
|
+
const packageInfo = this.readPackageJson(projectPath);
|
|
12
|
+
const readmeContent = this.readReadme(projectPath);
|
|
13
|
+
const modules = this.inferModules(report);
|
|
14
|
+
const entryPoints = this.findEntryPoints(report);
|
|
15
|
+
const keywords = this.extractKeywords(packageInfo, readmeContent, modules, report);
|
|
16
|
+
const techStack = this.buildTechStack(report, packageInfo);
|
|
17
|
+
const description = this.buildDescription(packageInfo, readmeContent, report);
|
|
18
|
+
const purpose = this.inferPurpose(keywords, modules, report);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
description,
|
|
22
|
+
purpose,
|
|
23
|
+
modules,
|
|
24
|
+
techStack,
|
|
25
|
+
entryPoints,
|
|
26
|
+
keywords,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ── Package.json ──
|
|
31
|
+
|
|
32
|
+
private readPackageJson(projectPath: string): Record<string, unknown> {
|
|
33
|
+
const candidates = [
|
|
34
|
+
join(projectPath, 'package.json'),
|
|
35
|
+
join(projectPath, 'pyproject.toml'),
|
|
36
|
+
join(projectPath, 'pubspec.yaml'),
|
|
37
|
+
join(projectPath, 'Cargo.toml'),
|
|
38
|
+
join(projectPath, 'pom.xml'),
|
|
39
|
+
join(projectPath, 'build.gradle'),
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
for (const candidate of candidates) {
|
|
43
|
+
if (existsSync(candidate)) {
|
|
44
|
+
try {
|
|
45
|
+
if (candidate.endsWith('.json')) {
|
|
46
|
+
return JSON.parse(readFileSync(candidate, 'utf-8'));
|
|
47
|
+
}
|
|
48
|
+
// For non-JSON, return raw content as 'raw' field
|
|
49
|
+
return { raw: readFileSync(candidate, 'utf-8'), type: basename(candidate) };
|
|
50
|
+
} catch {
|
|
51
|
+
// ignore
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private readReadme(projectPath: string): string {
|
|
59
|
+
const candidates = ['README.md', 'readme.md', 'README.txt', 'README', 'README.rst'];
|
|
60
|
+
for (const name of candidates) {
|
|
61
|
+
const path = join(projectPath, name);
|
|
62
|
+
if (existsSync(path)) {
|
|
63
|
+
try {
|
|
64
|
+
// Read first 3000 chars — enough for description, skip excessive content
|
|
65
|
+
return readFileSync(path, 'utf-8').slice(0, 3000);
|
|
66
|
+
} catch {
|
|
67
|
+
// ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ── Module Inference ──
|
|
75
|
+
|
|
76
|
+
private inferModules(report: AnalysisReport): ProjectSummary['modules'] {
|
|
77
|
+
const modules: Map<string, { files: Set<string>; hints: Set<string> }> = new Map();
|
|
78
|
+
|
|
79
|
+
for (const node of report.dependencyGraph.nodes) {
|
|
80
|
+
const parts = node.split('/');
|
|
81
|
+
// Skip root-level files
|
|
82
|
+
if (parts.length < 2) continue;
|
|
83
|
+
|
|
84
|
+
// Get the module directory (2nd level, or 1st level for flat projects)
|
|
85
|
+
let moduleName: string;
|
|
86
|
+
const firstDir = parts[0];
|
|
87
|
+
|
|
88
|
+
// Common source directories — go one level deeper
|
|
89
|
+
if (['src', 'lib', 'app', 'packages', 'modules', 'features', 'apps'].includes(firstDir)) {
|
|
90
|
+
moduleName = parts.length > 2 ? parts[1] : firstDir;
|
|
91
|
+
} else if (firstDir === 'tests' || firstDir === 'test' || firstDir === '__tests__') {
|
|
92
|
+
continue; // Skip test directories for module inference
|
|
93
|
+
} else {
|
|
94
|
+
moduleName = firstDir;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!modules.has(moduleName)) {
|
|
98
|
+
modules.set(moduleName, { files: new Set(), hints: new Set() });
|
|
99
|
+
}
|
|
100
|
+
const mod = modules.get(moduleName)!;
|
|
101
|
+
mod.files.add(node);
|
|
102
|
+
|
|
103
|
+
// Extract hints from filenames
|
|
104
|
+
const filename = basename(node).replace(/\.(ts|js|py|dart|go|java|rb|php|cs|tsx|jsx)$/, '');
|
|
105
|
+
if (filename !== 'index' && filename !== 'main' && filename !== '__init__') {
|
|
106
|
+
mod.hints.add(filename.toLowerCase());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return [...modules.entries()]
|
|
111
|
+
.filter(([, data]) => data.files.size > 0)
|
|
112
|
+
.sort((a, b) => b[1].files.size - a[1].files.size)
|
|
113
|
+
.slice(0, 15) // Top 15 modules
|
|
114
|
+
.map(([name, data]) => ({
|
|
115
|
+
name,
|
|
116
|
+
files: data.files.size,
|
|
117
|
+
description: this.describeModule(name, data.hints),
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private describeModule(name: string, hints: Set<string>): string {
|
|
122
|
+
const n = name.toLowerCase();
|
|
123
|
+
const h = [...hints].join(' ');
|
|
124
|
+
|
|
125
|
+
// Known module patterns
|
|
126
|
+
const patterns: [RegExp, string][] = [
|
|
127
|
+
[/auth/, 'Autenticação e autorização'],
|
|
128
|
+
[/user/, 'Gestão de usuários'],
|
|
129
|
+
[/payment|billing|charge|invoice/, 'Pagamentos e faturamento'],
|
|
130
|
+
[/order|cart|checkout/, 'Pedidos e checkout'],
|
|
131
|
+
[/product|catalog|item/, 'Catálogo de produtos'],
|
|
132
|
+
[/notif/, 'Sistema de notificações'],
|
|
133
|
+
[/email|mail|smtp/, 'Envio de emails'],
|
|
134
|
+
[/report|analytics|dashboard/, 'Relatórios e analytics'],
|
|
135
|
+
[/config|setting/, 'Configuração do sistema'],
|
|
136
|
+
[/util|helper|common|shared/, 'Utilitários compartilhados'],
|
|
137
|
+
[/middleware|interceptor|guard|pipe/, 'Middleware e interceptors'],
|
|
138
|
+
[/database|db|migration|seed/, 'Banco de dados e migrations'],
|
|
139
|
+
[/api|controller|route|endpoint/, 'API endpoints'],
|
|
140
|
+
[/service|business|domain/, 'Lógica de negócio'],
|
|
141
|
+
[/model|entity|schema/, 'Modelos de dados'],
|
|
142
|
+
[/test|spec|fixture/, 'Testes'],
|
|
143
|
+
[/validator|validation|sanitiz/, 'Validação de dados'],
|
|
144
|
+
[/security|crypto|encrypt/, 'Segurança e criptografia'],
|
|
145
|
+
[/cache|redis/, 'Cache e performance'],
|
|
146
|
+
[/queue|worker|job|task/, 'Processamento assíncrono'],
|
|
147
|
+
[/log|monitor|trace|metric/, 'Logging e monitoramento'],
|
|
148
|
+
[/file|upload|storage|s3/, 'Armazenamento de arquivos'],
|
|
149
|
+
[/search|elastic|index/, 'Busca e indexação'],
|
|
150
|
+
[/chat|message|websocket|socket/, 'Comunicação em tempo real'],
|
|
151
|
+
[/i18n|locale|translation/, 'Internacionalização'],
|
|
152
|
+
[/theme|style|design/, 'Design system e temas'],
|
|
153
|
+
[/component|widget|ui/, 'Componentes de UI'],
|
|
154
|
+
[/page|screen|view/, 'Páginas/telas'],
|
|
155
|
+
[/hook|composable/, 'Hooks/composables reutilizáveis'],
|
|
156
|
+
[/store|state|redux|bloc/, 'Gerenciamento de estado'],
|
|
157
|
+
[/navigation|router|routing/, 'Navegação e rotas'],
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
const combined = `${n} ${h}`;
|
|
161
|
+
for (const [regex, desc] of patterns) {
|
|
162
|
+
if (regex.test(combined)) return desc;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return `Módulo ${name}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ── Entry Points ──
|
|
169
|
+
|
|
170
|
+
private findEntryPoints(report: AnalysisReport): string[] {
|
|
171
|
+
const entryPatterns = [
|
|
172
|
+
/^(src\/)?(main|index|app|server|cli)\.(ts|js|py|dart|go|java)$/,
|
|
173
|
+
/^(src\/)?bin\//,
|
|
174
|
+
/manage\.py$/,
|
|
175
|
+
/^main\.go$/,
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
return report.dependencyGraph.nodes
|
|
179
|
+
.filter(node => entryPatterns.some(p => p.test(node)))
|
|
180
|
+
.slice(0, 5);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ── Keywords ──
|
|
184
|
+
|
|
185
|
+
private extractKeywords(
|
|
186
|
+
packageInfo: Record<string, unknown>,
|
|
187
|
+
readme: string,
|
|
188
|
+
modules: ProjectSummary['modules'],
|
|
189
|
+
report: AnalysisReport,
|
|
190
|
+
): string[] {
|
|
191
|
+
const keywords = new Set<string>();
|
|
192
|
+
|
|
193
|
+
// From package.json keywords
|
|
194
|
+
if (Array.isArray(packageInfo.keywords)) {
|
|
195
|
+
for (const kw of packageInfo.keywords) {
|
|
196
|
+
if (typeof kw === 'string') keywords.add(kw.toLowerCase());
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// From module names
|
|
201
|
+
for (const mod of modules) {
|
|
202
|
+
keywords.add(mod.name.toLowerCase());
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// From frameworks detected
|
|
206
|
+
for (const fw of report.projectInfo.frameworks) {
|
|
207
|
+
keywords.add(fw.toLowerCase());
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// From languages
|
|
211
|
+
for (const lang of report.projectInfo.primaryLanguages) {
|
|
212
|
+
keywords.add(lang.toLowerCase());
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Filter out generic words
|
|
216
|
+
const generic = new Set(['src', 'lib', 'app', 'utils', 'common', 'shared', 'core', 'index', 'main', 'dist', 'build']);
|
|
217
|
+
return [...keywords].filter(kw => !generic.has(kw) && kw.length > 1).slice(0, 20);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ── Tech Stack ──
|
|
221
|
+
|
|
222
|
+
private buildTechStack(report: AnalysisReport, packageInfo: Record<string, unknown>): string[] {
|
|
223
|
+
const stack: string[] = [];
|
|
224
|
+
|
|
225
|
+
// Languages
|
|
226
|
+
stack.push(...report.projectInfo.primaryLanguages);
|
|
227
|
+
|
|
228
|
+
// Frameworks from report
|
|
229
|
+
stack.push(...report.projectInfo.frameworks);
|
|
230
|
+
|
|
231
|
+
// Dependencies from package.json
|
|
232
|
+
const deps = { ...(packageInfo.dependencies as Record<string, string> || {}), ...(packageInfo.devDependencies as Record<string, string> || {}) };
|
|
233
|
+
const notable = [
|
|
234
|
+
'express', 'fastify', 'nestjs', '@nestjs/core', 'koa', 'hapi',
|
|
235
|
+
'react', 'next', 'angular', 'vue', 'svelte',
|
|
236
|
+
'prisma', '@prisma/client', 'typeorm', 'sequelize', 'mongoose', 'knex',
|
|
237
|
+
'jest', 'mocha', 'vitest', 'cypress', 'playwright',
|
|
238
|
+
'tailwindcss', 'styled-components', 'emotion',
|
|
239
|
+
'redis', 'ioredis', 'bull', 'bullmq',
|
|
240
|
+
'graphql', 'apollo', '@apollo/server',
|
|
241
|
+
'socket.io', 'ws',
|
|
242
|
+
'passport', 'jsonwebtoken', 'bcrypt',
|
|
243
|
+
'winston', 'pino',
|
|
244
|
+
'swagger', '@nestjs/swagger',
|
|
245
|
+
'docker', 'kubernetes',
|
|
246
|
+
'aws-sdk', '@aws-sdk',
|
|
247
|
+
'stripe', 'paypal',
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
for (const dep of Object.keys(deps)) {
|
|
251
|
+
const cleaned = dep.replace('@', '').split('/')[0];
|
|
252
|
+
if (notable.some(n => dep.includes(n))) {
|
|
253
|
+
if (!stack.some(s => s.toLowerCase() === cleaned.toLowerCase())) {
|
|
254
|
+
stack.push(dep);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return [...new Set(stack)].slice(0, 15);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ── Description Builder ──
|
|
263
|
+
|
|
264
|
+
private buildDescription(packageInfo: Record<string, unknown>, readme: string, report: AnalysisReport): string {
|
|
265
|
+
// Priority 1: package.json description
|
|
266
|
+
if (typeof packageInfo.description === 'string' && packageInfo.description.trim()) {
|
|
267
|
+
return packageInfo.description.trim();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Priority 2: First paragraph of README (skip badges, titles)
|
|
271
|
+
if (readme) {
|
|
272
|
+
const lines = readme.split('\n');
|
|
273
|
+
for (const line of lines) {
|
|
274
|
+
const trimmed = line.trim();
|
|
275
|
+
// Skip empty lines, headers, badges, links, HTML tags
|
|
276
|
+
if (!trimmed) continue;
|
|
277
|
+
if (trimmed.startsWith('#')) continue;
|
|
278
|
+
if (trimmed.startsWith('[!') || trimmed.startsWith('[![')) continue;
|
|
279
|
+
if (trimmed.startsWith('<')) continue;
|
|
280
|
+
if (trimmed.startsWith('---') || trimmed.startsWith('===')) continue;
|
|
281
|
+
if (trimmed.startsWith('![')) continue;
|
|
282
|
+
if (trimmed.length < 20) continue;
|
|
283
|
+
|
|
284
|
+
// Found a real text paragraph
|
|
285
|
+
return trimmed.slice(0, 300);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Priority 3: Infer from project name and structure
|
|
290
|
+
const name = report.projectInfo.name || 'Unknown';
|
|
291
|
+
const langs = report.projectInfo.primaryLanguages.join(', ');
|
|
292
|
+
const files = report.projectInfo.totalFiles;
|
|
293
|
+
return `Projeto ${name} — ${files} arquivos em ${langs}`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// ── Purpose Inference ──
|
|
297
|
+
|
|
298
|
+
private inferPurpose(
|
|
299
|
+
keywords: string[],
|
|
300
|
+
modules: ProjectSummary['modules'],
|
|
301
|
+
report: AnalysisReport,
|
|
302
|
+
): string {
|
|
303
|
+
const allSignals = [
|
|
304
|
+
...keywords,
|
|
305
|
+
...modules.map(m => m.name.toLowerCase()),
|
|
306
|
+
...modules.map(m => m.description.toLowerCase()),
|
|
307
|
+
...report.dependencyGraph.nodes.map(n => n.toLowerCase()),
|
|
308
|
+
].join(' ');
|
|
309
|
+
|
|
310
|
+
// Infer project type from signals
|
|
311
|
+
const types: [RegExp, string][] = [
|
|
312
|
+
[/api.*(rest|graph|endpoint)|controller.*route|swagger|openapi/, 'API Backend'],
|
|
313
|
+
[/cli|command.*line|bin\/|yargs|commander/, 'CLI Tool'],
|
|
314
|
+
[/component.*ui|react|angular|vue|frontend|page.*screen/, 'Frontend Application'],
|
|
315
|
+
[/mobile|flutter|dart|react.native|ionic/, 'Mobile App'],
|
|
316
|
+
[/library|lib|package|npm|pub|sdk|module/, 'Library / Package'],
|
|
317
|
+
[/test|spec|validator|lint|analyz|check/, 'Tool de Análise / Validação'],
|
|
318
|
+
[/microservice|service|worker|queue/, 'Microservice'],
|
|
319
|
+
[/monorepo|workspace|packages\//, 'Monorepo'],
|
|
320
|
+
[/bot|scraper|crawler|automation/, 'Bot / Automação'],
|
|
321
|
+
[/game|canvas|webgl|three/, 'Game / Visualização'],
|
|
322
|
+
[/e-?commerce|shop|cart|product|catalog/, 'E-commerce'],
|
|
323
|
+
[/blog|cms|content|post|article/, 'CMS / Blog'],
|
|
324
|
+
[/auth|login|oauth|sso|identity/, 'Sistema de Autenticação'],
|
|
325
|
+
[/chat|message|realtime|socket/, 'Comunicação Real-time'],
|
|
326
|
+
[/dashboard|admin|panel|analytics/, 'Dashboard / Admin Panel'],
|
|
327
|
+
[/payment|billing|fintech|finance|bank/, 'Fintech / Pagamentos'],
|
|
328
|
+
[/health|medical|patient|clinic/, 'Healthcare'],
|
|
329
|
+
[/education|course|learn|student/, 'EdTech'],
|
|
330
|
+
];
|
|
331
|
+
|
|
332
|
+
const matched: string[] = [];
|
|
333
|
+
for (const [regex, type] of types) {
|
|
334
|
+
if (regex.test(allSignals)) {
|
|
335
|
+
matched.push(type);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (matched.length > 0) {
|
|
340
|
+
return matched.slice(0, 3).join(' + ');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Fallback
|
|
344
|
+
const langs = report.projectInfo.primaryLanguages.join('/');
|
|
345
|
+
return `Projeto ${langs}`;
|
|
346
|
+
}
|
|
347
|
+
}
|
package/src/refactor-reporter.ts
CHANGED
|
@@ -230,7 +230,7 @@ ${this.renderFooter()}
|
|
|
230
230
|
private renderFooter(): string {
|
|
231
231
|
return `
|
|
232
232
|
<div class="footer">
|
|
233
|
-
<p>Generated by <a href="https://github.com/camilooscargbaptista/architect"
|
|
233
|
+
<p>Generated by <a href="https://github.com/camilooscargbaptista/architect">⚡ Architect v3.1</a> — Enterprise Refactoring Engine</p>
|
|
234
234
|
<p>By <strong>Camilo Girardelli</strong> · <a href="https://www.girardellitecnologia.com">Girardelli Tecnologia</a></p>
|
|
235
235
|
</div>`;
|
|
236
236
|
}
|
package/src/types.ts
CHANGED
|
@@ -82,6 +82,16 @@ export interface AnalysisReport {
|
|
|
82
82
|
mermaid: string;
|
|
83
83
|
type: 'component' | 'layer' | 'dependency';
|
|
84
84
|
};
|
|
85
|
+
projectSummary?: ProjectSummary;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ProjectSummary {
|
|
89
|
+
description: string;
|
|
90
|
+
purpose: string;
|
|
91
|
+
modules: { name: string; files: number; description: string }[];
|
|
92
|
+
techStack: string[];
|
|
93
|
+
entryPoints: string[];
|
|
94
|
+
keywords: string[];
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
export interface ArchitectConfig {
|