gsd-pi 2.80.0-dev.c2213c771 → 2.80.0-dev.c5c38454b

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 (270) hide show
  1. package/dist/resources/.managed-resources-content-hash +1 -1
  2. package/dist/resources/extensions/github-sync/templates.js +39 -8
  3. package/dist/resources/extensions/gsd/auto/loop.js +16 -9
  4. package/dist/resources/extensions/gsd/auto/run-unit.js +19 -15
  5. package/dist/resources/extensions/gsd/auto-dashboard.js +51 -15
  6. package/dist/resources/extensions/gsd/auto-dispatch.js +10 -0
  7. package/dist/resources/extensions/gsd/auto-recovery.js +154 -8
  8. package/dist/resources/extensions/gsd/auto-start.js +2 -3
  9. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +15 -1
  10. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +11 -1
  11. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +129 -1
  12. package/dist/resources/extensions/gsd/commands-extract-learnings.js +17 -12
  13. package/dist/resources/extensions/gsd/custom-workflow-engine.js +22 -2
  14. package/dist/resources/extensions/gsd/db-base-schema.js +14 -0
  15. package/dist/resources/extensions/gsd/db-migration-steps.js +16 -0
  16. package/dist/resources/extensions/gsd/graph.js +9 -3
  17. package/dist/resources/extensions/gsd/gsd-db.js +102 -2
  18. package/dist/resources/extensions/gsd/guided-flow.js +2 -2
  19. package/dist/resources/extensions/gsd/pr-evidence.js +57 -16
  20. package/dist/resources/extensions/gsd/working-output-messages.js +64 -0
  21. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  22. package/dist/web/standalone/.next/BUILD_ID +1 -1
  23. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  24. package/dist/web/standalone/.next/build-manifest.json +3 -3
  25. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  26. package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
  27. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  28. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  33. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  36. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  40. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  41. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  42. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  43. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  44. package/dist/web/standalone/.next/server/app/index.html +1 -1
  45. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  46. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  47. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  48. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  49. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  50. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  51. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  52. package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
  53. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  54. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  55. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  56. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  57. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  58. package/dist/web/standalone/.next/static/chunks/{8336.6f6f30e410419aff.js → 8336.631939fb583761fa.js} +1 -1
  59. package/dist/web/standalone/.next/static/chunks/{webpack-d82dbee6356c1733.js → webpack-0481f1221120a7c6.js} +1 -1
  60. package/package.json +7 -3
  61. package/packages/pi-ai/dist/models/fake-model.d.ts +12 -0
  62. package/packages/pi-ai/dist/models/fake-model.d.ts.map +1 -0
  63. package/packages/pi-ai/dist/models/fake-model.js +27 -0
  64. package/packages/pi-ai/dist/models/fake-model.js.map +1 -0
  65. package/packages/pi-ai/dist/models/index.d.ts.map +1 -1
  66. package/packages/pi-ai/dist/models/index.js +8 -0
  67. package/packages/pi-ai/dist/models/index.js.map +1 -1
  68. package/packages/pi-ai/dist/providers/fake.d.ts +42 -0
  69. package/packages/pi-ai/dist/providers/fake.d.ts.map +1 -0
  70. package/packages/pi-ai/dist/providers/fake.js +319 -0
  71. package/packages/pi-ai/dist/providers/fake.js.map +1 -0
  72. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  73. package/packages/pi-ai/dist/providers/register-builtins.js +24 -0
  74. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
  75. package/packages/pi-ai/src/models/fake-model.ts +30 -0
  76. package/packages/pi-ai/src/models/index.ts +9 -0
  77. package/packages/pi-ai/src/providers/fake.ts +376 -0
  78. package/packages/pi-ai/src/providers/register-builtins.ts +23 -0
  79. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  80. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +44 -0
  81. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  82. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +2 -0
  83. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  84. package/packages/pi-coding-agent/dist/core/extensions/runner.js +14 -1
  85. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  86. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +97 -0
  87. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  88. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  89. package/packages/pi-coding-agent/dist/core/model-registry.js +5 -0
  90. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  91. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +4 -0
  92. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  93. package/packages/pi-coding-agent/dist/core/settings-manager.js +8 -0
  94. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  95. package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
  96. package/packages/pi-coding-agent/dist/core/slash-commands.js +1 -0
  97. package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
  98. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +6 -4
  99. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
  100. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +54 -15
  101. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  102. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts +26 -0
  103. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -0
  104. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +112 -0
  105. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -0
  106. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts +2 -0
  107. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts.map +1 -0
  108. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +51 -0
  109. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +1 -0
  110. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  111. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
  112. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
  113. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +10 -9
  114. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
  115. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +3 -0
  116. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  117. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +11 -0
  118. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
  119. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
  120. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
  121. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +16 -0
  122. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  123. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +106 -17
  124. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  125. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  126. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +58 -1
  127. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  128. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +40 -1
  129. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
  130. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +1 -0
  131. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
  132. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +1 -0
  133. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
  134. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
  135. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +3 -0
  136. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  137. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +23 -0
  138. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  139. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
  140. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +20 -0
  141. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
  142. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts +2 -0
  143. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts.map +1 -0
  144. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js +79 -0
  145. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js.map +1 -0
  146. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
  147. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  148. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +13 -0
  149. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  150. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +1 -1
  151. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  152. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +18 -1
  153. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  154. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  155. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
  156. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
  157. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts +11 -0
  158. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts.map +1 -0
  159. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js +18 -0
  160. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js.map +1 -0
  161. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts +2 -0
  162. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts.map +1 -0
  163. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +48 -0
  164. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -0
  165. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +51 -0
  166. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +108 -0
  167. package/packages/pi-coding-agent/src/core/extensions/runner.ts +16 -1
  168. package/packages/pi-coding-agent/src/core/model-registry.ts +4 -0
  169. package/packages/pi-coding-agent/src/core/settings-manager.ts +12 -0
  170. package/packages/pi-coding-agent/src/core/slash-commands.ts +1 -0
  171. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
  172. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +78 -15
  173. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +59 -0
  174. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +160 -0
  175. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
  176. package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +10 -9
  177. package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +15 -0
  178. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
  179. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +118 -17
  180. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +43 -1
  181. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +73 -1
  182. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +1 -0
  183. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +1 -1
  184. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +25 -0
  185. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.test.ts +95 -0
  186. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +24 -1
  187. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.ts +13 -0
  188. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +32 -2
  189. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
  190. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +65 -0
  191. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.ts +29 -0
  192. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  193. package/packages/pi-tui/dist/__tests__/style.test.d.ts +2 -0
  194. package/packages/pi-tui/dist/__tests__/style.test.d.ts.map +1 -0
  195. package/packages/pi-tui/dist/__tests__/style.test.js +63 -0
  196. package/packages/pi-tui/dist/__tests__/style.test.js.map +1 -0
  197. package/packages/pi-tui/dist/__tests__/tui.test.js +24 -3
  198. package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
  199. package/packages/pi-tui/dist/index.d.ts +1 -0
  200. package/packages/pi-tui/dist/index.d.ts.map +1 -1
  201. package/packages/pi-tui/dist/index.js +2 -0
  202. package/packages/pi-tui/dist/index.js.map +1 -1
  203. package/packages/pi-tui/dist/style.d.ts +41 -0
  204. package/packages/pi-tui/dist/style.d.ts.map +1 -0
  205. package/packages/pi-tui/dist/style.js +158 -0
  206. package/packages/pi-tui/dist/style.js.map +1 -0
  207. package/packages/pi-tui/dist/tui.d.ts +0 -1
  208. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  209. package/packages/pi-tui/dist/tui.js +3 -8
  210. package/packages/pi-tui/dist/tui.js.map +1 -1
  211. package/packages/pi-tui/src/__tests__/style.test.ts +76 -0
  212. package/packages/pi-tui/src/__tests__/tui.test.ts +29 -3
  213. package/packages/pi-tui/src/index.ts +9 -0
  214. package/packages/pi-tui/src/style.ts +225 -0
  215. package/packages/pi-tui/src/tui.ts +3 -8
  216. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  217. package/pkg/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
  218. package/pkg/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  219. package/pkg/dist/modes/interactive/theme/theme-schema.js +13 -0
  220. package/pkg/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  221. package/pkg/dist/modes/interactive/theme/theme.d.ts +1 -1
  222. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  223. package/pkg/dist/modes/interactive/theme/theme.js +18 -1
  224. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  225. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  226. package/pkg/dist/modes/interactive/theme/themes.js +36 -27
  227. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
  228. package/src/resources/extensions/github-sync/templates.ts +38 -8
  229. package/src/resources/extensions/github-sync/tests/inline-code.test.ts +66 -0
  230. package/src/resources/extensions/gsd/auto/loop.ts +17 -10
  231. package/src/resources/extensions/gsd/auto/run-unit.ts +24 -14
  232. package/src/resources/extensions/gsd/auto-dashboard.ts +57 -8
  233. package/src/resources/extensions/gsd/auto-dispatch.ts +17 -0
  234. package/src/resources/extensions/gsd/auto-recovery.ts +153 -7
  235. package/src/resources/extensions/gsd/auto-start.ts +7 -6
  236. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +16 -1
  237. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +17 -1
  238. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +135 -1
  239. package/src/resources/extensions/gsd/commands-extract-learnings.ts +17 -12
  240. package/src/resources/extensions/gsd/custom-workflow-engine.ts +24 -1
  241. package/src/resources/extensions/gsd/db-base-schema.ts +15 -0
  242. package/src/resources/extensions/gsd/db-migration-steps.ts +17 -0
  243. package/src/resources/extensions/gsd/graph.ts +12 -5
  244. package/src/resources/extensions/gsd/gsd-db.ts +119 -1
  245. package/src/resources/extensions/gsd/guided-flow.ts +2 -2
  246. package/src/resources/extensions/gsd/pr-evidence.ts +63 -5
  247. package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +7 -1
  248. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +33 -0
  249. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +83 -4
  250. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +170 -1
  251. package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +9 -0
  252. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +112 -6
  253. package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +40 -2
  254. package/src/resources/extensions/gsd/tests/db-migration-steps.integration.test.ts +428 -0
  255. package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +2 -2
  256. package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-basic.md +52 -0
  257. package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-empty-optionals.md +42 -0
  258. package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +55 -0
  259. package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +60 -0
  260. package/src/resources/extensions/gsd/tests/graph-operations.test.ts +10 -0
  261. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +44 -0
  262. package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
  263. package/src/resources/extensions/gsd/tests/pr-evidence-equivalence.test.ts +102 -0
  264. package/src/resources/extensions/gsd/tests/pr-evidence-hardening.test.ts +165 -0
  265. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
  266. package/src/resources/extensions/gsd/tests/working-output-messages.test.ts +93 -0
  267. package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +179 -0
  268. package/src/resources/extensions/gsd/working-output-messages.ts +120 -0
  269. /package/dist/web/standalone/.next/static/{HZXiuIbWQmvXjo4Tl3_zk → TCSim36ZpcPu2WgeoC45g}/_buildManifest.js +0 -0
  270. /package/dist/web/standalone/.next/static/{HZXiuIbWQmvXjo4Tl3_zk → TCSim36ZpcPu2WgeoC45g}/_ssgManifest.js +0 -0
@@ -1,7 +1,9 @@
1
- import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
2
2
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
3
3
  import { minimatch } from "minimatch";
4
+ import { getIsolationMode } from "../preferences.js";
4
5
  import { logWarning } from "../workflow-logger.js";
6
+ import { isGsdWorktreePath, resolveWorktreeProjectRoot } from "../worktree-root.js";
5
7
  /**
6
8
  * Regex matching milestone CONTEXT.md file names in both legacy M001
7
9
  * and unique M001-abc123 formats. Exported so regex-hardening tests
@@ -728,3 +730,129 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
728
730
  // avoids breaking gsd_* MCP tools or future safe additions.
729
731
  return { block: false };
730
732
  }
733
+ // ─── Worktree isolation write gate (#5199) ────────────────────────────────
734
+ //
735
+ // When `git.isolation: worktree` is configured, the per-unit commit pipeline
736
+ // only runs inside the auto-mode loop (`auto-post-unit.ts`). If the LLM
737
+ // authors code at the project root before auto-mode is started, those writes
738
+ // land in the working tree but never reach a commit — they're silently
739
+ // orphaned outside git history. This guard blocks those writes at the
740
+ // tool_call seam so the agent receives a clear error instead.
741
+ const WORKTREE_GATE_BOOTSTRAP_UNITS = new Set([
742
+ "discuss-milestone",
743
+ "plan-milestone",
744
+ "init",
745
+ ]);
746
+ function realpathOrResolve(p) {
747
+ const abs = resolve(p);
748
+ try {
749
+ return realpathSync(abs);
750
+ }
751
+ catch {
752
+ // Path doesn't exist (yet) — realpath the deepest existing ancestor so
753
+ // platforms where /tmp -> /private/tmp don't break containment checks.
754
+ let dir = abs;
755
+ const tail = [];
756
+ while (dir && dir !== resolve(dir, "..")) {
757
+ try {
758
+ const real = realpathSync(dir);
759
+ return tail.length ? join(real, ...tail.reverse()) : real;
760
+ }
761
+ catch {
762
+ const idx = dir.lastIndexOf(sep);
763
+ if (idx <= 0)
764
+ break;
765
+ tail.push(dir.slice(idx + 1));
766
+ dir = dir.slice(0, idx) || sep;
767
+ }
768
+ }
769
+ return abs;
770
+ }
771
+ }
772
+ function isPathContained(target, container) {
773
+ if (target === container)
774
+ return true;
775
+ return target.startsWith(container.endsWith(sep) ? container : container + sep);
776
+ }
777
+ /**
778
+ * Block planning-write tool calls that would land code at the project root
779
+ * while `git.isolation: worktree` is in effect and auto-mode hasn't created
780
+ * (or flipped cwd into) the milestone worktree.
781
+ *
782
+ * Pure / unit-testable. Callers in `register-hooks.ts` supply the resolved
783
+ * project root and current auto liveness; this function does no I/O beyond
784
+ * realpath resolution.
785
+ *
786
+ * Allow rules (in order):
787
+ * 1. Tool isn't a planning-write (write/edit/multi_edit/notebook_edit).
788
+ * 2. `GSD_DISABLE_WORKTREE_WRITE_GUARD=1` self-hosting bypass.
789
+ * 3. Isolation mode is not "worktree".
790
+ * 4. Active unit is a bootstrap unit (discuss-milestone/plan-milestone/init).
791
+ * 5. Target is inside `<projectRoot>/.gsd/worktrees/` (a real worktree).
792
+ * 6. Target is inside `<projectRoot>/.gsd/` and isn't masquerading as a
793
+ * worktrees sibling (rejects the `.gsd/worktrees-extra/…` prefix trick).
794
+ * 7. Auto is live AND `effectiveBasePath` is itself a `.gsd/worktrees/…` path.
795
+ *
796
+ * Otherwise: block with a message that points the agent at `/gsd` to start
797
+ * auto-mode.
798
+ */
799
+ export function shouldBlockWorktreeWrite(toolName, targetPath, effectiveBasePath, isAutoLive, currentUnitType) {
800
+ const tool = canonicalToolName(toolName);
801
+ if (!PLANNING_WRITE_TOOLS.has(tool))
802
+ return { block: false };
803
+ if (process.env.GSD_DISABLE_WORKTREE_WRITE_GUARD === "1")
804
+ return { block: false };
805
+ if (getIsolationMode(effectiveBasePath) !== "worktree")
806
+ return { block: false };
807
+ if (currentUnitType && WORKTREE_GATE_BOOTSTRAP_UNITS.has(currentUnitType))
808
+ return { block: false };
809
+ if (!targetPath) {
810
+ return {
811
+ block: true,
812
+ reason: [
813
+ `HARD BLOCK: ${tool} called with empty path while \`git.isolation: worktree\` is configured`,
814
+ `and auto-mode is not active. Refusing to allow writes that cannot be located.`,
815
+ ].join(" "),
816
+ };
817
+ }
818
+ // Resolve the target relative to the project root, then realpath to defeat
819
+ // symlink-based escapes and prefix tricks (e.g. .gsd/worktrees-extra/).
820
+ const projectRoot = resolveWorktreeProjectRoot(effectiveBasePath);
821
+ const absTarget = isAbsolute(targetPath) ? targetPath : resolve(projectRoot, targetPath);
822
+ const realTarget = realpathOrResolve(absTarget);
823
+ const realRoot = realpathOrResolve(projectRoot);
824
+ const realGsd = realpathOrResolve(join(projectRoot, ".gsd"));
825
+ const realWorktreesDir = realpathOrResolve(join(projectRoot, ".gsd", "worktrees"));
826
+ // Allow writes inside the legitimate worktrees subtree.
827
+ if (isPathContained(realTarget, realWorktreesDir))
828
+ return { block: false };
829
+ // Allow writes to .gsd/ planning artifacts, but reject siblings whose name
830
+ // starts with "worktrees" (the worktrees-extra prefix trick — case 4).
831
+ if (isPathContained(realTarget, realGsd)) {
832
+ const rel = relative(realGsd, realTarget);
833
+ const firstSeg = rel.split(/[\/\\]/)[0] ?? "";
834
+ if (!firstSeg.startsWith("worktrees"))
835
+ return { block: false };
836
+ // fall through: looks like worktrees<something> sibling — block
837
+ }
838
+ // Auto is live and the caller is operating inside a worktree path —
839
+ // host tool's write happens in worktree context; let it through.
840
+ if (isAutoLive && isGsdWorktreePath(effectiveBasePath))
841
+ return { block: false };
842
+ // Block. Provide enough context that the agent can self-correct.
843
+ const displayTarget = isPathContained(realTarget, realRoot)
844
+ ? relative(realRoot, realTarget) || "."
845
+ : realTarget;
846
+ return {
847
+ block: true,
848
+ reason: [
849
+ `HARD BLOCK: Worktree isolation is configured (\`git.isolation: worktree\`) but auto-mode is`,
850
+ `not running and the target "${displayTarget}" is not inside \`.gsd/worktrees/<MID>/\`.`,
851
+ `Code edits at the project root would be lost — only the auto-mode commit pipeline`,
852
+ `(auto-post-unit) commits work, and it never runs outside the loop.`,
853
+ `Required action: start auto-mode with \`/gsd\` so the milestone worktree is created,`,
854
+ `then write inside it. To disable this guard for self-hosting development, set`,
855
+ `GSD_DISABLE_WORKTREE_WRITE_GUARD=1.`,
856
+ ].join(" "),
857
+ };
858
+ }
@@ -114,14 +114,19 @@ Using the \`write\` tool, persist the full structured report to
114
114
  LEARNINGS.md is the full, cited audit trail. Write it first — subsequent steps
115
115
  feed from its content.
116
116
 
117
- ### Step 3 — Optionally pre-query the memory store for semantic duplicates
117
+ ### Step 3 — Run one bounded duplicate check
118
118
 
119
- Before persisting any extracted item in Steps 4–6, you may call
120
- \`memory_query\` with 2–3 keywords from the item to check whether the
121
- memory store already holds a semantically equivalent entry at high
122
- confidence. Skip those items in their respective steps. The memory store
123
- is the single source of truth for cross-session durable knowledge — no
124
- other persistence call is part of this flow.
119
+ Before persisting extracted items in Steps 4–6, do at most one duplicate-check
120
+ pass for the durable Decisions, Lessons, and Patterns from this milestone. Use
121
+ the already-written LEARNINGS.md content and call \`memory_query\` once with a
122
+ compact keyword summary for the whole batch. If that result clearly shows a
123
+ semantically equivalent high-confidence memory for an item, mark only that item
124
+ as already captured and skip it in its respective persistence step.
125
+
126
+ Do not re-read milestone artefacts or repeat memory queries category-by-category
127
+ after this point. The memory store is the single source of truth for
128
+ cross-session durable knowledge — no other persistence call is part of this
129
+ flow.
125
130
 
126
131
  ### Step 4 — Persist Patterns via \`capture_thought\`
127
132
 
@@ -160,11 +165,11 @@ later projection back to a human-visible decisions register stays lossless
160
165
 
161
166
  ### Step 7 — Deduplication rule (applies to Steps 4, 5, 6)
162
167
 
163
- Before each \`capture_thought\` call, optionally call \`memory_query\` with 2–3
164
- keywords from the entry. If a semantically equivalent memory is returned at
165
- high confidence, skip the capture entirely. Prefer skipping a near-duplicate
166
- over creating a second slightly-different row — redundancy degrades the
167
- signal.
168
+ Use only the duplicate-check result from Step 3. If that bounded check returned
169
+ a semantically equivalent memory at high confidence for an extracted item, skip
170
+ the capture entirely. Otherwise, persist the item once via \`capture_thought\`.
171
+ Prefer skipping a near-duplicate over creating a second slightly-different row
172
+ — redundancy degrades the signal.
168
173
 
169
174
  ### Step 8 — Surprises stay only in LEARNINGS.md
170
175
 
@@ -13,13 +13,29 @@
13
13
  */
14
14
  import { readFileSync } from "node:fs";
15
15
  import { join } from "node:path";
16
- import { readGraph, writeGraph, getNextPendingStep, markStepActive, markStepComplete, expandIteration, } from "./graph.js";
16
+ import { readGraph, writeGraph, getNextPendingStep, markStepActive, markStepComplete, expandIteration, isTerminalStepStatus, } from "./graph.js";
17
17
  import { injectContext } from "./context-injector.js";
18
18
  import { readFrozenDefinition } from "./definition-io.js";
19
19
  import { parseUnitId } from "./unit-id.js";
20
20
  import { withFileLock } from "./file-lock.js";
21
21
  // Re-export for downstream consumers
22
22
  export { readFrozenDefinition } from "./definition-io.js";
23
+ function formatBlockedWorkflowReason(graph) {
24
+ const statusById = new Map(graph.steps.map((step) => [step.id, step.status]));
25
+ const blockedSteps = graph.steps
26
+ .filter((step) => step.status === "pending")
27
+ .map((step) => {
28
+ const blockers = step.dependsOn
29
+ .filter((depId) => !isTerminalStepStatus(statusById.get(depId)))
30
+ .map((depId) => `${depId} (${statusById.get(depId) ?? "missing"})`);
31
+ return blockers.length > 0
32
+ ? `${step.id} waiting on ${blockers.join(", ")}`
33
+ : `${step.id} has no runnable dependency path`;
34
+ });
35
+ return blockedSteps.length > 0
36
+ ? `Workflow blocked: no pending steps are ready. Blocked steps: ${blockedSteps.join("; ")}`
37
+ : "Workflow blocked: no pending steps are ready.";
38
+ }
23
39
  export class CustomWorkflowEngine {
24
40
  engineId = "custom";
25
41
  runDir;
@@ -80,7 +96,11 @@ export class CustomWorkflowEngine {
80
96
  if (!next) {
81
97
  const allDone = graph.steps.every((step) => step.status === "complete" || step.status === "expanded");
82
98
  if (!allDone) {
83
- return { action: "skip" };
99
+ return {
100
+ action: "stop",
101
+ reason: formatBlockedWorkflowReason(graph),
102
+ level: "error",
103
+ };
84
104
  }
85
105
  return {
86
106
  action: "stop",
@@ -294,6 +294,19 @@ export function createBaseSchemaObjects(db, hooks) {
294
294
  updated_at TEXT NOT NULL DEFAULT '',
295
295
  PRIMARY KEY (trace_id, turn_id, stage)
296
296
  )
297
+ `);
298
+ db.exec(`
299
+ CREATE TABLE IF NOT EXISTS milestone_commit_attributions (
300
+ commit_sha TEXT NOT NULL,
301
+ milestone_id TEXT NOT NULL,
302
+ slice_id TEXT DEFAULT NULL,
303
+ task_id TEXT DEFAULT NULL,
304
+ source TEXT NOT NULL DEFAULT 'recorded',
305
+ confidence REAL NOT NULL DEFAULT 1.0,
306
+ files_json TEXT NOT NULL DEFAULT '[]',
307
+ created_at TEXT NOT NULL DEFAULT '',
308
+ PRIMARY KEY (commit_sha, milestone_id)
309
+ )
297
310
  `);
298
311
  db.exec(`
299
312
  CREATE TABLE IF NOT EXISTS audit_events (
@@ -329,6 +342,7 @@ export function createBaseSchemaObjects(db, hooks) {
329
342
  db.exec("CREATE INDEX IF NOT EXISTS idx_gate_runs_turn ON gate_runs(trace_id, turn_id)");
330
343
  db.exec("CREATE INDEX IF NOT EXISTS idx_gate_runs_lookup ON gate_runs(milestone_id, slice_id, task_id, gate_id)");
331
344
  db.exec("CREATE INDEX IF NOT EXISTS idx_turn_git_tx_turn ON turn_git_transactions(trace_id, turn_id)");
345
+ db.exec("CREATE INDEX IF NOT EXISTS idx_milestone_commit_attr_milestone ON milestone_commit_attributions(milestone_id)");
332
346
  db.exec("CREATE INDEX IF NOT EXISTS idx_audit_events_trace ON audit_events(trace_id, ts)");
333
347
  db.exec("CREATE INDEX IF NOT EXISTS idx_audit_events_turn ON audit_events(trace_id, turn_id, ts)");
334
348
  db.exec("CREATE VIEW IF NOT EXISTS active_decisions AS SELECT * FROM decisions WHERE superseded_by IS NULL");
@@ -363,6 +363,22 @@ export function applyMigrationV21StructuredMemories(db) {
363
363
  export function applyMigrationV23MilestoneQueue(db) {
364
364
  ensureColumn(db, "milestones", "sequence", "ALTER TABLE milestones ADD COLUMN sequence INTEGER DEFAULT 0");
365
365
  }
366
+ export function applyMigrationV26MilestoneCommitAttributions(db) {
367
+ db.exec(`
368
+ CREATE TABLE IF NOT EXISTS milestone_commit_attributions (
369
+ commit_sha TEXT NOT NULL,
370
+ milestone_id TEXT NOT NULL,
371
+ slice_id TEXT DEFAULT NULL,
372
+ task_id TEXT DEFAULT NULL,
373
+ source TEXT NOT NULL DEFAULT 'recorded',
374
+ confidence REAL NOT NULL DEFAULT 1.0,
375
+ files_json TEXT NOT NULL DEFAULT '[]',
376
+ created_at TEXT NOT NULL DEFAULT '',
377
+ PRIMARY KEY (commit_sha, milestone_id)
378
+ )
379
+ `);
380
+ db.exec("CREATE INDEX IF NOT EXISTS idx_milestone_commit_attr_milestone ON milestone_commit_attributions(milestone_id)");
381
+ }
366
382
  export function applyMigrationV22QualityGateRepair(db, hooks) {
367
383
  const qgInfo = db.prepare("PRAGMA table_info(quality_gates)").all();
368
384
  const taskIdCol = qgInfo.find((r) => r["name"] === "task_id");
@@ -89,10 +89,16 @@ export function writeGraph(runDir, graph) {
89
89
  renameSync(tmpPath, filePath);
90
90
  }
91
91
  /**
92
- * Get the next pending step whose dependencies are all complete.
92
+ * Return whether a graph step status satisfies dependency edges.
93
+ */
94
+ export function isTerminalStepStatus(status) {
95
+ return status === "complete" || status === "expanded";
96
+ }
97
+ /**
98
+ * Get the next pending step whose dependencies are all terminal.
93
99
  *
94
100
  * Returns the first step (in array order) with status "pending" where
95
- * every step in its `dependsOn` list has status "complete".
101
+ * every step in its `dependsOn` list has status "complete" or "expanded".
96
102
  *
97
103
  * @param graph — the workflow graph to query
98
104
  * @returns The next dispatchable step, or null if none available
@@ -102,7 +108,7 @@ export function getNextPendingStep(graph) {
102
108
  for (const step of graph.steps) {
103
109
  if (step.status !== "pending")
104
110
  continue;
105
- const depsComplete = step.dependsOn.every((depId) => statusMap.get(depId) === "complete");
111
+ const depsComplete = step.dependsOn.every((depId) => isTerminalStepStatus(statusMap.get(depId)));
106
112
  if (depsComplete)
107
113
  return step;
108
114
  }
@@ -36,7 +36,7 @@ import { rowToActiveDecision, rowToActiveRequirement, rowToDecision, rowToRequir
36
36
  import { rowToGate } from "./db-gate-rows.js";
37
37
  import { rowToArtifact, rowToMilestone } from "./db-milestone-artifact-rows.js";
38
38
  import { backupDatabaseBeforeMigration } from "./db-migration-backup.js";
39
- import { applyMigrationV2Artifacts, applyMigrationV3Memories, applyMigrationV4DecisionMadeBy, applyMigrationV5HierarchyTables, applyMigrationV6SliceSummaries, applyMigrationV7Dependencies, applyMigrationV8PlanningFields, applyMigrationV9Ordering, applyMigrationV10ReplanTrigger, applyMigrationV11TaskPlanning, applyMigrationV12QualityGates, applyMigrationV13HotPathIndexes, applyMigrationV14SliceDependencies, applyMigrationV15AuditTables, applyMigrationV16EscalationSource, applyMigrationV17TaskEscalation, applyMigrationV18MemorySources, applyMigrationV19MemoryFts, applyMigrationV20MemoryRelations, applyMigrationV21StructuredMemories, applyMigrationV22QualityGateRepair, applyMigrationV23MilestoneQueue, } from "./db-migration-steps.js";
39
+ import { applyMigrationV2Artifacts, applyMigrationV3Memories, applyMigrationV4DecisionMadeBy, applyMigrationV5HierarchyTables, applyMigrationV6SliceSummaries, applyMigrationV7Dependencies, applyMigrationV8PlanningFields, applyMigrationV9Ordering, applyMigrationV10ReplanTrigger, applyMigrationV11TaskPlanning, applyMigrationV12QualityGates, applyMigrationV13HotPathIndexes, applyMigrationV14SliceDependencies, applyMigrationV15AuditTables, applyMigrationV16EscalationSource, applyMigrationV17TaskEscalation, applyMigrationV18MemorySources, applyMigrationV19MemoryFts, applyMigrationV20MemoryRelations, applyMigrationV21StructuredMemories, applyMigrationV22QualityGateRepair, applyMigrationV23MilestoneQueue, applyMigrationV26MilestoneCommitAttributions, } from "./db-migration-steps.js";
40
40
  import { isMemoriesFtsAvailableSchema, tryCreateMemoriesFtsSchema } from "./db-memory-fts-schema.js";
41
41
  import { createDbOpenState } from "./db-open-state.js";
42
42
  import { createRuntimeKvTableV25 } from "./db-runtime-kv-schema.js";
@@ -52,7 +52,7 @@ const providerLoader = createSqliteProviderLoader({
52
52
  nodeVersion: process.versions.node,
53
53
  writeStderr: (message) => process.stderr.write(message),
54
54
  });
55
- export const SCHEMA_VERSION = 25;
55
+ export const SCHEMA_VERSION = 26;
56
56
  function initSchema(db, fileBacked) {
57
57
  if (fileBacked)
58
58
  db.exec("PRAGMA journal_mode=WAL");
@@ -246,6 +246,10 @@ function migrateSchema(db) {
246
246
  createRuntimeKvTableV25(db);
247
247
  recordSchemaVersion(db, 25);
248
248
  }
249
+ if (currentVersion < 26) {
250
+ applyMigrationV26MilestoneCommitAttributions(db);
251
+ recordSchemaVersion(db, 26);
252
+ }
249
253
  db.exec("COMMIT");
250
254
  }
251
255
  catch (err) {
@@ -1158,6 +1162,47 @@ export function getSliceTasks(milestoneId, sliceId) {
1158
1162
  const rows = currentDb.prepare("SELECT * FROM tasks WHERE milestone_id = :mid AND slice_id = :sid ORDER BY sequence, id").all({ ":mid": milestoneId, ":sid": sliceId });
1159
1163
  return rows.map(rowToTask);
1160
1164
  }
1165
+ export function getCompletedMilestoneTaskFileHints(milestoneId) {
1166
+ if (!currentDb)
1167
+ return [];
1168
+ const rows = currentDb.prepare(`SELECT files, key_files
1169
+ FROM tasks
1170
+ WHERE milestone_id = :mid AND status IN ('complete', 'done')`).all({ ":mid": milestoneId });
1171
+ const hints = new Set();
1172
+ for (const row of rows) {
1173
+ for (const raw of [row["files"], row["key_files"]]) {
1174
+ for (const file of parseStringArrayColumn(raw)) {
1175
+ const normalized = normalizeRepoPath(file);
1176
+ if (normalized)
1177
+ hints.add(normalized);
1178
+ }
1179
+ }
1180
+ }
1181
+ return [...hints];
1182
+ }
1183
+ function parseStringArrayColumn(raw) {
1184
+ if (Array.isArray(raw))
1185
+ return raw.filter((entry) => typeof entry === "string");
1186
+ if (typeof raw !== "string")
1187
+ return [];
1188
+ const trimmed = raw.trim();
1189
+ if (!trimmed)
1190
+ return [];
1191
+ try {
1192
+ const parsed = JSON.parse(trimmed);
1193
+ if (Array.isArray(parsed))
1194
+ return parsed.filter((entry) => typeof entry === "string");
1195
+ if (typeof parsed === "string")
1196
+ return [parsed];
1197
+ }
1198
+ catch {
1199
+ return trimmed.split(",");
1200
+ }
1201
+ return [];
1202
+ }
1203
+ function normalizeRepoPath(file) {
1204
+ return file.trim().replace(/\\/g, "/").replace(/^\.\/+/, "");
1205
+ }
1161
1206
  // ─── ADR-011 Phase 2 escalation helpers ──────────────────────────────────
1162
1207
  /** Set pause-on-escalation state on a completed task. Mutually exclusive with awaiting_review. */
1163
1208
  export function setTaskEscalationPending(milestoneId, sliceId, taskId, artifactPath) {
@@ -1735,6 +1780,7 @@ export function deleteMilestone(milestoneId) {
1735
1780
  currentDb.prepare(`DELETE FROM replan_history WHERE milestone_id = :mid`).run({ ":mid": milestoneId });
1736
1781
  currentDb.prepare(`DELETE FROM assessments WHERE milestone_id = :mid`).run({ ":mid": milestoneId });
1737
1782
  currentDb.prepare(`DELETE FROM artifacts WHERE milestone_id = :mid`).run({ ":mid": milestoneId });
1783
+ currentDb.prepare(`DELETE FROM milestone_commit_attributions WHERE milestone_id = :mid`).run({ ":mid": milestoneId });
1738
1784
  currentDb.prepare(`DELETE FROM milestone_leases WHERE milestone_id = :mid`).run({ ":mid": milestoneId });
1739
1785
  currentDb.prepare(`DELETE FROM milestones WHERE id = :mid`).run({ ":mid": milestoneId });
1740
1786
  });
@@ -1962,6 +2008,59 @@ export function upsertTurnGitTransaction(entry) {
1962
2008
  ":updated_at": entry.updatedAt,
1963
2009
  });
1964
2010
  }
2011
+ export function getMilestoneCommitAttributionShas(milestoneId) {
2012
+ if (!currentDb)
2013
+ return [];
2014
+ const rows = currentDb.prepare(`SELECT commit_sha
2015
+ FROM milestone_commit_attributions
2016
+ WHERE milestone_id = :mid
2017
+ ORDER BY created_at, commit_sha`).all({ ":mid": milestoneId });
2018
+ return rows
2019
+ .map((row) => typeof row["commit_sha"] === "string" ? row["commit_sha"] : "")
2020
+ .filter(Boolean);
2021
+ }
2022
+ export function recordMilestoneCommitAttribution(entry) {
2023
+ if (!currentDb)
2024
+ return;
2025
+ transaction(() => {
2026
+ currentDb.prepare(`INSERT OR REPLACE INTO milestone_commit_attributions (
2027
+ commit_sha, milestone_id, slice_id, task_id, source, confidence, files_json, created_at
2028
+ ) VALUES (
2029
+ :commit_sha, :milestone_id, :slice_id, :task_id, :source, :confidence, :files_json, :created_at
2030
+ )`).run({
2031
+ ":commit_sha": entry.commitSha,
2032
+ ":milestone_id": entry.milestoneId,
2033
+ ":slice_id": entry.sliceId ?? null,
2034
+ ":task_id": entry.taskId ?? null,
2035
+ ":source": entry.source,
2036
+ ":confidence": entry.confidence,
2037
+ ":files_json": JSON.stringify(entry.files),
2038
+ ":created_at": entry.createdAt,
2039
+ });
2040
+ currentDb.prepare(`INSERT OR IGNORE INTO audit_events (
2041
+ event_id, trace_id, turn_id, caused_by, category, type, ts, payload_json
2042
+ ) VALUES (
2043
+ :event_id, :trace_id, :turn_id, :caused_by, :category, :type, :ts, :payload_json
2044
+ )`).run({
2045
+ ":event_id": `milestone-commit-attribution:${entry.milestoneId}:${entry.commitSha}`,
2046
+ ":trace_id": "milestone-commit-attribution",
2047
+ ":turn_id": null,
2048
+ ":caused_by": null,
2049
+ ":category": "git",
2050
+ ":type": "milestone-commit-attribution-recorded",
2051
+ ":ts": entry.createdAt,
2052
+ ":payload_json": JSON.stringify({
2053
+ commitSha: entry.commitSha,
2054
+ milestoneId: entry.milestoneId,
2055
+ sliceId: entry.sliceId ?? null,
2056
+ taskId: entry.taskId ?? null,
2057
+ source: entry.source,
2058
+ confidence: entry.confidence,
2059
+ files: entry.files,
2060
+ }),
2061
+ });
2062
+ });
2063
+ }
1965
2064
  export function insertAuditEvent(entry) {
1966
2065
  if (!currentDb)
1967
2066
  return;
@@ -2048,6 +2147,7 @@ export function clearEngineHierarchy() {
2048
2147
  currentDb.exec("DELETE FROM slice_dependencies");
2049
2148
  currentDb.exec("DELETE FROM assessments");
2050
2149
  currentDb.exec("DELETE FROM replan_history");
2150
+ currentDb.exec("DELETE FROM milestone_commit_attributions");
2051
2151
  currentDb.exec("DELETE FROM tasks");
2052
2152
  currentDb.exec("DELETE FROM slices");
2053
2153
  currentDb.exec("DELETE FROM milestone_leases");
@@ -1716,8 +1716,8 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
1716
1716
  // standard wizard below.
1717
1717
  {
1718
1718
  const prefs = loadEffectiveGSDPreferences(basePath)?.preferences;
1719
- const { hasPendingDeepStage } = await import("./auto-dispatch.js");
1720
- if (hasPendingDeepStage(prefs, basePath)) {
1719
+ const { shouldRunDeepProjectSetup } = await import("./auto-dispatch.js");
1720
+ if (shouldRunDeepProjectSetup(state, prefs, basePath)) {
1721
1721
  await startDeepProjectSetupForeground(ctx, pi, basePath, stepMode);
1722
1722
  return;
1723
1723
  }
@@ -8,8 +8,53 @@ const CHANGE_TYPE_LABELS = {
8
8
  docs: "Documentation only",
9
9
  chore: "Build, CI, or tooling changes",
10
10
  };
11
+ // Per-item cap for user-supplied content. 2 KB gives slice titles plus
12
+ // descriptions room while still bounding malicious DoS-via-PR-body input.
13
+ const USER_CONTENT_CAP_BYTES = 2048;
14
+ const TRUNCATION_SUFFIX = " … [truncated]";
15
+ // Strips HTML comments, fake commit trailers (Co-Authored-By, Signed-off-by —
16
+ // case-insensitive on the trailer name), and caps total length. Designed to
17
+ // be a no-op for well-formed input; golden fixtures must remain byte-stable.
18
+ // Trailer lines are removed (not rejected) so that a single bad line in an
19
+ // otherwise legitimate description does not block the entire PR.
20
+ function sanitizeUserContent(s) {
21
+ if (!s)
22
+ return s;
23
+ // Strip HTML comments greedily across newlines.
24
+ let out = s.replace(/<!--[\s\S]*?-->/g, "");
25
+ // Drop lines that look like commit trailers we do not want forged.
26
+ out = out
27
+ .split("\n")
28
+ .filter((line) => !/^\s*(co-authored-by|signed-off-by)\s*:/i.test(line))
29
+ .join("\n");
30
+ if (Buffer.byteLength(out, "utf8") > USER_CONTENT_CAP_BYTES) {
31
+ const budget = USER_CONTENT_CAP_BYTES - Buffer.byteLength(TRUNCATION_SUFFIX, "utf8");
32
+ // Truncate by code units to stay safely under the byte budget for ASCII;
33
+ // for multibyte content we conservatively walk back until under budget.
34
+ let sliced = out.slice(0, Math.max(0, budget));
35
+ while (Buffer.byteLength(sliced, "utf8") > budget && sliced.length > 0) {
36
+ sliced = sliced.slice(0, -1);
37
+ }
38
+ out = sliced + TRUNCATION_SUFFIX;
39
+ }
40
+ return out;
41
+ }
42
+ // Strips HTML comments and fake trailers without applying the length cap.
43
+ // Used for short fields like linkedIssue where truncation would be confusing.
44
+ function sanitizeIssueRef(s) {
45
+ if (!s)
46
+ return s;
47
+ let out = s.replace(/<!--[\s\S]*?-->/g, "");
48
+ out = out
49
+ .split("\n")
50
+ .filter((line) => !/^\s*(co-authored-by|signed-off-by)\s*:/i.test(line))
51
+ .join("\n");
52
+ return out;
53
+ }
11
54
  function normalizeList(values) {
12
- return (values ?? []).map((value) => value.trim()).filter(Boolean);
55
+ return (values ?? [])
56
+ .map((value) => sanitizeUserContent(value).trim())
57
+ .filter(Boolean);
13
58
  }
14
59
  function changeTypeChecklist(selected) {
15
60
  return Object.keys(CHANGE_TYPE_LABELS).map((type) => {
@@ -28,13 +73,17 @@ export function buildPrEvidence(input) {
28
73
  const subjectTitle = input.milestoneTitle?.trim() || subjectId;
29
74
  const changeType = input.changeType ?? "feat";
30
75
  const summaries = normalizeList(input.summaries);
76
+ const blockers = normalizeList(input.blockers);
31
77
  const roadmapItems = normalizeList(input.roadmapItems);
32
78
  const metrics = normalizeList(input.metrics);
33
79
  const testsRun = normalizeList(input.testsRun);
34
80
  const rollbackNotes = normalizeList(input.rollbackNotes);
35
- const linkedIssue = input.linkedIssue?.trim() || "Not specified. Add an issue link before marking this PR ready if CONTRIBUTING.md requires one.";
36
- const why = input.why?.trim() || `${capitalize(subjectKind)} work is complete and ready for review.`;
37
- const how = input.how?.trim() || "Generated from GSD evidence and local workflow artifacts.";
81
+ // linkedIssue is sanitized but not length-capped: legitimate issue refs
82
+ // are short by nature, and truncating "Closes #123" would be unhelpful.
83
+ const linkedIssueRaw = input.linkedIssue ? sanitizeIssueRef(input.linkedIssue).trim() : "";
84
+ const linkedIssue = linkedIssueRaw || "Not specified. Add an issue link before marking this PR ready if CONTRIBUTING.md requires one.";
85
+ const why = (input.why ? sanitizeUserContent(input.why).trim() : "") || `${capitalize(subjectKind)} work is complete and ready for review.`;
86
+ const how = (input.how ? sanitizeUserContent(input.how).trim() : "") || "Generated from GSD evidence and local workflow artifacts.";
38
87
  const title = `${changeType}: ${subjectTitle}`;
39
88
  const sections = [
40
89
  "## TL;DR",
@@ -46,19 +95,11 @@ export function buildPrEvidence(input) {
46
95
  "## What",
47
96
  "",
48
97
  summaries.length > 0 ? summaries.join("\n\n") : `${capitalize(subjectKind)} ${subjectId} completed.`,
49
- "",
50
- "## Why",
51
- "",
52
- why,
53
- "",
54
- "## How",
55
- "",
56
- how,
57
- "",
58
- "## Linked Issue",
59
- "",
60
- linkedIssue,
61
98
  ];
99
+ if (blockers.length > 0) {
100
+ sections.push("", "## Blockers", "", blockers.map((blocker) => `- ${blocker}`).join("\n"));
101
+ }
102
+ sections.push("", "## Why", "", why, "", "## How", "", how, "", "## Linked Issue", "", linkedIssue);
62
103
  if (roadmapItems.length > 0) {
63
104
  sections.push("", "## Roadmap", "", roadmapItems.join("\n"));
64
105
  }
@@ -0,0 +1,64 @@
1
+ // GSD-2 + src/resources/extensions/gsd/working-output-messages.ts - Formats and audits user-facing working-state messages.
2
+ const ACTION_RE = /\b(?:wait|pause|paused|retry|retrying|recover|recovering|resume|stop|stopped|run|press|type|configure|restart)\b/i;
3
+ export function formatAutoUnitWorkingMessage(unitType, unitId) {
4
+ switch (unitType) {
5
+ case "research-milestone":
6
+ case "research-slice":
7
+ return `Researching ${unitId}: waiting for provider response`;
8
+ case "plan-milestone":
9
+ case "plan-slice":
10
+ return `Planning ${unitId}: waiting for provider response`;
11
+ case "execute-task":
12
+ return `Executing ${unitId}: waiting for provider response`;
13
+ case "complete-slice":
14
+ case "complete-milestone":
15
+ return `Completing ${unitId}: waiting for provider response`;
16
+ default:
17
+ return `${unitType} ${unitId}: waiting for provider response`;
18
+ }
19
+ }
20
+ export function evaluateWorkingOutputMessage(item) {
21
+ const findings = [];
22
+ const message = item.message.trim();
23
+ const health = item.context?.health;
24
+ if (!message) {
25
+ findings.push({
26
+ code: "empty-message",
27
+ severity: "error",
28
+ detail: `${item.surface} message is empty`,
29
+ });
30
+ return findings;
31
+ }
32
+ if (/^Working(?:\.\.\.)?(?:\s|\(|$)/i.test(message)) {
33
+ findings.push({
34
+ code: "generic-working-message",
35
+ severity: "warning",
36
+ detail: `${item.surface} message should say what work is running`,
37
+ });
38
+ }
39
+ if (/Progressing well/i.test(message) && health && health !== "healthy") {
40
+ findings.push({
41
+ code: "misleading-healthy-message",
42
+ severity: "error",
43
+ detail: `${item.surface} says progress is healthy while runtime health is ${health}`,
44
+ });
45
+ }
46
+ if (/\b0\s*\/\s*0\s+slices\b/i.test(message)) {
47
+ findings.push({
48
+ code: "fake-zero-progress",
49
+ severity: "warning",
50
+ detail: `${item.surface} should hide roadmap progress before roadmap slices exist`,
51
+ });
52
+ }
53
+ if ((health === "stalled" || health === "provider-error" || health === "timeout") && !ACTION_RE.test(message)) {
54
+ findings.push({
55
+ code: "missing-action",
56
+ severity: "warning",
57
+ detail: `${item.surface} should give the user a next action for ${health}`,
58
+ });
59
+ }
60
+ return findings;
61
+ }
62
+ export function evaluateWorkingOutputMessages(items) {
63
+ return items.flatMap(evaluateWorkingOutputMessage);
64
+ }