gsd-pi 2.82.0-dev.ed17d078d → 3.0.0-dev.2e8b124f7

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 (580) hide show
  1. package/README.md +93 -18
  2. package/dist/cli.js +20 -9
  3. package/dist/headless-ui.js +13 -6
  4. package/dist/headless.js +9 -2
  5. package/dist/resources/.managed-resources-content-hash +1 -1
  6. package/dist/resources/GSD-WORKFLOW.md +10 -1
  7. package/dist/resources/extensions/claude-code-cli/partial-builder.js +2 -1
  8. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +44 -6
  9. package/dist/resources/extensions/cmux/index.js +5 -0
  10. package/dist/resources/extensions/gsd/auto/infra-errors.js +9 -3
  11. package/dist/resources/extensions/gsd/auto/loop.js +110 -37
  12. package/dist/resources/extensions/gsd/auto/orchestrator.js +13 -2
  13. package/dist/resources/extensions/gsd/auto/phases.js +104 -38
  14. package/dist/resources/extensions/gsd/auto/session.js +6 -0
  15. package/dist/resources/extensions/gsd/auto/unit-runner-events.js +7 -1
  16. package/dist/resources/extensions/gsd/auto/workflow-kernel.js +3 -0
  17. package/dist/resources/extensions/gsd/auto/workflow-memory-pressure.js +12 -0
  18. package/dist/resources/extensions/gsd/auto-dashboard.js +66 -1
  19. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +1 -0
  20. package/dist/resources/extensions/gsd/auto-dispatch.js +71 -20
  21. package/dist/resources/extensions/gsd/auto-model-selection.js +2 -0
  22. package/dist/resources/extensions/gsd/auto-post-unit.js +278 -137
  23. package/dist/resources/extensions/gsd/auto-prompts.js +36 -10
  24. package/dist/resources/extensions/gsd/auto-recovery.js +79 -14
  25. package/dist/resources/extensions/gsd/auto-start.js +90 -14
  26. package/dist/resources/extensions/gsd/auto-timers.js +11 -3
  27. package/dist/resources/extensions/gsd/auto-verification.js +102 -34
  28. package/dist/resources/extensions/gsd/auto-worktree.js +178 -11
  29. package/dist/resources/extensions/gsd/auto.js +107 -54
  30. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +31 -7
  31. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +10 -9
  32. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +5 -4
  33. package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +21 -9
  34. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +24 -9
  35. package/dist/resources/extensions/gsd/clean-root-preflight.js +170 -8
  36. package/dist/resources/extensions/gsd/commands/catalog.js +10 -1
  37. package/dist/resources/extensions/gsd/commands/handlers/core.js +38 -0
  38. package/dist/resources/extensions/gsd/commands/handlers/ops.js +20 -0
  39. package/dist/resources/extensions/gsd/commands-bootstrap.js +5 -0
  40. package/dist/resources/extensions/gsd/commands-handlers.js +2 -0
  41. package/dist/resources/extensions/gsd/commands-mcp-status.js +9 -0
  42. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +10 -2
  43. package/dist/resources/extensions/gsd/commands-verdict.js +139 -0
  44. package/dist/resources/extensions/gsd/crash-recovery.js +52 -7
  45. package/dist/resources/extensions/gsd/db/milestone-leases.js +24 -0
  46. package/dist/resources/extensions/gsd/db/unit-dispatches.js +3 -2
  47. package/dist/resources/extensions/gsd/db-base-schema.js +2 -0
  48. package/dist/resources/extensions/gsd/db-migration-steps.js +4 -0
  49. package/dist/resources/extensions/gsd/db-task-slice-rows.js +2 -0
  50. package/dist/resources/extensions/gsd/dispatch-guard.js +46 -2
  51. package/dist/resources/extensions/gsd/docs/preferences-reference.md +8 -0
  52. package/dist/resources/extensions/gsd/doctor-git-checks.js +46 -1
  53. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +28 -11
  54. package/dist/resources/extensions/gsd/doctor.js +2 -28
  55. package/dist/resources/extensions/gsd/export-html.js +27 -425
  56. package/dist/resources/extensions/gsd/forensics.js +10 -3
  57. package/dist/resources/extensions/gsd/git-service.js +138 -10
  58. package/dist/resources/extensions/gsd/gsd-db.js +76 -33
  59. package/dist/resources/extensions/gsd/guided-flow-queue.js +4 -3
  60. package/dist/resources/extensions/gsd/guided-flow.js +110 -117
  61. package/dist/resources/extensions/gsd/guided-unit-context.js +23 -0
  62. package/dist/resources/extensions/gsd/init-wizard.js +17 -2
  63. package/dist/resources/extensions/gsd/markdown-renderer.js +14 -11
  64. package/dist/resources/extensions/gsd/mcp-filter.js +58 -0
  65. package/dist/resources/extensions/gsd/migrate/parsers.js +10 -0
  66. package/dist/resources/extensions/gsd/migration-auto-check.js +12 -17
  67. package/dist/resources/extensions/gsd/milestone-actions.js +11 -4
  68. package/dist/resources/extensions/gsd/native-git-bridge.js +57 -14
  69. package/dist/resources/extensions/gsd/parallel-orchestrator.js +3 -0
  70. package/dist/resources/extensions/gsd/paths.js +4 -0
  71. package/dist/resources/extensions/gsd/pending-auto-start.js +52 -0
  72. package/dist/resources/extensions/gsd/planning-path-scope.js +9 -3
  73. package/dist/resources/extensions/gsd/post-execution-checks.js +73 -9
  74. package/dist/resources/extensions/gsd/pre-execution-checks.js +38 -11
  75. package/dist/resources/extensions/gsd/preferences-mcp.js +19 -0
  76. package/dist/resources/extensions/gsd/preferences-types.js +2 -0
  77. package/dist/resources/extensions/gsd/preferences-validation.js +138 -0
  78. package/dist/resources/extensions/gsd/preferences.js +2 -0
  79. package/dist/resources/extensions/gsd/prompt-loader.js +1 -1
  80. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  81. package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  82. package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  83. package/dist/resources/extensions/gsd/prompts/discuss.md +9 -9
  84. package/dist/resources/extensions/gsd/prompts/forensics.md +3 -3
  85. package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  86. package/dist/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  87. package/dist/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  88. package/dist/resources/extensions/gsd/prompts/queue.md +4 -4
  89. package/dist/resources/extensions/gsd/prompts/reactive-execute.md +1 -1
  90. package/dist/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  91. package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  92. package/dist/resources/extensions/gsd/queue-reorder-ui.js +30 -13
  93. package/dist/resources/extensions/gsd/repository-registry.js +44 -0
  94. package/dist/resources/extensions/gsd/safety/evidence-collector.js +2 -0
  95. package/dist/resources/extensions/gsd/safety/evidence-cross-ref.js +42 -18
  96. package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +59 -2
  97. package/dist/resources/extensions/gsd/smart-entry-routing.js +36 -0
  98. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
  99. package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +9 -14
  100. package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +19 -24
  101. package/dist/resources/extensions/gsd/state.js +14 -4
  102. package/dist/resources/extensions/gsd/status-guards.js +14 -2
  103. package/dist/resources/extensions/gsd/templates/plan.md +9 -5
  104. package/dist/resources/extensions/gsd/templates/task-plan.md +10 -2
  105. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -8
  106. package/dist/resources/extensions/gsd/tools/complete-slice.js +6 -8
  107. package/dist/resources/extensions/gsd/tools/plan-milestone.js +7 -1
  108. package/dist/resources/extensions/gsd/tools/plan-slice.js +151 -15
  109. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +119 -0
  110. package/dist/resources/extensions/gsd/unit-context-composer.js +2 -0
  111. package/dist/resources/extensions/gsd/unit-context-manifest.js +69 -17
  112. package/dist/resources/extensions/gsd/validation.js +23 -1
  113. package/dist/resources/extensions/gsd/verification-gate.js +142 -7
  114. package/dist/resources/extensions/gsd/verification-verdict.js +26 -0
  115. package/dist/resources/extensions/gsd/workflow-manifest.js +2 -0
  116. package/dist/resources/extensions/gsd/workflow-mcp.js +17 -1
  117. package/dist/resources/extensions/gsd/workflow-projections.js +6 -8
  118. package/dist/resources/extensions/gsd/worktree-lifecycle.js +83 -19
  119. package/dist/resources/extensions/gsd/worktree-manager.js +11 -2
  120. package/dist/resources/extensions/gsd/worktree-safety.js +33 -1
  121. package/dist/resources/extensions/gsd/worktree-state-projection.js +31 -0
  122. package/dist/resources/extensions/shared/html-shell.js +388 -0
  123. package/dist/resources/extensions/shared/interview-ui.js +6 -4
  124. package/dist/resources/extensions/subagent/index.js +448 -78
  125. package/dist/resources/extensions/subagent/launch.js +77 -0
  126. package/dist/resources/extensions/subagent/run-store.js +148 -0
  127. package/dist/resources/extensions/ttsr/ttsr-manager.js +3 -1
  128. package/dist/resources/extensions/visual-brief/artifact-policy.js +29 -0
  129. package/dist/resources/extensions/visual-brief/extension-manifest.json +8 -0
  130. package/dist/resources/extensions/visual-brief/index.js +5 -0
  131. package/dist/resources/extensions/visual-brief/page-contract.js +124 -0
  132. package/dist/resources/extensions/visual-brief/prompts.js +140 -0
  133. package/dist/resources/skills/forensics/SKILL.md +1 -1
  134. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  135. package/dist/web/standalone/.next/BUILD_ID +1 -1
  136. package/dist/web/standalone/.next/app-path-routes-manifest.json +10 -10
  137. package/dist/web/standalone/.next/build-manifest.json +3 -3
  138. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  139. package/dist/web/standalone/.next/react-loadable-manifest.json +5 -5
  140. package/dist/web/standalone/.next/required-server-files.json +1 -1
  141. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  142. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  143. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  144. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  145. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  146. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  147. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  148. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  149. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  150. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  151. package/dist/web/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  152. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  153. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  154. package/dist/web/standalone/.next/server/app/_not-found.rsc +4 -7
  155. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
  156. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  157. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +4 -5
  158. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  159. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  160. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -5
  161. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  162. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  163. package/dist/web/standalone/.next/server/app/index.html +1 -1
  164. package/dist/web/standalone/.next/server/app/index.rsc +4 -7
  165. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  166. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -7
  167. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  168. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +4 -5
  169. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
  170. package/dist/web/standalone/.next/server/app/page.js +2 -2
  171. package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
  172. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  173. package/dist/web/standalone/.next/server/app-paths-manifest.json +10 -10
  174. package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
  175. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  176. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  177. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  178. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  179. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  180. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  181. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  182. package/dist/web/standalone/.next/static/chunks/2973.33f26573894b6153.js +2 -0
  183. package/dist/web/standalone/.next/static/chunks/8359.65b24fac92188a6b.js +10 -0
  184. package/dist/web/standalone/.next/static/chunks/9441.ff70bb53f6835771.js +1 -0
  185. package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
  186. package/dist/web/standalone/.next/static/chunks/{webpack-de742b64187e13fe.js → webpack-855d616060cb6e59.js} +1 -1
  187. package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
  188. package/dist/web/standalone/server.js +1 -1
  189. package/package.json +4 -4
  190. package/packages/contracts/dist/rpc.test.js +7 -0
  191. package/packages/contracts/dist/rpc.test.js.map +1 -1
  192. package/packages/contracts/dist/workflow.d.ts +21 -0
  193. package/packages/contracts/dist/workflow.d.ts.map +1 -1
  194. package/packages/contracts/dist/workflow.js +24 -0
  195. package/packages/contracts/dist/workflow.js.map +1 -1
  196. package/packages/contracts/src/rpc.test.ts +8 -0
  197. package/packages/contracts/src/workflow.ts +24 -0
  198. package/packages/daemon/package.json +2 -2
  199. package/packages/mcp-server/README.md +13 -4
  200. package/packages/mcp-server/dist/workflow-tools.d.ts +0 -3
  201. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  202. package/packages/mcp-server/dist/workflow-tools.js +80 -0
  203. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  204. package/packages/mcp-server/package.json +2 -2
  205. package/packages/mcp-server/src/workflow-tools.test.ts +23 -1
  206. package/packages/mcp-server/src/workflow-tools.ts +168 -0
  207. package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
  208. package/packages/native/package.json +1 -1
  209. package/packages/native/tsconfig.json +2 -1
  210. package/packages/native/tsconfig.tsbuildinfo +1 -1
  211. package/packages/pi-agent-core/package.json +1 -1
  212. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  213. package/packages/pi-ai/dist/providers/google-gemini-cli.js +5 -0
  214. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  215. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts +2 -0
  216. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts.map +1 -0
  217. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js +41 -0
  218. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js.map +1 -0
  219. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  220. package/packages/pi-ai/dist/providers/openai-codex-responses.js +82 -1
  221. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  222. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts +2 -0
  223. package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts.map +1 -0
  224. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +52 -0
  225. package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -0
  226. package/packages/pi-ai/dist/providers/simple-options.d.ts +2 -4
  227. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  228. package/packages/pi-ai/dist/providers/simple-options.js +5 -6
  229. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
  230. package/packages/pi-ai/dist/providers/simple-options.test.d.ts +2 -0
  231. package/packages/pi-ai/dist/providers/simple-options.test.d.ts.map +1 -0
  232. package/packages/pi-ai/dist/providers/simple-options.test.js +50 -0
  233. package/packages/pi-ai/dist/providers/simple-options.test.js.map +1 -0
  234. package/packages/pi-ai/package.json +1 -1
  235. package/packages/pi-ai/src/providers/google-gemini-cli.test.ts +49 -0
  236. package/packages/pi-ai/src/providers/google-gemini-cli.ts +7 -0
  237. package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
  238. package/packages/pi-ai/src/providers/openai-codex-responses.ts +91 -1
  239. package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
  240. package/packages/pi-ai/src/providers/simple-options.ts +5 -6
  241. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  242. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts +2 -0
  243. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts.map +1 -0
  244. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js +66 -0
  245. package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js.map +1 -0
  246. package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
  247. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  248. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +44 -3
  249. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  250. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +6 -1
  251. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  252. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +7 -2
  253. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  254. package/packages/pi-coding-agent/dist/core/compaction/compaction.test.js +14 -1
  255. package/packages/pi-coding-agent/dist/core/compaction/compaction.test.js.map +1 -1
  256. package/packages/pi-coding-agent/dist/core/sdk.js +1 -1
  257. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  258. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +8 -2
  259. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  260. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  261. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +24 -6
  262. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  263. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -1
  264. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  265. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  266. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +71 -97
  267. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  268. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +7 -7
  269. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
  270. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +11 -0
  271. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
  272. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +25 -1
  273. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -1
  274. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +2 -0
  275. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  276. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +24 -10
  277. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  278. package/packages/pi-coding-agent/package.json +1 -1
  279. package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
  280. package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
  281. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +53 -3
  282. package/packages/pi-coding-agent/src/core/compaction/compaction.test.ts +23 -1
  283. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +7 -2
  284. package/packages/pi-coding-agent/src/core/sdk.ts +1 -1
  285. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +17 -1
  286. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +23 -7
  287. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -1
  288. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +75 -102
  289. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +15 -1
  290. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +9 -9
  291. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +30 -1
  292. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +29 -10
  293. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  294. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts +2 -0
  295. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts.map +1 -0
  296. package/packages/pi-tui/dist/__tests__/terminal.test.js +103 -0
  297. package/packages/pi-tui/dist/__tests__/terminal.test.js.map +1 -0
  298. package/packages/pi-tui/dist/__tests__/tui.test.js +45 -2
  299. package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
  300. package/packages/pi-tui/dist/terminal.d.ts +2 -0
  301. package/packages/pi-tui/dist/terminal.d.ts.map +1 -1
  302. package/packages/pi-tui/dist/terminal.js +12 -0
  303. package/packages/pi-tui/dist/terminal.js.map +1 -1
  304. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  305. package/packages/pi-tui/dist/tui.js +106 -27
  306. package/packages/pi-tui/dist/tui.js.map +1 -1
  307. package/packages/pi-tui/package.json +1 -1
  308. package/packages/pi-tui/src/__tests__/terminal.test.ts +121 -0
  309. package/packages/pi-tui/src/__tests__/tui.test.ts +59 -2
  310. package/packages/pi-tui/src/terminal.ts +11 -0
  311. package/packages/pi-tui/src/tui.ts +108 -27
  312. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  313. package/packages/rpc-client/package.json +1 -1
  314. package/packages/rpc-client/tsconfig.tsbuildinfo +1 -1
  315. package/pkg/package.json +1 -1
  316. package/src/resources/GSD-WORKFLOW.md +10 -1
  317. package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
  318. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +52 -6
  319. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
  320. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +49 -2
  321. package/src/resources/extensions/cmux/index.ts +6 -0
  322. package/src/resources/extensions/gsd/auto/contracts.ts +17 -6
  323. package/src/resources/extensions/gsd/auto/infra-errors.ts +9 -3
  324. package/src/resources/extensions/gsd/auto/loop.ts +111 -38
  325. package/src/resources/extensions/gsd/auto/orchestrator.ts +13 -2
  326. package/src/resources/extensions/gsd/auto/phases.ts +127 -49
  327. package/src/resources/extensions/gsd/auto/session.ts +16 -0
  328. package/src/resources/extensions/gsd/auto/types.ts +3 -0
  329. package/src/resources/extensions/gsd/auto/unit-runner-events.ts +6 -2
  330. package/src/resources/extensions/gsd/auto/workflow-kernel.ts +5 -1
  331. package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +13 -0
  332. package/src/resources/extensions/gsd/auto-dashboard.ts +72 -1
  333. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +1 -0
  334. package/src/resources/extensions/gsd/auto-dispatch.ts +74 -20
  335. package/src/resources/extensions/gsd/auto-model-selection.ts +2 -1
  336. package/src/resources/extensions/gsd/auto-post-unit.ts +312 -148
  337. package/src/resources/extensions/gsd/auto-prompts.ts +36 -13
  338. package/src/resources/extensions/gsd/auto-recovery.ts +83 -11
  339. package/src/resources/extensions/gsd/auto-start.ts +99 -12
  340. package/src/resources/extensions/gsd/auto-timers.ts +10 -3
  341. package/src/resources/extensions/gsd/auto-verification.ts +124 -42
  342. package/src/resources/extensions/gsd/auto-worktree.ts +195 -11
  343. package/src/resources/extensions/gsd/auto.ts +100 -42
  344. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +42 -7
  345. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +10 -9
  346. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +5 -4
  347. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +19 -7
  348. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +27 -10
  349. package/src/resources/extensions/gsd/clean-root-preflight.ts +174 -8
  350. package/src/resources/extensions/gsd/commands/catalog.ts +10 -1
  351. package/src/resources/extensions/gsd/commands/handlers/core.ts +41 -0
  352. package/src/resources/extensions/gsd/commands/handlers/ops.ts +21 -0
  353. package/src/resources/extensions/gsd/commands-bootstrap.ts +10 -0
  354. package/src/resources/extensions/gsd/commands-handlers.ts +2 -0
  355. package/src/resources/extensions/gsd/commands-mcp-status.ts +8 -0
  356. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +11 -3
  357. package/src/resources/extensions/gsd/commands-verdict.ts +202 -0
  358. package/src/resources/extensions/gsd/crash-recovery.ts +52 -6
  359. package/src/resources/extensions/gsd/db/milestone-leases.ts +26 -0
  360. package/src/resources/extensions/gsd/db/unit-dispatches.ts +4 -3
  361. package/src/resources/extensions/gsd/db-base-schema.ts +2 -0
  362. package/src/resources/extensions/gsd/db-migration-steps.ts +5 -0
  363. package/src/resources/extensions/gsd/db-task-slice-rows.ts +4 -0
  364. package/src/resources/extensions/gsd/dispatch-guard.ts +60 -2
  365. package/src/resources/extensions/gsd/docs/preferences-reference.md +8 -0
  366. package/src/resources/extensions/gsd/doctor-git-checks.ts +45 -1
  367. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +25 -13
  368. package/src/resources/extensions/gsd/doctor-types.ts +1 -0
  369. package/src/resources/extensions/gsd/doctor.ts +2 -27
  370. package/src/resources/extensions/gsd/export-html.ts +27 -427
  371. package/src/resources/extensions/gsd/forensics.ts +9 -3
  372. package/src/resources/extensions/gsd/git-service.ts +166 -11
  373. package/src/resources/extensions/gsd/gsd-db.ts +80 -31
  374. package/src/resources/extensions/gsd/guided-flow-queue.ts +4 -3
  375. package/src/resources/extensions/gsd/guided-flow.ts +142 -134
  376. package/src/resources/extensions/gsd/guided-unit-context.ts +30 -0
  377. package/src/resources/extensions/gsd/init-wizard.ts +17 -2
  378. package/src/resources/extensions/gsd/journal.ts +8 -1
  379. package/src/resources/extensions/gsd/markdown-renderer.ts +14 -11
  380. package/src/resources/extensions/gsd/mcp-filter.ts +80 -0
  381. package/src/resources/extensions/gsd/migrate/parsers.ts +11 -0
  382. package/src/resources/extensions/gsd/migration-auto-check.ts +15 -23
  383. package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
  384. package/src/resources/extensions/gsd/native-git-bridge.ts +63 -14
  385. package/src/resources/extensions/gsd/parallel-orchestrator.ts +3 -0
  386. package/src/resources/extensions/gsd/paths.ts +5 -0
  387. package/src/resources/extensions/gsd/pending-auto-start.ts +79 -0
  388. package/src/resources/extensions/gsd/planning-path-scope.ts +10 -2
  389. package/src/resources/extensions/gsd/post-execution-checks.ts +87 -12
  390. package/src/resources/extensions/gsd/pre-execution-checks.ts +49 -11
  391. package/src/resources/extensions/gsd/preferences-mcp.ts +27 -0
  392. package/src/resources/extensions/gsd/preferences-types.ts +33 -0
  393. package/src/resources/extensions/gsd/preferences-validation.ts +145 -0
  394. package/src/resources/extensions/gsd/preferences.ts +5 -0
  395. package/src/resources/extensions/gsd/prompt-loader.ts +1 -1
  396. package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  397. package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
  398. package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
  399. package/src/resources/extensions/gsd/prompts/discuss.md +9 -9
  400. package/src/resources/extensions/gsd/prompts/forensics.md +3 -3
  401. package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
  402. package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
  403. package/src/resources/extensions/gsd/prompts/plan-slice.md +4 -4
  404. package/src/resources/extensions/gsd/prompts/queue.md +4 -4
  405. package/src/resources/extensions/gsd/prompts/reactive-execute.md +1 -1
  406. package/src/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  407. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  408. package/src/resources/extensions/gsd/queue-reorder-ui.ts +31 -13
  409. package/src/resources/extensions/gsd/repository-registry.ts +77 -0
  410. package/src/resources/extensions/gsd/safety/evidence-collector.ts +2 -0
  411. package/src/resources/extensions/gsd/safety/evidence-cross-ref.ts +54 -19
  412. package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +52 -1
  413. package/src/resources/extensions/gsd/smart-entry-routing.ts +77 -0
  414. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
  415. package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +12 -15
  416. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +17 -25
  417. package/src/resources/extensions/gsd/state.ts +15 -4
  418. package/src/resources/extensions/gsd/status-guards.ts +16 -2
  419. package/src/resources/extensions/gsd/templates/plan.md +9 -5
  420. package/src/resources/extensions/gsd/templates/task-plan.md +10 -2
  421. package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +10 -1
  422. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +71 -0
  423. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
  424. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +300 -1
  425. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +197 -11
  426. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +151 -12
  427. package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +53 -2
  428. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +18 -6
  429. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +129 -6
  430. package/src/resources/extensions/gsd/tests/auto-retry-mcp-churn-fixes.test.ts +12 -0
  431. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +1 -0
  432. package/src/resources/extensions/gsd/tests/auto-stop-notification.test.ts +20 -0
  433. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
  434. package/src/resources/extensions/gsd/tests/autocomplete-regressions-1675.test.ts +21 -0
  435. package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
  436. package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +87 -0
  437. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +107 -2
  438. package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +32 -4
  439. package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
  440. package/src/resources/extensions/gsd/tests/commands-verdict.test.ts +378 -0
  441. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +4 -1
  442. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +5 -9
  443. package/src/resources/extensions/gsd/tests/complete-task.test.ts +3 -1
  444. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +104 -2
  445. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
  446. package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +208 -0
  447. package/src/resources/extensions/gsd/tests/db-task-slice-rows.test.ts +1 -0
  448. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +61 -2
  449. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +111 -1
  450. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +68 -1
  451. package/src/resources/extensions/gsd/tests/doctor-empty-worktree.test.ts +65 -0
  452. package/src/resources/extensions/gsd/tests/doctor-forensics-db-open-regression.test.ts +50 -0
  453. package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +97 -0
  454. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
  455. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +28 -0
  456. package/src/resources/extensions/gsd/tests/gsdroot-worktree-detection.test.ts +5 -2
  457. package/src/resources/extensions/gsd/tests/guided-discuss-project-prompt-rendering.test.ts +2 -0
  458. package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +106 -0
  459. package/src/resources/extensions/gsd/tests/guided-flow-session-isolation.test.ts +59 -11
  460. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
  461. package/src/resources/extensions/gsd/tests/guided-tool-contract.test.ts +65 -0
  462. package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +7 -7
  463. package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +5 -0
  464. package/src/resources/extensions/gsd/tests/infra-error.test.ts +2 -2
  465. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +9 -0
  466. package/src/resources/extensions/gsd/tests/init-prefs-routing.test.ts +22 -0
  467. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +20 -0
  468. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +199 -2
  469. package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +6 -1
  470. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +49 -3
  471. package/src/resources/extensions/gsd/tests/journal.test.ts +32 -0
  472. package/src/resources/extensions/gsd/tests/mcp-filter.test.ts +287 -0
  473. package/src/resources/extensions/gsd/tests/mcp-status.test.ts +11 -0
  474. package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +179 -0
  475. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +24 -1
  476. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +26 -18
  477. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +80 -2
  478. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +121 -1
  479. package/src/resources/extensions/gsd/tests/parallel-orchestrator-zombie-cleanup.test.ts +55 -0
  480. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
  481. package/src/resources/extensions/gsd/tests/pending-autostart-scope.test.ts +29 -5
  482. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +2 -1
  483. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +26 -0
  484. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +2 -0
  485. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +343 -3
  486. package/src/resources/extensions/gsd/tests/plan-task.test.ts +18 -1
  487. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
  488. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +105 -3
  489. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
  490. package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +84 -0
  491. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +59 -0
  492. package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +54 -0
  493. package/src/resources/extensions/gsd/tests/preferences-mcp.test.ts +128 -0
  494. package/src/resources/extensions/gsd/tests/preferences.test.ts +75 -0
  495. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +78 -0
  496. package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
  497. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +37 -1
  498. package/src/resources/extensions/gsd/tests/quality-gates.test.ts +6 -0
  499. package/src/resources/extensions/gsd/tests/queue-reorder-ui.test.ts +54 -0
  500. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +89 -2
  501. package/src/resources/extensions/gsd/tests/repository-registry.test.ts +52 -0
  502. package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +2 -3
  503. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +21 -1
  504. package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +72 -1
  505. package/src/resources/extensions/gsd/tests/smart-entry-routing.test.ts +113 -0
  506. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +86 -2
  507. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +6 -0
  508. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +119 -23
  509. package/src/resources/extensions/gsd/tests/status-guards.test.ts +17 -1
  510. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +64 -1
  511. package/src/resources/extensions/gsd/tests/subagent-model-dispatch.test.ts +2 -1
  512. package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +7 -3
  513. package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +1 -0
  514. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +131 -9
  515. package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +111 -1
  516. package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +29 -2
  517. package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +42 -1
  518. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +173 -1
  519. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
  520. package/src/resources/extensions/gsd/tests/workflow-kernel.test.ts +7 -0
  521. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +19 -1
  522. package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +21 -1
  523. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1 -1
  524. package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
  525. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
  526. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +57 -2
  527. package/src/resources/extensions/gsd/tests/worktree-preferences-sync.test.ts +25 -0
  528. package/src/resources/extensions/gsd/tests/worktree-safety.test.ts +46 -0
  529. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +95 -0
  530. package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +27 -0
  531. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +59 -0
  532. package/src/resources/extensions/gsd/tools/complete-milestone.ts +8 -10
  533. package/src/resources/extensions/gsd/tools/complete-slice.ts +6 -8
  534. package/src/resources/extensions/gsd/tools/plan-milestone.ts +5 -1
  535. package/src/resources/extensions/gsd/tools/plan-slice.ts +172 -12
  536. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +135 -0
  537. package/src/resources/extensions/gsd/types.ts +1 -1
  538. package/src/resources/extensions/gsd/unit-context-composer.ts +3 -0
  539. package/src/resources/extensions/gsd/unit-context-manifest.ts +86 -19
  540. package/src/resources/extensions/gsd/validation.ts +23 -1
  541. package/src/resources/extensions/gsd/verification-gate.ts +170 -6
  542. package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
  543. package/src/resources/extensions/gsd/workflow-manifest.ts +2 -0
  544. package/src/resources/extensions/gsd/workflow-mcp.ts +18 -1
  545. package/src/resources/extensions/gsd/workflow-projections.ts +6 -8
  546. package/src/resources/extensions/gsd/worktree-lifecycle.ts +93 -20
  547. package/src/resources/extensions/gsd/worktree-manager.ts +14 -2
  548. package/src/resources/extensions/gsd/worktree-safety.ts +45 -6
  549. package/src/resources/extensions/gsd/worktree-state-projection.ts +43 -0
  550. package/src/resources/extensions/shared/html-shell.ts +412 -0
  551. package/src/resources/extensions/shared/interview-ui.ts +6 -4
  552. package/src/resources/extensions/shared/tests/interview-notes-loop.test.ts +15 -0
  553. package/src/resources/extensions/subagent/index.ts +567 -103
  554. package/src/resources/extensions/subagent/launch.ts +131 -0
  555. package/src/resources/extensions/subagent/run-store.ts +218 -0
  556. package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
  557. package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
  558. package/src/resources/extensions/ttsr/ttsr-manager.ts +5 -1
  559. package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
  560. package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
  561. package/src/resources/extensions/visual-brief/index.ts +8 -0
  562. package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
  563. package/src/resources/extensions/visual-brief/prompts.ts +183 -0
  564. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
  565. package/src/resources/skills/forensics/SKILL.md +1 -1
  566. package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
  567. package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +0 -1
  568. package/dist/web/standalone/.next/static/chunks/8359.e059d86b255fce1c.js +0 -10
  569. package/dist/web/standalone/.next/static/chunks/9441.1081da1125d1764f.js +0 -1
  570. package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
  571. package/dist/web/standalone/.next/static/css/54ec2745c1da488b.css +0 -1
  572. package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
  573. package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  574. package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  575. package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  576. package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  577. package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  578. package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  579. /package/dist/web/standalone/.next/static/{YEvjuT-fsFfYQhDSWtueS → zCegwxH2e6vLp1vEZLLuZ}/_buildManifest.js +0 -0
  580. /package/dist/web/standalone/.next/static/{YEvjuT-fsFfYQhDSWtueS → zCegwxH2e6vLp1vEZLLuZ}/_ssgManifest.js +0 -0
@@ -10,6 +10,7 @@ import { shouldIgnoreAgentEndForActiveUnit } from "../auto/unit-runner-events.js
10
10
  import { resolveModelId } from "../auto-model-selection.js";
11
11
  import { resolveProjectRoot } from "../worktree.js";
12
12
  import { clearDiscussionFlowState } from "./write-gate.js";
13
+ import { clearGuidedUnitContext } from "../guided-unit-context.js";
13
14
  import { resumeAutoAfterProviderDelay } from "./provider-error-resume.js";
14
15
  import { classifyError, createRetryState, resetRetryState, isTransient, } from "../error-classifier.js";
15
16
  import { blockModel, isModelBlocked } from "../blocked-models.js";
@@ -18,6 +19,9 @@ const MAX_NETWORK_RETRIES = 2;
18
19
  function isObjectRecord(value) {
19
20
  return !!value && typeof value === "object";
20
21
  }
22
+ export function _hasEmptyAgentEndContent(content) {
23
+ return content == null || (Array.isArray(content) && content.length === 0);
24
+ }
21
25
  /**
22
26
  * Cap on auto-resume attempts for sustained transient-provider errors.
23
27
  *
@@ -57,6 +61,11 @@ export function isUserInitiatedAbortMessage(message) {
57
61
  return false;
58
62
  return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
59
63
  }
64
+ export function shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg) {
65
+ if (!isTransient(cls) || cls.kind === "rate-limit")
66
+ return false;
67
+ return !/retry failed after \d+ attempts:/i.test(rawErrorMsg);
68
+ }
60
69
  function isBareClaudeCodeSessionSwitchAbortMarker(message) {
61
70
  if (!message)
62
71
  return false;
@@ -150,6 +159,13 @@ export function resolveAgentEndErrorDisplay(rawErrorMsg, content) {
150
159
  }
151
160
  return rawErrorMsg;
152
161
  }
162
+ export function isTerminalDeletedWorktreeProviderError(message) {
163
+ if (!message)
164
+ return false;
165
+ if (!/\bdoes not exist\b/i.test(message))
166
+ return false;
167
+ return /[/\\]\.gsd[/\\](?:projects[/\\][^/\\]+[/\\])?worktrees[/\\][^/\\\s"']+/i.test(message);
168
+ }
153
169
  async function pauseTransientWithBackoff(cls, pi, ctx, errorDetail, isRateLimit) {
154
170
  retryState.consecutiveTransientCount += 1;
155
171
  const baseRetryAfterMs = "retryAfterMs" in cls ? cls.retryAfterMs : 15_000;
@@ -187,8 +203,10 @@ export async function handleAgentEnd(pi, event, ctx) {
187
203
  // falsely report files as missing — producing a spurious "ready signal
188
204
  // rejected" loop even though the files are on disk.
189
205
  clearPathCache();
206
+ const basePath = resolveAgentEndBasePath();
207
+ clearGuidedUnitContext(basePath);
190
208
  try {
191
- if (await checkDeepProjectSetupAfterTurn(event, ctx, resolveAgentEndBasePath())) {
209
+ if (await checkDeepProjectSetupAfterTurn(event, ctx, basePath)) {
192
210
  return;
193
211
  }
194
212
  }
@@ -196,22 +214,22 @@ export async function handleAgentEnd(pi, event, ctx) {
196
214
  const message = err instanceof Error ? err.message : String(err);
197
215
  logWarning("bootstrap", `checkDeepProjectSetupAfterTurn failed: ${message}`);
198
216
  }
199
- if (checkAutoStartAfterDiscuss()) {
200
- clearDiscussionFlowState(resolveAgentEndBasePath() ?? process.cwd());
217
+ if (checkAutoStartAfterDiscuss(basePath)) {
218
+ clearDiscussionFlowState(basePath ?? process.cwd());
201
219
  return;
202
220
  }
203
221
  // #4573 — When the LLM emits "Milestone X ready." but the required files
204
222
  // are missing, `checkAutoStartAfterDiscuss` returns false silently. Surface
205
223
  // that and nudge the LLM to complete the writes before the user hits the
206
224
  // downstream "All milestones complete" warning loop.
207
- if (maybeHandleReadyPhraseWithoutFiles(event))
225
+ if (maybeHandleReadyPhraseWithoutFiles(event, basePath))
208
226
  return;
209
227
  // #4573 — Empty-turn recovery: if the LLM announced intent in prose but
210
228
  // emitted no tool calls, nudge it to execute. Fires only when auto-mode is
211
229
  // active or a discussion autostart is pending (non-auto interactive discuss
212
230
  // is user-driven). Runs before `isAutoActive` early return so pending
213
231
  // discussions (where isAutoActive may be false) still get recovered.
214
- if (maybeHandleEmptyIntentTurn(event, isAutoActive()))
232
+ if (maybeHandleEmptyIntentTurn(event, isAutoActive(), basePath))
215
233
  return;
216
234
  if (!isAutoActive())
217
235
  return;
@@ -246,7 +264,7 @@ export async function handleAgentEnd(pi, event, ctx) {
246
264
  // that carry error context — e.g. errorMessage field or non-empty content
247
265
  // indicating a mid-stream failure. (#2695)
248
266
  const content = "content" in lastMsg ? lastMsg.content : undefined;
249
- const hasEmptyContent = Array.isArray(content) && content.length === 0;
267
+ const hasEmptyContent = _hasEmptyAgentEndContent(content);
250
268
  const hasErrorMessage = "errorMessage" in lastMsg && !!lastMsg.errorMessage;
251
269
  if (hasEmptyContent && !hasErrorMessage) {
252
270
  // Non-fatal: treat as a normal agent end so the loop can continue
@@ -292,6 +310,12 @@ export async function handleAgentEnd(pi, event, ctx) {
292
310
  // the assistant message text content for display purposes only.
293
311
  // Classification still uses rawErrorMsg to avoid false positives from prose.
294
312
  const displayMsg = resolveAgentEndErrorDisplay(rawErrorMsg, "content" in lastMsg ? lastMsg.content : undefined);
313
+ if (isAutoCompletionStopInProgress() &&
314
+ isTerminalDeletedWorktreeProviderError(`${rawErrorMsg}\n${displayMsg}`)) {
315
+ resetRetryState(retryState);
316
+ logWarning("bootstrap", `Ignoring stale deleted-worktree provider error during terminal completion reroot: ${displayMsg || rawErrorMsg}`);
317
+ return;
318
+ }
295
319
  const errorDetail = displayMsg ? `: ${displayMsg}` : "";
296
320
  const explicitRetryAfterMs = ("retryAfterMs" in lastMsg && typeof lastMsg.retryAfterMs === "number") ? lastMsg.retryAfterMs : undefined;
297
321
  // ── 1. Classify using rawErrorMsg to avoid prose false-positives ────
@@ -375,7 +399,7 @@ export async function handleAgentEnd(pi, event, ctx) {
375
399
  // Core retries transient failures in-session after this handler.
376
400
  // Keep that behavior for non-rate-limit classes to avoid pause/retry races,
377
401
  // but let rate-limit continue into model fallback logic below (#4373).
378
- if (isTransient(cls) && cls.kind !== "rate-limit") {
402
+ if (shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg)) {
379
403
  return;
380
404
  }
381
405
  // Cap rate-limit backoff for CLI-style providers (openai-codex, google-gemini-cli)
@@ -468,17 +468,18 @@ export function registerDbTools(pi) {
468
468
  promptGuidelines: [
469
469
  "Use gsd_plan_milestone for milestone planning instead of writing ROADMAP.md directly.",
470
470
  "Keep parameters flat and provide the full milestone planning payload, including slices.",
471
+ "Milestone and slice titles must not contain forward slash (/), en dash, or em dash characters.",
471
472
  "The tool validates input, writes milestone and slice planning data transactionally, renders ROADMAP.md from DB, and clears both state and parse caches after success.",
472
473
  "Use the canonical name gsd_plan_milestone; gsd_milestone_plan is only an alias.",
473
474
  ],
474
475
  parameters: Type.Object({
475
476
  // ── Core identification + content (required) ──────────────────────
476
477
  milestoneId: Type.String({ description: "Milestone ID (e.g. M001)" }),
477
- title: Type.String({ description: "Milestone title" }),
478
+ title: Type.String({ description: "Milestone title; must not contain forward slash (/), en dash, or em dash characters" }),
478
479
  vision: Type.String({ description: "Milestone vision" }),
479
480
  slices: Type.Array(Type.Object({
480
481
  sliceId: Type.String({ description: "Slice ID (e.g. S01)" }),
481
- title: Type.String({ description: "Slice title" }),
482
+ title: Type.String({ description: "Slice title; must not contain forward slash (/), en dash, or em dash characters" }),
482
483
  risk: Type.String({ description: "Slice risk" }),
483
484
  depends: Type.Array(Type.String(), { description: "Slice dependency IDs" }),
484
485
  demo: Type.String({ description: "Roadmap demo text / After this" }),
@@ -546,10 +547,10 @@ export function registerDbTools(pi) {
546
547
  title: Type.String({ description: "Task title" }),
547
548
  description: Type.String({ description: "Task description / steps block" }),
548
549
  estimate: Type.String({ description: "Task estimate string" }),
549
- files: Type.Array(Type.String(), { description: "Files likely touched" }),
550
+ files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
550
551
  verify: Type.String({ description: "Verification command or block" }),
551
- inputs: Type.Array(Type.String(), { description: "Input files or references" }),
552
- expectedOutput: Type.Array(Type.String(), { description: "Expected output files or artifacts" }),
552
+ inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
553
+ expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
553
554
  observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
554
555
  }), { description: "Planned tasks for the slice" }),
555
556
  // ── Enrichment metadata (optional — defaults to empty) ────────────
@@ -622,10 +623,10 @@ export function registerDbTools(pi) {
622
623
  title: Type.String({ description: "Task title" }),
623
624
  description: Type.String({ description: "Task description / steps block" }),
624
625
  estimate: Type.String({ description: "Task estimate string" }),
625
- files: Type.Array(Type.String(), { description: "Files likely touched" }),
626
+ files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
626
627
  verify: Type.String({ description: "Verification command or block" }),
627
- inputs: Type.Array(Type.String(), { description: "Input files or references" }),
628
- expectedOutput: Type.Array(Type.String(), { description: "Expected output files or artifacts" }),
628
+ inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
629
+ expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
629
630
  observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
630
631
  // Single-writer v3 audit trail (Stream 2): caller-provided actor identity + causation.
631
632
  actorName: Type.Optional(Type.String({ description: "Caller-provided actor identity for the audit trail (e.g. 'executor-01', 'gsd-orchestrator')" })),
@@ -847,7 +848,7 @@ export function registerDbTools(pi) {
847
848
  name: "gsd_skip_slice",
848
849
  label: "Skip Slice",
849
850
  description: "Mark a slice as skipped so auto-mode advances past it without executing. " +
850
- "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks (#4375). " +
851
+ "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks. " +
851
852
  "The slice data is preserved for reference. The state machine treats skipped slices like completed ones for dependency satisfaction.",
852
853
  promptSnippet: "Skip a GSD slice (mark as skipped, auto-mode will advance past it)",
853
854
  promptGuidelines: [
@@ -24,6 +24,7 @@ import { resolveWorktreeProjectRoot } from "../worktree-root.js";
24
24
  import { extractSubagentAgentClasses } from "./subagent-input.js";
25
25
  import { approvalGateIdForUnit, isExplicitApprovalResponse, shouldPauseForUserApprovalQuestion } from "../user-input-boundary.js";
26
26
  import { resolveSkillManifest } from "../skill-manifest.js";
27
+ import { getGuidedUnitContext } from "../guided-unit-context.js";
27
28
  let approvalQuestionAbortInFlight = false;
28
29
  async function loadWelcomeScreenModule() {
29
30
  const candidates = [];
@@ -675,7 +676,8 @@ export function registerHooks(pi, ecosystemHandlers) {
675
676
  // subagent dispatch. Closes the b23 bug class where a discuss-milestone
676
677
  // turn used the host Edit tool to modify user source files.
677
678
  const dash = getAutoRuntimeSnapshot();
678
- const activeUnitType = dash.currentUnit?.type;
679
+ const guidedUnit = getGuidedUnitContext(discussionBasePath);
680
+ const activeUnitType = dash.currentUnit?.type ?? guidedUnit?.unitType;
679
681
  if (activeUnitType) {
680
682
  const manifest = resolveManifest(activeUnitType);
681
683
  if (manifest) {
@@ -694,7 +696,7 @@ export function registerHooks(pi, ecosystemHandlers) {
694
696
  // Subagent inputs use { agent }, { tasks: [{ agent }] }, or { chain: [{ agent }] }.
695
697
  agentClasses = extractSubagentAgentClasses(event.input);
696
698
  }
697
- const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
699
+ const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || guidedUnit?.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
698
700
  if (planningGuard.block)
699
701
  return planningGuard;
700
702
  }
@@ -704,8 +706,7 @@ export function registerHooks(pi, ecosystemHandlers) {
704
706
  // git.isolation=worktree but auto-mode hasn't created the milestone
705
707
  // worktree yet. Without this, writes silently orphan outside git history.
706
708
  if (isToolCallEventType("write", event) || isToolCallEventType("edit", event)) {
707
- const wtBasePath = resolveWorktreeProjectRoot(dash.basePath ?? discussionBasePath);
708
- const wtGuard = shouldBlockWorktreeWrite(event.toolName, event.input.path, wtBasePath, isAutoActive(), dash.currentUnit?.type);
709
+ const wtGuard = shouldBlockWorktreeWrite(event.toolName, event.input.path, dash.basePath ?? discussionBasePath, isAutoActive(), dash.currentUnit?.type);
709
710
  if (wtGuard.block)
710
711
  return wtGuard;
711
712
  }
@@ -1,22 +1,34 @@
1
1
  export function extractSubagentAgentClasses(input) {
2
2
  if (!input || typeof input !== "object")
3
3
  return [];
4
- const record = input;
5
4
  const agentClasses = [];
5
+ const visited = new WeakSet();
6
6
  const addAgentClass = (value) => {
7
- if (typeof value === "string" && value.trim().length > 0)
8
- agentClasses.push(value.trim());
7
+ if (typeof value !== "string")
8
+ return;
9
+ const normalized = value.trim().replace(/\.md$/i, "");
10
+ if (normalized.length > 0)
11
+ agentClasses.push(normalized);
9
12
  };
10
- const addFromItems = (value) => {
13
+ const visitItems = (value) => {
11
14
  if (!Array.isArray(value))
12
15
  return;
13
16
  for (const item of value) {
14
- if (item && typeof item === "object")
15
- addAgentClass(item.agent);
17
+ visit(item);
16
18
  }
17
19
  };
18
- addAgentClass(record.agent);
19
- addFromItems(record.tasks);
20
- addFromItems(record.chain);
20
+ const visit = (value) => {
21
+ if (!value || typeof value !== "object")
22
+ return;
23
+ if (visited.has(value))
24
+ return;
25
+ visited.add(value);
26
+ const record = value;
27
+ addAgentClass(record.agent);
28
+ visitItems(record.tasks);
29
+ visitItems(record.chain);
30
+ visitItems(record.parallel);
31
+ };
32
+ visit(input);
21
33
  return agentClasses;
22
34
  }
@@ -3,6 +3,7 @@ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkS
3
3
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { minimatch } from "minimatch";
5
5
  import { getIsolationMode } from "../preferences.js";
6
+ import { compileSubagentPermissionContract } from "../unit-context-manifest.js";
6
7
  import { logWarning } from "../workflow-logger.js";
7
8
  import { isGsdWorktreePath, resolveWorktreeProjectRoot } from "../worktree-root.js";
8
9
  /**
@@ -57,7 +58,8 @@ const QUEUE_SAFE_TOOLS = new Set([
57
58
  * env / printenv — print environment variables
58
59
  * true / false — shell no-ops / test exit codes
59
60
  */
60
- const BASH_READ_ONLY_RE = /^\s*(cat|head|tail|less|more|wc|file|stat|du|df|which|type|echo|printf|ls|find|grep|rg|awk|sed\b(?!.*-i)|sort|uniq|diff|comm|tr|cut|tee\s+-a\s+\/dev\/null|git\s+(log|show|diff|status|branch|tag|remote|rev-parse|ls-files|blame|shortlog|describe|stash\s+list|config\s+--get|cat-file)|gh\s+(issue|pr|api|repo|release)\s+(view|list|diff|status|checks)|mkdir\s+-p\s+\.gsd|rtk\s|npm\s+run\s+(test|test:\w+|lint|lint:\w+|typecheck|type-check|type-check:\w+|check|verify|audit|outdated|format:check|ci|validate)\b|npm\s+(ls|list|info|view|show|outdated|audit|explain|doctor|ping|--version|-v)\b|npx\s|tsx\s|node\s+(--print|--version|-v\b)|python[23]?\s+(-c\s+'[^']*'|--version|-V\b|-m\s+(pip\s+show|pip\s+list|site))|pip[23]?\s+(show|list|freeze|check|index\s+versions)\b|jq\s|yq\s|curl\s+(-s\b|--silent\b)(?!\s+[^|>]*\s-[oO]\b)(?!\s+[^|>]*\s--output\b)[^|>]*$|openssl\s+(version|x509|s_client)|env\b|printenv\b|true\b|false\b)/;
61
+ const BASH_READ_ONLY_RE = /^\s*((?:cd|pushd|popd)(?:\s|$)|cat|head|tail|less|more|wc|file|stat|du|df|which|type|echo|printf|ls|find|grep|rg|awk|sed\b(?!.*-i)|sort|uniq|diff|comm|tr|cut|tee\s+-a\s+\/dev\/null|git\s+(log|show|diff|status|branch|tag|remote|rev-parse|ls-files|blame|shortlog|describe|stash\s+list|config\s+--get|cat-file)|gh\s+(issue|pr|api|repo|release)\s+(view|list|diff|status|checks)|mkdir\s+-p\s+\.gsd|rtk\s|npm\s+run\s+(test|test:\w+|lint|lint:\w+|typecheck|type-check|type-check:\w+|check|verify|audit|outdated|format:check|ci|validate)\b|npm\s+(ls|list|info|view|show|outdated|audit|explain|doctor|ping|--version|-v)\b|npx\s|tsx\s|node\s+(--print|--version|-v\b)|python[23]?\s+(-c\s+'[^']*'|--version|-V\b|-m\s+(pip\s+show|pip\s+list|site))|pip[23]?\s+(show|list|freeze|check|index\s+versions)\b|jq\s|yq\s|curl\s+(-s\b|--silent\b)(?!\s+[^|>]*\s-[oO]\b)(?!\s+[^|>]*\s--output\b)[^|>]*$|openssl\s+(version|x509|s_client)|env\b|printenv\b|true\b|false\b)/;
62
+ const BASH_VERIFICATION_RE = /^\s*(npm\s+(run\s+(build|test|test:\w+|lint|lint:\w+|typecheck|type-check|verify|ci|validate)\b|test\b)|pnpm\s+(build|test|lint|typecheck|verify)\b|yarn\s+(build|test|lint|typecheck|verify)\b|vitest\b|jest\b|go\s+test\b)/;
61
63
  function createEmptyWriteGateState() {
62
64
  return {
63
65
  verifiedDepthMilestones: new Set(),
@@ -623,7 +625,7 @@ function matchesAllowedGlob(absPath, basePath, globs) {
623
625
  function blockReason(unitType, mode, what) {
624
626
  return [
625
627
  `HARD BLOCK: unit "${unitType}" runs under tools-policy "${mode}" — ${what}.`,
626
- `This is a mechanical gate enforced by manifest.tools (#4934). You MUST NOT proceed,`,
628
+ `This is a mechanical gate enforced by manifest.tools. You MUST NOT proceed,`,
627
629
  `retry the same call, or rationalize past this block. If you need to write user source,`,
628
630
  `the work belongs in execute-task, not in a planning unit.`,
629
631
  ].join(" ");
@@ -642,6 +644,9 @@ function blockReason(unitType, mode, what) {
642
644
  * and listed in the policy's allowedSubagents.
643
645
  * - "docs" → like "planning" but also allows writes to paths
644
646
  * matching `allowedPathGlobs` relative to basePath.
647
+ * - "verification"
648
+ * → allows Bash for project verification commands, but keeps
649
+ * writes restricted to .gsd/ and blocks subagent dispatch.
645
650
  *
646
651
  * `pathOrCommand` is the file path for write/edit-shaped tools and the
647
652
  * shell command for bash. Other tools ignore this argument.
@@ -673,7 +678,7 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
673
678
  // Unknown tool in read-only mode — block by default.
674
679
  return { block: true, reason: blockReason(unitType, policy.mode, `tool "${tool}" is not on the read-only allowlist`) };
675
680
  }
676
- // planning / planning-dispatch / docs modes share the same surface for safe tools, bash, and subagent.
681
+ // planning / planning-dispatch / docs / verification modes share the same surface for safe tools, bash, and subagent.
677
682
  if (PLANNING_SAFE_TOOLS.has(tool))
678
683
  return { block: false };
679
684
  if (tool.startsWith("gsd_"))
@@ -681,7 +686,8 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
681
686
  if (PLANNING_SUBAGENT_TOOLS.has(tool)) {
682
687
  if (policy.mode === "planning-dispatch") {
683
688
  const requested = (agentClasses ?? []).map(a => a.trim()).filter(Boolean);
684
- const allowedSubagents = Array.isArray(policy.allowedSubagents) ? policy.allowedSubagents : [];
689
+ const dispatchContract = compileSubagentPermissionContract(policy);
690
+ const allowedSubagents = dispatchContract.allowedSubagents;
685
691
  const allowed = new Set(allowedSubagents);
686
692
  // When agentClasses is undefined, the caller has not been updated to extract
687
693
  // agent identities yet. Block and warn so stale callers surface in telemetry
@@ -718,6 +724,14 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
718
724
  return { block: true, reason: blockReason(unitType, policy.mode, `subagent dispatch is not permitted in planning units`) };
719
725
  }
720
726
  if (tool === "bash") {
727
+ if (policy.mode === "verification") {
728
+ if (BASH_VERIFICATION_RE.test(pathOrCommand) || BASH_READ_ONLY_RE.test(pathOrCommand))
729
+ return { block: false };
730
+ return {
731
+ block: true,
732
+ reason: blockReason(unitType, policy.mode, `bash is restricted to build/test verification commands (npm run build, npm test, etc.); cannot run "${pathOrCommand.slice(0, 80)}${pathOrCommand.length > 80 ? "…" : ""}"`),
733
+ };
734
+ }
721
735
  if (BASH_READ_ONLY_RE.test(pathOrCommand))
722
736
  return { block: false };
723
737
  return {
@@ -796,9 +810,9 @@ function isPathContained(target, container) {
796
810
  * while `git.isolation: worktree` is in effect and auto-mode hasn't created
797
811
  * (or flipped cwd into) the milestone worktree.
798
812
  *
799
- * Pure / unit-testable. Callers in `register-hooks.ts` supply the resolved
800
- * project root and current auto liveness; this function does no I/O beyond
801
- * realpath resolution.
813
+ * Pure / unit-testable. Callers in `register-hooks.ts` supply the effective
814
+ * execution base path (worker cwd or project root) and current auto liveness;
815
+ * this function does no I/O beyond realpath resolution.
802
816
  *
803
817
  * Allow rules (in order):
804
818
  * 1. Tool isn't a planning-write (write/edit/multi_edit/notebook_edit).
@@ -832,10 +846,11 @@ export function shouldBlockWorktreeWrite(toolName, targetPath, effectiveBasePath
832
846
  ].join(" "),
833
847
  };
834
848
  }
835
- // Resolve the target relative to the project root, then realpath to defeat
849
+ // Resolve relative targets against the effective execution base path, then
850
+ // canonicalize against the project root to defeat
836
851
  // symlink-based escapes and prefix tricks (e.g. .gsd/worktrees-extra/).
837
852
  const projectRoot = resolveWorktreeProjectRoot(effectiveBasePath);
838
- const absTarget = isAbsolute(targetPath) ? targetPath : resolve(projectRoot, targetPath);
853
+ const absTarget = isAbsolute(targetPath) ? targetPath : resolve(effectiveBasePath, targetPath);
839
854
  const realTarget = realpathOrResolve(absTarget);
840
855
  const realRoot = realpathOrResolve(projectRoot);
841
856
  const realGsd = realpathOrResolve(join(projectRoot, ".gsd"));
@@ -8,14 +8,153 @@
8
8
  *
9
9
  * Design constraints (from Trek-e approval):
10
10
  * - Warn the user before stashing (no silent surprises)
11
- * - git stash push / git stash pop only no custom stash management layer
12
- * - Stash/pop errors are logged but MUST NOT block the merge itself
11
+ * - git stash push / git stash apply+drop for targeted restore
12
+ * - Stash/apply errors are logged but MUST NOT block the merge itself
13
13
  * - Fast-path status check — clean trees pay no extra cost
14
14
  */
15
15
  import { execFileSync } from "node:child_process";
16
+ import { existsSync, readFileSync } from "node:fs";
17
+ import { join } from "node:path";
16
18
  import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
17
19
  import { logWarning } from "./workflow-logger.js";
18
20
  import { nativeHasChanges } from "./native-git-bridge.js";
21
+ function gitText(basePath, args) {
22
+ return execFileSync("git", args, {
23
+ cwd: basePath,
24
+ stdio: ["ignore", "pipe", "pipe"],
25
+ encoding: "utf-8",
26
+ env: GIT_NO_PROMPT_ENV,
27
+ });
28
+ }
29
+ function gitBuffer(basePath, args) {
30
+ return execFileSync("git", args, {
31
+ cwd: basePath,
32
+ stdio: ["ignore", "pipe", "pipe"],
33
+ env: GIT_NO_PROMPT_ENV,
34
+ });
35
+ }
36
+ function errorText(err) {
37
+ if (!err || typeof err !== "object")
38
+ return String(err);
39
+ const parts = [];
40
+ const stderr = err.stderr;
41
+ const stdout = err.stdout;
42
+ for (const value of [stderr, stdout]) {
43
+ if (typeof value === "string")
44
+ parts.push(value);
45
+ else if (value instanceof Uint8Array)
46
+ parts.push(Buffer.from(value).toString("utf-8"));
47
+ }
48
+ parts.push(err instanceof Error ? err.message : String(err));
49
+ return parts.filter(Boolean).join("\n");
50
+ }
51
+ function parseAlreadyExistsNoCheckoutPaths(text) {
52
+ const paths = [];
53
+ for (const line of text.split(/\r?\n/)) {
54
+ const match = /^(.+?) already exists, no checkout$/i.exec(line.trim());
55
+ if (match?.[1])
56
+ paths.push(match[1]);
57
+ }
58
+ return [...new Set(paths)];
59
+ }
60
+ function readZeroDelimitedPaths(output) {
61
+ return output.split("\0").filter(Boolean);
62
+ }
63
+ function listStashUntrackedPaths(basePath, stashRef) {
64
+ try {
65
+ const output = gitText(basePath, ["ls-tree", "-r", "-z", "--name-only", `${stashRef}^3`]);
66
+ return readZeroDelimitedPaths(output);
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
72
+ function listStashTrackedPaths(basePath, stashRef) {
73
+ try {
74
+ const output = gitText(basePath, ["diff", "--name-only", "-z", `${stashRef}^1`, stashRef]);
75
+ return readZeroDelimitedPaths(output);
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ function isWorktreeClean(basePath) {
82
+ try {
83
+ return gitText(basePath, ["status", "--porcelain"]).trim() === "";
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
89
+ function stashBlobEqualsWorktreeFile(basePath, stashRef, path) {
90
+ try {
91
+ const worktreePath = join(basePath, path);
92
+ if (!existsSync(worktreePath))
93
+ return false;
94
+ const worktreeContent = readFileSync(worktreePath);
95
+ const stashContent = gitBuffer(basePath, ["show", `${stashRef}^3:${path}`]);
96
+ return Buffer.compare(worktreeContent, stashContent) === 0;
97
+ }
98
+ catch {
99
+ return null;
100
+ }
101
+ }
102
+ function reconcileAlreadyPresentUntrackedStash(basePath, milestoneId, stashRef, err) {
103
+ const text = errorText(err);
104
+ const collidedPaths = parseAlreadyExistsNoCheckoutPaths(text);
105
+ if (collidedPaths.length === 0)
106
+ return null;
107
+ const untrackedPaths = listStashUntrackedPaths(basePath, stashRef);
108
+ if (!untrackedPaths || untrackedPaths.length === 0)
109
+ return null;
110
+ const trackedPaths = listStashTrackedPaths(basePath, stashRef);
111
+ if (trackedPaths === null || trackedPaths.length > 0)
112
+ return null;
113
+ const untrackedPathSet = new Set(untrackedPaths);
114
+ if (!collidedPaths.every((path) => untrackedPathSet.has(path)))
115
+ return null;
116
+ if (!untrackedPaths.every((path) => existsSync(join(basePath, path))))
117
+ return null;
118
+ if (isWorktreeClean(basePath) !== true)
119
+ return null;
120
+ const blobComparisons = untrackedPaths.map((path) => stashBlobEqualsWorktreeFile(basePath, stashRef, path));
121
+ if (blobComparisons.some((result) => result === null))
122
+ return null;
123
+ const allIdentical = blobComparisons.every(Boolean);
124
+ if (allIdentical) {
125
+ let dropped = true;
126
+ try {
127
+ execFileSync("git", ["stash", "drop", stashRef], {
128
+ cwd: basePath,
129
+ stdio: ["ignore", "pipe", "pipe"],
130
+ encoding: "utf-8",
131
+ env: GIT_NO_PROMPT_ENV,
132
+ });
133
+ }
134
+ catch (err) {
135
+ dropped = false;
136
+ logWarning("preflight", `git stash drop ${stashRef} failed after identical preflight stash reconciliation: ${err instanceof Error ? err.message : String(err)}`);
137
+ }
138
+ return {
139
+ restored: true,
140
+ needsManualRecovery: false,
141
+ message: dropped
142
+ ? `Preflight stash for milestone ${milestoneId} contained files already present after merge; identical stash dropped.`
143
+ : `Preflight stash for milestone ${milestoneId} contained files already present after merge, but ${stashRef} could not be dropped and remains as a backup.`,
144
+ stashRef,
145
+ resolution: dropped ? "already-present-dropped" : "already-present-preserved",
146
+ collidedPaths,
147
+ };
148
+ }
149
+ return {
150
+ restored: false,
151
+ needsManualRecovery: false,
152
+ message: `Preflight stash for milestone ${milestoneId} contained untracked files already present after merge. Keeping merged files and preserving ${stashRef} as a backup.`,
153
+ stashRef,
154
+ resolution: "already-present-preserved",
155
+ collidedPaths,
156
+ };
157
+ }
19
158
  function findPreflightStashRef(basePath, milestoneId, stashMarker) {
20
159
  const markerPrefix = `gsd-preflight-stash:${milestoneId}:`;
21
160
  let fallbackRef = null;
@@ -115,28 +254,50 @@ export function postflightPopStash(basePath, milestoneId, stashMarker, notify) {
115
254
  message: msg,
116
255
  };
117
256
  }
118
- execFileSync("git", ["stash", "pop", stashRef], {
257
+ execFileSync("git", ["stash", "apply", stashRef], {
119
258
  cwd: basePath,
120
259
  stdio: ["ignore", "pipe", "pipe"],
121
260
  encoding: "utf-8",
122
261
  env: GIT_NO_PROMPT_ENV,
123
262
  });
263
+ let dropWarning = null;
264
+ try {
265
+ execFileSync("git", ["stash", "drop", stashRef], {
266
+ cwd: basePath,
267
+ stdio: ["ignore", "pipe", "pipe"],
268
+ encoding: "utf-8",
269
+ env: GIT_NO_PROMPT_ENV,
270
+ });
271
+ }
272
+ catch (err) {
273
+ dropWarning = ` Stash was restored, but git stash drop ${stashRef} failed: ${err instanceof Error ? err.message : String(err)}.`;
274
+ logWarning("preflight", dropWarning.trim());
275
+ }
124
276
  const msg = `Restored stashed changes after milestone ${milestoneId} merge.`;
125
- notify(msg, "info");
277
+ notify(`${msg}${dropWarning ?? ""}`, dropWarning ? "warning" : "info");
126
278
  return {
127
279
  restored: true,
128
280
  needsManualRecovery: false,
129
- message: msg,
281
+ message: `${msg}${dropWarning ?? ""}`,
130
282
  stashRef,
283
+ resolution: "applied",
131
284
  };
132
285
  }
133
286
  catch (err) {
134
- // Pop conflicts mean the merged code collides with the stashed changes.
287
+ if (stashRef) {
288
+ const reconciled = reconcileAlreadyPresentUntrackedStash(basePath, milestoneId, stashRef, err);
289
+ if (reconciled) {
290
+ logWarning("preflight", reconciled.message);
291
+ notify(reconciled.message, reconciled.resolution === "already-present-preserved" ? "warning" : "info");
292
+ return reconciled;
293
+ }
294
+ }
295
+ // Apply conflicts mean the merged code collides with the stashed changes.
135
296
  // Log a warning — the user needs to resolve manually, but the merge succeeded.
136
297
  const restoreHint = stashRef
137
- ? `Run "git stash pop ${stashRef}" or "git stash apply ${stashRef}" manually to restore the correct stash.`
298
+ ? `Run "git stash apply ${stashRef}" manually to restore the correct stash, then "git stash drop ${stashRef}" after recovery.`
138
299
  : `Run "git stash list" to find the matching GSD preflight stash before restoring manually.`;
139
- const msg = `git stash pop ${stashRef ?? ""}`.trim() + ` failed after merge of milestone ${milestoneId}: ${err instanceof Error ? err.message : String(err)}. ${restoreHint}`;
300
+ const msg = `git stash apply ${stashRef ?? ""}`.trim() + ` failed after merge of milestone ${milestoneId}: ${err instanceof Error ? err.message : String(err)}. ${restoreHint}`;
140
301
  logWarning("preflight", msg);
141
302
  notify(msg, "warning");
142
303
  return {
@@ -144,6 +305,7 @@ export function postflightPopStash(basePath, milestoneId, stashMarker, notify) {
144
305
  needsManualRecovery: true,
145
306
  message: msg,
146
307
  ...(stashRef ? { stashRef } : {}),
308
+ resolution: "manual-recovery",
147
309
  };
148
310
  }
149
311
  }
@@ -2,7 +2,8 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { loadRegistry } from "../workflow-templates.js";
4
4
  import { gsdHome } from "../gsd-home.js";
5
- export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|undo-task|reset-slice|rate|skip|export|cleanup|model|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|debug|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|new-project|parallel|cmux|park|unpark|init|setup|onboarding|inspect|extensions|update|fast|mcp|rethink|workflow|codebase|notifications|ship|do|session-report|backlog|pr-branch|add-tests|scan|language|worktree|eval-review";
5
+ import { VISUAL_BRIEF_MODES } from "../../visual-brief/prompts.js";
6
+ export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|brief|queue|quick|discuss|capture|triage|dispatch|verdict|history|undo|undo-task|reset-slice|rate|skip|export|cleanup|model|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|debug|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|new-project|parallel|cmux|park|unpark|init|setup|onboarding|inspect|extensions|update|fast|mcp|rethink|workflow|codebase|notifications|ship|do|session-report|backlog|pr-branch|add-tests|scan|language|worktree|eval-review";
6
7
  export const TOP_LEVEL_SUBCOMMANDS = [
7
8
  { cmd: "help", desc: "Categorized command reference with descriptions" },
8
9
  { cmd: "next", desc: "Explicit step mode (same as /gsd)" },
@@ -12,6 +13,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
12
13
  { cmd: "status", desc: "Progress dashboard" },
13
14
  { cmd: "widget", desc: "Cycle widget: full → small → min → off" },
14
15
  { cmd: "visualize", desc: "Open 10-tab workflow visualizer (progress, timeline, deps, metrics, health, agent, changes, knowledge, captures, export)" },
16
+ { cmd: "brief", desc: "Generate a visual HTML brief: diagram, plan, diff review, recap, table, or slides" },
15
17
  { cmd: "queue", desc: "Queue and reorder future milestones" },
16
18
  { cmd: "quick", desc: "Execute a quick task without full planning overhead" },
17
19
  { cmd: "discuss", desc: "Discuss architecture and decisions" },
@@ -19,6 +21,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
19
21
  { cmd: "changelog", desc: "Show categorized release notes" },
20
22
  { cmd: "triage", desc: "Manually trigger triage of pending captures" },
21
23
  { cmd: "dispatch", desc: "Dispatch a specific phase directly" },
24
+ { cmd: "verdict", desc: "Override the recorded milestone validation verdict (pass|needs-attention|needs-remediation)" },
22
25
  { cmd: "history", desc: "View execution history" },
23
26
  { cmd: "undo", desc: "Revert last completed unit" },
24
27
  { cmd: "undo-task", desc: "Reset a specific task's completion state (DB + markdown)" },
@@ -75,6 +78,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
75
78
  { cmd: "eval-review", desc: "Audit a slice's AI evaluation strategy and write a scored EVAL-REVIEW.md (--force, --show)" },
76
79
  ];
77
80
  const NESTED_COMPLETIONS = {
81
+ brief: VISUAL_BRIEF_MODES.map((mode) => ({ cmd: mode.mode, desc: mode.description })),
78
82
  auto: [
79
83
  { cmd: "--verbose", desc: "Show detailed execution output" },
80
84
  { cmd: "--debug", desc: "Enable debug logging" },
@@ -232,6 +236,11 @@ const NESTED_COMPLETIONS = {
232
236
  { cmd: "uat", desc: "Run user acceptance testing" },
233
237
  { cmd: "replan", desc: "Replan the current slice" },
234
238
  ],
239
+ verdict: [
240
+ { cmd: "pass", desc: "Override the milestone validation verdict to pass" },
241
+ { cmd: "needs-attention", desc: "Override the verdict to needs-attention (requires --rationale)" },
242
+ { cmd: "needs-remediation", desc: "Override the verdict to needs-remediation (requires --rationale)" },
243
+ ],
235
244
  rate: [
236
245
  { cmd: "over", desc: "Model was overqualified for this task" },
237
246
  { cmd: "ok", desc: "Model was appropriate for this task" },