kakaroto-config 1.0.4 → 1.0.6
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/config/ARCHITECTURE.md +5 -7
- package/config/CLAUDE.md +11 -0
- package/config/agents/code-reviewer.md +66 -230
- package/config/agents/code-simplifier.md +70 -116
- package/config/agents/{visual-validator.md → functional-validator.md} +118 -92
- package/config/agents/memory-sync.md +193 -134
- package/config/commands/debug/02-investigate.md +3 -3
- package/config/commands/debug/03-fix.md +28 -6
- package/config/commands/debug/05-commit.md +1 -1
- package/config/commands/debug/validators/fix-permanence.md +1 -1
- package/config/commands/feature/01-understand.md +217 -0
- package/config/commands/feature/02-analyze.md +168 -0
- package/config/commands/feature/03-strategy.md +300 -0
- package/config/commands/feature/04-red.md +160 -0
- package/config/commands/feature/05-green.md +179 -0
- package/config/commands/feature/06-quality.md +109 -0
- package/config/commands/feature/07-validation.md +168 -0
- package/config/commands/feature/08-delivery.md +86 -0
- package/config/commands/feature/09-evaluate.md +140 -0
- package/config/commands/feature/playbooks/_e2e-base.md +39 -0
- package/config/commands/feature/playbooks/api/analyze.md +20 -0
- package/config/commands/feature/playbooks/api/e2e.md +29 -0
- package/config/commands/feature/playbooks/api/red.md +66 -0
- package/config/commands/feature/playbooks/job/analyze.md +29 -0
- package/config/commands/feature/playbooks/job/e2e.md +30 -0
- package/config/commands/feature/playbooks/job/red.md +77 -0
- package/config/commands/feature/playbooks/service/analyze.md +28 -0
- package/config/commands/feature/playbooks/service/e2e.md +25 -0
- package/config/commands/feature/playbooks/service/red.md +75 -0
- package/config/commands/feature/playbooks/ui/analyze.md +26 -0
- package/config/commands/feature/playbooks/ui/e2e.md +61 -0
- package/config/commands/feature/playbooks/ui/red.md +71 -0
- package/config/commands/feature.md +37 -4
- package/config/commands/gate.md +11 -23
- package/config/templates/spec-template.md +82 -68
- package/package.json +3 -3
- package/config/agents/dry-enforcer.md +0 -227
- package/config/commands/debug/techniques/flow-tracing.md +0 -75
- package/config/commands/debug/techniques/hypothesis-generation.md +0 -30
- package/config/commands/debug/techniques/sequential-thinking-config.md +0 -79
- package/config/commands/feature/01-interview.md +0 -143
- package/config/commands/feature/02-spec.md +0 -98
- package/config/commands/feature/03-planner.md +0 -200
- package/config/commands/feature/04-implement.md +0 -81
- package/config/commands/feature/05-quality.md +0 -140
- package/config/commands/feature/06-commit.md +0 -91
- package/config/commands/feature/07-evaluate.md +0 -129
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Fase 4: RED (Escrever Testes)
|
|
2
|
+
|
|
3
|
+
> **REGRA:** Testes devem FALHAR. Imports inexistentes OK. NÃO escreva código de produção.
|
|
4
|
+
|
|
5
|
+
## Responsabilidade
|
|
6
|
+
Escrever testes que FALHAM baseados no contract. Execução AUTÔNOMA.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Passo 1: Carregar Contexto
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Read {state.contract} # Critérios aprovados + mitigações
|
|
14
|
+
Read {state.analysis} # Mapa: testes existentes, código a reutilizar
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Listar factories/mocks disponíveis:
|
|
18
|
+
- test-utils/factories/ → nomes
|
|
19
|
+
- test-utils/mocks/ → nomes
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Passo 2: Isolar Contexto (CRUCIAL)
|
|
24
|
+
|
|
25
|
+
**DESCARTAR da memória:**
|
|
26
|
+
- Código de produção
|
|
27
|
+
- Patterns de implementação
|
|
28
|
+
- Como funções são implementadas
|
|
29
|
+
|
|
30
|
+
**RETER apenas:**
|
|
31
|
+
- Critérios do contract (O QUE testar)
|
|
32
|
+
- Nomes de factories/mocks (COMO isolar)
|
|
33
|
+
- Mapa de testes existentes (ONDE colocar)
|
|
34
|
+
|
|
35
|
+
> **Objetivo:** Testar COMPORTAMENTO, não IMPLEMENTAÇÃO.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Passo 3: Escrever Testes
|
|
40
|
+
|
|
41
|
+
### 3.1 Decisão de Local
|
|
42
|
+
|
|
43
|
+
| Resultado no Analysis | Ação |
|
|
44
|
+
|----------------------|------|
|
|
45
|
+
| Teste existe para módulo | ESTENDER arquivo existente |
|
|
46
|
+
| Arquivo existe, caso não | ADICIONAR describe/it |
|
|
47
|
+
| Nenhum existe | CRIAR novo arquivo |
|
|
48
|
+
|
|
49
|
+
### 3.2 Estrutura (via Playbook)
|
|
50
|
+
|
|
51
|
+
Carregar playbook de testes conforme tipo da feature:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Read ~/.claude/commands/feature/playbooks/{featureType}/red.md
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| featureType | Playbook |
|
|
58
|
+
|-------------|----------|
|
|
59
|
+
| api | playbooks/api/red.md |
|
|
60
|
+
| ui | playbooks/ui/red.md |
|
|
61
|
+
| service | playbooks/service/red.md |
|
|
62
|
+
| job | playbooks/job/red.md |
|
|
63
|
+
|
|
64
|
+
O playbook define:
|
|
65
|
+
- Testes requeridos (Unit/Integration/E2E)
|
|
66
|
+
- Mocks tipicos
|
|
67
|
+
- Test patterns com vitest
|
|
68
|
+
|
|
69
|
+
### 3.3 Regras
|
|
70
|
+
|
|
71
|
+
- Imports inexistentes OK (vão falhar - RED)
|
|
72
|
+
- Usar factories de test-utils/factories/
|
|
73
|
+
- Usar mocks de test-utils/mocks/
|
|
74
|
+
- 1 critério do contract → 1+ testes
|
|
75
|
+
- **APENAS Unit e Integration tests** (E2E é validado em 07-validation)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Passo 4: Sufficiency Gate
|
|
80
|
+
|
|
81
|
+
Usar `mcp__sequential-thinking__sequentialthinking`:
|
|
82
|
+
|
|
83
|
+
Verificar apenas critérios Unit/Integration (E2E é separado):
|
|
84
|
+
|
|
85
|
+
| # | Critério (Unit/Integration) | Teste Escrito | Coberto? |
|
|
86
|
+
|---|----------------------------|---------------|----------|
|
|
87
|
+
| 1 | "{critério}" | it('...') | ✓/✗ |
|
|
88
|
+
|
|
89
|
+
**SE** cobertura < 100%:
|
|
90
|
+
- Identificar critérios faltantes
|
|
91
|
+
- Voltar ao Passo 3
|
|
92
|
+
- Adicionar testes
|
|
93
|
+
|
|
94
|
+
**SE** cobertura == 100%:
|
|
95
|
+
- Prosseguir
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Passo 5: Verificar RED
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm test -- --testPathPattern="[feature]" 2>&1 || true
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Resultado | Ação |
|
|
106
|
+
|-----------|------|
|
|
107
|
+
| Todos FALHAM | Correto - prosseguir |
|
|
108
|
+
| Alguns passam | Investigar (já existe implementação?) |
|
|
109
|
+
| Erro de sintaxe | Corrigir teste e re-run |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Passo 6: Commit RED
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git add -A
|
|
117
|
+
git commit -m "$(cat <<'EOF'
|
|
118
|
+
test: add tests for [feature] (RED)
|
|
119
|
+
|
|
120
|
+
Tests expected to fail - implementation pending.
|
|
121
|
+
Coverage: {N} criteria from contract.
|
|
122
|
+
|
|
123
|
+
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
124
|
+
EOF
|
|
125
|
+
)"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Gate (BLOQUEANTE)
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
SLUG=$(jq -r '.feature' .claude/workflow-state.json 2>/dev/null)
|
|
134
|
+
|
|
135
|
+
# Pré-condição
|
|
136
|
+
test -f ".claude/contracts/${SLUG}.md" || { echo "❌ Pré: contract não existe"; exit 1; }
|
|
137
|
+
|
|
138
|
+
# Pós-condição: Commit RED existe
|
|
139
|
+
git log -1 --format="%s" | grep -q "test:.*RED" || { echo "❌ Commit RED não encontrado"; exit 1; }
|
|
140
|
+
|
|
141
|
+
echo "✅ Gate 04-red passou"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Passo 7: Atualizar Estado
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
jq '
|
|
150
|
+
.currentPhase = "05-green" |
|
|
151
|
+
.completedPhases += ["04-red"] |
|
|
152
|
+
.resumeHint = "Testes RED commitados. Prox: implementar código mínimo" |
|
|
153
|
+
.lastStep = "Passo 7: Atualizar Estado"
|
|
154
|
+
' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## PROXIMA FASE
|
|
160
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/05-green.md
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Fase 5: GREEN (Implementar)
|
|
2
|
+
|
|
3
|
+
> **REGRA:** Código MÍNIMO para testes passarem. Sem validações extras, abstrações ou otimizações.
|
|
4
|
+
|
|
5
|
+
## Responsabilidade
|
|
6
|
+
Implementar código MÍNIMO para testes passarem. Execução AUTÔNOMA.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Passo 1: Carregar Contexto
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Testes que falharam
|
|
14
|
+
git diff HEAD~1 --name-only | grep "\.test\.ts$"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Read {state.analysis} # Código existente a reutilizar
|
|
19
|
+
Read {state.contract} # Mitigações acordadas
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Passo 2: Planejar Tarefas
|
|
25
|
+
|
|
26
|
+
### 2.1 Mapear Testes → Código
|
|
27
|
+
|
|
28
|
+
| Teste | Código Necessário | Reutiliza? | Arquivo |
|
|
29
|
+
|-------|-------------------|------------|---------|
|
|
30
|
+
| it('A') | função X | helper.ts:20 | ESTENDER |
|
|
31
|
+
| it('B') | função Y | - | CRIAR |
|
|
32
|
+
| it('C') | função Z | utils.ts | REUTILIZAR |
|
|
33
|
+
|
|
34
|
+
### 2.2 Incluir Mitigações
|
|
35
|
+
|
|
36
|
+
Do contract, seção "Cenários Excluídos":
|
|
37
|
+
|
|
38
|
+
| Mitigação | Implementação | Arquivo |
|
|
39
|
+
|-----------|---------------|---------|
|
|
40
|
+
| try/catch para API | wrap em try/catch + log | handler.ts |
|
|
41
|
+
| Schema validation | zod schema | types.ts |
|
|
42
|
+
|
|
43
|
+
### 2.3 Ordenar
|
|
44
|
+
|
|
45
|
+
1. Dependências primeiro (tipos, utils)
|
|
46
|
+
2. Funções principais
|
|
47
|
+
3. Mitigações
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Passo 3: Implementar (Loop por Teste)
|
|
52
|
+
|
|
53
|
+
Para cada teste falhando:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
┌─────────────────────────────────────────┐
|
|
57
|
+
│ 1. TodoWrite: marcar in_progress │
|
|
58
|
+
│ 2. Implementar código MÍNIMO │
|
|
59
|
+
│ 3. tsc --noEmit │
|
|
60
|
+
│ 4. npm test -- --testPathPattern="X" │
|
|
61
|
+
│ 5. SE passou → TodoWrite: completed │
|
|
62
|
+
│ SE falhou → corrigir (max 3x) │
|
|
63
|
+
│ 6. Próximo teste │
|
|
64
|
+
└─────────────────────────────────────────┘
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### O que é "Código Mínimo"?
|
|
68
|
+
|
|
69
|
+
**FAZER:**
|
|
70
|
+
- Exatamente o que teste espera
|
|
71
|
+
- Estruturas simples e elegantes
|
|
72
|
+
- Reutilizar código existente
|
|
73
|
+
|
|
74
|
+
**NÃO FAZER:**
|
|
75
|
+
- Validações além do testado
|
|
76
|
+
- Abstrações "por precaução"
|
|
77
|
+
- Otimizações prematuras
|
|
78
|
+
- Refactoring (fase 6)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Passo 4: Validar GREEN
|
|
83
|
+
|
|
84
|
+
### 4.1 Testes
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm test
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 4.2 TypeScript
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx tsc --noEmit
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 4.3 Mitigações
|
|
97
|
+
|
|
98
|
+
Checklist do contract:
|
|
99
|
+
- [ ] Todas mitigações implementadas?
|
|
100
|
+
- [ ] Logging para cenários não testados?
|
|
101
|
+
- [ ] Schemas validam inputs de risco?
|
|
102
|
+
|
|
103
|
+
### 4.4 Loop de Correção
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
while (falhas AND tentativas < 3):
|
|
107
|
+
Identificar erro
|
|
108
|
+
Corrigir CÓDIGO (não teste)
|
|
109
|
+
Re-run
|
|
110
|
+
tentativas++
|
|
111
|
+
|
|
112
|
+
if ainda falha:
|
|
113
|
+
PARAR e reportar ao user
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Passo 5: Commit GREEN
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
git add -A
|
|
122
|
+
git commit -m "$(cat <<'EOF'
|
|
123
|
+
feat: implement [feature]
|
|
124
|
+
|
|
125
|
+
- All tests passing
|
|
126
|
+
- Mitigations implemented
|
|
127
|
+
|
|
128
|
+
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
129
|
+
EOF
|
|
130
|
+
)"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Gate (BLOQUEANTE)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Testes passam
|
|
139
|
+
npm test || { echo "❌ Testes falhando"; exit 1; }
|
|
140
|
+
|
|
141
|
+
# TypeScript compila
|
|
142
|
+
npx tsc --noEmit || { echo "❌ TypeScript não compila"; exit 1; }
|
|
143
|
+
|
|
144
|
+
echo "✅ Gate 05-green passou"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Output
|
|
150
|
+
|
|
151
|
+
```markdown
|
|
152
|
+
## GREEN Phase - Completo
|
|
153
|
+
|
|
154
|
+
**Testes:** X/X passando
|
|
155
|
+
|
|
156
|
+
**Arquivos modificados:**
|
|
157
|
+
- [lista]
|
|
158
|
+
|
|
159
|
+
**Mitigações implementadas:**
|
|
160
|
+
- [lista]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Passo 6: Atualizar Estado
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
jq '
|
|
169
|
+
.currentPhase = "06-quality" |
|
|
170
|
+
.completedPhases += ["05-green"] |
|
|
171
|
+
.resumeHint = "GREEN completo. Prox: quality gate (refactoring)" |
|
|
172
|
+
.lastStep = "Passo 6: Atualizar Estado"
|
|
173
|
+
' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## PROXIMA FASE
|
|
179
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/06-quality.md
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Fase 6: Quality
|
|
2
|
+
|
|
3
|
+
## Responsabilidade
|
|
4
|
+
REFACTOR do ciclo TDD + Quality Gate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Passo 1: Refactoring Agents
|
|
9
|
+
|
|
10
|
+
### 1.1 Code Simplifier
|
|
11
|
+
```javascript
|
|
12
|
+
Task({
|
|
13
|
+
subagent_type: "code-simplifier",
|
|
14
|
+
prompt: `Verificar reuso (DRY). Detectar duplicacoes. Simplificar.
|
|
15
|
+
|
|
16
|
+
REGRA PARA .test.ts - FACTORIES:
|
|
17
|
+
- SE objetos inline representando entidades
|
|
18
|
+
- E factory existe em test-utils/factories/
|
|
19
|
+
- ENTAO substituir por factory
|
|
20
|
+
- Validar com npm test
|
|
21
|
+
- Reverter se falhar`,
|
|
22
|
+
description: "Simplify and DRY check"
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 1.2 Code Reviewer
|
|
27
|
+
```javascript
|
|
28
|
+
Task({
|
|
29
|
+
subagent_type: "code-reviewer",
|
|
30
|
+
prompt: "Review final. Verificar qualidade, seguranca, patterns. Corrigir issues.",
|
|
31
|
+
description: "Final code review"
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Passo 2: Verificar Testes Pos-Refactoring
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm test 2>&1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Resultado | Acao |
|
|
44
|
+
|-----------|------|
|
|
45
|
+
| Todos passam | Pular para Passo 3 (Final Gate) |
|
|
46
|
+
| Algum falhou | Executar Recovery |
|
|
47
|
+
|
|
48
|
+
### Recovery (SE FAIL)
|
|
49
|
+
|
|
50
|
+
1. Identificar causa
|
|
51
|
+
2. Verificar diff do agent
|
|
52
|
+
3. Decidir: reverter ou corrigir
|
|
53
|
+
4. Re-run
|
|
54
|
+
5. Max 2 tentativas
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Passo 3: Final Gate
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm test && npx tsc --noEmit && npm run build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Self-Healing Loop
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
tentativas = 0
|
|
68
|
+
while (gate falhando AND tentativas < 2):
|
|
69
|
+
1. Identificar erro
|
|
70
|
+
2. Analisar causa
|
|
71
|
+
3. Corrigir
|
|
72
|
+
4. Re-run
|
|
73
|
+
tentativas++
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Gate (BLOQUEANTE)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Testes passam
|
|
82
|
+
npm test || { echo "❌ Testes falhando"; exit 1; }
|
|
83
|
+
|
|
84
|
+
# TypeScript compila
|
|
85
|
+
npx tsc --noEmit || { echo "❌ TypeScript não compila"; exit 1; }
|
|
86
|
+
|
|
87
|
+
# Build funciona
|
|
88
|
+
npm run build || { echo "❌ Build falhou"; exit 1; }
|
|
89
|
+
|
|
90
|
+
echo "✅ Gate 06-quality passou"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Passo 4: Atualizar Estado
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
jq '
|
|
99
|
+
.currentPhase = "07-validation" |
|
|
100
|
+
.completedPhases += ["06-quality"] |
|
|
101
|
+
.resumeHint = "Quality completo. Prox: E2E validation" |
|
|
102
|
+
.lastStep = "Passo 4: Atualizar Estado"
|
|
103
|
+
' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## PROXIMA FASE
|
|
109
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/07-validation.md
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Fase 7: Validation
|
|
2
|
+
|
|
3
|
+
## Responsabilidade
|
|
4
|
+
E2E Validation - verificar que feature funciona no mundo real.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Passo 1: Pre-flight Check (BLOCKING)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# Ler contract path do state
|
|
12
|
+
CONTRACT=$(jq -r '.contract' .claude/workflow-state.json)
|
|
13
|
+
|
|
14
|
+
# Verificar que contract existe e tem E2E spec
|
|
15
|
+
if [ ! -f "$CONTRACT" ]; then
|
|
16
|
+
echo "❌ GATE BLOQUEADO: Contract não encontrado em $CONTRACT"
|
|
17
|
+
echo "Execute fase 03-strategy para criar contract"
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
if ! grep -q "## E2E Validation" "$CONTRACT"; then
|
|
22
|
+
echo "❌ GATE BLOQUEADO: E2E Validation spec não encontrada no contract"
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Passo 2: Carregar Playbooks
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
// Carregar base E2E concepts
|
|
33
|
+
Read("~/.claude/commands/feature/playbooks/_e2e-base.md")
|
|
34
|
+
|
|
35
|
+
// Carregar E2E template especifico do tipo
|
|
36
|
+
Read("~/.claude/commands/feature/playbooks/{featureType}/e2e.md")
|
|
37
|
+
|
|
38
|
+
// Carregar contract com spec
|
|
39
|
+
Read({state.contract}) // path do workflow-state.json
|
|
40
|
+
// Extrair: e2e_type, e2e_spec
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Passo 3: Executar E2E por Tipo
|
|
46
|
+
|
|
47
|
+
### SE auto:
|
|
48
|
+
1. Rodar script/Playwright conforme spec
|
|
49
|
+
```bash
|
|
50
|
+
{comando do spec}
|
|
51
|
+
```
|
|
52
|
+
2. Reportar resultado
|
|
53
|
+
|
|
54
|
+
### SE semi-auto:
|
|
55
|
+
1. Disparar trigger (API call conforme spec)
|
|
56
|
+
2. Poll resultado (max 10x, interval 5s)
|
|
57
|
+
```javascript
|
|
58
|
+
for (let i = 0; i < 10; i++) {
|
|
59
|
+
const result = await checkCondition();
|
|
60
|
+
if (result.success) break;
|
|
61
|
+
await sleep(5000);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
3. Verificar criterio de sucesso
|
|
65
|
+
4. Reportar: "E2E Semi-auto: PASSOU" ou "FALHOU: {motivo}"
|
|
66
|
+
|
|
67
|
+
### SE hybrid:
|
|
68
|
+
1. Solicitar acao do user:
|
|
69
|
+
```javascript
|
|
70
|
+
AskUserQuestion({
|
|
71
|
+
questions: [{
|
|
72
|
+
question: "{acao_do_spec}. Responda quando terminar.",
|
|
73
|
+
header: "Acao Manual",
|
|
74
|
+
options: [
|
|
75
|
+
{ label: "Feito", description: "Executei a acao" },
|
|
76
|
+
{ label: "Nao consigo", description: "Problema ao executar" }
|
|
77
|
+
],
|
|
78
|
+
multiSelect: false
|
|
79
|
+
}]
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
2. User responde "Feito"
|
|
83
|
+
3. Claude executa verificacoes do spec
|
|
84
|
+
4. Reportar: "E2E Hybrid: PASSOU" ou "FALHOU: {motivo}"
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Passo 4: Self-Healing Loop (SE FALHOU)
|
|
89
|
+
|
|
90
|
+
### 4.1 Classificar Falha
|
|
91
|
+
|
|
92
|
+
| Tipo | Exemplos | Acao |
|
|
93
|
+
|------|----------|------|
|
|
94
|
+
| CORRIGIVEL | Bug no código, timeout config, query errada | Corrigir automaticamente |
|
|
95
|
+
| EXTERNO | Rede, serviço offline, credenciais | Reportar e parar |
|
|
96
|
+
|
|
97
|
+
### 4.2 Loop Automatico (max 2 tentativas)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
while (falhando AND tentativas < 2 AND tipo == CORRIGIVEL):
|
|
101
|
+
1. Analisar causa
|
|
102
|
+
2. Corrigir código/config/spec
|
|
103
|
+
3. Re-run E2E
|
|
104
|
+
tentativas++
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4.3 Escape Hatch (SE ainda falha)
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
AskUserQuestion({
|
|
111
|
+
questions: [{
|
|
112
|
+
question: "E2E falhou após self-healing. O que fazer?",
|
|
113
|
+
header: "E2E Failed",
|
|
114
|
+
options: [
|
|
115
|
+
{ label: "Debugar", description: "Executar /debug workflow" },
|
|
116
|
+
{ label: "Continuar", description: "Marcar FAILED e prosseguir" }
|
|
117
|
+
],
|
|
118
|
+
multiSelect: false
|
|
119
|
+
}]
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Passo 5: Atualizar Contract
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Atualizar contract (path do state.contract)
|
|
129
|
+
// Mudar E2E Status: PENDING → PASSED | FAILED
|
|
130
|
+
Edit({
|
|
131
|
+
file_path: {state.contract},
|
|
132
|
+
old_string: "**Status:** PENDING",
|
|
133
|
+
new_string: "**Status:** {PASSED | FAILED}"
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Gate (BLOQUEANTE)
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# E2E deve ter sido executado
|
|
143
|
+
CONTRACT=$(jq -r '.contract' .claude/workflow-state.json)
|
|
144
|
+
if ! grep -q "Status:.*PASSED\|Status:.*FAILED" "$CONTRACT" 2>/dev/null; then
|
|
145
|
+
echo "❌ GATE BLOQUEADO: E2E Validation não executada"
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
echo "✅ Gate 07-validation passou"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Passo 6: Atualizar Estado
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
jq '
|
|
158
|
+
.currentPhase = "08-delivery" |
|
|
159
|
+
.completedPhases += ["07-validation"] |
|
|
160
|
+
.resumeHint = "E2E validado. Prox: commit e push" |
|
|
161
|
+
.lastStep = "Passo 6: Atualizar Estado"
|
|
162
|
+
' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## PROXIMA FASE
|
|
168
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/08-delivery.md
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Fase 8: Delivery
|
|
2
|
+
|
|
3
|
+
## Responsabilidade
|
|
4
|
+
Entregar código validado (commit + push + memory sync).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Passo 1: Verificar Estado
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
git status
|
|
12
|
+
git diff --stat
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Passo 2: Commit
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git add -A
|
|
21
|
+
git commit -m "$(cat <<'EOF'
|
|
22
|
+
{type}: {descricao concisa em ingles}
|
|
23
|
+
|
|
24
|
+
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
25
|
+
EOF
|
|
26
|
+
)"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Tipos:** feat, fix, refactor, docs, test
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Passo 3: Push
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git push
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Passo 4: Memory Sync
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
Task({
|
|
45
|
+
subagent_type: "memory-sync",
|
|
46
|
+
prompt: "Sincronizar knowledge graph. Skip se trivial.",
|
|
47
|
+
description: "Sync memory graph"
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Gate (BLOQUEANTE)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 1. Commit deve existir com formato válido
|
|
57
|
+
git log -1 --format="%s" | grep -qE "^(feat|fix|refactor|test|docs):" || {
|
|
58
|
+
echo "❌ GATE BLOQUEADO: Commit não criado ou formato inválido"
|
|
59
|
+
exit 1
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# 2. Push deve estar feito (branch remota atualizada)
|
|
63
|
+
git status | grep -q "Your branch is up to date\|nothing to commit" || {
|
|
64
|
+
echo "⚠️ AVISO: Mudanças locais não pushadas"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
echo "✅ Gate 08-delivery passou"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Passo 5: Atualizar Estado
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
jq '
|
|
76
|
+
.currentPhase = "09-evaluate" |
|
|
77
|
+
.completedPhases += ["08-delivery"] |
|
|
78
|
+
.resumeHint = "Feature entregue. Prox: auto-avaliacao do workflow" |
|
|
79
|
+
.lastStep = "Passo 5: Atualizar Estado"
|
|
80
|
+
' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## PROXIMA FASE
|
|
86
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/09-evaluate.md
|