@ferris1225/pi-subagents 5.0.3 → 5.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 +47 -0
- package/README.md +78 -24
- package/index.ts +3 -1
- package/package.json +1 -1
- package/skills/workflow/SKILL.md +54 -35
- package/src/configuration/config.ts +17 -21
- package/src/configuration/models.ts +3 -11
- package/src/configuration/role-migration.ts +50 -0
- package/src/configuration/ui.ts +6 -10
- package/src/delegation/builtin-agents.ts +33 -16
- package/src/delegation/dispatch.ts +22 -24
- package/src/delegation/ownership.ts +98 -0
- package/src/delegation/phase-scope.ts +4 -2
- package/src/delegation/prompt.ts +34 -19
- package/src/execution/cli-run.ts +1 -0
- package/src/execution/run-control.ts +2 -0
- package/src/execution/spawn.ts +5 -5
- package/src/isolation/worktree.ts +86 -10
- package/src/lifecycle/dispatch-core.ts +3 -3
- package/src/lifecycle/durable.ts +6 -1
- package/src/lifecycle/runtime.ts +8 -10
- package/src/lifecycle/stop.ts +20 -5
- package/src/lifecycle/thread-lifecycle.ts +35 -15
- package/src/lifecycle/thread-shared.ts +3 -1
- package/src/lifecycle/tools.ts +13 -2
- package/src/presentation/format.ts +1 -0
- package/src/presentation/widget.ts +3 -3
- package/src/workflow/durable.ts +18 -5
- package/src/workflow/engine.ts +12 -0
- package/src/workflow/files.ts +44 -3
- package/src/workflow/tool.ts +13 -10
- package/workflows/code-review.md +19 -43
- package/workflows/migration.md +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.5
|
|
4
|
+
|
|
5
|
+
### Changes
|
|
6
|
+
|
|
7
|
+
- Share writer ownership across main edit/write calls, subagent runs, and pending
|
|
8
|
+
workflow nodes. Reject conflicting batches and graphs before any child starts;
|
|
9
|
+
keep ordered nodes compatible and hold stopped claims until finalization ends.
|
|
10
|
+
- Expose phase/scope ownership and retained results in status. Keep bounded
|
|
11
|
+
ownership reminders and reuse completed research, implementation, and checks.
|
|
12
|
+
- Rename reviewer to sentinel for implementation review and critic to skeptic
|
|
13
|
+
for named claims. Migrate settings, retained records, and selected trusted
|
|
14
|
+
workflow files on disk; runtime calls and inline graphs accept only current
|
|
15
|
+
role names. Reduce the review template to one implementation review followed
|
|
16
|
+
by verification of its specific findings.
|
|
17
|
+
- Automatically isolate implementation tasks in worktrees for single calls as
|
|
18
|
+
well as batches and workflows. Keep reading and review local. Report a fallback
|
|
19
|
+
to the caller's directory only when Git or a committed HEAD is unavailable;
|
|
20
|
+
explicit worktree requests never fall back. Simplify isolation guidance and
|
|
21
|
+
leave final integration serialized without delaying independent launches.
|
|
22
|
+
- Remove the unused dispatch-mode argument from isolation selection and its
|
|
23
|
+
callers, keeping explicit overrides and fallback behavior intact.
|
|
24
|
+
- Hide Pi child console windows on Windows while preserving RPC pipes and
|
|
25
|
+
process-tree cancellation.
|
|
26
|
+
- Hide successfully completed workflows from the widget immediately while
|
|
27
|
+
preserving failures, blocked nodes, completion messages, and status results.
|
|
28
|
+
- Inline the setup picker's forwarding wrapper and simplify the two-model route
|
|
29
|
+
without changing selection, provider aliases, or fallback behavior.
|
|
30
|
+
|
|
31
|
+
## 5.0.4
|
|
32
|
+
|
|
33
|
+
### Changes
|
|
34
|
+
|
|
35
|
+
- Initialize isolated worktrees from the caller's current files so dependent
|
|
36
|
+
workflow nodes and follow-ups see integrated uncommitted changes. Use the same
|
|
37
|
+
snapshot as the integration base and preserve the caller's index and HEAD.
|
|
38
|
+
- Keep stopped writer and phase leases until children and finalization quiesce,
|
|
39
|
+
including after control timeouts and repeated stop calls.
|
|
40
|
+
- Keep review requests within their authorized outcome, focus change reviews on
|
|
41
|
+
introduced defects, and request confirmation only for material uncertainty.
|
|
42
|
+
Main checks done conditions and blockers before claiming a delegated task is done.
|
|
43
|
+
- Reduce the broad code-review workflow from five nodes to four: its critic
|
|
44
|
+
verifies findings and writes the final review. Use both review roles only when
|
|
45
|
+
their distinct questions justify the extra session.
|
|
46
|
+
- Pass the shared interface contract to every migration node and declare the
|
|
47
|
+
closing gate's write scope. Reuse completed integrated checks when still valid.
|
|
48
|
+
- Clarify retained-session follow-ups and phase ownership in the workflow skill.
|
|
49
|
+
|
|
3
50
|
## 5.0.3
|
|
4
51
|
|
|
5
52
|
### Changes
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Esc returns without applying a picker selection, and the grid keeps the focused
|
|
|
20
20
|
cell. Model pickers support search, paste, and paging.
|
|
21
21
|
|
|
22
22
|
All roles follow the main model by default; thinking defaults to `low` for scout
|
|
23
|
-
and `high` for artisan,
|
|
23
|
+
and `high` for artisan, sentinel, and skeptic. The panel distinguishes defaults from overrides and
|
|
24
24
|
shows the effective level when model capabilities clamp a preference. Changing
|
|
25
25
|
a model preserves the thinking preference. Settings live in
|
|
26
26
|
`~/.pi/agent/pi-subagents.json` as `agentModels` and `agentThinkingLevels`.
|
|
@@ -31,11 +31,26 @@ a model preserves the thinking preference. Settings live in
|
|
|
31
31
|
| --- | --- | --- |
|
|
32
32
|
| `scout` | Code, documentation, and web research with citations | Read-only tools; no commands or edits |
|
|
33
33
|
| `artisan` | Implementation and fixes with tests and checks | Parent's tool surface, including codemode |
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
| `sentinel` | Inspect an implementation or diff against requirements and callers | Parent's tool surface; instructed not to edit |
|
|
35
|
+
| `skeptic` | Test a named claim, assumption, or review finding with counterexamples | Parent's tool surface; instructed not to edit |
|
|
36
|
+
|
|
37
|
+
The main model chooses from these role descriptions; names alone do not route a
|
|
38
|
+
task. Use `sentinel` for "inspect this diff" and `skeptic` for "does this claim
|
|
39
|
+
hold?" Default to one. Both are justified only by distinct questions, such as
|
|
40
|
+
reviewing an implementation and then testing its specific findings. A skeptic
|
|
41
|
+
without a named claim reports the gap and stops instead of starting another review.
|
|
42
|
+
|
|
43
|
+
Sentinel and skeptic may run focused checks, so their no-edit boundary is an
|
|
44
|
+
instruction, not a tool-enforced restriction. Change reviews focus on introduced
|
|
45
|
+
defects; a wider audit needs an explicit brief. All roles reuse existing facts
|
|
46
|
+
and valid checks, filling gaps rather than repeating main or upstream work.
|
|
47
|
+
|
|
48
|
+
Only `scout`, `artisan`, `sentinel`, and `skeptic` are valid runtime role names.
|
|
49
|
+
Existing model/thinking settings and interrupted run records migrate on load
|
|
50
|
+
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.
|
|
39
54
|
|
|
40
55
|
Children receive a self-contained brief and project instructions, but no parent
|
|
41
56
|
conversation. They cannot delegate or release. Main owns planning, integration,
|
|
@@ -52,12 +67,17 @@ Explicit requests to work in main or avoid subagents take precedence.
|
|
|
52
67
|
Use one owner per deliverable, including its regression tests. Brief the child
|
|
53
68
|
with the outcome, done condition, relevant paths, established evidence, write
|
|
54
69
|
boundaries, required checks, and a compact expected result. Scout retrieves
|
|
55
|
-
sources; artisan implements, while
|
|
70
|
+
sources; artisan implements, while sentinel and skeptic can execute focused checks. This policy applies the context-isolation,
|
|
56
71
|
focused-role, and coordination-cost guidance in the official
|
|
57
72
|
[Codex subagents](https://developers.openai.com/codex/subagents) and
|
|
58
73
|
[Claude Code subagents](https://code.claude.com/docs/en/sub-agents) docs to Pi's
|
|
59
74
|
one-shot leaf runs.
|
|
60
75
|
|
|
76
|
+
A review request produces findings. Main applies fixes when changes are
|
|
77
|
+
authorized and requests focused confirmation only when material uncertainty
|
|
78
|
+
remains. Before reporting success, main checks each done condition and any
|
|
79
|
+
blockers in the child's answer as well as the integrated diff.
|
|
80
|
+
|
|
61
81
|
Ask Pi to delegate explicitly, or call the tools directly:
|
|
62
82
|
|
|
63
83
|
```ts
|
|
@@ -95,6 +115,21 @@ including in one-shot `pi -p` sessions. Use stable `phaseId` values: completed
|
|
|
95
115
|
phases stay owned for the parent session, and interrupted phases retain ownership
|
|
96
116
|
across reloads. Repeating the same task in the same cwd is also rejected.
|
|
97
117
|
|
|
118
|
+
Ownership includes main, individual runs, and workflow nodes still waiting on
|
|
119
|
+
dependencies. Main continues only disjoint work and passes its completed research
|
|
120
|
+
and checks into the child brief. Pending graph nodes reserve their declared write
|
|
121
|
+
scopes; external conflicts reject a batch or graph before any child starts.
|
|
122
|
+
Main `edit`/`write` calls, including nested calls through `codemode`, are blocked
|
|
123
|
+
on those scopes. In-flight main writes also prevent conflicting dispatches.
|
|
124
|
+
Stopped writers keep their claims until execution and integration finish.
|
|
125
|
+
|
|
126
|
+
These checks use declared phase identity and exact paths/symbols. Main file writes
|
|
127
|
+
conservatively conflict with any claimed symbol in that file. Omitted scopes,
|
|
128
|
+
arbitrary shell/custom-tool effects, symlink aliases, and differently worded work
|
|
129
|
+
without a shared phase id cannot be inferred reliably; this is coordination,
|
|
130
|
+
not a sandbox or semantic duplicate detector. Use `subagent_status` to inspect
|
|
131
|
+
phase/scope ownership; an exact run id also retrieves its retained result for reuse.
|
|
132
|
+
|
|
98
133
|
## Workflows
|
|
99
134
|
|
|
100
135
|
Main proactively chooses `subagent_workflow` for two or more substantial phases
|
|
@@ -120,10 +155,9 @@ subagent_workflow({
|
|
|
120
155
|
},
|
|
121
156
|
{
|
|
122
157
|
id: "review",
|
|
123
|
-
agent: "
|
|
124
|
-
isolation: "shared",
|
|
158
|
+
agent: "sentinel",
|
|
125
159
|
dependsOn: ["fix"],
|
|
126
|
-
task: "
|
|
160
|
+
task: "Inspect the implementation against the refresh contract and callers. Reuse valid checks and investigate concrete gaps. Do not edit files.\n{{fix}}",
|
|
127
161
|
},
|
|
128
162
|
],
|
|
129
163
|
});
|
|
@@ -134,8 +168,8 @@ subagent_workflow({
|
|
|
134
168
|
facts. Long answers include a full-result file. A failed node blocks its
|
|
135
169
|
dependents; independent branches continue. The graph delivers one summary.
|
|
136
170
|
|
|
137
|
-
Reviews
|
|
138
|
-
|
|
171
|
+
Reviews inspect implementations; claim verification tests named findings or
|
|
172
|
+
assumptions. Add independent verification only when its distinct work earns the cost.
|
|
139
173
|
|
|
140
174
|
Saved definitions use JSON or Markdown with a `json` fenced block:
|
|
141
175
|
|
|
@@ -147,7 +181,12 @@ subagent_workflow({ file: ".pi/workflows/code-review.md" });
|
|
|
147
181
|
Definitions load from `.pi/workflows/`, `~/.pi/agent/workflows/`, and the shipped
|
|
148
182
|
[templates](./workflows), in that order of precedence. Project definitions and
|
|
149
183
|
explicit file paths require project trust. Customize template questions, targets,
|
|
150
|
-
and scopes before running them.
|
|
184
|
+
and scopes before running them. The `code-review` template has two nodes:
|
|
185
|
+
sentinel reviews the target, then skeptic verifies only the reported claims and
|
|
186
|
+
returns the final review. An ordinary review uses one sentinel. The `migration`
|
|
187
|
+
template passes the shared interface contract to every slice and declares the
|
|
188
|
+
closing gate's write scope. Run the full integrated gate once in main or a closing
|
|
189
|
+
node, and repeat it when later edits or unresolved failures warrant it.
|
|
151
190
|
|
|
152
191
|
See the [workflow skill](./skills/workflow/SKILL.md) for graph authoring details.
|
|
153
192
|
|
|
@@ -168,24 +207,37 @@ workflow progress groups, and task rows with status and elapsed time at the righ
|
|
|
168
207
|
Activity, model, thinking, token usage, and worktree state use secondary lines as
|
|
169
208
|
space permits. Task identities take priority over detail; failed and blocked
|
|
170
209
|
work takes priority over ordinary activity. Completed nodes collapse into graph
|
|
171
|
-
progress
|
|
172
|
-
|
|
210
|
+
progress while their workflow is running. Successfully completed workflows hide
|
|
211
|
+
automatically, while failed or blocked work stays visible until the next dispatch.
|
|
212
|
+
Completion messages and status lookups retain the results. Overflow reports
|
|
213
|
+
hidden tasks. Runs preparing their child process show `starting`. There is no
|
|
214
|
+
process-count limit or shared-checkout startup
|
|
173
215
|
lock: independent runs start together, including separate dispatch calls while
|
|
174
216
|
another call awaits results.
|
|
175
217
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
218
|
+
Usually omit `isolation`: implementation tasks use detached Git worktrees in
|
|
219
|
+
single calls, parallel batches, and workflows. Reading and review use the current
|
|
220
|
+
directory. Without a Git repository or committed `HEAD`, automatic isolation uses
|
|
221
|
+
the caller's directory and reports why. Unexpected setup or integration failures
|
|
222
|
+
remain failures; an explicit `isolation: "worktree"` requires isolation and never
|
|
223
|
+
falls back. `isolation: "shared"` is an advanced override for tasks that need to
|
|
224
|
+
write directly in the caller's checkout.
|
|
225
|
+
|
|
226
|
+
Each worktree starts from the caller's current tracked files and non-ignored
|
|
227
|
+
untracked files, including uncommitted changes. Its initial snapshot is also the
|
|
228
|
+
integration base, so dependent tasks see earlier results without reapplying them.
|
|
229
|
+
The caller's index, branch, and `HEAD` stay unchanged. Declare exact write paths
|
|
230
|
+
or symbols in `scope` to detect conflicts. Worktrees isolate Git changes, not
|
|
231
|
+
tool permissions. Independent tasks start together; only the final application
|
|
232
|
+
of worktree changes to the original checkout is serialized. Integration leaves
|
|
233
|
+
your index untouched, and failures retain recovery artifacts.
|
|
184
234
|
|
|
185
235
|
Cancelling the parent run with Escape stops unfinished work without waking the
|
|
186
236
|
parent. A cancellation receipt is supplied on the next user turn with the stopped
|
|
187
237
|
run and workflow ids, so main knows no additional `subagent_stop` is needed.
|
|
188
|
-
Cancelled work must not restart automatically.
|
|
238
|
+
Cancelled work must not restart automatically. A stopped run keeps its phase
|
|
239
|
+
and declared writer leases until its child and Git finalization quiesce, even if
|
|
240
|
+
the stop call reaches its wait deadline. Conversation-tree navigation also
|
|
189
241
|
stops unfinished work. New/resume/fork/reload ends old children and retains interrupted work
|
|
190
242
|
for manual recovery. Runs do not resume automatically; main finishes incomplete
|
|
191
243
|
work from partial changes and artifacts.
|
|
@@ -208,6 +260,8 @@ admission and isolation still apply. Pending runs cannot be steered, and fixed
|
|
|
208
260
|
workflow graphs cannot be edited.
|
|
209
261
|
|
|
210
262
|
Children use Pi's native `--mode rpc` CLI, retries, and session persistence.
|
|
263
|
+
On Windows, background child console windows stay hidden; RPC communication and
|
|
264
|
+
process-tree cancellation remain active.
|
|
211
265
|
A settled provider failure can hand off once to the main model in the same
|
|
212
266
|
session. State and full-result files live under
|
|
213
267
|
`~/.pi/agent/ferris-pi-subagents/`, grouped by project. `PI_CODING_AGENT_DIR`
|
package/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { runSetup } from "./src/configuration/setup.ts";
|
|
|
27
27
|
import { loadBuiltinAgents } from "./src/delegation/agents.ts";
|
|
28
28
|
import { registerSubagentTool } from "./src/delegation/dispatch.ts";
|
|
29
29
|
import { buildDelegationDirective, installDelegationSections } from "./src/delegation/prompt.ts";
|
|
30
|
+
import { pendingWorkflowLeases, registerMainOwnershipGuard } from "./src/delegation/ownership.ts";
|
|
30
31
|
import { currentSubagentDepth } from "./src/execution/spawn.ts";
|
|
31
32
|
import { createDispatchCore } from "./src/lifecycle/dispatch-core.ts";
|
|
32
33
|
import { registerCancellationHooks } from "./src/lifecycle/cancellation.ts";
|
|
@@ -78,6 +79,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
78
79
|
registerWorkflowTool(pi, runtime, dispatchCore);
|
|
79
80
|
registerLookupTools(pi, runtime, dispatchCore);
|
|
80
81
|
registerCancellationHooks(pi, runtime);
|
|
82
|
+
registerMainOwnershipGuard(pi, runtime);
|
|
81
83
|
|
|
82
84
|
pi.registerCommand("subagents-setup", {
|
|
83
85
|
description: "Configure pi-subagents: model and thinking per role",
|
|
@@ -118,7 +120,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
118
120
|
pi.on("before_agent_start", async (event) => {
|
|
119
121
|
await runtime.durableRestore;
|
|
120
122
|
const agents = loadBuiltinAgents();
|
|
121
|
-
const sources = [...runtime.threads.values()];
|
|
123
|
+
const sources = [...runtime.threads.values(), ...pendingWorkflowLeases(runtime)];
|
|
122
124
|
const sections = event.systemPromptOptions?.sections;
|
|
123
125
|
if (sections) {
|
|
124
126
|
installDelegationSections(sections, agents, sources);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferris1225/pi-subagents",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.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",
|
package/skills/workflow/SKILL.md
CHANGED
|
@@ -50,13 +50,13 @@ confirmation, and gate nodes merely to follow a template.
|
|
|
50
50
|
```ts
|
|
51
51
|
subagent_workflow({
|
|
52
52
|
name: "auth-fix",
|
|
53
|
-
description: "Fix the refresh race and
|
|
53
|
+
description: "Fix the refresh race and inspect the implementation.",
|
|
54
54
|
nodes: [
|
|
55
55
|
{ id: "map", agent: "scout", task: "Trace the refresh race in src/auth. Cite path:line and test coverage gaps." },
|
|
56
56
|
{ id: "fix", agent: "artisan", task: "Fix the race and add its regression tests. Evidence:\n{{map}}", dependsOn: ["map"],
|
|
57
57
|
scope: { paths: ["src/auth", "test/auth.test.ts"] } },
|
|
58
|
-
{ id: "review", agent: "
|
|
59
|
-
task: "
|
|
58
|
+
{ id: "review", agent: "sentinel",
|
|
59
|
+
task: "Inspect the implementation against the refresh contract and callers. Reuse completed checks; investigate concrete gaps and report confirmed defects. Do not edit files.\n{{fix}}",
|
|
60
60
|
dependsOn: ["fix"] },
|
|
61
61
|
],
|
|
62
62
|
});
|
|
@@ -81,20 +81,22 @@ The shapes that are worth writing, in the order they usually appear:
|
|
|
81
81
|
- **Fan-out with a join.** Independent slices of one plan run at the same time; a
|
|
82
82
|
join node depends on all of them. Declare disjoint `scope.paths` per slice —
|
|
83
83
|
the compiler rejects overlapping scopes between nodes with no dependency edge.
|
|
84
|
-
- **
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- **A closing gate.**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Choose depth for the risk.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
- **Implementation review → claim verification.** A sentinel inspects the diff
|
|
85
|
+
against requirements and callers. A skeptic tests only its named findings or a
|
|
86
|
+
stated design assumption. Do not ask both for a general review. Reuse valid
|
|
87
|
+
checks; add the second phase only when independent verification earns its cost.
|
|
88
|
+
Both may run focused reproductions; scout cannot execute commands.
|
|
89
|
+
- **A closing gate.** Run the project's required checks on the integrated result
|
|
90
|
+
in main or one closing node. Keep focused regression checks with the writer;
|
|
91
|
+
reuse a completed full gate unless later edits, failures, or unresolved
|
|
92
|
+
concerns invalidate it. A separate gate node must justify its own session.
|
|
93
|
+
|
|
94
|
+
Choose depth for the risk. Use sentinel for an implementation review, skeptic
|
|
95
|
+
for a named assumption or finding, and both only for distinct questions. Every
|
|
96
|
+
extra node should deliver new evidence. Keep a fix and its regression tests with
|
|
97
|
+
one owner.
|
|
98
|
+
A review request authorizes findings; apply fixes only when changes are also
|
|
99
|
+
authorized. Request focused confirmation when material uncertainty remains.
|
|
98
100
|
|
|
99
101
|
## 4. What the runtime guarantees, and what it does not
|
|
100
102
|
|
|
@@ -133,6 +135,11 @@ A node has no access to your conversation. Its brief carries:
|
|
|
133
135
|
3. the boundary (what not to touch, what not to decide),
|
|
134
136
|
4. the output you want back.
|
|
135
137
|
|
|
138
|
+
Include shared interface contracts or their file paths in every brief that needs
|
|
139
|
+
them; saying main already established a contract does not transmit it. A settled
|
|
140
|
+
run can still report a blocker: dependents must check prerequisite outputs, and
|
|
141
|
+
main checks done conditions before claiming success.
|
|
142
|
+
|
|
136
143
|
Write the brief the way you would brief a competent colleague who was not in the
|
|
137
144
|
meeting. Name paths and symbols; do not paste file contents — every node has its
|
|
138
145
|
own file tools, and a pasted file costs tokens it could have read.
|
|
@@ -166,12 +173,20 @@ node expects to write:
|
|
|
166
173
|
- Two nodes with no dependency edge may not claim overlapping paths — the graph
|
|
167
174
|
is rejected before anything starts. A dependency edge makes the overlap
|
|
168
175
|
intentional (a fix, then its own test file).
|
|
169
|
-
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
- External writer conflicts are rejected before any node starts. All pending
|
|
177
|
+
nodes reserve their declared write scope, including while dependencies run.
|
|
178
|
+
Main `edit`/`write` calls and other dispatches respect these reservations.
|
|
179
|
+
Ordered nodes in the same graph may reuse a scope after their prerequisites
|
|
180
|
+
settle. Arbitrary commands and undeclared writes are not sandboxed.
|
|
181
|
+
- Usually omit `isolation`. Implementation nodes use a detached Git worktree,
|
|
182
|
+
initialized from the caller's current tracked and non-ignored untracked files.
|
|
183
|
+
Reading and review stay in the caller's directory. Without a Git repository or
|
|
184
|
+
committed HEAD, automatic isolation uses the current directory and reports why.
|
|
185
|
+
An explicit `worktree` override requires isolation and never falls back.
|
|
186
|
+
Each isolated snapshot is also the integration base, so nodes see integrated
|
|
187
|
+
prerequisites before commit and only their own delta is applied on settlement.
|
|
188
|
+
- A stopped run retains phase and writer leases while its child or finalization
|
|
189
|
+
can still change files, including after the stop call's bounded wait expires.
|
|
175
190
|
|
|
176
191
|
## 8. Saved definitions
|
|
177
192
|
|
|
@@ -191,23 +206,27 @@ Save a graph when it will run again, when a reviewer should read the plan before
|
|
|
191
206
|
it runs, or when the phases are long enough that you want them in version
|
|
192
207
|
control. Run it by name; do not restate it inline.
|
|
193
208
|
|
|
194
|
-
**
|
|
195
|
-
are `<workflow-slug>.<node-id
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
209
|
+
**Settled phases stay owned for the parent session; interrupted phases keep
|
|
210
|
+
ownership across reloads.** Derived phase ids are `<workflow-slug>.<node-id>`.
|
|
211
|
+
Re-running the same shape is rejected **before any node starts**, naming the
|
|
212
|
+
owning runs. For a successfully completed phase, use `subagent_message` to
|
|
213
|
+
continue the same deliverable with its retained context. Finish incomplete or
|
|
214
|
+
interrupted work in main from the retained evidence. Retire the owner with
|
|
215
|
+
`subagent_stop({ id })` only when intentionally discarding its retained session;
|
|
216
|
+
give a different deliverable its own brief and phase id. Renaming the graph does
|
|
217
|
+
not bypass exact task matching. A new session alone does not clear an interrupted
|
|
218
|
+
run's claim.
|
|
203
219
|
|
|
204
220
|
## 9. Cost
|
|
205
221
|
|
|
206
222
|
Every node is a full model session with its own context, and the summary carries
|
|
207
223
|
each node's answer. Budget accordingly:
|
|
208
224
|
|
|
209
|
-
- Give each phase one owner
|
|
210
|
-
|
|
225
|
+
- Give each phase one owner across main, subagent, and workflow, including
|
|
226
|
+
pending nodes. Main continues only disjoint work. Pass completed main findings
|
|
227
|
+
and checks into briefs; later nodes fill gaps instead of restarting research.
|
|
228
|
+
- Use sentinel for implementation defects or skeptic for a named claim. Add both
|
|
229
|
+
only for distinct questions; reuse valid checks across every owner.
|
|
211
230
|
- Keep node answers short: conclusions, paths, `command → result`.
|
|
212
231
|
- Choose nodes from independent work; do not split one tightly coupled change
|
|
213
232
|
across nodes just to increase concurrency.
|
|
@@ -234,7 +253,7 @@ One completion message per graph:
|
|
|
234
253
|
### workflow auth-fix completed (3/3 completed)
|
|
235
254
|
- map (scout) completed · run #12 · 1m02s
|
|
236
255
|
- fix (artisan) completed · run #13 · 4m11s
|
|
237
|
-
- review (
|
|
256
|
+
- review (sentinel) completed · run #15 · 2m40s
|
|
238
257
|
|
|
239
258
|
Node answers:
|
|
240
259
|
#### map
|
|
@@ -7,16 +7,17 @@
|
|
|
7
7
|
* every operational default is a constant. Parsing is defensive: invalid
|
|
8
8
|
* fields fall back to defaults instead of throwing, so a hand-edited or
|
|
9
9
|
* partially-written file can never break the extension at runtime. Unknown
|
|
10
|
-
* keys from older versions are dropped
|
|
11
|
-
* on load.
|
|
10
|
+
* top-level keys from older versions are dropped; unknown role keys are retained
|
|
11
|
+
* and legacy role names migrated. The normalized shape is persisted on load.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
15
15
|
import { dirname, join } from "node:path";
|
|
16
16
|
import { getAgentDir, withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
17
|
+
import { migrateStoredRoleKeys } from "./role-migration.ts";
|
|
17
18
|
|
|
18
19
|
/** Full catalog of agents shipped with the package; all of them always run. */
|
|
19
|
-
export const BUILTIN_AGENT_NAMES = ["scout", "artisan", "
|
|
20
|
+
export const BUILTIN_AGENT_NAMES = ["scout", "artisan", "sentinel", "skeptic"] as const;
|
|
20
21
|
|
|
21
22
|
/** Thinking levels accepted by pi's `--thinking` option. */
|
|
22
23
|
const THINKING_LEVEL_VALUES = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
@@ -30,38 +31,32 @@ export function roleThinkingLevel(agentName: string): ThinkingLevel {
|
|
|
30
31
|
case "scout":
|
|
31
32
|
return "low";
|
|
32
33
|
case "artisan":
|
|
33
|
-
case "
|
|
34
|
-
case "
|
|
34
|
+
case "sentinel":
|
|
35
|
+
case "skeptic":
|
|
35
36
|
return "high";
|
|
36
37
|
default:
|
|
37
38
|
return DEFAULT_THINKING_LEVEL;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
/**
|
|
42
|
+
/** Responsibility line shown for a built-in's selected setup row. */
|
|
42
43
|
export interface AgentProfile {
|
|
43
|
-
/** A few words for picker rows. */
|
|
44
|
-
summary: string;
|
|
45
44
|
/** What this role owns, shown for its selected setup row. */
|
|
46
45
|
remark: string;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
export const AGENT_PROFILES: Record<(typeof BUILTIN_AGENT_NAMES)[number], AgentProfile> = {
|
|
50
49
|
scout: {
|
|
51
|
-
summary: "Research · read-only",
|
|
52
50
|
remark: "Bounded code, documentation, or web research with citations. No commands or edits.",
|
|
53
51
|
},
|
|
54
52
|
artisan: {
|
|
55
|
-
summary: "Implement · code & checks",
|
|
56
53
|
remark: "Implement one substantial change with its tests and verification.",
|
|
57
54
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
remark: "Review code for actionable defects and verify findings without editing files.",
|
|
55
|
+
sentinel: {
|
|
56
|
+
remark: "Inspect an implementation or diff against requirements and callers for defects and regressions. No edits.",
|
|
61
57
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
remark: "Challenge changes or findings with counterexamples and independent verification.",
|
|
58
|
+
skeptic: {
|
|
59
|
+
remark: "Test a named claim, design assumption, or review finding with counterexamples and focused checks. No edits.",
|
|
65
60
|
},
|
|
66
61
|
};
|
|
67
62
|
|
|
@@ -89,10 +84,8 @@ export interface SubagentsConfig {
|
|
|
89
84
|
agentThinkingLevels: Record<string, ThinkingLevel>;
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
agentThinkingLevels: {},
|
|
95
|
-
};
|
|
87
|
+
/** The default every load starts from; `defaultConfig` keeps the shape in one place. */
|
|
88
|
+
export const DEFAULT_CONFIG: SubagentsConfig = defaultConfig();
|
|
96
89
|
|
|
97
90
|
export function getConfigPath(agentDir: string = getAgentDir()): string {
|
|
98
91
|
return join(agentDir, CONFIG_FILE_NAME);
|
|
@@ -110,7 +103,8 @@ function isModelReference(value: unknown): value is string {
|
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
/**
|
|
113
|
-
* Merge a raw parsed JSON value over the defaults, dropping invalid fields
|
|
106
|
+
* Merge a raw parsed JSON value over the defaults, dropping invalid fields and
|
|
107
|
+
* migrating legacy role names after validation so valid canonical values win.
|
|
114
108
|
* Exported for tests.
|
|
115
109
|
*/
|
|
116
110
|
export function normalizeConfig(raw: unknown): SubagentsConfig {
|
|
@@ -139,6 +133,8 @@ export function normalizeConfig(raw: unknown): SubagentsConfig {
|
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
135
|
|
|
136
|
+
config.agentModels = migrateStoredRoleKeys(config.agentModels);
|
|
137
|
+
config.agentThinkingLevels = migrateStoredRoleKeys(config.agentThinkingLevels);
|
|
142
138
|
return config;
|
|
143
139
|
}
|
|
144
140
|
|
|
@@ -36,8 +36,6 @@ export interface ResolvedAgentModelRoute {
|
|
|
36
36
|
primaryRef?: string;
|
|
37
37
|
/** Current main-window model when it differs from the selection. */
|
|
38
38
|
mainFallbackRef?: string;
|
|
39
|
-
/** Runtime order, useful for status/tests. */
|
|
40
|
-
candidateRefs: string[];
|
|
41
39
|
/** Configured ref skipped because Pi does not currently report it available. */
|
|
42
40
|
unavailableSelectedRef?: string;
|
|
43
41
|
}
|
|
@@ -148,16 +146,10 @@ export function resolveAgentModelRoute(input: AgentModelRouteInput): ResolvedAge
|
|
|
148
146
|
? new Set(input.availableRefs.map((ref) => ref.trim()).filter(Boolean))
|
|
149
147
|
: undefined;
|
|
150
148
|
const resolvedSelectedRef = selectedRef ? resolveLiveModelRef(selectedRef, available) : undefined;
|
|
151
|
-
const selectedAvailable = !selectedRef || resolvedSelectedRef !== undefined;
|
|
152
|
-
const usableSelectedRef = selectedAvailable ? resolvedSelectedRef : undefined;
|
|
153
|
-
const primaryRef = usableSelectedRef ?? mainRef;
|
|
154
|
-
const ordered = [primaryRef, usableSelectedRef && usableSelectedRef !== mainRef ? mainRef : undefined];
|
|
155
|
-
const candidateRefs = [...new Set(ordered.filter((ref): ref is string => Boolean(ref)))];
|
|
156
149
|
return {
|
|
157
|
-
primaryRef,
|
|
158
|
-
...(
|
|
159
|
-
|
|
160
|
-
...(!selectedAvailable && selectedRef ? { unavailableSelectedRef: selectedRef } : {}),
|
|
150
|
+
primaryRef: resolvedSelectedRef ?? mainRef,
|
|
151
|
+
...(resolvedSelectedRef && mainRef && resolvedSelectedRef !== mainRef ? { mainFallbackRef: mainRef } : {}),
|
|
152
|
+
...(selectedRef && !resolvedSelectedRef ? { unavailableSelectedRef: selectedRef } : {}),
|
|
161
153
|
};
|
|
162
154
|
}
|
|
163
155
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** One-time data migration for the role rename. Runtime dispatch accepts only
|
|
2
|
+
* current catalog names; these helpers are used only at storage boundaries. */
|
|
3
|
+
|
|
4
|
+
export function migrateStoredAgentName(name: string): string {
|
|
5
|
+
if (name === "reviewer") return "sentinel";
|
|
6
|
+
if (name === "critic") return "skeptic";
|
|
7
|
+
return name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Valid explicit new settings win; old keys disappear after persistence. */
|
|
11
|
+
export function migrateStoredRoleKeys<T>(settings: Record<string, T>): Record<string, T> {
|
|
12
|
+
const migrated = { ...settings };
|
|
13
|
+
for (const [name, value] of Object.entries(settings)) {
|
|
14
|
+
const current = migrateStoredAgentName(name);
|
|
15
|
+
if (current === name) continue;
|
|
16
|
+
if (!Object.hasOwn(migrated, current)) migrated[current] = value;
|
|
17
|
+
delete migrated[name];
|
|
18
|
+
}
|
|
19
|
+
return migrated;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function migrateField(value: unknown, key: string): boolean {
|
|
23
|
+
if (!value || typeof value !== "object") return false;
|
|
24
|
+
const record = value as Record<string, unknown>;
|
|
25
|
+
if (typeof record[key] !== "string") return false;
|
|
26
|
+
const name = record[key].trim();
|
|
27
|
+
const current = migrateStoredAgentName(name);
|
|
28
|
+
if (current === name) return false;
|
|
29
|
+
record[key] = current;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Accept saved plans or bare node arrays; never rewrite briefs or node ids. */
|
|
34
|
+
export 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. */
|
|
43
|
+
export function migrateStoredRecordRoles(value: unknown): boolean {
|
|
44
|
+
if (!value || typeof value !== "object") return false;
|
|
45
|
+
const summary = (value as { resultSummary?: unknown }).resultSummary;
|
|
46
|
+
const threadChanged = migrateField(value, "agentName");
|
|
47
|
+
const summaryChanged = migrateField(summary, "agent");
|
|
48
|
+
const nodesChanged = migrateStoredWorkflowRoles(value);
|
|
49
|
+
return threadChanged || summaryChanged || nodesChanged;
|
|
50
|
+
}
|
package/src/configuration/ui.ts
CHANGED
|
@@ -135,15 +135,6 @@ class Picker implements Component, Focusable {
|
|
|
135
135
|
invalidate(): void { this.search.invalidate(); }
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function openPicker(ctx: PickerContext, items: SelectItem[], options: PickerOptions): Promise<string | undefined> {
|
|
139
|
-
if (ctx.mode !== "tui") {
|
|
140
|
-
ctx.ui.notify("/subagents-setup requires Pi's interactive TUI.", "error");
|
|
141
|
-
return Promise.resolve(undefined);
|
|
142
|
-
}
|
|
143
|
-
return ctx.ui.custom<string | undefined>((tui, theme, keybindings, done) =>
|
|
144
|
-
new Picker(items, options, tui, theme, keybindings, done));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
138
|
/** Single-select with fuzzy search and paging. Esc returns without a change. */
|
|
148
139
|
export function promptSelectOne(
|
|
149
140
|
ctx: PickerContext,
|
|
@@ -152,7 +143,12 @@ export function promptSelectOne(
|
|
|
152
143
|
items: SelectItem[],
|
|
153
144
|
initialValue?: string,
|
|
154
145
|
): Promise<string | undefined> {
|
|
155
|
-
|
|
146
|
+
if (ctx.mode !== "tui") {
|
|
147
|
+
ctx.ui.notify("/subagents-setup requires Pi's interactive TUI.", "error");
|
|
148
|
+
return Promise.resolve(undefined);
|
|
149
|
+
}
|
|
150
|
+
return ctx.ui.custom<string | undefined>((tui, theme, keybindings, done) =>
|
|
151
|
+
new Picker(items, { title, hint, initialValue }, tui, theme, keybindings, done));
|
|
156
152
|
}
|
|
157
153
|
|
|
158
154
|
/** One role per row, with Model, Thinking and Reset side by side: the whole
|