@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: 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.
@@ -1,49 +0,0 @@
1
- ---
2
- issue: 123
3
- issue_title: "refactor(pi-subagents): remove vi.fn() cast smell from test helpers"
4
- ---
5
-
6
- # Retro: #123 — remove vi.fn() cast smell from test helpers
7
-
8
- ## Final Retrospective (2026-05-22T00:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented removal of all 9 `as ReturnType<typeof vi.fn>` casts and 5 `vi.mocked()` calls across 3 test files, replacing them with named typed mock variables.
13
- Released as `pi-subagents-v6.8.1`.
14
- Pure test hygiene — no production code changes, no behavioral changes, 652 tests unchanged.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - **Three-file scope executed cleanly once the plan was right.**
21
- Each file was an independent commit with no cross-file dependencies.
22
- The named-variable pattern (`const mockGetRecord = vi.fn<AgentManagerLike["getRecord"]>()`) worked identically across all three test files despite different mock construction styles (factory function vs `beforeEach` assignment).
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `scope-drift` — The initial plan scoped the fix to `service-adapter.test.ts` only, listing `lifecycle.test.ts` and `tool-start.test.ts` as explicit Non-Goals — despite the planning-phase grep showing all 9 cast sites across 3 files.
27
- The user redirected with "let's eliminate this pattern of behavior."
28
- Updated the GitHub issue body, rewrote the plan, and amended the commit.
29
- Impact: plan rewrite (~2 minutes), no implementation rework.
30
- User-caught.
31
- - `missing-context` — Imported `MockInstance` from `vitest` during step 1 (`service-adapter.test.ts`) but actually used `ReturnType<typeof vi.fn<...>>` — matching the pattern used in the other two files.
32
- The unused import was caught by `pnpm run lint` at the post-implementation check, not proactively.
33
- Impact: one extra edit + amend cycle.
34
- Self-identified (via lint).
35
- - `other` — Ran `git commit --amend` to fix the unused import but HEAD was step 3's commit (`tool-start`), not step 1's (`service-adapter`).
36
- The amend landed the `service-adapter.test.ts` change into the wrong commit with the wrong message.
37
- Required `git reset --soft` back to the plan commit and recommitting all 3 files.
38
- Impact: ~1 minute of git surgery, clean result.
39
- Self-identified.
40
-
41
- #### What caused friction (user side)
42
-
43
- - The issue body scoped the fix to `service-adapter.test.ts` only, which the agent followed literally.
44
- The broader intent ("eliminate this pattern") was implicit.
45
- Flagging the desired scope as "all files with this pattern" in the issue body would have avoided the plan rewrite.
46
-
47
- ### Changes made
48
-
49
- 1. Wrote retro file at `packages/pi-subagents/docs/retro/0123-remove-vi-fn-cast-smell.md`.
@@ -1,46 +0,0 @@
1
- ---
2
- issue: 131
3
- issue_title: Consolidate shared test fixtures
4
- ---
5
-
6
- # Retro: #131 — Consolidate shared test fixtures
7
-
8
- ## Final Retrospective (2026-05-22T11:30:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned and implemented the consolidation of six duplicated test factories into two shared helpers (`createMockSession` in `test/helpers/mock-session.ts`, `createToolDeps` in `test/helpers/make-deps.ts`).
13
- All 715 tests pass, released as `pi-subagents-v6.9.4`.
14
- The implementation was a pure test refactor with no production code changes.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The lift-and-shift approach worked cleanly: create factory → migrate one consumer at a time → verify green after each step.
21
- Each migration commit was small and isolated, making failures easy to diagnose.
22
- - Structural typing as a strategy proved out — `createToolDeps()` returns `AgentToolDeps` (the superset), and `spawnBackground(deps, ...)` and `runForeground(deps, ...)` accept their narrow `BackgroundDeps`/`ForegroundDeps` interfaces without any casting.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `missing-context` — Plan used `registry.resolve("general-purpose", "/dir")` in the `make-deps.test.ts` test, but `AgentTypeRegistry` has no `resolve` method — the correct method is `resolveAgentConfig()`.
27
- Impact: one test failure during step 5 red→green, fixed immediately with no rework.
28
-
29
- - `missing-context` — Default values differed between the old narrow factories and the new shared factory: `"bg-1"` vs `"agent-1"` for spawn IDs (`background-spawner.test.ts`), `"Task done."` vs `"All done."` for result text (`foreground-runner.test.ts`).
30
- Impact: two test failures in step 7, one in step 8, each requiring assertion updates before the migration step could pass.
31
-
32
- - `missing-context` — `MockSession` interface used `ReturnType<typeof vi.fn>` which expands to `Mock<Procedure | Constructable>` in Vitest v4 — a union type TypeScript cannot call.
33
- Impact: `pnpm run check` failed after all TDD steps were done, requiring a separate `style:` commit to switch to explicitly parameterized `Mock<() => void>` etc.
34
-
35
- - `missing-context` — Removed the `AgentToolDeps` import from `agent-tool.test.ts` without checking that the `execute()` helper still referenced it.
36
- Impact: caught in the same `pnpm run check` pass, fixed in the same `style:` commit.
37
-
38
- #### What caused friction (user side)
39
-
40
- - No user-side friction observed.
41
- The plan was unambiguous, and the session ran autonomously through all 8 TDD steps plus post-checks without intervention.
42
-
43
- ### Changes made
44
-
45
- 1. `.pi/skills/testing/SKILL.md` — added TDD planning rule for diffing default values when consolidating duplicate test factories.
46
- 2. `.pi/skills/testing/SKILL.md` — added Vitest mock pattern rule for typing mock fields with `Mock<specific-signature>` instead of `ReturnType<typeof vi.fn>`.
@@ -1,33 +0,0 @@
1
- ---
2
- issue: 132
3
- issue_title: "Inject IO collaborators into `assembleSessionConfig`"
4
- ---
5
-
6
- # Retro: #132 — Inject IO collaborators into `assembleSessionConfig`
7
-
8
- ## Final Retrospective (2026-05-22T12:25:00Z)
9
-
10
- ### Session summary
11
-
12
- Defined an `AssemblerIO` interface bundling four IO/prompt collaborators, injected it into `assembleSessionConfig`, and updated `agent-runner.ts` to pass real implementations.
13
- Eliminated all 4 `vi.mock()` calls in `session-config.test.ts`, flattened the `vi.hoisted()` block into plain `vi.fn()` declarations, and shifted assertions from mock-call verification to output-property checks.
14
- Released as `pi-subagents-v6.10.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Perl two-pass replacement (multi-line then single-line) handled 40+ `assembleSessionConfig` call-site updates in one command with zero manual errors.
21
- - Flattening `vi.hoisted()` into regular `vi.fn()` declarations in step 3 was a clean simplification — hoisting was only needed when the mocks were referenced inside `vi.mock()` factories.
22
- - Real `getMemoryToolNames` / `getReadOnlyMemoryToolNames` worked as drop-in replacements with no test rework needed — the pure functions' behavior matched what the mocks were configured to return for all existing test scenarios.
23
-
24
- #### What caused friction (agent side)
25
-
26
- - `missing-context` — `mockBuildAgentPrompt` was declared as `vi.fn(() => "assembled system prompt")` which inferred `Mock<() => string>`.
27
- When step 4 used `mockImplementationOnce` with a parameterized function, TypeScript rejected it.
28
- The testing skill already documents `Mock<specific-signature>` for this exact case.
29
- Impact: one type-check failure, fixed by adding `Mock<AssemblerIO["buildAgentPrompt"]>` annotation; added friction but no rework.
30
-
31
- #### What caused friction (user side)
32
-
33
- - Nothing notable — standard prompt-template workflow with no corrections needed.
@@ -1,45 +0,0 @@
1
- ---
2
- issue: 133
3
- issue_title: "Inject SDK boundary into `agent-runner`"
4
- ---
5
-
6
- # Retro: #133 — Inject SDK boundary into agent-runner
7
-
8
- ## Final Retrospective (2026-05-22T13:15:00Z)
9
-
10
- ### Session summary
11
-
12
- Injected all SDK and IO dependencies into `runAgent()` via a `RunnerIO` interface and `createAgentRunner(io)` factory.
13
- Eliminated all 14 `vi.mock()` calls across `agent-runner.test.ts` (7) and `agent-runner-extension-tools.test.ts` (7).
14
- Released as `pi-subagents-v6.11.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - The `createAgentRunner(io)` factory pattern was a clean design choice that kept the `AgentRunner` interface and `AgentManager` completely unchanged — zero downstream impact.
21
- - Folding plan steps 1 and 2 into a single commit was the right call given `tsconfig.json` includes `test/` — recognized the constraint before attempting a broken intermediate commit.
22
-
23
- #### What caused friction (agent side)
24
-
25
- 1. `wrong-abstraction` — Annotated `createRunnerIO(): RunnerIO` in the test helper, which erased the `Mock<...>` type information from `vi.fn()` stubs.
26
- TypeScript then rejected `.mockResolvedValue()` on `io.createSession` across 18 call sites.
27
- Required removing the annotation plus a follow-up edit to remove the now-unused `type RunnerIO` import flagged by Biome.
28
- Impact: two extra edit rounds and a type-check cycle before the fix landed.
29
-
30
- 2. `missing-context` — Added `SettingsManager` to the SDK import block in `index.ts` without checking that the name was already imported from `./settings.js`.
31
- Biome caught the redeclaration and the `noRedeclare` lint error required an alias fix (`SettingsManager as SdkSettingsManager`).
32
- Impact: one extra edit round triggered by the autoformat failure.
33
-
34
- 3. `premature-convergence` — Spent excessive reasoning time deliberating commit-boundary strategy (whether to combine steps 1+2, how to handle broken intermediate states, whether step 4 would have remaining work).
35
- The answer was straightforward once the `tsconfig` `include` was checked, but the check came late in the deliberation.
36
- Impact: added friction but no rework — the final decision was correct.
37
-
38
- #### What caused friction (user side)
39
-
40
- - None identified.
41
- The plan and issue were well-specified, and the user's only intervention was "Please, continue" after a message boundary, which was appropriate.
42
-
43
- ### Changes made
44
-
45
- 1. `.pi/skills/testing/SKILL.md` — added rule: do not annotate test factory return types with production interface types (erases `Mock<...>` methods).