wegho-agentes 7.0.0 → 7.0.1

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.
Files changed (108) hide show
  1. package/.agent/skills/wegho-global-rules/SKILL.md +20 -0
  2. package/.agent/workflows/PROMPT_GUIDE.md +7 -4
  3. package/.agents/cli.ts +29 -21
  4. package/.agents/core/base-agent.ts +28 -12
  5. package/.agents/core/memory-system.ts +45 -13
  6. package/.agents/core/report-generator.ts +26 -19
  7. package/.agents/orchestrator.ts +104 -74
  8. package/.clinerules +318 -1229
  9. package/.cursorrules +0 -189
  10. package/README.md +3 -3
  11. package/docs/VERSION.md +3 -2
  12. package/package.json +3 -3
  13. package/.agents/agents/ai-agents/README.md +0 -175
  14. package/.agents/agents/ai-agents/agent.ts +0 -83
  15. package/.agents/agents/ai-agents/specialty.md +0 -14
  16. package/.agents/agents/architecture/README.md +0 -61
  17. package/.agents/agents/architecture/agent.ts +0 -238
  18. package/.agents/agents/architecture/memory.md +0 -111
  19. package/.agents/agents/architecture/specialty.md +0 -31
  20. package/.agents/agents/automation/README.md +0 -60
  21. package/.agents/agents/automation/agent.ts +0 -61
  22. package/.agents/agents/automation/specialty.md +0 -14
  23. package/.agents/agents/backend/README.md +0 -155
  24. package/.agents/agents/backend/agent.ts +0 -100
  25. package/.agents/agents/backend/specialty.md +0 -14
  26. package/.agents/agents/cloud/README.md +0 -73
  27. package/.agents/agents/cloud/agent.ts +0 -53
  28. package/.agents/agents/cloud/specialty.md +0 -14
  29. package/.agents/agents/code-auditor/README.md +0 -37
  30. package/.agents/agents/code-auditor/agent.ts +0 -334
  31. package/.agents/agents/code-auditor/specialty.md +0 -14
  32. package/.agents/agents/cro/README.md +0 -200
  33. package/.agents/agents/cro/agent.ts +0 -61
  34. package/.agents/agents/cro/specialty.md +0 -14
  35. package/.agents/agents/database/README.md +0 -67
  36. package/.agents/agents/database/agent.ts +0 -93
  37. package/.agents/agents/database/specialty.md +0 -14
  38. package/.agents/agents/devops/README.md +0 -84
  39. package/.agents/agents/devops/agent.ts +0 -54
  40. package/.agents/agents/devops/specialty.md +0 -14
  41. package/.agents/agents/documentation/README.md +0 -107
  42. package/.agents/agents/documentation/agent.ts +0 -253
  43. package/.agents/agents/documentation/memory.md +0 -56
  44. package/.agents/agents/documentation/specialty.md +0 -33
  45. package/.agents/agents/frontend/README.md +0 -188
  46. package/.agents/agents/frontend/agent.ts +0 -211
  47. package/.agents/agents/frontend/memory.md +0 -139
  48. package/.agents/agents/frontend/specialty.md +0 -30
  49. package/.agents/agents/inventory/README.md +0 -35
  50. package/.agents/agents/inventory/agent.ts +0 -758
  51. package/.agents/agents/inventory/memory.md +0 -50
  52. package/.agents/agents/inventory/specialty.md +0 -129
  53. package/.agents/agents/nextjs/README.md +0 -58
  54. package/.agents/agents/nextjs/agent.ts +0 -114
  55. package/.agents/agents/nextjs/specialty.md +0 -14
  56. package/.agents/agents/pentest/README.md +0 -228
  57. package/.agents/agents/pentest/agent.ts +0 -96
  58. package/.agents/agents/pentest/specialty.md +0 -14
  59. package/.agents/agents/planning/README.md +0 -107
  60. package/.agents/agents/planning/agent.ts +0 -389
  61. package/.agents/agents/planning/specialty.md +0 -14
  62. package/.agents/agents/project-discovery/README.md +0 -35
  63. package/.agents/agents/project-discovery/agent.ts +0 -344
  64. package/.agents/agents/project-discovery/specialty.md +0 -14
  65. package/.agents/agents/quality/README.md +0 -81
  66. package/.agents/agents/quality/agent.ts +0 -269
  67. package/.agents/agents/quality/memory.md +0 -110
  68. package/.agents/agents/quality/specialty.md +0 -31
  69. package/.agents/agents/rag/README.md +0 -41
  70. package/.agents/agents/rag/agent.ts +0 -85
  71. package/.agents/agents/rag/specialty.md +0 -14
  72. package/.agents/agents/security/README.md +0 -152
  73. package/.agents/agents/security/agent.ts +0 -218
  74. package/.agents/agents/security/memory.md +0 -91
  75. package/.agents/agents/security/specialty.md +0 -31
  76. package/.agents/agents/task-analyzer/README.md +0 -36
  77. package/.agents/agents/task-analyzer/agent.ts +0 -462
  78. package/.agents/agents/task-analyzer/specialty.md +0 -14
  79. package/.agents/agents/testing/README.md +0 -161
  80. package/.agents/agents/testing/agent.ts +0 -61
  81. package/.agents/agents/testing/specialty.md +0 -14
  82. package/.agents/agents/uiux/README.md +0 -68
  83. package/.agents/agents/uiux/agent.ts +0 -95
  84. package/.agents/agents/uiux/specialty.md +0 -14
  85. package/.agents/base/base-agent.ts +0 -331
  86. package/.agents/base/memory-system.ts +0 -397
  87. package/.agents/base/skill-manager.ts +0 -95
  88. package/.agents/convert-memory.ps1 +0 -153
  89. package/.agents/examples/reporting-example.md +0 -203
  90. package/.agents/managers/build-manager.ts +0 -304
  91. package/.agents/managers/cache-manager.ts +0 -184
  92. package/.agents/managers/checkpoint-manager.ts +0 -299
  93. package/.agents/migrate-agents.ps1 +0 -117
  94. package/.agents/templates/change-report.md +0 -55
  95. package/.agents/templates/execution-plan.md +0 -36
  96. package/.agents/unmapped-skills.txt +0 -0
  97. package/.agents/utils/agent-migrator.ts +0 -360
  98. package/.agents/utils/agent-monitor.ts +0 -102
  99. package/.agents/utils/agent-parallelizer.ts +0 -108
  100. package/.agents/utils/context-monitor.ts +0 -140
  101. package/.agents/utils/feedback-collector.ts +0 -207
  102. package/.agents/utils/file-generator.ts +0 -304
  103. package/.agents/utils/memory-converter.ts +0 -217
  104. package/.agents/utils/memory-dashboard.ts +0 -147
  105. package/.agents/utils/performance-tracker.ts +0 -275
  106. package/.agents/utils/report-generator.ts +0 -193
  107. package/.agents/utils/retry-utility.ts +0 -140
  108. package/.agents/utils/workflow-validator.ts +0 -158
@@ -1,100 +0,0 @@
1
- import { BaseAgent, TaskContext, TaskResult } from '../../base/base-agent.js';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
-
5
- /**
6
- * Backend Agent - Especialista em Backend Development
7
- *
8
- * Responsabilidades:
9
- * - Node.js, NestJS, Express development
10
- * - API design e REST/GraphQL patterns
11
- * - Microservices architecture
12
- * - Performance optimization
13
- *
14
- * Skills: backend-dev-guidelines, nodejs-best-practices, nestjs-expert,
15
- * api-patterns, graphql
16
- */
17
-
18
- export class BackendAgent extends BaseAgent {
19
- private skillsPath: string;
20
-
21
- constructor(memoryPath: string) {
22
- super('backend-agent', memoryPath);
23
- this.skillsPath = path.join(process.cwd(), 'skills');
24
- }
25
-
26
- async executeTask(taskDescription: string, context: TaskContext): Promise<TaskResult> {
27
- console.log(`\n⚙️ Backend Agent analisando tarefa...\n`);
28
-
29
- const issues: string[] = [];
30
- const recommendations: string[] = [];
31
-
32
- // Análise de API
33
- if (taskDescription.toLowerCase().includes('api') ||
34
- taskDescription.toLowerCase().includes('endpoint')) {
35
-
36
- recommendations.push('✅ Usar versionamento de API (v1, v2)');
37
- recommendations.push('✅ Implementar rate limiting');
38
- recommendations.push('✅ Adicionar validação de input');
39
- recommendations.push('✅ Retornar status codes apropriados');
40
- recommendations.push('✅ Documentar com OpenAPI/Swagger');
41
- }
42
-
43
- // Análise de Node.js
44
- if (taskDescription.toLowerCase().includes('nodejs') ||
45
- taskDescription.toLowerCase().includes('node')) {
46
-
47
- recommendations.push('✅ Usar async/await em vez de callbacks');
48
- recommendations.push('✅ Implementar error handling adequado');
49
- recommendations.push('✅ Usar environment variables');
50
- recommendations.push('✅ Implementar logging estruturado');
51
- }
52
-
53
- // Análise de NestJS
54
- if (taskDescription.toLowerCase().includes('nestjs')) {
55
- recommendations.push('✅ Usar módulos para organização');
56
- recommendations.push('✅ Implementar DTOs para validação');
57
- recommendations.push('✅ Usar Guards para autenticação');
58
- recommendations.push('✅ Implementar Interceptors para logging');
59
- }
60
-
61
- // Análise de GraphQL
62
- if (taskDescription.toLowerCase().includes('graphql')) {
63
- recommendations.push('✅ Definir schema types claramente');
64
- recommendations.push('✅ Implementar DataLoader para N+1');
65
- recommendations.push('✅ Adicionar query complexity limits');
66
- recommendations.push('✅ Usar fragments para reusabilidade');
67
- }
68
-
69
- // Análise de Performance
70
- if (taskDescription.toLowerCase().includes('performance')) {
71
- recommendations.push('✅ Implementar caching (Redis)');
72
- recommendations.push('✅ Usar connection pooling');
73
- recommendations.push('✅ Otimizar queries de database');
74
- recommendations.push('✅ Implementar pagination');
75
- }
76
-
77
- // Análise de Segurança
78
- if (taskDescription.toLowerCase().includes('segurança') ||
79
- taskDescription.toLowerCase().includes('security')) {
80
-
81
- recommendations.push('✅ Validar e sanitizar inputs');
82
- recommendations.push('✅ Usar HTTPS');
83
- recommendations.push('✅ Implementar CORS adequadamente');
84
- recommendations.push('✅ Usar helmet.js para headers');
85
- recommendations.push('✅ Implementar rate limiting');
86
- }
87
-
88
- const success = issues.length === 0;
89
-
90
- return {
91
- success,
92
- details: success
93
- ? `Backend Agent: ${recommendations.length} recomendações`
94
- : `Backend Agent: ${issues.length} problemas encontrados`,
95
- recommendations,
96
- blockers: issues
97
- };
98
- }
99
- }
100
-
@@ -1,14 +0,0 @@
1
- # Backend Agent - Especialidade
2
-
3
- ## Responsabilidades
4
- - Definir responsabilidades específicas
5
-
6
- ## Expertise
7
- - Definir áreas de expertise
8
-
9
- ## Regras
10
- - Arquivos < 500 linhas
11
- - Não alucinar APIs
12
-
13
- ## Tarefas Típicas
14
- - Listar tarefas típicas
@@ -1,73 +0,0 @@
1
- # Cloud Agent
2
-
3
- ## 🎯 Responsabilidade
4
-
5
- Especialista em serviços cloud (AWS, Azure, GCP), arquitetura serverless e infraestrutura na nuvem.
6
-
7
- ## 🛠️ Skills Disponíveis
8
-
9
- ### ☁️ AWS
10
-
11
- #### [aws-serverless](../../skills/aws-serverless/)
12
- **Propósito**: AWS Lambda e serverless
13
- **Quando usar**: Criar funções serverless
14
- **Capacidades**:
15
- - Lambda functions
16
- - API Gateway
17
- - DynamoDB
18
- - S3 integration
19
- - CloudFormation
20
-
21
- #### [aws-penetration-testing](../../skills/aws-penetration-testing/)
22
- **Propósito**: Segurança AWS
23
- **Quando usar**: Auditar infraestrutura AWS
24
- **Capacidades**:
25
- - IAM audit
26
- - S3 bucket security
27
- - Security groups
28
- - Compliance checks
29
-
30
- ### 🔷 Azure
31
-
32
- #### [azure-functions](../../skills/azure-functions/)
33
- **Propósito**: Azure Functions
34
- **Quando usar**: Serverless em Azure
35
- **Capacidades**:
36
- - Function apps
37
- - Triggers e bindings
38
- - Durable functions
39
- - Monitoring
40
-
41
- #### [gcp-cloud-run](../../skills/gcp-cloud-run/)
42
- **Propósito**: Google Cloud Run
43
- **Quando usar**: Containers serverless no GCP
44
-
45
- #### [deployment-procedures](../../skills/deployment-procedures/)
46
- **Propósito**: Procedimentos de deploy
47
- **Quando usar**: Documentar e automatizar deploys
48
-
49
- ## 📋 Tarefas Típicas
50
-
51
- - ✅ Criar funções serverless
52
- - ✅ Configurar infraestrutura cloud
53
- - ✅ Auditar segurança na nuvem
54
- - ✅ Otimizar custos
55
- - ✅ Implementar escalabilidade
56
- - ✅ Monitorar recursos
57
-
58
- ## 🔗 Dependências
59
-
60
- - `BaseAgent`
61
- - `MemorySystem`
62
- - `SkillManager`
63
-
64
- ## 🔄 Fluxo de Trabalho
65
-
66
- 1. **Consulta memória**: Busca arquiteturas similares
67
- 2. **Carrega skills**: aws/azure serverless
68
- 3. **Executa implementação**: Infraestrutura como código
69
- 4. **Registra resultado**: Salva configs em memory.md
70
-
71
- ## 📊 Memória
72
-
73
- Ver [memory.md](./memory.md) para histórico de deployments cloud.
@@ -1,53 +0,0 @@
1
- import { BaseAgent, TaskContext, TaskResult } from '../../base/base-agent.js';
2
-
3
- /**
4
- * Cloud Agent - Especialista em Cloud Platforms
5
- *
6
- * Responsabilidades:
7
- * - AWS, GCP, Azure
8
- * - Serverless architecture
9
- * - Cloud deployment
10
- * - Cloud security
11
- *
12
- * Skills: aws-serverless, gcp-cloud-run, azure-functions, vercel-deployment
13
- */
14
-
15
- export class CloudAgent extends BaseAgent {
16
- constructor(memoryPath: string) {
17
- super('cloud-agent', memoryPath);
18
- }
19
-
20
- async executeTask(taskDescription: string, context: TaskContext): Promise<TaskResult> {
21
- console.log(`\n☁️ Cloud Agent analisando tarefa...\n`);
22
-
23
- const recommendations: string[] = [];
24
-
25
- if (taskDescription.toLowerCase().includes('aws') || taskDescription.toLowerCase().includes('lambda')) {
26
- recommendations.push('✅ Usar Lambda layers para dependencies');
27
- recommendations.push('✅ Configurar VPC adequadamente');
28
- recommendations.push('✅ Implementar CloudWatch monitoring');
29
- recommendations.push('✅ Usar IAM roles com least privilege');
30
- }
31
-
32
- if (taskDescription.toLowerCase().includes('gcp') || taskDescription.toLowerCase().includes('cloud run')) {
33
- recommendations.push('✅ Configurar auto-scaling');
34
- recommendations.push('✅ Usar Cloud Build para CI/CD');
35
- recommendations.push('✅ Implementar Cloud Monitoring');
36
- recommendations.push('✅ Configurar service accounts');
37
- }
38
-
39
- if (taskDescription.toLowerCase().includes('serverless')) {
40
- recommendations.push('✅ Otimizar cold starts');
41
- recommendations.push('✅ Implementar timeout handling');
42
- recommendations.push('✅ Usar environment variables');
43
- recommendations.push('✅ Monitorar custos');
44
- }
45
-
46
- return {
47
- success: true,
48
- details: `Cloud Agent: ${recommendations.length} recomendações`,
49
- recommendations
50
- };
51
- }
52
- }
53
-
@@ -1,14 +0,0 @@
1
- # Cloud Agent - Especialidade
2
-
3
- ## Responsabilidades
4
- - Definir responsabilidades específicas
5
-
6
- ## Expertise
7
- - Definir áreas de expertise
8
-
9
- ## Regras
10
- - Arquivos < 500 linhas
11
- - Não alucinar APIs
12
-
13
- ## Tarefas Típicas
14
- - Listar tarefas típicas
@@ -1,37 +0,0 @@
1
- # Code Auditor Agent
2
-
3
- ## 🎯 Responsabilidade
4
-
5
- Auditoria completa de código: segurança, qualidade, performance, padrões e boas práticas.
6
-
7
- ## 🛠️ Skills Disponíveis
8
-
9
- *Combina skills de Security, Quality e Testing agents*
10
-
11
- ## 📋 Tarefas Típicas
12
-
13
- - ✅ Auditar código completo
14
- - ✅ Detectar vulnerabilidades
15
- - ✅ Validar padrões
16
- - ✅ Checar performance
17
- - ✅ Revisar arquitetura
18
- - ✅ Gerar relatório de auditoria
19
-
20
- ## 🔗 Dependências
21
-
22
- - `BaseAgent`
23
- - `MemorySystem`
24
- - `SkillManager`
25
- - `SecurityAgent`
26
- - `QualityAgent`
27
-
28
- ## 🔄 Fluxo de Trabalho
29
-
30
- 1. **Consulta memória**: Busca auditorias similares
31
- 2. **Carrega skills**: security + quality patterns
32
- 3. **Executa auditoria**: Análise completa
33
- 4. **Registra resultado**: Salva relatório em memory.md
34
-
35
- ## 📊 Memória
36
-
37
- Ver [memory.md](./memory.md) para histórico de auditorias.
@@ -1,334 +0,0 @@
1
- /**
2
- * Code Auditor Agent
3
- *
4
- * Responsabilidades:
5
- * - Escanear código existente em projetos que ainda não têm sistema de agentes
6
- * - Detectar violações das regras absolutas
7
- * - Gerar relatório completo com priorização (P0/P1/P2)
8
- * - Sugerir correções específicas
9
- */
10
-
11
- import * as fs from 'fs';
12
- import * as path from 'path';
13
- import { validateFileLines } from './config.js';
14
-
15
- export interface CodeViolation {
16
- file: string;
17
- line?: number;
18
- type: string;
19
- severity: 'P0' | 'P1' | 'P2';
20
- message: string;
21
- suggestion: string;
22
- }
23
-
24
- export interface AuditReport {
25
- totalFiles: number;
26
- totalViolations: number;
27
- p0Count: number;
28
- p1Count: number;
29
- p2Count: number;
30
- violations: CodeViolation[];
31
- summary: string;
32
- }
33
-
34
- export class CodeAuditorAgent {
35
- private projectRoot: string;
36
-
37
- constructor(projectRoot: string = process.cwd()) {
38
- this.projectRoot = projectRoot;
39
- }
40
-
41
- /**
42
- * Encontra todos os arquivos do projeto para auditoria
43
- */
44
- private findProjectFiles(): string[] {
45
- const files: string[] = [];
46
- const extensions = ['.ts', '.tsx', '.js', '.jsx'];
47
- const excludeDirs = ['node_modules', '.next', 'dist', 'build', '.git', '.agents'];
48
-
49
- const walkDir = (dir: string) => {
50
- const entries = fs.readdirSync(dir, { withFileTypes: true });
51
-
52
- for (const entry of entries) {
53
- const fullPath = path.join(dir, entry.name);
54
-
55
- if (entry.isDirectory()) {
56
- if (!excludeDirs.includes(entry.name)) {
57
- walkDir(fullPath);
58
- }
59
- } else if (entry.isFile()) {
60
- const ext = path.extname(entry.name);
61
- if (extensions.includes(ext)) {
62
- files.push(fullPath);
63
- }
64
- }
65
- }
66
- };
67
-
68
- try {
69
- walkDir(this.projectRoot);
70
- } catch (error) {
71
- console.error('Erro ao escanear diretórios:', error);
72
- }
73
-
74
- return files;
75
- }
76
-
77
- /**
78
- * Audita um arquivo individual
79
- */
80
- private auditFile(filePath: string): CodeViolation[] {
81
- const violations: CodeViolation[] = [];
82
-
83
- if (!fs.existsSync(filePath)) {
84
- return violations;
85
- }
86
-
87
- const content = fs.readFileSync(filePath, 'utf-8');
88
- const lines = content.split('\n');
89
- const relPath = path.relative(this.projectRoot, filePath);
90
-
91
- // Violação 1: Arquivo > 500 linhas (P0)
92
- const lineCheck = validateFileLines(filePath, 500);
93
- if (!lineCheck.valid) {
94
- violations.push({
95
- file: relPath,
96
- type: 'file-too-long',
97
- severity: 'P0',
98
- message: `Arquivo tem ${lineCheck.lineCount} linhas (limite: 500)`,
99
- suggestion: 'Refatorar: extrair hooks, componentes filhos ou funções para utils/lib',
100
- });
101
- }
102
-
103
- // Violação 2: Uso de 'any' não justificado (P1)
104
- lines.forEach((line, index) => {
105
- if (line.match(/:\s*any(?!\w)/) && !line.includes('// justified') && !line.includes('TODO')) {
106
- violations.push({
107
- file: relPath,
108
- line: index + 1,
109
- type: 'typescript-any',
110
- severity: 'P1',
111
- message: 'Uso de "any" detectado sem justificativa',
112
- suggestion: 'Usar tipo específico ou "unknown" + type guard',
113
- });
114
- }
115
- });
116
-
117
- // Violação 3: dangerouslySetInnerHTML sem sanitização (P0)
118
- if (content.includes('dangerouslySetInnerHTML') && !content.includes('DOMPurify')) {
119
- violations.push({
120
- file: relPath,
121
- type: 'xss-vulnerability',
122
- severity: 'P0',
123
- message: 'dangerouslySetInnerHTML sem sanitização detectado',
124
- suggestion: 'Usar DOMPurify.sanitize() antes de renderizar HTML',
125
- });
126
- }
127
-
128
- // Violação 4: service_role no cliente (P0)
129
- if (content.match(/service_role|SUPABASE_SERVICE_ROLE/i) && !filePath.includes('server')) {
130
- violations.push({
131
- file: relPath,
132
- type: 'security-critical',
133
- severity: 'P0',
134
- message: 'service_role key no código cliente (NUNCA expor no browser!)',
135
- suggestion: 'Mover para variável de ambiente server-side ou usar anon key',
136
- });
137
- }
138
-
139
- // Violação 5: console.log com dados sensíveis (P0)
140
- lines.forEach((line, index) => {
141
- if (line.match(/console\.(log|debug|info).*?(password|token|secret|key|credential)/i)) {
142
- violations.push({
143
- file: relPath,
144
- line: index + 1,
145
- type: 'security-leak',
146
- severity: 'P0',
147
- message: 'console.log com dados sensíveis detectado',
148
- suggestion: 'Remover log ou usar técnica de mascaramento',
149
- });
150
- }
151
- });
152
-
153
- // Violação 6: Inputs sem validação (P1)
154
- if (content.includes('<input') && !content.match(/zod|yup|validator/i)) {
155
- violations.push({
156
- file: relPath,
157
- type: 'missing-validation',
158
- severity: 'P1',
159
- message: 'Inputs detectados sem validação (Zod/Yup)',
160
- suggestion: 'Adicionar schema de validação com Zod ou Yup',
161
- });
162
- }
163
-
164
- // Violação 7: fetch() sem tratamento de erro (P1)
165
- lines.forEach((line, index) => {
166
- if (line.includes('fetch(') || line.includes('axios.')) {
167
- const nextLines = lines.slice(index, index + 10).join('\n');
168
- if (!nextLines.match(/\.catch|try|error/i)) {
169
- violations.push({
170
- file: relPath,
171
- line: index + 1,
172
- type: 'missing-error-handling',
173
- severity: 'P1',
174
- message: 'fetch() ou axios sem tratamento de erro',
175
- suggestion: 'Adicionar .catch() ou try-catch',
176
- });
177
- }
178
- }
179
- });
180
-
181
- // Violação 8: Componente com lógica de API direta (P2)
182
- if (relPath.includes('components/') && !relPath.includes('pages/')) {
183
- if (content.match(/fetch\(|axios\.|supabase\./)) {
184
- violations.push({
185
- file: relPath,
186
- type: 'architecture-violation',
187
- severity: 'P2',
188
- message: 'Componente com chamada de API direta',
189
- suggestion: 'Extrair lógica para hook customizado ou service',
190
- });
191
- }
192
- }
193
-
194
- // Violação 9: NEXT_PUBLIC_ com dados sensíveis (P0)
195
- if (content.match(/NEXT_PUBLIC_.*?(SECRET|KEY|PASSWORD|TOKEN)/i)) {
196
- violations.push({
197
- file: relPath,
198
- type: 'security-critical',
199
- severity: 'P0',
200
- message: 'Variável sensível exposta com NEXT_PUBLIC_',
201
- suggestion: 'Remover NEXT_PUBLIC_ e usar apenas no server-side',
202
- });
203
- }
204
-
205
- return violations;
206
- }
207
-
208
- /**
209
- * Executa auditoria completa do projeto
210
- */
211
- async auditProject(): Promise<AuditReport> {
212
- console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
213
- console.log('🔍 AUDITORIA DE CÓDIGO EXISTENTE');
214
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
215
-
216
- console.log('📂 Escaneando arquivos do projeto...');
217
- const files = this.findProjectFiles();
218
- console.log(`✅ ${files.length} arquivos encontrados\n`);
219
-
220
- console.log('🔍 Analisando código...');
221
- const allViolations: CodeViolation[] = [];
222
-
223
- for (const file of files) {
224
- const violations = this.auditFile(file);
225
- allViolations.push(...violations);
226
- }
227
-
228
- console.log(`✅ Análise concluída\n`);
229
-
230
- // Classificar por severidade
231
- const p0Violations = allViolations.filter(v => v.severity === 'P0');
232
- const p1Violations = allViolations.filter(v => v.severity === 'P1');
233
- const p2Violations = allViolations.filter(v => v.severity === 'P2');
234
-
235
- // Gerar relatório
236
- const report: AuditReport = {
237
- totalFiles: files.length,
238
- totalViolations: allViolations.length,
239
- p0Count: p0Violations.length,
240
- p1Count: p1Violations.length,
241
- p2Count: p2Violations.length,
242
- violations: allViolations,
243
- summary: this.generateSummary(allViolations, files.length),
244
- };
245
-
246
- return report;
247
- }
248
-
249
- /**
250
- * Gera resumo da auditoria
251
- */
252
- private generateSummary(violations: CodeViolation[], totalFiles: number): string {
253
- let summary = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
254
- summary += '📊 RELATÓRIO DE AUDITORIA\n';
255
- summary += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
256
-
257
- summary += `📁 Arquivos analisados: ${totalFiles}\n`;
258
- summary += `⚠️ Total de violações: ${violations.length}\n\n`;
259
-
260
- const p0 = violations.filter(v => v.severity === 'P0');
261
- const p1 = violations.filter(v => v.severity === 'P1');
262
- const p2 = violations.filter(v => v.severity === 'P2');
263
-
264
- summary += `💀 P0 (CRÍTICO): ${p0.length}\n`;
265
- summary += `⚠️ P1 (IMPORTANTE): ${p1.length}\n`;
266
- summary += `💡 P2 (MELHORIA): ${p2.length}\n\n`;
267
-
268
- // Agrupar por tipo
269
- const byType: Record<string, number> = {};
270
- violations.forEach(v => {
271
- byType[v.type] = (byType[v.type] || 0) + 1;
272
- });
273
-
274
- summary += '📋 Violações por tipo:\n';
275
- Object.entries(byType)
276
- .sort((a, b) => b[1] - a[1])
277
- .forEach(([type, count]) => {
278
- summary += ` - ${type}: ${count}\n`;
279
- });
280
-
281
- summary += '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
282
-
283
- if (p0.length > 0) {
284
- summary += '\n💀 P0 - BLOQUEADORES CRÍTICOS:\n\n';
285
- p0.forEach((v, index) => {
286
- summary += `${index + 1}. ${v.file}${v.line ? `:${v.line}` : ''}\n`;
287
- summary += ` ❌ ${v.message}\n`;
288
- summary += ` 💡 ${v.suggestion}\n\n`;
289
- });
290
- }
291
-
292
- if (p1.length > 0 && p1.length <= 10) {
293
- summary += '\n⚠️ P1 - IMPORTANTES (primeiros 10):\n\n';
294
- p1.slice(0, 10).forEach((v, index) => {
295
- summary += `${index + 1}. ${v.file}${v.line ? `:${v.line}` : ''}\n`;
296
- summary += ` ⚠️ ${v.message}\n`;
297
- summary += ` 💡 ${v.suggestion}\n\n`;
298
- });
299
- }
300
-
301
- summary += '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
302
- summary += '✅ PRÓXIMOS PASSOS:\n';
303
- summary += '1. Corrigir todas as violações P0 (bloqueadores críticos)\n';
304
- summary += '2. Revisar violações P1 (importantes para qualidade)\n';
305
- summary += '3. Considerar violações P2 (melhorias opcionais)\n';
306
- summary += '4. Execute novamente após correções para validar\n';
307
- summary += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
308
-
309
- return summary;
310
- }
311
-
312
- /**
313
- * Salva relatório em arquivo
314
- */
315
- saveReport(report: AuditReport): void {
316
- const reportPath = 'docs/AUDIT_REPORT.md';
317
-
318
- let content = `# Relatório de Auditoria de Código\n\n`;
319
- content += `**Data**: ${new Date().toISOString().split('T')[0]}\n`;
320
- content += `**Arquivos analisados**: ${report.totalFiles}\n`;
321
- content += `**Total de violações**: ${report.totalViolations}\n\n`;
322
-
323
- content += `## Resumo\n\n`;
324
- content += `- 💀 P0 (Crítico): ${report.p0Count}\n`;
325
- content += `- ⚠️ P1 (Importante): ${report.p1Count}\n`;
326
- content += `- 💡 P2 (Melhoria): ${report.p2Count}\n\n`;
327
-
328
- content += report.summary;
329
-
330
- fs.writeFileSync(reportPath, content, 'utf-8');
331
- console.log(`✅ Relatório salvo em: ${reportPath}\n`);
332
- }
333
- }
334
-
@@ -1,14 +0,0 @@
1
- # Code Auditor Agent - Especialidade
2
-
3
- ## Responsabilidades
4
- - Definir responsabilidades específicas
5
-
6
- ## Expertise
7
- - Definir áreas de expertise
8
-
9
- ## Regras
10
- - Arquivos < 500 linhas
11
- - Não alucinar APIs
12
-
13
- ## Tarefas Típicas
14
- - Listar tarefas típicas