@the-bearded-bear/claude-craft 4.0.2 → 4.0.3-next.db8034a
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/Dev/i18n/de/Common/agents/ralph-conductor.md +46 -134
- package/Dev/i18n/de/Common/commands/ralph-run.md +45 -146
- package/Dev/i18n/en/Common/agents/ralph-conductor.md +89 -44
- package/Dev/i18n/en/Common/commands/ralph-run.md +137 -72
- package/Dev/i18n/es/Common/agents/ralph-conductor.md +48 -136
- package/Dev/i18n/es/Common/commands/ralph-run.md +51 -140
- package/Dev/i18n/fr/Common/agents/ralph-conductor.md +83 -133
- package/Dev/i18n/fr/Common/commands/ralph-run.md +131 -106
- package/Dev/i18n/pt/Common/agents/ralph-conductor.md +46 -134
- package/Dev/i18n/pt/Common/commands/ralph-run.md +52 -153
- package/Tools/Ralph/.ralph/hooks/pre-tool-context.sh +100 -0
- package/Tools/Ralph/.ralph/hooks/session-restore.sh +118 -0
- package/Tools/Ralph/.ralph/hooks/status-injector.sh +147 -0
- package/Tools/Ralph/.ralph/hooks/stop-dod-gate.sh +133 -0
- package/Tools/Ralph/README.md +308 -19
- package/Tools/Ralph/lib/circuit-breaker.sh +320 -13
- package/Tools/Ralph/lib/config-generator.sh +561 -0
- package/Tools/Ralph/lib/dashboard.sh +392 -0
- package/Tools/Ralph/lib/dod-templates.sh +335 -0
- package/Tools/Ralph/lib/dod-validator.sh +116 -0
- package/Tools/Ralph/lib/health-monitor.sh +416 -0
- package/Tools/Ralph/lib/hooks-generator.sh +337 -0
- package/Tools/Ralph/lib/metrics-exporter.sh +383 -0
- package/Tools/Ralph/lib/project-detector.sh +562 -0
- package/Tools/Ralph/lib/session.sh +196 -0
- package/Tools/Ralph/ralph.sh +182 -1
- package/Tools/Ralph/templates/dod/dotnet.yml +73 -0
- package/Tools/Ralph/templates/dod/flutter.yml +70 -0
- package/Tools/Ralph/templates/dod/generic.yml +49 -0
- package/Tools/Ralph/templates/dod/go.yml +82 -0
- package/Tools/Ralph/templates/dod/python.yml +73 -0
- package/Tools/Ralph/templates/dod/react.yml +73 -0
- package/Tools/Ralph/templates/dod/rust.yml +73 -0
- package/Tools/Ralph/templates/dod/symfony.yml +73 -0
- package/Tools/Ralph/templates/ralph.yml.template +115 -4
- package/Tools/i18n/ralph/de.sh +49 -0
- package/Tools/i18n/ralph/en.sh +49 -0
- package/Tools/i18n/ralph/es.sh +49 -0
- package/Tools/i18n/ralph/fr.sh +49 -0
- package/Tools/i18n/ralph/pt.sh +49 -0
- package/cli/index.js +11 -1
- package/package.json +1 -1
|
@@ -1,170 +1,69 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Executar Claude em loop continuo ate completar tarefa (Ralph Wiggum)
|
|
3
|
-
argument-hint: <descricao-tarefa> [--auto|--
|
|
2
|
+
description: Executar Claude em loop continuo ate completar a tarefa (Ralph Wiggum v2.0)
|
|
3
|
+
argument-hint: <descricao-tarefa> [--auto-detect|--init|--interactive]
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Ralph Run - Loop Continuo de Agente IA
|
|
6
|
+
# Ralph Run - Loop Continuo de Agente IA v2.0
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Executa Claude em um loop continuo ate que a tarefa esteja completa ou os criterios de Definition of Done (DoD) sejam atendidos.
|
|
9
9
|
|
|
10
10
|
## Argumentos
|
|
11
11
|
|
|
12
12
|
**$ARGUMENTS**
|
|
13
13
|
|
|
14
14
|
- `<descricao-tarefa>`: A tarefa para Claude completar
|
|
15
|
-
- `--auto`:
|
|
16
|
-
- `--
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| Validador | Descricao |
|
|
53
|
-
|-----------|-----------|
|
|
54
|
-
| `command` | Executar comando shell (tests, lint, build) |
|
|
55
|
-
| `output_contains` | Verificar padrao na saida do Claude |
|
|
56
|
-
| `file_changed` | Verificar se arquivos foram modificados |
|
|
57
|
-
| `hook` | Executar hook Claude existente |
|
|
58
|
-
| `human` | Validacao humana interativa |
|
|
59
|
-
|
|
60
|
-
Exemplo DoD em `ralph.yml`:
|
|
61
|
-
|
|
62
|
-
```yaml
|
|
63
|
-
definition_of_done:
|
|
64
|
-
checklist:
|
|
65
|
-
- id: tests
|
|
66
|
-
name: "Todos os testes passam"
|
|
67
|
-
type: command
|
|
68
|
-
command: "docker compose exec app npm test"
|
|
69
|
-
required: true
|
|
70
|
-
|
|
71
|
-
- id: completion
|
|
72
|
-
name: "Claude sinaliza conclusao"
|
|
73
|
-
type: output_contains
|
|
74
|
-
pattern: "<promise>COMPLETE</promise>"
|
|
75
|
-
required: true
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### 4. Disjuntor (Circuit Breaker)
|
|
79
|
-
|
|
80
|
-
Mecanismo de seguranca para prevenir loops infinitos:
|
|
81
|
-
|
|
82
|
-
| Gatilho | Limite | Acao |
|
|
83
|
-
|---------|--------|------|
|
|
84
|
-
| Sem alteracoes de arquivos | 3 iteracoes | Parar |
|
|
85
|
-
| Erros repetidos | 5 iteracoes | Parar |
|
|
86
|
-
| Declinio de saida | 70% | Parar |
|
|
87
|
-
| Max iteracoes | 25 (padrao) | Parar |
|
|
88
|
-
|
|
89
|
-
### 5. Checkpointing
|
|
90
|
-
|
|
91
|
-
Checkpoints Git sao criados apos cada iteracao para:
|
|
92
|
-
- **Recuperacao**: Restaurar estado anterior se necessario
|
|
93
|
-
- **Historico**: Acompanhar progresso atraves das iteracoes
|
|
94
|
-
- **Revisao**: Inspecionar o que mudou em cada passo
|
|
95
|
-
|
|
96
|
-
## Saida
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
╔════════════════════════════════════════════════════════════╗
|
|
100
|
-
║ 🔁 Ralph Wiggum - Loop Continuo de Agente IA ║
|
|
101
|
-
╚════════════════════════════════════════════════════════════╝
|
|
102
|
-
|
|
103
|
-
✓ Sessao criada: ralph-1704067200-a1b2
|
|
104
|
-
|
|
105
|
-
ℹ Iniciando loop Ralph...
|
|
106
|
-
|
|
107
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
108
|
-
Iteracao 1 de 25
|
|
109
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
110
|
-
|
|
111
|
-
ℹ Invocando Claude...
|
|
112
|
-
ℹ Verificando criterios DoD...
|
|
113
|
-
✓ [tests] Todos os testes passam - OK
|
|
114
|
-
✓ [lint] Sem erros lint - OK
|
|
115
|
-
✓ [completion] Claude sinaliza conclusao - OK
|
|
116
|
-
|
|
117
|
-
Todos os criterios obrigatorios aprovados!
|
|
118
|
-
|
|
119
|
-
✓ DoD APROVADO
|
|
120
|
-
|
|
121
|
-
╔════════════════════════════════════════════════════════════╗
|
|
122
|
-
║ 📊 Resumo da Sessao ║
|
|
123
|
-
╚════════════════════════════════════════════════════════════╝
|
|
124
|
-
|
|
125
|
-
ID da sessao: ralph-1704067200-a1b2
|
|
126
|
-
Total de iteracoes: 3
|
|
127
|
-
Duracao: 45s
|
|
128
|
-
Status DoD: APROVADO
|
|
129
|
-
Motivo de saida: dod_complete
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Configuracao
|
|
133
|
-
|
|
134
|
-
Criar `ralph.yml` na raiz do projeto:
|
|
135
|
-
|
|
136
|
-
```yaml
|
|
137
|
-
version: "1.0"
|
|
138
|
-
|
|
139
|
-
session:
|
|
140
|
-
max_iterations: 25
|
|
141
|
-
timeout: 600000
|
|
142
|
-
|
|
143
|
-
circuit_breaker:
|
|
144
|
-
enabled: true
|
|
145
|
-
no_file_changes_threshold: 3
|
|
146
|
-
|
|
147
|
-
definition_of_done:
|
|
148
|
-
checklist:
|
|
149
|
-
- id: tests
|
|
150
|
-
type: command
|
|
151
|
-
command: "npm test"
|
|
152
|
-
required: true
|
|
153
|
-
- id: completion
|
|
154
|
-
type: output_contains
|
|
155
|
-
pattern: "<promise>COMPLETE</promise>"
|
|
156
|
-
required: true
|
|
15
|
+
- `--auto-detect`: Detectar automaticamente o tipo de projeto e configurar DoD
|
|
16
|
+
- `--init`: Gerar configuracao sem executar
|
|
17
|
+
- `--interactive`: Assistente de configuracao interativo
|
|
18
|
+
|
|
19
|
+
## Novas funcionalidades v2.0
|
|
20
|
+
|
|
21
|
+
| Funcionalidade | Descricao |
|
|
22
|
+
|----------------|-----------|
|
|
23
|
+
| **Integracao Hooks** | Integracao bidirecional com Claude Code 2.1.23+ |
|
|
24
|
+
| **Auto-Deteccao** | Deteccao automatica do tipo de projeto |
|
|
25
|
+
| **Dashboard** | Visualizacao em tempo real com barra de progresso |
|
|
26
|
+
| **Export Metricas** | Metricas em formato JSON e Prometheus |
|
|
27
|
+
| **Circuit Breaker Adaptativo** | 5 perfis com aprendizado historico |
|
|
28
|
+
| **Monitor de Saude** | Deteccao de estagnacao, espiral de erros |
|
|
29
|
+
| **Templates DoD** | Templates pre-configurados para 8 tecnologias |
|
|
30
|
+
|
|
31
|
+
## Circuit Breaker Adaptativo (v2.0)
|
|
32
|
+
|
|
33
|
+
| Perfil | Palavras-chave | Sem Mud. | Erros | Max Iter |
|
|
34
|
+
|--------|----------------|----------|-------|----------|
|
|
35
|
+
| `quick_fix` | fix, bug, typo | 2 | 3 | 10 |
|
|
36
|
+
| `small_feature` | add, implement | 3 | 4 | 15 |
|
|
37
|
+
| `medium_feature` | feature, create | 4 | 6 | 25 |
|
|
38
|
+
| `large_feature` | refactor, migrate | 5 | 8 | 50 |
|
|
39
|
+
| `exploration` | explore, investigate | 10 | 15 | 100 |
|
|
40
|
+
|
|
41
|
+
## Exemplos rapidos
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Uso basico
|
|
45
|
+
ralph.sh "Implementar autenticacao de usuario"
|
|
46
|
+
|
|
47
|
+
# Detectar e gerar config
|
|
48
|
+
ralph.sh --auto-detect --init
|
|
49
|
+
|
|
50
|
+
# Assistente interativo
|
|
51
|
+
ralph.sh --interactive
|
|
157
52
|
```
|
|
158
53
|
|
|
159
|
-
##
|
|
54
|
+
## Templates DoD por tecnologia
|
|
160
55
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
56
|
+
| Tecnologia | Comando Teste | Comando Lint |
|
|
57
|
+
|------------|---------------|--------------|
|
|
58
|
+
| Symfony | `vendor/bin/phpunit` | `vendor/bin/phpstan analyse` |
|
|
59
|
+
| Flutter | `flutter test` | `flutter analyze` |
|
|
60
|
+
| React | `npm test` | `npm run lint` |
|
|
61
|
+
| Python | `pytest` | `ruff check .` |
|
|
62
|
+
| .NET | `dotnet test` | `dotnet build /p:TreatWarningsAsErrors=true` |
|
|
63
|
+
| Go | `go test ./...` | `golangci-lint run` |
|
|
64
|
+
| Rust | `cargo test` | `cargo clippy` |
|
|
166
65
|
|
|
167
|
-
##
|
|
66
|
+
## Relacionado
|
|
168
67
|
|
|
169
68
|
- `@ralph-conductor` - Agente para orquestracao Ralph
|
|
170
69
|
- `/common:fix-bug-tdd` - Correcao de bugs com TDD
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Ralph Wiggum - PreToolUse Hook: Context Injector
|
|
4
|
+
# Injects relevant context before specific tool uses
|
|
5
|
+
#
|
|
6
|
+
# Exit codes:
|
|
7
|
+
# 0 - Continue (with optional additionalContext)
|
|
8
|
+
# 1 - Error
|
|
9
|
+
# 2 - Block tool use
|
|
10
|
+
# =============================================================================
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
# Read input from stdin (Claude hook format)
|
|
15
|
+
INPUT=$(cat)
|
|
16
|
+
|
|
17
|
+
# Parse input JSON
|
|
18
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd // "."')
|
|
19
|
+
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // ""')
|
|
20
|
+
TOOL_INPUT=$(echo "$INPUT" | jq -r '.tool_input // "{}"')
|
|
21
|
+
|
|
22
|
+
# Change to project directory
|
|
23
|
+
cd "$CWD" 2>/dev/null || cd "."
|
|
24
|
+
|
|
25
|
+
# =============================================================================
|
|
26
|
+
# Configuration
|
|
27
|
+
# =============================================================================
|
|
28
|
+
|
|
29
|
+
RALPH_SESSION_BASE="${RALPH_SESSION_BASE:-.ralph}"
|
|
30
|
+
|
|
31
|
+
# =============================================================================
|
|
32
|
+
# Tool-Specific Context
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
get_tool_context() {
|
|
36
|
+
local tool="$1"
|
|
37
|
+
local context=""
|
|
38
|
+
|
|
39
|
+
case "$tool" in
|
|
40
|
+
# Bash tool - remind about docker requirement
|
|
41
|
+
Bash)
|
|
42
|
+
# Check CLAUDE.md for docker requirement
|
|
43
|
+
if [[ -f ".claude/CLAUDE.md" ]]; then
|
|
44
|
+
if grep -q "docker" ".claude/CLAUDE.md" 2>/dev/null; then
|
|
45
|
+
context="Reminder: Use docker for commands as per project guidelines"
|
|
46
|
+
fi
|
|
47
|
+
fi
|
|
48
|
+
;;
|
|
49
|
+
|
|
50
|
+
# Write/Edit tools - check for protected files
|
|
51
|
+
Write|Edit)
|
|
52
|
+
local file_path
|
|
53
|
+
file_path=$(echo "$TOOL_INPUT" | jq -r '.file_path // .path // ""')
|
|
54
|
+
if [[ -n "$file_path" ]]; then
|
|
55
|
+
# Check if file is in protected list
|
|
56
|
+
if [[ "$file_path" == *".env"* ]] || [[ "$file_path" == *"secrets"* ]]; then
|
|
57
|
+
context="Warning: Modifying sensitive file. Ensure no secrets are exposed."
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
;;
|
|
61
|
+
|
|
62
|
+
# Task tool - remind about sprint context
|
|
63
|
+
Task)
|
|
64
|
+
local progress_file="$RALPH_SESSION_BASE/sprint-progress.md"
|
|
65
|
+
if [[ -f "$progress_file" ]]; then
|
|
66
|
+
local current_task
|
|
67
|
+
current_task=$(grep -oP '(?<=## Current Task: ).*' "$progress_file" 2>/dev/null | head -1)
|
|
68
|
+
if [[ -n "$current_task" ]]; then
|
|
69
|
+
context="Current sprint task: $current_task"
|
|
70
|
+
fi
|
|
71
|
+
fi
|
|
72
|
+
;;
|
|
73
|
+
|
|
74
|
+
*)
|
|
75
|
+
# No specific context for other tools
|
|
76
|
+
;;
|
|
77
|
+
esac
|
|
78
|
+
|
|
79
|
+
echo "$context"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# =============================================================================
|
|
83
|
+
# Main Logic
|
|
84
|
+
# =============================================================================
|
|
85
|
+
|
|
86
|
+
# Get tool-specific context
|
|
87
|
+
CONTEXT=$(get_tool_context "$TOOL_NAME")
|
|
88
|
+
|
|
89
|
+
# Output JSON response
|
|
90
|
+
if [[ -n "$CONTEXT" ]]; then
|
|
91
|
+
cat <<EOF
|
|
92
|
+
{
|
|
93
|
+
"additionalContext": $(echo "$CONTEXT" | jq -Rs .)
|
|
94
|
+
}
|
|
95
|
+
EOF
|
|
96
|
+
else
|
|
97
|
+
echo '{}'
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
exit 0
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Ralph Wiggum - SessionStart Hook: Session Restore
|
|
4
|
+
# Injects Ralph context when a Claude session starts
|
|
5
|
+
#
|
|
6
|
+
# Exit codes:
|
|
7
|
+
# 0 - Success (with additionalContext)
|
|
8
|
+
# 1 - Error
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
set -e
|
|
12
|
+
|
|
13
|
+
# Read input from stdin (Claude hook format)
|
|
14
|
+
INPUT=$(cat)
|
|
15
|
+
|
|
16
|
+
# Parse input JSON
|
|
17
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd // "."')
|
|
18
|
+
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // ""')
|
|
19
|
+
|
|
20
|
+
# Change to project directory
|
|
21
|
+
cd "$CWD" 2>/dev/null || cd "."
|
|
22
|
+
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# Configuration
|
|
25
|
+
# =============================================================================
|
|
26
|
+
|
|
27
|
+
RALPH_SESSION_BASE="${RALPH_SESSION_BASE:-.ralph}"
|
|
28
|
+
HOOK_CONTEXT_FILE="${RALPH_HOOK_CONTEXT:-}"
|
|
29
|
+
|
|
30
|
+
# =============================================================================
|
|
31
|
+
# Build Context
|
|
32
|
+
# =============================================================================
|
|
33
|
+
|
|
34
|
+
build_session_context() {
|
|
35
|
+
local context=""
|
|
36
|
+
|
|
37
|
+
# Check for Ralph session
|
|
38
|
+
if [[ -f "$HOOK_CONTEXT_FILE" ]]; then
|
|
39
|
+
local phase
|
|
40
|
+
phase=$(jq -r '.phase // "UNKNOWN"' "$HOOK_CONTEXT_FILE" 2>/dev/null)
|
|
41
|
+
local task
|
|
42
|
+
task=$(jq -r '.current_task // ""' "$HOOK_CONTEXT_FILE" 2>/dev/null)
|
|
43
|
+
local ralph_session
|
|
44
|
+
ralph_session=$(jq -r '.session_id // ""' "$HOOK_CONTEXT_FILE" 2>/dev/null)
|
|
45
|
+
|
|
46
|
+
context="Ralph Wiggum Session Active
|
|
47
|
+
- Ralph Session: $ralph_session
|
|
48
|
+
- Phase: $phase
|
|
49
|
+
- Current Task: ${task:-None}"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Check for sprint progress file
|
|
53
|
+
local progress_file="$RALPH_SESSION_BASE/sprint-progress.md"
|
|
54
|
+
if [[ -f "$progress_file" ]]; then
|
|
55
|
+
# Extract key info from progress file
|
|
56
|
+
local completed_count
|
|
57
|
+
completed_count=$(grep -c '^\s*- \[x\]' "$progress_file" 2>/dev/null || echo "0")
|
|
58
|
+
local pending_count
|
|
59
|
+
pending_count=$(grep -c '^\s*- \[ \]' "$progress_file" 2>/dev/null || echo "0")
|
|
60
|
+
|
|
61
|
+
if [[ -n "$context" ]]; then
|
|
62
|
+
context="$context
|
|
63
|
+
- Completed Tasks: $completed_count
|
|
64
|
+
- Pending Tasks: $pending_count"
|
|
65
|
+
else
|
|
66
|
+
context="Sprint Progress:
|
|
67
|
+
- Completed Tasks: $completed_count
|
|
68
|
+
- Pending Tasks: $pending_count"
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Add current phase from progress file
|
|
72
|
+
local current_phase
|
|
73
|
+
current_phase=$(grep -oP '(?<=## Current Phase: ).*' "$progress_file" 2>/dev/null | head -1)
|
|
74
|
+
if [[ -n "$current_phase" ]]; then
|
|
75
|
+
context="$context
|
|
76
|
+
- Sprint Phase: $current_phase"
|
|
77
|
+
fi
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# Check for git status
|
|
81
|
+
if command -v git &>/dev/null && git rev-parse --git-dir &>/dev/null 2>&1; then
|
|
82
|
+
local branch
|
|
83
|
+
branch=$(git branch --show-current 2>/dev/null)
|
|
84
|
+
local changes
|
|
85
|
+
changes=$(git status --porcelain 2>/dev/null | wc -l)
|
|
86
|
+
|
|
87
|
+
if [[ -n "$context" ]]; then
|
|
88
|
+
context="$context
|
|
89
|
+
|
|
90
|
+
Git Status:
|
|
91
|
+
- Branch: ${branch:-detached}
|
|
92
|
+
- Uncommitted changes: $changes"
|
|
93
|
+
fi
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# If no context was built, provide minimal info
|
|
97
|
+
if [[ -z "$context" ]]; then
|
|
98
|
+
context="Ralph Wiggum monitoring active"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
echo "$context"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# =============================================================================
|
|
105
|
+
# Main Logic
|
|
106
|
+
# =============================================================================
|
|
107
|
+
|
|
108
|
+
# Build context
|
|
109
|
+
CONTEXT=$(build_session_context)
|
|
110
|
+
|
|
111
|
+
# Output JSON response
|
|
112
|
+
cat <<EOF
|
|
113
|
+
{
|
|
114
|
+
"additionalContext": $(echo "$CONTEXT" | jq -Rs .)
|
|
115
|
+
}
|
|
116
|
+
EOF
|
|
117
|
+
|
|
118
|
+
exit 0
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Ralph Wiggum - PreToolUse Hook: Status Injector
|
|
4
|
+
# Injects current DoD status before first tool use (once: true)
|
|
5
|
+
#
|
|
6
|
+
# Exit codes:
|
|
7
|
+
# 0 - Continue (with additionalContext)
|
|
8
|
+
# 1 - Error
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
set -e
|
|
12
|
+
|
|
13
|
+
# Read input from stdin (Claude hook format)
|
|
14
|
+
INPUT=$(cat)
|
|
15
|
+
|
|
16
|
+
# Parse input JSON
|
|
17
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd // "."')
|
|
18
|
+
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // ""')
|
|
19
|
+
|
|
20
|
+
# Change to project directory
|
|
21
|
+
cd "$CWD" 2>/dev/null || cd "."
|
|
22
|
+
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# Configuration
|
|
25
|
+
# =============================================================================
|
|
26
|
+
|
|
27
|
+
CONFIG_FILE=""
|
|
28
|
+
for path in "ralph.yml" ".claude/ralph.yml"; do
|
|
29
|
+
if [[ -f "$path" ]]; then
|
|
30
|
+
CONFIG_FILE="$path"
|
|
31
|
+
break
|
|
32
|
+
fi
|
|
33
|
+
done
|
|
34
|
+
|
|
35
|
+
RALPH_SESSION_BASE="${RALPH_SESSION_BASE:-.ralph}"
|
|
36
|
+
|
|
37
|
+
# =============================================================================
|
|
38
|
+
# Get DoD Status
|
|
39
|
+
# =============================================================================
|
|
40
|
+
|
|
41
|
+
get_dod_status() {
|
|
42
|
+
local status=""
|
|
43
|
+
|
|
44
|
+
# If no config, basic status
|
|
45
|
+
if [[ -z "$CONFIG_FILE" || ! -f "$CONFIG_FILE" ]]; then
|
|
46
|
+
echo "DoD: Using simple completion marker (<promise>COMPLETE</promise>)"
|
|
47
|
+
return
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Check if yq is available
|
|
51
|
+
if ! command -v yq &>/dev/null; then
|
|
52
|
+
echo "DoD: Configuration present but yq not available for parsing"
|
|
53
|
+
return
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# Get DoD checklist
|
|
57
|
+
local checklist
|
|
58
|
+
checklist=$(yq e '.definition_of_done.checklist // []' "$CONFIG_FILE" 2>/dev/null)
|
|
59
|
+
|
|
60
|
+
if [[ "$checklist" == "[]" || -z "$checklist" ]]; then
|
|
61
|
+
local marker
|
|
62
|
+
marker=$(yq e '.definition_of_done.completion_marker // "<promise>COMPLETE</promise>"' "$CONFIG_FILE" 2>/dev/null)
|
|
63
|
+
echo "DoD: Using completion marker: $marker"
|
|
64
|
+
return
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Check each item
|
|
68
|
+
status="Definition of Done Status:"
|
|
69
|
+
local count
|
|
70
|
+
count=$(echo "$checklist" | yq e 'length' -)
|
|
71
|
+
|
|
72
|
+
local passed=0
|
|
73
|
+
local failed=0
|
|
74
|
+
local total=0
|
|
75
|
+
|
|
76
|
+
for ((i=0; i<count; i++)); do
|
|
77
|
+
local item
|
|
78
|
+
item=$(yq e ".definition_of_done.checklist[$i]" "$CONFIG_FILE")
|
|
79
|
+
|
|
80
|
+
local id
|
|
81
|
+
id=$(echo "$item" | yq e '.id' -)
|
|
82
|
+
local name
|
|
83
|
+
name=$(echo "$item" | yq e '.name' -)
|
|
84
|
+
local type
|
|
85
|
+
type=$(echo "$item" | yq e '.type' -)
|
|
86
|
+
local required
|
|
87
|
+
required=$(echo "$item" | yq e '.required // true' -)
|
|
88
|
+
|
|
89
|
+
if [[ "$required" != "true" ]]; then
|
|
90
|
+
continue
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
total=$((total + 1))
|
|
94
|
+
|
|
95
|
+
local check_passed=false
|
|
96
|
+
case "$type" in
|
|
97
|
+
command)
|
|
98
|
+
local cmd
|
|
99
|
+
cmd=$(echo "$item" | yq e '.command' -)
|
|
100
|
+
if eval "$cmd" >/dev/null 2>&1; then
|
|
101
|
+
check_passed=true
|
|
102
|
+
fi
|
|
103
|
+
;;
|
|
104
|
+
*)
|
|
105
|
+
# Can't check other types here
|
|
106
|
+
check_passed=true
|
|
107
|
+
;;
|
|
108
|
+
esac
|
|
109
|
+
|
|
110
|
+
if [[ "$check_passed" == "true" ]]; then
|
|
111
|
+
passed=$((passed + 1))
|
|
112
|
+
status="$status
|
|
113
|
+
[PASS] $name"
|
|
114
|
+
else
|
|
115
|
+
failed=$((failed + 1))
|
|
116
|
+
status="$status
|
|
117
|
+
[FAIL] $name"
|
|
118
|
+
fi
|
|
119
|
+
done
|
|
120
|
+
|
|
121
|
+
status="$status
|
|
122
|
+
|
|
123
|
+
Summary: $passed/$total required checks passing"
|
|
124
|
+
|
|
125
|
+
if [[ $failed -gt 0 ]]; then
|
|
126
|
+
status="$status
|
|
127
|
+
IMPORTANT: Fix failing checks before completing the task."
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
echo "$status"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# =============================================================================
|
|
134
|
+
# Main Logic
|
|
135
|
+
# =============================================================================
|
|
136
|
+
|
|
137
|
+
# Get DoD status
|
|
138
|
+
DOD_STATUS=$(get_dod_status)
|
|
139
|
+
|
|
140
|
+
# Output JSON response
|
|
141
|
+
cat <<EOF
|
|
142
|
+
{
|
|
143
|
+
"additionalContext": $(echo "$DOD_STATUS" | jq -Rs .)
|
|
144
|
+
}
|
|
145
|
+
EOF
|
|
146
|
+
|
|
147
|
+
exit 0
|