@gotgenes/pi-subagents 18.0.0 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +22 -31
  3. package/docs/architecture/architecture.md +157 -204
  4. package/docs/architecture/history/phase-19-implement-ui-decisions.md +282 -0
  5. package/package.json +5 -6
  6. package/src/lifecycle/subagent.ts +5 -9
  7. package/src/observation/notification.ts +23 -10
  8. package/src/observation/subagent-events-observer.ts +1 -3
  9. package/src/tools/get-result-report.ts +60 -0
  10. package/src/tools/get-result-tool.ts +25 -40
  11. package/src/types.ts +1 -1
  12. package/src/ui/session-navigator.ts +0 -2
  13. package/.prettierignore +0 -5
  14. package/AGENTS.md +0 -7
  15. package/docs/plans/0048-implement-subagents-api.md +0 -304
  16. package/docs/plans/0049-remove-group-join-output-file-rpc.md +0 -180
  17. package/docs/plans/0051-update-adr-0001-hard-fork.md +0 -77
  18. package/docs/plans/0052-remove-scheduled-subagents.md +0 -133
  19. package/docs/plans/0053-extract-model-resolution-from-execute.md +0 -181
  20. package/docs/plans/0054-decompose-index-into-modules.md +0 -302
  21. package/docs/plans/0057-structured-debug-logging.md +0 -154
  22. package/docs/plans/0061-session-format-transcript.md +0 -284
  23. package/docs/plans/0066-replace-as-any-with-sdk-types.md +0 -215
  24. package/docs/plans/0069-create-subagent-runtime.md +0 -345
  25. package/docs/plans/0070-extract-event-handlers.md +0 -306
  26. package/docs/plans/0071-extract-session-config-assembler.md +0 -362
  27. package/docs/plans/0072-inject-agent-manager-collaborators.md +0 -329
  28. package/docs/plans/0076-inject-cwd-into-agent-manager.md +0 -102
  29. package/docs/plans/0077-inject-project-agents-dir.md +0 -115
  30. package/docs/plans/0080-consolidate-agent-config-lookup.md +0 -247
  31. package/docs/plans/0084-extract-git-worktree-manager.md +0 -142
  32. package/docs/plans/0087-evolve-subagent-runtime-methods.md +0 -240
  33. package/docs/plans/0098-extract-agent-record-state-machine.md +0 -435
  34. package/docs/plans/0099-replace-ctx-with-parent-snapshot.md +0 -488
  35. package/docs/plans/0100-replace-callback-threading-with-session-subscription.md +0 -454
  36. package/docs/plans/0102-consolidate-test-record-factory.md +0 -176
  37. package/docs/plans/0108-extract-agent-type-registry.md +0 -322
  38. package/docs/plans/0109-extract-settings-manager.md +0 -276
  39. package/docs/plans/0110-agent-activity-tracker.md +0 -297
  40. package/docs/plans/0111-split-agent-record-lifecycle.md +0 -582
  41. package/docs/plans/0112-replace-agent-manager-callbacks.md +0 -241
  42. package/docs/plans/0113-disambiguate-spawn-options.md +0 -155
  43. package/docs/plans/0114-narrow-agent-tool-menu-deps.md +0 -279
  44. package/docs/plans/0115-decompose-agent-tool.md +0 -337
  45. package/docs/plans/0116-type-housekeeping.md +0 -351
  46. package/docs/plans/0118-settings-manager-apply-methods.md +0 -271
  47. package/docs/plans/0123-remove-vi-fn-cast-smell.md +0 -179
  48. package/docs/plans/0131-consolidate-shared-test-fixtures.md +0 -207
  49. package/docs/plans/0132-inject-io-into-session-config.md +0 -219
  50. package/docs/plans/0133-inject-sdk-boundary-into-agent-runner.md +0 -373
  51. package/docs/plans/0134-reduce-as-any-casts.md +0 -366
  52. package/docs/plans/0135-extract-display-helpers.md +0 -182
  53. package/docs/plans/0136-decompose-agent-menu.md +0 -300
  54. package/docs/plans/0144-consolidate-observation-model.md +0 -263
  55. package/docs/plans/0145-decompose-execute-push-ctx-to-boundary.md +0 -290
  56. package/docs/plans/0146-narrow-ui-context.md +0 -319
  57. package/docs/plans/0147-inject-wrap-text-into-conversation-viewer.md +0 -166
  58. package/docs/plans/0148-split-agent-widget-rendering.md +0 -255
  59. package/docs/plans/0152-add-prompt-snippet.md +0 -91
  60. package/docs/plans/0164-reorganize-into-domain-directories.md +0 -409
  61. package/docs/plans/0165-decompose-resolved-spawn-config.md +0 -157
  62. package/docs/plans/0166-extract-parent-session-info.md +0 -231
  63. package/docs/plans/0167-narrow-runner-io.md +0 -150
  64. package/docs/plans/0168-extract-tool-filter-config.md +0 -173
  65. package/docs/plans/0169-extract-run-context-from-run-options.md +0 -194
  66. package/docs/plans/0170-reduce-build-content-lines-complexity.md +0 -225
  67. package/docs/plans/0171-reduce-render-result-complexity.md +0 -200
  68. package/docs/plans/0172-extract-turn-formatting.md +0 -206
  69. package/docs/plans/0180-reorder-append-prompt-for-kv-cache.md +0 -100
  70. package/docs/plans/0185-remove-persistent-agent-memory.md +0 -161
  71. package/docs/plans/0188-replace-any-casts-with-sdk-types.md +0 -162
  72. package/docs/plans/0192-define-session-context-interface.md +0 -107
  73. package/docs/plans/0193-runtime-owns-context-queries.md +0 -245
  74. package/docs/plans/0194-align-tool-interfaces-for-structural-typing.md +0 -139
  75. package/docs/plans/0195-convert-tool-factories-to-classes.md +0 -264
  76. package/docs/plans/0196-convert-runner-menu-to-classes.md +0 -268
  77. package/docs/plans/0205-decompose-render-widget-lines.md +0 -140
  78. package/docs/plans/0206-decompose-show-agent-detail.md +0 -211
  79. package/docs/plans/0207-decompose-agent-widget-update.md +0 -242
  80. package/docs/plans/0208-extract-shared-test-fixtures.md +0 -298
  81. package/docs/plans/0214-convert-remaining-closure-factories-to-classes.md +0 -261
  82. package/docs/plans/0215-decompose-build-parent-context.md +0 -166
  83. package/docs/plans/0216-decompose-start-agent.md +0 -255
  84. package/docs/plans/0217-extract-overwrite-guard.md +0 -176
  85. package/docs/plans/0218-push-sdk-boundary-in-settings.md +0 -172
  86. package/docs/plans/0219-reduce-test-duplication-top-3-clone-families.md +0 -162
  87. package/docs/plans/0227-evolve-agent-record-into-agent.md +0 -322
  88. package/docs/plans/0228-async-start-agent-dissolve-run-handle.md +0 -288
  89. package/docs/plans/0229-agent-born-complete.md +0 -564
  90. package/docs/plans/0230-extract-concurrency-queue.md +0 -265
  91. package/docs/plans/0231-push-exec-registry-to-runner.md +0 -245
  92. package/docs/plans/0232-agent-resume-internal-observer-lifecycle.md +0 -180
  93. package/docs/plans/0237-remove-disallowed-tools.md +0 -180
  94. package/docs/plans/0238-remove-extensions-filtering.md +0 -191
  95. package/docs/plans/0239-collapse-filter-active-tools.md +0 -217
  96. package/docs/plans/0242-rename-agent-tool-to-subagent.md +0 -165
  97. package/docs/plans/0256-extract-worktree-isolation.md +0 -256
  98. package/docs/plans/0257-extract-child-session-factory.md +0 -285
  99. package/docs/plans/0262-add-workspace-provider-seam.md +0 -264
  100. package/docs/plans/0264-remove-extension-lifecycle-control.md +0 -277
  101. package/docs/plans/0265-born-complete-subagent-session.md +0 -333
  102. package/docs/plans/0270-type-consumable-public-surface.md +0 -204
  103. package/docs/plans/0272-export-workspace-collaborator-types.md +0 -147
  104. package/docs/plans/0277-encapsulate-agent-session.md +0 -304
  105. package/docs/plans/0280-rename-agent-to-subagent.md +0 -197
  106. package/docs/plans/0360-custom-agents-default-append.md +0 -132
  107. package/docs/plans/0373-extract-subagent-state.md +0 -250
  108. package/docs/plans/0374-encapsulate-subagent-start-notification.md +0 -268
  109. package/docs/plans/0375-extract-run-listener-workspace-bracket.md +0 -300
  110. package/docs/plans/0376-extract-manager-observer.md +0 -232
  111. package/docs/plans/0377-split-widget-delegation-from-runtime.md +0 -254
  112. package/docs/plans/0378-consolidate-lifecycle-test-fixtures.md +0 -243
  113. package/docs/plans/0379-consolidate-ui-tools-test-fixtures.md +0 -335
  114. package/docs/plans/0380-extract-layered-settings-loader.md +0 -223
  115. package/docs/plans/0381-replace-concurrency-queue-with-limiter.md +0 -267
  116. package/docs/plans/0400-include-parent-prompt-in-replace-mode.md +0 -199
  117. package/docs/plans/0403-abort-subagents-on-interrupt.md +0 -180
  118. package/docs/plans/0412-unify-session-mock-builders.md +0 -146
  119. package/docs/plans/0420-fold-run-metrics-live-activity-onto-record.md +0 -228
  120. package/docs/plans/0421-migrate-activity-readers-to-record-getters.md +0 -309
  121. package/docs/plans/0422-delete-activity-tracker-ui-observer.md +0 -204
  122. package/docs/plans/0423-widget-self-drive-from-lifecycle.md +0 -264
  123. package/docs/plans/0424-drop-widget-dep-from-subagent-tool.md +0 -166
  124. package/docs/plans/0425-reconcile-subagent-events-contract.md +0 -144
  125. package/docs/plans/0426-consolidate-residual-test-clone-families.md +0 -235
  126. package/docs/plans/0427-reconsider-ui-direction.md +0 -212
  127. package/docs/plans/0441-remove-agent-definition-management-subtree.md +0 -180
  128. package/docs/plans/0442-dissolve-agents-conversation-viewer.md +0 -195
  129. package/docs/plans/0444-shrink-widget-to-background-agents.md +0 -156
  130. package/docs/plans/0445-native-session-navigation.md +0 -365
  131. package/docs/plans/0446-spike-session-navigation-entry-criteria.md +0 -171
  132. package/docs/plans/0447-extract-subagents-settings-command.md +0 -220
  133. package/docs/plans/0448-block-disabled-agent-spawn.md +0 -207
  134. package/docs/plans/0462-navigation-renderer-tui-components.md +0 -338
  135. package/docs/plans/0463-file-snapshot-source-evicted-agents.md +0 -306
  136. package/docs/retro/0048-implement-subagents-api.md +0 -44
  137. package/docs/retro/0049-remove-group-join-output-file-rpc.md +0 -49
  138. package/docs/retro/0051-update-adr-0001-hard-fork.md +0 -39
  139. package/docs/retro/0053-extract-model-resolution-from-execute.md +0 -40
  140. package/docs/retro/0054-decompose-index-into-modules.md +0 -53
  141. package/docs/retro/0057-structured-debug-logging.md +0 -77
  142. package/docs/retro/0061-session-format-transcript.md +0 -41
  143. package/docs/retro/0066-replace-as-any-with-sdk-types.md +0 -44
  144. package/docs/retro/0069-create-subagent-runtime.md +0 -43
  145. package/docs/retro/0070-extract-event-handlers.md +0 -49
  146. package/docs/retro/0071-extract-session-config-assembler.md +0 -60
  147. package/docs/retro/0072-inject-agent-manager-collaborators.md +0 -46
  148. package/docs/retro/0076-inject-cwd-into-agent-manager.md +0 -35
  149. package/docs/retro/0077-inject-project-agents-dir.md +0 -33
  150. package/docs/retro/0080-consolidate-agent-config-lookup.md +0 -35
  151. package/docs/retro/0084-extract-git-worktree-manager.md +0 -37
  152. package/docs/retro/0087-evolve-subagent-runtime-methods.md +0 -42
  153. package/docs/retro/0098-extract-agent-record-state-machine.md +0 -46
  154. package/docs/retro/0099-replace-ctx-with-parent-snapshot.md +0 -37
  155. package/docs/retro/0100-replace-callback-threading-with-session-subscription.md +0 -36
  156. package/docs/retro/0102-consolidate-test-record-factory.md +0 -30
  157. package/docs/retro/0108-extract-agent-type-registry.md +0 -41
  158. package/docs/retro/0109-extract-settings-manager.md +0 -55
  159. package/docs/retro/0110-agent-activity-tracker.md +0 -44
  160. package/docs/retro/0111-split-agent-record-lifecycle.md +0 -61
  161. package/docs/retro/0112-replace-agent-manager-callbacks.md +0 -35
  162. package/docs/retro/0113-disambiguate-spawn-options.md +0 -29
  163. package/docs/retro/0114-narrow-agent-tool-menu-deps.md +0 -38
  164. package/docs/retro/0115-decompose-agent-tool.md +0 -51
  165. package/docs/retro/0116-type-housekeeping.md +0 -42
  166. package/docs/retro/0118-settings-manager-apply-methods.md +0 -40
  167. package/docs/retro/0123-remove-vi-fn-cast-smell.md +0 -49
  168. package/docs/retro/0131-consolidate-shared-test-fixtures.md +0 -46
  169. package/docs/retro/0132-inject-io-into-session-config.md +0 -33
  170. package/docs/retro/0133-inject-sdk-boundary-into-agent-runner.md +0 -45
  171. package/docs/retro/0134-reduce-as-any-casts.md +0 -56
  172. package/docs/retro/0135-extract-display-helpers.md +0 -38
  173. package/docs/retro/0136-decompose-agent-menu.md +0 -43
  174. package/docs/retro/0144-consolidate-observation-model.md +0 -39
  175. package/docs/retro/0145-decompose-execute-push-ctx-to-boundary.md +0 -56
  176. package/docs/retro/0146-narrow-ui-context.md +0 -70
  177. package/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md +0 -90
  178. package/docs/retro/0148-split-agent-widget-rendering.md +0 -39
  179. package/docs/retro/0152-add-prompt-snippet.md +0 -34
  180. package/docs/retro/0164-reorganize-into-domain-directories.md +0 -82
  181. package/docs/retro/0165-decompose-resolved-spawn-config.md +0 -78
  182. package/docs/retro/0166-extract-parent-session-info.md +0 -66
  183. package/docs/retro/0167-narrow-runner-io.md +0 -63
  184. package/docs/retro/0168-extract-tool-filter-config.md +0 -76
  185. package/docs/retro/0169-extract-run-context-from-run-options.md +0 -68
  186. package/docs/retro/0170-reduce-build-content-lines-complexity.md +0 -72
  187. package/docs/retro/0171-reduce-render-result-complexity.md +0 -77
  188. package/docs/retro/0172-extract-turn-formatting.md +0 -80
  189. package/docs/retro/0180-reorder-append-prompt-for-kv-cache.md +0 -62
  190. package/docs/retro/0185-remove-persistent-agent-memory.md +0 -73
  191. package/docs/retro/0188-replace-any-casts-with-sdk-types.md +0 -69
  192. package/docs/retro/0192-define-session-context-interface.md +0 -59
  193. package/docs/retro/0193-runtime-owns-context-queries.md +0 -75
  194. package/docs/retro/0194-align-tool-interfaces-for-structural-typing.md +0 -62
  195. package/docs/retro/0195-convert-tool-factories-to-classes.md +0 -84
  196. package/docs/retro/0196-convert-runner-menu-to-classes.md +0 -73
  197. package/docs/retro/0205-decompose-render-widget-lines.md +0 -64
  198. package/docs/retro/0206-decompose-show-agent-detail.md +0 -67
  199. package/docs/retro/0207-decompose-agent-widget-update.md +0 -92
  200. package/docs/retro/0208-extract-shared-test-fixtures.md +0 -102
  201. package/docs/retro/0214-convert-remaining-closure-factories-to-classes.md +0 -66
  202. package/docs/retro/0215-decompose-build-parent-context.md +0 -61
  203. package/docs/retro/0216-decompose-start-agent.md +0 -80
  204. package/docs/retro/0217-extract-overwrite-guard.md +0 -63
  205. package/docs/retro/0218-push-sdk-boundary-in-settings.md +0 -72
  206. package/docs/retro/0219-reduce-test-duplication-top-3-clone-families.md +0 -64
  207. package/docs/retro/0227-evolve-agent-record-into-agent.md +0 -80
  208. package/docs/retro/0228-async-start-agent-dissolve-run-handle.md +0 -80
  209. package/docs/retro/0229-agent-born-complete.md +0 -89
  210. package/docs/retro/0230-extract-concurrency-queue.md +0 -38
  211. package/docs/retro/0231-push-exec-registry-to-runner.md +0 -71
  212. package/docs/retro/0232-agent-resume-internal-observer-lifecycle.md +0 -109
  213. package/docs/retro/0237-remove-disallowed-tools.md +0 -78
  214. package/docs/retro/0238-remove-extensions-filtering.md +0 -72
  215. package/docs/retro/0239-collapse-filter-active-tools.md +0 -70
  216. package/docs/retro/0242-rename-agent-tool-to-subagent.md +0 -82
  217. package/docs/retro/0256-extract-worktree-isolation.md +0 -89
  218. package/docs/retro/0257-extract-child-session-factory.md +0 -33
  219. package/docs/retro/0262-add-workspace-provider-seam.md +0 -89
  220. package/docs/retro/0264-remove-extension-lifecycle-control.md +0 -91
  221. package/docs/retro/0265-born-complete-subagent-session.md +0 -97
  222. package/docs/retro/0270-type-consumable-public-surface.md +0 -108
  223. package/docs/retro/0272-export-workspace-collaborator-types.md +0 -38
  224. package/docs/retro/0277-encapsulate-agent-session.md +0 -80
  225. package/docs/retro/0280-rename-agent-to-subagent.md +0 -96
  226. package/docs/retro/0360-custom-agents-default-append.md +0 -81
  227. package/docs/retro/0373-extract-subagent-state.md +0 -94
  228. package/docs/retro/0374-encapsulate-subagent-start-notification.md +0 -171
  229. package/docs/retro/0375-extract-run-listener-workspace-bracket.md +0 -104
  230. package/docs/retro/0376-extract-manager-observer.md +0 -81
  231. package/docs/retro/0377-split-widget-delegation-from-runtime.md +0 -105
  232. package/docs/retro/0378-consolidate-lifecycle-test-fixtures.md +0 -100
  233. package/docs/retro/0379-consolidate-ui-tools-test-fixtures.md +0 -52
  234. package/docs/retro/0380-extract-layered-settings-loader.md +0 -97
  235. package/docs/retro/0381-replace-concurrency-queue-with-limiter.md +0 -95
  236. package/docs/retro/0400-include-parent-prompt-in-replace-mode.md +0 -84
  237. package/docs/retro/0403-abort-subagents-on-interrupt.md +0 -90
  238. package/docs/retro/0412-unify-session-mock-builders.md +0 -80
  239. package/docs/retro/0420-fold-run-metrics-live-activity-onto-record.md +0 -90
  240. package/docs/retro/0421-migrate-activity-readers-to-record-getters.md +0 -105
  241. package/docs/retro/0422-delete-activity-tracker-ui-observer.md +0 -97
  242. package/docs/retro/0423-widget-self-drive-from-lifecycle.md +0 -112
  243. package/docs/retro/0424-drop-widget-dep-from-subagent-tool.md +0 -89
  244. package/docs/retro/0425-reconcile-subagent-events-contract.md +0 -101
  245. package/docs/retro/0426-consolidate-residual-test-clone-families.md +0 -100
  246. package/docs/retro/0427-reconsider-ui-direction.md +0 -102
  247. package/docs/retro/0441-remove-agent-definition-management-subtree.md +0 -45
  248. package/docs/retro/0442-dissolve-agents-conversation-viewer.md +0 -108
  249. package/docs/retro/0444-shrink-widget-to-background-agents.md +0 -81
  250. package/docs/retro/0445-native-session-navigation.md +0 -122
  251. package/docs/retro/0446-spike-session-navigation-entry-criteria.md +0 -99
  252. package/docs/retro/0447-extract-subagents-settings-command.md +0 -91
  253. package/docs/retro/0448-block-disabled-agent-spawn.md +0 -75
  254. package/docs/retro/0462-navigation-renderer-tui-components.md +0 -105
  255. package/docs/retro/0463-file-snapshot-source-evicted-agents.md +0 -103
  256. package/src/observation/notification-state.ts +0 -27
  257. package/vitest.config.ts +0 -14
@@ -1,304 +0,0 @@
1
- ---
2
- issue: 48
3
- issue_title: "feat: implement and publish SubagentsAPI at extension init"
4
- ---
5
-
6
- # Implement and publish SubagentsService
7
-
8
- ## Problem Statement
9
-
10
- The package currently exposes an untyped, undocumented manager via `Symbol.for("pi-subagents:manager")` on `globalThis`.
11
- This forces consumers to guess the API shape, lacks model resolution at the boundary (causing "No API key found for undefined" crashes when consumers pass string model names), and leaks non-serializable internals (`AgentSession`, `AbortController`) in returned records.
12
-
13
- The architecture doc specifies a typed interface with `Symbol.for()` accessor functions that other extensions import as an optional peer dependency.
14
- This issue implements that boundary, following the naming and structural conventions established by `pi-permission-system`.
15
-
16
- ## Goals
17
-
18
- - Export `SubagentsService` interface, `SubagentRecord`, `SubagentStatus`, `SpawnOptions`, `LifetimeUsage`, accessor functions (`publishSubagentsService`, `getSubagentsService`), and event constants from the package's public entry point.
19
- - Create `src/service-adapter.ts` — an adapter wrapping `AgentManager` to satisfy `SubagentsService`, handling string model resolution and record serialization.
20
- - Call `publishSubagentsService()` at extension init; clean up on `session_shutdown`.
21
- - Remove the old `Symbol.for("pi-subagents:manager")` global key.
22
- - This is a **breaking change** (`feat!:`) — the old untyped global key is removed and replaced with the typed service under a new key.
23
- - Follow the naming and structural conventions established by `pi-permission-system` (`service.ts`, `@gotgenes/<pkg>:service` key, `Record<symbol, unknown>` cast).
24
-
25
- ## Non-Goals
26
-
27
- - Consumer extensions (scheduling, transcript) — these are separate packages.
28
- - Native Pi service registry integration (`pi.registerService()`) — deferred to a future Pi SDK release.
29
- - `SubagentsService.resume()` — not part of the initial interface per the architecture doc.
30
- - Output-file JSONL format migration (#61).
31
-
32
- ## Background
33
-
34
- ### Prerequisite issues
35
-
36
- - #49 (remove group-join and RPC) — **closed/merged**.
37
- The untyped RPC channels are already gone.
38
- - #52 (remove scheduled subagents) — **closed/merged**.
39
- - #51 (update ADR for hard fork) — **closed/merged**.
40
-
41
- ### Relevant modules
42
-
43
- | Module | Role in this change |
44
- | ----------------------- | ---------------------------------------------------------------------------------------------------- |
45
- | `src/index.ts` | Wiring layer. Currently publishes the untyped global; will call `publishSubagentsService()` instead. |
46
- | `src/agent-manager.ts` | Core lifecycle manager. The adapter wraps its public methods. |
47
- | `src/model-resolver.ts` | `resolveModel()` converts string → `Model`. The adapter calls this at the API boundary. |
48
- | `src/types.ts` | Defines `AgentRecord` (internal, non-serializable). |
49
- | `src/usage.ts` | Exports `LifetimeUsage` (already serializable). |
50
-
51
- ### Constraints from AGENTS.md
52
-
53
- - One concern per file — types/accessors in `src/service.ts`, adapter logic in `src/service-adapter.ts`.
54
- - Avoid `any` unless absolutely necessary — the accessor functions use `Record<symbol, unknown>` on `globalThis`.
55
- - Pi SDK imports stay out of business-logic modules — `service-adapter.ts` accepts `pi` and `ctx` as narrow interface parameters.
56
- - Narrow interface types for collaborators — the adapter takes a minimal `AgentManagerLike` interface, not the concrete `AgentManager` class.
57
-
58
- ### Alignment with pi-permission-system
59
-
60
- This plan deliberately follows the pattern established by `@gotgenes/pi-permission-system`:
61
-
62
- | Aspect | pi-permission-system | pi-subagents (this plan) |
63
- | --------------- | ------------------------------------------ | --------------------------------------- |
64
- | Public file | `src/service.ts` | `src/service.ts` |
65
- | Interface name | `PermissionsService` | `SubagentsService` |
66
- | Symbol.for key | `"@gotgenes/pi-permission-system:service"` | `"@gotgenes/pi-subagents:service"` |
67
- | globalThis cast | `Record<symbol, unknown>` | `Record<symbol, unknown>` |
68
- | Accessors | `publish/get/unpublishPermissionsService` | `publish/get/unpublishSubagentsService` |
69
- | exports → | `./src/service.ts` | `./src/service.ts` |
70
-
71
- The architecture doc uses `SubagentsAPI` naming and `pi:service:subagents` key; it should be updated during implementation to reflect the final naming.
72
-
73
- ## Design Overview
74
-
75
- ### Module decomposition
76
-
77
- ```text
78
- src/service.ts ← SubagentsService interface, SubagentRecord, SpawnOptions,
79
- SubagentStatus, accessor functions, event constants
80
- src/service-adapter.ts ← createSubagentsService() factory, record serialization,
81
- model resolution at the boundary
82
- src/index.ts ← wire: publishSubagentsService(createSubagentsService(...))
83
- ```
84
-
85
- ### Types (in `src/service.ts`)
86
-
87
- ```typescript
88
- export type SubagentStatus =
89
- | "queued" | "running" | "completed" | "steered"
90
- | "aborted" | "stopped" | "error";
91
-
92
- export interface SubagentRecord {
93
- id: string;
94
- type: string;
95
- description: string;
96
- status: SubagentStatus;
97
- result?: string;
98
- error?: string;
99
- toolUses: number;
100
- startedAt: number;
101
- completedAt?: number;
102
- lifetimeUsage: LifetimeUsage;
103
- compactionCount: number;
104
- worktreeResult?: { hasChanges: boolean; branch?: string };
105
- }
106
-
107
- export interface SpawnOptions {
108
- description?: string;
109
- model?: string;
110
- maxTurns?: number;
111
- thinkingLevel?: string;
112
- isolated?: boolean;
113
- inheritContext?: boolean;
114
- foreground?: boolean;
115
- bypassQueue?: boolean;
116
- isolation?: "worktree";
117
- }
118
-
119
- export interface SubagentsService {
120
- spawn(type: string, prompt: string, options?: SpawnOptions): string;
121
- getRecord(id: string): SubagentRecord | undefined;
122
- listAgents(): SubagentRecord[];
123
- abort(id: string): boolean;
124
- steer(id: string, message: string): Promise<boolean>;
125
- waitForAll(): Promise<void>;
126
- hasRunning(): boolean;
127
- }
128
-
129
- export const SUBAGENT_EVENTS = {
130
- STARTED: "subagents:started",
131
- COMPLETED: "subagents:completed",
132
- ACTIVITY: "subagents:activity",
133
- } as const;
134
- ```
135
-
136
- ### Accessor pattern
137
-
138
- ```typescript
139
- const SERVICE_KEY = Symbol.for("@gotgenes/pi-subagents:service");
140
-
141
- export function publishSubagentsService(service: SubagentsService): void {
142
- (globalThis as Record<symbol, unknown>)[SERVICE_KEY] = service;
143
- }
144
-
145
- export function getSubagentsService(): SubagentsService | undefined {
146
- return (globalThis as Record<symbol, unknown>)[SERVICE_KEY] as
147
- | SubagentsService
148
- | undefined;
149
- }
150
-
151
- export function unpublishSubagentsService(): void {
152
- delete (globalThis as Record<symbol, unknown>)[SERVICE_KEY];
153
- }
154
- ```
155
-
156
- ### Adapter (`src/service-adapter.ts`)
157
-
158
- The adapter accepts narrow interfaces rather than concrete classes:
159
-
160
- ```typescript
161
- interface AgentManagerLike {
162
- spawn(pi: any, ctx: any, type: string, prompt: string, options: any): string;
163
- getRecord(id: string): AgentRecord | undefined;
164
- listAgents(): AgentRecord[];
165
- abort(id: string): boolean;
166
- waitForAll(): Promise<void>;
167
- hasRunning(): boolean;
168
- }
169
-
170
- interface AdapterDeps {
171
- manager: AgentManagerLike;
172
- resolveModel: (input: string, registry: ModelRegistry) => any;
173
- getCtx: () => { pi: any; ctx: any } | undefined;
174
- getModelRegistry: () => ModelRegistry | undefined;
175
- }
176
- ```
177
-
178
- Key behaviors:
179
-
180
- 1. **String model resolution** — `spawn()` calls `resolveModel(options.model, registry)` before delegating to the manager.
181
- If resolution fails, throws with the error string (list of available models).
182
- 2. **Session gating** — throws if `getCtx()` returns `undefined` (no active session).
183
- 3. **Record serialization** — `toSubagentRecord()` strips `session`, `abortController`, `promise`, `pendingSteers`, `outputCleanup` from `AgentRecord`.
184
- 4. **Steer delegation** — uses the same pattern as the `steer_subagent` tool: checks status, queues if session not ready, delegates to `session.steer()`.
185
-
186
- This mirrors the `pi-permission-system` pattern: a slim `service.ts` defines the contract and accessors; a separate adapter file contains the implementation wiring.
187
-
188
- ### Public entry point
189
-
190
- The package currently has no explicit `exports` field in `package.json`.
191
- Since Pi loads the extension via `pi.extensions` (pointing at `./src/index.ts`), the service types and accessors need a separate public entry point.
192
- Add an `exports` map:
193
-
194
- ```json
195
- {
196
- "exports": {
197
- ".": "./src/service.ts"
198
- }
199
- }
200
- ```
201
-
202
- This exposes the types and accessor functions to consumers who `import("@gotgenes/pi-subagents")`.
203
- The extension entry point (`./src/index.ts`) remains declared in `pi.extensions`.
204
- This matches the pattern established by `pi-permission-system` (`exports` → `service.ts`, `pi.extensions` → `index.ts`).
205
-
206
- ### Edge cases
207
-
208
- - **No active session**: `spawn()` throws `"No active session — cannot spawn agents outside a session."`.
209
- - **Model resolution failure**: `spawn()` throws with the error string from `resolveModel()`.
210
- - **Missing description**: default to a truncated prompt (`prompt.slice(0, 80)`).
211
- - **Steer on non-running agent**: returns `false`.
212
- - **Steer before session ready**: queues the message (returns `true`).
213
-
214
- ### Naming conventions
215
-
216
- Following `pi-permission-system`'s established pattern:
217
-
218
- - Public file: `service.ts` (not `api.ts`)
219
- - Interface: `SubagentsService` (not `SubagentsAPI`)
220
- - Symbol key: `"@gotgenes/pi-subagents:service"` (scoped package name, not generic `pi:service:*`)
221
- - globalThis cast: `Record<symbol, unknown>` (not `any`)
222
- - Accessor names: `publish/get/unpublishSubagentsService`
223
-
224
- ## Module-Level Changes
225
-
226
- ### New files
227
-
228
- | File | Contents |
229
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
230
- | `src/service.ts` | `SubagentsService` interface, `SubagentRecord`, `SubagentStatus`, `SpawnOptions`, `LifetimeUsage` re-export, accessor functions, event constants, `unpublishSubagentsService`. |
231
- | `src/service-adapter.ts` | `createSubagentsService()` factory. `toSubagentRecord()` serializer. Narrow `AgentManagerLike` and `AdapterDeps` interfaces. |
232
- | `test/service-adapter.test.ts` | Unit tests for the adapter (model resolution, serialization, session gating, steer delegation). |
233
- | `test/service.test.ts` | Unit tests for accessor functions (publish/get/unpublish round-trip, isolation between keys). |
234
-
235
- ### Modified files
236
-
237
- | File | Change |
238
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
239
- | `src/index.ts` | Import `publishSubagentsService`, `unpublishSubagentsService` from `./service.js` and `createSubagentsService` from `./service-adapter.js`. Replace `Symbol.for("pi-subagents:manager")` block with `publishSubagentsService(createSubagentsService(...))`. In `session_shutdown`, call `unpublishSubagentsService()` instead of `delete (globalThis as any)[MANAGER_KEY]`. |
240
- | `package.json` | Add `"exports": { ".": "./src/service.ts" }`. |
241
- | `src/usage.ts` | No change needed — `LifetimeUsage` is already exported. Re-exported from `src/service.ts`. |
242
-
243
- ## Test Impact Analysis
244
-
245
- 1. **New unit tests enabled**: `test/service-adapter.test.ts` tests the adapter in isolation against a mock `AgentManagerLike` — model resolution, record stripping, session gating, steer semantics.
246
- `test/service.test.ts` tests the accessor functions (publish/get/unpublish lifecycle, `undefined` before publish).
247
- 2. **Existing tests that become redundant**: None — the old `Symbol.for("pi-subagents:manager")` global was not unit-tested.
248
- 3. **Existing tests that must stay**: All `agent-manager.test.ts` and `agent-runner.test.ts` tests remain — they test the internal engine, not the public service boundary.
249
- Any test referencing `MANAGER_KEY` or `"pi-subagents:manager"` in string assertions must be updated.
250
-
251
- ## TDD Order
252
-
253
- 1. **`src/service.ts` — types, accessors, and event constants.**
254
- Test: `test/service.test.ts` — `publishSubagentsService` stores on globalThis, `getSubagentsService` retrieves it, `unpublishSubagentsService` removes it, `getSubagentsService` returns `undefined` when not published.
255
- Commit: `feat!: add SubagentsService types and accessor functions`
256
-
257
- 2. **`src/service-adapter.ts` — `toSubagentRecord()` serializer.**
258
- Test: `test/service-adapter.test.ts` — given an `AgentRecord` with `session`, `abortController`, `promise`, `pendingSteers`, `outputCleanup`, verify the returned `SubagentRecord` contains only serializable fields.
259
- Commit: `feat: add SubagentRecord serializer`
260
-
261
- 3. **`src/service-adapter.ts` — `createSubagentsService().getRecord()` and `listAgents()`.**
262
- Test: verify `getRecord` delegates to manager and serializes; `listAgents` returns serialized records sorted by `startedAt` descending.
263
- Commit: `feat: implement getRecord and listAgents on SubagentsService adapter`
264
-
265
- 4. **`src/service-adapter.ts` — `spawn()` with model resolution and session gating.**
266
- Test: (a) throws when `getCtx()` returns `undefined`; (b) resolves string model names via `resolveModel`; (c) throws on model resolution failure; (d) delegates to manager with resolved model; (e) uses truncated prompt as default description.
267
- Commit: `feat: implement spawn with model resolution on SubagentsService adapter`
268
-
269
- 5. **`src/service-adapter.ts` — `steer()`, `abort()`, `waitForAll()`, `hasRunning()`.**
270
- Test: `steer` returns `false` for non-running agent, `true` when session queues or delivers; `abort`/`waitForAll`/`hasRunning` delegate to manager.
271
- Commit: `feat: implement steer, abort, waitForAll, hasRunning on adapter`
272
-
273
- 6. **Wire into `src/index.ts` — replace old global with typed service.**
274
- Replace `Symbol.for("pi-subagents:manager")` block with `publishSubagentsService(createSubagentsService(...))`.
275
- Update `session_shutdown` to call `unpublishSubagentsService()`.
276
- Commit: `feat!: publish SubagentsService at extension init, remove old untyped global`
277
-
278
- 7. **Add `exports` to `package.json`.**
279
- Add `"exports": { ".": "./src/service.ts" }` so consumers can `import("@gotgenes/pi-subagents")`.
280
- Commit: `feat: expose public service entry point via package exports`
281
-
282
- 8. **Run full suite and type check.**
283
- `pnpm vitest run && pnpm run check`.
284
- Fix any straggling references to `MANAGER_KEY` or `"pi-subagents:manager"` in tests.
285
- Commit (if fixes needed): `test: update references to old Symbol.for key`
286
-
287
- ## Risks and Mitigations
288
-
289
- | Risk | Mitigation |
290
- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
291
- | Consumers relying on the old `pi-subagents:manager` key break silently | This is a `feat!:` (major bump). No other package in this monorepo references the old key. Document migration in CHANGELOG via release-please. |
292
- | `exports` field breaks Pi's extension loader | Pi loads via `pi.extensions` (`./src/index.ts`), which is separate from `exports`. The `exports` field only affects `import("@gotgenes/pi-subagents")` from consumer code. Same pattern as `pi-permission-system`. |
293
- | Adapter leaks internal state if `AgentRecord` gains new non-serializable fields | `toSubagentRecord()` uses an explicit allowlist (pick pattern), not a denylist. New fields must be opted in. |
294
- | `steer()` race condition — session created between status check and queue push | The existing tool handler has the same race window and handles it acceptably. The adapter uses the same pattern (check session → queue if absent → delegate if present). |
295
- | `resolveModel` returns `any` — type unsafety at boundary | The adapter's `AgentManagerLike.spawn` already accepts `Model<any>` for the `options.model` field. The `any` is confined to the model-resolution seam, matching existing code. |
296
- | Architecture doc uses different naming (`SubagentsAPI`, `pi:service:subagents`) | Open question documented below. Update the architecture doc during implementation to reflect final naming. |
297
-
298
- ## Open Questions
299
-
300
- - Should `SubagentsService` be augmented with an `onEvent(channel, callback)` subscription method, or is `pi.events.on(SUBAGENT_EVENTS.COMPLETED, ...)` sufficient for consumers?
301
- Deferred — consumers already have access to `pi.events` and the event constants are exported.
302
- - The architecture doc uses `SubagentsAPI` naming and `pi:service:subagents` key.
303
- This plan intentionally diverges to align with the established `pi-permission-system` pattern (`*Service` naming, `@gotgenes/<pkg>:service` key, `Record<symbol, unknown>` cast).
304
- The architecture doc should be updated during implementation to reflect the final naming.
@@ -1,180 +0,0 @@
1
- ---
2
- issue: 49
3
- issue_title: "feat: remove group-join, output-file, and ad-hoc RPC"
4
- ---
5
-
6
- # Remove group-join and ad-hoc RPC
7
-
8
- ## Problem Statement
9
-
10
- Two optional subsystems remain in the core that are either consumer concerns or replaced by the typed `SubagentsAPI` (#48):
11
-
12
- 1. **Group join** — grouped completion notifications add batching complexity for marginal UX benefit when individual notifications are sufficient.
13
- 2. **Ad-hoc RPC** — untyped RPC over `pi.events` with per-request reply channels is replaced by the typed `SubagentsAPI` published via `Symbol.for()`.
14
-
15
- Removing these two subsystems reduces the core's surface area by ~220 source LOC, eliminates the join-mode settings system, and simplifies the completion callback path in `index.ts`.
16
-
17
- The **output file** subsystem (`src/output-file.ts`) is retained — it provides valuable post-hoc debugging transcripts for subagent sessions.
18
- A separate issue (#61) tracks porting it to Pi's official JSONL session format.
19
-
20
- ## Goals
21
-
22
- - Delete `src/group-join.ts` (141 LOC) and `src/cross-extension-rpc.ts` (80 LOC).
23
- - Delete `test/cross-extension-rpc.test.ts`.
24
- - Remove all group-join wiring from `index.ts`: `GroupJoinManager` instantiation, batch tracking (`currentBatchAgents`, `finalizeBatch`, `batchFinalizeTimer`, `batchCounter`), join-mode configuration state, and settings menu entry.
25
- - Remove all RPC wiring from `index.ts`: `registerRpcHandlers` import, `currentCtx` capture for RPC, `unsubPing/Spawn/Stop` teardown, and the `subagents:ready` broadcast.
26
- - Remove `JoinMode` type and `joinMode`/`groupId` fields from `types.ts`.
27
- - Remove `NotificationDetails.others` field (no longer needed without grouping).
28
- - Remove `defaultJoinMode` from `SubagentsSettings` and `SettingsAppliers` in `settings.ts`.
29
- - Remove `resolveJoinMode` from `invocation-config.ts`.
30
- - Simplify the completion callback in `index.ts` to always send an individual notification.
31
- - Preserve existing lifecycle events (`subagents:started`, `subagents:completed`, `subagents:failed`) — they are already emitted.
32
- - This is a **breaking change** (`feat!:`) — the join-mode setting is removed and RPC channels are no longer registered.
33
-
34
- ## Non-Goals
35
-
36
- - Removing the `Symbol.for("pi-subagents:manager")` global accessor — that belongs to #48 (implement SubagentsAPI), which replaces it with the typed `publishSubagentsAPI()`.
37
- - Removing `bypassQueue` from `SpawnOptions` — it remains useful for the typed API.
38
- - Providing migration shims for RPC consumers — none known.
39
- - Removing or modifying `src/output-file.ts` — retained for debugging value; porting to Pi's JSONL format is tracked in #61.
40
-
41
- ## Background
42
-
43
- The architecture doc marks these modules as "removing."
44
- Issue #52 (remove scheduled subagents) is already implemented and merged.
45
- Issue #48 (implement SubagentsAPI) depends on RPC removal here since the typed API replaces the untyped RPC.
46
-
47
- The `index.ts` file is the primary wiring layer affected.
48
- The completion callback currently routes through `groupJoin.onAgentComplete()` and only falls through to `sendIndividualNudge()` on `'pass'`.
49
- After this change, the callback always calls `sendIndividualNudge()` directly, which simplifies the control flow from ~90 lines of group/batch logic down to a single function call.
50
-
51
- The `currentCtx` variable captured in `session_start` exists solely for the RPC spawn handler.
52
- After RPC removal, session lifecycle hooks simplify: `session_start` only needs `manager.clearCompleted()`.
53
-
54
- ## Design Overview
55
-
56
- This is a pure deletion change with minor simplification of the remaining completion path.
57
-
58
- After removal, the background-agent completion flow becomes:
59
-
60
- 1. `AgentManager` calls `onComplete(record)`.
61
- 2. `onComplete` emits `subagents:completed` or `subagents:failed` on `pi.events`.
62
- 3. `onComplete` persists the record via `pi.appendEntry`.
63
- 4. If `record.resultConsumed`, clean up widget and return.
64
- 5. Otherwise, call `sendIndividualNudge(record)` — which schedules the notification with a 200ms debounce window (retained for `get_subagent_result` cancellation).
65
-
66
- The `NotificationDetails` interface stays (individual notifications still use it) but loses the `others` field.
67
- The `outputFile` field on `NotificationDetails` stays since output-file is retained.
68
-
69
- ### Settings changes
70
-
71
- `SubagentsSettings` loses `defaultJoinMode`.
72
- The settings menu loses the "Join mode" entry.
73
- `snapshotSettings()` and `persistToastFor()` patterns are unchanged — they just carry one fewer field.
74
-
75
- ### Types changes
76
-
77
- ```typescript
78
- // Remove from types.ts:
79
- export type JoinMode = 'async' | 'group' | 'smart';
80
-
81
- // Remove from AgentRecord:
82
- groupId?: string;
83
- joinMode?: JoinMode;
84
-
85
- // Remove from NotificationDetails:
86
- others?: NotificationDetails[];
87
- ```
88
-
89
- `AgentRecord.outputFile`, `outputCleanup`, and `toolCallId` are retained — they support the output-file subsystem which remains in scope.
90
-
91
- ## Module-Level Changes
92
-
93
- ### Delete
94
-
95
- | File | Lines |
96
- | ---------------------------------- | ----- |
97
- | `src/group-join.ts` | 141 |
98
- | `src/cross-extension-rpc.ts` | 80 |
99
- | `test/cross-extension-rpc.test.ts` | ~220 |
100
-
101
- ### Modify
102
-
103
- | File | Change |
104
- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
105
- | `src/index.ts` | Remove imports for group-join and RPC modules. Remove `GroupJoinManager` instantiation and the grouped-delivery callback (~30 lines). Remove batch tracking state and `finalizeBatch()` (~40 lines). Remove join-mode state (`defaultJoinMode`, `getDefaultJoinMode`, `setDefaultJoinMode`). Remove RPC registration, `currentCtx` capture, `unsubPing/Spawn/Stop` teardown. Remove `subagents:ready` emit. Remove "Join mode" settings menu entry and `snapshotSettings` join-mode field. Simplify `onComplete` callback to always call `sendIndividualNudge`. Remove the `currentBatchAgents` deferred-notification check. Remove join-mode resolution in background spawn path. |
106
- | `src/types.ts` | Remove `JoinMode` type. Remove `groupId` and `joinMode` from `AgentRecord`. Remove `others` from `NotificationDetails`. |
107
- | `src/settings.ts` | Remove `JoinMode` import. Remove `defaultJoinMode` from `SubagentsSettings`. Remove `setDefaultJoinMode` from `SettingsAppliers`. Remove `VALID_JOIN_MODES`. Remove sanitize clause and `applySettings` clause for `defaultJoinMode`. |
108
- | `src/invocation-config.ts` | Remove `JoinMode` import. Remove `resolveJoinMode` export. |
109
- | `README.md` | Remove "Cross-extension RPC" section. Remove join-mode documentation. Remove `subagents:ready` from events table. Update settings persistence paragraph to drop join-mode. |
110
- | `.pi/skills/package-pi-subagents/SKILL.md` | Remove `cross-extension-rpc.ts` and `group-join.ts` from architecture diagram and module tables. Update `index.ts` description. |
111
-
112
- ## Test Impact Analysis
113
-
114
- 1. No new unit tests are needed — this is pure deletion.
115
- 2. `test/cross-extension-rpc.test.ts` becomes entirely redundant and is deleted.
116
- 3. `test/output-file.test.ts` is retained (output-file stays).
117
- 4. There is no dedicated `group-join.test.ts` — the group-join logic was only tested indirectly through integration.
118
- 5. Existing tests for `agent-manager`, `agent-runner`, `settings`, and `invocation-config` must be checked for references to `joinMode`, `groupId`, `defaultJoinMode`, or `resolveJoinMode` — any such references need updating.
119
- 6. The notification renderer test (if any) may reference `others` on `NotificationDetails` — check and remove.
120
-
121
- ## TDD Order
122
-
123
- Since this is a removal (not a feature), the order is deletion-first with validation passes.
124
-
125
- 1. **Delete source files for both subsystems.**
126
- Delete `src/group-join.ts`, `src/cross-extension-rpc.ts`.
127
- Delete `test/cross-extension-rpc.test.ts`.
128
- Commit: `feat!: remove group-join and cross-extension-rpc source`
129
-
130
- 2. **Remove RPC wiring from `index.ts`.**
131
- Remove `registerRpcHandlers` import and call.
132
- Remove `currentCtx` state and RPC-related `session_start`/`session_shutdown` logic (keep `manager.clearCompleted()` call).
133
- Remove `unsubPing/Spawn/Stop` teardown.
134
- Remove `subagents:ready` emit.
135
- Commit: `feat!: remove RPC wiring from index.ts`
136
-
137
- 3. **Remove group-join wiring from `index.ts`.**
138
- Remove `GroupJoinManager` import and instantiation (including the grouped-delivery callback).
139
- Remove batch tracking (`currentBatchAgents`, `batchFinalizeTimer`, `batchCounter`, `finalizeBatch`).
140
- Remove `defaultJoinMode` state, `getDefaultJoinMode`, `setDefaultJoinMode`.
141
- Remove join-mode resolution in background spawn path.
142
- Remove "Join mode" settings menu entry.
143
- Remove `defaultJoinMode` from `snapshotSettings()`.
144
- Simplify the `onComplete` callback: remove `currentBatchAgents` check and `groupJoin.onAgentComplete()` routing — always call `sendIndividualNudge(record)`.
145
- Remove `setDefaultJoinMode` from `applyAndEmitLoaded` appliers.
146
- Commit: `feat!: remove group-join wiring from index.ts`
147
-
148
- 4. **Clean up types, settings, and invocation-config.**
149
- Remove `JoinMode` type from `types.ts`.
150
- Remove `groupId` and `joinMode` from `AgentRecord`.
151
- Remove `others` from `NotificationDetails`.
152
- Remove `defaultJoinMode` from `SubagentsSettings` and `SettingsAppliers` in `settings.ts`.
153
- Remove `VALID_JOIN_MODES` and sanitize/apply clauses.
154
- Remove `resolveJoinMode` and `JoinMode` import from `invocation-config.ts`.
155
- Commit: `feat!: remove join-mode types and settings`
156
-
157
- 5. **Verify all tests pass and fix straggling references.**
158
- Run `pnpm vitest run` and `pnpm run check`.
159
- Fix any test fixtures or assertions that reference removed fields (`joinMode`, `groupId`, `defaultJoinMode`, `resolveJoinMode`).
160
- Commit (if fixes needed): `test: remove references to deleted subsystems from test fixtures`
161
-
162
- 6. **Update documentation.**
163
- Update `README.md`: remove "Cross-extension RPC" section, join-mode documentation, `subagents:ready` event row.
164
- Update settings persistence paragraph.
165
- Update `.pi/skills/package-pi-subagents/SKILL.md`: remove `cross-extension-rpc.ts` and `group-join.ts` from architecture diagram and module tables, update `index.ts` description.
166
- Commit: `docs: remove group-join and RPC from README and AGENTS`
167
-
168
- ## Risks and Mitigations
169
-
170
- | Risk | Mitigation |
171
- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
172
- | Missed references cause compile errors | `grep -rn 'group.join\|GroupJoin\|registerRpcHandlers\|resolveJoinMode\|JoinMode' src/` after each step. `pnpm run check` catches import errors. |
173
- | Test fixtures reference removed fields | Step 5 explicitly scans for and fixes these. TypeScript `noEmit` check catches type mismatches. |
174
- | `Symbol.for("pi-subagents:manager")` accidentally removed | Explicitly out of scope — this belongs to #48. The global accessor stays until the typed API replaces it. |
175
- | Breaking change not communicated | `feat!:` commit prefix triggers a major version bump via release-please. |
176
- | Settings file with `defaultJoinMode` on disk | `sanitize()` already drops unknown fields silently — once the field is removed from the interface, existing files just have an inert JSON key that is ignored on load. |
177
-
178
- ## Open Questions
179
-
180
- None — the issue scope is fully specified and the architecture doc ratified these removals.
@@ -1,77 +0,0 @@
1
- ---
2
- issue: 51
3
- issue_title: "docs: update ADR 0001 to reflect hard-fork decision"
4
- ---
5
-
6
- # Update ADR-0001 to reflect hard-fork decision
7
-
8
- ## Problem Statement
9
-
10
- [ADR-0001] was written when the fork was a thin-patch layer over `tintinweb/pi-subagents`.
11
- The new architecture document (`docs/architecture/architecture.md`) commits to a hard fork with material scope reduction — scheduling removal, a `SubagentsAPI` boundary, `index.ts` decomposition, and more.
12
-
13
- Several claims in [ADR-0001] are now outdated:
14
-
15
- 1. The status is "accepted" but the decision has been superseded by the architecture doc.
16
- 2. The Upstream PRs section states "the fork's divergence reduces to package naming and tooling," which is no longer true.
17
- 3. The Consequences → Operational section implies that merging the upstream PRs eliminates behavioral divergence, which no longer holds.
18
-
19
- ## Goals
20
-
21
- - Add a supersession note to [ADR-0001] pointing to `docs/architecture/architecture.md`.
22
- - Update the "Upstream PRs are open" subsection so the "divergence reduces to…" claim reflects reality.
23
- - Update the Consequences → Operational section to note intentional divergence per the architecture document.
24
- - Preserve all existing rationale — no information is removed.
25
-
26
- ## Non-Goals
27
-
28
- - Rewriting the ADR from scratch — the original context is still useful.
29
- - Updating the architecture document itself.
30
- - Any code changes.
31
-
32
- ## Background
33
-
34
- [ADR-0001] has YAML frontmatter (`status: accepted`, `date: 2026-05-11`) and follows a standard ADR structure: Status, Context, Decision, Consequences.
35
-
36
- The architecture document (`docs/architecture/architecture.md`) describes a six-phase plan that materially diverges from upstream: scheduling removal, ad-hoc RPC replacement, group-join and output-file removal, a typed `SubagentsAPI` boundary, and `index.ts` decomposition.
37
-
38
- The three upstream PRs (#71, #72, #73) are still open and factually accurate — that section just needs the concluding sentence revised.
39
-
40
- ## Design Overview
41
-
42
- The update touches three areas of the ADR:
43
-
44
- 1. **Frontmatter + Status section** — change `status: accepted` to `status: superseded` in frontmatter, and update the Status section body to read "Superseded" with a pointer to `docs/architecture/architecture.md`.
45
- 2. **"Upstream PRs are open" subsection** — keep the PR list and factual statements intact; revise the final sentence ("Once these land upstream, the fork's divergence reduces to package naming and tooling.") to note that the fork now diverges intentionally beyond those patches, per the architecture document.
46
- 3. **Consequences → Operational** — add a sentence noting that the fork diverges intentionally beyond patches, and that the architecture document governs the fork's direction going forward.
47
- Keep the existing bullet about upstream PRs.
48
-
49
- No structural changes (new sections, removed sections, reordered content).
50
-
51
- ## Module-Level Changes
52
-
53
- | File | Change |
54
- | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
- | `docs/decisions/0001-deferred-patches.md` | Update frontmatter `status` from `accepted` to `superseded`; revise Status section; revise closing sentence in "Upstream PRs are open"; add divergence note to Consequences → Operational |
56
-
57
- ## Test Impact Analysis
58
-
59
- No tests are affected — this is a docs-only change.
60
-
61
- ## TDD Order
62
-
63
- 1. Update [ADR-0001] with all four edits described above.
64
- Commit: `docs: update ADR 0001 to reflect hard-fork decision (#51)`
65
-
66
- ## Risks and Mitigations
67
-
68
- | Risk | Mitigation |
69
- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
70
- | Supersession note makes the ADR look stale | Keep all original rationale intact; the note clarifies evolution, not obsolescence |
71
- | Wording drift between ADR and architecture doc | Use a direct pointer (`docs/architecture/architecture.md`) rather than paraphrasing the architecture doc's decisions |
72
-
73
- ## Open Questions
74
-
75
- None — the issue's acceptance criteria are unambiguous.
76
-
77
- [ADR-0001]: ../decisions/0001-deferred-patches.md