@opengsd/gsd-pi 1.2.0-dev.b1abb545 → 1.2.0-dev.ddc97c10

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 (662) hide show
  1. package/dist/cli-style.d.ts +17 -0
  2. package/dist/cli-style.js +28 -0
  3. package/dist/cli.js +1 -1
  4. package/dist/headless-events.d.ts +4 -2
  5. package/dist/headless-events.js +14 -34
  6. package/dist/mcp-server.js +2 -1
  7. package/dist/models-resolver.d.ts +3 -13
  8. package/dist/models-resolver.js +3 -22
  9. package/dist/resource-loader.js +2 -14
  10. package/dist/resources/.managed-resources-content-hash +1 -1
  11. package/dist/resources/GSD-WORKFLOW.md +5 -4
  12. package/dist/resources/extensions/async-jobs/async-bash-tool.js +30 -64
  13. package/dist/resources/extensions/async-jobs/await-tool.js +80 -12
  14. package/dist/resources/extensions/async-jobs/index.js +65 -0
  15. package/dist/resources/extensions/async-jobs/job-manager.js +12 -1
  16. package/dist/resources/extensions/bg-shell/bg-shell-command.js +6 -6
  17. package/dist/resources/extensions/bg-shell/bg-shell-tool.js +10 -7
  18. package/dist/resources/extensions/bg-shell/overlay.js +9 -6
  19. package/dist/resources/extensions/bg-shell/process-manager.js +54 -25
  20. package/dist/resources/extensions/bg-shell/readiness-detector.js +11 -0
  21. package/dist/resources/extensions/bg-shell/utilities.js +5 -2
  22. package/dist/resources/extensions/browser-tools/engine/managed-gsd-browser.js +209 -88
  23. package/dist/resources/extensions/browser-tools/engine/selection.js +73 -5
  24. package/dist/resources/extensions/browser-tools/index.js +69 -12
  25. package/dist/resources/extensions/claude-code-cli/models.js +9 -0
  26. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +38 -6
  27. package/dist/resources/extensions/gsd/auto/custom-verify-retry-store.js +17 -2
  28. package/dist/resources/extensions/gsd/auto/detect-stuck.js +33 -13
  29. package/dist/resources/extensions/gsd/auto/dispatch-history.js +105 -0
  30. package/dist/resources/extensions/gsd/auto/dispatch-key.js +37 -0
  31. package/dist/resources/extensions/gsd/auto/loop.js +4 -1
  32. package/dist/resources/extensions/gsd/auto/orchestrator.js +122 -58
  33. package/dist/resources/extensions/gsd/auto/phases.js +54 -6
  34. package/dist/resources/extensions/gsd/auto/session.js +3 -0
  35. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +11 -34
  36. package/dist/resources/extensions/gsd/auto-dispatch.js +50 -58
  37. package/dist/resources/extensions/gsd/auto-model-selection.js +36 -13
  38. package/dist/resources/extensions/gsd/auto-post-unit.js +43 -14
  39. package/dist/resources/extensions/gsd/auto-prompts.js +81 -19
  40. package/dist/resources/extensions/gsd/auto-start.js +24 -26
  41. package/dist/resources/extensions/gsd/auto-tool-tracking.js +18 -0
  42. package/dist/resources/extensions/gsd/auto-unit-closeout.js +45 -21
  43. package/dist/resources/extensions/gsd/auto-unit-tool-scope.js +12 -20
  44. package/dist/resources/extensions/gsd/auto-verification.js +23 -30
  45. package/dist/resources/extensions/gsd/auto-worktree-repair.js +10 -2
  46. package/dist/resources/extensions/gsd/auto-worktree.js +35 -352
  47. package/dist/resources/extensions/gsd/auto.js +45 -21
  48. package/dist/resources/extensions/gsd/blocked-models.js +28 -0
  49. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +29 -8
  50. package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +32 -12
  51. package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +2 -2
  52. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +19 -0
  53. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +229 -36
  54. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +319 -71
  55. package/dist/resources/extensions/gsd/branch-patterns.js +2 -0
  56. package/dist/resources/extensions/gsd/browser-daemon-auto-prep.js +83 -0
  57. package/dist/resources/extensions/gsd/browser-evidence.js +8 -2
  58. package/dist/resources/extensions/gsd/captures.js +5 -15
  59. package/dist/resources/extensions/gsd/closeout-recovery.js +3 -2
  60. package/dist/resources/extensions/gsd/closeout-wizard.js +92 -0
  61. package/dist/resources/extensions/gsd/commands/catalog.js +6 -62
  62. package/dist/resources/extensions/gsd/commands/context.js +16 -2
  63. package/dist/resources/extensions/gsd/commands-handlers.js +46 -3
  64. package/dist/resources/extensions/gsd/consent-question.js +353 -0
  65. package/dist/resources/extensions/gsd/consent-verdict.js +63 -0
  66. package/dist/resources/extensions/gsd/constants.js +0 -2
  67. package/dist/resources/extensions/gsd/crash-recovery.js +12 -15
  68. package/dist/resources/extensions/gsd/db/engine.js +755 -0
  69. package/dist/resources/extensions/gsd/db/queries.js +398 -0
  70. package/dist/resources/extensions/gsd/db/sql-constants.js +11 -0
  71. package/dist/resources/extensions/gsd/db/writers/cascades.js +194 -0
  72. package/dist/resources/extensions/gsd/db/writers/import-restore.js +182 -0
  73. package/dist/resources/extensions/gsd/db/writers/memory.js +149 -0
  74. package/dist/resources/extensions/gsd/db/writers/reconcile.js +458 -0
  75. package/dist/resources/extensions/gsd/db/writers/status.js +70 -0
  76. package/dist/resources/extensions/gsd/dispatch-guard.js +10 -35
  77. package/dist/resources/extensions/gsd/doctor-engine-checks.js +3 -3
  78. package/dist/resources/extensions/gsd/doctor-environment.js +5 -11
  79. package/dist/resources/extensions/gsd/doctor-format.js +9 -6
  80. package/dist/resources/extensions/gsd/doctor-git-checks.js +6 -21
  81. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +21 -16
  82. package/dist/resources/extensions/gsd/engine-hook-contract.js +70 -0
  83. package/dist/resources/extensions/gsd/error-classifier.js +9 -0
  84. package/dist/resources/extensions/gsd/exec-sandbox.js +30 -10
  85. package/dist/resources/extensions/gsd/files.js +33 -19
  86. package/dist/resources/extensions/gsd/git-service.js +1 -0
  87. package/dist/resources/extensions/gsd/gitignore.js +3 -0
  88. package/dist/resources/extensions/gsd/gsd-command-home.js +22 -12
  89. package/dist/resources/extensions/gsd/gsd-db.js +172 -2048
  90. package/dist/resources/extensions/gsd/guidance.js +158 -0
  91. package/dist/resources/extensions/gsd/guided-flow.js +57 -8
  92. package/dist/resources/extensions/gsd/markdown-renderer.js +10 -0
  93. package/dist/resources/extensions/gsd/mcp-filter.js +2 -19
  94. package/dist/resources/extensions/gsd/mcp-tool-name.js +5 -13
  95. package/dist/resources/extensions/gsd/memory-consolidation-scanner.js +1 -1
  96. package/dist/resources/extensions/gsd/migrate/safety.js +20 -9
  97. package/dist/resources/extensions/gsd/migration-auto-check.js +24 -3
  98. package/dist/resources/extensions/gsd/milestone-closeout.js +85 -24
  99. package/dist/resources/extensions/gsd/milestone-planning-persistence.js +2 -2
  100. package/dist/resources/extensions/gsd/model-cost-table.js +1 -0
  101. package/dist/resources/extensions/gsd/model-router.js +3 -0
  102. package/dist/resources/extensions/gsd/notification-store.js +11 -4
  103. package/dist/resources/extensions/gsd/parallel-merge.js +14 -11
  104. package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +11 -7
  105. package/dist/resources/extensions/gsd/parsers-legacy.js +16 -4
  106. package/dist/resources/extensions/gsd/paths.js +37 -24
  107. package/dist/resources/extensions/gsd/pre-execution-checks.js +91 -3
  108. package/dist/resources/extensions/gsd/preferences-models.js +14 -48
  109. package/dist/resources/extensions/gsd/preferences.js +14 -0
  110. package/dist/resources/extensions/gsd/projection-flush.js +7 -0
  111. package/dist/resources/extensions/gsd/prompts/complete-slice.md +3 -3
  112. package/dist/resources/extensions/gsd/prompts/execute-task.md +1 -1
  113. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
  114. package/dist/resources/extensions/gsd/prompts/plan-slice.md +2 -2
  115. package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -1
  116. package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
  117. package/dist/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  118. package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
  119. package/dist/resources/extensions/gsd/prompts/research-milestone.md +1 -1
  120. package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
  121. package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  122. package/dist/resources/extensions/gsd/prompts/run-uat.md +7 -5
  123. package/dist/resources/extensions/gsd/prompts/system.md +5 -2
  124. package/dist/resources/extensions/gsd/prompts/triage-captures.md +1 -1
  125. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
  126. package/dist/resources/extensions/gsd/provider-error-guidance.js +1 -5
  127. package/dist/resources/extensions/gsd/provider-switch-observer.js +1 -1
  128. package/dist/resources/extensions/gsd/publication.js +87 -0
  129. package/dist/resources/extensions/gsd/reactive-graph.js +8 -1
  130. package/dist/resources/extensions/gsd/recovery-classification.js +41 -87
  131. package/dist/resources/extensions/gsd/roadmap-slices.js +25 -3
  132. package/dist/resources/extensions/gsd/safety/destructive-confirmation.js +108 -0
  133. package/dist/resources/extensions/gsd/safety/evidence-collector.js +37 -4
  134. package/dist/resources/extensions/gsd/safety/evidence-cross-ref.js +7 -2
  135. package/dist/resources/extensions/gsd/safety/file-change-validator.js +10 -0
  136. package/dist/resources/extensions/gsd/session-lock.js +1 -1
  137. package/dist/resources/extensions/gsd/state-transition-matrix.js +38 -0
  138. package/dist/resources/extensions/gsd/state.js +6 -20
  139. package/dist/resources/extensions/gsd/status-guards.js +56 -8
  140. package/dist/resources/extensions/gsd/stop-notice.js +57 -0
  141. package/dist/resources/extensions/gsd/tool-contract.js +14 -3
  142. package/dist/resources/extensions/gsd/tool-presentation-plan.js +4 -4
  143. package/dist/resources/extensions/gsd/tool-surface-readiness.js +56 -0
  144. package/dist/resources/extensions/gsd/tools/complete-milestone.js +3 -2
  145. package/dist/resources/extensions/gsd/tools/complete-slice.js +46 -55
  146. package/dist/resources/extensions/gsd/tools/complete-task.js +3 -2
  147. package/dist/resources/extensions/gsd/tools/exec-tool.js +10 -8
  148. package/dist/resources/extensions/gsd/tools/plan-slice.js +14 -8
  149. package/dist/resources/extensions/gsd/tools/plan-task.js +2 -2
  150. package/dist/resources/extensions/gsd/tools/reassess-roadmap.js +2 -2
  151. package/dist/resources/extensions/gsd/tools/reopen-milestone.js +13 -31
  152. package/dist/resources/extensions/gsd/tools/reopen-slice.js +16 -35
  153. package/dist/resources/extensions/gsd/tools/reopen-task.js +2 -2
  154. package/dist/resources/extensions/gsd/tools/replan-slice.js +2 -2
  155. package/dist/resources/extensions/gsd/tools/skip-slice.js +18 -36
  156. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +67 -2
  157. package/dist/resources/extensions/gsd/uat-policy.js +42 -16
  158. package/dist/resources/extensions/gsd/undo.js +8 -7
  159. package/dist/resources/extensions/gsd/unit-closeout.js +138 -0
  160. package/dist/resources/extensions/gsd/unit-context-composer.js +74 -1
  161. package/dist/resources/extensions/gsd/unit-context-manifest.js +4 -27
  162. package/dist/resources/extensions/gsd/unit-registry.js +337 -0
  163. package/dist/resources/extensions/gsd/unit-tool-contracts.js +9 -182
  164. package/dist/resources/extensions/gsd/verdict-parser.js +1 -1
  165. package/dist/resources/extensions/gsd/verification-verdict.js +2 -1
  166. package/dist/resources/extensions/gsd/web-app-uat.js +45 -8
  167. package/dist/resources/extensions/gsd/workflow-tool-surface.js +1 -1
  168. package/dist/resources/extensions/gsd/worktree-git-recovery.js +293 -0
  169. package/dist/resources/extensions/gsd/worktree-lifecycle.js +12 -3
  170. package/dist/resources/extensions/gsd/worktree-manager.js +45 -28
  171. package/dist/resources/extensions/gsd/worktree-placement.js +59 -0
  172. package/dist/resources/extensions/gsd/worktree-reentry.js +12 -8
  173. package/dist/resources/extensions/gsd/worktree-root.js +28 -6
  174. package/dist/resources/extensions/gsd/worktree-safety.js +8 -5
  175. package/dist/resources/extensions/gsd/worktree-session-state.js +12 -11
  176. package/dist/resources/extensions/search-the-web/native-search.js +5 -3
  177. package/dist/resources/extensions/shared/browser-contract.js +59 -0
  178. package/dist/resources/extensions/shared/gsd-browser-cli.js +116 -6
  179. package/dist/resources/shared/gsd-browser-path-sync.js +214 -0
  180. package/dist/resources/shared/package-manager-detection.js +1 -1
  181. package/dist/resources/shared/package.json +3 -0
  182. package/dist/resources/skills/create-skill/references/executable-code.md +1 -1
  183. package/dist/resources/skills/create-skill/workflows/add-reference.md +8 -3
  184. package/dist/resources/skills/create-skill/workflows/add-script.md +4 -2
  185. package/dist/resources/skills/create-skill/workflows/add-template.md +3 -1
  186. package/dist/resources/skills/create-skill/workflows/add-workflow.md +8 -3
  187. package/dist/resources/skills/create-skill/workflows/upgrade-to-router.md +10 -5
  188. package/dist/resources/skills/create-skill/workflows/verify-skill.md +9 -4
  189. package/dist/resources/skills/gsd-browser/SKILL.md +1 -1
  190. package/dist/resources/skills/spike-wrap-up/SKILL.md +9 -9
  191. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  192. package/dist/update-check.d.ts +2 -0
  193. package/dist/update-check.js +24 -1
  194. package/dist/update-cmd.js +20 -3
  195. package/dist/web/standalone/.next/BUILD_ID +1 -1
  196. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  197. package/dist/web/standalone/.next/build-manifest.json +3 -3
  198. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  199. package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
  200. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  201. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  202. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  203. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  204. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  205. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  206. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  207. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  208. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  209. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  210. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  211. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  212. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  213. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  214. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  215. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  216. package/dist/web/standalone/.next/server/app/api/boot/route.js.nft.json +1 -1
  217. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js.nft.json +1 -1
  218. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js.nft.json +1 -1
  219. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js.nft.json +1 -1
  220. package/dist/web/standalone/.next/server/app/api/captures/route.js.nft.json +1 -1
  221. package/dist/web/standalone/.next/server/app/api/cleanup/route.js.nft.json +1 -1
  222. package/dist/web/standalone/.next/server/app/api/doctor/route.js.nft.json +1 -1
  223. package/dist/web/standalone/.next/server/app/api/export-data/route.js.nft.json +1 -1
  224. package/dist/web/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
  225. package/dist/web/standalone/.next/server/app/api/forensics/route.js.nft.json +1 -1
  226. package/dist/web/standalone/.next/server/app/api/git/route.js.nft.json +1 -1
  227. package/dist/web/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
  228. package/dist/web/standalone/.next/server/app/api/hooks/route.js.nft.json +1 -1
  229. package/dist/web/standalone/.next/server/app/api/inspect/route.js.nft.json +1 -1
  230. package/dist/web/standalone/.next/server/app/api/knowledge/route.js.nft.json +1 -1
  231. package/dist/web/standalone/.next/server/app/api/live-state/route.js.nft.json +1 -1
  232. package/dist/web/standalone/.next/server/app/api/mcp-connections/route.js.nft.json +1 -1
  233. package/dist/web/standalone/.next/server/app/api/notifications/route.js.nft.json +1 -1
  234. package/dist/web/standalone/.next/server/app/api/onboarding/route.js.nft.json +1 -1
  235. package/dist/web/standalone/.next/server/app/api/projects/route.js.nft.json +1 -1
  236. package/dist/web/standalone/.next/server/app/api/recovery/route.js.nft.json +1 -1
  237. package/dist/web/standalone/.next/server/app/api/session/browser/route.js.nft.json +1 -1
  238. package/dist/web/standalone/.next/server/app/api/session/command/route.js.nft.json +1 -1
  239. package/dist/web/standalone/.next/server/app/api/session/events/route.js.nft.json +1 -1
  240. package/dist/web/standalone/.next/server/app/api/session/manage/route.js.nft.json +1 -1
  241. package/dist/web/standalone/.next/server/app/api/settings-data/route.js.nft.json +1 -1
  242. package/dist/web/standalone/.next/server/app/api/shutdown/route.js.nft.json +1 -1
  243. package/dist/web/standalone/.next/server/app/api/skill-health/route.js.nft.json +1 -1
  244. package/dist/web/standalone/.next/server/app/api/steer/route.js.nft.json +1 -1
  245. package/dist/web/standalone/.next/server/app/api/switch-root/route.js.nft.json +1 -1
  246. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js.nft.json +1 -1
  247. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js.nft.json +1 -1
  248. package/dist/web/standalone/.next/server/app/api/undo/route.js.nft.json +1 -1
  249. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  250. package/dist/web/standalone/.next/server/app/api/update/route.js.nft.json +1 -1
  251. package/dist/web/standalone/.next/server/app/api/visualizer/route.js.nft.json +1 -1
  252. package/dist/web/standalone/.next/server/app/index.html +1 -1
  253. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  254. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  255. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  256. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  257. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  258. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  259. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  260. package/dist/web/standalone/.next/server/chunks/5124.js +1 -1
  261. package/dist/web/standalone/.next/server/chunks/{5047.js → 5942.js} +2 -2
  262. package/dist/web/standalone/.next/server/chunks/8357.js +2 -2
  263. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  264. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  265. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  266. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  267. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  268. package/dist/web/standalone/.next/static/chunks/{796.cf859a427a2cb2ac.js → 796.e0bdc932325d7e03.js} +1 -1
  269. package/dist/web/standalone/.next/static/chunks/{webpack-fbea77b5f9953368.js → webpack-f0285ce91d4ec9ef.js} +1 -1
  270. package/dist/web/standalone/node_modules/node-pty/build/Makefile +1 -1
  271. package/dist/web/standalone/package.json +1 -1
  272. package/dist/worktree-cli.js +3 -6
  273. package/dist/worktree-status-banner.js +7 -11
  274. package/package.json +1 -1
  275. package/packages/cloud-mcp-gateway/package.json +2 -2
  276. package/packages/contracts/dist/rpc.d.ts +1 -0
  277. package/packages/contracts/dist/rpc.d.ts.map +1 -1
  278. package/packages/contracts/dist/rpc.js.map +1 -1
  279. package/packages/contracts/dist/workflow.d.ts +4 -0
  280. package/packages/contracts/dist/workflow.d.ts.map +1 -1
  281. package/packages/contracts/dist/workflow.js.map +1 -1
  282. package/packages/contracts/package.json +1 -1
  283. package/packages/daemon/package.json +4 -4
  284. package/packages/gsd-agent-core/package.json +5 -5
  285. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts +5 -0
  286. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  287. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +8 -0
  288. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
  289. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  290. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js +7 -0
  291. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  292. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -1
  293. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js +8 -1
  294. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js.map +1 -1
  295. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.d.ts.map +1 -1
  296. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.js +11 -1
  297. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-chat-render.js.map +1 -1
  298. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.d.ts.map +1 -1
  299. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js +4 -4
  300. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js.map +1 -1
  301. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  302. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js +3 -1
  303. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js.map +1 -1
  304. package/packages/gsd-agent-modes/package.json +7 -7
  305. package/packages/mcp-server/dist/cli.js +9 -1
  306. package/packages/mcp-server/dist/cli.js.map +1 -1
  307. package/packages/mcp-server/dist/moonshot-tool-schema.d.ts +29 -0
  308. package/packages/mcp-server/dist/moonshot-tool-schema.d.ts.map +1 -0
  309. package/packages/mcp-server/dist/moonshot-tool-schema.js +50 -0
  310. package/packages/mcp-server/dist/moonshot-tool-schema.js.map +1 -0
  311. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  312. package/packages/mcp-server/dist/server.js +4 -0
  313. package/packages/mcp-server/dist/server.js.map +1 -1
  314. package/packages/mcp-server/dist/workflow-tools.d.ts +26 -18
  315. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  316. package/packages/mcp-server/dist/workflow-tools.js +145 -59
  317. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  318. package/packages/mcp-server/package.json +5 -4
  319. package/packages/native/package.json +1 -1
  320. package/packages/pi-agent-core/dist/harness/env/nodejs.d.ts +1 -0
  321. package/packages/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  322. package/packages/pi-agent-core/dist/harness/env/nodejs.js +34 -3
  323. package/packages/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  324. package/packages/pi-agent-core/dist/index.d.ts +1 -0
  325. package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
  326. package/packages/pi-agent-core/dist/index.js +3 -0
  327. package/packages/pi-agent-core/dist/index.js.map +1 -1
  328. package/packages/pi-agent-core/package.json +1 -1
  329. package/packages/pi-ai/README.md +1 -0
  330. package/packages/pi-ai/dist/index.d.ts +2 -0
  331. package/packages/pi-ai/dist/index.d.ts.map +1 -1
  332. package/packages/pi-ai/dist/index.js +2 -0
  333. package/packages/pi-ai/dist/index.js.map +1 -1
  334. package/packages/pi-ai/dist/models.generated.d.ts +192 -0
  335. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  336. package/packages/pi-ai/dist/models.generated.js +166 -0
  337. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  338. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  339. package/packages/pi-ai/dist/providers/anthropic.js +12 -7
  340. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  341. package/packages/pi-ai/dist/providers/google-shared.d.ts +5 -0
  342. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  343. package/packages/pi-ai/dist/providers/google-shared.js +12 -3
  344. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
  345. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  346. package/packages/pi-ai/dist/providers/openai-completions.js +7 -3
  347. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  348. package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts +9 -0
  349. package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts.map +1 -0
  350. package/packages/pi-ai/dist/utils/moonshot-tool-schema.js +34 -0
  351. package/packages/pi-ai/dist/utils/moonshot-tool-schema.js.map +1 -0
  352. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  353. package/packages/pi-ai/dist/utils/oauth/github-copilot.js +6 -2
  354. package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  355. package/packages/pi-ai/package.json +3 -2
  356. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +2 -2
  357. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  358. package/packages/pi-coding-agent/dist/core/auth-storage.js +19 -13
  359. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  360. package/packages/pi-coding-agent/dist/core/capability-patches.d.ts.map +1 -1
  361. package/packages/pi-coding-agent/dist/core/capability-patches.js +3 -1
  362. package/packages/pi-coding-agent/dist/core/capability-patches.js.map +1 -1
  363. package/packages/pi-coding-agent/dist/core/provider-readiness.d.ts.map +1 -1
  364. package/packages/pi-coding-agent/dist/core/provider-readiness.js +13 -6
  365. package/packages/pi-coding-agent/dist/core/provider-readiness.js.map +1 -1
  366. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +11 -0
  367. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
  368. package/packages/pi-coding-agent/dist/core/tools/bash.js +53 -11
  369. package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
  370. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  371. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  372. package/packages/pi-coding-agent/dist/index.js +1 -1
  373. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  374. package/packages/pi-coding-agent/dist/utils/shell.d.ts +28 -2
  375. package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -1
  376. package/packages/pi-coding-agent/dist/utils/shell.js +56 -10
  377. package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -1
  378. package/packages/pi-coding-agent/package.json +7 -7
  379. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  380. package/packages/pi-tui/dist/tui.js +9 -0
  381. package/packages/pi-tui/dist/tui.js.map +1 -1
  382. package/packages/pi-tui/package.json +2 -2
  383. package/packages/rpc-client/package.json +2 -2
  384. package/pkg/package.json +1 -1
  385. package/src/resources/GSD-WORKFLOW.md +5 -4
  386. package/src/resources/extensions/async-jobs/async-bash-cancel.test.ts +360 -0
  387. package/src/resources/extensions/async-jobs/async-bash-tool.ts +33 -56
  388. package/src/resources/extensions/async-jobs/await-tool.test.ts +139 -0
  389. package/src/resources/extensions/async-jobs/await-tool.ts +82 -12
  390. package/src/resources/extensions/async-jobs/index.ts +79 -0
  391. package/src/resources/extensions/async-jobs/job-manager.ts +21 -1
  392. package/src/resources/extensions/bg-shell/bg-shell-command.ts +6 -6
  393. package/src/resources/extensions/bg-shell/bg-shell-tool.ts +10 -6
  394. package/src/resources/extensions/bg-shell/overlay.ts +9 -5
  395. package/src/resources/extensions/bg-shell/process-manager.ts +50 -25
  396. package/src/resources/extensions/bg-shell/readiness-detector.ts +12 -0
  397. package/src/resources/extensions/bg-shell/tests/lifecycle-and-utilities.test.ts +48 -1
  398. package/src/resources/extensions/bg-shell/utilities.ts +5 -2
  399. package/src/resources/extensions/browser-tools/engine/managed-gsd-browser.ts +265 -98
  400. package/src/resources/extensions/browser-tools/engine/selection.ts +90 -4
  401. package/src/resources/extensions/browser-tools/index.ts +71 -13
  402. package/src/resources/extensions/browser-tools/tests/browser-engine-selection.test.mjs +83 -13
  403. package/src/resources/extensions/browser-tools/tests/gsd-browser-launch-config.test.mjs +40 -1
  404. package/src/resources/extensions/browser-tools/tests/managed-gsd-browser-tools.test.mjs +136 -0
  405. package/src/resources/extensions/claude-code-cli/models.ts +9 -0
  406. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +40 -4
  407. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +28 -0
  408. package/src/resources/extensions/gsd/auto/custom-verify-retry-store.ts +21 -3
  409. package/src/resources/extensions/gsd/auto/detect-stuck.ts +32 -9
  410. package/src/resources/extensions/gsd/auto/dispatch-history.ts +152 -0
  411. package/src/resources/extensions/gsd/auto/dispatch-key.ts +39 -0
  412. package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -1
  413. package/src/resources/extensions/gsd/auto/loop.ts +4 -1
  414. package/src/resources/extensions/gsd/auto/orchestrator.ts +137 -61
  415. package/src/resources/extensions/gsd/auto/phases.ts +74 -26
  416. package/src/resources/extensions/gsd/auto/session.ts +3 -0
  417. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +18 -48
  418. package/src/resources/extensions/gsd/auto-dispatch.ts +48 -61
  419. package/src/resources/extensions/gsd/auto-model-selection.ts +41 -12
  420. package/src/resources/extensions/gsd/auto-post-unit.ts +52 -13
  421. package/src/resources/extensions/gsd/auto-prompts.ts +118 -35
  422. package/src/resources/extensions/gsd/auto-start.ts +24 -29
  423. package/src/resources/extensions/gsd/auto-tool-tracking.ts +19 -0
  424. package/src/resources/extensions/gsd/auto-unit-closeout.ts +83 -28
  425. package/src/resources/extensions/gsd/auto-unit-tool-scope.ts +14 -21
  426. package/src/resources/extensions/gsd/auto-verification.ts +26 -28
  427. package/src/resources/extensions/gsd/auto-worktree-repair.ts +13 -2
  428. package/src/resources/extensions/gsd/auto-worktree.ts +41 -364
  429. package/src/resources/extensions/gsd/auto.ts +64 -25
  430. package/src/resources/extensions/gsd/blocked-models.ts +49 -0
  431. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +37 -10
  432. package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +33 -12
  433. package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +2 -2
  434. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +24 -0
  435. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +270 -37
  436. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +368 -78
  437. package/src/resources/extensions/gsd/branch-patterns.ts +3 -0
  438. package/src/resources/extensions/gsd/browser-daemon-auto-prep.ts +108 -0
  439. package/src/resources/extensions/gsd/browser-evidence.ts +18 -2
  440. package/src/resources/extensions/gsd/captures.ts +5 -16
  441. package/src/resources/extensions/gsd/closeout-recovery.ts +2 -1
  442. package/src/resources/extensions/gsd/closeout-wizard.ts +102 -0
  443. package/src/resources/extensions/gsd/commands/catalog.ts +6 -68
  444. package/src/resources/extensions/gsd/commands/context.ts +16 -2
  445. package/src/resources/extensions/gsd/commands-handlers.ts +46 -3
  446. package/src/resources/extensions/gsd/consent-question.ts +431 -0
  447. package/src/resources/extensions/gsd/consent-verdict.ts +86 -0
  448. package/src/resources/extensions/gsd/constants.ts +0 -3
  449. package/src/resources/extensions/gsd/crash-recovery.ts +13 -11
  450. package/src/resources/extensions/gsd/db/engine.ts +809 -0
  451. package/src/resources/extensions/gsd/db/queries.ts +490 -0
  452. package/src/resources/extensions/gsd/db/sql-constants.ts +12 -0
  453. package/src/resources/extensions/gsd/db/writers/cascades.ts +237 -0
  454. package/src/resources/extensions/gsd/db/writers/import-restore.ts +310 -0
  455. package/src/resources/extensions/gsd/db/writers/memory.ts +220 -0
  456. package/src/resources/extensions/gsd/db/writers/reconcile.ts +500 -0
  457. package/src/resources/extensions/gsd/db/writers/status.ts +88 -0
  458. package/src/resources/extensions/gsd/dispatch-guard.ts +8 -31
  459. package/src/resources/extensions/gsd/doctor-engine-checks.ts +3 -3
  460. package/src/resources/extensions/gsd/doctor-environment.ts +5 -13
  461. package/src/resources/extensions/gsd/doctor-format.ts +12 -7
  462. package/src/resources/extensions/gsd/doctor-git-checks.ts +5 -22
  463. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +22 -17
  464. package/src/resources/extensions/gsd/engine-hook-contract.ts +79 -0
  465. package/src/resources/extensions/gsd/error-classifier.ts +11 -0
  466. package/src/resources/extensions/gsd/exec-sandbox.ts +49 -9
  467. package/src/resources/extensions/gsd/files.ts +33 -12
  468. package/src/resources/extensions/gsd/git-service.ts +1 -0
  469. package/src/resources/extensions/gsd/gitignore.ts +3 -0
  470. package/src/resources/extensions/gsd/gsd-command-home.ts +13 -3
  471. package/src/resources/extensions/gsd/gsd-db.ts +176 -2375
  472. package/src/resources/extensions/gsd/guidance.ts +217 -0
  473. package/src/resources/extensions/gsd/guided-flow.ts +71 -31
  474. package/src/resources/extensions/gsd/markdown-renderer.ts +11 -0
  475. package/src/resources/extensions/gsd/mcp-filter.ts +2 -23
  476. package/src/resources/extensions/gsd/mcp-tool-name.ts +6 -11
  477. package/src/resources/extensions/gsd/memory-consolidation-scanner.ts +1 -1
  478. package/src/resources/extensions/gsd/migrate/safety.ts +18 -7
  479. package/src/resources/extensions/gsd/migration-auto-check.ts +28 -3
  480. package/src/resources/extensions/gsd/milestone-closeout.ts +109 -24
  481. package/src/resources/extensions/gsd/milestone-planning-persistence.ts +2 -2
  482. package/src/resources/extensions/gsd/model-cost-table.ts +1 -0
  483. package/src/resources/extensions/gsd/model-router.ts +3 -0
  484. package/src/resources/extensions/gsd/notification-store.ts +26 -3
  485. package/src/resources/extensions/gsd/parallel-merge.ts +12 -9
  486. package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +10 -7
  487. package/src/resources/extensions/gsd/parsers-legacy.ts +16 -4
  488. package/src/resources/extensions/gsd/paths.ts +42 -22
  489. package/src/resources/extensions/gsd/pre-execution-checks.ts +109 -3
  490. package/src/resources/extensions/gsd/preferences-models.ts +12 -47
  491. package/src/resources/extensions/gsd/preferences.ts +18 -0
  492. package/src/resources/extensions/gsd/projection-flush.ts +20 -0
  493. package/src/resources/extensions/gsd/prompts/complete-slice.md +3 -3
  494. package/src/resources/extensions/gsd/prompts/execute-task.md +1 -1
  495. package/src/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
  496. package/src/resources/extensions/gsd/prompts/plan-slice.md +2 -2
  497. package/src/resources/extensions/gsd/prompts/quick-task.md +1 -1
  498. package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
  499. package/src/resources/extensions/gsd/prompts/refine-slice.md +2 -2
  500. package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
  501. package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
  502. package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
  503. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
  504. package/src/resources/extensions/gsd/prompts/run-uat.md +7 -5
  505. package/src/resources/extensions/gsd/prompts/system.md +5 -2
  506. package/src/resources/extensions/gsd/prompts/triage-captures.md +1 -1
  507. package/src/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
  508. package/src/resources/extensions/gsd/provider-error-guidance.ts +4 -9
  509. package/src/resources/extensions/gsd/provider-switch-observer.ts +1 -1
  510. package/src/resources/extensions/gsd/publication.ts +122 -0
  511. package/src/resources/extensions/gsd/reactive-graph.ts +11 -1
  512. package/src/resources/extensions/gsd/recovery-classification.ts +47 -88
  513. package/src/resources/extensions/gsd/roadmap-slices.ts +28 -3
  514. package/src/resources/extensions/gsd/safety/destructive-confirmation.ts +134 -0
  515. package/src/resources/extensions/gsd/safety/evidence-collector.ts +36 -4
  516. package/src/resources/extensions/gsd/safety/evidence-cross-ref.ts +7 -2
  517. package/src/resources/extensions/gsd/safety/file-change-validator.ts +14 -0
  518. package/src/resources/extensions/gsd/session-lock.ts +1 -1
  519. package/src/resources/extensions/gsd/state-transition-matrix.ts +42 -0
  520. package/src/resources/extensions/gsd/state.ts +9 -21
  521. package/src/resources/extensions/gsd/status-guards.ts +59 -8
  522. package/src/resources/extensions/gsd/stop-notice.ts +75 -0
  523. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +123 -0
  524. package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +91 -0
  525. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +198 -26
  526. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +3 -1
  527. package/src/resources/extensions/gsd/tests/auto-post-unit-evidence-crossref-4909.test.ts +46 -0
  528. package/src/resources/extensions/gsd/tests/auto-remote-session-lock-cleanup.test.ts +65 -3
  529. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +2 -2
  530. package/src/resources/extensions/gsd/tests/auto-worktree-repair.test.ts +4 -2
  531. package/src/resources/extensions/gsd/tests/blocked-models.test.ts +19 -0
  532. package/src/resources/extensions/gsd/tests/browser-automation-contract-fixture.ts +39 -0
  533. package/src/resources/extensions/gsd/tests/browser-contract.test.ts +44 -0
  534. package/src/resources/extensions/gsd/tests/browser-daemon-auto-prep.test.ts +144 -0
  535. package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +66 -1
  536. package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +44 -0
  537. package/src/resources/extensions/gsd/tests/commands-verdict.test.ts +8 -7
  538. package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +42 -0
  539. package/src/resources/extensions/gsd/tests/consent-question.test.ts +351 -0
  540. package/src/resources/extensions/gsd/tests/custom-verify-retry-store.test.ts +67 -0
  541. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +10 -10
  542. package/src/resources/extensions/gsd/tests/destructive-confirmation.test.ts +303 -0
  543. package/src/resources/extensions/gsd/tests/dispatch-history.test.ts +273 -0
  544. package/src/resources/extensions/gsd/tests/dispatch-run-uat-browser-tools.test.ts +2 -1
  545. package/src/resources/extensions/gsd/tests/doctor-git-checks-terminal.test.ts +73 -0
  546. package/src/resources/extensions/gsd/tests/dynamic-bash-no-cap.test.ts +132 -0
  547. package/src/resources/extensions/gsd/tests/engine-hook-contract.test.ts +148 -0
  548. package/src/resources/extensions/gsd/tests/evidence-xref-gsd-exec.test.ts +157 -0
  549. package/src/resources/extensions/gsd/tests/exec-graceful-kill.test.ts +193 -0
  550. package/src/resources/extensions/gsd/tests/exec-tool.test.ts +29 -1
  551. package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +35 -1
  552. package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +33 -1
  553. package/src/resources/extensions/gsd/tests/gsd-command-home.test.ts +120 -0
  554. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +27 -0
  555. package/src/resources/extensions/gsd/tests/guidance.test.ts +148 -0
  556. package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +2 -6
  557. package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +58 -15
  558. package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +74 -59
  559. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +3 -2
  560. package/src/resources/extensions/gsd/tests/integration/gsd-integration-fixture.ts +80 -0
  561. package/src/resources/extensions/gsd/tests/integration/run-uat.test.ts +199 -0
  562. package/src/resources/extensions/gsd/tests/mcp-project-config.test.ts +3 -1
  563. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +85 -1
  564. package/src/resources/extensions/gsd/tests/milestone-closeout.test.ts +95 -4
  565. package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +32 -1
  566. package/src/resources/extensions/gsd/tests/notification-store.test.ts +32 -0
  567. package/src/resources/extensions/gsd/tests/oauth-api-model-routing.test.ts +167 -0
  568. package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +18 -0
  569. package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +138 -0
  570. package/src/resources/extensions/gsd/tests/phases-terminal-complete-idempotent.test.ts +242 -0
  571. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +63 -2
  572. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +193 -1
  573. package/src/resources/extensions/gsd/tests/prompt-db.test.ts +124 -6
  574. package/src/resources/extensions/gsd/tests/provider-error-guidance.test.ts +3 -3
  575. package/src/resources/extensions/gsd/tests/publication.test.ts +120 -0
  576. package/src/resources/extensions/gsd/tests/recovery-classification-illegal-transition.test.ts +30 -0
  577. package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +248 -1
  578. package/src/resources/extensions/gsd/tests/roadmap-slices.test.ts +68 -0
  579. package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +20 -1
  580. package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +38 -0
  581. package/src/resources/extensions/gsd/tests/session-switch-clears-pending-autostart.test.ts +108 -0
  582. package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +43 -6
  583. package/src/resources/extensions/gsd/tests/state-transition-matrix.test.ts +36 -0
  584. package/src/resources/extensions/gsd/tests/status-guards.test.ts +38 -0
  585. package/src/resources/extensions/gsd/tests/stop-notice.test.ts +70 -0
  586. package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +76 -0
  587. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +8 -0
  588. package/src/resources/extensions/gsd/tests/tool-surface-readiness.test.ts +155 -0
  589. package/src/resources/extensions/gsd/tests/tool-unavailable-retry.test.ts +33 -0
  590. package/src/resources/extensions/gsd/tests/transport-gate-double-complete.test.ts +139 -0
  591. package/src/resources/extensions/gsd/tests/uat-policy.test.ts +112 -29
  592. package/src/resources/extensions/gsd/tests/unit-closeout.test.ts +209 -0
  593. package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +67 -2
  594. package/src/resources/extensions/gsd/tests/unit-registry.test.ts +163 -0
  595. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +2 -0
  596. package/src/resources/extensions/gsd/tests/web-app-uat.test.ts +44 -1
  597. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +2 -2
  598. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +275 -40
  599. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +41 -4
  600. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +22 -1
  601. package/src/resources/extensions/gsd/tests/worktree-placement.test.ts +113 -0
  602. package/src/resources/extensions/gsd/tests/worktree-reentry.test.ts +1 -1
  603. package/src/resources/extensions/gsd/tests/worktree-safety.test.ts +3 -1
  604. package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +12 -6
  605. package/src/resources/extensions/gsd/tests/worktree-teardown-safety.test.ts +2 -2
  606. package/src/resources/extensions/gsd/tests/write-gate-seam.test.ts +358 -0
  607. package/src/resources/extensions/gsd/tests/write-gate.test.ts +109 -1
  608. package/src/resources/extensions/gsd/tool-contract.ts +38 -3
  609. package/src/resources/extensions/gsd/tool-presentation-plan.ts +4 -4
  610. package/src/resources/extensions/gsd/tool-surface-readiness.ts +76 -0
  611. package/src/resources/extensions/gsd/tools/complete-milestone.ts +3 -2
  612. package/src/resources/extensions/gsd/tools/complete-slice.ts +45 -70
  613. package/src/resources/extensions/gsd/tools/complete-task.ts +3 -2
  614. package/src/resources/extensions/gsd/tools/exec-tool.ts +9 -8
  615. package/src/resources/extensions/gsd/tools/plan-slice.ts +14 -8
  616. package/src/resources/extensions/gsd/tools/plan-task.ts +2 -2
  617. package/src/resources/extensions/gsd/tools/reassess-roadmap.ts +2 -2
  618. package/src/resources/extensions/gsd/tools/reopen-milestone.ts +13 -40
  619. package/src/resources/extensions/gsd/tools/reopen-slice.ts +16 -44
  620. package/src/resources/extensions/gsd/tools/reopen-task.ts +2 -2
  621. package/src/resources/extensions/gsd/tools/replan-slice.ts +2 -2
  622. package/src/resources/extensions/gsd/tools/skip-slice.ts +18 -44
  623. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +81 -2
  624. package/src/resources/extensions/gsd/uat-policy.ts +62 -16
  625. package/src/resources/extensions/gsd/undo.ts +9 -8
  626. package/src/resources/extensions/gsd/unit-closeout.ts +201 -0
  627. package/src/resources/extensions/gsd/unit-context-composer.ts +111 -1
  628. package/src/resources/extensions/gsd/unit-context-manifest.ts +4 -28
  629. package/src/resources/extensions/gsd/unit-registry.ts +412 -0
  630. package/src/resources/extensions/gsd/unit-tool-contracts.ts +27 -192
  631. package/src/resources/extensions/gsd/verdict-parser.ts +1 -1
  632. package/src/resources/extensions/gsd/verification-verdict.ts +4 -2
  633. package/src/resources/extensions/gsd/web-app-uat.ts +51 -8
  634. package/src/resources/extensions/gsd/workflow-tool-surface.ts +4 -1
  635. package/src/resources/extensions/gsd/worktree-git-recovery.ts +314 -0
  636. package/src/resources/extensions/gsd/worktree-lifecycle.ts +13 -9
  637. package/src/resources/extensions/gsd/worktree-manager.ts +47 -28
  638. package/src/resources/extensions/gsd/worktree-placement.ts +63 -0
  639. package/src/resources/extensions/gsd/worktree-reentry.ts +10 -7
  640. package/src/resources/extensions/gsd/worktree-root.ts +29 -6
  641. package/src/resources/extensions/gsd/worktree-safety.ts +8 -5
  642. package/src/resources/extensions/gsd/worktree-session-state.ts +11 -11
  643. package/src/resources/extensions/search-the-web/native-search.ts +5 -3
  644. package/src/resources/extensions/shared/browser-contract.ts +66 -0
  645. package/src/resources/extensions/shared/gsd-browser-cli.ts +141 -6
  646. package/src/resources/shared/gsd-browser-path-sync.ts +273 -0
  647. package/src/resources/shared/package-manager-detection.ts +1 -1
  648. package/src/resources/shared/package.json +3 -0
  649. package/src/resources/skills/create-skill/references/executable-code.md +1 -1
  650. package/src/resources/skills/create-skill/workflows/add-reference.md +8 -3
  651. package/src/resources/skills/create-skill/workflows/add-script.md +4 -2
  652. package/src/resources/skills/create-skill/workflows/add-template.md +3 -1
  653. package/src/resources/skills/create-skill/workflows/add-workflow.md +8 -3
  654. package/src/resources/skills/create-skill/workflows/upgrade-to-router.md +10 -5
  655. package/src/resources/skills/create-skill/workflows/verify-skill.md +9 -4
  656. package/src/resources/skills/gsd-browser/SKILL.md +1 -1
  657. package/src/resources/skills/spike-wrap-up/SKILL.md +9 -9
  658. package/dist/resources/extensions/gsd/user-input-boundary.js +0 -218
  659. package/src/resources/extensions/gsd/tests/user-input-boundary.test.ts +0 -173
  660. package/src/resources/extensions/gsd/user-input-boundary.ts +0 -216
  661. /package/dist/web/standalone/.next/static/{3PtrU9qGPEXwNLWkIyiqk → McokybTayhff1xEVc-d3T}/_buildManifest.js +0 -0
  662. /package/dist/web/standalone/.next/static/{3PtrU9qGPEXwNLWkIyiqk → McokybTayhff1xEVc-d3T}/_ssgManifest.js +0 -0
@@ -7,6 +7,9 @@
7
7
 
8
8
  import { describe, test } from 'node:test';
9
9
  import assert from 'node:assert/strict';
10
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
11
+ import { join } from 'node:path';
12
+ import { tmpdir } from 'node:os';
10
13
  import {
11
14
  openDatabase,
12
15
  closeDatabase,
@@ -22,6 +25,17 @@ import {
22
25
  formatDecisionsForPrompt,
23
26
  formatRequirementsForPrompt,
24
27
  } from '../context-store.ts';
28
+ import { inlineRequirementsFromDb } from '../auto-prompts.ts';
29
+ import { migrateFromMarkdown } from '../md-importer.ts';
30
+
31
+ function createDbProjectWithRequirements(content: string): { tmpDir: string; gsdDir: string } {
32
+ const tmpDir = mkdtempSync(join(tmpdir(), 'prompt-db-requirements-'));
33
+ const gsdDir = join(tmpDir, '.gsd');
34
+ mkdirSync(gsdDir, { recursive: true });
35
+ writeFileSync(join(gsdDir, 'REQUIREMENTS.md'), content);
36
+ openDatabase(join(gsdDir, 'gsd.db'));
37
+ return { tmpDir, gsdDir };
38
+ }
25
39
 
26
40
  // ═══════════════════════════════════════════════════════════════════════════
27
41
  // prompt-db: DB-aware decisions helper returns scoped content
@@ -182,6 +196,116 @@ console.log('\n=== prompt-db: fallback when DB unavailable ===');
182
196
  assert.deepStrictEqual(formattedReqs, '', 'formatRequirementsForPrompt returns empty for empty input');
183
197
  }
184
198
 
199
+ // ═══════════════════════════════════════════════════════════════════════════
200
+ // prompt-db: DB-aware requirements helper does not fall back on empty DB rows
201
+ // ═══════════════════════════════════════════════════════════════════════════
202
+
203
+ test('prompt-db: inlineRequirementsFromDb returns null instead of full file when DB query is empty', async () => {
204
+ const { tmpDir } = createDbProjectWithRequirements(
205
+ `# Requirements\n\nFULL FILE SHOULD NOT BE INLINED\n\n${'large requirement body\n'.repeat(500)}`,
206
+ );
207
+ try {
208
+ const inlined = await inlineRequirementsFromDb(tmpDir, 'M999', undefined, 'full');
209
+
210
+ assert.equal(inlined, null);
211
+ } finally {
212
+ closeDatabase();
213
+ rmSync(tmpDir, { recursive: true, force: true });
214
+ }
215
+ });
216
+
217
+ test('prompt-db: inlineRequirementsFromDb cascades from empty milestone query to active requirements', async () => {
218
+ const { tmpDir } = createDbProjectWithRequirements(
219
+ '# Requirements\n\nFULL FILE SHOULD NOT BE INLINED\n',
220
+ );
221
+ try {
222
+ insertRequirement({
223
+ id: 'R001',
224
+ class: 'functional',
225
+ status: 'active',
226
+ description: 'active requirement for another milestone',
227
+ why: 'needed',
228
+ source: 'M001',
229
+ primary_owner: 'M001/S01',
230
+ supporting_slices: '',
231
+ validation: 'test',
232
+ notes: '',
233
+ full_content: '',
234
+ superseded_by: null,
235
+ });
236
+ insertRequirement({
237
+ id: 'R002',
238
+ class: 'functional',
239
+ status: 'validated',
240
+ description: 'validated requirement should not be active fallback',
241
+ why: 'already done',
242
+ source: 'M001',
243
+ primary_owner: 'M001/S02',
244
+ supporting_slices: '',
245
+ validation: 'done',
246
+ notes: '',
247
+ full_content: '',
248
+ superseded_by: null,
249
+ });
250
+
251
+ const inlined = await inlineRequirementsFromDb(tmpDir, 'M999', undefined, 'full');
252
+
253
+ assert.ok(inlined);
254
+ assert.match(inlined, /### Requirements/);
255
+ assert.match(inlined, /# Requirements \(compact\)/);
256
+ assert.match(inlined, /R001/);
257
+ assert.match(inlined, /active requirement for another milestone/);
258
+ assert.doesNotMatch(inlined, /R002/);
259
+ assert.doesNotMatch(inlined, /FULL FILE SHOULD NOT BE INLINED/);
260
+ } finally {
261
+ closeDatabase();
262
+ rmSync(tmpDir, { recursive: true, force: true });
263
+ }
264
+ });
265
+
266
+ test('prompt-db: inlineRequirementsFromDb keeps active fallback compact for slice-scoped full calls', async () => {
267
+ const { tmpDir } = createDbProjectWithRequirements(
268
+ '# Requirements\n\nFULL FILE SHOULD NOT BE INLINED\n',
269
+ );
270
+ try {
271
+ insertRequirement({
272
+ id: 'R001',
273
+ class: 'functional',
274
+ status: 'active',
275
+ description: 'active requirement for another milestone',
276
+ why: 'needed',
277
+ source: 'M001',
278
+ primary_owner: 'M001/S01',
279
+ supporting_slices: '',
280
+ validation: 'test',
281
+ notes: '',
282
+ full_content: '',
283
+ superseded_by: null,
284
+ });
285
+
286
+ // Slice-scoped call at inlineLevel "full" with no matching rows for the
287
+ // milestone+slice or milestone-only queries. The cascade should land on
288
+ // status: "active" rows from another milestone, and those project-wide
289
+ // active rows must be formatted compactly even though sliceId is set —
290
+ // otherwise the full per-requirement markdown would be inlined for every
291
+ // active row across the project.
292
+ const inlined = await inlineRequirementsFromDb(tmpDir, 'M999', 'S99', 'full');
293
+
294
+ assert.ok(inlined);
295
+ assert.match(inlined, /### Requirements/);
296
+ assert.match(inlined, /# Requirements \(compact\)/);
297
+ assert.match(inlined, /R001/);
298
+ // Full per-requirement markdown is forbidden here — its hallmark fields
299
+ // (Class:/Status:/Why: as bolded list items) are emitted only by
300
+ // formatRequirementsForPrompt, never by formatRequirementsCompact.
301
+ assert.doesNotMatch(inlined, /\*\*Class:\*\*/);
302
+ assert.doesNotMatch(inlined, /FULL FILE SHOULD NOT BE INLINED/);
303
+ } finally {
304
+ closeDatabase();
305
+ rmSync(tmpDir, { recursive: true, force: true });
306
+ }
307
+ });
308
+
185
309
  // ═══════════════════════════════════════════════════════════════════════════
186
310
  // prompt-db: scoped filtering reduces content vs unscoped
187
311
  // ═══════════════════════════════════════════════════════════════════════════
@@ -316,12 +440,6 @@ console.log('\n=== prompt-db: DB helpers wrapper format matches expected pattern
316
440
  // prompt-db: re-import updates DB when source markdown changes
317
441
  // ═══════════════════════════════════════════════════════════════════════════
318
442
 
319
- import { mkdtempSync, writeFileSync, mkdirSync } from 'node:fs';
320
- import { join } from 'node:path';
321
- import { tmpdir } from 'node:os';
322
- import { migrateFromMarkdown } from '../md-importer.ts';
323
-
324
-
325
443
  describe('prompt-db', () => {
326
444
  test('prompt-db: re-import updates DB when source markdown changes', () => {
327
445
  // Create a temp dir simulating a project with .gsd/DECISIONS.md
@@ -3,10 +3,10 @@ import assert from "node:assert/strict";
3
3
 
4
4
  import { classifyError, isTransient } from "../error-classifier.ts";
5
5
  import {
6
- formatProviderErrorGuidance,
7
6
  resolveProviderErrorGuidance,
8
7
  unitTypeToPrefsPhaseKey,
9
8
  } from "../provider-error-guidance.ts";
9
+ import { formatGuidance } from "../guidance.ts";
10
10
 
11
11
  test("classifyError: Cloud Code Assist 400 invalid argument is model-error", () => {
12
12
  const result = classifyError(
@@ -75,8 +75,8 @@ test("resolveProviderErrorGuidance suggests gemini-3-flash for antigravity pro-h
75
75
  assert.ok(guidance.steps.some((step) => step.includes("fallbacks")));
76
76
  });
77
77
 
78
- test("formatProviderErrorGuidance numbers steps", () => {
79
- const text = formatProviderErrorGuidance({
78
+ test("formatGuidance numbers steps", () => {
79
+ const text = formatGuidance({
80
80
  summary: "Provider error on test/model.",
81
81
  steps: ["Change model", "Run /gsd next"],
82
82
  });
@@ -0,0 +1,120 @@
1
+ // gsd-pi — ADR-034 Publication module tests.
2
+ //
3
+ // Exercises publishMilestone against real local git fixtures (a bare repo as
4
+ // the remote) — no network, no gh. The PR path is only tested up to its
5
+ // non-fatal failure contract, since createDraftPullRequestFromEvidence shells
6
+ // out to gh.
7
+
8
+ import test from "node:test";
9
+ import assert from "node:assert/strict";
10
+ import { rmSync } from "node:fs";
11
+ import { join } from "node:path";
12
+
13
+ import { gitRemoteExists, publishMilestone } from "../publication.ts";
14
+ import { git, makeTempDir, makeTempRepo } from "./test-utils.ts";
15
+
16
+ function makeRepoWithBareRemote(): { repo: string; bare: string; cleanup: () => void } {
17
+ const repo = makeTempRepo("gsd-publication-test-");
18
+ const bare = join(makeTempDir("gsd-publication-remote-"), "remote.git");
19
+ git(repo, "init", "--bare", bare);
20
+ git(repo, "remote", "add", "origin", bare);
21
+ return {
22
+ repo,
23
+ bare,
24
+ cleanup: () => {
25
+ rmSync(repo, { recursive: true, force: true });
26
+ rmSync(bare, { recursive: true, force: true });
27
+ },
28
+ };
29
+ }
30
+
31
+ const NO_PUBLISH_PREFS = { autoPush: false, autoPr: false };
32
+
33
+ function makeRequest(repo: string, prefs: { autoPush: boolean; autoPr: boolean; remote?: string; prTargetBranch?: string }) {
34
+ return {
35
+ basePath: repo,
36
+ milestoneId: "M001",
37
+ milestoneTitle: "Test milestone",
38
+ integrationBranch: "main",
39
+ milestoneBranch: "milestone/M001",
40
+ sliceSummaries: ["### S01\nSlice one"],
41
+ nothingToCommit: false,
42
+ prefs,
43
+ };
44
+ }
45
+
46
+ test("gitRemoteExists distinguishes configured from missing remotes", () => {
47
+ const { repo, cleanup } = makeRepoWithBareRemote();
48
+ try {
49
+ assert.equal(gitRemoteExists(repo, "origin"), true);
50
+ assert.equal(gitRemoteExists(repo, "upstream"), false);
51
+ } finally {
52
+ cleanup();
53
+ }
54
+ });
55
+
56
+ test("auto-push pushes the integration branch to the remote", () => {
57
+ const { repo, bare, cleanup } = makeRepoWithBareRemote();
58
+ try {
59
+ const result = publishMilestone(makeRequest(repo, { autoPush: true, autoPr: false }));
60
+ assert.equal(result.pushed, true);
61
+ assert.equal(result.prCreated, false);
62
+ const remoteHeads = git(repo, "ls-remote", "--heads", bare);
63
+ assert.match(remoteHeads, /refs\/heads\/main/);
64
+ } finally {
65
+ cleanup();
66
+ }
67
+ });
68
+
69
+ test("auto-push is suppressed when auto-PR owns the remote interaction", () => {
70
+ const { repo, bare, cleanup } = makeRepoWithBareRemote();
71
+ try {
72
+ git(repo, "branch", "milestone/M001");
73
+ const result = publishMilestone(makeRequest(repo, { autoPush: true, autoPr: true }));
74
+ // PR creation pushes the milestone branch, then fails non-fatally at gh.
75
+ assert.equal(result.pushed, false);
76
+ assert.equal(result.prCreated, false);
77
+ assert.equal(result.prUrl, undefined);
78
+ const remoteHeads = git(repo, "ls-remote", "--heads", bare);
79
+ assert.match(remoteHeads, /refs\/heads\/milestone\/M001/);
80
+ assert.doesNotMatch(remoteHeads, /refs\/heads\/main/);
81
+ } finally {
82
+ cleanup();
83
+ }
84
+ });
85
+
86
+ test("nothing-to-commit short-circuits all publication", () => {
87
+ const { repo, bare, cleanup } = makeRepoWithBareRemote();
88
+ try {
89
+ const result = publishMilestone({
90
+ ...makeRequest(repo, { autoPush: true, autoPr: false }),
91
+ nothingToCommit: true,
92
+ });
93
+ assert.deepEqual(result, { pushed: false, prCreated: false });
94
+ const remoteHeads = git(repo, "ls-remote", "--heads", bare);
95
+ assert.equal(remoteHeads.trim(), "");
96
+ } finally {
97
+ cleanup();
98
+ }
99
+ });
100
+
101
+ test("missing remote makes publication a silent no-op", () => {
102
+ const { repo, cleanup } = makeRepoWithBareRemote();
103
+ try {
104
+ git(repo, "remote", "remove", "origin");
105
+ const result = publishMilestone(makeRequest(repo, { autoPush: true, autoPr: true }));
106
+ assert.deepEqual(result, { pushed: false, prCreated: false });
107
+ } finally {
108
+ cleanup();
109
+ }
110
+ });
111
+
112
+ test("publication disabled returns the empty result without touching git", () => {
113
+ const { repo, cleanup } = makeRepoWithBareRemote();
114
+ try {
115
+ const result = publishMilestone(makeRequest(repo, NO_PUBLISH_PREFS));
116
+ assert.deepEqual(result, { pushed: false, prCreated: false });
117
+ } finally {
118
+ cleanup();
119
+ }
120
+ });
@@ -0,0 +1,30 @@
1
+ // GSD — recovery-classification: illegal-transition kind (ADR-030)
2
+
3
+ import test from "node:test";
4
+ import assert from "node:assert/strict";
5
+
6
+ import { classifyFailure } from "../recovery-classification.ts";
7
+ import { IllegalPhaseTransitionError } from "../state-transition-matrix.ts";
8
+
9
+ test("classifyFailure recognizes IllegalPhaseTransitionError by class and escalates", () => {
10
+ const classification = classifyFailure({
11
+ error: new IllegalPhaseTransitionError("executing", "complete"),
12
+ unitType: "execute-task",
13
+ unitId: "T-1",
14
+ });
15
+
16
+ assert.equal(classification.failureKind, "illegal-transition");
17
+ assert.equal(classification.action, "escalate");
18
+ assert.equal(classification.exitReason, "illegal-transition");
19
+ assert.match(classification.reason, /Illegal phase transition/);
20
+ });
21
+
22
+ test("classifyFailure routes an explicit illegal-transition failureKind to the same case", () => {
23
+ const classification = classifyFailure({
24
+ error: new Error("derived edge rejected"),
25
+ failureKind: "illegal-transition",
26
+ });
27
+
28
+ assert.equal(classification.failureKind, "illegal-transition");
29
+ assert.equal(classification.action, "escalate");
30
+ });
@@ -1,6 +1,6 @@
1
1
  import test from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
3
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { tmpdir } from "node:os";
6
6
 
@@ -13,7 +13,11 @@ import { closeDatabase, getMilestone } from "../gsd-db.ts";
13
13
  import { deriveState, invalidateStateCache } from "../state.ts";
14
14
  import {
15
15
  getPendingGate,
16
+ loadWriteGateSnapshot,
17
+ markApprovalGateVerified,
18
+ markDepthVerified,
16
19
  resetWriteGateState,
20
+ setPendingGate,
17
21
  shouldBlockContextArtifactSave,
18
22
  } from "../bootstrap/write-gate.ts";
19
23
  import { classifyCommand } from "../safety/destructive-guard.ts";
@@ -802,3 +806,246 @@ test("register-hooks message_update does NOT pause while an interactive elicitat
802
806
  "prose-only approval with no elicitation in flight must still arm the pause notice",
803
807
  );
804
808
  });
809
+
810
+ test("register-hooks agent_end does not re-arm deferred gate after workflow MCP verified write-gate on disk", async (t) => {
811
+ const dir = makeTempDir("mcp-disk-sync");
812
+ const originalCwd = process.cwd();
813
+ const originalEnv = process.env.GSD_PERSIST_WRITE_GATE_STATE;
814
+ process.chdir(dir);
815
+ resetWriteGateState(dir);
816
+ clearPendingAutoStart(dir);
817
+ process.env.GSD_PERSIST_WRITE_GATE_STATE = "1";
818
+
819
+ const gateId = "depth_verification_M005_confirm";
820
+ const statePath = join(dir, ".gsd", "runtime", "write-gate-state.json");
821
+
822
+ t.after(() => {
823
+ try {
824
+ resetWriteGateState(dir);
825
+ clearPendingAutoStart(dir);
826
+ } finally {
827
+ if (originalEnv === undefined) {
828
+ delete process.env.GSD_PERSIST_WRITE_GATE_STATE;
829
+ } else {
830
+ process.env.GSD_PERSIST_WRITE_GATE_STATE = originalEnv;
831
+ }
832
+ process.chdir(originalCwd);
833
+ rmSync(dir, { recursive: true, force: true });
834
+ }
835
+ });
836
+
837
+ const handlers = new Map<string, Array<(event: any, ctx?: any) => Promise<any> | any>>();
838
+ const pi = {
839
+ on(event: string, handler: (event: any, ctx?: any) => Promise<any> | any) {
840
+ const existing = handlers.get(event) ?? [];
841
+ existing.push(handler);
842
+ handlers.set(event, existing);
843
+ },
844
+ } as any;
845
+
846
+ const ctx = {
847
+ cwd: dir,
848
+ ui: { notify: () => undefined },
849
+ } as any;
850
+
851
+ registerHooks(pi, []);
852
+
853
+ setPendingAutoStart(dir, {
854
+ basePath: dir,
855
+ milestoneId: "M005",
856
+ ctx,
857
+ pi: { sendMessage: () => undefined } as any,
858
+ });
859
+
860
+ const approvalMessage = {
861
+ role: "assistant",
862
+ content: [
863
+ { type: "text", text: "Did I capture the depth right?" },
864
+ ],
865
+ };
866
+
867
+ for (const handler of handlers.get("message_update") ?? []) {
868
+ await handler({ message: approvalMessage }, ctx);
869
+ }
870
+
871
+ setPendingGate(gateId, dir);
872
+ mkdirSync(join(dir, ".gsd", "runtime"), { recursive: true });
873
+ writeFileSync(statePath, JSON.stringify({
874
+ verifiedDepthMilestones: ["M005"],
875
+ verifiedApprovalGates: [gateId],
876
+ activeQueuePhase: false,
877
+ pendingGateId: null,
878
+ }, null, 2), "utf-8");
879
+
880
+ for (const handler of handlers.get("agent_end") ?? []) {
881
+ await handler({ messages: [] }, ctx);
882
+ }
883
+
884
+ assert.equal(getPendingGate(dir), null, "agent_end must not re-arm a gate the MCP subprocess already verified");
885
+ assert.equal(
886
+ shouldBlockContextArtifactSave("CONTEXT", "M005", null, dir).block,
887
+ false,
888
+ "verified milestone context writes must stay unlocked after agent_end",
889
+ );
890
+ assert.deepEqual(loadWriteGateSnapshot(dir), {
891
+ verifiedDepthMilestones: ["M005"],
892
+ verifiedApprovalGates: [gateId],
893
+ activeQueuePhase: false,
894
+ pendingGateId: null,
895
+ });
896
+ });
897
+
898
+ // ── External-engine post-hoc gate replay (write-gate two-process sync) ──────
899
+ // On claude-code-cli, pi ingests the SDK turn's tool blocks after the workflow
900
+ // MCP child already executed them. The depth gate can therefore arrive at
901
+ // tool_execution_start AFTER the child verified it and allowed the CONTEXT
902
+ // save; re-arming then wipes the verification and permanently blocks the
903
+ // discuss→auto handoff.
904
+
905
+ function makeHookHarness(): {
906
+ handlers: Map<string, Array<(event: any, ctx?: any) => Promise<any> | any>>;
907
+ pi: any;
908
+ } {
909
+ const handlers = new Map<string, Array<(event: any, ctx?: any) => Promise<any> | any>>();
910
+ const pi = {
911
+ on(event: string, handler: (event: any, ctx?: any) => Promise<any> | any) {
912
+ const existing = handlers.get(event) ?? [];
913
+ existing.push(handler);
914
+ handlers.set(event, existing);
915
+ },
916
+ } as any;
917
+ return { handlers, pi };
918
+ }
919
+
920
+ test("tool_execution_start does not re-arm a depth gate the MCP child already verified", async (t) => {
921
+ const dir = makeTempDir("posthoc-no-rearm");
922
+ resetWriteGateState(dir);
923
+ t.after(() => {
924
+ resetWriteGateState(dir);
925
+ rmSync(dir, { recursive: true, force: true });
926
+ });
927
+
928
+ const { handlers, pi } = makeHookHarness();
929
+ registerHooks(pi, []);
930
+ const ctx = { cwd: dir, ui: { notify: () => undefined } } as any;
931
+
932
+ // The child verified the gate and allowed the CONTEXT save before the host
933
+ // ever saw the tool block.
934
+ markApprovalGateVerified("depth_verification_M002_confirm", dir);
935
+ markDepthVerified("M002", dir);
936
+
937
+ for (const handler of handlers.get("tool_execution_start") ?? []) {
938
+ await handler({
939
+ toolCallId: "t-depth",
940
+ toolName: "mcp__gsd-workflow__ask_user_questions",
941
+ args: { questions: [{ id: "depth_verification_M002_confirm" }] },
942
+ }, ctx);
943
+ }
944
+
945
+ assert.equal(getPendingGate(dir), null, "post-hoc replay must not re-arm a verified gate");
946
+ const snapshot = loadWriteGateSnapshot(dir);
947
+ assert.ok(
948
+ snapshot.verifiedDepthMilestones.includes("M002"),
949
+ "re-arm wipes verifiedDepthMilestones — the verification must survive the replay",
950
+ );
951
+ assert.equal(
952
+ shouldBlockContextArtifactSave("CONTEXT", "M002", null, dir).block,
953
+ false,
954
+ "context saves must stay unlocked after the replayed tool_execution_start",
955
+ );
956
+ });
957
+
958
+ test("tool_execution_start still arms an unverified depth gate", async (t) => {
959
+ const dir = makeTempDir("live-arm");
960
+ resetWriteGateState(dir);
961
+ t.after(() => {
962
+ resetWriteGateState(dir);
963
+ rmSync(dir, { recursive: true, force: true });
964
+ });
965
+
966
+ const { handlers, pi } = makeHookHarness();
967
+ registerHooks(pi, []);
968
+ const ctx = { cwd: dir, ui: { notify: () => undefined } } as any;
969
+
970
+ for (const handler of handlers.get("tool_execution_start") ?? []) {
971
+ await handler({
972
+ toolCallId: "t-depth",
973
+ toolName: "ask_user_questions",
974
+ args: { questions: [{ id: "depth_verification_M002_confirm" }] },
975
+ }, ctx);
976
+ }
977
+
978
+ assert.equal(getPendingGate(dir), "depth_verification_M002_confirm");
979
+ });
980
+
981
+ test("tool_result verifies the gate from result.structuredContent when event.details is missing", async (t) => {
982
+ const dir = makeTempDir("structured-fallback");
983
+ resetWriteGateState(dir);
984
+ t.after(() => {
985
+ resetWriteGateState(dir);
986
+ rmSync(dir, { recursive: true, force: true });
987
+ });
988
+
989
+ const { handlers, pi } = makeHookHarness();
990
+ registerHooks(pi, []);
991
+ const ctx = { cwd: dir, ui: { notify: () => undefined } } as any;
992
+
993
+ setPendingGate("depth_verification_M002_confirm", dir);
994
+
995
+ const questions = [{
996
+ id: "depth_verification_M002_confirm",
997
+ options: [
998
+ { label: "Yes, you got it (Recommended)" },
999
+ { label: "Not quite — let me clarify" },
1000
+ ],
1001
+ }];
1002
+ for (const handler of handlers.get("tool_result") ?? []) {
1003
+ await handler({
1004
+ toolCallId: "t-depth",
1005
+ toolName: "mcp__gsd-workflow__ask_user_questions",
1006
+ input: { questions },
1007
+ // External MCP relay: no pi-native details, structured payload on result.
1008
+ result: {
1009
+ content: [{ type: "text", text: "answered" }],
1010
+ structuredContent: {
1011
+ questions,
1012
+ response: {
1013
+ answers: {
1014
+ depth_verification_M002_confirm: { selected: "Yes, you got it (Recommended)", notes: "" },
1015
+ },
1016
+ },
1017
+ cancelled: false,
1018
+ },
1019
+ },
1020
+ }, ctx);
1021
+ }
1022
+
1023
+ assert.equal(getPendingGate(dir), null, "structured fallback must clear the pending gate");
1024
+ assert.ok(loadWriteGateSnapshot(dir).verifiedDepthMilestones.includes("M002"));
1025
+ });
1026
+
1027
+ test("tool_result without details or structured content leaves the gate pending without crashing", async (t) => {
1028
+ const dir = makeTempDir("no-details");
1029
+ resetWriteGateState(dir);
1030
+ t.after(() => {
1031
+ resetWriteGateState(dir);
1032
+ rmSync(dir, { recursive: true, force: true });
1033
+ });
1034
+
1035
+ const { handlers, pi } = makeHookHarness();
1036
+ registerHooks(pi, []);
1037
+ const ctx = { cwd: dir, ui: { notify: () => undefined } } as any;
1038
+
1039
+ setPendingGate("depth_verification_M002_confirm", dir);
1040
+
1041
+ for (const handler of handlers.get("tool_result") ?? []) {
1042
+ await handler({
1043
+ toolCallId: "t-depth",
1044
+ toolName: "ask_user_questions",
1045
+ input: { questions: [{ id: "depth_verification_M002_confirm" }] },
1046
+ result: { content: [{ type: "text", text: "answered" }] },
1047
+ }, ctx);
1048
+ }
1049
+
1050
+ assert.equal(getPendingGate(dir), "depth_verification_M002_confirm");
1051
+ });
@@ -200,6 +200,74 @@ test("parseRoadmapSlices: checkbox slices with pipe characters do not switch to
200
200
  assert.deepEqual(slices[2]?.depends, ["S01", "S02"]);
201
201
  });
202
202
 
203
+ test("parseRoadmapSlices: demo markdown table does not switch checkbox roadmap to table mode (#721)", () => {
204
+ const checkboxWithDemoTable = [
205
+ "# M004: Demo Table Repro",
206
+ "",
207
+ "## Slices",
208
+ "",
209
+ "- [x] **S01: First** `risk:low` `depends:[]`",
210
+ " > After this: cli can render examples:",
211
+ "| Example | Meaning |",
212
+ "| --- | --- |",
213
+ "| S01 | Not a roadmap row |",
214
+ "- [ ] **S02: Second** `risk:medium` `depends:[S01]`",
215
+ " > After this: cat file | sort returns stable output.",
216
+ "",
217
+ ].join("\n");
218
+
219
+ const slices = parseRoadmapSlices(checkboxWithDemoTable);
220
+ assert.equal(slices.length, 2);
221
+ assert.equal(slices[0]?.id, "S01");
222
+ assert.equal(slices[0]?.title, "First");
223
+ assert.equal(slices[0]?.done, true);
224
+ assert.equal(slices[1]?.id, "S02");
225
+ assert.deepEqual(slices[1]?.depends, ["S01"]);
226
+ });
227
+
228
+ test("parseRoadmapSlices: table preceded by intro prose still parsed as table (#722)", () => {
229
+ const tableWithIntro = [
230
+ "# M005: Intro Before Table",
231
+ "",
232
+ "## Slices",
233
+ "",
234
+ "This milestone is broken into the following slices:",
235
+ "",
236
+ "| Slice | Title | Risk | Status |",
237
+ "| --- | --- | --- | --- |",
238
+ "| S01 | Foundation | Low | [x] Done |",
239
+ "| S02 | Core | High | [ ] Pending |",
240
+ "",
241
+ ].join("\n");
242
+
243
+ const slices = parseRoadmapSlices(tableWithIntro);
244
+ assert.equal(slices.length, 2);
245
+ assert.equal(slices[0]?.id, "S01");
246
+ assert.equal(slices[0]?.done, true);
247
+ assert.equal(slices[1]?.id, "S02");
248
+ assert.equal(slices[1]?.done, false);
249
+ });
250
+
251
+ test("parseRoadmapSlices: table without markdown separator row still parsed as table (#722)", () => {
252
+ const tableWithoutSeparator = [
253
+ "# M006: No Separator",
254
+ "",
255
+ "## Slices",
256
+ "",
257
+ "| Slice | Title | Risk | Status |",
258
+ "| S01 | Foundation | Low | [x] Done |",
259
+ "| S02 | Core | High | [ ] Pending |",
260
+ "",
261
+ ].join("\n");
262
+
263
+ const slices = parseRoadmapSlices(tableWithoutSeparator);
264
+ assert.equal(slices.length, 2);
265
+ assert.equal(slices[0]?.id, "S01");
266
+ assert.equal(slices[0]?.done, true);
267
+ assert.equal(slices[1]?.id, "S02");
268
+ assert.equal(slices[1]?.done, false);
269
+ });
270
+
203
271
  // --- Prose slice header completion marker tests (#1803) ---
204
272
 
205
273
  test("parseRoadmapSlices: prose headers with ✓ marker detected as done", () => {