@ferris1225/pi-subagents 5.0.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Breaking changes
6
+
7
+ - Support only the built-in `code-review`, `research`, and `migration` workflows
8
+ through `workflow` plus `inputs`. Remove inline graphs, custom names, workflow
9
+ files, and user/project workflow discovery. Keep old interrupted records
10
+ readable for recovery.
11
+ - Embed routing guidance and workflow templates in the extension. Remove the
12
+ separately loaded workflow skill and root workflow resource directory.
13
+
14
+ ### Changes
15
+
16
+ - Append one mandatory independent sentinel acceptance officer to every
17
+ workflow. Review all settled work and integration evidence, including failed
18
+ branches; require an explicit terminal PASS, and reject missing, ambiguous,
19
+ malformed, or FAIL verdicts. Cancellation skips acceptance.
20
+ - Replace ambiguous graph-source selection with direct built-in input errors.
21
+ Give different template inputs distinct phase identities while retaining
22
+ duplicate ownership for the same deliverable. Preserve brace syntax in task
23
+ inputs as literal text instead of interpreting it as graph dependencies.
24
+ - Redesign the terminal board around work progress, blocking reasons, and a
25
+ separate required-acceptance row. Keep failures visible within the 10-line
26
+ budget, preserve narrow-screen identity, and correct hidden-task counts.
27
+ - Redesign setup as a role selector with focused model/thinking details, using
28
+ side-by-side or stacked layouts. Preserve search, paging, focus, and default
29
+ versus override information. Budget setup height with the host's widget and
30
+ footer so required acceptance remains visible in a 24-row terminal.
31
+ - Preserve managed recovery references when the original checkout is temporarily
32
+ unavailable. Use stable durable identities and cross-process manifest locks
33
+ so separate windows cannot overwrite or delete each other's recovery records.
34
+ Match recovered workflow children by durable identity after local renumbering,
35
+ keep project keys stable through unavailable checkouts with aliased parent paths,
36
+ and exclude lock directories from project scans.
37
+ - Preserve concurrent recovery additions during announcements and keep newly
38
+ settled long-running sessions inside their follow-up retention window.
39
+ - Remove duplicate manifest scans and model-catalog lookups. Stop idle widget
40
+ refreshes and fix zero-width summaries and ANSI-contaminated task labels.
41
+
42
+ ## 5.0.6
43
+
44
+ ### Changes
45
+
46
+ - Hide Windows console windows for process launches inside child tools and
47
+ extensions, including `pi.exec` and inherited Node descendants. Preserve RPC
48
+ pipes, existing Node options, and macOS/Linux process-group cancellation.
49
+ - Prefer useful bounded delegation, including one artisan for a substantial
50
+ implementation without parallel work. Keep single runs, independent batches,
51
+ dependency workflows, and the two review roles distinct.
52
+ - Skip unused orchestration runtime creation in leaf processes and remove
53
+ duplicated delegation guidance. Correct transport and lifecycle comments.
54
+ - Gate publishing on checks across Windows, macOS, and Linux, with regression
55
+ coverage for shell visibility, process APIs, inherited preloads, and native Pi.
56
+
3
57
  ## 5.0.5
4
58
 
5
59
  ### Changes
package/README.md CHANGED
@@ -11,13 +11,15 @@ Requires **Pi >= 1.0.0** and **Node.js >= 22.19.0**.
11
11
  pi install npm:@ferris1225/pi-subagents
12
12
  ```
13
13
 
14
- Run `/subagents-setup` for a role grid: one row per role with **Model**,
15
- **Thinking**, and **Reset** as columns. ↑/↓ moves between roles, ←/→ between
16
- columns, and Enter edits the highlighted value. Headers align with their values,
17
- and the footer names the focused role and field; **Thinking** selects reasoning
18
- effort. Each selection saves immediately;
19
- Esc returns without applying a picker selection, and the grid keeps the focused
20
- cell. Model pickers support search, paste, and paging.
14
+ Run `/subagents-setup` for a role selector and focused settings editor. Wide
15
+ terminals place them side by side; narrow terminals stack them. ↑/↓ changes the
16
+ role, ←/→ selects **Model**, **Thinking**, or **Reset**, and Enter edits it.
17
+ The selected role shows its full model reference, effective reasoning level,
18
+ requested level when clamped, and default/override source. Each selection saves
19
+ immediately; Esc returns without applying a picker selection and keeps focus.
20
+ Model pickers support search, paste, and paging. On short terminals, PgUp/PgDn
21
+ scrolls the settings while the selected role and field stay pinned. Setup
22
+ reserves space for the workflow's required-acceptance row.
21
23
 
22
24
  All roles follow the main model by default; thinking defaults to `low` for scout
23
25
  and `high` for artisan, sentinel, and skeptic. The panel distinguishes defaults from overrides and
@@ -36,7 +38,7 @@ a model preserves the thinking preference. Settings live in
36
38
 
37
39
  The main model chooses from these role descriptions; names alone do not route a
38
40
  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
41
+ hold?" Default to one review role. Both are justified only by distinct questions, such as
40
42
  reviewing an implementation and then testing its specific findings. A skeptic
41
43
  without a named claim reports the gap and stops instead of starting another review.
42
44
 
@@ -48,9 +50,8 @@ and valid checks, filling gaps rather than repeating main or upstream work.
48
50
  Only `scout`, `artisan`, `sentinel`, and `skeptic` are valid runtime role names.
49
51
  Existing model/thinking settings and interrupted run records migrate on load
50
52
  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.
53
+ win. Custom roles and user-defined workflows are not supported. Retained records
54
+ from older releases remain available for recovery.
54
55
 
55
56
  Children receive a self-contained brief and project instructions, but no parent
56
57
  conversation. They cannot delegate or release. Main owns planning, integration,
@@ -58,11 +59,13 @@ and the final result. Keep a fix and its regression tests with one owner.
58
59
 
59
60
  ## Delegate
60
61
 
61
- Pi chooses delegation from the task structure; no special request is required.
62
- Small, familiar, or tightly coupled work stays in main. A child earns its cost
63
- when substantial bounded work benefits from parallel progress, isolating noisy
64
- research, or an independent check. Choose team size from independent work.
65
- Explicit requests to work in main or avoid subagents take precedence.
62
+ Pi proactively looks for useful bounded phases to delegate; no special request
63
+ is required. Focused ownership, isolated context, parallel progress, and an
64
+ independent check can each justify a child. A substantial self-contained fix can
65
+ go to one artisan together with its regression tests, even when there is nothing
66
+ to parallelize. Quick source checks and small understood edits stay in main.
67
+ Choose team size from independent work. Explicit requests to work in main or
68
+ avoid subagents take precedence.
66
69
 
67
70
  Use one owner per deliverable, including its regression tests. Brief the child
68
71
  with the outcome, done condition, relevant paths, established evidence, write
@@ -132,63 +135,77 @@ phase/scope ownership; an exact run id also retrieves its retained result for re
132
135
 
133
136
  ## Workflows
134
137
 
135
- Main proactively chooses `subagent_workflow` for two or more substantial phases
136
- with known dependencies and write scopes when scheduling them saves coordination.
137
- Independent phases without dependency edges use `subagent` with `tasks`; a single
138
- justified phase uses one `subagent` run. Small work stays in main.
138
+ `subagent_workflow` runs a built-in plan with named task inputs. Its only source
139
+ is the catalog in [templates.ts](./src/workflow/templates.ts): no inline `nodes`,
140
+ `file`, custom graph name, user directory, or project directory is loaded.
141
+ The model's routing rules are embedded in [prompt.ts](./src/delegation/prompt.ts),
142
+ so no separate workflow skill needs to be loaded.
139
143
 
140
- If a research result must determine the next task or its scope, run that phase
141
- first, decide in main, then reassess whether the remaining work fits a graph.
142
- A workflow runs a fixed plan; it does not discover the plan or adapt its nodes
143
- while running. Research, implementation, review, and confirmation are added only
144
- when the task needs their distinct work.
144
+ | Workflow | Work before acceptance | Required inputs |
145
+ | --- | --- | --- |
146
+ | `code-review` | Sentinel inspects the target and produces supported findings | `TARGET` |
147
+ | `research` | Three scouts investigate first-party sources, practice, and the repository; a fourth synthesizes the answer | `QUESTION` |
148
+ | `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` |
145
149
 
146
150
  ```ts
147
151
  subagent_workflow({
148
- name: "auth-fix",
149
- nodes: [
150
- {
151
- id: "fix",
152
- agent: "artisan",
153
- task: "Fix the refresh race in src/auth and add regression tests. Run the relevant checks.",
154
- scope: { paths: ["src/auth", "test/auth.test.ts"] },
155
- },
156
- {
157
- id: "review",
158
- agent: "sentinel",
159
- dependsOn: ["fix"],
160
- task: "Inspect the implementation against the refresh contract and callers. Reuse valid checks and investigate concrete gaps. Do not edit files.\n{{fix}}",
161
- },
162
- ],
152
+ workflow: "code-review",
153
+ inputs: { TARGET: "HEAD~1..HEAD; inspect the cache invalidation fix" },
163
154
  });
164
- ```
165
-
166
- `dependsOn` starts a node after its prerequisites complete and integrate.
167
- `{{id}}` inserts an upstream answer; `.status`, `.runId`, and `.error` expose its
168
- facts. Long answers include a full-result file. A failed node blocks its
169
- dependents; independent branches continue. The graph delivers one summary.
170
155
 
171
- Reviews inspect implementations; claim verification tests named findings or
172
- assumptions. Add independent verification only when its distinct work earns the cost.
156
+ subagent_workflow({
157
+ workflow: "research",
158
+ inputs: { QUESTION: "How should this repository invalidate its HTTP cache?" },
159
+ });
160
+ ```
173
161
 
174
- Saved definitions use JSON or Markdown with a `json` fenced block:
162
+ Migration inputs must name the shared interface contract, both slice briefs, and
163
+ exact write paths. Each slice owns its implementation and regression tests;
164
+ shared paths are rejected before any child starts. The integrated gate waits
165
+ for both slices and can edit their combined scope. For example:
175
166
 
176
167
  ```ts
177
- subagent_workflow({ workflow: "code-review" });
178
- subagent_workflow({ file: ".pi/workflows/code-review.md" });
168
+ subagent_workflow({
169
+ workflow: "migration",
170
+ inputs: {
171
+ TARGET: "the version 2 cache API",
172
+ CONTRACT: "docs/cache-v2.md",
173
+ CORE_CHANGE: "Update storage and its invalidation rules",
174
+ ADAPTER_CHANGE: "Update HTTP callers to the new interface",
175
+ CORE_SCOPE: "src/core",
176
+ CORE_TEST_SCOPE: "test/core",
177
+ ADAPTER_SCOPE: "src/adapters",
178
+ ADAPTER_TEST_SCOPE: "test/adapters",
179
+ },
180
+ });
179
181
  ```
180
182
 
181
- Definitions load from `.pi/workflows/`, `~/.pi/agent/workflows/`, and the shipped
182
- [templates](./workflows), in that order of precedence. Project definitions and
183
- explicit file paths require project trust. Customize template questions, targets,
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.
190
-
191
- See the [workflow skill](./skills/workflow/SKILL.md) for graph authoring details.
183
+ Choose a built-in workflow when its fixed phases fit the task. For one bounded
184
+ phase use `subagent`; for independent work use `subagent({ tasks: [...] })`.
185
+ If research must determine the next task or its scope, run it first and decide
186
+ in main. Missing, unknown, or unused template inputs are rejected with the exact
187
+ parameter names before a child starts. Task inputs remain literal, including
188
+ `{{...}}` text.
189
+
190
+ Every workflow ends with an independent **sentinel acceptance officer**. The
191
+ runtime adds this node, waits until all work has settled and integrated, and
192
+ passes a bounded evidence brief plus the complete report. Failed and blocked
193
+ branches are included. The officer reviews the delivered outcome, reuses valid
194
+ checks, and may run focused checks to close evidence gaps. It does not edit or
195
+ release. A successful code review can report defects in the target; acceptance
196
+ judges the accuracy and completeness of that review.
197
+
198
+ The final answer must end with `WORKFLOW_ACCEPTANCE: PASS` or
199
+ `WORKFLOW_ACCEPTANCE: FAIL`. A missing, ambiguous, malformed, or negative verdict
200
+ fails the workflow even when the reviewer process exits normally. A PASS cannot
201
+ clear failures in earlier work. Explicit cancellation or session interruption
202
+ stops the graph without starting acceptance. The graph sends one final summary
203
+ containing its acceptance result; main still owns remediation, the final gate,
204
+ and release.
205
+
206
+ Phase identity includes the built-in plan and its inputs. The same deliverable
207
+ remains owned within its workspace; different questions or targets can run in
208
+ the same session. Inspect retained results instead of repeating completed work.
192
209
 
193
210
  ## Status, cancellation, and recovery
194
211
 
@@ -202,18 +219,20 @@ See the [workflow skill](./skills/workflow/SKILL.md) for graph authoring details
202
219
  | `subagent_stop({ workflow: 3 })` | Stop a graph and finalize its active nodes |
203
220
  | `subagent_stop({ all: true })` | Stop all active runs and graphs |
204
221
 
205
- The widget is a compact task board capped at 10 lines: a status overview,
206
- workflow progress groups, and task rows with status and elapsed time at the right.
207
- Activity, model, thinking, token usage, and worktree state use secondary lines as
208
- space permits. Task identities take priority over detail; failed and blocked
209
- work takes priority over ordinary activity. Completed nodes collapse into graph
210
- progress while their workflow is running. Successfully completed workflows hide
211
- automatically, while failed or blocked work stays visible until the next dispatch.
222
+ The widget is a terminal task board capped at 10 lines: a quiet overview,
223
+ workflow identity and work progress, then task rows with status/time at the
224
+ right. Failures and blocked reasons get space before optional telemetry; narrow
225
+ terminals keep task identity visible. Model, thinking, token usage, and worktree
226
+ state appear as secondary detail. Each workflow has a separate **Acceptance
227
+ required** row showing pending, running, PASS, or FAIL. Acceptance does not
228
+ inflate the ordinary work count or hidden-task total. Completed work collapses
229
+ into progress while acceptance is pending; a successfully accepted workflow
230
+ hides automatically. Failed or blocked work stays until the next dispatch.
212
231
  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
215
- lock: independent runs start together, including separate dispatch calls while
216
- another call awaits results.
232
+ hidden tasks. Runs preparing their child process show `starting`. The refresh
233
+ timer runs only while visible active work needs it. There is no process-count
234
+ limit or shared-checkout startup lock: independent runs start together, including
235
+ separate dispatch calls while another call awaits results.
217
236
 
218
237
  Usually omit `isolation`: implementation tasks use detached Git worktrees in
219
238
  single calls, parallel batches, and workflows. Reading and review use the current
@@ -259,9 +278,17 @@ Both start a new run with the role, workspace and scope preserved. Queueing,
259
278
  admission and isolation still apply. Pending runs cannot be steered, and fixed
260
279
  workflow graphs cannot be edited.
261
280
 
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.
281
+ Children use Pi's native `--mode rpc` CLI with piped input/output, retries, and
282
+ session persistence. On Windows, console hiding covers the Pi child and Node
283
+ process launches made by its tools and extensions, including `pi.exec`, `pwsh`,
284
+ and `powershell`. The child preloads this policy before Pi starts and passes it
285
+ to Node descendants through `NODE_OPTIONS`, preserving existing options. An
286
+ explicit child extension installs the same policy for runtimes without Node
287
+ preloading. Windows launches stay attached so detachment cannot open a console.
288
+ On macOS and Linux, the policy leaves shell options unchanged; the Pi child uses
289
+ a separate process group for cancellation and does not launch a terminal app.
290
+ RPC communication and process-tree cancellation remain active. Commands that
291
+ explicitly open a terminal or GUI control their own windows.
265
292
  A settled provider failure can hand off once to the main model in the same
266
293
  session. State and full-result files live under
267
294
  `~/.pi/agent/ferris-pi-subagents/`, grouped by project. `PI_CODING_AGENT_DIR`
@@ -286,12 +313,24 @@ and freed bytes; `/subagents-cleanup dry-run` measures without deleting anything
286
313
 
287
314
  ## Development
288
315
 
316
+ Runtime code lives under `src/`; the package has no skill or workflow resource
317
+ directories. Built-in prompts and plans change with the code and its tests.
318
+
319
+ | Module | Responsibility |
320
+ | --- | --- |
321
+ | `delegation/` | Built-in roles, parent routing prompt, and phase/scope ownership |
322
+ | `workflow/` | Built-in templates, parameter validation, scheduling, and mandatory acceptance |
323
+ | `configuration/` | Model and thinking settings, plus the setup interface |
324
+ | `presentation/` | Running task board, activity, status, and result formatting |
325
+ | `execution/`, `lifecycle/`, `isolation/` | Child processes, durable state, cancellation, worktrees, and recovery |
326
+
289
327
  ```bash
290
328
  npm ci
291
329
  npm run check
292
330
  ```
293
331
 
294
- Pushing an unpublished package version to `main` triggers
332
+ Pushing an unpublished package version to `main` runs the checks on Windows,
333
+ macOS, and Linux before triggering
295
334
  [publishing and a GitHub Release](./.github/workflows/publish.yml).
296
335
 
297
336
  [Changelog](./CHANGELOG.md) · [MIT license](./LICENSE)
package/index.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  * The heavy lifting lives in focused modules:
6
6
  * - delegation/ — built-in roles, routing prompts, and tool contract
7
7
  * - configuration/ — persisted settings, model routes, and setup UI
8
- * - execution/ — process queue, native JSON CLI/control, and model handoff
8
+ * - execution/ — background tasks, native RPC transport, and model handoff
9
9
  * - lifecycle/ — durable threads, restoration, controls, and delivery
10
- * - workflow/ — dependency-graph plans, discovery, and the graph runner
10
+ * - workflow/ — built-in plans, dependency runner, and acceptance
11
11
  * - isolation/ — Git worktrees, recovery, and temporary-state hygiene
12
12
  * - presentation/ — announcements, formatting, monitor, and the active-run
13
13
  * widget
@@ -41,9 +41,6 @@ import { formatBytes, measureDurableUsage, runStorageCleanup } from "./src/isola
41
41
  import { getSubagentsRoot } from "./src/execution/spawn.ts";
42
42
 
43
43
  export default function (pi: ExtensionAPI): void {
44
- const configPath = getConfigPath(getAgentDir());
45
- const runtime = createRuntime(pi, configPath);
46
-
47
44
  // Recursion guard: sub-agent children are leaf processes. The `subagent` tool is
48
45
  // excluded from their toolset at spawn (--exclude-tools); this check is defense
49
46
  // in depth so a child can never expose the tool back to its model, even if
@@ -58,6 +55,9 @@ export default function (pi: ExtensionAPI): void {
58
55
  return;
59
56
  }
60
57
 
58
+ const configPath = getConfigPath(getAgentDir());
59
+ const runtime = createRuntime(pi, configPath);
60
+
61
61
  pi.registerMessageRenderer("subagent-result", (message, _options, theme) =>
62
62
  new Text(
63
63
  `${theme.fg("toolTitle", theme.bold("subagent result"))}\n${message.content}`,
@@ -72,7 +72,7 @@ export default function (pi: ExtensionAPI): void {
72
72
  });
73
73
 
74
74
  // One dispatcher serves both delegation tools, so a workflow node is an
75
- // ordinary managed run: same queue pacing, admission, isolation, and
75
+ // ordinary managed run: same lifecycle ownership, admission, isolation, and
76
76
  // durable checkpointing.
77
77
  const dispatchCore = createDispatchCore(runtime);
78
78
  registerSubagentTool(pi, runtime, dispatchCore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "5.0.5",
3
+ "version": "6.0.0",
4
4
  "description": "A managed sub-agent team for pi: research, implementation, independent review, interactive follow-ups, and Git worktree isolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,8 +25,6 @@
25
25
  "files": [
26
26
  "index.ts",
27
27
  "src",
28
- "skills",
29
- "workflows",
30
28
  "README.md",
31
29
  "CHANGELOG.md",
32
30
  "LICENSE"
@@ -34,9 +32,6 @@
34
32
  "pi": {
35
33
  "extensions": [
36
34
  "./index.ts"
37
- ],
38
- "skills": [
39
- "./skills"
40
35
  ]
41
36
  },
42
37
  "scripts": {
@@ -30,8 +30,8 @@ function migrateField(value: unknown, key: string): boolean {
30
30
  return true;
31
31
  }
32
32
 
33
- /** Accept saved plans or bare node arrays; never rewrite briefs or node ids. */
34
- export function migrateStoredWorkflowRoles(value: unknown): boolean {
33
+ /** Retained graph nodes keep their original briefs, ids, and dependencies. */
34
+ function migrateStoredWorkflowRoles(value: unknown): boolean {
35
35
  const nodes = Array.isArray(value) ? value : value && typeof value === "object" ? (value as { nodes?: unknown }).nodes : undefined;
36
36
  if (!Array.isArray(nodes)) return false;
37
37
  let changed = false;
@@ -53,12 +53,14 @@ function roleModel(ctx: ExtensionContext, config: SubagentsConfig, name: string)
53
53
  /** One row per role: every model and thinking choice stays visible together. */
54
54
  function roleRows(ctx: ExtensionContext, config: SubagentsConfig): RoleGridRow[] {
55
55
  const mainRef = currentModelRef(ctx) ?? "Pi default";
56
+ const models = availableModelsInScope(ctx);
56
57
  return BUILTIN_AGENT_NAMES.map((name) => {
57
58
  const profile = agentProfile(name)!;
58
59
  const selected = config.agentModels[name];
59
- const available = !selected || Boolean(findModelByRef(availableModelsInScope(ctx), selected));
60
+ const model = findModelByRef(models, selected);
61
+ const available = !selected || Boolean(model);
60
62
  const preferred = config.agentThinkingLevels[name] ?? roleThinkingLevel(name);
61
- const effective = resolveThinkingLevel(roleModel(ctx, config, name), preferred);
63
+ const effective = resolveThinkingLevel(model ?? ctx.model, preferred);
62
64
  const clamped = effective !== preferred ? " (" + preferred + " requested)" : "";
63
65
  const overridden = Boolean(config.agentThinkingLevels[name]);
64
66
  return {