@ferris1225/pi-subagents 6.0.5 → 7.0.1

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