gsd-pi 2.71.0 → 2.72.0-dev.8f83716

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 (465) hide show
  1. package/README.md +57 -17
  2. package/dist/cli.js +29 -3
  3. package/dist/headless-events.d.ts +2 -0
  4. package/dist/headless-events.js +7 -0
  5. package/dist/headless.js +16 -3
  6. package/dist/mcp-server.js +40 -17
  7. package/dist/provider-migrations.d.ts +10 -0
  8. package/dist/provider-migrations.js +12 -0
  9. package/dist/resource-loader.js +139 -13
  10. package/dist/resources/GSD-WORKFLOW.md +1 -1
  11. package/dist/resources/agents/debugger.md +58 -0
  12. package/dist/resources/agents/doc-writer.md +43 -0
  13. package/dist/resources/agents/git-ops.md +56 -0
  14. package/dist/resources/agents/javascript-pro.md +46 -271
  15. package/dist/resources/agents/planner.md +55 -0
  16. package/dist/resources/agents/refactorer.md +47 -0
  17. package/dist/resources/agents/reviewer.md +48 -0
  18. package/dist/resources/agents/security.md +59 -0
  19. package/dist/resources/agents/tester.md +50 -0
  20. package/dist/resources/agents/typescript-pro.md +41 -235
  21. package/dist/resources/extensions/claude-code-cli/partial-builder.js +40 -12
  22. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +133 -14
  23. package/dist/resources/extensions/gsd/auto/infra-errors.js +34 -0
  24. package/dist/resources/extensions/gsd/auto/loop.js +32 -1
  25. package/dist/resources/extensions/gsd/auto/phases.js +5 -1
  26. package/dist/resources/extensions/gsd/auto/session.js +11 -0
  27. package/dist/resources/extensions/gsd/auto-dashboard.js +22 -16
  28. package/dist/resources/extensions/gsd/auto-model-selection.js +10 -2
  29. package/dist/resources/extensions/gsd/auto-prompts.js +88 -33
  30. package/dist/resources/extensions/gsd/auto-start.js +34 -7
  31. package/dist/resources/extensions/gsd/auto-tool-tracking.js +1 -1
  32. package/dist/resources/extensions/gsd/auto-worktree.js +1 -1
  33. package/dist/resources/extensions/gsd/auto.js +56 -0
  34. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +3 -3
  35. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +2 -0
  36. package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +63 -51
  37. package/dist/resources/extensions/gsd/bootstrap/system-context.js +6 -0
  38. package/dist/resources/extensions/gsd/commands/context.js +15 -6
  39. package/dist/resources/extensions/gsd/commands/dispatcher.js +12 -2
  40. package/dist/resources/extensions/gsd/commands/handlers/auto.js +10 -33
  41. package/dist/resources/extensions/gsd/commands/handlers/core.js +56 -11
  42. package/dist/resources/extensions/gsd/commands/handlers/notifications-handler.js +15 -6
  43. package/dist/resources/extensions/gsd/commands/handlers/workflow.js +4 -10
  44. package/dist/resources/extensions/gsd/dashboard-overlay.js +8 -3
  45. package/dist/resources/extensions/gsd/dispatch-guard.js +18 -1
  46. package/dist/resources/extensions/gsd/doctor-providers.js +23 -0
  47. package/dist/resources/extensions/gsd/error-classifier.js +5 -2
  48. package/dist/resources/extensions/gsd/forensics.js +19 -6
  49. package/dist/resources/extensions/gsd/gate-registry.js +208 -0
  50. package/dist/resources/extensions/gsd/gsd-db.js +41 -0
  51. package/dist/resources/extensions/gsd/guided-flow.js +5 -10
  52. package/dist/resources/extensions/gsd/metrics.js +1 -0
  53. package/dist/resources/extensions/gsd/milestone-actions.js +10 -4
  54. package/dist/resources/extensions/gsd/milestone-validation-gates.js +11 -12
  55. package/dist/resources/extensions/gsd/notification-overlay.js +42 -13
  56. package/dist/resources/extensions/gsd/notification-store.js +56 -5
  57. package/dist/resources/extensions/gsd/notification-widget.js +5 -13
  58. package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +8 -3
  59. package/dist/resources/extensions/gsd/pre-execution-checks.js +35 -2
  60. package/dist/resources/extensions/gsd/prompt-validation.js +126 -0
  61. package/dist/resources/extensions/gsd/prompts/complete-slice.md +5 -3
  62. package/dist/resources/extensions/gsd/prompts/discuss.md +2 -0
  63. package/dist/resources/extensions/gsd/prompts/execute-task.md +22 -19
  64. package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +2 -0
  65. package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +2 -0
  66. package/dist/resources/extensions/gsd/prompts/guided-resume-task.md +1 -1
  67. package/dist/resources/extensions/gsd/prompts/queue.md +3 -2
  68. package/dist/resources/extensions/gsd/prompts/system.md +1 -0
  69. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +4 -1
  70. package/dist/resources/extensions/gsd/session-model-override.js +25 -0
  71. package/dist/resources/extensions/gsd/shortcut-defs.js +40 -0
  72. package/dist/resources/extensions/gsd/state.js +9 -2
  73. package/dist/resources/extensions/gsd/tools/complete-slice.js +52 -1
  74. package/dist/resources/extensions/gsd/tools/complete-task.js +51 -1
  75. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +4 -1
  76. package/dist/resources/extensions/ollama/index.js +13 -5
  77. package/dist/resources/extensions/shared/gsd-phase-state.js +35 -0
  78. package/dist/resources/extensions/subagent/agents.js +8 -0
  79. package/dist/resources/extensions/subagent/index.js +17 -0
  80. package/dist/resources/skills/create-skill/SKILL.md +2 -0
  81. package/dist/startup-model-validation.d.ts +0 -1
  82. package/dist/startup-model-validation.js +6 -2
  83. package/dist/web/standalone/.next/BUILD_ID +1 -1
  84. package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
  85. package/dist/web/standalone/.next/build-manifest.json +3 -3
  86. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  87. package/dist/web/standalone/.next/required-server-files.json +3 -3
  88. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  89. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  90. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  91. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  95. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  99. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  100. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  101. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  102. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  103. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  104. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  105. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  106. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  107. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  108. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  109. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  110. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  111. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  112. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  113. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  114. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  115. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  116. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  117. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  118. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  119. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  120. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  121. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  122. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  123. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  124. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  125. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  126. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  127. package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
  128. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  129. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  130. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  131. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  132. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  133. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  134. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  135. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  136. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  137. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  138. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  139. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  140. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  141. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  142. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  143. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  144. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  145. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  146. package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
  147. package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
  148. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  149. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  150. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  151. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  152. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  153. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  154. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  155. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  156. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  157. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  158. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  159. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  160. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  161. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  162. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  163. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  164. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  165. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  166. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  167. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  168. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  169. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  170. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  171. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  172. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  173. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  174. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  175. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  176. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
  177. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  178. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  179. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  180. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
  181. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  182. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +2 -2
  183. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  184. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  185. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  186. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  187. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  188. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  189. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  190. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  191. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  192. package/dist/web/standalone/.next/server/app/index.html +1 -1
  193. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  194. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  195. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  196. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  197. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  198. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  199. package/dist/web/standalone/.next/server/app/page.js +2 -2
  200. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  201. package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
  202. package/dist/web/standalone/.next/server/chunks/63.js +3 -3
  203. package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
  204. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  205. package/dist/web/standalone/.next/server/middleware.js +2 -2
  206. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  207. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  208. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  209. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  210. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  211. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
  212. package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
  213. package/dist/web/standalone/.next/static/chunks/app/page-f1e30ab6bb269149.js +1 -0
  214. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
  215. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
  216. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  217. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  218. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  219. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  220. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  221. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  222. package/dist/web/standalone/server.js +1 -1
  223. package/package.json +1 -1
  224. package/packages/mcp-server/dist/server.d.ts +12 -1
  225. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  226. package/packages/mcp-server/dist/server.js +90 -42
  227. package/packages/mcp-server/dist/server.js.map +1 -1
  228. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  229. package/packages/mcp-server/dist/workflow-tools.js +22 -12
  230. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  231. package/packages/mcp-server/src/server.ts +110 -38
  232. package/packages/mcp-server/src/workflow-tools.test.ts +110 -0
  233. package/packages/mcp-server/src/workflow-tools.ts +32 -12
  234. package/packages/pi-ai/dist/providers/amazon-bedrock.js +11 -2
  235. package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  236. package/packages/pi-ai/dist/providers/anthropic-auth.test.d.ts +2 -0
  237. package/packages/pi-ai/dist/providers/anthropic-auth.test.d.ts.map +1 -0
  238. package/packages/pi-ai/dist/providers/anthropic-auth.test.js +20 -0
  239. package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -0
  240. package/packages/pi-ai/dist/providers/anthropic-shared.d.ts +4 -1
  241. package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
  242. package/packages/pi-ai/dist/providers/anthropic-shared.js +8 -3
  243. package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
  244. package/packages/pi-ai/dist/providers/anthropic-shared.test.js +44 -1
  245. package/packages/pi-ai/dist/providers/anthropic-shared.test.js.map +1 -1
  246. package/packages/pi-ai/dist/providers/anthropic.d.ts +2 -1
  247. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  248. package/packages/pi-ai/dist/providers/anthropic.js +7 -4
  249. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  250. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  251. package/packages/pi-ai/dist/providers/openai-completions.js +11 -0
  252. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  253. package/packages/pi-ai/src/providers/amazon-bedrock.ts +13 -1
  254. package/packages/pi-ai/src/providers/anthropic-auth.test.ts +32 -0
  255. package/packages/pi-ai/src/providers/anthropic-shared.test.ts +55 -1
  256. package/packages/pi-ai/src/providers/anthropic-shared.ts +14 -3
  257. package/packages/pi-ai/src/providers/anthropic.ts +8 -4
  258. package/packages/pi-ai/src/providers/openai-completions.ts +14 -0
  259. package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.d.ts +2 -0
  260. package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.d.ts.map +1 -0
  261. package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.js +61 -0
  262. package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.js.map +1 -0
  263. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  264. package/packages/pi-coding-agent/dist/core/agent-session.js +2 -1
  265. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  266. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +10 -0
  267. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  268. package/packages/pi-coding-agent/dist/core/auth-storage.js +27 -0
  269. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  270. package/packages/pi-coding-agent/dist/core/auth-storage.test.js +85 -0
  271. package/packages/pi-coding-agent/dist/core/auth-storage.test.js.map +1 -1
  272. package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.d.ts +2 -0
  273. package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.d.ts.map +1 -0
  274. package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.js +64 -0
  275. package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.js.map +1 -0
  276. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  277. package/packages/pi-coding-agent/dist/core/model-resolver.js +22 -18
  278. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  279. package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts +8 -0
  280. package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts.map +1 -0
  281. package/packages/pi-coding-agent/dist/core/model-resolver.test.js +75 -0
  282. package/packages/pi-coding-agent/dist/core/model-resolver.test.js.map +1 -0
  283. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +5 -0
  284. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -1
  285. package/packages/pi-coding-agent/dist/core/retry-handler.js +55 -1
  286. package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -1
  287. package/packages/pi-coding-agent/dist/core/retry-handler.test.js +57 -0
  288. package/packages/pi-coding-agent/dist/core/retry-handler.test.js.map +1 -1
  289. package/packages/pi-coding-agent/dist/core/sdk.d.ts +11 -0
  290. package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  291. package/packages/pi-coding-agent/dist/core/sdk.js +38 -5
  292. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  293. package/packages/pi-coding-agent/dist/core/sdk.test.d.ts +2 -0
  294. package/packages/pi-coding-agent/dist/core/sdk.test.d.ts.map +1 -0
  295. package/packages/pi-coding-agent/dist/core/sdk.test.js +71 -0
  296. package/packages/pi-coding-agent/dist/core/sdk.test.js.map +1 -0
  297. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  298. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  299. package/packages/pi-coding-agent/dist/index.js +1 -1
  300. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  301. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.d.ts +2 -0
  302. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.d.ts.map +1 -0
  303. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.js +13 -0
  304. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.js.map +1 -0
  305. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +36 -0
  306. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  307. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +4 -0
  308. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  309. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +24 -2
  310. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
  311. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  312. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +9 -2
  313. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
  314. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +4 -0
  315. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  316. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +130 -12
  317. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  318. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  319. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +7 -2
  320. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  321. package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.d.ts.map +1 -1
  322. package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js +6 -1
  323. package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js.map +1 -1
  324. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  325. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +4 -3
  326. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  327. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +4 -2
  328. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
  329. package/packages/pi-coding-agent/package.json +1 -1
  330. package/packages/pi-coding-agent/src/core/agent-session-renderable-tools.test.ts +70 -0
  331. package/packages/pi-coding-agent/src/core/agent-session.ts +2 -1
  332. package/packages/pi-coding-agent/src/core/auth-storage.test.ts +108 -0
  333. package/packages/pi-coding-agent/src/core/auth-storage.ts +30 -0
  334. package/packages/pi-coding-agent/src/core/model-resolver-initial-model-auth.test.ts +78 -0
  335. package/packages/pi-coding-agent/src/core/model-resolver.test.ts +85 -0
  336. package/packages/pi-coding-agent/src/core/model-resolver.ts +22 -18
  337. package/packages/pi-coding-agent/src/core/retry-handler.test.ts +83 -0
  338. package/packages/pi-coding-agent/src/core/retry-handler.ts +60 -1
  339. package/packages/pi-coding-agent/src/core/sdk.test.ts +89 -0
  340. package/packages/pi-coding-agent/src/core/sdk.ts +45 -9
  341. package/packages/pi-coding-agent/src/index.ts +1 -0
  342. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/login-dialog.test.ts +24 -0
  343. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +72 -0
  344. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +30 -2
  345. package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +15 -6
  346. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +131 -12
  347. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +7 -2
  348. package/packages/pi-coding-agent/src/modes/interactive/controllers/model-controller.ts +6 -1
  349. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4 -3
  350. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +4 -2
  351. package/pkg/package.json +1 -1
  352. package/src/resources/GSD-WORKFLOW.md +1 -1
  353. package/src/resources/agents/debugger.md +58 -0
  354. package/src/resources/agents/doc-writer.md +43 -0
  355. package/src/resources/agents/git-ops.md +56 -0
  356. package/src/resources/agents/javascript-pro.md +46 -271
  357. package/src/resources/agents/planner.md +55 -0
  358. package/src/resources/agents/refactorer.md +47 -0
  359. package/src/resources/agents/reviewer.md +48 -0
  360. package/src/resources/agents/security.md +59 -0
  361. package/src/resources/agents/tester.md +50 -0
  362. package/src/resources/agents/typescript-pro.md +41 -235
  363. package/src/resources/extensions/claude-code-cli/partial-builder.ts +45 -12
  364. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +143 -13
  365. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +91 -2
  366. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +281 -6
  367. package/src/resources/extensions/gsd/auto/infra-errors.ts +38 -0
  368. package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -0
  369. package/src/resources/extensions/gsd/auto/loop.ts +45 -1
  370. package/src/resources/extensions/gsd/auto/phases.ts +6 -0
  371. package/src/resources/extensions/gsd/auto/session.ts +11 -0
  372. package/src/resources/extensions/gsd/auto-dashboard.ts +29 -18
  373. package/src/resources/extensions/gsd/auto-model-selection.ts +9 -1
  374. package/src/resources/extensions/gsd/auto-prompts.ts +111 -33
  375. package/src/resources/extensions/gsd/auto-start.ts +41 -7
  376. package/src/resources/extensions/gsd/auto-tool-tracking.ts +1 -1
  377. package/src/resources/extensions/gsd/auto-worktree.ts +1 -1
  378. package/src/resources/extensions/gsd/auto.ts +72 -0
  379. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +3 -3
  380. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +2 -0
  381. package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +79 -60
  382. package/src/resources/extensions/gsd/bootstrap/system-context.ts +7 -0
  383. package/src/resources/extensions/gsd/commands/context.ts +16 -5
  384. package/src/resources/extensions/gsd/commands/dispatcher.ts +14 -2
  385. package/src/resources/extensions/gsd/commands/handlers/auto.ts +10 -36
  386. package/src/resources/extensions/gsd/commands/handlers/core.ts +58 -11
  387. package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +17 -7
  388. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +4 -10
  389. package/src/resources/extensions/gsd/dashboard-overlay.ts +10 -3
  390. package/src/resources/extensions/gsd/dispatch-guard.ts +18 -1
  391. package/src/resources/extensions/gsd/doctor-providers.ts +24 -0
  392. package/src/resources/extensions/gsd/error-classifier.ts +5 -2
  393. package/src/resources/extensions/gsd/forensics.ts +23 -7
  394. package/src/resources/extensions/gsd/gate-registry.ts +251 -0
  395. package/src/resources/extensions/gsd/gsd-db.ts +51 -0
  396. package/src/resources/extensions/gsd/guided-flow.ts +5 -10
  397. package/src/resources/extensions/gsd/interrupted-session.ts +1 -0
  398. package/src/resources/extensions/gsd/metrics.ts +12 -1
  399. package/src/resources/extensions/gsd/milestone-actions.ts +10 -3
  400. package/src/resources/extensions/gsd/milestone-validation-gates.ts +11 -13
  401. package/src/resources/extensions/gsd/notification-overlay.ts +47 -14
  402. package/src/resources/extensions/gsd/notification-store.ts +54 -5
  403. package/src/resources/extensions/gsd/notification-widget.ts +5 -14
  404. package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +10 -3
  405. package/src/resources/extensions/gsd/pre-execution-checks.ts +39 -2
  406. package/src/resources/extensions/gsd/prompt-validation.ts +157 -0
  407. package/src/resources/extensions/gsd/prompts/complete-slice.md +5 -3
  408. package/src/resources/extensions/gsd/prompts/discuss.md +2 -0
  409. package/src/resources/extensions/gsd/prompts/execute-task.md +22 -19
  410. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +2 -0
  411. package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +2 -0
  412. package/src/resources/extensions/gsd/prompts/guided-resume-task.md +1 -1
  413. package/src/resources/extensions/gsd/prompts/queue.md +3 -2
  414. package/src/resources/extensions/gsd/prompts/system.md +1 -0
  415. package/src/resources/extensions/gsd/prompts/validate-milestone.md +4 -1
  416. package/src/resources/extensions/gsd/session-model-override.ts +36 -0
  417. package/src/resources/extensions/gsd/shortcut-defs.ts +56 -0
  418. package/src/resources/extensions/gsd/state.ts +13 -2
  419. package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +25 -9
  420. package/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts +28 -0
  421. package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +39 -0
  422. package/src/resources/extensions/gsd/tests/complete-slice-gate-closure.test.ts +167 -0
  423. package/src/resources/extensions/gsd/tests/complete-slice-prompt-task-summary-layout.test.ts +18 -0
  424. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +27 -0
  425. package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +36 -0
  426. package/src/resources/extensions/gsd/tests/execute-task-prompt-existing-artifact-guard.test.ts +33 -0
  427. package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +62 -0
  428. package/src/resources/extensions/gsd/tests/format-shortcut.test.ts +31 -0
  429. package/src/resources/extensions/gsd/tests/gate-dispatch.test.ts +27 -0
  430. package/src/resources/extensions/gsd/tests/gate-registry.test.ts +140 -0
  431. package/src/resources/extensions/gsd/tests/gsd-no-project-error.test.ts +73 -0
  432. package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +180 -0
  433. package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +66 -1
  434. package/src/resources/extensions/gsd/tests/model-isolation.test.ts +36 -51
  435. package/src/resources/extensions/gsd/tests/notification-store.test.ts +35 -0
  436. package/src/resources/extensions/gsd/tests/notification-widget.test.ts +26 -0
  437. package/src/resources/extensions/gsd/tests/notifications-handler.test.ts +90 -0
  438. package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +1 -0
  439. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +18 -0
  440. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +49 -0
  441. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +19 -0
  442. package/src/resources/extensions/gsd/tests/prompt-system-gate-coverage.test.ts +208 -0
  443. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +16 -0
  444. package/src/resources/extensions/gsd/tests/register-shortcuts.test.ts +63 -5
  445. package/src/resources/extensions/gsd/tests/session-model-override.test.ts +35 -0
  446. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +90 -0
  447. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +7 -0
  448. package/src/resources/extensions/gsd/tests/validate-milestone-prompt-verification-classes.test.ts +18 -0
  449. package/src/resources/extensions/gsd/tools/complete-slice.ts +63 -0
  450. package/src/resources/extensions/gsd/tools/complete-task.ts +63 -0
  451. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +4 -1
  452. package/src/resources/extensions/gsd/types.ts +26 -0
  453. package/src/resources/extensions/ollama/index.ts +13 -3
  454. package/src/resources/extensions/ollama/ollama-status-indicator.test.ts +28 -0
  455. package/src/resources/extensions/shared/gsd-phase-state.ts +42 -0
  456. package/src/resources/extensions/shared/tests/gsd-phase-state.test.ts +48 -0
  457. package/src/resources/extensions/subagent/agents.ts +10 -0
  458. package/src/resources/extensions/subagent/index.ts +18 -0
  459. package/src/resources/extensions/subagent/tests/agents-conflicts.test.ts +33 -0
  460. package/src/resources/skills/create-skill/SKILL.md +2 -0
  461. package/dist/web/standalone/.next/static/chunks/app/page-7115e62689b5fd84.js +0 -1
  462. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
  463. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
  464. /package/dist/web/standalone/.next/static/{nPky_WQC28aBD77eZsRAB → nCL1Ivw47iAAoKVgerXNi}/_buildManifest.js +0 -0
  465. /package/dist/web/standalone/.next/static/{nPky_WQC28aBD77eZsRAB → nCL1Ivw47iAAoKVgerXNi}/_ssgManifest.js +0 -0
@@ -2,254 +2,60 @@
2
2
  name: typescript-pro
3
3
  description: "TypeScript specialist for advanced type system patterns, complex generics, type-level programming, and end-to-end type safety across full-stack applications. Use when designing type-first APIs, creating branded types for domain modeling, building generic utilities, implementing discriminated unions for state machines, configuring tsconfig and build tooling, authoring type-safe libraries, setting up monorepo project references, migrating JavaScript to TypeScript, or optimizing TypeScript compilation and bundle performance."
4
4
  model: sonnet
5
- memory: project
6
5
  ---
7
6
 
8
- You are a senior TypeScript developer with mastery of TypeScript 5.0+ and its ecosystem, specializing in advanced type system features, full-stack type safety, and modern build tooling. Your expertise spans frontend frameworks, Node.js backends, and cross-platform development with focus on type safety and developer productivity.
7
+ You are a senior TypeScript developer with mastery of TypeScript 5.0+ and its ecosystem. You specialize in advanced type system features, full-stack type safety, and modern build tooling. Types are the specification start there.
9
8
 
10
- ## Core Operating Principles
9
+ ## Initialization
11
10
 
12
- - **Type-first development**: Always start with type definitions before implementation. Types are the specification.
13
- - **Strict mode always**: Assume `strict: true` and all strict compiler flags unless the project explicitly opts out. Never introduce `any` without documented justification.
14
- - **Verify before stating**: Read actual project configuration (tsconfig.json, package.json, build configs) before making assumptions about the project setup.
15
- - **Observable facts over assumptions**: If you need to know the TypeScript version, compiler options, or existing patterns — read the files. Do not guess.
11
+ 1. Read `tsconfig.json`, `package.json`, and build tool configs
12
+ 2. Assess existing type patterns generics, utility types, declaration files
13
+ 3. Identify framework and runtime (React, Vue, Node.js, Deno)
14
+ 4. Check lint/format config to align with project conventions
16
15
 
17
- ## Initialization Protocol
16
+ ## Core Principles
18
17
 
19
- When invoked for any task:
18
+ - **Strict mode always**: `strict: true`, no `any` without documented justification
19
+ - **Type-first**: Define data shapes and API contracts before writing logic
20
+ - **Inference over annotation**: Let TypeScript infer where it produces correct, readable types
21
+ - **`satisfies` over type annotation**: Preserves literal types while validating
22
+ - **`as const`** for literal preservation in arrays and objects
23
+ - **`import type`** for type-only imports — reduces emit, improves tree shaking
24
+ - **Exhaustive checks** with `never` in switch/if-else — catch unhandled cases at compile time
20
25
 
21
- 1. **Read project configuration**: Check for `tsconfig.json`, `package.json`, and build tool configs (vite.config.ts, next.config.js, webpack.config.ts, etc.)
22
- 2. **Assess existing type patterns**: Grep for type imports, generic usage, utility types, and declaration files to understand the project's type maturity
23
- 3. **Identify framework and runtime**: Determine if this is React, Vue, Angular, Node.js, Deno, or another target — this affects type patterns and available APIs
24
- 4. **Check existing lint/format config**: Look for .eslintrc, prettier config, biome config to align with project conventions
26
+ ## Key Patterns
25
27
 
26
- ## TypeScript Development Checklist
28
+ - Conditional types for flexible APIs: `T extends Array<infer U> ? { data: U[] } : { data: T }`
29
+ - Mapped types for transformations: `{ readonly [K in keyof T]: T[K] }`
30
+ - Template literal types for string manipulation: `` `on${Capitalize<T>}` ``
31
+ - Discriminated unions for state machines — each variant has a literal tag
32
+ - Branded types for domain modeling: `T & { readonly __brand: B }`
33
+ - Result types for error handling: `{ ok: true; value: T } | { ok: false; error: E }`
34
+ - Type guards at runtime boundaries — validate all external data (APIs, user input, files)
27
35
 
28
- Apply to every implementation:
36
+ ## Build & Tooling
29
37
 
30
- - [ ] Strict mode enabled with all compiler flags
31
- - [ ] No explicit `any` usage without documented justification
32
- - [ ] 100% type coverage for public APIs
33
- - [ ] Type-only imports used where applicable (`import type { ... }`)
34
- - [ ] Source maps properly configured for debugging
35
- - [ ] Declaration files generated for library code
36
- - [ ] Generic constraints are as narrow as possible
37
- - [ ] Discriminated unions preferred over optional fields for variant types
38
+ - `moduleResolution: "bundler"` for modern bundler projects
39
+ - `isolatedModules: true` for esbuild/SWC compatibility
40
+ - `incremental: true` with `.tsbuildinfo` for faster rebuilds
41
+ - `composite: true` + `declarationMap: true` for monorepo project references
42
+ - Type-only imports to reduce emit and improve tree shaking
43
+ - Monitor type instantiation counts with `--generateTrace` for slow compiles
38
44
 
39
- ## Advanced Type Patterns
45
+ ## Testing
40
46
 
41
- Apply these patterns where they improve safety and developer experience:
42
-
43
- **Conditional types** for flexible APIs:
44
- ```typescript
45
- type ApiResponse<T> = T extends Array<infer U>
46
- ? { data: U[]; total: number }
47
- : { data: T };
48
- ```
49
-
50
- **Mapped types** for transformations:
51
- ```typescript
52
- type Readonly<T> = { readonly [K in keyof T]: T[K] };
53
- type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
54
- ```
55
-
56
- **Template literal types** for string manipulation:
57
- ```typescript
58
- type EventName<T extends string> = `on${Capitalize<T>}`;
59
- type RouteParam<T extends string> = T extends `${infer _}:${infer Param}/${infer Rest}`
60
- ? Param | RouteParam<Rest>
61
- : T extends `${infer _}:${infer Param}` ? Param : never;
62
- ```
63
-
64
- **Discriminated unions** for state machines:
65
- ```typescript
66
- type State =
67
- | { status: 'idle' }
68
- | { status: 'loading'; startedAt: number }
69
- | { status: 'success'; data: unknown; completedAt: number }
70
- | { status: 'error'; error: Error; failedAt: number };
71
- ```
72
-
73
- **Branded types** for domain modeling:
74
- ```typescript
75
- type Brand<T, B extends string> = T & { readonly __brand: B };
76
- type UserId = Brand<string, 'UserId'>;
77
- type OrderId = Brand<string, 'OrderId'>;
78
- ```
79
-
80
- **Result types** for error handling:
81
- ```typescript
82
- type Result<T, E = Error> =
83
- | { ok: true; value: T }
84
- | { ok: false; error: E };
85
- ```
86
-
87
- ## Implementation Strategy
88
-
89
- When implementing TypeScript code:
90
-
91
- 1. **Design types first**: Define the data shapes, API contracts, and state types before writing any logic
92
- 2. **Use the compiler as a correctness tool**: Structure types so invalid states are unrepresentable
93
- 3. **Leverage inference**: Don't over-annotate — let TypeScript infer where it produces correct and readable types
94
- 4. **Create type guards for runtime boundaries**: All external data (API responses, user input, file reads) must pass through type guards or validation
95
- 5. **Use `satisfies` for type validation without widening**: Prefer `const config = { ... } satisfies Config` over `const config: Config = { ... }` when you want to preserve literal types
96
- 6. **Use `as const` for literal types**: Apply const assertions to preserve literal types in arrays and objects
97
- 7. **Exhaustive checking**: Use `never` type in switch/if-else chains to ensure all cases are handled
98
-
99
- ```typescript
100
- function assertNever(x: never): never {
101
- throw new Error(`Unexpected value: ${x}`);
102
- }
103
-
104
- function handleState(state: State): string {
105
- switch (state.status) {
106
- case 'idle': return 'Waiting';
107
- case 'loading': return 'Loading...';
108
- case 'success': return 'Done';
109
- case 'error': return state.error.message;
110
- default: return assertNever(state);
111
- }
112
- }
113
- ```
114
-
115
- ## Build and Tooling Optimization
116
-
117
- **tsconfig.json best practices**:
118
- - Use `moduleResolution: "bundler"` for modern bundler-based projects
119
- - Use `module: "ESNext"` or `"NodeNext"` depending on target
120
- - Enable `isolatedModules: true` for compatibility with transpile-only tools (esbuild, SWC)
121
- - Set `skipLibCheck: true` only if third-party declarations cause issues — prefer fixing the root cause
122
- - Use `paths` mapping for clean imports, backed by bundler aliases
123
- - Configure `project references` for monorepos with `composite: true` and `declarationMap: true`
124
-
125
- **Incremental compilation**:
126
- - Enable `incremental: true` with a `.tsbuildinfo` output path
127
- - Use `--build` mode for project references
128
- - Configure `tsBuildInfoFile` to a persistent location in CI
129
-
130
- **Performance tuning**:
131
- - Use `type-only imports` to reduce emit and improve tree shaking
132
- - Prefer `const enum` only when bundle size savings justify the trade-off (they don't work with `isolatedModules`)
133
- - Avoid deeply recursive conditional types in hot paths — they slow the compiler
134
- - Monitor type instantiation counts with `--generateTrace`
135
-
136
- ## Testing With Types
137
-
138
- - Write type tests using `expectTypeOf` (from vitest) or `tsd` for declaration testing
139
- - Create type-safe test utilities and fixtures
140
- - Use generic factory functions for test data
141
- - Ensure mock types match the real implementations
47
+ - Type tests with `expectTypeOf` (vitest) or `tsd` for declaration testing
48
+ - Type-safe test utilities and generic factory functions for test data
142
49
  - Test type narrowing paths explicitly
50
+ - Ensure mock types match real implementations
143
51
 
144
- ```typescript
145
- import { expectTypeOf } from 'vitest';
146
-
147
- test('type narrowing works', () => {
148
- const result: Result<string> = { ok: true, value: 'hello' };
149
- if (result.ok) {
150
- expectTypeOf(result.value).toBeString();
151
- } else {
152
- expectTypeOf(result.error).toEqualTypeOf<Error>();
153
- }
154
- });
155
- ```
156
-
157
- ## Full-Stack Type Safety
158
-
159
- - **tRPC**: Use for end-to-end type safety between client and server without code generation
160
- - **GraphQL**: Use code generation (graphql-codegen) for type-safe queries and mutations
161
- - **OpenAPI**: Generate TypeScript clients from OpenAPI specs
162
- - **Shared packages**: Extract shared types into dedicated packages in monorepos
163
- - **Database types**: Use query builders (Prisma, Drizzle, Kysely) that generate types from schema
164
- - **Form validation**: Use Zod schemas that infer TypeScript types (`z.infer<typeof schema>`)
165
-
166
- ## Error Handling Patterns
167
-
168
- - Prefer `Result<T, E>` types over throwing exceptions for expected error cases
169
- - Use `never` return type for functions that always throw
170
- - Create typed error hierarchies with discriminated unions
171
- - Type-safe error boundaries in React with proper generic constraints
172
- - Validate all external data at boundaries using Zod or similar runtime validators
173
-
174
- ## Library Authoring
175
-
176
- When creating libraries or shared packages:
177
-
178
- - Generate `.d.ts` declaration files with `declaration: true`
179
- - Enable `declarationMap: true` for go-to-definition into source
180
- - Use `exports` field in package.json for proper dual CJS/ESM support
181
- - Design generic APIs with minimal constraints — widen later if needed
182
- - Document generic type parameters with JSDoc `@typeParam`
183
- - Test declarations with `tsd` or `@ts-expect-error` assertions
184
- - Version type changes according to semver (breaking type changes = major version)
185
-
186
- ## Code Generation
187
-
188
- - **OpenAPI → TypeScript**: Use `openapi-typescript` for type generation, `openapi-fetch` for type-safe clients
189
- - **GraphQL → TypeScript**: Use `@graphql-codegen/cli` with appropriate plugins
190
- - **Database → TypeScript**: Use Prisma's `prisma generate` or Drizzle's schema inference
191
- - **Route → TypeScript**: Leverage framework-specific type generation (Next.js, tRPC)
192
-
193
- ## Quality Verification
194
-
195
- Before declaring any TypeScript task complete:
196
-
197
- 1. **Compile check**: Run `npx tsc --noEmit` and resolve all errors
198
- 2. **Lint check**: Run the project's configured linter (ESLint, Biome) with zero warnings
199
- 3. **Type coverage**: Verify no untyped public APIs remain
200
- 4. **Test execution**: Run the test suite and verify passing
201
- 5. **Bundle analysis**: If applicable, verify bundle size impact
202
- 6. **Declaration quality**: If library code, verify generated `.d.ts` files are correct and complete
203
-
204
- ## Communication Standards
205
-
206
- - State what you observed in the codebase, not what you assume
207
- - When proposing type patterns, explain why they improve safety or DX over alternatives
208
- - If a type pattern is complex, include a usage example showing how it catches errors at compile time
209
- - Report type coverage metrics when completing type-heavy work
210
- - Flag any `any` types introduced with explicit justification
211
-
212
- **Update your agent memory** as you discover TypeScript configuration patterns, type conventions, framework-specific typing approaches, build tool configurations, and architectural decisions in the codebase. Write concise notes about what you found and where.
213
-
214
- Examples of what to record:
215
- - tsconfig.json settings and their rationale
216
- - Custom utility types defined in the project
217
- - Type generation pipelines and their configuration
218
- - Framework-specific typing patterns used
219
- - Build performance characteristics and optimization strategies
220
- - Common type errors encountered and their fixes
221
- - Module resolution quirks specific to the project
222
-
223
- # Persistent Agent Memory
224
-
225
- You have a persistent Persistent Agent Memory directory at `/home/ubuntulinuxqa2/repos/claude_skills/.claude/agent-memory/typescript-pro/`. Its contents persist across conversations.
226
-
227
- As you work, consult your memory files to build on previous experience. When you encounter a mistake that seems like it could be common, check your Persistent Agent Memory for relevant notes — and if nothing is written yet, record what you learned.
228
-
229
- Guidelines:
230
- - `MEMORY.md` is always loaded into your system prompt — lines after 200 will be truncated, so keep it concise
231
- - Create separate topic files (e.g., `debugging.md`, `patterns.md`) for detailed notes and link to them from MEMORY.md
232
- - Update or remove memories that turn out to be wrong or outdated
233
- - Organize memory semantically by topic, not chronologically
234
- - Use the Write and Edit tools to update your memory files
235
-
236
- What to save:
237
- - Stable patterns and conventions confirmed across multiple interactions
238
- - Key architectural decisions, important file paths, and project structure
239
- - User preferences for workflow, tools, and communication style
240
- - Solutions to recurring problems and debugging insights
241
-
242
- What NOT to save:
243
- - Session-specific context (current task details, in-progress work, temporary state)
244
- - Information that might be incomplete — verify against project docs before writing
245
- - Anything that duplicates or contradicts existing CLAUDE.md instructions
246
- - Speculative or unverified conclusions from reading a single file
247
-
248
- Explicit user requests:
249
- - When the user asks you to remember something across sessions (e.g., "always use bun", "never auto-commit"), save it — no need to wait for multiple interactions
250
- - When the user asks to forget or stop remembering something, find and remove the relevant entries from your memory files
251
- - Since this memory is project-scope and shared with your team via version control, tailor your memories to this project
52
+ ## Verification Checklist
252
53
 
253
- ## MEMORY.md
54
+ 1. `npx tsc --noEmit` — zero errors
55
+ 2. Linter passes with zero warnings
56
+ 3. No untyped public APIs remain
57
+ 4. Tests passing, coverage target met
58
+ 5. Declaration files correct for library code
59
+ 6. No `any` without justification comment
254
60
 
255
- Your MEMORY.md is currently empty. When you notice a pattern worth preserving across sessions, save it here. Anything in MEMORY.md will be included in your system prompt next time.
61
+ Report concrete outcomes files changed, type coverage, test results, trade-offs made.
@@ -19,6 +19,49 @@ import type {
19
19
  import { hasXmlParameterTags, repairToolJson } from "@gsd/pi-ai";
20
20
  import type { BetaContentBlock, BetaRawMessageStreamEvent, NonNullableUsage } from "./sdk-types.js";
21
21
 
22
+ // ---------------------------------------------------------------------------
23
+ // MCP tool name parsing
24
+ // ---------------------------------------------------------------------------
25
+
26
+ /**
27
+ * Split a Claude Code MCP tool name (`mcp__<server>__<tool>`) into its parts.
28
+ * Returns null for non-prefixed names so callers can fall through unchanged.
29
+ *
30
+ * Server names may contain hyphens (`gsd-workflow`); the SDK uses the literal
31
+ * `__` delimiter between the server name and the tool name.
32
+ */
33
+ export function parseMcpToolName(name: string): { server: string; tool: string } | null {
34
+ if (!name.startsWith("mcp__")) return null;
35
+ const rest = name.slice("mcp__".length);
36
+ const delim = rest.indexOf("__");
37
+ if (delim <= 0 || delim === rest.length - 2) return null;
38
+ return { server: rest.slice(0, delim), tool: rest.slice(delim + 2) };
39
+ }
40
+
41
+ /**
42
+ * Build a GSD ToolCall block from a Claude Code SDK tool_use block, stripping
43
+ * the `mcp__<server>__` prefix from the name so registered extension renderers
44
+ * (which use the unprefixed canonical names) can match. The original server
45
+ * name is preserved on the block for diagnostics and rendering.
46
+ */
47
+ function toolCallFromBlock(
48
+ id: string,
49
+ rawName: string,
50
+ input: Record<string, unknown>,
51
+ ): ToolCall {
52
+ const parsed = parseMcpToolName(rawName);
53
+ const toolCall: ToolCall = {
54
+ type: "toolCall",
55
+ id,
56
+ name: parsed ? parsed.tool : rawName,
57
+ arguments: input,
58
+ };
59
+ if (parsed) {
60
+ (toolCall as ToolCall & { mcpServer?: string }).mcpServer = parsed.server;
61
+ }
62
+ return toolCall;
63
+ }
64
+
22
65
  // ---------------------------------------------------------------------------
23
66
  // Content-block mapping helpers
24
67
  // ---------------------------------------------------------------------------
@@ -41,12 +84,7 @@ export function mapContentBlock(
41
84
  } satisfies ThinkingContent;
42
85
 
43
86
  case "tool_use":
44
- return {
45
- type: "toolCall",
46
- id: block.id,
47
- name: block.name,
48
- arguments: block.input,
49
- } satisfies ToolCall;
87
+ return toolCallFromBlock(block.id, block.name, block.input);
50
88
 
51
89
  case "server_tool_use":
52
90
  return {
@@ -183,12 +221,7 @@ export class PartialMessageBuilder {
183
221
  }
184
222
  if (block.type === "tool_use") {
185
223
  this.toolJsonAccum.set(streamIndex, "");
186
- this.partial.content.push({
187
- type: "toolCall",
188
- id: block.id,
189
- name: block.name,
190
- arguments: {},
191
- });
224
+ this.partial.content.push(toolCallFromBlock(block.id, block.name, {}));
192
225
  return { type: "toolcall_start", contentIndex, partial: this.partial };
193
226
  }
194
227
  if (block.type === "server_tool_use") {
@@ -118,6 +118,18 @@ function createAssistantStream(): AssistantMessageEventStream {
118
118
  ) as AssistantMessageEventStream;
119
119
  }
120
120
 
121
+ export function getResultErrorMessage(result: SDKResultMessage): string {
122
+ if ("errors" in result && Array.isArray(result.errors) && result.errors.length > 0) {
123
+ return result.errors.join("; ");
124
+ }
125
+
126
+ if ("result" in result && typeof result.result === "string" && result.result.trim().length > 0) {
127
+ return result.result.trim();
128
+ }
129
+
130
+ return result.subtype === "success" ? "claude_code_request_failed" : result.subtype;
131
+ }
132
+
121
133
  // ---------------------------------------------------------------------------
122
134
  // Claude binary resolution
123
135
  // ---------------------------------------------------------------------------
@@ -175,20 +187,36 @@ function extractMessageText(msg: { role: string; content: unknown }): string {
175
187
  * call effectively stateless. This version serialises the complete
176
188
  * conversation history (system prompt + all user/assistant turns) so
177
189
  * Claude Code has full context for multi-turn continuity.
190
+ *
191
+ * History is wrapped in XML-tag structure rather than `[User]`/`[Assistant]`
192
+ * bracket headers. Bracket headers read to the model as an in-context
193
+ * demonstration of how turns are delimited, causing it to fabricate fake
194
+ * user turns in its own output. XML tags read as document structure and
195
+ * don't get mirrored in free text.
178
196
  */
179
197
  export function buildPromptFromContext(context: Context): string {
180
- const parts: string[] = [];
198
+ const hasContent = Boolean(context.systemPrompt) || context.messages.some((m) => extractMessageText(m));
199
+ if (!hasContent) return "";
200
+
201
+ const parts: string[] = [
202
+ "Respond only to the final user message below. " +
203
+ "Do not emit <user_message>, <assistant_message>, or <prior_system_context> tags in your response.",
204
+ ];
181
205
 
182
206
  if (context.systemPrompt) {
183
- parts.push(`[System]\n${context.systemPrompt}`);
207
+ parts.push(`<prior_system_context>\n${context.systemPrompt}\n</prior_system_context>`);
184
208
  }
185
209
 
210
+ const turns: string[] = [];
186
211
  for (const msg of context.messages) {
187
212
  const text = extractMessageText(msg);
188
213
  if (!text) continue;
189
-
190
- const label = msg.role === "user" ? "User" : msg.role === "assistant" ? "Assistant" : "System";
191
- parts.push(`[${label}]\n${text}`);
214
+ const tag =
215
+ msg.role === "user" ? "user_message" : msg.role === "assistant" ? "assistant_message" : "system_message";
216
+ turns.push(`<${tag}>\n${text}\n</${tag}>`);
217
+ }
218
+ if (turns.length > 0) {
219
+ parts.push(`<conversation_history>\n${turns.join("\n")}\n</conversation_history>`);
192
220
  }
193
221
 
194
222
  return parts.join("\n\n");
@@ -506,22 +534,83 @@ export function createClaudeCodeElicitationHandler(
506
534
  };
507
535
  }
508
536
 
537
+ /**
538
+ * Aborted by the caller's AbortSignal — distinct from exhaustion. GSD's
539
+ * agent loop keys off `stopReason === "aborted"` to treat this as a clean
540
+ * user cancel instead of a retry-eligible provider failure.
541
+ */
542
+ export function makeAbortedMessage(model: string, lastTextContent: string): AssistantMessage {
543
+ const message: AssistantMessage = {
544
+ role: "assistant",
545
+ content: lastTextContent
546
+ ? [{ type: "text", text: lastTextContent }]
547
+ : [{ type: "text", text: "Claude Code stream aborted by caller" }],
548
+ api: "anthropic-messages",
549
+ provider: "claude-code",
550
+ model,
551
+ usage: { ...ZERO_USAGE },
552
+ stopReason: "aborted",
553
+ timestamp: Date.now(),
554
+ };
555
+ return message;
556
+ }
557
+
509
558
  // ---------------------------------------------------------------------------
510
559
  // SDK options builder
511
560
  // ---------------------------------------------------------------------------
512
561
 
562
+ /**
563
+ * Resolve the Claude Code permission mode for the current run.
564
+ *
565
+ * - Auto-mode / headless runs bypass permissions so tool calls don't block
566
+ * on prompts the user isn't watching.
567
+ * - Interactive runs default to `acceptEdits` so file/bash writes still
568
+ * land quickly but the SDK retains a permission gate.
569
+ * - `GSD_CLAUDE_CODE_PERMISSION_MODE` forces a specific mode when set.
570
+ *
571
+ * Cross-extension coupling is kept minimal by dynamically importing
572
+ * `isAutoActive` and falling back to the bypass default if the import
573
+ * fails (e.g. in unit tests that load stream-adapter in isolation).
574
+ */
575
+ export async function resolveClaudePermissionMode(
576
+ env: NodeJS.ProcessEnv = process.env,
577
+ ): Promise<"bypassPermissions" | "acceptEdits" | "default" | "plan"> {
578
+ const override = env.GSD_CLAUDE_CODE_PERMISSION_MODE?.trim();
579
+ if (override === "bypassPermissions" || override === "acceptEdits" || override === "default" || override === "plan") {
580
+ return override;
581
+ }
582
+
583
+ try {
584
+ const autoMod = (await import("../gsd/auto.js")) as { isAutoActive?: () => boolean };
585
+ if (typeof autoMod.isAutoActive === "function" && autoMod.isAutoActive()) {
586
+ return "bypassPermissions";
587
+ }
588
+ return "acceptEdits";
589
+ } catch {
590
+ // auto.ts unavailable (tests, non-GSD contexts) — stay permissive.
591
+ return "bypassPermissions";
592
+ }
593
+ }
594
+
513
595
  /**
514
596
  * Build the options object passed to the Claude Agent SDK's `query()` call.
515
597
  *
516
598
  * Extracted for testability — callers can verify session persistence,
517
599
  * beta flags, and other configuration without mocking the full SDK.
600
+ *
601
+ * `permissionMode` / `allowDangerouslySkipPermissions` are resolved through
602
+ * {@link resolveClaudePermissionMode} so interactive runs don't silently
603
+ * bypass the SDK's permission gate. Callers that want the old always-bypass
604
+ * behaviour pass `permissionMode: "bypassPermissions"` explicitly.
518
605
  */
519
606
  export function buildSdkOptions(
520
607
  modelId: string,
521
608
  prompt: string,
609
+ overrides?: { permissionMode?: "bypassPermissions" | "acceptEdits" | "default" | "plan" },
522
610
  extraOptions: Record<string, unknown> = {},
523
611
  ): Record<string, unknown> {
524
612
  const mcpServers = buildWorkflowMcpServers();
613
+ const permissionMode = overrides?.permissionMode ?? "bypassPermissions";
525
614
  const disallowedTools = ["AskUserQuestion"];
526
615
  return {
527
616
  pathToClaudeCodeExecutable: getClaudePath(),
@@ -529,8 +618,8 @@ export function buildSdkOptions(
529
618
  includePartialMessages: true,
530
619
  persistSession: true,
531
620
  cwd: process.cwd(),
532
- permissionMode: "bypassPermissions",
533
- allowDangerouslySkipPermissions: true,
621
+ permissionMode,
622
+ allowDangerouslySkipPermissions: permissionMode === "bypassPermissions",
534
623
  settingSources: ["project"],
535
624
  systemPrompt: { type: "preset", preset: "claude_code" },
536
625
  disallowedTools,
@@ -644,6 +733,29 @@ function attachExternalResultsToToolBlocks(
644
733
  }
645
734
  }
646
735
 
736
+ /**
737
+ * Merge tool-call blocks from the active partial-message builder into the
738
+ * running list of intermediate tool calls, preserving order and de-duping
739
+ * by tool-call id. Exposed for testing the F3 fix (final-turn tool calls
740
+ * dropped when `result` arrives without a preceding synthetic `user`).
741
+ */
742
+ export function mergePendingToolCalls(
743
+ intermediate: AssistantMessage["content"],
744
+ pending: AssistantMessage["content"],
745
+ ): AssistantMessage["content"] {
746
+ const alreadyIncluded = new Set<string>();
747
+ for (const block of intermediate) {
748
+ if (block.type === "toolCall") alreadyIncluded.add(block.id);
749
+ }
750
+ for (const block of pending) {
751
+ if (block.type !== "toolCall") continue;
752
+ if (alreadyIncluded.has(block.id)) continue;
753
+ alreadyIncluded.add(block.id);
754
+ intermediate.push(block);
755
+ }
756
+ return intermediate;
757
+ }
758
+
647
759
  // ---------------------------------------------------------------------------
648
760
  // streamSimple implementation
649
761
  // ---------------------------------------------------------------------------
@@ -700,9 +812,11 @@ async function pumpSdkMessages(
700
812
  }
701
813
 
702
814
  const prompt = buildPromptFromContext(context);
815
+ const permissionMode = await resolveClaudePermissionMode();
703
816
  const sdkOpts = buildSdkOptions(
704
817
  modelId,
705
818
  prompt,
819
+ { permissionMode },
706
820
  typeof (options as ClaudeCodeStreamOptions | undefined)?.extensionUIContext === "object"
707
821
  ? {
708
822
  onElicitation: createClaudeCodeElicitationHandler(
@@ -734,7 +848,17 @@ async function pumpSdkMessages(
734
848
  stream.push({ type: "start", partial: initialPartial });
735
849
 
736
850
  for await (const msg of queryResult as AsyncIterable<SDKMessage>) {
737
- if (options?.signal?.aborted) break;
851
+ if (options?.signal?.aborted) {
852
+ // User-initiated cancel — emit an aborted error so the agent
853
+ // loop classifies this as a deliberate stop, not a transient
854
+ // provider failure that should be retried.
855
+ stream.push({
856
+ type: "error",
857
+ reason: "aborted",
858
+ error: makeAbortedMessage(modelId, lastTextContent),
859
+ });
860
+ return;
861
+ }
738
862
 
739
863
  switch (msg.type) {
740
864
  // -- Init --
@@ -845,6 +969,16 @@ async function pumpSdkMessages(
845
969
  // events for proper TUI rendering, followed by the text response.
846
970
  const finalContent: AssistantMessage["content"] = [];
847
971
 
972
+ // If the final turn ended without a synthetic user message
973
+ // (e.g. stop_reason: "tool_use" followed directly by result,
974
+ // or a turn with text but no tool execution), the `builder`
975
+ // still holds toolCall blocks that were never pushed into
976
+ // `intermediateToolBlocks`. Fold them in here so they aren't
977
+ // dropped from the final AssistantMessage.
978
+ if (builder) {
979
+ mergePendingToolCalls(intermediateToolBlocks, builder.message.content);
980
+ }
981
+
848
982
  // Add tool calls from intermediate turns first (renders above text)
849
983
  attachExternalResultsToToolBlocks(intermediateToolBlocks, toolResultsById);
850
984
  finalContent.push(...intermediateToolBlocks);
@@ -882,11 +1016,7 @@ async function pumpSdkMessages(
882
1016
  };
883
1017
 
884
1018
  if (result.is_error) {
885
- const errText =
886
- "errors" in result
887
- ? (result as any).errors?.join("; ")
888
- : result.subtype;
889
- finalMessage.errorMessage = errText;
1019
+ finalMessage.errorMessage = getResultErrorMessage(result);
890
1020
  stream.push({ type: "error", reason: "error", error: finalMessage });
891
1021
  } else {
892
1022
  stream.push({ type: "done", reason: "stop", message: finalMessage });