gsd-pi 2.80.0-dev.c5f2443b3 → 2.80.0-dev.d4fc28e6b
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 +4 -2
- package/dist/cli.js +0 -19
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +2 -2
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +29 -0
- package/dist/resources/extensions/github-sync/templates.js +39 -8
- package/dist/resources/extensions/gsd/auto/loop.js +119 -18
- package/dist/resources/extensions/gsd/auto/phases.js +212 -135
- package/dist/resources/extensions/gsd/auto/resolve.js +29 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +41 -45
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto/workflow-dispatch-claim.js +33 -1
- package/dist/resources/extensions/gsd/auto/workflow-worker-heartbeat.js +9 -1
- package/dist/resources/extensions/gsd/auto-dashboard.js +51 -15
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +26 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +27 -14
- package/dist/resources/extensions/gsd/auto-prompts.js +214 -17
- package/dist/resources/extensions/gsd/auto-recovery.js +197 -9
- package/dist/resources/extensions/gsd/auto-start.js +199 -9
- package/dist/resources/extensions/gsd/auto-supervisor.js +8 -1
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +111 -1
- package/dist/resources/extensions/gsd/auto.js +95 -27
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +103 -3
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +49 -36
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +15 -5
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +33 -20
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +7 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +8 -2
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +330 -55
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +129 -1
- package/dist/resources/extensions/gsd/clean-root-preflight.js +65 -9
- package/dist/resources/extensions/gsd/commands/dispatcher.js +5 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +17 -12
- package/dist/resources/extensions/gsd/commands-handlers.js +23 -9
- package/dist/resources/extensions/gsd/context-budget.js +37 -2
- package/dist/resources/extensions/gsd/crash-recovery.js +56 -10
- package/dist/resources/extensions/gsd/custom-workflow-engine.js +22 -2
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +92 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +18 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +22 -0
- package/dist/resources/extensions/gsd/detection.js +106 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +36 -4
- package/dist/resources/extensions/gsd/graph.js +9 -3
- package/dist/resources/extensions/gsd/gsd-db.js +146 -13
- package/dist/resources/extensions/gsd/guided-flow.js +129 -44
- package/dist/resources/extensions/gsd/memory-store.js +69 -12
- package/dist/resources/extensions/gsd/migrate/command.js +40 -1
- package/dist/resources/extensions/gsd/migration-auto-check.js +87 -0
- package/dist/resources/extensions/gsd/native-git-bridge.js +32 -8
- package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +13 -3
- package/dist/resources/extensions/gsd/planning-path-scope.js +26 -0
- package/dist/resources/extensions/gsd/pr-evidence.js +57 -16
- package/dist/resources/extensions/gsd/pre-execution-checks.js +22 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +28 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +21 -19
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/dist/resources/extensions/gsd/quick.js +34 -2
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +10 -2
- package/dist/resources/extensions/gsd/tools/context-mode-tool-result.js +15 -0
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +3 -15
- package/dist/resources/extensions/gsd/tools/memory-tools.js +1 -0
- package/dist/resources/extensions/gsd/tools/plan-slice.js +9 -0
- package/dist/resources/extensions/gsd/tools/plan-task.js +9 -0
- package/dist/resources/extensions/gsd/tools/resume-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +1 -1
- package/dist/resources/extensions/gsd/unit-context-composer.js +12 -3
- package/dist/resources/extensions/gsd/unit-runtime.js +22 -0
- package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
- package/dist/resources/extensions/gsd/working-output-messages.js +64 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +16 -14
- package/dist/resources/extensions/gsd/worktree-resolver.js +68 -21
- 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 +11 -11
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +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.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/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 +11 -11
- 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-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/{8336.6f6f30e410419aff.js → 8336.631939fb583761fa.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/{webpack-d82dbee6356c1733.js → webpack-0481f1221120a7c6.js} +1 -1
- package/dist/welcome-screen.d.ts +2 -0
- package/dist/welcome-screen.js +9 -7
- package/package.json +12 -8
- package/packages/contracts/package.json +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +22 -17
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +75 -2
- package/packages/mcp-server/src/workflow-tools.ts +30 -16
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +4 -1
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +5 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +2 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/index.d.ts +1 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/index.js +2 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -1
- package/packages/pi-agent-core/dist/token-audit.d.ts +47 -0
- package/packages/pi-agent-core/dist/token-audit.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/token-audit.js +221 -0
- package/packages/pi-agent-core/dist/token-audit.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +9 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.test.ts +128 -0
- package/packages/pi-agent-core/src/agent-loop.ts +4 -1
- package/packages/pi-agent-core/src/agent.ts +8 -0
- package/packages/pi-agent-core/src/index.ts +2 -0
- package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
- package/packages/pi-agent-core/src/token-audit.ts +287 -0
- package/packages/pi-agent-core/src/types.ts +14 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/models/fake-model.d.ts +12 -0
- package/packages/pi-ai/dist/models/fake-model.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/fake-model.js +27 -0
- package/packages/pi-ai/dist/models/fake-model.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/models/index.js +8 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/fake.d.ts +42 -0
- package/packages/pi-ai/dist/providers/fake.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/fake.js +319 -0
- package/packages/pi-ai/dist/providers/fake.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js +24 -0
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
- package/packages/pi-ai/src/models/fake-model.ts +30 -0
- package/packages/pi-ai/src/models/index.ts +9 -0
- package/packages/pi-ai/src/providers/fake.ts +376 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +23 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +32 -0
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js +18 -0
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +44 -7
- 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 +76 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +9 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js +103 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js +66 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js +24 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +8 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +5 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +20 -7
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +102 -3
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +39 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +5 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js +46 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +10 -2
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +74 -2
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +24 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +33 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js +22 -0
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +6 -7
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +2 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +6 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +54 -15
- 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/adaptive-layout.d.ts +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +112 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +51 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +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.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +10 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +17 -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 +109 -17
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.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 +69 -2
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +93 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +3 -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 +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js +79 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +18 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js +18 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +48 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +10 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +3 -2
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +36 -0
- package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +25 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +48 -7
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +89 -0
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +18 -0
- package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +10 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +113 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +24 -6
- package/packages/pi-coding-agent/src/core/extensions/types.ts +42 -1
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +4 -0
- package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +85 -3
- package/packages/pi-coding-agent/src/core/settings-manager.ts +51 -1
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/slash-commands.ts +1 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +78 -15
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +160 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +15 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +122 -17
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +99 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +92 -3
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.test.ts +95 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +24 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.ts +13 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +32 -2
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +65 -0
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.ts +29 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +14 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/style.test.d.ts +2 -0
- package/packages/pi-tui/dist/__tests__/style.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/__tests__/style.test.js +63 -0
- package/packages/pi-tui/dist/__tests__/style.test.js.map +1 -0
- package/packages/pi-tui/dist/__tests__/tui.test.js +24 -3
- package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
- package/packages/pi-tui/dist/index.d.ts +1 -0
- package/packages/pi-tui/dist/index.d.ts.map +1 -1
- package/packages/pi-tui/dist/index.js +2 -0
- package/packages/pi-tui/dist/index.js.map +1 -1
- package/packages/pi-tui/dist/style.d.ts +41 -0
- package/packages/pi-tui/dist/style.d.ts.map +1 -0
- package/packages/pi-tui/dist/style.js +158 -0
- package/packages/pi-tui/dist/style.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +0 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +21 -16
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/__tests__/style.test.ts +76 -0
- package/packages/pi-tui/src/__tests__/tui.test.ts +29 -3
- package/packages/pi-tui/src/index.ts +9 -0
- package/packages/pi-tui/src/style.ts +225 -0
- package/packages/pi-tui/src/tui.ts +23 -16
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +18 -1
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.js +36 -27
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/src/resources/GSD-WORKFLOW.md +2 -2
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +30 -0
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +26 -0
- package/src/resources/extensions/github-sync/templates.ts +38 -8
- package/src/resources/extensions/github-sync/tests/inline-code.test.ts +66 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +3 -2
- package/src/resources/extensions/gsd/auto/loop.ts +151 -26
- package/src/resources/extensions/gsd/auto/phases.ts +289 -196
- package/src/resources/extensions/gsd/auto/resolve.ts +42 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +52 -44
- package/src/resources/extensions/gsd/auto/session.ts +8 -0
- package/src/resources/extensions/gsd/auto/workflow-dispatch-claim.ts +63 -1
- package/src/resources/extensions/gsd/auto/workflow-worker-heartbeat.ts +14 -1
- package/src/resources/extensions/gsd/auto-dashboard.ts +57 -8
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +33 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +28 -14
- package/src/resources/extensions/gsd/auto-prompts.ts +228 -16
- package/src/resources/extensions/gsd/auto-recovery.ts +207 -7
- package/src/resources/extensions/gsd/auto-start.ts +237 -15
- package/src/resources/extensions/gsd/auto-supervisor.ts +7 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +123 -0
- package/src/resources/extensions/gsd/auto.ts +110 -22
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +119 -2
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +50 -36
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +16 -5
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +34 -19
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +8 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +9 -2
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +386 -55
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +135 -1
- package/src/resources/extensions/gsd/clean-root-preflight.ts +72 -9
- package/src/resources/extensions/gsd/commands/dispatcher.ts +6 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +17 -12
- package/src/resources/extensions/gsd/commands-handlers.ts +34 -15
- package/src/resources/extensions/gsd/context-budget.ts +44 -2
- package/src/resources/extensions/gsd/crash-recovery.ts +67 -10
- package/src/resources/extensions/gsd/custom-workflow-engine.ts +24 -1
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +107 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +19 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +25 -0
- package/src/resources/extensions/gsd/detection.ts +128 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +46 -8
- package/src/resources/extensions/gsd/graph.ts +12 -5
- package/src/resources/extensions/gsd/gsd-db.ts +168 -13
- package/src/resources/extensions/gsd/guided-flow.ts +150 -51
- package/src/resources/extensions/gsd/memory-store.ts +77 -12
- package/src/resources/extensions/gsd/migrate/command.ts +47 -1
- package/src/resources/extensions/gsd/migration-auto-check.ts +129 -0
- package/src/resources/extensions/gsd/native-git-bridge.ts +39 -6
- package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +13 -3
- package/src/resources/extensions/gsd/planning-path-scope.ts +35 -0
- package/src/resources/extensions/gsd/pr-evidence.ts +63 -5
- package/src/resources/extensions/gsd/pre-execution-checks.ts +23 -0
- package/src/resources/extensions/gsd/preferences-types.ts +1 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +27 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +21 -19
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/src/resources/extensions/gsd/quick.ts +37 -2
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +11 -2
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +33 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +516 -15
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +184 -2
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +168 -6
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +97 -2
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +10 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +22 -0
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +117 -7
- package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +40 -2
- package/src/resources/extensions/gsd/tests/db-migration-steps.integration.test.ts +428 -0
- package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +5 -2
- package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
- package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +132 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-basic.md +52 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-empty-optionals.md +42 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +55 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +60 -0
- package/src/resources/extensions/gsd/tests/graph-operations.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +6 -3
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +239 -1
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +32 -0
- package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
- package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/plan-task.test.ts +21 -0
- package/src/resources/extensions/gsd/tests/pr-evidence-equivalence.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/pr-evidence-hardening.test.ts +165 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +38 -17
- package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +192 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +29 -0
- package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +77 -0
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +166 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +101 -2
- package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/status-db-open.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +7 -9
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +136 -4
- package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +80 -1
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +142 -0
- package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/workflow-worker-heartbeat.test.ts +32 -1
- package/src/resources/extensions/gsd/tests/working-output-messages.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +37 -6
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +9 -2
- package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +22 -19
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +167 -4
- package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +179 -0
- package/src/resources/extensions/gsd/tools/context-mode-tool-result.ts +25 -0
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/exec-tool.ts +4 -23
- package/src/resources/extensions/gsd/tools/memory-tools.ts +1 -0
- package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -0
- package/src/resources/extensions/gsd/tools/plan-task.ts +10 -0
- package/src/resources/extensions/gsd/tools/resume-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +1 -1
- package/src/resources/extensions/gsd/unit-context-composer.ts +19 -4
- package/src/resources/extensions/gsd/unit-runtime.ts +25 -0
- package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
- package/src/resources/extensions/gsd/working-output-messages.ts +120 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +15 -4
- package/src/resources/extensions/gsd/worktree-resolver.ts +85 -19
- package/packages/contracts/tsconfig.tsbuildinfo +0 -1
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +0 -97
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → cWaxzf-sdbSSbbwYu8q7a}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → cWaxzf-sdbSSbbwYu8q7a}/_ssgManifest.js +0 -0
|
@@ -78,6 +78,7 @@ import {
|
|
|
78
78
|
nativeUpdateRef,
|
|
79
79
|
nativeIsAncestor,
|
|
80
80
|
nativeMergeAbort,
|
|
81
|
+
nativeWorktreeList,
|
|
81
82
|
} from "./native-git-bridge.js";
|
|
82
83
|
import { gsdHome } from "./gsd-home.js";
|
|
83
84
|
import { type MilestoneScope, type GsdWorkspace, createWorkspace } from "./workspace.js";
|
|
@@ -1180,6 +1181,122 @@ export function enterBranchModeForMilestone(
|
|
|
1180
1181
|
* (both formerly here) became dead.
|
|
1181
1182
|
*/
|
|
1182
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* True when `branch` is checked out in any worktree listed by
|
|
1186
|
+
* `git worktree list --porcelain`. Used to gate ref updates that would
|
|
1187
|
+
* otherwise leave a concurrent worktree's HEAD inconsistent with its
|
|
1188
|
+
* index/working tree (Codex peer-review of #5538-followup).
|
|
1189
|
+
*
|
|
1190
|
+
* Best-effort: a `nativeWorktreeList` failure returns true so we err on
|
|
1191
|
+
* the side of NOT moving the ref. Better to skip a fast-forward than to
|
|
1192
|
+
* silently corrupt another worktree.
|
|
1193
|
+
*/
|
|
1194
|
+
export function _isBranchCheckedOutElsewhere(
|
|
1195
|
+
basePath: string,
|
|
1196
|
+
branch: string,
|
|
1197
|
+
): boolean {
|
|
1198
|
+
try {
|
|
1199
|
+
const entries = nativeWorktreeList(basePath);
|
|
1200
|
+
return entries.some((entry) => entry.branch === branch);
|
|
1201
|
+
} catch {
|
|
1202
|
+
return true;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Resolve the integration branch using the same 3-tier fallback as the
|
|
1208
|
+
* fresh-create path: META.json → git.main_branch preference → detected
|
|
1209
|
+
* main branch. Returns null when no usable target exists.
|
|
1210
|
+
*/
|
|
1211
|
+
function _resolveIntegrationBranchForReuse(
|
|
1212
|
+
basePath: string,
|
|
1213
|
+
milestoneId: string,
|
|
1214
|
+
): string | null {
|
|
1215
|
+
const fromMeta = readIntegrationBranch(basePath, milestoneId);
|
|
1216
|
+
if (fromMeta) return fromMeta;
|
|
1217
|
+
|
|
1218
|
+
const gitPrefs = loadEffectiveGSDPreferences()?.preferences?.git;
|
|
1219
|
+
const fromPref = gitPrefs?.main_branch &&
|
|
1220
|
+
typeof gitPrefs.main_branch === "string" &&
|
|
1221
|
+
gitPrefs.main_branch.length > 0 &&
|
|
1222
|
+
nativeBranchExists(basePath, gitPrefs.main_branch)
|
|
1223
|
+
? gitPrefs.main_branch
|
|
1224
|
+
: null;
|
|
1225
|
+
if (fromPref) return fromPref;
|
|
1226
|
+
|
|
1227
|
+
try {
|
|
1228
|
+
return nativeDetectMainBranch(basePath);
|
|
1229
|
+
} catch {
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* When reusing an existing milestone branch, fast-forward it onto the
|
|
1236
|
+
* integration branch when that's safe (branch is a strict ancestor of
|
|
1237
|
+
* integration — no commits would be lost). Skips when the branch has its
|
|
1238
|
+
* own commits ahead of integration, when the integration branch can't be
|
|
1239
|
+
* resolved, or when any git operation fails — the merge gate at milestone
|
|
1240
|
+
* completion will surface real divergence as a conflict.
|
|
1241
|
+
*
|
|
1242
|
+
* The previous behavior re-attached the worktree to whatever stale tip
|
|
1243
|
+
* the branch held, which caused new milestone work to fork from a base
|
|
1244
|
+
* missing prior milestones' merges (#5538-followup).
|
|
1245
|
+
*/
|
|
1246
|
+
export function fastForwardReusedMilestoneBranchIfSafe(
|
|
1247
|
+
basePath: string,
|
|
1248
|
+
milestoneId: string,
|
|
1249
|
+
branch: string,
|
|
1250
|
+
): void {
|
|
1251
|
+
try {
|
|
1252
|
+
const integrationBranch = _resolveIntegrationBranchForReuse(basePath, milestoneId);
|
|
1253
|
+
if (!integrationBranch || integrationBranch === branch) return;
|
|
1254
|
+
if (!nativeBranchExists(basePath, integrationBranch)) return;
|
|
1255
|
+
|
|
1256
|
+
// Pure fast-forward only: branch must be a strict ancestor of integration.
|
|
1257
|
+
// If the branch has its own commits ahead, leave it alone.
|
|
1258
|
+
if (!nativeIsAncestor(basePath, branch, integrationBranch)) {
|
|
1259
|
+
debugLog("createAutoWorktree", {
|
|
1260
|
+
phase: "skip-ff-branch-not-ancestor",
|
|
1261
|
+
milestoneId,
|
|
1262
|
+
branch,
|
|
1263
|
+
integration: integrationBranch,
|
|
1264
|
+
});
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// Codex peer-review: `nativeUpdateRef` succeeds even when the branch is
|
|
1269
|
+
// currently checked out in another worktree, leaving that worktree's HEAD
|
|
1270
|
+
// inconsistent with its index/work tree. Skip the fast-forward if any
|
|
1271
|
+
// listed worktree has this branch checked out — the merge gate at
|
|
1272
|
+
// milestone-completion will surface stale-base divergence as a conflict
|
|
1273
|
+
// instead of silently corrupting the other worktree's state.
|
|
1274
|
+
if (_isBranchCheckedOutElsewhere(basePath, branch)) {
|
|
1275
|
+
debugLog("createAutoWorktree", {
|
|
1276
|
+
phase: "skip-ff-branch-checked-out-elsewhere",
|
|
1277
|
+
milestoneId,
|
|
1278
|
+
branch,
|
|
1279
|
+
});
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
nativeUpdateRef(basePath, `refs/heads/${branch}`, integrationBranch);
|
|
1284
|
+
debugLog("createAutoWorktree", {
|
|
1285
|
+
phase: "fast-forward-reused-branch",
|
|
1286
|
+
milestoneId,
|
|
1287
|
+
branch,
|
|
1288
|
+
integration: integrationBranch,
|
|
1289
|
+
});
|
|
1290
|
+
} catch (err) {
|
|
1291
|
+
debugLog("createAutoWorktree", {
|
|
1292
|
+
phase: "fast-forward-reused-branch-failed",
|
|
1293
|
+
milestoneId,
|
|
1294
|
+
branch,
|
|
1295
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1183
1300
|
export function createAutoWorktree(
|
|
1184
1301
|
basePath: string,
|
|
1185
1302
|
milestoneId: string,
|
|
@@ -1206,6 +1323,12 @@ export function createAutoWorktree(
|
|
|
1206
1323
|
|
|
1207
1324
|
let info: { name: string; path: string; branch: string; exists: boolean };
|
|
1208
1325
|
if (branchExists) {
|
|
1326
|
+
// #5538-followup: fast-forward the reused branch onto the integration
|
|
1327
|
+
// branch when safe so the next milestone forks from up-to-date code.
|
|
1328
|
+
// Without this, a milestone that was created before another milestone
|
|
1329
|
+
// merged into main would carry a stale base into its worktree.
|
|
1330
|
+
fastForwardReusedMilestoneBranchIfSafe(basePath, milestoneId, branch);
|
|
1331
|
+
|
|
1209
1332
|
// Re-attach worktree to the existing milestone branch (preserving commits)
|
|
1210
1333
|
info = createWorktree(basePath, milestoneId, {
|
|
1211
1334
|
branch,
|
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
isLockProcessAlive,
|
|
60
60
|
formatCrashInfo,
|
|
61
61
|
emitCrashRecoveredUnitEnd,
|
|
62
|
+
emitOpenUnitEndForUnit,
|
|
62
63
|
} from "./crash-recovery.js";
|
|
63
64
|
import {
|
|
64
65
|
acquireSessionLock,
|
|
@@ -150,6 +151,7 @@ import {
|
|
|
150
151
|
resolveProjectRoot,
|
|
151
152
|
} from "./worktree.js";
|
|
152
153
|
import { GitServiceImpl } from "./git-service.js";
|
|
154
|
+
import { nativeCheckoutBranch } from "./native-git-bridge.js";
|
|
153
155
|
import { getPriorSliceCompletionBlocker } from "./dispatch-guard.js";
|
|
154
156
|
import {
|
|
155
157
|
createAutoWorktree,
|
|
@@ -200,6 +202,8 @@ import {
|
|
|
200
202
|
detectWorkingTreeActivity,
|
|
201
203
|
} from "./auto-supervisor.js";
|
|
202
204
|
import { isDbAvailable, getMilestone } from "./gsd-db.js";
|
|
205
|
+
import { markLatestActiveForWorkerCanceled } from "./db/unit-dispatches.js";
|
|
206
|
+
import { writeUnitRuntimeRecord } from "./unit-runtime.js";
|
|
203
207
|
import { countPendingCaptures } from "./captures.js";
|
|
204
208
|
import { CMUX_CHANNELS, type CmuxLogLevel } from "../shared/cmux-events.js";
|
|
205
209
|
import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
|
|
@@ -242,6 +246,20 @@ import {
|
|
|
242
246
|
type WorktreeResolverDeps,
|
|
243
247
|
} from "./worktree-resolver.js";
|
|
244
248
|
import { reorderForCaching } from "./prompt-ordering.js";
|
|
249
|
+
import { initTokenCounter } from "./token-counter.js";
|
|
250
|
+
|
|
251
|
+
// Warm the tiktoken encoder at extension startup so context-budget computations
|
|
252
|
+
// can use accurate token counts via countTokensSync without paying the load
|
|
253
|
+
// cost mid-prompt-build. Fire-and-forget — failure falls back to the
|
|
254
|
+
// provider-aware char-ratio estimator already used by getCharsPerToken().
|
|
255
|
+
// Catch rejections explicitly: an unhandled rejection at module-import time
|
|
256
|
+
// can destabilize startup before the engine logger is configured.
|
|
257
|
+
void initTokenCounter().catch((err) => {
|
|
258
|
+
logWarning(
|
|
259
|
+
"engine",
|
|
260
|
+
`token counter warm-up failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
261
|
+
);
|
|
262
|
+
});
|
|
245
263
|
|
|
246
264
|
// ─── Session State ─────────────────────────────────────────────────────────
|
|
247
265
|
|
|
@@ -293,11 +311,15 @@ const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
|
|
|
293
311
|
* the DB is unavailable (e.g. fresh project before init) we skip registration
|
|
294
312
|
* silently rather than blocking session start.
|
|
295
313
|
*/
|
|
296
|
-
function registerAutoWorkerForSession(
|
|
314
|
+
function registerAutoWorkerForSession(
|
|
315
|
+
session: AutoSession,
|
|
316
|
+
projectRootOverride?: string,
|
|
317
|
+
): void {
|
|
297
318
|
if (session.workerId) return; // already registered (e.g. resume re-runs)
|
|
298
319
|
try {
|
|
299
320
|
const projectRootRealpath = normalizeRealPath(
|
|
300
|
-
|
|
321
|
+
projectRootOverride
|
|
322
|
+
?? session.scope?.workspace.projectRoot
|
|
301
323
|
?? (session.originalBasePath || session.basePath),
|
|
302
324
|
);
|
|
303
325
|
session.workerId = registerAutoWorker({ projectRootRealpath });
|
|
@@ -420,6 +442,17 @@ export function _synthesizePausedSessionRecoveryForTest(
|
|
|
420
442
|
return synthesizePausedSessionRecovery(basePath, unitType, unitId, sessionFile);
|
|
421
443
|
}
|
|
422
444
|
|
|
445
|
+
const DETACHED_AUTO_KEEPALIVE_INTERVAL_MS = 30_000;
|
|
446
|
+
|
|
447
|
+
function withDetachedAutoKeepalive<T>(run: Promise<T>): Promise<T> {
|
|
448
|
+
const keepAlive = setInterval(() => {}, DETACHED_AUTO_KEEPALIVE_INTERVAL_MS);
|
|
449
|
+
return run.finally(() => {
|
|
450
|
+
clearInterval(keepAlive);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export const _withDetachedAutoKeepaliveForTest = withDetachedAutoKeepalive;
|
|
455
|
+
|
|
423
456
|
export function startAutoDetached(
|
|
424
457
|
ctx: ExtensionCommandContext,
|
|
425
458
|
pi: ExtensionAPI,
|
|
@@ -431,7 +464,7 @@ export function startAutoDetached(
|
|
|
431
464
|
milestoneLock?: string | null;
|
|
432
465
|
},
|
|
433
466
|
): void {
|
|
434
|
-
void startAuto(ctx, pi, base, verboseMode, options).catch((err) => {
|
|
467
|
+
void withDetachedAutoKeepalive(startAuto(ctx, pi, base, verboseMode, options)).catch((err) => {
|
|
435
468
|
const message = getErrorMessage(err);
|
|
436
469
|
ctx.ui.notify(`Auto-start failed: ${message}`, "error");
|
|
437
470
|
logWarning("engine", `auto start error: ${message}`, { file: "auto.ts" });
|
|
@@ -490,9 +523,54 @@ export {
|
|
|
490
523
|
getBudgetEnforcementAction,
|
|
491
524
|
} from "./auto-budget.js";
|
|
492
525
|
|
|
526
|
+
function closeOutSignalInterruptedUnit(currentBasePath: string): void {
|
|
527
|
+
const currentUnit = s.currentUnit;
|
|
528
|
+
if (!currentUnit) return;
|
|
529
|
+
|
|
530
|
+
const reason = "Auto-mode process received a termination signal";
|
|
531
|
+
const errorContext: ErrorContext = {
|
|
532
|
+
message: reason,
|
|
533
|
+
category: "aborted",
|
|
534
|
+
isTransient: false,
|
|
535
|
+
};
|
|
536
|
+
const basePath = s.basePath || currentBasePath;
|
|
537
|
+
|
|
538
|
+
try {
|
|
539
|
+
emitOpenUnitEndForUnit(basePath, currentUnit.type, currentUnit.id, "cancelled", errorContext);
|
|
540
|
+
} catch (err) {
|
|
541
|
+
logWarning("engine", `signal unit-end cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
try {
|
|
545
|
+
writeUnitRuntimeRecord(basePath, currentUnit.type, currentUnit.id, currentUnit.startedAt, {
|
|
546
|
+
phase: "crashed",
|
|
547
|
+
lastProgressAt: Date.now(),
|
|
548
|
+
lastProgressKind: "signal",
|
|
549
|
+
});
|
|
550
|
+
} catch (err) {
|
|
551
|
+
logWarning("engine", `signal runtime cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
try {
|
|
555
|
+
if (s.workerId) markLatestActiveForWorkerCanceled(s.workerId, "signal-exit");
|
|
556
|
+
} catch (err) {
|
|
557
|
+
logWarning("engine", `signal dispatch cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
try {
|
|
561
|
+
resolveAgentEndCancelled(errorContext);
|
|
562
|
+
} catch (err) {
|
|
563
|
+
logWarning("engine", `signal resolve cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
493
567
|
/** Wrapper: register SIGTERM handler and store reference. */
|
|
494
568
|
function registerSigtermHandler(currentBasePath: string): void {
|
|
495
|
-
s.sigtermHandler = _registerSigtermHandler(
|
|
569
|
+
s.sigtermHandler = _registerSigtermHandler(
|
|
570
|
+
currentBasePath,
|
|
571
|
+
s.sigtermHandler,
|
|
572
|
+
() => closeOutSignalInterruptedUnit(currentBasePath),
|
|
573
|
+
);
|
|
496
574
|
}
|
|
497
575
|
|
|
498
576
|
/** Wrapper: deregister SIGTERM handler and clear reference. */
|
|
@@ -957,6 +1035,8 @@ export async function stopAuto(
|
|
|
957
1035
|
if (s.workerId) {
|
|
958
1036
|
markWorkerStopping(s.workerId);
|
|
959
1037
|
}
|
|
1038
|
+
s.workerId = null;
|
|
1039
|
+
s.milestoneLeaseToken = null;
|
|
960
1040
|
} catch (e) {
|
|
961
1041
|
debugLog("stop-cleanup-coordination", { error: e instanceof Error ? e.message : String(e) });
|
|
962
1042
|
}
|
|
@@ -1094,6 +1174,21 @@ export async function stopAuto(
|
|
|
1094
1174
|
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
1095
1175
|
}
|
|
1096
1176
|
|
|
1177
|
+
// Re-root the active command session/tool runtime after worktree teardown.
|
|
1178
|
+
// mergeAndExit restores process.cwd(), but AgentSession has already captured
|
|
1179
|
+
// its own cwd for tools and system prompt; refresh it before returning to the
|
|
1180
|
+
// user so follow-up commands do not target a removed milestone worktree.
|
|
1181
|
+
if (s.originalBasePath && ctx && s.cmdCtx) {
|
|
1182
|
+
try {
|
|
1183
|
+
const result = await s.cmdCtx.newSession({ workspaceRoot: s.basePath });
|
|
1184
|
+
if (result.cancelled) {
|
|
1185
|
+
logWarning("engine", "post-stop session re-root was cancelled", { file: "auto.ts", basePath: s.basePath });
|
|
1186
|
+
}
|
|
1187
|
+
} catch (err) {
|
|
1188
|
+
logWarning("engine", `post-stop session re-root failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts", basePath: s.basePath });
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1097
1192
|
// ── Step 8: Ledger notification ──
|
|
1098
1193
|
try {
|
|
1099
1194
|
const ledger = getLedger();
|
|
@@ -1357,6 +1452,7 @@ function buildResolverDeps(): WorktreeResolverDeps {
|
|
|
1357
1452
|
getAutoWorktreePath,
|
|
1358
1453
|
autoCommitCurrentBranch,
|
|
1359
1454
|
getCurrentBranch,
|
|
1455
|
+
checkoutBranch: nativeCheckoutBranch,
|
|
1360
1456
|
autoWorktreeBranch,
|
|
1361
1457
|
resolveMilestoneFile,
|
|
1362
1458
|
readFileSync: (path: string, encoding: string) =>
|
|
@@ -1960,6 +2056,10 @@ export async function startAuto(
|
|
|
1960
2056
|
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
1961
2057
|
const { initResources } = await import(resourceLoaderPath);
|
|
1962
2058
|
initResources(agentDir);
|
|
2059
|
+
// initResources() uses synchronous fs APIs, so the prompt-template cache
|
|
2060
|
+
// can be primed immediately — no need for the legacy 1s setTimeout deferral.
|
|
2061
|
+
const { primeCache } = await import("./prompt-loader.js");
|
|
2062
|
+
primeCache();
|
|
1963
2063
|
// Open the project DB before rebuild/derive so resume uses DB-backed
|
|
1964
2064
|
// state instead of falling back to stale markdown parsing (#2940).
|
|
1965
2065
|
await openProjectDbIfPresent(s.basePath);
|
|
@@ -2046,6 +2146,11 @@ export async function startAuto(
|
|
|
2046
2146
|
buildResolver,
|
|
2047
2147
|
};
|
|
2048
2148
|
|
|
2149
|
+
// Register the worker before bootstrap enters a milestone worktree.
|
|
2150
|
+
// This ensures enterMilestone can claim a lease and seed dispatch claims
|
|
2151
|
+
// for crash-recovery fidelity (#5405).
|
|
2152
|
+
registerAutoWorkerForSession(s, base);
|
|
2153
|
+
|
|
2049
2154
|
const ready = await bootstrapAutoSession(
|
|
2050
2155
|
s,
|
|
2051
2156
|
ctx,
|
|
@@ -2213,24 +2318,7 @@ export async function dispatchHookUnit(
|
|
|
2213
2318
|
startedAt: hookStartedAt,
|
|
2214
2319
|
};
|
|
2215
2320
|
|
|
2216
|
-
|
|
2217
|
-
// newSession() snapshots process.cwd() during construction; chdir-ing
|
|
2218
|
-
// afterward leaves the session rooted to whatever cwd was when the call
|
|
2219
|
-
// was made. Must be synchronous — no awaits between chdir and newSession.
|
|
2220
|
-
try { if (process.cwd() !== s.basePath) process.chdir(s.basePath); } catch (err) {
|
|
2221
|
-
const msg = `Failed to chdir before hook newSession (basePath: ${s.basePath}): ${err instanceof Error ? err.message : String(err)}`;
|
|
2222
|
-
logWarning("engine", msg, { file: "auto.ts", basePath: s.basePath, error: err instanceof Error ? err.message : String(err) });
|
|
2223
|
-
ctx.ui.notify(`${msg}. Cancelling hook dispatch to avoid running in the wrong directory.`, "error");
|
|
2224
|
-
if (wasActive) {
|
|
2225
|
-
s.basePath = previousBasePath;
|
|
2226
|
-
s.currentUnit = previousCurrentUnit;
|
|
2227
|
-
} else {
|
|
2228
|
-
s.reset();
|
|
2229
|
-
}
|
|
2230
|
-
return false;
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
const result = await s.cmdCtx!.newSession();
|
|
2321
|
+
const result = await s.cmdCtx!.newSession({ workspaceRoot: s.basePath });
|
|
2234
2322
|
if (result.cancelled) {
|
|
2235
2323
|
await stopAuto(ctx, pi);
|
|
2236
2324
|
return false;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
// GSD-2 + src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts - Handles provider and agent-end recovery for GSD auto-mode.
|
|
2
|
+
|
|
1
3
|
import type { ExtensionAPI, ExtensionContext } from "@gsd/pi-coding-agent";
|
|
2
4
|
|
|
5
|
+
import type { ErrorContext } from "../auto/types.js";
|
|
3
6
|
import { logWarning } from "../workflow-logger.js";
|
|
4
7
|
import {
|
|
5
8
|
checkDeepProjectSetupAfterTurn,
|
|
@@ -12,7 +15,12 @@ import { clearPathCache } from "../paths.js";
|
|
|
12
15
|
import { getAutoDashboardData, getAutoModeStartModel, isAutoActive, pauseAuto, setCurrentDispatchedModelId } from "../auto.js";
|
|
13
16
|
import { getNextFallbackModel, resolveModelWithFallbacksForUnit } from "../preferences.js";
|
|
14
17
|
import { pauseAutoForProviderError } from "../provider-error-pause.js";
|
|
15
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
isSessionSwitchAbortGraceActive,
|
|
20
|
+
isSessionSwitchInFlight,
|
|
21
|
+
resolveAgentEnd,
|
|
22
|
+
resolveAgentEndCancelled,
|
|
23
|
+
} from "../auto/resolve.js";
|
|
16
24
|
import { resolveModelId } from "../auto-model-selection.js";
|
|
17
25
|
import { resolveProjectRoot } from "../worktree.js";
|
|
18
26
|
import { clearDiscussionFlowState } from "./write-gate.js";
|
|
@@ -69,6 +77,96 @@ export function _buildAbortedPauseContext(lastMsg: { errorMessage?: unknown }):
|
|
|
69
77
|
};
|
|
70
78
|
}
|
|
71
79
|
|
|
80
|
+
export function isUserInitiatedAbortMessage(message: string | undefined | null): boolean {
|
|
81
|
+
if (!message) return false;
|
|
82
|
+
return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function isBareClaudeCodeSessionSwitchAbortMarker(message: string | undefined | null): boolean {
|
|
86
|
+
if (!message) return false;
|
|
87
|
+
const normalized = message.trim().replace(/\s+/g, " ").toLowerCase();
|
|
88
|
+
return normalized === "claude code process aborted by user"
|
|
89
|
+
|| normalized === "request aborted by user"
|
|
90
|
+
|| normalized === "process aborted by user"
|
|
91
|
+
|| normalized === "claude code stream aborted by caller";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function readAssistantTextContent(content: unknown): string {
|
|
95
|
+
if (!Array.isArray(content)) return "";
|
|
96
|
+
return content
|
|
97
|
+
.map((block) => {
|
|
98
|
+
if (!block || typeof block !== "object") return "";
|
|
99
|
+
const text = (block as { text?: unknown }).text;
|
|
100
|
+
return typeof text === "string" ? text : "";
|
|
101
|
+
})
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join("\n");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function isClaudeCodeSessionSwitchAbortMessage(lastMsg: unknown): boolean {
|
|
107
|
+
if (!lastMsg || typeof lastMsg !== "object") return false;
|
|
108
|
+
const m = lastMsg as { stopReason?: unknown; errorMessage?: unknown; content?: unknown };
|
|
109
|
+
const carriers = [
|
|
110
|
+
m.errorMessage ? String(m.errorMessage) : "",
|
|
111
|
+
readAssistantTextContent(m.content),
|
|
112
|
+
].filter((value) => value.trim().length > 0);
|
|
113
|
+
|
|
114
|
+
if ((m.stopReason === "error" || m.stopReason === "aborted") && carriers.length > 0) {
|
|
115
|
+
return carriers.every(isBareClaudeCodeSessionSwitchAbortMarker);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Resolve an agent_end event observed while a session switch is in flight.
|
|
123
|
+
*
|
|
124
|
+
* #5538-followup: When `newSession()` aborts an in-flight stream as part of a
|
|
125
|
+
* session transition (run-unit.ts:63 → _settleCurrentTurnForSessionTransition
|
|
126
|
+
* → agent.abort()), the SDK emits "Claude Code process aborted by user" or
|
|
127
|
+
* "Request aborted by user" against the previous unit's turn. The previous
|
|
128
|
+
* code path treated that as a user cancellation and propagated it to the next
|
|
129
|
+
* unit via the pending-switch-cancellation queue, killing auto-mode with
|
|
130
|
+
* "Auto-mode stopped — Unit aborted: Claude Code process aborted by user"
|
|
131
|
+
* even though no user input occurred.
|
|
132
|
+
*
|
|
133
|
+
* Claude Code abort markers are intentionally ignored when the abort fires
|
|
134
|
+
* while the session-switch is in flight: the abort is the expected side-effect
|
|
135
|
+
* of the transition, not a user signal. Other branches (genuine `stopReason
|
|
136
|
+
* === "aborted"` with diagnostic content/errorMessage) preserve the prior
|
|
137
|
+
* behavior.
|
|
138
|
+
*/
|
|
139
|
+
export function _handleSessionSwitchAgentEnd(
|
|
140
|
+
lastMsg: unknown,
|
|
141
|
+
resolveCancelled: (ctx: ErrorContext) => boolean,
|
|
142
|
+
): void {
|
|
143
|
+
if (!lastMsg || typeof lastMsg !== "object") return;
|
|
144
|
+
const m = lastMsg as { stopReason?: unknown; errorMessage?: unknown; content?: unknown };
|
|
145
|
+
|
|
146
|
+
if (isClaudeCodeSessionSwitchAbortMessage(m)) {
|
|
147
|
+
// Internal abort from in-flight session transition — drop on the floor.
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (m.stopReason === "error") {
|
|
152
|
+
const rawErrorMsg = m.errorMessage ? String(m.errorMessage) : "";
|
|
153
|
+
if (isBareClaudeCodeSessionSwitchAbortMarker(rawErrorMsg)) {
|
|
154
|
+
// Internal abort from in-flight session transition — drop on the floor.
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (m.stopReason === "aborted") {
|
|
161
|
+
const content = m.content;
|
|
162
|
+
const hasEmptyContent = Array.isArray(content) && content.length === 0;
|
|
163
|
+
const hasErrorMessage = !!m.errorMessage;
|
|
164
|
+
if (!hasEmptyContent || hasErrorMessage) {
|
|
165
|
+
resolveCancelled(_buildAbortedPauseContext(m as { errorMessage?: unknown }));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
72
170
|
async function pauseTransientWithBackoff(
|
|
73
171
|
cls: ErrorClass,
|
|
74
172
|
pi: ExtensionAPI,
|
|
@@ -146,9 +244,20 @@ export async function handleAgentEnd(
|
|
|
146
244
|
if (maybeHandleEmptyIntentTurn(event, isAutoActive())) return;
|
|
147
245
|
|
|
148
246
|
if (!isAutoActive()) return;
|
|
149
|
-
if (isSessionSwitchInFlight()) return;
|
|
150
247
|
|
|
151
248
|
const lastMsg = event.messages[event.messages.length - 1];
|
|
249
|
+
if (isSessionSwitchInFlight()) {
|
|
250
|
+
_handleSessionSwitchAgentEnd(lastMsg, resolveAgentEndCancelled);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (isSessionSwitchAbortGraceActive() && isClaudeCodeSessionSwitchAbortMessage(lastMsg)) {
|
|
255
|
+
// Claude Code can report the abort from `newSession()` a few hundred ms
|
|
256
|
+
// after the guard drops. That event belongs to the old turn; do not let it
|
|
257
|
+
// cancel the freshly-dispatched unit.
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
152
261
|
if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "aborted") {
|
|
153
262
|
// Empty content with aborted stopReason is a non-fatal agent stop (the LLM
|
|
154
263
|
// chose to end without producing output). Only pause on genuine fatal aborts
|
|
@@ -180,6 +289,14 @@ export async function handleAgentEnd(
|
|
|
180
289
|
// is in the assistant message text content. Fall back to content when
|
|
181
290
|
// errorMessage looks uninformative.
|
|
182
291
|
const rawErrorMsg = ("errorMessage" in lastMsg && lastMsg.errorMessage) ? String(lastMsg.errorMessage) : "";
|
|
292
|
+
if (isUserInitiatedAbortMessage(rawErrorMsg)) {
|
|
293
|
+
resolveAgentEndCancelled({
|
|
294
|
+
message: rawErrorMsg,
|
|
295
|
+
category: "aborted",
|
|
296
|
+
isTransient: false,
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
183
300
|
const isUseless = !rawErrorMsg || /^(success|ok|true|error|unknown)$/i.test(rawErrorMsg.trim());
|
|
184
301
|
// #3588: When errorMessage is uninformative, extract the real error from
|
|
185
302
|
// the assistant message text content for display purposes only.
|