gsd-pi 2.74.0-dev.28a6415 → 2.74.0-dev.658744a
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/resources/extensions/gsd/auto/phases.js +51 -6
- package/dist/resources/extensions/gsd/auto-model-selection.js +3 -3
- package/dist/resources/extensions/gsd/auto-post-unit.js +7 -3
- package/dist/resources/extensions/gsd/auto-recovery.js +24 -10
- package/dist/resources/extensions/gsd/auto-worktree.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/provider-error-resume.js +5 -3
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +10 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +61 -9
- package/dist/resources/extensions/gsd/cache.js +16 -5
- package/dist/resources/extensions/gsd/commands/catalog.js +6 -1
- package/dist/resources/extensions/gsd/commands/handlers/core.js +5 -1
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +50 -3
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +2 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +144 -0
- package/dist/resources/extensions/gsd/ecosystem/loader.js +145 -0
- package/dist/resources/extensions/gsd/guided-flow.js +8 -6
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +10 -0
- package/dist/resources/extensions/gsd/preferences.js +5 -0
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +15 -30
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -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 +13 -13
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- 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.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/onboarding/route.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/resize/route.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/stream/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- 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-paths-manifest.json +13 -13
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- 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/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/package.json +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +88 -6
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/workflow-tools.ts +95 -10
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/index.d.ts +1 -9
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +1 -9
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/models/capability-patches.d.ts +19 -0
- package/packages/pi-ai/dist/models/capability-patches.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/capability-patches.js +36 -0
- package/packages/pi-ai/dist/models/capability-patches.js.map +1 -0
- package/packages/pi-ai/dist/{models.custom.d.ts → models/custom.d.ts} +1 -1
- package/packages/pi-ai/dist/models/custom.d.ts.map +1 -0
- package/packages/pi-ai/dist/{models.custom.js → models/custom.js} +4 -4
- package/packages/pi-ai/dist/models/custom.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts +1482 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js +1484 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts +377 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js +379 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js +702 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts +71 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js +73 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts +590 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js +444 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts +156 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js +158 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js +107 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts +207 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js +209 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts +462 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.js +464 -0
- package/packages/pi-ai/dist/models/generated/google.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts +309 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.js +311 -0
- package/packages/pi-ai/dist/models/generated/groq.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts +383 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js +347 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js.map +1 -0
- package/packages/pi-ai/dist/{models.generated.d.ts → models/generated/index.d.ts} +1 -1
- package/packages/pi-ai/dist/{models.generated.d.ts.map → models/generated/index.d.ts.map} +1 -1
- package/packages/pi-ai/dist/models/generated/index.js +51 -0
- package/packages/pi-ai/dist/models/generated/index.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts +37 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js +39 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts +445 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.js +447 -0
- package/packages/pi-ai/dist/models/generated/mistral.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts +139 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js +141 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.js +702 -0
- package/packages/pi-ai/dist/models/generated/openai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts +122 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js +124 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts +530 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.js +532 -0
- package/packages/pi-ai/dist/models/generated/opencode.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts +4270 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js +4272 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts +2604 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js +2606 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts +411 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.js +413 -0
- package/packages/pi-ai/dist/models/generated/xai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts +276 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.js +239 -0
- package/packages/pi-ai/dist/models/generated/zai.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts +27 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/index.js +80 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -0
- package/packages/pi-ai/dist/models.d.ts +1 -36
- package/packages/pi-ai/dist/models.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.test.js +1 -2
- package/packages/pi-ai/dist/models.generated.test.js.map +1 -1
- package/packages/pi-ai/dist/models.js +3 -112
- package/packages/pi-ai/dist/models.js.map +1 -1
- package/packages/pi-ai/dist/models.test.js +6 -5
- package/packages/pi-ai/dist/models.test.js.map +1 -1
- package/packages/pi-ai/scripts/generate-models.ts +74 -40
- package/packages/pi-ai/src/index.ts +1 -9
- package/packages/pi-ai/src/models/capability-patches.ts +40 -0
- package/packages/pi-ai/src/{models.custom.ts → models/custom.ts} +4 -4
- package/packages/pi-ai/src/models/generated/amazon-bedrock.ts +1486 -0
- package/packages/pi-ai/src/models/generated/anthropic.ts +381 -0
- package/packages/pi-ai/src/models/generated/azure-openai-responses.ts +704 -0
- package/packages/pi-ai/src/models/generated/cerebras.ts +75 -0
- package/packages/pi-ai/src/models/generated/github-copilot.ts +446 -0
- package/packages/pi-ai/src/models/generated/google-antigravity.ts +160 -0
- package/packages/pi-ai/src/models/generated/google-gemini-cli.ts +109 -0
- package/packages/pi-ai/src/models/generated/google-vertex.ts +211 -0
- package/packages/pi-ai/src/models/generated/google.ts +466 -0
- package/packages/pi-ai/src/models/generated/groq.ts +313 -0
- package/packages/pi-ai/src/models/generated/huggingface.ts +349 -0
- package/packages/pi-ai/src/models/generated/index.ts +52 -0
- package/packages/pi-ai/src/models/generated/kimi-coding.ts +41 -0
- package/packages/pi-ai/src/models/generated/minimax-cn.ts +109 -0
- package/packages/pi-ai/src/models/generated/minimax.ts +109 -0
- package/packages/pi-ai/src/models/generated/mistral.ts +449 -0
- package/packages/pi-ai/src/models/generated/openai-codex.ts +143 -0
- package/packages/pi-ai/src/models/generated/openai.ts +704 -0
- package/packages/pi-ai/src/models/generated/opencode-go.ts +126 -0
- package/packages/pi-ai/src/models/generated/opencode.ts +534 -0
- package/packages/pi-ai/src/models/generated/openrouter.ts +4274 -0
- package/packages/pi-ai/src/models/generated/vercel-ai-gateway.ts +2608 -0
- package/packages/pi-ai/src/models/generated/xai.ts +415 -0
- package/packages/pi-ai/src/models/generated/zai.ts +241 -0
- package/packages/pi-ai/src/models/index.ts +106 -0
- package/packages/pi-ai/src/models.generated.test.ts +1 -2
- package/packages/pi-ai/src/models.test.ts +6 -5
- package/packages/pi-ai/src/models.ts +3 -153
- 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 +8 -2
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +214 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +18 -8
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +47 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +8 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +68 -8
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +22 -22
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.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 +115 -4
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +38 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +70 -6
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +12 -6
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +273 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +19 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +20 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +67 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +83 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +23 -26
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +176 -40
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +44 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +92 -6
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/gsd/auto/phases.ts +70 -6
- package/src/resources/extensions/gsd/auto-model-selection.ts +3 -3
- package/src/resources/extensions/gsd/auto-post-unit.ts +7 -3
- package/src/resources/extensions/gsd/auto-recovery.ts +29 -9
- package/src/resources/extensions/gsd/auto-worktree.ts +1 -0
- package/src/resources/extensions/gsd/bootstrap/provider-error-resume.ts +5 -3
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +15 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +72 -8
- package/src/resources/extensions/gsd/cache.ts +16 -5
- package/src/resources/extensions/gsd/commands/catalog.ts +6 -1
- package/src/resources/extensions/gsd/commands/handlers/core.ts +5 -1
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +57 -3
- package/src/resources/extensions/gsd/docs/preferences-reference.md +2 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +228 -0
- package/src/resources/extensions/gsd/ecosystem/loader.ts +201 -0
- package/src/resources/extensions/gsd/guided-flow.ts +4 -2
- package/src/resources/extensions/gsd/preferences-types.ts +6 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +10 -0
- package/src/resources/extensions/gsd/preferences.ts +6 -0
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +15 -31
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +177 -0
- package/src/resources/extensions/gsd/tests/auto-retry-mcp-churn-fixes.test.ts +272 -0
- package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +117 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/preferences.test.ts +145 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +57 -2
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +1 -1
- package/src/resources/extensions/gsd/types.ts +13 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +2 -1
- package/packages/pi-ai/dist/models.custom.d.ts.map +0 -1
- package/packages/pi-ai/dist/models.custom.js.map +0 -1
- package/packages/pi-ai/dist/models.generated.js +0 -14343
- package/packages/pi-ai/dist/models.generated.js.map +0 -1
- package/packages/pi-ai/src/models.generated.ts +0 -14345
- /package/dist/web/standalone/.next/static/{fMaWScj7m6EsI3DbaNv2_ → Es_JWCfFZjIvYZShmjyye}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{fMaWScj7m6EsI3DbaNv2_ → Es_JWCfFZjIvYZShmjyye}/_ssgManifest.js +0 -0
package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression test: invalidateAllCaches() must NOT wipe the artifacts table.
|
|
3
|
+
*
|
|
4
|
+
* Prior to this fix, `cache.ts` bundled `clearArtifacts()` (which runs
|
|
5
|
+
* `DELETE FROM artifacts`) into `invalidateAllCaches()`. That helper fires
|
|
6
|
+
* on every post-unit pass, so rows written by `saveArtifactToDb` and
|
|
7
|
+
* `writeAndStore` (RESEARCH, CONTEXT, VALIDATION, ASSESSMENT, PLAN,
|
|
8
|
+
* ROADMAP, task PLAN, task SUMMARY) got deleted within seconds of being
|
|
9
|
+
* written. The milestone completed on disk, but `SELECT COUNT(*) FROM
|
|
10
|
+
* artifacts` returned 0, and the agent fell into a "file exists but DB
|
|
11
|
+
* record missing" recovery loop.
|
|
12
|
+
*
|
|
13
|
+
* The artifacts table is a write-through store, not a read cache. Routine
|
|
14
|
+
* cache invalidation must preserve its contents.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { describe, test, afterEach } from "node:test";
|
|
20
|
+
import assert from "node:assert/strict";
|
|
21
|
+
import { readFileSync } from "node:fs";
|
|
22
|
+
import { resolve } from "node:path";
|
|
23
|
+
|
|
24
|
+
import { invalidateAllCaches } from "../cache.ts";
|
|
25
|
+
import {
|
|
26
|
+
openDatabase,
|
|
27
|
+
closeDatabase,
|
|
28
|
+
insertArtifact,
|
|
29
|
+
isDbAvailable,
|
|
30
|
+
_getAdapter,
|
|
31
|
+
} from "../gsd-db.ts";
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
if (isDbAvailable()) {
|
|
35
|
+
try {
|
|
36
|
+
closeDatabase();
|
|
37
|
+
} catch {
|
|
38
|
+
/* best-effort teardown */
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("invalidateAllCaches() must preserve the artifacts table", () => {
|
|
44
|
+
test("rows survive a single invalidate call", () => {
|
|
45
|
+
const opened = openDatabase(":memory:");
|
|
46
|
+
assert.equal(opened, true, "in-memory DB must open");
|
|
47
|
+
|
|
48
|
+
insertArtifact({
|
|
49
|
+
path: "milestones/M001/slices/S01/S01-RESEARCH.md",
|
|
50
|
+
artifact_type: "RESEARCH",
|
|
51
|
+
milestone_id: "M001",
|
|
52
|
+
slice_id: "S01",
|
|
53
|
+
task_id: null,
|
|
54
|
+
full_content: "# Research\n\nFindings go here.\n",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
invalidateAllCaches();
|
|
58
|
+
|
|
59
|
+
const adapter = _getAdapter();
|
|
60
|
+
assert.ok(adapter, "adapter should be available");
|
|
61
|
+
const row = adapter!
|
|
62
|
+
.prepare(
|
|
63
|
+
"SELECT path, artifact_type, length(full_content) AS len FROM artifacts WHERE path = :path",
|
|
64
|
+
)
|
|
65
|
+
.get({ ":path": "milestones/M001/slices/S01/S01-RESEARCH.md" }) as
|
|
66
|
+
| { path: string; artifact_type: string; len: number }
|
|
67
|
+
| undefined;
|
|
68
|
+
|
|
69
|
+
assert.ok(
|
|
70
|
+
row,
|
|
71
|
+
"artifact row must still exist after invalidateAllCaches — this is the Phase B bug",
|
|
72
|
+
);
|
|
73
|
+
assert.equal(row!.artifact_type, "RESEARCH");
|
|
74
|
+
assert.ok((row!.len ?? 0) > 0, "full_content must not be truncated");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("multiple rows for a full milestone survive repeated invalidates", () => {
|
|
78
|
+
openDatabase(":memory:");
|
|
79
|
+
|
|
80
|
+
const inserts = [
|
|
81
|
+
{
|
|
82
|
+
path: "milestones/M001/M001-ROADMAP.md",
|
|
83
|
+
artifact_type: "ROADMAP",
|
|
84
|
+
milestone_id: "M001",
|
|
85
|
+
slice_id: null,
|
|
86
|
+
task_id: null,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
path: "milestones/M001/slices/S01/S01-RESEARCH.md",
|
|
90
|
+
artifact_type: "RESEARCH",
|
|
91
|
+
milestone_id: "M001",
|
|
92
|
+
slice_id: "S01",
|
|
93
|
+
task_id: null,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
path: "milestones/M001/slices/S01/S01-PLAN.md",
|
|
97
|
+
artifact_type: "PLAN",
|
|
98
|
+
milestone_id: "M001",
|
|
99
|
+
slice_id: "S01",
|
|
100
|
+
task_id: null,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
path: "milestones/M001/slices/S01/tasks/T01-PLAN.md",
|
|
104
|
+
artifact_type: "PLAN",
|
|
105
|
+
milestone_id: "M001",
|
|
106
|
+
slice_id: "S01",
|
|
107
|
+
task_id: "T01",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
path: "milestones/M001/slices/S01/tasks/T01-SUMMARY.md",
|
|
111
|
+
artifact_type: "SUMMARY",
|
|
112
|
+
milestone_id: "M001",
|
|
113
|
+
slice_id: "S01",
|
|
114
|
+
task_id: "T01",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
path: "milestones/M001/M001-SUMMARY.md",
|
|
118
|
+
artifact_type: "SUMMARY",
|
|
119
|
+
milestone_id: "M001",
|
|
120
|
+
slice_id: null,
|
|
121
|
+
task_id: null,
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
for (const i of inserts) {
|
|
126
|
+
insertArtifact({ ...i, full_content: `# ${i.artifact_type} content\n` });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Simulate a full milestone's worth of post-unit cycles.
|
|
130
|
+
for (let i = 0; i < 10; i++) {
|
|
131
|
+
invalidateAllCaches();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const adapter = _getAdapter()!;
|
|
135
|
+
const count = (
|
|
136
|
+
adapter.prepare("SELECT COUNT(*) AS n FROM artifacts").get() as { n: number }
|
|
137
|
+
).n;
|
|
138
|
+
|
|
139
|
+
assert.equal(
|
|
140
|
+
count,
|
|
141
|
+
inserts.length,
|
|
142
|
+
`all ${inserts.length} artifact rows must survive repeated invalidate calls; got ${count}`,
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("cache.ts must not re-import clearArtifacts into invalidateAllCaches", () => {
|
|
148
|
+
const src = readFileSync(
|
|
149
|
+
resolve(process.cwd(), "src", "resources", "extensions", "gsd", "cache.ts"),
|
|
150
|
+
"utf-8",
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
test("clearArtifacts is not imported from gsd-db", () => {
|
|
154
|
+
assert.ok(
|
|
155
|
+
!/import\s*\{[^}]*clearArtifacts[^}]*\}\s*from\s*['"]\.\/gsd-db/.test(src),
|
|
156
|
+
"cache.ts must not import clearArtifacts — it causes the artifacts-table-wipe regression",
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("invalidateAllCaches does not call clearArtifacts", () => {
|
|
161
|
+
const fnIdx = src.indexOf("function invalidateAllCaches");
|
|
162
|
+
assert.ok(fnIdx !== -1);
|
|
163
|
+
const body = src.slice(fnIdx, fnIdx + 1000);
|
|
164
|
+
assert.ok(
|
|
165
|
+
!/\bclearArtifacts\s*\(/.test(body),
|
|
166
|
+
"invalidateAllCaches must not call clearArtifacts() — it wipes the write-through store",
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("cache.ts documents why clearArtifacts is not bundled here", () => {
|
|
171
|
+
// Future reviewers need to see the rationale or they'll re-add it.
|
|
172
|
+
assert.ok(
|
|
173
|
+
/artifacts.*NOT included|write-through store/i.test(src),
|
|
174
|
+
"cache.ts must explain why the artifacts table is NOT invalidated here",
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for PR #4288 — auto-retry bug, .mcp.json churn, and MCP
|
|
3
|
+
* worktree routing fixes.
|
|
4
|
+
*
|
|
5
|
+
* Covers four source-file changes:
|
|
6
|
+
* 1. src/resources/extensions/gsd/safety/evidence-collector.ts (functional)
|
|
7
|
+
* 2. src/resources/extensions/gsd/bootstrap/register-hooks.ts (source shape)
|
|
8
|
+
* 3. src/resources/extensions/gsd/auto-recovery.ts (source shape)
|
|
9
|
+
* 4. packages/mcp-server/src/workflow-tools.ts (source shape)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, it, beforeEach } from "node:test";
|
|
15
|
+
import assert from "node:assert/strict";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { resolve } from "node:path";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
resetEvidence,
|
|
21
|
+
getEvidence,
|
|
22
|
+
recordToolCall,
|
|
23
|
+
recordToolResult,
|
|
24
|
+
type BashEvidence,
|
|
25
|
+
} from "../safety/evidence-collector.js";
|
|
26
|
+
|
|
27
|
+
// ─── 1. evidence-collector: functional ─────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
describe("evidence-collector: toolCallId-based matching (A-3)", () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
resetEvidence();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("records bash calls with their toolCallId at dispatch time", () => {
|
|
35
|
+
recordToolCall("tc-1", "bash", { command: "ls -la" });
|
|
36
|
+
recordToolCall("tc-2", "bash", { command: "git status" });
|
|
37
|
+
|
|
38
|
+
const entries = getEvidence();
|
|
39
|
+
assert.equal(entries.length, 2);
|
|
40
|
+
assert.equal(entries[0].toolCallId, "tc-1");
|
|
41
|
+
assert.equal(entries[1].toolCallId, "tc-2");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("matches results to the correct entry by toolCallId, not insertion order", () => {
|
|
45
|
+
// Simulate two parallel bash calls dispatched in order tc-1, tc-2.
|
|
46
|
+
recordToolCall("tc-1", "bash", { command: "slow-thing" });
|
|
47
|
+
recordToolCall("tc-2", "bash", { command: "fast-thing" });
|
|
48
|
+
|
|
49
|
+
// Results arrive out of order: tc-2 first (fast), then tc-1 (slow).
|
|
50
|
+
// With the old empty-string-matching strategy, tc-2's result would be
|
|
51
|
+
// stapled to tc-1's entry because findLastUnresolved scanned backwards
|
|
52
|
+
// for empty ids. Now we match by id directly.
|
|
53
|
+
recordToolResult("tc-2", "bash", "Command exited with code 0\nfast-output", false);
|
|
54
|
+
recordToolResult("tc-1", "bash", "Command exited with code 1\nslow-failure", true);
|
|
55
|
+
|
|
56
|
+
const entries = getEvidence() as readonly BashEvidence[];
|
|
57
|
+
const tc1 = entries.find(e => e.toolCallId === "tc-1") as BashEvidence | undefined;
|
|
58
|
+
const tc2 = entries.find(e => e.toolCallId === "tc-2") as BashEvidence | undefined;
|
|
59
|
+
|
|
60
|
+
assert.ok(tc1, "tc-1 entry must exist");
|
|
61
|
+
assert.ok(tc2, "tc-2 entry must exist");
|
|
62
|
+
|
|
63
|
+
// The original command stays attached to the entry it was recorded with,
|
|
64
|
+
// and the result matches the id it was reported for.
|
|
65
|
+
assert.equal(tc1.command, "slow-thing");
|
|
66
|
+
assert.equal(tc1.exitCode, 1);
|
|
67
|
+
assert.ok(tc1.outputSnippet.includes("slow-failure"));
|
|
68
|
+
|
|
69
|
+
assert.equal(tc2.command, "fast-thing");
|
|
70
|
+
assert.equal(tc2.exitCode, 0);
|
|
71
|
+
assert.ok(tc2.outputSnippet.includes("fast-output"));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("ignores results with unknown toolCallIds rather than corrupting nearby entries", () => {
|
|
75
|
+
recordToolCall("tc-1", "bash", { command: "real" });
|
|
76
|
+
recordToolResult("tc-UNKNOWN", "bash", "Command exited with code 0\n", false);
|
|
77
|
+
|
|
78
|
+
const entries = getEvidence() as readonly BashEvidence[];
|
|
79
|
+
assert.equal(entries.length, 1);
|
|
80
|
+
assert.equal(entries[0].toolCallId, "tc-1");
|
|
81
|
+
// tc-1 must be untouched — no result was reported for it.
|
|
82
|
+
assert.equal(entries[0].exitCode, -1);
|
|
83
|
+
assert.equal(entries[0].outputSnippet, "");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("records write/edit entries with their toolCallId", () => {
|
|
87
|
+
recordToolCall("tc-write", "write", { file_path: "/tmp/a.md" });
|
|
88
|
+
recordToolCall("tc-edit", "edit", { file_path: "/tmp/b.md" });
|
|
89
|
+
|
|
90
|
+
const entries = getEvidence();
|
|
91
|
+
assert.equal(entries.length, 2);
|
|
92
|
+
assert.equal(entries[0].kind, "write");
|
|
93
|
+
assert.equal(entries[0].toolCallId, "tc-write");
|
|
94
|
+
assert.equal(entries[1].kind, "edit");
|
|
95
|
+
assert.equal(entries[1].toolCallId, "tc-edit");
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ─── 2. register-hooks: MCP auto-prep gated inside auto-worktrees (A-1) ────
|
|
100
|
+
|
|
101
|
+
describe("register-hooks: skip prepareWorkflowMcpForProject inside auto-worktrees (A-1)", () => {
|
|
102
|
+
const src = readFileSync(
|
|
103
|
+
resolve(process.cwd(), "src", "resources", "extensions", "gsd", "bootstrap", "register-hooks.ts"),
|
|
104
|
+
"utf-8",
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
it("session_start hook is gated on isInAutoWorktree", () => {
|
|
108
|
+
const idx = src.indexOf('pi.on("session_start"');
|
|
109
|
+
assert.ok(idx !== -1, "session_start handler must exist");
|
|
110
|
+
const block = src.slice(idx, idx + 2500);
|
|
111
|
+
assert.ok(
|
|
112
|
+
block.includes("isInAutoWorktree"),
|
|
113
|
+
"session_start must consult isInAutoWorktree before preparing MCP",
|
|
114
|
+
);
|
|
115
|
+
assert.ok(
|
|
116
|
+
block.includes("prepareWorkflowMcpForProject"),
|
|
117
|
+
"session_start still prepares MCP for non-worktree paths",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("session_switch hook is gated on isInAutoWorktree", () => {
|
|
122
|
+
const idx = src.indexOf('pi.on("session_switch"');
|
|
123
|
+
assert.ok(idx !== -1, "session_switch handler must exist");
|
|
124
|
+
const block = src.slice(idx, idx + 2500);
|
|
125
|
+
assert.ok(
|
|
126
|
+
block.includes("isInAutoWorktree"),
|
|
127
|
+
"session_switch must consult isInAutoWorktree before preparing MCP",
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("tool_call hook forwards event.toolCallId into safetyRecordToolCall (A-3)", () => {
|
|
132
|
+
// Find the call site (skip the import line by looking for the opening paren).
|
|
133
|
+
const idx = src.indexOf("safetyRecordToolCall(");
|
|
134
|
+
assert.ok(idx !== -1, "safetyRecordToolCall call must exist");
|
|
135
|
+
const line = src.slice(idx, src.indexOf("\n", idx));
|
|
136
|
+
assert.ok(
|
|
137
|
+
line.includes("event.toolCallId"),
|
|
138
|
+
"safetyRecordToolCall must receive event.toolCallId as the first argument",
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// ─── 3. auto-recovery: verify-fail instrumentation ─────────────────────────
|
|
144
|
+
|
|
145
|
+
describe("verifyExpectedArtifact: verify-fail exit-point logging (Phase B diag)", () => {
|
|
146
|
+
const src = readFileSync(
|
|
147
|
+
resolve(process.cwd(), "src", "resources", "extensions", "gsd", "auto-recovery.ts"),
|
|
148
|
+
"utf-8",
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
it("logs a verify-fail warning on the null-absPath exit", () => {
|
|
152
|
+
assert.ok(
|
|
153
|
+
src.includes('verify-fail ${unitType} ${unitId}: resolveExpectedArtifactPath returned null'),
|
|
154
|
+
"null-absPath branch must emit a diagnostic line",
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("logs a verify-fail warning on the existsSync-false exit", () => {
|
|
159
|
+
assert.ok(
|
|
160
|
+
src.includes("verify-fail ${unitType} ${unitId}: existsSync false"),
|
|
161
|
+
"existsSync-false branch must emit a diagnostic line",
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("logs a verify-fail warning on the plan-slice no-task-entry exit", () => {
|
|
166
|
+
assert.ok(
|
|
167
|
+
src.includes("verify-fail ${unitType} ${unitId}: plan has no task checkbox/heading"),
|
|
168
|
+
"plan-slice no-task branch must emit a diagnostic line",
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("plan-slice task-plan-files check fails fast on missing tasks dir (hardening)", () => {
|
|
173
|
+
// The original check silently passed when resolveTasksDir returned null.
|
|
174
|
+
// The new check returns false with a diagnostic, which is correct — if
|
|
175
|
+
// the tool successfully planned tasks, the tasks/ dir must exist.
|
|
176
|
+
const idx = src.indexOf('verify-fail ${unitType} ${unitId}: resolveTasksDir returned null');
|
|
177
|
+
assert.ok(
|
|
178
|
+
idx !== -1,
|
|
179
|
+
"resolveTasksDir-null branch must emit a diagnostic and return false",
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// ─── 4. workflow-tools (mcp-server): guard + optional projectDir + routing ─
|
|
185
|
+
|
|
186
|
+
describe("mcp-server workflow-tools: projectDir routing (Phase B root cause)", () => {
|
|
187
|
+
const src = readFileSync(
|
|
188
|
+
resolve(process.cwd(), "packages", "mcp-server", "src", "workflow-tools.ts"),
|
|
189
|
+
"utf-8",
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
it("projectDirParam is optional and documents the default", () => {
|
|
193
|
+
const idx = src.indexOf("const projectDirParam");
|
|
194
|
+
assert.ok(idx !== -1, "projectDirParam definition must exist");
|
|
195
|
+
const block = src.slice(idx, idx + 600);
|
|
196
|
+
assert.ok(
|
|
197
|
+
block.includes(".optional()"),
|
|
198
|
+
"projectDirParam must be optional so the agent stops deliberating",
|
|
199
|
+
);
|
|
200
|
+
assert.ok(
|
|
201
|
+
/Omit this field/i.test(block),
|
|
202
|
+
"description must tell the agent to omit the field",
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("parseWorkflowArgs defaults projectDir to process.cwd() when omitted", () => {
|
|
207
|
+
const idx = src.indexOf("function parseWorkflowArgs");
|
|
208
|
+
assert.ok(idx !== -1, "parseWorkflowArgs must exist");
|
|
209
|
+
const block = src.slice(idx, idx + 1500);
|
|
210
|
+
assert.ok(
|
|
211
|
+
block.includes("parsed.projectDir ?? process.cwd()"),
|
|
212
|
+
"parseWorkflowArgs must fall back to process.cwd() when projectDir is omitted",
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("validateProjectDir accepts external-state worktree paths via .gsd symlink target", () => {
|
|
217
|
+
const idx = src.indexOf("function validateProjectDir");
|
|
218
|
+
assert.ok(idx !== -1, "validateProjectDir must exist");
|
|
219
|
+
const block = src.slice(idx, idx + 2500);
|
|
220
|
+
assert.ok(
|
|
221
|
+
block.includes("resolveExternalStateRoot"),
|
|
222
|
+
"validateProjectDir must consult resolveExternalStateRoot for external-state layouts",
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const helperIdx = src.indexOf("function resolveExternalStateRoot");
|
|
226
|
+
assert.ok(helperIdx !== -1, "resolveExternalStateRoot helper must exist");
|
|
227
|
+
const helperBlock = src.slice(helperIdx, helperIdx + 600);
|
|
228
|
+
assert.ok(
|
|
229
|
+
helperBlock.includes("realpathSync"),
|
|
230
|
+
"resolveExternalStateRoot must use realpathSync to follow the symlink",
|
|
231
|
+
);
|
|
232
|
+
assert.ok(
|
|
233
|
+
/join\([^)]*\.gsd/.test(helperBlock),
|
|
234
|
+
"resolveExternalStateRoot must resolve <allowedRoot>/.gsd",
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("parseWorkflowArgs routes tool writes to the active worktree when one exists", () => {
|
|
239
|
+
// This is the Phase B root-cause fix: when the tool call is scoped to a
|
|
240
|
+
// milestone that has an auto-worktree at <projectRoot>/.gsd/worktrees/<MID>/,
|
|
241
|
+
// tool writes must go to the worktree .gsd rather than the shared project .gsd.
|
|
242
|
+
const parseIdx = src.indexOf("function parseWorkflowArgs");
|
|
243
|
+
const parseBlock = src.slice(parseIdx, parseIdx + 2500);
|
|
244
|
+
assert.ok(
|
|
245
|
+
parseBlock.includes("resolveActiveWorktreeBasePath"),
|
|
246
|
+
"parseWorkflowArgs must consult resolveActiveWorktreeBasePath",
|
|
247
|
+
);
|
|
248
|
+
assert.ok(
|
|
249
|
+
parseBlock.includes("extractMilestoneId"),
|
|
250
|
+
"parseWorkflowArgs must extract the milestoneId to locate the worktree",
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("resolveActiveWorktreeBasePath checks .git presence to avoid hijacking stray directories", () => {
|
|
255
|
+
const idx = src.indexOf("function resolveActiveWorktreeBasePath");
|
|
256
|
+
assert.ok(idx !== -1, "resolveActiveWorktreeBasePath helper must exist");
|
|
257
|
+
const block = src.slice(idx, idx + 1200);
|
|
258
|
+
assert.ok(
|
|
259
|
+
block.includes('existsSync(join(wtPath, ".git"))'),
|
|
260
|
+
"resolveActiveWorktreeBasePath must verify a .git file exists in the worktree",
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("extractMilestoneId handles camelCase, snake_case, and short aliases", () => {
|
|
265
|
+
const idx = src.indexOf("function extractMilestoneId");
|
|
266
|
+
assert.ok(idx !== -1, "extractMilestoneId helper must exist");
|
|
267
|
+
const block = src.slice(idx, idx + 600);
|
|
268
|
+
assert.ok(block.includes("milestoneId"), "must check milestoneId");
|
|
269
|
+
assert.ok(block.includes("milestone_id"), "must check milestone_id");
|
|
270
|
+
assert.ok(block.includes("mid"), "must check mid");
|
|
271
|
+
});
|
|
272
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// GSD Extension — Regression tests for auto-mode warning noise (PR #4294)
|
|
2
|
+
//
|
|
3
|
+
// Three independent bug fixes, three regression tests:
|
|
4
|
+
//
|
|
5
|
+
// 1. auto-model-selection.ts — buildFlatRateContext detached
|
|
6
|
+
// getProviderAuthMode from its receiver, losing `this` and throwing
|
|
7
|
+
// "Cannot read properties of undefined (reading 'registeredProviders')".
|
|
8
|
+
// Runtime test: pass a registry whose method actually uses `this` and
|
|
9
|
+
// verify the returned authMode survives (proves the method is called
|
|
10
|
+
// with correct binding).
|
|
11
|
+
//
|
|
12
|
+
// 2. auto-worktree.ts — isSamePath logged every error as a warning,
|
|
13
|
+
// including ENOENT when a worktree's .gsd dir hadn't been created yet.
|
|
14
|
+
// Source-check test: the catch block must short-circuit on ENOENT
|
|
15
|
+
// before hitting logWarning. Follows the same style as
|
|
16
|
+
// copy-planning-artifacts-samepath.test.ts.
|
|
17
|
+
//
|
|
18
|
+
// 3. guided-flow.ts — checkAutoStartAfterDiscuss unconditionally tried
|
|
19
|
+
// to unlink DISCUSSION-MANIFEST.json and warned on ENOENT even when
|
|
20
|
+
// the milestone never had a discussion phase. Source-check test:
|
|
21
|
+
// the unlink must be guarded with existsSync, matching the
|
|
22
|
+
// CONTEXT-DRAFT.md cleanup pattern two lines above.
|
|
23
|
+
|
|
24
|
+
import test from "node:test";
|
|
25
|
+
import assert from "node:assert/strict";
|
|
26
|
+
import { readFileSync } from "node:fs";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
|
|
29
|
+
import { buildFlatRateContext } from "../auto-model-selection.ts";
|
|
30
|
+
|
|
31
|
+
// ─── Bug 2: this-binding regression ─────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
test("buildFlatRateContext invokes getProviderAuthMode with correct `this`", () => {
|
|
34
|
+
// Mimics ModelRegistry: getProviderAuthMode reads from an instance field.
|
|
35
|
+
// Detaching the method to a local variable would break this — the old code
|
|
36
|
+
// did `const fn = ctx.modelRegistry.getProviderAuthMode; fn(provider)`,
|
|
37
|
+
// which called the method with `this === undefined` and threw.
|
|
38
|
+
const providerData = new Map<string, string>([
|
|
39
|
+
["claude-code", "externalCli"],
|
|
40
|
+
["anthropic", "apiKey"],
|
|
41
|
+
]);
|
|
42
|
+
const registry = {
|
|
43
|
+
_providers: providerData,
|
|
44
|
+
getProviderAuthMode(provider: string): string {
|
|
45
|
+
// Access via `this` — fails loudly if the method was called unbound.
|
|
46
|
+
const map = this._providers;
|
|
47
|
+
return map.get(provider) ?? "apiKey";
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const ctx = buildFlatRateContext("claude-code", { modelRegistry: registry });
|
|
52
|
+
assert.equal(
|
|
53
|
+
ctx.authMode,
|
|
54
|
+
"externalCli",
|
|
55
|
+
"authMode should be extracted when getProviderAuthMode is called as a method",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const ctx2 = buildFlatRateContext("anthropic", { modelRegistry: registry });
|
|
59
|
+
assert.equal(ctx2.authMode, "apiKey");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ─── Bug 1: isSamePath source check ─────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
test("isSamePath short-circuits ENOENT before logging a warning", () => {
|
|
65
|
+
const srcPath = join(import.meta.dirname, "..", "auto-worktree.ts");
|
|
66
|
+
const src = readFileSync(srcPath, "utf-8");
|
|
67
|
+
|
|
68
|
+
const fnIdx = src.indexOf("function isSamePath");
|
|
69
|
+
assert.ok(fnIdx !== -1, "isSamePath function exists");
|
|
70
|
+
|
|
71
|
+
// Grab the function body (enough to cover the catch block).
|
|
72
|
+
const fnBody = src.slice(fnIdx, fnIdx + 600);
|
|
73
|
+
|
|
74
|
+
const catchIdx = fnBody.indexOf("catch");
|
|
75
|
+
assert.ok(catchIdx !== -1, "isSamePath has a catch block");
|
|
76
|
+
|
|
77
|
+
const enoentIdx = fnBody.indexOf("ENOENT", catchIdx);
|
|
78
|
+
const warnIdx = fnBody.indexOf("logWarning", catchIdx);
|
|
79
|
+
|
|
80
|
+
assert.ok(enoentIdx !== -1, "catch block must handle ENOENT explicitly");
|
|
81
|
+
assert.ok(warnIdx !== -1, "catch block still warns on non-ENOENT errors");
|
|
82
|
+
assert.ok(
|
|
83
|
+
enoentIdx < warnIdx,
|
|
84
|
+
"ENOENT early-return must precede the logWarning call",
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ─── Bug 3: guided-flow manifest unlink source check ────────────────────
|
|
89
|
+
|
|
90
|
+
test("checkAutoStartAfterDiscuss guards DISCUSSION-MANIFEST.json unlink with existsSync", () => {
|
|
91
|
+
const srcPath = join(import.meta.dirname, "..", "guided-flow.ts");
|
|
92
|
+
const src = readFileSync(srcPath, "utf-8");
|
|
93
|
+
|
|
94
|
+
const fnIdx = src.indexOf("function checkAutoStartAfterDiscuss");
|
|
95
|
+
assert.ok(fnIdx !== -1, "checkAutoStartAfterDiscuss function exists");
|
|
96
|
+
|
|
97
|
+
// Locate the manifest cleanup comment and its surrounding block.
|
|
98
|
+
const cleanupIdx = src.indexOf(
|
|
99
|
+
"remove discussion manifest after auto-start",
|
|
100
|
+
fnIdx,
|
|
101
|
+
);
|
|
102
|
+
assert.ok(cleanupIdx !== -1, "manifest cleanup block still exists");
|
|
103
|
+
|
|
104
|
+
// Everything from the comment to a short distance below should contain
|
|
105
|
+
// the existsSync guard before the unlinkSync call.
|
|
106
|
+
const block = src.slice(cleanupIdx, cleanupIdx + 400);
|
|
107
|
+
|
|
108
|
+
const existsIdx = block.indexOf("existsSync(manifestPath)");
|
|
109
|
+
const unlinkIdx = block.indexOf("unlinkSync(manifestPath)");
|
|
110
|
+
|
|
111
|
+
assert.ok(existsIdx !== -1, "manifest unlink must be guarded by existsSync");
|
|
112
|
+
assert.ok(unlinkIdx !== -1, "manifest unlink still happens when file exists");
|
|
113
|
+
assert.ok(
|
|
114
|
+
existsIdx < unlinkIdx,
|
|
115
|
+
"existsSync guard must precede the unlinkSync call",
|
|
116
|
+
);
|
|
117
|
+
});
|
|
@@ -198,7 +198,7 @@ test("session_start bootstraps the health widget alongside notifications", async
|
|
|
198
198
|
},
|
|
199
199
|
} as any;
|
|
200
200
|
|
|
201
|
-
registerHooks(pi);
|
|
201
|
+
registerHooks(pi, []);
|
|
202
202
|
const sessionStart = handlers.get("session_start");
|
|
203
203
|
assert.ok(sessionStart, "session_start handler is registered");
|
|
204
204
|
|
|
@@ -595,13 +595,13 @@ test("unit-end event contains errorContext when unit is cancelled with structure
|
|
|
595
595
|
const unitPromise = runUnitPhase(ic, iterData, loopState);
|
|
596
596
|
await new Promise(r => setTimeout(r, 50));
|
|
597
597
|
|
|
598
|
-
// Resolve with errorContext (simulates a timeout
|
|
598
|
+
// Resolve with errorContext (simulates a unit hard timeout — not session creation)
|
|
599
599
|
resolveAgentEndCancelled({ message: "Hard timeout error: exceeded limit", category: "timeout", isTransient: true });
|
|
600
600
|
|
|
601
601
|
const result = await unitPromise;
|
|
602
|
-
//
|
|
602
|
+
// Unit hard timeouts pause (recoverable) without auto-resume
|
|
603
603
|
assert.equal(result.action, "break");
|
|
604
|
-
assert.equal((result as any).reason, "
|
|
604
|
+
assert.equal((result as any).reason, "unit-hard-timeout");
|
|
605
605
|
assert.equal(pauseCalls, 1, "timeout cancellations should pause auto-mode exactly once");
|
|
606
606
|
assert.equal(commitCalls, 1, "timeout cancellations should flush a unit auto-commit once");
|
|
607
607
|
|