A plugin for OpenCode that implements a self-referential AI loop - repeatedly feeding the same prompt until the AI signals completion.
Inspired by Geoffrey Huntley's "Ralph" technique.
- You give the AI a task with clear completion criteria
- The AI works on the task
- When the session becomes idle, OContinue checks if the AI signaled completion
- If not complete (and under max iterations), OContinue feeds the same prompt again
- The AI sees its previous work in context and continues from where it left off
- Loop continues until completion or max iterations reached
Copy the plugin/ and command/ folders to your .opencode directory:
# Clone the repo
git clone https://github.com/d3vr/OContinue.git
cd OContinue
# Copy to your project's .opencode directory
cp -r plugin command /path/to/your/project/.opencode/
# Add state files to gitignore
echo "ocontinue-state.json" >> /path/to/your/project/.opencode/.gitignore
echo "ocontinue.log" >> /path/to/your/project/.opencode/.gitignoreOr install globally:
cp -r plugin command ~/.config/opencode/Restart OpenCode to load the plugin.
/ocontinue "Your task description here"
With custom max iterations (default: 20):
/ocontinue "Fix all TypeScript errors" 10
With custom completion promise (default: "DONE"):
/ocontinue "Refactor the auth module" 10 COMPLETE
Press Ctrl+C (or Esc) to abort the current operation - this also stops the loop.
The AI will see instructions to include <promise>DONE</promise> (or your custom promise text) when the task is complete. Once detected, the loop stops automatically.
- Per-session loops - Run multiple loops in different sessions
- Abort detection - Loop stops if you abort (Esc/Ctrl+C)
- Toast notifications - Visual feedback for loop events
- Log file - Detailed logs in
.opencode/ocontinue.log - Persistent state - Loop survives OpenCode restarts
| Parameter | Default | Description |
|---|---|---|
max |
20 | Maximum iterations before stopping |
promise |
"DONE" | Text the AI must include to signal completion |
| Aspect | Ralph (Claude Code) | OContinue (OpenCode) |
|---|---|---|
| Mechanism | Stop hook blocks exit | session.idle event triggers continuation |
| Message injection | Blocks exit with prompt | Sends new message via SDK |
| Result | Same prompt fed repeatedly | Same prompt fed repeatedly |
MIT