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
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
# 📊 Exemplo de Reporting Completo
|
|
2
|
-
|
|
3
|
-
## ❌ ANTES: Sem Sistema de Reporting
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
Usuário: "Crie um componente de login com validação"
|
|
7
|
-
|
|
8
|
-
Agente: Vou criar o componente...
|
|
9
|
-
|
|
10
|
-
[... código é gerado ...]
|
|
11
|
-
|
|
12
|
-
Agente: Pronto! Criei o componente LoginForm.tsx com validações.
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
**Problemas**:
|
|
16
|
-
- ❌ Não mostra quais agentes foram usados
|
|
17
|
-
- ❌ Não mostra nível de contexto
|
|
18
|
-
- ❌ Não explica POR QUÊ as escolhas foram feitas
|
|
19
|
-
- ❌ Não mostra o ANTES vs DEPOIS
|
|
20
|
-
- ❌ Não documenta memórias (boas e ruins)
|
|
21
|
-
- ❌ Não há plano antes de executar
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## ✅ DEPOIS: Com Sistema de Reporting
|
|
26
|
-
|
|
27
|
-
```markdown
|
|
28
|
-
Usuário: "Crie um componente de login com validação"
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
📊 CONTEXTO ATUAL
|
|
33
|
-
🟡 **MÉDIO** (54%)
|
|
34
|
-
Espaço suficiente para esta tarefa.
|
|
35
|
-
|
|
36
|
-
[████████████████░░░░░░░░░░░░░░] 54%
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
📋 PLANO DE EXECUÇÃO
|
|
41
|
-
|
|
42
|
-
## ⚙️ O Que Será Feito
|
|
43
|
-
- [ ] Criar componente LoginForm.tsx
|
|
44
|
-
- [ ] Adicionar validação de email (regex)
|
|
45
|
-
- [ ] Adicionar validação de senha (min 8 chars)
|
|
46
|
-
- [ ] Integrar com Supabase Auth
|
|
47
|
-
- [ ] Adicionar feedback visual de erros
|
|
48
|
-
|
|
49
|
-
## 🤖 Agentes que Serão Usados
|
|
50
|
-
- [ ] **Frontend Agent** - Criar componente React
|
|
51
|
-
- [ ] **Security Agent** - Validar padrões de segurança
|
|
52
|
-
- [ ] **Testing Agent** - Criar testes unitários
|
|
53
|
-
|
|
54
|
-
## 📊 Estimativa de Contexto
|
|
55
|
-
**Contexto Atual**: Médio (54%)
|
|
56
|
-
**Contexto Após Tarefa**: Médio-Alto (~72%)
|
|
57
|
-
**Ação Recomendada**: Continuar nesta conversa
|
|
58
|
-
|
|
59
|
-
## 🎯 Critérios de Sucesso
|
|
60
|
-
- ✅ Componente funcional
|
|
61
|
-
- ✅ Validação de email funcionando
|
|
62
|
-
- ✅ Validação de senha funcionando
|
|
63
|
-
- ✅ Sem vulnerabilidades
|
|
64
|
-
- ✅ Testes passando
|
|
65
|
-
|
|
66
|
-
## 🚨 Possíveis Bloqueadores
|
|
67
|
-
- ⚠️ Pode precisar atualizar @supabase/auth-helpers
|
|
68
|
-
- ⚠️ Regex de email pode precisar ajuste
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
[Aguardando confirmação do usuário...]
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
🤖 AGENTES ATIVOS:
|
|
77
|
-
🔄 Frontend Agent - Criando componente LoginForm (2s)
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
✅ EXECUTANDO...
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
📝 RELATÓRIO DE MUDANÇAS
|
|
86
|
-
|
|
87
|
-
## 🤖 Agente Responsável
|
|
88
|
-
**Frontend Agent**
|
|
89
|
-
|
|
90
|
-
## 📊 Contexto
|
|
91
|
-
- **Nível de contexto**: Médio-Alto (72%)
|
|
92
|
-
- **Status**: ✅ Dentro do limite saudável
|
|
93
|
-
|
|
94
|
-
## ✅ O Que Foi Feito
|
|
95
|
-
- Criado `components/auth/LoginForm.tsx`
|
|
96
|
-
- Adicionadas validações de email e senha
|
|
97
|
-
- Integrado com Supabase Auth (signInWithPassword)
|
|
98
|
-
- Adicionado feedback visual de erros com toast
|
|
99
|
-
|
|
100
|
-
## 🎯 Por Que Foi Feito
|
|
101
|
-
- **Necessidade**: Sistema precisa de autenticação de usuários
|
|
102
|
-
- **Validação**: Previne erros de input antes de chamar API
|
|
103
|
-
- **Segurança**: Validação client-side + server-side (RLS)
|
|
104
|
-
- **UX**: Feedback visual melhora experiência do usuário
|
|
105
|
-
|
|
106
|
-
## 📊 Antes vs Depois
|
|
107
|
-
|
|
108
|
-
### ANTES
|
|
109
|
-
```typescript
|
|
110
|
-
// Não existia
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### DEPOIS
|
|
114
|
-
```typescript
|
|
115
|
-
'use client';
|
|
116
|
-
|
|
117
|
-
import { useState } from 'react';
|
|
118
|
-
import { z } from 'zod';
|
|
119
|
-
import { supabase } from '@/lib/supabase';
|
|
120
|
-
|
|
121
|
-
const loginSchema = z.object({
|
|
122
|
-
email: z.string().email('Email inválido'),
|
|
123
|
-
password: z.string().min(8, 'Mínimo 8 caracteres')
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
export function LoginForm() {
|
|
127
|
-
// Validação de email com zod
|
|
128
|
-
// Validação de senha (min 8 chars)
|
|
129
|
-
// Integração com Supabase Auth
|
|
130
|
-
// Feedback visual de erros
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## 🔍 Diferenças Importantes
|
|
135
|
-
- ➕ **Adicionado**: Validação regex de email (RFC 5322)
|
|
136
|
-
- ➕ **Adicionado**: Validação de senha (mínimo 8 caracteres)
|
|
137
|
-
- ➕ **Adicionado**: Integração com Supabase Auth
|
|
138
|
-
- ➕ **Adicionado**: Feedback de erros com toast notifications
|
|
139
|
-
- ➕ **Adicionado**: Loading state durante autenticação
|
|
140
|
-
|
|
141
|
-
## 💾 MEMÓRIAS SALVAS
|
|
142
|
-
|
|
143
|
-
### ✅ Frontend Agent (Boa)
|
|
144
|
-
- Padrão de validação com zod funciona muito bem
|
|
145
|
-
- Toast notifications melhoram UX
|
|
146
|
-
- Separar validação client/server é boa prática
|
|
147
|
-
|
|
148
|
-
### ❌ Security Agent (Atenção)
|
|
149
|
-
- Quase esqueci de adicionar rate limiting no Supabase
|
|
150
|
-
- Validação client-side NÃO substitui server-side (RLS)
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
📊 DASHBOARD DE MEMÓRIAS
|
|
155
|
-
|
|
156
|
-
┌──────────────────────────────────────────────────┐
|
|
157
|
-
│ Frontend Agent │
|
|
158
|
-
├──────────────────────────────────────────────────┤
|
|
159
|
-
│ ✅ Memórias Boas: 13 │
|
|
160
|
-
│ - Padrão de validação com zod (6x sucesso) │
|
|
161
|
-
│ - Estrutura de componentes (3x) │
|
|
162
|
-
│ - State management com Zustand (4x) │
|
|
163
|
-
│ │
|
|
164
|
-
│ ❌ Memórias Ruins: 3 │
|
|
165
|
-
│ - Esquecer PropTypes (2x erro) │
|
|
166
|
-
│ - Não validar props opcionais (1x) │
|
|
167
|
-
│ │
|
|
168
|
-
│ 📈 Taxa de Sucesso: 81% │
|
|
169
|
-
└──────────────────────────────────────────────────┘
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
📊 CONTEXTO FINAL: Médio-Alto (72%)
|
|
174
|
-
⚠️ Ainda há espaço, mas monitore o crescimento.
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
**Status**: ✅ Tarefa concluída com sucesso!
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## 🎯 Comparação
|
|
184
|
-
|
|
185
|
-
| Aspecto | SEM Reporting | COM Reporting |
|
|
186
|
-
|---------|---------------|---------------|
|
|
187
|
-
| **Transparência** | ❌ Baixa | ✅ Total |
|
|
188
|
-
| **Controle de Contexto** | ❌ Sem aviso | ✅ Aviso proativo |
|
|
189
|
-
| **Rastreabilidade** | ❌ Não sabe quem fez | ✅ Agente + timestamp |
|
|
190
|
-
| **Explicação** | ❌ Só mostra resultado | ✅ Explica POR QUÊ |
|
|
191
|
-
| **Aprendizado** | ❌ Sem histórico | ✅ Dashboard de memórias |
|
|
192
|
-
| **Planejamento** | ❌ Executa direto | ✅ Plano antes de executar |
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## ✨ Benefícios do Novo Sistema
|
|
197
|
-
|
|
198
|
-
1. **📊 Transparência Total**: Usuário sempre sabe o que está acontecendo
|
|
199
|
-
2. **⚠️ Controle de Contexto**: Aviso antes de estourar limite
|
|
200
|
-
3. **📝 Rastreabilidade**: Sabe exatamente quem fez o quê e quando
|
|
201
|
-
4. **🧠 Aprendizado Visível**: Dashboard mostra padrões de sucesso e erro
|
|
202
|
-
5. **✅ Planejamento Obrigatório**: Sempre há confirmação antes de executar
|
|
203
|
-
6. **🔍 Explicação Detalhada**: Entende POR QUÊ as decisões foram tomadas
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build Manager - Sistema de Build Incremental
|
|
3
|
-
*
|
|
4
|
-
* Responsabilidades:
|
|
5
|
-
* - Rastrear todas as mudanças de arquivos
|
|
6
|
-
* - Versionar builds incrementalmente (build 1 → build 780)
|
|
7
|
-
* - Criar snapshots de arquivos modificados
|
|
8
|
-
* - Manter histórico completo de builds
|
|
9
|
-
*
|
|
10
|
-
* Estrutura:
|
|
11
|
-
* projeto/
|
|
12
|
-
* ├── .builds/
|
|
13
|
-
* │ ├── history.json
|
|
14
|
-
* │ └── snapshots/
|
|
15
|
-
* │ └── 0.0.1/
|
|
16
|
-
* │ └── arquivo.ts/
|
|
17
|
-
* │ ├── build-001.ts
|
|
18
|
-
* │ ├── build-002.ts
|
|
19
|
-
* │ └── build-780.ts
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import * as fs from 'fs';
|
|
23
|
-
import * as path from 'path';
|
|
24
|
-
|
|
25
|
-
export interface BuildEntry {
|
|
26
|
-
buildNumber: number;
|
|
27
|
-
version: string;
|
|
28
|
-
timestamp: string;
|
|
29
|
-
agent: string;
|
|
30
|
-
files: string[];
|
|
31
|
-
success: boolean;
|
|
32
|
-
description?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface BuildHistory {
|
|
36
|
-
currentVersion: string;
|
|
37
|
-
currentBuild: number;
|
|
38
|
-
builds: BuildEntry[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class BuildManager {
|
|
42
|
-
private projectRoot: string;
|
|
43
|
-
private buildsDir: string;
|
|
44
|
-
private historyFile: string;
|
|
45
|
-
private snapshotsDir: string;
|
|
46
|
-
private history: BuildHistory;
|
|
47
|
-
|
|
48
|
-
constructor(projectRoot: string = process.cwd()) {
|
|
49
|
-
this.projectRoot = projectRoot;
|
|
50
|
-
|
|
51
|
-
// Use package-relative path instead of project root
|
|
52
|
-
const packageRoot = path.join(__dirname, '..', '..');
|
|
53
|
-
this.buildsDir = path.join(packageRoot, '.system', 'builds');
|
|
54
|
-
this.historyFile = path.join(this.buildsDir, 'history.json');
|
|
55
|
-
this.snapshotsDir = path.join(this.buildsDir, 'snapshots');
|
|
56
|
-
|
|
57
|
-
this.ensureDirectories();
|
|
58
|
-
this.history = this.loadHistory();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Cria diretórios necessários
|
|
63
|
-
*/
|
|
64
|
-
private ensureDirectories(): void {
|
|
65
|
-
if (!fs.existsSync(this.buildsDir)) {
|
|
66
|
-
fs.mkdirSync(this.buildsDir, { recursive: true });
|
|
67
|
-
}
|
|
68
|
-
if (!fs.existsSync(this.snapshotsDir)) {
|
|
69
|
-
fs.mkdirSync(this.snapshotsDir, { recursive: true });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Carrega histórico de builds
|
|
75
|
-
*/
|
|
76
|
-
private loadHistory(): BuildHistory {
|
|
77
|
-
if (fs.existsSync(this.historyFile)) {
|
|
78
|
-
try {
|
|
79
|
-
const content = fs.readFileSync(this.historyFile, 'utf-8');
|
|
80
|
-
return JSON.parse(content);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.warn('⚠️ Erro ao carregar histórico de builds, criando novo');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
currentVersion: '0.0.1',
|
|
88
|
-
currentBuild: 0,
|
|
89
|
-
builds: []
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Salva histórico de builds
|
|
95
|
-
*/
|
|
96
|
-
private saveHistory(): void {
|
|
97
|
-
fs.writeFileSync(
|
|
98
|
-
this.historyFile,
|
|
99
|
-
JSON.stringify(this.history, null, 2),
|
|
100
|
-
'utf-8'
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Incrementa build e cria snapshot
|
|
106
|
-
*/
|
|
107
|
-
async createBuild(
|
|
108
|
-
files: string[],
|
|
109
|
-
agent: string,
|
|
110
|
-
success: boolean,
|
|
111
|
-
description?: string
|
|
112
|
-
): Promise<number> {
|
|
113
|
-
this.history.currentBuild++;
|
|
114
|
-
const buildNumber = this.history.currentBuild;
|
|
115
|
-
|
|
116
|
-
console.log(`\n📦 Criando Build ${buildNumber}...`);
|
|
117
|
-
|
|
118
|
-
// Criar snapshots dos arquivos modificados
|
|
119
|
-
const savedFiles: string[] = [];
|
|
120
|
-
for (const filePath of files) {
|
|
121
|
-
if (fs.existsSync(filePath)) {
|
|
122
|
-
const snapshotPath = await this.createSnapshot(filePath, buildNumber);
|
|
123
|
-
if (snapshotPath) {
|
|
124
|
-
savedFiles.push(snapshotPath);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Registrar build no histórico
|
|
130
|
-
const buildEntry: BuildEntry = {
|
|
131
|
-
buildNumber,
|
|
132
|
-
version: this.history.currentVersion,
|
|
133
|
-
timestamp: new Date().toISOString(),
|
|
134
|
-
agent,
|
|
135
|
-
files: savedFiles,
|
|
136
|
-
success,
|
|
137
|
-
description
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
this.history.builds.push(buildEntry);
|
|
141
|
-
this.saveHistory();
|
|
142
|
-
|
|
143
|
-
console.log(`✅ Build ${buildNumber} criado com sucesso`);
|
|
144
|
-
console.log(` Arquivos: ${savedFiles.length}`);
|
|
145
|
-
console.log(` Agente: ${agent}`);
|
|
146
|
-
|
|
147
|
-
return buildNumber;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Cria snapshot de um arquivo
|
|
152
|
-
*/
|
|
153
|
-
private async createSnapshot(filePath: string, buildNumber: number): Promise<string | null> {
|
|
154
|
-
try {
|
|
155
|
-
// Caminho relativo ao projeto
|
|
156
|
-
const relativePath = path.relative(this.projectRoot, filePath);
|
|
157
|
-
|
|
158
|
-
// Diretório do snapshot: .builds/snapshots/0.0.1/arquivo.ts/
|
|
159
|
-
const snapshotDir = path.join(
|
|
160
|
-
this.snapshotsDir,
|
|
161
|
-
this.history.currentVersion,
|
|
162
|
-
relativePath
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
// Criar diretório se não existir
|
|
166
|
-
if (!fs.existsSync(snapshotDir)) {
|
|
167
|
-
fs.mkdirSync(snapshotDir, { recursive: true });
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Arquivo snapshot: build-001.ts
|
|
171
|
-
const ext = path.extname(filePath);
|
|
172
|
-
const snapshotFile = path.join(
|
|
173
|
-
snapshotDir,
|
|
174
|
-
`build-${buildNumber.toString().padStart(3, '0')}${ext}`
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
// Copiar arquivo
|
|
178
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
179
|
-
fs.writeFileSync(snapshotFile, content, 'utf-8');
|
|
180
|
-
|
|
181
|
-
return path.relative(this.buildsDir, snapshotFile);
|
|
182
|
-
} catch (error) {
|
|
183
|
-
console.error(`❌ Erro ao criar snapshot de ${filePath}:`, error);
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Incrementa versão (0.0.1 → 0.0.2)
|
|
190
|
-
*/
|
|
191
|
-
incrementVersion(type: 'major' | 'minor' | 'patch' = 'patch'): string {
|
|
192
|
-
const [major, minor, patch] = this.history.currentVersion.split('.').map(Number);
|
|
193
|
-
|
|
194
|
-
switch (type) {
|
|
195
|
-
case 'major':
|
|
196
|
-
this.history.currentVersion = `${major + 1}.0.0`;
|
|
197
|
-
break;
|
|
198
|
-
case 'minor':
|
|
199
|
-
this.history.currentVersion = `${major}.${minor + 1}.0`;
|
|
200
|
-
break;
|
|
201
|
-
case 'patch':
|
|
202
|
-
this.history.currentVersion = `${major}.${minor}.${patch + 1}`;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
this.history.currentBuild = 0; // Reset build counter
|
|
207
|
-
this.saveHistory();
|
|
208
|
-
|
|
209
|
-
console.log(`📌 Versão incrementada para ${this.history.currentVersion}`);
|
|
210
|
-
return this.history.currentVersion;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Obtém histórico de builds
|
|
215
|
-
*/
|
|
216
|
-
getHistory(): BuildHistory {
|
|
217
|
-
return this.history;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Obtém build atual
|
|
222
|
-
*/
|
|
223
|
-
getCurrentBuild(): number {
|
|
224
|
-
return this.history.currentBuild;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Obtém versão atual
|
|
229
|
-
*/
|
|
230
|
-
getCurrentVersion(): string {
|
|
231
|
-
return this.history.currentVersion;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Obtém builds de um arquivo específico
|
|
236
|
-
*/
|
|
237
|
-
getFileBuilds(filePath: string): BuildEntry[] {
|
|
238
|
-
const relativePath = path.relative(this.projectRoot, filePath);
|
|
239
|
-
return this.history.builds.filter(build =>
|
|
240
|
-
build.files.some(f => f.includes(relativePath))
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Restaura arquivo de um build específico
|
|
246
|
-
*/
|
|
247
|
-
async restoreFromBuild(filePath: string, buildNumber: number): Promise<boolean> {
|
|
248
|
-
try {
|
|
249
|
-
const relativePath = path.relative(this.projectRoot, filePath);
|
|
250
|
-
const ext = path.extname(filePath);
|
|
251
|
-
|
|
252
|
-
const snapshotFile = path.join(
|
|
253
|
-
this.snapshotsDir,
|
|
254
|
-
this.history.currentVersion,
|
|
255
|
-
relativePath,
|
|
256
|
-
`build-${buildNumber.toString().padStart(3, '0')}${ext}`
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
if (!fs.existsSync(snapshotFile)) {
|
|
260
|
-
console.error(`❌ Build ${buildNumber} não encontrado para ${filePath}`);
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const content = fs.readFileSync(snapshotFile, 'utf-8');
|
|
265
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
266
|
-
|
|
267
|
-
console.log(`✅ Arquivo restaurado do build ${buildNumber}`);
|
|
268
|
-
return true;
|
|
269
|
-
} catch (error) {
|
|
270
|
-
console.error(`❌ Erro ao restaurar do build ${buildNumber}:`, error);
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Gera relatório de builds
|
|
277
|
-
*/
|
|
278
|
-
generateReport(): string {
|
|
279
|
-
const report = [`\n📊 RELATÓRIO DE BUILDS\n${'='.repeat(60)}`];
|
|
280
|
-
|
|
281
|
-
report.push(`Versão Atual: ${this.history.currentVersion}`);
|
|
282
|
-
report.push(`Build Atual: ${this.history.currentBuild}`);
|
|
283
|
-
report.push(`Total de Builds: ${this.history.builds.length}\n`);
|
|
284
|
-
|
|
285
|
-
if (this.history.builds.length > 0) {
|
|
286
|
-
report.push('Últimos 10 Builds:');
|
|
287
|
-
const recent = this.history.builds.slice(-10).reverse();
|
|
288
|
-
|
|
289
|
-
for (const build of recent) {
|
|
290
|
-
const status = build.success ? '✅' : '❌';
|
|
291
|
-
const date = new Date(build.timestamp).toLocaleString('pt-BR');
|
|
292
|
-
report.push(`${status} Build ${build.buildNumber} - ${date}`);
|
|
293
|
-
report.push(` Agente: ${build.agent}`);
|
|
294
|
-
if (build.description) {
|
|
295
|
-
report.push(` Descrição: ${build.description}`);
|
|
296
|
-
}
|
|
297
|
-
report.push(` Arquivos: ${build.files.length}`);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
report.push(`${'='.repeat(60)}\n`);
|
|
302
|
-
return report.join('\n');
|
|
303
|
-
}
|
|
304
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache Manager - Sistema de cache inteligente com TTL
|
|
3
|
-
*
|
|
4
|
-
* Reduz latência de consultas à memória em até 80%
|
|
5
|
-
* ao cachear resultados frequentes em memória
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export interface CacheEntry<T> {
|
|
9
|
-
data: T;
|
|
10
|
-
expiry: number;
|
|
11
|
-
hits: number;
|
|
12
|
-
createdAt: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface CacheStats {
|
|
16
|
-
hits: number;
|
|
17
|
-
misses: number;
|
|
18
|
-
size: number;
|
|
19
|
-
hitRate: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class CacheManager {
|
|
23
|
-
private cache = new Map<string, CacheEntry<any>>();
|
|
24
|
-
private readonly defaultTTL: number;
|
|
25
|
-
private readonly maxSize: number;
|
|
26
|
-
private stats = {
|
|
27
|
-
hits: 0,
|
|
28
|
-
misses: 0
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
constructor(defaultTTL: number = 300000, maxSize: number = 1000) {
|
|
32
|
-
this.defaultTTL = defaultTTL; // 5 minutos padrão
|
|
33
|
-
this.maxSize = maxSize;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Obtém valor do cache
|
|
38
|
-
*/
|
|
39
|
-
get<T>(key: string): T | null {
|
|
40
|
-
const entry = this.cache.get(key);
|
|
41
|
-
|
|
42
|
-
if (!entry) {
|
|
43
|
-
this.stats.misses++;
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Verificar se expirou
|
|
48
|
-
if (Date.now() > entry.expiry) {
|
|
49
|
-
this.cache.delete(key);
|
|
50
|
-
this.stats.misses++;
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Incrementar hits
|
|
55
|
-
entry.hits++;
|
|
56
|
-
this.stats.hits++;
|
|
57
|
-
|
|
58
|
-
return entry.data as T;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Define valor no cache
|
|
63
|
-
*/
|
|
64
|
-
set<T>(key: string, data: T, ttl?: number): void {
|
|
65
|
-
// Verificar limite de tamanho
|
|
66
|
-
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
67
|
-
this.evictLRU();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const expiryTime = ttl || this.defaultTTL;
|
|
71
|
-
|
|
72
|
-
this.cache.set(key, {
|
|
73
|
-
data,
|
|
74
|
-
expiry: Date.now() + expiryTime,
|
|
75
|
-
hits: 0,
|
|
76
|
-
createdAt: Date.now()
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Remove entrada do cache
|
|
82
|
-
*/
|
|
83
|
-
delete(key: string): boolean {
|
|
84
|
-
return this.cache.delete(key);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Limpa todo o cache
|
|
89
|
-
*/
|
|
90
|
-
clear(): void {
|
|
91
|
-
this.cache.clear();
|
|
92
|
-
this.stats.hits = 0;
|
|
93
|
-
this.stats.misses = 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Remove entradas expiradas
|
|
98
|
-
*/
|
|
99
|
-
cleanup(): number {
|
|
100
|
-
const now = Date.now();
|
|
101
|
-
let removed = 0;
|
|
102
|
-
|
|
103
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
104
|
-
if (now > entry.expiry) {
|
|
105
|
-
this.cache.delete(key);
|
|
106
|
-
removed++;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return removed;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Evict Least Recently Used (LRU)
|
|
115
|
-
*/
|
|
116
|
-
private evictLRU(): void {
|
|
117
|
-
let lruKey: string | null = null;
|
|
118
|
-
let lruHits = Infinity;
|
|
119
|
-
|
|
120
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
121
|
-
if (entry.hits < lruHits) {
|
|
122
|
-
lruHits = entry.hits;
|
|
123
|
-
lruKey = key;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (lruKey) {
|
|
128
|
-
this.cache.delete(lruKey);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Obtém estatísticas do cache
|
|
134
|
-
*/
|
|
135
|
-
getStats(): CacheStats {
|
|
136
|
-
const total = this.stats.hits + this.stats.misses;
|
|
137
|
-
const hitRate = total > 0 ? (this.stats.hits / total) * 100 : 0;
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
hits: this.stats.hits,
|
|
141
|
-
misses: this.stats.misses,
|
|
142
|
-
size: this.cache.size,
|
|
143
|
-
hitRate: Math.round(hitRate * 100) / 100
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Reseta estatísticas
|
|
149
|
-
*/
|
|
150
|
-
resetStats(): void {
|
|
151
|
-
this.stats.hits = 0;
|
|
152
|
-
this.stats.misses = 0;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Obtém todas as chaves do cache
|
|
157
|
-
*/
|
|
158
|
-
keys(): string[] {
|
|
159
|
-
return Array.from(this.cache.keys());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Verifica se chave existe no cache
|
|
164
|
-
*/
|
|
165
|
-
has(key: string): boolean {
|
|
166
|
-
const entry = this.cache.get(key);
|
|
167
|
-
if (!entry) return false;
|
|
168
|
-
|
|
169
|
-
// Verificar se não expirou
|
|
170
|
-
if (Date.now() > entry.expiry) {
|
|
171
|
-
this.cache.delete(key);
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Obtém tamanho atual do cache
|
|
180
|
-
*/
|
|
181
|
-
size(): number {
|
|
182
|
-
return this.cache.size;
|
|
183
|
-
}
|
|
184
|
-
}
|