@wavilikhin/ralph-wiggum 0.1.15 → 0.1.17
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/README.md +26 -1
- package/package.json +1 -1
- package/templates/ralph-loop.sh +25 -4
package/README.md
CHANGED
|
@@ -3,8 +3,19 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@wavilikhin/ralph-wiggum)
|
|
4
4
|
[](https://github.com/wavilikhin/ralph-wiggum/actions/workflows/publish.yml)
|
|
5
5
|
|
|
6
|
+
```
|
|
7
|
+
____ _ _ __ ___
|
|
8
|
+
| _ \ __ _| |_ __ | |__ \ \ / (_) __ _ _ _ _ _ _ __
|
|
9
|
+
| |_) / _` | | '_ \| '_ \ \ \ /\ / /| |/ _` | | | | | | | '_ \
|
|
10
|
+
| _ < (_| | | |_) | | | | \ V V / | | (_| | |_| | |_| | | | |
|
|
11
|
+
|_| \_\__,_|_| .__/|_| |_| \_/\_/ |_|\__, |\__,_|\__,_|_| |_|
|
|
12
|
+
|_| |___/
|
|
13
|
+
```
|
|
14
|
+
|
|
6
15
|
Ralph Wiggum is a tiny wrapper around the “autonomous loop” pattern: run an AI coding agent repeatedly, but keep each iteration small and strict.
|
|
7
16
|
|
|
17
|
+
Origin: the [Ralph Wiggum autonomous loop](https://ghuntley.com/ralph/) pattern by Geoffrey Huntley.
|
|
18
|
+
|
|
8
19
|
Each iteration:
|
|
9
20
|
- starts with fresh context (new process)
|
|
10
21
|
- completes exactly one plan item
|
|
@@ -53,7 +64,9 @@ The loop stops when either:
|
|
|
53
64
|
|
|
54
65
|
## Flags
|
|
55
66
|
|
|
56
|
-
`ralph-wiggum init` scaffolds files. The loop itself is controlled via `.ralph/run.sh
|
|
67
|
+
`ralph-wiggum init` scaffolds files. The loop itself is controlled via `.ralph/run.sh`.
|
|
68
|
+
|
|
69
|
+
Any additional flags are forwarded to `opencode run`.
|
|
57
70
|
|
|
58
71
|
```bash
|
|
59
72
|
.ralph/run.sh [options]
|
|
@@ -96,6 +109,18 @@ tail -f .ralph/logs/ralph.log
|
|
|
96
109
|
- Enforces one commit per iteration.
|
|
97
110
|
- Requires a clean working tree after each iteration.
|
|
98
111
|
|
|
112
|
+
### Permissions
|
|
113
|
+
|
|
114
|
+
Ralph Wiggum automatically allows `external_directory` permission to prevent OpenCode from blocking the autonomous loop with permission prompts. This setting is merged with your project's `opencode.json` — your other permissions remain intact.
|
|
115
|
+
|
|
116
|
+
If you need full permissive mode (allow all permissions), set the environment variable before running:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
OPENCODE_CONFIG_CONTENT='{"permission":"allow"}' .ralph/run.sh
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
See [OpenCode Permissions](https://opencode.ai/docs/permissions) for details.
|
|
123
|
+
|
|
99
124
|
<details>
|
|
100
125
|
<summary><strong>AI agent appendix (full detail)</strong></summary>
|
|
101
126
|
|
package/package.json
CHANGED
package/templates/ralph-loop.sh
CHANGED
|
@@ -18,6 +18,7 @@ MODEL="${RALPH_MODEL:-anthropic/claude-opus-4-20250514}"
|
|
|
18
18
|
VARIANT=""
|
|
19
19
|
VERBOSE=false
|
|
20
20
|
LIVE=false
|
|
21
|
+
OPENCODE_ARGS=()
|
|
21
22
|
|
|
22
23
|
# All ralph files are in .ralph/
|
|
23
24
|
RALPH_DIR="$SCRIPT_DIR"
|
|
@@ -214,10 +215,19 @@ while [[ $# -gt 0 ]]; do
|
|
|
214
215
|
print_usage
|
|
215
216
|
exit 0
|
|
216
217
|
;;
|
|
218
|
+
--)
|
|
219
|
+
shift
|
|
220
|
+
OPENCODE_ARGS+=("$@")
|
|
221
|
+
break
|
|
222
|
+
;;
|
|
217
223
|
*)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
if [[ $# -ge 2 && "$2" != -* ]]; then
|
|
225
|
+
OPENCODE_ARGS+=("$1" "$2")
|
|
226
|
+
shift 2
|
|
227
|
+
else
|
|
228
|
+
OPENCODE_ARGS+=("$1")
|
|
229
|
+
shift
|
|
230
|
+
fi
|
|
221
231
|
;;
|
|
222
232
|
esac
|
|
223
233
|
done
|
|
@@ -265,12 +275,18 @@ cd "$REPO_ROOT"
|
|
|
265
275
|
for i in $(seq 1 "$MAX_ITERATIONS"); do
|
|
266
276
|
ITER_START=$(date +%s)
|
|
267
277
|
ITER_LOG_FILE="$LOGS_DIR/ralph_iter_${i}.log"
|
|
278
|
+
LIVE_PREFIX=" ${DIM}[LIVE ${i}/${MAX_ITERATIONS}]${NC} "
|
|
268
279
|
|
|
269
280
|
log_iteration_start "$i" "$MAX_ITERATIONS"
|
|
270
281
|
|
|
271
282
|
BEFORE_HEAD=$(git rev-parse HEAD)
|
|
272
283
|
log_info "HEAD before: ${DIM}${BEFORE_HEAD:0:8}${NC}"
|
|
273
284
|
|
|
285
|
+
# Allow external_directory permission to prevent blocking prompts during autonomous execution.
|
|
286
|
+
# This merges with (not replaces) any existing opencode.json permissions in the project.
|
|
287
|
+
# See: https://opencode.ai/docs/permissions
|
|
288
|
+
export OPENCODE_CONFIG_CONTENT='{"permission":{"external_directory":"allow"}}'
|
|
289
|
+
|
|
274
290
|
OPENCODE_CMD=(
|
|
275
291
|
opencode run
|
|
276
292
|
--model "$MODEL"
|
|
@@ -281,6 +297,10 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
|
|
|
281
297
|
if [[ -n "$VARIANT" ]]; then
|
|
282
298
|
OPENCODE_CMD+=(--variant "$VARIANT")
|
|
283
299
|
fi
|
|
300
|
+
|
|
301
|
+
if [[ ${#OPENCODE_ARGS[@]} -gt 0 ]]; then
|
|
302
|
+
OPENCODE_CMD+=("${OPENCODE_ARGS[@]}")
|
|
303
|
+
fi
|
|
284
304
|
|
|
285
305
|
OPENCODE_CMD+=("Follow the attached PROMPT.md. Use AGENTS.md for validation commands and IMPLEMENTATION_PLAN.md for task selection. Do exactly one task and one commit.")
|
|
286
306
|
|
|
@@ -291,7 +311,8 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
|
|
|
291
311
|
set +e
|
|
292
312
|
if [[ "$LIVE" == true ]]; then
|
|
293
313
|
# Stream to terminal AND write to log file
|
|
294
|
-
|
|
314
|
+
# Prefix each opencode line so it doesn't visually clash with ralph logs.
|
|
315
|
+
"${OPENCODE_CMD[@]}" 2>&1 | while IFS= read -r line; do printf '%b%s\n' "$LIVE_PREFIX" "$line"; done | tee "$ITER_LOG_FILE"
|
|
295
316
|
EXIT_CODE=${PIPESTATUS[0]}
|
|
296
317
|
OUTPUT=$(cat "$ITER_LOG_FILE")
|
|
297
318
|
elif [[ "$VERBOSE" == true ]]; then
|