@opengsd/gsd-pi 1.0.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 (2880) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/package.json +171 -0
  4. package/packages/contracts/dist/index.d.ts +3 -0
  5. package/packages/contracts/dist/index.d.ts.map +1 -0
  6. package/packages/contracts/dist/index.js +5 -0
  7. package/packages/contracts/dist/index.js.map +1 -0
  8. package/packages/contracts/dist/rpc.d.ts +549 -0
  9. package/packages/contracts/dist/rpc.d.ts.map +1 -0
  10. package/packages/contracts/dist/rpc.js +53 -0
  11. package/packages/contracts/dist/rpc.js.map +1 -0
  12. package/packages/contracts/dist/rpc.test.d.ts +2 -0
  13. package/packages/contracts/dist/rpc.test.d.ts.map +1 -0
  14. package/packages/contracts/dist/rpc.test.js +54 -0
  15. package/packages/contracts/dist/rpc.test.js.map +1 -0
  16. package/packages/contracts/dist/workflow.d.ts +201 -0
  17. package/packages/contracts/dist/workflow.d.ts.map +1 -0
  18. package/packages/contracts/dist/workflow.js +225 -0
  19. package/packages/contracts/dist/workflow.js.map +1 -0
  20. package/packages/contracts/package.json +39 -0
  21. package/packages/contracts/src/index.ts +5 -0
  22. package/packages/contracts/src/rpc.test.ts +80 -0
  23. package/packages/contracts/src/rpc.ts +286 -0
  24. package/packages/contracts/src/workflow.ts +237 -0
  25. package/packages/contracts/tsconfig.json +25 -0
  26. package/packages/daemon/package.json +49 -0
  27. package/packages/daemon/src/channel-manager.ts +223 -0
  28. package/packages/daemon/src/cli.ts +96 -0
  29. package/packages/daemon/src/commands.ts +110 -0
  30. package/packages/daemon/src/config.ts +137 -0
  31. package/packages/daemon/src/daemon.test.ts +763 -0
  32. package/packages/daemon/src/daemon.ts +199 -0
  33. package/packages/daemon/src/discord-bot.test.ts +792 -0
  34. package/packages/daemon/src/discord-bot.ts +491 -0
  35. package/packages/daemon/src/event-bridge.test.ts +620 -0
  36. package/packages/daemon/src/event-bridge.ts +494 -0
  37. package/packages/daemon/src/event-formatter.test.ts +401 -0
  38. package/packages/daemon/src/event-formatter.ts +413 -0
  39. package/packages/daemon/src/index.ts +55 -0
  40. package/packages/daemon/src/launchd.test.ts +356 -0
  41. package/packages/daemon/src/launchd.ts +242 -0
  42. package/packages/daemon/src/logger.ts +89 -0
  43. package/packages/daemon/src/message-batcher.test.ts +308 -0
  44. package/packages/daemon/src/message-batcher.ts +216 -0
  45. package/packages/daemon/src/orchestrator.test.ts +584 -0
  46. package/packages/daemon/src/orchestrator.ts +469 -0
  47. package/packages/daemon/src/project-scanner.test.ts +235 -0
  48. package/packages/daemon/src/project-scanner.ts +99 -0
  49. package/packages/daemon/src/session-manager.test.ts +822 -0
  50. package/packages/daemon/src/session-manager.ts +400 -0
  51. package/packages/daemon/src/types.ts +184 -0
  52. package/packages/daemon/src/verbosity.test.ts +171 -0
  53. package/packages/daemon/src/verbosity.ts +101 -0
  54. package/packages/daemon/tsconfig.json +24 -0
  55. package/packages/mcp-server/README.md +275 -0
  56. package/packages/mcp-server/package.json +53 -0
  57. package/packages/mcp-server/src/alias-telemetry.test.ts +78 -0
  58. package/packages/mcp-server/src/alias-telemetry.ts +30 -0
  59. package/packages/mcp-server/src/cli.ts +70 -0
  60. package/packages/mcp-server/src/env-writer.test.ts +433 -0
  61. package/packages/mcp-server/src/env-writer.ts +292 -0
  62. package/packages/mcp-server/src/import-candidates.test.ts +53 -0
  63. package/packages/mcp-server/src/index.ts +43 -0
  64. package/packages/mcp-server/src/mcp-server.test.ts +1395 -0
  65. package/packages/mcp-server/src/parse-workflow-args.test.ts +80 -0
  66. package/packages/mcp-server/src/readers/captures.ts +119 -0
  67. package/packages/mcp-server/src/readers/doctor-lite.ts +225 -0
  68. package/packages/mcp-server/src/readers/graph.test.ts +679 -0
  69. package/packages/mcp-server/src/readers/graph.ts +863 -0
  70. package/packages/mcp-server/src/readers/index.ts +28 -0
  71. package/packages/mcp-server/src/readers/knowledge.ts +111 -0
  72. package/packages/mcp-server/src/readers/metrics.ts +118 -0
  73. package/packages/mcp-server/src/readers/paths.test.ts +67 -0
  74. package/packages/mcp-server/src/readers/paths.ts +334 -0
  75. package/packages/mcp-server/src/readers/readers.test.ts +513 -0
  76. package/packages/mcp-server/src/readers/roadmap.ts +263 -0
  77. package/packages/mcp-server/src/readers/state.ts +223 -0
  78. package/packages/mcp-server/src/remote-questions.test.ts +397 -0
  79. package/packages/mcp-server/src/remote-questions.ts +967 -0
  80. package/packages/mcp-server/src/secure-env-collect.test.ts +260 -0
  81. package/packages/mcp-server/src/server.ts +1342 -0
  82. package/packages/mcp-server/src/session-manager.ts +404 -0
  83. package/packages/mcp-server/src/tool-credentials.test.ts +95 -0
  84. package/packages/mcp-server/src/tool-credentials.ts +97 -0
  85. package/packages/mcp-server/src/types.ts +96 -0
  86. package/packages/mcp-server/src/workflow-tools-parity.test.ts +257 -0
  87. package/packages/mcp-server/src/workflow-tools.test.ts +2350 -0
  88. package/packages/mcp-server/src/workflow-tools.ts +2257 -0
  89. package/packages/mcp-server/tsconfig.json +25 -0
  90. package/packages/mcp-server/tsconfig.test.json +19 -0
  91. package/packages/native/dist/ast/index.d.ts +4 -0
  92. package/packages/native/dist/ast/index.js +11 -0
  93. package/packages/native/dist/ast/types.d.ts +69 -0
  94. package/packages/native/dist/ast/types.js +2 -0
  95. package/packages/native/dist/clipboard/index.d.ts +28 -0
  96. package/packages/native/dist/clipboard/index.js +38 -0
  97. package/packages/native/dist/clipboard/types.d.ts +7 -0
  98. package/packages/native/dist/clipboard/types.js +2 -0
  99. package/packages/native/dist/diff/index.d.ts +33 -0
  100. package/packages/native/dist/diff/index.js +43 -0
  101. package/packages/native/dist/diff/types.d.ts +23 -0
  102. package/packages/native/dist/diff/types.js +2 -0
  103. package/packages/native/dist/fd/index.d.ts +26 -0
  104. package/packages/native/dist/fd/index.js +30 -0
  105. package/packages/native/dist/fd/types.d.ts +29 -0
  106. package/packages/native/dist/fd/types.js +2 -0
  107. package/packages/native/dist/glob/index.d.ts +28 -0
  108. package/packages/native/dist/glob/index.js +35 -0
  109. package/packages/native/dist/glob/types.d.ts +50 -0
  110. package/packages/native/dist/glob/types.js +2 -0
  111. package/packages/native/dist/grep/index.d.ts +21 -0
  112. package/packages/native/dist/grep/index.js +28 -0
  113. package/packages/native/dist/grep/types.d.ts +99 -0
  114. package/packages/native/dist/grep/types.js +2 -0
  115. package/packages/native/dist/gsd-parser/index.d.ts +45 -0
  116. package/packages/native/dist/gsd-parser/index.js +61 -0
  117. package/packages/native/dist/gsd-parser/types.d.ts +55 -0
  118. package/packages/native/dist/gsd-parser/types.js +8 -0
  119. package/packages/native/dist/highlight/index.d.ts +28 -0
  120. package/packages/native/dist/highlight/index.js +38 -0
  121. package/packages/native/dist/highlight/types.d.ts +25 -0
  122. package/packages/native/dist/highlight/types.js +2 -0
  123. package/packages/native/dist/html/index.d.ts +15 -0
  124. package/packages/native/dist/html/index.js +19 -0
  125. package/packages/native/dist/html/types.d.ts +7 -0
  126. package/packages/native/dist/html/types.js +2 -0
  127. package/packages/native/dist/image/index.d.ts +15 -0
  128. package/packages/native/dist/image/index.js +23 -0
  129. package/packages/native/dist/image/types.d.ts +35 -0
  130. package/packages/native/dist/image/types.js +29 -0
  131. package/packages/native/dist/index.d.ts +46 -0
  132. package/packages/native/dist/index.js +85 -0
  133. package/packages/native/dist/json-parse/index.d.ts +23 -0
  134. package/packages/native/dist/json-parse/index.js +78 -0
  135. package/packages/native/dist/native.d.ts +57 -0
  136. package/packages/native/dist/native.js +113 -0
  137. package/packages/native/dist/ps/index.d.ts +38 -0
  138. package/packages/native/dist/ps/index.js +53 -0
  139. package/packages/native/dist/stream-process/index.d.ts +35 -0
  140. package/packages/native/dist/stream-process/index.js +254 -0
  141. package/packages/native/dist/text/index.d.ts +55 -0
  142. package/packages/native/dist/text/index.js +76 -0
  143. package/packages/native/dist/text/types.d.ts +27 -0
  144. package/packages/native/dist/text/types.js +13 -0
  145. package/packages/native/dist/truncate/index.d.ts +29 -0
  146. package/packages/native/dist/truncate/index.js +30 -0
  147. package/packages/native/dist/ttsr/index.d.ts +27 -0
  148. package/packages/native/dist/ttsr/index.js +37 -0
  149. package/packages/native/dist/ttsr/types.d.ts +9 -0
  150. package/packages/native/dist/ttsr/types.js +2 -0
  151. package/packages/native/dist/xxhash/index.d.ts +22 -0
  152. package/packages/native/dist/xxhash/index.js +89 -0
  153. package/packages/native/package.json +97 -0
  154. package/packages/native/src/__tests__/_test-coverage-guard.test.mjs +98 -0
  155. package/packages/native/src/__tests__/clipboard.test.mjs +126 -0
  156. package/packages/native/src/__tests__/diff.test.mjs +189 -0
  157. package/packages/native/src/__tests__/fd.test.mjs +199 -0
  158. package/packages/native/src/__tests__/glob.test.mjs +237 -0
  159. package/packages/native/src/__tests__/grep.test.mjs +179 -0
  160. package/packages/native/src/__tests__/highlight.test.mjs +156 -0
  161. package/packages/native/src/__tests__/html.test.mjs +98 -0
  162. package/packages/native/src/__tests__/image.test.mjs +137 -0
  163. package/packages/native/src/__tests__/json-parse.test.mjs +158 -0
  164. package/packages/native/src/__tests__/module-compat.test.mjs +123 -0
  165. package/packages/native/src/__tests__/ps.test.mjs +115 -0
  166. package/packages/native/src/__tests__/stream-process.test.mjs +108 -0
  167. package/packages/native/src/__tests__/text.test.mjs +295 -0
  168. package/packages/native/src/__tests__/truncate.test.mjs +160 -0
  169. package/packages/native/src/__tests__/ttsr.test.mjs +135 -0
  170. package/packages/native/src/__tests__/xxhash.test.mjs +122 -0
  171. package/packages/native/src/ast/index.ts +12 -0
  172. package/packages/native/src/ast/types.ts +75 -0
  173. package/packages/native/src/clipboard/index.ts +40 -0
  174. package/packages/native/src/clipboard/types.ts +7 -0
  175. package/packages/native/src/diff/index.ts +61 -0
  176. package/packages/native/src/diff/types.ts +24 -0
  177. package/packages/native/src/fd/index.ts +36 -0
  178. package/packages/native/src/fd/types.ts +31 -0
  179. package/packages/native/src/glob/index.ts +44 -0
  180. package/packages/native/src/glob/types.ts +53 -0
  181. package/packages/native/src/grep/index.ts +49 -0
  182. package/packages/native/src/grep/types.ts +105 -0
  183. package/packages/native/src/gsd-parser/index.ts +98 -0
  184. package/packages/native/src/gsd-parser/types.ts +62 -0
  185. package/packages/native/src/highlight/index.ts +44 -0
  186. package/packages/native/src/highlight/types.ts +25 -0
  187. package/packages/native/src/html/index.ts +24 -0
  188. package/packages/native/src/html/types.ts +7 -0
  189. package/packages/native/src/image/index.ts +28 -0
  190. package/packages/native/src/image/types.ts +41 -0
  191. package/packages/native/src/index.ts +128 -0
  192. package/packages/native/src/json-parse/index.ts +76 -0
  193. package/packages/native/src/native.ts +154 -0
  194. package/packages/native/src/ps/index.ts +52 -0
  195. package/packages/native/src/stream-process/index.ts +313 -0
  196. package/packages/native/src/text/index.ts +125 -0
  197. package/packages/native/src/text/types.ts +29 -0
  198. package/packages/native/src/truncate/index.ts +50 -0
  199. package/packages/native/src/ttsr/index.ts +39 -0
  200. package/packages/native/src/ttsr/types.ts +10 -0
  201. package/packages/native/src/xxhash/index.ts +98 -0
  202. package/packages/native/tsconfig.json +9 -0
  203. package/packages/native/tsconfig.tsbuildinfo +1 -0
  204. package/packages/pi-agent-core/package.json +23 -0
  205. package/packages/pi-agent-core/src/agent-loop.test.ts +733 -0
  206. package/packages/pi-agent-core/src/agent-loop.ts +851 -0
  207. package/packages/pi-agent-core/src/agent.test.ts +129 -0
  208. package/packages/pi-agent-core/src/agent.ts +668 -0
  209. package/packages/pi-agent-core/src/index.ts +10 -0
  210. package/packages/pi-agent-core/src/proxy.ts +334 -0
  211. package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
  212. package/packages/pi-agent-core/src/token-audit.ts +287 -0
  213. package/packages/pi-agent-core/src/types.ts +358 -0
  214. package/packages/pi-agent-core/tsconfig.json +28 -0
  215. package/packages/pi-ai/bedrock-provider.d.ts +1 -0
  216. package/packages/pi-ai/bedrock-provider.js +1 -0
  217. package/packages/pi-ai/package.json +48 -0
  218. package/packages/pi-ai/scripts/generate-models.ts +1671 -0
  219. package/packages/pi-ai/src/api-registry.ts +86 -0
  220. package/packages/pi-ai/src/bedrock-provider.ts +6 -0
  221. package/packages/pi-ai/src/cli.ts +133 -0
  222. package/packages/pi-ai/src/env-api-keys.ts +148 -0
  223. package/packages/pi-ai/src/index.ts +36 -0
  224. package/packages/pi-ai/src/models/capability-patches.ts +51 -0
  225. package/packages/pi-ai/src/models/custom.ts +337 -0
  226. package/packages/pi-ai/src/models/fake-model.ts +30 -0
  227. package/packages/pi-ai/src/models/generated/amazon-bedrock.ts +1554 -0
  228. package/packages/pi-ai/src/models/generated/anthropic.ts +398 -0
  229. package/packages/pi-ai/src/models/generated/azure-openai-responses.ts +704 -0
  230. package/packages/pi-ai/src/models/generated/cerebras.ts +75 -0
  231. package/packages/pi-ai/src/models/generated/github-copilot.ts +446 -0
  232. package/packages/pi-ai/src/models/generated/google-antigravity.ts +177 -0
  233. package/packages/pi-ai/src/models/generated/google-gemini-cli.ts +109 -0
  234. package/packages/pi-ai/src/models/generated/google-vertex.ts +211 -0
  235. package/packages/pi-ai/src/models/generated/google.ts +466 -0
  236. package/packages/pi-ai/src/models/generated/groq.ts +160 -0
  237. package/packages/pi-ai/src/models/generated/huggingface.ts +349 -0
  238. package/packages/pi-ai/src/models/generated/index.ts +52 -0
  239. package/packages/pi-ai/src/models/generated/kimi-coding.ts +41 -0
  240. package/packages/pi-ai/src/models/generated/minimax-cn.ts +109 -0
  241. package/packages/pi-ai/src/models/generated/minimax.ts +109 -0
  242. package/packages/pi-ai/src/models/generated/mistral.ts +449 -0
  243. package/packages/pi-ai/src/models/generated/openai-codex.ts +177 -0
  244. package/packages/pi-ai/src/models/generated/openai.ts +721 -0
  245. package/packages/pi-ai/src/models/generated/opencode-go.ts +126 -0
  246. package/packages/pi-ai/src/models/generated/opencode.ts +534 -0
  247. package/packages/pi-ai/src/models/generated/openrouter.ts +4291 -0
  248. package/packages/pi-ai/src/models/generated/vercel-ai-gateway.ts +2608 -0
  249. package/packages/pi-ai/src/models/generated/xai.ts +415 -0
  250. package/packages/pi-ai/src/models/generated/zai.ts +241 -0
  251. package/packages/pi-ai/src/models/index.ts +115 -0
  252. package/packages/pi-ai/src/models.generated.test.ts +362 -0
  253. package/packages/pi-ai/src/models.test.ts +404 -0
  254. package/packages/pi-ai/src/models.ts +3 -0
  255. package/packages/pi-ai/src/oauth.ts +1 -0
  256. package/packages/pi-ai/src/providers/amazon-bedrock.test.ts +164 -0
  257. package/packages/pi-ai/src/providers/amazon-bedrock.ts +797 -0
  258. package/packages/pi-ai/src/providers/anthropic-auth.test.ts +92 -0
  259. package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +36 -0
  260. package/packages/pi-ai/src/providers/anthropic-shared.cache-breakpoint.test.ts +289 -0
  261. package/packages/pi-ai/src/providers/anthropic-shared.test.ts +134 -0
  262. package/packages/pi-ai/src/providers/anthropic-shared.ts +899 -0
  263. package/packages/pi-ai/src/providers/anthropic-vertex.ts +130 -0
  264. package/packages/pi-ai/src/providers/anthropic.ts +240 -0
  265. package/packages/pi-ai/src/providers/api-family.test.ts +129 -0
  266. package/packages/pi-ai/src/providers/api-family.ts +57 -0
  267. package/packages/pi-ai/src/providers/azure-openai-responses.ts +248 -0
  268. package/packages/pi-ai/src/providers/fake.ts +376 -0
  269. package/packages/pi-ai/src/providers/github-copilot-headers.ts +37 -0
  270. package/packages/pi-ai/src/providers/google-gemini-cli.test.ts +90 -0
  271. package/packages/pi-ai/src/providers/google-gemini-cli.ts +982 -0
  272. package/packages/pi-ai/src/providers/google-shared.test.ts +137 -0
  273. package/packages/pi-ai/src/providers/google-shared.ts +364 -0
  274. package/packages/pi-ai/src/providers/google-vertex.ts +500 -0
  275. package/packages/pi-ai/src/providers/google.ts +467 -0
  276. package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +118 -0
  277. package/packages/pi-ai/src/providers/mistral.ts +597 -0
  278. package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
  279. package/packages/pi-ai/src/providers/openai-codex-responses.ts +1007 -0
  280. package/packages/pi-ai/src/providers/openai-completions.test.ts +75 -0
  281. package/packages/pi-ai/src/providers/openai-completions.ts +830 -0
  282. package/packages/pi-ai/src/providers/openai-responses-shared.ts +496 -0
  283. package/packages/pi-ai/src/providers/openai-responses.ts +205 -0
  284. package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
  285. package/packages/pi-ai/src/providers/provider-capabilities.test.ts +174 -0
  286. package/packages/pi-ai/src/providers/provider-capabilities.ts +215 -0
  287. package/packages/pi-ai/src/providers/register-builtins.ts +216 -0
  288. package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
  289. package/packages/pi-ai/src/providers/simple-options.ts +61 -0
  290. package/packages/pi-ai/src/providers/think-tag-parser.test.ts +44 -0
  291. package/packages/pi-ai/src/providers/think-tag-parser.ts +94 -0
  292. package/packages/pi-ai/src/providers/transform-messages-report.test.ts +189 -0
  293. package/packages/pi-ai/src/providers/transform-messages.ts +289 -0
  294. package/packages/pi-ai/src/stream.ts +59 -0
  295. package/packages/pi-ai/src/types.ts +413 -0
  296. package/packages/pi-ai/src/utils/event-stream.ts +87 -0
  297. package/packages/pi-ai/src/utils/hash.ts +13 -0
  298. package/packages/pi-ai/src/utils/json-parse.ts +51 -0
  299. package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +282 -0
  300. package/packages/pi-ai/src/utils/oauth/github-copilot.ts +470 -0
  301. package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +80 -0
  302. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +323 -0
  303. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +80 -0
  304. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +468 -0
  305. package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
  306. package/packages/pi-ai/src/utils/oauth/index.ts +134 -0
  307. package/packages/pi-ai/src/utils/oauth/openai-codex.ts +472 -0
  308. package/packages/pi-ai/src/utils/oauth/pkce.ts +34 -0
  309. package/packages/pi-ai/src/utils/oauth/types.ts +49 -0
  310. package/packages/pi-ai/src/utils/overflow.ts +129 -0
  311. package/packages/pi-ai/src/utils/repair-tool-json.ts +241 -0
  312. package/packages/pi-ai/src/utils/sanitize-unicode.ts +25 -0
  313. package/packages/pi-ai/src/utils/tests/json-parse.test.ts +17 -0
  314. package/packages/pi-ai/src/utils/tests/overflow.test.ts +58 -0
  315. package/packages/pi-ai/src/utils/tests/repair-tool-json.test.ts +240 -0
  316. package/packages/pi-ai/src/utils/typebox-helpers.ts +24 -0
  317. package/packages/pi-ai/src/utils/validation.ts +69 -0
  318. package/packages/pi-ai/src/web-runtime-env-api-keys.ts +86 -0
  319. package/packages/pi-ai/src/web-runtime-oauth.ts +9 -0
  320. package/packages/pi-ai/tsconfig.json +28 -0
  321. package/packages/pi-coding-agent/package.json +52 -0
  322. package/packages/pi-coding-agent/scripts/copy-assets.cjs +55 -0
  323. package/packages/pi-coding-agent/src/cli/abort-signal-timeout.test.ts +73 -0
  324. package/packages/pi-coding-agent/src/cli/abort-signal-timeout.ts +18 -0
  325. package/packages/pi-coding-agent/src/cli/args.test.ts +44 -0
  326. package/packages/pi-coding-agent/src/cli/args.ts +357 -0
  327. package/packages/pi-coding-agent/src/cli/config-selector.ts +52 -0
  328. package/packages/pi-coding-agent/src/cli/file-processor.ts +96 -0
  329. package/packages/pi-coding-agent/src/cli/list-models.ts +164 -0
  330. package/packages/pi-coding-agent/src/cli/session-picker.ts +51 -0
  331. package/packages/pi-coding-agent/src/cli.ts +20 -0
  332. package/packages/pi-coding-agent/src/config.ts +245 -0
  333. package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +491 -0
  334. package/packages/pi-coding-agent/src/core/agent-session-model-switch.test.ts +93 -0
  335. package/packages/pi-coding-agent/src/core/agent-session-renderable-tools.test.ts +70 -0
  336. package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
  337. package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +172 -0
  338. package/packages/pi-coding-agent/src/core/agent-session.ts +3150 -0
  339. package/packages/pi-coding-agent/src/core/artifact-manager.ts +125 -0
  340. package/packages/pi-coding-agent/src/core/auth-storage.test.ts +654 -0
  341. package/packages/pi-coding-agent/src/core/auth-storage.ts +925 -0
  342. package/packages/pi-coding-agent/src/core/bash-executor.ts +316 -0
  343. package/packages/pi-coding-agent/src/core/blob-store.ts +154 -0
  344. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +1571 -0
  345. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +307 -0
  346. package/packages/pi-coding-agent/src/core/compaction/compaction.test.ts +598 -0
  347. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +986 -0
  348. package/packages/pi-coding-agent/src/core/compaction/index.ts +7 -0
  349. package/packages/pi-coding-agent/src/core/compaction/utils.ts +368 -0
  350. package/packages/pi-coding-agent/src/core/compaction-orchestrator.test.ts +154 -0
  351. package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +440 -0
  352. package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
  353. package/packages/pi-coding-agent/src/core/compaction-utils.test.ts +117 -0
  354. package/packages/pi-coding-agent/src/core/constants.ts +59 -0
  355. package/packages/pi-coding-agent/src/core/contextual-tips.test.ts +259 -0
  356. package/packages/pi-coding-agent/src/core/contextual-tips.ts +232 -0
  357. package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
  358. package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
  359. package/packages/pi-coding-agent/src/core/defaults.ts +3 -0
  360. package/packages/pi-coding-agent/src/core/diagnostics.ts +15 -0
  361. package/packages/pi-coding-agent/src/core/discovery-cache.test.ts +163 -0
  362. package/packages/pi-coding-agent/src/core/discovery-cache.ts +104 -0
  363. package/packages/pi-coding-agent/src/core/event-bus.ts +33 -0
  364. package/packages/pi-coding-agent/src/core/exec.ts +106 -0
  365. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
  366. package/packages/pi-coding-agent/src/core/export-html/index.ts +306 -0
  367. package/packages/pi-coding-agent/src/core/export-html/template.css +971 -0
  368. package/packages/pi-coding-agent/src/core/export-html/template.html +54 -0
  369. package/packages/pi-coding-agent/src/core/export-html/template.js +1583 -0
  370. package/packages/pi-coding-agent/src/core/export-html/tool-renderer.ts +114 -0
  371. package/packages/pi-coding-agent/src/core/export-html/vendor/highlight.min.js +1213 -0
  372. package/packages/pi-coding-agent/src/core/export-html/vendor/marked.min.js +6 -0
  373. package/packages/pi-coding-agent/src/core/extensions/extension-discovery.ts +119 -0
  374. package/packages/pi-coding-agent/src/core/extensions/extension-manifest.test.ts +77 -0
  375. package/packages/pi-coding-agent/src/core/extensions/extension-manifest.ts +62 -0
  376. package/packages/pi-coding-agent/src/core/extensions/extension-registry.ts +222 -0
  377. package/packages/pi-coding-agent/src/core/extensions/extension-sort.test.ts +134 -0
  378. package/packages/pi-coding-agent/src/core/extensions/extension-sort.ts +137 -0
  379. package/packages/pi-coding-agent/src/core/extensions/index.ts +186 -0
  380. package/packages/pi-coding-agent/src/core/extensions/loader.test.ts +275 -0
  381. package/packages/pi-coding-agent/src/core/extensions/loader.ts +1139 -0
  382. package/packages/pi-coding-agent/src/core/extensions/project-trust.ts +51 -0
  383. package/packages/pi-coding-agent/src/core/extensions/provider-registration.test.ts +81 -0
  384. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +282 -0
  385. package/packages/pi-coding-agent/src/core/extensions/runner.ts +1241 -0
  386. package/packages/pi-coding-agent/src/core/extensions/types.ts +1872 -0
  387. package/packages/pi-coding-agent/src/core/extensions/wrapper.ts +127 -0
  388. package/packages/pi-coding-agent/src/core/fallback-resolver.test.ts +242 -0
  389. package/packages/pi-coding-agent/src/core/fallback-resolver.ts +164 -0
  390. package/packages/pi-coding-agent/src/core/footer-data-provider.ts +144 -0
  391. package/packages/pi-coding-agent/src/core/fs-utils.test.ts +54 -0
  392. package/packages/pi-coding-agent/src/core/fs-utils.ts +12 -0
  393. package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +271 -0
  394. package/packages/pi-coding-agent/src/core/hooks-runner.ts +460 -0
  395. package/packages/pi-coding-agent/src/core/image-overflow-recovery.test.ts +228 -0
  396. package/packages/pi-coding-agent/src/core/image-overflow-recovery.ts +118 -0
  397. package/packages/pi-coding-agent/src/core/index.ts +80 -0
  398. package/packages/pi-coding-agent/src/core/keybindings.ts +211 -0
  399. package/packages/pi-coding-agent/src/core/lifecycle-hooks.test.ts +227 -0
  400. package/packages/pi-coding-agent/src/core/lifecycle-hooks.ts +280 -0
  401. package/packages/pi-coding-agent/src/core/local-model-check.ts +45 -0
  402. package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
  403. package/packages/pi-coding-agent/src/core/lsp/client.ts +968 -0
  404. package/packages/pi-coding-agent/src/core/lsp/config.ts +356 -0
  405. package/packages/pi-coding-agent/src/core/lsp/defaults.json +456 -0
  406. package/packages/pi-coding-agent/src/core/lsp/edits.ts +109 -0
  407. package/packages/pi-coding-agent/src/core/lsp/helpers.ts +54 -0
  408. package/packages/pi-coding-agent/src/core/lsp/index.ts +1065 -0
  409. package/packages/pi-coding-agent/src/core/lsp/lsp-integration.test.ts +451 -0
  410. package/packages/pi-coding-agent/src/core/lsp/lsp-legacy-alias.test.ts +70 -0
  411. package/packages/pi-coding-agent/src/core/lsp/lsp.md +39 -0
  412. package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +190 -0
  413. package/packages/pi-coding-agent/src/core/lsp/types.ts +445 -0
  414. package/packages/pi-coding-agent/src/core/lsp/utils.ts +706 -0
  415. package/packages/pi-coding-agent/src/core/messages.test.ts +114 -0
  416. package/packages/pi-coding-agent/src/core/messages.ts +226 -0
  417. package/packages/pi-coding-agent/src/core/model-discovery.test.ts +144 -0
  418. package/packages/pi-coding-agent/src/core/model-discovery.ts +318 -0
  419. package/packages/pi-coding-agent/src/core/model-registry-auth-header.test.ts +44 -0
  420. package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +730 -0
  421. package/packages/pi-coding-agent/src/core/model-registry-custom-caps.test.ts +245 -0
  422. package/packages/pi-coding-agent/src/core/model-registry-discovery.test.ts +210 -0
  423. package/packages/pi-coding-agent/src/core/model-registry-env-fallback.test.ts +59 -0
  424. package/packages/pi-coding-agent/src/core/model-registry.ts +1053 -0
  425. package/packages/pi-coding-agent/src/core/model-resolver-initial-model-auth.test.ts +78 -0
  426. package/packages/pi-coding-agent/src/core/model-resolver.test.ts +85 -0
  427. package/packages/pi-coding-agent/src/core/model-resolver.ts +511 -0
  428. package/packages/pi-coding-agent/src/core/models-json-writer.test.ts +145 -0
  429. package/packages/pi-coding-agent/src/core/models-json-writer.ts +188 -0
  430. package/packages/pi-coding-agent/src/core/package-commands.test.ts +262 -0
  431. package/packages/pi-coding-agent/src/core/package-commands.ts +310 -0
  432. package/packages/pi-coding-agent/src/core/package-manager.ts +1845 -0
  433. package/packages/pi-coding-agent/src/core/prompt-templates.ts +299 -0
  434. package/packages/pi-coding-agent/src/core/redact-secrets.test.ts +86 -0
  435. package/packages/pi-coding-agent/src/core/redact-secrets.ts +58 -0
  436. package/packages/pi-coding-agent/src/core/resolve-config-value.test.ts +295 -0
  437. package/packages/pi-coding-agent/src/core/resolve-config-value.ts +118 -0
  438. package/packages/pi-coding-agent/src/core/resource-loader-cache-reset.test.ts +107 -0
  439. package/packages/pi-coding-agent/src/core/resource-loader.ts +929 -0
  440. package/packages/pi-coding-agent/src/core/retry-handler.test.ts +518 -0
  441. package/packages/pi-coding-agent/src/core/retry-handler.ts +576 -0
  442. package/packages/pi-coding-agent/src/core/retryable-error-regex.ts +18 -0
  443. package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
  444. package/packages/pi-coding-agent/src/core/sdk.test.ts +113 -0
  445. package/packages/pi-coding-agent/src/core/sdk.ts +688 -0
  446. package/packages/pi-coding-agent/src/core/session-manager.test.ts +129 -0
  447. package/packages/pi-coding-agent/src/core/session-manager.ts +1646 -0
  448. package/packages/pi-coding-agent/src/core/settings-manager-security.test.ts +102 -0
  449. package/packages/pi-coding-agent/src/core/settings-manager.ts +1247 -0
  450. package/packages/pi-coding-agent/src/core/skill-tool.test.ts +117 -0
  451. package/packages/pi-coding-agent/src/core/skills.ts +490 -0
  452. package/packages/pi-coding-agent/src/core/slash-commands.ts +43 -0
  453. package/packages/pi-coding-agent/src/core/system-prompt.ts +296 -0
  454. package/packages/pi-coding-agent/src/core/timings.ts +25 -0
  455. package/packages/pi-coding-agent/src/core/token-telemetry.ts +77 -0
  456. package/packages/pi-coding-agent/src/core/tools/bash-background.test.ts +91 -0
  457. package/packages/pi-coding-agent/src/core/tools/bash-interceptor.test.ts +198 -0
  458. package/packages/pi-coding-agent/src/core/tools/bash-interceptor.ts +115 -0
  459. package/packages/pi-coding-agent/src/core/tools/bash-spawn-windows.test.ts +77 -0
  460. package/packages/pi-coding-agent/src/core/tools/bash.ts +478 -0
  461. package/packages/pi-coding-agent/src/core/tools/edit-diff.test.ts +85 -0
  462. package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +402 -0
  463. package/packages/pi-coding-agent/src/core/tools/edit.ts +242 -0
  464. package/packages/pi-coding-agent/src/core/tools/find.ts +209 -0
  465. package/packages/pi-coding-agent/src/core/tools/grep.ts +356 -0
  466. package/packages/pi-coding-agent/src/core/tools/hashline-edit.ts +318 -0
  467. package/packages/pi-coding-agent/src/core/tools/hashline-read.ts +207 -0
  468. package/packages/pi-coding-agent/src/core/tools/hashline.test.ts +456 -0
  469. package/packages/pi-coding-agent/src/core/tools/hashline.ts +525 -0
  470. package/packages/pi-coding-agent/src/core/tools/index.ts +226 -0
  471. package/packages/pi-coding-agent/src/core/tools/ls.ts +178 -0
  472. package/packages/pi-coding-agent/src/core/tools/path-utils.test.ts +67 -0
  473. package/packages/pi-coding-agent/src/core/tools/path-utils.ts +106 -0
  474. package/packages/pi-coding-agent/src/core/tools/read.ts +235 -0
  475. package/packages/pi-coding-agent/src/core/tools/spawn-shell-windows.test.ts +31 -0
  476. package/packages/pi-coding-agent/src/core/tools/tool-compatibility-registry.ts +83 -0
  477. package/packages/pi-coding-agent/src/core/tools/tool-target-metadata.test.ts +127 -0
  478. package/packages/pi-coding-agent/src/core/tools/tool-target.ts +48 -0
  479. package/packages/pi-coding-agent/src/core/tools/truncate.ts +267 -0
  480. package/packages/pi-coding-agent/src/core/tools/write.ts +133 -0
  481. package/packages/pi-coding-agent/src/index.ts +422 -0
  482. package/packages/pi-coding-agent/src/main.ts +649 -0
  483. package/packages/pi-coding-agent/src/migrations.ts +295 -0
  484. package/packages/pi-coding-agent/src/modes/index.ts +16 -0
  485. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/assistant-message-design.test.ts +128 -0
  486. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +93 -0
  487. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/collapsible-message.test.ts +111 -0
  488. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/login-dialog.test.ts +24 -0
  489. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/provider-display-name.test.ts +28 -0
  490. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/timestamp.test.ts +41 -0
  491. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +512 -0
  492. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/user-message-design.test.ts +139 -0
  493. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +66 -0
  494. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +161 -0
  495. package/packages/pi-coding-agent/src/modes/interactive/components/animated-component.test.ts +115 -0
  496. package/packages/pi-coding-agent/src/modes/interactive/components/animated-component.ts +107 -0
  497. package/packages/pi-coding-agent/src/modes/interactive/components/armin.ts +360 -0
  498. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +200 -0
  499. package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.test.ts +35 -0
  500. package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +287 -0
  501. package/packages/pi-coding-agent/src/modes/interactive/components/bordered-loader.ts +66 -0
  502. package/packages/pi-coding-agent/src/modes/interactive/components/branch-summary-message.ts +54 -0
  503. package/packages/pi-coding-agent/src/modes/interactive/components/collapsible-message.ts +45 -0
  504. package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +73 -0
  505. package/packages/pi-coding-agent/src/modes/interactive/components/config-selector.ts +599 -0
  506. package/packages/pi-coding-agent/src/modes/interactive/components/countdown-timer.ts +43 -0
  507. package/packages/pi-coding-agent/src/modes/interactive/components/custom-editor.ts +97 -0
  508. package/packages/pi-coding-agent/src/modes/interactive/components/custom-message.ts +89 -0
  509. package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.test.ts +68 -0
  510. package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.ts +159 -0
  511. package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +153 -0
  512. package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.test.ts +99 -0
  513. package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +97 -0
  514. package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +150 -0
  515. package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +92 -0
  516. package/packages/pi-coding-agent/src/modes/interactive/components/extension-selector.ts +152 -0
  517. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +266 -0
  518. package/packages/pi-coding-agent/src/modes/interactive/components/index.ts +33 -0
  519. package/packages/pi-coding-agent/src/modes/interactive/components/interactive-key-handling.test.ts +122 -0
  520. package/packages/pi-coding-agent/src/modes/interactive/components/keybinding-hints.ts +84 -0
  521. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +256 -0
  522. package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +693 -0
  523. package/packages/pi-coding-agent/src/modes/interactive/components/oauth-selector.ts +127 -0
  524. package/packages/pi-coding-agent/src/modes/interactive/components/provider-manager.ts +231 -0
  525. package/packages/pi-coding-agent/src/modes/interactive/components/render-cache.ts +22 -0
  526. package/packages/pi-coding-agent/src/modes/interactive/components/scoped-models-selector.ts +342 -0
  527. package/packages/pi-coding-agent/src/modes/interactive/components/selector-footers.test.ts +63 -0
  528. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
  529. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +1015 -0
  530. package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +466 -0
  531. package/packages/pi-coding-agent/src/modes/interactive/components/show-images-selector.ts +47 -0
  532. package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +61 -0
  533. package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.test.ts +27 -0
  534. package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.ts +67 -0
  535. package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +66 -0
  536. package/packages/pi-coding-agent/src/modes/interactive/components/timestamp.ts +49 -0
  537. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +303 -0
  538. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1457 -0
  539. package/packages/pi-coding-agent/src/modes/interactive/components/transcript-design.ts +345 -0
  540. package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +84 -0
  541. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +1125 -0
  542. package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.test.ts +28 -0
  543. package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.ts +154 -0
  544. package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +76 -0
  545. package/packages/pi-coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
  546. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +230 -0
  547. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +1066 -0
  548. package/packages/pi-coding-agent/src/modes/interactive/controllers/extension-ui-controller.ts +68 -0
  549. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +373 -0
  550. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +157 -0
  551. package/packages/pi-coding-agent/src/modes/interactive/controllers/model-controller.ts +76 -0
  552. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-lifecycle.test.ts +63 -0
  553. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +73 -0
  554. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +40 -0
  555. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4418 -0
  556. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.test.ts +95 -0
  557. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +695 -0
  558. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-highlight.test.ts +23 -0
  559. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.ts +96 -0
  560. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +1130 -0
  561. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +388 -0
  562. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +68 -0
  563. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.ts +29 -0
  564. package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +15 -0
  565. package/packages/pi-coding-agent/src/modes/interactive/utils/tool-call-summary.test.ts +39 -0
  566. package/packages/pi-coding-agent/src/modes/interactive/utils/tool-call-summary.ts +56 -0
  567. package/packages/pi-coding-agent/src/modes/print-mode.ts +106 -0
  568. package/packages/pi-coding-agent/src/modes/rpc/jsonl.ts +64 -0
  569. package/packages/pi-coding-agent/src/modes/rpc/remote-terminal.ts +109 -0
  570. package/packages/pi-coding-agent/src/modes/rpc/rpc-client.ts +574 -0
  571. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +891 -0
  572. package/packages/pi-coding-agent/src/modes/rpc/rpc-protocol-v2.test.ts +971 -0
  573. package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +4 -0
  574. package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
  575. package/packages/pi-coding-agent/src/resources/extensions/memory/index.ts +270 -0
  576. package/packages/pi-coding-agent/src/resources/extensions/memory/pipeline.ts +567 -0
  577. package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +31 -0
  578. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.test.ts +98 -0
  579. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +479 -0
  580. package/packages/pi-coding-agent/src/tests/path-display.test.ts +85 -0
  581. package/packages/pi-coding-agent/src/tests/system-prompt-cache-stability.test.ts +102 -0
  582. package/packages/pi-coding-agent/src/tests/system-prompt-file-safety.test.ts +22 -0
  583. package/packages/pi-coding-agent/src/tests/system-prompt-skill-filter.test.ts +157 -0
  584. package/packages/pi-coding-agent/src/tests/token-telemetry.test.ts +200 -0
  585. package/packages/pi-coding-agent/src/types/ambient-modules.d.ts +69 -0
  586. package/packages/pi-coding-agent/src/utils/changelog.ts +99 -0
  587. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +227 -0
  588. package/packages/pi-coding-agent/src/utils/clipboard-native.ts +11 -0
  589. package/packages/pi-coding-agent/src/utils/clipboard.ts +14 -0
  590. package/packages/pi-coding-agent/src/utils/error.ts +6 -0
  591. package/packages/pi-coding-agent/src/utils/frontmatter.ts +39 -0
  592. package/packages/pi-coding-agent/src/utils/git.ts +192 -0
  593. package/packages/pi-coding-agent/src/utils/image-convert.ts +28 -0
  594. package/packages/pi-coding-agent/src/utils/image-resize.ts +225 -0
  595. package/packages/pi-coding-agent/src/utils/mime.ts +30 -0
  596. package/packages/pi-coding-agent/src/utils/path-display.ts +36 -0
  597. package/packages/pi-coding-agent/src/utils/photon.ts +2 -0
  598. package/packages/pi-coding-agent/src/utils/shell.ts +212 -0
  599. package/packages/pi-coding-agent/src/utils/sleep.ts +18 -0
  600. package/packages/pi-coding-agent/src/utils/tools-manager.ts +286 -0
  601. package/packages/pi-coding-agent/tsconfig.json +28 -0
  602. package/packages/pi-tui/dist/__tests__/autocomplete.test.d.ts +2 -0
  603. package/packages/pi-tui/dist/__tests__/autocomplete.test.d.ts.map +1 -0
  604. package/packages/pi-tui/dist/__tests__/autocomplete.test.js +206 -0
  605. package/packages/pi-tui/dist/__tests__/autocomplete.test.js.map +1 -0
  606. package/packages/pi-tui/dist/__tests__/fuzzy.test.d.ts +2 -0
  607. package/packages/pi-tui/dist/__tests__/fuzzy.test.d.ts.map +1 -0
  608. package/packages/pi-tui/dist/__tests__/fuzzy.test.js +100 -0
  609. package/packages/pi-tui/dist/__tests__/fuzzy.test.js.map +1 -0
  610. package/packages/pi-tui/dist/__tests__/keys.test.d.ts +2 -0
  611. package/packages/pi-tui/dist/__tests__/keys.test.d.ts.map +1 -0
  612. package/packages/pi-tui/dist/__tests__/keys.test.js +18 -0
  613. package/packages/pi-tui/dist/__tests__/keys.test.js.map +1 -0
  614. package/packages/pi-tui/dist/__tests__/loader.test.d.ts +2 -0
  615. package/packages/pi-tui/dist/__tests__/loader.test.d.ts.map +1 -0
  616. package/packages/pi-tui/dist/__tests__/loader.test.js +24 -0
  617. package/packages/pi-tui/dist/__tests__/loader.test.js.map +1 -0
  618. package/packages/pi-tui/dist/__tests__/overlay-layout.test.d.ts +2 -0
  619. package/packages/pi-tui/dist/__tests__/overlay-layout.test.d.ts.map +1 -0
  620. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js +227 -0
  621. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js.map +1 -0
  622. package/packages/pi-tui/dist/__tests__/stdin-buffer.test.d.ts +2 -0
  623. package/packages/pi-tui/dist/__tests__/stdin-buffer.test.d.ts.map +1 -0
  624. package/packages/pi-tui/dist/__tests__/stdin-buffer.test.js +80 -0
  625. package/packages/pi-tui/dist/__tests__/stdin-buffer.test.js.map +1 -0
  626. package/packages/pi-tui/dist/__tests__/style.test.d.ts +2 -0
  627. package/packages/pi-tui/dist/__tests__/style.test.d.ts.map +1 -0
  628. package/packages/pi-tui/dist/__tests__/style.test.js +129 -0
  629. package/packages/pi-tui/dist/__tests__/style.test.js.map +1 -0
  630. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts +2 -0
  631. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts.map +1 -0
  632. package/packages/pi-tui/dist/__tests__/terminal.test.js +103 -0
  633. package/packages/pi-tui/dist/__tests__/terminal.test.js.map +1 -0
  634. package/packages/pi-tui/dist/__tests__/tui.test.d.ts +2 -0
  635. package/packages/pi-tui/dist/__tests__/tui.test.d.ts.map +1 -0
  636. package/packages/pi-tui/dist/__tests__/tui.test.js +315 -0
  637. package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -0
  638. package/packages/pi-tui/dist/__tests__/utils.test.d.ts +2 -0
  639. package/packages/pi-tui/dist/__tests__/utils.test.d.ts.map +1 -0
  640. package/packages/pi-tui/dist/__tests__/utils.test.js +17 -0
  641. package/packages/pi-tui/dist/__tests__/utils.test.js.map +1 -0
  642. package/packages/pi-tui/dist/autocomplete.d.ts +55 -0
  643. package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -0
  644. package/packages/pi-tui/dist/autocomplete.js +540 -0
  645. package/packages/pi-tui/dist/autocomplete.js.map +1 -0
  646. package/packages/pi-tui/dist/components/__tests__/box.test.d.ts +2 -0
  647. package/packages/pi-tui/dist/components/__tests__/box.test.d.ts.map +1 -0
  648. package/packages/pi-tui/dist/components/__tests__/box.test.js +20 -0
  649. package/packages/pi-tui/dist/components/__tests__/box.test.js.map +1 -0
  650. package/packages/pi-tui/dist/components/__tests__/cancellable-loader.test.d.ts +2 -0
  651. package/packages/pi-tui/dist/components/__tests__/cancellable-loader.test.d.ts.map +1 -0
  652. package/packages/pi-tui/dist/components/__tests__/cancellable-loader.test.js +38 -0
  653. package/packages/pi-tui/dist/components/__tests__/cancellable-loader.test.js.map +1 -0
  654. package/packages/pi-tui/dist/components/__tests__/editor.test.d.ts +2 -0
  655. package/packages/pi-tui/dist/components/__tests__/editor.test.d.ts.map +1 -0
  656. package/packages/pi-tui/dist/components/__tests__/editor.test.js +89 -0
  657. package/packages/pi-tui/dist/components/__tests__/editor.test.js.map +1 -0
  658. package/packages/pi-tui/dist/components/__tests__/input.test.d.ts +2 -0
  659. package/packages/pi-tui/dist/components/__tests__/input.test.d.ts.map +1 -0
  660. package/packages/pi-tui/dist/components/__tests__/input.test.js +81 -0
  661. package/packages/pi-tui/dist/components/__tests__/input.test.js.map +1 -0
  662. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts +2 -0
  663. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts.map +1 -0
  664. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js +161 -0
  665. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js.map +1 -0
  666. package/packages/pi-tui/dist/components/__tests__/loader.test.d.ts +2 -0
  667. package/packages/pi-tui/dist/components/__tests__/loader.test.d.ts.map +1 -0
  668. package/packages/pi-tui/dist/components/__tests__/loader.test.js +81 -0
  669. package/packages/pi-tui/dist/components/__tests__/loader.test.js.map +1 -0
  670. package/packages/pi-tui/dist/components/__tests__/markdown-list.test.d.ts +2 -0
  671. package/packages/pi-tui/dist/components/__tests__/markdown-list.test.d.ts.map +1 -0
  672. package/packages/pi-tui/dist/components/__tests__/markdown-list.test.js +36 -0
  673. package/packages/pi-tui/dist/components/__tests__/markdown-list.test.js.map +1 -0
  674. package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.d.ts +2 -0
  675. package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.d.ts.map +1 -0
  676. package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.js +70 -0
  677. package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.js.map +1 -0
  678. package/packages/pi-tui/dist/components/__tests__/select-list.test.d.ts +2 -0
  679. package/packages/pi-tui/dist/components/__tests__/select-list.test.d.ts.map +1 -0
  680. package/packages/pi-tui/dist/components/__tests__/select-list.test.js +42 -0
  681. package/packages/pi-tui/dist/components/__tests__/select-list.test.js.map +1 -0
  682. package/packages/pi-tui/dist/components/__tests__/truncated-text.test.d.ts +2 -0
  683. package/packages/pi-tui/dist/components/__tests__/truncated-text.test.d.ts.map +1 -0
  684. package/packages/pi-tui/dist/components/__tests__/truncated-text.test.js +14 -0
  685. package/packages/pi-tui/dist/components/__tests__/truncated-text.test.js.map +1 -0
  686. package/packages/pi-tui/dist/components/box.d.ts +23 -0
  687. package/packages/pi-tui/dist/components/box.d.ts.map +1 -0
  688. package/packages/pi-tui/dist/components/box.js +111 -0
  689. package/packages/pi-tui/dist/components/box.js.map +1 -0
  690. package/packages/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
  691. package/packages/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  692. package/packages/pi-tui/dist/components/cancellable-loader.js +38 -0
  693. package/packages/pi-tui/dist/components/cancellable-loader.js.map +1 -0
  694. package/packages/pi-tui/dist/components/editor.d.ts +245 -0
  695. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -0
  696. package/packages/pi-tui/dist/components/editor.js +1825 -0
  697. package/packages/pi-tui/dist/components/editor.js.map +1 -0
  698. package/packages/pi-tui/dist/components/image.d.ts +37 -0
  699. package/packages/pi-tui/dist/components/image.d.ts.map +1 -0
  700. package/packages/pi-tui/dist/components/image.js +84 -0
  701. package/packages/pi-tui/dist/components/image.js.map +1 -0
  702. package/packages/pi-tui/dist/components/image.test.d.ts +6 -0
  703. package/packages/pi-tui/dist/components/image.test.d.ts.map +1 -0
  704. package/packages/pi-tui/dist/components/image.test.js +33 -0
  705. package/packages/pi-tui/dist/components/image.test.js.map +1 -0
  706. package/packages/pi-tui/dist/components/input.d.ts +42 -0
  707. package/packages/pi-tui/dist/components/input.d.ts.map +1 -0
  708. package/packages/pi-tui/dist/components/input.js +479 -0
  709. package/packages/pi-tui/dist/components/input.js.map +1 -0
  710. package/packages/pi-tui/dist/components/loader.d.ts +24 -0
  711. package/packages/pi-tui/dist/components/loader.d.ts.map +1 -0
  712. package/packages/pi-tui/dist/components/loader.js +74 -0
  713. package/packages/pi-tui/dist/components/loader.js.map +1 -0
  714. package/packages/pi-tui/dist/components/markdown.d.ts +106 -0
  715. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -0
  716. package/packages/pi-tui/dist/components/markdown.js +668 -0
  717. package/packages/pi-tui/dist/components/markdown.js.map +1 -0
  718. package/packages/pi-tui/dist/components/select-list.d.ts +32 -0
  719. package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -0
  720. package/packages/pi-tui/dist/components/select-list.js +155 -0
  721. package/packages/pi-tui/dist/components/select-list.js.map +1 -0
  722. package/packages/pi-tui/dist/components/settings-list.d.ts +50 -0
  723. package/packages/pi-tui/dist/components/settings-list.d.ts.map +1 -0
  724. package/packages/pi-tui/dist/components/settings-list.js +179 -0
  725. package/packages/pi-tui/dist/components/settings-list.js.map +1 -0
  726. package/packages/pi-tui/dist/components/spacer.d.ts +12 -0
  727. package/packages/pi-tui/dist/components/spacer.d.ts.map +1 -0
  728. package/packages/pi-tui/dist/components/spacer.js +22 -0
  729. package/packages/pi-tui/dist/components/spacer.js.map +1 -0
  730. package/packages/pi-tui/dist/components/text.d.ts +19 -0
  731. package/packages/pi-tui/dist/components/text.d.ts.map +1 -0
  732. package/packages/pi-tui/dist/components/text.js +83 -0
  733. package/packages/pi-tui/dist/components/text.js.map +1 -0
  734. package/packages/pi-tui/dist/components/truncated-text.d.ts +13 -0
  735. package/packages/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
  736. package/packages/pi-tui/dist/components/truncated-text.js +54 -0
  737. package/packages/pi-tui/dist/components/truncated-text.js.map +1 -0
  738. package/packages/pi-tui/dist/editor-component.d.ts +41 -0
  739. package/packages/pi-tui/dist/editor-component.d.ts.map +1 -0
  740. package/packages/pi-tui/dist/editor-component.js +2 -0
  741. package/packages/pi-tui/dist/editor-component.js.map +1 -0
  742. package/packages/pi-tui/dist/fuzzy.d.ts +16 -0
  743. package/packages/pi-tui/dist/fuzzy.d.ts.map +1 -0
  744. package/packages/pi-tui/dist/fuzzy.js +111 -0
  745. package/packages/pi-tui/dist/fuzzy.js.map +1 -0
  746. package/packages/pi-tui/dist/index.d.ts +24 -0
  747. package/packages/pi-tui/dist/index.d.ts.map +1 -0
  748. package/packages/pi-tui/dist/index.js +35 -0
  749. package/packages/pi-tui/dist/index.js.map +1 -0
  750. package/packages/pi-tui/dist/keybindings.d.ts +39 -0
  751. package/packages/pi-tui/dist/keybindings.d.ts.map +1 -0
  752. package/packages/pi-tui/dist/keybindings.js +116 -0
  753. package/packages/pi-tui/dist/keybindings.js.map +1 -0
  754. package/packages/pi-tui/dist/keys.d.ts +142 -0
  755. package/packages/pi-tui/dist/keys.d.ts.map +1 -0
  756. package/packages/pi-tui/dist/keys.js +994 -0
  757. package/packages/pi-tui/dist/keys.js.map +1 -0
  758. package/packages/pi-tui/dist/kill-ring.d.ts +28 -0
  759. package/packages/pi-tui/dist/kill-ring.d.ts.map +1 -0
  760. package/packages/pi-tui/dist/kill-ring.js +46 -0
  761. package/packages/pi-tui/dist/kill-ring.js.map +1 -0
  762. package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
  763. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
  764. package/packages/pi-tui/dist/overlay-layout.js +314 -0
  765. package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
  766. package/packages/pi-tui/dist/stdin-buffer.d.ts +55 -0
  767. package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
  768. package/packages/pi-tui/dist/stdin-buffer.js +342 -0
  769. package/packages/pi-tui/dist/stdin-buffer.js.map +1 -0
  770. package/packages/pi-tui/dist/style.d.ts +52 -0
  771. package/packages/pi-tui/dist/style.d.ts.map +1 -0
  772. package/packages/pi-tui/dist/style.js +219 -0
  773. package/packages/pi-tui/dist/style.js.map +1 -0
  774. package/packages/pi-tui/dist/terminal-image.d.ts +68 -0
  775. package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -0
  776. package/packages/pi-tui/dist/terminal-image.js +181 -0
  777. package/packages/pi-tui/dist/terminal-image.js.map +1 -0
  778. package/packages/pi-tui/dist/terminal.d.ts +89 -0
  779. package/packages/pi-tui/dist/terminal.d.ts.map +1 -0
  780. package/packages/pi-tui/dist/terminal.js +295 -0
  781. package/packages/pi-tui/dist/terminal.js.map +1 -0
  782. package/packages/pi-tui/dist/tui.d.ts +213 -0
  783. package/packages/pi-tui/dist/tui.d.ts.map +1 -0
  784. package/packages/pi-tui/dist/tui.js +978 -0
  785. package/packages/pi-tui/dist/tui.js.map +1 -0
  786. package/packages/pi-tui/dist/undo-stack.d.ts +17 -0
  787. package/packages/pi-tui/dist/undo-stack.d.ts.map +1 -0
  788. package/packages/pi-tui/dist/undo-stack.js +27 -0
  789. package/packages/pi-tui/dist/undo-stack.js.map +1 -0
  790. package/packages/pi-tui/dist/utils.d.ts +72 -0
  791. package/packages/pi-tui/dist/utils.d.ts.map +1 -0
  792. package/packages/pi-tui/dist/utils.js +120 -0
  793. package/packages/pi-tui/dist/utils.js.map +1 -0
  794. package/packages/pi-tui/package.json +35 -0
  795. package/packages/pi-tui/src/__tests__/autocomplete.test.ts +264 -0
  796. package/packages/pi-tui/src/__tests__/fuzzy.test.ts +120 -0
  797. package/packages/pi-tui/src/__tests__/keys.test.ts +21 -0
  798. package/packages/pi-tui/src/__tests__/loader.test.ts +30 -0
  799. package/packages/pi-tui/src/__tests__/overlay-layout.test.ts +266 -0
  800. package/packages/pi-tui/src/__tests__/stdin-buffer.test.ts +99 -0
  801. package/packages/pi-tui/src/__tests__/style.test.ts +156 -0
  802. package/packages/pi-tui/src/__tests__/terminal.test.ts +121 -0
  803. package/packages/pi-tui/src/__tests__/tui.test.ts +377 -0
  804. package/packages/pi-tui/src/__tests__/utils.test.ts +22 -0
  805. package/packages/pi-tui/src/autocomplete.ts +675 -0
  806. package/packages/pi-tui/src/components/__tests__/box.test.ts +25 -0
  807. package/packages/pi-tui/src/components/__tests__/cancellable-loader.test.ts +45 -0
  808. package/packages/pi-tui/src/components/__tests__/editor.test.ts +119 -0
  809. package/packages/pi-tui/src/components/__tests__/input.test.ts +111 -0
  810. package/packages/pi-tui/src/components/__tests__/leak-fixes-runtime.test.ts +219 -0
  811. package/packages/pi-tui/src/components/__tests__/loader.test.ts +122 -0
  812. package/packages/pi-tui/src/components/__tests__/markdown-list.test.ts +40 -0
  813. package/packages/pi-tui/src/components/__tests__/markdown-maxlines.test.ts +82 -0
  814. package/packages/pi-tui/src/components/__tests__/select-list.test.ts +70 -0
  815. package/packages/pi-tui/src/components/__tests__/truncated-text.test.ts +17 -0
  816. package/packages/pi-tui/src/components/box.ts +150 -0
  817. package/packages/pi-tui/src/components/cancellable-loader.ts +42 -0
  818. package/packages/pi-tui/src/components/editor.ts +2196 -0
  819. package/packages/pi-tui/src/components/image.test.ts +41 -0
  820. package/packages/pi-tui/src/components/image.ts +131 -0
  821. package/packages/pi-tui/src/components/input.ts +558 -0
  822. package/packages/pi-tui/src/components/loader.ts +83 -0
  823. package/packages/pi-tui/src/components/markdown.ts +842 -0
  824. package/packages/pi-tui/src/components/select-list.ts +194 -0
  825. package/packages/pi-tui/src/components/settings-list.ts +251 -0
  826. package/packages/pi-tui/src/components/spacer.ts +28 -0
  827. package/packages/pi-tui/src/components/text.ts +107 -0
  828. package/packages/pi-tui/src/components/truncated-text.ts +72 -0
  829. package/packages/pi-tui/src/editor-component.ts +77 -0
  830. package/packages/pi-tui/src/fuzzy.ts +138 -0
  831. package/packages/pi-tui/src/index.ts +98 -0
  832. package/packages/pi-tui/src/keybindings.ts +189 -0
  833. package/packages/pi-tui/src/keys.ts +1196 -0
  834. package/packages/pi-tui/src/kill-ring.ts +46 -0
  835. package/packages/pi-tui/src/overlay-layout.ts +408 -0
  836. package/packages/pi-tui/src/stdin-buffer.ts +419 -0
  837. package/packages/pi-tui/src/style.ts +295 -0
  838. package/packages/pi-tui/src/terminal-image.ts +260 -0
  839. package/packages/pi-tui/src/terminal.ts +377 -0
  840. package/packages/pi-tui/src/tui.ts +1182 -0
  841. package/packages/pi-tui/src/undo-stack.ts +28 -0
  842. package/packages/pi-tui/src/utils.ts +154 -0
  843. package/packages/pi-tui/tsconfig.json +28 -0
  844. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -0
  845. package/packages/rpc-client/README.md +132 -0
  846. package/packages/rpc-client/examples/basic-usage.ts +13 -0
  847. package/packages/rpc-client/package.json +42 -0
  848. package/packages/rpc-client/src/index.ts +10 -0
  849. package/packages/rpc-client/src/jsonl.ts +64 -0
  850. package/packages/rpc-client/src/rpc-client.test.ts +625 -0
  851. package/packages/rpc-client/src/rpc-client.ts +663 -0
  852. package/packages/rpc-client/src/rpc-types.ts +4 -0
  853. package/packages/rpc-client/tsconfig.examples.json +17 -0
  854. package/packages/rpc-client/tsconfig.json +25 -0
  855. package/pkg/dist/core/export-html/template.css +971 -0
  856. package/pkg/dist/core/export-html/template.html +54 -0
  857. package/pkg/dist/core/export-html/template.js +1583 -0
  858. package/pkg/dist/core/export-html/vendor/highlight.min.js +1213 -0
  859. package/pkg/dist/core/export-html/vendor/marked.min.js +6 -0
  860. package/pkg/package.json +8 -0
  861. package/scripts/ensure-workspace-builds.cjs +123 -0
  862. package/scripts/install.js +526 -0
  863. package/scripts/lib/workspace-manifest.cjs +86 -0
  864. package/scripts/link-workspace-packages.cjs +82 -0
  865. package/scripts/postinstall.js +11 -0
  866. package/src/resources/GSD-WORKFLOW.md +664 -0
  867. package/src/resources/agents/debugger.md +58 -0
  868. package/src/resources/agents/doc-writer.md +43 -0
  869. package/src/resources/agents/git-ops.md +56 -0
  870. package/src/resources/agents/javascript-pro.md +55 -0
  871. package/src/resources/agents/planner.md +55 -0
  872. package/src/resources/agents/refactorer.md +47 -0
  873. package/src/resources/agents/researcher.md +29 -0
  874. package/src/resources/agents/reviewer.md +48 -0
  875. package/src/resources/agents/scout.md +56 -0
  876. package/src/resources/agents/security.md +59 -0
  877. package/src/resources/agents/tester.md +50 -0
  878. package/src/resources/agents/typescript-pro.md +61 -0
  879. package/src/resources/agents/worker.md +31 -0
  880. package/src/resources/extensions/ask-user-questions.ts +478 -0
  881. package/src/resources/extensions/async-jobs/async-bash-timeout.test.ts +122 -0
  882. package/src/resources/extensions/async-jobs/async-bash-tool.ts +263 -0
  883. package/src/resources/extensions/async-jobs/await-tool.test.ts +200 -0
  884. package/src/resources/extensions/async-jobs/await-tool.ts +136 -0
  885. package/src/resources/extensions/async-jobs/cancel-job-tool.ts +35 -0
  886. package/src/resources/extensions/async-jobs/extension-manifest.json +13 -0
  887. package/src/resources/extensions/async-jobs/index.ts +153 -0
  888. package/src/resources/extensions/async-jobs/job-manager.ts +242 -0
  889. package/src/resources/extensions/aws-auth/index.ts +144 -0
  890. package/src/resources/extensions/bg-shell/bg-shell-command.ts +219 -0
  891. package/src/resources/extensions/bg-shell/bg-shell-lifecycle.ts +413 -0
  892. package/src/resources/extensions/bg-shell/bg-shell-tool.ts +985 -0
  893. package/src/resources/extensions/bg-shell/extension-manifest.json +14 -0
  894. package/src/resources/extensions/bg-shell/index.ts +54 -0
  895. package/src/resources/extensions/bg-shell/interaction.ts +200 -0
  896. package/src/resources/extensions/bg-shell/output-formatter.ts +262 -0
  897. package/src/resources/extensions/bg-shell/overlay.ts +441 -0
  898. package/src/resources/extensions/bg-shell/process-manager.ts +469 -0
  899. package/src/resources/extensions/bg-shell/readiness-detector.ts +126 -0
  900. package/src/resources/extensions/bg-shell/types.ts +291 -0
  901. package/src/resources/extensions/bg-shell/utilities.ts +93 -0
  902. package/src/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
  903. package/src/resources/extensions/browser-tools/capture.ts +229 -0
  904. package/src/resources/extensions/browser-tools/core.ts +1196 -0
  905. package/src/resources/extensions/browser-tools/evaluate-helpers.ts +184 -0
  906. package/src/resources/extensions/browser-tools/extension-manifest.json +37 -0
  907. package/src/resources/extensions/browser-tools/index.ts +163 -0
  908. package/src/resources/extensions/browser-tools/lifecycle.ts +270 -0
  909. package/src/resources/extensions/browser-tools/package.json +24 -0
  910. package/src/resources/extensions/browser-tools/refs.ts +264 -0
  911. package/src/resources/extensions/browser-tools/settle.ts +197 -0
  912. package/src/resources/extensions/browser-tools/state.ts +408 -0
  913. package/src/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +601 -0
  914. package/src/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +651 -0
  915. package/src/resources/extensions/browser-tools/tests/capture-sharp-optional.test.cjs +91 -0
  916. package/src/resources/extensions/browser-tools/tools/action-cache.ts +216 -0
  917. package/src/resources/extensions/browser-tools/tools/assertions.ts +342 -0
  918. package/src/resources/extensions/browser-tools/tools/codegen.ts +274 -0
  919. package/src/resources/extensions/browser-tools/tools/device.ts +183 -0
  920. package/src/resources/extensions/browser-tools/tools/extract.ts +229 -0
  921. package/src/resources/extensions/browser-tools/tools/forms.ts +805 -0
  922. package/src/resources/extensions/browser-tools/tools/injection-detect.ts +221 -0
  923. package/src/resources/extensions/browser-tools/tools/inspection.ts +492 -0
  924. package/src/resources/extensions/browser-tools/tools/intent.ts +629 -0
  925. package/src/resources/extensions/browser-tools/tools/interaction.ts +865 -0
  926. package/src/resources/extensions/browser-tools/tools/navigation.ts +232 -0
  927. package/src/resources/extensions/browser-tools/tools/network-mock.ts +244 -0
  928. package/src/resources/extensions/browser-tools/tools/pages.ts +303 -0
  929. package/src/resources/extensions/browser-tools/tools/pdf.ts +92 -0
  930. package/src/resources/extensions/browser-tools/tools/refs.ts +541 -0
  931. package/src/resources/extensions/browser-tools/tools/screenshot.ts +102 -0
  932. package/src/resources/extensions/browser-tools/tools/session.ts +400 -0
  933. package/src/resources/extensions/browser-tools/tools/state-persistence.ts +202 -0
  934. package/src/resources/extensions/browser-tools/tools/verify.ts +117 -0
  935. package/src/resources/extensions/browser-tools/tools/visual-diff.ts +209 -0
  936. package/src/resources/extensions/browser-tools/tools/wait.ts +247 -0
  937. package/src/resources/extensions/browser-tools/tools/zoom.ts +105 -0
  938. package/src/resources/extensions/browser-tools/utils.ts +660 -0
  939. package/src/resources/extensions/claude-code-cli/index.ts +28 -0
  940. package/src/resources/extensions/claude-code-cli/models.ts +51 -0
  941. package/src/resources/extensions/claude-code-cli/package.json +11 -0
  942. package/src/resources/extensions/claude-code-cli/partial-builder.ts +305 -0
  943. package/src/resources/extensions/claude-code-cli/readiness.ts +242 -0
  944. package/src/resources/extensions/claude-code-cli/sdk-types.ts +149 -0
  945. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +1981 -0
  946. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +256 -0
  947. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +2380 -0
  948. package/src/resources/extensions/cmux/index.ts +479 -0
  949. package/src/resources/extensions/cmux/package.json +7 -0
  950. package/src/resources/extensions/context7/extension-manifest.json +12 -0
  951. package/src/resources/extensions/context7/index.ts +435 -0
  952. package/src/resources/extensions/context7/package.json +11 -0
  953. package/src/resources/extensions/get-secrets-from-user.ts +608 -0
  954. package/src/resources/extensions/github-sync/cli.ts +367 -0
  955. package/src/resources/extensions/github-sync/index.ts +93 -0
  956. package/src/resources/extensions/github-sync/mapping.ts +81 -0
  957. package/src/resources/extensions/github-sync/sync.ts +594 -0
  958. package/src/resources/extensions/github-sync/templates.ts +339 -0
  959. package/src/resources/extensions/github-sync/tests/cli.test.ts +89 -0
  960. package/src/resources/extensions/github-sync/tests/commit-linking.test.ts +43 -0
  961. package/src/resources/extensions/github-sync/tests/inline-code.test.ts +66 -0
  962. package/src/resources/extensions/github-sync/tests/mapping.test.ts +104 -0
  963. package/src/resources/extensions/github-sync/tests/sync-source.test.ts +14 -0
  964. package/src/resources/extensions/github-sync/tests/templates.test.ts +209 -0
  965. package/src/resources/extensions/github-sync/types.ts +47 -0
  966. package/src/resources/extensions/google-search/extension-manifest.json +13 -0
  967. package/src/resources/extensions/google-search/index.ts +6 -0
  968. package/src/resources/extensions/google-search/package.json +9 -0
  969. package/src/resources/extensions/gsd/abandon-detect.ts +62 -0
  970. package/src/resources/extensions/gsd/activity-log.ts +184 -0
  971. package/src/resources/extensions/gsd/atomic-write.ts +185 -0
  972. package/src/resources/extensions/gsd/auto/contracts.ts +159 -0
  973. package/src/resources/extensions/gsd/auto/custom-verify-retry-store.ts +72 -0
  974. package/src/resources/extensions/gsd/auto/detect-stuck.ts +138 -0
  975. package/src/resources/extensions/gsd/auto/finalize-timeout.ts +49 -0
  976. package/src/resources/extensions/gsd/auto/infra-errors.ts +92 -0
  977. package/src/resources/extensions/gsd/auto/lease-conflict-notice.ts +62 -0
  978. package/src/resources/extensions/gsd/auto/loop-deps.ts +302 -0
  979. package/src/resources/extensions/gsd/auto/loop.ts +1448 -0
  980. package/src/resources/extensions/gsd/auto/orchestrator.ts +417 -0
  981. package/src/resources/extensions/gsd/auto/phases.ts +3014 -0
  982. package/src/resources/extensions/gsd/auto/resolve.ts +176 -0
  983. package/src/resources/extensions/gsd/auto/run-unit.ts +306 -0
  984. package/src/resources/extensions/gsd/auto/session.ts +427 -0
  985. package/src/resources/extensions/gsd/auto/turn-epoch.ts +108 -0
  986. package/src/resources/extensions/gsd/auto/types.ts +130 -0
  987. package/src/resources/extensions/gsd/auto/unit-runner-events.ts +19 -0
  988. package/src/resources/extensions/gsd/auto/verification-retry-policy.ts +82 -0
  989. package/src/resources/extensions/gsd/auto/workflow-custom-engine-dispatch-outcome.ts +28 -0
  990. package/src/resources/extensions/gsd/auto/workflow-custom-engine-iteration.ts +52 -0
  991. package/src/resources/extensions/gsd/auto/workflow-custom-engine-reconcile-outcome.ts +58 -0
  992. package/src/resources/extensions/gsd/auto/workflow-custom-engine-reconcile.ts +71 -0
  993. package/src/resources/extensions/gsd/auto/workflow-custom-engine-retry.ts +90 -0
  994. package/src/resources/extensions/gsd/auto/workflow-custom-engine-verify-outcome.ts +50 -0
  995. package/src/resources/extensions/gsd/auto/workflow-dispatch-claim.ts +179 -0
  996. package/src/resources/extensions/gsd/auto/workflow-dispatch-ledger.ts +45 -0
  997. package/src/resources/extensions/gsd/auto/workflow-iteration-completion.ts +26 -0
  998. package/src/resources/extensions/gsd/auto/workflow-journal-reporter.ts +33 -0
  999. package/src/resources/extensions/gsd/auto/workflow-kernel.ts +542 -0
  1000. package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +71 -0
  1001. package/src/resources/extensions/gsd/auto/workflow-phase-reporter.ts +22 -0
  1002. package/src/resources/extensions/gsd/auto/workflow-session-lock.ts +68 -0
  1003. package/src/resources/extensions/gsd/auto/workflow-sidecar-iteration.ts +46 -0
  1004. package/src/resources/extensions/gsd/auto/workflow-sidecar-queue.ts +46 -0
  1005. package/src/resources/extensions/gsd/auto/workflow-turn-reporter.ts +68 -0
  1006. package/src/resources/extensions/gsd/auto/workflow-unit-dispatch.ts +89 -0
  1007. package/src/resources/extensions/gsd/auto/workflow-worker-heartbeat.ts +51 -0
  1008. package/src/resources/extensions/gsd/auto-artifact-paths.ts +218 -0
  1009. package/src/resources/extensions/gsd/auto-budget.ts +57 -0
  1010. package/src/resources/extensions/gsd/auto-dashboard.ts +1239 -0
  1011. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +311 -0
  1012. package/src/resources/extensions/gsd/auto-dispatch.ts +1827 -0
  1013. package/src/resources/extensions/gsd/auto-model-selection.ts +755 -0
  1014. package/src/resources/extensions/gsd/auto-post-unit.ts +2375 -0
  1015. package/src/resources/extensions/gsd/auto-prompts.ts +4108 -0
  1016. package/src/resources/extensions/gsd/auto-recovery.ts +1217 -0
  1017. package/src/resources/extensions/gsd/auto-runtime-state.ts +63 -0
  1018. package/src/resources/extensions/gsd/auto-start.ts +1561 -0
  1019. package/src/resources/extensions/gsd/auto-status-message.ts +45 -0
  1020. package/src/resources/extensions/gsd/auto-supervisor.ts +86 -0
  1021. package/src/resources/extensions/gsd/auto-timeout-recovery.ts +308 -0
  1022. package/src/resources/extensions/gsd/auto-timers.ts +366 -0
  1023. package/src/resources/extensions/gsd/auto-tool-tracking.ts +156 -0
  1024. package/src/resources/extensions/gsd/auto-unit-closeout.ts +138 -0
  1025. package/src/resources/extensions/gsd/auto-utils.ts +25 -0
  1026. package/src/resources/extensions/gsd/auto-verification.ts +955 -0
  1027. package/src/resources/extensions/gsd/auto-worktree-repair.ts +194 -0
  1028. package/src/resources/extensions/gsd/auto-worktree.ts +2570 -0
  1029. package/src/resources/extensions/gsd/auto.ts +3167 -0
  1030. package/src/resources/extensions/gsd/blocked-models.ts +98 -0
  1031. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +685 -0
  1032. package/src/resources/extensions/gsd/bootstrap/crash-log.ts +32 -0
  1033. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +1408 -0
  1034. package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +144 -0
  1035. package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +123 -0
  1036. package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +67 -0
  1037. package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +166 -0
  1038. package/src/resources/extensions/gsd/bootstrap/notify-interceptor.ts +34 -0
  1039. package/src/resources/extensions/gsd/bootstrap/provider-error-resume.ts +61 -0
  1040. package/src/resources/extensions/gsd/bootstrap/query-tools.ts +68 -0
  1041. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +154 -0
  1042. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +1203 -0
  1043. package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +101 -0
  1044. package/src/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.ts +61 -0
  1045. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +32 -0
  1046. package/src/resources/extensions/gsd/bootstrap/system-context.ts +770 -0
  1047. package/src/resources/extensions/gsd/bootstrap/tests/write-gate-basepath.test.ts +103 -0
  1048. package/src/resources/extensions/gsd/bootstrap/tests/write-gate-shouldblock-basepath.test.ts +97 -0
  1049. package/src/resources/extensions/gsd/bootstrap/tool-call-loop-guard.ts +103 -0
  1050. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +1059 -0
  1051. package/src/resources/extensions/gsd/branch-patterns.ts +16 -0
  1052. package/src/resources/extensions/gsd/browser-evidence.ts +29 -0
  1053. package/src/resources/extensions/gsd/cache.ts +40 -0
  1054. package/src/resources/extensions/gsd/captures.ts +571 -0
  1055. package/src/resources/extensions/gsd/changelog.ts +213 -0
  1056. package/src/resources/extensions/gsd/claude-import.ts +705 -0
  1057. package/src/resources/extensions/gsd/clean-root-preflight.ts +564 -0
  1058. package/src/resources/extensions/gsd/closeout-recovery.ts +290 -0
  1059. package/src/resources/extensions/gsd/codebase-generator.ts +616 -0
  1060. package/src/resources/extensions/gsd/collision-diagnostics.ts +332 -0
  1061. package/src/resources/extensions/gsd/commands/catalog.ts +577 -0
  1062. package/src/resources/extensions/gsd/commands/context.ts +159 -0
  1063. package/src/resources/extensions/gsd/commands/dispatcher.ts +101 -0
  1064. package/src/resources/extensions/gsd/commands/handlers/auto.ts +179 -0
  1065. package/src/resources/extensions/gsd/commands/handlers/core.ts +597 -0
  1066. package/src/resources/extensions/gsd/commands/handlers/escalate.ts +216 -0
  1067. package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +144 -0
  1068. package/src/resources/extensions/gsd/commands/handlers/onboarding.ts +196 -0
  1069. package/src/resources/extensions/gsd/commands/handlers/ops.ts +359 -0
  1070. package/src/resources/extensions/gsd/commands/handlers/parallel.ts +147 -0
  1071. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +691 -0
  1072. package/src/resources/extensions/gsd/commands/index.ts +20 -0
  1073. package/src/resources/extensions/gsd/commands-add-tests.ts +137 -0
  1074. package/src/resources/extensions/gsd/commands-backlog.ts +182 -0
  1075. package/src/resources/extensions/gsd/commands-bootstrap.ts +280 -0
  1076. package/src/resources/extensions/gsd/commands-closeout.ts +109 -0
  1077. package/src/resources/extensions/gsd/commands-cmux.ts +182 -0
  1078. package/src/resources/extensions/gsd/commands-codebase.ts +198 -0
  1079. package/src/resources/extensions/gsd/commands-config.ts +119 -0
  1080. package/src/resources/extensions/gsd/commands-debug.ts +510 -0
  1081. package/src/resources/extensions/gsd/commands-do.ts +110 -0
  1082. package/src/resources/extensions/gsd/commands-eval-review.ts +716 -0
  1083. package/src/resources/extensions/gsd/commands-extensions.ts +1088 -0
  1084. package/src/resources/extensions/gsd/commands-extract-learnings.ts +493 -0
  1085. package/src/resources/extensions/gsd/commands-handlers.ts +510 -0
  1086. package/src/resources/extensions/gsd/commands-inspect.ts +99 -0
  1087. package/src/resources/extensions/gsd/commands-logs.ts +537 -0
  1088. package/src/resources/extensions/gsd/commands-maintenance.ts +544 -0
  1089. package/src/resources/extensions/gsd/commands-mcp-status.ts +402 -0
  1090. package/src/resources/extensions/gsd/commands-memory.ts +551 -0
  1091. package/src/resources/extensions/gsd/commands-pr-branch.ts +234 -0
  1092. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1848 -0
  1093. package/src/resources/extensions/gsd/commands-rate.ts +55 -0
  1094. package/src/resources/extensions/gsd/commands-scan.ts +126 -0
  1095. package/src/resources/extensions/gsd/commands-session-report.ts +101 -0
  1096. package/src/resources/extensions/gsd/commands-ship.ts +292 -0
  1097. package/src/resources/extensions/gsd/commands-verdict.ts +229 -0
  1098. package/src/resources/extensions/gsd/commands-workflow-templates.ts +684 -0
  1099. package/src/resources/extensions/gsd/commands-worktree.ts +383 -0
  1100. package/src/resources/extensions/gsd/commands.ts +17 -0
  1101. package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
  1102. package/src/resources/extensions/gsd/complexity-classifier.ts +331 -0
  1103. package/src/resources/extensions/gsd/component-loader.ts +592 -0
  1104. package/src/resources/extensions/gsd/component-types.ts +362 -0
  1105. package/src/resources/extensions/gsd/config-overlay.ts +331 -0
  1106. package/src/resources/extensions/gsd/constants.ts +69 -0
  1107. package/src/resources/extensions/gsd/context-budget.ts +309 -0
  1108. package/src/resources/extensions/gsd/context-injector.ts +100 -0
  1109. package/src/resources/extensions/gsd/context-masker.ts +74 -0
  1110. package/src/resources/extensions/gsd/context-store.ts +497 -0
  1111. package/src/resources/extensions/gsd/crash-recovery.ts +427 -0
  1112. package/src/resources/extensions/gsd/custom-execution-policy.ts +74 -0
  1113. package/src/resources/extensions/gsd/custom-verification.ts +183 -0
  1114. package/src/resources/extensions/gsd/custom-workflow-engine.ts +274 -0
  1115. package/src/resources/extensions/gsd/dashboard-overlay.ts +684 -0
  1116. package/src/resources/extensions/gsd/db/auto-workers.ts +310 -0
  1117. package/src/resources/extensions/gsd/db/command-queue.ts +149 -0
  1118. package/src/resources/extensions/gsd/db/milestone-leases.ts +300 -0
  1119. package/src/resources/extensions/gsd/db/runtime-kv.ts +127 -0
  1120. package/src/resources/extensions/gsd/db/unit-dispatches.ts +554 -0
  1121. package/src/resources/extensions/gsd/db-adapter.ts +75 -0
  1122. package/src/resources/extensions/gsd/db-base-schema.ts +387 -0
  1123. package/src/resources/extensions/gsd/db-connection-cache.ts +45 -0
  1124. package/src/resources/extensions/gsd/db-coordination-schema.ts +109 -0
  1125. package/src/resources/extensions/gsd/db-decision-requirement-rows.ts +77 -0
  1126. package/src/resources/extensions/gsd/db-gate-rows.ts +19 -0
  1127. package/src/resources/extensions/gsd/db-lightweight-query-rows.ts +50 -0
  1128. package/src/resources/extensions/gsd/db-memory-fts-schema.ts +66 -0
  1129. package/src/resources/extensions/gsd/db-migration-backup.ts +34 -0
  1130. package/src/resources/extensions/gsd/db-migration-steps.ts +464 -0
  1131. package/src/resources/extensions/gsd/db-milestone-artifact-rows.ts +70 -0
  1132. package/src/resources/extensions/gsd/db-open-state.ts +47 -0
  1133. package/src/resources/extensions/gsd/db-provider.ts +148 -0
  1134. package/src/resources/extensions/gsd/db-runtime-kv-schema.ts +30 -0
  1135. package/src/resources/extensions/gsd/db-schema-metadata.ts +33 -0
  1136. package/src/resources/extensions/gsd/db-task-slice-rows.ts +150 -0
  1137. package/src/resources/extensions/gsd/db-transaction.ts +76 -0
  1138. package/src/resources/extensions/gsd/db-verification-evidence-rows.ts +14 -0
  1139. package/src/resources/extensions/gsd/db-verification-evidence-schema.ts +22 -0
  1140. package/src/resources/extensions/gsd/db-writer.ts +966 -0
  1141. package/src/resources/extensions/gsd/debug-logger.ts +178 -0
  1142. package/src/resources/extensions/gsd/debug-session-store.ts +377 -0
  1143. package/src/resources/extensions/gsd/deep-project-setup-policy.ts +257 -0
  1144. package/src/resources/extensions/gsd/definition-io.ts +18 -0
  1145. package/src/resources/extensions/gsd/definition-loader.ts +469 -0
  1146. package/src/resources/extensions/gsd/delegation-policy.ts +197 -0
  1147. package/src/resources/extensions/gsd/detection.ts +1339 -0
  1148. package/src/resources/extensions/gsd/dev-execution-policy.ts +51 -0
  1149. package/src/resources/extensions/gsd/dev-workflow-engine.ts +110 -0
  1150. package/src/resources/extensions/gsd/diff-context.ts +214 -0
  1151. package/src/resources/extensions/gsd/dispatch-guard.ts +211 -0
  1152. package/src/resources/extensions/gsd/docs/COORDINATION.md +42 -0
  1153. package/src/resources/extensions/gsd/docs/claude-marketplace-import.md +214 -0
  1154. package/src/resources/extensions/gsd/docs/preferences-reference.md +755 -0
  1155. package/src/resources/extensions/gsd/doctor-checks.ts +5 -0
  1156. package/src/resources/extensions/gsd/doctor-engine-checks.ts +196 -0
  1157. package/src/resources/extensions/gsd/doctor-environment.ts +643 -0
  1158. package/src/resources/extensions/gsd/doctor-format.ts +99 -0
  1159. package/src/resources/extensions/gsd/doctor-git-checks.ts +622 -0
  1160. package/src/resources/extensions/gsd/doctor-global-checks.ts +84 -0
  1161. package/src/resources/extensions/gsd/doctor-proactive.ts +488 -0
  1162. package/src/resources/extensions/gsd/doctor-providers.ts +523 -0
  1163. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +793 -0
  1164. package/src/resources/extensions/gsd/doctor-types.ts +134 -0
  1165. package/src/resources/extensions/gsd/doctor.ts +802 -0
  1166. package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +233 -0
  1167. package/src/resources/extensions/gsd/ecosystem/loader.ts +201 -0
  1168. package/src/resources/extensions/gsd/engine-resolver.ts +57 -0
  1169. package/src/resources/extensions/gsd/engine-types.ts +71 -0
  1170. package/src/resources/extensions/gsd/env-utils.ts +31 -0
  1171. package/src/resources/extensions/gsd/error-classifier.ts +188 -0
  1172. package/src/resources/extensions/gsd/error-utils.ts +6 -0
  1173. package/src/resources/extensions/gsd/errors.ts +29 -0
  1174. package/src/resources/extensions/gsd/escalation.ts +369 -0
  1175. package/src/resources/extensions/gsd/eval-review-schema.ts +243 -0
  1176. package/src/resources/extensions/gsd/exec-history.ts +153 -0
  1177. package/src/resources/extensions/gsd/exec-sandbox.ts +333 -0
  1178. package/src/resources/extensions/gsd/execution-policy.ts +43 -0
  1179. package/src/resources/extensions/gsd/exit-command.ts +30 -0
  1180. package/src/resources/extensions/gsd/export-html.ts +1008 -0
  1181. package/src/resources/extensions/gsd/export.ts +318 -0
  1182. package/src/resources/extensions/gsd/extension-manifest.json +33 -0
  1183. package/src/resources/extensions/gsd/file-lock.ts +132 -0
  1184. package/src/resources/extensions/gsd/files.ts +1009 -0
  1185. package/src/resources/extensions/gsd/forensics.ts +1342 -0
  1186. package/src/resources/extensions/gsd/fresh-run-ui.ts +43 -0
  1187. package/src/resources/extensions/gsd/gate-registry.ts +251 -0
  1188. package/src/resources/extensions/gsd/git-conflict-state.ts +23 -0
  1189. package/src/resources/extensions/gsd/git-constants.ts +41 -0
  1190. package/src/resources/extensions/gsd/git-self-heal.ts +158 -0
  1191. package/src/resources/extensions/gsd/git-service.ts +1412 -0
  1192. package/src/resources/extensions/gsd/gitignore.ts +336 -0
  1193. package/src/resources/extensions/gsd/graph-context.ts +212 -0
  1194. package/src/resources/extensions/gsd/graph.ts +349 -0
  1195. package/src/resources/extensions/gsd/gsd-command-home.ts +209 -0
  1196. package/src/resources/extensions/gsd/gsd-db.ts +3190 -0
  1197. package/src/resources/extensions/gsd/gsd-home.ts +30 -0
  1198. package/src/resources/extensions/gsd/guided-flow-queue.ts +443 -0
  1199. package/src/resources/extensions/gsd/guided-flow.ts +2887 -0
  1200. package/src/resources/extensions/gsd/guided-unit-context.ts +30 -0
  1201. package/src/resources/extensions/gsd/health-widget-core.ts +140 -0
  1202. package/src/resources/extensions/gsd/health-widget.ts +148 -0
  1203. package/src/resources/extensions/gsd/history.ts +144 -0
  1204. package/src/resources/extensions/gsd/hook-emitter.ts +188 -0
  1205. package/src/resources/extensions/gsd/index.ts +37 -0
  1206. package/src/resources/extensions/gsd/init-wizard.ts +704 -0
  1207. package/src/resources/extensions/gsd/interrupted-session.ts +269 -0
  1208. package/src/resources/extensions/gsd/journal.ts +218 -0
  1209. package/src/resources/extensions/gsd/json-persistence.ts +78 -0
  1210. package/src/resources/extensions/gsd/jsonl-utils.ts +21 -0
  1211. package/src/resources/extensions/gsd/key-manager.ts +1018 -0
  1212. package/src/resources/extensions/gsd/knowledge-backfill.ts +164 -0
  1213. package/src/resources/extensions/gsd/knowledge-capture.ts +160 -0
  1214. package/src/resources/extensions/gsd/knowledge-parser.ts +174 -0
  1215. package/src/resources/extensions/gsd/knowledge-projection.ts +241 -0
  1216. package/src/resources/extensions/gsd/legacy-telemetry.ts +99 -0
  1217. package/src/resources/extensions/gsd/markdown-renderer.ts +982 -0
  1218. package/src/resources/extensions/gsd/marketplace-discovery.ts +508 -0
  1219. package/src/resources/extensions/gsd/mcp-filter.ts +80 -0
  1220. package/src/resources/extensions/gsd/mcp-project-config.ts +128 -0
  1221. package/src/resources/extensions/gsd/md-importer.ts +748 -0
  1222. package/src/resources/extensions/gsd/memory-backfill.ts +212 -0
  1223. package/src/resources/extensions/gsd/memory-consolidation-scanner.ts +277 -0
  1224. package/src/resources/extensions/gsd/memory-embeddings.ts +235 -0
  1225. package/src/resources/extensions/gsd/memory-extractor.ts +434 -0
  1226. package/src/resources/extensions/gsd/memory-ingest.ts +286 -0
  1227. package/src/resources/extensions/gsd/memory-relations.ts +240 -0
  1228. package/src/resources/extensions/gsd/memory-source-store.ts +138 -0
  1229. package/src/resources/extensions/gsd/memory-store.ts +909 -0
  1230. package/src/resources/extensions/gsd/metrics.ts +1040 -0
  1231. package/src/resources/extensions/gsd/migrate/audit.ts +219 -0
  1232. package/src/resources/extensions/gsd/migrate/command.ts +341 -0
  1233. package/src/resources/extensions/gsd/migrate/index.ts +44 -0
  1234. package/src/resources/extensions/gsd/migrate/parser.ts +323 -0
  1235. package/src/resources/extensions/gsd/migrate/parsers.ts +676 -0
  1236. package/src/resources/extensions/gsd/migrate/preview.ts +58 -0
  1237. package/src/resources/extensions/gsd/migrate/safety.ts +149 -0
  1238. package/src/resources/extensions/gsd/migrate/transformer.ts +411 -0
  1239. package/src/resources/extensions/gsd/migrate/types.ts +370 -0
  1240. package/src/resources/extensions/gsd/migrate/validator.ts +55 -0
  1241. package/src/resources/extensions/gsd/migrate/writer.ts +592 -0
  1242. package/src/resources/extensions/gsd/migrate-external.ts +215 -0
  1243. package/src/resources/extensions/gsd/migration-auto-check.ts +121 -0
  1244. package/src/resources/extensions/gsd/milestone-actions.ts +193 -0
  1245. package/src/resources/extensions/gsd/milestone-id-reservation.ts +47 -0
  1246. package/src/resources/extensions/gsd/milestone-id-utils.ts +32 -0
  1247. package/src/resources/extensions/gsd/milestone-ids.ts +136 -0
  1248. package/src/resources/extensions/gsd/milestone-scope-classifier.ts +373 -0
  1249. package/src/resources/extensions/gsd/milestone-summary-classifier.ts +42 -0
  1250. package/src/resources/extensions/gsd/milestone-validation-gates.ts +53 -0
  1251. package/src/resources/extensions/gsd/model-cost-table.ts +89 -0
  1252. package/src/resources/extensions/gsd/model-router.ts +844 -0
  1253. package/src/resources/extensions/gsd/namespaced-registry.ts +467 -0
  1254. package/src/resources/extensions/gsd/namespaced-resolver.ts +307 -0
  1255. package/src/resources/extensions/gsd/native-git-bridge.ts +1447 -0
  1256. package/src/resources/extensions/gsd/native-parser-bridge.ts +267 -0
  1257. package/src/resources/extensions/gsd/notification-overlay.ts +322 -0
  1258. package/src/resources/extensions/gsd/notification-store.ts +342 -0
  1259. package/src/resources/extensions/gsd/notification-widget.ts +69 -0
  1260. package/src/resources/extensions/gsd/notifications.ts +153 -0
  1261. package/src/resources/extensions/gsd/observability-validator.ts +456 -0
  1262. package/src/resources/extensions/gsd/onboarding-state.ts +146 -0
  1263. package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
  1264. package/src/resources/extensions/gsd/package.json +11 -0
  1265. package/src/resources/extensions/gsd/parallel-eligibility.ts +248 -0
  1266. package/src/resources/extensions/gsd/parallel-merge.ts +270 -0
  1267. package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +507 -0
  1268. package/src/resources/extensions/gsd/parallel-orchestrator.ts +1077 -0
  1269. package/src/resources/extensions/gsd/parsers-legacy.ts +292 -0
  1270. package/src/resources/extensions/gsd/paths.ts +722 -0
  1271. package/src/resources/extensions/gsd/pending-auto-start.ts +81 -0
  1272. package/src/resources/extensions/gsd/phase-anchor.ts +71 -0
  1273. package/src/resources/extensions/gsd/planning-depth.ts +137 -0
  1274. package/src/resources/extensions/gsd/planning-path-scope.ts +45 -0
  1275. package/src/resources/extensions/gsd/plugin-importer.ts +411 -0
  1276. package/src/resources/extensions/gsd/post-execution-checks.ts +665 -0
  1277. package/src/resources/extensions/gsd/post-unit-hooks.ts +86 -0
  1278. package/src/resources/extensions/gsd/pr-evidence.ts +182 -0
  1279. package/src/resources/extensions/gsd/pre-execution-checks.ts +890 -0
  1280. package/src/resources/extensions/gsd/preferences-mcp.ts +27 -0
  1281. package/src/resources/extensions/gsd/preferences-models.ts +572 -0
  1282. package/src/resources/extensions/gsd/preferences-skills.ts +147 -0
  1283. package/src/resources/extensions/gsd/preferences-types.ts +579 -0
  1284. package/src/resources/extensions/gsd/preferences-validation.ts +1453 -0
  1285. package/src/resources/extensions/gsd/preferences.ts +697 -0
  1286. package/src/resources/extensions/gsd/preparation.ts +1419 -0
  1287. package/src/resources/extensions/gsd/process-task-path.ts +81 -0
  1288. package/src/resources/extensions/gsd/progress-score.ts +161 -0
  1289. package/src/resources/extensions/gsd/project-research-policy.ts +259 -0
  1290. package/src/resources/extensions/gsd/prompt-cache-optimizer.ts +217 -0
  1291. package/src/resources/extensions/gsd/prompt-loader.ts +248 -0
  1292. package/src/resources/extensions/gsd/prompt-ordering.ts +200 -0
  1293. package/src/resources/extensions/gsd/prompt-validation.ts +157 -0
  1294. package/src/resources/extensions/gsd/prompts/add-tests.md +36 -0
  1295. package/src/resources/extensions/gsd/prompts/complete-milestone.md +91 -0
  1296. package/src/resources/extensions/gsd/prompts/complete-slice.md +49 -0
  1297. package/src/resources/extensions/gsd/prompts/debug-diagnose.md +27 -0
  1298. package/src/resources/extensions/gsd/prompts/debug-session-manager.md +80 -0
  1299. package/src/resources/extensions/gsd/prompts/discuss-headless.md +252 -0
  1300. package/src/resources/extensions/gsd/prompts/discuss.md +368 -0
  1301. package/src/resources/extensions/gsd/prompts/doctor-heal.md +31 -0
  1302. package/src/resources/extensions/gsd/prompts/execute-task.md +73 -0
  1303. package/src/resources/extensions/gsd/prompts/forensics.md +155 -0
  1304. package/src/resources/extensions/gsd/prompts/gate-evaluate.md +32 -0
  1305. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +116 -0
  1306. package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +113 -0
  1307. package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +99 -0
  1308. package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +74 -0
  1309. package/src/resources/extensions/gsd/prompts/guided-research-decision.md +70 -0
  1310. package/src/resources/extensions/gsd/prompts/guided-research-project.md +102 -0
  1311. package/src/resources/extensions/gsd/prompts/guided-research-slice.md +15 -0
  1312. package/src/resources/extensions/gsd/prompts/guided-resume-task.md +1 -0
  1313. package/src/resources/extensions/gsd/prompts/guided-workflow-preferences.md +68 -0
  1314. package/src/resources/extensions/gsd/prompts/heal-skill.md +45 -0
  1315. package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +28 -0
  1316. package/src/resources/extensions/gsd/prompts/plan-milestone.md +114 -0
  1317. package/src/resources/extensions/gsd/prompts/plan-slice.md +55 -0
  1318. package/src/resources/extensions/gsd/prompts/queue.md +128 -0
  1319. package/src/resources/extensions/gsd/prompts/quick-task.md +40 -0
  1320. package/src/resources/extensions/gsd/prompts/reactive-execute.md +44 -0
  1321. package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +68 -0
  1322. package/src/resources/extensions/gsd/prompts/refine-slice.md +79 -0
  1323. package/src/resources/extensions/gsd/prompts/replan-slice.md +39 -0
  1324. package/src/resources/extensions/gsd/prompts/research-milestone.md +47 -0
  1325. package/src/resources/extensions/gsd/prompts/research-slice.md +58 -0
  1326. package/src/resources/extensions/gsd/prompts/rethink.md +95 -0
  1327. package/src/resources/extensions/gsd/prompts/review-migration.md +66 -0
  1328. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +33 -0
  1329. package/src/resources/extensions/gsd/prompts/run-uat.md +89 -0
  1330. package/src/resources/extensions/gsd/prompts/scan.md +79 -0
  1331. package/src/resources/extensions/gsd/prompts/system.md +180 -0
  1332. package/src/resources/extensions/gsd/prompts/triage-captures.md +68 -0
  1333. package/src/resources/extensions/gsd/prompts/validate-milestone.md +88 -0
  1334. package/src/resources/extensions/gsd/prompts/workflow-oneshot.md +26 -0
  1335. package/src/resources/extensions/gsd/prompts/workflow-start.md +28 -0
  1336. package/src/resources/extensions/gsd/prompts/worktree-merge.md +125 -0
  1337. package/src/resources/extensions/gsd/provider-error-pause.ts +49 -0
  1338. package/src/resources/extensions/gsd/provider-switch-observer.ts +185 -0
  1339. package/src/resources/extensions/gsd/python-resolver.ts +76 -0
  1340. package/src/resources/extensions/gsd/queue-order.ts +235 -0
  1341. package/src/resources/extensions/gsd/queue-reorder-ui.ts +295 -0
  1342. package/src/resources/extensions/gsd/quick.ts +297 -0
  1343. package/src/resources/extensions/gsd/reactive-graph.ts +337 -0
  1344. package/src/resources/extensions/gsd/recovery-classification.ts +139 -0
  1345. package/src/resources/extensions/gsd/repo-identity.ts +683 -0
  1346. package/src/resources/extensions/gsd/reports.ts +505 -0
  1347. package/src/resources/extensions/gsd/repository-registry.ts +108 -0
  1348. package/src/resources/extensions/gsd/rethink.ts +164 -0
  1349. package/src/resources/extensions/gsd/roadmap-mutations.ts +134 -0
  1350. package/src/resources/extensions/gsd/roadmap-slices.ts +294 -0
  1351. package/src/resources/extensions/gsd/root-write-leak-guard.ts +101 -0
  1352. package/src/resources/extensions/gsd/routing-history.ts +286 -0
  1353. package/src/resources/extensions/gsd/rule-registry.ts +599 -0
  1354. package/src/resources/extensions/gsd/rule-types.ts +68 -0
  1355. package/src/resources/extensions/gsd/run-manager.ts +214 -0
  1356. package/src/resources/extensions/gsd/safe-fs.ts +48 -0
  1357. package/src/resources/extensions/gsd/safety/content-validator.ts +98 -0
  1358. package/src/resources/extensions/gsd/safety/destructive-guard.ts +49 -0
  1359. package/src/resources/extensions/gsd/safety/evidence-collector.ts +265 -0
  1360. package/src/resources/extensions/gsd/safety/evidence-cross-ref.ts +155 -0
  1361. package/src/resources/extensions/gsd/safety/file-change-validator.ts +124 -0
  1362. package/src/resources/extensions/gsd/safety/git-checkpoint.ts +130 -0
  1363. package/src/resources/extensions/gsd/safety/safety-harness.ts +114 -0
  1364. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-project.md +26 -0
  1365. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-requirements.md +57 -0
  1366. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-roadmap.md +19 -0
  1367. package/src/resources/extensions/gsd/schemas/parsers.ts +346 -0
  1368. package/src/resources/extensions/gsd/schemas/validate.ts +452 -0
  1369. package/src/resources/extensions/gsd/service-tier.ts +199 -0
  1370. package/src/resources/extensions/gsd/session-forensics.ts +580 -0
  1371. package/src/resources/extensions/gsd/session-lock.ts +732 -0
  1372. package/src/resources/extensions/gsd/session-model-override.ts +36 -0
  1373. package/src/resources/extensions/gsd/session-status-io.ts +179 -0
  1374. package/src/resources/extensions/gsd/setup-catalog.ts +105 -0
  1375. package/src/resources/extensions/gsd/shortcut-defs.ts +56 -0
  1376. package/src/resources/extensions/gsd/skill-catalog.ts +1088 -0
  1377. package/src/resources/extensions/gsd/skill-discovery.ts +157 -0
  1378. package/src/resources/extensions/gsd/skill-health.ts +422 -0
  1379. package/src/resources/extensions/gsd/skill-manifest.ts +175 -0
  1380. package/src/resources/extensions/gsd/skill-telemetry.ts +141 -0
  1381. package/src/resources/extensions/gsd/skills/gsd-headless/SKILL.md +242 -0
  1382. package/src/resources/extensions/gsd/skills/gsd-headless/references/answer-injection.md +83 -0
  1383. package/src/resources/extensions/gsd/skills/gsd-headless/references/commands.md +64 -0
  1384. package/src/resources/extensions/gsd/skills/gsd-headless/references/multi-session.md +176 -0
  1385. package/src/resources/extensions/gsd/slice-cadence.ts +411 -0
  1386. package/src/resources/extensions/gsd/slice-parallel-conflict.ts +86 -0
  1387. package/src/resources/extensions/gsd/slice-parallel-eligibility.ts +73 -0
  1388. package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +913 -0
  1389. package/src/resources/extensions/gsd/smart-entry-routing.ts +77 -0
  1390. package/src/resources/extensions/gsd/state-reconciliation/drift/completion.ts +172 -0
  1391. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +417 -0
  1392. package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +66 -0
  1393. package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +101 -0
  1394. package/src/resources/extensions/gsd/state-reconciliation/drift/sketch-flag.ts +68 -0
  1395. package/src/resources/extensions/gsd/state-reconciliation/drift/stale-render.ts +185 -0
  1396. package/src/resources/extensions/gsd/state-reconciliation/drift/stale-worker.ts +46 -0
  1397. package/src/resources/extensions/gsd/state-reconciliation/errors.ts +67 -0
  1398. package/src/resources/extensions/gsd/state-reconciliation/index.ts +142 -0
  1399. package/src/resources/extensions/gsd/state-reconciliation/registry.ts +27 -0
  1400. package/src/resources/extensions/gsd/state-reconciliation/spawn-gate.ts +65 -0
  1401. package/src/resources/extensions/gsd/state-reconciliation/types.ts +83 -0
  1402. package/src/resources/extensions/gsd/state-reconciliation.ts +25 -0
  1403. package/src/resources/extensions/gsd/state-transition-matrix.ts +152 -0
  1404. package/src/resources/extensions/gsd/state.ts +1730 -0
  1405. package/src/resources/extensions/gsd/status-guards.ts +41 -0
  1406. package/src/resources/extensions/gsd/structured-data-formatter.ts +146 -0
  1407. package/src/resources/extensions/gsd/sync-lock.ts +152 -0
  1408. package/src/resources/extensions/gsd/templates/PREFERENCES.md +101 -0
  1409. package/src/resources/extensions/gsd/templates/context.md +108 -0
  1410. package/src/resources/extensions/gsd/templates/decisions.md +8 -0
  1411. package/src/resources/extensions/gsd/templates/knowledge.md +19 -0
  1412. package/src/resources/extensions/gsd/templates/milestone-summary.md +81 -0
  1413. package/src/resources/extensions/gsd/templates/milestone-validation.md +74 -0
  1414. package/src/resources/extensions/gsd/templates/plan.md +152 -0
  1415. package/src/resources/extensions/gsd/templates/project.md +41 -0
  1416. package/src/resources/extensions/gsd/templates/reassessment.md +29 -0
  1417. package/src/resources/extensions/gsd/templates/requirements.md +81 -0
  1418. package/src/resources/extensions/gsd/templates/research.md +79 -0
  1419. package/src/resources/extensions/gsd/templates/roadmap.md +131 -0
  1420. package/src/resources/extensions/gsd/templates/runtime.md +21 -0
  1421. package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
  1422. package/src/resources/extensions/gsd/templates/slice-context.md +58 -0
  1423. package/src/resources/extensions/gsd/templates/slice-summary.md +108 -0
  1424. package/src/resources/extensions/gsd/templates/state.md +17 -0
  1425. package/src/resources/extensions/gsd/templates/task-plan.md +95 -0
  1426. package/src/resources/extensions/gsd/templates/task-summary.md +66 -0
  1427. package/src/resources/extensions/gsd/templates/uat.md +54 -0
  1428. package/src/resources/extensions/gsd/tests/active-milestone-id-guard.test.ts +91 -0
  1429. package/src/resources/extensions/gsd/tests/activity-log.test.ts +175 -0
  1430. package/src/resources/extensions/gsd/tests/agent-end-retry.test.ts +80 -0
  1431. package/src/resources/extensions/gsd/tests/artifact-corruption-2630.test.ts +296 -0
  1432. package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +145 -0
  1433. package/src/resources/extensions/gsd/tests/artifact-validators.test.ts +524 -0
  1434. package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +143 -0
  1435. package/src/resources/extensions/gsd/tests/ask-user-questions-dedup.test.ts +120 -0
  1436. package/src/resources/extensions/gsd/tests/atomic-write.test.ts +144 -0
  1437. package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +47 -0
  1438. package/src/resources/extensions/gsd/tests/auto-blocked-remediation-message.test.ts +89 -0
  1439. package/src/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +62 -0
  1440. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +807 -0
  1441. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +457 -0
  1442. package/src/resources/extensions/gsd/tests/auto-discuss-milestone-deadlock-4973.test.ts +289 -0
  1443. package/src/resources/extensions/gsd/tests/auto-loop-no-copy-artifacts.test.ts +72 -0
  1444. package/src/resources/extensions/gsd/tests/auto-loop-symlink-worktree.test.ts +190 -0
  1445. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +5503 -0
  1446. package/src/resources/extensions/gsd/tests/auto-migrating-recovery.test.ts +63 -0
  1447. package/src/resources/extensions/gsd/tests/auto-milestone-target.test.ts +61 -0
  1448. package/src/resources/extensions/gsd/tests/auto-mode-guards.test.ts +79 -0
  1449. package/src/resources/extensions/gsd/tests/auto-mode-interactive-guard.test.ts +71 -0
  1450. package/src/resources/extensions/gsd/tests/auto-model-selection-tool-poisoning.test.ts +742 -0
  1451. package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +479 -0
  1452. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +1300 -0
  1453. package/src/resources/extensions/gsd/tests/auto-pause-double-entry-guard.test.ts +76 -0
  1454. package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +103 -0
  1455. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +759 -0
  1456. package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +390 -0
  1457. package/src/resources/extensions/gsd/tests/auto-post-unit-artifact-diagnostic.test.ts +32 -0
  1458. package/src/resources/extensions/gsd/tests/auto-post-unit-evidence-crossref-4909.test.ts +60 -0
  1459. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +218 -0
  1460. package/src/resources/extensions/gsd/tests/auto-pr-bugs.test.ts +66 -0
  1461. package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +74 -0
  1462. package/src/resources/extensions/gsd/tests/auto-prompts-fallback.test.ts +35 -0
  1463. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +1773 -0
  1464. package/src/resources/extensions/gsd/tests/auto-remediate-slice-status.test.ts +48 -0
  1465. package/src/resources/extensions/gsd/tests/auto-remote-session-lock-cleanup.test.ts +64 -0
  1466. package/src/resources/extensions/gsd/tests/auto-retry-mcp-churn-fixes.test.ts +98 -0
  1467. package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +59 -0
  1468. package/src/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +277 -0
  1469. package/src/resources/extensions/gsd/tests/auto-session-scope.test.ts +348 -0
  1470. package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +45 -0
  1471. package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +61 -0
  1472. package/src/resources/extensions/gsd/tests/auto-start-cold-db-bootstrap.test.ts +27 -0
  1473. package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +26 -0
  1474. package/src/resources/extensions/gsd/tests/auto-start-needs-discussion.test.ts +175 -0
  1475. package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +161 -0
  1476. package/src/resources/extensions/gsd/tests/auto-start-project-milestone-reconcile.test.ts +49 -0
  1477. package/src/resources/extensions/gsd/tests/auto-start-time-persistence.test.ts +32 -0
  1478. package/src/resources/extensions/gsd/tests/auto-start-validation-block.test.ts +52 -0
  1479. package/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts +19 -0
  1480. package/src/resources/extensions/gsd/tests/auto-status-message.test.ts +46 -0
  1481. package/src/resources/extensions/gsd/tests/auto-stop-notification.test.ts +31 -0
  1482. package/src/resources/extensions/gsd/tests/auto-supervisor.test.mjs +70 -0
  1483. package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +54 -0
  1484. package/src/resources/extensions/gsd/tests/auto-unit-closeout.test.ts +68 -0
  1485. package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +106 -0
  1486. package/src/resources/extensions/gsd/tests/auto-workers.test.ts +134 -0
  1487. package/src/resources/extensions/gsd/tests/auto-worktree-auto-resolve.test.ts +80 -0
  1488. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +244 -0
  1489. package/src/resources/extensions/gsd/tests/auto-worktree-repair.test.ts +199 -0
  1490. package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +171 -0
  1491. package/src/resources/extensions/gsd/tests/autocomplete-regressions-1675.test.ts +143 -0
  1492. package/src/resources/extensions/gsd/tests/block-db-writes.test.ts +63 -0
  1493. package/src/resources/extensions/gsd/tests/blocked-models.test.ts +98 -0
  1494. package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +23 -0
  1495. package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
  1496. package/src/resources/extensions/gsd/tests/browser-teardown.test.ts +92 -0
  1497. package/src/resources/extensions/gsd/tests/browser-tools-compatibility-declarations.test.ts +62 -0
  1498. package/src/resources/extensions/gsd/tests/budget-prediction.test.ts +147 -0
  1499. package/src/resources/extensions/gsd/tests/bundled-skill-triggers.test.ts +77 -0
  1500. package/src/resources/extensions/gsd/tests/bundled-workflow-defs.test.ts +180 -0
  1501. package/src/resources/extensions/gsd/tests/cache-staleness-regression.test.ts +290 -0
  1502. package/src/resources/extensions/gsd/tests/canonical-milestone-root.test.ts +108 -0
  1503. package/src/resources/extensions/gsd/tests/capability-router.test.ts +371 -0
  1504. package/src/resources/extensions/gsd/tests/captures.test.ts +524 -0
  1505. package/src/resources/extensions/gsd/tests/check-auto-start-pending-gate.test.ts +203 -0
  1506. package/src/resources/extensions/gsd/tests/check-auto-start-ready-guard.test.ts +148 -0
  1507. package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +87 -0
  1508. package/src/resources/extensions/gsd/tests/claude-import-marketplace-discovery.test.ts +191 -0
  1509. package/src/resources/extensions/gsd/tests/claude-import-tui.test.ts +350 -0
  1510. package/src/resources/extensions/gsd/tests/claude-skill-dirs.test.ts +51 -0
  1511. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +509 -0
  1512. package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +76 -0
  1513. package/src/resources/extensions/gsd/tests/cli-provider-rate-limit.test.ts +47 -0
  1514. package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
  1515. package/src/resources/extensions/gsd/tests/closeout-recovery.test.ts +101 -0
  1516. package/src/resources/extensions/gsd/tests/cmux.test.ts +333 -0
  1517. package/src/resources/extensions/gsd/tests/codebase-generator.test.ts +669 -0
  1518. package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +43 -0
  1519. package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +506 -0
  1520. package/src/resources/extensions/gsd/tests/collision-diagnostics.test.ts +705 -0
  1521. package/src/resources/extensions/gsd/tests/command-queue.test.ts +141 -0
  1522. package/src/resources/extensions/gsd/tests/commands-backlog.test.ts +158 -0
  1523. package/src/resources/extensions/gsd/tests/commands-config.test.ts +31 -0
  1524. package/src/resources/extensions/gsd/tests/commands-dispatcher-unmerged-milestone.test.ts +188 -0
  1525. package/src/resources/extensions/gsd/tests/commands-dispatcher-validation-block.test.ts +178 -0
  1526. package/src/resources/extensions/gsd/tests/commands-do.test.ts +175 -0
  1527. package/src/resources/extensions/gsd/tests/commands-eval-review.test.ts +612 -0
  1528. package/src/resources/extensions/gsd/tests/commands-extensions-version-compare.test.ts +58 -0
  1529. package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +663 -0
  1530. package/src/resources/extensions/gsd/tests/commands-inspect-open-db.test.ts +46 -0
  1531. package/src/resources/extensions/gsd/tests/commands-logs.test.ts +241 -0
  1532. package/src/resources/extensions/gsd/tests/commands-pr-branch.test.ts +68 -0
  1533. package/src/resources/extensions/gsd/tests/commands-scan.test.ts +351 -0
  1534. package/src/resources/extensions/gsd/tests/commands-session-report.test.ts +82 -0
  1535. package/src/resources/extensions/gsd/tests/commands-ship-eval-warn.test.ts +156 -0
  1536. package/src/resources/extensions/gsd/tests/commands-ship.test.ts +71 -0
  1537. package/src/resources/extensions/gsd/tests/commands-verdict.test.ts +439 -0
  1538. package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +311 -0
  1539. package/src/resources/extensions/gsd/tests/commands-worktree-clean.test.ts +48 -0
  1540. package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +136 -0
  1541. package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +366 -0
  1542. package/src/resources/extensions/gsd/tests/complete-milestone-prompt-rendering.test.ts +47 -0
  1543. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +743 -0
  1544. package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +193 -0
  1545. package/src/resources/extensions/gsd/tests/complete-slice-gate-closure.test.ts +167 -0
  1546. package/src/resources/extensions/gsd/tests/complete-slice-prompt-task-summary-layout.test.ts +18 -0
  1547. package/src/resources/extensions/gsd/tests/complete-slice-string-coercion.test.ts +247 -0
  1548. package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +156 -0
  1549. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +556 -0
  1550. package/src/resources/extensions/gsd/tests/complete-task-normalize-lists.test.ts +50 -0
  1551. package/src/resources/extensions/gsd/tests/complete-task-rollback-evidence.test.ts +105 -0
  1552. package/src/resources/extensions/gsd/tests/complete-task.test.ts +513 -0
  1553. package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +84 -0
  1554. package/src/resources/extensions/gsd/tests/completed-units-metrics-sync.test.ts +61 -0
  1555. package/src/resources/extensions/gsd/tests/completion-hierarchy-guards.test.ts +192 -0
  1556. package/src/resources/extensions/gsd/tests/complexity-classifier.test.ts +206 -0
  1557. package/src/resources/extensions/gsd/tests/component-loader.test.ts +582 -0
  1558. package/src/resources/extensions/gsd/tests/component-types.test.ts +127 -0
  1559. package/src/resources/extensions/gsd/tests/context-budget.test.ts +389 -0
  1560. package/src/resources/extensions/gsd/tests/context-injector.test.ts +313 -0
  1561. package/src/resources/extensions/gsd/tests/context-masker.test.ts +122 -0
  1562. package/src/resources/extensions/gsd/tests/context-store-decisions-from-memories.test.ts +312 -0
  1563. package/src/resources/extensions/gsd/tests/context-store.test.ts +715 -0
  1564. package/src/resources/extensions/gsd/tests/core-overlay-fallback.test.ts +185 -0
  1565. package/src/resources/extensions/gsd/tests/cost-projection.test.ts +120 -0
  1566. package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +294 -0
  1567. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +331 -0
  1568. package/src/resources/extensions/gsd/tests/crash-recovery.test.ts +709 -0
  1569. package/src/resources/extensions/gsd/tests/current-directory-root-homedir-fallback.test.ts +63 -0
  1570. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +902 -0
  1571. package/src/resources/extensions/gsd/tests/custom-verification.test.ts +415 -0
  1572. package/src/resources/extensions/gsd/tests/custom-verify-retry-store.test.ts +139 -0
  1573. package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +483 -0
  1574. package/src/resources/extensions/gsd/tests/cwd-fallback-hardening.test.ts +138 -0
  1575. package/src/resources/extensions/gsd/tests/dashboard-budget.test.ts +360 -0
  1576. package/src/resources/extensions/gsd/tests/dashboard-custom-engine.test.ts +23 -0
  1577. package/src/resources/extensions/gsd/tests/db-access-guardrails.test.ts +110 -0
  1578. package/src/resources/extensions/gsd/tests/db-adapter.test.ts +82 -0
  1579. package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +208 -0
  1580. package/src/resources/extensions/gsd/tests/db-base-schema.test.ts +62 -0
  1581. package/src/resources/extensions/gsd/tests/db-connection-cache.test.ts +60 -0
  1582. package/src/resources/extensions/gsd/tests/db-coordination-schema.test.ts +39 -0
  1583. package/src/resources/extensions/gsd/tests/db-decision-requirement-rows.test.ts +135 -0
  1584. package/src/resources/extensions/gsd/tests/db-gate-rows.test.ts +53 -0
  1585. package/src/resources/extensions/gsd/tests/db-lightweight-query-rows.test.ts +45 -0
  1586. package/src/resources/extensions/gsd/tests/db-memory-fts-schema.test.ts +86 -0
  1587. package/src/resources/extensions/gsd/tests/db-migration-backup.test.ts +105 -0
  1588. package/src/resources/extensions/gsd/tests/db-migration-steps.integration.test.ts +428 -0
  1589. package/src/resources/extensions/gsd/tests/db-migration-steps.test.ts +159 -0
  1590. package/src/resources/extensions/gsd/tests/db-milestone-artifact-rows.test.ts +53 -0
  1591. package/src/resources/extensions/gsd/tests/db-open-state.test.ts +56 -0
  1592. package/src/resources/extensions/gsd/tests/db-path-worktree-symlink.test.ts +95 -0
  1593. package/src/resources/extensions/gsd/tests/db-provider.test.ts +105 -0
  1594. package/src/resources/extensions/gsd/tests/db-runtime-kv-schema.test.ts +37 -0
  1595. package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +115 -0
  1596. package/src/resources/extensions/gsd/tests/db-task-slice-rows.test.ts +130 -0
  1597. package/src/resources/extensions/gsd/tests/db-transaction.test.ts +110 -0
  1598. package/src/resources/extensions/gsd/tests/db-verification-evidence-schema.test.ts +76 -0
  1599. package/src/resources/extensions/gsd/tests/db-writer-path-containment.test.ts +152 -0
  1600. package/src/resources/extensions/gsd/tests/db-writer-root-artifact.test.ts +221 -0
  1601. package/src/resources/extensions/gsd/tests/db-writer-scope.test.ts +230 -0
  1602. package/src/resources/extensions/gsd/tests/db-writer.test.ts +980 -0
  1603. package/src/resources/extensions/gsd/tests/debug-command-handler.test.ts +942 -0
  1604. package/src/resources/extensions/gsd/tests/debug-command-lifecycle.integration.test.ts +1229 -0
  1605. package/src/resources/extensions/gsd/tests/debug-logger.test.ts +187 -0
  1606. package/src/resources/extensions/gsd/tests/debug-session-store.test.ts +565 -0
  1607. package/src/resources/extensions/gsd/tests/decision-scope-cascade.test.ts +370 -0
  1608. package/src/resources/extensions/gsd/tests/decisions-projection-from-memories.test.ts +453 -0
  1609. package/src/resources/extensions/gsd/tests/decisions-stop-table-writes.test.ts +348 -0
  1610. package/src/resources/extensions/gsd/tests/deep-mode-integration.test.ts +406 -0
  1611. package/src/resources/extensions/gsd/tests/deep-planning-mode-dispatch.test.ts +923 -0
  1612. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +1705 -0
  1613. package/src/resources/extensions/gsd/tests/deep-project-setup-policy.test.ts +193 -0
  1614. package/src/resources/extensions/gsd/tests/defer-milestone-stamp.test.ts +30 -0
  1615. package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +65 -0
  1616. package/src/resources/extensions/gsd/tests/deferred-slice-dispatch.test.ts +203 -0
  1617. package/src/resources/extensions/gsd/tests/definition-io.test.ts +57 -0
  1618. package/src/resources/extensions/gsd/tests/definition-loader.test.ts +762 -0
  1619. package/src/resources/extensions/gsd/tests/delegation-policy.test.ts +151 -0
  1620. package/src/resources/extensions/gsd/tests/derive-state-crossval.test.ts +514 -0
  1621. package/src/resources/extensions/gsd/tests/derive-state-db-disk-reconcile.test.ts +133 -0
  1622. package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +1388 -0
  1623. package/src/resources/extensions/gsd/tests/derive-state-deps.test.ts +641 -0
  1624. package/src/resources/extensions/gsd/tests/derive-state-draft.test.ts +313 -0
  1625. package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +558 -0
  1626. package/src/resources/extensions/gsd/tests/derive-state.test.ts +1049 -0
  1627. package/src/resources/extensions/gsd/tests/detect-stuck-respects-retry.test.ts +173 -0
  1628. package/src/resources/extensions/gsd/tests/detection.test.ts +1367 -0
  1629. package/src/resources/extensions/gsd/tests/dev-engine-wrapper.test.ts +314 -0
  1630. package/src/resources/extensions/gsd/tests/diff-context.test.ts +136 -0
  1631. package/src/resources/extensions/gsd/tests/discord-invite-links.test.ts +47 -0
  1632. package/src/resources/extensions/gsd/tests/discuss-cold-start-db-open.test.ts +71 -0
  1633. package/src/resources/extensions/gsd/tests/discuss-command-targeting-5471.test.ts +125 -0
  1634. package/src/resources/extensions/gsd/tests/discuss-empty-db-fallback.test.ts +62 -0
  1635. package/src/resources/extensions/gsd/tests/discuss-headless-rendering.test.ts +37 -0
  1636. package/src/resources/extensions/gsd/tests/discuss-incremental-persistence.test.ts +45 -0
  1637. package/src/resources/extensions/gsd/tests/discuss-milestone-structured-questions.test.ts +115 -0
  1638. package/src/resources/extensions/gsd/tests/discuss-prompt.test.ts +15 -0
  1639. package/src/resources/extensions/gsd/tests/discuss-queued-milestones.test.ts +170 -0
  1640. package/src/resources/extensions/gsd/tests/discuss-tool-scope-leak.test.ts +35 -0
  1641. package/src/resources/extensions/gsd/tests/discuss-tool-scoping.test.ts +138 -0
  1642. package/src/resources/extensions/gsd/tests/dispatch-backgroundable-annotation.test.ts +55 -0
  1643. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +276 -0
  1644. package/src/resources/extensions/gsd/tests/dispatch-guard-closed-status.test.ts +43 -0
  1645. package/src/resources/extensions/gsd/tests/dispatch-guard-summary-db-mismatch.test.ts +77 -0
  1646. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +446 -0
  1647. package/src/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +279 -0
  1648. package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +358 -0
  1649. package/src/resources/extensions/gsd/tests/dispatch-uat-last-completed.test.ts +206 -0
  1650. package/src/resources/extensions/gsd/tests/dispatcher-stuck-planning.test.ts +55 -0
  1651. package/src/resources/extensions/gsd/tests/dist-redirect.mjs +112 -0
  1652. package/src/resources/extensions/gsd/tests/doctor-empty-worktree.test.ts +65 -0
  1653. package/src/resources/extensions/gsd/tests/doctor-fix-flag.test.ts +92 -0
  1654. package/src/resources/extensions/gsd/tests/doctor-forensics-db-open-regression.test.ts +50 -0
  1655. package/src/resources/extensions/gsd/tests/doctor-heal-fixable-warnings.test.ts +14 -0
  1656. package/src/resources/extensions/gsd/tests/doctor-orphan-milestone-4996.test.ts +100 -0
  1657. package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +828 -0
  1658. package/src/resources/extensions/gsd/tests/doctor-runtime-checks.test.ts +47 -0
  1659. package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +43 -0
  1660. package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +36 -0
  1661. package/src/resources/extensions/gsd/tests/draft-promotion.test.ts +149 -0
  1662. package/src/resources/extensions/gsd/tests/dynamic-routing-default.test.ts +20 -0
  1663. package/src/resources/extensions/gsd/tests/engine-interfaces-contract.test.ts +271 -0
  1664. package/src/resources/extensions/gsd/tests/enhanced-verification-integration.test.ts +531 -0
  1665. package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +530 -0
  1666. package/src/resources/extensions/gsd/tests/ensure-preconditions-guard-4996.test.ts +93 -0
  1667. package/src/resources/extensions/gsd/tests/error-success-mask.test.ts +32 -0
  1668. package/src/resources/extensions/gsd/tests/escalation.test.ts +819 -0
  1669. package/src/resources/extensions/gsd/tests/est-annotation-timeout.test.ts +53 -0
  1670. package/src/resources/extensions/gsd/tests/eval-review-schema.test.ts +282 -0
  1671. package/src/resources/extensions/gsd/tests/event-replay-idempotency.test.ts +140 -0
  1672. package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +121 -0
  1673. package/src/resources/extensions/gsd/tests/exec-history.test.ts +252 -0
  1674. package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +407 -0
  1675. package/src/resources/extensions/gsd/tests/execute-summary-save-empty-project.test.ts +109 -0
  1676. package/src/resources/extensions/gsd/tests/execute-task-prompt-existing-artifact-guard.test.ts +33 -0
  1677. package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +62 -0
  1678. package/src/resources/extensions/gsd/tests/execution-entry-missing-context-4671.test.ts +187 -0
  1679. package/src/resources/extensions/gsd/tests/exit-command.test.ts +101 -0
  1680. package/src/resources/extensions/gsd/tests/export-html-all.test.ts +116 -0
  1681. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +387 -0
  1682. package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +164 -0
  1683. package/src/resources/extensions/gsd/tests/extension-selector-separator.test.ts +144 -0
  1684. package/src/resources/extensions/gsd/tests/false-degraded-mode-warning.test.ts +43 -0
  1685. package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
  1686. package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +108 -0
  1687. package/src/resources/extensions/gsd/tests/file-lock.test.ts +177 -0
  1688. package/src/resources/extensions/gsd/tests/files-loadfile-eisdir.test.ts +18 -0
  1689. package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +151 -0
  1690. package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +103 -0
  1691. package/src/resources/extensions/gsd/tests/find-missing-summaries-closed-runtime.test.ts +47 -0
  1692. package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-basic.md +52 -0
  1693. package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-empty-optionals.md +42 -0
  1694. package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +55 -0
  1695. package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +60 -0
  1696. package/src/resources/extensions/gsd/tests/flag-file-db.test.ts +278 -0
  1697. package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +305 -0
  1698. package/src/resources/extensions/gsd/tests/forensics-error-filter.test.ts +121 -0
  1699. package/src/resources/extensions/gsd/tests/forensics-issue-routing.test.ts +43 -0
  1700. package/src/resources/extensions/gsd/tests/forensics-prompt-rendering.test.ts +36 -0
  1701. package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +215 -0
  1702. package/src/resources/extensions/gsd/tests/format-shortcut.test.ts +100 -0
  1703. package/src/resources/extensions/gsd/tests/freeform-decisions.test.ts +298 -0
  1704. package/src/resources/extensions/gsd/tests/fresh-run-ui.test.ts +65 -0
  1705. package/src/resources/extensions/gsd/tests/frontmatter-parse-noise.test.ts +34 -0
  1706. package/src/resources/extensions/gsd/tests/gate-1b-orphan-discrimination.test.ts +193 -0
  1707. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound-corrections.test.ts +246 -0
  1708. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound.test.ts +218 -0
  1709. package/src/resources/extensions/gsd/tests/gate-dispatch.test.ts +216 -0
  1710. package/src/resources/extensions/gsd/tests/gate-registry.test.ts +140 -0
  1711. package/src/resources/extensions/gsd/tests/gate-state-canonicalization.test.ts +102 -0
  1712. package/src/resources/extensions/gsd/tests/gate-storage.test.ts +156 -0
  1713. package/src/resources/extensions/gsd/tests/git-checkpoint.test.ts +103 -0
  1714. package/src/resources/extensions/gsd/tests/gitignore-bg-shell-runtime.test.ts +77 -0
  1715. package/src/resources/extensions/gsd/tests/google-search-stub.test.ts +91 -0
  1716. package/src/resources/extensions/gsd/tests/graph-context.test.ts +337 -0
  1717. package/src/resources/extensions/gsd/tests/graph-operations.test.ts +599 -0
  1718. package/src/resources/extensions/gsd/tests/gsd-command-home.test.ts +134 -0
  1719. package/src/resources/extensions/gsd/tests/gsd-db-failed-open-restore.test.ts +117 -0
  1720. package/src/resources/extensions/gsd/tests/gsd-db-workspace-scope.test.ts +226 -0
  1721. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1210 -0
  1722. package/src/resources/extensions/gsd/tests/gsd-home.test.ts +43 -0
  1723. package/src/resources/extensions/gsd/tests/gsd-inspect.test.ts +114 -0
  1724. package/src/resources/extensions/gsd/tests/gsd-no-project-error-runtime.test.ts +95 -0
  1725. package/src/resources/extensions/gsd/tests/gsd-recover.test.ts +440 -0
  1726. package/src/resources/extensions/gsd/tests/gsd-root-canonical.test.ts +66 -0
  1727. package/src/resources/extensions/gsd/tests/gsd-root-home-guard.test.ts +149 -0
  1728. package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +445 -0
  1729. package/src/resources/extensions/gsd/tests/gsdroot-worktree-detection.test.ts +146 -0
  1730. package/src/resources/extensions/gsd/tests/guided-discuss-milestone-prompt-rendering.test.ts +43 -0
  1731. package/src/resources/extensions/gsd/tests/guided-discuss-project-prompt-rendering.test.ts +43 -0
  1732. package/src/resources/extensions/gsd/tests/guided-discuss-requirements-prompt-rendering.test.ts +45 -0
  1733. package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +106 -0
  1734. package/src/resources/extensions/gsd/tests/guided-flow-dynamic-routing.test.ts +135 -0
  1735. package/src/resources/extensions/gsd/tests/guided-flow-prompt-consolidation.test.ts +147 -0
  1736. package/src/resources/extensions/gsd/tests/guided-flow-session-isolation.test.ts +219 -0
  1737. package/src/resources/extensions/gsd/tests/guided-flow-state-rebuild.test.ts +140 -0
  1738. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
  1739. package/src/resources/extensions/gsd/tests/guided-tool-contract.test.ts +65 -0
  1740. package/src/resources/extensions/gsd/tests/handler-worktree-write-isolation.test.ts +57 -0
  1741. package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +130 -0
  1742. package/src/resources/extensions/gsd/tests/header-renderer.test.ts +40 -0
  1743. package/src/resources/extensions/gsd/tests/headless-answers.test.ts +350 -0
  1744. package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +127 -0
  1745. package/src/resources/extensions/gsd/tests/headless-query.test.ts +184 -0
  1746. package/src/resources/extensions/gsd/tests/health-widget.test.ts +251 -0
  1747. package/src/resources/extensions/gsd/tests/help-menu-coverage.test.ts +57 -0
  1748. package/src/resources/extensions/gsd/tests/hook-key-parsing.test.ts +56 -0
  1749. package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +103 -0
  1750. package/src/resources/extensions/gsd/tests/import-done-milestones-runtime.test.ts +145 -0
  1751. package/src/resources/extensions/gsd/tests/in-flight-tool-tracking.test.ts +32 -0
  1752. package/src/resources/extensions/gsd/tests/infra-error.test.ts +129 -0
  1753. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +189 -0
  1754. package/src/resources/extensions/gsd/tests/init-prefs-routing.test.ts +275 -0
  1755. package/src/resources/extensions/gsd/tests/init-skip-git.test.ts +16 -0
  1756. package/src/resources/extensions/gsd/tests/init-wizard.test.ts +239 -0
  1757. package/src/resources/extensions/gsd/tests/insert-slice-no-wipe.test.ts +88 -0
  1758. package/src/resources/extensions/gsd/tests/integration/all-milestones-complete-merge.test.ts +199 -0
  1759. package/src/resources/extensions/gsd/tests/integration/atomic-task-closeout.test.ts +72 -0
  1760. package/src/resources/extensions/gsd/tests/integration/auto-preflight.test.ts +38 -0
  1761. package/src/resources/extensions/gsd/tests/integration/auto-recovery.test.ts +966 -0
  1762. package/src/resources/extensions/gsd/tests/integration/auto-secrets-gate.test.ts +194 -0
  1763. package/src/resources/extensions/gsd/tests/integration/auto-stash-merge.test.ts +121 -0
  1764. package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +964 -0
  1765. package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +430 -0
  1766. package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +256 -0
  1767. package/src/resources/extensions/gsd/tests/integration/continue-here.test.ts +281 -0
  1768. package/src/resources/extensions/gsd/tests/integration/doctor-completion-deferral.test.ts +88 -0
  1769. package/src/resources/extensions/gsd/tests/integration/doctor-delimiter-fix.test.ts +83 -0
  1770. package/src/resources/extensions/gsd/tests/integration/doctor-enhancements.test.ts +243 -0
  1771. package/src/resources/extensions/gsd/tests/integration/doctor-environment-worktree.test.ts +164 -0
  1772. package/src/resources/extensions/gsd/tests/integration/doctor-environment.test.ts +403 -0
  1773. package/src/resources/extensions/gsd/tests/integration/doctor-false-positives.test.ts +243 -0
  1774. package/src/resources/extensions/gsd/tests/integration/doctor-fixlevel.test.ts +263 -0
  1775. package/src/resources/extensions/gsd/tests/integration/doctor-git-symlink-cwd.test.ts +90 -0
  1776. package/src/resources/extensions/gsd/tests/integration/doctor-git.test.ts +954 -0
  1777. package/src/resources/extensions/gsd/tests/integration/doctor-proactive.test.ts +431 -0
  1778. package/src/resources/extensions/gsd/tests/integration/doctor-roadmap-summary-atomicity.test.ts +123 -0
  1779. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +549 -0
  1780. package/src/resources/extensions/gsd/tests/integration/doctor.test.ts +612 -0
  1781. package/src/resources/extensions/gsd/tests/integration/e2e-workflow-pipeline-integration.test.ts +476 -0
  1782. package/src/resources/extensions/gsd/tests/integration/feature-branch-lifecycle-integration.test.ts +415 -0
  1783. package/src/resources/extensions/gsd/tests/integration/git-locale.test.ts +130 -0
  1784. package/src/resources/extensions/gsd/tests/integration/git-self-heal.test.ts +131 -0
  1785. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +2040 -0
  1786. package/src/resources/extensions/gsd/tests/integration/gitignore-staging-2570.test.ts +150 -0
  1787. package/src/resources/extensions/gsd/tests/integration/gitignore-tracked-gsd.test.ts +257 -0
  1788. package/src/resources/extensions/gsd/tests/integration/headless-command.ts +534 -0
  1789. package/src/resources/extensions/gsd/tests/integration/idle-recovery.test.ts +474 -0
  1790. package/src/resources/extensions/gsd/tests/integration/inherited-repo-home-dir.test.ts +191 -0
  1791. package/src/resources/extensions/gsd/tests/integration/integration-lifecycle.test.ts +274 -0
  1792. package/src/resources/extensions/gsd/tests/integration/integration-mixed-milestones.test.ts +539 -0
  1793. package/src/resources/extensions/gsd/tests/integration/integration-proof.test.ts +634 -0
  1794. package/src/resources/extensions/gsd/tests/integration/merge-cwd-restore.test.ts +169 -0
  1795. package/src/resources/extensions/gsd/tests/integration/merge-preserve-worktree-on-preteardown-error.test.ts +77 -0
  1796. package/src/resources/extensions/gsd/tests/integration/migrate-command.test.ts +405 -0
  1797. package/src/resources/extensions/gsd/tests/integration/milestone-transition-worktree.test.ts +119 -0
  1798. package/src/resources/extensions/gsd/tests/integration/parallel-merge.test.ts +669 -0
  1799. package/src/resources/extensions/gsd/tests/integration/parallel-workers-multi-milestone-e2e.test.ts +337 -0
  1800. package/src/resources/extensions/gsd/tests/integration/paths.test.ts +98 -0
  1801. package/src/resources/extensions/gsd/tests/integration/plugin-importer-live.test.ts +481 -0
  1802. package/src/resources/extensions/gsd/tests/integration/queue-completed-milestone-perf.test.ts +161 -0
  1803. package/src/resources/extensions/gsd/tests/integration/queue-reorder-e2e.test.ts +335 -0
  1804. package/src/resources/extensions/gsd/tests/integration/quick-branch-lifecycle.test.ts +253 -0
  1805. package/src/resources/extensions/gsd/tests/integration/run-uat.test.ts +689 -0
  1806. package/src/resources/extensions/gsd/tests/integration/state-machine-edge-cases.test.ts +1356 -0
  1807. package/src/resources/extensions/gsd/tests/integration/state-machine-live-validation.test.ts +980 -0
  1808. package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +832 -0
  1809. package/src/resources/extensions/gsd/tests/integration/test-isolation.ts +53 -0
  1810. package/src/resources/extensions/gsd/tests/integration/token-savings.test.ts +341 -0
  1811. package/src/resources/extensions/gsd/tests/integration/workspace-collapse-integration.test.ts +369 -0
  1812. package/src/resources/extensions/gsd/tests/integration/worktree-e2e.test.ts +248 -0
  1813. package/src/resources/extensions/gsd/tests/integration-edge.test.ts +223 -0
  1814. package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +71 -0
  1815. package/src/resources/extensions/gsd/tests/interactive-tool-idle-exemption.test.ts +119 -0
  1816. package/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts +241 -0
  1817. package/src/resources/extensions/gsd/tests/interrupted-session-ui.test.ts +180 -0
  1818. package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +19 -0
  1819. package/src/resources/extensions/gsd/tests/issue-4540-regressions.test.ts +288 -0
  1820. package/src/resources/extensions/gsd/tests/iterate-engine-integration.test.ts +429 -0
  1821. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +1473 -0
  1822. package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +179 -0
  1823. package/src/resources/extensions/gsd/tests/journal.test.ts +373 -0
  1824. package/src/resources/extensions/gsd/tests/json-persistence-atomic.test.ts +183 -0
  1825. package/src/resources/extensions/gsd/tests/key-manager.test.ts +501 -0
  1826. package/src/resources/extensions/gsd/tests/knowledge-backfill-projection.test.ts +323 -0
  1827. package/src/resources/extensions/gsd/tests/knowledge-capture.test.ts +242 -0
  1828. package/src/resources/extensions/gsd/tests/knowledge.test.ts +434 -0
  1829. package/src/resources/extensions/gsd/tests/lazy-pi-tui-import.test.ts +53 -0
  1830. package/src/resources/extensions/gsd/tests/lease-conflict-notice.test.ts +38 -0
  1831. package/src/resources/extensions/gsd/tests/legacy-component-format-telemetry.test.ts +62 -0
  1832. package/src/resources/extensions/gsd/tests/legacy-telemetry.test.ts +144 -0
  1833. package/src/resources/extensions/gsd/tests/load-knowledge-block-rules-only.test.ts +209 -0
  1834. package/src/resources/extensions/gsd/tests/load-memory-block.test.ts +36 -0
  1835. package/src/resources/extensions/gsd/tests/manifest-status.test.ts +274 -0
  1836. package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +1292 -0
  1837. package/src/resources/extensions/gsd/tests/marketplace-test-fixtures.ts +91 -0
  1838. package/src/resources/extensions/gsd/tests/mcp-client-security.test.ts +47 -0
  1839. package/src/resources/extensions/gsd/tests/mcp-filter.test.ts +287 -0
  1840. package/src/resources/extensions/gsd/tests/mcp-project-config.test.ts +89 -0
  1841. package/src/resources/extensions/gsd/tests/mcp-status.test.ts +183 -0
  1842. package/src/resources/extensions/gsd/tests/md-importer.test.ts +416 -0
  1843. package/src/resources/extensions/gsd/tests/measurement.test.ts +531 -0
  1844. package/src/resources/extensions/gsd/tests/memory-consolidation-scanner.test.ts +316 -0
  1845. package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
  1846. package/src/resources/extensions/gsd/tests/memory-embeddings.test.ts +213 -0
  1847. package/src/resources/extensions/gsd/tests/memory-extractor.test.ts +244 -0
  1848. package/src/resources/extensions/gsd/tests/memory-ingest.test.ts +153 -0
  1849. package/src/resources/extensions/gsd/tests/memory-leak-guards.test.ts +91 -0
  1850. package/src/resources/extensions/gsd/tests/memory-maintenance.test.ts +107 -0
  1851. package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +79 -0
  1852. package/src/resources/extensions/gsd/tests/memory-relations.test.ts +175 -0
  1853. package/src/resources/extensions/gsd/tests/memory-store.test.ts +460 -0
  1854. package/src/resources/extensions/gsd/tests/memory-tools.test.ts +327 -0
  1855. package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +303 -0
  1856. package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +179 -0
  1857. package/src/resources/extensions/gsd/tests/merge-self-branch-guard.test.ts +105 -0
  1858. package/src/resources/extensions/gsd/tests/metrics-atomic-merge.test.ts +222 -0
  1859. package/src/resources/extensions/gsd/tests/metrics-lock-hardening.test.ts +400 -0
  1860. package/src/resources/extensions/gsd/tests/metrics-lock-not-acquired.test.ts +141 -0
  1861. package/src/resources/extensions/gsd/tests/metrics-lock-retry-sleep.test.ts +287 -0
  1862. package/src/resources/extensions/gsd/tests/metrics-milestone-scope.test.ts +64 -0
  1863. package/src/resources/extensions/gsd/tests/metrics-prune-cache-invalidation.test.ts +149 -0
  1864. package/src/resources/extensions/gsd/tests/metrics-scope.test.ts +378 -0
  1865. package/src/resources/extensions/gsd/tests/metrics.test.ts +519 -0
  1866. package/src/resources/extensions/gsd/tests/migrate-external-worktree.test.ts +165 -0
  1867. package/src/resources/extensions/gsd/tests/migrate-hierarchy.test.ts +429 -0
  1868. package/src/resources/extensions/gsd/tests/migrate-parser.test.ts +782 -0
  1869. package/src/resources/extensions/gsd/tests/migrate-safety-audit.test.ts +242 -0
  1870. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +651 -0
  1871. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +448 -0
  1872. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +347 -0
  1873. package/src/resources/extensions/gsd/tests/migrate-writer.test.ts +361 -0
  1874. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +135 -0
  1875. package/src/resources/extensions/gsd/tests/milestone-id-gap-reuse-4996.test.ts +152 -0
  1876. package/src/resources/extensions/gsd/tests/milestone-id-reservation.test.ts +73 -0
  1877. package/src/resources/extensions/gsd/tests/milestone-leases.test.ts +152 -0
  1878. package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +364 -0
  1879. package/src/resources/extensions/gsd/tests/milestone-report-path.test.ts +68 -0
  1880. package/src/resources/extensions/gsd/tests/milestone-scope-classifier.test.ts +206 -0
  1881. package/src/resources/extensions/gsd/tests/milestone-status-authoritative.test.ts +116 -0
  1882. package/src/resources/extensions/gsd/tests/milestone-status-tool.test.ts +202 -0
  1883. package/src/resources/extensions/gsd/tests/milestone-summary-classifier.test.ts +30 -0
  1884. package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +122 -0
  1885. package/src/resources/extensions/gsd/tests/model-cost-table.test.ts +111 -0
  1886. package/src/resources/extensions/gsd/tests/model-isolation.test.ts +305 -0
  1887. package/src/resources/extensions/gsd/tests/model-router.test.ts +990 -0
  1888. package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +90 -0
  1889. package/src/resources/extensions/gsd/tests/must-have-parser.test.ts +278 -0
  1890. package/src/resources/extensions/gsd/tests/namespaced-registry.test.ts +1027 -0
  1891. package/src/resources/extensions/gsd/tests/namespaced-resolver.test.ts +671 -0
  1892. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +228 -0
  1893. package/src/resources/extensions/gsd/tests/native-git-infra-errors.test.ts +50 -0
  1894. package/src/resources/extensions/gsd/tests/native-has-changes-cache.test.ts +61 -0
  1895. package/src/resources/extensions/gsd/tests/needs-remediation-revalidation.test.ts +55 -0
  1896. package/src/resources/extensions/gsd/tests/next-milestone-id.test.ts +23 -0
  1897. package/src/resources/extensions/gsd/tests/none-mode-gates.test.ts +200 -0
  1898. package/src/resources/extensions/gsd/tests/note-captures-executed.test.ts +50 -0
  1899. package/src/resources/extensions/gsd/tests/notification-overlay.test.ts +129 -0
  1900. package/src/resources/extensions/gsd/tests/notification-store.test.ts +325 -0
  1901. package/src/resources/extensions/gsd/tests/notification-widget.test.ts +87 -0
  1902. package/src/resources/extensions/gsd/tests/notifications-handler.test.ts +134 -0
  1903. package/src/resources/extensions/gsd/tests/notifications.test.ts +134 -0
  1904. package/src/resources/extensions/gsd/tests/onboarding-state.test.ts +105 -0
  1905. package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +159 -0
  1906. package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +144 -0
  1907. package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
  1908. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +374 -0
  1909. package/src/resources/extensions/gsd/tests/overrides.test.ts +124 -0
  1910. package/src/resources/extensions/gsd/tests/parallel-budget-atomicity.test.ts +330 -0
  1911. package/src/resources/extensions/gsd/tests/parallel-commit-scope.test.ts +164 -0
  1912. package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +273 -0
  1913. package/src/resources/extensions/gsd/tests/parallel-eligibility-ghost.test.ts +170 -0
  1914. package/src/resources/extensions/gsd/tests/parallel-milestone-isolation.test.ts +106 -0
  1915. package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +114 -0
  1916. package/src/resources/extensions/gsd/tests/parallel-orchestration.test.ts +736 -0
  1917. package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
  1918. package/src/resources/extensions/gsd/tests/parallel-orchestrator-zombie-cleanup.test.ts +332 -0
  1919. package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +308 -0
  1920. package/src/resources/extensions/gsd/tests/parallel-skill-prompt-integration.test.ts +158 -0
  1921. package/src/resources/extensions/gsd/tests/parallel-worker-lock-contention.test.ts +226 -0
  1922. package/src/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +199 -0
  1923. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +157 -0
  1924. package/src/resources/extensions/gsd/tests/park-edge-cases.test.ts +253 -0
  1925. package/src/resources/extensions/gsd/tests/park-milestone.test.ts +420 -0
  1926. package/src/resources/extensions/gsd/tests/parsers.test.ts +1892 -0
  1927. package/src/resources/extensions/gsd/tests/path-cache-decoupled.test.ts +209 -0
  1928. package/src/resources/extensions/gsd/tests/path-normalization-unified.test.ts +175 -0
  1929. package/src/resources/extensions/gsd/tests/paths-cache.test.ts +170 -0
  1930. package/src/resources/extensions/gsd/tests/paused-session-via-db.test.ts +121 -0
  1931. package/src/resources/extensions/gsd/tests/pending-autostart-scope.test.ts +144 -0
  1932. package/src/resources/extensions/gsd/tests/phantom-ghost-detection.test.ts +42 -0
  1933. package/src/resources/extensions/gsd/tests/phantom-milestone-default-queued.test.ts +24 -0
  1934. package/src/resources/extensions/gsd/tests/phase-anchor.test.ts +83 -0
  1935. package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +126 -0
  1936. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +404 -0
  1937. package/src/resources/extensions/gsd/tests/plan-gate-failed-doctor-heal-hint.test.ts +37 -0
  1938. package/src/resources/extensions/gsd/tests/plan-milestone-artifact-verification.test.ts +102 -0
  1939. package/src/resources/extensions/gsd/tests/plan-milestone-boundary-map-preservation.test.ts +114 -0
  1940. package/src/resources/extensions/gsd/tests/plan-milestone-queue-context.test.ts +48 -0
  1941. package/src/resources/extensions/gsd/tests/plan-milestone-rendering.test.ts +45 -0
  1942. package/src/resources/extensions/gsd/tests/plan-milestone-sketch-render.test.ts +157 -0
  1943. package/src/resources/extensions/gsd/tests/plan-milestone-title.test.ts +71 -0
  1944. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +349 -0
  1945. package/src/resources/extensions/gsd/tests/plan-quality-validator.test.ts +474 -0
  1946. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +306 -0
  1947. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +712 -0
  1948. package/src/resources/extensions/gsd/tests/plan-task.test.ts +183 -0
  1949. package/src/resources/extensions/gsd/tests/planning-crossval.test.ts +305 -0
  1950. package/src/resources/extensions/gsd/tests/planning-depth-setter.test.ts +172 -0
  1951. package/src/resources/extensions/gsd/tests/plugin-importer.test.ts +1383 -0
  1952. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +536 -0
  1953. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +1065 -0
  1954. package/src/resources/extensions/gsd/tests/post-mutation-hook.test.ts +171 -0
  1955. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +25 -0
  1956. package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +300 -0
  1957. package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +567 -0
  1958. package/src/resources/extensions/gsd/tests/pr-evidence-equivalence.test.ts +102 -0
  1959. package/src/resources/extensions/gsd/tests/pr-evidence-hardening.test.ts +165 -0
  1960. package/src/resources/extensions/gsd/tests/pr-evidence.test.ts +79 -0
  1961. package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +149 -0
  1962. package/src/resources/extensions/gsd/tests/pre-exec-gate-loop.test.ts +275 -0
  1963. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +2246 -0
  1964. package/src/resources/extensions/gsd/tests/pre-execution-fail-closed.test.ts +244 -0
  1965. package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +708 -0
  1966. package/src/resources/extensions/gsd/tests/preferences-formatting.test.ts +87 -0
  1967. package/src/resources/extensions/gsd/tests/preferences-mcp.test.ts +128 -0
  1968. package/src/resources/extensions/gsd/tests/preferences-worktree-sync.test.ts +118 -0
  1969. package/src/resources/extensions/gsd/tests/preferences.test.ts +1314 -0
  1970. package/src/resources/extensions/gsd/tests/preflight-context-draft-filter.test.ts +115 -0
  1971. package/src/resources/extensions/gsd/tests/prefs-missing-models-crash.test.ts +148 -0
  1972. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +222 -0
  1973. package/src/resources/extensions/gsd/tests/process-task-path.test.ts +51 -0
  1974. package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +620 -0
  1975. package/src/resources/extensions/gsd/tests/project-relocation-recovery.test.ts +297 -0
  1976. package/src/resources/extensions/gsd/tests/project-root-cwd-crash.test.ts +35 -0
  1977. package/src/resources/extensions/gsd/tests/projection-no-plan-overwrite.test.ts +56 -0
  1978. package/src/resources/extensions/gsd/tests/projection-regression.test.ts +277 -0
  1979. package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +677 -0
  1980. package/src/resources/extensions/gsd/tests/prompt-cache-optimizer.test.ts +326 -0
  1981. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +574 -0
  1982. package/src/resources/extensions/gsd/tests/prompt-db.test.ts +387 -0
  1983. package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
  1984. package/src/resources/extensions/gsd/tests/prompt-loader-extension-dir.test.ts +49 -0
  1985. package/src/resources/extensions/gsd/tests/prompt-loader-replacement.test.ts +178 -0
  1986. package/src/resources/extensions/gsd/tests/prompt-loader-working-directory.test.ts +19 -0
  1987. package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
  1988. package/src/resources/extensions/gsd/tests/prompt-ordering.test.ts +296 -0
  1989. package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
  1990. package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +91 -0
  1991. package/src/resources/extensions/gsd/tests/prompt-system-gate-coverage.test.ts +208 -0
  1992. package/src/resources/extensions/gsd/tests/prompt-tool-names.test.ts +69 -0
  1993. package/src/resources/extensions/gsd/tests/prompts-no-gitignored-test-refs.test.ts +56 -0
  1994. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +744 -0
  1995. package/src/resources/extensions/gsd/tests/provider-switch-observer.test.ts +252 -0
  1996. package/src/resources/extensions/gsd/tests/python-resolver.test.ts +131 -0
  1997. package/src/resources/extensions/gsd/tests/quality-gates.test.ts +344 -0
  1998. package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +51 -0
  1999. package/src/resources/extensions/gsd/tests/queue-auto-guard.test.ts +39 -0
  2000. package/src/resources/extensions/gsd/tests/queue-draft-detection.test.ts +101 -0
  2001. package/src/resources/extensions/gsd/tests/queue-execution-guard.test.ts +166 -0
  2002. package/src/resources/extensions/gsd/tests/queue-order.test.ts +192 -0
  2003. package/src/resources/extensions/gsd/tests/queue-prompt-rendering.test.ts +37 -0
  2004. package/src/resources/extensions/gsd/tests/queue-reorder-ui.test.ts +54 -0
  2005. package/src/resources/extensions/gsd/tests/queued-discuss-fast-path.test.ts +106 -0
  2006. package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +36 -0
  2007. package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
  2008. package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +61 -0
  2009. package/src/resources/extensions/gsd/tests/rate-limit-model-fallback.test.ts +90 -0
  2010. package/src/resources/extensions/gsd/tests/reactive-executor.test.ts +511 -0
  2011. package/src/resources/extensions/gsd/tests/reactive-graph.test.ts +363 -0
  2012. package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +728 -0
  2013. package/src/resources/extensions/gsd/tests/reassess-default-optin.test.ts +146 -0
  2014. package/src/resources/extensions/gsd/tests/reassess-detection.test.ts +154 -0
  2015. package/src/resources/extensions/gsd/tests/reassess-handler.test.ts +442 -0
  2016. package/src/resources/extensions/gsd/tests/reassess-prompt.test.ts +135 -0
  2017. package/src/resources/extensions/gsd/tests/reconciliation-edge-cases.test.ts +162 -0
  2018. package/src/resources/extensions/gsd/tests/recovery-attempts-reset.test.ts +144 -0
  2019. package/src/resources/extensions/gsd/tests/regex-hardening.test.ts +161 -0
  2020. package/src/resources/extensions/gsd/tests/register-extension-guard.test.ts +126 -0
  2021. package/src/resources/extensions/gsd/tests/register-hooks-compaction-checkpoint.test.ts +252 -0
  2022. package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +442 -0
  2023. package/src/resources/extensions/gsd/tests/register-shortcuts.test.ts +131 -0
  2024. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +197 -0
  2025. package/src/resources/extensions/gsd/tests/remote-notification-from-desktop.test.ts +107 -0
  2026. package/src/resources/extensions/gsd/tests/remote-questions.test.ts +774 -0
  2027. package/src/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
  2028. package/src/resources/extensions/gsd/tests/reopen-slice.test.ts +155 -0
  2029. package/src/resources/extensions/gsd/tests/reopen-task.test.ts +165 -0
  2030. package/src/resources/extensions/gsd/tests/replan-handler.test.ts +410 -0
  2031. package/src/resources/extensions/gsd/tests/replan-slice.test.ts +609 -0
  2032. package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +258 -0
  2033. package/src/resources/extensions/gsd/tests/repository-registry.test.ts +101 -0
  2034. package/src/resources/extensions/gsd/tests/require-slice-discussion-dispatch.test.ts +170 -0
  2035. package/src/resources/extensions/gsd/tests/requirements.test.ts +110 -0
  2036. package/src/resources/extensions/gsd/tests/research-milestone-composer.test.ts +132 -0
  2037. package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +23 -0
  2038. package/src/resources/extensions/gsd/tests/resolve-ts.mjs +9 -0
  2039. package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +50 -0
  2040. package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +65 -0
  2041. package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +102 -0
  2042. package/src/resources/extensions/gsd/tests/resume-missing-worktree-warning.test.ts +209 -0
  2043. package/src/resources/extensions/gsd/tests/retry-diagnostic-reasoning.test.ts +161 -0
  2044. package/src/resources/extensions/gsd/tests/retry-state-reset.test.ts +305 -0
  2045. package/src/resources/extensions/gsd/tests/rewrite-count-persist.test.ts +82 -0
  2046. package/src/resources/extensions/gsd/tests/rewrite-docs-abandon-detect.test.ts +195 -0
  2047. package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +213 -0
  2048. package/src/resources/extensions/gsd/tests/roadmap-parse-regression.test.ts +399 -0
  2049. package/src/resources/extensions/gsd/tests/roadmap-slices.test.ts +464 -0
  2050. package/src/resources/extensions/gsd/tests/rogue-file-detection.test.ts +294 -0
  2051. package/src/resources/extensions/gsd/tests/routing-history.test.ts +229 -0
  2052. package/src/resources/extensions/gsd/tests/rule-registry.test.ts +411 -0
  2053. package/src/resources/extensions/gsd/tests/run-manager.test.ts +229 -0
  2054. package/src/resources/extensions/gsd/tests/run-uat-composer.test.ts +151 -0
  2055. package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +94 -0
  2056. package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +94 -0
  2057. package/src/resources/extensions/gsd/tests/runtime-kv.test.ts +120 -0
  2058. package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +268 -0
  2059. package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
  2060. package/src/resources/extensions/gsd/tests/schema-v21-sequence.test.ts +413 -0
  2061. package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
  2062. package/src/resources/extensions/gsd/tests/schema-v9-sequence.test.ts +176 -0
  2063. package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +364 -0
  2064. package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
  2065. package/src/resources/extensions/gsd/tests/service-tier.test.ts +131 -0
  2066. package/src/resources/extensions/gsd/tests/session-forensics-readonly-classification.test.ts +70 -0
  2067. package/src/resources/extensions/gsd/tests/session-lock-multipath.test.ts +166 -0
  2068. package/src/resources/extensions/gsd/tests/session-lock-regression.test.ts +379 -0
  2069. package/src/resources/extensions/gsd/tests/session-lock-transient-read.test.ts +224 -0
  2070. package/src/resources/extensions/gsd/tests/session-model-override.test.ts +40 -0
  2071. package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +387 -0
  2072. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +304 -0
  2073. package/src/resources/extensions/gsd/tests/shared-wal.test.ts +239 -0
  2074. package/src/resources/extensions/gsd/tests/show-config-command.test.ts +58 -0
  2075. package/src/resources/extensions/gsd/tests/sidecar-queue.test.ts +182 -0
  2076. package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +130 -0
  2077. package/src/resources/extensions/gsd/tests/silent-catch-diagnostics.test.ts +244 -0
  2078. package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +180 -0
  2079. package/src/resources/extensions/gsd/tests/single-writer-v3-tool-surface.test.ts +158 -0
  2080. package/src/resources/extensions/gsd/tests/skill-activation.test.ts +352 -0
  2081. package/src/resources/extensions/gsd/tests/skill-catalog.test.ts +193 -0
  2082. package/src/resources/extensions/gsd/tests/skill-lifecycle.test.ts +126 -0
  2083. package/src/resources/extensions/gsd/tests/skill-manifest.test.ts +112 -0
  2084. package/src/resources/extensions/gsd/tests/skip-slice-cascades-tasks.test.ts +125 -0
  2085. package/src/resources/extensions/gsd/tests/skip-slice-state-rebuild.test.ts +63 -0
  2086. package/src/resources/extensions/gsd/tests/skipped-validation-completion.test.ts +144 -0
  2087. package/src/resources/extensions/gsd/tests/skipped-validation-db-atomicity.test.ts +57 -0
  2088. package/src/resources/extensions/gsd/tests/slice-cadence.test.ts +301 -0
  2089. package/src/resources/extensions/gsd/tests/slice-context-injection.test.ts +79 -0
  2090. package/src/resources/extensions/gsd/tests/slice-disk-reconcile.test.ts +187 -0
  2091. package/src/resources/extensions/gsd/tests/slice-parallel-conflict.test.ts +92 -0
  2092. package/src/resources/extensions/gsd/tests/slice-parallel-eligibility.test.ts +95 -0
  2093. package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +348 -0
  2094. package/src/resources/extensions/gsd/tests/slice-sequence-insert.test.ts +124 -0
  2095. package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +76 -0
  2096. package/src/resources/extensions/gsd/tests/smart-entry-draft.test.ts +33 -0
  2097. package/src/resources/extensions/gsd/tests/smart-entry-routing.test.ts +113 -0
  2098. package/src/resources/extensions/gsd/tests/sqlite-unavailable-gate.test.ts +29 -0
  2099. package/src/resources/extensions/gsd/tests/stale-dirlistcache-4648.test.ts +65 -0
  2100. package/src/resources/extensions/gsd/tests/stale-lockfile-recovery.test.ts +45 -0
  2101. package/src/resources/extensions/gsd/tests/stale-milestone-id-reservation.test.ts +79 -0
  2102. package/src/resources/extensions/gsd/tests/stale-queued-milestone.test.ts +147 -0
  2103. package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +49 -0
  2104. package/src/resources/extensions/gsd/tests/stale-worktree-cwd.test.ts +152 -0
  2105. package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +148 -0
  2106. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +334 -0
  2107. package/src/resources/extensions/gsd/tests/stash-pop-gsd-conflict.test.ts +203 -0
  2108. package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +442 -0
  2109. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +424 -0
  2110. package/src/resources/extensions/gsd/tests/state-derivation-parity.test.ts +257 -0
  2111. package/src/resources/extensions/gsd/tests/state-machine-full-walkthrough.test.ts +1645 -0
  2112. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +1137 -0
  2113. package/src/resources/extensions/gsd/tests/state-transition-matrix.test.ts +44 -0
  2114. package/src/resources/extensions/gsd/tests/status-db-open.test.ts +42 -0
  2115. package/src/resources/extensions/gsd/tests/status-guards.test.ts +50 -0
  2116. package/src/resources/extensions/gsd/tests/steer-worktree-path.test.ts +123 -0
  2117. package/src/resources/extensions/gsd/tests/stop-auto-merge-back.test.ts +95 -0
  2118. package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +18 -0
  2119. package/src/resources/extensions/gsd/tests/stop-backtrack.test.ts +216 -0
  2120. package/src/resources/extensions/gsd/tests/structured-data-formatter.test.ts +285 -0
  2121. package/src/resources/extensions/gsd/tests/stuck-detection-coverage.test.ts +232 -0
  2122. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +197 -0
  2123. package/src/resources/extensions/gsd/tests/subagent-agent-discovery.test.ts +91 -0
  2124. package/src/resources/extensions/gsd/tests/subagent-model-dispatch.test.ts +174 -0
  2125. package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +226 -0
  2126. package/src/resources/extensions/gsd/tests/survivor-branch-complete.test.ts +121 -0
  2127. package/src/resources/extensions/gsd/tests/symlink-extension-discovery.test.ts +125 -0
  2128. package/src/resources/extensions/gsd/tests/symlink-numbered-variants.test.ts +145 -0
  2129. package/src/resources/extensions/gsd/tests/sync-lock.test.ts +153 -0
  2130. package/src/resources/extensions/gsd/tests/sync-worktree-skip-current.test.ts +40 -0
  2131. package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
  2132. package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +99 -0
  2133. package/src/resources/extensions/gsd/tests/teardown-chdir-failure-clears-registry.test.ts +162 -0
  2134. package/src/resources/extensions/gsd/tests/teardown-cleanup-parity.test.ts +98 -0
  2135. package/src/resources/extensions/gsd/tests/teardown-failure-clears-registry.test.ts +186 -0
  2136. package/src/resources/extensions/gsd/tests/terminated-transient.test.ts +128 -0
  2137. package/src/resources/extensions/gsd/tests/test-helpers.test.ts +98 -0
  2138. package/src/resources/extensions/gsd/tests/test-helpers.ts +214 -0
  2139. package/src/resources/extensions/gsd/tests/test-utils.ts +165 -0
  2140. package/src/resources/extensions/gsd/tests/token-cost-display.test.ts +118 -0
  2141. package/src/resources/extensions/gsd/tests/token-counter.test.ts +242 -0
  2142. package/src/resources/extensions/gsd/tests/token-profile.test.ts +100 -0
  2143. package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +382 -0
  2144. package/src/resources/extensions/gsd/tests/tool-call-loop-guard.test.ts +179 -0
  2145. package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +306 -0
  2146. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +211 -0
  2147. package/src/resources/extensions/gsd/tests/tool-naming.test.ts +155 -0
  2148. package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +383 -0
  2149. package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +138 -0
  2150. package/src/resources/extensions/gsd/tests/triage-resolution.test.ts +612 -0
  2151. package/src/resources/extensions/gsd/tests/tui-header-lifecycle.test.ts +330 -0
  2152. package/src/resources/extensions/gsd/tests/tui-render-kit.test.ts +88 -0
  2153. package/src/resources/extensions/gsd/tests/turn-epoch.test.ts +153 -0
  2154. package/src/resources/extensions/gsd/tests/uat-stuck-loop-orphaned-worktree.test.ts +289 -0
  2155. package/src/resources/extensions/gsd/tests/unborn-branch.test.ts +85 -0
  2156. package/src/resources/extensions/gsd/tests/undo.test.ts +462 -0
  2157. package/src/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +203 -0
  2158. package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +529 -0
  2159. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +462 -0
  2160. package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +326 -0
  2161. package/src/resources/extensions/gsd/tests/unit-ownership.test.ts +258 -0
  2162. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +335 -0
  2163. package/src/resources/extensions/gsd/tests/unmerged-milestone-guard.test.ts +112 -0
  2164. package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +67 -0
  2165. package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +101 -0
  2166. package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +245 -0
  2167. package/src/resources/extensions/gsd/tests/uok-execution-graph.test.ts +85 -0
  2168. package/src/resources/extensions/gsd/tests/uok-flags.test.ts +69 -0
  2169. package/src/resources/extensions/gsd/tests/uok-gate-runner.test.ts +145 -0
  2170. package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +241 -0
  2171. package/src/resources/extensions/gsd/tests/uok-gitops-wiring.test.ts +58 -0
  2172. package/src/resources/extensions/gsd/tests/uok-kernel-path.test.ts +178 -0
  2173. package/src/resources/extensions/gsd/tests/uok-loop-adapter-writer.test.ts +163 -0
  2174. package/src/resources/extensions/gsd/tests/uok-model-policy.test.ts +89 -0
  2175. package/src/resources/extensions/gsd/tests/uok-parity-report.test.ts +42 -0
  2176. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +262 -0
  2177. package/src/resources/extensions/gsd/tests/uok-preferences.test.ts +42 -0
  2178. package/src/resources/extensions/gsd/tests/uok-writer.test.ts +75 -0
  2179. package/src/resources/extensions/gsd/tests/update-command.test.ts +86 -0
  2180. package/src/resources/extensions/gsd/tests/vacuous-truth-slices.test.ts +115 -0
  2181. package/src/resources/extensions/gsd/tests/vacuum-recovery.test.ts +154 -0
  2182. package/src/resources/extensions/gsd/tests/validate-directory.test.ts +269 -0
  2183. package/src/resources/extensions/gsd/tests/validate-extension-package.test.ts +168 -0
  2184. package/src/resources/extensions/gsd/tests/validate-milestone-prompt-verification-classes.test.ts +21 -0
  2185. package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +300 -0
  2186. package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +371 -0
  2187. package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +766 -0
  2188. package/src/resources/extensions/gsd/tests/validation-block-guard.test.ts +104 -0
  2189. package/src/resources/extensions/gsd/tests/validation-gate-patterns.test.ts +178 -0
  2190. package/src/resources/extensions/gsd/tests/validation.test.ts +72 -0
  2191. package/src/resources/extensions/gsd/tests/validator-scope-parity.test.ts +239 -0
  2192. package/src/resources/extensions/gsd/tests/verdict-parser.test.ts +156 -0
  2193. package/src/resources/extensions/gsd/tests/verification-evidence.test.ts +601 -0
  2194. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +1265 -0
  2195. package/src/resources/extensions/gsd/tests/verification-operational-gate.test.ts +112 -0
  2196. package/src/resources/extensions/gsd/tests/verification-retry-policy.test.ts +83 -0
  2197. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
  2198. package/src/resources/extensions/gsd/tests/verify-artifact-tightened.test.ts +204 -0
  2199. package/src/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +109 -0
  2200. package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +84 -0
  2201. package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +359 -0
  2202. package/src/resources/extensions/gsd/tests/visualizer-views.test.ts +716 -0
  2203. package/src/resources/extensions/gsd/tests/wave1-critical-regressions.test.ts +49 -0
  2204. package/src/resources/extensions/gsd/tests/wave2-events-regressions.test.ts +48 -0
  2205. package/src/resources/extensions/gsd/tests/wave3-session-regressions.test.ts +47 -0
  2206. package/src/resources/extensions/gsd/tests/wave4-write-safety-regressions.test.ts +70 -0
  2207. package/src/resources/extensions/gsd/tests/wave5-consistency-regressions.test.ts +165 -0
  2208. package/src/resources/extensions/gsd/tests/windows-path-normalization.test.ts +97 -0
  2209. package/src/resources/extensions/gsd/tests/worker-model-override.test.ts +56 -0
  2210. package/src/resources/extensions/gsd/tests/worker-registry.test.ts +146 -0
  2211. package/src/resources/extensions/gsd/tests/workflow-custom-engine-dispatch-outcome.test.ts +55 -0
  2212. package/src/resources/extensions/gsd/tests/workflow-custom-engine-iteration.test.ts +93 -0
  2213. package/src/resources/extensions/gsd/tests/workflow-custom-engine-reconcile-outcome.test.ts +108 -0
  2214. package/src/resources/extensions/gsd/tests/workflow-custom-engine-reconcile.test.ts +146 -0
  2215. package/src/resources/extensions/gsd/tests/workflow-custom-engine-retry.test.ts +136 -0
  2216. package/src/resources/extensions/gsd/tests/workflow-custom-engine-verify-outcome.test.ts +95 -0
  2217. package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +313 -0
  2218. package/src/resources/extensions/gsd/tests/workflow-dispatch-ledger.test.ts +82 -0
  2219. package/src/resources/extensions/gsd/tests/workflow-events.test.ts +205 -0
  2220. package/src/resources/extensions/gsd/tests/workflow-install.test.ts +113 -0
  2221. package/src/resources/extensions/gsd/tests/workflow-iteration-completion.test.ts +44 -0
  2222. package/src/resources/extensions/gsd/tests/workflow-journal-reporter.test.ts +49 -0
  2223. package/src/resources/extensions/gsd/tests/workflow-kernel.test.ts +630 -0
  2224. package/src/resources/extensions/gsd/tests/workflow-logger-audit.test.ts +123 -0
  2225. package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +92 -0
  2226. package/src/resources/extensions/gsd/tests/workflow-logger.test.ts +411 -0
  2227. package/src/resources/extensions/gsd/tests/workflow-manifest.test.ts +336 -0
  2228. package/src/resources/extensions/gsd/tests/workflow-mcp-auto-prep.test.ts +76 -0
  2229. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +771 -0
  2230. package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +91 -0
  2231. package/src/resources/extensions/gsd/tests/workflow-phase-reporter.test.ts +40 -0
  2232. package/src/resources/extensions/gsd/tests/workflow-plugins.test.ts +310 -0
  2233. package/src/resources/extensions/gsd/tests/workflow-projections.test.ts +405 -0
  2234. package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
  2235. package/src/resources/extensions/gsd/tests/workflow-reconcile.test.ts +91 -0
  2236. package/src/resources/extensions/gsd/tests/workflow-session-lock.test.ts +135 -0
  2237. package/src/resources/extensions/gsd/tests/workflow-sidecar-iteration.test.ts +110 -0
  2238. package/src/resources/extensions/gsd/tests/workflow-sidecar-queue.test.ts +116 -0
  2239. package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +198 -0
  2240. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1397 -0
  2241. package/src/resources/extensions/gsd/tests/workflow-turn-reporter.test.ts +87 -0
  2242. package/src/resources/extensions/gsd/tests/workflow-unit-dispatch.test.ts +160 -0
  2243. package/src/resources/extensions/gsd/tests/workflow-worker-heartbeat.test.ts +154 -0
  2244. package/src/resources/extensions/gsd/tests/working-output-messages.test.ts +93 -0
  2245. package/src/resources/extensions/gsd/tests/workspace-index.test.ts +38 -0
  2246. package/src/resources/extensions/gsd/tests/workspace.test.ts +196 -0
  2247. package/src/resources/extensions/gsd/tests/worktree-bugfix.test.ts +117 -0
  2248. package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +202 -0
  2249. package/src/resources/extensions/gsd/tests/worktree-db-respawn-truncation.test.ts +219 -0
  2250. package/src/resources/extensions/gsd/tests/worktree-db-same-file.test.ts +165 -0
  2251. package/src/resources/extensions/gsd/tests/worktree-db.test.ts +440 -0
  2252. package/src/resources/extensions/gsd/tests/worktree-expected-warnings.test.ts +39 -0
  2253. package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
  2254. package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +207 -0
  2255. package/src/resources/extensions/gsd/tests/worktree-health-monorepo.test.ts +109 -0
  2256. package/src/resources/extensions/gsd/tests/worktree-health.test.ts +181 -0
  2257. package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +216 -0
  2258. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +397 -0
  2259. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +992 -0
  2260. package/src/resources/extensions/gsd/tests/worktree-main-branch.test.ts +27 -0
  2261. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +290 -0
  2262. package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +110 -0
  2263. package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +242 -0
  2264. package/src/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +165 -0
  2265. package/src/resources/extensions/gsd/tests/worktree-preferences-sync.test.ts +180 -0
  2266. package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
  2267. package/src/resources/extensions/gsd/tests/worktree-projection-writers.test.ts +206 -0
  2268. package/src/resources/extensions/gsd/tests/worktree-root-resolution.test.ts +50 -0
  2269. package/src/resources/extensions/gsd/tests/worktree-root.test.ts +69 -0
  2270. package/src/resources/extensions/gsd/tests/worktree-safety.test.ts +417 -0
  2271. package/src/resources/extensions/gsd/tests/worktree-state-projection.test.ts +120 -0
  2272. package/src/resources/extensions/gsd/tests/worktree-submodule-safety.test.ts +228 -0
  2273. package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +134 -0
  2274. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +705 -0
  2275. package/src/resources/extensions/gsd/tests/worktree-sync-overwrite-loop.test.ts +156 -0
  2276. package/src/resources/extensions/gsd/tests/worktree-sync-tasks.test.ts +85 -0
  2277. package/src/resources/extensions/gsd/tests/worktree-teardown-safety.test.ts +148 -0
  2278. package/src/resources/extensions/gsd/tests/worktree-telemetry.test.ts +283 -0
  2279. package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +206 -0
  2280. package/src/resources/extensions/gsd/tests/worktree.test.ts +304 -0
  2281. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +476 -0
  2282. package/src/resources/extensions/gsd/tests/write-gate-predicates.test.ts +188 -0
  2283. package/src/resources/extensions/gsd/tests/write-gate.test.ts +726 -0
  2284. package/src/resources/extensions/gsd/tests/write-intercept.test.ts +76 -0
  2285. package/src/resources/extensions/gsd/tests/zero-slice-roadmap-guided.test.ts +25 -0
  2286. package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +81 -0
  2287. package/src/resources/extensions/gsd/token-counter.ts +83 -0
  2288. package/src/resources/extensions/gsd/tool-contract.ts +82 -0
  2289. package/src/resources/extensions/gsd/tools/complete-milestone.ts +273 -0
  2290. package/src/resources/extensions/gsd/tools/complete-slice.ts +568 -0
  2291. package/src/resources/extensions/gsd/tools/complete-task.ts +473 -0
  2292. package/src/resources/extensions/gsd/tools/context-mode-tool-result.ts +25 -0
  2293. package/src/resources/extensions/gsd/tools/exec-search-tool.ts +81 -0
  2294. package/src/resources/extensions/gsd/tools/exec-tool.ts +286 -0
  2295. package/src/resources/extensions/gsd/tools/memory-tools.ts +427 -0
  2296. package/src/resources/extensions/gsd/tools/plan-milestone.ts +370 -0
  2297. package/src/resources/extensions/gsd/tools/plan-slice.ts +443 -0
  2298. package/src/resources/extensions/gsd/tools/plan-task.ts +161 -0
  2299. package/src/resources/extensions/gsd/tools/reassess-roadmap.ts +289 -0
  2300. package/src/resources/extensions/gsd/tools/reopen-milestone.ts +152 -0
  2301. package/src/resources/extensions/gsd/tools/reopen-slice.ts +152 -0
  2302. package/src/resources/extensions/gsd/tools/reopen-task.ts +146 -0
  2303. package/src/resources/extensions/gsd/tools/replan-slice.ts +242 -0
  2304. package/src/resources/extensions/gsd/tools/resume-tool.ts +40 -0
  2305. package/src/resources/extensions/gsd/tools/skip-slice.ts +133 -0
  2306. package/src/resources/extensions/gsd/tools/validate-milestone.ts +301 -0
  2307. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +991 -0
  2308. package/src/resources/extensions/gsd/triage-resolution.ts +578 -0
  2309. package/src/resources/extensions/gsd/triage-ui.ts +196 -0
  2310. package/src/resources/extensions/gsd/tui/render-kit.ts +153 -0
  2311. package/src/resources/extensions/gsd/types.ts +721 -0
  2312. package/src/resources/extensions/gsd/undo.ts +465 -0
  2313. package/src/resources/extensions/gsd/unit-context-composer.ts +285 -0
  2314. package/src/resources/extensions/gsd/unit-context-manifest.ts +796 -0
  2315. package/src/resources/extensions/gsd/unit-id.ts +14 -0
  2316. package/src/resources/extensions/gsd/unit-ownership.ts +275 -0
  2317. package/src/resources/extensions/gsd/unit-runtime.ts +267 -0
  2318. package/src/resources/extensions/gsd/unmerged-milestone-guard.ts +150 -0
  2319. package/src/resources/extensions/gsd/uok/audit-toggle.ts +9 -0
  2320. package/src/resources/extensions/gsd/uok/audit.ts +85 -0
  2321. package/src/resources/extensions/gsd/uok/contracts.ts +306 -0
  2322. package/src/resources/extensions/gsd/uok/dispatch-envelope.ts +60 -0
  2323. package/src/resources/extensions/gsd/uok/execution-graph.ts +263 -0
  2324. package/src/resources/extensions/gsd/uok/flags.ts +45 -0
  2325. package/src/resources/extensions/gsd/uok/gate-runner.ts +206 -0
  2326. package/src/resources/extensions/gsd/uok/gitops.ts +80 -0
  2327. package/src/resources/extensions/gsd/uok/kernel.ts +124 -0
  2328. package/src/resources/extensions/gsd/uok/loop-adapter.ts +212 -0
  2329. package/src/resources/extensions/gsd/uok/model-policy.ts +112 -0
  2330. package/src/resources/extensions/gsd/uok/parity-report.ts +84 -0
  2331. package/src/resources/extensions/gsd/uok/plan-v2.ts +209 -0
  2332. package/src/resources/extensions/gsd/uok/timeline.ts +158 -0
  2333. package/src/resources/extensions/gsd/uok/writer.ts +113 -0
  2334. package/src/resources/extensions/gsd/user-input-boundary.ts +166 -0
  2335. package/src/resources/extensions/gsd/validate-directory.ts +186 -0
  2336. package/src/resources/extensions/gsd/validation-block-guard.ts +83 -0
  2337. package/src/resources/extensions/gsd/validation.ts +45 -0
  2338. package/src/resources/extensions/gsd/verdict-parser.ts +110 -0
  2339. package/src/resources/extensions/gsd/verification-evidence.ts +270 -0
  2340. package/src/resources/extensions/gsd/verification-gate.ts +848 -0
  2341. package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
  2342. package/src/resources/extensions/gsd/visualizer-data.ts +953 -0
  2343. package/src/resources/extensions/gsd/visualizer-overlay.ts +570 -0
  2344. package/src/resources/extensions/gsd/visualizer-views.ts +1229 -0
  2345. package/src/resources/extensions/gsd/watch/header-renderer.ts +331 -0
  2346. package/src/resources/extensions/gsd/watch/splash-palette.ts +11 -0
  2347. package/src/resources/extensions/gsd/workflow-dispatch.ts +106 -0
  2348. package/src/resources/extensions/gsd/workflow-engine.ts +38 -0
  2349. package/src/resources/extensions/gsd/workflow-events.ts +166 -0
  2350. package/src/resources/extensions/gsd/workflow-install.ts +422 -0
  2351. package/src/resources/extensions/gsd/workflow-logger.ts +381 -0
  2352. package/src/resources/extensions/gsd/workflow-manifest.ts +260 -0
  2353. package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +60 -0
  2354. package/src/resources/extensions/gsd/workflow-mcp.ts +459 -0
  2355. package/src/resources/extensions/gsd/workflow-migration.ts +340 -0
  2356. package/src/resources/extensions/gsd/workflow-plugins.ts +402 -0
  2357. package/src/resources/extensions/gsd/workflow-projections.ts +567 -0
  2358. package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
  2359. package/src/resources/extensions/gsd/workflow-reconcile.ts +681 -0
  2360. package/src/resources/extensions/gsd/workflow-templates/accessibility-audit.md +88 -0
  2361. package/src/resources/extensions/gsd/workflow-templates/api-breaking-change.md +117 -0
  2362. package/src/resources/extensions/gsd/workflow-templates/bugfix.md +88 -0
  2363. package/src/resources/extensions/gsd/workflow-templates/changelog-gen.md +82 -0
  2364. package/src/resources/extensions/gsd/workflow-templates/ci-bootstrap.md +144 -0
  2365. package/src/resources/extensions/gsd/workflow-templates/dead-code.md +81 -0
  2366. package/src/resources/extensions/gsd/workflow-templates/dep-upgrade.md +75 -0
  2367. package/src/resources/extensions/gsd/workflow-templates/docs-sync.yaml +76 -0
  2368. package/src/resources/extensions/gsd/workflow-templates/env-audit.yaml +88 -0
  2369. package/src/resources/extensions/gsd/workflow-templates/full-project.md +42 -0
  2370. package/src/resources/extensions/gsd/workflow-templates/hotfix.md +46 -0
  2371. package/src/resources/extensions/gsd/workflow-templates/issue-triage.md +84 -0
  2372. package/src/resources/extensions/gsd/workflow-templates/observability-setup.md +133 -0
  2373. package/src/resources/extensions/gsd/workflow-templates/onboarding-check.md +74 -0
  2374. package/src/resources/extensions/gsd/workflow-templates/performance-audit.md +125 -0
  2375. package/src/resources/extensions/gsd/workflow-templates/pr-review.md +67 -0
  2376. package/src/resources/extensions/gsd/workflow-templates/pr-triage.md +83 -0
  2377. package/src/resources/extensions/gsd/workflow-templates/refactor.md +84 -0
  2378. package/src/resources/extensions/gsd/workflow-templates/registry.json +269 -0
  2379. package/src/resources/extensions/gsd/workflow-templates/release.md +118 -0
  2380. package/src/resources/extensions/gsd/workflow-templates/rename-symbol.yaml +99 -0
  2381. package/src/resources/extensions/gsd/workflow-templates/security-audit.md +74 -0
  2382. package/src/resources/extensions/gsd/workflow-templates/small-feature.md +82 -0
  2383. package/src/resources/extensions/gsd/workflow-templates/spike.md +76 -0
  2384. package/src/resources/extensions/gsd/workflow-templates/test-backfill.yaml +73 -0
  2385. package/src/resources/extensions/gsd/workflow-templates.ts +278 -0
  2386. package/src/resources/extensions/gsd/working-output-messages.ts +120 -0
  2387. package/src/resources/extensions/gsd/workspace-index.ts +277 -0
  2388. package/src/resources/extensions/gsd/workspace.ts +95 -0
  2389. package/src/resources/extensions/gsd/worktree-command-bootstrap.ts +46 -0
  2390. package/src/resources/extensions/gsd/worktree-command.ts +834 -0
  2391. package/src/resources/extensions/gsd/worktree-health.ts +178 -0
  2392. package/src/resources/extensions/gsd/worktree-lifecycle.ts +1989 -0
  2393. package/src/resources/extensions/gsd/worktree-manager.ts +909 -0
  2394. package/src/resources/extensions/gsd/worktree-root.ts +182 -0
  2395. package/src/resources/extensions/gsd/worktree-safety.ts +329 -0
  2396. package/src/resources/extensions/gsd/worktree-session-state.ts +35 -0
  2397. package/src/resources/extensions/gsd/worktree-state-projection.ts +447 -0
  2398. package/src/resources/extensions/gsd/worktree-telemetry.ts +366 -0
  2399. package/src/resources/extensions/gsd/worktree.ts +235 -0
  2400. package/src/resources/extensions/gsd/write-intercept.ts +99 -0
  2401. package/src/resources/extensions/mac-tools/extension-manifest.json +16 -0
  2402. package/src/resources/extensions/mac-tools/index.ts +852 -0
  2403. package/src/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
  2404. package/src/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
  2405. package/src/resources/extensions/mcp-client/auth.ts +160 -0
  2406. package/src/resources/extensions/mcp-client/index.ts +526 -0
  2407. package/src/resources/extensions/mcp-client/manager.ts +516 -0
  2408. package/src/resources/extensions/mcp-client/tests/global-config.test.ts +91 -0
  2409. package/src/resources/extensions/mcp-client/tests/manager.test.ts +165 -0
  2410. package/src/resources/extensions/mcp-client/tests/server-name-spaces.test.ts +89 -0
  2411. package/src/resources/extensions/ollama/index.ts +158 -0
  2412. package/src/resources/extensions/ollama/model-capabilities.ts +186 -0
  2413. package/src/resources/extensions/ollama/ndjson-stream.ts +63 -0
  2414. package/src/resources/extensions/ollama/ollama-auth-mode.test.ts +128 -0
  2415. package/src/resources/extensions/ollama/ollama-chat-provider.ts +459 -0
  2416. package/src/resources/extensions/ollama/ollama-client.ts +262 -0
  2417. package/src/resources/extensions/ollama/ollama-commands.ts +248 -0
  2418. package/src/resources/extensions/ollama/ollama-discovery.ts +134 -0
  2419. package/src/resources/extensions/ollama/ollama-status-indicator.test.ts +215 -0
  2420. package/src/resources/extensions/ollama/ollama-tool.ts +287 -0
  2421. package/src/resources/extensions/ollama/tests/model-capabilities.test.ts +258 -0
  2422. package/src/resources/extensions/ollama/tests/ollama-chat-provider-stream.test.ts +82 -0
  2423. package/src/resources/extensions/ollama/tests/ollama-client-timeout-env.test.ts +147 -0
  2424. package/src/resources/extensions/ollama/tests/ollama-client.test.ts +38 -0
  2425. package/src/resources/extensions/ollama/tests/ollama-discovery.test.ts +55 -0
  2426. package/src/resources/extensions/ollama/thinking-parser.ts +116 -0
  2427. package/src/resources/extensions/ollama/types.ts +153 -0
  2428. package/src/resources/extensions/package.json +3 -0
  2429. package/src/resources/extensions/remote-questions/commands.ts +480 -0
  2430. package/src/resources/extensions/remote-questions/config.ts +126 -0
  2431. package/src/resources/extensions/remote-questions/discord-adapter.ts +148 -0
  2432. package/src/resources/extensions/remote-questions/extension-manifest.json +11 -0
  2433. package/src/resources/extensions/remote-questions/format.ts +315 -0
  2434. package/src/resources/extensions/remote-questions/http-client.ts +76 -0
  2435. package/src/resources/extensions/remote-questions/manager.ts +270 -0
  2436. package/src/resources/extensions/remote-questions/mod.ts +16 -0
  2437. package/src/resources/extensions/remote-questions/notify.ts +90 -0
  2438. package/src/resources/extensions/remote-questions/remote-command.ts +437 -0
  2439. package/src/resources/extensions/remote-questions/slack-adapter.ts +141 -0
  2440. package/src/resources/extensions/remote-questions/status.ts +31 -0
  2441. package/src/resources/extensions/remote-questions/store.ts +81 -0
  2442. package/src/resources/extensions/remote-questions/telegram-adapter.ts +231 -0
  2443. package/src/resources/extensions/remote-questions/tests/command-polling.test.ts +256 -0
  2444. package/src/resources/extensions/remote-questions/tests/remote-answer-normalization.test.ts +92 -0
  2445. package/src/resources/extensions/remote-questions/tests/telegram-commands.test.ts +267 -0
  2446. package/src/resources/extensions/remote-questions/types.ts +102 -0
  2447. package/src/resources/extensions/search-the-web/cache.ts +78 -0
  2448. package/src/resources/extensions/search-the-web/command-search-provider.ts +105 -0
  2449. package/src/resources/extensions/search-the-web/extension-manifest.json +13 -0
  2450. package/src/resources/extensions/search-the-web/format.ts +258 -0
  2451. package/src/resources/extensions/search-the-web/http.ts +238 -0
  2452. package/src/resources/extensions/search-the-web/index.ts +64 -0
  2453. package/src/resources/extensions/search-the-web/native-search.ts +276 -0
  2454. package/src/resources/extensions/search-the-web/provider.ts +150 -0
  2455. package/src/resources/extensions/search-the-web/tavily.ts +116 -0
  2456. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +589 -0
  2457. package/src/resources/extensions/search-the-web/tool-llm-context.ts +608 -0
  2458. package/src/resources/extensions/search-the-web/tool-search.ts +677 -0
  2459. package/src/resources/extensions/search-the-web/url-utils.ts +144 -0
  2460. package/src/resources/extensions/shared/cmux-events.ts +59 -0
  2461. package/src/resources/extensions/shared/confirm-ui.ts +126 -0
  2462. package/src/resources/extensions/shared/format-utils.ts +99 -0
  2463. package/src/resources/extensions/shared/frontmatter.ts +117 -0
  2464. package/src/resources/extensions/shared/gsd-phase-state.ts +95 -0
  2465. package/src/resources/extensions/shared/html-shell.ts +412 -0
  2466. package/src/resources/extensions/shared/interview-ui.ts +848 -0
  2467. package/src/resources/extensions/shared/layout-utils.ts +75 -0
  2468. package/src/resources/extensions/shared/mod.ts +31 -0
  2469. package/src/resources/extensions/shared/next-action-ui.ts +226 -0
  2470. package/src/resources/extensions/shared/path-display.ts +19 -0
  2471. package/src/resources/extensions/shared/rtk-session-stats.ts +248 -0
  2472. package/src/resources/extensions/shared/rtk-shared.ts +58 -0
  2473. package/src/resources/extensions/shared/rtk.ts +98 -0
  2474. package/src/resources/extensions/shared/sanitize.ts +55 -0
  2475. package/src/resources/extensions/shared/terminal.ts +28 -0
  2476. package/src/resources/extensions/shared/tests/ask-user-freetext.test.ts +161 -0
  2477. package/src/resources/extensions/shared/tests/format-utils.test.ts +155 -0
  2478. package/src/resources/extensions/shared/tests/gsd-phase-state.test.ts +90 -0
  2479. package/src/resources/extensions/shared/tests/interview-notes-loop.test.ts +198 -0
  2480. package/src/resources/extensions/shared/tests/interview-preview.test.ts +185 -0
  2481. package/src/resources/extensions/shared/tests/next-action-ui-hasui.test.ts +144 -0
  2482. package/src/resources/extensions/shared/tests/preview-layout.test.ts +120 -0
  2483. package/src/resources/extensions/shared/tui.ts +11 -0
  2484. package/src/resources/extensions/shared/ui.ts +401 -0
  2485. package/src/resources/extensions/slash-commands/audit.ts +89 -0
  2486. package/src/resources/extensions/slash-commands/clear.ts +10 -0
  2487. package/src/resources/extensions/slash-commands/create-extension.ts +311 -0
  2488. package/src/resources/extensions/slash-commands/create-slash-command.ts +234 -0
  2489. package/src/resources/extensions/slash-commands/extension-manifest.json +11 -0
  2490. package/src/resources/extensions/slash-commands/index.ts +12 -0
  2491. package/src/resources/extensions/subagent/agents.ts +166 -0
  2492. package/src/resources/extensions/subagent/extension-manifest.json +13 -0
  2493. package/src/resources/extensions/subagent/index.ts +1938 -0
  2494. package/src/resources/extensions/subagent/isolation.ts +504 -0
  2495. package/src/resources/extensions/subagent/launch.ts +131 -0
  2496. package/src/resources/extensions/subagent/run-store.ts +218 -0
  2497. package/src/resources/extensions/subagent/tests/agents-conflicts.test.ts +33 -0
  2498. package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
  2499. package/src/resources/extensions/subagent/tests/model-override.test.ts +55 -0
  2500. package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
  2501. package/src/resources/extensions/subagent/worker-registry.ts +100 -0
  2502. package/src/resources/extensions/ttsr/extension-manifest.json +11 -0
  2503. package/src/resources/extensions/ttsr/index.ts +168 -0
  2504. package/src/resources/extensions/ttsr/rule-loader.ts +75 -0
  2505. package/src/resources/extensions/ttsr/ttsr-interrupt.md +6 -0
  2506. package/src/resources/extensions/ttsr/ttsr-manager.ts +465 -0
  2507. package/src/resources/extensions/universal-config/discovery.ts +104 -0
  2508. package/src/resources/extensions/universal-config/extension-manifest.json +13 -0
  2509. package/src/resources/extensions/universal-config/format.ts +191 -0
  2510. package/src/resources/extensions/universal-config/index.ts +120 -0
  2511. package/src/resources/extensions/universal-config/package.json +11 -0
  2512. package/src/resources/extensions/universal-config/scanners.ts +642 -0
  2513. package/src/resources/extensions/universal-config/tests/discovery.test.ts +119 -0
  2514. package/src/resources/extensions/universal-config/tests/format.test.ts +127 -0
  2515. package/src/resources/extensions/universal-config/tests/scanners.test.ts +456 -0
  2516. package/src/resources/extensions/universal-config/tools.ts +60 -0
  2517. package/src/resources/extensions/universal-config/types.ts +135 -0
  2518. package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
  2519. package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
  2520. package/src/resources/extensions/visual-brief/index.ts +8 -0
  2521. package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
  2522. package/src/resources/extensions/visual-brief/prompts.ts +183 -0
  2523. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
  2524. package/src/resources/extensions/voice/extension-manifest.json +12 -0
  2525. package/src/resources/extensions/voice/index.ts +264 -0
  2526. package/src/resources/extensions/voice/linux-ready.ts +86 -0
  2527. package/src/resources/extensions/voice/speech-recognizer.py +504 -0
  2528. package/src/resources/extensions/voice/speech-recognizer.swift +154 -0
  2529. package/src/resources/extensions/voice/tests/linux-ready.test.ts +140 -0
  2530. package/src/resources/skills/accessibility/SKILL.md +522 -0
  2531. package/src/resources/skills/accessibility/references/WCAG.md +162 -0
  2532. package/src/resources/skills/agent-browser/SKILL.md +517 -0
  2533. package/src/resources/skills/agent-browser/references/authentication.md +202 -0
  2534. package/src/resources/skills/agent-browser/references/commands.md +263 -0
  2535. package/src/resources/skills/agent-browser/references/profiling.md +120 -0
  2536. package/src/resources/skills/agent-browser/references/proxy-support.md +194 -0
  2537. package/src/resources/skills/agent-browser/references/session-management.md +193 -0
  2538. package/src/resources/skills/agent-browser/references/snapshot-refs.md +194 -0
  2539. package/src/resources/skills/agent-browser/references/video-recording.md +173 -0
  2540. package/src/resources/skills/agent-browser/templates/authenticated-session.sh +105 -0
  2541. package/src/resources/skills/agent-browser/templates/capture-workflow.sh +69 -0
  2542. package/src/resources/skills/agent-browser/templates/form-automation.sh +62 -0
  2543. package/src/resources/skills/api-design/SKILL.md +190 -0
  2544. package/src/resources/skills/best-practices/SKILL.md +583 -0
  2545. package/src/resources/skills/btw/SKILL.md +42 -0
  2546. package/src/resources/skills/code-optimizer/SKILL.md +160 -0
  2547. package/src/resources/skills/code-optimizer/references/algorithmic-complexity.md +66 -0
  2548. package/src/resources/skills/code-optimizer/references/build-compilation.md +90 -0
  2549. package/src/resources/skills/code-optimizer/references/bundle-dependencies.md +82 -0
  2550. package/src/resources/skills/code-optimizer/references/caching-memoization.md +76 -0
  2551. package/src/resources/skills/code-optimizer/references/concurrency-async.md +80 -0
  2552. package/src/resources/skills/code-optimizer/references/config-infra.md +71 -0
  2553. package/src/resources/skills/code-optimizer/references/data-structures.md +80 -0
  2554. package/src/resources/skills/code-optimizer/references/database-queries.md +76 -0
  2555. package/src/resources/skills/code-optimizer/references/dead-code-redundancy.md +84 -0
  2556. package/src/resources/skills/code-optimizer/references/error-resilience.md +80 -0
  2557. package/src/resources/skills/code-optimizer/references/io-network.md +89 -0
  2558. package/src/resources/skills/code-optimizer/references/logging-observability.md +64 -0
  2559. package/src/resources/skills/code-optimizer/references/memory-resources.md +66 -0
  2560. package/src/resources/skills/code-optimizer/references/rendering-ui.md +90 -0
  2561. package/src/resources/skills/code-optimizer/references/security-performance.md +68 -0
  2562. package/src/resources/skills/core-web-vitals/SKILL.md +441 -0
  2563. package/src/resources/skills/core-web-vitals/references/LCP.md +208 -0
  2564. package/src/resources/skills/create-gsd-extension/SKILL.md +93 -0
  2565. package/src/resources/skills/create-gsd-extension/references/compaction-session-control.md +77 -0
  2566. package/src/resources/skills/create-gsd-extension/references/custom-commands.md +139 -0
  2567. package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +108 -0
  2568. package/src/resources/skills/create-gsd-extension/references/custom-tools.md +183 -0
  2569. package/src/resources/skills/create-gsd-extension/references/custom-ui.md +490 -0
  2570. package/src/resources/skills/create-gsd-extension/references/events-reference.md +126 -0
  2571. package/src/resources/skills/create-gsd-extension/references/extension-lifecycle.md +64 -0
  2572. package/src/resources/skills/create-gsd-extension/references/extensionapi-reference.md +75 -0
  2573. package/src/resources/skills/create-gsd-extension/references/extensioncontext-reference.md +53 -0
  2574. package/src/resources/skills/create-gsd-extension/references/key-rules-gotchas.md +37 -0
  2575. package/src/resources/skills/create-gsd-extension/references/mode-behavior.md +32 -0
  2576. package/src/resources/skills/create-gsd-extension/references/model-provider-management.md +89 -0
  2577. package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +55 -0
  2578. package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +90 -0
  2579. package/src/resources/skills/create-gsd-extension/references/state-management.md +70 -0
  2580. package/src/resources/skills/create-gsd-extension/references/system-prompt-modification.md +52 -0
  2581. package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
  2582. package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
  2583. package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +104 -0
  2584. package/src/resources/skills/create-gsd-extension/workflows/add-capability.md +57 -0
  2585. package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +176 -0
  2586. package/src/resources/skills/create-gsd-extension/workflows/debug-extension.md +76 -0
  2587. package/src/resources/skills/create-mcp-server/SKILL.md +121 -0
  2588. package/src/resources/skills/create-skill/SKILL.md +186 -0
  2589. package/src/resources/skills/create-skill/references/api-security.md +226 -0
  2590. package/src/resources/skills/create-skill/references/be-clear-and-direct.md +531 -0
  2591. package/src/resources/skills/create-skill/references/common-patterns.md +595 -0
  2592. package/src/resources/skills/create-skill/references/core-principles.md +437 -0
  2593. package/src/resources/skills/create-skill/references/executable-code.md +175 -0
  2594. package/src/resources/skills/create-skill/references/gsd-skill-ecosystem.md +68 -0
  2595. package/src/resources/skills/create-skill/references/iteration-and-testing.md +474 -0
  2596. package/src/resources/skills/create-skill/references/recommended-structure.md +168 -0
  2597. package/src/resources/skills/create-skill/references/skill-structure.md +372 -0
  2598. package/src/resources/skills/create-skill/references/use-xml-tags.md +466 -0
  2599. package/src/resources/skills/create-skill/references/using-scripts.md +113 -0
  2600. package/src/resources/skills/create-skill/references/using-templates.md +112 -0
  2601. package/src/resources/skills/create-skill/references/workflows-and-validation.md +510 -0
  2602. package/src/resources/skills/create-skill/templates/router-skill.md +73 -0
  2603. package/src/resources/skills/create-skill/templates/simple-skill.md +33 -0
  2604. package/src/resources/skills/create-skill/workflows/add-reference.md +96 -0
  2605. package/src/resources/skills/create-skill/workflows/add-script.md +93 -0
  2606. package/src/resources/skills/create-skill/workflows/add-template.md +74 -0
  2607. package/src/resources/skills/create-skill/workflows/add-workflow.md +120 -0
  2608. package/src/resources/skills/create-skill/workflows/audit-skill.md +148 -0
  2609. package/src/resources/skills/create-skill/workflows/create-new-skill.md +196 -0
  2610. package/src/resources/skills/create-skill/workflows/get-guidance.md +121 -0
  2611. package/src/resources/skills/create-skill/workflows/upgrade-to-router.md +161 -0
  2612. package/src/resources/skills/create-skill/workflows/verify-skill.md +204 -0
  2613. package/src/resources/skills/create-workflow/SKILL.md +130 -0
  2614. package/src/resources/skills/create-workflow/references/feature-patterns.md +128 -0
  2615. package/src/resources/skills/create-workflow/references/verification-policies.md +76 -0
  2616. package/src/resources/skills/create-workflow/references/yaml-schema-v1.md +46 -0
  2617. package/src/resources/skills/create-workflow/templates/blog-post-pipeline.yaml +60 -0
  2618. package/src/resources/skills/create-workflow/templates/code-audit.yaml +60 -0
  2619. package/src/resources/skills/create-workflow/templates/release-checklist.yaml +66 -0
  2620. package/src/resources/skills/create-workflow/templates/workflow-definition.yaml +32 -0
  2621. package/src/resources/skills/create-workflow/workflows/create-from-scratch.md +104 -0
  2622. package/src/resources/skills/create-workflow/workflows/create-from-template.md +72 -0
  2623. package/src/resources/skills/debug-like-expert/SKILL.md +231 -0
  2624. package/src/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
  2625. package/src/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
  2626. package/src/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
  2627. package/src/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
  2628. package/src/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
  2629. package/src/resources/skills/decompose-into-slices/SKILL.md +139 -0
  2630. package/src/resources/skills/dependency-upgrade/SKILL.md +158 -0
  2631. package/src/resources/skills/design-an-interface/SKILL.md +102 -0
  2632. package/src/resources/skills/forensics/SKILL.md +153 -0
  2633. package/src/resources/skills/frontend-design/SKILL.md +45 -0
  2634. package/src/resources/skills/github-workflows/SKILL.md +90 -0
  2635. package/src/resources/skills/github-workflows/references/gh/SKILL.md +276 -0
  2636. package/src/resources/skills/github-workflows/references/gh/references/issue-stories.md +204 -0
  2637. package/src/resources/skills/github-workflows/references/gh/references/labels.md +170 -0
  2638. package/src/resources/skills/github-workflows/references/gh/references/milestones.md +158 -0
  2639. package/src/resources/skills/github-workflows/references/gh/references/projects-v2.md +177 -0
  2640. package/src/resources/skills/github-workflows/references/gh/scripts/experiment_cleanup.py +191 -0
  2641. package/src/resources/skills/github-workflows/references/gh/scripts/github_project_setup.py +799 -0
  2642. package/src/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
  2643. package/src/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +608 -0
  2644. package/src/resources/skills/grill-me/SKILL.md +93 -0
  2645. package/src/resources/skills/handoff/SKILL.md +121 -0
  2646. package/src/resources/skills/lint/SKILL.md +145 -0
  2647. package/src/resources/skills/make-interfaces-feel-better/SKILL.md +122 -0
  2648. package/src/resources/skills/make-interfaces-feel-better/animations.md +379 -0
  2649. package/src/resources/skills/make-interfaces-feel-better/performance.md +88 -0
  2650. package/src/resources/skills/make-interfaces-feel-better/surfaces.md +247 -0
  2651. package/src/resources/skills/make-interfaces-feel-better/typography.md +123 -0
  2652. package/src/resources/skills/observability/SKILL.md +174 -0
  2653. package/src/resources/skills/react-best-practices/README.md +123 -0
  2654. package/src/resources/skills/react-best-practices/SKILL.md +136 -0
  2655. package/src/resources/skills/react-best-practices/metadata.json +15 -0
  2656. package/src/resources/skills/react-best-practices/rules/_sections.md +46 -0
  2657. package/src/resources/skills/react-best-practices/rules/_template.md +28 -0
  2658. package/src/resources/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  2659. package/src/resources/skills/react-best-practices/rules/advanced-init-once.md +42 -0
  2660. package/src/resources/skills/react-best-practices/rules/advanced-use-latest.md +39 -0
  2661. package/src/resources/skills/react-best-practices/rules/async-api-routes.md +38 -0
  2662. package/src/resources/skills/react-best-practices/rules/async-defer-await.md +80 -0
  2663. package/src/resources/skills/react-best-practices/rules/async-dependencies.md +51 -0
  2664. package/src/resources/skills/react-best-practices/rules/async-parallel.md +28 -0
  2665. package/src/resources/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
  2666. package/src/resources/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
  2667. package/src/resources/skills/react-best-practices/rules/bundle-conditional.md +31 -0
  2668. package/src/resources/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
  2669. package/src/resources/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  2670. package/src/resources/skills/react-best-practices/rules/bundle-preload.md +50 -0
  2671. package/src/resources/skills/react-best-practices/rules/client-event-listeners.md +74 -0
  2672. package/src/resources/skills/react-best-practices/rules/client-localstorage-schema.md +71 -0
  2673. package/src/resources/skills/react-best-practices/rules/client-passive-event-listeners.md +48 -0
  2674. package/src/resources/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
  2675. package/src/resources/skills/react-best-practices/rules/js-batch-dom-css.md +107 -0
  2676. package/src/resources/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
  2677. package/src/resources/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
  2678. package/src/resources/skills/react-best-practices/rules/js-cache-storage.md +70 -0
  2679. package/src/resources/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
  2680. package/src/resources/skills/react-best-practices/rules/js-early-exit.md +50 -0
  2681. package/src/resources/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
  2682. package/src/resources/skills/react-best-practices/rules/js-index-maps.md +37 -0
  2683. package/src/resources/skills/react-best-practices/rules/js-length-check-first.md +49 -0
  2684. package/src/resources/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
  2685. package/src/resources/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
  2686. package/src/resources/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
  2687. package/src/resources/skills/react-best-practices/rules/rendering-activity.md +26 -0
  2688. package/src/resources/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  2689. package/src/resources/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
  2690. package/src/resources/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
  2691. package/src/resources/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  2692. package/src/resources/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  2693. package/src/resources/skills/react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  2694. package/src/resources/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
  2695. package/src/resources/skills/react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  2696. package/src/resources/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
  2697. package/src/resources/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
  2698. package/src/resources/skills/react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  2699. package/src/resources/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
  2700. package/src/resources/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
  2701. package/src/resources/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  2702. package/src/resources/skills/react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  2703. package/src/resources/skills/react-best-practices/rules/rerender-memo.md +44 -0
  2704. package/src/resources/skills/react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  2705. package/src/resources/skills/react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  2706. package/src/resources/skills/react-best-practices/rules/rerender-transitions.md +40 -0
  2707. package/src/resources/skills/react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  2708. package/src/resources/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
  2709. package/src/resources/skills/react-best-practices/rules/server-auth-actions.md +96 -0
  2710. package/src/resources/skills/react-best-practices/rules/server-cache-lru.md +41 -0
  2711. package/src/resources/skills/react-best-practices/rules/server-cache-react.md +76 -0
  2712. package/src/resources/skills/react-best-practices/rules/server-dedup-props.md +65 -0
  2713. package/src/resources/skills/react-best-practices/rules/server-parallel-fetching.md +83 -0
  2714. package/src/resources/skills/react-best-practices/rules/server-serialization.md +38 -0
  2715. package/src/resources/skills/review/SKILL.md +218 -0
  2716. package/src/resources/skills/security-review/SKILL.md +181 -0
  2717. package/src/resources/skills/spike-wrap-up/SKILL.md +138 -0
  2718. package/src/resources/skills/tdd/SKILL.md +112 -0
  2719. package/src/resources/skills/test/SKILL.md +204 -0
  2720. package/src/resources/skills/userinterface-wiki/SKILL.md +253 -0
  2721. package/src/resources/skills/userinterface-wiki/rules/_sections.md +66 -0
  2722. package/src/resources/skills/userinterface-wiki/rules/_template.md +24 -0
  2723. package/src/resources/skills/userinterface-wiki/rules/a11y-reduced-motion-check.md +30 -0
  2724. package/src/resources/skills/userinterface-wiki/rules/a11y-toggle-setting.md +30 -0
  2725. package/src/resources/skills/userinterface-wiki/rules/a11y-visual-equivalent.md +36 -0
  2726. package/src/resources/skills/userinterface-wiki/rules/a11y-volume-control.md +28 -0
  2727. package/src/resources/skills/userinterface-wiki/rules/appropriate-confirmations-only.md +19 -0
  2728. package/src/resources/skills/userinterface-wiki/rules/appropriate-errors-warnings.md +18 -0
  2729. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-decorative.md +21 -0
  2730. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-high-frequency.md +28 -0
  2731. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-punishing.md +27 -0
  2732. package/src/resources/skills/userinterface-wiki/rules/container-callback-ref.md +31 -0
  2733. package/src/resources/skills/userinterface-wiki/rules/container-guard-initial-zero.md +25 -0
  2734. package/src/resources/skills/userinterface-wiki/rules/container-no-excessive-use.md +13 -0
  2735. package/src/resources/skills/userinterface-wiki/rules/container-overflow-hidden.md +25 -0
  2736. package/src/resources/skills/userinterface-wiki/rules/container-transition-delay.md +21 -0
  2737. package/src/resources/skills/userinterface-wiki/rules/container-two-div-pattern.md +35 -0
  2738. package/src/resources/skills/userinterface-wiki/rules/container-use-resize-observer.md +48 -0
  2739. package/src/resources/skills/userinterface-wiki/rules/context-cleanup-nodes.md +25 -0
  2740. package/src/resources/skills/userinterface-wiki/rules/context-resume-suspended.md +28 -0
  2741. package/src/resources/skills/userinterface-wiki/rules/context-reuse-single.md +30 -0
  2742. package/src/resources/skills/userinterface-wiki/rules/design-filter-for-character.md +25 -0
  2743. package/src/resources/skills/userinterface-wiki/rules/design-noise-for-percussion.md +26 -0
  2744. package/src/resources/skills/userinterface-wiki/rules/design-oscillator-for-tonal.md +22 -0
  2745. package/src/resources/skills/userinterface-wiki/rules/duration-max-300ms.md +21 -0
  2746. package/src/resources/skills/userinterface-wiki/rules/duration-press-hover.md +21 -0
  2747. package/src/resources/skills/userinterface-wiki/rules/duration-shorten-before-curve.md +21 -0
  2748. package/src/resources/skills/userinterface-wiki/rules/duration-small-state.md +15 -0
  2749. package/src/resources/skills/userinterface-wiki/rules/easing-entrance-ease-out.md +21 -0
  2750. package/src/resources/skills/userinterface-wiki/rules/easing-exit-ease-in.md +21 -0
  2751. package/src/resources/skills/userinterface-wiki/rules/easing-for-state-change.md +27 -0
  2752. package/src/resources/skills/userinterface-wiki/rules/easing-linear-only-progress.md +21 -0
  2753. package/src/resources/skills/userinterface-wiki/rules/easing-natural-decay.md +22 -0
  2754. package/src/resources/skills/userinterface-wiki/rules/easing-no-linear-motion.md +22 -0
  2755. package/src/resources/skills/userinterface-wiki/rules/easing-transition-ease-in-out.md +15 -0
  2756. package/src/resources/skills/userinterface-wiki/rules/envelope-exponential-decay.md +21 -0
  2757. package/src/resources/skills/userinterface-wiki/rules/envelope-no-zero-target.md +21 -0
  2758. package/src/resources/skills/userinterface-wiki/rules/envelope-set-initial-value.md +22 -0
  2759. package/src/resources/skills/userinterface-wiki/rules/exit-key-required.md +29 -0
  2760. package/src/resources/skills/userinterface-wiki/rules/exit-matches-initial.md +29 -0
  2761. package/src/resources/skills/userinterface-wiki/rules/exit-prop-required.md +33 -0
  2762. package/src/resources/skills/userinterface-wiki/rules/exit-requires-wrapper.md +27 -0
  2763. package/src/resources/skills/userinterface-wiki/rules/impl-default-subtle.md +21 -0
  2764. package/src/resources/skills/userinterface-wiki/rules/impl-preload-audio.md +34 -0
  2765. package/src/resources/skills/userinterface-wiki/rules/impl-reset-current-time.md +26 -0
  2766. package/src/resources/skills/userinterface-wiki/rules/mode-pop-layout-for-lists.md +25 -0
  2767. package/src/resources/skills/userinterface-wiki/rules/mode-sync-layout-conflict.md +29 -0
  2768. package/src/resources/skills/userinterface-wiki/rules/mode-wait-doubles-duration.md +25 -0
  2769. package/src/resources/skills/userinterface-wiki/rules/morphing-aria-hidden.md +21 -0
  2770. package/src/resources/skills/userinterface-wiki/rules/morphing-consistent-viewbox.md +23 -0
  2771. package/src/resources/skills/userinterface-wiki/rules/morphing-group-variants.md +33 -0
  2772. package/src/resources/skills/userinterface-wiki/rules/morphing-jump-non-grouped.md +29 -0
  2773. package/src/resources/skills/userinterface-wiki/rules/morphing-reduced-motion.md +28 -0
  2774. package/src/resources/skills/userinterface-wiki/rules/morphing-spring-rotation.md +23 -0
  2775. package/src/resources/skills/userinterface-wiki/rules/morphing-strokelinecap-round.md +21 -0
  2776. package/src/resources/skills/userinterface-wiki/rules/morphing-three-lines.md +32 -0
  2777. package/src/resources/skills/userinterface-wiki/rules/morphing-use-collapsed.md +33 -0
  2778. package/src/resources/skills/userinterface-wiki/rules/native-backdrop-styling.md +27 -0
  2779. package/src/resources/skills/userinterface-wiki/rules/native-placeholder-styling.md +27 -0
  2780. package/src/resources/skills/userinterface-wiki/rules/native-selection-styling.md +18 -0
  2781. package/src/resources/skills/userinterface-wiki/rules/nested-consistent-timing.md +25 -0
  2782. package/src/resources/skills/userinterface-wiki/rules/nested-propagate-required.md +41 -0
  2783. package/src/resources/skills/userinterface-wiki/rules/none-context-menu-entrance.md +25 -0
  2784. package/src/resources/skills/userinterface-wiki/rules/none-high-frequency.md +29 -0
  2785. package/src/resources/skills/userinterface-wiki/rules/none-keyboard-navigation.md +32 -0
  2786. package/src/resources/skills/userinterface-wiki/rules/param-click-duration.md +21 -0
  2787. package/src/resources/skills/userinterface-wiki/rules/param-filter-frequency-range.md +21 -0
  2788. package/src/resources/skills/userinterface-wiki/rules/param-q-value-range.md +21 -0
  2789. package/src/resources/skills/userinterface-wiki/rules/param-reasonable-gain.md +21 -0
  2790. package/src/resources/skills/userinterface-wiki/rules/physics-active-state.md +23 -0
  2791. package/src/resources/skills/userinterface-wiki/rules/physics-no-excessive-stagger.md +22 -0
  2792. package/src/resources/skills/userinterface-wiki/rules/physics-spring-for-overshoot.md +23 -0
  2793. package/src/resources/skills/userinterface-wiki/rules/physics-subtle-deformation.md +22 -0
  2794. package/src/resources/skills/userinterface-wiki/rules/prefetch-hit-slop.md +27 -0
  2795. package/src/resources/skills/userinterface-wiki/rules/prefetch-keyboard-tab.md +19 -0
  2796. package/src/resources/skills/userinterface-wiki/rules/prefetch-not-everything.md +22 -0
  2797. package/src/resources/skills/userinterface-wiki/rules/prefetch-touch-fallback.md +34 -0
  2798. package/src/resources/skills/userinterface-wiki/rules/prefetch-trajectory-over-hover.md +32 -0
  2799. package/src/resources/skills/userinterface-wiki/rules/prefetch-use-selectively.md +13 -0
  2800. package/src/resources/skills/userinterface-wiki/rules/presence-disable-interactions.md +31 -0
  2801. package/src/resources/skills/userinterface-wiki/rules/presence-hook-in-child.md +31 -0
  2802. package/src/resources/skills/userinterface-wiki/rules/presence-safe-to-remove.md +37 -0
  2803. package/src/resources/skills/userinterface-wiki/rules/pseudo-content-required.md +28 -0
  2804. package/src/resources/skills/userinterface-wiki/rules/pseudo-first-line-styling.md +27 -0
  2805. package/src/resources/skills/userinterface-wiki/rules/pseudo-hit-target-expansion.md +31 -0
  2806. package/src/resources/skills/userinterface-wiki/rules/pseudo-marker-styling.md +28 -0
  2807. package/src/resources/skills/userinterface-wiki/rules/pseudo-over-dom-node.md +32 -0
  2808. package/src/resources/skills/userinterface-wiki/rules/pseudo-position-relative-parent.md +33 -0
  2809. package/src/resources/skills/userinterface-wiki/rules/pseudo-z-index-layering.md +37 -0
  2810. package/src/resources/skills/userinterface-wiki/rules/spring-for-gestures.md +27 -0
  2811. package/src/resources/skills/userinterface-wiki/rules/spring-for-interruptible.md +27 -0
  2812. package/src/resources/skills/userinterface-wiki/rules/spring-params-balanced.md +29 -0
  2813. package/src/resources/skills/userinterface-wiki/rules/spring-preserves-velocity.md +28 -0
  2814. package/src/resources/skills/userinterface-wiki/rules/staging-dim-background.md +22 -0
  2815. package/src/resources/skills/userinterface-wiki/rules/staging-one-focal-point.md +24 -0
  2816. package/src/resources/skills/userinterface-wiki/rules/staging-z-index-hierarchy.md +22 -0
  2817. package/src/resources/skills/userinterface-wiki/rules/timing-consistent.md +24 -0
  2818. package/src/resources/skills/userinterface-wiki/rules/timing-no-entrance-context-menu.md +22 -0
  2819. package/src/resources/skills/userinterface-wiki/rules/timing-under-300ms.md +22 -0
  2820. package/src/resources/skills/userinterface-wiki/rules/transition-name-cleanup.md +28 -0
  2821. package/src/resources/skills/userinterface-wiki/rules/transition-name-required.md +27 -0
  2822. package/src/resources/skills/userinterface-wiki/rules/transition-name-unique.md +24 -0
  2823. package/src/resources/skills/userinterface-wiki/rules/transition-over-js-library.md +32 -0
  2824. package/src/resources/skills/userinterface-wiki/rules/transition-style-pseudo-elements.md +24 -0
  2825. package/src/resources/skills/userinterface-wiki/rules/type-antialiased-on-retina.md +18 -0
  2826. package/src/resources/skills/userinterface-wiki/rules/type-disambiguation-stylistic-set.md +15 -0
  2827. package/src/resources/skills/userinterface-wiki/rules/type-font-display-swap.md +28 -0
  2828. package/src/resources/skills/userinterface-wiki/rules/type-justify-with-hyphens.md +24 -0
  2829. package/src/resources/skills/userinterface-wiki/rules/type-letter-spacing-uppercase.md +28 -0
  2830. package/src/resources/skills/userinterface-wiki/rules/type-no-font-synthesis.md +18 -0
  2831. package/src/resources/skills/userinterface-wiki/rules/type-oldstyle-nums-for-prose.md +21 -0
  2832. package/src/resources/skills/userinterface-wiki/rules/type-opentype-contextual-alternates.md +15 -0
  2833. package/src/resources/skills/userinterface-wiki/rules/type-optical-sizing-auto.md +25 -0
  2834. package/src/resources/skills/userinterface-wiki/rules/type-proper-fractions.md +15 -0
  2835. package/src/resources/skills/userinterface-wiki/rules/type-slashed-zero.md +17 -0
  2836. package/src/resources/skills/userinterface-wiki/rules/type-tabular-nums-for-data.md +21 -0
  2837. package/src/resources/skills/userinterface-wiki/rules/type-text-wrap-balance-headings.md +21 -0
  2838. package/src/resources/skills/userinterface-wiki/rules/type-text-wrap-pretty.md +16 -0
  2839. package/src/resources/skills/userinterface-wiki/rules/type-underline-offset.md +25 -0
  2840. package/src/resources/skills/userinterface-wiki/rules/type-variable-weight-continuous.md +23 -0
  2841. package/src/resources/skills/userinterface-wiki/rules/ux-aesthetic-usability.md +32 -0
  2842. package/src/resources/skills/userinterface-wiki/rules/ux-cognitive-load-reduce.md +49 -0
  2843. package/src/resources/skills/userinterface-wiki/rules/ux-common-region-boundaries.md +50 -0
  2844. package/src/resources/skills/userinterface-wiki/rules/ux-doherty-perceived-speed.md +29 -0
  2845. package/src/resources/skills/userinterface-wiki/rules/ux-doherty-under-400ms.md +30 -0
  2846. package/src/resources/skills/userinterface-wiki/rules/ux-fitts-hit-area.md +32 -0
  2847. package/src/resources/skills/userinterface-wiki/rules/ux-fitts-target-size.md +31 -0
  2848. package/src/resources/skills/userinterface-wiki/rules/ux-goal-gradient-progress.md +33 -0
  2849. package/src/resources/skills/userinterface-wiki/rules/ux-hicks-minimize-choices.md +45 -0
  2850. package/src/resources/skills/userinterface-wiki/rules/ux-jakobs-familiar-patterns.md +37 -0
  2851. package/src/resources/skills/userinterface-wiki/rules/ux-millers-chunking.md +23 -0
  2852. package/src/resources/skills/userinterface-wiki/rules/ux-pareto-prioritize-features.md +36 -0
  2853. package/src/resources/skills/userinterface-wiki/rules/ux-peak-end-finish-strong.md +35 -0
  2854. package/src/resources/skills/userinterface-wiki/rules/ux-postels-accept-messy-input.md +45 -0
  2855. package/src/resources/skills/userinterface-wiki/rules/ux-pragnanz-simplify.md +33 -0
  2856. package/src/resources/skills/userinterface-wiki/rules/ux-progressive-disclosure.md +41 -0
  2857. package/src/resources/skills/userinterface-wiki/rules/ux-proximity-grouping.md +38 -0
  2858. package/src/resources/skills/userinterface-wiki/rules/ux-serial-position.md +31 -0
  2859. package/src/resources/skills/userinterface-wiki/rules/ux-similarity-consistency.md +35 -0
  2860. package/src/resources/skills/userinterface-wiki/rules/ux-teslers-complexity.md +28 -0
  2861. package/src/resources/skills/userinterface-wiki/rules/ux-uniform-connectedness.md +43 -0
  2862. package/src/resources/skills/userinterface-wiki/rules/ux-von-restorff-emphasis.md +29 -0
  2863. package/src/resources/skills/userinterface-wiki/rules/ux-zeigarnik-show-incomplete.md +36 -0
  2864. package/src/resources/skills/userinterface-wiki/rules/visual-animate-shadow-pseudo.md +49 -0
  2865. package/src/resources/skills/userinterface-wiki/rules/visual-border-alpha-colors.md +25 -0
  2866. package/src/resources/skills/userinterface-wiki/rules/visual-button-shadow-anatomy.md +49 -0
  2867. package/src/resources/skills/userinterface-wiki/rules/visual-concentric-radius.md +40 -0
  2868. package/src/resources/skills/userinterface-wiki/rules/visual-consistent-spacing-scale.md +35 -0
  2869. package/src/resources/skills/userinterface-wiki/rules/visual-layered-shadows.md +30 -0
  2870. package/src/resources/skills/userinterface-wiki/rules/visual-no-pure-black-shadow.md +25 -0
  2871. package/src/resources/skills/userinterface-wiki/rules/visual-shadow-direction.md +25 -0
  2872. package/src/resources/skills/userinterface-wiki/rules/visual-shadow-matches-elevation.md +23 -0
  2873. package/src/resources/skills/userinterface-wiki/rules/weight-duration-matches-action.md +29 -0
  2874. package/src/resources/skills/userinterface-wiki/rules/weight-match-action.md +32 -0
  2875. package/src/resources/skills/verify-before-complete/SKILL.md +98 -0
  2876. package/src/resources/skills/web-design-guidelines/SKILL.md +39 -0
  2877. package/src/resources/skills/web-quality-audit/SKILL.md +168 -0
  2878. package/src/resources/skills/web-quality-audit/scripts/analyze.sh +91 -0
  2879. package/src/resources/skills/write-docs/SKILL.md +82 -0
  2880. package/src/resources/skills/write-milestone-brief/SKILL.md +135 -0
@@ -0,0 +1,2887 @@
1
+ /**
2
+ * GSD Guided Flow — Smart Entry Wizard
3
+ *
4
+ * One function: showSmartEntry(). Reads state from disk, shows a contextual
5
+ * wizard via showNextAction(), and dispatches through GSD-WORKFLOW.md.
6
+ * No execution state, no hooks, no tools — the LLM does the rest.
7
+ */
8
+
9
+ import type { ExtensionAPI, ExtensionContext, ExtensionCommandContext } from "@gsd/pi-coding-agent";
10
+ import type { GSDState } from "./types.js";
11
+ import { showNextAction } from "../shared/tui.js";
12
+ import { loadFile, saveFile } from "./files.js";
13
+ import { isDbAvailable, getMilestone, getMilestoneSlices } from "./gsd-db.js";
14
+ import { parseRoadmapSlices } from "./roadmap-slices.js";
15
+ import { loadPrompt, inlineTemplate } from "./prompt-loader.js";
16
+ import {
17
+ buildCompleteSlicePrompt,
18
+ buildDiscussMilestonePrompt,
19
+ buildExecuteTaskPrompt,
20
+ buildPlanMilestonePrompt,
21
+ buildPlanSlicePrompt,
22
+ buildSkillActivationBlock,
23
+ } from "./auto-prompts.js";
24
+ import { deriveState, isGhostMilestone } from "./state.js";
25
+ import { invalidateAllCaches } from "./cache.js";
26
+ import { startAutoDetached } from "./auto.js";
27
+ import { clearLock } from "./crash-recovery.js";
28
+ import {
29
+ assessInterruptedSession,
30
+ formatInterruptedSessionRunningMessage,
31
+ formatInterruptedSessionSummary,
32
+ } from "./interrupted-session.js";
33
+ import { listUnitRuntimeRecords, clearUnitRuntimeRecord, isInFlightRuntimePhase } from "./unit-runtime.js";
34
+ import { resolveExpectedArtifactPath } from "./auto.js";
35
+ import { gsdHome } from "./gsd-home.js";
36
+ import {
37
+ gsdRoot, milestonesDir, resolveMilestoneFile, resolveMilestonePath,
38
+ resolveSliceFile, resolveSlicePath, resolveGsdRootFile, relGsdRootFile,
39
+ relMilestoneFile, relSliceFile, clearPathCache,
40
+ } from "./paths.js";
41
+ import { join } from "node:path";
42
+ import { readFileSync, existsSync, mkdirSync, readdirSync, rmSync, unlinkSync } from "node:fs";
43
+ import { readSessionLockData, isSessionLockProcessAlive } from "./session-lock.js";
44
+ import { nativeAddAll, nativeCommit, nativeHasCommittedHead, nativeIsRepo, nativeInit } from "./native-git-bridge.js";
45
+ import { isInheritedRepo } from "./repo-identity.js";
46
+ import { ensureGitignore, ensurePreferences, untrackRuntimeFiles } from "./gitignore.js";
47
+ import { getIsolationMode, loadEffectiveGSDPreferences } from "./preferences.js";
48
+ import { resolveUokFlags } from "./uok/flags.js";
49
+ import { ensurePlanV2Graph, isMissingFinalizedContextResult } from "./uok/plan-v2.js";
50
+ import { detectProjectState, hasGsdBootstrapArtifacts } from "./detection.js";
51
+ import { isFutureMilestoneStatus } from "./status-guards.js";
52
+ import { showProjectInit, offerMigration } from "./init-wizard.js";
53
+ import { validateDirectory } from "./validate-directory.js";
54
+ import { showConfirm } from "../shared/tui.js";
55
+ import { debugLog } from "./debug-logger.js";
56
+ import { findMilestoneIds, clearReservedMilestoneIds } from "./milestone-ids.js";
57
+ import { nextMilestoneIdReserved } from "./milestone-id-reservation.js";
58
+ export { nextMilestoneIdReserved } from "./milestone-id-reservation.js";
59
+ import { parkMilestone, discardMilestone } from "./milestone-actions.js";
60
+ import { selectAndApplyModel } from "./auto-model-selection.js";
61
+ import { DISCUSS_TOOLS_ALLOWLIST } from "./constants.js";
62
+ import {
63
+ getWorkflowTransportSupportError,
64
+ getRequiredWorkflowToolsForGuidedUnit,
65
+ supportsStructuredQuestions,
66
+ } from "./workflow-mcp.js";
67
+ import {
68
+ runPreparation,
69
+ formatCodebaseBrief,
70
+ formatPriorContextBrief,
71
+ } from "./preparation.js";
72
+ import { verifyExpectedArtifact } from "./auto-recovery.js";
73
+ import type { MilestoneScope } from "./workspace.js";
74
+ import { getPendingGate, extractDepthVerificationMilestoneId } from "./bootstrap/write-gate.js";
75
+ import {
76
+ _getPendingAutoStart,
77
+ clearPendingAutoStart,
78
+ deletePendingAutoStart,
79
+ getDiscussionMilestoneId,
80
+ hasPendingAutoStart,
81
+ setPendingAutoStart,
82
+ } from "./pending-auto-start.js";
83
+ import { clearGuidedUnitContext, setGuidedUnitContext } from "./guided-unit-context.js";
84
+
85
+ export {
86
+ _getPendingAutoStart,
87
+ clearPendingAutoStart,
88
+ getDiscussionMilestoneId,
89
+ setPendingAutoStart,
90
+ } from "./pending-auto-start.js";
91
+
92
+ export function shouldSkipGitBootstrapAfterInit(result: { gitEnabled?: boolean }): boolean {
93
+ return result.gitEnabled === false;
94
+ }
95
+
96
+ // ─── Re-exports (preserve public API for existing importers) ────────────────
97
+ export {
98
+ MILESTONE_ID_RE, generateMilestoneSuffix, nextMilestoneId,
99
+ extractMilestoneSeq, parseMilestoneId, milestoneIdSort,
100
+ maxMilestoneNum, findMilestoneIds,
101
+ reserveMilestoneId, claimReservedId, getReservedMilestoneIds, clearReservedMilestoneIds,
102
+ } from "./milestone-ids.js";
103
+ export {
104
+ showQueue, handleQueueReorder, showQueueAdd,
105
+ buildExistingMilestonesContext,
106
+ } from "./guided-flow-queue.js";
107
+ import { logWarning } from "./workflow-logger.js";
108
+ import { readManifest } from "./workflow-manifest.js";
109
+ import { deleteRuntimeKv } from "./db/runtime-kv.js";
110
+ import { PAUSED_SESSION_KV_KEY } from "./interrupted-session.js";
111
+ import { buildWorkflowDispatchContent } from "./workflow-protocol.js";
112
+ import { isFullGsdToolSurfaceRequested, restoreGsdWorkflowTools, scopeGsdWorkflowToolsForDispatch } from "./bootstrap/register-hooks.js";
113
+ import {
114
+ resolveActiveTaskChoiceRoute,
115
+ type ActiveTaskChoice,
116
+ } from "./smart-entry-routing.js";
117
+
118
+ export { resolveGuidedExecuteLaunchMode } from "./smart-entry-routing.js";
119
+
120
+ export interface HeadlessMilestoneCreationOptions {
121
+ startAutoAfterReady?: boolean;
122
+ }
123
+
124
+ type AutoStartOptions = Parameters<typeof startAutoDetached>[4];
125
+ type AutoStartLauncher = typeof startAutoDetached;
126
+
127
+ function scheduleAutoStartAfterIdle(
128
+ ctx: ExtensionCommandContext,
129
+ pi: ExtensionAPI,
130
+ basePath: string,
131
+ verboseMode: boolean,
132
+ options?: AutoStartOptions,
133
+ launch: AutoStartLauncher = startAutoDetached,
134
+ ): void {
135
+ const waitForIdle =
136
+ typeof (ctx as { waitForIdle?: unknown }).waitForIdle === "function"
137
+ ? ctx.waitForIdle.bind(ctx)
138
+ : async () => {};
139
+ void waitForIdle()
140
+ .then(() => {
141
+ setTimeout(() => launch(ctx, pi, basePath, verboseMode, options), 0);
142
+ })
143
+ .catch((err) => {
144
+ const message = err instanceof Error ? err.message : String(err);
145
+ ctx.ui.notify(`Auto-start failed while waiting for the prior turn to settle: ${message}`, "error");
146
+ logWarning("guided", `auto-start idle wait failed: ${message}`);
147
+ });
148
+ }
149
+
150
+ export const _scheduleAutoStartAfterIdleForTest = scheduleAutoStartAfterIdle;
151
+
152
+ // ─── Scope-based validator wrappers ──────────────────────────────────────────
153
+ // These thin wrappers accept a MilestoneScope so callers that already hold a
154
+ // pinned scope never have to re-derive (basePath, milestoneId) separately.
155
+ // The underlying implementations in auto-recovery.ts / auto-artifact-paths.ts /
156
+ // state.ts are unchanged — only the call surface in guided-flow.ts is migrated.
157
+
158
+ /**
159
+ * Scope-based overload of verifyExpectedArtifact.
160
+ * Uses scope.workspace.projectRoot as the authoritative base path, making
161
+ * the check immune to cwd-drift and worktree-path divergence.
162
+ */
163
+ export function verifyExpectedArtifactForScope(
164
+ scope: MilestoneScope,
165
+ unitType: string,
166
+ unitId: string,
167
+ ): boolean {
168
+ return verifyExpectedArtifact(unitType, unitId, scope.workspace.projectRoot);
169
+ }
170
+
171
+ /**
172
+ * Scope-based overload of resolveExpectedArtifactPath.
173
+ * Returns the canonical absolute path (or null) using the scope's projectRoot.
174
+ */
175
+ export function resolveExpectedArtifactPathForScope(
176
+ scope: MilestoneScope,
177
+ unitType: string,
178
+ unitId: string,
179
+ ): string | null {
180
+ return resolveExpectedArtifactPath(unitType, unitId, scope.workspace.projectRoot);
181
+ }
182
+
183
+ async function runQuickTaskChoice(ctx: ExtensionCommandContext, pi: ExtensionAPI): Promise<void> {
184
+ if (!ctx.hasUI) {
185
+ ctx.ui.notify("Run /gsd quick <task> for small bounded work, or /gsd do <task> for natural-language routing.", "info");
186
+ return;
187
+ }
188
+
189
+ const task = (await ctx.ui.input("Quick task", "Describe the small task to run with /gsd quick"))?.trim();
190
+ if (!task) {
191
+ ctx.ui.notify("Quick task cancelled.", "info");
192
+ return;
193
+ }
194
+
195
+ const { handleQuick } = await import("./quick.js");
196
+ await handleQuick(task, ctx, pi);
197
+ }
198
+
199
+ function isNonInteractiveContext(ctx: ExtensionCommandContext): boolean {
200
+ if (!ctx.hasUI) return true;
201
+ return process.env.GSD_HEADLESS === "1" || process.env.GSD_WEB_BRIDGE_TUI === "1";
202
+ }
203
+
204
+ /**
205
+ * Scope-based overload of isGhostMilestone.
206
+ * Binds basePath and milestoneId from the scope, ensuring path resolution
207
+ * uses the canonical project root regardless of the cwd at call time.
208
+ */
209
+ export function isGhostMilestoneByScope(scope: MilestoneScope): boolean {
210
+ return isGhostMilestone(scope.workspace.projectRoot, scope.milestoneId);
211
+ }
212
+
213
+ function needsPlanV2Gate(state: GSDState): boolean {
214
+ return state.phase === "executing"
215
+ || state.phase === "summarizing"
216
+ || state.phase === "validating-milestone"
217
+ || state.phase === "completing-milestone";
218
+ }
219
+
220
+ type PlanV2GateDecision = "pass" | "recover-missing-context" | "block";
221
+
222
+ function runPlanV2Gate(
223
+ ctx: ExtensionContext,
224
+ basePath: string,
225
+ state: GSDState,
226
+ ): PlanV2GateDecision {
227
+ const prefs = loadEffectiveGSDPreferences(basePath)?.preferences;
228
+ const uokFlags = resolveUokFlags(prefs);
229
+ if (!uokFlags.planV2 || !needsPlanV2Gate(state)) return "pass";
230
+ const compiled = ensurePlanV2Graph(basePath, state);
231
+ if (!compiled.ok) {
232
+ if (isMissingFinalizedContextResult(compiled)) {
233
+ return "recover-missing-context";
234
+ }
235
+ const reason = compiled.reason ?? "plan-v2 compilation failed";
236
+ ctx.ui.notify(
237
+ `Plan gate failed-closed: ${reason}. Complete plan/discuss artifacts before execution.\n\nIf this keeps happening, try: /gsd doctor heal`,
238
+ "error",
239
+ );
240
+ return "block";
241
+ }
242
+ return "pass";
243
+ }
244
+
245
+ export const _needsPlanV2GateForTest = needsPlanV2Gate;
246
+ export const _runPlanV2GateForTest = runPlanV2Gate;
247
+
248
+ export function _roadmapHasParseableSlicesForTest(
249
+ roadmapContent: string | null | undefined,
250
+ ): boolean {
251
+ if (!roadmapContent) return false;
252
+ return parseRoadmapSlices(roadmapContent).length > 0;
253
+ }
254
+
255
+ // ─── Commit Instruction Helpers ──────────────────────────────────────────────
256
+
257
+ /** Build commit instruction for planning prompts. .gsd/ is managed externally and always gitignored. */
258
+ function buildDocsCommitInstruction(_message: string): string {
259
+ return "Do not commit planning artifacts — .gsd/ is managed externally.";
260
+ }
261
+
262
+ // ─── Auto-start after discuss ─────────────────────────────────────────────────
263
+
264
+ interface PendingDeepProjectSetupEntry {
265
+ ctx: ExtensionCommandContext;
266
+ pi: ExtensionAPI;
267
+ basePath: string;
268
+ step?: boolean;
269
+ createdAt: number;
270
+ sessionId?: string;
271
+ currentUnitType?: string;
272
+ currentUnitId?: string;
273
+ }
274
+
275
+ // #4573: cap for how many times we nudge the LLM after a premature ready
276
+ // phrase before giving up and asking the user to re-run /gsd.
277
+ const MAX_READY_REJECTS = 2;
278
+
279
+ // H1 (#5012): cap for Gate 1b plan-blocked recovery hints. After this many
280
+ // consecutive recovery attempts the loop is stopped and the user is directed
281
+ // to investigate manually.
282
+ const MAX_PLAN_BLOCKED_RECOVERIES = 3;
283
+
284
+ // #4573: matches the canonical ready phrase the discuss prompt asks the LLM
285
+ // to emit. Accepts any M-prefixed milestone ID (three digits + optional
286
+ // suffix) with optional trailing punctuation.
287
+ const READY_PHRASE_RE = /\bMilestone\s+M\d{3}[A-Z0-9-]*\s+ready\.?/i;
288
+
289
+ const pendingDeepProjectSetupMap = new Map<string, PendingDeepProjectSetupEntry>();
290
+ const USER_DRIVEN_DEEP_SETUP_UNITS = new Set([
291
+ "discuss-project",
292
+ "discuss-requirements",
293
+ "research-decision",
294
+ ]);
295
+ export const FOREGROUND_DEEP_SETUP_RULE_NAMES = new Set([
296
+ "deep: pre-planning (no workflow prefs) → workflow-preferences",
297
+ "deep: pre-planning (no PROJECT) → discuss-project",
298
+ "deep: pre-planning (no REQUIREMENTS) → discuss-requirements",
299
+ "deep: pre-planning (no research decision) → research-decision",
300
+ ]);
301
+ const LEGACY_DEEP_SETUP_PSEUDO_MILESTONE_DIRS = new Set([
302
+ "PROJECT",
303
+ "REQUIREMENTS",
304
+ "RESEARCH-DECISION",
305
+ "RESEARCH-PROJECT",
306
+ "WORKFLOW-PREFS",
307
+ ]);
308
+ const FOREGROUND_DEEP_SETUP_QUESTION_POLICY = `## Foreground Deep Setup Question Policy
309
+
310
+ This stage is running inside the foreground \`/gsd new-project --deep\` interview. Ask user questions in plain chat only.
311
+
312
+ - Do NOT call \`ask_user_questions\`, \`AskUserQuestion\`, or ToolSearch to discover user-input tools.
313
+ - Ask one focused round, then stop and wait for the user's normal chat response.`;
314
+
315
+ function hasNestedFileOrSymlink(dir: string): boolean {
316
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
317
+ if (entry.isFile() || entry.isSymbolicLink()) return true;
318
+ if (entry.isDirectory() && hasNestedFileOrSymlink(join(dir, entry.name))) return true;
319
+ }
320
+ return false;
321
+ }
322
+
323
+ function clearEmptyLegacyDeepSetupPseudoMilestones(basePath: string, entries: string[]): string[] {
324
+ const mDir = milestonesDir(basePath);
325
+ const remaining: string[] = [];
326
+ for (const entry of entries) {
327
+ if (!LEGACY_DEEP_SETUP_PSEUDO_MILESTONE_DIRS.has(entry)) {
328
+ remaining.push(entry);
329
+ continue;
330
+ }
331
+
332
+ const entryPath = join(mDir, entry);
333
+ try {
334
+ if (hasNestedFileOrSymlink(entryPath)) {
335
+ remaining.push(entry);
336
+ continue;
337
+ }
338
+ rmSync(entryPath, { recursive: true, force: true });
339
+ logWarning("guided", `Self-heal: removed empty legacy deep setup pseudo-milestone directory ${entry}`);
340
+ } catch (err) {
341
+ remaining.push(entry);
342
+ logWarning("guided", `legacy deep setup pseudo-milestone cleanup failed for ${entry}: ${(err as Error).message}`);
343
+ }
344
+ }
345
+ return remaining;
346
+ }
347
+
348
+ export function clearPendingDeepProjectSetup(basePath?: string): void {
349
+ if (basePath) {
350
+ pendingDeepProjectSetupMap.delete(basePath);
351
+ } else {
352
+ pendingDeepProjectSetupMap.clear();
353
+ }
354
+ }
355
+
356
+ function _getPendingDeepProjectSetup(basePath?: string): PendingDeepProjectSetupEntry | null {
357
+ if (basePath) return pendingDeepProjectSetupMap.get(basePath) ?? null;
358
+ if (pendingDeepProjectSetupMap.size === 1) return pendingDeepProjectSetupMap.values().next().value!;
359
+ return null;
360
+ }
361
+
362
+ function getDeepSetupSessionId(ctx: ExtensionContext | undefined): string | undefined {
363
+ return ctx?.sessionManager?.getSessionId?.();
364
+ }
365
+
366
+ function _getPendingDeepProjectSetupForContext(
367
+ ctx: ExtensionContext | undefined,
368
+ basePath?: string,
369
+ ): PendingDeepProjectSetupEntry | null {
370
+ if (basePath) {
371
+ const direct = pendingDeepProjectSetupMap.get(basePath);
372
+ if (direct) return direct;
373
+ }
374
+ if (!ctx) return _getPendingDeepProjectSetup();
375
+
376
+ const sessionId = getDeepSetupSessionId(ctx);
377
+ if (sessionId) {
378
+ const matches = [...pendingDeepProjectSetupMap.values()].filter(entry => entry.sessionId === sessionId);
379
+ if (matches.length === 1) return matches[0]!;
380
+ }
381
+
382
+ const matches = [...pendingDeepProjectSetupMap.values()].filter(entry => entry.ctx === ctx);
383
+ return matches.length === 1 ? matches[0]! : null;
384
+ }
385
+
386
+ export function getPendingDeepProjectSetupUnitForContext(
387
+ ctx: ExtensionContext | undefined,
388
+ basePath?: string,
389
+ ): { unitType: string; unitId: string } | null {
390
+ const entry = _getPendingDeepProjectSetupForContext(ctx, basePath);
391
+ if (!entry?.currentUnitType || !entry.currentUnitId) return null;
392
+ return {
393
+ unitType: entry.currentUnitType,
394
+ unitId: entry.currentUnitId,
395
+ };
396
+ }
397
+
398
+ export async function startDeepProjectSetupForeground(
399
+ ctx: ExtensionCommandContext,
400
+ pi: ExtensionAPI,
401
+ basePath: string,
402
+ step?: boolean,
403
+ ): Promise<void> {
404
+ const entry: PendingDeepProjectSetupEntry = {
405
+ ctx,
406
+ pi,
407
+ basePath,
408
+ step,
409
+ createdAt: Date.now(),
410
+ sessionId: getDeepSetupSessionId(ctx),
411
+ };
412
+ pendingDeepProjectSetupMap.set(basePath, entry);
413
+ await dispatchNextDeepProjectSetupStage(entry);
414
+ }
415
+
416
+ export async function checkDeepProjectSetupAfterTurn(
417
+ _event: { messages: any[] },
418
+ ctx?: ExtensionContext,
419
+ basePath?: string,
420
+ ): Promise<boolean> {
421
+ const entry = _getPendingDeepProjectSetupForContext(ctx, basePath);
422
+ if (!entry) return false;
423
+
424
+ if (entry.currentUnitType && entry.currentUnitId) {
425
+ // TODO(C-future): PendingDeepProjectSetupEntry does not carry a MilestoneScope
426
+ // because deep-project-setup units span non-milestone unit types (discuss-project,
427
+ // discuss-requirements, etc.). Migrate to verifyExpectedArtifactForScope once
428
+ // PendingDeepProjectSetupEntry is extended with a scope field.
429
+ const artifactReady = verifyExpectedArtifact(entry.currentUnitType, entry.currentUnitId, entry.basePath);
430
+ if (!artifactReady) {
431
+ return false;
432
+ }
433
+ }
434
+
435
+ // R2: a depth-verification gate is still pending — the LLM emitted the
436
+ // confirmation question (via ask_user_questions or plain chat) but the user
437
+ // has not approved yet. Returning false keeps the entry in the
438
+ // pendingDeepProjectSetupMap so the next user message can resume.
439
+ const pendingGateId = getPendingGate(entry.basePath);
440
+ if (pendingGateId) {
441
+ return false;
442
+ }
443
+
444
+ return dispatchNextDeepProjectSetupStage(entry);
445
+ }
446
+
447
+ async function dispatchNextDeepProjectSetupStage(entry: PendingDeepProjectSetupEntry): Promise<boolean> {
448
+ invalidateAllCaches();
449
+ const prefs = loadEffectiveGSDPreferences(entry.basePath)?.preferences;
450
+ const { DISPATCH_RULES, hasPendingDeepStage } = await import("./auto-dispatch.js");
451
+
452
+ if (!hasPendingDeepStage(prefs, entry.basePath)) {
453
+ pendingDeepProjectSetupMap.delete(entry.basePath);
454
+ scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
455
+ return true;
456
+ }
457
+
458
+ const state = await deriveState(entry.basePath);
459
+ const dispatchCtx = {
460
+ basePath: entry.basePath,
461
+ mid: "PROJECT",
462
+ midTitle: "Project setup",
463
+ state,
464
+ prefs,
465
+ // Claude Code currently surfaces workflow-MCP question calls as tool-request
466
+ // UI that can be cancelled outside the normal chat flow. During the
467
+ // foreground deep project setup interview, keep user input in plain chat so
468
+ // `/gsd new-project --deep` cannot bounce through cancelled tool requests.
469
+ structuredQuestionsAvailable: "false" as const,
470
+ };
471
+ let result: Awaited<ReturnType<(typeof DISPATCH_RULES)[number]["match"]>> = null;
472
+ for (const rule of DISPATCH_RULES) {
473
+ // Only evaluate foreground setup gates here. Later deep rules such as
474
+ // research-project have dispatch-time side effects (e.g. claiming an
475
+ // inflight marker) and must be left to auto-mode once the interview is
476
+ // complete.
477
+ if (!FOREGROUND_DEEP_SETUP_RULE_NAMES.has(rule.name)) continue;
478
+ result = await rule.match(dispatchCtx);
479
+ if (result) break;
480
+ }
481
+
482
+ if (!result || result.action !== "dispatch") {
483
+ if (result?.action === "stop") {
484
+ entry.ctx.ui.notify(result.reason, result.level);
485
+ } else if (hasPendingDeepStage(prefs, entry.basePath)) {
486
+ pendingDeepProjectSetupMap.delete(entry.basePath);
487
+ scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
488
+ return true;
489
+ }
490
+ return false;
491
+ }
492
+
493
+ if (!USER_DRIVEN_DEEP_SETUP_UNITS.has(result.unitType)) {
494
+ pendingDeepProjectSetupMap.delete(entry.basePath);
495
+ scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
496
+ return true;
497
+ }
498
+
499
+ entry.currentUnitType = result.unitType;
500
+ entry.currentUnitId = result.unitId;
501
+ entry.createdAt = Date.now();
502
+ await dispatchWorkflow(
503
+ entry.pi,
504
+ `${result.prompt}\n\n${FOREGROUND_DEEP_SETUP_QUESTION_POLICY}`,
505
+ "gsd-run",
506
+ entry.ctx,
507
+ result.unitType,
508
+ { basePath: entry.basePath },
509
+ );
510
+ return true;
511
+ }
512
+
513
+ /** Called from agent_end to check if auto-mode should start after discuss */
514
+ export function checkAutoStartAfterDiscuss(lookupBasePath?: string): boolean {
515
+ const entry = _getPendingAutoStart(lookupBasePath);
516
+ if (!entry) return false;
517
+
518
+ const { ctx, pi, basePath, milestoneId, step } = entry;
519
+
520
+ // Gate 1: Primary milestone must have CONTEXT.md or ROADMAP.md
521
+ // The "discuss" path creates CONTEXT.md; the "plan" path creates ROADMAP.md.
522
+ // Use pinned scope (immune to cwd-drift) for existence checks.
523
+ const contextFilePath = entry.scope.contextFile();
524
+ const roadmapFilePath = entry.scope.roadmapFile();
525
+ const contextFile = existsSync(contextFilePath) ? contextFilePath : null;
526
+ const roadmapFile = existsSync(roadmapFilePath) ? roadmapFilePath : null;
527
+ if (!contextFile && !roadmapFile) return false; // neither artifact yet — keep waiting
528
+
529
+ // Gate 1a: a depth-verification gate is still pending for THIS milestone — the
530
+ // LLM emitted the confirmation question (via ask_user_questions or plain chat)
531
+ // but the user has not answered yet. Advancing now would skip the gate and
532
+ // race ahead with unverified context.
533
+ const basePathForGate = entry.scope.workspace.projectRoot;
534
+ const pendingGateId = getPendingGate(basePathForGate);
535
+ if (pendingGateId) {
536
+ const pendingMilestoneId = extractDepthVerificationMilestoneId(pendingGateId);
537
+ // Block advancement if the gate is for THIS milestone, OR if it's a
538
+ // project/requirements gate (no milestone id encoded) for the deep setup flow.
539
+ const isProjectGate =
540
+ pendingGateId === "depth_verification_project_confirm" ||
541
+ pendingGateId === "depth_verification_requirements_confirm" ||
542
+ pendingGateId === "depth_verification_research_decision_confirm";
543
+ if (pendingMilestoneId === milestoneId || isProjectGate) {
544
+ return false;
545
+ }
546
+ }
547
+
548
+ // Gate 1b: Discriminate plan-blocked from discuss-incomplete when the DB row is queued.
549
+ // If the DB is available and the row is still "queued" but CONTEXT.md already exists on
550
+ // disk, the discuss phase completed but gsd_plan_milestone was hard-blocked by the
551
+ // depth-verification gate. Emit a recovery hint so the next agent turn can retry
552
+ // gsd_plan_milestone, then return false (keep blocking auto-start).
553
+ // If CONTEXT.md does not exist (discuss-incomplete), Gate 1 already blocked above.
554
+ if (isDbAvailable()) {
555
+ const dbRow = getMilestone(milestoneId);
556
+ if (dbRow?.status === "queued" && contextFile) {
557
+ if (entry.planBlockedRecoveryCount >= MAX_PLAN_BLOCKED_RECOVERIES) {
558
+ // H1: recovery loop cap reached — stop triggering new turns, escalate to user.
559
+ logWarning(
560
+ "guided",
561
+ `Gate 1b: milestone ${milestoneId} plan-blocked recovery limit reached ` +
562
+ `(${entry.planBlockedRecoveryCount}/${MAX_PLAN_BLOCKED_RECOVERIES}); escalating to user`,
563
+ );
564
+ ctx.ui.notify(
565
+ `Milestone ${milestoneId} plan_milestone has been blocked ${entry.planBlockedRecoveryCount} times. ` +
566
+ `Re-run /gsd to reset the recovery counter, or run /gsd-debug to diagnose without resetting.`,
567
+ "error",
568
+ );
569
+ return false;
570
+ }
571
+ logWarning(
572
+ "guided",
573
+ `Gate 1b: milestone ${milestoneId} queued with CONTEXT.md present — ` +
574
+ `plan_milestone was blocked; emitting recovery hint ` +
575
+ `(attempt ${entry.planBlockedRecoveryCount + 1}/${MAX_PLAN_BLOCKED_RECOVERIES})`,
576
+ );
577
+ ctx.ui.notify(
578
+ `Milestone ${milestoneId}: context file exists but milestone is still queued. ` +
579
+ `Retrying gsd_plan_milestone to complete the blocked planning step.`,
580
+ "warning",
581
+ );
582
+ try {
583
+ pi.sendMessage(
584
+ {
585
+ customType: "gsd-plan-milestone-blocked-recovery",
586
+ content:
587
+ `Milestone ${milestoneId} has ${contextFile} on disk but its DB row is still ` +
588
+ `"queued". The gsd_plan_milestone tool was previously blocked by the ` +
589
+ `depth-verification gate. Call gsd_plan_milestone now to complete the ` +
590
+ `planning phase.`,
591
+ display: false,
592
+ },
593
+ { triggerTurn: true },
594
+ );
595
+ // Increment only after a successful dispatch so transient sendMessage
596
+ // failures do not consume recovery budget.
597
+ entry.planBlockedRecoveryCount += 1;
598
+ } catch (e) {
599
+ logWarning("guided", `Gate 1b recovery sendMessage failed: ${(e as Error).message}`);
600
+ }
601
+ return false;
602
+ }
603
+ }
604
+
605
+ // Gate 2: STATE.md must exist — written as the last step in the discuss
606
+ // output phase. This prevents auto-start from firing during Phase 3
607
+ // (sequential readiness gates for remaining milestones) in multi-milestone
608
+ // discussions, where M001-CONTEXT.md exists but M002/M003 haven't been
609
+ // processed yet.
610
+ const stateFilePath = entry.scope.stateFile();
611
+ if (!existsSync(stateFilePath)) return false; // discussion not finalized yet
612
+
613
+ // Gate 3: Multi-milestone completeness warning
614
+ // Parse PROJECT.md for milestone sequence, warn if any are missing context.
615
+ // Don't block — milestones can be intentionally queued without context.
616
+ const projectFile = resolveGsdRootFile(basePath, "PROJECT");
617
+ let projectIds: string[] = [];
618
+ if (projectFile) {
619
+ try {
620
+ const projectContent = readFileSync(projectFile, "utf-8");
621
+ projectIds = parseMilestoneSequenceFromProject(projectContent);
622
+ if (projectIds.length > 1) {
623
+ const missing = projectIds.filter(id => {
624
+ const hasContext = !!resolveMilestoneFile(basePath, id, "CONTEXT");
625
+ const hasDraft = !!resolveMilestoneFile(basePath, id, "CONTEXT-DRAFT");
626
+ const hasDir = existsSync(join(gsdRoot(basePath), "milestones", id));
627
+ return !hasContext && !hasDraft && !hasDir;
628
+ });
629
+ if (missing.length > 0) {
630
+ ctx.ui.notify(
631
+ `Multi-milestone validation: ${missing.join(", ")} not found in filesystem. ` +
632
+ `Discussion may not have completed all readiness gates.`,
633
+ "warning",
634
+ );
635
+ }
636
+ }
637
+ } catch (e) { logWarning("guided", `PROJECT.md parsing failed: ${(e as Error).message}`); }
638
+ }
639
+
640
+ // Gate 4: Discussion manifest process verification (multi-milestone only)
641
+ // The LLM writes DISCUSSION-MANIFEST.json after each Phase 3 gate decision.
642
+ // When it exists, validate it before auto-starting. Project history alone is
643
+ // not a reliable signal for the current discussion mode.
644
+ const manifestPath = join(entry.scope.workspace.contract.projectGsd, "DISCUSSION-MANIFEST.json");
645
+ if (existsSync(manifestPath)) {
646
+ try {
647
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
648
+ const total = typeof manifest.total === "number" ? manifest.total : 0;
649
+ const completed = typeof manifest.gates_completed === "number" ? manifest.gates_completed : 0;
650
+
651
+ if (total > 1 && completed < total) {
652
+ // Discussion not complete — block auto-start until all gates are done
653
+ return false;
654
+ }
655
+
656
+ // Cross-check manifest milestones against PROJECT.md if available
657
+ if (projectIds.length > 0) {
658
+ const manifestIds = Object.keys(manifest.milestones ?? {});
659
+ const untracked = projectIds.filter(id => !manifestIds.includes(id));
660
+ if (untracked.length > 0) {
661
+ ctx.ui.notify(
662
+ `Discussion manifest missing gates for: ${untracked.join(", ")}`,
663
+ "warning",
664
+ );
665
+ }
666
+ }
667
+ } catch (e) { logWarning("guided", `discussion manifest verification failed: ${(e as Error).message}`); }
668
+ }
669
+
670
+ // Draft promotion cleanup: if a CONTEXT-DRAFT.md exists alongside the new
671
+ // CONTEXT.md, delete the draft — it's been consumed by the discussion.
672
+ try {
673
+ const draftFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT-DRAFT");
674
+ if (draftFile) unlinkSync(draftFile);
675
+ } catch (e) { logWarning("guided", `CONTEXT-DRAFT.md unlink failed: ${(e as Error).message}`); }
676
+
677
+ // Cleanup: remove discussion manifest after auto-start (only needed during discussion)
678
+ if (existsSync(manifestPath)) {
679
+ try { unlinkSync(manifestPath); } catch (e) { logWarning("guided", `manifest unlink failed: ${(e as Error).message}`); }
680
+ }
681
+
682
+ // R3b: belt-and-suspenders for silent registration failure. The discuss flow
683
+ // finished and STATE.md exists, but the milestone may never have landed in
684
+ // the DB. Without this guard, the user sees "Milestone M001 ready." and then
685
+ // /gsd reports "No Active Milestone".
686
+ if (isDbAvailable()) {
687
+ const milestoneRow = getMilestone(milestoneId);
688
+ if (!milestoneRow) {
689
+ let manifestHasMilestone = false;
690
+ try {
691
+ const manifest = readManifest(basePath);
692
+ manifestHasMilestone = Array.isArray(manifest?.milestones) && manifest.milestones.some(m => m.id === milestoneId);
693
+ } catch (e) {
694
+ logWarning("guided", `R3b: failed to read state manifest: ${(e as Error).message}`);
695
+ }
696
+ if (manifestHasMilestone) {
697
+ logWarning("guided", `R3b: getMilestone(${milestoneId}) returned null but manifest has the row — treating as stale read`);
698
+ } else {
699
+ ctx.ui.notify(
700
+ `Milestone ${milestoneId}: discuss artifacts on disk but no DB row exists. ` +
701
+ `PROJECT.md may have failed to register milestones. ` +
702
+ `Re-save PROJECT.md with canonical "- [ ] M001: Title — One-liner" lines, ` +
703
+ `then re-run /gsd to recover.`,
704
+ "error",
705
+ );
706
+ return false;
707
+ }
708
+ }
709
+ }
710
+
711
+ deletePendingAutoStart(basePath);
712
+ ctx.ui.notify(`Milestone ${milestoneId} ready.`, "success");
713
+ if (entry.startAuto !== false) {
714
+ scheduleAutoStartAfterIdle(ctx, pi, basePath, false, { step });
715
+ }
716
+ return true;
717
+ }
718
+
719
+ /**
720
+ * Extract the concatenated text content from an assistant message, whether it
721
+ * stores content as a string or as an array of text blocks.
722
+ */
723
+ function extractAssistantText(msg: any): string {
724
+ if (!msg) return "";
725
+ const content = msg.content;
726
+ if (typeof content === "string") return content;
727
+ if (!Array.isArray(content)) return "";
728
+ const parts: string[] = [];
729
+ for (const block of content) {
730
+ if (!block || typeof block !== "object") continue;
731
+ if (block.type === "text" && typeof block.text === "string") parts.push(block.text);
732
+ }
733
+ return parts.join("\n");
734
+ }
735
+
736
+ /**
737
+ * Return true if the assistant message contains any tool-use block.
738
+ *
739
+ * The canonical pi-ai `AssistantMessage.content` (see packages/pi-ai/src/types.ts)
740
+ * uses `type: "toolCall"` and `type: "serverToolUse"` for tool invocations —
741
+ * every provider (anthropic-direct, claude-code-cli, openai, etc.) normalizes
742
+ * incoming tool blocks into these two shapes before they reach guided-flow.
743
+ *
744
+ * The Anthropic API wire shape `"tool_use"` / `"server_tool_use"` does NOT appear
745
+ * in the internal AssistantMessage — those literals are only used when sending
746
+ * messages back out to the Anthropic API. Matching them here was a latent bug:
747
+ * `hasToolUse` returned `false` for every real tool call, which let the
748
+ * empty-turn nudge fire and pre-empt MCP tools that block on the user
749
+ * (e.g. `ask_user_questions`). See investigation in PR for #4658.
750
+ */
751
+ function hasToolUse(msg: any): boolean {
752
+ if (!msg) return false;
753
+ const content = msg.content;
754
+ if (!Array.isArray(content)) return false;
755
+ return content.some(
756
+ (b: any) =>
757
+ b &&
758
+ typeof b === "object" &&
759
+ (b.type === "toolCall" || b.type === "serverToolUse"),
760
+ );
761
+ }
762
+
763
+ /**
764
+ * #4573 — Detect and recover from the "ready phrase without files" failure mode.
765
+ *
766
+ * When the LLM emits "Milestone {{id}} ready." but has not written the
767
+ * milestone CONTEXT/ROADMAP artifacts, `checkAutoStartAfterDiscuss()` silently
768
+ * returns false and the next /gsd invocation loops into the "All milestones
769
+ * complete" warning.
770
+ *
771
+ * This function, called from `handleAgentEnd` after `checkAutoStartAfterDiscuss`
772
+ * returns false, pattern-matches the ready phrase on the last assistant message.
773
+ * If it fired AND neither the canonical M###-CONTEXT.md/M###-ROADMAP.md nor
774
+ * legacy CONTEXT.md/ROADMAP.md files exist, it:
775
+ * 1. Notifies the user that the signal was rejected.
776
+ * 2. Injects a system message via `pi.sendMessage(..., {triggerTurn:true})`
777
+ * telling the LLM the signal was premature and to emit the writes now.
778
+ * 3. Caps at `MAX_READY_REJECTS` per-entry; beyond that, gives up and asks
779
+ * the user to re-run /gsd.
780
+ *
781
+ * Returns true when a nudge (or give-up) was emitted, signaling the caller to
782
+ * skip `resolveAgentEnd`.
783
+ */
784
+ export function maybeHandleReadyPhraseWithoutFiles(event: { messages: any[] }, lookupBasePath?: string): boolean {
785
+ const entry = _getPendingAutoStart(lookupBasePath);
786
+ if (!entry) return false;
787
+ const { ctx, pi, basePath, milestoneId } = entry;
788
+
789
+ // Gate: last assistant message must contain the ready phrase
790
+ const lastMsg = event.messages[event.messages.length - 1];
791
+ const text = extractAssistantText(lastMsg);
792
+ if (!READY_PHRASE_RE.test(text)) return false;
793
+
794
+ // Bust paths.ts cached dir listings before checking for fresh writes. The
795
+ // LLM's Write tool calls do not invalidate paths.ts caches, so a stale
796
+ // listing taken before the milestone dir or its CONTEXT/ROADMAP files
797
+ // existed would falsely report the artifacts as missing and trigger the
798
+ // 3-strike "ready without files" abort even though the writes succeeded.
799
+ clearPathCache();
800
+
801
+ // Gate: artifacts must still be missing — if they exist, the happy path
802
+ // already fired and we have nothing to do.
803
+ const contextFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT");
804
+ const roadmapFile = resolveMilestoneFile(basePath, milestoneId, "ROADMAP");
805
+ if (contextFile || roadmapFile) return false;
806
+
807
+ // Diagnostic: when the cached resolver reports both files missing, also probe
808
+ // the canonical paths with uncached existsSync so we can tell whether the
809
+ // recovery is firing on real-missing files or a path-resolution miss
810
+ // (basePath/symlink mismatch, stale cache despite agent-end-recovery flush,
811
+ // legacy descriptor dir not matching, etc.).
812
+ try {
813
+ const mDir = resolveMilestonePath(basePath, milestoneId);
814
+ const canonicalCtx = mDir ? join(mDir, `${milestoneId}-CONTEXT.md`) : null;
815
+ const canonicalRoadmap = mDir ? join(mDir, `${milestoneId}-ROADMAP.md`) : null;
816
+ logWarning(
817
+ "guided",
818
+ `ready-phrase-reject diagnostic mid=${milestoneId} basePath=${basePath} ` +
819
+ `mDir=${mDir ?? "null"} ` +
820
+ `canonical-ctx=${canonicalCtx ?? "null"} ctx-exists=${canonicalCtx ? existsSync(canonicalCtx) : "n/a"} ` +
821
+ `canonical-roadmap=${canonicalRoadmap ?? "null"} roadmap-exists=${canonicalRoadmap ? existsSync(canonicalRoadmap) : "n/a"}`,
822
+ );
823
+ } catch (e) {
824
+ logWarning("guided", `ready-phrase-reject diagnostic failed: ${(e as Error).message}`);
825
+ }
826
+
827
+ entry.readyRejectCount = (entry.readyRejectCount ?? 0) + 1;
828
+
829
+ if (entry.readyRejectCount > MAX_READY_REJECTS) {
830
+ // Give up: clear state and tell the user to re-run /gsd. Avoids an
831
+ // infinite nudge loop when the LLM never produces the writes.
832
+ deletePendingAutoStart(basePath);
833
+ ctx.ui.notify(
834
+ `Milestone ${milestoneId}: LLM signaled "ready" ${entry.readyRejectCount} times without writing files. ` +
835
+ `Stopping auto-nudge. Run /gsd to try again.`,
836
+ "error",
837
+ );
838
+ return true;
839
+ }
840
+
841
+ const contextRel = relMilestoneFile(basePath, milestoneId, "CONTEXT");
842
+ const roadmapRel = relMilestoneFile(basePath, milestoneId, "ROADMAP");
843
+ ctx.ui.notify(
844
+ `Milestone ${milestoneId}: "ready" signal rejected — ${contextRel} and ${roadmapRel} are missing. Asking the LLM to complete the writes.`,
845
+ "warning",
846
+ );
847
+
848
+ const nudge =
849
+ `You emitted "Milestone ${milestoneId} ready." but neither ` +
850
+ `${contextRel} nor ${roadmapRel} exists on disk. ` +
851
+ `The ready phrase is a POST-WRITE signal and has been rejected. ` +
852
+ `In this turn: (1) write PROJECT.md, REQUIREMENTS.md, and the milestone ` +
853
+ `CONTEXT.md, (2) call gsd_plan_milestone, then (3) emit the ready phrase. ` +
854
+ `Do not describe these steps — execute them as tool calls. ` +
855
+ `This is retry ${entry.readyRejectCount}/${MAX_READY_REJECTS}; further ` +
856
+ `premature signals will clear the session.`;
857
+
858
+ try {
859
+ pi.sendMessage(
860
+ { customType: "gsd-ready-no-files", content: nudge, display: false },
861
+ { triggerTurn: true },
862
+ );
863
+ } catch (e) {
864
+ logWarning("guided", `ready-phrase nudge sendMessage failed: ${(e as Error).message}`);
865
+ return false;
866
+ }
867
+ return true;
868
+ }
869
+
870
+ /**
871
+ * #4573 — Detect and recover from the "announces tool, never calls it" stall.
872
+ *
873
+ * The LLM emits text like "I'll now write the CONTEXT.md file" but the turn
874
+ * ends with zero tool-use blocks. The harness has no post-turn tool-call
875
+ * validation, so the unit promise resolves and the user sees a stalled state.
876
+ *
877
+ * This function, called from `handleAgentEnd`, inspects the last assistant
878
+ * message. If ALL of the following are true, it injects a recovery message:
879
+ * - Text-only (no tool-use blocks)
880
+ * - Contains a commit-intent phrase ("I'll write", "I'll call", etc.)
881
+ * - Auto-mode is active OR a discussion autostart is pending
882
+ * - `emptyTurnRetryCount` is under the cap
883
+ *
884
+ * Per-handler state is held on the `PendingAutoStartEntry` when present, and
885
+ * on a module-level map otherwise. The counter resets on any successful
886
+ * tool-use turn via `resetEmptyTurnCounter`.
887
+ */
888
+ const emptyTurnCounterByBase = new Map<string, number>();
889
+ const MAX_EMPTY_TURN_RETRIES = 2;
890
+
891
+ // Phrases that indicate the LLM is about to do something but has not yet.
892
+ // Kept tight to avoid flagging legitimate narration like "I'll wait for your answer."
893
+ //
894
+ // "make" was previously in the verb list but matches conversational meta phrases
895
+ // like "Let me make sure I understand…" which are NOT action announcements —
896
+ // removed to prevent the empty-turn nudge from auto-replying to user questions
897
+ // in discuss flows.
898
+ const COMMIT_INTENT_RE =
899
+ /\b(?:I['’]ll|I will|Next,? I['’]ll|Now I['’]ll|Let me|I['’]m going to|I am going to)\s+(?:now\s+)?(?:write|create|call|invoke|update|add|run|execute|generate|produce|emit|compose|implement|save|apply|commit)\b/i;
900
+
901
+ /**
902
+ * Reset the empty-turn counter for a basePath after a successful tool-use turn.
903
+ * Called from handleAgentEnd when the last message contains tool_use blocks.
904
+ */
905
+ export function resetEmptyTurnCounter(basePath?: string): void {
906
+ if (basePath) emptyTurnCounterByBase.delete(basePath);
907
+ else emptyTurnCounterByBase.clear();
908
+ }
909
+
910
+ export function maybeHandleEmptyIntentTurn(
911
+ event: { messages: any[] },
912
+ isAuto: boolean,
913
+ lookupBasePath?: string,
914
+ ): boolean {
915
+ // Gate: only fire when there is system-driven work in flight. Interactive
916
+ // /gsd discuss (user-driven) produces legitimate text-only turns.
917
+ if (!isAuto && !hasPendingAutoStart(lookupBasePath)) return false;
918
+
919
+ const lastMsg = event.messages[event.messages.length - 1];
920
+ if (!lastMsg) return false;
921
+ if (hasToolUse(lastMsg)) return false;
922
+
923
+ const text = extractAssistantText(lastMsg).trim();
924
+ if (!text) return false;
925
+
926
+ // Skip if the LLM is emitting the ready phrase — that is the ready-no-files
927
+ // path, handled by maybeHandleReadyPhraseWithoutFiles.
928
+ if (READY_PHRASE_RE.test(text)) return false;
929
+
930
+ // Skip if the LLM is clearly handing back to the user. Discuss flows
931
+ // often pose a question and follow it with a conditional intent on the
932
+ // same line ("Did I capture that correctly? If so, I'll write the
933
+ // requirements."). A line-trailing `?` check misses these because the
934
+ // line ends in `.`. Match any sentence-terminating `?` (followed by
935
+ // whitespace or end-of-text) — false negatives here auto-reply to the
936
+ // user, which is a much worse failure mode than a missed nudge.
937
+ if (/\?(?:\s|$)/.test(text)) return false;
938
+
939
+ // Must contain a commit-intent phrase — this is the stall we care about.
940
+ if (!COMMIT_INTENT_RE.test(text)) return false;
941
+
942
+ // Resolve the target basePath + pi for injection. Prefer the pending
943
+ // autostart entry (discuss flow); otherwise we cannot inject.
944
+ const entry = _getPendingAutoStart(lookupBasePath);
945
+ if (!entry) return false;
946
+ const { ctx, pi, basePath } = entry;
947
+
948
+ const count = (emptyTurnCounterByBase.get(basePath) ?? 0) + 1;
949
+ emptyTurnCounterByBase.set(basePath, count);
950
+
951
+ if (count > MAX_EMPTY_TURN_RETRIES) {
952
+ ctx.ui.notify(
953
+ `Empty-turn recovery: LLM announced intent ${count} times without calling any tool. ` +
954
+ `Stopping auto-nudge.`,
955
+ "error",
956
+ );
957
+ return false; // let the normal flow resolve/pause the unit
958
+ }
959
+
960
+ ctx.ui.notify(
961
+ `Empty-turn detected: LLM announced intent but called no tool. Prompting it to execute.`,
962
+ "info",
963
+ );
964
+
965
+ const nudge =
966
+ `Your last turn announced an action (e.g. "I'll write…" or "Let me call…") ` +
967
+ `but contained no tool call. The system records zero tool-use blocks for ` +
968
+ `that turn. Execute the announced action NOW as a tool call in this turn. ` +
969
+ `Do not describe it again. Retry ${count}/${MAX_EMPTY_TURN_RETRIES}.`;
970
+
971
+ try {
972
+ pi.sendMessage(
973
+ { customType: "gsd-empty-turn-recovery", content: nudge, display: false },
974
+ { triggerTurn: true },
975
+ );
976
+ } catch (e) {
977
+ logWarning("guided", `empty-turn nudge sendMessage failed: ${(e as Error).message}`);
978
+ return false;
979
+ }
980
+ return true;
981
+ }
982
+
983
+ /**
984
+ * Extract milestone IDs from PROJECT.md milestone sequence table.
985
+ * Looks for rows like "| M001 | Name | Status |" and extracts the ID column.
986
+ */
987
+ function parseMilestoneSequenceFromProject(content: string): string[] {
988
+ const ids: string[] = [];
989
+ const lines = content.split(/\r?\n/);
990
+ for (const line of lines) {
991
+ const match = line.match(/^\|\s*(M\d{3}[A-Z0-9-]*)\s*\|/);
992
+ if (match) ids.push(match[1]);
993
+ }
994
+ return ids;
995
+ }
996
+
997
+ // ─── Types ────────────────────────────────────────────────────────────────────
998
+
999
+ type UIContext = ExtensionContext;
1000
+
1001
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
1002
+
1003
+ interface DispatchWorkflowOptions {
1004
+ basePath?: string;
1005
+ deps?: {
1006
+ loadPreferences?: typeof loadEffectiveGSDPreferences;
1007
+ selectModel?: typeof selectAndApplyModel;
1008
+ getTransportSupportError?: typeof getWorkflowTransportSupportError;
1009
+ };
1010
+ }
1011
+
1012
+ export function resolveGuidedDispatchProjectRoot(basePath?: string): string {
1013
+ return basePath ?? process.cwd();
1014
+ }
1015
+
1016
+ /**
1017
+ * Read GSD-WORKFLOW.md and dispatch it to the LLM with a contextual note.
1018
+ * This is the only way the wizard triggers work — everything else is the LLM's job.
1019
+ *
1020
+ * When a unitType is provided, resolves the user's model preference for that
1021
+ * phase (e.g., models.planning → "plan-milestone", models.discuss → "discuss-milestone") and applies it before
1022
+ * dispatching. This ensures guided-flow dispatches respect the same
1023
+ * per-phase model preferences that auto-mode uses.
1024
+ */
1025
+ async function dispatchWorkflow(
1026
+ pi: ExtensionAPI,
1027
+ note: string,
1028
+ customType = "gsd-run",
1029
+ ctx?: ExtensionContext,
1030
+ unitType?: string,
1031
+ options?: DispatchWorkflowOptions,
1032
+ ): Promise<void> {
1033
+ const resolvedOptions = options ?? {};
1034
+ const projectRoot = resolveGuidedDispatchProjectRoot(resolvedOptions.basePath);
1035
+ const loadPreferences = resolvedOptions.deps?.loadPreferences ?? loadEffectiveGSDPreferences;
1036
+ const selectModel = resolvedOptions.deps?.selectModel ?? selectAndApplyModel;
1037
+ const getTransportSupportError = resolvedOptions.deps?.getTransportSupportError ?? getWorkflowTransportSupportError;
1038
+
1039
+ // Route through the dynamic routing pipeline (complexity classification,
1040
+ // tier downgrade, fallback chains) — same path as auto-mode dispatches (#2958).
1041
+ if (ctx && unitType) {
1042
+ const prefs = loadPreferences(projectRoot)?.preferences;
1043
+ const result = await selectModel(
1044
+ ctx, pi, unitType, /* unitId */ "", projectRoot,
1045
+ prefs, /* verbose */ false, /* autoModeStartModel */ null,
1046
+ /* retryContext */ undefined, /* isAutoMode */ false,
1047
+ );
1048
+ if (result.appliedModel) {
1049
+ debugLog("guided-flow-model-applied", {
1050
+ unitType,
1051
+ model: `${result.appliedModel.provider}/${result.appliedModel.id}`,
1052
+ routing: result.routing,
1053
+ });
1054
+ }
1055
+
1056
+ const compatibilityError = getTransportSupportError(
1057
+ result.appliedModel?.provider ?? ctx.model?.provider,
1058
+ getRequiredWorkflowToolsForGuidedUnit(unitType),
1059
+ {
1060
+ projectRoot,
1061
+ surface: "guided flow",
1062
+ unitType,
1063
+ authMode: result.appliedModel?.provider
1064
+ ? ctx.modelRegistry.getProviderAuthMode(result.appliedModel.provider)
1065
+ : ctx.model?.provider
1066
+ ? ctx.modelRegistry.getProviderAuthMode(ctx.model.provider)
1067
+ : undefined,
1068
+ baseUrl: result.appliedModel?.baseUrl ?? ctx.model?.baseUrl,
1069
+ activeTools: typeof pi.getActiveTools === "function" ? pi.getActiveTools() : [],
1070
+ },
1071
+ );
1072
+ if (compatibilityError) {
1073
+ ctx.ui.notify(compatibilityError, "error");
1074
+ return;
1075
+ }
1076
+ }
1077
+
1078
+ // Scope tools for guided workflow turns (#2949, token-consumption savings).
1079
+ // Providers with grammar-based constrained decoding (xAI/Grok) return
1080
+ // "Grammar is too complex" when the combined tool schema is too large.
1081
+ // Guided workflow turns only need the active unit's tool surface; strip
1082
+ // unrelated GSD tools and broad non-GSD tools for this queued turn, then
1083
+ // restore so the narrowed surface does not leak into future dispatches.
1084
+ let savedTools: ReturnType<typeof scopeGsdWorkflowToolsForDispatch> = null;
1085
+
1086
+ try {
1087
+ const currentTools = pi.getActiveTools();
1088
+ savedTools = {
1089
+ tools: currentTools,
1090
+ visibleSkills: typeof pi.getVisibleSkills === "function" ? pi.getVisibleSkills() : undefined,
1091
+ restoreVisibleSkills: typeof pi.setVisibleSkills === "function",
1092
+ };
1093
+ if (unitType?.startsWith("discuss-") && !isFullGsdToolSurfaceRequested()) {
1094
+ // Keep all non-GSD tools (builtins, other extensions) and only the
1095
+ // GSD tools on the discuss allowlist.
1096
+ const scopedTools = currentTools.filter(
1097
+ (t) => !t.startsWith("gsd_") || DISCUSS_TOOLS_ALLOWLIST.includes(t),
1098
+ );
1099
+ pi.setActiveTools(scopedTools);
1100
+ const scopedState = scopeGsdWorkflowToolsForDispatch(pi, unitType);
1101
+ savedTools = {
1102
+ tools: currentTools,
1103
+ visibleSkills: scopedState?.visibleSkills ?? savedTools.visibleSkills,
1104
+ restoreVisibleSkills: scopedState?.restoreVisibleSkills ?? savedTools.restoreVisibleSkills,
1105
+ };
1106
+ debugLog("discuss-tool-scoping", {
1107
+ unitType,
1108
+ before: currentTools.length,
1109
+ after: pi.getActiveTools().length,
1110
+ removed: currentTools.length - pi.getActiveTools().length,
1111
+ });
1112
+ } else {
1113
+ savedTools = scopeGsdWorkflowToolsForDispatch(pi, unitType) ?? savedTools;
1114
+ }
1115
+
1116
+ const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
1117
+ const workflow = readFileSync(workflowPath, "utf-8");
1118
+
1119
+ if (unitType) setGuidedUnitContext(projectRoot, unitType);
1120
+ try {
1121
+ pi.sendMessage(
1122
+ {
1123
+ customType,
1124
+ content: buildWorkflowDispatchContent({ workflow, workflowPath, task: note }),
1125
+ display: false,
1126
+ },
1127
+ { triggerTurn: true },
1128
+ );
1129
+ } catch (err) {
1130
+ clearGuidedUnitContext(projectRoot);
1131
+ throw err;
1132
+ }
1133
+ } finally {
1134
+ // Restore full tool set after the message is queued. The LLM turn has
1135
+ // already captured the scoped set — restoring prevents the narrowed
1136
+ // tools from leaking into subsequent dispatches (#3628). The finally
1137
+ // block ensures restoration even if sendMessage throws.
1138
+ restoreGsdWorkflowTools(pi, savedTools);
1139
+ }
1140
+ }
1141
+
1142
+ export const _dispatchWorkflowForTest = dispatchWorkflow;
1143
+
1144
+ export function getDiscussableFutureMilestones<T extends { id: string; status: string }>(
1145
+ registry: T[],
1146
+ activeMilestoneId?: string | null,
1147
+ ): T[] {
1148
+ return registry.filter((m) =>
1149
+ m.id !== activeMilestoneId && m.status !== "complete" && m.status !== "parked",
1150
+ );
1151
+ }
1152
+
1153
+ function getStructuredQuestionsAvailability(
1154
+ pi: ExtensionAPI,
1155
+ ctx: ExtensionContext | undefined,
1156
+ ): "true" | "false" {
1157
+ if (!ctx) return "false";
1158
+
1159
+ const provider = ctx.model?.provider;
1160
+ const authMode = provider ? ctx.modelRegistry.getProviderAuthMode(provider) : undefined;
1161
+ return supportsStructuredQuestions(pi.getActiveTools(), {
1162
+ authMode,
1163
+ baseUrl: ctx.model?.baseUrl,
1164
+ }) ? "true" : "false";
1165
+ }
1166
+
1167
+ /**
1168
+ * Resolve a model ID string to a model object from available models.
1169
+ * Handles "provider/model" and bare ID formats.
1170
+ */
1171
+ function resolveAvailableModel<T extends { id: string; provider: string }>(
1172
+ modelId: string,
1173
+ availableModels: T[],
1174
+ currentProvider: string | undefined,
1175
+ ): T | undefined {
1176
+ const slashIdx = modelId.indexOf("/");
1177
+
1178
+ if (slashIdx !== -1) {
1179
+ const maybeProvider = modelId.substring(0, slashIdx);
1180
+ const id = modelId.substring(slashIdx + 1);
1181
+
1182
+ const knownProviders = new Set(availableModels.map(m => m.provider.toLowerCase()));
1183
+ if (knownProviders.has(maybeProvider.toLowerCase())) {
1184
+ const match = availableModels.find(
1185
+ m => m.provider.toLowerCase() === maybeProvider.toLowerCase()
1186
+ && m.id.toLowerCase() === id.toLowerCase(),
1187
+ );
1188
+ if (match) return match;
1189
+ }
1190
+
1191
+ // Try matching the full string as a model ID (OpenRouter-style)
1192
+ const lower = modelId.toLowerCase();
1193
+ return availableModels.find(
1194
+ m => m.id.toLowerCase() === lower
1195
+ || `${m.provider}/${m.id}`.toLowerCase() === lower,
1196
+ );
1197
+ }
1198
+
1199
+ // Bare ID — prefer current provider, then first available
1200
+ const exactProviderMatch = availableModels.find(
1201
+ m => m.id === modelId && m.provider === currentProvider,
1202
+ );
1203
+ return exactProviderMatch ?? availableModels.find(m => m.id === modelId);
1204
+ }
1205
+
1206
+ /**
1207
+ * Build the discuss-and-plan prompt for a new milestone.
1208
+ * Used by all three "new milestone" paths (first ever, no active, all complete).
1209
+ */
1210
+ function buildDiscussPrompt(nextId: string, preamble: string, _basePath: string, pi: ExtensionAPI, ctx: ExtensionCommandContext, preparationContext?: string): string {
1211
+ const milestoneRel = `.gsd/milestones/${nextId}`;
1212
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
1213
+ const inlinedTemplates = [
1214
+ inlineTemplate("project", "Project"),
1215
+ inlineTemplate("requirements", "Requirements"),
1216
+ inlineTemplate("context", "Context"),
1217
+ inlineTemplate("roadmap", "Roadmap"),
1218
+ inlineTemplate("decisions", "Decisions"),
1219
+ ].join("\n\n---\n\n");
1220
+ return loadPrompt("discuss", {
1221
+ milestoneId: nextId,
1222
+ preamble,
1223
+ preparationContext: preparationContext ?? "",
1224
+ structuredQuestionsAvailable,
1225
+ contextPath: `${milestoneRel}/${nextId}-CONTEXT.md`,
1226
+ roadmapPath: `${milestoneRel}/${nextId}-ROADMAP.md`,
1227
+ inlinedTemplates,
1228
+ commitInstruction: buildDocsCommitInstruction(`docs(${nextId}): context, requirements, and roadmap`),
1229
+ multiMilestoneCommitInstruction: buildDocsCommitInstruction("docs: project plan — N milestones"),
1230
+ });
1231
+ }
1232
+
1233
+ /**
1234
+ * Build the discuss prompt for headless milestone creation.
1235
+ * Uses the discuss-headless prompt template with seed context injected.
1236
+ */
1237
+ function buildHeadlessDiscussPrompt(nextId: string, seedContext: string, _basePath: string): string {
1238
+ const milestoneRel = `.gsd/milestones/${nextId}`;
1239
+ const inlinedTemplates = [
1240
+ inlineTemplate("project", "Project"),
1241
+ inlineTemplate("requirements", "Requirements"),
1242
+ inlineTemplate("context", "Context"),
1243
+ inlineTemplate("roadmap", "Roadmap"),
1244
+ inlineTemplate("decisions", "Decisions"),
1245
+ ].join("\n\n---\n\n");
1246
+ return loadPrompt("discuss-headless", {
1247
+ milestoneId: nextId,
1248
+ seedContext,
1249
+ contextPath: `${milestoneRel}/${nextId}-CONTEXT.md`,
1250
+ roadmapPath: `${milestoneRel}/${nextId}-ROADMAP.md`,
1251
+ inlinedTemplates,
1252
+ commitInstruction: buildDocsCommitInstruction(`docs(${nextId}): context, requirements, and roadmap`),
1253
+ multiMilestoneCommitInstruction: buildDocsCommitInstruction("docs: project plan — N milestones"),
1254
+ });
1255
+ }
1256
+
1257
+ /**
1258
+ * Run preparation phase if enabled, then build the discuss prompt.
1259
+ * Preparation analyzes the codebase and prior context, injecting the results
1260
+ * as supplementary context into the standard discuss template. The discuss
1261
+ * template drives the conversation (asks "What's the vision?" first), while
1262
+ * the preparation briefs give the agent grounding in the existing codebase.
1263
+ *
1264
+ * @param ctx - Extension command context with UI for progress notifications
1265
+ * @param nextId - The milestone ID being discussed
1266
+ * @param preamble - Preamble text for the discuss prompt
1267
+ * @param basePath - Root directory of the project
1268
+ * @returns The discuss prompt string
1269
+ */
1270
+ async function prepareAndBuildDiscussPrompt(
1271
+ ctx: ExtensionCommandContext,
1272
+ pi: ExtensionAPI,
1273
+ nextId: string,
1274
+ preamble: string,
1275
+ basePath: string,
1276
+ ): Promise<string> {
1277
+ const prefs = loadEffectiveGSDPreferences()?.preferences ?? {};
1278
+
1279
+ // Run preparation if enabled (default: true) — results are injected as
1280
+ // supplementary context into the standard discuss prompt, NOT as a
1281
+ // replacement template. The discuss prompt always leads with "What's the
1282
+ // vision?" so the user defines the scope, not the codebase analysis.
1283
+ let preparationContext = "";
1284
+ if (prefs.discuss_preparation !== false) {
1285
+ try {
1286
+ const prepResult = await runPreparation(basePath, ctx.ui, {
1287
+ discuss_preparation: prefs.discuss_preparation,
1288
+ discuss_web_research: prefs.discuss_web_research,
1289
+ discuss_depth: prefs.discuss_depth,
1290
+ });
1291
+
1292
+ if (prepResult.enabled) {
1293
+ const codebaseBrief = prepResult.codebaseBrief || formatCodebaseBrief(prepResult.codebase);
1294
+ const priorContextBrief = prepResult.priorContextBrief || formatPriorContextBrief(prepResult.priorContext);
1295
+ const parts: string[] = [];
1296
+ if (codebaseBrief) parts.push(`### Codebase Brief\n\n${codebaseBrief}`);
1297
+ if (priorContextBrief) parts.push(`### Prior Context Brief\n\n${priorContextBrief}`);
1298
+ if (parts.length > 0) {
1299
+ preparationContext = `\n\n## Preparation Context\n\nThe system analyzed the codebase before this discussion. Use these findings as background context — they describe what already exists, NOT what the user wants to build. Always ask the user what they want to build first.\n\n${parts.join("\n\n")}`;
1300
+ }
1301
+ }
1302
+ } catch (err) {
1303
+ logWarning("guided", `preparation failed, proceeding without context: ${(err as Error).message}`);
1304
+ }
1305
+ }
1306
+
1307
+ return buildDiscussPrompt(nextId, preamble, basePath, pi, ctx, preparationContext);
1308
+ }
1309
+
1310
+ /**
1311
+ * Bootstrap a .gsd/ project from scratch for headless use.
1312
+ * Ensures git repo, .gsd/ structure, gitignore, and preferences all exist.
1313
+ */
1314
+ function bootstrapGsdProject(basePath: string): void {
1315
+ if (!nativeIsRepo(basePath) || isInheritedRepo(basePath)) {
1316
+ const mainBranch = loadEffectiveGSDPreferences()?.preferences?.git?.main_branch || "main";
1317
+ nativeInit(basePath, mainBranch);
1318
+ }
1319
+
1320
+ const root = gsdRoot(basePath);
1321
+ mkdirSync(join(root, "milestones"), { recursive: true });
1322
+ mkdirSync(join(root, "runtime"), { recursive: true });
1323
+
1324
+ const gitPrefs = loadEffectiveGSDPreferences(basePath)?.preferences?.git;
1325
+ const manageGitignore = gitPrefs?.manage_gitignore;
1326
+ ensureGitignore(basePath, { manageGitignore });
1327
+ ensurePreferences(basePath);
1328
+ if (manageGitignore !== false) untrackRuntimeFiles(basePath);
1329
+ }
1330
+
1331
+ /**
1332
+ * Headless milestone creation from a seed specification document.
1333
+ * Bootstraps the project if needed, generates the next milestone ID,
1334
+ * and dispatches the headless discuss prompt (no Q&A rounds).
1335
+ */
1336
+ export async function showHeadlessMilestoneCreation(
1337
+ ctx: ExtensionCommandContext,
1338
+ pi: ExtensionAPI,
1339
+ basePath: string,
1340
+ seedContext: string,
1341
+ options: HeadlessMilestoneCreationOptions = {},
1342
+ ): Promise<void> {
1343
+ // Clear stale reservations from previous cancelled sessions (#2488)
1344
+ clearReservedMilestoneIds();
1345
+
1346
+ // Ensure .gsd/ is bootstrapped
1347
+ bootstrapGsdProject(basePath);
1348
+
1349
+ const { ensureDbOpen } = await import("./bootstrap/dynamic-tools.js");
1350
+ await ensureDbOpen(basePath);
1351
+
1352
+ // Generate next milestone ID
1353
+ const existingIds = findMilestoneIds(basePath);
1354
+ const prefs = loadEffectiveGSDPreferences();
1355
+ const nextId = nextMilestoneIdReserved(existingIds, prefs?.preferences?.unique_milestone_ids ?? false, basePath);
1356
+
1357
+ // Fix #4996: Do NOT pre-create the milestone directory here.
1358
+ // atomicWriteAsync (used by all artifact writers) calls mkdir lazily before
1359
+ // each write, so every path through saveArtifactToDb / saveFile is already
1360
+ // lazy-mkdir-safe. Pre-creating the dir before the discuss flow runs leaves
1361
+ // an orphan stub if discuss is abandoned — that stub later skews nextMilestoneId.
1362
+
1363
+ // Build and dispatch the headless discuss prompt
1364
+ const prompt = buildHeadlessDiscussPrompt(nextId, seedContext, basePath);
1365
+
1366
+ // Set the ready handoff. Headless --auto owns the auto start itself so it can
1367
+ // wait for completion without racing the guided-flow pending auto-start.
1368
+ setPendingAutoStart(basePath, {
1369
+ ctx,
1370
+ pi,
1371
+ basePath,
1372
+ milestoneId: nextId,
1373
+ startAuto: options.startAutoAfterReady !== false,
1374
+ });
1375
+
1376
+ // Dispatch as discuss-milestone. The LLM writes PROJECT.md, REQUIREMENTS.md,
1377
+ // and CONTEXT.md, then calls gsd_plan_milestone — this is semantically the
1378
+ // discuss path, just non-interactive. Using "plan-milestone" here caused
1379
+ // model/tool routing to skip discuss-flow tool scoping and
1380
+ // `checkAutoStartAfterDiscuss` guardrails that rely on the
1381
+ // "discuss-"-prefixed unitType.
1382
+ await dispatchWorkflow(pi, prompt, "gsd-run", ctx, "discuss-milestone", { basePath });
1383
+ }
1384
+
1385
+
1386
+ // ─── Discuss Flow ─────────────────────────────────────────────────────────────
1387
+
1388
+ /**
1389
+ * Build a rich inlined-context prompt for discussing a specific slice.
1390
+ * Preloads roadmap, milestone context, research, decisions, and completed
1391
+ * slice summaries so the agent can ask grounded UX/behaviour questions
1392
+ * without wasting a turn reading files.
1393
+ */
1394
+ async function buildDiscussSlicePrompt(
1395
+ mid: string,
1396
+ sid: string,
1397
+ sTitle: string,
1398
+ base: string,
1399
+ options?: { rediscuss?: boolean; structuredQuestionsAvailable?: string },
1400
+ ): Promise<string> {
1401
+ const inlined: string[] = [];
1402
+
1403
+ // Roadmap — always included so the agent sees surrounding slices
1404
+ const roadmapPath = resolveMilestoneFile(base, mid, "ROADMAP");
1405
+ const roadmapRel = relMilestoneFile(base, mid, "ROADMAP");
1406
+ const roadmapContent = roadmapPath ? await loadFile(roadmapPath) : null;
1407
+ if (roadmapContent) {
1408
+ inlined.push(`### Milestone Roadmap\nSource: \`${roadmapRel}\`\n\n${roadmapContent.trim()}`);
1409
+ }
1410
+
1411
+ // Milestone context — understanding the full milestone intent
1412
+ const contextPath = resolveMilestoneFile(base, mid, "CONTEXT");
1413
+ const contextRel = relMilestoneFile(base, mid, "CONTEXT");
1414
+ const contextContent = contextPath ? await loadFile(contextPath) : null;
1415
+ if (contextContent) {
1416
+ inlined.push(`### Milestone Context\nSource: \`${contextRel}\`\n\n${contextContent.trim()}`);
1417
+ }
1418
+
1419
+ // Milestone research — technical grounding
1420
+ const researchPath = resolveMilestoneFile(base, mid, "RESEARCH");
1421
+ const researchRel = relMilestoneFile(base, mid, "RESEARCH");
1422
+ const researchContent = researchPath ? await loadFile(researchPath) : null;
1423
+ if (researchContent) {
1424
+ inlined.push(`### Milestone Research\nSource: \`${researchRel}\`\n\n${researchContent.trim()}`);
1425
+ }
1426
+
1427
+ // Decisions — architectural context that constrains this slice
1428
+ const decisionsPath = resolveGsdRootFile(base, "DECISIONS");
1429
+ if (existsSync(decisionsPath)) {
1430
+ const decisionsContent = await loadFile(decisionsPath);
1431
+ if (decisionsContent) {
1432
+ inlined.push(`### Decisions Register\nSource: \`${relGsdRootFile("DECISIONS")}\`\n\n${decisionsContent.trim()}`);
1433
+ }
1434
+ }
1435
+
1436
+ // Completed slice summaries — what was already built that this slice builds on
1437
+ // Ensure DB is open so getMilestoneSlices returns real data (#2560).
1438
+ {
1439
+ const { ensureDbOpen } = await import("./bootstrap/dynamic-tools.js");
1440
+ await ensureDbOpen();
1441
+ type NormSlice = { id: string; done: boolean };
1442
+ let normSlices: NormSlice[] = [];
1443
+ if (isDbAvailable()) {
1444
+ normSlices = getMilestoneSlices(mid).map(s => ({ id: s.id, done: s.status === "complete" }));
1445
+ }
1446
+ for (const s of normSlices) {
1447
+ if (!s.done || s.id === sid) continue;
1448
+ const summaryPath = resolveSliceFile(base, mid, s.id, "SUMMARY");
1449
+ const summaryRel = relSliceFile(base, mid, s.id, "SUMMARY");
1450
+ const summaryContent = summaryPath ? await loadFile(summaryPath) : null;
1451
+ if (summaryContent) {
1452
+ inlined.push(`### ${s.id} Summary (completed)\nSource: \`${summaryRel}\`\n\n${summaryContent.trim()}`);
1453
+ }
1454
+ }
1455
+ }
1456
+
1457
+ const inlinedContext = inlined.length > 0
1458
+ ? `## Inlined Context (preloaded — do not re-read these files)\n\n${inlined.join("\n\n---\n\n")}`
1459
+ : `## Inlined Context\n\n_(no context files found yet — go in blind and ask broad questions)_`;
1460
+
1461
+ const sliceDirPath = `.gsd/milestones/${mid}/slices/${sid}`;
1462
+ const sliceContextPath = `${sliceDirPath}/${sid}-CONTEXT.md`;
1463
+
1464
+ // When re-discussing, inject a preamble so the agent treats this as an update interview
1465
+ const rediscussPreamble = options?.rediscuss
1466
+ ? `\n\n## Re-discuss Mode\n\nThis slice already has an existing context file (\`${sliceContextPath}\`) from a prior discussion. The user has chosen to re-discuss it. Read the existing context file, interview for any updates, changes, or new decisions, and rewrite the file with merged findings. Do NOT skip the interview — the user explicitly asked to revisit this slice.\n`
1467
+ : "";
1468
+
1469
+ const inlinedTemplates = inlineTemplate("slice-context", "Slice Context");
1470
+ return loadPrompt("guided-discuss-slice", {
1471
+ milestoneId: mid,
1472
+ sliceId: sid,
1473
+ sliceTitle: sTitle,
1474
+ inlinedContext: inlinedContext + rediscussPreamble,
1475
+ sliceDirPath,
1476
+ contextPath: sliceContextPath,
1477
+ projectRoot: base,
1478
+ inlinedTemplates,
1479
+ structuredQuestionsAvailable: options?.structuredQuestionsAvailable ?? "false",
1480
+ commitInstruction: buildDocsCommitInstruction(`docs(${mid}/${sid}): slice context from discuss`),
1481
+ });
1482
+ }
1483
+
1484
+ /**
1485
+ * /gsd discuss — show a picker of non-done slices and run a slice interview.
1486
+ * Loops back to the picker after each discussion so the user can chain
1487
+ * multiple slice interviews in one session.
1488
+ */
1489
+ export async function showDiscuss(
1490
+ ctx: ExtensionCommandContext,
1491
+ pi: ExtensionAPI,
1492
+ basePath: string,
1493
+ options?: { target?: string },
1494
+ ): Promise<void> {
1495
+ // Guard: no .gsd/ project
1496
+ if (!existsSync(gsdRoot(basePath))) {
1497
+ ctx.ui.notify("No GSD project found. Run /gsd to start one first.", "warning");
1498
+ return;
1499
+ }
1500
+
1501
+ // Ensure DB is open before deriving state (#5837).
1502
+ const { ensureDbOpen } = await import("./bootstrap/dynamic-tools.js");
1503
+ await ensureDbOpen(basePath);
1504
+
1505
+ // Invalidate caches to pick up artifacts written by a just-completed discuss/plan
1506
+ invalidateAllCaches();
1507
+
1508
+ const state = await deriveState(basePath);
1509
+ const discussableFutureMilestones = getDiscussableFutureMilestones(
1510
+ state.registry,
1511
+ state.activeMilestone?.id,
1512
+ );
1513
+
1514
+ // Rebuild STATE.md from derived state before any dispatch (#3475).
1515
+ // Without this, guided prompts read a stale STATE.md cache and the
1516
+ // agent bootstraps from the wrong milestone.
1517
+ try {
1518
+ const { buildStateMarkdown } = await import("./doctor.js");
1519
+ await saveFile(resolveGsdRootFile(basePath, "STATE"), buildStateMarkdown(state));
1520
+ } catch (err) {
1521
+ logWarning("guided", `STATE.md rebuild failed: ${(err as Error).message}`);
1522
+ }
1523
+
1524
+ const target = options?.target?.trim();
1525
+ if (target) {
1526
+ const slash = target.indexOf("/");
1527
+ if (slash > 0) {
1528
+ const mid = target.slice(0, slash);
1529
+ const sid = target.slice(slash + 1);
1530
+ const targetMilestone = state.registry.find((m) => m.id === mid);
1531
+ if (!targetMilestone || targetMilestone.status === "complete" || targetMilestone.status === "parked") {
1532
+ ctx.ui.notify(`Milestone ${mid} is not discussable.`, "warning");
1533
+ return;
1534
+ }
1535
+ const slices = isDbAvailable()
1536
+ ? getMilestoneSlices(mid).map(s => ({ id: s.id, done: s.status === "complete", title: s.title }))
1537
+ : [];
1538
+ const chosen = slices.find((s) => s.id === sid);
1539
+ if (!chosen) {
1540
+ ctx.ui.notify(`Slice ${target} was not found in discussable slices.`, "warning");
1541
+ return;
1542
+ }
1543
+ if (chosen.done) {
1544
+ ctx.ui.notify(`Slice ${target} is already complete; nothing to discuss.`, "info");
1545
+ return;
1546
+ }
1547
+ const contextFile = resolveSliceFile(basePath, mid, sid, "CONTEXT");
1548
+ const sqAvail = getStructuredQuestionsAvailability(pi, ctx);
1549
+ const prompt = await buildDiscussSlicePrompt(mid, sid, chosen.title, basePath, {
1550
+ rediscuss: !!contextFile,
1551
+ structuredQuestionsAvailable: sqAvail,
1552
+ });
1553
+ await dispatchWorkflow(pi, prompt, "gsd-discuss", ctx, "discuss-slice", { basePath });
1554
+ return;
1555
+ }
1556
+
1557
+ const targetMilestone = state.registry.find((m) => m.id === target);
1558
+ if (!targetMilestone || targetMilestone.status === "complete" || targetMilestone.status === "parked") {
1559
+ ctx.ui.notify(`Milestone ${target} is not discussable.`, "warning");
1560
+ return;
1561
+ }
1562
+ await dispatchDiscussForMilestone(ctx, pi, basePath, targetMilestone.id, targetMilestone.title, {});
1563
+ return;
1564
+ }
1565
+
1566
+ // No active milestone (or corrupted milestone with undefined id) —
1567
+ // check for pending milestones to discuss instead
1568
+ if (!state.activeMilestone?.id) {
1569
+ if (discussableFutureMilestones.length === 0) {
1570
+ ctx.ui.notify("No active milestone. Run /gsd to create one first.", "warning");
1571
+ return;
1572
+ }
1573
+ await showDiscussQueuedMilestone(ctx, pi, basePath, discussableFutureMilestones);
1574
+ return;
1575
+ }
1576
+
1577
+ const mid = state.activeMilestone.id;
1578
+ const milestoneTitle = state.activeMilestone.title;
1579
+
1580
+ // Special case: milestone is in needs-discussion phase (has CONTEXT-DRAFT.md but no roadmap yet).
1581
+ // Route to the draft discussion flow instead of erroring — the discussion IS how the roadmap gets created.
1582
+ if (state.phase === "needs-discussion") {
1583
+ const draftFile = resolveMilestoneFile(basePath, mid, "CONTEXT-DRAFT");
1584
+ const draftContent = draftFile ? await loadFile(draftFile) : null;
1585
+
1586
+ const choice = await showNextAction(ctx, {
1587
+ title: `GSD — ${mid}: ${milestoneTitle}`,
1588
+ summary: ["This milestone has a draft context from a prior discussion.", "It needs a dedicated discussion before auto-planning can begin."],
1589
+ actions: [
1590
+ {
1591
+ id: "discuss_draft",
1592
+ label: "Discuss from draft",
1593
+ description: "Continue where the prior discussion left off — seed material is loaded automatically.",
1594
+ recommended: true,
1595
+ },
1596
+ {
1597
+ id: "discuss_fresh",
1598
+ label: "Start fresh discussion",
1599
+ description: "Discard the draft and start a new discussion from scratch.",
1600
+ },
1601
+ {
1602
+ id: "skip_milestone",
1603
+ label: "Skip — create new milestone",
1604
+ description: "Leave this milestone as-is and start something new.",
1605
+ },
1606
+ ],
1607
+ notYetMessage: "Run /gsd discuss when ready to discuss this milestone.",
1608
+ });
1609
+
1610
+ if (choice === "discuss_draft") {
1611
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
1612
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
1613
+ const basePrompt = loadPrompt("guided-discuss-milestone", {
1614
+ workingDirectory: basePath,
1615
+ milestoneId: mid, milestoneTitle, inlinedTemplates: discussMilestoneTemplates, structuredQuestionsAvailable,
1616
+ commitInstruction: buildDocsCommitInstruction(`docs(${mid}): milestone context from discuss`),
1617
+ fastPathInstruction: "",
1618
+ });
1619
+ const seed = draftContent
1620
+ ? `${basePrompt}\n\n## Prior Discussion (Draft Seed)\n\n${draftContent}`
1621
+ : basePrompt;
1622
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: mid, step: false });
1623
+ await dispatchWorkflow(pi, seed, "gsd-discuss", ctx, "discuss-milestone", { basePath });
1624
+ } else if (choice === "discuss_fresh") {
1625
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
1626
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
1627
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: mid, step: false });
1628
+ await dispatchWorkflow(pi, loadPrompt("guided-discuss-milestone", {
1629
+ workingDirectory: basePath,
1630
+ milestoneId: mid, milestoneTitle, inlinedTemplates: discussMilestoneTemplates, structuredQuestionsAvailable,
1631
+ commitInstruction: buildDocsCommitInstruction(`docs(${mid}): milestone context from discuss`),
1632
+ fastPathInstruction: "",
1633
+ }), "gsd-discuss", ctx, "discuss-milestone", { basePath });
1634
+ } else if (choice === "skip_milestone") {
1635
+ const { ensureDbOpen } = await import("./bootstrap/dynamic-tools.js");
1636
+ await ensureDbOpen(basePath);
1637
+ const milestoneIds = findMilestoneIds(basePath);
1638
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
1639
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
1640
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: false });
1641
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId, `New milestone ${nextId}.`, basePath), "gsd-run", ctx, "discuss-milestone", { basePath });
1642
+ }
1643
+ return;
1644
+ }
1645
+
1646
+ // Guard: no roadmap yet (unless DB has slices)
1647
+ const roadmapFile = resolveMilestoneFile(basePath, mid, "ROADMAP");
1648
+ const roadmapContent = roadmapFile ? await loadFile(roadmapFile) : null;
1649
+ if (!roadmapContent && !isDbAvailable()) {
1650
+ ctx.ui.notify("No roadmap yet for this milestone. Run /gsd to plan first.", "warning");
1651
+ return;
1652
+ }
1653
+
1654
+ // Normalize slices: prefer DB, fall back to parser
1655
+ type NormSlice = { id: string; done: boolean; title: string };
1656
+ let normSlices: NormSlice[];
1657
+ if (isDbAvailable()) {
1658
+ normSlices = getMilestoneSlices(mid).map(s => ({ id: s.id, done: s.status === "complete", title: s.title }));
1659
+ } else {
1660
+ normSlices = [];
1661
+ }
1662
+ // DB is open but returned zero slices despite a roadmap existing —
1663
+ // the DB may be empty due to WAL loss or truncation (see #2815, #2892).
1664
+ // Fall back to roadmap parsing to prevent false "all complete" exit.
1665
+ if (normSlices.length === 0 && roadmapContent) {
1666
+ normSlices = parseRoadmapSlices(roadmapContent).map(s => ({ id: s.id, done: s.done, title: s.title }));
1667
+ }
1668
+ const pendingSlices = normSlices.filter(s => !s.done);
1669
+
1670
+ if (pendingSlices.length === 0) {
1671
+ // All slices complete — but queued milestones may still need discussion (#3150)
1672
+ if (discussableFutureMilestones.length > 0) {
1673
+ await showDiscussQueuedMilestone(ctx, pi, basePath, discussableFutureMilestones);
1674
+ return;
1675
+ }
1676
+ ctx.ui.notify("All slices are complete — nothing to discuss.", "info");
1677
+ return;
1678
+ }
1679
+
1680
+ // Loop: show picker, dispatch discuss, repeat until "not_yet"
1681
+ while (true) {
1682
+ // Invalidate caches so we pick up CONTEXT files written by the just-completed discussion
1683
+ invalidateAllCaches();
1684
+
1685
+ // Build discussion-state map: which slices have CONTEXT files already?
1686
+ const discussedMap = new Map<string, boolean>();
1687
+ for (const s of pendingSlices) {
1688
+ const contextFile = resolveSliceFile(basePath, mid, s.id, "CONTEXT");
1689
+ discussedMap.set(s.id, !!contextFile);
1690
+ }
1691
+
1692
+ // If all pending slices are discussed, check for queued milestones before exiting (#3150)
1693
+ const allDiscussed = pendingSlices.every(s => discussedMap.get(s.id));
1694
+ if (allDiscussed) {
1695
+ if (discussableFutureMilestones.length > 0) {
1696
+ await showDiscussQueuedMilestone(ctx, pi, basePath, discussableFutureMilestones);
1697
+ return;
1698
+ }
1699
+ const lockData = readSessionLockData(basePath);
1700
+ const remoteAutoRunning = lockData && lockData.pid !== process.pid && isSessionLockProcessAlive(lockData);
1701
+ const nextStep = remoteAutoRunning
1702
+ ? "Auto-mode is already running — use /gsd status to check progress."
1703
+ : "Run /gsd to start planning.";
1704
+ ctx.ui.notify(
1705
+ `All ${pendingSlices.length} slices discussed. ${nextStep}`,
1706
+ "info",
1707
+ );
1708
+ return;
1709
+ }
1710
+
1711
+ // Find the first undiscussed slice to recommend
1712
+ const firstUndiscussedId = pendingSlices.find(s => !discussedMap.get(s.id))?.id;
1713
+
1714
+ const actions = pendingSlices.map((s) => {
1715
+ const discussed = discussedMap.get(s.id) ?? false;
1716
+ const statusParts: string[] = [];
1717
+ if (state.activeSlice?.id === s.id) statusParts.push("active");
1718
+ else statusParts.push("upcoming");
1719
+ statusParts.push(discussed ? "discussed ✓" : "not discussed");
1720
+
1721
+ return {
1722
+ id: s.id,
1723
+ label: `${s.id}: ${s.title}`,
1724
+ description: statusParts.join(" · "),
1725
+ recommended: s.id === firstUndiscussedId,
1726
+ };
1727
+ });
1728
+
1729
+ // Offer access to queued milestones when any exist
1730
+ if (discussableFutureMilestones.length > 0) {
1731
+ actions.push({
1732
+ id: "discuss_queued_milestone",
1733
+ label: "Discuss a future/planned milestone",
1734
+ description: `Refine context for ${discussableFutureMilestones.length} future milestone(s). Does not affect current execution.`,
1735
+ recommended: false,
1736
+ });
1737
+ }
1738
+
1739
+ const choice = await showNextAction(ctx, {
1740
+ title: "GSD — Discuss a slice",
1741
+ summary: [
1742
+ `${mid}: ${milestoneTitle}`,
1743
+ "Pick a slice to interview. Context file will be written when done.",
1744
+ ],
1745
+ actions,
1746
+ notYetMessage: "Run /gsd discuss when ready.",
1747
+ });
1748
+
1749
+ if (choice === "not_yet") return;
1750
+
1751
+ if (choice === "discuss_queued_milestone") {
1752
+ await showDiscussQueuedMilestone(ctx, pi, basePath, discussableFutureMilestones);
1753
+ return;
1754
+ }
1755
+
1756
+ const chosen = pendingSlices.find(s => s.id === choice);
1757
+ if (!chosen) return;
1758
+
1759
+ // If the slice already has a CONTEXT file, confirm re-discuss intent
1760
+ const isRediscuss = discussedMap.get(chosen.id) ?? false;
1761
+ if (isRediscuss) {
1762
+ const confirm = await showNextAction(ctx, {
1763
+ title: `Re-discuss ${chosen.id}?`,
1764
+ summary: [
1765
+ `${chosen.id} already has a context file from a prior discussion.`,
1766
+ "Re-discussing will interview for updates and rewrite the context file.",
1767
+ ],
1768
+ actions: [
1769
+ { id: "rediscuss", label: "Re-discuss to update context", description: "Interview for changes and rewrite", recommended: true },
1770
+ { id: "cancel", label: "Cancel", description: "Go back to slice picker" },
1771
+ ],
1772
+ });
1773
+ if (confirm !== "rediscuss") continue;
1774
+ }
1775
+
1776
+ const sqAvail = getStructuredQuestionsAvailability(pi, ctx);
1777
+ const prompt = await buildDiscussSlicePrompt(mid, chosen.id, chosen.title, basePath, { rediscuss: isRediscuss, structuredQuestionsAvailable: sqAvail });
1778
+ await dispatchWorkflow(pi, prompt, "gsd-discuss", ctx, "discuss-slice", { basePath });
1779
+
1780
+ // Wait for the discuss session to finish, then loop back to the picker
1781
+ await ctx.waitForIdle();
1782
+ invalidateAllCaches();
1783
+ }
1784
+ }
1785
+
1786
+ // ─── Queued Milestone Discussion ─────────────────────────────────────────────
1787
+
1788
+ /**
1789
+ * Show a picker of queued (pending) milestones and dispatch a discuss flow for
1790
+ * the chosen one. Discussing a queued milestone does NOT activate it — it only
1791
+ * refines the CONTEXT.md artifact so it is better prepared when auto-mode
1792
+ * eventually reaches it.
1793
+ */
1794
+ async function showDiscussQueuedMilestone(
1795
+ ctx: ExtensionCommandContext,
1796
+ pi: ExtensionAPI,
1797
+ basePath: string,
1798
+ pendingMilestones: Array<{ id: string; title: string; status: string }>,
1799
+ ): Promise<void> {
1800
+ const actions = pendingMilestones.map((m, i) => {
1801
+ const hasContext = !!resolveMilestoneFile(basePath, m.id, "CONTEXT");
1802
+ const hasDraft = !hasContext && !!resolveMilestoneFile(basePath, m.id, "CONTEXT-DRAFT");
1803
+ const hasRoadmap = !!resolveMilestoneFile(basePath, m.id, "ROADMAP");
1804
+ const contextStatus = hasContext ? "context ✓" : hasDraft ? "draft context" : "no context yet";
1805
+ const roadmapStatus = hasRoadmap ? " · roadmap ✓" : "";
1806
+ return {
1807
+ id: m.id,
1808
+ label: `${m.id}: ${m.title}`,
1809
+ description: `[${m.status}] · ${contextStatus}${roadmapStatus}`,
1810
+ recommended: i === 0,
1811
+ };
1812
+ });
1813
+
1814
+ const choice = await showNextAction(ctx, {
1815
+ title: "GSD — Discuss a future/planned milestone",
1816
+ summary: [
1817
+ "Select a future or planned milestone to discuss.",
1818
+ "Discussing will update its context file. It will not be activated.",
1819
+ ],
1820
+ actions,
1821
+
1822
+ });
1823
+
1824
+ if (choice === "not_yet") return;
1825
+
1826
+ const chosen = pendingMilestones.find(m => m.id === choice);
1827
+ if (!chosen) return;
1828
+
1829
+ const hasDraft = !!resolveMilestoneFile(basePath, chosen.id, "CONTEXT-DRAFT");
1830
+ let fastPath = hasDraft;
1831
+
1832
+ if (!hasDraft) {
1833
+ const mode = await showNextAction(ctx, {
1834
+ title: `Discuss ${chosen.id}`,
1835
+ summary: [
1836
+ "Choose how to start the discussion.",
1837
+ "Fast path skips generic scouting — use it when you already know the scope.",
1838
+ ],
1839
+ actions: [
1840
+ {
1841
+ id: "full",
1842
+ label: "Full discussion",
1843
+ description: "Scout the codebase, ask open-ended questions, explore deeply",
1844
+ recommended: true,
1845
+ },
1846
+ {
1847
+ id: "fast",
1848
+ label: "I have the scope — fast path",
1849
+ description: "Treat your first message as authoritative seed context; skip scouting",
1850
+ },
1851
+ ],
1852
+ notYetMessage: "Run /gsd discuss when ready.",
1853
+ });
1854
+ if (mode === "not_yet") return;
1855
+ fastPath = mode === "fast";
1856
+ }
1857
+
1858
+ await dispatchDiscussForMilestone(ctx, pi, basePath, chosen.id, chosen.title, { fastPath });
1859
+ }
1860
+
1861
+ /**
1862
+ * Dispatch the guided-discuss-milestone prompt for a milestone without
1863
+ * setting pendingAutoStart — so discussing a queued milestone does not
1864
+ * implicitly activate it when the session ends.
1865
+ */
1866
+ async function dispatchDiscussForMilestone(
1867
+ ctx: ExtensionCommandContext,
1868
+ pi: ExtensionAPI,
1869
+ basePath: string,
1870
+ mid: string,
1871
+ milestoneTitle: string,
1872
+ opts: { fastPath?: boolean } = {},
1873
+ ): Promise<void> {
1874
+ const draftFile = resolveMilestoneFile(basePath, mid, "CONTEXT-DRAFT");
1875
+ const draftContent = draftFile ? await loadFile(draftFile) : null;
1876
+ const hasSeed = !!(draftContent || opts.fastPath);
1877
+ const fastPathInstruction = hasSeed
1878
+ ? [
1879
+ "> **Fast path active — scope provided.**",
1880
+ "> Do NOT perform a generic codebase scouting pass.",
1881
+ "> Do at most 2 targeted reads to check for obvious conflicts with existing work.",
1882
+ "> Treat the seed context or the operator's first message as authoritative.",
1883
+ "> Move directly to the depth summary and write step.",
1884
+ "> Ask only questions where the answer would materially change scope.",
1885
+ ].join("\n")
1886
+ : "";
1887
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
1888
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
1889
+ const basePrompt = loadPrompt("guided-discuss-milestone", {
1890
+ workingDirectory: basePath,
1891
+ milestoneId: mid,
1892
+ milestoneTitle,
1893
+ inlinedTemplates: discussMilestoneTemplates,
1894
+ structuredQuestionsAvailable,
1895
+ commitInstruction: buildDocsCommitInstruction(`docs(${mid}): milestone context from discuss`),
1896
+ fastPathInstruction,
1897
+ });
1898
+ const prompt = draftContent
1899
+ ? `${basePrompt}\n\n## Prior Discussion (Draft Seed)\n\n${draftContent}`
1900
+ : basePrompt;
1901
+ await dispatchWorkflow(pi, prompt, "gsd-discuss", ctx, "discuss-milestone", { basePath });
1902
+ }
1903
+
1904
+ // ─── Smart Entry Point ────────────────────────────────────────────────────────
1905
+
1906
+ /**
1907
+ * The one wizard. Reads state, shows contextual options, dispatches into the workflow doc.
1908
+ */
1909
+ /**
1910
+ * Self-heal: scan runtime records and clear stale ones left behind when
1911
+ * auto-mode crashed mid-unit. auto.ts has its own selfHealRuntimeRecords()
1912
+ * but guided-flow (manual /gsd mode) never called it — meaning stale records
1913
+ * persisted until the next /gsd auto run. This ensures the wizard always
1914
+ * starts from a clean state regardless of how the previous session ended.
1915
+ */
1916
+ function selfHealRuntimeRecords(basePath: string, ctx: ExtensionContext): { cleared: number } {
1917
+ try {
1918
+ const records = listUnitRuntimeRecords(basePath);
1919
+ let cleared = 0;
1920
+ for (const record of records) {
1921
+ const { unitType, unitId, phase } = record;
1922
+ // Clear records whose expected artifact already exists (completed but not cleaned up)
1923
+ // TODO(C-future): selfHealRuntimeRecords iterates across all unit types (not just milestone
1924
+ // units), so it cannot be converted to resolveExpectedArtifactPathForScope without
1925
+ // first establishing a per-record scope. Migrate once unit runtime records carry scope info.
1926
+ const artifactPath = resolveExpectedArtifactPath(unitType, unitId, basePath);
1927
+ if (artifactPath && existsSync(artifactPath)) {
1928
+ clearUnitRuntimeRecord(basePath, unitType, unitId);
1929
+ cleared++;
1930
+ continue;
1931
+ }
1932
+ // Clear records stuck in an in-flight phase (process died mid-unit).
1933
+ if (isInFlightRuntimePhase(phase)) {
1934
+ clearUnitRuntimeRecord(basePath, unitType, unitId);
1935
+ cleared++;
1936
+ }
1937
+ }
1938
+ if (cleared > 0) {
1939
+ ctx.ui.notify(`Self-heal: cleared ${cleared} stale runtime record(s) from a previous session.`, "info");
1940
+ }
1941
+ return { cleared };
1942
+ } catch (e) {
1943
+ logWarning("guided", `self-heal stale runtime records failed: ${(e as Error).message}`);
1944
+ return { cleared: 0 };
1945
+ }
1946
+ }
1947
+
1948
+ // ─── Milestone Actions Submenu ──────────────────────────────────────────────
1949
+
1950
+ /**
1951
+ * Shows a submenu with Park / Discard / Skip / Back options for the active milestone.
1952
+ * Returns true if an action was taken (caller should re-enter showSmartEntry or
1953
+ * dispatch a new workflow). Returns false if the user chose "Back".
1954
+ */
1955
+ async function handleMilestoneActions(
1956
+ ctx: ExtensionCommandContext,
1957
+ pi: ExtensionAPI,
1958
+ basePath: string,
1959
+ milestoneId: string,
1960
+ milestoneTitle: string,
1961
+ options?: { step?: boolean },
1962
+ ): Promise<boolean> {
1963
+ const stepMode = options?.step;
1964
+ const choice = await showNextAction(ctx, {
1965
+ title: `Milestone Actions — ${milestoneId}`,
1966
+ summary: [`${milestoneId}: ${milestoneTitle}`],
1967
+ actions: [
1968
+ {
1969
+ id: "park",
1970
+ label: "Park milestone",
1971
+ description: "Pause this milestone — it stays on disk but is skipped.",
1972
+ },
1973
+ {
1974
+ id: "discard",
1975
+ label: "Discard milestone",
1976
+ description: "Permanently delete this milestone and all its contents.",
1977
+ },
1978
+ {
1979
+ id: "skip",
1980
+ label: "Skip — create new milestone",
1981
+ description: "Leave this milestone and start a fresh one.",
1982
+ },
1983
+ {
1984
+ id: "back",
1985
+ label: "Back",
1986
+ description: "Return to the previous menu.",
1987
+ },
1988
+ ],
1989
+ notYetMessage: "Run /gsd when ready.",
1990
+ });
1991
+
1992
+ if (choice === "park") {
1993
+ const reason = await showNextAction(ctx, {
1994
+ title: `Park ${milestoneId}`,
1995
+ summary: ["Why is this milestone being parked?"],
1996
+ actions: [
1997
+ { id: "priority_shift", label: "Priority shift", description: "Other work is more important right now." },
1998
+ { id: "blocked_external", label: "Blocked externally", description: "Waiting on an external dependency or decision." },
1999
+ { id: "needs_rethink", label: "Needs rethinking", description: "The approach needs to be reconsidered." },
2000
+ ],
2001
+ notYetMessage: "Run /gsd when ready.",
2002
+ });
2003
+
2004
+ // User pressed "Not yet" / Escape — cancel the park operation
2005
+ if (!reason || reason === "not_yet") return false;
2006
+
2007
+ const reasonText = reason === "priority_shift" ? "Priority shift — other work is more important"
2008
+ : reason === "blocked_external" ? "Blocked externally — waiting on external dependency"
2009
+ : reason === "needs_rethink" ? "Needs rethinking — approach needs reconsideration"
2010
+ : "Parked by user";
2011
+
2012
+ const success = parkMilestone(basePath, milestoneId, reasonText);
2013
+ if (success) {
2014
+ ctx.ui.notify(`Parked ${milestoneId}. Run /gsd unpark ${milestoneId} to reactivate.`, "info");
2015
+ } else {
2016
+ ctx.ui.notify(`Could not park ${milestoneId} — milestone not found or already parked.`, "warning");
2017
+ }
2018
+ return true;
2019
+ }
2020
+
2021
+ if (choice === "discard") {
2022
+ const confirmed = await showConfirm(ctx, {
2023
+ title: "Discard milestone?",
2024
+ message: `This will permanently delete ${milestoneId} and all its contents (roadmap, plans, task summaries).`,
2025
+ confirmLabel: "Discard",
2026
+ declineLabel: "Cancel",
2027
+ });
2028
+ if (confirmed) {
2029
+ discardMilestone(basePath, milestoneId);
2030
+ ctx.ui.notify(`Discarded ${milestoneId}.`, "info");
2031
+ return true;
2032
+ }
2033
+ return false;
2034
+ }
2035
+
2036
+ if (choice === "skip") {
2037
+ const milestoneIds = findMilestoneIds(basePath);
2038
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
2039
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
2040
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2041
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2042
+ `New milestone ${nextId}.`,
2043
+ basePath
2044
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2045
+ return true;
2046
+ }
2047
+
2048
+ // "back" or null
2049
+ return false;
2050
+ }
2051
+
2052
+ export async function showSmartEntry(
2053
+ ctx: ExtensionCommandContext,
2054
+ pi: ExtensionAPI,
2055
+ basePath: string,
2056
+ options?: { step?: boolean },
2057
+ ): Promise<void> {
2058
+ const stepMode = options?.step;
2059
+
2060
+ // ── Clear stale milestone ID reservations from previous cancelled sessions ──
2061
+ // Reservations only need to survive within a single /gsd interaction.
2062
+ // Without this, each cancelled session permanently bumps the next ID. (#2488)
2063
+ clearReservedMilestoneIds();
2064
+
2065
+ // ── Directory safety check — refuse to operate in system/home dirs ───
2066
+ const dirCheck = validateDirectory(basePath);
2067
+ if (dirCheck.severity === "blocked") {
2068
+ ctx.ui.notify(dirCheck.reason!, "error");
2069
+ return;
2070
+ }
2071
+ if (dirCheck.severity === "warning") {
2072
+ const proceed = await showConfirm(ctx, {
2073
+ title: "GSD — Unusual Directory",
2074
+ message: dirCheck.reason!,
2075
+ confirmLabel: "Continue anyway",
2076
+ declineLabel: "Cancel",
2077
+ });
2078
+ if (!proceed) return;
2079
+ }
2080
+
2081
+ // ── Detection preamble — run before any bootstrap ────────────────────
2082
+ // Check bootstrap completeness, not just .gsd/ directory existence.
2083
+ // A zombie .gsd/ state (symlink exists but missing PREFERENCES.md and
2084
+ // milestones/) must trigger the init wizard, not skip it (#2942).
2085
+ const gsdPath = gsdRoot(basePath);
2086
+ const hasBootstrapArtifacts = hasGsdBootstrapArtifacts(gsdPath);
2087
+ let skipGitBootstrap = false;
2088
+
2089
+ if (!hasBootstrapArtifacts) {
2090
+ const detection = detectProjectState(basePath);
2091
+
2092
+ // v1 .planning/ detected — offer migration before anything else
2093
+ if (detection.state === "v1-planning" && detection.v1) {
2094
+ const migrationChoice = await offerMigration(ctx, detection.v1);
2095
+ if (migrationChoice === "cancel") return;
2096
+ if (migrationChoice === "migrate") {
2097
+ const { handleMigrate } = await import("./migrate/command.js");
2098
+ await handleMigrate("", ctx, pi);
2099
+ return;
2100
+ }
2101
+ // "fresh" — fall through to init wizard
2102
+ }
2103
+
2104
+ // No .gsd/ or zombie .gsd/ — run the project init wizard
2105
+ const result = await showProjectInit(ctx, pi, basePath, detection);
2106
+ if (!result.completed) return; // User cancelled
2107
+ skipGitBootstrap = shouldSkipGitBootstrapAfterInit(result);
2108
+
2109
+ // Init wizard bootstrapped .gsd/ — fall through to the normal flow below
2110
+ // which will detect "no milestones" and start the discuss prompt
2111
+ }
2112
+
2113
+ // ── Ensure git repo exists — GSD needs it for worktree isolation ──────
2114
+ // Also handle inherited repos: if basePath is a subdirectory of another
2115
+ // git repo that has no .gsd, create a fresh repo to prevent cross-project
2116
+ // state leaks (#1639).
2117
+ if (!skipGitBootstrap && (!nativeIsRepo(basePath) || isInheritedRepo(basePath))) {
2118
+ const mainBranch = loadEffectiveGSDPreferences()?.preferences?.git?.main_branch || "main";
2119
+ nativeInit(basePath, mainBranch);
2120
+ }
2121
+
2122
+ // ── Ensure .gitignore has baseline patterns ──────────────────────────
2123
+ if (!skipGitBootstrap && nativeIsRepo(basePath)) {
2124
+ const gitPrefs = loadEffectiveGSDPreferences(basePath)?.preferences?.git;
2125
+ const manageGitignore = gitPrefs?.manage_gitignore;
2126
+ ensureGitignore(basePath, { manageGitignore });
2127
+ if (manageGitignore !== false) untrackRuntimeFiles(basePath);
2128
+ }
2129
+
2130
+ // Deep setup can pre-create .gsd/PREFERENCES.md before the normal init
2131
+ // wizard path runs. If that path also initialized git, make HEAD reachable
2132
+ // now so later worktree/git-log operations do not run on an unborn branch.
2133
+ if (!skipGitBootstrap && nativeIsRepo(basePath) && !nativeHasCommittedHead(basePath)) {
2134
+ try {
2135
+ nativeAddAll(basePath);
2136
+ nativeCommit(basePath, "chore: init project");
2137
+ } catch (err) {
2138
+ const message = err instanceof Error ? err.message : String(err);
2139
+ logWarning("guided", `initial git commit failed; worktree isolation will remain disabled until HEAD exists: ${message}`);
2140
+ }
2141
+ }
2142
+
2143
+ {
2144
+ const { ensureDbOpen } = await import("./bootstrap/dynamic-tools.js");
2145
+ await ensureDbOpen(basePath);
2146
+ }
2147
+
2148
+ // ── Self-heal stale runtime records from crashed auto-mode sessions ──
2149
+ selfHealRuntimeRecords(basePath, ctx);
2150
+
2151
+ const interrupted = await assessInterruptedSession(basePath);
2152
+ if (interrupted.classification === "running") {
2153
+ ctx.ui.notify(formatInterruptedSessionRunningMessage(interrupted), "error");
2154
+ return;
2155
+ }
2156
+
2157
+ if (interrupted.classification === "stale") {
2158
+ clearLock(basePath);
2159
+ if (interrupted.pausedSession) {
2160
+ // Phase C pt 2: paused-session.json migrated to runtime_kv
2161
+ // (global scope, key PAUSED_SESSION_KV_KEY).
2162
+ try {
2163
+ deleteRuntimeKv("global", "", PAUSED_SESSION_KV_KEY);
2164
+ } catch (e) {
2165
+ logWarning("guided", `stale paused-session DB cleanup failed: ${(e as Error).message}`, { file: "guided-flow.ts" });
2166
+ }
2167
+ }
2168
+ } else if (interrupted.classification === "recoverable") {
2169
+ if (interrupted.lock) clearLock(basePath);
2170
+ const resumeLabel = interrupted.pausedSession?.stepMode
2171
+ ? "Resume with /gsd next"
2172
+ : "Resume with /gsd auto";
2173
+ const resume = await showNextAction(ctx, {
2174
+ title: "GSD — Interrupted Session Detected",
2175
+ summary: formatInterruptedSessionSummary(interrupted),
2176
+ actions: [
2177
+ { id: "resume", label: resumeLabel, description: "Pick up where it left off", recommended: true },
2178
+ { id: "continue", label: "Continue manually", description: "Open the wizard as normal" },
2179
+ ],
2180
+ });
2181
+ if (resume === "resume") {
2182
+ startAutoDetached(ctx, pi, basePath, false, {
2183
+ interrupted,
2184
+ step: interrupted.pausedSession?.stepMode ?? false,
2185
+ });
2186
+ return;
2187
+ }
2188
+ }
2189
+
2190
+ if (interrupted.classification !== "recoverable") {
2191
+ try {
2192
+ const { checkMarkdownHierarchyAgainstDb } = await import("./migration-auto-check.js");
2193
+ const result = await checkMarkdownHierarchyAgainstDb(basePath);
2194
+ if (result.action === "recovery-required") {
2195
+ ctx.ui.notify(
2196
+ result.message ??
2197
+ `Markdown planning artifacts do not match the authoritative DB. Run \`${result.recoveryCommand ?? "gsd recover"}\` to import markdown explicitly.`,
2198
+ "warning",
2199
+ );
2200
+ }
2201
+ } catch (err) {
2202
+ const message = err instanceof Error ? err.message : String(err);
2203
+ ctx.ui.notify(`GSD could not compare markdown planning artifacts with gsd.db: ${message}`, "warning");
2204
+ logWarning("guided", `planning state DB/markdown comparison failed: ${message}`, { file: "guided-flow.ts" });
2205
+ }
2206
+ }
2207
+
2208
+ // Always derive from the project root — the assessment may have derived
2209
+ // state from a worktree path that was cleaned up in the stale branch above.
2210
+ const state = await deriveState(basePath);
2211
+
2212
+ // Rebuild STATE.md from derived state before any dispatch (#3475).
2213
+ try {
2214
+ const { buildStateMarkdown } = await import("./doctor.js");
2215
+ await saveFile(resolveGsdRootFile(basePath, "STATE"), buildStateMarkdown(state));
2216
+ } catch (err) {
2217
+ logWarning("guided", `STATE.md rebuild failed: ${(err as Error).message}`);
2218
+ }
2219
+
2220
+ // ── Deep planning mode kickoff ────────────────────────────────────────
2221
+ // When `planning_depth: deep` is set (e.g. via `/gsd new-project --deep`)
2222
+ // and any project-level stage gate is still pending, keep the user-question
2223
+ // stages in the foreground conversation. Auto-mode is resumed only after
2224
+ // the project interview artifacts exist, so questions do not look like
2225
+ // cancelled auto-mode runs.
2226
+ // Light mode and fully-completed deep projects fall through to the
2227
+ // standard wizard below.
2228
+ {
2229
+ const prefs = loadEffectiveGSDPreferences(basePath)?.preferences;
2230
+ const { shouldRunDeepProjectSetup } = await import("./auto-dispatch.js");
2231
+ if (shouldRunDeepProjectSetup(state, prefs, basePath)) {
2232
+ await startDeepProjectSetupForeground(ctx, pi, basePath, stepMode);
2233
+ return;
2234
+ }
2235
+ }
2236
+
2237
+ const planV2GateDecision = runPlanV2Gate(ctx, basePath, state);
2238
+ if (planV2GateDecision === "block") return;
2239
+
2240
+ if (!state.activeMilestone?.id) {
2241
+ // Guard: if a discuss session is already in flight, don't re-inject the prompt.
2242
+ // Both /gsd and /gsd auto reach this branch when no milestone exists yet.
2243
+ // Without this guard, every subsequent /gsd call overwrites the pending auto-start
2244
+ // and fires another dispatchWorkflow, resetting the conversation mid-interview.
2245
+ if (hasPendingAutoStart(basePath)) {
2246
+ // #3274: If /clear interrupted the discussion, the pending entry is stale.
2247
+ // Detect staleness: no manifest, no milestone CONTEXT artifact, AND entry is older than
2248
+ // 30s (avoids race between .set() and LLM writing first artifact).
2249
+ const entry = _getPendingAutoStart(basePath)!;
2250
+ const ageMs = Date.now() - (entry.createdAt || 0);
2251
+ const manifestExists = existsSync(join(gsdRoot(basePath), "DISCUSSION-MANIFEST.json"));
2252
+ const milestoneHasContext = !!resolveMilestoneFile(basePath, entry.milestoneId, "CONTEXT");
2253
+ const milestoneHasRoadmap = !!resolveMilestoneFile(basePath, entry.milestoneId, "ROADMAP");
2254
+ const milestoneRow = isDbAvailable() ? getMilestone(entry.milestoneId) : null;
2255
+ const discussPlanComplete = milestoneHasRoadmap && !!milestoneRow && milestoneRow.status !== "queued";
2256
+ if (discussPlanComplete) {
2257
+ // The discuss flow already completed, but pending auto-start cleanup handshake did not run.
2258
+ // Clear stale in-memory guard and continue through normal active-milestone routing.
2259
+ deletePendingAutoStart(basePath);
2260
+ } else if (!manifestExists && !milestoneHasContext && ageMs > 30_000) {
2261
+ // Stale entry from an interrupted discussion — clear and continue
2262
+ deletePendingAutoStart(basePath);
2263
+ } else {
2264
+ ctx.ui.notify("Discussion already in progress — answer the question above to continue.", "info");
2265
+ return;
2266
+ }
2267
+ }
2268
+
2269
+ const milestoneIds = findMilestoneIds(basePath);
2270
+
2271
+ // Sanity check (#456): if findMilestoneIds returns [] but the milestones
2272
+ // directory has contents, something went wrong (permissions, stale worktree
2273
+ // cwd, etc). Warn instead of silently starting a new-project flow.
2274
+ if (milestoneIds.length === 0) {
2275
+ const mDir = milestonesDir(basePath);
2276
+ if (existsSync(mDir)) {
2277
+ try {
2278
+ const entries = clearEmptyLegacyDeepSetupPseudoMilestones(basePath, readdirSync(mDir));
2279
+ if (entries.length > 0) {
2280
+ ctx.ui.notify(
2281
+ `Milestone directory has ${entries.length} entries but none were recognized as milestones. ` +
2282
+ `This may indicate a corrupted state or wrong working directory. Run \`/gsd doctor\` to diagnose.`,
2283
+ "warning",
2284
+ );
2285
+ return;
2286
+ }
2287
+ } catch (e) { logWarning("guided", `directory read failed: ${(e as Error).message}`); }
2288
+ }
2289
+ }
2290
+
2291
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
2292
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
2293
+ const isFirst = milestoneIds.length === 0;
2294
+
2295
+ if (isFirst) {
2296
+ // First ever — skip wizard, just ask directly
2297
+ ctx.ui.setStatus("gsd-step", "New Milestone · answer the questions above to plan");
2298
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2299
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2300
+ `New project, milestone ${nextId}. Do NOT read or explore .gsd/ — it's empty scaffolding.`,
2301
+ basePath
2302
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2303
+ } else {
2304
+ if (isNonInteractiveContext(ctx)) {
2305
+ ctx.ui.notify(`Auto-mode stopped — ${state.nextAction || "No active milestone."}`, "info");
2306
+ return;
2307
+ }
2308
+ const choice = await showNextAction(ctx, {
2309
+ title: "GSD — Get Shit Done",
2310
+ summary: ["No active milestone."],
2311
+ actions: [
2312
+ {
2313
+ id: "quick_task",
2314
+ label: "Quick task",
2315
+ description: "For small bounded work, run /gsd quick <task> or /gsd do <task>.",
2316
+ recommended: true,
2317
+ },
2318
+ {
2319
+ id: "new_milestone",
2320
+ label: "Create next milestone",
2321
+ description: "Define a larger body of work with planning artifacts.",
2322
+ },
2323
+ ],
2324
+ notYetMessage: "Run /gsd when ready.",
2325
+ });
2326
+
2327
+ if (choice === "quick_task") {
2328
+ await runQuickTaskChoice(ctx, pi);
2329
+ } else if (choice === "new_milestone") {
2330
+ ctx.ui.setStatus("gsd-step", "New Milestone · answer the questions above to plan");
2331
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2332
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2333
+ `New milestone ${nextId}.`,
2334
+ basePath
2335
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2336
+ }
2337
+ }
2338
+ return;
2339
+ }
2340
+
2341
+ const milestoneId = state.activeMilestone.id;
2342
+ const milestoneTitle = state.activeMilestone.title;
2343
+
2344
+ if (planV2GateDecision === "recover-missing-context") {
2345
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId, step: stepMode });
2346
+ await dispatchWorkflow(
2347
+ pi,
2348
+ await buildDiscussMilestonePrompt(
2349
+ milestoneId,
2350
+ milestoneTitle,
2351
+ basePath,
2352
+ getStructuredQuestionsAvailability(pi, ctx),
2353
+ ),
2354
+ "gsd-discuss",
2355
+ ctx,
2356
+ "discuss-milestone",
2357
+ { basePath },
2358
+ );
2359
+ return;
2360
+ }
2361
+
2362
+ // ── All milestones complete → New milestone ──────────────────────────
2363
+ if (state.phase === "complete") {
2364
+ if (isNonInteractiveContext(ctx)) {
2365
+ ctx.ui.notify("Auto-mode stopped — all milestones complete.", "info");
2366
+ return;
2367
+ }
2368
+ const choice = await showNextAction(ctx, {
2369
+ title: `GSD — ${milestoneId}: ${milestoneTitle}`,
2370
+ summary: ["All milestones complete."],
2371
+ actions: [
2372
+ {
2373
+ id: "quick_task",
2374
+ label: "Quick task",
2375
+ description: "Do a small bounded task without opening a milestone.",
2376
+ recommended: true,
2377
+ },
2378
+ {
2379
+ id: "new_milestone",
2380
+ label: "Start new milestone",
2381
+ description: "Define and plan the next milestone.",
2382
+ },
2383
+ {
2384
+ id: "status",
2385
+ label: "View status",
2386
+ description: "Review what was built.",
2387
+ },
2388
+ ],
2389
+ notYetMessage: "Run /gsd when ready.",
2390
+ });
2391
+
2392
+ if (choice === "quick_task") {
2393
+ await runQuickTaskChoice(ctx, pi);
2394
+ } else if (choice === "new_milestone") {
2395
+ const milestoneIds = findMilestoneIds(basePath);
2396
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
2397
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
2398
+
2399
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2400
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2401
+ `New milestone ${nextId}.`,
2402
+ basePath
2403
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2404
+ } else if (choice === "status") {
2405
+ const { fireStatusViaCommand } = await import("./commands.js");
2406
+ await fireStatusViaCommand(ctx);
2407
+ }
2408
+ return;
2409
+ }
2410
+
2411
+ // ── Draft milestone — needs discussion before planning ────────────────
2412
+ if (state.phase === "needs-discussion") {
2413
+ const draftFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT-DRAFT");
2414
+ const draftContent = draftFile ? await loadFile(draftFile) : null;
2415
+
2416
+ const choice = await showNextAction(ctx, {
2417
+ title: `GSD — ${milestoneId}: ${milestoneTitle}`,
2418
+ summary: ["This milestone has a draft context from a prior discussion.", "It needs a dedicated discussion before auto-planning can begin."],
2419
+ actions: [
2420
+ {
2421
+ id: "discuss_draft",
2422
+ label: "Discuss from draft",
2423
+ description: "Continue where the prior discussion left off — seed material is loaded automatically.",
2424
+ recommended: true,
2425
+ },
2426
+ {
2427
+ id: "discuss_fresh",
2428
+ label: "Start fresh discussion",
2429
+ description: "Discard the draft and start a new discussion from scratch.",
2430
+ },
2431
+ {
2432
+ id: "skip_milestone",
2433
+ label: "Skip — create new milestone",
2434
+ description: "Leave this milestone as-is and start something new.",
2435
+ },
2436
+ ],
2437
+ notYetMessage: "Run /gsd when ready to discuss this milestone.",
2438
+ });
2439
+
2440
+ if (choice === "discuss_draft") {
2441
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
2442
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
2443
+ const basePrompt = loadPrompt("guided-discuss-milestone", {
2444
+ workingDirectory: basePath,
2445
+ milestoneId, milestoneTitle, inlinedTemplates: discussMilestoneTemplates, structuredQuestionsAvailable,
2446
+ commitInstruction: buildDocsCommitInstruction(`docs(${milestoneId}): milestone context from discuss`),
2447
+ fastPathInstruction: "",
2448
+ });
2449
+ const seed = draftContent
2450
+ ? `${basePrompt}\n\n## Prior Discussion (Draft Seed)\n\n${draftContent}`
2451
+ : basePrompt;
2452
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId, step: stepMode });
2453
+ await dispatchWorkflow(pi, seed, "gsd-discuss", ctx, "discuss-milestone", { basePath });
2454
+ } else if (choice === "discuss_fresh") {
2455
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
2456
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
2457
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId, step: stepMode });
2458
+ await dispatchWorkflow(pi, loadPrompt("guided-discuss-milestone", {
2459
+ workingDirectory: basePath,
2460
+ milestoneId, milestoneTitle, inlinedTemplates: discussMilestoneTemplates, structuredQuestionsAvailable,
2461
+ commitInstruction: buildDocsCommitInstruction(`docs(${milestoneId}): milestone context from discuss`),
2462
+ fastPathInstruction: "",
2463
+ }), "gsd-discuss", ctx, "discuss-milestone", { basePath });
2464
+ } else if (choice === "skip_milestone") {
2465
+ const milestoneIds = findMilestoneIds(basePath);
2466
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
2467
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
2468
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2469
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2470
+ `New milestone ${nextId}.`,
2471
+ basePath
2472
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2473
+ }
2474
+ return;
2475
+ }
2476
+
2477
+ if (state.phase === "blocked") {
2478
+ const choice = await showNextAction(ctx, {
2479
+ title: `GSD — ${milestoneId}: ${milestoneTitle}`,
2480
+ summary: state.blockers.length > 0
2481
+ ? state.blockers
2482
+ : [state.nextAction || "This milestone is blocked."],
2483
+ actions: [
2484
+ {
2485
+ id: "status",
2486
+ label: "View status",
2487
+ description: "Review the blocker and current milestone state.",
2488
+ recommended: true,
2489
+ },
2490
+ {
2491
+ id: "park",
2492
+ label: "Park milestone",
2493
+ description: "Explicitly defer this milestone before starting other work.",
2494
+ },
2495
+ ],
2496
+ notYetMessage: "Resolve the blocker, or park the milestone explicitly.",
2497
+ });
2498
+
2499
+ if (choice === "status") {
2500
+ const { fireStatusViaCommand } = await import("./commands.js");
2501
+ await fireStatusViaCommand(ctx);
2502
+ } else if (choice === "park") {
2503
+ const success = parkMilestone(basePath, milestoneId, "Validation attention deferred by user");
2504
+ ctx.ui.notify(
2505
+ success ? `Parked ${milestoneId}. Run /gsd unpark ${milestoneId} to reactivate.` : `Could not park ${milestoneId} — milestone not found.`,
2506
+ success ? "info" : "warning",
2507
+ );
2508
+ }
2509
+ return;
2510
+ }
2511
+
2512
+ // ── No active slice ──────────────────────────────────────────────────
2513
+ if (!state.activeSlice) {
2514
+ const roadmapFile = resolveMilestoneFile(basePath, milestoneId, "ROADMAP");
2515
+ const hasRoadmap = !!(roadmapFile && await loadFile(roadmapFile));
2516
+
2517
+ // A roadmap file with zero parseable slices (placeholder text) should be
2518
+ // treated the same as no roadmap — offer "Create roadmap" instead of "Go auto"
2519
+ // which would immediately get stuck in blocked state (#3441).
2520
+ let roadmapHasSlices = false;
2521
+ if (hasRoadmap) {
2522
+ const roadmapContent = await loadFile(roadmapFile!);
2523
+ if (roadmapContent) {
2524
+ roadmapHasSlices = _roadmapHasParseableSlicesForTest(roadmapContent);
2525
+ }
2526
+ }
2527
+
2528
+ if (!hasRoadmap || !roadmapHasSlices) {
2529
+ // No roadmap → discuss or plan
2530
+ const contextFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT");
2531
+ const hasContext = !!(contextFile && await loadFile(contextFile));
2532
+
2533
+ const actions = [
2534
+ {
2535
+ id: "quick_task",
2536
+ label: "Quick task instead",
2537
+ description: "Use this when the work is small and should not become a milestone.",
2538
+ recommended: true,
2539
+ },
2540
+ {
2541
+ id: "plan",
2542
+ label: "Create roadmap",
2543
+ description: hasContext
2544
+ ? "Context captured. Decompose into slices with a boundary map."
2545
+ : "Decompose the milestone into slices with a boundary map.",
2546
+ },
2547
+ ...(!hasContext ? [{
2548
+ id: "discuss",
2549
+ label: "Discuss first",
2550
+ description: "Capture decisions on gray areas before planning.",
2551
+ }] : []),
2552
+ {
2553
+ id: "skip_milestone",
2554
+ label: "Skip — create new milestone",
2555
+ description: "Leave this milestone on disk and start a fresh one.",
2556
+ },
2557
+ {
2558
+ id: "discard_milestone",
2559
+ label: "Discard this milestone",
2560
+ description: "Delete the milestone directory and start over.",
2561
+ },
2562
+ ];
2563
+
2564
+ const choice = await showNextAction(ctx, {
2565
+ title: `GSD — ${milestoneId}: ${milestoneTitle}`,
2566
+ summary: [hasContext ? "Context captured. Ready to create roadmap." : "New milestone — no roadmap yet."],
2567
+ actions,
2568
+ notYetMessage: "Run /gsd when ready.",
2569
+ });
2570
+
2571
+ if (choice === "quick_task") {
2572
+ await runQuickTaskChoice(ctx, pi);
2573
+ } else if (choice === "plan") {
2574
+ ctx.ui.setStatus("gsd-step", "Planning Milestone · decomposing into slices");
2575
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId, step: stepMode });
2576
+ await dispatchWorkflow(
2577
+ pi,
2578
+ await buildPlanMilestonePrompt(milestoneId, milestoneTitle, basePath),
2579
+ "gsd-run",
2580
+ ctx,
2581
+ "plan-milestone",
2582
+ { basePath },
2583
+ );
2584
+ } else if (choice === "discuss") {
2585
+ const discussMilestoneTemplates = inlineTemplate("context", "Context");
2586
+ const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
2587
+ await dispatchWorkflow(pi, loadPrompt("guided-discuss-milestone", {
2588
+ workingDirectory: basePath,
2589
+ milestoneId, milestoneTitle, inlinedTemplates: discussMilestoneTemplates, structuredQuestionsAvailable,
2590
+ commitInstruction: buildDocsCommitInstruction(`docs(${milestoneId}): milestone context from discuss`),
2591
+ fastPathInstruction: "",
2592
+ }), "gsd-run", ctx, "discuss-milestone", { basePath });
2593
+ } else if (choice === "skip_milestone") {
2594
+ const milestoneIds = findMilestoneIds(basePath);
2595
+ const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
2596
+ const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
2597
+ setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
2598
+ await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
2599
+ `New milestone ${nextId}.`,
2600
+ basePath
2601
+ ), "gsd-run", ctx, "discuss-milestone", { basePath });
2602
+ } else if (choice === "discard_milestone") {
2603
+ const confirmed = await showConfirm(ctx, {
2604
+ title: "Discard milestone?",
2605
+ message: `This will permanently delete ${milestoneId} and all its contents.`,
2606
+ confirmLabel: "Discard",
2607
+ declineLabel: "Cancel",
2608
+ });
2609
+ if (confirmed) {
2610
+ discardMilestone(basePath, milestoneId);
2611
+ return showSmartEntry(ctx, pi, basePath, options);
2612
+ }
2613
+ }
2614
+ } else {
2615
+ // Roadmap exists — either blocked or ready for auto
2616
+ const actions = [
2617
+ {
2618
+ id: "auto",
2619
+ label: "Go auto",
2620
+ description: "Execute everything automatically until milestone complete.",
2621
+ recommended: true,
2622
+ },
2623
+ {
2624
+ id: "status",
2625
+ label: "View status",
2626
+ description: "See milestone progress and blockers.",
2627
+ },
2628
+ {
2629
+ id: "milestone_actions",
2630
+ label: "Milestone actions",
2631
+ description: "Park, discard, or skip this milestone.",
2632
+ },
2633
+ ];
2634
+
2635
+ const choice = await showNextAction(ctx, {
2636
+ title: `GSD — ${milestoneId}: ${milestoneTitle}`,
2637
+ summary: ["Roadmap exists. Ready to execute."],
2638
+ actions,
2639
+ notYetMessage: "Run /gsd status for details.",
2640
+ });
2641
+
2642
+ if (choice === "auto") {
2643
+ startAutoDetached(ctx, pi, basePath, false);
2644
+ } else if (choice === "status") {
2645
+ const { fireStatusViaCommand } = await import("./commands.js");
2646
+ await fireStatusViaCommand(ctx);
2647
+ } else if (choice === "milestone_actions") {
2648
+ const acted = await handleMilestoneActions(ctx, pi, basePath, milestoneId, milestoneTitle, options);
2649
+ if (acted) return showSmartEntry(ctx, pi, basePath, options);
2650
+ }
2651
+ }
2652
+ return;
2653
+ }
2654
+
2655
+ const sliceId = state.activeSlice.id;
2656
+ const sliceTitle = state.activeSlice.title;
2657
+
2658
+ // ── Slice needs planning ─────────────────────────────────────────────
2659
+ if (state.phase === "planning") {
2660
+ const contextFile = resolveSliceFile(basePath, milestoneId, sliceId, "CONTEXT");
2661
+ const researchFile = resolveSliceFile(basePath, milestoneId, sliceId, "RESEARCH");
2662
+ const hasContext = !!(contextFile && await loadFile(contextFile));
2663
+ const hasResearch = !!(researchFile && await loadFile(researchFile));
2664
+
2665
+ const actions = [
2666
+ {
2667
+ id: "plan",
2668
+ label: `Plan ${sliceId}`,
2669
+ description: `Decompose "${sliceTitle}" into tasks with must-haves.`,
2670
+ recommended: true,
2671
+ },
2672
+ ...(!hasContext ? [{
2673
+ id: "discuss",
2674
+ label: `Discuss ${sliceId} first`,
2675
+ description: "Capture context and decisions for this slice.",
2676
+ }] : []),
2677
+ ...(!hasResearch ? [{
2678
+ id: "research",
2679
+ label: `Research ${sliceId} first`,
2680
+ description: "Scout codebase and relevant docs.",
2681
+ }] : []),
2682
+ {
2683
+ id: "status",
2684
+ label: "View status",
2685
+ description: "See milestone progress.",
2686
+ },
2687
+ {
2688
+ id: "milestone_actions",
2689
+ label: "Milestone actions",
2690
+ description: "Park, discard, or skip this milestone.",
2691
+ },
2692
+ ];
2693
+
2694
+ const summaryParts = [];
2695
+ if (hasContext) summaryParts.push("context ✓");
2696
+ if (hasResearch) summaryParts.push("research ✓");
2697
+ const summaryLine = summaryParts.length > 0
2698
+ ? `${sliceId}: ${sliceTitle} (${summaryParts.join(", ")})`
2699
+ : `${sliceId}: ${sliceTitle} — ready for planning.`;
2700
+
2701
+ const choice = await showNextAction(ctx, {
2702
+ title: `GSD — ${milestoneId} / ${sliceId}: ${sliceTitle}`,
2703
+ summary: [summaryLine],
2704
+ actions,
2705
+ notYetMessage: "Run /gsd when ready.",
2706
+ });
2707
+
2708
+ if (choice === "plan") {
2709
+ ctx.ui.setStatus("gsd-step", "Slice Planning · answer the questions above");
2710
+ await dispatchWorkflow(
2711
+ pi,
2712
+ await buildPlanSlicePrompt(milestoneId, milestoneTitle, sliceId, sliceTitle, basePath),
2713
+ "gsd-run",
2714
+ ctx,
2715
+ "plan-slice",
2716
+ { basePath },
2717
+ );
2718
+ } else if (choice === "discuss") {
2719
+ const sqAvail = getStructuredQuestionsAvailability(pi, ctx);
2720
+ await dispatchWorkflow(pi, await buildDiscussSlicePrompt(milestoneId, sliceId, sliceTitle, basePath, { rediscuss: hasContext, structuredQuestionsAvailable: sqAvail }), "gsd-run", ctx, "discuss-slice", { basePath });
2721
+ } else if (choice === "research") {
2722
+ const researchTemplates = inlineTemplate("research", "Research");
2723
+ await dispatchWorkflow(pi, loadPrompt("guided-research-slice", {
2724
+ milestoneId,
2725
+ sliceId,
2726
+ sliceTitle,
2727
+ inlinedTemplates: researchTemplates,
2728
+ skillActivation: buildSkillActivationBlock({
2729
+ base: basePath,
2730
+ milestoneId,
2731
+ sliceId,
2732
+ sliceTitle,
2733
+ extraContext: [researchTemplates],
2734
+ }),
2735
+ }), "gsd-run", ctx, "research-slice", { basePath });
2736
+ } else if (choice === "status") {
2737
+ const { fireStatusViaCommand } = await import("./commands.js");
2738
+ await fireStatusViaCommand(ctx);
2739
+ } else if (choice === "milestone_actions") {
2740
+ const acted = await handleMilestoneActions(ctx, pi, basePath, milestoneId, milestoneTitle, options);
2741
+ if (acted) return showSmartEntry(ctx, pi, basePath, options);
2742
+ }
2743
+ return;
2744
+ }
2745
+
2746
+ // ── All tasks done → Complete slice ──────────────────────────────────
2747
+ if (state.phase === "summarizing") {
2748
+ const choice = await showNextAction(ctx, {
2749
+ title: `GSD — ${milestoneId} / ${sliceId}: ${sliceTitle}`,
2750
+ summary: ["All tasks complete. Ready for slice summary."],
2751
+ actions: [
2752
+ {
2753
+ id: "complete",
2754
+ label: `Complete ${sliceId}`,
2755
+ description: "Write slice summary, UAT, mark done, and squash-merge to main.",
2756
+ recommended: true,
2757
+ },
2758
+ {
2759
+ id: "status",
2760
+ label: "View status",
2761
+ description: "Review tasks before completing.",
2762
+ },
2763
+ {
2764
+ id: "milestone_actions",
2765
+ label: "Milestone actions",
2766
+ description: "Park, discard, or skip this milestone.",
2767
+ },
2768
+ ],
2769
+ notYetMessage: "Run /gsd when ready.",
2770
+ });
2771
+
2772
+ if (choice === "complete") {
2773
+ ctx.ui.setStatus("gsd-step", "Completing Slice · review changes above");
2774
+ await dispatchWorkflow(
2775
+ pi,
2776
+ await buildCompleteSlicePrompt(milestoneId, milestoneTitle, sliceId, sliceTitle, basePath),
2777
+ "gsd-run",
2778
+ ctx,
2779
+ "complete-slice",
2780
+ { basePath },
2781
+ );
2782
+ } else if (choice === "status") {
2783
+ const { fireStatusViaCommand } = await import("./commands.js");
2784
+ await fireStatusViaCommand(ctx);
2785
+ } else if (choice === "milestone_actions") {
2786
+ const acted = await handleMilestoneActions(ctx, pi, basePath, milestoneId, milestoneTitle, options);
2787
+ if (acted) return showSmartEntry(ctx, pi, basePath, options);
2788
+ }
2789
+ return;
2790
+ }
2791
+
2792
+ // ── Active task → Execute ────────────────────────────────────────────
2793
+ if (state.activeTask) {
2794
+ const taskId = state.activeTask.id;
2795
+ const taskTitle = state.activeTask.title;
2796
+
2797
+ const continueFile = resolveSliceFile(basePath, milestoneId, sliceId, "CONTINUE");
2798
+ const sDir = resolveSlicePath(basePath, milestoneId, sliceId);
2799
+ const hasInterrupted = !!(continueFile && await loadFile(continueFile)) ||
2800
+ !!(sDir && await loadFile(join(sDir, "continue.md")));
2801
+
2802
+ const choice = await showNextAction(ctx, {
2803
+ title: `GSD — ${milestoneId} / ${sliceId}: ${sliceTitle}`,
2804
+ summary: [
2805
+ hasInterrupted
2806
+ ? `Resuming: ${taskId} — ${taskTitle}`
2807
+ : `Next: ${taskId} — ${taskTitle}`,
2808
+ ],
2809
+ actions: [
2810
+ {
2811
+ id: "execute",
2812
+ label: hasInterrupted ? `Resume ${taskId}` : `Execute ${taskId}`,
2813
+ description: hasInterrupted
2814
+ ? "Continue from where you left off."
2815
+ : `Start working on "${taskTitle}".`,
2816
+ recommended: true,
2817
+ },
2818
+ {
2819
+ id: "auto",
2820
+ label: "Go auto",
2821
+ description: "Execute this and all remaining tasks automatically.",
2822
+ },
2823
+ {
2824
+ id: "status",
2825
+ label: "View status",
2826
+ description: "See slice progress before starting.",
2827
+ },
2828
+ {
2829
+ id: "milestone_actions",
2830
+ label: "Milestone actions",
2831
+ description: "Park, discard, or skip this milestone.",
2832
+ },
2833
+ ],
2834
+ notYetMessage: "Run /gsd when ready.",
2835
+ });
2836
+
2837
+ if (choice === "not_yet") return;
2838
+
2839
+ const route = resolveActiveTaskChoiceRoute({
2840
+ choice: choice as ActiveTaskChoice,
2841
+ isolationMode: getIsolationMode(basePath),
2842
+ milestoneId,
2843
+ });
2844
+
2845
+ if (route.kind === "auto-bootstrap") {
2846
+ startAutoDetached(ctx, pi, basePath, route.verboseMode, route.options);
2847
+ return;
2848
+ }
2849
+
2850
+ if (route.kind === "guided-dispatch") {
2851
+ ctx.ui.setStatus("gsd-step", "Executing Task · follow progress above");
2852
+ if (hasInterrupted) {
2853
+ await dispatchWorkflow(pi, loadPrompt("guided-resume-task", {
2854
+ milestoneId,
2855
+ sliceId,
2856
+ skillActivation: buildSkillActivationBlock({
2857
+ base: basePath,
2858
+ milestoneId,
2859
+ sliceId,
2860
+ taskId,
2861
+ taskTitle,
2862
+ }),
2863
+ }), "gsd-run", ctx, "execute-task", { basePath });
2864
+ } else {
2865
+ await dispatchWorkflow(
2866
+ pi,
2867
+ await buildExecuteTaskPrompt(milestoneId, sliceId, sliceTitle, taskId, taskTitle, basePath),
2868
+ "gsd-run",
2869
+ ctx,
2870
+ "execute-task",
2871
+ { basePath },
2872
+ );
2873
+ }
2874
+ } else if (route.kind === "status") {
2875
+ const { fireStatusViaCommand } = await import("./commands.js");
2876
+ await fireStatusViaCommand(ctx);
2877
+ } else if (route.kind === "milestone-actions") {
2878
+ const acted = await handleMilestoneActions(ctx, pi, basePath, milestoneId, milestoneTitle, options);
2879
+ if (acted) return showSmartEntry(ctx, pi, basePath, options);
2880
+ }
2881
+ return;
2882
+ }
2883
+
2884
+ // ── Fallback: show status ────────────────────────────────────────────
2885
+ const { fireStatusViaCommand } = await import("./commands.js");
2886
+ await fireStatusViaCommand(ctx);
2887
+ }