@graypark/ralph-codex 0.6.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graypark/ralph-codex",
3
- "version": "0.6.0",
3
+ "version": "0.7.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",
@@ -1,22 +1,22 @@
1
1
  ---
2
2
  name: ralph-interview
3
- description: "Interactive interview that generates optimized /ralph-loop commands with PRD-based phase tracking"
3
+ description: "Interactive interview that generates optimized ralph-loop commands with PRD-based phase tracking. Compatible with ralph-skills prd.json format."
4
4
  ---
5
5
 
6
6
  # Ralph Interview — Command Generator
7
7
 
8
- You are an expert at crafting `/ralph-loop:ralph-loop` commands for the Ralph Loop plugin.
9
- When the user describes a task, conduct a brief interview to gather missing context, then generate a PRD + progress file pair and a single ralph-loop command.
8
+ You are an expert at crafting ralph-loop commands for the Ralph Loop plugin.
9
+ When the user describes a task, conduct a brief interview to gather missing context, then generate a PRD, activate the loop, and start working immediately.
10
10
 
11
11
  ## Core Principles
12
12
 
13
- - **PRD-driven**: All phases and items live in `.ralph/prd.md`. The loop prompt reads it each iteration.
14
- - **Progress tracking**: `.ralph/progress.md` tracks what's done. Each iteration reads it to decide what's next.
15
- - **Self-correcting loops**: Every prompt embeds "modify, verify, retry on failure" cycles.
13
+ - **PRD-driven**: All phases and items live in prd.json. The loop reads it each iteration.
14
+ - **Progress tracking**: progress.txt tracks what is done. Each iteration reads it to decide what is next.
15
+ - **One story per iteration**: Each loop iteration implements ONE user story, commits, and updates progress.
16
+ - **Self-correcting**: Every prompt embeds "modify, verify, retry on failure" cycles.
16
17
  - **Escape hatches required**: Always specify what to do when stuck after N retries.
17
- - **Atomic commits**: Instruct a git commit per logical work unit.
18
18
  - **Objective completion criteria only**: No subjective criteria. Use test passes, linter clears, etc.
19
- - **Parallel when possible**: Use the ralph-orchestrator patterns for independent work streams.
19
+ - **Parallel when possible**: Use ralph-orchestrator patterns for independent work streams.
20
20
 
21
21
  ## Interview Process
22
22
 
@@ -76,202 +76,201 @@ Evaluate the task against the ralph-orchestrator decision matrix:
76
76
  | TDD-based feature implementation | 15-30 |
77
77
  | Full refactor / migration | 30-50 |
78
78
 
79
- **Rule of thumb:** `item_count x 2 + 5` as baseline.
80
-
81
- ## PRD + Progress Pattern
82
-
83
- This is the core mechanism for multi-phase work. Instead of embedding all phases in one prompt or chaining state files, generate two files that the loop reads each iteration.
84
-
85
- ### .ralph/prd.md
86
-
87
- Contains all phases and work items:
88
-
89
- ```markdown
90
- # PRD: [Task Title]
91
-
92
- ## Phase 1: [Phase Name]
93
-
94
- - [ ] Item 1 description
95
- - [ ] Item 2 description
96
- - [ ] Item 3 description
97
-
98
- ## Phase 2: [Phase Name]
99
-
100
- - [ ] Item 4 description
101
- - [ ] Item 5 description
102
-
103
- ## Completion Criteria
104
-
105
- - [Objective condition 1]
106
- - [Objective condition 2]
107
- - [Verification command] passes
79
+ **Rule of thumb:** `story_count x 2 + 5` as baseline.
80
+
81
+ ## PRD Format: prd.json (ralph-skills compatible)
82
+
83
+ Generate PRDs in the **prd.json** format used by ralph-skills. This ensures compatibility with `/ralph-skills:ralph` and `/ralph-skills:prd`.
84
+
85
+ ### prd.json
86
+
87
+ ```json
88
+ {
89
+ "project": "[Project Name]",
90
+ "branchName": "ralph/[feature-name]",
91
+ "description": "[Feature description]",
92
+ "userStories": [
93
+ {
94
+ "id": "US-001",
95
+ "title": "[Story title]",
96
+ "description": "As a [user], I want [feature] so that [benefit]",
97
+ "acceptanceCriteria": [
98
+ "Specific verifiable criterion",
99
+ "Another criterion",
100
+ "Typecheck passes"
101
+ ],
102
+ "priority": 1,
103
+ "passes": false,
104
+ "notes": ""
105
+ }
106
+ ]
107
+ }
108
108
  ```
109
109
 
110
- ### .ralph/progress.md
110
+ ### Story Sizing Rules
111
111
 
112
- Updated by the loop after each completed item:
112
+ Each story MUST be completable in ONE iteration (one context window):
113
113
 
114
- ```markdown
115
- # Progress
114
+ - **Right-sized**: Add a DB column, create one component, update one endpoint
115
+ - **Too big (split)**: "Build entire dashboard", "Add authentication", "Refactor API"
116
+ - **Rule of thumb**: If you cannot describe the change in 2-3 sentences, split it
116
117
 
117
- ## Completed
118
+ ### Story Ordering
118
119
 
119
- - [x] Item 1 commit abc1234
120
- - [x] Item 2 — commit def5678
120
+ Stories execute in priority order. Dependencies first:
121
121
 
122
- ## Current Phase
122
+ 1. Schema/database changes
123
+ 2. Backend logic / server actions
124
+ 3. UI components that use the backend
125
+ 4. Aggregation views / dashboards
123
126
 
124
- Phase 1: [Phase Name]
127
+ ### Acceptance Criteria Rules
125
128
 
126
- ## Blocked
129
+ - MUST be verifiable, not vague
130
+ - Always include: `"Typecheck passes"` (or equivalent verification)
131
+ - For UI stories: add `"Verify in browser"` or equivalent
132
+ - Bad: "Works correctly", "Good UX"
133
+ - Good: "Button shows confirmation dialog before deleting", "Filter persists in URL params"
127
134
 
128
- (none)
135
+ ### progress.txt
129
136
 
130
- ## Next
137
+ An append-only log file that tracks iteration history:
131
138
 
132
- Item 3
133
139
  ```
140
+ ## Codebase Patterns
141
+ - [Reusable patterns discovered during iteration]
134
142
 
135
- ### The Loop Prompt
136
-
137
- The ralph-loop prompt is always the same structure:
143
+ ---
138
144
 
139
- ```
140
- /ralph-loop:ralph-loop "## Instructions
141
- 1. Read .ralph/prd.md for the full task plan
142
- 2. Read .ralph/progress.md for current status
143
- 3. Pick the next incomplete item (first unchecked item in current phase)
144
- 4. If current phase is complete, advance to next phase and update progress
145
- 5. Implement the item
146
- 6. Run verification: [command]
147
- 7. On failure: read error, fix, retry (max 3 times per item)
148
- 8. On success: update .ralph/progress.md (mark item done, note commit hash)
149
- 9. git add -A && git commit -m '[convention]: [item description]'
150
- 10. If ALL items in ALL phases are done and verification passes, output <promise>TADA</promise>
151
-
152
- ## When Stuck
153
- After 3 retries on any item:
154
- - Add it to Blocked section in .ralph/progress.md with error details
155
- - Move to next item
156
- - Document in .ralph/progress.md
157
-
158
- ## References
159
- [list of reference files]
160
-
161
- ## Verification
162
- [verification command]" --max-iterations [N] --completion-promise "TADA"
145
+ ## [Date] - US-001
146
+ - What was implemented
147
+ - Files changed
148
+ - **Learnings for future iterations:**
149
+ - Patterns discovered
150
+ - Gotchas encountered
151
+ ---
163
152
  ```
164
153
 
165
- ### Why This Works
154
+ The `## Codebase Patterns` section at the top is read first by each iteration to avoid repeating mistakes.
166
155
 
167
- - **Resumable**: Stop anytime. Progress is on disk. Restart the same command and it picks up where it left off.
168
- - **Inspectable**: Open `.ralph/progress.md` to see exactly what's done and what's next.
169
- - **Phase transitions are natural**: The agent reads the PRD, sees Phase 1 is done, moves to Phase 2.
170
- - **No state file conflicts**: The ralph-loop state file only manages the loop itself, not the task.
171
- - **Fresh context each iteration**: Agent re-reads PRD and progress, no context rot.
156
+ ## Compatibility with Existing Skills
172
157
 
173
- ## Output Format
158
+ ### ralph-skills:prd (marketplace)
174
159
 
175
- Structure the final output as:
160
+ - Our prd.json output uses the EXACT same format
161
+ - User can generate PRD with `/ralph-skills:prd`, then use our interview to generate the loop command
162
+ - Or use our interview to generate both PRD and loop command
176
163
 
177
- 1. **Task summary** — One paragraph describing the overall work.
178
- 2. **PRD preview** — Show the .ralph/prd.md content.
179
- 3. **Loop command** — The single ralph-loop command to run.
180
- 4. **Execution prompt** — Ask how to proceed.
164
+ ### ralph-skills:ralph (marketplace)
181
165
 
182
- ### Example Output
183
-
184
- ```
185
- ## Task Summary
186
- Fix 3 P1 + 7 P2 responsive issues based on the audit report.
166
+ - Our loop prompt follows the same pattern as ralph-skills prompt.md
167
+ - Same prd.json format, same progress.txt format
168
+ - Same `passes: true/false` tracking, same commit convention
169
+ - Same `<promise>COMPLETE</promise>` completion signal
187
170
 
188
- ## PRD (.ralph/prd.md)
189
- # PRD: Responsive Fixes
190
- ## Phase 1: P1 Critical
191
- - [ ] Fix header overflow on mobile
192
- - [ ] Fix nav collapse breakpoint
193
- - [ ] Fix card grid stacking
171
+ ### Official ralph-loop plugin (claude-plugins-official)
194
172
 
195
- ## Phase 2: P2 Important
196
- - [ ] Adjust sidebar width at 768px
197
- ...
198
-
199
- ## Command
200
- ` ` `
201
- /ralph-loop:ralph-loop "..." --max-iterations 25 --completion-promise "TADA"
202
- ` ` `
203
-
204
- ---
205
- **Ready to run?**
206
- - **y** → Write PRD + progress files and start the loop
207
- - **n** → Files and command are above, set up manually
208
- - **edit** → Tell me what to change
209
- ```
173
+ - If the official plugin is installed, this interview works with its stop hook
174
+ - PRD and progress files work with either stop hook
210
175
 
211
176
  ## Rules
212
177
 
213
178
  - **No subjective completion criteria**: Banned phrases: "works well", "looks clean", "properly done."
214
- - **No prompt without verification**: At least one automated check (tsc, test, lint, build) is mandatory.
179
+ - **No prompt without verification**: At least one automated check is mandatory.
215
180
  - **No missing escape hatch**: Every prompt MUST have a "When Stuck" section.
216
- - **No oversized single Phase**: Do not put more than 8 independent items in one Phase. Split them.
217
- - **Always generate .ralph/prd.md and .ralph/progress.md**: These are mandatory for multi-phase tasks.
181
+ - **No oversized stories**: Each story must be completable in ONE iteration. Split if too big.
182
+ - **Always use prd.json format**: Ensures compatibility with ralph-skills ecosystem.
183
+ - **Default promise is COMPLETE**: Use `<promise>COMPLETE</promise>` to match ralph-skills convention.
218
184
 
219
185
  ## Conversation Flow
220
186
 
221
- ### Standard Flow
222
-
223
187
  ```
224
- [User] -> Describes the task
225
- [Assistant] -> Asks interview questions (1 round, max 5 questions)
188
+ [User] -> /ralph-interview "build X feature"
189
+ [Assistant] -> Interview questions (1 round, skip if context is sufficient)
226
190
  [User] -> Answers
227
- [Assistant] -> Generates PRD + command + asks "Ready to run?"
191
+ [Assistant] -> Shows PRD briefly, asks "Ready?"
228
192
  [User] -> "y"
229
- [Assistant] -> Writes .ralph/ files via Bash, then invokes ralph-loop skill
193
+ [Assistant] -> Writes files + activates loop + starts US-001 IN THE SAME RESPONSE
230
194
  ```
231
195
 
232
- ### Quick-Run Flow
196
+ ### Quick-Run
233
197
 
234
198
  If the user includes "run immediately", "just do it", "run it", "바로 실행", "바로 시작", or "--run":
199
+ Skip the "Ready?" prompt. Go straight to activation after showing the PRD briefly.
235
200
 
236
- 1. Conduct the interview (skip if enough context).
237
- 2. Generate PRD + command. Show briefly.
238
- 3. Write .ralph/prd.md and .ralph/progress.md via Bash tool.
239
- 4. Invoke ralph-loop skill immediately. Do NOT stop after step 3.
240
-
241
- ### Execution — MANDATORY SKILL INVOCATION
201
+ ## Activation Sequence
242
202
 
243
- When the user confirms with "y", "yes", "run", etc., you MUST:
203
+ When the user confirms (or quick-run), execute ALL of these steps in a SINGLE response. Do NOT stop between steps.
244
204
 
245
- 1. Create .ralph/ directory and write prd.md + progress.md via Bash tool
246
- 2. Actually invoke the ralph-loop skill to start the loop
205
+ ### Step 1: Write prd.json via Bash
247
206
 
248
- WRONG (do NOT do this):
207
+ ```bash
208
+ cat > prd.json << 'EOF'
209
+ { ... generated PRD ... }
210
+ EOF
211
+ ```
249
212
 
250
- - Printing the command as text and stopping
251
- - Writing files and saying "ready" or "set up"
252
- - Telling the user to copy-paste
213
+ ### Step 2: Write progress.txt via Bash
253
214
 
254
- RIGHT (you MUST do this):
215
+ ```bash
216
+ cat > progress.txt << 'EOF'
217
+ ## Codebase Patterns
218
+ (none yet)
219
+ EOF
220
+ ```
255
221
 
256
- - Write the .ralph/ files via Bash
257
- - Then invoke ralph-loop skill so the loop actually starts
222
+ ### Step 3: Activate the stop hook via Bash
258
223
 
259
- #### How to invoke ralph-loop
224
+ Write the ralph-loop state file that makes the stop hook intercept session exits:
260
225
 
261
- **Claude Code**: Use the Skill tool:
226
+ ```bash
227
+ mkdir -p .claude
228
+ cat > .claude/ralph-loop.local.md << 'EOF'
229
+ ---
230
+ active: true
231
+ iteration: 1
232
+ session_id:
233
+ max_iterations: <N>
234
+ completion_promise: "COMPLETE"
235
+ started_at: "<now>"
236
+ ---
262
237
 
263
- ```
264
- Skill tool call:
265
- skill: "ralph-loop:ralph-loop"
266
- args: "<prompt>" --max-iterations <N> --completion-promise "TADA"
238
+ Read prd.json for task plan. Read progress.txt for status (Codebase Patterns first).
239
+ Check correct branch from branchName. If not on it, create from main.
240
+ Pick highest priority story where passes is false.
241
+ Implement that ONE story.
242
+ Run verification: <command>.
243
+ On failure: fix and retry, max 3 times.
244
+ On success: commit 'feat: [Story ID] - [Title]'.
245
+ Update prd.json: set passes to true. Append to progress.txt with learnings.
246
+ If ALL stories pass: <promise>COMPLETE</promise>.
247
+ When stuck: set notes in prd.json, skip to next story.
248
+ EOF
267
249
  ```
268
250
 
269
- **Codex CLI**: Reference the skill via markdown link:
251
+ ### Step 4: START WORKING ON US-001 IMMEDIATELY
270
252
 
271
- ```
272
- [$ralph-loop](~/.codex/skills/ralph-loop/SKILL.md) "<prompt>" --max-iterations <N> --completion-promise "TADA"
273
- ```
253
+ This is the critical step. After writing files, you MUST begin actual work in the SAME response:
254
+
255
+ 1. Read the prd.json you just wrote
256
+ 2. Create/checkout the branch from branchName
257
+ 3. Pick the first story (US-001)
258
+ 4. Implement it — write real code, make real changes
259
+ 5. Run the verification command
260
+ 6. Commit the changes
261
+ 7. Update prd.json (set passes: true)
262
+ 8. Append to progress.txt
263
+
264
+ Do NOT:
265
+
266
+ - Say "loop is now active" and stop
267
+ - Say "starting work on US-001" and stop
268
+ - Print a summary and wait for user input
269
+ - Ask if the user wants to proceed
274
270
 
275
- Note: On Windows use `%USERPROFILE%\.codex\skills\ralph-loop\SKILL.md`. If CODEX_HOME is set, use that.
271
+ DO:
276
272
 
277
- If you do not actually invoke the skill, the loop will not start.
273
+ - Actually write code
274
+ - Actually run tests
275
+ - Actually commit
276
+ - The stop hook will handle continuation to US-002 when you finish