@graypark/ralph-codex 0.7.2 → 0.8.1

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 CHANGED
@@ -1,15 +1,101 @@
1
- # ralph-codex
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/vcz-Gray/ralph-codex/main/assets/ralph-codex-banner.svg" alt="ralph-codex" width="600" />
3
+ </p>
2
4
 
3
- Self-referential iterative development loops for **Codex CLI** and **Claude Code** — with multi-agent orchestration, interactive command generation, and cross-platform stop hooks.
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@graypark/ralph-codex"><img src="https://img.shields.io/npm/v/@graypark/ralph-codex.svg?style=flat-square&color=blue" alt="npm version" /></a>
7
+ <a href="https://www.npmjs.com/package/@graypark/ralph-codex"><img src="https://img.shields.io/npm/dm/@graypark/ralph-codex.svg?style=flat-square&color=green" alt="npm downloads" /></a>
8
+ <a href="https://github.com/vcz-Gray/ralph-codex/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="license" /></a>
9
+ <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg?style=flat-square" alt="node version" />
10
+ <img src="https://img.shields.io/badge/platform-Codex%20CLI%20%7C%20Claude%20Code-purple.svg?style=flat-square" alt="platform" />
11
+ <img src="https://img.shields.io/badge/tests-32%20passing-brightgreen.svg?style=flat-square" alt="tests" />
12
+ </p>
13
+
14
+ <p align="center">
15
+ <b>Iterative AI development loops with PRD-driven task tracking, multi-agent orchestration, and interactive command generation.</b>
16
+ <br/>
17
+ <sub>Based on <a href="https://ghuntley.com/ralph/">Geoffrey Huntley's Ralph Wiggum technique</a></sub>
18
+ </p>
19
+
20
+ ---
21
+
22
+ ## Why ralph-codex?
23
+
24
+ AI coding agents struggle with:
25
+
26
+ | Problem | What happens |
27
+ | ------------------------ | ---------------------------------------------------------- |
28
+ | **Context rot** | Long conversations accumulate noise, agent gets confused |
29
+ | **No checkpoints** | All-or-nothing execution — can't resume after interruption |
30
+ | **Lost learnings** | Previous iterations' insights overwritten by new context |
31
+ | **Completion ambiguity** | Agent says "done" but tests still fail |
32
+
33
+ ralph-codex solves this:
34
+
35
+ - **Fresh context per iteration** — Each cycle reads PRD + progress from disk, no degradation
36
+ - **Git-enforced safety** — Atomic commits per story, rollback at any point
37
+ - **Append-only learnings** — `progress.txt` accumulates knowledge across iterations
38
+ - **Test-verified completion** — Agent can only exit when `<promise>COMPLETE</promise>` is genuinely true
4
39
 
5
40
  ## What is Ralph Loop?
6
41
 
7
- An AI agent works on a task in a continuous loop, seeing its own previous work each iteration, until a completion condition is met. ralph-codex adds smart orchestration on top: automatic phase splitting, parallel subagent spawning, and an interview-driven command generator.
42
+ An AI agent works on a task in a continuous loop. Each iteration starts with **fresh context** reading the PRD and progress files to decide what to do next. The agent implements one story, commits, updates progress, and exits. The stop hook intercepts the exit and re-injects the prompt. Repeat until all stories pass.
43
+
44
+ ```
45
+ ┌──────────────────────┐
46
+ │ /ralph-interview │
47
+ │ Describe your task │
48
+ └──────────┬───────────┘
49
+
50
+ ┌──────────▼───────────┐
51
+ │ Generate prd.json │
52
+ │ + progress.txt │
53
+ └──────────┬───────────┘
54
+
55
+ ┌────────────────▼────────────────┐
56
+ │ Ralph Loop │
57
+ │ │
58
+ │ 1. Read prd.json + progress │
59
+ │ 2. Pick next story (passes=false)│
60
+ │ 3. Implement + verify │
61
+ │ 4. Commit + update progress │
62
+ │ 5. Exit attempt │
63
+ │ │ │
64
+ │ Stop Hook intercepts │
65
+ │ Re-injects prompt │
66
+ │ │ │
67
+ │ Back to step 1 ──────────────┘
68
+ │ │
69
+ │ All stories pass? │
70
+ │ → <promise>COMPLETE</promise> │
71
+ └─────────────────────────────────┘
72
+ ```
73
+
74
+ ## Quick Start
75
+
76
+ ```bash
77
+ npx @graypark/ralph-codex --global
78
+ ```
79
+
80
+ Then in your AI coding session:
81
+
82
+ ```
83
+ /ralph-interview Add user authentication with JWT, bcrypt, and login UI
84
+ ```
85
+
86
+ That's it. The interview generates a PRD, activates the loop, and starts implementing story by story.
8
87
 
9
- ## Requirements
88
+ ## Features
10
89
 
11
- - **Node.js** 18+
12
- - **Codex CLI** v0.114+ or **Claude Code** (any version with plugin support)
90
+ | Feature | Description |
91
+ | ----------------------------- | -------------------------------------------------------------------------- |
92
+ | **PRD-driven loops** | `prd.json` + `progress.txt` — resumable, inspectable, git-friendly |
93
+ | **Interactive interview** | `/ralph-interview` asks targeted questions, generates optimized commands |
94
+ | **Multi-agent orchestration** | `/ralph-orchestrator` — 5 patterns for parallel work streams |
95
+ | **One story per iteration** | Focused context, clean commits, no context rot |
96
+ | **Cross-platform** | Node.js stop hook — Windows, macOS, Linux without WSL |
97
+ | **Ecosystem compatible** | Works with `ralph-skills:prd`, `ralph-skills:ralph`, official `ralph-loop` |
98
+ | **Stop & resume** | Stop anytime. Restart the same command — picks up where it left off |
13
99
 
14
100
  ## Installation
15
101
 
@@ -19,7 +105,7 @@ An AI agent works on a task in a continuous loop, seeing its own previous work e
19
105
  npx @graypark/ralph-codex --global
20
106
  ```
21
107
 
22
- ### Git clone
108
+ ### Clone & install
23
109
 
24
110
  ```bash
25
111
  git clone https://github.com/vcz-Gray/ralph-codex.git
@@ -27,19 +113,18 @@ cd ralph-codex
27
113
  node bin/install.mjs --global
28
114
  ```
29
115
 
30
- ### Options
116
+ | Flag | Description |
117
+ | ----------- | --------------------------------------- |
118
+ | `--global` | Install to `~/.codex/` (default) |
119
+ | `--local` | Install to `.codex/` in current project |
120
+ | `--dry-run` | Preview without changes |
121
+ | `--force` | Overwrite existing |
31
122
 
32
- | Flag | Description |
33
- | ----------- | ------------------------------------------------ |
34
- | `--global` | Install to `~/.codex/` or `~/.claude/` (default) |
35
- | `--local` | Install to `.codex/` in current project |
36
- | `--dry-run` | Preview changes without modifying anything |
37
- | `--force` | Overwrite existing installation |
38
-
39
- ### What Gets Installed
123
+ <details>
124
+ <summary>What gets installed</summary>
40
125
 
41
126
  ```
42
- ~/.codex/ (or ~/.claude/)
127
+ ~/.codex/
43
128
  ├── plugins/ralph-codex/ # Core plugin files
44
129
  ├── hooks.json # Stop hook (merged with existing)
45
130
  └── skills/
@@ -49,218 +134,148 @@ node bin/install.mjs --global
49
134
  └── ralph-orchestrator/ # /ralph-orchestrator — multi-agent patterns
50
135
  ```
51
136
 
137
+ </details>
138
+
52
139
  ## Commands
53
140
 
54
- ### `/ralph-interview` — Smart Command Generator
141
+ ### `/ralph-interview` — The Main Entry Point
55
142
 
56
- **The recommended way to start.** Interviews you about your task, evaluates whether subagents would help, then generates an optimized command.
143
+ Interviews you about your task, generates a PRD with right-sized stories, activates the loop, and starts working immediately.
57
144
 
58
145
  ```
59
- /ralph-interview
146
+ /ralph-interview Refactor auth module across frontend and backend
60
147
  ```
61
148
 
62
- 1. Describe your task
63
- 2. Answer 3–5 targeted questions (scope, verification, parallelism potential, etc.)
64
- 3. Get a ready-to-run command with phases, escape hatches, and orchestration
65
-
66
- **Auto-execute:** Add "run immediately" or "바로 실행" to start without confirmation:
149
+ **What happens:**
67
150
 
68
- ```
69
- /ralph-interview Refactor the auth module across 3 services, run immediately
70
- ```
151
+ 1. 3-5 targeted questions (scope, verification, parallelism, etc.)
152
+ 2. Generates `prd.json` with properly sized and ordered stories
153
+ 3. Writes `progress.txt` for iteration tracking
154
+ 4. Activates stop hook and starts implementing US-001
71
155
 
72
- **Multi-phase tasks:** The interview generates `.ralph/prd.md` + `.ralph/progress.md` files. The loop reads these each iteration to track phases and items:
156
+ **Quick-run** skip the "Ready?" prompt:
73
157
 
74
158
  ```
75
- .ralph/
76
- ├── prd.md # All phases and work items
77
- └── progress.md # What's done, what's next, what's blocked
159
+ /ralph-interview Add pagination to users API, run immediately
78
160
  ```
79
161
 
80
- The loop naturally transitions between phases by reading progress. Stop anytime — restart the same command and it picks up where it left off.
81
-
82
162
  ### `/ralph-orchestrator` — Multi-Agent Patterns
83
163
 
84
- Analyzes your task and recommends the best orchestration strategy:
164
+ Recommends the best execution strategy based on your task structure:
85
165
 
86
- | Pattern | Best For |
87
- | ------------------------------------------- | ------------------------------------------------- |
88
- | **Parallel Explore → Sequential Implement** | Large codebase research + targeted fixes |
89
- | **Divide by Ownership** | Multi-service changes (frontend + backend + auth) |
90
- | **Fan-Out / Fan-In** | Comprehensive audits (security + perf + a11y) |
91
- | **Scout-Then-Execute** | Unfamiliar codebases |
92
- | **Pipeline with Checkpoints** | Complex multi-stage transformations |
166
+ | Pattern | When to use |
167
+ | --------------------------------------- | ---------------------------------------- |
168
+ | Parallel Explore → Sequential Implement | Research across large codebase, then fix |
169
+ | Divide by Ownership | Multi-service changes (fe + be + auth) |
170
+ | Fan-Out / Fan-In | Parallel audits (security + perf + a11y) |
171
+ | Scout-Then-Execute | Unfamiliar codebase |
172
+ | Pipeline with Checkpoints | Multi-stage transformations |
93
173
 
94
- **Decision matrix**the orchestrator scores your task automatically:
174
+ ### `/ralph-loop`Direct Loop
95
175
 
96
- ```
97
- Files span 3+ directories → +2
98
- Items are independent → +2
99
- Multiple services/repos → +3
100
- 10+ similar items → +1
101
- Need full context → -2
102
- Order matters → -2
103
-
104
- Score >= 3 → Parallel subagents
105
- Score 0–2 → Sequential + optional scout
106
- Score < 0 → Single loop
107
- ```
108
-
109
- ### `/ralph-loop` — Run a Loop Directly
176
+ If you already have a PRD or want to write your own prompt:
110
177
 
111
178
  ```
112
- /ralph-loop "Build a REST API" --max-iterations 30 --completion-promise "ALL_TESTS_PASS"
179
+ /ralph-loop "Read prd.json, pick next story, implement, verify, commit" --max-iterations 20 --completion-promise "COMPLETE"
113
180
  ```
114
181
 
115
- | Parameter | Default | Description |
116
- | --------------------------- | ---------- | ------------------------------ |
117
- | `PROMPT` | (required) | Task description |
118
- | `--max-iterations N` | 20 | Max iterations (0 = unlimited) |
119
- | `--completion-promise TEXT` | "TADA" | Phrase that signals completion |
120
-
121
- ### `/cancel-ralph` — Stop the Loop
182
+ ### `/cancel-ralph` Stop
122
183
 
123
184
  ```
124
185
  /cancel-ralph
125
186
  ```
126
187
 
127
- ## How the Loop Works
128
-
129
- ```
130
- ┌─────────────────────────────────────────────┐
131
- │ /ralph-loop "Build feature X" │
132
- │ │
133
- ┌──────────┐ ┌──────────┐ │
134
- │ Agent │───▶│ Works │ │
135
- │ starts │ │ on task │ │
136
- └──────────┘ └────┬─────┘ │
137
- │ │ │
138
- │ ▼ │
139
- │ ┌──────────────┐ │
140
- │ │ Tries to exit │ │
141
- │ └───────┬──────┘ │
142
- │ │ │
143
- │ ▼ │
144
- │ ┌───────────────────┐ │
145
- │ │ Stop Hook │ │
146
- │ │ ┌───────────────┐ │ │
147
- │ │ │ Max reached? │─┼──Yes──▶ EXIT
148
- │ │ │ Promise found?│─┼──Yes──▶ EXIT
149
- │ │ └───────┬───────┘ │ │
150
- │ │ No │ │
151
- │ │ Block exit + │ │
152
- │ │ re-inject prompt │ │
153
- │ └─────────┬─────────┘ │
154
- │ │ │
155
- │ ┌──────────────┐ │
156
- │ │ Sees previous │──── loop ────┘
157
- │ │ work in files │
158
- │ └──────────────┘
188
+ ## PRD Format
189
+
190
+ ralph-codex uses the **ralph-skills compatible** `prd.json` format:
191
+
192
+ ```json
193
+ {
194
+ "project": "MyApp",
195
+ "branchName": "ralph/auth-system",
196
+ "description": "JWT authentication with login UI",
197
+ "userStories": [
198
+ {
199
+ "id": "US-001",
200
+ "title": "Add users table with password hash",
201
+ "description": "As a developer, I need user storage for auth",
202
+ "acceptanceCriteria": [
203
+ "Users table with email, password_hash columns",
204
+ "Migration runs successfully",
205
+ "Typecheck passes"
206
+ ],
207
+ "priority": 1,
208
+ "passes": false,
209
+ "notes": ""
210
+ }
211
+ ]
212
+ }
159
213
  ```
160
214
 
161
- ## Multi-Agent Orchestration Example
215
+ Each story is sized to complete in **one iteration** (one context window). Dependencies are ordered by priority.
162
216
 
163
- For a task like "audit and fix auth across frontend, backend, and auth-service":
217
+ ## Ecosystem Compatibility
164
218
 
165
- ```
166
- Phase 1 — Parallel Exploration (3 subagents):
167
- ├── Agent "fe-scan": Search frontend for auth issues → report
168
- ├── Agent "be-scan": Search backend for auth issues → report
169
- └── Agent "auth-scan": Search auth-service for issues → report
219
+ ralph-codex works seamlessly with existing Ralph tools:
170
220
 
171
- Phase 2 — Merge & Plan:
172
- └── Ralph Loop: Read all reports → create prioritized fix plan
221
+ | Tool | Compatibility |
222
+ | ---------------------------- | -------------------------------------------------------------------- |
223
+ | `ralph-skills:prd` | Same `prd.json` format — generate PRD there, loop here |
224
+ | `ralph-skills:ralph` | Same `progress.txt`, same `passes` tracking, same `COMPLETE` promise |
225
+ | Official `ralph-loop` plugin | PRD files work with either stop hook |
226
+ | `snarktank/ralph` | Compatible PRD structure and iteration pattern |
173
227
 
174
- Phase 3 — Parallel Implementation:
175
- ├── Agent "fe-dev" (worktree): Fix frontend items
176
- ├── Agent "be-dev" (worktree): Fix backend items
177
- └── Agent "auth-dev" (worktree): Fix auth-service items
228
+ ## Multi-Agent Orchestration
229
+
230
+ For tasks spanning multiple services or requiring broad exploration:
178
231
 
179
- Phase 4 — Integration:
180
- └── Ralph Loop: Merge branches → run full test suite → fix conflicts
181
232
  ```
233
+ Phase 1 — Parallel Scan (3 agents):
234
+ ├── Agent "fe-scan": Search frontend/** for auth gaps
235
+ ├── Agent "be-scan": Search backend/** for auth gaps
236
+ └── Agent "db-scan": Review schema for missing constraints
182
237
 
183
- The `/ralph-interview` skill generates this automatically when it detects multi-service scope.
238
+ Phase 2 Sequential Fix (ralph-loop):
239
+ └── Read merged findings → implement fixes story by story
240
+ ```
184
241
 
185
- ## Updating
242
+ The interview automatically evaluates parallelism potential using a scoring matrix.
186
243
 
187
- To update to the latest version:
244
+ ## Updating
188
245
 
189
246
  ```bash
190
247
  npx @graypark/ralph-codex --global --force
191
248
  ```
192
249
 
193
- Or if installed via git:
194
-
195
- ```bash
196
- cd ralph-codex
197
- git pull
198
- node bin/install.mjs --global --force
199
- ```
200
-
201
- ## Windows Support
202
-
203
- Works natively on Windows without WSL or Git Bash:
204
-
205
- - All paths use `path.join()` (no hardcoded slashes)
206
- - Installer copies files instead of symlinks on Windows
207
- - State files use JSON (no Unix-specific formats)
208
- - Hooks use `node` as the interpreter (cross-platform)
209
-
210
- ## Uninstall
250
+ ## Uninstalling
211
251
 
212
252
  ```bash
213
253
  npx @graypark/ralph-codex uninstall
214
254
  ```
215
255
 
216
- ## Claude Code Plugin
217
-
218
- This package includes a `.claude-plugin/plugin.json` manifest for Claude Code marketplace compatibility. To use as a Claude Code plugin:
219
-
220
- 1. Clone the repo to your machine
221
- 2. In Claude Code, reference the plugin directory
222
- 3. Skills (`ralph-interview`, `ralph-orchestrator`, etc.) will be auto-discovered
223
-
224
256
  ## Architecture
225
257
 
226
258
  ```
227
259
  ralph-codex/
228
- ├── .claude-plugin/
229
- │ └── plugin.json # Claude Code marketplace manifest
260
+ ├── .claude-plugin/plugin.json # Claude Code marketplace manifest
230
261
  ├── bin/
231
- │ ├── install.mjs # Cross-platform installer
232
- │ └── uninstall.mjs # Clean uninstaller
262
+ │ ├── install.mjs # Cross-platform installer
263
+ │ └── uninstall.mjs # Clean uninstaller
233
264
  ├── hooks/
234
- ├── hooks.json # Hook registration (reference)
235
- │ └── stop-hook.mjs # Stop hook — core loop engine
265
+ └── stop-hook.mjs # Core loop engine (Node.js)
236
266
  ├── commands/
237
- │ ├── ralph-loop.md # /ralph-loop command
238
- │ └── cancel-ralph.md # /cancel-ralph command
267
+ │ ├── ralph-loop.md # /ralph-loop command
268
+ │ └── cancel-ralph.md # /cancel-ralph command
239
269
  ├── skills/
240
- │ ├── ralph-interview/
241
- └── SKILL.md # Interactive command generator
242
- │ └── ralph-orchestrator/
243
- │ └── SKILL.md # Multi-agent orchestration patterns
270
+ │ ├── ralph-interview/SKILL.md # Interactive command generator
271
+ │ └── ralph-orchestrator/SKILL.md # Multi-agent patterns
244
272
  ├── lib/
245
- │ ├── paths.mjs # Cross-platform path utilities
246
- │ ├── state.mjs # Loop state management
247
- │ └── stop-hook-core.mjs # Testable stop hook logic
248
- ├── tests/ # 32 test cases (vitest)
249
- └── package.json
273
+ │ ├── paths.mjs # Cross-platform paths
274
+ │ ├── state.mjs # Loop state management
275
+ │ └── stop-hook-core.mjs # Testable hook logic
276
+ └── tests/ # 32 test cases (vitest)
250
277
  ```
251
278
 
252
- ## Comparison
253
-
254
- | Feature | Claude Code (official) | Codex CLI (builtin) | ralph-codex (this) |
255
- | ---------------------- | ---------------------- | ------------------- | ------------------------ |
256
- | Runtime | Bash (sh/perl) | Rust | Node.js (cross-platform) |
257
- | Windows | WSL required | Experimental | Native |
258
- | Hook protocol | JSON | JSON | Same |
259
- | Command generator | None | None | `/ralph-interview` |
260
- | Multi-agent | Manual | Experimental | `/ralph-orchestrator` |
261
- | Orchestration patterns | None | None | 5 built-in patterns |
262
- | Plugin format | `.claude-plugin` | `.codex/skills` | Both |
263
-
264
279
  ## Development
265
280
 
266
281
  ```bash
@@ -272,3 +287,9 @@ npx vitest # watch mode
272
287
  ## License
273
288
 
274
289
  MIT
290
+
291
+ ---
292
+
293
+ <p align="center">
294
+ Built for <a href="https://github.com/openai/codex">Codex CLI</a> and <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>
295
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graypark/ralph-codex",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "description": "Ralph Loop for Codex CLI & Claude Code — iterative dev loops with multi-agent orchestration, interactive interview, and stop hooks",
6
6
  "license": "MIT",
@@ -181,6 +181,7 @@ The `## Codebase Patterns` section at the top is read first by each iteration to
181
181
  - **No oversized stories**: Each story must be completable in ONE iteration. Split if too big.
182
182
  - **Always use prd.json format**: Ensures compatibility with ralph-skills ecosystem.
183
183
  - **Default promise is COMPLETE**: Use `<promise>COMPLETE</promise>` to match ralph-skills convention.
184
+ - **Always overwrite**: Never ask before overwriting prd.json or progress.txt. Just write them.
184
185
 
185
186
  ## Conversation Flow
186
187
 
@@ -202,6 +203,8 @@ Skip the "Ready?" prompt. Go straight to activation after showing the PRD briefl
202
203
 
203
204
  When the user confirms (or quick-run), execute ALL of these steps in a SINGLE response. Do NOT stop between steps.
204
205
 
206
+ IMPORTANT: Always overwrite existing prd.json and progress.txt without asking. Do NOT check if they exist. Do NOT ask the user for confirmation before overwriting. Do NOT archive old files. Just write them.
207
+
205
208
  ### Step 1: Write prd.json via Bash
206
209
 
207
210
  ```bash