ralph-cli-sandboxed 0.1.0 → 0.1.5
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 +190 -21
- package/dist/commands/docker.d.ts +1 -0
- package/dist/commands/docker.js +615 -0
- package/dist/commands/help.d.ts +1 -0
- package/dist/commands/help.js +85 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +146 -0
- package/dist/commands/once.d.ts +1 -0
- package/dist/commands/once.js +40 -0
- package/dist/commands/prd.d.ts +10 -0
- package/dist/commands/prd.js +271 -0
- package/dist/commands/prompt.d.ts +1 -0
- package/dist/commands/prompt.js +52 -0
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.js +319 -0
- package/dist/commands/scripts.d.ts +1 -0
- package/dist/commands/scripts.js +159 -0
- package/dist/config/languages.json +156 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +66 -7
- package/dist/templates/prompts.d.ts +43 -0
- package/dist/templates/prompts.js +118 -0
- package/dist/utils/config.d.ts +36 -0
- package/dist/utils/config.js +98 -0
- package/dist/utils/prompt.d.ts +8 -0
- package/dist/utils/prompt.js +101 -0
- package/docs/PRD-GENERATOR.md +361 -0
- package/package.json +44 -10
- package/.ralph/config.json +0 -6
- package/.ralph/docker/.dockerignore +0 -5
- package/.ralph/docker/Dockerfile +0 -105
- package/.ralph/docker/docker-compose.yml +0 -28
- package/.ralph/docker/init-firewall.sh +0 -78
- package/.ralph/prd.json +0 -38
- package/.ralph/progress.txt +0 -24
- package/.ralph/prompt.md +0 -24
- package/src/index.ts +0 -12
- package/tsconfig.json +0 -15
- /package/{.ralph → docs}/HOW-TO-WRITE-PRDs.md +0 -0
package/README.md
CHANGED
|
@@ -1,60 +1,229 @@
|
|
|
1
1
|
# ralph-cli-sandboxed
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AI-driven development automation CLI for [Claude Code](https://github.com/anthropics/claude-code), implementing the [Ralph Wiggum technique](https://ghuntley.com/ralph/) created by Geoffrey Huntley.
|
|
4
|
+
|
|
5
|
+
The Ralph Wiggum technique (named after the Simpsons character) runs a coding agent from a clean slate, over and over, until a stop condition is met. As [Matt Pocock describes it](https://x.com/mattpocockuk/status/2008200878633931247): "an AI coding approach that lets you run seriously long-running AI agents (hours, days) that ship code while you sleep."
|
|
6
|
+
|
|
7
|
+
This CLI automates iterative development by having Claude work through a PRD (Product Requirements Document), implementing features one at a time, running tests, and committing changes. When an iteration completes, the next one starts fresh - preventing context rot and allowing long-running autonomous development.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
12
|
+
# Use directly with npx
|
|
13
|
+
npx ralph-cli-sandboxed init
|
|
14
|
+
|
|
15
|
+
# Or install globally
|
|
8
16
|
npm install -g ralph-cli-sandboxed
|
|
17
|
+
ralph init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1. Initialize ralph in your project
|
|
24
|
+
ralph init
|
|
25
|
+
|
|
26
|
+
# 2. Add requirements to your PRD
|
|
27
|
+
ralph add
|
|
28
|
+
|
|
29
|
+
# 3. Run a single iteration
|
|
30
|
+
ralph once
|
|
31
|
+
|
|
32
|
+
# 4. Or run multiple iterations
|
|
33
|
+
ralph run 5
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
| Command | Description |
|
|
39
|
+
|---------|-------------|
|
|
40
|
+
| `ralph init` | Initialize ralph in current project |
|
|
41
|
+
| `ralph once` | Run a single automation iteration |
|
|
42
|
+
| `ralph run <n>` | Run n automation iterations |
|
|
43
|
+
| `ralph add` | Add a new PRD entry (interactive) |
|
|
44
|
+
| `ralph list` | List all PRD entries |
|
|
45
|
+
| `ralph status` | Show PRD completion status |
|
|
46
|
+
| `ralph toggle <n>` | Toggle passes status for entry n |
|
|
47
|
+
| `ralph clean` | Remove all passing entries from PRD |
|
|
48
|
+
| `ralph docker` | Generate Docker sandbox environment |
|
|
49
|
+
| `ralph help` | Show help message |
|
|
50
|
+
|
|
51
|
+
> **Note:** `ralph prd <subcommand>` still works for compatibility (e.g., `ralph prd add`).
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
After running `ralph init`, you'll have:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
.ralph/
|
|
59
|
+
├── config.json # Project configuration
|
|
60
|
+
├── prompt.md # Shared prompt template
|
|
61
|
+
├── prd.json # Product requirements document
|
|
62
|
+
└── progress.txt # Progress tracking file
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Supported Languages
|
|
66
|
+
|
|
67
|
+
- **Bun** (TypeScript) - `bun check`, `bun test`
|
|
68
|
+
- **Node.js** (TypeScript) - `npm run typecheck`, `npm test`
|
|
69
|
+
- **Python** - `mypy .`, `pytest`
|
|
70
|
+
- **Go** - `go build ./...`, `go test ./...`
|
|
71
|
+
- **Rust** - `cargo check`, `cargo test`
|
|
72
|
+
- **Custom** - Define your own commands
|
|
73
|
+
|
|
74
|
+
### CLI Configuration
|
|
75
|
+
|
|
76
|
+
Ralph can be configured to use different AI CLI tools. By default, it uses Claude Code. Configure in `.ralph/config.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"cli": {
|
|
81
|
+
"command": "claude",
|
|
82
|
+
"args": ["--permission-mode", "acceptEdits"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- `command`: The CLI executable name (must be in PATH)
|
|
88
|
+
- `args`: Default arguments passed to the CLI
|
|
89
|
+
|
|
90
|
+
The `-p` flag with PRD/prompt content and `--dangerously-skip-permissions` (in containers) are added automatically at runtime.
|
|
91
|
+
|
|
92
|
+
## PRD Format
|
|
93
|
+
|
|
94
|
+
The PRD (`prd.json`) is an array of requirements:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
[
|
|
98
|
+
{
|
|
99
|
+
"category": "feature",
|
|
100
|
+
"description": "Add user authentication",
|
|
101
|
+
"steps": [
|
|
102
|
+
"Create login form",
|
|
103
|
+
"Implement JWT tokens",
|
|
104
|
+
"Add protected routes"
|
|
105
|
+
],
|
|
106
|
+
"passes": false
|
|
107
|
+
}
|
|
108
|
+
]
|
|
9
109
|
```
|
|
10
110
|
|
|
11
|
-
|
|
111
|
+
Categories: `ui`, `feature`, `bugfix`, `setup`, `development`, `testing`, `docs`
|
|
112
|
+
|
|
113
|
+
## Docker Sandbox
|
|
12
114
|
|
|
13
|
-
Run
|
|
115
|
+
Run ralph in an isolated Docker container:
|
|
14
116
|
|
|
15
117
|
```bash
|
|
16
|
-
|
|
118
|
+
# Generate Docker files
|
|
119
|
+
ralph docker
|
|
120
|
+
|
|
121
|
+
# Build the image
|
|
122
|
+
ralph docker --build
|
|
123
|
+
|
|
124
|
+
# Run container
|
|
125
|
+
ralph docker --run
|
|
17
126
|
```
|
|
18
127
|
|
|
19
|
-
|
|
128
|
+
Features:
|
|
129
|
+
- Based on [Claude Code devcontainer](https://github.com/anthropics/claude-code/tree/main/.devcontainer)
|
|
130
|
+
- Network sandboxing (firewall allows only GitHub, npm, Anthropic API)
|
|
131
|
+
- Your `~/.claude` credentials mounted automatically (Pro/Max OAuth)
|
|
132
|
+
- Language-specific tooling pre-installed
|
|
20
133
|
|
|
21
|
-
|
|
134
|
+
### Installing packages in container
|
|
22
135
|
|
|
23
136
|
```bash
|
|
24
|
-
|
|
137
|
+
# Run as root to install packages
|
|
138
|
+
docker compose run -u root ralph apt-get update
|
|
139
|
+
docker compose run -u root ralph apt-get install <package>
|
|
25
140
|
```
|
|
26
141
|
|
|
27
|
-
##
|
|
142
|
+
## How It Works
|
|
143
|
+
|
|
144
|
+
1. **Read PRD**: Claude reads your requirements from `prd.json`
|
|
145
|
+
2. **Implement**: Works on the highest priority incomplete feature
|
|
146
|
+
3. **Verify**: Runs your check and test commands
|
|
147
|
+
4. **Update**: Marks the feature as complete in the PRD
|
|
148
|
+
5. **Commit**: Creates a git commit for the feature
|
|
149
|
+
6. **Repeat**: Continues to the next feature (in `run` mode)
|
|
150
|
+
|
|
151
|
+
When all PRD items pass, Claude outputs `<promise>COMPLETE</promise>` and stops.
|
|
152
|
+
|
|
153
|
+
## Security
|
|
154
|
+
|
|
155
|
+
### Container Requirement
|
|
156
|
+
|
|
157
|
+
**It is strongly recommended to run ralph inside a Docker container for security.** The Ralph Wiggum technique involves running an AI agent autonomously, which means granting it elevated permissions to execute code and modify files without manual approval for each action.
|
|
158
|
+
|
|
159
|
+
### The `--dangerously-skip-permissions` Flag
|
|
160
|
+
|
|
161
|
+
When running inside a container, ralph automatically passes the `--dangerously-skip-permissions` flag to Claude Code. This flag:
|
|
28
162
|
|
|
29
|
-
|
|
163
|
+
- Allows Claude to execute commands and modify files without prompting for permission
|
|
164
|
+
- Is **only** enabled when ralph detects it's running inside a container
|
|
165
|
+
- Is required for autonomous operation (otherwise Claude would pause for approval on every action)
|
|
30
166
|
|
|
31
|
-
-
|
|
32
|
-
- npm
|
|
167
|
+
**Warning:** The `--dangerously-skip-permissions` flag gives the AI agent full control over the environment. This is why container isolation is critical:
|
|
33
168
|
|
|
34
|
-
|
|
169
|
+
- The container provides a sandbox boundary
|
|
170
|
+
- Network access is restricted to essential services (GitHub, npm, Anthropic API)
|
|
171
|
+
- Your host system remains protected even if something goes wrong
|
|
172
|
+
|
|
173
|
+
### Container Detection
|
|
174
|
+
|
|
175
|
+
Ralph detects container environments by checking:
|
|
176
|
+
- `DEVCONTAINER` environment variable
|
|
177
|
+
- Presence of `/.dockerenv` file
|
|
178
|
+
- Container indicators in `/proc/1/cgroup`
|
|
179
|
+
- `container` environment variable
|
|
180
|
+
|
|
181
|
+
If you're running outside a container and need autonomous mode, use `ralph docker` to set up a safe sandbox environment first.
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
To contribute or test changes to ralph locally:
|
|
35
186
|
|
|
36
187
|
```bash
|
|
188
|
+
# Clone the repository
|
|
189
|
+
git clone https://github.com/choas/ralph-cli-sandboxed
|
|
190
|
+
cd ralph-cli-sandboxed
|
|
191
|
+
|
|
192
|
+
# Install dependencies
|
|
37
193
|
npm install
|
|
38
|
-
```
|
|
39
194
|
|
|
40
|
-
|
|
195
|
+
# Run ralph in development mode (without building)
|
|
196
|
+
npm run dev -- <args>
|
|
41
197
|
|
|
42
|
-
|
|
43
|
-
npm run
|
|
198
|
+
# Examples:
|
|
199
|
+
npm run dev -- --version
|
|
200
|
+
npm run dev -- list
|
|
201
|
+
npm run dev -- once
|
|
44
202
|
```
|
|
45
203
|
|
|
46
|
-
|
|
204
|
+
The `npm run dev -- <args>` command runs ralph directly from TypeScript source using `tsx`, allowing you to test changes without rebuilding.
|
|
205
|
+
|
|
206
|
+
### Platform-Specific Dependencies
|
|
207
|
+
|
|
208
|
+
The `node_modules` folder contains platform-specific binaries (e.g., esbuild). If you switch between running on your host machine and inside a Docker/Podman container, you'll need to reinstall dependencies:
|
|
47
209
|
|
|
48
210
|
```bash
|
|
49
|
-
|
|
211
|
+
# When switching environments (host <-> container)
|
|
212
|
+
rm -rf node_modules && npm install
|
|
50
213
|
```
|
|
51
214
|
|
|
52
|
-
|
|
215
|
+
Alternatively, when mounting your project into a container, use a separate volume for node_modules to keep host and container dependencies isolated:
|
|
53
216
|
|
|
54
217
|
```bash
|
|
55
|
-
|
|
218
|
+
podman run -v $(pwd):/workspace -v /workspace/node_modules your-image
|
|
56
219
|
```
|
|
57
220
|
|
|
221
|
+
## Requirements
|
|
222
|
+
|
|
223
|
+
- Node.js 18+
|
|
224
|
+
- [Claude Code CLI](https://github.com/anthropics/claude-code) installed
|
|
225
|
+
- Claude Pro/Max subscription or Anthropic API key
|
|
226
|
+
|
|
58
227
|
## License
|
|
59
228
|
|
|
60
|
-
|
|
229
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function docker(args: string[]): Promise<void>;
|