@gotgenes/pi-subagents 18.0.1 → 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 (260) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/docs/architecture/architecture.md +157 -204
  3. package/docs/architecture/history/phase-19-implement-ui-decisions.md +282 -0
  4. package/package.json +5 -6
  5. package/src/lifecycle/subagent.ts +5 -9
  6. package/src/observation/notification.ts +23 -10
  7. package/src/observation/subagent-events-observer.ts +1 -3
  8. package/src/tools/get-result-report.ts +60 -0
  9. package/src/tools/get-result-tool.ts +25 -40
  10. package/src/types.ts +1 -1
  11. package/src/ui/session-navigator.ts +0 -2
  12. package/.prettierignore +0 -5
  13. package/AGENTS.md +0 -7
  14. package/docs/plans/0048-implement-subagents-api.md +0 -304
  15. package/docs/plans/0049-remove-group-join-output-file-rpc.md +0 -180
  16. package/docs/plans/0051-update-adr-0001-hard-fork.md +0 -77
  17. package/docs/plans/0052-remove-scheduled-subagents.md +0 -133
  18. package/docs/plans/0053-extract-model-resolution-from-execute.md +0 -181
  19. package/docs/plans/0054-decompose-index-into-modules.md +0 -302
  20. package/docs/plans/0057-structured-debug-logging.md +0 -154
  21. package/docs/plans/0061-session-format-transcript.md +0 -284
  22. package/docs/plans/0066-replace-as-any-with-sdk-types.md +0 -215
  23. package/docs/plans/0069-create-subagent-runtime.md +0 -345
  24. package/docs/plans/0070-extract-event-handlers.md +0 -306
  25. package/docs/plans/0071-extract-session-config-assembler.md +0 -362
  26. package/docs/plans/0072-inject-agent-manager-collaborators.md +0 -329
  27. package/docs/plans/0076-inject-cwd-into-agent-manager.md +0 -102
  28. package/docs/plans/0077-inject-project-agents-dir.md +0 -115
  29. package/docs/plans/0080-consolidate-agent-config-lookup.md +0 -247
  30. package/docs/plans/0084-extract-git-worktree-manager.md +0 -142
  31. package/docs/plans/0087-evolve-subagent-runtime-methods.md +0 -240
  32. package/docs/plans/0098-extract-agent-record-state-machine.md +0 -435
  33. package/docs/plans/0099-replace-ctx-with-parent-snapshot.md +0 -488
  34. package/docs/plans/0100-replace-callback-threading-with-session-subscription.md +0 -454
  35. package/docs/plans/0102-consolidate-test-record-factory.md +0 -176
  36. package/docs/plans/0108-extract-agent-type-registry.md +0 -322
  37. package/docs/plans/0109-extract-settings-manager.md +0 -276
  38. package/docs/plans/0110-agent-activity-tracker.md +0 -297
  39. package/docs/plans/0111-split-agent-record-lifecycle.md +0 -582
  40. package/docs/plans/0112-replace-agent-manager-callbacks.md +0 -241
  41. package/docs/plans/0113-disambiguate-spawn-options.md +0 -155
  42. package/docs/plans/0114-narrow-agent-tool-menu-deps.md +0 -279
  43. package/docs/plans/0115-decompose-agent-tool.md +0 -337
  44. package/docs/plans/0116-type-housekeeping.md +0 -351
  45. package/docs/plans/0118-settings-manager-apply-methods.md +0 -271
  46. package/docs/plans/0123-remove-vi-fn-cast-smell.md +0 -179
  47. package/docs/plans/0131-consolidate-shared-test-fixtures.md +0 -207
  48. package/docs/plans/0132-inject-io-into-session-config.md +0 -219
  49. package/docs/plans/0133-inject-sdk-boundary-into-agent-runner.md +0 -373
  50. package/docs/plans/0134-reduce-as-any-casts.md +0 -366
  51. package/docs/plans/0135-extract-display-helpers.md +0 -182
  52. package/docs/plans/0136-decompose-agent-menu.md +0 -300
  53. package/docs/plans/0144-consolidate-observation-model.md +0 -263
  54. package/docs/plans/0145-decompose-execute-push-ctx-to-boundary.md +0 -290
  55. package/docs/plans/0146-narrow-ui-context.md +0 -319
  56. package/docs/plans/0147-inject-wrap-text-into-conversation-viewer.md +0 -166
  57. package/docs/plans/0148-split-agent-widget-rendering.md +0 -255
  58. package/docs/plans/0152-add-prompt-snippet.md +0 -91
  59. package/docs/plans/0164-reorganize-into-domain-directories.md +0 -409
  60. package/docs/plans/0165-decompose-resolved-spawn-config.md +0 -157
  61. package/docs/plans/0166-extract-parent-session-info.md +0 -231
  62. package/docs/plans/0167-narrow-runner-io.md +0 -150
  63. package/docs/plans/0168-extract-tool-filter-config.md +0 -173
  64. package/docs/plans/0169-extract-run-context-from-run-options.md +0 -194
  65. package/docs/plans/0170-reduce-build-content-lines-complexity.md +0 -225
  66. package/docs/plans/0171-reduce-render-result-complexity.md +0 -200
  67. package/docs/plans/0172-extract-turn-formatting.md +0 -206
  68. package/docs/plans/0180-reorder-append-prompt-for-kv-cache.md +0 -100
  69. package/docs/plans/0185-remove-persistent-agent-memory.md +0 -161
  70. package/docs/plans/0188-replace-any-casts-with-sdk-types.md +0 -162
  71. package/docs/plans/0192-define-session-context-interface.md +0 -107
  72. package/docs/plans/0193-runtime-owns-context-queries.md +0 -245
  73. package/docs/plans/0194-align-tool-interfaces-for-structural-typing.md +0 -139
  74. package/docs/plans/0195-convert-tool-factories-to-classes.md +0 -264
  75. package/docs/plans/0196-convert-runner-menu-to-classes.md +0 -268
  76. package/docs/plans/0205-decompose-render-widget-lines.md +0 -140
  77. package/docs/plans/0206-decompose-show-agent-detail.md +0 -211
  78. package/docs/plans/0207-decompose-agent-widget-update.md +0 -242
  79. package/docs/plans/0208-extract-shared-test-fixtures.md +0 -298
  80. package/docs/plans/0214-convert-remaining-closure-factories-to-classes.md +0 -261
  81. package/docs/plans/0215-decompose-build-parent-context.md +0 -166
  82. package/docs/plans/0216-decompose-start-agent.md +0 -255
  83. package/docs/plans/0217-extract-overwrite-guard.md +0 -176
  84. package/docs/plans/0218-push-sdk-boundary-in-settings.md +0 -172
  85. package/docs/plans/0219-reduce-test-duplication-top-3-clone-families.md +0 -162
  86. package/docs/plans/0227-evolve-agent-record-into-agent.md +0 -322
  87. package/docs/plans/0228-async-start-agent-dissolve-run-handle.md +0 -288
  88. package/docs/plans/0229-agent-born-complete.md +0 -564
  89. package/docs/plans/0230-extract-concurrency-queue.md +0 -265
  90. package/docs/plans/0231-push-exec-registry-to-runner.md +0 -245
  91. package/docs/plans/0232-agent-resume-internal-observer-lifecycle.md +0 -180
  92. package/docs/plans/0237-remove-disallowed-tools.md +0 -180
  93. package/docs/plans/0238-remove-extensions-filtering.md +0 -191
  94. package/docs/plans/0239-collapse-filter-active-tools.md +0 -217
  95. package/docs/plans/0242-rename-agent-tool-to-subagent.md +0 -165
  96. package/docs/plans/0256-extract-worktree-isolation.md +0 -256
  97. package/docs/plans/0257-extract-child-session-factory.md +0 -285
  98. package/docs/plans/0262-add-workspace-provider-seam.md +0 -264
  99. package/docs/plans/0264-remove-extension-lifecycle-control.md +0 -277
  100. package/docs/plans/0265-born-complete-subagent-session.md +0 -333
  101. package/docs/plans/0270-type-consumable-public-surface.md +0 -204
  102. package/docs/plans/0272-export-workspace-collaborator-types.md +0 -147
  103. package/docs/plans/0277-encapsulate-agent-session.md +0 -304
  104. package/docs/plans/0280-rename-agent-to-subagent.md +0 -197
  105. package/docs/plans/0360-custom-agents-default-append.md +0 -132
  106. package/docs/plans/0373-extract-subagent-state.md +0 -250
  107. package/docs/plans/0374-encapsulate-subagent-start-notification.md +0 -268
  108. package/docs/plans/0375-extract-run-listener-workspace-bracket.md +0 -300
  109. package/docs/plans/0376-extract-manager-observer.md +0 -232
  110. package/docs/plans/0377-split-widget-delegation-from-runtime.md +0 -254
  111. package/docs/plans/0378-consolidate-lifecycle-test-fixtures.md +0 -243
  112. package/docs/plans/0379-consolidate-ui-tools-test-fixtures.md +0 -335
  113. package/docs/plans/0380-extract-layered-settings-loader.md +0 -223
  114. package/docs/plans/0381-replace-concurrency-queue-with-limiter.md +0 -267
  115. package/docs/plans/0400-include-parent-prompt-in-replace-mode.md +0 -199
  116. package/docs/plans/0403-abort-subagents-on-interrupt.md +0 -180
  117. package/docs/plans/0412-unify-session-mock-builders.md +0 -146
  118. package/docs/plans/0420-fold-run-metrics-live-activity-onto-record.md +0 -228
  119. package/docs/plans/0421-migrate-activity-readers-to-record-getters.md +0 -309
  120. package/docs/plans/0422-delete-activity-tracker-ui-observer.md +0 -204
  121. package/docs/plans/0423-widget-self-drive-from-lifecycle.md +0 -264
  122. package/docs/plans/0424-drop-widget-dep-from-subagent-tool.md +0 -166
  123. package/docs/plans/0425-reconcile-subagent-events-contract.md +0 -144
  124. package/docs/plans/0426-consolidate-residual-test-clone-families.md +0 -235
  125. package/docs/plans/0427-reconsider-ui-direction.md +0 -212
  126. package/docs/plans/0441-remove-agent-definition-management-subtree.md +0 -180
  127. package/docs/plans/0442-dissolve-agents-conversation-viewer.md +0 -195
  128. package/docs/plans/0443-consolidate-remaining-test-clone-families.md +0 -268
  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/plans/0470-refresh-readme-command-surface.md +0 -159
  137. package/docs/retro/0048-implement-subagents-api.md +0 -44
  138. package/docs/retro/0049-remove-group-join-output-file-rpc.md +0 -49
  139. package/docs/retro/0051-update-adr-0001-hard-fork.md +0 -39
  140. package/docs/retro/0053-extract-model-resolution-from-execute.md +0 -40
  141. package/docs/retro/0054-decompose-index-into-modules.md +0 -53
  142. package/docs/retro/0057-structured-debug-logging.md +0 -77
  143. package/docs/retro/0061-session-format-transcript.md +0 -41
  144. package/docs/retro/0066-replace-as-any-with-sdk-types.md +0 -44
  145. package/docs/retro/0069-create-subagent-runtime.md +0 -43
  146. package/docs/retro/0070-extract-event-handlers.md +0 -49
  147. package/docs/retro/0071-extract-session-config-assembler.md +0 -60
  148. package/docs/retro/0072-inject-agent-manager-collaborators.md +0 -46
  149. package/docs/retro/0076-inject-cwd-into-agent-manager.md +0 -35
  150. package/docs/retro/0077-inject-project-agents-dir.md +0 -33
  151. package/docs/retro/0080-consolidate-agent-config-lookup.md +0 -35
  152. package/docs/retro/0084-extract-git-worktree-manager.md +0 -37
  153. package/docs/retro/0087-evolve-subagent-runtime-methods.md +0 -42
  154. package/docs/retro/0098-extract-agent-record-state-machine.md +0 -46
  155. package/docs/retro/0099-replace-ctx-with-parent-snapshot.md +0 -37
  156. package/docs/retro/0100-replace-callback-threading-with-session-subscription.md +0 -36
  157. package/docs/retro/0102-consolidate-test-record-factory.md +0 -30
  158. package/docs/retro/0108-extract-agent-type-registry.md +0 -41
  159. package/docs/retro/0109-extract-settings-manager.md +0 -55
  160. package/docs/retro/0110-agent-activity-tracker.md +0 -44
  161. package/docs/retro/0111-split-agent-record-lifecycle.md +0 -61
  162. package/docs/retro/0112-replace-agent-manager-callbacks.md +0 -35
  163. package/docs/retro/0113-disambiguate-spawn-options.md +0 -29
  164. package/docs/retro/0114-narrow-agent-tool-menu-deps.md +0 -38
  165. package/docs/retro/0115-decompose-agent-tool.md +0 -51
  166. package/docs/retro/0116-type-housekeeping.md +0 -42
  167. package/docs/retro/0118-settings-manager-apply-methods.md +0 -40
  168. package/docs/retro/0123-remove-vi-fn-cast-smell.md +0 -49
  169. package/docs/retro/0131-consolidate-shared-test-fixtures.md +0 -46
  170. package/docs/retro/0132-inject-io-into-session-config.md +0 -33
  171. package/docs/retro/0133-inject-sdk-boundary-into-agent-runner.md +0 -45
  172. package/docs/retro/0134-reduce-as-any-casts.md +0 -56
  173. package/docs/retro/0135-extract-display-helpers.md +0 -38
  174. package/docs/retro/0136-decompose-agent-menu.md +0 -43
  175. package/docs/retro/0144-consolidate-observation-model.md +0 -39
  176. package/docs/retro/0145-decompose-execute-push-ctx-to-boundary.md +0 -56
  177. package/docs/retro/0146-narrow-ui-context.md +0 -70
  178. package/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md +0 -90
  179. package/docs/retro/0148-split-agent-widget-rendering.md +0 -39
  180. package/docs/retro/0152-add-prompt-snippet.md +0 -34
  181. package/docs/retro/0164-reorganize-into-domain-directories.md +0 -82
  182. package/docs/retro/0165-decompose-resolved-spawn-config.md +0 -78
  183. package/docs/retro/0166-extract-parent-session-info.md +0 -66
  184. package/docs/retro/0167-narrow-runner-io.md +0 -63
  185. package/docs/retro/0168-extract-tool-filter-config.md +0 -76
  186. package/docs/retro/0169-extract-run-context-from-run-options.md +0 -68
  187. package/docs/retro/0170-reduce-build-content-lines-complexity.md +0 -72
  188. package/docs/retro/0171-reduce-render-result-complexity.md +0 -77
  189. package/docs/retro/0172-extract-turn-formatting.md +0 -80
  190. package/docs/retro/0180-reorder-append-prompt-for-kv-cache.md +0 -62
  191. package/docs/retro/0185-remove-persistent-agent-memory.md +0 -73
  192. package/docs/retro/0188-replace-any-casts-with-sdk-types.md +0 -69
  193. package/docs/retro/0192-define-session-context-interface.md +0 -59
  194. package/docs/retro/0193-runtime-owns-context-queries.md +0 -75
  195. package/docs/retro/0194-align-tool-interfaces-for-structural-typing.md +0 -62
  196. package/docs/retro/0195-convert-tool-factories-to-classes.md +0 -84
  197. package/docs/retro/0196-convert-runner-menu-to-classes.md +0 -73
  198. package/docs/retro/0205-decompose-render-widget-lines.md +0 -64
  199. package/docs/retro/0206-decompose-show-agent-detail.md +0 -67
  200. package/docs/retro/0207-decompose-agent-widget-update.md +0 -92
  201. package/docs/retro/0208-extract-shared-test-fixtures.md +0 -102
  202. package/docs/retro/0214-convert-remaining-closure-factories-to-classes.md +0 -66
  203. package/docs/retro/0215-decompose-build-parent-context.md +0 -61
  204. package/docs/retro/0216-decompose-start-agent.md +0 -80
  205. package/docs/retro/0217-extract-overwrite-guard.md +0 -63
  206. package/docs/retro/0218-push-sdk-boundary-in-settings.md +0 -72
  207. package/docs/retro/0219-reduce-test-duplication-top-3-clone-families.md +0 -64
  208. package/docs/retro/0227-evolve-agent-record-into-agent.md +0 -80
  209. package/docs/retro/0228-async-start-agent-dissolve-run-handle.md +0 -80
  210. package/docs/retro/0229-agent-born-complete.md +0 -89
  211. package/docs/retro/0230-extract-concurrency-queue.md +0 -38
  212. package/docs/retro/0231-push-exec-registry-to-runner.md +0 -71
  213. package/docs/retro/0232-agent-resume-internal-observer-lifecycle.md +0 -109
  214. package/docs/retro/0237-remove-disallowed-tools.md +0 -78
  215. package/docs/retro/0238-remove-extensions-filtering.md +0 -72
  216. package/docs/retro/0239-collapse-filter-active-tools.md +0 -70
  217. package/docs/retro/0242-rename-agent-tool-to-subagent.md +0 -82
  218. package/docs/retro/0256-extract-worktree-isolation.md +0 -89
  219. package/docs/retro/0257-extract-child-session-factory.md +0 -33
  220. package/docs/retro/0262-add-workspace-provider-seam.md +0 -89
  221. package/docs/retro/0264-remove-extension-lifecycle-control.md +0 -91
  222. package/docs/retro/0265-born-complete-subagent-session.md +0 -97
  223. package/docs/retro/0270-type-consumable-public-surface.md +0 -108
  224. package/docs/retro/0272-export-workspace-collaborator-types.md +0 -38
  225. package/docs/retro/0277-encapsulate-agent-session.md +0 -80
  226. package/docs/retro/0280-rename-agent-to-subagent.md +0 -96
  227. package/docs/retro/0360-custom-agents-default-append.md +0 -81
  228. package/docs/retro/0373-extract-subagent-state.md +0 -94
  229. package/docs/retro/0374-encapsulate-subagent-start-notification.md +0 -171
  230. package/docs/retro/0375-extract-run-listener-workspace-bracket.md +0 -104
  231. package/docs/retro/0376-extract-manager-observer.md +0 -81
  232. package/docs/retro/0377-split-widget-delegation-from-runtime.md +0 -105
  233. package/docs/retro/0378-consolidate-lifecycle-test-fixtures.md +0 -100
  234. package/docs/retro/0379-consolidate-ui-tools-test-fixtures.md +0 -52
  235. package/docs/retro/0380-extract-layered-settings-loader.md +0 -97
  236. package/docs/retro/0381-replace-concurrency-queue-with-limiter.md +0 -95
  237. package/docs/retro/0400-include-parent-prompt-in-replace-mode.md +0 -84
  238. package/docs/retro/0403-abort-subagents-on-interrupt.md +0 -90
  239. package/docs/retro/0412-unify-session-mock-builders.md +0 -80
  240. package/docs/retro/0420-fold-run-metrics-live-activity-onto-record.md +0 -90
  241. package/docs/retro/0421-migrate-activity-readers-to-record-getters.md +0 -105
  242. package/docs/retro/0422-delete-activity-tracker-ui-observer.md +0 -97
  243. package/docs/retro/0423-widget-self-drive-from-lifecycle.md +0 -112
  244. package/docs/retro/0424-drop-widget-dep-from-subagent-tool.md +0 -89
  245. package/docs/retro/0425-reconcile-subagent-events-contract.md +0 -101
  246. package/docs/retro/0426-consolidate-residual-test-clone-families.md +0 -100
  247. package/docs/retro/0427-reconsider-ui-direction.md +0 -102
  248. package/docs/retro/0441-remove-agent-definition-management-subtree.md +0 -97
  249. package/docs/retro/0442-dissolve-agents-conversation-viewer.md +0 -108
  250. package/docs/retro/0443-consolidate-remaining-test-clone-families.md +0 -28
  251. package/docs/retro/0444-shrink-widget-to-background-agents.md +0 -81
  252. package/docs/retro/0445-native-session-navigation.md +0 -122
  253. package/docs/retro/0446-spike-session-navigation-entry-criteria.md +0 -99
  254. package/docs/retro/0447-extract-subagents-settings-command.md +0 -91
  255. package/docs/retro/0448-block-disabled-agent-spawn.md +0 -75
  256. package/docs/retro/0462-navigation-renderer-tui-components.md +0 -105
  257. package/docs/retro/0463-file-snapshot-source-evicted-agents.md +0 -103
  258. package/docs/retro/0470-refresh-readme-command-surface.md +0 -40
  259. package/src/observation/notification-state.ts +0 -27
  260. package/vitest.config.ts +0 -14
@@ -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.
@@ -1,41 +0,0 @@
1
- ---
2
- issue: 108
3
- issue_title: "refactor(pi-subagents): extract AgentTypeRegistry class from module-scoped state"
4
- ---
5
-
6
- # Retro: #108 — extract AgentTypeRegistry class
7
-
8
- ## Final Retrospective (2026-05-21T13:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented the `AgentTypeRegistry` class extraction from module-scoped state in `agent-types.ts`.
13
- The lift-and-shift approach across 7 TDD steps (9 commits including plan and docs) migrated 11 source files and 11 test files while keeping 574 tests green at every commit.
14
- The `reloadCustomAgents` callback was removed from `AgentToolDeps` and `AgentMenuDeps`, replaced by `deps.registry.reload()`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The `AgentConfigLookup` narrow interface (ISP) for `session-config.ts` kept tests simple — plain objects with 2 methods, no class instantiation needed.
21
- - Using `vi.spyOn` on a real `AgentTypeRegistry` instance in `agent-menu.test.ts` was cleaner than `vi.hoisted` + `vi.fn()` factories: correct types, automatic cleanup via `vi.restoreAllMocks()`.
22
- - Step 2 (inject through 4-file config-assembly chain) was the riskiest single step but landed cleanly because the `vi.mock("agent-types.js")` stubs were narrowed to only the free functions that `session-config.ts` still imports (`getMemoryToolNames`, `getReadOnlyMemoryToolNames`).
23
-
24
- #### What caused friction (agent side)
25
-
26
- 1. `missing-context` — The plan's "Test files affected" table listed 8 files but missed 3 (`prompts.test.ts`, `tools/get-result-tool.test.ts`, `conversation-viewer.test.ts`) that directly import symbols being removed in step 7.
27
- The grep during planning found `prompts.test.ts` as an importer of `registerAgents` but didn't include it in the table.
28
- Impact: 3 extra test files needed updating in step 7; caught by the full-suite run, not by surprise in CI.
29
-
30
- 2. `wrong-abstraction` — First `perl -0777` regex for bulk-updating 16 `ConversationViewer` constructor calls in `conversation-viewer.test.ts` failed because the character class `[^)]+` didn't match the multi-line arguments.
31
- A simpler pattern targeting just the `vi.fn(),\n );` suffix worked on the second try.
32
- Impact: added friction but no rework — ~2 minutes.
33
-
34
- 3. `missing-context` — Type check after step 7 revealed `promptMode: string` vs `"replace" | "append"` narrowing issue in `agent-runner-extension-tools.test.ts`.
35
- The `agentConfigMock.current` object had `promptMode: "replace"` which TypeScript widened to `string` when spread into the mock `AgentConfigLookup` return.
36
- Impact: one additional edit with a return-type annotation; caught by `pnpm run check` as recommended by the testing skill.
37
-
38
- #### What caused friction (user side)
39
-
40
- - No user-side friction observed.
41
- The issue description was clear, the architecture doc had the design already sketched, and no mid-session redirects were needed.
@@ -1,55 +0,0 @@
1
- ---
2
- issue: 109
3
- issue_title: "refactor(pi-subagents): extract SettingsManager class"
4
- ---
5
-
6
- # Retro: #109 — extract SettingsManager class
7
-
8
- ## Final Retrospective (2026-05-21T17:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented the `SettingsManager` class extraction across 8 TDD cycles plus doc updates.
13
- The class owns `defaultMaxTurns`, `graceTurns`, and `maxConcurrent` with normalizing property accessors, a `load()` method for merged config, and `saveAndNotify()` for persistence + lifecycle events.
14
- Six settings-related callback fields in `AgentMenuDeps` collapsed to a single `settings` collaborator (13 → 8 fields), and `SettingsAppliers`, `applySettings`, `applyAndEmitLoaded`, `saveAndEmitChanged` were removed.
15
- A follow-up issue (#118) was filed for a LoD/Tell-Don't-Ask violation the user identified in the post-implementation review.
16
-
17
- ### Observations
18
-
19
- #### What went well
20
-
21
- - The lift-and-shift TDD approach worked cleanly: the new class was built and tested in isolation (cycles 1–2), consumers migrated one at a time (cycles 3–5), wiring consolidated (cycle 6), and old code removed last (cycles 7–8).
22
- Each commit left the repo in a valid state.
23
- - The user's design critique (LoD / Tell-Don't-Ask on `deps.settings.saveAndNotify()` orchestration) was sharp and led to a concrete follow-up issue (#118) with a clear fix.
24
- The session handled it well — acknowledged, designed the fix, filed the issue, updated the architecture doc, and stopped without scope-creeping into implementation.
25
-
26
- #### What caused friction (agent side)
27
-
28
- 1. `wrong-abstraction` — The plan did not anticipate that changing `AgentMenuDeps` (cycle 3) would immediately break `index.ts` type-checking.
29
- Each interface change in cycles 3, 4, and 5 required a same-commit bridge fix in `index.ts` to keep `pnpm run check` clean.
30
- The plan's separation of "migrate consumers" (cycles 3–5) from "wire in index.ts" (cycle 6) was too coarse — interface changes propagate to the call site immediately.
31
- Impact: three unplanned bridge edits in `index.ts`, each small but requiring context-switching mid-cycle.
32
-
33
- 2. `missing-context` — The `sed` command in cycle 5 (`sed -i '' 's/maxConcurrent: 1,/getMaxConcurrent: () => 1,/g'`) missed two call sites where `maxConcurrent: 1` had no trailing comma (end of object literal).
34
- A `grep` check after the `sed` would have caught this immediately.
35
- Impact: two tests failed unexpectedly; required a follow-up read + manual edit before the cycle could complete.
36
-
37
- 3. `missing-context` — The Edit tool failed on `runtime.ts` because the file uses `─` (U+2500, BOX DRAWINGS LIGHT HORIZONTAL) in section separators, not `—` (U+2014, EM DASH).
38
- The Unicode characters looked identical in the terminal, and the Edit tool's exact-match requirement meant the mismatch was silent until the replacement failed.
39
- Impact: three failed Edit attempts before falling back to a Python script for the replacement.
40
- This is the same class of issue seen in previous sessions with Unicode characters in source files.
41
-
42
- 4. `premature-convergence` — The plan designed `SettingsManager` as a data holder with persistence methods but didn't consider whether the menu should orchestrate across `settings` and `manager` or whether `SettingsManager` should own the full consequence chain.
43
- The user caught this as a LoD/Tell-Don't-Ask violation in post-implementation review.
44
- Impact: no rework (filed as follow-up #118), but the design could have been better from the start if the plan had applied the design-review checklist's LoD check to the proposed `showSettings` interaction pattern.
45
-
46
- #### What caused friction (user side)
47
-
48
- - The user's LoD critique was well-timed — after implementation was complete, avoiding mid-stream rework.
49
- If the critique had surfaced during planning (e.g., by the agent applying the design-review checklist to the proposed consumer interaction pattern), the follow-up issue might have been part of the original scope.
50
- This is an opportunity for the planning step to simulate the consumer's call sites before finalizing the design, not just the class interface.
51
-
52
- ### Changes made
53
-
54
- 1. `.pi/prompts/plan-issue.md` — Added consumer call-site sketch heuristic to the "Design Overview" section: when a new collaborator is introduced, sketch 3–5 lines of consumer pseudocode to verify Tell-Don't-Ask and LoD.
55
- 2. `.pi/skills/testing/SKILL.md` — Added TDD planning rule: when a step changes an interface with a single call site, the step must include updating that call site (type checker enforces co-location).
@@ -1,44 +0,0 @@
1
- ---
2
- issue: 110
3
- issue_title: "refactor(pi-subagents): wrap AgentActivity in AgentActivityTracker class"
4
- ---
5
-
6
- # Retro: #110 — wrap AgentActivity in AgentActivityTracker class
7
-
8
- ## Final Retrospective (2026-05-21T23:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented `AgentActivityTracker` class across 6 TDD cycles plus doc updates, released as `pi-subagents-v6.7.0`.
13
- The 7-field mutable `AgentActivity` interface was replaced with a class exposing explicit transition methods (`onToolStart`, `onToolEnd`, `onMessageStart`, `onMessageUpdate`, `onTurnEnd`, `onUsageUpdate`, `setSession`) and read-only accessors.
14
- All 7 source files and 3 test files were migrated incrementally without any big-bang commit.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - **TDD Red phase caught all three implementation bugs.**
21
- 1. `onToolEnd` initially incremented `toolUses` unconditionally (ported from original code), but the plan specified no-op defensive behavior.
22
- The Red phase test `"onToolEnd with no matching tool is a no-op"` caught it instantly.
23
- 2. `Date.now()` key collision in `activeTools` Map — two `onToolStart("Read")` calls in the same millisecond produced identical keys, so the second overwrote the first.
24
- The Red phase test `"multiple concurrent tools with same name tracked independently"` caught it.
25
- 3. `describeActivity` signature needed `ReadonlyMap<string, string>` after the accessor change — caught by `pnpm run check` in step 3.
26
- All three were fixed immediately with no cascading rework.
27
- - **Incremental migration avoided type breakage.**
28
- The plan kept `AgentActivity` alive in `agent-widget.ts` until step 3, so steps 1–2 compiled without touching downstream files.
29
- Each step only broke the files it was about to migrate, keeping intermediate states valid.
30
- - **Monotonic counter is strictly better than `Date.now()` for tool keys.**
31
- The extraction enabled replacing the `toolName + "_" + Date.now()` key strategy with `toolName + "_" + (++this._toolKeySeq)`, which never collides regardless of timing.
32
- This is a concrete improvement the original inline code couldn't easily adopt.
33
-
34
- #### What caused friction (agent side)
35
-
36
- - `missing-context` — The plan specified the `Date.now()` key strategy from the original code, but didn't account for same-millisecond collisions in test execution.
37
- Impact: ~1 minute debugging in step 1; trivial fix to monotonic counter.
38
- - `premature-convergence` — Initial `onToolEnd` implementation copied the original's unconditional `toolUses++` before checking the plan's specified no-op behavior.
39
- Impact: caught immediately by the Red phase test, single-line fix.
40
-
41
- #### What caused friction (user side)
42
-
43
- - No material friction observed.
44
- The session ran end-to-end (plan → implement → ship → release) without user intervention.
@@ -1,61 +0,0 @@
1
- ---
2
- issue: 111
3
- issue_title: "refactor(pi-subagents): split AgentRecord lifecycle state into phase-specific objects"
4
- ---
5
-
6
- # Retro: #111 — split AgentRecord lifecycle state into phase-specific objects
7
-
8
- ## Final Retrospective (2026-05-22T01:50:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented the `AgentRecord` lifecycle split across 12 TDD cycles plus doc updates, released as `pi-subagents-v6.8.0`.
13
- Three new phase-specific collaborators (`ExecutionState`, `WorktreeState`, `NotificationState`) replace 9 post-construction mutable fields.
14
- `pendingSteers` moved to a `Map` on `AgentManager`; stats (`toolUses`, `lifetimeUsage`, `compactionCount`) encapsulated behind mutation methods with read-only getters.
15
- `AgentRecordInit` trimmed from 19 optional fields to 4.
16
-
17
- ### Observations
18
-
19
- #### What went well
20
-
21
- - **Lift-and-shift scaled from 7 files (#110) to 18 files (#111) without any intermediate test breakage.**
22
- Every commit left all 41 test files passing.
23
- The pattern — add new alongside old, migrate consumers with fallbacks (`record.execution?.session ?? record.session`), strip fallbacks in a final commit — is reliable for multi-step encapsulation refactors.
24
- - **Stats encapsulation was simpler than expected.**
25
- Converting `toolUses`, `lifetimeUsage`, `compactionCount` to private fields with getters and mutation methods required zero changes to read-only consumers because the getter names match the old field names.
26
- Only `record-observer.ts` (the sole writer) needed updating.
27
- - **The `createTestRecord` factory intersection type trick preserved backward compatibility.**
28
- The factory accepts `toolUses?: number` via `Partial<AgentRecordInit> & { toolUses?: number; ... }` and internally calls `record.incrementToolUses()` in a loop.
29
- This let 10+ test files continue passing `toolUses: 5` without rewriting each to call mutation methods directly.
30
- - **`Promise.withResolvers` timing analysis in the plan was unnecessary.**
31
- The plan spent ~40 lines analyzing whether `promise` should live inside `ExecutionState` and concluded it should stay separate.
32
- Implementation confirmed: `record.execution` is set in `onSessionCreated` (async callback), `record.promise` is set after `runner.run()` (synchronous return) — different moments, straightforward.
33
-
34
- #### What caused friction (agent side)
35
-
36
- - `missing-context` — In the step 7 test for `record.execution`, the initial mock runner used `mockResolvedValue(...)` which doesn't call `onSessionCreated`, so `record.execution` stayed `undefined`.
37
- Had to switch to `mockImplementation(async (..., opts) => { opts.onSessionCreated?.(session); ... })`.
38
- The existing tests in the same file already use this pattern for record-observer tests, but I didn't check them first.
39
- Impact: one test rewrite (~2 minutes), no rework to production code.
40
- - `scope-drift` — Step 4 absorbed step 5 (adding collaborator fields) without noting the merge in the commit or session log.
41
- Step 5 became a no-op.
42
- Impact: no rework, but the session narrative skipped a plan step without explanation.
43
- - `wrong-abstraction` — Step 12 was planned as a simple cleanup ("remove old fields and trim `AgentRecordInit`") but required coordinated changes across 18 files: removing 9 fields from `AgentRecordInit`, updating the `createTestRecord` factory, fixing 5 test files that passed removed fields, and stripping all fallback patterns.
44
- This was 2-3 steps' worth of work compressed into one.
45
- Impact: step 12 took significantly longer than other steps, though it landed cleanly.
46
- - `missing-context` — Did not proactively flag the `as ReturnType<typeof vi.fn>` cast smell in `service-adapter.test.ts` while migrating that file.
47
- The user noticed it and asked about it.
48
- Filed as #123.
49
- Impact: added friction but no rework; follow-up issue created.
50
- User-caught.
51
-
52
- #### What caused friction (user side)
53
-
54
- - No material friction observed.
55
- The user's `ask_user` decisions during planning (NotificationState collaborator, Map on AgentManager) gave clear direction.
56
- Quick "follow-up" response on the cast smell kept scope tight.
57
-
58
- ### Changes made
59
-
60
- 1. `packages/pi-subagents/docs/retro/0111-split-agent-record-lifecycle.md` — this retro file.
61
- 2. `.pi/skills/testing/SKILL.md` — added field-removal rule symmetric to the existing field-addition rule (esbuild silent pass-through on unknown init properties).
@@ -1,35 +0,0 @@
1
- ---
2
- issue: 112
3
- issue_title: "refactor(pi-subagents): replace AgentManager callbacks with observer interface"
4
- ---
5
-
6
- # Retro: #112 — replace AgentManager callbacks with observer interface
7
-
8
- ## Final Retrospective (2026-05-21T21:00:00-04:00)
9
-
10
- ### Session summary
11
-
12
- Replaced three fire-and-forget callback fields (`onStart`, `onComplete`, `onCompact`) on `AgentManagerOptions` with a single `AgentManagerObserver` interface.
13
- The refactoring touched `agent-manager.ts`, `index.ts`, and `agent-manager.test.ts` with zero test-count delta (652/652).
14
- Released as `pi-subagents-v6.8.2`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The issue description was thorough and unambiguous — no `ask_user` needed during planning, and the design mapped directly to implementation.
21
- - Self-identified the testing skill's single-call-site rule during execution: the plan split Steps 2 and 3 into separate commits, but `AgentManagerOptions` has one call site in `index.ts`, so both had to land together.
22
- Merged them without rework.
23
- - Pre-existing lint issue (unused `ExecutionState` import in `agent-manager.ts`) caught and fixed proactively during the lint step.
24
-
25
- #### What caused friction (agent side)
26
-
27
- - `instruction-violation` (self-identified) — The plan wrote TDD Steps 2 and 3 as separate commits, but the testing skill says "when a TDD step changes an interface that has a single call site, the step must include updating that call site."
28
- The planning phase loaded the testing skill but didn't apply this specific rule when structuring the TDD order.
29
- Impact: added friction but no rework — caught during execution when `pnpm run check` surfaced the expected type error in `index.ts` after Step 2.
30
- - `other` (tool interaction) — One `Edit` tool `oldText` match failure in `agent-manager.ts` because the selected block included a blank line that didn't exist between `subscribeRecordObserver` and `options.onSessionCreated`.
31
- Impact: one extra read + edit cycle (~30 seconds).
32
-
33
- #### What caused friction (user side)
34
-
35
- - Nothing — the session ran without user corrections or redirections.
@@ -1,29 +0,0 @@
1
- ---
2
- issue: 113
3
- issue_title: "refactor(pi-subagents): disambiguate SpawnOptions (public vs internal)"
4
- ---
5
-
6
- # Retro: #113 — disambiguate SpawnOptions (public vs internal)
7
-
8
- ## Final Retrospective (2026-05-21T21:10:00-04:00)
9
-
10
- ### Session summary
11
-
12
- Renamed the internal `SpawnOptions` in `agent-manager.ts` to `AgentSpawnConfig` to disambiguate it from the public `SpawnOptions` in `service.ts`.
13
- Pure mechanical rename across 4 files with zero test-count delta (652/652).
14
- Released as `pi-subagents-v6.8.3`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Completely frictionless execution — single-step plan executed exactly as written with no corrections, rework, or failed edits.
21
- - The session benefited from context already loaded during the preceding #112 cycle (same package, same skills, same source files), which made planning and execution faster.
22
-
23
- #### What caused friction (agent side)
24
-
25
- - Nothing — the rename was purely mechanical and the plan matched reality exactly.
26
-
27
- #### What caused friction (user side)
28
-
29
- - Nothing — no user intervention needed.
@@ -1,38 +0,0 @@
1
- ---
2
- issue: 114
3
- issue_title: "refactor(pi-subagents): narrow AgentToolDeps and AgentMenuDeps"
4
- ---
5
-
6
- # Retro: #114 — narrow AgentToolDeps and AgentMenuDeps
7
-
8
- ## Final Retrospective (2026-05-21T21:43:48-04:00)
9
-
10
- ### Session summary
11
-
12
- Narrowed `AgentToolDeps` from 9 to 6 fields and `AgentMenuDeps` from 8 to 7 fields.
13
- Moved `subagents:created` event emission from the Agent tool to a new `AgentManagerObserver.onAgentCreated` method.
14
- Extracted `buildTypeListText` to `tools/helpers.ts`, derived description text inside `createAgentTool`, removed dead `emitEvent` from `AgentMenuDeps`, and narrowed `agentActivity` to typed `AgentActivityAccess`/`AgentActivityReader` interfaces.
15
- Test count increased from 638 to 660.
16
- Released as `pi-subagents-v6.9.0`.
17
-
18
- ### Observations
19
-
20
- #### What went well
21
-
22
- - The `ask_user` gate during planning was well-targeted.
23
- The first question (where to move `emitEvent`) had a clear answer.
24
- The second (description-text derivation) genuinely needed user input, and the user requested more context via the "I could use more context" response — the follow-up `preview`-type question with fenced code blocks handled this cleanly.
25
- - The 6-step TDD plan mapped to implementation with only one deviation (see below), caught exactly where the workflow is designed to catch it (the `pnpm run check` step).
26
- - All 6 prerequisites (#108, #109, #110, #112, #113, #118) were verified as closed before planning.
27
- The observer issue (#112) was correctly identified from a `gh issue list` grep despite not being explicitly numbered in the issue body (the issue said "the observer issue").
28
-
29
- #### What caused friction (agent side)
30
-
31
- - `missing-context` (self-identified) — Step 6 narrowed `agentActivity` from `Map<string, AgentActivityTracker>` to `AgentActivityAccess` (which exposes only `get`/`set`/`delete`), but the test in `agent-tool.test.ts` used `.has()` on the map.
32
- The `pnpm run check` typecheck caught `Property 'has' does not exist on type 'AgentActivityAccess'`.
33
- Fixed by replacing `.has(id)` with `.get(id) !== undefined` in the same commit.
34
- Impact: one extra read + edit cycle (~30 seconds), no rework.
35
-
36
- #### What caused friction (user side)
37
-
38
- - Nothing — no user corrections or redirections needed during the session.
@@ -1,51 +0,0 @@
1
- ---
2
- issue: 115
3
- issue_title: "refactor(pi-subagents): decompose agent-tool.ts into foreground/background modules"
4
- ---
5
-
6
- # Retro: #115 — decompose agent-tool.ts into foreground/background modules
7
-
8
- ## Final Retrospective (2026-05-21T22:30:00-04:00)
9
-
10
- ### Session summary
11
-
12
- Decomposed the 579-line `tools/agent-tool.ts` into focused modules: `foreground-runner.ts` (spinner, streaming, cleanup) and `background-spawner.ts` (activity setup, notification wiring), with `agent-tool.ts` remaining as the orchestrator (411 lines).
13
- Before extracting, fixed two upstream API gaps: widened `onSessionCreated` callback to `(session, record)` to eliminate a `listAgents()` reverse-search, and added `toolCallId` to `AgentSpawnConfig` so the manager wires `NotificationState` at spawn time.
14
- Test count increased from 641 to 690.
15
- Released as `pi-subagents-v6.9.1`.
16
-
17
- ### Observations
18
-
19
- #### What went well
20
-
21
- - The revised plan (after user feedback) was structurally clean — fixing API gaps first made the extraction trivial; each extracted module received only what it needed without workarounds.
22
- - TDD execution was smooth: 6 steps, all green after each commit, only minor deviations (type annotation issue, `index.ts` call-site fix).
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `wrong-abstraction` (user-caught) — The initial plan was a mechanical code-move that defined 4 new interfaces (`ForegroundRunDeps`, `BackgroundSpawnDeps`, `ForegroundRunParams`, `BackgroundSpawnParams`) to paper over two upstream API gaps: a `listAgents()` reverse-search in the foreground `onSessionCreated` callback, and a post-spawn `record.notification` mutation in the background path.
27
- The user asked *"What dependencies are still missing for these split tools, that they want, rather than some low level state or collaborators that they have?"*
28
- — redirecting me to fix the API surface before extracting.
29
- Impact: entire plan rewritten (~15 minutes), but the revised plan was significantly cleaner and the implementation went smoothly.
30
-
31
- - `missing-context` (self-identified) — During step 5 (foreground extraction), two tests in `foreground-runner.test.ts` failed because mock sessions were `{}` objects lacking a `subscribe` method required by `subscribeUIObserver`.
32
- The function's dependency on `SubscribableSession` (requiring `.subscribe()`) wasn't accounted for in the test mock.
33
- Impact: one test fix cycle (~2 minutes), no rework.
34
-
35
- - `missing-context` (self-identified) — Annotating `runForeground` with an explicit `Promise<AgentToolResult<any>>` return type widened the content array type from `{ type: "text", text: string }[]` to `(TextContent | ImageContent)[]`, breaking existing `content[0].text` patterns in tests.
36
- Fixed by removing the explicit annotation and letting TypeScript infer the narrow type.
37
- Impact: three edit cycles to diagnose and fix (~5 minutes).
38
-
39
- - `missing-context` (self-identified) — Step 1 removed `listAgents` from `AgentToolManager` but didn't update the construction site in `index.ts`.
40
- `pnpm run check` caught it in step 4.
41
- Impact: one-line fix in the same commit, no rework.
42
-
43
- #### What caused friction (user side)
44
-
45
- - The initial plan's size and mechanical nature required a user redirect.
46
- The `/plan-issue` prompt's Design Overview section asks to sketch consumer call sites for *new collaborators*, but the same Tell-Don't-Ask check should apply to *extracted* modules' interactions with their upstream dependencies.
47
- A prompt tweak could help the agent catch this pattern earlier.
48
-
49
- ### Changes made
50
-
51
- 1. `.pi/prompts/plan-issue.md` — added extraction-specific Tell-Don't-Ask verification step to the Design Overview section: sketch the extracted module's upstream interactions before planning the extraction, fix API gaps first.
@@ -1,42 +0,0 @@
1
- ---
2
- issue: 116
3
- issue_title: "refactor(pi-subagents): type housekeeping and small structural cleanups"
4
- ---
5
-
6
- # Retro: #116 — type housekeeping and small structural cleanups
7
-
8
- ## Final Retrospective (2026-05-21T23:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and executed 6 refactoring steps for issue #116: relocated 3 misplaced types from `types.ts` to their natural home modules, converted `createNotificationSystem` closure to a `NotificationManager` class, switched `ConversationViewer` to an options-bag constructor, and defined `AgentIdentity`/`AgentPromptConfig` narrow subset interfaces.
13
- All 690 tests stayed green throughout; no behavioral changes.
14
- Released as `pi-subagents-v6.9.2`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The Python script approach for bulk-converting 16 `ConversationViewer` positional constructor calls to options-bag syntax was efficient and correct on the first attempt — all 17 tests passed immediately after the conversion.
21
- - Proactive `grep -rn 'new ConversationViewer'` before step 5 caught the `agent-menu.ts` call site that the plan's Module-Level Changes section had omitted, avoiding a broken commit.
22
- - The architecture doc update was clean — 5 targeted edits to mark E2 done, update smells table, and fix metrics.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `missing-context` — In all three type-relocation steps (1–3), I updated source-file imports but did not pre-flight grep for test-file imports of the relocated symbol.
27
- Each time, `pnpm run check` caught the stale test import, requiring an extra edit-check round trip.
28
- This happened with `test/renderer.test.ts` (step 1), `test/agent-runner.test.ts` + `test/agent-runner-extension-tools.test.ts` (step 2), and `test/prompts.test.ts` (step 3).
29
- Impact: 3 unnecessary edit-check cycles; no broken commits since the type checker caught every case before `git commit`.
30
-
31
- - `missing-context` — In step 4, the first `Edit` call on `src/index.ts` failed because the autoformatter had merged the `NotificationDetails` type import (added in step 1) into the existing notification import line, changing the text I expected.
32
- Had to re-read the file to find the current import text.
33
- Impact: one wasted edit call plus a file read; added ~10 seconds of friction.
34
-
35
- #### What caused friction (user side)
36
-
37
- - No friction observed — the user's prompts were clear and the `/tdd-plan` and `/ship-issue` templates provided all needed structure.
38
-
39
- ### Takeaway
40
-
41
- When relocating a type or symbol, always run `grep -rn 'SymbolName' src/ test/` before editing to identify *all* importers upfront — both source and test files.
42
- This avoids the repeated pattern of "edit source → type-check fails on test → fix test → type-check again."
@@ -1,40 +0,0 @@
1
- ---
2
- issue: 118
3
- issue_title: "refactor(pi-subagents): SettingsManager apply methods — eliminate cross-collaborator orchestration"
4
- ---
5
-
6
- # Retro: #118 — SettingsManager apply methods
7
-
8
- ## Final Retrospective (2026-05-21T21:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented 3 `apply*` methods on `SettingsManager` (`applyMaxConcurrent`, `applyDefaultMaxTurns`, `applyGraceTurns`) across 5 TDD cycles plus doc updates, released as `pi-subagents-v6.6.0`.
13
- Each method owns the full consequence chain (normalize → set → callback → persist → emit → return toast), eliminating the LoD/Tell-Don't-Ask violation in `showSettings` that was identified during the #109 retro.
14
- `notifyConcurrencyChanged` was removed from `AgentMenuManager`; the menu no longer coordinates between settings and the agent manager.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - **Retro-driven improvement validated.**
21
- Issue #118 was filed during the #109 retro as a LoD/Tell-Don't-Ask follow-up, and the plan-issue prompt's consumer call-site sketch heuristic (added in #109's retro) was already in the plan template.
22
- The plan for #118 included concrete before/after call-site sketches that made the design unambiguous — no `ask-user` decision needed.
23
- - **Interface-then-wiring TDD order worked cleanly.**
24
- The #109 retro noted that interface changes propagate to `index.ts` immediately, forcing unplanned bridge edits.
25
- This time the plan accounted for it: Cycle 4 committed only menu files (leaving a known `index.ts` type error), and Cycle 5 fixed the wiring in a separate commit.
26
- The intermediate type error was contained and expected.
27
- - **`defaultMaxTurns` branch consolidation.**
28
- During Cycle 4, the separate `n === 0` and `n >= 1` branches in `showSettings` were consolidated to a single `n >= 0` check, since `applyDefaultMaxTurns` handles the 0→unlimited mapping internally.
29
- This was a minor but correct simplification that emerged naturally from the Tell-Don't-Ask refactor.
30
-
31
- #### What caused friction (agent side)
32
-
33
- - No material friction.
34
- All 5 TDD cycles completed without rework, failed edits, or unexpected test failures.
35
- The plan was tight and the issue's "Proposed change" section was unambiguous.
36
-
37
- #### What caused friction (user side)
38
-
39
- - No material friction observed.
40
- The session ran end-to-end (plan → implement → ship → release) without user intervention.