@ferris1225/pi-subagents 6.0.0 → 6.0.2
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 +63 -0
- package/README.md +110 -42
- package/package.json +4 -4
- package/src/configuration/models.ts +10 -5
- package/src/configuration/setup.ts +54 -35
- package/src/configuration/ui.ts +109 -221
- package/src/delegation/agents.ts +15 -22
- package/src/delegation/dispatch.ts +17 -122
- package/src/delegation/prompt.ts +10 -10
- package/src/execution/cli-run.ts +112 -39
- package/src/execution/process-tree.ts +12 -8
- package/src/execution/run-control.ts +11 -3
- package/src/execution/spawn.ts +9 -2
- package/src/isolation/cleanup.ts +22 -7
- package/src/isolation/managed-paths.ts +6 -4
- package/src/isolation/manifest-mutation.ts +17 -1
- package/src/isolation/recovery.ts +11 -15
- package/src/isolation/temp-hygiene.ts +1 -1
- package/src/lifecycle/await-results.ts +114 -0
- package/src/lifecycle/dispatch-core.ts +7 -1
- package/src/lifecycle/durable.ts +25 -17
- package/src/lifecycle/runtime.ts +3 -1
- package/src/lifecycle/thread-lifecycle.ts +6 -4
- package/src/lifecycle/thread-restore.ts +12 -21
- package/src/lifecycle/tools.ts +90 -33
- package/src/presentation/announcements.ts +8 -2
- package/src/workflow/durable.ts +3 -3
- package/src/workflow/engine.ts +44 -22
- package/src/workflow/tool.ts +47 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.2
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Simplify `/subagents-setup` into role, setting, and value lists with consistent
|
|
8
|
+
up/down navigation and one-level-back cancellation. Preserve focus and save
|
|
9
|
+
each confirmed change immediately.
|
|
10
|
+
- Prioritize visible model choices over repeated details, show readable model
|
|
11
|
+
names with providers, and distinguish saved settings from keyboard focus.
|
|
12
|
+
Explain following the main model versus choosing a fixed model explicitly.
|
|
13
|
+
- Preserve Unicode search, paste, paging, capability-aware thinking preferences,
|
|
14
|
+
and space for the workflow required-acceptance row on short terminals.
|
|
15
|
+
|
|
16
|
+
## 6.0.1
|
|
17
|
+
|
|
18
|
+
### Fixes
|
|
19
|
+
|
|
20
|
+
- Resolve the child working directory before launching or updating its private
|
|
21
|
+
session header, preserving fallback and follow-ups through macOS path aliases
|
|
22
|
+
and Windows junctions without a cross-project fork prompt.
|
|
23
|
+
- Require Pi SDK 1.4.0 and preserve callable codemode/deferred tools in child
|
|
24
|
+
sessions, including approved read-only tools that register after startup.
|
|
25
|
+
Keep delegation controls model-only and invoke them outside codemode.
|
|
26
|
+
- Add workflow and completed-run follow-up waiting; default all dispatches to
|
|
27
|
+
waiting in one-shot print/JSON sessions. Return final evidence exactly once
|
|
28
|
+
after integration and acceptance, mark awaited failures as tool errors, and
|
|
29
|
+
cancel unfinished work without background wake-ups.
|
|
30
|
+
- Display child RPC steering acknowledgements in the tool card and status,
|
|
31
|
+
including request ID and queued/handled/unknown queue disposition. Distinguish
|
|
32
|
+
receipt from model execution instead of showing only a generic success mark.
|
|
33
|
+
- Cancel unattended RPC input dialogs with an explicit response, preventing
|
|
34
|
+
invisible confirmation or input requests from hanging child execution.
|
|
35
|
+
- Clarify that launch receipts are not task completion and that main resumes
|
|
36
|
+
from child evidence to finish fixes and final checks. Correct interrupted-run
|
|
37
|
+
retirement examples, equal-task ownership guidance, and completed-run
|
|
38
|
+
follow-up recommendations. Reuse the completion waiter across dispatch paths.
|
|
39
|
+
- Deliver unexpected workflow failures through the same final-summary route.
|
|
40
|
+
- Retry brief Windows permission/sharing errors during atomic manifest
|
|
41
|
+
replacement under the existing writer lock, preserving the last checkpoint
|
|
42
|
+
and propagating persistent errors without an unlink/copy fallback.
|
|
43
|
+
|
|
44
|
+
- Contain synchronous Windows process-termination errors and child spawn
|
|
45
|
+
failures with missing stdio, preventing resource errors such as `ENOMEM`,
|
|
46
|
+
`EMFILE`, and `ENFILE` from escaping into the parent Pi process.
|
|
47
|
+
- Default completed-run follow-ups to `context: "auto"`: reuse retained history
|
|
48
|
+
when available, otherwise dispatch with a bounded summary and report the
|
|
49
|
+
fallback. Keep explicit `session` strict, expose available follow-up context
|
|
50
|
+
in status, and give interrupted runs actionable recovery guidance.
|
|
51
|
+
- Bind private session copies to the next run's cwd so follow-ups survive
|
|
52
|
+
removal of an earlier worktree. Preserve the session ID and prior entries,
|
|
53
|
+
and remind continued agents to re-read changed files.
|
|
54
|
+
- Preserve recovery artifacts when manifests or path validation cannot be read.
|
|
55
|
+
Protect live owners during empty-session, age, budget and project cleanup.
|
|
56
|
+
Prune expired checkpoints before restore, keep checkpoints with live owners
|
|
57
|
+
or children, and retain validated paths when a session file is unavailable.
|
|
58
|
+
Recovery inspection errors warn without skipping progress-widget setup.
|
|
59
|
+
- Recheck cancellation and source state before follow-up dispatch, and handle
|
|
60
|
+
a retained transcript disappearing during copying without duplicate launches.
|
|
61
|
+
- Drain settlement-triggered cleanup during shutdown and stop launching new
|
|
62
|
+
sweeps once shutdown begins, avoiding filesystem activity after teardown.
|
|
63
|
+
- Correct the documented five-minute minimum retention under budget pressure
|
|
64
|
+
and distinguish automatic reclamation from explicit storage cleanup.
|
|
65
|
+
|
|
3
66
|
## 6.0.0
|
|
4
67
|
|
|
5
68
|
### Breaking changes
|
package/README.md
CHANGED
|
@@ -5,21 +5,28 @@ dependency workflows, and Git worktree isolation.
|
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
|
-
Requires **Pi >= 1.
|
|
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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
Run `/subagents-setup`, choose a role, then choose **Model**, **Thinking**, or
|
|
16
|
+
**Reset defaults**. Every screen uses ↑/↓ and Enter; Esc goes back one level
|
|
17
|
+
without applying an unconfirmed choice. Selections save immediately and return
|
|
18
|
+
to the same setting; returning to the role list keeps that role selected.
|
|
19
|
+
|
|
20
|
+
Model and thinking choices support search, Unicode paste, and PgUp/PgDn paging.
|
|
21
|
+
Models show their friendly name and provider; search also matches exact model
|
|
22
|
+
references and capabilities. **[saved]** marks the stored selection independently
|
|
23
|
+
of the navigation cursor. **Follow main (dynamic)** tracks the main window's
|
|
24
|
+
model, including future changes; choosing a specific model pins that reference,
|
|
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
|
+
The list takes priority over details on short terminals. Setup reserves space
|
|
29
|
+
for the workflow identity and required-acceptance row.
|
|
23
30
|
|
|
24
31
|
All roles follow the main model by default; thinking defaults to `low` for scout
|
|
25
32
|
and `high` for artisan, sentinel, and skeptic. The panel distinguishes defaults from overrides and
|
|
@@ -113,10 +120,21 @@ subagent({
|
|
|
113
120
|
});
|
|
114
121
|
```
|
|
115
122
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
Use `wait: true` when the next step needs the result. `subagent`,
|
|
124
|
+
`subagent_workflow`, and completed-run `subagent_message` follow-ups default to
|
|
125
|
+
waiting in one-shot `pi -p` / JSON sessions, so the parent stays alive until the
|
|
126
|
+
work finishes. TUI and RPC sessions default to background delivery; `wait: false`
|
|
127
|
+
explicitly selects it in any mode. Each result is delivered once, after
|
|
128
|
+
integration, either in the waiting tool call or as a background completion.
|
|
129
|
+
Awaited failures are tool errors with retained evidence.
|
|
130
|
+
|
|
131
|
+
A launch receipt only confirms delegation. Main continues independent work or
|
|
132
|
+
pauses until the completion wakes it, then finishes the requested outcome and
|
|
133
|
+
final checks. It does not poll or treat a successful launch as task completion.
|
|
134
|
+
Use stable `phaseId` values: completed phases stay owned for the parent session,
|
|
135
|
+
and interrupted phases retain ownership across reloads. Equal normalized tasks
|
|
136
|
+
in the same cwd are also rejected, even with a different `phaseId`. Reuse the
|
|
137
|
+
result, or use `subagent_message` for an additional bounded step.
|
|
120
138
|
|
|
121
139
|
Ownership includes main, individual runs, and workflow nodes still waiting on
|
|
122
140
|
dependencies. Main continues only disjoint work and passes its completed research
|
|
@@ -151,6 +169,7 @@ so no separate workflow skill needs to be loaded.
|
|
|
151
169
|
subagent_workflow({
|
|
152
170
|
workflow: "code-review",
|
|
153
171
|
inputs: { TARGET: "HEAD~1..HEAD; inspect the cache invalidation fix" },
|
|
172
|
+
wait: true,
|
|
154
173
|
});
|
|
155
174
|
|
|
156
175
|
subagent_workflow({
|
|
@@ -200,8 +219,10 @@ The final answer must end with `WORKFLOW_ACCEPTANCE: PASS` or
|
|
|
200
219
|
fails the workflow even when the reviewer process exits normally. A PASS cannot
|
|
201
220
|
clear failures in earlier work. Explicit cancellation or session interruption
|
|
202
221
|
stops the graph without starting acceptance. The graph sends one final summary
|
|
203
|
-
containing its acceptance result
|
|
204
|
-
and
|
|
222
|
+
containing its acceptance result, or returns it in the tool call with `wait: true`.
|
|
223
|
+
Waiting includes integration and acceptance, streams progress, and stops owned
|
|
224
|
+
work on parent cancellation without a background wake-up. Main still owns
|
|
225
|
+
remediation, the final gate, and release.
|
|
205
226
|
|
|
206
227
|
Phase identity includes the built-in plan and its inputs. The same deliverable
|
|
207
228
|
remains owned within its workspace; different questions or targets can run in
|
|
@@ -213,7 +234,7 @@ the same session. Inspect retained results instead of repeating completed work.
|
|
|
213
234
|
| --- | --- |
|
|
214
235
|
| `subagent_status({ id: 12 })` | Inspect a run's progress, result, and recovery paths |
|
|
215
236
|
| `subagent_status({ workflow: 3 })` | Inspect graph nodes and dependencies |
|
|
216
|
-
| `subagent_message({ id: 12, message: "Check the caller too" })` | Steer a running child, or
|
|
237
|
+
| `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 |
|
|
217
238
|
| `subagent_message({ id: 12, message: "Add the test", context: "summary" })` | Start a new next step with only a bounded summary of the earlier run |
|
|
218
239
|
| `subagent_stop({ id: "12" })` | Stop a run and retire its retained session |
|
|
219
240
|
| `subagent_stop({ workflow: 3 })` | Stop a graph and finalize its active nodes |
|
|
@@ -261,22 +282,42 @@ stops unfinished work. New/resume/fork/reload ends old children and retains inte
|
|
|
261
282
|
for manual recovery. Runs do not resume automatically; main finishes incomplete
|
|
262
283
|
work from partial changes and artifacts.
|
|
263
284
|
|
|
264
|
-
A steering
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
285
|
+
A steering call waits for the child's existing RPC channel to acknowledge the
|
|
286
|
+
matching request ID. The tool card shows **Received · queued** when Pi confirms
|
|
287
|
+
queueing, **Received · handled** when an input hook consumes the message, or
|
|
288
|
+
**Accepted · queue state unconfirmed** when no disposition is available.
|
|
289
|
+
`subagent_status` retains the latest acknowledgement, request ID, age, and message
|
|
290
|
+
summary. Rejection or a missing acknowledgement is an error, not a receipt.
|
|
291
|
+
Queueing delivers at a Pi steering boundary; it does not prove that the model
|
|
292
|
+
has executed the instruction.
|
|
293
|
+
|
|
294
|
+
To continue a successfully completed run, choose the context that fits the follow-up:
|
|
295
|
+
|
|
296
|
+
- `context: "auto"` (default) continues a private copy of the retained session
|
|
297
|
+
when available. If cleanup has removed it, the follow-up starts with a bounded
|
|
298
|
+
summary and explicitly reports that full history is unavailable. No retry is
|
|
299
|
+
needed for an expired session.
|
|
300
|
+
- `context: "session"` requires full history for rework that depends on earlier
|
|
301
|
+
details. If the session is unavailable, the call fails without starting a run.
|
|
302
|
+
- `context: "summary"` always starts fresh for a new next step, with the earlier
|
|
303
|
+
objective, final result and touched files. It cannot rely on omitted details
|
|
304
|
+
or reuse the earlier provider cache.
|
|
305
|
+
|
|
306
|
+
Session continuations retain the earlier history and provider prompt-cache key
|
|
307
|
+
(`sessionId`). Their private copy is bound to the new run's working directory,
|
|
308
|
+
including when a previous temporary worktree has already been removed. Child
|
|
309
|
+
startup and the copied session header use the same physical directory, so macOS
|
|
310
|
+
path aliases and Windows junctions do not trigger a cross-project fork prompt.
|
|
311
|
+
The continuation is instructed to re-read files before editing in the current cwd.
|
|
312
|
+
|
|
313
|
+
Every follow-up preserves the role, workspace and scope and passes through normal
|
|
314
|
+
admission and isolation. Set `wait: true` to receive its final result in the same
|
|
315
|
+
call; this waiting option applies to newly started follow-ups, while steering a
|
|
316
|
+
running child returns its acknowledgement. `subagent_status` reports whether a
|
|
317
|
+
completed run has a session available or only summary context. Results and summaries remain
|
|
318
|
+
available within the current parent runtime; completed runs are not restored
|
|
319
|
+
after reload. Pending runs cannot be steered, and fixed workflow graphs cannot
|
|
320
|
+
be edited.
|
|
280
321
|
|
|
281
322
|
Children use Pi's native `--mode rpc` CLI with piped input/output, retries, and
|
|
282
323
|
session persistence. On Windows, console hiding covers the Pi child and Node
|
|
@@ -287,29 +328,56 @@ explicit child extension installs the same policy for runtimes without Node
|
|
|
287
328
|
preloading. Windows launches stay attached so detachment cannot open a console.
|
|
288
329
|
On macOS and Linux, the policy leaves shell options unchanged; the Pi child uses
|
|
289
330
|
a separate process group for cancellation and does not launch a terminal app.
|
|
290
|
-
RPC communication and process-tree cancellation remain active.
|
|
291
|
-
|
|
331
|
+
RPC communication and process-tree cancellation remain active. Child startup
|
|
332
|
+
errors are reported as failed runs. If Windows cannot launch `taskkill`,
|
|
333
|
+
termination falls back to killing the child directly. Commands that explicitly
|
|
334
|
+
open a terminal or GUI control their own windows.
|
|
292
335
|
A settled provider failure can hand off once to the main model in the same
|
|
293
336
|
session. State and full-result files live under
|
|
294
337
|
`~/.pi/agent/ferris-pi-subagents/`, grouped by project. `PI_CODING_AGENT_DIR`
|
|
295
338
|
overrides the agent directory.
|
|
296
339
|
|
|
340
|
+
## Pi codemode compatibility
|
|
341
|
+
|
|
342
|
+
Call `subagent`, `subagent_workflow`, and the control tools directly. They use
|
|
343
|
+
Pi's `model-only` exposure and are intentionally unavailable as nested
|
|
344
|
+
`tools.subagent(...)` calls inside codemode. Children can still use codemode
|
|
345
|
+
with their inherited callable tools. Indirect tools retain their exposure;
|
|
346
|
+
scout promotes approved read-only tools for direct use. It waits up to ten
|
|
347
|
+
seconds for startup registration and activates later arrivals between turns.
|
|
348
|
+
Read-only classification uses Pi tool metadata.
|
|
349
|
+
|
|
350
|
+
Child RPC dialogs that require confirmation, selection, or text input are
|
|
351
|
+
cancelled with a matching response and an explanation, so an unattended child
|
|
352
|
+
does not hang waiting for an invisible dialog. No confirmation is approved
|
|
353
|
+
automatically.
|
|
354
|
+
|
|
297
355
|
## Storage and cleanup
|
|
298
356
|
|
|
299
357
|
Each project root holds `sessions/`, `worktrees/`, `tmp/` and `results/`. Startup
|
|
300
358
|
hygiene already drops temp leftovers, artifacts whose Pi process is gone, result
|
|
301
359
|
files past their retention window, and project roots idle for three days. Parked
|
|
302
|
-
recovery work and
|
|
360
|
+
recovery work and manifest references are protected during these sweeps.
|
|
361
|
+
Interrupted checkpoints expire after 30 days when no recorded owner or child
|
|
362
|
+
from the current boot is alive; expired checkpoints are pruned before restore.
|
|
363
|
+
Missing session files do not erase validated recovery paths. Unreadable or
|
|
364
|
+
malformed manifests leave artifacts intact and skip automatic reclamation;
|
|
365
|
+
explicit cleanup reports the error. Startup warns about failed recovery inspection
|
|
366
|
+
and continues initializing the progress widget.
|
|
303
367
|
|
|
304
368
|
Reclamation is automatic: a settlement may trigger one paced sweep (at most every
|
|
305
369
|
five minutes) that drops dead-owner artifacts, expired result files, and settled
|
|
306
370
|
session copies older than 30 minutes, then trims the oldest settled sessions
|
|
307
|
-
until a project fits its 1.5 GB budget.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
371
|
+
until a project fits its 1.5 GB budget. Under budget pressure, settled sessions
|
|
372
|
+
older than five minutes can be removed. Live runs, parked recovery work, and
|
|
373
|
+
manifest references remain protected. Automatic follow-ups use the retained
|
|
374
|
+
summary when a completed run's transcript has expired. Session shutdown waits
|
|
375
|
+
for cleanup already in progress and prevents new settlement sweeps.
|
|
376
|
+
|
|
377
|
+
`/subagents-cleanup` immediately reclaims unclaimed dead-owner artifacts and idle
|
|
378
|
+
project roots, reporting usage and freed bytes. `/subagents-cleanup dry-run`
|
|
379
|
+
measures without deleting anything. Session age and budget reclamation runs
|
|
380
|
+
automatically on settlement.
|
|
313
381
|
|
|
314
382
|
## Development
|
|
315
383
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferris1225/pi-subagents",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
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",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"prepack": "npm run check"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@earendil-works/pi-ai": ">=1.
|
|
44
|
-
"@earendil-works/pi-coding-agent": ">=1.
|
|
45
|
-
"@earendil-works/pi-tui": ">=1.
|
|
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",
|
|
46
46
|
"typebox": "*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -24,6 +24,7 @@ export interface ModelPickerItem {
|
|
|
24
24
|
value: string;
|
|
25
25
|
label: string;
|
|
26
26
|
description?: string;
|
|
27
|
+
saved?: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export type ModelListEntry = Pick<
|
|
@@ -199,19 +200,23 @@ export function buildModelPickerItems(options: {
|
|
|
199
200
|
|
|
200
201
|
const dynamic: ModelPickerItem = {
|
|
201
202
|
value: CURRENT_MAIN_MODEL,
|
|
202
|
-
label: "
|
|
203
|
-
description: "
|
|
203
|
+
label: "Follow main (dynamic)",
|
|
204
|
+
description: "Uses the main window's model, including future changes. Now: " + (mainRef ?? "Pi default") + ". No model is pinned.",
|
|
205
|
+
saved: !configuredRef,
|
|
204
206
|
};
|
|
205
207
|
const items: ModelPickerItem[] = [dynamic];
|
|
206
208
|
for (const ref of refs) {
|
|
207
209
|
const model = byRef.get(ref)!;
|
|
208
210
|
const tags = [ref === liveConfiguredRef ? "configured" : "", ref === mainRef ? "current main" : ""]
|
|
209
211
|
.filter(Boolean);
|
|
210
|
-
const name = model.name.trim()
|
|
212
|
+
const name = model.name.trim() || model.id;
|
|
213
|
+
const duplicateName = [...byRef.values()].some((other) =>
|
|
214
|
+
other.id !== model.id && other.provider === model.provider && (other.name.trim() || other.id) === name);
|
|
211
215
|
items.push({
|
|
212
216
|
value: ref,
|
|
213
|
-
label:
|
|
214
|
-
description: [
|
|
217
|
+
label: name + " · " + model.provider + (duplicateName ? " (" + model.id + ")" : ""),
|
|
218
|
+
description: ["Reference: " + ref, "Pins this model; falls back to main if unavailable or it fails.", modelCapabilities(model), ...tags].join(" · "),
|
|
219
|
+
saved: ref === liveConfiguredRef,
|
|
215
220
|
});
|
|
216
221
|
}
|
|
217
222
|
return items;
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
resolveThinkingLevel,
|
|
25
25
|
supportedThinkingLevels,
|
|
26
26
|
} from "./models.ts";
|
|
27
|
-
import {
|
|
27
|
+
import { promptMenu, promptSelectOne, type SetupItem } from "./ui.ts";
|
|
28
28
|
|
|
29
29
|
const ROLE_DEFAULT = "__role_default__";
|
|
30
30
|
const THINKING_LEVEL_HINTS: Record<ThinkingLevel, string> = {
|
|
@@ -50,29 +50,38 @@ function roleModel(ctx: ExtensionContext, config: SubagentsConfig, name: string)
|
|
|
50
50
|
return findModelByRef(availableModelsInScope(ctx), config.agentModels[name]) ?? ctx.model;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const ROLE_PURPOSE: Record<string, string> = {
|
|
54
|
+
scout: "Research with citations",
|
|
55
|
+
artisan: "Implement and verify",
|
|
56
|
+
sentinel: "Review implementation",
|
|
57
|
+
skeptic: "Challenge a named claim",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
function roleSettings(ctx: ExtensionContext, config: SubagentsConfig, name: string): SetupItem[] {
|
|
61
|
+
const selected = config.agentModels[name];
|
|
62
|
+
const model = findModelByRef(availableModelsInScope(ctx), selected);
|
|
63
|
+
const modelLabel = selected
|
|
64
|
+
? model ? model.name + " · " + model.provider : selected + " (unavailable)"
|
|
65
|
+
: "Follow main (dynamic)";
|
|
66
|
+
const preferred = config.agentThinkingLevels[name] ?? roleThinkingLevel(name);
|
|
67
|
+
const effective = resolveThinkingLevel(model ?? ctx.model, preferred);
|
|
68
|
+
const source = config.agentThinkingLevels[name] ? "override" : "role default";
|
|
69
|
+
const thinking = effective + (effective !== preferred ? " (" + preferred + " requested)" : "") + " · " + source;
|
|
70
|
+
return [
|
|
71
|
+
{ value: "model", label: "Model: " + modelLabel, description: selected
|
|
72
|
+
? "Pinned reference: " + selected + (model ? ". Falls back to main if it fails." : ". Unavailable; using main.")
|
|
73
|
+
: "Follows the main window's model, including future changes. Now: " + (currentModelRef(ctx) ?? "Pi default") + ". Choose a specific model to pin it." },
|
|
74
|
+
{ value: "thinking", label: "Thinking: " + thinking,
|
|
75
|
+
description: "Reasoning effort: " + thinking + ". Role default: " + roleThinkingLevel(name) + ". Model capabilities limit the effective level; your saved preference is kept when changing models." },
|
|
76
|
+
{ value: "reset", label: "Reset defaults", description: "Restore only " + name + " to Follow main and role-default thinking (" + roleThinkingLevel(name) + "). Saves immediately." },
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function roleItems(ctx: ExtensionContext, config: SubagentsConfig): SetupItem[] {
|
|
57
81
|
return BUILTIN_AGENT_NAMES.map((name) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const available = !selected || Boolean(model);
|
|
62
|
-
const preferred = config.agentThinkingLevels[name] ?? roleThinkingLevel(name);
|
|
63
|
-
const effective = resolveThinkingLevel(model ?? ctx.model, preferred);
|
|
64
|
-
const clamped = effective !== preferred ? " (" + preferred + " requested)" : "";
|
|
65
|
-
const overridden = Boolean(config.agentThinkingLevels[name]);
|
|
66
|
-
return {
|
|
67
|
-
role: name,
|
|
68
|
-
thinkingOverridden: overridden,
|
|
69
|
-
model: selected ? selected + (available ? "" : " (unavailable)") : "Follow main",
|
|
70
|
-
thinking: effective + clamped,
|
|
71
|
-
description: profile.remark + " Model: " + (selected
|
|
72
|
-
? (available ? "falls back to main if it fails." : "unavailable; using main.")
|
|
73
|
-
: "follows main (" + mainRef + ") dynamically.")
|
|
74
|
-
+ " Thinking: role default " + roleThinkingLevel(name) + ", clamped to the model-supported levels. Reset restores " + name + " to Follow main and that default. * marks an override.",
|
|
75
|
-
};
|
|
82
|
+
const settings = roleSettings(ctx, config, name);
|
|
83
|
+
return { value: name, label: name + " · " + ROLE_PURPOSE[name],
|
|
84
|
+
description: settings[0]!.label + "\n" + settings[1]!.label + "\n" + agentProfile(name)!.remark };
|
|
76
85
|
});
|
|
77
86
|
}
|
|
78
87
|
async function editSetting(
|
|
@@ -90,7 +99,7 @@ async function editSetting(
|
|
|
90
99
|
delete next.agentThinkingLevels[name];
|
|
91
100
|
} else if (field === "model") {
|
|
92
101
|
const choice = await promptSelectOne(ctx, name + " · Model",
|
|
93
|
-
"
|
|
102
|
+
"Follow main = dynamic · Others = pinned",
|
|
94
103
|
buildModelPickerItems({ models: availableModelsInScope(ctx), configuredRef: config.agentModels[name], mainRef: currentModelRef(ctx) }),
|
|
95
104
|
config.agentModels[name] ?? CURRENT_MAIN_MODEL);
|
|
96
105
|
if (choice === undefined) return undefined;
|
|
@@ -109,9 +118,13 @@ async function editSetting(
|
|
|
109
118
|
...supported.map((level) => ({ value: level, label: level, description: THINKING_LEVEL_HINTS[level] })),
|
|
110
119
|
];
|
|
111
120
|
const current = config.agentThinkingLevels[name];
|
|
121
|
+
if (current && !supported.includes(current)) {
|
|
122
|
+
options.push({ value: current, label: current + " (runs as " + resolveThinkingLevel(model, current) + ")",
|
|
123
|
+
description: "Saved preference; this model clamps it. Keep it for other models, or choose a supported level." });
|
|
124
|
+
}
|
|
112
125
|
const choice = await promptSelectOne(ctx, name + " · Thinking",
|
|
113
|
-
"
|
|
114
|
-
options, current
|
|
126
|
+
"Reasoning effort · saved preferences survive model changes",
|
|
127
|
+
options, current ?? ROLE_DEFAULT);
|
|
115
128
|
if (choice === undefined) return undefined;
|
|
116
129
|
if (choice === ROLE_DEFAULT) delete next.agentThinkingLevels[name];
|
|
117
130
|
else next.agentThinkingLevels[name] = choice as ThinkingLevel;
|
|
@@ -130,17 +143,23 @@ export async function runSetup(ctx: ExtensionContext, configPath: string = getCo
|
|
|
130
143
|
}
|
|
131
144
|
try {
|
|
132
145
|
let config = await loadConfig(configPath);
|
|
133
|
-
let
|
|
146
|
+
let roleFocus: string | undefined;
|
|
147
|
+
const settingFocus: Record<string, string> = {};
|
|
134
148
|
let status = "Changes save immediately";
|
|
135
149
|
while (true) {
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
const name = await promptMenu(ctx, "Subagents · Roles", status === "Changes save immediately" ? "Choose a role · " + status : status, roleItems(ctx, config), roleFocus);
|
|
151
|
+
if (name === undefined) return;
|
|
152
|
+
roleFocus = name;
|
|
153
|
+
while (true) {
|
|
154
|
+
const field = await promptMenu(ctx, name + " · Settings", status === "Changes save immediately" ? "Choose a setting · " + status : status, roleSettings(ctx, config, name), settingFocus[name]);
|
|
155
|
+
if (field === undefined) break;
|
|
156
|
+
settingFocus[name] = field;
|
|
157
|
+
const next = await editSetting(ctx, config, name, field);
|
|
158
|
+
if (!next) continue;
|
|
159
|
+
await saveConfig(next, configPath);
|
|
160
|
+
config = next;
|
|
161
|
+
status = "Saved " + name + (field === "reset" ? " defaults" : " " + field);
|
|
162
|
+
}
|
|
144
163
|
}
|
|
145
164
|
} catch (error) {
|
|
146
165
|
ctx.ui.notify("pi-subagents setup failed: " + errorMessage(error), "error");
|