@canivel/ralph 0.2.0 → 0.2.3

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.
Files changed (39) hide show
  1. package/.agents/ralph/PROMPT_build.md +126 -126
  2. package/.agents/ralph/agents.sh +17 -15
  3. package/.agents/ralph/config.sh +25 -25
  4. package/.agents/ralph/log-activity.sh +15 -15
  5. package/.agents/ralph/loop.sh +1027 -1001
  6. package/.agents/ralph/references/CONTEXT_ENGINEERING.md +126 -126
  7. package/.agents/ralph/references/GUARDRAILS.md +174 -174
  8. package/AGENTS.md +20 -20
  9. package/README.md +270 -266
  10. package/bin/ralph +766 -765
  11. package/diagram.svg +55 -55
  12. package/examples/commands.md +46 -46
  13. package/package.json +39 -39
  14. package/skills/commit/SKILL.md +219 -219
  15. package/skills/commit/references/commit_examples.md +292 -292
  16. package/skills/dev-browser/SKILL.md +211 -211
  17. package/skills/dev-browser/bun.lock +443 -443
  18. package/skills/dev-browser/package-lock.json +2988 -2988
  19. package/skills/dev-browser/package.json +31 -31
  20. package/skills/dev-browser/references/scraping.md +155 -155
  21. package/skills/dev-browser/scripts/start-relay.ts +32 -32
  22. package/skills/dev-browser/scripts/start-server.ts +117 -117
  23. package/skills/dev-browser/server.sh +24 -24
  24. package/skills/dev-browser/src/client.ts +474 -474
  25. package/skills/dev-browser/src/index.ts +287 -287
  26. package/skills/dev-browser/src/relay.ts +731 -731
  27. package/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -223
  28. package/skills/dev-browser/src/snapshot/browser-script.ts +877 -877
  29. package/skills/dev-browser/src/snapshot/index.ts +14 -14
  30. package/skills/dev-browser/src/snapshot/inject.ts +13 -13
  31. package/skills/dev-browser/src/types.ts +34 -34
  32. package/skills/dev-browser/tsconfig.json +36 -36
  33. package/skills/dev-browser/vitest.config.ts +12 -12
  34. package/skills/prd/SKILL.md +235 -235
  35. package/tests/agent-loops.mjs +79 -79
  36. package/tests/agent-ping.mjs +39 -39
  37. package/tests/audit.md +56 -56
  38. package/tests/cli-smoke.mjs +47 -47
  39. package/tests/real-agents.mjs +127 -127
package/README.md CHANGED
@@ -1,266 +1,270 @@
1
- # Ralph
2
-
3
- ![Ralph](ralph.webp)
4
-
5
- Ralph is a minimal, file-based agent loop for autonomous coding. Each iteration starts fresh, reads the same on-disk state, and commits work for one story at a time.
6
-
7
- > **Fork Note:** This is a fork of [@iannuttall/ralph](https://github.com/iannuttall/ralph) with improved agent support and first-run configuration.
8
-
9
- ## What's New in This Fork
10
-
11
- - **First-run agent selection** - Prompted to choose your default agent on first use
12
- - **`ralph config` command** - Reconfigure your default agent anytime
13
- - **Improved Claude support** - Direct spawning with proper TTY handling for PRD generation
14
- - **Better Windows compatibility** - Fixed shell quoting issues
15
- - **Global config storage** - Settings persist in `~/.ralph/config.json`
16
-
17
- ## How It Works
18
-
19
- Ralph treats **files and git** as memory, not the model context:
20
-
21
- - **PRD (JSON)** - Defines stories, quality gates, and status
22
- - **Loop** - Executes one story per iteration
23
- - **State** - Persists in `.ralph/` directory
24
-
25
- ![Ralph architecture](diagram.svg)
26
-
27
- ## Installation
28
-
29
- ### From npm (recommended)
30
-
31
- ```bash
32
- npm i -g @canivel/ralph
33
- ```
34
-
35
- ### From source
36
-
37
- ```bash
38
- git clone https://github.com/canivel/ralph.git
39
- cd ralph
40
- npm install
41
- npm link
42
- ```
43
-
44
- ### Prerequisites
45
-
46
- You need at least one AI agent CLI installed:
47
-
48
- | Agent | Install Command |
49
- |-------|-----------------|
50
- | Claude | `curl -fsSL https://claude.ai/install.sh \| bash` |
51
- | Codex | `npm i -g @openai/codex` |
52
- | Droid | `curl -fsSL https://app.factory.ai/cli \| sh` |
53
- | OpenCode | `curl -fsSL https://opencode.ai/install.sh \| bash` |
54
-
55
- ## Quick Start
56
-
57
- ```bash
58
- # 1. Navigate to your project
59
- cd my-project
60
-
61
- # 2. Generate a PRD (first run prompts for agent selection)
62
- ralph prd "A task management app with projects and due dates"
63
-
64
- # 3. Build one story at a time
65
- ralph build 1
66
- ```
67
-
68
- On first run, you'll see the agent selection prompt:
69
-
70
- ```
71
- Ralph Configuration
72
- ? Select your default agent
73
- > claude (Anthropic Claude CLI)
74
- codex (OpenAI Codex CLI)
75
- droid (Factory Droid CLI)
76
- opencode (OpenCode CLI)
77
- ```
78
-
79
- ## Commands
80
-
81
- | Command | Description |
82
- |---------|-------------|
83
- | `ralph prd ["<request>"]` | Generate a PRD JSON file via agent |
84
- | `ralph build [n]` | Run n build iterations (default: continuous) |
85
- | `ralph config` | Configure or change default agent |
86
- | `ralph install` | Copy templates to current repo for customization |
87
- | `ralph install --skills` | Install required skills (commit, dev-browser, prd) |
88
- | `ralph overview` | Generate human-readable overview from PRD |
89
- | `ralph ping` | Health check for agent connectivity |
90
- | `ralph log "<message>"` | Append to activity log |
91
- | `ralph help` | Show help message |
92
-
93
- ### Options
94
-
95
- | Option | Description |
96
- |--------|-------------|
97
- | `--agent <name>` | Override agent (codex, claude, droid, opencode) |
98
- | `--prd <path>` | Override PRD file path |
99
- | `--out <path>` | Override PRD output path (for `prd` command) |
100
- | `--progress <path>` | Override progress log path |
101
- | `--no-commit` | Dry run without committing (for `build` command) |
102
- | `--force` | Force overwrite (for `install` command) |
103
-
104
- ## Usage Examples
105
-
106
- ### Generate a PRD
107
-
108
- ```bash
109
- # Interactive mode - prompts for description
110
- ralph prd
111
-
112
- # Direct mode - pass description as argument
113
- ralph prd "A REST API for user authentication with JWT tokens"
114
-
115
- # Specify output path
116
- ralph prd --out .agents/tasks/prd-auth.json "Auth API"
117
- ```
118
-
119
- ### Build Stories
120
-
121
- ```bash
122
- # Build one story
123
- ralph build 1
124
-
125
- # Build 5 stories
126
- ralph build 5
127
-
128
- # Dry run (no commits)
129
- ralph build 1 --no-commit
130
-
131
- # Use specific PRD file
132
- ralph build 1 --prd .agents/tasks/prd-auth.json
133
-
134
- # Override agent for this run
135
- ralph build 1 --agent codex
136
- ```
137
-
138
- ### Configuration
139
-
140
- ```bash
141
- # Change default agent
142
- ralph config
143
-
144
- # Install templates for customization
145
- ralph install
146
-
147
- # Install skills (commit, dev-browser, prd)
148
- ralph install --skills
149
- ```
150
-
151
- ## Configuration
152
-
153
- ### Global Config
154
-
155
- Ralph stores global settings in `~/.ralph/config.json`:
156
-
157
- ```json
158
- {
159
- "defaultAgent": "claude",
160
- "configuredAt": "2026-01-19T12:00:00.000Z"
161
- }
162
- ```
163
-
164
- To change your default agent:
165
-
166
- ```bash
167
- ralph config
168
- ```
169
-
170
- ### Project Config
171
-
172
- After running `ralph install`, you can customize behavior in `.agents/ralph/config.sh`:
173
-
174
- ```bash
175
- # Override agent command
176
- AGENT_CMD="claude -p --dangerously-skip-permissions \"\$(cat {prompt})\""
177
-
178
- # Build settings
179
- NO_COMMIT=false
180
- MAX_ITERATIONS=25
181
- STALE_SECONDS=0
182
- ```
183
-
184
- ## Template Hierarchy
185
-
186
- Ralph looks for templates in this order:
187
-
188
- 1. `.agents/ralph/` in current project (if present)
189
- 2. Bundled defaults from the package
190
-
191
- State and logs always go to `.ralph/` in the project.
192
-
193
- ## PRD Story Status
194
-
195
- The build loop automatically updates story status:
196
-
197
- | Status | Meaning |
198
- |--------|---------|
199
- | `open` | Available for selection |
200
- | `in_progress` | Currently being worked on (with `startedAt`) |
201
- | `done` | Completed (with `completedAt`) |
202
-
203
- If a loop crashes while a story is `in_progress`, set `STALE_SECONDS` in config to auto-reopen stalled stories.
204
-
205
- ## State Files
206
-
207
- All state is stored in `.ralph/` in your project:
208
-
209
- | File | Purpose |
210
- |------|---------|
211
- | `progress.md` | Append-only progress log |
212
- | `guardrails.md` | Lessons learned ("Signs") |
213
- | `activity.log` | Activity and timing log |
214
- | `errors.log` | Repeated failures and notes |
215
- | `runs/` | Raw run logs and summaries |
216
-
217
- ## Advanced
218
-
219
- ### Multiple PRD Files
220
-
221
- If you have multiple PRD JSON files in `.agents/tasks/` and don't specify `--prd`, Ralph will prompt you to choose.
222
-
223
- ### OpenCode Server Mode
224
-
225
- For faster performance with OpenCode, run `opencode serve` in a separate terminal and uncomment the server mode lines in `.agents/ralph/agents.sh`:
226
-
227
- ```bash
228
- AGENT_OPENCODE_CMD="opencode run --attach http://localhost:4096 \"\$(cat {prompt})\""
229
- ```
230
-
231
- ### Custom Agent Commands
232
-
233
- Use `{prompt}` placeholder when the agent needs a file path instead of stdin:
234
-
235
- ```bash
236
- AGENT_CMD="my-agent --file {prompt}"
237
- ```
238
-
239
- ## Development
240
-
241
- ### Running Tests
242
-
243
- ```bash
244
- # Dry-run smoke tests (no agent required)
245
- npm test
246
-
247
- # Fast agent health check
248
- npm run test:ping
249
-
250
- # Integration tests (requires agents)
251
- RALPH_INTEGRATION=1 npm test
252
-
253
- # Full real-agent loop test
254
- npm run test:real
255
- ```
256
-
257
- ### Publishing
258
-
259
- ```bash
260
- npm login
261
- npm publish --access public
262
- ```
263
-
264
- ## License
265
-
266
- MIT
1
+ # Ralph
2
+
3
+ ![Ralph](ralph.webp)
4
+
5
+ Ralph is a minimal, file-based agent loop for autonomous coding. Each iteration starts fresh, reads the same on-disk state, and commits work for one story at a time.
6
+
7
+ > **Fork Note:** This is a fork of [@iannuttall/ralph](https://github.com/iannuttall/ralph) with improved agent support and first-run configuration.
8
+
9
+ ## What's New in This Fork
10
+
11
+ - **First-run agent selection** - Prompted to choose your default agent on first use
12
+ - **`ralph config` command** - Reconfigure your default agent anytime
13
+ - **Improved Claude support** - Uses stdin mode (`-p -`) for reliable prompt passing
14
+ - **Better Windows compatibility** - Fixed shell quoting and Python detection
15
+ - **Global config storage** - Settings persist in `~/.ralph/config.json`
16
+
17
+ ## How It Works
18
+
19
+ Ralph treats **files and git** as memory, not the model context:
20
+
21
+ - **PRD (JSON)** - Defines stories, quality gates, and status
22
+ - **Loop** - Executes one story per iteration
23
+ - **State** - Persists in `.ralph/` directory
24
+
25
+ ![Ralph architecture](diagram.svg)
26
+
27
+ ## Installation
28
+
29
+ ### From npm (recommended)
30
+
31
+ ```bash
32
+ npm i -g @canivel/ralph
33
+ ```
34
+
35
+ ### From source
36
+
37
+ ```bash
38
+ git clone https://github.com/canivel/ralph.git
39
+ cd ralph
40
+ npm install
41
+ npm link
42
+ ```
43
+
44
+ ### Prerequisites
45
+
46
+ You need at least one AI agent CLI installed:
47
+
48
+ | Agent | Install Command |
49
+ |-------|-----------------|
50
+ | Claude | `curl -fsSL https://claude.ai/install.sh \| bash` |
51
+ | Codex | `npm i -g @openai/codex` |
52
+ | Droid | `curl -fsSL https://app.factory.ai/cli \| sh` |
53
+ | OpenCode | `curl -fsSL https://opencode.ai/install.sh \| bash` |
54
+
55
+ ## Quick Start
56
+
57
+ ```bash
58
+ # 1. Navigate to your project
59
+ cd my-project
60
+
61
+ # 2. Generate a PRD (first run prompts for agent selection)
62
+ ralph prd "A task management app with projects and due dates"
63
+
64
+ # 3. Build one story at a time
65
+ ralph build 1
66
+ ```
67
+
68
+ On first run, you'll see the agent selection prompt:
69
+
70
+ ```
71
+ Ralph Configuration
72
+ ? Select your default agent
73
+ > claude (Anthropic Claude CLI)
74
+ codex (OpenAI Codex CLI)
75
+ droid (Factory Droid CLI)
76
+ opencode (OpenCode CLI)
77
+ ```
78
+
79
+ ## Commands
80
+
81
+ | Command | Description |
82
+ |---------|-------------|
83
+ | `ralph prd ["<request>"]` | Generate a PRD JSON file via agent |
84
+ | `ralph build [n]` | Run n build iterations (default: continuous) |
85
+ | `ralph config` | Configure or change default agent |
86
+ | `ralph install` | Copy templates to current repo for customization |
87
+ | `ralph install --skills` | Install required skills (commit, dev-browser, prd) |
88
+ | `ralph overview` | Generate human-readable overview from PRD |
89
+ | `ralph ping` | Health check for agent connectivity |
90
+ | `ralph log "<message>"` | Append to activity log |
91
+ | `ralph help` | Show help message |
92
+
93
+ ### Options
94
+
95
+ | Option | Description |
96
+ |--------|-------------|
97
+ | `--agent <name>` | Override agent (codex, claude, droid, opencode) |
98
+ | `--prd <path>` | Override PRD file path |
99
+ | `--out <path>` | Override PRD output path (for `prd` command) |
100
+ | `--progress <path>` | Override progress log path |
101
+ | `--no-commit` | Dry run without committing (for `build` command) |
102
+ | `--force` | Force overwrite (for `install` command) |
103
+
104
+ ## Usage Examples
105
+
106
+ ### Generate a PRD
107
+
108
+ ```bash
109
+ # Interactive mode - prompts for description
110
+ ralph prd
111
+
112
+ # Direct mode - pass description as argument
113
+ ralph prd "A REST API for user authentication with JWT tokens"
114
+
115
+ # Specify output path
116
+ ralph prd --out .agents/tasks/prd-auth.json "Auth API"
117
+ ```
118
+
119
+ ### Build Stories
120
+
121
+ ```bash
122
+ # Build one story
123
+ ralph build 1
124
+
125
+ # Build 5 stories
126
+ ralph build 5
127
+
128
+ # Dry run (no commits)
129
+ ralph build 1 --no-commit
130
+
131
+ # Use specific PRD file
132
+ ralph build 1 --prd .agents/tasks/prd-auth.json
133
+
134
+ # Override agent for this run
135
+ ralph build 1 --agent codex
136
+ ```
137
+
138
+ ### Configuration
139
+
140
+ ```bash
141
+ # Change default agent
142
+ ralph config
143
+
144
+ # Install templates for customization
145
+ ralph install
146
+
147
+ # Install skills (commit, dev-browser, prd)
148
+ ralph install --skills
149
+ ```
150
+
151
+ ## Configuration
152
+
153
+ ### Global Config
154
+
155
+ Ralph stores global settings in `~/.ralph/config.json`:
156
+
157
+ ```json
158
+ {
159
+ "defaultAgent": "claude",
160
+ "configuredAt": "2026-01-19T12:00:00.000Z"
161
+ }
162
+ ```
163
+
164
+ To change your default agent:
165
+
166
+ ```bash
167
+ ralph config
168
+ ```
169
+
170
+ ### Project Config
171
+
172
+ After running `ralph install`, you can customize behavior in `.agents/ralph/config.sh`:
173
+
174
+ ```bash
175
+ # Override agent command (Claude uses stdin mode by default)
176
+ # AGENT_CMD="claude --dangerously-skip-permissions -p -"
177
+
178
+ # Build settings
179
+ NO_COMMIT=false
180
+ MAX_ITERATIONS=25
181
+ STALE_SECONDS=0
182
+ ```
183
+
184
+ ## Template Hierarchy
185
+
186
+ Ralph looks for templates in this order:
187
+
188
+ 1. `.agents/ralph/` in current project (if present)
189
+ 2. Bundled defaults from the package
190
+
191
+ State and logs always go to `.ralph/` in the project.
192
+
193
+ ## PRD Story Status
194
+
195
+ The build loop automatically updates story status:
196
+
197
+ | Status | Meaning |
198
+ |--------|---------|
199
+ | `open` | Available for selection |
200
+ | `in_progress` | Currently being worked on (with `startedAt`) |
201
+ | `done` | Completed (with `completedAt`) |
202
+
203
+ If a loop crashes while a story is `in_progress`, set `STALE_SECONDS` in config to auto-reopen stalled stories.
204
+
205
+ ## State Files
206
+
207
+ All state is stored in `.ralph/` in your project:
208
+
209
+ | File | Purpose |
210
+ |------|---------|
211
+ | `progress.md` | Append-only progress log |
212
+ | `guardrails.md` | Lessons learned ("Signs") |
213
+ | `activity.log` | Activity and timing log |
214
+ | `errors.log` | Repeated failures and notes |
215
+ | `runs/` | Raw run logs and summaries |
216
+
217
+ ## Advanced
218
+
219
+ ### Multiple PRD Files
220
+
221
+ If you have multiple PRD JSON files in `.agents/tasks/` and don't specify `--prd`, Ralph will prompt you to choose.
222
+
223
+ ### OpenCode Server Mode
224
+
225
+ For faster performance with OpenCode, run `opencode serve` in a separate terminal and uncomment the server mode lines in `.agents/ralph/agents.sh`:
226
+
227
+ ```bash
228
+ AGENT_OPENCODE_CMD="opencode run --attach http://localhost:4096 \"\$(cat {prompt})\""
229
+ ```
230
+
231
+ ### Custom Agent Commands
232
+
233
+ Agents are passed prompts via stdin by default. Use `{prompt}` placeholder when the agent needs a file path instead:
234
+
235
+ ```bash
236
+ # Stdin mode (default for claude, codex)
237
+ AGENT_CMD="my-agent -"
238
+
239
+ # File path mode (for agents that require a file)
240
+ AGENT_CMD="my-agent --file {prompt}"
241
+ ```
242
+
243
+ ## Development
244
+
245
+ ### Running Tests
246
+
247
+ ```bash
248
+ # Dry-run smoke tests (no agent required)
249
+ npm test
250
+
251
+ # Fast agent health check
252
+ npm run test:ping
253
+
254
+ # Integration tests (requires agents)
255
+ RALPH_INTEGRATION=1 npm test
256
+
257
+ # Full real-agent loop test
258
+ npm run test:real
259
+ ```
260
+
261
+ ### Publishing
262
+
263
+ ```bash
264
+ npm login
265
+ npm publish --access public
266
+ ```
267
+
268
+ ## License
269
+
270
+ MIT