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
@@ -1,5 +1,4 @@
1
1
  // GSD2 — Extension registration: wires all GSD tools, commands, and hooks into pi
2
- import { registerGSDCommand } from "../commands.js";
3
2
  import { registerExitCommand } from "../exit-command.js";
4
3
  import { registerWorktreeCommand } from "../worktree-command.js";
5
4
  import { registerDbTools } from "./db-tools.js";
@@ -9,6 +8,7 @@ import { registerQueryTools } from "./query-tools.js";
9
8
  import { registerHooks } from "./register-hooks.js";
10
9
  import { registerShortcuts } from "./register-shortcuts.js";
11
10
  import { writeCrashLog } from "./crash-log.js";
11
+ import { logWarning } from "../workflow-logger.js";
12
12
  export { writeCrashLog } from "./crash-log.js";
13
13
  export function handleRecoverableExtensionProcessError(err) {
14
14
  if (err.code === "EPIPE") {
@@ -52,7 +52,8 @@ function installEpipeGuard() {
52
52
  }
53
53
  }
54
54
  export function registerGsdExtension(pi) {
55
- registerGSDCommand(pi);
55
+ // Note: registerGSDCommand is called by index.ts before this function,
56
+ // so we intentionally skip it here to avoid double-registration.
56
57
  registerWorktreeCommand(pi);
57
58
  registerExitCommand(pi);
58
59
  installEpipeGuard();
@@ -62,10 +63,22 @@ export function registerGsdExtension(pi) {
62
63
  process.exit(0);
63
64
  },
64
65
  });
65
- registerDynamicTools(pi);
66
- registerDbTools(pi);
67
- registerJournalTools(pi);
68
- registerQueryTools(pi);
69
- registerShortcuts(pi);
70
- registerHooks(pi);
66
+ // Wrap non-critical registrations individually so one failure
67
+ // doesn't prevent the others from loading.
68
+ const nonCriticalRegistrations = [
69
+ ["dynamic-tools", () => registerDynamicTools(pi)],
70
+ ["db-tools", () => registerDbTools(pi)],
71
+ ["journal-tools", () => registerJournalTools(pi)],
72
+ ["query-tools", () => registerQueryTools(pi)],
73
+ ["shortcuts", () => registerShortcuts(pi)],
74
+ ["hooks", () => registerHooks(pi)],
75
+ ];
76
+ for (const [name, register] of nonCriticalRegistrations) {
77
+ try {
78
+ register();
79
+ }
80
+ catch (err) {
81
+ logWarning("bootstrap", `Failed to register ${name}: ${err instanceof Error ? err.message : String(err)}`);
82
+ }
83
+ }
71
84
  }
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { loadRegistry } from "../workflow-templates.js";
5
5
  import { resolveProjectRoot } from "../worktree.js";
6
6
  const gsdHome = process.env.GSD_HOME || join(homedir(), ".gsd");
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|undo-task|reset-slice|rate|skip|export|cleanup|model|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|mcp|rethink|codebase|notifications";
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|undo-task|reset-slice|rate|skip|export|cleanup|model|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|mcp|rethink|codebase|notifications|ship|do|session-report|backlog|pr-branch|add-tests";
8
8
  export const TOP_LEVEL_SUBCOMMANDS = [
9
9
  { cmd: "help", desc: "Categorized command reference with descriptions" },
10
10
  { cmd: "next", desc: "Explicit step mode (same as /gsd)" },
@@ -62,6 +62,12 @@ export const TOP_LEVEL_SUBCOMMANDS = [
62
62
  { cmd: "rethink", desc: "Conversational project reorganization — reorder, park, discard, add milestones" },
63
63
  { cmd: "workflow", desc: "Custom workflow lifecycle (new, run, list, validate, pause, resume)" },
64
64
  { cmd: "codebase", desc: "Generate, refresh, and inspect the codebase map cache (.gsd/CODEBASE.md)" },
65
+ { cmd: "ship", desc: "Create PR from milestone artifacts and open for review" },
66
+ { cmd: "do", desc: "Route freeform text to the right GSD command" },
67
+ { cmd: "session-report", desc: "Session cost, tokens, and work summary" },
68
+ { cmd: "backlog", desc: "Manage backlog items (add, promote, remove, list)" },
69
+ { cmd: "pr-branch", desc: "Create clean PR branch filtering .gsd/ commits" },
70
+ { cmd: "add-tests", desc: "Generate tests for completed slices" },
65
71
  ];
66
72
  const NESTED_COMPLETIONS = {
67
73
  auto: [
@@ -231,6 +237,25 @@ const NESTED_COMPLETIONS = {
231
237
  { cmd: "stats", desc: "Show file count, description coverage, and generation time" },
232
238
  { cmd: "help", desc: "Show usage and available subcommands" },
233
239
  ],
240
+ ship: [
241
+ { cmd: "--dry-run", desc: "Preview PR without creating" },
242
+ { cmd: "--draft", desc: "Open as draft PR" },
243
+ { cmd: "--base", desc: "Override target branch (default: main)" },
244
+ { cmd: "--force", desc: "Ship even with pending tasks" },
245
+ ],
246
+ "session-report": [
247
+ { cmd: "--json", desc: "Machine-readable JSON output" },
248
+ { cmd: "--save", desc: "Save report to .gsd/reports/" },
249
+ ],
250
+ backlog: [
251
+ { cmd: "add", desc: "Add item to backlog" },
252
+ { cmd: "promote", desc: "Promote backlog item to active slice" },
253
+ { cmd: "remove", desc: "Remove backlog item" },
254
+ ],
255
+ "pr-branch": [
256
+ { cmd: "--dry-run", desc: "Preview what would be filtered" },
257
+ { cmd: "--name", desc: "Custom branch name" },
258
+ ],
234
259
  };
235
260
  function filterOptions(partial, options, prefix = "") {
236
261
  const normalizedPrefix = prefix ? `${prefix} ` : "";
@@ -8,6 +8,9 @@ import { handleExport } from "../../export.js";
8
8
  import { handleHistory } from "../../history.js";
9
9
  import { handleUndo } from "../../undo.js";
10
10
  import { handleRemote } from "../../../remote-questions/mod.js";
11
+ import { handleShip } from "../../commands-ship.js";
12
+ import { handleSessionReport } from "../../commands-session-report.js";
13
+ import { handlePrBranch } from "../../commands-pr-branch.js";
11
14
  import { projectRoot } from "../context.js";
12
15
  export async function handleOpsCommand(trimmed, ctx, pi) {
13
16
  if (trimmed === "init") {
@@ -213,5 +216,22 @@ Examples:
213
216
  await handleCodebase(trimmed.replace(/^codebase\s*/, "").trim(), ctx, pi);
214
217
  return true;
215
218
  }
219
+ if (trimmed === "ship" || trimmed.startsWith("ship ")) {
220
+ await handleShip(trimmed.replace(/^ship\s*/, "").trim(), ctx, pi);
221
+ return true;
222
+ }
223
+ if (trimmed === "session-report" || trimmed.startsWith("session-report ")) {
224
+ await handleSessionReport(trimmed.replace(/^session-report\s*/, "").trim(), ctx);
225
+ return true;
226
+ }
227
+ if (trimmed === "pr-branch" || trimmed.startsWith("pr-branch ")) {
228
+ await handlePrBranch(trimmed.replace(/^pr-branch\s*/, "").trim(), ctx);
229
+ return true;
230
+ }
231
+ if (trimmed === "add-tests" || trimmed.startsWith("add-tests ")) {
232
+ const { handleAddTests } = await import("../../commands-add-tests.js");
233
+ await handleAddTests(trimmed.replace(/^add-tests\s*/, "").trim(), ctx, pi);
234
+ return true;
235
+ }
216
236
  return false;
217
237
  }
@@ -25,6 +25,61 @@ const WORKFLOW_USAGE = [
25
25
  " pause — Pause custom workflow auto-mode",
26
26
  " resume — Resume paused custom workflow auto-mode",
27
27
  ].join("\n");
28
+ function splitWorkflowRunArgs(input) {
29
+ const tokens = [];
30
+ let current = "";
31
+ let quote = null;
32
+ let escapeNext = false;
33
+ for (const ch of input) {
34
+ if (escapeNext) {
35
+ current += ch;
36
+ escapeNext = false;
37
+ continue;
38
+ }
39
+ if (ch === "\\") {
40
+ escapeNext = true;
41
+ continue;
42
+ }
43
+ if (quote) {
44
+ if (ch === quote) {
45
+ quote = null;
46
+ }
47
+ else {
48
+ current += ch;
49
+ }
50
+ continue;
51
+ }
52
+ if (ch === '"' || ch === "'") {
53
+ quote = ch;
54
+ continue;
55
+ }
56
+ if (/\s/.test(ch)) {
57
+ if (current) {
58
+ tokens.push(current);
59
+ current = "";
60
+ }
61
+ continue;
62
+ }
63
+ current += ch;
64
+ }
65
+ if (escapeNext)
66
+ current += "\\";
67
+ if (current)
68
+ tokens.push(current);
69
+ return tokens;
70
+ }
71
+ export function parseWorkflowRunArgs(args) {
72
+ const parts = splitWorkflowRunArgs(args);
73
+ const defName = parts[0] ?? "";
74
+ const overrides = {};
75
+ for (let i = 1; i < parts.length; i++) {
76
+ const eqIdx = parts[i].indexOf("=");
77
+ if (eqIdx > 0) {
78
+ overrides[parts[i].slice(0, eqIdx)] = parts[i].slice(eqIdx + 1);
79
+ }
80
+ }
81
+ return { defName, overrides };
82
+ }
28
83
  async function handleCustomWorkflow(sub, ctx, pi) {
29
84
  // Bare `/gsd workflow` — show usage
30
85
  if (!sub) {
@@ -43,15 +98,7 @@ async function handleCustomWorkflow(sub, ctx, pi) {
43
98
  ctx.ui.notify("Usage: /gsd workflow run <name> [param=value ...]", "warning");
44
99
  return true;
45
100
  }
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
- }
101
+ const { defName, overrides } = parseWorkflowRunArgs(args);
55
102
  try {
56
103
  const base = projectRoot();
57
104
  const runDir = createRun(base, defName, Object.keys(overrides).length > 0 ? overrides : undefined);
@@ -146,6 +193,18 @@ async function handleCustomWorkflow(sub, ctx, pi) {
146
193
  return true;
147
194
  }
148
195
  export async function handleWorkflowCommand(trimmed, ctx, pi) {
196
+ // ── /gsd do — natural language routing (must be early to route to other commands) ──
197
+ if (trimmed === "do" || trimmed.startsWith("do ")) {
198
+ const { handleDo } = await import("../../commands-do.js");
199
+ await handleDo(trimmed.replace(/^do\s*/, "").trim(), ctx, pi);
200
+ return true;
201
+ }
202
+ // ── Backlog management ──
203
+ if (trimmed === "backlog" || trimmed.startsWith("backlog ")) {
204
+ const { handleBacklog } = await import("../../commands-backlog.js");
205
+ await handleBacklog(trimmed.replace(/^backlog\s*/, "").trim(), ctx, pi);
206
+ return true;
207
+ }
149
208
  // ── Custom workflow commands (`/gsd workflow ...`) ──
150
209
  if (trimmed === "workflow" || trimmed.startsWith("workflow ")) {
151
210
  const sub = trimmed.slice("workflow".length).trim();
@@ -0,0 +1,111 @@
1
+ /**
2
+ * GSD Command — /gsd add-tests
3
+ *
4
+ * Generates tests for a completed slice by dispatching an LLM prompt
5
+ * with implementation context (summaries, changed files, test patterns).
6
+ */
7
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { deriveState } from "./state.js";
10
+ import { gsdRoot, resolveSliceFile } from "./paths.js";
11
+ import { loadPrompt } from "./prompt-loader.js";
12
+ function findLastCompletedSlice(basePath, milestoneId) {
13
+ // Scan disk for slices that have a SUMMARY.md (indicating completion)
14
+ const slicesDir = join(gsdRoot(basePath), "milestones", milestoneId, "slices");
15
+ if (!existsSync(slicesDir))
16
+ return null;
17
+ try {
18
+ const entries = readdirSync(slicesDir, { withFileTypes: true })
19
+ .filter((e) => e.isDirectory() && /^S\d+$/.test(e.name))
20
+ .sort((a, b) => b.name.localeCompare(a.name)); // reverse order — latest first
21
+ for (const entry of entries) {
22
+ const summaryPath = join(slicesDir, entry.name, `${entry.name}-SUMMARY.md`);
23
+ if (existsSync(summaryPath))
24
+ return entry.name;
25
+ }
26
+ }
27
+ catch {
28
+ // non-fatal
29
+ }
30
+ return null;
31
+ }
32
+ function readSliceSummary(basePath, milestoneId, sliceId) {
33
+ const summaryPath = resolveSliceFile(basePath, milestoneId, sliceId, "SUMMARY");
34
+ if (summaryPath && existsSync(summaryPath)) {
35
+ const content = readFileSync(summaryPath, "utf-8");
36
+ const titleMatch = content.match(/^#\s+(.+)/m);
37
+ return { title: titleMatch?.[1] ?? sliceId, content };
38
+ }
39
+ return { title: sliceId, content: "(no summary available)" };
40
+ }
41
+ function detectTestPatterns(basePath) {
42
+ const patterns = [];
43
+ // Check for common test configs
44
+ const checks = [
45
+ { file: "jest.config.ts", name: "Jest" },
46
+ { file: "jest.config.js", name: "Jest" },
47
+ { file: "vitest.config.ts", name: "Vitest" },
48
+ { file: "vitest.config.js", name: "Vitest" },
49
+ { file: ".mocharc.yml", name: "Mocha" },
50
+ ];
51
+ for (const check of checks) {
52
+ if (existsSync(join(basePath, check.file))) {
53
+ patterns.push(`Framework: ${check.name} (${check.file})`);
54
+ }
55
+ }
56
+ // Look for existing test files to infer patterns
57
+ const testDirs = ["tests", "test", "src/__tests__", "__tests__"];
58
+ for (const dir of testDirs) {
59
+ const fullDir = join(basePath, dir);
60
+ if (existsSync(fullDir)) {
61
+ try {
62
+ const files = readdirSync(fullDir).filter((f) => f.endsWith(".test.ts") || f.endsWith(".spec.ts") || f.endsWith(".test.js"));
63
+ if (files.length > 0) {
64
+ patterns.push(`Test directory: ${dir}/ (${files.length} test files)`);
65
+ // Read first test file for patterns
66
+ const samplePath = join(fullDir, files[0]);
67
+ const sample = readFileSync(samplePath, "utf-8").slice(0, 500);
68
+ patterns.push(`Sample pattern from ${files[0]}:\n${sample}`);
69
+ break;
70
+ }
71
+ }
72
+ catch {
73
+ // non-fatal
74
+ }
75
+ }
76
+ }
77
+ return patterns.length > 0 ? patterns.join("\n") : "No test framework detected. Use Node.js built-in test runner.";
78
+ }
79
+ export async function handleAddTests(args, ctx, pi) {
80
+ const basePath = process.cwd();
81
+ const state = await deriveState(basePath);
82
+ if (!state.activeMilestone) {
83
+ ctx.ui.notify("No active milestone.", "warning");
84
+ return;
85
+ }
86
+ const milestoneId = state.activeMilestone.id;
87
+ // Determine target
88
+ const targetId = args.trim() || findLastCompletedSlice(basePath, milestoneId);
89
+ if (!targetId) {
90
+ ctx.ui.notify("No completed slices found. Specify a slice ID: /gsd add-tests S03", "warning");
91
+ return;
92
+ }
93
+ // Gather context
94
+ const summary = readSliceSummary(basePath, milestoneId, targetId);
95
+ const testPatterns = detectTestPatterns(basePath);
96
+ ctx.ui.notify(`Generating tests for ${targetId}: "${summary.title}"...`, "info");
97
+ try {
98
+ const prompt = loadPrompt("add-tests", {
99
+ sliceId: targetId,
100
+ sliceTitle: summary.title,
101
+ sliceSummary: summary.content,
102
+ existingTestPatterns: testPatterns,
103
+ workingDirectory: basePath,
104
+ });
105
+ pi.sendMessage({ customType: "gsd-add-tests", content: prompt, display: false }, { triggerTurn: true });
106
+ }
107
+ catch (err) {
108
+ const msg = err instanceof Error ? err.message : String(err);
109
+ ctx.ui.notify(`Failed to dispatch test generation: ${msg}`, "error");
110
+ }
111
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * GSD Command — /gsd backlog
3
+ *
4
+ * Structured backlog management with 999.x numbering.
5
+ * Items stored in .gsd/BACKLOG.md as markdown checklist.
6
+ * Items can be promoted to active slices via add-slice.
7
+ */
8
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
9
+ import { join, dirname } from "node:path";
10
+ import { gsdRoot } from "./paths.js";
11
+ function backlogPath(basePath) {
12
+ return join(gsdRoot(basePath), "BACKLOG.md");
13
+ }
14
+ function parseBacklog(basePath) {
15
+ const filePath = backlogPath(basePath);
16
+ if (!existsSync(filePath))
17
+ return [];
18
+ const content = readFileSync(filePath, "utf-8");
19
+ const items = [];
20
+ for (const line of content.split("\n")) {
21
+ const match = line.match(/^- \[([ x])\] (999\.\d+) — (.+?)(?:\s*\((.+)\))?$/);
22
+ if (match) {
23
+ items.push({
24
+ id: match[2],
25
+ title: match[3].trim(),
26
+ done: match[1] === "x",
27
+ note: match[4] ?? "",
28
+ });
29
+ }
30
+ }
31
+ return items;
32
+ }
33
+ function writeBacklog(basePath, items) {
34
+ const filePath = backlogPath(basePath);
35
+ mkdirSync(dirname(filePath), { recursive: true });
36
+ const lines = ["# Backlog\n"];
37
+ for (const item of items) {
38
+ const check = item.done ? "x" : " ";
39
+ const note = item.note ? ` (${item.note})` : "";
40
+ lines.push(`- [${check}] ${item.id} — ${item.title}${note}`);
41
+ }
42
+ lines.push(""); // trailing newline
43
+ writeFileSync(filePath, lines.join("\n"), "utf-8");
44
+ }
45
+ function nextBacklogId(items) {
46
+ let maxNum = 0;
47
+ for (const item of items) {
48
+ const match = item.id.match(/^999\.(\d+)$/);
49
+ if (match) {
50
+ const num = parseInt(match[1], 10);
51
+ if (num > maxNum)
52
+ maxNum = num;
53
+ }
54
+ }
55
+ return `999.${maxNum + 1}`;
56
+ }
57
+ async function listBacklog(basePath, ctx) {
58
+ const items = parseBacklog(basePath);
59
+ if (items.length === 0) {
60
+ ctx.ui.notify("Backlog is empty. Add items with /gsd backlog add <title>", "info");
61
+ return;
62
+ }
63
+ const lines = ["Backlog:\n"];
64
+ for (const item of items) {
65
+ const status = item.done ? "✓" : "○";
66
+ const note = item.note ? ` (${item.note})` : "";
67
+ lines.push(` ${status} ${item.id} — ${item.title}${note}`);
68
+ }
69
+ const pending = items.filter((i) => !i.done).length;
70
+ lines.push(`\n${pending} pending, ${items.length - pending} promoted/done`);
71
+ ctx.ui.notify(lines.join("\n"), "info");
72
+ }
73
+ async function addBacklogItem(basePath, title, ctx) {
74
+ if (!title) {
75
+ ctx.ui.notify("Usage: /gsd backlog add <title>", "warning");
76
+ return;
77
+ }
78
+ const items = parseBacklog(basePath);
79
+ const id = nextBacklogId(items);
80
+ const date = new Date().toISOString().slice(0, 10);
81
+ items.push({ id, title: title.replace(/^['"]|['"]$/g, ""), done: false, note: `added ${date}` });
82
+ writeBacklog(basePath, items);
83
+ ctx.ui.notify(`Added ${id}: "${title}"`, "success");
84
+ }
85
+ async function promoteBacklogItem(basePath, itemId, ctx, pi) {
86
+ if (!itemId) {
87
+ ctx.ui.notify("Usage: /gsd backlog promote <id>\nExample: /gsd backlog promote 999.1", "warning");
88
+ return;
89
+ }
90
+ const items = parseBacklog(basePath);
91
+ const item = items.find((i) => i.id === itemId);
92
+ if (!item) {
93
+ ctx.ui.notify(`Backlog item ${itemId} not found.`, "warning");
94
+ return;
95
+ }
96
+ if (item.done) {
97
+ ctx.ui.notify(`${itemId} is already promoted/done.`, "info");
98
+ return;
99
+ }
100
+ // Promote — currently requires single-writer engine (not yet available)
101
+ // Mark as promoted in backlog for now; slice creation will be available with the engine.
102
+ item.done = true;
103
+ item.note = `promoted ${new Date().toISOString().slice(0, 10)}`;
104
+ writeBacklog(basePath, items);
105
+ ctx.ui.notify(`Promoted ${itemId}: "${item.title}" — add it to the roadmap manually or wait for engine slice commands.`, "info");
106
+ }
107
+ async function removeBacklogItem(basePath, itemId, ctx) {
108
+ if (!itemId) {
109
+ ctx.ui.notify("Usage: /gsd backlog remove <id>", "warning");
110
+ return;
111
+ }
112
+ const items = parseBacklog(basePath);
113
+ const idx = items.findIndex((i) => i.id === itemId);
114
+ if (idx === -1) {
115
+ ctx.ui.notify(`Backlog item ${itemId} not found.`, "warning");
116
+ return;
117
+ }
118
+ const removed = items.splice(idx, 1)[0];
119
+ writeBacklog(basePath, items);
120
+ ctx.ui.notify(`Removed ${removed.id}: "${removed.title}"`, "success");
121
+ }
122
+ export async function handleBacklog(args, ctx, pi) {
123
+ const basePath = process.cwd();
124
+ const parts = args.trim().split(/\s+/);
125
+ const sub = parts[0] ?? "";
126
+ const rest = parts.slice(1).join(" ");
127
+ switch (sub) {
128
+ case "":
129
+ return listBacklog(basePath, ctx);
130
+ case "add":
131
+ return addBacklogItem(basePath, rest, ctx);
132
+ case "promote":
133
+ return promoteBacklogItem(basePath, rest.trim(), ctx, pi);
134
+ case "remove":
135
+ return removeBacklogItem(basePath, rest.trim(), ctx);
136
+ default:
137
+ // Treat as implicit add
138
+ return addBacklogItem(basePath, args, ctx);
139
+ }
140
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * GSD Command — /gsd do
3
+ *
4
+ * Routes freeform natural language to the correct /gsd subcommand
5
+ * using keyword matching. Falls back to /gsd quick for task-like input.
6
+ */
7
+ const ROUTES = [
8
+ { keywords: ["progress", "status", "dashboard", "how far", "where are we"], command: "status" },
9
+ { keywords: ["auto", "autonomous", "run all", "keep going", "start auto"], command: "auto" },
10
+ { keywords: ["stop", "halt", "abort"], command: "stop" },
11
+ { keywords: ["pause", "break", "take a break"], command: "pause" },
12
+ { keywords: ["history", "past", "what happened", "previous"], command: "history" },
13
+ { keywords: ["doctor", "health", "diagnose", "check health"], command: "doctor" },
14
+ { keywords: ["clean up", "cleanup", "remove old", "prune", "tidy"], command: "cleanup" },
15
+ { keywords: ["export", "report", "share results"], command: "export" },
16
+ { keywords: ["ship", "pull request", "create pr", "open pr", "merge"], command: "ship" },
17
+ { keywords: ["discuss", "talk about", "architecture", "design"], command: "discuss" },
18
+ { keywords: ["undo", "revert", "rollback", "take back"], command: "undo" },
19
+ { keywords: ["skip", "skip task", "skip this"], command: "skip" },
20
+ { keywords: ["queue", "reorder", "milestone order", "order milestones"], command: "queue" },
21
+ { keywords: ["visualize", "viz", "graph", "chart", "show graph"], command: "visualize" },
22
+ { keywords: ["capture", "note", "idea", "thought", "remember"], command: "capture" },
23
+ { keywords: ["inspect", "database", "sqlite", "db state"], command: "inspect" },
24
+ { keywords: ["knowledge", "rule", "pattern", "lesson"], command: "knowledge" },
25
+ { keywords: ["session report", "session summary", "cost summary", "how much"], command: "session-report" },
26
+ { keywords: ["backlog", "parking lot", "later", "someday"], command: "backlog" },
27
+ { keywords: ["pr branch", "clean branch", "filter commits"], command: "pr-branch" },
28
+ { keywords: ["add tests", "write tests", "generate tests", "test coverage"], command: "add-tests" },
29
+ { keywords: ["next", "step", "next step", "what's next"], command: "next" },
30
+ { keywords: ["migrate", "migration", "convert", "upgrade"], command: "migrate" },
31
+ { keywords: ["steer", "change direction", "pivot", "redirect"], command: "steer" },
32
+ { keywords: ["park", "shelve", "set aside"], command: "park" },
33
+ { keywords: ["widget", "toggle widget"], command: "widget" },
34
+ { keywords: ["logs", "debug logs", "log files"], command: "logs" },
35
+ ];
36
+ function matchRoute(input) {
37
+ const lower = input.toLowerCase();
38
+ let bestMatch = null;
39
+ for (const route of ROUTES) {
40
+ for (const keyword of route.keywords) {
41
+ if (lower.includes(keyword)) {
42
+ const score = keyword.length; // Longer match = higher confidence
43
+ if (!bestMatch || score > bestMatch.score) {
44
+ // Strip the matched keyword from input to get remaining args
45
+ const idx = lower.indexOf(keyword);
46
+ const remaining = (input.slice(0, idx) + input.slice(idx + keyword.length)).trim();
47
+ bestMatch = { command: route.command, remainingArgs: remaining, score };
48
+ }
49
+ }
50
+ }
51
+ }
52
+ return bestMatch;
53
+ }
54
+ export async function handleDo(args, ctx, pi) {
55
+ if (!args.trim()) {
56
+ ctx.ui.notify("Usage: /gsd do <what you want to do>\n\n" +
57
+ "Examples:\n" +
58
+ " /gsd do show me progress\n" +
59
+ " /gsd do run autonomously\n" +
60
+ " /gsd do clean up old branches\n" +
61
+ " /gsd do fix the login bug", "warning");
62
+ return;
63
+ }
64
+ const match = matchRoute(args);
65
+ if (match) {
66
+ const fullCommand = match.remainingArgs
67
+ ? `${match.command} ${match.remainingArgs}`
68
+ : match.command;
69
+ ctx.ui.notify(`→ /gsd ${fullCommand}`, "info");
70
+ // Re-dispatch through the main dispatcher
71
+ const { handleGSDCommand } = await import("./commands/dispatcher.js");
72
+ await handleGSDCommand(fullCommand, ctx, pi);
73
+ return;
74
+ }
75
+ // No keyword match → treat as quick task
76
+ ctx.ui.notify(`→ /gsd quick ${args}`, "info");
77
+ const { handleQuick } = await import("./quick.js");
78
+ await handleQuick(args, ctx, pi);
79
+ }
@@ -449,7 +449,7 @@ export async function handleCleanupProjects(args, ctx) {
449
449
  * Prints counts of recovered items and the resulting project phase.
450
450
  */
451
451
  export async function handleRecover(ctx, basePath) {
452
- const { isDbAvailable: dbAvailable, _getAdapter, transaction: dbTransaction } = await import("./gsd-db.js");
452
+ const { isDbAvailable: dbAvailable, clearEngineHierarchy, transaction: dbTransaction } = await import("./gsd-db.js");
453
453
  const { migrateHierarchyToDb } = await import("./md-importer.js");
454
454
  const { invalidateStateCache } = await import("./state.js");
455
455
  if (!dbAvailable()) {
@@ -457,12 +457,12 @@ export async function handleRecover(ctx, basePath) {
457
457
  return;
458
458
  }
459
459
  try {
460
- // 1. Delete + re-populate inside a single transaction for atomicity
461
- const db = _getAdapter();
460
+ // 1. Delete + re-populate inside a single transaction for atomicity.
461
+ // clearEngineHierarchy() uses transaction() internally but transaction()
462
+ // is re-entrant, so wrapping in dbTransaction() keeps the whole
463
+ // clear+repopulate atomic.
462
464
  const counts = dbTransaction(() => {
463
- db.exec("DELETE FROM tasks");
464
- db.exec("DELETE FROM slices");
465
- db.exec("DELETE FROM milestones");
465
+ clearEngineHierarchy();
466
466
  return migrateHierarchyToDb(basePath);
467
467
  });
468
468
  // 3. Invalidate state cache so deriveState() picks up fresh DB data