chore: Add Ralph installation script and test utility#94
chore: Add Ralph installation script and test utility#94moneypenny-CHI wants to merge 1 commit intosnarktank:mainfrom
Conversation
Greptile OverviewGreptile SummaryAdds a self-contained The core flow is Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant T as test-ralph
participant R as ralph.sh
participant J as jq
participant C as claude CLI
participant A as amp CLI
U->>T: run ./test-ralph
T->>T: check command -v jq
T->>T: check command -v claude
alt missing deps
T-->>U: exit 1
else deps ok
T->>R: invoke ralph.sh
R->>J: read prd.json branchName
R->>R: init progress.txt / archive if branch changed
loop each iteration
alt TOOL == amp
R->>A: amp reads prompt.md
A-->>R: output
else TOOL == claude
R->>C: claude reads CLAUDE.md
C-->>R: output
end
R->>R: check for COMPLETE marker
end
R-->>U: exit 0 if COMPLETE else exit 1
end
|
| fi | ||
|
|
||
| echo "Dependencies verified. Running Ralph..." | ||
| cd ~/ralph-tools && ./ralph.sh --tool claude |
There was a problem hiding this comment.
Broken flag syntax
test-ralph calls ./ralph.sh --tool claude, but ralph.sh treats --tool as requiring the next arg to be the tool name. With the current call, $2 is empty and the script errors with “Invalid tool ''”. Use --tool=claude or ./ralph.sh --tool claude <iters>.
| cd ~/ralph-tools && ./ralph.sh --tool claude | |
| cd ~/ralph-tools && ./ralph.sh --tool=claude |
| shift | ||
| ;; | ||
| *) | ||
| # Assume it's max_iterations if it's a number | ||
| if [[ "$1" =~ ^[0-9]+$ ]]; then | ||
| MAX_ITERATIONS="$1" | ||
| fi |
There was a problem hiding this comment.
Silently ignores args
In the default *) case, non-numeric arguments are ignored (shifted) without error. This means typos like --toool=claude or an accidental positional string will be silently dropped, and the script will run with defaults (e.g., TOOL=amp). That will definitely lead to confusing behavior in real use; unknown flags should error out.
| exit 1 | ||
| fi | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PRD_FILE="$SCRIPT_DIR/prd.json" | ||
| PROGRESS_FILE="$SCRIPT_DIR/progress.txt" |
There was a problem hiding this comment.
Missing jq dependency
ralph.sh uses jq to read .branchName but never checks jq is installed. On machines without jq, the archive/branch tracking logic fails and can reset/overwrite progress.txt incorrectly (because CURRENT_BRANCH becomes empty). Add an explicit command -v jq check alongside the tool check.
| OUTPUT=$(cat "$SCRIPT_DIR/prompt.md" | amp --dangerously-allow-all 2>&1 | tee /dev/stderr) || true | ||
| else | ||
| # Claude Code: use --dangerously-skip-permissions for autonomous operation, --print for output | ||
| OUTPUT=$(claude --dangerously-skip-permissions --print < "$SCRIPT_DIR/CLAUDE.md" 2>&1 | tee /dev/stderr) || true | ||
| fi | ||
|
|
||
| # Check for completion signal |
There was a problem hiding this comment.
Wrong input file
In --tool claude mode, the script feeds CLAUDE.md to claude --print. But CLAUDE.md instructs the agent to read prd.json and progress.txt and take actions; it is not the “prompt” content itself. This will run without providing a user prompt context (unlike the amp path which uses prompt.md), so the claude mode won’t behave as intended. If the intent is to run the same loop prompt, this should read prompt.md (or a dedicated prompt file) and keep CLAUDE.md as repo guidance.
This PR adds the 'ralph.sh' script and a 'test-ralph' utility to simplify installation and verification of the Ralph autonomous coding loop system.\n\nChanges include:\n- Installation of 'ralph.sh' and 'CLAUDE.md' to '~/ralph-tools/'.\n- Creation of a 'test-ralph' script.\n- Verification of 'jq' and 'claude' CLI dependencies.