substrate-ai 0.2.0 → 0.2.2
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 +67 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
# Substrate
|
|
6
6
|
|
|
7
|
-
Substrate is an autonomous software development pipeline. Describe your project
|
|
7
|
+
Substrate is an autonomous software development pipeline you operate from Claude Code. Describe your project, and Substrate coordinates multiple AI coding agents (Claude Code, Codex, Gemini CLI) working in parallel across isolated branches — from concept through implementation and code review. A built-in supervisor watches for stalls, auto-recovers, and after each run analyzes what happened and experiments with improvements — closing the loop automatically.
|
|
8
8
|
|
|
9
|
-
Unlike API-based orchestrators, Substrate routes work through the CLI tools you already have installed, maximizing your existing AI subscriptions before falling back to pay-per-token billing. Runs are persistent and resumable
|
|
9
|
+
Unlike API-based orchestrators, Substrate routes work through the CLI tools you already have installed, maximizing your existing AI subscriptions before falling back to pay-per-token billing. Runs are persistent and resumable with full cost visibility across every provider.
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
@@ -17,54 +17,50 @@ Unlike API-based orchestrators, Substrate routes work through the CLI tools you
|
|
|
17
17
|
- [Codex CLI](https://github.com/openai/codex) (`codex`)
|
|
18
18
|
- Gemini CLI (`gemini`)
|
|
19
19
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
Install as a project dependency:
|
|
20
|
+
## Quick Start
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
npm install substrate-ai
|
|
26
|
-
```
|
|
22
|
+
### Install
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
Install globally and initialize in your project:
|
|
29
25
|
|
|
30
26
|
```bash
|
|
31
27
|
npm install -g substrate-ai
|
|
28
|
+
substrate init
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
Or as a project dependency:
|
|
35
32
|
|
|
36
33
|
```bash
|
|
37
|
-
|
|
38
|
-
substrate
|
|
34
|
+
npm install substrate-ai
|
|
35
|
+
npx substrate init
|
|
39
36
|
```
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
This scaffolds CLAUDE.md with behavioral directives and generates `.claude/commands/` slash commands. Claude Code reads these on session start and knows how to operate the pipeline automatically.
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
### Use Substrate From Claude
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
Start a Claude Code session in your project. Claude automatically sees the substrate instructions and slash commands. From there:
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
- **"Run the substrate pipeline"** — Claude runs the full lifecycle from analysis through implementation
|
|
45
|
+
- **"Run substrate for stories 7-1, 7-2, 7-3"** — Claude implements specific stories
|
|
46
|
+
- **"/substrate-run"** — invoke the slash command directly for a guided pipeline run
|
|
47
|
+
- **"/substrate-supervisor"** — launch the supervisor to monitor, recover stalls, and run experiments
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Claude parses structured events, handles escalations, offers to fix review issues, and summarizes results. You stay in control — Claude always asks before re-running failed stories or applying fixes.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
npm install substrate-ai
|
|
53
|
-
[npx] substrate init
|
|
54
|
-
```
|
|
51
|
+
### Monitor and Self-Improve
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
While the pipeline runs (or after it finishes), tell Claude in the same or a separate session:
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
> "Run the substrate supervisor with experiments"
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
The supervisor watches the pipeline, kills stalls, and auto-restarts. When the run completes, it analyzes what happened — bottlenecks, token waste, slow stories — then runs A/B experiments on prompts and config in isolated worktrees. Improvements get auto-PRed; regressions get discarded.
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```
|
|
59
|
+
Later, ask Claude to compare runs:
|
|
60
|
+
|
|
61
|
+
> "Compare the last two substrate runs"
|
|
62
|
+
|
|
63
|
+
This is the full loop: run → watch → analyze → experiment → improve.
|
|
68
64
|
|
|
69
65
|
### Pick Up an Existing BMAD Project
|
|
70
66
|
|
|
@@ -79,14 +75,7 @@ Already have a project with BMAD artifacts (from vanilla BMAD, the Beads-based a
|
|
|
79
75
|
| `_bmad-output/implementation-artifacts/*.md` | Optional | Existing story files — Substrate skips create-story for any it finds |
|
|
80
76
|
| `package.json` | Optional | Test framework detection |
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm install substrate-ai
|
|
86
|
-
[npx] substrate init
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**Then start a Claude Code session and tell it what to do:**
|
|
78
|
+
After the same install + init from [Quick Start](#quick-start), start a Claude Code session and tell it what to do:
|
|
90
79
|
|
|
91
80
|
> "Run the substrate pipeline to implement the remaining stories."
|
|
92
81
|
|
|
@@ -94,21 +83,6 @@ Claude reads the CLAUDE.md scaffold, discovers the substrate commands, and drive
|
|
|
94
83
|
|
|
95
84
|
Substrate reads one directory — `_bmad-output/` — and doesn't care which tool created it. It does not read `sprint-status.yaml` or `.beads/` — you decide what's left by choosing which story keys to pass.
|
|
96
85
|
|
|
97
|
-
### Autonomous Pipeline (standalone)
|
|
98
|
-
|
|
99
|
-
Substrate also runs standalone without an AI agent driving it:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
[npx] substrate brainstorm # Explore your idea
|
|
103
|
-
[npx] substrate init # Set up methodology pack
|
|
104
|
-
[npx] substrate run # Full pipeline: analysis → implement
|
|
105
|
-
[npx] substrate run --from solutioning # Skip to a specific phase
|
|
106
|
-
[npx] substrate resume # Pick up where you left off
|
|
107
|
-
[npx] substrate status # Check pipeline progress
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
The pipeline walks through the full software development lifecycle: analysis, planning, solutioning, and implementation — dispatching agents to build, test, and code-review each story.
|
|
111
|
-
|
|
112
86
|
## Supported Worker Agents
|
|
113
87
|
|
|
114
88
|
Substrate dispatches work to CLI-based AI agents running as child processes. It never calls LLMs directly — all implementation, code review, and story generation is delegated to these worker agents.
|
|
@@ -121,8 +95,6 @@ Substrate dispatches work to CLI-based AI agents running as child processes. It
|
|
|
121
95
|
|
|
122
96
|
All three agents are fully supported as worker targets. Substrate auto-discovers available agents and routes work based on adapter health checks and configuration.
|
|
123
97
|
|
|
124
|
-
> **Note on agent scaffolding:** Separately from worker dispatch, Substrate can also scaffold instruction files that teach an AI agent how to *drive* the pipeline as a front-end. Today, `substrate init` generates a CLAUDE.md scaffold for Claude Code (see [AI Agent Integration](#ai-agent-integration)). Equivalent scaffolds for Codex (`AGENTS.md`) and Gemini (`GEMINI.md`) are planned.
|
|
125
|
-
|
|
126
98
|
## Pipeline Observability
|
|
127
99
|
|
|
128
100
|
Substrate provides multiple output modes for monitoring pipeline execution.
|
|
@@ -154,11 +126,11 @@ Pipeline complete: 5 succeeded, 0 failed, 1 escalated
|
|
|
154
126
|
For programmatic consumption, `--events` emits newline-delimited JSON events on stdout:
|
|
155
127
|
|
|
156
128
|
```bash
|
|
157
|
-
|
|
158
|
-
|
|
129
|
+
substrate run --events
|
|
130
|
+
substrate run --events --stories 7-1,7-2
|
|
159
131
|
```
|
|
160
132
|
|
|
161
|
-
|
|
133
|
+
Event types form a discriminated union on the `type` field:
|
|
162
134
|
|
|
163
135
|
| Event | Description |
|
|
164
136
|
|-------|-------------|
|
|
@@ -169,6 +141,9 @@ Seven event types form a discriminated union on the `type` field:
|
|
|
169
141
|
| `story:escalation` | Story escalated after exhausting review cycles — includes issue list with severities |
|
|
170
142
|
| `story:warn` | Non-fatal warning (e.g., token ceiling truncation) |
|
|
171
143
|
| `story:log` | Informational progress message |
|
|
144
|
+
| `supervisor:*` | Supervisor lifecycle events — `kill`, `restart`, `abort`, `summary` |
|
|
145
|
+
| `supervisor:analysis:*` | Post-run analysis events — `complete`, `error` |
|
|
146
|
+
| `supervisor:experiment:*` | Experiment loop events — `start`, `skip`, `recommendations`, `complete`, `error` |
|
|
172
147
|
|
|
173
148
|
All events carry a `ts` (ISO-8601 timestamp) field. The full TypeScript types are exported from the package:
|
|
174
149
|
|
|
@@ -185,12 +160,12 @@ if (event.type === 'story:escalation') {
|
|
|
185
160
|
|
|
186
161
|
## AI Agent Integration
|
|
187
162
|
|
|
188
|
-
Substrate is designed to be operated by AI agents, not just humans.
|
|
163
|
+
Substrate is designed to be operated by AI agents, not just humans. Three mechanisms teach agents how to interact with the pipeline at runtime:
|
|
189
164
|
|
|
190
165
|
### Self-Describing CLI (`--help-agent`)
|
|
191
166
|
|
|
192
167
|
```bash
|
|
193
|
-
|
|
168
|
+
substrate run --help-agent
|
|
194
169
|
```
|
|
195
170
|
|
|
196
171
|
Outputs a machine-optimized markdown prompt fragment (<2000 tokens) that an AI agent can ingest as a system prompt. Generated from the same TypeScript type definitions as the event emitter, so documentation never drifts from implementation. Includes:
|
|
@@ -206,24 +181,38 @@ Outputs a machine-optimized markdown prompt fragment (<2000 tokens) that an AI a
|
|
|
206
181
|
|
|
207
182
|
- Instructions to run `--help-agent` on first use
|
|
208
183
|
- Event-driven interaction patterns (escalation handling, fix offers, confirmation requirements)
|
|
184
|
+
- Supervisor workflow guidance (when to use `run` vs `supervisor` vs `supervisor --experiment`)
|
|
209
185
|
- Section is wrapped in `<!-- substrate:start/end -->` markers for idempotent updates
|
|
210
186
|
- Re-running `init` updates the substrate section while preserving all other CLAUDE.md content
|
|
211
187
|
|
|
188
|
+
### Slash Commands
|
|
189
|
+
|
|
190
|
+
`substrate init` also generates `.claude/commands/` slash commands that Claude Code can invoke directly:
|
|
191
|
+
|
|
192
|
+
- `/substrate-run` — Start or resume a pipeline run with structured events
|
|
193
|
+
- `/substrate-supervisor` — Launch the supervisor monitor with stall detection and auto-restart
|
|
194
|
+
- `/substrate-metrics` — Query run history, compare runs, and read analysis reports
|
|
195
|
+
|
|
196
|
+
These commands encode the recommended invocation patterns so Claude uses the right flags without needing to memorize them.
|
|
197
|
+
|
|
212
198
|
## Commands
|
|
213
199
|
|
|
200
|
+
These commands are invoked by AI agents (Claude Code, Codex, Gemini CLI) during pipeline operation. You typically don't run them directly — you tell your agent what to do and it selects the right command.
|
|
201
|
+
|
|
214
202
|
### Pipeline
|
|
215
203
|
|
|
216
204
|
| Command | Description |
|
|
217
205
|
|---------|-------------|
|
|
218
206
|
| `substrate brainstorm` | Interactive multi-persona ideation session |
|
|
219
|
-
| `substrate init` | Initialize methodology pack
|
|
207
|
+
| `substrate init` | Initialize config, methodology pack, CLAUDE.md scaffold, and slash commands |
|
|
220
208
|
| `substrate run` | Run the full pipeline (analysis → implement) |
|
|
221
209
|
| `substrate run --events` | Emit NDJSON event stream on stdout |
|
|
222
|
-
| `substrate run --
|
|
223
|
-
| `substrate run --help-agent` | Print agent instruction prompt fragment and exit |
|
|
210
|
+
| `substrate run --stories <keys>` | Run specific stories (e.g., `7-1,7-2`) |
|
|
224
211
|
| `substrate run --from <phase>` | Start from a specific phase |
|
|
212
|
+
| `substrate run --help-agent` | Print agent instruction prompt fragment and exit |
|
|
225
213
|
| `substrate resume` | Resume an interrupted pipeline run |
|
|
226
214
|
| `substrate status` | Show pipeline run status |
|
|
215
|
+
| `substrate amend` | Run an amendment pipeline against a completed run |
|
|
227
216
|
|
|
228
217
|
### Observability
|
|
229
218
|
|
|
@@ -231,22 +220,34 @@ Outputs a machine-optimized markdown prompt fragment (<2000 tokens) that an AI a
|
|
|
231
220
|
|---------|-------------|
|
|
232
221
|
| `substrate health` | Check pipeline health, stall detection, and process status |
|
|
233
222
|
| `substrate supervisor` | Long-running monitor that kills stalled runs and auto-restarts |
|
|
234
|
-
| `substrate
|
|
235
|
-
| `substrate
|
|
223
|
+
| `substrate supervisor --experiment` | Self-improvement loop: post-run analysis + A/B experiments |
|
|
224
|
+
| `substrate metrics` | Historical pipeline run metrics |
|
|
225
|
+
| `substrate metrics --compare <a,b>` | Side-by-side comparison of two runs |
|
|
226
|
+
| `substrate metrics --analysis <run-id>` | Read the analysis report for a specific run |
|
|
227
|
+
| `substrate monitor status` | View agent performance metrics |
|
|
236
228
|
| `substrate monitor report` | Generate a detailed performance report |
|
|
229
|
+
| `substrate monitor recommendations` | Display routing recommendations from performance data |
|
|
237
230
|
| `substrate cost` | View cost and token usage summary |
|
|
238
231
|
|
|
232
|
+
### Worktree Management
|
|
233
|
+
|
|
234
|
+
| Command | Description |
|
|
235
|
+
|---------|-------------|
|
|
236
|
+
| `substrate merge` | Detect conflicts and merge task worktree branches into the target branch |
|
|
237
|
+
| `substrate worktrees` | List all active git worktrees and their associated tasks |
|
|
238
|
+
|
|
239
239
|
### Setup
|
|
240
240
|
|
|
241
241
|
| Command | Description |
|
|
242
242
|
|---------|-------------|
|
|
243
243
|
| `substrate adapters` | List and check available AI agent adapters |
|
|
244
244
|
| `substrate config` | Show, set, export, or import configuration |
|
|
245
|
+
| `substrate upgrade` | Check for updates and upgrade to the latest version |
|
|
245
246
|
| `substrate --help` | Show all available commands |
|
|
246
247
|
|
|
247
248
|
## Configuration
|
|
248
249
|
|
|
249
|
-
Substrate reads configuration from `.substrate/config.yaml` in your project root. Run `
|
|
250
|
+
Substrate reads configuration from `.substrate/config.yaml` in your project root. Run `substrate init` to generate a default config.
|
|
250
251
|
|
|
251
252
|
## Development
|
|
252
253
|
|