Repository navigation
Conversation
…atter Both hooks read the frontmatter with a sed range that reopens at every --- line, and the stop hook rebuilt the prompt by dropping every --- line. A prompt with Markdown rules lost those lines on every iteration, and a frontmatter-like block quoted in the body (iteration: not a number) made the stop hook declare the state file corrupted and delete it. Read the frontmatter as the block up to the first closing --- only, feed the body back verbatim, and rewrite iteration: inside the frontmatter alone.
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.
Problem
Both hooks read the frontmatter of
.cursor/ralph/scratchpad.mdwithsed -n '/^---$/,/^---$/...'. A sed range reopens at every later---, so a Markdown rule in the prompt body starts a second "frontmatter" block. The stop hook also rebuilt the prompt withawk '/^---$/{i++; next} i>=2', which drops every---line, and bumped the counter withsed "s/^iteration: .*/..."over the whole file.With a prompt that contains rules (a pasted spec with
---separators is the common case):---line disappears from the followup on each iteration;--- name: x ... ---", or any body line beginning withiteration:after a rule) leaks into the parsed frontmatter;iterationthen reads as1\n<body line>, fails the numeric check, and the stop hook reports "state file corrupted" and deletes the loop.Fix
---on line 1 and the first closing---(awkwith anexitat the first close), in both hooks.---, verbatim.iteration:rewrite is limited to the frontmatter.Tests
ralph-loop/tests/body-separators.test.sh(standalone bash, same shape as the tests in #1000): a body with two rules and aniteration:phrase, then a body with a quoted frontmatter block. Against the hooks onmain3 of 12 checks fail (both rules lost; quoted block stops the loop and deletes the state file); 12/12 with this branch, on macOS (BSD awk) and indebian:bookworm-slim(mawk 1.3.4).node scripts/validate-plugins.mjspasses.Merges cleanly onto
main(git merge-tree). It touches lines adjacent to #1000 (dependency guards and missing-key handling), so the two conflict textually; whichever lands second gets rebased, the logic is independent.