refactor(naming): remove @ prefix from on-disk filenames (#131)

* refactor(naming): remove @ prefix from on-disk filenames

BREAKING CHANGE: Renames @fix_plan.md → fix_plan.md and @AGENT.md → AGENT.md

This change improves POSIX compliance and compatibility with command-line tools.
The @ prefix was originally used to avoid naming conflicts, but with the .ralph/
folder structure introduced in v0.10.0, this convention is no longer necessary.

Changes:
- Update all scripts to use new naming (fix_plan.md, AGENT.md)
- Update migration script to handle both old and new naming conventions
- Update templates to use new naming
- Update all documentation references
- Update all 420 tests to expect new naming (TDD approach)

Migration:
- Existing projects with @-prefixed files will be automatically renamed
  when running ralph-migrate
- Projects already using the new naming will continue to work unchanged

* docs(claude): update file naming conventions section

* fix(migrate): prevent orphaned @-prefixed files during migration

When both root/@fix_plan.md and .ralph/@fix_plan.md exist, the root file
now takes priority and the .ralph/@fix_plan.md is removed (backup exists).
This prevents orphaned legacy files after migration.

---------

Co-authored-by: Test User <test@example.com>
This commit is contained in:
Frank Bria 2026-01-26 15:40:27 -07:00 committed by GitHub
parent 05c57207f3
commit c7e7a1c6a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 288 additions and 236 deletions

View file

@ -188,8 +188,8 @@ bats tests/unit/test_ralph_enable.bats
The loop is controlled by several key files and environment variables within the `.ralph/` subfolder:
- **.ralph/PROMPT.md** - Main prompt file that drives each loop iteration
- **.ralph/@fix_plan.md** - Prioritized task list that Ralph follows
- **.ralph/@AGENT.md** - Build and run instructions maintained by Ralph
- **.ralph/fix_plan.md** - Prioritized task list that Ralph follows
- **.ralph/AGENT.md** - Build and run instructions maintained by Ralph
- **.ralph/status.json** - Real-time status tracking (JSON format)
- **.ralph/logs/** - Execution logs for each loop iteration
@ -218,7 +218,7 @@ CLAUDE_MIN_VERSION="2.0.76" # Minimum Claude CLI version
**Loop Context:**
Each loop iteration injects context via `build_loop_context()`:
- Current loop number
- Remaining tasks from @fix_plan.md
- Remaining tasks from fix_plan.md
- Circuit breaker state (if not CLOSED)
- Previous loop work summary
@ -239,7 +239,7 @@ The `EXIT_SIGNAL` value is read from `.ralph/.response_analysis` (at `.analysis.
**Other exit conditions (checked before completion indicators):**
- Multiple consecutive "done" signals from Claude Code (`done_signals >= 2`)
- Too many test-only loops indicating feature completeness (`test_loops >= 3`)
- All items in .ralph/@fix_plan.md marked as completed
- All items in .ralph/fix_plan.md marked as completed
**Example behavior when EXIT_SIGNAL is false:**
```
@ -284,8 +284,8 @@ Each project created with `./setup.sh` follows this structure with a `.ralph/` s
project-name/
├── .ralph/ # Ralph configuration and state (hidden folder)
│ ├── PROMPT.md # Main development instructions
│ ├── @fix_plan.md # Prioritized TODO list
│ ├── @AGENT.md # Build/run instructions
│ ├── fix_plan.md # Prioritized TODO list
│ ├── AGENT.md # Build/run instructions
│ ├── specs/ # Project specifications
│ ├── examples/ # Usage examples
│ ├── logs/ # Loop execution logs
@ -304,7 +304,7 @@ Templates in `templates/` provide starting points for new projects:
## File Naming Conventions
- Files prefixed with `@` (e.g., `.ralph/@fix_plan.md`) are Ralph-specific control files
- Ralph control files (`fix_plan.md`, `AGENT.md`, `PROMPT.md`) reside in the `.ralph/` directory
- Hidden files within `.ralph/` (e.g., `.ralph/.call_count`, `.ralph/.exit_signals`) track loop state
- `.ralph/logs/` contains timestamped execution logs
- `.ralph/docs/generated/` for Ralph-created documentation
@ -345,7 +345,7 @@ Ralph uses multiple mechanisms to detect when to exit:
- `MAX_CONSECUTIVE_TEST_LOOPS=3` - Exit if too many test-only iterations
- `MAX_CONSECUTIVE_DONE_SIGNALS=2` - Exit on repeated completion signals
- `TEST_PERCENTAGE_THRESHOLD=30%` - Flag if testing dominates recent loops
- Completion detection via .ralph/@fix_plan.md checklist items
- Completion detection via .ralph/fix_plan.md checklist items
### Completion Indicators with EXIT_SIGNAL Gate
@ -542,7 +542,7 @@ bats tests/unit/test_cli_parsing.bats
- Added 22 comprehensive tests for `ralph_import.sh` PRD conversion script
- Tests cover: file format support (.md, .txt, .json), output file creation, project naming
- Mock infrastructure for `ralph-setup` and Claude Code CLI isolation
- Output file validation: PROMPT.md, @fix_plan.md, specs/requirements.md creation
- Output file validation: PROMPT.md, fix_plan.md, specs/requirements.md creation
- Project naming tests: custom names, auto-detection from filename, path handling
- Error handling tests: missing source file, missing ralph-setup, conversion failures
- Help and usage tests: --help flag, no arguments behavior
@ -554,7 +554,7 @@ bats tests/unit/test_cli_parsing.bats
### Project Setup Tests (v0.9.4)
- Added 36 comprehensive tests for `setup.sh` project initialization script
- Tests cover: directory creation, subdirectory structure, template copying, git initialization
- Template copying verification for PROMPT.md, @fix_plan.md, @AGENT.md
- Template copying verification for PROMPT.md, fix_plan.md, AGENT.md
- Git repository validation: .git exists, valid repo, initial commit, correct message
- README.md creation and content verification
- Custom and default project name handling
@ -683,8 +683,8 @@ Before moving to the next feature, ALL changes must be:
- Create pull requests for all significant changes
4. **Ralph Integration**:
- Update .ralph/@fix_plan.md with new tasks before starting work
- Mark items complete in .ralph/@fix_plan.md upon completion
- Update .ralph/fix_plan.md with new tasks before starting work
- Mark items complete in .ralph/fix_plan.md upon completion
- Update .ralph/PROMPT.md if Ralph's behavior needs modification
- Test Ralph loop with new features before completion
@ -712,7 +712,7 @@ Before moving to the next feature, ALL changes must be:
4. **Template Maintenance**:
- Update template files when new patterns are introduced
- Keep PROMPT.md template current with best practices
- Update @AGENT.md template with new build patterns
- Update AGENT.md template with new build patterns
- Document new Ralph configuration options
5. **CLAUDE.md Maintenance**:
@ -730,7 +730,7 @@ Before marking ANY feature as complete, verify:
- [ ] All changes committed with conventional commit messages
- [ ] All commits pushed to remote repository
- [ ] CI/CD pipeline passes
- [ ] .ralph/@fix_plan.md task marked as complete
- [ ] .ralph/fix_plan.md task marked as complete
- [ ] Implementation documentation updated
- [ ] Inline code comments updated or added
- [ ] CLAUDE.md updated (if new patterns introduced)
@ -743,7 +743,7 @@ Before marking ANY feature as complete, verify:
These standards ensure:
- **Quality**: Thorough testing prevents regressions in Ralph's autonomous behavior
- **Traceability**: Git commits and @fix_plan.md provide clear history of changes
- **Traceability**: Git commits and fix_plan.md provide clear history of changes
- **Maintainability**: Current documentation reduces onboarding time and prevents knowledge loss
- **Collaboration**: Pushed changes enable team visibility and code review
- **Reliability**: Consistent quality gates maintain Ralph loop stability

View file

@ -231,7 +231,7 @@ fi
| Local variables | snake_case | `local loop_count=0` |
| Constants | UPPER_SNAKE_CASE | `MAX_CALLS_PER_HOUR` |
| File names | snake_case.sh | `circuit_breaker.sh` |
| Control files | @prefix | `@fix_plan.md` |
| Control files | snake_case.md | `fix_plan.md`, `AGENT.md` |
**Function Documentation:**
@ -401,7 +401,7 @@ assert_file_exists # Verify file exists
assert_dir_exists # Verify directory exists
strip_colors # Remove ANSI color codes
create_mock_prompt # Create test PROMPT.md
create_mock_fix_plan # Create test @fix_plan.md
create_mock_fix_plan # Create test fix_plan.md
create_mock_status # Create test status.json
```

View file

@ -53,7 +53,7 @@ Ralph is an implementation of the Geoffrey Huntley's technique for Claude Code t
- Higher threshold than normal (2) to avoid false positives while preventing API waste
- Fixed checkbox parsing for indented markdown (Bug #3):
- Changed patterns from `^- \[` to `^[[:space:]]*- \[` (POSIX-compliant)
- Supports indented checkboxes in `@fix_plan.md`
- Supports indented checkboxes in `fix_plan.md`
- Updated README.md documentation example for new log path
**v0.10.0 - .ralph/ Subfolder Structure (BREAKING CHANGE)**
@ -193,7 +193,7 @@ cd my-project
# Review and adjust the generated files:
# - .ralph/PROMPT.md (Ralph instructions)
# - .ralph/@fix_plan.md (task priorities)
# - .ralph/fix_plan.md (task priorities)
# - .ralph/specs/requirements.md (technical specs)
# Start autonomous development
@ -209,7 +209,7 @@ cd my-awesome-project
# Configure your project requirements manually
# Edit .ralph/PROMPT.md with your project goals
# Edit .ralph/specs/ with detailed specifications
# Edit .ralph/@fix_plan.md with initial priorities
# Edit .ralph/fix_plan.md with initial priorities
# Start autonomous development
ralph --monitor
@ -272,7 +272,7 @@ Loop 8: Claude outputs "All tasks complete, project ready"
```
**Other exit conditions:**
- All tasks in `.ralph/@fix_plan.md` marked complete
- All tasks in `.ralph/fix_plan.md` marked complete
- Multiple consecutive "done" signals from Claude Code
- Too many test-focused loops (indicating feature completeness)
- Claude API 5-hour usage limit reached (with user prompt to wait or exit)
@ -310,7 +310,7 @@ ralph-import design-doc.pdf
Ralph-import creates a complete project with:
- **.ralph/PROMPT.md** - Converted into Ralph development instructions
- **.ralph/@fix_plan.md** - Requirements broken down into prioritized tasks
- **.ralph/fix_plan.md** - Requirements broken down into prioritized tasks
- **.ralph/specs/requirements.md** - Technical specifications extracted from your document
- **Standard Ralph structure** - All necessary directories and template files in `.ralph/`
@ -457,8 +457,8 @@ Ralph creates a standardized structure for each project with a `.ralph/` subfold
my-project/
├── .ralph/ # Ralph configuration and state (hidden folder)
│ ├── PROMPT.md # Main development instructions for Ralph
│ ├── @fix_plan.md # Prioritized task list (@ prefix = Ralph control file)
│ ├── @AGENT.md # Build and run instructions
│ ├── fix_plan.md # Prioritized task list (@ prefix = Ralph control file)
│ ├── AGENT.md # Build and run instructions
│ ├── specs/ # Project specifications and requirements
│ │ └── stdlib/ # Standard library specifications
│ ├── examples/ # Usage examples and test cases
@ -474,15 +474,15 @@ my-project/
### Writing Effective Prompts
1. **Be Specific** - Clear requirements lead to better results
2. **Prioritize** - Use `.ralph/@fix_plan.md` to guide Ralph's focus
2. **Prioritize** - Use `.ralph/fix_plan.md` to guide Ralph's focus
3. **Set Boundaries** - Define what's in/out of scope
4. **Include Examples** - Show expected inputs/outputs
### Project Specifications
- Place detailed requirements in `.ralph/specs/`
- Use `.ralph/@fix_plan.md` for prioritized task tracking
- Keep `.ralph/@AGENT.md` updated with build instructions
- Use `.ralph/fix_plan.md` for prioritized task tracking
- Keep `.ralph/AGENT.md` updated with build instructions
- Document key decisions and architecture
### Monitoring Progress
@ -607,7 +607,7 @@ tail -f .ralph/logs/ralph.log
- **Rate Limits** - Ralph automatically waits and displays countdown
- **5-Hour API Limit** - Ralph detects and prompts for user action (wait or exit)
- **Stuck Loops** - Check `@fix_plan.md` for unclear or conflicting tasks
- **Stuck Loops** - Check `fix_plan.md` for unclear or conflicting tasks
- **Early Exit** - Review exit thresholds if Ralph stops too soon
- **Premature Exit** - Check if Claude is setting `EXIT_SIGNAL: false` (Ralph now respects this)
- **Execution Timeouts** - Increase `--timeout` value for complex operations

View file

@ -429,7 +429,7 @@ $EXIT_SIGNALS_FILE # ".exit_signals"
# Mock data creation
create_mock_prompt # Create sample PROMPT.md
create_mock_fix_plan 5 2 # Create @fix_plan.md (5 total, 2 completed)
create_mock_fix_plan 5 2 # Create fix_plan.md (5 total, 2 completed)
create_mock_status 1 42 100 # Create status.json (loop 1, 42 calls, 100 max)
create_mock_exit_signals 0 2 0 # Create exit signals (0 test, 2 done, 0 complete)
```
@ -513,12 +513,12 @@ create_sample_prd_json "output.json" # JSON PRD
```bash
# Create sample Ralph project files
create_sample_prompt "PROMPT.md"
create_sample_fix_plan "@fix_plan.md" 10 3 # 10 tasks, 3 completed
create_sample_agent_md "@AGENT.md"
create_sample_fix_plan "fix_plan.md" 10 3 # 10 tasks, 3 completed
create_sample_agent_md "AGENT.md"
# Create complete project structure
create_test_project "project-name"
# Creates: PROMPT.md, @fix_plan.md, @AGENT.md, specs/, src/, logs/, etc.
# Creates: PROMPT.md, fix_plan.md, AGENT.md, specs/, src/, logs/, etc.
```
#### Output Fixtures

View file

@ -205,9 +205,9 @@ should_exit_gracefully() {
# 4. Check fix_plan.md for completion
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
if [[ -f "$RALPH_DIR/@fix_plan.md" ]]; then
local total_items=$(grep -cE "^[[:space:]]*- \[" "$RALPH_DIR/@fix_plan.md" 2>/dev/null || echo "0")
local completed_items=$(grep -cE "^[[:space:]]*- \[x\]" "$RALPH_DIR/@fix_plan.md" 2>/dev/null || echo "0")
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local total_items=$(grep -cE "^[[:space:]]*- \[" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local completed_items=$(grep -cE "^[[:space:]]*- \[x\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
log_status "WARN" "Exit condition: All fix_plan.md items completed ($completed_items/$total_items)"
@ -506,8 +506,8 @@ mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
# Copy templates to .ralph/
cp ../templates/PROMPT.md .ralph/
cp ../templates/fix_plan.md .ralph/@fix_plan.md
cp ../templates/AGENT.md .ralph/@AGENT.md
cp ../templates/fix_plan.md .ralph/fix_plan.md
cp ../templates/AGENT.md .ralph/AGENT.md
cp -r ../templates/specs/* .ralph/specs/ 2>/dev/null || true
# Initialize git
@ -535,18 +535,18 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
## Current Objectives
1. Study .ralph/specs/* to learn about the project specifications
2. Review .ralph/@fix_plan.md for current priorities
2. Review .ralph/fix_plan.md for current priorities
3. Implement the highest priority item using best practices
4. Use parallel subagents for complex tasks (max 100 concurrent)
5. Run tests after each implementation
6. Update documentation and .ralph/@fix_plan.md
6. Update documentation and .ralph/fix_plan.md
## Key Principles
- ONE task per loop - focus on the most important thing
- Search the codebase before assuming something isn't implemented
- Use subagents for expensive operations (file searching, analysis)
- Write comprehensive tests with clear documentation
- Update .ralph/@fix_plan.md with your learnings
- Update .ralph/fix_plan.md with your learnings
- Commit working changes with descriptive messages
## 🧪 Testing Guidelines (CRITICAL)
@ -561,13 +561,13 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
- Before making changes: search codebase using subagents
- After implementation: run ESSENTIAL tests for the modified code only
- If tests fail: fix them as part of your current work
- Keep @AGENT.md updated with build/run instructions
- Keep AGENT.md updated with build/run instructions
- Document the WHY behind tests and implementations
- No placeholder implementations - build it properly
## Completion Awareness
If you believe the project is complete or nearly complete:
- Update .ralph/@fix_plan.md to reflect completion status
- Update .ralph/fix_plan.md to reflect completion status
- Summarize what has been accomplished
- Note any remaining minor tasks
- Do NOT continue with busy work like extensive testing
@ -577,11 +577,11 @@ If you believe the project is complete or nearly complete:
- .ralph/specs/: Project specifications and requirements
- src/: Source code implementation
- .ralph/examples/: Example usage and test cases
- .ralph/@fix_plan.md: Prioritized TODO list
- .ralph/@AGENT.md: Project build and run instructions
- .ralph/fix_plan.md: Prioritized TODO list
- .ralph/AGENT.md: Project build and run instructions
## Current Task
Follow .ralph/@fix_plan.md and choose the most important item to implement next.
Follow .ralph/fix_plan.md and choose the most important item to implement next.
Use your judgment to prioritize what will have the biggest impact on project progress.
Remember: Quality over speed. Build it right the first time. Know when you're done.

View file

@ -88,7 +88,7 @@ Loop 1-10: Normal (CLOSED state, progress detected)
Loop 11-13: No file changes detected (transition to HALF-OPEN)
Loop 14: Still no progress (transition to OPEN, halt execution)
Output: "⚠️ Circuit breaker opened: No progress detected in 4 loops.
Last file change: loop #10. Please review @fix_plan.md."
Last file change: loop #10. Please review fix_plan.md."
RECOMMENDATION:
Implement Circuit Breaker with these triggers:
@ -173,7 +173,7 @@ IMPACT: Makes Ralph's outputs parseable and actionable
From PROMPT.md lines 38-45:
"If you believe the project is complete or nearly complete:
- Update @fix_plan.md to reflect completion status"
- Update fix_plan.md to reflect completion status"
This requirement violates SMART criteria:
- Specific: ❌ "believe" is subjective
@ -183,10 +183,10 @@ This requirement violates SMART criteria:
- Timely: ❌ No timeframe
Better requirement:
"When all tasks in @fix_plan.md are marked [x] AND no errors are present
"When all tasks in fix_plan.md are marked [x] AND no errors are present
in the last test run AND you have nothing left to implement from specs/:
- Output: EXIT_SIGNAL=true
- Update @fix_plan.md with completion summary
- Update fix_plan.md with completion summary
- List any deferred items in ## Deferred section"
This is:
@ -232,7 +232,7 @@ Current state: Abstract instructions
Required state: Concrete examples
Example 1: Successful Completion
Given: All @fix_plan.md items are checked [x]
Given: All fix_plan.md items are checked [x]
And: Last test run shows 100% passing
And: No errors in logs/
When: Claude evaluates project status
@ -334,7 +334,7 @@ Extensions (Error Handling):
2. Ralph exits with "no_progress" signal
RECOMMENDATION:
Document use cases in @AGENT.md or new USE_CASES.md file.
Document use cases in AGENT.md or new USE_CASES.md file.
Define all actors, goals, success criteria, and failure modes.
This provides design clarity and testing scenarios.

View file

@ -106,7 +106,7 @@ RECOMMENDATION: <one line summary>
**Clear Exit Criteria**:
Claude sets `EXIT_SIGNAL: true` only when ALL conditions met:
1. All @fix_plan.md items marked [x]
1. All fix_plan.md items marked [x]
2. All tests passing (or no tests needed)
3. No errors/warnings in last execution
4. All specs/ requirements implemented

View file

@ -30,7 +30,7 @@ Successfully implemented all Phase 2 recommendations from the expert panel revie
Six concrete scenarios using Given/When/Then format:
**Scenario 1: Successful Project Completion**
- **Given**: All @fix_plan.md items marked [x], tests passing, no errors
- **Given**: All fix_plan.md items marked [x], tests passing, no errors
- **Then**: OUTPUT EXIT_SIGNAL=true with COMPLETE status
- **Ralph's Action**: Gracefully exits loop with success message
@ -87,7 +87,7 @@ Six concrete scenarios using Given/When/Then format:
#### Six Primary Use Cases
**UC-1: Execute Development Loop** (Main workflow)
- **Preconditions**: PROMPT.md exists, @fix_plan.md has tasks
- **Preconditions**: PROMPT.md exists, fix_plan.md has tasks
- **Success**: Task completed, files modified/committed, status tracked
- **14-step main scenario** with extensions for:
- Circuit breaker OPEN → halt with guidance

View file

@ -23,7 +23,7 @@
### ✅ 75 Tests (100% Pass)
1. **Unit Tests** (35 tests)
- **Rate Limiting** (15 tests): can_make_call(), increment_call_counter(), edge cases
- **Exit Detection** (20 tests): test saturation, done signals, completion indicators, @fix_plan.md validation, error handling
- **Exit Detection** (20 tests): test saturation, done signals, completion indicators, fix_plan.md validation, error handling
2. **Integration Tests** (40 tests)
- **Loop Execution** (20 tests): response analyzer detection, circuit breaker states, full loop integration, exit signal detection

View file

@ -32,7 +32,7 @@
- `tests/helpers/fixtures.bash` - Test data fixtures
- Sample PRD documents (MD, JSON)
- Sample PROMPT.md, @fix_plan.md, @AGENT.md
- Sample PROMPT.md, fix_plan.md, AGENT.md
- Sample status.json and progress.json
- Sample Claude Code outputs
- Complete test project creation
@ -83,7 +83,7 @@ Test Categories:
- Threshold boundaries (1, 2 indicators)
- Project completion detection
- @fix_plan.md completion (5 tests)
- fix_plan.md completion (5 tests)
- All items complete
- Partial completion
- Missing file

View file

@ -32,7 +32,7 @@
- Cannot modify project requirements
- Must respect API rate limits
- Cannot override circuit breaker when open
- Requires valid PROMPT.md and @fix_plan.md
- Requires valid PROMPT.md and fix_plan.md
---
@ -58,7 +58,7 @@
**Type**: Human
**Goal**: Initiate Ralph, review results, intervene when needed
**Capabilities**:
- Create PROMPT.md and @fix_plan.md
- Create PROMPT.md and fix_plan.md
- Start/stop Ralph execution
- Reset circuit breaker
- Review code changes
@ -89,7 +89,7 @@
**Stakeholders**: Human Developer (wants progress), Claude Code (executor)
**Preconditions**:
- PROMPT.md exists and is valid
- @fix_plan.md exists with at least one task
- fix_plan.md exists with at least one task
- Claude Code CLI is installed and accessible
- git repository is initialized
@ -105,7 +105,7 @@
2. Ralph checks circuit breaker state (must be CLOSED or HALF_OPEN)
3. Ralph verifies rate limit allows execution
4. Ralph executes Claude Code with PROMPT.md
5. Claude Code reads @fix_plan.md and selects task
5. Claude Code reads fix_plan.md and selects task
6. Claude Code implements task (files modified)
7. Claude Code runs relevant tests
8. Claude Code outputs RALPH_STATUS block
@ -400,7 +400,7 @@
**Main Success Scenario**:
1. User identifies circuit breaker opened (from ralph-monitor or logs)
2. User reviews logs/ralph.log to understand cause
3. User fixes underlying issue (updates @fix_plan.md, fixes error, etc.)
3. User fixes underlying issue (updates fix_plan.md, fixes error, etc.)
4. User runs: `ralph --reset-circuit`
5. Ralph loads circuit_breaker.sh functions
6. Ralph calls reset_circuit_breaker("Manual reset by user")

View file

@ -47,7 +47,7 @@ fi
```
**Attack Vector**:
If `@fix_plan.md` or `.response_analysis` contains malicious content like:
If `fix_plan.md` or `.response_analysis` contains malicious content like:
```
"; rm -rf /; echo "
```

View file

@ -262,8 +262,8 @@ mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
# Copy templates from Ralph home to .ralph/ subfolder
cp "$RALPH_HOME/templates/PROMPT.md" .ralph/
cp "$RALPH_HOME/templates/fix_plan.md" .ralph/@fix_plan.md
cp "$RALPH_HOME/templates/AGENT.md" .ralph/@AGENT.md
cp "$RALPH_HOME/templates/fix_plan.md" .ralph/fix_plan.md
cp "$RALPH_HOME/templates/AGENT.md" .ralph/AGENT.md
cp -r "$RALPH_HOME/templates/specs/"* .ralph/specs/ 2>/dev/null || true
# Initialize git

View file

@ -303,7 +303,7 @@ should_halt_execution() {
echo -e "${YELLOW}Ralph has detected that no progress is being made.${NC}"
echo ""
echo -e "${YELLOW}Possible reasons:${NC}"
echo " • Project may be complete (check .ralph/@fix_plan.md)"
echo " • Project may be complete (check .ralph/fix_plan.md)"
echo " • Claude may be stuck on an error"
echo " • .ralph/PROMPT.md may need clarification"
echo " • Manual intervention may be required"
@ -311,7 +311,7 @@ should_halt_execution() {
echo -e "${YELLOW}To continue:${NC}"
echo " 1. Review recent logs: tail -20 .ralph/logs/ralph.log"
echo " 2. Check Claude output: ls -lt .ralph/logs/claude_output_*.log | head -1"
echo " 3. Update .ralph/@fix_plan.md if needed"
echo " 3. Update .ralph/fix_plan.md if needed"
echo " 4. Reset circuit breaker: ralph --reset-circuit"
echo ""
return 0 # Signal to halt

View file

@ -83,8 +83,8 @@ check_existing_ralph() {
# Check for required files
local required_files=(
".ralph/PROMPT.md"
".ralph/@fix_plan.md"
".ralph/@AGENT.md"
".ralph/fix_plan.md"
".ralph/AGENT.md"
)
local missing=()
@ -508,7 +508,7 @@ generate_prompt_md() {
objectives_section="$objectives"
else
objectives_section="- Review the codebase and understand the current state
- Follow tasks in @fix_plan.md
- Follow tasks in fix_plan.md
- Implement one task per loop
- Write tests for new functionality
- Update documentation as needed"
@ -530,7 +530,7 @@ ${objectives_section}
- ONE task per loop - focus on the most important thing
- Search the codebase before assuming something isn't implemented
- Write comprehensive tests with clear documentation
- Update @fix_plan.md with your learnings
- Update fix_plan.md with your learnings
- Commit working changes with descriptive messages
## Testing Guidelines
@ -539,7 +539,7 @@ ${objectives_section}
- Only write tests for NEW functionality you implement
## Build & Run
See @AGENT.md for build and run instructions.
See AGENT.md for build and run instructions.
## Status Reporting (CRITICAL)
@ -558,11 +558,11 @@ RECOMMENDATION: <one line summary of what to do next>
\`\`\`
## Current Task
Follow @fix_plan.md and choose the most important item to implement next.
Follow fix_plan.md and choose the most important item to implement next.
PROMPTEOF
}
# generate_agent_md - Generate @AGENT.md with detected build commands
# generate_agent_md - Generate AGENT.md with detected build commands
#
# Parameters:
# $1 (build_cmd) - Build command
@ -607,7 +607,7 @@ ${run_cmd}
AGENTEOF
}
# generate_fix_plan_md - Generate @fix_plan.md with imported tasks
# generate_fix_plan_md - Generate fix_plan.md with imported tasks
#
# Parameters:
# $1 (tasks) - Tasks to include (newline-separated, markdown checkbox format)
@ -771,11 +771,11 @@ enable_ralph_in_directory() {
local agent_content
agent_content=$(generate_agent_md "$DETECTED_BUILD_CMD" "$DETECTED_TEST_CMD" "$DETECTED_RUN_CMD")
safe_create_file ".ralph/@AGENT.md" "$agent_content"
safe_create_file ".ralph/AGENT.md" "$agent_content"
local fix_plan_content
fix_plan_content=$(generate_fix_plan_md "$task_content")
safe_create_file ".ralph/@fix_plan.md" "$fix_plan_content"
safe_create_file ".ralph/fix_plan.md" "$fix_plan_content"
# Detect task sources for .ralphrc
detect_task_sources

View file

@ -1,12 +1,14 @@
#!/bin/bash
# Migration script for Ralph projects from flat structure to .ralph/ subfolder
# Version: 1.0.0
# Version: 2.0.0
#
# This script migrates existing Ralph projects from the old flat structure:
# PROMPT.md, @fix_plan.md, @AGENT.md, specs/, logs/, docs/generated/
# To the new .ralph/ subfolder structure:
# .ralph/PROMPT.md, .ralph/@fix_plan.md, .ralph/@AGENT.md, .ralph/specs/, etc.
# PROMPT.md, @fix_plan.md (or fix_plan.md), @AGENT.md (or AGENT.md), specs/, logs/, docs/generated/
# To the new .ralph/ subfolder structure with POSIX-compliant naming:
# .ralph/PROMPT.md, .ralph/fix_plan.md, .ralph/AGENT.md, .ralph/specs/, etc.
#
# Also renames legacy @-prefixed files to remove the @ prefix.
#
# Usage: ./migrate_to_ralph_folder.sh [project-directory]
#
@ -41,9 +43,10 @@ is_already_migrated() {
local project_dir=$1
# Check if .ralph/ directory exists with key files
# Accept both new naming (fix_plan.md) and legacy naming (@fix_plan.md)
if [[ -d "$project_dir/.ralph" ]] && \
[[ -f "$project_dir/.ralph/PROMPT.md" ]] && \
[[ -f "$project_dir/.ralph/@fix_plan.md" ]]; then
{ [[ -f "$project_dir/.ralph/fix_plan.md" ]] || [[ -f "$project_dir/.ralph/@fix_plan.md" ]]; }; then
return 0 # Already migrated
fi
return 1 # Not migrated
@ -54,11 +57,16 @@ needs_migration() {
local project_dir=$1
# Check for old-style structure (files in root)
# Also check for legacy @-prefixed files (both root and .ralph/)
if [[ -f "$project_dir/PROMPT.md" ]] || \
[[ -f "$project_dir/@fix_plan.md" ]] || \
[[ -f "$project_dir/fix_plan.md" ]] || \
[[ -f "$project_dir/@AGENT.md" ]] || \
[[ -f "$project_dir/AGENT.md" ]] || \
[[ -d "$project_dir/specs" && ! -d "$project_dir/.ralph/specs" ]] || \
[[ -d "$project_dir/logs" && ! -d "$project_dir/.ralph/logs" ]]; then
[[ -d "$project_dir/logs" && ! -d "$project_dir/.ralph/logs" ]] || \
[[ -f "$project_dir/.ralph/@fix_plan.md" ]] || \
[[ -f "$project_dir/.ralph/@AGENT.md" ]]; then
return 0 # Needs migration
fi
return 1 # Doesn't need migration
@ -80,10 +88,15 @@ create_backup() {
log "INFO" "Creating backup at $backup_dir" >&2
mkdir -p "$backup_dir"
# Backup files that will be moved
# Backup files that will be moved (both old @ naming and new naming)
[[ -f "$project_dir/PROMPT.md" ]] && cp "$project_dir/PROMPT.md" "$backup_dir/"
[[ -f "$project_dir/@fix_plan.md" ]] && cp "$project_dir/@fix_plan.md" "$backup_dir/"
[[ -f "$project_dir/fix_plan.md" ]] && cp "$project_dir/fix_plan.md" "$backup_dir/"
[[ -f "$project_dir/@AGENT.md" ]] && cp "$project_dir/@AGENT.md" "$backup_dir/"
[[ -f "$project_dir/AGENT.md" ]] && cp "$project_dir/AGENT.md" "$backup_dir/"
# Also backup legacy @-prefixed files in .ralph/ if they exist
[[ -f "$project_dir/.ralph/@fix_plan.md" ]] && cp "$project_dir/.ralph/@fix_plan.md" "$backup_dir/"
[[ -f "$project_dir/.ralph/@AGENT.md" ]] && cp "$project_dir/.ralph/@AGENT.md" "$backup_dir/"
[[ -d "$project_dir/specs" ]] && cp -r "$project_dir/specs" "$backup_dir/"
[[ -d "$project_dir/logs" ]] && cp -r "$project_dir/logs" "$backup_dir/"
[[ -d "$project_dir/docs/generated" ]] && cp -r "$project_dir/docs/generated" "$backup_dir/docs_generated"
@ -121,14 +134,49 @@ migrate_project() {
mv "$project_dir/PROMPT.md" "$project_dir/.ralph/PROMPT.md"
fi
# Handle fix_plan.md - check for both old (@-prefixed) and new naming
# Priority: root file wins over .ralph/ file (root is more likely to be current)
if [[ -f "$project_dir/@fix_plan.md" ]]; then
log "INFO" "Moving @fix_plan.md to .ralph/"
mv "$project_dir/@fix_plan.md" "$project_dir/.ralph/@fix_plan.md"
log "INFO" "Moving @fix_plan.md to .ralph/fix_plan.md (renaming to remove @ prefix)"
# Remove any existing .ralph/@fix_plan.md to avoid orphaned files
if [[ -f "$project_dir/.ralph/@fix_plan.md" ]]; then
log "WARN" "Removing .ralph/@fix_plan.md (superseded by root @fix_plan.md, backup available)"
rm "$project_dir/.ralph/@fix_plan.md"
fi
mv "$project_dir/@fix_plan.md" "$project_dir/.ralph/fix_plan.md"
elif [[ -f "$project_dir/fix_plan.md" ]]; then
log "INFO" "Moving fix_plan.md to .ralph/"
if [[ -f "$project_dir/.ralph/@fix_plan.md" ]]; then
log "WARN" "Removing .ralph/@fix_plan.md (superseded by root fix_plan.md, backup available)"
rm "$project_dir/.ralph/@fix_plan.md"
fi
mv "$project_dir/fix_plan.md" "$project_dir/.ralph/fix_plan.md"
elif [[ -f "$project_dir/.ralph/@fix_plan.md" ]]; then
# No root file, just rename the legacy .ralph/ file
log "INFO" "Renaming .ralph/@fix_plan.md to .ralph/fix_plan.md"
mv "$project_dir/.ralph/@fix_plan.md" "$project_dir/.ralph/fix_plan.md"
fi
# Handle AGENT.md - check for both old (@-prefixed) and new naming
# Priority: root file wins over .ralph/ file (root is more likely to be current)
if [[ -f "$project_dir/@AGENT.md" ]]; then
log "INFO" "Moving @AGENT.md to .ralph/"
mv "$project_dir/@AGENT.md" "$project_dir/.ralph/@AGENT.md"
log "INFO" "Moving @AGENT.md to .ralph/AGENT.md (renaming to remove @ prefix)"
if [[ -f "$project_dir/.ralph/@AGENT.md" ]]; then
log "WARN" "Removing .ralph/@AGENT.md (superseded by root @AGENT.md, backup available)"
rm "$project_dir/.ralph/@AGENT.md"
fi
mv "$project_dir/@AGENT.md" "$project_dir/.ralph/AGENT.md"
elif [[ -f "$project_dir/AGENT.md" ]]; then
log "INFO" "Moving AGENT.md to .ralph/"
if [[ -f "$project_dir/.ralph/@AGENT.md" ]]; then
log "WARN" "Removing .ralph/@AGENT.md (superseded by root AGENT.md, backup available)"
rm "$project_dir/.ralph/@AGENT.md"
fi
mv "$project_dir/AGENT.md" "$project_dir/.ralph/AGENT.md"
elif [[ -f "$project_dir/.ralph/@AGENT.md" ]]; then
# No root file, just rename the legacy .ralph/ file
log "INFO" "Renaming .ralph/@AGENT.md to .ralph/AGENT.md"
mv "$project_dir/.ralph/@AGENT.md" "$project_dir/.ralph/AGENT.md"
fi
# Move specs directory contents (fail-safe: preserve dotfiles, verify copy before delete)
@ -242,7 +290,7 @@ main() {
# Check if needs migration
if ! needs_migration "$project_dir"; then
log "WARN" "No Ralph project files found. Nothing to migrate."
log "INFO" "Expected files: PROMPT.md, @fix_plan.md, @AGENT.md, specs/, logs/"
log "INFO" "Expected files: PROMPT.md, fix_plan.md (or @fix_plan.md), AGENT.md (or @AGENT.md), specs/, logs/"
exit 0
fi
@ -281,11 +329,14 @@ Description:
new .ralph/ subfolder structure. This change keeps source code clean by moving
Ralph-specific files into a dedicated subfolder.
It also renames legacy @-prefixed files (@fix_plan.md, @AGENT.md) to the new
POSIX-compliant naming convention (fix_plan.md, AGENT.md).
Old structure:
project/
├── PROMPT.md
├── @fix_plan.md
├── @AGENT.md
├── @fix_plan.md (or fix_plan.md)
├── @AGENT.md (or AGENT.md)
├── specs/
├── logs/
└── src/
@ -294,8 +345,8 @@ Description:
project/
├── .ralph/
│ ├── PROMPT.md
│ ├── @fix_plan.md
│ ├── @AGENT.md
│ ├── fix_plan.md
│ ├── AGENT.md
│ ├── specs/
│ ├── logs/
│ └── docs/generated/
@ -305,6 +356,7 @@ Features:
- Automatically detects if migration is needed
- Creates backup before migration
- Moves all Ralph-specific files and state
- Renames @-prefixed files to POSIX-compliant names
- Preserves src/ at project root
Examples:

View file

@ -94,7 +94,7 @@ What this command does:
2. Identifies available task sources (beads, GitHub, PRDs)
3. Imports tasks from selected sources
4. Creates .ralph/ configuration directory
5. Generates PROMPT.md, @fix_plan.md, @AGENT.md
5. Generates PROMPT.md, fix_plan.md, AGENT.md
6. Creates .ralphrc for project-specific settings
This command is:
@ -483,17 +483,17 @@ phase_verification() {
all_good=false
fi
if [[ -f ".ralph/@fix_plan.md" ]]; then
print_success ".ralph/@fix_plan.md"
if [[ -f ".ralph/fix_plan.md" ]]; then
print_success ".ralph/fix_plan.md"
else
print_error ".ralph/@fix_plan.md - MISSING"
print_error ".ralph/fix_plan.md - MISSING"
all_good=false
fi
if [[ -f ".ralph/@AGENT.md" ]]; then
print_success ".ralph/@AGENT.md"
if [[ -f ".ralph/AGENT.md" ]]; then
print_success ".ralph/AGENT.md"
else
print_error ".ralph/@AGENT.md - MISSING"
print_error ".ralph/AGENT.md - MISSING"
all_good=false
fi
@ -519,8 +519,8 @@ phase_verification() {
echo "Next steps:"
echo ""
print_bullet "Review and customize .ralph/PROMPT.md" "1."
print_bullet "Edit tasks in .ralph/@fix_plan.md" "2."
print_bullet "Update build commands in .ralph/@AGENT.md" "3."
print_bullet "Edit tasks in .ralph/fix_plan.md" "2."
print_bullet "Update build commands in .ralph/AGENT.md" "3."
print_bullet "Start Ralph: ralph --monitor" "4."
echo ""

View file

@ -384,12 +384,12 @@ main() {
# Track created files
[[ -f ".ralph/PROMPT.md" ]] && CREATED_FILES+=(".ralph/PROMPT.md")
[[ -f ".ralph/@fix_plan.md" ]] && CREATED_FILES+=(".ralph/@fix_plan.md")
[[ -f ".ralph/@AGENT.md" ]] && CREATED_FILES+=(".ralph/@AGENT.md")
[[ -f ".ralph/fix_plan.md" ]] && CREATED_FILES+=(".ralph/fix_plan.md")
[[ -f ".ralph/AGENT.md" ]] && CREATED_FILES+=(".ralph/AGENT.md")
[[ -f ".ralphrc" ]] && CREATED_FILES+=(".ralphrc")
# Verify required files exist
if [[ ! -f ".ralph/PROMPT.md" ]] || [[ ! -f ".ralph/@fix_plan.md" ]]; then
if [[ ! -f ".ralph/PROMPT.md" ]] || [[ ! -f ".ralph/fix_plan.md" ]]; then
output_error "Required files were not created"
exit $ENABLE_ERROR
fi

View file

@ -261,7 +261,7 @@ The command will:
1. Create a new Ralph project
2. Use Claude Code to intelligently convert your PRD into:
- .ralph/PROMPT.md (Ralph instructions)
- .ralph/@fix_plan.md (prioritized tasks)
- .ralph/fix_plan.md (prioritized tasks)
- .ralph/specs/ (technical specifications)
HELPEOF
@ -330,7 +330,7 @@ You are Ralph, an autonomous AI development agent working on a [PROJECT NAME] pr
- Search the codebase before assuming something isn't implemented
- Use subagents for expensive operations (file searching, analysis)
- Write comprehensive tests with clear documentation
- Update @fix_plan.md with your learnings
- Update fix_plan.md with your learnings
- Commit working changes with descriptive messages
## 🧪 Testing Guidelines (CRITICAL)
@ -350,10 +350,10 @@ You are Ralph, an autonomous AI development agent working on a [PROJECT NAME] pr
[Define what "done" looks like based on the PRD]
## Current Task
Follow @fix_plan.md and choose the most important item to implement next.
Follow fix_plan.md and choose the most important item to implement next.
```
### 2. .ralph/@fix_plan.md
### 2. .ralph/fix_plan.md
Convert requirements into a prioritized task list:
```markdown
# Ralph Fix Plan
@ -396,7 +396,7 @@ Create detailed technical specifications:
2. Create the three files above with content derived from the PRD
3. Ensure all requirements are captured and properly prioritized
4. Make the PROMPT.md actionable for autonomous development
5. Structure @fix_plan.md with clear, implementable tasks
5. Structure fix_plan.md with clear, implementable tasks
PROMPTEOF
@ -505,7 +505,7 @@ PROMPTEOF
# Use PARSED_FILES_CREATED from JSON if available, otherwise check filesystem
local missing_files=()
local created_files=()
local expected_files=(".ralph/PROMPT.md" ".ralph/@fix_plan.md" ".ralph/specs/requirements.md")
local expected_files=(".ralph/PROMPT.md" ".ralph/fix_plan.md" ".ralph/specs/requirements.md")
# If JSON provided files_created, use that to inform verification
if [[ "$json_parsed" == "true" && -n "$PARSED_FILES_CREATED" && "$PARSED_FILES_CREATED" != "[]" ]]; then
@ -606,7 +606,7 @@ main() {
echo "Next steps:"
echo " 1. Review and edit the generated files:"
echo " - .ralph/PROMPT.md (Ralph instructions)"
echo " - .ralph/@fix_plan.md (task priorities)"
echo " - .ralph/fix_plan.md (task priorities)"
echo " - .ralph/specs/requirements.md (technical specs)"
echo " 2. Start autonomous development:"
echo " ralph --monitor"

View file

@ -413,15 +413,15 @@ should_exit_gracefully() {
# 5. Check fix_plan.md for completion
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
if [[ -f "$RALPH_DIR/@fix_plan.md" ]]; then
local total_items=$(grep -cE "^[[:space:]]*- \[" "$RALPH_DIR/@fix_plan.md" 2>/dev/null)
local completed_items=$(grep -cE "^[[:space:]]*- \[x\]" "$RALPH_DIR/@fix_plan.md" 2>/dev/null)
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local total_items=$(grep -cE "^[[:space:]]*- \[" "$RALPH_DIR/fix_plan.md" 2>/dev/null)
local completed_items=$(grep -cE "^[[:space:]]*- \[x\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null)
# Handle case where grep returns no matches (exit code 1)
[[ -z "$total_items" ]] && total_items=0
[[ -z "$completed_items" ]] && completed_items=0
log_status "INFO" "DEBUG: .ralph/@fix_plan.md check - total_items:$total_items, completed_items:$completed_items" >&2
log_status "INFO" "DEBUG: .ralph/fix_plan.md check - total_items:$total_items, completed_items:$completed_items" >&2
if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
log_status "WARN" "Exit condition: All fix_plan.md items completed ($completed_items/$total_items)" >&2
@ -429,7 +429,7 @@ should_exit_gracefully() {
return 0
fi
else
log_status "INFO" "DEBUG: .ralph/@fix_plan.md file not found" >&2
log_status "INFO" "DEBUG: .ralph/fix_plan.md file not found" >&2
fi
log_status "INFO" "DEBUG: No exit conditions met, continuing loop" >&2
@ -526,10 +526,10 @@ build_loop_context() {
# Add loop number
context="Loop #${loop_count}. "
# Extract incomplete tasks from @fix_plan.md
# Extract incomplete tasks from fix_plan.md
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
if [[ -f "$RALPH_DIR/@fix_plan.md" ]]; then
local incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/@fix_plan.md" 2>/dev/null || echo "0")
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
context+="Remaining tasks: ${incomplete_tasks}. "
fi
@ -1155,7 +1155,7 @@ main() {
echo ""
# Check if this looks like a partial Ralph project
if [[ -f "$RALPH_DIR/@fix_plan.md" ]] || [[ -d "$RALPH_DIR/specs" ]] || [[ -f "$RALPH_DIR/@AGENT.md" ]]; then
if [[ -f "$RALPH_DIR/fix_plan.md" ]] || [[ -d "$RALPH_DIR/specs" ]] || [[ -f "$RALPH_DIR/AGENT.md" ]]; then
echo "This appears to be a Ralph project but is missing .ralph/PROMPT.md."
echo "You may need to create or restore the PROMPT.md file."
else
@ -1170,7 +1170,7 @@ main() {
echo " 4. Navigate to an existing Ralph project directory"
echo " 5. Or create .ralph/PROMPT.md manually in this directory"
echo ""
echo "Ralph projects should contain: .ralph/PROMPT.md, .ralph/@fix_plan.md, .ralph/specs/, src/, etc."
echo "Ralph projects should contain: .ralph/PROMPT.md, .ralph/fix_plan.md, .ralph/specs/, src/, etc."
exit 1
fi

View file

@ -40,8 +40,8 @@ mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
# Copy templates to .ralph/
cp "$TEMPLATES_DIR/PROMPT.md" .ralph/
cp "$TEMPLATES_DIR/fix_plan.md" .ralph/@fix_plan.md
cp "$TEMPLATES_DIR/AGENT.md" .ralph/@AGENT.md
cp "$TEMPLATES_DIR/fix_plan.md" .ralph/fix_plan.md
cp "$TEMPLATES_DIR/AGENT.md" .ralph/AGENT.md
cp -r "$TEMPLATES_DIR/specs"/* .ralph/specs/ 2>/dev/null || true
# Initialize git

View file

@ -94,8 +94,8 @@ Before moving to the next feature, ALL changes must be:
- Create pull requests for all significant changes
4. **Ralph Integration**:
- Update .ralph/@fix_plan.md with new tasks before starting work
- Mark items complete in .ralph/@fix_plan.md upon completion
- Update .ralph/fix_plan.md with new tasks before starting work
- Mark items complete in .ralph/fix_plan.md upon completion
- Update .ralph/PROMPT.md if development patterns change
- Test features work within Ralph's autonomous loop
@ -137,10 +137,10 @@ Before marking ANY feature as complete, verify:
- [ ] Type checking passes (if applicable)
- [ ] All changes committed with conventional commit messages
- [ ] All commits pushed to remote repository
- [ ] .ralph/@fix_plan.md task marked as complete
- [ ] .ralph/fix_plan.md task marked as complete
- [ ] Implementation documentation updated
- [ ] Inline code comments updated or added
- [ ] .ralph/@AGENT.md updated (if new patterns introduced)
- [ ] .ralph/AGENT.md updated (if new patterns introduced)
- [ ] Breaking changes documented
- [ ] Features tested within Ralph loop (if applicable)
- [ ] CI/CD pipeline passes
@ -149,7 +149,7 @@ Before marking ANY feature as complete, verify:
These standards ensure:
- **Quality**: High test coverage and pass rates prevent regressions
- **Traceability**: Git commits and .ralph/@fix_plan.md provide clear history of changes
- **Traceability**: Git commits and .ralph/fix_plan.md provide clear history of changes
- **Maintainability**: Current documentation reduces onboarding time and prevents knowledge loss
- **Collaboration**: Pushed changes enable team visibility and code review
- **Reliability**: Consistent quality gates maintain production stability

View file

@ -5,7 +5,7 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
## Current Objectives
1. Study .ralph/specs/* to learn about the project specifications
2. Review .ralph/@fix_plan.md for current priorities
2. Review .ralph/fix_plan.md for current priorities
3. Implement the highest priority item using best practices
4. Use parallel subagents for complex tasks (max 100 concurrent)
5. Run tests after each implementation
@ -16,7 +16,7 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
- Search the codebase before assuming something isn't implemented
- Use subagents for expensive operations (file searching, analysis)
- Write comprehensive tests with clear documentation
- Update .ralph/@fix_plan.md with your learnings
- Update .ralph/fix_plan.md with your learnings
- Commit working changes with descriptive messages
## 🧪 Testing Guidelines (CRITICAL)
@ -31,7 +31,7 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
- Before making changes: search codebase using subagents
- After implementation: run ESSENTIAL tests for the modified code only
- If tests fail: fix them as part of your current work
- Keep .ralph/@AGENT.md updated with build/run instructions
- Keep .ralph/AGENT.md updated with build/run instructions
- Document the WHY behind tests and implementations
- No placeholder implementations - build it properly
@ -54,7 +54,7 @@ RECOMMENDATION: <one line summary of what to do next>
### When to set EXIT_SIGNAL: true
Set EXIT_SIGNAL to **true** when ALL of these conditions are met:
1. ✅ All items in @fix_plan.md are marked [x]
1. ✅ All items in fix_plan.md are marked [x]
2. ✅ All tests are passing (or no tests exist for valid reasons)
3. ✅ No errors or warnings in the last execution
4. ✅ All requirements from specs/ are implemented
@ -71,7 +71,7 @@ FILES_MODIFIED: 5
TESTS_STATUS: PASSING
WORK_TYPE: IMPLEMENTATION
EXIT_SIGNAL: false
RECOMMENDATION: Continue with next priority task from @fix_plan.md
RECOMMENDATION: Continue with next priority task from fix_plan.md
---END_RALPH_STATUS---
```
@ -115,7 +115,7 @@ Each scenario shows the exact conditions and expected behavior.
### Scenario 1: Successful Project Completion
**Given**:
- All items in .ralph/@fix_plan.md are marked [x]
- All items in .ralph/fix_plan.md are marked [x]
- Last test run shows all tests passing
- No errors in recent logs/
- All requirements from .ralph/specs/ are implemented
@ -192,7 +192,7 @@ RECOMMENDATION: Stuck on [error description] - human intervention needed
### Scenario 4: No Work Remaining
**Given**:
- All tasks in @fix_plan.md are complete
- All tasks in fix_plan.md are complete
- You analyze .ralph/specs/ and find nothing new to implement
- Code quality is acceptable
- Tests are passing
@ -218,7 +218,7 @@ RECOMMENDATION: No remaining work, all .ralph/specs implemented
### Scenario 5: Making Progress
**Given**:
- Tasks remain in .ralph/@fix_plan.md
- Tasks remain in .ralph/fix_plan.md
- Implementation is underway
- Files are being modified
- Tests are passing or being fixed
@ -234,7 +234,7 @@ FILES_MODIFIED: 7
TESTS_STATUS: PASSING
WORK_TYPE: IMPLEMENTATION
EXIT_SIGNAL: false
RECOMMENDATION: Continue with next task from .ralph/@fix_plan.md
RECOMMENDATION: Continue with next task from .ralph/fix_plan.md
---END_RALPH_STATUS---
```
@ -270,8 +270,8 @@ RECOMMENDATION: Blocked on [specific dependency] - need [what's needed]
## File Structure
- .ralph/: Ralph-specific configuration and documentation
- specs/: Project specifications and requirements
- @fix_plan.md: Prioritized TODO list
- @AGENT.md: Project build and run instructions
- fix_plan.md: Prioritized TODO list
- AGENT.md: Project build and run instructions
- PROMPT.md: This file - Ralph development instructions
- logs/: Loop execution logs
- docs/generated/: Auto-generated documentation
@ -279,7 +279,7 @@ RECOMMENDATION: Blocked on [specific dependency] - need [what's needed]
- examples/: Example usage and test cases
## Current Task
Follow .ralph/@fix_plan.md and choose the most important item to implement next.
Follow .ralph/fix_plan.md and choose the most important item to implement next.
Use your judgment to prioritize what will have the biggest impact on project progress.
Remember: Quality over speed. Build it right the first time. Know when you're done.

View file

@ -123,7 +123,7 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
## Current Objectives
1. Study specs/* to learn about the project specifications
2. Review @fix_plan.md for current priorities
2. Review fix_plan.md for current priorities
3. Implement the highest priority item using best practices
4. Use parallel subagents for complex tasks (max 100 concurrent)
5. Run tests after each implementation
@ -134,7 +134,7 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
- Search the codebase before assuming something isn't implemented
- Use subagents for expensive operations (file searching, analysis)
- Write comprehensive tests with clear documentation
- Update @fix_plan.md with your learnings
- Update fix_plan.md with your learnings
- Commit working changes with descriptive messages
## 🧪 Testing Guidelines (CRITICAL)
@ -145,13 +145,13 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
- Focus on CORE functionality first, comprehensive testing later
## Current Task
Follow @fix_plan.md and choose the most important item to implement next.
Follow fix_plan.md and choose the most important item to implement next.
EOF
}
# Sample @fix_plan.md
# Sample fix_plan.md
create_sample_fix_plan() {
local file=${1:-"@fix_plan.md"}
local file=${1:-"fix_plan.md"}
local total=${2:-10}
local completed=${3:-3}
@ -203,9 +203,9 @@ EOF
EOF
}
# Sample @AGENT.md
# Sample AGENT.md
create_sample_agent_md() {
local file=${1:-"@AGENT.md"}
local file=${1:-"AGENT.md"}
cat > "$file" << 'EOF'
# Agent Build Instructions
@ -260,7 +260,7 @@ Created the following files:
Running tests...
✓ All tests passed (5/5)
Updating @fix_plan.md...
Updating fix_plan.md...
Completed: Set up basic project structure
Ready for next task.
@ -365,8 +365,8 @@ create_test_project() {
# Create Ralph files in .ralph/ subdirectory
create_sample_prompt ".ralph/PROMPT.md"
create_sample_fix_plan ".ralph/@fix_plan.md" 10 3
create_sample_agent_md ".ralph/@AGENT.md"
create_sample_fix_plan ".ralph/fix_plan.md" 10 3
create_sample_agent_md ".ralph/AGENT.md"
# Create state files in .ralph/
echo "0" > .ralph/.call_count

View file

@ -95,11 +95,11 @@ Test the system.
EOF
}
# Helper: Create a mock @fix_plan.md file
# Helper: Create a mock fix_plan.md file
create_mock_fix_plan() {
local total=${1:-5}
local completed=${2:-0}
local fix_plan_file="$RALPH_DIR/@fix_plan.md"
local fix_plan_file="$RALPH_DIR/fix_plan.md"
mkdir -p "$RALPH_DIR"
cat > "$fix_plan_file" << EOF

View file

@ -45,7 +45,7 @@ You are Ralph, an autonomous AI development agent.
## Current Objectives
- Study specs/* to learn about the project specifications
- Review @fix_plan.md for current priorities
- Review fix_plan.md for current priorities
## Key Principles
- ONE task per loop
@ -54,7 +54,7 @@ You are Ralph, an autonomous AI development agent.
- LIMIT testing to ~20% of your total effort
EOF
cat > ".ralph/@fix_plan.md" << 'EOF'
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
@ -70,7 +70,7 @@ cat > ".ralph/@fix_plan.md" << 'EOF'
- [x] Project initialization
EOF
cat > ".ralph/@AGENT.md" << 'EOF'
cat > ".ralph/AGENT.md" << 'EOF'
# Agent Build Instructions
## Project Setup
@ -128,7 +128,7 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
## Current Objectives
1. Study specs/* to learn about the project specifications
2. Review @fix_plan.md for current priorities
2. Review fix_plan.md for current priorities
3. Implement the highest priority item using best practices
4. Use parallel subagents for complex tasks (max 100 concurrent)
5. Run tests after each implementation
@ -139,7 +139,7 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
- Search the codebase before assuming something isn't implemented
- Use subagents for expensive operations (file searching, analysis)
- Write comprehensive tests with clear documentation
- Update @fix_plan.md with your learnings
- Update fix_plan.md with your learnings
- Commit working changes with descriptive messages
## Testing Guidelines (CRITICAL)
@ -166,11 +166,11 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
- App loads quickly (<2s initial load)
## Current Task
Follow @fix_plan.md and choose the most important item to implement next.
Follow fix_plan.md and choose the most important item to implement next.
EOF
# Create @fix_plan.md in .ralph/
cat > ".ralph/@fix_plan.md" << 'EOF'
# Create fix_plan.md in .ralph/
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
@ -374,36 +374,36 @@ remove_ralph_setup_mock() {
[[ "$output" -ge 1 ]]
}
# Test 5: ralph-import creates @fix_plan.md
@test "ralph-import creates @fix_plan.md with prioritized tasks" {
# Test 5: ralph-import creates fix_plan.md
@test "ralph-import creates fix_plan.md with prioritized tasks" {
create_sample_prd_md "test-app.md"
run bash "$PROJECT_ROOT/ralph_import.sh" "test-app.md"
assert_success
# @fix_plan.md should exist in .ralph/ subfolder
assert_file_exists "test-app/.ralph/@fix_plan.md"
# fix_plan.md should exist in .ralph/ subfolder
assert_file_exists "test-app/.ralph/fix_plan.md"
# Check structure includes priority sections
run grep -c "High Priority" "test-app/.ralph/@fix_plan.md"
run grep -c "High Priority" "test-app/.ralph/fix_plan.md"
assert_success
[[ "$output" -ge 1 ]]
run grep -c "Medium Priority" "test-app/.ralph/@fix_plan.md"
run grep -c "Medium Priority" "test-app/.ralph/fix_plan.md"
assert_success
[[ "$output" -ge 1 ]]
run grep -c "Low Priority" "test-app/.ralph/@fix_plan.md"
run grep -c "Low Priority" "test-app/.ralph/fix_plan.md"
assert_success
[[ "$output" -ge 1 ]]
run grep -c "Completed" "test-app/.ralph/@fix_plan.md"
run grep -c "Completed" "test-app/.ralph/fix_plan.md"
assert_success
[[ "$output" -ge 1 ]]
# Check checkbox format
run grep -E "^\- \[[ x]\]" "test-app/.ralph/@fix_plan.md"
run grep -E "^\- \[[ x]\]" "test-app/.ralph/fix_plan.md"
assert_success
}
@ -445,7 +445,7 @@ remove_ralph_setup_mock() {
# Files should be in custom-named directory under .ralph/ subfolder
assert_file_exists "my-custom-project/.ralph/PROMPT.md"
assert_file_exists "my-custom-project/.ralph/@fix_plan.md"
assert_file_exists "my-custom-project/.ralph/fix_plan.md"
assert_file_exists "my-custom-project/.ralph/specs/requirements.md"
# Default name directory should NOT exist
@ -616,8 +616,8 @@ remove_ralph_setup_mock() {
# Verify all required files in .ralph/ subfolder
assert_file_exists "my-app/.ralph/PROMPT.md"
assert_file_exists "my-app/.ralph/@fix_plan.md"
assert_file_exists "my-app/.ralph/@AGENT.md"
assert_file_exists "my-app/.ralph/fix_plan.md"
assert_file_exists "my-app/.ralph/AGENT.md"
assert_file_exists "my-app/.ralph/specs/requirements.md"
# Verify source PRD was copied
@ -738,7 +738,7 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
## Current Objectives
1. Study specs/* to learn about the project specifications
2. Review @fix_plan.md for current priorities
2. Review fix_plan.md for current priorities
## Key Principles
- ONE task per loop
@ -747,8 +747,8 @@ You are Ralph, an autonomous AI development agent working on a Task Management A
- LIMIT testing to ~20% of your total effort
EOF
# Create @fix_plan.md in .ralph/
cat > ".ralph/@fix_plan.md" << 'EOF'
# Create fix_plan.md in .ralph/
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
@ -781,13 +781,13 @@ EOF
# Output JSON response to stdout (mimicking --output-format json)
cat << 'JSON_OUTPUT'
{
"result": "Successfully converted PRD to Ralph format. Created .ralph/PROMPT.md, .ralph/@fix_plan.md, and .ralph/specs/requirements.md",
"result": "Successfully converted PRD to Ralph format. Created .ralph/PROMPT.md, .ralph/fix_plan.md, and .ralph/specs/requirements.md",
"sessionId": "session-prd-convert-123",
"metadata": {
"files_changed": 3,
"has_errors": false,
"completion_status": "complete",
"files_created": [".ralph/PROMPT.md", ".ralph/@fix_plan.md", ".ralph/specs/requirements.md"]
"files_created": [".ralph/PROMPT.md", ".ralph/fix_plan.md", ".ralph/specs/requirements.md"]
}
}
JSON_OUTPUT
@ -814,7 +814,7 @@ cat > /dev/null
# Ensure .ralph directory exists
mkdir -p .ralph
# Only create PROMPT.md (missing @fix_plan.md and specs/requirements.md)
# Only create PROMPT.md (missing fix_plan.md and specs/requirements.md)
cat > .ralph/PROMPT.md << 'EOF'
# Ralph Development Instructions
@ -832,7 +832,7 @@ cat << 'JSON_OUTPUT'
"has_errors": true,
"completion_status": "partial",
"files_created": [".ralph/PROMPT.md"],
"missing_files": [".ralph/@fix_plan.md", ".ralph/specs/requirements.md"]
"missing_files": [".ralph/fix_plan.md", ".ralph/specs/requirements.md"]
}
}
JSON_OUTPUT
@ -901,7 +901,7 @@ cat > .ralph/PROMPT.md << 'EOF'
You are Ralph, an autonomous AI development agent.
EOF
cat > ".ralph/@fix_plan.md" << 'EOF'
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
@ -920,7 +920,7 @@ EOF
# Output plain text (no JSON)
echo "Mock: Claude Code conversion completed successfully"
echo "Created: .ralph/PROMPT.md, .ralph/@fix_plan.md, .ralph/specs/requirements.md"
echo "Created: .ralph/PROMPT.md, .ralph/fix_plan.md, .ralph/specs/requirements.md"
exit 0
MOCK_CLAUDE_TEXT_EOF
chmod +x "$MOCK_BIN_DIR/claude"
@ -937,7 +937,7 @@ MOCK_CLAUDE_TEXT_EOF
# All files should be created in .ralph/ subfolder
assert_file_exists "json-test/.ralph/PROMPT.md"
assert_file_exists "json-test/.ralph/@fix_plan.md"
assert_file_exists "json-test/.ralph/fix_plan.md"
assert_file_exists "json-test/.ralph/specs/requirements.md"
}
@ -983,7 +983,7 @@ MOCK_CLAUDE_TEXT_EOF
# All files should be created in .ralph/ subfolder
assert_file_exists "text-test/.ralph/PROMPT.md"
assert_file_exists "text-test/.ralph/@fix_plan.md"
assert_file_exists "text-test/.ralph/fix_plan.md"
assert_file_exists "text-test/.ralph/specs/requirements.md"
}
@ -1059,7 +1059,7 @@ cat > .ralph/PROMPT.md << 'EOF'
# Ralph Development Instructions
EOF
cat > ".ralph/@fix_plan.md" << 'EOF'
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
- [ ] Task 1
@ -1128,7 +1128,7 @@ cat > .ralph/PROMPT.md << 'EOF'
# Ralph Development Instructions
EOF
cat > ".ralph/@fix_plan.md" << 'EOF'
cat > ".ralph/fix_plan.md" << 'EOF'
# Ralph Fix Plan
## High Priority
- [ ] Task 1

View file

@ -33,7 +33,7 @@ setup() {
You are Ralph, an autonomous AI development agent.
## Current Objectives
1. Follow @fix_plan.md for current priorities
1. Follow fix_plan.md for current priorities
2. Implement using best practices
3. Run tests after each implementation
EOF
@ -169,24 +169,24 @@ teardown() {
diff templates/PROMPT.md test-project/.ralph/PROMPT.md
}
@test "setup.sh copies fix_plan.md as @fix_plan.md to .ralph/" {
@test "setup.sh copies fix_plan.md to .ralph/" {
run bash "$SETUP_SCRIPT" test-project
assert_success
assert_file_exists "test-project/.ralph/@fix_plan.md"
assert_file_exists "test-project/.ralph/fix_plan.md"
# Verify content matches source
diff templates/fix_plan.md "test-project/.ralph/@fix_plan.md"
diff templates/fix_plan.md "test-project/.ralph/fix_plan.md"
}
@test "setup.sh copies AGENT.md as @AGENT.md to .ralph/" {
@test "setup.sh copies AGENT.md to .ralph/" {
run bash "$SETUP_SCRIPT" test-project
assert_success
assert_file_exists "test-project/.ralph/@AGENT.md"
assert_file_exists "test-project/.ralph/AGENT.md"
# Verify content matches source
diff templates/AGENT.md "test-project/.ralph/@AGENT.md"
diff templates/AGENT.md "test-project/.ralph/AGENT.md"
}
@test "setup.sh copies specs templates to .ralph/specs/" {
@ -332,8 +332,8 @@ teardown() {
bash "$SETUP_SCRIPT" my-custom-app
assert_file_exists "my-custom-app/.ralph/PROMPT.md"
assert_file_exists "my-custom-app/.ralph/@fix_plan.md"
assert_file_exists "my-custom-app/.ralph/@AGENT.md"
assert_file_exists "my-custom-app/.ralph/fix_plan.md"
assert_file_exists "my-custom-app/.ralph/AGENT.md"
}
# =============================================================================
@ -370,8 +370,8 @@ teardown() {
# Verify all files in .ralph/
assert_file_exists "my-project/.ralph/PROMPT.md"
assert_file_exists "my-project/.ralph/@fix_plan.md"
assert_file_exists "my-project/.ralph/@AGENT.md"
assert_file_exists "my-project/.ralph/fix_plan.md"
assert_file_exists "my-project/.ralph/AGENT.md"
# README stays at root
assert_file_exists "my-project/README.md"
}

View file

@ -35,7 +35,7 @@ setup() {
# Create sample project files
create_sample_prompt
create_sample_fix_plan "$RALPH_DIR/@fix_plan.md" 10 3
create_sample_fix_plan "$RALPH_DIR/fix_plan.md" 10 3
# Source library components
source "${BATS_TEST_DIRNAME}/../../lib/date_utils.sh"
@ -93,8 +93,8 @@ setup() {
context="Loop #${loop_count}. "
if [[ -f "$RALPH_DIR/@fix_plan.md" ]]; then
local incomplete_tasks=$(grep -c "^- \[ \]" "$RALPH_DIR/@fix_plan.md" 2>/dev/null || echo "0")
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local incomplete_tasks=$(grep -c "^- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
context+="Remaining tasks: ${incomplete_tasks}. "
fi
@ -218,9 +218,9 @@ teardown() {
[[ "$output" == *"Loop #5"* ]] || [[ "$output" == *"5"* ]]
}
@test "build_loop_context counts remaining tasks from @fix_plan.md" {
@test "build_loop_context counts remaining tasks from fix_plan.md" {
# Create fix plan with 7 incomplete tasks in .ralph/ directory
cat > "$RALPH_DIR/@fix_plan.md" << 'EOF'
cat > "$RALPH_DIR/fix_plan.md" << 'EOF'
# Fix Plan
- [x] Task 1 done
- [x] Task 2 done
@ -287,8 +287,8 @@ EOF
[[ ${#output} -le 600 ]]
}
@test "build_loop_context handles missing @fix_plan.md gracefully" {
rm -f "$RALPH_DIR/@fix_plan.md"
@test "build_loop_context handles missing fix_plan.md gracefully" {
rm -f "$RALPH_DIR/fix_plan.md"
run build_loop_context 1

View file

@ -39,8 +39,8 @@ teardown() {
@test "check_existing_ralph returns 'complete' when all required files exist" {
mkdir -p .ralph
echo "# PROMPT" > .ralph/PROMPT.md
echo "# Fix Plan" > .ralph/@fix_plan.md
echo "# Agent" > .ralph/@AGENT.md
echo "# Fix Plan" > .ralph/fix_plan.md
echo "# Agent" > .ralph/AGENT.md
check_existing_ralph || true
@ -50,20 +50,20 @@ teardown() {
@test "check_existing_ralph returns 'partial' when some files are missing" {
mkdir -p .ralph
echo "# PROMPT" > .ralph/PROMPT.md
# Missing @fix_plan.md and @AGENT.md
# Missing fix_plan.md and AGENT.md
check_existing_ralph || true
assert_equal "$RALPH_STATE" "partial"
[[ " ${RALPH_MISSING_FILES[*]} " =~ ".ralph/@fix_plan.md" ]]
[[ " ${RALPH_MISSING_FILES[*]} " =~ ".ralph/@AGENT.md" ]]
[[ " ${RALPH_MISSING_FILES[*]} " =~ ".ralph/fix_plan.md" ]]
[[ " ${RALPH_MISSING_FILES[*]} " =~ ".ralph/AGENT.md" ]]
}
@test "is_ralph_enabled returns 0 when fully enabled" {
mkdir -p .ralph
echo "# PROMPT" > .ralph/PROMPT.md
echo "# Fix Plan" > .ralph/@fix_plan.md
echo "# Agent" > .ralph/@AGENT.md
echo "# Fix Plan" > .ralph/fix_plan.md
echo "# Agent" > .ralph/AGENT.md
run is_ralph_enabled
assert_success
@ -314,16 +314,16 @@ EOF
assert_success
[[ -f ".ralph/PROMPT.md" ]]
[[ -f ".ralph/@fix_plan.md" ]]
[[ -f ".ralph/@AGENT.md" ]]
[[ -f ".ralph/fix_plan.md" ]]
[[ -f ".ralph/AGENT.md" ]]
[[ -f ".ralphrc" ]]
}
@test "enable_ralph_in_directory returns ALREADY_ENABLED when complete and no force" {
mkdir -p .ralph
echo "# PROMPT" > .ralph/PROMPT.md
echo "# Fix Plan" > .ralph/@fix_plan.md
echo "# Agent" > .ralph/@AGENT.md
echo "# Fix Plan" > .ralph/fix_plan.md
echo "# Agent" > .ralph/AGENT.md
export ENABLE_FORCE="false"
@ -335,8 +335,8 @@ EOF
@test "enable_ralph_in_directory overwrites with force flag" {
mkdir -p .ralph
echo "old content" > .ralph/PROMPT.md
echo "old fix plan" > .ralph/@fix_plan.md
echo "old agent" > .ralph/@AGENT.md
echo "old fix plan" > .ralph/fix_plan.md
echo "old agent" > .ralph/AGENT.md
export ENABLE_FORCE="true"
export ENABLE_PROJECT_NAME="new-project"

View file

@ -75,9 +75,9 @@ should_exit_gracefully() {
fi
# 4. Check fix_plan.md for completion
if [[ -f "$RALPH_DIR/@fix_plan.md" ]]; then
local total_items=$(grep -c "^- \[" "$RALPH_DIR/@fix_plan.md" 2>/dev/null)
local completed_items=$(grep -c "^- \[x\]" "$RALPH_DIR/@fix_plan.md" 2>/dev/null)
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local total_items=$(grep -c "^- \[" "$RALPH_DIR/fix_plan.md" 2>/dev/null)
local completed_items=$(grep -c "^- \[x\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null)
# Handle case where grep returns no matches (exit code 1)
[[ -z "$total_items" ]] && total_items=0
@ -176,9 +176,9 @@ EOF
assert_equal "$result" ""
}
# Test 10: Exit when @fix_plan.md all items complete
# Test 10: Exit when fix_plan.md all items complete
@test "should_exit_gracefully exits when all fix_plan items complete" {
cat > "$RALPH_DIR/@fix_plan.md" << 'EOF'
cat > "$RALPH_DIR/fix_plan.md" << 'EOF'
# Fix Plan
- [x] Task 1
- [x] Task 2
@ -189,9 +189,9 @@ EOF
assert_equal "$result" "plan_complete"
}
# Test 11: No exit when @fix_plan.md partially complete
# Test 11: No exit when fix_plan.md partially complete
@test "should_exit_gracefully continues when fix_plan partially complete" {
cat > "$RALPH_DIR/@fix_plan.md" << 'EOF'
cat > "$RALPH_DIR/fix_plan.md" << 'EOF'
# Fix Plan
- [x] Task 1
- [ ] Task 2
@ -202,9 +202,9 @@ EOF
assert_equal "$result" ""
}
# Test 12: No exit when @fix_plan.md missing
# Test 12: No exit when fix_plan.md missing
@test "should_exit_gracefully continues when fix_plan missing" {
# Don't create @fix_plan.md
# Don't create fix_plan.md
result=$(should_exit_gracefully || true)
assert_equal "$result" ""
@ -236,9 +236,9 @@ EOF
assert_equal "$result" "test_saturation"
}
# Test 16: @fix_plan.md with no checkboxes
# Test 16: fix_plan.md with no checkboxes
@test "should_exit_gracefully handles fix_plan with no checkboxes" {
cat > "$RALPH_DIR/@fix_plan.md" << 'EOF'
cat > "$RALPH_DIR/fix_plan.md" << 'EOF'
# Fix Plan
This is just text, no tasks yet.
EOF
@ -247,9 +247,9 @@ EOF
assert_equal "$result" ""
}
# Test 17: @fix_plan.md with mixed checkbox formats
# Test 17: fix_plan.md with mixed checkbox formats
@test "should_exit_gracefully handles mixed checkbox formats" {
cat > "$RALPH_DIR/@fix_plan.md" << 'EOF'
cat > "$RALPH_DIR/fix_plan.md" << 'EOF'
# Fix Plan
- [x] Task 1 completed
- [ ] Task 2 pending

View file

@ -72,8 +72,8 @@ teardown() {
assert_success
[[ -d ".ralph" ]]
[[ -f ".ralph/PROMPT.md" ]]
[[ -f ".ralph/@fix_plan.md" ]]
[[ -f ".ralph/@AGENT.md" ]]
[[ -f ".ralph/fix_plan.md" ]]
[[ -f ".ralph/AGENT.md" ]]
}
@test "ralph enable-ci creates .ralphrc configuration" {
@ -197,7 +197,7 @@ EOF
assert_success
# Check that tasks were imported
grep -q "authentication\|API\|database" .ralph/@fix_plan.md
grep -q "authentication\|API\|database" .ralph/fix_plan.md
}
@test "ralph enable-ci fails gracefully with missing PRD file" {
@ -238,8 +238,8 @@ EOF
@test "ralph enable-ci does not overwrite existing files without force" {
mkdir -p .ralph
echo "original prompt" > .ralph/PROMPT.md
echo "original fix plan" > .ralph/@fix_plan.md
echo "original agent" > .ralph/@AGENT.md
echo "original fix plan" > .ralph/fix_plan.md
echo "original agent" > .ralph/AGENT.md
run bash "$RALPH_ENABLE_CI" --from none

View file

@ -39,7 +39,7 @@ setup() {
# Create sample project files in .ralph/ directory
create_sample_prompt "$RALPH_DIR/PROMPT.md"
create_sample_fix_plan "$RALPH_DIR/@fix_plan.md" 10 3
create_sample_fix_plan "$RALPH_DIR/fix_plan.md" 10 3
# Source library components
source "${BATS_TEST_DIRNAME}/../../lib/date_utils.sh"