pi-herdr-agents 1.4.1 → 1.5.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.
Files changed (35) hide show
  1. package/AGENTS.md +2 -1
  2. package/CHANGELOG.md +37 -1
  3. package/CONTEXT.md +28 -12
  4. package/README.md +61 -30
  5. package/RELEASING.md +2 -1
  6. package/agents/adversarial-reviewer.md +143 -65
  7. package/agents/reviewer.md +111 -141
  8. package/config.json.example +7 -0
  9. package/docs/README.md +3 -1
  10. package/docs/adr/0002-agent-workflow-skill-runtime-taxonomy.md +32 -21
  11. package/docs/adr/0003-installable-role-packs.md +7 -5
  12. package/docs/orchestrated-review-workflow-plan.md +46 -13
  13. package/docs/review-evaluation.md +183 -0
  14. package/docs/worktree-subagents.md +11 -5
  15. package/package.json +6 -3
  16. package/pi-extension/subagents/activity.ts +582 -443
  17. package/pi-extension/subagents/completion.ts +143 -129
  18. package/pi-extension/subagents/herdr.ts +36 -14
  19. package/pi-extension/subagents/index.ts +157 -61
  20. package/pi-extension/subagents/launch.ts +109 -77
  21. package/pi-extension/subagents/lifecycle.ts +561 -402
  22. package/pi-extension/subagents/model-config.ts +85 -70
  23. package/pi-extension/subagents/pane-config.ts +135 -0
  24. package/pi-extension/subagents/plan-skill.md +3 -2
  25. package/pi-extension/subagents/role-config.ts +96 -0
  26. package/pi-extension/subagents/runtime-routing.ts +301 -274
  27. package/pi-extension/subagents/session.ts +5 -1
  28. package/pi-extension/subagents/status.ts +473 -389
  29. package/pi-extension/subagents/subagent-done.ts +319 -287
  30. package/pi-extension/subagents/type-guards.ts +14 -11
  31. package/pi-extension/subagents/workflow-worker.js +15 -4
  32. package/pi-extension/subagents/workflow.ts +87 -75
  33. package/skills/orchestrate/SKILL.md +73 -31
  34. package/skills/orchestrate/adversarial-review-example.js +553 -0
  35. package/skills/orchestrate/adversarial-review.md +264 -0
package/AGENTS.md CHANGED
@@ -84,6 +84,7 @@ For normal changes:
84
84
 
85
85
  ```bash
86
86
  npm test
87
+ npm run format:check
87
88
  npm run lint
88
89
  npm pack --dry-run
89
90
  git diff --check
@@ -104,7 +105,7 @@ Use `PI_TEST_MODEL="openai-codex/gpt-5.6-luna" PI_TEST_TIMEOUT=180000 npm run te
104
105
  Before committing:
105
106
 
106
107
  - inspect `git status` and the final diff;
107
- - confirm the package preview includes `CHANGELOG.md`, `skills/orchestrate/SKILL.md`, and `pi-extension/subagents/workflow-worker.js`, while excluding plans, journals, sessions, prototypes, generated evidence, and local config;
108
+ - confirm the package preview includes `CHANGELOG.md`, `skills/orchestrate/SKILL.md`, `skills/orchestrate/adversarial-review.md`, `skills/orchestrate/adversarial-review-example.js`, and `pi-extension/subagents/workflow-worker.js`, while excluding plans, journals, sessions, prototypes, generated evidence, and local config;
108
109
  - run `npm pack --dry-run` when package contents or documentation paths changed;
109
110
  - confirm that no generated plans, journals, sessions, provider configuration, test scripts, or review artifacts are staged; and
110
111
  - confirm that no accidental empty directory exists at the repository root:
package/CHANGELOG.md CHANGED
@@ -7,12 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
9
9
 
10
- ## [v1.4.1](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.4.0...v1.4.1)
10
+ ## [v1.5.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.4.2...v1.5.0)
11
+
12
+ ### Merged
13
+
14
+ - Add configurable split-pane subagent launches (#16) [`#23`](https://github.com/giuseppecrj/pi-herdr-agents/pull/23)
15
+ - Close owned panes after failed subagent launches (#18) [`#22`](https://github.com/giuseppecrj/pi-herdr-agents/pull/22)
16
+ - Allow disabling bundled agent roles (#14) [`#21`](https://github.com/giuseppecrj/pi-herdr-agents/pull/21)
17
+ - Fix premature subagent completion during compaction (#17) [`#20`](https://github.com/giuseppecrj/pi-herdr-agents/pull/20)
18
+ - Harden adversarial review workflows and add evaluation coverage [`#19`](https://github.com/giuseppecrj/pi-herdr-agents/pull/19)
19
+
20
+ ### Commits
21
+
22
+ - feat: harden adversarial review workflows and evaluation [`38a69e8`](https://github.com/giuseppecrj/pi-herdr-agents/commit/38a69e80c92d684f104c22f9f435a5ae30468750)
23
+ - fix: enforce lint and format coverage for shipped review helper [`116c9ff`](https://github.com/giuseppecrj/pi-herdr-agents/commit/116c9ffd301e7b72e99feb677d11531643c0dba3)
24
+ - fix: enforce adversarial review workflow contracts [`7920e1a`](https://github.com/giuseppecrj/pi-herdr-agents/commit/7920e1ad3231a893284f716c017d918ade9d4410)
25
+ - feat: support split panes for public subagent launches [`4b9f217`](https://github.com/giuseppecrj/pi-herdr-agents/commit/4b9f2179dae252cb2ea708adcceb9219d5604181)
26
+ - fix: wait for settled agent runs before auto-exit [`b6a5ab8`](https://github.com/giuseppecrj/pi-herdr-agents/commit/b6a5ab82ad0b948194a85c3e1116e6fb4b22ffc0)
27
+ - fix: close transaction-owned panes after failed launches [`266301a`](https://github.com/giuseppecrj/pi-herdr-agents/commit/266301a30c352f4fb66802d17e9cb766d3a00b7f)
28
+ - feat: allow disabling bundled agent roles [`e866ade`](https://github.com/giuseppecrj/pi-herdr-agents/commit/e866ade49f35c7bd51931c1e216fd9749abca2e8)
29
+ - fix: distinguish role-pack replacements from bundled warnings [`d4452c8`](https://github.com/giuseppecrj/pi-herdr-agents/commit/d4452c8994c61607d2c1d1259679c1b7f7be8780)
30
+ - fix: address evaluation validator review findings [`406d1ab`](https://github.com/giuseppecrj/pi-herdr-agents/commit/406d1ab9e1a129d336ed0b850508d335b130e156)
31
+
32
+ ## [v1.4.2](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.4.1...v1.4.2) - 2026-08-31
33
+
34
+ ### Commits
35
+
36
+ - style: format source with Biome [`06d67d7`](https://github.com/giuseppecrj/pi-herdr-agents/commit/06d67d7c2fa48be6eb5ae7a11e165208da9a228e)
37
+ - style: format workflow-review integration test [`1215dc5`](https://github.com/giuseppecrj/pi-herdr-agents/commit/1215dc58db7e98abb1a18278ca892432c519f6ac)
38
+ - chore: add Biome formatter [`5b6aef3`](https://github.com/giuseppecrj/pi-herdr-agents/commit/5b6aef316c1183bf094d893c88624972762380d5)
39
+ - fix: neutralize line breaks in launch script comments [`ae3c52f`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ae3c52f4a66c9075a14526c30fe8801ab85b35f4)
40
+ - docs: align README with shipped coordinator and workflow behavior [`cc55c68`](https://github.com/giuseppecrj/pi-herdr-agents/commit/cc55c68fc1cc03a28642797eaf1a19c0317aec6c)
41
+ - chore: release v1.4.2 [`5c38516`](https://github.com/giuseppecrj/pi-herdr-agents/commit/5c38516bb78707c55682ee0e85ad991719332027)
42
+ - fix: correct the adversarial-reviewer worktree warning [`7518567`](https://github.com/giuseppecrj/pi-herdr-agents/commit/75185675d589adc3511f40722420387c2dc647fd)
43
+ - ci: run format:check in the release workflow [`bc5b998`](https://github.com/giuseppecrj/pi-herdr-agents/commit/bc5b99819833158623b115587e75c37ae8ead009)
44
+
45
+ ## [v1.4.1](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.4.0...v1.4.1) - 2026-08-31
11
46
 
12
47
  ### Commits
13
48
 
14
49
  - chore: install anti-slop lint rules [`633766b`](https://github.com/giuseppecrj/pi-herdr-agents/commit/633766b434e9558df67650b458a7d4536ac9ffd6)
15
50
  - refactor: satisfy anti-slop lint rules [`d9cbf1d`](https://github.com/giuseppecrj/pi-herdr-agents/commit/d9cbf1dbc9442971260414fd52ff20a49a2cde88)
51
+ - chore: release v1.4.1 [`49d50e2`](https://github.com/giuseppecrj/pi-herdr-agents/commit/49d50e2cd64abed8a74db46c103b22e944a5c614)
16
52
  - test: stop asserting a deterministic reviewer start order [`edd848e`](https://github.com/giuseppecrj/pi-herdr-agents/commit/edd848ee8057290a7d47f7260b65ba29d832bec5)
17
53
 
18
54
  ## [v1.4.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.3.1...v1.4.0) - 2026-08-31
package/CONTEXT.md CHANGED
@@ -53,8 +53,16 @@ A user-selected PRD, ticket set, URL, or combination that the orchestration skil
53
53
  _Avoid_: Required ticket conversion, fixed ticket graph, runtime refetch, path escape
54
54
 
55
55
  **Orchestration skill**:
56
- The user-facing native Pi skill bundled with this package that accepts an execution source, derives a workflow script, and invokes the runner only after approval.
57
- _Avoid_: Extension command, separate skill package, raw runner API
56
+ The user-facing native Pi skill bundled with this package that accepts an execution source, derives a workflow script, and invokes the runner only after approval. Its adversarial branch is a disclosed procedure in the same skill, not another engine or role.
57
+ _Avoid_: Extension command, separate skill package, raw runner API, child-authored workflow
58
+
59
+ **Adversarial review procedure**:
60
+ The preferred `orchestrate` branch for exact approved review: two routine or three distinct-lens high-risk discovery reviewers, candidate-dependent cross-family verification, then fresh synthesis. It uses the existing runner and SDK.
61
+ _Avoid_: Fixed `3 + 3 + 1`, confidence vote, new workflow engine
62
+
63
+ **Compatibility review coordinator**:
64
+ The transitional `adversarial-reviewer` role for public asynchronous child launches. It stays open across automatic result steers, counts terminal child envelopes by name, and calls `subagent_done` only after synthesis. Its Bash-enabled inspection contract is behavioral rather than an enforced read-only capability boundary.
65
+ _Avoid_: Preferred hardened path, enforced read-only runner, auto-exit coordinator
58
66
 
59
67
  **Source resolution**:
60
68
  The orchestration skill reads an execution source through capabilities already available to the parent; the extension has no built-in tracker client and stops when the source is inaccessible.
@@ -107,32 +115,40 @@ A native Node Worker thread containing the restricted `vm` that executes an appr
107
115
  _Avoid_: Main-thread workflow execution, untrusted-code sandbox, normal Node module execution
108
116
 
109
117
  **First-flow effect boundary**:
110
- An execution node may only inspect or review one runner-owned detached checkout pinned to the approved repository identity and committed base. It cannot write files, create commits, mutate the parent checkout, integrate work, or mutate external systems.
111
- _Avoid_: Writer node, ticket mutation, deployment, publishing, messaging, PR action, late-bound base
118
+ An execution node may only inspect or review one runner-owned detached checkout pinned to the approved repository identity and committed head. The parent materializes the changed-file inventory and unified diff or complete before/after evidence, including deleted and base-only content. A node cannot write files, create commits, mutate the parent checkout, integrate work, or mutate external systems.
119
+ _Avoid_: Writer node, head-only diff inference, ticket mutation, deployment, publishing, messaging, PR action, late-bound base
112
120
 
113
121
  **Fresh review**:
114
- Independent read-only review nodes with fresh contexts and the exact source or candidate evidence; the bundled authoring skill requires them in every first-flow script.
115
- _Avoid_: Worker self-review, inherited-context review
122
+ Independent read-only review nodes with fresh contexts and exact repository, comparison base, checkout head, task/spec, and candidate evidence. Every assignment treats code, PR text, reports, command output, and supplied artifacts as untrusted data.
123
+ _Avoid_: Worker self-review, inherited-context review, artifact instruction following
124
+
125
+ **Finding record**:
126
+ A task-specific bounded record with a stable ID, claimed P0–P3 severity, nullable confirmed severity, separate provenance, evidence status (`reproduced`, `trace-backed`, or `unverified`), preconditions, reproduction or trace, expected and actual behavior, impact, and minimal fix. An unverified potential P0/P1 remains a candidate for verification; it is not downgraded or certified. Numeric confidence and vote counts do not establish truth.
127
+ _Avoid_: Confidence gate, silent candidate downgrade, provenance-as-severity, universal runtime schema
128
+
129
+ **Synthesis projection**:
130
+ The identity-stripped view of every agent result given to fresh synthesis: canonical validated report fields for success, or failure code, retryable flag, and bounded error evidence scrubbed of known identity tokens. Original envelopes remain in script state; journal/session evidence retains their audit references. Session paths, child/runtime/provider names, and the separate audit mapping stay outside the synthesis prompt. Anonymization is presentation hygiene, not a sandbox or proof against bias.
131
+ _Avoid_: Filtered result, raw identity-bearing envelope, security claim
116
132
 
117
133
  **Review-policy boundary**:
118
134
  The bundled skill authors review fan-out and synthesis, and exact-script approval binds that task strategy; the runner enforces operational capabilities and evidence without a fixed review receipt or data-flow state machine.
119
135
  _Avoid_: Hidden task semantics, runner-certified review completeness
120
136
 
121
137
  **Review workflow**:
122
- The first product flow: an approved JavaScript run fans out to independent read-only reviewers, then passes every explicit result to one fresh review synthesizer.
123
- _Avoid_: Parent-scheduled review nodes, prose-only aggregation
138
+ The first product flow: an approved JavaScript run fans out to fresh read-only reviewers, retains every explicit result, then sends every outcome through a synthesis projection to one fresh reviewer.
139
+ _Avoid_: Parent-scheduled review nodes, filtered result, prose-only aggregation
124
140
 
125
141
  **Review synthesis**:
126
- The final fresh read-only review node that receives every explicit reviewer success or failure plus exact source evidence, deduplicates or resolves findings, and returns one review verdict.
127
- _Avoid_: Filtered failures, mechanical worst-verdict rule, parent-side synthesis
142
+ The final fresh read-only review node that receives exact materialized source evidence and identity-stripped projections for every discovery and verification outcome, preserves finding provenance, resolves claims from evidence, and returns one task-specific result. Reviewer aliases and a predetermined report order reduce identity/order cues while the approval packet and journal retain auditable runtime provenance.
143
+ _Avoid_: Filtered failures, raw identity metadata, mechanical worst-verdict rule, confidence voting, parent-side synthesis
128
144
 
129
145
  **Parent-guided recovery**:
130
146
  Current runtime child failures are explicit non-retryable evidence. The parent can approve a new smaller workflow for missing coverage. The bundled skill also contains one dormant same-node replacement branch, used only when a required failure explicitly has `retryable: true`; it never infers retryability from prose or runtime error text.
131
147
  _Avoid_: Error-text retry classification, silent model fallback, unbounded retries
132
148
 
133
149
  **Incomplete review**:
134
- A review-workflow task-result state chosen by the script when a declared reviewer fails; it is not a runner-owned terminal state.
135
- _Avoid_: Hidden missing coverage, runtime-wide review semantics
150
+ A review-workflow task-result state chosen by the script when drift, failure, missing or truncated evidence, malformed task output, a child-reported coverage gap, or unresolved material verification leaves coverage unknown. Valid discovery, verification, or synthesis output with `status: INCOMPLETE` propagates even through `ok: true`. It is not a runner-owned terminal state.
151
+ _Avoid_: Hidden missing coverage, runtime-wide review semantics, invented or certified-uncertain findings
136
152
 
137
153
  **Ready for integration (deferred)**:
138
154
  A possible later writer-workflow result containing retained commits, verification, and review evidence. It is not a first-flow result and cannot claim automatic acceptance.
package/README.md CHANGED
@@ -76,7 +76,7 @@ subagent({ name: "DB scout", agent: "scout", model: "<provider>/<fast-tier-id>",
76
76
  // Both return immediately; each result comes back independently.
77
77
  ```
78
78
 
79
- Use ordinary panes for read-only agents. A single or sequential writer can work in the parent checkout; give each parallel independent writing agent a unique managed worktree. See [Worktree subagents](docs/worktree-subagents.md).
79
+ Use ordinary panes for read-only agents. A single or sequential writer can work in the parent checkout; give each parallel independent writing agent a unique managed worktree. The parent acts as coordinator: decompose work, give each child one bounded outcome with its goal, allowed files, verification, and commit instruction, and keep dependent writes sequential. Children are leaves by default; the parent owns integration and final verification. See [Worktree subagents](docs/worktree-subagents.md).
80
80
 
81
81
  ## How it works
82
82
 
@@ -112,7 +112,7 @@ pi install git:github.com/giuseppecrj/pi-herdr-agents@main
112
112
 
113
113
  Smoke-test delivery with an autonomous subagent instructed to return one exact marker. Success means the marker itself—not only a generic wake-up notice—automatically appears in the parent turn.
114
114
 
115
- Subagent tabs, panes, and worktree workspaces are created without stealing keyboard focus. Launch commands target child panes by explicit ID, so focus and command delivery are independent. Note: the `interactive` option controls parent status notifications, not terminal focus.
115
+ Subagent tabs, panes, and worktree workspaces are created without stealing keyboard focus. Launch commands target child panes by explicit ID, so focus and command delivery are independent. If a fresh or resumed launch fails, the extension closes the ordinary pane that it created and preserves the original launch error. It does not close a caller-supplied surface, and managed worktree workspaces remain retained on failure. Note: the `interactive` option controls parent status notifications, not terminal focus.
116
116
 
117
117
  ## What's Included
118
118
 
@@ -162,12 +162,12 @@ The current workflow inventory is:
162
162
 
163
163
  | Workflow | Entry point | Composition, artifacts, and runtime |
164
164
  | -------- | ----------- | ----------------------------------- |
165
- | Planning | `/plan` | Scout → interactive planner → workers → reviewer; writes `.pi/plans/...` artifacts; runs on Pi. |
165
+ | Planning | `/plan` | Autonomous scout → interactive planner → workers → reviewer; writes `.pi/plans/...` artifacts; runs on Pi. |
166
166
  | Iteration | `/iterate` | Opens one interactive full-context Pi fork and returns its completion summary. |
167
167
  | Side question | `/btw`, `/btw-close` | Opens one replaceable interactive Pi side session; its answer stays outside the parent transcript. |
168
168
  | Worktree handoff | `/worktree <name> [task]`, `/worktree list` | Forks the active conversation into a long-lived interactive Pi process in a new worktree created from committed `HEAD`; retains the parent session. |
169
- | Approved review runner | `herdr_workflow` (low-level control tool) | Validates and runs exact approved project-local JavaScript with bounded read-only Pi reviewers. The bundled `orchestrate` skill authors this first-flow topology. |
170
- | Adversarial review | `adversarial-reviewer` | Transitional workflow implementation that selects eligible authenticated Pi runtimes for generic reviewer passes, verifies findings, and uses a fresh reviewer synthesis pass. It does not write artifacts in the reviewed checkout. |
169
+ | Approved review runner | `herdr_workflow` (low-level control tool) | Validates and runs exact approved project-local JavaScript with bounded read-only Pi reviewers. The bundled `orchestrate` skill authors generic and adversarial review topologies. |
170
+ | Adversarial review | `/skill:orchestrate` (preferred), `adversarial-reviewer` (compatibility) | The preferred procedure uses exact approval, a pinned runner-owned checkout, risk-based discovery, candidate-dependent verification, and fresh synthesis. The compatibility coordinator uses public asynchronous children when the hardened prerequisites are unavailable. |
171
171
 
172
172
  ### Bundled visible definitions
173
173
 
@@ -179,7 +179,7 @@ The current workflow inventory is:
179
179
  | **reviewer** | Leaf agent role | Config, then parent | Reviews changes for correctness, security, and maintainability. |
180
180
  | **visual-tester** | Leaf agent role | Config, then parent | Performs visual QA through the `chrome-cdp` skill. |
181
181
  | **poteto** | Coordinator agent role | Config, then parent | Autonomously investigates, edits minimally, delegates independent work, and verifies. |
182
- | **adversarial-reviewer** | Transitional workflow implementation | Three distinct eligible authenticated Pi model IDs, preferring provider diversity | Runs evidence-backed Optimizer and Skeptic passes through generic `reviewer` children, then a fresh reviewer synthesis pass. |
182
+ | **adversarial-reviewer** | Compatibility coordinator role | Exact eligible authenticated Pi models selected by risk and project policy | Runs two routine or three high-risk discovery reviewers, candidate-dependent cross-family verification, and fresh synthesis through public asynchronous children. |
183
183
 
184
184
  All subagents execute through Pi. Claude models remain available through normal
185
185
  Pi provider/model routing. Legacy role definitions that contain `cli` fail before
@@ -189,7 +189,7 @@ authenticated Pi `provider/model-id`.
189
189
  Optional prerequisites fail closed and are not bundled:
190
190
 
191
191
  - `visual-tester` needs an external `chrome-cdp` skill that provides `scripts/cdp.mjs`.
192
- - `adversarial-reviewer` needs three distinct exact authenticated Pi model IDs that meet project review constraints; it prefers IDs from different providers when available.
192
+ - Adversarial review needs a resolved standalone `reviewer` role, confirmed human-only authorship or known author model families, and enough distinct exact authenticated Pi models to satisfy project author-family exclusion and cross-family verification. Routine discovery uses two distinct IDs; concrete high-risk surfaces use three distinct lenses. The preferred `orchestrate` procedure fails closed when its pinned committed checkout, complete diff evidence, origin, or runtime prerequisites are unavailable. The compatibility coordinator can use a project-approved reduced topology only when it discloses the omitted coverage.
193
193
  - `/plan` uses the bundled scout and planner roles and records ordered tasks in
194
194
  `plan.md`; it does not require a researcher role, todo tool, or `write-todos` skill.
195
195
 
@@ -298,11 +298,18 @@ cp config.json.example config.json
298
298
  },
299
299
  "models": {
300
300
  "agents": {}
301
+ },
302
+ "roles": {
303
+ "bundled": true
304
+ },
305
+ "panes": {
306
+ "mode": "tab",
307
+ "direction": "right"
301
308
  }
302
309
  }
303
310
  ```
304
311
 
305
- If `config.json` is absent, status settings fall back to `config.json.example`.
312
+ If `config.json` is absent, status, role, and pane settings fall back to `config.json.example`.
306
313
  Model routing does not read the example: no model overrides apply until a real
307
314
  `config.json` exists.
308
315
 
@@ -322,6 +329,12 @@ exact IDs from your authenticated model catalog:
322
329
  }
323
330
  ```
324
331
 
332
+ Set `roles.bundled` to `false` to exclude this package's bundled role definitions from listing and exact-name launch. It defaults to `true`. Registered role packs remain available, and global and project definitions keep their existing precedence. A role-pack name collides with a bundled role only while that bundled layer is enabled; when it is disabled, the role pack can supply that name.
333
+
334
+ Set `panes.mode` to `"split"` to open ordinary public `subagent` and `subagent_resume` launches, including bare forks and `/iterate`, as splits of the stable parent pane. Set `panes.direction` to `"right"` or `"down"`; it defaults to `"right"` and is ignored when mode is `"tab"`. The default `"tab"` mode preserves existing behavior. Managed worktrees still use separate workspaces, while approved workflow readers and `/btw` keep their existing tab behavior.
335
+
336
+ Run `/reload` after changing role, model, or pane settings.
337
+
325
338
  `models.default` sets the model for subagents that do not specify a model.
326
339
  `models.agents` sets per-agent defaults, keyed by the agent name passed to
327
340
  `subagent({ agent: ... })`. Explicit `model` tool arguments take precedence,
@@ -339,7 +352,7 @@ only, to keep approved workflow runtimes deterministic.
339
352
  `config.json` is gitignored in the source tree so local overrides are not
340
353
  committed from a checkout. On an installed package root, treat it as disposable
341
354
  local state that package updates may replace. Run `/reload` after changing it;
342
- status and model configuration are loaded when the extension starts.
355
+ status, model, role, and pane configuration are loaded when the extension starts.
343
356
 
344
357
  ---
345
358
 
@@ -399,7 +412,7 @@ prompts, handoffs, and results.
399
412
 
400
413
  Use one worktree per parallel independent writing task; a single or sequential writer can work in the parent checkout, and read-only agents use ordinary panes. `cwd` selects the source Git repository, `branch` must be unique, and `base` is resolved to an exact commit before creation. If `base` is omitted, the source checkout's committed `HEAD` is used. Parent-checkout changes that have not been committed are not copied.
401
414
 
402
- A launch with `worktree` and an effective bundled `scout`, `reviewer`, or `adversarial-reviewer` returns a non-blocking warning. Scouts and reviewers normally need an ordinary pane; the adversarial reviewer is a coordinator that uses an ordinary pane for its child reviewers. To inspect or review an existing worker result, start an ordinary child in that retained worktree path. Project or global role overrides do not receive these bundled-role warnings.
415
+ A launch with `worktree` and an effective bundled `scout`, `reviewer`, or `adversarial-reviewer` returns a non-blocking warning. Scouts and reviewers normally need an ordinary pane; the adversarial reviewer is a compatibility coordinator that uses an ordinary pane for its child reviewers. To inspect or review an existing worker result, start an ordinary child in that retained worktree path. Project or global role overrides do not receive these bundled-role warnings. A `read,bash` allowlist is not an enforced read-only boundary because shell commands can mutate files; report-only roles must restrict Bash to safe inspection and avoid artifact-generating verification in the reviewed checkout.
403
416
 
404
417
  The child starts at the returned worktree root. Tell writing agents to test and commit when you want a commit-based handoff, and tell them not to push, merge, switch branches, or remove the worktree. The parent owns review and integration.
405
418
 
@@ -423,6 +436,8 @@ subagent_interrupt({ name: "Scout" });
423
436
 
424
437
  This sends Escape to the child pane, cancelling the in-progress model turn. The subagent session stays alive — the pane, session file, and background polling all remain intact. After the interrupt, the widget immediately labels the child as `interrupted` (counted as **open**, not active processing). Stale pre-interrupt activity snapshots are ignored so a lagging Herdr/`active` reading cannot overwrite the interrupt. The process elapsed timer keeps running because the pane is still open; only the interrupted-state duration freezes relative to the interrupt request. If the child starts work later, newer observations return it to `active`; completion, failure, and `caller_ping` still flow through normally.
425
438
 
439
+ `id` and `name` are each optional, but execution requires one usable target: an exact running ID or an exact, unambiguous display name. When both are supplied, `id` is used. Duplicate names are rejected.
440
+
426
441
  This is a turn-level interrupt, not a method for forcibly terminating a subagent session.
427
442
 
428
443
  ---
@@ -437,11 +452,17 @@ herdr_workflow({ action: "start", runId: "run-1" }); // after APPROVE <hash pref
437
452
  herdr_workflow({ action: "cancel", runId: "run-1" });
438
453
  ```
439
454
 
455
+ Parameters:
456
+
457
+ - `action` (required): `prepare`, `start`, or `cancel`.
458
+ - `path` (required for `prepare`): Path to the workflow script.
459
+ - `runId` (required for `cancel` and `start`): For `start`, it must match the pending run.
460
+
440
461
  ### Prepare and start contract
441
462
 
442
463
  - The script must be `<project>/.pi/plans/<run>/workflow.js` in a trusted Git repository with no existing adjacent `run.jsonl`.
443
- - Its first comment contains strict version-1 JSON metadata that binds the exact committed base, source provenance, distinct review-node IDs and their roles, authenticated `provider/model` references, thinking levels, and per-run caps that cannot exceed the fixed limits.
444
- - Fixed workflow caps: 256 KiB source, 8 agents, concurrency 4, 30-minute deadline, 100,000-character prompts, 100 logs × 4,000 characters, and 64 KiB serialized task result. Metadata may only lower caps.
464
+ - Its first comment contains strict version-1 JSON metadata that binds the exact committed base, source provenance, distinct review-node IDs and their roles, authenticated `provider/model` references, thinking levels, and the configurable `maxAgents` and `maxConcurrency` caps.
465
+ - Fixed workflow caps: 256 KiB source, 8 agents, concurrency 4, 30-minute deadline, 100,000-character prompts, 100 logs × 4,000 characters, and 64 KiB serialized task result. Metadata may lower only `maxAgents` and `maxConcurrency`.
445
466
  - Preparation validates and compiles without evaluating JavaScript, creating a journal or checkout, or launching a child. It returns the exact approval packet and keeps one pending candidate in process memory.
446
467
  - Start requires the latest real user message in the same parent session to be exactly `APPROVE <8 lowercase hex characters>`. It revalidates the complete candidate, consumes approval once, creates the append-only journal, and runs in the background.
447
468
  - Review children are fresh Pi sessions with derived read-only tools in one detached checkout pinned to the approved base. Parent uncommitted files are absent, intermediate child results stay inside the workflow, and operational failures remain explicit non-retryable evidence for parent-guided recovery.
@@ -461,7 +482,13 @@ There is no list, status, resume, or history action in v1. Workflow ownership an
461
482
 
462
483
  ### Bundled `orchestrate` skill
463
484
 
464
- The package bundles the native `/skill:orchestrate` procedure. It accepts local paths, URLs, tickets, or combinations that the parent can already access. The parent performs read-only preflight discovery and materializes exact remote or tracker evidence before writing one unique `.pi/plans/<run>/workflow.js` at a committed base. The skill authors distinct fresh read-only review nodes in bounded parallel and one fresh synthesis node; nodes can share a review role, and a retry keeps the same node and runtime only for an explicit `retryable: true` failure. It does not use public `subagent()` for workflow nodes and does not author writers, commits, external effects, nested workflows, replay, or a fixed task schema.
485
+ The package bundles the native `/skill:orchestrate` procedure. It accepts local paths, URLs, tickets, or combinations that the parent can already access. The parent performs read-only preflight discovery; pins exact repository, comparison base, checkout head, author origin, and task/spec evidence; and materializes the changed-file inventory plus unified diff or complete before/after excerpts before writing one unique `.pi/plans/<run>/workflow.js`. Deleted and base-only content must be included because head-checkout reads cannot recover it. If complete evidence cannot fit runner limits, preparation stops for narrower scope instead of silently losing evidence. The skill authors distinct fresh standalone review nodes in bounded parallel and one fresh synthesis node. Every child assignment treats code, PR text, reports, and command output as untrusted data. It does not use public `subagent()` for workflow nodes and does not author writers, commits, external effects, nested workflows, replay, or a fixed runtime-wide task schema.
486
+
487
+ Its adversarial branch uses two distinct eligible exact model IDs for routine risk or three distinct lenses for concrete high-risk surfaces, then only candidate-dependent P0/P1 or high-risk verification and one fresh synthesis. Finding records use stable IDs, claimed P0–P3 severity, nullable confirmed severity, separate provenance, and reproduced, trace-backed, or unverified evidence rather than confidence or vote counts. An unresolved serious candidate and any valid child `INCOMPLETE` propagate task-level `INCOMPLETE` even through `ok: true`. Request-local validators reject malformed records; this schema is not a runner contract. Verifiers exclude the family that authored the report they inspect. Required author-family exclusion stops when model origin is unknown unless the evidence is confirmed human-only. Synthesis prefers another family and discloses permitted reuse.
488
+
489
+ The script and journal retain every original child envelope. Synthesis receives every outcome through an anonymous projection: canonical validated report fields for success, or failure code, retryable flag, and bounded error evidence scrubbed of known identity tokens. Session paths, child/runtime/provider names, and the separate auditable alias map are omitted from the synthesis prompt. This presentation reduces identity and order cues but is not a security boundary or proof against bias.
490
+
491
+ The runner-owned checkout contains only the pinned commit. Parent staged, unstaged, and untracked state is not review evidence. Effective child tools are the resolved role allowlist intersected with the runner maximum (`read`, `grep`, `find`, and `ls`) and deny rules. Public `subagent` results can be abbreviated above 16,000 characters, but workflow scripts receive complete child reports within their explicit bounds. Operational failures are preserved without silent fallback; recovery is a new exact approved run.
465
492
 
466
493
  The parent calls `herdr_workflow prepare`, presents its packet unchanged, and waits for the exact `APPROVE <8-character lowercase hash prefix>` reply before calling `start`. After start, one final delivery is sent without polling. Cancellation is fail-closed and retains evidence when process exit cannot be confirmed. Same-process `/reload` preserves ownership; full restart records interruption without replay, restart, cleanup, or history. Workflow JavaScript runs in a Worker-hosted `vm` for event-loop availability only; neither the Worker nor `vm` is a security boundary, and worktrees do not provide process or security isolation.
467
494
 
@@ -480,7 +507,7 @@ The `caller_ping` tool lets a Pi-backed subagent request help from its parent ag
480
507
  - `sessionPath` (required): Path to the child session `.jsonl` file
481
508
  - `name` (optional): Display name for the resumed pane (defaults to `Resume`)
482
509
  - `message` (optional): Follow-up prompt to send after resuming
483
- - `autoExit` (optional): Whether the resumed session should auto-exit after its next response. Defaults to `true` for autonomous follow-up work; set `false` when resuming for an interactive handoff.
510
+ - `autoExit` (optional): Whether the resumed session should auto-exit after its next response fully settles. Defaults to `true` for autonomous follow-up work; set `false` when resuming for an interactive handoff.
484
511
 
485
512
  **Interaction flow:**
486
513
 
@@ -514,11 +541,11 @@ The `/plan` command orchestrates a full planning-to-implementation pipeline.
514
541
  ```
515
542
 
516
543
  ```
517
- Phase 1: Investigation → Quick codebase scan
544
+ Phase 1: Investigation → Autonomous scout maps the codebase
518
545
  Phase 2: Planning → Interactive planner subagent (user collaborates)
519
546
  Phase 3: Review Plan → Confirm ordered tasks, adjust if needed
520
- Phase 4: Execute → Sequential workers, or isolated parallel workers for independent tasks
521
- Phase 5: Integrate → Parent reviews and integrates worktree branches one at a time
547
+ Phase 4: Execute → Shared-checkout sequential workers by default; isolated parallel workers for independent tasks
548
+ Phase 5: Integrate → Parent reviews and integrates worktree branches one at a time, only when worktrees are used
522
549
  Phase 6: Review → Reviewer subagent checks the integrated changes
523
550
  ```
524
551
 
@@ -691,9 +718,9 @@ the files, derives package name/version from the nearest `package.json`, and
691
718
  reports invalid paths, missing descriptions, filename/name mismatches, and
692
719
  package-layer collisions in the listing surfaces.
693
720
 
694
- Role packs cannot replace bundled roles, and duplicate role names from multiple
695
- role packs are disabled rather than resolved by extension load order. Use a
696
- global or project definition for an intentional override.
721
+ Role packs cannot replace an enabled bundled role, and duplicate role names
722
+ from multiple role packs are disabled rather than resolved by extension load
723
+ order. Use a global or project definition for an intentional override.
697
724
 
698
725
  See [ADR-0003](docs/adr/0003-installable-role-packs.md) for the registration seam,
699
726
  collision rules, and rejected alternatives.
@@ -727,7 +754,7 @@ and verify them with `/subagent list` plus a smoke launch.
727
754
  | `session-mode` | string | Default child-session mode: `standalone`, `lineage-only`, or `fork` |
728
755
  | `spawning` | boolean | Set `false` to deny all subagent-spawning tools |
729
756
  | `deny-tools` | string | Comma-separated `pi-herdr-agents` tool names to suppress; this is not a universal cross-extension deny list |
730
- | `auto-exit` | boolean | Auto-shutdown when the agent finishes its turn — no `subagent_done` call needed. If the user sends any input, auto-exit is permanently disabled and the user takes over the session. Recommended for autonomous agents (scout, worker); not for interactive ones (planner). Also determines the default value of `interactive` (see below). |
757
+ | `auto-exit` | boolean | Auto-shutdown after Pi fully settles when the latest assistant turn does not end with `stopReason: "aborted"` — no `subagent_done` call needed. User input does not permanently disable auto-exit. Recommended for autonomous agents (scout, worker); not for interactive ones (planner). Also determines the default value of `interactive` (see below). |
731
758
  | `interactive` | boolean | Override whether stall/recovery transitions wake the parent session. Defaults to the inverse of `auto-exit`: autonomous agents (`auto-exit: true`) are non-interactive and get stall pings; agents without `auto-exit` are interactive and stay quiet. Explicit values take precedence. |
732
759
  | `cwd` | string | Default working directory. Absolute paths are unambiguous; relative agent-frontmatter paths resolve from Pi's agent config directory (`PI_CODING_AGENT_DIR` or `~/.pi/agent`), not the project root |
733
760
  | `disable-model-invocation` | boolean | Hide a role from discovery surfaces like `subagents_list`. The definition remains directly invocable by exact name via `subagent({ agent: "name", ... })`. |
@@ -757,12 +784,13 @@ session-mode: lineage-only
757
784
 
758
785
  ### `auto-exit`
759
786
 
760
- When set to `true`, the agent session shuts down automatically as soon as the agent finishes its turn — no explicit `subagent_done` call is needed.
787
+ When set to `true`, the agent session shuts down on Pi's `agent_settled` event unless the latest assistant message has `stopReason: "aborted"` — no explicit `subagent_done` call is needed.
761
788
 
762
789
  **Behavior:**
763
790
 
764
- - The session closes after the agent's final message (on the `agent_end` event)
765
- - If the user sends **any input** before the agent finishes, auto-exit is permanently disabled for that session — the user takes over interactively
791
+ - Low-level `agent_end` events do not close the session because Pi may still retry, compact and retry, or process a queued continuation.
792
+ - After `agent_settled`, a normal or error stop exits, while an aborted stop stays open.
793
+ - User input does not permanently disable auto-exit; the latest settled assistant stop reason determines whether the session exits.
766
794
  - The modeHint injected into the agent's task is adjusted accordingly: autonomous agents see "Complete your task autonomously." rather than instructions to call `subagent_done`
767
795
 
768
796
  **When to use:**
@@ -833,12 +861,15 @@ deny-tools: subagent
833
861
 
834
862
  ### Recommended Configuration
835
863
 
836
- | Agent | `spawning` | Rationale |
837
- | ---------- | ----------- | -------------------------------------------- |
838
- | planner | *(default)* | Legitimately spawns scouts for investigation |
839
- | worker | `false` | Should implement tasks, not delegate |
840
- | reviewer | `false` | Should review, not spawn |
841
- | scout | `false` | Should gather context, not spawn |
864
+ | Agent | `spawning` | Rationale |
865
+ | --- | --- | --- |
866
+ | planner | *(default)* | Can spawn scouts for investigation. |
867
+ | poteto | `true` | Delegates independent work. |
868
+ | adversarial-reviewer | `true` | Compatibility coordinator; launches bounded discovery, conditional verification, and synthesis children. It sets `auto-exit: false` so automatic child-result steers can drive every wave, then calls `subagent_done`. |
869
+ | worker | `false` | Implements bounded tasks. |
870
+ | reviewer | `false` | Reviews without delegation. |
871
+ | scout | `false` | Gathers context without delegation. |
872
+ | visual-tester | `false` | Performs visual QA without delegation. |
842
873
 
843
874
  ---
844
875
 
package/RELEASING.md CHANGED
@@ -21,6 +21,7 @@ Automated release gates (run by the workflow and required locally):
21
21
 
22
22
  ```bash
23
23
  npm ci
24
+ npm run format:check
24
25
  npm run lint
25
26
  npm test
26
27
  npm pack --dry-run
@@ -40,7 +41,7 @@ The optional live-provider smoke test is not a release gate:
40
41
  PI_TEST_MODEL="openai-codex/gpt-5.6-luna" PI_TEST_TIMEOUT=180000 npm run test:integration:live
41
42
  ```
42
43
 
43
- Do not release from skipped Herdr tests. Confirm the package preview includes `README.md`, `CHANGELOG.md`, `AGENTS.md`, `docs/`, `agents/`, `skills/orchestrate/SKILL.md`, and `pi-extension/subagents/workflow-worker.js`. Confirm it excludes plans, journals, sessions, prototypes, generated evidence, and local `config.json`, and that the worktree integration tests leave no test workspace behind.
44
+ Do not release from skipped Herdr tests. Confirm the package preview includes `README.md`, `CHANGELOG.md`, `AGENTS.md`, `docs/`, `agents/`, `skills/orchestrate/SKILL.md`, `skills/orchestrate/adversarial-review.md`, `skills/orchestrate/adversarial-review-example.js`, and `pi-extension/subagents/workflow-worker.js`. Confirm it excludes plans, journals, sessions, prototypes, generated evidence, and local `config.json`, and that the worktree integration tests leave no test workspace behind.
44
45
 
45
46
  ## npm authentication
46
47