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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// GSD2 — Ecosystem Extension API wrapper
|
|
2
|
+
// Wraps pi's ExtensionAPI to expose typed GSD context (phase + active unit)
|
|
3
|
+
// to extensions loaded from `./.gsd/extensions/`. The wrapper intercepts only
|
|
4
|
+
// `on("before_agent_start", ...)` so GSD can dispatch ecosystem handlers AFTER
|
|
5
|
+
// refreshing state — fixing the load-order race where third-party
|
|
6
|
+
// `.pi/extensions/` handlers see a stale module-level snapshot (#3338).
|
|
7
|
+
//
|
|
8
|
+
// SINGLE-SESSION INVARIANT: the module-level `_snapshot` is per-process.
|
|
9
|
+
// Worktree or project switches do NOT reload extensions, matching pi's
|
|
10
|
+
// `.pi/extensions/` behavior. Only re-launching the CLI rebinds the snapshot.
|
|
11
|
+
import { isGSDActive, getCurrentPhase } from "../../shared/gsd-phase-state.js";
|
|
12
|
+
import { logWarning } from "../workflow-logger.js";
|
|
13
|
+
// ─── Auto-loop phase mapping ────────────────────────────────────────────
|
|
14
|
+
const AUTO_LOOP_PHASE_MAP = {
|
|
15
|
+
"plan-milestone": "planning",
|
|
16
|
+
"plan-slice": "planning",
|
|
17
|
+
"research": "researching",
|
|
18
|
+
"discuss": "discussing",
|
|
19
|
+
"execute-task": "executing",
|
|
20
|
+
"verify": "verifying",
|
|
21
|
+
"summarize-task": "summarizing",
|
|
22
|
+
"summarize-slice": "summarizing",
|
|
23
|
+
"advance": "advancing",
|
|
24
|
+
"validate-milestone": "validating-milestone",
|
|
25
|
+
"complete-milestone": "completing-milestone",
|
|
26
|
+
"replan-slice": "replanning-slice",
|
|
27
|
+
};
|
|
28
|
+
/** Exposed for unit tests. Returns null for unknown keys (does NOT default). */
|
|
29
|
+
export function mapAutoLoopPhase(raw) {
|
|
30
|
+
return AUTO_LOOP_PHASE_MAP[raw] ?? null;
|
|
31
|
+
}
|
|
32
|
+
function resolvePhase(state) {
|
|
33
|
+
if (!state)
|
|
34
|
+
return null;
|
|
35
|
+
if (isGSDActive()) {
|
|
36
|
+
const raw = getCurrentPhase();
|
|
37
|
+
if (raw != null) {
|
|
38
|
+
const mapped = AUTO_LOOP_PHASE_MAP[raw];
|
|
39
|
+
if (mapped)
|
|
40
|
+
return mapped;
|
|
41
|
+
logWarning("ecosystem", `unknown auto-loop phase: ${raw}`);
|
|
42
|
+
// FALL THROUGH to state.phase rather than defaulting to "executing".
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return state.phase;
|
|
46
|
+
}
|
|
47
|
+
function resolveActiveUnit(state) {
|
|
48
|
+
if (!state)
|
|
49
|
+
return null;
|
|
50
|
+
const m = state.activeMilestone;
|
|
51
|
+
const s = state.activeSlice;
|
|
52
|
+
const t = state.activeTask;
|
|
53
|
+
if (!m || !s || !t)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
milestoneId: m.id,
|
|
57
|
+
milestoneTitle: m.title,
|
|
58
|
+
sliceId: s.id,
|
|
59
|
+
sliceTitle: s.title,
|
|
60
|
+
taskId: t.id,
|
|
61
|
+
taskTitle: t.title,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
let _snapshot = { phase: null, activeUnit: null };
|
|
65
|
+
/** Refresh the snapshot from a freshly derived GSDState (or null on failure). */
|
|
66
|
+
export function updateSnapshot(state) {
|
|
67
|
+
_snapshot = {
|
|
68
|
+
phase: resolvePhase(state),
|
|
69
|
+
activeUnit: resolveActiveUnit(state),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function getSnapshotPhase() {
|
|
73
|
+
return _snapshot.phase;
|
|
74
|
+
}
|
|
75
|
+
export function getSnapshotActiveUnit() {
|
|
76
|
+
return _snapshot.activeUnit;
|
|
77
|
+
}
|
|
78
|
+
/** Test-only: reset the snapshot to its initial empty state. */
|
|
79
|
+
export function _resetSnapshot() {
|
|
80
|
+
_snapshot = { phase: null, activeUnit: null };
|
|
81
|
+
}
|
|
82
|
+
// ─── Wrapper factory ────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* Build a GSDExtensionAPI by manually delegating every ExtensionAPI method
|
|
85
|
+
* to the underlying pi instance, except `on("before_agent_start", ...)`
|
|
86
|
+
* which is captured into `sharedHandlers` for GSD-owned dispatch.
|
|
87
|
+
*
|
|
88
|
+
* Uses `satisfies GSDExtensionAPI` (NOT `as`) so TypeScript catches drift
|
|
89
|
+
* when pi adds new ExtensionAPI methods.
|
|
90
|
+
*/
|
|
91
|
+
export function createGSDExtensionAPI(pi, sharedHandlers) {
|
|
92
|
+
const wrapper = {
|
|
93
|
+
// ── Event subscription (single intercept point) ────────────────────
|
|
94
|
+
on(event, handler) {
|
|
95
|
+
if (event === "before_agent_start") {
|
|
96
|
+
sharedHandlers.push(handler);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
pi.on(event, handler);
|
|
100
|
+
},
|
|
101
|
+
// ── Event emission ─────────────────────────────────────────────────
|
|
102
|
+
emitBeforeModelSelect: (...args) => pi.emitBeforeModelSelect(...args),
|
|
103
|
+
emitAdjustToolSet: (...args) => pi.emitAdjustToolSet(...args),
|
|
104
|
+
// ── Tool / command / shortcut / flag registration ──────────────────
|
|
105
|
+
registerTool: ((tool) => pi.registerTool(tool)),
|
|
106
|
+
registerCommand: (...args) => pi.registerCommand(...args),
|
|
107
|
+
registerBeforeInstall: (...args) => pi.registerBeforeInstall(...args),
|
|
108
|
+
registerAfterInstall: (...args) => pi.registerAfterInstall(...args),
|
|
109
|
+
registerBeforeRemove: (...args) => pi.registerBeforeRemove(...args),
|
|
110
|
+
registerAfterRemove: (...args) => pi.registerAfterRemove(...args),
|
|
111
|
+
registerShortcut: (...args) => pi.registerShortcut(...args),
|
|
112
|
+
registerFlag: (...args) => pi.registerFlag(...args),
|
|
113
|
+
getFlag: (...args) => pi.getFlag(...args),
|
|
114
|
+
// ── Message rendering ──────────────────────────────────────────────
|
|
115
|
+
registerMessageRenderer: ((customType, renderer) => pi.registerMessageRenderer(customType, renderer)),
|
|
116
|
+
// ── Actions ────────────────────────────────────────────────────────
|
|
117
|
+
sendMessage: ((message, options) => pi.sendMessage(message, options)),
|
|
118
|
+
sendUserMessage: (...args) => pi.sendUserMessage(...args),
|
|
119
|
+
retryLastTurn: () => pi.retryLastTurn(),
|
|
120
|
+
appendEntry: ((customType, data) => pi.appendEntry(customType, data)),
|
|
121
|
+
// ── Session metadata ───────────────────────────────────────────────
|
|
122
|
+
setSessionName: (...args) => pi.setSessionName(...args),
|
|
123
|
+
getSessionName: () => pi.getSessionName(),
|
|
124
|
+
setLabel: (...args) => pi.setLabel(...args),
|
|
125
|
+
exec: (...args) => pi.exec(...args),
|
|
126
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
127
|
+
getAllTools: () => pi.getAllTools(),
|
|
128
|
+
setActiveTools: (...args) => pi.setActiveTools(...args),
|
|
129
|
+
getCommands: () => pi.getCommands(),
|
|
130
|
+
// ── Model & thinking ───────────────────────────────────────────────
|
|
131
|
+
setModel: (...args) => pi.setModel(...args),
|
|
132
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
133
|
+
setThinkingLevel: (...args) => pi.setThinkingLevel(...args),
|
|
134
|
+
// ── Provider registration ──────────────────────────────────────────
|
|
135
|
+
registerProvider: (...args) => pi.registerProvider(...args),
|
|
136
|
+
unregisterProvider: (...args) => pi.unregisterProvider(...args),
|
|
137
|
+
// ── Shared event bus (passthrough property) ────────────────────────
|
|
138
|
+
events: pi.events,
|
|
139
|
+
// ── GSD-specific additions ─────────────────────────────────────────
|
|
140
|
+
getPhase: () => _snapshot.phase,
|
|
141
|
+
getActiveUnit: () => _snapshot.activeUnit,
|
|
142
|
+
};
|
|
143
|
+
return wrapper;
|
|
144
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// GSD2 — Ecosystem extension loader for ./.gsd/extensions/
|
|
2
|
+
// Discovers and registers single-file extensions that consume GSDExtensionAPI.
|
|
3
|
+
// Trust-gated (mirrors pi's `.pi/extensions/` model) and isolated from pi's
|
|
4
|
+
// own loader chain — handlers run in GSD's own dispatch step, not pi's.
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { getAgentDir } from "@gsd/pi-coding-agent";
|
|
9
|
+
import { logWarning } from "../workflow-logger.js";
|
|
10
|
+
import { createGSDExtensionAPI, } from "./gsd-extension-api.js";
|
|
11
|
+
// ─── Trust check (inlined; pi does not export isProjectTrusted from its
|
|
12
|
+
// package root, and constraint forbids modifying packages/pi-coding-agent/) ─
|
|
13
|
+
const TRUSTED_PROJECTS_FILE = "trusted-projects.json";
|
|
14
|
+
function isProjectTrusted(projectPath, agentDir) {
|
|
15
|
+
const canonical = path.resolve(projectPath);
|
|
16
|
+
const trustedPath = path.join(agentDir, TRUSTED_PROJECTS_FILE);
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(trustedPath, "utf-8");
|
|
19
|
+
const parsed = JSON.parse(content);
|
|
20
|
+
if (Array.isArray(parsed)) {
|
|
21
|
+
return parsed.includes(canonical);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// missing or malformed — treat as untrusted
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// ─── Ready-promise singleton ────────────────────────────────────────────
|
|
30
|
+
let _readyPromise = null;
|
|
31
|
+
let _untrustedWarned = false;
|
|
32
|
+
/**
|
|
33
|
+
* Discover and register ecosystem extensions from `./.gsd/extensions/`.
|
|
34
|
+
* Idempotent: subsequent calls with the same arguments return the same
|
|
35
|
+
* pending promise (no double-load).
|
|
36
|
+
*/
|
|
37
|
+
export function loadEcosystemExtensions(pi, sharedHandlers, cwd = process.cwd()) {
|
|
38
|
+
if (_readyPromise)
|
|
39
|
+
return _readyPromise;
|
|
40
|
+
_readyPromise = _loadEcosystemExtensionsImpl(pi, sharedHandlers, cwd);
|
|
41
|
+
return _readyPromise;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a promise that resolves when ecosystem loading has completed.
|
|
45
|
+
* If loading was never kicked off this returns a resolved promise so the
|
|
46
|
+
* `before_agent_start` handler can `await` unconditionally.
|
|
47
|
+
*/
|
|
48
|
+
export function getEcosystemReadyPromise() {
|
|
49
|
+
return _readyPromise ?? Promise.resolve();
|
|
50
|
+
}
|
|
51
|
+
/** Test-only: clear the singleton so tests can re-run loading. */
|
|
52
|
+
export function _resetEcosystemLoader() {
|
|
53
|
+
_readyPromise = null;
|
|
54
|
+
_untrustedWarned = false;
|
|
55
|
+
}
|
|
56
|
+
// ─── Implementation ─────────────────────────────────────────────────────
|
|
57
|
+
async function _loadEcosystemExtensionsImpl(pi, sharedHandlers, cwd) {
|
|
58
|
+
const extDir = path.join(cwd, ".gsd", "extensions");
|
|
59
|
+
if (!fs.existsSync(extDir))
|
|
60
|
+
return;
|
|
61
|
+
// Trust gate: refuse to load arbitrary code from untrusted project dirs.
|
|
62
|
+
if (!isProjectTrusted(cwd, getAgentDir())) {
|
|
63
|
+
if (!_untrustedWarned) {
|
|
64
|
+
_untrustedWarned = true;
|
|
65
|
+
logWarning("ecosystem", ".gsd/extensions present but project is not trusted — skipping ecosystem extensions. Run `pi trust` to opt in.");
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Resolve realpath ONCE so symlink-escape detection has a stable anchor.
|
|
70
|
+
let realExtDir;
|
|
71
|
+
try {
|
|
72
|
+
realExtDir = fs.realpathSync(extDir);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logWarning("ecosystem", `failed to resolve extensions dir: ${err instanceof Error ? err.message : String(err)}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let entries;
|
|
79
|
+
try {
|
|
80
|
+
entries = fs
|
|
81
|
+
.readdirSync(extDir)
|
|
82
|
+
.filter((f) => f.endsWith(".js") || f.endsWith(".ts"))
|
|
83
|
+
.sort(); // deterministic load order
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
logWarning("ecosystem", `failed to read extensions dir: ${err instanceof Error ? err.message : String(err)}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// The wrapper api is built once per loader run and shared by all extensions
|
|
90
|
+
// so they all read from the same module-level snapshot.
|
|
91
|
+
const api = createGSDExtensionAPI(pi, sharedHandlers);
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
await _loadOne(extDir, realExtDir, entry, api);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function _loadOne(extDir, realExtDir, entry, api) {
|
|
97
|
+
const fullPath = path.join(extDir, entry);
|
|
98
|
+
// Symlink-escape guard: reject entries whose realpath is not under realExtDir.
|
|
99
|
+
let realFullPath;
|
|
100
|
+
try {
|
|
101
|
+
realFullPath = fs.realpathSync(fullPath);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
logWarning("ecosystem", `failed to resolve ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const realExtDirWithSep = realExtDir.endsWith(path.sep) ? realExtDir : realExtDir + path.sep;
|
|
108
|
+
if (realFullPath !== realExtDir &&
|
|
109
|
+
!realFullPath.startsWith(realExtDirWithSep)) {
|
|
110
|
+
logWarning("ecosystem", `rejecting ${entry}: realpath escapes extensions dir`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// For .ts files, require a sibling compiled .js — we do not run a TS loader
|
|
114
|
+
// in production. Drop mtime heuristics: if .js exists, prefer it; otherwise warn.
|
|
115
|
+
let importPath = realFullPath;
|
|
116
|
+
if (entry.endsWith(".ts")) {
|
|
117
|
+
const jsSibling = realFullPath.slice(0, -3) + ".js";
|
|
118
|
+
if (fs.existsSync(jsSibling)) {
|
|
119
|
+
importPath = jsSibling;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
logWarning("ecosystem", `${entry}: TypeScript source has no compiled .js sibling — compile it first`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let mod;
|
|
127
|
+
try {
|
|
128
|
+
mod = await import(pathToFileURL(importPath).href);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
logWarning("ecosystem", `failed to import ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const factory = mod?.default;
|
|
135
|
+
if (typeof factory !== "function") {
|
|
136
|
+
logWarning("ecosystem", `${entry}: default export is not a function`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
await factory(api);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
logWarning("ecosystem", `factory threw for ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -212,14 +212,16 @@ export function checkAutoStartAfterDiscuss() {
|
|
|
212
212
|
logWarning("guided", `CONTEXT-DRAFT.md unlink failed: ${e.message}`);
|
|
213
213
|
}
|
|
214
214
|
// Cleanup: remove discussion manifest after auto-start (only needed during discussion)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
if (existsSync(manifestPath)) {
|
|
216
|
+
try {
|
|
217
|
+
unlinkSync(manifestPath);
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
logWarning("guided", `manifest unlink failed: ${e.message}`);
|
|
221
|
+
}
|
|
220
222
|
}
|
|
221
223
|
pendingAutoStartMap.delete(basePath);
|
|
222
|
-
ctx.ui.notify(`Milestone ${milestoneId} ready.`, "
|
|
224
|
+
ctx.ui.notify(`Milestone ${milestoneId} ready.`, "success");
|
|
223
225
|
startAutoDetached(ctx, pi, basePath, false, { step });
|
|
224
226
|
return true;
|
|
225
227
|
}
|
|
@@ -1144,5 +1144,15 @@ export function validatePreferences(preferences) {
|
|
|
1144
1144
|
errors.push(`discuss_depth must be one of: quick, standard, thorough`);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
+
// ─── Language ────────────────────────────────────────────────────────
|
|
1148
|
+
if (preferences.language !== undefined) {
|
|
1149
|
+
const trimmed = typeof preferences.language === "string" ? preferences.language.trim() : undefined;
|
|
1150
|
+
if (trimmed && trimmed.length <= 50 && !/[\r\n]/.test(trimmed)) {
|
|
1151
|
+
validated.language = trimmed;
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
errors.push(`language must be a non-empty string up to 50 characters with no newlines (e.g. "Chinese", "de", "日本語")`);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1147
1157
|
return { preferences: validated, errors, warnings };
|
|
1148
1158
|
}
|
|
@@ -360,6 +360,7 @@ function mergePreferences(base, override) {
|
|
|
360
360
|
slice_parallel: (base.slice_parallel || override.slice_parallel)
|
|
361
361
|
? { ...(base.slice_parallel ?? {}), ...(override.slice_parallel ?? {}) }
|
|
362
362
|
: undefined,
|
|
363
|
+
language: override.language ?? base.language,
|
|
363
364
|
};
|
|
364
365
|
}
|
|
365
366
|
function mergeStringLists(base, override) {
|
|
@@ -454,6 +455,10 @@ export function renderPreferencesForSystemPrompt(preferences, resolutions) {
|
|
|
454
455
|
lines.push(` - ${instruction}`);
|
|
455
456
|
}
|
|
456
457
|
}
|
|
458
|
+
if (preferences.language) {
|
|
459
|
+
const safeLang = preferences.language.replace(/[\r\n]/g, " ").slice(0, 50);
|
|
460
|
+
lines.push(`- Language: Always respond in ${safeLang}.`);
|
|
461
|
+
}
|
|
457
462
|
return lines.join("\n");
|
|
458
463
|
}
|
|
459
464
|
// ─── Hook Resolution ──────────────────────────────────────────────────────────
|
|
@@ -32,11 +32,11 @@ export function getFilePaths() {
|
|
|
32
32
|
* Record a tool call at dispatch time (before execution).
|
|
33
33
|
* Exit codes and output are filled in by recordToolResult after execution.
|
|
34
34
|
*/
|
|
35
|
-
export function recordToolCall(toolName, input) {
|
|
35
|
+
export function recordToolCall(toolCallId, toolName, input) {
|
|
36
36
|
if (toolName === "bash" || toolName === "Bash") {
|
|
37
37
|
unitEvidence.push({
|
|
38
38
|
kind: "bash",
|
|
39
|
-
toolCallId
|
|
39
|
+
toolCallId,
|
|
40
40
|
command: String(input.command ?? ""),
|
|
41
41
|
exitCode: -1,
|
|
42
42
|
outputSnippet: "",
|
|
@@ -46,7 +46,7 @@ export function recordToolCall(toolName, input) {
|
|
|
46
46
|
else if (toolName === "write" || toolName === "Write") {
|
|
47
47
|
unitEvidence.push({
|
|
48
48
|
kind: "write",
|
|
49
|
-
toolCallId
|
|
49
|
+
toolCallId,
|
|
50
50
|
path: String(input.file_path ?? input.path ?? ""),
|
|
51
51
|
timestamp: Date.now(),
|
|
52
52
|
});
|
|
@@ -54,44 +54,29 @@ export function recordToolCall(toolName, input) {
|
|
|
54
54
|
else if (toolName === "edit" || toolName === "Edit") {
|
|
55
55
|
unitEvidence.push({
|
|
56
56
|
kind: "edit",
|
|
57
|
-
toolCallId
|
|
57
|
+
toolCallId,
|
|
58
58
|
path: String(input.file_path ?? input.path ?? ""),
|
|
59
59
|
timestamp: Date.now(),
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Record a tool execution result. Matches the
|
|
65
|
-
*
|
|
64
|
+
* Record a tool execution result. Matches the entry by toolCallId (assigned
|
|
65
|
+
* at dispatch time) and fills in exit code + output. Prior versions matched
|
|
66
|
+
* by `kind + empty-string` which corrupted parallel tool calls.
|
|
66
67
|
*/
|
|
67
68
|
export function recordToolResult(toolCallId, toolName, result, isError) {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
entry.exitCode = exitMatch ? Number(exitMatch[1]) : (isError ? 1 : 0);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else if (normalizedName === "write" || normalizedName === "edit") {
|
|
80
|
-
const entry = findLastUnresolved(normalizedName);
|
|
81
|
-
if (entry) {
|
|
82
|
-
entry.toolCallId = toolCallId;
|
|
83
|
-
}
|
|
69
|
+
const entry = unitEvidence.find(e => e.toolCallId === toolCallId);
|
|
70
|
+
if (!entry)
|
|
71
|
+
return;
|
|
72
|
+
if (entry.kind === "bash") {
|
|
73
|
+
const text = extractResultText(result);
|
|
74
|
+
entry.outputSnippet = text.slice(0, 500);
|
|
75
|
+
const exitMatch = text.match(/Command exited with code (\d+)/);
|
|
76
|
+
entry.exitCode = exitMatch ? Number(exitMatch[1]) : (isError ? 1 : 0);
|
|
84
77
|
}
|
|
85
78
|
}
|
|
86
79
|
// ─── Internals ──────────────────────────────────────────────────────────────
|
|
87
|
-
function findLastUnresolved(kind) {
|
|
88
|
-
for (let i = unitEvidence.length - 1; i >= 0; i--) {
|
|
89
|
-
if (unitEvidence[i].kind === kind && unitEvidence[i].toolCallId === "") {
|
|
90
|
-
return unitEvidence[i];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
80
|
function extractResultText(result) {
|
|
96
81
|
if (typeof result === "string")
|
|
97
82
|
return result;
|