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.
- package/.agent/skills/wegho-global-rules/SKILL.md +20 -0
- package/.agent/workflows/PROMPT_GUIDE.md +7 -4
- package/.agents/cli.ts +29 -21
- package/.agents/core/base-agent.ts +28 -12
- package/.agents/core/memory-system.ts +45 -13
- package/.agents/core/report-generator.ts +26 -19
- package/.agents/orchestrator.ts +104 -74
- package/.clinerules +318 -1229
- package/.cursorrules +0 -189
- package/README.md +3 -3
- package/docs/VERSION.md +3 -2
- package/package.json +3 -3
- package/.agents/agents/ai-agents/README.md +0 -175
- package/.agents/agents/ai-agents/agent.ts +0 -83
- package/.agents/agents/ai-agents/specialty.md +0 -14
- package/.agents/agents/architecture/README.md +0 -61
- package/.agents/agents/architecture/agent.ts +0 -238
- package/.agents/agents/architecture/memory.md +0 -111
- package/.agents/agents/architecture/specialty.md +0 -31
- package/.agents/agents/automation/README.md +0 -60
- package/.agents/agents/automation/agent.ts +0 -61
- package/.agents/agents/automation/specialty.md +0 -14
- package/.agents/agents/backend/README.md +0 -155
- package/.agents/agents/backend/agent.ts +0 -100
- package/.agents/agents/backend/specialty.md +0 -14
- package/.agents/agents/cloud/README.md +0 -73
- package/.agents/agents/cloud/agent.ts +0 -53
- package/.agents/agents/cloud/specialty.md +0 -14
- package/.agents/agents/code-auditor/README.md +0 -37
- package/.agents/agents/code-auditor/agent.ts +0 -334
- package/.agents/agents/code-auditor/specialty.md +0 -14
- package/.agents/agents/cro/README.md +0 -200
- package/.agents/agents/cro/agent.ts +0 -61
- package/.agents/agents/cro/specialty.md +0 -14
- package/.agents/agents/database/README.md +0 -67
- package/.agents/agents/database/agent.ts +0 -93
- package/.agents/agents/database/specialty.md +0 -14
- package/.agents/agents/devops/README.md +0 -84
- package/.agents/agents/devops/agent.ts +0 -54
- package/.agents/agents/devops/specialty.md +0 -14
- package/.agents/agents/documentation/README.md +0 -107
- package/.agents/agents/documentation/agent.ts +0 -253
- package/.agents/agents/documentation/memory.md +0 -56
- package/.agents/agents/documentation/specialty.md +0 -33
- package/.agents/agents/frontend/README.md +0 -188
- package/.agents/agents/frontend/agent.ts +0 -211
- package/.agents/agents/frontend/memory.md +0 -139
- package/.agents/agents/frontend/specialty.md +0 -30
- package/.agents/agents/inventory/README.md +0 -35
- package/.agents/agents/inventory/agent.ts +0 -758
- package/.agents/agents/inventory/memory.md +0 -50
- package/.agents/agents/inventory/specialty.md +0 -129
- package/.agents/agents/nextjs/README.md +0 -58
- package/.agents/agents/nextjs/agent.ts +0 -114
- package/.agents/agents/nextjs/specialty.md +0 -14
- package/.agents/agents/pentest/README.md +0 -228
- package/.agents/agents/pentest/agent.ts +0 -96
- package/.agents/agents/pentest/specialty.md +0 -14
- package/.agents/agents/planning/README.md +0 -107
- package/.agents/agents/planning/agent.ts +0 -389
- package/.agents/agents/planning/specialty.md +0 -14
- package/.agents/agents/project-discovery/README.md +0 -35
- package/.agents/agents/project-discovery/agent.ts +0 -344
- package/.agents/agents/project-discovery/specialty.md +0 -14
- package/.agents/agents/quality/README.md +0 -81
- package/.agents/agents/quality/agent.ts +0 -269
- package/.agents/agents/quality/memory.md +0 -110
- package/.agents/agents/quality/specialty.md +0 -31
- package/.agents/agents/rag/README.md +0 -41
- package/.agents/agents/rag/agent.ts +0 -85
- package/.agents/agents/rag/specialty.md +0 -14
- package/.agents/agents/security/README.md +0 -152
- package/.agents/agents/security/agent.ts +0 -218
- package/.agents/agents/security/memory.md +0 -91
- package/.agents/agents/security/specialty.md +0 -31
- package/.agents/agents/task-analyzer/README.md +0 -36
- package/.agents/agents/task-analyzer/agent.ts +0 -462
- package/.agents/agents/task-analyzer/specialty.md +0 -14
- package/.agents/agents/testing/README.md +0 -161
- package/.agents/agents/testing/agent.ts +0 -61
- package/.agents/agents/testing/specialty.md +0 -14
- package/.agents/agents/uiux/README.md +0 -68
- package/.agents/agents/uiux/agent.ts +0 -95
- package/.agents/agents/uiux/specialty.md +0 -14
- package/.agents/base/base-agent.ts +0 -331
- package/.agents/base/memory-system.ts +0 -397
- package/.agents/base/skill-manager.ts +0 -95
- package/.agents/convert-memory.ps1 +0 -153
- package/.agents/examples/reporting-example.md +0 -203
- package/.agents/managers/build-manager.ts +0 -304
- package/.agents/managers/cache-manager.ts +0 -184
- package/.agents/managers/checkpoint-manager.ts +0 -299
- package/.agents/migrate-agents.ps1 +0 -117
- package/.agents/templates/change-report.md +0 -55
- package/.agents/templates/execution-plan.md +0 -36
- package/.agents/unmapped-skills.txt +0 -0
- package/.agents/utils/agent-migrator.ts +0 -360
- package/.agents/utils/agent-monitor.ts +0 -102
- package/.agents/utils/agent-parallelizer.ts +0 -108
- package/.agents/utils/context-monitor.ts +0 -140
- package/.agents/utils/feedback-collector.ts +0 -207
- package/.agents/utils/file-generator.ts +0 -304
- package/.agents/utils/memory-converter.ts +0 -217
- package/.agents/utils/memory-dashboard.ts +0 -147
- package/.agents/utils/performance-tracker.ts +0 -275
- package/.agents/utils/report-generator.ts +0 -193
- package/.agents/utils/retry-utility.ts +0 -140
- package/.agents/utils/workflow-validator.ts +0 -158
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wegho-global-rules
|
|
3
|
+
description: Always-on rules for wegho-agentes. Applies to any task in this workspace and must be loaded on every agent switch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wegho Global Rules
|
|
7
|
+
|
|
8
|
+
This skill enforces the global rules and mandatory workflow for all agents.
|
|
9
|
+
|
|
10
|
+
## Always load these files before doing any work
|
|
11
|
+
- `docs/AGENT_RULES.md`
|
|
12
|
+
- `.agents/AGENT_WORKFLOW.md`
|
|
13
|
+
- `.agent/workflows/run-agents-workflow.md`
|
|
14
|
+
|
|
15
|
+
## Mandatory behavior
|
|
16
|
+
1. Follow all rules in `docs/AGENT_RULES.md` with no exceptions.
|
|
17
|
+
2. Execute the mandatory workflow steps from `.agents/AGENT_WORKFLOW.md` for every task.
|
|
18
|
+
3. If you switch agents or if more than 10 minutes pass, re-read the files above and restate the constraints before continuing.
|
|
19
|
+
4. If any rule conflicts with the user request, stop and ask for clarification.
|
|
20
|
+
5. If a workflow step cannot be completed, report it explicitly and block completion.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# Prompt Completo para Executar Workflow dos Agentes
|
|
2
2
|
|
|
3
|
-
## 🎯 Objetivo
|
|
4
|
-
Executar o sistema de agentes `wegho-agentes` garantindo que todos os 6 passos obrigatórios sejam seguidos e validados.
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
## 🎯 Objetivo
|
|
4
|
+
Executar o sistema de agentes `wegho-agentes` garantindo que todos os 6 passos obrigatórios sejam seguidos e validados.
|
|
5
|
+
|
|
6
|
+
## ✅ Regra global (Antigravity)
|
|
7
|
+
Sempre carregar a skill `wegho-global-rules` antes de executar qualquer tarefa ou trocar de agente.
|
|
8
|
+
|
|
9
|
+
---
|
|
7
10
|
|
|
8
11
|
## 📋 Prompt para IA
|
|
9
12
|
|
package/.agents/cli.ts
CHANGED
|
@@ -16,11 +16,17 @@ import * as fs from 'fs';
|
|
|
16
16
|
import * as path from 'path';
|
|
17
17
|
import { execSync } from 'child_process';
|
|
18
18
|
import * as readline from 'readline';
|
|
19
|
-
import { IntelligentOrchestrator } from './orchestrator.js';
|
|
20
|
-
import { fileURLToPath } from 'url';
|
|
21
|
-
|
|
22
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
-
const __dirname = path.dirname(__filename);
|
|
19
|
+
import { IntelligentOrchestrator } from './orchestrator.js';
|
|
20
|
+
import { fileURLToPath } from 'url';
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = path.dirname(__filename);
|
|
24
|
+
|
|
25
|
+
function estimateTokens(text: string): number {
|
|
26
|
+
const normalized = text.trim();
|
|
27
|
+
if (!normalized) return 0;
|
|
28
|
+
return Math.ceil(normalized.length / 4);
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
// Define commands using a mapped type or interface if needed, but simple object is fine
|
|
26
32
|
const COMMANDS: Record<string, () => Promise<void> | void> = {
|
|
@@ -401,22 +407,24 @@ async function main(): Promise<void> {
|
|
|
401
407
|
// Se não for um comando explícito (!), trate como uma tarefa para o orquestrador
|
|
402
408
|
const isCommand = command.startsWith('!');
|
|
403
409
|
|
|
404
|
-
if (isCommand) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
console.log(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
410
|
+
if (isCommand) {
|
|
411
|
+
console.log(`🧮 Tokens estimados (comando): ${estimateTokens(command)}`);
|
|
412
|
+
const handler = COMMANDS[command.toLowerCase()];
|
|
413
|
+
if (!handler) {
|
|
414
|
+
console.log(`\n❌ Comando não encontrado: ${command}\n`);
|
|
415
|
+
console.log('💡 Use "!comandos" para ver a lista completa.\n');
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
await handler();
|
|
419
|
+
} else {
|
|
420
|
+
// Modo Tarefa: "npm run agent 'Minha tarefa'"
|
|
421
|
+
try {
|
|
422
|
+
const taskDescription = process.argv.slice(2).join(' ');
|
|
423
|
+
console.log(`\n🤖 Nova tarefa recebida: "${taskDescription}"\n`);
|
|
424
|
+
console.log(`🧮 Tokens estimados (tarefa): ${estimateTokens(taskDescription)}\n`);
|
|
425
|
+
|
|
426
|
+
const context = await initializeContext(true);
|
|
427
|
+
const orchestrator = new IntelligentOrchestrator(context);
|
|
420
428
|
|
|
421
429
|
await orchestrator.orchestrateTask(taskDescription);
|
|
422
430
|
} catch (error: any) {
|
|
@@ -65,16 +65,19 @@ export abstract class BaseAgent {
|
|
|
65
65
|
/**
|
|
66
66
|
* Executa tarefa consultando memória
|
|
67
67
|
*/
|
|
68
|
-
async executeWithMemory(taskDescription: string, context: TaskContext): Promise<TaskResult> {
|
|
69
|
-
console.log(`\n${'='.repeat(60)}`);
|
|
70
|
-
console.log(`🤖 AGENTE ATIVO: ${this.agentName.toUpperCase()}`);
|
|
71
|
-
console.log(`${'='.repeat(60)}`);
|
|
72
|
-
console.log(`📋 Tarefa: ${taskDescription}`);
|
|
73
|
-
console.log(`⏰ Início: ${new Date().toLocaleTimeString('pt-BR')}\n`);
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
this.
|
|
77
|
-
|
|
68
|
+
async executeWithMemory(taskDescription: string, context: TaskContext): Promise<TaskResult> {
|
|
69
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
70
|
+
console.log(`🤖 AGENTE ATIVO: ${this.agentName.toUpperCase()}`);
|
|
71
|
+
console.log(`${'='.repeat(60)}`);
|
|
72
|
+
console.log(`📋 Tarefa: ${taskDescription}`);
|
|
73
|
+
console.log(`⏰ Início: ${new Date().toLocaleTimeString('pt-BR')}\n`);
|
|
74
|
+
|
|
75
|
+
// Resetar passos do workflow a cada execução
|
|
76
|
+
this.initializeWorkflowSteps();
|
|
77
|
+
|
|
78
|
+
// PASSO 1: Consultar casos similares
|
|
79
|
+
this.markStepCompleted('Consultar Memória', { count: 0 });
|
|
80
|
+
const similarCases = this.memory.getSimilarCases(this.agentName, taskDescription, 5);
|
|
78
81
|
|
|
79
82
|
if (similarCases.length > 0) {
|
|
80
83
|
console.log(`💭 [${this.agentName}] Encontrei ${similarCases.length} caso(s) similar(es):`);
|
|
@@ -85,8 +88,21 @@ export abstract class BaseAgent {
|
|
|
85
88
|
console.log(` Feedback: ${case_.userFeedback.satisfied ? '👍' : '👎'}`);
|
|
86
89
|
}
|
|
87
90
|
});
|
|
88
|
-
this.updateStepDetails('Consultar Memória', { count: similarCases.length });
|
|
89
|
-
}
|
|
91
|
+
this.updateStepDetails('Consultar Memória', { count: similarCases.length });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Verificar últimas mudanças relacionadas aos arquivos da tarefa
|
|
95
|
+
if (context.files && context.files.length > 0) {
|
|
96
|
+
const latestEntries = this.memory.getLatestEntriesForFiles(this.agentName, context.files, 3);
|
|
97
|
+
if (latestEntries.length > 0) {
|
|
98
|
+
console.log(`\n🕵️ [${this.agentName}] Últimas mudanças relacionadas aos arquivos da tarefa:`);
|
|
99
|
+
latestEntries.forEach((entry, index) => {
|
|
100
|
+
const status = entry.result === 'success' ? '✅' : '❌';
|
|
101
|
+
const when = new Date(entry.timestamp as any).toLocaleString('pt-BR');
|
|
102
|
+
console.log(` ${index + 1}. ${status} ${entry.taskDescription} (${when})`);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
90
106
|
|
|
91
107
|
// PASSO 2: Obter recomendações baseadas em aprendizados
|
|
92
108
|
this.markStepCompleted('Obter Recomendações', { count: 0 });
|
|
@@ -68,7 +68,7 @@ export interface AgentMemory {
|
|
|
68
68
|
/**
|
|
69
69
|
* Sistema de Memória
|
|
70
70
|
*/
|
|
71
|
-
export class MemorySystem {
|
|
71
|
+
export class MemorySystem {
|
|
72
72
|
private memoryBasePath: string;
|
|
73
73
|
private maxEntries: number;
|
|
74
74
|
private cache: CacheManager;
|
|
@@ -283,7 +283,7 @@ export class MemorySystem {
|
|
|
283
283
|
/**
|
|
284
284
|
* Obtém recomendações baseadas em aprendizados
|
|
285
285
|
*/
|
|
286
|
-
getRecommendations(agentName: string, taskDescription: string): string[] {
|
|
286
|
+
getRecommendations(agentName: string, taskDescription: string): string[] {
|
|
287
287
|
// Verificar cache primeiro
|
|
288
288
|
const cacheKey = `recommendations:${agentName}:${taskDescription}`;
|
|
289
289
|
const cached = this.cache.get<string[]>(cacheKey);
|
|
@@ -308,8 +308,32 @@ export class MemorySystem {
|
|
|
308
308
|
// Cachear resultado
|
|
309
309
|
this.cache.set(cacheKey, results, 120000); // 2 minutos TTL
|
|
310
310
|
|
|
311
|
-
return results;
|
|
312
|
-
}
|
|
311
|
+
return results;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Retorna as últimas entradas relacionadas a arquivos/páginas
|
|
316
|
+
*/
|
|
317
|
+
getLatestEntriesForFiles(
|
|
318
|
+
agentName: string,
|
|
319
|
+
files: string[],
|
|
320
|
+
limit: number = 3
|
|
321
|
+
): MemoryEntry[] {
|
|
322
|
+
const normalizedFiles = files.map(f => this.normalizePath(f));
|
|
323
|
+
if (normalizedFiles.length === 0) return [];
|
|
324
|
+
|
|
325
|
+
const memory = this.loadMemory(agentName);
|
|
326
|
+
const allEntries = [...memory.successes, ...memory.failures];
|
|
327
|
+
|
|
328
|
+
const matches = allEntries.filter(entry => {
|
|
329
|
+
const entryFiles = (entry.context?.files || []).map(f => this.normalizePath(f));
|
|
330
|
+
return entryFiles.some(ef => normalizedFiles.some(nf => ef.includes(nf) || nf.includes(ef)));
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
return matches
|
|
334
|
+
.sort((a, b) => this.toDate(b.timestamp).getTime() - this.toDate(a.timestamp).getTime())
|
|
335
|
+
.slice(0, limit);
|
|
336
|
+
}
|
|
313
337
|
|
|
314
338
|
/**
|
|
315
339
|
* Obtém estatísticas do cache
|
|
@@ -386,12 +410,20 @@ export class MemorySystem {
|
|
|
386
410
|
.filter(word => word.length > 3);
|
|
387
411
|
}
|
|
388
412
|
|
|
389
|
-
private calculateSimilarity(keywords1: string[], keywords2: string[]): number {
|
|
390
|
-
const set1 = new Set(keywords1);
|
|
391
|
-
const set2 = new Set(keywords2);
|
|
392
|
-
const intersection = new Set([...set1].filter(k => set2.has(k)));
|
|
393
|
-
const union = new Set([...set1, ...set2]);
|
|
394
|
-
|
|
395
|
-
return union.size > 0 ? intersection.size / union.size : 0;
|
|
396
|
-
}
|
|
397
|
-
|
|
413
|
+
private calculateSimilarity(keywords1: string[], keywords2: string[]): number {
|
|
414
|
+
const set1 = new Set(keywords1);
|
|
415
|
+
const set2 = new Set(keywords2);
|
|
416
|
+
const intersection = new Set([...set1].filter(k => set2.has(k)));
|
|
417
|
+
const union = new Set([...set1, ...set2]);
|
|
418
|
+
|
|
419
|
+
return union.size > 0 ? intersection.size / union.size : 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
private normalizePath(input: string): string {
|
|
423
|
+
return input.trim().replace(/\\/g, '/').toLowerCase();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private toDate(value: Date | string): Date {
|
|
427
|
+
return value instanceof Date ? value : new Date(value);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
@@ -110,16 +110,20 @@ export class ReportGenerator {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// Como testar
|
|
113
|
-
if (report.status === 'success') {
|
|
114
|
-
markdown += `## 🧪 Como Testar\n\n`;
|
|
115
|
-
markdown += `\`\`\`bash\n`;
|
|
116
|
-
markdown += `npm run dev\n`;
|
|
117
|
-
markdown += `# Acesse http://localhost:3000\n`;
|
|
118
|
-
markdown += `\`\`\`\n\n`;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
markdown +=
|
|
122
|
-
markdown +=
|
|
113
|
+
if (report.status === 'success') {
|
|
114
|
+
markdown += `## 🧪 Como Testar\n\n`;
|
|
115
|
+
markdown += `\`\`\`bash\n`;
|
|
116
|
+
markdown += `npm run dev\n`;
|
|
117
|
+
markdown += `# Acesse http://localhost:3000\n`;
|
|
118
|
+
markdown += `\`\`\`\n\n`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
markdown += `## ✅ Confirmação\n\n`;
|
|
122
|
+
markdown += `Tem algo a modificar a mais ou posso mandar para o github?\n\n`;
|
|
123
|
+
markdown += `Por favor, faça um resumo do que foi feito para não perder a memória.\n\n`;
|
|
124
|
+
|
|
125
|
+
markdown += `---\n\n`;
|
|
126
|
+
markdown += `**Gerado em**: ${new Date().toLocaleString('pt-BR')}\n`;
|
|
123
127
|
|
|
124
128
|
return markdown;
|
|
125
129
|
}
|
|
@@ -182,12 +186,15 @@ export class ReportGenerator {
|
|
|
182
186
|
console.log('');
|
|
183
187
|
}
|
|
184
188
|
|
|
185
|
-
if (report.status === 'success' && report.nextSteps.length > 0) {
|
|
186
|
-
console.log('📚 Próximos passos:');
|
|
187
|
-
report.nextSteps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
|
|
188
|
-
console.log('');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
console.log('
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
if (report.status === 'success' && report.nextSteps.length > 0) {
|
|
190
|
+
console.log('📚 Próximos passos:');
|
|
191
|
+
report.nextSteps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
|
|
192
|
+
console.log('');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log('❓ Tem algo a modificar a mais ou posso mandar para o github?');
|
|
196
|
+
console.log('📝 Por favor, faça um resumo do que foi feito para não perder a memória.\n');
|
|
197
|
+
|
|
198
|
+
console.log('='.repeat(60) + '\n');
|
|
199
|
+
}
|
|
200
|
+
}
|
package/.agents/orchestrator.ts
CHANGED
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
* - Dar decisão final GO/NO-GO
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { DocumentationAgent } from './agents/documentation/agent.js';
|
|
19
|
-
import { InventoryAgent } from './agents/inventory/agent.js';
|
|
12
|
+
import { FrontEndAgent } from './core/frontend-agent.js';
|
|
13
|
+
import { SecurityAgent } from './core/security-agent.js';
|
|
14
|
+
import { ArchitectureAgent } from './core/architecture-agent.js';
|
|
15
|
+
import { QualityAgent } from './core/quality-agent.js';
|
|
16
|
+
import { DocumentationAgent } from './core/documentation-agent.js';
|
|
17
|
+
import { InventoryAgent } from './core/inventory-agent.js';
|
|
20
18
|
|
|
21
19
|
// Domain Agents
|
|
22
20
|
import { CMSAgent } from './domains/news/cms-agent.js';
|
|
@@ -24,33 +22,34 @@ import { SEOAgent } from './domains/news/seo-agent.js';
|
|
|
24
22
|
import { ProductionControlAgent } from './domains/production/production-control-agent.js';
|
|
25
23
|
import { RouteAgent } from './domains/logistics/route-agent.js';
|
|
26
24
|
|
|
27
|
-
import { TaskAnalyzerAgent, TaskAnalysis, AgentAssignment } from './
|
|
28
|
-
import { MemorySystem } from './
|
|
29
|
-
import { FeedbackCollector, UserFeedback } from './
|
|
25
|
+
import { TaskAnalyzerAgent, TaskAnalysis, AgentAssignment } from './task-analyzer-agent.js';
|
|
26
|
+
import { MemorySystem } from './core/memory-system.js';
|
|
27
|
+
import { FeedbackCollector, UserFeedback } from './core/feedback-collector.js';
|
|
30
28
|
import { PythonBridge } from './security/python-bridge.js';
|
|
31
29
|
import { AgentConfig, DEFAULT_CONFIG } from './config.js';
|
|
32
30
|
import { ProjectContext } from './context-loader.js';
|
|
33
|
-
import { BaseAgent, TaskContext, TaskResult } from './
|
|
34
|
-
import { RetryUtility } from './
|
|
35
|
-
import { AgentParallelizer } from './
|
|
36
|
-
import { PerformanceTracker } from './
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
31
|
+
import { BaseAgent, TaskContext, TaskResult } from './core/base-agent.js';
|
|
32
|
+
import { RetryUtility } from './core/retry-utility.js';
|
|
33
|
+
import { AgentParallelizer } from './core/agent-parallelizer.js';
|
|
34
|
+
import { PerformanceTracker } from './core/performance-tracker.js';
|
|
35
|
+
import { WorkflowValidator } from './core/workflow-validator.js';
|
|
36
|
+
import { PlanningAgent, ImplementationPlan } from './core/planning-agent.js';
|
|
37
|
+
import { CheckpointManager } from './core/checkpoint-manager.js';
|
|
38
|
+
import { FileGenerator } from './core/file-generator.js';
|
|
39
|
+
import { ReportGenerator, ExecutionReport } from './core/report-generator.js';
|
|
40
|
+
import { NextJSAgent } from './core/nextjs-agent.js';
|
|
41
|
+
import { UIUXAgent } from './core/uiux-agent.js';
|
|
42
|
+
import { BackendAgent } from './core/backend-agent.js';
|
|
43
|
+
import { DatabaseAgent } from './core/database-agent.js';
|
|
44
|
+
import { AIAgentsAgent } from './core/ai-agents-agent.js';
|
|
45
|
+
import { RAGAgent } from './core/rag-agent.js';
|
|
46
|
+
import { PentestAgent } from './core/pentest-agent.js';
|
|
47
|
+
import { DevOpsAgent } from './core/devops-agent.js';
|
|
48
|
+
import { CloudAgent } from './core/cloud-agent.js';
|
|
49
|
+
import { TestingAgent } from './core/testing-agent.js';
|
|
50
|
+
import { CROAgent } from './core/cro-agent.js';
|
|
51
|
+
import { AutomationAgent } from './core/automation-agent.js';
|
|
52
|
+
import { BuildManager } from './core/build-manager.js';
|
|
54
53
|
|
|
55
54
|
export interface AgentReport {
|
|
56
55
|
agentName: string;
|
|
@@ -178,9 +177,10 @@ export class IntelligentOrchestrator {
|
|
|
178
177
|
* Orquestra uma tarefa completa com aprendizado
|
|
179
178
|
*/
|
|
180
179
|
async orchestrateTask(taskDescription: string): Promise<ExecutionResult> {
|
|
181
|
-
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
182
|
-
console.log('🎯 ORQUESTRADOR INTELIGENTE');
|
|
183
|
-
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
180
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
181
|
+
console.log('🎯 ORQUESTRADOR INTELIGENTE');
|
|
182
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
183
|
+
console.log(`🧮 Tokens estimados (tarefa): ${this.estimateTokens(taskDescription)}\n`);
|
|
184
184
|
|
|
185
185
|
const taskId = this.generateTaskId();
|
|
186
186
|
const startTime = Date.now();
|
|
@@ -355,14 +355,17 @@ export class IntelligentOrchestrator {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
359
|
-
console.log(`${success ? '✅ GO' : '❌ NO-GO'} - Execução ${success ? 'concluída' : 'bloqueada'}`);
|
|
360
|
-
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
358
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
359
|
+
console.log(`${success ? '✅ GO' : '❌ NO-GO'} - Execução ${success ? 'concluída' : 'bloqueada'}`);
|
|
360
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
361
|
+
|
|
362
|
+
console.log('Tem algo a modificar a mais ou posso mandar para o github?');
|
|
363
|
+
console.log('Por favor, faça um resumo do que foi feito para não perder a memória.');
|
|
364
|
+
|
|
365
|
+
// 6. Coletar feedback (se habilitado)
|
|
366
|
+
if (this.config.feedbackEnabled) {
|
|
367
|
+
await this.collectFeedbackForTask(taskId, selectedAgents, taskDescription);
|
|
368
|
+
}
|
|
366
369
|
|
|
367
370
|
return {
|
|
368
371
|
success,
|
|
@@ -434,17 +437,19 @@ export class IntelligentOrchestrator {
|
|
|
434
437
|
assignment: AgentAssignment,
|
|
435
438
|
analysis: TaskAnalysis
|
|
436
439
|
): Promise<AgentReport> {
|
|
437
|
-
console.log(`━━━ ${assignment.agentName} ━━━`);
|
|
438
|
-
console.log(`Subtarefa: ${assignment.subtask}\n`);
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
440
|
+
console.log(`━━━ ${assignment.agentName} ━━━`);
|
|
441
|
+
console.log(`Subtarefa: ${assignment.subtask}\n`);
|
|
442
|
+
console.log(`🧮 Tokens estimados (subtarefa): ${this.estimateTokens(assignment.subtask)}\n`);
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
const context: TaskContext = {
|
|
446
|
+
files: this.extractFilesForAgent(assignment.agentName, analysis),
|
|
447
|
+
areas: analysis.detectedAreas,
|
|
448
|
+
complexity: analysis.complexity,
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const agentInstance = this.getAgentByName(assignment.agentName);
|
|
452
|
+
let result: TaskResult;
|
|
448
453
|
|
|
449
454
|
// Iniciar tracking de performance
|
|
450
455
|
const taskId = this.generateTaskId();
|
|
@@ -474,8 +479,8 @@ export class IntelligentOrchestrator {
|
|
|
474
479
|
case 'documentation-agent':
|
|
475
480
|
return await this.documentationAgent.executeWithMemory(assignment.subtask, context);
|
|
476
481
|
|
|
477
|
-
case 'inventory-agent':
|
|
478
|
-
return await this.inventoryAgent.
|
|
482
|
+
case 'inventory-agent':
|
|
483
|
+
return await this.inventoryAgent.executeWithMemory(assignment.subtask, context);
|
|
479
484
|
|
|
480
485
|
case 'cms-agent':
|
|
481
486
|
return await this.cmsAgent.executeWithMemory(assignment.subtask, context);
|
|
@@ -553,23 +558,41 @@ export class IntelligentOrchestrator {
|
|
|
553
558
|
backoffMultiplier: 2
|
|
554
559
|
},
|
|
555
560
|
assignment.agentName
|
|
556
|
-
);
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
let status: AgentReport['status'] = result.success ? 'success' : 'error';
|
|
564
|
+
const blockers: string[] = [...(result.issues || [])];
|
|
565
|
+
|
|
566
|
+
if (agentInstance && agentInstance instanceof BaseAgent) {
|
|
567
|
+
const validator = new WorkflowValidator();
|
|
568
|
+
const validation = validator.validateAgentExecution(
|
|
569
|
+
assignment.agentName,
|
|
570
|
+
agentInstance.getWorkflowSteps()
|
|
571
|
+
);
|
|
572
|
+
const report = validator.generateValidationReport(assignment.agentName, validation);
|
|
573
|
+
console.log(report);
|
|
574
|
+
|
|
575
|
+
if (!validation.compliant) {
|
|
576
|
+
status = 'error';
|
|
577
|
+
blockers.push(
|
|
578
|
+
`Workflow NON-COMPLIANT: passos faltantes - ${validation.missingSteps.join(', ')}`
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// Finalizar tracking de performance
|
|
584
|
+
this.performanceTracker.endTracking(trackingId, result.success);
|
|
562
585
|
|
|
563
586
|
console.log(`${result.success ? '✅' : '❌'} ${assignment.agentName} concluído\n`);
|
|
564
587
|
|
|
565
|
-
return {
|
|
566
|
-
agentName: assignment.agentName,
|
|
567
|
-
stepNumber: assignment.priority,
|
|
568
|
-
status,
|
|
569
|
-
summary: result.success ? 'Tarefa concluída com sucesso' : 'Tarefa falhou',
|
|
570
|
-
details: result.details,
|
|
571
|
-
blockers:
|
|
572
|
-
};
|
|
588
|
+
return {
|
|
589
|
+
agentName: assignment.agentName,
|
|
590
|
+
stepNumber: assignment.priority,
|
|
591
|
+
status,
|
|
592
|
+
summary: result.success ? 'Tarefa concluída com sucesso' : 'Tarefa falhou',
|
|
593
|
+
details: result.details,
|
|
594
|
+
blockers: blockers.length > 0 ? blockers : undefined,
|
|
595
|
+
};
|
|
573
596
|
|
|
574
597
|
} catch (error) {
|
|
575
598
|
console.error(`❌ Erro ao executar ${assignment.agentName}:`, error);
|
|
@@ -616,7 +639,7 @@ export class IntelligentOrchestrator {
|
|
|
616
639
|
complexity: 'low'
|
|
617
640
|
};
|
|
618
641
|
|
|
619
|
-
const result = await this.inventoryAgent.
|
|
642
|
+
const result = await this.inventoryAgent.executeWithMemory(`check duplication for "${taskDescription}"`, context);
|
|
620
643
|
|
|
621
644
|
if (result.warnings && result.warnings.length > 0) {
|
|
622
645
|
console.log('\n⚠️ ALERTA DE DUPLICAÇÃO DETECTADO:');
|
|
@@ -716,6 +739,7 @@ export class IntelligentOrchestrator {
|
|
|
716
739
|
try {
|
|
717
740
|
// Executar validate
|
|
718
741
|
console.log(' Executando npm run validate...');
|
|
742
|
+
const { execSync } = await import('child_process');
|
|
719
743
|
execSync('npm run validate', { stdio: 'pipe' });
|
|
720
744
|
console.log(' ✅ Validate passou');
|
|
721
745
|
} catch (error) {
|
|
@@ -732,9 +756,15 @@ export class IntelligentOrchestrator {
|
|
|
732
756
|
/**
|
|
733
757
|
* Gera ID único para tarefa
|
|
734
758
|
*/
|
|
735
|
-
private generateTaskId(): string {
|
|
736
|
-
return `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
737
|
-
}
|
|
759
|
+
private generateTaskId(): string {
|
|
760
|
+
return `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
private estimateTokens(text: string): number {
|
|
764
|
+
const normalized = text.trim();
|
|
765
|
+
if (!normalized) return 0;
|
|
766
|
+
return Math.ceil(normalized.length / 4);
|
|
767
|
+
}
|
|
738
768
|
|
|
739
769
|
/**
|
|
740
770
|
* Método legado para compatibilidade
|