@ferris1225/pi-subagents 6.0.4 → 7.0.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 CHANGED
@@ -1,5 +1,70 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Breaking changes
6
+
7
+ - Make lead/worker orchestration the only workflow. Main judges difficulty,
8
+ delegates simple bounded work by default, splits complex tasks or handles
9
+ their difficult core, and always reviews the actual diff and evidence.
10
+ Remove sentinel and the role matrix.
11
+ - Replace legacy configuration on startup with versioned worker settings:
12
+ one model and thinking preference shared by artisan and scout. Delete the
13
+ old config without a backup and direct users to `/subagents-setup`; preserve
14
+ sessions, worktrees, results, and recovery records.
15
+ - Remove automatic main-model worker retries. Provider failures return evidence
16
+ to main. An unavailable configured worker blocks dispatch and keeps its setting
17
+ instead of silently consuming main-model quota.
18
+ - Reject unreadable settings and invalid worker model references at dispatch,
19
+ while keeping main available to explain the problem.
20
+ - Require Pi >= 1.5.2 and align development SDKs to 1.5.2.
21
+
22
+ ### Changes
23
+
24
+ - Simplify setup to Model, Thinking, and Reset with searchable pickers, compact
25
+ narrow-terminal hints, and Pi's blocked status while awaiting input.
26
+ - Keep live main/worker assignments separate from the stable prompt for caching.
27
+ Use compact briefs, preserved worker sessions, focused corrections, and reuse
28
+ of valid evidence to limit repeated work. Return invalid plans and repeated
29
+ failed fixes to main; worker completion explicitly requests main's review.
30
+ - Rewrite the README around the new workflow, breaking reset, budget tradeoffs,
31
+ prompt research, Pi APIs, controls, and recovery behavior.
32
+ - Prefer an exact configured provider reference over its alias regardless of
33
+ catalog order. Remove obsolete role migration and duplicate delivery logic.
34
+ - Bound test-file concurrency to four so native Windows shell probes do not
35
+ time out under process-heavy parallel suites; retain runtime concurrency tests.
36
+
37
+ ## 6.0.5
38
+
39
+ ### Fixes
40
+
41
+ - List every run a parallel launch started in its receipt instead of the first
42
+ two run ids.
43
+ - Inline completion answers up to 40 lines and 8,000 characters regardless of
44
+ line width; a single prose line over 200 characters no longer moves the whole
45
+ answer to its result file. Repeated deliveries of one result name one artifact.
46
+ - Give isolated children the original checkout and worktree paths so they map
47
+ paths from the brief into the worktree instead of editing the original.
48
+ - Include the model-failure takeover guidance in awaited results, and keep
49
+ per-model usage totals for stopped, crashed, and restored runs.
50
+ - Keep model overrides outside the session's model scope; session start removes
51
+ only overrides that no authenticated provider offers.
52
+ - Reject unknown `/subagents-cleanup` arguments without deleting anything.
53
+ - Show `starting` for every starting run, including a restart on the main model,
54
+ and advise waiting for a stopping run instead of stopping it again.
55
+ - Give session follow-ups a deterministic objective, so repeated identical
56
+ follow-ups follow the same duplicate rules as summary follow-ups.
57
+
58
+ ### Changes
59
+
60
+ - Restrict the `subagent` role parameter to `scout`, `artisan`, and `sentinel`.
61
+ - Tighten the delegation directive and role prompts: drop the routing line that
62
+ restated role descriptions, name codemode only when present, clarify how main
63
+ applies review findings, label leases by role, remove script-tool guidance
64
+ from scout, and separate sentinel findings from unverified concerns.
65
+ - Shorten the `subagent_message` description and remove code left from the
66
+ workflow runner and earlier setup screens.
67
+
3
68
  ## 6.0.4
4
69
 
5
70
  ### Changes
package/README.md CHANGED
@@ -1,284 +1,253 @@
1
1
  # pi-subagents
2
2
 
3
- Sub-agents for [Pi](https://github.com/earendil-works/pi): research, implementation,
4
- independent review, interactive follow-ups, and Git worktree isolation.
5
-
6
- ## Install
7
-
8
- Requires **Pi >= 1.5.0** and **Node.js >= 22.19.0**. Development and native
9
- integration tests use the Pi 1.5.0 SDK.
10
-
11
- ```bash
12
- pi install npm:@ferris1225/pi-subagents
3
+ Lead/worker orchestration for [Pi](https://github.com/earendil-works/pi).
4
+ Your capable main model judges difficulty, plans, handles complex work, reviews
5
+ the actual changes, and owns the final answer. Cheaper workers execute simple,
6
+ bounded tasks with their own context, model, tools, and retained sessions.
7
+
8
+ Requires **Pi >= 1.5.2** and **Node.js >= 22.19.0**. Development and native CLI
9
+ integration tests use the **Pi 1.5.2 SDK**.
10
+
11
+ ## Get started
12
+
13
+ 1. Install the extension:
14
+
15
+ ```bash
16
+ pi install npm:@ferris1225/pi-subagents
17
+ ```
18
+
19
+ 2. Choose a capable main model with Pi's model selector; it always owns review.
20
+ 3. Run `/subagents-setup` and select a capable, cost-effective worker model.
21
+ 4. Give main your task. Orchestration is the default and only workflow.
22
+
23
+ The setup panel has three rows: **Model**, **Thinking**, and **Reset**.
24
+ Use ↑/↓ and Enter; Esc returns without changing a picker selection. Changes save
25
+ immediately. The model picker supports search, paste, paging, and Tab for details.
26
+ The menu keeps the current main model visible. Long values can be paged with
27
+ PgUp/PgDn, and the panel adapts to narrow terminals.
28
+
29
+ Workers initially **follow main** with **medium** thinking. Choose a separate
30
+ worker model to use a cheaper model for execution. The extension does not guess
31
+ model quality or promise savings from token prices. A saved thinking preference
32
+ survives model changes and is clamped to the chosen model's supported levels.
33
+ Reset restores Follow main and medium thinking.
34
+
35
+ The goal is to reduce expensive main-model usage, budget, and quota consumption.
36
+ Total tokens can increase because briefs, separate contexts, and review also cost
37
+ tokens. Judge savings by total task cost and main-model usage, including retries
38
+ and rework. Compact handoffs, retained worker sessions, reuse of valid checks, and
39
+ delegating execution are the mechanisms; no savings benchmark is claimed here.
40
+
41
+ ## Upgrading to v7
42
+
43
+ **This is a breaking release.** On the first session start after upgrading, the
44
+ old `pi-subagents.json` is deleted and replaced with fresh worker settings.
45
+ Old per-role model/thinking values are discarded, with no legacy config backup.
46
+ Pi displays a notice directing you to `/subagents-setup`.
47
+
48
+ The old role matrix, optional delegation policy, independent reviewer, and
49
+ `sentinel` role are gone. Main performs review. Calls naming retired roles
50
+ are rejected.
51
+
52
+ Only the settings file is reset. Existing sessions, results, worktrees, and
53
+ recovery evidence remain protected. Retired-role records can still be inspected
54
+ or stopped; they do not create a supported reviewer role or resume automatically.
55
+
56
+ The new configuration is stored at `~/.pi/agent/pi-subagents.json`:
57
+
58
+ ```json
59
+ {
60
+ "version": 1,
61
+ "thinking": "medium"
62
+ }
13
63
  ```
14
64
 
15
- Run `/subagents-setup` to open a standalone centered modal panel rather than
16
- squeezing menus into the input editor dock. Wide panels place the role register
17
- and the focused role's settings side by side; narrow panels stack them. ↑/↓
18
- changes the role, ←/→ selects **Model**, **Thinking**, or **Reset**, and Enter
19
- edits it in a searchable modal picker. The selected role shows its full model
20
- reference, effective reasoning level, requested level when clamped, and
21
- default/override source. Each selection saves immediately; Esc returns without
22
- applying a picker selection and keeps focus. Model pickers support search,
23
- paste, and paging. On short terminals, PgUp/PgDn scrolls the settings while the
24
- selected role and field stay pinned.
25
-
26
- All roles follow the main model by default; thinking defaults to `low` for scout
27
- and `high` for artisan and sentinel. The panel distinguishes defaults from overrides and
28
- shows the effective level when model capabilities clamp a preference. Changing
29
- a model preserves the thinking preference. Settings live in
30
- `~/.pi/agent/pi-subagents.json` as `agentModels` and `agentThinkingLevels`.
31
-
32
- ## Agents
33
-
34
- | Agent | Use for | Access |
65
+ Selecting a worker adds `model: "provider/model-id"`. This is one shared worker
66
+ setting, not a map of roles. `PI_CODING_AGENT_DIR` overrides the agent directory.
67
+ An unavailable or out-of-scope worker stays configured and blocks dispatch until
68
+ availability is restored or you select another model. Provider failures return
69
+ to main with evidence; the extension never starts a main-model worker as a retry.
70
+ Unreadable settings or an invalid model reference also stop new dispatches instead
71
+ of silently selecting main. Repair the file or run `/subagents-setup`.
72
+
73
+ ## How orchestration works
74
+
75
+ 1. **Main judges difficulty and plans.** It investigates the decisions that
76
+ determine the approach, resolves ambiguity, and defines acceptance criteria
77
+ and write boundaries. It splits complex tasks into simple worker briefs and
78
+ keeps the difficult core when delegation would create more rework.
79
+ 2. **Workers execute.** Main sends a self-contained brief. Each worker owns a
80
+ bounded task and its checks, returning a compact result with changed paths,
81
+ verification evidence, and blockers.
82
+ 3. **Main reviews.** After worktree integration, main checks the actual diff,
83
+ relevant callers, acceptance criteria, and test evidence. Worker completion
84
+ is explicitly marked as a review handoff, not approval.
85
+ 4. **Main corrects or accepts.** Focused corrections go back to the owning worker
86
+ through its retained session. Main repairs an invalid plan or takes over when
87
+ assumptions fail. It owns final validation, release, and the user-facing answer.
88
+
89
+ Simple edits, fixes, tests, docs, and bounded research go to cheaper workers by
90
+ default. Main decides what is simple enough for the configured worker; there is
91
+ no keyword classifier or automatic model ranking. Complex or uncertain work can
92
+ stay in main. Review and final acceptance always stay in main, never in a cheap
93
+ reviewer. Main avoids repeating completed worker effort. Questions and review-only requests do not authorize
94
+ implementation. Explicit requests to work in main take precedence. Parallel workers require independent
95
+ scope and disjoint write ownership; a fix and its regression tests share an owner.
96
+
97
+ There are two worker tool scopes, both using the same model/thinking settings:
98
+
99
+ | Scope | Tool parameter | Access |
35
100
  | --- | --- | --- |
36
- | `scout` | Code, documentation, and web research with citations | Read-only tools; no commands or edits |
37
- | `artisan` | Implementation and fixes with tests and checks | Parent's tool surface, including codemode |
38
- | `sentinel` | Inspect an implementation or diff and challenge claims or assumptions for defects and regressions | Parent's tool surface; instructed not to edit |
39
-
40
- The main model chooses from these role descriptions; names alone do not route a
41
- task. Use `sentinel` to inspect implementations/diffs or challenge a specific claim
42
- or assumption with counterexamples and focused checks.
43
-
44
- Sentinel may run focused checks, so its no-edit boundary is an instruction, not
45
- a tool-enforced restriction. Change reviews focus on introduced defects; a wider
46
- audit needs an explicit brief. All roles reuse existing facts and valid checks,
47
- filling gaps rather than repeating main or upstream work.
48
-
49
- Only `scout`, `artisan`, and `sentinel` are valid runtime role names.
50
- Existing model/thinking settings and interrupted run records migrate on load
51
- (`reviewer`, `critic`, and `skeptic` map to `sentinel`) and are saved with the
52
- current names. Explicit valid settings under the current names win. Custom roles
53
- are not supported. Retained records from older releases remain available for recovery.
54
-
55
- Children receive a self-contained brief and project instructions, but no parent
56
- conversation. They cannot delegate or release. Main owns planning, integration,
57
- and the final result. Keep a fix and its regression tests with one owner.
58
-
59
- ## Delegate
60
-
61
- Pi proactively looks for useful bounded phases to delegate; no special request
62
- is required. Focused ownership, isolated context, parallel progress, and an
63
- independent check can each justify a child. A substantial self-contained fix can
64
- go to one artisan together with its regression tests, even when there is nothing
65
- to parallelize. Quick source checks and small understood edits stay in main.
66
- Choose team size from independent work. Explicit requests to work in main or
67
- avoid subagents take precedence.
68
-
69
- Use one owner per deliverable, including its regression tests. Brief the child
70
- with the outcome, done condition, relevant paths, established evidence, write
71
- boundaries, required checks, and a compact expected result. Scout retrieves
72
- sources; artisan implements, while sentinel can execute focused checks. This policy applies the context-isolation,
73
- focused-role, and coordination-cost guidance in the official
74
- [Codex subagents](https://developers.openai.com/codex/subagents) and
75
- [Claude Code subagents](https://code.claude.com/docs/en/sub-agents) docs to Pi's
76
- one-shot leaf runs.
77
-
78
- A review request produces findings. Main applies fixes when changes are
79
- authorized and requests focused confirmation only when material uncertainty
80
- remains. Before reporting success, main checks each done condition and any
81
- blockers in the child's answer as well as the integrated diff.
82
-
83
- Ask Pi to delegate explicitly, or call the tool directly:
101
+ | Implementation | `artisan` | Parent's live tools, including codemode; implements and checks the plan |
102
+ | Read-only research | `scout` | Proven read-only lookups; no commands, builds, tests, or edits |
84
103
 
85
- ```ts
86
- subagent({
87
- agent: "artisan",
88
- task: "Fix cache invalidation in src/cache, add regression tests, and run the checks.",
89
- });
90
- ```
104
+ The read-only scope preserves a tool boundary for research. It is not a separate
105
+ reviewer. Children cannot delegate or release. Main and workers exchange briefs,
106
+ results, and feedback, rather than copying the parent's full conversation.
91
107
 
92
- Independent tasks can run together:
108
+ Planning, review, and the instruction to return after two unsuccessful fixes
109
+ are model instructions, not a runtime verdict engine or a hard retry counter.
110
+ Cancellation, role admission, tool boundaries, and worktree lifecycle are enforced
111
+ by the extension. No automatic review score certifies a worker's result.
112
+
113
+ ## Briefs and calls
114
+
115
+ A useful brief names the **outcome**, **acceptance criteria**, **relevant paths and
116
+ evidence**, **write boundary**, **checks**, **return conditions**, and **expected
117
+ result**. Pass established facts forward and assign only missing work.
93
118
 
94
119
  ```ts
95
120
  subagent({
96
- tasks: [
97
- {
98
- agent: "artisan",
99
- task: "Fix config validation and its regression tests.",
100
- },
101
- {
102
- agent: "artisan",
103
- task: "Update docs/providers.md from the established API citations.",
104
- },
105
- ],
121
+ agent: "artisan",
122
+ task: [
123
+ "Fix cache invalidation in src/cache.ts and its regression test.",
124
+ "Acceptance: a write invalidates the matching key without clearing unrelated keys.",
125
+ "Evidence: the stale read starts in Cache.get; keep the current public API.",
126
+ "Write only src/cache.ts and test/cache.test.ts.",
127
+ "Run the cache tests. Return to main if the storage interface contradicts this plan.",
128
+ "Report the outcome, changed paths, command/results, and blockers for main's review.",
129
+ ].join("\n"),
130
+ wait: true,
106
131
  });
107
132
  ```
108
133
 
109
- Use `wait: true` when the next step needs the result. `subagent` and completed-run
110
- `subagent_message` follow-ups default to waiting in one-shot `pi -p` / JSON sessions,
111
- so the parent stays alive until the work finishes. TUI and RPC sessions default
112
- to background delivery; `wait: false` explicitly selects it in any mode. Each
113
- result is delivered once, after integration, either in the waiting tool call or
114
- as a background completion. Awaited failures are tool errors with retained evidence.
115
-
116
- A launch receipt only confirms delegation. Main continues independent work or
117
- pauses until the completion wakes it, then finishes the requested outcome and
118
- final checks. It does not poll or treat a successful launch as task completion.
119
- Equal normalized tasks in the same cwd are rejected as duplicates while active
120
- or settled in the current session. Reuse the result, or use `subagent_message`
121
- for an additional bounded step.
134
+ Independent tasks use `tasks: [{ agent, task }, ...]`. Each task can also specify
135
+ `cwd` and `isolation`. Duplicate normalized tasks in the same cwd are rejected
136
+ while active or settled; reuse the result or continue the existing work.
122
137
 
123
- ## Status, cancellation, and recovery
138
+ Use `wait: true` for an immediate dependency. Print/JSON sessions wait by
139
+ default; TUI/RPC sessions return background receipts. A launch receipt is not
140
+ completion. Main continues independent work, then pauses until results arrive.
141
+ Results are delivered once, after integration. Awaited failures are tool errors.
142
+ Answers exceeding 40 lines or 8,000 characters link their full-result artifact.
124
143
 
125
- | Tool | Use |
144
+ | Tool | Purpose |
126
145
  | --- | --- |
127
- | `subagent_status({ id: 12 })` | Inspect a run's progress, result, and recovery paths |
128
- | `subagent_message({ id: 12, message: "Check the caller too" })` | Steer a running child, or continue a completed run using its session when available and a summary otherwise |
129
- | `subagent_message({ id: 12, message: "Add the test", context: "summary" })` | Start a new next step with only a bounded summary of the earlier run |
146
+ | `subagent_status({ id: 12 })` | Inspect progress, result, session availability, and recovery paths |
147
+ | `subagent_message({ id: 12, message: "Fix the remaining edge case", wait: true })` | Steer an active worker or continue completed work |
148
+ | `subagent_message({ id: 12, message: "Next bounded task", context: "summary" })` | Start from a compact summary instead of the earlier transcript |
130
149
  | `subagent_stop({ id: "12" })` | Stop a run and retire its retained session |
131
- | `subagent_stop({ all: true })` | Stop all active runs in this session |
132
-
133
- The widget is a terminal task board capped at 10 lines: a quiet overview, then
134
- task rows with status/time at the right. Failures get space before optional
135
- telemetry; narrow terminals keep task identity visible. Model, thinking, token
136
- usage, and worktree state appear as secondary detail. Failed work stays until
137
- the next dispatch. Completion messages and status lookups retain the results.
138
- Overflow reports hidden tasks. Runs preparing their child process show `starting`.
139
- The refresh timer runs only while visible active work needs it. There is no
140
- process-count limit or shared-checkout startup lock: independent runs start
141
- together, including separate dispatch calls while another call awaits results.
142
-
143
- Usually omit `isolation`: implementation tasks use detached Git worktrees in
144
- single calls and parallel batches. Reading and review use the current directory.
145
- Without a Git repository or committed `HEAD`, automatic isolation uses the
146
- caller's directory and reports why. Unexpected setup or integration failures
147
- remain failures; an explicit `isolation: "worktree"` requires isolation and never
148
- falls back. `isolation: "shared"` is an advanced override for tasks that need to
149
- write directly in the caller's checkout.
150
-
151
- Each worktree starts from the caller's current tracked files and non-ignored
152
- untracked files, including uncommitted changes. Its initial snapshot is also the
153
- integration base, so dependent tasks see earlier results without reapplying them.
154
- The caller's index, branch, and `HEAD` stay unchanged. Worktrees isolate Git
155
- changes, not tool permissions. Independent tasks start together; only the final
156
- application of worktree changes to the original checkout is serialized.
157
- Integration leaves your index untouched, and failures retain recovery artifacts.
158
-
159
- Cancelling the parent run with Escape stops unfinished work without waking the
160
- parent. A cancellation receipt is supplied on the next user turn with the stopped
161
- run ids, so main knows no additional `subagent_stop` is needed. Cancelled work
162
- must not restart automatically. Conversation-tree navigation also stops
163
- unfinished work. New/resume/fork/reload ends old children and retains interrupted
164
- work for manual recovery. Runs do not resume automatically; main finishes
165
- incomplete work from partial changes and artifacts.
166
-
167
- A steering call waits for the child's existing RPC channel to acknowledge the
168
- matching request ID. The tool card shows **Received · queued** when Pi confirms
169
- queueing, **Received · handled** when an input hook consumes the message, or
170
- **Accepted · queue state unconfirmed** when no disposition is available.
171
- `subagent_status` retains the latest acknowledgement, request ID, age, and message
172
- summary. Rejection or a missing acknowledgement is an error, not a receipt.
173
- Queueing delivers at a Pi steering boundary; it does not prove that the model
174
- has executed the instruction.
175
-
176
- To continue a successfully completed run, choose the context that fits the follow-up:
177
-
178
- - `context: "auto"` (default) continues a private copy of the retained session
179
- when available. If cleanup has removed it, the follow-up starts with a bounded
180
- summary and explicitly reports that full history is unavailable. No retry is
181
- needed for an expired session.
182
- - `context: "session"` requires full history for rework that depends on earlier
183
- details. If the session is unavailable, the call fails without starting a run.
184
- - `context: "summary"` always starts fresh for a new next step, with the earlier
185
- objective, final result and touched files. It cannot rely on omitted details
186
- or reuse the earlier provider cache.
187
-
188
- Session continuations retain the earlier history and provider prompt-cache key
189
- (`sessionId`). Their private copy is bound to the new run's working directory,
190
- including when a previous temporary worktree has already been removed. Child
191
- startup and the copied session header use the same physical directory, so macOS
192
- path aliases and Windows junctions do not trigger a cross-project fork prompt.
193
- The continuation is instructed to re-read files before editing in the current cwd.
194
-
195
- Every follow-up preserves the role and workspace and passes through normal
196
- admission and isolation. Set `wait: true` to receive its final result in the same
197
- call; this waiting option applies to newly started follow-ups, while steering a
198
- running child returns its acknowledgement. `subagent_status` reports whether a
199
- completed run has a session available or only summary context. Results and summaries remain
200
- available within the current parent runtime; completed runs are not restored
201
- after reload. Pending runs cannot be steered.
202
-
203
- Children use Pi's native `--mode rpc` CLI with piped input/output, retries, and
204
- session persistence. On Windows, console hiding covers the Pi child and Node
205
- process launches made by its tools and extensions, including `pi.exec`, `pwsh`,
206
- and `powershell`. The child preloads this policy before Pi starts and passes it
207
- to Node descendants through `NODE_OPTIONS`, preserving existing options. An
208
- explicit child extension installs the same policy for runtimes without Node
209
- preloading. Windows launches stay attached so detachment cannot open a console.
210
- On macOS and Linux, the policy leaves shell options unchanged; the Pi child uses
211
- a separate process group for cancellation and does not launch a terminal app.
212
- RPC communication and process-tree cancellation remain active. Child startup
213
- errors are reported as failed runs. If Windows cannot launch `taskkill`,
214
- termination falls back to killing the child directly. Commands that explicitly
215
- open a terminal or GUI control their own windows.
216
- A settled provider failure can hand off once to the main model in the same
217
- session. State and full-result files live under
218
- `~/.pi/agent/ferris-pi-subagents/`, grouped by project. `PI_CODING_AGENT_DIR`
219
- overrides the agent directory.
220
-
221
- ## Pi codemode compatibility
222
-
223
- Call `subagent` and the control tools directly. They use Pi's `model-only`
224
- exposure and are intentionally unavailable as nested `tools.subagent(...)` calls
225
- inside codemode. Children can still use codemode with their inherited callable
226
- tools. Indirect tools retain their exposure; scout promotes approved read-only
227
- tools for direct use. It waits up to ten seconds for startup registration and
228
- activates later arrivals between turns. Read-only classification uses Pi tool
229
- metadata.
230
-
231
- Child RPC dialogs that require confirmation, selection, or text input are
232
- cancelled with a matching response and an explanation, so an unattended child
233
- does not hang waiting for an invisible dialog. No confirmation is approved
234
- automatically.
235
-
236
- ## Storage and cleanup
237
-
238
- Each project root holds `sessions/`, `worktrees/`, `tmp/` and `results/`. Startup
239
- hygiene already drops temp leftovers, artifacts whose Pi process is gone, result
240
- files past their retention window, and project roots idle for three days. Parked
241
- recovery work and manifest references are protected during these sweeps.
242
- Interrupted checkpoints expire after 30 days when no recorded owner or child
243
- from the current boot is alive; expired checkpoints are pruned before restore.
244
- Missing session files do not erase validated recovery paths. Unreadable or
245
- malformed manifests leave artifacts intact and skip automatic reclamation;
246
- explicit cleanup reports the error. Startup warns about failed recovery inspection
247
- and continues initializing the progress widget.
248
-
249
- Reclamation is automatic: a settlement may trigger one paced sweep (at most every
250
- five minutes) that drops dead-owner artifacts, expired result files, and settled
251
- session copies older than 30 minutes, then trims the oldest settled sessions
252
- until a project fits its 1.5 GB budget. Under budget pressure, settled sessions
253
- older than five minutes can be removed. Live runs, parked recovery work, and
254
- manifest references remain protected. Automatic follow-ups use the retained
255
- summary when a completed run's transcript has expired. Session shutdown waits
256
- for cleanup already in progress and prevents new settlement sweeps.
257
-
258
- `/subagents-cleanup` immediately reclaims unclaimed dead-owner artifacts and idle
259
- project roots, reporting usage and freed bytes. `/subagents-cleanup dry-run`
260
- measures without deleting anything. Session age and budget reclamation runs
261
- automatically on settlement.
150
+ | `subagent_stop({ all: true })` | Stop all active work in this session |
151
+
152
+ Follow-ups use `context: "auto"` by default: a private copy of the retained session,
153
+ or an explicit summary fallback when it expired. `context: "session"` requires full
154
+ history. Continuations retain the session ID/cache key and re-read files in their
155
+ current workspace. Summary continuations cannot rely on omitted history.
156
+
157
+ Steering waits for a matching RPC acknowledgement. Received/queued means Pi queued
158
+ the instruction, not that the model acted on it. A rejected or missing
159
+ acknowledgement is an error. Failed or interrupted runs require main to inspect
160
+ partial work; they do not restart automatically.
161
+
162
+ ## Isolation and control
163
+
164
+ Implementation uses a detached Git worktree by default, even for one worker.
165
+ Read-only research uses the caller's directory. Without a Git repository or
166
+ committed HEAD, automatic isolation reports a shared-directory fallback.
167
+ Explicit `isolation: "worktree"` requires isolation; `"shared"` writes directly
168
+ in the caller's checkout.
169
+
170
+ Each worktree snapshots current tracked and non-ignored untracked files,
171
+ including uncommitted work. The child is told how original paths map into its
172
+ worktree. Integration applies only its delta, is serialized per repository,
173
+ and preserves the caller's index, branch, and HEAD. Failures retain recovery
174
+ artifacts. Worktrees isolate Git changes, not permissions.
175
+
176
+ Escape cancels unfinished workers without waking main. Main receives a cancellation
177
+ receipt on the next user turn. Tree navigation, new/resume/fork/reload, and shutdown
178
+ stop old work; interrupted evidence remains available for recovery.
179
+
180
+ The task widget shows status, elapsed time, model, thinking, tokens, and worktree
181
+ state in at most ten lines. Independent workers can start together; only
182
+ integration into the original checkout is serialized.
183
+
184
+ ## Pi integration
185
+
186
+ Workers run the native Pi CLI in RPC mode with piped I/O and retained sessions.
187
+ Delegation/control tools are model-only: call them directly, outside codemode.
188
+ Workers inherit reachable tools without activating unrelated direct tools; scout
189
+ gets only tools whose metadata proves them read-only.
190
+
191
+ Unattended confirmation/input dialogs are cancelled, never auto-approved. Windows
192
+ child processes and their Node descendants use the existing hidden-console
193
+ policy; process-tree cancellation remains active on every supported platform.
194
+ A provider failure returns control and evidence to main without an automatic
195
+ upgrade to main's model. Pi's own same-model retry behavior remains unchanged.
196
+
197
+ [Pi 1.5.2](https://github.com/earendil-works/pi/blob/v1.5.2/packages/coding-agent/CHANGELOG.md)
198
+ fixes sessions whose original directory disappeared. Private continuation
199
+ copies still rebind their cwd while retaining their session ID. Pi 1.5.1 added
200
+ message threads, idle cache warming, and classifier access through
201
+ `ctx.modelRegistry.classify()`. This extension keeps Pi's provider behavior and
202
+ cache settings; exited workers do not keep warming caches between runs.
203
+ Classifier routing is not used: main makes the plan after investigation.
204
+ The settings modal uses Pi's `blocked` status while awaiting input.
205
+
206
+ ## Storage
207
+
208
+ Durable data lives under `~/.pi/agent/ferris-pi-subagents/`, grouped by project:
209
+ sessions, worktrees, temporary state, and result artifacts.
210
+
211
+ Startup and paced settlement cleanup reclaim dead-owner artifacts, expired results,
212
+ and old settled sessions. Settled session retention is normally 30 minutes with
213
+ a 1.5 GB project budget; budget pressure can remove sessions older than five
214
+ minutes. Interrupted records expire after 30 days when their recorded processes
215
+ are no longer alive. Live work, parked recovery, and referenced artifacts are
216
+ protected. Unreadable manifests prevent reclamation.
217
+
218
+ `/subagents-cleanup dry-run` reports usage; `/subagents-cleanup` reclaims eligible
219
+ artifacts. Unknown arguments are rejected. Shutdown drains cleanup already running.
220
+
221
+ ## Design references
222
+
223
+ The prompt policy draws on these official descriptions:
224
+
225
+ - [Devin Fusion](https://cognition.com/blog/local-fusion): separate lead/worker
226
+ contexts, compact briefs and feedback, and lead-owned review.
227
+ - [Antigravity Orchestrator](https://antigravity.google/docs/models#orchestrator):
228
+ planning, execution, and returning control when the plan needs repair.
229
+ - [Anthropic's multi-agent engineering](https://www.anthropic.com/research/multi-agent-research-system):
230
+ explicit objectives, output formats, sources, boundaries, and effort proportional to the task.
231
+ - [Context engineering](https://www.anthropic.com/research/effective-context-engineering-for-ai-agents):
232
+ focused instructions and small, relevant context.
233
+
234
+ These inform this extension's design; benchmark savings from other products do
235
+ not establish savings here. Local tests verify routing, delivery, isolation, and
236
+ UI behavior, not comparative model quality or cost.
262
237
 
263
238
  ## Development
264
239
 
265
- Runtime code lives under `src/`; the package has no skill or workflow resource
266
- directories. Built-in prompts change with the code and its tests.
267
-
268
- | Module | Responsibility |
269
- | --- | --- |
270
- | `delegation/` | Built-in roles, parent routing prompt, and duplicate-dispatch admission |
271
- | `configuration/` | Model and thinking settings, plus the standalone setup modal panel |
272
- | `presentation/` | Running task board, activity, status, and result formatting |
273
- | `execution/`, `lifecycle/`, `isolation/` | Child processes, durable state, cancellation, worktrees, and recovery |
274
-
275
240
  ```bash
276
241
  npm ci
277
242
  npm run check
278
243
  ```
279
244
 
280
- Pushing an unpublished package version to `main` runs the checks on Windows,
281
- macOS, and Linux before triggering
282
- [publishing and a GitHub Release](./.github/workflows/publish.yml).
245
+ Runtime modules live in `src/`: configuration/UI, orchestration prompts,
246
+ execution, lifecycle, isolation/recovery, and presentation. Native integration tests
247
+ use a local fixture provider and do not consume paid model requests.
248
+
249
+ Pushes of an unpublished version to `main` run checks on Windows, macOS, and
250
+ Linux, then [publish to npm and create a GitHub Release](./.github/workflows/publish.yml).
251
+ Do not publish locally.
283
252
 
284
253
  [Changelog](./CHANGELOG.md) · [MIT license](./LICENSE)