pi-agent-replicate 0.0.0-stage → 1.4.1

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 (82) hide show
  1. package/AGENTS.md +27 -0
  2. package/CHANGELOG.md +152 -0
  3. package/CONTEXT.md +63 -0
  4. package/LICENSE +21 -0
  5. package/README.md +68 -2
  6. package/RELEASING.md +132 -0
  7. package/assets/banner.png +0 -0
  8. package/config.json.example +6 -0
  9. package/docs/README.md +23 -0
  10. package/docs/adr/0003-installable-role-packs.md +29 -0
  11. package/docs/adr/0008-adopt-pi-only-subagent-execution.md +22 -0
  12. package/docs/adr/0009-durable-recursive-subagent-ownership.md +23 -0
  13. package/docs/adr/0010-public-subagent-tree-registry.md +16 -0
  14. package/docs/configuration.md +14 -0
  15. package/docs/development.md +27 -0
  16. package/docs/public-subagent-tree-api.md +58 -0
  17. package/docs/retained-roles.md +71 -0
  18. package/docs/settled-lifecycle-contract.md +71 -0
  19. package/docs/worktree-subagents.md +58 -0
  20. package/examples/role-pack/extension.ts +18 -0
  21. package/examples/role-pack/package.json +16 -0
  22. package/examples/role-pack/roles/example-reviewer.md +12 -0
  23. package/index.d.ts +116 -0
  24. package/index.js +1064 -0
  25. package/index.ts +155 -0
  26. package/package.json +70 -4
  27. package/pi-extension/subagents/activity.js +575 -0
  28. package/pi-extension/subagents/activity.ts +980 -0
  29. package/pi-extension/subagents/completion.js +184 -0
  30. package/pi-extension/subagents/completion.ts +229 -0
  31. package/pi-extension/subagents/delivery-drain.js +15 -0
  32. package/pi-extension/subagents/delivery-drain.ts +20 -0
  33. package/pi-extension/subagents/delivery-files.js +86 -0
  34. package/pi-extension/subagents/delivery-files.ts +105 -0
  35. package/pi-extension/subagents/delivery-log.js +51 -0
  36. package/pi-extension/subagents/delivery-log.ts +51 -0
  37. package/pi-extension/subagents/delivery-payload.ts +55 -0
  38. package/pi-extension/subagents/delivery.ts +219 -0
  39. package/pi-extension/subagents/execution-owner.js +30 -0
  40. package/pi-extension/subagents/execution-owner.ts +38 -0
  41. package/pi-extension/subagents/herdr.js +645 -0
  42. package/pi-extension/subagents/herdr.ts +927 -0
  43. package/pi-extension/subagents/index.ts +3400 -0
  44. package/pi-extension/subagents/launch.js +774 -0
  45. package/pi-extension/subagents/launch.ts +1124 -0
  46. package/pi-extension/subagents/lifecycle.js +477 -0
  47. package/pi-extension/subagents/lifecycle.ts +582 -0
  48. package/pi-extension/subagents/lineage.js +806 -0
  49. package/pi-extension/subagents/lineage.ts +841 -0
  50. package/pi-extension/subagents/replica-background.js +32 -0
  51. package/pi-extension/subagents/replica-background.ts +38 -0
  52. package/pi-extension/subagents/replica-branch.ts +45 -0
  53. package/pi-extension/subagents/replica-directory-settings.ts +51 -0
  54. package/pi-extension/subagents/replica-history.js +22 -0
  55. package/pi-extension/subagents/replica-history.ts +21 -0
  56. package/pi-extension/subagents/replica-work.js +326 -0
  57. package/pi-extension/subagents/replica-work.ts +336 -0
  58. package/pi-extension/subagents/replica-worker.js +74 -0
  59. package/pi-extension/subagents/replica-worker.ts +71 -0
  60. package/pi-extension/subagents/replication.ts +99 -0
  61. package/pi-extension/subagents/result-delivery-queue.ts +33 -0
  62. package/pi-extension/subagents/role-catalog.js +123 -0
  63. package/pi-extension/subagents/role-catalog.ts +24 -0
  64. package/pi-extension/subagents/runtime-routing.js +154 -0
  65. package/pi-extension/subagents/runtime-routing.ts +239 -0
  66. package/pi-extension/subagents/session-binding.js +346 -0
  67. package/pi-extension/subagents/session-binding.ts +339 -0
  68. package/pi-extension/subagents/session-work.js +219 -0
  69. package/pi-extension/subagents/session-work.ts +167 -0
  70. package/pi-extension/subagents/session.js +318 -0
  71. package/pi-extension/subagents/session.ts +448 -0
  72. package/pi-extension/subagents/settled-contract.js +47 -0
  73. package/pi-extension/subagents/settled-contract.ts +175 -0
  74. package/pi-extension/subagents/source-state.js +180 -0
  75. package/pi-extension/subagents/source-state.ts +184 -0
  76. package/pi-extension/subagents/status.ts +493 -0
  77. package/pi-extension/subagents/subagent-done.js +805 -0
  78. package/pi-extension/subagents/subagent-done.ts +878 -0
  79. package/pi-extension/subagents/terminal.js +111 -0
  80. package/pi-extension/subagents/terminal.ts +208 -0
  81. package/pi-extension/subagents/watchdog.js +122 -0
  82. package/pi-extension/subagents/watchdog.ts +171 -0
package/AGENTS.md ADDED
@@ -0,0 +1,27 @@
1
+ # Pi Agent Replicate
2
+
3
+ `CONTEXT.md` holds the product intent and the contracts of the `replicate` tool. Read it before changing the tool, its schema or how it is presented. Read the matching document before changing its contract:
4
+
5
+ - `docs/settled-lifecycle-contract.md`: how child turns settle into one parent result.
6
+ - `docs/worktree-subagents.md`: worktree snapshots, joins and retained worktrees.
7
+ - `docs/public-subagent-tree-api.md`: the package-root API.
8
+ - `docs/adr/`: past decisions; don't revive removed surfaces.
9
+
10
+ Keep exactly one model-facing tool, `replicate`, with only `name` and `task` in its schema.
11
+
12
+ ## Code map
13
+
14
+ - `pi-extension/subagents/index.ts`: tools, discovery, launch/watch lifecycle and delivery.
15
+ - `pi-extension/subagents/launch.ts`: Pi and worktree launch transaction.
16
+ - `pi-extension/subagents/lineage.ts`: durable recursive ownership.
17
+ - `pi-extension/subagents/runtime-routing.ts`: role-to-parent runtime resolution.
18
+ - `pi-extension/subagents/completion.ts`, `session.ts`, `subagent-done.ts`: completion evidence.
19
+ - `index.ts`, `index.js`, `index.d.ts`: package-root API. Edit all three together.
20
+
21
+ TypeScript modules under `pi-extension/subagents` that have JavaScript mirrors must stay aligned.
22
+
23
+ ## Checks
24
+
25
+ - If `index.ts`, `index.js` or `index.d.ts` changes, run `npx tsc --noEmit index.ts` and `node --check index.js`.
26
+ - Inspect package contents with `npm pack --dry-run`.
27
+ - Run lifecycle and Herdr cases through `test/integration/run-isolated.ts` with an explicit file list (see `README.md`). Never point tests at the user's persistent Herdr server.
package/CHANGELOG.md ADDED
@@ -0,0 +1,152 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Earlier entries were generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
9
+
10
+
11
+ ## [v1.4.1](https://github.com/alexshpunt/pi-agent-replicate/compare/v1.4.0...v1.4.1) - 2026-11-01
12
+
13
+ - Rewrote the README to explain replication, inherited context, installation, and directory modes.
14
+ - Updated the package image so the full artwork fits in the Pi Packages preview.
15
+
16
+ ## v1.4.0 - 2026-11-01
17
+
18
+ First npm release of Pi Agent Replicate under its own package name.
19
+
20
+ ### Highlights
21
+
22
+ - Give a Pi agent a `replicate` tool to work on independent tasks in parallel while it continues its own work. Replica results return to the originating session.
23
+ - Use separate Git worktrees by default, or select a shared project directory with `/replica-directory` when replicas need the same files and dependencies.
24
+ - Recover replica ownership and results across reloads, with durable settlement and cleanup after descendant work drains.
25
+ - Expose the subagent tree through the package-root API for programmatic integrations.
26
+ - Introduce the Pi Agent Replicate mascot and refreshed README.
27
+
28
+ Shared-directory changes are immediately visible and are not automatically rolled back if a replica fails. Coordinate concurrent edits to avoid overwriting work.
29
+
30
+ ## [v1.3.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.2.3...v1.3.0)
31
+
32
+ ### Commits
33
+
34
+ - feat: identify workflow review nodes [`6919ab1`](https://github.com/giuseppecrj/pi-herdr-agents/commit/6919ab1c655f0e6c50944011889df14800cf2021)
35
+
36
+ ## [v1.2.3](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.2.2...v1.2.3) - 2026-08-18
37
+
38
+ ### Commits
39
+
40
+ - fix: shorten worktree labels [`4caeabb`](https://github.com/giuseppecrj/pi-herdr-agents/commit/4caeabb4db088b8c60d0caf701ec49fe538f8df2)
41
+ - docs: add release workflow skill [`9937f34`](https://github.com/giuseppecrj/pi-herdr-agents/commit/9937f3402ab672023525c19a50dee3cbd7d579bb)
42
+ - chore: release v1.2.3 [`cd5036e`](https://github.com/giuseppecrj/pi-herdr-agents/commit/cd5036e6254ee5d28d8da3ddfd55e8cc4e0db413)
43
+
44
+ ## [v1.2.2](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.2.1...v1.2.2) - 2026-08-18
45
+
46
+ ### Commits
47
+
48
+ - fix: hide completion tool from auto-exit children [`e4cad6b`](https://github.com/giuseppecrj/pi-herdr-agents/commit/e4cad6bdbe5d1952f5bb838640493c20ab332dbd)
49
+ - chore: release v1.2.2 [`ab7843b`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ab7843b4919574789029c985f27509b968242b05)
50
+
51
+ ## [v1.2.1](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.2.0...v1.2.1) - 2026-08-13
52
+
53
+ ### Commits
54
+
55
+ - docs: polish package readme and artwork [`908dd76`](https://github.com/giuseppecrj/pi-herdr-agents/commit/908dd76875c91871b8d91113e6d1633d5112d5b3)
56
+ - chore: release v1.2.1 [`df87f12`](https://github.com/giuseppecrj/pi-herdr-agents/commit/df87f126ec5cad4735c441752471aa8bd724f2e9)
57
+
58
+ ## [v1.2.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.1.0...v1.2.0) - 2026-08-13
59
+
60
+ ### Commits
61
+
62
+ - feat: add worktree session handoff [`8b6f928`](https://github.com/giuseppecrj/pi-herdr-agents/commit/8b6f928c0b61a97f66614054340a68c023df0c95)
63
+ - style: format worktree handoff changes [`c1cdc44`](https://github.com/giuseppecrj/pi-herdr-agents/commit/c1cdc4480f0e29268194bc80809959215d13044f)
64
+ - fix: confirm worktree handoff startup [`0e4a97c`](https://github.com/giuseppecrj/pi-herdr-agents/commit/0e4a97c46b6dd1d9fc56d9c74511e380dca6e6d0)
65
+ - feat: simplify worktree command [`4dc88e0`](https://github.com/giuseppecrj/pi-herdr-agents/commit/4dc88e0a962625eec10240d57cf67548510e6a9a)
66
+ - docs: add worktree handoff research [`00f95c6`](https://github.com/giuseppecrj/pi-herdr-agents/commit/00f95c65e0f050492259a0de625c35e4eef9aae8)
67
+ - test: cover failed worktree handoff recovery [`dd27c0a`](https://github.com/giuseppecrj/pi-herdr-agents/commit/dd27c0a8f17e51cff635e5b77e18ff7f05896650)
68
+ - chore: release v1.2.0 [`dba1ab5`](https://github.com/giuseppecrj/pi-herdr-agents/commit/dba1ab5564b9ef64ae1f0f57b6df4bb40502970c)
69
+ - ci: upgrade release actions to node24 [`ec9158d`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ec9158d838cb0fae914c94fc448a6677b4ab1696)
70
+
71
+ ## [v1.1.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v1.0.0...v1.1.0) - 2026-08-11
72
+
73
+ ### Commits
74
+
75
+ - chore: initialize generated changelog [`77ca8eb`](https://github.com/giuseppecrj/pi-herdr-agents/commit/77ca8eb000e1d06f6d23bfbd8fdcac491bef581d)
76
+ - feat: label coordinated subagents [`e2d15ab`](https://github.com/giuseppecrj/pi-herdr-agents/commit/e2d15abf2cbe9f0557d14ab768dd39e64352577e)
77
+ - chore: release v1.1.0 [`732c0dc`](https://github.com/giuseppecrj/pi-herdr-agents/commit/732c0dcef0f0a85be737b9dd6023a59eb2771178)
78
+
79
+ ## [v1.0.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.1.4...v1.0.0) - 2026-08-11
80
+
81
+ ### Commits
82
+
83
+ - refactor: extract fresh Pi launch transaction [`2241084`](https://github.com/giuseppecrj/pi-herdr-agents/commit/22410845f8b62765fd2ac391cbd94156010abba6)
84
+ - refactor: remove external CLI subagent execution [`9c31fe7`](https://github.com/giuseppecrj/pi-herdr-agents/commit/9c31fe7e566c1fdb3fa8ac3c8a5879fbc25f0fb8)
85
+ - refactor: route Pi session resumes through launch module [`f16f42b`](https://github.com/giuseppecrj/pi-herdr-agents/commit/f16f42b003813852039be9ec1e91b65f28b87bb6)
86
+ - refactor: deliver subagent results through one message [`52c4e02`](https://github.com/giuseppecrj/pi-herdr-agents/commit/52c4e029bbe39170d16a0178b369ab2f68a2d40d)
87
+ - test: stabilize asynchronous subagent integration [`3d2cebb`](https://github.com/giuseppecrj/pi-herdr-agents/commit/3d2cebb41894f2c66038d636998a9b2e0b781431)
88
+ - _No commit message_ [`d5a5c2d`](https://github.com/giuseppecrj/pi-herdr-agents/commit/d5a5c2d0baa1b25a362e0c02de5f6d48342d9393)
89
+ - updates [`e345303`](https://github.com/giuseppecrj/pi-herdr-agents/commit/e345303338857ca19b8ce880c0707173505ad78b)
90
+ - chore: release v1.0.0 [`ccc0045`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ccc0045f3bd6b937bf6acd238b97fe48341bd8ba)
91
+ - merge: deepen Pi subagent launch and resume [`674da9d`](https://github.com/giuseppecrj/pi-herdr-agents/commit/674da9dc5d752deca3538c0d8d7ffdbdecc00a4c)
92
+
93
+ ## [v0.1.4](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.1.3...v0.1.4) - 2026-08-10
94
+
95
+ ### Commits
96
+
97
+ - chore: release v0.1.4 [`0ce2fe4`](https://github.com/giuseppecrj/pi-herdr-agents/commit/0ce2fe45b3c76a2bffe1df561076d1c62537c139)
98
+
99
+ ## [v0.1.3](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.1.2...v0.1.3) - 2026-08-07
100
+
101
+ ### Commits
102
+
103
+ - fix: reject empty workflow completions [`338a788`](https://github.com/giuseppecrj/pi-herdr-agents/commit/338a788855c9ea7ac8b3f6214ff8b3130bc4b007)
104
+ - test: verify fallback completion from session evidence [`b2eb4b0`](https://github.com/giuseppecrj/pi-herdr-agents/commit/b2eb4b0fec5bd7d5ec9f473168cf3710e600052d)
105
+ - chore: release v0.1.3 [`a2cd1b5`](https://github.com/giuseppecrj/pi-herdr-agents/commit/a2cd1b5ab424226e371ee6388e79d8ccf3e9a304)
106
+
107
+ ## [v0.1.2](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.1.1...v0.1.2) - 2026-08-07
108
+
109
+ ### Commits
110
+
111
+ - chore: release v0.1.2 [`67608a5`](https://github.com/giuseppecrj/pi-herdr-agents/commit/67608a5b1950222b522277c2fb4a246cbffb91f8)
112
+
113
+ ## [v0.1.1](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.1.0...v0.1.1) - 2026-08-07
114
+
115
+ ### Commits
116
+
117
+ - fix: wait for Herdr shell readiness [`58bfa99`](https://github.com/giuseppecrj/pi-herdr-agents/commit/58bfa99c150963b4c7f7cc8348b8e2ead00399af)
118
+ - chore: release v0.1.1 [`9b9a3c9`](https://github.com/giuseppecrj/pi-herdr-agents/commit/9b9a3c9ded45f65be7c2814cb34230ee5bf82532)
119
+
120
+ ## [v0.1.0](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.0.4...v0.1.0) - 2026-08-05
121
+
122
+ ### Commits
123
+
124
+ - feat: add ordered subagent model fallbacks [`2ce041b`](https://github.com/giuseppecrj/pi-herdr-agents/commit/2ce041b51f1eb1906623bc0c361fea6a3acf019d)
125
+ - chore: release v0.1.0 [`b409457`](https://github.com/giuseppecrj/pi-herdr-agents/commit/b409457f58b738734b48a4e7cf3418da957db271)
126
+
127
+ ## [v0.0.4](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.0.3...v0.0.4) - 2026-08-05
128
+
129
+ ### Merged
130
+
131
+ - agents: extract Claude CLI adapter [`#5`](https://github.com/giuseppecrj/pi-herdr-agents/pull/5)
132
+
133
+ ### Commits
134
+
135
+ - release: update version to 0.0.4 [`c685c35`](https://github.com/giuseppecrj/pi-herdr-agents/commit/c685c3553ec76d987972c1786d966b704ad9197b)
136
+
137
+ ## [v0.0.3](https://github.com/giuseppecrj/pi-herdr-agents/compare/v0.0.2...v0.0.3) - 2026-08-05
138
+
139
+ ### Commits
140
+
141
+ - docs: enhance documentation for adversarial-reviewer and runtime adapter policies; clarify model selection process and permissions [`ddf4a34`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ddf4a3411e018c7335bc66e191d5d84b187d8d07)
142
+ - agents: remove bundled Claude reviewer adapter [`ed12ddf`](https://github.com/giuseppecrj/pi-herdr-agents/commit/ed12ddf774046dd0a708fd54d53f12d25118d006)
143
+ - docs: align release baseline with 0.0.2 [`c136b16`](https://github.com/giuseppecrj/pi-herdr-agents/commit/c136b1659370bc4265b1ed4c67c2b670c764a8b1)
144
+ - release: update version to 0.0.3 [`c6ce52c`](https://github.com/giuseppecrj/pi-herdr-agents/commit/c6ce52c6af3b9a3157c073aa257ea69f826597ad)
145
+
146
+ ## v0.0.2 - 2026-08-05
147
+
148
+ ### Commits
149
+
150
+ - feat: launch Pi Herdr Agents 0.2.0 [`4fa3f26`](https://github.com/giuseppecrj/pi-herdr-agents/commit/4fa3f26d743defa68ce1c068fbc80cc5f3062934)
151
+ - release: prepare 0.0.2 [`5d6e65d`](https://github.com/giuseppecrj/pi-herdr-agents/commit/5d6e65d4c25a8df427dd057b77267985bb505d1a)
152
+ - update version [`4ffd68f`](https://github.com/giuseppecrj/pi-herdr-agents/commit/4ffd68f55f58cedbfb9fd84cd139f81c107552eb)
package/CONTEXT.md ADDED
@@ -0,0 +1,63 @@
1
+ # Project context
2
+
3
+ `pi-agent-replicate` lets an agent split independent work into copies of its current Pi session in Herdr.
4
+
5
+ ## Shipped surface
6
+
7
+ The experimental model-facing surface is exactly one tool: `replicate({ name, task })`. Its schema never gains continuation parameters. One invocation creates one fresh copy in a pane, using a dedicated worktree by default or the parent directory when configured for the project. A user command selects the directory mode. The package ships no bundled roles, review workflows or orchestration skills.
8
+
9
+ The old model-facing role, completion and help tools are removed. The internal launcher and package-root tree API remain available for callers that need custom roles, bare children or managed worktrees. Their contracts are separate from replication.
10
+
11
+ ## Replication
12
+
13
+ Replication is parallel work by copies of one agent, not delegation. The caller must already be at its intended working location and understand the task. It must identify independent parts, specify the copy's work and expected result, and continue a different part itself. Do not replicate while deciding the task or just to wait. Waiting after completing useful parallel work is allowed.
14
+
15
+ Use progressive disclosure. The initial description explains purpose and use, not Git, worktrees, checkpoints, delivery routing or host mechanics. Results retain a full summary without host reference footers or saved-copy choices. A failure or conflict explains the work problem. The parent continues with that information or creates a fresh replica.
16
+
17
+ A clone inherits the parent's model, thinking level, full system prompt, active tools and current active conversation, including the triggering user turn. Explicit CLI extensions follow it. The snapshot is captured before asynchronous launch work, so another turn or sibling tool result cannot change its context. Inherited pending tool calls are settled without executing them again.
18
+
19
+ Copied extension control state must not wake a parent-side background operation before the replica receives its own assignment. Keep the active conversation, not ownership of the parent's pending operations.
20
+
21
+ The bounded assignment, parallel-copy identity and required summary belong in a normal task message. Internal original-session references stay in host metadata. Replication must not change the system prompt or its cache prefix. There are no role, model, cwd, worktree or batch choices on this tool.
22
+
23
+ By default each clone gets a source snapshot with tracked working files and nonignored untracked files. The host uses a private index and protected checkpoint refs without changing parent HEAD or staging. Ignored files are not copied. Worktrees isolate files, not shared processes, ports or databases. The project can instead select a shared directory for new clones: no source snapshot or join is made, files are immediately shared, and failure does not undo changes. A clone can replicate its own independent work. It remains responsible until its descendants drain, then returns a nonempty final summary. No help or explicit completion tool is registered for clones.
24
+
25
+ The immediate parent's host saves completion and session evidence. In worktree mode it also saves source evidence; only successful children attempt a three-way join after their descendants drain. Sibling joins are serial, including across overlapping Pi incarnations. Costly replica checkpoint, join and cleanup work runs in a separate host process so it cannot block Pi's input or model loop. Durable ownership gates and existing journals recover interrupted work. Revalidate the original parent's location before file application and delivery. Task completion and integration are separate outcomes. A Git-clean join does not prove program correctness. Conflicts apply no child files; failures and empty summaries never auto-join partial work. Saved work remains available for manual resolution and recovery.
26
+
27
+ Every settled replica closes its owned pane and empty Herdr workspace after descendant drain and process exit, including failure and conflict. Failed or unjoined checkouts and saved sessions remain available for recovery. Applied worktrees are removed only after durable integration and checkpointing, verified ownership and process exit. Later edits or uncertain ownership prevent removal. Sessions and source checkpoints remain reconstructable. Closed parents defer successful joins until their exact session reopens.
28
+
29
+ Each invocation uses fresh source and conversation from the immediate parent. Model-facing resume and fork choices are removed; internal saved sessions and checkpoints remain recovery evidence. Terminal model failure is also terminal: report honest error facts and a file of every post-fork textual assistant answer. Exclude inherited answers, tool calls, tool results and hidden reasoning. Do not truncate the history. An empty required summary is a failure.
30
+
31
+ The caller must choose an explicit task-specific name in lowercase kebab-case for every invocation. Reject missing or invalid names before launch. The runtime adds the immediate parent's origin as `task-name ← parent-name`, using the first nonempty parent session name, current Herdr pane name, or project directory name. Do not generate task names or copy numbers. Keep the same combined title in the child session, host surfaces, status, and result; internal IDs still own recovery and delivery.
32
+
33
+ New replica branches must show their origin and supplied task name as `replica/<origin>/<name>`, not an opaque copy ID. Use a lowercase ASCII origin slug, transliterating Cyrillic so Herdr does not drop the origin from the checkout directory. Reserve each branch atomically at its exact snapshot commit. Serialize allocation across the repository and check both branch names and flattened checkout names; occupied names get numeric suffixes without changing session titles or reusing another copy's source. Preserve parent HEAD and staging, and leave existing branches and recovery paths unchanged.
34
+
35
+ ## Durable lifecycle
36
+
37
+ Replication is fire-and-forget. The caller gets an acknowledgement and later automatic delivery that starts a turn. Parents do not poll. Every fully stopped replica returns one truthful result, even after user input or Escape, and closes after durable settlement and descendant drain. Interruption and unsaved closure are failures with preserved post-fork answers and source work. Process loss does not automatically relaunch a replica; its immediate parent continues the work or creates a fresh copy.
38
+
39
+ Routine supervision must leave the parent's input and tools responsive while copies run. Bound-session discovery uses its exact ownership index, attachment and same-session artifacts, not unrelated historical sessions. Reuse validated binding metadata and consume appended records without rereading whole conversations on every tick. File replacement, truncation and identity changes must invalidate that reuse; the cache is not ownership evidence on its own.
40
+
41
+ A missing or damaged answer-history boundary must not prevent terminal failure delivery or pane cleanup. Report the export error rather than guessing which answers belong to the copy. A failed session checkpoint must not prevent saving terminal facts and source work; retain the checkout and block integration when no usable session checkpoint exists.
42
+
43
+ A replica may fail before it can register its own runtime. Record the allocated shell's boot and process incarnation from the parent before dispatch. A confirmed failed startup can close that owned pane without a child location record, while retaining its checkout. Include available loader diagnostics in the parent error. A native launch tool error already saved in the parent is not delivered again as a recovered replica result. An ambiguous dispatch error must not declare a process finished if it actually started.
44
+
45
+ Replica shutdown requires a stopped agent, no active tools, no pending background terminal/request receipts or queued results, no reported live Linux descendants, and drained child replicas. Background completions are processed by the copy before it returns; a new run invalidates an older closure attempt. Persist receipt/process ownership only for the exact session so reload does not abandon its work or transfer another session's jobs. Count reported child processes and their observed descendants, not the host shell or unrelated runtime helpers. Unreported daemons and remote jobs without receipts are outside this guard.
46
+
47
+ Return the settled hook's finalization promise to Pi. Request shutdown before interactive mode checks the settled boundary; an async request started without that promise can leave a finished copy idle forever.
48
+
49
+ Normal settlement follows this drain without an extra model confirmation. Ten continuously idle seconds provide a safety net for missed handoff, not a limit on active work. Queued messages, requests, tools, retries, compaction, movement and descendant drain suspend that clock. A saved settlement can be retried after reload; missing settlement evidence cannot become success. The retained non-replica recovery and intervention policies remain separate.
50
+
51
+ Session identity, not a file path or pane ID, owns delivery. A binding inside each session carries its durable store and child settings. Teleport preserves that entry and session ID. The ownership index and lineage inboxes survive Pi and Herdr process replacement. Reopening the exact parent replays pending answers and starts a turn; a closed parent is never opened automatically. New-ID forks cannot claim the original answers. A delivery is acknowledged only after its exact result entry is saved, not merely queued. Cleanup requires the recorded shell incarnation to still own the pane.
52
+
53
+ Each tool-launched attempt also retains its actual execution ID and visible outer root from Pi's execution events. Persist both with launch metadata and delivery inboxes; do not recover them from ID syntax, names, paths, completion order or timing. Publish the root as `parentToolCallId` on delayed result/help messages so existing consumers can group searchable output without rewriting history. Each fresh invocation records its own owner; automatic recovery preserves it. Missing ownership stays missing. This display linkage must not change result payloads, consumption, wakeups or source integration.
54
+
55
+ ## Retained launch paths
56
+
57
+ For the internal launcher and package-root API, model and thinking resolve independently: use custom role frontmatter when present, otherwise inherit the parent. Role models must be exact authenticated `provider/model-id` values; fallback lists are unsupported.
58
+
59
+ Roles come from project, global or installed role-pack directories, in that priority order. Legacy external CLI roles fail closed. The retained API does not register model-facing completion or help controls.
60
+
61
+ Managed worktrees remain opt-in on these retained paths. Ownership is recorded before Herdr creates resources. They use an exact committed base without copying parent dirty files, retain the workspace after every outcome, and never push, merge or remove it automatically. Replication has its own snapshot and automatic-join contract, separate from these retained worktrees.
62
+
63
+ The package-root API keeps these contracts through `createSubagentTree` and `attachSubagentTree` without registering model-facing tools.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HazAT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="assets/banner.png" alt="Pi Agent Replicate: one agent branches into two copies" width="100%">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">Pi Agent Replicate</h1>
6
+
7
+ <p align="center">One agent. Parallel work.</p>
8
+
9
+ <div align="center">
10
+
11
+ [![npm version](https://img.shields.io/npm/v/pi-agent-replicate)](https://www.npmjs.com/package/pi-agent-replicate)
12
+ [![MIT license](https://img.shields.io/npm/l/pi-agent-replicate)](./LICENSE)
13
+
14
+ </div>
15
+
16
+ Give your [Pi](https://github.com/earendil-works/pi) agent the ability to work in parallel in [Herdr](https://herdr.dev). It creates copies of itself for independent parts of a task, keeps working, and receives their results automatically.
17
+
18
+ Each copy starts with the current conversation, system prompt, model, thinking level and active tools. It has the context it needs to continue the work, rather than starting from scratch.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pi install npm:pi-agent-replicate
24
+ ```
25
+
26
+ Start Pi inside Herdr, then restart Pi or run `/reload`.
27
+
28
+ ## How it works
29
+
30
+ The extension adds one tool, `replicate`. The agent calls it with a task-specific name and a bounded assignment:
31
+
32
+ ```typescript
33
+ replicate({
34
+ name: "check-auth-risks",
35
+ task: "Check authentication risks while I implement the settings change. Return concrete findings with file references.",
36
+ });
37
+ ```
38
+
39
+ The name uses lowercase kebab-case. The copy works in its own Pi session and can create copies of its own. When its work and any child work finish, the result returns to the original agent automatically. The original can continue independent work or end its turn while it waits; it does not need to poll.
40
+
41
+ Use replication when there are genuinely independent tasks to do in parallel, not simply to hand off a task and wait. Copies inherit the conversation and tools, but their subsequent conversations are separate.
42
+
43
+ ## Where copies work
44
+
45
+ By default, each copy works in a separate Git worktree. It starts with a snapshot of the parent's tracked changes and non-ignored new files. Ignored files, dependencies and build outputs are not copied. On success, the host attempts to apply the copy's changes to the parent without changing its HEAD or staging. A conflict or failure leaves the copy's work available for review rather than applying partial changes. A clean join does not guarantee the combined code is correct.
46
+
47
+ Worktree mode requires a non-bare Git checkout with a commit. Snapshots do not support unresolved index conflicts, sparse or assume-unchanged index entries, submodules or nested Git repositories. Worktrees isolate files, not shared processes, ports or databases.
48
+
49
+ When copies need the same directory, switch to shared mode:
50
+
51
+ ```text
52
+ /replica-directory shared
53
+ ```
54
+
55
+ Shared copies work in the parent's current directory, including ignored files and dependencies. They do not create a worktree or branch, and there is no snapshot or automatic join. Changes are visible immediately and can remain even if a copy fails. Coordinate assignments: parallel edits to the same files can overwrite each other, and there is no automatic rollback.
56
+
57
+ Use `/replica-directory worktree` to switch back, or `/replica-directory` to choose interactively. The setting is saved in `.pi/replicate.json` in the current project directory and applies to new copies only.
58
+
59
+ ## When a copy stops
60
+
61
+ A completed copy returns its summary automatically. If it fails, is interrupted or loses its process, the parent receives a failure and any available answer information. Copies do not restart automatically; the parent can create a fresh copy if needed. In worktree mode, failed or conflicted work remains available for recovery; in shared mode, changes may already be in the shared directory.
62
+
63
+ ## More information
64
+
65
+ See the [documentation](docs/README.md) for technical contracts and [development instructions](docs/development.md).
66
+
67
+ ## License
68
+
69
+ [MIT](LICENSE)
package/RELEASING.md ADDED
@@ -0,0 +1,132 @@
1
+ # Release guide
2
+
3
+ GitHub Actions publishes this package when the version in `package.json` changes on `main`. The release workflow reads the package name and version from `package.json`, validates the package, publishes to npm, creates a matching `vX.Y.Z` tag, and creates a GitHub Release. If `.github/release-notes/<version>.md` exists, the release uses that file. Otherwise GitHub generates the notes and adds the npm package link.
4
+
5
+ The published version must be unique on npm.
6
+
7
+ ## Public versioning
8
+
9
+ `pi-agent-replicate` is a new npm package name and needs its first publication. The upstream `pi-herdr-agents` package used `0.0.1` for its manual bootstrap and `0.0.2` for its first trusted-publishing release. Those versions are upstream history, not publications of this renamed package.
10
+
11
+ Do not design a release that creates a GitHub Release without a successful npm publish for a new version. The workflow publishes first, then tags and creates the GitHub Release.
12
+
13
+ ## Prerequisites
14
+
15
+ You need:
16
+
17
+ - Permission to manage this repository's GitHub Actions settings and npm package access for `pi-agent-replicate`
18
+ - A clean local `main` branch
19
+
20
+ Automated release gates (run by the workflow and required locally):
21
+
22
+ ```bash
23
+ npm ci
24
+ npm run lint
25
+ npm test
26
+ npm pack --dry-run
27
+ ```
28
+
29
+ Manual deterministic Herdr integration (required before you push a release commit; not run in GitHub Actions):
30
+
31
+ ```bash
32
+ npm run test:integration
33
+ ```
34
+
35
+ Run that suite from inside Herdr. The shipped command bootstraps a separate test-owned headless Herdr server with a private socket, config, state directory, and worktree directory. It clears inherited Herdr identity and fails closed if the private endpoint cannot start, so it never falls back to the persistent user server. Normal exit and `SIGINT`, `SIGTERM`, or `SIGHUP` use one idempotent shutdown that verifies child and server process groups have exited, escalates after bounded grace, and removes only owned paths. Concurrent runs use separate endpoints and need no shared Herdr test slot. It uses real Pi and Herdr processes with the local deterministic provider, so it needs no provider credentials or network access. A focused file can be passed after `--`, for example `npm run test:integration -- test/integration/mux-surface.test.ts`.
36
+ The optional live-provider smoke test is not a release gate:
37
+
38
+ ```bash
39
+ PI_TEST_MODEL="openai-codex/gpt-5.6-luna" PI_TEST_TIMEOUT=180000 npm run test:integration:live
40
+ ```
41
+
42
+ Do not release from skipped Herdr tests. Confirm the package preview includes `README.md`, `CHANGELOG.md`, `AGENTS.md`, `docs/`, the package-root API files, and the files under `pi-extension/subagents/`. Confirm it excludes plans, journals, sessions, prototypes, generated evidence, and local `config.json`, and that the worktree integration tests leave no test workspace behind.
43
+
44
+ ## npm authentication
45
+
46
+ ### Steady state: trusted publishing (tokenless)
47
+
48
+ After the package exists on npm, steady-state releases use npm trusted publishing (OIDC). No long-lived `NPM_TOKEN` is required.
49
+
50
+ 1. Open the package settings for `pi-agent-replicate` on [npmjs.com](https://www.npmjs.com/).
51
+ 2. Add a trusted publisher for GitHub Actions with:
52
+ - Organization or user: `alexshpunt`
53
+ - Repository: `pi-agent-replicate`
54
+ - Workflow filename: `publish.yml`
55
+ - Allowed action: `npm publish`
56
+ 3. Confirm the release job has `permissions.id-token: write` and runs on a GitHub-hosted runner (already set in `.github/workflows/publish.yml`).
57
+ 4. Confirm the workflow uses the exactly pinned Node `26.3.0`, whose bundled npm supports trusted publishing.
58
+ 5. Publish stays tokenless: `npm publish --access public --provenance`.
59
+
60
+ When the repository secret `NPM_TOKEN` is absent, the publish step unsets `NODE_AUTH_TOKEN` and relies on OIDC. Once the package exists, the workflow fails if `NPM_TOKEN` is still configured, so steady-state releases cannot silently keep using the bootstrap credential. Manual dispatch runs only from `main`; other refs are rejected.
61
+
62
+ A new trusted publisher expires 48 hours after creation unless it completes a successful publish. Create or recreate it shortly before the next release; an expired configuration cannot authorize publishing. The first successful trusted publish validates the configuration.
63
+
64
+ ### Bootstrap history
65
+
66
+ The upstream `0.0.1` publication and documented trusted publisher for `giuseppecrj/pi-herdr-agents` do not establish the renamed npm package or authorize its releases.
67
+
68
+ Only during an explicitly requested first release, configure a temporary `NPM_TOKEN` if `pi-agent-replicate` does not yet exist on npm. After that publication, revoke and remove the token, then configure the trusted publisher above. The workflow rejects `NPM_TOKEN` once the package exists. Renaming the project does not publish a package or configure its trusted publisher.
69
+
70
+ ## Publish a release
71
+
72
+ Choose the semantic version increment:
73
+
74
+ - `patch`: compatible bug fixes, such as `0.0.2` to `0.0.3`
75
+ - `minor`: compatible features, such as `0.0.2` to `0.1.0`
76
+ - `major`: breaking changes, such as `0.0.2` to `1.0.0`
77
+
78
+ Save approved release notes as `.github/release-notes/<version>.md` and commit that file before the version commit. The workflow uses its contents verbatim for the matching release. An empty notes file stops release creation. Without a matching file, GitHub generates the release notes.
79
+
80
+ Create the version commit without a local tag:
81
+
82
+ ```bash
83
+ git fetch --tags --prune
84
+ npm version patch --no-git-tag-version
85
+ git add package.json package-lock.json CHANGELOG.md
86
+ git commit -m "chore: release v$(node -p \"require('./package.json').version\")"
87
+ git push origin main
88
+ ```
89
+
90
+ The `npm version` hook regenerates `CHANGELOG.md` with `auto-changelog`. Use `npm run changelog` to regenerate it without changing the version.
91
+
92
+ Replace `patch` with `minor` or `major` when appropriate. The push triggers the **Release** workflow, which installs dependencies, runs lint and unit tests, previews package contents, publishes to npm with provenance, creates and pushes the version tag, and creates the GitHub Release.
93
+
94
+ You can rerun a failed or incomplete release from **Actions → Release → Run workflow**. If npm already has `PACKAGE_NAME@VERSION`, the workflow reads that version's `gitHead` and continues only when it matches `GITHUB_SHA` (exact-commit retry). A foreign publish fails before tag or GitHub Release creation. Existing tags are verified to point at the release commit. The workflow does not create a GitHub Release for a version that still needs publish and failed to publish.
95
+
96
+ ## Verify the release
97
+
98
+ After the workflow succeeds, inspect the published package:
99
+
100
+ ```bash
101
+ npm view pi-agent-replicate
102
+ ```
103
+
104
+ Test installation through Pi:
105
+
106
+ ```bash
107
+ pi install npm:pi-agent-replicate
108
+ ```
109
+
110
+ The package should appear at <https://pi.dev/packages/pi-agent-replicate> after the gallery indexes the npm release.
111
+
112
+ ## Troubleshooting
113
+
114
+ ### Tag points to another commit
115
+
116
+ The workflow stops if the matching version tag already points to a different commit. Do not move or reuse release tags. Increment the package version and push a new release commit instead.
117
+
118
+ ### npm rejects authentication
119
+
120
+ Confirm that the trusted publisher matches owner `alexshpunt`, repository `pi-agent-replicate`, and workflow `publish.yml`, that the job has `id-token: write`, and that the runner is GitHub-hosted. If a release reports that `NPM_TOKEN` is bootstrap-only, remove the secret and use the trusted publisher.
121
+
122
+ ### npm reports that the version already exists
123
+
124
+ If the published `gitHead` does not match this commit, the workflow fails before tagging. npm versions are immutable: increment the package version and push a new release commit. If it is a retry of the exact same commit, the workflow skips publish and continues with tag/release.
125
+
126
+ ### Initial branch creation did not release
127
+
128
+ A clean repository's first push has `github.event.before` all zeroes. The workflow treats that as `release=false`. For the renamed package's first publication, follow the bootstrap instructions above. Once it exists on npm, use tokenless trusted publishing for later releases.
129
+
130
+ ### The package is absent from pi.dev
131
+
132
+ Confirm that npm published the package publicly and that `package.json` contains the `pi-package` keyword. Gallery indexing may take some time.
Binary file
@@ -0,0 +1,6 @@
1
+ {
2
+ "status": {
3
+ "enabled": true,
4
+ "quietThresholdMs": 120000
5
+ }
6
+ }
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Documentation
2
+
3
+ ## Active contracts
4
+
5
+ - [Worktree subagents](worktree-subagents.md) — isolation, retained state, review, and cleanup.
6
+ - [Public subagent tree API](public-subagent-tree-api.md) — package-root API and ownership contract.
7
+ - [Settled lifecycle contract](settled-lifecycle-contract.md) — completion and delivery semantics.
8
+ - [Retained role launcher](retained-roles.md) — role definitions and discovery for the package-root API.
9
+ - [Status configuration](configuration.md) — status display settings.
10
+ - [Development](development.md) — checks and isolated integration testing.
11
+
12
+ ## Architecture decisions
13
+
14
+ - [ADR-0003](adr/0003-installable-role-packs.md) — installable custom role packs.
15
+ - [ADR-0008](adr/0008-adopt-pi-only-subagent-execution.md) — Pi-only child execution.
16
+ - [ADR-0009](adr/0009-durable-recursive-subagent-ownership.md) — durable recursive ownership.
17
+ - [ADR-0010](adr/0010-public-subagent-tree-registry.md) — public process-local tree registry.
18
+
19
+ Older workflow and command decisions were removed with the surfaces they described. Historical release notes remain in `CHANGELOG.md`.
20
+
21
+ ## Background research
22
+
23
+ Files under [research](research/) are evidence and alternatives, not shipped contracts. When research conflicts with the README or an accepted ADR, the active contract wins.
@@ -0,0 +1,29 @@
1
+ # ADR-0003: Installable role packs
2
+
3
+ - Status: Accepted
4
+
5
+ ## Context
6
+
7
+ Projects need reusable custom subagent roles without copying them into every repository. The extension itself no longer ships built-in roles.
8
+
9
+ ## Decision
10
+
11
+ Discover role files from three sources, in this order:
12
+
13
+ 1. project `.pi/agents`;
14
+ 2. global Pi agent directories;
15
+ 3. installable packages that contribute agent directories through `pi-herdr-subagents:roles:discover:v1`.
16
+
17
+ Project roles override global roles. Global roles override package roles. If two packages contribute the same role name, discovery reports a collision instead of choosing by package order.
18
+
19
+ A role is a Markdown file with frontmatter and an optional prompt body. Role frontmatter may own model, thinking, tools, skills, cwd, session mode, prompt mode, and interaction defaults. Legacy roles that request an external CLI fail closed before Herdr creates resources.
20
+
21
+ The runtime does not scan arbitrary `node_modules` folders. Installed packages register their directories through the discovery event.
22
+
23
+ ## Consequences
24
+
25
+ - Role packs are reusable and explicit.
26
+ - Local policy can override package defaults.
27
+ - Package collisions are visible and deterministic.
28
+ - There is no protected built-in namespace.
29
+ - Role packs contribute roles only; they do not add commands or executable workflow engines.
@@ -0,0 +1,22 @@
1
+ # ADR-0008: Adopt Pi-only subagent execution
2
+
3
+ - **Status:** Accepted (implemented)
4
+ - **Date:** 2026-08-10
5
+ - **Scope:** `giuseppecrj/pi-herdr-agents`
6
+ - **Supersedes:** The external CLI runtime-adapter provisions of ADR-0002
7
+
8
+ ## Decision
9
+
10
+ Make every public subagent run Pi-backed. Remove the Claude terminal adapter and its `cli`, `cli-model`, and `resumeSessionId` interface fields. Existing role files that request an external CLI must fail with a clear error instead of silently running through Pi.
11
+
12
+ A single deep launch module will own the complete launch transaction behind one small interface. Pi and Herdr remain implementation details of that module; do not add a runtime adapter seam without a second real execution path.
13
+
14
+ Completion delivery will use one custom message whose content contains the bounded result and triggers the parent turn. Completion detection will keep the Pi sidecar as primary evidence and the terminal exit marker as its best-effort fallback.
15
+
16
+ ## Why
17
+
18
+ The Claude terminal path duplicates launch, completion, transcript, cleanup, status, resume, and interruption behavior. It also requires `--dangerously-skip-permissions`, has no bundled role, and reduces locality and test leverage. Pi already provides Claude models through normal provider/model routing.
19
+
20
+ ## Consequences
21
+
22
+ This is an immediate breaking change with no deprecation adapter. Custom roles that request an external CLI fail closed before Herdr creates resources.
@@ -0,0 +1,23 @@
1
+ # ADR-0009: Durable recursive subagent ownership
2
+
3
+ - Status: Accepted
4
+
5
+ ## Context
6
+
7
+ A child may launch descendants and then settle before they do. Process-local maps cannot preserve correct ownership through extension reloads or independent child processes.
8
+
9
+ ## Decision
10
+
11
+ Publish immutable lineage events under the parent session artifacts. Register each child before Herdr creates its pane or worktree. Each node records its parent node and parent Pi session sink.
12
+
13
+ A node drains only after its own terminal result has been delivered and every recursive descendant has drained. Inbox materialization uses durable claims and acknowledgements so recovery can avoid duplicate delivery. Cancellation becomes terminal only after pane absence and process exit are proven.
14
+
15
+ Lineage identity belongs to the launched Pi process. Unrelated subprocesses that inherit environment variables do not become descendants.
16
+
17
+ ## Consequences
18
+
19
+ - Nested ownership survives extension reloads and independent processes.
20
+ - A parent cannot report final completion while a descendant remains undrained.
21
+ - Results route to the exact parent Pi session.
22
+ - Corrupt, cyclic, or unattributable state fails closed instead of guessing.
23
+ - Cleanup is separate from delivery, so retained evidence remains inspectable.
@@ -0,0 +1,16 @@
1
+ # ADR 0010: Public subagent tree registry
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-08-30
5
+
6
+ ## Decision
7
+
8
+ The package-root public subagent tree API uses a lazy process-local registry and one single-writer branch journal per Pi process. Tree artifacts live below the original caller session's artifact directory. Published node, terminal, and callback records use temporary files and same-filesystem rename; exclusive claims prevent competing owners.
9
+
10
+ Nested Pi children receive only a package-owned context-file path outside model task text. They attach with validated caller, tree, token, and parent identities. The existing `launchPiSubagent()` remains the only Pi/Herdr launch owner.
11
+
12
+ `/reload`, `/new`, and `/resume` rebind fresh context in the same process. `/fork` is accepted only when the fresh session's `parentSession` header matches the previously bound session and `previousSessionFile`; stale callbacks are rejected by binding generation. Terminal completion is one compare-and-set record, and cancellation is authoritative only after pane absence and captured process exit are confirmed.
13
+
14
+ ## Consequences
15
+
16
+ The API is intentionally for installed Pi extensions inside Herdr and does not promise arbitrary Node use or full process restart recovery. A process crash can leave retained evidence for inspection, but the filesystem protocol is not a general job engine. Clean and explicit-empty roots may complete while descendant error or abort panes remain open and are reported in bounded lifecycle rows.
@@ -0,0 +1,14 @@
1
+ # Status configuration
2
+
3
+ Status settings are read from `config.json` at the installed package root. If that file is absent, `config.json.example` supplies the defaults:
4
+
5
+ ```json
6
+ {
7
+ "status": {
8
+ "enabled": true,
9
+ "quietThresholdMs": 120000
10
+ }
11
+ }
12
+ ```
13
+
14
+ `PI_SUBAGENT_QUIET_THRESHOLD_MS` overrides the quiet threshold for the current process. It must be a positive integer. Package updates may replace changes made inside the installed package directory.