gsd-pi 2.74.0-dev.2b524c3 → 2.74.0-dev.6e23363

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 (275) hide show
  1. package/dist/cli.js +85 -0
  2. package/dist/headless-query.js +4 -1
  3. package/dist/help-text.js +23 -0
  4. package/dist/resources/extensions/gsd/activity-log.js +16 -0
  5. package/dist/resources/extensions/gsd/auto/detect-stuck.js +11 -4
  6. package/dist/resources/extensions/gsd/auto/loop.js +147 -10
  7. package/dist/resources/extensions/gsd/auto/phases.js +158 -4
  8. package/dist/resources/extensions/gsd/auto/session.js +10 -0
  9. package/dist/resources/extensions/gsd/auto-dispatch.js +11 -1
  10. package/dist/resources/extensions/gsd/auto-model-selection.js +51 -5
  11. package/dist/resources/extensions/gsd/auto-post-unit.js +213 -14
  12. package/dist/resources/extensions/gsd/auto-prompts.js +12 -0
  13. package/dist/resources/extensions/gsd/auto-unit-closeout.js +18 -0
  14. package/dist/resources/extensions/gsd/auto-verification.js +100 -2
  15. package/dist/resources/extensions/gsd/auto.js +36 -4
  16. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +21 -8
  17. package/dist/resources/extensions/gsd/commands/catalog.js +26 -1
  18. package/dist/resources/extensions/gsd/commands/handlers/ops.js +20 -0
  19. package/dist/resources/extensions/gsd/commands/handlers/workflow.js +68 -9
  20. package/dist/resources/extensions/gsd/commands-add-tests.js +111 -0
  21. package/dist/resources/extensions/gsd/commands-backlog.js +140 -0
  22. package/dist/resources/extensions/gsd/commands-do.js +79 -0
  23. package/dist/resources/extensions/gsd/commands-maintenance.js +6 -6
  24. package/dist/resources/extensions/gsd/commands-pr-branch.js +180 -0
  25. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +1 -1
  26. package/dist/resources/extensions/gsd/commands-session-report.js +82 -0
  27. package/dist/resources/extensions/gsd/commands-ship.js +187 -0
  28. package/dist/resources/extensions/gsd/db-writer.js +3 -5
  29. package/dist/resources/extensions/gsd/docs/preferences-reference.md +14 -1
  30. package/dist/resources/extensions/gsd/git-service.js +49 -1
  31. package/dist/resources/extensions/gsd/graph-context.js +157 -0
  32. package/dist/resources/extensions/gsd/gsd-db.js +581 -2
  33. package/dist/resources/extensions/gsd/guided-flow.js +23 -0
  34. package/dist/resources/extensions/gsd/index.js +15 -2
  35. package/dist/resources/extensions/gsd/init-wizard.js +1 -0
  36. package/dist/resources/extensions/gsd/journal.js +27 -0
  37. package/dist/resources/extensions/gsd/md-importer.js +3 -4
  38. package/dist/resources/extensions/gsd/memory-store.js +19 -51
  39. package/dist/resources/extensions/gsd/metrics.js +19 -0
  40. package/dist/resources/extensions/gsd/milestone-validation-gates.js +13 -12
  41. package/dist/resources/extensions/gsd/native-git-bridge.js +7 -4
  42. package/dist/resources/extensions/gsd/parallel-orchestrator.js +33 -1
  43. package/dist/resources/extensions/gsd/preferences-models.js +20 -3
  44. package/dist/resources/extensions/gsd/preferences-types.js +1 -0
  45. package/dist/resources/extensions/gsd/preferences-validation.js +108 -2
  46. package/dist/resources/extensions/gsd/preferences.js +26 -0
  47. package/dist/resources/extensions/gsd/prompts/add-tests.md +35 -0
  48. package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +12 -2
  49. package/dist/resources/extensions/gsd/state.js +5 -1
  50. package/dist/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
  51. package/dist/resources/extensions/gsd/tools/complete-slice.js +20 -0
  52. package/dist/resources/extensions/gsd/tools/validate-milestone.js +39 -4
  53. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +3 -14
  54. package/dist/resources/extensions/gsd/triage-resolution.js +2 -5
  55. package/dist/resources/extensions/gsd/unit-ownership.js +1 -1
  56. package/dist/resources/extensions/gsd/uok/audit-toggle.js +7 -0
  57. package/dist/resources/extensions/gsd/uok/audit.js +40 -0
  58. package/dist/resources/extensions/gsd/uok/contracts.js +1 -0
  59. package/dist/resources/extensions/gsd/uok/execution-graph.js +179 -0
  60. package/dist/resources/extensions/gsd/uok/flags.js +29 -0
  61. package/dist/resources/extensions/gsd/uok/gate-runner.js +109 -0
  62. package/dist/resources/extensions/gsd/uok/gitops.js +53 -0
  63. package/dist/resources/extensions/gsd/uok/kernel.js +80 -0
  64. package/dist/resources/extensions/gsd/uok/loop-adapter.js +133 -0
  65. package/dist/resources/extensions/gsd/uok/model-policy.js +66 -0
  66. package/dist/resources/extensions/gsd/uok/plan-v2.js +132 -0
  67. package/dist/resources/extensions/gsd/workflow-logger.js +22 -0
  68. package/dist/resources/extensions/gsd/workflow-manifest.js +8 -69
  69. package/dist/resources/extensions/gsd/workflow-migration.js +21 -22
  70. package/dist/resources/extensions/gsd/workflow-projections.js +4 -1
  71. package/dist/resources/extensions/gsd/workflow-reconcile.js +14 -11
  72. package/dist/resources/extensions/ttsr/ttsr-manager.js +3 -1
  73. package/dist/tsconfig.extensions.tsbuildinfo +1 -0
  74. package/dist/web/standalone/.next/BUILD_ID +1 -1
  75. package/dist/web/standalone/.next/app-path-routes-manifest.json +9 -9
  76. package/dist/web/standalone/.next/build-manifest.json +2 -2
  77. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  78. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  79. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  81. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  82. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  83. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  84. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  85. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  86. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  87. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  88. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  89. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  90. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  91. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  92. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/index.html +1 -1
  95. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  99. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  100. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  101. package/dist/web/standalone/.next/server/app-paths-manifest.json +9 -9
  102. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  103. package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
  104. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  105. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  106. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  107. package/package.json +3 -2
  108. package/packages/daemon/package.json +2 -2
  109. package/packages/mcp-server/dist/index.d.ts +3 -0
  110. package/packages/mcp-server/dist/index.d.ts.map +1 -1
  111. package/packages/mcp-server/dist/index.js +3 -0
  112. package/packages/mcp-server/dist/index.js.map +1 -1
  113. package/packages/mcp-server/dist/readers/graph.d.ts +87 -0
  114. package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -0
  115. package/packages/mcp-server/dist/readers/graph.js +548 -0
  116. package/packages/mcp-server/dist/readers/graph.js.map +1 -0
  117. package/packages/mcp-server/dist/readers/index.d.ts +2 -0
  118. package/packages/mcp-server/dist/readers/index.d.ts.map +1 -1
  119. package/packages/mcp-server/dist/readers/index.js +1 -0
  120. package/packages/mcp-server/dist/readers/index.js.map +1 -1
  121. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  122. package/packages/mcp-server/dist/server.js +65 -0
  123. package/packages/mcp-server/dist/server.js.map +1 -1
  124. package/packages/mcp-server/package.json +2 -2
  125. package/packages/mcp-server/src/index.ts +15 -0
  126. package/packages/mcp-server/src/readers/graph.test.ts +426 -0
  127. package/packages/mcp-server/src/readers/graph.ts +708 -0
  128. package/packages/mcp-server/src/readers/index.ts +12 -0
  129. package/packages/mcp-server/src/server.ts +83 -0
  130. package/packages/mcp-server/tsconfig.json +1 -0
  131. package/packages/mcp-server/tsconfig.tsbuildinfo +1 -0
  132. package/packages/native/package.json +2 -2
  133. package/packages/native/tsconfig.tsbuildinfo +1 -0
  134. package/packages/pi-agent-core/package.json +1 -1
  135. package/packages/pi-agent-core/tsconfig.json +1 -0
  136. package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -0
  137. package/packages/pi-ai/package.json +1 -1
  138. package/packages/pi-ai/tsconfig.json +1 -0
  139. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -0
  140. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +120 -0
  141. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  142. package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts +2 -0
  143. package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts.map +1 -0
  144. package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js +52 -0
  145. package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js.map +1 -0
  146. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  147. package/packages/pi-coding-agent/dist/core/model-registry.js +2 -2
  148. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  149. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  150. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +48 -4
  151. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  152. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +166 -0
  153. package/packages/pi-coding-agent/src/core/model-registry-env-fallback.test.ts +59 -0
  154. package/packages/pi-coding-agent/src/core/model-registry.ts +2 -1
  155. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +53 -4
  156. package/packages/pi-coding-agent/src/types/ambient-modules.d.ts +69 -0
  157. package/packages/pi-coding-agent/tsconfig.json +3 -2
  158. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -0
  159. package/packages/pi-tui/package.json +1 -1
  160. package/packages/pi-tui/tsconfig.json +1 -0
  161. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -0
  162. package/packages/rpc-client/package.json +1 -1
  163. package/packages/rpc-client/tsconfig.json +1 -0
  164. package/packages/rpc-client/tsconfig.tsbuildinfo +1 -0
  165. package/src/resources/extensions/gsd/activity-log.ts +21 -0
  166. package/src/resources/extensions/gsd/auto/detect-stuck.ts +12 -4
  167. package/src/resources/extensions/gsd/auto/loop-deps.ts +10 -0
  168. package/src/resources/extensions/gsd/auto/loop.ts +159 -10
  169. package/src/resources/extensions/gsd/auto/phases.ts +191 -4
  170. package/src/resources/extensions/gsd/auto/session.ts +10 -0
  171. package/src/resources/extensions/gsd/auto-dispatch.ts +16 -6
  172. package/src/resources/extensions/gsd/auto-model-selection.ts +66 -5
  173. package/src/resources/extensions/gsd/auto-post-unit.ts +231 -15
  174. package/src/resources/extensions/gsd/auto-prompts.ts +13 -0
  175. package/src/resources/extensions/gsd/auto-unit-closeout.ts +25 -1
  176. package/src/resources/extensions/gsd/auto-verification.ts +129 -2
  177. package/src/resources/extensions/gsd/auto.ts +41 -2
  178. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +24 -8
  179. package/src/resources/extensions/gsd/commands/catalog.ts +26 -1
  180. package/src/resources/extensions/gsd/commands/handlers/ops.ts +20 -0
  181. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +74 -9
  182. package/src/resources/extensions/gsd/commands-add-tests.ts +137 -0
  183. package/src/resources/extensions/gsd/commands-backlog.ts +182 -0
  184. package/src/resources/extensions/gsd/commands-do.ts +109 -0
  185. package/src/resources/extensions/gsd/commands-maintenance.ts +6 -6
  186. package/src/resources/extensions/gsd/commands-pr-branch.ts +234 -0
  187. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1 -1
  188. package/src/resources/extensions/gsd/commands-session-report.ts +101 -0
  189. package/src/resources/extensions/gsd/commands-ship.ts +219 -0
  190. package/src/resources/extensions/gsd/db-writer.ts +3 -5
  191. package/src/resources/extensions/gsd/docs/preferences-reference.md +14 -1
  192. package/src/resources/extensions/gsd/git-service.ts +68 -0
  193. package/src/resources/extensions/gsd/graph-context.ts +212 -0
  194. package/src/resources/extensions/gsd/gsd-db.ts +788 -3
  195. package/src/resources/extensions/gsd/guided-flow.ts +32 -0
  196. package/src/resources/extensions/gsd/index.ts +18 -2
  197. package/src/resources/extensions/gsd/init-wizard.ts +3 -2
  198. package/src/resources/extensions/gsd/journal.ts +30 -0
  199. package/src/resources/extensions/gsd/md-importer.ts +3 -5
  200. package/src/resources/extensions/gsd/memory-store.ts +31 -62
  201. package/src/resources/extensions/gsd/metrics.ts +26 -0
  202. package/src/resources/extensions/gsd/milestone-validation-gates.ts +13 -14
  203. package/src/resources/extensions/gsd/native-git-bridge.ts +11 -12
  204. package/src/resources/extensions/gsd/parallel-orchestrator.ts +40 -1
  205. package/src/resources/extensions/gsd/preferences-models.ts +20 -3
  206. package/src/resources/extensions/gsd/preferences-types.ts +32 -0
  207. package/src/resources/extensions/gsd/preferences-validation.ts +107 -2
  208. package/src/resources/extensions/gsd/preferences.ts +28 -0
  209. package/src/resources/extensions/gsd/prompts/add-tests.md +35 -0
  210. package/src/resources/extensions/gsd/session-lock.ts +14 -2
  211. package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +20 -1
  212. package/src/resources/extensions/gsd/state.ts +9 -2
  213. package/src/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
  214. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +7 -3
  215. package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +20 -0
  216. package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +7 -3
  217. package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +6 -2
  218. package/src/resources/extensions/gsd/tests/commands-backlog.test.ts +158 -0
  219. package/src/resources/extensions/gsd/tests/commands-do.test.ts +127 -0
  220. package/src/resources/extensions/gsd/tests/commands-pr-branch.test.ts +68 -0
  221. package/src/resources/extensions/gsd/tests/commands-session-report.test.ts +82 -0
  222. package/src/resources/extensions/gsd/tests/commands-ship.test.ts +71 -0
  223. package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +14 -0
  224. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
  225. package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
  226. package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +154 -0
  227. package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +10 -7
  228. package/src/resources/extensions/gsd/tests/graph-context.test.ts +337 -0
  229. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1 -1
  230. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +68 -1
  231. package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -2
  232. package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -3
  233. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +140 -0
  234. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
  235. package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +2 -1
  236. package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +40 -1
  237. package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +180 -0
  238. package/src/resources/extensions/gsd/tests/token-profile.test.ts +8 -5
  239. package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +101 -0
  240. package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +85 -0
  241. package/src/resources/extensions/gsd/tests/uok-execution-graph.test.ts +69 -0
  242. package/src/resources/extensions/gsd/tests/uok-flags.test.ts +39 -0
  243. package/src/resources/extensions/gsd/tests/uok-gate-runner.test.ts +70 -0
  244. package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +85 -0
  245. package/src/resources/extensions/gsd/tests/uok-gitops-wiring.test.ts +35 -0
  246. package/src/resources/extensions/gsd/tests/uok-model-policy.test.ts +89 -0
  247. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +167 -0
  248. package/src/resources/extensions/gsd/tests/uok-preferences.test.ts +42 -0
  249. package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +39 -0
  250. package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +223 -0
  251. package/src/resources/extensions/gsd/tools/complete-slice.ts +26 -0
  252. package/src/resources/extensions/gsd/tools/validate-milestone.ts +48 -3
  253. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +3 -11
  254. package/src/resources/extensions/gsd/triage-resolution.ts +2 -7
  255. package/src/resources/extensions/gsd/types.ts +1 -1
  256. package/src/resources/extensions/gsd/unit-ownership.ts +2 -2
  257. package/src/resources/extensions/gsd/uok/audit-toggle.ts +9 -0
  258. package/src/resources/extensions/gsd/uok/audit.ts +51 -0
  259. package/src/resources/extensions/gsd/uok/contracts.ts +135 -0
  260. package/src/resources/extensions/gsd/uok/execution-graph.ts +241 -0
  261. package/src/resources/extensions/gsd/uok/flags.ts +45 -0
  262. package/src/resources/extensions/gsd/uok/gate-runner.ts +146 -0
  263. package/src/resources/extensions/gsd/uok/gitops.ts +75 -0
  264. package/src/resources/extensions/gsd/uok/kernel.ts +105 -0
  265. package/src/resources/extensions/gsd/uok/loop-adapter.ts +162 -0
  266. package/src/resources/extensions/gsd/uok/model-policy.ts +112 -0
  267. package/src/resources/extensions/gsd/uok/plan-v2.ts +156 -0
  268. package/src/resources/extensions/gsd/workflow-logger.ts +25 -0
  269. package/src/resources/extensions/gsd/workflow-manifest.ts +9 -104
  270. package/src/resources/extensions/gsd/workflow-migration.ts +21 -29
  271. package/src/resources/extensions/gsd/workflow-projections.ts +8 -1
  272. package/src/resources/extensions/gsd/workflow-reconcile.ts +15 -15
  273. package/src/resources/extensions/ttsr/ttsr-manager.ts +10 -5
  274. /package/dist/web/standalone/.next/static/{YzIEI9sxJy4t5xgClF08g → bc2gRVFTgD7j--BsJE7vP}/_buildManifest.js +0 -0
  275. /package/dist/web/standalone/.next/static/{YzIEI9sxJy4t5xgClF08g → bc2gRVFTgD7j--BsJE7vP}/_ssgManifest.js +0 -0
@@ -0,0 +1,127 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ // ─── Mock dispatcher to capture routed commands ─────────────────────────
5
+
6
+ let lastRouted: string | null = null;
7
+ let lastQuick: string | null = null;
8
+
9
+ const mockCtx = {
10
+ ui: {
11
+ notify: (_msg: string, _level: string) => {},
12
+ },
13
+ } as any;
14
+
15
+ // We test the keyword matching logic directly since the handler imports
16
+ // the dispatcher dynamically (which requires the full extension runtime).
17
+
18
+ // Inline the route-matching logic from commands-do.ts for unit testing.
19
+ interface Route {
20
+ keywords: string[];
21
+ command: string;
22
+ }
23
+
24
+ const ROUTES: Route[] = [
25
+ { keywords: ["progress", "status", "dashboard", "how far", "where are we"], command: "status" },
26
+ { keywords: ["auto", "autonomous", "run all", "keep going", "start auto"], command: "auto" },
27
+ { keywords: ["stop", "halt", "abort"], command: "stop" },
28
+ { keywords: ["pause", "break", "take a break"], command: "pause" },
29
+ { keywords: ["history", "past", "what happened", "previous"], command: "history" },
30
+ { keywords: ["doctor", "health", "diagnose", "check health"], command: "doctor" },
31
+ { keywords: ["clean up", "cleanup", "remove old", "prune", "tidy"], command: "cleanup" },
32
+ { keywords: ["ship", "pull request", "create pr", "open pr", "merge"], command: "ship" },
33
+ { keywords: ["discuss", "talk about", "architecture", "design"], command: "discuss" },
34
+ { keywords: ["undo", "revert", "rollback", "take back"], command: "undo" },
35
+ { keywords: ["skip", "skip task", "skip this"], command: "skip" },
36
+ { keywords: ["visualize", "viz", "graph", "chart", "show graph"], command: "visualize" },
37
+ { keywords: ["capture", "note", "idea", "thought", "remember"], command: "capture" },
38
+ { keywords: ["inspect", "database", "sqlite", "db state"], command: "inspect" },
39
+ { keywords: ["session report", "session summary", "cost summary", "how much"], command: "session-report" },
40
+ { keywords: ["backlog", "parking lot", "later", "someday"], command: "backlog" },
41
+ { keywords: ["add tests", "write tests", "generate tests", "test coverage"], command: "add-tests" },
42
+ { keywords: ["next", "step", "next step", "what's next"], command: "next" },
43
+ ];
44
+
45
+ interface MatchResult {
46
+ command: string;
47
+ remainingArgs: string;
48
+ score: number;
49
+ }
50
+
51
+ function matchRoute(input: string): MatchResult | null {
52
+ const lower = input.toLowerCase();
53
+ let bestMatch: MatchResult | null = null;
54
+
55
+ for (const route of ROUTES) {
56
+ for (const keyword of route.keywords) {
57
+ if (lower.includes(keyword)) {
58
+ const score = keyword.length;
59
+ if (!bestMatch || score > bestMatch.score) {
60
+ const idx = lower.indexOf(keyword);
61
+ const remaining = (input.slice(0, idx) + input.slice(idx + keyword.length)).trim();
62
+ bestMatch = { command: route.command, remainingArgs: remaining, score };
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ return bestMatch;
69
+ }
70
+
71
+ // ─── Tests ──────────────────────────────────────────────────────────────
72
+
73
+ test("/gsd do: routes 'show me progress' to status", () => {
74
+ const match = matchRoute("show me progress");
75
+ assert.ok(match);
76
+ assert.equal(match.command, "status");
77
+ });
78
+
79
+ test("/gsd do: routes 'run autonomously' to auto", () => {
80
+ const match = matchRoute("run autonomously");
81
+ assert.ok(match);
82
+ assert.equal(match.command, "auto");
83
+ });
84
+
85
+ test("/gsd do: routes 'clean up old branches' to cleanup", () => {
86
+ const match = matchRoute("clean up old branches");
87
+ assert.ok(match);
88
+ assert.equal(match.command, "cleanup");
89
+ assert.equal(match.remainingArgs, "old branches");
90
+ });
91
+
92
+ test("/gsd do: routes 'create pr for milestone' to ship", () => {
93
+ const match = matchRoute("create pr for milestone");
94
+ assert.ok(match);
95
+ assert.equal(match.command, "ship");
96
+ });
97
+
98
+ test("/gsd do: routes 'add tests for S03' to add-tests", () => {
99
+ const match = matchRoute("add tests for S03");
100
+ assert.ok(match);
101
+ assert.equal(match.command, "add-tests");
102
+ });
103
+
104
+ test("/gsd do: routes 'what is next' to next", () => {
105
+ const match = matchRoute("what's next");
106
+ assert.ok(match);
107
+ assert.equal(match.command, "next");
108
+ });
109
+
110
+ test("/gsd do: returns null for unrecognized input", () => {
111
+ const match = matchRoute("florbinate the gizmo");
112
+ assert.equal(match, null);
113
+ });
114
+
115
+ test("/gsd do: prefers longer keyword match", () => {
116
+ // "check health" (12 chars) should beat "health" (6 chars)
117
+ const match = matchRoute("check health of the system");
118
+ assert.ok(match);
119
+ assert.equal(match.command, "doctor");
120
+ assert.ok(match.score >= 12);
121
+ });
122
+
123
+ test("/gsd do: routes 'session report' to session-report", () => {
124
+ const match = matchRoute("show me the session report");
125
+ assert.ok(match);
126
+ assert.equal(match.command, "session-report");
127
+ });
@@ -0,0 +1,68 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ // Test the filtering logic used by /gsd pr-branch.
5
+ // Full integration requires git operations, so we test the path filtering.
6
+
7
+ test("pr-branch: identifies .gsd/ paths", () => {
8
+ const files = [
9
+ ".gsd/milestones/M001/ROADMAP.md",
10
+ ".gsd/metrics.json",
11
+ "src/main.ts",
12
+ "package.json",
13
+ ".planning/PLAN.md",
14
+ "PLAN.md",
15
+ ];
16
+
17
+ const codeFiles = files.filter(
18
+ (f) => !f.startsWith(".gsd/") && !f.startsWith(".planning/") && f !== "PLAN.md",
19
+ );
20
+
21
+ assert.deepEqual(codeFiles, ["src/main.ts", "package.json"]);
22
+ });
23
+
24
+ test("pr-branch: all .gsd/ files returns empty", () => {
25
+ const files = [
26
+ ".gsd/milestones/M001/ROADMAP.md",
27
+ ".gsd/metrics.json",
28
+ ".gsd/BACKLOG.md",
29
+ ];
30
+
31
+ const codeFiles = files.filter(
32
+ (f) => !f.startsWith(".gsd/") && !f.startsWith(".planning/") && f !== "PLAN.md",
33
+ );
34
+
35
+ assert.equal(codeFiles.length, 0);
36
+ });
37
+
38
+ test("pr-branch: mixed commits with code changes", () => {
39
+ const files = [
40
+ ".gsd/milestones/M001/ROADMAP.md",
41
+ "src/auth.ts",
42
+ "src/auth.test.ts",
43
+ ];
44
+
45
+ const hasCodeChanges = files.some(
46
+ (f) => !f.startsWith(".gsd/") && !f.startsWith(".planning/") && f !== "PLAN.md",
47
+ );
48
+
49
+ assert.ok(hasCodeChanges);
50
+ });
51
+
52
+ test("pr-branch: --dry-run flag", () => {
53
+ assert.ok("--dry-run".includes("--dry-run"));
54
+ assert.ok(!"--name my-branch".includes("--dry-run"));
55
+ });
56
+
57
+ test("pr-branch: --name flag parsing", () => {
58
+ const args = "--name my-clean-pr";
59
+ const nameMatch = args.match(/--name\s+(\S+)/);
60
+ assert.ok(nameMatch);
61
+ assert.equal(nameMatch[1], "my-clean-pr");
62
+ });
63
+
64
+ test("pr-branch: default branch name", () => {
65
+ const currentBranch = "feat/add-auth";
66
+ const prBranch = `pr/${currentBranch}`;
67
+ assert.equal(prBranch, "pr/feat/add-auth");
68
+ });
@@ -0,0 +1,82 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ // Test the formatting logic used by session-report.
5
+ // The actual handler requires runtime context (metrics module), so we
6
+ // test the core formatting and aggregation patterns.
7
+
8
+ test("session-report: format cost correctly", () => {
9
+ // Simple cost formatting test
10
+ const formatCost = (cost: number): string => {
11
+ if (cost < 0.01) return "<$0.01";
12
+ return `$${cost.toFixed(2)}`;
13
+ };
14
+
15
+ assert.equal(formatCost(0), "<$0.01");
16
+ assert.equal(formatCost(0.005), "<$0.01");
17
+ assert.equal(formatCost(1.5), "$1.50");
18
+ assert.equal(formatCost(10.999), "$11.00");
19
+ });
20
+
21
+ test("session-report: format token count", () => {
22
+ const formatTokenCount = (count: number): string => {
23
+ if (count >= 1_000_000) return `${(count / 1_000_000).toFixed(1)}M`;
24
+ if (count >= 1_000) return `${(count / 1_000).toFixed(1)}K`;
25
+ return String(count);
26
+ };
27
+
28
+ assert.equal(formatTokenCount(500), "500");
29
+ assert.equal(formatTokenCount(1500), "1.5K");
30
+ assert.equal(formatTokenCount(1_200_000), "1.2M");
31
+ });
32
+
33
+ test("session-report: aggregate by model", () => {
34
+ interface UnitMetric {
35
+ model: string;
36
+ cost: number;
37
+ }
38
+
39
+ const units: UnitMetric[] = [
40
+ { model: "opus", cost: 1.0 },
41
+ { model: "opus", cost: 0.8 },
42
+ { model: "sonnet", cost: 0.3 },
43
+ { model: "sonnet", cost: 0.5 },
44
+ { model: "sonnet", cost: 0.2 },
45
+ ];
46
+
47
+ const byModel = new Map<string, { count: number; cost: number }>();
48
+ for (const u of units) {
49
+ const existing = byModel.get(u.model) ?? { count: 0, cost: 0 };
50
+ existing.count++;
51
+ existing.cost += u.cost;
52
+ byModel.set(u.model, existing);
53
+ }
54
+
55
+ const opus = byModel.get("opus")!;
56
+ assert.equal(opus.count, 2);
57
+ assert.ok(Math.abs(opus.cost - 1.8) < 0.01);
58
+
59
+ const sonnet = byModel.get("sonnet")!;
60
+ assert.equal(sonnet.count, 3);
61
+ assert.ok(Math.abs(sonnet.cost - 1.0) < 0.01);
62
+ });
63
+
64
+ test("session-report: --json flag detection", () => {
65
+ const args1 = "--json";
66
+ const args2 = "--save --json";
67
+ const args3 = "something else";
68
+
69
+ assert.ok(args1.includes("--json"));
70
+ assert.ok(args2.includes("--json"));
71
+ assert.ok(!args3.includes("--json"));
72
+ });
73
+
74
+ test("session-report: --save flag detection", () => {
75
+ const args1 = "--save";
76
+ const args2 = "--save --json";
77
+ const args3 = "";
78
+
79
+ assert.ok(args1.includes("--save"));
80
+ assert.ok(args2.includes("--save"));
81
+ assert.ok(!args3.includes("--save"));
82
+ });
@@ -0,0 +1,71 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ // Test the PR content generation logic used by /gsd ship.
5
+ // Full integration requires gh CLI + git, so we test the text generation.
6
+
7
+ test("ship: generates TL;DR format", () => {
8
+ // Simulate generatePRContent output structure
9
+ const milestoneId = "M001";
10
+ const milestoneTitle = "User authentication system";
11
+
12
+ const title = `feat: ${milestoneTitle}`;
13
+ assert.equal(title, "feat: User authentication system");
14
+ assert.ok(title.length < 80); // PR title should be short
15
+ });
16
+
17
+ test("ship: --dry-run flag detection", () => {
18
+ const args1 = "--dry-run";
19
+ const args2 = "--draft --dry-run";
20
+ const args3 = "--draft";
21
+
22
+ assert.ok(args1.includes("--dry-run"));
23
+ assert.ok(args2.includes("--dry-run"));
24
+ assert.ok(!args3.includes("--dry-run"));
25
+ });
26
+
27
+ test("ship: --base flag parsing", () => {
28
+ const args = "--base develop --draft";
29
+ const baseMatch = args.match(/--base\s+(\S+)/);
30
+ assert.ok(baseMatch);
31
+ assert.equal(baseMatch[1], "develop");
32
+ });
33
+
34
+ test("ship: --base flag absent defaults", () => {
35
+ const args = "--draft";
36
+ const baseMatch = args.match(/--base\s+(\S+)/);
37
+ assert.equal(baseMatch, null);
38
+ });
39
+
40
+ test("ship: --force flag detection", () => {
41
+ const args1 = "--force";
42
+ const args2 = "";
43
+
44
+ assert.ok(args1.includes("--force"));
45
+ assert.ok(!args2.includes("--force"));
46
+ });
47
+
48
+ test("ship: change type checklist format", () => {
49
+ const checklist = [
50
+ "- [x] `feat` — New feature or capability",
51
+ "- [ ] `fix` — Bug fix",
52
+ "- [ ] `refactor` — Code restructuring",
53
+ "- [ ] `test` — Adding or updating tests",
54
+ "- [ ] `docs` — Documentation only",
55
+ "- [ ] `chore` — Build, CI, or tooling changes",
56
+ ];
57
+
58
+ // Verify format matches CONTRIBUTING.md expectations
59
+ for (const line of checklist) {
60
+ assert.match(line, /^- \[[ x]\] `\w+` — .+$/);
61
+ }
62
+ });
63
+
64
+ test("ship: PR body contains required sections", () => {
65
+ const requiredSections = ["## TL;DR", "## Change type"];
66
+ const body = "## TL;DR\n\n**What:** Ship M001\n\n## Change type\n\n- [x] `feat`";
67
+
68
+ for (const section of requiredSections) {
69
+ assert.ok(body.includes(section), `Missing section: ${section}`);
70
+ }
71
+ });
@@ -217,6 +217,20 @@ describe("workflow command handler", () => {
217
217
  );
218
218
  });
219
219
 
220
+ it("preserves quoted workflow run overrides (#4130)", async () => {
221
+ const { parseWorkflowRunArgs } = await import("../commands/handlers/workflow.ts");
222
+ assert.deepStrictEqual(
223
+ parseWorkflowRunArgs('demo-workflow target="multi word target" region=\'us east\''),
224
+ {
225
+ defName: "demo-workflow",
226
+ overrides: {
227
+ target: "multi word target",
228
+ region: "us east",
229
+ },
230
+ },
231
+ );
232
+ });
233
+
220
234
  it("'/gsd workflow run nonexistent' shows error for missing definition", async () => {
221
235
  const { handled, notifications } = await callHandler("workflow run nonexistent-def-12345");
222
236
  assert.ok(handled, "should be handled");
@@ -125,9 +125,9 @@ console.log('\n=== complete-slice: schema v6 migration ===');
125
125
 
126
126
  const adapter = _getAdapter()!;
127
127
 
128
- // Verify schema version is current (v14 after indexes + slice_dependencies)
128
+ // Verify schema version is current (v15 with UOK projection tables)
129
129
  const versionRow = adapter.prepare('SELECT MAX(version) as v FROM schema_version').get();
130
- assertEq(versionRow?.['v'], 14, 'schema version should be 14');
130
+ assertEq(versionRow?.['v'], 15, 'schema version should be 15');
131
131
 
132
132
  // Verify slices table has full_summary_md and full_uat_md columns
133
133
  const cols = adapter.prepare("PRAGMA table_info(slices)").all();
@@ -109,9 +109,9 @@ console.log('\n=== complete-task: schema v5 migration ===');
109
109
 
110
110
  const adapter = _getAdapter()!;
111
111
 
112
- // Verify schema version is current (v14 after indexes + slice_dependencies)
112
+ // Verify schema version is current (v15 with UOK projection tables)
113
113
  const versionRow = adapter.prepare('SELECT MAX(version) as v FROM schema_version').get();
114
- assertEq(versionRow?.['v'], 14, 'schema version should be 14');
114
+ assertEq(versionRow?.['v'], 15, 'schema version should be 15');
115
115
 
116
116
  // Verify all 4 new tables exist
117
117
  const tables = adapter.prepare(
@@ -0,0 +1,154 @@
1
+ // Structural contracts for GSD extension bootstrap isolation.
2
+ //
3
+ // The /gsd command must survive failures in the full extension bootstrap
4
+ // (register-extension.ts). This guards against the regression where a
5
+ // Windows-specific import failure in register-shortcuts.ts silently
6
+ // prevented /gsd from being registered at all (#4168, #4172).
7
+
8
+ import { describe, test } from "node:test";
9
+ import assert from "node:assert/strict";
10
+ import { readFileSync } from "node:fs";
11
+ import { join, dirname } from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const indexSrc = readFileSync(join(__dirname, "../index.ts"), "utf-8");
16
+ const registerExtSrc = readFileSync(
17
+ join(__dirname, "../bootstrap/register-extension.ts"),
18
+ "utf-8",
19
+ );
20
+
21
+ // ─── index.ts: core /gsd command must be registered before full bootstrap ─────
22
+
23
+ describe("index.ts bootstrap isolation", () => {
24
+ test("imports registerGSDCommand from commands/index.js separately", () => {
25
+ assert.ok(
26
+ indexSrc.includes('./commands/index.js"') || indexSrc.includes("./commands/index.js'"),
27
+ "index.ts must import registerGSDCommand from ./commands/index.js",
28
+ );
29
+ });
30
+
31
+ test("calls registerGSDCommand before importing register-extension.js", () => {
32
+ const gsdCommandCallPos = indexSrc.indexOf("registerGSDCommand(pi)");
33
+ const bootstrapImportPos = indexSrc.indexOf(
34
+ './bootstrap/register-extension.js"',
35
+ );
36
+
37
+ assert.ok(gsdCommandCallPos >= 0, "must call registerGSDCommand(pi)");
38
+ assert.ok(bootstrapImportPos >= 0, "must import register-extension.js");
39
+ assert.ok(
40
+ gsdCommandCallPos < bootstrapImportPos,
41
+ "registerGSDCommand(pi) must be called BEFORE importing register-extension.js",
42
+ );
43
+ });
44
+
45
+ test("wraps register-extension.js import in try-catch", () => {
46
+ // The dynamic import of register-extension.js must be inside a try block
47
+ const tryPos = indexSrc.indexOf("try {");
48
+ const bootstrapImportPos = indexSrc.indexOf(
49
+ './bootstrap/register-extension.js"',
50
+ );
51
+ const catchPos = indexSrc.indexOf("catch (err)");
52
+
53
+ assert.ok(tryPos >= 0, "must have try block");
54
+ assert.ok(catchPos >= 0, "must have catch block");
55
+ assert.ok(
56
+ tryPos < bootstrapImportPos && bootstrapImportPos < catchPos,
57
+ "register-extension.js import must be wrapped in try-catch",
58
+ );
59
+ });
60
+
61
+ test("logs warning on bootstrap failure via workflow-logger", () => {
62
+ assert.ok(
63
+ indexSrc.includes("logWarning"),
64
+ "must use logWarning when bootstrap fails",
65
+ );
66
+ assert.ok(
67
+ indexSrc.includes("Extension setup partially failed"),
68
+ "warning message must indicate partial failure with /gsd still available",
69
+ );
70
+ });
71
+ });
72
+
73
+ // ─── register-extension.ts: no double-registration + defensive wrapping ───────
74
+
75
+ describe("register-extension.ts defensive registration", () => {
76
+ test("does NOT import or call registerGSDCommand (avoids double-registration)", () => {
77
+ // registerGSDCommand is now called by index.ts, not register-extension.ts
78
+ assert.ok(
79
+ !registerExtSrc.includes("import { registerGSDCommand }"),
80
+ "register-extension.ts must NOT import registerGSDCommand",
81
+ );
82
+
83
+ // Check the function body of registerGsdExtension doesn't call it
84
+ const funcBodyStart = registerExtSrc.indexOf(
85
+ "export function registerGsdExtension",
86
+ );
87
+ const funcBody = registerExtSrc.slice(funcBodyStart);
88
+ assert.ok(
89
+ !funcBody.includes("registerGSDCommand(pi)"),
90
+ "registerGsdExtension must NOT call registerGSDCommand(pi)",
91
+ );
92
+ });
93
+
94
+ test("still registers worktree, exit, and kill commands", () => {
95
+ const funcBodyStart = registerExtSrc.indexOf(
96
+ "export function registerGsdExtension",
97
+ );
98
+ const funcBody = registerExtSrc.slice(funcBodyStart);
99
+
100
+ assert.ok(
101
+ funcBody.includes("registerWorktreeCommand(pi)"),
102
+ "must register worktree command",
103
+ );
104
+ assert.ok(
105
+ funcBody.includes("registerExitCommand(pi)"),
106
+ "must register exit command",
107
+ );
108
+ assert.ok(
109
+ funcBody.includes('"kill"'),
110
+ "must register kill command",
111
+ );
112
+ });
113
+
114
+ test("wraps non-critical registrations in individual try-catch blocks", () => {
115
+ const funcBodyStart = registerExtSrc.indexOf(
116
+ "export function registerGsdExtension",
117
+ );
118
+ const funcBody = registerExtSrc.slice(funcBodyStart);
119
+
120
+ // Each non-critical registration should be wrapped with error handling
121
+ const registrationNames = [
122
+ "dynamic-tools",
123
+ "db-tools",
124
+ "journal-tools",
125
+ "query-tools",
126
+ "shortcuts",
127
+ "hooks",
128
+ ];
129
+
130
+ for (const name of registrationNames) {
131
+ assert.ok(
132
+ funcBody.includes(`"${name}"`),
133
+ `non-critical registration "${name}" must be present`,
134
+ );
135
+ }
136
+
137
+ // Must have try-catch inside the registration loop
138
+ assert.ok(
139
+ funcBody.includes("try {") && funcBody.includes("catch (err)"),
140
+ "must have try-catch for non-critical registrations",
141
+ );
142
+ });
143
+
144
+ test("logs warning when a non-critical registration fails", () => {
145
+ assert.ok(
146
+ registerExtSrc.includes("Failed to register"),
147
+ "must log descriptive warning for individual registration failures",
148
+ );
149
+ assert.ok(
150
+ registerExtSrc.includes("logWarning"),
151
+ "must use logWarning from workflow-logger",
152
+ );
153
+ });
154
+ });
@@ -26,6 +26,14 @@ import { MAX_FINALIZE_TIMEOUTS } from "../auto/types.ts";
26
26
 
27
27
  const { assertTrue, assertEq, report } = createTestContext();
28
28
 
29
+ function getRunFinalizeBody(phasesSource: string): string {
30
+ const fnIdx = phasesSource.indexOf("export async function runFinalize(");
31
+ assertTrue(fnIdx > 0, "runFinalize function should exist in phases.ts");
32
+
33
+ const nextExportIdx = phasesSource.indexOf("\nexport ", fnIdx + 1);
34
+ return phasesSource.slice(fnIdx, nextExportIdx > fnIdx ? nextExportIdx : undefined);
35
+ }
36
+
29
37
  // ═══ Test: withTimeout resolves when inner promise resolves promptly ══════════
30
38
 
31
39
  {
@@ -145,11 +153,7 @@ const { assertTrue, assertEq, report } = createTestContext();
145
153
  "utf-8",
146
154
  );
147
155
 
148
- // Find the runFinalize function body
149
- const fnIdx = phasesSource.indexOf("export async function runFinalize(");
150
- assertTrue(fnIdx > 0, "runFinalize function should exist in phases.ts");
151
-
152
- const fnBody = phasesSource.slice(fnIdx, fnIdx + 8000);
156
+ const fnBody = getRunFinalizeBody(phasesSource);
153
157
 
154
158
  // postUnitPreVerification must be wrapped in withTimeout
155
159
  const preTimeoutIdx = fnBody.indexOf("withTimeout(");
@@ -207,8 +211,7 @@ const { assertTrue, assertEq, report } = createTestContext();
207
211
  "utf-8",
208
212
  );
209
213
 
210
- const fnIdx = phasesSource.indexOf("export async function runFinalize(");
211
- const fnBody = phasesSource.slice(fnIdx, fnIdx + 8000);
214
+ const fnBody = getRunFinalizeBody(phasesSource);
212
215
 
213
216
  // Both timeout handlers should increment consecutiveFinalizeTimeouts
214
217
  const incrementCount = (fnBody.match(/consecutiveFinalizeTimeouts\+\+/g) || []).length;