@ferris1225/pi-subagents 5.0.6 → 6.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +187 -97
  3. package/index.ts +1 -1
  4. package/package.json +4 -9
  5. package/src/configuration/role-migration.ts +2 -2
  6. package/src/configuration/setup.ts +4 -2
  7. package/src/configuration/ui.ts +144 -132
  8. package/src/delegation/agents.ts +15 -22
  9. package/src/delegation/dispatch.ts +17 -122
  10. package/src/delegation/prompt.ts +13 -12
  11. package/src/execution/cli-run.ts +112 -39
  12. package/src/execution/process-tree.ts +12 -8
  13. package/src/execution/run-control.ts +11 -3
  14. package/src/execution/spawn.ts +24 -7
  15. package/src/isolation/cleanup.ts +31 -12
  16. package/src/isolation/managed-paths.ts +6 -4
  17. package/src/isolation/manifest-mutation.ts +89 -0
  18. package/src/isolation/recovery.ts +33 -29
  19. package/src/isolation/temp-hygiene.ts +1 -1
  20. package/src/lifecycle/await-results.ts +114 -0
  21. package/src/lifecycle/dispatch-core.ts +7 -1
  22. package/src/lifecycle/durable.ts +83 -39
  23. package/src/lifecycle/runtime.ts +12 -4
  24. package/src/lifecycle/stop.ts +2 -2
  25. package/src/lifecycle/thread-lifecycle.ts +10 -5
  26. package/src/lifecycle/thread-restore.ts +26 -25
  27. package/src/lifecycle/thread-shared.ts +15 -3
  28. package/src/lifecycle/tools.ts +90 -33
  29. package/src/presentation/announcements.ts +8 -2
  30. package/src/presentation/monitor.ts +5 -3
  31. package/src/presentation/widget.ts +157 -113
  32. package/src/workflow/acceptance.ts +67 -0
  33. package/src/workflow/durable.ts +34 -14
  34. package/src/workflow/engine.ts +161 -51
  35. package/src/workflow/plan.ts +25 -4
  36. package/src/workflow/state.ts +6 -0
  37. package/src/workflow/templates.ts +156 -0
  38. package/src/workflow/tool.ts +65 -109
  39. package/skills/workflow/SKILL.md +0 -268
  40. package/src/workflow/files.ts +0 -236
  41. package/workflows/code-review.md +0 -38
  42. package/workflows/migration.md +0 -42
  43. package/workflows/research.md +0 -48
package/CHANGELOG.md CHANGED
@@ -1,5 +1,94 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.1
4
+
5
+ ### Fixes
6
+
7
+ - Resolve the child working directory before launching or updating its private
8
+ session header, preserving fallback and follow-ups through macOS path aliases
9
+ and Windows junctions without a cross-project fork prompt.
10
+ - Require Pi SDK 1.4.0 and preserve callable codemode/deferred tools in child
11
+ sessions, including approved read-only tools that register after startup.
12
+ Keep delegation controls model-only and invoke them outside codemode.
13
+ - Add workflow and completed-run follow-up waiting; default all dispatches to
14
+ waiting in one-shot print/JSON sessions. Return final evidence exactly once
15
+ after integration and acceptance, mark awaited failures as tool errors, and
16
+ cancel unfinished work without background wake-ups.
17
+ - Display child RPC steering acknowledgements in the tool card and status,
18
+ including request ID and queued/handled/unknown queue disposition. Distinguish
19
+ receipt from model execution instead of showing only a generic success mark.
20
+ - Cancel unattended RPC input dialogs with an explicit response, preventing
21
+ invisible confirmation or input requests from hanging child execution.
22
+ - Clarify that launch receipts are not task completion and that main resumes
23
+ from child evidence to finish fixes and final checks. Correct interrupted-run
24
+ retirement examples, equal-task ownership guidance, and completed-run
25
+ follow-up recommendations. Reuse the completion waiter across dispatch paths.
26
+ - Deliver unexpected workflow failures through the same final-summary route.
27
+ - Retry brief Windows permission/sharing errors during atomic manifest
28
+ replacement under the existing writer lock, preserving the last checkpoint
29
+ and propagating persistent errors without an unlink/copy fallback.
30
+
31
+ - Contain synchronous Windows process-termination errors and child spawn
32
+ failures with missing stdio, preventing resource errors such as `ENOMEM`,
33
+ `EMFILE`, and `ENFILE` from escaping into the parent Pi process.
34
+ - Default completed-run follow-ups to `context: "auto"`: reuse retained history
35
+ when available, otherwise dispatch with a bounded summary and report the
36
+ fallback. Keep explicit `session` strict, expose available follow-up context
37
+ in status, and give interrupted runs actionable recovery guidance.
38
+ - Bind private session copies to the next run's cwd so follow-ups survive
39
+ removal of an earlier worktree. Preserve the session ID and prior entries,
40
+ and remind continued agents to re-read changed files.
41
+ - Preserve recovery artifacts when manifests or path validation cannot be read.
42
+ Protect live owners during empty-session, age, budget and project cleanup.
43
+ Prune expired checkpoints before restore, keep checkpoints with live owners
44
+ or children, and retain validated paths when a session file is unavailable.
45
+ Recovery inspection errors warn without skipping progress-widget setup.
46
+ - Recheck cancellation and source state before follow-up dispatch, and handle
47
+ a retained transcript disappearing during copying without duplicate launches.
48
+ - Drain settlement-triggered cleanup during shutdown and stop launching new
49
+ sweeps once shutdown begins, avoiding filesystem activity after teardown.
50
+ - Correct the documented five-minute minimum retention under budget pressure
51
+ and distinguish automatic reclamation from explicit storage cleanup.
52
+
53
+ ## 6.0.0
54
+
55
+ ### Breaking changes
56
+
57
+ - Support only the built-in `code-review`, `research`, and `migration` workflows
58
+ through `workflow` plus `inputs`. Remove inline graphs, custom names, workflow
59
+ files, and user/project workflow discovery. Keep old interrupted records
60
+ readable for recovery.
61
+ - Embed routing guidance and workflow templates in the extension. Remove the
62
+ separately loaded workflow skill and root workflow resource directory.
63
+
64
+ ### Changes
65
+
66
+ - Append one mandatory independent sentinel acceptance officer to every
67
+ workflow. Review all settled work and integration evidence, including failed
68
+ branches; require an explicit terminal PASS, and reject missing, ambiguous,
69
+ malformed, or FAIL verdicts. Cancellation skips acceptance.
70
+ - Replace ambiguous graph-source selection with direct built-in input errors.
71
+ Give different template inputs distinct phase identities while retaining
72
+ duplicate ownership for the same deliverable. Preserve brace syntax in task
73
+ inputs as literal text instead of interpreting it as graph dependencies.
74
+ - Redesign the terminal board around work progress, blocking reasons, and a
75
+ separate required-acceptance row. Keep failures visible within the 10-line
76
+ budget, preserve narrow-screen identity, and correct hidden-task counts.
77
+ - Redesign setup as a role selector with focused model/thinking details, using
78
+ side-by-side or stacked layouts. Preserve search, paging, focus, and default
79
+ versus override information. Budget setup height with the host's widget and
80
+ footer so required acceptance remains visible in a 24-row terminal.
81
+ - Preserve managed recovery references when the original checkout is temporarily
82
+ unavailable. Use stable durable identities and cross-process manifest locks
83
+ so separate windows cannot overwrite or delete each other's recovery records.
84
+ Match recovered workflow children by durable identity after local renumbering,
85
+ keep project keys stable through unavailable checkouts with aliased parent paths,
86
+ and exclude lock directories from project scans.
87
+ - Preserve concurrent recovery additions during announcements and keep newly
88
+ settled long-running sessions inside their follow-up retention window.
89
+ - Remove duplicate manifest scans and model-catalog lookups. Stop idle widget
90
+ refreshes and fix zero-width summaries and ANSI-contaminated task labels.
91
+
3
92
  ## 5.0.6
4
93
 
5
94
  ### Changes
package/README.md CHANGED
@@ -5,19 +5,22 @@ dependency workflows, and Git worktree isolation.
5
5
 
6
6
  ## Install
7
7
 
8
- Requires **Pi >= 1.0.0** and **Node.js >= 22.19.0**.
8
+ Requires **Pi >= 1.4.0** and **Node.js >= 22.19.0**. Development and native
9
+ integration tests use the Pi 1.4.0 SDK.
9
10
 
10
11
  ```bash
11
12
  pi install npm:@ferris1225/pi-subagents
12
13
  ```
13
14
 
14
- Run `/subagents-setup` for a role grid: one row per role with **Model**,
15
- **Thinking**, and **Reset** as columns. ↑/↓ moves between roles, ←/→ between
16
- columns, and Enter edits the highlighted value. Headers align with their values,
17
- and the footer names the focused role and field; **Thinking** selects reasoning
18
- effort. Each selection saves immediately;
19
- Esc returns without applying a picker selection, and the grid keeps the focused
20
- cell. Model pickers support search, paste, and paging.
15
+ Run `/subagents-setup` for a role selector and focused settings editor. Wide
16
+ terminals place them side by side; narrow terminals stack them. ↑/↓ changes the
17
+ role, ←/→ selects **Model**, **Thinking**, or **Reset**, and Enter edits it.
18
+ The selected role shows its full model reference, effective reasoning level,
19
+ requested level when clamped, and default/override source. Each selection saves
20
+ immediately; Esc returns without applying a picker selection and keeps focus.
21
+ Model pickers support search, paste, and paging. On short terminals, PgUp/PgDn
22
+ scrolls the settings while the selected role and field stay pinned. Setup
23
+ reserves space for the workflow's required-acceptance row.
21
24
 
22
25
  All roles follow the main model by default; thinking defaults to `low` for scout
23
26
  and `high` for artisan, sentinel, and skeptic. The panel distinguishes defaults from overrides and
@@ -48,9 +51,8 @@ and valid checks, filling gaps rather than repeating main or upstream work.
48
51
  Only `scout`, `artisan`, `sentinel`, and `skeptic` are valid runtime role names.
49
52
  Existing model/thinking settings and interrupted run records migrate on load
50
53
  and are saved with the new names. Explicit valid settings under the new names
51
- win. A selected trusted saved workflow is migrated on disk before compilation;
52
- its briefs, node ids, and dependency edges are preserved. Discovery remains
53
- read-only. New tool calls and inline graphs using retired names are rejected.
54
+ win. Custom roles and user-defined workflows are not supported. Retained records
55
+ from older releases remain available for recovery.
54
56
 
55
57
  Children receive a self-contained brief and project instructions, but no parent
56
58
  conversation. They cannot delegate or release. Main owns planning, integration,
@@ -112,10 +114,21 @@ subagent({
112
114
  });
113
115
  ```
114
116
 
115
- Results arrive automatically. Set `wait: true` to return them in the tool call,
116
- including in one-shot `pi -p` sessions. Use stable `phaseId` values: completed
117
- phases stay owned for the parent session, and interrupted phases retain ownership
118
- across reloads. Repeating the same task in the same cwd is also rejected.
117
+ Use `wait: true` when the next step needs the result. `subagent`,
118
+ `subagent_workflow`, and completed-run `subagent_message` follow-ups default to
119
+ waiting in one-shot `pi -p` / JSON sessions, so the parent stays alive until the
120
+ work finishes. TUI and RPC sessions default to background delivery; `wait: false`
121
+ explicitly selects it in any mode. Each result is delivered once, after
122
+ integration, either in the waiting tool call or as a background completion.
123
+ Awaited failures are tool errors with retained evidence.
124
+
125
+ A launch receipt only confirms delegation. Main continues independent work or
126
+ pauses until the completion wakes it, then finishes the requested outcome and
127
+ final checks. It does not poll or treat a successful launch as task completion.
128
+ Use stable `phaseId` values: completed phases stay owned for the parent session,
129
+ and interrupted phases retain ownership across reloads. Equal normalized tasks
130
+ in the same cwd are also rejected, even with a different `phaseId`. Reuse the
131
+ result, or use `subagent_message` for an additional bounded step.
119
132
 
120
133
  Ownership includes main, individual runs, and workflow nodes still waiting on
121
134
  dependencies. Main continues only disjoint work and passes its completed research
@@ -134,63 +147,80 @@ phase/scope ownership; an exact run id also retrieves its retained result for re
134
147
 
135
148
  ## Workflows
136
149
 
137
- Main proactively chooses `subagent_workflow` for two or more substantial phases
138
- with known dependencies and write scopes when scheduling them saves coordination.
139
- Independent phases without dependency edges use `subagent` with `tasks`; a single
140
- justified phase uses one `subagent` run. Small work stays in main.
150
+ `subagent_workflow` runs a built-in plan with named task inputs. Its only source
151
+ is the catalog in [templates.ts](./src/workflow/templates.ts): no inline `nodes`,
152
+ `file`, custom graph name, user directory, or project directory is loaded.
153
+ The model's routing rules are embedded in [prompt.ts](./src/delegation/prompt.ts),
154
+ so no separate workflow skill needs to be loaded.
141
155
 
142
- If a research result must determine the next task or its scope, run that phase
143
- first, decide in main, then reassess whether the remaining work fits a graph.
144
- A workflow runs a fixed plan; it does not discover the plan or adapt its nodes
145
- while running. Research, implementation, review, and confirmation are added only
146
- when the task needs their distinct work.
156
+ | Workflow | Work before acceptance | Required inputs |
157
+ | --- | --- | --- |
158
+ | `code-review` | Sentinel inspects the target and produces supported findings | `TARGET` |
159
+ | `research` | Three scouts investigate first-party sources, practice, and the repository; a fourth synthesizes the answer | `QUESTION` |
160
+ | `migration` | Two artisans implement disjoint slices; an integrated gate checks and fixes their combined result | `TARGET`, `CONTRACT`, `CORE_CHANGE`, `ADAPTER_CHANGE`, `CORE_SCOPE`, `CORE_TEST_SCOPE`, `ADAPTER_SCOPE`, `ADAPTER_TEST_SCOPE` |
147
161
 
148
162
  ```ts
149
163
  subagent_workflow({
150
- name: "auth-fix",
151
- nodes: [
152
- {
153
- id: "fix",
154
- agent: "artisan",
155
- task: "Fix the refresh race in src/auth and add regression tests. Run the relevant checks.",
156
- scope: { paths: ["src/auth", "test/auth.test.ts"] },
157
- },
158
- {
159
- id: "review",
160
- agent: "sentinel",
161
- dependsOn: ["fix"],
162
- task: "Inspect the implementation against the refresh contract and callers. Reuse valid checks and investigate concrete gaps. Do not edit files.\n{{fix}}",
163
- },
164
- ],
164
+ workflow: "code-review",
165
+ inputs: { TARGET: "HEAD~1..HEAD; inspect the cache invalidation fix" },
166
+ wait: true,
165
167
  });
166
- ```
167
-
168
- `dependsOn` starts a node after its prerequisites complete and integrate.
169
- `{{id}}` inserts an upstream answer; `.status`, `.runId`, and `.error` expose its
170
- facts. Long answers include a full-result file. A failed node blocks its
171
- dependents; independent branches continue. The graph delivers one summary.
172
168
 
173
- Reviews inspect implementations; claim verification tests named findings or
174
- assumptions. Add independent verification only when its distinct work earns the cost.
169
+ subagent_workflow({
170
+ workflow: "research",
171
+ inputs: { QUESTION: "How should this repository invalidate its HTTP cache?" },
172
+ });
173
+ ```
175
174
 
176
- Saved definitions use JSON or Markdown with a `json` fenced block:
175
+ Migration inputs must name the shared interface contract, both slice briefs, and
176
+ exact write paths. Each slice owns its implementation and regression tests;
177
+ shared paths are rejected before any child starts. The integrated gate waits
178
+ for both slices and can edit their combined scope. For example:
177
179
 
178
180
  ```ts
179
- subagent_workflow({ workflow: "code-review" });
180
- subagent_workflow({ file: ".pi/workflows/code-review.md" });
181
+ subagent_workflow({
182
+ workflow: "migration",
183
+ inputs: {
184
+ TARGET: "the version 2 cache API",
185
+ CONTRACT: "docs/cache-v2.md",
186
+ CORE_CHANGE: "Update storage and its invalidation rules",
187
+ ADAPTER_CHANGE: "Update HTTP callers to the new interface",
188
+ CORE_SCOPE: "src/core",
189
+ CORE_TEST_SCOPE: "test/core",
190
+ ADAPTER_SCOPE: "src/adapters",
191
+ ADAPTER_TEST_SCOPE: "test/adapters",
192
+ },
193
+ });
181
194
  ```
182
195
 
183
- Definitions load from `.pi/workflows/`, `~/.pi/agent/workflows/`, and the shipped
184
- [templates](./workflows), in that order of precedence. Project definitions and
185
- explicit file paths require project trust. Customize template questions, targets,
186
- and scopes before running them. The `code-review` template has two nodes:
187
- sentinel reviews the target, then skeptic verifies only the reported claims and
188
- returns the final review. An ordinary review uses one sentinel. The `migration`
189
- template passes the shared interface contract to every slice and declares the
190
- closing gate's write scope. Run the full integrated gate once in main or a closing
191
- node, and repeat it when later edits or unresolved failures warrant it.
192
-
193
- See the [workflow skill](./skills/workflow/SKILL.md) for graph authoring details.
196
+ Choose a built-in workflow when its fixed phases fit the task. For one bounded
197
+ phase use `subagent`; for independent work use `subagent({ tasks: [...] })`.
198
+ If research must determine the next task or its scope, run it first and decide
199
+ in main. Missing, unknown, or unused template inputs are rejected with the exact
200
+ parameter names before a child starts. Task inputs remain literal, including
201
+ `{{...}}` text.
202
+
203
+ Every workflow ends with an independent **sentinel acceptance officer**. The
204
+ runtime adds this node, waits until all work has settled and integrated, and
205
+ passes a bounded evidence brief plus the complete report. Failed and blocked
206
+ branches are included. The officer reviews the delivered outcome, reuses valid
207
+ checks, and may run focused checks to close evidence gaps. It does not edit or
208
+ release. A successful code review can report defects in the target; acceptance
209
+ judges the accuracy and completeness of that review.
210
+
211
+ The final answer must end with `WORKFLOW_ACCEPTANCE: PASS` or
212
+ `WORKFLOW_ACCEPTANCE: FAIL`. A missing, ambiguous, malformed, or negative verdict
213
+ fails the workflow even when the reviewer process exits normally. A PASS cannot
214
+ clear failures in earlier work. Explicit cancellation or session interruption
215
+ stops the graph without starting acceptance. The graph sends one final summary
216
+ containing its acceptance result, or returns it in the tool call with `wait: true`.
217
+ Waiting includes integration and acceptance, streams progress, and stops owned
218
+ work on parent cancellation without a background wake-up. Main still owns
219
+ remediation, the final gate, and release.
220
+
221
+ Phase identity includes the built-in plan and its inputs. The same deliverable
222
+ remains owned within its workspace; different questions or targets can run in
223
+ the same session. Inspect retained results instead of repeating completed work.
194
224
 
195
225
  ## Status, cancellation, and recovery
196
226
 
@@ -198,24 +228,26 @@ See the [workflow skill](./skills/workflow/SKILL.md) for graph authoring details
198
228
  | --- | --- |
199
229
  | `subagent_status({ id: 12 })` | Inspect a run's progress, result, and recovery paths |
200
230
  | `subagent_status({ workflow: 3 })` | Inspect graph nodes and dependencies |
201
- | `subagent_message({ id: 12, message: "Check the caller too" })` | Steer a running child, or start a follow-up from its completed session |
231
+ | `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 |
202
232
  | `subagent_message({ id: 12, message: "Add the test", context: "summary" })` | Start a new next step with only a bounded summary of the earlier run |
203
233
  | `subagent_stop({ id: "12" })` | Stop a run and retire its retained session |
204
234
  | `subagent_stop({ workflow: 3 })` | Stop a graph and finalize its active nodes |
205
235
  | `subagent_stop({ all: true })` | Stop all active runs and graphs |
206
236
 
207
- The widget is a compact task board capped at 10 lines: a status overview,
208
- workflow progress groups, and task rows with status and elapsed time at the right.
209
- Activity, model, thinking, token usage, and worktree state use secondary lines as
210
- space permits. Task identities take priority over detail; failed and blocked
211
- work takes priority over ordinary activity. Completed nodes collapse into graph
212
- progress while their workflow is running. Successfully completed workflows hide
213
- automatically, while failed or blocked work stays visible until the next dispatch.
237
+ The widget is a terminal task board capped at 10 lines: a quiet overview,
238
+ workflow identity and work progress, then task rows with status/time at the
239
+ right. Failures and blocked reasons get space before optional telemetry; narrow
240
+ terminals keep task identity visible. Model, thinking, token usage, and worktree
241
+ state appear as secondary detail. Each workflow has a separate **Acceptance
242
+ required** row showing pending, running, PASS, or FAIL. Acceptance does not
243
+ inflate the ordinary work count or hidden-task total. Completed work collapses
244
+ into progress while acceptance is pending; a successfully accepted workflow
245
+ hides automatically. Failed or blocked work stays until the next dispatch.
214
246
  Completion messages and status lookups retain the results. Overflow reports
215
- hidden tasks. Runs preparing their child process show `starting`. There is no
216
- process-count limit or shared-checkout startup
217
- lock: independent runs start together, including separate dispatch calls while
218
- another call awaits results.
247
+ hidden tasks. Runs preparing their child process show `starting`. The refresh
248
+ timer runs only while visible active work needs it. There is no process-count
249
+ limit or shared-checkout startup lock: independent runs start together, including
250
+ separate dispatch calls while another call awaits results.
219
251
 
220
252
  Usually omit `isolation`: implementation tasks use detached Git worktrees in
221
253
  single calls, parallel batches, and workflows. Reading and review use the current
@@ -244,22 +276,42 @@ stops unfinished work. New/resume/fork/reload ends old children and retains inte
244
276
  for manual recovery. Runs do not resume automatically; main finishes incomplete
245
277
  work from partial changes and artifacts.
246
278
 
247
- A steering message is queued at the next Pi steering boundary; acknowledgement
248
- does not mean the child has acted on it. To continue a successfully completed
249
- run, choose the context that fits the follow-up:
250
-
251
- - `context: "session"` (default) for rework — revising, fixing or extending the
252
- same deliverable. It continues a private copy of the retained session, so the
253
- earlier reasoning stays available and the provider prompt-cache key
254
- (`sessionId`) is unchanged.
255
- - `context: "summary"` for a new next step — the new run never sees the old
256
- transcript and is briefed with the objective, the final result and the files
257
- the run touched. Cheaper, no cache reuse, and it cannot rely on detail the
258
- summary omits.
259
-
260
- Both start a new run with the role, workspace and scope preserved. Queueing,
261
- admission and isolation still apply. Pending runs cannot be steered, and fixed
262
- workflow graphs cannot be edited.
279
+ A steering call waits for the child's existing RPC channel to acknowledge the
280
+ matching request ID. The tool card shows **Received · queued** when Pi confirms
281
+ queueing, **Received · handled** when an input hook consumes the message, or
282
+ **Accepted · queue state unconfirmed** when no disposition is available.
283
+ `subagent_status` retains the latest acknowledgement, request ID, age, and message
284
+ summary. Rejection or a missing acknowledgement is an error, not a receipt.
285
+ Queueing delivers at a Pi steering boundary; it does not prove that the model
286
+ has executed the instruction.
287
+
288
+ To continue a successfully completed run, choose the context that fits the follow-up:
289
+
290
+ - `context: "auto"` (default) continues a private copy of the retained session
291
+ when available. If cleanup has removed it, the follow-up starts with a bounded
292
+ summary and explicitly reports that full history is unavailable. No retry is
293
+ needed for an expired session.
294
+ - `context: "session"` requires full history for rework that depends on earlier
295
+ details. If the session is unavailable, the call fails without starting a run.
296
+ - `context: "summary"` always starts fresh for a new next step, with the earlier
297
+ objective, final result and touched files. It cannot rely on omitted details
298
+ or reuse the earlier provider cache.
299
+
300
+ Session continuations retain the earlier history and provider prompt-cache key
301
+ (`sessionId`). Their private copy is bound to the new run's working directory,
302
+ including when a previous temporary worktree has already been removed. Child
303
+ startup and the copied session header use the same physical directory, so macOS
304
+ path aliases and Windows junctions do not trigger a cross-project fork prompt.
305
+ The continuation is instructed to re-read files before editing in the current cwd.
306
+
307
+ Every follow-up preserves the role, workspace and scope and passes through normal
308
+ admission and isolation. Set `wait: true` to receive its final result in the same
309
+ call; this waiting option applies to newly started follow-ups, while steering a
310
+ running child returns its acknowledgement. `subagent_status` reports whether a
311
+ completed run has a session available or only summary context. Results and summaries remain
312
+ available within the current parent runtime; completed runs are not restored
313
+ after reload. Pending runs cannot be steered, and fixed workflow graphs cannot
314
+ be edited.
263
315
 
264
316
  Children use Pi's native `--mode rpc` CLI with piped input/output, retries, and
265
317
  session persistence. On Windows, console hiding covers the Pi child and Node
@@ -270,32 +322,70 @@ explicit child extension installs the same policy for runtimes without Node
270
322
  preloading. Windows launches stay attached so detachment cannot open a console.
271
323
  On macOS and Linux, the policy leaves shell options unchanged; the Pi child uses
272
324
  a separate process group for cancellation and does not launch a terminal app.
273
- RPC communication and process-tree cancellation remain active. Commands that
274
- explicitly open a terminal or GUI control their own windows.
325
+ RPC communication and process-tree cancellation remain active. Child startup
326
+ errors are reported as failed runs. If Windows cannot launch `taskkill`,
327
+ termination falls back to killing the child directly. Commands that explicitly
328
+ open a terminal or GUI control their own windows.
275
329
  A settled provider failure can hand off once to the main model in the same
276
330
  session. State and full-result files live under
277
331
  `~/.pi/agent/ferris-pi-subagents/`, grouped by project. `PI_CODING_AGENT_DIR`
278
332
  overrides the agent directory.
279
333
 
334
+ ## Pi codemode compatibility
335
+
336
+ Call `subagent`, `subagent_workflow`, and the control tools directly. They use
337
+ Pi's `model-only` exposure and are intentionally unavailable as nested
338
+ `tools.subagent(...)` calls inside codemode. Children can still use codemode
339
+ with their inherited callable tools. Indirect tools retain their exposure;
340
+ scout promotes approved read-only tools for direct use. It waits up to ten
341
+ seconds for startup registration and activates later arrivals between turns.
342
+ Read-only classification uses Pi tool metadata.
343
+
344
+ Child RPC dialogs that require confirmation, selection, or text input are
345
+ cancelled with a matching response and an explanation, so an unattended child
346
+ does not hang waiting for an invisible dialog. No confirmation is approved
347
+ automatically.
348
+
280
349
  ## Storage and cleanup
281
350
 
282
351
  Each project root holds `sessions/`, `worktrees/`, `tmp/` and `results/`. Startup
283
352
  hygiene already drops temp leftovers, artifacts whose Pi process is gone, result
284
353
  files past their retention window, and project roots idle for three days. Parked
285
- recovery work and anything a manifest still references always survive.
354
+ recovery work and manifest references are protected during these sweeps.
355
+ Interrupted checkpoints expire after 30 days when no recorded owner or child
356
+ from the current boot is alive; expired checkpoints are pruned before restore.
357
+ Missing session files do not erase validated recovery paths. Unreadable or
358
+ malformed manifests leave artifacts intact and skip automatic reclamation;
359
+ explicit cleanup reports the error. Startup warns about failed recovery inspection
360
+ and continues initializing the progress widget.
286
361
 
287
362
  Reclamation is automatic: a settlement may trigger one paced sweep (at most every
288
363
  five minutes) that drops dead-owner artifacts, expired result files, and settled
289
364
  session copies older than 30 minutes, then trims the oldest settled sessions
290
- until a project fits its 1.5 GB budget. Live runs, parked recovery work, recent
291
- sessions, and anything a manifest references are never touched, so rework within
292
- the last half hour can still continue its session.
365
+ until a project fits its 1.5 GB budget. Under budget pressure, settled sessions
366
+ older than five minutes can be removed. Live runs, parked recovery work, and
367
+ manifest references remain protected. Automatic follow-ups use the retained
368
+ summary when a completed run's transcript has expired. Session shutdown waits
369
+ for cleanup already in progress and prevents new settlement sweeps.
293
370
 
294
- `/subagents-cleanup` runs the same pass immediately and reports per-project usage
295
- and freed bytes; `/subagents-cleanup dry-run` measures without deleting anything.
371
+ `/subagents-cleanup` immediately reclaims unclaimed dead-owner artifacts and idle
372
+ project roots, reporting usage and freed bytes. `/subagents-cleanup dry-run`
373
+ measures without deleting anything. Session age and budget reclamation runs
374
+ automatically on settlement.
296
375
 
297
376
  ## Development
298
377
 
378
+ Runtime code lives under `src/`; the package has no skill or workflow resource
379
+ directories. Built-in prompts and plans change with the code and its tests.
380
+
381
+ | Module | Responsibility |
382
+ | --- | --- |
383
+ | `delegation/` | Built-in roles, parent routing prompt, and phase/scope ownership |
384
+ | `workflow/` | Built-in templates, parameter validation, scheduling, and mandatory acceptance |
385
+ | `configuration/` | Model and thinking settings, plus the setup interface |
386
+ | `presentation/` | Running task board, activity, status, and result formatting |
387
+ | `execution/`, `lifecycle/`, `isolation/` | Child processes, durable state, cancellation, worktrees, and recovery |
388
+
299
389
  ```bash
300
390
  npm ci
301
391
  npm run check
package/index.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * - configuration/ — persisted settings, model routes, and setup UI
8
8
  * - execution/ — background tasks, native RPC transport, and model handoff
9
9
  * - lifecycle/ — durable threads, restoration, controls, and delivery
10
- * - workflow/ — dependency-graph plans, discovery, and the graph runner
10
+ * - workflow/ — built-in plans, dependency runner, and acceptance
11
11
  * - isolation/ — Git worktrees, recovery, and temporary-state hygiene
12
12
  * - presentation/ — announcements, formatting, monitor, and the active-run
13
13
  * widget
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "5.0.6",
3
+ "version": "6.0.1",
4
4
  "description": "A managed sub-agent team for pi: research, implementation, independent review, interactive follow-ups, and Git worktree isolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,8 +25,6 @@
25
25
  "files": [
26
26
  "index.ts",
27
27
  "src",
28
- "skills",
29
- "workflows",
30
28
  "README.md",
31
29
  "CHANGELOG.md",
32
30
  "LICENSE"
@@ -34,9 +32,6 @@
34
32
  "pi": {
35
33
  "extensions": [
36
34
  "./index.ts"
37
- ],
38
- "skills": [
39
- "./skills"
40
35
  ]
41
36
  },
42
37
  "scripts": {
@@ -45,9 +40,9 @@
45
40
  "prepack": "npm run check"
46
41
  },
47
42
  "peerDependencies": {
48
- "@earendil-works/pi-ai": ">=1.0.0",
49
- "@earendil-works/pi-coding-agent": ">=1.0.0",
50
- "@earendil-works/pi-tui": ">=1.0.0",
43
+ "@earendil-works/pi-ai": ">=1.4.0",
44
+ "@earendil-works/pi-coding-agent": ">=1.4.0",
45
+ "@earendil-works/pi-tui": ">=1.4.0",
51
46
  "typebox": "*"
52
47
  },
53
48
  "devDependencies": {
@@ -30,8 +30,8 @@ function migrateField(value: unknown, key: string): boolean {
30
30
  return true;
31
31
  }
32
32
 
33
- /** Accept saved plans or bare node arrays; never rewrite briefs or node ids. */
34
- export function migrateStoredWorkflowRoles(value: unknown): boolean {
33
+ /** Retained graph nodes keep their original briefs, ids, and dependencies. */
34
+ function migrateStoredWorkflowRoles(value: unknown): boolean {
35
35
  const nodes = Array.isArray(value) ? value : value && typeof value === "object" ? (value as { nodes?: unknown }).nodes : undefined;
36
36
  if (!Array.isArray(nodes)) return false;
37
37
  let changed = false;
@@ -53,12 +53,14 @@ function roleModel(ctx: ExtensionContext, config: SubagentsConfig, name: string)
53
53
  /** One row per role: every model and thinking choice stays visible together. */
54
54
  function roleRows(ctx: ExtensionContext, config: SubagentsConfig): RoleGridRow[] {
55
55
  const mainRef = currentModelRef(ctx) ?? "Pi default";
56
+ const models = availableModelsInScope(ctx);
56
57
  return BUILTIN_AGENT_NAMES.map((name) => {
57
58
  const profile = agentProfile(name)!;
58
59
  const selected = config.agentModels[name];
59
- const available = !selected || Boolean(findModelByRef(availableModelsInScope(ctx), selected));
60
+ const model = findModelByRef(models, selected);
61
+ const available = !selected || Boolean(model);
60
62
  const preferred = config.agentThinkingLevels[name] ?? roleThinkingLevel(name);
61
- const effective = resolveThinkingLevel(roleModel(ctx, config, name), preferred);
63
+ const effective = resolveThinkingLevel(model ?? ctx.model, preferred);
62
64
  const clamped = effective !== preferred ? " (" + preferred + " requested)" : "";
63
65
  const overridden = Boolean(config.agentThinkingLevels[name]);
64
66
  return {