@opengsd/gsd-pi 1.3.0-dev.65546769 → 1.3.0-dev.738160b9

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 (488) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +17 -4
  3. package/dist/headless-answers.js +1 -1
  4. package/dist/headless-ui.d.ts +1 -1
  5. package/dist/headless-ui.js +1 -1
  6. package/dist/headless.js +1 -1
  7. package/dist/resources/.managed-resources-content-hash +1 -1
  8. package/dist/resources/extensions/claude-code-cli/models.js +9 -0
  9. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +11 -2
  10. package/dist/resources/extensions/google-cli/stream-adapter.js +82 -15
  11. package/dist/resources/extensions/gsd/artifact-verification.js +427 -0
  12. package/dist/resources/extensions/gsd/auto/orchestrator.js +12 -3
  13. package/dist/resources/extensions/gsd/auto/session.js +11 -0
  14. package/dist/resources/extensions/gsd/auto/verification-retry-policy.js +1 -1
  15. package/dist/resources/extensions/gsd/auto-artifact-paths.js +28 -1
  16. package/dist/resources/extensions/gsd/auto-budget.js +5 -1
  17. package/dist/resources/extensions/gsd/auto-dispatch.js +34 -20
  18. package/dist/resources/extensions/gsd/auto-post-unit.js +1 -1
  19. package/dist/resources/extensions/gsd/auto-prompts.js +29 -14
  20. package/dist/resources/extensions/gsd/auto-recovery.js +9 -510
  21. package/dist/resources/extensions/gsd/auto-runtime-state.js +4 -5
  22. package/dist/resources/extensions/gsd/auto-timeout-recovery.js +3 -3
  23. package/dist/resources/extensions/gsd/auto-verification.js +5 -2
  24. package/dist/resources/extensions/gsd/auto.js +19 -10
  25. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +103 -13
  26. package/dist/resources/extensions/gsd/bootstrap/core-session-tools.js +39 -0
  27. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +11 -5
  28. package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +2 -0
  29. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +2 -0
  30. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +41 -21
  31. package/dist/resources/extensions/gsd/bootstrap/system-context.js +46 -19
  32. package/dist/resources/extensions/gsd/bootstrap/tool-call-loop-guard.js +96 -10
  33. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +1 -1
  34. package/dist/resources/extensions/gsd/closeout-consistency-gate.js +3 -1
  35. package/dist/resources/extensions/gsd/commands/handlers/auto.js +1 -1
  36. package/dist/resources/extensions/gsd/commands-context.js +19 -1
  37. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +17 -11
  38. package/dist/resources/extensions/gsd/commands-usage.js +1 -1
  39. package/dist/resources/extensions/gsd/commands-worktree.js +12 -10
  40. package/dist/resources/extensions/gsd/dashboard-overlay.js +32 -3
  41. package/dist/resources/extensions/gsd/db/engine.js +4 -1
  42. package/dist/resources/extensions/gsd/db/queries.js +60 -0
  43. package/dist/resources/extensions/gsd/db-memory-fts-schema.js +34 -0
  44. package/dist/resources/extensions/gsd/db-workspace.js +55 -3
  45. package/dist/resources/extensions/gsd/delegation-policy.js +1 -1
  46. package/dist/resources/extensions/gsd/docs/preferences-reference.md +2 -2
  47. package/dist/resources/extensions/gsd/doctor-engine-checks.js +192 -4
  48. package/dist/resources/extensions/gsd/doctor-providers.js +92 -8
  49. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +3 -0
  50. package/dist/resources/extensions/gsd/exec-sandbox.js +53 -11
  51. package/dist/resources/extensions/gsd/flat-phase-migration.js +45 -0
  52. package/dist/resources/extensions/gsd/forensics.js +2 -32
  53. package/dist/resources/extensions/gsd/git-service.js +61 -4
  54. package/dist/resources/extensions/gsd/gitignore.js +4 -1
  55. package/dist/resources/extensions/gsd/guided-flow-queue.js +66 -5
  56. package/dist/resources/extensions/gsd/health-widget.js +55 -29
  57. package/dist/resources/extensions/gsd/json-persistence.js +20 -0
  58. package/dist/resources/extensions/gsd/knowledge-backfill.js +18 -11
  59. package/dist/resources/extensions/gsd/layout-policy.js +3 -1
  60. package/dist/resources/extensions/gsd/markdown-renderer.js +8 -9
  61. package/dist/resources/extensions/gsd/memory-backfill.js +28 -21
  62. package/dist/resources/extensions/gsd/memory-consolidation-scanner.js +44 -21
  63. package/dist/resources/extensions/gsd/metrics.js +4 -4
  64. package/dist/resources/extensions/gsd/migrate-external.js +11 -2
  65. package/dist/resources/extensions/gsd/migration-auto-check.js +22 -0
  66. package/dist/resources/extensions/gsd/milestone-ids.js +32 -2
  67. package/dist/resources/extensions/gsd/milestone-implementation-evidence.js +26 -20
  68. package/dist/resources/extensions/gsd/orphan-stash-audit.js +92 -16
  69. package/dist/resources/extensions/gsd/prompts/code-review.md +6 -4
  70. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +2 -2
  71. package/dist/resources/extensions/gsd/prompts/plan-slice.md +3 -3
  72. package/dist/resources/extensions/gsd/quick.js +45 -2
  73. package/dist/resources/extensions/gsd/root-write-leak-guard.js +7 -1
  74. package/dist/resources/extensions/gsd/safety/destructive-guard.js +8 -1
  75. package/dist/resources/extensions/gsd/safety/evidence-collector.js +16 -1
  76. package/dist/resources/extensions/gsd/safety/file-change-validator.js +5 -2
  77. package/dist/resources/extensions/gsd/session-forensics.js +11 -1
  78. package/dist/resources/extensions/gsd/skills/gsd-headless/references/commands.md +1 -1
  79. package/dist/resources/extensions/gsd/state/derive/cache.js +28 -0
  80. package/dist/resources/extensions/gsd/state/derive/db-open.js +39 -0
  81. package/dist/resources/extensions/gsd/state/derive/from-db.js +452 -0
  82. package/dist/resources/extensions/gsd/state/derive/index.js +75 -0
  83. package/dist/resources/extensions/gsd/state/derive/interrupted-work.js +21 -0
  84. package/dist/resources/extensions/gsd/state-reconciliation/drift/stale-render.js +45 -2
  85. package/dist/resources/extensions/gsd/state-reconciliation/index.js +48 -23
  86. package/dist/resources/extensions/gsd/state-reconciliation/registry.js +32 -28
  87. package/dist/resources/extensions/gsd/state.js +12 -611
  88. package/dist/resources/extensions/gsd/tools/complete-milestone.js +4 -2
  89. package/dist/resources/extensions/gsd/tools/complete-slice.js +2 -2
  90. package/dist/resources/extensions/gsd/tools/complete-task.js +43 -14
  91. package/dist/resources/extensions/gsd/tools/exec-tool.js +7 -2
  92. package/dist/resources/extensions/gsd/tools/plan-slice.js +59 -44
  93. package/dist/resources/extensions/gsd/tools/plan-task.js +28 -5
  94. package/dist/resources/extensions/gsd/undo.js +43 -6
  95. package/dist/resources/extensions/gsd/unit-context-composer.js +23 -7
  96. package/dist/resources/extensions/gsd/unit-registry.js +36 -6
  97. package/dist/resources/extensions/gsd/unmerged-milestone-guard.js +33 -3
  98. package/dist/resources/extensions/gsd/validation-block-guard.js +9 -4
  99. package/dist/resources/extensions/gsd/verification-gate.js +7 -0
  100. package/dist/resources/extensions/gsd/workflow-manifest.js +126 -13
  101. package/dist/resources/extensions/gsd/workflow-projections.js +19 -14
  102. package/dist/resources/extensions/gsd/workspace-git-preflight.js +30 -1
  103. package/dist/resources/extensions/gsd/worktree-manager.js +44 -2
  104. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  105. package/dist/web/standalone/.next/BUILD_ID +1 -1
  106. package/dist/web/standalone/.next/app-path-routes-manifest.json +10 -10
  107. package/dist/web/standalone/.next/build-manifest.json +3 -3
  108. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  109. package/dist/web/standalone/.next/react-loadable-manifest.json +9 -9
  110. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  111. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  112. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  113. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  114. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  115. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  116. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  117. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  118. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  119. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  120. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  121. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  122. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  123. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  124. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  125. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  126. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  127. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  128. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  129. package/dist/web/standalone/.next/server/app/index.html +1 -1
  130. package/dist/web/standalone/.next/server/app/index.rsc +2 -2
  131. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  132. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  133. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  134. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  135. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  136. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  137. package/dist/web/standalone/.next/server/app-paths-manifest.json +10 -10
  138. package/dist/web/standalone/.next/server/chunks/8357.js +1 -1
  139. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  140. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  141. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  142. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  143. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  144. package/dist/web/standalone/.next/static/chunks/{2659.b7b129ee6a769448.js → 2659.58e950899a9bb82f.js} +1 -1
  145. package/dist/web/standalone/.next/static/chunks/2772.a7c1fcc69a4685ef.js +1 -0
  146. package/dist/web/standalone/.next/static/chunks/{3616.3c60753b8ffcbd2e.js → 3616.61a2af74bb8833c8.js} +1 -1
  147. package/dist/web/standalone/.next/static/chunks/{4283.8e446784528ed9dc.js → 4283.d0d9e0a955e441cb.js} +1 -1
  148. package/dist/web/standalone/.next/static/chunks/{5826.a46ecdd1cfe8dabc.js → 5826.5421d66c72b9f34e.js} +1 -1
  149. package/dist/web/standalone/.next/static/chunks/{8785.481aa5869991b760.js → 8785.e29b3134cab1d153.js} +1 -1
  150. package/dist/web/standalone/.next/static/chunks/8937.640dc9c2aaa1dfad.js +10 -0
  151. package/dist/web/standalone/.next/static/chunks/app/{page-6644fc6ee8ca1247.js → page-72a856634ad14c10.js} +1 -1
  152. package/dist/web/standalone/.next/static/chunks/webpack-9c401904f87ded16.js +1 -0
  153. package/dist/web/standalone/node_modules/node-pty/build/Makefile +1 -1
  154. package/package.json +1 -1
  155. package/packages/cloud-mcp-gateway/package.json +2 -2
  156. package/packages/contracts/dist/workflow.d.ts +1 -0
  157. package/packages/contracts/dist/workflow.d.ts.map +1 -1
  158. package/packages/contracts/dist/workflow.js +2 -0
  159. package/packages/contracts/dist/workflow.js.map +1 -1
  160. package/packages/contracts/package.json +1 -1
  161. package/packages/daemon/package.json +4 -4
  162. package/packages/gsd-agent-core/dist/agent-session.d.ts +1 -0
  163. package/packages/gsd-agent-core/dist/agent-session.d.ts.map +1 -1
  164. package/packages/gsd-agent-core/dist/agent-session.js +3 -0
  165. package/packages/gsd-agent-core/dist/agent-session.js.map +1 -1
  166. package/packages/gsd-agent-core/dist/extension-ui-snapshot.d.ts +41 -0
  167. package/packages/gsd-agent-core/dist/extension-ui-snapshot.d.ts.map +1 -0
  168. package/packages/gsd-agent-core/dist/extension-ui-snapshot.js +62 -0
  169. package/packages/gsd-agent-core/dist/extension-ui-snapshot.js.map +1 -0
  170. package/packages/gsd-agent-core/dist/index.d.ts +2 -0
  171. package/packages/gsd-agent-core/dist/index.d.ts.map +1 -1
  172. package/packages/gsd-agent-core/dist/index.js +2 -0
  173. package/packages/gsd-agent-core/dist/index.js.map +1 -1
  174. package/packages/gsd-agent-core/dist/session/agent-session-events.js +1 -1
  175. package/packages/gsd-agent-core/dist/session/agent-session-events.js.map +1 -1
  176. package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts +1 -0
  177. package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts.map +1 -1
  178. package/packages/gsd-agent-core/dist/session/agent-session-host.js.map +1 -1
  179. package/packages/gsd-agent-core/dist/session/agent-session-prompt.d.ts +5 -0
  180. package/packages/gsd-agent-core/dist/session/agent-session-prompt.d.ts.map +1 -1
  181. package/packages/gsd-agent-core/dist/session/agent-session-prompt.js +60 -3
  182. package/packages/gsd-agent-core/dist/session/agent-session-prompt.js.map +1 -1
  183. package/packages/gsd-agent-core/dist/transcript-store.d.ts +58 -0
  184. package/packages/gsd-agent-core/dist/transcript-store.d.ts.map +1 -0
  185. package/packages/gsd-agent-core/dist/transcript-store.js +132 -0
  186. package/packages/gsd-agent-core/dist/transcript-store.js.map +1 -0
  187. package/packages/gsd-agent-core/package.json +5 -5
  188. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  189. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  190. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +25 -11
  191. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
  192. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.d.ts +4 -0
  193. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.d.ts.map +1 -0
  194. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.js +7 -0
  195. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller-latency.js.map +1 -0
  196. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts +3 -24
  197. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  198. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js +26 -829
  199. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  200. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.d.ts +58 -0
  201. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.d.ts.map +1 -0
  202. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.js +312 -0
  203. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-handoff-filter.js.map +1 -0
  204. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.d.ts +31 -0
  205. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.d.ts.map +1 -0
  206. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.js +130 -0
  207. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-pinned-zone.js.map +1 -0
  208. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.d.ts +15 -0
  209. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.d.ts.map +1 -0
  210. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.js +258 -0
  211. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-segment-walker.js.map +1 -0
  212. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.d.ts +13 -0
  213. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.d.ts.map +1 -0
  214. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.js +118 -0
  215. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-tool-rollup.js.map +1 -0
  216. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.d.ts +9 -0
  217. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
  218. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.js +1 -1
  219. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-state.js.map +1 -1
  220. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.d.ts +54 -0
  221. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.d.ts.map +1 -0
  222. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.js +20 -0
  223. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-ui-state.js.map +1 -0
  224. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts +4 -1
  225. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  226. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js +9 -0
  227. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js.map +1 -1
  228. package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.d.ts +56 -0
  229. package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.d.ts.map +1 -0
  230. package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.js +44 -0
  231. package/packages/gsd-agent-modes/dist/modes/interactive/streaming-render-state.js.map +1 -0
  232. package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.d.ts +5 -0
  233. package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.d.ts.map +1 -0
  234. package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.js +77 -0
  235. package/packages/gsd-agent-modes/dist/modes/interactive/tui-transcript-tracker.js.map +1 -0
  236. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-client.d.ts +2 -0
  237. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  238. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-client.js +23 -5
  239. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-client.js.map +1 -1
  240. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  241. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js +18 -0
  242. package/packages/gsd-agent-modes/dist/modes/rpc/rpc-mode.js.map +1 -1
  243. package/packages/gsd-agent-modes/package.json +7 -7
  244. package/packages/mcp-server/README.md +1 -1
  245. package/packages/mcp-server/dist/server.d.ts +1 -1
  246. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  247. package/packages/mcp-server/dist/server.js +3 -3
  248. package/packages/mcp-server/dist/server.js.map +1 -1
  249. package/packages/mcp-server/dist/workflow-tools.d.ts +13 -1
  250. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  251. package/packages/mcp-server/dist/workflow-tools.js +35 -21
  252. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  253. package/packages/mcp-server/package.json +4 -4
  254. package/packages/native/package.json +1 -1
  255. package/packages/pi-agent-core/dist/agent-loop.js +3 -2
  256. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  257. package/packages/pi-agent-core/package.json +1 -1
  258. package/packages/pi-ai/dist/models.generated.d.ts +46 -0
  259. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  260. package/packages/pi-ai/dist/models.generated.js +38 -0
  261. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  262. package/packages/pi-ai/package.json +1 -1
  263. package/packages/pi-coding-agent/README.md +3 -2
  264. package/packages/pi-coding-agent/dist/core/session-manager-context.d.ts +9 -0
  265. package/packages/pi-coding-agent/dist/core/session-manager-context.d.ts.map +1 -0
  266. package/packages/pi-coding-agent/dist/core/session-manager-context.js +94 -0
  267. package/packages/pi-coding-agent/dist/core/session-manager-context.js.map +1 -0
  268. package/packages/pi-coding-agent/dist/core/session-manager-list.d.ts +8 -0
  269. package/packages/pi-coding-agent/dist/core/session-manager-list.d.ts.map +1 -0
  270. package/packages/pi-coding-agent/dist/core/session-manager-list.js +244 -0
  271. package/packages/pi-coding-agent/dist/core/session-manager-list.js.map +1 -0
  272. package/packages/pi-coding-agent/dist/core/session-manager-migration.d.ts +12 -0
  273. package/packages/pi-coding-agent/dist/core/session-manager-migration.d.ts.map +1 -0
  274. package/packages/pi-coding-agent/dist/core/session-manager-migration.js +84 -0
  275. package/packages/pi-coding-agent/dist/core/session-manager-migration.js.map +1 -0
  276. package/packages/pi-coding-agent/dist/core/session-manager-types.d.ts +135 -0
  277. package/packages/pi-coding-agent/dist/core/session-manager-types.d.ts.map +1 -0
  278. package/packages/pi-coding-agent/dist/core/session-manager-types.js +2 -0
  279. package/packages/pi-coding-agent/dist/core/session-manager-types.js.map +1 -0
  280. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +6 -154
  281. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  282. package/packages/pi-coding-agent/dist/core/session-manager.js +22 -459
  283. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  284. package/packages/pi-coding-agent/dist/theme/theme-schema.d.ts +75 -75
  285. package/packages/pi-coding-agent/dist/theme/theme-schema.d.ts.map +1 -1
  286. package/packages/pi-coding-agent/dist/theme/theme-schema.js +1 -1
  287. package/packages/pi-coding-agent/dist/theme/theme-schema.js.map +1 -1
  288. package/packages/pi-coding-agent/dist/theme/theme.d.ts.map +1 -1
  289. package/packages/pi-coding-agent/dist/theme/theme.js +11 -7
  290. package/packages/pi-coding-agent/dist/theme/theme.js.map +1 -1
  291. package/packages/pi-coding-agent/package.json +7 -7
  292. package/packages/pi-tui/package.json +2 -2
  293. package/packages/rpc-client/package.json +2 -2
  294. package/pkg/dist/theme/theme-schema.d.ts +75 -75
  295. package/pkg/dist/theme/theme-schema.d.ts.map +1 -1
  296. package/pkg/dist/theme/theme-schema.js +1 -1
  297. package/pkg/dist/theme/theme-schema.js.map +1 -1
  298. package/pkg/dist/theme/theme.d.ts.map +1 -1
  299. package/pkg/dist/theme/theme.js +11 -7
  300. package/pkg/dist/theme/theme.js.map +1 -1
  301. package/pkg/package.json +1 -1
  302. package/src/resources/extensions/claude-code-cli/models.ts +9 -0
  303. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +20 -2
  304. package/src/resources/extensions/claude-code-cli/tests/index.test.ts +14 -0
  305. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +80 -0
  306. package/src/resources/extensions/google-cli/stream-adapter.ts +106 -19
  307. package/src/resources/extensions/gsd/artifact-verification.ts +464 -0
  308. package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -0
  309. package/src/resources/extensions/gsd/auto/orchestrator.ts +25 -11
  310. package/src/resources/extensions/gsd/auto/session.ts +14 -0
  311. package/src/resources/extensions/gsd/auto/verification-retry-policy.ts +3 -1
  312. package/src/resources/extensions/gsd/auto-artifact-paths.ts +47 -1
  313. package/src/resources/extensions/gsd/auto-budget.ts +12 -1
  314. package/src/resources/extensions/gsd/auto-dispatch.ts +35 -24
  315. package/src/resources/extensions/gsd/auto-post-unit.ts +1 -1
  316. package/src/resources/extensions/gsd/auto-prompts.ts +41 -15
  317. package/src/resources/extensions/gsd/auto-recovery.ts +13 -511
  318. package/src/resources/extensions/gsd/auto-runtime-state.ts +4 -5
  319. package/src/resources/extensions/gsd/auto-timeout-recovery.ts +3 -2
  320. package/src/resources/extensions/gsd/auto-verification.ts +5 -1
  321. package/src/resources/extensions/gsd/auto.ts +23 -8
  322. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +125 -12
  323. package/src/resources/extensions/gsd/bootstrap/core-session-tools.ts +44 -0
  324. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +11 -5
  325. package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +2 -0
  326. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +2 -0
  327. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +52 -21
  328. package/src/resources/extensions/gsd/bootstrap/system-context.ts +52 -18
  329. package/src/resources/extensions/gsd/bootstrap/tool-call-loop-guard.ts +104 -10
  330. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +1 -1
  331. package/src/resources/extensions/gsd/closeout-consistency-gate.ts +2 -1
  332. package/src/resources/extensions/gsd/commands/handlers/auto.ts +1 -1
  333. package/src/resources/extensions/gsd/commands-context.ts +18 -1
  334. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +15 -10
  335. package/src/resources/extensions/gsd/commands-usage.ts +1 -1
  336. package/src/resources/extensions/gsd/commands-worktree.ts +12 -10
  337. package/src/resources/extensions/gsd/dashboard-overlay.ts +32 -3
  338. package/src/resources/extensions/gsd/db/engine.ts +8 -1
  339. package/src/resources/extensions/gsd/db/queries.ts +79 -0
  340. package/src/resources/extensions/gsd/db-memory-fts-schema.ts +45 -0
  341. package/src/resources/extensions/gsd/db-workspace.ts +61 -3
  342. package/src/resources/extensions/gsd/delegation-policy.ts +1 -1
  343. package/src/resources/extensions/gsd/docs/preferences-reference.md +2 -2
  344. package/src/resources/extensions/gsd/doctor-engine-checks.ts +233 -5
  345. package/src/resources/extensions/gsd/doctor-providers.ts +103 -9
  346. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +3 -0
  347. package/src/resources/extensions/gsd/doctor-types.ts +3 -0
  348. package/src/resources/extensions/gsd/exec-sandbox.ts +56 -11
  349. package/src/resources/extensions/gsd/flat-phase-migration.ts +44 -0
  350. package/src/resources/extensions/gsd/forensics.ts +2 -33
  351. package/src/resources/extensions/gsd/git-service.ts +69 -5
  352. package/src/resources/extensions/gsd/gitignore.ts +4 -1
  353. package/src/resources/extensions/gsd/guided-flow-queue.ts +89 -4
  354. package/src/resources/extensions/gsd/health-widget.ts +69 -32
  355. package/src/resources/extensions/gsd/json-persistence.ts +20 -0
  356. package/src/resources/extensions/gsd/knowledge-backfill.ts +16 -10
  357. package/src/resources/extensions/gsd/layout-policy.ts +2 -1
  358. package/src/resources/extensions/gsd/markdown-renderer.ts +8 -11
  359. package/src/resources/extensions/gsd/memory-backfill.ts +26 -20
  360. package/src/resources/extensions/gsd/memory-consolidation-scanner.ts +51 -19
  361. package/src/resources/extensions/gsd/metrics.ts +4 -4
  362. package/src/resources/extensions/gsd/migrate-external.ts +8 -2
  363. package/src/resources/extensions/gsd/migration-auto-check.ts +23 -0
  364. package/src/resources/extensions/gsd/milestone-ids.ts +31 -2
  365. package/src/resources/extensions/gsd/milestone-implementation-evidence.ts +35 -21
  366. package/src/resources/extensions/gsd/orphan-stash-audit.ts +108 -20
  367. package/src/resources/extensions/gsd/prompts/code-review.md +6 -4
  368. package/src/resources/extensions/gsd/prompts/plan-milestone.md +2 -2
  369. package/src/resources/extensions/gsd/prompts/plan-slice.md +3 -3
  370. package/src/resources/extensions/gsd/quick.ts +43 -2
  371. package/src/resources/extensions/gsd/root-write-leak-guard.ts +13 -1
  372. package/src/resources/extensions/gsd/safety/destructive-guard.ts +9 -1
  373. package/src/resources/extensions/gsd/safety/evidence-collector.ts +16 -1
  374. package/src/resources/extensions/gsd/safety/file-change-validator.ts +8 -2
  375. package/src/resources/extensions/gsd/session-forensics.ts +11 -1
  376. package/src/resources/extensions/gsd/skills/gsd-headless/references/commands.md +1 -1
  377. package/src/resources/extensions/gsd/state/derive/cache.ts +46 -0
  378. package/src/resources/extensions/gsd/state/derive/db-open.ts +45 -0
  379. package/src/resources/extensions/gsd/state/derive/from-db.ts +561 -0
  380. package/src/resources/extensions/gsd/state/derive/index.ts +104 -0
  381. package/src/resources/extensions/gsd/state/derive/interrupted-work.ts +31 -0
  382. package/src/resources/extensions/gsd/state-reconciliation/drift/stale-render.ts +81 -7
  383. package/src/resources/extensions/gsd/state-reconciliation/index.ts +50 -24
  384. package/src/resources/extensions/gsd/state-reconciliation/registry.ts +43 -28
  385. package/src/resources/extensions/gsd/state.ts +32 -732
  386. package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +4 -3
  387. package/src/resources/extensions/gsd/tests/auto-artifact-paths.test.ts +98 -1
  388. package/src/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +14 -5
  389. package/src/resources/extensions/gsd/tests/auto-pause-double-entry-guard.test.ts +36 -0
  390. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +182 -4
  391. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +146 -1
  392. package/src/resources/extensions/gsd/tests/auto-retry-mcp-churn-fixes.test.ts +30 -0
  393. package/src/resources/extensions/gsd/tests/commands-context.test.ts +26 -0
  394. package/src/resources/extensions/gsd/tests/commands-gsd-core.test.ts +1 -0
  395. package/src/resources/extensions/gsd/tests/commands-worktree-clean.test.ts +80 -0
  396. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +28 -0
  397. package/src/resources/extensions/gsd/tests/complete-slice-reopen-handoff.test.ts +69 -0
  398. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +11 -0
  399. package/src/resources/extensions/gsd/tests/complete-task-rollback-evidence.test.ts +48 -8
  400. package/src/resources/extensions/gsd/tests/complete-task.test.ts +75 -0
  401. package/src/resources/extensions/gsd/tests/dashboard-overlay.test.ts +55 -2
  402. package/src/resources/extensions/gsd/tests/db-memory-fts-schema.test.ts +58 -3
  403. package/src/resources/extensions/gsd/tests/decisions-projection-from-memories.test.ts +51 -0
  404. package/src/resources/extensions/gsd/tests/destructive-guard.test.ts +44 -0
  405. package/src/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +143 -0
  406. package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +26 -1
  407. package/src/resources/extensions/gsd/tests/doctor-forensics-db-open-regression.test.ts +70 -2
  408. package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +107 -0
  409. package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +239 -2
  410. package/src/resources/extensions/gsd/tests/exec-graceful-kill.test.ts +38 -0
  411. package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +16 -0
  412. package/src/resources/extensions/gsd/tests/exec-tool.test.ts +45 -1
  413. package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +40 -0
  414. package/src/resources/extensions/gsd/tests/flat-phase-migration.test.ts +37 -2
  415. package/src/resources/extensions/gsd/tests/forensics-error-filter.test.ts +88 -0
  416. package/src/resources/extensions/gsd/tests/gitignore-bg-shell-runtime.test.ts +4 -0
  417. package/src/resources/extensions/gsd/tests/guided-discuss-milestone-prompt-rendering.test.ts +42 -0
  418. package/src/resources/extensions/gsd/tests/health-widget.test.ts +268 -3
  419. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +130 -3
  420. package/src/resources/extensions/gsd/tests/integration/queue-active-milestone-context-budget.test.ts +93 -0
  421. package/src/resources/extensions/gsd/tests/integration/quick-branch-lifecycle.test.ts +56 -9
  422. package/src/resources/extensions/gsd/tests/json-persistence-atomic.test.ts +47 -0
  423. package/src/resources/extensions/gsd/tests/knowledge-backfill-projection.test.ts +35 -0
  424. package/src/resources/extensions/gsd/tests/knowledge-cold-start.test.ts +14 -0
  425. package/src/resources/extensions/gsd/tests/memory-consolidation-scanner.test.ts +78 -0
  426. package/src/resources/extensions/gsd/tests/memory-store.test.ts +48 -0
  427. package/src/resources/extensions/gsd/tests/merge-closeout-consistency-gate.test.ts +31 -1
  428. package/src/resources/extensions/gsd/tests/metrics-prune-cache-invalidation.test.ts +6 -0
  429. package/src/resources/extensions/gsd/tests/metrics.test.ts +1 -0
  430. package/src/resources/extensions/gsd/tests/migrate-external-worktree.test.ts +57 -0
  431. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +70 -0
  432. package/src/resources/extensions/gsd/tests/orchestrator-logs.test.ts +43 -1
  433. package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +91 -7
  434. package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +26 -0
  435. package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +4 -1
  436. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +1 -1
  437. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +10 -0
  438. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +103 -4
  439. package/src/resources/extensions/gsd/tests/plan-task.test.ts +44 -1
  440. package/src/resources/extensions/gsd/tests/post-mutation-hook.test.ts +4 -2
  441. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +54 -1
  442. package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +50 -14
  443. package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +58 -0
  444. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +8 -6
  445. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +195 -1
  446. package/src/resources/extensions/gsd/tests/read-uat-gate-verdict.test.ts +185 -0
  447. package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +87 -0
  448. package/src/resources/extensions/gsd/tests/register-hooks-loop-guard-auto.test.ts +103 -0
  449. package/src/resources/extensions/gsd/tests/root-write-leak-guard.test.ts +20 -1
  450. package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +15 -3
  451. package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +56 -0
  452. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +191 -0
  453. package/src/resources/extensions/gsd/tests/tool-call-loop-guard.test.ts +208 -0
  454. package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +32 -3
  455. package/src/resources/extensions/gsd/tests/undo.test.ts +74 -0
  456. package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +193 -14
  457. package/src/resources/extensions/gsd/tests/unmerged-milestone-guard.test.ts +25 -0
  458. package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +38 -0
  459. package/src/resources/extensions/gsd/tests/validation-block-guard.test.ts +79 -0
  460. package/src/resources/extensions/gsd/tests/verification-retry-policy.test.ts +69 -4
  461. package/src/resources/extensions/gsd/tests/verify-artifact-tightened.test.ts +66 -0
  462. package/src/resources/extensions/gsd/tests/workflow-manifest.test.ts +96 -15
  463. package/src/resources/extensions/gsd/tests/workflow-mcp-preflight.test.ts +1 -0
  464. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +8 -4
  465. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +6 -5
  466. package/src/resources/extensions/gsd/tests/workspace-git-preflight.test.ts +151 -2
  467. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +39 -0
  468. package/src/resources/extensions/gsd/tools/complete-milestone.ts +3 -2
  469. package/src/resources/extensions/gsd/tools/complete-slice.ts +2 -2
  470. package/src/resources/extensions/gsd/tools/complete-task.ts +53 -15
  471. package/src/resources/extensions/gsd/tools/exec-tool.ts +7 -3
  472. package/src/resources/extensions/gsd/tools/plan-slice.ts +60 -47
  473. package/src/resources/extensions/gsd/tools/plan-task.ts +30 -5
  474. package/src/resources/extensions/gsd/undo.ts +47 -6
  475. package/src/resources/extensions/gsd/unit-context-composer.ts +33 -7
  476. package/src/resources/extensions/gsd/unit-registry.ts +36 -6
  477. package/src/resources/extensions/gsd/unmerged-milestone-guard.ts +41 -5
  478. package/src/resources/extensions/gsd/validation-block-guard.ts +13 -7
  479. package/src/resources/extensions/gsd/verification-gate.ts +8 -0
  480. package/src/resources/extensions/gsd/workflow-manifest.ts +141 -7
  481. package/src/resources/extensions/gsd/workflow-projections.ts +20 -14
  482. package/src/resources/extensions/gsd/workspace-git-preflight.ts +31 -0
  483. package/src/resources/extensions/gsd/worktree-manager.ts +41 -1
  484. package/dist/web/standalone/.next/static/chunks/2772.bfa657f49f955239.js +0 -1
  485. package/dist/web/standalone/.next/static/chunks/796.e0bdc932325d7e03.js +0 -10
  486. package/dist/web/standalone/.next/static/chunks/webpack-f46ea08200a0227e.js +0 -1
  487. /package/dist/web/standalone/.next/static/{BTKtGFF1Y-hvVJEGhBRo9 → 2A_WqqCS-EoYZxN9_v3d2}/_buildManifest.js +0 -0
  488. /package/dist/web/standalone/.next/static/{BTKtGFF1Y-hvVJEGhBRo9 → 2A_WqqCS-EoYZxN9_v3d2}/_ssgManifest.js +0 -0
@@ -23,9 +23,10 @@ const DEFAULT_KNOWLEDGE_MAX_CHARS = 12_000;
23
23
  const DEFAULT_CODEBASE_MAX_CHARS = 8_000;
24
24
  const MIN_CONTEXT_MESSAGE_MAX_CHARS = 1_000;
25
25
  const MIN_KNOWLEDGE_MAX_CHARS = 1_000;
26
- const contextMaintenanceCompletedForBasePath = new Set();
27
- const contextMaintenanceInFlightByBasePath = new Map();
28
- const deferredContextMaintenanceByBasePath = new Map();
26
+ const CONTEXT_MAINTENANCE_KEY_SEPARATOR = "\0";
27
+ const contextMaintenanceCompletedForSession = new Set();
28
+ const contextMaintenanceInFlightBySession = new Map();
29
+ const deferredContextMaintenanceBySession = new Map();
29
30
  /**
30
31
  * Bundled skill triggers — resolved dynamically at runtime instead of
31
32
  * hardcoding absolute paths in the system prompt template. Only skills
@@ -100,7 +101,8 @@ function warnDeprecatedAgentInstructions() {
100
101
  }
101
102
  }
102
103
  async function runSessionStartupMaintenanceOnce(basePath, ctx) {
103
- if (contextMaintenanceCompletedForBasePath.has(basePath)) {
104
+ const maintenanceKey = getContextMaintenanceKey(basePath, ctx);
105
+ if (contextMaintenanceCompletedForSession.has(maintenanceKey)) {
104
106
  // Backfills are session-once, but memory queries and other DB-backed
105
107
  // prompt assembly still need an active adapter on every turn.
106
108
  try {
@@ -112,16 +114,16 @@ async function runSessionStartupMaintenanceOnce(basePath, ctx) {
112
114
  }
113
115
  return false;
114
116
  }
115
- const existing = contextMaintenanceInFlightByBasePath.get(basePath);
117
+ const existing = contextMaintenanceInFlightBySession.get(maintenanceKey);
116
118
  const isInitiator = !existing;
117
119
  // Use a definite Promise<boolean> so `await inFlight` has a known return type.
118
120
  let inFlight;
119
121
  if (isInitiator) {
120
- inFlight = performSessionStartupMaintenance(basePath, ctx);
121
- contextMaintenanceInFlightByBasePath.set(basePath, inFlight);
122
+ inFlight = performSessionStartupMaintenance(basePath, ctx, maintenanceKey);
123
+ contextMaintenanceInFlightBySession.set(maintenanceKey, inFlight);
122
124
  void inFlight.finally(() => {
123
- if (contextMaintenanceInFlightByBasePath.get(basePath) === inFlight) {
124
- contextMaintenanceInFlightByBasePath.delete(basePath);
125
+ if (contextMaintenanceInFlightBySession.get(maintenanceKey) === inFlight) {
126
+ contextMaintenanceInFlightBySession.delete(maintenanceKey);
125
127
  }
126
128
  });
127
129
  }
@@ -131,7 +133,7 @@ async function runSessionStartupMaintenanceOnce(basePath, ctx) {
131
133
  const result = await inFlight;
132
134
  return isInitiator ? result : false;
133
135
  }
134
- async function performSessionStartupMaintenance(basePath, ctx) {
136
+ async function performSessionStartupMaintenance(basePath, ctx, maintenanceKey) {
135
137
  // DB-backed memory backfills run below. On a cold session the database file
136
138
  // may exist without an active in-process adapter, so open the canonical
137
139
  // project DB before those best-effort operations inspect it.
@@ -154,10 +156,33 @@ async function performSessionStartupMaintenance(basePath, ctx) {
154
156
  ]);
155
157
  // Mark session complete before scheduling deferred work so any concurrent
156
158
  // caller that observes the completed state does not re-enter maintenance.
157
- contextMaintenanceCompletedForBasePath.add(basePath);
158
- scheduleDeferredContextMaintenance(basePath);
159
+ contextMaintenanceCompletedForSession.add(maintenanceKey);
160
+ scheduleDeferredContextMaintenance(basePath, maintenanceKey);
159
161
  return true;
160
162
  }
163
+ function getContextMaintenanceKey(basePath, ctx) {
164
+ return `${basePath}${CONTEXT_MAINTENANCE_KEY_SEPARATOR}${getContextSessionPart(ctx)}`;
165
+ }
166
+ function getContextSessionPart(ctx) {
167
+ const sessionManager = ctx.sessionManager;
168
+ try {
169
+ const sessionId = sessionManager?.getSessionId?.();
170
+ if (typeof sessionId === "string" && sessionId.length > 0)
171
+ return `id:${sessionId}`;
172
+ }
173
+ catch (e) {
174
+ logWarning("bootstrap", `session-id fetch failed: ${e.message}`);
175
+ }
176
+ try {
177
+ const sessionFile = sessionManager?.getSessionFile?.();
178
+ if (typeof sessionFile === "string" && sessionFile.length > 0)
179
+ return `file:${sessionFile}`;
180
+ }
181
+ catch (e) {
182
+ logWarning("bootstrap", `session-file fetch failed: ${e.message}`);
183
+ }
184
+ return "process";
185
+ }
161
186
  async function runDecisionsMemoryBackfill(ctx) {
162
187
  // ADR-013 step 5: opportunistic decisions->memories backfill. Idempotent
163
188
  // and best-effort — first run absorbs the existing decisions table into
@@ -188,18 +213,18 @@ async function runKnowledgeMemoryBackfill(basePath, ctx) {
188
213
  logWarning("bootstrap", `KNOWLEDGE.md backfill failed: ${e.message}`);
189
214
  }
190
215
  }
191
- function scheduleDeferredContextMaintenance(basePath) {
192
- if (deferredContextMaintenanceByBasePath.has(basePath))
216
+ function scheduleDeferredContextMaintenance(basePath, maintenanceKey) {
217
+ if (deferredContextMaintenanceBySession.has(maintenanceKey))
193
218
  return;
194
219
  const task = new Promise((resolve) => {
195
220
  setTimeout(() => {
196
221
  void runDeferredContextMaintenance(basePath).finally(resolve);
197
222
  }, 0);
198
223
  });
199
- deferredContextMaintenanceByBasePath.set(basePath, task);
224
+ deferredContextMaintenanceBySession.set(maintenanceKey, task);
200
225
  void task.finally(() => {
201
- if (deferredContextMaintenanceByBasePath.get(basePath) === task) {
202
- deferredContextMaintenanceByBasePath.delete(basePath);
226
+ if (deferredContextMaintenanceBySession.get(maintenanceKey) === task) {
227
+ deferredContextMaintenanceBySession.delete(maintenanceKey);
203
228
  }
204
229
  });
205
230
  }
@@ -232,8 +257,10 @@ async function reportConsolidationGapsDeferred(basePath) {
232
257
  }
233
258
  export async function _flushDeferredContextMaintenanceForTest(basePath) {
234
259
  const tasks = basePath
235
- ? [deferredContextMaintenanceByBasePath.get(basePath)].filter((task) => Boolean(task))
236
- : [...deferredContextMaintenanceByBasePath.values()];
260
+ ? [...deferredContextMaintenanceBySession.entries()]
261
+ .filter(([key]) => key.startsWith(`${basePath}${CONTEXT_MAINTENANCE_KEY_SEPARATOR}`))
262
+ .map(([, task]) => task)
263
+ : [...deferredContextMaintenanceBySession.values()];
237
264
  await Promise.allSettled(tasks);
238
265
  }
239
266
  export async function buildBeforeAgentStartResult(event, ctx) {
@@ -1,25 +1,55 @@
1
1
  /**
2
2
  * Tool-call loop guard.
3
3
  *
4
- * Detects when a model calls the same tool with identical arguments
5
- * repeatedly within a single agent turn. Works in both auto-mode and
6
- * interactive sessions by hooking into the `tool_call` event, which
7
- * fires before execution and can block the call.
4
+ * Detects when a model repeats tool calls within a single Agent Turn.
5
+ * Works in both auto-mode and interactive sessions by hooking into the
6
+ * native engine's `tool_call` event, which fires before execution and can
7
+ * block the call.
8
8
  *
9
- * The guard uses a sliding window: it tracks the last N tool signatures
10
- * and blocks when the same signature appears more than MAX_CONSECUTIVE
11
- * times in a row. Resets on each agent turn (session_start, agent_end)
12
- * and when a different tool call breaks the streak.
9
+ * The guard has two independent checks: a sliding window for identical
10
+ * tool signatures, and a per-tool-name cap for repeated calls with varied
11
+ * arguments. State resets at Agent Turn boundaries (session_start,
12
+ * agent_end) and the identical-signature streak also resets when a
13
+ * different tool call breaks the streak. Block messages instruct the model
14
+ * to stop tooling for the rest of that turn and answer in text.
15
+ *
16
+ * The per-tool-name check (#783 Brief C) tracks call counts within a
17
+ * turn regardless of args, decaying after successful state-mutating tools.
18
+ * This catches improvisation
19
+ * loops where the model attempts the same missing workflow tool through
20
+ * varied surfaces (bash → `node -e` → CLI), each with a different
21
+ * signature, so the identical-args streak never trips, while allowing
22
+ * tool-heavy turns that are making file-mutation progress. Whichever guard
23
+ * trips first blocks.
13
24
  */
14
25
  import { createHash } from "node:crypto";
26
+ import { INHERENTLY_REPEATABLE_TOOL_SET } from "./core-session-tools.js";
15
27
  const MAX_CONSECUTIVE_IDENTICAL_CALLS = 4;
16
28
  /** Interactive/user-facing tools where even 1 duplicate is confusing. */
17
29
  const STRICT_LOOP_TOOLS = new Set(["ask_user_questions"]);
18
30
  const MAX_CONSECUTIVE_STRICT = 1;
31
+ /**
32
+ * Per-turn cap on calls to the SAME tool name, regardless of args (#783).
33
+ *
34
+ * General-purpose execution tools are routinely called many times per turn
35
+ * (touching multiple files, running several commands), so they get a higher
36
+ * ceiling. Everything else — workflow one-shot tools (e.g. gsd_complete_milestone)
37
+ * and any non-allowlisted tool — gets the default cap. The default is generous
38
+ * enough to absorb legitimate retries but catches the reported improvisation
39
+ * loop (~51 calls) well before a cost spike.
40
+ */
41
+ const PER_TOOL_DEFAULT_CAP = 6;
42
+ const PER_TOOL_REPEATABLE_CAP = 15;
43
+ const PER_TOOL_CAP_EXEMPT_TOOLS = new Set(["find", "glob", "grep", "ls", "read", "search_and_read"]);
44
+ const STATE_MUTATING_TOOL_SET = new Set(["edit", "write", "multi_edit", "notebook_edit"]);
19
45
  let consecutiveCount = 0;
20
46
  let lastSignature = "";
21
47
  let lastToolName = "";
22
48
  let enabled = true;
49
+ /** Per-tool-name call counts within the current turn (#783 Brief C). */
50
+ const perToolCounts = new Map();
51
+ let mutationEpoch = 0;
52
+ const perToolLastMutationEpoch = new Map();
23
53
  /** Hash tool name + args into a compact signature for comparison. */
24
54
  function hashToolCall(toolName, args) {
25
55
  const h = createHash("sha256");
@@ -38,6 +68,13 @@ function hashToolCall(toolName, args) {
38
68
  *
39
69
  * Returns `{ block: false }` for allowed calls.
40
70
  * Returns `{ block: true, reason }` when the loop threshold is exceeded.
71
+ *
72
+ * Two independent guards run; whichever trips first blocks:
73
+ * 1. Identical-signature streak (MAX_CONSECUTIVE_IDENTICAL_CALLS, strict for
74
+ * ask_user_questions).
75
+ * 2. Per-tool-name cap (PER_TOOL_DEFAULT_CAP / PER_TOOL_REPEATABLE_CAP),
76
+ * independent of args, reset after file-mutation progress — catches
77
+ * improvisation loops (#783).
41
78
  */
42
79
  export function checkToolCallLoop(toolName, args) {
43
80
  if (!enabled)
@@ -51,26 +88,65 @@ export function checkToolCallLoop(toolName, args) {
51
88
  lastSignature = sig;
52
89
  lastToolName = toolName;
53
90
  }
91
+ // ── Guard 1: identical-signature streak ──
54
92
  const threshold = STRICT_LOOP_TOOLS.has(toolName)
55
93
  ? MAX_CONSECUTIVE_STRICT
56
94
  : MAX_CONSECUTIVE_IDENTICAL_CALLS;
57
95
  if (consecutiveCount > threshold) {
58
96
  return {
59
97
  block: true,
60
- reason: `Tool loop detected: ${toolName} called ${consecutiveCount} times ` +
98
+ reason: `Tool loop detected (identical args): ${toolName} called ${consecutiveCount} times ` +
61
99
  `with identical arguments. Blocking to prevent infinite loop. ` +
62
- `Try a different approach or modify your arguments.`,
100
+ `Do not retry this tool or call other tools this turn — stop and respond to the user in text.`,
63
101
  count: consecutiveCount,
64
102
  };
65
103
  }
104
+ // ── Guard 2: per-tool-name cap, independent of args (#783 Brief C) ──
105
+ // Catches improvisation loops where the same tool is invoked many times with
106
+ // varied args (e.g. retrying a missing workflow tool via bash/node -e/CLI).
107
+ const priorPerToolCount = (perToolLastMutationEpoch.get(toolName) ?? mutationEpoch) < mutationEpoch
108
+ ? 0
109
+ : (perToolCounts.get(toolName) ?? 0);
110
+ const perToolCount = priorPerToolCount + 1;
111
+ perToolCounts.set(toolName, perToolCount);
112
+ perToolLastMutationEpoch.set(toolName, mutationEpoch);
113
+ // Read-only navigation tools are normal context gathering; Guard 1 still
114
+ // catches true reread loops with identical arguments.
115
+ if (PER_TOOL_CAP_EXEMPT_TOOLS.has(toolName)) {
116
+ return { block: false, count: consecutiveCount };
117
+ }
118
+ const perToolCap = INHERENTLY_REPEATABLE_TOOL_SET.has(toolName)
119
+ ? PER_TOOL_REPEATABLE_CAP
120
+ : PER_TOOL_DEFAULT_CAP;
121
+ if (perToolCount > perToolCap) {
122
+ return {
123
+ block: true,
124
+ reason: `Tool loop detected (repeated tool): ${toolName} called ${perToolCount} times ` +
125
+ `this turn (cap ${perToolCap}). Blocking to prevent infinite loop. ` +
126
+ `The tool may be unavailable or failing repeatedly. ` +
127
+ `Do not retry this tool or pivot to other tools this turn — stop and respond to the user in text.`,
128
+ count: perToolCount,
129
+ };
130
+ }
66
131
  return { block: false, count: consecutiveCount };
67
132
  }
133
+ /** Record successful mutation progress so Guard 2 can decay on the next count. */
134
+ export function recordToolCallLoopMutation(toolName) {
135
+ if (!enabled)
136
+ return;
137
+ if (!STATE_MUTATING_TOOL_SET.has(toolName))
138
+ return;
139
+ mutationEpoch++;
140
+ }
68
141
  /** Reset the guard state. Call at agent turn boundaries. */
69
142
  export function resetToolCallLoopGuard() {
70
143
  consecutiveCount = 0;
71
144
  lastSignature = "";
72
145
  lastToolName = "";
73
146
  enabled = true;
147
+ perToolCounts.clear();
148
+ mutationEpoch = 0;
149
+ perToolLastMutationEpoch.clear();
74
150
  }
75
151
  /** Disable the guard (e.g. during shutdown). */
76
152
  export function disableToolCallLoopGuard() {
@@ -78,8 +154,18 @@ export function disableToolCallLoopGuard() {
78
154
  consecutiveCount = 0;
79
155
  lastSignature = "";
80
156
  lastToolName = "";
157
+ perToolCounts.clear();
158
+ mutationEpoch = 0;
159
+ perToolLastMutationEpoch.clear();
81
160
  }
82
161
  /** Get current consecutive count for diagnostics. */
83
162
  export function getToolCallLoopCount() {
84
163
  return consecutiveCount;
85
164
  }
165
+ /**
166
+ * Get the per-tool-name call count for the current turn (#783 Brief C).
167
+ * Returns 0 for tools not yet called. Diagnostic only.
168
+ */
169
+ export function getToolCallCountForTool(toolName) {
170
+ return perToolCounts.get(toolName) ?? 0;
171
+ }
@@ -141,7 +141,7 @@ function ensureWriteGateSnapshotDirectory(basePath) {
141
141
  }
142
142
  mkdirSync(join(gsdPath, "runtime"), { recursive: true });
143
143
  }
144
- function currentWriteGateSnapshot(basePath = process.cwd()) {
144
+ export function currentWriteGateSnapshot(basePath = process.cwd()) {
145
145
  const state = getWriteGateState(basePath);
146
146
  return {
147
147
  verifiedDepthMilestones: [...state.verifiedDepthMilestones].sort(),
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
5
  import { getLatestAssessmentByScope, getMilestone, getMilestoneSlices, getPendingGates, getSliceTasks, insertAssessment, isDbAvailable, transaction, } from "./gsd-db.js";
6
6
  import { getWorkflowDatabasePath, refreshWorkflowDatabaseFromDisk, } from "./db-workspace.js";
7
- import { isClosedStatus } from "./status-guards.js";
7
+ import { isClosedStatus, isDeferredStatus } from "./status-guards.js";
8
8
  import { closeQualityGatesFromEvidence } from "./quality-gate-closure.js";
9
9
  import { insertMilestoneValidationGates } from "./milestone-validation-gates.js";
10
10
  import { relMilestoneFile, resolveSliceFile } from "./paths.js";
@@ -144,6 +144,8 @@ export function checkCloseoutConsistencyGate(milestoneId, options = {}) {
144
144
  });
145
145
  }
146
146
  for (const slice of slices) {
147
+ if (isDeferredStatus(slice.status))
148
+ continue;
147
149
  if (!isClosedStatus(slice.status)) {
148
150
  return blocked("slice-open", `Closeout consistency blocked for ${milestoneId}: slice ${slice.id} status is "${slice.status}".`);
149
151
  }
@@ -190,7 +190,7 @@ export async function handleAutoCommand(trimmed, ctx, pi) {
190
190
  }
191
191
  return true;
192
192
  }
193
- await pauseAuto(ctx, pi);
193
+ await pauseAuto(ctx, pi, undefined, { abortActiveTurn: true });
194
194
  return true;
195
195
  }
196
196
  if (trimmed === "rate" || trimmed.startsWith("rate ")) {
@@ -8,6 +8,8 @@ import { formatPercent, formatTokenCount } from "./metrics.js";
8
8
  import { countTokensSync } from "./token-counter.js";
9
9
  import { writeContextChartHtml } from "./context-chart-html.js";
10
10
  import { openInBrowser } from "./export.js";
11
+ import { truncateWithEllipsis } from "../shared/format-utils.js";
12
+ const REDACTED_TOOL_ARGUMENT_KEYS = new Set(["content", "oldText", "newText"]);
11
13
  function resolveProvider(provider) {
12
14
  const normalized = (provider ?? "unknown").toLowerCase();
13
15
  if (normalized === "anthropic" || normalized === "claude-code")
@@ -167,6 +169,22 @@ export function parseSystemPromptSections(systemPrompt, provider) {
167
169
  }
168
170
  return sections;
169
171
  }
172
+ function redactToolCallArguments(value) {
173
+ if (Array.isArray(value))
174
+ return value.map(redactToolCallArguments);
175
+ if (!value || typeof value !== "object")
176
+ return value;
177
+ const safe = {};
178
+ for (const [key, child] of Object.entries(value)) {
179
+ if (REDACTED_TOOL_ARGUMENT_KEYS.has(key)) {
180
+ safe[key] = typeof child === "string" ? truncateWithEllipsis(child, 101) : "[redacted]";
181
+ }
182
+ else {
183
+ safe[key] = redactToolCallArguments(child);
184
+ }
185
+ }
186
+ return safe;
187
+ }
170
188
  function messageToText(message) {
171
189
  const role = message.role;
172
190
  if (role === "assistant") {
@@ -183,7 +201,7 @@ function messageToText(message) {
183
201
  parts.push(typed.thinking);
184
202
  if (typed.type === "toolCall") {
185
203
  parts.push(typed.name ?? "tool");
186
- parts.push(JSON.stringify(typed.arguments ?? {}));
204
+ parts.push(JSON.stringify(redactToolCallArguments(typed.arguments ?? {})));
187
205
  }
188
206
  }
189
207
  }
@@ -1164,7 +1164,7 @@ async function configureContextCodebase(ctx, prefs) {
1164
1164
  cm.observation_mask_turns = maskTurns;
1165
1165
  else if (maskTurns === "clear")
1166
1166
  delete cm.observation_mask_turns;
1167
- const thresh = await promptNumber(ctx, "Compaction threshold percent (0.5–0.95)", cm.compaction_threshold_percent, "0.60");
1167
+ const thresh = await promptNumber(ctx, "Soft context warning threshold percent (0.5–0.95)", cm.compaction_threshold_percent, "0.60");
1168
1168
  if (thresh !== undefined && thresh !== "clear")
1169
1169
  cm.compaction_threshold_percent = thresh;
1170
1170
  else if (thresh === "clear")
@@ -1671,19 +1671,25 @@ export function serializePreferencesToFrontmatter(prefs) {
1671
1671
  const entries = Object.entries(item);
1672
1672
  if (entries.length > 0) {
1673
1673
  const [firstKey, firstVal] = entries[0];
1674
- lines.push(`${prefix} - ${firstKey}: ${yamlSafeString(firstVal)}`);
1675
- for (let i = 1; i < entries.length; i++) {
1676
- const [k, v] = entries[i];
1677
- if (Array.isArray(v)) {
1678
- lines.push(`${prefix} ${k}:`);
1679
- for (const arrItem of v) {
1680
- lines.push(`${prefix} - ${yamlSafeString(arrItem)}`);
1681
- }
1674
+ if (Array.isArray(firstVal)) {
1675
+ lines.push(`${prefix} - ${firstKey}:`);
1676
+ for (const arrItem of firstVal) {
1677
+ lines.push(`${prefix} - ${yamlSafeString(arrItem)}`);
1682
1678
  }
1683
- else {
1684
- lines.push(`${prefix} ${k}: ${yamlSafeString(v)}`);
1679
+ }
1680
+ else if (typeof firstVal === "object" && firstVal !== null) {
1681
+ lines.push(`${prefix} - ${firstKey}:`);
1682
+ for (const [k, v] of Object.entries(firstVal)) {
1683
+ serializeValue(k, v, indent + 3);
1685
1684
  }
1686
1685
  }
1686
+ else {
1687
+ lines.push(`${prefix} - ${firstKey}: ${yamlSafeString(firstVal)}`);
1688
+ }
1689
+ for (let i = 1; i < entries.length; i++) {
1690
+ const [k, v] = entries[i];
1691
+ serializeValue(k, v, indent + 2);
1692
+ }
1687
1693
  }
1688
1694
  }
1689
1695
  else {
@@ -83,7 +83,7 @@ function formatThresholdLines() {
83
83
  }
84
84
  const compactionThreshold = prefs?.context_management?.compaction_threshold_percent;
85
85
  if (typeof compactionThreshold === "number") {
86
- lines.push(`Compaction: ${Math.round(compactionThreshold * 100)}%`);
86
+ lines.push(`Soft context warning: ${Math.round(compactionThreshold * 100)}%`);
87
87
  }
88
88
  return lines;
89
89
  }
@@ -12,9 +12,9 @@ import { inferCommitType } from "./git-service.js";
12
12
  import { autoCommitCurrentBranch } from "./worktree.js";
13
13
  import { GSDError, GSD_GIT_ERROR } from "./errors.js";
14
14
  // ─── Status helper ─────────────────────────────────────────────────────────
15
- function getStatus(basePath, name, wtPath) {
16
- const diff = diffWorktreeAll(basePath, name);
17
- const numstat = diffWorktreeNumstat(basePath, name);
15
+ function getStatus(basePath, name, wtPath, mainBranch) {
16
+ const diff = diffWorktreeAll(basePath, name, undefined, mainBranch);
17
+ const numstat = diffWorktreeNumstat(basePath, name, undefined, mainBranch);
18
18
  const filesChanged = diff.added.length + diff.modified.length + diff.removed.length;
19
19
  let linesAdded = 0;
20
20
  let linesRemoved = 0;
@@ -31,8 +31,7 @@ function getStatus(basePath, name, wtPath) {
31
31
  }
32
32
  let commits = 0;
33
33
  try {
34
- const main = nativeDetectMainBranch(basePath);
35
- commits = nativeCommitCountBetween(basePath, main, worktreeBranchName(name));
34
+ commits = nativeCommitCountBetween(basePath, mainBranch, worktreeBranchName(name));
36
35
  }
37
36
  catch {
38
37
  // commit count unavailable → leave at 0
@@ -88,7 +87,8 @@ export function formatCleanKeepReason(status) {
88
87
  async function handleList(ctx) {
89
88
  const basePath = projectRoot();
90
89
  const worktrees = listWorktrees(basePath);
91
- const statuses = worktrees.map((wt) => getStatus(basePath, wt.name, wt.path));
90
+ const mainBranch = worktrees.length > 0 ? nativeDetectMainBranch(basePath) : "";
91
+ const statuses = worktrees.map((wt) => getStatus(basePath, wt.name, wt.path, mainBranch));
92
92
  ctx.ui.notify(formatWorktreeList(statuses), "info");
93
93
  }
94
94
  // ─── Subcommand: merge ──────────────────────────────────────────────────────
@@ -117,7 +117,8 @@ async function handleMerge(args, ctx) {
117
117
  ctx.ui.notify(`Worktree "${target}" not found.\n\nAvailable: ${available}`, "error");
118
118
  return;
119
119
  }
120
- const status = getStatus(basePath, target, wt.path);
120
+ const mainBranch = nativeDetectMainBranch(basePath);
121
+ const status = getStatus(basePath, target, wt.path, mainBranch);
121
122
  if (status.filesChanged === 0 && !status.uncommitted) {
122
123
  try {
123
124
  removeWorktree(basePath, target, { deleteBranch: true });
@@ -144,7 +145,6 @@ async function handleMerge(args, ctx) {
144
145
  }
145
146
  }
146
147
  const commitType = inferCommitType(target);
147
- const mainBranch = nativeDetectMainBranch(basePath);
148
148
  const commitMessage = `${commitType}: merge worktree ${target}\n\nGSD-Worktree: ${target}`;
149
149
  try {
150
150
  mergeWorktreeToMain(basePath, target, commitMessage);
@@ -191,8 +191,9 @@ async function handleClean(ctx) {
191
191
  }
192
192
  const removed = [];
193
193
  const kept = [];
194
+ const mainBranch = nativeDetectMainBranch(basePath);
194
195
  for (const wt of worktrees) {
195
- const status = getStatus(basePath, wt.name, wt.path);
196
+ const status = getStatus(basePath, wt.name, wt.path, mainBranch);
196
197
  if (status.filesChanged === 0 && !status.uncommitted) {
197
198
  try {
198
199
  removeWorktree(basePath, wt.name, { deleteBranch: true });
@@ -238,7 +239,8 @@ async function handleRemove(args, ctx) {
238
239
  ctx.ui.notify(`Worktree "${name}" not found.\n\nAvailable: ${available}`, "error");
239
240
  return;
240
241
  }
241
- const status = getStatus(basePath, name, wt.path);
242
+ const mainBranch = nativeDetectMainBranch(basePath);
243
+ const status = getStatus(basePath, name, wt.path, mainBranch);
242
244
  if ((status.filesChanged > 0 || status.uncommitted) && !force) {
243
245
  ctx.ui.notify([
244
246
  `Worktree "${name}" has pending changes (${formatCleanKeepReason(status)}).`,
@@ -21,7 +21,7 @@ import { getWorkerBatches, hasActiveWorkers } from "../subagent/worker-registry.
21
21
  import { formatDuration, padRight, joinColumns, centerLine, fitColumns, STATUS_GLYPH, STATUS_COLOR } from "../shared/mod.js";
22
22
  import { estimateTimeRemaining } from "./auto-dashboard.js";
23
23
  import { computeProgressScore } from "./progress-score.js";
24
- import { runEnvironmentChecks } from "./doctor-environment.js";
24
+ import { runEnvironmentChecksAsync } from "./doctor-environment.js";
25
25
  import { formattedShortcutPair } from "./shortcut-defs.js";
26
26
  import { renderDialogFrame, renderKeyHints } from "./tui/render-kit.js";
27
27
  export function unitLabel(type) {
@@ -62,6 +62,9 @@ export class GSDDashboardOverlay {
62
62
  loading = true;
63
63
  loadedDashboardIdentity;
64
64
  refreshInFlight = null;
65
+ envRefreshInFlight = null;
66
+ cachedEnvBasePath;
67
+ cachedEnvIssues = [];
65
68
  disposed = false;
66
69
  resizeHandler = null;
67
70
  cachedMetrics = null;
@@ -155,11 +158,38 @@ export class GSDDashboardOverlay {
155
158
  if (initial) {
156
159
  this.loading = false;
157
160
  }
161
+ this.scheduleEnvironmentRefresh(this.dashData.basePath || process.cwd());
158
162
  if (identityChanged) {
159
163
  this.invalidate();
160
164
  }
161
165
  this.tui.requestRender();
162
166
  }
167
+ scheduleEnvironmentRefresh(basePath) {
168
+ if (this.cachedEnvBasePath !== basePath) {
169
+ this.cachedEnvBasePath = basePath;
170
+ this.cachedEnvIssues = [];
171
+ this.invalidate();
172
+ }
173
+ if (this.envRefreshInFlight || this.disposed)
174
+ return;
175
+ this.envRefreshInFlight = this.refreshEnvironmentHealth(basePath)
176
+ .finally(() => {
177
+ this.envRefreshInFlight = null;
178
+ });
179
+ }
180
+ async refreshEnvironmentHealth(basePath) {
181
+ try {
182
+ const envResults = await runEnvironmentChecksAsync(basePath);
183
+ if (this.disposed || this.cachedEnvBasePath !== basePath)
184
+ return;
185
+ this.cachedEnvIssues = envResults.filter(r => r.status !== "ok");
186
+ this.invalidate();
187
+ this.tui.requestRender();
188
+ }
189
+ catch {
190
+ // Non-fatal — keep last known environment issues
191
+ }
192
+ }
163
193
  async loadData() {
164
194
  const base = this.dashData.basePath || process.cwd();
165
195
  try {
@@ -540,8 +570,7 @@ export class GSDDashboardOverlay {
540
570
  }
541
571
  }
542
572
  // Environment health section (#1221) — only show issues
543
- const envResults = runEnvironmentChecks(this.dashData.basePath || process.cwd());
544
- const envIssues = envResults.filter(r => r.status !== "ok");
573
+ const envIssues = this.cachedEnvIssues;
545
574
  if (envIssues.length > 0) {
546
575
  lines.push(blank());
547
576
  lines.push(hr());
@@ -19,7 +19,7 @@ import { createCoordinationTablesV24 } from "../db-coordination-schema.js";
19
19
  import { createDbConnectionCache } from "../db-connection-cache.js";
20
20
  import { backupDatabaseBeforeMigration, isMigrationBackupError } from "../db-migration-backup.js";
21
21
  import { applyMigrationV2Artifacts, applyMigrationV3Memories, applyMigrationV4DecisionMadeBy, applyMigrationV5HierarchyTables, applyMigrationV6SliceSummaries, applyMigrationV7Dependencies, applyMigrationV8PlanningFields, applyMigrationV9Ordering, applyMigrationV10ReplanTrigger, applyMigrationV11TaskPlanning, applyMigrationV12QualityGates, applyMigrationV13HotPathIndexes, applyMigrationV14SliceDependencies, applyMigrationV15AuditTables, applyMigrationV16EscalationSource, applyMigrationV17TaskEscalation, applyMigrationV18MemorySources, applyMigrationV19MemoryFts, applyMigrationV20MemoryRelations, applyMigrationV21StructuredMemories, applyMigrationV22QualityGateRepair, applyMigrationV23MilestoneQueue, applyMigrationV26MilestoneCommitAttributions, applyMigrationV27ArtifactHash, applyMigrationV28MemoryLastHitAt, applyMigrationV29RepositoryTargets, } from "../db-migration-steps.js";
22
- import { isMemoriesFtsAvailableSchema, tryCreateMemoriesFtsSchema } from "../db-memory-fts-schema.js";
22
+ import { isMemoriesFtsAvailableSchema, rebuildMemoriesFtsSchemaOnce, tryCreateMemoriesFtsSchema, } from "../db-memory-fts-schema.js";
23
23
  import { createDbOpenState } from "../db-open-state.js";
24
24
  import { createRuntimeKvTableV25 } from "../db-runtime-kv-schema.js";
25
25
  import { getCurrentSchemaVersion, recordSchemaVersion } from "../db-schema-metadata.js";
@@ -101,6 +101,9 @@ function initSchema(db, fileBacked, dbPath) {
101
101
  throw err;
102
102
  }
103
103
  migrateSchema(db, dbPath);
104
+ rebuildMemoriesFtsSchemaOnce(db, {
105
+ onRebuildFailed: (message) => logWarning("db", message),
106
+ });
104
107
  }
105
108
  export function _isLikelyWslDrvFsPathForTest(dbPath) {
106
109
  if (!dbPath || process.platform !== "linux")