pi-squad 0.6.5 → 0.14.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 +200 -318
- package/package.json +21 -3
- package/src/advisor.ts +145 -0
- package/src/agent-pool.ts +39 -15
- package/src/agents/_defaults/architect.json +8 -1
- package/src/agents/_defaults/backend.json +9 -1
- package/src/agents/_defaults/debugger.json +8 -1
- package/src/agents/_defaults/devops.json +9 -1
- package/src/agents/_defaults/docs.json +8 -1
- package/src/agents/_defaults/frontend.json +10 -1
- package/src/agents/_defaults/fullstack.json +8 -1
- package/src/agents/_defaults/planner.json +7 -1
- package/src/agents/_defaults/qa.json +8 -1
- package/src/agents/_defaults/researcher.json +8 -1
- package/src/agents/_defaults/reviewer.json +10 -0
- package/src/agents/_defaults/security.json +8 -1
- package/src/index.ts +375 -212
- package/src/monitor.ts +20 -7
- package/src/panel/message-view.ts +2 -2
- package/src/panel/squad-panel.ts +3 -3
- package/src/panel/squad-widget.ts +3 -3
- package/src/panel/task-list.ts +2 -2
- package/src/plan-rules.ts +134 -0
- package/src/planner.ts +18 -14
- package/src/protocol.ts +11 -20
- package/src/scheduler.ts +172 -95
- package/src/skills/squad-architecture/SKILL.md +53 -0
- package/src/skills/squad-backend-dev/SKILL.md +45 -0
- package/src/skills/squad-code-review/SKILL.md +89 -0
- package/src/skills/{collaboration → squad-collaboration}/SKILL.md +6 -2
- package/src/skills/squad-debugging/SKILL.md +61 -0
- package/src/skills/squad-frontend-dev/SKILL.md +51 -0
- package/src/skills/squad-protocol/SKILL.md +19 -0
- package/src/skills/squad-qa-testing/SKILL.md +72 -0
- package/src/skills/squad-security-audit/SKILL.md +43 -0
- package/src/skills/squad-supervisor/SKILL.md +85 -11
- package/src/skills/{verification → squad-verification}/SKILL.md +1 -1
- package/src/store.ts +24 -26
- package/src/types.ts +48 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ Multi-agent collaboration extension for [pi](https://github.com/badlogic/pi-mono
|
|
|
8
8
|
# From npm
|
|
9
9
|
pi install npm:pi-squad
|
|
10
10
|
|
|
11
|
+
# From git
|
|
12
|
+
pi install git:github.com/picassio/pi-squad
|
|
13
|
+
|
|
11
14
|
# Or symlink for development
|
|
12
15
|
ln -sf /path/to/pi-squad/src ~/.pi/agent/extensions/squad
|
|
13
16
|
```
|
|
@@ -22,11 +25,11 @@ Ask pi to do something complex. It calls the `squad` tool automatically:
|
|
|
22
25
|
> Build a REST API with authentication, tests, and documentation
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
The planner agent reads your codebase and creates a task breakdown automatically. Or
|
|
28
|
+
The planner agent reads your codebase and creates a task breakdown automatically. Or define tasks explicitly:
|
|
26
29
|
|
|
27
30
|
```
|
|
28
31
|
> Use squad: goal="Build task API", tasks=[
|
|
29
|
-
{id: "api", title: "Build CRUD endpoints
|
|
32
|
+
{id: "api", title: "Build CRUD endpoints", agent: "backend"},
|
|
30
33
|
{id: "tests", title: "Write tests", agent: "qa", depends: ["api"]},
|
|
31
34
|
{id: "docs", title: "Write README", agent: "docs", depends: ["api"]}
|
|
32
35
|
]
|
|
@@ -34,421 +37,300 @@ The planner agent reads your codebase and creates a task breakdown automatically
|
|
|
34
37
|
|
|
35
38
|
### What Happens
|
|
36
39
|
|
|
37
|
-
1. Planner analyzes the codebase and creates tasks
|
|
38
|
-
2. A **live widget** appears above the editor showing task
|
|
39
|
-
3.
|
|
40
|
+
1. **Planner** analyzes the codebase and creates tasks with dependencies
|
|
41
|
+
2. A **live widget** appears above the editor showing task progress
|
|
42
|
+
3. **Specialist agents** spawn as separate pi processes, working in parallel where dependencies allow
|
|
40
43
|
4. QA agents can trigger **automatic rework loops** when they find bugs
|
|
41
|
-
5.
|
|
44
|
+
5. On completion, pi receives a summary with each task's output
|
|
42
45
|
6. Multiple squads can run concurrently across different projects
|
|
43
46
|
|
|
44
|
-
##
|
|
47
|
+
## Features
|
|
45
48
|
|
|
46
|
-
###
|
|
49
|
+
### Dependency-Aware Scheduling
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
Tasks define dependencies. The scheduler resolves the DAG, spawns ready tasks up to `maxConcurrency`, and auto-unblocks dependents when tasks complete.
|
|
49
52
|
|
|
50
53
|
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
◻ docs (docs) ← api
|
|
54
|
+
architect → backend ──→ qa
|
|
55
|
+
↑
|
|
56
|
+
architect → frontend ─┘
|
|
55
57
|
```
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
- Per-task elapsed time (warning color after 3 minutes)
|
|
59
|
-
- Live tool call preview for running tasks
|
|
60
|
-
- Stale detection — shows `⏳ idle` when agent has no output for 2+ minutes
|
|
61
|
-
- Responsive — caps visible tasks on small terminals, shows `+N more` overflow
|
|
62
|
-
- Completion duration for finished tasks
|
|
63
|
-
|
|
64
|
-
### Status Bar (footer)
|
|
59
|
+
Architect runs first. Backend and frontend run in parallel after architect completes. QA waits for both.
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
⏳ squad 2/3 $0.58
|
|
68
|
-
```
|
|
61
|
+
### QA Rework Loop
|
|
69
62
|
|
|
70
|
-
|
|
63
|
+
When a QA agent outputs `## Verdict: FAIL`, the scheduler automatically:
|
|
71
64
|
|
|
72
|
-
|
|
65
|
+
1. Creates a **fix task** for the original agent with QA feedback
|
|
66
|
+
2. Creates a **retest task** for QA, blocked until the fix completes
|
|
67
|
+
3. Loops up to `maxRetries` (default: 2), then escalates
|
|
73
68
|
|
|
74
|
-
**Task list** with sticky summary at bottom:
|
|
75
69
|
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
│ ⏳ tests (qa) 45s │
|
|
79
|
-
│ ◻ docs (docs) blocked │
|
|
80
|
-
│ │
|
|
81
|
-
│ ── tests (live) ───────────────────── │
|
|
82
|
-
│ → bash npm test │
|
|
83
|
-
│ │
|
|
84
|
-
│ 2/3 · $0.58 · 3m │
|
|
85
|
-
├──────────────────────────────────────────────┤
|
|
86
|
-
│ ↑↓ nav ⏎ msgs m send p pause ^q close │
|
|
87
|
-
╰──────────────────────────────────────────────╯
|
|
70
|
+
api (backend) ✓ → qa (qa) ✗ found bug
|
|
71
|
+
→ api-fix-1 (backend) ✓ → qa-retest-1 (qa) ✓ all passing
|
|
88
72
|
```
|
|
89
73
|
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
╭─ tests · qa ⏳ ─────────────────────────────╮
|
|
93
|
-
│ 10:03 qa │
|
|
94
|
-
│ Starting test implementation. Will cover │
|
|
95
|
-
│ all CRUD endpoints, validation, and │
|
|
96
|
-
│ edge cases for empty input. │
|
|
97
|
-
│ 10:04 qa │
|
|
98
|
-
│ → write src/tasks.test.js │
|
|
99
|
-
│ 10:05 YOU │
|
|
100
|
-
│ Also test edge cases for empty input │
|
|
101
|
-
│ ─ 65% ─ 24 msgs ─ ↑↓ scroll │
|
|
102
|
-
├──────────────────────────────────────────────┤
|
|
103
|
-
│ ↑↓ scroll m send esc back ^q close │
|
|
104
|
-
╰──────────────────────────────────────────────╯
|
|
105
|
-
```
|
|
74
|
+
### Built-in Engineering Skills
|
|
106
75
|
|
|
107
|
-
|
|
76
|
+
9 skills ship with the extension. Every squad agent automatically loads them:
|
|
108
77
|
|
|
109
|
-
|
|
|
78
|
+
| Skill | Purpose |
|
|
110
79
|
|---|---|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
| `/squad clear` | Dismiss widget, deactivate view |
|
|
121
|
-
| `/squad cleanup` | Delete squad data (select one or all) |
|
|
122
|
-
| `/squad cleanup all` | Delete all squad data |
|
|
123
|
-
| `/squad enable` | Enable pi-squad (tools, widget, system prompt) |
|
|
124
|
-
| `/squad disable` | Disable pi-squad completely |
|
|
80
|
+
| `squad-architecture` | API contract definition, shared types, project structure, decision documentation |
|
|
81
|
+
| `squad-backend-dev` | REST conventions, database patterns, auth implementation, error handling, security |
|
|
82
|
+
| `squad-frontend-dev` | React patterns, state management, Tailwind CSS, accessibility, API integration |
|
|
83
|
+
| `squad-qa-testing` | Test strategy, checklist, evidence requirements, verdict format, rework flow |
|
|
84
|
+
| `squad-security-audit` | Vulnerability checklist, common patterns, reporting format |
|
|
85
|
+
| `squad-verification` | Verify before claiming done, evidence-based completion |
|
|
86
|
+
| `squad-collaboration` | Building on others' work, asking questions, sharing knowledge |
|
|
87
|
+
| `squad-protocol` | Communication rules, @mention syntax, completion format |
|
|
88
|
+
| `squad-supervisor` | Squad management guidance for the main pi agent |
|
|
125
89
|
|
|
126
|
-
|
|
90
|
+
Skills are prefixed with `squad-` to avoid conflicts with user or project skills. Squad agents also inherit all skills from the main pi session (user skills, package skills, project skills).
|
|
127
91
|
|
|
128
|
-
|
|
129
|
-
|---|---|---|
|
|
130
|
-
| `Ctrl+Q` | Anywhere | Toggle squad panel overlay |
|
|
131
|
-
| `↑↓` or `jk` | Panel | Navigate tasks / scroll messages |
|
|
132
|
-
| `Enter` | Panel task list | View task messages |
|
|
133
|
-
| `Esc` | Panel message view | Back to task list |
|
|
134
|
-
| `m` | Panel | Send message to selected task's agent |
|
|
135
|
-
| `p` | Panel task list | Pause/resume task |
|
|
136
|
-
| `x` | Panel task list | Cancel task |
|
|
137
|
-
| `q` | Panel task list | Close panel |
|
|
92
|
+
### 11 Specialist Agents
|
|
138
93
|
|
|
139
|
-
|
|
94
|
+
Bundled agent definitions are copied to `~/.pi/squad/agents/` on first run. Edit them freely — the extension never overwrites existing files.
|
|
140
95
|
|
|
141
|
-
|
|
|
142
|
-
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
96
|
+
| Agent | Role | Tags |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `architect` | Software Architect | architecture, design, patterns |
|
|
99
|
+
| `backend` | Backend Engineer | api, server, database, auth |
|
|
100
|
+
| `frontend` | Frontend Engineer | react, ui, css, tailwind, accessibility |
|
|
101
|
+
| `fullstack` | Fullstack Developer | general, coding, implementation |
|
|
102
|
+
| `qa` | QA Engineer | testing, verification, e2e |
|
|
103
|
+
| `reviewer` | Code Reviewer (read-only) | review, code-quality, over-engineering |
|
|
104
|
+
| `security` | Security Engineer | audit, vulnerability, threat-modeling |
|
|
105
|
+
| `debugger` | Debugger & Root Cause Analyst | debugging, investigation, bugs |
|
|
106
|
+
| `devops` | DevOps Engineer | ci-cd, docker, deployment |
|
|
107
|
+
| `docs` | Technical Writer | documentation, readme, api-docs |
|
|
108
|
+
| `researcher` | Research Analyst | research, analysis, exploration |
|
|
109
|
+
| `planner` | Project Planner | planning, architecture, coordination |
|
|
147
110
|
|
|
148
|
-
|
|
111
|
+
### Agent Collaboration
|
|
149
112
|
|
|
150
|
-
|
|
113
|
+
**Chain context**: When task A completes, its output is injected into task B's system prompt. Downstream agents know what was built.
|
|
151
114
|
|
|
152
|
-
|
|
115
|
+
**Shared filesystem**: All agents work in the same project directory. Upstream agents create files, downstream agents read and modify them.
|
|
153
116
|
|
|
154
|
-
|
|
155
|
-
> Build the auth API → starts squad-1
|
|
156
|
-
> Build the dashboard UI → starts squad-2 (runs in parallel)
|
|
117
|
+
**Sibling awareness**: Parallel agents see each other's status and modified files, with warnings about shared file edits.
|
|
157
118
|
|
|
158
|
-
|
|
159
|
-
/squad select → switch widget/panel focus
|
|
160
|
-
```
|
|
119
|
+
**@mention routing**: Agents write `@frontend what token format?` in their output. The router delivers it in real-time via RPC `steer()`.
|
|
161
120
|
|
|
162
|
-
|
|
121
|
+
### Smart Planner
|
|
163
122
|
|
|
164
|
-
|
|
123
|
+
The planner creates task breakdowns with proper dependency ordering:
|
|
124
|
+
- Frontend tasks depend on backend API tasks (so frontend can test against real endpoints)
|
|
125
|
+
- Parallel tasks that share interfaces get a design/architecture task first
|
|
126
|
+
- Task descriptions include specific API paths, schemas, and conventions
|
|
165
127
|
|
|
166
|
-
When
|
|
128
|
+
When the main agent provides tasks directly (via the `tasks` parameter), unknown agent names are automatically remapped to `fullstack` instead of failing.
|
|
167
129
|
|
|
168
|
-
|
|
169
|
-
2. **Creates a rework task** for the original agent with QA feedback injected into its system prompt
|
|
170
|
-
3. **Creates a retest task** for QA, blocked until the rework completes
|
|
171
|
-
4. After fix, QA re-tests. If still failing, loops up to `maxRetries` (default: 2)
|
|
172
|
-
5. If retry limit exceeded, **escalates** to the main agent for human decision
|
|
130
|
+
## User Interface
|
|
173
131
|
|
|
174
|
-
###
|
|
132
|
+
### Widget (above editor)
|
|
133
|
+
|
|
134
|
+
Shows live squad progress. Truncated to terminal width — no wrapping, deterministic height.
|
|
175
135
|
|
|
176
136
|
```
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
→ auth-fix-2 (backend) ✓ — fixed again [auto-created]
|
|
182
|
-
→ qa-auth-retest-2 (qa) ✓ — all tests pass ✓
|
|
137
|
+
⏳ squad Build task API 2/3 $0.58 3m12s ^q detail · /squad msg
|
|
138
|
+
✓ api (backend) 2m12s Created CRUD REST API with validation
|
|
139
|
+
⏳ tests (qa) 45s → bash npm test
|
|
140
|
+
◻ docs (docs) ← api
|
|
183
141
|
```
|
|
184
142
|
|
|
185
|
-
###
|
|
186
|
-
|
|
187
|
-
The rework agent's system prompt includes:
|
|
188
|
-
- Original task output (what was built)
|
|
189
|
-
- QA feedback (what failed, with specific issues)
|
|
190
|
-
- Instructions to make targeted fixes, not rewrite everything
|
|
191
|
-
|
|
192
|
-
### QA verdict format
|
|
143
|
+
### Status Bar
|
|
193
144
|
|
|
194
|
-
QA agents should end their output with a structured verdict:
|
|
195
|
-
|
|
196
|
-
```markdown
|
|
197
|
-
## Verdict: PASS
|
|
198
|
-
All 42 tests passing. No issues found.
|
|
199
145
|
```
|
|
200
|
-
|
|
201
|
-
```markdown
|
|
202
|
-
## Verdict: FAIL
|
|
203
|
-
|
|
204
|
-
## Issues
|
|
205
|
-
1. **[src/auth.ts:45]** JWT expiry not enforced
|
|
206
|
-
- Expected: 401 for expired tokens
|
|
207
|
-
- Got: 200 (token accepted)
|
|
208
|
-
2. **[src/routes.ts:23]** Missing rate limit on /login
|
|
146
|
+
⏳ squad 2/3 $0.58
|
|
209
147
|
```
|
|
210
148
|
|
|
211
|
-
###
|
|
149
|
+
### Panel (Ctrl+Q)
|
|
212
150
|
|
|
213
|
-
|
|
214
|
-
config: {
|
|
215
|
-
maxConcurrency: 3, // parallel agents (default: 2)
|
|
216
|
-
maxRetries: 2, // rework attempts before escalation (default: 2)
|
|
217
|
-
}
|
|
218
|
-
```
|
|
151
|
+
Full overlay with task list, live activity preview, and scrollable message view.
|
|
219
152
|
|
|
220
|
-
|
|
153
|
+
| Key | Action |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `↑↓` / `jk` | Navigate tasks / scroll messages |
|
|
156
|
+
| `Enter` | View task messages |
|
|
157
|
+
| `Esc` | Back to task list |
|
|
158
|
+
| `m` | Send message to agent |
|
|
159
|
+
| `p` | Pause/resume task |
|
|
160
|
+
| `x` | Cancel task |
|
|
161
|
+
| `Ctrl+Q` / `q` | Close panel |
|
|
221
162
|
|
|
222
|
-
|
|
163
|
+
### Slash Commands
|
|
223
164
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
165
|
+
| Command | Description |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `/squad select` | Pick a squad to view |
|
|
168
|
+
| `/squad list` | List project squads |
|
|
169
|
+
| `/squad all` | List all squads |
|
|
170
|
+
| `/squad agents` | Manage agent definitions |
|
|
171
|
+
| `/squad msg [agent] text` | Send message to agent |
|
|
172
|
+
| `/squad widget` | Toggle widget |
|
|
173
|
+
| `/squad panel` | Toggle panel |
|
|
174
|
+
| `/squad cancel` | Cancel running squad |
|
|
175
|
+
| `/squad clear` | Dismiss widget |
|
|
176
|
+
| `/squad cleanup` | Delete squad data |
|
|
177
|
+
| `/squad enable/disable` | Enable/disable the extension |
|
|
229
178
|
|
|
230
|
-
|
|
179
|
+
## Tools (LLM-callable)
|
|
231
180
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
181
|
+
| Tool | Description |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `squad` | Start a squad with goal + optional tasks/config |
|
|
184
|
+
| `squad_status` | Check progress, costs, task states |
|
|
185
|
+
| `squad_message` | Send message to a running agent |
|
|
186
|
+
| `squad_modify` | Add/cancel/pause/resume tasks or squads |
|
|
236
187
|
|
|
237
|
-
|
|
188
|
+
The main agent sees available agents in its system prompt and squad state when a squad is active.
|
|
238
189
|
|
|
239
|
-
##
|
|
190
|
+
## Configuration
|
|
240
191
|
|
|
241
|
-
|
|
192
|
+
```javascript
|
|
193
|
+
squad({
|
|
194
|
+
goal: "Build the app",
|
|
195
|
+
config: {
|
|
196
|
+
maxConcurrency: 3, // parallel agents (default: 2)
|
|
197
|
+
maxRetries: 2, // QA rework attempts before escalation (default: 2)
|
|
198
|
+
},
|
|
199
|
+
agents: {
|
|
200
|
+
backend: { model: "claude-sonnet-4-20250514" }, // per-agent model override
|
|
201
|
+
architect: { thinking: "high" }, // per-agent thinking level
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
```
|
|
242
205
|
|
|
243
|
-
|
|
206
|
+
### Context Inheritance
|
|
244
207
|
|
|
245
|
-
|
|
246
|
-
|---|---|---|
|
|
247
|
-
| **planner** | Task breakdown and planning | planning, architecture |
|
|
248
|
-
| **fullstack** | General-purpose coding | general, coding |
|
|
249
|
-
| **architect** | System design, architecture | architecture, design |
|
|
250
|
-
| **backend** | APIs, databases, server-side | api, server, database |
|
|
251
|
-
| **frontend** | UI/UX, React, CSS | react, ui, css |
|
|
252
|
-
| **debugger** | Root cause analysis | debugging, bugs |
|
|
253
|
-
| **qa** | Testing, verification | testing, qa, e2e |
|
|
254
|
-
| **security** | Security audits | security, audit |
|
|
255
|
-
| **docs** | Technical writing | documentation, readme |
|
|
256
|
-
| **researcher** | Code exploration, analysis | research, analysis |
|
|
257
|
-
| **devops** | CI/CD, infrastructure | ci-cd, docker |
|
|
258
|
-
|
|
259
|
-
### Agent Management
|
|
260
|
-
|
|
261
|
-
Use `/squad agents` for interactive management:
|
|
208
|
+
Agents normally start fresh with only their task description, dependency outputs, and squad protocol. Set `inheritContext: true` on a task to fork the main pi session (via `pi --fork`) so that agent inherits the full conversation context:
|
|
262
209
|
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
|
|
210
|
+
```js
|
|
211
|
+
squad({
|
|
212
|
+
goal: "Implement the design we discussed",
|
|
213
|
+
tasks: [
|
|
214
|
+
{ id: "impl", title: "Implement agreed design", agent: "backend",
|
|
215
|
+
description: "Goal: implement the API design agreed in this conversation. Verify: npm test",
|
|
216
|
+
inheritContext: true },
|
|
217
|
+
],
|
|
218
|
+
})
|
|
266
219
|
```
|
|
267
220
|
|
|
268
|
-
|
|
269
|
-
- **
|
|
270
|
-
- **
|
|
271
|
-
-
|
|
272
|
-
-
|
|
273
|
-
-
|
|
221
|
+
**Caveats:**
|
|
222
|
+
- **Cost**: the agent pays the entire conversation history as input tokens on every turn — use sparingly
|
|
223
|
+
- **Context-window guard**: the fork is skipped automatically when the estimated session size exceeds 50% of the agent model's context window (agents on smaller-context models silently degrade to standard squad context; the skip is recorded in the task's message log and `debug.log`)
|
|
224
|
+
- Requires the main session to have a session file (skipped under `--no-session`)
|
|
225
|
+
- Forked child sessions are stored under `~/.pi/squad/<squad-id>/sessions/`, not in your project's session list
|
|
226
|
+
- Prefer restating the 3-5 key decisions in the task description — reach for `inheritContext` only when that's impractical
|
|
274
227
|
|
|
275
228
|
### Custom Agents
|
|
276
229
|
|
|
277
|
-
Create
|
|
230
|
+
Create `~/.pi/squad/agents/my-agent.json` (global) or `{project}/.pi/squad/agents/my-agent.json` (project override):
|
|
278
231
|
|
|
279
232
|
```json
|
|
280
233
|
{
|
|
281
|
-
"name": "
|
|
234
|
+
"name": "my-agent",
|
|
282
235
|
"role": "ML Engineer",
|
|
283
236
|
"description": "Machine learning, PyTorch, data pipelines",
|
|
284
|
-
"model":
|
|
237
|
+
"model": null,
|
|
238
|
+
"thinking": null,
|
|
285
239
|
"tools": null,
|
|
286
240
|
"tags": ["ml", "pytorch", "data"],
|
|
287
|
-
"prompt": "You are an ML engineer specializing in PyTorch..."
|
|
288
|
-
"disabled": false
|
|
241
|
+
"prompt": "You are an ML engineer specializing in PyTorch..."
|
|
289
242
|
}
|
|
290
243
|
```
|
|
291
244
|
|
|
292
|
-
- `model`: `null` =
|
|
293
|
-
- `
|
|
294
|
-
- `tags`: Used by the planner to match agents to tasks automatically.
|
|
295
|
-
- `disabled`: `true` = hidden from planner, tasks assigned to this agent will fail.
|
|
296
|
-
- Project-local agents override global agents with the same name.
|
|
297
|
-
|
|
298
|
-
## How Agents Collaborate
|
|
299
|
-
|
|
300
|
-
### Chain Context (primary)
|
|
245
|
+
- `model`: `null` = squad default (see below). Override per agent or per squad.
|
|
246
|
+
- `thinking`: `null` = squad default. One of `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` (passed via pi's `--thinking` flag). Override per agent or per squad. Also editable via `/squad agents` → "Change thinking".
|
|
301
247
|
|
|
302
|
-
|
|
248
|
+
### Default Model & Thinking (`/squad defaults`)
|
|
303
249
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
All agents work in the same project directory. Upstream agents create files, downstream agents read and modify them. Each agent is instructed to read files before writing to avoid conflicts.
|
|
307
|
-
|
|
308
|
-
### Sibling Awareness
|
|
309
|
-
|
|
310
|
-
When agents run in parallel, each sees the other's status and modified files in their system prompt:
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
# Sibling Tasks
|
|
314
|
-
- template-engine [in_progress] — fullstack — Create HTML templates
|
|
250
|
+
Agents without an explicit `model`/`thinking` follow the squad default policy (stored in `~/.pi/squad/settings.json`):
|
|
315
251
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
### @Mention Routing
|
|
322
|
-
|
|
323
|
-
Agents can message each other in real-time:
|
|
324
|
-
|
|
325
|
-
```
|
|
326
|
-
Agent output: "@frontend what token format do you need?"
|
|
327
|
-
→ Router parses @mention
|
|
328
|
-
→ Delivers to running agent via steer()
|
|
329
|
-
→ Or queues for delivery when agent spawns
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### Block Detection
|
|
333
|
-
|
|
334
|
-
If an agent says "I'm blocked" or "cannot proceed", the router detects it and escalates to the main agent.
|
|
252
|
+
| Policy | Behavior |
|
|
253
|
+
|---|---|
|
|
254
|
+
| `main` *(default)* | **Follow the main pi session's current model and thinking level** — switch models mid-session and new agents follow |
|
|
255
|
+
| `pi-default` | Legacy behavior: the child pi process resolves its own configured default |
|
|
256
|
+
| explicit value | A fixed model id (e.g. `openai-codex/gpt-5.6-terra`) or thinking level |
|
|
335
257
|
|
|
336
|
-
|
|
258
|
+
Change interactively with `/squad defaults`. The planner agent follows the same policy. Resolution order: agent def → per-squad override → squad default policy.
|
|
259
|
+
- `tools`: `null` = all tools. Restrict with `["bash", "read", "write", "edit"]`.
|
|
260
|
+
- `tags`: Used by the planner to match agents to tasks automatically.
|
|
261
|
+
- Project-local agents override global agents with the same name.
|
|
337
262
|
|
|
338
|
-
###
|
|
263
|
+
### Advisor — Self-Healing Squads (`/squad advisor`)
|
|
339
264
|
|
|
340
|
-
|
|
341
|
-
- In-progress tasks are automatically **suspended** on next startup
|
|
342
|
-
- Squad is marked as **paused**
|
|
343
|
-
- Only squads with completed tasks trigger a notification
|
|
344
|
-
- Squads with zero progress are silently paused (no noise)
|
|
265
|
+
Modeled on the advisor tool pattern ([pi-advisor](https://github.com/RimuruW/pi-advisor) / Anthropic's advisor strategy): when the health monitor flags an agent as stuck, the squad consults a **stronger advisor model in-process** (via pi-ai, no subprocess) with a curated digest — task, recent messages, recent tool activity — before interrupting you.
|
|
345
266
|
|
|
346
|
-
|
|
267
|
+
The advisor returns a verdict (`Course-correct` / `Push through` / `Needs human input`) plus ≤5 action items:
|
|
268
|
+
- **Course-correct / Push through** → advice is steered directly into the stuck agent's conversation; escalation suppressed
|
|
269
|
+
- **Needs human input** → escalates immediately with the advisor's assessment attached
|
|
270
|
+
- Advisor disabled, exhausted (`maxCallsPerTask`), or failed → normal escalation to you
|
|
347
271
|
|
|
348
|
-
|
|
272
|
+
Configure with `/squad advisor` (on/off, model, max calls per task, reasoning effort). Defaults: **enabled**, model = main session's model, 2 calls/task, medium reasoning. Settings persist in `~/.pi/squad/settings.json` under `advisor`. All consultations are recorded in the task's message log (`from: "advisor"`).
|
|
349
273
|
|
|
350
|
-
|
|
351
|
-
> Resume the squad
|
|
352
|
-
```
|
|
274
|
+
## Reliability
|
|
353
275
|
|
|
354
|
-
|
|
355
|
-
1. Finds the latest paused squad for the project
|
|
356
|
-
2. Creates a fresh scheduler from disk state
|
|
357
|
-
3. Wires up event handlers for completion/failure/escalation
|
|
358
|
-
4. Restarts suspended tasks
|
|
276
|
+
### Meaningful Work Check
|
|
359
277
|
|
|
360
|
-
|
|
278
|
+
Agents must complete at least 1 LLM turn AND make at least 1 tool call to be marked as "done". Agents that exit cleanly but did no work (rate limit, API error, model not found) are retried once, then failed — never silently marked successful.
|
|
361
279
|
|
|
362
|
-
###
|
|
280
|
+
### Session Resilience
|
|
363
281
|
|
|
364
|
-
|
|
282
|
+
- In-progress tasks are **suspended** on session crash, **resumed** on next startup
|
|
283
|
+
- Squads are fully reconstructable from JSON files on disk
|
|
284
|
+
- Spawn failures are retried once with a 2-second delay
|
|
285
|
+
- All errors logged to `~/.pi/squad/debug.log` (always for errors, `PI_SQUAD_DEBUG=1` for verbose)
|
|
365
286
|
|
|
366
|
-
|
|
287
|
+
### Health Monitoring
|
|
367
288
|
|
|
368
|
-
|
|
|
369
|
-
|
|
370
|
-
|
|
|
371
|
-
|
|
|
372
|
-
|
|
|
373
|
-
|
|
|
374
|
-
| **Spawn retry** | Retries once on transient startup failures, then fails with diagnostics |
|
|
375
|
-
| **File tracking** | Warns agents about files modified by other agents |
|
|
376
|
-
| **@mention routing** | Parsed from output, delivered via RPC `steer()` |
|
|
377
|
-
| **Escalation** | Blocked agents, stuck agents, retry limit, spawn failure → notify main agent |
|
|
378
|
-
| **Clean notifications** | Uses `sendMessage({ display: true })` — visible to user, not in LLM history |
|
|
289
|
+
| Check | Threshold | Action |
|
|
290
|
+
|---|---|---|
|
|
291
|
+
| Idle warning | 3 minutes no output | Steer agent with nudge |
|
|
292
|
+
| Stuck detection | 5 minutes no output | Abort and fail task |
|
|
293
|
+
| Loop detection | Same tool call 5x | Steer with warning |
|
|
294
|
+
| Hard ceiling | 30 minutes total | Abort task |
|
|
379
295
|
|
|
380
296
|
## Data Layout
|
|
381
297
|
|
|
382
|
-
All state
|
|
298
|
+
All state in `~/.pi/squad/`. No database, no daemon. Writes are atomic. JSONL reads skip corrupt lines.
|
|
383
299
|
|
|
384
300
|
```
|
|
385
301
|
~/.pi/squad/
|
|
386
|
-
├── agents/
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
│ ├── decisions.jsonl
|
|
395
|
-
│ └── findings.jsonl
|
|
396
|
-
└── {task-id}/ — one directory per task
|
|
397
|
-
├── task.json — status, agent, output, usage, retryOf, qaFeedback
|
|
398
|
-
└── messages.jsonl — full conversation log
|
|
302
|
+
├── agents/ — agent definitions (user-editable)
|
|
303
|
+
├── debug.log — error and debug logging
|
|
304
|
+
└── {squad-id}/
|
|
305
|
+
├── squad.json — goal, status, config, cwd
|
|
306
|
+
├── context.json — live state snapshot
|
|
307
|
+
└── {task-id}/
|
|
308
|
+
├── task.json — status, output, usage, retryOf, qaFeedback
|
|
309
|
+
└── messages.jsonl — conversation log
|
|
399
310
|
```
|
|
400
311
|
|
|
401
312
|
## Architecture
|
|
402
313
|
|
|
403
314
|
```
|
|
404
315
|
src/
|
|
405
|
-
├── index.ts
|
|
406
|
-
├── types.ts
|
|
407
|
-
├── store.ts
|
|
408
|
-
├── scheduler.ts
|
|
409
|
-
├── agent-pool.ts
|
|
410
|
-
├── protocol.ts
|
|
411
|
-
├── router.ts
|
|
412
|
-
├── monitor.ts
|
|
413
|
-
├──
|
|
414
|
-
├──
|
|
415
|
-
├── panel/
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
│ ├── task-list.ts — task tree with status icons, elapsed time, sticky summary
|
|
419
|
-
│ └── message-view.ts — scrollable message log with word wrap, fixed-height layout
|
|
420
|
-
├── skills/
|
|
421
|
-
│ ├── supervisor/ — teaches main agent to supervise squads
|
|
422
|
-
│ ├── squad-protocol/ — communication rules for child agents
|
|
423
|
-
│ ├── collaboration/ — team interaction patterns
|
|
424
|
-
│ └── verification/ — verify-before-done + structured QA verdicts
|
|
425
|
-
└── agents/_defaults/ — 11 bundled agent definitions
|
|
316
|
+
├── index.ts — extension entry: tools, commands, widget, panel, lifecycle
|
|
317
|
+
├── types.ts — type definitions
|
|
318
|
+
├── store.ts — JSON/JSONL file I/O, atomic writes
|
|
319
|
+
├── scheduler.ts — dependency DAG, concurrency, rework loop, task lifecycle
|
|
320
|
+
├── agent-pool.ts — pi RPC process management, activity tracking
|
|
321
|
+
├── protocol.ts — system prompt builder (chain context, sibling awareness, knowledge)
|
|
322
|
+
├── router.ts — @mention parsing, cross-agent messaging
|
|
323
|
+
├── monitor.ts — health checks (idle, stuck, loop, ceiling)
|
|
324
|
+
├── planner.ts — one-shot goal decomposition via LLM
|
|
325
|
+
├── logger.ts — file-based logging (never writes to stderr)
|
|
326
|
+
├── panel/ — TUI overlay panel and widget
|
|
327
|
+
├── skills/ — 9 bundled skills for agents
|
|
328
|
+
└── agents/_defaults/ — 11 bundled agent definitions
|
|
426
329
|
```
|
|
427
330
|
|
|
428
|
-
## Test Results
|
|
429
|
-
|
|
430
|
-
### Simple (3 tasks, linear chain)
|
|
431
|
-
- URL shortener API: 3 tasks, 30 turns, $0.83, 4.5 minutes
|
|
432
|
-
- Backend → QA → Docs, all passing
|
|
433
|
-
|
|
434
|
-
### Medium (5 tasks, planner-decomposed)
|
|
435
|
-
- Quiz API: 5 tasks, 82 turns, $3.11, 14 minutes
|
|
436
|
-
- Planner auto-created: architect → backend → fullstack → QA + docs
|
|
437
|
-
- 111 vitest tests passing, 3,637 lines of code
|
|
438
|
-
|
|
439
|
-
### Complex with rework (5 original + 4 auto-rework = 9 tasks)
|
|
440
|
-
- Chat API with auth + rooms: 9 tasks, 176 turns, $4.60, 26 minutes
|
|
441
|
-
- QA found 2 bugs → 2 automatic rework cycles → both fixed and verified
|
|
442
|
-
- Dependency chain with parallel QA and rework loop
|
|
443
|
-
|
|
444
|
-
### Parallel squads (2 squads running simultaneously)
|
|
445
|
-
- Bookmarks API (2/2, $0.83) + Notes CLI (6/6 with 2 rework cycles, $1.17)
|
|
446
|
-
- Both ran concurrently from the same pi session
|
|
447
|
-
- Combined: 12 tasks, 101 turns, $2.00
|
|
448
|
-
|
|
449
331
|
## Requirements
|
|
450
332
|
|
|
451
|
-
- [pi](https://github.com/badlogic/pi-mono)
|
|
333
|
+
- [pi](https://github.com/badlogic/pi-mono) v0.63.0+ (recommended v0.64.0+)
|
|
452
334
|
- An API key configured in pi (Anthropic, OpenRouter, etc.)
|
|
453
335
|
- Node.js 18+
|
|
454
336
|
|