feat: add context placeholders for ralph name, iteration, and max_iterations#25
Closed
malpou wants to merge 3 commits into
Closed
feat: add context placeholders for ralph name, iteration, and max_iterations#25malpou wants to merge 3 commits into
malpou wants to merge 3 commits into
Conversation
… max_iterations
Ralphs can now access runtime metadata via {{ context.name }},
{{ context.iteration }}, and {{ context.max_iterations }} placeholders.
These are resolved alongside existing command and arg placeholders in
a single pass to prevent cross-contamination.
Closes computerlovetech#14
Co-authored-by: Ralphify <noreply@ralphify.co>
…ations Co-authored-by: Ralphify <noreply@ralphify.co>
kasperjunge
reviewed
Mar 24, 2026
Collaborator
kasperjunge
left a comment
There was a problem hiding this comment.
Thanks for this one — clean implementation and great test coverage.
One naming change I'd like before merging: rename context.* to ralph.*. So {{ ralph.name }}, {{ ralph.iteration }}, {{ ralph.max_iterations }}.
Reasoning: in a RALPH.md file, {{ ralph.name }} is immediately self-documenting — "this ralph's name." context is an overloaded term that requires a mental lookup ("context of what?"). ralph.* reads naturally and there's zero ambiguity.
If you update the namespace naming + docs, this is good to merge.
2 tasks
Collaborator
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.
Summary
Closes #14.
{{ context.name }},{{ context.iteration }}, and{{ context.max_iterations }}built-in placeholders so ralphs can access runtime metadata in their promptscontext.nameresolves to the ralph directory name,context.iterationto the 1-based iteration number, andcontext.max_iterationsto the total if-nwas set (empty otherwise)Changes
_frontmatter.py— newFIELD_CONTEXTconstant_resolver.py— extended_ALL_PATTERNregex andresolve_all()to handle thecontextnamespaceengine.py— new_build_context()helper, updated_assemble_prompt()signature to acceptRunStateTest plan
uv run pytest){{ context.iteration }}in the prompt body and verify it resolves to the correct iteration number{{ context.max_iterations }}is empty when-nis not set