gsd-pi 2.71.0-dev.e17e0ce → 2.72.0-dev.3118184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -3
- package/dist/cli.js +76 -3
- package/dist/mcp-server.js +37 -14
- package/dist/onboarding.js +10 -0
- package/dist/resources/agents/debugger.md +58 -0
- package/dist/resources/agents/doc-writer.md +43 -0
- package/dist/resources/agents/git-ops.md +56 -0
- package/dist/resources/agents/javascript-pro.md +46 -271
- package/dist/resources/agents/planner.md +55 -0
- package/dist/resources/agents/refactorer.md +47 -0
- package/dist/resources/agents/reviewer.md +48 -0
- package/dist/resources/agents/security.md +59 -0
- package/dist/resources/agents/tester.md +50 -0
- package/dist/resources/agents/typescript-pro.md +41 -235
- package/dist/resources/extensions/async-jobs/await-tool.js +7 -4
- package/dist/resources/extensions/async-jobs/job-manager.js +28 -3
- package/dist/resources/extensions/claude-code-cli/partial-builder.js +40 -12
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +132 -10
- package/dist/resources/extensions/gsd/auto/loop.js +84 -1
- package/dist/resources/extensions/gsd/auto/phases.js +4 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +6 -0
- package/dist/resources/extensions/gsd/auto-prompts.js +88 -33
- package/dist/resources/extensions/gsd/auto-recovery.js +11 -0
- package/dist/resources/extensions/gsd/auto-start.js +24 -4
- package/dist/resources/extensions/gsd/auto.js +29 -19
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +3 -3
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +9 -11
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +2 -5
- package/dist/resources/extensions/gsd/commands-handlers.js +4 -1
- package/dist/resources/extensions/gsd/context-injector.js +1 -1
- package/dist/resources/extensions/gsd/custom-workflow-engine.js +3 -7
- package/dist/resources/extensions/gsd/definition-io.js +15 -0
- package/dist/resources/extensions/gsd/dispatch-guard.js +4 -0
- package/dist/resources/extensions/gsd/doctor-providers.js +23 -0
- package/dist/resources/extensions/gsd/doctor-runtime-checks.js +6 -3
- package/dist/resources/extensions/gsd/error-classifier.js +4 -1
- package/dist/resources/extensions/gsd/gate-registry.js +208 -0
- package/dist/resources/extensions/gsd/git-service.js +11 -8
- package/dist/resources/extensions/gsd/gitignore.js +12 -6
- package/dist/resources/extensions/gsd/gsd-db.js +90 -6
- package/dist/resources/extensions/gsd/key-manager.js +2 -0
- package/dist/resources/extensions/gsd/milestone-validation-gates.js +11 -12
- package/dist/resources/extensions/gsd/notification-overlay.js +26 -12
- package/dist/resources/extensions/gsd/notification-store.js +5 -4
- package/dist/resources/extensions/gsd/preferences-skills.js +2 -34
- package/dist/resources/extensions/gsd/preferences-types.js +15 -0
- package/dist/resources/extensions/gsd/preferences.js +16 -3
- package/dist/resources/extensions/gsd/prompt-loader.js +4 -1
- package/dist/resources/extensions/gsd/prompt-validation.js +126 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +3 -1
- package/dist/resources/extensions/gsd/prompts/discuss.md +122 -13
- package/dist/resources/extensions/gsd/prompts/execute-task.md +2 -0
- package/dist/resources/extensions/gsd/prompts/system.md +1 -1
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/dist/resources/extensions/gsd/shortcut-defs.js +7 -1
- package/dist/resources/extensions/gsd/state.js +29 -2
- package/dist/resources/extensions/gsd/tools/complete-slice.js +52 -1
- package/dist/resources/extensions/gsd/tools/complete-task.js +51 -1
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +4 -1
- package/dist/resources/extensions/gsd/workflow-projections.js +7 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +30 -3
- package/dist/resources/extensions/gsd/write-intercept.js +10 -1
- package/dist/resources/extensions/ollama/index.js +17 -10
- package/dist/resources/extensions/ollama/ollama-client.js +35 -6
- package/dist/resources/extensions/ollama/ollama-discovery.js +32 -6
- package/dist/resources/extensions/shared/gsd-phase-state.js +35 -0
- package/dist/resources/extensions/subagent/agents.js +8 -0
- package/dist/resources/extensions/subagent/index.js +17 -0
- package/dist/startup-model-validation.d.ts +0 -1
- package/dist/startup-model-validation.js +6 -2
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
- 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/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +3 -3
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/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/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
- package/dist/web/standalone/.next/server/chunks/2331.js +16 -16
- package/dist/web/standalone/.next/server/chunks/4741.js +12 -12
- package/dist/web/standalone/.next/server/chunks/5822.js +2 -2
- package/dist/web/standalone/.next/server/chunks/63.js +8 -8
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- package/dist/web/standalone/.next/server/edge-runtime-webpack.js +2 -0
- package/dist/web/standalone/.next/server/functions-config-manifest.json +0 -9
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +29 -2
- package/dist/web/standalone/.next/server/middleware.js +4 -12
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/server/webpack-runtime.js +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/server.d.ts +12 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +90 -42
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +1 -1
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/server.ts +110 -38
- package/packages/mcp-server/src/workflow-tools.ts +1 -1
- package/packages/pi-ai/dist/env-api-keys.js +1 -0
- package/packages/pi-ai/dist/env-api-keys.js.map +1 -1
- package/packages/pi-ai/dist/models.custom.d.ts +105 -0
- package/packages/pi-ai/dist/models.custom.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.custom.js +97 -0
- package/packages/pi-ai/dist/models.custom.js.map +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +648 -140
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +867 -370
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/models.generated.test.d.ts +2 -0
- package/packages/pi-ai/dist/models.generated.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/models.generated.test.js +334 -0
- package/packages/pi-ai/dist/models.generated.test.js.map +1 -0
- package/packages/pi-ai/dist/models.test.js +105 -0
- package/packages/pi-ai/dist/models.test.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +1 -1
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +5 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +57 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -0
- package/packages/pi-ai/src/env-api-keys.ts +1 -0
- package/packages/pi-ai/src/models.custom.ts +98 -0
- package/packages/pi-ai/src/models.generated.test.ts +373 -0
- package/packages/pi-ai/src/models.generated.ts +867 -370
- package/packages/pi-ai/src/models.test.ts +135 -0
- package/packages/pi-ai/src/types.ts +1 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +71 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +4 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.js +75 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +5 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.js +55 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.test.js +57 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +9 -0
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +36 -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/model-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +9 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
- 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 +87 -12
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js +6 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/model-resolver.test.ts +85 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +1 -0
- package/packages/pi-coding-agent/src/core/retry-handler.test.ts +83 -0
- package/packages/pi-coding-agent/src/core/retry-handler.ts +60 -1
- package/packages/pi-coding-agent/src/core/sdk.ts +10 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +72 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +15 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +84 -12
- package/packages/pi-coding-agent/src/modes/interactive/controllers/model-controller.ts +6 -1
- package/packages/pi-tui/dist/components/__tests__/editor.test.js +12 -0
- package/packages/pi-tui/dist/components/__tests__/editor.test.js.map +1 -1
- package/packages/pi-tui/dist/components/__tests__/input.test.js +12 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js.map +1 -1
- package/packages/pi-tui/dist/keys.d.ts.map +1 -1
- package/packages/pi-tui/dist/keys.js +27 -0
- package/packages/pi-tui/dist/keys.js.map +1 -1
- package/packages/pi-tui/src/components/__tests__/editor.test.ts +18 -0
- package/packages/pi-tui/src/components/__tests__/input.test.ts +18 -0
- package/packages/pi-tui/src/keys.ts +32 -0
- package/pkg/package.json +1 -1
- package/src/resources/agents/debugger.md +58 -0
- package/src/resources/agents/doc-writer.md +43 -0
- package/src/resources/agents/git-ops.md +56 -0
- package/src/resources/agents/javascript-pro.md +46 -271
- package/src/resources/agents/planner.md +55 -0
- package/src/resources/agents/refactorer.md +47 -0
- package/src/resources/agents/reviewer.md +48 -0
- package/src/resources/agents/security.md +59 -0
- package/src/resources/agents/tester.md +50 -0
- package/src/resources/agents/typescript-pro.md +41 -235
- package/src/resources/extensions/async-jobs/await-tool.test.ts +40 -7
- package/src/resources/extensions/async-jobs/await-tool.ts +7 -4
- package/src/resources/extensions/async-jobs/job-manager.ts +33 -3
- package/src/resources/extensions/claude-code-cli/partial-builder.ts +45 -12
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +139 -8
- package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +91 -2
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +245 -2
- package/src/resources/extensions/gsd/auto/loop.ts +89 -1
- package/src/resources/extensions/gsd/auto/phases.ts +4 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +7 -0
- package/src/resources/extensions/gsd/auto-prompts.ts +111 -33
- package/src/resources/extensions/gsd/auto-recovery.ts +10 -0
- package/src/resources/extensions/gsd/auto-start.ts +31 -4
- package/src/resources/extensions/gsd/auto.ts +29 -20
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +3 -3
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +8 -10
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +2 -5
- package/src/resources/extensions/gsd/commands-handlers.ts +5 -1
- package/src/resources/extensions/gsd/context-injector.ts +1 -1
- package/src/resources/extensions/gsd/custom-workflow-engine.ts +4 -8
- package/src/resources/extensions/gsd/definition-io.ts +18 -0
- package/src/resources/extensions/gsd/dispatch-guard.ts +5 -0
- package/src/resources/extensions/gsd/doctor-providers.ts +24 -0
- package/src/resources/extensions/gsd/doctor-runtime-checks.ts +6 -3
- package/src/resources/extensions/gsd/error-classifier.ts +4 -1
- package/src/resources/extensions/gsd/gate-registry.ts +251 -0
- package/src/resources/extensions/gsd/git-service.ts +11 -8
- package/src/resources/extensions/gsd/gitignore.ts +12 -6
- package/src/resources/extensions/gsd/gsd-db.ts +105 -6
- package/src/resources/extensions/gsd/key-manager.ts +2 -0
- package/src/resources/extensions/gsd/milestone-validation-gates.ts +11 -13
- package/src/resources/extensions/gsd/notification-overlay.ts +27 -11
- package/src/resources/extensions/gsd/notification-store.ts +5 -4
- package/src/resources/extensions/gsd/preferences-skills.ts +2 -36
- package/src/resources/extensions/gsd/preferences-types.ts +16 -0
- package/src/resources/extensions/gsd/preferences.ts +19 -6
- package/src/resources/extensions/gsd/prompt-loader.ts +6 -1
- package/src/resources/extensions/gsd/prompt-validation.ts +157 -0
- package/src/resources/extensions/gsd/prompts/complete-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/discuss.md +122 -13
- package/src/resources/extensions/gsd/prompts/execute-task.md +2 -0
- package/src/resources/extensions/gsd/prompts/system.md +1 -1
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/src/resources/extensions/gsd/shortcut-defs.ts +8 -1
- package/src/resources/extensions/gsd/state.ts +33 -2
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/block-db-writes.test.ts +63 -0
- package/src/resources/extensions/gsd/tests/complete-slice-gate-closure.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/definition-io.test.ts +57 -0
- package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/doctor-heal-fixable-warnings.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/false-degraded-mode-warning.test.ts +104 -0
- package/src/resources/extensions/gsd/tests/format-shortcut.test.ts +16 -0
- package/src/resources/extensions/gsd/tests/gate-dispatch.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/gate-registry.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +107 -5
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +8 -6
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +63 -0
- package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/plan-milestone-artifact-verification.test.ts +62 -0
- package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +34 -0
- package/src/resources/extensions/gsd/tests/preferences-formatting.test.ts +87 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/projection-regression.test.ts +96 -1
- package/src/resources/extensions/gsd/tests/prompt-loader-working-directory.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/prompt-system-gate-coverage.test.ts +208 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +97 -0
- package/src/resources/extensions/gsd/tests/register-shortcuts.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +41 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +63 -0
- package/src/resources/extensions/gsd/tools/complete-task.ts +63 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +4 -1
- package/src/resources/extensions/gsd/types.ts +26 -0
- package/src/resources/extensions/gsd/workflow-projections.ts +8 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +29 -3
- package/src/resources/extensions/gsd/write-intercept.ts +10 -1
- package/src/resources/extensions/ollama/index.ts +17 -8
- package/src/resources/extensions/ollama/ollama-client.ts +35 -6
- package/src/resources/extensions/ollama/ollama-discovery.ts +37 -6
- package/src/resources/extensions/ollama/ollama-status-indicator.test.ts +28 -0
- package/src/resources/extensions/ollama/tests/ollama-discovery.test.ts +54 -0
- package/src/resources/extensions/shared/gsd-phase-state.ts +42 -0
- package/src/resources/extensions/shared/tests/gsd-phase-state.test.ts +48 -0
- package/src/resources/extensions/subagent/agents.ts +10 -0
- package/src/resources/extensions/subagent/index.ts +18 -0
- package/src/resources/extensions/subagent/tests/agents-conflicts.test.ts +33 -0
- /package/dist/web/standalone/.next/static/{cYPZv_bAhZk2ms-Pz6vsY → NzO79SOz9jHX-VY5-0t2O}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{cYPZv_bAhZk2ms-Pz6vsY → NzO79SOz9jHX-VY5-0t2O}/_ssgManifest.js +0 -0
|
@@ -2,254 +2,60 @@
|
|
|
2
2
|
name: typescript-pro
|
|
3
3
|
description: "TypeScript specialist for advanced type system patterns, complex generics, type-level programming, and end-to-end type safety across full-stack applications. Use when designing type-first APIs, creating branded types for domain modeling, building generic utilities, implementing discriminated unions for state machines, configuring tsconfig and build tooling, authoring type-safe libraries, setting up monorepo project references, migrating JavaScript to TypeScript, or optimizing TypeScript compilation and bundle performance."
|
|
4
4
|
model: sonnet
|
|
5
|
-
memory: project
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
You are a senior TypeScript developer with mastery of TypeScript 5.0+ and its ecosystem
|
|
7
|
+
You are a senior TypeScript developer with mastery of TypeScript 5.0+ and its ecosystem. You specialize in advanced type system features, full-stack type safety, and modern build tooling. Types are the specification — start there.
|
|
9
8
|
|
|
10
|
-
##
|
|
9
|
+
## Initialization
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
1. Read `tsconfig.json`, `package.json`, and build tool configs
|
|
12
|
+
2. Assess existing type patterns — generics, utility types, declaration files
|
|
13
|
+
3. Identify framework and runtime (React, Vue, Node.js, Deno)
|
|
14
|
+
4. Check lint/format config to align with project conventions
|
|
16
15
|
|
|
17
|
-
##
|
|
16
|
+
## Core Principles
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
- **Strict mode always**: `strict: true`, no `any` without documented justification
|
|
19
|
+
- **Type-first**: Define data shapes and API contracts before writing logic
|
|
20
|
+
- **Inference over annotation**: Let TypeScript infer where it produces correct, readable types
|
|
21
|
+
- **`satisfies` over type annotation**: Preserves literal types while validating
|
|
22
|
+
- **`as const`** for literal preservation in arrays and objects
|
|
23
|
+
- **`import type`** for type-only imports — reduces emit, improves tree shaking
|
|
24
|
+
- **Exhaustive checks** with `never` in switch/if-else — catch unhandled cases at compile time
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
2. **Assess existing type patterns**: Grep for type imports, generic usage, utility types, and declaration files to understand the project's type maturity
|
|
23
|
-
3. **Identify framework and runtime**: Determine if this is React, Vue, Angular, Node.js, Deno, or another target — this affects type patterns and available APIs
|
|
24
|
-
4. **Check existing lint/format config**: Look for .eslintrc, prettier config, biome config to align with project conventions
|
|
26
|
+
## Key Patterns
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
- Conditional types for flexible APIs: `T extends Array<infer U> ? { data: U[] } : { data: T }`
|
|
29
|
+
- Mapped types for transformations: `{ readonly [K in keyof T]: T[K] }`
|
|
30
|
+
- Template literal types for string manipulation: `` `on${Capitalize<T>}` ``
|
|
31
|
+
- Discriminated unions for state machines — each variant has a literal tag
|
|
32
|
+
- Branded types for domain modeling: `T & { readonly __brand: B }`
|
|
33
|
+
- Result types for error handling: `{ ok: true; value: T } | { ok: false; error: E }`
|
|
34
|
+
- Type guards at runtime boundaries — validate all external data (APIs, user input, files)
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
## Build & Tooling
|
|
29
37
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- [ ] Generic constraints are as narrow as possible
|
|
37
|
-
- [ ] Discriminated unions preferred over optional fields for variant types
|
|
38
|
+
- `moduleResolution: "bundler"` for modern bundler projects
|
|
39
|
+
- `isolatedModules: true` for esbuild/SWC compatibility
|
|
40
|
+
- `incremental: true` with `.tsbuildinfo` for faster rebuilds
|
|
41
|
+
- `composite: true` + `declarationMap: true` for monorepo project references
|
|
42
|
+
- Type-only imports to reduce emit and improve tree shaking
|
|
43
|
+
- Monitor type instantiation counts with `--generateTrace` for slow compiles
|
|
38
44
|
|
|
39
|
-
##
|
|
45
|
+
## Testing
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
**Conditional types** for flexible APIs:
|
|
44
|
-
```typescript
|
|
45
|
-
type ApiResponse<T> = T extends Array<infer U>
|
|
46
|
-
? { data: U[]; total: number }
|
|
47
|
-
: { data: T };
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Mapped types** for transformations:
|
|
51
|
-
```typescript
|
|
52
|
-
type Readonly<T> = { readonly [K in keyof T]: T[K] };
|
|
53
|
-
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Template literal types** for string manipulation:
|
|
57
|
-
```typescript
|
|
58
|
-
type EventName<T extends string> = `on${Capitalize<T>}`;
|
|
59
|
-
type RouteParam<T extends string> = T extends `${infer _}:${infer Param}/${infer Rest}`
|
|
60
|
-
? Param | RouteParam<Rest>
|
|
61
|
-
: T extends `${infer _}:${infer Param}` ? Param : never;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Discriminated unions** for state machines:
|
|
65
|
-
```typescript
|
|
66
|
-
type State =
|
|
67
|
-
| { status: 'idle' }
|
|
68
|
-
| { status: 'loading'; startedAt: number }
|
|
69
|
-
| { status: 'success'; data: unknown; completedAt: number }
|
|
70
|
-
| { status: 'error'; error: Error; failedAt: number };
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Branded types** for domain modeling:
|
|
74
|
-
```typescript
|
|
75
|
-
type Brand<T, B extends string> = T & { readonly __brand: B };
|
|
76
|
-
type UserId = Brand<string, 'UserId'>;
|
|
77
|
-
type OrderId = Brand<string, 'OrderId'>;
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**Result types** for error handling:
|
|
81
|
-
```typescript
|
|
82
|
-
type Result<T, E = Error> =
|
|
83
|
-
| { ok: true; value: T }
|
|
84
|
-
| { ok: false; error: E };
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Implementation Strategy
|
|
88
|
-
|
|
89
|
-
When implementing TypeScript code:
|
|
90
|
-
|
|
91
|
-
1. **Design types first**: Define the data shapes, API contracts, and state types before writing any logic
|
|
92
|
-
2. **Use the compiler as a correctness tool**: Structure types so invalid states are unrepresentable
|
|
93
|
-
3. **Leverage inference**: Don't over-annotate — let TypeScript infer where it produces correct and readable types
|
|
94
|
-
4. **Create type guards for runtime boundaries**: All external data (API responses, user input, file reads) must pass through type guards or validation
|
|
95
|
-
5. **Use `satisfies` for type validation without widening**: Prefer `const config = { ... } satisfies Config` over `const config: Config = { ... }` when you want to preserve literal types
|
|
96
|
-
6. **Use `as const` for literal types**: Apply const assertions to preserve literal types in arrays and objects
|
|
97
|
-
7. **Exhaustive checking**: Use `never` type in switch/if-else chains to ensure all cases are handled
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
function assertNever(x: never): never {
|
|
101
|
-
throw new Error(`Unexpected value: ${x}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function handleState(state: State): string {
|
|
105
|
-
switch (state.status) {
|
|
106
|
-
case 'idle': return 'Waiting';
|
|
107
|
-
case 'loading': return 'Loading...';
|
|
108
|
-
case 'success': return 'Done';
|
|
109
|
-
case 'error': return state.error.message;
|
|
110
|
-
default: return assertNever(state);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Build and Tooling Optimization
|
|
116
|
-
|
|
117
|
-
**tsconfig.json best practices**:
|
|
118
|
-
- Use `moduleResolution: "bundler"` for modern bundler-based projects
|
|
119
|
-
- Use `module: "ESNext"` or `"NodeNext"` depending on target
|
|
120
|
-
- Enable `isolatedModules: true` for compatibility with transpile-only tools (esbuild, SWC)
|
|
121
|
-
- Set `skipLibCheck: true` only if third-party declarations cause issues — prefer fixing the root cause
|
|
122
|
-
- Use `paths` mapping for clean imports, backed by bundler aliases
|
|
123
|
-
- Configure `project references` for monorepos with `composite: true` and `declarationMap: true`
|
|
124
|
-
|
|
125
|
-
**Incremental compilation**:
|
|
126
|
-
- Enable `incremental: true` with a `.tsbuildinfo` output path
|
|
127
|
-
- Use `--build` mode for project references
|
|
128
|
-
- Configure `tsBuildInfoFile` to a persistent location in CI
|
|
129
|
-
|
|
130
|
-
**Performance tuning**:
|
|
131
|
-
- Use `type-only imports` to reduce emit and improve tree shaking
|
|
132
|
-
- Prefer `const enum` only when bundle size savings justify the trade-off (they don't work with `isolatedModules`)
|
|
133
|
-
- Avoid deeply recursive conditional types in hot paths — they slow the compiler
|
|
134
|
-
- Monitor type instantiation counts with `--generateTrace`
|
|
135
|
-
|
|
136
|
-
## Testing With Types
|
|
137
|
-
|
|
138
|
-
- Write type tests using `expectTypeOf` (from vitest) or `tsd` for declaration testing
|
|
139
|
-
- Create type-safe test utilities and fixtures
|
|
140
|
-
- Use generic factory functions for test data
|
|
141
|
-
- Ensure mock types match the real implementations
|
|
47
|
+
- Type tests with `expectTypeOf` (vitest) or `tsd` for declaration testing
|
|
48
|
+
- Type-safe test utilities and generic factory functions for test data
|
|
142
49
|
- Test type narrowing paths explicitly
|
|
50
|
+
- Ensure mock types match real implementations
|
|
143
51
|
|
|
144
|
-
|
|
145
|
-
import { expectTypeOf } from 'vitest';
|
|
146
|
-
|
|
147
|
-
test('type narrowing works', () => {
|
|
148
|
-
const result: Result<string> = { ok: true, value: 'hello' };
|
|
149
|
-
if (result.ok) {
|
|
150
|
-
expectTypeOf(result.value).toBeString();
|
|
151
|
-
} else {
|
|
152
|
-
expectTypeOf(result.error).toEqualTypeOf<Error>();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Full-Stack Type Safety
|
|
158
|
-
|
|
159
|
-
- **tRPC**: Use for end-to-end type safety between client and server without code generation
|
|
160
|
-
- **GraphQL**: Use code generation (graphql-codegen) for type-safe queries and mutations
|
|
161
|
-
- **OpenAPI**: Generate TypeScript clients from OpenAPI specs
|
|
162
|
-
- **Shared packages**: Extract shared types into dedicated packages in monorepos
|
|
163
|
-
- **Database types**: Use query builders (Prisma, Drizzle, Kysely) that generate types from schema
|
|
164
|
-
- **Form validation**: Use Zod schemas that infer TypeScript types (`z.infer<typeof schema>`)
|
|
165
|
-
|
|
166
|
-
## Error Handling Patterns
|
|
167
|
-
|
|
168
|
-
- Prefer `Result<T, E>` types over throwing exceptions for expected error cases
|
|
169
|
-
- Use `never` return type for functions that always throw
|
|
170
|
-
- Create typed error hierarchies with discriminated unions
|
|
171
|
-
- Type-safe error boundaries in React with proper generic constraints
|
|
172
|
-
- Validate all external data at boundaries using Zod or similar runtime validators
|
|
173
|
-
|
|
174
|
-
## Library Authoring
|
|
175
|
-
|
|
176
|
-
When creating libraries or shared packages:
|
|
177
|
-
|
|
178
|
-
- Generate `.d.ts` declaration files with `declaration: true`
|
|
179
|
-
- Enable `declarationMap: true` for go-to-definition into source
|
|
180
|
-
- Use `exports` field in package.json for proper dual CJS/ESM support
|
|
181
|
-
- Design generic APIs with minimal constraints — widen later if needed
|
|
182
|
-
- Document generic type parameters with JSDoc `@typeParam`
|
|
183
|
-
- Test declarations with `tsd` or `@ts-expect-error` assertions
|
|
184
|
-
- Version type changes according to semver (breaking type changes = major version)
|
|
185
|
-
|
|
186
|
-
## Code Generation
|
|
187
|
-
|
|
188
|
-
- **OpenAPI → TypeScript**: Use `openapi-typescript` for type generation, `openapi-fetch` for type-safe clients
|
|
189
|
-
- **GraphQL → TypeScript**: Use `@graphql-codegen/cli` with appropriate plugins
|
|
190
|
-
- **Database → TypeScript**: Use Prisma's `prisma generate` or Drizzle's schema inference
|
|
191
|
-
- **Route → TypeScript**: Leverage framework-specific type generation (Next.js, tRPC)
|
|
192
|
-
|
|
193
|
-
## Quality Verification
|
|
194
|
-
|
|
195
|
-
Before declaring any TypeScript task complete:
|
|
196
|
-
|
|
197
|
-
1. **Compile check**: Run `npx tsc --noEmit` and resolve all errors
|
|
198
|
-
2. **Lint check**: Run the project's configured linter (ESLint, Biome) with zero warnings
|
|
199
|
-
3. **Type coverage**: Verify no untyped public APIs remain
|
|
200
|
-
4. **Test execution**: Run the test suite and verify passing
|
|
201
|
-
5. **Bundle analysis**: If applicable, verify bundle size impact
|
|
202
|
-
6. **Declaration quality**: If library code, verify generated `.d.ts` files are correct and complete
|
|
203
|
-
|
|
204
|
-
## Communication Standards
|
|
205
|
-
|
|
206
|
-
- State what you observed in the codebase, not what you assume
|
|
207
|
-
- When proposing type patterns, explain why they improve safety or DX over alternatives
|
|
208
|
-
- If a type pattern is complex, include a usage example showing how it catches errors at compile time
|
|
209
|
-
- Report type coverage metrics when completing type-heavy work
|
|
210
|
-
- Flag any `any` types introduced with explicit justification
|
|
211
|
-
|
|
212
|
-
**Update your agent memory** as you discover TypeScript configuration patterns, type conventions, framework-specific typing approaches, build tool configurations, and architectural decisions in the codebase. Write concise notes about what you found and where.
|
|
213
|
-
|
|
214
|
-
Examples of what to record:
|
|
215
|
-
- tsconfig.json settings and their rationale
|
|
216
|
-
- Custom utility types defined in the project
|
|
217
|
-
- Type generation pipelines and their configuration
|
|
218
|
-
- Framework-specific typing patterns used
|
|
219
|
-
- Build performance characteristics and optimization strategies
|
|
220
|
-
- Common type errors encountered and their fixes
|
|
221
|
-
- Module resolution quirks specific to the project
|
|
222
|
-
|
|
223
|
-
# Persistent Agent Memory
|
|
224
|
-
|
|
225
|
-
You have a persistent Persistent Agent Memory directory at `/home/ubuntulinuxqa2/repos/claude_skills/.claude/agent-memory/typescript-pro/`. Its contents persist across conversations.
|
|
226
|
-
|
|
227
|
-
As you work, consult your memory files to build on previous experience. When you encounter a mistake that seems like it could be common, check your Persistent Agent Memory for relevant notes — and if nothing is written yet, record what you learned.
|
|
228
|
-
|
|
229
|
-
Guidelines:
|
|
230
|
-
- `MEMORY.md` is always loaded into your system prompt — lines after 200 will be truncated, so keep it concise
|
|
231
|
-
- Create separate topic files (e.g., `debugging.md`, `patterns.md`) for detailed notes and link to them from MEMORY.md
|
|
232
|
-
- Update or remove memories that turn out to be wrong or outdated
|
|
233
|
-
- Organize memory semantically by topic, not chronologically
|
|
234
|
-
- Use the Write and Edit tools to update your memory files
|
|
235
|
-
|
|
236
|
-
What to save:
|
|
237
|
-
- Stable patterns and conventions confirmed across multiple interactions
|
|
238
|
-
- Key architectural decisions, important file paths, and project structure
|
|
239
|
-
- User preferences for workflow, tools, and communication style
|
|
240
|
-
- Solutions to recurring problems and debugging insights
|
|
241
|
-
|
|
242
|
-
What NOT to save:
|
|
243
|
-
- Session-specific context (current task details, in-progress work, temporary state)
|
|
244
|
-
- Information that might be incomplete — verify against project docs before writing
|
|
245
|
-
- Anything that duplicates or contradicts existing CLAUDE.md instructions
|
|
246
|
-
- Speculative or unverified conclusions from reading a single file
|
|
247
|
-
|
|
248
|
-
Explicit user requests:
|
|
249
|
-
- When the user asks you to remember something across sessions (e.g., "always use bun", "never auto-commit"), save it — no need to wait for multiple interactions
|
|
250
|
-
- When the user asks to forget or stop remembering something, find and remove the relevant entries from your memory files
|
|
251
|
-
- Since this memory is project-scope and shared with your team via version control, tailor your memories to this project
|
|
52
|
+
## Verification Checklist
|
|
252
53
|
|
|
253
|
-
|
|
54
|
+
1. `npx tsc --noEmit` — zero errors
|
|
55
|
+
2. Linter passes with zero warnings
|
|
56
|
+
3. No untyped public APIs remain
|
|
57
|
+
4. Tests passing, coverage target met
|
|
58
|
+
5. Declaration files correct for library code
|
|
59
|
+
6. No `any` without justification comment
|
|
254
60
|
|
|
255
|
-
|
|
61
|
+
Report concrete outcomes — files changed, type coverage, test results, trade-offs made.
|
|
@@ -119,12 +119,10 @@ test("await_job returns not-found message for invalid job IDs", async () => {
|
|
|
119
119
|
manager.shutdown();
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
test("await_job
|
|
122
|
+
test("await_job suppresses follow-up for jobs that complete while awaiting (#2248)", async () => {
|
|
123
123
|
const followUps: string[] = [];
|
|
124
124
|
const manager = new AsyncJobManager({
|
|
125
|
-
onJobComplete: (job) =>
|
|
126
|
-
if (!job.awaited) followUps.push(job.id);
|
|
127
|
-
},
|
|
125
|
+
onJobComplete: (job) => followUps.push(job.id),
|
|
128
126
|
});
|
|
129
127
|
const tool = createAwaitTool(() => manager);
|
|
130
128
|
|
|
@@ -133,13 +131,48 @@ test("await_job marks jobs as awaited to suppress follow-up delivery (#2248)", a
|
|
|
133
131
|
return new Promise<string>((resolve) => setTimeout(() => resolve("result"), 50));
|
|
134
132
|
});
|
|
135
133
|
|
|
136
|
-
// await_job consumes the result — should
|
|
134
|
+
// await_job consumes the result — suppressFollowUp() should cancel delivery timer
|
|
137
135
|
await tool.execute("tc7", { jobs: [jobId] }, noopSignal, () => {}, undefined as never);
|
|
138
136
|
|
|
139
|
-
// Give the onJobComplete callback a tick to fire
|
|
137
|
+
// Give the onJobComplete callback a tick to fire (if suppression failed)
|
|
138
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
139
|
+
|
|
140
|
+
assert.equal(followUps.length, 0, "onJobComplete should not fire for jobs consumed by await_job");
|
|
141
|
+
|
|
142
|
+
manager.shutdown();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("await_job suppresses follow-up for already-completed jobs (cross-turn case) (#3787)", async () => {
|
|
146
|
+
// This is the key regression: job completes in a prior LLM turn, then
|
|
147
|
+
// await_job is called in a later turn. The delivery timer must still be
|
|
148
|
+
// cancellable at that point.
|
|
149
|
+
const followUps: string[] = [];
|
|
150
|
+
const manager = new AsyncJobManager({
|
|
151
|
+
onJobComplete: (job) => followUps.push(job.id),
|
|
152
|
+
});
|
|
153
|
+
const tool = createAwaitTool(() => manager);
|
|
154
|
+
|
|
155
|
+
// Register and let the job complete fully before calling await_job
|
|
156
|
+
const jobId = manager.register("bash", "pre-completed-job", async () => "done");
|
|
157
|
+
const job = manager.getJob(jobId)!;
|
|
158
|
+
await job.promise;
|
|
159
|
+
|
|
160
|
+
// Simulate a "later turn" by yielding to the event loop — this lets any
|
|
161
|
+
// queueMicrotask callbacks run, but the setTimeout(0) delivery timer has
|
|
162
|
+
// not yet fired (it's scheduled for the next macrotask).
|
|
163
|
+
await new Promise((r) => setImmediate(r));
|
|
164
|
+
|
|
165
|
+
// Now call await_job — suppressFollowUp() should cancel the pending timer
|
|
166
|
+
await tool.execute("tc7b", { jobs: [jobId] }, noopSignal, () => {}, undefined as never);
|
|
167
|
+
|
|
168
|
+
// Drain the macrotask queue — the (now-cancelled) timer would have fired here
|
|
140
169
|
await new Promise((r) => setTimeout(r, 50));
|
|
141
170
|
|
|
142
|
-
assert.equal(
|
|
171
|
+
assert.equal(
|
|
172
|
+
followUps.length,
|
|
173
|
+
0,
|
|
174
|
+
"onJobComplete should not fire for already-completed jobs consumed by await_job",
|
|
175
|
+
);
|
|
143
176
|
|
|
144
177
|
manager.shutdown();
|
|
145
178
|
});
|
|
@@ -66,10 +66,13 @@ export function createAwaitTool(getManager: () => AsyncJobManager): ToolDefiniti
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
69
|
+
// Suppress follow-up notifications for all watched jobs upfront.
|
|
70
|
+
// suppressFollowUp() cancels the pending delivery timer (if any), which
|
|
71
|
+
// handles both the within-turn case (job completes while we await) and
|
|
72
|
+
// the cross-turn case (job already completed before await_job was called).
|
|
73
|
+
// Previously this only set j.awaited = true, which missed the cross-turn
|
|
74
|
+
// case because the queueMicrotask had already fired (#3787).
|
|
75
|
+
for (const j of watched) manager.suppressFollowUp(j.id);
|
|
73
76
|
|
|
74
77
|
// If all watched jobs are already done, return immediately
|
|
75
78
|
const running = watched.filter((j) => j.status === "running");
|
|
@@ -24,6 +24,12 @@ export interface Job {
|
|
|
24
24
|
errorText?: string;
|
|
25
25
|
/** Set by await_job when results are consumed. Suppresses follow-up delivery. */
|
|
26
26
|
awaited?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Handle for the pending follow-up delivery timer (set by deliverResult).
|
|
29
|
+
* Stored so suppressFollowUp() can cancel it before the notification fires,
|
|
30
|
+
* even when await_job is called after the job has already completed (#3787).
|
|
31
|
+
*/
|
|
32
|
+
deliveryTimer?: ReturnType<typeof setTimeout>;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export interface JobManagerOptions {
|
|
@@ -170,12 +176,36 @@ export class AsyncJobManager {
|
|
|
170
176
|
|
|
171
177
|
// ── Private ────────────────────────────────────────────────────────────
|
|
172
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Suppress follow-up notification for a job — cancels any pending delivery
|
|
181
|
+
* timer and marks the job as awaited. Safe to call at any time, including
|
|
182
|
+
* before or after the job completes (#3787).
|
|
183
|
+
*/
|
|
184
|
+
suppressFollowUp(id: string): void {
|
|
185
|
+
const job = this.jobs.get(id);
|
|
186
|
+
if (!job) return;
|
|
187
|
+
job.awaited = true;
|
|
188
|
+
if (job.deliveryTimer !== undefined) {
|
|
189
|
+
clearTimeout(job.deliveryTimer);
|
|
190
|
+
job.deliveryTimer = undefined;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
173
194
|
private deliverResult(job: Job): void {
|
|
174
195
|
if (!this.onJobComplete) return;
|
|
175
|
-
//
|
|
176
|
-
//
|
|
196
|
+
// Use setTimeout(0) instead of queueMicrotask so the handle is cancellable.
|
|
197
|
+
// suppressFollowUp() can clear this timer even when await_job is called in
|
|
198
|
+
// a later LLM turn (after the job already completed). queueMicrotask ran
|
|
199
|
+
// immediately and could not be cancelled (#2762, #3787).
|
|
177
200
|
const cb = this.onJobComplete;
|
|
178
|
-
|
|
201
|
+
job.deliveryTimer = setTimeout(() => {
|
|
202
|
+
job.deliveryTimer = undefined;
|
|
203
|
+
if (!job.awaited) cb(job);
|
|
204
|
+
}, 0);
|
|
205
|
+
// Allow process to exit even if timer is pending
|
|
206
|
+
if (typeof job.deliveryTimer === "object" && "unref" in job.deliveryTimer) {
|
|
207
|
+
(job.deliveryTimer as NodeJS.Timeout).unref();
|
|
208
|
+
}
|
|
179
209
|
}
|
|
180
210
|
|
|
181
211
|
private scheduleEviction(id: string): void {
|
|
@@ -19,6 +19,49 @@ import type {
|
|
|
19
19
|
import { hasXmlParameterTags, repairToolJson } from "@gsd/pi-ai";
|
|
20
20
|
import type { BetaContentBlock, BetaRawMessageStreamEvent, NonNullableUsage } from "./sdk-types.js";
|
|
21
21
|
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// MCP tool name parsing
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Split a Claude Code MCP tool name (`mcp__<server>__<tool>`) into its parts.
|
|
28
|
+
* Returns null for non-prefixed names so callers can fall through unchanged.
|
|
29
|
+
*
|
|
30
|
+
* Server names may contain hyphens (`gsd-workflow`); the SDK uses the literal
|
|
31
|
+
* `__` delimiter between the server name and the tool name.
|
|
32
|
+
*/
|
|
33
|
+
export function parseMcpToolName(name: string): { server: string; tool: string } | null {
|
|
34
|
+
if (!name.startsWith("mcp__")) return null;
|
|
35
|
+
const rest = name.slice("mcp__".length);
|
|
36
|
+
const delim = rest.indexOf("__");
|
|
37
|
+
if (delim <= 0 || delim === rest.length - 2) return null;
|
|
38
|
+
return { server: rest.slice(0, delim), tool: rest.slice(delim + 2) };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Build a GSD ToolCall block from a Claude Code SDK tool_use block, stripping
|
|
43
|
+
* the `mcp__<server>__` prefix from the name so registered extension renderers
|
|
44
|
+
* (which use the unprefixed canonical names) can match. The original server
|
|
45
|
+
* name is preserved on the block for diagnostics and rendering.
|
|
46
|
+
*/
|
|
47
|
+
function toolCallFromBlock(
|
|
48
|
+
id: string,
|
|
49
|
+
rawName: string,
|
|
50
|
+
input: Record<string, unknown>,
|
|
51
|
+
): ToolCall {
|
|
52
|
+
const parsed = parseMcpToolName(rawName);
|
|
53
|
+
const toolCall: ToolCall = {
|
|
54
|
+
type: "toolCall",
|
|
55
|
+
id,
|
|
56
|
+
name: parsed ? parsed.tool : rawName,
|
|
57
|
+
arguments: input,
|
|
58
|
+
};
|
|
59
|
+
if (parsed) {
|
|
60
|
+
(toolCall as ToolCall & { mcpServer?: string }).mcpServer = parsed.server;
|
|
61
|
+
}
|
|
62
|
+
return toolCall;
|
|
63
|
+
}
|
|
64
|
+
|
|
22
65
|
// ---------------------------------------------------------------------------
|
|
23
66
|
// Content-block mapping helpers
|
|
24
67
|
// ---------------------------------------------------------------------------
|
|
@@ -41,12 +84,7 @@ export function mapContentBlock(
|
|
|
41
84
|
} satisfies ThinkingContent;
|
|
42
85
|
|
|
43
86
|
case "tool_use":
|
|
44
|
-
return
|
|
45
|
-
type: "toolCall",
|
|
46
|
-
id: block.id,
|
|
47
|
-
name: block.name,
|
|
48
|
-
arguments: block.input,
|
|
49
|
-
} satisfies ToolCall;
|
|
87
|
+
return toolCallFromBlock(block.id, block.name, block.input);
|
|
50
88
|
|
|
51
89
|
case "server_tool_use":
|
|
52
90
|
return {
|
|
@@ -183,12 +221,7 @@ export class PartialMessageBuilder {
|
|
|
183
221
|
}
|
|
184
222
|
if (block.type === "tool_use") {
|
|
185
223
|
this.toolJsonAccum.set(streamIndex, "");
|
|
186
|
-
this.partial.content.push({
|
|
187
|
-
type: "toolCall",
|
|
188
|
-
id: block.id,
|
|
189
|
-
name: block.name,
|
|
190
|
-
arguments: {},
|
|
191
|
-
});
|
|
224
|
+
this.partial.content.push(toolCallFromBlock(block.id, block.name, {}));
|
|
192
225
|
return { type: "toolcall_start", contentIndex, partial: this.partial };
|
|
193
226
|
}
|
|
194
227
|
if (block.type === "server_tool_use") {
|