@linxiraos/pi-messenger 1.1.1 → 1.3.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +741 -676
  2. package/LICENSE +45 -0
  3. package/README.md +424 -424
  4. package/THIRD-PARTY-NOTICES.txt +22951 -0
  5. package/config-overlay.ts +175 -171
  6. package/config.ts +221 -209
  7. package/crew/agents/crew-plan-sync.md +66 -64
  8. package/crew/agents/crew-planner.md +173 -172
  9. package/crew/agents/crew-reviewer.md +58 -58
  10. package/crew/agents/crew-worker.md +130 -129
  11. package/crew/agents.ts +507 -434
  12. package/crew/handlers/coordination.ts +350 -332
  13. package/crew/handlers/plan.ts +988 -906
  14. package/crew/handlers/review.ts +354 -333
  15. package/crew/handlers/revise.ts +400 -376
  16. package/crew/handlers/status.ts +303 -295
  17. package/crew/handlers/sync.ts +237 -233
  18. package/crew/handlers/task.ts +820 -792
  19. package/crew/handlers/team.ts +294 -235
  20. package/crew/handlers/work.ts +467 -425
  21. package/crew/id-allocator.ts +30 -30
  22. package/crew/index.ts +297 -257
  23. package/crew/live-progress.ts +58 -58
  24. package/crew/lobby.ts +504 -473
  25. package/crew/prompt.ts +262 -252
  26. package/crew/registry.ts +114 -114
  27. package/crew/spawn.ts +135 -111
  28. package/crew/state-autonomous.ts +163 -164
  29. package/crew/state-planning.ts +264 -263
  30. package/crew/state.ts +20 -20
  31. package/crew/store.ts +646 -642
  32. package/crew/task-actions.ts +162 -131
  33. package/crew/team/store.ts +572 -479
  34. package/crew/team/subagent-roles.ts +105 -87
  35. package/crew/team/types.ts +50 -50
  36. package/crew/types.ts +194 -194
  37. package/crew/utils/artifacts.ts +57 -62
  38. package/crew/utils/config.ts +158 -156
  39. package/crew/utils/discover.ts +221 -219
  40. package/crew/utils/install.ts +94 -85
  41. package/crew/utils/migrations.ts +126 -0
  42. package/crew/utils/progress.ts +191 -187
  43. package/crew/utils/result.ts +16 -16
  44. package/crew/utils/risk-labels.ts +5 -7
  45. package/crew/utils/task-format.ts +14 -14
  46. package/crew/utils/team-roles.ts +44 -28
  47. package/crew/utils/truncate.ts +76 -79
  48. package/crew/utils/verdict.ts +55 -55
  49. package/editor-binary.ts +150 -0
  50. package/editor-command.ts +107 -0
  51. package/editor-target.ts +40 -0
  52. package/feed.ts +321 -268
  53. package/handlers.ts +1041 -1107
  54. package/index.ts +1314 -1206
  55. package/install.mjs +187 -189
  56. package/lib.ts +587 -467
  57. package/overlay-actions.ts +519 -511
  58. package/overlay-coordinator.ts +150 -150
  59. package/overlay-render.ts +770 -676
  60. package/overlay.ts +872 -830
  61. package/package.json +64 -60
  62. package/paths.ts +60 -0
  63. package/skills/pi-messenger-crew/SKILL.md +375 -347
  64. package/store.ts +1147 -1139
  65. package/teamagent-command.ts +321 -0
  66. package/vitest.config.ts +10 -10
@@ -1,347 +1,375 @@
1
- ---
2
- name: pi-messenger-crew
3
- description: Orchestrator reference for pi-messenger Crew planning, task management, configuration, and agent coordination. Crew workers already have the pi_messenger actions they need in crew-worker.md.
4
- ---
5
-
6
- # Pi-Messenger Crew Skill
7
-
8
- > Crew workers do not need this skill. `crew-worker.md` already contains every `pi_messenger` action workers need for task execution.
9
- >
10
- > Orchestrators and humans can use this as the full reference for planning, task management, configuration, and Crew internals.
11
-
12
- Use pi-messenger for multi-agent coordination and Crew task orchestration.
13
-
14
- ## Quick Reference
15
-
16
- ### Join or Leave the Mesh
17
- ```typescript
18
- pi_messenger({ action: "join" })
19
- pi_messenger({ action: "leave" })
20
- ```
21
-
22
- ### Check Status
23
- ```typescript
24
- pi_messenger({ action: "status" })
25
- pi_messenger({ action: "list" }) // See other agents
26
- pi_messenger({ action: "feed" }) // Activity feed
27
- ```
28
-
29
- ## Crew Workflow
30
-
31
- ### 1. Check Crew Agents
32
- ```typescript
33
- pi_messenger({ action: "crew.agents" }) // Verify 5 agents
34
- pi_messenger({ action: "crew.install" }) // Informational: shows discovered sources
35
- ```
36
-
37
- ### 2. Plan from PRD
38
- ```typescript
39
- // Auto-discover PRD.md in current directory
40
- pi_messenger({ action: "plan" })
41
-
42
- // Or specify path
43
- pi_messenger({ action: "plan", prd: "path/to/PRD.md" })
44
-
45
- // Or pass an inline prompt (no PRD file needed)
46
- pi_messenger({ action: "plan", prompt: "Scan the codebase for bugs focusing on error handling" })
47
-
48
- // Re-plan with a steering prompt (wipes existing tasks, preserves progress notes)
49
- pi_messenger({ action: "plan", prompt: "Split the auth module into login and registration" })
50
-
51
- // Steer first-time planning (prompt injected into progress notes before planner runs)
52
- pi_messenger({ action: "plan", prd: "docs/PRD.md", prompt: "focus on backend first" })
53
-
54
- // Plan + auto-start autonomous work when planning completes
55
- pi_messenger({ action: "plan" }) // auto-starts workers (default)
56
-
57
- // Cancel active or stale planning
58
- pi_messenger({ action: "plan.cancel" })
59
- ```
60
-
61
- Re-planning rejects if any tasks are `in_progress` — stop or complete them first. The steering prompt is injected into `planning-progress.md`'s Notes section where the planner reads it on every pass.
62
-
63
- ### Optional: Activate Team Context
64
- ```typescript
65
- pi_messenger({ action: "team.setup", name: "migration-squad" })
66
- pi_messenger({ action: "team.setup", name: "review-squad" })
67
- pi_messenger({ action: "team.setup", name: "research-squad", message: "Research first, then plan the implementation." })
68
- pi_messenger({ action: "team.memory.note", type: "decision", message: "Use cursor pagination for task history" })
69
- pi_messenger({ action: "team.roles" })
70
- pi_messenger({ action: "team.status" })
71
- ```
72
-
73
- Team is optional. Use `team.setup` for first-run setup: it activates a profile, saves editable JSON if needed, creates a starter charter when missing, and returns next steps. Crew remains the execution engine. Team role names follow the packaged `pi-subagents` vocabulary where possible (`context-builder`, `delegate`, `oracle`, `planner`, `researcher`, `reviewer`, `scout`, `worker`). `pi-messenger` may read subagent markdown metadata from disk when present, but it does not require or invoke subagents. Active Team profiles let the planner tag tasks with `role` and `riskLabels`, then inject role, charter, and memory context into worker prompts. High-risk tasks wait for `task.approve`; `task.reject` records feedback and rejected tasks surface `task.revise` / `task.revise-tree` next steps.
74
-
75
- ### 3. Work on Tasks
76
- ```typescript
77
- // Single wave (runs ready tasks once)
78
- pi_messenger({ action: "work" })
79
-
80
- // Autonomous (keeps running until done/blocked)
81
- pi_messenger({ action: "work", autonomous: true })
82
-
83
- // Override concurrency or model for this wave
84
- pi_messenger({ action: "work", autonomous: true, concurrency: 4 })
85
- pi_messenger({ action: "work", model: "claude-sonnet-4-20250514" })
86
- ```
87
-
88
- ### 4. Task Management
89
- ```typescript
90
- pi_messenger({ action: "task.list" })
91
- pi_messenger({ action: "task.ready" }) // Tasks with no pending deps
92
- pi_messenger({ action: "task.show", id: "task-1" })
93
- pi_messenger({ action: "task.start", id: "task-1" })
94
- pi_messenger({ action: "task.progress", id: "task-1", message: "Implemented auth middleware" })
95
- pi_messenger({ action: "task.done", id: "task-1", summary: "What was done" })
96
- pi_messenger({ action: "task.block", id: "task-1", reason: "Why blocked" })
97
- pi_messenger({ action: "task.unblock", id: "task-1" })
98
- pi_messenger({ action: "task.reset", id: "task-1" })
99
- pi_messenger({ action: "task.reset", id: "task-1", cascade: true }) // Reset dependents too
100
-
101
- // Create tasks manually
102
- pi_messenger({ action: "task.create", title: "Implement auth", content: "Detailed spec...", dependsOn: ["task-1"] })
103
- pi_messenger({ action: "task.create", title: "Change auth API", role: "worker", riskLabels: ["auth", "api-contract"] })
104
- pi_messenger({ action: "task.approve", id: "task-2" })
105
-
106
- // Split a task into subtasks (two-phase: inspect then execute)
107
- pi_messenger({ action: "task.split", id: "task-3" }) // Inspect: shows spec, deps, dependents
108
- pi_messenger({ action: "task.split", id: "task-3", subtasks: [
109
- { title: "Subtask A", content: "..." },
110
- { title: "Subtask B", content: "..." }
111
- ] }) // Execute: creates subtasks, parent becomes milestone
112
- ```
113
-
114
- ### 5. Task Revision
115
- ```typescript
116
- // Revise a single task's spec (planner rewrites based on your prompt)
117
- pi_messenger({ action: "task.revise", id: "task-3", prompt: "add error handling for network failures" })
118
-
119
- // Revise a task and all its transitive dependents (subtree revision)
120
- // Planner sees the full subtree and can add/remove/modify tasks
121
- pi_messenger({ action: "task.revise-tree", id: "task-3", prompt: "split this into separate API and CLI tasks" })
122
- ```
123
-
124
- Single revision rewrites one task's spec. Tree revision rewrites an entire subtree — the planner can modify existing tasks, add new ones (capped at 2x subtree size), remove pending ones, and rewire dependencies. Done tasks in the subtree are preserved; revisable tasks reset to `todo`.
125
-
126
- Both revisions are mutually exclusive (only one revision at a time).
127
-
128
- ### 6. Review
129
- ```typescript
130
- // Review a task implementation
131
- pi_messenger({ action: "review", target: "task-1" })
132
-
133
- // Review the overall plan
134
- pi_messenger({ action: "review", target: "plan", type: "plan" })
135
- ```
136
-
137
- ## Overlay Keybindings
138
-
139
- The Crew overlay (accessible via `/messenger` then tab to Crew) supports these keybindings:
140
-
141
- **Global:** `[+/-]` Adjust worker concurrency (1-10), `[c]` Cancel active planning, `[Esc]` Close/back
142
-
143
- **Task list view:** `[↑/↓]` Navigate, `[Enter]` Detail view
144
-
145
- **Task actions (list and detail):**
146
- - `[s]` Start task (todo only)
147
- - `[r]` Reset task, `[R]` Cascade reset (reset + all dependents)
148
- - `[u]` Unblock task (blocked only)
149
- - `[b]` Block with reason (in_progress only)
150
- - `[q]` Stop worker (in_progress with live worker)
151
- - `[m]` Message worker (in_progress with live worker)
152
- - `[S]` Split task (shows hint with command)
153
- - `[p]` Revise task spec, `[P]` Revise subtree (not in_progress, not milestone)
154
- - `[x]` Delete task (not while worker is active)
155
- - `[←/→]` Navigate between tasks in detail view
156
-
157
- ## File Coordination
158
-
159
- ```typescript
160
- // Reserve files before editing
161
- pi_messenger({ action: "reserve", paths: ["src/index.ts", "src/types.ts"], reason: "Working on core" })
162
-
163
- // Release when done
164
- pi_messenger({ action: "release" })
165
- ```
166
-
167
- ## Agent Communication
168
-
169
- ```typescript
170
- // Rename yourself
171
- pi_messenger({ action: "rename", name: "MyAgentName" })
172
-
173
- // Send message to specific agent
174
- pi_messenger({ action: "send", to: "OtherAgent", message: "Hello!" })
175
-
176
- // Broadcast to all
177
- pi_messenger({ action: "broadcast", message: "Announcement" })
178
- ```
179
-
180
- Messages are logged to the feed and visible in the overlay. DMs interrupt only the target agent (delivered as steering); broadcasts interrupt all agents.
181
-
182
- ## Typical Crew Session
183
-
184
- ```typescript
185
- // 1. Join
186
- pi_messenger({ action: "join" })
187
-
188
- // 2. Plan (spawns planner agent)
189
- pi_messenger({ action: "plan" })
190
-
191
- // 3. Check tasks
192
- pi_messenger({ action: "task.list" })
193
-
194
- // 4. Work
195
- pi_messenger({ action: "work", autonomous: true })
196
-
197
- // 5. Status
198
- pi_messenger({ action: "status" })
199
- ```
200
-
201
- ## Data Storage
202
-
203
- Crew stores data in `.pi/messenger/crew/`:
204
- ```
205
- .pi/messenger/crew/
206
- ├── config.json # Project config (concurrency, models, coordination, etc.)
207
- ├── plan.json # Plan metadata
208
- ├── planning-progress.md # Planner output log (Notes section for steering)
209
- ├── planning-outline.md # Latest plan outline
210
- ├── planning-state.json # Current planning phase/pass
211
- ├── agents/ # Optional: project-level crew agent overrides
212
- │ └── crew-worker.md
213
- ├── tasks/
214
- │ ├── task-1.json # Task metadata (status, deps, summary)
215
- │ ├── task-1.md # Task spec (planner-generated)
216
- │ ├── task-1.progress.md # Worker progress log
217
- │ └── ...
218
- ├── blocks/
219
- │ └── task-N.md # Block context
220
- └── artifacts/ # Debug artifacts (agent input/output)
221
- ```
222
-
223
- Team stores active project state in `.pi/messenger/team/`:
224
- ```
225
- .pi/messenger/team/
226
- ├── team.json # Active team/profile
227
- ├── charter.md # Project team charter
228
- ├── memory.jsonl # Structured memory source of truth
229
- ├── decisions.md # Human-readable memory rollups
230
- ├── interfaces.md
231
- ├── risks.md
232
- └── handoffs.md
233
- ```
234
-
235
- Reusable profiles are JSON files under `~/.pi/agent/messenger/team-profiles/`.
236
-
237
- The activity feed lives at `.pi/messenger/feed.jsonl` (project-scoped, shared across all agents in the project).
238
-
239
- Each crew agent ships with a default model:
240
-
241
- | Agent | Role | Default Model |
242
- |-------|------|---------------|
243
- | `crew-planner` | planner | `anthropic/claude-opus-4-6` |
244
- | `crew-worker` | worker | `anthropic/claude-haiku-4-5` |
245
- | `crew-reviewer` | reviewer | `anthropic/claude-opus-4-6` |
246
- | `crew-plan-sync` | analyst | `anthropic/claude-haiku-4-5` |
247
-
248
- Override via `crew.models.<role>` in config. To customize an agent for a project, copy it from `~/.pi/agent/extensions/pi-messenger/crew/agents/` to `.pi/messenger/crew/agents/` and edit the frontmatter — project-level agents override extension defaults by name. Agents support `thinking: <level>` in frontmatter (off, minimal, low, medium, high, xhigh). Config `thinking.<role>` overrides the frontmatter value.
249
-
250
- ## Configuration
251
-
252
- User-level config goes in `~/.pi/agent/pi-messenger.json` under a `crew` key. Project-level config goes in `.pi/messenger/crew/config.json`. Project overrides user, both override defaults.
253
-
254
- Crew spawns multiple LLM sessions in parallel — start with a cheap worker model and scale up. Add this to `~/.pi/agent/pi-messenger.json`:
255
-
256
- ```json
257
- { "crew": { "models": { "worker": "claude-haiku-4-5" } } }
258
- ```
259
-
260
- Model strings accept `provider/model` format for explicit provider selection and `:level` suffix for inline thinking control:
261
-
262
- ```json
263
- { "crew": { "models": { "worker": "anthropic/claude-haiku-4-5", "planner": "openrouter/anthropic/claude-sonnet-4:high" } } }
264
- ```
265
-
266
- The `:level` suffix and the `thinking.<role>` config are independent — if both are set, the suffix takes precedence.
267
-
268
- Full example (`~/.pi/agent/pi-messenger.json`):
269
- ```json
270
- {
271
- "crew": {
272
- "concurrency": { "workers": 3, "max": 6 },
273
- "models": { "worker": "claude-haiku-4-5", "planner": "claude-sonnet-4-6" },
274
- "coordination": "chatty",
275
- "work": { "maxAttemptsPerTask": 5 }
276
- }
277
- }
278
- ```
279
-
280
- Project-level (`.pi/messenger/crew/config.json`):
281
- ```json
282
- {
283
- "concurrency": { "workers": 4 },
284
- "coordination": "moderate",
285
- "models": { "worker": "gpt-4.1" },
286
- "planning": { "maxPasses": 1 },
287
- "work": {
288
- "maxWaves": 50,
289
- "env": { "OPENAI_API_BASE": "https://custom.endpoint" }
290
- }
291
- }
292
- ```
293
-
294
- ### Key Settings
295
-
296
- | Setting | Description | Default |
297
- |---------|-------------|---------|
298
- | `concurrency.workers` | Default parallel workers per wave | `2` |
299
- | `concurrency.max` | Maximum workers allowed via `+` key (hard ceiling: 10) | `10` |
300
- | `dependencies` | Dependency scheduling mode: `advisory` or `strict` | `"advisory"` |
301
- | `coordination` | Worker communication level: `none`, `minimal`, `moderate`, `chatty` | `chatty` |
302
- | `messageBudgets` | Max outgoing messages per worker per level (sends rejected after limit) | `{ none: 0, minimal: 2, moderate: 5, chatty: 10 }` |
303
- | `models.worker` | Default model for workers | `anthropic/claude-haiku-4-5` |
304
- | `models.planner` | Default model for planner | `anthropic/claude-opus-4-6` |
305
- | `models.reviewer` | Default model for reviewer | `anthropic/claude-opus-4-6` |
306
- | `models.analyst` | Default model for analyst (plan-sync) | `anthropic/claude-haiku-4-5` |
307
- | `thinking.planner` | Thinking level for planner agent | (from frontmatter) |
308
- | `thinking.worker` | Thinking level for worker agents | (from frontmatter) |
309
- | `thinking.reviewer` | Thinking level for reviewer agents | (from frontmatter) |
310
- | `thinking.analyst` | Thinking level for analyst agents | (from frontmatter) |
311
- | `planning.maxPasses` | Max planner/reviewer refinement passes | `1` |
312
- | `work.maxWaves` | Max autonomous waves | `50` |
313
- | `work.maxAttemptsPerTask` | Max attempts before auto-blocking a task | `5` |
314
- | `work.stopOnBlock` | Stop autonomous mode when any task blocks | `false` |
315
- | `work.shutdownGracePeriodMs` | Grace period before SIGTERM on abort | `30000` |
316
- | `work.env` | Environment variables passed to spawned workers | `{}` |
317
-
318
- ### Coordination Levels
319
-
320
- Controls how much workers communicate during execution:
321
-
322
- - **`none`**: No coordination instructions. Workers just execute their task.
323
- - **`minimal`**: Check reservations before editing files. Message if conflicts.
324
- - **`moderate`**: Announce start/completion via broadcast. Check reservations. Ask about unclear dependencies.
325
- - **`chatty`** (default): All of moderate, plus: DM peers whose tasks overlap, share progress on interface changes, respond to incoming messages, claim next task after completion.
326
-
327
- At `moderate` and `chatty`, workers also receive recent activity context and concurrent task info in their prompts.
328
-
329
- ### Model Override Priority
330
-
331
- Worker model is resolved with this priority (highest wins):
332
- 1. Per-task `model` field on the task object
333
- 2. Per-wave `model` param on the work call
334
- 3. Team role model when present
335
- 4. Config-level `crew.models.worker`
336
- 5. Host session model
337
- 6. Agent `.md` frontmatter `model` field
338
-
339
- ### Graceful Shutdown
340
-
341
- When you cancel a work run (Ctrl+C), workers receive a shutdown sequence:
342
- 1. Inbox message asking the worker to stop, release reservations, and exit
343
- 2. Wait `shutdownGracePeriodMs` (default 30s) for clean exit
344
- 3. SIGTERM if still running, wait 5s
345
- 4. SIGKILL if still running
346
-
347
- Tasks from gracefully shutdown workers reset to `todo` for retry on the next wave. Crashed workers (non-graceful exit) block the task in autonomous mode to prevent retry loops.
1
+ ---
2
+ name: pi-messenger-crew
3
+ description: Orchestrator reference for pi-messenger Crew planning, task management, configuration, and agent coordination. Crew workers already have the pi_messenger actions they need in crew-worker.md.
4
+ ---
5
+
6
+ # Pi-Messenger Crew Skill
7
+
8
+ > Crew workers do not need this skill. `crew-worker.md` already contains every `pi_messenger` action workers need for task execution.
9
+ >
10
+ > Orchestrators and humans can use this as the full reference for planning, task management, configuration, and Crew internals.
11
+
12
+ Use pi-messenger for multi-agent coordination and Crew task orchestration.
13
+
14
+ ## Quick Reference
15
+
16
+ ### Join or Leave the Mesh
17
+
18
+ ```typescript
19
+ pi_messenger({ action: "join" });
20
+ pi_messenger({ action: "leave" });
21
+ ```
22
+
23
+ ### Check Status
24
+
25
+ ```typescript
26
+ pi_messenger({ action: "status" });
27
+ pi_messenger({ action: "list" }); // See other agents
28
+ pi_messenger({ action: "feed" }); // Activity feed
29
+ ```
30
+
31
+ ## Crew Workflow
32
+
33
+ ### 1. Check Crew Agents
34
+
35
+ ```typescript
36
+ pi_messenger({ action: "crew.agents" }); // Verify 5 agents
37
+ pi_messenger({ action: "crew.install" }); // Informational: shows discovered sources
38
+ ```
39
+
40
+ ### 2. Plan from PRD
41
+
42
+ ```typescript
43
+ // Auto-discover PRD.md in current directory
44
+ pi_messenger({ action: "plan" });
45
+
46
+ // Or specify path
47
+ pi_messenger({ action: "plan", prd: "path/to/PRD.md" });
48
+
49
+ // Or pass an inline prompt (no PRD file needed)
50
+ pi_messenger({ action: "plan", prompt: "Scan the codebase for bugs focusing on error handling" });
51
+
52
+ // Re-plan with a steering prompt (wipes existing tasks, preserves progress notes)
53
+ pi_messenger({ action: "plan", prompt: "Split the auth module into login and registration" });
54
+
55
+ // Steer first-time planning (prompt injected into progress notes before planner runs)
56
+ pi_messenger({ action: "plan", prd: "docs/PRD.md", prompt: "focus on backend first" });
57
+
58
+ // Plan + auto-start autonomous work when planning completes
59
+ pi_messenger({ action: "plan" }); // auto-starts workers (default)
60
+
61
+ // Cancel active or stale planning
62
+ pi_messenger({ action: "plan.cancel" });
63
+ ```
64
+
65
+ Re-planning rejects if any tasks are `in_progress` — stop or complete them first. The steering prompt is injected into `planning-progress.md`'s Notes section where the planner reads it on every pass.
66
+
67
+ ### Optional: Activate Team Context
68
+
69
+ ```typescript
70
+ pi_messenger({ action: "team.setup", name: "migration-squad" });
71
+ pi_messenger({ action: "team.setup", name: "review-squad" });
72
+ pi_messenger({
73
+ action: "team.setup",
74
+ name: "research-squad",
75
+ message: "Research first, then plan the implementation.",
76
+ });
77
+ pi_messenger({ action: "team.memory.note", type: "decision", message: "Use cursor pagination for task history" });
78
+ pi_messenger({ action: "team.roles" });
79
+ pi_messenger({ action: "team.status" });
80
+ ```
81
+
82
+ Team is optional. Use `team.setup` for first-run setup: it activates a profile, saves editable JSON if needed, creates a starter charter when missing, and returns next steps. Crew remains the execution engine. Team role names follow the packaged `pi-subagents` vocabulary where possible (`context-builder`, `delegate`, `oracle`, `planner`, `researcher`, `reviewer`, `scout`, `worker`). `pi-messenger` may read subagent markdown metadata from disk when present, but it does not require or invoke subagents. Active Team profiles let the planner tag tasks with `role` and `riskLabels`, then inject role, charter, and memory context into worker prompts. High-risk tasks wait for `task.approve`; `task.reject` records feedback and rejected tasks surface `task.revise` / `task.revise-tree` next steps.
83
+
84
+ ### 3. Work on Tasks
85
+
86
+ ```typescript
87
+ // Single wave (runs ready tasks once)
88
+ pi_messenger({ action: "work" });
89
+
90
+ // Autonomous (keeps running until done/blocked)
91
+ pi_messenger({ action: "work", autonomous: true });
92
+
93
+ // Override concurrency or model for this wave
94
+ pi_messenger({ action: "work", autonomous: true, concurrency: 4 });
95
+ pi_messenger({ action: "work", model: "claude-sonnet-4-20250514" });
96
+ ```
97
+
98
+ ### 4. Task Management
99
+
100
+ ```typescript
101
+ pi_messenger({ action: "task.list" });
102
+ pi_messenger({ action: "task.ready" }); // Tasks with no pending deps
103
+ pi_messenger({ action: "task.show", id: "task-1" });
104
+ pi_messenger({ action: "task.start", id: "task-1" });
105
+ pi_messenger({ action: "task.progress", id: "task-1", message: "Implemented auth middleware" });
106
+ pi_messenger({ action: "task.done", id: "task-1", summary: "What was done" });
107
+ pi_messenger({ action: "task.block", id: "task-1", reason: "Why blocked" });
108
+ pi_messenger({ action: "task.unblock", id: "task-1" });
109
+ pi_messenger({ action: "task.reset", id: "task-1" });
110
+ pi_messenger({ action: "task.reset", id: "task-1", cascade: true }); // Reset dependents too
111
+
112
+ // Create tasks manually
113
+ pi_messenger({ action: "task.create", title: "Implement auth", content: "Detailed spec...", dependsOn: ["task-1"] });
114
+ pi_messenger({ action: "task.create", title: "Change auth API", role: "worker", riskLabels: ["auth", "api-contract"] });
115
+ pi_messenger({ action: "task.approve", id: "task-2" });
116
+
117
+ // Split a task into subtasks (two-phase: inspect then execute)
118
+ pi_messenger({ action: "task.split", id: "task-3" }); // Inspect: shows spec, deps, dependents
119
+ pi_messenger({
120
+ action: "task.split",
121
+ id: "task-3",
122
+ subtasks: [
123
+ { title: "Subtask A", content: "..." },
124
+ { title: "Subtask B", content: "..." },
125
+ ],
126
+ }); // Execute: creates subtasks, parent becomes milestone
127
+ ```
128
+
129
+ ### 5. Task Revision
130
+
131
+ ```typescript
132
+ // Revise a single task's spec (planner rewrites based on your prompt)
133
+ pi_messenger({ action: "task.revise", id: "task-3", prompt: "add error handling for network failures" });
134
+
135
+ // Revise a task and all its transitive dependents (subtree revision)
136
+ // Planner sees the full subtree and can add/remove/modify tasks
137
+ pi_messenger({ action: "task.revise-tree", id: "task-3", prompt: "split this into separate API and CLI tasks" });
138
+ ```
139
+
140
+ Single revision rewrites one task's spec. Tree revision rewrites an entire subtree — the planner can modify existing tasks, add new ones (capped at 2x subtree size), remove pending ones, and rewire dependencies. Done tasks in the subtree are preserved; revisable tasks reset to `todo`.
141
+
142
+ Both revisions are mutually exclusive (only one revision at a time).
143
+
144
+ ### 6. Review
145
+
146
+ ```typescript
147
+ // Review a task implementation
148
+ pi_messenger({ action: "review", target: "task-1" });
149
+
150
+ // Review the overall plan
151
+ pi_messenger({ action: "review", target: "plan", type: "plan" });
152
+ ```
153
+
154
+ ## Overlay Keybindings
155
+
156
+ The Crew overlay (accessible via `/messenger` then tab to Crew) supports these keybindings:
157
+
158
+ **Global:** `[+/-]` Adjust worker concurrency (1-10), `[c]` Cancel active planning, `[Esc]` Close/back
159
+
160
+ **Task list view:** `[↑/↓]` Navigate, `[Enter]` Detail view
161
+
162
+ **Task actions (list and detail):**
163
+
164
+ - `[s]` Start task (todo only)
165
+ - `[r]` Reset task, `[R]` Cascade reset (reset + all dependents)
166
+ - `[u]` Unblock task (blocked only)
167
+ - `[b]` Block with reason (in_progress only)
168
+ - `[q]` Stop worker (in_progress with live worker)
169
+ - `[m]` Message worker (in_progress with live worker)
170
+ - `[S]` Split task (shows hint with command)
171
+ - `[p]` Revise task spec, `[P]` Revise subtree (not in_progress, not milestone)
172
+ - `[x]` Delete task (not while worker is active)
173
+ - `[←/→]` Navigate between tasks in detail view
174
+
175
+ ## File Coordination
176
+
177
+ ```typescript
178
+ // Reserve files before editing
179
+ pi_messenger({ action: "reserve", paths: ["src/index.ts", "src/types.ts"], reason: "Working on core" });
180
+
181
+ // Release when done
182
+ pi_messenger({ action: "release" });
183
+ ```
184
+
185
+ ## Agent Communication
186
+
187
+ ```typescript
188
+ // Rename yourself
189
+ pi_messenger({ action: "rename", name: "MyAgentName" });
190
+
191
+ // Send message to specific agent
192
+ pi_messenger({ action: "send", to: "OtherAgent", message: "Hello!" });
193
+
194
+ // Broadcast to all
195
+ pi_messenger({ action: "broadcast", message: "Announcement" });
196
+ ```
197
+
198
+ Messages are logged to the feed and visible in the overlay. DMs interrupt only the target agent (delivered as steering); broadcasts interrupt all agents.
199
+
200
+ ## Typical Crew Session
201
+
202
+ ```typescript
203
+ // 1. Join
204
+ pi_messenger({ action: "join" });
205
+
206
+ // 2. Plan (spawns planner agent)
207
+ pi_messenger({ action: "plan" });
208
+
209
+ // 3. Check tasks
210
+ pi_messenger({ action: "task.list" });
211
+
212
+ // 4. Work
213
+ pi_messenger({ action: "work", autonomous: true });
214
+
215
+ // 5. Status
216
+ pi_messenger({ action: "status" });
217
+ ```
218
+
219
+ ## Data Storage
220
+
221
+ Crew stores data in `.zeta/messenger/crew/`:
222
+
223
+ ```
224
+ .zeta/messenger/crew/
225
+ ├── config.json # Project config (concurrency, models, coordination, etc.)
226
+ ├── plan.json # Plan metadata
227
+ ├── planning-progress.md # Planner output log (Notes section for steering)
228
+ ├── planning-outline.md # Latest plan outline
229
+ ├── planning-state.json # Current planning phase/pass
230
+ ├── agents/ # Optional: project-level crew agent overrides
231
+ │ └── crew-worker.md
232
+ ├── tasks/
233
+ │ ├── task-1.json # Task metadata (status, deps, summary)
234
+ │ ├── task-1.md # Task spec (planner-generated)
235
+ │ ├── task-1.progress.md # Worker progress log
236
+ │ └── ...
237
+ ├── blocks/
238
+ │ └── task-N.md # Block context
239
+ └── artifacts/ # Debug artifacts (agent input/output)
240
+ ```
241
+
242
+ Team stores active project state in `.zeta/messenger/team/`:
243
+
244
+ ```
245
+ .zeta/messenger/team/
246
+ ├── team.json # Active team/profile
247
+ ├── charter.md # Project team charter
248
+ ├── memory.jsonl # Structured memory source of truth
249
+ ├── decisions.md # Human-readable memory rollups
250
+ ├── interfaces.md
251
+ ├── risks.md
252
+ └── handoffs.md
253
+ ```
254
+
255
+ Reusable profiles are JSON files under `~/.zeta/agent/messenger/team-profiles/`.
256
+
257
+ The activity feed lives at `.zeta/messenger/feed.jsonl` (project-scoped, shared across all agents in the project).
258
+
259
+ Each crew agent ships with a default model:
260
+
261
+ | Agent | Role | Default Model |
262
+ | ---------------- | -------- | ---------------------------- |
263
+ | `crew-planner` | planner | `anthropic/claude-opus-4-6` |
264
+ | `crew-worker` | worker | `anthropic/claude-haiku-4-5` |
265
+ | `crew-reviewer` | reviewer | `anthropic/claude-opus-4-6` |
266
+ | `crew-plan-sync` | analyst | `anthropic/claude-haiku-4-5` |
267
+
268
+ Override via `crew.models.<role>` in config. To customize an agent for a project, copy it from the extension's `crew/agents/` directory (under `~/.zeta/plugins/node_modules/@linxiraos/pi-messenger/`) to `.zeta/messenger/crew/agents/` and edit the frontmatter — project-level agents override extension defaults by name, and load only when the project opts in (`"trustProjectAgents": true` in `.zeta/pi-messenger.json`). Agents support `thinking: <level>` in frontmatter (off, minimal, low, medium, high, xhigh). Config `thinking.<role>` overrides the frontmatter value.
269
+
270
+ ## Configuration
271
+
272
+ User-level config goes in `~/.zeta/agent/pi-messenger.json` under a `crew` key. Project-level config goes in `.zeta/messenger/crew/config.json`. Project overrides user, both override defaults.
273
+
274
+ Crew spawns multiple LLM sessions in parallel — start with a cheap worker model and scale up. Add this to `~/.zeta/agent/pi-messenger.json`:
275
+
276
+ ```json
277
+ { "crew": { "models": { "worker": "claude-haiku-4-5" } } }
278
+ ```
279
+
280
+ Model strings accept `provider/model` format for explicit provider selection and `:level` suffix for inline thinking control:
281
+
282
+ ```json
283
+ {
284
+ "crew": {
285
+ "models": { "worker": "anthropic/claude-haiku-4-5", "planner": "openrouter/anthropic/claude-sonnet-4:high" }
286
+ }
287
+ }
288
+ ```
289
+
290
+ The `:level` suffix and the `thinking.<role>` config are independent — if both are set, the suffix takes precedence.
291
+
292
+ Full example (`~/.zeta/agent/pi-messenger.json`):
293
+
294
+ ```json
295
+ {
296
+ "crew": {
297
+ "concurrency": { "workers": 3, "max": 6 },
298
+ "models": { "worker": "claude-haiku-4-5", "planner": "claude-sonnet-4-6" },
299
+ "coordination": "chatty",
300
+ "work": { "maxAttemptsPerTask": 5 }
301
+ }
302
+ }
303
+ ```
304
+
305
+ Project-level (`.zeta/messenger/crew/config.json`):
306
+
307
+ ```json
308
+ {
309
+ "concurrency": { "workers": 4 },
310
+ "coordination": "moderate",
311
+ "models": { "worker": "gpt-4.1" },
312
+ "planning": { "maxPasses": 1 },
313
+ "work": {
314
+ "maxWaves": 50,
315
+ "env": { "OPENAI_API_BASE": "https://custom.endpoint" }
316
+ }
317
+ }
318
+ ```
319
+
320
+ ### Key Settings
321
+
322
+ | Setting | Description | Default |
323
+ | ---------------------------- | ----------------------------------------------------------------------- | -------------------------------------------------- |
324
+ | `concurrency.workers` | Default parallel workers per wave | `2` |
325
+ | `concurrency.max` | Maximum workers allowed via `+` key (hard ceiling: 10) | `10` |
326
+ | `dependencies` | Dependency scheduling mode: `advisory` or `strict` | `"advisory"` |
327
+ | `coordination` | Worker communication level: `none`, `minimal`, `moderate`, `chatty` | `chatty` |
328
+ | `messageBudgets` | Max outgoing messages per worker per level (sends rejected after limit) | `{ none: 0, minimal: 2, moderate: 5, chatty: 10 }` |
329
+ | `models.worker` | Default model for workers | `anthropic/claude-haiku-4-5` |
330
+ | `models.planner` | Default model for planner | `anthropic/claude-opus-4-6` |
331
+ | `models.reviewer` | Default model for reviewer | `anthropic/claude-opus-4-6` |
332
+ | `models.analyst` | Default model for analyst (plan-sync) | `anthropic/claude-haiku-4-5` |
333
+ | `thinking.planner` | Thinking level for planner agent | (from frontmatter) |
334
+ | `thinking.worker` | Thinking level for worker agents | (from frontmatter) |
335
+ | `thinking.reviewer` | Thinking level for reviewer agents | (from frontmatter) |
336
+ | `thinking.analyst` | Thinking level for analyst agents | (from frontmatter) |
337
+ | `planning.maxPasses` | Max planner/reviewer refinement passes | `1` |
338
+ | `work.maxWaves` | Max autonomous waves | `50` |
339
+ | `work.maxAttemptsPerTask` | Max attempts before auto-blocking a task | `5` |
340
+ | `work.stopOnBlock` | Stop autonomous mode when any task blocks | `false` |
341
+ | `work.shutdownGracePeriodMs` | Grace period before SIGTERM on abort | `30000` |
342
+ | `work.env` | Environment variables passed to spawned workers | `{}` |
343
+
344
+ ### Coordination Levels
345
+
346
+ Controls how much workers communicate during execution:
347
+
348
+ - **`none`**: No coordination instructions. Workers just execute their task.
349
+ - **`minimal`**: Check reservations before editing files. Message if conflicts.
350
+ - **`moderate`**: Announce start/completion via broadcast. Check reservations. Ask about unclear dependencies.
351
+ - **`chatty`** (default): All of moderate, plus: DM peers whose tasks overlap, share progress on interface changes, respond to incoming messages, claim next task after completion.
352
+
353
+ At `moderate` and `chatty`, workers also receive recent activity context and concurrent task info in their prompts.
354
+
355
+ ### Model Override Priority
356
+
357
+ Worker model is resolved with this priority (highest wins):
358
+
359
+ 1. Per-task `model` field on the task object
360
+ 2. Per-wave `model` param on the work call
361
+ 3. Team role model when present
362
+ 4. Config-level `crew.models.worker`
363
+ 5. Host session model
364
+ 6. Agent `.md` frontmatter `model` field
365
+
366
+ ### Graceful Shutdown
367
+
368
+ When you cancel a work run (Ctrl+C), workers receive a shutdown sequence:
369
+
370
+ 1. Inbox message asking the worker to stop, release reservations, and exit
371
+ 2. Wait `shutdownGracePeriodMs` (default 30s) for clean exit
372
+ 3. SIGTERM if still running, wait 5s
373
+ 4. SIGKILL if still running
374
+
375
+ Tasks from gracefully shutdown workers reset to `todo` for retry on the next wave. Crashed workers (non-graceful exit) block the task in autonomous mode to prevent retry loops.