feat: implement canonical ralph pattern with unlimited and headless modes#4
feat: implement canonical ralph pattern with unlimited and headless modes#4yazan-albaiz merged 5 commits intomasterfrom
Conversation
…odes Align Ralph CLI with the canonical ralph pattern as described by Geoffrey Huntley, where prompts are STATIC and context is fresh each iteration. LLMs perform best without accumulated context noise. Key changes: 1. Remove context injection from prompts - preparePrompt() now only appends completion suffix - No iteration numbers or PROJECT_ROOT injected - Claude reads state from files (progress.txt), not injected context 2. Add --unlimited / -u flag - Run indefinitely until <promise>COMPLETE</promise> - TUI shows "∞" instead of max iteration count - Conflicts with -m (validation added) 3. Add --headless flag - TUI-free execution for AFK/background operation - Structured console logging with timestamps - New src/lib/headlessRunner.ts module - Stops on BLOCKED/DECIDE (no interactive resume) 4. Update documentation - README.md: Add "The Canonical Ralph Workflow" section - CLAUDE.md: Document canonical pattern and new options 5. Update TUI components - Header.tsx: Show ∞ for unlimited mode - IterationPanel.tsx: Hide progress bar in unlimited mode Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ssions) - Remove PROGRESS.md and add to .gitignore - Add --print flag to Claude spawning for non-interactive mode - Document known sub-agent permission limitations - Add throttling to output capture to prevent TUI flashing - Implement auto-commit feature with commit_message tag support - Add git.ts module for git operations - Add --auto-commit/--no-auto-commit CLI flags (default: on) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
@claude review plesae |
|
Claude finished @yazan-albaiz's task in 1m 58s —— View job Code Review CompleteReviewed PR #4: Canonical Ralph Pattern Implementation Review Checklist
SummaryThis is a well-implemented PR that successfully implements the canonical ralph pattern as described by Geoffrey Huntley. The changes are architecturally sound and align with the stated goal of keeping prompts static and context fresh. The code quality is high, with proper error handling, TypeScript types, and comprehensive tests. ✅ Strengths1. Clean Implementation of Canonical PatternThe removal of context injection in
2. Excellent Headless Mode Implementation
3. Consistent Unlimited Mode SupportThe unlimited mode is properly threaded through:
4. Comprehensive DocumentationBoth README.md and CLAUDE.md updated thoroughly:
5. Solid Test CoverageTests updated to match new behavior:
🔍 Issues Found🐛 Bug: Git Auto-commit May Stage Unwanted FilesLocation: The
export function commitChanges(cwd: string, message: string): CommitResult {
try {
// Stage all changes
execSync('git add -A', { cwd, stdio: 'pipe' }); // ⚠️ DangerousRecommendation: Use
|
Required fixes: - Use `git add -u` instead of `git add -A` to prevent committing untracked files (.env, secrets) - Remove redundant staging from generateDefaultCommitMessage(), use unstaged diff instead Optional improvements: - Add debug logging for git errors in generateDefaultCommitMessage() - Document auto-commit feature in CLAUDE.md - Add integration tests for unlimited mode behavior Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
@claude re-review after the lastest changes please. |
|
Claude finished @yazan-albaiz's task in 1m 42s —— View job Re-reviewing PR after latest changesReview Checklist
Changes Since Last ReviewThe commit Required Fixes (✅ All Addressed):
Optional Improvements (✅ All Implemented):
Detailed Review of Changes1. Git Safety Fix (src/lib/git.ts:68-74) ✅/**
* Stage modifications to tracked files and commit
* Uses `git add -u` to avoid accidentally committing untracked files like .env or secrets
*/
export function commitChanges(cwd: string, message: string): CommitResult {
try {
// Stage modifications to tracked files only (safer than -A)
execSync('git add -u', { cwd, stdio: 'pipe' });Excellent! This properly addresses the security concern. The function:
2. Redundant Staging Fix (src/lib/git.ts:98-105) ✅/**
* Generate a default commit message based on current changes
* Called before staging, so uses unstaged diff to analyze changes
*/
export function generateDefaultCommitMessage(cwd: string, iteration: number): string {
try {
// Use unstaged diff since files aren't staged yet when this is called
const diffStat = execSync('git diff --stat', { cwd, encoding: 'utf-8' });Perfect! The redundant staging is removed:
3. Debug Logging (src/lib/git.ts:115-116) ✅ } catch (err) {
logger.debug(`Failed to generate commit message from diff: ${err}`);
}Good addition! This makes debugging easier without polluting user output. 4. Documentation (CLAUDE.md) ✅The added documentation is comprehensive:
This will help future developers understand the design decisions. 5. Integration Tests (tests/integration.test.ts) ✅Two new tests added: Test 1: "simulates unlimited mode - continues until completion signal"
Test 2: "unlimited mode respects completion signal"
Code Quality Assessment✅ Strengths
No New Issues FoundI reviewed the changes thoroughly and found:
Final VerdictStatus: ✅ APPROVED - Ready to Merge All required fixes from the previous review have been addressed correctly, and the optional improvements have been implemented well. The code is secure, well-tested, and properly documented. Summary of What Was Fixed
RecommendationMerge this PR. It successfully implements the canonical ralph pattern with:
The implementation is solid and all review feedback has been addressed. Great work! 🎉 | |
Summary
Align Ralph CLI with the canonical ralph pattern as described by Geoffrey Huntley, where prompts are STATIC and context is fresh each iteration.
Why This Matters
The canonical solution:
Changes
1. Remove Context Injection
preparePrompt()now only appends completion suffixPROJECT_ROOTinjectedprogress.txt), not injected context2. Add
--unlimited/-uFlag<promise>COMPLETE</promise>or user intervention-m(cannot use both)3. Add
--headlessFlagsrc/lib/headlessRunner.tsmodule4. Documentation Updates
progress.txtconvention5. TUI Updates
Files Changed
src/lib/promiseParser.tssrc/lib/headlessRunner.tssrc/cli.tsx-u/--unlimitedand--headlessflagssrc/types/index.tsunlimitedandheadlessto configsrc/hooks/useClaudeLoop.tssrc/components/Header.tsxsrc/components/IterationPanel.tsxsrc/app.tsxtests/promiseParser.test.tstests/integration.test.tsREADME.mdCLAUDE.mdTest Plan
ralph "test" -m 1(basic operation)ralph "test" --unlimited(unlimited mode)ralph "test" --headless -m 2(headless mode)ralph "test" --unlimited -m 5(should error - conflict)Usage Examples
🤖 Generated with Claude Code