@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,41 +0,0 @@
1
- ---
2
- issue: 61
3
- issue_title: "feat: port subagent transcript logging to Pi's official JSONL session format"
4
- ---
5
-
6
- # Retro: #61 — port subagent transcript logging to Pi's official JSONL session format
7
-
8
- ## Final Retrospective (2026-05-20T17:15:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped a migration from the bespoke `output-file.ts` transcript format to Pi's official JSONL session format via `SessionManager.create()`.
13
- The change replaced 143 lines of manual streaming code with 3 lines leveraging the SDK's native persistence, nested subagent sessions under the parent session directory with `parentSession` header linking.
14
- Released as `pi-subagents-v6.0.0` (major version bump due to breaking transcript format change).
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The plan-to-implementation translation was clean: 6 TDD steps mapped to 7 commits (one extra `fix:` for biome lint).
21
- No steps needed reordering or merging.
22
- - The `ask_user` design decision gates during planning (persistence strategy, file location) produced clear answers that avoided rework during implementation.
23
- - Research into nicobailon/pi-subagents, edxeth/pi-subagents, and HazAT/pi-interactive-subagents provided useful reference for the session directory layout, confirming the parent-relative nesting pattern.
24
- - The biome lint catch on the unused `cwd` parameter led to a better design — incorporating `cwd` into the temp fallback path for project namespacing — rather than a mechanical underscore prefix.
25
-
26
- #### What caused friction (agent side)
27
-
28
- - `missing-context` — The plan listed test impact for `agent-runner.test.ts` but didn't grep for other test files mocking `SessionManager` or `ctx.sessionManager`.
29
- Three additional files needed updating: `agent-runner-extension-tools.test.ts`, `print-mode.test.ts`, and `test/tools/agent-tool.test.ts`.
30
- The testing skill explicitly says "grep for ALL test files that construct a compatible mock — not just factory helpers."
31
- Impact: ~5 minutes of reactive fixes during Step 4.
32
- Self-identified at implementation time.
33
-
34
- - `missing-context` — The plan didn't account for the timing difference between the old synchronous `record.outputFile` assignment (immediately after `spawn()`) and the new asynchronous availability (after `SessionManager.create()` runs inside `runAgent()`).
35
- This required adding `session.sessionManager.getSessionFile()` in the `onSessionCreated` callback — a design decision made during implementation.
36
- Impact: minor within-step rework, no extra commit needed.
37
-
38
- #### What caused friction (user side)
39
-
40
- - The dependency update to 0.75.4 was a reasonable pre-plan request, but it added ~10 minutes of tangential work (diagnosing `pnpm update` resolution behavior, normalizing version specifiers).
41
- This could have been a separate commit/session, though batching it was pragmatic since it gave the plan access to the latest SDK types.
@@ -1,44 +0,0 @@
1
- ---
2
- issue: 66
3
- issue_title: "refactor: replace `as any` casts in extracted tool/menu factories with proper SDK types"
4
- ---
5
-
6
- # Retro: #66 — replace `as any` casts with proper SDK types
7
-
8
- ## Final Retrospective (2026-05-20T18:50:00Z)
9
-
10
- ### Session summary
11
-
12
- Replaced all 14 `as any` casts in `src/index.ts` by typing 5 factory dep interfaces with proper SDK types (`ExtensionContext`, `AgentSession`, `ExtensionAPI`, `ModelRegistry`) and the newly-exported `SpawnOptions`.
13
- Released as `pi-subagents-v5.8.1` with zero behavioral change across 520 tests.
14
- The plan, implementation, and shipping were completed in a single session with 6 implementation commits.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Thorough context-gathering during planning paid off: reading all 5 dep interfaces, the SDK `.d.ts` files, test mock helpers, and the `ExtensionUIContext` shape before writing the plan meant most steps landed on first `pnpm run check`.
21
- - The plan's risk table anticipated the cascading `as any` issue on `createAgentTool` and prepared a mitigation ("add explicit `satisfies ToolDefinition<…>` if needed"), which was close to the actual fix needed.
22
- - Steps 4 and 5 (`GetResultDeps`, `SteerToolDeps`) were trivially clean — single-type-import changes that compiled immediately.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `missing-context` — The plan assumed `NotificationDeps.sendMessage.display` could be optional (`display?: boolean`) but the SDK's `CustomMessage.display` is required `boolean`.
27
- First `pnpm run check` after step 2 failed; required one extra edit-verify cycle.
28
- Impact: added friction but no rework (fixed in the same commit).
29
-
30
- - `missing-context` — The plan did not check the `execute` function's full signature in `agent-tool.ts`.
31
- Removing the outer `as any` on `createAgentTool({...})` exposed three additional type mismatches: `onUpdate` parameter type (`unknown` vs `AgentToolResult<any>`), `signal` optionality (`AbortSignal` vs `AbortSignal | undefined`), and `params.description` (`unknown` vs `string`).
32
- The plan flagged cascading risk but assumed only the return type would be affected.
33
- Impact: step 3 required three extra edits and two extra `pnpm run check` cycles, noted as a deviation in the commit body.
34
-
35
- - `missing-context` — Steps 6 and 7 had to be folded into one commit.
36
- The plan listed them as independent steps but typing `AgentMenuManager.spawnAndWait(ctx: ExtensionContext)` immediately made `MenuContext` incompatible — `showGenerateWizard` passes `ctx: MenuContext` to the dep callback that now expects `ExtensionContext`.
37
- The testing skill already warns: "when a TDD plan lists separate steps that share a type definition, changing that type in step N breaks steps N+1…N+k."
38
- The planner failed to recognize that `MenuContext` and `AgentMenuManager.spawnAndWait` share a type dependency through `ctx`.
39
- Impact: no rework — the steps were folded successfully — but the plan's step count was inaccurate.
40
-
41
- #### What caused friction (user side)
42
-
43
- - No user-side friction observed.
44
- The user ran three sequential prompts (`/plan-issue 66`, `/tdd-plan`, `/ship-issue`) with no corrections or redirects needed.
@@ -1,43 +0,0 @@
1
- ---
2
- issue: 69
3
- issue_title: "refactor: eliminate module-scope mutable state in pi-subagents — create SubagentRuntime"
4
- ---
5
-
6
- # Retro: #69 — create SubagentRuntime
7
-
8
- ## Final Retrospective (2026-05-19T16:47:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped `SubagentRuntime` — a composition-root object that replaces module-scope mutable state in `agent-runner.ts` and closure-scoped state in `index.ts`.
13
- Six TDD steps completed with one deviation: `agent-tool.ts` and `agent-menu.ts` also imported the removed getter/setter exports, requiring unplanned fixes.
14
- Released as `pi-subagents-v5.2.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The lift-and-shift strategy (introduce `RunOptions` fields alongside module-scope fallback, wire consumers, then remove old path) kept the 460-test suite green through every intermediate commit.
21
- No step broke existing tests.
22
- - `pnpm run check` caught the two missing downstream files (`agent-tool.ts`, `agent-menu.ts`) immediately after the removal step.
23
- The typecheck-after-removal safety net worked exactly as intended.
24
- - The `pi-permission-system` prior art (`ExtensionRuntime` in #43) provided a clear structural template, reducing design decisions to near zero.
25
-
26
- #### What caused friction (agent side)
27
-
28
- - `missing-context` — The plan's Module-Level Changes listed `agent-runner.ts`, `agent-manager.ts`, and `index.ts` but missed `src/tools/agent-tool.ts` and `src/ui/agent-menu.ts`, both of which imported `getDefaultMaxTurns`/`setDefaultMaxTurns`/`getGraceTurns`/`setGraceTurns` from `agent-runner.ts`.
29
- A grep for all importers of the removed symbols during planning would have caught this.
30
- Impact: 4 extra files touched in step 5 (the two source files + their test helpers); no rework of earlier steps, but the commit scope was wider than planned. (self-identified at `pnpm run check` time)
31
-
32
- - `missing-context` — In step 3 (`agent-manager.test.ts`), checked `vi.mocked(runAgent).mock.calls[0]` without clearing the mock first.
33
- The module-level `vi.mock("../src/agent-runner.js")` is shared across all describe blocks, so `calls[0]` picked up a stale invocation from an earlier test.
34
- Impact: one debug cycle adding `vi.mocked(runAgent).mockClear()` after `resolvedRun()`. (self-identified)
35
-
36
- #### What caused friction (user side)
37
-
38
- - Nothing notable.
39
- The plan was unambiguous, and the session ran without user intervention beyond the initial prompts.
40
-
41
- ### Changes made
42
-
43
- 1. `.pi/prompts/plan-issue.md` — added grep-importers rule to the Module-Level Changes bullet: when a step removes or renames an export, grep all `src/` and `test/` files for every removed symbol before finalizing the file list.
@@ -1,49 +0,0 @@
1
- ---
2
- issue: 70
3
- issue_title: "refactor: extract event handlers from pi-subagents index.ts into src/handlers/"
4
- ---
5
-
6
- # Retro: #70 — extract event handlers from index.ts
7
-
8
- ## Final Retrospective (2026-05-20T19:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented #70 — extracting four inline event handler lambdas from `src/index.ts` into `src/handlers/lifecycle.ts` (`SessionLifecycleHandler` class) and `src/handlers/tool-start.ts` (`ToolStartHandler` class).
13
- During planning, the user identified that the initial plain-function design missed shared collaborators and structural smells, prompting a redesign to class-based handlers and a predecessor issue (#87) to evolve `SubagentRuntime` from a data bag to an object with methods.
14
- Released as `pi-subagents-v5.8.0` with 8 new handler tests (520 total).
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The user's progressive questioning during planning ("Are you confident?", "Keep digging", Kent Beck quote) surfaced two concrete structural smells — output arguments on `runtime.currentCtx` writes and 8 LoD violations via `runtime.widget!` reach-throughs — that the initial design would have just relocated rather than fixed.
21
- - Filing predecessor #87 was the right sequencing call.
22
- By the time #70 executed, the runtime had proper methods and the handler extraction was purely mechanical.
23
- - The 3-step TDD cycle executed cleanly with zero rework or deviations from the plan.
24
- The only issue was a `tsc` type error (`vi.fn()` return type not assignable to `() => void`) caught during the post-TDD type check and fixed in-place before the final commit.
25
-
26
- #### What caused friction (agent side)
27
-
28
- - `premature-convergence` — The initial plan used plain functions with per-call `LifecycleDeps`/`ToolStartDeps` interfaces, the first viable approach, without analyzing whether handlers shared collaborators.
29
- The user had to prompt three times before I switched to class-based handlers with constructor-injected shared deps.
30
- Impact: three rounds of plan revision before the design was correct; no rework commits, but significant planning churn.
31
-
32
- - `instruction-violation` (user-caught) — The `/plan-issue` prompt says "load the `design-review` skill and run its checklist on the affected modules."
33
- I loaded the skill but did not actually run the checklist (grep for access patterns, check LoD, check output arguments) until the user explicitly told me to "keep digging."
34
- Had I run the checklist proactively, the output-argument and LoD findings would have surfaced on the first pass, and the predecessor issue (#87) would have been identified without user escalation.
35
- Impact: user had to escalate three times; planning took ~3× longer than necessary.
36
-
37
- - `wrong-abstraction` — I initially reasoned at the mechanical level ("handlers are small, 1–5 lines, so plain functions are fine") instead of the structural level ("do these handlers share collaborators that a class captures naturally?").
38
- The code-style skill explicitly says "Do not pass a shared dependency bag to functions that only use a subset" — but I applied it backwards (splitting into per-function deps) rather than recognizing the shared deps as a class cohesion signal.
39
- Impact: same as premature-convergence above; folded into the same rework cycle.
40
-
41
- #### What caused friction (user side)
42
-
43
- - The progressive escalation approach (question → directive → quote) was effective pedagogically but required three turns of user attention on what a proactive design-review checklist run would have caught automatically.
44
- Earlier intervention with a specific redirect (e.g., "Run the design-review checklist before writing the plan") could have resolved it in one turn.
45
-
46
- ### Changes made
47
-
48
- 1. Retro file created at `packages/pi-subagents/docs/retro/0070-extract-event-handlers.md`.
49
- 2. Updated `packages/pi-subagents/docs/architecture/architecture.md` — marked #87 and #70 as done (✓), updated Phase 2 status to complete, updated next-issue pointer to #66.
@@ -1,60 +0,0 @@
1
- ---
2
- issue: 71
3
- issue_title: "refactor: extract pure agent-session assembler from agent-runner.ts"
4
- ---
5
-
6
- # Retro: #71 - extract session-config assembler
7
-
8
- ## Final Retrospective (2026-05-19T22:15:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped `assembleSessionConfig()` - a pure configuration assembler extracted from `runAgent()` in `agent-runner.ts`.
13
- Eight TDD steps completed across three phases (plan, implement, ship), adding 33 new tests in `test/session-config.test.ts` and reducing `runAgent()` from ~390 lines to ~198.
14
- Released as `pi-subagents-v5.3.0`.
15
- Filed follow-up #80 (consolidate `getConfig`/`getAgentConfig`) and updated the architecture roadmap.
16
-
17
- ### Observations
18
-
19
- #### What went well
20
-
21
- - The user's redirecting question ("Do we need more decomposition?
22
- Are there any seams we can exploit?") at the `as any` fix point was perfectly timed.
23
- It shifted the approach from mechanical casting (8 `as any` casts) to a structural fix: `unknown` for opaque model handles, `Array<{ provider: string; id: string }>` for the availability check.
24
- The final design removed the `@earendil-works/pi-ai` import from `session-config.ts` entirely - cleaner than the plan's original specification of `Model<any>`.
25
- - The prior art from `pi-permission-system` (`evaluate()` extraction) provided a clear template for the pure-core-from-IO-shell pattern.
26
- Design decisions were minimal.
27
- - All 451 existing tests stayed green through every intermediate commit.
28
- The mock-at-module-boundary strategy (`vi.mock("../src/agent-types.js")` etc.) meant existing `agent-runner.test.ts` mocks continued to intercept the same module paths even after the assembler delegated to them.
29
-
30
- #### What caused friction (agent side)
31
-
32
- - `premature-convergence` - When `pnpm run check` surfaced 10 type errors from `Model<any>` in `SessionConfig`, the first fix attempt was adding `as any` casts to the `vi.fn` factory return values and all test model objects (8 casts total).
33
- This partially addressed the symptom but created new `never[]` inference errors and left a fundamentally wrong interface.
34
- The user's first pushback ("Can we find a real type?") prompted a proper analysis of `Model<TApi>`'s ~10 required fields, leading to the `unknown` solution.
35
- Impact: ~20 minutes of rework across 3 attempts (the `as any` factory cast, diagnosing the residual `never[]` errors, and the final `unknown` rewrite). (user-caught)
36
-
37
- - `missing-context` - The plan omitted `agentMaxTurns` from the `SessionConfig` return type.
38
- `runAgent()`'s turn-limit resolution reads `agentConfig?.maxTurns`, which is no longer available after the assembly delegation.
39
- Caught during step 7 (wiring) when the code wouldn't compile without it.
40
- Impact: added one field to `SessionConfig` and `assembleSessionConfig`; no rework of earlier steps, but the commit body noted the deviation. (self-identified at implementation time)
41
-
42
- - `missing-context` - The `vi.fn(() => [])` → `never[]` TypeScript inference issue wasn't anticipated.
43
- Five mock factories (`mockGetMemoryToolNames`, `mockGetReadOnlyMemoryToolNames`, `mockPreloadSkills`, `mockRegistry.find`, `mockRegistry.getAvailable`) needed explicit return-type annotations.
44
- Impact: one debug cycle to diagnose, then a second to fix with `import type` annotations. (self-identified during `pnpm run check`)
45
-
46
- #### What caused friction (user side)
47
-
48
- - The user's second pushback ("Do we need more decomposition?") was the highest-leverage intervention in the session.
49
- Without it, the `as any` approach would have landed and the `pi-ai` import would have stayed in `session-config.ts` - defeating the goal of a SDK-free business-logic module.
50
- The pattern of catching design-level issues through "is there a better seam?"
51
- questions is worth preserving.
52
-
53
- #### Design observations (not actionable as rules)
54
-
55
- - The `cfg.model as Model<any> | undefined` cast in `agent-runner.ts` is a legitimate interim cost — it's one line at the SDK boundary and will be resolved when #66 (replace `as any` casts with proper SDK types) and #72 (AgentManager DI) refine the interface contracts.
56
- Codifying “use `unknown` + boundary cast” as a general pattern would normalize something that should feel uncomfortable and motivate further interface refinement.
57
-
58
- ### Changes made
59
-
60
- 1. `.pi/skills/testing/SKILL.md` — added `vi.fn()` return-type annotation rule under “Vitest mock patterns”: annotate factories that return empty arrays or narrow literals to prevent `never[]` inference.
@@ -1,46 +0,0 @@
1
- ---
2
- issue: 72
3
- issue_title: "refactor: dependency-inject AgentManager's collaborators"
4
- ---
5
-
6
- # Retro: #72 — dependency-inject AgentManager's collaborators
7
-
8
- ## Final Retrospective (2026-05-20T17:50:00Z)
9
-
10
- ### Session summary
11
-
12
- Defined `AgentRunner` and `WorktreeManager` interfaces, converted `AgentManager`'s 6-positional-parameter constructor to an options bag with injected collaborators, migrated all 19 test sites from `vi.mock()` to `vi.fn()` stubs, and added 7 new DI-enabled tests.
13
- The planning phase required significant user redirection to arrive at the right abstractions; the TDD execution phase was clean with zero rework.
14
- Released as `pi-subagents-v5.6.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The `ask_user` interactions during planning surfaced genuine design decisions (options bag vs positional constructor, lifecycle callback grouping) that the issue body left open.
21
- The user's responses were substantive and redirecting.
22
- - The user's "make the change that makes the change easy" framing identified #84 (`GitWorktreeManager` extraction) as a prerequisite, which made #72's implementation clean — zero type-shuffling needed.
23
- - The lift-and-shift test migration (Phase B → Phase C) worked exactly as planned: introduce `createManager()` helper under the old constructor, then switch it to the options bag atomically.
24
- All 19 test sites migrated with no logic changes.
25
- - `Promise.withResolvers` (ES2024) in the new queueing test made controlled async coordination clean — no manual resolve/reject wiring.
26
-
27
- #### What caused friction (agent side)
28
-
29
- - `wrong-abstraction` — Spent ~4 analysis cycles on "how to move types between files" (`ToolActivity`, `RunOptions`, `WorktreeInfo` → `types.ts`) when the real question was "what objects want to exist?"
30
- The user had to redirect three times: "are there real objects with state?", "what state IS in AgentRunner?", and "we haven't pulled all the threads."
31
- Impact: added ~10 minutes of back-and-forth during planning, but ultimately produced a better design (stateful `WorktreeManager` vs stateless `AgentRunner` seam, plus #84 as prep).
32
- The dependency-graph analysis itself was sound — it confirmed no circular deps — but it answered a question nobody was asking.
33
-
34
- - `premature-convergence` — First draft of the plan included `WorktreeManager` extraction as "Phase A step 1" inside #72.
35
- The user asked "did we create another issue that we need to tackle first?"
36
- — pointing out that the prep work should be its own issue.
37
- Impact: minor rework to update the plan and file #84; no code rework since it was caught during planning. (User-caught.)
38
-
39
- #### What caused friction (user side)
40
-
41
- - The user's early redirect ("take a step back — does the AgentManager really need six params?") could have been even more direct — e.g., "before we discuss constructor shape, what higher-level abstractions are missing?"
42
- That said, the Socratic approach ultimately led to a better shared understanding of why `WorktreeManager` is a real object and `AgentRunner` is a seam.
43
-
44
- ### Changes made
45
-
46
- 1. Retro file created at `packages/pi-subagents/docs/retro/0072-inject-agent-manager-collaborators.md`.
@@ -1,35 +0,0 @@
1
- ---
2
- issue: 76
3
- issue_title: "refactor: inject cwd into AgentManager constructor instead of reading process.cwd() in dispose()"
4
- ---
5
-
6
- # Retro: #76 — inject cwd into AgentManager constructor
7
-
8
- ## Final Retrospective (2026-05-19T21:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped a single-step refactoring that injects `cwd: string` into the `AgentManager` constructor, replacing the `process.cwd()` call in `dispose()` with `this.cwd`.
13
- Released as `pi-subagents-v5.4.1`.
14
- The entire cycle (plan → TDD → ship → release) completed in one session with one minor friction point.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Clean single-commit implementation: one `refactor:` commit touched 3 files, updated 18 test constructor calls plus one production call site, and added one new assertion — all green on first run.
21
- - TDD Red phase worked well despite the plan calling this a "single-step refactoring."
22
- Writing a new test (`"calls pruneWorktrees with the cwd passed to the constructor"`) gave a clear Red signal before the implementation change, even though the constructor signature change had to be applied atomically.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `wrong-abstraction` — The plan's "Test Impact Analysis" stated "No new unit tests are needed" and framed existing tests as sufficient.
27
- In practice, the existing tests only called `dispose()` in `afterEach` hooks without assertions on `pruneWorktrees` arguments, so a new test was needed for a proper Red phase.
28
- The user noticed the discrepancy before TDD began ("We will at least alter some tests, right?").
29
- Impact: one clarifying exchange, no rework.
30
- User-caught.
31
-
32
- #### What caused friction (user side)
33
-
34
- - None observed.
35
- The user's question about test changes was a useful early catch that would have surfaced during TDD anyway.
@@ -1,33 +0,0 @@
1
- ---
2
- issue: 77
3
- issue_title: "refactor: add projectAgentsDir to AgentMenuDeps instead of reading process.cwd() inline"
4
- ---
5
-
6
- # Retro: #77 — inject projectAgentsDir into AgentMenuDeps
7
-
8
- ## Final Retrospective (2026-05-20T16:15:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped a refactoring that adds `projectAgentsDir: string` to `AgentMenuDeps`, replacing the inline `process.cwd()` lambda in `createAgentsMenuHandler`.
13
- The change mirrors the existing `personalAgentsDir` injection pattern.
14
- Released as `pi-subagents-v5.8.2`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Clean end-to-end execution: plan → TDD → ship with zero corrections or rework.
21
- - The Red test was well-targeted: exercised `findAgentFile` through the menu navigation path and naturally failed because `process.cwd()` produced a different path than the injected `/test-project/.pi/agents`.
22
- - Correctly identified at execution time that the plan's two-step TDD split was impractical (interface change is atomic) and combined into a single `refactor:` commit.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `instruction-violation` — The plan listed two TDD commits (step 1: `test:`, step 2: `refactor:`) but adding a required field to `AgentMenuDeps` is an atomic change — the test references the new field, so both must land together.
27
- The testing skill's shared-type-definition rule ("changing that type in step N breaks steps N+1…N+k — fold them into one step") should have been applied during planning.
28
- Impact: added friction but no rework — the deviation was self-identified at execution time and the steps were combined.
29
- Self-identified.
30
-
31
- #### What caused friction (user side)
32
-
33
- - None observed.
@@ -1,35 +0,0 @@
1
- ---
2
- issue: 80
3
- issue_title: "refactor: consolidate getConfig / getAgentConfig into a single resolution path"
4
- ---
5
-
6
- # Retro: #80 — consolidate getConfig / getAgentConfig
7
-
8
- ## Final Retrospective (2026-05-20T00:35:00Z)
9
-
10
- ### Session summary
11
-
12
- Consolidated two overlapping agent config lookup functions (`getConfig` and `getAgentConfig`) into a single `resolveAgentConfig(type): AgentConfig` with a guaranteed-non-null return and internal fallback chain.
13
- Migrated all 6 source callers and 5 test files across 6 TDD commits, then shipped as `pi-subagents-v5.4.0`.
14
-
15
- ### Observations
16
-
17
- #### What went well
18
-
19
- - The lift-and-shift migration strategy (add new function → migrate callers incrementally → remove old functions) kept every commit green.
20
- No intermediate step broke the test suite.
21
- - The planning phase correctly identified an under-documented scope question (callers beyond the two mentioned in the issue) and used `ask-user` to resolve it before writing the plan.
22
- - The `test/prompts.test.ts` caller, missed by the plan, was caught cleanly during the final grep sweep in step 6 — no rework needed, just an additional edit in the same commit.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `missing-context` — The plan specified that `resolveAgentConfig` should fall back for disabled types (matching `getConfig`'s semantics), but didn't trace what `agent-menu.ts` actually reads from disabled configs.
27
- `agent-menu.ts` iterates `getAllTypes()` (including disabled agents) and needs the real config to render `✕` indicators, source badges, and `(disabled)` descriptions.
28
- With fallback-for-disabled semantics, disabled agents would silently display as general-purpose.
29
- Caught during step 4 while editing `agent-menu.ts`, before any wrong test assertions ran.
30
- Impact: required changing `resolveAgentConfig` semantics (only fall back for unknown types, not disabled) and updating the step 1 test — a ~5 minute fix folded into the step 4 commit.
31
-
32
- #### What caused friction (user side)
33
-
34
- - Nothing notable.
35
- The user's `ask-user` response during planning ("remove both, migrate all callers") was clear and included a useful directional note about computing values earlier.
@@ -1,37 +0,0 @@
1
- ---
2
- issue: 84
3
- issue_title: "refactor: extract GitWorktreeManager class from worktree.ts free functions"
4
- ---
5
-
6
- # Retro: #84 — extract GitWorktreeManager class from worktree.ts free functions
7
-
8
- ## Final Retrospective (2026-05-20T13:31:00Z)
9
-
10
- ### Session summary
11
-
12
- Extracted a `WorktreeManager` interface and `GitWorktreeManager` class from the three free functions in `worktree.ts`.
13
- The two-step TDD cycle (add tests → add implementation) executed cleanly with no rework or deviations from the plan.
14
- Released as `pi-subagents-v5.5.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The issue body included an exact "Proposed Interface" section with TypeScript code, which made the plan nearly mechanical and eliminated all design ambiguity.
21
- The `ask-user` step was correctly skipped.
22
- - The two-step TDD cycle was appropriately minimal for a thin delegation extraction — no over-engineering of the test or commit structure.
23
- - The full pipeline (plan → TDD → ship → release) completed in a single pass with zero corrections.
24
-
25
- #### What caused friction (agent side)
26
-
27
- No friction observed.
28
- The issue was well-scoped and the existing pipeline instructions handled every step.
29
-
30
- #### What caused friction (user side)
31
-
32
- No friction observed.
33
- The pipeline was driven cleanly with `/plan-issue` → `/tdd-plan` → `/ship-issue`.
34
-
35
- ### Changes made
36
-
37
- 1. Retro file created at `packages/pi-subagents/docs/retro/0084-extract-git-worktree-manager.md`.
@@ -1,42 +0,0 @@
1
- ---
2
- issue: 87
3
- issue_title: "refactor: evolve SubagentRuntime from data bag to object with methods"
4
- ---
5
-
6
- # Retro: #87 — evolve SubagentRuntime from data bag to object with methods
7
-
8
- ## Final Retrospective (2026-05-20T18:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped #87 — converting `SubagentRuntime` from a plain interface + factory into a class with session-context methods (`setSessionContext`, `clearSessionContext`) and widget delegation methods (`setUICtx`, `onTurnStart`, `markFinished`, `updateWidget`, `ensureTimer`).
13
- All 10 call sites in `index.ts` were migrated, eliminating raw `currentCtx` field writes and `runtime.widget!` reach-throughs.
14
- Released as `pi-subagents-v5.7.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The 3-step TDD cycle executed cleanly with zero rework or deviations from the plan.
21
- Test count went from 5 → 16 in `runtime.test.ts`; all 512 package tests stayed green throughout.
22
- - The user identified a missing architecture update and a pre-existing hallucination (`@earendil-works/pi-subagents` → `@gotgenes/pi-subagents`) after the plan commit.
23
- The fix was a single well-scoped commit (`ddee1a0`) that corrected 10 scope references, updated the dependency graph to include #87 as a precursor to #70, and fixed list numbering per phase heading.
24
- - The plan's "Call sites to migrate" tables with exact line numbers and before/after code made step 3 (the refactoring commit) purely mechanical — no design decisions at implementation time.
25
-
26
- #### What caused friction (agent side)
27
-
28
- - `missing-context` — In TDD step 2, the new `describe` block used `vi.fn()` but the test file's import was `{ describe, expect, it }` without `vi`.
29
- The first red run surfaced this immediately (`ReferenceError: vi is not defined`) and it was fixed before the green step.
30
- Impact: one extra test run, no rework commits.
31
- - `scope-drift` — The `/plan-issue` prompt does not instruct updating `architecture.md`, but the user noticed #87 was missing from the roadmap's dependency graph.
32
- The agent hadn't checked `architecture.md` during planning even though #87 is explicitly listed as a precursor to #70 in the #70 plan.
33
- Impact: user-caught; required a follow-up edit pass after the plan commit.
34
-
35
- #### What caused friction (user side)
36
-
37
- No friction observed.
38
- The user's correction about `architecture.md` was well-targeted and caught a real gap.
39
-
40
- ### Changes made
41
-
42
- 1. Retro file created at `packages/pi-subagents/docs/retro/0087-evolve-subagent-runtime-methods.md`.
@@ -1,46 +0,0 @@
1
- ---
2
- issue: 98
3
- issue_title: "Extract AgentRecord state machine from scattered status transitions"
4
- ---
5
-
6
- # Retro: #98 — Extract AgentRecord state machine
7
-
8
- ## Final Retrospective (2026-05-20T23:45:00Z)
9
-
10
- ### Session summary
11
-
12
- Converted `AgentRecord` from a plain interface to a class with 7 encapsulated transition methods, centralizing the scattered status-transition logic from 6 locations in `agent-manager.ts`.
13
- The prerequisite issue #102 (shared test factory) made the class conversion a 2-file change instead of an 8-file rewrite.
14
- Released as `pi-subagents-v6.1.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The "encapsulate last" TDD strategy (cycles 1–5 with public fields, cycle 6 makes them private) let the compiler verify migration completeness before locking down access.
21
- `get-result-tool.test.ts` and `make-record.test.ts` failures were caught immediately.
22
- - The worktree-reorder design insight (compute final result including branch text before calling the transition method) avoided the need for an `appendToResult()` method and survived implementation unchanged.
23
- - The prerequisite issue #102 (shared `createTestRecord` factory) proved essential — the class conversion touched only the factory and `agent-manager.ts`, not 8 individual test files.
24
-
25
- #### What caused friction (agent side)
26
-
27
- - `premature-convergence` — The initial plan proposed `MutableAgentRecord` alongside the existing interface, which was the lowest-friction path but the wrong abstraction.
28
- The user redirected twice ("It should definitely become a class" → "I meant encapsulate") before the design was right.
29
- Impact: full plan rewrite and an extra prerequisite issue (#102).
30
- The plan template's "use ask-user for ambiguous design choices" instruction applied (class vs wrapper was genuinely ambiguous), but I didn't invoke it.
31
-
32
- - `missing-context` — The revised plan stated "No test files need updating (except the shared factory)" but missed `{ ...baseRecord, field }` spread patterns in `test/notification.test.ts`, `test/service-adapter.test.ts`, `test/tools/get-result-tool.test.ts`, and `test/helpers/make-record.test.ts`.
33
- Spreading a class instance produces a plain object that lacks the class's methods.
34
- Impact: 4 extra test files needed mechanical fixes in cycles 4 and 6; plan's "Unchanged files" list was wrong.
35
- The compiler caught all of them, so no behavioral risk, but the plan should have predicted the churn.
36
-
37
- #### What caused friction (user side)
38
-
39
- - The issue body was intentionally flexible ("onto AgentRecord (or a thin wrapper)"), which left the wrapper-vs-class decision open.
40
- The user's preference for a class with encapsulated state became clear only after seeing the initial plan.
41
- Earlier signal (e.g., labeling the issue with a "class conversion" tag or stating "must encapsulate" in the issue body) would have avoided the plan rewrite.
42
-
43
- ### Changes made
44
-
45
- 1. `.pi/skills/testing/SKILL.md` — Added interface→class spread-pattern rule to TDD planning rules.
46
- 2. `.pi/skills/package-pi-subagents/SKILL.md` — Added `agent-record.ts` to the Core engine module table and updated `types.ts` description.
@@ -1,37 +0,0 @@
1
- ---
2
- issue: 99
3
- issue_title: "Replace live `ctx` capture with ParentSnapshot in AgentManager"
4
- ---
5
-
6
- # Retro: #99 — Replace live ctx capture with ParentSnapshot
7
-
8
- ## Final Retrospective (2026-05-20T20:30:00-04:00)
9
-
10
- ### Session summary
11
-
12
- Implemented the `ParentSnapshot` extraction — Step 2 of the AgentManager internal decomposition.
13
- The user prompted a mid-planning restructure using Kent Beck's "make the change that makes the change easy" principle, which split the work into two clean phases: pi-elimination prep (cycles 1–2), then snapshot introduction (cycles 3–5).
14
- All 5 cycles landed first-try with no rework, releasing as `pi-subagents-v6.2.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The two-phase plan structure (prep then payload) kept each cycle focused on one concern.
21
- Cycle 5 was particularly clean — only 2 files changed because `buildParentSnapshot` was mocked in agent-manager tests.
22
- - `sed` for mechanical bulk replacements (27 `spawn(mockPi,` → `spawn(mockCtx,`) was the right tool — faster and less error-prone than 27 individual edits.
23
- - The `pnpm run check` after cycle 4 caught exactly the expected type error in `agent-manager.ts`, confirming the incremental approach was working as designed.
24
-
25
- #### What caused friction (agent side)
26
-
27
- - `wrong-abstraction` — Initial plan (before user intervention) interleaved pi-elimination and snapshot concerns across all 5 cycles.
28
- The user had to invoke Kent Beck's principle to trigger the restructure.
29
- Impact: one plan rewrite (amend commit), but no implementation rework since it happened before coding started.
30
-
31
- - `missing-context` — Used `Parameters<typeof createAgentSession>[0]["modelRegistry"]` as a type cast without checking that the SDK's `createAgentSession` parameter type is a union including `undefined`.
32
- Impact: minimal — caught immediately by `pnpm run check`, fixed with a simple `as any` in the same cycle.
33
-
34
- #### What caused friction (user side)
35
-
36
- - The user's "make the change easy" prompt was well-timed — after the plan was written but before implementation.
37
- No suggestions for improvement here; the intervention was strategic and well-placed.
@@ -1,36 +0,0 @@
1
- ---
2
- issue: 100
3
- issue_title: "Replace callback threading with direct session-event subscription"
4
- ---
5
-
6
- # Retro: #100 — Replace callback threading with direct session-event subscription
7
-
8
- ## Final Retrospective (2026-05-20T22:30:00-04:00)
9
-
10
- ### Session summary
11
-
12
- Implemented Step 3 of the AgentManager internal decomposition — replacing the 3-layer callback-threading pattern with two independent session observers (`subscribeRecordObserver` and `subscribeUIObserver`).
13
- Five TDD cycles landed with only one unanticipated test breakage, releasing as `pi-subagents-v6.3.0`.
14
- `SpawnOptions` dropped 5 `on*` fields, `RunOptions` dropped 5, and `ResumeOptions` dropped 3, with net −220 lines of source code removed.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The phased plan structure (extract observers → wire AgentManager → wire agent-tool → simplify runner) created clean isolation between cycles.
21
- Each cycle touched 1–2 source files and 1 test file, making changes easy to review.
22
- - Upgrading `mockSession()` once in cycle 3 to support `subscribe()` and `emit()` was a one-time investment that made the stat-verification tests more realistic — events now drive record state instead of manually calling callbacks on `RunOptions`.
23
- - The `resume()` simplification was particularly clean: 10 lines of callback wiring reduced to 2 lines (`subscribeRecordObserver` + `runner.resume` with only `{ signal }`).
24
- - All 5 TDD cycles except one landed first-try with no rework.
25
-
26
- #### What caused friction (agent side)
27
-
28
- - `missing-context` — The plan listed `bindExtensions({ onError })` as part of the unchanged runner code, but the `onError` handler called `options.onToolActivity` which was removed in cycle 5.
29
- The plan said "grep for `ToolActivity`" but the reference was inside a function literal passed to `bindExtensions`, not a type import.
30
- Impact: one unexpected test failure in cycle 5 (`bindExtensions` test expected `onError`), caught immediately and fixed in the same commit.
31
- Noted in commit body as a plan deviation.
32
-
33
- #### What caused friction (user side)
34
-
35
- - No friction observed.
36
- The issue description was thorough and unambiguous, and the user's involvement was limited to triggering each phase (`/plan-issue`, `/tdd-plan`, `/ship-issue`).
@@ -1,30 +0,0 @@
1
- ---
2
- issue: 102
3
- issue_title: "Consolidate test AgentRecord construction into a shared factory"
4
- ---
5
-
6
- # Retro: #102 — Consolidate test AgentRecord construction into a shared factory
7
-
8
- ## Final Retrospective (2026-05-20T15:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned, implemented, and shipped a shared `createTestRecord()` factory in `test/helpers/make-record.ts`, migrating 7 test files from local factories and inline literals.
13
- The session completed in three slash-command phases (plan → TDD → ship) with zero rework, zero test failures, and zero deviations from the plan.
14
- Released as `pi-subagents-v6.0.1`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The Explore subagent surveyed all 8 test files' factory patterns in parallel, producing a structured comparison table that directly informed the plan's default-value decisions.
21
- - Before migrating `service-adapter.test.ts`, reading the `toSubagentRecord` source confirmed that `!== undefined` guards make absent-property vs. property-set-to-undefined semantically equivalent — avoiding a subtle test failure.
22
- - All 4 TDD steps passed on first run, confirming the plan's migration strategy (preserve old defaults via overrides) was sound.
23
-
24
- #### What caused friction (agent side)
25
-
26
- No friction points — the mechanical nature of the refactoring and the well-specified plan eliminated ambiguity.
27
-
28
- #### What caused friction (user side)
29
-
30
- No friction points — the three-phase slash-command workflow required no manual intervention.