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
@@ -45,12 +45,17 @@ import { runPreparation, formatCodebaseBrief, formatPriorContextBrief, } from ".
45
45
  import { verifyExpectedArtifact } from "./auto-recovery.js";
46
46
  import { createWorkspace, scopeMilestone } from "./workspace.js";
47
47
  import { getPendingGate, extractDepthVerificationMilestoneId } from "./bootstrap/write-gate.js";
48
+ export function shouldSkipGitBootstrapAfterInit(result) {
49
+ return result.gitEnabled === false;
50
+ }
48
51
  // ─── Re-exports (preserve public API for existing importers) ────────────────
49
52
  export { MILESTONE_ID_RE, generateMilestoneSuffix, nextMilestoneId, extractMilestoneSeq, parseMilestoneId, milestoneIdSort, maxMilestoneNum, findMilestoneIds, reserveMilestoneId, claimReservedId, getReservedMilestoneIds, clearReservedMilestoneIds, } from "./milestone-ids.js";
50
53
  export { showQueue, handleQueueReorder, showQueueAdd, buildExistingMilestonesContext, } from "./guided-flow-queue.js";
51
54
  import { logWarning } from "./workflow-logger.js";
52
55
  import { deleteRuntimeKv } from "./db/runtime-kv.js";
53
56
  import { PAUSED_SESSION_KV_KEY } from "./interrupted-session.js";
57
+ import { buildWorkflowDispatchContent } from "./workflow-protocol.js";
58
+ import { isFullGsdToolSurfaceRequested, restoreGsdWorkflowTools, scopeGsdWorkflowToolsForDispatch } from "./bootstrap/register-hooks.js";
54
59
  function scheduleAutoStartAfterIdle(ctx, pi, basePath, verboseMode, options, launch = startAutoDetached) {
55
60
  const waitForIdle = typeof ctx.waitForIdle === "function"
56
61
  ? ctx.waitForIdle.bind(ctx)
@@ -129,6 +134,13 @@ function runPlanV2Gate(ctx, basePath, state) {
129
134
  }
130
135
  return "pass";
131
136
  }
137
+ export const _needsPlanV2GateForTest = needsPlanV2Gate;
138
+ export const _runPlanV2GateForTest = runPlanV2Gate;
139
+ export function _roadmapHasParseableSlicesForTest(roadmapContent) {
140
+ if (!roadmapContent)
141
+ return false;
142
+ return parseRoadmapSlices(roadmapContent).length > 0;
143
+ }
132
144
  // ─── Commit Instruction Helpers ──────────────────────────────────────────────
133
145
  /** Build commit instruction for planning prompts. .gsd/ is managed externally and always gitignored. */
134
146
  function buildDocsCommitInstruction(_message) {
@@ -152,7 +164,7 @@ const USER_DRIVEN_DEEP_SETUP_UNITS = new Set([
152
164
  "discuss-requirements",
153
165
  "research-decision",
154
166
  ]);
155
- const FOREGROUND_DEEP_SETUP_RULE_NAMES = new Set([
167
+ export const FOREGROUND_DEEP_SETUP_RULE_NAMES = new Set([
156
168
  "deep: pre-planning (no workflow prefs) → workflow-preferences",
157
169
  "deep: pre-planning (no PROJECT) → discuss-project",
158
170
  "deep: pre-planning (no REQUIREMENTS) → discuss-requirements",
@@ -845,40 +857,58 @@ async function dispatchWorkflow(pi, note, customType = "gsd-run", ctx, unitType)
845
857
  return;
846
858
  }
847
859
  }
848
- // Scope tools for discuss flows (#2949).
860
+ // Scope tools for guided workflow turns (#2949, token-consumption savings).
849
861
  // Providers with grammar-based constrained decoding (xAI/Grok) return
850
862
  // "Grammar is too complex" when the combined tool schema is too large.
851
- // Discuss flows only need a small subset of GSD tools — strip the heavy
852
- // planning/execution/completion tools to keep the grammar within limits.
863
+ // Guided workflow turns only need the active unit's tool surface; strip
864
+ // unrelated GSD tools and broad non-GSD tools for this queued turn, then
865
+ // restore so the narrowed surface does not leak into future dispatches.
853
866
  let savedTools = null;
854
- if (unitType?.startsWith("discuss-")) {
867
+ try {
855
868
  const currentTools = pi.getActiveTools();
856
- savedTools = currentTools;
857
- // Keep all non-GSD tools (builtins, other extensions) and only the
858
- // GSD tools on the discuss allowlist.
859
- const scopedTools = currentTools.filter((t) => !t.startsWith("gsd_") || DISCUSS_TOOLS_ALLOWLIST.includes(t));
860
- pi.setActiveTools(scopedTools);
861
- debugLog("discuss-tool-scoping", {
862
- unitType,
863
- before: currentTools.length,
864
- after: scopedTools.length,
865
- removed: currentTools.length - scopedTools.length,
866
- });
867
- }
868
- const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
869
- const workflow = readFileSync(workflowPath, "utf-8");
870
- pi.sendMessage({
871
- customType,
872
- content: `Read the following GSD workflow protocol and execute exactly.\n\n${workflow}\n\n## Your Task\n\n${note}`,
873
- display: false,
874
- }, { triggerTurn: true });
875
- // Restore full tool set after the message is queued. The LLM turn has
876
- // already captured the scoped set — restoring prevents the narrowed
877
- // tools from leaking into subsequent dispatches (#3628).
878
- if (savedTools) {
879
- pi.setActiveTools(savedTools);
869
+ savedTools = {
870
+ tools: currentTools,
871
+ visibleSkills: typeof pi.getVisibleSkills === "function" ? pi.getVisibleSkills() : undefined,
872
+ restoreVisibleSkills: typeof pi.setVisibleSkills === "function",
873
+ };
874
+ if (unitType?.startsWith("discuss-") && !isFullGsdToolSurfaceRequested()) {
875
+ // Keep all non-GSD tools (builtins, other extensions) and only the
876
+ // GSD tools on the discuss allowlist.
877
+ const scopedTools = currentTools.filter((t) => !t.startsWith("gsd_") || DISCUSS_TOOLS_ALLOWLIST.includes(t));
878
+ pi.setActiveTools(scopedTools);
879
+ const scopedState = scopeGsdWorkflowToolsForDispatch(pi, unitType);
880
+ savedTools = {
881
+ tools: currentTools,
882
+ visibleSkills: scopedState?.visibleSkills ?? savedTools.visibleSkills,
883
+ restoreVisibleSkills: scopedState?.restoreVisibleSkills ?? savedTools.restoreVisibleSkills,
884
+ };
885
+ debugLog("discuss-tool-scoping", {
886
+ unitType,
887
+ before: currentTools.length,
888
+ after: pi.getActiveTools().length,
889
+ removed: currentTools.length - pi.getActiveTools().length,
890
+ });
891
+ }
892
+ else {
893
+ savedTools = scopeGsdWorkflowToolsForDispatch(pi, unitType) ?? savedTools;
894
+ }
895
+ const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
896
+ const workflow = readFileSync(workflowPath, "utf-8");
897
+ pi.sendMessage({
898
+ customType,
899
+ content: buildWorkflowDispatchContent({ workflow, workflowPath, task: note }),
900
+ display: false,
901
+ }, { triggerTurn: true });
902
+ }
903
+ finally {
904
+ // Restore full tool set after the message is queued. The LLM turn has
905
+ // already captured the scoped set — restoring prevents the narrowed
906
+ // tools from leaking into subsequent dispatches (#3628). The finally
907
+ // block ensures restoration even if sendMessage throws.
908
+ restoreGsdWorkflowTools(pi, savedTools);
880
909
  }
881
910
  }
911
+ export const _dispatchWorkflowForTest = dispatchWorkflow;
882
912
  function getStructuredQuestionsAvailability(pi, ctx) {
883
913
  if (!ctx)
884
914
  return "false";
@@ -1647,7 +1677,7 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
1647
1677
  const result = await showProjectInit(ctx, pi, basePath, detection);
1648
1678
  if (!result.completed)
1649
1679
  return; // User cancelled
1650
- skipGitBootstrap = result.gitEnabled === false;
1680
+ skipGitBootstrap = shouldSkipGitBootstrapAfterInit(result);
1651
1681
  // Init wizard bootstrapped .gsd/ — fall through to the normal flow below
1652
1682
  // which will detect "no milestones" and start the discuss prompt
1653
1683
  }
@@ -1965,8 +1995,7 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
1965
1995
  if (hasRoadmap) {
1966
1996
  const roadmapContent = await loadFile(roadmapFile);
1967
1997
  if (roadmapContent) {
1968
- const parsed = parseRoadmapSlices(roadmapContent);
1969
- roadmapHasSlices = parsed.length > 0;
1998
+ roadmapHasSlices = _roadmapHasParseableSlicesForTest(roadmapContent);
1970
1999
  }
1971
2000
  }
1972
2001
  if (!hasRoadmap || !roadmapHasSlices) {
@@ -15,6 +15,9 @@ import { assertSafeDirectory } from "./validate-directory.js";
15
15
  import { runSkillInstallStep } from "./skill-catalog.js";
16
16
  import { generateCodebaseMap, writeCodebaseMap } from "./codebase-generator.js";
17
17
  import { handlePrefsWizard, writePreferencesFile } from "./commands-prefs-wizard.js";
18
+ export function shouldWriteGitFiles(gitEnabled) {
19
+ return gitEnabled;
20
+ }
18
21
  // ─── Defaults ───────────────────────────────────────────────────────────────────
19
22
  const DEFAULT_PREFS = {
20
23
  mode: "solo",
@@ -247,7 +250,7 @@ export async function showProjectInit(ctx, pi, basePath, detection) {
247
250
  }
248
251
  // Ensure .gitignore only when git is active. A user who selected "Skip"
249
252
  // should not have git initialized or git-related files mutated later.
250
- if (gitEnabled) {
253
+ if (shouldWriteGitFiles(gitEnabled)) {
251
254
  ensureGitignore(basePath);
252
255
  untrackRuntimeFiles(basePath);
253
256
  }
@@ -5,7 +5,7 @@
5
5
  // Both READ and WRITE operations are native — push operations remain as
6
6
  // execSync calls because git2 credential handling is too complex.
7
7
  import { execFileSync } from "node:child_process";
8
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
8
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { join } from "node:path";
10
10
  import { GSDError, GSD_GIT_ERROR } from "./errors.js";
11
11
  import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
@@ -1007,6 +1007,24 @@ export function nativeRmForce(basePath, paths) {
1007
1007
  gitFileExec(basePath, ["rm", "--force", "--", path], true);
1008
1008
  }
1009
1009
  }
1010
+ function runGitWorktreeAdd(basePath, wtPath, branch, createBranch, startPoint) {
1011
+ if (createBranch) {
1012
+ const branchRef = gitExec(basePath, ["show-ref", "--verify", `refs/heads/${branch}`], true);
1013
+ if (branchRef) {
1014
+ gitExec(basePath, ["worktree", "add", wtPath, branch]);
1015
+ return;
1016
+ }
1017
+ gitExec(basePath, ["worktree", "add", "-b", branch, wtPath, startPoint ?? "HEAD"]);
1018
+ }
1019
+ else {
1020
+ gitExec(basePath, ["worktree", "add", wtPath, branch]);
1021
+ }
1022
+ }
1023
+ export function assertWorktreeMaterialized(wtPath) {
1024
+ if (existsSync(join(wtPath, ".git")))
1025
+ return;
1026
+ throw new GSDError(GSD_GIT_ERROR, `git worktree add did not materialize a valid worktree at ${wtPath}: missing .git file`);
1027
+ }
1010
1028
  /**
1011
1029
  * Add a new git worktree.
1012
1030
  * Native: libgit2 worktree API.
@@ -1016,14 +1034,20 @@ export function nativeWorktreeAdd(basePath, wtPath, branch, createBranch, startP
1016
1034
  const native = loadNative();
1017
1035
  if (native) {
1018
1036
  native.gitWorktreeAdd(basePath, wtPath, branch, createBranch, startPoint);
1019
- return;
1020
- }
1021
- if (createBranch) {
1022
- gitExec(basePath, ["worktree", "add", "-b", branch, wtPath, startPoint ?? "HEAD"]);
1023
- }
1024
- else {
1025
- gitExec(basePath, ["worktree", "add", wtPath, branch]);
1037
+ try {
1038
+ assertWorktreeMaterialized(wtPath);
1039
+ return;
1040
+ }
1041
+ catch {
1042
+ rmSync(wtPath, { recursive: true, force: true });
1043
+ gitExec(basePath, ["worktree", "prune"], true);
1044
+ runGitWorktreeAdd(basePath, wtPath, branch, createBranch, startPoint);
1045
+ assertWorktreeMaterialized(wtPath);
1046
+ return;
1047
+ }
1026
1048
  }
1049
+ runGitWorktreeAdd(basePath, wtPath, branch, createBranch, startPoint);
1050
+ assertWorktreeMaterialized(wtPath);
1027
1051
  }
1028
1052
  /**
1029
1053
  * Remove a git worktree.
@@ -0,0 +1,101 @@
1
+ // GSD-2 + src/resources/extensions/gsd/orphan-stash-audit.ts
2
+ // Startup sweep for orphaned gsd-preflight-stash entries left behind by
3
+ // interrupted milestone merges (#5538-followup).
4
+ import { execFileSync } from "node:child_process";
5
+ import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
6
+ /**
7
+ * Recognize the "already restored" failure mode of `git stash apply`.
8
+ *
9
+ * When a preflight stash captured untracked files via `--include-untracked`
10
+ * and those files are now present in the working tree (e.g. a prior audit
11
+ * run already applied this stash), `git stash apply` aborts with
12
+ * `<path> already exists, no checkout` and exits non-zero. That is the
13
+ * idempotent steady state for this audit, not a recovery failure — treat
14
+ * it as a no-op so repeated GSD startups stop spamming the user with
15
+ * warnings about stashes that have already been restored (#5538-followup
16
+ * peer-review feedback).
17
+ */
18
+ function _isAlreadyRestoredApplyError(err) {
19
+ if (!err || typeof err !== "object")
20
+ return false;
21
+ const stderr = err.stderr;
22
+ const stderrText = typeof stderr === "string" ? stderr : stderr instanceof Uint8Array ? Buffer.from(stderr).toString("utf-8") : "";
23
+ if (stderrText && /already exists, no checkout/i.test(stderrText))
24
+ return true;
25
+ const message = err instanceof Error ? err.message : String(err);
26
+ return /already exists, no checkout/i.test(message);
27
+ }
28
+ export { _isAlreadyRestoredApplyError };
29
+ /**
30
+ * Audit `git stash list` for orphaned `gsd-preflight-stash:M00x:*` entries.
31
+ *
32
+ * The matching merge code in `phases.ts` previously skipped the postflight
33
+ * pop whenever `mergeAndExit` threw, leaking the user's pre-merge working
34
+ * tree into the stash list. For every preflight-stash entry whose milestone
35
+ * is now complete (per the supplied callback), `git stash apply` is invoked —
36
+ * NOT `pop`. The stash entry stays in the list so the user retains a backup
37
+ * if the apply produces unexpected merge results. Idempotent across repeated
38
+ * startup runs.
39
+ *
40
+ * Failures are best-effort: a list error (no repo, git unavailable) returns
41
+ * an empty result. An apply error becomes a warning the user sees alongside
42
+ * the existing orphan-branch audit messages — startup continues.
43
+ */
44
+ export function auditOrphanedPreflightStashes(basePath, isMilestoneComplete) {
45
+ const result = { applied: [], warnings: [] };
46
+ let listOutput;
47
+ try {
48
+ listOutput = execFileSync("git", ["stash", "list", "--format=%gd%x00%s"], {
49
+ cwd: basePath,
50
+ stdio: ["ignore", "pipe", "pipe"],
51
+ encoding: "utf-8",
52
+ env: GIT_NO_PROMPT_ENV,
53
+ });
54
+ }
55
+ catch {
56
+ return result;
57
+ }
58
+ const MARKER_RE = /\bgsd-preflight-stash:([A-Za-z0-9_-]+):/;
59
+ for (const line of listOutput.split("\n")) {
60
+ const sep = line.indexOf("\x00");
61
+ if (sep < 0)
62
+ continue;
63
+ const ref = line.slice(0, sep);
64
+ const subject = line.slice(sep + 1);
65
+ if (!ref || !subject)
66
+ continue;
67
+ const match = MARKER_RE.exec(subject);
68
+ if (!match)
69
+ continue;
70
+ const milestoneId = match[1];
71
+ let complete = false;
72
+ try {
73
+ complete = isMilestoneComplete(milestoneId);
74
+ }
75
+ catch (err) {
76
+ result.warnings.push(`Could not determine completion status for ${milestoneId} during preflight-stash audit: ${err instanceof Error ? err.message : String(err)}.`);
77
+ continue;
78
+ }
79
+ if (!complete)
80
+ continue;
81
+ try {
82
+ execFileSync("git", ["stash", "apply", "--quiet", ref], {
83
+ cwd: basePath,
84
+ stdio: ["ignore", "pipe", "pipe"],
85
+ encoding: "utf-8",
86
+ env: GIT_NO_PROMPT_ENV,
87
+ });
88
+ result.applied.push({ milestoneId, stashRef: ref });
89
+ }
90
+ catch (err) {
91
+ // Idempotent steady state: stash was already applied in a prior audit
92
+ // run; the files exist and `git stash apply` refuses to overwrite.
93
+ // Skip silently so repeat runs are no-ops.
94
+ if (_isAlreadyRestoredApplyError(err))
95
+ continue;
96
+ result.warnings.push(`Could not apply orphaned preflight stash ${ref} (milestone ${milestoneId}): ${err instanceof Error ? err.message : String(err)}. ` +
97
+ `Run \`git stash apply ${ref}\` manually to restore your pre-merge changes.`);
98
+ }
99
+ }
100
+ return result;
101
+ }
@@ -12,7 +12,7 @@ import { join, dirname } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import { gsdRoot } from "./paths.js";
14
14
  import { createWorktree, worktreePath } from "./worktree-manager.js";
15
- import { autoWorktreeBranch, runWorktreePostCreateHook, syncGsdStateToWorktree } from "./auto-worktree.js";
15
+ import { autoWorktreeBranch, fastForwardReusedMilestoneBranchIfSafe, runWorktreePostCreateHook, syncGsdStateToWorktree } from "./auto-worktree.js";
16
16
  import { nativeBranchExists } from "./native-git-bridge.js";
17
17
  import { readIntegrationBranch } from "./git-service.js";
18
18
  import { resolveParallelConfig } from "./preferences.js";
@@ -368,7 +368,7 @@ export async function startParallel(basePath, milestoneIds, prefs) {
368
368
  // Create the worktree (without chdir — coordinator stays in project root)
369
369
  let wtPath;
370
370
  try {
371
- wtPath = createMilestoneWorktree(basePath, mid);
371
+ wtPath = _createMilestoneWorktree(basePath, mid);
372
372
  }
373
373
  catch (e) {
374
374
  logWarning("parallel", `createMilestoneWorktree fallback for ${mid}: ${e.message}`);
@@ -421,12 +421,22 @@ export async function startParallel(basePath, milestoneIds, prefs) {
421
421
  /**
422
422
  * Create a git worktree for a milestone without changing the coordinator's cwd.
423
423
  * Uses milestone/<MID> branch naming (same as auto-worktree.ts).
424
+ *
425
+ * Exported with the `_` prefix purely for tests — production callers stay on
426
+ * the closure-private name `createMilestoneWorktree` below.
424
427
  */
425
- function createMilestoneWorktree(basePath, milestoneId) {
428
+ export function _createMilestoneWorktree(basePath, milestoneId) {
426
429
  const branch = autoWorktreeBranch(milestoneId);
427
430
  const branchExists = nativeBranchExists(basePath, branch);
428
431
  let info;
429
432
  if (branchExists) {
433
+ // #5549 post-merge audit (R3): match the fast-forward behavior added to
434
+ // `createAutoWorktree` in commit 8996cb68e. When a worker reuses an
435
+ // existing milestone branch, fast-forward it onto the integration branch
436
+ // when safe so per-worker worktrees don't fork from a stale base after a
437
+ // sibling milestone has merged. Same `nativeIsAncestor` + worktree-list
438
+ // safety guards apply.
439
+ fastForwardReusedMilestoneBranchIfSafe(basePath, milestoneId, branch);
430
440
  info = createWorktree(basePath, milestoneId, { branch, reuseExistingBranch: true });
431
441
  }
432
442
  else {
@@ -328,6 +328,8 @@ function shouldValidateInputAsPath(raw) {
328
328
  const trimmed = raw.trim();
329
329
  if (!trimmed)
330
330
  return false;
331
+ if (isRuntimeOnlyInput(trimmed))
332
+ return false;
331
333
  const candidate = extractPathFromAnnotation(trimmed);
332
334
  if (!candidate)
333
335
  return false;
@@ -349,6 +351,9 @@ function shouldValidateInputAsPath(raw) {
349
351
  /[\\/]/.test(candidate) ||
350
352
  /[*?[\]{}]/.test(candidate));
351
353
  }
354
+ function isRuntimeOnlyInput(raw) {
355
+ return /\(\s*runtime\s*\)/i.test(raw);
356
+ }
352
357
  function containsGlobPattern(candidate) {
353
358
  return ["*", "?", "[", "]", "{", "}"].some((char) => candidate.includes(char));
354
359
  }
@@ -386,6 +391,15 @@ function getExpectedOutputsUpTo(tasks, taskIndex) {
386
391
  */
387
392
  export function checkFilePathConsistency(tasks, basePath) {
388
393
  const results = [];
394
+ // Build a set of all files created by any task at any position (normalized).
395
+ // Used to suppress consistency errors for files that will be caught with a
396
+ // more precise message by checkTaskOrdering (sequence violation).
397
+ const allTaskOutputs = new Set();
398
+ for (const t of tasks) {
399
+ for (const f of t.expected_output) {
400
+ allTaskOutputs.add(normalizeFilePath(f));
401
+ }
402
+ }
389
403
  for (let i = 0; i < tasks.length; i++) {
390
404
  const task = tasks[i];
391
405
  const priorOutputs = getExpectedOutputsUpTo(tasks, i);
@@ -416,6 +430,12 @@ export function checkFilePathConsistency(tasks, basePath) {
416
430
  anyOutputUnderDirectory(normalizedFile, ownOutputs);
417
431
  }
418
432
  if (!existsOnDisk && !inPriorOutputs && !inOwnOutputs && !directorySatisfied) {
433
+ // If a later task claims to create this file, the ordering check will
434
+ // fire a more precise "sequence violation" error for the same file.
435
+ // Suppress the consistency error here to avoid duplicate noise.
436
+ if (allTaskOutputs.has(normalizedFile) && !ownOutputs.has(normalizedFile)) {
437
+ continue;
438
+ }
419
439
  results.push({
420
440
  category: "file",
421
441
  target: file,
@@ -461,6 +481,8 @@ export function checkTaskOrdering(tasks, basePath) {
461
481
  const task = tasks[i];
462
482
  const filesToCheck = [...task.inputs];
463
483
  for (const file of filesToCheck) {
484
+ if (isRuntimeOnlyInput(file))
485
+ continue;
464
486
  if (!shouldValidateInputAsPath(file))
465
487
  continue;
466
488
  const normalizedFile = normalizeFilePath(file);
@@ -6,6 +6,8 @@ You are executing GSD auto-mode.
6
6
 
7
7
  Your working directory is `{{workingDirectory}}`. All file reads, writes, and shell commands MUST operate relative to this directory. Do NOT `cd` to any other directory.
8
8
 
9
+ If any inlined plan, summary, verification command, or prior artifact names an absolute path outside `{{workingDirectory}}`, treat that path as stale context. Convert it to the equivalent relative path under `{{workingDirectory}}` before reading, writing, or executing. If no equivalent path exists under `{{workingDirectory}}`, record a verification failure and stop; do not edit or run commands in another checkout.
10
+
9
11
  ## Mission
10
12
 
11
13
  All slices are complete. Verify the integrated work, persist milestone completion, refresh project state, and write the final record future milestones will rely on.
@@ -14,7 +16,7 @@ Preloaded context includes roadmap, requirements, decisions, project context, an
14
16
 
15
17
  Start with what the excerpts give you. Read full files when the section heads signal richer context you need.
16
18
 
17
- **On-demand Read ordering:** Complete all slice SUMMARY Reads you need for cross-slice synthesis, the Decision Re-evaluation table, and LEARNINGS **before** calling `gsd_complete_milestone` (step 12). Once that tool runs, the milestone is marked complete in the DB, so it must be the final persistent milestone-closeout write.
19
+ **On-demand Read ordering:** Complete all slice SUMMARY Reads you need for cross-slice synthesis, the Decision Re-evaluation table, and LEARNINGS **before** calling `gsd_complete_milestone` (step 13). Once that tool runs, the milestone is marked complete in the DB, so it must be the final persistent milestone-closeout write.
18
20
 
19
21
  ### Closeout Review Mode
20
22
 
@@ -43,7 +45,7 @@ Subagents report only; they do not write user source. Fold any findings into Dec
43
45
 
44
46
  ### Verification Gate — STOP if verification failed
45
47
 
46
- **If ANY verification failure was recorded in steps 3, 4, or 5, you MUST follow the failure path below. Do NOT proceed with steps 913.**
48
+ **If ANY verification failure was recorded in steps 4, 5, or 6, you MUST follow the failure path below. Do NOT proceed with steps 1014.**
47
49
 
48
50
  **Failure path** (verification failed):
49
51
  - Do NOT call `gsd_complete_milestone`.
@@ -67,13 +69,15 @@ Subagents report only; they do not write user source. Fold any findings into Dec
67
69
  - `title` (string) — Milestone title
68
70
  - `oneLiner` (string) — One-sentence summary of what the milestone achieved
69
71
  - `narrative` (string) — Detailed narrative of what happened during the milestone
72
+ - `verificationPassed` (boolean) — Must be `true`; confirms code-change verification, success criteria, and definition-of-done checks all passed
73
+
74
+ **Recommended parameters** (the schema accepts these as optional, but always fill them in — omitted values render as placeholders such as "Not provided.", "None.", or "(none)"):
70
75
  - `successCriteriaResults` (string) — Markdown detailing how each success criterion was met or not met
71
76
  - `definitionOfDoneResults` (string) — Markdown detailing how each definition-of-done item was met
72
77
  - `requirementOutcomes` (string) — Markdown detailing requirement status transitions with evidence
73
78
  - `keyDecisions` (array of strings) — Key architectural/pattern decisions made during the milestone
74
79
  - `keyFiles` (array of strings) — Key files created or modified during the milestone
75
80
  - `lessonsLearned` (array of strings) — Lessons learned during the milestone
76
- - `verificationPassed` (boolean) — Must be `true`; confirms code-change verification, success criteria, and definition-of-done checks all passed
77
81
 
78
82
  **Optional parameters:**
79
83
  - `followUps` (string) — Follow-up items for future milestones
@@ -82,6 +86,6 @@ Subagents report only; they do not write user source. Fold any findings into Dec
82
86
  14. Do not commit manually — the system auto-commits your changes after this unit completes.
83
87
  - Say: "Milestone {{milestoneId}} complete."
84
88
 
85
- **Important:** Do NOT skip code-change, success-criteria, or definition-of-done verification (steps 3-5). The summary must reflect verified outcomes. Verification failures block completion; there is no override. If a verification tool fails, errors, or returns unexpected output, treat it as failure.
89
+ **Important:** Do NOT skip code-change, success-criteria, or definition-of-done verification (steps 4-6). The summary must reflect verified outcomes. Verification failures block completion; there is no override. If a verification tool fails, errors, or returns unexpected output, treat it as failure.
86
90
 
87
91
  **File system safety:** When scanning milestone directories for evidence, use `ls` or `find` first. Never pass a directory path (e.g. `tasks/`, `slices/`) to `read`; it only accepts file paths.
@@ -29,7 +29,7 @@ Use `subagent` only for fresh-context review when useful: reviewer for cross-cut
29
29
  7. If requirement status changed, call `gsd_requirement_update`; do not write `.gsd/REQUIREMENTS.md` directly.
30
30
  8. Prepare `gsd_slice_complete` content with camelCase fields `milestoneId`, `sliceId`, `sliceTitle`, `oneLiner`, `narrative`, `verification`, and `uatContent`.
31
31
  9. Draft concrete UAT with preconditions, numbered steps, expected outcomes, edge cases, UAT Type, and Not Proven By This UAT.
32
- 10. Review task summaries for DECISIONS.md and KNOWLEDGE.md-worthy decisions, patterns, and gotchas. Capture significant items with `capture_thought`; do not append knowledge files directly.
32
+ 10. Review the inlined task-summary excerpts for DECISIONS.md and KNOWLEDGE.md-worthy decisions, patterns, and gotchas. Read full `*-SUMMARY.md` files only when an excerpt is absent, truncated, or lacks the specific evidence needed for the slice narrative. Capture significant items with `capture_thought`; do not append knowledge files directly.
33
33
  11. Call `gsd_slice_complete`. The DB-backed tool is the canonical write path. Do **not** manually write `{{sliceSummaryPath}}`. Do **not** manually write `{{sliceUatPath}}`. Do not edit roadmap checkboxes; the tool renders files and updates projections.
34
34
  12. Do not run git commands.
35
35
  13. Update `.gsd/PROJECT.md` with a full `write` only if the current project state needs refresh.
@@ -33,7 +33,7 @@ You execute. The inlined task plan is authoritative. Verify referenced files and
33
33
  ## Execution Rules
34
34
 
35
35
  1. Tersely narrate transitions, decisions, and verification outcomes between tool-call clusters.
36
- 2. Call `memory_query` with 2-4 keywords from the task title and touched files unless this is purely mechanical.
36
+ 2. Use the injected memory/context blocks first. Call `memory_query` with 2-4 keywords from the task title and touched files only when no injected memory block exists or the inlined memory/context is insufficient for this task.
37
37
  3. {{skillActivation}} Follow activated skills before code edits.
38
38
  4. Execute the task plan. Before any `Write` that creates an artifact or output file, check whether that path already exists. If it does, read it first and decide whether the work is already done, should be extended, or truly needs replacement.
39
39
  5. Build real behavior through the intended surface; stubs/mocks belong in tests only.
@@ -59,11 +59,13 @@ Keep about **{{verificationBudget}}** for verification and summary. If context i
59
59
  - If the plan is fundamentally invalid, set `blocker_discovered: true` in the summary and explain.
60
60
  - For downstream-impacting ambiguity that cannot be resolved from code, plans, or decisions, include an `escalation` object with question, options, recommendation, rationale, and `continueWithDefault`.
61
61
  - Capture meaningful architecture/pattern/observability decisions with `capture_thought`; capture non-obvious gotchas or conventions only when they save future investigation.
62
- - Read the template at `{{taskSummaryTemplatePath}}`.
62
+ - Use the inlined Task Summary template below. Read `{{taskSummaryTemplatePath}}` only if the inlined template is absent or visibly truncated.
63
63
  - Call `gsd_task_complete` with camelCase fields `milestoneId`, `sliceId`, `taskId`, `oneLiner`, `narrative`, `verification`, and `verificationEvidence`.
64
64
  - The DB-backed tool is the canonical write path. Do **not** manually write `{{taskSummaryPath}}` or edit PLAN.md checkboxes; the tool renders the summary and updates state.
65
65
  - Do not run git commands; the system commits from your summary.
66
66
 
67
+ {{inlinedTemplates}}
68
+
67
69
  **Autonomous execution:** no human is available. Do not call `ask_user_questions` or `secure_env_collect`; make reasonable assumptions and document them.
68
70
 
69
71
  **You MUST call `gsd_task_complete` before finishing.**
@@ -39,7 +39,7 @@ If slice research is inlined, trust it. Explore enough code to confirm paths, bo
39
39
  5. Define slice verification before tasks. Non-trivial slices need real tests or executable assertions; boundary contracts need contract-exercising checks. Tests must not read .gitignore/gitignored paths such as `.gsd/`, `.planning/`, or `.audits/`.
40
40
  6. Include Threat Surface (Q3), Requirement Impact (Q4), proof level, observability, integration closure, Failure Modes (Q5), Load Profile (Q6), and Negative Tests (Q7) only where applicable.
41
41
  7. Right-size tasks. Simple slices can be one task; split only when context, ownership, or verification boundaries justify it.
42
- 8. Each task needs a concrete title, Why / Files / Do / Verify / Done when, plus task-plan description, steps, must-haves, verification, inputs, and expected output. Inputs and Expected Output must include concrete backtick-wrapped paths; each task needs at least one output path. Use paths relative to `{{workingDirectory}}`; do not put absolute paths to the original checkout or any directory outside `{{workingDirectory}}` in `files`, `inputs`, `expectedOutput`, or verification commands.
42
+ 8. Each task needs a concrete title, Why / Files / Do / Verify / Done when, plus task-plan description, steps, must-haves, verification, inputs, and expected output. Inputs and Expected Output must include concrete backtick-wrapped paths. Use paths relative to `{{workingDirectory}}`; do not put absolute paths to the original checkout or any directory outside `{{workingDirectory}}` in `files`, `inputs`, `expectedOutput`, or verification commands. **`expected_output` must only list files the task actually creates or overwrites on disk.** Do NOT include files the task merely reads, verifies, or tests — those belong only in `inputs`. If a task is a pure verification or test task that produces no new files, its `expected_output` may be empty or limited to test-result artifacts (e.g. a log or assertion output). A file that does not yet exist on disk and is needed as an `input` must be produced by an earlier task's `expected_output` — if no prior task creates it, add a task before this one that does.
43
43
  9. Persist with `gsd_plan_slice` using goal, successCriteria, optional proofLevel/integrationClosure/observabilityImpact, and tasks. `gsd_plan_slice` handles task persistence transactionally and renders `{{outputPath}}` plus task plans; do not call `gsd_plan_task`. The DB-backed tool is the canonical write path. Do **not** rely on direct `PLAN.md` writes as the source of truth.
44
44
  10. Self-audit before finishing: goal/demo closure, requirement coverage, locked decisions, concrete paths, dependency order, wiring, scope size, proof truthfulness, feature completeness, and quality gates. Quality gates: non-trivial slices/tasks include specific Q3-Q7 coverage where applicable.
45
45
  11. If planning creates structural decisions, append them to `.gsd/DECISIONS.md`.
@@ -8,7 +8,7 @@ Your working directory is `{{workingDirectory}}`. All file reads, writes, and sh
8
8
 
9
9
  A completed task reported `blocker_discovered: true`, meaning the current slice plan cannot be executed as-is. Your job is to rewrite the remaining tasks in the slice plan to address the blocker while preserving all completed work.
10
10
 
11
- All relevant context has been preloaded below — the roadmap, current slice plan, the blocker task summary, and decisions are inlined. Start working immediately without re-reading these files.
11
+ All relevant context has been preloaded below — the roadmap, current slice plan, blocker task summary excerpt, and decisions are inlined. Start working immediately without re-reading these files.
12
12
 
13
13
  {{inlinedContext}}
14
14
 
@@ -30,7 +30,7 @@ Consider these captures when rewriting the remaining tasks — they represent th
30
30
 
31
31
  ## Instructions
32
32
 
33
- 1. Read the blocker task summary carefully. Understand exactly what was discovered and why it blocks the current plan.
33
+ 1. Use the inlined blocker summary excerpt first. Read the full blocker task summary only if the excerpt is absent, marked truncated, or lacks the specific blocker evidence needed to replan.
34
34
  2. Analyze the remaining `[ ]` tasks in the slice plan. Determine which are still valid, which need modification, and which should be replaced.
35
35
  3. **Persist replan state through `gsd_replan_slice`.** Call it with: `milestoneId`, `sliceId`, `blockerTaskId`, `blockerDescription`, `whatChanged`, `updatedTasks` (array of task objects with taskId, title, description, estimate, files, verify, inputs, expectedOutput), `removedTaskIds` (array of task ID strings). The tool structurally enforces preservation of completed tasks, writes replan history to the DB, re-renders `{{planPath}}`, and renders `{{replanPath}}`. Preserve or update the Threat Surface and Requirement Impact sections if the replan changes the slice's security posture or requirement coverage.
36
36
  4. If any incomplete task had a `T0x-PLAN.md`, remove or rewrite it to match the new task description.
@@ -1,3 +1,5 @@
1
+ // Project/App: GSD-2
2
+ // File Purpose: Slice-cadence merge and milestone resquash git operations.
1
3
  /**
2
4
  * Slice-cadence collapse — #4765.
3
5
  *
@@ -29,6 +31,7 @@ import { logWarning } from "./workflow-logger.js";
29
31
  import { emitSliceMerged, emitMilestoneResquash } from "./worktree-telemetry.js";
30
32
  import { loadEffectiveGSDPreferences } from "./preferences.js";
31
33
  import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
34
+ import { getMilestone, getSlice, isDbAvailable } from "./gsd-db.js";
32
35
  /**
33
36
  * Auto-worktree milestone branch name. Must match autoWorktreeBranch() in
34
37
  * auto-worktree.ts; duplicated here to avoid a cyclic import.
@@ -59,6 +62,46 @@ function cleanupMergeArtifacts(projectRoot) {
59
62
  logWarning("worktree", `merge artifact cleanup failed: ${err instanceof Error ? err.message : String(err)}`);
60
63
  }
61
64
  }
65
+ function stripKnownIdPrefix(value, id) {
66
+ const raw = String(value ?? "").trim();
67
+ if (!raw)
68
+ return undefined;
69
+ const lower = raw.toLowerCase();
70
+ const idLower = id.toLowerCase();
71
+ if (lower.startsWith(`${idLower}:`))
72
+ return raw.slice(id.length + 1).trim() || undefined;
73
+ return raw;
74
+ }
75
+ function getSliceMergeNames(milestoneId, sliceId) {
76
+ if (!isDbAvailable())
77
+ return {};
78
+ return {
79
+ milestoneTitle: stripKnownIdPrefix(getMilestone(milestoneId)?.title, milestoneId),
80
+ sliceTitle: stripKnownIdPrefix(getSlice(milestoneId, sliceId)?.title, sliceId),
81
+ };
82
+ }
83
+ function buildSliceMergeCommitMessage(milestoneId, sliceId, milestoneBranch) {
84
+ const names = getSliceMergeNames(milestoneId, sliceId);
85
+ const sliceLabel = names.sliceTitle ?? sliceId;
86
+ const subject = `feat: ${sliceLabel} - ${sliceId} of ${milestoneId} (slice-cadence)`;
87
+ const body = [
88
+ `Slice: ${sliceId}${names.sliceTitle ? ` - ${names.sliceTitle}` : ""}`,
89
+ `Milestone: ${milestoneId}${names.milestoneTitle ? ` - ${names.milestoneTitle}` : ""}`,
90
+ `GSD-Slice: ${sliceId}`,
91
+ `GSD-Milestone: ${milestoneId}`,
92
+ `Branch: ${milestoneBranch}`,
93
+ ];
94
+ return `${subject}\n\n${body.join("\n")}`;
95
+ }
96
+ function buildMilestoneResquashCommitMessage(milestoneId, sliceCount) {
97
+ const milestoneTitle = isDbAvailable()
98
+ ? stripKnownIdPrefix(getMilestone(milestoneId)?.title, milestoneId)
99
+ : undefined;
100
+ const subject = milestoneTitle
101
+ ? `feat: ${milestoneTitle} (${milestoneId}, ${sliceCount} slices re-squashed)`
102
+ : `feat: ${milestoneId} (${sliceCount} slices re-squashed)`;
103
+ return `${subject}\n\nMilestone: ${milestoneId}${milestoneTitle ? ` - ${milestoneTitle}` : ""}\nGSD-Milestone: ${milestoneId}`;
104
+ }
62
105
  function advanceMilestoneBranch(projectRoot, worktreeCwd, milestoneBranch, mainBranch) {
63
106
  let worktreeBranch = null;
64
107
  try {
@@ -173,7 +216,7 @@ export function mergeSliceToMain(projectRoot, milestoneId, sliceId) {
173
216
  throw new MergeConflictError(conflictedFiles, "squash", milestoneBranch, mainBranch);
174
217
  }
175
218
  // Commit the squash with a slice-scoped message
176
- const commitSha = nativeCommit(projectRoot, `gsd: merge ${sliceId} of ${milestoneId} (slice-cadence)`);
219
+ const commitSha = nativeCommit(projectRoot, buildSliceMergeCommitMessage(milestoneId, sliceId, milestoneBranch));
177
220
  // Advance the milestone branch to main so the next slice's commits start
178
221
  // from a clean base. When the milestone branch is checked out in an auto
179
222
  // worktree, Git refuses a project-root branch -f; reset from inside the
@@ -255,7 +298,7 @@ export function resquashMilestoneOnMain(projectRoot, milestoneId, startSha) {
255
298
  stdio: ["ignore", "pipe", "pipe"],
256
299
  encoding: "utf-8",
257
300
  });
258
- const newSha = nativeCommit(projectRoot, `gsd: complete milestone ${milestoneId} (${sliceCount} slices re-squashed)`, { allowEmpty: true });
301
+ const newSha = nativeCommit(projectRoot, buildMilestoneResquashCommitMessage(milestoneId, sliceCount), { allowEmpty: true });
259
302
  try {
260
303
  emitMilestoneResquash(projectRoot, milestoneId, {
261
304
  sliceCount,