pi-squad 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 picassio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,244 @@
1
+ # pi-squad
2
+
3
+ Multi-agent collaboration extension for [pi](https://github.com/badlogic/pi-mono). Decomposes complex tasks into subtasks, assigns specialist agents, manages dependencies, and runs them in parallel — with a live TUI widget, side panel, and full slash command interface.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ # From npm
9
+ pi install npm:pi-squad
10
+
11
+ # Or symlink for development
12
+ ln -sf /path/to/pi-squad/src ~/.pi/agent/extensions/squad
13
+ ```
14
+
15
+ Pi auto-discovers extensions on startup. No build step.
16
+
17
+ ## Quick Start
18
+
19
+ Ask pi to do something complex. It calls the `squad` tool automatically:
20
+
21
+ ```
22
+ > Build a REST API with authentication, tests, and documentation
23
+ ```
24
+
25
+ Or be explicit:
26
+
27
+ ```
28
+ > Use squad: goal="Build task API", tasks=[
29
+ {id: "api", title: "Build CRUD endpoints with express", agent: "backend"},
30
+ {id: "tests", title: "Write tests", agent: "qa", depends: ["api"]},
31
+ {id: "docs", title: "Write README", agent: "docs", depends: ["api"]}
32
+ ]
33
+ ```
34
+
35
+ ### What Happens
36
+
37
+ 1. Extension creates tasks, starts the scheduler
38
+ 2. A **live widget** appears above the editor showing task status
39
+ 3. Agents spawn as separate pi processes, work in parallel where deps allow
40
+ 4. When complete, pi reports the summary
41
+
42
+ ## User Interface
43
+
44
+ ### Widget (above editor)
45
+
46
+ Always visible when a squad is active. Updates every 2 seconds.
47
+
48
+ ```
49
+ ⏳ squad Build task API 1/3 $0.58 3m12s ctrl+q panel · /squad
50
+ ✓ api (backend) Created CRUD REST API with validation
51
+ ⏳ tests (qa) → bash npm test
52
+ ◻ docs (docs) ← api
53
+ ```
54
+
55
+ ### Status Bar (footer)
56
+
57
+ ```
58
+ ⏳ squad 1/3 $0.58
59
+ ```
60
+
61
+ ### Panel (Ctrl+Q)
62
+
63
+ Side panel on wide screens, centered overlay on narrow screens. Press `Ctrl+Q` to toggle focus between the panel and the editor.
64
+
65
+ **Task list:**
66
+ ```
67
+ ╭─ squad: Build task API ─────────────────────╮
68
+ │ ▸ ✓ api (backend) 2m12s │
69
+ │ ⏳ tests (qa) 45s │
70
+ │ ◻ docs (docs) blocked │
71
+ │ │
72
+ │ ── tests (live) ───────────────────── │
73
+ │ → bash npm test │
74
+ │ │
75
+ │ 1/3 · $0.58 · 3m │
76
+ ├──────────────────────────────────────────────┤
77
+ │ ↑↓ nav ⏎ msgs m send p pause ^q switch │
78
+ ╰──────────────────────────────────────────────╯
79
+ ```
80
+
81
+ **Message view** (Enter on a task):
82
+ ```
83
+ ╭─ tests · qa ⏳ ─────────────────────────────╮
84
+ │ 10:03 qa │
85
+ │ Starting test implementation │
86
+ │ 10:04 qa │
87
+ │ → write src/tasks.test.js │
88
+ │ 10:05 YOU │
89
+ │ Also test edge cases for empty input │
90
+ ├──────────────────────────────────────────────┤
91
+ │ ↑↓ scroll m send esc back ^q switch │
92
+ ╰──────────────────────────────────────────────╯
93
+ ```
94
+
95
+ ## Commands
96
+
97
+ | Command | Description |
98
+ |---|---|
99
+ | `/squad` or `/squad select` | Pick a squad to view (interactive selector) |
100
+ | `/squad list` | List squads for current project |
101
+ | `/squad all` | List all squads across all projects |
102
+ | `/squad msg [agent] text` | Send message to a running agent |
103
+ | `/squad widget` | Toggle live widget |
104
+ | `/squad panel` | Toggle overlay panel |
105
+ | `/squad cancel` | Cancel running squad |
106
+ | `/squad clear` | Dismiss widget, deactivate view |
107
+
108
+ ## Keyboard Shortcuts
109
+
110
+ | Key | Context | Action |
111
+ |---|---|---|
112
+ | `Ctrl+Q` | Main editor | Open/focus squad panel |
113
+ | `Ctrl+Q` | Panel focused (wide) | Return focus to editor (panel stays visible) |
114
+ | `Ctrl+Q` | Panel focused (narrow) | Hide panel |
115
+ | `↑↓` | Panel | Navigate tasks / scroll messages |
116
+ | `Enter` | Panel task list | View task messages |
117
+ | `Esc` | Panel message view | Back to task list |
118
+ | `m` | Panel | Send message to selected task's agent |
119
+ | `p` | Panel task list | Pause/resume task |
120
+ | `x` | Panel task list | Cancel task |
121
+ | `q` | Panel task list | Release focus / hide |
122
+
123
+ ## Tools (LLM-callable)
124
+
125
+ | Tool | Description |
126
+ |---|---|
127
+ | `squad` | Start a squad (non-blocking, returns immediately) |
128
+ | `squad_status` | Check progress, filtered by project |
129
+ | `squad_message` | Send message to a running agent via `steer()` |
130
+ | `squad_modify` | Add/remove/pause/resume/cancel tasks |
131
+
132
+ The main pi agent sees squad state in its system prompt automatically and can relay messages, add tasks, or check status on your behalf.
133
+
134
+ ## Sending Messages to Agents
135
+
136
+ Three ways:
137
+
138
+ 1. **`/squad msg`** — type in the main editor
139
+ ```
140
+ /squad msg Use postgres instead of SQLite
141
+ /squad msg backend Use postgres instead of SQLite
142
+ ```
143
+
144
+ 2. **`m` key** — press in the panel (task list or message view), opens input dialog
145
+
146
+ 3. **Natural chat** — tell pi, it relays automatically
147
+ ```
148
+ > Tell the backend agent to use argon2 for password hashing
149
+ ```
150
+
151
+ ## Agents
152
+
153
+ 11 specialist agents are bundled. On first run, they're copied to `~/.pi/squad/agents/` for editing.
154
+
155
+ | Agent | Specialty |
156
+ |---|---|
157
+ | **planner** | Task breakdown and planning |
158
+ | **fullstack** | General-purpose coding |
159
+ | **architect** | System design, architecture |
160
+ | **backend** | APIs, databases, server-side |
161
+ | **frontend** | UI/UX, React, CSS |
162
+ | **debugger** | Root cause analysis |
163
+ | **qa** | Testing, verification |
164
+ | **security** | Security audits |
165
+ | **docs** | Technical writing |
166
+ | **researcher** | Code exploration, analysis |
167
+ | **devops** | CI/CD, infrastructure |
168
+
169
+ ### Custom Agents
170
+
171
+ Create a JSON file in `~/.pi/squad/agents/` (global) or `{project}/.pi/squad/agents/` (project override):
172
+
173
+ ```json
174
+ {
175
+ "name": "ml-engineer",
176
+ "role": "ML Engineer",
177
+ "description": "Machine learning, PyTorch, data pipelines",
178
+ "model": "anthropic/claude-sonnet-4-20250514",
179
+ "tools": null,
180
+ "tags": ["ml", "pytorch", "data"],
181
+ "prompt": "You are an ML engineer specializing in PyTorch..."
182
+ }
183
+ ```
184
+
185
+ Project-local agents override global agents with the same name.
186
+
187
+ ## How Agents Collaborate
188
+
189
+ - **Dependencies** — task B waits for task A before starting
190
+ - **Chain context** — task A's output is injected into task B's system prompt
191
+ - **@mentions** — agents write `@agentname message` to talk to each other in real time
192
+ - **Human messages** — sent via panel, `/squad msg`, or the LLM's `squad_message` tool
193
+ - **Shared knowledge** — decisions and findings tracked in `knowledge/*.jsonl`
194
+
195
+ ## Data
196
+
197
+ All state lives in `~/.pi/squad/` (global). No database, no daemon, no external services.
198
+
199
+ ```
200
+ ~/.pi/squad/
201
+ ├── agents/*.json — global agent definitions
202
+ └── {squad-id}/
203
+ ├── squad.json — metadata (goal, status, cwd, agents, config)
204
+ ├── context.json — live state snapshot
205
+ └── {task-id}/
206
+ ├── task.json — task metadata + output
207
+ └── messages.jsonl — conversation log
208
+ ```
209
+
210
+ Each squad stores its project `cwd` in `squad.json`. The `/squad list` command filters by current project. `/squad all` shows everything.
211
+
212
+ Project-local agent overrides: `{project}/.pi/squad/agents/`
213
+
214
+ ## Multi-Project Support
215
+
216
+ Squads are stored globally but scoped to projects by their `cwd` field. Multiple pi sessions can run squads for different projects simultaneously.
217
+
218
+ ```
219
+ Session A (cwd: /projects/api) Session B (cwd: /projects/web)
220
+ └── squad "build-auth" └── squad "build-dashboard"
221
+ both stored in ~/.pi/squad/
222
+ filtered by cwd when listing
223
+ ```
224
+
225
+ `/squad list` shows squads for the current project. `/squad all` shows all projects.
226
+
227
+ Any pi session can browse and view any squad with `/squad select` or `/squad all`.
228
+
229
+ ## Governance
230
+
231
+ - **Dependency enforcement** — blocked tasks never spawn, auto-unblock when deps complete
232
+ - **Concurrency control** — configurable `maxConcurrency` (default: 2)
233
+ - **Health monitoring** — idle warning (3m), stuck intervention (5m), loop detection, 30m hard ceiling
234
+ - **@mention routing** — parsed from agent output, delivered via RPC `steer()`
235
+ - **File conflict tracking** — warns agents about files modified by others
236
+
237
+ ## Requirements
238
+
239
+ - [pi](https://github.com/badlogic/pi-mono) coding agent
240
+ - An API key configured in pi (Anthropic, OpenRouter, etc.)
241
+
242
+ ## License
243
+
244
+ MIT
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "pi-squad",
3
+ "version": "0.1.0",
4
+ "description": "Multi-agent collaboration extension for pi — task decomposition, dependency management, parallel execution, TUI panel",
5
+ "type": "module",
6
+ "pi": {
7
+ "extensions": ["src/index.ts"],
8
+ "skills": ["src/skills/squad-protocol", "src/skills/collaboration", "src/skills/verification"]
9
+ },
10
+ "files": [
11
+ "src",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "keywords": [
16
+ "pi",
17
+ "pi-extension",
18
+ "multi-agent",
19
+ "agent-collaboration",
20
+ "task-management",
21
+ "tui"
22
+ ],
23
+ "author": "picassio",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/picassio/pi-squad.git"
28
+ },
29
+ "homepage": "https://github.com/picassio/pi-squad"
30
+ }