gsd-pi 2.78.0-dev.aeeb2ca00 → 2.78.1-dev.84a383f51
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.
- package/README.md +7 -7
- package/dist/claude-cli-check.js +64 -37
- package/dist/cli-policy.d.ts +13 -0
- package/dist/cli-policy.js +17 -0
- package/dist/cli.js +95 -55
- package/dist/headless-query.d.ts +22 -0
- package/dist/headless-query.js +24 -4
- package/dist/headless.d.ts +10 -0
- package/dist/headless.js +16 -1
- package/dist/loader.js +7 -10
- package/dist/onboarding.d.ts +10 -0
- package/dist/onboarding.js +2 -2
- package/dist/provider-migrations.d.ts +2 -2
- package/dist/provider-migrations.js +5 -2
- package/dist/resource-loader.d.ts +5 -2
- package/dist/resource-loader.js +28 -5
- package/dist/resources/.managed-resources-content-hash +1 -0
- package/dist/resources/extensions/claude-code-cli/readiness.js +77 -45
- package/dist/resources/extensions/gsd/auto/loop.js +23 -0
- package/dist/resources/extensions/gsd/auto/phases.js +2 -2
- package/dist/resources/extensions/gsd/auto/run-unit.js +3 -1
- package/dist/resources/extensions/gsd/auto/session.js +3 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -4
- package/dist/resources/extensions/gsd/auto-runtime-state.js +31 -0
- package/dist/resources/extensions/gsd/auto-start.js +1 -1
- package/dist/resources/extensions/gsd/auto-tool-tracking.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +30 -0
- package/dist/resources/extensions/gsd/auto.js +14 -5
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +14 -2
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +7 -5
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +2 -2
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +5 -4
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +94 -31
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +11 -6
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +34 -8
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +38 -2
- package/dist/resources/extensions/gsd/commands/catalog.js +69 -5
- package/dist/resources/extensions/gsd/commands/handlers/core.js +22 -1
- package/dist/resources/extensions/gsd/commands-mcp-status.js +3 -1
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +10 -1
- package/dist/resources/extensions/gsd/dashboard-overlay.js +1 -1
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +4 -0
- package/dist/resources/extensions/gsd/doctor-runtime-checks.js +39 -1
- package/dist/resources/extensions/gsd/error-classifier.js +1 -1
- package/dist/resources/extensions/gsd/forensics.js +2 -2
- package/dist/resources/extensions/gsd/git-service.js +12 -5
- package/dist/resources/extensions/gsd/gsd-db.js +11 -2
- package/dist/resources/extensions/gsd/guided-flow.js +23 -23
- package/dist/resources/extensions/gsd/memory-store.js +66 -31
- package/dist/resources/extensions/gsd/milestone-id-reservation.js +36 -0
- package/dist/resources/extensions/gsd/model-router.js +114 -9
- package/dist/resources/extensions/gsd/native-git-bridge.js +7 -1
- package/dist/resources/extensions/gsd/preferences-models.js +91 -15
- package/dist/resources/extensions/gsd/preferences-types.js +2 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +32 -0
- package/dist/resources/extensions/gsd/preferences.js +5 -3
- package/dist/resources/extensions/gsd/prompt-loader.js +23 -12
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +9 -3
- package/dist/resources/extensions/gsd/state.js +42 -0
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/dist/resources/extensions/gsd/tools/memory-tools.js +18 -1
- package/dist/resources/extensions/gsd/visualizer-overlay.js +1 -1
- package/dist/resources/extensions/gsd/watch/header-renderer.js +3 -1
- package/dist/resources/extensions/gsd/worktree-command.js +26 -46
- package/dist/resources/extensions/gsd/worktree-session-state.js +33 -0
- package/dist/resources/extensions/mcp-client/index.js +6 -3
- package/dist/resources/extensions/slash-commands/create-extension.js +36 -22
- package/dist/resources/skills/create-gsd-extension/SKILL.md +9 -5
- package/dist/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
- package/dist/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
- package/dist/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
- package/dist/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
- package/dist/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
- package/dist/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
- package/dist/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
- package/dist/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
- package/dist/rtk-shared.d.ts +3 -0
- package/dist/rtk-shared.js +17 -0
- package/dist/rtk.d.ts +2 -5
- package/dist/rtk.js +3 -20
- package/dist/runtime-checks.d.ts +27 -0
- package/dist/runtime-checks.js +38 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +44 -4
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +4 -2
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/server/webpack-runtime.js +1 -1
- package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +1 -0
- package/dist/web/standalone/.next/static/chunks/2824.08296bc2f9654698.js +1 -0
- package/dist/web/standalone/.next/static/chunks/3026.3af53b279375f082.js +1 -0
- package/dist/web/standalone/.next/static/chunks/315.6f68ae79b67d25cf.js +1 -0
- package/dist/web/standalone/.next/static/chunks/3497.4bfc60a3b3dea717.js +1 -0
- package/dist/web/standalone/.next/static/chunks/5516.4a07c872b5c3a663.js +1 -0
- package/dist/web/standalone/.next/static/chunks/8336.31b019697882acfb.js +10 -0
- package/dist/web/standalone/.next/static/chunks/8845.c9702695e8c5a9c5.js +2 -0
- package/dist/web/standalone/.next/static/chunks/9058.01ef3a463bda88f1.js +20 -0
- package/dist/web/standalone/.next/static/chunks/9441.1081da1125d1764f.js +1 -0
- package/dist/web/standalone/.next/static/chunks/app/{page-5b113fd32bc2a1c3.js → page-9bf2e0c50fb2ca05.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/webpack-f9f0dc45e4f3ac10.js +1 -0
- package/dist/web/standalone/package.json +2 -1
- package/dist/worktree-status-banner.d.ts +1 -0
- package/dist/worktree-status-banner.js +132 -0
- package/package.json +1 -1
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/alias-telemetry.d.ts +8 -0
- package/packages/mcp-server/dist/alias-telemetry.d.ts.map +1 -0
- package/packages/mcp-server/dist/alias-telemetry.js +30 -0
- package/packages/mcp-server/dist/alias-telemetry.js.map +1 -0
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +74 -46
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +2 -2
- package/packages/mcp-server/src/alias-telemetry.test.ts +78 -0
- package/packages/mcp-server/src/alias-telemetry.ts +30 -0
- package/packages/mcp-server/src/workflow-tools.test.ts +26 -0
- package/packages/mcp-server/src/workflow-tools.ts +93 -58
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.js +231 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +48 -19
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +13 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/dist/utils/repair-tool-json.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/repair-tool-json.js +24 -3
- package/packages/pi-ai/dist/utils/repair-tool-json.js.map +1 -1
- package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js +26 -0
- package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js.map +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/src/providers/anthropic-shared.cache-breakpoint.test.ts +289 -0
- package/packages/pi-ai/src/providers/anthropic-shared.ts +52 -20
- package/packages/pi-ai/src/types.ts +13 -0
- package/packages/pi-ai/src/utils/repair-tool-json.ts +24 -3
- package/packages/pi-ai/src/utils/tests/repair-tool-json.test.ts +32 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +6 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.js +4 -0
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +19 -2
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +10 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +18 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +13 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +20 -16
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts +37 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.js +49 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +133 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +14 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js +78 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js +181 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js.map +1 -0
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +7 -0
- package/packages/pi-coding-agent/src/core/messages.ts +4 -0
- package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +32 -2
- package/packages/pi-coding-agent/src/core/model-registry.ts +21 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +33 -15
- package/packages/pi-coding-agent/src/core/token-telemetry.ts +77 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +212 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +17 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +1 -1
- package/packages/pi-coding-agent/src/tests/system-prompt-cache-stability.test.ts +102 -0
- package/packages/pi-coding-agent/src/tests/token-telemetry.test.ts +200 -0
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js +17 -3
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js.map +1 -1
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts +2 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js +161 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js.map +1 -0
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/src/__tests__/autocomplete.test.ts +20 -3
- package/packages/pi-tui/src/components/__tests__/leak-fixes-runtime.test.ts +219 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/packages/rpc-client/package.json +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +78 -46
- package/src/resources/extensions/gsd/auto/loop.ts +24 -2
- package/src/resources/extensions/gsd/auto/phases.ts +3 -3
- package/src/resources/extensions/gsd/auto/run-unit.ts +3 -1
- package/src/resources/extensions/gsd/auto/session.ts +3 -0
- package/src/resources/extensions/gsd/auto/types.ts +1 -0
- package/src/resources/extensions/gsd/auto-recovery.ts +46 -8
- package/src/resources/extensions/gsd/auto-runtime-state.ts +51 -0
- package/src/resources/extensions/gsd/auto-start.ts +1 -1
- package/src/resources/extensions/gsd/auto-tool-tracking.ts +2 -4
- package/src/resources/extensions/gsd/auto-worktree.ts +38 -0
- package/src/resources/extensions/gsd/auto.ts +14 -4
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +15 -13
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +8 -7
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +2 -2
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +10 -9
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +102 -31
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +12 -6
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +39 -8
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +39 -11
- package/src/resources/extensions/gsd/commands/catalog.ts +75 -5
- package/src/resources/extensions/gsd/commands/handlers/core.ts +22 -1
- package/src/resources/extensions/gsd/commands-mcp-status.ts +3 -1
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +15 -1
- package/src/resources/extensions/gsd/dashboard-overlay.ts +1 -1
- package/src/resources/extensions/gsd/docs/preferences-reference.md +4 -0
- package/src/resources/extensions/gsd/doctor-runtime-checks.ts +39 -1
- package/src/resources/extensions/gsd/doctor-types.ts +3 -1
- package/src/resources/extensions/gsd/error-classifier.ts +1 -1
- package/src/resources/extensions/gsd/forensics.ts +2 -2
- package/src/resources/extensions/gsd/git-service.ts +13 -5
- package/src/resources/extensions/gsd/gsd-db.ts +12 -2
- package/src/resources/extensions/gsd/guided-flow.ts +25 -25
- package/src/resources/extensions/gsd/memory-store.ts +81 -28
- package/src/resources/extensions/gsd/milestone-id-reservation.ts +47 -0
- package/src/resources/extensions/gsd/model-router.ts +172 -9
- package/src/resources/extensions/gsd/native-git-bridge.ts +7 -1
- package/src/resources/extensions/gsd/preferences-models.ts +101 -15
- package/src/resources/extensions/gsd/preferences-types.ts +6 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +35 -0
- package/src/resources/extensions/gsd/preferences.ts +16 -2
- package/src/resources/extensions/gsd/prompt-loader.ts +26 -12
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +9 -3
- package/src/resources/extensions/gsd/state.ts +42 -0
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +178 -1
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +9 -5
- package/src/resources/extensions/gsd/tests/auto-supervisor.test.mjs +21 -4
- package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/budget-prediction.test.ts +138 -211
- package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +142 -59
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +7 -4
- package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +89 -32
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +41 -23
- package/src/resources/extensions/gsd/tests/db-path-worktree-symlink.test.ts +3 -43
- package/src/resources/extensions/gsd/tests/debug-logger.test.ts +5 -3
- package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +116 -0
- package/src/resources/extensions/gsd/tests/discuss-empty-db-fallback.test.ts +22 -87
- package/src/resources/extensions/gsd/tests/discuss-queued-milestones.test.ts +7 -118
- package/src/resources/extensions/gsd/tests/discuss-tool-scope-leak.test.ts +18 -60
- package/src/resources/extensions/gsd/tests/doctor-orphan-milestone-4996.test.ts +100 -0
- package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +14 -76
- package/src/resources/extensions/gsd/tests/ensure-preconditions-guard-4996.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/false-degraded-mode-warning.test.ts +22 -83
- package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +1 -63
- package/src/resources/extensions/gsd/tests/find-missing-summaries-closed-runtime.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +26 -1
- package/src/resources/extensions/gsd/tests/gitignore-bg-shell-runtime.test.ts +63 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/gsd-no-project-error-runtime.test.ts +81 -0
- package/src/resources/extensions/gsd/tests/headless-answers.test.ts +14 -4
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +22 -12
- package/src/resources/extensions/gsd/tests/help-menu-coverage.test.ts +57 -0
- package/src/resources/extensions/gsd/tests/import-done-milestones-runtime.test.ts +145 -0
- package/src/resources/extensions/gsd/tests/init-prefs-routing.test.ts +64 -1
- package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +22 -0
- package/src/resources/extensions/gsd/tests/integration/token-savings.test.ts +0 -23
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +128 -0
- package/src/resources/extensions/gsd/tests/memory-tools.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/merge-self-branch-guard.test.ts +124 -0
- package/src/resources/extensions/gsd/tests/milestone-id-gap-reuse-4996.test.ts +152 -0
- package/src/resources/extensions/gsd/tests/model-router.test.ts +169 -8
- package/src/resources/extensions/gsd/tests/native-git-infra-errors.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +32 -43
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +4 -10
- package/src/resources/extensions/gsd/tests/preferences.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +16 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +6 -6
- package/src/resources/extensions/gsd/tests/register-hooks-compaction-checkpoint.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +168 -19
- package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +23 -1
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +101 -0
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +51 -4
- package/src/resources/extensions/gsd/tests/turn-epoch.test.ts +7 -16
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -7
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +15 -1
- package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +6 -6
- package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +15 -0
- package/src/resources/extensions/gsd/tools/memory-tools.ts +17 -1
- package/src/resources/extensions/gsd/unit-context-manifest.ts +8 -8
- package/src/resources/extensions/gsd/visualizer-overlay.ts +1 -1
- package/src/resources/extensions/gsd/watch/header-renderer.ts +3 -1
- package/src/resources/extensions/gsd/workflow-logger.ts +1 -0
- package/src/resources/extensions/gsd/worktree-command.ts +31 -44
- package/src/resources/extensions/gsd/worktree-session-state.ts +35 -0
- package/src/resources/extensions/mcp-client/index.ts +6 -3
- package/src/resources/extensions/mcp-client/tests/global-config.test.ts +91 -0
- package/src/resources/extensions/slash-commands/create-extension.ts +38 -24
- package/src/resources/skills/create-gsd-extension/SKILL.md +9 -5
- package/src/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
- package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
- package/src/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
- package/src/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
- package/src/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
- package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
- package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
- package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +2 -2
- package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +3 -3
- package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +58 -0
- package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
- package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +0 -601
- package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +0 -651
- package/dist/resources/extensions/browser-tools/tests/capture-sharp-optional.test.cjs +0 -91
- package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +0 -53
- package/dist/resources/extensions/gsd/tests/dist-redirect.mjs +0 -112
- package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +0 -23
- package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +0 -5
- package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +0 -608
- package/dist/web/standalone/.next/static/chunks/2826.e9f5195e91f9cad2.js +0 -11
- package/dist/web/standalone/.next/static/chunks/3621.fc7480022c972438.js +0 -20
- package/dist/web/standalone/.next/static/chunks/webpack-2e68521d7c82f7c2.js +0 -1
- package/src/resources/extensions/gsd/tests/copy-planning-artifacts-samepath.test.ts +0 -22
- package/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts +0 -47
- package/src/resources/extensions/gsd/tests/empty-content-abort-loop.test.ts +0 -75
- /package/dist/web/standalone/.next/static/{cAJH99yNS1UPbeSEiNRrV → UF5VF4F1tB0miEtJS7LyX}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{cAJH99yNS1UPbeSEiNRrV → UF5VF4F1tB0miEtJS7LyX}/_ssgManifest.js +0 -0
|
@@ -80,13 +80,12 @@ import { runAutoLoopWithUok } from "./uok/kernel.js";
|
|
|
80
80
|
import { resolveUokFlags } from "./uok/flags.js";
|
|
81
81
|
import { WorktreeResolver, } from "./worktree-resolver.js";
|
|
82
82
|
import { reorderForCaching } from "./prompt-ordering.js";
|
|
83
|
-
// ─── Session State ─────────────────────────────────────────────────────────
|
|
84
|
-
import { AutoSession, } from "./auto/session.js";
|
|
85
83
|
export { STUB_RECOVERY_THRESHOLD, NEW_SESSION_TIMEOUT_MS, } from "./auto/session.js";
|
|
84
|
+
import { autoSession as s } from "./auto-runtime-state.js";
|
|
86
85
|
// ── ENCAPSULATION INVARIANT ─────────────────────────────────────────────────
|
|
87
86
|
// ALL mutable auto-mode state lives in the AutoSession class (auto/session.ts).
|
|
88
87
|
// This file must NOT declare module-level `let` or `var` variables for state.
|
|
89
|
-
// The single `s` instance below is the only mutable
|
|
88
|
+
// The single shared `s` instance below is the only mutable AutoSession binding.
|
|
90
89
|
//
|
|
91
90
|
// When adding features or fixing bugs:
|
|
92
91
|
// - New mutable state → add a property to AutoSession, not a module-level variable
|
|
@@ -95,7 +94,6 @@ export { STUB_RECOVERY_THRESHOLD, NEW_SESSION_TIMEOUT_MS, } from "./auto/session
|
|
|
95
94
|
//
|
|
96
95
|
// Tests in auto-session-encapsulation.test.ts enforce this invariant.
|
|
97
96
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
98
|
-
const s = new AutoSession();
|
|
99
97
|
/** Throttle STATE.md rebuilds — at most once per 30 seconds */
|
|
100
98
|
const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
|
|
101
99
|
function captureProjectRootEnv(projectRoot) {
|
|
@@ -1408,10 +1406,21 @@ const widgetStateAccessors = {
|
|
|
1408
1406
|
* Ensure directories, branches, and other prerequisites exist before
|
|
1409
1407
|
* dispatching a unit. The LLM should never need to mkdir or git checkout.
|
|
1410
1408
|
*/
|
|
1411
|
-
function ensurePreconditions(unitType, unitId, base, state) {
|
|
1409
|
+
export function ensurePreconditions(unitType, unitId, base, state) {
|
|
1412
1410
|
const { milestone: mid, slice: sid } = parseUnitId(unitId);
|
|
1413
1411
|
const mDir = resolveMilestonePath(base, mid);
|
|
1414
1412
|
if (!mDir) {
|
|
1413
|
+
// Fix #4996: When dispatching a slice unit against an unrecognised milestone,
|
|
1414
|
+
// only create the directory if the milestone has a DB row.
|
|
1415
|
+
// Without this guard, forward-referenced unit IDs (e.g. from REQUIREMENTS.md)
|
|
1416
|
+
// silently scaffold empty stub directories that later skew nextMilestoneId.
|
|
1417
|
+
if (sid !== undefined) {
|
|
1418
|
+
const hasDbRow = isDbAvailable() && getMilestone(mid) != null;
|
|
1419
|
+
if (!hasDbRow) {
|
|
1420
|
+
logWarning("engine", `ensurePreconditions: skipping mkdir for unrecognised milestone ${mid} referenced by slice unit ${unitId} — no DB row exists`, { file: "auto.ts" });
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1415
1424
|
const newDir = join(milestonesDir(base), mid);
|
|
1416
1425
|
mkdirSync(join(newDir, "slices"), { recursive: true });
|
|
1417
1426
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
2
|
import { Text } from "@gsd/pi-tui";
|
|
3
|
-
import { findMilestoneIds, nextMilestoneId, claimReservedId, getReservedMilestoneIds } from "../guided-flow.js";
|
|
4
3
|
import { loadEffectiveGSDPreferences } from "../preferences.js";
|
|
5
4
|
import { ensureDbOpen } from "./dynamic-tools.js";
|
|
6
5
|
import { StringEnum } from "@gsd/pi-ai";
|
|
7
6
|
import { logError } from "../workflow-logger.js";
|
|
8
|
-
|
|
7
|
+
async function loadWorkflowExecutors() {
|
|
8
|
+
return import("../tools/workflow-tool-executors.js");
|
|
9
|
+
}
|
|
9
10
|
/**
|
|
10
11
|
* Register an alias tool that shares the same execute function as its canonical counterpart.
|
|
11
12
|
* The alias description and promptGuidelines direct the LLM to prefer the canonical name.
|
|
@@ -280,6 +281,7 @@ export function registerDbTools(pi) {
|
|
|
280
281
|
registerAlias(pi, requirementSaveTool, "gsd_save_requirement", "gsd_requirement_save");
|
|
281
282
|
// ─── gsd_summary_save (formerly gsd_save_summary) ──────────────────────
|
|
282
283
|
const summarySaveExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
284
|
+
const { executeSummarySave } = await loadWorkflowExecutors();
|
|
283
285
|
return executeSummarySave(params, process.cwd());
|
|
284
286
|
};
|
|
285
287
|
const summarySaveTool = {
|
|
@@ -330,6 +332,7 @@ export function registerDbTools(pi) {
|
|
|
330
332
|
try {
|
|
331
333
|
// Claim a reserved ID if the guided-flow already previewed one to the user.
|
|
332
334
|
// This guarantees the ID shown in the UI matches the one materialised on disk.
|
|
335
|
+
const { claimReservedId, findMilestoneIds, getReservedMilestoneIds, nextMilestoneId } = await import("../guided-flow.js");
|
|
333
336
|
const reserved = claimReservedId();
|
|
334
337
|
if (reserved) {
|
|
335
338
|
await ensureMilestoneDbRow(reserved);
|
|
@@ -408,6 +411,7 @@ export function registerDbTools(pi) {
|
|
|
408
411
|
registerAlias(pi, milestoneGenerateIdTool, "gsd_generate_milestone_id", "gsd_milestone_generate_id");
|
|
409
412
|
// ─── gsd_plan_milestone (gsd_milestone_plan alias) ─────────────────────
|
|
410
413
|
const planMilestoneExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
414
|
+
const { executePlanMilestone } = await loadWorkflowExecutors();
|
|
411
415
|
return executePlanMilestone(params, process.cwd());
|
|
412
416
|
};
|
|
413
417
|
const planMilestoneTool = {
|
|
@@ -472,6 +476,7 @@ export function registerDbTools(pi) {
|
|
|
472
476
|
registerAlias(pi, planMilestoneTool, "gsd_milestone_plan", "gsd_plan_milestone");
|
|
473
477
|
// ─── gsd_plan_slice (gsd_slice_plan alias) ─────────────────────────────
|
|
474
478
|
const planSliceExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
479
|
+
const { executePlanSlice } = await loadWorkflowExecutors();
|
|
475
480
|
return executePlanSlice(params, process.cwd());
|
|
476
481
|
};
|
|
477
482
|
const planSliceTool = {
|
|
@@ -585,6 +590,7 @@ export function registerDbTools(pi) {
|
|
|
585
590
|
registerAlias(pi, planTaskTool, "gsd_task_plan", "gsd_plan_task");
|
|
586
591
|
// ─── gsd_task_complete (gsd_complete_task alias) ────────────────────────
|
|
587
592
|
const taskCompleteExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
593
|
+
const { executeTaskComplete } = await loadWorkflowExecutors();
|
|
588
594
|
return executeTaskComplete(params, process.cwd());
|
|
589
595
|
};
|
|
590
596
|
const taskCompleteTool = {
|
|
@@ -647,6 +653,7 @@ export function registerDbTools(pi) {
|
|
|
647
653
|
registerAlias(pi, taskCompleteTool, "gsd_complete_task", "gsd_task_complete");
|
|
648
654
|
// ─── gsd_slice_complete (gsd_complete_slice alias) ─────────────────────
|
|
649
655
|
const sliceCompleteExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
656
|
+
const { executeSliceComplete } = await loadWorkflowExecutors();
|
|
650
657
|
return executeSliceComplete(params, process.cwd());
|
|
651
658
|
};
|
|
652
659
|
const sliceCompleteTool = {
|
|
@@ -811,6 +818,7 @@ export function registerDbTools(pi) {
|
|
|
811
818
|
});
|
|
812
819
|
// ─── gsd_complete_milestone ────────────────────────────────────────────
|
|
813
820
|
const milestoneCompleteExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
821
|
+
const { executeCompleteMilestone } = await loadWorkflowExecutors();
|
|
814
822
|
return executeCompleteMilestone(params, process.cwd());
|
|
815
823
|
};
|
|
816
824
|
const milestoneCompleteTool = {
|
|
@@ -851,6 +859,7 @@ export function registerDbTools(pi) {
|
|
|
851
859
|
registerAlias(pi, milestoneCompleteTool, "gsd_milestone_complete", "gsd_complete_milestone");
|
|
852
860
|
// ─── gsd_validate_milestone (gsd_milestone_validate alias) ─────────────
|
|
853
861
|
const milestoneValidateExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
862
|
+
const { executeValidateMilestone } = await loadWorkflowExecutors();
|
|
854
863
|
return executeValidateMilestone(params, process.cwd());
|
|
855
864
|
};
|
|
856
865
|
const milestoneValidateTool = {
|
|
@@ -883,6 +892,7 @@ export function registerDbTools(pi) {
|
|
|
883
892
|
registerAlias(pi, milestoneValidateTool, "gsd_milestone_validate", "gsd_validate_milestone");
|
|
884
893
|
// ─── gsd_replan_slice (gsd_slice_replan alias) ─────────────────────────
|
|
885
894
|
const replanSliceExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
895
|
+
const { executeReplanSlice } = await loadWorkflowExecutors();
|
|
886
896
|
return executeReplanSlice(params, process.cwd());
|
|
887
897
|
};
|
|
888
898
|
const replanSliceTool = {
|
|
@@ -925,6 +935,7 @@ export function registerDbTools(pi) {
|
|
|
925
935
|
registerAlias(pi, replanSliceTool, "gsd_slice_replan", "gsd_replan_slice");
|
|
926
936
|
// ─── gsd_reassess_roadmap (gsd_roadmap_reassess alias) ─────────────────
|
|
927
937
|
const reassessRoadmapExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
938
|
+
const { executeReassessRoadmap } = await loadWorkflowExecutors();
|
|
928
939
|
return executeReassessRoadmap(params, process.cwd());
|
|
929
940
|
};
|
|
930
941
|
const reassessRoadmapTool = {
|
|
@@ -1157,6 +1168,7 @@ export function registerDbTools(pi) {
|
|
|
1157
1168
|
registerAlias(pi, reopenMilestoneTool, "gsd_reopen_milestone", "gsd_milestone_reopen");
|
|
1158
1169
|
// ─── gsd_save_gate_result ──────────────────────────────────────────────
|
|
1159
1170
|
const saveGateResultExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
1171
|
+
const { executeSaveGateResult } = await loadWorkflowExecutors();
|
|
1160
1172
|
return executeSaveGateResult(params, process.cwd());
|
|
1161
1173
|
};
|
|
1162
1174
|
const saveGateResultTool = {
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
// Exposes the `gsd_exec` tool over MCP. Opt-in: disabled unless
|
|
4
4
|
// `context_mode.enabled: true` is set in preferences.
|
|
5
5
|
import { Type } from "@sinclair/typebox";
|
|
6
|
-
import { executeGsdExec } from "../tools/exec-tool.js";
|
|
7
|
-
import { executeExecSearch } from "../tools/exec-search-tool.js";
|
|
8
|
-
import { executeResume } from "../tools/resume-tool.js";
|
|
9
|
-
import { loadEffectiveGSDPreferences } from "../preferences.js";
|
|
10
|
-
import { logWarning } from "../workflow-logger.js";
|
|
11
6
|
export function registerExecTools(pi) {
|
|
12
7
|
pi.registerTool({
|
|
13
8
|
name: "gsd_exec",
|
|
@@ -35,6 +30,11 @@ export function registerExecTools(pi) {
|
|
|
35
30
|
})),
|
|
36
31
|
}),
|
|
37
32
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
33
|
+
const [{ executeGsdExec }, { loadEffectiveGSDPreferences }, { logWarning }] = await Promise.all([
|
|
34
|
+
import("../tools/exec-tool.js"),
|
|
35
|
+
import("../preferences.js"),
|
|
36
|
+
import("../workflow-logger.js"),
|
|
37
|
+
]);
|
|
38
38
|
let prefs = null;
|
|
39
39
|
try {
|
|
40
40
|
prefs = loadEffectiveGSDPreferences();
|
|
@@ -67,6 +67,7 @@ export function registerExecTools(pi) {
|
|
|
67
67
|
limit: Type.Optional(Type.Number({ description: "Max results (default 20, cap 200)", minimum: 1, maximum: 200 })),
|
|
68
68
|
}),
|
|
69
69
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
70
|
+
const { executeExecSearch } = await import("../tools/exec-search-tool.js");
|
|
70
71
|
return executeExecSearch(params, {
|
|
71
72
|
baseDir: process.cwd(),
|
|
72
73
|
});
|
|
@@ -85,6 +86,7 @@ export function registerExecTools(pi) {
|
|
|
85
86
|
],
|
|
86
87
|
parameters: Type.Object({}),
|
|
87
88
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
89
|
+
const { executeResume } = await import("../tools/resume-tool.js");
|
|
88
90
|
return executeResume(params, {
|
|
89
91
|
baseDir: process.cwd(),
|
|
90
92
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// GSD2 — Read-only query tools exposing DB state to the LLM via the WAL connection
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { ensureDbOpen } from "./dynamic-tools.js";
|
|
4
|
-
import { executeMilestoneStatus } from "../tools/workflow-tool-executors.js";
|
|
5
|
-
import { checkpointDatabase } from "../gsd-db.js";
|
|
6
4
|
export function registerQueryTools(pi) {
|
|
7
5
|
pi.registerTool({
|
|
8
6
|
name: "gsd_milestone_status",
|
|
@@ -25,6 +23,7 @@ export function registerQueryTools(pi) {
|
|
|
25
23
|
details: { operation: "milestone_status", error: "db_unavailable" },
|
|
26
24
|
};
|
|
27
25
|
}
|
|
26
|
+
const { executeMilestoneStatus } = await import("../tools/workflow-tool-executors.js");
|
|
28
27
|
return executeMilestoneStatus(params);
|
|
29
28
|
},
|
|
30
29
|
});
|
|
@@ -49,6 +48,7 @@ export function registerQueryTools(pi) {
|
|
|
49
48
|
details: { operation: "checkpoint_db", error: "db_unavailable" },
|
|
50
49
|
};
|
|
51
50
|
}
|
|
51
|
+
const { checkpointDatabase } = await import("../gsd-db.js");
|
|
52
52
|
checkpointDatabase();
|
|
53
53
|
return {
|
|
54
54
|
content: [{ type: "text", text: "WAL checkpoint complete. gsd.db is now up to date and safe to stage with git add." }],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// GSD2 — Extension registration: wires all GSD tools, commands, and hooks into pi
|
|
2
2
|
import { registerExitCommand } from "../exit-command.js";
|
|
3
|
-
import {
|
|
4
|
-
import { loadEcosystemExtensions } from "../ecosystem/loader.js";
|
|
3
|
+
import { registerLazyWorktreeCommands } from "../worktree-command-bootstrap.js";
|
|
5
4
|
import { registerDbTools } from "./db-tools.js";
|
|
6
5
|
import { registerDynamicTools } from "./dynamic-tools.js";
|
|
7
6
|
import { registerExecTools } from "./exec-tools.js";
|
|
@@ -64,7 +63,7 @@ function installEpipeGuard() {
|
|
|
64
63
|
export function registerGsdExtension(pi) {
|
|
65
64
|
// Note: registerGSDCommand is called by index.ts before this function,
|
|
66
65
|
// so we intentionally skip it here to avoid double-registration.
|
|
67
|
-
|
|
66
|
+
registerLazyWorktreeCommands(pi);
|
|
68
67
|
registerExitCommand(pi);
|
|
69
68
|
// Wire the Layer 2 event emitter bridge so deeply-nested GSD code can emit
|
|
70
69
|
// extension events (git lifecycle, verify, budget, milestone, unit) without
|
|
@@ -102,7 +101,9 @@ export function registerGsdExtension(pi) {
|
|
|
102
101
|
["cmux-events", () => initCmuxEventListeners(pi.events)],
|
|
103
102
|
["hooks", () => registerHooks(pi, ecosystemHandlers)],
|
|
104
103
|
["ecosystem", () => {
|
|
105
|
-
void
|
|
104
|
+
void import("../ecosystem/loader.js")
|
|
105
|
+
.then(({ loadEcosystemExtensions }) => loadEcosystemExtensions(pi, ecosystemHandlers))
|
|
106
|
+
.catch((err) => {
|
|
106
107
|
logWarning("ecosystem", `loader failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
107
108
|
});
|
|
108
109
|
}],
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { isToolCallEventType } from "@gsd/pi-coding-agent";
|
|
3
3
|
import { updateSnapshot } from "../ecosystem/gsd-extension-api.js";
|
|
4
|
-
import { getEcosystemReadyPromise } from "../ecosystem/loader.js";
|
|
5
4
|
import { buildMilestoneFileName, resolveMilestonePath, resolveSliceFile, resolveSlicePath } from "../paths.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { clearDiscussionFlowState, isDepthConfirmationAnswer, isQueuePhaseActive, markDepthVerified, resetWriteGateState, shouldBlockContextWrite, shouldBlockQueueExecution, isGateQuestionId, setPendingGate, clearPendingGate, getPendingGate, shouldBlockPendingGate, shouldBlockPendingGateBash, extractDepthVerificationMilestoneId } from "./write-gate.js";
|
|
5
|
+
import { clearDiscussionFlowState, isDepthConfirmationAnswer, isQueuePhaseActive, markDepthVerified, resetWriteGateState, shouldBlockContextWrite, shouldBlockPlanningUnit, shouldBlockQueueExecution, isGateQuestionId, setPendingGate, clearPendingGate, getPendingGate, shouldBlockPendingGate, shouldBlockPendingGateBash, extractDepthVerificationMilestoneId } from "./write-gate.js";
|
|
6
|
+
import { resolveManifest } from "../unit-context-manifest.js";
|
|
9
7
|
import { isBlockedStateFile, isBashWriteToStateFile, BLOCKED_WRITE_ERROR } from "../write-intercept.js";
|
|
10
|
-
import { cleanupQuickBranch } from "../quick.js";
|
|
11
|
-
import { getDiscussionMilestoneId } from "../guided-flow.js";
|
|
12
|
-
import { loadToolApiKeys } from "../commands-config.js";
|
|
13
8
|
import { loadFile, saveFile, formatContinue } from "../files.js";
|
|
14
|
-
import {
|
|
15
|
-
import { getAutoDashboardData, isAutoActive, isAutoPaused, markToolEnd, markToolStart, recordToolInvocationError } from "../auto.js";
|
|
16
|
-
import { isParallelActive, shutdownParallel } from "../parallel-orchestrator.js";
|
|
9
|
+
import { getAutoRuntimeSnapshot, isAutoActive, isAutoPaused, markToolEnd, markToolStart, recordToolInvocationError } from "../auto-runtime-state.js";
|
|
17
10
|
import { checkToolCallLoop, resetToolCallLoopGuard } from "./tool-call-loop-guard.js";
|
|
18
11
|
import { saveActivityLog } from "../activity-log.js";
|
|
19
|
-
import { resetAskUserQuestionsCache } from "../../ask-user-questions.js";
|
|
20
12
|
import { recordToolCall as safetyRecordToolCall, recordToolResult as safetyRecordToolResult, saveEvidenceToDisk } from "../safety/evidence-collector.js";
|
|
21
13
|
import { parseUnitId } from "../unit-id.js";
|
|
22
14
|
import { classifyCommand } from "../safety/destructive-guard.js";
|
|
@@ -24,26 +16,52 @@ import { logWarning as safetyLogWarning } from "../workflow-logger.js";
|
|
|
24
16
|
import { installNotifyInterceptor } from "./notify-interceptor.js";
|
|
25
17
|
import { initNotificationStore } from "../notification-store.js";
|
|
26
18
|
import { initNotificationWidget } from "../notification-widget.js";
|
|
27
|
-
import { initHealthWidget } from "../health-widget.js";
|
|
28
19
|
// Skip the welcome screen on the very first session_start — cli.ts already
|
|
29
20
|
// printed it before the TUI launched. Only re-print on /clear (subsequent sessions).
|
|
30
21
|
let isFirstSession = true;
|
|
22
|
+
async function deriveGsdState(basePath) {
|
|
23
|
+
const { deriveState } = await import("../state.js");
|
|
24
|
+
return deriveState(basePath);
|
|
25
|
+
}
|
|
26
|
+
async function getDiscussionMilestoneIdFor(basePath) {
|
|
27
|
+
const { getDiscussionMilestoneId } = await import("../guided-flow.js");
|
|
28
|
+
return getDiscussionMilestoneId(basePath);
|
|
29
|
+
}
|
|
30
|
+
async function loadToolApiKeysForSession() {
|
|
31
|
+
const { loadToolApiKeys } = await import("../commands-config.js");
|
|
32
|
+
loadToolApiKeys();
|
|
33
|
+
}
|
|
34
|
+
async function resetAskUserQuestionsTurnCache() {
|
|
35
|
+
const { resetAskUserQuestionsCache } = await import("../../ask-user-questions.js");
|
|
36
|
+
resetAskUserQuestionsCache();
|
|
37
|
+
}
|
|
31
38
|
async function syncServiceTierStatus(ctx) {
|
|
32
39
|
const { getEffectiveServiceTier, formatServiceTierFooterStatus } = await import("../service-tier.js");
|
|
33
40
|
ctx.ui.setStatus("gsd-fast", formatServiceTierFooterStatus(getEffectiveServiceTier(), ctx.model?.id));
|
|
34
41
|
}
|
|
42
|
+
async function applyDisabledModelProviderPolicy(ctx) {
|
|
43
|
+
try {
|
|
44
|
+
const { resolveDisabledModelProvidersFromPreferences } = await import("../preferences.js");
|
|
45
|
+
ctx.modelRegistry.setDisabledModelProviders(resolveDisabledModelProvidersFromPreferences());
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Non-fatal: keep default provider visibility if preferences cannot be loaded.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
35
51
|
export function registerHooks(pi, ecosystemHandlers) {
|
|
36
52
|
pi.on("session_start", async (_event, ctx) => {
|
|
37
53
|
initNotificationStore(process.cwd());
|
|
38
54
|
installNotifyInterceptor(ctx);
|
|
39
55
|
initNotificationWidget(ctx);
|
|
40
56
|
if (!isAutoActive()) {
|
|
57
|
+
const { initHealthWidget } = await import("../health-widget.js");
|
|
41
58
|
initHealthWidget(ctx);
|
|
42
59
|
}
|
|
43
60
|
resetWriteGateState();
|
|
44
61
|
resetToolCallLoopGuard();
|
|
45
|
-
|
|
62
|
+
await resetAskUserQuestionsTurnCache();
|
|
46
63
|
await syncServiceTierStatus(ctx);
|
|
64
|
+
await applyDisabledModelProviderPolicy(ctx);
|
|
47
65
|
// Skip MCP auto-prep when running inside an auto-worktree (see session_switch below).
|
|
48
66
|
const { isInAutoWorktree } = await import("../auto-worktree.js");
|
|
49
67
|
if (!isInAutoWorktree(process.cwd())) {
|
|
@@ -79,7 +97,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
79
97
|
}
|
|
80
98
|
catch { /* non-fatal */ }
|
|
81
99
|
}
|
|
82
|
-
|
|
100
|
+
await loadToolApiKeysForSession();
|
|
83
101
|
if (isAutoActive()) {
|
|
84
102
|
ctx.ui.setWidget("gsd-health", undefined);
|
|
85
103
|
}
|
|
@@ -89,9 +107,10 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
89
107
|
installNotifyInterceptor(ctx);
|
|
90
108
|
resetWriteGateState();
|
|
91
109
|
resetToolCallLoopGuard();
|
|
92
|
-
|
|
110
|
+
await resetAskUserQuestionsTurnCache();
|
|
93
111
|
clearDiscussionFlowState();
|
|
94
112
|
await syncServiceTierStatus(ctx);
|
|
113
|
+
await applyDisabledModelProviderPolicy(ctx);
|
|
95
114
|
// Skip MCP auto-prep when running inside an auto-worktree. The worktree
|
|
96
115
|
// already has .mcp.json from createAutoWorktree, and re-running the writer
|
|
97
116
|
// post-chdir rewrites the file mid-run (non-idempotent due to cwd-relative
|
|
@@ -101,20 +120,26 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
101
120
|
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
102
121
|
prepareWorkflowMcpForProject(ctx, process.cwd());
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
if (isAutoActive()) {
|
|
123
|
+
await loadToolApiKeysForSession();
|
|
124
|
+
if (!isAutoActive()) {
|
|
125
|
+
const { initHealthWidget } = await import("../health-widget.js");
|
|
126
|
+
initHealthWidget(ctx);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
106
129
|
ctx.ui.setWidget("gsd-health", undefined);
|
|
107
130
|
}
|
|
108
131
|
});
|
|
109
132
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
110
133
|
// Wait for ecosystem loader to finish (no-op after first turn).
|
|
134
|
+
const { getEcosystemReadyPromise } = await import("../ecosystem/loader.js");
|
|
111
135
|
await getEcosystemReadyPromise();
|
|
112
136
|
// GSD's own context injection (existing behavior — unchanged).
|
|
137
|
+
const { buildBeforeAgentStartResult } = await import("./system-context.js");
|
|
113
138
|
const gsdResult = await buildBeforeAgentStartResult(event, ctx);
|
|
114
139
|
// Refresh the snapshot used by ecosystem getPhase()/getActiveUnit().
|
|
115
140
|
// deriveState has its own ~100ms cache so this is cheap on repeat calls.
|
|
116
141
|
try {
|
|
117
|
-
const state = await
|
|
142
|
+
const state = await deriveGsdState(process.cwd());
|
|
118
143
|
updateSnapshot(state);
|
|
119
144
|
}
|
|
120
145
|
catch {
|
|
@@ -148,7 +173,8 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
148
173
|
});
|
|
149
174
|
pi.on("agent_end", async (event, ctx) => {
|
|
150
175
|
resetToolCallLoopGuard();
|
|
151
|
-
|
|
176
|
+
await resetAskUserQuestionsTurnCache();
|
|
177
|
+
const { handleAgentEnd } = await import("./agent-end-recovery.js");
|
|
152
178
|
await handleAgentEnd(pi, event, ctx);
|
|
153
179
|
});
|
|
154
180
|
// Squash-merge quick-task branch back to the original branch after the
|
|
@@ -156,6 +182,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
156
182
|
// quick-return state is pending, so this is safe to call on every turn.
|
|
157
183
|
pi.on("turn_end", async () => {
|
|
158
184
|
try {
|
|
185
|
+
const { cleanupQuickBranch } = await import("../quick.js");
|
|
159
186
|
cleanupQuickBranch();
|
|
160
187
|
}
|
|
161
188
|
catch {
|
|
@@ -172,8 +199,8 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
172
199
|
const basePath = process.cwd();
|
|
173
200
|
const { ensureDbOpen } = await import("./dynamic-tools.js");
|
|
174
201
|
await ensureDbOpen();
|
|
175
|
-
const state = await
|
|
176
|
-
if (!state.activeMilestone || !state.activeSlice
|
|
202
|
+
const state = await deriveGsdState(basePath);
|
|
203
|
+
if (!state.activeMilestone || !state.activeSlice)
|
|
177
204
|
return;
|
|
178
205
|
// Write checkpoint for ALL phases, not just "executing" — discuss, research,
|
|
179
206
|
// and planning also carry in-memory state (user answers, gate verification)
|
|
@@ -189,21 +216,30 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
189
216
|
if (await loadFile(legacyContinue))
|
|
190
217
|
return;
|
|
191
218
|
const continuePath = join(sliceDir, `${state.activeSlice.id}-CONTINUE.md`);
|
|
219
|
+
const taskId = state.activeTask?.id ?? "none";
|
|
220
|
+
const taskTitle = state.activeTask?.title ?? "";
|
|
221
|
+
const phaseLabel = state.phase.replace(/-/g, " ");
|
|
192
222
|
await saveFile(continuePath, formatContinue({
|
|
193
223
|
frontmatter: {
|
|
194
224
|
milestone: state.activeMilestone.id,
|
|
195
225
|
slice: state.activeSlice.id,
|
|
196
|
-
task:
|
|
226
|
+
task: taskId,
|
|
197
227
|
step: 0,
|
|
198
228
|
totalSteps: 0,
|
|
199
229
|
status: "compacted",
|
|
200
230
|
savedAt: new Date().toISOString(),
|
|
201
231
|
},
|
|
202
|
-
completedWork:
|
|
203
|
-
|
|
232
|
+
completedWork: state.activeTask
|
|
233
|
+
? `Task ${taskId} (${taskTitle}) was in progress when compaction occurred.`
|
|
234
|
+
: `Slice ${state.activeSlice.id} was in ${phaseLabel} phase when compaction occurred.`,
|
|
235
|
+
remainingWork: state.activeTask
|
|
236
|
+
? "Check the task plan for remaining steps."
|
|
237
|
+
: "Continue this slice from the latest planning/research/discussion artifacts.",
|
|
204
238
|
decisions: "Check task summary files for prior decisions.",
|
|
205
239
|
context: "Session was auto-compacted by Pi. Resume with /gsd.",
|
|
206
|
-
nextAction:
|
|
240
|
+
nextAction: state.activeTask
|
|
241
|
+
? `Resume task ${taskId}: ${taskTitle}.`
|
|
242
|
+
: `Resume ${phaseLabel} work for slice ${state.activeSlice.id}.`,
|
|
207
243
|
}));
|
|
208
244
|
});
|
|
209
245
|
// Context-mode snapshot: write .gsd/last-snapshot.md before compaction so
|
|
@@ -225,7 +261,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
225
261
|
const basePath = process.cwd();
|
|
226
262
|
let activeContext = null;
|
|
227
263
|
try {
|
|
228
|
-
const state = await
|
|
264
|
+
const state = await deriveGsdState(basePath);
|
|
229
265
|
if (state.activeMilestone && state.activeSlice && state.activeTask) {
|
|
230
266
|
activeContext =
|
|
231
267
|
`Active: ${state.activeMilestone.id} / ${state.activeSlice.id} / ${state.activeTask.id}` +
|
|
@@ -242,6 +278,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
242
278
|
}
|
|
243
279
|
});
|
|
244
280
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
281
|
+
const { isParallelActive, shutdownParallel } = await import("../parallel-orchestrator.js");
|
|
245
282
|
if (isParallelActive()) {
|
|
246
283
|
try {
|
|
247
284
|
await shutdownParallel(process.cwd());
|
|
@@ -252,7 +289,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
252
289
|
}
|
|
253
290
|
if (!isAutoActive() && !isAutoPaused())
|
|
254
291
|
return;
|
|
255
|
-
const dash =
|
|
292
|
+
const dash = getAutoRuntimeSnapshot();
|
|
256
293
|
if (dash.currentUnit) {
|
|
257
294
|
saveActivityLog(ctx, dash.basePath, dash.currentUnit.type, dash.currentUnit.id);
|
|
258
295
|
}
|
|
@@ -278,7 +315,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
278
315
|
// If ask_user_questions was called with a gate ID but hasn't been confirmed,
|
|
279
316
|
// block all non-read-only tool calls to prevent the model from skipping gates.
|
|
280
317
|
if (getPendingGate()) {
|
|
281
|
-
const milestoneId =
|
|
318
|
+
const milestoneId = await getDiscussionMilestoneIdFor(discussionBasePath);
|
|
282
319
|
if (isToolCallEventType("bash", event)) {
|
|
283
320
|
const bashGuard = shouldBlockPendingGateBash(event.input.command, milestoneId, isQueuePhaseActive());
|
|
284
321
|
if (bashGuard.block)
|
|
@@ -309,6 +346,32 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
309
346
|
if (queueGuard.block)
|
|
310
347
|
return queueGuard;
|
|
311
348
|
}
|
|
349
|
+
// ── Planning-unit tools-policy enforcement (#4934): runtime half ─────
|
|
350
|
+
// The active auto-mode unit's manifest declares a ToolsPolicy. For
|
|
351
|
+
// planning/docs/read-only modes, deny writes outside .gsd/ (or the
|
|
352
|
+
// manifest's allowedPathGlobs), bash that isn't read-only, and
|
|
353
|
+
// subagent dispatch. Closes the b23 bug class where a discuss-milestone
|
|
354
|
+
// turn used the host Edit tool to modify user source files.
|
|
355
|
+
const dash = getAutoRuntimeSnapshot();
|
|
356
|
+
const activeUnitType = dash.currentUnit?.type;
|
|
357
|
+
if (activeUnitType) {
|
|
358
|
+
const manifest = resolveManifest(activeUnitType);
|
|
359
|
+
if (manifest) {
|
|
360
|
+
let planningInput = "";
|
|
361
|
+
if (isToolCallEventType("write", event)) {
|
|
362
|
+
planningInput = event.input.path;
|
|
363
|
+
}
|
|
364
|
+
else if (isToolCallEventType("edit", event)) {
|
|
365
|
+
planningInput = event.input.path;
|
|
366
|
+
}
|
|
367
|
+
else if (isToolCallEventType("bash", event)) {
|
|
368
|
+
planningInput = event.input.command;
|
|
369
|
+
}
|
|
370
|
+
const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || discussionBasePath, activeUnitType, manifest.tools);
|
|
371
|
+
if (planningGuard.block)
|
|
372
|
+
return planningGuard;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
312
375
|
// ── Single-writer engine: block direct writes to STATE.md ──────────
|
|
313
376
|
// Covers write, edit, and bash tools to prevent bypass vectors.
|
|
314
377
|
if (isToolCallEventType("write", event)) {
|
|
@@ -328,7 +391,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
328
391
|
}
|
|
329
392
|
if (!isToolCallEventType("write", event))
|
|
330
393
|
return;
|
|
331
|
-
const result = shouldBlockContextWrite(event.toolName, event.input.path,
|
|
394
|
+
const result = shouldBlockContextWrite(event.toolName, event.input.path, await getDiscussionMilestoneIdFor(discussionBasePath), isQueuePhaseActive());
|
|
332
395
|
if (result.block)
|
|
333
396
|
return result;
|
|
334
397
|
});
|
|
@@ -368,7 +431,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
368
431
|
}
|
|
369
432
|
if (event.toolName !== "ask_user_questions")
|
|
370
433
|
return;
|
|
371
|
-
const milestoneId =
|
|
434
|
+
const milestoneId = await getDiscussionMilestoneIdFor(process.cwd());
|
|
372
435
|
const queueActive = isQueuePhaseActive();
|
|
373
436
|
const details = event.details;
|
|
374
437
|
// ── Discussion gate enforcement: handle gate question responses ──
|
|
@@ -464,7 +527,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
464
527
|
safetyRecordToolResult(event.toolCallId, event.toolName, event.result, event.isError);
|
|
465
528
|
// Persist evidence to disk after each tool result so it survives a session
|
|
466
529
|
// restart mid-unit (Bug #4385 — non-persisted evidence false positives).
|
|
467
|
-
const dash =
|
|
530
|
+
const dash = getAutoRuntimeSnapshot();
|
|
468
531
|
if (dash.basePath && dash.currentUnit?.type === "execute-task") {
|
|
469
532
|
const { milestone: pMid, slice: pSid, task: pTid } = parseUnitId(dash.currentUnit.id);
|
|
470
533
|
if (pMid && pSid && pTid) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { Key } from "@gsd/pi-tui";
|
|
4
|
-
import { GSDDashboardOverlay } from "../dashboard-overlay.js";
|
|
5
|
-
import { GSDNotificationOverlay } from "../notification-overlay.js";
|
|
6
|
-
import { ParallelMonitorOverlay } from "../parallel-monitor-overlay.js";
|
|
7
4
|
import { GSD_SHORTCUTS } from "../shortcut-defs.js";
|
|
8
|
-
import { projectRoot } from "../commands/context.js";
|
|
9
5
|
import { shortcutDesc } from "../../shared/mod.js";
|
|
6
|
+
async function getProjectRoot() {
|
|
7
|
+
const { projectRoot } = await import("../commands/context.js");
|
|
8
|
+
return projectRoot();
|
|
9
|
+
}
|
|
10
10
|
export function registerShortcuts(pi) {
|
|
11
11
|
const overlayOptions = {
|
|
12
12
|
width: "90%",
|
|
@@ -15,7 +15,10 @@ export function registerShortcuts(pi) {
|
|
|
15
15
|
anchor: "center",
|
|
16
16
|
};
|
|
17
17
|
const openDashboardOverlay = async (ctx) => {
|
|
18
|
-
const basePath =
|
|
18
|
+
const [{ GSDDashboardOverlay }, basePath] = await Promise.all([
|
|
19
|
+
import("../dashboard-overlay.js"),
|
|
20
|
+
getProjectRoot(),
|
|
21
|
+
]);
|
|
19
22
|
if (!existsSync(join(basePath, ".gsd"))) {
|
|
20
23
|
ctx.ui.notify("No .gsd/ directory found. Run /gsd to start.", "info");
|
|
21
24
|
return;
|
|
@@ -26,6 +29,7 @@ export function registerShortcuts(pi) {
|
|
|
26
29
|
});
|
|
27
30
|
};
|
|
28
31
|
const openNotificationsOverlay = async (ctx) => {
|
|
32
|
+
const { GSDNotificationOverlay } = await import("../notification-overlay.js");
|
|
29
33
|
await ctx.ui.custom((tui, theme, _kb, done) => new GSDNotificationOverlay(tui, theme, () => done(true)), {
|
|
30
34
|
overlay: true,
|
|
31
35
|
overlayOptions: {
|
|
@@ -38,12 +42,13 @@ export function registerShortcuts(pi) {
|
|
|
38
42
|
});
|
|
39
43
|
};
|
|
40
44
|
const openParallelOverlay = async (ctx) => {
|
|
41
|
-
const basePath =
|
|
45
|
+
const basePath = await getProjectRoot();
|
|
42
46
|
const parallelDir = join(basePath, ".gsd", "parallel");
|
|
43
47
|
if (!existsSync(parallelDir)) {
|
|
44
48
|
ctx.ui.notify("No parallel workers found. Run /gsd parallel start first.", "info");
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
51
|
+
const { ParallelMonitorOverlay } = await import("../parallel-monitor-overlay.js");
|
|
47
52
|
await ctx.ui.custom((tui, theme, _kb, done) => new ParallelMonitorOverlay(tui, theme, () => done(true), basePath), {
|
|
48
53
|
overlay: true,
|
|
49
54
|
overlayOptions,
|
|
@@ -12,7 +12,7 @@ import { resolveGsdRootFile, resolveSliceFile, resolveSlicePath, resolveTaskFile
|
|
|
12
12
|
import { ensureCodebaseMapFresh, readCodebaseMap } from "../codebase-generator.js";
|
|
13
13
|
import { hasSkillSnapshot, detectNewSkills, formatSkillsXml } from "../skill-discovery.js";
|
|
14
14
|
import { getActiveAutoWorktreeContext } from "../auto-worktree.js";
|
|
15
|
-
import { getActiveWorktreeName, getWorktreeOriginalCwd } from "../worktree-
|
|
15
|
+
import { getActiveWorktreeName, getWorktreeOriginalCwd } from "../worktree-session-state.js";
|
|
16
16
|
import { deriveState } from "../state.js";
|
|
17
17
|
import { formatOverridesSection, formatShortcut, loadActiveOverrides, loadFile, parseContinue, parseSummary } from "../files.js";
|
|
18
18
|
import { toPosixPath } from "../../shared/mod.js";
|
|
@@ -177,24 +177,50 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
177
177
|
const subagentModelBlock = subagentModelConfig
|
|
178
178
|
? `\n\n## Subagent Model\n\nWhen spawning subagents via the \`subagent\` tool, always pass \`model: "${subagentModelConfig.primary}"\` in the tool call parameters. Never omit this — always specify it explicitly.`
|
|
179
179
|
: "";
|
|
180
|
-
|
|
180
|
+
// memoryBlock is FTS-queried against the user prompt and changes per call.
|
|
181
|
+
// Removing it from `fullSystem` keeps the system-prompt cache breakpoint
|
|
182
|
+
// stable across calls — the only scoped goal of this fix. The pi-ai
|
|
183
|
+
// Anthropic adapter additionally cache-marks the last user turn, so the
|
|
184
|
+
// memoryBlock injected via the context message may itself be cached up to
|
|
185
|
+
// that boundary; that's orthogonal and unchanged from prior behavior. The
|
|
186
|
+
// load-bearing win here is preserving the system+tools cache hit. (#5019)
|
|
187
|
+
const fullSystem = `${event.systemPrompt}\n\n[SYSTEM CONTEXT — GSD]\n\n${systemContent}${preferenceBlock}${knowledgeBlock}${codebaseBlock}${newSkillsBlock}${worktreeBlock}${subagentModelBlock}`;
|
|
181
188
|
stopContextTimer({
|
|
182
189
|
systemPromptSize: fullSystem.length,
|
|
183
190
|
injectionSize: injection?.length ?? forensicsInjection?.length ?? 0,
|
|
184
191
|
hasPreferences: preferenceBlock.length > 0,
|
|
185
192
|
hasNewSkills: newSkillsBlock.length > 0,
|
|
186
193
|
});
|
|
187
|
-
|
|
188
|
-
const contextMessage = injection
|
|
189
|
-
? { customType: "gsd-guided-context", content: injection, display: false }
|
|
190
|
-
: forensicsInjection
|
|
191
|
-
? { customType: "gsd-forensics", content: forensicsInjection, display: false }
|
|
192
|
-
: null;
|
|
194
|
+
const contextMessage = buildContextMessage({ memoryBlock, injection, forensicsInjection });
|
|
193
195
|
return {
|
|
194
196
|
systemPrompt: fullSystem,
|
|
195
197
|
...(contextMessage ? { message: contextMessage } : {}),
|
|
196
198
|
};
|
|
197
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Route the per-call dynamic blocks (memory, guided-execute, forensics) into a
|
|
202
|
+
* single user-message context payload so they ride the volatile suffix instead
|
|
203
|
+
* of the cached system prefix. Priority when both memory and an injection are
|
|
204
|
+
* present: guided > forensics > memory-only. (#5019)
|
|
205
|
+
*
|
|
206
|
+
* Exported for direct unit testing — the surrounding bootstrap has too many
|
|
207
|
+
* filesystem and DB dependencies to exercise this routing logic in-place.
|
|
208
|
+
*/
|
|
209
|
+
export function buildContextMessage(opts) {
|
|
210
|
+
const memoryContent = opts.memoryBlock.trim();
|
|
211
|
+
if (opts.injection) {
|
|
212
|
+
const content = memoryContent ? `${memoryContent}\n\n${opts.injection}` : opts.injection;
|
|
213
|
+
return { customType: "gsd-guided-context", content, display: false };
|
|
214
|
+
}
|
|
215
|
+
if (opts.forensicsInjection) {
|
|
216
|
+
const content = memoryContent ? `${memoryContent}\n\n${opts.forensicsInjection}` : opts.forensicsInjection;
|
|
217
|
+
return { customType: "gsd-forensics", content, display: false };
|
|
218
|
+
}
|
|
219
|
+
if (memoryContent) {
|
|
220
|
+
return { customType: "gsd-memory", content: memoryContent, display: false };
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
198
224
|
/**
|
|
199
225
|
* ADR-013 step 4 — auto-injection parity for the memories table.
|
|
200
226
|
*
|