pi-agent-fleet 0.2.0 → 0.4.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/README.md +84 -23
- package/assets/canvas-node-peek.png +0 -0
- package/assets/canvas.png +0 -0
- package/package.json +16 -8
- package/src/canvas-client.tsx +669 -0
- package/src/canvas.ts +881 -0
- package/src/command.ts +247 -0
- package/src/controller.ts +302 -0
- package/src/dag.ts +72 -3
- package/src/edits.ts +107 -0
- package/src/fleet-store.ts +55 -0
- package/src/index.ts +8 -594
- package/src/insert.ts +90 -0
- package/src/model-resolution.ts +73 -0
- package/src/planner.ts +148 -0
- package/src/preferences.ts +103 -0
- package/src/prompts.ts +7 -0
- package/src/runner.ts +41 -8
- package/src/scheduler.ts +159 -8
- package/src/tools.ts +348 -0
- package/src/types.ts +7 -1
- package/src/ui.ts +51 -12
- package/src/viz.ts +3 -2
- package/src/worktree.ts +75 -0
package/README.md
CHANGED
|
@@ -9,6 +9,16 @@ DAG-of-agents fleets for [pi](https://github.com/earendil-works/pi-coding-agent)
|
|
|
9
9
|
└─ ○ reviewer (k3) · waiting on builder-relaunch
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Demo
|
|
13
|
+
|
|
14
|
+
Live browser canvas — per-node status, turns, tokens, cost, and click-to-peek session tail:
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
Node detail side panel — peek a running node's recent session without leaving the canvas:
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
12
22
|
## Why
|
|
13
23
|
|
|
14
24
|
One agent is a tool. A **fleet** is a workflow: researchers feed builders, builders feed reviewers, reviewers gate quality — all visible, all recorded, all contract-checked. Fleets run in-process via pi's SDK: any provider pi is logged into (Claude, Codex, Kimi, …) works per-node.
|
|
@@ -32,26 +42,51 @@ Ask your pi session (the LLM drives the tools):
|
|
|
32
42
|
> combiner (depends on both) writes output/sum.md with the total.
|
|
33
43
|
> Each declares its output as a markdown contract.
|
|
34
44
|
|
|
35
|
-
The agent calls `fleet_plan` (
|
|
36
|
-
|
|
37
|
-
## Fleet modes
|
|
45
|
+
The agent calls `fleet_design` (if you describe it in prose) or `fleet_plan` (if you already have JSON), you confirm the preview, then `fleet_launch` runs it. Watch the live widget or open the browser canvas; read the report at `.fleet/<name>-<ts>/report.md`.
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
## Writing a fleet
|
|
40
48
|
|
|
41
49
|
```json
|
|
42
50
|
{
|
|
43
51
|
"fleet_name": "auth-research",
|
|
44
52
|
"type": "dag",
|
|
45
|
-
"config": {
|
|
53
|
+
"config": {
|
|
54
|
+
"max_concurrent": 4,
|
|
55
|
+
"model": "gpt-5.4-mini",
|
|
56
|
+
"effort": "medium",
|
|
57
|
+
"warn_cost_usd": 10
|
|
58
|
+
},
|
|
46
59
|
"workers": [
|
|
47
|
-
{
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
60
|
+
{
|
|
61
|
+
"id": "research",
|
|
62
|
+
"type": "research",
|
|
63
|
+
"task": "…",
|
|
64
|
+
"outputs": [{ "path": "output/findings.md", "kind": "markdown", "required": true }]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "build",
|
|
68
|
+
"type": "code-run",
|
|
69
|
+
"task": "…",
|
|
70
|
+
"depends_on": ["research"],
|
|
71
|
+
"model": "kimi-coding/k3",
|
|
72
|
+
"effort": "high",
|
|
73
|
+
"outputs": [{ "path": "src/auth/login.ts", "kind": "file-exists", "required": true }]
|
|
74
|
+
}
|
|
51
75
|
]
|
|
52
76
|
}
|
|
53
77
|
```
|
|
54
78
|
|
|
79
|
+
- `config.model` / `config.effort` — fleet-wide defaults; per-worker `model` and `effort` override.
|
|
80
|
+
- `effort` maps to pi thinking levels: `off | minimal | low | medium | high | xhigh | max`.
|
|
81
|
+
- `config.warn_cost_usd` — soft cost guardrail surfaced in the live widget.
|
|
82
|
+
- `iterate: false` — run the node once at iteration 1 and carry its outputs forward.
|
|
83
|
+
- `worktree: true` — run the node in a dedicated git worktree.
|
|
84
|
+
- Worker types `research`, `code-run`, `reviewer`, `write`, `read-only` each get a tailored tool set.
|
|
85
|
+
|
|
86
|
+
## Fleet modes
|
|
87
|
+
|
|
88
|
+
**One-shot DAG** — static dependency graph, parallel layers, contracts at exit.
|
|
89
|
+
|
|
55
90
|
**Iterative fleet** — reviewer-gated replay until quality passes:
|
|
56
91
|
|
|
57
92
|
```json
|
|
@@ -64,7 +99,7 @@ The agent calls `fleet_plan` (validates + ASCII preview), you confirm, `fleet_la
|
|
|
64
99
|
|
|
65
100
|
A reviewer node writes a verdict contract (`verdict: lgtm | iterate | escalate` + actionable body). `iterate` → builders get the review injected as feedback next iteration. `lgtm` × `lgtm_count` consecutive → completed. `escalate` → fleet pauses and notifies you. `gate: "none"` → free-running loop (autoresearch pattern: eval instructions live in the worker's task text).
|
|
66
101
|
|
|
67
|
-
**Worktree mode** — `worktree: true` on a node: the worker
|
|
102
|
+
**Worktree mode** — `worktree: true` on a node: the worker runs in a dedicated git worktree on a deterministic branch (`fleet/<fleet-name>/<node-id>`). The extension creates the worktree, commits the worker's changes, and, when two or more worktree workers exist, auto-injects a `fleet-integrator` node that merges their branches in dependency order before the agent runs. Overlapping repo-relative output paths without an ordered handoff are rejected at plan time. Merge conflicts surface as a failed integrator with a `status_note` listing the files, so the operator can resolve and relaunch.
|
|
68
103
|
|
|
69
104
|
**Run-once vs replay nodes** — `iterate: false`: node runs at iteration 1 only, outputs carry over (e.g. research that doesn't change).
|
|
70
105
|
|
|
@@ -77,7 +112,8 @@ Every worker declares `outputs[]` with kinds, verified in code at worker exit be
|
|
|
77
112
|
| `markdown` | exists, non-empty, starts with `#` |
|
|
78
113
|
| `file-exists` | exists, non-empty (repo-relative paths = code edits) |
|
|
79
114
|
| `verdict` | `verdict: lgtm\|iterate\|escalate` line + non-empty body |
|
|
80
|
-
| `json`
|
|
115
|
+
| `json` | parses as JSON |
|
|
116
|
+
| `yaml` | parses as YAML |
|
|
81
117
|
|
|
82
118
|
Failed required contract → `contract_failed`, dependents blocked, orchestrator notified. No silent passes.
|
|
83
119
|
|
|
@@ -85,33 +121,58 @@ Failed required contract → `contract_failed`, dependents blocked, orchestrator
|
|
|
85
121
|
|
|
86
122
|
| tool | purpose |
|
|
87
123
|
|---|---|
|
|
124
|
+
| `fleet_design` | draft a fleet DAG from plain-language requirements (planner agent → validated JSON + preview) |
|
|
88
125
|
| `fleet_plan` | validate + preview a fleet definition (no launch) |
|
|
89
|
-
| `fleet_launch` | launch
|
|
90
|
-
| `fleet_status` | live DAG status |
|
|
91
|
-
| `fleet_pause` / `fleet_resume` | pause/resume loop fleets at iteration boundary |
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
126
|
+
| `fleet_launch` | launch the planned fleet after user confirmation; `skip_confirm` for unattended runs |
|
|
127
|
+
| `fleet_status` | live DAG status and widget lines |
|
|
128
|
+
| `fleet_pause` / `fleet_resume` | pause/resume loop fleets at the next iteration boundary |
|
|
129
|
+
| `fleet_kill` | kill all, or kill a single node by worker id |
|
|
130
|
+
| `fleet_relaunch` | re-run a failed/killed node and its blocked downstream; optional model override |
|
|
131
|
+
| `fleet_add_node` | insert new workers into a running fleet mid-flight |
|
|
132
|
+
| `fleet_edit` | edit a pending node's model/effort/task, or fleet config mid-run |
|
|
133
|
+
| `fleet_report` | regenerate the fleet markdown report |
|
|
134
|
+
| `fleet_canvas` | open a browser canvas; `?demo=1` shows synthetic data for UI iteration |
|
|
95
135
|
|
|
96
|
-
`/fleet viz | status | clear | pause | resume | relaunch <id> [model] |
|
|
136
|
+
`/fleet viz | status | clear | pause | resume | kill all|<node_id> | relaunch <id> [model] | add <json> | edit <node_id>|config ... | configure [show|set k v] | canvas [open|url|stop]`
|
|
137
|
+
|
|
138
|
+
## Runtime mutation
|
|
139
|
+
|
|
140
|
+
Fleets are not frozen after launch. You can kill a single stuck node, relaunch it with a stronger model, edit a pending node's task, or inject new workers with `fleet_add_node`. Inserted nodes validate against the existing DAG (unique ids, acyclic, loop-gate rules) and start dispatching as soon as their dependencies complete.
|
|
141
|
+
|
|
142
|
+
## Preferences
|
|
143
|
+
|
|
144
|
+
Set fleet-wide defaults in `~/.pi/agent/fleet.json`:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"max_concurrent": 4,
|
|
149
|
+
"model": "gpt-5.4-mini",
|
|
150
|
+
"effort": "medium",
|
|
151
|
+
"warn_cost_usd": 10
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
These are merged into `fleet_plan` results. Manage them with `/fleet configure show | set <key> <value>`.
|
|
97
156
|
|
|
98
157
|
## Records
|
|
99
158
|
|
|
100
|
-
Everything lands in `.fleet/<name>-<ts>/` (git-ignored): `state.json` (single source of truth, atomic writes), per-worker `prompt.md` + `session.jsonl` + outputs, per-iteration archives, and a machine-written `report.md` with per-worker turns/tokens/cost, contract results, verdict history, and git diff stats.
|
|
159
|
+
Everything lands in `.fleet/<name>-<ts>/` (git-ignored): `state.json` (single source of truth, atomic writes), per-worker `prompt.md` + `session.jsonl` + outputs, per-iteration archives, and a machine-written `report.md` with per-worker turns/tokens/cost, contract results, verdict history, and git diff stats. Completed nodes keep their stats visible in the widget and report after the fleet ends.
|
|
101
160
|
|
|
102
|
-
## Model selection
|
|
161
|
+
## Model selection and effort
|
|
103
162
|
|
|
104
|
-
Fleet-wide default via `config.model`; per-node override via `worker.model`. Any model pi can resolve
|
|
163
|
+
Fleet-wide default via `config.model` and `config.effort`; per-node override via `worker.model` and `worker.effort`. Any model pi can resolve works, including any provider pi is logged into. Cheap models for trivial writers, strong models for reviewers:
|
|
105
164
|
|
|
106
165
|
```json
|
|
107
|
-
{ "id": "reviewer", "type": "reviewer", "model": "kimi-coding/k3",
|
|
166
|
+
{ "id": "reviewer", "type": "reviewer", "model": "kimi-coding/k3", "effort": "high" }
|
|
108
167
|
```
|
|
109
168
|
|
|
169
|
+
Model refs are validated at plan and launch time so bad names fail fast. There is no baked-in default provider: the extension uses whatever pi has configured.
|
|
170
|
+
|
|
110
171
|
## Development
|
|
111
172
|
|
|
112
173
|
```bash
|
|
113
174
|
npm install
|
|
114
|
-
npm test #
|
|
175
|
+
npm test # 232 tests, zero-API (fake session factory)
|
|
115
176
|
npm run typecheck
|
|
116
177
|
```
|
|
117
178
|
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-fleet",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DAG-of-agents fleets for pi
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "DAG-of-agents fleets for pi — parallel workers with contracts, reviewer-gated iteration loops, and live progress",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "vitest run",
|
|
@@ -9,21 +9,22 @@
|
|
|
9
9
|
"typecheck": "tsc --noEmit"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
13
12
|
"@earendil-works/pi-ai": "*",
|
|
13
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
14
14
|
"typebox": "*"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@earendil-works/pi-coding-agent": "^0.80.0",
|
|
18
17
|
"@earendil-works/pi-ai": "^0.80.0",
|
|
18
|
+
"@earendil-works/pi-coding-agent": "^0.80.0",
|
|
19
|
+
"@types/node": "^22.0.0",
|
|
19
20
|
"typescript": "^5.5.0",
|
|
20
|
-
"vitest": "^2.1.0"
|
|
21
|
-
"@types/node": "^22.0.0"
|
|
21
|
+
"vitest": "^2.1.0"
|
|
22
22
|
},
|
|
23
23
|
"pi": {
|
|
24
24
|
"extensions": [
|
|
25
25
|
"./src/index.ts"
|
|
26
|
-
]
|
|
26
|
+
],
|
|
27
|
+
"image": "https://raw.githubusercontent.com/sagarsrc/pi-agent-fleet/v0.4.0/assets/canvas.png"
|
|
27
28
|
},
|
|
28
29
|
"license": "MIT",
|
|
29
30
|
"author": "Sagar Sarkale",
|
|
@@ -45,8 +46,15 @@
|
|
|
45
46
|
],
|
|
46
47
|
"files": [
|
|
47
48
|
"src/",
|
|
49
|
+
"assets/",
|
|
48
50
|
"examples/",
|
|
49
51
|
"README.md",
|
|
50
52
|
"LICENSE"
|
|
51
|
-
]
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@xyflow/react": "^12.11.2",
|
|
56
|
+
"esbuild": "^0.21.5",
|
|
57
|
+
"react": "^19.2.8",
|
|
58
|
+
"react-dom": "^19.2.8"
|
|
59
|
+
}
|
|
52
60
|
}
|