TOM
HASTJARJANTO

// SOFTWARE ENGINEER // NETHERLANDS

[ ← RETURN ]

Simple Ralph Wiggum script

TOM HASTJARJANTO · DEVAI-RALPH
#!/usr/bin/env bash
set -uo pipefail

MAX_ITERATIONS=20

cleanup() {
    stty sane 2>/dev/null
}
trap cleanup EXIT

for i in $(seq 1 $MAX_ITERATIONS); do
    echo "[${i}/${MAX_ITERATIONS}]"

    OUTPUT=$(opencode run "implement the first unfinished todo and tick it off when completed, follow the AGENTS.md. Confirm you will follow AGENTS.md. If you have no unfinished todos, say '<SUCCESS>All tasks completed!</SUCCESS>' and exit.") || {
        echo "opencode run failed with exit code $?"
        continue
    }

    if [[ -z "$OUTPUT" ]]; then
        echo "opencode produced no output, retrying..."
        continue
    fi

    echo "$OUTPUT"

    if [[ "$OUTPUT" == *"<SUCCESS>All tasks completed!</SUCCESS>"* ]]; then
        exit 0
    fi
done