@wavilikhin/ralph-wiggum 0.1.15 → 0.1.16
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 +14 -1
- package/package.json +1 -1
- package/templates/ralph-loop.sh +20 -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]
|
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,6 +275,7 @@ 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
|
|
|
@@ -281,6 +292,10 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
|
|
|
281
292
|
if [[ -n "$VARIANT" ]]; then
|
|
282
293
|
OPENCODE_CMD+=(--variant "$VARIANT")
|
|
283
294
|
fi
|
|
295
|
+
|
|
296
|
+
if [[ ${#OPENCODE_ARGS[@]} -gt 0 ]]; then
|
|
297
|
+
OPENCODE_CMD+=("${OPENCODE_ARGS[@]}")
|
|
298
|
+
fi
|
|
284
299
|
|
|
285
300
|
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
301
|
|
|
@@ -291,7 +306,8 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
|
|
|
291
306
|
set +e
|
|
292
307
|
if [[ "$LIVE" == true ]]; then
|
|
293
308
|
# Stream to terminal AND write to log file
|
|
294
|
-
|
|
309
|
+
# Prefix each opencode line so it doesn't visually clash with ralph logs.
|
|
310
|
+
"${OPENCODE_CMD[@]}" 2>&1 | while IFS= read -r line; do printf '%b%s\n' "$LIVE_PREFIX" "$line"; done | tee "$ITER_LOG_FILE"
|
|
295
311
|
EXIT_CODE=${PIPESTATUS[0]}
|
|
296
312
|
OUTPUT=$(cat "$ITER_LOG_FILE")
|
|
297
313
|
elif [[ "$VERBOSE" == true ]]; then
|