@opengsd/gsd-pi 1.9.0 → 1.10.0

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 (300) hide show
  1. package/README.md +10 -10
  2. package/dist/headless.js +2 -1
  3. package/dist/resources/.managed-resources-content-hash +1 -1
  4. package/dist/resources/GSD-WORKFLOW.md +2 -2
  5. package/dist/resources/extensions/gsd/artifact-verification.js +3 -4
  6. package/dist/resources/extensions/gsd/auto/loop.js +24 -4
  7. package/dist/resources/extensions/gsd/auto/run-unit.js +19 -1
  8. package/dist/resources/extensions/gsd/auto/unit-phase.js +37 -5
  9. package/dist/resources/extensions/gsd/auto-artifact-paths.js +14 -8
  10. package/dist/resources/extensions/gsd/auto-dispatch.js +2 -0
  11. package/dist/resources/extensions/gsd/auto-prompts.js +102 -21
  12. package/dist/resources/extensions/gsd/auto-recovery.js +10 -5
  13. package/dist/resources/extensions/gsd/auto-runtime-state.js +5 -5
  14. package/dist/resources/extensions/gsd/auto-start.js +29 -9
  15. package/dist/resources/extensions/gsd/auto-tool-tracking.js +40 -0
  16. package/dist/resources/extensions/gsd/auto-worktree-cleanup.js +4 -0
  17. package/dist/resources/extensions/gsd/auto-worktree-sync.js +7 -3
  18. package/dist/resources/extensions/gsd/auto-worktree-teardown.js +1 -1
  19. package/dist/resources/extensions/gsd/auto.js +15 -5
  20. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +2 -0
  21. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +33 -7
  22. package/dist/resources/extensions/gsd/bootstrap/system-context.js +10 -3
  23. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +4 -24
  24. package/dist/resources/extensions/gsd/commands-verdict.js +10 -9
  25. package/dist/resources/extensions/gsd/compat/compat-marker.js +80 -5
  26. package/dist/resources/extensions/gsd/constants.js +12 -13
  27. package/dist/resources/extensions/gsd/context-masker.js +97 -21
  28. package/dist/resources/extensions/gsd/db/engine.js +5 -2
  29. package/dist/resources/extensions/gsd/docs/preferences-reference.md +22 -0
  30. package/dist/resources/extensions/gsd/doctor-engine-checks.js +24 -8
  31. package/dist/resources/extensions/gsd/error-classifier.js +12 -2
  32. package/dist/resources/extensions/gsd/exec-sandbox.js +1 -0
  33. package/dist/resources/extensions/gsd/flat-phase-migration.js +12 -0
  34. package/dist/resources/extensions/gsd/git-service.js +19 -7
  35. package/dist/resources/extensions/gsd/gsd-db.js +75 -31
  36. package/dist/resources/extensions/gsd/guided-flow.js +11 -5
  37. package/dist/resources/extensions/gsd/markdown-renderer.js +5 -21
  38. package/dist/resources/extensions/gsd/md-importer.js +5 -6
  39. package/dist/resources/extensions/gsd/model-cost-table.js +2 -0
  40. package/dist/resources/extensions/gsd/model-router.js +11 -0
  41. package/dist/resources/extensions/gsd/paths.js +66 -15
  42. package/dist/resources/extensions/gsd/planning-subagent-policy.js +37 -0
  43. package/dist/resources/extensions/gsd/planning-subagent-registry.js +25 -0
  44. package/dist/resources/extensions/gsd/preferences-types.js +5 -0
  45. package/dist/resources/extensions/gsd/preferences-validation.js +48 -1
  46. package/dist/resources/extensions/gsd/preferences.js +17 -0
  47. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +5 -5
  48. package/dist/resources/extensions/gsd/provider-payload-policy.js +16 -5
  49. package/dist/resources/extensions/gsd/safety/destructive-guard.js +1 -1
  50. package/dist/resources/extensions/gsd/skill-activation.js +17 -3
  51. package/dist/resources/extensions/gsd/state-reconciliation/drift/external-markdown-edit.js +98 -2
  52. package/dist/resources/extensions/gsd/state-reconciliation/drift/external-planning-edit.js +4 -1
  53. package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +5 -2
  54. package/dist/resources/extensions/gsd/stop-notice.js +9 -0
  55. package/dist/resources/extensions/gsd/templates/PREFERENCES.md +5 -0
  56. package/dist/resources/extensions/gsd/tools/complete-task.js +12 -5
  57. package/dist/resources/extensions/gsd/tools/reopen-milestone.js +14 -5
  58. package/dist/resources/extensions/gsd/tools/reopen-slice.js +15 -5
  59. package/dist/resources/extensions/gsd/tools/reopen-task.js +16 -10
  60. package/dist/resources/extensions/gsd/unit-context-composer.js +28 -5
  61. package/dist/resources/extensions/gsd/workflow-projections.js +2 -3
  62. package/dist/resources/extensions/gsd/workspace.js +2 -1
  63. package/dist/resources/extensions/gsd/worktree-state-projection.js +20 -18
  64. package/dist/resources/extensions/shared/interview-ui.js +43 -6
  65. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  66. package/dist/web/standalone/.next/BUILD_ID +1 -1
  67. package/dist/web/standalone/.next/app-path-routes-manifest.json +8 -8
  68. package/dist/web/standalone/.next/build-manifest.json +2 -2
  69. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  70. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  71. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  72. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  73. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  74. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  75. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  76. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  78. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  79. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  81. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  82. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  83. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  84. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  85. package/dist/web/standalone/.next/server/app/index.html +1 -1
  86. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  87. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  88. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  89. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  90. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  91. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app-paths-manifest.json +8 -8
  93. package/dist/web/standalone/.next/server/chunks/1991.js +2 -2
  94. package/dist/web/standalone/.next/server/chunks/5124.js +1 -1
  95. package/dist/web/standalone/.next/server/chunks/8357.js +1 -1
  96. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  97. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  98. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  99. package/dist/web/standalone/node_modules/@gsd/native/package.json +1 -1
  100. package/dist/web/standalone/node_modules/node-pty/build/Makefile +1 -1
  101. package/integrations/hermes/open_gsd_hermes/gsd_client.py +1 -1
  102. package/integrations/hermes/pyproject.toml +1 -1
  103. package/package.json +7 -6
  104. package/packages/cloud-mcp-gateway/package.json +2 -2
  105. package/packages/contracts/package.json +1 -1
  106. package/packages/daemon/package.json +4 -4
  107. package/packages/gsd-agent-core/dist/compaction/compaction.d.ts.map +1 -1
  108. package/packages/gsd-agent-core/dist/compaction/compaction.js +36 -4
  109. package/packages/gsd-agent-core/dist/compaction/compaction.js.map +1 -1
  110. package/packages/gsd-agent-core/dist/sdk.d.ts.map +1 -1
  111. package/packages/gsd-agent-core/dist/sdk.js +1 -0
  112. package/packages/gsd-agent-core/dist/sdk.js.map +1 -1
  113. package/packages/gsd-agent-core/package.json +5 -5
  114. package/packages/gsd-agent-modes/package.json +7 -7
  115. package/packages/gsd-cloud/README.md +9 -3
  116. package/packages/gsd-cloud/dist/background-cli.test.d.ts +2 -0
  117. package/packages/gsd-cloud/dist/background-cli.test.d.ts.map +1 -0
  118. package/packages/gsd-cloud/dist/background-cli.test.js +248 -0
  119. package/packages/gsd-cloud/dist/background-cli.test.js.map +1 -0
  120. package/packages/gsd-cloud/dist/cli.d.ts.map +1 -1
  121. package/packages/gsd-cloud/dist/cli.js +121 -15
  122. package/packages/gsd-cloud/dist/cli.js.map +1 -1
  123. package/packages/gsd-cloud/dist/cloud-config.d.ts +1 -1
  124. package/packages/gsd-cloud/dist/cloud-config.d.ts.map +1 -1
  125. package/packages/gsd-cloud/dist/cloud-config.js +7 -1
  126. package/packages/gsd-cloud/dist/cloud-config.js.map +1 -1
  127. package/packages/gsd-cloud/dist/cloud-runtime.d.ts +1 -3
  128. package/packages/gsd-cloud/dist/cloud-runtime.d.ts.map +1 -1
  129. package/packages/gsd-cloud/dist/cloud-runtime.js +9 -7
  130. package/packages/gsd-cloud/dist/cloud-runtime.js.map +1 -1
  131. package/packages/gsd-cloud/dist/runtime-process.d.ts +27 -0
  132. package/packages/gsd-cloud/dist/runtime-process.d.ts.map +1 -0
  133. package/packages/gsd-cloud/dist/runtime-process.js +272 -0
  134. package/packages/gsd-cloud/dist/runtime-process.js.map +1 -0
  135. package/packages/gsd-cloud/dist/runtime-process.test.d.ts +2 -0
  136. package/packages/gsd-cloud/dist/runtime-process.test.d.ts.map +1 -0
  137. package/packages/gsd-cloud/dist/runtime-process.test.js +97 -0
  138. package/packages/gsd-cloud/dist/runtime-process.test.js.map +1 -0
  139. package/packages/gsd-cloud/package.json +2 -2
  140. package/packages/mcp-server/README.md +7 -2
  141. package/packages/mcp-server/dist/cli-runner.d.ts +3 -0
  142. package/packages/mcp-server/dist/cli-runner.d.ts.map +1 -1
  143. package/packages/mcp-server/dist/cli-runner.js +119 -33
  144. package/packages/mcp-server/dist/cli-runner.js.map +1 -1
  145. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  146. package/packages/mcp-server/dist/server.js +5 -5
  147. package/packages/mcp-server/dist/server.js.map +1 -1
  148. package/packages/mcp-server/dist/workflow-tools.d.ts +4 -3
  149. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  150. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  151. package/packages/mcp-server/package.json +4 -4
  152. package/packages/native/package.json +1 -1
  153. package/packages/pi-agent-core/dist/agent.d.ts +5 -1
  154. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  155. package/packages/pi-agent-core/dist/agent.js +2 -0
  156. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  157. package/packages/pi-agent-core/package.json +1 -1
  158. package/packages/pi-ai/dist/models.generated.d.ts +76 -0
  159. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  160. package/packages/pi-ai/dist/models.generated.js +70 -0
  161. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  162. package/packages/pi-ai/dist/providers/anthropic.js +6 -1
  163. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  164. package/packages/pi-ai/dist/providers/openai-codex-responses.js +1 -1
  165. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  166. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  167. package/packages/pi-ai/dist/providers/openai-completions.js +103 -0
  168. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  169. package/packages/pi-ai/dist/providers/openai-responses.js +1 -1
  170. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
  171. package/packages/pi-ai/package.json +1 -1
  172. package/packages/pi-coding-agent/dist/core/capability-patches.js +1 -1
  173. package/packages/pi-coding-agent/dist/core/capability-patches.js.map +1 -1
  174. package/packages/pi-coding-agent/dist/core/model-resolver.js +1 -1
  175. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  176. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +11 -1
  177. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  178. package/packages/pi-coding-agent/dist/core/settings-manager.js +8 -0
  179. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  180. package/packages/pi-coding-agent/dist/core/skills.d.ts +5 -0
  181. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  182. package/packages/pi-coding-agent/dist/core/skills.js +54 -0
  183. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
  184. package/packages/pi-coding-agent/package.json +7 -7
  185. package/packages/pi-tui/package.json +2 -2
  186. package/packages/rpc-client/package.json +2 -2
  187. package/pkg/package.json +1 -1
  188. package/src/resources/GSD-WORKFLOW.md +2 -2
  189. package/src/resources/extensions/gsd/artifact-verification.ts +3 -8
  190. package/src/resources/extensions/gsd/auto/loop.ts +48 -4
  191. package/src/resources/extensions/gsd/auto/run-unit.ts +20 -1
  192. package/src/resources/extensions/gsd/auto/unit-phase.ts +41 -5
  193. package/src/resources/extensions/gsd/auto-artifact-paths.ts +14 -7
  194. package/src/resources/extensions/gsd/auto-dispatch.ts +1 -0
  195. package/src/resources/extensions/gsd/auto-prompts.ts +118 -19
  196. package/src/resources/extensions/gsd/auto-recovery.ts +10 -8
  197. package/src/resources/extensions/gsd/auto-runtime-state.ts +12 -7
  198. package/src/resources/extensions/gsd/auto-start.ts +31 -8
  199. package/src/resources/extensions/gsd/auto-tool-tracking.ts +56 -0
  200. package/src/resources/extensions/gsd/auto-worktree-cleanup.ts +4 -0
  201. package/src/resources/extensions/gsd/auto-worktree-sync.ts +10 -3
  202. package/src/resources/extensions/gsd/auto-worktree-teardown.ts +1 -1
  203. package/src/resources/extensions/gsd/auto.ts +20 -7
  204. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +1 -0
  205. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +41 -12
  206. package/src/resources/extensions/gsd/bootstrap/system-context.ts +11 -3
  207. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +7 -29
  208. package/src/resources/extensions/gsd/commands-verdict.ts +16 -9
  209. package/src/resources/extensions/gsd/compat/compat-marker.ts +99 -5
  210. package/src/resources/extensions/gsd/constants.ts +14 -13
  211. package/src/resources/extensions/gsd/context-masker.ts +98 -2
  212. package/src/resources/extensions/gsd/db/engine.ts +5 -2
  213. package/src/resources/extensions/gsd/docs/preferences-reference.md +22 -0
  214. package/src/resources/extensions/gsd/doctor-engine-checks.ts +30 -7
  215. package/src/resources/extensions/gsd/error-classifier.ts +13 -2
  216. package/src/resources/extensions/gsd/exec-sandbox.ts +1 -0
  217. package/src/resources/extensions/gsd/flat-phase-migration.ts +14 -0
  218. package/src/resources/extensions/gsd/git-service.ts +19 -6
  219. package/src/resources/extensions/gsd/gsd-db.ts +85 -33
  220. package/src/resources/extensions/gsd/guided-flow.ts +11 -4
  221. package/src/resources/extensions/gsd/markdown-renderer.ts +5 -23
  222. package/src/resources/extensions/gsd/md-importer.ts +5 -5
  223. package/src/resources/extensions/gsd/model-cost-table.ts +2 -0
  224. package/src/resources/extensions/gsd/model-router.ts +12 -0
  225. package/src/resources/extensions/gsd/paths.ts +73 -15
  226. package/src/resources/extensions/gsd/planning-subagent-policy.ts +58 -0
  227. package/src/resources/extensions/gsd/planning-subagent-registry.ts +31 -0
  228. package/src/resources/extensions/gsd/preferences-types.ts +16 -0
  229. package/src/resources/extensions/gsd/preferences-validation.ts +62 -0
  230. package/src/resources/extensions/gsd/preferences.ts +25 -0
  231. package/src/resources/extensions/gsd/prompts/validate-milestone.md +5 -5
  232. package/src/resources/extensions/gsd/provider-payload-policy.ts +18 -4
  233. package/src/resources/extensions/gsd/safety/destructive-guard.ts +1 -1
  234. package/src/resources/extensions/gsd/skill-activation.ts +17 -3
  235. package/src/resources/extensions/gsd/state-reconciliation/drift/external-markdown-edit.ts +132 -2
  236. package/src/resources/extensions/gsd/state-reconciliation/drift/external-planning-edit.ts +4 -1
  237. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +4 -2
  238. package/src/resources/extensions/gsd/stop-notice.ts +11 -0
  239. package/src/resources/extensions/gsd/templates/PREFERENCES.md +5 -0
  240. package/src/resources/extensions/gsd/tests/auto-artifact-paths.test.ts +7 -7
  241. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +264 -0
  242. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +39 -0
  243. package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +21 -1
  244. package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +74 -1
  245. package/src/resources/extensions/gsd/tests/before-provider-context-management.test.ts +55 -0
  246. package/src/resources/extensions/gsd/tests/commands-verdict.test.ts +10 -0
  247. package/src/resources/extensions/gsd/tests/compat-marker.test.ts +25 -0
  248. package/src/resources/extensions/gsd/tests/complete-task.test.ts +76 -1
  249. package/src/resources/extensions/gsd/tests/context-masker.test.ts +204 -8
  250. package/src/resources/extensions/gsd/tests/db-engine-cjs-compat.test.ts +12 -0
  251. package/src/resources/extensions/gsd/tests/db-tools-alias-suppression.test.ts +62 -0
  252. package/src/resources/extensions/gsd/tests/destructive-confirmation.test.ts +33 -0
  253. package/src/resources/extensions/gsd/tests/destructive-guard.test.ts +14 -0
  254. package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +83 -0
  255. package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +33 -1
  256. package/src/resources/extensions/gsd/tests/external-markdown-edit.test.ts +38 -1
  257. package/src/resources/extensions/gsd/tests/flat-phase-migration.test.ts +8 -9
  258. package/src/resources/extensions/gsd/tests/flat-phase-validation-path.test.ts +20 -1
  259. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +32 -0
  260. package/src/resources/extensions/gsd/tests/guided-discuss-milestone-prompt-rendering.test.ts +22 -0
  261. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +13 -0
  262. package/src/resources/extensions/gsd/tests/integration/paths.test.ts +22 -4
  263. package/src/resources/extensions/gsd/tests/integration-branch-meta-location.test.ts +62 -0
  264. package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +5 -5
  265. package/src/resources/extensions/gsd/tests/model-cost-table.test.ts +9 -1
  266. package/src/resources/extensions/gsd/tests/model-router.test.ts +1 -1
  267. package/src/resources/extensions/gsd/tests/parallel-skill-prompt-integration.test.ts +7 -5
  268. package/src/resources/extensions/gsd/tests/preferences.test.ts +84 -0
  269. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +4 -0
  270. package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +87 -0
  271. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +121 -1
  272. package/src/resources/extensions/gsd/tests/reactive-executor.test.ts +39 -0
  273. package/src/resources/extensions/gsd/tests/register-hooks-loop-guard-auto.test.ts +105 -0
  274. package/src/resources/extensions/gsd/tests/service-tier.test.ts +4 -0
  275. package/src/resources/extensions/gsd/tests/single-writer-v3-tool-surface.test.ts +33 -7
  276. package/src/resources/extensions/gsd/tests/skill-activation.test.ts +20 -16
  277. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +52 -0
  278. package/src/resources/extensions/gsd/tests/stop-notice.test.ts +21 -1
  279. package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +13 -7
  280. package/src/resources/extensions/gsd/tests/terminated-transient.test.ts +14 -0
  281. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +19 -0
  282. package/src/resources/extensions/gsd/tests/tool-naming.test.ts +8 -0
  283. package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +39 -0
  284. package/src/resources/extensions/gsd/tests/validate-milestone-prompt-verification-classes.test.ts +7 -0
  285. package/src/resources/extensions/gsd/tests/workflow-projections.test.ts +4 -4
  286. package/src/resources/extensions/gsd/tests/worktree-state-projection.test.ts +2 -2
  287. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +60 -0
  288. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +34 -0
  289. package/src/resources/extensions/gsd/tools/complete-task.ts +20 -5
  290. package/src/resources/extensions/gsd/tools/reopen-milestone.ts +24 -5
  291. package/src/resources/extensions/gsd/tools/reopen-slice.ts +25 -5
  292. package/src/resources/extensions/gsd/tools/reopen-task.ts +23 -9
  293. package/src/resources/extensions/gsd/unit-context-composer.ts +34 -8
  294. package/src/resources/extensions/gsd/workflow-projections.ts +2 -3
  295. package/src/resources/extensions/gsd/workspace.ts +2 -1
  296. package/src/resources/extensions/gsd/worktree-state-projection.ts +21 -24
  297. package/src/resources/extensions/shared/interview-ui.ts +47 -8
  298. package/src/resources/extensions/shared/tests/interview-ui-border.test.ts +29 -0
  299. /package/dist/web/standalone/.next/static/{BE5XoklToI6lZjRzpXih8 → EAhnhYMt5UVOiG9-iPDjc}/_buildManifest.js +0 -0
  300. /package/dist/web/standalone/.next/static/{BE5XoklToI6lZjRzpXih8 → EAhnhYMt5UVOiG9-iPDjc}/_ssgManifest.js +0 -0
@@ -635,6 +635,7 @@ function mergePreferences(base, override) {
635
635
  : undefined,
636
636
  post_unit_hooks: mergePostUnitHooks(base.post_unit_hooks, override.post_unit_hooks),
637
637
  pre_dispatch_hooks: mergePreDispatchHooks(base.pre_dispatch_hooks, override.pre_dispatch_hooks),
638
+ planning_subagents: mergePlanningSubagents(base.planning_subagents, override.planning_subagents),
638
639
  dynamic_routing: (base.dynamic_routing || override.dynamic_routing)
639
640
  ? { ...(base.dynamic_routing ?? {}), ...(override.dynamic_routing ?? {}) }
640
641
  : undefined,
@@ -752,6 +753,22 @@ function mergePreDispatchHooks(base, override) {
752
753
  }
753
754
  return merged.length > 0 ? merged : undefined;
754
755
  }
756
+ function mergePlanningSubagents(base, override) {
757
+ if (!base && !override)
758
+ return undefined;
759
+ const merged = {};
760
+ const unitTypes = new Set([
761
+ ...Object.keys(base ?? {}),
762
+ ...Object.keys(override ?? {}),
763
+ ]);
764
+ for (const unitType of unitTypes) {
765
+ const allowed = mergeStringLists(base?.[unitType]?.allowed, override?.[unitType]?.allowed);
766
+ if (allowed?.length) {
767
+ merged[unitType] = { allowed };
768
+ }
769
+ }
770
+ return Object.keys(merged).length > 0 ? merged : undefined;
771
+ }
755
772
  // ─── System Prompt Rendering ──────────────────────────────────────────────────
756
773
  export function renderPreferencesForSystemPrompt(preferences, resolutions, options) {
757
774
  const validated = validatePreferences(preferences);
@@ -24,18 +24,18 @@ Roadmap, slice summaries, assessments, requirements, decisions, and project cont
24
24
 
25
25
  ### Step 1 - Dispatch Parallel Reviewers
26
26
 
27
- The Inlined Context above already preloads the evidence reviewers need — the roadmap, per-slice SUMMARY/ASSESSMENT excerpts, requirements, and verification classes. **Embed the relevant preloaded evidence directly into each reviewer's task prompt** so reviewers work from it instead of re-reading the same artifacts from disk. Each reviewer should read a full file only when its excerpt is missing, truncated, or internally inconsistent — never as a routine first step. This avoids three reviewers independently re-surveying artifacts the orchestrator already holds.
27
+ The Inlined Context above already preloads the evidence reviewers need — the roadmap, per-slice SUMMARY/ASSESSMENT excerpts, requirements, and verification classes. **Embed the relevant preloaded evidence directly into each reviewer's task prompt** so reviewers work from it instead of re-reading the same artifacts from disk. Each reviewer should read a full file only when its excerpt is missing, truncated, or internally inconsistent — never as a routine first step. When a reviewer needs a full artifact, use only explicit file paths from the On-demand Validation Artifacts / On-demand Milestone Context blocks or discover files with `find .gsd -type f`; never pass a phase, slice, `tasks/`, or `slices/` directory to `read` or `readFileSync`. This avoids three reviewers independently re-surveying artifacts the orchestrator already holds.
28
28
 
29
29
  Call `subagent` with `tasks: [...]` containing ALL THREE reviewers simultaneously:
30
30
 
31
31
  **Reviewer A - Requirements Coverage**
32
- Prompt: "Review milestone {{milestoneId}} requirements coverage. Working directory: {{workingDirectory}}. Use the preloaded requirements and slice SUMMARY evidence embedded in this task — do not re-read them from disk. For each requirement, mark COVERED, PARTIAL, or MISSING against that evidence. Read a full SUMMARY under `.gsd/milestones/{{milestoneId}}/slices/` only if its preloaded excerpt is missing, truncated, or inconsistent. Output table: Requirement | Status | Evidence. End with one-line verdict: PASS if all covered, NEEDS-ATTENTION if partials exist, FAIL if any missing."
32
+ Prompt: "Review milestone {{milestoneId}} requirements coverage. Working directory: {{workingDirectory}}. Use the preloaded requirements and slice SUMMARY evidence embedded in this task — do not re-read them from disk. For each requirement, mark COVERED, PARTIAL, or MISSING against that evidence. Read a full SUMMARY only from an explicit file path in the On-demand Validation Artifacts list, or discover candidates with `find .gsd -type f -name '*-SUMMARY.md'`; never read a directory path. Output table: Requirement | Status | Evidence. End with one-line verdict: PASS if all covered, NEEDS-ATTENTION if partials exist, FAIL if any missing."
33
33
 
34
34
  **Reviewer B - Cross-Slice Integration**
35
- Prompt: "Review milestone {{milestoneId}} cross-slice integration. Working directory: {{workingDirectory}}. Use the preloaded roadmap and slice SUMMARY evidence embedded in this task — do not re-read them from disk. Find the boundary map (produces/consumes contracts) in the roadmap. For each boundary, confirm producer SUMMARY produced the artifact and consumer SUMMARY consumed it. Read `{{roadmapPath}}` or a full SUMMARY only if the preloaded evidence is missing, truncated, or inconsistent. Output table: Boundary | Producer Summary | Consumer Summary | Status. End with one-line verdict: PASS if all boundaries honored, NEEDS-ATTENTION if any gaps."
35
+ Prompt: "Review milestone {{milestoneId}} cross-slice integration. Working directory: {{workingDirectory}}. Use the preloaded roadmap and slice SUMMARY evidence embedded in this task — do not re-read them from disk. Find the boundary map (produces/consumes contracts) in the roadmap. For each boundary, confirm producer SUMMARY produced the artifact and consumer SUMMARY consumed it. Read `{{roadmapPath}}` or a full SUMMARY from the On-demand Validation Artifacts list only if the preloaded evidence is missing, truncated, or inconsistent; never read a directory path. Output table: Boundary | Producer Summary | Consumer Summary | Status. End with one-line verdict: PASS if all boundaries honored, NEEDS-ATTENTION if any gaps."
36
36
 
37
37
  **Reviewer C - Assessment & Acceptance Criteria**
38
- Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Use the preloaded milestone context, slice SUMMARY, and ASSESSMENT evidence embedded in this task — do not re-read them from disk. Read `.gsd/milestones/{{milestoneId}}/{{milestoneId}}-CONTEXT.md`, a full SUMMARY, or a full ASSESSMENT only if the preloaded excerpt is missing, truncated, or inconsistent. UAT files are specs, not evidence. Verify each criterion maps to passing evidence. Then review the inlined `Verification Classes (from planning)` table. For every planned row in that table, output a `Verification Classes` table with columns `Class | Planned Check | Evidence | Verdict`. Preserve every planned non-empty class row; do not summarize, rename, combine, or omit planned classes. The first cell of each row must be exactly `Contract`, `Integration`, `Operational`, or `UAT` when that class is present in planning. If a planned class lacks evidence, still include its canonical row and mark the verdict NEEDS-ATTENTION or FAIL. If a planned browser/UAT class has no ASSESSMENT with browser/runtime actions and assertions, return NEEDS-ATTENTION. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered by evidence, NEEDS-ATTENTION if gaps exist."
38
+ Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Use the preloaded milestone context, slice SUMMARY, and ASSESSMENT evidence embedded in this task — do not re-read them from disk. Read the milestone context from the On-demand Milestone Context file path, and read full SUMMARY or ASSESSMENT files only from explicit paths in the On-demand Validation Artifacts list, if the preloaded excerpt is missing, truncated, or inconsistent. UAT files are specs, not evidence. Verify each criterion maps to passing evidence. Then review the inlined `Verification Classes (from planning)` table. For every planned row in that table, output a `Verification Classes` table with columns `Class | Planned Check | Evidence | Verdict`. Preserve every planned non-empty class row; do not summarize, rename, combine, or omit planned classes. The first cell of each row must be exactly `Contract`, `Integration`, `Operational`, or `UAT` when that class is present in planning. If a planned class lacks evidence, still include its canonical row and mark the verdict NEEDS-ATTENTION or FAIL. If a planned browser/UAT class has no ASSESSMENT with browser/runtime actions and assertions, return NEEDS-ATTENTION. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered by evidence, NEEDS-ATTENTION if gaps exist."
39
39
 
40
40
  ### Step 2 - Synthesize Findings
41
41
 
@@ -85,6 +85,6 @@ If verdict is `needs-remediation`:
85
85
 
86
86
  **You MUST call `gsd_validate_milestone` before finishing. Do not manually write `{{validationPath}}`.**
87
87
 
88
- **File system safety:** When scanning milestone directories, use `ls` or `find` first. Never pass a directory path such as `tasks/` or `slices/` directly to `read`; it only accepts files.
88
+ **File system safety:** When scanning milestone directories, use `find .gsd -type f` first and read only files. In flat-phase projects, `.gsd/phases/<NN>-<slug>/` is a directory, not an artifact. Never pass a directory path such as a phase directory, `tasks/`, or `slices/` directly to `read`, `readFile`, or `readFileSync`.
89
89
 
90
90
  When done, say: "Milestone {{milestoneId}} validation complete — verdict: <verdict>." Say this exactly once — if you already said it in a prior message, do not repeat it.
@@ -2,12 +2,14 @@
2
2
  * Provider Payload Policy - ordered shaping of provider request payloads.
3
3
  *
4
4
  * The order is intentional:
5
- * 1. observation budgeting masks old tool results in auto-mode,
6
- * 2. display truncation caps tool-result text for every mode,
7
- * 3. the protected Source Context Block is appended after truncation,
8
- * 4. supported models receive the configured service tier.
5
+ * 1. superseded GSD context injections (memory/guided/forensics) are removed,
6
+ * keeping only the latest, for every mode,
7
+ * 2. observation budgeting masks old tool results in auto-mode,
8
+ * 3. display truncation caps tool-result text for every mode,
9
+ * 4. the protected Source Context Block is appended after truncation,
10
+ * 5. supported models receive the configured service tier.
9
11
  */
10
- import { createObservationMask, createResponsesInputObservationMask, truncateContextResultMessages, truncateResponsesInputResultItems, } from "./context-masker.js";
12
+ import { createObservationMask, createResponsesInputObservationMask, filterSupersededContextInjections, filterSupersededResponsesContextInjections, truncateContextResultMessages, truncateResponsesInputResultItems, } from "./context-masker.js";
11
13
  import { getSourceObservationStore, isAutoActive } from "./auto-runtime-state.js";
12
14
  import { loadEffectiveGSDPreferences } from "./preferences.js";
13
15
  import { getEffectiveServiceTier, supportsServiceTier } from "./service-tier.js";
@@ -42,9 +44,18 @@ export function applyProviderPayloadPolicy({ payload, modelId, deps: overrides,
42
44
  }
43
45
  function applyContextManagement(payload, deps) {
44
46
  const config = deps.loadContextManagementConfig();
47
+ applyContextInjectionFilter(payload);
45
48
  applyObservationBudget(payload, config, deps.isAutoActive());
46
49
  applyDisplayTruncation(payload, config);
47
50
  }
51
+ function applyContextInjectionFilter(payload) {
52
+ if (Array.isArray(payload.messages)) {
53
+ payload.messages = filterSupersededContextInjections(payload.messages);
54
+ }
55
+ if (Array.isArray(payload.input)) {
56
+ payload.input = filterSupersededResponsesContextInjections(payload.input);
57
+ }
58
+ }
48
59
  function applyObservationBudget(payload, config, autoActive) {
49
60
  if (!autoActive || config?.observation_masking === false)
50
61
  return;
@@ -6,7 +6,7 @@
6
6
  * Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
7
7
  */
8
8
  const DESTRUCTIVE_PATTERNS = [
9
- { pattern: /\brm\s+(-[^\s]*[rfRF][^\s]*\s+|.*\s+-[^\s]*[rfRF])/, label: "recursive delete" },
9
+ { pattern: /\brm\s+((?:-(?!-)[^\s]*[rR][^\s]*|--recursive)\s+|.*\s+(?:-(?!-)[^\s]*[rR][^\s]*|--recursive)(?:\s|$))/, label: "recursive delete" },
10
10
  { pattern: /\bgit\s+push\s+.*--force/, label: "force push" },
11
11
  { pattern: /\bgit\s+push\s+-f\b/, label: "force push" },
12
12
  { pattern: /\bgit\s+reset\s+--hard/, label: "hard reset" },
@@ -104,11 +104,24 @@ function resolvePreferredSkillNames(prefs, visibleSkills, contextTokens, base) {
104
104
  /** Skill names must be lowercase alphanumeric with hyphens — reject anything else
105
105
  * to prevent prompt injection via crafted directory names. */
106
106
  const SAFE_SKILL_NAME = /^[a-z0-9][a-z0-9-]*$/;
107
- function formatSkillActivationBlock(skillNames) {
107
+ function escapeXml(str) {
108
+ return str
109
+ .replace(/&/g, "&amp;")
110
+ .replace(/</g, "&lt;")
111
+ .replace(/>/g, "&gt;")
112
+ .replace(/"/g, "&quot;")
113
+ .replace(/'/g, "&apos;");
114
+ }
115
+ function formatSkillActivationBlock(skillNames, skillPaths) {
108
116
  const safe = skillNames.filter(name => SAFE_SKILL_NAME.test(name));
109
117
  if (safe.length === 0)
110
118
  return "";
111
- const reads = safe.map(name => `Read the installed '${name}' skill file from <available_skills>`).join(". ");
119
+ const reads = safe.map(name => {
120
+ const path = skillPaths.get(name);
121
+ if (path)
122
+ return `Read the skill file at \`${escapeXml(path)}\``;
123
+ return `Find '${name}' in <available_skills>, copy its <location> value, and pass that exact path to read`;
124
+ }).join(". ");
112
125
  return `<skill_activation>${reads}.</skill_activation>`;
113
126
  }
114
127
  /**
@@ -149,6 +162,7 @@ export function buildSkillActivationBlock(params) {
149
162
  const visibleSkills = loaded;
150
163
  const manifestScopedSkills = filterSkillsByManifest(visibleSkills, params.unitType);
151
164
  const installedNames = new Set(visibleSkills.map(skill => normalizeSkillReference(skill.name)));
165
+ const installedSkillPaths = new Map(visibleSkills.map(skill => [normalizeSkillReference(skill.name), skill.filePath]));
152
166
  warnIfManifestHasMissingSkills(params.unitType, installedNames);
153
167
  const avoided = new Set(resolvePreferenceSkillNames(prefs?.avoid_skills ?? [], params.base));
154
168
  const matched = new Set();
@@ -196,7 +210,7 @@ export function buildSkillActivationBlock(params) {
196
210
  const ordered = [...matched]
197
211
  .filter(name => installedNames.has(name) && !avoided.has(name))
198
212
  .sort();
199
- const activationBlock = formatSkillActivationBlock(ordered);
213
+ const activationBlock = formatSkillActivationBlock(ordered, installedSkillPaths);
200
214
  // Omit recommendations when the system catalog is manifest-scoped for this
201
215
  // unit — skill names are already listed in <available_skills>.
202
216
  let recommendationsBlock = "";
@@ -8,9 +8,81 @@
8
8
  // renderAllFromDb pass re-projects; the write-time invalidation hook then
9
9
  // refreshes the marker entry, closing the loop.
10
10
  import { existsSync, readFileSync } from "node:fs";
11
- import { join } from "node:path";
11
+ import { basename, join } from "node:path";
12
12
  import { computeProjectionSha, readCompatMarker, writeCompatMarker, } from "../../compat/compat-marker.js";
13
+ import { _getAdapter } from "../../gsd-db.js";
13
14
  import { logWarning } from "../../workflow-logger.js";
15
+ function deepestProjectionScope(entities) {
16
+ let best = null;
17
+ for (const entity of entities) {
18
+ const parts = entity.split("/").filter(Boolean);
19
+ if (parts.length === 0)
20
+ continue;
21
+ if (!best || parts.length > best.length)
22
+ best = parts;
23
+ }
24
+ if (!best)
25
+ return null;
26
+ return {
27
+ milestoneId: best[0],
28
+ sliceId: best[1] ?? null,
29
+ taskId: best[2] ?? null,
30
+ };
31
+ }
32
+ function artifactTypeFromProjectionPath(projectionPath) {
33
+ const name = basename(projectionPath);
34
+ const match = name.match(/^(?:[A-Za-z]\d+|\d+(?:-\d+)?)-(.+)\.md$/);
35
+ return match?.[1]?.toUpperCase() ?? null;
36
+ }
37
+ function dbProjectionMatches(projectionPath, entry, actualSha) {
38
+ const adapter = _getAdapter();
39
+ if (!adapter)
40
+ return false;
41
+ try {
42
+ const rows = adapter
43
+ .prepare("SELECT full_content FROM artifacts WHERE path = :path")
44
+ .all({ ":path": projectionPath });
45
+ const scope = deepestProjectionScope(entry.entities);
46
+ const artifactType = artifactTypeFromProjectionPath(projectionPath);
47
+ if (scope?.taskId) {
48
+ rows.push(...adapter
49
+ .prepare(`SELECT full_content
50
+ FROM artifacts
51
+ WHERE milestone_id = :mid AND slice_id = :sid AND task_id = :tid
52
+ AND (:type IS NULL OR artifact_type = :type)`)
53
+ .all({
54
+ ":mid": scope.milestoneId,
55
+ ":sid": scope.sliceId,
56
+ ":tid": scope.taskId,
57
+ ":type": artifactType,
58
+ }));
59
+ }
60
+ else if (scope?.sliceId) {
61
+ rows.push(...adapter
62
+ .prepare(`SELECT full_content
63
+ FROM artifacts
64
+ WHERE milestone_id = :mid AND slice_id = :sid AND task_id IS NULL
65
+ AND (:type IS NULL OR artifact_type = :type)`)
66
+ .all({
67
+ ":mid": scope.milestoneId,
68
+ ":sid": scope.sliceId,
69
+ ":type": artifactType,
70
+ }));
71
+ }
72
+ else if (scope) {
73
+ rows.push(...adapter
74
+ .prepare(`SELECT full_content
75
+ FROM artifacts
76
+ WHERE milestone_id = :mid AND slice_id IS NULL AND task_id IS NULL
77
+ AND (:type IS NULL OR artifact_type = :type)`)
78
+ .all({ ":mid": scope.milestoneId, ":type": artifactType }));
79
+ }
80
+ return rows.some((row) => computeProjectionSha(row.full_content) === actualSha);
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ }
14
86
  /**
15
87
  * Detect sha drift between the marker baseline and current file contents.
16
88
  *
@@ -21,11 +93,15 @@ import { logWarning } from "../../workflow-logger.js";
21
93
  * - Sha mismatch → one record per drifted file, scoped to its recorded entities.
22
94
  */
23
95
  function detectExternalMarkdownEdit(_state, ctx) {
24
- const marker = readCompatMarker(ctx.basePath);
96
+ const marker = readCompatMarker(ctx.basePath, {
97
+ healInvalidKeys: !ctx.dryRun,
98
+ quarantineInvalid: !ctx.dryRun,
99
+ });
25
100
  const entries = Object.entries(marker.projections);
26
101
  if (entries.length === 0)
27
102
  return [];
28
103
  const records = [];
104
+ let markerChanged = false;
29
105
  for (const [projectionPath, entry] of entries) {
30
106
  const abs = join(ctx.basePath, ".gsd", projectionPath);
31
107
  if (!existsSync(abs))
@@ -33,6 +109,21 @@ function detectExternalMarkdownEdit(_state, ctx) {
33
109
  const actual = computeProjectionSha(readFileSync(abs, "utf-8"));
34
110
  if (actual === entry.sha)
35
111
  continue;
112
+ if (dbProjectionMatches(projectionPath, entry, actual)) {
113
+ if (!ctx.dryRun) {
114
+ marker.projections[projectionPath] = {
115
+ sha: actual,
116
+ entities: entry.entities,
117
+ };
118
+ markerChanged = true;
119
+ logWarning("reconcile", `external-markdown-edit: refreshed stale compat marker for ${projectionPath} (expectedSha=${entry.sha}, actualSha=${actual})`);
120
+ }
121
+ else {
122
+ logWarning("reconcile", `external-markdown-edit: stale compat marker for ${projectionPath} (expectedSha=${entry.sha}, actualSha=${actual})`);
123
+ }
124
+ continue;
125
+ }
126
+ logWarning("reconcile", `external-markdown-edit drift for ${projectionPath} (expectedSha=${entry.sha}, actualSha=${actual})`);
36
127
  records.push({
37
128
  kind: "external-markdown-edit",
38
129
  projectionPath,
@@ -41,6 +132,11 @@ function detectExternalMarkdownEdit(_state, ctx) {
41
132
  entities: entry.entities,
42
133
  });
43
134
  }
135
+ if (markerChanged) {
136
+ marker.lastWriter = "gsd-pi";
137
+ marker.lastProjectedAt = new Date().toISOString();
138
+ writeCompatMarker(ctx.basePath, marker);
139
+ }
44
140
  return records;
45
141
  }
46
142
  /**
@@ -55,7 +55,10 @@ function detectUnseededPlanningFiles(ctx, projections, passthrough) {
55
55
  return records;
56
56
  }
57
57
  async function detectExternalPlanningEdit(_state, ctx) {
58
- const marker = readCompatMarker(ctx.basePath);
58
+ const marker = readCompatMarker(ctx.basePath, {
59
+ healInvalidKeys: !ctx.dryRun,
60
+ quarantineInvalid: !ctx.dryRun,
61
+ });
59
62
  if (!marker.planning?.active) {
60
63
  // Not yet activated. Activation (layout parse + DB import) is owned by
61
64
  // capturePlanningCompatIfNeeded, called from reconcileBeforeDispatch when
@@ -9,7 +9,7 @@ import { renderRoadmapFromDb } from "../../markdown-renderer.js";
9
9
  import { findMilestoneIds } from "../../milestone-ids.js";
10
10
  import { parseRoadmap } from "../../parsers-legacy.js";
11
11
  import { resolveMilestoneFile } from "../../paths.js";
12
- import { isClosedStatus } from "../../status-guards.js";
12
+ import { isClosedStatus, isSkippedForDispatch } from "../../status-guards.js";
13
13
  function arraysEqual(a, b) {
14
14
  if (a.length !== b.length)
15
15
  return false;
@@ -76,7 +76,10 @@ export function detectRoadmapDivergenceDrift(_state, ctx) {
76
76
  for (const milestoneId of findMilestoneIds(ctx.basePath)) {
77
77
  // Skip milestones that don't yet have a DB row — that's the
78
78
  // unregistered-milestone drift handler's responsibility.
79
- if (!getMilestone(milestoneId))
79
+ const milestone = getMilestone(milestoneId);
80
+ if (!milestone)
81
+ continue;
82
+ if (isSkippedForDispatch(milestone.status))
80
83
  continue;
81
84
  if (milestoneHasDivergence(ctx.basePath, milestoneId)) {
82
85
  drifts.push({ kind: "roadmap-divergence", milestoneId });
@@ -22,6 +22,12 @@ export function formatStopNoticePrefix(reason) {
22
22
  const prefix = stopNoticeKind(reason) === "blocked" ? "Auto-mode blocked" : "Auto-mode stopped";
23
23
  return displayReason ? `${prefix} — ${displayReason}` : prefix;
24
24
  }
25
+ export function formatVerdictRecordedNotice(message) {
26
+ return `Verdict recorded: ${message}`;
27
+ }
28
+ export function formatVerdictRejectedNotice(message) {
29
+ return `Verdict rejected: ${message}`;
30
+ }
25
31
  // ─── Classification (headless host side) ────────────────────────────────
26
32
  // The canonical lowercase prefixes the headless event loop recognizes in
27
33
  // notify messages. Emitters above and ad-hoc emitters elsewhere must start
@@ -33,6 +39,8 @@ export const TERMINAL_NOTICE_PREFIXES = [
33
39
  "auto-mode complete",
34
40
  "no active milestone",
35
41
  "auto-mode idle",
42
+ "verdict recorded",
43
+ "verdict rejected",
36
44
  ];
37
45
  /** Manual-resolution notices emitted before auto-mode can formally pause/stop. */
38
46
  export function isManualResolutionNotice(message) {
@@ -65,6 +73,7 @@ export function isInteractiveMenuUnavailableNotice(message) {
65
73
  }
66
74
  export function isBlockedNoticeMessage(message) {
67
75
  return (message.includes("blocked:") ||
76
+ message.startsWith("verdict rejected") ||
68
77
  (isPauseNotice(message) && !isNonBlockingPauseNotice(message)) ||
69
78
  isManualResolutionNotice(message) ||
70
79
  isInteractiveMenuUnavailableNotice(message));
@@ -92,6 +92,11 @@ remote_questions:
92
92
  uat_dispatch:
93
93
  post_unit_hooks: []
94
94
  pre_dispatch_hooks: []
95
+ # planning_subagents:
96
+ # plan-milestone:
97
+ # allowed: [scout, planner, security]
98
+ # plan-slice:
99
+ # allowed: [scout, planner, reviewer, security]
95
100
  # language:
96
101
  # experimental:
97
102
  # rtk: false
@@ -15,7 +15,7 @@ import { isClosedStatus } from "../status-guards.js";
15
15
  import { transaction, insertMilestone, insertSlice, insertTask, insertVerificationEvidence, getMilestone, getSlice, getTask, updateTaskStatus, deleteVerificationEvidence, saveGateResult, getPendingGatesForTurn, getUnresolvedBlockingReworkFindingsForTask, getBlockingReworkFindingsForTask, applyReworkResolutions, } from "../gsd-db.js";
16
16
  import { getWorkflowDatabasePath, ensureWorkflowDbAtPath } from "../db-workspace.js";
17
17
  import { getGatesForTurn } from "../gate-registry.js";
18
- import { gsdProjectionRoot, clearPathCache, resolveMilestonePath, resolveSlicePath } from "../paths.js";
18
+ import { buildFlatTaskFileName, buildTaskFileName, gsdProjectionRoot, clearPathCache, legacyMilestonesDir, resolveMilestonePath, resolveSlicePath, } from "../paths.js";
19
19
  import { resolveCanonicalMilestoneRoot } from "../worktree-manager.js";
20
20
  import { checkOwnership, taskUnitKey } from "../unit-ownership.js";
21
21
  import { saveFile, clearParseCache } from "../files.js";
@@ -34,13 +34,20 @@ function taskSummaryPath(basePath, milestoneId, sliceId, taskId) {
34
34
  // a legacy layout and breaks all subsequent path resolution for the session.
35
35
  const slicePath = resolveSlicePath(basePath, milestoneId, sliceId);
36
36
  const phaseDir = resolveMilestonePath(basePath, milestoneId);
37
- if (slicePath && phaseDir && slicePath !== phaseDir) {
38
- // Legacy layout: the slice has its own slices/SID/ subdir → tasks/ subdir
39
- return join(slicePath, "tasks", `${taskId}-SUMMARY.md`);
37
+ const legacyBase = legacyMilestonesDir(basePath);
38
+ const isLegacy = phaseDir
39
+ ? phaseDir.startsWith(legacyBase + "/") || phaseDir.startsWith(legacyBase + "\\")
40
+ : false;
41
+ if (isLegacy && phaseDir) {
42
+ // Legacy layout: the slice has its own slices/SID/ subdir → tasks/ subdir.
43
+ const legacySlicePath = slicePath && slicePath !== phaseDir
44
+ ? slicePath
45
+ : join(phaseDir, "slices", sliceId);
46
+ return join(legacySlicePath, "tasks", buildTaskFileName(taskId, "SUMMARY"));
40
47
  }
41
48
  if (phaseDir) {
42
49
  // Flat-phase: task summaries go in the phase dir (no tasks/ subdir)
43
- return join(phaseDir, `${taskId}-SUMMARY.md`);
50
+ return join(phaseDir, buildFlatTaskFileName(sliceId, taskId, "SUMMARY"));
44
51
  }
45
52
  // Fallback: legacy hardcoded path (milestone/slice dir not on disk yet)
46
53
  return join(gsdProjectionRoot(basePath), "milestones", milestoneId, "slices", sliceId, "tasks", `${taskId}-SUMMARY.md`);
@@ -16,7 +16,7 @@ import { logWarning } from "../workflow-logger.js";
16
16
  import { debugLog } from "../debug-logger.js";
17
17
  import { existsSync, unlinkSync } from "node:fs";
18
18
  import { join } from "node:path";
19
- import { resolveMilestonePath, resolveSlicePath, resolveTasksDir, clearPathCache } from "../paths.js";
19
+ import { buildFlatTaskFileName, buildTaskFileName, legacyMilestonesDir, resolveMilestonePath, resolveSlicePath, resolveTasksDir, clearPathCache, } from "../paths.js";
20
20
  export async function handleReopenMilestone(params, basePath) {
21
21
  // ── Validate required fields ────────────────────────────────────────────
22
22
  if (!params.milestoneId || typeof params.milestoneId !== "string" || params.milestoneId.trim() === "") {
@@ -41,6 +41,8 @@ export async function handleReopenMilestone(params, basePath) {
41
41
  // auto-corrects entities back to "complete", making reopen a no-op (#3161).
42
42
  try {
43
43
  const milestoneDir = resolveMilestonePath(basePath, params.milestoneId);
44
+ const legacyBase = legacyMilestonesDir(basePath);
45
+ const isLegacy = !!milestoneDir && (milestoneDir.startsWith(legacyBase + "/") || milestoneDir.startsWith(legacyBase + "\\"));
44
46
  if (milestoneDir) {
45
47
  const milestoneSummary = join(milestoneDir, `${params.milestoneId}-SUMMARY.md`);
46
48
  if (existsSync(milestoneSummary))
@@ -58,10 +60,17 @@ export async function handleReopenMilestone(params, basePath) {
58
60
  unlinkSync(sliceUat);
59
61
  }
60
62
  const tasksDir = resolveTasksDir(basePath, params.milestoneId, slice.id);
61
- if (tasksDir) {
62
- const tasks = getSliceTasks(params.milestoneId, slice.id);
63
- for (const task of tasks) {
64
- const taskSummary = join(tasksDir, `${task.id}-SUMMARY.md`);
63
+ const tasks = getSliceTasks(params.milestoneId, slice.id);
64
+ for (const task of tasks) {
65
+ const taskSummaries = isLegacy
66
+ ? (tasksDir ? [join(tasksDir, buildTaskFileName(task.id, "SUMMARY"))] : [])
67
+ : milestoneDir
68
+ ? [
69
+ join(milestoneDir, buildFlatTaskFileName(slice.id, task.id, "SUMMARY")),
70
+ join(milestoneDir, buildTaskFileName(task.id, "SUMMARY")),
71
+ ]
72
+ : [];
73
+ for (const taskSummary of taskSummaries) {
65
74
  if (existsSync(taskSummary))
66
75
  unlinkSync(taskSummary);
67
76
  }
@@ -22,7 +22,7 @@ import { appendEvent } from "../workflow-events.js";
22
22
  import { logWarning } from "../workflow-logger.js";
23
23
  import { existsSync, unlinkSync } from "node:fs";
24
24
  import { join } from "node:path";
25
- import { resolveTasksDir, resolveSlicePath, clearPathCache } from "../paths.js";
25
+ import { buildFlatTaskFileName, buildTaskFileName, legacyMilestonesDir, resolveMilestonePath, resolveTasksDir, resolveSlicePath, clearPathCache, } from "../paths.js";
26
26
  export async function handleReopenSlice(params, basePath) {
27
27
  // ── Validate required fields ────────────────────────────────────────────
28
28
  if (!params.sliceId || typeof params.sliceId !== "string" || params.sliceId.trim() === "") {
@@ -52,11 +52,21 @@ export async function handleReopenSlice(params, basePath) {
52
52
  // Without this, the DB-filesystem reconciler sees SUMMARY.md files and
53
53
  // auto-corrects tasks back to "complete", making reopen a no-op (#3161).
54
54
  try {
55
+ const milestoneDir = resolveMilestonePath(basePath, params.milestoneId);
56
+ const legacyBase = legacyMilestonesDir(basePath);
57
+ const isLegacy = !!milestoneDir && (milestoneDir.startsWith(legacyBase + "/") || milestoneDir.startsWith(legacyBase + "\\"));
55
58
  const tasksDir = resolveTasksDir(basePath, params.milestoneId, params.sliceId);
56
- if (tasksDir) {
57
- const tasks = getSliceTasks(params.milestoneId, params.sliceId);
58
- for (const task of tasks) {
59
- const summaryPath = join(tasksDir, `${task.id}-SUMMARY.md`);
59
+ const tasks = getSliceTasks(params.milestoneId, params.sliceId);
60
+ for (const task of tasks) {
61
+ const summaryPaths = isLegacy
62
+ ? (tasksDir ? [join(tasksDir, buildTaskFileName(task.id, "SUMMARY"))] : [])
63
+ : milestoneDir
64
+ ? [
65
+ join(milestoneDir, buildFlatTaskFileName(params.sliceId, task.id, "SUMMARY")),
66
+ join(milestoneDir, buildTaskFileName(task.id, "SUMMARY")),
67
+ ]
68
+ : [];
69
+ for (const summaryPath of summaryPaths) {
60
70
  if (existsSync(summaryPath))
61
71
  unlinkSync(summaryPath);
62
72
  }
@@ -17,8 +17,8 @@ import { appendEvent } from "../workflow-events.js";
17
17
  import { logWarning } from "../workflow-logger.js";
18
18
  import { writeReopenReason } from "../reopen-reason.js";
19
19
  import { existsSync, unlinkSync } from "node:fs";
20
- import { join, basename, dirname } from "node:path";
21
- import { resolveTasksDir, resolveSlicePath, clearPathCache } from "../paths.js";
20
+ import { join } from "node:path";
21
+ import { buildFlatTaskFileName, buildTaskFileName, legacyMilestonesDir, resolveMilestonePath, resolveTasksDir, resolveSlicePath, clearPathCache, } from "../paths.js";
22
22
  export async function handleReopenTask(params, basePath) {
23
23
  // ── Validate required fields ────────────────────────────────────────────
24
24
  if (!params.taskId || typeof params.taskId !== "string" || params.taskId.trim() === "") {
@@ -76,14 +76,20 @@ export async function handleReopenTask(params, basePath) {
76
76
  // summary cleanup into tasks/ (#1208).
77
77
  try {
78
78
  const slicePath = resolveSlicePath(basePath, params.milestoneId, params.sliceId);
79
- if (slicePath) {
80
- const isLegacySlice = basename(dirname(slicePath)) === "slices";
81
- const summaryDir = isLegacySlice
82
- ? (resolveTasksDir(basePath, params.milestoneId, params.sliceId) ?? slicePath)
83
- : slicePath;
84
- const summaryPath = join(summaryDir, `${params.taskId}-SUMMARY.md`);
85
- if (existsSync(summaryPath))
86
- unlinkSync(summaryPath);
79
+ const milestonePath = resolveMilestonePath(basePath, params.milestoneId);
80
+ if (milestonePath) {
81
+ const legacyBase = legacyMilestonesDir(basePath);
82
+ const isLegacy = milestonePath.startsWith(legacyBase + "/") || milestonePath.startsWith(legacyBase + "\\");
83
+ const summaryPaths = isLegacy
84
+ ? [join(resolveTasksDir(basePath, params.milestoneId, params.sliceId) ?? slicePath ?? join(milestonePath, "slices", params.sliceId, "tasks"), buildTaskFileName(params.taskId, "SUMMARY"))]
85
+ : [
86
+ join(milestonePath, buildFlatTaskFileName(params.sliceId, params.taskId, "SUMMARY")),
87
+ join(milestonePath, buildTaskFileName(params.taskId, "SUMMARY")),
88
+ ];
89
+ for (const summaryPath of summaryPaths) {
90
+ if (existsSync(summaryPath))
91
+ unlinkSync(summaryPath);
92
+ }
87
93
  }
88
94
  }
89
95
  catch (cleanupErr) {
@@ -36,6 +36,7 @@
36
36
  // owned by the unit, not in the composer. Reviews must enforce this — it
37
37
  // is the difference between an orchestrator and a runaway DSL.
38
38
  import { resolveManifest, } from "./unit-context-manifest.js";
39
+ import { resolveEffectivePlanningToolsPolicy } from "./planning-subagent-policy.js";
39
40
  import { getUnitToolSurfaceContract } from "./unit-tool-contracts.js";
40
41
  /**
41
42
  * Produce the inlined-context portion of a unit's system prompt by
@@ -148,11 +149,32 @@ const TOOL_SURFACE_GUIDANCE_BY_UNIT = {
148
149
  "validate-milestone": "Dispatch reviewer subagents in parallel, then persist the verdict via `gsd_validate_milestone`. Do not query `.gsd/gsd.db` directly — use `gsd_milestone_status` and inlined context.",
149
150
  "complete-milestone": "Persist completion only through `gsd_complete_milestone` after verification passes. Do not query `.gsd/gsd.db` directly. Do not write `.gsd/PROJECT.md` or `.gsd/REQUIREMENTS.md` by hand — use `gsd_summary_save` and `gsd_requirement_update`.",
150
151
  "replan-slice": "Persist replans through `gsd_replan_slice` only. Do not edit `PLAN.md` or task plans directly.",
151
- "plan-slice": "Persist planning through `gsd_plan_slice` only. Dispatch subagents only to **scout** or **planner** for reconnaissance — not implementation agents. Do not edit user source files outside `.gsd/**`.",
152
- "refine-slice": "Persist refinements through `gsd_plan_slice` only. Dispatch subagents only to **scout** or **planner**. Do not edit user source files outside `.gsd/**`.",
153
- "plan-milestone": "Persist milestone planning through `gsd_plan_milestone` / `gsd_plan_slice`. Do not edit user source files outside `.gsd/**`.",
154
152
  "research-slice": "Dispatch subagents only to **scout** or **planner** for reconnaissance. Do not edit user source files outside `.gsd/**`.",
155
153
  };
154
+ function formatAllowedAgents(agents) {
155
+ return agents.map((agent) => `**${agent}**`).join(", ");
156
+ }
157
+ function guidanceForUnitToolsPolicy(unitType, policy) {
158
+ if (unitType === "plan-slice") {
159
+ const dispatch = policy.mode === "planning-dispatch"
160
+ ? ` Dispatch subagents only to ${formatAllowedAgents(policy.allowedSubagents)} for reconnaissance — not implementation agents.`
161
+ : " Do not dispatch subagents.";
162
+ return `Persist planning through \`gsd_plan_slice\` only.${dispatch} Do not edit user source files outside \`.gsd/**\`.`;
163
+ }
164
+ if (unitType === "refine-slice") {
165
+ const dispatch = policy.mode === "planning-dispatch"
166
+ ? ` Dispatch subagents only to ${formatAllowedAgents(policy.allowedSubagents)}.`
167
+ : " Do not dispatch subagents.";
168
+ return `Persist refinements through \`gsd_plan_slice\` only.${dispatch} Do not edit user source files outside \`.gsd/**\`.`;
169
+ }
170
+ if (unitType === "plan-milestone") {
171
+ const dispatch = policy.mode === "planning-dispatch"
172
+ ? ` Dispatch subagents only to ${formatAllowedAgents(policy.allowedSubagents)}.`
173
+ : "";
174
+ return `Persist milestone planning through \`gsd_plan_milestone\` / \`gsd_plan_slice\`.${dispatch} Do not edit user source files outside \`.gsd/**\`.`;
175
+ }
176
+ return undefined;
177
+ }
156
178
  function guidanceForToolsPolicy(policy) {
157
179
  switch (policy.mode) {
158
180
  case "planning":
@@ -191,8 +213,9 @@ export function composeToolSurfaceInstructions(unitType, opts) {
191
213
  const manifest = resolveManifest(unitType);
192
214
  if (!manifest)
193
215
  return "";
194
- const unitGuidance = TOOL_SURFACE_GUIDANCE_BY_UNIT[unitType];
195
- const policyGuidance = unitGuidance ? null : guidanceForToolsPolicy(manifest.tools);
216
+ const effectiveTools = resolveEffectivePlanningToolsPolicy(unitType, manifest.tools, opts.basePath) ?? manifest.tools;
217
+ const unitGuidance = guidanceForUnitToolsPolicy(unitType, effectiveTools) ?? TOOL_SURFACE_GUIDANCE_BY_UNIT[unitType];
218
+ const policyGuidance = unitGuidance ? null : guidanceForToolsPolicy(effectiveTools);
196
219
  const forbiddenLine = formatForbiddenWorkflowToolsLine(unitType, unitGuidance);
197
220
  const parts = [unitGuidance, policyGuidance, forbiddenLine].filter((part) => typeof part === "string" && part.length > 0);
198
221
  if (parts.length === 0)
@@ -13,7 +13,7 @@ import { isClosedStatus } from "./status-guards.js";
13
13
  import { deriveState } from "./state.js";
14
14
  import { renderPlanFromDb, renderRoadmapFromDb } from "./markdown-renderer.js";
15
15
  import { readManifest } from "./workflow-manifest.js";
16
- import { gsdRoot, resolveMilestoneFile, resolveSliceFile, resolveTaskFile, relTaskFile } from "./paths.js";
16
+ import { gsdRoot, resolveMilestoneFile, resolveSliceFile, resolveTaskFile, targetTaskFile } from "./paths.js";
17
17
  // ─── Helpers ─────────────────────────────────────────────────────────────
18
18
  /**
19
19
  * Strip a leading ID prefix (e.g. "M001: " or "S04: ") from a title
@@ -276,8 +276,7 @@ export function renderSummaryProjection(basePath, milestoneId, sliceId, taskId)
276
276
  return;
277
277
  const evidenceRows = getVerificationEvidence(milestoneId, sliceId, taskId);
278
278
  const content = renderSummaryContent(taskRow, sliceId, milestoneId, evidenceRows);
279
- const summaryPath = resolveTaskFile(basePath, milestoneId, sliceId, taskId, "SUMMARY")
280
- ?? join(basePath, relTaskFile(basePath, milestoneId, sliceId, taskId, "SUMMARY", getMilestone(milestoneId)?.title));
279
+ const summaryPath = targetTaskFile(basePath, milestoneId, sliceId, taskId, "SUMMARY", getMilestone(milestoneId)?.title);
281
280
  mkdirSync(dirname(summaryPath), { recursive: true });
282
281
  atomicWriteSync(summaryPath, content);
283
282
  }
@@ -2,6 +2,7 @@
2
2
  import { dirname, join, resolve } from "node:path";
3
3
  import { resolveGsdPathContract, resolveMilestoneFile, resolveMilestonePath, targetMilestoneFile, normalizeRealPath, } from "./paths.js";
4
4
  import { isGsdWorktreePath, resolveWorktreeProjectRoot } from "./worktree-root.js";
5
+ import { milestoneMetaPath } from "./git-service.js";
5
6
  function tryRealpath(p) {
6
7
  return normalizeRealPath(p);
7
8
  }
@@ -63,7 +64,7 @@ export function scopeMilestone(workspace, milestoneId) {
63
64
  stateFile: () => join(gsd, "STATE.md"),
64
65
  dbPath: () => contract.projectDb,
65
66
  milestoneDir: () => scopeMilestoneDir(basePath, milestoneId),
66
- metaJson: () => join(gsd, `${milestoneId}-META.json`),
67
+ metaJson: () => milestoneMetaPath(basePath, milestoneId),
67
68
  });
68
69
  return scope;
69
70
  }