githubgrenade/ralph

Rust 100.0%

Ralph Wiggum

Ralph Wiggum is a loop runner for opencode iterations. It automates running multiple iterations of opencode with configurable timeouts, pre/post commands, and logging.

Installation

cargo build --release

Or install from github:

cargo install --git https://github.com/grenade/ralph

Usage

rw \
    --model ${model} \
    --project-prompt ${project_prompt} \
    --framework-prompt ${framework_prompt} \
    --generic-prompt ${generic_prompt} \
    --project-path ${project_path} \
    --iterations ${iterations} \
    --log-path ${log_path} \
    [OPTIONS]
Options:
  --model <MODEL>                    Model to use for opencode (e.g., "claude-sonnet-4-20250514")
  --project-prompt <PROJECT_PROMPT>  Path to project prompt file
  --framework-prompt <FRAMEWORK_PROMPT>  Path to framework prompt file
  --generic-prompt <GENERIC_PROMPT>   Path to generic prompt file
  --project-path <PROJECT_PATH>      Path to the project directory
  --iterations <ITERATIONS>          Number of iterations to run
  --log-path <LOG_PATH>              Directory to store log files
  --exec-timeout <SECONDS>           Execution timeout in seconds [default: 180]
  --pre-cmd <CMD>                    Command to run before each iteration (e.g., "git checkout .")
  --post-cmd <CMD>                   Command to run after each iteration (e.g., "cargo build")
  -h, --help                         Print help

Example

./target/release/rw \
  --model "claude-sonnet-4-20250514" \
  --project-prompt ~/.rw/prompts/ralph.md \
  --framework-prompt ~/.rw/prompts/rust-2021-cli.md \
  --generic-prompt ~/.rw/prompts/generic.md \
  --project-path ~/git/grenade/ralph \
  --iterations 5 \
  --log-path ~/.rw/logs/ralph \
  --exec-timeout 300 \
  --pre-cmd "git checkout ." \
  --post-cmd "cargo build"

Features

  • Multiple iterations: Run opencode multiple times in a loop
  • Timeout handling: Configurable timeout for each iteration
  • Pre/Post commands: Run shell commands before and after each iteration
  • Logging: All output is logged to separate files for each iteration
  • ANSI stripping: Output is stripped of ANSI escape sequences before logging

Log Output

Logs are saved to <log-path>/<project-name>-iter<N>.log for each iteration.

License

MIT

3 activities