gsd-pi 2.80.0-dev.fbe7c8c6f → 2.81.0-dev.3cddbbba2
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 +47 -59
- package/dist/claude-cli-check.d.ts +30 -0
- package/dist/claude-cli-check.js +18 -7
- package/dist/cli.js +0 -19
- package/dist/headless-query.d.ts +10 -0
- package/dist/headless-query.js +6 -4
- package/dist/loader-entrypoint.d.ts +8 -0
- package/dist/loader-entrypoint.js +27 -0
- package/dist/loader.js +2 -11
- package/dist/mcp-server.d.ts +1 -0
- package/dist/mcp-server.js +6 -3
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/claude-code-cli/readiness.js +18 -7
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +40 -3
- package/dist/resources/extensions/github-sync/sync.js +4 -1
- package/dist/resources/extensions/gsd/auto/contracts.js +2 -0
- package/dist/resources/extensions/gsd/auto/loop.js +214 -17
- package/dist/resources/extensions/gsd/auto/orchestrator.js +48 -4
- package/dist/resources/extensions/gsd/auto/phases.js +372 -134
- package/dist/resources/extensions/gsd/auto/resolve.js +29 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +88 -33
- package/dist/resources/extensions/gsd/auto/session.js +18 -1
- package/dist/resources/extensions/gsd/auto/unit-runner-events.js +7 -0
- package/dist/resources/extensions/gsd/auto/verification-retry-policy.js +43 -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 +199 -177
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +30 -11
- package/dist/resources/extensions/gsd/auto-post-unit.js +119 -79
- package/dist/resources/extensions/gsd/auto-prompts.js +103 -16
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -1
- package/dist/resources/extensions/gsd/auto-runtime-state.js +5 -0
- package/dist/resources/extensions/gsd/auto-start.js +251 -16
- 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-unit-closeout.js +33 -5
- package/dist/resources/extensions/gsd/auto-verification.js +12 -6
- package/dist/resources/extensions/gsd/auto-worktree.js +237 -336
- package/dist/resources/extensions/gsd/auto.js +493 -129
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +133 -12
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +44 -37
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +37 -10
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +30 -20
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +4 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +6 -4
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +5 -3
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +1 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +337 -55
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +4 -8
- package/dist/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.js +4 -0
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +19 -2
- package/dist/resources/extensions/gsd/clean-root-preflight.js +24 -6
- package/dist/resources/extensions/gsd/commands/handlers/notifications-handler.js +4 -10
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +2 -2
- package/dist/resources/extensions/gsd/commands-config.js +1 -1
- package/dist/resources/extensions/gsd/commands-eval-review.js +2 -2
- 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/dashboard-overlay.js +1 -1
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +92 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +4 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +6 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +75 -6
- package/dist/resources/extensions/gsd/gsd-db.js +46 -13
- package/dist/resources/extensions/gsd/guided-flow.js +119 -42
- package/dist/resources/extensions/gsd/health-widget-core.js +1 -1
- package/dist/resources/extensions/gsd/health-widget.js +6 -9
- package/dist/resources/extensions/gsd/init-wizard.js +4 -1
- 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 +46 -22
- package/dist/resources/extensions/gsd/notification-overlay.js +35 -40
- package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
- package/dist/resources/extensions/gsd/parallel-merge.js +53 -30
- package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +25 -33
- 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/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 +22 -17
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +14 -12
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +20 -2
- package/dist/resources/extensions/gsd/prompts/discuss.md +20 -2
- 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-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/recovery-classification.js +94 -0
- package/dist/resources/extensions/gsd/slice-cadence.js +45 -2
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +15 -9
- package/dist/resources/extensions/gsd/state-reconciliation.js +27 -0
- package/dist/resources/extensions/gsd/tool-contract.js +50 -0
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -7
- package/dist/resources/extensions/gsd/tools/complete-task.js +1 -1
- 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/tui/render-kit.js +74 -0
- 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/watch/header-renderer.js +92 -69
- package/dist/resources/extensions/gsd/watch/splash-palette.js +10 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +2 -2
- package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
- package/dist/resources/extensions/gsd/worktree-lifecycle.js +1364 -0
- package/dist/resources/extensions/gsd/worktree-safety.js +119 -0
- package/dist/resources/extensions/gsd/worktree-state-projection.js +317 -0
- package/dist/resources/extensions/gsd/worktree-telemetry.js +3 -1
- package/dist/resources/skills/web-quality-audit/scripts/analyze.sh +0 -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 +2 -2
- 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_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
- 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/middleware.js +3 -3
- 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/8359.e059d86b255fce1c.js +10 -0
- package/dist/web/standalone/.next/static/chunks/app/{page-fab3ebb85b006001.js → page-752f1e2ebdaa3e45.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/{webpack-0481f1221120a7c6.js → webpack-de742b64187e13fe.js} +1 -1
- package/dist/welcome-screen.d.ts +2 -7
- package/dist/welcome-screen.js +68 -75
- package/package.json +3 -3
- package/packages/daemon/package.json +2 -2
- 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/package.json +2 -2
- 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/package.json +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 +9 -2
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +43 -11
- 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 +31 -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/package.json +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 +52 -11
- 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 +26 -10
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js +35 -13
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +21 -11
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts +7 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +9 -7
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +23 -14
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +2 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +48 -21
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js +22 -21
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js +22 -21
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js.map +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +39 -25
- package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +26 -22
- package/packages/pi-ai/src/providers/anthropic.ts +22 -9
- package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +34 -21
- package/packages/pi-ai/src/types.ts +3 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +56 -22
- package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +24 -28
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +24 -28
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +36 -1
- 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 +30 -1
- 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 +21 -2
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +94 -16
- 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 +6 -2
- 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 +3 -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 +6 -6
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +5 -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 +60 -4
- 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/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 +81 -4
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -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 +25 -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/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/core/tools/bash-spawn-windows.test.js +22 -56
- package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.js +12 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.js +14 -6
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/grep.js +12 -3
- package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +2 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/ls.js +10 -3
- package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/read.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js +7 -62
- package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js +115 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts +19 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.js +20 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts +4 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/write.js +9 -1
- package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.js +47 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/assistant-message-design.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +161 -7
- 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/__tests__/user-message-design.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.js +40 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/user-message-design.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts +0 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +30 -29
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +10 -3
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +1 -1
- 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 +13 -13
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +1 -3
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +58 -3
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +2 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +12 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.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 +14 -41
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +25 -1
- 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 +6 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +225 -73
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.d.ts +35 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.js +152 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/transcript-design.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.js +73 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tui-style-kit.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +12 -8
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +31 -6
- 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 +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +2 -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 +25 -3
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.js +17 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-highlight.test.js.map +1 -0
- 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 +105 -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 +27 -26
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +9 -6
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- 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 +28 -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/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +40 -1
- package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +40 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +102 -16
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +6 -2
- 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 +5 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +8 -5
- package/packages/pi-coding-agent/src/core/extensions/types.ts +63 -2
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
- package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +92 -4
- package/packages/pi-coding-agent/src/core/settings-manager.ts +39 -1
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/src/core/tools/bash-spawn-windows.test.ts +22 -66
- package/packages/pi-coding-agent/src/core/tools/bash.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/edit.ts +13 -1
- package/packages/pi-coding-agent/src/core/tools/find.ts +15 -6
- package/packages/pi-coding-agent/src/core/tools/grep.ts +13 -3
- package/packages/pi-coding-agent/src/core/tools/hashline-read.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/index.ts +8 -0
- package/packages/pi-coding-agent/src/core/tools/ls.ts +11 -3
- package/packages/pi-coding-agent/src/core/tools/read.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/spawn-shell-windows.test.ts +11 -72
- package/packages/pi-coding-agent/src/core/tools/tool-target-metadata.test.ts +127 -0
- package/packages/pi-coding-agent/src/core/tools/tool-target.ts +48 -0
- package/packages/pi-coding-agent/src/core/tools/write.ts +14 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/assistant-message-design.test.ts +56 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +228 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/user-message-design.test.ts +48 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +10 -3
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +43 -42
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +14 -14
- package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +64 -3
- package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +13 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +15 -42
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +31 -1
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +247 -94
- package/packages/pi-coding-agent/src/modes/interactive/components/transcript-design.ts +196 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tui-style-kit.ts +94 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +14 -9
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +75 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +39 -8
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +27 -3
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-highlight.test.ts +23 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +106 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +27 -26
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +9 -6
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +1 -1
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +31 -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__/overlay-layout.test.js +14 -1
- package/packages/pi-tui/dist/__tests__/overlay-layout.test.js.map +1 -1
- package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -1
- package/packages/pi-tui/dist/overlay-layout.js +9 -6
- package/packages/pi-tui/dist/overlay-layout.js.map +1 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +18 -8
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/src/__tests__/overlay-layout.test.ts +20 -1
- package/packages/pi-tui/src/overlay-layout.ts +10 -7
- package/packages/pi-tui/src/tui.ts +20 -8
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/packages/rpc-client/README.md +7 -0
- package/packages/rpc-client/package.json +1 -1
- package/pkg/dist/modes/interactive/theme/theme-highlight.test.d.ts +2 -0
- package/pkg/dist/modes/interactive/theme/theme-highlight.test.d.ts.map +1 -0
- package/pkg/dist/modes/interactive/theme/theme-highlight.test.js +17 -0
- package/pkg/dist/modes/interactive/theme/theme-highlight.test.js.map +1 -0
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +105 -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 +27 -26
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +25 -7
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +42 -3
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +67 -0
- package/src/resources/extensions/github-sync/sync.ts +8 -1
- package/src/resources/extensions/github-sync/tests/sync-source.test.ts +6 -18
- package/src/resources/extensions/gsd/auto/contracts.ts +19 -2
- package/src/resources/extensions/gsd/auto/loop-deps.ts +19 -16
- package/src/resources/extensions/gsd/auto/loop.ts +247 -25
- package/src/resources/extensions/gsd/auto/orchestrator.ts +52 -4
- package/src/resources/extensions/gsd/auto/phases.ts +512 -202
- package/src/resources/extensions/gsd/auto/resolve.ts +42 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +97 -34
- package/src/resources/extensions/gsd/auto/session.ts +19 -1
- package/src/resources/extensions/gsd/auto/types.ts +3 -0
- package/src/resources/extensions/gsd/auto/unit-runner-events.ts +15 -0
- package/src/resources/extensions/gsd/auto/verification-retry-policy.ts +82 -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 +249 -182
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +31 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +131 -81
- package/src/resources/extensions/gsd/auto-prompts.ts +112 -15
- package/src/resources/extensions/gsd/auto-recovery.ts +54 -0
- package/src/resources/extensions/gsd/auto-runtime-state.ts +5 -0
- package/src/resources/extensions/gsd/auto-start.ts +321 -21
- 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-unit-closeout.ts +51 -0
- package/src/resources/extensions/gsd/auto-verification.ts +12 -6
- package/src/resources/extensions/gsd/auto-worktree.ts +267 -360
- package/src/resources/extensions/gsd/auto.ts +578 -126
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +166 -12
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +45 -37
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +36 -10
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +32 -19
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +5 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +7 -4
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +6 -3
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +1 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +384 -55
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +5 -8
- package/src/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.ts +4 -0
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -2
- package/src/resources/extensions/gsd/clean-root-preflight.ts +32 -7
- package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +4 -10
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +4 -2
- package/src/resources/extensions/gsd/commands-config.ts +1 -1
- package/src/resources/extensions/gsd/commands-eval-review.ts +2 -2
- 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/dashboard-overlay.ts +1 -1
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +107 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +4 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +8 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +89 -10
- package/src/resources/extensions/gsd/gsd-db.ts +50 -13
- package/src/resources/extensions/gsd/guided-flow.ts +148 -49
- package/src/resources/extensions/gsd/health-widget-core.ts +1 -1
- package/src/resources/extensions/gsd/health-widget.ts +8 -9
- package/src/resources/extensions/gsd/init-wizard.ts +5 -1
- package/src/resources/extensions/gsd/journal.ts +2 -0
- 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 +53 -19
- package/src/resources/extensions/gsd/notification-overlay.ts +50 -46
- package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
- package/src/resources/extensions/gsd/parallel-merge.ts +61 -34
- package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +33 -35
- 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/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 +22 -17
- package/src/resources/extensions/gsd/prompts/complete-slice.md +14 -12
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +20 -2
- package/src/resources/extensions/gsd/prompts/discuss.md +20 -2
- 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-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/recovery-classification.ts +122 -0
- package/src/resources/extensions/gsd/slice-cadence.ts +49 -2
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +23 -9
- package/src/resources/extensions/gsd/state-reconciliation.ts +57 -0
- package/src/resources/extensions/gsd/tests/agent-end-retry.test.ts +59 -89
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +47 -172
- package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +0 -35
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +134 -9
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +1125 -215
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +80 -59
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +119 -2
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +3 -47
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +363 -18
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +175 -11
- package/src/resources/extensions/gsd/tests/auto-pr-bugs.test.ts +54 -95
- package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +67 -26
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/auto-remediate-slice-status.test.ts +32 -30
- package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +16 -1
- package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +32 -128
- package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +20 -54
- package/src/resources/extensions/gsd/tests/auto-start-cold-db-bootstrap.test.ts +20 -30
- package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +17 -29
- package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +160 -0
- package/src/resources/extensions/gsd/tests/auto-start-time-persistence.test.ts +21 -39
- package/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts +15 -24
- package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +44 -29
- package/src/resources/extensions/gsd/tests/auto-unit-closeout.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +39 -51
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +159 -213
- package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +15 -32
- package/src/resources/extensions/gsd/tests/browser-teardown.test.ts +0 -41
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +15 -6
- package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +34 -27
- package/src/resources/extensions/gsd/tests/cmux.test.ts +51 -53
- package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +39 -61
- package/src/resources/extensions/gsd/tests/commands-config.test.ts +26 -19
- 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-milestone.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/complete-task-normalize-lists.test.ts +29 -33
- package/src/resources/extensions/gsd/tests/completed-units-metrics-sync.test.ts +45 -108
- 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 +90 -31
- 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 +46 -11
- package/src/resources/extensions/gsd/tests/cwd-fallback-hardening.test.ts +138 -0
- package/src/resources/extensions/gsd/tests/dashboard-custom-engine.test.ts +4 -68
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +24 -11
- package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +14 -65
- package/src/resources/extensions/gsd/tests/discuss-tool-scoping.test.ts +44 -37
- package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +100 -38
- package/src/resources/extensions/gsd/tests/dispatch-guard-closed-status.test.ts +25 -15
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/dispatcher-stuck-planning.test.ts +35 -17
- package/src/resources/extensions/gsd/tests/error-success-mask.test.ts +16 -21
- package/src/resources/extensions/gsd/tests/est-annotation-timeout.test.ts +15 -82
- 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 +151 -0
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +2 -20
- package/src/resources/extensions/gsd/tests/frontmatter-parse-noise.test.ts +18 -26
- package/src/resources/extensions/gsd/tests/header-renderer.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/headless-milestone-parity.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +14 -4
- package/src/resources/extensions/gsd/tests/init-skip-git.test.ts +9 -12
- package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/integration/git-locale.test.ts +31 -20
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +92 -0
- package/src/resources/extensions/gsd/tests/integration/milestone-transition-worktree.test.ts +0 -47
- package/src/resources/extensions/gsd/tests/integration/parallel-merge.test.ts +116 -24
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +60 -202
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +13 -56
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +248 -11
- 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/lazy-pi-tui-import.test.ts +44 -6
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +21 -35
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +77 -12
- 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 +267 -0
- package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +88 -98
- package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +70 -278
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/needs-remediation-revalidation.test.ts +37 -30
- package/src/resources/extensions/gsd/tests/note-captures-executed.test.ts +32 -28
- package/src/resources/extensions/gsd/tests/notification-overlay.test.ts +78 -41
- package/src/resources/extensions/gsd/tests/notifications-handler.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +12 -182
- package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +144 -0
- package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
- package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +38 -6
- package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/phantom-ghost-detection.test.ts +24 -37
- package/src/resources/extensions/gsd/tests/phantom-milestone-default-queued.test.ts +9 -24
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +95 -75
- 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/post-exec-retry-bypass.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +36 -22
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +36 -30
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +74 -4
- package/src/resources/extensions/gsd/tests/preferences-worktree-sync.test.ts +20 -22
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +130 -32
- package/src/resources/extensions/gsd/tests/project-root-cwd-crash.test.ts +18 -36
- package/src/resources/extensions/gsd/tests/projection-no-plan-overwrite.test.ts +35 -73
- package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +76 -138
- package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +24 -1
- 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 +70 -106
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +59 -161
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +33 -29
- package/src/resources/extensions/gsd/tests/queue-auto-guard.test.ts +22 -196
- package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +23 -93
- package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +50 -79
- package/src/resources/extensions/gsd/tests/reassess-default-optin.test.ts +27 -13
- package/src/resources/extensions/gsd/tests/remote-questions.test.ts +151 -251
- package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +41 -29
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +58 -69
- package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +36 -164
- package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +57 -41
- package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +91 -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-model-override.test.ts +14 -9
- 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 +222 -0
- package/src/resources/extensions/gsd/tests/show-config-command.test.ts +44 -42
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/skip-slice-state-rebuild.test.ts +56 -24
- package/src/resources/extensions/gsd/tests/skipped-validation-db-atomicity.test.ts +51 -11
- package/src/resources/extensions/gsd/tests/slice-cadence.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/slice-context-injection.test.ts +66 -50
- package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +68 -107
- package/src/resources/extensions/gsd/tests/slice-sequence-insert.test.ts +115 -42
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +21 -77
- package/src/resources/extensions/gsd/tests/smart-entry-draft.test.ts +25 -116
- package/src/resources/extensions/gsd/tests/sqlite-unavailable-gate.test.ts +21 -57
- package/src/resources/extensions/gsd/tests/stale-dirlistcache-4648.test.ts +29 -76
- package/src/resources/extensions/gsd/tests/stale-lockfile-recovery.test.ts +33 -24
- package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +39 -30
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +65 -56
- package/src/resources/extensions/gsd/tests/status-db-open.test.ts +35 -40
- package/src/resources/extensions/gsd/tests/stop-auto-merge-back.test.ts +48 -46
- package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +14 -102
- package/src/resources/extensions/gsd/tests/subagent-model-dispatch.test.ts +78 -232
- package/src/resources/extensions/gsd/tests/sync-worktree-skip-current.test.ts +32 -35
- 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-profile.test.ts +84 -309
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +295 -0
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +134 -341
- package/src/resources/extensions/gsd/tests/tui-header-lifecycle.test.ts +330 -0
- package/src/resources/extensions/gsd/tests/tui-render-kit.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +136 -4
- package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +8 -25
- 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 -99
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +43 -36
- package/src/resources/extensions/gsd/tests/verification-retry-policy.test.ts +83 -0
- package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +84 -444
- package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +142 -0
- package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +44 -189
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +8 -57
- 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/worktree-db-same-file.test.ts +21 -44
- package/src/resources/extensions/gsd/tests/worktree-expected-warnings.test.ts +27 -26
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +14 -13
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +197 -78
- package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +888 -0
- package/src/resources/extensions/gsd/tests/worktree-main-branch.test.ts +20 -18
- 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-safety.test.ts +327 -0
- package/src/resources/extensions/gsd/tests/worktree-state-projection.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/worktree-telemetry.test.ts +59 -2
- package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +40 -1
- package/src/resources/extensions/gsd/tests/zero-slice-roadmap-guided.test.ts +19 -13
- package/src/resources/extensions/gsd/tool-contract.ts +82 -0
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +14 -15
- package/src/resources/extensions/gsd/tools/complete-task.ts +1 -1
- 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/tui/render-kit.ts +109 -0
- 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/watch/header-renderer.ts +121 -79
- package/src/resources/extensions/gsd/watch/splash-palette.ts +11 -0
- package/src/resources/extensions/gsd/workflow-mcp.ts +2 -2
- package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
- package/src/resources/extensions/gsd/worktree-lifecycle.ts +1882 -0
- package/src/resources/extensions/gsd/worktree-safety.ts +282 -0
- package/src/resources/extensions/gsd/worktree-state-projection.ts +404 -0
- package/src/resources/extensions/gsd/worktree-telemetry.ts +7 -2
- package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +86 -40
- package/src/resources/skills/web-quality-audit/scripts/analyze.sh +0 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +0 -733
- package/dist/web/standalone/.next/static/chunks/8336.631939fb583761fa.js +0 -10
- package/src/resources/extensions/gsd/tests/sync-layer-scope.test.ts +0 -434
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +0 -1247
- package/src/resources/extensions/gsd/worktree-resolver.ts +0 -909
- /package/dist/web/standalone/.next/static/{yTuahMMuJzVnsov5PreWl → F5x9E6H9k_52fjqyql93y}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{yTuahMMuJzVnsov5PreWl → F5x9E6H9k_52fjqyql93y}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Project/App: GSD-2
|
|
2
|
+
// File Purpose: Auto-mode orchestration, session lifecycle, and stop handling.
|
|
1
3
|
/**
|
|
2
4
|
* GSD Auto Mode — Fresh Session Per Unit
|
|
3
5
|
*
|
|
@@ -14,6 +16,7 @@ import type {
|
|
|
14
16
|
ExtensionAPI,
|
|
15
17
|
ExtensionContext,
|
|
16
18
|
ExtensionCommandContext,
|
|
19
|
+
SessionMessageEntry,
|
|
17
20
|
} from "@gsd/pi-coding-agent";
|
|
18
21
|
|
|
19
22
|
import { deriveState } from "./state.js";
|
|
@@ -30,7 +33,7 @@ import {
|
|
|
30
33
|
setRuntimeKv,
|
|
31
34
|
deleteRuntimeKv,
|
|
32
35
|
} from "./db/runtime-kv.js";
|
|
33
|
-
import { getManifestStatus } from "./files.js";
|
|
36
|
+
import { extractSection, getManifestStatus, splitFrontmatter, parseFrontmatterMap } from "./files.js";
|
|
34
37
|
export { inlinePriorMilestoneSummary } from "./files.js";
|
|
35
38
|
import { collectSecretsFromManifest } from "../get-secrets-from-user.js";
|
|
36
39
|
import {
|
|
@@ -59,6 +62,7 @@ import {
|
|
|
59
62
|
isLockProcessAlive,
|
|
60
63
|
formatCrashInfo,
|
|
61
64
|
emitCrashRecoveredUnitEnd,
|
|
65
|
+
emitOpenUnitEndForUnit,
|
|
62
66
|
} from "./crash-recovery.js";
|
|
63
67
|
import {
|
|
64
68
|
acquireSessionLock,
|
|
@@ -150,6 +154,7 @@ import {
|
|
|
150
154
|
resolveProjectRoot,
|
|
151
155
|
} from "./worktree.js";
|
|
152
156
|
import { GitServiceImpl } from "./git-service.js";
|
|
157
|
+
import { nativeCheckoutBranch } from "./native-git-bridge.js";
|
|
153
158
|
import { getPriorSliceCompletionBlocker } from "./dispatch-guard.js";
|
|
154
159
|
import {
|
|
155
160
|
createAutoWorktree,
|
|
@@ -162,8 +167,6 @@ import {
|
|
|
162
167
|
mergeMilestoneToMain,
|
|
163
168
|
autoWorktreeBranch,
|
|
164
169
|
syncWorktreeStateBack,
|
|
165
|
-
syncProjectRootToWorktree,
|
|
166
|
-
syncStateToProjectRoot,
|
|
167
170
|
readResourceVersion,
|
|
168
171
|
checkResourcesStale,
|
|
169
172
|
escapeStaleWorktree,
|
|
@@ -186,6 +189,8 @@ import { isClosedStatus } from "./status-guards.js";
|
|
|
186
189
|
import {
|
|
187
190
|
type AutoDashboardData,
|
|
188
191
|
updateProgressWidget as _updateProgressWidget,
|
|
192
|
+
setCompletionProgressWidget,
|
|
193
|
+
setAutoOutcomeWidget,
|
|
189
194
|
updateSliceProgressCache,
|
|
190
195
|
clearSliceProgressCache,
|
|
191
196
|
describeNextUnit as _describeNextUnit,
|
|
@@ -199,7 +204,9 @@ import {
|
|
|
199
204
|
deregisterSigtermHandler as _deregisterSigtermHandler,
|
|
200
205
|
detectWorkingTreeActivity,
|
|
201
206
|
} from "./auto-supervisor.js";
|
|
202
|
-
import { isDbAvailable, getMilestone } from "./gsd-db.js";
|
|
207
|
+
import { isDbAvailable, getMilestone, getMilestoneSlices } from "./gsd-db.js";
|
|
208
|
+
import { markLatestActiveForWorkerCanceled } from "./db/unit-dispatches.js";
|
|
209
|
+
import { writeUnitRuntimeRecord } from "./unit-runtime.js";
|
|
203
210
|
import { countPendingCaptures } from "./captures.js";
|
|
204
211
|
import { CMUX_CHANNELS, type CmuxLogLevel } from "../shared/cmux-events.js";
|
|
205
212
|
import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
|
|
@@ -227,21 +234,41 @@ import { bootstrapAutoSession, openProjectDbIfPresent, type BootstrapDeps } from
|
|
|
227
234
|
import { initHealthWidget } from "./health-widget.js";
|
|
228
235
|
import { runLegacyAutoLoop, runUokKernelLoop } from "./auto/loop.js";
|
|
229
236
|
import { resolveAgentEnd, resolveAgentEndCancelled, _resetPendingResolve, isSessionSwitchInFlight } from "./auto/resolve.js";
|
|
230
|
-
import type { LoopDeps } from "./auto/loop-deps.js";
|
|
237
|
+
import type { LoopDeps, StopAutoOptions } from "./auto/loop-deps.js";
|
|
231
238
|
import type { ErrorContext } from "./auto/types.js";
|
|
232
239
|
import { runAutoLoopWithUok } from "./uok/kernel.js";
|
|
233
240
|
import { resolveUokFlags } from "./uok/flags.js";
|
|
234
241
|
import { validateDirectory } from "./validate-directory.js";
|
|
235
242
|
import { createAutoOrchestrator } from "./auto/orchestrator.js";
|
|
236
243
|
import type { AutoOrchestrationModule, AutoOrchestratorDeps } from "./auto/contracts.js";
|
|
244
|
+
import { reconcileBeforeDispatch } from "./state-reconciliation.js";
|
|
245
|
+
import { compileUnitToolContract } from "./tool-contract.js";
|
|
246
|
+
import { createWorktreeSafetyModule } from "./worktree-safety.js";
|
|
247
|
+
import { resolveManifest } from "./unit-context-manifest.js";
|
|
248
|
+
import { classifyFailure } from "./recovery-classification.js";
|
|
237
249
|
// Slice-level parallelism (#2340)
|
|
238
250
|
import { getEligibleSlices } from "./slice-parallel-eligibility.js";
|
|
239
251
|
import { startSliceParallel } from "./slice-parallel-orchestrator.js";
|
|
240
252
|
import {
|
|
241
|
-
|
|
242
|
-
type
|
|
243
|
-
} from "./worktree-
|
|
253
|
+
WorktreeLifecycle,
|
|
254
|
+
type WorktreeLifecycleDeps,
|
|
255
|
+
} from "./worktree-lifecycle.js";
|
|
256
|
+
import { WorktreeStateProjection } from "./worktree-state-projection.js";
|
|
244
257
|
import { reorderForCaching } from "./prompt-ordering.js";
|
|
258
|
+
import { initTokenCounter } from "./token-counter.js";
|
|
259
|
+
|
|
260
|
+
// Warm the tiktoken encoder at extension startup so context-budget computations
|
|
261
|
+
// can use accurate token counts via countTokensSync without paying the load
|
|
262
|
+
// cost mid-prompt-build. Fire-and-forget — failure falls back to the
|
|
263
|
+
// provider-aware char-ratio estimator already used by getCharsPerToken().
|
|
264
|
+
// Catch rejections explicitly: an unhandled rejection at module-import time
|
|
265
|
+
// can destabilize startup before the engine logger is configured.
|
|
266
|
+
void initTokenCounter().catch((err) => {
|
|
267
|
+
logWarning(
|
|
268
|
+
"engine",
|
|
269
|
+
`token counter warm-up failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
270
|
+
);
|
|
271
|
+
});
|
|
245
272
|
|
|
246
273
|
// ─── Session State ─────────────────────────────────────────────────────────
|
|
247
274
|
|
|
@@ -293,11 +320,15 @@ const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
|
|
|
293
320
|
* the DB is unavailable (e.g. fresh project before init) we skip registration
|
|
294
321
|
* silently rather than blocking session start.
|
|
295
322
|
*/
|
|
296
|
-
function registerAutoWorkerForSession(
|
|
323
|
+
function registerAutoWorkerForSession(
|
|
324
|
+
session: AutoSession,
|
|
325
|
+
projectRootOverride?: string,
|
|
326
|
+
): void {
|
|
297
327
|
if (session.workerId) return; // already registered (e.g. resume re-runs)
|
|
298
328
|
try {
|
|
299
329
|
const projectRootRealpath = normalizeRealPath(
|
|
300
|
-
|
|
330
|
+
projectRootOverride
|
|
331
|
+
?? session.scope?.workspace.projectRoot
|
|
301
332
|
?? (session.originalBasePath || session.basePath),
|
|
302
333
|
);
|
|
303
334
|
session.workerId = registerAutoWorker({ projectRootRealpath });
|
|
@@ -332,6 +363,14 @@ function restoreProjectRootEnv(): void {
|
|
|
332
363
|
s.projectRootEnvCaptured = false;
|
|
333
364
|
}
|
|
334
365
|
|
|
366
|
+
export function _captureProjectRootEnvForTest(projectRoot: string): void {
|
|
367
|
+
captureProjectRootEnv(projectRoot);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function _restoreProjectRootEnvForTest(): void {
|
|
371
|
+
restoreProjectRootEnv();
|
|
372
|
+
}
|
|
373
|
+
|
|
335
374
|
function captureMilestoneLockEnv(milestoneId: string | null): void {
|
|
336
375
|
if (!s.milestoneLockEnvCaptured) {
|
|
337
376
|
s.hadMilestoneLockEnv = Object.prototype.hasOwnProperty.call(process.env, "GSD_MILESTONE_LOCK");
|
|
@@ -420,6 +459,11 @@ export function _synthesizePausedSessionRecoveryForTest(
|
|
|
420
459
|
return synthesizePausedSessionRecovery(basePath, unitType, unitId, sessionFile);
|
|
421
460
|
}
|
|
422
461
|
|
|
462
|
+
// `_resolvePausedResumeBasePathForTest` was retired in ADR-016 phase 2 / B3
|
|
463
|
+
// (#5621). Production callers go through
|
|
464
|
+
// `WorktreeLifecycle.resumeFromPausedSession`; the pure helper for tests is
|
|
465
|
+
// `resolvePausedResumeBasePath` exported from `worktree-lifecycle.ts`.
|
|
466
|
+
|
|
423
467
|
const DETACHED_AUTO_KEEPALIVE_INTERVAL_MS = 30_000;
|
|
424
468
|
|
|
425
469
|
function withDetachedAutoKeepalive<T>(run: Promise<T>): Promise<T> {
|
|
@@ -501,9 +545,54 @@ export {
|
|
|
501
545
|
getBudgetEnforcementAction,
|
|
502
546
|
} from "./auto-budget.js";
|
|
503
547
|
|
|
548
|
+
function closeOutSignalInterruptedUnit(currentBasePath: string): void {
|
|
549
|
+
const currentUnit = s.currentUnit;
|
|
550
|
+
if (!currentUnit) return;
|
|
551
|
+
|
|
552
|
+
const reason = "Auto-mode process received a termination signal";
|
|
553
|
+
const errorContext: ErrorContext = {
|
|
554
|
+
message: reason,
|
|
555
|
+
category: "aborted",
|
|
556
|
+
isTransient: false,
|
|
557
|
+
};
|
|
558
|
+
const basePath = s.basePath || currentBasePath;
|
|
559
|
+
|
|
560
|
+
try {
|
|
561
|
+
emitOpenUnitEndForUnit(basePath, currentUnit.type, currentUnit.id, "cancelled", errorContext);
|
|
562
|
+
} catch (err) {
|
|
563
|
+
logWarning("engine", `signal unit-end cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
try {
|
|
567
|
+
writeUnitRuntimeRecord(basePath, currentUnit.type, currentUnit.id, currentUnit.startedAt, {
|
|
568
|
+
phase: "crashed",
|
|
569
|
+
lastProgressAt: Date.now(),
|
|
570
|
+
lastProgressKind: "signal",
|
|
571
|
+
});
|
|
572
|
+
} catch (err) {
|
|
573
|
+
logWarning("engine", `signal runtime cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
try {
|
|
577
|
+
if (s.workerId) markLatestActiveForWorkerCanceled(s.workerId, "signal-exit");
|
|
578
|
+
} catch (err) {
|
|
579
|
+
logWarning("engine", `signal dispatch cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
resolveAgentEndCancelled(errorContext);
|
|
584
|
+
} catch (err) {
|
|
585
|
+
logWarning("engine", `signal resolve cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
504
589
|
/** Wrapper: register SIGTERM handler and store reference. */
|
|
505
590
|
function registerSigtermHandler(currentBasePath: string): void {
|
|
506
|
-
s.sigtermHandler = _registerSigtermHandler(
|
|
591
|
+
s.sigtermHandler = _registerSigtermHandler(
|
|
592
|
+
currentBasePath,
|
|
593
|
+
s.sigtermHandler,
|
|
594
|
+
() => closeOutSignalInterruptedUnit(currentBasePath),
|
|
595
|
+
);
|
|
507
596
|
}
|
|
508
597
|
|
|
509
598
|
/** Wrapper: deregister SIGTERM handler and clear reference. */
|
|
@@ -577,6 +666,10 @@ export function isAutoActive(): boolean {
|
|
|
577
666
|
return s.active;
|
|
578
667
|
}
|
|
579
668
|
|
|
669
|
+
export function isAutoCompletionStopInProgress(): boolean {
|
|
670
|
+
return s.completionStopInProgress;
|
|
671
|
+
}
|
|
672
|
+
|
|
580
673
|
/** Test-only seam for validating auto-mode guards (#4704). Do not use in production code. */
|
|
581
674
|
export function _setAutoActiveForTest(active: boolean): void {
|
|
582
675
|
s.active = active;
|
|
@@ -606,6 +699,30 @@ export function isAutoPaused(): boolean {
|
|
|
606
699
|
return s.paused;
|
|
607
700
|
}
|
|
608
701
|
|
|
702
|
+
export interface ResumeResourceRefreshDeps {
|
|
703
|
+
env?: NodeJS.ProcessEnv;
|
|
704
|
+
importModule?: (specifier: string) => Promise<any>;
|
|
705
|
+
openProjectDb?: (basePath: string) => Promise<void>;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
export async function refreshResumeResourcesAndDb(
|
|
709
|
+
basePath: string,
|
|
710
|
+
deps: ResumeResourceRefreshDeps = {},
|
|
711
|
+
): Promise<void> {
|
|
712
|
+
const env = deps.env ?? process.env;
|
|
713
|
+
const importModule = deps.importModule ?? ((specifier: string) => import(specifier));
|
|
714
|
+
const agentDir = env.GSD_CODING_AGENT_DIR || join(gsdHome(), "agent");
|
|
715
|
+
const pkgRoot = env.GSD_PKG_ROOT;
|
|
716
|
+
const resourceLoaderPath = pkgRoot
|
|
717
|
+
? pathToFileURL(join(pkgRoot, "dist", "resource-loader.js")).href
|
|
718
|
+
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
719
|
+
const { initResources } = await importModule(resourceLoaderPath);
|
|
720
|
+
initResources(agentDir);
|
|
721
|
+
const { primeCache } = await importModule("./prompt-loader.js");
|
|
722
|
+
primeCache();
|
|
723
|
+
await (deps.openProjectDb ?? openProjectDbIfPresent)(basePath);
|
|
724
|
+
}
|
|
725
|
+
|
|
609
726
|
export function setActiveEngineId(id: string | null): void {
|
|
610
727
|
s.activeEngineId = id;
|
|
611
728
|
}
|
|
@@ -813,6 +930,31 @@ function buildSnapshotOpts(
|
|
|
813
930
|
};
|
|
814
931
|
}
|
|
815
932
|
|
|
933
|
+
function currentUnitLabel(): string | null {
|
|
934
|
+
if (!s.currentUnit) return null;
|
|
935
|
+
return `${unitVerb(s.currentUnit.type)} ${s.currentUnit.id}`;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function setLifecycleOutcome(
|
|
939
|
+
ctx: ExtensionContext | undefined,
|
|
940
|
+
input: {
|
|
941
|
+
status: "paused" | "stopped" | "blocked" | "failed" | "complete" | "waiting" | "step";
|
|
942
|
+
title: string;
|
|
943
|
+
detail?: string | null;
|
|
944
|
+
nextAction: string;
|
|
945
|
+
commands?: string[];
|
|
946
|
+
unitLabel?: string | null;
|
|
947
|
+
},
|
|
948
|
+
): void {
|
|
949
|
+
if (!ctx?.hasUI) return;
|
|
950
|
+
const { unitLabel: unitLabelOverride, ...rest } = input;
|
|
951
|
+
setAutoOutcomeWidget(ctx, {
|
|
952
|
+
...rest,
|
|
953
|
+
unitLabel: unitLabelOverride !== undefined ? unitLabelOverride : currentUnitLabel(),
|
|
954
|
+
startedAt: s.autoStartTime,
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
|
|
816
958
|
function handleLostSessionLock(
|
|
817
959
|
ctx?: ExtensionContext,
|
|
818
960
|
lockStatus?: SessionLockStatus,
|
|
@@ -860,7 +1002,23 @@ function handleLostSessionLock(
|
|
|
860
1002
|
* the stale unit state, progress widget, status badge, and restores CWD so
|
|
861
1003
|
* the dashboard does not show an orphaned timer and the shell is usable.
|
|
862
1004
|
*/
|
|
863
|
-
function
|
|
1005
|
+
export async function rerootCommandSession(
|
|
1006
|
+
cmdCtx: Pick<ExtensionCommandContext, "newSession"> | null | undefined,
|
|
1007
|
+
workspaceRoot: string,
|
|
1008
|
+
): Promise<{ status: "skipped" | "ok" | "cancelled" | "failed"; error?: string }> {
|
|
1009
|
+
if (!cmdCtx || !workspaceRoot) return { status: "skipped" };
|
|
1010
|
+
try {
|
|
1011
|
+
const result = await cmdCtx.newSession({ workspaceRoot });
|
|
1012
|
+
return result.cancelled ? { status: "cancelled" } : { status: "ok" };
|
|
1013
|
+
} catch (err) {
|
|
1014
|
+
return {
|
|
1015
|
+
status: "failed",
|
|
1016
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
export async function cleanupAfterLoopExit(ctx: ExtensionContext): Promise<void> {
|
|
864
1022
|
s.currentUnit = null;
|
|
865
1023
|
s.active = false;
|
|
866
1024
|
deactivateGSD();
|
|
@@ -884,35 +1042,132 @@ function cleanupAfterLoopExit(ctx: ExtensionContext): void {
|
|
|
884
1042
|
// visible so the user still has a resumable auto-mode signal on screen.
|
|
885
1043
|
if (!s.paused) {
|
|
886
1044
|
ctx.ui.setStatus("gsd-auto", undefined);
|
|
887
|
-
|
|
1045
|
+
if (s.completionStopInProgress) {
|
|
1046
|
+
s.completionStopInProgress = false;
|
|
1047
|
+
}
|
|
888
1048
|
initHealthWidget(ctx);
|
|
889
1049
|
}
|
|
890
1050
|
|
|
891
|
-
//
|
|
1051
|
+
// ADR-016 phase 3 (#5693): the stop-path basePath restore routes through
|
|
1052
|
+
// `Lifecycle.restoreToProjectRoot()`, the sole owner of `s.basePath`
|
|
1053
|
+
// mutation. The verb assigns `s.basePath` before any throwable work
|
|
1054
|
+
// (rebuildGitService, cache invalidation), so a thrown error still leaves
|
|
1055
|
+
// basePath restored — no fallback assignment needed at the call site.
|
|
1056
|
+
// The chdir stays here because `restoreToProjectRoot` is a pure
|
|
1057
|
+
// session-state mutation.
|
|
892
1058
|
if (s.originalBasePath) {
|
|
893
|
-
s.basePath = s.originalBasePath;
|
|
894
1059
|
try {
|
|
895
|
-
|
|
1060
|
+
buildLifecycle().restoreToProjectRoot();
|
|
896
1061
|
} catch (err) {
|
|
897
|
-
|
|
898
|
-
|
|
1062
|
+
logWarning(
|
|
1063
|
+
"engine",
|
|
1064
|
+
`restore project root failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
1065
|
+
{ file: "auto.ts" },
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
try {
|
|
1069
|
+
process.chdir(s.originalBasePath);
|
|
1070
|
+
} catch (err) {
|
|
1071
|
+
logWarning("engine", `basePath restore/chdir failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
899
1072
|
}
|
|
900
1073
|
}
|
|
1074
|
+
|
|
1075
|
+
if (s.originalBasePath && s.cmdCtx) {
|
|
1076
|
+
const result = await rerootCommandSession(s.cmdCtx, s.originalBasePath);
|
|
1077
|
+
if (result.status === "cancelled") {
|
|
1078
|
+
logWarning("engine", "post-loop session re-root was cancelled", { file: "auto.ts", basePath: s.originalBasePath });
|
|
1079
|
+
} else if (result.status === "failed") {
|
|
1080
|
+
logWarning("engine", `post-loop session re-root failed: ${result.error ?? "unknown"}`, { file: "auto.ts", basePath: s.originalBasePath });
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export function _cleanupAfterLoopExitForTest(ctx: ExtensionContext): Promise<void> {
|
|
1086
|
+
return cleanupAfterLoopExit(ctx);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
export type AutoWorktreeExitAction = "skip" | "merge" | "preserve";
|
|
1090
|
+
|
|
1091
|
+
interface MilestoneCompletionRollup {
|
|
1092
|
+
milestoneTitle?: string;
|
|
1093
|
+
oneLiner?: string;
|
|
1094
|
+
successCriteriaResults?: string;
|
|
1095
|
+
definitionOfDoneResults?: string;
|
|
1096
|
+
requirementOutcomes?: string;
|
|
1097
|
+
deviations?: string;
|
|
1098
|
+
followUps?: string;
|
|
1099
|
+
keyDecisions?: string[];
|
|
1100
|
+
keyFiles?: string[];
|
|
1101
|
+
lessonsLearned?: string[];
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
function normalizeFrontmatterList(value: unknown): string[] {
|
|
1105
|
+
if (!Array.isArray(value)) return [];
|
|
1106
|
+
return value
|
|
1107
|
+
.map(item => typeof item === "string" ? item.trim() : "")
|
|
1108
|
+
.filter(item => item.length > 0 && item !== "(none)");
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function firstBoldParagraph(body: string): string | undefined {
|
|
1112
|
+
const match = body.match(/\*\*([^*\n][\s\S]*?)\*\*/);
|
|
1113
|
+
return match?.[1]?.replace(/\s+/g, " ").trim() || undefined;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function loadMilestoneCompletionRollup(basePath: string, milestoneId: string | null | undefined): MilestoneCompletionRollup {
|
|
1117
|
+
if (!milestoneId) return {};
|
|
1118
|
+
const summaryPath = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
|
|
1119
|
+
if (!summaryPath || !existsSync(summaryPath)) return {};
|
|
1120
|
+
|
|
1121
|
+
try {
|
|
1122
|
+
const raw = readFileSync(summaryPath, "utf-8");
|
|
1123
|
+
const [frontmatterLines, body] = splitFrontmatter(raw);
|
|
1124
|
+
const frontmatter = frontmatterLines ? parseFrontmatterMap(frontmatterLines) : {};
|
|
1125
|
+
return {
|
|
1126
|
+
milestoneTitle: typeof frontmatter.title === "string" ? frontmatter.title : undefined,
|
|
1127
|
+
oneLiner: firstBoldParagraph(body),
|
|
1128
|
+
successCriteriaResults: extractSection(body, "Success Criteria Results") ?? undefined,
|
|
1129
|
+
definitionOfDoneResults: extractSection(body, "Definition of Done Results") ?? undefined,
|
|
1130
|
+
requirementOutcomes: extractSection(body, "Requirement Outcomes") ?? undefined,
|
|
1131
|
+
deviations: extractSection(body, "Deviations") ?? undefined,
|
|
1132
|
+
followUps: extractSection(body, "Follow-ups") ?? undefined,
|
|
1133
|
+
keyDecisions: normalizeFrontmatterList(frontmatter.key_decisions),
|
|
1134
|
+
keyFiles: normalizeFrontmatterList(frontmatter.key_files),
|
|
1135
|
+
lessonsLearned: normalizeFrontmatterList(frontmatter.lessons_learned),
|
|
1136
|
+
};
|
|
1137
|
+
} catch (err) {
|
|
1138
|
+
logWarning("dashboard", `completion roll-up summary read failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1139
|
+
return {};
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
export function _resolveAutoWorktreeExitActionForTest(
|
|
1144
|
+
currentMilestoneId: string | null | undefined,
|
|
1145
|
+
milestoneMergedInPhases: boolean,
|
|
1146
|
+
milestoneComplete: boolean,
|
|
1147
|
+
): AutoWorktreeExitAction {
|
|
1148
|
+
const action = _selectStopAutoWorktreeExit({
|
|
1149
|
+
currentMilestoneId: currentMilestoneId ?? null,
|
|
1150
|
+
milestoneComplete,
|
|
1151
|
+
milestoneMergedInPhases,
|
|
1152
|
+
});
|
|
1153
|
+
return action === "none" ? "skip" : action;
|
|
901
1154
|
}
|
|
902
1155
|
|
|
903
1156
|
export async function stopAuto(
|
|
904
1157
|
ctx?: ExtensionContext,
|
|
905
1158
|
pi?: ExtensionAPI,
|
|
906
1159
|
reason?: string,
|
|
1160
|
+
options: StopAutoOptions = {},
|
|
907
1161
|
): Promise<void> {
|
|
908
1162
|
if (!s.active && !s.paused) return;
|
|
909
1163
|
const loadedPreferences = loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences;
|
|
910
1164
|
const reasonSuffix = reason ? ` — ${reason}` : "";
|
|
1165
|
+
const preserveCompletionSurface = Boolean(options.completionWidget);
|
|
1166
|
+
s.completionStopInProgress = preserveCompletionSurface;
|
|
911
1167
|
|
|
912
|
-
// #4764 — telemetry: record the exit reason
|
|
913
|
-
// was
|
|
914
|
-
//
|
|
915
|
-
// is exactly the pattern that strands work.
|
|
1168
|
+
// #4764 — telemetry: record the exit reason, isolation mode, whether an auto
|
|
1169
|
+
// worktree was active, and whether the current milestone was merged before
|
|
1170
|
+
// stopAuto. The unmerged-work warning is only meaningful for real worktrees.
|
|
916
1171
|
try {
|
|
917
1172
|
const { emitAutoExit } = await import("./worktree-telemetry.js");
|
|
918
1173
|
type AutoExitReason =
|
|
@@ -937,10 +1192,13 @@ export async function stopAuto(
|
|
|
937
1192
|
: rawReason === "stop" || rawReason === "pause"
|
|
938
1193
|
? rawReason
|
|
939
1194
|
: "other";
|
|
940
|
-
|
|
1195
|
+
const telemetryBase = s.originalBasePath || s.basePath;
|
|
1196
|
+
emitAutoExit(telemetryBase, {
|
|
941
1197
|
reason: normalizedReason,
|
|
942
1198
|
milestoneId: s.currentMilestoneId ?? undefined,
|
|
943
1199
|
milestoneMerged: s.milestoneMergedInPhases === true,
|
|
1200
|
+
isolationMode: getIsolationMode(telemetryBase),
|
|
1201
|
+
worktreeActive: isInAutoWorktree(s.basePath),
|
|
944
1202
|
});
|
|
945
1203
|
} catch (err) {
|
|
946
1204
|
logWarning("engine", `auto-exit telemetry failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -968,6 +1226,8 @@ export async function stopAuto(
|
|
|
968
1226
|
if (s.workerId) {
|
|
969
1227
|
markWorkerStopping(s.workerId);
|
|
970
1228
|
}
|
|
1229
|
+
s.workerId = null;
|
|
1230
|
+
s.milestoneLeaseToken = null;
|
|
971
1231
|
} catch (e) {
|
|
972
1232
|
debugLog("stop-cleanup-coordination", { error: e instanceof Error ? e.message : String(e) });
|
|
973
1233
|
}
|
|
@@ -1011,7 +1271,7 @@ export async function stopAuto(
|
|
|
1011
1271
|
const notifyCtx = ctx
|
|
1012
1272
|
? { notify: ctx.ui.notify.bind(ctx.ui) }
|
|
1013
1273
|
: { notify: () => {} };
|
|
1014
|
-
const
|
|
1274
|
+
const lifecycle = buildLifecycle();
|
|
1015
1275
|
|
|
1016
1276
|
// Check if the milestone is complete. DB status is the authoritative
|
|
1017
1277
|
// signal — only a successful gsd_complete_milestone call flips it to
|
|
@@ -1049,17 +1309,35 @@ export async function stopAuto(
|
|
|
1049
1309
|
logWarning("engine", `milestone summary check failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
1050
1310
|
}
|
|
1051
1311
|
|
|
1052
|
-
|
|
1312
|
+
const exitAction = _selectStopAutoWorktreeExit({
|
|
1313
|
+
currentMilestoneId: s.currentMilestoneId,
|
|
1314
|
+
milestoneComplete,
|
|
1315
|
+
milestoneMergedInPhases: s.milestoneMergedInPhases,
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
if (exitAction === "merge") {
|
|
1053
1319
|
// Milestone is complete — merge worktree branch back to main
|
|
1054
|
-
|
|
1055
|
-
|
|
1320
|
+
const r = lifecycle.exitMilestone(
|
|
1321
|
+
s.currentMilestoneId,
|
|
1322
|
+
{ merge: true },
|
|
1323
|
+
notifyCtx,
|
|
1324
|
+
);
|
|
1325
|
+
if (!r.ok && r.cause instanceof Error) throw r.cause;
|
|
1326
|
+
} else if (exitAction === "preserve") {
|
|
1056
1327
|
// Milestone still in progress — preserve branch for later resumption
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1328
|
+
const r = lifecycle.exitMilestone(
|
|
1329
|
+
s.currentMilestoneId,
|
|
1330
|
+
{ merge: false, preserveBranch: true },
|
|
1331
|
+
notifyCtx,
|
|
1332
|
+
);
|
|
1333
|
+
if (!r.ok && r.cause instanceof Error) throw r.cause;
|
|
1060
1334
|
}
|
|
1061
1335
|
}
|
|
1062
1336
|
} catch (e) {
|
|
1337
|
+
ctx?.ui.notify(
|
|
1338
|
+
`Worktree cleanup failed for ${s.currentMilestoneId ?? "current milestone"}: ${e instanceof Error ? e.message : String(e)}. Resolve the preserved branch/worktree and run /gsd auto to resume.`,
|
|
1339
|
+
"warning",
|
|
1340
|
+
);
|
|
1063
1341
|
debugLog("stop-cleanup-worktree", { error: e instanceof Error ? e.message : String(e) });
|
|
1064
1342
|
}
|
|
1065
1343
|
|
|
@@ -1078,6 +1356,21 @@ export async function stopAuto(
|
|
|
1078
1356
|
}
|
|
1079
1357
|
}
|
|
1080
1358
|
|
|
1359
|
+
// Pre-compute completion widget slice counts while the DB is still open.
|
|
1360
|
+
// Step 8 runs after closeDatabase(), so DB-backed slice lookups must happen here.
|
|
1361
|
+
const completionMilestoneId = options.completionWidget?.milestoneId ?? s.currentMilestoneId;
|
|
1362
|
+
let completedSlices: number | null = null;
|
|
1363
|
+
let totalSlices: number | null = null;
|
|
1364
|
+
if (preserveCompletionSurface && options.completionWidget && completionMilestoneId && isDbAvailable()) {
|
|
1365
|
+
try {
|
|
1366
|
+
const slices = getMilestoneSlices(completionMilestoneId);
|
|
1367
|
+
completedSlices = slices.filter(slice => isClosedStatus(slice.status)).length;
|
|
1368
|
+
totalSlices = slices.length;
|
|
1369
|
+
} catch (err) {
|
|
1370
|
+
logWarning("dashboard", `completion slice stats lookup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1081
1374
|
// ── Step 6: DB cleanup ──
|
|
1082
1375
|
if (isDbAvailable()) {
|
|
1083
1376
|
try {
|
|
@@ -1090,37 +1383,113 @@ export async function stopAuto(
|
|
|
1090
1383
|
}
|
|
1091
1384
|
}
|
|
1092
1385
|
|
|
1093
|
-
// ── Step 7: Restore basePath and chdir ──
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1386
|
+
// ── Step 7: Restore basePath and chdir (ADR-016 phase 3, #5693) ──
|
|
1387
|
+
// `restoreToProjectRoot` assigns s.basePath before any throwable work;
|
|
1388
|
+
// no fallback assignment is needed at the call site.
|
|
1389
|
+
if (s.originalBasePath) {
|
|
1390
|
+
try {
|
|
1391
|
+
buildLifecycle().restoreToProjectRoot();
|
|
1392
|
+
} catch (e) {
|
|
1393
|
+
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
1394
|
+
}
|
|
1395
|
+
try {
|
|
1396
|
+
process.chdir(s.basePath);
|
|
1397
|
+
} catch (err) {
|
|
1398
|
+
/* best-effort */
|
|
1399
|
+
logWarning("engine", `chdir failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// Re-root the active command session/tool runtime after worktree teardown.
|
|
1404
|
+
// mergeAndExit restores process.cwd(), but AgentSession has already captured
|
|
1405
|
+
// its own cwd for tools and system prompt; refresh it before returning to the
|
|
1406
|
+
// user so follow-up commands do not target a removed milestone worktree.
|
|
1407
|
+
if (s.originalBasePath && ctx && s.cmdCtx) {
|
|
1408
|
+
const result = await rerootCommandSession(s.cmdCtx, s.originalBasePath);
|
|
1409
|
+
if (result.status === "cancelled") {
|
|
1410
|
+
logWarning("engine", "post-stop session re-root was cancelled", { file: "auto.ts", basePath: s.originalBasePath });
|
|
1411
|
+
} else if (result.status === "failed") {
|
|
1412
|
+
logWarning("engine", `post-stop session re-root failed: ${result.error ?? "unknown"}`, { file: "auto.ts", basePath: s.originalBasePath });
|
|
1103
1413
|
}
|
|
1104
|
-
} catch (e) {
|
|
1105
|
-
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
1106
1414
|
}
|
|
1107
1415
|
|
|
1108
1416
|
// ── Step 8: Ledger notification ──
|
|
1109
1417
|
try {
|
|
1110
1418
|
const ledger = getLedger();
|
|
1419
|
+
const isAllComplete = reason === "All milestones complete";
|
|
1420
|
+
const isMilestoneComplete = /^Milestone\s+\S+\s+complete$/i.test(reason ?? "");
|
|
1421
|
+
const notificationPrefix = isAllComplete
|
|
1422
|
+
? "All milestones complete"
|
|
1423
|
+
: isMilestoneComplete
|
|
1424
|
+
? `${reason}. Auto-mode finished this milestone`
|
|
1425
|
+
: `Auto-mode stopped${reasonSuffix}`;
|
|
1111
1426
|
if (ledger && ledger.units.length > 0) {
|
|
1112
1427
|
const totals = getProjectTotals(ledger.units);
|
|
1113
1428
|
ctx?.ui.notify(
|
|
1114
|
-
|
|
1429
|
+
`${notificationPrefix}. Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${ledger.units.length} units`,
|
|
1115
1430
|
"info",
|
|
1116
1431
|
);
|
|
1117
1432
|
} else {
|
|
1118
|
-
ctx?.ui.notify(
|
|
1433
|
+
ctx?.ui.notify(`${notificationPrefix}.`, "info");
|
|
1119
1434
|
}
|
|
1120
1435
|
} catch (e) {
|
|
1121
1436
|
debugLog("stop-cleanup-ledger", { error: e instanceof Error ? e.message : String(e) });
|
|
1122
1437
|
}
|
|
1123
1438
|
|
|
1439
|
+
if (preserveCompletionSurface && ctx && options.completionWidget) {
|
|
1440
|
+
const ledger = getLedger();
|
|
1441
|
+
const units = ledger?.units ?? [];
|
|
1442
|
+
const totals = units.length > 0 ? getProjectTotals(units) : null;
|
|
1443
|
+
let totalInput = 0;
|
|
1444
|
+
let totalCacheRead = 0;
|
|
1445
|
+
try {
|
|
1446
|
+
for (const entry of s.cmdCtx?.sessionManager?.getEntries?.() ?? []) {
|
|
1447
|
+
if (entry.type === "message") {
|
|
1448
|
+
const msgEntry = entry as SessionMessageEntry;
|
|
1449
|
+
if (msgEntry.message?.role === "assistant") {
|
|
1450
|
+
const usage = (msgEntry.message as any).usage;
|
|
1451
|
+
if (usage) {
|
|
1452
|
+
totalInput += usage.input || 0;
|
|
1453
|
+
totalCacheRead += usage.cacheRead || 0;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
} catch (err) {
|
|
1459
|
+
logWarning("dashboard", `completion stats lookup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1460
|
+
}
|
|
1461
|
+
const contextUsage = s.cmdCtx?.getContextUsage?.();
|
|
1462
|
+
const milestoneId = completionMilestoneId;
|
|
1463
|
+
const rollup = loadMilestoneCompletionRollup(s.originalBasePath || s.basePath, milestoneId);
|
|
1464
|
+
setCompletionProgressWidget(ctx, {
|
|
1465
|
+
milestoneId,
|
|
1466
|
+
milestoneTitle: options.completionWidget.milestoneTitle ?? rollup.milestoneTitle,
|
|
1467
|
+
oneLiner: rollup.oneLiner,
|
|
1468
|
+
successCriteriaResults: rollup.successCriteriaResults,
|
|
1469
|
+
definitionOfDoneResults: rollup.definitionOfDoneResults,
|
|
1470
|
+
requirementOutcomes: rollup.requirementOutcomes,
|
|
1471
|
+
deviations: rollup.deviations,
|
|
1472
|
+
followUps: rollup.followUps,
|
|
1473
|
+
keyDecisions: rollup.keyDecisions,
|
|
1474
|
+
keyFiles: rollup.keyFiles,
|
|
1475
|
+
lessonsLearned: rollup.lessonsLearned,
|
|
1476
|
+
reason: reason ?? "Milestone complete",
|
|
1477
|
+
startedAt: s.autoStartTime,
|
|
1478
|
+
totalCost: totals?.cost ?? 0,
|
|
1479
|
+
totalTokens: totals?.tokens.total ?? 0,
|
|
1480
|
+
unitCount: units.length,
|
|
1481
|
+
cacheHitRate: totalCacheRead + totalInput > 0
|
|
1482
|
+
? (totalCacheRead / (totalCacheRead + totalInput)) * 100
|
|
1483
|
+
: null,
|
|
1484
|
+
contextPercent: contextUsage?.percent ?? null,
|
|
1485
|
+
contextWindow: contextUsage?.contextWindow ?? s.cmdCtx?.model?.contextWindow ?? null,
|
|
1486
|
+
completedSlices,
|
|
1487
|
+
totalSlices,
|
|
1488
|
+
allMilestonesComplete: options.completionWidget.allMilestonesComplete,
|
|
1489
|
+
basePath: s.originalBasePath || s.basePath || null,
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1124
1493
|
// ── Step 9: Cmux sidebar / event log ──
|
|
1125
1494
|
try {
|
|
1126
1495
|
pi?.events.emit(CMUX_CHANNELS.SIDEBAR, { action: "clear" as const, preferences: loadedPreferences });
|
|
@@ -1211,8 +1580,20 @@ export async function stopAuto(
|
|
|
1211
1580
|
|
|
1212
1581
|
// UI cleanup
|
|
1213
1582
|
ctx?.ui.setStatus("gsd-auto", undefined);
|
|
1214
|
-
|
|
1215
|
-
|
|
1583
|
+
if (!preserveCompletionSurface) {
|
|
1584
|
+
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
1585
|
+
const status = reason?.startsWith("Blocked:") ? "blocked" : reason?.toLowerCase().includes("fail") ? "failed" : "stopped";
|
|
1586
|
+
setLifecycleOutcome(ctx, {
|
|
1587
|
+
status,
|
|
1588
|
+
title: status === "blocked" ? "Auto-mode blocked" : status === "failed" ? "Auto-mode stopped with an issue" : "Auto-mode stopped",
|
|
1589
|
+
detail: reason ?? "Auto-mode stopped.",
|
|
1590
|
+
nextAction: status === "blocked"
|
|
1591
|
+
? "Fix the blocker, then run /gsd auto to resume."
|
|
1592
|
+
: "Run /gsd status for the current project state, or /gsd auto to continue.",
|
|
1593
|
+
commands: ["/gsd status for overview", "/gsd auto to run", "/gsd visualize to inspect", "/gsd notifications for history"],
|
|
1594
|
+
});
|
|
1595
|
+
if (ctx) initHealthWidget(ctx);
|
|
1596
|
+
}
|
|
1216
1597
|
restoreProjectRootEnv();
|
|
1217
1598
|
restoreMilestoneLockEnv();
|
|
1218
1599
|
|
|
@@ -1229,10 +1610,21 @@ export async function stopAuto(
|
|
|
1229
1610
|
}
|
|
1230
1611
|
|
|
1231
1612
|
// Reset all session state in one call
|
|
1232
|
-
s.
|
|
1613
|
+
s.resetAfterStop({ preserveCompletionSurface });
|
|
1233
1614
|
}
|
|
1234
1615
|
}
|
|
1235
1616
|
|
|
1617
|
+
export type StopAutoWorktreeExitAction = "none" | "merge" | "preserve";
|
|
1618
|
+
|
|
1619
|
+
export function _selectStopAutoWorktreeExit(args: {
|
|
1620
|
+
currentMilestoneId: string | null;
|
|
1621
|
+
milestoneComplete: boolean;
|
|
1622
|
+
milestoneMergedInPhases: boolean;
|
|
1623
|
+
}): StopAutoWorktreeExitAction {
|
|
1624
|
+
if (!args.currentMilestoneId || args.milestoneMergedInPhases) return "none";
|
|
1625
|
+
return args.milestoneComplete ? "merge" : "preserve";
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1236
1628
|
/**
|
|
1237
1629
|
* Pause auto-mode without destroying state. Context is preserved.
|
|
1238
1630
|
* The user can interact with the agent, then `/gsd auto` resumes
|
|
@@ -1292,6 +1684,8 @@ export async function pauseAuto(
|
|
|
1292
1684
|
logWarning("engine", `paused-session DB write failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
1293
1685
|
}
|
|
1294
1686
|
|
|
1687
|
+
const pausedUnitLabel = currentUnitLabel();
|
|
1688
|
+
|
|
1295
1689
|
// Close out the current unit so its runtime record doesn't stay at "dispatched"
|
|
1296
1690
|
if (s.currentUnit && ctx) {
|
|
1297
1691
|
try {
|
|
@@ -1342,8 +1736,16 @@ export async function pauseAuto(
|
|
|
1342
1736
|
s.verificationRetryCount.clear();
|
|
1343
1737
|
ctx?.ui.setStatus("gsd-auto", "paused");
|
|
1344
1738
|
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
1345
|
-
if (ctx) initHealthWidget(ctx);
|
|
1346
1739
|
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
1740
|
+
setLifecycleOutcome(ctx, {
|
|
1741
|
+
status: "paused",
|
|
1742
|
+
title: `${s.stepMode ? "Step" : "Auto"}-mode paused`,
|
|
1743
|
+
detail: _errorContext?.message ?? "Paused by user request.",
|
|
1744
|
+
nextAction: `Type to steer, or run ${resumeCmd} to resume.`,
|
|
1745
|
+
commands: [resumeCmd, "/gsd status for overview", "/gsd notifications for history"],
|
|
1746
|
+
unitLabel: pausedUnitLabel,
|
|
1747
|
+
});
|
|
1748
|
+
if (ctx) initHealthWidget(ctx);
|
|
1347
1749
|
ctx?.ui.notify(
|
|
1348
1750
|
`${s.stepMode ? "Step" : "Auto"}-mode paused (Escape). Type to interact, or ${resumeCmd} to resume.`,
|
|
1349
1751
|
"info",
|
|
@@ -1351,43 +1753,43 @@ export async function pauseAuto(
|
|
|
1351
1753
|
}
|
|
1352
1754
|
|
|
1353
1755
|
/**
|
|
1354
|
-
* Build a
|
|
1355
|
-
*
|
|
1756
|
+
* Build a WorktreeLifecycle Module wrapping the current session.
|
|
1757
|
+
*
|
|
1758
|
+
* Per ADR-016, the Lifecycle Module is the typed-Interface owner of milestone
|
|
1759
|
+
* entry/exit/merge verbs and calls Projection on lifecycle transitions. The
|
|
1760
|
+
* deps bag is intentionally focused — Lifecycle does not see the wider auto-
|
|
1761
|
+
* mode dependency graph.
|
|
1762
|
+
*/
|
|
1763
|
+
/**
|
|
1764
|
+
* Construct a `WorktreeLifecycleDeps` bag without binding to any session.
|
|
1765
|
+
*
|
|
1766
|
+
* Exported so session-less callers (currently `parallel-merge.ts`) can build
|
|
1767
|
+
* the same deps and call `mergeMilestoneStandalone` through the Worktree
|
|
1768
|
+
* Lifecycle Module instead of bypassing it (ADR-016 phase 2 / A2).
|
|
1356
1769
|
*/
|
|
1357
|
-
function
|
|
1770
|
+
export function buildWorktreeLifecycleDeps(): WorktreeLifecycleDeps {
|
|
1771
|
+
// ADR-016 phase 2 / C-track close-out:
|
|
1772
|
+
// C1 (#5624) — fs + git-CLI primitives inlined
|
|
1773
|
+
// C2 (#5625) — worktree-manager helpers inlined
|
|
1774
|
+
// C3 (#5626) — cache + preferences + paths inlined
|
|
1775
|
+
// C4 (#5627) — GitServiceImpl constructor → gitServiceFactory
|
|
1776
|
+
//
|
|
1777
|
+
// Final WorktreeLifecycleDeps shape: 3 fields (gitServiceFactory,
|
|
1778
|
+
// worktreeProjection, mergeMilestoneToMain). Down from 18 at slice-7
|
|
1779
|
+
// closure.
|
|
1358
1780
|
return {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1781
|
+
gitServiceFactory: (basePath: string) => {
|
|
1782
|
+
const gitConfig =
|
|
1783
|
+
loadEffectiveGSDPreferences()?.preferences?.git ?? {};
|
|
1784
|
+
return new GitServiceImpl(basePath, gitConfig);
|
|
1785
|
+
},
|
|
1786
|
+
worktreeProjection: new WorktreeStateProjection(),
|
|
1362
1787
|
mergeMilestoneToMain,
|
|
1363
|
-
syncWorktreeStateBack,
|
|
1364
|
-
teardownAutoWorktree,
|
|
1365
|
-
createAutoWorktree,
|
|
1366
|
-
enterAutoWorktree,
|
|
1367
|
-
enterBranchModeForMilestone,
|
|
1368
|
-
getAutoWorktreePath,
|
|
1369
|
-
autoCommitCurrentBranch,
|
|
1370
|
-
getCurrentBranch,
|
|
1371
|
-
autoWorktreeBranch,
|
|
1372
|
-
resolveMilestoneFile,
|
|
1373
|
-
readFileSync: (path: string, encoding: string) =>
|
|
1374
|
-
readFileSync(path, encoding as BufferEncoding),
|
|
1375
|
-
GitServiceImpl:
|
|
1376
|
-
GitServiceImpl as unknown as WorktreeResolverDeps["GitServiceImpl"],
|
|
1377
|
-
loadEffectiveGSDPreferences:
|
|
1378
|
-
loadEffectiveGSDPreferences as unknown as WorktreeResolverDeps["loadEffectiveGSDPreferences"],
|
|
1379
|
-
invalidateAllCaches,
|
|
1380
|
-
captureIntegrationBranch,
|
|
1381
1788
|
};
|
|
1382
1789
|
}
|
|
1383
1790
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
* Cheap to construct — it's just a thin wrapper over `s` + deps.
|
|
1387
|
-
* Used by stopAuto(), resume path, and buildLoopDeps().
|
|
1388
|
-
*/
|
|
1389
|
-
function buildResolver(): WorktreeResolver {
|
|
1390
|
-
return new WorktreeResolver(s, buildResolverDeps());
|
|
1791
|
+
function buildLifecycle(): WorktreeLifecycle {
|
|
1792
|
+
return new WorktreeLifecycle(s, buildWorktreeLifecycleDeps());
|
|
1391
1793
|
}
|
|
1392
1794
|
|
|
1393
1795
|
/**
|
|
@@ -1407,9 +1809,26 @@ export function createWiredAutoOrchestrationModule(
|
|
|
1407
1809
|
let seq = 0;
|
|
1408
1810
|
|
|
1409
1811
|
const deps: AutoOrchestratorDeps = {
|
|
1812
|
+
stateReconciliation: {
|
|
1813
|
+
async reconcileBeforeDispatch() {
|
|
1814
|
+
const result = await reconcileBeforeDispatch(dispatchBasePath);
|
|
1815
|
+
if (!result.ok) {
|
|
1816
|
+
return {
|
|
1817
|
+
ok: false,
|
|
1818
|
+
reason: result.reason,
|
|
1819
|
+
stateSnapshot: result.stateSnapshot,
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
return {
|
|
1823
|
+
ok: true,
|
|
1824
|
+
reason: result.repaired.join(", "),
|
|
1825
|
+
stateSnapshot: result.stateSnapshot,
|
|
1826
|
+
};
|
|
1827
|
+
},
|
|
1828
|
+
},
|
|
1410
1829
|
dispatch: {
|
|
1411
|
-
async decideNextUnit() {
|
|
1412
|
-
const state =
|
|
1830
|
+
async decideNextUnit(input) {
|
|
1831
|
+
const state = input.stateSnapshot;
|
|
1413
1832
|
const active = state.activeMilestone;
|
|
1414
1833
|
if (!active) return null;
|
|
1415
1834
|
|
|
@@ -1433,12 +1852,48 @@ export function createWiredAutoOrchestrationModule(
|
|
|
1433
1852
|
},
|
|
1434
1853
|
recovery: {
|
|
1435
1854
|
async classifyAndRecover(input) {
|
|
1436
|
-
const
|
|
1437
|
-
return { action:
|
|
1855
|
+
const recovery = classifyFailure(input);
|
|
1856
|
+
return { action: recovery.action, reason: recovery.reason };
|
|
1857
|
+
},
|
|
1858
|
+
},
|
|
1859
|
+
toolContract: {
|
|
1860
|
+
async compileUnitToolContract(unitType) {
|
|
1861
|
+
const result = compileUnitToolContract(unitType);
|
|
1862
|
+
if (!result.ok) return { ok: false, reason: result.detail };
|
|
1863
|
+
return { ok: true, reason: result.contract.validationRules.join(", ") };
|
|
1438
1864
|
},
|
|
1439
1865
|
},
|
|
1440
1866
|
worktree: {
|
|
1441
|
-
async prepareForUnit() {
|
|
1867
|
+
async prepareForUnit(unitType, unitId) {
|
|
1868
|
+
const manifest = resolveManifest(unitType);
|
|
1869
|
+
if (!manifest) {
|
|
1870
|
+
return {
|
|
1871
|
+
ok: false,
|
|
1872
|
+
reason: `No Unit manifest is registered for ${unitType}`,
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
const writeScope =
|
|
1876
|
+
manifest.tools.mode === "all" || manifest.tools.mode === "docs"
|
|
1877
|
+
? "source-writing"
|
|
1878
|
+
: "planning-only";
|
|
1879
|
+
const safety = createWorktreeSafetyModule();
|
|
1880
|
+
const snapshot = await deriveState(dispatchBasePath);
|
|
1881
|
+
const milestoneId = snapshot.activeMilestone?.id ?? null;
|
|
1882
|
+
const expectedBranch = milestoneId ? autoWorktreeBranch(milestoneId) : null;
|
|
1883
|
+
const result = safety.validateUnitRoot({
|
|
1884
|
+
unitType,
|
|
1885
|
+
unitId,
|
|
1886
|
+
writeScope,
|
|
1887
|
+
projectRoot: runtimeBasePath,
|
|
1888
|
+
unitRoot: dispatchBasePath,
|
|
1889
|
+
milestoneId,
|
|
1890
|
+
expectedBranch,
|
|
1891
|
+
});
|
|
1892
|
+
if (!result.ok) {
|
|
1893
|
+
return { ok: false, reason: `${result.kind}: ${result.reason}` };
|
|
1894
|
+
}
|
|
1895
|
+
return { ok: true, reason: result.kind };
|
|
1896
|
+
},
|
|
1442
1897
|
async syncAfterUnit() {},
|
|
1443
1898
|
async cleanupOnStop() {},
|
|
1444
1899
|
},
|
|
@@ -1536,6 +1991,7 @@ function buildLoopDeps(pi: ExtensionAPI): LoopDeps {
|
|
|
1536
1991
|
initRegistry(convertDispatchRules(DISPATCH_RULES));
|
|
1537
1992
|
|
|
1538
1993
|
const cmux = makeCmuxEmitters(pi);
|
|
1994
|
+
const worktreeProjection = new WorktreeStateProjection();
|
|
1539
1995
|
|
|
1540
1996
|
return {
|
|
1541
1997
|
lockBase,
|
|
@@ -1559,8 +2015,8 @@ function buildLoopDeps(pi: ExtensionAPI): LoopDeps {
|
|
|
1559
2015
|
// Pre-dispatch health gate
|
|
1560
2016
|
preDispatchHealthGate,
|
|
1561
2017
|
|
|
1562
|
-
// Worktree
|
|
1563
|
-
|
|
2018
|
+
// Worktree state projection (ADR-016 — single Module Interface)
|
|
2019
|
+
worktreeProjection,
|
|
1564
2020
|
|
|
1565
2021
|
// Resource version guard
|
|
1566
2022
|
checkResourcesStale,
|
|
@@ -1575,7 +2031,6 @@ function buildLoopDeps(pi: ExtensionAPI): LoopDeps {
|
|
|
1575
2031
|
pruneQueueOrder,
|
|
1576
2032
|
isInAutoWorktree,
|
|
1577
2033
|
shouldUseWorktreeIsolation,
|
|
1578
|
-
mergeMilestoneToMain,
|
|
1579
2034
|
teardownAutoWorktree,
|
|
1580
2035
|
createAutoWorktree,
|
|
1581
2036
|
captureIntegrationBranch,
|
|
@@ -1632,8 +2087,9 @@ function buildLoopDeps(pi: ExtensionAPI): LoopDeps {
|
|
|
1632
2087
|
// Git
|
|
1633
2088
|
GitServiceImpl: GitServiceImpl as unknown as LoopDeps["GitServiceImpl"],
|
|
1634
2089
|
|
|
1635
|
-
//
|
|
1636
|
-
|
|
2090
|
+
// Worktree Lifecycle Module (ADR-016 — single Module Interface for the
|
|
2091
|
+
// milestone create/enter/exit/merge verbs)
|
|
2092
|
+
lifecycle: buildLifecycle(),
|
|
1637
2093
|
|
|
1638
2094
|
// Post-unit processing
|
|
1639
2095
|
postUnitPreVerification,
|
|
@@ -1894,7 +2350,12 @@ export async function startAuto(
|
|
|
1894
2350
|
s.verbose = verboseMode;
|
|
1895
2351
|
s.stepMode = requestedStepMode;
|
|
1896
2352
|
s.cmdCtx = ctx;
|
|
1897
|
-
|
|
2353
|
+
// ADR-016 phase 2 / B2 (#5620): bootstrap basePath transition before
|
|
2354
|
+
// the resume path consults persisted worktree state. Defensive about
|
|
2355
|
+
// s.originalBasePath — the meta-restore above (line 2003 / 2055) may
|
|
2356
|
+
// have already populated it from paused metadata; the verb preserves
|
|
2357
|
+
// that value.
|
|
2358
|
+
buildLifecycle().adoptSessionRoot(base);
|
|
1898
2359
|
// ── Resume worktree: if the paused session was inside a milestone worktree,
|
|
1899
2360
|
// apply that path as the dispatch basePath immediately (#3723).
|
|
1900
2361
|
// This ensures the dispatch loop runs from the worktree directory even when
|
|
@@ -1910,9 +2371,8 @@ export async function startAuto(
|
|
|
1910
2371
|
{ file: "auto.ts", milestoneId: s.currentMilestoneId ?? "" },
|
|
1911
2372
|
);
|
|
1912
2373
|
}
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
}
|
|
2374
|
+
// ADR-016 phase 2 / B3 (#5621): paused-resume worktree-path adoption.
|
|
2375
|
+
buildLifecycle().resumeFromPausedSession(base, resumeWorktreePath);
|
|
1916
2376
|
// Rebuild scope now that s.basePath reflects the actual worktree (or project root).
|
|
1917
2377
|
rebuildScope(s.basePath, s.currentMilestoneId);
|
|
1918
2378
|
// Ensure the workflow-logger audit log is pinned to the project root
|
|
@@ -1940,9 +2400,17 @@ export async function startAuto(
|
|
|
1940
2400
|
!detectWorktreeName(s.basePath) &&
|
|
1941
2401
|
!detectWorktreeName(s.originalBasePath)
|
|
1942
2402
|
) {
|
|
1943
|
-
|
|
2403
|
+
const enterResult = buildLifecycle().enterMilestone(s.currentMilestoneId, {
|
|
1944
2404
|
notify: ctx.ui.notify.bind(ctx.ui),
|
|
1945
2405
|
});
|
|
2406
|
+
if (!enterResult.ok && enterResult.reason === "lease-conflict") {
|
|
2407
|
+
ctx.ui.notify(
|
|
2408
|
+
`Cannot resume milestone ${s.currentMilestoneId}: lease is held by another worker.`,
|
|
2409
|
+
"error",
|
|
2410
|
+
);
|
|
2411
|
+
await stopAuto(ctx, pi, "lease-conflict during resume");
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
1946
2414
|
// s.basePath may have been updated to a worktree path by enterMilestone.
|
|
1947
2415
|
rebuildScope(s.basePath, s.currentMilestoneId);
|
|
1948
2416
|
}
|
|
@@ -1964,16 +2432,7 @@ export async function startAuto(
|
|
|
1964
2432
|
// tree; deployed extensions live at ~/.gsd/agent/extensions/gsd/ where the
|
|
1965
2433
|
// relative path resolves to ~/.gsd/agent/resource-loader.js which doesn't exist.
|
|
1966
2434
|
// Using GSD_PKG_ROOT constructs a correct absolute path in both contexts (#3949).
|
|
1967
|
-
|
|
1968
|
-
const pkgRoot = process.env.GSD_PKG_ROOT;
|
|
1969
|
-
const resourceLoaderPath = pkgRoot
|
|
1970
|
-
? pathToFileURL(join(pkgRoot, "dist", "resource-loader.js")).href
|
|
1971
|
-
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
1972
|
-
const { initResources } = await import(resourceLoaderPath);
|
|
1973
|
-
initResources(agentDir);
|
|
1974
|
-
// Open the project DB before rebuild/derive so resume uses DB-backed
|
|
1975
|
-
// state instead of falling back to stale markdown parsing (#2940).
|
|
1976
|
-
await openProjectDbIfPresent(s.basePath);
|
|
2435
|
+
await refreshResumeResourcesAndDb(s.basePath);
|
|
1977
2436
|
try {
|
|
1978
2437
|
await rebuildState(s.basePath);
|
|
1979
2438
|
pi.events.emit(CMUX_CHANNELS.SIDEBAR, { action: "sync" as const, preferences: loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences, state: await deriveState(s.basePath) });
|
|
@@ -2045,7 +2504,7 @@ export async function startAuto(
|
|
|
2045
2504
|
runKernelLoop: runUokKernelLoop,
|
|
2046
2505
|
runLegacyLoop: runLegacyAutoLoop,
|
|
2047
2506
|
});
|
|
2048
|
-
cleanupAfterLoopExit(ctx);
|
|
2507
|
+
await cleanupAfterLoopExit(ctx);
|
|
2049
2508
|
return;
|
|
2050
2509
|
}
|
|
2051
2510
|
|
|
@@ -2054,9 +2513,14 @@ export async function startAuto(
|
|
|
2054
2513
|
shouldUseWorktreeIsolation,
|
|
2055
2514
|
registerSigtermHandler,
|
|
2056
2515
|
lockBase,
|
|
2057
|
-
|
|
2516
|
+
buildLifecycle,
|
|
2058
2517
|
};
|
|
2059
2518
|
|
|
2519
|
+
// Register the worker before bootstrap enters a milestone worktree.
|
|
2520
|
+
// This ensures enterMilestone can claim a lease and seed dispatch claims
|
|
2521
|
+
// for crash-recovery fidelity (#5405).
|
|
2522
|
+
registerAutoWorkerForSession(s, base);
|
|
2523
|
+
|
|
2060
2524
|
const ready = await bootstrapAutoSession(
|
|
2061
2525
|
s,
|
|
2062
2526
|
ctx,
|
|
@@ -2100,7 +2564,7 @@ export async function startAuto(
|
|
|
2100
2564
|
runKernelLoop: runUokKernelLoop,
|
|
2101
2565
|
runLegacyLoop: runLegacyAutoLoop,
|
|
2102
2566
|
});
|
|
2103
|
-
cleanupAfterLoopExit(ctx);
|
|
2567
|
+
await cleanupAfterLoopExit(ctx);
|
|
2104
2568
|
}
|
|
2105
2569
|
|
|
2106
2570
|
// describeNextUnit is imported from auto-dashboard.ts and re-exported
|
|
@@ -2210,7 +2674,12 @@ export async function dispatchHookUnit(
|
|
|
2210
2674
|
s.pendingQuickTasks = [];
|
|
2211
2675
|
}
|
|
2212
2676
|
|
|
2213
|
-
|
|
2677
|
+
// ADR-016 phase 2 / B2 (#5620): hook-trigger basePath transition. Treats
|
|
2678
|
+
// the trigger as a bootstrap variant — if the session is fresh,
|
|
2679
|
+
// `originalBasePath` gets set to `targetBasePath`; if the session was
|
|
2680
|
+
// already active with an established `originalBasePath`, the verb
|
|
2681
|
+
// preserves it.
|
|
2682
|
+
buildLifecycle().adoptSessionRoot(targetBasePath);
|
|
2214
2683
|
if (!s.orchestration) {
|
|
2215
2684
|
ensureOrchestrationModule(ctx, pi, s.basePath);
|
|
2216
2685
|
}
|
|
@@ -2224,24 +2693,7 @@ export async function dispatchHookUnit(
|
|
|
2224
2693
|
startedAt: hookStartedAt,
|
|
2225
2694
|
};
|
|
2226
2695
|
|
|
2227
|
-
|
|
2228
|
-
// newSession() snapshots process.cwd() during construction; chdir-ing
|
|
2229
|
-
// afterward leaves the session rooted to whatever cwd was when the call
|
|
2230
|
-
// was made. Must be synchronous — no awaits between chdir and newSession.
|
|
2231
|
-
try { if (process.cwd() !== s.basePath) process.chdir(s.basePath); } catch (err) {
|
|
2232
|
-
const msg = `Failed to chdir before hook newSession (basePath: ${s.basePath}): ${err instanceof Error ? err.message : String(err)}`;
|
|
2233
|
-
logWarning("engine", msg, { file: "auto.ts", basePath: s.basePath, error: err instanceof Error ? err.message : String(err) });
|
|
2234
|
-
ctx.ui.notify(`${msg}. Cancelling hook dispatch to avoid running in the wrong directory.`, "error");
|
|
2235
|
-
if (wasActive) {
|
|
2236
|
-
s.basePath = previousBasePath;
|
|
2237
|
-
s.currentUnit = previousCurrentUnit;
|
|
2238
|
-
} else {
|
|
2239
|
-
s.reset();
|
|
2240
|
-
}
|
|
2241
|
-
return false;
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
const result = await s.cmdCtx!.newSession();
|
|
2696
|
+
const result = await s.cmdCtx!.newSession({ workspaceRoot: s.basePath });
|
|
2245
2697
|
if (result.cancelled) {
|
|
2246
2698
|
await stopAuto(ctx, pi);
|
|
2247
2699
|
return false;
|