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
|
*
|
|
@@ -13,14 +15,14 @@ import { deriveState } from "./state.js";
|
|
|
13
15
|
import { parseUnitId } from "./unit-id.js";
|
|
14
16
|
import { assessInterruptedSession, readPausedSessionMetadata, PAUSED_SESSION_KV_KEY, } from "./interrupted-session.js";
|
|
15
17
|
import { setRuntimeKv, deleteRuntimeKv, } from "./db/runtime-kv.js";
|
|
16
|
-
import { getManifestStatus } from "./files.js";
|
|
18
|
+
import { extractSection, getManifestStatus, splitFrontmatter, parseFrontmatterMap } from "./files.js";
|
|
17
19
|
export { inlinePriorMilestoneSummary } from "./files.js";
|
|
18
20
|
import { collectSecretsFromManifest } from "../get-secrets-from-user.js";
|
|
19
21
|
import { gsdRoot, resolveMilestoneFile, resolveMilestonePath, resolveDir, milestonesDir, } from "./paths.js";
|
|
20
22
|
import { invalidateAllCaches } from "./cache.js";
|
|
21
23
|
import { clearActivityLogState } from "./activity-log.js";
|
|
22
24
|
import { synthesizeCrashRecovery, getDeepDiagnostic, readActiveMilestoneId, } from "./session-forensics.js";
|
|
23
|
-
import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, } from "./crash-recovery.js";
|
|
25
|
+
import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
|
|
24
26
|
import { acquireSessionLock, getSessionLockStatus, releaseSessionLock, updateSessionLock, } from "./session-lock.js";
|
|
25
27
|
import { resolveAutoSupervisorConfig, loadEffectiveGSDPreferences, getIsolationMode, } from "./preferences.js";
|
|
26
28
|
import { sendDesktopNotification } from "./notifications.js";
|
|
@@ -43,10 +45,10 @@ import { isAbsolute, join } from "node:path";
|
|
|
43
45
|
import { pathToFileURL } from "node:url";
|
|
44
46
|
import { readFileSync, existsSync, mkdirSync } from "node:fs";
|
|
45
47
|
import { atomicWriteSync } from "./atomic-write.js";
|
|
46
|
-
import {
|
|
48
|
+
import { captureIntegrationBranch, detectWorktreeName, getCurrentBranch, getMainBranch, setActiveMilestoneId, resolveProjectRoot, } from "./worktree.js";
|
|
47
49
|
import { GitServiceImpl } from "./git-service.js";
|
|
48
50
|
import { getPriorSliceCompletionBlocker } from "./dispatch-guard.js";
|
|
49
|
-
import { createAutoWorktree,
|
|
51
|
+
import { createAutoWorktree, teardownAutoWorktree, isInAutoWorktree, getAutoWorktreePath, mergeMilestoneToMain, autoWorktreeBranch, checkResourcesStale, escapeStaleWorktree, } from "./auto-worktree.js";
|
|
50
52
|
import { pruneQueueOrder } from "./queue-order.js";
|
|
51
53
|
import { startCommandPolling as _startCommandPolling, isRemoteConfigured } from "../remote-questions/manager.js";
|
|
52
54
|
import { debugLog, isDebugEnabled, writeDebugSummary } from "./debug-logger.js";
|
|
@@ -58,9 +60,11 @@ import { recoverFailedMigration } from "./migrate-external.js";
|
|
|
58
60
|
import { initRegistry, convertDispatchRules } from "./rule-registry.js";
|
|
59
61
|
import { emitJournalEvent as _emitJournalEvent } from "./journal.js";
|
|
60
62
|
import { isClosedStatus } from "./status-guards.js";
|
|
61
|
-
import { updateProgressWidget as _updateProgressWidget, updateSliceProgressCache, clearSliceProgressCache, } from "./auto-dashboard.js";
|
|
63
|
+
import { updateProgressWidget as _updateProgressWidget, setCompletionProgressWidget, setAutoOutcomeWidget, updateSliceProgressCache, clearSliceProgressCache, unitVerb, } from "./auto-dashboard.js";
|
|
62
64
|
import { registerSigtermHandler as _registerSigtermHandler, deregisterSigtermHandler as _deregisterSigtermHandler, } from "./auto-supervisor.js";
|
|
63
|
-
import { isDbAvailable, getMilestone } from "./gsd-db.js";
|
|
65
|
+
import { isDbAvailable, getMilestone, getMilestoneSlices } from "./gsd-db.js";
|
|
66
|
+
import { markLatestActiveForWorkerCanceled } from "./db/unit-dispatches.js";
|
|
67
|
+
import { writeUnitRuntimeRecord } from "./unit-runtime.js";
|
|
64
68
|
import { countPendingCaptures } from "./captures.js";
|
|
65
69
|
import { CMUX_CHANNELS } from "../shared/cmux-events.js";
|
|
66
70
|
import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
|
|
@@ -83,8 +87,24 @@ import { runAutoLoopWithUok } from "./uok/kernel.js";
|
|
|
83
87
|
import { resolveUokFlags } from "./uok/flags.js";
|
|
84
88
|
import { validateDirectory } from "./validate-directory.js";
|
|
85
89
|
import { createAutoOrchestrator } from "./auto/orchestrator.js";
|
|
86
|
-
import {
|
|
90
|
+
import { reconcileBeforeDispatch } from "./state-reconciliation.js";
|
|
91
|
+
import { compileUnitToolContract } from "./tool-contract.js";
|
|
92
|
+
import { createWorktreeSafetyModule } from "./worktree-safety.js";
|
|
93
|
+
import { resolveManifest } from "./unit-context-manifest.js";
|
|
94
|
+
import { classifyFailure } from "./recovery-classification.js";
|
|
95
|
+
import { WorktreeLifecycle, } from "./worktree-lifecycle.js";
|
|
96
|
+
import { WorktreeStateProjection } from "./worktree-state-projection.js";
|
|
87
97
|
import { reorderForCaching } from "./prompt-ordering.js";
|
|
98
|
+
import { initTokenCounter } from "./token-counter.js";
|
|
99
|
+
// Warm the tiktoken encoder at extension startup so context-budget computations
|
|
100
|
+
// can use accurate token counts via countTokensSync without paying the load
|
|
101
|
+
// cost mid-prompt-build. Fire-and-forget — failure falls back to the
|
|
102
|
+
// provider-aware char-ratio estimator already used by getCharsPerToken().
|
|
103
|
+
// Catch rejections explicitly: an unhandled rejection at module-import time
|
|
104
|
+
// can destabilize startup before the engine logger is configured.
|
|
105
|
+
void initTokenCounter().catch((err) => {
|
|
106
|
+
logWarning("engine", `token counter warm-up failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
107
|
+
});
|
|
88
108
|
export { STUB_RECOVERY_THRESHOLD, NEW_SESSION_TIMEOUT_MS, } from "./auto/session.js";
|
|
89
109
|
import { autoSession as s } from "./auto-runtime-state.js";
|
|
90
110
|
import { gsdHome } from "./gsd-home.js";
|
|
@@ -112,11 +132,12 @@ const STATE_REBUILD_MIN_INTERVAL_MS = 30_000;
|
|
|
112
132
|
* the DB is unavailable (e.g. fresh project before init) we skip registration
|
|
113
133
|
* silently rather than blocking session start.
|
|
114
134
|
*/
|
|
115
|
-
function registerAutoWorkerForSession(session) {
|
|
135
|
+
function registerAutoWorkerForSession(session, projectRootOverride) {
|
|
116
136
|
if (session.workerId)
|
|
117
137
|
return; // already registered (e.g. resume re-runs)
|
|
118
138
|
try {
|
|
119
|
-
const projectRootRealpath = normalizeRealPath(
|
|
139
|
+
const projectRootRealpath = normalizeRealPath(projectRootOverride
|
|
140
|
+
?? session.scope?.workspace.projectRoot
|
|
120
141
|
?? (session.originalBasePath || session.basePath));
|
|
121
142
|
session.workerId = registerAutoWorker({ projectRootRealpath });
|
|
122
143
|
}
|
|
@@ -148,6 +169,12 @@ function restoreProjectRootEnv() {
|
|
|
148
169
|
s.hadProjectRootEnv = false;
|
|
149
170
|
s.projectRootEnvCaptured = false;
|
|
150
171
|
}
|
|
172
|
+
export function _captureProjectRootEnvForTest(projectRoot) {
|
|
173
|
+
captureProjectRootEnv(projectRoot);
|
|
174
|
+
}
|
|
175
|
+
export function _restoreProjectRootEnvForTest() {
|
|
176
|
+
restoreProjectRootEnv();
|
|
177
|
+
}
|
|
151
178
|
function captureMilestoneLockEnv(milestoneId) {
|
|
152
179
|
if (!s.milestoneLockEnvCaptured) {
|
|
153
180
|
s.hadMilestoneLockEnv = Object.prototype.hasOwnProperty.call(process.env, "GSD_MILESTONE_LOCK");
|
|
@@ -225,6 +252,10 @@ function synthesizePausedSessionRecovery(basePath, unitType, unitId, sessionFile
|
|
|
225
252
|
export function _synthesizePausedSessionRecoveryForTest(basePath, unitType, unitId, sessionFile) {
|
|
226
253
|
return synthesizePausedSessionRecovery(basePath, unitType, unitId, sessionFile);
|
|
227
254
|
}
|
|
255
|
+
// `_resolvePausedResumeBasePathForTest` was retired in ADR-016 phase 2 / B3
|
|
256
|
+
// (#5621). Production callers go through
|
|
257
|
+
// `WorktreeLifecycle.resumeFromPausedSession`; the pure helper for tests is
|
|
258
|
+
// `resolvePausedResumeBasePath` exported from `worktree-lifecycle.ts`.
|
|
228
259
|
const DETACHED_AUTO_KEEPALIVE_INTERVAL_MS = 30_000;
|
|
229
260
|
function withDetachedAutoKeepalive(run) {
|
|
230
261
|
const keepAlive = setInterval(() => { }, DETACHED_AUTO_KEEPALIVE_INTERVAL_MS);
|
|
@@ -272,9 +303,50 @@ export function shouldUseWorktreeIsolation(basePath) {
|
|
|
272
303
|
*/
|
|
273
304
|
// Re-export budget utilities for external consumers
|
|
274
305
|
export { getBudgetAlertLevel, getNewBudgetAlertLevel, getBudgetEnforcementAction, } from "./auto-budget.js";
|
|
306
|
+
function closeOutSignalInterruptedUnit(currentBasePath) {
|
|
307
|
+
const currentUnit = s.currentUnit;
|
|
308
|
+
if (!currentUnit)
|
|
309
|
+
return;
|
|
310
|
+
const reason = "Auto-mode process received a termination signal";
|
|
311
|
+
const errorContext = {
|
|
312
|
+
message: reason,
|
|
313
|
+
category: "aborted",
|
|
314
|
+
isTransient: false,
|
|
315
|
+
};
|
|
316
|
+
const basePath = s.basePath || currentBasePath;
|
|
317
|
+
try {
|
|
318
|
+
emitOpenUnitEndForUnit(basePath, currentUnit.type, currentUnit.id, "cancelled", errorContext);
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
logWarning("engine", `signal unit-end cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
writeUnitRuntimeRecord(basePath, currentUnit.type, currentUnit.id, currentUnit.startedAt, {
|
|
325
|
+
phase: "crashed",
|
|
326
|
+
lastProgressAt: Date.now(),
|
|
327
|
+
lastProgressKind: "signal",
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
logWarning("engine", `signal runtime cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
332
|
+
}
|
|
333
|
+
try {
|
|
334
|
+
if (s.workerId)
|
|
335
|
+
markLatestActiveForWorkerCanceled(s.workerId, "signal-exit");
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
logWarning("engine", `signal dispatch cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
resolveAgentEndCancelled(errorContext);
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
logWarning("engine", `signal resolve cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
275
347
|
/** Wrapper: register SIGTERM handler and store reference. */
|
|
276
348
|
function registerSigtermHandler(currentBasePath) {
|
|
277
|
-
s.sigtermHandler = _registerSigtermHandler(currentBasePath, s.sigtermHandler);
|
|
349
|
+
s.sigtermHandler = _registerSigtermHandler(currentBasePath, s.sigtermHandler, () => closeOutSignalInterruptedUnit(currentBasePath));
|
|
278
350
|
}
|
|
279
351
|
/** Wrapper: deregister SIGTERM handler and clear reference. */
|
|
280
352
|
function deregisterSigtermHandler() {
|
|
@@ -341,6 +413,9 @@ export function getAutoDashboardData() {
|
|
|
341
413
|
export function isAutoActive() {
|
|
342
414
|
return s.active;
|
|
343
415
|
}
|
|
416
|
+
export function isAutoCompletionStopInProgress() {
|
|
417
|
+
return s.completionStopInProgress;
|
|
418
|
+
}
|
|
344
419
|
/** Test-only seam for validating auto-mode guards (#4704). Do not use in production code. */
|
|
345
420
|
export function _setAutoActiveForTest(active) {
|
|
346
421
|
s.active = active;
|
|
@@ -360,6 +435,20 @@ export function _warnIfWorktreeMissingForTest(worktreePath, milestoneId) {
|
|
|
360
435
|
export function isAutoPaused() {
|
|
361
436
|
return s.paused;
|
|
362
437
|
}
|
|
438
|
+
export async function refreshResumeResourcesAndDb(basePath, deps = {}) {
|
|
439
|
+
const env = deps.env ?? process.env;
|
|
440
|
+
const importModule = deps.importModule ?? ((specifier) => import(specifier));
|
|
441
|
+
const agentDir = env.GSD_CODING_AGENT_DIR || join(gsdHome(), "agent");
|
|
442
|
+
const pkgRoot = env.GSD_PKG_ROOT;
|
|
443
|
+
const resourceLoaderPath = pkgRoot
|
|
444
|
+
? pathToFileURL(join(pkgRoot, "dist", "resource-loader.js")).href
|
|
445
|
+
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
446
|
+
const { initResources } = await importModule(resourceLoaderPath);
|
|
447
|
+
initResources(agentDir);
|
|
448
|
+
const { primeCache } = await importModule("./prompt-loader.js");
|
|
449
|
+
primeCache();
|
|
450
|
+
await (deps.openProjectDb ?? openProjectDbIfPresent)(basePath);
|
|
451
|
+
}
|
|
363
452
|
export function setActiveEngineId(id) {
|
|
364
453
|
s.activeEngineId = id;
|
|
365
454
|
}
|
|
@@ -523,6 +612,21 @@ function buildSnapshotOpts(_unitType, _unitId) {
|
|
|
523
612
|
...(s.currentUnitRouting ?? {}),
|
|
524
613
|
};
|
|
525
614
|
}
|
|
615
|
+
function currentUnitLabel() {
|
|
616
|
+
if (!s.currentUnit)
|
|
617
|
+
return null;
|
|
618
|
+
return `${unitVerb(s.currentUnit.type)} ${s.currentUnit.id}`;
|
|
619
|
+
}
|
|
620
|
+
function setLifecycleOutcome(ctx, input) {
|
|
621
|
+
if (!ctx?.hasUI)
|
|
622
|
+
return;
|
|
623
|
+
const { unitLabel: unitLabelOverride, ...rest } = input;
|
|
624
|
+
setAutoOutcomeWidget(ctx, {
|
|
625
|
+
...rest,
|
|
626
|
+
unitLabel: unitLabelOverride !== undefined ? unitLabelOverride : currentUnitLabel(),
|
|
627
|
+
startedAt: s.autoStartTime,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
526
630
|
function handleLostSessionLock(ctx, lockStatus) {
|
|
527
631
|
debugLog("session-lock-lost", {
|
|
528
632
|
lockBase: lockBase(),
|
|
@@ -563,7 +667,21 @@ function handleLostSessionLock(ctx, lockStatus) {
|
|
|
563
667
|
* the stale unit state, progress widget, status badge, and restores CWD so
|
|
564
668
|
* the dashboard does not show an orphaned timer and the shell is usable.
|
|
565
669
|
*/
|
|
566
|
-
function
|
|
670
|
+
export async function rerootCommandSession(cmdCtx, workspaceRoot) {
|
|
671
|
+
if (!cmdCtx || !workspaceRoot)
|
|
672
|
+
return { status: "skipped" };
|
|
673
|
+
try {
|
|
674
|
+
const result = await cmdCtx.newSession({ workspaceRoot });
|
|
675
|
+
return result.cancelled ? { status: "cancelled" } : { status: "ok" };
|
|
676
|
+
}
|
|
677
|
+
catch (err) {
|
|
678
|
+
return {
|
|
679
|
+
status: "failed",
|
|
680
|
+
error: err instanceof Error ? err.message : String(err),
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
export async function cleanupAfterLoopExit(ctx) {
|
|
567
685
|
s.currentUnit = null;
|
|
568
686
|
s.active = false;
|
|
569
687
|
deactivateGSD();
|
|
@@ -588,30 +706,102 @@ function cleanupAfterLoopExit(ctx) {
|
|
|
588
706
|
// visible so the user still has a resumable auto-mode signal on screen.
|
|
589
707
|
if (!s.paused) {
|
|
590
708
|
ctx.ui.setStatus("gsd-auto", undefined);
|
|
591
|
-
|
|
709
|
+
if (s.completionStopInProgress) {
|
|
710
|
+
s.completionStopInProgress = false;
|
|
711
|
+
}
|
|
592
712
|
initHealthWidget(ctx);
|
|
593
713
|
}
|
|
594
|
-
//
|
|
714
|
+
// ADR-016 phase 3 (#5693): the stop-path basePath restore routes through
|
|
715
|
+
// `Lifecycle.restoreToProjectRoot()`, the sole owner of `s.basePath`
|
|
716
|
+
// mutation. The verb assigns `s.basePath` before any throwable work
|
|
717
|
+
// (rebuildGitService, cache invalidation), so a thrown error still leaves
|
|
718
|
+
// basePath restored — no fallback assignment needed at the call site.
|
|
719
|
+
// The chdir stays here because `restoreToProjectRoot` is a pure
|
|
720
|
+
// session-state mutation.
|
|
595
721
|
if (s.originalBasePath) {
|
|
596
|
-
s.basePath = s.originalBasePath;
|
|
597
722
|
try {
|
|
598
|
-
|
|
723
|
+
buildLifecycle().restoreToProjectRoot();
|
|
599
724
|
}
|
|
600
725
|
catch (err) {
|
|
601
|
-
|
|
602
|
-
logWarning("engine", `chdir failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
726
|
+
logWarning("engine", `restore project root failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
603
727
|
}
|
|
728
|
+
try {
|
|
729
|
+
process.chdir(s.originalBasePath);
|
|
730
|
+
}
|
|
731
|
+
catch (err) {
|
|
732
|
+
logWarning("engine", `basePath restore/chdir failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (s.originalBasePath && s.cmdCtx) {
|
|
736
|
+
const result = await rerootCommandSession(s.cmdCtx, s.originalBasePath);
|
|
737
|
+
if (result.status === "cancelled") {
|
|
738
|
+
logWarning("engine", "post-loop session re-root was cancelled", { file: "auto.ts", basePath: s.originalBasePath });
|
|
739
|
+
}
|
|
740
|
+
else if (result.status === "failed") {
|
|
741
|
+
logWarning("engine", `post-loop session re-root failed: ${result.error ?? "unknown"}`, { file: "auto.ts", basePath: s.originalBasePath });
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
export function _cleanupAfterLoopExitForTest(ctx) {
|
|
746
|
+
return cleanupAfterLoopExit(ctx);
|
|
747
|
+
}
|
|
748
|
+
function normalizeFrontmatterList(value) {
|
|
749
|
+
if (!Array.isArray(value))
|
|
750
|
+
return [];
|
|
751
|
+
return value
|
|
752
|
+
.map(item => typeof item === "string" ? item.trim() : "")
|
|
753
|
+
.filter(item => item.length > 0 && item !== "(none)");
|
|
754
|
+
}
|
|
755
|
+
function firstBoldParagraph(body) {
|
|
756
|
+
const match = body.match(/\*\*([^*\n][\s\S]*?)\*\*/);
|
|
757
|
+
return match?.[1]?.replace(/\s+/g, " ").trim() || undefined;
|
|
758
|
+
}
|
|
759
|
+
function loadMilestoneCompletionRollup(basePath, milestoneId) {
|
|
760
|
+
if (!milestoneId)
|
|
761
|
+
return {};
|
|
762
|
+
const summaryPath = resolveMilestoneFile(basePath, milestoneId, "SUMMARY");
|
|
763
|
+
if (!summaryPath || !existsSync(summaryPath))
|
|
764
|
+
return {};
|
|
765
|
+
try {
|
|
766
|
+
const raw = readFileSync(summaryPath, "utf-8");
|
|
767
|
+
const [frontmatterLines, body] = splitFrontmatter(raw);
|
|
768
|
+
const frontmatter = frontmatterLines ? parseFrontmatterMap(frontmatterLines) : {};
|
|
769
|
+
return {
|
|
770
|
+
milestoneTitle: typeof frontmatter.title === "string" ? frontmatter.title : undefined,
|
|
771
|
+
oneLiner: firstBoldParagraph(body),
|
|
772
|
+
successCriteriaResults: extractSection(body, "Success Criteria Results") ?? undefined,
|
|
773
|
+
definitionOfDoneResults: extractSection(body, "Definition of Done Results") ?? undefined,
|
|
774
|
+
requirementOutcomes: extractSection(body, "Requirement Outcomes") ?? undefined,
|
|
775
|
+
deviations: extractSection(body, "Deviations") ?? undefined,
|
|
776
|
+
followUps: extractSection(body, "Follow-ups") ?? undefined,
|
|
777
|
+
keyDecisions: normalizeFrontmatterList(frontmatter.key_decisions),
|
|
778
|
+
keyFiles: normalizeFrontmatterList(frontmatter.key_files),
|
|
779
|
+
lessonsLearned: normalizeFrontmatterList(frontmatter.lessons_learned),
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
catch (err) {
|
|
783
|
+
logWarning("dashboard", `completion roll-up summary read failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
784
|
+
return {};
|
|
604
785
|
}
|
|
605
786
|
}
|
|
606
|
-
export
|
|
787
|
+
export function _resolveAutoWorktreeExitActionForTest(currentMilestoneId, milestoneMergedInPhases, milestoneComplete) {
|
|
788
|
+
const action = _selectStopAutoWorktreeExit({
|
|
789
|
+
currentMilestoneId: currentMilestoneId ?? null,
|
|
790
|
+
milestoneComplete,
|
|
791
|
+
milestoneMergedInPhases,
|
|
792
|
+
});
|
|
793
|
+
return action === "none" ? "skip" : action;
|
|
794
|
+
}
|
|
795
|
+
export async function stopAuto(ctx, pi, reason, options = {}) {
|
|
607
796
|
if (!s.active && !s.paused)
|
|
608
797
|
return;
|
|
609
798
|
const loadedPreferences = loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences;
|
|
610
799
|
const reasonSuffix = reason ? ` — ${reason}` : "";
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
//
|
|
614
|
-
//
|
|
800
|
+
const preserveCompletionSurface = Boolean(options.completionWidget);
|
|
801
|
+
s.completionStopInProgress = preserveCompletionSurface;
|
|
802
|
+
// #4764 — telemetry: record the exit reason, isolation mode, whether an auto
|
|
803
|
+
// worktree was active, and whether the current milestone was merged before
|
|
804
|
+
// stopAuto. The unmerged-work warning is only meaningful for real worktrees.
|
|
615
805
|
try {
|
|
616
806
|
const { emitAutoExit } = await import("./worktree-telemetry.js");
|
|
617
807
|
// Normalize the free-form reason to a closed set so the telemetry
|
|
@@ -633,10 +823,13 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
633
823
|
: rawReason === "stop" || rawReason === "pause"
|
|
634
824
|
? rawReason
|
|
635
825
|
: "other";
|
|
636
|
-
|
|
826
|
+
const telemetryBase = s.originalBasePath || s.basePath;
|
|
827
|
+
emitAutoExit(telemetryBase, {
|
|
637
828
|
reason: normalizedReason,
|
|
638
829
|
milestoneId: s.currentMilestoneId ?? undefined,
|
|
639
830
|
milestoneMerged: s.milestoneMergedInPhases === true,
|
|
831
|
+
isolationMode: getIsolationMode(telemetryBase),
|
|
832
|
+
worktreeActive: isInAutoWorktree(s.basePath),
|
|
640
833
|
});
|
|
641
834
|
}
|
|
642
835
|
catch (err) {
|
|
@@ -666,6 +859,8 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
666
859
|
if (s.workerId) {
|
|
667
860
|
markWorkerStopping(s.workerId);
|
|
668
861
|
}
|
|
862
|
+
s.workerId = null;
|
|
863
|
+
s.milestoneLeaseToken = null;
|
|
669
864
|
}
|
|
670
865
|
catch (e) {
|
|
671
866
|
debugLog("stop-cleanup-coordination", { error: e instanceof Error ? e.message : String(e) });
|
|
@@ -709,7 +904,7 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
709
904
|
const notifyCtx = ctx
|
|
710
905
|
? { notify: ctx.ui.notify.bind(ctx.ui) }
|
|
711
906
|
: { notify: () => { } };
|
|
712
|
-
const
|
|
907
|
+
const lifecycle = buildLifecycle();
|
|
713
908
|
// Check if the milestone is complete. DB status is the authoritative
|
|
714
909
|
// signal — only a successful gsd_complete_milestone call flips it to
|
|
715
910
|
// "complete" (tools/complete-milestone.ts). SUMMARY file presence is
|
|
@@ -740,19 +935,27 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
740
935
|
// Non-fatal — fall through to preserveBranch path
|
|
741
936
|
logWarning("engine", `milestone summary check failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
742
937
|
}
|
|
743
|
-
|
|
938
|
+
const exitAction = _selectStopAutoWorktreeExit({
|
|
939
|
+
currentMilestoneId: s.currentMilestoneId,
|
|
940
|
+
milestoneComplete,
|
|
941
|
+
milestoneMergedInPhases: s.milestoneMergedInPhases,
|
|
942
|
+
});
|
|
943
|
+
if (exitAction === "merge") {
|
|
744
944
|
// Milestone is complete — merge worktree branch back to main
|
|
745
|
-
|
|
945
|
+
const r = lifecycle.exitMilestone(s.currentMilestoneId, { merge: true }, notifyCtx);
|
|
946
|
+
if (!r.ok && r.cause instanceof Error)
|
|
947
|
+
throw r.cause;
|
|
746
948
|
}
|
|
747
|
-
else {
|
|
949
|
+
else if (exitAction === "preserve") {
|
|
748
950
|
// Milestone still in progress — preserve branch for later resumption
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
951
|
+
const r = lifecycle.exitMilestone(s.currentMilestoneId, { merge: false, preserveBranch: true }, notifyCtx);
|
|
952
|
+
if (!r.ok && r.cause instanceof Error)
|
|
953
|
+
throw r.cause;
|
|
752
954
|
}
|
|
753
955
|
}
|
|
754
956
|
}
|
|
755
957
|
catch (e) {
|
|
958
|
+
ctx?.ui.notify(`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.`, "warning");
|
|
756
959
|
debugLog("stop-cleanup-worktree", { error: e instanceof Error ? e.message : String(e) });
|
|
757
960
|
}
|
|
758
961
|
// ── Step 5: Rebuild state while DB is still open (#3599) ──
|
|
@@ -770,6 +973,21 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
770
973
|
});
|
|
771
974
|
}
|
|
772
975
|
}
|
|
976
|
+
// Pre-compute completion widget slice counts while the DB is still open.
|
|
977
|
+
// Step 8 runs after closeDatabase(), so DB-backed slice lookups must happen here.
|
|
978
|
+
const completionMilestoneId = options.completionWidget?.milestoneId ?? s.currentMilestoneId;
|
|
979
|
+
let completedSlices = null;
|
|
980
|
+
let totalSlices = null;
|
|
981
|
+
if (preserveCompletionSurface && options.completionWidget && completionMilestoneId && isDbAvailable()) {
|
|
982
|
+
try {
|
|
983
|
+
const slices = getMilestoneSlices(completionMilestoneId);
|
|
984
|
+
completedSlices = slices.filter(slice => isClosedStatus(slice.status)).length;
|
|
985
|
+
totalSlices = slices.length;
|
|
986
|
+
}
|
|
987
|
+
catch (err) {
|
|
988
|
+
logWarning("dashboard", `completion slice stats lookup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
773
991
|
// ── Step 6: DB cleanup ──
|
|
774
992
|
if (isDbAvailable()) {
|
|
775
993
|
try {
|
|
@@ -782,36 +1000,112 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
782
1000
|
});
|
|
783
1001
|
}
|
|
784
1002
|
}
|
|
785
|
-
// ── Step 7: Restore basePath and chdir ──
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1003
|
+
// ── Step 7: Restore basePath and chdir (ADR-016 phase 3, #5693) ──
|
|
1004
|
+
// `restoreToProjectRoot` assigns s.basePath before any throwable work;
|
|
1005
|
+
// no fallback assignment is needed at the call site.
|
|
1006
|
+
if (s.originalBasePath) {
|
|
1007
|
+
try {
|
|
1008
|
+
buildLifecycle().restoreToProjectRoot();
|
|
1009
|
+
}
|
|
1010
|
+
catch (e) {
|
|
1011
|
+
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
1012
|
+
}
|
|
1013
|
+
try {
|
|
1014
|
+
process.chdir(s.basePath);
|
|
1015
|
+
}
|
|
1016
|
+
catch (err) {
|
|
1017
|
+
/* best-effort */
|
|
1018
|
+
logWarning("engine", `chdir failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
796
1019
|
}
|
|
797
1020
|
}
|
|
798
|
-
|
|
799
|
-
|
|
1021
|
+
// Re-root the active command session/tool runtime after worktree teardown.
|
|
1022
|
+
// mergeAndExit restores process.cwd(), but AgentSession has already captured
|
|
1023
|
+
// its own cwd for tools and system prompt; refresh it before returning to the
|
|
1024
|
+
// user so follow-up commands do not target a removed milestone worktree.
|
|
1025
|
+
if (s.originalBasePath && ctx && s.cmdCtx) {
|
|
1026
|
+
const result = await rerootCommandSession(s.cmdCtx, s.originalBasePath);
|
|
1027
|
+
if (result.status === "cancelled") {
|
|
1028
|
+
logWarning("engine", "post-stop session re-root was cancelled", { file: "auto.ts", basePath: s.originalBasePath });
|
|
1029
|
+
}
|
|
1030
|
+
else if (result.status === "failed") {
|
|
1031
|
+
logWarning("engine", `post-stop session re-root failed: ${result.error ?? "unknown"}`, { file: "auto.ts", basePath: s.originalBasePath });
|
|
1032
|
+
}
|
|
800
1033
|
}
|
|
801
1034
|
// ── Step 8: Ledger notification ──
|
|
802
1035
|
try {
|
|
803
1036
|
const ledger = getLedger();
|
|
1037
|
+
const isAllComplete = reason === "All milestones complete";
|
|
1038
|
+
const isMilestoneComplete = /^Milestone\s+\S+\s+complete$/i.test(reason ?? "");
|
|
1039
|
+
const notificationPrefix = isAllComplete
|
|
1040
|
+
? "All milestones complete"
|
|
1041
|
+
: isMilestoneComplete
|
|
1042
|
+
? `${reason}. Auto-mode finished this milestone`
|
|
1043
|
+
: `Auto-mode stopped${reasonSuffix}`;
|
|
804
1044
|
if (ledger && ledger.units.length > 0) {
|
|
805
1045
|
const totals = getProjectTotals(ledger.units);
|
|
806
|
-
ctx?.ui.notify(
|
|
1046
|
+
ctx?.ui.notify(`${notificationPrefix}. Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${ledger.units.length} units`, "info");
|
|
807
1047
|
}
|
|
808
1048
|
else {
|
|
809
|
-
ctx?.ui.notify(
|
|
1049
|
+
ctx?.ui.notify(`${notificationPrefix}.`, "info");
|
|
810
1050
|
}
|
|
811
1051
|
}
|
|
812
1052
|
catch (e) {
|
|
813
1053
|
debugLog("stop-cleanup-ledger", { error: e instanceof Error ? e.message : String(e) });
|
|
814
1054
|
}
|
|
1055
|
+
if (preserveCompletionSurface && ctx && options.completionWidget) {
|
|
1056
|
+
const ledger = getLedger();
|
|
1057
|
+
const units = ledger?.units ?? [];
|
|
1058
|
+
const totals = units.length > 0 ? getProjectTotals(units) : null;
|
|
1059
|
+
let totalInput = 0;
|
|
1060
|
+
let totalCacheRead = 0;
|
|
1061
|
+
try {
|
|
1062
|
+
for (const entry of s.cmdCtx?.sessionManager?.getEntries?.() ?? []) {
|
|
1063
|
+
if (entry.type === "message") {
|
|
1064
|
+
const msgEntry = entry;
|
|
1065
|
+
if (msgEntry.message?.role === "assistant") {
|
|
1066
|
+
const usage = msgEntry.message.usage;
|
|
1067
|
+
if (usage) {
|
|
1068
|
+
totalInput += usage.input || 0;
|
|
1069
|
+
totalCacheRead += usage.cacheRead || 0;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
catch (err) {
|
|
1076
|
+
logWarning("dashboard", `completion stats lookup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1077
|
+
}
|
|
1078
|
+
const contextUsage = s.cmdCtx?.getContextUsage?.();
|
|
1079
|
+
const milestoneId = completionMilestoneId;
|
|
1080
|
+
const rollup = loadMilestoneCompletionRollup(s.originalBasePath || s.basePath, milestoneId);
|
|
1081
|
+
setCompletionProgressWidget(ctx, {
|
|
1082
|
+
milestoneId,
|
|
1083
|
+
milestoneTitle: options.completionWidget.milestoneTitle ?? rollup.milestoneTitle,
|
|
1084
|
+
oneLiner: rollup.oneLiner,
|
|
1085
|
+
successCriteriaResults: rollup.successCriteriaResults,
|
|
1086
|
+
definitionOfDoneResults: rollup.definitionOfDoneResults,
|
|
1087
|
+
requirementOutcomes: rollup.requirementOutcomes,
|
|
1088
|
+
deviations: rollup.deviations,
|
|
1089
|
+
followUps: rollup.followUps,
|
|
1090
|
+
keyDecisions: rollup.keyDecisions,
|
|
1091
|
+
keyFiles: rollup.keyFiles,
|
|
1092
|
+
lessonsLearned: rollup.lessonsLearned,
|
|
1093
|
+
reason: reason ?? "Milestone complete",
|
|
1094
|
+
startedAt: s.autoStartTime,
|
|
1095
|
+
totalCost: totals?.cost ?? 0,
|
|
1096
|
+
totalTokens: totals?.tokens.total ?? 0,
|
|
1097
|
+
unitCount: units.length,
|
|
1098
|
+
cacheHitRate: totalCacheRead + totalInput > 0
|
|
1099
|
+
? (totalCacheRead / (totalCacheRead + totalInput)) * 100
|
|
1100
|
+
: null,
|
|
1101
|
+
contextPercent: contextUsage?.percent ?? null,
|
|
1102
|
+
contextWindow: contextUsage?.contextWindow ?? s.cmdCtx?.model?.contextWindow ?? null,
|
|
1103
|
+
completedSlices,
|
|
1104
|
+
totalSlices,
|
|
1105
|
+
allMilestonesComplete: options.completionWidget.allMilestonesComplete,
|
|
1106
|
+
basePath: s.originalBasePath || s.basePath || null,
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
815
1109
|
// ── Step 9: Cmux sidebar / event log ──
|
|
816
1110
|
try {
|
|
817
1111
|
pi?.events.emit(CMUX_CHANNELS.SIDEBAR, { action: "clear", preferences: loadedPreferences });
|
|
@@ -902,9 +1196,21 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
902
1196
|
resetProactiveHealing();
|
|
903
1197
|
// UI cleanup
|
|
904
1198
|
ctx?.ui.setStatus("gsd-auto", undefined);
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1199
|
+
if (!preserveCompletionSurface) {
|
|
1200
|
+
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
1201
|
+
const status = reason?.startsWith("Blocked:") ? "blocked" : reason?.toLowerCase().includes("fail") ? "failed" : "stopped";
|
|
1202
|
+
setLifecycleOutcome(ctx, {
|
|
1203
|
+
status,
|
|
1204
|
+
title: status === "blocked" ? "Auto-mode blocked" : status === "failed" ? "Auto-mode stopped with an issue" : "Auto-mode stopped",
|
|
1205
|
+
detail: reason ?? "Auto-mode stopped.",
|
|
1206
|
+
nextAction: status === "blocked"
|
|
1207
|
+
? "Fix the blocker, then run /gsd auto to resume."
|
|
1208
|
+
: "Run /gsd status for the current project state, or /gsd auto to continue.",
|
|
1209
|
+
commands: ["/gsd status for overview", "/gsd auto to run", "/gsd visualize to inspect", "/gsd notifications for history"],
|
|
1210
|
+
});
|
|
1211
|
+
if (ctx)
|
|
1212
|
+
initHealthWidget(ctx);
|
|
1213
|
+
}
|
|
908
1214
|
restoreProjectRootEnv();
|
|
909
1215
|
restoreMilestoneLockEnv();
|
|
910
1216
|
// Drop the active-tool baseline so a subsequent /gsd auto run on the
|
|
@@ -920,9 +1226,14 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
920
1226
|
debugLog("stop-orchestration-stop", { error: err instanceof Error ? err.message : String(err) });
|
|
921
1227
|
}
|
|
922
1228
|
// Reset all session state in one call
|
|
923
|
-
s.
|
|
1229
|
+
s.resetAfterStop({ preserveCompletionSurface });
|
|
924
1230
|
}
|
|
925
1231
|
}
|
|
1232
|
+
export function _selectStopAutoWorktreeExit(args) {
|
|
1233
|
+
if (!args.currentMilestoneId || args.milestoneMergedInPhases)
|
|
1234
|
+
return "none";
|
|
1235
|
+
return args.milestoneComplete ? "merge" : "preserve";
|
|
1236
|
+
}
|
|
926
1237
|
/**
|
|
927
1238
|
* Pause auto-mode without destroying state. Context is preserved.
|
|
928
1239
|
* The user can interact with the agent, then `/gsd auto` resumes
|
|
@@ -976,6 +1287,7 @@ export async function pauseAuto(ctx, _pi, _errorContext) {
|
|
|
976
1287
|
// Non-fatal — resume will still work via full bootstrap, just without worktree context
|
|
977
1288
|
logWarning("engine", `paused-session DB write failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
|
|
978
1289
|
}
|
|
1290
|
+
const pausedUnitLabel = currentUnitLabel();
|
|
979
1291
|
// Close out the current unit so its runtime record doesn't stay at "dispatched"
|
|
980
1292
|
if (s.currentUnit && ctx) {
|
|
981
1293
|
try {
|
|
@@ -1023,45 +1335,55 @@ export async function pauseAuto(ctx, _pi, _errorContext) {
|
|
|
1023
1335
|
s.verificationRetryCount.clear();
|
|
1024
1336
|
ctx?.ui.setStatus("gsd-auto", "paused");
|
|
1025
1337
|
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
1338
|
+
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
1339
|
+
setLifecycleOutcome(ctx, {
|
|
1340
|
+
status: "paused",
|
|
1341
|
+
title: `${s.stepMode ? "Step" : "Auto"}-mode paused`,
|
|
1342
|
+
detail: _errorContext?.message ?? "Paused by user request.",
|
|
1343
|
+
nextAction: `Type to steer, or run ${resumeCmd} to resume.`,
|
|
1344
|
+
commands: [resumeCmd, "/gsd status for overview", "/gsd notifications for history"],
|
|
1345
|
+
unitLabel: pausedUnitLabel,
|
|
1346
|
+
});
|
|
1026
1347
|
if (ctx)
|
|
1027
1348
|
initHealthWidget(ctx);
|
|
1028
|
-
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
1029
1349
|
ctx?.ui.notify(`${s.stepMode ? "Step" : "Auto"}-mode paused (Escape). Type to interact, or ${resumeCmd} to resume.`, "info");
|
|
1030
1350
|
}
|
|
1031
1351
|
/**
|
|
1032
|
-
* Build a
|
|
1033
|
-
*
|
|
1352
|
+
* Build a WorktreeLifecycle Module wrapping the current session.
|
|
1353
|
+
*
|
|
1354
|
+
* Per ADR-016, the Lifecycle Module is the typed-Interface owner of milestone
|
|
1355
|
+
* entry/exit/merge verbs and calls Projection on lifecycle transitions. The
|
|
1356
|
+
* deps bag is intentionally focused — Lifecycle does not see the wider auto-
|
|
1357
|
+
* mode dependency graph.
|
|
1358
|
+
*/
|
|
1359
|
+
/**
|
|
1360
|
+
* Construct a `WorktreeLifecycleDeps` bag without binding to any session.
|
|
1361
|
+
*
|
|
1362
|
+
* Exported so session-less callers (currently `parallel-merge.ts`) can build
|
|
1363
|
+
* the same deps and call `mergeMilestoneStandalone` through the Worktree
|
|
1364
|
+
* Lifecycle Module instead of bypassing it (ADR-016 phase 2 / A2).
|
|
1034
1365
|
*/
|
|
1035
|
-
function
|
|
1366
|
+
export function buildWorktreeLifecycleDeps() {
|
|
1367
|
+
// ADR-016 phase 2 / C-track close-out:
|
|
1368
|
+
// C1 (#5624) — fs + git-CLI primitives inlined
|
|
1369
|
+
// C2 (#5625) — worktree-manager helpers inlined
|
|
1370
|
+
// C3 (#5626) — cache + preferences + paths inlined
|
|
1371
|
+
// C4 (#5627) — GitServiceImpl constructor → gitServiceFactory
|
|
1372
|
+
//
|
|
1373
|
+
// Final WorktreeLifecycleDeps shape: 3 fields (gitServiceFactory,
|
|
1374
|
+
// worktreeProjection, mergeMilestoneToMain). Down from 18 at slice-7
|
|
1375
|
+
// closure.
|
|
1036
1376
|
return {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1377
|
+
gitServiceFactory: (basePath) => {
|
|
1378
|
+
const gitConfig = loadEffectiveGSDPreferences()?.preferences?.git ?? {};
|
|
1379
|
+
return new GitServiceImpl(basePath, gitConfig);
|
|
1380
|
+
},
|
|
1381
|
+
worktreeProjection: new WorktreeStateProjection(),
|
|
1040
1382
|
mergeMilestoneToMain,
|
|
1041
|
-
syncWorktreeStateBack,
|
|
1042
|
-
teardownAutoWorktree,
|
|
1043
|
-
createAutoWorktree,
|
|
1044
|
-
enterAutoWorktree,
|
|
1045
|
-
enterBranchModeForMilestone,
|
|
1046
|
-
getAutoWorktreePath,
|
|
1047
|
-
autoCommitCurrentBranch,
|
|
1048
|
-
getCurrentBranch,
|
|
1049
|
-
autoWorktreeBranch,
|
|
1050
|
-
resolveMilestoneFile,
|
|
1051
|
-
readFileSync: (path, encoding) => readFileSync(path, encoding),
|
|
1052
|
-
GitServiceImpl: GitServiceImpl,
|
|
1053
|
-
loadEffectiveGSDPreferences: loadEffectiveGSDPreferences,
|
|
1054
|
-
invalidateAllCaches,
|
|
1055
|
-
captureIntegrationBranch,
|
|
1056
1383
|
};
|
|
1057
1384
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
* Cheap to construct — it's just a thin wrapper over `s` + deps.
|
|
1061
|
-
* Used by stopAuto(), resume path, and buildLoopDeps().
|
|
1062
|
-
*/
|
|
1063
|
-
function buildResolver() {
|
|
1064
|
-
return new WorktreeResolver(s, buildResolverDeps());
|
|
1385
|
+
function buildLifecycle() {
|
|
1386
|
+
return new WorktreeLifecycle(s, buildWorktreeLifecycleDeps());
|
|
1065
1387
|
}
|
|
1066
1388
|
/**
|
|
1067
1389
|
* Thin entry glue for the new Auto Orchestration module.
|
|
@@ -1074,9 +1396,26 @@ export function createWiredAutoOrchestrationModule(ctx, _pi, dispatchBasePath, r
|
|
|
1074
1396
|
const flowId = `auto-orchestrator-${Date.now()}`;
|
|
1075
1397
|
let seq = 0;
|
|
1076
1398
|
const deps = {
|
|
1399
|
+
stateReconciliation: {
|
|
1400
|
+
async reconcileBeforeDispatch() {
|
|
1401
|
+
const result = await reconcileBeforeDispatch(dispatchBasePath);
|
|
1402
|
+
if (!result.ok) {
|
|
1403
|
+
return {
|
|
1404
|
+
ok: false,
|
|
1405
|
+
reason: result.reason,
|
|
1406
|
+
stateSnapshot: result.stateSnapshot,
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
return {
|
|
1410
|
+
ok: true,
|
|
1411
|
+
reason: result.repaired.join(", "),
|
|
1412
|
+
stateSnapshot: result.stateSnapshot,
|
|
1413
|
+
};
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1077
1416
|
dispatch: {
|
|
1078
|
-
async decideNextUnit() {
|
|
1079
|
-
const state =
|
|
1417
|
+
async decideNextUnit(input) {
|
|
1418
|
+
const state = input.stateSnapshot;
|
|
1080
1419
|
const active = state.activeMilestone;
|
|
1081
1420
|
if (!active)
|
|
1082
1421
|
return null;
|
|
@@ -1100,12 +1439,48 @@ export function createWiredAutoOrchestrationModule(ctx, _pi, dispatchBasePath, r
|
|
|
1100
1439
|
},
|
|
1101
1440
|
recovery: {
|
|
1102
1441
|
async classifyAndRecover(input) {
|
|
1103
|
-
const
|
|
1104
|
-
return { action:
|
|
1442
|
+
const recovery = classifyFailure(input);
|
|
1443
|
+
return { action: recovery.action, reason: recovery.reason };
|
|
1444
|
+
},
|
|
1445
|
+
},
|
|
1446
|
+
toolContract: {
|
|
1447
|
+
async compileUnitToolContract(unitType) {
|
|
1448
|
+
const result = compileUnitToolContract(unitType);
|
|
1449
|
+
if (!result.ok)
|
|
1450
|
+
return { ok: false, reason: result.detail };
|
|
1451
|
+
return { ok: true, reason: result.contract.validationRules.join(", ") };
|
|
1105
1452
|
},
|
|
1106
1453
|
},
|
|
1107
1454
|
worktree: {
|
|
1108
|
-
async prepareForUnit() {
|
|
1455
|
+
async prepareForUnit(unitType, unitId) {
|
|
1456
|
+
const manifest = resolveManifest(unitType);
|
|
1457
|
+
if (!manifest) {
|
|
1458
|
+
return {
|
|
1459
|
+
ok: false,
|
|
1460
|
+
reason: `No Unit manifest is registered for ${unitType}`,
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
const writeScope = manifest.tools.mode === "all" || manifest.tools.mode === "docs"
|
|
1464
|
+
? "source-writing"
|
|
1465
|
+
: "planning-only";
|
|
1466
|
+
const safety = createWorktreeSafetyModule();
|
|
1467
|
+
const snapshot = await deriveState(dispatchBasePath);
|
|
1468
|
+
const milestoneId = snapshot.activeMilestone?.id ?? null;
|
|
1469
|
+
const expectedBranch = milestoneId ? autoWorktreeBranch(milestoneId) : null;
|
|
1470
|
+
const result = safety.validateUnitRoot({
|
|
1471
|
+
unitType,
|
|
1472
|
+
unitId,
|
|
1473
|
+
writeScope,
|
|
1474
|
+
projectRoot: runtimeBasePath,
|
|
1475
|
+
unitRoot: dispatchBasePath,
|
|
1476
|
+
milestoneId,
|
|
1477
|
+
expectedBranch,
|
|
1478
|
+
});
|
|
1479
|
+
if (!result.ok) {
|
|
1480
|
+
return { ok: false, reason: `${result.kind}: ${result.reason}` };
|
|
1481
|
+
}
|
|
1482
|
+
return { ok: true, reason: result.kind };
|
|
1483
|
+
},
|
|
1109
1484
|
async syncAfterUnit() { },
|
|
1110
1485
|
async cleanupOnStop() { },
|
|
1111
1486
|
},
|
|
@@ -1199,6 +1574,7 @@ function buildLoopDeps(pi) {
|
|
|
1199
1574
|
// (resolveDispatch, runPreDispatchHooks, etc.) delegate to the registry.
|
|
1200
1575
|
initRegistry(convertDispatchRules(DISPATCH_RULES));
|
|
1201
1576
|
const cmux = makeCmuxEmitters(pi);
|
|
1577
|
+
const worktreeProjection = new WorktreeStateProjection();
|
|
1202
1578
|
return {
|
|
1203
1579
|
lockBase,
|
|
1204
1580
|
buildSnapshotOpts,
|
|
@@ -1218,8 +1594,8 @@ function buildLoopDeps(pi) {
|
|
|
1218
1594
|
loadEffectiveGSDPreferences,
|
|
1219
1595
|
// Pre-dispatch health gate
|
|
1220
1596
|
preDispatchHealthGate,
|
|
1221
|
-
// Worktree
|
|
1222
|
-
|
|
1597
|
+
// Worktree state projection (ADR-016 — single Module Interface)
|
|
1598
|
+
worktreeProjection,
|
|
1223
1599
|
// Resource version guard
|
|
1224
1600
|
checkResourcesStale,
|
|
1225
1601
|
// Session lock
|
|
@@ -1231,7 +1607,6 @@ function buildLoopDeps(pi) {
|
|
|
1231
1607
|
pruneQueueOrder,
|
|
1232
1608
|
isInAutoWorktree,
|
|
1233
1609
|
shouldUseWorktreeIsolation,
|
|
1234
|
-
mergeMilestoneToMain,
|
|
1235
1610
|
teardownAutoWorktree,
|
|
1236
1611
|
createAutoWorktree,
|
|
1237
1612
|
captureIntegrationBranch,
|
|
@@ -1280,8 +1655,9 @@ function buildLoopDeps(pi) {
|
|
|
1280
1655
|
atomicWriteSync,
|
|
1281
1656
|
// Git
|
|
1282
1657
|
GitServiceImpl: GitServiceImpl,
|
|
1283
|
-
//
|
|
1284
|
-
|
|
1658
|
+
// Worktree Lifecycle Module (ADR-016 — single Module Interface for the
|
|
1659
|
+
// milestone create/enter/exit/merge verbs)
|
|
1660
|
+
lifecycle: buildLifecycle(),
|
|
1285
1661
|
// Post-unit processing
|
|
1286
1662
|
postUnitPreVerification,
|
|
1287
1663
|
runPostUnitVerification,
|
|
@@ -1500,7 +1876,12 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1500
1876
|
s.verbose = verboseMode;
|
|
1501
1877
|
s.stepMode = requestedStepMode;
|
|
1502
1878
|
s.cmdCtx = ctx;
|
|
1503
|
-
|
|
1879
|
+
// ADR-016 phase 2 / B2 (#5620): bootstrap basePath transition before
|
|
1880
|
+
// the resume path consults persisted worktree state. Defensive about
|
|
1881
|
+
// s.originalBasePath — the meta-restore above (line 2003 / 2055) may
|
|
1882
|
+
// have already populated it from paused metadata; the verb preserves
|
|
1883
|
+
// that value.
|
|
1884
|
+
buildLifecycle().adoptSessionRoot(base);
|
|
1504
1885
|
// ── Resume worktree: if the paused session was inside a milestone worktree,
|
|
1505
1886
|
// apply that path as the dispatch basePath immediately (#3723).
|
|
1506
1887
|
// This ensures the dispatch loop runs from the worktree directory even when
|
|
@@ -1512,9 +1893,8 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1512
1893
|
if (resumeWorktreePath && !existsSync(resumeWorktreePath)) {
|
|
1513
1894
|
logWarning("session", `Worktree was expected at ${resumeWorktreePath} but is missing. Continuing in project-root mode. To restart with a fresh worktree, run /gsd-debug or recreate the milestone.`, { file: "auto.ts", milestoneId: s.currentMilestoneId ?? "" });
|
|
1514
1895
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
}
|
|
1896
|
+
// ADR-016 phase 2 / B3 (#5621): paused-resume worktree-path adoption.
|
|
1897
|
+
buildLifecycle().resumeFromPausedSession(base, resumeWorktreePath);
|
|
1518
1898
|
// Rebuild scope now that s.basePath reflects the actual worktree (or project root).
|
|
1519
1899
|
rebuildScope(s.basePath, s.currentMilestoneId);
|
|
1520
1900
|
// Ensure the workflow-logger audit log is pinned to the project root
|
|
@@ -1540,9 +1920,14 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1540
1920
|
!isInAutoWorktree(s.basePath) &&
|
|
1541
1921
|
!detectWorktreeName(s.basePath) &&
|
|
1542
1922
|
!detectWorktreeName(s.originalBasePath)) {
|
|
1543
|
-
|
|
1923
|
+
const enterResult = buildLifecycle().enterMilestone(s.currentMilestoneId, {
|
|
1544
1924
|
notify: ctx.ui.notify.bind(ctx.ui),
|
|
1545
1925
|
});
|
|
1926
|
+
if (!enterResult.ok && enterResult.reason === "lease-conflict") {
|
|
1927
|
+
ctx.ui.notify(`Cannot resume milestone ${s.currentMilestoneId}: lease is held by another worker.`, "error");
|
|
1928
|
+
await stopAuto(ctx, pi, "lease-conflict during resume");
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1546
1931
|
// s.basePath may have been updated to a worktree path by enterMilestone.
|
|
1547
1932
|
rebuildScope(s.basePath, s.currentMilestoneId);
|
|
1548
1933
|
}
|
|
@@ -1559,16 +1944,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1559
1944
|
// tree; deployed extensions live at ~/.gsd/agent/extensions/gsd/ where the
|
|
1560
1945
|
// relative path resolves to ~/.gsd/agent/resource-loader.js which doesn't exist.
|
|
1561
1946
|
// Using GSD_PKG_ROOT constructs a correct absolute path in both contexts (#3949).
|
|
1562
|
-
|
|
1563
|
-
const pkgRoot = process.env.GSD_PKG_ROOT;
|
|
1564
|
-
const resourceLoaderPath = pkgRoot
|
|
1565
|
-
? pathToFileURL(join(pkgRoot, "dist", "resource-loader.js")).href
|
|
1566
|
-
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
1567
|
-
const { initResources } = await import(resourceLoaderPath);
|
|
1568
|
-
initResources(agentDir);
|
|
1569
|
-
// Open the project DB before rebuild/derive so resume uses DB-backed
|
|
1570
|
-
// state instead of falling back to stale markdown parsing (#2940).
|
|
1571
|
-
await openProjectDbIfPresent(s.basePath);
|
|
1947
|
+
await refreshResumeResourcesAndDb(s.basePath);
|
|
1572
1948
|
try {
|
|
1573
1949
|
await rebuildState(s.basePath);
|
|
1574
1950
|
pi.events.emit(CMUX_CHANNELS.SIDEBAR, { action: "sync", preferences: loadEffectiveGSDPreferences(s.basePath || undefined)?.preferences, state: await deriveState(s.basePath) });
|
|
@@ -1621,7 +1997,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1621
1997
|
runKernelLoop: runUokKernelLoop,
|
|
1622
1998
|
runLegacyLoop: runLegacyAutoLoop,
|
|
1623
1999
|
});
|
|
1624
|
-
cleanupAfterLoopExit(ctx);
|
|
2000
|
+
await cleanupAfterLoopExit(ctx);
|
|
1625
2001
|
return;
|
|
1626
2002
|
}
|
|
1627
2003
|
// ── Fresh start path — delegated to auto-start.ts ──
|
|
@@ -1629,8 +2005,12 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1629
2005
|
shouldUseWorktreeIsolation,
|
|
1630
2006
|
registerSigtermHandler,
|
|
1631
2007
|
lockBase,
|
|
1632
|
-
|
|
2008
|
+
buildLifecycle,
|
|
1633
2009
|
};
|
|
2010
|
+
// Register the worker before bootstrap enters a milestone worktree.
|
|
2011
|
+
// This ensures enterMilestone can claim a lease and seed dispatch claims
|
|
2012
|
+
// for crash-recovery fidelity (#5405).
|
|
2013
|
+
registerAutoWorkerForSession(s, base);
|
|
1634
2014
|
const ready = await bootstrapAutoSession(s, ctx, pi, base, verboseMode, requestedStepMode, bootstrapDeps, freshStartAssessment);
|
|
1635
2015
|
if (!ready)
|
|
1636
2016
|
return;
|
|
@@ -1664,7 +2044,7 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1664
2044
|
runKernelLoop: runUokKernelLoop,
|
|
1665
2045
|
runLegacyLoop: runLegacyAutoLoop,
|
|
1666
2046
|
});
|
|
1667
|
-
cleanupAfterLoopExit(ctx);
|
|
2047
|
+
await cleanupAfterLoopExit(ctx);
|
|
1668
2048
|
}
|
|
1669
2049
|
// describeNextUnit is imported from auto-dashboard.ts and re-exported
|
|
1670
2050
|
export { describeNextUnit } from "./auto-dashboard.js";
|
|
@@ -1737,7 +2117,12 @@ export async function dispatchHookUnit(ctx, pi, hookName, triggerUnitType, trigg
|
|
|
1737
2117
|
s.currentUnit = null;
|
|
1738
2118
|
s.pendingQuickTasks = [];
|
|
1739
2119
|
}
|
|
1740
|
-
|
|
2120
|
+
// ADR-016 phase 2 / B2 (#5620): hook-trigger basePath transition. Treats
|
|
2121
|
+
// the trigger as a bootstrap variant — if the session is fresh,
|
|
2122
|
+
// `originalBasePath` gets set to `targetBasePath`; if the session was
|
|
2123
|
+
// already active with an established `originalBasePath`, the verb
|
|
2124
|
+
// preserves it.
|
|
2125
|
+
buildLifecycle().adoptSessionRoot(targetBasePath);
|
|
1741
2126
|
if (!s.orchestration) {
|
|
1742
2127
|
ensureOrchestrationModule(ctx, pi, s.basePath);
|
|
1743
2128
|
}
|
|
@@ -1748,28 +2133,7 @@ export async function dispatchHookUnit(ctx, pi, hookName, triggerUnitType, trigg
|
|
|
1748
2133
|
id: triggerUnitId,
|
|
1749
2134
|
startedAt: hookStartedAt,
|
|
1750
2135
|
};
|
|
1751
|
-
|
|
1752
|
-
// newSession() snapshots process.cwd() during construction; chdir-ing
|
|
1753
|
-
// afterward leaves the session rooted to whatever cwd was when the call
|
|
1754
|
-
// was made. Must be synchronous — no awaits between chdir and newSession.
|
|
1755
|
-
try {
|
|
1756
|
-
if (process.cwd() !== s.basePath)
|
|
1757
|
-
process.chdir(s.basePath);
|
|
1758
|
-
}
|
|
1759
|
-
catch (err) {
|
|
1760
|
-
const msg = `Failed to chdir before hook newSession (basePath: ${s.basePath}): ${err instanceof Error ? err.message : String(err)}`;
|
|
1761
|
-
logWarning("engine", msg, { file: "auto.ts", basePath: s.basePath, error: err instanceof Error ? err.message : String(err) });
|
|
1762
|
-
ctx.ui.notify(`${msg}. Cancelling hook dispatch to avoid running in the wrong directory.`, "error");
|
|
1763
|
-
if (wasActive) {
|
|
1764
|
-
s.basePath = previousBasePath;
|
|
1765
|
-
s.currentUnit = previousCurrentUnit;
|
|
1766
|
-
}
|
|
1767
|
-
else {
|
|
1768
|
-
s.reset();
|
|
1769
|
-
}
|
|
1770
|
-
return false;
|
|
1771
|
-
}
|
|
1772
|
-
const result = await s.cmdCtx.newSession();
|
|
2136
|
+
const result = await s.cmdCtx.newSession({ workspaceRoot: s.basePath });
|
|
1773
2137
|
if (result.cancelled) {
|
|
1774
2138
|
await stopAuto(ctx, pi);
|
|
1775
2139
|
return false;
|