wegho-agentes 4.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 (94) hide show
  1. package/.agents/AGENT_WORKFLOW.md +528 -0
  2. package/.agents/AI_COMPATIBILITY.md +332 -0
  3. package/.agents/CLI.md +222 -0
  4. package/.agents/README.md +130 -0
  5. package/.agents/cli.js +389 -0
  6. package/.agents/code-auditor-agent.ts +333 -0
  7. package/.agents/config.ts +145 -0
  8. package/.agents/context-loader.ts +300 -0
  9. package/.agents/core/agent-parallelizer.test.ts +94 -0
  10. package/.agents/core/agent-parallelizer.ts +108 -0
  11. package/.agents/core/architecture-agent.ts +237 -0
  12. package/.agents/core/base-agent.ts +311 -0
  13. package/.agents/core/cache-manager.test.ts +147 -0
  14. package/.agents/core/cache-manager.ts +184 -0
  15. package/.agents/core/documentation-agent.ts +183 -0
  16. package/.agents/core/feedback-collector.ts +207 -0
  17. package/.agents/core/frontend-agent.ts +210 -0
  18. package/.agents/core/inventory-agent.ts +582 -0
  19. package/.agents/core/memory-system.ts +397 -0
  20. package/.agents/core/quality-agent.ts +268 -0
  21. package/.agents/core/retry-utility.test.ts +165 -0
  22. package/.agents/core/retry-utility.ts +140 -0
  23. package/.agents/core/security-agent.ts +217 -0
  24. package/.agents/core/workflow-validator.test.ts +171 -0
  25. package/.agents/core/workflow-validator.ts +158 -0
  26. package/.agents/domains/README.md +53 -0
  27. package/.agents/domains/logistics/route-agent.ts +177 -0
  28. package/.agents/domains/news/cms-agent.ts +158 -0
  29. package/.agents/domains/news/seo-agent.ts +170 -0
  30. package/.agents/domains/production/production-control-agent.ts +169 -0
  31. package/.agents/example-learning-system.js +118 -0
  32. package/.agents/init.ts +164 -0
  33. package/.agents/memory/architecture-agent/failures.json +1 -0
  34. package/.agents/memory/architecture-agent/learnings.json +1 -0
  35. package/.agents/memory/architecture-agent/specialty.md +31 -0
  36. package/.agents/memory/architecture-agent/successes.json +16 -0
  37. package/.agents/memory/cms-agent/failures.json +1 -0
  38. package/.agents/memory/cms-agent/learnings.json +1 -0
  39. package/.agents/memory/cms-agent/specialty.md +30 -0
  40. package/.agents/memory/cms-agent/successes.json +16 -0
  41. package/.agents/memory/documentation-agent/failures.json +1 -0
  42. package/.agents/memory/documentation-agent/learnings.json +1 -0
  43. package/.agents/memory/documentation-agent/specialty.md +33 -0
  44. package/.agents/memory/documentation-agent/successes.json +16 -0
  45. package/.agents/memory/frontend-agent/failures.json +1 -0
  46. package/.agents/memory/frontend-agent/learnings.json +1 -0
  47. package/.agents/memory/frontend-agent/specialty.md +30 -0
  48. package/.agents/memory/frontend-agent/successes.json +16 -0
  49. package/.agents/memory/inventory-agent/failures.json +1 -0
  50. package/.agents/memory/inventory-agent/inventory/index.json +8 -0
  51. package/.agents/memory/inventory-agent/inventory/types.json +77716 -0
  52. package/.agents/memory/inventory-agent/inventory/variables.json +405 -0
  53. package/.agents/memory/inventory-agent/learnings.json +1 -0
  54. package/.agents/memory/inventory-agent/specialty.md +129 -0
  55. package/.agents/memory/inventory-agent/successes.json +30 -0
  56. package/.agents/memory/production-control-agent/failures.json +1 -0
  57. package/.agents/memory/production-control-agent/learnings.json +1 -0
  58. package/.agents/memory/production-control-agent/specialty.md +29 -0
  59. package/.agents/memory/production-control-agent/successes.json +16 -0
  60. package/.agents/memory/quality-agent/failures.json +16 -0
  61. package/.agents/memory/quality-agent/learnings.json +1 -0
  62. package/.agents/memory/quality-agent/specialty.md +31 -0
  63. package/.agents/memory/quality-agent/successes.json +1 -0
  64. package/.agents/memory/reference-repositories.json +271 -0
  65. package/.agents/memory/route-agent/failures.json +1 -0
  66. package/.agents/memory/route-agent/learnings.json +1 -0
  67. package/.agents/memory/route-agent/specialty.md +29 -0
  68. package/.agents/memory/route-agent/successes.json +16 -0
  69. package/.agents/memory/security-agent/failures.json +1 -0
  70. package/.agents/memory/security-agent/learnings.json +1 -0
  71. package/.agents/memory/security-agent/specialty.md +31 -0
  72. package/.agents/memory/security-agent/successes.json +16 -0
  73. package/.agents/memory/seo-agent/failures.json +1 -0
  74. package/.agents/memory/seo-agent/learnings.json +1 -0
  75. package/.agents/memory/seo-agent/specialty.md +31 -0
  76. package/.agents/memory/seo-agent/successes.json +16 -0
  77. package/.agents/orchestrator.ts +438 -0
  78. package/.agents/project-discovery-agent.ts +342 -0
  79. package/.agents/security/pentesting-agent.py +387 -0
  80. package/.agents/security/python-bridge.ts +193 -0
  81. package/.agents/security/vulnerability-db.json +201 -0
  82. package/.agents/task-analyzer-agent.ts +346 -0
  83. package/.agents/test-init-context.js +67 -0
  84. package/INSTALL.md +300 -0
  85. package/LICENSE +21 -0
  86. package/README.md +315 -0
  87. package/docs/AGENT_RULES.md +292 -0
  88. package/docs/BUILD_HISTORY.md +65 -0
  89. package/docs/DESIGN_SYSTEM.md +256 -0
  90. package/docs/LEARNING_SYSTEM.md +326 -0
  91. package/docs/SYMBOLS_TREE.md +182 -0
  92. package/docs/VERSION.md +6 -0
  93. package/docs/architecture.md +111 -0
  94. package/package.json +60 -0
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Project Discovery Agent
3
+ *
4
+ * Responsabilidades:
5
+ * - Detectar se é projeto novo ou existente
6
+ * - Fazer perguntas sobre o projeto
7
+ * - Analisar respostas e gerar relatório
8
+ * - Sugerir/criar agentes customizados
9
+ * - Adicionar estruturas ao código
10
+ */
11
+
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+ import { DomainType } from './config';
15
+
16
+ export interface ProjectProfile {
17
+ isNewProject: boolean;
18
+ projectName: string;
19
+ domain: DomainType | 'custom';
20
+ customDomain?: string;
21
+ stack: string[];
22
+ objectives: string[];
23
+ features: string[];
24
+ teamSize: number;
25
+ hasDatabase: boolean;
26
+ hasCMS: boolean;
27
+ hasAuth: boolean;
28
+ hasPayments: boolean;
29
+ customNeeds: string[];
30
+ }
31
+
32
+ export interface AgentRecommendation {
33
+ name: string;
34
+ file: string;
35
+ purpose: string;
36
+ priority: 'high' | 'medium' | 'low';
37
+ autoCreate: boolean;
38
+ }
39
+
40
+ export class ProjectDiscoveryAgent {
41
+ private readline: any;
42
+
43
+ constructor() {
44
+ this.readline = require('readline').createInterface({
45
+ input: process.stdin,
46
+ output: process.stdout,
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Detecta se é projeto novo
52
+ */
53
+ detectNewProject(): boolean {
54
+ // Verifica se já existe documentação de agentes
55
+ const hasAgentRules = fs.existsSync('docs/AGENT_RULES.md');
56
+ const hasBuildHistory = fs.existsSync('docs/BUILD_HISTORY.md');
57
+ const hasSymbolsTree = fs.existsSync('docs/SYMBOLS_TREE.md');
58
+
59
+ // Se não existe nenhum, é novo
60
+ if (!hasAgentRules && !hasBuildHistory && !hasSymbolsTree) {
61
+ return true;
62
+ }
63
+
64
+ // Se tem BUILD_HISTORY vazio ou só com template, é novo
65
+ if (hasBuildHistory) {
66
+ const content = fs.readFileSync('docs/BUILD_HISTORY.md', 'utf-8');
67
+ if (content.includes('[Próximas Entradas]') && !content.includes('Build 001')) {
68
+ return true;
69
+ }
70
+ }
71
+
72
+ return false;
73
+ }
74
+
75
+ /**
76
+ * Faz pergunta ao usuário
77
+ */
78
+ private async ask(question: string): Promise<string> {
79
+ return new Promise((resolve) => {
80
+ this.readline.question(question, (answer: string) => {
81
+ resolve(answer.trim());
82
+ });
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Pergunta de múltipla escolha
88
+ */
89
+ private async askChoice(question: string, choices: string[]): Promise<string> {
90
+ console.log(`\n${question}`);
91
+ choices.forEach((choice, index) => {
92
+ console.log(` ${index + 1}. ${choice}`);
93
+ });
94
+
95
+ const answer = await this.ask('Escolha (número): ');
96
+ const index = parseInt(answer) - 1;
97
+
98
+ if (index >= 0 && index < choices.length) {
99
+ return choices[index];
100
+ }
101
+
102
+ return choices[0]; // Default primeira opção
103
+ }
104
+
105
+ /**
106
+ * Executa descoberta interativa do projeto
107
+ */
108
+ async discoverProject(): Promise<ProjectProfile> {
109
+ console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
110
+ console.log('🔍 DESCOBERTA DO PROJETO');
111
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
112
+
113
+ const isNewProject = this.detectNewProject();
114
+
115
+ if (isNewProject) {
116
+ console.log('✨ Detectado: PROJETO NOVO\n');
117
+ } else {
118
+ console.log('📦 Detectado: PROJETO EXISTENTE\n');
119
+ console.log('🔍 Vou primeiro analisar o código existente para gerar relatório...\n');
120
+
121
+ // NOVO: Executar auditoria de código para projetos existentes
122
+ const { CodeAuditorAgent } = require('./code-auditor-agent');
123
+ const auditor = new CodeAuditorAgent();
124
+ const auditReport = await auditor.auditProject();
125
+
126
+ // Mostrar resumo da auditoria
127
+ console.log(auditReport.summary);
128
+
129
+ // Salvar relatório
130
+ auditor.saveReport(auditReport);
131
+
132
+ console.log('📋 Execute as correções recomendadas antes de prosseguir.\n');
133
+ console.log('Agora vamos configurar os agentes...\n');
134
+ }
135
+
136
+ // Perguntas básicas
137
+ const projectName = await this.ask('📝 Nome do projeto: ');
138
+
139
+ const domain = await this.askChoice(
140
+ '🎯 Qual o domínio principal?',
141
+ ['Site de Notícias', 'Produção/Expedição', 'Logística', 'E-commerce', 'SaaS', 'Outro']
142
+ );
143
+
144
+ let customDomain: string | undefined;
145
+ if (domain === 'Outro') {
146
+ customDomain = await this.ask(' Descreva o domínio: ');
147
+ }
148
+
149
+ // Stack
150
+ console.log('\n💻 Stack Tecnológica (separado por vírgula):');
151
+ const stackInput = await this.ask(' Ex: Next.js, Supabase, React, TypeScript: ');
152
+ const stack = stackInput.split(',').map(s => s.trim()).filter(s => s.length > 0);
153
+
154
+ // Objetivos
155
+ console.log('\n🎯 Principais objetivos (separado por vírgula):');
156
+ const objectivesInput = await this.ask(' Ex: Gestão de conteúdo, Dashboard analytics: ');
157
+ const objectives = objectivesInput.split(',').map(s => s.trim()).filter(s => s.length > 0);
158
+
159
+ // Features
160
+ console.log('\n📋 Features principais (separado por vírgula):');
161
+ const featuresInput = await this.ask(' Ex: Login, Pagamentos, Notificações: ');
162
+ const features = featuresInput.split(',').map(s => s.trim()).filter(s => s.length > 0);
163
+
164
+ // Tamanho do time
165
+ const teamSizeInput = await this.ask('\n👥 Tamanho do time (número): ');
166
+ const teamSize = parseInt(teamSizeInput) || 1;
167
+
168
+ // Questões específicas
169
+ const hasDatabase = (await this.ask('\n🗄️ Usa banco de dados? (s/n): ')).toLowerCase() === 's';
170
+ const hasCMS = (await this.ask('📰 Precisa de CMS? (s/n): ')).toLowerCase() === 's';
171
+ const hasAuth = (await this.ask('🔐 Tem autenticação? (s/n): ')).toLowerCase() === 's';
172
+ const hasPayments = (await this.ask('💳 Processa pagamentos? (s/n): ')).toLowerCase() === 's';
173
+
174
+ // Necessidades customizadas
175
+ console.log('\n🔧 Necessidades específicas do projeto (separado por vírgula):');
176
+ const customNeedsInput = await this.ask(' Ex: Integração com API externa, Relatórios PDF: ');
177
+ const customNeeds = customNeedsInput.split(',').map(s => s.trim()).filter(s => s.length > 0);
178
+
179
+ this.readline.close();
180
+
181
+ // Mapear domínio
182
+ const domainMapping: Record<string, DomainType | 'custom'> = {
183
+ 'Site de Notícias': 'news',
184
+ 'Produção/Expedição': 'production',
185
+ 'Logística': 'logistics',
186
+ 'E-commerce': 'custom',
187
+ 'SaaS': 'custom',
188
+ 'Outro': 'custom',
189
+ };
190
+
191
+ return {
192
+ isNewProject,
193
+ projectName,
194
+ domain: domainMapping[domain] || 'custom',
195
+ customDomain: domain === 'Outro' ? customDomain : undefined,
196
+ stack,
197
+ objectives,
198
+ features,
199
+ teamSize,
200
+ hasDatabase,
201
+ hasCMS,
202
+ hasAuth,
203
+ hasPayments,
204
+ customNeeds,
205
+ };
206
+ }
207
+
208
+ /**
209
+ * Gera recomendações de agentes baseado no perfil
210
+ */
211
+ generateRecommendations(profile: ProjectProfile): AgentRecommendation[] {
212
+ const recommendations: AgentRecommendation[] = [];
213
+
214
+ // Agentes core (sempre recomendados)
215
+ recommendations.push(
216
+ { name: 'Frontend', file: 'core/frontend-agent.ts', purpose: 'Validar UI/UX', priority: 'high', autoCreate: true },
217
+ { name: 'Security', file: 'core/security-agent.ts', purpose: 'Detectar vulnerabilidades', priority: 'high', autoCreate: true },
218
+ { name: 'Architecture', file: 'core/architecture-agent.ts', purpose: 'Manter organização', priority: 'high', autoCreate: true },
219
+ { name: 'Quality', file: 'core/quality-agent.ts', purpose: 'Lint, build, tests', priority: 'high', autoCreate: true },
220
+ { name: 'Documentation', file: 'core/documentation-agent.ts', purpose: 'Docs automáticas', priority: 'medium', autoCreate: true }
221
+ );
222
+
223
+ // Agentes de domínio específicos
224
+ if (profile.domain === 'news' || profile.hasCMS) {
225
+ recommendations.push(
226
+ { name: 'CMS', file: 'domains/news/cms-agent.ts', purpose: 'Gestão de conteúdo', priority: 'high', autoCreate: true },
227
+ { name: 'SEO', file: 'domains/news/seo-agent.ts', purpose: 'Otimização SEO', priority: 'high', autoCreate: true }
228
+ );
229
+ }
230
+
231
+ if (profile.domain === 'production') {
232
+ recommendations.push(
233
+ { name: 'Production Control', file: 'domains/production/production-control-agent.ts', purpose: 'Eventos de produção', priority: 'high', autoCreate: true },
234
+ { name: 'Quality Control', file: 'domains/production/quality-control-agent.ts', purpose: 'Controle de qualidade', priority: 'medium', autoCreate: false }
235
+ );
236
+ }
237
+
238
+ if (profile.domain === 'logistics') {
239
+ recommendations.push(
240
+ { name: 'Route', file: 'domains/logistics/route-agent.ts', purpose: 'Otimização de rotas', priority: 'high', autoCreate: true },
241
+ { name: 'Fleet', file: 'domains/logistics/fleet-agent.ts', purpose: 'Gestão de frota', priority: 'medium', autoCreate: false }
242
+ );
243
+ }
244
+
245
+ // Agentes baseados em features
246
+ if (profile.hasAuth) {
247
+ recommendations.push(
248
+ { name: 'Auth', file: 'domains/custom/auth-agent.ts', purpose: 'Validar fluxos de autenticação', priority: 'high', autoCreate: true }
249
+ );
250
+ }
251
+
252
+ if (profile.hasPayments) {
253
+ recommendations.push(
254
+ { name: 'Payments', file: 'domains/custom/payments-agent.ts', purpose: 'Validar transações', priority: 'high', autoCreate: true }
255
+ );
256
+ }
257
+
258
+ if (profile.hasDatabase) {
259
+ recommendations.push(
260
+ { name: 'Database Security', file: 'core/database-security-agent.ts', purpose: 'RLS e policies', priority: 'high', autoCreate: true }
261
+ );
262
+ }
263
+
264
+ return recommendations;
265
+ }
266
+
267
+ /**
268
+ * Gera relatório do projeto
269
+ */
270
+ generateReport(profile: ProjectProfile, recommendations: AgentRecommendation[]): string {
271
+ let report = '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
272
+ report += '📊 RELATÓRIO DO PROJETO\n';
273
+ report += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
274
+
275
+ report += `📝 **Nome**: ${profile.projectName}\n`;
276
+ report += `🎯 **Domínio**: ${profile.domain}${profile.customDomain ? ` (${profile.customDomain})` : ''}\n`;
277
+ report += `✨ **Status**: ${profile.isNewProject ? 'Projeto Novo' : 'Projeto Existente'}\n`;
278
+ report += `👥 **Time**: ${profile.teamSize} pessoa(s)\n\n`;
279
+
280
+ report += `💻 **Stack**:\n`;
281
+ profile.stack.forEach(s => report += ` - ${s}\n`);
282
+
283
+ report += `\n🎯 **Objetivos**:\n`;
284
+ profile.objectives.forEach(o => report += ` - ${o}\n`);
285
+
286
+ report += `\n📋 **Features**:\n`;
287
+ profile.features.forEach(f => report += ` - ${f}\n`);
288
+
289
+ report += `\n🔧 **Características**:\n`;
290
+ report += ` - Database: ${profile.hasDatabase ? '✅' : '❌'}\n`;
291
+ report += ` - CMS: ${profile.hasCMS ? '✅' : '❌'}\n`;
292
+ report += ` - Auth: ${profile.hasAuth ? '✅' : '❌'}\n`;
293
+ report += ` - Payments: ${profile.hasPayments ? '✅' : '❌'}\n`;
294
+
295
+ if (profile.customNeeds.length > 0) {
296
+ report += `\n🔧 **Necessidades Específicas**:\n`;
297
+ profile.customNeeds.forEach(n => report += ` - ${n}\n`);
298
+ }
299
+
300
+ report += `\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
301
+ report += '🤖 AGENTES RECOMENDADOS\n';
302
+ report += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
303
+
304
+ const highPriority = recommendations.filter(r => r.priority === 'high');
305
+ const mediumPriority = recommendations.filter(r => r.priority === 'medium');
306
+ const lowPriority = recommendations.filter(r => r.priority === 'low');
307
+
308
+ if (highPriority.length > 0) {
309
+ report += '🔴 **Alta Prioridade** (serão criados automaticamente):\n';
310
+ highPriority.forEach(r => {
311
+ report += ` ✅ ${r.name} - ${r.purpose}\n`;
312
+ report += ` 📄 ${r.file}\n`;
313
+ });
314
+ report += '\n';
315
+ }
316
+
317
+ if (mediumPriority.length > 0) {
318
+ report += '🟡 **Média Prioridade** (opcionais):\n';
319
+ mediumPriority.forEach(r => {
320
+ report += ` ⚪ ${r.name} - ${r.purpose}\n`;
321
+ report += ` 📄 ${r.file}\n`;
322
+ });
323
+ report += '\n';
324
+ }
325
+
326
+ report += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
327
+ report += `✅ **Total**: ${recommendations.length} agentes recomendados\n`;
328
+ report += `🔴 **Auto-criação**: ${recommendations.filter(r => r.autoCreate).length} agentes\n`;
329
+ report += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
330
+
331
+ return report;
332
+ }
333
+
334
+ /**
335
+ * Salva perfil do projeto
336
+ */
337
+ saveProfile(profile: ProjectProfile): void {
338
+ const profilePath = 'docs/PROJECT_PROFILE.json';
339
+ fs.writeFileSync(profilePath, JSON.stringify(profile, null, 2), 'utf-8');
340
+ console.log(`✅ Perfil salvo em: ${profilePath}\n`);
341
+ }
342
+ }