gsd-pi 2.80.0-dev.42bd34838 → 2.80.0-dev.488219eb6

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 (509) hide show
  1. package/dist/claude-cli-check.d.ts +30 -0
  2. package/dist/claude-cli-check.js +18 -7
  3. package/dist/cli.js +0 -19
  4. package/dist/headless-query.d.ts +10 -0
  5. package/dist/headless-query.js +6 -4
  6. package/dist/loader-entrypoint.d.ts +8 -0
  7. package/dist/loader-entrypoint.js +27 -0
  8. package/dist/loader.js +2 -11
  9. package/dist/mcp-server.d.ts +1 -0
  10. package/dist/mcp-server.js +6 -3
  11. package/dist/resources/.managed-resources-content-hash +1 -1
  12. package/dist/resources/extensions/claude-code-cli/readiness.js +18 -7
  13. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +29 -0
  14. package/dist/resources/extensions/github-sync/sync.js +4 -1
  15. package/dist/resources/extensions/gsd/auto/loop.js +71 -8
  16. package/dist/resources/extensions/gsd/auto/phases.js +179 -99
  17. package/dist/resources/extensions/gsd/auto/resolve.js +12 -0
  18. package/dist/resources/extensions/gsd/auto/run-unit.js +10 -30
  19. package/dist/resources/extensions/gsd/auto/session.js +8 -0
  20. package/dist/resources/extensions/gsd/auto/workflow-dispatch-claim.js +33 -1
  21. package/dist/resources/extensions/gsd/auto/workflow-worker-heartbeat.js +9 -1
  22. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
  23. package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
  24. package/dist/resources/extensions/gsd/auto-post-unit.js +94 -76
  25. package/dist/resources/extensions/gsd/auto-prompts.js +90 -15
  26. package/dist/resources/extensions/gsd/auto-start.js +238 -12
  27. package/dist/resources/extensions/gsd/auto-worktree.js +209 -81
  28. package/dist/resources/extensions/gsd/auto.js +95 -44
  29. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +96 -26
  30. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +44 -37
  31. package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +37 -10
  32. package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +6 -3
  33. package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +4 -1
  34. package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +6 -4
  35. package/dist/resources/extensions/gsd/bootstrap/query-tools.js +5 -3
  36. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +1 -1
  37. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +298 -54
  38. package/dist/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.js +4 -0
  39. package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
  40. package/dist/resources/extensions/gsd/clean-root-preflight.js +24 -6
  41. package/dist/resources/extensions/gsd/commands/handlers/ops.js +2 -2
  42. package/dist/resources/extensions/gsd/commands-config.js +1 -1
  43. package/dist/resources/extensions/gsd/commands-eval-review.js +2 -2
  44. package/dist/resources/extensions/gsd/commands-handlers.js +23 -9
  45. package/dist/resources/extensions/gsd/dashboard-overlay.js +1 -1
  46. package/dist/resources/extensions/gsd/db/unit-dispatches.js +53 -0
  47. package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
  48. package/dist/resources/extensions/gsd/git-service.js +37 -1
  49. package/dist/resources/extensions/gsd/guided-flow.js +61 -32
  50. package/dist/resources/extensions/gsd/init-wizard.js +4 -1
  51. package/dist/resources/extensions/gsd/native-git-bridge.js +32 -8
  52. package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
  53. package/dist/resources/extensions/gsd/parallel-orchestrator.js +13 -3
  54. package/dist/resources/extensions/gsd/pre-execution-checks.js +22 -0
  55. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +8 -4
  56. package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  57. package/dist/resources/extensions/gsd/prompts/execute-task.md +4 -2
  58. package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  59. package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
  60. package/dist/resources/extensions/gsd/slice-cadence.js +45 -2
  61. package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +15 -9
  62. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -7
  63. package/dist/resources/extensions/gsd/tools/complete-task.js +1 -1
  64. package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
  65. package/dist/resources/extensions/gsd/worktree-resolver.js +57 -5
  66. package/dist/resources/skills/web-quality-audit/scripts/analyze.sh +0 -0
  67. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  68. package/dist/web/standalone/.next/BUILD_ID +1 -1
  69. package/dist/web/standalone/.next/app-path-routes-manifest.json +11 -11
  70. package/dist/web/standalone/.next/build-manifest.json +3 -3
  71. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  72. package/dist/web/standalone/.next/react-loadable-manifest.json +2 -2
  73. package/dist/web/standalone/.next/required-server-files.json +1 -1
  74. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  75. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  76. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  78. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  79. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  81. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  82. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  83. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  84. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  85. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  86. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  87. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  88. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  89. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  90. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  91. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/index.html +1 -1
  93. package/dist/web/standalone/.next/server/app/index.rsc +2 -2
  94. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  95. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  96. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  99. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  100. package/dist/web/standalone/.next/server/app-paths-manifest.json +11 -11
  101. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  102. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  103. package/dist/web/standalone/.next/server/middleware.js +3 -3
  104. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  105. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  106. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  107. package/dist/web/standalone/.next/static/chunks/8359.e059d86b255fce1c.js +10 -0
  108. package/dist/web/standalone/.next/static/chunks/app/{page-fab3ebb85b006001.js → page-752f1e2ebdaa3e45.js} +1 -1
  109. package/dist/web/standalone/.next/static/chunks/{webpack-0481f1221120a7c6.js → webpack-de742b64187e13fe.js} +1 -1
  110. package/dist/web/standalone/server.js +1 -1
  111. package/dist/welcome-screen.d.ts +2 -0
  112. package/dist/welcome-screen.js +9 -7
  113. package/package.json +1 -1
  114. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  115. package/packages/pi-agent-core/dist/agent-loop.js +4 -1
  116. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  117. package/packages/pi-agent-core/dist/agent.d.ts +5 -0
  118. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  119. package/packages/pi-agent-core/dist/agent.js +2 -0
  120. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  121. package/packages/pi-agent-core/dist/index.d.ts +1 -0
  122. package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
  123. package/packages/pi-agent-core/dist/index.js +2 -0
  124. package/packages/pi-agent-core/dist/index.js.map +1 -1
  125. package/packages/pi-agent-core/dist/token-audit.d.ts +47 -0
  126. package/packages/pi-agent-core/dist/token-audit.d.ts.map +1 -0
  127. package/packages/pi-agent-core/dist/token-audit.js +221 -0
  128. package/packages/pi-agent-core/dist/token-audit.js.map +1 -0
  129. package/packages/pi-agent-core/dist/types.d.ts +9 -0
  130. package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
  131. package/packages/pi-agent-core/dist/types.js.map +1 -1
  132. package/packages/pi-agent-core/src/agent-loop.test.ts +128 -0
  133. package/packages/pi-agent-core/src/agent-loop.ts +4 -1
  134. package/packages/pi-agent-core/src/agent.ts +8 -0
  135. package/packages/pi-agent-core/src/index.ts +2 -0
  136. package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
  137. package/packages/pi-agent-core/src/token-audit.ts +287 -0
  138. package/packages/pi-agent-core/src/types.ts +14 -0
  139. package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
  140. package/packages/pi-ai/dist/providers/anthropic-auth.test.js +35 -13
  141. package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
  142. package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +21 -11
  143. package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -1
  144. package/packages/pi-ai/dist/providers/anthropic.d.ts +7 -0
  145. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  146. package/packages/pi-ai/dist/providers/anthropic.js +9 -7
  147. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  148. package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +23 -14
  149. package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -1
  150. package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +48 -21
  151. package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -1
  152. package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js +22 -21
  153. package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js.map +1 -1
  154. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js +22 -21
  155. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js.map +1 -1
  156. package/packages/pi-ai/src/providers/anthropic-auth.test.ts +39 -25
  157. package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +26 -22
  158. package/packages/pi-ai/src/providers/anthropic.ts +22 -9
  159. package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +34 -21
  160. package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +56 -22
  161. package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +24 -28
  162. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +24 -28
  163. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  164. package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js +18 -0
  165. package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js.map +1 -1
  166. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +12 -0
  167. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  168. package/packages/pi-coding-agent/dist/core/agent-session.js +36 -7
  169. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  170. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +3 -1
  171. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  172. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  173. package/packages/pi-coding-agent/dist/core/extensions/loader.js +8 -0
  174. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  175. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +2 -0
  176. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  177. package/packages/pi-coding-agent/dist/core/extensions/runner.js +3 -6
  178. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  179. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +3 -3
  180. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  181. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +34 -3
  182. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  183. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  184. package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +2 -0
  185. package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -1
  186. package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts +2 -0
  187. package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts.map +1 -0
  188. package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js +46 -0
  189. package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js.map +1 -0
  190. package/packages/pi-coding-agent/dist/core/sdk.d.ts +10 -2
  191. package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  192. package/packages/pi-coding-agent/dist/core/sdk.js +74 -2
  193. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  194. package/packages/pi-coding-agent/dist/core/skill-tool.test.js +22 -0
  195. package/packages/pi-coding-agent/dist/core/skill-tool.test.js.map +1 -1
  196. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +6 -7
  197. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  198. package/packages/pi-coding-agent/dist/core/system-prompt.js +2 -3
  199. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  200. package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js +22 -56
  201. package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js.map +1 -1
  202. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +1 -0
  203. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
  204. package/packages/pi-coding-agent/dist/core/tools/bash.js +3 -1
  205. package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
  206. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +2 -0
  207. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
  208. package/packages/pi-coding-agent/dist/core/tools/edit.js +12 -1
  209. package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
  210. package/packages/pi-coding-agent/dist/core/tools/find.d.ts +2 -0
  211. package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
  212. package/packages/pi-coding-agent/dist/core/tools/find.js +14 -6
  213. package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
  214. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +2 -0
  215. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -1
  216. package/packages/pi-coding-agent/dist/core/tools/grep.js +12 -3
  217. package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -1
  218. package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts +2 -0
  219. package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts.map +1 -1
  220. package/packages/pi-coding-agent/dist/core/tools/hashline-read.js +3 -1
  221. package/packages/pi-coding-agent/dist/core/tools/hashline-read.js.map +1 -1
  222. package/packages/pi-coding-agent/dist/core/tools/index.d.ts +2 -1
  223. package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
  224. package/packages/pi-coding-agent/dist/core/tools/index.js +1 -0
  225. package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
  226. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +2 -0
  227. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -1
  228. package/packages/pi-coding-agent/dist/core/tools/ls.js +10 -3
  229. package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -1
  230. package/packages/pi-coding-agent/dist/core/tools/read.d.ts +2 -0
  231. package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
  232. package/packages/pi-coding-agent/dist/core/tools/read.js +3 -1
  233. package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -1
  234. package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js +7 -62
  235. package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js.map +1 -1
  236. package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts +2 -0
  237. package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts.map +1 -0
  238. package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js +115 -0
  239. package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js.map +1 -0
  240. package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts +19 -0
  241. package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts.map +1 -0
  242. package/packages/pi-coding-agent/dist/core/tools/tool-target.js +20 -0
  243. package/packages/pi-coding-agent/dist/core/tools/tool-target.js.map +1 -0
  244. package/packages/pi-coding-agent/dist/core/tools/write.d.ts +4 -0
  245. package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
  246. package/packages/pi-coding-agent/dist/core/tools/write.js +9 -1
  247. package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -1
  248. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +89 -2
  249. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  250. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +25 -1
  251. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
  252. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +5 -0
  253. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  254. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +153 -8
  255. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  256. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  257. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +18 -1
  258. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  259. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +23 -5
  260. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
  261. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +2 -0
  262. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  263. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +19 -0
  264. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  265. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +23 -5
  266. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -1
  267. package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +25 -0
  268. package/packages/pi-coding-agent/src/core/agent-session.ts +40 -7
  269. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +3 -1
  270. package/packages/pi-coding-agent/src/core/extensions/loader.ts +10 -0
  271. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +3 -3
  272. package/packages/pi-coding-agent/src/core/extensions/runner.ts +5 -5
  273. package/packages/pi-coding-agent/src/core/extensions/types.ts +37 -2
  274. package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
  275. package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
  276. package/packages/pi-coding-agent/src/core/sdk.ts +85 -3
  277. package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
  278. package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
  279. package/packages/pi-coding-agent/src/core/tools/bash-spawn-windows.test.ts +22 -66
  280. package/packages/pi-coding-agent/src/core/tools/bash.ts +4 -1
  281. package/packages/pi-coding-agent/src/core/tools/edit.ts +13 -1
  282. package/packages/pi-coding-agent/src/core/tools/find.ts +15 -6
  283. package/packages/pi-coding-agent/src/core/tools/grep.ts +13 -3
  284. package/packages/pi-coding-agent/src/core/tools/hashline-read.ts +4 -1
  285. package/packages/pi-coding-agent/src/core/tools/index.ts +8 -0
  286. package/packages/pi-coding-agent/src/core/tools/ls.ts +11 -3
  287. package/packages/pi-coding-agent/src/core/tools/read.ts +4 -1
  288. package/packages/pi-coding-agent/src/core/tools/spawn-shell-windows.test.ts +11 -72
  289. package/packages/pi-coding-agent/src/core/tools/tool-target-metadata.test.ts +127 -0
  290. package/packages/pi-coding-agent/src/core/tools/tool-target.ts +48 -0
  291. package/packages/pi-coding-agent/src/core/tools/write.ts +14 -2
  292. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +119 -2
  293. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +31 -1
  294. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +177 -8
  295. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +24 -5
  296. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +17 -1
  297. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +21 -0
  298. package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +25 -8
  299. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  300. package/src/resources/extensions/claude-code-cli/readiness.ts +25 -7
  301. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +30 -0
  302. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +26 -0
  303. package/src/resources/extensions/github-sync/sync.ts +8 -1
  304. package/src/resources/extensions/github-sync/tests/sync-source.test.ts +6 -18
  305. package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -2
  306. package/src/resources/extensions/gsd/auto/loop.ts +84 -8
  307. package/src/resources/extensions/gsd/auto/phases.ts +258 -159
  308. package/src/resources/extensions/gsd/auto/resolve.ts +19 -0
  309. package/src/resources/extensions/gsd/auto/run-unit.ts +10 -29
  310. package/src/resources/extensions/gsd/auto/session.ts +8 -0
  311. package/src/resources/extensions/gsd/auto/workflow-dispatch-claim.ts +63 -1
  312. package/src/resources/extensions/gsd/auto/workflow-worker-heartbeat.ts +14 -1
  313. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
  314. package/src/resources/extensions/gsd/auto-dispatch.ts +16 -0
  315. package/src/resources/extensions/gsd/auto-post-unit.ts +107 -78
  316. package/src/resources/extensions/gsd/auto-prompts.ts +95 -14
  317. package/src/resources/extensions/gsd/auto-start.ts +286 -15
  318. package/src/resources/extensions/gsd/auto-worktree.ts +241 -72
  319. package/src/resources/extensions/gsd/auto.ts +132 -40
  320. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +116 -24
  321. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +45 -37
  322. package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +36 -10
  323. package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +8 -3
  324. package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +5 -1
  325. package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +7 -4
  326. package/src/resources/extensions/gsd/bootstrap/query-tools.ts +6 -3
  327. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +1 -1
  328. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +347 -54
  329. package/src/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.ts +4 -0
  330. package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
  331. package/src/resources/extensions/gsd/clean-root-preflight.ts +32 -7
  332. package/src/resources/extensions/gsd/commands/handlers/ops.ts +4 -2
  333. package/src/resources/extensions/gsd/commands-config.ts +1 -1
  334. package/src/resources/extensions/gsd/commands-eval-review.ts +2 -2
  335. package/src/resources/extensions/gsd/commands-handlers.ts +34 -15
  336. package/src/resources/extensions/gsd/dashboard-overlay.ts +1 -1
  337. package/src/resources/extensions/gsd/db/unit-dispatches.ts +66 -0
  338. package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
  339. package/src/resources/extensions/gsd/git-service.ts +41 -2
  340. package/src/resources/extensions/gsd/guided-flow.ts +71 -39
  341. package/src/resources/extensions/gsd/init-wizard.ts +5 -1
  342. package/src/resources/extensions/gsd/native-git-bridge.ts +39 -6
  343. package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
  344. package/src/resources/extensions/gsd/parallel-orchestrator.ts +13 -3
  345. package/src/resources/extensions/gsd/pre-execution-checks.ts +23 -0
  346. package/src/resources/extensions/gsd/prompts/complete-milestone.md +8 -4
  347. package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  348. package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
  349. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  350. package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
  351. package/src/resources/extensions/gsd/slice-cadence.ts +49 -2
  352. package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +23 -9
  353. package/src/resources/extensions/gsd/tests/agent-end-retry.test.ts +59 -89
  354. package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +47 -172
  355. package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +0 -35
  356. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +35 -9
  357. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +361 -10
  358. package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +80 -59
  359. package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +3 -47
  360. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +76 -18
  361. package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +106 -0
  362. package/src/resources/extensions/gsd/tests/auto-pr-bugs.test.ts +54 -95
  363. package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +67 -26
  364. package/src/resources/extensions/gsd/tests/auto-remediate-slice-status.test.ts +32 -30
  365. package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +32 -128
  366. package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +20 -54
  367. package/src/resources/extensions/gsd/tests/auto-start-cold-db-bootstrap.test.ts +20 -30
  368. package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +17 -29
  369. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +138 -0
  370. package/src/resources/extensions/gsd/tests/auto-start-time-persistence.test.ts +21 -39
  371. package/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts +15 -24
  372. package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +44 -29
  373. package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +39 -51
  374. package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +159 -213
  375. package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +15 -32
  376. package/src/resources/extensions/gsd/tests/browser-teardown.test.ts +0 -41
  377. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +15 -6
  378. package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +34 -27
  379. package/src/resources/extensions/gsd/tests/cmux.test.ts +51 -53
  380. package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +39 -61
  381. package/src/resources/extensions/gsd/tests/commands-config.test.ts +26 -19
  382. package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +31 -0
  383. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +140 -0
  384. package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
  385. package/src/resources/extensions/gsd/tests/complete-task-normalize-lists.test.ts +29 -33
  386. package/src/resources/extensions/gsd/tests/completed-units-metrics-sync.test.ts +45 -108
  387. package/src/resources/extensions/gsd/tests/context-store.test.ts +7 -1
  388. package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +35 -31
  389. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +5 -1
  390. package/src/resources/extensions/gsd/tests/cwd-fallback-hardening.test.ts +138 -0
  391. package/src/resources/extensions/gsd/tests/dashboard-custom-engine.test.ts +4 -68
  392. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +4 -9
  393. package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +14 -65
  394. package/src/resources/extensions/gsd/tests/discuss-tool-scoping.test.ts +44 -37
  395. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +58 -40
  396. package/src/resources/extensions/gsd/tests/dispatch-guard-closed-status.test.ts +25 -15
  397. package/src/resources/extensions/gsd/tests/dispatcher-stuck-planning.test.ts +35 -17
  398. package/src/resources/extensions/gsd/tests/error-success-mask.test.ts +16 -21
  399. package/src/resources/extensions/gsd/tests/est-annotation-timeout.test.ts +15 -82
  400. package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +5 -2
  401. package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
  402. package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +132 -0
  403. package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +2 -20
  404. package/src/resources/extensions/gsd/tests/frontmatter-parse-noise.test.ts +18 -26
  405. package/src/resources/extensions/gsd/tests/init-skip-git.test.ts +9 -12
  406. package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +40 -0
  407. package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +4 -2
  408. package/src/resources/extensions/gsd/tests/integration/git-locale.test.ts +31 -20
  409. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +12 -0
  410. package/src/resources/extensions/gsd/tests/integration/milestone-transition-worktree.test.ts +0 -47
  411. package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +60 -202
  412. package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +13 -56
  413. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +5 -1
  414. package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +32 -0
  415. package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -0
  416. package/src/resources/extensions/gsd/tests/lazy-pi-tui-import.test.ts +44 -6
  417. package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +21 -35
  418. package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -0
  419. package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +242 -0
  420. package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +79 -98
  421. package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +70 -278
  422. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
  423. package/src/resources/extensions/gsd/tests/needs-remediation-revalidation.test.ts +37 -30
  424. package/src/resources/extensions/gsd/tests/note-captures-executed.test.ts +32 -28
  425. package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +3 -0
  426. package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +133 -0
  427. package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
  428. package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
  429. package/src/resources/extensions/gsd/tests/phantom-ghost-detection.test.ts +24 -37
  430. package/src/resources/extensions/gsd/tests/phantom-milestone-default-queued.test.ts +9 -24
  431. package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +91 -75
  432. package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +36 -22
  433. package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +36 -30
  434. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
  435. package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +74 -4
  436. package/src/resources/extensions/gsd/tests/preferences-worktree-sync.test.ts +20 -22
  437. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +130 -32
  438. package/src/resources/extensions/gsd/tests/project-root-cwd-crash.test.ts +18 -36
  439. package/src/resources/extensions/gsd/tests/projection-no-plan-overwrite.test.ts +35 -73
  440. package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +76 -138
  441. package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
  442. package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +70 -125
  443. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +59 -161
  444. package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +33 -29
  445. package/src/resources/extensions/gsd/tests/queue-auto-guard.test.ts +22 -196
  446. package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +23 -93
  447. package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +50 -79
  448. package/src/resources/extensions/gsd/tests/reassess-default-optin.test.ts +27 -13
  449. package/src/resources/extensions/gsd/tests/remote-questions.test.ts +151 -251
  450. package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +41 -29
  451. package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +58 -69
  452. package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +32 -164
  453. package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +57 -41
  454. package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
  455. package/src/resources/extensions/gsd/tests/session-model-override.test.ts +14 -9
  456. package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +77 -0
  457. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +166 -0
  458. package/src/resources/extensions/gsd/tests/show-config-command.test.ts +44 -42
  459. package/src/resources/extensions/gsd/tests/skip-slice-state-rebuild.test.ts +56 -24
  460. package/src/resources/extensions/gsd/tests/skipped-validation-db-atomicity.test.ts +51 -11
  461. package/src/resources/extensions/gsd/tests/slice-cadence.test.ts +23 -0
  462. package/src/resources/extensions/gsd/tests/slice-context-injection.test.ts +66 -50
  463. package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +68 -107
  464. package/src/resources/extensions/gsd/tests/slice-sequence-insert.test.ts +115 -42
  465. package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +21 -97
  466. package/src/resources/extensions/gsd/tests/smart-entry-draft.test.ts +25 -116
  467. package/src/resources/extensions/gsd/tests/sqlite-unavailable-gate.test.ts +21 -57
  468. package/src/resources/extensions/gsd/tests/stale-dirlistcache-4648.test.ts +29 -76
  469. package/src/resources/extensions/gsd/tests/stale-lockfile-recovery.test.ts +33 -24
  470. package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +39 -30
  471. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
  472. package/src/resources/extensions/gsd/tests/status-db-open.test.ts +33 -47
  473. package/src/resources/extensions/gsd/tests/stop-auto-merge-back.test.ts +48 -46
  474. package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +14 -102
  475. package/src/resources/extensions/gsd/tests/subagent-model-dispatch.test.ts +78 -232
  476. package/src/resources/extensions/gsd/tests/sync-worktree-skip-current.test.ts +32 -35
  477. package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
  478. package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +7 -9
  479. package/src/resources/extensions/gsd/tests/token-profile.test.ts +84 -309
  480. package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
  481. package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +134 -341
  482. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +8 -25
  483. package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +50 -1
  484. package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -99
  485. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +43 -36
  486. package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +84 -444
  487. package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +142 -0
  488. package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +44 -189
  489. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +2 -57
  490. package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
  491. package/src/resources/extensions/gsd/tests/workflow-worker-heartbeat.test.ts +32 -1
  492. package/src/resources/extensions/gsd/tests/worktree-db-same-file.test.ts +21 -44
  493. package/src/resources/extensions/gsd/tests/worktree-expected-warnings.test.ts +27 -26
  494. package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +14 -13
  495. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
  496. package/src/resources/extensions/gsd/tests/worktree-main-branch.test.ts +20 -18
  497. package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +22 -19
  498. package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
  499. package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +140 -3
  500. package/src/resources/extensions/gsd/tests/zero-slice-roadmap-guided.test.ts +19 -13
  501. package/src/resources/extensions/gsd/tools/complete-milestone.ts +14 -15
  502. package/src/resources/extensions/gsd/tools/complete-task.ts +1 -1
  503. package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
  504. package/src/resources/extensions/gsd/worktree-resolver.ts +83 -5
  505. package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +86 -40
  506. package/src/resources/skills/web-quality-audit/scripts/analyze.sh +0 -0
  507. package/dist/web/standalone/.next/static/chunks/8336.631939fb583761fa.js +0 -10
  508. /package/dist/web/standalone/.next/static/{tht0ltP8EIjsohPOA_WZf → G68KoLv5claox_Dyd4pZn}/_buildManifest.js +0 -0
  509. /package/dist/web/standalone/.next/static/{tht0ltP8EIjsohPOA_WZf → G68KoLv5claox_Dyd4pZn}/_ssgManifest.js +0 -0
@@ -1,72 +1,61 @@
1
1
  /**
2
- * Regression test for #3628 — restore tool set after discuss flow scoping
3
- *
4
- * The discuss flow narrows the active tool set to avoid "grammar too complex"
5
- * errors. Without restoring after sendMessage, the narrowed tools leaked into
6
- * subsequent dispatches, breaking plan/execute flows.
7
- *
8
- * The fix saves the full tool set before scoping and restores it after
9
- * sendMessage returns.
2
+ * Regression test for #3628 — restore tool set after discuss flow scoping.
10
3
  */
11
4
 
12
- import { describe, it } from 'node:test'
13
- import assert from 'node:assert/strict'
14
- import { readFileSync } from 'node:fs'
15
- import { resolve } from 'node:path'
16
- import { extractSourceRegion } from "./test-helpers.ts";
17
-
18
- const src = readFileSync(
19
- resolve(process.cwd(), 'src', 'resources', 'extensions', 'gsd', 'guided-flow.ts'),
20
- 'utf-8',
21
- )
22
-
23
- describe('restore tools after discuss flow scoping (#3628)', () => {
24
- it('savedTools is declared before the discuss scoping block', () => {
25
- // savedTools must be declared before the discuss-* check
26
- const savedToolsDecl = src.indexOf('let savedTools')
27
- const discussCheck = src.indexOf('if (unitType?.startsWith("discuss-"))')
28
- assert.ok(savedToolsDecl !== -1, 'savedTools variable must be declared')
29
- assert.ok(discussCheck !== -1, 'discuss-* type check must exist')
30
- assert.ok(
31
- savedToolsDecl < discussCheck,
32
- 'savedTools must be declared before the discuss scoping block',
33
- )
34
- })
35
-
36
- it('savedTools captures current tools inside the discuss block', () => {
37
- const discussCheck = src.indexOf('if (unitType?.startsWith("discuss-"))')
38
- assert.ok(discussCheck !== -1)
39
-
40
- // Look for savedTools assignment within the discuss block
41
- const blockAfter = extractSourceRegion(src, 'if (unitType?.startsWith("discuss-"))')
42
- assert.ok(
43
- blockAfter.includes('savedTools = currentTools'),
44
- 'savedTools must be assigned from currentTools inside the discuss block',
45
- )
46
- })
47
-
48
- it('savedTools is restored after sendMessage', () => {
49
- // #4573: guided-flow.ts now contains multiple `triggerTurn: true` calls
50
- // (ready-phrase and empty-turn recovery paths). The discuss-flow scoping
51
- // sendMessage is the one that follows `savedTools = currentTools`, so
52
- // anchor the search there rather than at the first `triggerTurn: true`.
53
- const savedToolsAssign = src.indexOf('savedTools = currentTools')
54
- assert.ok(savedToolsAssign !== -1, 'savedTools = currentTools must exist')
55
-
56
- const sendMsg = src.indexOf('triggerTurn: true', savedToolsAssign)
57
- assert.ok(sendMsg !== -1, 'discuss-flow sendMessage with triggerTurn must exist after savedTools capture')
58
-
59
- // After sendMessage, savedTools should be restored via setActiveTools.
60
- // Use fromIdx to anchor at the discuss-flow sendMessage, not the first
61
- // triggerTurn: true occurrence in the file.
62
- const afterSend = extractSourceRegion(src, 'triggerTurn: true', { fromIdx: savedToolsAssign })
63
- assert.ok(
64
- afterSend.includes('if (savedTools)'),
65
- 'savedTools restoration guard must exist after sendMessage',
66
- )
67
- assert.ok(
68
- afterSend.includes('setActiveTools(savedTools)'),
69
- 'setActiveTools(savedTools) must be called to restore the full tool set',
70
- )
71
- })
72
- })
5
+ import test from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { tmpdir } from "node:os";
10
+
11
+ import { _dispatchWorkflowForTest } from "../guided-flow.ts";
12
+
13
+ test("discuss workflow scopes tools for the queued turn and restores the full tool set", async () => {
14
+ const dir = mkdtempSync(join(tmpdir(), "gsd-discuss-tools-"));
15
+ const workflowPath = join(dir, "GSD-WORKFLOW.md");
16
+ const originalWorkflowPath = process.env.GSD_WORKFLOW_PATH;
17
+ const originalTools = [
18
+ "gsd_task_complete",
19
+ "gsd_summary_save",
20
+ "shell_exec",
21
+ "gsd_plan_milestone",
22
+ ];
23
+ let activeTools = [...originalTools];
24
+ let sentTools: string[] | null = null;
25
+ let triggerTurn = false;
26
+
27
+ const pi = {
28
+ getActiveTools: () => [...activeTools],
29
+ setActiveTools: (tools: string[]) => {
30
+ activeTools = [...tools];
31
+ },
32
+ sendMessage: (_message: unknown, options?: { triggerTurn?: boolean }) => {
33
+ sentTools = [...activeTools];
34
+ triggerTurn = options?.triggerTurn === true;
35
+ },
36
+ };
37
+
38
+ try {
39
+ writeFileSync(workflowPath, "# Workflow\n", "utf-8");
40
+ process.env.GSD_WORKFLOW_PATH = workflowPath;
41
+
42
+ await _dispatchWorkflowForTest(
43
+ pi as any,
44
+ "Interview the user.",
45
+ "gsd-discuss",
46
+ undefined,
47
+ "discuss-milestone",
48
+ );
49
+
50
+ assert.deepEqual(sentTools, ["gsd_summary_save"]);
51
+ assert.deepEqual(activeTools, originalTools);
52
+ assert.equal(triggerTurn, true);
53
+ } finally {
54
+ if (originalWorkflowPath === undefined) {
55
+ delete process.env.GSD_WORKFLOW_PATH;
56
+ } else {
57
+ process.env.GSD_WORKFLOW_PATH = originalWorkflowPath;
58
+ }
59
+ rmSync(dir, { recursive: true, force: true });
60
+ }
61
+ });
@@ -1,15 +1,6 @@
1
1
  /**
2
- * Tests for fix of #3723: auto-mode resume/crash-recovery dispatches
3
- * from project root instead of milestone worktree.
4
- *
5
- * During resume, the paused-session metadata may record `worktreePath` that
6
- * was active when the session paused. The resume path must use that path (or
7
- * derive the worktree path via filesystem lookup) to set the dispatch context
8
- * (`s.basePath`), rather than defaulting to the project root.
9
- *
10
- * The fix adds an early worktree-path resolution step in the paused-session
11
- * resume block of auto.ts — immediately after `s.basePath = base` — so that
12
- * the correct dispatch directory is used before the dispatch loop runs.
2
+ * Tests for fix of #3723: auto-mode resume/crash-recovery dispatches from
3
+ * the paused milestone worktree when that worktree still exists.
13
4
  */
14
5
 
15
6
  import test from "node:test";
@@ -18,95 +9,8 @@ import { readFileSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
18
9
  import { join } from "node:path";
19
10
  import { tmpdir } from "node:os";
20
11
  import { randomUUID } from "node:crypto";
21
- import { fileURLToPath } from "node:url";
22
- import { dirname } from "node:path";
23
12
 
24
- const __dirname = dirname(fileURLToPath(import.meta.url));
25
- const autoSrc = readFileSync(join(__dirname, "..", "auto.ts"), "utf-8");
26
-
27
- // ── Source-structure tests ────────────────────────────────────────────────────
28
-
29
- /**
30
- * Extract the paused-session resume block from auto.ts.
31
- *
32
- * The block we care about is the `if (s.paused) { ... }` section inside
33
- * startAuto, which contains `s.basePath = base` (line ~1473) followed by the
34
- * `enterMilestone` call.
35
- *
36
- * We find it by locating the `s.basePath = base` assignment that appears
37
- * WITHIN the s.paused branch (there's only one: all other basePath assignments
38
- * use originalBasePath or a different value). We extract from that assignment
39
- * up to just before `enterMilestone(`.
40
- */
41
- function getBasepathToEnterMilestoneSegment(): string {
42
- // Find `s.basePath = base;` in the s.paused branch
43
- // This assignment appears uniquely inside the resume block
44
- const assignPattern = "s.basePath = base;";
45
- const assignIdx = autoSrc.indexOf(assignPattern);
46
- assert.ok(
47
- assignIdx > -1,
48
- `auto.ts must contain '${assignPattern}' in the resume block`,
49
- );
50
-
51
- // Find the next enterMilestone call after this assignment
52
- const enterMilestoneIdx = autoSrc.indexOf("enterMilestone(", assignIdx);
53
- assert.ok(
54
- enterMilestoneIdx > assignIdx,
55
- "auto.ts must call enterMilestone after the s.basePath = base assignment",
56
- );
57
-
58
- // Return the code between the assignment and enterMilestone
59
- return autoSrc.slice(assignIdx, enterMilestoneIdx);
60
- }
61
-
62
- test("auto.ts resume block resolves paused-session worktreePath and applies it to s.basePath before entering worktree (fixes #3723)", () => {
63
- // The segment between `s.basePath = base` and `enterMilestone(` must
64
- // contain logic that resolves the paused-session worktreePath and applies
65
- // it to s.basePath when the worktree exists on disk.
66
- //
67
- // The fix reads the worktree path from freshStartAssessment.pausedSession
68
- // (since `meta` is out of scope at this point in startAuto) and assigns
69
- // it to s.basePath, guarded by existsSync.
70
- //
71
- // Without this fix, the dispatch loop runs from `base` (project root)
72
- // instead of the worktree, causing split-brain execution (#3723).
73
- const segment = getBasepathToEnterMilestoneSegment();
74
-
75
- // The fix uses freshStartAssessment.pausedSession?.worktreePath via a
76
- // local variable (resumeWorktreePath) and assigns to s.basePath.
77
- const hasWorktreePathResolution =
78
- segment.includes("worktreePath") &&
79
- segment.includes("existsSync") &&
80
- segment.includes("s.basePath =");
81
-
82
- assert.ok(
83
- hasWorktreePathResolution,
84
- "auto.ts must resolve the paused-session worktreePath, check existsSync, and assign " +
85
- "s.basePath before enterMilestone — crash-recovery currently dispatches from project root " +
86
- "instead of milestone worktree (issue #3723). The fix belongs between `s.basePath = base` " +
87
- "and the enterMilestone call.",
88
- );
89
- });
90
-
91
- test("auto.ts worktreePath assignment in resume block guards against non-existent path (fixes #3723)", () => {
92
- // The assignment to s.basePath from the paused-session worktreePath must
93
- // be guarded by existsSync to avoid setting an invalid basePath if the
94
- // worktree was cleaned up between pause and resume.
95
- const segment = getBasepathToEnterMilestoneSegment();
96
-
97
- // Must have existsSync guard AND a worktreePath reference AND s.basePath assignment
98
- const hasGuardedAssignment =
99
- segment.includes("existsSync") &&
100
- segment.includes("worktreePath") &&
101
- segment.includes("s.basePath =");
102
-
103
- assert.ok(
104
- hasGuardedAssignment,
105
- "auto.ts must guard the s.basePath = worktreePath assignment with existsSync (fixes #3723)",
106
- );
107
- });
108
-
109
- // ── Functional tests ──────────────────────────────────────────────────────────
13
+ import { _resolvePausedResumeBasePathForTest } from "../auto.ts";
110
14
 
111
15
  function makeTmpBase(): string {
112
16
  const base = join(tmpdir(), `gsd-resume-wt-${randomUUID()}`);
@@ -115,7 +19,7 @@ function makeTmpBase(): string {
115
19
  }
116
20
 
117
21
  function cleanup(base: string): void {
118
- try { rmSync(base, { recursive: true, force: true }); } catch { /* */ }
22
+ try { rmSync(base, { recursive: true, force: true }); } catch { /* noop */ }
119
23
  }
120
24
 
121
25
  function writePausedSession(
@@ -142,7 +46,6 @@ function makeWorktreePath(base: string, milestoneId: string): string {
142
46
 
143
47
  function setupWorktreeOnDisk(wt: string): void {
144
48
  mkdirSync(wt, { recursive: true });
145
- // Simulate a git worktree: .git file with gitdir pointer
146
49
  writeFileSync(
147
50
  join(wt, ".git"),
148
51
  "gitdir: /project/.git/worktrees/M001-test\n",
@@ -150,81 +53,46 @@ function setupWorktreeOnDisk(wt: string): void {
150
53
  );
151
54
  }
152
55
 
153
- function writeRoadmap(base: string, milestoneId = "M001-test"): void {
154
- const milestoneDir = join(base, ".gsd", "milestones", milestoneId);
155
- mkdirSync(join(milestoneDir, "slices", "S01", "tasks"), { recursive: true });
156
- writeFileSync(
157
- join(milestoneDir, `${milestoneId}-ROADMAP.md`),
158
- [
159
- `# ${milestoneId}: Test Milestone`,
160
- "",
161
- "## Slices",
162
- "",
163
- "- [ ] **S01: Test slice** `risk:low`",
164
- " After this: Demo",
165
- ].join("\n"),
166
- "utf-8",
167
- );
168
- }
56
+ test("resume base path uses paused-session worktreePath when the worktree exists", () => {
57
+ const base = makeTmpBase();
58
+ const wt = makeWorktreePath(base, "M001-test");
59
+ try {
60
+ setupWorktreeOnDisk(wt);
61
+ assert.equal(
62
+ _resolvePausedResumeBasePathForTest(base, wt),
63
+ wt,
64
+ );
65
+ } finally {
66
+ cleanup(base);
67
+ }
68
+ });
169
69
 
170
- test("readPausedSessionMetadata round-trips worktreePath from paused-session.json", () => {
171
- // Verify that the paused-session metadata correctly stores and reads back
172
- // the worktreePath field — this is what the resume path in auto.ts uses
173
- // to determine the dispatch basePath (#3723).
174
- //
175
- // Implemented inline to avoid slow import chain from interrupted-session.ts.
70
+ test("resume base path falls back to project root when paused worktree is missing", () => {
71
+ const base = makeTmpBase();
72
+ const wt = makeWorktreePath(base, "M001-test");
73
+ try {
74
+ assert.equal(
75
+ _resolvePausedResumeBasePathForTest(base, wt),
76
+ base,
77
+ );
78
+ } finally {
79
+ cleanup(base);
80
+ }
81
+ });
82
+
83
+ test("read paused-session metadata round-trips worktreePath from paused-session.json", () => {
176
84
  const base = makeTmpBase();
177
85
  const wt = makeWorktreePath(base, "M001-test");
178
86
  try {
179
87
  setupWorktreeOnDisk(wt);
180
88
  writePausedSession(base, "M001-test", wt);
181
89
 
182
- // Simulate readPausedSessionMetadata without importing the full module
183
90
  const pausedPath = join(base, ".gsd", "runtime", "paused-session.json");
184
91
  const meta = JSON.parse(readFileSync(pausedPath, "utf-8"));
185
92
 
186
- assert.ok(meta, "paused-session metadata must be readable");
187
93
  assert.equal(meta.milestoneId, "M001-test");
188
- assert.equal(meta.worktreePath, wt, "worktreePath must round-trip through paused-session.json");
94
+ assert.equal(meta.worktreePath, wt);
189
95
  } finally {
190
96
  cleanup(base);
191
97
  }
192
98
  });
193
-
194
- test("auto.ts resume block uses worktreePath from freshStartAssessment.pausedSession as dispatch basePath when worktree exists (#3723)", () => {
195
- // End-to-end structural verification: the auto.ts source must contain code
196
- // that reads the worktreePath from freshStartAssessment.pausedSession AND
197
- // applies it to s.basePath (guarded by existsSync) between the
198
- // `s.basePath = base` assignment and `enterMilestone`.
199
- //
200
- // This is the core of the #3723 fix. Without this check, a session that
201
- // paused while operating inside a worktree will resume dispatching from the
202
- // project root, not the worktree — causing split-brain execution where some
203
- // operations target the worktree and others target the project root.
204
- const segment = getBasepathToEnterMilestoneSegment();
205
-
206
- // Must reference freshStartAssessment.pausedSession?.worktreePath or
207
- // equivalent local variable, AND contain an existsSync guard
208
- const hasAssessmentWorktreePath =
209
- segment.includes("freshStartAssessment.pausedSession") &&
210
- segment.includes("worktreePath");
211
-
212
- assert.ok(
213
- hasAssessmentWorktreePath,
214
- "auto.ts must read worktreePath from freshStartAssessment.pausedSession between " +
215
- "s.basePath=base and enterMilestone",
216
- );
217
- assert.ok(
218
- segment.includes("existsSync"),
219
- "auto.ts must guard worktreePath usage with existsSync",
220
- );
221
- // The actual basePath re-assignment must be present in the segment
222
- // (note: there are multiple `s.basePath =` assignments — we need one after
223
- // the initial `s.basePath = base` assignment within this segment)
224
- const worktreeAssignIdx = segment.lastIndexOf("s.basePath =");
225
- const baseAssignIdx = segment.indexOf("s.basePath = base");
226
- assert.ok(
227
- worktreeAssignIdx > baseAssignIdx,
228
- "auto.ts must assign s.basePath to the worktree path after `s.basePath = base` in the resume block",
229
- );
230
- });
@@ -1,51 +1,67 @@
1
1
  /**
2
- * Regression test for #3624 — cap run-uat dispatch attempts
3
- *
4
- * When verification commands fail before writing a verdict, the run-uat
5
- * dispatch rule fires repeatedly in an infinite loop. The fix adds a
6
- * MAX_UAT_ATTEMPTS constant and calls incrementUatCount before dispatch
7
- * to cap the number of attempts.
8
- *
9
- * Structural verification test — reads source to confirm MAX_UAT_ATTEMPTS
10
- * and incrementUatCount exist.
2
+ * Regression test for #3624 — cap run-uat dispatch attempts.
11
3
  */
12
4
 
13
- import { describe, test } from 'node:test';
14
- import assert from 'node:assert/strict';
15
- import { readFileSync } from 'node:fs';
16
- import { fileURLToPath } from 'node:url';
17
- import { dirname, join } from 'node:path';
5
+ import test from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { tmpdir } from "node:os";
18
10
 
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
11
+ import { DISPATCH_RULES, getUatCount } from "../auto-dispatch.ts";
21
12
 
22
- const source = readFileSync(join(__dirname, '..', 'auto-dispatch.ts'), 'utf-8');
13
+ function makeUatProject(): string {
14
+ const base = mkdtempSync(join(tmpdir(), "gsd-uat-cap-"));
15
+ const milestone = join(base, ".gsd", "milestones", "M001");
16
+ mkdirSync(join(milestone, "slices", "S01"), { recursive: true });
17
+ mkdirSync(join(milestone, "slices", "S02"), { recursive: true });
18
+ writeFileSync(
19
+ join(milestone, "M001-ROADMAP.md"),
20
+ [
21
+ "# M001: UAT Cap",
22
+ "",
23
+ "## Slices",
24
+ "- [x] **S01: Completed slice** `risk:low`",
25
+ " Demo: done.",
26
+ "- [ ] **S02: Remaining slice** `risk:low`",
27
+ " Demo: pending.",
28
+ ].join("\n"),
29
+ "utf-8",
30
+ );
31
+ writeFileSync(
32
+ join(milestone, "slices", "S01", "S01-UAT.md"),
33
+ "# UAT\n\nRun the checks. No verdict has been written yet.\n",
34
+ "utf-8",
35
+ );
36
+ return base;
37
+ }
23
38
 
24
- describe('run-uat replay cap (#3624)', () => {
25
- test('MAX_UAT_ATTEMPTS constant is defined', () => {
26
- assert.match(source, /const MAX_UAT_ATTEMPTS\s*=\s*\d+/,
27
- 'MAX_UAT_ATTEMPTS constant should be defined');
28
- });
39
+ test("run-uat dispatch stops after three attempts without a verdict", async () => {
40
+ const basePath = makeUatProject();
41
+ const rule = DISPATCH_RULES.find((r) => r.name === "run-uat (post-completion)");
42
+ assert.ok(rule, "run-uat dispatch rule is registered");
29
43
 
30
- test('incrementUatCount function is exported', () => {
31
- assert.match(source, /export function incrementUatCount\(/,
32
- 'incrementUatCount should be an exported function');
33
- });
44
+ const ctx = {
45
+ state: { phase: "planning", activeSlice: null },
46
+ mid: "M001",
47
+ midTitle: "UAT Cap",
48
+ basePath,
49
+ prefs: { uat_dispatch: true },
50
+ };
34
51
 
35
- test('getUatCount function is exported', () => {
36
- assert.match(source, /export function getUatCount\(/,
37
- 'getUatCount should be an exported function');
38
- });
52
+ try {
53
+ for (let i = 1; i <= 3; i++) {
54
+ const action = await rule.match(ctx as any);
55
+ assert.equal(action?.action, "dispatch");
56
+ assert.equal(action?.unitType, "run-uat");
57
+ assert.equal(getUatCount(basePath, "M001", "S01"), i);
58
+ }
39
59
 
40
- test('incrementUatCount is called before dispatch in rule', () => {
41
- // incrementUatCount should be called before the dispatch return
42
- const ruleSection = source.slice(source.indexOf('checkNeedsRunUat'));
43
- assert.match(ruleSection, /incrementUatCount\(/,
44
- 'incrementUatCount should be called in the dispatch rule');
45
- });
46
-
47
- test('attempts are compared against MAX_UAT_ATTEMPTS', () => {
48
- assert.match(source, /attempts\s*>\s*MAX_UAT_ATTEMPTS/,
49
- 'dispatch should check attempts > MAX_UAT_ATTEMPTS');
50
- });
60
+ const capped = await rule.match(ctx as any);
61
+ assert.equal(capped?.action, "stop");
62
+ assert.match(capped?.reason ?? "", /dispatched 3 times/);
63
+ assert.equal(getUatCount(basePath, "M001", "S01"), 4);
64
+ } finally {
65
+ rmSync(basePath, { recursive: true, force: true });
66
+ }
51
67
  });
@@ -0,0 +1,96 @@
1
+ // GSD-2 + src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts
2
+ // Regression: bootstrap must rederive `currentMilestoneId` from an unmerged
3
+ // completed milestone branch when in-memory state was lost across a process
4
+ // restart (#5538-followup).
5
+
6
+ import test from "node:test";
7
+ import assert from "node:assert/strict";
8
+
9
+ import { _selectResumableMilestone } from "../auto-start.js";
10
+
11
+ const ALL_COMPLETE = (_id: string) => true;
12
+ const NEVER_COMPLETE = (_id: string) => false;
13
+ const HAS_COMMITS = (_branch: string) => 1;
14
+ const NO_COMMITS = (_branch: string) => 0;
15
+
16
+ test("returns null when no branches exist", () => {
17
+ const result = _selectResumableMilestone([], new Set(), ALL_COMPLETE, HAS_COMMITS);
18
+ assert.equal(result, null);
19
+ });
20
+
21
+ test("returns null when every milestone branch is already merged", () => {
22
+ const branches = ["milestone/M001", "milestone/M002"];
23
+ const merged = new Set(branches);
24
+ const result = _selectResumableMilestone(branches, merged, ALL_COMPLETE, HAS_COMMITS);
25
+ assert.equal(result, null);
26
+ });
27
+
28
+ test("returns null when no candidate milestones are complete", () => {
29
+ const branches = ["milestone/M002"];
30
+ const result = _selectResumableMilestone(branches, new Set(), NEVER_COMPLETE, HAS_COMMITS);
31
+ assert.equal(result, null);
32
+ });
33
+
34
+ test("returns null when no branch has commits ahead", () => {
35
+ const branches = ["milestone/M002"];
36
+ const result = _selectResumableMilestone(branches, new Set(), ALL_COMPLETE, NO_COMMITS);
37
+ assert.equal(result, null);
38
+ });
39
+
40
+ test("returns the unmerged completed milestone (regression: M002 stranded after restart)", () => {
41
+ // Repro of test12345 state: M001 ✅ merged, M002 ✅ unmerged, M003 🔄.
42
+ // Bootstrap must seed currentMilestoneId = "M002" so the loop's transition
43
+ // guard fires when the next iteration sees mid="M003".
44
+ const branches = ["milestone/M002", "milestone/M003"];
45
+ const merged = new Set<string>(); // none merged from this list
46
+ const isComplete = (id: string) => id === "M002"; // M003 still in progress
47
+ const result = _selectResumableMilestone(branches, merged, isComplete, HAS_COMMITS);
48
+ assert.equal(result, "M002");
49
+ });
50
+
51
+ test("picks the lex-greatest milestone when multiple candidates exist", () => {
52
+ // M001, M002 both unmerged complete -> pick M002 (the most recent).
53
+ const branches = ["milestone/M001", "milestone/M002"];
54
+ const result = _selectResumableMilestone(
55
+ branches,
56
+ new Set(),
57
+ ALL_COMPLETE,
58
+ HAS_COMMITS,
59
+ );
60
+ assert.equal(result, "M002");
61
+ });
62
+
63
+ test("ignores branch names that don't follow the milestone/ prefix", () => {
64
+ const branches = ["feature/something", "milestone/M002", "fix/bug-1"];
65
+ const result = _selectResumableMilestone(
66
+ branches,
67
+ new Set(),
68
+ ALL_COMPLETE,
69
+ HAS_COMMITS,
70
+ );
71
+ assert.equal(result, "M002");
72
+ });
73
+
74
+ test("isComplete callback throwing skips that milestone but does not crash", () => {
75
+ const branches = ["milestone/M001", "milestone/M002"];
76
+ const isComplete = (id: string) => {
77
+ if (id === "M001") throw new Error("db unavailable for M001");
78
+ return true;
79
+ };
80
+ // Implementation choice: a thrown isComplete is propagated. Wrapping in
81
+ // try/catch happens at the production wrapper level (findUnmergedCompletedMilestone).
82
+ // Verify the helper itself surfaces the error so callers see real failures.
83
+ assert.throws(() => _selectResumableMilestone(branches, new Set(), isComplete, HAS_COMMITS));
84
+ });
85
+
86
+ test("commitsAhead callback throwing for one branch falls through to others", () => {
87
+ // Production wrapper: commits-ahead failures should not abort the search.
88
+ // The helper catches throws from commitsAhead per-branch and treats as 0.
89
+ const branches = ["milestone/M001", "milestone/M002"];
90
+ const commitsAhead = (branch: string) => {
91
+ if (branch === "milestone/M001") throw new Error("rev-walk failed");
92
+ return 5;
93
+ };
94
+ const result = _selectResumableMilestone(branches, new Set(), ALL_COMPLETE, commitsAhead);
95
+ assert.equal(result, "M002");
96
+ });
@@ -1,7 +1,5 @@
1
1
  import test from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import { readFileSync } from "node:fs";
4
- import { join } from "node:path";
5
3
 
6
4
  import {
7
5
  clearSessionModelOverride,
@@ -9,8 +7,6 @@ import {
9
7
  setSessionModelOverride,
10
8
  } from "../session-model-override.js";
11
9
 
12
- const phasesSource = readFileSync(join(import.meta.dirname, "..", "auto", "phases.ts"), "utf-8");
13
-
14
10
  test("setSessionModelOverride stores provider/model for the session", () => {
15
11
  const sessionId = `session-override-${Date.now()}`;
16
12
  setSessionModelOverride(sessionId, { provider: "openai-codex", id: "gpt-5.4" });
@@ -27,9 +23,18 @@ test("clearSessionModelOverride removes the session override", () => {
27
23
  assert.equal(getSessionModelOverride(sessionId), undefined);
28
24
  });
29
25
 
30
- test("auto dispatch threads manual session model override into selectAndApplyModel", () => {
31
- assert.ok(
32
- phasesSource.includes("s.manualSessionModelOverride"),
33
- "auto/phases.ts should pass s.manualSessionModelOverride into selectAndApplyModel",
34
- );
26
+ test("session model overrides are isolated by session id", () => {
27
+ const first = `session-first-${Date.now()}`;
28
+ const second = `session-second-${Date.now()}`;
29
+ setSessionModelOverride(first, { provider: "openai-codex", id: "gpt-5.4" });
30
+ setSessionModelOverride(second, { provider: "anthropic", id: "claude-sonnet-4-6" });
31
+
32
+ assert.deepEqual(getSessionModelOverride(first), {
33
+ provider: "openai-codex",
34
+ id: "gpt-5.4",
35
+ });
36
+ assert.deepEqual(getSessionModelOverride(second), {
37
+ provider: "anthropic",
38
+ id: "claude-sonnet-4-6",
39
+ });
35
40
  });