gsd-pi 2.70.0 → 2.70.1-dev.3e19108
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/dist/loader.js +4 -0
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +152 -2
- package/dist/resources/extensions/gsd/auto-model-selection.js +33 -19
- package/dist/resources/extensions/gsd/auto-prompts.js +7 -3
- package/dist/resources/extensions/gsd/auto-start.js +28 -12
- package/dist/resources/extensions/gsd/auto.js +12 -8
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +4 -0
- package/dist/resources/extensions/gsd/commands-handlers.js +22 -8
- package/dist/resources/extensions/gsd/doctor-engine-checks.js +12 -0
- package/dist/resources/extensions/gsd/doctor-format.js +2 -0
- package/dist/resources/extensions/gsd/guided-flow.js +33 -20
- package/dist/resources/extensions/gsd/init-wizard.js +3 -11
- package/dist/resources/extensions/gsd/pre-execution-checks.js +5 -3
- package/dist/resources/extensions/gsd/prompts/discuss.md +31 -13
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +34 -0
- package/dist/resources/extensions/gsd/validate-directory.js +30 -12
- package/dist/resources/extensions/gsd/workflow-mcp-auto-prep.js +56 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +12 -1
- package/dist/resources/extensions/slash-commands/audit.js +2 -1
- package/dist/resources/extensions/subagent/isolation.js +4 -2
- package/dist/update-check.d.ts +1 -0
- package/dist/update-check.js +30 -27
- package/dist/update-cmd.js +3 -11
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
- package/dist/web/standalone/.next/build-manifest.json +4 -4
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- 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.js +2 -2
- 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 +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- 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 +3 -3
- 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/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- 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 +4 -4
- 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 +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
- package/dist/web/standalone/.next/server/chunks/63.js +3 -3
- package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware.js +2 -2
- package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-manifest.json +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/static/chunks/2826.dd3dc8bbd3025fa5.js +9 -0
- package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-f1e30ab6bb269149.js +1 -0
- package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-6e4d7e9a4f57bed4.js → webpack-b868033a5834586d.js} +1 -1
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
- package/dist/web/standalone/server.js +1 -1
- package/dist/web-mode.js +4 -0
- package/package.json +11 -11
- package/packages/mcp-server/dist/env-writer.d.ts +39 -0
- package/packages/mcp-server/dist/env-writer.d.ts.map +1 -0
- package/packages/mcp-server/dist/env-writer.js +158 -0
- package/packages/mcp-server/dist/env-writer.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +11 -2
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +102 -2
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts +2 -0
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +35 -3
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/env-writer.test.ts +280 -0
- package/packages/mcp-server/src/env-writer.ts +183 -0
- package/packages/mcp-server/src/import-candidates.test.ts +48 -0
- package/packages/mcp-server/src/secure-env-collect.test.ts +265 -0
- package/packages/mcp-server/src/server.ts +137 -3
- package/packages/mcp-server/src/workflow-tools.ts +34 -1
- package/packages/pi-agent-core/dist/agent.d.ts +8 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +3 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/src/agent.test.ts +82 -0
- package/packages/pi-agent-core/src/agent.ts +12 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +133 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.js +38 -15
- package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +10 -0
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +58 -21
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +3 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +152 -0
- package/packages/pi-coding-agent/src/core/lsp/config.ts +43 -17
- package/packages/pi-coding-agent/src/core/sdk.ts +8 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +83 -27
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +7 -5
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +229 -2
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +205 -0
- package/src/resources/extensions/gsd/auto-model-selection.ts +39 -25
- package/src/resources/extensions/gsd/auto-prompts.ts +7 -3
- package/src/resources/extensions/gsd/auto-start.ts +37 -14
- package/src/resources/extensions/gsd/auto.ts +12 -8
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +4 -0
- package/src/resources/extensions/gsd/commands-handlers.ts +22 -7
- package/src/resources/extensions/gsd/doctor-engine-checks.ts +14 -0
- package/src/resources/extensions/gsd/doctor-format.ts +1 -0
- package/src/resources/extensions/gsd/doctor-types.ts +1 -0
- package/src/resources/extensions/gsd/guided-flow.ts +36 -17
- package/src/resources/extensions/gsd/init-wizard.ts +3 -13
- package/src/resources/extensions/gsd/pre-execution-checks.ts +6 -3
- package/src/resources/extensions/gsd/prompts/discuss.md +31 -13
- package/src/resources/extensions/gsd/tests/discuss-incremental-persistence.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +207 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +48 -1
- package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +8 -7
- package/src/resources/extensions/gsd/tests/validate-directory.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +87 -1
- package/src/resources/extensions/gsd/tests/workflow-mcp-auto-prep.test.ts +76 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +180 -1
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +22 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +60 -25
- package/src/resources/extensions/gsd/validate-directory.ts +33 -11
- package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +76 -0
- package/src/resources/extensions/gsd/workflow-mcp.ts +16 -1
- package/src/resources/extensions/slash-commands/audit.ts +2 -1
- package/src/resources/extensions/subagent/isolation.ts +4 -3
- package/dist/web/standalone/.next/static/chunks/2826.821e01b07d92e948.js +0 -9
- package/dist/web/standalone/.next/static/chunks/app/page-7115e62689b5fd84.js +0 -1
- package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
- /package/dist/web/standalone/.next/static/{Nl6lg7zP5dNgNBV1107v1 → cHCEWiRJM5bXJa9HkP1QU}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{Nl6lg7zP5dNgNBV1107v1 → cHCEWiRJM5bXJa9HkP1QU}/_ssgManifest.js +0 -0
package/dist/loader.js
CHANGED
|
@@ -93,6 +93,10 @@ if (!existsSync(appRoot)) {
|
|
|
93
93
|
}
|
|
94
94
|
// GSD_CODING_AGENT_DIR — tells pi's getAgentDir() to return ~/.gsd/agent/ instead of ~/.gsd/agent/
|
|
95
95
|
process.env.GSD_CODING_AGENT_DIR = agentDir;
|
|
96
|
+
// GSD_PKG_ROOT — absolute path to gsd-pi package root. Used by deployed extensions
|
|
97
|
+
// (e.g. auto.ts resume path) to import modules like resource-loader.js that live
|
|
98
|
+
// in the package tree, not in the deployed ~/.gsd/agent/ tree.
|
|
99
|
+
process.env.GSD_PKG_ROOT = gsdRoot;
|
|
96
100
|
// RTK environment — make ~/.gsd/agent/bin visible to all child-process paths,
|
|
97
101
|
// not just the bash tool, and force-disable RTK telemetry for GSD-managed use.
|
|
98
102
|
applyRtkProcessEnv(process.env);
|
|
@@ -10,6 +10,8 @@ import { EventStream } from "@gsd/pi-ai";
|
|
|
10
10
|
import { execSync } from "node:child_process";
|
|
11
11
|
import { PartialMessageBuilder, ZERO_USAGE, mapUsage } from "./partial-builder.js";
|
|
12
12
|
import { buildWorkflowMcpServers } from "../gsd/workflow-mcp.js";
|
|
13
|
+
import { showInterviewRound } from "../shared/tui.js";
|
|
14
|
+
const OTHER_OPTION_LABEL = "None of the above";
|
|
13
15
|
// ---------------------------------------------------------------------------
|
|
14
16
|
// Stream factory
|
|
15
17
|
// ---------------------------------------------------------------------------
|
|
@@ -124,6 +126,147 @@ export function makeStreamExhaustedErrorMessage(model, lastTextContent) {
|
|
|
124
126
|
}
|
|
125
127
|
return message;
|
|
126
128
|
}
|
|
129
|
+
function readElicitationChoices(options) {
|
|
130
|
+
if (!Array.isArray(options))
|
|
131
|
+
return [];
|
|
132
|
+
return options
|
|
133
|
+
.map((option) => (typeof option?.const === "string" ? option.const : typeof option?.title === "string" ? option.title : ""))
|
|
134
|
+
.filter((option) => option.length > 0);
|
|
135
|
+
}
|
|
136
|
+
export function parseAskUserQuestionsElicitation(request) {
|
|
137
|
+
if (request.mode && request.mode !== "form")
|
|
138
|
+
return null;
|
|
139
|
+
const properties = request.requestedSchema?.properties;
|
|
140
|
+
if (!properties || typeof properties !== "object")
|
|
141
|
+
return null;
|
|
142
|
+
const questions = [];
|
|
143
|
+
for (const [fieldId, rawField] of Object.entries(properties)) {
|
|
144
|
+
if (fieldId.endsWith("__note"))
|
|
145
|
+
continue;
|
|
146
|
+
if (!rawField || typeof rawField !== "object")
|
|
147
|
+
return null;
|
|
148
|
+
const header = typeof rawField.title === "string" && rawField.title.length > 0 ? rawField.title : fieldId;
|
|
149
|
+
const question = typeof rawField.description === "string" ? rawField.description : "";
|
|
150
|
+
if (rawField.type === "array") {
|
|
151
|
+
const options = readElicitationChoices(rawField.items?.anyOf).map((label) => ({ label, description: "" }));
|
|
152
|
+
if (options.length === 0)
|
|
153
|
+
return null;
|
|
154
|
+
questions.push({
|
|
155
|
+
id: fieldId,
|
|
156
|
+
header,
|
|
157
|
+
question,
|
|
158
|
+
options,
|
|
159
|
+
allowMultiple: true,
|
|
160
|
+
});
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (rawField.type === "string") {
|
|
164
|
+
const noteFieldId = Object.prototype.hasOwnProperty.call(properties, `${fieldId}__note`)
|
|
165
|
+
? `${fieldId}__note`
|
|
166
|
+
: undefined;
|
|
167
|
+
const options = readElicitationChoices(rawField.oneOf)
|
|
168
|
+
.filter((label) => label !== OTHER_OPTION_LABEL)
|
|
169
|
+
.map((label) => ({ label, description: "" }));
|
|
170
|
+
if (options.length === 0)
|
|
171
|
+
return null;
|
|
172
|
+
questions.push({
|
|
173
|
+
id: fieldId,
|
|
174
|
+
header,
|
|
175
|
+
question,
|
|
176
|
+
options,
|
|
177
|
+
noteFieldId,
|
|
178
|
+
});
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return questions.length > 0 ? questions : null;
|
|
184
|
+
}
|
|
185
|
+
export function roundResultToElicitationContent(questions, result) {
|
|
186
|
+
const content = {};
|
|
187
|
+
for (const question of questions) {
|
|
188
|
+
const answer = result.answers[question.id];
|
|
189
|
+
if (!answer)
|
|
190
|
+
continue;
|
|
191
|
+
if (question.allowMultiple) {
|
|
192
|
+
const selected = Array.isArray(answer.selected) ? answer.selected : [answer.selected];
|
|
193
|
+
content[question.id] = selected;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const selected = Array.isArray(answer.selected) ? answer.selected[0] ?? "" : answer.selected;
|
|
197
|
+
content[question.id] = selected;
|
|
198
|
+
if (question.noteFieldId && selected === OTHER_OPTION_LABEL && answer.notes.trim().length > 0) {
|
|
199
|
+
content[question.noteFieldId] = answer.notes.trim();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return content;
|
|
203
|
+
}
|
|
204
|
+
function buildElicitationPromptTitle(request, question) {
|
|
205
|
+
const parts = [
|
|
206
|
+
request.serverName ? `[${request.serverName}]` : "",
|
|
207
|
+
question.header,
|
|
208
|
+
question.question,
|
|
209
|
+
].filter((part) => part && part.trim().length > 0);
|
|
210
|
+
return parts.join("\n\n");
|
|
211
|
+
}
|
|
212
|
+
async function promptElicitationWithDialogs(request, questions, ui, signal) {
|
|
213
|
+
const content = {};
|
|
214
|
+
for (const question of questions) {
|
|
215
|
+
const title = buildElicitationPromptTitle(request, question);
|
|
216
|
+
if (question.allowMultiple) {
|
|
217
|
+
const selected = await ui.select(title, question.options.map((option) => option.label), {
|
|
218
|
+
allowMultiple: true,
|
|
219
|
+
signal,
|
|
220
|
+
});
|
|
221
|
+
if (Array.isArray(selected)) {
|
|
222
|
+
if (selected.length === 0)
|
|
223
|
+
return { action: "cancel" };
|
|
224
|
+
content[question.id] = selected;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (typeof selected === "string" && selected.length > 0) {
|
|
228
|
+
content[question.id] = [selected];
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
return { action: "cancel" };
|
|
232
|
+
}
|
|
233
|
+
const selected = await ui.select(title, [...question.options.map((option) => option.label), OTHER_OPTION_LABEL], { signal });
|
|
234
|
+
if (typeof selected !== "string" || selected.length === 0) {
|
|
235
|
+
return { action: "cancel" };
|
|
236
|
+
}
|
|
237
|
+
content[question.id] = selected;
|
|
238
|
+
if (question.noteFieldId && selected === OTHER_OPTION_LABEL) {
|
|
239
|
+
const note = await ui.input(`${question.header} note`, "Explain your answer", { signal });
|
|
240
|
+
if (note === undefined)
|
|
241
|
+
return { action: "cancel" };
|
|
242
|
+
if (note.trim().length > 0) {
|
|
243
|
+
content[question.noteFieldId] = note.trim();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return { action: "accept", content };
|
|
248
|
+
}
|
|
249
|
+
export function createClaudeCodeElicitationHandler(ui) {
|
|
250
|
+
if (!ui)
|
|
251
|
+
return undefined;
|
|
252
|
+
return async (request, { signal }) => {
|
|
253
|
+
if (request.mode === "url") {
|
|
254
|
+
return { action: "decline" };
|
|
255
|
+
}
|
|
256
|
+
const questions = parseAskUserQuestionsElicitation(request);
|
|
257
|
+
if (!questions) {
|
|
258
|
+
return { action: "decline" };
|
|
259
|
+
}
|
|
260
|
+
const interviewResult = await showInterviewRound(questions, { signal }, { ui }).catch(() => undefined);
|
|
261
|
+
if (interviewResult && Object.keys(interviewResult.answers).length > 0) {
|
|
262
|
+
return {
|
|
263
|
+
action: "accept",
|
|
264
|
+
content: roundResultToElicitationContent(questions, interviewResult),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return promptElicitationWithDialogs(request, questions, ui, signal);
|
|
268
|
+
};
|
|
269
|
+
}
|
|
127
270
|
// ---------------------------------------------------------------------------
|
|
128
271
|
// SDK options builder
|
|
129
272
|
// ---------------------------------------------------------------------------
|
|
@@ -133,8 +276,9 @@ export function makeStreamExhaustedErrorMessage(model, lastTextContent) {
|
|
|
133
276
|
* Extracted for testability — callers can verify session persistence,
|
|
134
277
|
* beta flags, and other configuration without mocking the full SDK.
|
|
135
278
|
*/
|
|
136
|
-
export function buildSdkOptions(modelId, prompt) {
|
|
279
|
+
export function buildSdkOptions(modelId, prompt, extraOptions = {}) {
|
|
137
280
|
const mcpServers = buildWorkflowMcpServers();
|
|
281
|
+
const disallowedTools = ["AskUserQuestion"];
|
|
138
282
|
return {
|
|
139
283
|
pathToClaudeCodeExecutable: getClaudePath(),
|
|
140
284
|
model: modelId,
|
|
@@ -145,8 +289,10 @@ export function buildSdkOptions(modelId, prompt) {
|
|
|
145
289
|
allowDangerouslySkipPermissions: true,
|
|
146
290
|
settingSources: ["project"],
|
|
147
291
|
systemPrompt: { type: "preset", preset: "claude_code" },
|
|
292
|
+
disallowedTools,
|
|
148
293
|
...(mcpServers ? { mcpServers } : {}),
|
|
149
294
|
betas: modelId.includes("sonnet") ? ["context-1m-2025-08-07"] : [],
|
|
295
|
+
...extraOptions,
|
|
150
296
|
};
|
|
151
297
|
}
|
|
152
298
|
function normalizeToolResultContent(content) {
|
|
@@ -272,7 +418,11 @@ async function pumpSdkMessages(model, context, options, stream) {
|
|
|
272
418
|
options.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
273
419
|
}
|
|
274
420
|
const prompt = buildPromptFromContext(context);
|
|
275
|
-
const sdkOpts = buildSdkOptions(modelId, prompt
|
|
421
|
+
const sdkOpts = buildSdkOptions(modelId, prompt, typeof options?.extensionUIContext === "object"
|
|
422
|
+
? {
|
|
423
|
+
onElicitation: createClaudeCodeElicitationHandler(options?.extensionUIContext),
|
|
424
|
+
}
|
|
425
|
+
: {});
|
|
276
426
|
const queryResult = sdk.query({
|
|
277
427
|
prompt,
|
|
278
428
|
options: {
|
|
@@ -8,10 +8,17 @@ import { classifyUnitComplexity, tierLabel } from "./complexity-classifier.js";
|
|
|
8
8
|
import { resolveModelForComplexity, escalateTier, getEligibleModels, loadCapabilityOverrides, adjustToolSet } from "./model-router.js";
|
|
9
9
|
import { getLedger, getProjectTotals } from "./metrics.js";
|
|
10
10
|
import { unitPhaseLabel } from "./auto-dashboard.js";
|
|
11
|
-
export function resolvePreferredModelConfig(unitType, autoModeStartModel
|
|
11
|
+
export function resolvePreferredModelConfig(unitType, autoModeStartModel,
|
|
12
|
+
/** When false, only return explicit per-phase model configs — do not
|
|
13
|
+
* synthesize a routing ceiling from dynamic_routing.tier_models (#3962). */
|
|
14
|
+
isAutoMode = true) {
|
|
12
15
|
const explicitConfig = resolveModelWithFallbacksForUnit(unitType);
|
|
13
16
|
if (explicitConfig)
|
|
14
17
|
return explicitConfig;
|
|
18
|
+
// In interactive mode, don't synthesize a routing-based model config.
|
|
19
|
+
// The user's session model (/model) should be used as-is (#3962).
|
|
20
|
+
if (!isAutoMode)
|
|
21
|
+
return undefined;
|
|
15
22
|
const routingConfig = resolveDynamicRoutingConfig();
|
|
16
23
|
if (!routingConfig.enabled || !routingConfig.tier_models)
|
|
17
24
|
return undefined;
|
|
@@ -34,14 +41,23 @@ export function resolvePreferredModelConfig(unitType, autoModeStartModel) {
|
|
|
34
41
|
*
|
|
35
42
|
* Returns routing metadata for metrics tracking.
|
|
36
43
|
*/
|
|
37
|
-
export async function selectAndApplyModel(ctx, pi, unitType, unitId, basePath, prefs, verbose, autoModeStartModel, retryContext
|
|
38
|
-
|
|
44
|
+
export async function selectAndApplyModel(ctx, pi, unitType, unitId, basePath, prefs, verbose, autoModeStartModel, retryContext,
|
|
45
|
+
/** When false (interactive/guided-flow), skip dynamic routing and use the session model.
|
|
46
|
+
* Dynamic routing only applies in auto-mode where cost optimization is expected. (#3962) */
|
|
47
|
+
isAutoMode = true) {
|
|
48
|
+
const modelConfig = resolvePreferredModelConfig(unitType, autoModeStartModel, isAutoMode);
|
|
39
49
|
let routing = null;
|
|
40
50
|
let appliedModel = null;
|
|
41
51
|
if (modelConfig) {
|
|
42
52
|
const availableModels = ctx.modelRegistry.getAvailable();
|
|
43
53
|
// ─── Dynamic Model Routing ─────────────────────────────────────────
|
|
54
|
+
// Dynamic routing (complexity-based downgrading) only applies in auto-mode.
|
|
55
|
+
// Interactive/guided-flow dispatches use the user's session model directly,
|
|
56
|
+
// respecting their /model selection without silent downgrades (#3962).
|
|
44
57
|
const routingConfig = resolveDynamicRoutingConfig();
|
|
58
|
+
if (!isAutoMode) {
|
|
59
|
+
routingConfig.enabled = false;
|
|
60
|
+
}
|
|
45
61
|
let effectiveModelConfig = modelConfig;
|
|
46
62
|
let routingTierLabel = "";
|
|
47
63
|
// Disable routing for flat-rate providers like GitHub Copilot (#3453).
|
|
@@ -85,9 +101,8 @@ export async function selectAndApplyModel(ctx, pi, unitType, unitId, basePath, p
|
|
|
85
101
|
const escalated = escalateTier(retryContext.previousTier);
|
|
86
102
|
if (escalated) {
|
|
87
103
|
classification = { ...classification, tier: escalated, reason: "escalated after failure" };
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
104
|
+
// Always notify on tier escalation — model changes should be visible (#3962)
|
|
105
|
+
ctx.ui.notify(`Tier escalation: ${retryContext.previousTier} → ${escalated} (retry after failure)`, "info");
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
// Load user capability overrides from preferences (D-17: deep-merged with built-in profiles)
|
|
@@ -139,19 +154,18 @@ export async function selectAndApplyModel(ctx, pi, unitType, unitId, basePath, p
|
|
|
139
154
|
primary: routingResult.modelId,
|
|
140
155
|
fallbacks: routingResult.fallbacks,
|
|
141
156
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
157
|
+
// Always notify on model downgrade — users should see when their
|
|
158
|
+
// model selection is overridden, not just in verbose mode (#3962).
|
|
159
|
+
if (routingResult.selectionMethod === "capability-scored" && routingResult.capabilityScores) {
|
|
160
|
+
const tierLbl = tierLabel(classification.tier);
|
|
161
|
+
const scores = Object.entries(routingResult.capabilityScores)
|
|
162
|
+
.sort(([, a], [, b]) => b - a)
|
|
163
|
+
.map(([id, score]) => `${id}: ${score.toFixed(1)}`)
|
|
164
|
+
.join(", ");
|
|
165
|
+
ctx.ui.notify(`Dynamic routing [${tierLbl}]: ${routingResult.modelId} (capability-scored) — ${scores}`, "info");
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
ctx.ui.notify(`Dynamic routing [${tierLabel(classification.tier)}]: ${routingResult.modelId} (${classification.reason})`, "info");
|
|
155
169
|
}
|
|
156
170
|
}
|
|
157
171
|
routingTierLabel = ` [${tierLabel(classification.tier)}]`;
|
|
@@ -876,7 +876,7 @@ export async function buildDiscussMilestonePrompt(mid, midTitle, base) {
|
|
|
876
876
|
milestoneId: mid,
|
|
877
877
|
milestoneTitle: midTitle,
|
|
878
878
|
inlinedTemplates: discussTemplates,
|
|
879
|
-
structuredQuestionsAvailable: "
|
|
879
|
+
structuredQuestionsAvailable: "false",
|
|
880
880
|
commitInstruction: "Do not commit planning artifacts — .gsd/ is managed externally.",
|
|
881
881
|
fastPathInstruction: "",
|
|
882
882
|
});
|
|
@@ -1319,7 +1319,9 @@ export async function buildCompleteMilestonePrompt(mid, midTitle, base, level) {
|
|
|
1319
1319
|
try {
|
|
1320
1320
|
const { isDbAvailable, getMilestoneSlices } = await import("./gsd-db.js");
|
|
1321
1321
|
if (isDbAvailable()) {
|
|
1322
|
-
sliceIds = getMilestoneSlices(mid)
|
|
1322
|
+
sliceIds = getMilestoneSlices(mid)
|
|
1323
|
+
.filter(s => s.status !== "skipped")
|
|
1324
|
+
.map(s => s.id);
|
|
1323
1325
|
}
|
|
1324
1326
|
}
|
|
1325
1327
|
catch (err) {
|
|
@@ -1415,7 +1417,9 @@ export async function buildValidateMilestonePrompt(mid, midTitle, base, level) {
|
|
|
1415
1417
|
try {
|
|
1416
1418
|
const { isDbAvailable, getMilestoneSlices } = await import("./gsd-db.js");
|
|
1417
1419
|
if (isDbAvailable()) {
|
|
1418
|
-
valSliceIds = getMilestoneSlices(mid)
|
|
1420
|
+
valSliceIds = getMilestoneSlices(mid)
|
|
1421
|
+
.filter(s => s.status !== "skipped")
|
|
1422
|
+
.map(s => s.id);
|
|
1419
1423
|
}
|
|
1420
1424
|
}
|
|
1421
1425
|
catch (err) {
|
|
@@ -38,7 +38,7 @@ import { existsSync, mkdirSync, readdirSync, rmSync, statSync, unlinkSync, } fro
|
|
|
38
38
|
import { join } from "node:path";
|
|
39
39
|
import { sep as pathSep } from "node:path";
|
|
40
40
|
import { resolveProjectRootDbPath } from "./bootstrap/dynamic-tools.js";
|
|
41
|
-
import { resolveDefaultSessionModel } from "./preferences-models.js";
|
|
41
|
+
import { resolveDefaultSessionModel, resolveDynamicRoutingConfig } from "./preferences-models.js";
|
|
42
42
|
/**
|
|
43
43
|
* Bootstrap a fresh auto-mode session. Handles everything from git init
|
|
44
44
|
* through secrets collection, returning when ready for the first
|
|
@@ -248,17 +248,9 @@ export async function bootstrapAutoSession(s, ctx, pi, base, verboseMode, reques
|
|
|
248
248
|
logWarning("engine", `mkdir failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const result = ensureProjectWorkflowMcpConfig(base);
|
|
255
|
-
if (result.status !== "unchanged") {
|
|
256
|
-
ctx.ui.notify(`Claude Code MCP prepared at ${result.configPath}`, "info");
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
catch (err) {
|
|
260
|
-
ctx.ui.notify(`Claude Code MCP prep failed: ${err instanceof Error ? err.message : String(err)}`, "warning");
|
|
261
|
-
}
|
|
251
|
+
{
|
|
252
|
+
const { prepareWorkflowMcpForProject } = await import("./workflow-mcp-auto-prep.js");
|
|
253
|
+
prepareWorkflowMcpForProject(ctx, base);
|
|
262
254
|
}
|
|
263
255
|
// Initialize GitServiceImpl
|
|
264
256
|
s.gitService = new GitServiceImpl(s.basePath, loadEffectiveGSDPreferences()?.preferences?.git ?? {});
|
|
@@ -609,6 +601,30 @@ export async function bootstrapAutoSession(s, ctx, pi, base, verboseMode, reques
|
|
|
609
601
|
? `Will loop through ${pendingCount} milestones.`
|
|
610
602
|
: "Will loop until milestone complete.";
|
|
611
603
|
ctx.ui.notify(`${modeLabel} started. ${scopeMsg}`, "info");
|
|
604
|
+
// Show dynamic routing status so users know upfront if models will be
|
|
605
|
+
// downgraded for simple tasks (#3962).
|
|
606
|
+
// Use the same effective logic as selectAndApplyModel: check flat-rate
|
|
607
|
+
// provider suppression and resolve the actual ceiling model.
|
|
608
|
+
const routingConfig = resolveDynamicRoutingConfig();
|
|
609
|
+
const startModelLabel = s.autoModeStartModel
|
|
610
|
+
? `${s.autoModeStartModel.provider}/${s.autoModeStartModel.id}`
|
|
611
|
+
: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : "default";
|
|
612
|
+
// Flat-rate providers (e.g. GitHub Copilot, claude-code) suppress routing
|
|
613
|
+
// at dispatch time (#3453) — reflect that in the banner.
|
|
614
|
+
const { isFlatRateProvider } = await import("./auto-model-selection.js");
|
|
615
|
+
const effectiveProvider = s.autoModeStartModel?.provider ?? ctx.model?.provider;
|
|
616
|
+
const effectivelyEnabled = routingConfig.enabled
|
|
617
|
+
&& !(effectiveProvider && isFlatRateProvider(effectiveProvider));
|
|
618
|
+
// The actual ceiling may come from tier_models.heavy, not the start model.
|
|
619
|
+
const effectiveCeiling = (routingConfig.enabled && routingConfig.tier_models?.heavy)
|
|
620
|
+
? routingConfig.tier_models.heavy
|
|
621
|
+
: startModelLabel;
|
|
622
|
+
if (effectivelyEnabled) {
|
|
623
|
+
ctx.ui.notify(`Dynamic routing: enabled — simple tasks may use cheaper models (ceiling: ${effectiveCeiling})`, "info");
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
ctx.ui.notify(`Dynamic routing: disabled — all tasks will use ${startModelLabel}`, "info");
|
|
627
|
+
}
|
|
612
628
|
updateSessionLock(lockBase(), "starting", s.currentMilestoneId ?? "unknown");
|
|
613
629
|
writeLock(lockBase(), "starting", s.currentMilestoneId ?? "unknown");
|
|
614
630
|
// Secrets collection gate
|
|
@@ -37,9 +37,9 @@ import { getRtkSessionSavings } from "../shared/rtk-session-stats.js";
|
|
|
37
37
|
import { initMetrics, resetMetrics, getLedger, getProjectTotals, formatCost, formatTokenCount, } from "./metrics.js";
|
|
38
38
|
import { logWarning } from "./workflow-logger.js";
|
|
39
39
|
import { homedir } from "node:os";
|
|
40
|
-
import { join
|
|
40
|
+
import { join } from "node:path";
|
|
41
|
+
import { pathToFileURL } from "node:url";
|
|
41
42
|
import { readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync } from "node:fs";
|
|
42
|
-
import { createRequire } from "node:module";
|
|
43
43
|
import { atomicWriteSync } from "./atomic-write.js";
|
|
44
44
|
import { autoCommitCurrentBranch, captureIntegrationBranch, detectWorktreeName, getCurrentBranch, getMainBranch, setActiveMilestoneId, } from "./worktree.js";
|
|
45
45
|
import { GitServiceImpl } from "./git-service.js";
|
|
@@ -1021,13 +1021,17 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1021
1021
|
restoreHookState(s.basePath);
|
|
1022
1022
|
// Re-sync managed resources on resume so long-lived auto sessions pick up
|
|
1023
1023
|
// bundled extension updates before resume-time verification/state logic runs.
|
|
1024
|
+
// GSD_PKG_ROOT is set by loader.ts and points to the gsd-pi package root.
|
|
1025
|
+
// The relative import ("../../../resource-loader.js") only works from the source
|
|
1026
|
+
// tree; deployed extensions live at ~/.gsd/agent/extensions/gsd/ where the
|
|
1027
|
+
// relative path resolves to ~/.gsd/agent/resource-loader.js which doesn't exist.
|
|
1028
|
+
// Using GSD_PKG_ROOT constructs a correct absolute path in both contexts (#3949).
|
|
1024
1029
|
const agentDir = process.env.GSD_CODING_AGENT_DIR || join(process.env.GSD_HOME || homedir(), ".gsd", "agent");
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
const
|
|
1030
|
-
const { initResources } = await import(join(pkgRoot, "dist", "resource-loader.js"));
|
|
1030
|
+
const pkgRoot = process.env.GSD_PKG_ROOT;
|
|
1031
|
+
const resourceLoaderPath = pkgRoot
|
|
1032
|
+
? pathToFileURL(join(pkgRoot, "dist", "resource-loader.js")).href
|
|
1033
|
+
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
1034
|
+
const { initResources } = await import(resourceLoaderPath);
|
|
1031
1035
|
initResources(agentDir);
|
|
1032
1036
|
// Open the project DB before rebuild/derive so resume uses DB-backed
|
|
1033
1037
|
// state instead of falling back to stale markdown parsing (#2940).
|
|
@@ -39,6 +39,8 @@ export function registerHooks(pi) {
|
|
|
39
39
|
resetToolCallLoopGuard();
|
|
40
40
|
resetAskUserQuestionsCache();
|
|
41
41
|
await syncServiceTierStatus(ctx);
|
|
42
|
+
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
43
|
+
prepareWorkflowMcpForProject(ctx, process.cwd());
|
|
42
44
|
// Apply show_token_cost preference (#1515)
|
|
43
45
|
try {
|
|
44
46
|
const { loadEffectiveGSDPreferences } = await import("../preferences.js");
|
|
@@ -78,6 +80,8 @@ export function registerHooks(pi) {
|
|
|
78
80
|
resetAskUserQuestionsCache();
|
|
79
81
|
clearDiscussionFlowState();
|
|
80
82
|
await syncServiceTierStatus(ctx);
|
|
83
|
+
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
84
|
+
prepareWorkflowMcpForProject(ctx, process.cwd());
|
|
81
85
|
loadToolApiKeys();
|
|
82
86
|
});
|
|
83
87
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
@@ -15,6 +15,26 @@ import { isAutoActive, checkRemoteAutoSession } from "./auto.js";
|
|
|
15
15
|
import { getAutoWorktreePath } from "./auto-worktree.js";
|
|
16
16
|
import { projectRoot } from "./commands/context.js";
|
|
17
17
|
import { loadPrompt } from "./prompt-loader.js";
|
|
18
|
+
const UPDATE_REGISTRY_URL = "https://registry.npmjs.org/gsd-pi/latest";
|
|
19
|
+
const UPDATE_FETCH_TIMEOUT_MS = 5000;
|
|
20
|
+
async function fetchLatestVersionForCommand() {
|
|
21
|
+
const controller = new AbortController();
|
|
22
|
+
const timeout = setTimeout(() => controller.abort(), UPDATE_FETCH_TIMEOUT_MS);
|
|
23
|
+
try {
|
|
24
|
+
const res = await fetch(UPDATE_REGISTRY_URL, { signal: controller.signal });
|
|
25
|
+
if (!res.ok)
|
|
26
|
+
return null;
|
|
27
|
+
const data = (await res.json());
|
|
28
|
+
const latest = typeof data.version === "string" ? data.version.trim().replace(/^v/, "") : "";
|
|
29
|
+
return latest.length > 0 ? latest : null;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
clearTimeout(timeout);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
18
38
|
export function dispatchDoctorHeal(pi, scope, reportText, structuredIssues) {
|
|
19
39
|
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(process.env.HOME ?? "~", ".gsd", "agent", "GSD-WORKFLOW.md");
|
|
20
40
|
const workflow = readFileSync(workflowPath, "utf-8");
|
|
@@ -311,14 +331,8 @@ export async function handleUpdate(ctx) {
|
|
|
311
331
|
const NPM_PACKAGE = "gsd-pi";
|
|
312
332
|
const current = process.env.GSD_VERSION || "0.0.0";
|
|
313
333
|
ctx.ui.notify(`Current version: v${current}\nChecking npm registry...`, "info");
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
latest = execSync(`npm view ${NPM_PACKAGE} version`, {
|
|
317
|
-
encoding: "utf-8",
|
|
318
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
319
|
-
}).trim();
|
|
320
|
-
}
|
|
321
|
-
catch {
|
|
334
|
+
const latest = await fetchLatestVersionForCommand();
|
|
335
|
+
if (!latest) {
|
|
322
336
|
ctx.ui.notify("Failed to reach npm registry. Check your network connection.", "error");
|
|
323
337
|
return;
|
|
324
338
|
}
|
|
@@ -6,6 +6,18 @@ import { deriveState } from "./state.js";
|
|
|
6
6
|
import { readEvents } from "./workflow-events.js";
|
|
7
7
|
import { renderAllProjections } from "./workflow-projections.js";
|
|
8
8
|
export async function checkEngineHealth(basePath, issues, fixesApplied) {
|
|
9
|
+
const dbPath = join(basePath, ".gsd", "gsd.db");
|
|
10
|
+
if (!isDbAvailable() && existsSync(dbPath)) {
|
|
11
|
+
issues.push({
|
|
12
|
+
severity: "warning",
|
|
13
|
+
code: "db_unavailable",
|
|
14
|
+
scope: "project",
|
|
15
|
+
unitId: "project",
|
|
16
|
+
message: "Database unavailable — using filesystem state derivation (degraded mode). State queries may be slower and less reliable.",
|
|
17
|
+
file: ".gsd/gsd.db",
|
|
18
|
+
fixable: false,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
9
21
|
// ── DB constraint violation detection (full doctor only, not pre-dispatch per D-10) ──
|
|
10
22
|
try {
|
|
11
23
|
if (isDbAvailable()) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
function matchesScope(unitId, scope) {
|
|
2
2
|
if (!scope)
|
|
3
3
|
return true;
|
|
4
|
+
if (unitId === "project" || unitId === "environment")
|
|
5
|
+
return true;
|
|
4
6
|
return unitId === scope || unitId.startsWith(`${scope}/`) || unitId.startsWith(`${scope}`);
|
|
5
7
|
}
|
|
6
8
|
export function summarizeDoctorIssues(issues) {
|