gsd-pi 2.81.0 → 2.82.0-dev.ed17d078d

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 (503) hide show
  1. package/README.md +60 -30
  2. package/dist/resources/.managed-resources-content-hash +1 -1
  3. package/dist/resources/extensions/browser-tools/tools/screenshot.js +1 -0
  4. package/dist/resources/extensions/browser-tools/tools/zoom.js +1 -0
  5. package/dist/resources/extensions/gsd/auto/loop.js +111 -8
  6. package/dist/resources/extensions/gsd/auto/orchestrator.js +113 -6
  7. package/dist/resources/extensions/gsd/auto/phases.js +199 -97
  8. package/dist/resources/extensions/gsd/auto/run-unit.js +66 -3
  9. package/dist/resources/extensions/gsd/auto/session.js +9 -0
  10. package/dist/resources/extensions/gsd/auto/verification-retry-policy.js +43 -0
  11. package/dist/resources/extensions/gsd/auto-dashboard.js +182 -178
  12. package/dist/resources/extensions/gsd/auto-dispatch.js +14 -11
  13. package/dist/resources/extensions/gsd/auto-post-unit.js +7 -1
  14. package/dist/resources/extensions/gsd/auto-prompts.js +11 -3
  15. package/dist/resources/extensions/gsd/auto-recovery.js +6 -181
  16. package/dist/resources/extensions/gsd/auto-runtime-state.js +5 -0
  17. package/dist/resources/extensions/gsd/auto-start.js +20 -23
  18. package/dist/resources/extensions/gsd/auto-unit-closeout.js +33 -5
  19. package/dist/resources/extensions/gsd/auto-verification.js +12 -6
  20. package/dist/resources/extensions/gsd/auto-worktree.js +8 -0
  21. package/dist/resources/extensions/gsd/auto.js +386 -106
  22. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +13 -6
  23. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +13 -2
  24. package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +4 -8
  25. package/dist/resources/extensions/gsd/bootstrap/system-context.js +55 -12
  26. package/dist/resources/extensions/gsd/commands/handlers/core.js +1 -1
  27. package/dist/resources/extensions/gsd/commands/handlers/notifications-handler.js +4 -10
  28. package/dist/resources/extensions/gsd/commands/handlers/parallel.js +9 -0
  29. package/dist/resources/extensions/gsd/commands-handlers.js +15 -2
  30. package/dist/resources/extensions/gsd/context-store.js +112 -0
  31. package/dist/resources/extensions/gsd/db-writer.js +150 -84
  32. package/dist/resources/extensions/gsd/docs/preferences-reference.md +1 -1
  33. package/dist/resources/extensions/gsd/doctor-git-checks.js +41 -6
  34. package/dist/resources/extensions/gsd/git-service.js +2 -1
  35. package/dist/resources/extensions/gsd/gsd-db.js +7 -23
  36. package/dist/resources/extensions/gsd/health-widget-core.js +1 -1
  37. package/dist/resources/extensions/gsd/health-widget.js +4 -10
  38. package/dist/resources/extensions/gsd/knowledge-backfill.js +144 -0
  39. package/dist/resources/extensions/gsd/knowledge-capture.js +136 -0
  40. package/dist/resources/extensions/gsd/knowledge-parser.js +154 -0
  41. package/dist/resources/extensions/gsd/knowledge-projection.js +210 -0
  42. package/dist/resources/extensions/gsd/markdown-renderer.js +6 -96
  43. package/dist/resources/extensions/gsd/md-importer.js +1 -1
  44. package/dist/resources/extensions/gsd/memory-backfill.js +73 -17
  45. package/dist/resources/extensions/gsd/memory-consolidation-scanner.js +222 -0
  46. package/dist/resources/extensions/gsd/migrate/command.js +5 -0
  47. package/dist/resources/extensions/gsd/migrate/preview.js +9 -0
  48. package/dist/resources/extensions/gsd/migrate/transformer.js +51 -4
  49. package/dist/resources/extensions/gsd/migrate/writer.js +11 -1
  50. package/dist/resources/extensions/gsd/native-git-bridge.js +14 -14
  51. package/dist/resources/extensions/gsd/notification-overlay.js +35 -40
  52. package/dist/resources/extensions/gsd/parallel-merge.js +53 -30
  53. package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +25 -33
  54. package/dist/resources/extensions/gsd/prompts/complete-slice.md +14 -12
  55. package/dist/resources/extensions/gsd/prompts/discuss-headless.md +20 -2
  56. package/dist/resources/extensions/gsd/prompts/discuss.md +20 -2
  57. package/dist/resources/extensions/gsd/prompts/system.md +2 -2
  58. package/dist/resources/extensions/gsd/provider-switch-observer.js +146 -0
  59. package/dist/resources/extensions/gsd/recovery-classification.js +15 -1
  60. package/dist/resources/extensions/gsd/session-lock.js +40 -0
  61. package/dist/resources/extensions/gsd/state-reconciliation/drift/completion.js +131 -0
  62. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +247 -0
  63. package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +50 -0
  64. package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +87 -0
  65. package/dist/resources/extensions/gsd/state-reconciliation/drift/sketch-flag.js +50 -0
  66. package/dist/resources/extensions/gsd/state-reconciliation/drift/stale-render.js +124 -0
  67. package/dist/resources/extensions/gsd/state-reconciliation/drift/stale-worker.js +32 -0
  68. package/dist/resources/extensions/gsd/state-reconciliation/errors.js +41 -0
  69. package/dist/resources/extensions/gsd/state-reconciliation/index.js +99 -0
  70. package/dist/resources/extensions/gsd/state-reconciliation/registry.js +24 -0
  71. package/dist/resources/extensions/gsd/state-reconciliation/spawn-gate.js +43 -0
  72. package/dist/resources/extensions/gsd/state-reconciliation/types.js +3 -0
  73. package/dist/resources/extensions/gsd/state-reconciliation.js +5 -26
  74. package/dist/resources/extensions/gsd/templates/knowledge.md +2 -2
  75. package/dist/resources/extensions/gsd/tui/render-kit.js +74 -0
  76. package/dist/resources/extensions/gsd/watch/header-renderer.js +92 -69
  77. package/dist/resources/extensions/gsd/watch/splash-palette.js +10 -0
  78. package/dist/resources/extensions/gsd/workflow-mcp.js +2 -2
  79. package/dist/resources/extensions/gsd/worktree-lifecycle.js +722 -316
  80. package/dist/resources/extensions/gsd/worktree-telemetry.js +3 -1
  81. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  82. package/dist/web/standalone/.next/BUILD_ID +1 -1
  83. package/dist/web/standalone/.next/app-path-routes-manifest.json +6 -6
  84. package/dist/web/standalone/.next/build-manifest.json +3 -3
  85. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  86. package/dist/web/standalone/.next/required-server-files.json +3 -3
  87. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  88. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  89. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  90. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  91. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  95. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  98. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  99. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  100. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  101. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  102. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  103. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  104. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  105. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  106. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  107. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  108. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  109. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  110. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  111. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  112. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  113. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  114. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  115. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  116. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  117. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  118. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  119. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  120. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  121. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  122. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  123. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  124. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  125. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  126. package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
  127. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  128. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  129. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  130. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  131. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  132. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  133. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  134. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  135. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  136. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  137. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  138. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  139. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  140. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  141. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  142. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  143. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  144. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  145. package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
  146. package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
  147. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  148. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  149. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  150. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  151. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  152. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  153. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  154. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  155. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  156. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  157. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  158. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  159. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  160. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  161. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  162. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  163. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  164. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  165. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  166. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  167. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  168. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  169. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  170. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  171. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  172. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  173. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  174. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  175. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
  176. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  177. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  178. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  179. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
  180. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  181. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +2 -2
  182. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  183. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  184. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  185. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  186. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  187. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  188. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  189. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  190. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  191. package/dist/web/standalone/.next/server/app/index.html +1 -1
  192. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  193. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  194. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  195. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  196. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  197. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  198. package/dist/web/standalone/.next/server/app/page.js +2 -2
  199. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  200. package/dist/web/standalone/.next/server/app-paths-manifest.json +6 -6
  201. package/dist/web/standalone/.next/server/chunks/63.js +3 -3
  202. package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
  203. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  204. package/dist/web/standalone/.next/server/middleware.js +2 -2
  205. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  206. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  207. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  208. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  209. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  210. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
  211. package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
  212. package/dist/web/standalone/.next/static/chunks/app/page-752f1e2ebdaa3e45.js +1 -0
  213. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
  214. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
  215. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  216. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  217. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  218. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  219. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  220. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  221. package/dist/web/standalone/server.js +1 -1
  222. package/dist/welcome-screen.d.ts +0 -7
  223. package/dist/welcome-screen.js +60 -69
  224. package/package.json +3 -2
  225. package/packages/daemon/package.json +2 -2
  226. package/packages/mcp-server/README.md +2 -0
  227. package/packages/mcp-server/package.json +2 -2
  228. package/packages/mcp-server/src/workflow-tools-parity.test.ts +244 -0
  229. package/packages/native/package.json +1 -1
  230. package/packages/pi-agent-core/package.json +1 -1
  231. package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
  232. package/packages/pi-ai/dist/index.d.ts +2 -2
  233. package/packages/pi-ai/dist/index.d.ts.map +1 -1
  234. package/packages/pi-ai/dist/index.js +1 -1
  235. package/packages/pi-ai/dist/index.js.map +1 -1
  236. package/packages/pi-ai/dist/providers/transform-messages.d.ts +11 -0
  237. package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
  238. package/packages/pi-ai/dist/providers/transform-messages.js +20 -0
  239. package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -1
  240. package/packages/pi-ai/package.json +1 -1
  241. package/packages/pi-ai/src/index.ts +7 -2
  242. package/packages/pi-ai/src/providers/transform-messages.ts +24 -0
  243. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  244. package/packages/pi-coding-agent/dist/core/system-prompt.js +4 -4
  245. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  246. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.d.ts +2 -0
  247. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.d.ts.map +1 -0
  248. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.js +47 -0
  249. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.js.map +1 -0
  250. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +76 -9
  251. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  252. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.d.ts +2 -0
  253. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.d.ts.map +1 -0
  254. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.js +40 -0
  255. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.js.map +1 -0
  256. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts +0 -1
  257. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -1
  258. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +30 -29
  259. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -1
  260. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +10 -3
  261. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +1 -1
  262. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  263. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +13 -13
  264. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
  265. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +1 -3
  266. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  267. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +58 -3
  268. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -1
  269. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +2 -2
  270. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -1
  271. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +12 -6
  272. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -1
  273. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  274. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +14 -41
  275. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  276. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +0 -1
  277. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  278. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +86 -82
  279. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  280. package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.d.ts +35 -0
  281. package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.d.ts.map +1 -0
  282. package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.js +152 -0
  283. package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.js.map +1 -0
  284. package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.d.ts +16 -0
  285. package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.d.ts.map +1 -0
  286. package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.js +73 -0
  287. package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.js.map +1 -0
  288. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +1 -1
  289. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  290. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +12 -8
  291. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -1
  292. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.d.ts +2 -0
  293. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.d.ts.map +1 -0
  294. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.js +17 -0
  295. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.js.map +1 -0
  296. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  297. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +105 -1
  298. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  299. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  300. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +27 -26
  301. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
  302. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +9 -6
  303. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -1
  304. package/packages/pi-coding-agent/dist/tests/system-prompt-file-safety.test.d.ts +2 -0
  305. package/packages/pi-coding-agent/dist/tests/system-prompt-file-safety.test.d.ts.map +1 -0
  306. package/packages/pi-coding-agent/dist/tests/system-prompt-file-safety.test.js +17 -0
  307. package/packages/pi-coding-agent/dist/tests/system-prompt-file-safety.test.js.map +1 -0
  308. package/packages/pi-coding-agent/package.json +1 -1
  309. package/packages/pi-coding-agent/src/core/system-prompt.ts +4 -4
  310. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/assistant-message-design.test.ts +56 -0
  311. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +113 -9
  312. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/user-message-design.test.ts +48 -0
  313. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +10 -3
  314. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +43 -42
  315. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +14 -14
  316. package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +64 -3
  317. package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +13 -7
  318. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +15 -42
  319. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +84 -104
  320. package/packages/pi-coding-agent/src/modes/interactive/components/transcript-design.ts +196 -0
  321. package/packages/pi-coding-agent/src/modes/interactive/components/tui-style-kit.ts +94 -0
  322. package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +14 -9
  323. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-highlight.test.ts +23 -0
  324. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +106 -1
  325. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +27 -26
  326. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +9 -6
  327. package/packages/pi-coding-agent/src/tests/system-prompt-file-safety.test.ts +22 -0
  328. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  329. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js +14 -1
  330. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js.map +1 -1
  331. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -1
  332. package/packages/pi-tui/dist/overlay-layout.js +9 -6
  333. package/packages/pi-tui/dist/overlay-layout.js.map +1 -1
  334. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  335. package/packages/pi-tui/dist/tui.js +5 -0
  336. package/packages/pi-tui/dist/tui.js.map +1 -1
  337. package/packages/pi-tui/package.json +1 -1
  338. package/packages/pi-tui/src/__tests__/overlay-layout.test.ts +20 -1
  339. package/packages/pi-tui/src/overlay-layout.ts +10 -7
  340. package/packages/pi-tui/src/tui.ts +6 -0
  341. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  342. package/packages/rpc-client/package.json +1 -1
  343. package/pkg/dist/modes/interactive/theme/theme-highlight.test.d.ts +2 -0
  344. package/pkg/dist/modes/interactive/theme/theme-highlight.test.d.ts.map +1 -0
  345. package/pkg/dist/modes/interactive/theme/theme-highlight.test.js +17 -0
  346. package/pkg/dist/modes/interactive/theme/theme-highlight.test.js.map +1 -0
  347. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  348. package/pkg/dist/modes/interactive/theme/theme.js +105 -1
  349. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  350. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  351. package/pkg/dist/modes/interactive/theme/themes.js +27 -26
  352. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
  353. package/pkg/package.json +1 -1
  354. package/src/resources/extensions/browser-tools/tools/screenshot.ts +1 -0
  355. package/src/resources/extensions/browser-tools/tools/zoom.ts +1 -0
  356. package/src/resources/extensions/gsd/auto/contracts.ts +46 -11
  357. package/src/resources/extensions/gsd/auto/loop-deps.ts +9 -5
  358. package/src/resources/extensions/gsd/auto/loop.ts +113 -9
  359. package/src/resources/extensions/gsd/auto/orchestrator.ts +118 -6
  360. package/src/resources/extensions/gsd/auto/phases.ts +158 -19
  361. package/src/resources/extensions/gsd/auto/run-unit.ts +69 -4
  362. package/src/resources/extensions/gsd/auto/session.ts +10 -0
  363. package/src/resources/extensions/gsd/auto/verification-retry-policy.ts +82 -0
  364. package/src/resources/extensions/gsd/auto-dashboard.ts +230 -183
  365. package/src/resources/extensions/gsd/auto-dispatch.ts +15 -1
  366. package/src/resources/extensions/gsd/auto-post-unit.ts +7 -1
  367. package/src/resources/extensions/gsd/auto-prompts.ts +11 -3
  368. package/src/resources/extensions/gsd/auto-recovery.ts +7 -209
  369. package/src/resources/extensions/gsd/auto-runtime-state.ts +5 -0
  370. package/src/resources/extensions/gsd/auto-start.ts +22 -22
  371. package/src/resources/extensions/gsd/auto-unit-closeout.ts +51 -0
  372. package/src/resources/extensions/gsd/auto-verification.ts +12 -6
  373. package/src/resources/extensions/gsd/auto-worktree.ts +8 -0
  374. package/src/resources/extensions/gsd/auto.ts +424 -106
  375. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +21 -6
  376. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +12 -2
  377. package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +5 -8
  378. package/src/resources/extensions/gsd/bootstrap/system-context.ts +58 -15
  379. package/src/resources/extensions/gsd/commands/handlers/core.ts +1 -1
  380. package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +4 -10
  381. package/src/resources/extensions/gsd/commands/handlers/parallel.ts +12 -0
  382. package/src/resources/extensions/gsd/commands-handlers.ts +19 -2
  383. package/src/resources/extensions/gsd/context-store.ts +120 -1
  384. package/src/resources/extensions/gsd/db-writer.ts +167 -84
  385. package/src/resources/extensions/gsd/docs/preferences-reference.md +1 -1
  386. package/src/resources/extensions/gsd/doctor-git-checks.ts +44 -6
  387. package/src/resources/extensions/gsd/doctor-types.ts +2 -0
  388. package/src/resources/extensions/gsd/git-service.ts +2 -0
  389. package/src/resources/extensions/gsd/gsd-db.ts +7 -23
  390. package/src/resources/extensions/gsd/health-widget-core.ts +1 -1
  391. package/src/resources/extensions/gsd/health-widget.ts +6 -10
  392. package/src/resources/extensions/gsd/journal.ts +2 -0
  393. package/src/resources/extensions/gsd/knowledge-backfill.ts +164 -0
  394. package/src/resources/extensions/gsd/knowledge-capture.ts +160 -0
  395. package/src/resources/extensions/gsd/knowledge-parser.ts +174 -0
  396. package/src/resources/extensions/gsd/knowledge-projection.ts +241 -0
  397. package/src/resources/extensions/gsd/markdown-renderer.ts +10 -96
  398. package/src/resources/extensions/gsd/md-importer.ts +1 -1
  399. package/src/resources/extensions/gsd/memory-backfill.ts +89 -17
  400. package/src/resources/extensions/gsd/memory-consolidation-scanner.ts +277 -0
  401. package/src/resources/extensions/gsd/migrate/command.ts +5 -0
  402. package/src/resources/extensions/gsd/migrate/preview.ts +10 -0
  403. package/src/resources/extensions/gsd/migrate/transformer.ts +58 -4
  404. package/src/resources/extensions/gsd/migrate/writer.ts +14 -1
  405. package/src/resources/extensions/gsd/native-git-bridge.ts +14 -13
  406. package/src/resources/extensions/gsd/notification-overlay.ts +50 -46
  407. package/src/resources/extensions/gsd/parallel-merge.ts +61 -34
  408. package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +33 -35
  409. package/src/resources/extensions/gsd/prompts/complete-slice.md +14 -12
  410. package/src/resources/extensions/gsd/prompts/discuss-headless.md +20 -2
  411. package/src/resources/extensions/gsd/prompts/discuss.md +20 -2
  412. package/src/resources/extensions/gsd/prompts/system.md +2 -2
  413. package/src/resources/extensions/gsd/provider-switch-observer.ts +185 -0
  414. package/src/resources/extensions/gsd/recovery-classification.ts +18 -1
  415. package/src/resources/extensions/gsd/session-lock.ts +41 -0
  416. package/src/resources/extensions/gsd/state-reconciliation/drift/completion.ts +172 -0
  417. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +337 -0
  418. package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +69 -0
  419. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +109 -0
  420. package/src/resources/extensions/gsd/state-reconciliation/drift/sketch-flag.ts +68 -0
  421. package/src/resources/extensions/gsd/state-reconciliation/drift/stale-render.ts +185 -0
  422. package/src/resources/extensions/gsd/state-reconciliation/drift/stale-worker.ts +46 -0
  423. package/src/resources/extensions/gsd/state-reconciliation/errors.ts +67 -0
  424. package/src/resources/extensions/gsd/state-reconciliation/index.ts +142 -0
  425. package/src/resources/extensions/gsd/state-reconciliation/registry.ts +27 -0
  426. package/src/resources/extensions/gsd/state-reconciliation/spawn-gate.ts +60 -0
  427. package/src/resources/extensions/gsd/state-reconciliation/types.ts +83 -0
  428. package/src/resources/extensions/gsd/state-reconciliation.ts +21 -53
  429. package/src/resources/extensions/gsd/templates/knowledge.md +2 -2
  430. package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +1 -1
  431. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +99 -0
  432. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +729 -176
  433. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +408 -4
  434. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +291 -4
  435. package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +20 -5
  436. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +18 -0
  437. package/src/resources/extensions/gsd/tests/auto-unit-closeout.test.ts +68 -0
  438. package/src/resources/extensions/gsd/tests/browser-tools-compatibility-declarations.test.ts +62 -0
  439. package/src/resources/extensions/gsd/tests/context-store-decisions-from-memories.test.ts +312 -0
  440. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +28 -1
  441. package/src/resources/extensions/gsd/tests/db-writer.test.ts +13 -8
  442. package/src/resources/extensions/gsd/tests/decisions-projection-from-memories.test.ts +453 -0
  443. package/src/resources/extensions/gsd/tests/decisions-stop-table-writes.test.ts +348 -0
  444. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +20 -2
  445. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +44 -0
  446. package/src/resources/extensions/gsd/tests/freeform-decisions.test.ts +8 -4
  447. package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +11 -7
  448. package/src/resources/extensions/gsd/tests/header-renderer.test.ts +40 -0
  449. package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +10 -0
  450. package/src/resources/extensions/gsd/tests/health-widget.test.ts +14 -4
  451. package/src/resources/extensions/gsd/tests/integration/doctor-git.test.ts +44 -0
  452. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +26 -0
  453. package/src/resources/extensions/gsd/tests/integration/integration-lifecycle.test.ts +13 -5
  454. package/src/resources/extensions/gsd/tests/integration/integration-proof.test.ts +1 -1
  455. package/src/resources/extensions/gsd/tests/integration/migrate-command.test.ts +48 -3
  456. package/src/resources/extensions/gsd/tests/integration/parallel-merge.test.ts +116 -24
  457. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +0 -1
  458. package/src/resources/extensions/gsd/tests/knowledge-backfill-projection.test.ts +323 -0
  459. package/src/resources/extensions/gsd/tests/knowledge-capture.test.ts +242 -0
  460. package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -2
  461. package/src/resources/extensions/gsd/tests/load-knowledge-block-rules-only.test.ts +209 -0
  462. package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +1 -1
  463. package/src/resources/extensions/gsd/tests/memory-consolidation-scanner.test.ts +316 -0
  464. package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +46 -11
  465. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +5 -1
  466. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +6 -1
  467. package/src/resources/extensions/gsd/tests/notification-overlay.test.ts +78 -41
  468. package/src/resources/extensions/gsd/tests/notifications-handler.test.ts +44 -0
  469. package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +12 -217
  470. package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +38 -6
  471. package/src/resources/extensions/gsd/tests/plan-milestone-sketch-render.test.ts +157 -0
  472. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +2 -2
  473. package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +1 -1
  474. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +32 -1
  475. package/src/resources/extensions/gsd/tests/provider-switch-observer.test.ts +252 -0
  476. package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +7 -3
  477. package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +6 -3
  478. package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +16 -4
  479. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +24 -0
  480. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +65 -58
  481. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +952 -0
  482. package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +4 -0
  483. package/src/resources/extensions/gsd/tests/tui-header-lifecycle.test.ts +121 -1
  484. package/src/resources/extensions/gsd/tests/tui-render-kit.test.ts +66 -0
  485. package/src/resources/extensions/gsd/tests/verification-retry-policy.test.ts +83 -0
  486. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +6 -0
  487. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +158 -58
  488. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +572 -118
  489. package/src/resources/extensions/gsd/tests/worktree-telemetry.test.ts +59 -2
  490. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +18 -0
  491. package/src/resources/extensions/gsd/tui/render-kit.ts +109 -0
  492. package/src/resources/extensions/gsd/watch/header-renderer.ts +121 -79
  493. package/src/resources/extensions/gsd/watch/splash-palette.ts +11 -0
  494. package/src/resources/extensions/gsd/workflow-logger.ts +4 -0
  495. package/src/resources/extensions/gsd/workflow-mcp.ts +2 -2
  496. package/src/resources/extensions/gsd/worktree-lifecycle.ts +1151 -524
  497. package/src/resources/extensions/gsd/worktree-telemetry.ts +7 -2
  498. package/dist/web/standalone/.next/static/chunks/app/page-200592a7f3baf579.js +0 -1
  499. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
  500. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
  501. package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +0 -1544
  502. /package/dist/web/standalone/.next/static/{drLMkgfHQ8lzS229_HWYR → YEvjuT-fsFfYQhDSWtueS}/_buildManifest.js +0 -0
  503. /package/dist/web/standalone/.next/static/{drLMkgfHQ8lzS229_HWYR → YEvjuT-fsFfYQhDSWtueS}/_ssgManifest.js +0 -0
@@ -1,13 +1,5 @@
1
- /**
2
- * Auto-mode Dispatch Table declarative phase → unit mapping.
3
- *
4
- * Each rule maps a GSD state to the unit type, unit ID, and prompt builder
5
- * that should be dispatched. Rules are evaluated in order; the first match wins.
6
- *
7
- * This replaces the 130-line if-else chain in dispatchNextUnit with a
8
- * data structure that is inspectable, testable per-rule, and extensible
9
- * without modifying orchestration code.
10
- */
1
+ // Project/App: GSD-2
2
+ // File Purpose: Declarative auto-mode dispatch rules and dispatch resolver.
11
3
  import { loadFile, extractUatType, loadActiveOverrides } from "./files.js";
12
4
  import { isDbAvailable, getMilestoneSlices, getPendingGates, markAllGatesOmitted, getMilestone, insertAssessment, transaction } from "./gsd-db.js";
13
5
  import { isClosedStatus } from "./status-guards.js";
@@ -1191,9 +1183,20 @@ export const DISPATCH_RULES = [
1191
1183
  },
1192
1184
  {
1193
1185
  name: "complete → stop",
1194
- match: async ({ state }) => {
1186
+ match: async ({ state, mid, midTitle, basePath }) => {
1195
1187
  if (state.phase !== "complete")
1196
1188
  return null;
1189
+ if (mid && isDbAvailable()) {
1190
+ const milestone = getMilestone(mid);
1191
+ if (milestone && !isClosedStatus(milestone.status)) {
1192
+ return {
1193
+ action: "dispatch",
1194
+ unitType: "complete-milestone",
1195
+ unitId: mid,
1196
+ prompt: await buildCompleteMilestonePrompt(mid, midTitle, basePath),
1197
+ };
1198
+ }
1199
+ }
1197
1200
  return {
1198
1201
  action: "stop",
1199
1202
  reason: "All milestones complete.",
@@ -55,6 +55,7 @@ import { detectAbandonMilestone } from "./abandon-detect.js";
55
55
  import { isDeterministicPolicyError } from "./auto-tool-tracking.js";
56
56
  import { clearProjectResearchInflightMarker, finalizeProjectResearchTimeout, } from "./project-research-policy.js";
57
57
  import { validateArtifact } from "./schemas/validate.js";
58
+ import { verificationRetryKey } from "./auto/verification-retry-policy.js";
58
59
  // ─── Path Comparison Helper ───────────────────────────────────────────────
59
60
  /** Compare two paths for physical identity, tolerating trailing slashes and symlinks. */
60
61
  function isSamePathLocal(a, b) {
@@ -865,6 +866,7 @@ export async function postUnitPreVerification(pctx, opts) {
865
866
  const outcome = finalizeProjectResearchTimeout(s.basePath, "Project research unit ended before all required dimensions produced durable files.");
866
867
  s.pendingVerificationRetry = null;
867
868
  s.verificationRetryCount.delete(retryKey);
869
+ s.verificationRetryFailureHashes.delete(retryKey);
868
870
  triggerArtifactVerified = verifyExpectedArtifact(s.currentUnit.type, s.currentUnit.id, s.basePath);
869
871
  if (triggerArtifactVerified) {
870
872
  invalidateAllCaches();
@@ -915,6 +917,7 @@ export async function postUnitPreVerification(pctx, opts) {
915
917
  s.lastToolInvocationError = null;
916
918
  s.pendingVerificationRetry = null;
917
919
  s.verificationRetryCount.delete(retryKey);
920
+ s.verificationRetryFailureHashes.delete(retryKey);
918
921
  writeBlockerPlaceholder(s.currentUnit.type, s.currentUnit.id, s.basePath, reason);
919
922
  ctx.ui.notify(`${s.currentUnit.type} ${s.currentUnit.id} — deterministic policy rejection, wrote blocker placeholder (no retries) (#4973)`, "warning");
920
923
  // Fall through to "continue" — do NOT enter the retry or db-unavailable paths.
@@ -943,6 +946,7 @@ export async function postUnitPreVerification(pctx, opts) {
943
946
  const failureDetails = describeArtifactVerificationFailure(s.currentUnit.type, s.currentUnit.id, s.basePath);
944
947
  if (attempt > MAX_ARTIFACT_VERIFICATION_RETRIES) {
945
948
  s.verificationRetryCount.delete(retryKey);
949
+ s.verificationRetryFailureHashes.delete(retryKey);
946
950
  debugLog("postUnit", { phase: "artifact-verify-exhausted", unitType: s.currentUnit.type, unitId: s.currentUnit.id, attempt });
947
951
  ctx.ui.notify(`${failureDetails} Pausing auto-mode after ${MAX_ARTIFACT_VERIFICATION_RETRIES} retries.`, "error");
948
952
  await pauseAuto(ctx, pi);
@@ -962,7 +966,9 @@ export async function postUnitPreVerification(pctx, opts) {
962
966
  // Verification succeeded — clear the retry counter so a future failure
963
967
  // of the same unit gets a full retry budget instead of the stale count.
964
968
  if (triggerArtifactVerified) {
965
- s.verificationRetryCount.delete(`${s.currentUnit.type}:${s.currentUnit.id}`);
969
+ const retryKey = verificationRetryKey(s.currentUnit.type, s.currentUnit.id);
970
+ s.verificationRetryCount.delete(retryKey);
971
+ s.verificationRetryFailureHashes.delete(retryKey);
966
972
  }
967
973
  }
968
974
  else {
@@ -728,12 +728,20 @@ export async function inlineDecisionsFromDb(base, milestoneId, scope, level) {
728
728
  try {
729
729
  const { isDbAvailable } = await import("./gsd-db.js");
730
730
  if (isDbAvailable()) {
731
- const { queryDecisions, formatDecisionsForPrompt } = await import("./context-store.js");
731
+ // ADR-013 Phase 6 cutover (Stage 1): read decisions from the `memories`
732
+ // table. Both `queryDecisions` (legacy) and `queryDecisionsFromMemories`
733
+ // return identical Decision[] for active rows once Phase 5 dual-write is
734
+ // caught up. Switching the read here lets the destructive Phase 6 step
735
+ // (#5755) retire the legacy `decisions` table without changing prompt
736
+ // contents. Projection regen (`DECISIONS.md`) still sources from the
737
+ // legacy table — that switch lands separately to handle superseded
738
+ // history cleanly.
739
+ const { queryDecisionsFromMemories, formatDecisionsForPrompt } = await import("./context-store.js");
732
740
  // First query: try with both milestoneId and scope (if scope provided)
733
- let decisions = queryDecisions({ milestoneId, scope });
741
+ let decisions = queryDecisionsFromMemories({ milestoneId, scope });
734
742
  // Cascade: if empty AND scope was provided, retry without scope
735
743
  if (decisions.length === 0 && scope) {
736
- decisions = queryDecisions({ milestoneId });
744
+ decisions = queryDecisionsFromMemories({ milestoneId });
737
745
  }
738
746
  if (decisions.length > 0) {
739
747
  // Use compact format for non-full levels to save ~35% tokens
@@ -14,13 +14,11 @@ import { clearParseCache } from "./files.js";
14
14
  import { parseRoadmap as parseLegacyRoadmap, parsePlan as parseLegacyPlan } from "./parsers-legacy.js";
15
15
  import { isDbAvailable, getTask, getSlice, getSliceTasks, getPendingGates, updateTaskStatus, updateSliceStatus, insertSlice, getMilestone, refreshOpenDatabaseFromDisk, getCompletedMilestoneTaskFileHints, getMilestoneCommitAttributionShas, recordMilestoneCommitAttribution } from "./gsd-db.js";
16
16
  import { isValidationTerminal } from "./state.js";
17
- import { getErrorMessage } from "./error-utils.js";
18
- import { logWarning, logError } from "./workflow-logger.js";
17
+ import { logWarning } from "./workflow-logger.js";
19
18
  import { readIntegrationBranch } from "./git-service.js";
20
19
  import { isClosedStatus } from "./status-guards.js";
21
- import { nativeConflictFiles, nativeCommit, nativeCheckoutTheirs, nativeAddPaths, nativeMergeAbort, nativeRebaseAbort, nativeResetHard, } from "./native-git-bridge.js";
22
20
  import { resolveSlicePath, resolveSliceFile, resolveTasksDir, resolveTaskFiles, relMilestoneFile, relSliceFile, buildSliceFileName, resolveMilestoneFile, clearPathCache, resolveGsdRootFile, } from "./paths.js";
23
- import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, } from "node:fs";
21
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
24
22
  import { execFileSync } from "node:child_process";
25
23
  import { dirname, join } from "node:path";
26
24
  import { resolveExpectedArtifactPath, diagnoseExpectedArtifact, } from "./auto-artifact-paths.js";
@@ -932,183 +930,10 @@ export function writeBlockerPlaceholder(unitType, unitId, base, reason) {
932
930
  return diagnoseExpectedArtifact(unitType, unitId, base);
933
931
  }
934
932
  // ─── Merge State Reconciliation ───────────────────────────────────────────────
935
- /**
936
- * Best-effort abort of a pending merge/squash and hard-reset to HEAD.
937
- * Handles both real merges (MERGE_HEAD) and squash merges (SQUASH_MSG).
938
- */
939
- function abortAndResetMerge(basePath, hasMergeHead, squashMsgPath) {
940
- if (hasMergeHead) {
941
- try {
942
- nativeMergeAbort(basePath);
943
- }
944
- catch (err) {
945
- /* best-effort */
946
- logWarning("recovery", `git merge-abort failed: ${err instanceof Error ? err.message : String(err)}`);
947
- }
948
- }
949
- else if (squashMsgPath) {
950
- try {
951
- unlinkSync(squashMsgPath);
952
- }
953
- catch (err) {
954
- /* best-effort */
955
- logWarning("recovery", `file unlink failed: ${err instanceof Error ? err.message : String(err)}`);
956
- }
957
- }
958
- try {
959
- nativeResetHard(basePath);
960
- }
961
- catch (err) {
962
- /* best-effort */
963
- logError("recovery", `git reset failed: ${err instanceof Error ? err.message : String(err)}`);
964
- }
965
- }
966
- /**
967
- * Detect and abort other in-progress git operations left behind by a SIGKILL'd
968
- * worker (rebase, cherry-pick, revert). Without this, a killed worker mid-rebase
969
- * leaves `.git/rebase-merge/` or `.git/CHERRY_PICK_HEAD` and the worktree is
970
- * wedged until the user manually runs the matching `--abort`.
971
- *
972
- * Called before merge-state reconciliation because these states block any
973
- * subsequent merge/commit operation. (Issue #4980 HIGH-7)
974
- */
975
- function reconcileOtherInProgressGitOps(basePath, ctx) {
976
- const gitDir = join(basePath, ".git");
977
- const states = [
978
- {
979
- label: "rebase",
980
- indicators: [join(gitDir, "rebase-merge"), join(gitDir, "rebase-apply")],
981
- abort: () => nativeRebaseAbort(basePath),
982
- },
983
- {
984
- label: "cherry-pick",
985
- indicators: [join(gitDir, "CHERRY_PICK_HEAD")],
986
- abort: () => {
987
- // No native helper; fall back to git CLI.
988
- try {
989
- execFileSync("git", ["cherry-pick", "--abort"], {
990
- cwd: basePath, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8",
991
- });
992
- }
993
- catch (err) {
994
- logWarning("recovery", `cherry-pick --abort failed: ${getErrorMessage(err)}`);
995
- }
996
- },
997
- },
998
- {
999
- label: "revert",
1000
- indicators: [join(gitDir, "REVERT_HEAD")],
1001
- abort: () => {
1002
- try {
1003
- execFileSync("git", ["revert", "--abort"], {
1004
- cwd: basePath, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8",
1005
- });
1006
- }
1007
- catch (err) {
1008
- logWarning("recovery", `revert --abort failed: ${getErrorMessage(err)}`);
1009
- }
1010
- },
1011
- },
1012
- ];
1013
- let reconciled = false;
1014
- for (const s of states) {
1015
- const present = s.indicators.some((p) => existsSync(p));
1016
- if (!present)
1017
- continue;
1018
- try {
1019
- s.abort();
1020
- ctx.ui.notify(`Detected leftover ${s.label} state from prior session — aborted.`, "warning");
1021
- reconciled = true;
1022
- }
1023
- catch (err) {
1024
- logError("recovery", `${s.label} abort failed: ${getErrorMessage(err)}`);
1025
- ctx.ui.notify(`Detected leftover ${s.label} state but auto-abort failed. ` +
1026
- `Run \`git ${s.label} --abort\` manually before retrying.`, "error");
1027
- return "blocked";
1028
- }
1029
- }
1030
- return reconciled ? "reconciled" : "clean";
1031
- }
1032
- /**
1033
- * Detect leftover merge state from a prior session and reconcile it.
1034
- * If MERGE_HEAD or SQUASH_MSG exists, check whether conflicts are resolved.
1035
- * If resolved: finalize the commit. If only .gsd conflicts remain: auto-resolve.
1036
- * If code conflicts remain: fail safe without modifying the worktree.
1037
- */
1038
- export function reconcileMergeState(basePath, ctx) {
1039
- // First, abort any rebase/cherry-pick/revert left over from a SIGKILL'd
1040
- // worker. Doing this before the merge-state check unblocks any merge that
1041
- // would otherwise refuse with "you have unfinished operation". (HIGH-7)
1042
- const otherOpsResult = reconcileOtherInProgressGitOps(basePath, ctx);
1043
- if (otherOpsResult === "blocked")
1044
- return "blocked";
1045
- const mergeHeadPath = join(basePath, ".git", "MERGE_HEAD");
1046
- const squashMsgPath = join(basePath, ".git", "SQUASH_MSG");
1047
- const hasMergeHead = existsSync(mergeHeadPath);
1048
- const hasSquashMsg = existsSync(squashMsgPath);
1049
- if (!hasMergeHead && !hasSquashMsg) {
1050
- // If we cleaned up another op type, return "reconciled" so the caller
1051
- // re-derives state from a known-good baseline.
1052
- return otherOpsResult === "reconciled" ? "reconciled" : "clean";
1053
- }
1054
- const conflictedFiles = nativeConflictFiles(basePath);
1055
- if (conflictedFiles.length === 0) {
1056
- // All conflicts resolved — finalize the merge/squash commit
1057
- try {
1058
- const commitSha = nativeCommit(basePath, "chore(gsd): reconcile merge state");
1059
- if (commitSha) {
1060
- const mode = hasMergeHead ? "merge" : "squash commit";
1061
- ctx.ui.notify(`Finalized leftover ${mode} from prior session.`, "info");
1062
- }
1063
- else {
1064
- ctx.ui.notify("No new commit needed for leftover merge/squash state — already committed.", "info");
1065
- }
1066
- }
1067
- catch (err) {
1068
- const errorMessage = getErrorMessage(err);
1069
- ctx.ui.notify(`Failed to finalize leftover merge/squash commit: ${errorMessage}`, "error");
1070
- return "blocked";
1071
- }
1072
- }
1073
- else {
1074
- // Still conflicted — try auto-resolving .gsd/ state file conflicts (#530)
1075
- const gsdConflicts = conflictedFiles.filter((f) => f.startsWith(".gsd/"));
1076
- const codeConflicts = conflictedFiles.filter((f) => !f.startsWith(".gsd/"));
1077
- if (gsdConflicts.length > 0 && codeConflicts.length === 0) {
1078
- // All conflicts are in .gsd/ state files — auto-resolve by accepting theirs
1079
- let resolved = true;
1080
- try {
1081
- nativeCheckoutTheirs(basePath, gsdConflicts);
1082
- nativeAddPaths(basePath, gsdConflicts);
1083
- }
1084
- catch (e) {
1085
- logError("recovery", `auto-resolve .gsd/ conflicts failed: ${e.message}`);
1086
- resolved = false;
1087
- }
1088
- if (resolved) {
1089
- try {
1090
- nativeCommit(basePath, "chore: auto-resolve .gsd/ state file conflicts");
1091
- ctx.ui.notify(`Auto-resolved ${gsdConflicts.length} .gsd/ state file conflict(s) from prior merge.`, "info");
1092
- }
1093
- catch (e) {
1094
- logError("recovery", `auto-commit .gsd/ conflict resolution failed: ${e.message}`);
1095
- resolved = false;
1096
- }
1097
- }
1098
- if (!resolved) {
1099
- abortAndResetMerge(basePath, hasMergeHead, squashMsgPath);
1100
- ctx.ui.notify("Detected leftover merge state — auto-resolve failed, cleaned up. Re-deriving state.", "warning");
1101
- }
1102
- }
1103
- else {
1104
- // Code conflicts present — fail safe and preserve any manual resolution
1105
- // work instead of discarding it with merge --abort/reset --hard.
1106
- ctx.ui.notify("Detected leftover merge state with unresolved code conflicts. Auto-mode will pause without modifying the worktree so manual conflict resolution is preserved.", "error");
1107
- return "blocked";
1108
- }
1109
- }
1110
- return "reconciled";
1111
- }
933
+ // Body relocated to state-reconciliation/drift/merge-state.ts (ADR-017 #5701).
934
+ // Re-exported here for backward compatibility with existing call sites:
935
+ // auto.ts, auto/loop-deps.ts, tests/integration/auto-recovery.test.ts.
936
+ export { reconcileMergeState, } from "./state-reconciliation/drift/merge-state.js";
1112
937
  // ─── Loop Remediation ─────────────────────────────────────────────────────────
1113
938
  /**
1114
939
  * Build concrete, manual remediation steps for a loop-detected unit failure.
@@ -33,3 +33,8 @@ export function recordToolInvocationError(toolName, errorMsg) {
33
33
  autoSession.lastToolInvocationError = `${toolName}: ${errorMsg}`;
34
34
  }
35
35
  }
36
+ export function clearToolInvocationError() {
37
+ if (!autoSession.active)
38
+ return;
39
+ autoSession.lastToolInvocationError = null;
40
+ }
@@ -679,30 +679,22 @@ export async function bootstrapAutoSession(s, ctx, pi, base, verboseMode, reques
679
679
  {
680
680
  const orphan = findUnmergedCompletedMilestone(base, getIsolationMode(base));
681
681
  if (orphan && orphan !== state.activeMilestone?.id) {
682
- const priorBasePath = s.basePath;
683
- const priorOriginalBasePath = s.originalBasePath;
684
- s.originalBasePath = base;
685
- s.basePath = getAutoWorktreePath(base, orphan) ?? base;
686
- const result = _mergeOrphanCompletedMilestone(buildLifecycle(), orphan, ctx.ui);
682
+ // ADR-016 phase 2 / B4 (#5622): the swap-run-revert protocol for
683
+ // the orphan-merge dance is owned by `adoptOrphanWorktree`. The
684
+ // verb snapshots prior `s.basePath` / `s.originalBasePath`, swaps
685
+ // into the orphan worktree, runs the merge callback under the
686
+ // swap, and reverts (or holds the swap) based on the result.
687
+ // Callers can no longer forget the revert step on failure — the
688
+ // pattern that originally motivated this verb.
689
+ const lifecycle = buildLifecycle();
690
+ const result = lifecycle.adoptOrphanWorktree(orphan, base, () => _mergeOrphanCompletedMilestone(lifecycle, orphan, ctx.ui));
687
691
  if (!result.merged) {
688
- s.basePath = base;
689
- s.originalBasePath = base;
690
- try {
691
- process.chdir(base);
692
- }
693
- catch (err) {
694
- logWarning("bootstrap", `could not restore cwd after orphan merge failure: ${err instanceof Error ? err.message : String(err)}`);
695
- }
692
+ // Verb already restored basePath/originalBasePath to `base` and
693
+ // chdir'd there. Return early.
696
694
  return releaseLockAndReturn();
697
695
  }
698
- if (!s.active) {
699
- s.basePath = priorBasePath || base;
700
- s.originalBasePath = priorOriginalBasePath || base;
701
- }
702
- if (result.merged) {
703
- invalidateAllCaches();
704
- state = await deriveState(base);
705
- }
696
+ invalidateAllCaches();
697
+ state = await deriveState(base);
706
698
  }
707
699
  }
708
700
  const effectivePrefs = loadEffectiveGSDPreferences(base)?.preferences;
@@ -792,7 +784,10 @@ export async function bootstrapAutoSession(s, ctx, pi, base, verboseMode, reques
792
784
  s.stepMode = requestedStepMode;
793
785
  s.verbose = verboseMode;
794
786
  s.cmdCtx = ctx;
795
- s.basePath = base;
787
+ // ADR-016 phase 2 / B2 (#5620): single owner of bootstrap basePath
788
+ // mutation. Sets s.basePath = base and s.originalBasePath = base
789
+ // (originalBasePath is empty on a fresh bootstrap).
790
+ buildLifecycle().adoptSessionRoot(base);
796
791
  s.unitDispatchCount.clear();
797
792
  s.unitRecoveryCount.clear();
798
793
  s.lastBudgetAlertLevel = 0;
@@ -842,7 +837,9 @@ export async function bootstrapAutoSession(s, ctx, pi, base, verboseMode, reques
842
837
  }
843
838
  }
844
839
  // ── Auto-worktree setup ──
845
- s.originalBasePath = base;
840
+ // s.originalBasePath was set to `base` by `adoptSessionRoot(base)` above
841
+ // (ADR-016 phase 2 / B2, #5620). The redundant assignment that used to
842
+ // live here is gone.
846
843
  const isUnderGsdWorktrees = (p) => {
847
844
  // Direct layout: /.gsd/worktrees/
848
845
  const marker = `${pathSep}.gsd${pathSep}worktrees${pathSep}`;
@@ -1,12 +1,40 @@
1
- /**
2
- * Unit closeout helper consolidates the repeated pattern of
3
- * snapshotting metrics + saving activity log + extracting memories
4
- * that appears 6+ times in auto.ts.
5
- */
1
+ // Project/App: GSD-2
2
+ // File Purpose: Auto-mode unit closeout metrics, activity capture, and ghost-run detection.
6
3
  import { snapshotUnitMetrics } from "./metrics.js";
7
4
  import { saveActivityLog } from "./activity-log.js";
8
5
  import { logWarning } from "./workflow-logger.js";
9
6
  import { writeTurnGitTransaction } from "./uok/gitops.js";
7
+ export const GHOST_COMPLETION_MAX_ELAPSED_MS = 500;
8
+ export function snapshotUnitActivity(ctx, startedAt, now = Date.now()) {
9
+ let toolCalls = 0;
10
+ let assistantMessages = 0;
11
+ const entries = ctx.sessionManager.getEntries() ?? [];
12
+ for (const entry of entries) {
13
+ if (entry.type !== "message")
14
+ continue;
15
+ const msg = entry.message;
16
+ if (!msg || msg.role !== "assistant")
17
+ continue;
18
+ assistantMessages++;
19
+ if (!Array.isArray(msg.content))
20
+ continue;
21
+ for (const block of msg.content) {
22
+ if (block?.type === "toolCall")
23
+ toolCalls++;
24
+ }
25
+ }
26
+ return {
27
+ elapsedMs: Math.max(0, now - startedAt),
28
+ toolCalls,
29
+ assistantMessages,
30
+ };
31
+ }
32
+ export function isSuspiciousGhostCompletion(ctx, startedAt, maxElapsedMs = GHOST_COMPLETION_MAX_ELAPSED_MS) {
33
+ const activity = snapshotUnitActivity(ctx, startedAt);
34
+ return (activity.elapsedMs < maxElapsedMs &&
35
+ activity.toolCalls === 0 &&
36
+ activity.assistantMessages === 0);
37
+ }
10
38
  /**
11
39
  * Snapshot metrics, save activity log, and fire-and-forget memory extraction
12
40
  * for a completed unit. Returns the activity log file path (if any).
@@ -17,6 +17,7 @@ import { runPostExecutionChecks } from "./post-execution-checks.js";
17
17
  import { join } from "node:path";
18
18
  import { resolveUokFlags } from "./uok/flags.js";
19
19
  import { UokGateRunner } from "./uok/gate-runner.js";
20
+ import { verificationRetryKey } from "./auto/verification-retry-policy.js";
20
21
  function isInfraVerificationFailure(stderr) {
21
22
  return /\b(ENOENT|ENOTFOUND|ETIMEDOUT|ECONNRESET|EAI_AGAIN|spawn\s+\S+\s+ENOENT|command not found)\b/i.test(stderr);
22
23
  }
@@ -238,7 +239,8 @@ export async function runPostUnitVerification(vctx, pauseAuto) {
238
239
  }
239
240
  }
240
241
  // Write verification evidence JSON
241
- const attempt = s.verificationRetryCount.get(s.currentUnit.id) ?? 0;
242
+ const retryKey = verificationRetryKey(s.currentUnit.type, s.currentUnit.id);
243
+ const attempt = s.verificationRetryCount.get(retryKey) ?? 0;
242
244
  if (mid && sid && tid) {
243
245
  try {
244
246
  const sDir = resolveSlicePath(s.basePath, mid, sid);
@@ -261,7 +263,8 @@ export async function runPostUnitVerification(vctx, pauseAuto) {
261
263
  (result.discoverySource === "package-json" ||
262
264
  result.checks.some((check) => isInfraVerificationFailure(check.stderr)));
263
265
  if (advisoryFailure) {
264
- s.verificationRetryCount.delete(s.currentUnit.id);
266
+ s.verificationRetryCount.delete(retryKey);
267
+ s.verificationRetryFailureHashes.delete(retryKey);
265
268
  s.pendingVerificationRetry = null;
266
269
  ctx.ui.notify(result.discoverySource === "package-json"
267
270
  ? "Verification failed in auto-discovered package.json checks — treating as advisory."
@@ -422,14 +425,16 @@ export async function runPostUnitVerification(vctx, pauseAuto) {
422
425
  }
423
426
  // ── Auto-fix retry logic ──
424
427
  if (result.passed) {
425
- s.verificationRetryCount.delete(s.currentUnit.id);
428
+ s.verificationRetryCount.delete(retryKey);
429
+ s.verificationRetryFailureHashes.delete(retryKey);
426
430
  s.pendingVerificationRetry = null;
427
431
  return "continue";
428
432
  }
429
433
  else if (postExecBlockingFailure) {
430
434
  // Post-execution failures are cross-task consistency issues — retrying the same task won't fix them.
431
435
  // Skip retry and pause immediately for human review.
432
- s.verificationRetryCount.delete(s.currentUnit.id);
436
+ s.verificationRetryCount.delete(retryKey);
437
+ s.verificationRetryFailureHashes.delete(retryKey);
433
438
  s.pendingVerificationRetry = null;
434
439
  ctx.ui.notify(`Post-execution checks failed — cross-task consistency issue detected, pausing for human review`, "error");
435
440
  await pauseAuto(ctx, pi);
@@ -437,7 +442,7 @@ export async function runPostUnitVerification(vctx, pauseAuto) {
437
442
  }
438
443
  else if (autoFixEnabled && attempt + 1 <= maxRetries) {
439
444
  const nextAttempt = attempt + 1;
440
- s.verificationRetryCount.set(s.currentUnit.id, nextAttempt);
445
+ s.verificationRetryCount.set(retryKey, nextAttempt);
441
446
  s.pendingVerificationRetry = {
442
447
  unitId: s.currentUnit.id,
443
448
  failureContext: formatFailureContext(result),
@@ -455,7 +460,8 @@ export async function runPostUnitVerification(vctx, pauseAuto) {
455
460
  }
456
461
  else {
457
462
  // Gate failed, retries exhausted
458
- s.verificationRetryCount.delete(s.currentUnit.id);
463
+ s.verificationRetryCount.delete(retryKey);
464
+ s.verificationRetryFailureHashes.delete(retryKey);
459
465
  s.pendingVerificationRetry = null;
460
466
  const exhaustedFails = result.checks
461
467
  .filter((c) => c.exitCode !== 0)
@@ -1271,6 +1271,14 @@ function autoCommitDirtyState(cwd) {
1271
1271
  * On merge conflict: throws MergeConflictError.
1272
1272
  * On "nothing to commit" after squash: safe only if milestone work is already
1273
1273
  * on the integration branch. Throws if unanchored code changes would be lost.
1274
+ *
1275
+ * @internal **Do not call directly.** This is the inner squash-merge primitive
1276
+ * for the Worktree Lifecycle Module (ADR-016 phase 2 / A3, issue #5619).
1277
+ * Production callers must go through `WorktreeLifecycle.mergeMilestoneStandalone`
1278
+ * or `WorktreeLifecycle.exitMilestone({ merge: true })`. The export keyword
1279
+ * is preserved only so `auto.ts:buildWorktreeLifecycleDeps()` can wire this
1280
+ * function through the Module's deps seam — that is the construction of the
1281
+ * seam, not a bypass.
1274
1282
  */
1275
1283
  export function mergeMilestoneToMain(originalBasePath_, milestoneId, roadmapContent) {
1276
1284
  const worktreeCwd = process.cwd();