pi-baton 0.7.5 → 0.8.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/CHANGELOG.md +202 -163
- package/README.md +184 -179
- package/docs/workflows.md +154 -0
- package/extensions/index.ts +14 -1
- package/lib/run-store.ts +113 -1
- package/lib/status.ts +43 -0
- package/lib/workflow-discovery.ts +66 -26
- package/package.json +67 -67
package/README.md
CHANGED
|
@@ -1,179 +1,184 @@
|
|
|
1
|
-
# Pi Baton
|
|
2
|
-
|
|
3
|
-
[](https://discord.gg/4945dXZVW5)
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img src="./assets/pi-baton-icon-512.png" alt="Pi Baton icon" width="192" height="192" />
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
[](https://github.com/eiei114/pi-baton/actions/workflows/ci.yml)
|
|
10
|
-
[](https://github.com/eiei114/pi-baton/actions/workflows/publish.yml)
|
|
11
|
-
[](https://www.npmjs.com/package/pi-baton)
|
|
12
|
-
[](https://www.npmjs.com/package/pi-baton)
|
|
13
|
-
[](LICENSE)
|
|
14
|
-
[](https://pi.dev/packages)
|
|
15
|
-
[](docs/release.md)
|
|
16
|
-
<a href="https://buymeacoffee.com/ekawano114m"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="217" height="60"></a>
|
|
17
|
-
|
|
18
|
-
> Run YAML-defined review loops in Pi with per-step model switching and isolated step context.
|
|
19
|
-
|
|
20
|
-
## What this is
|
|
21
|
-
|
|
22
|
-
Pi Baton is a Pi-native workflow baton runner. Define `implement → review → fix` loops in YAML, and let Pi Baton execute them with automatic baton handoff between isolated subagent steps.
|
|
23
|
-
|
|
24
|
-
## Features
|
|
25
|
-
|
|
26
|
-
- **Per-step model switching** — fast model for implement, strong model for review
|
|
27
|
-
- **Isolated step context** — no shared conversation pollution between steps
|
|
28
|
-
- **Structured review contract** — `accept`/`reject` with mandatory findings or acceptance notes
|
|
29
|
-
- **Live progress widget** — see which step is running, its agent, and judgment in real time
|
|
30
|
-
|
|
31
|
-
## Install
|
|
32
|
-
|
|
33
|
-
Install the published npm package with Pi:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
pi install npm:pi-baton
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Pin a specific version when you want reproducible installs:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
pi install npm:pi-baton@0.
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Install into the current project instead of your user Pi settings:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
pi install npm:pi-baton -l
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Or install from GitHub:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
pi install git:github.com/eiei114/pi-baton
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Try it without permanently installing:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pi -e npm:pi-baton
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Quick start
|
|
64
|
-
|
|
65
|
-
Try this package locally from a clone of this repository:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
pi -e .
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Then run:
|
|
72
|
-
|
|
73
|
-
```txt
|
|
74
|
-
/baton:new create a workflow scaffold
|
|
75
|
-
/baton:start choose workflow + task brief → idle run
|
|
76
|
-
/baton:run execute run to terminal state (with live widget)
|
|
77
|
-
/baton:status show the active run summary
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
agent:
|
|
121
|
-
model:
|
|
122
|
-
prompt:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
|
|
145
|
-
| `
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1
|
+
# Pi Baton
|
|
2
|
+
|
|
3
|
+
[](https://discord.gg/4945dXZVW5)
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="./assets/pi-baton-icon-512.png" alt="Pi Baton icon" width="192" height="192" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
[](https://github.com/eiei114/pi-baton/actions/workflows/ci.yml)
|
|
10
|
+
[](https://github.com/eiei114/pi-baton/actions/workflows/publish.yml)
|
|
11
|
+
[](https://www.npmjs.com/package/pi-baton)
|
|
12
|
+
[](https://www.npmjs.com/package/pi-baton)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
[](https://pi.dev/packages)
|
|
15
|
+
[](docs/release.md)
|
|
16
|
+
<a href="https://buymeacoffee.com/ekawano114m"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="217" height="60"></a>
|
|
17
|
+
|
|
18
|
+
> Run YAML-defined review loops in Pi with per-step model switching and isolated step context.
|
|
19
|
+
|
|
20
|
+
## What this is
|
|
21
|
+
|
|
22
|
+
Pi Baton is a Pi-native workflow baton runner. Define `implement → review → fix` loops in YAML, and let Pi Baton execute them with automatic baton handoff between isolated subagent steps.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Per-step model switching** — fast model for implement, strong model for review
|
|
27
|
+
- **Isolated step context** — no shared conversation pollution between steps
|
|
28
|
+
- **Structured review contract** — `accept`/`reject` with mandatory findings or acceptance notes
|
|
29
|
+
- **Live progress widget** — see which step is running, its agent, and judgment in real time
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Install the published npm package with Pi:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pi install npm:pi-baton
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Pin a specific version when you want reproducible installs:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pi install npm:pi-baton@0.8.5
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Install into the current project instead of your user Pi settings:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pi install npm:pi-baton -l
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install from GitHub:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pi install git:github.com/eiei114/pi-baton
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Try it without permanently installing:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pi -e npm:pi-baton
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
Try this package locally from a clone of this repository:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pi -e .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then run:
|
|
72
|
+
|
|
73
|
+
```txt
|
|
74
|
+
/baton:new create a workflow scaffold
|
|
75
|
+
/baton:start choose workflow + task brief → idle run
|
|
76
|
+
/baton:run execute run to terminal state (with live widget)
|
|
77
|
+
/baton:status show the active run summary, or the most recent finished run
|
|
78
|
+
/baton:history list recent completed or failed runs from persisted history
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use `/baton:status` for the active run or the single most recent finished run. Use `/baton:history` when you need a short list of recent completed or failed runs and their `.pi/baton/runs/<id>` directories.
|
|
82
|
+
|
|
83
|
+
Builtin workflows work out of the box — no agent setup required:
|
|
84
|
+
|
|
85
|
+
- `Default Review Loop` (`implement → review → fix`)
|
|
86
|
+
- `Two-Stage Review Gauntlet` (`draft → technical_review → editorial_review`, with rejects routed through `fix`)
|
|
87
|
+
|
|
88
|
+
## Prerequisites
|
|
89
|
+
|
|
90
|
+
Pi Baton ships builtin `worker` and `reviewer` subagents under `agents/`. They work with your current Pi model.
|
|
91
|
+
|
|
92
|
+
To override with custom agents, place `.md` files under:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
.pi/agents/worker.md
|
|
96
|
+
.pi/agents/reviewer.md
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Discovery order: project `.pi/agents/` → user `~/.pi/agent/agents/` → pi-baton builtin.
|
|
100
|
+
|
|
101
|
+
## Workflow authoring
|
|
102
|
+
|
|
103
|
+
See [`docs/workflows.md`](docs/workflows.md) for an end-to-end walkthrough: step kinds, transitions, the review contract, `iteration_cap`, model overrides, and agent discovery order.
|
|
104
|
+
|
|
105
|
+
```txt
|
|
106
|
+
/baton:new
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Pick a name and a scaffold from `default-review-loop` is written to `.pi/baton/workflows/` and opened in editor. The scaffold includes `<your-fast-model>` / `<your-strong-model>` placeholders for step-level model overrides.
|
|
110
|
+
|
|
111
|
+
The shipped `workflows/` directory also includes `two-stage-review-gauntlet.yaml`, a second builtin graph that demonstrates chaining two review gates before completion.
|
|
112
|
+
|
|
113
|
+
### Workflow YAML reference
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
name: My Review Loop
|
|
117
|
+
iteration_cap: 5
|
|
118
|
+
steps:
|
|
119
|
+
implement:
|
|
120
|
+
agent: worker
|
|
121
|
+
model: openai/gpt-5.4 # optional: fast model
|
|
122
|
+
prompt: work prompt
|
|
123
|
+
next: review
|
|
124
|
+
review:
|
|
125
|
+
agent: reviewer
|
|
126
|
+
model: anthropic/claude-opus-4-5 # optional: strong model
|
|
127
|
+
prompt: review prompt
|
|
128
|
+
on_accept: _complete # or a step name
|
|
129
|
+
on_reject: fix
|
|
130
|
+
fix:
|
|
131
|
+
agent: worker
|
|
132
|
+
model: openai/gpt-5.4
|
|
133
|
+
prompt: fix prompt
|
|
134
|
+
next: review
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- `on_accept: _complete` ends the run.
|
|
138
|
+
- `iteration_cap` prevents infinite review loops — the run fails at the cap.
|
|
139
|
+
- Review agents must return `accept`/`reject` with findings or acceptance notes.
|
|
140
|
+
|
|
141
|
+
## Package contents
|
|
142
|
+
|
|
143
|
+
| Path | Purpose |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `extensions/` | Slash-command entrypoints (`/baton:new`, `/baton:start`, `/baton:run`, `/baton:status`, `/baton:history`) |
|
|
146
|
+
| `lib/` | Workflow parser, run engine, subagent runner, review contract, UI widget |
|
|
147
|
+
| `agents/` | Builtin `worker` and `reviewer` subagent definitions |
|
|
148
|
+
| `workflows/` | Builtin workflows (`default-review-loop.yaml`, `two-stage-review-gauntlet.yaml`) |
|
|
149
|
+
| `assets/` | README / package branding assets |
|
|
150
|
+
| `docs/` | Workflow authoring guide, release and maintainer documentation |
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm install
|
|
156
|
+
npm run ci
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Release
|
|
160
|
+
|
|
161
|
+
This package uses npm Trusted Publishing with GitHub Actions OIDC — no `NPM_TOKEN` is required.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm version patch
|
|
165
|
+
git push
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
On `main`, version bumps trigger auto-release and publish workflows. See [`docs/release.md`](docs/release.md) for setup details.
|
|
169
|
+
|
|
170
|
+
## Security
|
|
171
|
+
|
|
172
|
+
Pi packages can execute code with your local permissions. Review extensions before installing third-party packages.
|
|
173
|
+
|
|
174
|
+
For vulnerability reporting, see [`SECURITY.md`](SECURITY.md).
|
|
175
|
+
|
|
176
|
+
## Links
|
|
177
|
+
|
|
178
|
+
- npm: https://www.npmjs.com/package/pi-baton
|
|
179
|
+
- GitHub: https://github.com/eiei114/pi-baton
|
|
180
|
+
- Issues: https://github.com/eiei114/pi-baton/issues
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Custom workflow authoring
|
|
2
|
+
|
|
3
|
+
This guide walks through authoring a custom Pi Baton workflow YAML. For a compact field reference, see the [Workflow YAML reference](../README.md#workflow-yaml-reference) in the README.
|
|
4
|
+
|
|
5
|
+
## Where workflows live
|
|
6
|
+
|
|
7
|
+
| Location | Source | Notes |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `.pi/baton/workflows/*.yaml` | user | Your custom workflows; listed first in `/baton:start` |
|
|
10
|
+
| `workflows/*.yaml` (package) | builtin | Shipped with pi-baton (`default-review-loop`, `two-stage-review-gauntlet`) |
|
|
11
|
+
|
|
12
|
+
Run `/baton:new` to scaffold a new file under `.pi/baton/workflows/`. The scaffold copies the default review loop and adds `<your-fast-model>` / `<your-strong-model>` placeholders on worker and reviewer steps.
|
|
13
|
+
|
|
14
|
+
The **first step key** in `steps:` is the entry step when a run starts.
|
|
15
|
+
|
|
16
|
+
## Step kinds
|
|
17
|
+
|
|
18
|
+
Every step requires `agent` and `prompt`. Pi Baton infers the step kind from its transition fields.
|
|
19
|
+
|
|
20
|
+
### Linear steps
|
|
21
|
+
|
|
22
|
+
Use `next` to move unconditionally to the next step. Linear steps are for implement, fix, draft, or any work that always proceeds forward.
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
implement:
|
|
26
|
+
agent: worker
|
|
27
|
+
prompt: |
|
|
28
|
+
Complete the task brief. End with a JSON summary block.
|
|
29
|
+
next: review
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Review steps
|
|
33
|
+
|
|
34
|
+
Use `on_accept` and `on_reject` instead of `next`. Review steps gate progress on a structured judgment.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
review:
|
|
38
|
+
agent: reviewer
|
|
39
|
+
prompt: |
|
|
40
|
+
Review the work. Return accept or reject using the JSON contract.
|
|
41
|
+
on_accept: _complete # or another step name
|
|
42
|
+
on_reject: fix
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A step **cannot** mix `next` with `on_accept` / `on_reject`. Each step is either linear or review.
|
|
46
|
+
|
|
47
|
+
## Transitions
|
|
48
|
+
|
|
49
|
+
| Field | Used by | Target |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `next` | linear | Another step name |
|
|
52
|
+
| `on_accept` | review | `_complete` or another step name |
|
|
53
|
+
| `on_reject` | review | Another step name (typically a fix step) |
|
|
54
|
+
|
|
55
|
+
`_complete` is the only special token. It marks a successful terminal state — the run completes when a review step accepts into `_complete`.
|
|
56
|
+
|
|
57
|
+
Transition targets must reference steps defined in the same `steps:` map (except `_complete`).
|
|
58
|
+
|
|
59
|
+
### Choosing `on_accept` vs `next`
|
|
60
|
+
|
|
61
|
+
- **`next`** — the step always hands off to the same successor. Use for deterministic pipelines (`draft → technical_review`).
|
|
62
|
+
- **`on_accept` / `on_reject`** — the successor depends on reviewer judgment. Use when a gate can block or redirect work.
|
|
63
|
+
|
|
64
|
+
### Chaining review gates
|
|
65
|
+
|
|
66
|
+
The builtin `two-stage-review-gauntlet` demonstrates two review steps before completion:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
draft → technical_review ──accept──→ editorial_review ──accept──→ _complete
|
|
70
|
+
│ │
|
|
71
|
+
└──────── reject ──→ fix ──────┘
|
|
72
|
+
│
|
|
73
|
+
└── next → technical_review
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
After a reject, route through a fix step and re-enter the earliest gate that must re-validate the changes.
|
|
77
|
+
|
|
78
|
+
## Review contract
|
|
79
|
+
|
|
80
|
+
Review steps require agents to end with a fenced JSON block. Pi Baton parses `judgment`, and validates the payload before choosing a branch.
|
|
81
|
+
|
|
82
|
+
**Accept** — `judgment` must be `"accept"` and `acceptanceNote` must be non-empty:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{"summary":"Short review summary","judgment":"accept","acceptanceNote":"Why this passes"}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Reject** — `judgment` must be `"reject"` and `findings` must be a non-empty string array:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{"summary":"Short review summary","judgment":"reject","findings":["Actionable issue 1"]}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Non-review steps use `summary` when present and fall back to the output text when it is absent. If parsing fails on a review step, the run fails with a `ReviewContractError`.
|
|
95
|
+
|
|
96
|
+
Builtin `reviewer` agent prompts include the contract. Custom review agents should instruct the model to follow the same shape.
|
|
97
|
+
|
|
98
|
+
## `iteration_cap`
|
|
99
|
+
|
|
100
|
+
`iteration_cap` is a required positive integer. It limits how many times a review step can **reject** before the run fails.
|
|
101
|
+
|
|
102
|
+
- The counter starts at `0` when a run begins.
|
|
103
|
+
- Each review **reject** increments the counter by one.
|
|
104
|
+
- Before executing a review step, if `iteration >= iteration_cap`, the run fails with `Iteration cap (N) reached`.
|
|
105
|
+
- Accepts and linear steps do not increment the counter.
|
|
106
|
+
|
|
107
|
+
Example: `iteration_cap: 5` allows up to five review reject cycles (reviews at iterations 0–4). After the fifth reject raises the counter to 5, the next review attempt is blocked.
|
|
108
|
+
|
|
109
|
+
Set the cap high enough for your loop depth but low enough to prevent runaway reject cycles.
|
|
110
|
+
|
|
111
|
+
## Model overrides
|
|
112
|
+
|
|
113
|
+
Each step may set an optional `model` field (`provider/model-id`, e.g. `openai/gpt-5.4`).
|
|
114
|
+
|
|
115
|
+
| Situation | Model used |
|
|
116
|
+
|---|---|
|
|
117
|
+
| Step defines a concrete `model` | That model |
|
|
118
|
+
| Step omits `model` | Current Pi session model |
|
|
119
|
+
| Scaffold placeholder (`<your-fast-model>`) | Current Pi session model |
|
|
120
|
+
|
|
121
|
+
Convention: use a faster model on worker/linear steps and a stronger model on review steps. `/baton:new` inserts placeholders as a reminder — replace them with real model IDs or remove them to inherit the session model.
|
|
122
|
+
|
|
123
|
+
Step-level overrides apply per subagent invocation; other steps in the same run can use different models.
|
|
124
|
+
|
|
125
|
+
## Agent discovery order
|
|
126
|
+
|
|
127
|
+
Each step's `agent` value must match a Pi subagent `name` from frontmatter. Pi Baton merges agents from three locations; when names collide, **project overrides user overrides builtin**:
|
|
128
|
+
|
|
129
|
+
1. **Project** — nearest `.pi/agents/*.md` walking up from the run's target directory
|
|
130
|
+
2. **User** — `~/.pi/agent/agents/*.md`
|
|
131
|
+
3. **pi-baton builtin** — `agents/` in the package (`worker`, `reviewer`)
|
|
132
|
+
|
|
133
|
+
If a workflow references an agent name that cannot be resolved, validation fails before the run starts.
|
|
134
|
+
|
|
135
|
+
To customize behavior, add `.pi/agents/worker.md` or `.pi/agents/reviewer.md` in your project. Use the same `name` as the workflow references so your file overrides the builtin definition.
|
|
136
|
+
|
|
137
|
+
## End-to-end checklist
|
|
138
|
+
|
|
139
|
+
1. Run `/baton:new` (or copy a builtin workflow into `.pi/baton/workflows/`).
|
|
140
|
+
2. Set `name`, `iteration_cap`, and define `steps:` with the first step as entry.
|
|
141
|
+
3. Assign `agent` values that exist in your agent discovery path.
|
|
142
|
+
4. Add optional `model` overrides on steps that need a different model.
|
|
143
|
+
5. Write prompts that end with the JSON contract (review steps must include judgment rules).
|
|
144
|
+
6. Wire transitions: linear steps use `next`; review steps use `on_accept` / `on_reject`.
|
|
145
|
+
7. Run `/baton:start` to pick the workflow, then `/baton:run` to execute.
|
|
146
|
+
8. Run `/baton:status` to inspect the active run, or the most recent finished run after `/baton:run` completes.
|
|
147
|
+
9. Run `/baton:history` to list recent completed or failed runs when you need older terminal outcomes or run directories. `/baton:status` stays focused on the active run or the latest finished run only.
|
|
148
|
+
|
|
149
|
+
## Examples
|
|
150
|
+
|
|
151
|
+
Study the shipped workflows for complete, working graphs:
|
|
152
|
+
|
|
153
|
+
- [`workflows/default-review-loop.yaml`](../workflows/default-review-loop.yaml) — classic `implement → review → fix` loop
|
|
154
|
+
- [`workflows/two-stage-review-gauntlet.yaml`](../workflows/two-stage-review-gauntlet.yaml) — chained review gates with a shared fix step
|
package/extensions/index.ts
CHANGED
|
@@ -10,8 +10,13 @@ import {
|
|
|
10
10
|
createIdleRun,
|
|
11
11
|
loadActiveRun,
|
|
12
12
|
loadMostRecentTerminalRun,
|
|
13
|
+
loadTerminalRunHistory,
|
|
13
14
|
} from "../lib/run-store.ts";
|
|
14
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
NO_ACTIVE_RUN_MESSAGE,
|
|
17
|
+
formatHistorySummary,
|
|
18
|
+
formatStatusSummary,
|
|
19
|
+
} from "../lib/status.ts";
|
|
15
20
|
import { createSubagentRunner } from "../lib/subagent-runner.ts";
|
|
16
21
|
import { WorkflowNameCollisionError, createWorkflowScaffold } from "../lib/workflow-scaffold.ts";
|
|
17
22
|
import { WorkflowValidationError } from "../lib/workflow-schema.ts";
|
|
@@ -199,4 +204,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
199
204
|
ctx.ui.notify(formatStatusSummary(manifest), "info");
|
|
200
205
|
},
|
|
201
206
|
});
|
|
207
|
+
|
|
208
|
+
pi.registerCommand("baton:history", {
|
|
209
|
+
description: "List recent completed or failed Baton runs from persisted history",
|
|
210
|
+
handler: async (_args, ctx) => {
|
|
211
|
+
const history = await loadTerminalRunHistory(ctx.cwd);
|
|
212
|
+
ctx.ui.notify(formatHistorySummary(history), "info");
|
|
213
|
+
},
|
|
214
|
+
});
|
|
202
215
|
}
|