@gotgenes/pi-subagents 18.0.1 → 18.0.3

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 (268) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/docs/architecture/architecture.md +165 -203
  3. package/docs/architecture/history/phase-19-implement-ui-decisions.md +282 -0
  4. package/package.json +6 -7
  5. package/src/config/default-agents.ts +3 -0
  6. package/src/lifecycle/subagent.ts +25 -14
  7. package/src/observation/notification.ts +23 -10
  8. package/src/observation/subagent-events-observer.ts +1 -3
  9. package/src/runtime.ts +2 -1
  10. package/src/service/service-adapter.ts +20 -17
  11. package/src/session/model-resolver.ts +31 -30
  12. package/src/tools/agent-tool.ts +17 -13
  13. package/src/tools/get-result-report.ts +60 -0
  14. package/src/tools/get-result-tool.ts +25 -40
  15. package/src/tools/helpers.ts +21 -5
  16. package/src/tools/spawn-config.ts +5 -5
  17. package/src/tools/steer-tool.ts +37 -27
  18. package/src/types.ts +4 -1
  19. package/src/ui/session-navigator.ts +0 -2
  20. package/.prettierignore +0 -5
  21. package/AGENTS.md +0 -7
  22. package/docs/plans/0048-implement-subagents-api.md +0 -304
  23. package/docs/plans/0049-remove-group-join-output-file-rpc.md +0 -180
  24. package/docs/plans/0051-update-adr-0001-hard-fork.md +0 -77
  25. package/docs/plans/0052-remove-scheduled-subagents.md +0 -133
  26. package/docs/plans/0053-extract-model-resolution-from-execute.md +0 -181
  27. package/docs/plans/0054-decompose-index-into-modules.md +0 -302
  28. package/docs/plans/0057-structured-debug-logging.md +0 -154
  29. package/docs/plans/0061-session-format-transcript.md +0 -284
  30. package/docs/plans/0066-replace-as-any-with-sdk-types.md +0 -215
  31. package/docs/plans/0069-create-subagent-runtime.md +0 -345
  32. package/docs/plans/0070-extract-event-handlers.md +0 -306
  33. package/docs/plans/0071-extract-session-config-assembler.md +0 -362
  34. package/docs/plans/0072-inject-agent-manager-collaborators.md +0 -329
  35. package/docs/plans/0076-inject-cwd-into-agent-manager.md +0 -102
  36. package/docs/plans/0077-inject-project-agents-dir.md +0 -115
  37. package/docs/plans/0080-consolidate-agent-config-lookup.md +0 -247
  38. package/docs/plans/0084-extract-git-worktree-manager.md +0 -142
  39. package/docs/plans/0087-evolve-subagent-runtime-methods.md +0 -240
  40. package/docs/plans/0098-extract-agent-record-state-machine.md +0 -435
  41. package/docs/plans/0099-replace-ctx-with-parent-snapshot.md +0 -488
  42. package/docs/plans/0100-replace-callback-threading-with-session-subscription.md +0 -454
  43. package/docs/plans/0102-consolidate-test-record-factory.md +0 -176
  44. package/docs/plans/0108-extract-agent-type-registry.md +0 -322
  45. package/docs/plans/0109-extract-settings-manager.md +0 -276
  46. package/docs/plans/0110-agent-activity-tracker.md +0 -297
  47. package/docs/plans/0111-split-agent-record-lifecycle.md +0 -582
  48. package/docs/plans/0112-replace-agent-manager-callbacks.md +0 -241
  49. package/docs/plans/0113-disambiguate-spawn-options.md +0 -155
  50. package/docs/plans/0114-narrow-agent-tool-menu-deps.md +0 -279
  51. package/docs/plans/0115-decompose-agent-tool.md +0 -337
  52. package/docs/plans/0116-type-housekeeping.md +0 -351
  53. package/docs/plans/0118-settings-manager-apply-methods.md +0 -271
  54. package/docs/plans/0123-remove-vi-fn-cast-smell.md +0 -179
  55. package/docs/plans/0131-consolidate-shared-test-fixtures.md +0 -207
  56. package/docs/plans/0132-inject-io-into-session-config.md +0 -219
  57. package/docs/plans/0133-inject-sdk-boundary-into-agent-runner.md +0 -373
  58. package/docs/plans/0134-reduce-as-any-casts.md +0 -366
  59. package/docs/plans/0135-extract-display-helpers.md +0 -182
  60. package/docs/plans/0136-decompose-agent-menu.md +0 -300
  61. package/docs/plans/0144-consolidate-observation-model.md +0 -263
  62. package/docs/plans/0145-decompose-execute-push-ctx-to-boundary.md +0 -290
  63. package/docs/plans/0146-narrow-ui-context.md +0 -319
  64. package/docs/plans/0147-inject-wrap-text-into-conversation-viewer.md +0 -166
  65. package/docs/plans/0148-split-agent-widget-rendering.md +0 -255
  66. package/docs/plans/0152-add-prompt-snippet.md +0 -91
  67. package/docs/plans/0164-reorganize-into-domain-directories.md +0 -409
  68. package/docs/plans/0165-decompose-resolved-spawn-config.md +0 -157
  69. package/docs/plans/0166-extract-parent-session-info.md +0 -231
  70. package/docs/plans/0167-narrow-runner-io.md +0 -150
  71. package/docs/plans/0168-extract-tool-filter-config.md +0 -173
  72. package/docs/plans/0169-extract-run-context-from-run-options.md +0 -194
  73. package/docs/plans/0170-reduce-build-content-lines-complexity.md +0 -225
  74. package/docs/plans/0171-reduce-render-result-complexity.md +0 -200
  75. package/docs/plans/0172-extract-turn-formatting.md +0 -206
  76. package/docs/plans/0180-reorder-append-prompt-for-kv-cache.md +0 -100
  77. package/docs/plans/0185-remove-persistent-agent-memory.md +0 -161
  78. package/docs/plans/0188-replace-any-casts-with-sdk-types.md +0 -162
  79. package/docs/plans/0192-define-session-context-interface.md +0 -107
  80. package/docs/plans/0193-runtime-owns-context-queries.md +0 -245
  81. package/docs/plans/0194-align-tool-interfaces-for-structural-typing.md +0 -139
  82. package/docs/plans/0195-convert-tool-factories-to-classes.md +0 -264
  83. package/docs/plans/0196-convert-runner-menu-to-classes.md +0 -268
  84. package/docs/plans/0205-decompose-render-widget-lines.md +0 -140
  85. package/docs/plans/0206-decompose-show-agent-detail.md +0 -211
  86. package/docs/plans/0207-decompose-agent-widget-update.md +0 -242
  87. package/docs/plans/0208-extract-shared-test-fixtures.md +0 -298
  88. package/docs/plans/0214-convert-remaining-closure-factories-to-classes.md +0 -261
  89. package/docs/plans/0215-decompose-build-parent-context.md +0 -166
  90. package/docs/plans/0216-decompose-start-agent.md +0 -255
  91. package/docs/plans/0217-extract-overwrite-guard.md +0 -176
  92. package/docs/plans/0218-push-sdk-boundary-in-settings.md +0 -172
  93. package/docs/plans/0219-reduce-test-duplication-top-3-clone-families.md +0 -162
  94. package/docs/plans/0227-evolve-agent-record-into-agent.md +0 -322
  95. package/docs/plans/0228-async-start-agent-dissolve-run-handle.md +0 -288
  96. package/docs/plans/0229-agent-born-complete.md +0 -564
  97. package/docs/plans/0230-extract-concurrency-queue.md +0 -265
  98. package/docs/plans/0231-push-exec-registry-to-runner.md +0 -245
  99. package/docs/plans/0232-agent-resume-internal-observer-lifecycle.md +0 -180
  100. package/docs/plans/0237-remove-disallowed-tools.md +0 -180
  101. package/docs/plans/0238-remove-extensions-filtering.md +0 -191
  102. package/docs/plans/0239-collapse-filter-active-tools.md +0 -217
  103. package/docs/plans/0242-rename-agent-tool-to-subagent.md +0 -165
  104. package/docs/plans/0256-extract-worktree-isolation.md +0 -256
  105. package/docs/plans/0257-extract-child-session-factory.md +0 -285
  106. package/docs/plans/0262-add-workspace-provider-seam.md +0 -264
  107. package/docs/plans/0264-remove-extension-lifecycle-control.md +0 -277
  108. package/docs/plans/0265-born-complete-subagent-session.md +0 -333
  109. package/docs/plans/0270-type-consumable-public-surface.md +0 -204
  110. package/docs/plans/0272-export-workspace-collaborator-types.md +0 -147
  111. package/docs/plans/0277-encapsulate-agent-session.md +0 -304
  112. package/docs/plans/0280-rename-agent-to-subagent.md +0 -197
  113. package/docs/plans/0360-custom-agents-default-append.md +0 -132
  114. package/docs/plans/0373-extract-subagent-state.md +0 -250
  115. package/docs/plans/0374-encapsulate-subagent-start-notification.md +0 -268
  116. package/docs/plans/0375-extract-run-listener-workspace-bracket.md +0 -300
  117. package/docs/plans/0376-extract-manager-observer.md +0 -232
  118. package/docs/plans/0377-split-widget-delegation-from-runtime.md +0 -254
  119. package/docs/plans/0378-consolidate-lifecycle-test-fixtures.md +0 -243
  120. package/docs/plans/0379-consolidate-ui-tools-test-fixtures.md +0 -335
  121. package/docs/plans/0380-extract-layered-settings-loader.md +0 -223
  122. package/docs/plans/0381-replace-concurrency-queue-with-limiter.md +0 -267
  123. package/docs/plans/0400-include-parent-prompt-in-replace-mode.md +0 -199
  124. package/docs/plans/0403-abort-subagents-on-interrupt.md +0 -180
  125. package/docs/plans/0412-unify-session-mock-builders.md +0 -146
  126. package/docs/plans/0420-fold-run-metrics-live-activity-onto-record.md +0 -228
  127. package/docs/plans/0421-migrate-activity-readers-to-record-getters.md +0 -309
  128. package/docs/plans/0422-delete-activity-tracker-ui-observer.md +0 -204
  129. package/docs/plans/0423-widget-self-drive-from-lifecycle.md +0 -264
  130. package/docs/plans/0424-drop-widget-dep-from-subagent-tool.md +0 -166
  131. package/docs/plans/0425-reconcile-subagent-events-contract.md +0 -144
  132. package/docs/plans/0426-consolidate-residual-test-clone-families.md +0 -235
  133. package/docs/plans/0427-reconsider-ui-direction.md +0 -212
  134. package/docs/plans/0441-remove-agent-definition-management-subtree.md +0 -180
  135. package/docs/plans/0442-dissolve-agents-conversation-viewer.md +0 -195
  136. package/docs/plans/0443-consolidate-remaining-test-clone-families.md +0 -268
  137. package/docs/plans/0444-shrink-widget-to-background-agents.md +0 -156
  138. package/docs/plans/0445-native-session-navigation.md +0 -365
  139. package/docs/plans/0446-spike-session-navigation-entry-criteria.md +0 -171
  140. package/docs/plans/0447-extract-subagents-settings-command.md +0 -220
  141. package/docs/plans/0448-block-disabled-agent-spawn.md +0 -207
  142. package/docs/plans/0462-navigation-renderer-tui-components.md +0 -338
  143. package/docs/plans/0463-file-snapshot-source-evicted-agents.md +0 -306
  144. package/docs/plans/0470-refresh-readme-command-surface.md +0 -159
  145. package/docs/retro/0048-implement-subagents-api.md +0 -44
  146. package/docs/retro/0049-remove-group-join-output-file-rpc.md +0 -49
  147. package/docs/retro/0051-update-adr-0001-hard-fork.md +0 -39
  148. package/docs/retro/0053-extract-model-resolution-from-execute.md +0 -40
  149. package/docs/retro/0054-decompose-index-into-modules.md +0 -53
  150. package/docs/retro/0057-structured-debug-logging.md +0 -77
  151. package/docs/retro/0061-session-format-transcript.md +0 -41
  152. package/docs/retro/0066-replace-as-any-with-sdk-types.md +0 -44
  153. package/docs/retro/0069-create-subagent-runtime.md +0 -43
  154. package/docs/retro/0070-extract-event-handlers.md +0 -49
  155. package/docs/retro/0071-extract-session-config-assembler.md +0 -60
  156. package/docs/retro/0072-inject-agent-manager-collaborators.md +0 -46
  157. package/docs/retro/0076-inject-cwd-into-agent-manager.md +0 -35
  158. package/docs/retro/0077-inject-project-agents-dir.md +0 -33
  159. package/docs/retro/0080-consolidate-agent-config-lookup.md +0 -35
  160. package/docs/retro/0084-extract-git-worktree-manager.md +0 -37
  161. package/docs/retro/0087-evolve-subagent-runtime-methods.md +0 -42
  162. package/docs/retro/0098-extract-agent-record-state-machine.md +0 -46
  163. package/docs/retro/0099-replace-ctx-with-parent-snapshot.md +0 -37
  164. package/docs/retro/0100-replace-callback-threading-with-session-subscription.md +0 -36
  165. package/docs/retro/0102-consolidate-test-record-factory.md +0 -30
  166. package/docs/retro/0108-extract-agent-type-registry.md +0 -41
  167. package/docs/retro/0109-extract-settings-manager.md +0 -55
  168. package/docs/retro/0110-agent-activity-tracker.md +0 -44
  169. package/docs/retro/0111-split-agent-record-lifecycle.md +0 -61
  170. package/docs/retro/0112-replace-agent-manager-callbacks.md +0 -35
  171. package/docs/retro/0113-disambiguate-spawn-options.md +0 -29
  172. package/docs/retro/0114-narrow-agent-tool-menu-deps.md +0 -38
  173. package/docs/retro/0115-decompose-agent-tool.md +0 -51
  174. package/docs/retro/0116-type-housekeeping.md +0 -42
  175. package/docs/retro/0118-settings-manager-apply-methods.md +0 -40
  176. package/docs/retro/0123-remove-vi-fn-cast-smell.md +0 -49
  177. package/docs/retro/0131-consolidate-shared-test-fixtures.md +0 -46
  178. package/docs/retro/0132-inject-io-into-session-config.md +0 -33
  179. package/docs/retro/0133-inject-sdk-boundary-into-agent-runner.md +0 -45
  180. package/docs/retro/0134-reduce-as-any-casts.md +0 -56
  181. package/docs/retro/0135-extract-display-helpers.md +0 -38
  182. package/docs/retro/0136-decompose-agent-menu.md +0 -43
  183. package/docs/retro/0144-consolidate-observation-model.md +0 -39
  184. package/docs/retro/0145-decompose-execute-push-ctx-to-boundary.md +0 -56
  185. package/docs/retro/0146-narrow-ui-context.md +0 -70
  186. package/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md +0 -90
  187. package/docs/retro/0148-split-agent-widget-rendering.md +0 -39
  188. package/docs/retro/0152-add-prompt-snippet.md +0 -34
  189. package/docs/retro/0164-reorganize-into-domain-directories.md +0 -82
  190. package/docs/retro/0165-decompose-resolved-spawn-config.md +0 -78
  191. package/docs/retro/0166-extract-parent-session-info.md +0 -66
  192. package/docs/retro/0167-narrow-runner-io.md +0 -63
  193. package/docs/retro/0168-extract-tool-filter-config.md +0 -76
  194. package/docs/retro/0169-extract-run-context-from-run-options.md +0 -68
  195. package/docs/retro/0170-reduce-build-content-lines-complexity.md +0 -72
  196. package/docs/retro/0171-reduce-render-result-complexity.md +0 -77
  197. package/docs/retro/0172-extract-turn-formatting.md +0 -80
  198. package/docs/retro/0180-reorder-append-prompt-for-kv-cache.md +0 -62
  199. package/docs/retro/0185-remove-persistent-agent-memory.md +0 -73
  200. package/docs/retro/0188-replace-any-casts-with-sdk-types.md +0 -69
  201. package/docs/retro/0192-define-session-context-interface.md +0 -59
  202. package/docs/retro/0193-runtime-owns-context-queries.md +0 -75
  203. package/docs/retro/0194-align-tool-interfaces-for-structural-typing.md +0 -62
  204. package/docs/retro/0195-convert-tool-factories-to-classes.md +0 -84
  205. package/docs/retro/0196-convert-runner-menu-to-classes.md +0 -73
  206. package/docs/retro/0205-decompose-render-widget-lines.md +0 -64
  207. package/docs/retro/0206-decompose-show-agent-detail.md +0 -67
  208. package/docs/retro/0207-decompose-agent-widget-update.md +0 -92
  209. package/docs/retro/0208-extract-shared-test-fixtures.md +0 -102
  210. package/docs/retro/0214-convert-remaining-closure-factories-to-classes.md +0 -66
  211. package/docs/retro/0215-decompose-build-parent-context.md +0 -61
  212. package/docs/retro/0216-decompose-start-agent.md +0 -80
  213. package/docs/retro/0217-extract-overwrite-guard.md +0 -63
  214. package/docs/retro/0218-push-sdk-boundary-in-settings.md +0 -72
  215. package/docs/retro/0219-reduce-test-duplication-top-3-clone-families.md +0 -64
  216. package/docs/retro/0227-evolve-agent-record-into-agent.md +0 -80
  217. package/docs/retro/0228-async-start-agent-dissolve-run-handle.md +0 -80
  218. package/docs/retro/0229-agent-born-complete.md +0 -89
  219. package/docs/retro/0230-extract-concurrency-queue.md +0 -38
  220. package/docs/retro/0231-push-exec-registry-to-runner.md +0 -71
  221. package/docs/retro/0232-agent-resume-internal-observer-lifecycle.md +0 -109
  222. package/docs/retro/0237-remove-disallowed-tools.md +0 -78
  223. package/docs/retro/0238-remove-extensions-filtering.md +0 -72
  224. package/docs/retro/0239-collapse-filter-active-tools.md +0 -70
  225. package/docs/retro/0242-rename-agent-tool-to-subagent.md +0 -82
  226. package/docs/retro/0256-extract-worktree-isolation.md +0 -89
  227. package/docs/retro/0257-extract-child-session-factory.md +0 -33
  228. package/docs/retro/0262-add-workspace-provider-seam.md +0 -89
  229. package/docs/retro/0264-remove-extension-lifecycle-control.md +0 -91
  230. package/docs/retro/0265-born-complete-subagent-session.md +0 -97
  231. package/docs/retro/0270-type-consumable-public-surface.md +0 -108
  232. package/docs/retro/0272-export-workspace-collaborator-types.md +0 -38
  233. package/docs/retro/0277-encapsulate-agent-session.md +0 -80
  234. package/docs/retro/0280-rename-agent-to-subagent.md +0 -96
  235. package/docs/retro/0360-custom-agents-default-append.md +0 -81
  236. package/docs/retro/0373-extract-subagent-state.md +0 -94
  237. package/docs/retro/0374-encapsulate-subagent-start-notification.md +0 -171
  238. package/docs/retro/0375-extract-run-listener-workspace-bracket.md +0 -104
  239. package/docs/retro/0376-extract-manager-observer.md +0 -81
  240. package/docs/retro/0377-split-widget-delegation-from-runtime.md +0 -105
  241. package/docs/retro/0378-consolidate-lifecycle-test-fixtures.md +0 -100
  242. package/docs/retro/0379-consolidate-ui-tools-test-fixtures.md +0 -52
  243. package/docs/retro/0380-extract-layered-settings-loader.md +0 -97
  244. package/docs/retro/0381-replace-concurrency-queue-with-limiter.md +0 -95
  245. package/docs/retro/0400-include-parent-prompt-in-replace-mode.md +0 -84
  246. package/docs/retro/0403-abort-subagents-on-interrupt.md +0 -90
  247. package/docs/retro/0412-unify-session-mock-builders.md +0 -80
  248. package/docs/retro/0420-fold-run-metrics-live-activity-onto-record.md +0 -90
  249. package/docs/retro/0421-migrate-activity-readers-to-record-getters.md +0 -105
  250. package/docs/retro/0422-delete-activity-tracker-ui-observer.md +0 -97
  251. package/docs/retro/0423-widget-self-drive-from-lifecycle.md +0 -112
  252. package/docs/retro/0424-drop-widget-dep-from-subagent-tool.md +0 -89
  253. package/docs/retro/0425-reconcile-subagent-events-contract.md +0 -101
  254. package/docs/retro/0426-consolidate-residual-test-clone-families.md +0 -100
  255. package/docs/retro/0427-reconsider-ui-direction.md +0 -102
  256. package/docs/retro/0441-remove-agent-definition-management-subtree.md +0 -97
  257. package/docs/retro/0442-dissolve-agents-conversation-viewer.md +0 -108
  258. package/docs/retro/0443-consolidate-remaining-test-clone-families.md +0 -28
  259. package/docs/retro/0444-shrink-widget-to-background-agents.md +0 -81
  260. package/docs/retro/0445-native-session-navigation.md +0 -122
  261. package/docs/retro/0446-spike-session-navigation-entry-criteria.md +0 -99
  262. package/docs/retro/0447-extract-subagents-settings-command.md +0 -91
  263. package/docs/retro/0448-block-disabled-agent-spawn.md +0 -75
  264. package/docs/retro/0462-navigation-renderer-tui-components.md +0 -105
  265. package/docs/retro/0463-file-snapshot-source-evicted-agents.md +0 -103
  266. package/docs/retro/0470-refresh-readme-command-surface.md +0 -40
  267. package/src/observation/notification-state.ts +0 -27
  268. package/vitest.config.ts +0 -14
@@ -1,34 +0,0 @@
1
- ---
2
- issue: 152
3
- issue_title: "Add promptSnippet to pi-subagents tools"
4
- ---
5
-
6
- # Retro: #152 — Add `promptSnippet` to pi-subagents tools
7
-
8
- ## Final Retrospective (2026-05-22)
9
-
10
- ### Session summary
11
-
12
- Added `promptSnippet` to the `Agent`, `get_subagent_result`, and `steer_subagent` tool registrations in pi-subagents, matching the convention used by pi-github-tools and pi-colgrep.
13
- The full plan→TDD→ship pipeline completed in one session with zero rework.
14
- Released as `pi-subagents-v6.14.0`.
15
-
16
- ### Observations
17
-
18
- #### What went well
19
-
20
- - Clean single-cycle execution: the issue was unambiguous, the plan correctly scoped it as one TDD step, and the implementation matched the plan exactly.
21
- - Cross-package convention check (grepping sibling packages for `promptSnippet` usage) confirmed the `"tool_name: One-liner."` format before writing the plan, avoiding any wording rework.
22
-
23
- #### What caused friction (agent side)
24
-
25
- No friction points identified.
26
- The issue was a straightforward property addition with no design decisions, no interface changes, and no downstream breakage.
27
-
28
- #### What caused friction (user side)
29
-
30
- No friction points identified.
31
-
32
- ### Changes made
33
-
34
- 1. Created `packages/pi-subagents/docs/retro/0152-add-prompt-snippet.md` (this file).
@@ -1,82 +0,0 @@
1
- ---
2
- issue: 164
3
- issue_title: "refactor(pi-subagents): reorganize source into domain directories"
4
- ---
5
-
6
- # Retro: #164 — refactor(pi-subagents): reorganize source into domain directories
7
-
8
- ## Stage: Planning (2026-05-23T00:00:00Z)
9
-
10
- ### Session summary
11
-
12
- Read issue #164, confirmed #157 (import normalization) was a prerequisite and had been completed.
13
- Explored the full `src/` and `test/` structure, mapped every relative import in the 26 files to be moved, and produced a four-commit plan that moves files domain-by-domain in dependency order.
14
-
15
- ### Observations
16
-
17
- - Issue #157 removed `.js` suffixes and introduced `#src/*` aliases in `test/` files.
18
- This makes the reorganization cleaner: test imports are flat `#src/agent-manager` → `#src/lifecycle/agent-manager` with no depth variation.
19
- - `lifecycle/` and `observation/` have a circular dependency (`agent-manager` ↔ `record-observer`), so they must be moved in a single commit (Step 3).
20
- All other domains can be committed independently.
21
- - `vitest.config.ts` uses `"test/**/*.test.ts"` — test files in new subdirectories are
22
- auto-discovered without config changes.
23
- - Three UI test files (`conversation-viewer.test.ts`, `display.test.ts`,
24
- `widget-renderer.test.ts`) are misplaced at `test/` root; left out of scope for this issue.
25
- - No `default-agents.test.ts`, `context.test.ts`, or `execution-state.test.ts` exist —
26
- those src modules have no dedicated test files.
27
- - The import tables in the plan enumerate every path change; `pnpm run check` will catch
28
- any missed update before each commit.
29
-
30
- ## Stage: Implementation — TDD (2026-05-23T16:55:00Z)
31
-
32
- ### Session summary
33
-
34
- Executed all four plan steps (config, session, lifecycle+observation, service) plus a fifth unplanned step converting all `src/` internal imports to `#src/` aliases.
35
- All 50 test files and 805 tests pass throughout.
36
- Updated `docs/architecture/architecture.md` to reflect the completed restructuring.
37
-
38
- ### Observations
39
-
40
- - The plan's consumer tables were mostly complete but missed a few files: `src/ui/widget-renderer.ts` and `src/session-config.ts` (still at root during step 1) both imported `agent-types`; `src/service-adapter.ts` imported `model-resolver`; `test/parent-snapshot.test.ts` had a `vi.mock("#src/context")` path.
41
- All caught immediately by `pnpm run check` or a failing test.
42
- - `src/service-adapter.ts` and `src/service.ts` (still at root during step 3) imported `parent-snapshot` and `usage` which moved in that step, so they had to be fixed as part of step 3's commit rather than step 4's.
43
- - The `#src/` alias conversion (fifth commit) was added after the user correctly observed that `src/` files should use the same alias style as `test/` files.
44
- This eliminates all `../` relative cross-directory imports from `src/`.
45
- Future file moves in `src/` now only require updating the `#src/domain/name` string — no relative depth arithmetic.
46
- - Biome auto-fixed 14 files (import sorting / trailing whitespace) during the `#src/` conversion step; committed via `git add -A` after the pre-commit hook run.
47
-
48
- ## Stage: Final Retrospective (2026-05-23T17:10:00Z)
49
-
50
- ### Session summary
51
-
52
- Shipped #164 (6 commits, `pi-subagents-v6.17.2`), filed #174 (ESLint for type-aware rules + import path enforcement), and reviewed the full issue lifecycle across planning, implementation, and shipping sessions.
53
-
54
- ### Observations
55
-
56
- #### What went well
57
-
58
- - The user's mid-implementation redirect to use `#src/` aliases in `src/` files was the highest-impact intervention across the entire issue.
59
- It eliminated the `../` depth-arithmetic problem, simplified the final commit to a one-liner `sed` command across 40 files, and directly motivated #174.
60
- - `pnpm run check` (`tsc --noEmit`) caught every missed consumer immediately — no broken commit ever landed.
61
- - The four-step dependency ordering (config → session → lifecycle+observation → service) kept every commit green despite the circular dependency between `lifecycle` and `observation`.
62
-
63
- #### What caused friction (agent side)
64
-
65
- - `wrong-abstraction` — Used ~60 individual `Edit` tool calls across steps 1–4 for what was a mechanical find-and-replace.
66
- The fifth commit proved `sed` handles bulk import rewrites across 40 files in a single command.
67
- Impact: hundreds of unnecessary tool calls and significant token waste across four commits.
68
- - `missing-context` — The plan's consumer tables missed 4 files (`src/ui/widget-renderer.ts`, `src/session-config.ts`, `src/service-adapter.ts`, `test/parent-snapshot.test.ts` `vi.mock` path).
69
- The plan manually traced imports instead of using `grep` to enumerate all consumers of each moving module.
70
- Impact: mid-step rework in steps 1, 2, and 3 to fix un-updated imports caught by `tsc`.
71
- - `missing-context` — Did not recognize that `src/` files should use `#src/` aliases (same as `test/` files) even though #157 set up the aliases for exactly this purpose.
72
- Impact: all four domain-move commits used relative `../` imports, requiring a fifth unplanned commit to convert them.
73
- User-caught.
74
- - `wrong-abstraction` — The agent lacks access to LSP-level refactoring tools ("Move to file", "Rename symbol") that a human developer would use for this kind of reorganization.
75
- A human with an LSP would have completed the entire issue in minutes with zero missed consumers.
76
- This is a fundamental capability gap — the agent compensated with low-level text manipulation, which is error-prone and token-expensive.
77
-
78
- #### What caused friction (user side)
79
-
80
- - The `#src/` alias convention was established in #157 but the user didn't flag it during the planning session.
81
- Had this been raised during planning, all four domain-move commits would have used `#src/` from the start.
82
- The user did catch it during implementation, which was still early enough to save the final result.
@@ -1,78 +0,0 @@
1
- ---
2
- issue: 165
3
- issue_title: "refactor(pi-subagents): decompose ResolvedSpawnConfig (15 fields)"
4
- ---
5
-
6
- # Retro: #165 — decompose ResolvedSpawnConfig (15 fields)
7
-
8
- ## Stage: Planning (2026-05-24T13:41:41Z)
9
-
10
- ### Session summary
11
-
12
- Produced a 5-step TDD plan to decompose the 15-field `ResolvedSpawnConfig` into three nested sub-interfaces (`SpawnIdentity`, `SpawnExecution`, `SpawnPresentation`).
13
- Also improved skill descriptions for `colgrep` and `markdown-conventions` to signal decision-relevant content rather than tool reference material.
14
-
15
- ### Observations
16
-
17
- - The proposed decomposition in the issue aligns well with actual field usage patterns — no adjustments needed.
18
- - `modelName` and `agentTags` are never accessed by external consumers; they're intermediate computation exposed on the return type.
19
- Keeping them on `SpawnPresentation` is harmless and aids debuggability.
20
- - Step 1 (interface change + return restructure) will break type checking for all consumers simultaneously.
21
- The plan addresses this by landing steps 1–4 in rapid succession on the same branch.
22
- - Both test files have `makeConfig()` factories that must be updated in lock-step with their respective source files.
23
- - Issue #164 (directory reorganization) is closed, so import paths are already in their final `#src/<domain>/` form.
24
-
25
- ## Stage: Implementation — TDD (2026-05-24T14:32:58Z)
26
-
27
- ### Session summary
28
-
29
- Completed all 4 TDD cycles plus full-suite verification in one session.
30
- The decomposition touched 7 files (4 source, 3 test) and kept the test count flat at 805 — no new tests needed for a pure structural refactor.
31
-
32
- ### Observations
33
-
34
- - The `Partial<ResolvedSpawnConfig>` spread pattern in `makeConfig` factories doesn't deep-merge into nested sub-objects.
35
- Two tests (`foreground-runner.test.ts` and `background-spawner.test.ts`) used flat field overrides (`{ fellBack: true }`, `{ description: "my task" }`) that silently stopped working after nesting.
36
- Fixed by writing out the full nested sub-object at the override call site.
37
- Future factories for nested config types should either deep-merge or avoid the `Partial<T>` spread pattern — see the `testing` skill's warning about this.
38
- - Step 1 breaking all consumers simultaneously was handled smoothly by completing all steps before pushing, as planned.
39
- No transitional alias was needed.
40
- - The `background-spawner.test.ts` description-override test was the only unexpected friction point — the flat spread issue wasn't caught by the plan.
41
-
42
- ## Stage: Final Retrospective (2026-05-24T15:00:14Z)
43
-
44
- ### Session summary
45
-
46
- Shipped issue #165 (CI green, released as `pi-subagents-v6.18.1`) and ran the final retrospective.
47
- The most impactful outcome across all three sessions was the skill description improvements (commit `51f52ef`), which addressed a recurring `instruction-violation` pattern.
48
-
49
- ### Observations
50
-
51
- #### What went well
52
-
53
- - The user's probing question ("This is consistent, though.
54
- Why?") turned a simple skill-loading skip into a generalizable improvement to three skill descriptions and two prompt instructions.
55
- This is a good example of the user investing a redirecting question instead of a correction.
56
- - TDD execution was clean — 4 cycles, no rework, no type errors at the end.
57
- The plan's risk mitigation ("land steps 1–4 on the same branch") worked as intended.
58
- - Ship stage had zero friction: push, CI, close, release-please merge, tag — all first-try.
59
-
60
- #### What caused friction (agent side)
61
-
62
- - `instruction-violation` — Skipped loading the `colgrep` skill during planning despite explicit instructions.
63
- Root cause: skill descriptions that read like tool reference manuals get deprioritized because the agent perceives them as redundant with the tool schema already in context.
64
- Impact: no rework on the plan itself, but triggered a productive detour to improve skill descriptions.
65
- User-caught.
66
- - `missing-context` — The plan didn't anticipate that `Partial<ResolvedSpawnConfig>` spread in test factories would silently break after nesting.
67
- The `testing` skill already warns about spread-related pitfalls, but not this specific variant (flat keys ignored by top-level spread on a nested structure).
68
- Impact: one test failure during step 4 that required a verbose inline fix (writing out the full `execution` sub-object).
69
- Self-identified during implementation.
70
-
71
- #### What caused friction (user side)
72
-
73
- - None observed.
74
- The user's intervention on the `colgrep` skill was well-timed and produced a higher-value outcome than skipping it would have.
75
-
76
- ### Changes made
77
-
78
- 1. Added a TDD planning rule to `.pi/skills/testing/SKILL.md` warning about `Partial<T>` spread not deep-merging into nested interfaces after a flat-to-nested refactor.
@@ -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."