opencode-ralph/command/ralph-context.md
Chindriș Mihai Alexandru aaf72e35d4 feat: add history tracking, context injection, and struggle detection
Enhanced Ralph Wiggum plugin with:
- Iteration history tracking (ralph-history.local.json)
- Mid-loop context injection via /ralph-context command
- Loop status monitoring via /ralph-status command
- Struggle detection (no file changes, high error rate, rapid iterations)
- Operator guidance in continuation prompts
- Tool usage and file modification tracking per iteration

New commands:
- /ralph-status: View current loop state, history summary, struggle indicators
- /ralph-context: Inject hints/guidance mid-loop without stopping

Fork of rot13maxi/opencode-ralph with significant enhancements.
2026-01-26 02:31:33 +02:00

1.7 KiB

description
Inject context into the next Ralph loop iteration

Ralph Context Command

Add context or hints that will be injected into the next Ralph loop iteration. This is useful when the AI is stuck and needs guidance without stopping the loop.

Instructions

Execute the following steps:

  1. Parse the context from: $ARGUMENTS

    The entire argument string is the context to inject.

  2. Check if ralph-loop.local.md exists to verify an active loop.

  3. If no active loop, output:

⚠️ No active Ralph loop found.

Start a loop first with:
  /ralph-loop "Your task" --completion-promise "DONE" --max-iterations 20
  1. If an active loop exists:

    a. Create or append to ralph-context.local.md:

    ---
    added_at: "<ISO_TIMESTAMP>"
    ---
    
    <CONTEXT_TEXT>
    

    b. Output confirmation:

✅ Context queued for next iteration!

📝 Added:
   <CONTEXT_TEXT>

The AI will receive this context at the start of iteration <NEXT_ITERATION>.
Context is automatically cleared after being consumed.

💡 Tips:
   - Be specific: "The bug is in utils/parser.ts line 42"
   - Suggest approaches: "Try using the singleton pattern"
   - Point to resources: "Check the API docs at /docs/api.md"
  1. If called with no arguments, display current pending context:
📝 Pending Context for Next Iteration:

<CONTEXT_TEXT if exists>
<or "No pending context">

Commands:
  /ralph-context <text>  - Add context
  /ralph-clear-context   - Clear pending context

Example Usage

/ralph-context Focus on fixing the authentication module first
/ralph-context The error is in line 42 of auth.ts - check the token validation
/ralph-context Try using async/await instead of callbacks