fix(loop-state): change state files from .md to .state extension#111
fix(loop-state): change state files from .md to .state extension#111marcusquinn merged 1 commit intomainfrom
Conversation
Loop state files (.local.md) were being picked up as OpenCode agents because they're .md files in the .agent/ directory tree. Changed extensions: - ralph-loop.local.md -> ralph-loop.local.state - quality-loop.local.md -> quality-loop.local.state - full-loop.local.md -> full-loop.local.state This prevents OpenCode from discovering them as agents while keeping them in the logical .agent/loop-state/ location. Fixes 'Loop-State/Quality-Loop.Local' appearing in OpenCode tab cycle.
|
Caution Review failedThe pull request is closed. WalkthroughState file naming convention updated from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where certain loop state files, previously using the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Jan 17 03:20:49 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Code Review
This pull request correctly changes the file extension for loop state files from .md to .state across multiple scripts, which is a good change to prevent them from being incorrectly identified as agents. My review focuses on improving maintainability by reducing hardcoded file paths and addresses a critical issue in the migration script (setup.sh) that could lead to loss of user state. I've suggested using constants for file paths where possible and provided a more robust migration logic for setup.sh.
|
|
||
| # Move loop-related files | ||
| for file in ralph-loop.local.md loop-state.json re-anchor.md guardrails.md; do | ||
| for file in ralph-loop.local.state loop-state.json re-anchor.md guardrails.md; do |
There was a problem hiding this comment.
This migration logic appears incomplete and could lead to loss of user loop state.
- File Rename: It moves
ralph-loop.local.statebut doesn't handle renaming existing.mdstate files (e.g.,ralph-loop.local.md) to the new.stateextension. Old.mdfiles will be ignored by the updated scripts. - Missing Files: The migration only considers
ralph-loop. It should also handlequality-loop.local.mdandfull-loop.local.md.
A more robust migration would be to explicitly check for old .md files, move and rename them. For example:
# Files to move and rename from .md to .state
local files_to_rename=("ralph-loop.local" "quality-loop.local" "full-loop.local")
for base_name in "${files_to_rename[@]}"; do
if [[ -f "$old_state_dir/${base_name}.md" ]]; then
mv "$old_state_dir/${base_name}.md" "$new_state_dir/${base_name}.state"
print_info " Moved and renamed ${base_name}.md"
fi
done
# Move other files that don't need renaming
for file in loop-state.json re-anchor.md guardrails.md; do
if [[ -f "$old_state_dir/$file" ]]; then
mv "$old_state_dir/$file" "$new_state_dir/"
print_info " Moved $file"
fi
done| rm -f ".agent/loop-state/ralph-loop.local.state" 2>/dev/null | ||
| rm -f ".agent/loop-state/quality-loop.local.state" 2>/dev/null | ||
| rm -f ".claude/ralph-loop.local.state" 2>/dev/null | ||
| rm -f ".claude/quality-loop.local.state" 2>/dev/null |
There was a problem hiding this comment.
These file paths for sub-loops are hardcoded, and a similar issue exists in cmd_resume. To improve maintainability and avoid magic strings, it would be best to define them as readonly constants at the top of the script. This would centralize the paths and make future changes easier.
For example, at the top of the script:
readonly RALPH_STATE_FILE_PATH=".agent/loop-state/ralph-loop.local.state"
readonly RALPH_LEGACY_STATE_FILE_PATH=".claude/ralph-loop.local.state"
# ... and so on for quality loopThen these constants could be used here and in cmd_resume.
| # $3 - Options string (key=value pairs separated by commas) | ||
| # Returns: 0 | ||
| # Side effects: Creates .agent/loop-state/quality-loop.local.md | ||
| # Side effects: Creates .agent/loop-state/quality-loop.local.state |
There was a problem hiding this comment.
Instead of hardcoding the filename in this comment, it's better to refer to the STATE_FILE constant defined at the top of the script. This ensures the comment stays in sync if the variable ever changes.
| # Side effects: Creates .agent/loop-state/quality-loop.local.state | |
| # Side effects: Creates the state file defined in STATE_FILE |
| local legacy_state="$worktree_path/.agent/loop-state/ralph-loop.local.state" | ||
| local legacy_state_old="$worktree_path/.claude/ralph-loop.local.state" |
There was a problem hiding this comment.
The file paths are being reconstructed here, but you have RALPH_STATE_FILE and RALPH_LEGACY_STATE_FILE constants defined at the top of the file. Reusing them would make the code more maintainable and less prone to errors if the paths change.
| local legacy_state="$worktree_path/.agent/loop-state/ralph-loop.local.state" | |
| local legacy_state_old="$worktree_path/.claude/ralph-loop.local.state" | |
| local legacy_state="$worktree_path/$RALPH_STATE_FILE" | |
| local legacy_state_old="$worktree_path/$RALPH_LEGACY_STATE_FILE" |
| local legacy_state="$worktree_path/.agent/loop-state/ralph-loop.local.state" | ||
| local legacy_state_old="$worktree_path/.claude/ralph-loop.local.state" |
There was a problem hiding this comment.
Similar to the show_status_all function, the file paths are being reconstructed here. Please use the RALPH_STATE_FILE and RALPH_LEGACY_STATE_FILE constants to improve maintainability.
| local legacy_state="$worktree_path/.agent/loop-state/ralph-loop.local.state" | |
| local legacy_state_old="$worktree_path/.claude/ralph-loop.local.state" | |
| local legacy_state="$worktree_path/$RALPH_STATE_FILE" | |
| local legacy_state_old="$worktree_path/$RALPH_LEGACY_STATE_FILE" |
| local ralph_file="$project_root/.agent/loop-state/ralph-loop.local.state" | ||
| local ralph_file_legacy="$project_root/.claude/ralph-loop.local.state" |
There was a problem hiding this comment.
| local state_file="$worktree_path/.agent/loop-state/ralph-loop.local.state" | ||
| local state_file_legacy="$worktree_path/.claude/ralph-loop.local.state" |
There was a problem hiding this comment.
🤖 Augment PR SummarySummary: This PR prevents loop state files from being discovered as OpenCode agents by changing their extension from Changes:
Technical Notes: The key behavior change is the file extension swap to avoid Markdown-based agent discovery while keeping the loop-state files colocated under 🤖 Was this summary useful? React with 👍 or 👎 |



Summary
Loop state files (
.local.md) were being picked up as OpenCode agents because they're.mdfiles in the.agent/directory tree (via the.opencode/agentsymlink).Solution
Changed file extensions from
.mdto.state:ralph-loop.local.md->ralph-loop.local.statequality-loop.local.md->quality-loop.local.statefull-loop.local.md->full-loop.local.stateThis prevents OpenCode from discovering them as agents while keeping them in the logical
.agent/loop-state/location.Files Updated
quality-loop-helper.sh- STATE_FILE constantralph-loop-helper.sh- RALPH_STATE_FILE and legacy pathsfull-loop-helper.sh- STATE_FILE and cleanup pathsworktree-sessions.sh- state file pathssession-review-helper.sh- ralph file pathsgenerate-opencode-commands.sh- documentationsetup.sh- migration pathsTesting
After merging, run
./setup.shto deploy. The loop state files will use.stateextension and won't appear in OpenCode's Tab cycle.Fixes "Loop-State/Quality-Loop.Local" appearing in OpenCode tab cycle.
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.