Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/ralph-wiggum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Always use `--max-iterations` as a safety net to prevent infinite loops on impos
# - Suggest alternative approaches"
```

**Note**: The `--completion-promise` uses exact string matching, so you cannot use it for multiple completion conditions (like "SUCCESS" vs "BLOCKED"). Always rely on `--max-iterations` as your primary safety mechanism.
**Note**: The `--completion-promise` uses case-insensitive string matching with whitespace normalization, so `COMPLETE`, `Complete`, and `complete` are all equivalent. However, it does not support multiple completion conditions (like "SUCCESS" vs "BLOCKED"). Always rely on `--max-iterations` as your primary safety mechanism.

## Philosophy

Expand Down
8 changes: 5 additions & 3 deletions plugins/ralph-wiggum/hooks/stop-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ if [[ "$COMPLETION_PROMISE" != "null" ]] && [[ -n "$COMPLETION_PROMISE" ]]; then
# .*? is non-greedy (takes FIRST tag), whitespace normalized
PROMISE_TEXT=$(echo "$LAST_OUTPUT" | perl -0777 -pe 's/.*?<promise>(.*?)<\/promise>.*/$1/s; s/^\s+|\s+$//g; s/\s+/ /g' 2>/dev/null || echo "")

# Use = for literal string comparison (not pattern matching)
# == in [[ ]] does glob pattern matching which breaks with *, ?, [ characters
if [[ -n "$PROMISE_TEXT" ]] && [[ "$PROMISE_TEXT" = "$COMPLETION_PROMISE" ]]; then
# Normalize and lowercase both sides for case-insensitive, whitespace-tolerant matching
# Uses tr for portability (${var,,} requires Bash 4+ but macOS ships Bash 3)
PROMISE_LOWER=$(echo "$PROMISE_TEXT" | tr '[:upper:]' '[:lower:]')
EXPECTED_LOWER=$(echo "$COMPLETION_PROMISE" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s/[[:space:]]\{1,\}/ /g' | tr '[:upper:]' '[:lower:]')
if [[ -n "$PROMISE_TEXT" ]] && [[ "$PROMISE_LOWER" = "$EXPECTED_LOWER" ]]; then
echo "✅ Ralph loop: Detected <promise>$COMPLETION_PROMISE</promise>"
rm "$RALPH_STATE_FILE"
exit 0
Expand Down