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.
- package/.agents/AGENT_WORKFLOW.md +528 -0
- package/.agents/AI_COMPATIBILITY.md +332 -0
- package/.agents/CLI.md +222 -0
- package/.agents/README.md +130 -0
- package/.agents/cli.js +389 -0
- package/.agents/code-auditor-agent.ts +333 -0
- package/.agents/config.ts +145 -0
- package/.agents/context-loader.ts +300 -0
- package/.agents/core/agent-parallelizer.test.ts +94 -0
- package/.agents/core/agent-parallelizer.ts +108 -0
- package/.agents/core/architecture-agent.ts +237 -0
- package/.agents/core/base-agent.ts +311 -0
- package/.agents/core/cache-manager.test.ts +147 -0
- package/.agents/core/cache-manager.ts +184 -0
- package/.agents/core/documentation-agent.ts +183 -0
- package/.agents/core/feedback-collector.ts +207 -0
- package/.agents/core/frontend-agent.ts +210 -0
- package/.agents/core/inventory-agent.ts +582 -0
- package/.agents/core/memory-system.ts +397 -0
- package/.agents/core/quality-agent.ts +268 -0
- package/.agents/core/retry-utility.test.ts +165 -0
- package/.agents/core/retry-utility.ts +140 -0
- package/.agents/core/security-agent.ts +217 -0
- package/.agents/core/workflow-validator.test.ts +171 -0
- package/.agents/core/workflow-validator.ts +158 -0
- package/.agents/domains/README.md +53 -0
- package/.agents/domains/logistics/route-agent.ts +177 -0
- package/.agents/domains/news/cms-agent.ts +158 -0
- package/.agents/domains/news/seo-agent.ts +170 -0
- package/.agents/domains/production/production-control-agent.ts +169 -0
- package/.agents/example-learning-system.js +118 -0
- package/.agents/init.ts +164 -0
- package/.agents/memory/architecture-agent/failures.json +1 -0
- package/.agents/memory/architecture-agent/learnings.json +1 -0
- package/.agents/memory/architecture-agent/specialty.md +31 -0
- package/.agents/memory/architecture-agent/successes.json +16 -0
- package/.agents/memory/cms-agent/failures.json +1 -0
- package/.agents/memory/cms-agent/learnings.json +1 -0
- package/.agents/memory/cms-agent/specialty.md +30 -0
- package/.agents/memory/cms-agent/successes.json +16 -0
- package/.agents/memory/documentation-agent/failures.json +1 -0
- package/.agents/memory/documentation-agent/learnings.json +1 -0
- package/.agents/memory/documentation-agent/specialty.md +33 -0
- package/.agents/memory/documentation-agent/successes.json +16 -0
- package/.agents/memory/frontend-agent/failures.json +1 -0
- package/.agents/memory/frontend-agent/learnings.json +1 -0
- package/.agents/memory/frontend-agent/specialty.md +30 -0
- package/.agents/memory/frontend-agent/successes.json +16 -0
- package/.agents/memory/inventory-agent/failures.json +1 -0
- package/.agents/memory/inventory-agent/inventory/index.json +8 -0
- package/.agents/memory/inventory-agent/inventory/types.json +77716 -0
- package/.agents/memory/inventory-agent/inventory/variables.json +405 -0
- package/.agents/memory/inventory-agent/learnings.json +1 -0
- package/.agents/memory/inventory-agent/specialty.md +129 -0
- package/.agents/memory/inventory-agent/successes.json +30 -0
- package/.agents/memory/production-control-agent/failures.json +1 -0
- package/.agents/memory/production-control-agent/learnings.json +1 -0
- package/.agents/memory/production-control-agent/specialty.md +29 -0
- package/.agents/memory/production-control-agent/successes.json +16 -0
- package/.agents/memory/quality-agent/failures.json +16 -0
- package/.agents/memory/quality-agent/learnings.json +1 -0
- package/.agents/memory/quality-agent/specialty.md +31 -0
- package/.agents/memory/quality-agent/successes.json +1 -0
- package/.agents/memory/reference-repositories.json +271 -0
- package/.agents/memory/route-agent/failures.json +1 -0
- package/.agents/memory/route-agent/learnings.json +1 -0
- package/.agents/memory/route-agent/specialty.md +29 -0
- package/.agents/memory/route-agent/successes.json +16 -0
- package/.agents/memory/security-agent/failures.json +1 -0
- package/.agents/memory/security-agent/learnings.json +1 -0
- package/.agents/memory/security-agent/specialty.md +31 -0
- package/.agents/memory/security-agent/successes.json +16 -0
- package/.agents/memory/seo-agent/failures.json +1 -0
- package/.agents/memory/seo-agent/learnings.json +1 -0
- package/.agents/memory/seo-agent/specialty.md +31 -0
- package/.agents/memory/seo-agent/successes.json +16 -0
- package/.agents/orchestrator.ts +438 -0
- package/.agents/project-discovery-agent.ts +342 -0
- package/.agents/security/pentesting-agent.py +387 -0
- package/.agents/security/python-bridge.ts +193 -0
- package/.agents/security/vulnerability-db.json +201 -0
- package/.agents/task-analyzer-agent.ts +346 -0
- package/.agents/test-init-context.js +67 -0
- package/INSTALL.md +300 -0
- package/LICENSE +21 -0
- package/README.md +315 -0
- package/docs/AGENT_RULES.md +292 -0
- package/docs/BUILD_HISTORY.md +65 -0
- package/docs/DESIGN_SYSTEM.md +256 -0
- package/docs/LEARNING_SYSTEM.md +326 -0
- package/docs/SYMBOLS_TREE.md +182 -0
- package/docs/VERSION.md +6 -0
- package/docs/architecture.md +111 -0
- package/package.json +60 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SEO Agent (com Memória)
|
|
3
|
+
* Domínio: Site de Notícias
|
|
4
|
+
*
|
|
5
|
+
* Responsabilidades:
|
|
6
|
+
* - Validar meta tags (title, description, og:image)
|
|
7
|
+
* - Verificar structured data (JSON-LD)
|
|
8
|
+
* - Sugerir otimizações de performance
|
|
9
|
+
* - Validar sitemap.xml
|
|
10
|
+
* - Aprender padrões de SEO que funcionam
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { BaseAgent, TaskContext, TaskResult } from '../../core/base-agent';
|
|
14
|
+
|
|
15
|
+
export interface SEOMetadata {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
keywords?: string[];
|
|
19
|
+
ogImage?: string;
|
|
20
|
+
ogType?: string;
|
|
21
|
+
canonicalUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class SEOAgent extends BaseAgent {
|
|
25
|
+
constructor(memoryBasePath: string = '.agents/memory') {
|
|
26
|
+
super('seo-agent', memoryBasePath);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Implementação da validação de SEO
|
|
31
|
+
*/
|
|
32
|
+
async executeTask(taskDescription: string, context: TaskContext): Promise<TaskResult> {
|
|
33
|
+
const warnings: string[] = [];
|
|
34
|
+
const recommendations: string[] = [];
|
|
35
|
+
|
|
36
|
+
// Aqui seria feita a validação real de SEO
|
|
37
|
+
// Por enquanto, retorna sucesso
|
|
38
|
+
const success = warnings.length === 0;
|
|
39
|
+
const details = success
|
|
40
|
+
? 'SEO validado com sucesso'
|
|
41
|
+
: `Avisos: ${warnings.join(', ')}`;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
success,
|
|
45
|
+
details,
|
|
46
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
47
|
+
recommendations: recommendations.length > 0 ? recommendations : undefined
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Valida meta tags
|
|
53
|
+
*/
|
|
54
|
+
validateMetaTags(metadata: SEOMetadata): { valid: boolean; warnings: string[]; recommendations: string[] } {
|
|
55
|
+
const warnings: string[] = [];
|
|
56
|
+
const recommendations: string[] = [];
|
|
57
|
+
|
|
58
|
+
// Title
|
|
59
|
+
if (!metadata.title) {
|
|
60
|
+
warnings.push('Meta title ausente');
|
|
61
|
+
} else if (metadata.title.length > 60) {
|
|
62
|
+
warnings.push(`Meta title muito longo (${metadata.title.length} caracteres, ideal: 50-60)`);
|
|
63
|
+
} else if (metadata.title.length < 30) {
|
|
64
|
+
recommendations.push('Meta title poderia ser mais descritivo (mínimo recomendado: 30 caracteres)');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Description
|
|
68
|
+
if (!metadata.description) {
|
|
69
|
+
warnings.push('Meta description ausente');
|
|
70
|
+
} else if (metadata.description.length > 160) {
|
|
71
|
+
warnings.push(`Meta description muito longa (${metadata.description.length} caracteres, ideal: 150-160)`);
|
|
72
|
+
} else if (metadata.description.length < 100) {
|
|
73
|
+
recommendations.push('Meta description poderia ser mais descritiva (mínimo recomendado: 100 caracteres)');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Open Graph
|
|
77
|
+
if (!metadata.ogImage) {
|
|
78
|
+
recommendations.push('Adicionar og:image para melhor compartilhamento em redes sociais');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!metadata.canonicalUrl) {
|
|
82
|
+
recommendations.push('Adicionar canonical URL para evitar conteúdo duplicado');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { valid: warnings.length === 0, warnings, recommendations };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gera structured data (JSON-LD) para artigo
|
|
90
|
+
*/
|
|
91
|
+
generateArticleStructuredData(article: {
|
|
92
|
+
title: string;
|
|
93
|
+
description: string;
|
|
94
|
+
author: string;
|
|
95
|
+
publishedDate: string;
|
|
96
|
+
imageUrl: string;
|
|
97
|
+
}): string {
|
|
98
|
+
return JSON.stringify({
|
|
99
|
+
'@context': 'https://schema.org',
|
|
100
|
+
'@type': 'NewsArticle',
|
|
101
|
+
headline: article.title,
|
|
102
|
+
description: article.description,
|
|
103
|
+
author: {
|
|
104
|
+
'@type': 'Person',
|
|
105
|
+
name: article.author,
|
|
106
|
+
},
|
|
107
|
+
datePublished: article.publishedDate,
|
|
108
|
+
image: article.imageUrl,
|
|
109
|
+
}, null, 2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Valida sitemap.xml
|
|
114
|
+
*/
|
|
115
|
+
validateSitemap(sitemapContent: string): { valid: boolean; errors: string[] } {
|
|
116
|
+
const errors: string[] = [];
|
|
117
|
+
|
|
118
|
+
if (!sitemapContent.includes('<?xml')) {
|
|
119
|
+
errors.push('Sitemap deve começar com declaração XML');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!sitemapContent.includes('<urlset')) {
|
|
123
|
+
errors.push('Sitemap deve conter elemento <urlset>');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!sitemapContent.includes('<loc>')) {
|
|
127
|
+
errors.push('Sitemap deve conter ao menos uma <loc> (URL)');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { valid: errors.length === 0, errors };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Especialidade padrão do SEO Agent
|
|
135
|
+
*/
|
|
136
|
+
protected getDefaultSpecialty(): string {
|
|
137
|
+
return `# SEO Agent - Especialidade
|
|
138
|
+
|
|
139
|
+
## Responsabilidades
|
|
140
|
+
- Validar meta tags (title, description, og:image)
|
|
141
|
+
- Verificar structured data (JSON-LD)
|
|
142
|
+
- Sugerir otimizações de SEO
|
|
143
|
+
- Validar sitemap.xml
|
|
144
|
+
- Garantir URLs SEO-friendly
|
|
145
|
+
|
|
146
|
+
## Expertise
|
|
147
|
+
- SEO On-Page
|
|
148
|
+
- Meta Tags e Open Graph
|
|
149
|
+
- Structured Data (Schema.org)
|
|
150
|
+
- Sitemap e Robots.txt
|
|
151
|
+
- Core Web Vitals
|
|
152
|
+
- Google Search Console
|
|
153
|
+
|
|
154
|
+
## Regras
|
|
155
|
+
- Meta title: 50-60 caracteres
|
|
156
|
+
- Meta description: 150-160 caracteres
|
|
157
|
+
- Sempre incluir og:image
|
|
158
|
+
- Usar canonical URL
|
|
159
|
+
- Structured data para artigos
|
|
160
|
+
- Sitemap atualizado
|
|
161
|
+
|
|
162
|
+
## Tarefas Típicas
|
|
163
|
+
- Validar meta tags de páginas
|
|
164
|
+
- Gerar structured data
|
|
165
|
+
- Otimizar títulos e descrições
|
|
166
|
+
- Validar sitemap
|
|
167
|
+
- Sugerir melhorias de SEO
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production Control Agent (com Memória)
|
|
3
|
+
* Domínio: Produção e Expedição
|
|
4
|
+
*
|
|
5
|
+
* Responsabilidades:
|
|
6
|
+
* - Monitorar eventos de produção
|
|
7
|
+
* - Validar fluxo (inicio → processamento → conclusão)
|
|
8
|
+
* - Alertar sobre gargalos ou atrasos
|
|
9
|
+
* - Validar schema Supabase
|
|
10
|
+
* - Aprender padrões de produção eficientes
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { BaseAgent, TaskContext, TaskResult } from '../../core/base-agent';
|
|
14
|
+
|
|
15
|
+
export interface ProductionEvent {
|
|
16
|
+
id: string;
|
|
17
|
+
event_type: 'start' | 'processing' | 'complete' | 'pause';
|
|
18
|
+
timestamp: string;
|
|
19
|
+
shift: string;
|
|
20
|
+
quantity: number;
|
|
21
|
+
operator_id: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ProductionControlAgent extends BaseAgent {
|
|
25
|
+
constructor(memoryBasePath: string = '.agents/memory') {
|
|
26
|
+
super('production-control-agent', memoryBasePath);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Implementação da validação de produção
|
|
31
|
+
*/
|
|
32
|
+
async executeTask(taskDescription: string, context: TaskContext): Promise<TaskResult> {
|
|
33
|
+
const issues: string[] = [];
|
|
34
|
+
const warnings: string[] = [];
|
|
35
|
+
|
|
36
|
+
// Aqui seria feita a validação real de eventos de produção
|
|
37
|
+
const success = issues.length === 0;
|
|
38
|
+
const details = success
|
|
39
|
+
? 'Controle de produção validado com sucesso'
|
|
40
|
+
: `Problemas encontrados: ${issues.join(', ')}`;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
success,
|
|
44
|
+
details,
|
|
45
|
+
issues: issues.length > 0 ? issues : undefined,
|
|
46
|
+
warnings: warnings.length > 0 ? warnings : undefined
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Valida evento de produção
|
|
52
|
+
*/
|
|
53
|
+
validateEvent(event: Partial<ProductionEvent>): { valid: boolean; errors: string[] } {
|
|
54
|
+
const errors: string[] = [];
|
|
55
|
+
|
|
56
|
+
if (!event.event_type) {
|
|
57
|
+
errors.push('Tipo de evento é obrigatório');
|
|
58
|
+
} else if (!['start', 'processing', 'complete', 'pause'].includes(event.event_type)) {
|
|
59
|
+
errors.push('Tipo de evento inválido (permitidos: start, processing, complete, pause)');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!event.timestamp) {
|
|
63
|
+
errors.push('Timestamp é obrigatório');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!event.shift) {
|
|
67
|
+
errors.push('Turno (shift) é obrigatório');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (event.quantity !== undefined && event.quantity < 0) {
|
|
71
|
+
errors.push('Quantidade não pode ser negativa');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!event.operator_id) {
|
|
75
|
+
errors.push('Operador é obrigatório');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return { valid: errors.length === 0, errors };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Detecta gargalos em eventos
|
|
83
|
+
*/
|
|
84
|
+
detectBottlenecks(events: ProductionEvent[]): string[] {
|
|
85
|
+
const bottlenecks: string[] = [];
|
|
86
|
+
|
|
87
|
+
// Detectar eventos em "processing" por muito tempo (>2h exemplo)
|
|
88
|
+
const now = new Date();
|
|
89
|
+
events.forEach(event => {
|
|
90
|
+
if (event.event_type === 'processing') {
|
|
91
|
+
const eventTime = new Date(event.timestamp);
|
|
92
|
+
const diffHours = (now.getTime() - eventTime.getTime()) / (1000 * 60 * 60);
|
|
93
|
+
|
|
94
|
+
if (diffHours > 2) {
|
|
95
|
+
bottlenecks.push(`Evento ${event.id} em processamento há ${diffHours.toFixed(1)} horas`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Detectar pausas frequentes
|
|
101
|
+
const pauseEvents = events.filter(e => e.event_type === 'pause');
|
|
102
|
+
if (pauseEvents.length > 5) {
|
|
103
|
+
bottlenecks.push(`Muitas pausas detectadas (${pauseEvents.length})`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return bottlenecks;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Valida schema Supabase
|
|
111
|
+
*/
|
|
112
|
+
validateSchema(migrations: string[]): { valid: boolean; recommendations: string[] } {
|
|
113
|
+
const recommendations: string[] = [];
|
|
114
|
+
|
|
115
|
+
const hasProductionEvents = migrations.some(m => m.includes('create table production_events'));
|
|
116
|
+
const hasPlantLogs = migrations.some(m => m.includes('create table plant_logs'));
|
|
117
|
+
const hasMiningCycles = migrations.some(m => m.includes('create table mining_cycles'));
|
|
118
|
+
|
|
119
|
+
if (!hasProductionEvents) {
|
|
120
|
+
recommendations.push('Criar tabela "production_events" (id, event_type, timestamp, shift, quantity, operator_id)');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!hasPlantLogs) {
|
|
124
|
+
recommendations.push('Criar tabela "plant_logs" (id, plant_id, log_type, timestamp, data)');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!hasMiningCycles) {
|
|
128
|
+
recommendations.push('Criar tabela "mining_cycles" (id, cycle_start, cycle_end, location, quantity)');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { valid: recommendations.length === 0, recommendations };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Especialidade padrão do Production Control Agent
|
|
136
|
+
*/
|
|
137
|
+
protected getDefaultSpecialty(): string {
|
|
138
|
+
return `# Production Control Agent - Especialidade
|
|
139
|
+
|
|
140
|
+
## Responsabilidades
|
|
141
|
+
- Monitorar eventos de produção
|
|
142
|
+
- Validar fluxo (inicio → processamento → conclusão)
|
|
143
|
+
- Alertar sobre gargalos ou atrasos
|
|
144
|
+
- Validar schema Supabase para produção
|
|
145
|
+
- Otimizar processos de produção
|
|
146
|
+
|
|
147
|
+
## Expertise
|
|
148
|
+
- Controle de Produção
|
|
149
|
+
- Gestão de Turnos
|
|
150
|
+
- Detecção de Gargalos
|
|
151
|
+
- KPIs de Produção
|
|
152
|
+
- Mineração e Expedição
|
|
153
|
+
|
|
154
|
+
## Regras
|
|
155
|
+
- Eventos devem seguir fluxo: start → processing → complete
|
|
156
|
+
- Pausas devem ser justificadas
|
|
157
|
+
- Quantidade não pode ser negativa
|
|
158
|
+
- Operador deve estar vinculado
|
|
159
|
+
- Monitorar tempo de processamento
|
|
160
|
+
|
|
161
|
+
## Tarefas Típicas
|
|
162
|
+
- Validar eventos de produção
|
|
163
|
+
- Detectar gargalos em tempo real
|
|
164
|
+
- Sugerir otimizações de processo
|
|
165
|
+
- Validar schema de banco de dados
|
|
166
|
+
- Gerar relatórios de produção
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exemplo de Uso do Sistema de Agentes com Aprendizado
|
|
3
|
+
*
|
|
4
|
+
* Este script demonstra como usar o novo sistema de agentes com memória e aprendizado contínuo.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { IntelligentOrchestrator } = require('./orchestrator');
|
|
8
|
+
const { ContextLoader } = require('./context-loader');
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
12
|
+
console.log('🚀 SISTEMA DE AGENTES COM APRENDIZADO CONTÍNUO');
|
|
13
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
14
|
+
|
|
15
|
+
// 1. Carregar contexto do projeto
|
|
16
|
+
console.log('📂 Carregando contexto do projeto...\n');
|
|
17
|
+
const contextLoader = new ContextLoader();
|
|
18
|
+
const context = await contextLoader.loadContext();
|
|
19
|
+
|
|
20
|
+
// 2. Criar orquestrador inteligente
|
|
21
|
+
const orchestrator = new IntelligentOrchestrator(context);
|
|
22
|
+
|
|
23
|
+
// 3. Exemplo 1: Criar componente de login
|
|
24
|
+
console.log('\n━━━ EXEMPLO 1: Criar Componente de Login ━━━\n');
|
|
25
|
+
|
|
26
|
+
const result1 = await orchestrator.orchestrateTask(
|
|
27
|
+
'Criar componente de login com validação de email e senha, estados de loading e error, e acessibilidade'
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
console.log(`\nResultado: ${result1.status}`);
|
|
31
|
+
console.log(`Task ID: ${result1.taskId}\n`);
|
|
32
|
+
|
|
33
|
+
// 4. Fornecer feedback positivo
|
|
34
|
+
if (result1.success) {
|
|
35
|
+
console.log('━━━ Fornecendo Feedback Positivo ━━━\n');
|
|
36
|
+
|
|
37
|
+
await orchestrator.provideFeedback(result1.taskId, 'frontend-agent', {
|
|
38
|
+
satisfied: true,
|
|
39
|
+
likes: [
|
|
40
|
+
'Validação de inputs implementada corretamente',
|
|
41
|
+
'Estados de loading e error incluídos',
|
|
42
|
+
'Acessibilidade com aria-labels'
|
|
43
|
+
],
|
|
44
|
+
dislikes: [],
|
|
45
|
+
suggestions: [
|
|
46
|
+
'Adicionar animação de transição'
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await orchestrator.provideFeedback(result1.taskId, 'security-agent', {
|
|
51
|
+
satisfied: true,
|
|
52
|
+
likes: [
|
|
53
|
+
'Validação de senha forte',
|
|
54
|
+
'Proteção contra XSS'
|
|
55
|
+
],
|
|
56
|
+
dislikes: [],
|
|
57
|
+
suggestions: []
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 5. Exemplo 2: Criar componente similar (agentes devem aprender)
|
|
62
|
+
console.log('\n━━━ EXEMPLO 2: Criar Componente de Registro (Similar) ━━━\n');
|
|
63
|
+
|
|
64
|
+
const result2 = await orchestrator.orchestrateTask(
|
|
65
|
+
'Criar componente de registro com validação de email, senha e confirmação de senha'
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
console.log(`\nResultado: ${result2.status}`);
|
|
69
|
+
console.log(`Task ID: ${result2.taskId}\n`);
|
|
70
|
+
|
|
71
|
+
// 6. Ver relatórios de feedback
|
|
72
|
+
console.log('\n━━━ RELATÓRIOS DE FEEDBACK ━━━\n');
|
|
73
|
+
|
|
74
|
+
console.log(orchestrator.getFeedbackReport('frontend-agent'));
|
|
75
|
+
console.log(orchestrator.getFeedbackReport('security-agent'));
|
|
76
|
+
|
|
77
|
+
// 7. Exemplo 3: Tarefa com problema (para testar aprendizado de falhas)
|
|
78
|
+
console.log('\n━━━ EXEMPLO 3: Componente com Problema ━━━\n');
|
|
79
|
+
|
|
80
|
+
const result3 = await orchestrator.orchestrateTask(
|
|
81
|
+
'Criar componente que usa dangerouslySetInnerHTML sem sanitização'
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
console.log(`\nResultado: ${result3.status}`);
|
|
85
|
+
|
|
86
|
+
if (!result3.success) {
|
|
87
|
+
console.log('Bloqueadores detectados:');
|
|
88
|
+
result3.blockers.forEach(blocker => console.log(` - ${blocker}`));
|
|
89
|
+
|
|
90
|
+
// Fornecer feedback negativo
|
|
91
|
+
await orchestrator.provideFeedback(result3.taskId, 'security-agent', {
|
|
92
|
+
satisfied: false,
|
|
93
|
+
likes: [],
|
|
94
|
+
dislikes: [
|
|
95
|
+
'Detectou vulnerabilidade XSS corretamente'
|
|
96
|
+
],
|
|
97
|
+
suggestions: [
|
|
98
|
+
'Sugerir DOMPurify automaticamente'
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
104
|
+
console.log('✅ DEMONSTRAÇÃO CONCLUÍDA');
|
|
105
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
106
|
+
|
|
107
|
+
console.log('💡 Dicas:');
|
|
108
|
+
console.log(' - Memória dos agentes está em .agents/memory/');
|
|
109
|
+
console.log(' - Cada agente tem: successes.json, failures.json, learnings.json');
|
|
110
|
+
console.log(' - Agentes aprendem com feedback e evitam repetir erros');
|
|
111
|
+
console.log(' - Orquestrador seleciona agentes com melhor histórico\n');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Executar
|
|
115
|
+
main().catch(error => {
|
|
116
|
+
console.error('❌ Erro:', error);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
});
|
package/.agents/init.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 🚀 SCRIPT DE INICIALIZAÇÃO DO SISTEMA DE AGENTES
|
|
5
|
+
*
|
|
6
|
+
* Este script é executado quando alguém instala o sistema pela primeira vez.
|
|
7
|
+
* Ele:
|
|
8
|
+
* 1. Pede permissão para escanear o projeto
|
|
9
|
+
* 2. Inicializa o orquestrador
|
|
10
|
+
* 3. Cria memória inicial para TODOS os agentes
|
|
11
|
+
* 4. Organiza o almoxarifado (Inventory Agent)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as readline from 'readline';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import { InventoryAgent } from './core/inventory-agent';
|
|
17
|
+
import { FrontEndAgent } from './core/frontend-agent';
|
|
18
|
+
import { SecurityAgent } from './core/security-agent';
|
|
19
|
+
import { ArchitectureAgent } from './core/architecture-agent';
|
|
20
|
+
import { QualityAgent } from './core/quality-agent';
|
|
21
|
+
import { DocumentationAgent } from './core/documentation-agent';
|
|
22
|
+
import { CMSAgent } from './domains/news/cms-agent';
|
|
23
|
+
import { SEOAgent } from './domains/news/seo-agent';
|
|
24
|
+
import { ProductionControlAgent } from './domains/production/production-control-agent';
|
|
25
|
+
import { RouteAgent } from './domains/logistics/route-agent';
|
|
26
|
+
|
|
27
|
+
const rl = readline.createInterface({
|
|
28
|
+
input: process.stdin,
|
|
29
|
+
output: process.stdout,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function question(query: string): Promise<string> {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
rl.question(query, resolve);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
console.log('\n' + '='.repeat(60));
|
|
40
|
+
console.log('🤖 BEM-VINDO AO SISTEMA DE AGENTES INTELIGENTES');
|
|
41
|
+
console.log('='.repeat(60) + '\n');
|
|
42
|
+
|
|
43
|
+
console.log('Este é o processo de inicialização do sistema.');
|
|
44
|
+
console.log('O orquestrador irá preparar TODOS os agentes para trabalhar.\n');
|
|
45
|
+
|
|
46
|
+
// 1. Pedir permissão
|
|
47
|
+
const permission = await question(
|
|
48
|
+
'❓ Posso escanear seu projeto e criar a memória inicial para todos os agentes? (s/n): '
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (permission.toLowerCase() !== 's' && permission.toLowerCase() !== 'sim') {
|
|
52
|
+
console.log('\n❌ Inicialização cancelada pelo usuário.');
|
|
53
|
+
console.log('Execute novamente quando estiver pronto: npm run init\n');
|
|
54
|
+
rl.close();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log('\n✅ Permissão concedida! Iniciando...\n');
|
|
59
|
+
|
|
60
|
+
const projectRoot = process.cwd();
|
|
61
|
+
|
|
62
|
+
// 2. Inicializar agentes
|
|
63
|
+
console.log('📦 Inicializando agentes...\n');
|
|
64
|
+
|
|
65
|
+
const memoryPath = path.join(projectRoot, '.agents', 'memory');
|
|
66
|
+
|
|
67
|
+
const agents = [
|
|
68
|
+
{ name: 'Inventory Agent', agent: new InventoryAgent(projectRoot, memoryPath), priority: 1 },
|
|
69
|
+
{ name: 'Frontend Agent', agent: new FrontEndAgent(memoryPath), priority: 2 },
|
|
70
|
+
{ name: 'Security Agent', agent: new SecurityAgent(memoryPath), priority: 2 },
|
|
71
|
+
{ name: 'Architecture Agent', agent: new ArchitectureAgent(memoryPath), priority: 2 },
|
|
72
|
+
{ name: 'Quality Agent', agent: new QualityAgent(memoryPath), priority: 2 },
|
|
73
|
+
{ name: 'Documentation Agent', agent: new DocumentationAgent(memoryPath), priority: 2 },
|
|
74
|
+
{ name: 'CMS Agent', agent: new CMSAgent(memoryPath), priority: 3 },
|
|
75
|
+
{ name: 'SEO Agent', agent: new SEOAgent(memoryPath), priority: 3 },
|
|
76
|
+
{ name: 'Production Control Agent', agent: new ProductionControlAgent(memoryPath), priority: 3 },
|
|
77
|
+
{ name: 'Route Agent', agent: new RouteAgent(memoryPath), priority: 3 },
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
// Ordenar por prioridade (Inventory Agent primeiro)
|
|
81
|
+
agents.sort((a, b) => a.priority - b.priority);
|
|
82
|
+
|
|
83
|
+
// 3. Inicializar cada agente
|
|
84
|
+
for (const { name, agent } of agents) {
|
|
85
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
86
|
+
console.log(`🤖 Inicializando: ${name}`);
|
|
87
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
// Cada agente executa sua tarefa de inicialização
|
|
91
|
+
const result = await agent.executeWithMemory('Inicializar memória do agente', {
|
|
92
|
+
files: [],
|
|
93
|
+
areas: ['initialization'],
|
|
94
|
+
complexity: 'low',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (result.success) {
|
|
98
|
+
console.log(`✅ ${name} inicializado com sucesso!`);
|
|
99
|
+
if (result.details) {
|
|
100
|
+
console.log(` ${result.details}`);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
console.log(`⚠️ ${name} teve problemas na inicialização:`);
|
|
104
|
+
console.log(` ${result.details}`);
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.log(`❌ Erro ao inicializar ${name}:`);
|
|
108
|
+
console.log(` ${(error as Error).message}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 4. Scan completo do Inventory Agent
|
|
113
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
114
|
+
console.log('🏭 INVENTORY AGENT - Escaneando Projeto Completo');
|
|
115
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
116
|
+
|
|
117
|
+
const inventoryAgent = agents[0].agent as InventoryAgent;
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const scanResult = await inventoryAgent.executeWithMemory('Escanear projeto completo', {
|
|
121
|
+
files: [],
|
|
122
|
+
areas: ['all'],
|
|
123
|
+
complexity: 'high',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (scanResult.success) {
|
|
127
|
+
console.log('\n✅ Scan completo do projeto finalizado!');
|
|
128
|
+
console.log(` ${scanResult.details}`);
|
|
129
|
+
|
|
130
|
+
if (scanResult.recommendations && scanResult.recommendations.length > 0) {
|
|
131
|
+
console.log('\n📊 Resumo do Inventário:');
|
|
132
|
+
scanResult.recommendations.forEach((rec) => {
|
|
133
|
+
console.log(` ${rec}`);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.log(`❌ Erro no scan do projeto: ${(error as Error).message}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 5. Resumo final
|
|
142
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
143
|
+
console.log('🎉 INICIALIZAÇÃO COMPLETA!');
|
|
144
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
145
|
+
|
|
146
|
+
console.log('✅ Todos os agentes foram inicializados e estão prontos para trabalhar!');
|
|
147
|
+
console.log('✅ Memória inicial criada para cada agente');
|
|
148
|
+
console.log('✅ Inventário completo do projeto catalogado\n');
|
|
149
|
+
|
|
150
|
+
console.log('📚 Próximos passos:');
|
|
151
|
+
console.log(' 1. Execute tarefas usando: npm run task "sua tarefa"');
|
|
152
|
+
console.log(' 2. Consulte a documentação em: .agents/README.md');
|
|
153
|
+
console.log(' 3. Veja o inventário em: .agents/memory/inventory-agent/inventory/\n');
|
|
154
|
+
|
|
155
|
+
console.log('🤖 Sistema de Agentes Inteligentes pronto para uso!\n');
|
|
156
|
+
|
|
157
|
+
rl.close();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main().catch((error) => {
|
|
161
|
+
console.error('\n❌ Erro fatal durante inicialização:', error);
|
|
162
|
+
rl.close();
|
|
163
|
+
process.exit(1);
|
|
164
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Architecture Agent - Especialidade
|
|
2
|
+
|
|
3
|
+
## Responsabilidades
|
|
4
|
+
- Validar estrutura de arquivos
|
|
5
|
+
- Garantir limite de 500 linhas por arquivo
|
|
6
|
+
- Detectar duplicação de código
|
|
7
|
+
- Validar separação de camadas (MVC, Clean Architecture)
|
|
8
|
+
- Verificar nomenclatura consistente
|
|
9
|
+
|
|
10
|
+
## Expertise
|
|
11
|
+
- Design Patterns (Factory, Strategy, Observer, etc.)
|
|
12
|
+
- SOLID Principles
|
|
13
|
+
- Clean Architecture
|
|
14
|
+
- Microservices Architecture
|
|
15
|
+
- Modularização e Componentização
|
|
16
|
+
- DRY (Don't Repeat Yourself)
|
|
17
|
+
|
|
18
|
+
## Regras
|
|
19
|
+
- Máximo 500 linhas por arquivo
|
|
20
|
+
- Sem duplicação de código (DRY)
|
|
21
|
+
- Separação clara de responsabilidades
|
|
22
|
+
- Nomenclatura consistente (PascalCase para componentes, camelCase para funções)
|
|
23
|
+
- Componentes UI não devem ter lógica de API
|
|
24
|
+
- Utils devem ser independentes de UI
|
|
25
|
+
|
|
26
|
+
## Tarefas Típicas
|
|
27
|
+
- Validar estrutura de novos componentes
|
|
28
|
+
- Detectar código duplicado
|
|
29
|
+
- Sugerir refatorações
|
|
30
|
+
- Validar separação de camadas
|
|
31
|
+
- Revisar nomenclatura de arquivos
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1769137691457-s1srymq3m",
|
|
4
|
+
"timestamp": "2026-01-23T03:08:11.457Z",
|
|
5
|
+
"taskDescription": "Inicializar memória do agente",
|
|
6
|
+
"context": {
|
|
7
|
+
"files": [],
|
|
8
|
+
"areas": [
|
|
9
|
+
"initialization"
|
|
10
|
+
],
|
|
11
|
+
"complexity": "low"
|
|
12
|
+
},
|
|
13
|
+
"result": "success",
|
|
14
|
+
"details": "Arquitetura validada com sucesso"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|