@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,66 +0,0 @@
1
- ---
2
- issue: 166
3
- issue_title: "refactor(pi-subagents): extract ParentSessionInfo from AgentSpawnConfig (13 fields)"
4
- ---
5
-
6
- # Retro: #166 — Extract ParentSessionInfo from AgentSpawnConfig
7
-
8
- ## Stage: Planning (2026-05-24T16:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 6-step TDD plan to extract `ParentSessionInfo` from `AgentSpawnConfig`.
13
- The refactoring groups three co-traveling fields (`parentSessionFile`, `parentSessionId`, `toolCallId`) into a named value object, reducing `AgentSpawnConfig` from 13 to 11 fields.
14
-
15
- ### Observations
16
-
17
- - The `SubagentsService` boundary (`service-adapter.ts`) does not pass any of the three fields, so this is a purely internal refactoring with no public API impact.
18
- - `getSessionInfo` in `AgentToolDeps` returns only `parentSessionFile` and `parentSessionId`; `toolCallId` comes from the `execute` callback's first argument — the plan keeps this separation and merges them at the `agent-tool.ts` boundary.
19
- - `RunOptions` in `agent-runner.ts` never carried `toolCallId` (it was consumed in `AgentManager.spawn` before reaching the runner), so the nested `parentSession` on `RunOptions` only holds the two session fields.
20
- - The deep-merge trap from the testing skill is relevant: `background-spawner.test.ts` has a `makeParams` factory that spreads flat fields — must be converted to nested `parentSession` construction.
21
- - Issue #165 (decompose `ResolvedSpawnConfig`) is closed, so this plan builds on stable ground.
22
-
23
- ## Stage: Implementation — TDD (2026-05-24T17:00:00Z)
24
-
25
- ### Session summary
26
-
27
- All 5 TDD cycles completed across `agent-manager.ts`, `agent-runner.ts`, `background-spawner.ts`, `foreground-runner.ts`, and `agent-tool.ts`.
28
- Test count held steady at 805 (no net new tests — refactor only).
29
- Type check and lint both clean after all steps.
30
-
31
- ### Observations
32
-
33
- - The `AgentSpawnConfig` field count went from 15 to 13 (not 13 → 10 as originally estimated) — the architecture doc quoted the issue's stale count; the actual pre-refactor interface had 15 fields (`bypassQueue` and others were already present).
34
- The architecture doc was updated to reflect "done" with a note about the nested group rather than a specific before/after number.
35
- - The deep-merge trap (noted in planning) did materialise: `background-spawner.test.ts`'s `makeParams` spread `Partial<BackgroundParams>` with flat fields.
36
- Fixed by replacing the three flat fields with a single `parentSession` object at the factory level — top-level spread still works correctly since `parentSession` is one field.
37
- - `RunOptions` in `agent-runner.ts` needed a new import of `ParentSessionInfo` from `agent-manager.ts`; no circular dependency since `agent-runner.ts` already imports from `agent-manager.ts`.
38
- - `agent-tool.ts` still imports `AgentSpawnConfig` (needed by `AgentToolManager` interface) — the new `ParentSessionInfo` import was added alongside it.
39
- - All 5 commits are clean `refactor:` messages; architecture doc update is a separate `docs:` commit.
40
-
41
- ## Stage: Final Retrospective (2026-05-24T18:00:00Z)
42
-
43
- ### Session summary
44
-
45
- Planning, TDD implementation (5 steps), shipping, and CI verification all completed in a single session.
46
- Released as `pi-subagents-v6.18.2`.
47
- Zero rework — every TDD step went green on first attempt.
48
-
49
- ### Observations
50
-
51
- #### What went well
52
-
53
- - The planning session's identification of the deep-merge trap in `background-spawner.test.ts`'s `makeParams` factory paid off — the TDD implementation handled it without friction because the risk was anticipated.
54
- - The 5-step inside-out TDD order (manager → runner → background → foreground → agent-tool) was the right sequence.
55
- Each step only introduced type errors in files that subsequent steps would fix, with no circular breakage.
56
- - Clean mechanical execution — 805 tests before and after, zero rework commits, lint and type-check clean throughout.
57
-
58
- #### What caused friction (agent side)
59
-
60
- - `missing-context` — The plan repeated the issue body's stale "13 fields" count without verifying against the actual `AgentSpawnConfig` interface (which had 15 fields after `bypassQueue` was added in a prior issue).
61
- The plan also inconsistently claimed the extraction would reduce the count to both "11" and "10" in different places.
62
- Impact: required corrections in the architecture doc update, but no implementation rework.
63
-
64
- #### What caused friction (user side)
65
-
66
- - None observed — the user let the session run autonomously through all stages without intervention.
@@ -1,63 +0,0 @@
1
- ---
2
- issue: 167
3
- issue_title: "refactor(pi-subagents): narrow RunnerIO (9 methods → 2 focused interfaces)"
4
- ---
5
-
6
- # Retro: #167 — narrow RunnerIO (9 methods → 2 focused interfaces)
7
-
8
- ## Stage: Planning (2026-05-24T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a plan to split the `RunnerIO` interface in `agent-runner.ts` into two focused sub-interfaces (`EnvironmentIO` and `SessionFactoryIO`) while keeping `RunnerIO` as a backward-compatible type alias for their intersection.
13
- The change is a pure refactoring with zero runtime behavior change.
14
-
15
- ### Observations
16
-
17
- - The split is mechanical and low-risk: `RunnerIO` becomes `type RunnerIO = EnvironmentIO & SessionFactoryIO`, and all existing consumers (production code and test factories) continue to compile via structural typing.
18
- - Dependency #164 (reorganize into domain directories) is already closed, so file paths are current.
19
- - The two test `createRunnerIO()` factories are unannotated (intentionally, per testing skill guidelines), so they don't need type-level updates — only comment updates for documentation.
20
- - This is a two-commit TDD plan, suitable for `/build-plan` rather than full TDD cycles since no new tests are required.
21
-
22
- ## Stage: Implementation — TDD (2026-05-24T20:45:00Z)
23
-
24
- ### Session summary
25
-
26
- Completed both TDD steps in full.
27
- Step 1 added `EnvironmentIO` and `SessionFactoryIO` interfaces and converted `RunnerIO` to a type alias in `agent-runner.ts`; step 2 updated comments in both test factories.
28
- Test count held steady at 805/805 (50 files) — no behavioral changes.
29
-
30
- ### Observations
31
-
32
- - The type check (`pnpm run check`) passed immediately after the interface split — structural typing meant zero call-site changes in `index.ts` or test factories.
33
- - `RunnerIO` JSDoc was split: `EnvironmentIO` got the environment-discovery description, `SessionFactoryIO` got the original "decouples from Pi SDK imports" description, and `RunnerIO` itself got a short backward-compatibility note.
34
- - Architecture doc updated: wide-interface table row and Step 4 roadmap entry both marked done.
35
- - No deviations from the plan.
36
-
37
- ## Stage: Final Retrospective (2026-05-24T21:30:00Z)
38
-
39
- ### Session summary
40
-
41
- Issue #167 completed across three sessions: planning, TDD implementation, and ship.
42
- The `RunnerIO` interface was split into `EnvironmentIO` and `SessionFactoryIO` with a backward-compatible type alias.
43
- Released as `pi-subagents-v6.18.4`.
44
-
45
- ### Observations
46
-
47
- #### What went well
48
-
49
- - The plan correctly identified that structural typing would make this zero-friction — no call-site changes were needed in `index.ts` or either test factory.
50
- - The two-step TDD plan was right-sized for a pure refactoring: step 1 for the interface split, step 2 for comment updates.
51
- No new tests were needed, and the existing 805 tests validated the change without modification.
52
- - Ship session was clean: CI passed first try, release-please PR merged, issue closed.
53
-
54
- #### What caused friction (agent side)
55
-
56
- - `missing-context` — The TDD session's architecture doc update (`824fd72`) only touched the `RunnerIO`-specific table row and Step 4 roadmap entry.
57
- It missed that the same file's "Current layout" section still showed the pre-#164 flat file structure and retained a redundant "Proposed directory restructuring" section.
58
- The user had to request a follow-up update (`d4a98aa`) in the ship session.
59
- Impact: one extra commit and user prompt; no rework of prior commits.
60
-
61
- #### What caused friction (user side)
62
-
63
- - No friction observed.
@@ -1,76 +0,0 @@
1
- ---
2
- issue: 168
3
- issue_title: "refactor(pi-subagents): extract ToolFilterConfig from SessionConfig (11 fields)"
4
- ---
5
-
6
- # Retro: #168 — extract ToolFilterConfig from SessionConfig
7
-
8
- ## Stage: Planning (2026-05-24T19:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 2-step plan to extract `ToolFilterConfig` (grouping `toolNames`, `disallowedSet`, `extensions`) from `SessionConfig` and update `filterActiveTools` to accept the named type.
13
- The change is a pure internal refactoring — `SessionConfig` is not exported from the package.
14
-
15
- ### Observations
16
-
17
- - The issue says "11 fields" but `SessionConfig` currently has 10 — likely a minor count discrepancy from when the issue was filed.
18
- The extraction still reduces top-level fields from 10 to 8.
19
- - `toolNames` serves dual duty: it's both the session-creation tool list and the `filterActiveTools` allowlist reference.
20
- Nesting it under `toolFilter` is still correct since both uses originate from the same assembled config.
21
- - `agent-runner-extension-tools.test.ts` exercises tool filtering end-to-end via `runAgent` and never references `SessionConfig` fields directly — it serves as a zero-change regression canary for this refactoring.
22
- - The plan has only 2 TDD steps because the refactoring is mechanical and behavior-preserving.
23
- Step 1 handles the interface change + assembler + tests; step 2 handles the consumer (`filterActiveTools` + `runAgent`).
24
-
25
- ## Stage: Implementation — TDD (2026-05-24T19:30:00Z)
26
-
27
- ### Session summary
28
-
29
- Completed both refactoring steps cleanly.
30
- `ToolFilterConfig` is now exported from `session-config.ts`, nested as `SessionConfig.toolFilter`, and consumed by `filterActiveTools` as a single named argument.
31
- All 805 tests continue to pass; no new tests were added (pure structural refactoring with no behavior change).
32
-
33
- ### Observations
34
-
35
- - Step 1 left intentional type errors in `agent-runner.ts` (expected: the consumer hadn't been updated yet); committing mid-step-1 was correct because the session-config tests were green in isolation.
36
- - The autoformatter ran on `agent-runner.ts` after the Step 2 edits (Biome reformatted the two condensed filter-call lines); the committed diff was already formatted.
37
- - All 9 flat-field assertions in `session-config.test.ts` (`result.toolNames`, `result.extensions`, `result.disallowedSet`) were correctly migrated to `result.toolFilter.*` — grep confirmed no stragglers.
38
- - `agent-runner-extension-tools.test.ts` required zero changes, confirming its role as a regression canary.
39
- - Architecture doc updated: `SessionConfig` row in the wide-interface table marked `✓ done`; Step 5 narrative updated to reflect actual field count (10 → 8, not 11 → 8 as the issue stated).
40
-
41
- ## Stage: Final Retrospective (2026-05-24T20:00:00Z)
42
-
43
- ### Session summary
44
-
45
- Issue #168 completed across three sessions (Planning → TDD → Ship) with zero friction, rework, or plan deviations.
46
- Total diff: 3 files changed, 37 insertions, 41 deletions (net reduction).
47
- Released as `pi-subagents-v6.18.5`.
48
-
49
- ### Observations
50
-
51
- #### What went well
52
-
53
- - **Grep-before-commit safety net.**
54
- The planning session identified 9 flat-field assertions in `session-config.test.ts` that would silently pass as `undefined` if missed during migration.
55
- The TDD session grepped for all three field names before committing step 1, catching all 9 in one pass.
56
- This is the testing skill’s "grep for all test files" rule applied to assertion migration.
57
- - **Regression canary identification during planning.**
58
- The planning session called out `agent-runner-extension-tools.test.ts` as a zero-change regression canary.
59
- The TDD session confirmed this prediction — no changes needed, all existing tests green.
60
- Identifying canary tests during planning gave confidence that the two refactoring steps were correctly scoped.
61
- - **2-step granularity was right.**
62
- Step 1 (interface + assembler + tests) left intentional type errors in the consumer.
63
- Step 2 (consumer update) resolved them.
64
- This kept each commit reviewable and type-check-green at the session-config boundary.
65
-
66
- #### What caused friction (agent side)
67
-
68
- None.
69
-
70
- #### What caused friction (user side)
71
-
72
- None.
73
-
74
- ### Changes made
75
-
76
- No process changes — clean execution with no proposals warranted.
@@ -1,68 +0,0 @@
1
- ---
2
- issue: 169
3
- issue_title: "refactor(pi-subagents): extract RunContext from RunOptions (12 fields)"
4
- ---
5
-
6
- # Retro: #169 — extract RunContext from RunOptions
7
-
8
- ## Stage: Planning (2026-05-24T17:07:10Z)
9
-
10
- ### Session summary
11
-
12
- Produced a plan to extract 4 parent-context fields (`exec`, `registry`, `cwd`, `parentSession`) from `RunOptions` into a nested `RunContext` interface.
13
- The plan is a single-step refactor (all changes in one commit) plus a comment-update commit, affecting 3 source files and 3 test files.
14
-
15
- ### Observations
16
-
17
- - The issue body proposed flat `parentSessionFile`/`parentSessionId` fields on `RunContext`, but #166 already grouped these into `ParentSessionInfo`.
18
- The plan uses `parentSession?: ParentSessionInfo` instead, preserving the existing grouping.
19
- - `RunOptions` is purely internal — not exported via `service.ts` — so the refactor is non-breaking.
20
- - All test call sites construct `RunOptions` inline (no `Partial<RunOptions>` spread patterns), so TypeScript will catch any missing `context` field at compile time.
21
- - The change is small enough to land in a single TDD step — no lift-and-shift needed.
22
- - Prerequisite #164 (directory reorganization) is already implemented.
23
-
24
- ## Stage: Implementation — TDD (2026-05-24T17:14:32Z)
25
-
26
- ### Session summary
27
-
28
- Completed both TDD steps in one session.
29
- Step 1 defined `RunContext`, updated `RunOptions`, migrated `runAgent()` reads to `options.context.*`, restructured `AgentManager.startAgent()`, and updated all 16 test call sites across 3 test files.
30
- Step 2 updated comment references in `runtime.ts` and `session-config.ts`.
31
- Test count unchanged (50 files, 805 tests — pure refactor with no behavior change).
32
-
33
- ### Observations
34
-
35
- - The `agent-manager.test.ts` update also added two new assertions (`context.exec` and `context.registry` are defined) to each existing `getRunConfig` threading test, confirming the context object is wired correctly; these were not in the plan but add useful coverage.
36
- - All 16 `runAgent()` call sites in tests used inline option literals (no spread patterns), so TypeScript caught any missed site at compile time — the plan's risk mitigation held.
37
- - No deviations from the plan otherwise; the comment-only step was trivial.
38
-
39
- ## Stage: Final Retrospective (2026-05-24T17:32:52Z)
40
-
41
- ### Session summary
42
-
43
- Completed the full issue lifecycle (plan → TDD → ship → retro) in a single conversation.
44
- The refactor extracted 4 parent-context fields from `RunOptions` into a nested `RunContext` interface, updating 3 source files and 3 test files.
45
- Released as `pi-subagents-v6.18.6`.
46
-
47
- ### Observations
48
-
49
- #### What went well
50
-
51
- - The plan correctly adapted the issue's stale proposed interface (flat `parentSessionFile`/`parentSessionId`) to match the already-implemented `ParentSessionInfo` grouping from #166.
52
- This prevented a design conflict and kept the extraction consistent with prior work.
53
- - All 16 test call sites used inline option literals — no spread patterns — so TypeScript caught every missed migration site at compile time.
54
- The plan's risk analysis predicted this correctly.
55
- - Single-step TDD was appropriate for this scope; no lift-and-shift was needed.
56
-
57
- #### What caused friction (agent side)
58
-
59
- - `missing-context` — After the TDD step, checked the architecture doc for staleness by running `grep` for the exact symbols `RunOptions` and `RunContext`.
60
- The doc's "Dependency bag inventory" table and "Proposed bag decompositions" section used prose descriptions ("12 fields", "High") rather than code identifiers, so the grep found no matches and the agent skipped the update.
61
- The user then asked "Is the architecture doc up to date?"
62
- which prompted a three-fix commit (`ea49fe1`).
63
- Impact: one extra round-trip with the user; no rework to code, but an extra commit that could have been folded into the TDD step.
64
-
65
- #### What caused friction (user side)
66
-
67
- - No friction observed on the user side.
68
- The user's single question ("Is the architecture doc up to date?") was well-timed and caught the only gap.
@@ -1,72 +0,0 @@
1
- ---
2
- issue: 170
3
- issue_title: "refactor(pi-subagents): reduce buildContentLines complexity (cognitive 71)"
4
- ---
5
-
6
- # Retro: #170 — reduce buildContentLines complexity
7
-
8
- ## Stage: Planning (2026-05-24T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a plan to extract per-content-type formatters from `buildContentLines` (cognitive complexity 71) into a new `ui/message-formatters.ts` module.
13
- The plan includes 8 TDD steps: 6 red→green steps for unit tests covering each formatter and the dispatcher, then 2 refactor steps to create the module and simplify `buildContentLines` to a dispatch loop.
14
-
15
- ### Observations
16
-
17
- - The extraction is mechanical — each `if`/`else if` branch in the loop becomes a standalone pure function returning `string[] | null`.
18
- - `FormatterContext` is deliberately narrow (2 fields: `theme` + `wrapText`) to avoid growing a dependency bag.
19
- - File-local types (`ToolCallContent`, `BashExecutionMessage`) and helpers (`getToolCallName`, `isBashExecution`) move with the formatters since they have no other consumers.
20
- - Existing `conversation-viewer.test.ts` tests are integration-level width-safety tests and remain unchanged — they exercise `render()` → `buildContentLines` → `truncateToWidth`, which is orthogonal to per-message formatting.
21
- - Issue #164 (domain directory reorganization) is already implemented, so the file is at `src/ui/conversation-viewer.ts`.
22
-
23
- ## Stage: Implementation — TDD (2026-05-24T21:00:00Z)
24
-
25
- ### Session summary
26
-
27
- Completed all 8 TDD steps: 6 red→green cycles building up `src/ui/message-formatters.ts` (one formatter per step), then 2 refactor steps moving helpers out of `conversation-viewer.ts` and replacing `buildContentLines` with a dispatch loop.
28
- Test count went from 805 to 853 (+48 new unit tests in `test/message-formatters.test.ts`).
29
- `conversation-viewer.ts` shrank from 325 to 251 lines.
30
-
31
- ### Observations
32
-
33
- - `getToolCallName` needed to be exported (not just file-local) so `conversation-viewer.ts` could import it during the intermediate step 7 state; it stays exported since `message-formatters.ts` owns it permanently.
34
- - The `AgentMessage` SDK type does not have an index signature, so the `formatMessage` call in `buildContentLines` required `as unknown as { role: string; [key: string]: unknown }` to satisfy TypeScript's structural checker — this is consistent with the existing `as any` pattern in the codebase for untyped SDK boundaries.
35
- - The `formatStreamingIndicator` uses `◍` (U+25CD CIRCLE WITH VERTICAL FILL) to match the original `▍` character in `buildContentLines` — confirmed identical output.
36
- - Pre-existing lint warning (`Theme` unused import in `conversation-viewer.test.ts`) was fixed as a `style:` commit alongside the final step.
37
-
38
- ## Stage: Final Retrospective (2026-05-24T22:00:00Z)
39
-
40
- ### Session summary
41
-
42
- Shipped issue #170 (CI green, issue closed, released as `pi-subagents-v6.18.7`), then reviewed the full three-session lifecycle (planning → TDD → shipping) for friction patterns.
43
-
44
- ### Observations
45
-
46
- #### What went well
47
-
48
- - The extraction was clean: 48 new unit tests, no behavioral change, all 853 tests green throughout.
49
- - The `FormatterContext` interface stayed at exactly 2 fields — the narrow-interface discipline held.
50
-
51
- #### What caused friction (agent side)
52
-
53
- 1. `wrong-abstraction` — The plan decomposed 8 TDD steps for a mechanical extraction.
54
- Six separate test-only commits (one per formatter) added commit noise without meaningful red→green insight.
55
- Impact: added friction but no rework; a 2–3 step plan would have been cleaner for a copy-and-extract refactoring.
56
- 2. `missing-context` — Step 7 (move helpers) and step 8 (rewire `buildContentLines`) were planned as separate commits, but the intermediate state required temporarily exporting `getToolCallName` and keeping `extractText`/`describeActivity` imports.
57
- The plan didn't account for this intermediate dependency chain.
58
- Impact: one extra edit cycle to add then remove the temporary export.
59
- 3. `instruction-violation` (self-identified, user-caught) — The `/tdd-plan` prompt's step 5 says to check `packages/<PKG>/docs/architecture/` after the last TDD step.
60
- I did not update the architecture doc until the user asked.
61
- Impact: one extra commit and a user intervention; the rule was clear but missed during execution.
62
- 4. `missing-context` — The `formatMessage` dispatcher used `{ role: string; [key: string]: unknown }` as its parameter type, which required `as unknown as` at the call site because the SDK's `AgentMessage` union includes `CompactionSummaryMessage` without an index signature.
63
- The plan's design overview didn't anticipate this SDK type mismatch.
64
- Impact: one extra edit cycle during step 8, no rework.
65
-
66
- #### What caused friction (user side)
67
-
68
- - No friction observed — the user's single intervention (architecture doc) was a legitimate catch of a missed step.
69
-
70
- ### Changes made
71
-
72
- 1. Updated `packages/pi-subagents/docs/retro/0170-reduce-build-content-lines-complexity.md` with final retrospective stage entry.
@@ -1,77 +0,0 @@
1
- ---
2
- issue: 171
3
- issue_title: "refactor(pi-subagents): reduce renderResult complexity (cognitive 43)"
4
- ---
5
-
6
- # Retro: #171 — refactor(pi-subagents): reduce renderResult complexity
7
-
8
- ## Stage: Planning (2026-05-24T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a plan to extract per-status rendering from `renderResult` in `tools/agent-tool.ts` into a new `tools/result-renderer.ts` module with seven pure functions and a dispatcher.
13
- The TDD order has 9 steps: 7 test-first steps (one per function) followed by 2 refactor steps (extract, then simplify).
14
-
15
- ### Observations
16
-
17
- - No existing tests cover `renderResult` — all `agent-tool.test.ts` tests exercise `execute` paths and tool metadata only.
18
- This means the TDD steps write tests against a not-yet-existing module, which is clean red→green.
19
- - The inline `stats()` closure is used by 4 of 6 status branches, making it a natural shared function.
20
- - Completed/steered share 90% of logic (icon color + collapsed text differ); error/aborted share icon+stats structure.
21
- Keeping each pair in one function avoids wrong-abstraction duplication.
22
- - The `Theme` type in `display.ts` and the `widget-renderer.ts` pattern in `ui/` provide a proven template for pure rendering modules — the new module follows the same shape.
23
- - Dependency #164 (domain directory reorganization) is already merged, so file paths use the `tools/` subdirectory.
24
-
25
- ## Stage: Implementation — TDD (2026-05-24T21:00:00Z)
26
-
27
- ### Session summary
28
-
29
- Completed all 9 TDD steps from the plan: 7 test-first commits adding `renderStats`, `renderRunning`, `renderBackground`, `renderCompleted`, `renderStopped`, `renderFailed`, and `renderAgentResult` to `result-renderer.ts`, followed by a refactor commit simplifying `renderResult` in `agent-tool.ts` to a 10-line guard + dispatcher.
30
- Test count increased from 853 to 896 (+43 new tests across 52 test files).
31
- A docs commit updated the architecture file to remove `renderResult` from the complexity hotspot table and add `result-renderer.ts` to the tools layout.
32
-
33
- ### Observations
34
-
35
- - Steps 1–7 built `result-renderer.ts` function by function; the implementation was written upfront from a careful reading of the original `renderResult` body, making each subsequent test step immediately green.
36
- This is valid TDD for an extraction refactor: the tests lock in expected behavior before the extraction is done.
37
- - The ESLint pre-commit hook correctly removed `@typescript-eslint/no-unsafe-return` from `agent-tool.ts`'s `eslint-disable` comment — that rule was only needed by the old `renderResult` body, not the new dispatcher.
38
- - No deviations from the plan: all 7 functions in `result-renderer.ts`, `renderResult` is now a guard + dispatcher as designed, and all 3 unused imports (`SPINNER`, `formatMs`, `formatTurns`) were removed.
39
- - The `Theme` type from `display.ts` worked cleanly for the pure functions — the `widget-renderer.ts` precedent held.
40
-
41
- ## Stage: User Note (2026-05-24T21:30:00Z)
42
-
43
- We need to update `/plan-issue` so the plan includes updating any architecture documents.
44
-
45
- ## Stage: Final Retrospective (2026-05-24T22:00:00Z)
46
-
47
- ### Session summary
48
-
49
- Issue #171 shipped cleanly across three sessions: planning produced a 9-step TDD plan, implementation added 43 tests and extracted `renderResult` into `tools/result-renderer.ts` (cognitive complexity 43 → dispatcher), and shipping released `pi-subagents-v6.18.8` with no deviations.
50
- The only friction was an incomplete architecture doc update that required a second manual pass.
51
-
52
- ### Observations
53
-
54
- #### What went well
55
-
56
- - The plan-to-implementation pipeline worked smoothly for a mechanical extraction refactor — zero deviations from the plan across all 9 TDD steps.
57
- - The `Theme` type from `display.ts` and the `widget-renderer.ts` pattern provided a proven template, making the extraction straightforward.
58
- - ESLint pre-commit hooks caught a stale `eslint-disable` rule (`no-unsafe-return`) automatically during the refactor commit.
59
-
60
- #### What caused friction (agent side)
61
-
62
- - `missing-context` — The TDD session's initial architecture update (commit `1183522`) only updated the complexity hotspot table and layout listing, missing health metrics, the Mermaid domain diagram, the Phase 10 structural refactoring table, and the SKILL.md domain table.
63
- The user had to explicitly request the fuller update, which landed as a second commit (`1510dc7`).
64
- Impact: extra user round-trip and a second commit for what should have been one complete update.
65
- - `missing-context` — The `git add ../../.pi/skills/...` path triggered a `pi-permission-system` permission denial because the relative path escaped the package directory.
66
- Switched to repo-root-relative path to resolve.
67
- Impact: minor — one failed commit attempt, immediately retried.
68
-
69
- #### What caused friction (user side)
70
-
71
- - The `/plan-issue` prompt did not instruct the planner to check architecture docs for sections affected by the change.
72
- Because the plan's Module-Level Changes omitted `docs/architecture/architecture.md`, the TDD session treated architecture updates as an afterthought rather than a planned deliverable.
73
- Impact: the user had to intervene with an explicit request and a retro note.
74
-
75
- ### Changes made
76
-
77
- 1. `.pi/prompts/plan-issue.md` — Added architecture-doc check to the Module-Level Changes bullet: "When the change adds, removes, or moves a module, check `packages/<PKG>/docs/architecture/` for layout listings, complexity tables, health metrics, or domain diagrams that reference the affected files and list them as doc updates."
@@ -1,80 +0,0 @@
1
- ---
2
- issue: 172
3
- issue_title: "refactor(pi-subagents): extract shared turn-formatting logic"
4
- ---
5
-
6
- # Retro: #172 — Extract shared turn-formatting logic
7
-
8
- ## Stage: Planning (2026-05-24T18:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Planned the extraction of duplicated turn-formatting logic from `lifecycle/agent-runner.ts` and `ui/message-formatters.ts` into a new shared module `session/content-items.ts`.
13
- The plan covers extracting `ToolCallContent`, `getToolCallName`, and a new `extractAssistantContent` function, with a 6-step TDD order.
14
-
15
- ### Observations
16
-
17
- - Issue #170 (completed) shifted the duplication target from `conversation-viewer.ts` to `message-formatters.ts` — the issue body's line references are stale but the duplication still exists in the same form.
18
- - Both dependencies (#164 and #170) are closed, so this is unblocked.
19
- - The duplication is clearly incidental (same data extraction, different presentation) — safe to extract per the code-design skill's structural-reasons check.
20
- - `getToolCallName` has no direct unit tests today; the extraction enables testing it for the first time.
21
- - `getAgentConversation` also has no tests — noted as out of scope but worth a follow-up.
22
- - Considered adding `extractText` to the new module for consistency but deferred to keep scope tight.
23
-
24
- ## Stage: Implementation — TDD (2026-05-24T19:05:00Z)
25
-
26
- ### Session summary
27
-
28
- Completed all 6 TDD steps from the plan.
29
- Created `session/content-items.ts` with `getToolCallName` and `extractAssistantContent`, added 11 unit tests, then refactored both `message-formatters.ts` and `agent-runner.ts` to use the shared module.
30
- Test count went from 896 to 907 (+11).
31
-
32
- ### Observations
33
-
34
- - Steps 1 and 2 (test-only commits) were folded into step 3's feat commit per the plan's intent — all three land together.
35
- - The `getToolCallName` parameter type needed widening from `{ type: string }` to `{ type: string; [key: string]: unknown }` to allow test object literals to pass excess-property checking.
36
- This in turn required an `as unknown as` double cast at the `agent-runner.ts` call site, because the SDK's `TextContent | ThinkingContent | ToolCall` union lacks an index signature.
37
- Same pattern already present in `conversation-viewer.ts`.
38
- - `message-formatters.ts` had both an import and a re-export of `getToolCallName`; simplified to a pure re-export only.
39
- - The lint fixup (unused import) was amended into the same refactor commit before pushing.
40
- - Architecture doc updated: `content-items.ts` added to session module listing, production-duplication section updated, Step 9 marked Done.
41
-
42
- ## Stage: Final Retrospective (2026-05-24T20:30:00Z)
43
-
44
- ### Session summary
45
-
46
- Planned, implemented, and shipped the extraction of shared turn-formatting logic from `lifecycle/agent-runner.ts` and `ui/message-formatters.ts` into `session/content-items.ts`.
47
- Released as `pi-subagents-v6.19.0`.
48
- During code review the user challenged double-casts in the initial implementation, which led to discovering that the local `ToolCallContent` type was dead code and the SDK exports the real `ToolCall` type — the final implementation is significantly cleaner than what the plan specified.
49
- Filed #188 for broader `any`-to-SDK-type cleanup discovered during the investigation.
50
-
51
- ### Observations
52
-
53
- #### What went well
54
-
55
- - The user's Socratic challenge ("Talk to me about these double-casts") was the pivotal moment.
56
- Rather than directing a fix, it prompted an investigation of the SDK's actual `ToolCall` type, which revealed that `ToolCall.name` is always required and `toolName` never appears on content items.
57
- This eliminated the `ToolCallContent` interface, the `toolName` fallback, the index-signature parameter type, and all double-casts — none of which the plan anticipated.
58
- - Cross-session retro context worked well: the planning-stage note about #170 shifting the duplication target saved time during TDD.
59
- - The SDK source investigation yielded a follow-up issue (#188) for replacing `any` casts in `extractText` and `SubscribableSession` with proper SDK types.
60
-
61
- #### What caused friction (agent side)
62
-
63
- - `missing-context` — Did not check SDK type exports during planning.
64
- The plan copied `ToolCallContent` verbatim from the existing code without verifying what `@earendil-works/pi-ai` exports.
65
- The source comments ("SDK doesn't export the narrow type") were wrong — the types have been exported for some time.
66
- Impact: the initial TDD implementation introduced a `{ type: string; [key: string]: unknown }` parameter type that forced `as unknown as` double-casts, requiring a full rework after user review.
67
- - `premature-convergence` — When TypeScript rejected excess properties in test object literals, I widened the parameter type to include an index signature instead of exploring alternatives.
68
- The correct fix (using `ReadonlyArray<{ type: string }>` with `in` narrowing, or importing SDK types as test fixtures) was simpler and avoided the cast cascade.
69
- Impact: one round of rework plus an amended commit that muddied the git history.
70
-
71
- #### What caused friction (user side)
72
-
73
- - The user's intervention at the cast review stage was well-timed and effective.
74
- One earlier opportunity: if the user had flagged the `toolName` fallback or the SDK-type question during the plan review (before TDD started), the initial implementation would have been correct from the start.
75
- However, this is a marginal improvement — the plan review was clean and the friction was minor.
76
-
77
- ### Changes made
78
-
79
- 1. `.pi/skills/code-design/SKILL.md` — Added two rules to "Pi SDK boundaries": verify SDK exports before redeclaring types locally; prefer minimal structural supertypes over index-signature types for parameters accepting SDK content.
80
- 2. `.pi/skills/testing/SKILL.md` — Added TDD planning rule: verify SDK exports when extracting locally-declared types that shadow SDK types.
@@ -1,62 +0,0 @@
1
- ---
2
- issue: 180
3
- issue_title: "perf(pi-subagents): reorder append-mode system prompt to enable KV cache reuse"
4
- ---
5
-
6
- # Retro: #180 — Reorder append-mode system prompt for KV cache reuse
7
-
8
- ## Stage: Planning (2026-05-24T20:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Produced a plan to reorder the append-mode system prompt in `buildAgentPrompt()` so the shared inherited content (~8k tokens) comes before the varying `<active_agent>` tag and env block, enabling LLM KV cache prefix reuse across subagent invocations.
13
-
14
- ### Observations
15
-
16
- - Confirmed pi-permission-system's `ACTIVE_AGENT_TAG_REGEX.exec()` is position-independent — no changes needed in that package despite the `pkg:pi-permission-system` label on the issue.
17
- - Only two tests assert positional ordering in append mode (`startsWith` and `tagIdx === 0`); all other prompt tests use `toContain()` and are unaffected.
18
- - Replace mode is a separate code path and is not touched.
19
- - The TDD cycle is minimal: one red step (update two positional assertions), one green step (reorder the return statement + update JSDoc).
20
-
21
- ## Stage: Implementation — TDD (2026-05-24T20:15:00Z)
22
-
23
- ### Session summary
24
-
25
- Completed both TDD cycles in `buildAgentPrompt()` in `src/session/prompts.ts`.
26
- Two positional assertions in `test/session/prompts.test.ts` were updated to expect the new ordering (red), then the append-mode return statement was reordered and the JSDoc updated (green).
27
- Test count unchanged at 805 across 50 files.
28
-
29
- ### Observations
30
-
31
- - The JSDoc bullet for append mode also described the old ordering ("env header + parent system prompt + ...") and was corrected as part of the green step.
32
- - The `<active_agent>` tag is followed by a `\n\n`, so when it moves after `<sub_agent_context>`, a `\n\n` separator between the bridge and the tag was needed to maintain clean section boundaries.
33
- - No deviations from the plan; both steps were exactly as described.
34
-
35
- ## Stage: Final Retrospective (2026-05-24T21:00:00Z)
36
-
37
- ### Session summary
38
-
39
- Issue #180 went from external community observation through release (`pi-subagents-v6.18.3`) in a single continuous session.
40
- The plan predicted exactly two TDD steps; both executed without deviation or rework.
41
-
42
- ### Observations
43
-
44
- #### What went well
45
-
46
- - End-to-end lifecycle in one session: external comment → issue → plan → TDD → ship → release.
47
- No corrections, no scope drift, no rework across any stage.
48
- - The plan's test impact analysis was accurate — only two positional assertions needed updating; all `toContain()` tests passed untouched.
49
- - Confirming pi-permission-system's `ACTIVE_AGENT_TAG_REGEX.exec()` is position-independent during planning eliminated the second `pkg:*` label's scope entirely, keeping the change to a single file.
50
-
51
- #### What caused friction (agent side)
52
-
53
- - `wrong-abstraction` — Launched an Explore agent (75.9s, 18 tool uses) to map the prompt assembly flow when the `package-pi-subagents` skill already listed the file layout and `prompts.ts` is 107 lines.
54
- Direct `read` + `grep` achieved the same confirmation in ~3 seconds during the planning phase.
55
- Impact: added ~75 seconds of latency but no rework.
56
- - `missing-context` — The plan listed "Update the JSDoc comment" but missed that the mode-description bullet ("env header + parent system prompt + ...") also encoded the old ordering.
57
- Caught during the green step and fixed in the same commit.
58
- Impact: added friction but no rework.
59
-
60
- #### What caused friction (user side)
61
-
62
- - Nothing notable — the user's prompts were well-scoped and the issue description was unambiguous.
@@ -1,73 +0,0 @@
1
- ---
2
- issue: 185
3
- issue_title: "pi-subagents: Remove persistent agent memory feature"
4
- ---
5
-
6
- # Retro: #185 — pi-subagents: Remove persistent agent memory feature
7
-
8
- ## Stage: Planning (2026-05-24T20:46:56Z)
9
-
10
- ### Session summary
11
-
12
- Traced all memory-related code across 9 source files, 5 test files, and the architecture doc.
13
- Produced a 5-step TDD plan: extract shared utilities (`isSymlink`, `isUnsafeName`, `safeReadFile`) to `safe-fs.ts`, then remove memory consumers (session assembly, config, UI), then delete the module, then update docs.
14
-
15
- ### Observations
16
-
17
- - The three utility functions in `memory.ts` are the only complication — `skill-loader.ts` imports them independently of memory.
18
- Extracting to `src/session/safe-fs.ts` keeps them co-located with their sole remaining consumer.
19
- - The removal is consumers-first, declaration-last: session-config and prompts lose their memory logic before `MemoryScope` is removed from `types.ts`, avoiding intermediate type errors.
20
- - No ambiguous design choices — the issue scope section is precise about what to remove and what to extract.
21
- - Memory field in custom agent frontmatter will silently become a no-op (ignored by the YAML parser) — no user-facing error, just loss of the feature.
22
- - The `AssemblerIO` interface shrinks from 4 fields to 2 after removal, which is a welcome simplification.
23
-
24
- ## Stage: Implementation — TDD (2026-05-24T22:41:23Z)
25
-
26
- ### Session summary
27
-
28
- All 5 TDD steps completed across 5 commits.
29
- Test count went from 901 (54 files) to 848 (53 files) — a net reduction of 53 tests and 1 file, reflecting the deletion of the `memory.test.ts` file with its memory-specific tests and the removal of memory-related tests from `session-config.test.ts`, `prompts.test.ts`, `agent-types.test.ts`, and `custom-agents.test.ts`.
30
- New file `safe-fs.test.ts` was created with 13 tests for the extracted utilities.
31
-
32
- ### Observations
33
-
34
- - Step 1 had a subtle bug: after re-exporting `isUnsafeName` from `safe-fs` in `memory.ts`, the function was not imported into the `memory.ts` module scope itself, so `resolveMemoryDir` got a `ReferenceError` at runtime.
35
- Fix was trivial: add `isUnsafeName` to the import alongside `isSymlink` and `safeReadFile`.
36
- - Step 3 introduced a type error in `memory.ts` (still alive at that point): `MemoryScope` was imported from `#src/types` which no longer exported it.
37
- Fix: inline the literal union `"user" | "project" | "local"` directly in `memory.ts` as a local type, so it compiles cleanly until deletion in step 4.
38
- - The `SKILL.md` for `package-pi-subagents` also listed `memory.ts` in the session domain table — updated alongside `architecture.md` in the docs commit.
39
- - No deviations from the plan other than the two minor bugs above (both self-corrected within the same TDD step).
40
-
41
- ## Stage: Final Retrospective (2026-05-24T22:47:55Z)
42
-
43
- ### Session summary
44
-
45
- Shipped issue #185 as `pi-subagents-v7.0.0`.
46
- CI passed, issue closed, release-please PR #190 merged.
47
- Three sessions total: planning, TDD (5 steps / 5 commits), shipping.
48
-
49
- ### Observations
50
-
51
- #### What went well
52
-
53
- - The issue's "Scope" section was precise enough that the planning session required no `ask_user` and the Explore agent's trace matched the final commit diff exactly.
54
- - Consumers-first, declaration-last ordering kept each commit independently compilable (after the two self-corrected fixes).
55
- - The `SKILL.md` domain table update was caught naturally during the docs step even though the plan didn't list it.
56
-
57
- #### What caused friction (agent side)
58
-
59
- - `missing-context` — In TDD step 1, `memory.ts` was updated to re-export `isUnsafeName` from `safe-fs`, but the function was not imported into `memory.ts`'s own scope.
60
- `resolveMemoryDir` threw a `ReferenceError` at runtime.
61
- Impact: one extra test-run cycle (~5 seconds) and a trivial one-line fix; no rework commit.
62
- - `missing-context` — In TDD step 3, removing `MemoryScope` from `types.ts` broke `memory.ts` (scheduled for deletion in step 4).
63
- The plan said "consumers-first" but didn't account for the doomed module itself being a consumer of the type.
64
- Impact: one extra `pnpm run check` cycle and a local type inline; no rework commit.
65
- Both share the same root cause: incremental deletion plans must account for doomed files' own imports at each intermediate step.
66
-
67
- #### What caused friction (user side)
68
-
69
- - None observed — all three sessions ran without user corrections or redirections.
70
-
71
- ### Changes made
72
-
73
- 1. Added a TDD planning rule to `.pi/skills/testing/SKILL.md` about accounting for doomed modules' own imports during multi-step deletion.