@th0rgal/ralph-wiggum 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -88
- package/bin/ralph.js +917 -0
- package/install.ps1 +3 -33
- package/install.sh +3 -30
- package/package.json +4 -10
- package/ralph.ts +447 -26
- package/uninstall.ps1 +10 -18
- package/uninstall.sh +10 -17
- package/.opencode/command/cancel-ralph.md +0 -26
- package/.opencode/command/help.md +0 -98
- package/.opencode/command/ralph-loop.md +0 -45
- package/.opencode/plugin/ralph-wiggum.ts +0 -288
- package/bin/ralph +0 -0
package/README.md
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
<a href="#what-is-ralph">What is Ralph?</a> •
|
|
18
18
|
<a href="#installation">Installation</a> •
|
|
19
19
|
<a href="#quick-start">Quick Start</a> •
|
|
20
|
-
<a href="#which-approach">Which Approach?</a> •
|
|
21
20
|
<a href="#commands">Commands</a>
|
|
22
21
|
</p>
|
|
23
22
|
|
|
@@ -27,6 +26,8 @@
|
|
|
27
26
|
|
|
28
27
|
Ralph is a development methodology where an AI agent receives the **same prompt repeatedly** until it completes a task. Each iteration, the AI sees its previous work in files and git history, enabling self-correction and incremental progress.
|
|
29
28
|
|
|
29
|
+
This package provides a **CLI-only** implementation (no OpenCode plugin).
|
|
30
|
+
|
|
30
31
|
```bash
|
|
31
32
|
# The essence of Ralph:
|
|
32
33
|
while true; do
|
|
@@ -44,12 +45,26 @@ done
|
|
|
44
45
|
| **Persistence** | Walk away, come back to completed work |
|
|
45
46
|
| **Iteration** | Complex tasks broken into incremental progress |
|
|
46
47
|
| **Automation** | No babysitting—loop handles retries |
|
|
48
|
+
| **Observability** | Monitor progress with `--status`, see history and struggle indicators |
|
|
49
|
+
| **Mid-Loop Guidance** | Inject hints with `--add-context` without stopping the loop |
|
|
47
50
|
|
|
48
51
|
## Installation
|
|
49
52
|
|
|
50
53
|
**Prerequisites:** [Bun](https://bun.sh) and [OpenCode](https://opencode.ai)
|
|
51
54
|
|
|
52
|
-
###
|
|
55
|
+
### npm (recommended)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install -g @th0rgal/ralph-wiggum
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Bun
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun add -g @th0rgal/ralph-wiggum
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### From source
|
|
53
68
|
|
|
54
69
|
```bash
|
|
55
70
|
git clone https://github.com/Th0rgal/ralph-wiggum
|
|
@@ -57,8 +72,6 @@ cd opencode-ralph-wiggum
|
|
|
57
72
|
./install.sh
|
|
58
73
|
```
|
|
59
74
|
|
|
60
|
-
### Windows (PowerShell)
|
|
61
|
-
|
|
62
75
|
```powershell
|
|
63
76
|
git clone https://github.com/Th0rgal/ralph-wiggum
|
|
64
77
|
cd opencode-ralph-wiggum
|
|
@@ -67,8 +80,6 @@ cd opencode-ralph-wiggum
|
|
|
67
80
|
|
|
68
81
|
This installs:
|
|
69
82
|
- `ralph` CLI command (global)
|
|
70
|
-
- OpenCode commands (`/ralph-loop`, `/cancel-ralph`, `/help`)
|
|
71
|
-
- OpenCode plugin with custom tools
|
|
72
83
|
|
|
73
84
|
## Quick Start
|
|
74
85
|
|
|
@@ -83,57 +94,9 @@ ralph "Build a REST API for todos with CRUD operations and tests. \
|
|
|
83
94
|
--max-iterations 20
|
|
84
95
|
```
|
|
85
96
|
|
|
86
|
-
## Which Approach?
|
|
87
|
-
|
|
88
|
-
This implementation provides **two ways** to run Ralph loops:
|
|
89
|
-
|
|
90
|
-
### CLI Loop (Recommended)
|
|
91
|
-
|
|
92
|
-
External loop that calls `opencode run` repeatedly.
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
ralph "Your task" --max-iterations 10
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
| Pros | Cons |
|
|
99
|
-
|------|------|
|
|
100
|
-
| ✅ Works with any OpenCode version | ❌ Each iteration is a fresh session |
|
|
101
|
-
| ✅ Simple and predictable | ❌ No conversation context between iterations |
|
|
102
|
-
| ✅ Easy to debug | |
|
|
103
|
-
| ✅ Auto-commit between iterations | |
|
|
104
|
-
|
|
105
|
-
**Best for:** Most use cases, especially tasks with clear success criteria.
|
|
106
|
-
|
|
107
|
-
### Plugin Loop (Experimental)
|
|
108
|
-
|
|
109
|
-
In-session continuation using OpenCode's SDK events.
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# In OpenCode TUI, use the ralph_start tool:
|
|
113
|
-
# "Start a Ralph loop to build X"
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
| Pros | Cons |
|
|
117
|
-
|------|------|
|
|
118
|
-
| ✅ Single session context | ❌ Depends on OpenCode plugin API |
|
|
119
|
-
| ✅ More efficient | ❌ Experimental—API may change |
|
|
120
|
-
| ✅ Tools available in-session | ❌ Harder to debug |
|
|
121
|
-
|
|
122
|
-
**Best for:** Long-running tasks where conversation context matters.
|
|
123
|
-
|
|
124
|
-
### Decision Guide
|
|
125
|
-
|
|
126
|
-
| If you need... | Use |
|
|
127
|
-
|---------------|-----|
|
|
128
|
-
| Reliability | CLI Loop |
|
|
129
|
-
| Auto-commits | CLI Loop |
|
|
130
|
-
| Conversation context | Plugin Loop |
|
|
131
|
-
| Scripting/automation | CLI Loop |
|
|
132
|
-
| First time trying Ralph | CLI Loop |
|
|
133
|
-
|
|
134
97
|
## Commands
|
|
135
98
|
|
|
136
|
-
###
|
|
99
|
+
### Running a Loop
|
|
137
100
|
|
|
138
101
|
```bash
|
|
139
102
|
ralph "<prompt>" [options]
|
|
@@ -150,44 +113,78 @@ Options:
|
|
|
150
113
|
--help Show help
|
|
151
114
|
```
|
|
152
115
|
|
|
153
|
-
###
|
|
116
|
+
### Monitoring & Control
|
|
154
117
|
|
|
155
118
|
```bash
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/help # Show Ralph Wiggum documentation
|
|
159
|
-
```
|
|
119
|
+
# Check status of active loop (run from another terminal)
|
|
120
|
+
ralph --status
|
|
160
121
|
|
|
161
|
-
|
|
122
|
+
# Add context/hints for the next iteration
|
|
123
|
+
ralph --add-context "Focus on fixing the auth module first"
|
|
162
124
|
|
|
163
|
-
|
|
125
|
+
# Clear pending context
|
|
126
|
+
ralph --clear-context
|
|
127
|
+
```
|
|
164
128
|
|
|
165
|
-
|
|
166
|
-
|------|-------------|
|
|
167
|
-
| `ralph_start` | Start a loop with prompt, max iterations, completion promise |
|
|
168
|
-
| `ralph_status` | Check current loop status and iteration |
|
|
169
|
-
| `ralph_cancel` | Cancel the active loop |
|
|
129
|
+
### Status Dashboard
|
|
170
130
|
|
|
171
|
-
|
|
131
|
+
The `--status` command shows:
|
|
132
|
+
- **Active loop info**: Current iteration, elapsed time, prompt
|
|
133
|
+
- **Pending context**: Any hints queued for next iteration
|
|
134
|
+
- **Iteration history**: Last 5 iterations with tools used, duration
|
|
135
|
+
- **Struggle indicators**: Warnings if agent is stuck (no progress, repeated errors)
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
139
|
+
║ Ralph Wiggum Status ║
|
|
140
|
+
╚══════════════════════════════════════════════════════════════════╝
|
|
141
|
+
|
|
142
|
+
🔄 ACTIVE LOOP
|
|
143
|
+
Iteration: 3 / 10
|
|
144
|
+
Elapsed: 5m 23s
|
|
145
|
+
Promise: COMPLETE
|
|
146
|
+
Prompt: Build a REST API...
|
|
147
|
+
|
|
148
|
+
📊 HISTORY (3 iterations)
|
|
149
|
+
Total time: 5m 23s
|
|
150
|
+
|
|
151
|
+
Recent iterations:
|
|
152
|
+
🔄 #1: 2m 10s | Bash:5 Write:3 Read:2
|
|
153
|
+
🔄 #2: 1m 45s | Edit:4 Bash:3 Read:2
|
|
154
|
+
🔄 #3: 1m 28s | Bash:2 Edit:1
|
|
155
|
+
|
|
156
|
+
⚠️ STRUGGLE INDICATORS:
|
|
157
|
+
- No file changes in 3 iterations
|
|
158
|
+
💡 Consider using: ralph --add-context "your hint here"
|
|
159
|
+
```
|
|
172
160
|
|
|
173
|
-
###
|
|
161
|
+
### Mid-Loop Context Injection
|
|
174
162
|
|
|
175
|
-
|
|
176
|
-
Remove `ralph-wiggum` from your OpenCode `plugin` list (opencode.json), or run:
|
|
163
|
+
Guide a struggling agent without stopping the loop:
|
|
177
164
|
|
|
178
165
|
```bash
|
|
179
|
-
|
|
166
|
+
# In another terminal while loop is running
|
|
167
|
+
ralph --add-context "The bug is in utils/parser.ts line 42"
|
|
168
|
+
ralph --add-context "Try using the singleton pattern for config"
|
|
180
169
|
```
|
|
181
170
|
|
|
182
|
-
|
|
171
|
+
Context is automatically consumed after one iteration.
|
|
172
|
+
|
|
173
|
+
## Troubleshooting
|
|
174
|
+
|
|
175
|
+
### "ralph-wiggum" plugin errors
|
|
183
176
|
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
This package is **CLI-only**. If OpenCode tries to load a `ralph-wiggum` plugin,
|
|
178
|
+
remove it from your OpenCode `plugin` list (opencode.json), or run:
|
|
186
179
|
|
|
187
180
|
```bash
|
|
188
181
|
ralph "Your task" --no-plugins
|
|
189
182
|
```
|
|
190
183
|
|
|
184
|
+
### "bun: command not found"
|
|
185
|
+
|
|
186
|
+
Install Bun: https://bun.sh
|
|
187
|
+
|
|
191
188
|
## Writing Good Prompts
|
|
192
189
|
|
|
193
190
|
### Include Clear Success Criteria
|
|
@@ -280,34 +277,38 @@ ralph "Your task" --max-iterations 20
|
|
|
280
277
|
|
|
281
278
|
```
|
|
282
279
|
ralph-wiggum/
|
|
283
|
-
├── ralph.
|
|
280
|
+
├── bin/ralph.js # CLI entrypoint (npm wrapper)
|
|
281
|
+
├── ralph.ts # Main loop implementation
|
|
284
282
|
├── package.json # Package config
|
|
285
|
-
├── install.sh
|
|
286
|
-
|
|
287
|
-
└── .opencode/
|
|
288
|
-
├── command/
|
|
289
|
-
│ ├── ralph-loop.md # /ralph-loop command
|
|
290
|
-
│ ├── cancel-ralph.md # /cancel-ralph command
|
|
291
|
-
│ └── help.md # /help command
|
|
292
|
-
└── plugin/
|
|
293
|
-
└── ralph-wiggum.ts # OpenCode plugin
|
|
283
|
+
├── install.sh / install.ps1 # Installation scripts
|
|
284
|
+
└── uninstall.sh / uninstall.ps1 # Uninstallation scripts
|
|
294
285
|
```
|
|
295
286
|
|
|
287
|
+
### State Files (in .opencode/)
|
|
288
|
+
|
|
289
|
+
During operation, Ralph stores state in `.opencode/`:
|
|
290
|
+
- `ralph-loop.state.json` - Active loop state
|
|
291
|
+
- `ralph-history.json` - Iteration history and metrics
|
|
292
|
+
- `ralph-context.md` - Pending context for next iteration
|
|
293
|
+
|
|
296
294
|
## Uninstall
|
|
297
295
|
|
|
298
296
|
```bash
|
|
299
|
-
|
|
297
|
+
npm uninstall -g @th0rgal/ralph-wiggum
|
|
300
298
|
```
|
|
301
299
|
|
|
302
300
|
```powershell
|
|
303
|
-
|
|
301
|
+
npm uninstall -g @th0rgal/ralph-wiggum
|
|
304
302
|
```
|
|
305
303
|
|
|
306
304
|
## Learn More
|
|
307
305
|
|
|
308
306
|
- [Original technique by Geoffrey Huntley](https://ghuntley.com/ralph/)
|
|
309
307
|
- [Ralph Orchestrator](https://github.com/mikeyobrien/ralph-orchestrator)
|
|
310
|
-
|
|
308
|
+
|
|
309
|
+
## See Also
|
|
310
|
+
|
|
311
|
+
Check out [OpenAgent](https://github.com/Th0rgal/openagent) - a dashboard for orchestrating AI agents with workspace management, real-time monitoring, and multi-agent workflows.
|
|
311
312
|
|
|
312
313
|
## License
|
|
313
314
|
|