openralph 0.0.0-dev-202601221023
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/LICENSE +21 -0
- package/README.md +429 -0
- package/bin/ralph +69 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Luke Parker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# OpenRalph
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/openralph)
|
|
6
|
+
[](https://www.npmjs.com/package/openralph)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://bun.sh)
|
|
9
|
+
[](https://www.typescriptlang.org/)
|
|
10
|
+
|
|
11
|
+
**AI agent loop for autonomous task execution.**
|
|
12
|
+
|
|
13
|
+
Reads a PRD, picks one task, completes it, commits, repeats.
|
|
14
|
+
|
|
15
|
+
[Quick Start](#quick-start) •
|
|
16
|
+
[Features](#features) •
|
|
17
|
+
[Usage](#usage) •
|
|
18
|
+
[Config](#configuration) •
|
|
19
|
+
[Docs](#writing-prds)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="assets/images/ralph-task.jpg" alt="Ralph TUI - Task view with PRD items" width="100%" />
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<img src="assets/images/ralph-output details.jpg" alt="Ralph TUI - Output view showing agent activity" width="100%" />
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<img src="assets/images/openralph-terminal.jpg" alt="Ralph with openralph terminal side-by-side" width="100%" />
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Install stable release
|
|
43
|
+
bun install -g openralph
|
|
44
|
+
|
|
45
|
+
# Or install dev snapshot (latest from dev branch)
|
|
46
|
+
bun install -g openralph@dev
|
|
47
|
+
|
|
48
|
+
# Initialize PRD, progress log, and prompt
|
|
49
|
+
ralph init
|
|
50
|
+
|
|
51
|
+
# Run in any project directory
|
|
52
|
+
ralph
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Install from Source
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/shuv1337/openralph.git
|
|
59
|
+
cd openralph
|
|
60
|
+
bun install
|
|
61
|
+
bun run build:single # compiles for current platform
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
- **Autonomous Task Execution** — AI agent reads your PRD, picks tasks, and completes them one by one
|
|
69
|
+
- **Context-Aware Loop** — Re-reads full context every iteration, eliminating context drift
|
|
70
|
+
- **Beautiful TUI** — Real-time progress dashboard with task tracking and agent activity logs
|
|
71
|
+
- **Multiple Adapters** — Works with OpenCode server, opencode-run, or Codex CLI
|
|
72
|
+
- **Headless Mode** — CI-friendly output with JSON/JSONL/text formats
|
|
73
|
+
- **Session Safety** — Lock files prevent multiple instances; graceful shutdown with state persistence
|
|
74
|
+
- **Smart Resume** — Automatically resumes from where it left off after interruption
|
|
75
|
+
- **PRD Conversion** — Convert markdown plans to structured PRD JSON with `ralph init --from`
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## What is Ralph?
|
|
80
|
+
|
|
81
|
+
Ralph-driven development forces an AI agent to re-read full context every iteration, eliminating context drift. Each loop:
|
|
82
|
+
|
|
83
|
+
1. Read `prd.json`
|
|
84
|
+
2. Pick ONE task
|
|
85
|
+
3. Complete it
|
|
86
|
+
4. Commit (updating the PRD in the same commit)
|
|
87
|
+
5. Repeat until done
|
|
88
|
+
|
|
89
|
+
The agent never pushes—only commits—so you maintain review control.
|
|
90
|
+
|
|
91
|
+
**Why it works:**
|
|
92
|
+
- Deterministic failures are debuggable. When Ralph fails, fix the prompt.
|
|
93
|
+
- `AGENTS.md` accumulates wisdom so future iterations don't rediscover fire.
|
|
94
|
+
- Human review checkpoint before anything goes live.
|
|
95
|
+
|
|
96
|
+
**Learn more:**
|
|
97
|
+
- [ghuntley.com/ralph](https://ghuntley.com/ralph/)
|
|
98
|
+
- [lukeparker.dev/stop-chatting-with-ai-start-loops-ralph-driven-development](https://lukeparker.dev/stop-chatting-with-ai-start-loops-ralph-driven-development)
|
|
99
|
+
|
|
100
|
+
### For LLM Agents
|
|
101
|
+
|
|
102
|
+
When tasked by a user to set up or run Ralph:
|
|
103
|
+
1. Run `ralph init` to create required files (`prd.json`, `.ralph-prompt.md`, `AGENTS.md`)
|
|
104
|
+
2. Populate `prd.json` with tasks from the user's plan or requirements
|
|
105
|
+
3. Add project-specific notes to `AGENTS.md` (build commands, pitfalls, conventions)
|
|
106
|
+
4. Run `ralph` — the loop handles the rest
|
|
107
|
+
|
|
108
|
+
Do NOT manually edit `.ralph-state.json` or `.ralph-lock`. Never `git push` — only commit.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Usage
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
ralph # uses prd.json in current directory
|
|
116
|
+
ralph --plan BACKLOG.json # different PRD file
|
|
117
|
+
ralph --progress progress.txt # custom progress log
|
|
118
|
+
ralph --model anthropic/claude-opus-4 # different model
|
|
119
|
+
ralph --reset # remove generated files and state, then exit
|
|
120
|
+
ralph --verbose # enable debug logging to file
|
|
121
|
+
ralph init --from plan.md # convert unstructured plan to PRD JSON
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### CLI Options
|
|
125
|
+
|
|
126
|
+
| Option | Default | Description |
|
|
127
|
+
|--------|---------|-------------|
|
|
128
|
+
| `--plan, -p` | `prd.json` | PRD file path |
|
|
129
|
+
| `--progress` | `progress.txt` | Progress log path |
|
|
130
|
+
| `--model, -m` | `opencode/claude-opus-4-5` | Model (provider/model format) |
|
|
131
|
+
| `--adapter` | `opencode-server` | Adapter (opencode-server, opencode-run, codex) |
|
|
132
|
+
| `--prompt` | see below | Custom prompt (`{plan}` and `{progress}` placeholders) |
|
|
133
|
+
| `--prompt-file` | `.ralph-prompt.md` | Prompt file path |
|
|
134
|
+
| `--reset, -r` | `false` | Remove generated files and state, then exit |
|
|
135
|
+
| `--headless, -H` | `false` | CI-friendly output |
|
|
136
|
+
| `--format` | `text` | Headless output format (text, jsonl, json) |
|
|
137
|
+
| `--timestamps` | `false` | Include timestamps in headless output |
|
|
138
|
+
| `--max-iterations` | (none) | Cap iterations (headless) |
|
|
139
|
+
| `--max-time` | (none) | Cap runtime seconds (headless) |
|
|
140
|
+
| `--server, -s` | (none) | OpenCode server URL |
|
|
141
|
+
| `--server-timeout` | `5000` | Health check timeout in ms |
|
|
142
|
+
| `--agent, -a` | (none) | Agent name (e.g., build/plan/general) |
|
|
143
|
+
| `--debug, -d` | `false` | Manual session creation |
|
|
144
|
+
| `--yes` | `false` | Auto-confirm prompts |
|
|
145
|
+
| `--auto-reset` | `true` | Auto-reset when no TTY prompt |
|
|
146
|
+
| `--force, -f` | `false` | Force acquire session lock |
|
|
147
|
+
| `--verbose, -V` | `false` | Enable verbose debug logging to file |
|
|
148
|
+
| `--fallback-agent` | (none) | Fallback agent mapping (format: `primary:fallback`) |
|
|
149
|
+
|
|
150
|
+
### Init Subcommand
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
ralph init # create template PRD, prompt, plugin, and AGENTS.md
|
|
154
|
+
ralph init --from plan.md # convert markdown plan to PRD JSON
|
|
155
|
+
ralph init --force # overwrite existing files
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Creates these files:
|
|
159
|
+
- `prd.json` — PRD plan file (wrapped format with metadata)
|
|
160
|
+
- `progress.txt` — Progress log
|
|
161
|
+
- `.ralph-prompt.md` — Prompt template
|
|
162
|
+
- `.opencode/plugin/ralph-write-guardrail.ts` — Write guardrail plugin
|
|
163
|
+
- `AGENTS.md` — Project configuration for AI agents (never overwritten)
|
|
164
|
+
- `.gitignore` entries — Adds Ralph runtime files to .gitignore
|
|
165
|
+
|
|
166
|
+
| Option | Description |
|
|
167
|
+
|--------|-------------|
|
|
168
|
+
| `--from` | Source plan or notes to convert into PRD JSON |
|
|
169
|
+
| `--force` | Overwrite existing files (except AGENTS.md) |
|
|
170
|
+
|
|
171
|
+
<details>
|
|
172
|
+
<summary><strong>Default Prompt Template</strong></summary>
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
READ all of {plan} and {progress}. Pick ONE task with passes=false (prefer highest-risk/highest-impact). Keep changes small: one logical change per commit. Update {plan} by setting passes=true and adding notes or steps as needed. Append a brief entry to {progress} with what changed and why. Run feedback loops before committing: bun run typecheck, bun test, bun run lint (if missing, note it in {progress} and continue). Commit change (update {plan} in the same commit). ONLY do one task unless GLARINGLY OBVIOUS steps should run together. Quality bar: production code, maintainable, tests when appropriate. If you learn a critical operational detail, update AGENTS.md. When ALL tasks complete, create .ralph-done and output <promise>COMPLETE</promise>. NEVER GIT PUSH. ONLY COMMIT.
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
</details>
|
|
179
|
+
|
|
180
|
+
### Converting Plans to PRDs
|
|
181
|
+
|
|
182
|
+
When running `ralph init --from plan.md`, OpenRalph intelligently converts your markdown notes into a structured `prd.json`.
|
|
183
|
+
|
|
184
|
+
#### Best Practice `plan.md` Format:
|
|
185
|
+
To get the most out of the conversion, use this format in your markdown plans:
|
|
186
|
+
|
|
187
|
+
```markdown
|
|
188
|
+
# My Project Plan
|
|
189
|
+
|
|
190
|
+
- [x] [setup] Initialize repository and project structure
|
|
191
|
+
- [x] [ui] Design the landing page hero section
|
|
192
|
+
- [ ] [feat] Implement user authentication logic
|
|
193
|
+
- [ ] [feat] Add database persistence for tasks
|
|
194
|
+
- [ ] Plain list items are also picked up
|
|
195
|
+
* Asterisk lists work too
|
|
196
|
+
1. Numbered lists are also supported
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Why this works:**
|
|
200
|
+
- **Status Syncing**: Ralph detects `[x]` as completed (`passes: true`) and `[ ]` as pending (`passes: false`).
|
|
201
|
+
- **Category Tags**: Placing a bracketed tag like `[ui]` or `[feat]` at the start of a task automatically sets the `category` field in the generated PRD.
|
|
202
|
+
- **Deduplication**: Ralph automatically removes duplicate tasks during the conversion process.
|
|
203
|
+
- **Universal Support**: Works across Windows, macOS, and Linux with any standard terminal.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Configuration
|
|
208
|
+
|
|
209
|
+
Ralph reads configuration from `~/.config/ralph/config.json`:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"model": "opencode/claude-opus-4-5",
|
|
214
|
+
"plan": "prd.json",
|
|
215
|
+
"progress": "progress.txt",
|
|
216
|
+
"adapter": "opencode-server",
|
|
217
|
+
"server": "http://localhost:4190",
|
|
218
|
+
"serverTimeout": 5000
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
CLI arguments override config file values.
|
|
223
|
+
|
|
224
|
+
### Environment Variables
|
|
225
|
+
|
|
226
|
+
| Variable | Description |
|
|
227
|
+
|----------|-------------|
|
|
228
|
+
| `RALPH_MODEL` | Override model |
|
|
229
|
+
| `RALPH_ADAPTER` | Override adapter |
|
|
230
|
+
| `RALPH_PLAN` | Override plan file path |
|
|
231
|
+
| `RALPH_PROGRESS` | Override progress log path |
|
|
232
|
+
| `RALPH_SERVER` | Override OpenCode server URL |
|
|
233
|
+
| `RALPH_LOG_DIR` | Override debug log directory |
|
|
234
|
+
|
|
235
|
+
### Safety & Reliability
|
|
236
|
+
|
|
237
|
+
- **Session Locking** — Prevents multiple Ralph instances from running in the same directory
|
|
238
|
+
- **Error Backoff** — Retries failed agent iterations with exponential backoff
|
|
239
|
+
- **Graceful Shutdown** — Double Ctrl+C for force quit, single for confirmed exit
|
|
240
|
+
|
|
241
|
+
### Adapters
|
|
242
|
+
|
|
243
|
+
| Adapter | Description |
|
|
244
|
+
|---------|-------------|
|
|
245
|
+
| `opencode-server` | Default. Connects to OpenCode server via SDK |
|
|
246
|
+
| `opencode-run` | Spawns `opencode run` as PTY subprocess |
|
|
247
|
+
| `codex` | Spawns OpenAI Codex CLI as PTY subprocess |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Writing PRDs
|
|
252
|
+
|
|
253
|
+
PRD JSON uses `passes` flags so Ralph can track scope and progress. Two formats supported:
|
|
254
|
+
|
|
255
|
+
**Plain array** (user-created) or **wrapped format** (generated by `ralph init` with metadata).
|
|
256
|
+
|
|
257
|
+
### Task Item Fields
|
|
258
|
+
|
|
259
|
+
| Field | Required | Description |
|
|
260
|
+
|-------|----------|-------------|
|
|
261
|
+
| `description` | ✅ | Task description |
|
|
262
|
+
| `passes` | ✅ | Whether complete |
|
|
263
|
+
| `id` | ❌ | Custom ID (e.g., `"1.1.1"`) |
|
|
264
|
+
| `category` | ❌ | Category (e.g., `functional`, `setup`) |
|
|
265
|
+
| `steps` | ❌ | Verification steps |
|
|
266
|
+
| `status` | ❌ | `pending` / `actionable` / `active` / `done` / `blocked` / `error` |
|
|
267
|
+
| `effort` | ❌ | `XS` / `S` / `M` / `L` / `XL` |
|
|
268
|
+
| `risk` | ❌ | `L` / `M` / `H` |
|
|
269
|
+
|
|
270
|
+
**See [`prd.example.json`](prd.example.json) for a complete example with all fields.**
|
|
271
|
+
|
|
272
|
+
### Tips
|
|
273
|
+
|
|
274
|
+
- Small, isolated tasks — one commit each
|
|
275
|
+
- Explicit verification steps
|
|
276
|
+
- Use `effort` and `risk` for prioritization (high-risk first)
|
|
277
|
+
- Legacy markdown checkboxes work, but `ralph init --from plan.md` is the upgrade path
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Workflow Files
|
|
282
|
+
|
|
283
|
+
| File | Purpose |
|
|
284
|
+
|------|---------|
|
|
285
|
+
| `prd.json` | PRD plan items with `passes` state |
|
|
286
|
+
| `progress.txt` | Progress log appended each iteration |
|
|
287
|
+
| `.ralph-prompt.md` | Prompt template used for loop runs |
|
|
288
|
+
| `.ralph-state.json` | Persisted state for resume after Ctrl+C |
|
|
289
|
+
| `.ralph-lock` | Prevents multiple instances |
|
|
290
|
+
| `.ralph-done` | Agent creates this when all tasks complete |
|
|
291
|
+
| `.ralph-pause` | Created by `p` key to pause loop |
|
|
292
|
+
| `.opencode/plugin/ralph-write-guardrail.ts` | Protects files from AI modification |
|
|
293
|
+
| `AGENTS.md` | Project configuration for AI agents |
|
|
294
|
+
| `~/.local/state/ralph/logs/*.log` | Debug and memory logs (when `--verbose` is enabled) |
|
|
295
|
+
|
|
296
|
+
Add to `.gitignore`:
|
|
297
|
+
```
|
|
298
|
+
.ralph-*
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Progress Log Example
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
## Iteration 3 - 2025-01-10T12:34:56Z
|
|
305
|
+
- Task: Wire up API client
|
|
306
|
+
- Checks: typecheck, test
|
|
307
|
+
- Commit: abc123
|
|
308
|
+
- Notes: Added retry logic for timeouts
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### AGENTS.md
|
|
312
|
+
|
|
313
|
+
Ralph writes operational learnings here. Future iterations read it.
|
|
314
|
+
|
|
315
|
+
```markdown
|
|
316
|
+
# AGENTS.md
|
|
317
|
+
|
|
318
|
+
## Build
|
|
319
|
+
- Run `bun install` before `bun run dev`
|
|
320
|
+
|
|
321
|
+
## Pitfalls
|
|
322
|
+
- Never import from `solid-js`, use `@opentui/solid`
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Keybindings
|
|
328
|
+
|
|
329
|
+
| Key | Action |
|
|
330
|
+
|-----|--------|
|
|
331
|
+
| `q` / `Ctrl+C` | Quit (shows confirmation) |
|
|
332
|
+
| `Ctrl+C` (double) | Force quit |
|
|
333
|
+
| `p` | Pause/Resume loop |
|
|
334
|
+
| `c` | Open command palette |
|
|
335
|
+
| `:` | Steering mode (send message to agent) |
|
|
336
|
+
| `t` | Launch terminal with attach command |
|
|
337
|
+
| `Shift+T` | Toggle tasks panel |
|
|
338
|
+
| `o` | Toggle Details/Output view |
|
|
339
|
+
| `d` | Toggle progress dashboard |
|
|
340
|
+
| `x` | Toggle task status (staged) |
|
|
341
|
+
| `?` | Show help overlay |
|
|
342
|
+
| `↑` / `k` | Navigate up (in tasks panel) |
|
|
343
|
+
| `↓` / `j` | Navigate down (in tasks panel) |
|
|
344
|
+
| `n` | New session (debug mode only) |
|
|
345
|
+
| `Escape` | Close overlay/panel |
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Architecture
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
src/
|
|
353
|
+
├── index.ts # CLI entry, wires TUI to loop
|
|
354
|
+
├── loop.ts # Main agent loop (prompt → events → commit)
|
|
355
|
+
├── app.tsx # Solid.js TUI root component
|
|
356
|
+
├── state.ts # State types and persistence
|
|
357
|
+
├── plan.ts # PRD + markdown plan parser
|
|
358
|
+
├── git.ts # Git operations (hash, diff, commits)
|
|
359
|
+
├── prompt.ts # User confirmation prompts
|
|
360
|
+
├── adapters/ # Adapter implementations (opencode, codex)
|
|
361
|
+
├── components/ # TUI components (header, log, footer, panels)
|
|
362
|
+
├── context/ # React-style contexts (theme, dialog, toast)
|
|
363
|
+
├── hooks/ # Custom hooks (keyboard, loop state, stats)
|
|
364
|
+
├── lib/ # Core utilities (config, logging, theming, time)
|
|
365
|
+
├── pty/ # PTY subprocess management
|
|
366
|
+
├── templates/ # Init templates (agents, plugins)
|
|
367
|
+
├── types/ # TypeScript type definitions
|
|
368
|
+
└── ui/ # Dialog components
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Data flow:** `index.ts` starts the TUI (`app.tsx`) and the loop (`loop.ts`) in parallel. The loop sends callbacks to update TUI state. State persists to `.ralph-state.json` for resume capability.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Testing
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
bun test # run all tests
|
|
379
|
+
bun test --watch # watch mode
|
|
380
|
+
bun test --coverage # with coverage
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
tests/
|
|
385
|
+
├── unit/ # Module isolation tests
|
|
386
|
+
├── integration/ # Full workflow tests
|
|
387
|
+
├── fixtures/ # Test plans and PRD JSON
|
|
388
|
+
└── helpers/ # Mock factories, temp file utils
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Requirements
|
|
394
|
+
|
|
395
|
+
- [Bun](https://bun.sh) v1.0+
|
|
396
|
+
- [OpenCode](https://opencode.ai) CLI running (or alternative adapter)
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## Contributing
|
|
401
|
+
|
|
402
|
+
Contributions are welcome! Feel free to submit a Pull Request.
|
|
403
|
+
|
|
404
|
+
1. Fork the repo
|
|
405
|
+
2. Create your feature branch (`git checkout -b feature/cool-stuff`)
|
|
406
|
+
3. Commit your changes (`git commit -m 'Add cool stuff'`)
|
|
407
|
+
4. Push to the branch (`git push origin feature/cool-stuff`)
|
|
408
|
+
5. Open a Pull Request
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Credits
|
|
413
|
+
|
|
414
|
+
- Thanks to [Geoffrey Huntley](https://ghuntley.com) for the original Ralph Wiggum loop concept
|
|
415
|
+
- OpenRalph is a fork of [`opencode-ralph`](https://github.com/hona/opencode-ralph) — huge thanks to [Hona](https://github.com/hona) for the original implementation
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## License
|
|
420
|
+
|
|
421
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
<div align="center">
|
|
426
|
+
|
|
427
|
+
Made by the ralph development community
|
|
428
|
+
|
|
429
|
+
</div>
|
package/bin/ralph
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const projectRoot = path.resolve(__dirname, "..");
|
|
12
|
+
|
|
13
|
+
const platformMap = {
|
|
14
|
+
darwin: "darwin",
|
|
15
|
+
linux: "linux",
|
|
16
|
+
win32: "windows",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const archMap = {
|
|
20
|
+
x64: "x64",
|
|
21
|
+
arm64: "arm64",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const platform = platformMap[os.platform()] ?? os.platform();
|
|
25
|
+
const arch = archMap[os.arch()] ?? os.arch();
|
|
26
|
+
const packageName = `openralph-${platform}-${arch}`;
|
|
27
|
+
const binaryName = platform === "windows" ? "ralph.exe" : "ralph";
|
|
28
|
+
|
|
29
|
+
let binaryPath;
|
|
30
|
+
|
|
31
|
+
// First, check for locally built binary in dist/ directory
|
|
32
|
+
const localBinaryPath = path.join(projectRoot, "dist", packageName, "bin", binaryName);
|
|
33
|
+
if (fs.existsSync(localBinaryPath)) {
|
|
34
|
+
binaryPath = localBinaryPath;
|
|
35
|
+
} else {
|
|
36
|
+
// Fall back to npm package resolution for installed packages
|
|
37
|
+
try {
|
|
38
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
39
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
40
|
+
binaryPath = path.join(packageDir, "bin", binaryName);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
// No local build and no npm package found
|
|
43
|
+
console.error(`Error: No ralph binary found for ${platform}-${arch}.`);
|
|
44
|
+
console.error("");
|
|
45
|
+
console.error("To fix this, run:");
|
|
46
|
+
console.error(" bun run build:single # Build for current platform");
|
|
47
|
+
console.error("");
|
|
48
|
+
console.error("Or install globally:");
|
|
49
|
+
console.error(" bun install -g openralph");
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(binaryPath)) {
|
|
55
|
+
console.error(`Error: Binary not found at ${binaryPath}`);
|
|
56
|
+
console.error("");
|
|
57
|
+
console.error("To fix this, run:");
|
|
58
|
+
console.error(" bun run build:single # Rebuild for current platform");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
63
|
+
child.on("exit", (code) => {
|
|
64
|
+
process.exit(code ?? 0);
|
|
65
|
+
});
|
|
66
|
+
child.on("error", (error) => {
|
|
67
|
+
console.error(`Failed to run ${binaryName}: ${error.message}`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openralph",
|
|
3
|
+
"version": "0.0.0-dev-202601221023",
|
|
4
|
+
"description": "Ralph Driven Development using OpenCode SDK and OpenTUI",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ralph": "./bin/ralph"
|
|
7
|
+
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"openralph-darwin-arm64": "0.0.0-dev-202601221023",
|
|
10
|
+
"openralph-darwin-x64": "0.0.0-dev-202601221023",
|
|
11
|
+
"openralph-linux-arm64": "0.0.0-dev-202601221023",
|
|
12
|
+
"openralph-linux-x64": "0.0.0-dev-202601221023",
|
|
13
|
+
"openralph-windows-x64": "0.0.0-dev-202601221023"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/shuv1337/openralph.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"cli",
|
|
21
|
+
"ai",
|
|
22
|
+
"coding",
|
|
23
|
+
"assistant"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT"
|
|
26
|
+
}
|