spec-and-loop 1.0.8 → 1.2.0
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/QUICKSTART.md +265 -53
- package/README.md +210 -175
- package/lib/mini-ralph/context.js +99 -0
- package/lib/mini-ralph/errors.js +112 -0
- package/lib/mini-ralph/history.js +99 -0
- package/lib/mini-ralph/index.js +93 -0
- package/lib/mini-ralph/invoker.js +243 -0
- package/lib/mini-ralph/prompt.js +116 -0
- package/lib/mini-ralph/runner.js +495 -0
- package/lib/mini-ralph/state.js +93 -0
- package/lib/mini-ralph/status.js +238 -0
- package/lib/mini-ralph/tasks.js +209 -0
- package/package.json +3 -3
- package/scripts/mini-ralph-cli.js +226 -0
- package/scripts/ralph-run.sh +182 -72
- package/scripts/setup.js +39 -31
package/QUICKSTART.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Quick Start Guide
|
|
2
2
|
|
|
3
|
+
> **Version Compatibility:** OpenSpec 1.2.0 | spec-and-loop 2.0.0
|
|
4
|
+
|
|
3
5
|
Get up and running with **spec-and-loop** in 5 minutes!
|
|
4
6
|
|
|
5
7
|
## Prerequisites
|
|
@@ -7,8 +9,8 @@ Get up and running with **spec-and-loop** in 5 minutes!
|
|
|
7
9
|
Install these tools (one-time setup):
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
# 1. Install openspec (OpenSpec CLI)
|
|
11
|
-
npm install -g @fission-ai/openspec@
|
|
12
|
+
# 1. Install openspec (OpenSpec CLI) - pinned to version 1.2.0
|
|
13
|
+
npm install -g @fission-ai/openspec@1.2.0
|
|
12
14
|
|
|
13
15
|
# 2. Install opencode (agentic coding assistant)
|
|
14
16
|
npm install -g opencode-ai
|
|
@@ -24,15 +26,16 @@ brew install jq
|
|
|
24
26
|
git init
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
> **Note:** This guide is for OpenSpec 1.2.0 and spec-and-loop 2.0.0.
|
|
30
|
+
> No external `ralph` CLI needed — `spec-and-loop` includes its own internal
|
|
31
|
+
> mini Ralph loop engine. Just install `opencode` and you're ready to go. The
|
|
32
|
+
> runtime prompt is self-contained and does not depend on editor-specific slash
|
|
33
|
+
> commands or local-only skills.
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
npm install -g spec-and-loop
|
|
31
|
-
```
|
|
35
|
+
## Installation
|
|
32
36
|
|
|
33
|
-
**Prerequisites:** Install openspec and opencode:
|
|
34
37
|
```bash
|
|
35
|
-
npm install -g
|
|
38
|
+
npm install -g spec-and-loop@2.0.0
|
|
36
39
|
```
|
|
37
40
|
|
|
38
41
|
## Quick Demo (5 Minutes)
|
|
@@ -47,10 +50,13 @@ git init
|
|
|
47
50
|
openspec init
|
|
48
51
|
|
|
49
52
|
# 3. Create a new change
|
|
50
|
-
openspec new add-hello-world
|
|
53
|
+
openspec new change add-hello-world
|
|
51
54
|
|
|
52
|
-
# 4.
|
|
53
|
-
openspec
|
|
55
|
+
# 4. Review and complete the OpenSpec artifacts
|
|
56
|
+
# (openspec/changes/add-hello-world/proposal.md)
|
|
57
|
+
# (openspec/changes/add-hello-world/design.md)
|
|
58
|
+
# (openspec/changes/add-hello-world/specs/*/spec.md)
|
|
59
|
+
# (openspec/changes/add-hello-world/tasks.md)
|
|
54
60
|
|
|
55
61
|
# 5. Run the ralph loop (executes tasks with opencode)
|
|
56
62
|
ralph-run --change add-hello-world
|
|
@@ -58,8 +64,8 @@ ralph-run --change add-hello-world
|
|
|
58
64
|
|
|
59
65
|
**That's it!** The script will:
|
|
60
66
|
- Read your OpenSpec artifacts (proposal, specs, design, tasks)
|
|
61
|
-
- Execute each task with full context using
|
|
62
|
-
- Create a git commit after each task
|
|
67
|
+
- Execute each task with full context using the internal mini Ralph engine
|
|
68
|
+
- Create a git commit after each task (unless `--no-commit` is passed)
|
|
63
69
|
- Track progress in tasks.md
|
|
64
70
|
|
|
65
71
|
## What Just Happened?
|
|
@@ -70,13 +76,13 @@ ralph-run --change add-hello-world
|
|
|
70
76
|
- `design.md`: Technical decisions
|
|
71
77
|
- `tasks.md`: Implementation tasks as checkboxes
|
|
72
78
|
|
|
73
|
-
2. **Executed tasks** with opencode
|
|
74
|
-
- Each task got full context (proposal + specs + design +
|
|
79
|
+
2. **Executed tasks** with opencode via mini Ralph
|
|
80
|
+
- Each task got full context (proposal + specs + design + fresh task snapshot)
|
|
75
81
|
- Git commits created after each task
|
|
76
82
|
- Task checkboxes marked as complete
|
|
77
83
|
|
|
78
84
|
3. **Iterated** until all tasks done
|
|
79
|
-
-
|
|
85
|
+
- Recent failures or no-progress iterations inform subsequent tasks
|
|
80
86
|
- Each task builds on the previous commit
|
|
81
87
|
- Full granular git history
|
|
82
88
|
|
|
@@ -91,6 +97,9 @@ ls -la openspec/changes/add-hello-world/
|
|
|
91
97
|
|
|
92
98
|
# View the generated PRD (internal use)
|
|
93
99
|
cat openspec/changes/add-hello-world/.ralph/PRD.md
|
|
100
|
+
|
|
101
|
+
# Check loop status
|
|
102
|
+
ralph-run --status
|
|
94
103
|
```
|
|
95
104
|
|
|
96
105
|
## Common Commands
|
|
@@ -98,21 +107,42 @@ cat openspec/changes/add-hello-world/.ralph/PRD.md
|
|
|
98
107
|
### OpenSpec Commands
|
|
99
108
|
|
|
100
109
|
```bash
|
|
101
|
-
|
|
102
|
-
openspec
|
|
103
|
-
openspec
|
|
104
|
-
openspec
|
|
105
|
-
openspec
|
|
106
|
-
|
|
110
|
+
# Core workflow
|
|
111
|
+
openspec init # Initialize OpenSpec in current directory
|
|
112
|
+
openspec new change <name> # Create a new change directory
|
|
113
|
+
openspec show <item-name> # Show a change or spec in detail
|
|
114
|
+
openspec archive <change-name> # Archive a completed change
|
|
115
|
+
|
|
116
|
+
# Information and status
|
|
117
|
+
openspec list # List all active changes (use --specs to list specs)
|
|
118
|
+
openspec status --change <name> # Display artifact completion status for a change
|
|
119
|
+
openspec validate <item-name> # Validate changes and specs
|
|
120
|
+
|
|
121
|
+
# View and manage
|
|
122
|
+
openspec view # Display interactive dashboard of specs and changes
|
|
123
|
+
openspec update # Update OpenSpec instruction files
|
|
124
|
+
openspec config # View and modify global OpenSpec configuration
|
|
125
|
+
|
|
126
|
+
# Advanced
|
|
127
|
+
openspec spec # Manage and view OpenSpec specifications
|
|
128
|
+
openspec instructions # Output enriched instructions for creating artifacts
|
|
129
|
+
openspec templates # Show resolved template paths for artifacts
|
|
130
|
+
openspec schemas # List available workflow schemas
|
|
107
131
|
```
|
|
108
132
|
|
|
109
133
|
### Ralph Loop Commands
|
|
110
134
|
|
|
111
135
|
```bash
|
|
112
|
-
ralph-run
|
|
113
|
-
ralph-run --change <name>
|
|
114
|
-
ralph-run --verbose
|
|
115
|
-
ralph-run --
|
|
136
|
+
ralph-run # Auto-detect most recent change and run
|
|
137
|
+
ralph-run --change <name> # Run for specific change
|
|
138
|
+
ralph-run --verbose # Run with debug output
|
|
139
|
+
ralph-run --no-commit # Run without auto-committing
|
|
140
|
+
ralph-run --help # Show help message
|
|
141
|
+
|
|
142
|
+
# Observability and control
|
|
143
|
+
ralph-run --status # Show loop status dashboard
|
|
144
|
+
ralph-run --add-context "guidance text" # Inject context into next iteration
|
|
145
|
+
ralph-run --clear-context # Remove pending context
|
|
116
146
|
```
|
|
117
147
|
|
|
118
148
|
## Real-World Example
|
|
@@ -124,7 +154,7 @@ git init
|
|
|
124
154
|
openspec init
|
|
125
155
|
|
|
126
156
|
# 2. Create a feature
|
|
127
|
-
openspec new user-authentication
|
|
157
|
+
openspec new change user-authentication
|
|
128
158
|
|
|
129
159
|
# 3. Go through the workflow
|
|
130
160
|
# - Create proposal: Why add auth?
|
|
@@ -132,73 +162,257 @@ openspec new user-authentication
|
|
|
132
162
|
# - Create design: Use JWT, store hashed passwords
|
|
133
163
|
# - Create tasks: 15 checkboxes for implementation
|
|
134
164
|
|
|
135
|
-
# 4.
|
|
136
|
-
openspec ff user-authentication
|
|
137
|
-
|
|
138
|
-
# 5. Execute the implementation
|
|
165
|
+
# 4. Execute the implementation
|
|
139
166
|
ralph-run --change user-authentication
|
|
140
167
|
|
|
141
|
-
#
|
|
168
|
+
# 5. Watch the magic happen!
|
|
142
169
|
# [INFO] Found 15 tasks to execute
|
|
143
170
|
# [INFO] Executing task 1/15: Create User model
|
|
144
|
-
# ✓ Complete
|
|
145
171
|
# [INFO] Executing task 2/15: Implement password hashing
|
|
146
|
-
# ✓ Complete
|
|
147
172
|
# ...
|
|
148
173
|
|
|
149
|
-
#
|
|
174
|
+
# 6. Add context mid-run if needed (from another terminal)
|
|
175
|
+
ralph-run --add-context "Prefer bcrypt over argon2 for password hashing"
|
|
176
|
+
|
|
177
|
+
# 7. Check status
|
|
178
|
+
ralph-run --status
|
|
179
|
+
|
|
180
|
+
# 8. Verify the implementation
|
|
150
181
|
git log --oneline # 15 commits, one per task
|
|
151
182
|
git diff HEAD~15 # See full implementation
|
|
152
183
|
```
|
|
153
184
|
|
|
154
185
|
## Troubleshooting
|
|
155
186
|
|
|
156
|
-
### "openspec
|
|
187
|
+
### "openspec: command not found"
|
|
188
|
+
|
|
189
|
+
**Problem:** OpenSpec CLI is not installed or not in PATH
|
|
190
|
+
|
|
191
|
+
**Solution:**
|
|
192
|
+
```bash
|
|
193
|
+
# Install with pinned version (recommended)
|
|
194
|
+
npm install -g @fission-ai/openspec@1.2.0
|
|
195
|
+
|
|
196
|
+
# Verify installation
|
|
197
|
+
openspec --version
|
|
198
|
+
|
|
199
|
+
# If command still not found, add npm global bin to PATH
|
|
200
|
+
export PATH="$PATH:$(npm root -g)/.bin"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### "opencode: command not found"
|
|
204
|
+
|
|
205
|
+
**Problem:** opencode CLI is not installed or not in PATH
|
|
157
206
|
|
|
207
|
+
**Solution:**
|
|
158
208
|
```bash
|
|
159
|
-
|
|
209
|
+
# Install opencode
|
|
210
|
+
npm install -g opencode-ai
|
|
211
|
+
|
|
212
|
+
# Verify installation
|
|
213
|
+
opencode --version
|
|
214
|
+
|
|
215
|
+
# If command still not found, add npm global bin to PATH
|
|
216
|
+
export PATH="$PATH:$(npm root -g)/.bin"
|
|
160
217
|
```
|
|
161
218
|
|
|
162
219
|
### "jq CLI not found"
|
|
163
220
|
|
|
221
|
+
**Problem:** jq (JSON processor) is not installed
|
|
222
|
+
|
|
223
|
+
**Solution:**
|
|
164
224
|
```bash
|
|
165
225
|
# Ubuntu/Debian
|
|
166
226
|
sudo apt install jq
|
|
167
227
|
|
|
168
228
|
# macOS
|
|
169
229
|
brew install jq
|
|
230
|
+
|
|
231
|
+
# Verify installation
|
|
232
|
+
jq --version
|
|
170
233
|
```
|
|
171
234
|
|
|
172
235
|
### "Not a git repository"
|
|
173
236
|
|
|
237
|
+
**Problem:** You're not in a git repository
|
|
238
|
+
|
|
239
|
+
**Solution:**
|
|
174
240
|
```bash
|
|
241
|
+
# Initialize git in current directory
|
|
175
242
|
git init
|
|
243
|
+
|
|
244
|
+
# Verify
|
|
245
|
+
git status
|
|
176
246
|
```
|
|
177
247
|
|
|
178
248
|
### "command not found: ralph-run"
|
|
179
249
|
|
|
180
|
-
**Problem:** npm bin directory not in PATH
|
|
250
|
+
**Problem:** spec-and-loop npm bin directory not in PATH
|
|
181
251
|
|
|
182
252
|
**Solution:**
|
|
183
253
|
```bash
|
|
184
|
-
# Add
|
|
185
|
-
export PATH="$PATH:$(npm root -g)/.bin"
|
|
254
|
+
# Add npm global bin directory to PATH
|
|
255
|
+
echo 'export PATH="$PATH:$(npm root -g)/.bin"' >> ~/.bashrc
|
|
256
|
+
# Or for zsh:
|
|
257
|
+
echo 'export PATH="$PATH:$(npm root -g)/.bin"' >> ~/.zshrc
|
|
186
258
|
|
|
187
259
|
# Reload shell
|
|
188
260
|
source ~/.bashrc
|
|
261
|
+
# or
|
|
262
|
+
source ~/.zshrc
|
|
263
|
+
|
|
264
|
+
# Verify
|
|
265
|
+
ralph-run --help
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### "Internal mini Ralph runtime not found"
|
|
269
|
+
|
|
270
|
+
**Problem:** spec-and-loop installation is incomplete or node is missing
|
|
271
|
+
|
|
272
|
+
**Solution:**
|
|
273
|
+
```bash
|
|
274
|
+
# Ensure spec-and-loop is properly installed
|
|
275
|
+
npm uninstall -g spec-and-loop
|
|
276
|
+
npm install -g spec-and-loop
|
|
277
|
+
|
|
278
|
+
# Ensure Node.js is installed (version 24.0.0 or higher)
|
|
279
|
+
node --version
|
|
280
|
+
|
|
281
|
+
# If node is not installed, install from https://nodejs.org
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### "OpenSpec changes directory not found"
|
|
285
|
+
|
|
286
|
+
**Problem:** OpenSpec has not been initialized or no changes exist
|
|
287
|
+
|
|
288
|
+
**Solution:**
|
|
289
|
+
```bash
|
|
290
|
+
# Initialize OpenSpec
|
|
291
|
+
openspec init
|
|
292
|
+
|
|
293
|
+
# Create a new change
|
|
294
|
+
openspec new change my-feature
|
|
295
|
+
|
|
296
|
+
# Verify directory exists
|
|
297
|
+
ls -la openspec/changes/
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### "No changes found with tasks.md"
|
|
301
|
+
|
|
302
|
+
**Problem:** No OpenSpec changes with tasks files exist
|
|
303
|
+
|
|
304
|
+
**Solution:**
|
|
305
|
+
```bash
|
|
306
|
+
# List available changes
|
|
307
|
+
openspec list
|
|
308
|
+
|
|
309
|
+
# Create a new change if needed
|
|
310
|
+
openspec new change my-new-feature
|
|
311
|
+
|
|
312
|
+
# Ensure tasks.md exists in your change directory
|
|
313
|
+
ls -la openspec/changes/my-new-feature/tasks.md
|
|
189
314
|
```
|
|
190
315
|
|
|
191
316
|
### "No tasks to execute"
|
|
192
317
|
|
|
193
|
-
**Problem:** All tasks already complete
|
|
318
|
+
**Problem:** All tasks in tasks.md are already marked complete
|
|
319
|
+
|
|
320
|
+
**Solution:**
|
|
321
|
+
```bash
|
|
322
|
+
# Check tasks.md for incomplete tasks
|
|
323
|
+
grep "^\- \[ \]" openspec/changes/my-new-feature/tasks.md
|
|
324
|
+
|
|
325
|
+
# If no incomplete tasks, create a new change
|
|
326
|
+
openspec new change another-feature
|
|
327
|
+
|
|
328
|
+
# Or uncheck a task by editing tasks.md manually:
|
|
329
|
+
# Change: - [x] This task is done
|
|
330
|
+
# To: - [ ] This task needs work
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### "Required artifact not found"
|
|
334
|
+
|
|
335
|
+
**Problem:** OpenSpec artifacts (proposal.md, design.md, tasks.md) are missing
|
|
194
336
|
|
|
195
337
|
**Solution:**
|
|
196
338
|
```bash
|
|
197
|
-
# Check
|
|
198
|
-
|
|
339
|
+
# Check what artifacts exist in your change directory
|
|
340
|
+
ls -la openspec/changes/my-new-feature/
|
|
341
|
+
|
|
342
|
+
# Create missing artifacts manually or use openspec new change
|
|
343
|
+
openspec new change my-new-feature
|
|
344
|
+
|
|
345
|
+
# Or manually create the required files:
|
|
346
|
+
# - openspec/changes/my-new-feature/proposal.md
|
|
347
|
+
# - openspec/changes/my-new-feature/design.md
|
|
348
|
+
# - openspec/changes/my-new-feature/specs/spec-name/spec.md
|
|
349
|
+
# - openspec/changes/my-new-feature/tasks.md
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### "Required directory not found: specs/"
|
|
353
|
+
|
|
354
|
+
**Problem:** The specs directory is missing from your change
|
|
355
|
+
|
|
356
|
+
**Solution:**
|
|
357
|
+
```bash
|
|
358
|
+
# Create the specs directory
|
|
359
|
+
mkdir -p openspec/changes/my-new-feature/specs
|
|
360
|
+
|
|
361
|
+
# Create at least one spec file
|
|
362
|
+
mkdir -p openspec/changes/my-new-feature/specs/main-feature
|
|
363
|
+
echo "# Main Feature Spec" > openspec/changes/my-new-feature/specs/main-feature/spec.md
|
|
364
|
+
|
|
365
|
+
# Verify
|
|
366
|
+
ls -la openspec/changes/my-new-feature/specs/
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### "opencode CLI not found"
|
|
370
|
+
|
|
371
|
+
**Problem:** opencode is not installed globally
|
|
372
|
+
|
|
373
|
+
**Solution:**
|
|
374
|
+
```bash
|
|
375
|
+
# Install opencode
|
|
376
|
+
npm install -g opencode-ai
|
|
377
|
+
|
|
378
|
+
# Verify installation
|
|
379
|
+
opencode --version
|
|
380
|
+
|
|
381
|
+
# Add to PATH if needed
|
|
382
|
+
export PATH="$PATH:$(npm root -g)/.bin"
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### "Node.js version too old"
|
|
386
|
+
|
|
387
|
+
**Problem:** Node.js version is below the required version (24.0.0+)
|
|
388
|
+
|
|
389
|
+
**Solution:**
|
|
390
|
+
```bash
|
|
391
|
+
# Check current Node.js version
|
|
392
|
+
node --version
|
|
393
|
+
|
|
394
|
+
# If version is below 24.0.0, upgrade Node.js:
|
|
395
|
+
# Using nvm (recommended):
|
|
396
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
|
397
|
+
nvm install 24
|
|
398
|
+
nvm use 24
|
|
399
|
+
|
|
400
|
+
# Or install from https://nodejs.org
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### "npm: command not found"
|
|
404
|
+
|
|
405
|
+
**Problem:** npm is not installed or not in PATH
|
|
406
|
+
|
|
407
|
+
**Solution:**
|
|
408
|
+
```bash
|
|
409
|
+
# npm comes with Node.js. Install Node.js from https://nodejs.org
|
|
410
|
+
|
|
411
|
+
# After installing Node.js, verify:
|
|
412
|
+
npm --version
|
|
413
|
+
node --version
|
|
199
414
|
|
|
200
|
-
#
|
|
201
|
-
openspec new another-feature
|
|
415
|
+
# If still not found, restart your terminal or add to PATH
|
|
202
416
|
```
|
|
203
417
|
|
|
204
418
|
## Features at a Glance
|
|
@@ -210,8 +424,9 @@ openspec new another-feature
|
|
|
210
424
|
| **Iterative Loop** | Each task builds on previous commits |
|
|
211
425
|
| **Error Propagation** | Failures inform subsequent tasks |
|
|
212
426
|
| **Granular History** | One git commit per task |
|
|
213
|
-
| **Auto-Resume** | Interrupted? Run again—picks up where left off |
|
|
214
|
-
| **Context Injection** |
|
|
427
|
+
| **Auto-Resume** | Interrupted? Run again — picks up where left off |
|
|
428
|
+
| **Context Injection** | `--add-context` injects guidance into the next iteration |
|
|
429
|
+
| **No External Ralph** | Self-contained mini Ralph engine — no `ralph` CLI needed |
|
|
215
430
|
|
|
216
431
|
## Testing
|
|
217
432
|
|
|
@@ -253,21 +468,18 @@ Tests run automatically on every push and pull request via GitHub Actions on bot
|
|
|
253
468
|
|
|
254
469
|
1. **Read the full README.md** for detailed documentation
|
|
255
470
|
2. **Try a real feature** in your project
|
|
256
|
-
3. **Explore
|
|
257
|
-
4. **
|
|
258
|
-
5. **Review TESTING.md** for testing guidelines
|
|
471
|
+
3. **Explore `openspec/changes/<name>/.ralph/`** to see the per-change loop state
|
|
472
|
+
4. **Review TESTING.md** for testing guidelines
|
|
259
473
|
|
|
260
474
|
## Resources
|
|
261
475
|
|
|
262
476
|
- [Full README](./README.md) - Comprehensive documentation
|
|
263
477
|
- [OpenSpec](https://openspec.ai) - Specification workflow
|
|
264
478
|
- [opencode](https://opencode.ai) - Agentic coding assistant
|
|
265
|
-
- [open-ralph-wiggum](https://github.com/Th0rgal/open-ralph-wiggum) - Iterative execution loop
|
|
266
479
|
|
|
267
480
|
## Need Help?
|
|
268
481
|
|
|
269
482
|
- Check the **Troubleshooting** section above
|
|
270
483
|
- Review the **Full README.md** for detailed info
|
|
271
|
-
- Check **.hidden/** directory for advanced guides
|
|
272
484
|
|
|
273
|
-
Happy coding!
|
|
485
|
+
Happy coding!
|