fix(ralph-wiggum): stop parsing /ralph-loop prompt text as shell code - #80495
Open
Serhii-Leniv wants to merge 1 commit into
Open
fix(ralph-wiggum): stop parsing /ralph-loop prompt text as shell code#80495Serhii-Leniv wants to merge 1 commit into
Serhii-Leniv wants to merge 1 commit into
Conversation
The /ralph-loop command substituted $ARGUMENTS directly into the auto-executed shell line, so the user's prompt text was parsed as shell code. Any prompt containing an apostrophe (Bob's), a semicolon, $(...), or a newline made the setup command fail its permission check (or fail to parse) before the loop ever started: Error: Shell command permission check failed for pattern ... This Bash command contains multiple operations. With permission checks bypassed, $(...) in a prompt would even execute. Feed $ARGUMENTS to setup-ralph-loop.sh via a quoted heredoc on stdin instead, so prompt text is never shell-parsed, and parse the --max-iterations / --completion-promise options textually in the script. Direct argv invocation still works. The state file format is unchanged, so stop-hook.sh is unaffected. Fixes anthropics#16037
Open
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16037
Problem
/ralph-loopsubstitutes$ARGUMENTSdirectly into the auto-executed shell line inralph-loop.md, so the user's prompt text is parsed as shell code. The loop then fails before it starts for everyday prompts. Reproduced on Claude Code v2.1.218 (Windows, git-bash shell):/ralph-loopFix the bug in Bob's codebash: eval: unexpected EOF while looking for matching 'Fix auth; then add testsShell command permission check failed: Parse errorFix the $(hostname) placeholder bugpermission check failed: Contains command_substitutionThis Bash command contains multiple operations(the original report)The permission check is the only thing standing between
$(...)in a prompt and actual execution — a commenter on #16037 works around the failure with--dangerously-skip-permissions, at which point prompt text can run as code.Fix
commands/ralph-loop.md: feed$ARGUMENTSto the setup script via a quoted heredoc on stdin, so prompt text is never interpreted by the shell. Verified on v2.1.218 that the heredoc form passes theallowed-toolspermission check that the inline form fails.scripts/setup-ralph-loop.sh: read the raw argument text from stdin and parse--max-iterations/--completion-promisetextually (quoted promises still work; quotes are now literal characters). Direct invocation with positional argv still works. Surrounding quotes on the prompt are stripped, matching the README's/ralph-loop "Build X" --completion-promise "DONE"usage.hooks/stop-hook.shneeds no changes. Bumped plugin version 1.0.0 → 1.0.1.Testing
$(...)kept literal, CRLF input, argv fallback,--help, and all error branches.claude -p --plugin-dir:/ralph-wiggum:ralph-loop Say hello then stop; mention Bob's code --max-iterations 1— previously failed pre-model; now the loop starts, runs one iteration, hits the max-iterations limit, and cleans up its state file.This PR was written with the assistance of Claude Code; all changes were reviewed and the tests run by me.