gsd-pi 2.82.0-dev.c22380fc3 → 2.82.0-dev.e7a7f1ed5
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 +5 -4
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +10 -1
- package/dist/resources/extensions/claude-code-cli/partial-builder.js +2 -1
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +1 -1
- package/dist/resources/extensions/cmux/index.js +5 -0
- package/dist/resources/extensions/gsd/auto/infra-errors.js +9 -3
- package/dist/resources/extensions/gsd/auto/loop.js +5 -5
- package/dist/resources/extensions/gsd/auto/orchestrator.js +11 -0
- package/dist/resources/extensions/gsd/auto/phases.js +81 -31
- package/dist/resources/extensions/gsd/auto/workflow-memory-pressure.js +12 -0
- package/dist/resources/extensions/gsd/auto-dashboard.js +66 -1
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +1 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +18 -17
- package/dist/resources/extensions/gsd/auto-model-selection.js +2 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +233 -127
- package/dist/resources/extensions/gsd/auto-prompts.js +2 -2
- package/dist/resources/extensions/gsd/auto-recovery.js +71 -14
- package/dist/resources/extensions/gsd/auto-start.js +87 -14
- package/dist/resources/extensions/gsd/auto-verification.js +45 -26
- package/dist/resources/extensions/gsd/auto-worktree.js +176 -10
- package/dist/resources/extensions/gsd/auto.js +37 -5
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +31 -7
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +9 -8
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +4 -2
- package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +21 -9
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +16 -2
- package/dist/resources/extensions/gsd/clean-root-preflight.js +170 -8
- package/dist/resources/extensions/gsd/commands/catalog.js +4 -1
- package/dist/resources/extensions/gsd/commands/handlers/core.js +37 -0
- package/dist/resources/extensions/gsd/commands-bootstrap.js +5 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +7 -2
- package/dist/resources/extensions/gsd/crash-recovery.js +43 -5
- package/dist/resources/extensions/gsd/db/milestone-leases.js +24 -0
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +3 -2
- package/dist/resources/extensions/gsd/dispatch-guard.js +2 -2
- package/dist/resources/extensions/gsd/doctor-git-checks.js +46 -1
- package/dist/resources/extensions/gsd/doctor-runtime-checks.js +28 -11
- package/dist/resources/extensions/gsd/doctor.js +2 -28
- package/dist/resources/extensions/gsd/export-html.js +27 -425
- package/dist/resources/extensions/gsd/git-service.js +45 -3
- package/dist/resources/extensions/gsd/gsd-db.js +21 -6
- package/dist/resources/extensions/gsd/guided-flow-queue.js +4 -3
- package/dist/resources/extensions/gsd/guided-flow.js +101 -116
- package/dist/resources/extensions/gsd/guided-unit-context.js +23 -0
- package/dist/resources/extensions/gsd/migrate/parsers.js +10 -0
- package/dist/resources/extensions/gsd/migration-auto-check.js +12 -17
- package/dist/resources/extensions/gsd/milestone-actions.js +11 -4
- package/dist/resources/extensions/gsd/native-git-bridge.js +48 -12
- package/dist/resources/extensions/gsd/pending-auto-start.js +52 -0
- package/dist/resources/extensions/gsd/post-execution-checks.js +73 -2
- package/dist/resources/extensions/gsd/pre-execution-checks.js +28 -1
- package/dist/resources/extensions/gsd/prompt-loader.js +1 -1
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
- package/dist/resources/extensions/gsd/prompts/discuss.md +9 -9
- package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
- package/dist/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +4 -4
- package/dist/resources/extensions/gsd/prompts/queue.md +4 -4
- package/dist/resources/extensions/gsd/prompts/refine-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/dist/resources/extensions/gsd/queue-reorder-ui.js +30 -13
- package/dist/resources/extensions/gsd/smart-entry-routing.js +36 -0
- package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
- package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +9 -14
- package/dist/resources/extensions/gsd/state-reconciliation/drift/roadmap.js +19 -24
- package/dist/resources/extensions/gsd/status-guards.js +11 -0
- package/dist/resources/extensions/gsd/templates/plan.md +8 -5
- package/dist/resources/extensions/gsd/templates/task-plan.md +4 -2
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -8
- package/dist/resources/extensions/gsd/tools/complete-slice.js +6 -8
- package/dist/resources/extensions/gsd/tools/plan-milestone.js +7 -1
- package/dist/resources/extensions/gsd/tools/plan-slice.js +89 -14
- package/dist/resources/extensions/gsd/unit-context-manifest.js +32 -10
- package/dist/resources/extensions/gsd/validation.js +23 -1
- package/dist/resources/extensions/gsd/verification-gate.js +68 -7
- package/dist/resources/extensions/gsd/verification-verdict.js +26 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +17 -1
- package/dist/resources/extensions/gsd/workflow-projections.js +6 -8
- package/dist/resources/extensions/gsd/worktree-lifecycle.js +33 -8
- package/dist/resources/extensions/shared/html-shell.js +388 -0
- package/dist/resources/extensions/subagent/index.js +448 -78
- package/dist/resources/extensions/subagent/launch.js +77 -0
- package/dist/resources/extensions/subagent/run-store.js +148 -0
- package/dist/resources/extensions/visual-brief/artifact-policy.js +29 -0
- package/dist/resources/extensions/visual-brief/extension-manifest.json +8 -0
- package/dist/resources/extensions/visual-brief/index.js +5 -0
- package/dist/resources/extensions/visual-brief/page-contract.js +124 -0
- package/dist/resources/extensions/visual-brief/prompts.js +140 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +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.js.nft.json +1 -1
- 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 +4 -7
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
- 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 +4 -5
- 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 +2 -5
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -7
- 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 +4 -7
- 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 +4 -5
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
- package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
- 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/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/2973.33f26573894b6153.js +2 -0
- package/dist/web/standalone/.next/static/chunks/{8359.e059d86b255fce1c.js → 8359.7eb3bb8f8ecf4c01.js} +2 -2
- package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-de742b64187e13fe.js → webpack-9a4db269f9ed63ad.js} +1 -1
- package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
- package/package.json +4 -4
- package/packages/mcp-server/src/workflow-tools.test.ts +1 -1
- package/packages/native/tsconfig.json +2 -1
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +5 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.test.js +41 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.js +82 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +52 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts +2 -4
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +5 -6
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/simple-options.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.test.js +50 -0
- package/packages/pi-ai/dist/providers/simple-options.test.js.map +1 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.test.ts +49 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +7 -0
- package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +63 -0
- package/packages/pi-ai/src/providers/openai-codex-responses.ts +91 -1
- package/packages/pi-ai/src/providers/simple-options.test.ts +60 -0
- package/packages/pi-ai/src/providers/simple-options.ts +5 -6
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js +66 -0
- package/packages/pi-coding-agent/dist/core/agent-session-thinking-level.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +24 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-thinking-level.test.ts +79 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +23 -7
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/terminal.test.d.ts +2 -0
- package/packages/pi-tui/dist/__tests__/terminal.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/__tests__/terminal.test.js +103 -0
- package/packages/pi-tui/dist/__tests__/terminal.test.js.map +1 -0
- package/packages/pi-tui/dist/terminal.d.ts +2 -0
- package/packages/pi-tui/dist/terminal.d.ts.map +1 -1
- package/packages/pi-tui/dist/terminal.js +12 -0
- package/packages/pi-tui/dist/terminal.js.map +1 -1
- package/packages/pi-tui/src/__tests__/terminal.test.ts +121 -0
- package/packages/pi-tui/src/terminal.ts +11 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/src/resources/GSD-WORKFLOW.md +10 -1
- package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +1 -1
- package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +9 -0
- package/src/resources/extensions/cmux/index.ts +6 -0
- package/src/resources/extensions/gsd/auto/contracts.ts +14 -6
- package/src/resources/extensions/gsd/auto/infra-errors.ts +9 -3
- package/src/resources/extensions/gsd/auto/loop.ts +8 -5
- package/src/resources/extensions/gsd/auto/orchestrator.ts +11 -0
- package/src/resources/extensions/gsd/auto/phases.ts +90 -38
- package/src/resources/extensions/gsd/auto/workflow-memory-pressure.ts +13 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +72 -1
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +1 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +19 -17
- package/src/resources/extensions/gsd/auto-model-selection.ts +2 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +266 -139
- package/src/resources/extensions/gsd/auto-prompts.ts +2 -2
- package/src/resources/extensions/gsd/auto-recovery.ts +74 -11
- package/src/resources/extensions/gsd/auto-start.ts +94 -12
- package/src/resources/extensions/gsd/auto-verification.ts +58 -36
- package/src/resources/extensions/gsd/auto-worktree.ts +193 -10
- package/src/resources/extensions/gsd/auto.ts +40 -5
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +42 -7
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +9 -8
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +4 -2
- package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +19 -7
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -3
- package/src/resources/extensions/gsd/clean-root-preflight.ts +174 -8
- package/src/resources/extensions/gsd/commands/catalog.ts +4 -1
- package/src/resources/extensions/gsd/commands/handlers/core.ts +40 -0
- package/src/resources/extensions/gsd/commands-bootstrap.ts +10 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +8 -3
- package/src/resources/extensions/gsd/crash-recovery.ts +44 -4
- package/src/resources/extensions/gsd/db/milestone-leases.ts +26 -0
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +4 -3
- package/src/resources/extensions/gsd/dispatch-guard.ts +2 -2
- package/src/resources/extensions/gsd/doctor-git-checks.ts +45 -1
- package/src/resources/extensions/gsd/doctor-runtime-checks.ts +25 -13
- package/src/resources/extensions/gsd/doctor-types.ts +1 -0
- package/src/resources/extensions/gsd/doctor.ts +2 -27
- package/src/resources/extensions/gsd/export-html.ts +27 -427
- package/src/resources/extensions/gsd/git-service.ts +51 -4
- package/src/resources/extensions/gsd/gsd-db.ts +21 -6
- package/src/resources/extensions/gsd/guided-flow-queue.ts +4 -3
- package/src/resources/extensions/gsd/guided-flow.ts +134 -133
- package/src/resources/extensions/gsd/guided-unit-context.ts +30 -0
- package/src/resources/extensions/gsd/migrate/parsers.ts +11 -0
- package/src/resources/extensions/gsd/migration-auto-check.ts +15 -23
- package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
- package/src/resources/extensions/gsd/native-git-bridge.ts +54 -12
- package/src/resources/extensions/gsd/pending-auto-start.ts +79 -0
- package/src/resources/extensions/gsd/post-execution-checks.ts +87 -2
- package/src/resources/extensions/gsd/pre-execution-checks.ts +32 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +1 -1
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -8
- package/src/resources/extensions/gsd/prompts/discuss.md +9 -9
- package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +4 -4
- package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +3 -3
- package/src/resources/extensions/gsd/prompts/plan-slice.md +4 -4
- package/src/resources/extensions/gsd/prompts/queue.md +4 -4
- package/src/resources/extensions/gsd/prompts/refine-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/src/resources/extensions/gsd/queue-reorder-ui.ts +31 -13
- package/src/resources/extensions/gsd/smart-entry-routing.ts +77 -0
- package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
- package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +12 -15
- package/src/resources/extensions/gsd/state-reconciliation/drift/roadmap.ts +17 -25
- package/src/resources/extensions/gsd/status-guards.ts +13 -0
- package/src/resources/extensions/gsd/templates/plan.md +8 -5
- package/src/resources/extensions/gsd/templates/task-plan.md +4 -2
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +80 -1
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +35 -7
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +53 -2
- package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +12 -1
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +91 -6
- package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/auto-stop-notification.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
- package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +87 -0
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +107 -2
- package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +11 -2
- package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +4 -1
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +5 -9
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +86 -2
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +208 -0
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +59 -2
- package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/doctor-empty-worktree.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +11 -0
- package/src/resources/extensions/gsd/tests/guided-discuss-project-prompt-rendering.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +106 -0
- package/src/resources/extensions/gsd/tests/guided-flow-session-isolation.test.ts +59 -11
- package/src/resources/extensions/gsd/tests/guided-flow.test.ts +21 -0
- package/src/resources/extensions/gsd/tests/guided-tool-contract.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +7 -7
- package/src/resources/extensions/gsd/tests/hook-model-resolution.test.ts +5 -0
- package/src/resources/extensions/gsd/tests/infra-error.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +112 -1
- package/src/resources/extensions/gsd/tests/integration/state-machine-runtime-failures.test.ts +6 -1
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +179 -0
- package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +24 -1
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +26 -18
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +63 -2
- package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +121 -1
- package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
- package/src/resources/extensions/gsd/tests/pending-autostart-scope.test.ts +29 -5
- package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +225 -1
- package/src/resources/extensions/gsd/tests/plan-task.test.ts +17 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
- package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +86 -0
- package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +59 -0
- package/src/resources/extensions/gsd/tests/prompt-loader.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +37 -1
- package/src/resources/extensions/gsd/tests/queue-reorder-ui.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +89 -2
- package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +2 -3
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/smart-entry-routing.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +53 -2
- package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +119 -23
- package/src/resources/extensions/gsd/tests/status-guards.test.ts +13 -1
- package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +64 -1
- package/src/resources/extensions/gsd/tests/summary-render-parity.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +86 -7
- package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +29 -2
- package/src/resources/extensions/gsd/tests/verification-gate.test.ts +110 -1
- package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +19 -1
- package/src/resources/extensions/gsd/tests/workflow-memory-pressure.test.ts +21 -1
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-git-pathspec.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
- package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +54 -0
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +8 -10
- package/src/resources/extensions/gsd/tools/complete-slice.ts +6 -8
- package/src/resources/extensions/gsd/tools/plan-milestone.ts +5 -1
- package/src/resources/extensions/gsd/tools/plan-slice.ts +98 -12
- package/src/resources/extensions/gsd/types.ts +1 -1
- package/src/resources/extensions/gsd/unit-context-manifest.ts +47 -11
- package/src/resources/extensions/gsd/validation.ts +23 -1
- package/src/resources/extensions/gsd/verification-gate.ts +78 -6
- package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
- package/src/resources/extensions/gsd/workflow-mcp.ts +18 -1
- package/src/resources/extensions/gsd/workflow-projections.ts +6 -8
- package/src/resources/extensions/gsd/worktree-lifecycle.ts +41 -8
- package/src/resources/extensions/shared/html-shell.ts +412 -0
- package/src/resources/extensions/subagent/index.ts +567 -103
- package/src/resources/extensions/subagent/launch.ts +131 -0
- package/src/resources/extensions/subagent/run-store.ts +218 -0
- package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
- package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
- package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
- package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
- package/src/resources/extensions/visual-brief/index.ts +8 -0
- package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
- package/src/resources/extensions/visual-brief/prompts.ts +183 -0
- package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
- package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
- package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +0 -1
- package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
- package/dist/web/standalone/.next/static/css/54ec2745c1da488b.css +0 -1
- package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
- package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
- package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
- package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
- package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
- package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
- package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
- /package/dist/web/standalone/.next/static/{Wop3A7KRGyR06H3rla_1- → 4dSwdrs__8NwCZggxP9KF}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{Wop3A7KRGyR06H3rla_1- → 4dSwdrs__8NwCZggxP9KF}/_ssgManifest.js +0 -0
|
@@ -22,7 +22,7 @@ import { gsdRoot, resolveMilestoneFile, resolveMilestonePath, resolveDir, milest
|
|
|
22
22
|
import { invalidateAllCaches } from "./cache.js";
|
|
23
23
|
import { clearActivityLogState } from "./activity-log.js";
|
|
24
24
|
import { synthesizeCrashRecovery, getDeepDiagnostic, readActiveMilestoneId, } from "./session-forensics.js";
|
|
25
|
-
import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
|
|
25
|
+
import { writeLock, clearLock, clearStaleWorkerLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
|
|
26
26
|
import { acquireSessionLock, getSessionLockStatus, releaseSessionLock, updateSessionLock, } from "./session-lock.js";
|
|
27
27
|
import { resolveAutoSupervisorConfig, loadEffectiveGSDPreferences, getIsolationMode, } from "./preferences.js";
|
|
28
28
|
import { sendDesktopNotification } from "./notifications.js";
|
|
@@ -127,6 +127,12 @@ import { normalizeRealPath } from "./paths.js";
|
|
|
127
127
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
128
128
|
/** Throttle STATE.md rebuilds — at most once per 30 seconds */
|
|
129
129
|
const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
|
|
130
|
+
export function formatAutoStopNotification(prefix, totals, unitCount) {
|
|
131
|
+
return [
|
|
132
|
+
`${prefix}.`,
|
|
133
|
+
`Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${unitCount} units`,
|
|
134
|
+
].join("\n");
|
|
135
|
+
}
|
|
130
136
|
/**
|
|
131
137
|
* Phase B — register this auto-mode process in the workers table so other
|
|
132
138
|
* workers and janitors can detect liveness via heartbeat. Best-effort: if
|
|
@@ -707,6 +713,7 @@ export async function cleanupAfterLoopExit(ctx) {
|
|
|
707
713
|
// visible so the user still has a resumable auto-mode signal on screen.
|
|
708
714
|
if (!s.paused) {
|
|
709
715
|
ctx.ui.setStatus("gsd-auto", undefined);
|
|
716
|
+
ctx.ui.setWidget("gsd-progress", undefined);
|
|
710
717
|
if (s.completionStopInProgress) {
|
|
711
718
|
s.completionStopInProgress = false;
|
|
712
719
|
}
|
|
@@ -1029,7 +1036,7 @@ export async function stopAuto(ctx, pi, reason, options = {}) {
|
|
|
1029
1036
|
: `Auto-mode stopped${reasonSuffix}`;
|
|
1030
1037
|
if (ledger && ledger.units.length > 0) {
|
|
1031
1038
|
const totals = getProjectTotals(ledger.units);
|
|
1032
|
-
ctx?.ui.notify(
|
|
1039
|
+
ctx?.ui.notify(formatAutoStopNotification(notificationPrefix, totals, ledger.units.length), "info");
|
|
1033
1040
|
}
|
|
1034
1041
|
else {
|
|
1035
1042
|
ctx?.ui.notify(`${notificationPrefix}.`, "info");
|
|
@@ -1318,7 +1325,6 @@ export async function pauseAuto(ctx, _pi, _errorContext) {
|
|
|
1318
1325
|
restoreProjectRootEnv();
|
|
1319
1326
|
restoreMilestoneLockEnv();
|
|
1320
1327
|
s.pendingVerificationRetry = null;
|
|
1321
|
-
s.verificationRetryCount.clear();
|
|
1322
1328
|
ctx?.ui.setStatus("gsd-auto", "paused");
|
|
1323
1329
|
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
1324
1330
|
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
@@ -1420,6 +1426,13 @@ export function createWiredDispatchAdapter(ctx, pi, dispatchBasePath) {
|
|
|
1420
1426
|
sessionProvider,
|
|
1421
1427
|
modelRegistry,
|
|
1422
1428
|
});
|
|
1429
|
+
if (action.action === "stop") {
|
|
1430
|
+
return {
|
|
1431
|
+
kind: "blocked",
|
|
1432
|
+
reason: action.reason,
|
|
1433
|
+
action: action.level === "warning" ? "pause" : "stop",
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1423
1436
|
if (action.action !== "dispatch")
|
|
1424
1437
|
return null;
|
|
1425
1438
|
return {
|
|
@@ -1640,6 +1653,17 @@ export function createWiredAutoOrchestrationModule(ctx, pi, dispatchBasePath, ru
|
|
|
1640
1653
|
};
|
|
1641
1654
|
return createAutoOrchestrator(deps);
|
|
1642
1655
|
}
|
|
1656
|
+
function notifyResumeBlocked(ctx, result) {
|
|
1657
|
+
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
1658
|
+
ctx.ui.notify(`Auto-mode blocked: ${result.reason}. Fix and run ${resumeCmd} to resume.`, "warning");
|
|
1659
|
+
setLifecycleOutcome(ctx, {
|
|
1660
|
+
status: "blocked",
|
|
1661
|
+
title: "Auto-mode blocked",
|
|
1662
|
+
detail: result.reason,
|
|
1663
|
+
nextAction: `Fix the blocker, then run ${resumeCmd} to resume.`,
|
|
1664
|
+
commands: ["/gsd status for overview", `${resumeCmd} to resume`, "/gsd doctor to diagnose"],
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1643
1667
|
function ensureOrchestrationModule(ctx, pi, basePath) {
|
|
1644
1668
|
s.orchestration = createWiredAutoOrchestrationModule(ctx, pi, basePath, lockBase());
|
|
1645
1669
|
}
|
|
@@ -1924,7 +1948,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1924
1948
|
// This closes the journal gap reported in #3348 where the worker wrote side
|
|
1925
1949
|
// effects (SUMMARY.md, DB updates) but died before emitting unit-end.
|
|
1926
1950
|
emitCrashRecoveredUnitEnd(base, freshStartAssessment.lock);
|
|
1927
|
-
|
|
1951
|
+
clearStaleWorkerLock(base);
|
|
1928
1952
|
}
|
|
1929
1953
|
if (!s.paused) {
|
|
1930
1954
|
s.pendingCrashRecovery =
|
|
@@ -1987,6 +2011,8 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1987
2011
|
initMetrics(base);
|
|
1988
2012
|
if (s.currentMilestoneId)
|
|
1989
2013
|
setActiveMilestoneId(base, s.currentMilestoneId);
|
|
2014
|
+
await openProjectDbIfPresent(base);
|
|
2015
|
+
registerAutoWorkerForSession(s, base);
|
|
1990
2016
|
// Re-register health level notification callback lost across process restart
|
|
1991
2017
|
setLevelChangeCallback((_from, to, summary) => {
|
|
1992
2018
|
const level = to === "red" ? "error" : to === "yellow" ? "warning" : "info";
|
|
@@ -2062,7 +2088,12 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
2062
2088
|
}
|
|
2063
2089
|
pi.events.emit(CMUX_CHANNELS.LOG, { preferences: loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences, message: s.stepMode ? "Step-mode resumed." : "Auto-mode resumed.", level: "progress" });
|
|
2064
2090
|
try {
|
|
2065
|
-
await s.orchestration?.resume();
|
|
2091
|
+
const resumeResult = await s.orchestration?.resume();
|
|
2092
|
+
if (resumeResult?.kind === "blocked") {
|
|
2093
|
+
notifyResumeBlocked(ctx, resumeResult);
|
|
2094
|
+
await cleanupAfterLoopExit(ctx);
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2066
2097
|
}
|
|
2067
2098
|
catch (err) {
|
|
2068
2099
|
debugLog("resume-orchestration-resume", { error: err instanceof Error ? err.message : String(err) });
|
|
@@ -2083,6 +2114,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
2083
2114
|
const bootstrapDeps = {
|
|
2084
2115
|
shouldUseWorktreeIsolation,
|
|
2085
2116
|
registerSigtermHandler,
|
|
2117
|
+
registerAutoWorkerForSession: (projectRoot) => registerAutoWorkerForSession(s, projectRoot),
|
|
2086
2118
|
lockBase,
|
|
2087
2119
|
buildLifecycle,
|
|
2088
2120
|
};
|
|
@@ -10,6 +10,7 @@ import { shouldIgnoreAgentEndForActiveUnit } from "../auto/unit-runner-events.js
|
|
|
10
10
|
import { resolveModelId } from "../auto-model-selection.js";
|
|
11
11
|
import { resolveProjectRoot } from "../worktree.js";
|
|
12
12
|
import { clearDiscussionFlowState } from "./write-gate.js";
|
|
13
|
+
import { clearGuidedUnitContext } from "../guided-unit-context.js";
|
|
13
14
|
import { resumeAutoAfterProviderDelay } from "./provider-error-resume.js";
|
|
14
15
|
import { classifyError, createRetryState, resetRetryState, isTransient, } from "../error-classifier.js";
|
|
15
16
|
import { blockModel, isModelBlocked } from "../blocked-models.js";
|
|
@@ -18,6 +19,9 @@ const MAX_NETWORK_RETRIES = 2;
|
|
|
18
19
|
function isObjectRecord(value) {
|
|
19
20
|
return !!value && typeof value === "object";
|
|
20
21
|
}
|
|
22
|
+
export function _hasEmptyAgentEndContent(content) {
|
|
23
|
+
return content == null || (Array.isArray(content) && content.length === 0);
|
|
24
|
+
}
|
|
21
25
|
/**
|
|
22
26
|
* Cap on auto-resume attempts for sustained transient-provider errors.
|
|
23
27
|
*
|
|
@@ -57,6 +61,11 @@ export function isUserInitiatedAbortMessage(message) {
|
|
|
57
61
|
return false;
|
|
58
62
|
return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
|
|
59
63
|
}
|
|
64
|
+
export function shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg) {
|
|
65
|
+
if (!isTransient(cls) || cls.kind === "rate-limit")
|
|
66
|
+
return false;
|
|
67
|
+
return !/retry failed after \d+ attempts:/i.test(rawErrorMsg);
|
|
68
|
+
}
|
|
60
69
|
function isBareClaudeCodeSessionSwitchAbortMarker(message) {
|
|
61
70
|
if (!message)
|
|
62
71
|
return false;
|
|
@@ -150,6 +159,13 @@ export function resolveAgentEndErrorDisplay(rawErrorMsg, content) {
|
|
|
150
159
|
}
|
|
151
160
|
return rawErrorMsg;
|
|
152
161
|
}
|
|
162
|
+
export function isTerminalDeletedWorktreeProviderError(message) {
|
|
163
|
+
if (!message)
|
|
164
|
+
return false;
|
|
165
|
+
if (!/\bdoes not exist\b/i.test(message))
|
|
166
|
+
return false;
|
|
167
|
+
return /[/\\]\.gsd[/\\](?:projects[/\\][^/\\]+[/\\])?worktrees[/\\][^/\\\s"']+/i.test(message);
|
|
168
|
+
}
|
|
153
169
|
async function pauseTransientWithBackoff(cls, pi, ctx, errorDetail, isRateLimit) {
|
|
154
170
|
retryState.consecutiveTransientCount += 1;
|
|
155
171
|
const baseRetryAfterMs = "retryAfterMs" in cls ? cls.retryAfterMs : 15_000;
|
|
@@ -187,8 +203,10 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
187
203
|
// falsely report files as missing — producing a spurious "ready signal
|
|
188
204
|
// rejected" loop even though the files are on disk.
|
|
189
205
|
clearPathCache();
|
|
206
|
+
const basePath = resolveAgentEndBasePath();
|
|
207
|
+
clearGuidedUnitContext(basePath);
|
|
190
208
|
try {
|
|
191
|
-
if (await checkDeepProjectSetupAfterTurn(event, ctx,
|
|
209
|
+
if (await checkDeepProjectSetupAfterTurn(event, ctx, basePath)) {
|
|
192
210
|
return;
|
|
193
211
|
}
|
|
194
212
|
}
|
|
@@ -196,22 +214,22 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
196
214
|
const message = err instanceof Error ? err.message : String(err);
|
|
197
215
|
logWarning("bootstrap", `checkDeepProjectSetupAfterTurn failed: ${message}`);
|
|
198
216
|
}
|
|
199
|
-
if (checkAutoStartAfterDiscuss()) {
|
|
200
|
-
clearDiscussionFlowState(
|
|
217
|
+
if (checkAutoStartAfterDiscuss(basePath)) {
|
|
218
|
+
clearDiscussionFlowState(basePath ?? process.cwd());
|
|
201
219
|
return;
|
|
202
220
|
}
|
|
203
221
|
// #4573 — When the LLM emits "Milestone X ready." but the required files
|
|
204
222
|
// are missing, `checkAutoStartAfterDiscuss` returns false silently. Surface
|
|
205
223
|
// that and nudge the LLM to complete the writes before the user hits the
|
|
206
224
|
// downstream "All milestones complete" warning loop.
|
|
207
|
-
if (maybeHandleReadyPhraseWithoutFiles(event))
|
|
225
|
+
if (maybeHandleReadyPhraseWithoutFiles(event, basePath))
|
|
208
226
|
return;
|
|
209
227
|
// #4573 — Empty-turn recovery: if the LLM announced intent in prose but
|
|
210
228
|
// emitted no tool calls, nudge it to execute. Fires only when auto-mode is
|
|
211
229
|
// active or a discussion autostart is pending (non-auto interactive discuss
|
|
212
230
|
// is user-driven). Runs before `isAutoActive` early return so pending
|
|
213
231
|
// discussions (where isAutoActive may be false) still get recovered.
|
|
214
|
-
if (maybeHandleEmptyIntentTurn(event, isAutoActive()))
|
|
232
|
+
if (maybeHandleEmptyIntentTurn(event, isAutoActive(), basePath))
|
|
215
233
|
return;
|
|
216
234
|
if (!isAutoActive())
|
|
217
235
|
return;
|
|
@@ -246,7 +264,7 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
246
264
|
// that carry error context — e.g. errorMessage field or non-empty content
|
|
247
265
|
// indicating a mid-stream failure. (#2695)
|
|
248
266
|
const content = "content" in lastMsg ? lastMsg.content : undefined;
|
|
249
|
-
const hasEmptyContent =
|
|
267
|
+
const hasEmptyContent = _hasEmptyAgentEndContent(content);
|
|
250
268
|
const hasErrorMessage = "errorMessage" in lastMsg && !!lastMsg.errorMessage;
|
|
251
269
|
if (hasEmptyContent && !hasErrorMessage) {
|
|
252
270
|
// Non-fatal: treat as a normal agent end so the loop can continue
|
|
@@ -292,6 +310,12 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
292
310
|
// the assistant message text content for display purposes only.
|
|
293
311
|
// Classification still uses rawErrorMsg to avoid false positives from prose.
|
|
294
312
|
const displayMsg = resolveAgentEndErrorDisplay(rawErrorMsg, "content" in lastMsg ? lastMsg.content : undefined);
|
|
313
|
+
if (isAutoCompletionStopInProgress() &&
|
|
314
|
+
isTerminalDeletedWorktreeProviderError(`${rawErrorMsg}\n${displayMsg}`)) {
|
|
315
|
+
resetRetryState(retryState);
|
|
316
|
+
logWarning("bootstrap", `Ignoring stale deleted-worktree provider error during terminal completion reroot: ${displayMsg || rawErrorMsg}`);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
295
319
|
const errorDetail = displayMsg ? `: ${displayMsg}` : "";
|
|
296
320
|
const explicitRetryAfterMs = ("retryAfterMs" in lastMsg && typeof lastMsg.retryAfterMs === "number") ? lastMsg.retryAfterMs : undefined;
|
|
297
321
|
// ── 1. Classify using rawErrorMsg to avoid prose false-positives ────
|
|
@@ -375,7 +399,7 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
375
399
|
// Core retries transient failures in-session after this handler.
|
|
376
400
|
// Keep that behavior for non-rate-limit classes to avoid pause/retry races,
|
|
377
401
|
// but let rate-limit continue into model fallback logic below (#4373).
|
|
378
|
-
if (
|
|
402
|
+
if (shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg)) {
|
|
379
403
|
return;
|
|
380
404
|
}
|
|
381
405
|
// Cap rate-limit backoff for CLI-style providers (openai-codex, google-gemini-cli)
|
|
@@ -468,17 +468,18 @@ export function registerDbTools(pi) {
|
|
|
468
468
|
promptGuidelines: [
|
|
469
469
|
"Use gsd_plan_milestone for milestone planning instead of writing ROADMAP.md directly.",
|
|
470
470
|
"Keep parameters flat and provide the full milestone planning payload, including slices.",
|
|
471
|
+
"Milestone and slice titles must not contain forward slash (/), en dash, or em dash characters.",
|
|
471
472
|
"The tool validates input, writes milestone and slice planning data transactionally, renders ROADMAP.md from DB, and clears both state and parse caches after success.",
|
|
472
473
|
"Use the canonical name gsd_plan_milestone; gsd_milestone_plan is only an alias.",
|
|
473
474
|
],
|
|
474
475
|
parameters: Type.Object({
|
|
475
476
|
// ── Core identification + content (required) ──────────────────────
|
|
476
477
|
milestoneId: Type.String({ description: "Milestone ID (e.g. M001)" }),
|
|
477
|
-
title: Type.String({ description: "Milestone title" }),
|
|
478
|
+
title: Type.String({ description: "Milestone title; must not contain forward slash (/), en dash, or em dash characters" }),
|
|
478
479
|
vision: Type.String({ description: "Milestone vision" }),
|
|
479
480
|
slices: Type.Array(Type.Object({
|
|
480
481
|
sliceId: Type.String({ description: "Slice ID (e.g. S01)" }),
|
|
481
|
-
title: Type.String({ description: "Slice title" }),
|
|
482
|
+
title: Type.String({ description: "Slice title; must not contain forward slash (/), en dash, or em dash characters" }),
|
|
482
483
|
risk: Type.String({ description: "Slice risk" }),
|
|
483
484
|
depends: Type.Array(Type.String(), { description: "Slice dependency IDs" }),
|
|
484
485
|
demo: Type.String({ description: "Roadmap demo text / After this" }),
|
|
@@ -546,10 +547,10 @@ export function registerDbTools(pi) {
|
|
|
546
547
|
title: Type.String({ description: "Task title" }),
|
|
547
548
|
description: Type.String({ description: "Task description / steps block" }),
|
|
548
549
|
estimate: Type.String({ description: "Task estimate string" }),
|
|
549
|
-
files: Type.Array(Type.String(), { description: "
|
|
550
|
+
files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
|
|
550
551
|
verify: Type.String({ description: "Verification command or block" }),
|
|
551
|
-
inputs: Type.Array(Type.String(), { description: "
|
|
552
|
-
expectedOutput: Type.Array(Type.String(), { description: "
|
|
552
|
+
inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
|
|
553
|
+
expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
|
|
553
554
|
observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
|
|
554
555
|
}), { description: "Planned tasks for the slice" }),
|
|
555
556
|
// ── Enrichment metadata (optional — defaults to empty) ────────────
|
|
@@ -622,10 +623,10 @@ export function registerDbTools(pi) {
|
|
|
622
623
|
title: Type.String({ description: "Task title" }),
|
|
623
624
|
description: Type.String({ description: "Task description / steps block" }),
|
|
624
625
|
estimate: Type.String({ description: "Task estimate string" }),
|
|
625
|
-
files: Type.Array(Type.String(), { description: "
|
|
626
|
+
files: Type.Array(Type.String(), { description: "Array<string> of files likely touched; pass [\"path\"] or [], never a single string" }),
|
|
626
627
|
verify: Type.String({ description: "Verification command or block" }),
|
|
627
|
-
inputs: Type.Array(Type.String(), { description: "
|
|
628
|
-
expectedOutput: Type.Array(Type.String(), { description: "
|
|
628
|
+
inputs: Type.Array(Type.String(), { description: "Array<string> of input files or references; pass [\"path\"] or [], never a single string" }),
|
|
629
|
+
expectedOutput: Type.Array(Type.String(), { description: "Array<string> of expected output files or artifacts; pass [\"path\"] or [], never a single string" }),
|
|
629
630
|
observabilityImpact: Type.Optional(Type.String({ description: "Task observability impact" })),
|
|
630
631
|
// Single-writer v3 audit trail (Stream 2): caller-provided actor identity + causation.
|
|
631
632
|
actorName: Type.Optional(Type.String({ description: "Caller-provided actor identity for the audit trail (e.g. 'executor-01', 'gsd-orchestrator')" })),
|
|
@@ -24,6 +24,7 @@ import { resolveWorktreeProjectRoot } from "../worktree-root.js";
|
|
|
24
24
|
import { extractSubagentAgentClasses } from "./subagent-input.js";
|
|
25
25
|
import { approvalGateIdForUnit, isExplicitApprovalResponse, shouldPauseForUserApprovalQuestion } from "../user-input-boundary.js";
|
|
26
26
|
import { resolveSkillManifest } from "../skill-manifest.js";
|
|
27
|
+
import { getGuidedUnitContext } from "../guided-unit-context.js";
|
|
27
28
|
let approvalQuestionAbortInFlight = false;
|
|
28
29
|
async function loadWelcomeScreenModule() {
|
|
29
30
|
const candidates = [];
|
|
@@ -675,7 +676,8 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
675
676
|
// subagent dispatch. Closes the b23 bug class where a discuss-milestone
|
|
676
677
|
// turn used the host Edit tool to modify user source files.
|
|
677
678
|
const dash = getAutoRuntimeSnapshot();
|
|
678
|
-
const
|
|
679
|
+
const guidedUnit = getGuidedUnitContext(discussionBasePath);
|
|
680
|
+
const activeUnitType = dash.currentUnit?.type ?? guidedUnit?.unitType;
|
|
679
681
|
if (activeUnitType) {
|
|
680
682
|
const manifest = resolveManifest(activeUnitType);
|
|
681
683
|
if (manifest) {
|
|
@@ -694,7 +696,7 @@ export function registerHooks(pi, ecosystemHandlers) {
|
|
|
694
696
|
// Subagent inputs use { agent }, { tasks: [{ agent }] }, or { chain: [{ agent }] }.
|
|
695
697
|
agentClasses = extractSubagentAgentClasses(event.input);
|
|
696
698
|
}
|
|
697
|
-
const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
|
|
699
|
+
const planningGuard = shouldBlockPlanningUnit(event.toolName, planningInput, dash.basePath || guidedUnit?.basePath || discussionBasePath, activeUnitType, manifest.tools, agentClasses);
|
|
698
700
|
if (planningGuard.block)
|
|
699
701
|
return planningGuard;
|
|
700
702
|
}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
export function extractSubagentAgentClasses(input) {
|
|
2
2
|
if (!input || typeof input !== "object")
|
|
3
3
|
return [];
|
|
4
|
-
const record = input;
|
|
5
4
|
const agentClasses = [];
|
|
5
|
+
const visited = new WeakSet();
|
|
6
6
|
const addAgentClass = (value) => {
|
|
7
|
-
if (typeof value
|
|
8
|
-
|
|
7
|
+
if (typeof value !== "string")
|
|
8
|
+
return;
|
|
9
|
+
const normalized = value.trim().replace(/\.md$/i, "");
|
|
10
|
+
if (normalized.length > 0)
|
|
11
|
+
agentClasses.push(normalized);
|
|
9
12
|
};
|
|
10
|
-
const
|
|
13
|
+
const visitItems = (value) => {
|
|
11
14
|
if (!Array.isArray(value))
|
|
12
15
|
return;
|
|
13
16
|
for (const item of value) {
|
|
14
|
-
|
|
15
|
-
addAgentClass(item.agent);
|
|
17
|
+
visit(item);
|
|
16
18
|
}
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const visit = (value) => {
|
|
21
|
+
if (!value || typeof value !== "object")
|
|
22
|
+
return;
|
|
23
|
+
if (visited.has(value))
|
|
24
|
+
return;
|
|
25
|
+
visited.add(value);
|
|
26
|
+
const record = value;
|
|
27
|
+
addAgentClass(record.agent);
|
|
28
|
+
visitItems(record.tasks);
|
|
29
|
+
visitItems(record.chain);
|
|
30
|
+
visitItems(record.parallel);
|
|
31
|
+
};
|
|
32
|
+
visit(input);
|
|
21
33
|
return agentClasses;
|
|
22
34
|
}
|
|
@@ -3,6 +3,7 @@ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkS
|
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { minimatch } from "minimatch";
|
|
5
5
|
import { getIsolationMode } from "../preferences.js";
|
|
6
|
+
import { compileSubagentPermissionContract } from "../unit-context-manifest.js";
|
|
6
7
|
import { logWarning } from "../workflow-logger.js";
|
|
7
8
|
import { isGsdWorktreePath, resolveWorktreeProjectRoot } from "../worktree-root.js";
|
|
8
9
|
/**
|
|
@@ -58,6 +59,7 @@ const QUEUE_SAFE_TOOLS = new Set([
|
|
|
58
59
|
* true / false — shell no-ops / test exit codes
|
|
59
60
|
*/
|
|
60
61
|
const BASH_READ_ONLY_RE = /^\s*(cat|head|tail|less|more|wc|file|stat|du|df|which|type|echo|printf|ls|find|grep|rg|awk|sed\b(?!.*-i)|sort|uniq|diff|comm|tr|cut|tee\s+-a\s+\/dev\/null|git\s+(log|show|diff|status|branch|tag|remote|rev-parse|ls-files|blame|shortlog|describe|stash\s+list|config\s+--get|cat-file)|gh\s+(issue|pr|api|repo|release)\s+(view|list|diff|status|checks)|mkdir\s+-p\s+\.gsd|rtk\s|npm\s+run\s+(test|test:\w+|lint|lint:\w+|typecheck|type-check|type-check:\w+|check|verify|audit|outdated|format:check|ci|validate)\b|npm\s+(ls|list|info|view|show|outdated|audit|explain|doctor|ping|--version|-v)\b|npx\s|tsx\s|node\s+(--print|--version|-v\b)|python[23]?\s+(-c\s+'[^']*'|--version|-V\b|-m\s+(pip\s+show|pip\s+list|site))|pip[23]?\s+(show|list|freeze|check|index\s+versions)\b|jq\s|yq\s|curl\s+(-s\b|--silent\b)(?!\s+[^|>]*\s-[oO]\b)(?!\s+[^|>]*\s--output\b)[^|>]*$|openssl\s+(version|x509|s_client)|env\b|printenv\b|true\b|false\b)/;
|
|
62
|
+
const BASH_VERIFICATION_RE = /^\s*(npm\s+(run\s+(build|test|test:\w+|lint|lint:\w+|typecheck|type-check|verify|ci|validate)\b|test\b)|pnpm\s+(build|test|lint|typecheck|verify)\b|yarn\s+(build|test|lint|typecheck|verify)\b|vitest\b|jest\b|go\s+test\b)/;
|
|
61
63
|
function createEmptyWriteGateState() {
|
|
62
64
|
return {
|
|
63
65
|
verifiedDepthMilestones: new Set(),
|
|
@@ -642,6 +644,9 @@ function blockReason(unitType, mode, what) {
|
|
|
642
644
|
* and listed in the policy's allowedSubagents.
|
|
643
645
|
* - "docs" → like "planning" but also allows writes to paths
|
|
644
646
|
* matching `allowedPathGlobs` relative to basePath.
|
|
647
|
+
* - "verification"
|
|
648
|
+
* → allows Bash for project verification commands, but keeps
|
|
649
|
+
* writes restricted to .gsd/ and blocks subagent dispatch.
|
|
645
650
|
*
|
|
646
651
|
* `pathOrCommand` is the file path for write/edit-shaped tools and the
|
|
647
652
|
* shell command for bash. Other tools ignore this argument.
|
|
@@ -673,7 +678,7 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
|
|
|
673
678
|
// Unknown tool in read-only mode — block by default.
|
|
674
679
|
return { block: true, reason: blockReason(unitType, policy.mode, `tool "${tool}" is not on the read-only allowlist`) };
|
|
675
680
|
}
|
|
676
|
-
// planning / planning-dispatch / docs modes share the same surface for safe tools, bash, and subagent.
|
|
681
|
+
// planning / planning-dispatch / docs / verification modes share the same surface for safe tools, bash, and subagent.
|
|
677
682
|
if (PLANNING_SAFE_TOOLS.has(tool))
|
|
678
683
|
return { block: false };
|
|
679
684
|
if (tool.startsWith("gsd_"))
|
|
@@ -681,7 +686,8 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
|
|
|
681
686
|
if (PLANNING_SUBAGENT_TOOLS.has(tool)) {
|
|
682
687
|
if (policy.mode === "planning-dispatch") {
|
|
683
688
|
const requested = (agentClasses ?? []).map(a => a.trim()).filter(Boolean);
|
|
684
|
-
const
|
|
689
|
+
const dispatchContract = compileSubagentPermissionContract(policy);
|
|
690
|
+
const allowedSubagents = dispatchContract.allowedSubagents;
|
|
685
691
|
const allowed = new Set(allowedSubagents);
|
|
686
692
|
// When agentClasses is undefined, the caller has not been updated to extract
|
|
687
693
|
// agent identities yet. Block and warn so stale callers surface in telemetry
|
|
@@ -718,6 +724,14 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
|
|
|
718
724
|
return { block: true, reason: blockReason(unitType, policy.mode, `subagent dispatch is not permitted in planning units`) };
|
|
719
725
|
}
|
|
720
726
|
if (tool === "bash") {
|
|
727
|
+
if (policy.mode === "verification") {
|
|
728
|
+
if (BASH_VERIFICATION_RE.test(pathOrCommand) || BASH_READ_ONLY_RE.test(pathOrCommand))
|
|
729
|
+
return { block: false };
|
|
730
|
+
return {
|
|
731
|
+
block: true,
|
|
732
|
+
reason: blockReason(unitType, policy.mode, `bash is restricted to build/test verification commands (npm run build, npm test, etc.); cannot run "${pathOrCommand.slice(0, 80)}${pathOrCommand.length > 80 ? "…" : ""}"`),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
721
735
|
if (BASH_READ_ONLY_RE.test(pathOrCommand))
|
|
722
736
|
return { block: false };
|
|
723
737
|
return {
|
|
@@ -8,14 +8,153 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Design constraints (from Trek-e approval):
|
|
10
10
|
* - Warn the user before stashing (no silent surprises)
|
|
11
|
-
* - git stash push / git stash
|
|
12
|
-
* - Stash/
|
|
11
|
+
* - git stash push / git stash apply+drop for targeted restore
|
|
12
|
+
* - Stash/apply errors are logged but MUST NOT block the merge itself
|
|
13
13
|
* - Fast-path status check — clean trees pay no extra cost
|
|
14
14
|
*/
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
16
18
|
import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
|
|
17
19
|
import { logWarning } from "./workflow-logger.js";
|
|
18
20
|
import { nativeHasChanges } from "./native-git-bridge.js";
|
|
21
|
+
function gitText(basePath, args) {
|
|
22
|
+
return execFileSync("git", args, {
|
|
23
|
+
cwd: basePath,
|
|
24
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
25
|
+
encoding: "utf-8",
|
|
26
|
+
env: GIT_NO_PROMPT_ENV,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function gitBuffer(basePath, args) {
|
|
30
|
+
return execFileSync("git", args, {
|
|
31
|
+
cwd: basePath,
|
|
32
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
33
|
+
env: GIT_NO_PROMPT_ENV,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function errorText(err) {
|
|
37
|
+
if (!err || typeof err !== "object")
|
|
38
|
+
return String(err);
|
|
39
|
+
const parts = [];
|
|
40
|
+
const stderr = err.stderr;
|
|
41
|
+
const stdout = err.stdout;
|
|
42
|
+
for (const value of [stderr, stdout]) {
|
|
43
|
+
if (typeof value === "string")
|
|
44
|
+
parts.push(value);
|
|
45
|
+
else if (value instanceof Uint8Array)
|
|
46
|
+
parts.push(Buffer.from(value).toString("utf-8"));
|
|
47
|
+
}
|
|
48
|
+
parts.push(err instanceof Error ? err.message : String(err));
|
|
49
|
+
return parts.filter(Boolean).join("\n");
|
|
50
|
+
}
|
|
51
|
+
function parseAlreadyExistsNoCheckoutPaths(text) {
|
|
52
|
+
const paths = [];
|
|
53
|
+
for (const line of text.split(/\r?\n/)) {
|
|
54
|
+
const match = /^(.+?) already exists, no checkout$/i.exec(line.trim());
|
|
55
|
+
if (match?.[1])
|
|
56
|
+
paths.push(match[1]);
|
|
57
|
+
}
|
|
58
|
+
return [...new Set(paths)];
|
|
59
|
+
}
|
|
60
|
+
function readZeroDelimitedPaths(output) {
|
|
61
|
+
return output.split("\0").filter(Boolean);
|
|
62
|
+
}
|
|
63
|
+
function listStashUntrackedPaths(basePath, stashRef) {
|
|
64
|
+
try {
|
|
65
|
+
const output = gitText(basePath, ["ls-tree", "-r", "-z", "--name-only", `${stashRef}^3`]);
|
|
66
|
+
return readZeroDelimitedPaths(output);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function listStashTrackedPaths(basePath, stashRef) {
|
|
73
|
+
try {
|
|
74
|
+
const output = gitText(basePath, ["diff", "--name-only", "-z", `${stashRef}^1`, stashRef]);
|
|
75
|
+
return readZeroDelimitedPaths(output);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function isWorktreeClean(basePath) {
|
|
82
|
+
try {
|
|
83
|
+
return gitText(basePath, ["status", "--porcelain"]).trim() === "";
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function stashBlobEqualsWorktreeFile(basePath, stashRef, path) {
|
|
90
|
+
try {
|
|
91
|
+
const worktreePath = join(basePath, path);
|
|
92
|
+
if (!existsSync(worktreePath))
|
|
93
|
+
return false;
|
|
94
|
+
const worktreeContent = readFileSync(worktreePath);
|
|
95
|
+
const stashContent = gitBuffer(basePath, ["show", `${stashRef}^3:${path}`]);
|
|
96
|
+
return Buffer.compare(worktreeContent, stashContent) === 0;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function reconcileAlreadyPresentUntrackedStash(basePath, milestoneId, stashRef, err) {
|
|
103
|
+
const text = errorText(err);
|
|
104
|
+
const collidedPaths = parseAlreadyExistsNoCheckoutPaths(text);
|
|
105
|
+
if (collidedPaths.length === 0)
|
|
106
|
+
return null;
|
|
107
|
+
const untrackedPaths = listStashUntrackedPaths(basePath, stashRef);
|
|
108
|
+
if (!untrackedPaths || untrackedPaths.length === 0)
|
|
109
|
+
return null;
|
|
110
|
+
const trackedPaths = listStashTrackedPaths(basePath, stashRef);
|
|
111
|
+
if (trackedPaths === null || trackedPaths.length > 0)
|
|
112
|
+
return null;
|
|
113
|
+
const untrackedPathSet = new Set(untrackedPaths);
|
|
114
|
+
if (!collidedPaths.every((path) => untrackedPathSet.has(path)))
|
|
115
|
+
return null;
|
|
116
|
+
if (!untrackedPaths.every((path) => existsSync(join(basePath, path))))
|
|
117
|
+
return null;
|
|
118
|
+
if (isWorktreeClean(basePath) !== true)
|
|
119
|
+
return null;
|
|
120
|
+
const blobComparisons = untrackedPaths.map((path) => stashBlobEqualsWorktreeFile(basePath, stashRef, path));
|
|
121
|
+
if (blobComparisons.some((result) => result === null))
|
|
122
|
+
return null;
|
|
123
|
+
const allIdentical = blobComparisons.every(Boolean);
|
|
124
|
+
if (allIdentical) {
|
|
125
|
+
let dropped = true;
|
|
126
|
+
try {
|
|
127
|
+
execFileSync("git", ["stash", "drop", stashRef], {
|
|
128
|
+
cwd: basePath,
|
|
129
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
130
|
+
encoding: "utf-8",
|
|
131
|
+
env: GIT_NO_PROMPT_ENV,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
dropped = false;
|
|
136
|
+
logWarning("preflight", `git stash drop ${stashRef} failed after identical preflight stash reconciliation: ${err instanceof Error ? err.message : String(err)}`);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
restored: true,
|
|
140
|
+
needsManualRecovery: false,
|
|
141
|
+
message: dropped
|
|
142
|
+
? `Preflight stash for milestone ${milestoneId} contained files already present after merge; identical stash dropped.`
|
|
143
|
+
: `Preflight stash for milestone ${milestoneId} contained files already present after merge, but ${stashRef} could not be dropped and remains as a backup.`,
|
|
144
|
+
stashRef,
|
|
145
|
+
resolution: dropped ? "already-present-dropped" : "already-present-preserved",
|
|
146
|
+
collidedPaths,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
restored: false,
|
|
151
|
+
needsManualRecovery: false,
|
|
152
|
+
message: `Preflight stash for milestone ${milestoneId} contained untracked files already present after merge. Keeping merged files and preserving ${stashRef} as a backup.`,
|
|
153
|
+
stashRef,
|
|
154
|
+
resolution: "already-present-preserved",
|
|
155
|
+
collidedPaths,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
19
158
|
function findPreflightStashRef(basePath, milestoneId, stashMarker) {
|
|
20
159
|
const markerPrefix = `gsd-preflight-stash:${milestoneId}:`;
|
|
21
160
|
let fallbackRef = null;
|
|
@@ -115,28 +254,50 @@ export function postflightPopStash(basePath, milestoneId, stashMarker, notify) {
|
|
|
115
254
|
message: msg,
|
|
116
255
|
};
|
|
117
256
|
}
|
|
118
|
-
execFileSync("git", ["stash", "
|
|
257
|
+
execFileSync("git", ["stash", "apply", stashRef], {
|
|
119
258
|
cwd: basePath,
|
|
120
259
|
stdio: ["ignore", "pipe", "pipe"],
|
|
121
260
|
encoding: "utf-8",
|
|
122
261
|
env: GIT_NO_PROMPT_ENV,
|
|
123
262
|
});
|
|
263
|
+
let dropWarning = null;
|
|
264
|
+
try {
|
|
265
|
+
execFileSync("git", ["stash", "drop", stashRef], {
|
|
266
|
+
cwd: basePath,
|
|
267
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
268
|
+
encoding: "utf-8",
|
|
269
|
+
env: GIT_NO_PROMPT_ENV,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
dropWarning = ` Stash was restored, but git stash drop ${stashRef} failed: ${err instanceof Error ? err.message : String(err)}.`;
|
|
274
|
+
logWarning("preflight", dropWarning.trim());
|
|
275
|
+
}
|
|
124
276
|
const msg = `Restored stashed changes after milestone ${milestoneId} merge.`;
|
|
125
|
-
notify(msg
|
|
277
|
+
notify(`${msg}${dropWarning ?? ""}`, dropWarning ? "warning" : "info");
|
|
126
278
|
return {
|
|
127
279
|
restored: true,
|
|
128
280
|
needsManualRecovery: false,
|
|
129
|
-
message: msg
|
|
281
|
+
message: `${msg}${dropWarning ?? ""}`,
|
|
130
282
|
stashRef,
|
|
283
|
+
resolution: "applied",
|
|
131
284
|
};
|
|
132
285
|
}
|
|
133
286
|
catch (err) {
|
|
134
|
-
|
|
287
|
+
if (stashRef) {
|
|
288
|
+
const reconciled = reconcileAlreadyPresentUntrackedStash(basePath, milestoneId, stashRef, err);
|
|
289
|
+
if (reconciled) {
|
|
290
|
+
logWarning("preflight", reconciled.message);
|
|
291
|
+
notify(reconciled.message, reconciled.resolution === "already-present-preserved" ? "warning" : "info");
|
|
292
|
+
return reconciled;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Apply conflicts mean the merged code collides with the stashed changes.
|
|
135
296
|
// Log a warning — the user needs to resolve manually, but the merge succeeded.
|
|
136
297
|
const restoreHint = stashRef
|
|
137
|
-
? `Run "git stash
|
|
298
|
+
? `Run "git stash apply ${stashRef}" manually to restore the correct stash, then "git stash drop ${stashRef}" after recovery.`
|
|
138
299
|
: `Run "git stash list" to find the matching GSD preflight stash before restoring manually.`;
|
|
139
|
-
const msg = `git stash
|
|
300
|
+
const msg = `git stash apply ${stashRef ?? ""}`.trim() + ` failed after merge of milestone ${milestoneId}: ${err instanceof Error ? err.message : String(err)}. ${restoreHint}`;
|
|
140
301
|
logWarning("preflight", msg);
|
|
141
302
|
notify(msg, "warning");
|
|
142
303
|
return {
|
|
@@ -144,6 +305,7 @@ export function postflightPopStash(basePath, milestoneId, stashMarker, notify) {
|
|
|
144
305
|
needsManualRecovery: true,
|
|
145
306
|
message: msg,
|
|
146
307
|
...(stashRef ? { stashRef } : {}),
|
|
308
|
+
resolution: "manual-recovery",
|
|
147
309
|
};
|
|
148
310
|
}
|
|
149
311
|
}
|