@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,72 +0,0 @@
1
- ---
2
- issue: 218
3
- issue_title: "Push SDK boundary in settings.ts (Phase 13, Step 5)"
4
- ---
5
-
6
- # Retro: #218 — Push SDK boundary in settings.ts
7
-
8
- ## Stage: Planning (2026-05-26T17:01:55Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 3-step TDD plan to inject `agentDir: string` into `SettingsManager` and `loadSettings`, removing the only Pi SDK import from `settings.ts`.
13
- The change is straightforward — a single parameter addition threading through constructor, free function, and boundary wiring.
14
-
15
- ### Observations
16
-
17
- - The change is entirely mechanical: no design ambiguity, no new abstractions, no breaking public API.
18
- - The main implementation effort is in test updates (~35 `new SettingsManager(...)` call sites plus ~15 `loadSettings(...)` calls), all requiring an `agentDir` argument.
19
- - All test `describe` blocks that manipulate `PI_CODING_AGENT_DIR` env var can drop that scaffolding entirely, simplifying setup/teardown.
20
- - `saveSettings` has no SDK dependency and needs no signature change — only `loadSettings` calls `globalPath()`.
21
-
22
- ## Stage: Implementation — TDD (2026-05-26T17:13:26Z)
23
-
24
- ### Session summary
25
-
26
- Completed all 3 plan steps across 2 commits plus 1 doc commit.
27
- All 970 tests pass; `settings.ts` now has 0 Pi SDK imports and all `PI_CODING_AGENT_DIR` env var manipulation is gone from `settings.test.ts`.
28
-
29
- ### Observations
30
-
31
- - **Steps 1+2 combined:** Changing `loadSettings(cwd)` to `loadSettings(agentDir, cwd)` forced updating `SettingsManager.load()` in the same commit — they were inseparable (esbuild skips type checks, so the old call compiled but produced wrong runtime behavior).
32
- The two production changes landed in one commit with a note in the body.
33
- - **Test simplification was significant:** Removed `originalAgentDirEnv` save/restore scaffolding from 5 `describe` blocks; the test code shrank by 32 lines net.
34
- - **`/nonexistent` sentinel:** Tests that construct `SettingsManager` but never call `load()` pass `agentDir: "/nonexistent"` — a clear signal the field is unused in that scope.
35
- - Architecture doc Step 5 heading marked `✓` and folded into the last `feat:` commit by `pi-autoformat`.
36
-
37
- ## Stage: Final Retrospective (2026-05-26T17:22:11Z)
38
-
39
- ### Session summary
40
-
41
- Issue #218 went from plan to shipped release (`pi-subagents-v7.8.0`) in a single continuous session.
42
- Planning, TDD (2 feat commits + 1 doc commit), shipping, CI verification, issue close, and release-please merge all completed without user intervention beyond stage transitions.
43
-
44
- ### Observations
45
-
46
- #### What went well
47
-
48
- - **Clean mechanical execution:** The entire change was 2 production files (`settings.ts`, `index.ts`) and 1 test file, with zero unexpected test breakage and zero rework commits.
49
- - **Test simplification payoff:** Removing `PI_CODING_AGENT_DIR` env var scaffolding from 5 `describe` blocks shrank the test file by 32 lines net — a tangible improvement in test readability.
50
- - **Ship stage model efficiency:** The `/ship-issue` stage ran on `deepseek-v4-flash`, which was appropriate for the purely mechanical push/CI/close/merge workflow.
51
-
52
- #### What caused friction (agent side)
53
-
54
- 1. `wrong-abstraction` — The plan split steps 1 and 2 into separate commits, but changing `loadSettings(cwd)` to `loadSettings(agentDir, cwd)` immediately broke `SettingsManager.load()` which calls it.
55
- The agent recognized this during the red phase and combined them into one commit.
56
- The existing testing skill rule ("When a TDD plan lists separate steps that share a type definition… fold them into one step") already covers this — the plan just didn't apply it.
57
- Impact: added friction but no rework; recognized on first test run.
58
- 2. `missing-context` — Attempted to add `| ✓ #218 |` as an extra column to one row of the architecture doc's findings table, creating a column-count mismatch.
59
- The autoformatter reverted the broken table.
60
- The agent then spent ~5 tool calls (`git show --stat`, `git status`, `grep` ×2, `read`) investigating what happened before switching to the Step 5 heading approach.
61
- Impact: ~2 minutes of investigation; no rework beyond the heading edit.
62
-
63
- #### What caused friction (user side)
64
-
65
- - The user asked "Are we ready for shipping?"
66
- which surfaced that the TDD retro stage notes were still uncommitted.
67
- This was a useful checkpoint — the ship stage committed them before pushing.
68
- Opportunity: the `/tdd-plan` prompt could commit retro notes as part of its final step, but the current flow (write notes, then commit in ship) is lightweight enough that enforcing it would add complexity for marginal gain.
69
-
70
- ### Changes made
71
-
72
- 1. Retro file updated at `packages/pi-subagents/docs/retro/0218-push-sdk-boundary-in-settings.md` — no other files changed.
@@ -1,64 +0,0 @@
1
- ---
2
- issue: 219
3
- issue_title: "Reduce test duplication — top 3 clone families (Phase 13, Step 6)"
4
- ---
5
-
6
- # Retro: #219 — Reduce test duplication — top 3 clone families
7
-
8
- ## Stage: Planning (2026-05-26T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Analyzed duplication patterns in the three target test files (`agent-manager.test.ts`, `conversation-viewer.test.ts`, `agent-config-editor.test.ts`).
13
- Produced a 5-step TDD plan with shared `manager-stubs.ts` helper for runner/worktree factories, plus inline factories for the two UI test files.
14
-
15
- ### Observations
16
-
17
- - The agent-manager test has the most diverse clone families (runner stubs, worktree stubs, run-result shapes) — these benefit from a shared helper file since the patterns are reused across 15+ describe blocks.
18
- - The conversation-viewer and config-editor duplication is more localized — inline factories within each test file are the right granularity to avoid over-extraction.
19
- - Gated runners (using `Promise.withResolvers`) were deliberately kept inline since they encode test-specific flow control that a factory would obscure.
20
- - Both dependencies (#214, #216) are closed, so the production code is stable and the tests won't shift under us during implementation.
21
-
22
- ## Stage: Implementation — TDD (2026-05-26T17:42:41Z)
23
-
24
- ### Session summary
25
-
26
- Completed all 4 TDD cycles: created `test/helpers/manager-stubs.ts` + `manager-stubs.test.ts` (13 smoke tests), migrated `agent-manager.test.ts`, `conversation-viewer.test.ts`, and `agent-config-editor.test.ts`.
27
- Test count delta: 970 → 983 (+13 from smoke tests).
28
- All 4 commits landed cleanly; full suite green at every step.
29
-
30
- ### Observations
31
-
32
- - Target file line savings: `agent-manager.test.ts` −63, `conversation-viewer.test.ts` −58, `agent-config-editor.test.ts` −16; offset by +211 for the new helper files.
33
- Net LOC is positive, but the _clone_ lines fallow detects are eliminated — the metric the issue targets.
34
- - The `createSessionRunner` + `createRunResult` chain required careful identity-check verification: `createRunResult(sess)` calls `toAgentSession(sess)` which casts without creating a new object, so `toBe(session)` assertions in the execution-state tests still pass. ✓
35
- - ESLint auto-fixed two cosmetic issues on commit (`activity = undefined` → `activity` destructuring, `session as unknown` cast removal) — caught by pre-commit hooks, not a problem in practice.
36
- - The `assertRenderFitsWidths` helper in `conversation-viewer.test.ts` reduced the 10 render-safety tests from ~8 lines each to 1–4 lines each; the `setupDetail` helper in `agent-config-editor.test.ts` eliminated 3 repeated setup lines per test across 18 `showAgentDetail` tests.
37
-
38
- ## Stage: Final Retrospective (2026-05-26T17:50:31Z)
39
-
40
- ### Session summary
41
-
42
- All three stages (planning, TDD, ship) completed in a single session with zero user corrections.
43
- Four TDD commits landed cleanly, CI passed on first push, issue #219 closed, and `pi-subagents-v7.8.1` released.
44
-
45
- ### Observations
46
-
47
- #### What went well
48
-
49
- - Clean incremental verification: `pnpm vitest run <file>` ran after every code change, full suite at the end.
50
- No regressions at any step.
51
- - The plan's decision to keep gated runners inline proved correct — tests with `Promise.withResolvers` flow control stayed readable without abstraction.
52
- - The `write` tool was the right choice for `conversation-viewer.test.ts` and `agent-config-editor.test.ts` (pervasive changes), while `edit` with 16 targeted replacements worked cleanly for `agent-manager.test.ts` (scattered but formulaic substitutions).
53
- - Ship stage used `deepseek-v4-flash` for purely mechanical CI/release steps — appropriate model-task alignment.
54
-
55
- #### What caused friction (agent side)
56
-
57
- - `other` — ESLint pre-commit hooks auto-fixed two cosmetic patterns (`activity = undefined` → bare destructuring; `session as unknown` cast removal), requiring re-stage + re-commit.
58
- Impact: ~10 seconds per occurrence, no rework.
59
- This is routine and inherent to the workflow.
60
-
61
- #### What caused friction (user side)
62
-
63
- - None observed.
64
- The user's three-stage prompt chain (`/plan-issue` → `/tdd-plan` → `/ship-issue`) provided sufficient context at each stage with no manual intervention needed.
@@ -1,80 +0,0 @@
1
- ---
2
- issue: 227
3
- issue_title: "Evolve AgentRecord into Agent with behavior (Phase 15, Step 1)"
4
- ---
5
-
6
- # Retro: #227 — Evolve AgentRecord into Agent with behavior
7
-
8
- ## Stage: Planning (2026-05-27T12:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced an 8-step TDD plan to move per-agent behavior (`abort`, `queueSteer`/`flushPendingSteers`, `setupWorktree`) from `AgentManager` into `AgentRecord`, then rename `AgentRecord` → `Agent` across the codebase.
13
- The plan follows a "add behavior first, rename last" strategy to keep behavior diffs small and the rename commit purely mechanical.
14
-
15
- ### Observations
16
-
17
- - `AgentRecord` is internal-only (public API is `SubagentRecord` in `service.ts`), so the rename is non-breaking.
18
- - The `queueSteer` method can be removed from `AgentManagerLike` and `SteerToolManager` interfaces entirely — both callers (`steer-tool`, `service-adapter`) already hold the agent reference from `getRecord()`, so they can call `agent.queueSteer()` directly.
19
- - Queue removal in `abort()` must stay on `AgentManager` until #230 extracts `ConcurrencyQueue`.
20
- - `RunHandle` ownership explicitly deferred to #228 — the plan does not touch `RunHandle` at all.
21
- - The rename step (step 7) touches ~30 files but is purely mechanical; all behavior changes land in steps 1–6.
22
-
23
- ## Stage: Implementation — TDD (2026-05-27T13:00:00Z)
24
-
25
- ### Session summary
26
-
27
- Completed all 8 TDD steps from the plan.
28
- Added 9 new tests (steer buffering, `abort()`, `setupWorktree()`) and migrated 977 existing tests to the renamed `Agent` class.
29
- Test count went from 977 to 986 across 62 test files.
30
-
31
- ### Observations
32
-
33
- - Fallow reported `AgentInit` and `AgentStatus` as unused type exports from `types.ts`; suppressed with `// fallow-ignore-next-line unused-type` (correct singular form — tool's error message hints at this).
34
- - `ESLint` auto-removed an `as any` cast in the `setupWorktree` test (the mock `WorktreeManager` already satisfied the interface structurally); staged and re-committed cleanly.
35
- - Biome auto-formatted several test files during the rename commit; re-staged and re-committed.
36
- - Pre-completion reviewer returned **WARN** for 4 stale diagram/table references in `architecture.md` and the `package-pi-subagents` skill table; all fixed before the final commit.
37
- - No deviations from the plan's behavior design; the `queueSteer` removal from manager interfaces worked exactly as anticipated in the retro notes.
38
-
39
- ## Stage: Final Retrospective (2026-05-27T17:22:00Z)
40
-
41
- ### Session summary
42
-
43
- Completed all stages in a single session: planning, 8 TDD steps, pre-completion review, shipping, and release as `pi-subagents-v10.1.0`.
44
- Three behaviors (`abort`, steer buffering, worktree setup) moved from `AgentManager` to `Agent`, followed by a codebase-wide rename (33 files).
45
-
46
- ### Observations
47
-
48
- #### What went well
49
-
50
- - The "add behavior first, rename last" strategy kept behavior-adding commits small (1–2 files each) and the rename commit purely mechanical.
51
- - Planning identified that `queueSteer` could be removed from `AgentManagerLike` and `SteerToolManager` entirely — this simplified the delegation step and eliminated an unnecessary indirection layer.
52
- - Pre-completion reviewer caught 4 stale Mermaid diagram references and a skill table entry that the plan's step 8 did not anticipate; all fixed before shipping.
53
-
54
- #### What caused friction (agent side)
55
-
56
- 1. `scope-drift` — Added `AgentInit` and `AgentStatus` to the `types.ts` re-export barrel during the rename step without verifying any file imports them from that path.
57
- Impact: fallow flagged dead code, triggering a 4-call suppression trial (`unused-export` → `unused-types` → `unused-type`), then the user identified the real fix (remove the speculative re-exports entirely), requiring a follow-up `fix:` commit after docs were already done.
58
- 2. `missing-context` — During the mechanical rename (step 7), `sed` commands matched `#test/helpers/make-record` but missed the relative import `"./helpers/make-record"` in `conversation-viewer.test.ts`.
59
- Impact: `pnpm run check` caught it in 1 tool call; minimal rework.
60
- 3. `missing-context` — The fallow skill documents `unused-export` as a suppression kind but not `unused-type`.
61
- Impact: 3 wrong guesses before the correct suppression syntax.
62
- Self-identified after fallow's error message suggested the correct kind name.
63
-
64
- #### What caused friction (user side)
65
-
66
- - The user's question about whether the fallow suppressions could be removed in a future step was a valuable prompt — it surfaced that the re-exports were speculative and could be removed immediately.
67
- Earlier intervention (e.g., during the TDD stage when the suppressions were added) would have avoided the `fix:` commit.
68
-
69
- ### Diagnostic details
70
-
71
- - **Model-performance correlation** — Pre-completion reviewer ran as `pre-completion-reviewer` subagent (default model); appropriate for judgment-heavy work (doc staleness, code design review).
72
- No model mismatches.
73
- - **Feedback-loop gap analysis** — `pnpm run check` was run after every delegation step (steps 2, 4, 6, 7) and after every behavior-adding step (steps 1, 3, 5).
74
- Verification was incremental throughout, not deferred to the end.
75
- The `conversation-viewer.test.ts` import miss in step 7 was caught immediately by the type checker.
76
-
77
- ### Changes made
78
-
79
- 1. `.pi/skills/fallow/SKILL.md` — Added `unused-type` suppression example alongside existing `unused-export` example.
80
- 2. `AGENTS.md` — Added "no speculative re-exports" rule to Code Style section.
@@ -1,80 +0,0 @@
1
- ---
2
- issue: 228
3
- issue_title: "Convert startAgent to async/await, move run lifecycle to Agent (Phase 15, Step 2)"
4
- ---
5
-
6
- # Retro: #228 — Convert startAgent to async/await, move run lifecycle to Agent
7
-
8
- ## Stage: Planning (2026-05-27T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned the async `startAgent` conversion and decided to dissolve `RunHandle` into Agent methods rather than moving it as a separate class.
13
- Identified three preparatory steps (narrow promise type, add Agent methods, hoist worktree setup) that make the final async conversion a minimal diff.
14
-
15
- ### Observations
16
-
17
- - The original issue proposed `Agent.createRunHandle()` as a factory, keeping RunHandle as a separate class.
18
- Analysis showed 5 of 6 RunHandle concerns are Agent state mutations — RunHandle is doing work that belongs on Agent.
19
- The clincher was `resume()` in `agent-manager.ts`: it duplicates RunHandle's pattern manually, and #232 wants to unify them.
20
- Dissolving RunHandle gives both `startAgent` and `resume` the same primitives (`completeRun`, `failRun`, `releaseListeners`).
21
- - The synchronous-throw contract in `spawn()` for worktree failures requires hoisting `record.setupWorktree()` out of `startAgent` before the async conversion.
22
- Without this prep step, async `startAgent` would turn the throw into a rejected promise that `spawn()` doesn't catch.
23
- - `promise: Promise<string>` → `Promise<void>` is safe because the resolved string is dead — every consumer reads `record.result` instead.
24
- Only one test assertion reads the resolved value.
25
- - `completeRun`/`failRun` take `worktrees: WorktreeManager` as a parameter rather than storing it on Agent (ISP — only needed at run end, exactly two callers).
26
-
27
- ## Stage: Implementation — TDD (2026-05-27T20:40:00Z)
28
-
29
- ### Session summary
30
-
31
- Implemented all 6 TDD steps: narrowed `promise` to `Promise<void>`, added 6 run lifecycle methods to Agent (+19 tests), replaced `RunHandle` with Agent methods (-85 LOC), hoisted worktree setup to callers, converted `startAgent` to async/await, and updated architecture docs.
32
- Test count: 986 → 1005.
33
-
34
- ### Observations
35
-
36
- - Step 1 (promise narrowing) required fixing 3 additional test files not listed in the plan: `make-agent.test.ts`, `service-adapter.test.ts`, `get-result-tool.test.ts`.
37
- All were trivial `Promise.resolve("done")` → `Promise.resolve()` changes and a cast removal.
38
- - The lift-and-shift approach worked cleanly — each of the 5 implementation commits was small and independently green.
39
- The most impactful commit was step 3 (replace RunHandle, -96/+6 lines) which was risk-free because step 2 had already introduced the Agent methods.
40
- - Pre-completion reviewer returned WARN for stale `AgentRecord` and `run-handle.ts` references in `architecture.md` class diagram and layout listing.
41
- These were pre-existing staleness from #227's rename that wasn't fully propagated to Mermaid diagrams.
42
- Fixed by amending the docs commit.
43
-
44
- ## Stage: Final Retrospective (2026-05-27T21:46:00Z)
45
-
46
- ### Session summary
47
-
48
- Completed all stages (plan, TDD, ship, retro) in a single session.
49
- Dissolved `RunHandle` into 6 Agent methods, converted `startAgent` to async/await, released as `pi-subagents-v10.2.0`.
50
- Test delta: 986 → 1005 (+19).
51
-
52
- ### Observations
53
-
54
- #### What went well
55
-
56
- - The user's two redirecting questions during planning ("What's the change that makes this easier?"
57
- and "Tell me more about RunHandle — is there something that should replace it?") transformed a mechanical "move the class" plan into a "dissolve the abstraction" plan.
58
- The dissolve approach is architecturally superior and sets up #232 (resume unification) for free.
59
- - The lift-and-shift decomposition (introduce Agent methods alongside `RunHandle`, then swap and delete) produced 5 independently-green commits.
60
- The riskiest commit (step 3: delete `RunHandle`, -96/+6 lines) was trivially safe because step 2 had already proven the replacement methods.
61
-
62
- #### What caused friction (agent side)
63
-
64
- - `premature-convergence` — The agent planned around the issue's proposed `Agent.createRunHandle()` factory without questioning whether `RunHandle` should exist as a separate class.
65
- The user had to ask two redirecting questions to push the analysis deeper.
66
- Impact: plan was rewritten before commit (no wasted implementation), but the user spent two turns guiding analysis the agent should have done proactively.
67
- - `missing-context` — Plan step 1 (narrow `Promise<string>` to `Promise<void>`) listed only `agent-manager.test.ts` for updates but missed 3 additional test files (`make-agent.test.ts`, `service-adapter.test.ts`, `get-result-tool.test.ts`) that construct `Promise<string>` values.
68
- The testing skill says "grep for all test files" for type changes — this was not applied during planning.
69
- Impact: caught by `pnpm run check` in the same step, no rework.
70
-
71
- #### What caused friction (user side)
72
-
73
- - No friction observed.
74
- The user's questioning style (asking "what does it do?
75
- who needs it?"
76
- rather than prescribing the solution) was collaborative and effective.
77
-
78
- ### Changes made
79
-
80
- 1. `.pi/prompts/plan-issue.md` — added relocation-dissolution heuristic: when an issue proposes moving a class, list callers and fields touched to check if it should be dissolved into the owner instead.
@@ -1,89 +0,0 @@
1
- ---
2
- issue: 229
3
- issue_title: "Agent born complete: Agent.run() absorbs startAgent (Phase 15, Step 4)"
4
- ---
5
-
6
- # Retro: #229 — Agent born complete: Agent.run() absorbs startAgent
7
-
8
- ## Stage: Planning (2026-05-27T18:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 9-step TDD plan for absorbing `AgentManager.startAgent()` into `Agent.run()`.
13
- Key design decisions: per-agent `AgentLifecycleObserver` interface passed at construction (chosen over callback fields and EventEmitter), and fully async worktree error surface (chosen over split sync/async).
14
-
15
- ### Observations
16
-
17
- - **Observer pattern chosen over callbacks:** The per-agent `AgentLifecycleObserver` interface replaces three separate mechanisms (`onSessionCreated` callback, `setOnRunFinished`, `onCompact` callback).
18
- All methods are optional, composed by `AgentManager.buildObserver()` per spawn.
19
- - **`ParentSessionInfo`/`CompactionInfo` relocation needed:** `agent.ts` importing from `agent-manager.ts` would create a circular type import (agent-manager already imports `Agent`).
20
- Moving both types to `types.ts` in step 1 avoids the cycle.
21
- - **`AgentInit` grows wide (15+ optional fields):** Making run-config fields optional preserves backward compat for the 55+ `new Agent()` calls in tests.
22
- Noted as a known smell — follow-up issues (#230 ConcurrencyQueue, potential `AgentInit` restructuring) may address this.
23
- - **Async error surface changes tool behavior:** `background-spawner.ts`'s try/catch around `manager.spawn()` becomes unreachable for worktree errors.
24
- Keeping it for robustness; the error surfaces on `record.error` instead.
25
- - **Lift-and-shift TDD order:** Steps 3–5 incrementally change `AgentInit`, `setupWorktree`, and `completeRun`/`failRun` before step 6 adds `Agent.run()`.
26
- This avoids a single massive step that rewrites everything at once.
27
-
28
- ## Stage: Implementation — TDD (2026-05-28T01:00:00Z)
29
-
30
- ### Session summary
31
-
32
- Completed all 9 TDD steps in 9 commits (plus 2 planning/retro docs commits).
33
- Test count went from 1005 to 1020 (+15 tests).
34
- `AgentManager.startAgent()`, `SpawnArgs`, and `onSessionCreated` callback are deleted.
35
- `Agent.run()` now owns the full execution lifecycle.
36
-
37
- ### Observations
38
-
39
- - **Steps 7–8 merged in practice:** The tool-layer `onSessionCreated` → `observer` migration (step 8) had to be done alongside the `AgentSpawnConfig` change (step 7) because removing the `onSessionCreated` field broke compilation of `background-spawner.ts` and `foreground-runner.ts`.
40
- This was expected — they share the same type.
41
- - **`setupWorktree` kept public:** The plan called for making it private in step 4, but it was kept public through step 6 since the manager still called it.
42
- After step 7 (Agent.run() absorbs the call), it could be made private; left as a minor follow-up (reviewer flagged as WARN).
43
- - **`isBackground` removed from Agent storage:** The field was declared on `AgentInit` but Agent never reads it — the manager resolves `isBackground` before construction (setting initial status and composing the observer).
44
- Biome flagged it as unused; removed from stored fields, kept on `AgentInit` for the manager's use.
45
- - **Worktree error surface confirmed async:** The `agent-manager.test.ts` test for synchronous worktree throw was rewritten to verify the error surfaces on `record.error` after awaiting the promise.
46
- `background-spawner.ts` try/catch around `spawn()` retained for robustness.
47
- - **Pre-completion reviewer:** WARN — 3 non-blocking findings: `setupWorktree` not marked private, `isBackground` dead field on `AgentInit`, and `package-pi-subagents` SKILL.md Phase 15 description referencing deleted `startAgent`.
48
-
49
- ## Stage: Final Retrospective (2026-05-28T01:30:00Z)
50
-
51
- ### Session summary
52
-
53
- Planned, implemented (9 TDD steps), shipped, and released `pi-subagents-v11.0.0` in a single session spanning planning → TDD → ship → retro.
54
- Test count: 1005 → 1020 (+15).
55
- Also filed #249 (`pi-permission-system` bash external-directory gate bug) discovered during the pre-completion review.
56
-
57
- ### Observations
58
-
59
- #### What went well
60
-
61
- - The lift-and-shift TDD strategy (steps 1–5 incrementally preparing, step 6 adding `Agent.run()`, step 7 rewriting `spawn()`) kept every commit compilable and green.
62
- No step required backtracking.
63
- - The `ask-user` call during planning (observer pattern vs callbacks, sync vs async error surface) front-loaded design decisions that would have caused rework if deferred.
64
- - Pre-commit hooks caught both lint failures (`no-unnecessary-condition` on `abortController?.abort()`, `unbound-method` on observer forwarding) before they reached CI.
65
-
66
- #### What caused friction (agent side)
67
-
68
- - `wrong-abstraction` — The plan separated step 7 (remove `onSessionCreated` from `AgentSpawnConfig`) and step 8 (update tool-layer consumers) as distinct commits.
69
- Removing the field immediately broke `background-spawner.ts` and `foreground-runner.ts` at compilation, forcing a merge.
70
- Impact: added friction but no rework — the merge was straightforward since both files needed the same `onSessionCreated` → `observer` transformation.
71
- Added a testing skill rule to catch this pattern in future plans.
72
-
73
- #### What caused friction (user side)
74
-
75
- - The pre-completion reviewer's Mermaid validation (`mmdc -o /tmp/mermaid-check.svg`) triggered a permission prompt from `pi-permission-system` despite `/tmp/*` being configured as `"allow"` in the global config.
76
- This was a genuine bug (#249) in the bash external-directory gate, not a config mistake.
77
- The prompt interrupted the automated review flow, requiring manual approval.
78
-
79
- ### Diagnostic details
80
-
81
- - **Model-performance correlation** — Pre-completion reviewer ran on `claude-sonnet-4-6-20260526`; appropriate for judgment-heavy review work (code design, acceptance criteria, mermaid validation).
82
- No mismatches detected.
83
- - **Feedback-loop gap analysis** — `pnpm run check` and `pnpm run test` were run after every TDD step commit, not just at the end.
84
- `pnpm run lint` ran at the end (post-TDD checks) and at pre-push, which is correct since lint is slower and pre-commit hooks catch most issues incrementally.
85
-
86
- ### Changes made
87
-
88
- 1. `.pi/skills/testing/SKILL.md` — added TDD planning rule: when a step removes a field from a shared interface, all downstream readers must update in the same step.
89
- 2. `packages/pi-subagents/docs/retro/0229-agent-born-complete.md` — appended Final Retrospective stage entry.
@@ -1,38 +0,0 @@
1
- ---
2
- issue: 230
3
- issue_title: "Extract ConcurrencyQueue from AgentManager (Phase 15, Step 5)"
4
- ---
5
-
6
- # Retro: #230 — Extract ConcurrencyQueue from AgentManager
7
-
8
- ## Stage: Planning (2026-05-28T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 3-step TDD plan for extracting the scheduling concern (3 fields, 3 methods) from `AgentManager` into a new `ConcurrencyQueue` class.
13
- Both dependencies (#229 Agent.run(), #231 runner self-contained) are confirmed closed.
14
-
15
- ### Observations
16
-
17
- - The issue's proposed API has `drain(start: (id: string) => void)` but also `markFinished()` as no-arg with "running--, drain()" semantics — a contradiction.
18
- Resolved by storing the `startAgent` callback at construction, making both `drain()` and `markFinished()` no-arg.
19
- This follows Tell-Don't-Ask and matches the established forward-reference-via-closure pattern already used for `onMaxConcurrentChanged`.
20
- - `markFinished()` auto-drain changes the ordering from "decrement → observer → drain" to "decrement + drain → observer."
21
- Verified this is safe: observer notification only processes the completed agent and drain only starts promises without awaiting.
22
- - `SettingsManager` does not change — only the callback wiring in `index.ts` changes target from `manager.notifyConcurrencyChanged()` to `queue.drain()`.
23
- - The `agent.ts` `abort()` method has a comment referencing #230 that should be updated in the implementation step.
24
-
25
- ## Stage: Implementation — TDD (2026-05-28T21:35:00Z)
26
-
27
- ### Session summary
28
-
29
- Implemented all 3 TDD steps: (1) `ConcurrencyQueue` class + 22 unit tests, (2) migrated `AgentManager` to use injected `ConcurrencyQueue` and updated `index.ts` wiring + test helper, (3) architecture docs and SKILL.md updates.
30
- Test count delta: 1020 → 1042 (+22 new `ConcurrencyQueue` tests, 0 removed).
31
-
32
- ### Observations
33
-
34
- - The `createManager` test helper required the forward-reference-via-closure pattern (`let mgr` then closure then assignment) with a `prefer-const` ESLint suppression — same pattern used in production `index.ts` for `onMaxConcurrentChanged`.
35
- - Pre-completion reviewer returned WARN for one stale comment (`drainQueue` reference in `waitForAll`) — fixed by amending the docs commit.
36
- - No plan deviations.
37
- All module-level changes matched the plan exactly.
38
- - Pre-completion reviewer: WARN → fixed (stale comment).
@@ -1,71 +0,0 @@
1
- ---
2
- issue: 231
3
- issue_title: "Push exec/registry relay deps to runner construction (Phase 15, Step 3)"
4
- ---
5
-
6
- # Retro: #231 — Push exec/registry relay deps to runner construction
7
-
8
- ## Stage: Planning (2026-05-27T21:53:10Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 6-step TDD plan to move `exec` and `registry` from `AgentManager` to `ConcreteAgentRunner` via a new `RunnerDeps` interface.
13
- The plan keeps `RunContext` (shrunk to 2 per-call fields) rather than dissolving it — #229 will likely dissolve it when `Agent.run()` calls the runner directly.
14
-
15
- ### Observations
16
-
17
- - Confirmed `exec` and `registry` are pure relay deps on `AgentManager` — stored at construction, used only at lines 193–194 to forward into `runner.run()`.
18
- - Chose `RunnerDeps` bag over separate positional params on `ConcreteAgentRunner` and `runAgent()` — groups all three runner-owned deps (`io`, `exec`, `registry`) in one interface, and `runAgent()` stays at 5 parameters.
19
- - `AgentManagerOptions.registry` uses the concrete `AgentTypeRegistry` class; `RunContext.registry` uses the narrow `AgentConfigLookup` interface.
20
- The new `RunnerDeps.registry` uses `AgentConfigLookup` (ISP).
21
- - Test churn is moderate (~20 `runAgent()` call sites change last param pattern) but mechanical — assertions stay identical.
22
- - Added a `createRunnerDeps()` test helper to `runner-io.ts` to reduce per-file boilerplate in runner tests.
23
-
24
- ## Stage: Implementation — TDD (2026-05-27T22:05:32Z)
25
-
26
- ### Session summary
27
-
28
- Implemented the 6-step plan in 4 commits (steps 3–5 merged).
29
- All 1005 tests pass; no test count change.
30
- Pre-completion reviewer returned PASS.
31
-
32
- ### Observations
33
-
34
- - Plan steps 3, 4, and 5 could not be separate commits: removing `exec`/`registry` from `RunContext` (step 3) immediately caused TypeScript excess-property errors in `AgentManager` (step 4) and `index.ts` (step 5).
35
- Merged all three into one commit.
36
- The testing skill’s rule “when a TDD step changes an interface that has a single call site, the step must include updating that call site” applies.
37
- - Shrinking `RunContext` to all-optional fields made pre-existing `as never` casts in `test/helpers/manager-stubs.test.ts` unnecessary (eslint `no-unnecessary-type-assertion`).
38
- Fixed as a lint cleanup in the doc commit.
39
- - The `sed`-based bulk replacement for `runAgent(..., io)` → `runAgent(..., { io, exec, registry: mockAgentLookup })` missed one multi-line call site (the `rejects.toThrow` test wrapping the call in `expect()`).
40
- Caught immediately by the test run.
41
-
42
- ## Stage: Final Retrospective (2026-05-27T22:43:52Z)
43
-
44
- ### Session summary
45
-
46
- Shipped #231 cleanly: CI passed on first push, issue closed, release `pi-subagents-v10.2.1` published.
47
- The entire issue (plan → TDD → ship) completed in one sitting with no user intervention needed.
48
-
49
- ### Observations
50
-
51
- #### What went well
52
-
53
- - The `RunnerDeps` design was unambiguous — the `ask_user` gate in planning correctly identified the one genuine design choice (`RunContext` fate) and got user input before proceeding.
54
- - Pre-completion reviewer returned PASS with zero findings, confirming the mechanical refactoring was clean.
55
- - Merging plan steps 3–5 during TDD was the right call; the testing skill rule about single-call-site interfaces caught the plan's error before any broken commit landed.
56
-
57
- #### What caused friction (agent side)
58
-
59
- - `wrong-abstraction` — The plan listed steps 3, 4, and 5 as separate commits and claimed "each commit is independently valid," but removing fields from `RunContext` (step 3) immediately caused TypeScript excess-property errors in `AgentManager` (step 4) and `index.ts` (step 5).
60
- The existing `/plan-issue` rule (line 109) covers removing exports with single call sites, but did not trigger recognition because this was *shrinking* an interface, not removing one.
61
- Impact: the TDD agent had to merge three steps on the fly — no rework, but the plan was misleading.
62
- - `missing-context` — The `sed`-based bulk replacement for `runAgent(..., io)` missed one multi-line call site where `}, io)` appeared on a different line than the opening `runAgent(`.
63
- Impact: one extra manual edit; caught immediately by the test run.
64
-
65
- #### What caused friction (user side)
66
-
67
- - No friction observed — the user's involvement was limited to confirming the `RunContext` design choice during planning.
68
-
69
- ### Changes made
70
-
71
- 1. `.pi/prompts/plan-issue.md` — added a rule under TDD Order: when a step removes fields from an interface, include downstream object-literal call-site updates in the same step (TypeScript excess property checking).
@@ -1,109 +0,0 @@
1
- ---
2
- issue: 232
3
- issue_title: "Agent.resume() with internal observer lifecycle (Phase 15, Step 6)"
4
- ---
5
-
6
- # Retro: #232 — Agent.resume() with internal observer lifecycle (Phase 15, Step 6)
7
-
8
- ## Stage: Planning (2026-05-28T18:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 3-step plan to move the observer subscribe/use/release pattern out of `AgentManager.resume()` into a new `Agent.resume(prompt, signal?)`, mirroring the `run()` wiring added in #229.
13
- This is the last "manager reaches into Agent" duplication in the Phase 15 roadmap (Step 6, priority 8).
14
- Confirmed the prerequisite #229 is closed and `Agent` already holds `_runner`, `observer`, `attachObserver`/`releaseListeners`, and `resetForResume`.
15
-
16
- ### Observations
17
-
18
- - Non-breaking (`feat:`) — `AgentManager.resume()` keeps its signature and `Agent | undefined` contract; `Agent.resume()` is additive.
19
- No `ask_user` needed; the issue's proposed change is concrete and unambiguous.
20
- - Observer routing equivalence verified: old code wired `onCompact` → `AgentManagerObserver.onAgentCompacted`; new code routes through the per-agent `AgentLifecycleObserver.onCompacted`, which `buildObserver()` forwards to `onAgentCompacted`.
21
- Net routing identical.
22
- - Abort semantics intentionally preserved — `signal` flows straight to `runner.resume({ signal })`, not through the agent's `abortController` (resume differs from `run()` here; flagged as a Non-Goal to avoid accidental behavior change).
23
- - Removing the `subscribeAgentObserver` import from `agent-manager.ts` must land in the same commit as the body rewrite (type checker flags the unused import). `grep` confirmed `agent.ts` remains the importer and `record-observer.ts` keeps the export live.
24
- - Discovered the `architecture.md` class diagram is stale from #229 (missing `Agent.run()`, stale `setupWorktree`/`completeRun`/`setOnRunFinished` signatures, old `resume(id, snapshot, exec)`).
25
- Scoped only a light touch (resume-related entries + Step 6 ✅); full diagram refresh deferred as a follow-up.
26
- - Lift-and-shift TDD order: step 1 introduces `Agent.resume()` alongside the old manager logic; step 2 collapses the manager method and removes the import together.
27
- Existing manager-level resume tests act as the integration safety net and stay.
28
-
29
- ## Stage: Implementation — TDD (2026-05-28T19:00:00Z)
30
-
31
- ### Session summary
32
-
33
- Completed all 3 TDD steps in 3 commits plus a bonus `fix:` commit, totalling 4 new commits.
34
- `Agent.resume()` added with full observer lifecycle, `AgentManager.resume()` collapsed to guard-plus-delegation, `subscribeAgentObserver` import removed from `agent-manager.ts`, and `architecture.md` updated.
35
- Test count: 1042 → 1053 (+11).
36
-
37
- ### Observations
38
-
39
- - **Bonus fix found mid-session:** A user question revealed a listener leak introduced in #229 — `Agent.run()` called `wireSignal()` before `setupWorktree()`, but the worktree-failure catch block returned without `releaseListeners()`, leaving the parent `AbortSignal` holding a reference to the errored agent.
40
- Fixed TDD-style: failing test first (`"releases the parent-signal listener when worktree setup fails"` in `agent.test.ts`), then one-line fix adding `this.releaseListeners()` to the catch block in `run()`.
41
- Committed as a separate `fix:` commit with a body attributing the regression to #229.
42
- - **Pre-completion reviewer: WARN** — one non-blocking finding: the Phase 15 findings-summary table in `architecture.md` didn't mark the resolved rows (consistent pre-existing pattern from #229–#231).
43
- Fixed by adding strikethrough + ✅ to all four resolved finding rows (#229 "Agent cannot run itself", #230 "Scheduling", #231 "exec/registry", #232 "resume()") in an additional `docs:` commit.
44
- All other reviewer checks passed (Mermaid diagrams validated with `mmdc`, fallow clean, code design clean).
45
- - **Reviewer warning resolved:** The findings table gap was pre-existing across four issues; closing it in this commit makes the table accurate going into Phase 16.
46
-
47
- ## Stage: Final Retrospective (2026-05-28T20:31:35Z)
48
-
49
- ### Session summary
50
-
51
- Planned, implemented (3 TDD steps), fixed a latent #229 bug surfaced by a user question, shipped, and released `pi-subagents-v11.2.0` in a single continuous session.
52
- Test count: 1042 → 1053 (+11).
53
- The dominant friction was capturing the `pre-completion-reviewer`'s verdict: foreground subagent dispatch surfaced only the completion banner, not the report body, forcing several retrieval attempts and a near-miss where shipping began before a clean verdict existed.
54
-
55
- ### Observations
56
-
57
- #### What went well
58
-
59
- - **User-prompted latent-bug discovery, fixed TDD-style.**
60
- The user's question "did we introduce a bug in a prior issue?"
61
- led to finding the `Agent.run()` abort-signal listener leak (regression from #229: `wireSignal()` ran before `setupWorktree()`, and the worktree-failure catch returned without `releaseListeners()`).
62
- Fixed red→green: failing test `"releases the parent-signal listener when worktree setup fails"` first, then a one-line `releaseListeners()` addition.
63
- The `fix:` commit body attributes the regression to #229 so release-please categorizes it correctly.
64
- - **Lift-and-shift plan executed without backtracking.**
65
- Step 1 introduced `Agent.resume()` alongside the old manager logic; step 2 collapsed the manager method and removed the `subscribeAgentObserver` import together (type checker would reject splitting them).
66
- Every commit stayed green.
67
- - **Incremental verification.** `pnpm run check` + targeted `vitest run` after each TDD step; full suite, lint, and `pnpm fallow dead-code` (from repo root) after the last step.
68
-
69
- #### What caused friction (agent side)
70
-
71
- - `other` (tooling) — Foreground `pre-completion-reviewer` dispatch returned only the completion banner (`Agent completed in Xs, N tool uses`), not the report body.
72
- Two foreground dispatches yielded a truncated line and an empty body; `get_subagent_result` reported the foreground agent was "cleaned up"; `read_session` omits tool-result bodies.
73
- Only a background dispatch retrieved via `get_subagent_result(wait: true, verbose: true)` surfaced the full PASS/WARN report.
74
- Impact: ~5 wasted retrieval/re-dispatch tool calls and one long thrashing reviewer run (232 tool uses, with repeated `fatal: bad revision` git lookups) before a clean verdict.
75
- - `instruction-violation` (user-caught) — The `pre-completion` skill says "proceed to Summarize only after the reviewer returns PASS or WARN," but I began `/ship-issue` (pushed, started `ci_watch`) without ever cleanly capturing a verdict.
76
- The user interrupted: "we should have verified our fix … can we try dispatching pre-completion again?"
77
- Impact: aborted `ci_watch`, re-dispatched the review, then re-shipped — no incorrect release, but a redundant push/CI cycle.
78
- Root cause is shared with the tooling friction above: because the verdict was never captured, the gate silently passed.
79
-
80
- #### What caused friction (user side)
81
-
82
- - The user's prior-issue-bug question was high-value strategic redirection — it surfaced a real defect the `pre-completion-reviewer` itself examined (`completeRun`/`failRun`/`abort`) but did not flag.
83
- Opportunity: the reviewer's code-design lens could check resource-cleanup symmetry across all early-return paths, not just the happy/`failRun` paths.
84
- - The user caught the "shipped before verifying" gap that should have been the agent's own gate.
85
- Framed as opportunity: a reliable verdict-capture step removes the need for this manual oversight.
86
-
87
- ### Diagnostic details
88
-
89
- - **Model-performance correlation** — The `pre-completion-reviewer` ran on `claude-sonnet-4-6`; appropriate for judgment-heavy review (code design, acceptance criteria, Mermaid validation).
90
- No mismatch.
91
- Note: the first (truncated) run used 232 tool calls vs 26 for the clean run — the long run thrashed on failed `git rev-parse` lookups of abbreviated SHAs.
92
- - **Escalation-delay tracking** — The verdict-capture rabbit hole ran >5 consecutive tool calls (foreground re-dispatch → `get_subagent_result` → `read_session` → background dispatch) before the background+verbose approach worked.
93
- Switching to background dispatch after the first truncation would have resolved it immediately.
94
- - **Feedback-loop gap analysis** — No gap: verification ran incrementally after each TDD step, and `fallow` ran from the repo root (not a package subdir), matching CI.
95
-
96
- ### Changes made
97
-
98
- 1. `.pi/skills/pre-completion/SKILL.md` — added a Step 3 guard (P2, safety net): a missing `Overall: PASS|WARN|FAIL` line is treated as "report not captured" and triggers a re-dispatch; do not proceed to "Summarize" on a banner-only result.
99
- 2. `.pi/agents/pre-completion-reviewer.md` — reviewer-side durable fix: (a) the final message must be the report block ending with `### Overall`, never a trailing tool call; (b) thrash guard — use the dispatcher-provided base tag and modified-files list, do not retry `git rev-parse` on abbreviated SHAs.
100
- 3. Proposal P1 (background dispatch + verbose retrieval) was presented but **not** adopted; with the reviewer's output contract fixed, foreground dispatch should return the report directly.
101
- Recorded as a fallback if banner-only foreground results recur.
102
-
103
- ### Root-cause follow-up: reviewer verdict-capture failure
104
-
105
- After the initial retro commit we examined *why* foreground dispatches returned only a banner.
106
- Ruled out the #229 abort-signal leak: it only fires on `isolation: "worktree"` setup failure (never exercised by the reviewer dispatches, which used no worktree), and a leaked listener cannot truncate a healthy agent's output — wrong code path and wrong symptom.
107
- The `/reload` after the fix is a confounder (it clears in-session state) but does not implicate the leak itself.
108
- Best explanation (≈70% confidence): the reviewer ended long, thrashing runs (232 tool calls, repeated `fatal: bad revision` lookups) *on tool activity rather than a final report*, so foreground returned the last text it saw.
109
- Note: the running extension loads `../packages/pi-subagents` from this working tree (per `.pi/settings.json`), so source edits take effect after `/reload` — an earlier claim that the session ran an installed build was wrong.