gsd-pi 2.41.0-dev.cac69f9 → 2.42.0-dev.1df898f

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 (263) hide show
  1. package/README.md +23 -0
  2. package/dist/cli.js +18 -3
  3. package/dist/loader.js +3 -1
  4. package/dist/resource-loader.js +39 -6
  5. package/dist/resources/extensions/async-jobs/async-bash-tool.js +52 -4
  6. package/dist/resources/extensions/async-jobs/await-tool.js +5 -0
  7. package/dist/resources/extensions/async-jobs/index.js +2 -0
  8. package/dist/resources/extensions/gsd/auto/loop.js +80 -0
  9. package/dist/resources/extensions/gsd/auto/phases.js +3 -5
  10. package/dist/resources/extensions/gsd/auto/session.js +6 -0
  11. package/dist/resources/extensions/gsd/auto-dashboard.js +2 -0
  12. package/dist/resources/extensions/gsd/auto-prompts.js +3 -16
  13. package/dist/resources/extensions/gsd/auto-start.js +8 -11
  14. package/dist/resources/extensions/gsd/auto.js +28 -1
  15. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +11 -5
  16. package/dist/resources/extensions/gsd/bootstrap/tool-call-loop-guard.js +7 -2
  17. package/dist/resources/extensions/gsd/commands/catalog.js +32 -0
  18. package/dist/resources/extensions/gsd/commands/handlers/workflow.js +146 -0
  19. package/dist/resources/extensions/gsd/context-injector.js +74 -0
  20. package/dist/resources/extensions/gsd/custom-execution-policy.js +47 -0
  21. package/dist/resources/extensions/gsd/custom-verification.js +145 -0
  22. package/dist/resources/extensions/gsd/custom-workflow-engine.js +164 -0
  23. package/dist/resources/extensions/gsd/dashboard-overlay.js +1 -0
  24. package/dist/resources/extensions/gsd/definition-loader.js +352 -0
  25. package/dist/resources/extensions/gsd/detection.js +19 -0
  26. package/dist/resources/extensions/gsd/dev-execution-policy.js +24 -0
  27. package/dist/resources/extensions/gsd/dev-workflow-engine.js +82 -0
  28. package/dist/resources/extensions/gsd/doctor-checks.js +31 -1
  29. package/dist/resources/extensions/gsd/doctor-providers.js +10 -0
  30. package/dist/resources/extensions/gsd/engine-resolver.js +40 -0
  31. package/dist/resources/extensions/gsd/engine-types.js +8 -0
  32. package/dist/resources/extensions/gsd/execution-policy.js +8 -0
  33. package/dist/resources/extensions/gsd/forensics.js +84 -0
  34. package/dist/resources/extensions/gsd/git-constants.js +1 -0
  35. package/dist/resources/extensions/gsd/git-service.js +1 -1
  36. package/dist/resources/extensions/gsd/graph.js +225 -0
  37. package/dist/resources/extensions/gsd/native-git-bridge.js +1 -0
  38. package/dist/resources/extensions/gsd/preferences-types.js +1 -0
  39. package/dist/resources/extensions/gsd/preferences.js +59 -8
  40. package/dist/resources/extensions/gsd/prompts/forensics.md +12 -5
  41. package/dist/resources/extensions/gsd/repo-identity.js +46 -5
  42. package/dist/resources/extensions/gsd/run-manager.js +134 -0
  43. package/dist/resources/extensions/gsd/service-tier.js +13 -4
  44. package/dist/resources/extensions/gsd/session-lock.js +2 -2
  45. package/dist/resources/extensions/gsd/workflow-engine.js +7 -0
  46. package/dist/resources/extensions/gsd/worktree-resolver.js +2 -2
  47. package/dist/resources/extensions/gsd/worktree.js +2 -2
  48. package/dist/resources/extensions/mcp-client/index.js +2 -1
  49. package/dist/resources/extensions/search-the-web/tool-search.js +3 -3
  50. package/dist/resources/skills/create-workflow/SKILL.md +103 -0
  51. package/dist/resources/skills/create-workflow/references/feature-patterns.md +128 -0
  52. package/dist/resources/skills/create-workflow/references/verification-policies.md +76 -0
  53. package/dist/resources/skills/create-workflow/references/yaml-schema-v1.md +46 -0
  54. package/dist/resources/skills/create-workflow/templates/blog-post-pipeline.yaml +60 -0
  55. package/dist/resources/skills/create-workflow/templates/code-audit.yaml +60 -0
  56. package/dist/resources/skills/create-workflow/templates/release-checklist.yaml +66 -0
  57. package/dist/resources/skills/create-workflow/templates/workflow-definition.yaml +32 -0
  58. package/dist/resources/skills/create-workflow/workflows/create-from-scratch.md +104 -0
  59. package/dist/resources/skills/create-workflow/workflows/create-from-template.md +72 -0
  60. package/dist/web/standalone/.next/BUILD_ID +1 -1
  61. package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
  62. package/dist/web/standalone/.next/build-manifest.json +2 -2
  63. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  64. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  65. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  66. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  67. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  68. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  69. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  70. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  71. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  72. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  73. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  74. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  75. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  76. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  78. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  79. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  81. package/dist/web/standalone/.next/server/app/index.html +1 -1
  82. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  83. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  84. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  85. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  86. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  87. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  88. package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
  89. package/dist/web/standalone/.next/server/chunks/229.js +2 -2
  90. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  91. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  92. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  93. package/dist/web-mode.d.ts +2 -0
  94. package/dist/web-mode.js +40 -4
  95. package/package.json +1 -1
  96. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  97. package/packages/pi-agent-core/dist/agent.js +2 -0
  98. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  99. package/packages/pi-agent-core/dist/types.d.ts +6 -0
  100. package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
  101. package/packages/pi-agent-core/dist/types.js.map +1 -1
  102. package/packages/pi-agent-core/src/agent.test.ts +53 -0
  103. package/packages/pi-agent-core/src/agent.ts +3 -0
  104. package/packages/pi-agent-core/src/types.ts +6 -0
  105. package/packages/pi-agent-core/tsconfig.json +1 -1
  106. package/packages/pi-ai/dist/models.d.ts +5 -3
  107. package/packages/pi-ai/dist/models.d.ts.map +1 -1
  108. package/packages/pi-ai/dist/models.generated.d.ts +801 -1468
  109. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  110. package/packages/pi-ai/dist/models.generated.js +1135 -1588
  111. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  112. package/packages/pi-ai/dist/models.js.map +1 -1
  113. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  114. package/packages/pi-ai/dist/utils/oauth/github-copilot.js +60 -2
  115. package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  116. package/packages/pi-ai/scripts/generate-models.ts +1543 -0
  117. package/packages/pi-ai/src/models.generated.ts +1140 -1593
  118. package/packages/pi-ai/src/models.ts +7 -4
  119. package/packages/pi-ai/src/utils/oauth/github-copilot.ts +74 -2
  120. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  121. package/packages/pi-coding-agent/dist/core/agent-session.js +8 -1
  122. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  123. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +7 -0
  124. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  125. package/packages/pi-coding-agent/dist/core/auth-storage.js +29 -2
  126. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  127. package/packages/pi-coding-agent/dist/core/auth-storage.test.js +60 -0
  128. package/packages/pi-coding-agent/dist/core/auth-storage.test.js.map +1 -1
  129. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  130. package/packages/pi-coding-agent/dist/core/extensions/loader.js +18 -0
  131. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  132. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
  133. package/packages/pi-coding-agent/dist/core/lsp/client.js +23 -0
  134. package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
  135. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  136. package/packages/pi-coding-agent/dist/core/model-registry.js +2 -0
  137. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  138. package/packages/pi-coding-agent/dist/core/package-manager.d.ts +6 -0
  139. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  140. package/packages/pi-coding-agent/dist/core/package-manager.js +63 -11
  141. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  142. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +9 -0
  143. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  144. package/packages/pi-coding-agent/dist/core/resource-loader.js +20 -6
  145. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  146. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  147. package/packages/pi-coding-agent/dist/core/system-prompt.js +6 -5
  148. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  149. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  150. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +3 -0
  151. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -1
  152. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  153. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +9 -6
  154. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  155. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  156. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +30 -10
  157. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  158. package/packages/pi-coding-agent/package.json +1 -1
  159. package/packages/pi-coding-agent/src/core/agent-session.ts +7 -1
  160. package/packages/pi-coding-agent/src/core/auth-storage.test.ts +68 -0
  161. package/packages/pi-coding-agent/src/core/auth-storage.ts +30 -2
  162. package/packages/pi-coding-agent/src/core/extensions/loader.ts +18 -0
  163. package/packages/pi-coding-agent/src/core/lsp/client.ts +29 -0
  164. package/packages/pi-coding-agent/src/core/model-registry.ts +3 -0
  165. package/packages/pi-coding-agent/src/core/package-manager.ts +99 -58
  166. package/packages/pi-coding-agent/src/core/resource-loader.ts +24 -6
  167. package/packages/pi-coding-agent/src/core/system-prompt.ts +6 -5
  168. package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +3 -0
  169. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +10 -6
  170. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +31 -11
  171. package/pkg/package.json +1 -1
  172. package/src/resources/extensions/async-jobs/async-bash-timeout.test.ts +122 -0
  173. package/src/resources/extensions/async-jobs/async-bash-tool.ts +40 -4
  174. package/src/resources/extensions/async-jobs/await-tool.test.ts +47 -0
  175. package/src/resources/extensions/async-jobs/await-tool.ts +5 -0
  176. package/src/resources/extensions/async-jobs/index.ts +1 -0
  177. package/src/resources/extensions/async-jobs/job-manager.ts +2 -0
  178. package/src/resources/extensions/gsd/auto/loop-deps.ts +0 -1
  179. package/src/resources/extensions/gsd/auto/loop.ts +91 -0
  180. package/src/resources/extensions/gsd/auto/phases.ts +3 -5
  181. package/src/resources/extensions/gsd/auto/session.ts +6 -0
  182. package/src/resources/extensions/gsd/auto-dashboard.ts +2 -0
  183. package/src/resources/extensions/gsd/auto-prompts.ts +2 -18
  184. package/src/resources/extensions/gsd/auto-start.ts +7 -10
  185. package/src/resources/extensions/gsd/auto.ts +31 -1
  186. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +13 -5
  187. package/src/resources/extensions/gsd/bootstrap/tool-call-loop-guard.ts +9 -2
  188. package/src/resources/extensions/gsd/commands/catalog.ts +32 -0
  189. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +164 -0
  190. package/src/resources/extensions/gsd/context-injector.ts +100 -0
  191. package/src/resources/extensions/gsd/custom-execution-policy.ts +73 -0
  192. package/src/resources/extensions/gsd/custom-verification.ts +180 -0
  193. package/src/resources/extensions/gsd/custom-workflow-engine.ts +216 -0
  194. package/src/resources/extensions/gsd/dashboard-overlay.ts +1 -0
  195. package/src/resources/extensions/gsd/definition-loader.ts +462 -0
  196. package/src/resources/extensions/gsd/detection.ts +19 -0
  197. package/src/resources/extensions/gsd/dev-execution-policy.ts +51 -0
  198. package/src/resources/extensions/gsd/dev-workflow-engine.ts +110 -0
  199. package/src/resources/extensions/gsd/doctor-checks.ts +32 -1
  200. package/src/resources/extensions/gsd/doctor-providers.ts +13 -0
  201. package/src/resources/extensions/gsd/doctor-types.ts +1 -0
  202. package/src/resources/extensions/gsd/engine-resolver.ts +57 -0
  203. package/src/resources/extensions/gsd/engine-types.ts +71 -0
  204. package/src/resources/extensions/gsd/execution-policy.ts +43 -0
  205. package/src/resources/extensions/gsd/forensics.ts +92 -0
  206. package/src/resources/extensions/gsd/git-constants.ts +1 -0
  207. package/src/resources/extensions/gsd/git-service.ts +0 -1
  208. package/src/resources/extensions/gsd/gitignore.ts +1 -1
  209. package/src/resources/extensions/gsd/graph.ts +312 -0
  210. package/src/resources/extensions/gsd/native-git-bridge.ts +1 -0
  211. package/src/resources/extensions/gsd/preferences-types.ts +3 -0
  212. package/src/resources/extensions/gsd/preferences.ts +62 -6
  213. package/src/resources/extensions/gsd/prompts/forensics.md +12 -5
  214. package/src/resources/extensions/gsd/repo-identity.ts +48 -5
  215. package/src/resources/extensions/gsd/run-manager.ts +180 -0
  216. package/src/resources/extensions/gsd/service-tier.ts +17 -4
  217. package/src/resources/extensions/gsd/session-lock.ts +2 -2
  218. package/src/resources/extensions/gsd/tests/activity-log.test.ts +31 -69
  219. package/src/resources/extensions/gsd/tests/bundled-workflow-defs.test.ts +180 -0
  220. package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +283 -0
  221. package/src/resources/extensions/gsd/tests/context-injector.test.ts +313 -0
  222. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +540 -0
  223. package/src/resources/extensions/gsd/tests/custom-verification.test.ts +382 -0
  224. package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +339 -0
  225. package/src/resources/extensions/gsd/tests/dashboard-custom-engine.test.ts +87 -0
  226. package/src/resources/extensions/gsd/tests/definition-loader.test.ts +778 -0
  227. package/src/resources/extensions/gsd/tests/dev-engine-wrapper.test.ts +318 -0
  228. package/src/resources/extensions/gsd/tests/e2e-workflow-pipeline-integration.test.ts +476 -0
  229. package/src/resources/extensions/gsd/tests/engine-interfaces-contract.test.ts +271 -0
  230. package/src/resources/extensions/gsd/tests/forensics-dedup.test.ts +48 -0
  231. package/src/resources/extensions/gsd/tests/forensics-issue-routing.test.ts +43 -0
  232. package/src/resources/extensions/gsd/tests/git-locale.test.ts +133 -0
  233. package/src/resources/extensions/gsd/tests/git-service.test.ts +44 -0
  234. package/src/resources/extensions/gsd/tests/graph-operations.test.ts +599 -0
  235. package/src/resources/extensions/gsd/tests/iterate-engine-integration.test.ts +429 -0
  236. package/src/resources/extensions/gsd/tests/journal.test.ts +82 -127
  237. package/src/resources/extensions/gsd/tests/manifest-status.test.ts +73 -82
  238. package/src/resources/extensions/gsd/tests/run-manager.test.ts +229 -0
  239. package/src/resources/extensions/gsd/tests/service-tier.test.ts +30 -1
  240. package/src/resources/extensions/gsd/tests/skill-activation.test.ts +56 -3
  241. package/src/resources/extensions/gsd/tests/symlink-numbered-variants.test.ts +151 -0
  242. package/src/resources/extensions/gsd/tests/tool-call-loop-guard.test.ts +45 -0
  243. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +156 -263
  244. package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +35 -78
  245. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +81 -74
  246. package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +1 -2
  247. package/src/resources/extensions/gsd/workflow-engine.ts +38 -0
  248. package/src/resources/extensions/gsd/worktree-resolver.ts +2 -3
  249. package/src/resources/extensions/gsd/worktree.ts +2 -2
  250. package/src/resources/extensions/mcp-client/index.ts +5 -1
  251. package/src/resources/extensions/search-the-web/tool-search.ts +3 -3
  252. package/src/resources/skills/create-workflow/SKILL.md +103 -0
  253. package/src/resources/skills/create-workflow/references/feature-patterns.md +128 -0
  254. package/src/resources/skills/create-workflow/references/verification-policies.md +76 -0
  255. package/src/resources/skills/create-workflow/references/yaml-schema-v1.md +46 -0
  256. package/src/resources/skills/create-workflow/templates/blog-post-pipeline.yaml +60 -0
  257. package/src/resources/skills/create-workflow/templates/code-audit.yaml +60 -0
  258. package/src/resources/skills/create-workflow/templates/release-checklist.yaml +66 -0
  259. package/src/resources/skills/create-workflow/templates/workflow-definition.yaml +32 -0
  260. package/src/resources/skills/create-workflow/workflows/create-from-scratch.md +104 -0
  261. package/src/resources/skills/create-workflow/workflows/create-from-template.md +72 -0
  262. /package/dist/web/standalone/.next/static/{EnGUNqHeGbE0tuuUkTJVA → qw8qDHXOTLUXBq1vEknSz}/_buildManifest.js +0 -0
  263. /package/dist/web/standalone/.next/static/{EnGUNqHeGbE0tuuUkTJVA → qw8qDHXOTLUXBq1vEknSz}/_ssgManifest.js +0 -0
@@ -15,10 +15,15 @@ import { saveActivityLog } from "../activity-log.js";
15
15
  // Skip the welcome screen on the very first session_start — cli.ts already
16
16
  // printed it before the TUI launched. Only re-print on /clear (subsequent sessions).
17
17
  let isFirstSession = true;
18
+ async function syncServiceTierStatus(ctx) {
19
+ const { getEffectiveServiceTier, formatServiceTierFooterStatus } = await import("../service-tier.js");
20
+ ctx.ui.setStatus("gsd-fast", formatServiceTierFooterStatus(getEffectiveServiceTier(), ctx.model?.id));
21
+ }
18
22
  export function registerHooks(pi) {
19
23
  pi.on("session_start", async (_event, ctx) => {
20
24
  resetWriteGateState();
21
25
  resetToolCallLoopGuard();
26
+ await syncServiceTierStatus(ctx);
22
27
  if (isFirstSession) {
23
28
  isFirstSession = false;
24
29
  }
@@ -26,9 +31,9 @@ export function registerHooks(pi) {
26
31
  try {
27
32
  const gsdBinPath = process.env.GSD_BIN_PATH;
28
33
  if (gsdBinPath) {
29
- const { dirname } = await import('node:path');
30
- const { printWelcomeScreen } = await import(join(dirname(gsdBinPath), 'welcome-screen.js'));
31
- printWelcomeScreen({ version: process.env.GSD_VERSION || '0.0.0' });
34
+ const { dirname } = await import("node:path");
35
+ const { printWelcomeScreen } = await import(join(dirname(gsdBinPath), "welcome-screen.js"));
36
+ printWelcomeScreen({ version: process.env.GSD_VERSION || "0.0.0" });
32
37
  }
33
38
  }
34
39
  catch { /* non-fatal */ }
@@ -179,9 +184,10 @@ export function registerHooks(pi) {
179
184
  pi.on("tool_execution_end", async (event) => {
180
185
  markToolEnd(event.toolCallId);
181
186
  });
187
+ pi.on("model_select", async (_event, ctx) => {
188
+ await syncServiceTierStatus(ctx);
189
+ });
182
190
  pi.on("before_provider_request", async (event) => {
183
- if (!isAutoActive())
184
- return;
185
191
  const modelId = event.model?.id;
186
192
  if (!modelId)
187
193
  return;
@@ -20,8 +20,13 @@ let enabled = true;
20
20
  function hashToolCall(toolName, args) {
21
21
  const h = createHash("sha256");
22
22
  h.update(toolName);
23
- // Sort keys for deterministic hashing regardless of object key order
24
- h.update(JSON.stringify(args, Object.keys(args).sort()));
23
+ // Sort keys recursively for deterministic hashing regardless of object key order
24
+ h.update(JSON.stringify(args, (_key, value) => value && typeof value === "object" && !Array.isArray(value)
25
+ ? Object.keys(value).sort().reduce((o, k) => {
26
+ o[k] = value[k];
27
+ return o;
28
+ }, {})
29
+ : value));
25
30
  return h.digest("hex").slice(0, 16);
26
31
  }
27
32
  /**
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { loadRegistry } from "../workflow-templates.js";
5
+ import { resolveProjectRoot } from "../worktree.js";
5
6
  const gsdHome = process.env.GSD_HOME || join(homedir(), ".gsd");
6
7
  export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|rate|skip|export|cleanup|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|cmux|park|unpark|init|setup|inspect|extensions|update|fast";
7
8
  export const TOP_LEVEL_SUBCOMMANDS = [
@@ -53,6 +54,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
53
54
  { cmd: "templates", desc: "List available workflow templates" },
54
55
  { cmd: "extensions", desc: "Manage extensions (list, enable, disable, info)" },
55
56
  { cmd: "fast", desc: "Toggle OpenAI service tier (on/off/flex/status)" },
57
+ { cmd: "workflow", desc: "Custom workflow lifecycle (new, run, list, validate, pause, resume)" },
56
58
  ];
57
59
  const NESTED_COMPLETIONS = {
58
60
  auto: [
@@ -193,6 +195,14 @@ const NESTED_COMPLETIONS = {
193
195
  { cmd: "ok", desc: "Model was appropriate for this task" },
194
196
  { cmd: "under", desc: "Model was underqualified for this task" },
195
197
  ],
198
+ workflow: [
199
+ { cmd: "new", desc: "Create a new workflow definition (via skill)" },
200
+ { cmd: "run", desc: "Create a run and start auto-mode" },
201
+ { cmd: "list", desc: "List workflow runs" },
202
+ { cmd: "validate", desc: "Validate a workflow definition YAML" },
203
+ { cmd: "pause", desc: "Pause custom workflow auto-mode" },
204
+ { cmd: "resume", desc: "Resume paused custom workflow auto-mode" },
205
+ ],
196
206
  };
197
207
  function filterOptions(partial, options, prefix = "") {
198
208
  const normalizedPrefix = prefix ? `${prefix} ` : "";
@@ -287,6 +297,28 @@ export function getGsdArgumentCompletions(prefix) {
287
297
  if (command === "undo" && parts.length <= 2) {
288
298
  return [{ value: "undo --force", label: "--force", description: "Skip confirmation prompt" }];
289
299
  }
300
+ // Workflow definition-name completion for `workflow run <name>` and `workflow validate <name>`
301
+ if (command === "workflow" && (subcommand === "run" || subcommand === "validate") && parts.length <= 3) {
302
+ try {
303
+ const defsDir = join(resolveProjectRoot(process.cwd()), ".gsd", "workflow-defs");
304
+ if (existsSync(defsDir)) {
305
+ return readdirSync(defsDir)
306
+ .filter((f) => f.endsWith(".yaml") && f.startsWith(third))
307
+ .map((f) => {
308
+ const name = f.replace(/\.yaml$/, "");
309
+ return {
310
+ value: `workflow ${subcommand} ${name}`,
311
+ label: name,
312
+ description: `Workflow definition: ${name}`,
313
+ };
314
+ });
315
+ }
316
+ }
317
+ catch {
318
+ // ignore filesystem errors during completion
319
+ }
320
+ return [];
321
+ }
290
322
  const nested = NESTED_COMPLETIONS[command];
291
323
  if (nested && parts.length <= 2) {
292
324
  return filterOptions(subcommand, nested, command);
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync, unlinkSync } from "node:fs";
2
2
  import { join } from "node:path";
3
+ import { parse as parseYaml } from "yaml";
3
4
  import { handleQuick } from "../../quick.js";
4
5
  import { showDiscuss, showHeadlessMilestoneCreation, showQueue } from "../../guided-flow.js";
5
6
  import { handleStart, handleTemplates } from "../../commands-workflow-templates.js";
@@ -10,7 +11,152 @@ import { loadEffectiveGSDPreferences } from "../../preferences.js";
10
11
  import { nextMilestoneId } from "../../milestone-ids.js";
11
12
  import { findMilestoneIds } from "../../guided-flow.js";
12
13
  import { projectRoot } from "../context.js";
14
+ import { createRun, listRuns } from "../../run-manager.js";
15
+ import { setActiveEngineId, setActiveRunDir, startAuto, pauseAuto, isAutoActive, getActiveEngineId, } from "../../auto.js";
16
+ import { validateDefinition } from "../../definition-loader.js";
17
+ // ─── Custom Workflow Subcommands ─────────────────────────────────────────
18
+ const WORKFLOW_USAGE = [
19
+ "Usage: /gsd workflow <subcommand>",
20
+ "",
21
+ " new — Create a new workflow definition (via skill)",
22
+ " run <name> [k=v] — Create a run and start auto-mode",
23
+ " list [name] — List workflow runs (optionally filtered by name)",
24
+ " validate <name> — Validate a workflow definition YAML",
25
+ " pause — Pause custom workflow auto-mode",
26
+ " resume — Resume paused custom workflow auto-mode",
27
+ ].join("\n");
28
+ async function handleCustomWorkflow(sub, ctx, pi) {
29
+ // Bare `/gsd workflow` — show usage
30
+ if (!sub) {
31
+ ctx.ui.notify(WORKFLOW_USAGE, "info");
32
+ return true;
33
+ }
34
+ // ── new ──
35
+ if (sub === "new") {
36
+ ctx.ui.notify("Use the create-workflow skill: /skill create-workflow", "info");
37
+ return true;
38
+ }
39
+ // ── run <name> [param=value ...] ──
40
+ if (sub === "run" || sub.startsWith("run ")) {
41
+ const args = sub.slice("run".length).trim();
42
+ if (!args) {
43
+ ctx.ui.notify("Usage: /gsd workflow run <name> [param=value ...]", "warning");
44
+ return true;
45
+ }
46
+ const parts = args.split(/\s+/);
47
+ const defName = parts[0];
48
+ const overrides = {};
49
+ for (let i = 1; i < parts.length; i++) {
50
+ const eqIdx = parts[i].indexOf("=");
51
+ if (eqIdx > 0) {
52
+ overrides[parts[i].slice(0, eqIdx)] = parts[i].slice(eqIdx + 1);
53
+ }
54
+ }
55
+ try {
56
+ const base = projectRoot();
57
+ const runDir = createRun(base, defName, Object.keys(overrides).length > 0 ? overrides : undefined);
58
+ setActiveEngineId("custom");
59
+ setActiveRunDir(runDir);
60
+ ctx.ui.notify(`Created workflow run: ${defName}\nRun dir: ${runDir}`, "info");
61
+ await startAuto(ctx, pi, base, false);
62
+ }
63
+ catch (err) {
64
+ // Clean up engine state so a failed workflow run doesn't pollute the next /gsd auto
65
+ setActiveEngineId(null);
66
+ setActiveRunDir(null);
67
+ const msg = err instanceof Error ? err.message : String(err);
68
+ ctx.ui.notify(`Failed to run workflow "${defName}": ${msg}`, "error");
69
+ }
70
+ return true;
71
+ }
72
+ // ── list [name] ──
73
+ if (sub === "list" || sub.startsWith("list ")) {
74
+ const filterName = sub.slice("list".length).trim() || undefined;
75
+ const base = projectRoot();
76
+ const runs = listRuns(base, filterName);
77
+ if (runs.length === 0) {
78
+ ctx.ui.notify("No workflow runs found.", "info");
79
+ return true;
80
+ }
81
+ const lines = runs.map((r) => {
82
+ const stepInfo = `${r.steps.completed}/${r.steps.total} steps`;
83
+ return `• ${r.name} [${r.timestamp}] — ${r.status} (${stepInfo})`;
84
+ });
85
+ ctx.ui.notify(lines.join("\n"), "info");
86
+ return true;
87
+ }
88
+ // ── validate <name> ──
89
+ if (sub === "validate" || sub.startsWith("validate ")) {
90
+ const defName = sub.slice("validate".length).trim();
91
+ if (!defName) {
92
+ ctx.ui.notify("Usage: /gsd workflow validate <name>", "warning");
93
+ return true;
94
+ }
95
+ const base = projectRoot();
96
+ const defPath = join(base, ".gsd", "workflow-defs", `${defName}.yaml`);
97
+ if (!existsSync(defPath)) {
98
+ ctx.ui.notify(`Definition not found: ${defPath}`, "error");
99
+ return true;
100
+ }
101
+ try {
102
+ const raw = readFileSync(defPath, "utf-8");
103
+ const parsed = parseYaml(raw);
104
+ const result = validateDefinition(parsed);
105
+ if (result.valid) {
106
+ ctx.ui.notify(`✓ "${defName}" is a valid workflow definition.`, "info");
107
+ }
108
+ else {
109
+ ctx.ui.notify(`✗ "${defName}" has errors:\n - ${result.errors.join("\n - ")}`, "error");
110
+ }
111
+ }
112
+ catch (err) {
113
+ const msg = err instanceof Error ? err.message : String(err);
114
+ ctx.ui.notify(`Failed to validate "${defName}": ${msg}`, "error");
115
+ }
116
+ return true;
117
+ }
118
+ // ── pause ──
119
+ if (sub === "pause") {
120
+ const engineId = getActiveEngineId();
121
+ if (engineId === "dev" || engineId === null) {
122
+ ctx.ui.notify("No custom workflow is running. Use /gsd pause for dev workflow.", "warning");
123
+ return true;
124
+ }
125
+ if (!isAutoActive()) {
126
+ ctx.ui.notify("Auto-mode is not active.", "warning");
127
+ return true;
128
+ }
129
+ await pauseAuto(ctx, pi);
130
+ ctx.ui.notify("Custom workflow paused.", "info");
131
+ return true;
132
+ }
133
+ // ── resume ──
134
+ if (sub === "resume") {
135
+ const engineId = getActiveEngineId();
136
+ if (engineId === "dev" || engineId === null) {
137
+ ctx.ui.notify("No custom workflow to resume. Use /gsd auto for dev workflow.", "warning");
138
+ return true;
139
+ }
140
+ try {
141
+ await startAuto(ctx, pi, projectRoot(), false);
142
+ ctx.ui.notify("Custom workflow resumed.", "info");
143
+ }
144
+ catch (err) {
145
+ const msg = err instanceof Error ? err.message : String(err);
146
+ ctx.ui.notify(`Failed to resume workflow: ${msg}`, "error");
147
+ }
148
+ return true;
149
+ }
150
+ // Unknown subcommand — show usage
151
+ ctx.ui.notify(`Unknown workflow subcommand: "${sub}"\n\n${WORKFLOW_USAGE}`, "warning");
152
+ return true;
153
+ }
13
154
  export async function handleWorkflowCommand(trimmed, ctx, pi) {
155
+ // ── Custom workflow commands (`/gsd workflow ...`) ──
156
+ if (trimmed === "workflow" || trimmed.startsWith("workflow ")) {
157
+ const sub = trimmed.slice("workflow".length).trim();
158
+ return handleCustomWorkflow(sub, ctx, pi);
159
+ }
14
160
  if (trimmed === "queue") {
15
161
  await showQueue(ctx, pi, projectRoot());
16
162
  return true;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * context-injector.ts — Inject prior step artifacts as context into step prompts.
3
+ *
4
+ * Reads the frozen DEFINITION.yaml from a run directory, finds the current step's
5
+ * `contextFrom` references, locates each referenced step's `produces` artifacts
6
+ * on disk, reads their content (truncated to 10k chars), and prepends formatted
7
+ * context blocks to the step prompt.
8
+ *
9
+ * Observability:
10
+ * - Truncation is logged via console.warn when it occurs, preventing silent overflow.
11
+ * - Missing artifact files are skipped silently (the step may not have produced them yet).
12
+ * - Unknown step IDs in contextFrom produce a console.warn for diagnosis.
13
+ * - The frozen DEFINITION.yaml on disk is the single source of truth for contextFrom config.
14
+ */
15
+ import { readFileSync, existsSync } from "node:fs";
16
+ import { resolve, sep } from "node:path";
17
+ import { readFrozenDefinition } from "./custom-workflow-engine.js";
18
+ /** Maximum characters per artifact to prevent context window blowout. */
19
+ const MAX_CONTEXT_CHARS = 10_000;
20
+ /**
21
+ * Inject context from prior step artifacts into a step's prompt.
22
+ *
23
+ * Reads the frozen DEFINITION.yaml from `runDir`, finds the step matching
24
+ * `stepId`, and for each step ID in its `contextFrom` array, looks up that
25
+ * step's `produces` paths, reads them from disk (relative to `runDir`),
26
+ * truncates to MAX_CONTEXT_CHARS, and prepends as labeled context blocks.
27
+ *
28
+ * @param runDir — absolute path to the workflow run directory
29
+ * @param stepId — the step ID whose prompt to enrich
30
+ * @param prompt — the original step prompt
31
+ * @returns The prompt with context blocks prepended, or unchanged if no context applies
32
+ * @throws Error if DEFINITION.yaml is missing or unreadable
33
+ */
34
+ export function injectContext(runDir, stepId, prompt) {
35
+ const def = readFrozenDefinition(runDir);
36
+ const step = def.steps.find((s) => s.id === stepId);
37
+ if (!step || !step.contextFrom || step.contextFrom.length === 0) {
38
+ return prompt;
39
+ }
40
+ const contextBlocks = [];
41
+ for (const refStepId of step.contextFrom) {
42
+ const refStep = def.steps.find((s) => s.id === refStepId);
43
+ if (!refStep) {
44
+ console.warn(`context-injector: step "${stepId}" references unknown step "${refStepId}" in contextFrom — skipping`);
45
+ continue;
46
+ }
47
+ if (!refStep.produces || refStep.produces.length === 0) {
48
+ continue;
49
+ }
50
+ for (const relPath of refStep.produces) {
51
+ const absPath = resolve(runDir, relPath);
52
+ // Path traversal guard: ensure resolved path stays within runDir
53
+ if (!absPath.startsWith(resolve(runDir) + sep) && absPath !== resolve(runDir)) {
54
+ console.warn(`context-injector: artifact path "${relPath}" resolves outside runDir — skipping`);
55
+ continue;
56
+ }
57
+ if (!existsSync(absPath)) {
58
+ // Artifact not yet produced or optional — skip silently
59
+ continue;
60
+ }
61
+ let content = readFileSync(absPath, "utf-8");
62
+ if (content.length > MAX_CONTEXT_CHARS) {
63
+ console.warn(`context-injector: truncating artifact "${relPath}" from step "${refStepId}" ` +
64
+ `(${content.length} chars → ${MAX_CONTEXT_CHARS} chars)`);
65
+ content = content.slice(0, MAX_CONTEXT_CHARS) + "\n...[truncated]";
66
+ }
67
+ contextBlocks.push(`--- Context from step "${refStepId}" (file: ${relPath}) ---\n${content}\n---`);
68
+ }
69
+ }
70
+ if (contextBlocks.length === 0) {
71
+ return prompt;
72
+ }
73
+ return contextBlocks.join("\n\n") + "\n\n" + prompt;
74
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * custom-execution-policy.ts — ExecutionPolicy for custom workflows.
3
+ *
4
+ * Delegates verification to the step-level verification module which reads
5
+ * the frozen DEFINITION.yaml and dispatches to the appropriate policy handler.
6
+ *
7
+ * Observability:
8
+ * - verify() returns the outcome from runCustomVerification() — four policies
9
+ * are supported: content-heuristic, shell-command, prompt-verify, human-review.
10
+ * - selectModel() returns null — defers to loop defaults.
11
+ * - recover() returns retry — simple default recovery strategy.
12
+ */
13
+ import { runCustomVerification } from "./custom-verification.js";
14
+ export class CustomExecutionPolicy {
15
+ runDir;
16
+ constructor(runDir) {
17
+ this.runDir = runDir;
18
+ }
19
+ /** No workspace preparation needed for custom workflows. */
20
+ async prepareWorkspace(_basePath, _milestoneId) {
21
+ // No-op — custom workflows don't need worktree setup
22
+ }
23
+ /** Defer model selection to loop defaults. */
24
+ async selectModel(_unitType, _unitId, _context) {
25
+ return null;
26
+ }
27
+ /**
28
+ * Verify step output by dispatching to the step's configured verification policy.
29
+ *
30
+ * Extracts the step ID from unitId (format: "<workflowName>/<stepId>")
31
+ * and calls runCustomVerification() which reads the frozen DEFINITION.yaml
32
+ * to determine which policy to apply.
33
+ */
34
+ async verify(_unitType, unitId, _context) {
35
+ const parts = unitId.split("/");
36
+ const stepId = parts[parts.length - 1];
37
+ return runCustomVerification(this.runDir, stepId);
38
+ }
39
+ /** Default recovery: retry the step. */
40
+ async recover(_unitType, _unitId, _context) {
41
+ return { outcome: "retry", reason: "Default retry" };
42
+ }
43
+ /** No-op closeout — no commits or artifact capture. */
44
+ async closeout(_unitType, _unitId, _context) {
45
+ return { committed: false, artifacts: [] };
46
+ }
47
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * custom-verification.ts — Step verification for custom workflows.
3
+ *
4
+ * Reads the frozen DEFINITION.yaml from a run directory, finds the step's
5
+ * `verify` policy, and dispatches to the appropriate handler. Four policies:
6
+ *
7
+ * - content-heuristic: file existence + optional minSize + optional pattern match
8
+ * - shell-command: spawnSync with 30s timeout, exit 0 → continue, else retry
9
+ * - prompt-verify: always "pause" (defers to agent)
10
+ * - human-review: always "pause" (waits for manual inspection)
11
+ * - (no policy): returns "continue" (passthrough)
12
+ *
13
+ * Observability:
14
+ * - Return value is the typed verification outcome ("continue" | "retry" | "pause").
15
+ * - shell-command captures stderr from spawnSync — callers can inspect on retry.
16
+ * - content-heuristic logs the specific failure (missing file, below minSize, pattern mismatch).
17
+ * - The frozen DEFINITION.yaml on disk is the single source of truth for step policies.
18
+ */
19
+ import { readFileSync, existsSync, statSync } from "node:fs";
20
+ import { resolve, sep } from "node:path";
21
+ import { spawnSync } from "node:child_process";
22
+ import { readFrozenDefinition } from "./custom-workflow-engine.js";
23
+ /**
24
+ * Run custom verification for a specific step in a workflow run.
25
+ *
26
+ * Reads the frozen DEFINITION.yaml from `runDir`, finds the step with the
27
+ * given `stepId`, and dispatches to the appropriate verification handler
28
+ * based on the step's `verify.policy` field.
29
+ *
30
+ * @param runDir — absolute path to the workflow run directory
31
+ * @param stepId — the step ID to verify (e.g. "step-1")
32
+ * @returns "continue" if verification passes, "retry" if it should retry, "pause" if it needs review
33
+ * @throws Error if DEFINITION.yaml is missing or unreadable
34
+ */
35
+ export function runCustomVerification(runDir, stepId) {
36
+ const def = readFrozenDefinition(runDir);
37
+ const step = def.steps.find((s) => s.id === stepId);
38
+ if (!step) {
39
+ // Step not found in definition — nothing to verify, continue
40
+ return "continue";
41
+ }
42
+ if (!step.verify) {
43
+ // No verification policy configured — passthrough
44
+ return "continue";
45
+ }
46
+ return dispatchPolicy(runDir, step, step.verify);
47
+ }
48
+ /**
49
+ * Dispatch to the correct policy handler.
50
+ */
51
+ function dispatchPolicy(runDir, step, verify) {
52
+ switch (verify.policy) {
53
+ case "content-heuristic":
54
+ return handleContentHeuristic(runDir, step, verify);
55
+ case "shell-command":
56
+ return handleShellCommand(runDir, verify);
57
+ case "prompt-verify":
58
+ return "pause";
59
+ case "human-review":
60
+ return "pause";
61
+ default:
62
+ // Unknown policy — safe default is pause
63
+ return "pause";
64
+ }
65
+ }
66
+ /**
67
+ * content-heuristic handler.
68
+ *
69
+ * For each path in the step's `produces` array:
70
+ * 1. Check that the file exists (resolved relative to runDir)
71
+ * 2. If `minSize` is set, check that file size >= minSize bytes
72
+ * 3. If `pattern` is set, check that file content matches the regex
73
+ *
74
+ * Returns "continue" if all checks pass, "pause" if any fail.
75
+ * If `produces` is empty or undefined, returns "continue" (nothing to check).
76
+ */
77
+ function handleContentHeuristic(runDir, step, verify) {
78
+ const produces = step.produces;
79
+ if (!produces || produces.length === 0) {
80
+ return "continue";
81
+ }
82
+ for (const relPath of produces) {
83
+ const absPath = resolve(runDir, relPath);
84
+ // Path traversal guard
85
+ if (!absPath.startsWith(resolve(runDir) + sep) && absPath !== resolve(runDir)) {
86
+ return "pause";
87
+ }
88
+ // 1. File existence
89
+ if (!existsSync(absPath)) {
90
+ return "pause";
91
+ }
92
+ // 2. Minimum size check
93
+ if (verify.minSize !== undefined) {
94
+ const stat = statSync(absPath);
95
+ if (stat.size < verify.minSize) {
96
+ return "pause";
97
+ }
98
+ }
99
+ // 3. Pattern match check (with timeout guard against ReDoS)
100
+ if (verify.pattern !== undefined) {
101
+ const content = readFileSync(absPath, "utf-8");
102
+ try {
103
+ if (!new RegExp(verify.pattern).test(content)) {
104
+ return "pause";
105
+ }
106
+ }
107
+ catch {
108
+ // Invalid regex at runtime — treat as verification failure
109
+ return "pause";
110
+ }
111
+ }
112
+ }
113
+ return "continue";
114
+ }
115
+ /**
116
+ * shell-command handler.
117
+ *
118
+ * Runs the command via `sh -c` with cwd set to the run directory
119
+ * and a 30-second timeout. Returns "continue" if exit code 0,
120
+ * "retry" otherwise (including timeout/signal kills).
121
+ *
122
+ * SECURITY: The command string comes from a frozen DEFINITION.yaml written
123
+ * at run-creation time. The trust boundary is the workflow definition author.
124
+ * Commands run with the same privileges as the GSD process. Only use
125
+ * shell-command verification with definitions you trust.
126
+ */
127
+ function handleShellCommand(runDir, verify) {
128
+ // Guard: reject commands containing shell expansion patterns that suggest injection
129
+ const dangerousPatterns = /\$\(|`|;\s*(rm|curl|wget|nc|bash|sh|eval)\b/;
130
+ if (dangerousPatterns.test(verify.command)) {
131
+ console.warn(`custom-verification: shell-command contains suspicious pattern, skipping: ${verify.command}`);
132
+ return "pause";
133
+ }
134
+ const result = spawnSync("sh", ["-c", verify.command], {
135
+ cwd: runDir,
136
+ timeout: 30_000,
137
+ encoding: "utf-8",
138
+ stdio: "pipe",
139
+ env: { ...process.env, PATH: process.env.PATH },
140
+ });
141
+ if (result.status === 0) {
142
+ return "continue";
143
+ }
144
+ return "retry";
145
+ }