@ferris1225/pi-subagents 6.0.3 → 6.0.5
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 +42 -0
- package/README.md +83 -200
- package/index.ts +8 -13
- package/package.json +1 -1
- package/src/configuration/config.ts +2 -6
- package/src/configuration/role-migration.ts +3 -14
- package/src/configuration/setup.ts +66 -57
- package/src/configuration/ui.ts +335 -64
- package/src/delegation/agents.ts +5 -6
- package/src/delegation/builtin-agents.ts +10 -31
- package/src/delegation/dispatch.ts +52 -165
- package/src/delegation/prompt.ts +29 -82
- package/src/execution/background.ts +2 -2
- package/src/execution/run-control.ts +1 -1
- package/src/execution/spawn.ts +2 -30
- package/src/isolation/worktree.ts +0 -14
- package/src/lifecycle/cancellation.ts +4 -8
- package/src/lifecycle/completion.ts +9 -21
- package/src/lifecycle/dispatch-core.ts +7 -7
- package/src/lifecycle/durable.ts +5 -29
- package/src/lifecycle/runtime.ts +11 -63
- package/src/lifecycle/stop.ts +1 -2
- package/src/lifecycle/thread-lifecycle.ts +38 -83
- package/src/lifecycle/thread-restore.ts +1 -3
- package/src/lifecycle/thread-shared.ts +10 -27
- package/src/lifecycle/tools.ts +24 -114
- package/src/presentation/announcements.ts +8 -6
- package/src/presentation/format.ts +39 -14
- package/src/presentation/monitor.ts +697 -758
- package/src/presentation/widget.ts +34 -142
- package/src/delegation/ownership.ts +0 -98
- package/src/delegation/phase-scope.ts +0 -186
- package/src/workflow/acceptance.ts +0 -67
- package/src/workflow/durable.ts +0 -228
- package/src/workflow/engine.ts +0 -816
- package/src/workflow/plan.ts +0 -409
- package/src/workflow/state.ts +0 -55
- package/src/workflow/templates.ts +0 -156
- package/src/workflow/tool.ts +0 -254
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.5
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- List every run a parallel launch started in its receipt instead of the first
|
|
8
|
+
two run ids.
|
|
9
|
+
- Inline completion answers up to 40 lines and 8,000 characters regardless of
|
|
10
|
+
line width; a single prose line over 200 characters no longer moves the whole
|
|
11
|
+
answer to its result file. Repeated deliveries of one result name one artifact.
|
|
12
|
+
- Give isolated children the original checkout and worktree paths so they map
|
|
13
|
+
paths from the brief into the worktree instead of editing the original.
|
|
14
|
+
- Include the model-failure takeover guidance in awaited results, and keep
|
|
15
|
+
per-model usage totals for stopped, crashed, and restored runs.
|
|
16
|
+
- Keep model overrides outside the session's model scope; session start removes
|
|
17
|
+
only overrides that no authenticated provider offers.
|
|
18
|
+
- Reject unknown `/subagents-cleanup` arguments without deleting anything.
|
|
19
|
+
- Show `starting` for every starting run, including a restart on the main model,
|
|
20
|
+
and advise waiting for a stopping run instead of stopping it again.
|
|
21
|
+
- Give session follow-ups a deterministic objective, so repeated identical
|
|
22
|
+
follow-ups follow the same duplicate rules as summary follow-ups.
|
|
23
|
+
|
|
24
|
+
### Changes
|
|
25
|
+
|
|
26
|
+
- Restrict the `subagent` role parameter to `scout`, `artisan`, and `sentinel`.
|
|
27
|
+
- Tighten the delegation directive and role prompts: drop the routing line that
|
|
28
|
+
restated role descriptions, name codemode only when present, clarify how main
|
|
29
|
+
applies review findings, label leases by role, remove script-tool guidance
|
|
30
|
+
from scout, and separate sentinel findings from unverified concerns.
|
|
31
|
+
- Shorten the `subagent_message` description and remove code left from the
|
|
32
|
+
workflow runner and earlier setup screens.
|
|
33
|
+
|
|
34
|
+
## 6.0.4
|
|
35
|
+
|
|
36
|
+
### Changes
|
|
37
|
+
|
|
38
|
+
- Open `/subagents-setup` role configuration and model/thinking pickers in
|
|
39
|
+
standalone centered modal overlay panels instead of squeezing them into the
|
|
40
|
+
input editor dock.
|
|
41
|
+
- Streamline delegation to the three core roles (`scout`, `artisan`, `sentinel`),
|
|
42
|
+
consolidating implementation review and claim-challenge verification into
|
|
43
|
+
`sentinel` and removing separate workflow/phase-scope machinery.
|
|
44
|
+
|
|
3
45
|
## 6.0.3
|
|
4
46
|
|
|
5
47
|
### Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pi-subagents
|
|
2
2
|
|
|
3
3
|
Sub-agents for [Pi](https://github.com/earendil-works/pi): research, implementation,
|
|
4
|
-
|
|
4
|
+
independent review, interactive follow-ups, and Git worktree isolation.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -12,29 +12,25 @@ integration tests use the Pi 1.5.0 SDK.
|
|
|
12
12
|
pi install npm:@ferris1225/pi-subagents
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Run `/subagents-setup
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
even when it currently matches main. Tab toggles complete details (including
|
|
26
|
-
exact references); ↑/↓ and PgUp/PgDn scroll them. Tab or Esc returns from details
|
|
27
|
-
to the list, keeping the search and cursor.
|
|
28
|
-
Filtering keeps focus on a matching name or reference, including after an empty
|
|
29
|
-
result; other queries select the best match. Hints follow your Pi keybindings.
|
|
30
|
-
The list takes priority over details on short terminals. Setup reserves space
|
|
31
|
-
for the workflow identity and required-acceptance row.
|
|
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.
|
|
32
25
|
|
|
33
26
|
All roles follow the main model by default; thinking defaults to `low` for scout
|
|
34
|
-
and `high` for artisan
|
|
27
|
+
and `high` for artisan and sentinel. The panel distinguishes defaults from overrides and
|
|
35
28
|
shows the effective level when model capabilities clamp a preference. Changing
|
|
36
29
|
a model preserves the thinking preference. Settings live in
|
|
37
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.
|
|
38
34
|
|
|
39
35
|
## Agents
|
|
40
36
|
|
|
@@ -42,32 +38,26 @@ a model preserves the thinking preference. Settings live in
|
|
|
42
38
|
| --- | --- | --- |
|
|
43
39
|
| `scout` | Code, documentation, and web research with citations | Read-only tools; no commands or edits |
|
|
44
40
|
| `artisan` | Implementation and fixes with tests and checks | Parent's tool surface, including codemode |
|
|
45
|
-
| `sentinel` | Inspect an implementation or diff
|
|
46
|
-
| `skeptic` | Test a named claim, assumption, or review finding with counterexamples | Parent's tool surface; instructed not to edit |
|
|
41
|
+
| `sentinel` | Inspect an implementation or diff and challenge claims or assumptions for defects and regressions | Parent's tool surface; instructed not to edit |
|
|
47
42
|
|
|
48
43
|
The main model chooses from these role descriptions; names alone do not route a
|
|
49
|
-
task. Use `sentinel`
|
|
50
|
-
|
|
51
|
-
reviewing an implementation and then testing its specific findings. A skeptic
|
|
52
|
-
without a named claim reports the gap and stops instead of starting another review.
|
|
44
|
+
task. Use `sentinel` to inspect implementations/diffs or challenge a specific claim
|
|
45
|
+
or assumption with counterexamples and focused checks.
|
|
53
46
|
|
|
54
|
-
Sentinel
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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.
|
|
58
51
|
|
|
59
|
-
Only `scout`, `artisan`,
|
|
52
|
+
Only `scout`, `artisan`, and `sentinel` are valid runtime role names.
|
|
60
53
|
Existing model/thinking settings and interrupted run records migrate on load
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
from older releases remain available for recovery.
|
|
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.
|
|
64
57
|
|
|
65
58
|
Children receive a self-contained brief and project instructions, but no parent
|
|
66
59
|
conversation. They cannot delegate or release. Main owns planning, integration,
|
|
67
60
|
and the final result. Keep a fix and its regression tests with one owner.
|
|
68
|
-
Follow-ups use the latest objective while retaining earlier constraints unless
|
|
69
|
-
explicitly changed. Research separates documented contracts, reported experience,
|
|
70
|
-
and local code; synthesis retrieves more sources only to resolve a gap or conflict.
|
|
71
61
|
|
|
72
62
|
## Delegate
|
|
73
63
|
|
|
@@ -82,7 +72,7 @@ avoid subagents take precedence.
|
|
|
82
72
|
Use one owner per deliverable, including its regression tests. Brief the child
|
|
83
73
|
with the outcome, done condition, relevant paths, established evidence, write
|
|
84
74
|
boundaries, required checks, and a compact expected result. Scout retrieves
|
|
85
|
-
sources; artisan implements, while sentinel
|
|
75
|
+
sources; artisan implements, while sentinel can execute focused checks. This policy applies the context-isolation,
|
|
86
76
|
focused-role, and coordination-cost guidance in the official
|
|
87
77
|
[Codex subagents](https://developers.openai.com/codex/subagents) and
|
|
88
78
|
[Claude Code subagents](https://code.claude.com/docs/en/sub-agents) docs to Pi's
|
|
@@ -93,14 +83,12 @@ authorized and requests focused confirmation only when material uncertainty
|
|
|
93
83
|
remains. Before reporting success, main checks each done condition and any
|
|
94
84
|
blockers in the child's answer as well as the integrated diff.
|
|
95
85
|
|
|
96
|
-
Ask Pi to delegate explicitly, or call the
|
|
86
|
+
Ask Pi to delegate explicitly, or call the tool directly:
|
|
97
87
|
|
|
98
88
|
```ts
|
|
99
89
|
subagent({
|
|
100
90
|
agent: "artisan",
|
|
101
|
-
phaseId: "cache-fix",
|
|
102
91
|
task: "Fix cache invalidation in src/cache, add regression tests, and run the checks.",
|
|
103
|
-
scope: { paths: ["src/cache", "test/cache.test.ts"] },
|
|
104
92
|
});
|
|
105
93
|
```
|
|
106
94
|
|
|
@@ -111,159 +99,57 @@ subagent({
|
|
|
111
99
|
tasks: [
|
|
112
100
|
{
|
|
113
101
|
agent: "artisan",
|
|
114
|
-
phaseId: "config-fix",
|
|
115
102
|
task: "Fix config validation and its regression tests.",
|
|
116
|
-
scope: { paths: ["src/config.ts", "test/config.test.ts"] },
|
|
117
103
|
},
|
|
118
104
|
{
|
|
119
105
|
agent: "artisan",
|
|
120
|
-
phaseId: "provider-docs",
|
|
121
106
|
task: "Update docs/providers.md from the established API citations.",
|
|
122
|
-
scope: { paths: ["docs/providers.md"] },
|
|
123
107
|
},
|
|
124
108
|
],
|
|
125
109
|
});
|
|
126
110
|
```
|
|
127
111
|
|
|
128
|
-
Use `wait: true` when the next step needs the result. `subagent
|
|
129
|
-
`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
in the same cwd are
|
|
142
|
-
result, or use `subagent_message`
|
|
143
|
-
|
|
144
|
-
Ownership includes main, individual runs, and workflow nodes still waiting on
|
|
145
|
-
dependencies. Main continues only disjoint work and passes its completed research
|
|
146
|
-
and checks into the child brief. Pending graph nodes reserve their declared write
|
|
147
|
-
scopes; external conflicts reject a batch or graph before any child starts.
|
|
148
|
-
Main `edit`/`write` calls, including nested calls through `codemode`, are blocked
|
|
149
|
-
on those scopes. In-flight main writes also prevent conflicting dispatches.
|
|
150
|
-
Stopped writers keep their claims until execution and integration finish.
|
|
151
|
-
|
|
152
|
-
These checks use declared phase identity and exact paths/symbols. Main file writes
|
|
153
|
-
conservatively conflict with any claimed symbol in that file. Omitted scopes,
|
|
154
|
-
arbitrary shell/custom-tool effects, symlink aliases, and differently worded work
|
|
155
|
-
without a shared phase id cannot be inferred reliably; this is coordination,
|
|
156
|
-
not a sandbox or semantic duplicate detector. Use `subagent_status` to inspect
|
|
157
|
-
phase/scope ownership; an exact run id also retrieves its retained result for reuse.
|
|
158
|
-
|
|
159
|
-
## Workflows
|
|
160
|
-
|
|
161
|
-
`subagent_workflow` runs a built-in plan with named task inputs. Its only source
|
|
162
|
-
is the catalog in [templates.ts](./src/workflow/templates.ts): no inline `nodes`,
|
|
163
|
-
`file`, custom graph name, user directory, or project directory is loaded.
|
|
164
|
-
The model's routing rules are embedded in [prompt.ts](./src/delegation/prompt.ts),
|
|
165
|
-
so no separate workflow skill needs to be loaded.
|
|
166
|
-
|
|
167
|
-
| Workflow | Work before acceptance | Required inputs |
|
|
168
|
-
| --- | --- | --- |
|
|
169
|
-
| `code-review` | Sentinel inspects the target and produces supported findings | `TARGET` |
|
|
170
|
-
| `research` | Three scouts investigate first-party sources, practice, and the repository; a fourth synthesizes the answer | `QUESTION` |
|
|
171
|
-
| `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` |
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
subagent_workflow({
|
|
175
|
-
workflow: "code-review",
|
|
176
|
-
inputs: { TARGET: "HEAD~1..HEAD; inspect the cache invalidation fix" },
|
|
177
|
-
wait: true,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
subagent_workflow({
|
|
181
|
-
workflow: "research",
|
|
182
|
-
inputs: { QUESTION: "How should this repository invalidate its HTTP cache?" },
|
|
183
|
-
});
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Migration inputs must name the shared interface contract, both slice briefs, and
|
|
187
|
-
exact write paths. Each slice owns its implementation and regression tests;
|
|
188
|
-
shared paths are rejected before any child starts. The integrated gate waits
|
|
189
|
-
for both slices and can edit their combined scope. For example:
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
subagent_workflow({
|
|
193
|
-
workflow: "migration",
|
|
194
|
-
inputs: {
|
|
195
|
-
TARGET: "the version 2 cache API",
|
|
196
|
-
CONTRACT: "docs/cache-v2.md",
|
|
197
|
-
CORE_CHANGE: "Update storage and its invalidation rules",
|
|
198
|
-
ADAPTER_CHANGE: "Update HTTP callers to the new interface",
|
|
199
|
-
CORE_SCOPE: "src/core",
|
|
200
|
-
CORE_TEST_SCOPE: "test/core",
|
|
201
|
-
ADAPTER_SCOPE: "src/adapters",
|
|
202
|
-
ADAPTER_TEST_SCOPE: "test/adapters",
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Choose a built-in workflow when its fixed phases fit the task. For one bounded
|
|
208
|
-
phase use `subagent`; for independent work use `subagent({ tasks: [...] })`.
|
|
209
|
-
If research must determine the next task or its scope, run it first and decide
|
|
210
|
-
in main. Missing, unknown, or unused template inputs are rejected with the exact
|
|
211
|
-
parameter names before a child starts. Task inputs remain literal, including
|
|
212
|
-
`{{...}}` text.
|
|
213
|
-
|
|
214
|
-
Every workflow ends with an independent **sentinel acceptance officer**. The
|
|
215
|
-
runtime adds this node, waits until all work has settled and integrated, and
|
|
216
|
-
passes a bounded evidence brief plus the complete report. Failed and blocked
|
|
217
|
-
branches are included. The officer reviews the delivered outcome, reuses valid
|
|
218
|
-
checks, and may run focused checks to close evidence gaps. It does not edit or
|
|
219
|
-
release. A successful code review can report defects in the target; acceptance
|
|
220
|
-
judges the accuracy and completeness of that review.
|
|
221
|
-
|
|
222
|
-
The final answer must end with `WORKFLOW_ACCEPTANCE: PASS` or
|
|
223
|
-
`WORKFLOW_ACCEPTANCE: FAIL`. A missing, ambiguous, malformed, or negative verdict
|
|
224
|
-
fails the workflow even when the reviewer process exits normally. A PASS cannot
|
|
225
|
-
clear failures in earlier work. Explicit cancellation or session interruption
|
|
226
|
-
stops the graph without starting acceptance. The graph sends one final summary
|
|
227
|
-
containing its acceptance result, or returns it in the tool call with `wait: true`.
|
|
228
|
-
Waiting includes integration and acceptance, streams progress, and stops owned
|
|
229
|
-
work on parent cancellation without a background wake-up. Main still owns
|
|
230
|
-
remediation, the final gate, and release.
|
|
231
|
-
|
|
232
|
-
Phase identity includes the built-in plan and its inputs. The same deliverable
|
|
233
|
-
remains owned within its workspace; different questions or targets can run in
|
|
234
|
-
the same session. Inspect retained results instead of repeating completed work.
|
|
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.
|
|
235
128
|
|
|
236
129
|
## Status, cancellation, and recovery
|
|
237
130
|
|
|
238
131
|
| Tool | Use |
|
|
239
132
|
| --- | --- |
|
|
240
133
|
| `subagent_status({ id: 12 })` | Inspect a run's progress, result, and recovery paths |
|
|
241
|
-
| `subagent_status({ workflow: 3 })` | Inspect graph nodes and dependencies |
|
|
242
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 |
|
|
243
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 |
|
|
244
136
|
| `subagent_stop({ id: "12" })` | Stop a run and retire its retained session |
|
|
245
|
-
| `subagent_stop({
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
hides automatically. Failed or blocked work stays until the next dispatch.
|
|
257
|
-
Completion messages and status lookups retain the results. Overflow reports
|
|
258
|
-
hidden tasks. Runs preparing their child process show `starting`. The refresh
|
|
259
|
-
timer runs only while visible active work needs it. There is no process-count
|
|
260
|
-
limit or shared-checkout startup lock: independent runs start together, including
|
|
261
|
-
separate dispatch calls while another call awaits results.
|
|
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.
|
|
262
148
|
|
|
263
149
|
Usually omit `isolation`: implementation tasks use detached Git worktrees in
|
|
264
|
-
single calls
|
|
265
|
-
|
|
266
|
-
|
|
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
|
|
267
153
|
remain failures; an explicit `isolation: "worktree"` requires isolation and never
|
|
268
154
|
falls back. `isolation: "shared"` is an advanced override for tasks that need to
|
|
269
155
|
write directly in the caller's checkout.
|
|
@@ -271,21 +157,20 @@ write directly in the caller's checkout.
|
|
|
271
157
|
Each worktree starts from the caller's current tracked files and non-ignored
|
|
272
158
|
untracked files, including uncommitted changes. Its initial snapshot is also the
|
|
273
159
|
integration base, so dependent tasks see earlier results without reapplying them.
|
|
274
|
-
The caller's index, branch, and `HEAD` stay unchanged.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
of worktree changes to the original
|
|
278
|
-
|
|
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.
|
|
279
166
|
|
|
280
167
|
Cancelling the parent run with Escape stops unfinished work without waking the
|
|
281
168
|
parent. A cancellation receipt is supplied on the next user turn with the stopped
|
|
282
|
-
run
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
for manual recovery. Runs do not resume automatically; main finishes incomplete
|
|
288
|
-
work from partial changes and artifacts.
|
|
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.
|
|
289
174
|
|
|
290
175
|
A steering call waits for the child's existing RPC channel to acknowledge the
|
|
291
176
|
matching request ID. The tool card shows **Received · queued** when Pi confirms
|
|
@@ -315,14 +200,13 @@ startup and the copied session header use the same physical directory, so macOS
|
|
|
315
200
|
path aliases and Windows junctions do not trigger a cross-project fork prompt.
|
|
316
201
|
The continuation is instructed to re-read files before editing in the current cwd.
|
|
317
202
|
|
|
318
|
-
Every follow-up preserves the role
|
|
203
|
+
Every follow-up preserves the role and workspace and passes through normal
|
|
319
204
|
admission and isolation. Set `wait: true` to receive its final result in the same
|
|
320
205
|
call; this waiting option applies to newly started follow-ups, while steering a
|
|
321
206
|
running child returns its acknowledgement. `subagent_status` reports whether a
|
|
322
207
|
completed run has a session available or only summary context. Results and summaries remain
|
|
323
208
|
available within the current parent runtime; completed runs are not restored
|
|
324
|
-
after reload. Pending runs cannot be steered
|
|
325
|
-
be edited.
|
|
209
|
+
after reload. Pending runs cannot be steered.
|
|
326
210
|
|
|
327
211
|
Children use Pi's native `--mode rpc` CLI with piped input/output, retries, and
|
|
328
212
|
session persistence. On Windows, console hiding covers the Pi child and Node
|
|
@@ -344,13 +228,13 @@ overrides the agent directory.
|
|
|
344
228
|
|
|
345
229
|
## Pi codemode compatibility
|
|
346
230
|
|
|
347
|
-
Call `subagent
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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.
|
|
354
238
|
|
|
355
239
|
Child RPC dialogs that require confirmation, selection, or text input are
|
|
356
240
|
cancelled with a matching response and an explanation, so an unattended child
|
|
@@ -381,19 +265,18 @@ for cleanup already in progress and prevents new settlement sweeps.
|
|
|
381
265
|
|
|
382
266
|
`/subagents-cleanup` immediately reclaims unclaimed dead-owner artifacts and idle
|
|
383
267
|
project roots, reporting usage and freed bytes. `/subagents-cleanup dry-run`
|
|
384
|
-
measures without deleting anything
|
|
385
|
-
automatically on settlement.
|
|
268
|
+
measures without deleting anything; any other argument is rejected without
|
|
269
|
+
deleting. Session age and budget reclamation runs automatically on settlement.
|
|
386
270
|
|
|
387
271
|
## Development
|
|
388
272
|
|
|
389
273
|
Runtime code lives under `src/`; the package has no skill or workflow resource
|
|
390
|
-
directories. Built-in prompts
|
|
274
|
+
directories. Built-in prompts change with the code and its tests.
|
|
391
275
|
|
|
392
276
|
| Module | Responsibility |
|
|
393
277
|
| --- | --- |
|
|
394
|
-
| `delegation/` | Built-in roles, parent routing prompt, and
|
|
395
|
-
| `
|
|
396
|
-
| `configuration/` | Model and thinking settings, plus the setup interface |
|
|
278
|
+
| `delegation/` | Built-in roles, parent routing prompt, and duplicate-dispatch admission |
|
|
279
|
+
| `configuration/` | Model and thinking settings, plus the standalone setup modal panel |
|
|
397
280
|
| `presentation/` | Running task board, activity, status, and result formatting |
|
|
398
281
|
| `execution/`, `lifecycle/`, `isolation/` | Child processes, durable state, cancellation, worktrees, and recovery |
|
|
399
282
|
|
package/index.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
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/ — built-in plans, dependency runner, and acceptance
|
|
11
10
|
* - isolation/ — Git worktrees, recovery, and temporary-state hygiene
|
|
12
11
|
* - presentation/ — announcements, formatting, monitor, and the active-run
|
|
13
12
|
* widget
|
|
@@ -27,18 +26,15 @@ import { runSetup } from "./src/configuration/setup.ts";
|
|
|
27
26
|
import { loadBuiltinAgents } from "./src/delegation/agents.ts";
|
|
28
27
|
import { registerSubagentTool } from "./src/delegation/dispatch.ts";
|
|
29
28
|
import { buildDelegationDirective, installDelegationSections } from "./src/delegation/prompt.ts";
|
|
30
|
-
import {
|
|
31
|
-
import { currentSubagentDepth } from "./src/execution/spawn.ts";
|
|
29
|
+
import { currentSubagentDepth, getSubagentsRoot } from "./src/execution/spawn.ts";
|
|
32
30
|
import { createDispatchCore } from "./src/lifecycle/dispatch-core.ts";
|
|
33
31
|
import { registerCancellationHooks } from "./src/lifecycle/cancellation.ts";
|
|
34
32
|
import { createRuntime } from "./src/lifecycle/runtime.ts";
|
|
35
33
|
import { bootstrapDurableState } from "./src/lifecycle/thread-restore.ts";
|
|
36
34
|
import { registerLookupTools } from "./src/lifecycle/tools.ts";
|
|
37
|
-
import { registerWorkflowTool, restoreWorkflowState } from "./src/workflow/tool.ts";
|
|
38
35
|
import { registerAnnouncements } from "./src/presentation/announcements.ts";
|
|
39
36
|
import { clearActiveRunsWidget } from "./src/presentation/widget.ts";
|
|
40
37
|
import { formatBytes, measureDurableUsage, runStorageCleanup } from "./src/isolation/cleanup.ts";
|
|
41
|
-
import { getSubagentsRoot } from "./src/execution/spawn.ts";
|
|
42
38
|
|
|
43
39
|
export default function (pi: ExtensionAPI): void {
|
|
44
40
|
// Recursion guard: sub-agent children are leaf processes. The `subagent` tool is
|
|
@@ -71,15 +67,10 @@ export default function (pi: ExtensionAPI): void {
|
|
|
71
67
|
await runtime.shutdown();
|
|
72
68
|
});
|
|
73
69
|
|
|
74
|
-
// One dispatcher serves both delegation tools, so a workflow node is an
|
|
75
|
-
// ordinary managed run: same lifecycle ownership, admission, isolation, and
|
|
76
|
-
// durable checkpointing.
|
|
77
70
|
const dispatchCore = createDispatchCore(runtime);
|
|
78
71
|
registerSubagentTool(pi, runtime, dispatchCore);
|
|
79
|
-
registerWorkflowTool(pi, runtime, dispatchCore);
|
|
80
72
|
registerLookupTools(pi, runtime, dispatchCore);
|
|
81
73
|
registerCancellationHooks(pi, runtime);
|
|
82
|
-
registerMainOwnershipGuard(pi, runtime);
|
|
83
74
|
|
|
84
75
|
pi.registerCommand("subagents-setup", {
|
|
85
76
|
description: "Configure pi-subagents: model and thinking per role",
|
|
@@ -91,8 +82,13 @@ export default function (pi: ExtensionAPI): void {
|
|
|
91
82
|
pi.registerCommand("subagents-cleanup", {
|
|
92
83
|
description: "Report and reclaim pi-subagents storage; /subagents-cleanup dry-run only reports",
|
|
93
84
|
handler: async (args, ctx) => {
|
|
85
|
+
const mode = args.trim();
|
|
86
|
+
if (mode !== "" && mode !== "dry-run") {
|
|
87
|
+
ctx.ui.notify(`pi-subagents cleanup: unknown argument "${mode}"; nothing was deleted. Use /subagents-cleanup or /subagents-cleanup dry-run.`, "warning");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
94
90
|
const root = getSubagentsRoot(configPath);
|
|
95
|
-
if (
|
|
91
|
+
if (mode === "dry-run") {
|
|
96
92
|
const usage = measureDurableUsage(root);
|
|
97
93
|
const detail = usage.projects.slice(0, 5).map((project) =>
|
|
98
94
|
`${project.path.split(/[\\/]/u).at(-1)} ${formatBytes(project.bytes)} (${project.sessions} sessions, ${project.worktrees} worktrees)`);
|
|
@@ -111,7 +107,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
111
107
|
|
|
112
108
|
pi.on("session_start", async (_event, ctx) => {
|
|
113
109
|
await bootstrapDurableState(runtime, ctx.cwd);
|
|
114
|
-
await restoreWorkflowState(runtime, ctx);
|
|
115
110
|
});
|
|
116
111
|
registerAnnouncements(pi, runtime);
|
|
117
112
|
|
|
@@ -120,7 +115,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
120
115
|
pi.on("before_agent_start", async (event) => {
|
|
121
116
|
await runtime.durableRestore;
|
|
122
117
|
const agents = loadBuiltinAgents();
|
|
123
|
-
const sources = [...runtime.threads.values()
|
|
118
|
+
const sources = [...runtime.threads.values()];
|
|
124
119
|
const sections = event.systemPromptOptions?.sections;
|
|
125
120
|
if (sections) {
|
|
126
121
|
installDelegationSections(sections, agents, sources);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferris1225/pi-subagents",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5",
|
|
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",
|
|
@@ -17,7 +17,7 @@ import { getAgentDir, withFileMutationQueue } from "@earendil-works/pi-coding-ag
|
|
|
17
17
|
import { migrateStoredRoleKeys } from "./role-migration.ts";
|
|
18
18
|
|
|
19
19
|
/** Full catalog of agents shipped with the package; all of them always run. */
|
|
20
|
-
export const BUILTIN_AGENT_NAMES = ["scout", "artisan", "sentinel"
|
|
20
|
+
export const BUILTIN_AGENT_NAMES = ["scout", "artisan", "sentinel"] as const;
|
|
21
21
|
|
|
22
22
|
/** Thinking levels accepted by pi's `--thinking` option. */
|
|
23
23
|
const THINKING_LEVEL_VALUES = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
@@ -32,7 +32,6 @@ export function roleThinkingLevel(agentName: string): ThinkingLevel {
|
|
|
32
32
|
return "low";
|
|
33
33
|
case "artisan":
|
|
34
34
|
case "sentinel":
|
|
35
|
-
case "skeptic":
|
|
36
35
|
return "high";
|
|
37
36
|
default:
|
|
38
37
|
return DEFAULT_THINKING_LEVEL;
|
|
@@ -53,10 +52,7 @@ export const AGENT_PROFILES: Record<(typeof BUILTIN_AGENT_NAMES)[number], AgentP
|
|
|
53
52
|
remark: "Implement one substantial change with its tests and verification.",
|
|
54
53
|
},
|
|
55
54
|
sentinel: {
|
|
56
|
-
remark: "Inspect an implementation or diff
|
|
57
|
-
},
|
|
58
|
-
skeptic: {
|
|
59
|
-
remark: "Test a named claim, design assumption, or review finding with counterexamples and focused checks. No edits.",
|
|
55
|
+
remark: "Inspect an implementation or diff and challenge claims or assumptions for defects and regressions. No edits.",
|
|
60
56
|
},
|
|
61
57
|
};
|
|
62
58
|
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* current catalog names; these helpers are used only at storage boundaries. */
|
|
3
3
|
|
|
4
4
|
export function migrateStoredAgentName(name: string): string {
|
|
5
|
-
if (name === "reviewer") return "sentinel";
|
|
6
|
-
if (name === "critic") return "skeptic";
|
|
5
|
+
if (name === "reviewer" || name === "critic" || name === "skeptic") return "sentinel";
|
|
7
6
|
return name;
|
|
8
7
|
}
|
|
9
8
|
|
|
@@ -30,21 +29,11 @@ function migrateField(value: unknown, key: string): boolean {
|
|
|
30
29
|
return true;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
/**
|
|
34
|
-
function migrateStoredWorkflowRoles(value: unknown): boolean {
|
|
35
|
-
const nodes = Array.isArray(value) ? value : value && typeof value === "object" ? (value as { nodes?: unknown }).nodes : undefined;
|
|
36
|
-
if (!Array.isArray(nodes)) return false;
|
|
37
|
-
let changed = false;
|
|
38
|
-
for (const node of nodes) changed = migrateField(node, "agent") || changed;
|
|
39
|
-
return changed;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Thread and workflow manifests retain their ids, leases, and recovery paths. */
|
|
32
|
+
/** Thread manifests retain their ids, leases, and recovery paths. */
|
|
43
33
|
export function migrateStoredRecordRoles(value: unknown): boolean {
|
|
44
34
|
if (!value || typeof value !== "object") return false;
|
|
45
35
|
const summary = (value as { resultSummary?: unknown }).resultSummary;
|
|
46
36
|
const threadChanged = migrateField(value, "agentName");
|
|
47
37
|
const summaryChanged = migrateField(summary, "agent");
|
|
48
|
-
|
|
49
|
-
return threadChanged || summaryChanged || nodesChanged;
|
|
38
|
+
return threadChanged || summaryChanged;
|
|
50
39
|
}
|