@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,705 @@
|
|
|
1
|
+
import { TemplateContext } from '../../types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stack-specific rule generators.
|
|
5
|
+
* Each generates a 03-[framework].md rule file tailored to the detected stack.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function generateStackRules(ctx: TemplateContext): string | null {
|
|
9
|
+
const { stack } = ctx;
|
|
10
|
+
|
|
11
|
+
if (stack.frameworks.includes('NestJS')) return generateNestJSRules(ctx);
|
|
12
|
+
if (stack.frameworks.includes('Angular')) return generateAngularRules(ctx);
|
|
13
|
+
if (stack.frameworks.includes('Next.js')) return generateNextJSRules(ctx);
|
|
14
|
+
if (stack.frameworks.includes('Django') || stack.frameworks.includes('FastAPI')) return generatePythonWebRules(ctx);
|
|
15
|
+
if (stack.frameworks.includes('Flutter')) return generateFlutterRules(ctx);
|
|
16
|
+
if (stack.frameworks.includes('Spring')) return generateSpringRules(ctx);
|
|
17
|
+
if (stack.frameworks.includes('Express') || stack.frameworks.includes('Fastify')) return generateNodeAPIRules(ctx);
|
|
18
|
+
|
|
19
|
+
return null; // No framework-specific rules needed
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getStackRuleFileName(ctx: TemplateContext): string | null {
|
|
23
|
+
const { stack } = ctx;
|
|
24
|
+
if (stack.frameworks.includes('NestJS')) return '03-nestjs';
|
|
25
|
+
if (stack.frameworks.includes('Angular')) return '03-angular';
|
|
26
|
+
if (stack.frameworks.includes('Next.js')) return '03-nextjs';
|
|
27
|
+
if (stack.frameworks.includes('Django')) return '03-django';
|
|
28
|
+
if (stack.frameworks.includes('FastAPI')) return '03-fastapi';
|
|
29
|
+
if (stack.frameworks.includes('Flutter')) return '03-flutter';
|
|
30
|
+
if (stack.frameworks.includes('Spring')) return '03-spring';
|
|
31
|
+
if (stack.frameworks.includes('Express')) return '03-express';
|
|
32
|
+
if (stack.frameworks.includes('Fastify')) return '03-fastify';
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ────────────────────────────────────────────────────
|
|
37
|
+
// NestJS
|
|
38
|
+
// ────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
function generateNestJSRules(ctx: TemplateContext): string {
|
|
41
|
+
const { projectName, config } = ctx;
|
|
42
|
+
|
|
43
|
+
return `---
|
|
44
|
+
antigravity:
|
|
45
|
+
trigger: 'always_on'
|
|
46
|
+
globs: ['**/*.ts']
|
|
47
|
+
description: 'Regras NestJS para ${projectName}'
|
|
48
|
+
priority: HIGH
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
# ⚙️ Regras NestJS — ${projectName}
|
|
52
|
+
|
|
53
|
+
> **Padrões obrigatórios para desenvolvimento NestJS.**
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 📦 Estrutura de Módulo
|
|
58
|
+
|
|
59
|
+
\`\`\`
|
|
60
|
+
Cada feature = 1 módulo NestJS
|
|
61
|
+
|
|
62
|
+
src/modules/[feature]/
|
|
63
|
+
├── [feature].module.ts → @Module({ imports, providers, exports })
|
|
64
|
+
├── [feature].controller.ts → @Controller() — HTTP endpoints
|
|
65
|
+
├── [feature].controller.spec.ts → Testes do controller
|
|
66
|
+
├── [feature].service.ts → @Injectable() — Lógica de negócio
|
|
67
|
+
├── [feature].service.spec.ts → Testes do service
|
|
68
|
+
├── dto/
|
|
69
|
+
│ ├── create-[feature].dto.ts → class-validator + class-transformer
|
|
70
|
+
│ ├── update-[feature].dto.ts → Partial<CreateDto>
|
|
71
|
+
│ └── [feature]-response.dto.ts → Response shape (NUNCA entity direta)
|
|
72
|
+
├── entities/
|
|
73
|
+
│ └── [feature].entity.ts → @Entity() TypeORM / Prisma model
|
|
74
|
+
├── guards/ → Guards específicos
|
|
75
|
+
├── pipes/ → Pipes customizados
|
|
76
|
+
└── interfaces/ → Interfaces do módulo
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🎯 Decorators — Uso Correto
|
|
82
|
+
|
|
83
|
+
\`\`\`
|
|
84
|
+
@Controller() → Routing APENAS. Sem lógica de negócio.
|
|
85
|
+
@Injectable() → Services, Repositories. Injetáveis.
|
|
86
|
+
@Module() → Agrupa components. Declara imports/exports.
|
|
87
|
+
@Entity() → Modelo de banco. NUNCA expor na API.
|
|
88
|
+
|
|
89
|
+
Guards:
|
|
90
|
+
@UseGuards(AuthGuard) → Autenticação
|
|
91
|
+
@UseGuards(RolesGuard) → Autorização
|
|
92
|
+
@Roles('admin', 'user') → Roles necessárias
|
|
93
|
+
|
|
94
|
+
Pipes:
|
|
95
|
+
@UsePipes(ValidationPipe) → Validação de DTO
|
|
96
|
+
{ whitelist: true, forbidNonWhitelisted: true, transform: true }
|
|
97
|
+
|
|
98
|
+
Interceptors:
|
|
99
|
+
@UseInterceptors(LoggingInterceptor) → Logging
|
|
100
|
+
@UseInterceptors(TransformInterceptor) → Response shape
|
|
101
|
+
\`\`\`
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 🚫 Anti-Patterns NestJS
|
|
106
|
+
|
|
107
|
+
\`\`\`
|
|
108
|
+
❌ PROIBIDO: Lógica de negócio no controller
|
|
109
|
+
→ Mover para service
|
|
110
|
+
|
|
111
|
+
❌ PROIBIDO: Entity como response de API
|
|
112
|
+
→ Criar DTO de response
|
|
113
|
+
|
|
114
|
+
❌ PROIBIDO: @Body() sem DTO validado
|
|
115
|
+
→ Criar DTO com class-validator
|
|
116
|
+
|
|
117
|
+
❌ PROIBIDO: Service importando Request/Response
|
|
118
|
+
→ Service recebe dados puros, controller adapta
|
|
119
|
+
|
|
120
|
+
❌ PROIBIDO: Circular module imports
|
|
121
|
+
→ Usar forwardRef() ou extrair shared module
|
|
122
|
+
|
|
123
|
+
❌ PROIBIDO: Repository no controller
|
|
124
|
+
→ Controller → Service → Repository
|
|
125
|
+
|
|
126
|
+
❌ PROIBIDO: try/catch genérico no controller
|
|
127
|
+
→ Usar exception filters
|
|
128
|
+
|
|
129
|
+
❌ PROIBIDO: console.log
|
|
130
|
+
→ Usar @nestjs/common Logger ou winston
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## ✅ Patterns NestJS Obrigatórios
|
|
136
|
+
|
|
137
|
+
\`\`\`
|
|
138
|
+
✅ Global validation pipe no bootstrap
|
|
139
|
+
✅ Global exception filter (HttpExceptionFilter)
|
|
140
|
+
✅ DTOs com class-validator para TODOS os endpoints
|
|
141
|
+
✅ Config via @nestjs/config + .env
|
|
142
|
+
✅ Database via TypeORM/Prisma com migrations
|
|
143
|
+
✅ Auth via Passport + JWT strategy
|
|
144
|
+
✅ Swagger via @nestjs/swagger + ApiProperty()
|
|
145
|
+
✅ Health check endpoint (/health)
|
|
146
|
+
✅ Cobertura ≥ ${config.coverageMinimum}%
|
|
147
|
+
\`\`\`
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 📋 Checklist por Endpoint
|
|
152
|
+
|
|
153
|
+
\`\`\`
|
|
154
|
+
□ DTO de request com validação
|
|
155
|
+
□ DTO de response (não entity)
|
|
156
|
+
□ Guard de auth aplicado
|
|
157
|
+
□ Swagger decorators (@ApiTags, @ApiOperation, @ApiResponse)
|
|
158
|
+
□ Error handling (HttpException com status correto)
|
|
159
|
+
□ Teste unitário do service method
|
|
160
|
+
□ Teste de integração do endpoint
|
|
161
|
+
□ Logging estruturado
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
**Gerado por Architect v3.1**
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ────────────────────────────────────────────────────
|
|
171
|
+
// Angular
|
|
172
|
+
// ────────────────────────────────────────────────────
|
|
173
|
+
|
|
174
|
+
function generateAngularRules(ctx: TemplateContext): string {
|
|
175
|
+
const { projectName, config } = ctx;
|
|
176
|
+
|
|
177
|
+
return `---
|
|
178
|
+
antigravity:
|
|
179
|
+
trigger: 'always_on'
|
|
180
|
+
globs: ['**/*.ts', '**/*.html', '**/*.scss']
|
|
181
|
+
description: 'Regras Angular para ${projectName}'
|
|
182
|
+
priority: HIGH
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
# 🅰️ Regras Angular — ${projectName}
|
|
186
|
+
|
|
187
|
+
> **Padrões obrigatórios para desenvolvimento Angular.**
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 📦 Estrutura de Module
|
|
192
|
+
|
|
193
|
+
\`\`\`
|
|
194
|
+
src/app/modules/[feature]/
|
|
195
|
+
├── [feature].module.ts
|
|
196
|
+
├── [feature]-routing.module.ts
|
|
197
|
+
├── components/
|
|
198
|
+
│ ├── [feature]-list/
|
|
199
|
+
│ │ ├── [feature]-list.component.ts
|
|
200
|
+
│ │ ├── [feature]-list.component.html
|
|
201
|
+
│ │ ├── [feature]-list.component.scss
|
|
202
|
+
│ │ └── [feature]-list.component.spec.ts
|
|
203
|
+
│ └── [feature]-form/
|
|
204
|
+
│ └── ...
|
|
205
|
+
├── services/
|
|
206
|
+
│ ├── [feature].service.ts
|
|
207
|
+
│ └── [feature].service.spec.ts
|
|
208
|
+
├── models/
|
|
209
|
+
│ └── [feature].model.ts
|
|
210
|
+
├── guards/
|
|
211
|
+
└── pipes/
|
|
212
|
+
\`\`\`
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 🎯 Component Rules
|
|
217
|
+
|
|
218
|
+
\`\`\`
|
|
219
|
+
□ Smart vs Dumb components (Container vs Presentational)
|
|
220
|
+
□ OnPush change detection por padrão
|
|
221
|
+
□ Unsubscribe de Observables (takeUntilDestroyed ou async pipe)
|
|
222
|
+
□ TODOS os estados: loading, error, empty, data
|
|
223
|
+
□ Lazy loading para feature modules
|
|
224
|
+
□ trackBy em *ngFor
|
|
225
|
+
□ Sem lógica de negócio no template
|
|
226
|
+
□ Sem lógica de negócio no component — usar services
|
|
227
|
+
\`\`\`
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 🚫 Anti-Patterns Angular
|
|
232
|
+
|
|
233
|
+
\`\`\`
|
|
234
|
+
❌ Component com > 200 linhas de lógica → Extrair para service
|
|
235
|
+
❌ Subscribe manual sem unsubscribe → Memory leak
|
|
236
|
+
❌ Chamadas HTTP no component → Usar service
|
|
237
|
+
❌ any em templates → Tipar corretamente
|
|
238
|
+
❌ Shared module gigante → Dividir por domínio
|
|
239
|
+
\`\`\`
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## ✅ Checklist por Component
|
|
244
|
+
|
|
245
|
+
\`\`\`
|
|
246
|
+
□ OnPush change detection
|
|
247
|
+
□ Loading/error/empty states
|
|
248
|
+
□ Responsive (mobile + desktop)
|
|
249
|
+
□ Acessibilidade (labels, aria)
|
|
250
|
+
□ Lazy loaded (se feature module)
|
|
251
|
+
□ Teste unitário
|
|
252
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
**Gerado por Architect v3.1**
|
|
258
|
+
`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// ────────────────────────────────────────────────────
|
|
262
|
+
// Next.js
|
|
263
|
+
// ────────────────────────────────────────────────────
|
|
264
|
+
|
|
265
|
+
function generateNextJSRules(ctx: TemplateContext): string {
|
|
266
|
+
const { projectName, config } = ctx;
|
|
267
|
+
|
|
268
|
+
return `---
|
|
269
|
+
antigravity:
|
|
270
|
+
trigger: 'always_on'
|
|
271
|
+
globs: ['**/*.{ts,tsx,js,jsx}']
|
|
272
|
+
description: 'Regras Next.js para ${projectName}'
|
|
273
|
+
priority: HIGH
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
# ▲ Regras Next.js — ${projectName}
|
|
277
|
+
|
|
278
|
+
> **Padrões obrigatórios para desenvolvimento Next.js.**
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📦 Estrutura
|
|
283
|
+
|
|
284
|
+
\`\`\`
|
|
285
|
+
src/
|
|
286
|
+
├── app/ → App Router (pages, layouts, loading, error)
|
|
287
|
+
│ ├── layout.tsx → Root layout
|
|
288
|
+
│ ├── page.tsx → Home
|
|
289
|
+
│ ├── [feature]/
|
|
290
|
+
│ │ ├── page.tsx → Feature page (Server Component por padrão)
|
|
291
|
+
│ │ ├── loading.tsx → Loading UI
|
|
292
|
+
│ │ ├── error.tsx → Error boundary
|
|
293
|
+
│ │ └── layout.tsx → Feature layout
|
|
294
|
+
├── components/ → Shared components
|
|
295
|
+
│ ├── ui/ → Design system atoms
|
|
296
|
+
│ └── [feature]/ → Feature-specific components
|
|
297
|
+
├── lib/ → Utilities, API clients
|
|
298
|
+
├── services/ → Business logic, data fetching
|
|
299
|
+
├── types/ → TypeScript types
|
|
300
|
+
└── hooks/ → Custom React hooks
|
|
301
|
+
\`\`\`
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 🎯 Server vs Client Components
|
|
306
|
+
|
|
307
|
+
\`\`\`
|
|
308
|
+
Server Components (padrão):
|
|
309
|
+
✅ Data fetching
|
|
310
|
+
✅ Acesso a backend resources
|
|
311
|
+
✅ Sensitive data (tokens, keys)
|
|
312
|
+
✅ Large dependencies server-side
|
|
313
|
+
|
|
314
|
+
Client Components ('use client'):
|
|
315
|
+
✅ Interatividade (onClick, onChange)
|
|
316
|
+
✅ Hooks (useState, useEffect)
|
|
317
|
+
✅ Browser APIs
|
|
318
|
+
✅ Event listeners
|
|
319
|
+
|
|
320
|
+
REGRA: Manter Client Components o menor possível.
|
|
321
|
+
Push 'use client' para baixo na árvore.
|
|
322
|
+
\`\`\`
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## 🚫 Anti-Patterns Next.js
|
|
327
|
+
|
|
328
|
+
\`\`\`
|
|
329
|
+
❌ 'use client' no layout.tsx → Quebra streaming SSR
|
|
330
|
+
❌ fetch sem cache strategy → Definir revalidate
|
|
331
|
+
❌ useEffect para data fetching → Server Component
|
|
332
|
+
❌ API route sem validação → Zod schema
|
|
333
|
+
❌ Client component gigante → Extrair server parts
|
|
334
|
+
\`\`\`
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## ✅ Checklist por Page
|
|
339
|
+
|
|
340
|
+
\`\`\`
|
|
341
|
+
□ loading.tsx para Suspense boundary
|
|
342
|
+
□ error.tsx para error boundary
|
|
343
|
+
□ Metadata (generateMetadata) para SEO
|
|
344
|
+
□ Server Component por padrão
|
|
345
|
+
□ Validação de params/searchParams
|
|
346
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
**Gerado por Architect v3.1**
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// ────────────────────────────────────────────────────
|
|
356
|
+
// Python Web (Django / FastAPI)
|
|
357
|
+
// ────────────────────────────────────────────────────
|
|
358
|
+
|
|
359
|
+
function generatePythonWebRules(ctx: TemplateContext): string {
|
|
360
|
+
const { projectName, stack, config } = ctx;
|
|
361
|
+
const fw = stack.frameworks.includes('Django') ? 'Django' : 'FastAPI';
|
|
362
|
+
|
|
363
|
+
return `---
|
|
364
|
+
antigravity:
|
|
365
|
+
trigger: 'always_on'
|
|
366
|
+
globs: ['**/*.py']
|
|
367
|
+
description: 'Regras ${fw} para ${projectName}'
|
|
368
|
+
priority: HIGH
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
# 🐍 Regras ${fw} — ${projectName}
|
|
372
|
+
|
|
373
|
+
> **Padrões obrigatórios para desenvolvimento ${fw}.**
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 📦 Estrutura
|
|
378
|
+
|
|
379
|
+
${fw === 'Django' ? `\`\`\`
|
|
380
|
+
apps/[feature]/
|
|
381
|
+
├── __init__.py
|
|
382
|
+
├── admin.py → Admin customizado
|
|
383
|
+
├── apps.py → App config
|
|
384
|
+
├── models.py → Models (ORM)
|
|
385
|
+
├── managers.py → Custom QuerySet/Manager
|
|
386
|
+
├── serializers.py → DRF Serializers
|
|
387
|
+
├── views.py → ViewSets / APIViews
|
|
388
|
+
├── urls.py → URL patterns
|
|
389
|
+
├── permissions.py → Custom permissions
|
|
390
|
+
├── filters.py → django-filter sets
|
|
391
|
+
├── signals.py → Signal handlers
|
|
392
|
+
├── services.py → Business logic (NÃO no view)
|
|
393
|
+
├── tasks.py → Celery tasks
|
|
394
|
+
├── tests/
|
|
395
|
+
│ ├── test_models.py
|
|
396
|
+
│ ├── test_views.py
|
|
397
|
+
│ └── test_services.py
|
|
398
|
+
└── migrations/
|
|
399
|
+
\`\`\`` : `\`\`\`
|
|
400
|
+
app/
|
|
401
|
+
├── main.py → FastAPI app, middleware
|
|
402
|
+
├── core/
|
|
403
|
+
│ ├── config.py → Pydantic Settings
|
|
404
|
+
│ ├── security.py → JWT, hashing
|
|
405
|
+
│ └── deps.py → Dependency injection
|
|
406
|
+
├── modules/[feature]/
|
|
407
|
+
│ ├── __init__.py
|
|
408
|
+
│ ├── router.py → APIRouter endpoints
|
|
409
|
+
│ ├── schemas.py → Pydantic models (request/response)
|
|
410
|
+
│ ├── models.py → SQLAlchemy models
|
|
411
|
+
│ ├── service.py → Business logic
|
|
412
|
+
│ ├── repository.py → Data access
|
|
413
|
+
│ └── tests/
|
|
414
|
+
│ ├── test_router.py
|
|
415
|
+
│ └── test_service.py
|
|
416
|
+
└── alembic/ → Migrations
|
|
417
|
+
\`\`\``}
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## 🚫 Anti-Patterns ${fw}
|
|
422
|
+
|
|
423
|
+
\`\`\`
|
|
424
|
+
${fw === 'Django' ? `❌ Fat views (lógica de negócio no view) → Usar services.py
|
|
425
|
+
❌ N+1 queries → select_related / prefetch_related
|
|
426
|
+
❌ Raw SQL sem necessidade → QuerySet API
|
|
427
|
+
❌ Model sem __str__ → Sempre implementar
|
|
428
|
+
❌ Migrations manuais → Sempre via makemigrations
|
|
429
|
+
❌ Signal abuse → Preferir chamada explícita em service` : `❌ Lógica no router (endpoint) → Usar service layer
|
|
430
|
+
❌ SQLAlchemy session no router → Dependency injection
|
|
431
|
+
❌ Schemas sem validação → Pydantic validators
|
|
432
|
+
❌ sync blocking em async → Usar run_in_executor
|
|
433
|
+
❌ Sem type hints → FastAPI depende de tipos`}
|
|
434
|
+
\`\`\`
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## ✅ Checklist
|
|
439
|
+
|
|
440
|
+
\`\`\`
|
|
441
|
+
□ Lógica de negócio em services (não views/routers)
|
|
442
|
+
□ Schemas/Serializers para TODOS os endpoints
|
|
443
|
+
□ Migrations reversíveis
|
|
444
|
+
□ Testes para models, services, views
|
|
445
|
+
□ Type hints em todo código
|
|
446
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
447
|
+
\`\`\`
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
**Gerado por Architect v3.1**
|
|
452
|
+
`;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// ────────────────────────────────────────────────────
|
|
456
|
+
// Flutter
|
|
457
|
+
// ────────────────────────────────────────────────────
|
|
458
|
+
|
|
459
|
+
function generateFlutterRules(ctx: TemplateContext): string {
|
|
460
|
+
const { projectName, config } = ctx;
|
|
461
|
+
|
|
462
|
+
return `---
|
|
463
|
+
antigravity:
|
|
464
|
+
trigger: 'always_on'
|
|
465
|
+
globs: ['**/*.dart']
|
|
466
|
+
description: 'Regras Flutter para ${projectName}'
|
|
467
|
+
priority: HIGH
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
# 📱 Regras Flutter — ${projectName}
|
|
471
|
+
|
|
472
|
+
> **Padrões obrigatórios para desenvolvimento Flutter.**
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## 📦 Estrutura
|
|
477
|
+
|
|
478
|
+
\`\`\`
|
|
479
|
+
lib/
|
|
480
|
+
├── main.dart → Entry point
|
|
481
|
+
├── app.dart → MaterialApp / Router
|
|
482
|
+
├── core/
|
|
483
|
+
│ ├── di/ → Dependency injection (get_it/riverpod)
|
|
484
|
+
│ ├── theme/ → AppTheme, colors, typography
|
|
485
|
+
│ ├── network/ → Dio/HTTP client config
|
|
486
|
+
│ ├── storage/ → SharedPreferences, secure storage
|
|
487
|
+
│ └── utils/ → Extensions, formatters
|
|
488
|
+
├── features/[feature]/
|
|
489
|
+
│ ├── data/
|
|
490
|
+
│ │ ├── models/ → JSON models (fromJson/toJson)
|
|
491
|
+
│ │ ├── repositories/ → Repository implementation
|
|
492
|
+
│ │ └── datasources/ → API calls, local DB
|
|
493
|
+
│ ├── domain/
|
|
494
|
+
│ │ ├── entities/ → Business entities
|
|
495
|
+
│ │ ├── repositories/ → Repository interfaces (abstract)
|
|
496
|
+
│ │ └── usecases/ → Business logic units
|
|
497
|
+
│ └── presentation/
|
|
498
|
+
│ ├── pages/ → Screen widgets
|
|
499
|
+
│ ├── widgets/ → Feature-specific widgets
|
|
500
|
+
│ ├── bloc/ (ou cubit/) → State management
|
|
501
|
+
│ └── providers/ → Riverpod providers (se usado)
|
|
502
|
+
└── shared/
|
|
503
|
+
├── widgets/ → Reusable widgets
|
|
504
|
+
└── models/ → Shared models
|
|
505
|
+
\`\`\`
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
## 🎯 State Management
|
|
510
|
+
|
|
511
|
+
\`\`\`
|
|
512
|
+
Padrão: BLoC/Cubit ou Riverpod (escolher UM)
|
|
513
|
+
|
|
514
|
+
BLoC:
|
|
515
|
+
Event → BLoC → State → UI
|
|
516
|
+
□ Events são imutáveis
|
|
517
|
+
□ States são imutáveis
|
|
518
|
+
□ BLoC não importa Flutter (puro Dart)
|
|
519
|
+
□ Um BLoC por feature (não God BLoC)
|
|
520
|
+
|
|
521
|
+
NUNCA:
|
|
522
|
+
❌ setState para lógica complexa
|
|
523
|
+
❌ State management misturado (BLoC + Provider + setState)
|
|
524
|
+
❌ BLoC acessando BuildContext
|
|
525
|
+
\`\`\`
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## 🚫 Anti-Patterns Flutter
|
|
530
|
+
|
|
531
|
+
\`\`\`
|
|
532
|
+
❌ Column com muitos children para listas → ListView.builder
|
|
533
|
+
❌ Widget gigante (> 200 linhas) → Extrair sub-widgets
|
|
534
|
+
❌ Build method com lógica → Mover para BLoC/Cubit
|
|
535
|
+
❌ Sem const constructors → Sempre usar const
|
|
536
|
+
❌ FutureBuilder direto para API calls → BLoC/Cubit
|
|
537
|
+
❌ Hardcoded strings → Usar l10n/intl
|
|
538
|
+
❌ Hardcoded colors → Usar Theme.of(context)
|
|
539
|
+
\`\`\`
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## ✅ Checklist por Screen
|
|
544
|
+
|
|
545
|
+
\`\`\`
|
|
546
|
+
□ TODOS os estados: loading, error, empty, data
|
|
547
|
+
□ Pull-to-refresh (se lista)
|
|
548
|
+
□ Skeleton/shimmer para loading
|
|
549
|
+
□ Error retry button
|
|
550
|
+
□ Responsive (tablet support se necessário)
|
|
551
|
+
□ Keyboard handling (dismiss, next field)
|
|
552
|
+
□ Teste de widget
|
|
553
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
554
|
+
\`\`\`
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
**Gerado por Architect v3.1**
|
|
559
|
+
`;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// ────────────────────────────────────────────────────
|
|
563
|
+
// Spring Boot
|
|
564
|
+
// ────────────────────────────────────────────────────
|
|
565
|
+
|
|
566
|
+
function generateSpringRules(ctx: TemplateContext): string {
|
|
567
|
+
const { projectName, config } = ctx;
|
|
568
|
+
|
|
569
|
+
return `---
|
|
570
|
+
antigravity:
|
|
571
|
+
trigger: 'always_on'
|
|
572
|
+
globs: ['**/*.java', '**/*.kt']
|
|
573
|
+
description: 'Regras Spring Boot para ${projectName}'
|
|
574
|
+
priority: HIGH
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
# 🍃 Regras Spring Boot — ${projectName}
|
|
578
|
+
|
|
579
|
+
> **Padrões obrigatórios para desenvolvimento Spring Boot.**
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
## 📦 Estrutura
|
|
584
|
+
|
|
585
|
+
\`\`\`
|
|
586
|
+
src/main/java/com/[org]/[project]/
|
|
587
|
+
├── [Feature]Module/
|
|
588
|
+
│ ├── controller/
|
|
589
|
+
│ │ └── [Feature]Controller.java → @RestController
|
|
590
|
+
│ ├── service/
|
|
591
|
+
│ │ ├── [Feature]Service.java → Interface
|
|
592
|
+
│ │ └── [Feature]ServiceImpl.java → @Service
|
|
593
|
+
│ ├── repository/
|
|
594
|
+
│ │ └── [Feature]Repository.java → @Repository / JPA
|
|
595
|
+
│ ├── dto/
|
|
596
|
+
│ │ ├── Create[Feature]Request.java → @Valid annotations
|
|
597
|
+
│ │ └── [Feature]Response.java
|
|
598
|
+
│ ├── entity/
|
|
599
|
+
│ │ └── [Feature].java → @Entity JPA
|
|
600
|
+
│ └── exception/
|
|
601
|
+
│ └── [Feature]NotFoundException.java
|
|
602
|
+
\`\`\`
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
## 🚫 Anti-Patterns Spring
|
|
607
|
+
|
|
608
|
+
\`\`\`
|
|
609
|
+
❌ @Autowired field injection → Constructor injection
|
|
610
|
+
❌ Lógica no controller → Service layer
|
|
611
|
+
❌ Entity como response → DTO mapping
|
|
612
|
+
❌ catch(Exception e) genérico → Specific exceptions + @ControllerAdvice
|
|
613
|
+
❌ @Transactional no controller → Service layer
|
|
614
|
+
\`\`\`
|
|
615
|
+
|
|
616
|
+
---
|
|
617
|
+
|
|
618
|
+
## ✅ Checklist
|
|
619
|
+
|
|
620
|
+
\`\`\`
|
|
621
|
+
□ Constructor injection (não field)
|
|
622
|
+
□ DTOs com @Valid
|
|
623
|
+
□ @ControllerAdvice para exception handling
|
|
624
|
+
□ @Transactional no service
|
|
625
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
626
|
+
\`\`\`
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
**Gerado por Architect v3.1**
|
|
631
|
+
`;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// ────────────────────────────────────────────────────
|
|
635
|
+
// Express / Fastify (Node.js API)
|
|
636
|
+
// ────────────────────────────────────────────────────
|
|
637
|
+
|
|
638
|
+
function generateNodeAPIRules(ctx: TemplateContext): string {
|
|
639
|
+
const { projectName, stack, config } = ctx;
|
|
640
|
+
const fw = stack.frameworks.includes('Fastify') ? 'Fastify' : 'Express';
|
|
641
|
+
|
|
642
|
+
return `---
|
|
643
|
+
antigravity:
|
|
644
|
+
trigger: 'always_on'
|
|
645
|
+
globs: ['**/*.{ts,js}']
|
|
646
|
+
description: 'Regras ${fw} para ${projectName}'
|
|
647
|
+
priority: HIGH
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
# 🚀 Regras ${fw} — ${projectName}
|
|
651
|
+
|
|
652
|
+
> **Padrões obrigatórios para desenvolvimento ${fw}.**
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## 📦 Estrutura
|
|
657
|
+
|
|
658
|
+
\`\`\`
|
|
659
|
+
src/
|
|
660
|
+
├── app.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → ${fw} app setup, middleware
|
|
661
|
+
├── server.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → Server bootstrap
|
|
662
|
+
├── modules/[feature]/
|
|
663
|
+
│ ├── [feature].routes.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → Route definitions
|
|
664
|
+
│ ├── [feature].controller.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → Request handling
|
|
665
|
+
│ ├── [feature].service.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → Business logic
|
|
666
|
+
│ ├── [feature].schema.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → Validation (Joi/Zod)
|
|
667
|
+
│ ├── [feature].model.${stack.languages.includes('TypeScript') ? 'ts' : 'js'} → DB model
|
|
668
|
+
│ └── __tests__/
|
|
669
|
+
├── middleware/ → Auth, logging, error handler
|
|
670
|
+
├── config/ → Environment config
|
|
671
|
+
└── utils/ → Shared utilities
|
|
672
|
+
\`\`\`
|
|
673
|
+
|
|
674
|
+
---
|
|
675
|
+
|
|
676
|
+
## 🚫 Anti-Patterns ${fw}
|
|
677
|
+
|
|
678
|
+
\`\`\`
|
|
679
|
+
❌ Lógica de negócio no route handler → Usar service layer
|
|
680
|
+
❌ req.body sem validação → Joi/Zod schema
|
|
681
|
+
❌ Callback hell → async/await
|
|
682
|
+
❌ Error swallowing (catch vazio) → Proper error handler middleware
|
|
683
|
+
❌ Secrets hardcoded → Environment variables
|
|
684
|
+
❌ console.log em produção → Structured logger (winston/pino)
|
|
685
|
+
\`\`\`
|
|
686
|
+
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
## ✅ Checklist
|
|
690
|
+
|
|
691
|
+
\`\`\`
|
|
692
|
+
□ Validation middleware em TODOS os endpoints
|
|
693
|
+
□ Error handling middleware global
|
|
694
|
+
□ Auth middleware para rotas protegidas
|
|
695
|
+
□ Rate limiting
|
|
696
|
+
□ CORS configurado
|
|
697
|
+
□ Helmet para security headers
|
|
698
|
+
□ Cobertura ≥ ${config.coverageMinimum}%
|
|
699
|
+
\`\`\`
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
**Gerado por Architect v3.1**
|
|
704
|
+
`;
|
|
705
|
+
}
|