pi-messenger 0.9.0 → 0.11.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/CHANGELOG.md +33 -0
- package/README.md +107 -344
- package/crew/agents/crew-worker.md +9 -0
- package/crew/agents.ts +178 -14
- package/crew/handlers/plan.ts +4 -5
- package/crew/handlers/review.ts +11 -9
- package/crew/handlers/work.ts +79 -45
- package/crew/index.ts +5 -4
- package/crew/live-progress.ts +57 -0
- package/crew/state.ts +0 -16
- package/crew/types.ts +6 -0
- package/crew/utils/config.ts +26 -11
- package/crew/utils/progress.ts +4 -1
- package/crew-overlay.ts +51 -14
- package/index.ts +23 -3
- package/install.mjs +120 -7
- package/overlay.ts +47 -2
- package/package.json +9 -3
- package/vitest.config.ts +10 -0
- package/ARCHITECTURE.md +0 -220
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.11.0] - 2026-02-08
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **Test suite** — 53 tests across 7 Vitest suites covering store CRUD, state machine, config merging, agent discovery, model resolution, graceful shutdown, and live progress (including cwd isolation). Includes test helpers for temp directories and mock contexts.
|
|
7
|
+
- **Per-agent runtime config** — Model override with 4-level priority: per-task > per-wave `model` param > config `crew.models.worker` > agent `.md` frontmatter. Environment variable override via `crew.work.env` config (not exposed as tool param to prevent API keys in logs).
|
|
8
|
+
- **Graceful shutdown** — `AbortSignal` threaded from tool execute through to spawned workers. On abort: discovers worker name via PID-based registry scan, writes shutdown message to worker inbox, waits 30s grace period, SIGTERM, waits 5s, SIGKILL. Tasks reset to `todo` for retry. Workers instructed to release reservations and exit without committing.
|
|
9
|
+
- **Live crew progress** — In-memory pub/sub store fed by worker JSONL events. Overlay Crew tab shows Active Workers section with tool name, call count, tokens, and elapsed time updating every second. Status bar shows active worker count during autonomous mode (`🔨N`).
|
|
10
|
+
- **`shutdownGracePeriodMs` config** — Configurable grace period before SIGTERM (default: 30000).
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Dynamic overlay height** — Content area scales with terminal size (8-25 lines) instead of hardcoded 10. On a standard 24-row terminal, visible content goes from 10 to 15 lines.
|
|
14
|
+
- **Handler signatures simplified** — Removed unused `state` and `dirs` parameters from plan and review handlers.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **`deepMerge` crash** — Merging config with `models` key crashed when the target didn't have the key. Hardened for undefined target keys.
|
|
18
|
+
- **Result/task association** — Worker results now matched by `taskId` field instead of array index, since `spawnAgents` returns in completion order not submission order.
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
- `attemptsPerTask` field from `AutonomousState` — declared but never populated by any code.
|
|
22
|
+
- `ARCHITECTURE.md` from repo (moved to external docs).
|
|
23
|
+
|
|
24
|
+
## [0.10.0] - 2026-02-05
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- **Crew spawner applies agent definitions** — Spawned crew workers now receive the agent's system prompt (`--append-system-prompt`), tool restrictions (`--tools`), and model override from their `.md` definitions. Previously a phantom `--agent` flag was passed that pi-core silently ignored, the agent name leaked into the prompt as noise, and the system prompts (worker's 6-phase protocol, reviewer's rubric, planner's exploration workflow) were never delivered. Tool restrictions also take effect: reviewers and interview generators are now limited to `read,bash` instead of getting all default builtins including `write` and `edit`.
|
|
28
|
+
- **Crew spawner session cleanup** — Spawned workers now pass `--no-session` to avoid writing ephemeral session files to disk.
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- **`--crew-install` / `--crew-uninstall` CLI flags** — `npx pi-messenger --crew-install` copies crew agent `.md` files and the `pi-messenger-crew` skill to user directories. `--crew-uninstall` removes them. Reads from the npm package (not the installed extension) to avoid version skew.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- **README rewrite** — Installation section now shows real CLI commands instead of tool-call syntax. "How It Works" section explains pi extension API hooks (`pi.on()`, `pi.sendMessage()`, `{ block: true }`, `ctx.ui.custom()`) instead of listing directory trees.
|
|
35
|
+
|
|
3
36
|
## [0.9.0] - 2026-02-05
|
|
4
37
|
|
|
5
38
|
### Added
|
package/README.md
CHANGED
|
@@ -6,106 +6,76 @@
|
|
|
6
6
|
|
|
7
7
|
**What if multiple agents in different terminals sharing a folder could talk to each other like they're in a chat room?** Join, see who's online and what they're doing. Claim tasks, reserve files, send messages. Built on [Pi's](https://github.com/badlogic/pi-mono) extension system. No daemon, no server, just files.
|
|
8
8
|
|
|
9
|
+
[](https://www.npmjs.com/package/pi-messenger)
|
|
9
10
|
[](LICENSE)
|
|
10
11
|
[]()
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Pi-messenger adds a `pi_messenger` tool that **agents use** for coordination. You don't type these commands - you ask your agent to do things, and it calls `pi_messenger` behind the scenes.
|
|
15
|
-
|
|
16
|
-
## Quick Start
|
|
17
|
-
|
|
18
|
-
### Multi-Agent Coordination
|
|
19
|
-
|
|
20
|
-
Once joined (manually or via auto-join config), agents can coordinate:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
pi_messenger({ action: "reserve", paths: ["src/auth/"], reason: "Refactoring" })
|
|
24
|
-
// → Reserved src/auth/ - other agents will be blocked
|
|
25
|
-
|
|
26
|
-
// ... does the work ...
|
|
13
|
+
## Installation
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
```bash
|
|
16
|
+
pi install npm:pi-messenger
|
|
30
17
|
```
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Crew Task Orchestration
|
|
35
|
-
|
|
36
|
-
Ask your agent to plan and execute from a PRD:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
pi_messenger({ action: "plan" })
|
|
40
|
-
// → Planner analyzes codebase, creates tasks
|
|
19
|
+
Crew agents and the `pi-messenger-crew` skill are auto-installed on first use of `plan`, `work`, or `review`. To install them ahead of time:
|
|
41
20
|
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npx pi-messenger --crew-install
|
|
44
23
|
```
|
|
45
24
|
|
|
46
|
-
|
|
25
|
+
This copies `crew/agents/*.md` to `~/.pi/agent/agents/` and `skills/pi-messenger-crew/` to `~/.pi/agent/skills/`.
|
|
47
26
|
|
|
48
|
-
|
|
27
|
+
To remove the extension:
|
|
49
28
|
|
|
50
29
|
```bash
|
|
51
|
-
|
|
30
|
+
npx pi-messenger --remove
|
|
52
31
|
```
|
|
53
32
|
|
|
54
|
-
To remove:
|
|
33
|
+
To also remove crew agents and skill:
|
|
55
34
|
|
|
56
35
|
```bash
|
|
57
|
-
npx pi-messenger --
|
|
36
|
+
npx pi-messenger --crew-uninstall
|
|
58
37
|
```
|
|
59
38
|
|
|
60
|
-
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
Once joined (manually or via `autoRegister` config), agents can coordinate:
|
|
61
42
|
|
|
43
|
+
```typescript
|
|
44
|
+
pi_messenger({ action: "join" })
|
|
45
|
+
pi_messenger({ action: "reserve", paths: ["src/auth/"], reason: "Refactoring" })
|
|
46
|
+
pi_messenger({ action: "send", to: "GoldFalcon", message: "auth is done" })
|
|
47
|
+
pi_messenger({ action: "release" })
|
|
62
48
|
```
|
|
63
|
-
|
|
49
|
+
|
|
50
|
+
For multi-agent task orchestration from a PRD:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
pi_messenger({ action: "plan" }) // Planner analyzes codebase, creates tasks
|
|
54
|
+
pi_messenger({ action: "work", autonomous: true }) // Workers execute tasks in waves until done
|
|
55
|
+
pi_messenger({ action: "review", target: "task-1" }) // Reviewer checks implementation
|
|
64
56
|
```
|
|
65
57
|
|
|
66
58
|
## Features
|
|
67
59
|
|
|
68
|
-
**Living Presence** -
|
|
60
|
+
**Living Presence** - Status indicators (active, idle, away, stuck), tool call counts, token usage, and auto-generated status messages like "on fire" or "debugging...". Your agent name appears in the status bar: `msg: SwiftRaven (2 peers) ●3`
|
|
69
61
|
|
|
70
|
-
**Activity Feed** -
|
|
62
|
+
**Activity Feed** - Unified timeline of edits, commits, test runs, messages, and task events. Query with `{ action: "feed" }`.
|
|
71
63
|
|
|
72
64
|
**Discovery** - Agents register with memorable themed names (SwiftRaven, LunarDust, OakTree). See who's active, what they're working on, which model and git branch they're on.
|
|
73
65
|
|
|
74
|
-
**Messaging** - Send messages between agents. Recipients wake up immediately and see the message as a steering prompt.
|
|
66
|
+
**Messaging** - Send messages between agents. Recipients wake up immediately and see the message as a steering prompt.
|
|
75
67
|
|
|
76
68
|
**File Reservations** - Claim files or directories. Other agents get blocked with a clear message telling them who to coordinate with. Auto-releases on exit.
|
|
77
69
|
|
|
78
|
-
**Stuck Detection** - Agents idle too long with an open task or reservation are flagged as stuck.
|
|
70
|
+
**Stuck Detection** - Agents idle too long with an open task or reservation are flagged as stuck. Peers get a notification.
|
|
79
71
|
|
|
80
|
-
**Human as Participant** - Your interactive pi session appears in the agent list with `(you)`. Same activity tracking, same status messages.
|
|
81
|
-
|
|
82
|
-
**Swarm Coordination** - Multiple agents work on the same spec file. Claim tasks atomically, mark them complete, see who's doing what.
|
|
72
|
+
**Human as Participant** - Your interactive pi session appears in the agent list with `(you)`. Same activity tracking, same status messages. Chat from the overlay.
|
|
83
73
|
|
|
84
74
|
## Chat Overlay
|
|
85
75
|
|
|
86
76
|
`/messenger` opens an interactive overlay with agent presence, activity feed, and chat:
|
|
87
77
|
|
|
88
|
-
|
|
89
|
-
╭─ Messenger ── 3 agents ── myapp ────────────────────╮
|
|
90
|
-
│ │
|
|
91
|
-
│ 🟢 SwiftRaven (you) │
|
|
92
|
-
│ editing login.ts - 12 tools - 31.0k - on fire 🔥 │
|
|
93
|
-
│ │
|
|
94
|
-
│ 🟡 GoldFalcon idle 2m │
|
|
95
|
-
│ 8 tools - 24.1k - 📁 src/api/ │
|
|
96
|
-
│ │
|
|
97
|
-
│ 🔴 IronKnight stuck │
|
|
98
|
-
│ 3 tools - 16.4k │
|
|
99
|
-
│ │
|
|
100
|
-
│ Activity │
|
|
101
|
-
│ 10:42 SwiftRaven editing login.ts │
|
|
102
|
-
│ 10:40 GoldFalcon → SwiftRaven: "auth done?" │
|
|
103
|
-
│ 10:38 SwiftRaven committed "feat: add OAuth" │
|
|
104
|
-
│ 10:35 [Crew] GoldFalcon started task-03 │
|
|
105
|
-
├──────────────────────────────────────────────────────┤
|
|
106
|
-
│ > @GoldFalcon almost done [Tab] [Enter]│
|
|
107
|
-
╰──────────────────────────────────────────────────────╯
|
|
108
|
-
```
|
|
78
|
+
<img width="722" height="351" alt="pi-messenger chat overlay" src="https://github.com/user-attachments/assets/4d0f1db7-90dd-4ffb-9463-560426edebd9" />
|
|
109
79
|
|
|
110
80
|
Chat input supports `@Name msg` for DMs and `@all msg` for broadcasts. Text without `@` broadcasts from the Agents tab or DMs the selected agent tab.
|
|
111
81
|
|
|
@@ -118,120 +88,19 @@ Chat input supports `@Name msg` for DMs and `@all msg` for broadcasts. Text with
|
|
|
118
88
|
|
|
119
89
|
## Crew: Task Orchestration
|
|
120
90
|
|
|
121
|
-
Crew
|
|
122
|
-
|
|
123
|
-
### Basic Workflow
|
|
124
|
-
|
|
125
|
-
1. **Plan** - Planner analyzes your codebase and PRD, creates tasks
|
|
126
|
-
2. **Work** - Workers implement tasks in parallel waves
|
|
127
|
-
3. **Review** - Reviewer checks each implementation
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
// Plan from your PRD (auto-discovers PRD.md, SPEC.md, etc.)
|
|
131
|
-
pi_messenger({ action: "plan" })
|
|
132
|
-
|
|
133
|
-
// Or specify PRD path explicitly
|
|
134
|
-
pi_messenger({ action: "plan", prd: "docs/PRD.md" })
|
|
135
|
-
|
|
136
|
-
// Execute tasks (spawns parallel workers)
|
|
137
|
-
pi_messenger({ action: "work" })
|
|
138
|
-
|
|
139
|
-
// Or run autonomously until done/blocked
|
|
140
|
-
pi_messenger({ action: "work", autonomous: true })
|
|
141
|
-
|
|
142
|
-
// Review a specific task
|
|
143
|
-
pi_messenger({ action: "review", target: "task-1" })
|
|
144
|
-
// → SHIP ✅ or NEEDS_WORK 🔄
|
|
145
|
-
```
|
|
91
|
+
Crew turns a PRD into a dependency graph of tasks, then executes them in parallel waves.
|
|
146
92
|
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
**Planning**
|
|
150
|
-
| Action | Description | Example |
|
|
151
|
-
|--------|-------------|---------|
|
|
152
|
-
| `plan` | Create plan from PRD | `{ action: "plan" }` or `{ action: "plan", prd: "..." }` |
|
|
153
|
-
| `status` | Show progress | `{ action: "status" }` |
|
|
154
|
-
|
|
155
|
-
**Work Execution**
|
|
156
|
-
| Action | Description | Example |
|
|
157
|
-
|--------|-------------|---------|
|
|
158
|
-
| `work` | Run ready tasks | `{ action: "work" }` |
|
|
159
|
-
| `work` (auto) | Run until done/blocked | `{ action: "work", autonomous: true }` |
|
|
160
|
-
|
|
161
|
-
**Task Management**
|
|
162
|
-
| Action | Description | Example |
|
|
163
|
-
|--------|-------------|---------|
|
|
164
|
-
| `task.show` | Show task details | `{ action: "task.show", id: "task-1" }` |
|
|
165
|
-
| `task.list` | List all tasks | `{ action: "task.list" }` |
|
|
166
|
-
| `task.start` | Start task | `{ action: "task.start", id: "task-1" }` |
|
|
167
|
-
| `task.done` | Complete task | `{ action: "task.done", id: "task-1", summary: "..." }` |
|
|
168
|
-
| `task.block` | Block task | `{ action: "task.block", id: "task-1", reason: "..." }` |
|
|
169
|
-
| `task.unblock` | Unblock task | `{ action: "task.unblock", id: "task-1" }` |
|
|
170
|
-
| `task.ready` | List ready tasks | `{ action: "task.ready" }` |
|
|
171
|
-
| `task.reset` | Reset task | `{ action: "task.reset", id: "task-1", cascade: true }` |
|
|
172
|
-
|
|
173
|
-
**Review**
|
|
174
|
-
| Action | Description | Example |
|
|
175
|
-
|--------|-------------|---------|
|
|
176
|
-
| `review` | Review implementation | `{ action: "review", target: "task-1" }` |
|
|
177
|
-
|
|
178
|
-
**Maintenance**
|
|
179
|
-
| Action | Description | Example |
|
|
180
|
-
|--------|-------------|---------|
|
|
181
|
-
| `crew.status` | Overall status | `{ action: "crew.status" }` |
|
|
182
|
-
| `crew.validate` | Validate plan | `{ action: "crew.validate" }` |
|
|
183
|
-
| `crew.agents` | List crew agents | `{ action: "crew.agents" }` |
|
|
184
|
-
| `crew.install` | Install crew agents | `{ action: "crew.install" }` |
|
|
185
|
-
|
|
186
|
-
### Planning Workflow
|
|
187
|
-
|
|
188
|
-
The `plan` action runs a multi-pass planning loop: the planner drafts tasks, a reviewer checks them against the PRD, and the planner refines until SHIP or `planning.maxPasses` is reached. All passes and feedback are stored in `.pi/messenger/crew/planning-progress.md`.
|
|
93
|
+
### Workflow
|
|
189
94
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
│ ├── PRD.md ◄── Planner discovers and reads these │
|
|
194
|
-
│ ├── DESIGN.md │
|
|
195
|
-
│ ├── src/ │
|
|
196
|
-
│ └── ... │
|
|
197
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
198
|
-
│
|
|
199
|
-
▼
|
|
200
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
201
|
-
│ Planner (opus) │
|
|
202
|
-
│ ├── Explores codebase structure and patterns │
|
|
203
|
-
│ ├── Reads project documentation │
|
|
204
|
-
│ ├── Identifies gaps, edge cases, security concerns │
|
|
205
|
-
│ └── Drafts task breakdown with dependencies │
|
|
206
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
207
|
-
│ append to
|
|
208
|
-
▼
|
|
209
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
210
|
-
│ planning-progress.md (history + feedback) │
|
|
211
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
212
|
-
│
|
|
213
|
-
▼
|
|
214
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
215
|
-
│ Reviewer (gpt-5.2-high) │
|
|
216
|
-
│ ├── SHIP ✅ or NEEDS_WORK 🔄 │
|
|
217
|
-
│ └── Feeds back into the next planner pass │
|
|
218
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
219
|
-
│ SHIP
|
|
220
|
-
▼
|
|
221
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
222
|
-
│ Result: Tasks with Dependencies │
|
|
223
|
-
│ ├── task-1: Setup types (no deps) │
|
|
224
|
-
│ ├── task-2: Core logic (depends on task-1) │
|
|
225
|
-
│ ├── task-3: API endpoints (depends on task-1) │
|
|
226
|
-
│ └── task-4: Tests (depends on task-2, task-3) │
|
|
227
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
228
|
-
```
|
|
95
|
+
1. **Plan** — Planner explores the codebase and PRD, drafts tasks with dependencies. A reviewer checks the plan; the planner refines until SHIP or `maxPasses` is reached. History is stored in `planning-progress.md`.
|
|
96
|
+
2. **Work** — Workers implement ready tasks (all dependencies met) in parallel waves. A single `work` call runs one wave. `autonomous: true` runs waves back-to-back until everything is done or blocked.
|
|
97
|
+
3. **Review** — Reviewer checks each implementation: SHIP, NEEDS_WORK, or MAJOR_RETHINK.
|
|
229
98
|
|
|
230
|
-
|
|
99
|
+
No special PRD format required — the planner auto-discovers `PRD.md`, `SPEC.md`, `DESIGN.md`, etc. in your project root and `docs/`.
|
|
231
100
|
|
|
232
|
-
###
|
|
101
|
+
### Wave Execution
|
|
233
102
|
|
|
234
|
-
|
|
103
|
+
Tasks form a dependency graph. Independent tasks run concurrently:
|
|
235
104
|
|
|
236
105
|
```
|
|
237
106
|
Wave 1: task-1 (no deps) ─┐
|
|
@@ -243,63 +112,7 @@ Wave 2: task-2 (→ task-1) ─┤── task-1 done, task-2 unblocked
|
|
|
243
112
|
Wave 3: task-5 (→ task-2, task-4) ── both deps done
|
|
244
113
|
```
|
|
245
114
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
The planner structures tasks to maximize this parallelism. Foundation work (types, config, schemas) has no dependencies so it starts immediately. Features that don't touch each other get separate dependency chains so they can run in parallel. Tasks that need shared work done first (tests, integration, docs) depend on the tasks that produce it.
|
|
249
|
-
|
|
250
|
-
A single `work` call runs one wave. Autonomous mode (`autonomous: true`) runs waves back-to-back until everything is done or blocked.
|
|
251
|
-
|
|
252
|
-
### Autonomous Mode
|
|
253
|
-
|
|
254
|
-
Run tasks continuously until completion:
|
|
255
|
-
|
|
256
|
-
```typescript
|
|
257
|
-
pi_messenger({ action: "work", autonomous: true })
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
Autonomous mode:
|
|
261
|
-
- Executes waves of parallel workers
|
|
262
|
-
- Auto-blocks on failure
|
|
263
|
-
- Stops when all tasks done or blocked
|
|
264
|
-
- Respects `maxWaves` limit (default: 50)
|
|
265
|
-
|
|
266
|
-
### Crew Overlay Tab
|
|
267
|
-
|
|
268
|
-
The `/messenger` overlay includes a Crew tab showing task status:
|
|
269
|
-
|
|
270
|
-
```
|
|
271
|
-
╭─ Messenger ── 3 agents ── myapp ──────────────────────╮
|
|
272
|
-
│ Agents │ ▸ Crew (2/5) │ ● GoldFalcon │ + All │
|
|
273
|
-
├──────────────────────────────────────────────────────┤
|
|
274
|
-
│ │
|
|
275
|
-
│ 📋 docs/PRD.md [2/5] │
|
|
276
|
-
│ │
|
|
277
|
-
│ ✓ task-1 Setup OAuth config │
|
|
278
|
-
│ ✓ task-2 Implement token storage │
|
|
279
|
-
│ ● task-3 Add Google provider (SwiftRaven) │
|
|
280
|
-
│ ○ task-4 Add GitHub provider → task-2 │
|
|
281
|
-
│ ○ task-5 Write tests → task-3, task-4 │
|
|
282
|
-
│ │
|
|
283
|
-
├──────────────────────────────────────────────────────┤
|
|
284
|
-
│ ● AUTO Wave 2 │ 2/5 done │ 1 ready │ ⏱️ 3:42 │
|
|
285
|
-
╰──────────────────────────────────────────────────────╯
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### Crew Data Storage
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
.pi/messenger/crew/
|
|
292
|
-
├── plan.json # Plan metadata (PRD path, progress)
|
|
293
|
-
├── plan.md # Planner output
|
|
294
|
-
├── planning-progress.md # Planning loop history + feedback
|
|
295
|
-
├── tasks/
|
|
296
|
-
│ ├── task-1.json # Task metadata
|
|
297
|
-
│ ├── task-1.md # Task specification
|
|
298
|
-
│ └── ...
|
|
299
|
-
├── blocks/ # Block context for blocked tasks
|
|
300
|
-
├── artifacts/ # Debug artifacts
|
|
301
|
-
└── config.json # Project-level crew config
|
|
302
|
-
```
|
|
115
|
+
The planner structures tasks to maximize parallelism. Foundation work has no dependencies and starts immediately. Features that don't touch each other get separate chains. Autonomous mode stops when all tasks are done or blocked.
|
|
303
116
|
|
|
304
117
|
### Crew Configuration
|
|
305
118
|
|
|
@@ -309,128 +122,80 @@ Add to `~/.pi/agent/pi-messenger.json`:
|
|
|
309
122
|
{
|
|
310
123
|
"crew": {
|
|
311
124
|
"concurrency": { "workers": 2 },
|
|
125
|
+
"models": { "worker": "claude-sonnet-4-20250514" },
|
|
312
126
|
"review": { "enabled": true, "maxIterations": 3 },
|
|
313
127
|
"planning": { "maxPasses": 3 },
|
|
314
|
-
"work": {
|
|
128
|
+
"work": {
|
|
129
|
+
"maxAttemptsPerTask": 5,
|
|
130
|
+
"maxWaves": 50,
|
|
131
|
+
"shutdownGracePeriodMs": 30000,
|
|
132
|
+
"env": { "NODE_ENV": "test" }
|
|
133
|
+
}
|
|
315
134
|
}
|
|
316
135
|
}
|
|
317
136
|
```
|
|
318
137
|
|
|
319
138
|
| Setting | Description | Default |
|
|
320
139
|
|---------|-------------|---------|
|
|
321
|
-
| `concurrency.workers` | Max parallel workers
|
|
322
|
-
| `
|
|
323
|
-
| `review.
|
|
324
|
-
| `
|
|
325
|
-
| `
|
|
326
|
-
| `work.
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
Crew agents are **auto-installed** on first use of `plan`, `work`, or `review`. To manually install or update:
|
|
140
|
+
| `concurrency.workers` | Max parallel workers per wave | `2` |
|
|
141
|
+
| `models.worker` | Model for spawned workers (overridden by per-task or per-wave `model` param) | agent `.md` frontmatter |
|
|
142
|
+
| `review.enabled` | Auto-review after task completion | `true` |
|
|
143
|
+
| `review.maxIterations` | Max review/fix cycles per task | `3` |
|
|
144
|
+
| `planning.maxPasses` | Max planner/reviewer refinement passes | `3` |
|
|
145
|
+
| `work.maxAttemptsPerTask` | Auto-block after N failures | `5` |
|
|
146
|
+
| `work.maxWaves` | Max autonomous waves | `50` |
|
|
147
|
+
| `work.shutdownGracePeriodMs` | Grace period before SIGTERM on abort | `30000` |
|
|
148
|
+
| `work.env` | Environment variables passed to spawned workers | `{}` |
|
|
331
149
|
|
|
332
|
-
|
|
333
|
-
pi_messenger({ action: "crew.install" })
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
**What gets installed:**
|
|
337
|
-
- **5 agents** in `~/.pi/agent/agents/` (planner, worker, reviewer, interview-generator, plan-sync)
|
|
338
|
-
- **1 skill** in `~/.pi/agent/skills/` (pi-messenger-crew quick reference)
|
|
339
|
-
|
|
340
|
-
To remove:
|
|
341
|
-
```typescript
|
|
342
|
-
pi_messenger({ action: "crew.uninstall" })
|
|
343
|
-
```
|
|
150
|
+
Crew agents (planner, worker, reviewer, interview-generator, plan-sync) are **auto-installed** on first use. Run `npx pi-messenger --crew-install` to manually install or update.
|
|
344
151
|
|
|
345
|
-
##
|
|
152
|
+
## API Reference
|
|
346
153
|
|
|
347
|
-
###
|
|
154
|
+
### Coordination
|
|
348
155
|
|
|
349
|
-
**Coordination**
|
|
350
156
|
| Action | Description |
|
|
351
157
|
|--------|-------------|
|
|
352
158
|
| `join` | Join the agent mesh |
|
|
353
159
|
| `list` | List agents with presence info |
|
|
354
160
|
| `status` | Show your status or crew progress |
|
|
355
|
-
| `whois` | Detailed info about an agent |
|
|
356
|
-
| `feed` | Show activity feed |
|
|
357
|
-
| `set_status` | Set custom status message (
|
|
358
|
-
| `send` | Send DM (
|
|
359
|
-
| `broadcast` | Broadcast to all (
|
|
360
|
-
| `reserve` | Reserve files (
|
|
361
|
-
| `release` | Release reservations (
|
|
362
|
-
| `rename` | Change your name (
|
|
363
|
-
| `swarm` | Show swarm task status |
|
|
364
|
-
| `claim` | Claim a swarm task (requires `taskId`) |
|
|
365
|
-
| `unclaim` | Release a swarm claim (requires `taskId`) |
|
|
366
|
-
| `complete` | Complete a swarm task (requires `taskId`) |
|
|
161
|
+
| `whois` | Detailed info about an agent (`name` required) |
|
|
162
|
+
| `feed` | Show activity feed (`limit` optional, default: 20) |
|
|
163
|
+
| `set_status` | Set custom status message (`message` optional — omit to clear) |
|
|
164
|
+
| `send` | Send DM (`to` + `message` required) |
|
|
165
|
+
| `broadcast` | Broadcast to all (`message` required) |
|
|
166
|
+
| `reserve` | Reserve files (`paths` required, `reason` optional) |
|
|
167
|
+
| `release` | Release reservations (`paths` optional — omit to release all) |
|
|
168
|
+
| `rename` | Change your name (`name` required) |
|
|
367
169
|
|
|
368
|
-
|
|
369
|
-
pi_messenger({
|
|
370
|
-
action: string, // Action to perform
|
|
371
|
-
|
|
372
|
-
// Coordination
|
|
373
|
-
name?: string, // For whois, rename
|
|
374
|
-
message?: string, // For send, broadcast, set_status
|
|
375
|
-
to?: string | string[], // For send
|
|
376
|
-
paths?: string[], // For reserve, release
|
|
377
|
-
reason?: string, // For reserve, claim, task.block
|
|
378
|
-
limit?: number, // For feed (default: 20)
|
|
379
|
-
|
|
380
|
-
// Plan
|
|
381
|
-
prd?: string, // PRD file path
|
|
382
|
-
|
|
383
|
-
// Task identifiers
|
|
384
|
-
id?: string, // Task ID (task-N)
|
|
385
|
-
taskId?: string, // Swarm task ID
|
|
386
|
-
target?: string, // Target for review
|
|
387
|
-
|
|
388
|
-
// Creation
|
|
389
|
-
title?: string, // For task.create
|
|
390
|
-
dependsOn?: string[], // Task dependencies
|
|
391
|
-
|
|
392
|
-
// Completion
|
|
393
|
-
summary?: string, // For task.done
|
|
394
|
-
|
|
395
|
-
// Work options
|
|
396
|
-
autonomous?: boolean, // Run continuously
|
|
397
|
-
concurrency?: number, // Override concurrency
|
|
398
|
-
|
|
399
|
-
// Reset
|
|
400
|
-
cascade?: boolean, // Reset dependent tasks too
|
|
401
|
-
})
|
|
402
|
-
```
|
|
170
|
+
### Crew
|
|
403
171
|
|
|
404
|
-
|
|
172
|
+
| Action | Description |
|
|
173
|
+
|--------|-------------|
|
|
174
|
+
| `plan` | Create plan from PRD (`prd` optional — auto-discovers if omitted) |
|
|
175
|
+
| `work` | Run ready tasks (`autonomous`, `concurrency` optional) |
|
|
176
|
+
| `review` | Review implementation (`target` task ID required) |
|
|
177
|
+
| `task.list` | List all tasks |
|
|
178
|
+
| `task.show` | Show task details (`id` required) |
|
|
179
|
+
| `task.start` | Start a task (`id` required) |
|
|
180
|
+
| `task.done` | Complete a task (`id` required, `summary` optional) |
|
|
181
|
+
| `task.block` | Block a task (`id` + `reason` required) |
|
|
182
|
+
| `task.unblock` | Unblock a task (`id` required) |
|
|
183
|
+
| `task.ready` | List tasks ready to work |
|
|
184
|
+
| `task.reset` | Reset a task (`id` required, `cascade` optional) |
|
|
185
|
+
| `crew.status` | Overall crew status |
|
|
186
|
+
| `crew.validate` | Validate plan dependencies |
|
|
187
|
+
| `crew.agents` | List available crew agents |
|
|
188
|
+
| `crew.install` | Install/update crew agents |
|
|
189
|
+
| `crew.uninstall` | Remove crew agents and skill |
|
|
190
|
+
|
|
191
|
+
### Swarm (Spec-Based)
|
|
405
192
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
// Swarm
|
|
413
|
-
swarm?: boolean, // Get swarm status
|
|
414
|
-
claim?: string, // Claim a task
|
|
415
|
-
unclaim?: string, // Release without completing
|
|
416
|
-
complete?: string, // Mark task complete
|
|
417
|
-
notes?: string, // Completion notes
|
|
418
|
-
|
|
419
|
-
// Messaging
|
|
420
|
-
to?: string | string[], // Recipient(s)
|
|
421
|
-
broadcast?: boolean, // Send to all
|
|
422
|
-
message?: string, // Message text
|
|
423
|
-
|
|
424
|
-
// Reservations
|
|
425
|
-
reserve?: string[], // Paths to reserve
|
|
426
|
-
reason?: string, // Why reserving/claiming
|
|
427
|
-
release?: string[] | true, // Release reservations
|
|
428
|
-
|
|
429
|
-
// Other
|
|
430
|
-
rename?: string, // Change your name
|
|
431
|
-
list?: boolean, // List active agents
|
|
432
|
-
})
|
|
433
|
-
```
|
|
193
|
+
| Action | Description |
|
|
194
|
+
|--------|-------------|
|
|
195
|
+
| `swarm` | Show swarm task status |
|
|
196
|
+
| `claim` | Claim a task (`taskId` required) |
|
|
197
|
+
| `unclaim` | Release a claim (`taskId` required) |
|
|
198
|
+
| `complete` | Complete a task (`taskId` required) |
|
|
434
199
|
|
|
435
200
|
## Configuration
|
|
436
201
|
|
|
@@ -452,32 +217,30 @@ Create `~/.pi/agent/pi-messenger.json`:
|
|
|
452
217
|
| `autoRegister` | Join mesh on startup | `false` |
|
|
453
218
|
| `autoRegisterPaths` | Folders where auto-join is enabled (supports `*` globs) | `[]` |
|
|
454
219
|
| `scopeToFolder` | Only see agents in same directory | `false` |
|
|
455
|
-
| `nameTheme` | Name
|
|
220
|
+
| `nameTheme` | Name theme: `default`, `nature`, `space`, `minimal`, `custom` | `"default"` |
|
|
456
221
|
| `nameWords` | Custom theme words: `{ adjectives: [...], nouns: [...] }` | — |
|
|
457
222
|
| `feedRetention` | Max events kept in activity feed | `50` |
|
|
458
|
-
| `stuckThreshold` | Seconds of inactivity before stuck detection | `900`
|
|
223
|
+
| `stuckThreshold` | Seconds of inactivity before stuck detection | `900` |
|
|
459
224
|
| `stuckNotify` | Show notification when a peer appears stuck | `true` |
|
|
460
225
|
| `autoStatus` | Auto-generate status messages from activity | `true` |
|
|
461
226
|
| `crewEventsInFeed` | Include crew task events in activity feed | `true` |
|
|
462
227
|
| `contextMode` | Context injection level: `full`, `minimal`, `none` | `"full"` |
|
|
463
228
|
|
|
229
|
+
Config priority: project `.pi/pi-messenger.json` > user `~/.pi/agent/pi-messenger.json` > `~/.pi/agent/settings.json` `"messenger"` key > defaults.
|
|
230
|
+
|
|
464
231
|
## How It Works
|
|
465
232
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
├── claims.json # Active task claims
|
|
472
|
-
├── completions.json # Completed tasks
|
|
473
|
-
└── swarm.lock # Atomic lock for claims
|
|
474
|
-
```
|
|
233
|
+
Pi-messenger is a [pi extension](https://github.com/badlogic/pi-mono) that hooks into the agent lifecycle. It uses `pi.on("tool_call")` and `pi.on("tool_result")` to track activity — every edit, commit, and test run gets logged. `pi.on("session_start")` handles auto-registration, `pi.on("session_shutdown")` cleans up, and `pi.on("agent_end")` drives autonomous crew mode by checking for ready tasks after each agent turn.
|
|
234
|
+
|
|
235
|
+
Incoming messages wake the receiving agent via `pi.sendMessage()` with `triggerTurn: true` and `deliverAs: "steer"`, which injects the message as a steering prompt that resumes the agent. File reservations are enforced by returning `{ block: true }` from a `tool_call` hook on write/edit operations. The `/messenger` overlay uses `ctx.ui.custom()` for the chat TUI, and `ctx.ui.setStatus()` keeps the status bar updated with peer count and unread messages.
|
|
236
|
+
|
|
237
|
+
Crew workers are spawned as `pi --mode json` subprocesses with the agent's system prompt, model, and tool restrictions from their `.md` definitions. Progress is tracked via JSONL streaming — the overlay subscribes to a live progress store that shows each worker's current tool, call count, and token usage in real time. Aborting a work run triggers graceful shutdown: each worker receives an inbox message asking it to stop, followed by a grace period before SIGTERM. The planner and reviewer work the same way — just pi instances with different agent configs.
|
|
475
238
|
|
|
476
|
-
|
|
239
|
+
All coordination is file-based, no daemon required. Global state (registry, inboxes, activity feed) lives in `~/.pi/agent/messenger/`. Per-project crew data (plan, tasks, artifacts) lives in `.pi/messenger/crew/` inside your project. Dead agents are detected via PID checks and cleaned up automatically.
|
|
477
240
|
|
|
478
241
|
## Credits
|
|
479
242
|
|
|
480
|
-
- **[mcp_agent_mail](https://github.com/Dicklesworthstone/mcp_agent_mail)** by [@doodlestein](https://x.com/doodlestein)
|
|
243
|
+
- **[mcp_agent_mail](https://github.com/Dicklesworthstone/mcp_agent_mail)** by [@doodlestein](https://x.com/doodlestein) — Inspiration for agent-to-agent messaging
|
|
481
244
|
- **[Pi coding agent](https://github.com/badlogic/pi-mono/)** by [@badlogicgames](https://x.com/badlogicgames)
|
|
482
245
|
|
|
483
246
|
## License
|
|
@@ -85,6 +85,15 @@ pi_messenger({
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
## Shutdown Handling
|
|
89
|
+
|
|
90
|
+
If you receive a message saying "SHUTDOWN REQUESTED":
|
|
91
|
+
1. Stop what you're doing
|
|
92
|
+
2. Release reservations: `pi_messenger({ action: "release" })`
|
|
93
|
+
3. Do NOT mark the task as done — leave it as in_progress for retry
|
|
94
|
+
4. Do NOT commit anything
|
|
95
|
+
5. Exit immediately
|
|
96
|
+
|
|
88
97
|
## Important Rules
|
|
89
98
|
|
|
90
99
|
- ALWAYS join first, before any other pi_messenger calls
|