gsd-pi 2.33.1-dev.29a8268 → 2.33.1-dev.bf822e6
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/dist/cli.js +16 -0
- package/dist/resource-loader.d.ts +2 -0
- package/dist/resource-loader.js +39 -4
- package/dist/resources/extensions/ask-user-questions.js +217 -0
- package/dist/resources/extensions/async-jobs/async-bash-tool.js +180 -0
- package/dist/resources/extensions/async-jobs/await-tool.js +90 -0
- package/dist/resources/extensions/async-jobs/cancel-job-tool.js +28 -0
- package/dist/resources/extensions/async-jobs/index.js +119 -0
- package/dist/resources/extensions/async-jobs/job-manager.js +159 -0
- package/dist/resources/extensions/aws-auth/index.js +138 -0
- package/dist/resources/extensions/bg-shell/bg-shell-command.js +182 -0
- package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.js +343 -0
- package/dist/resources/extensions/bg-shell/bg-shell-tool.js +831 -0
- package/dist/resources/extensions/bg-shell/index.js +41 -0
- package/dist/resources/extensions/bg-shell/interaction.js +160 -0
- package/dist/resources/extensions/bg-shell/output-formatter.js +245 -0
- package/dist/resources/extensions/bg-shell/overlay.js +378 -0
- package/dist/resources/extensions/bg-shell/process-manager.js +413 -0
- package/dist/resources/extensions/bg-shell/readiness-detector.js +109 -0
- package/dist/resources/extensions/bg-shell/types.js +96 -0
- package/dist/resources/extensions/bg-shell/utilities.js +50 -0
- package/dist/resources/extensions/browser-tools/capture.js +179 -0
- package/dist/resources/extensions/browser-tools/core.js +899 -0
- package/dist/resources/extensions/browser-tools/{evaluate-helpers.ts → evaluate-helpers.js} +0 -1
- package/dist/resources/extensions/browser-tools/index.js +123 -0
- package/dist/resources/extensions/browser-tools/lifecycle.js +222 -0
- package/dist/resources/extensions/browser-tools/refs.js +254 -0
- package/dist/resources/extensions/browser-tools/settle.js +173 -0
- package/dist/resources/extensions/browser-tools/state.js +126 -0
- package/dist/resources/extensions/browser-tools/tools/action-cache.js +179 -0
- package/dist/resources/extensions/browser-tools/tools/assertions.js +320 -0
- package/dist/resources/extensions/browser-tools/tools/codegen.js +242 -0
- package/dist/resources/extensions/browser-tools/tools/device.js +162 -0
- package/dist/resources/extensions/browser-tools/tools/extract.js +191 -0
- package/dist/resources/extensions/browser-tools/tools/forms.js +710 -0
- package/dist/resources/extensions/browser-tools/tools/injection-detect.js +178 -0
- package/dist/resources/extensions/browser-tools/tools/inspection.js +426 -0
- package/dist/resources/extensions/browser-tools/tools/intent.js +556 -0
- package/dist/resources/extensions/browser-tools/tools/interaction.js +776 -0
- package/dist/resources/extensions/browser-tools/tools/navigation.js +208 -0
- package/dist/resources/extensions/browser-tools/tools/network-mock.js +194 -0
- package/dist/resources/extensions/browser-tools/tools/pages.js +280 -0
- package/dist/resources/extensions/browser-tools/tools/pdf.js +74 -0
- package/dist/resources/extensions/browser-tools/tools/refs.js +485 -0
- package/dist/resources/extensions/browser-tools/tools/screenshot.js +87 -0
- package/dist/resources/extensions/browser-tools/tools/session.js +375 -0
- package/dist/resources/extensions/browser-tools/tools/state-persistence.js +180 -0
- package/dist/resources/extensions/browser-tools/tools/visual-diff.js +174 -0
- package/dist/resources/extensions/browser-tools/tools/wait.js +201 -0
- package/dist/resources/extensions/browser-tools/tools/zoom.js +90 -0
- package/dist/resources/extensions/browser-tools/utils.js +490 -0
- package/dist/resources/extensions/context7/index.js +337 -0
- package/dist/resources/extensions/get-secrets-from-user.js +492 -0
- package/dist/resources/extensions/google-search/index.js +373 -0
- package/dist/resources/extensions/gsd/activity-log.js +146 -0
- package/dist/resources/extensions/gsd/atomic-write.js +38 -0
- package/dist/resources/extensions/gsd/auto/session.js +187 -0
- package/dist/resources/extensions/gsd/auto-budget.js +30 -0
- package/dist/resources/extensions/gsd/{auto-constants.ts → auto-constants.js} +0 -1
- package/dist/resources/extensions/gsd/auto-dashboard.js +509 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +180 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +382 -0
- package/dist/resources/extensions/gsd/auto-idempotency.js +106 -0
- package/dist/resources/extensions/gsd/auto-model-selection.js +133 -0
- package/dist/resources/extensions/gsd/auto-observability.js +54 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +495 -0
- package/dist/resources/extensions/gsd/auto-prompts.js +1121 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +550 -0
- package/dist/resources/extensions/gsd/auto-start.js +393 -0
- package/dist/resources/extensions/gsd/auto-stuck-detection.js +165 -0
- package/dist/resources/extensions/gsd/{auto-supervisor.ts → auto-supervisor.js} +25 -33
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +183 -0
- package/dist/resources/extensions/gsd/auto-timers.js +181 -0
- package/dist/resources/extensions/gsd/auto-tool-tracking.js +50 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +30 -0
- package/dist/resources/extensions/gsd/auto-verification.js +209 -0
- package/dist/resources/extensions/gsd/auto-worktree.js +665 -0
- package/dist/resources/extensions/gsd/auto.js +1495 -0
- package/dist/resources/extensions/gsd/{cache.ts → cache.js} +5 -7
- package/dist/resources/extensions/gsd/captures.js +348 -0
- package/dist/resources/extensions/gsd/claude-import.js +540 -0
- package/dist/resources/extensions/gsd/collision-diagnostics.js +226 -0
- package/dist/resources/extensions/gsd/commands-bootstrap.js +223 -0
- package/dist/resources/extensions/gsd/commands-config.js +89 -0
- package/dist/resources/extensions/gsd/commands-extensions.js +259 -0
- package/dist/resources/extensions/gsd/commands-handlers.js +310 -0
- package/dist/resources/extensions/gsd/commands-inspect.js +70 -0
- package/dist/resources/extensions/gsd/commands-logs.js +468 -0
- package/dist/resources/extensions/gsd/commands-maintenance.js +185 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +660 -0
- package/dist/resources/extensions/gsd/commands-workflow-templates.js +408 -0
- package/dist/resources/extensions/gsd/commands.js +1024 -0
- package/dist/resources/extensions/gsd/complexity-classifier.js +257 -0
- package/dist/resources/extensions/gsd/{constants.ts → constants.js} +0 -6
- package/dist/resources/extensions/gsd/context-budget.js +187 -0
- package/dist/resources/extensions/gsd/context-store.js +165 -0
- package/dist/resources/extensions/gsd/crash-recovery.js +110 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.js +562 -0
- package/dist/resources/extensions/gsd/db-writer.js +298 -0
- package/dist/resources/extensions/gsd/debug-logger.js +161 -0
- package/dist/resources/extensions/gsd/detection.js +373 -0
- package/dist/resources/extensions/gsd/diff-context.js +168 -0
- package/dist/resources/extensions/gsd/dispatch-guard.js +76 -0
- package/dist/resources/extensions/gsd/doctor-checks.js +563 -0
- package/dist/resources/extensions/gsd/doctor-environment.js +429 -0
- package/dist/resources/extensions/gsd/doctor-format.js +71 -0
- package/dist/resources/extensions/gsd/doctor-proactive.js +239 -0
- package/dist/resources/extensions/gsd/doctor-providers.js +292 -0
- package/dist/resources/extensions/gsd/doctor-types.js +12 -0
- package/dist/resources/extensions/gsd/doctor.js +672 -0
- package/dist/resources/extensions/gsd/error-utils.js +6 -0
- package/dist/resources/extensions/gsd/{errors.ts → errors.js} +6 -11
- package/dist/resources/extensions/gsd/exit-command.js +11 -0
- package/dist/resources/extensions/gsd/{export-html.ts → export-html.js} +482 -614
- package/dist/resources/extensions/gsd/export.js +268 -0
- package/dist/resources/extensions/gsd/file-watcher.js +76 -0
- package/dist/resources/extensions/gsd/files.js +937 -0
- package/dist/resources/extensions/gsd/forensics.js +511 -0
- package/dist/resources/extensions/gsd/{git-constants.ts → git-constants.js} +4 -5
- package/dist/resources/extensions/gsd/git-self-heal.js +113 -0
- package/dist/resources/extensions/gsd/git-service.js +460 -0
- package/dist/resources/extensions/gsd/{gitignore.ts → gitignore.js} +98 -125
- package/dist/resources/extensions/gsd/gsd-db.js +590 -0
- package/dist/resources/extensions/gsd/guided-flow-queue.js +366 -0
- package/dist/resources/extensions/gsd/guided-flow.js +1158 -0
- package/dist/resources/extensions/gsd/health-widget.js +141 -0
- package/dist/resources/extensions/gsd/history.js +118 -0
- package/dist/resources/extensions/gsd/index.js +1250 -0
- package/dist/resources/extensions/gsd/init-wizard.js +479 -0
- package/dist/resources/extensions/gsd/json-persistence.js +62 -0
- package/dist/resources/extensions/gsd/{jsonl-utils.ts → jsonl-utils.js} +10 -7
- package/dist/resources/extensions/gsd/key-manager.js +829 -0
- package/dist/resources/extensions/gsd/marketplace-discovery.js +356 -0
- package/dist/resources/extensions/gsd/md-importer.js +440 -0
- package/dist/resources/extensions/gsd/mechanical-completion.js +351 -0
- package/dist/resources/extensions/gsd/memory-extractor.js +295 -0
- package/dist/resources/extensions/gsd/memory-store.js +351 -0
- package/dist/resources/extensions/gsd/metrics.js +377 -0
- package/dist/resources/extensions/gsd/migrate/command.js +157 -0
- package/dist/resources/extensions/gsd/migrate/index.js +7 -0
- package/dist/resources/extensions/gsd/migrate/parser.js +268 -0
- package/dist/resources/extensions/gsd/migrate/parsers.js +477 -0
- package/dist/resources/extensions/gsd/migrate/preview.js +47 -0
- package/dist/resources/extensions/gsd/migrate/transformer.js +278 -0
- package/dist/resources/extensions/gsd/migrate/types.js +4 -0
- package/dist/resources/extensions/gsd/migrate/validator.js +41 -0
- package/dist/resources/extensions/gsd/migrate/writer.js +477 -0
- package/dist/resources/extensions/gsd/migrate-external.js +130 -0
- package/dist/resources/extensions/gsd/milestone-actions.js +111 -0
- package/dist/resources/extensions/gsd/{milestone-ids.ts → milestone-ids.js} +50 -63
- package/dist/resources/extensions/gsd/model-cost-table.js +48 -0
- package/dist/resources/extensions/gsd/model-router.js +187 -0
- package/dist/resources/extensions/gsd/namespaced-registry.js +322 -0
- package/dist/resources/extensions/gsd/namespaced-resolver.js +176 -0
- package/dist/resources/extensions/gsd/native-git-bridge.js +842 -0
- package/dist/resources/extensions/gsd/native-parser-bridge.js +156 -0
- package/dist/resources/extensions/gsd/notifications.js +58 -0
- package/dist/resources/extensions/gsd/observability-validator.js +398 -0
- package/dist/resources/extensions/gsd/parallel-eligibility.js +182 -0
- package/dist/resources/extensions/gsd/parallel-merge.js +121 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +687 -0
- package/dist/resources/extensions/gsd/paths.js +414 -0
- package/dist/resources/extensions/gsd/plugin-importer.js +254 -0
- package/dist/resources/extensions/gsd/post-unit-hooks.js +433 -0
- package/dist/resources/extensions/gsd/preferences-models.js +294 -0
- package/dist/resources/extensions/gsd/preferences-skills.js +154 -0
- package/dist/resources/extensions/gsd/preferences-types.js +73 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +607 -0
- package/dist/resources/extensions/gsd/preferences.js +325 -0
- package/dist/resources/extensions/gsd/progress-score.js +197 -0
- package/dist/resources/extensions/gsd/prompt-cache-optimizer.js +150 -0
- package/dist/resources/extensions/gsd/prompt-compressor.js +393 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +119 -0
- package/dist/resources/extensions/gsd/prompt-ordering.js +170 -0
- package/dist/resources/extensions/gsd/provider-error-pause.js +60 -0
- package/dist/resources/extensions/gsd/queue-order.js +178 -0
- package/dist/resources/extensions/gsd/queue-reorder-ui.js +234 -0
- package/dist/resources/extensions/gsd/quick.js +230 -0
- package/dist/resources/extensions/gsd/repo-identity.js +187 -0
- package/dist/resources/extensions/gsd/{reports.ts → reports.js} +146 -241
- package/dist/resources/extensions/gsd/{resource-version.ts → resource-version.js} +50 -53
- package/dist/resources/extensions/gsd/roadmap-slices.js +130 -0
- package/dist/resources/extensions/gsd/routing-history.js +210 -0
- package/dist/resources/extensions/gsd/safe-fs.js +52 -0
- package/dist/resources/extensions/gsd/semantic-chunker.js +254 -0
- package/dist/resources/extensions/gsd/session-forensics.js +427 -0
- package/dist/resources/extensions/gsd/session-lock.js +384 -0
- package/dist/resources/extensions/gsd/session-status-io.js +134 -0
- package/dist/resources/extensions/gsd/skill-discovery.js +121 -0
- package/dist/resources/extensions/gsd/skill-health.js +324 -0
- package/dist/resources/extensions/gsd/{skill-telemetry.ts → skill-telemetry.js} +58 -74
- package/dist/resources/extensions/gsd/state.js +653 -0
- package/dist/resources/extensions/gsd/structured-data-formatter.js +97 -0
- package/dist/resources/extensions/gsd/summary-distiller.js +212 -0
- package/dist/resources/extensions/gsd/token-counter.js +54 -0
- package/dist/resources/extensions/gsd/triage-resolution.js +217 -0
- package/dist/resources/extensions/gsd/triage-ui.js +125 -0
- package/dist/resources/extensions/gsd/types.js +4 -0
- package/dist/resources/extensions/gsd/undo.js +210 -0
- package/dist/resources/extensions/gsd/unit-id.js +7 -0
- package/dist/resources/extensions/gsd/unit-runtime.js +130 -0
- package/dist/resources/extensions/gsd/validate-directory.js +143 -0
- package/dist/resources/extensions/gsd/verification-evidence.js +123 -0
- package/dist/resources/extensions/gsd/verification-gate.js +543 -0
- package/dist/resources/extensions/gsd/visualizer-data.js +612 -0
- package/dist/resources/extensions/gsd/visualizer-overlay.js +501 -0
- package/dist/resources/extensions/gsd/visualizer-views.js +893 -0
- package/dist/resources/extensions/gsd/workflow-templates.js +188 -0
- package/dist/resources/extensions/gsd/workspace-index.js +139 -0
- package/dist/resources/extensions/gsd/worktree-command-bootstrap.js +40 -0
- package/dist/resources/extensions/gsd/worktree-command.js +676 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +359 -0
- package/dist/resources/extensions/gsd/worktree.js +236 -0
- package/dist/resources/extensions/mac-tools/index.js +768 -0
- package/dist/resources/extensions/mcp-client/index.js +363 -0
- package/dist/resources/extensions/package.json +3 -0
- package/dist/resources/extensions/remote-questions/config.js +70 -0
- package/dist/resources/extensions/remote-questions/discord-adapter.js +134 -0
- package/dist/resources/extensions/remote-questions/format.js +234 -0
- package/dist/resources/extensions/remote-questions/http-client.js +43 -0
- package/dist/resources/extensions/remote-questions/manager.js +156 -0
- package/dist/resources/extensions/remote-questions/{mod.ts → mod.js} +1 -10
- package/dist/resources/extensions/remote-questions/notify.js +89 -0
- package/dist/resources/extensions/remote-questions/remote-command.js +453 -0
- package/dist/resources/extensions/remote-questions/slack-adapter.js +123 -0
- package/dist/resources/extensions/remote-questions/status.js +25 -0
- package/dist/resources/extensions/remote-questions/store.js +70 -0
- package/dist/resources/extensions/remote-questions/telegram-adapter.js +123 -0
- package/dist/resources/extensions/remote-questions/types.js +5 -0
- package/dist/resources/extensions/search-the-web/cache.js +74 -0
- package/dist/resources/extensions/search-the-web/command-search-provider.js +79 -0
- package/dist/resources/extensions/search-the-web/format.js +161 -0
- package/dist/resources/extensions/search-the-web/http.js +178 -0
- package/dist/resources/extensions/search-the-web/index.js +41 -0
- package/dist/resources/extensions/search-the-web/native-search.js +166 -0
- package/dist/resources/extensions/search-the-web/provider.js +143 -0
- package/dist/resources/extensions/search-the-web/tavily.js +82 -0
- package/dist/resources/extensions/search-the-web/tool-fetch-page.js +452 -0
- package/dist/resources/extensions/search-the-web/tool-llm-context.js +455 -0
- package/dist/resources/extensions/search-the-web/tool-search.js +482 -0
- package/dist/resources/extensions/search-the-web/url-utils.js +121 -0
- package/dist/resources/extensions/shared/confirm-ui.js +96 -0
- package/dist/resources/extensions/shared/{format-utils.ts → format-utils.js} +85 -91
- package/dist/resources/extensions/shared/frontmatter.js +109 -0
- package/dist/resources/extensions/shared/interview-ui.js +569 -0
- package/dist/resources/extensions/shared/{mod.ts → mod.js} +2 -24
- package/dist/resources/extensions/shared/next-action-ui.js +168 -0
- package/dist/resources/extensions/shared/{path-display.ts → path-display.js} +2 -3
- package/dist/resources/extensions/shared/sanitize.js +17 -0
- package/dist/resources/extensions/shared/terminal.js +21 -0
- package/dist/resources/extensions/shared/ui.js +245 -0
- package/dist/resources/extensions/shared/wizard-ui.js +478 -0
- package/dist/resources/extensions/slash-commands/audit.js +72 -0
- package/dist/resources/extensions/slash-commands/clear.js +8 -0
- package/dist/resources/extensions/slash-commands/create-extension.js +264 -0
- package/dist/resources/extensions/slash-commands/create-slash-command.js +208 -0
- package/dist/resources/extensions/slash-commands/index.js +10 -0
- package/dist/resources/extensions/subagent/agents.js +103 -0
- package/dist/resources/extensions/subagent/index.js +905 -0
- package/dist/resources/extensions/subagent/isolation.js +384 -0
- package/dist/resources/extensions/subagent/worker-registry.js +73 -0
- package/dist/resources/extensions/ttsr/index.js +144 -0
- package/dist/resources/extensions/ttsr/rule-loader.js +70 -0
- package/dist/resources/extensions/ttsr/ttsr-manager.js +380 -0
- package/dist/resources/extensions/universal-config/discovery.js +94 -0
- package/dist/resources/extensions/universal-config/format.js +178 -0
- package/dist/resources/extensions/universal-config/index.js +99 -0
- package/dist/resources/extensions/universal-config/scanners.js +574 -0
- package/dist/resources/extensions/universal-config/tools.js +57 -0
- package/dist/resources/extensions/universal-config/types.js +8 -0
- package/dist/resources/extensions/voice/index.js +247 -0
- package/dist/startup-timings.d.ts +2 -0
- package/dist/startup-timings.js +22 -0
- package/package.json +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +5498 -3645
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +2595 -742
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/src/models.generated.ts +2852 -999
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +9 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +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 +31 -4
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +9 -0
- package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +35 -4
- package/packages/pi-coding-agent/src/index.ts +1 -0
- package/packages/pi-tui/dist/utils.d.ts.map +1 -1
- package/packages/pi-tui/dist/utils.js +32 -2
- package/packages/pi-tui/dist/utils.js.map +1 -1
- package/packages/pi-tui/src/utils.ts +28 -2
- package/src/resources/extensions/bg-shell/index.ts +41 -46
- package/src/resources/extensions/browser-tools/index.ts +156 -67
- package/src/resources/extensions/gsd/auto-verification.ts +20 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +74 -2
- package/src/resources/extensions/gsd/auto.ts +11 -0
- package/src/resources/extensions/gsd/commands-bootstrap.ts +252 -0
- package/src/resources/extensions/gsd/commands.ts +39 -31
- package/src/resources/extensions/gsd/git-service.ts +7 -0
- package/src/resources/extensions/gsd/guided-flow.ts +22 -11
- package/src/resources/extensions/gsd/index.ts +93 -32
- package/src/resources/extensions/gsd/quick.ts +52 -3
- package/src/resources/extensions/gsd/repo-identity.ts +56 -22
- package/src/resources/extensions/gsd/session-lock.ts +6 -0
- package/src/resources/extensions/gsd/tests/loop-regression.test.ts +1 -4
- package/src/resources/extensions/gsd/tests/quick-branch-lifecycle.test.ts +281 -0
- package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/verification-gate.test.ts +65 -0
- package/src/resources/extensions/gsd/types.ts +4 -0
- package/src/resources/extensions/gsd/verification-evidence.ts +1 -1
- package/src/resources/extensions/gsd/verification-gate.ts +23 -2
- package/src/resources/extensions/gsd/worktree-command-bootstrap.ts +46 -0
- package/src/resources/extensions/gsd/worktree-command.ts +17 -11
- package/src/resources/extensions/package.json +3 -0
- package/src/resources/extensions/search-the-web/command-search-provider.ts +1 -1
- package/src/resources/extensions/search-the-web/index.ts +35 -52
- package/src/resources/extensions/search-the-web/tavily.ts +1 -1
- package/dist/resources/extensions/ask-user-questions.ts +0 -290
- package/dist/resources/extensions/async-jobs/async-bash-tool.ts +0 -212
- package/dist/resources/extensions/async-jobs/await-tool.ts +0 -103
- package/dist/resources/extensions/async-jobs/cancel-job-tool.ts +0 -35
- package/dist/resources/extensions/async-jobs/index.ts +0 -141
- package/dist/resources/extensions/async-jobs/job-manager.ts +0 -211
- package/dist/resources/extensions/aws-auth/index.ts +0 -144
- package/dist/resources/extensions/bg-shell/bg-shell-command.ts +0 -219
- package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.ts +0 -400
- package/dist/resources/extensions/bg-shell/bg-shell-tool.ts +0 -985
- package/dist/resources/extensions/bg-shell/index.ts +0 -59
- package/dist/resources/extensions/bg-shell/interaction.ts +0 -198
- package/dist/resources/extensions/bg-shell/output-formatter.ts +0 -279
- package/dist/resources/extensions/bg-shell/overlay.ts +0 -437
- package/dist/resources/extensions/bg-shell/process-manager.ts +0 -464
- package/dist/resources/extensions/bg-shell/readiness-detector.ts +0 -126
- package/dist/resources/extensions/bg-shell/types.ts +0 -303
- package/dist/resources/extensions/bg-shell/utilities.ts +0 -57
- package/dist/resources/extensions/browser-tools/capture.ts +0 -199
- package/dist/resources/extensions/browser-tools/core.ts +0 -1196
- package/dist/resources/extensions/browser-tools/index.ts +0 -71
- package/dist/resources/extensions/browser-tools/lifecycle.ts +0 -270
- package/dist/resources/extensions/browser-tools/refs.ts +0 -264
- package/dist/resources/extensions/browser-tools/settle.ts +0 -197
- package/dist/resources/extensions/browser-tools/state.ts +0 -408
- package/dist/resources/extensions/browser-tools/tools/action-cache.ts +0 -216
- package/dist/resources/extensions/browser-tools/tools/assertions.ts +0 -342
- package/dist/resources/extensions/browser-tools/tools/codegen.ts +0 -274
- package/dist/resources/extensions/browser-tools/tools/device.ts +0 -183
- package/dist/resources/extensions/browser-tools/tools/extract.ts +0 -229
- package/dist/resources/extensions/browser-tools/tools/forms.ts +0 -801
- package/dist/resources/extensions/browser-tools/tools/injection-detect.ts +0 -221
- package/dist/resources/extensions/browser-tools/tools/inspection.ts +0 -492
- package/dist/resources/extensions/browser-tools/tools/intent.ts +0 -614
- package/dist/resources/extensions/browser-tools/tools/interaction.ts +0 -865
- package/dist/resources/extensions/browser-tools/tools/navigation.ts +0 -232
- package/dist/resources/extensions/browser-tools/tools/network-mock.ts +0 -244
- package/dist/resources/extensions/browser-tools/tools/pages.ts +0 -303
- package/dist/resources/extensions/browser-tools/tools/pdf.ts +0 -92
- package/dist/resources/extensions/browser-tools/tools/refs.ts +0 -541
- package/dist/resources/extensions/browser-tools/tools/screenshot.ts +0 -101
- package/dist/resources/extensions/browser-tools/tools/session.ts +0 -400
- package/dist/resources/extensions/browser-tools/tools/state-persistence.ts +0 -202
- package/dist/resources/extensions/browser-tools/tools/visual-diff.ts +0 -209
- package/dist/resources/extensions/browser-tools/tools/wait.ts +0 -247
- package/dist/resources/extensions/browser-tools/tools/zoom.ts +0 -104
- package/dist/resources/extensions/browser-tools/utils.ts +0 -660
- package/dist/resources/extensions/context7/index.ts +0 -428
- package/dist/resources/extensions/get-secrets-from-user.ts +0 -607
- package/dist/resources/extensions/google-search/index.ts +0 -466
- package/dist/resources/extensions/gsd/activity-log.ts +0 -162
- package/dist/resources/extensions/gsd/atomic-write.ts +0 -35
- package/dist/resources/extensions/gsd/auto/session.ts +0 -236
- package/dist/resources/extensions/gsd/auto-budget.ts +0 -32
- package/dist/resources/extensions/gsd/auto-dashboard.ts +0 -626
- package/dist/resources/extensions/gsd/auto-direct-dispatch.ts +0 -224
- package/dist/resources/extensions/gsd/auto-dispatch.ts +0 -409
- package/dist/resources/extensions/gsd/auto-idempotency.ts +0 -151
- package/dist/resources/extensions/gsd/auto-model-selection.ts +0 -179
- package/dist/resources/extensions/gsd/auto-observability.ts +0 -72
- package/dist/resources/extensions/gsd/auto-post-unit.ts +0 -618
- package/dist/resources/extensions/gsd/auto-prompts.ts +0 -1273
- package/dist/resources/extensions/gsd/auto-recovery.ts +0 -578
- package/dist/resources/extensions/gsd/auto-start.ts +0 -483
- package/dist/resources/extensions/gsd/auto-stuck-detection.ts +0 -221
- package/dist/resources/extensions/gsd/auto-timeout-recovery.ts +0 -263
- package/dist/resources/extensions/gsd/auto-timers.ts +0 -224
- package/dist/resources/extensions/gsd/auto-tool-tracking.ts +0 -54
- package/dist/resources/extensions/gsd/auto-unit-closeout.ts +0 -48
- package/dist/resources/extensions/gsd/auto-verification.ts +0 -229
- package/dist/resources/extensions/gsd/auto-worktree.ts +0 -658
- package/dist/resources/extensions/gsd/auto.ts +0 -1834
- package/dist/resources/extensions/gsd/captures.ts +0 -427
- package/dist/resources/extensions/gsd/claude-import.ts +0 -656
- package/dist/resources/extensions/gsd/collision-diagnostics.ts +0 -332
- package/dist/resources/extensions/gsd/commands-config.ts +0 -102
- package/dist/resources/extensions/gsd/commands-extensions.ts +0 -328
- package/dist/resources/extensions/gsd/commands-handlers.ts +0 -395
- package/dist/resources/extensions/gsd/commands-inspect.ts +0 -91
- package/dist/resources/extensions/gsd/commands-logs.ts +0 -536
- package/dist/resources/extensions/gsd/commands-maintenance.ts +0 -206
- package/dist/resources/extensions/gsd/commands-prefs-wizard.ts +0 -780
- package/dist/resources/extensions/gsd/commands-workflow-templates.ts +0 -543
- package/dist/resources/extensions/gsd/commands.ts +0 -1149
- package/dist/resources/extensions/gsd/complexity-classifier.ts +0 -320
- package/dist/resources/extensions/gsd/context-budget.ts +0 -266
- package/dist/resources/extensions/gsd/context-store.ts +0 -195
- package/dist/resources/extensions/gsd/crash-recovery.ts +0 -121
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +0 -681
- package/dist/resources/extensions/gsd/db-writer.ts +0 -360
- package/dist/resources/extensions/gsd/debug-logger.ts +0 -178
- package/dist/resources/extensions/gsd/detection.ts +0 -470
- package/dist/resources/extensions/gsd/diff-context.ts +0 -214
- package/dist/resources/extensions/gsd/dispatch-guard.ts +0 -81
- package/dist/resources/extensions/gsd/doctor-checks.ts +0 -612
- package/dist/resources/extensions/gsd/doctor-environment.ts +0 -497
- package/dist/resources/extensions/gsd/doctor-format.ts +0 -78
- package/dist/resources/extensions/gsd/doctor-proactive.ts +0 -292
- package/dist/resources/extensions/gsd/doctor-providers.ts +0 -343
- package/dist/resources/extensions/gsd/doctor-types.ts +0 -87
- package/dist/resources/extensions/gsd/doctor.ts +0 -722
- package/dist/resources/extensions/gsd/error-utils.ts +0 -6
- package/dist/resources/extensions/gsd/exit-command.ts +0 -18
- package/dist/resources/extensions/gsd/export.ts +0 -317
- package/dist/resources/extensions/gsd/file-watcher.ts +0 -97
- package/dist/resources/extensions/gsd/files.ts +0 -1058
- package/dist/resources/extensions/gsd/forensics.ts +0 -629
- package/dist/resources/extensions/gsd/git-self-heal.ts +0 -127
- package/dist/resources/extensions/gsd/git-service.ts +0 -586
- package/dist/resources/extensions/gsd/gsd-db.ts +0 -685
- package/dist/resources/extensions/gsd/guided-flow-queue.ts +0 -440
- package/dist/resources/extensions/gsd/guided-flow.ts +0 -1303
- package/dist/resources/extensions/gsd/health-widget.ts +0 -167
- package/dist/resources/extensions/gsd/history.ts +0 -143
- package/dist/resources/extensions/gsd/index.ts +0 -1401
- package/dist/resources/extensions/gsd/init-wizard.ts +0 -587
- package/dist/resources/extensions/gsd/json-persistence.ts +0 -67
- package/dist/resources/extensions/gsd/key-manager.ts +0 -996
- package/dist/resources/extensions/gsd/marketplace-discovery.ts +0 -508
- package/dist/resources/extensions/gsd/md-importer.ts +0 -527
- package/dist/resources/extensions/gsd/mechanical-completion.ts +0 -430
- package/dist/resources/extensions/gsd/memory-extractor.ts +0 -352
- package/dist/resources/extensions/gsd/memory-store.ts +0 -441
- package/dist/resources/extensions/gsd/metrics.ts +0 -532
- package/dist/resources/extensions/gsd/migrate/command.ts +0 -219
- package/dist/resources/extensions/gsd/migrate/index.ts +0 -42
- package/dist/resources/extensions/gsd/migrate/parser.ts +0 -323
- package/dist/resources/extensions/gsd/migrate/parsers.ts +0 -539
- package/dist/resources/extensions/gsd/migrate/preview.ts +0 -48
- package/dist/resources/extensions/gsd/migrate/transformer.ts +0 -346
- package/dist/resources/extensions/gsd/migrate/types.ts +0 -370
- package/dist/resources/extensions/gsd/migrate/validator.ts +0 -55
- package/dist/resources/extensions/gsd/migrate/writer.ts +0 -579
- package/dist/resources/extensions/gsd/migrate-external.ts +0 -140
- package/dist/resources/extensions/gsd/milestone-actions.ts +0 -126
- package/dist/resources/extensions/gsd/model-cost-table.ts +0 -65
- package/dist/resources/extensions/gsd/model-router.ts +0 -256
- package/dist/resources/extensions/gsd/namespaced-registry.ts +0 -467
- package/dist/resources/extensions/gsd/namespaced-resolver.ts +0 -307
- package/dist/resources/extensions/gsd/native-git-bridge.ts +0 -1041
- package/dist/resources/extensions/gsd/native-parser-bridge.ts +0 -267
- package/dist/resources/extensions/gsd/notifications.ts +0 -87
- package/dist/resources/extensions/gsd/observability-validator.ts +0 -429
- package/dist/resources/extensions/gsd/parallel-eligibility.ts +0 -233
- package/dist/resources/extensions/gsd/parallel-merge.ts +0 -157
- package/dist/resources/extensions/gsd/parallel-orchestrator.ts +0 -826
- package/dist/resources/extensions/gsd/paths.ts +0 -449
- package/dist/resources/extensions/gsd/plugin-importer.ts +0 -411
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +0 -520
- package/dist/resources/extensions/gsd/preferences-models.ts +0 -329
- package/dist/resources/extensions/gsd/preferences-skills.ts +0 -169
- package/dist/resources/extensions/gsd/preferences-types.ts +0 -229
- package/dist/resources/extensions/gsd/preferences-validation.ts +0 -590
- package/dist/resources/extensions/gsd/preferences.ts +0 -416
- package/dist/resources/extensions/gsd/progress-score.ts +0 -273
- package/dist/resources/extensions/gsd/prompt-cache-optimizer.ts +0 -213
- package/dist/resources/extensions/gsd/prompt-compressor.ts +0 -508
- package/dist/resources/extensions/gsd/prompt-loader.ts +0 -130
- package/dist/resources/extensions/gsd/prompt-ordering.ts +0 -200
- package/dist/resources/extensions/gsd/provider-error-pause.ts +0 -88
- package/dist/resources/extensions/gsd/queue-order.ts +0 -230
- package/dist/resources/extensions/gsd/queue-reorder-ui.ts +0 -276
- package/dist/resources/extensions/gsd/quick.ts +0 -212
- package/dist/resources/extensions/gsd/repo-identity.ts +0 -169
- package/dist/resources/extensions/gsd/roadmap-slices.ts +0 -149
- package/dist/resources/extensions/gsd/routing-history.ts +0 -286
- package/dist/resources/extensions/gsd/safe-fs.ts +0 -47
- package/dist/resources/extensions/gsd/semantic-chunker.ts +0 -336
- package/dist/resources/extensions/gsd/session-forensics.ts +0 -537
- package/dist/resources/extensions/gsd/session-lock.ts +0 -426
- package/dist/resources/extensions/gsd/session-status-io.ts +0 -179
- package/dist/resources/extensions/gsd/skill-discovery.ts +0 -139
- package/dist/resources/extensions/gsd/skill-health.ts +0 -417
- package/dist/resources/extensions/gsd/state.ts +0 -727
- package/dist/resources/extensions/gsd/structured-data-formatter.ts +0 -144
- package/dist/resources/extensions/gsd/summary-distiller.ts +0 -258
- package/dist/resources/extensions/gsd/tests/activity-log.test.ts +0 -213
- package/dist/resources/extensions/gsd/tests/agent-end-retry.test.ts +0 -107
- package/dist/resources/extensions/gsd/tests/all-milestones-complete-merge.test.ts +0 -200
- package/dist/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +0 -50
- package/dist/resources/extensions/gsd/tests/auto-dashboard.test.ts +0 -166
- package/dist/resources/extensions/gsd/tests/auto-dispatch-loop.test.ts +0 -691
- package/dist/resources/extensions/gsd/tests/auto-lock-creation.test.ts +0 -186
- package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +0 -40
- package/dist/resources/extensions/gsd/tests/auto-recovery.test.ts +0 -640
- package/dist/resources/extensions/gsd/tests/auto-reentrancy-guard.test.ts +0 -127
- package/dist/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +0 -302
- package/dist/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +0 -257
- package/dist/resources/extensions/gsd/tests/auto-skip-loop.test.ts +0 -123
- package/dist/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +0 -340
- package/dist/resources/extensions/gsd/tests/auto-worktree.test.ts +0 -167
- package/dist/resources/extensions/gsd/tests/budget-prediction.test.ts +0 -220
- package/dist/resources/extensions/gsd/tests/cache-staleness-regression.test.ts +0 -317
- package/dist/resources/extensions/gsd/tests/captures.test.ts +0 -438
- package/dist/resources/extensions/gsd/tests/claude-import-tui.test.ts +0 -351
- package/dist/resources/extensions/gsd/tests/collect-from-manifest.test.ts +0 -469
- package/dist/resources/extensions/gsd/tests/collision-diagnostics.test.ts +0 -705
- package/dist/resources/extensions/gsd/tests/commands-logs.test.ts +0 -241
- package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +0 -209
- package/dist/resources/extensions/gsd/tests/complexity-classifier.test.ts +0 -181
- package/dist/resources/extensions/gsd/tests/context-budget.test.ts +0 -352
- package/dist/resources/extensions/gsd/tests/context-compression.test.ts +0 -193
- package/dist/resources/extensions/gsd/tests/context-store.test.ts +0 -462
- package/dist/resources/extensions/gsd/tests/continue-here.test.ts +0 -285
- package/dist/resources/extensions/gsd/tests/cost-projection.test.ts +0 -134
- package/dist/resources/extensions/gsd/tests/crash-recovery.test.ts +0 -134
- package/dist/resources/extensions/gsd/tests/dashboard-budget.test.ts +0 -346
- package/dist/resources/extensions/gsd/tests/db-writer.test.ts +0 -602
- package/dist/resources/extensions/gsd/tests/debug-logger.test.ts +0 -185
- package/dist/resources/extensions/gsd/tests/derive-state-db.test.ts +0 -405
- package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +0 -421
- package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +0 -308
- package/dist/resources/extensions/gsd/tests/derive-state.test.ts +0 -788
- package/dist/resources/extensions/gsd/tests/detection.test.ts +0 -398
- package/dist/resources/extensions/gsd/tests/diff-context.test.ts +0 -136
- package/dist/resources/extensions/gsd/tests/discuss-prompt.test.ts +0 -15
- package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +0 -128
- package/dist/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +0 -132
- package/dist/resources/extensions/gsd/tests/dispatch-stall-guard.test.ts +0 -126
- package/dist/resources/extensions/gsd/tests/doctor-environment.test.ts +0 -314
- package/dist/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +0 -245
- package/dist/resources/extensions/gsd/tests/doctor-git.test.ts +0 -344
- package/dist/resources/extensions/gsd/tests/doctor-proactive.test.ts +0 -278
- package/dist/resources/extensions/gsd/tests/doctor-providers.test.ts +0 -298
- package/dist/resources/extensions/gsd/tests/doctor-runtime.test.ts +0 -302
- package/dist/resources/extensions/gsd/tests/doctor.test.ts +0 -652
- package/dist/resources/extensions/gsd/tests/draft-promotion.test.ts +0 -169
- package/dist/resources/extensions/gsd/tests/exit-command.test.ts +0 -50
- package/dist/resources/extensions/gsd/tests/export-html-all.test.ts +0 -105
- package/dist/resources/extensions/gsd/tests/export-html-enhancements.test.ts +0 -378
- package/dist/resources/extensions/gsd/tests/extension-selector-separator.test.ts +0 -144
- package/dist/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +0 -424
- package/dist/resources/extensions/gsd/tests/git-self-heal.test.ts +0 -131
- package/dist/resources/extensions/gsd/tests/git-service.test.ts +0 -1181
- package/dist/resources/extensions/gsd/tests/gsd-db.test.ts +0 -353
- package/dist/resources/extensions/gsd/tests/gsd-inspect.test.ts +0 -125
- package/dist/resources/extensions/gsd/tests/gsd-tools.test.ts +0 -326
- package/dist/resources/extensions/gsd/tests/headless-answers.test.ts +0 -340
- package/dist/resources/extensions/gsd/tests/headless-query.test.ts +0 -162
- package/dist/resources/extensions/gsd/tests/idle-recovery.test.ts +0 -485
- package/dist/resources/extensions/gsd/tests/in-flight-tool-tracking.test.ts +0 -32
- package/dist/resources/extensions/gsd/tests/init-wizard.test.ts +0 -197
- package/dist/resources/extensions/gsd/tests/integration/headless-command.ts +0 -534
- package/dist/resources/extensions/gsd/tests/integration-edge.test.ts +0 -228
- package/dist/resources/extensions/gsd/tests/integration-lifecycle.test.ts +0 -277
- package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +0 -523
- package/dist/resources/extensions/gsd/tests/key-manager.test.ts +0 -414
- package/dist/resources/extensions/gsd/tests/knowledge.test.ts +0 -161
- package/dist/resources/extensions/gsd/tests/loop-regression.test.ts +0 -877
- package/dist/resources/extensions/gsd/tests/manifest-status.test.ts +0 -283
- package/dist/resources/extensions/gsd/tests/marketplace-test-fixtures.ts +0 -91
- package/dist/resources/extensions/gsd/tests/md-importer.test.ts +0 -410
- package/dist/resources/extensions/gsd/tests/mechanical-completion.test.ts +0 -356
- package/dist/resources/extensions/gsd/tests/memory-extractor.test.ts +0 -180
- package/dist/resources/extensions/gsd/tests/memory-leak-guards.test.ts +0 -91
- package/dist/resources/extensions/gsd/tests/memory-store.test.ts +0 -345
- package/dist/resources/extensions/gsd/tests/metrics.test.ts +0 -253
- package/dist/resources/extensions/gsd/tests/migrate-command.test.ts +0 -369
- package/dist/resources/extensions/gsd/tests/migrate-parser.test.ts +0 -757
- package/dist/resources/extensions/gsd/tests/migrate-transformer.test.ts +0 -635
- package/dist/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +0 -414
- package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +0 -303
- package/dist/resources/extensions/gsd/tests/migrate-writer.test.ts +0 -398
- package/dist/resources/extensions/gsd/tests/milestone-transition-worktree.test.ts +0 -147
- package/dist/resources/extensions/gsd/tests/model-cost-table.test.ts +0 -69
- package/dist/resources/extensions/gsd/tests/model-isolation.test.ts +0 -157
- package/dist/resources/extensions/gsd/tests/model-router.test.ts +0 -167
- package/dist/resources/extensions/gsd/tests/must-have-parser.test.ts +0 -291
- package/dist/resources/extensions/gsd/tests/namespaced-registry.test.ts +0 -1027
- package/dist/resources/extensions/gsd/tests/namespaced-resolver.test.ts +0 -671
- package/dist/resources/extensions/gsd/tests/native-has-changes-cache.test.ts +0 -61
- package/dist/resources/extensions/gsd/tests/next-milestone-id.test.ts +0 -23
- package/dist/resources/extensions/gsd/tests/none-mode-gates.test.ts +0 -114
- package/dist/resources/extensions/gsd/tests/notifications.test.ts +0 -67
- package/dist/resources/extensions/gsd/tests/overrides.test.ts +0 -131
- package/dist/resources/extensions/gsd/tests/parallel-budget-atomicity.test.ts +0 -331
- package/dist/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +0 -298
- package/dist/resources/extensions/gsd/tests/parallel-merge.test.ts +0 -468
- package/dist/resources/extensions/gsd/tests/parallel-orchestration.test.ts +0 -685
- package/dist/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +0 -171
- package/dist/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +0 -354
- package/dist/resources/extensions/gsd/tests/park-edge-cases.test.ts +0 -276
- package/dist/resources/extensions/gsd/tests/park-milestone.test.ts +0 -401
- package/dist/resources/extensions/gsd/tests/parsers.test.ts +0 -1704
- package/dist/resources/extensions/gsd/tests/plan-milestone.test.ts +0 -133
- package/dist/resources/extensions/gsd/tests/plan-quality-validator.test.ts +0 -363
- package/dist/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +0 -42
- package/dist/resources/extensions/gsd/tests/plugin-importer-live.test.ts +0 -481
- package/dist/resources/extensions/gsd/tests/plugin-importer.test.ts +0 -1383
- package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +0 -337
- package/dist/resources/extensions/gsd/tests/preferences.test.ts +0 -276
- package/dist/resources/extensions/gsd/tests/progress-score.test.ts +0 -206
- package/dist/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +0 -464
- package/dist/resources/extensions/gsd/tests/prompt-cache-optimizer.test.ts +0 -314
- package/dist/resources/extensions/gsd/tests/prompt-compressor.test.ts +0 -529
- package/dist/resources/extensions/gsd/tests/prompt-db.test.ts +0 -385
- package/dist/resources/extensions/gsd/tests/prompt-ordering.test.ts +0 -296
- package/dist/resources/extensions/gsd/tests/provider-errors.test.ts +0 -338
- package/dist/resources/extensions/gsd/tests/queue-draft-detection.test.ts +0 -126
- package/dist/resources/extensions/gsd/tests/queue-order.test.ts +0 -204
- package/dist/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +0 -282
- package/dist/resources/extensions/gsd/tests/reassess-detection.test.ts +0 -154
- package/dist/resources/extensions/gsd/tests/reassess-prompt.test.ts +0 -145
- package/dist/resources/extensions/gsd/tests/regex-hardening.test.ts +0 -281
- package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +0 -642
- package/dist/resources/extensions/gsd/tests/remote-status.test.ts +0 -99
- package/dist/resources/extensions/gsd/tests/replan-slice.test.ts +0 -538
- package/dist/resources/extensions/gsd/tests/requirements.test.ts +0 -106
- package/dist/resources/extensions/gsd/tests/roadmap-parse-regression.test.ts +0 -358
- package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +0 -66
- package/dist/resources/extensions/gsd/tests/routing-history.test.ts +0 -240
- package/dist/resources/extensions/gsd/tests/run-uat.test.ts +0 -416
- package/dist/resources/extensions/gsd/tests/secure-env-collect.test.ts +0 -185
- package/dist/resources/extensions/gsd/tests/semantic-chunker.test.ts +0 -426
- package/dist/resources/extensions/gsd/tests/session-lock-regression.test.ts +0 -216
- package/dist/resources/extensions/gsd/tests/session-lock.test.ts +0 -434
- package/dist/resources/extensions/gsd/tests/skill-lifecycle.test.ts +0 -126
- package/dist/resources/extensions/gsd/tests/smart-entry-draft.test.ts +0 -123
- package/dist/resources/extensions/gsd/tests/stale-worktree-cwd.test.ts +0 -142
- package/dist/resources/extensions/gsd/tests/stop-auto-remote.test.ts +0 -156
- package/dist/resources/extensions/gsd/tests/structured-data-formatter.test.ts +0 -365
- package/dist/resources/extensions/gsd/tests/summary-distiller.test.ts +0 -323
- package/dist/resources/extensions/gsd/tests/test-helpers.ts +0 -61
- package/dist/resources/extensions/gsd/tests/token-counter.test.ts +0 -129
- package/dist/resources/extensions/gsd/tests/token-optimization-benchmark.test.ts +0 -1272
- package/dist/resources/extensions/gsd/tests/token-optimization-prefs.test.ts +0 -164
- package/dist/resources/extensions/gsd/tests/token-profile.test.ts +0 -268
- package/dist/resources/extensions/gsd/tests/token-savings.test.ts +0 -366
- package/dist/resources/extensions/gsd/tests/triage-dispatch.test.ts +0 -340
- package/dist/resources/extensions/gsd/tests/triage-resolution.test.ts +0 -416
- package/dist/resources/extensions/gsd/tests/undo.test.ts +0 -136
- package/dist/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +0 -219
- package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +0 -258
- package/dist/resources/extensions/gsd/tests/update-command.test.ts +0 -67
- package/dist/resources/extensions/gsd/tests/validate-directory.test.ts +0 -222
- package/dist/resources/extensions/gsd/tests/validate-milestone.test.ts +0 -375
- package/dist/resources/extensions/gsd/tests/verification-evidence.test.ts +0 -745
- package/dist/resources/extensions/gsd/tests/verification-gate.test.ts +0 -1208
- package/dist/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +0 -145
- package/dist/resources/extensions/gsd/tests/visualizer-data.test.ts +0 -446
- package/dist/resources/extensions/gsd/tests/visualizer-overlay.test.ts +0 -237
- package/dist/resources/extensions/gsd/tests/visualizer-views.test.ts +0 -718
- package/dist/resources/extensions/gsd/tests/worker-registry.test.ts +0 -148
- package/dist/resources/extensions/gsd/tests/workflow-templates.test.ts +0 -173
- package/dist/resources/extensions/gsd/tests/workspace-index.test.ts +0 -38
- package/dist/resources/extensions/gsd/tests/worktree-bugfix.test.ts +0 -120
- package/dist/resources/extensions/gsd/tests/worktree-e2e.test.ts +0 -244
- package/dist/resources/extensions/gsd/tests/worktree-integration.test.ts +0 -207
- package/dist/resources/extensions/gsd/tests/worktree-manager.test.ts +0 -141
- package/dist/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +0 -165
- package/dist/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +0 -206
- package/dist/resources/extensions/gsd/tests/worktree.test.ts +0 -171
- package/dist/resources/extensions/gsd/tests/write-gate.test.ts +0 -211
- package/dist/resources/extensions/gsd/token-counter.ts +0 -65
- package/dist/resources/extensions/gsd/triage-resolution.ts +0 -284
- package/dist/resources/extensions/gsd/triage-ui.ts +0 -175
- package/dist/resources/extensions/gsd/types.ts +0 -425
- package/dist/resources/extensions/gsd/undo.ts +0 -223
- package/dist/resources/extensions/gsd/unit-id.ts +0 -14
- package/dist/resources/extensions/gsd/unit-runtime.ts +0 -192
- package/dist/resources/extensions/gsd/validate-directory.ts +0 -164
- package/dist/resources/extensions/gsd/verification-evidence.ts +0 -188
- package/dist/resources/extensions/gsd/verification-gate.ts +0 -643
- package/dist/resources/extensions/gsd/visualizer-data.ts +0 -866
- package/dist/resources/extensions/gsd/visualizer-overlay.ts +0 -566
- package/dist/resources/extensions/gsd/visualizer-views.ts +0 -1171
- package/dist/resources/extensions/gsd/workflow-templates.ts +0 -241
- package/dist/resources/extensions/gsd/workspace-index.ts +0 -217
- package/dist/resources/extensions/gsd/worktree-command.ts +0 -807
- package/dist/resources/extensions/gsd/worktree-manager.ts +0 -449
- package/dist/resources/extensions/gsd/worktree.ts +0 -257
- package/dist/resources/extensions/mac-tools/index.ts +0 -852
- package/dist/resources/extensions/mcp-client/index.ts +0 -459
- package/dist/resources/extensions/remote-questions/config.ts +0 -83
- package/dist/resources/extensions/remote-questions/discord-adapter.ts +0 -148
- package/dist/resources/extensions/remote-questions/format.ts +0 -315
- package/dist/resources/extensions/remote-questions/http-client.ts +0 -76
- package/dist/resources/extensions/remote-questions/manager.ts +0 -184
- package/dist/resources/extensions/remote-questions/notify.ts +0 -90
- package/dist/resources/extensions/remote-questions/remote-command.ts +0 -457
- package/dist/resources/extensions/remote-questions/slack-adapter.ts +0 -141
- package/dist/resources/extensions/remote-questions/status.ts +0 -31
- package/dist/resources/extensions/remote-questions/store.ts +0 -81
- package/dist/resources/extensions/remote-questions/telegram-adapter.ts +0 -149
- package/dist/resources/extensions/remote-questions/types.ts +0 -102
- package/dist/resources/extensions/search-the-web/cache.ts +0 -78
- package/dist/resources/extensions/search-the-web/command-search-provider.ts +0 -101
- package/dist/resources/extensions/search-the-web/format.ts +0 -258
- package/dist/resources/extensions/search-the-web/http.ts +0 -238
- package/dist/resources/extensions/search-the-web/index.ts +0 -65
- package/dist/resources/extensions/search-the-web/native-search.ts +0 -193
- package/dist/resources/extensions/search-the-web/provider.ts +0 -148
- package/dist/resources/extensions/search-the-web/tavily.ts +0 -116
- package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +0 -589
- package/dist/resources/extensions/search-the-web/tool-llm-context.ts +0 -608
- package/dist/resources/extensions/search-the-web/tool-search.ts +0 -649
- package/dist/resources/extensions/search-the-web/url-utils.ts +0 -125
- package/dist/resources/extensions/shared/confirm-ui.ts +0 -126
- package/dist/resources/extensions/shared/frontmatter.ts +0 -117
- package/dist/resources/extensions/shared/interview-ui.ts +0 -613
- package/dist/resources/extensions/shared/next-action-ui.ts +0 -212
- package/dist/resources/extensions/shared/sanitize.ts +0 -19
- package/dist/resources/extensions/shared/terminal.ts +0 -23
- package/dist/resources/extensions/shared/tests/format-utils.test.ts +0 -153
- package/dist/resources/extensions/shared/ui.ts +0 -400
- package/dist/resources/extensions/shared/wizard-ui.ts +0 -551
- package/dist/resources/extensions/slash-commands/audit.ts +0 -88
- package/dist/resources/extensions/slash-commands/clear.ts +0 -10
- package/dist/resources/extensions/slash-commands/create-extension.ts +0 -297
- package/dist/resources/extensions/slash-commands/create-slash-command.ts +0 -234
- package/dist/resources/extensions/slash-commands/index.ts +0 -12
- package/dist/resources/extensions/subagent/agents.ts +0 -126
- package/dist/resources/extensions/subagent/index.ts +0 -1121
- package/dist/resources/extensions/subagent/isolation.ts +0 -501
- package/dist/resources/extensions/subagent/worker-registry.ts +0 -99
- package/dist/resources/extensions/ttsr/index.ts +0 -168
- package/dist/resources/extensions/ttsr/rule-loader.ts +0 -74
- package/dist/resources/extensions/ttsr/ttsr-manager.ts +0 -456
- package/dist/resources/extensions/universal-config/discovery.ts +0 -104
- package/dist/resources/extensions/universal-config/format.ts +0 -191
- package/dist/resources/extensions/universal-config/index.ts +0 -120
- package/dist/resources/extensions/universal-config/scanners.ts +0 -642
- package/dist/resources/extensions/universal-config/tests/discovery.test.ts +0 -119
- package/dist/resources/extensions/universal-config/tests/format.test.ts +0 -127
- package/dist/resources/extensions/universal-config/tests/scanners.test.ts +0 -456
- package/dist/resources/extensions/universal-config/tools.ts +0 -60
- package/dist/resources/extensions/universal-config/types.ts +0 -135
- package/dist/resources/extensions/voice/index.ts +0 -272
- package/dist/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +0 -51
- package/dist/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +0 -143
|
@@ -1,1834 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GSD Auto Mode — Fresh Session Per Unit
|
|
3
|
-
*
|
|
4
|
-
* State machine driven by .gsd/ files on disk. Each "unit" of work
|
|
5
|
-
* (plan slice, execute task, complete slice) gets a fresh session via
|
|
6
|
-
* the stashed ctx.newSession() pattern.
|
|
7
|
-
*
|
|
8
|
-
* The extension reads disk state after each agent_end, determines the
|
|
9
|
-
* next unit type, creates a fresh session, and injects a focused prompt
|
|
10
|
-
* telling the LLM which files to read and what to do.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
ExtensionAPI,
|
|
15
|
-
ExtensionContext,
|
|
16
|
-
ExtensionCommandContext,
|
|
17
|
-
} from "@gsd/pi-coding-agent";
|
|
18
|
-
|
|
19
|
-
import { deriveState } from "./state.js";
|
|
20
|
-
import type { GSDState } from "./types.js";
|
|
21
|
-
import { loadFile, getManifestStatus, resolveAllOverrides, parsePlan, parseSummary } from "./files.js";
|
|
22
|
-
import { loadPrompt } from "./prompt-loader.js";
|
|
23
|
-
import { runVerificationGate, formatFailureContext, captureRuntimeErrors, runDependencyAudit } from "./verification-gate.js";
|
|
24
|
-
import { writeVerificationJSON } from "./verification-evidence.js";
|
|
25
|
-
import { collectSecretsFromManifest } from "../get-secrets-from-user.js";
|
|
26
|
-
import {
|
|
27
|
-
gsdRoot, resolveMilestoneFile, resolveSliceFile, resolveSlicePath,
|
|
28
|
-
resolveMilestonePath, resolveDir, resolveTasksDir, resolveTaskFile,
|
|
29
|
-
milestonesDir, buildTaskFileName,
|
|
30
|
-
} from "./paths.js";
|
|
31
|
-
import { invalidateAllCaches } from "./cache.js";
|
|
32
|
-
import { saveActivityLog, clearActivityLogState } from "./activity-log.js";
|
|
33
|
-
import { synthesizeCrashRecovery, getDeepDiagnostic } from "./session-forensics.js";
|
|
34
|
-
import { writeLock, clearLock, readCrashLock, formatCrashInfo, isLockProcessAlive } from "./crash-recovery.js";
|
|
35
|
-
import {
|
|
36
|
-
acquireSessionLock,
|
|
37
|
-
validateSessionLock,
|
|
38
|
-
releaseSessionLock,
|
|
39
|
-
updateSessionLock,
|
|
40
|
-
} from "./session-lock.js";
|
|
41
|
-
import {
|
|
42
|
-
clearUnitRuntimeRecord,
|
|
43
|
-
inspectExecuteTaskDurability,
|
|
44
|
-
readUnitRuntimeRecord,
|
|
45
|
-
writeUnitRuntimeRecord,
|
|
46
|
-
} from "./unit-runtime.js";
|
|
47
|
-
import { resolveAutoSupervisorConfig, loadEffectiveGSDPreferences, resolveSkillDiscoveryMode, getIsolationMode } from "./preferences.js";
|
|
48
|
-
import { sendDesktopNotification } from "./notifications.js";
|
|
49
|
-
import type { GSDPreferences } from "./preferences.js";
|
|
50
|
-
import {
|
|
51
|
-
type BudgetAlertLevel,
|
|
52
|
-
getBudgetAlertLevel,
|
|
53
|
-
getNewBudgetAlertLevel,
|
|
54
|
-
getBudgetEnforcementAction,
|
|
55
|
-
} from "./auto-budget.js";
|
|
56
|
-
import {
|
|
57
|
-
markToolStart as _markToolStart,
|
|
58
|
-
markToolEnd as _markToolEnd,
|
|
59
|
-
getOldestInFlightToolAgeMs as _getOldestInFlightToolAgeMs,
|
|
60
|
-
getInFlightToolCount,
|
|
61
|
-
getOldestInFlightToolStart,
|
|
62
|
-
clearInFlightTools,
|
|
63
|
-
} from "./auto-tool-tracking.js";
|
|
64
|
-
import {
|
|
65
|
-
collectObservabilityWarnings as _collectObservabilityWarnings,
|
|
66
|
-
buildObservabilityRepairBlock,
|
|
67
|
-
} from "./auto-observability.js";
|
|
68
|
-
import { closeoutUnit } from "./auto-unit-closeout.js";
|
|
69
|
-
import { recoverTimedOutUnit } from "./auto-timeout-recovery.js";
|
|
70
|
-
import { selectAndApplyModel } from "./auto-model-selection.js";
|
|
71
|
-
import {
|
|
72
|
-
readResourceVersion,
|
|
73
|
-
checkResourcesStale,
|
|
74
|
-
escapeStaleWorktree,
|
|
75
|
-
} from "./resource-version.js";
|
|
76
|
-
import { initRoutingHistory, resetRoutingHistory, recordOutcome } from "./routing-history.js";
|
|
77
|
-
import {
|
|
78
|
-
checkPostUnitHooks,
|
|
79
|
-
getActiveHook,
|
|
80
|
-
resetHookState,
|
|
81
|
-
isRetryPending,
|
|
82
|
-
consumeRetryTrigger,
|
|
83
|
-
runPreDispatchHooks,
|
|
84
|
-
persistHookState,
|
|
85
|
-
restoreHookState,
|
|
86
|
-
clearPersistedHookState,
|
|
87
|
-
} from "./post-unit-hooks.js";
|
|
88
|
-
import { ensureGitignore, untrackRuntimeFiles } from "./gitignore.js";
|
|
89
|
-
import { runGSDDoctor, rebuildState, summarizeDoctorIssues } from "./doctor.js";
|
|
90
|
-
import {
|
|
91
|
-
preDispatchHealthGate,
|
|
92
|
-
recordHealthSnapshot,
|
|
93
|
-
checkHealEscalation,
|
|
94
|
-
resetProactiveHealing,
|
|
95
|
-
formatHealthSummary,
|
|
96
|
-
getConsecutiveErrorUnits,
|
|
97
|
-
} from "./doctor-proactive.js";
|
|
98
|
-
import { snapshotSkills, clearSkillSnapshot } from "./skill-discovery.js";
|
|
99
|
-
import { captureAvailableSkills, getAndClearSkills, resetSkillTelemetry } from "./skill-telemetry.js";
|
|
100
|
-
import {
|
|
101
|
-
initMetrics, resetMetrics, getLedger,
|
|
102
|
-
getProjectTotals, formatCost, formatTokenCount,
|
|
103
|
-
} from "./metrics.js";
|
|
104
|
-
import { computeBudgets, resolveExecutorContextWindow } from "./context-budget.js";
|
|
105
|
-
import { GSDError, GSD_ARTIFACT_MISSING } from "./errors.js";
|
|
106
|
-
import { join } from "node:path";
|
|
107
|
-
import { sep as pathSep } from "node:path";
|
|
108
|
-
import { parseUnitId } from "./unit-id.js";
|
|
109
|
-
import { readdirSync, readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync, statSync } from "node:fs";
|
|
110
|
-
import { atomicWriteSync } from "./atomic-write.js";
|
|
111
|
-
import { nativeIsRepo, nativeInit, nativeAddAll, nativeCommit } from "./native-git-bridge.js";
|
|
112
|
-
import {
|
|
113
|
-
autoCommitCurrentBranch,
|
|
114
|
-
captureIntegrationBranch,
|
|
115
|
-
detectWorktreeName,
|
|
116
|
-
getCurrentBranch,
|
|
117
|
-
getMainBranch,
|
|
118
|
-
MergeConflictError,
|
|
119
|
-
parseSliceBranch,
|
|
120
|
-
setActiveMilestoneId,
|
|
121
|
-
} from "./worktree.js";
|
|
122
|
-
import { createGitService, type TaskCommitContext } from "./git-service.js";
|
|
123
|
-
import { getPriorSliceCompletionBlocker } from "./dispatch-guard.js";
|
|
124
|
-
import { formatGitError } from "./git-self-heal.js";
|
|
125
|
-
import {
|
|
126
|
-
createAutoWorktree,
|
|
127
|
-
enterAutoWorktree,
|
|
128
|
-
teardownAutoWorktree,
|
|
129
|
-
isInAutoWorktree,
|
|
130
|
-
getAutoWorktreePath,
|
|
131
|
-
getAutoWorktreeOriginalBase,
|
|
132
|
-
mergeMilestoneToMain,
|
|
133
|
-
autoWorktreeBranch,
|
|
134
|
-
} from "./auto-worktree.js";
|
|
135
|
-
import { pruneQueueOrder } from "./queue-order.js";
|
|
136
|
-
import { consumeSignal } from "./session-status-io.js";
|
|
137
|
-
import { showNextAction } from "../shared/mod.js";
|
|
138
|
-
import { debugLog, debugTime, debugCount, debugPeak, enableDebug, isDebugEnabled, writeDebugSummary, getDebugLogPath } from "./debug-logger.js";
|
|
139
|
-
import {
|
|
140
|
-
resolveExpectedArtifactPath,
|
|
141
|
-
verifyExpectedArtifact,
|
|
142
|
-
writeBlockerPlaceholder,
|
|
143
|
-
diagnoseExpectedArtifact,
|
|
144
|
-
skipExecuteTask,
|
|
145
|
-
completedKeysPath,
|
|
146
|
-
persistCompletedKey,
|
|
147
|
-
removePersistedKey,
|
|
148
|
-
loadPersistedKeys,
|
|
149
|
-
selfHealRuntimeRecords,
|
|
150
|
-
buildLoopRemediationSteps,
|
|
151
|
-
reconcileMergeState,
|
|
152
|
-
} from "./auto-recovery.js";
|
|
153
|
-
import { resolveDispatch, resetRewriteCircuitBreaker } from "./auto-dispatch.js";
|
|
154
|
-
import {
|
|
155
|
-
type AutoDashboardData,
|
|
156
|
-
updateProgressWidget as _updateProgressWidget,
|
|
157
|
-
updateSliceProgressCache,
|
|
158
|
-
clearSliceProgressCache,
|
|
159
|
-
describeNextUnit as _describeNextUnit,
|
|
160
|
-
unitVerb,
|
|
161
|
-
formatAutoElapsed as _formatAutoElapsed,
|
|
162
|
-
formatWidgetTokens,
|
|
163
|
-
hideFooter,
|
|
164
|
-
type WidgetStateAccessors,
|
|
165
|
-
} from "./auto-dashboard.js";
|
|
166
|
-
import {
|
|
167
|
-
registerSigtermHandler as _registerSigtermHandler,
|
|
168
|
-
deregisterSigtermHandler as _deregisterSigtermHandler,
|
|
169
|
-
detectWorkingTreeActivity,
|
|
170
|
-
} from "./auto-supervisor.js";
|
|
171
|
-
import { isDbAvailable } from "./gsd-db.js";
|
|
172
|
-
import { hasPendingCaptures, loadPendingCaptures, countPendingCaptures } from "./captures.js";
|
|
173
|
-
|
|
174
|
-
// ── Extracted modules ──────────────────────────────────────────────────────
|
|
175
|
-
import { startUnitSupervision, type SupervisionContext } from "./auto-timers.js";
|
|
176
|
-
import { checkIdempotency, type IdempotencyContext } from "./auto-idempotency.js";
|
|
177
|
-
import { checkStuckAndRecover, type StuckContext } from "./auto-stuck-detection.js";
|
|
178
|
-
import { runPostUnitVerification, type VerificationContext } from "./auto-verification.js";
|
|
179
|
-
import { postUnitPreVerification, postUnitPostVerification, type PostUnitContext } from "./auto-post-unit.js";
|
|
180
|
-
import { bootstrapAutoSession, type BootstrapDeps } from "./auto-start.js";
|
|
181
|
-
|
|
182
|
-
// Resource staleness, stale worktree escape → resource-version.ts
|
|
183
|
-
|
|
184
|
-
// ─── Session State ─────────────────────────────────────────────────────────
|
|
185
|
-
|
|
186
|
-
import {
|
|
187
|
-
AutoSession,
|
|
188
|
-
MAX_UNIT_DISPATCHES, STUB_RECOVERY_THRESHOLD, MAX_LIFETIME_DISPATCHES,
|
|
189
|
-
MAX_CONSECUTIVE_SKIPS, DISPATCH_GAP_TIMEOUT_MS, MAX_SKIP_DEPTH,
|
|
190
|
-
NEW_SESSION_TIMEOUT_MS, DISPATCH_HANG_TIMEOUT_MS,
|
|
191
|
-
} from "./auto/session.js";
|
|
192
|
-
import type { CompletedUnit, CurrentUnit, UnitRouting, StartModel, PendingVerificationRetry } from "./auto/session.js";
|
|
193
|
-
import { getErrorMessage } from "./error-utils.js";
|
|
194
|
-
|
|
195
|
-
// ── ENCAPSULATION INVARIANT ─────────────────────────────────────────────────
|
|
196
|
-
// ALL mutable auto-mode state lives in the AutoSession class (auto/session.ts).
|
|
197
|
-
// This file must NOT declare module-level `let` or `var` variables for state.
|
|
198
|
-
// The single `s` instance below is the only mutable module-level binding.
|
|
199
|
-
//
|
|
200
|
-
// When adding features or fixing bugs:
|
|
201
|
-
// - New mutable state → add a property to AutoSession, not a module-level variable
|
|
202
|
-
// - New constants → module-level `const` is fine (immutable)
|
|
203
|
-
// - New state that needs reset on stopAuto → add to AutoSession.reset()
|
|
204
|
-
//
|
|
205
|
-
// Tests in auto-session-encapsulation.test.ts enforce this invariant.
|
|
206
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
207
|
-
const s = new AutoSession();
|
|
208
|
-
|
|
209
|
-
import { STATE_REBUILD_MIN_INTERVAL_MS } from "./auto-constants.js";
|
|
210
|
-
|
|
211
|
-
export function shouldUseWorktreeIsolation(): boolean {
|
|
212
|
-
const prefs = loadEffectiveGSDPreferences()?.preferences?.git;
|
|
213
|
-
if (prefs?.isolation === "none") return false;
|
|
214
|
-
if (prefs?.isolation === "branch") return false;
|
|
215
|
-
return true; // default: worktree
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// All mutable state lives in AutoSession (auto/session.ts) — see encapsulation invariant above.
|
|
219
|
-
/** Wrapper: register SIGTERM handler and store reference. */
|
|
220
|
-
function registerSigtermHandler(currentBasePath: string): void {
|
|
221
|
-
s.sigtermHandler = _registerSigtermHandler(currentBasePath, s.sigtermHandler);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** Wrapper: deregister SIGTERM handler and clear reference. */
|
|
225
|
-
function deregisterSigtermHandler(): void {
|
|
226
|
-
_deregisterSigtermHandler(s.sigtermHandler);
|
|
227
|
-
s.sigtermHandler = null;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export function getAutoDashboardData(): AutoDashboardData {
|
|
231
|
-
const ledger = getLedger();
|
|
232
|
-
const totals = ledger ? getProjectTotals(ledger.units) : null;
|
|
233
|
-
// Pending capture count — lazy check, non-fatal
|
|
234
|
-
let pendingCaptureCount = 0;
|
|
235
|
-
try {
|
|
236
|
-
if (s.basePath) {
|
|
237
|
-
pendingCaptureCount = countPendingCaptures(s.basePath);
|
|
238
|
-
}
|
|
239
|
-
} catch {
|
|
240
|
-
// Non-fatal — captures module may not be loaded
|
|
241
|
-
}
|
|
242
|
-
return { active: s.active, paused: s.paused,
|
|
243
|
-
stepMode: s.stepMode,
|
|
244
|
-
startTime: s.autoStartTime,
|
|
245
|
-
elapsed: (s.active || s.paused) ? Date.now() - s.autoStartTime : 0,
|
|
246
|
-
currentUnit: s.currentUnit ? { ...s.currentUnit } : null,
|
|
247
|
-
completedUnits: [...s.completedUnits], basePath: s.basePath,
|
|
248
|
-
totalCost: totals?.cost ?? 0,
|
|
249
|
-
totalTokens: totals?.tokens.total ?? 0,
|
|
250
|
-
pendingCaptureCount,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
255
|
-
|
|
256
|
-
export function isAutoActive(): boolean {
|
|
257
|
-
return s.active;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export function isAutoPaused(): boolean {
|
|
261
|
-
return s.paused;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Return the model captured at auto-mode start for this session.
|
|
266
|
-
* Used by error-recovery to fall back to the session's own model
|
|
267
|
-
* instead of reading (potentially stale) preferences from disk (#1065).
|
|
268
|
-
*/
|
|
269
|
-
export function getAutoModeStartModel(): { provider: string; id: string } | null {
|
|
270
|
-
return s.autoModeStartModel;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Tool tracking — delegates to auto-tool-tracking.ts
|
|
274
|
-
export function markToolStart(toolCallId: string): void {
|
|
275
|
-
_markToolStart(toolCallId, s.active);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export function markToolEnd(toolCallId: string): void {
|
|
279
|
-
_markToolEnd(toolCallId);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function getOldestInFlightToolAgeMs(): number {
|
|
283
|
-
return _getOldestInFlightToolAgeMs();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Return the base path to use for the auto.lock file.
|
|
288
|
-
* Always uses the original project root (not the worktree) so that
|
|
289
|
-
* a second terminal can discover and stop a running auto-mode session.
|
|
290
|
-
*/
|
|
291
|
-
function lockBase(): string {
|
|
292
|
-
return s.originalBasePath || s.basePath;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Attempt to stop a running auto-mode session from a different process.
|
|
297
|
-
* Reads the lock file at the project root, checks if the PID is alive,
|
|
298
|
-
* and sends SIGTERM to gracefully stop it.
|
|
299
|
-
*
|
|
300
|
-
* Returns true if a remote session was found and signaled, false otherwise.
|
|
301
|
-
*/
|
|
302
|
-
export function stopAutoRemote(projectRoot: string): { found: boolean; pid?: number; error?: string } {
|
|
303
|
-
const lock = readCrashLock(projectRoot);
|
|
304
|
-
if (!lock) return { found: false };
|
|
305
|
-
|
|
306
|
-
if (!isLockProcessAlive(lock)) {
|
|
307
|
-
// Stale lock — clean it up
|
|
308
|
-
clearLock(projectRoot);
|
|
309
|
-
return { found: false };
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Send SIGTERM — the auto-mode process has a handler that clears the lock and exits
|
|
313
|
-
try {
|
|
314
|
-
process.kill(lock.pid, "SIGTERM");
|
|
315
|
-
return { found: true, pid: lock.pid };
|
|
316
|
-
} catch (err) {
|
|
317
|
-
return { found: false, error: (err as Error).message };
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function isStepMode(): boolean {
|
|
322
|
-
return s.stepMode;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function clearUnitTimeout(): void {
|
|
326
|
-
if (s.unitTimeoutHandle) {
|
|
327
|
-
clearTimeout(s.unitTimeoutHandle);
|
|
328
|
-
s.unitTimeoutHandle = null;
|
|
329
|
-
}
|
|
330
|
-
if (s.wrapupWarningHandle) {
|
|
331
|
-
clearTimeout(s.wrapupWarningHandle);
|
|
332
|
-
s.wrapupWarningHandle = null;
|
|
333
|
-
}
|
|
334
|
-
if (s.idleWatchdogHandle) {
|
|
335
|
-
clearInterval(s.idleWatchdogHandle);
|
|
336
|
-
s.idleWatchdogHandle = null;
|
|
337
|
-
}
|
|
338
|
-
if (s.continueHereHandle) {
|
|
339
|
-
clearInterval(s.continueHereHandle);
|
|
340
|
-
s.continueHereHandle = null;
|
|
341
|
-
}
|
|
342
|
-
clearInFlightTools();
|
|
343
|
-
clearDispatchGapWatchdog();
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
function clearDispatchGapWatchdog(): void {
|
|
347
|
-
if (s.dispatchGapHandle) {
|
|
348
|
-
clearTimeout(s.dispatchGapHandle);
|
|
349
|
-
s.dispatchGapHandle = null;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/** Build snapshot metric opts, enriching with continueHereFired from the runtime record. */
|
|
354
|
-
function buildSnapshotOpts(unitType: string, unitId: string): { continueHereFired?: boolean; promptCharCount?: number; baselineCharCount?: number } & Record<string, unknown> {
|
|
355
|
-
const runtime = s.currentUnit ? readUnitRuntimeRecord(s.basePath, unitType, unitId) : null;
|
|
356
|
-
return {
|
|
357
|
-
promptCharCount: s.lastPromptCharCount,
|
|
358
|
-
baselineCharCount: s.lastBaselineCharCount,
|
|
359
|
-
...(s.currentUnitRouting ?? {}),
|
|
360
|
-
...(runtime?.continueHereFired ? { continueHereFired: true } : {}),
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// ─── Extracted Merge Helper ───────────────────────────────────────────────
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Attempt to merge the current milestone branch to main.
|
|
368
|
-
* Handles both worktree and branch isolation modes with a single code path.
|
|
369
|
-
* Returns true if merge succeeded, false on error (non-fatal, logged).
|
|
370
|
-
*
|
|
371
|
-
* Extracted from 4 duplicate merge blocks in dispatchNextUnit to eliminate
|
|
372
|
-
* the bug factory where fixing one copy didn't fix the others (#1308).
|
|
373
|
-
*/
|
|
374
|
-
function tryMergeMilestone(ctx: ExtensionContext, milestoneId: string, mode: "transition" | "complete"): boolean {
|
|
375
|
-
const isolationMode = getIsolationMode();
|
|
376
|
-
|
|
377
|
-
// Worktree merge path
|
|
378
|
-
if (isInAutoWorktree(s.basePath) && s.originalBasePath) {
|
|
379
|
-
try {
|
|
380
|
-
const roadmapPath = resolveMilestoneFile(s.originalBasePath, milestoneId, "ROADMAP");
|
|
381
|
-
if (!roadmapPath) {
|
|
382
|
-
teardownAutoWorktree(s.originalBasePath, milestoneId);
|
|
383
|
-
ctx.ui.notify(`Exited worktree for ${milestoneId} (no roadmap for merge).`, "info");
|
|
384
|
-
return false;
|
|
385
|
-
}
|
|
386
|
-
const roadmapContent = readFileSync(roadmapPath, "utf-8");
|
|
387
|
-
const mergeResult = mergeMilestoneToMain(s.originalBasePath, milestoneId, roadmapContent);
|
|
388
|
-
s.basePath = s.originalBasePath;
|
|
389
|
-
s.gitService = createGitService(s.basePath);
|
|
390
|
-
ctx.ui.notify(
|
|
391
|
-
`Milestone ${milestoneId} merged to main.${mergeResult.pushed ? " Pushed to remote." : ""}`,
|
|
392
|
-
"info",
|
|
393
|
-
);
|
|
394
|
-
return true;
|
|
395
|
-
} catch (err) {
|
|
396
|
-
ctx.ui.notify(
|
|
397
|
-
`Milestone merge failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
398
|
-
"warning",
|
|
399
|
-
);
|
|
400
|
-
if (s.originalBasePath) {
|
|
401
|
-
s.basePath = s.originalBasePath;
|
|
402
|
-
try { process.chdir(s.basePath); } catch { /* best-effort */ }
|
|
403
|
-
}
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Branch-mode merge path
|
|
409
|
-
if (isolationMode === "branch") {
|
|
410
|
-
try {
|
|
411
|
-
const currentBranch = getCurrentBranch(s.basePath);
|
|
412
|
-
const milestoneBranch = autoWorktreeBranch(milestoneId);
|
|
413
|
-
if (currentBranch === milestoneBranch) {
|
|
414
|
-
const roadmapPath = resolveMilestoneFile(s.basePath, milestoneId, "ROADMAP");
|
|
415
|
-
if (roadmapPath) {
|
|
416
|
-
const roadmapContent = readFileSync(roadmapPath, "utf-8");
|
|
417
|
-
const mergeResult = mergeMilestoneToMain(s.basePath, milestoneId, roadmapContent);
|
|
418
|
-
s.gitService = createGitService(s.basePath);
|
|
419
|
-
ctx.ui.notify(
|
|
420
|
-
`Milestone ${milestoneId} merged (branch mode).${mergeResult.pushed ? " Pushed to remote." : ""}`,
|
|
421
|
-
"info",
|
|
422
|
-
);
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
} catch (err) {
|
|
427
|
-
ctx.ui.notify(
|
|
428
|
-
`Milestone merge failed (branch mode): ${err instanceof Error ? err.message : String(err)}`,
|
|
429
|
-
"warning",
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Start a watchdog that fires if no new unit is dispatched within DISPATCH_GAP_TIMEOUT_MS
|
|
439
|
-
* after handleAgentEnd completes. This catches the case where the dispatch chain silently
|
|
440
|
-
* breaks (e.g., unhandled exception in dispatchNextUnit) and auto-mode is left s.active but idle.
|
|
441
|
-
*
|
|
442
|
-
* The watchdog is cleared on the next successful unit dispatch (clearUnitTimeout is called
|
|
443
|
-
* at the start of handleAgentEnd, which calls clearDispatchGapWatchdog).
|
|
444
|
-
*/
|
|
445
|
-
function startDispatchGapWatchdog(ctx: ExtensionContext, pi: ExtensionAPI): void {
|
|
446
|
-
clearDispatchGapWatchdog();
|
|
447
|
-
s.dispatchGapHandle = setTimeout(async () => {
|
|
448
|
-
s.dispatchGapHandle = null;
|
|
449
|
-
if (!s.active || !s.cmdCtx) return;
|
|
450
|
-
|
|
451
|
-
if (s.verbose) {
|
|
452
|
-
ctx.ui.notify(
|
|
453
|
-
"Dispatch gap detected — re-evaluating state.",
|
|
454
|
-
"info",
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
try {
|
|
459
|
-
await dispatchNextUnit(ctx, pi);
|
|
460
|
-
} catch (retryErr) {
|
|
461
|
-
const message = getErrorMessage(retryErr);
|
|
462
|
-
await stopAuto(ctx, pi, `Dispatch gap recovery failed: ${message}`);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (s.active && !s.unitTimeoutHandle && !s.wrapupWarningHandle) {
|
|
467
|
-
await stopAuto(ctx, pi, "Stalled — no dispatchable unit after retry");
|
|
468
|
-
}
|
|
469
|
-
}, DISPATCH_GAP_TIMEOUT_MS);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export async function stopAuto(ctx?: ExtensionContext, pi?: ExtensionAPI, reason?: string): Promise<void> {
|
|
473
|
-
if (!s.active && !s.paused) return;
|
|
474
|
-
const reasonSuffix = reason ? ` — ${reason}` : "";
|
|
475
|
-
clearUnitTimeout();
|
|
476
|
-
if (lockBase()) {
|
|
477
|
-
releaseSessionLock(lockBase());
|
|
478
|
-
clearLock(lockBase());
|
|
479
|
-
}
|
|
480
|
-
clearSkillSnapshot();
|
|
481
|
-
resetSkillTelemetry();
|
|
482
|
-
s.dispatching = false;
|
|
483
|
-
s.skipDepth = 0;
|
|
484
|
-
|
|
485
|
-
// Remove SIGTERM handler registered at auto-mode start
|
|
486
|
-
deregisterSigtermHandler();
|
|
487
|
-
|
|
488
|
-
// ── Auto-worktree: exit worktree and reset s.basePath on stop ──
|
|
489
|
-
if (s.currentMilestoneId && isInAutoWorktree(s.basePath)) {
|
|
490
|
-
try {
|
|
491
|
-
try { autoCommitCurrentBranch(s.basePath, "stop", s.currentMilestoneId); } catch (e) { debugLog("stop-auto-commit-failed", { error: getErrorMessage(e) }); }
|
|
492
|
-
teardownAutoWorktree(s.originalBasePath, s.currentMilestoneId, { preserveBranch: true });
|
|
493
|
-
s.basePath = s.originalBasePath;
|
|
494
|
-
s.gitService = createGitService(s.basePath);
|
|
495
|
-
ctx?.ui.notify("Exited auto-worktree (branch preserved for resume).", "info");
|
|
496
|
-
} catch (err) {
|
|
497
|
-
ctx?.ui.notify(
|
|
498
|
-
`Auto-worktree teardown failed: ${getErrorMessage(err)}`,
|
|
499
|
-
"warning",
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// ── DB cleanup: close the SQLite connection ──
|
|
505
|
-
if (isDbAvailable()) {
|
|
506
|
-
try {
|
|
507
|
-
const { closeDatabase } = await import("./gsd-db.js");
|
|
508
|
-
closeDatabase();
|
|
509
|
-
} catch (e) { debugLog("db-close-failed", { error: getErrorMessage(e) }); }
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
if (s.originalBasePath) {
|
|
513
|
-
s.basePath = s.originalBasePath;
|
|
514
|
-
try { process.chdir(s.basePath); } catch { /* best-effort */ }
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
const ledger = getLedger();
|
|
518
|
-
if (ledger && ledger.units.length > 0) {
|
|
519
|
-
const totals = getProjectTotals(ledger.units);
|
|
520
|
-
ctx?.ui.notify(
|
|
521
|
-
`Auto-mode stopped${reasonSuffix}. Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${ledger.units.length} units`,
|
|
522
|
-
"info",
|
|
523
|
-
);
|
|
524
|
-
} else {
|
|
525
|
-
ctx?.ui.notify(`Auto-mode stopped${reasonSuffix}.`, "info");
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
if (s.basePath) {
|
|
529
|
-
try { await rebuildState(s.basePath); } catch (e) { debugLog("stop-rebuild-state-failed", { error: getErrorMessage(e) }); }
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (isDebugEnabled()) {
|
|
533
|
-
const logPath = writeDebugSummary();
|
|
534
|
-
if (logPath) {
|
|
535
|
-
ctx?.ui.notify(`Debug log written → ${logPath}`, "info");
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
resetMetrics();
|
|
540
|
-
resetRoutingHistory();
|
|
541
|
-
resetHookState();
|
|
542
|
-
if (s.basePath) clearPersistedHookState(s.basePath);
|
|
543
|
-
s.active = false;
|
|
544
|
-
s.paused = false;
|
|
545
|
-
s.stepMode = false;
|
|
546
|
-
s.unitDispatchCount.clear();
|
|
547
|
-
s.unitRecoveryCount.clear();
|
|
548
|
-
s.unitConsecutiveSkips.clear();
|
|
549
|
-
clearInFlightTools();
|
|
550
|
-
s.lastBudgetAlertLevel = 0;
|
|
551
|
-
s.lastStateRebuildAt = 0;
|
|
552
|
-
s.unitLifetimeDispatches.clear();
|
|
553
|
-
s.currentUnit = null;
|
|
554
|
-
s.autoModeStartModel = null;
|
|
555
|
-
s.currentMilestoneId = null;
|
|
556
|
-
s.originalBasePath = "";
|
|
557
|
-
s.completedUnits = [];
|
|
558
|
-
s.pendingQuickTasks = [];
|
|
559
|
-
clearSliceProgressCache();
|
|
560
|
-
clearActivityLogState();
|
|
561
|
-
resetProactiveHealing();
|
|
562
|
-
s.recentlyEvictedKeys.clear();
|
|
563
|
-
s.pendingCrashRecovery = null;
|
|
564
|
-
s.pendingVerificationRetry = null;
|
|
565
|
-
s.verificationRetryCount.clear();
|
|
566
|
-
s.pausedSessionFile = null;
|
|
567
|
-
s.handlingAgentEnd = false;
|
|
568
|
-
ctx?.ui.setStatus("gsd-auto", undefined);
|
|
569
|
-
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
570
|
-
ctx?.ui.setFooter(undefined);
|
|
571
|
-
|
|
572
|
-
if (pi && ctx && s.originalModelId && s.originalModelProvider) {
|
|
573
|
-
const original = ctx.modelRegistry.find(s.originalModelProvider, s.originalModelId);
|
|
574
|
-
if (original) await pi.setModel(original);
|
|
575
|
-
s.originalModelId = null;
|
|
576
|
-
s.originalModelProvider = null;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
s.cmdCtx = null;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Pause auto-mode without destroying state. Context is preserved.
|
|
584
|
-
* The user can interact with the agent, then `/gsd auto` resumes
|
|
585
|
-
* from disk state. Called when the user presses Escape during auto-mode.
|
|
586
|
-
*/
|
|
587
|
-
export async function pauseAuto(ctx?: ExtensionContext, _pi?: ExtensionAPI): Promise<void> {
|
|
588
|
-
if (!s.active) return;
|
|
589
|
-
clearUnitTimeout();
|
|
590
|
-
|
|
591
|
-
s.pausedSessionFile = ctx?.sessionManager?.getSessionFile() ?? null;
|
|
592
|
-
|
|
593
|
-
if (lockBase()) {
|
|
594
|
-
releaseSessionLock(lockBase());
|
|
595
|
-
clearLock(lockBase());
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
deregisterSigtermHandler();
|
|
599
|
-
|
|
600
|
-
s.active = false;
|
|
601
|
-
s.paused = true;
|
|
602
|
-
s.pendingVerificationRetry = null;
|
|
603
|
-
s.verificationRetryCount.clear();
|
|
604
|
-
ctx?.ui.setStatus("gsd-auto", "paused");
|
|
605
|
-
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
606
|
-
ctx?.ui.setFooter(undefined);
|
|
607
|
-
const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
|
|
608
|
-
ctx?.ui.notify(
|
|
609
|
-
`${s.stepMode ? "Step" : "Auto"}-mode paused (Escape). Type to interact, or ${resumeCmd} to resume.`,
|
|
610
|
-
"info",
|
|
611
|
-
);
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
export async function startAuto(
|
|
616
|
-
ctx: ExtensionCommandContext,
|
|
617
|
-
pi: ExtensionAPI,
|
|
618
|
-
base: string,
|
|
619
|
-
verboseMode: boolean,
|
|
620
|
-
options?: { step?: boolean },
|
|
621
|
-
): Promise<void> {
|
|
622
|
-
const requestedStepMode = options?.step ?? false;
|
|
623
|
-
|
|
624
|
-
// Escape stale worktree cwd from a previous milestone (#608).
|
|
625
|
-
base = escapeStaleWorktree(base);
|
|
626
|
-
|
|
627
|
-
// If resuming from paused state, just re-activate and dispatch next unit.
|
|
628
|
-
if (s.paused) {
|
|
629
|
-
// Re-acquire session lock before resuming
|
|
630
|
-
const resumeLock = acquireSessionLock(base);
|
|
631
|
-
if (!resumeLock.acquired) {
|
|
632
|
-
ctx.ui.notify(
|
|
633
|
-
`Cannot resume: ${resumeLock.reason}`,
|
|
634
|
-
"error",
|
|
635
|
-
);
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
s.paused = false;
|
|
640
|
-
s.active = true;
|
|
641
|
-
s.verbose = verboseMode;
|
|
642
|
-
s.stepMode = requestedStepMode;
|
|
643
|
-
s.cmdCtx = ctx;
|
|
644
|
-
s.basePath = base;
|
|
645
|
-
s.unitDispatchCount.clear();
|
|
646
|
-
s.unitLifetimeDispatches.clear();
|
|
647
|
-
s.unitConsecutiveSkips.clear();
|
|
648
|
-
if (!getLedger()) initMetrics(base);
|
|
649
|
-
if (s.currentMilestoneId) setActiveMilestoneId(base, s.currentMilestoneId);
|
|
650
|
-
|
|
651
|
-
// ── Auto-worktree: re-enter worktree on resume ──
|
|
652
|
-
if (s.currentMilestoneId && shouldUseWorktreeIsolation() && s.originalBasePath && !isInAutoWorktree(s.basePath) && !detectWorktreeName(s.basePath) && !detectWorktreeName(s.originalBasePath)) {
|
|
653
|
-
try {
|
|
654
|
-
const existingWtPath = getAutoWorktreePath(s.originalBasePath, s.currentMilestoneId);
|
|
655
|
-
if (existingWtPath) {
|
|
656
|
-
const wtPath = enterAutoWorktree(s.originalBasePath, s.currentMilestoneId);
|
|
657
|
-
s.basePath = wtPath;
|
|
658
|
-
s.gitService = createGitService(s.basePath);
|
|
659
|
-
ctx.ui.notify(`Re-entered auto-worktree at ${wtPath}`, "info");
|
|
660
|
-
} else {
|
|
661
|
-
const wtPath = createAutoWorktree(s.originalBasePath, s.currentMilestoneId);
|
|
662
|
-
s.basePath = wtPath;
|
|
663
|
-
s.gitService = createGitService(s.basePath);
|
|
664
|
-
ctx.ui.notify(`Recreated auto-worktree at ${wtPath}`, "info");
|
|
665
|
-
}
|
|
666
|
-
} catch (err) {
|
|
667
|
-
ctx.ui.notify(
|
|
668
|
-
`Auto-worktree re-entry failed: ${getErrorMessage(err)}. Continuing at current path.`,
|
|
669
|
-
"warning",
|
|
670
|
-
);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
registerSigtermHandler(lockBase());
|
|
675
|
-
|
|
676
|
-
ctx.ui.setStatus("gsd-auto", s.stepMode ? "next" : "auto");
|
|
677
|
-
ctx.ui.setFooter(hideFooter);
|
|
678
|
-
ctx.ui.notify(s.stepMode ? "Step-mode resumed." : "Auto-mode resumed.", "info");
|
|
679
|
-
restoreHookState(s.basePath);
|
|
680
|
-
try { await rebuildState(s.basePath); } catch (e) { debugLog("resume-rebuild-state-failed", { error: getErrorMessage(e) }); }
|
|
681
|
-
try {
|
|
682
|
-
const report = await runGSDDoctor(s.basePath, { fix: true });
|
|
683
|
-
if (report.fixesApplied.length > 0) {
|
|
684
|
-
ctx.ui.notify(`Resume: applied ${report.fixesApplied.length} fix(es) to state.`, "info");
|
|
685
|
-
}
|
|
686
|
-
} catch (e) { debugLog("resume-doctor-failed", { error: getErrorMessage(e) }); }
|
|
687
|
-
await selfHealRuntimeRecords(s.basePath, ctx, s.completedKeySet);
|
|
688
|
-
invalidateAllCaches();
|
|
689
|
-
|
|
690
|
-
if (s.pausedSessionFile) {
|
|
691
|
-
const activityDir = join(gsdRoot(s.basePath), "activity");
|
|
692
|
-
const recovery = synthesizeCrashRecovery(
|
|
693
|
-
s.basePath,
|
|
694
|
-
s.currentUnit?.type ?? "unknown",
|
|
695
|
-
s.currentUnit?.id ?? "unknown", s.pausedSessionFile ?? undefined,
|
|
696
|
-
activityDir,
|
|
697
|
-
);
|
|
698
|
-
if (recovery && recovery.trace.toolCallCount > 0) {
|
|
699
|
-
s.pendingCrashRecovery = recovery.prompt;
|
|
700
|
-
ctx.ui.notify(
|
|
701
|
-
`Recovered ${recovery.trace.toolCallCount} tool calls from paused session. Resuming with context.`,
|
|
702
|
-
"info",
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
s.pausedSessionFile = null;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// If resuming from a secrets pause, re-collect before dispatching (#1146)
|
|
709
|
-
if (s.pausedForSecrets && s.currentMilestoneId) {
|
|
710
|
-
try {
|
|
711
|
-
const manifestStatus = await getManifestStatus(s.basePath, s.currentMilestoneId);
|
|
712
|
-
if (manifestStatus && manifestStatus.pending.length > 0) {
|
|
713
|
-
const result = await collectSecretsFromManifest(s.basePath, s.currentMilestoneId, ctx);
|
|
714
|
-
if (result && result.applied.length > 0) {
|
|
715
|
-
ctx.ui.notify(
|
|
716
|
-
`Secrets collected: ${result.applied.length} applied, ${result.skipped.length} skipped, ${result.existingSkipped.length} already set.`,
|
|
717
|
-
"info",
|
|
718
|
-
);
|
|
719
|
-
} else if (result && result.applied.length === 0 && result.skipped.length > 0) {
|
|
720
|
-
// All keys were skipped — still pending, re-pause
|
|
721
|
-
s.paused = true;
|
|
722
|
-
s.active = false;
|
|
723
|
-
ctx.ui.notify(
|
|
724
|
-
`All env variables were skipped. Auto-mode remains paused.\nCollect them with /gsd secrets, then resume with /gsd auto.`,
|
|
725
|
-
"warning",
|
|
726
|
-
);
|
|
727
|
-
ctx.ui.setStatus("gsd-auto", "paused");
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
} catch (err) {
|
|
732
|
-
ctx.ui.notify(
|
|
733
|
-
`Secrets check error: ${getErrorMessage(err)}. Continuing without secrets.`,
|
|
734
|
-
"warning",
|
|
735
|
-
);
|
|
736
|
-
}
|
|
737
|
-
s.pausedForSecrets = false;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
updateSessionLock(lockBase(), "resuming", s.currentMilestoneId ?? "unknown", s.completedUnits.length);
|
|
741
|
-
writeLock(lockBase(), "resuming", s.currentMilestoneId ?? "unknown", s.completedUnits.length);
|
|
742
|
-
|
|
743
|
-
await dispatchNextUnit(ctx, pi);
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
// ── Fresh start path — delegated to auto-start.ts ──
|
|
748
|
-
const bootstrapDeps: BootstrapDeps = {
|
|
749
|
-
shouldUseWorktreeIsolation,
|
|
750
|
-
registerSigtermHandler,
|
|
751
|
-
lockBase,
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
const ready = await bootstrapAutoSession(s, ctx, pi, base, verboseMode, requestedStepMode, bootstrapDeps);
|
|
755
|
-
if (!ready) return;
|
|
756
|
-
|
|
757
|
-
// Dispatch the first unit
|
|
758
|
-
await dispatchNextUnit(ctx, pi);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// ─── Agent End Handler ────────────────────────────────────────────────────────
|
|
762
|
-
|
|
763
|
-
/** Guard against concurrent handleAgentEnd execution. */
|
|
764
|
-
|
|
765
|
-
export async function handleAgentEnd(
|
|
766
|
-
ctx: ExtensionContext,
|
|
767
|
-
pi: ExtensionAPI,
|
|
768
|
-
): Promise<void> {
|
|
769
|
-
if (!s.active || !s.cmdCtx) return;
|
|
770
|
-
if (s.handlingAgentEnd) {
|
|
771
|
-
// Another agent_end arrived while we're still processing the previous one.
|
|
772
|
-
// This happens when a unit dispatched inside handleAgentEnd (e.g. via hooks,
|
|
773
|
-
// triage, or quick-task early-dispatch paths) completes before the outer
|
|
774
|
-
// handleAgentEnd returns. Queue a retry so the completed unit's agent_end
|
|
775
|
-
// is not silently dropped (#1072).
|
|
776
|
-
s.pendingAgentEndRetry = true;
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
s.handlingAgentEnd = true;
|
|
780
|
-
|
|
781
|
-
try {
|
|
782
|
-
|
|
783
|
-
// Unit completed — clear its timeout
|
|
784
|
-
clearUnitTimeout();
|
|
785
|
-
|
|
786
|
-
// ── Pre-verification processing (commit, doctor, state rebuild, etc.) ──
|
|
787
|
-
const postUnitCtx: PostUnitContext = {
|
|
788
|
-
s,
|
|
789
|
-
ctx,
|
|
790
|
-
pi,
|
|
791
|
-
buildSnapshotOpts,
|
|
792
|
-
lockBase,
|
|
793
|
-
stopAuto,
|
|
794
|
-
pauseAuto,
|
|
795
|
-
updateProgressWidget,
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
const preResult = await postUnitPreVerification(postUnitCtx);
|
|
799
|
-
if (preResult === "dispatched") return;
|
|
800
|
-
|
|
801
|
-
// ── Verification gate: run typecheck/lint/test after execute-task ──
|
|
802
|
-
const verificationResult = await runPostUnitVerification(
|
|
803
|
-
{ s, ctx, pi },
|
|
804
|
-
dispatchNextUnit,
|
|
805
|
-
startDispatchGapWatchdog,
|
|
806
|
-
pauseAuto,
|
|
807
|
-
);
|
|
808
|
-
if (verificationResult === "retry" || verificationResult === "pause") return;
|
|
809
|
-
|
|
810
|
-
// ── Post-verification processing (DB dual-write, hooks, triage, quick-tasks) ──
|
|
811
|
-
const postResult = await postUnitPostVerification(postUnitCtx);
|
|
812
|
-
if (postResult === "dispatched" || postResult === "stopped") return;
|
|
813
|
-
if (postResult === "step-wizard") {
|
|
814
|
-
await showStepWizard(ctx, pi);
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
// ── Dispatch with hang detection (#1073) ────────────────────────────────
|
|
819
|
-
// Start a safety watchdog BEFORE calling dispatchNextUnit. If dispatch
|
|
820
|
-
// hangs at any await (newSession, model selection, etc.), the gap watchdog
|
|
821
|
-
// inside handleAgentEnd never fires because we never reach the check.
|
|
822
|
-
// This pre-dispatch watchdog ensures recovery even when dispatchNextUnit
|
|
823
|
-
// itself is permanently blocked.
|
|
824
|
-
const dispatchHangGuard = setTimeout(() => {
|
|
825
|
-
if (!s.active) return;
|
|
826
|
-
// dispatchNextUnit has been running for too long — it's likely hung.
|
|
827
|
-
// Start the gap watchdog which will retry dispatch from scratch.
|
|
828
|
-
if (!s.unitTimeoutHandle && !s.wrapupWarningHandle) {
|
|
829
|
-
ctx.ui.notify(
|
|
830
|
-
`Dispatch hang detected (${DISPATCH_HANG_TIMEOUT_MS / 1000}s without completion). Starting recovery watchdog.`,
|
|
831
|
-
"warning",
|
|
832
|
-
);
|
|
833
|
-
startDispatchGapWatchdog(ctx, pi);
|
|
834
|
-
}
|
|
835
|
-
}, DISPATCH_HANG_TIMEOUT_MS);
|
|
836
|
-
|
|
837
|
-
try {
|
|
838
|
-
await dispatchNextUnit(ctx, pi);
|
|
839
|
-
} catch (dispatchErr) {
|
|
840
|
-
const message = getErrorMessage(dispatchErr);
|
|
841
|
-
ctx.ui.notify(
|
|
842
|
-
`Dispatch error after unit completion: ${message}. Retrying in ${DISPATCH_GAP_TIMEOUT_MS / 1000}s.`,
|
|
843
|
-
"error",
|
|
844
|
-
);
|
|
845
|
-
startDispatchGapWatchdog(ctx, pi);
|
|
846
|
-
return;
|
|
847
|
-
} finally {
|
|
848
|
-
clearTimeout(dispatchHangGuard);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
if (s.active && !s.unitTimeoutHandle && !s.wrapupWarningHandle) {
|
|
852
|
-
startDispatchGapWatchdog(ctx, pi);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
} finally {
|
|
856
|
-
s.handlingAgentEnd = false;
|
|
857
|
-
|
|
858
|
-
// If an agent_end event was dropped by the reentrancy guard while we were
|
|
859
|
-
// processing, re-enter handleAgentEnd on the next microtask. This prevents
|
|
860
|
-
// the summarizing phase stall (#1072) where a unit dispatched inside
|
|
861
|
-
// handleAgentEnd (hooks, triage, quick-task) completes before we return,
|
|
862
|
-
// and its agent_end is silently dropped — leaving auto-mode active but
|
|
863
|
-
// permanently stalled with no unit running and no watchdog set.
|
|
864
|
-
if (s.pendingAgentEndRetry) {
|
|
865
|
-
s.pendingAgentEndRetry = false;
|
|
866
|
-
// Clear gap watchdog from the previous cycle to prevent concurrent
|
|
867
|
-
// dispatch when the deferred handleAgentEnd calls dispatchNextUnit (#1272).
|
|
868
|
-
clearDispatchGapWatchdog();
|
|
869
|
-
setImmediate(() => {
|
|
870
|
-
handleAgentEnd(ctx, pi).catch((err) => {
|
|
871
|
-
const msg = getErrorMessage(err);
|
|
872
|
-
ctx.ui.notify(`Deferred agent_end retry failed: ${msg}`, "error");
|
|
873
|
-
pauseAuto(ctx, pi).catch(() => {});
|
|
874
|
-
});
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// ─── Step Mode Wizard ─────────────────────────────────────────────────────
|
|
881
|
-
|
|
882
|
-
/**
|
|
883
|
-
* Show the step-mode wizard after a unit completes.
|
|
884
|
-
*/
|
|
885
|
-
async function showStepWizard(
|
|
886
|
-
ctx: ExtensionContext,
|
|
887
|
-
pi: ExtensionAPI,
|
|
888
|
-
): Promise<void> {
|
|
889
|
-
if (!s.cmdCtx) return;
|
|
890
|
-
|
|
891
|
-
const state = await deriveState(s.basePath);
|
|
892
|
-
const mid = state.activeMilestone?.id;
|
|
893
|
-
|
|
894
|
-
const justFinished = s.currentUnit
|
|
895
|
-
? `${unitVerb(s.currentUnit.type)} ${s.currentUnit.id}`
|
|
896
|
-
: "previous unit";
|
|
897
|
-
|
|
898
|
-
if (!mid || state.phase === "complete") {
|
|
899
|
-
const incomplete = (state.registry ?? []).filter(m => m.status !== "complete" && m.status !== "parked");
|
|
900
|
-
if (incomplete.length > 0 && state.phase !== "complete" && state.phase !== "blocked" && state.phase !== "pre-planning") {
|
|
901
|
-
const ids = incomplete.map(m => m.id).join(", ");
|
|
902
|
-
const diag = `basePath=${s.basePath}, milestones=[${state.registry.map(m => `${m.id}:${m.status}`).join(", ")}], phase=${state.phase}`;
|
|
903
|
-
ctx.ui.notify(`Unexpected: ${incomplete.length} incomplete milestone(s) (${ids}) but no active milestone.\n Diagnostic: ${diag}`, "error");
|
|
904
|
-
await stopAuto(ctx, pi, `No active milestone — ${incomplete.length} incomplete (${ids})`);
|
|
905
|
-
} else {
|
|
906
|
-
await stopAuto(ctx, pi, state.phase === "complete" ? "All work complete" : "No active milestone");
|
|
907
|
-
}
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
const nextDesc = _describeNextUnit(state);
|
|
912
|
-
|
|
913
|
-
const choice = await showNextAction(s.cmdCtx, {
|
|
914
|
-
title: `GSD — ${justFinished} complete`,
|
|
915
|
-
summary: [
|
|
916
|
-
`${mid}: ${state.activeMilestone?.title ?? mid}`,
|
|
917
|
-
...(state.activeSlice ? [`${state.activeSlice.id}: ${state.activeSlice.title}`] : []),
|
|
918
|
-
],
|
|
919
|
-
actions: [
|
|
920
|
-
{
|
|
921
|
-
id: "continue",
|
|
922
|
-
label: nextDesc.label,
|
|
923
|
-
description: nextDesc.description,
|
|
924
|
-
recommended: true,
|
|
925
|
-
},
|
|
926
|
-
{
|
|
927
|
-
id: "auto",
|
|
928
|
-
label: "Switch to auto",
|
|
929
|
-
description: "Continue without pausing between steps.",
|
|
930
|
-
},
|
|
931
|
-
{
|
|
932
|
-
id: "status",
|
|
933
|
-
label: "View status",
|
|
934
|
-
description: "Open the dashboard.",
|
|
935
|
-
},
|
|
936
|
-
],
|
|
937
|
-
notYetMessage: "Run /gsd next when ready to continue.",
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
if (choice === "continue") {
|
|
941
|
-
await dispatchNextUnit(ctx, pi);
|
|
942
|
-
} else if (choice === "auto") {
|
|
943
|
-
s.stepMode = false;
|
|
944
|
-
ctx.ui.setStatus("gsd-auto", "auto");
|
|
945
|
-
ctx.ui.notify("Switched to auto-mode.", "info");
|
|
946
|
-
await dispatchNextUnit(ctx, pi);
|
|
947
|
-
} else if (choice === "status") {
|
|
948
|
-
const { fireStatusViaCommand } = await import("./commands.js");
|
|
949
|
-
await fireStatusViaCommand(ctx as ExtensionCommandContext);
|
|
950
|
-
await showStepWizard(ctx, pi);
|
|
951
|
-
} else {
|
|
952
|
-
await pauseAuto(ctx, pi);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
/** Thin wrapper: delegates to auto-dashboard.ts, passing state accessors. */
|
|
958
|
-
function updateProgressWidget(
|
|
959
|
-
ctx: ExtensionContext,
|
|
960
|
-
unitType: string,
|
|
961
|
-
unitId: string,
|
|
962
|
-
state: GSDState,
|
|
963
|
-
): void {
|
|
964
|
-
const badge = s.currentUnitRouting?.tier
|
|
965
|
-
? ({ light: "L", standard: "S", heavy: "H" }[s.currentUnitRouting.tier] ?? undefined)
|
|
966
|
-
: undefined;
|
|
967
|
-
_updateProgressWidget(ctx, unitType, unitId, state, widgetStateAccessors, badge);
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
/** State accessors for the widget — closures over module globals. */
|
|
971
|
-
const widgetStateAccessors: WidgetStateAccessors = {
|
|
972
|
-
getAutoStartTime: () => s.autoStartTime,
|
|
973
|
-
isStepMode: () => s.stepMode,
|
|
974
|
-
getCmdCtx: () => s.cmdCtx,
|
|
975
|
-
getBasePath: () => s.basePath,
|
|
976
|
-
isVerbose: () => s.verbose,
|
|
977
|
-
};
|
|
978
|
-
|
|
979
|
-
// ─── Core Loop ────────────────────────────────────────────────────────────────
|
|
980
|
-
|
|
981
|
-
async function dispatchNextUnit(
|
|
982
|
-
ctx: ExtensionContext,
|
|
983
|
-
pi: ExtensionAPI,
|
|
984
|
-
): Promise<void> {
|
|
985
|
-
if (!s.active || !s.cmdCtx) {
|
|
986
|
-
debugLog(`dispatchNextUnit early return — active=${s.active}, cmdCtx=${!!s.cmdCtx}`);
|
|
987
|
-
if (s.active && !s.cmdCtx) {
|
|
988
|
-
ctx.ui.notify("Auto-mode session expired. Run /gsd auto to restart.", "info");
|
|
989
|
-
}
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// ── Session lock validation: detect if another process has taken over ──
|
|
994
|
-
if (lockBase() && !validateSessionLock(lockBase())) {
|
|
995
|
-
debugLog("dispatchNextUnit session-lock-lost — another process may have taken over");
|
|
996
|
-
ctx.ui.notify(
|
|
997
|
-
"Session lock lost — another GSD process appears to have taken over. Stopping gracefully.",
|
|
998
|
-
"error",
|
|
999
|
-
);
|
|
1000
|
-
// Don't call stopAuto here to avoid releasing the lock we don't own
|
|
1001
|
-
s.active = false;
|
|
1002
|
-
s.paused = false;
|
|
1003
|
-
clearUnitTimeout();
|
|
1004
|
-
deregisterSigtermHandler();
|
|
1005
|
-
ctx.ui.setStatus("gsd-auto", undefined);
|
|
1006
|
-
ctx.ui.setWidget("gsd-progress", undefined);
|
|
1007
|
-
ctx.ui.setFooter(undefined);
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// Reentrancy guard — unconditional to prevent concurrent dispatch from
|
|
1012
|
-
// gap watchdog or pendingAgentEndRetry during skip chains (#1272).
|
|
1013
|
-
// Previously the guard was bypassed when skipDepth > 0, but the recursive
|
|
1014
|
-
// skip chain's inner finally block resets s.dispatching = false before the
|
|
1015
|
-
// outer call's finally runs, opening a window for concurrent entry.
|
|
1016
|
-
if (s.dispatching) {
|
|
1017
|
-
debugLog("dispatchNextUnit reentrancy guard — another dispatch in progress, bailing");
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
s.dispatching = true;
|
|
1021
|
-
try {
|
|
1022
|
-
// Recursion depth guard
|
|
1023
|
-
if (s.skipDepth > MAX_SKIP_DEPTH) {
|
|
1024
|
-
s.skipDepth = 0;
|
|
1025
|
-
ctx.ui.notify(`Skipped ${MAX_SKIP_DEPTH}+ completed units. Yielding to UI before continuing.`, "info");
|
|
1026
|
-
await new Promise(r => setTimeout(r, 200));
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// Resource version guard
|
|
1030
|
-
const staleMsg = checkResourcesStale(s.resourceVersionOnStart);
|
|
1031
|
-
if (staleMsg) {
|
|
1032
|
-
await stopAuto(ctx, pi, staleMsg);
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
invalidateAllCaches();
|
|
1037
|
-
s.lastPromptCharCount = undefined;
|
|
1038
|
-
s.lastBaselineCharCount = undefined;
|
|
1039
|
-
|
|
1040
|
-
// ── Pre-dispatch health gate ──
|
|
1041
|
-
try {
|
|
1042
|
-
const healthGate = await preDispatchHealthGate(s.basePath);
|
|
1043
|
-
if (healthGate.fixesApplied.length > 0) {
|
|
1044
|
-
ctx.ui.notify(`Pre-dispatch: ${healthGate.fixesApplied.join(", ")}`, "info");
|
|
1045
|
-
}
|
|
1046
|
-
if (!healthGate.proceed) {
|
|
1047
|
-
ctx.ui.notify(healthGate.reason ?? "Pre-dispatch health check failed.", "error");
|
|
1048
|
-
await pauseAuto(ctx, pi);
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
} catch {
|
|
1052
|
-
// Non-fatal
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
const stopDeriveTimer = debugTime("derive-state");
|
|
1056
|
-
let state = await deriveState(s.basePath);
|
|
1057
|
-
stopDeriveTimer({
|
|
1058
|
-
phase: state.phase,
|
|
1059
|
-
milestone: state.activeMilestone?.id,
|
|
1060
|
-
slice: state.activeSlice?.id,
|
|
1061
|
-
task: state.activeTask?.id,
|
|
1062
|
-
});
|
|
1063
|
-
let mid = state.activeMilestone?.id;
|
|
1064
|
-
let midTitle = state.activeMilestone?.title;
|
|
1065
|
-
|
|
1066
|
-
// Detect milestone transition
|
|
1067
|
-
if (mid && s.currentMilestoneId && mid !== s.currentMilestoneId) {
|
|
1068
|
-
ctx.ui.notify(
|
|
1069
|
-
`Milestone ${ s.currentMilestoneId } complete. Advancing to ${mid}: ${midTitle}.`,
|
|
1070
|
-
"info",
|
|
1071
|
-
);
|
|
1072
|
-
sendDesktopNotification("GSD", `Milestone ${s.currentMilestoneId} complete!`, "success", "milestone");
|
|
1073
|
-
const vizPrefs = loadEffectiveGSDPreferences()?.preferences;
|
|
1074
|
-
if (vizPrefs?.auto_visualize) {
|
|
1075
|
-
ctx.ui.notify("Run /gsd visualize to see progress overview.", "info");
|
|
1076
|
-
}
|
|
1077
|
-
if (vizPrefs?.auto_report !== false) {
|
|
1078
|
-
try {
|
|
1079
|
-
const { loadVisualizerData } = await import("./visualizer-data.js");
|
|
1080
|
-
const { generateHtmlReport } = await import("./export-html.js");
|
|
1081
|
-
const { writeReportSnapshot, reportsDir } = await import("./reports.js");
|
|
1082
|
-
const { basename } = await import("node:path");
|
|
1083
|
-
const snapData = await loadVisualizerData(s.basePath);
|
|
1084
|
-
const completedMs = snapData.milestones.find(m => m.id === s.currentMilestoneId);
|
|
1085
|
-
const msTitle = completedMs?.title ?? s.currentMilestoneId;
|
|
1086
|
-
const gsdVersion = process.env.GSD_VERSION ?? "0.0.0";
|
|
1087
|
-
const projName = basename(s.basePath);
|
|
1088
|
-
const doneSlices = snapData.milestones.reduce((s, m) => s + m.slices.filter(sl => sl.done).length, 0);
|
|
1089
|
-
const totalSlices = snapData.milestones.reduce((s, m) => s + m.slices.length, 0);
|
|
1090
|
-
const outPath = writeReportSnapshot({ basePath: s.basePath,
|
|
1091
|
-
html: generateHtmlReport(snapData, {
|
|
1092
|
-
projectName: projName,
|
|
1093
|
-
projectPath: s.basePath,
|
|
1094
|
-
gsdVersion,
|
|
1095
|
-
milestoneId: s.currentMilestoneId,
|
|
1096
|
-
indexRelPath: "index.html",
|
|
1097
|
-
}),
|
|
1098
|
-
milestoneId: s.currentMilestoneId,
|
|
1099
|
-
milestoneTitle: msTitle,
|
|
1100
|
-
kind: "milestone",
|
|
1101
|
-
projectName: projName,
|
|
1102
|
-
projectPath: s.basePath,
|
|
1103
|
-
gsdVersion,
|
|
1104
|
-
totalCost: snapData.totals?.cost ?? 0,
|
|
1105
|
-
totalTokens: snapData.totals?.tokens.total ?? 0,
|
|
1106
|
-
totalDuration: snapData.totals?.duration ?? 0,
|
|
1107
|
-
doneSlices,
|
|
1108
|
-
totalSlices,
|
|
1109
|
-
doneMilestones: snapData.milestones.filter(m => m.status === "complete").length,
|
|
1110
|
-
totalMilestones: snapData.milestones.length,
|
|
1111
|
-
phase: snapData.phase,
|
|
1112
|
-
});
|
|
1113
|
-
ctx.ui.notify(
|
|
1114
|
-
`Report saved: .gsd/reports/${basename(outPath)} — open index.html to browse progression.`,
|
|
1115
|
-
"info",
|
|
1116
|
-
);
|
|
1117
|
-
} catch (err) {
|
|
1118
|
-
ctx.ui.notify(
|
|
1119
|
-
`Report generation failed: ${getErrorMessage(err)}`,
|
|
1120
|
-
"warning",
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
// Reset stuck detection for new milestone
|
|
1125
|
-
s.unitDispatchCount.clear();
|
|
1126
|
-
s.unitRecoveryCount.clear();
|
|
1127
|
-
s.unitConsecutiveSkips.clear();
|
|
1128
|
-
s.unitLifetimeDispatches.clear();
|
|
1129
|
-
try {
|
|
1130
|
-
const file = completedKeysPath(s.basePath);
|
|
1131
|
-
if (existsSync(file)) {
|
|
1132
|
-
atomicWriteSync(file, JSON.stringify([]));
|
|
1133
|
-
}
|
|
1134
|
-
s.completedKeySet.clear();
|
|
1135
|
-
} catch (e) { debugLog("completed-keys-reset-failed", { error: getErrorMessage(e) }); }
|
|
1136
|
-
|
|
1137
|
-
// ── Worktree lifecycle on milestone transition (#616) ──
|
|
1138
|
-
if ((isInAutoWorktree(s.basePath) || getIsolationMode() === "branch") && shouldUseWorktreeIsolation()) {
|
|
1139
|
-
tryMergeMilestone(ctx, s.currentMilestoneId, "transition");
|
|
1140
|
-
|
|
1141
|
-
// Reset to project root and re-derive state for the new milestone
|
|
1142
|
-
if (s.originalBasePath) {
|
|
1143
|
-
s.basePath = s.originalBasePath;
|
|
1144
|
-
s.gitService = createGitService(s.basePath);
|
|
1145
|
-
}
|
|
1146
|
-
invalidateAllCaches();
|
|
1147
|
-
|
|
1148
|
-
state = await deriveState(s.basePath);
|
|
1149
|
-
mid = state.activeMilestone?.id;
|
|
1150
|
-
midTitle = state.activeMilestone?.title;
|
|
1151
|
-
|
|
1152
|
-
if (mid) {
|
|
1153
|
-
captureIntegrationBranch(s.basePath, mid);
|
|
1154
|
-
try {
|
|
1155
|
-
const wtPath = createAutoWorktree(s.basePath, mid);
|
|
1156
|
-
s.basePath = wtPath;
|
|
1157
|
-
s.gitService = createGitService(s.basePath);
|
|
1158
|
-
ctx.ui.notify(`Created auto-worktree for ${mid} at ${wtPath}`, "info");
|
|
1159
|
-
} catch (err) {
|
|
1160
|
-
ctx.ui.notify(
|
|
1161
|
-
`Auto-worktree creation for ${mid} failed: ${getErrorMessage(err)}. Continuing in project root.`,
|
|
1162
|
-
"warning",
|
|
1163
|
-
);
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
} else {
|
|
1167
|
-
if (getIsolationMode() !== "none") {
|
|
1168
|
-
captureIntegrationBranch(s.originalBasePath || s.basePath, mid);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
const pendingIds = (state.registry ?? [])
|
|
1173
|
-
.filter(m => m.status !== "complete")
|
|
1174
|
-
.map(m => m.id);
|
|
1175
|
-
pruneQueueOrder(s.basePath, pendingIds);
|
|
1176
|
-
}
|
|
1177
|
-
if (mid) {
|
|
1178
|
-
s.currentMilestoneId = mid;
|
|
1179
|
-
setActiveMilestoneId(s.basePath, mid);
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
if (!mid) {
|
|
1183
|
-
if (s.currentUnit) {
|
|
1184
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
const incomplete = (state.registry ?? []).filter(m => m.status !== "complete" && m.status !== "parked");
|
|
1188
|
-
if (incomplete.length === 0) {
|
|
1189
|
-
// Genuinely all complete (parked milestones excluded) — merge milestone branch to main before stopping (#962)
|
|
1190
|
-
if (s.currentMilestoneId) {
|
|
1191
|
-
tryMergeMilestone(ctx, s.currentMilestoneId, "complete");
|
|
1192
|
-
}
|
|
1193
|
-
sendDesktopNotification("GSD", "All milestones complete!", "success", "milestone");
|
|
1194
|
-
await stopAuto(ctx, pi, "All milestones complete");
|
|
1195
|
-
} else if (state.phase === "blocked") {
|
|
1196
|
-
const blockerMsg = `Blocked: ${state.blockers.join(", ")}`;
|
|
1197
|
-
await stopAuto(ctx, pi, blockerMsg);
|
|
1198
|
-
ctx.ui.notify(`${blockerMsg}. Fix and run /gsd auto.`, "warning");
|
|
1199
|
-
sendDesktopNotification("GSD", blockerMsg, "error", "attention");
|
|
1200
|
-
} else {
|
|
1201
|
-
const ids = incomplete.map(m => m.id).join(", ");
|
|
1202
|
-
const diag = `basePath=${s.basePath}, milestones=[${state.registry.map(m => `${m.id}:${m.status}`).join(", ")}], phase=${state.phase}`;
|
|
1203
|
-
ctx.ui.notify(`Unexpected: ${incomplete.length} incomplete milestone(s) (${ids}) but no active milestone.\n Diagnostic: ${diag}`, "error");
|
|
1204
|
-
await stopAuto(ctx, pi, `No active milestone — ${incomplete.length} incomplete (${ids}), see diagnostic above`);
|
|
1205
|
-
}
|
|
1206
|
-
return;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
if (!midTitle) {
|
|
1210
|
-
midTitle = mid;
|
|
1211
|
-
ctx.ui.notify(`Milestone ${mid} has no title in roadmap — using ID as fallback.`, "warning");
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
// ── Mid-merge safety check ──
|
|
1215
|
-
if (reconcileMergeState(s.basePath, ctx)) {
|
|
1216
|
-
invalidateAllCaches();
|
|
1217
|
-
state = await deriveState(s.basePath);
|
|
1218
|
-
mid = state.activeMilestone?.id;
|
|
1219
|
-
midTitle = state.activeMilestone?.title;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
if (!mid || !midTitle) {
|
|
1223
|
-
if (s.currentUnit) {
|
|
1224
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1225
|
-
}
|
|
1226
|
-
const noMilestoneReason = !mid
|
|
1227
|
-
? "No active milestone after merge reconciliation"
|
|
1228
|
-
: `Milestone ${mid} has no title after reconciliation`;
|
|
1229
|
-
await stopAuto(ctx, pi, noMilestoneReason);
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
// Determine next unit
|
|
1234
|
-
let unitType: string;
|
|
1235
|
-
let unitId: string;
|
|
1236
|
-
let prompt: string;
|
|
1237
|
-
|
|
1238
|
-
if (state.phase === "complete") {
|
|
1239
|
-
if (s.currentUnit) {
|
|
1240
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1241
|
-
}
|
|
1242
|
-
try {
|
|
1243
|
-
const file = completedKeysPath(s.basePath);
|
|
1244
|
-
if (existsSync(file)) {
|
|
1245
|
-
atomicWriteSync(file, JSON.stringify([]));
|
|
1246
|
-
}
|
|
1247
|
-
s.completedKeySet.clear();
|
|
1248
|
-
} catch (e) { debugLog("completed-keys-reset-failed", { error: getErrorMessage(e) }); }
|
|
1249
|
-
// ── Milestone merge ──
|
|
1250
|
-
if (s.currentMilestoneId) {
|
|
1251
|
-
tryMergeMilestone(ctx, s.currentMilestoneId, "complete");
|
|
1252
|
-
}
|
|
1253
|
-
sendDesktopNotification("GSD", `Milestone ${mid} complete!`, "success", "milestone");
|
|
1254
|
-
await stopAuto(ctx, pi, `Milestone ${mid} complete`);
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
if (state.phase === "blocked") {
|
|
1259
|
-
if (s.currentUnit) {
|
|
1260
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1261
|
-
}
|
|
1262
|
-
const blockerMsg = `Blocked: ${state.blockers.join(", ")}`;
|
|
1263
|
-
await stopAuto(ctx, pi, blockerMsg);
|
|
1264
|
-
ctx.ui.notify(`${blockerMsg}. Fix and run /gsd auto.`, "warning");
|
|
1265
|
-
sendDesktopNotification("GSD", blockerMsg, "error", "attention");
|
|
1266
|
-
return;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
// Budget ceiling guard, context window guard, secrets gate, dispatch table
|
|
1270
|
-
const prefs = loadEffectiveGSDPreferences()?.preferences;
|
|
1271
|
-
|
|
1272
|
-
const budgetCeiling = prefs?.budget_ceiling;
|
|
1273
|
-
if (budgetCeiling !== undefined && budgetCeiling > 0) {
|
|
1274
|
-
const currentLedger = getLedger();
|
|
1275
|
-
const totalCost = currentLedger ? getProjectTotals(currentLedger.units).cost : 0;
|
|
1276
|
-
const budgetPct = totalCost / budgetCeiling;
|
|
1277
|
-
const budgetAlertLevel = getBudgetAlertLevel(budgetPct);
|
|
1278
|
-
const newBudgetAlertLevel = getNewBudgetAlertLevel(s.lastBudgetAlertLevel, budgetPct);
|
|
1279
|
-
const enforcement = prefs?.budget_enforcement ?? "pause";
|
|
1280
|
-
|
|
1281
|
-
const budgetEnforcementAction = getBudgetEnforcementAction(enforcement, budgetPct);
|
|
1282
|
-
|
|
1283
|
-
if (newBudgetAlertLevel === 100 && budgetEnforcementAction !== "none") {
|
|
1284
|
-
const msg = `Budget ceiling ${formatCost(budgetCeiling)} reached (spent ${formatCost(totalCost)}).`;
|
|
1285
|
-
s.lastBudgetAlertLevel = newBudgetAlertLevel;
|
|
1286
|
-
if (budgetEnforcementAction === "halt") {
|
|
1287
|
-
sendDesktopNotification("GSD", msg, "error", "budget");
|
|
1288
|
-
await stopAuto(ctx, pi, "Budget ceiling reached");
|
|
1289
|
-
return;
|
|
1290
|
-
}
|
|
1291
|
-
if (budgetEnforcementAction === "pause") {
|
|
1292
|
-
ctx.ui.notify(`${msg} Pausing auto-mode — /gsd auto to override and continue.`, "warning");
|
|
1293
|
-
sendDesktopNotification("GSD", msg, "warning", "budget");
|
|
1294
|
-
await pauseAuto(ctx, pi);
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
ctx.ui.notify(`${msg} Continuing (enforcement: warn).`, "warning");
|
|
1298
|
-
sendDesktopNotification("GSD", msg, "warning", "budget");
|
|
1299
|
-
} else if (newBudgetAlertLevel === 90) {
|
|
1300
|
-
s.lastBudgetAlertLevel = newBudgetAlertLevel;
|
|
1301
|
-
ctx.ui.notify(`Budget 90%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "warning");
|
|
1302
|
-
sendDesktopNotification("GSD", `Budget 90%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "warning", "budget");
|
|
1303
|
-
} else if (newBudgetAlertLevel === 80) {
|
|
1304
|
-
s.lastBudgetAlertLevel = newBudgetAlertLevel;
|
|
1305
|
-
ctx.ui.notify(`Approaching budget ceiling — 80%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "warning");
|
|
1306
|
-
sendDesktopNotification("GSD", `Approaching budget ceiling — 80%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "warning", "budget");
|
|
1307
|
-
} else if (newBudgetAlertLevel === 75) {
|
|
1308
|
-
s.lastBudgetAlertLevel = newBudgetAlertLevel;
|
|
1309
|
-
ctx.ui.notify(`Budget 75%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "info");
|
|
1310
|
-
sendDesktopNotification("GSD", `Budget 75%: ${formatCost(totalCost)} / ${formatCost(budgetCeiling)}`, "info", "budget");
|
|
1311
|
-
} else if (budgetAlertLevel === 0) {
|
|
1312
|
-
s.lastBudgetAlertLevel = 0;
|
|
1313
|
-
}
|
|
1314
|
-
} else {
|
|
1315
|
-
s.lastBudgetAlertLevel = 0;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
const contextThreshold = prefs?.context_pause_threshold ?? 0;
|
|
1319
|
-
if (contextThreshold > 0 && s.cmdCtx) {
|
|
1320
|
-
const contextUsage = s.cmdCtx.getContextUsage();
|
|
1321
|
-
if (contextUsage && contextUsage.percent !== null && contextUsage.percent >= contextThreshold) {
|
|
1322
|
-
const msg = `Context window at ${contextUsage.percent}% (threshold: ${contextThreshold}%). Pausing to prevent truncated output.`;
|
|
1323
|
-
ctx.ui.notify(`${msg} Run /gsd auto to continue (will start fresh session).`, "warning");
|
|
1324
|
-
sendDesktopNotification("GSD", `Context ${contextUsage.percent}% — paused`, "warning", "attention");
|
|
1325
|
-
await pauseAuto(ctx, pi);
|
|
1326
|
-
return;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// Secrets re-check gate
|
|
1331
|
-
const runSecretsGate = async () => {
|
|
1332
|
-
try {
|
|
1333
|
-
const manifestStatus = await getManifestStatus(s.basePath, mid);
|
|
1334
|
-
if (manifestStatus && manifestStatus.pending.length > 0) {
|
|
1335
|
-
const result = await collectSecretsFromManifest(s.basePath, mid, ctx);
|
|
1336
|
-
if (result && result.applied && result.skipped && result.existingSkipped) {
|
|
1337
|
-
ctx.ui.notify(
|
|
1338
|
-
`Secrets collected: ${result.applied.length} applied, ${result.skipped.length} skipped, ${result.existingSkipped.length} already set.`,
|
|
1339
|
-
"info",
|
|
1340
|
-
);
|
|
1341
|
-
} else {
|
|
1342
|
-
ctx.ui.notify("Secrets collection skipped.", "info");
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
} catch (err) {
|
|
1346
|
-
ctx.ui.notify(
|
|
1347
|
-
`Secrets collection error: ${getErrorMessage(err)}. Continuing with next task.`,
|
|
1348
|
-
"warning",
|
|
1349
|
-
);
|
|
1350
|
-
}
|
|
1351
|
-
};
|
|
1352
|
-
|
|
1353
|
-
await runSecretsGate();
|
|
1354
|
-
|
|
1355
|
-
// ── Interactive discussion gate ──
|
|
1356
|
-
// If the active milestone needs discussion (has CONTEXT-DRAFT.md but no roadmap),
|
|
1357
|
-
// stop auto-mode and route to the interactive discussion flow. The guided-flow
|
|
1358
|
-
// handles needs-discussion correctly — it just needs to be called instead of
|
|
1359
|
-
// letting the dispatch table fire "needs-discussion → stop" (#1170).
|
|
1360
|
-
if (state.phase === "needs-discussion") {
|
|
1361
|
-
if (s.currentUnit) {
|
|
1362
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1363
|
-
}
|
|
1364
|
-
const cmdCtx = s.cmdCtx!;
|
|
1365
|
-
const basePath = s.basePath;
|
|
1366
|
-
await stopAuto(ctx, pi, `${mid}: ${midTitle} needs discussion before planning.`);
|
|
1367
|
-
const { showSmartEntry } = await import("./guided-flow.js");
|
|
1368
|
-
await showSmartEntry(cmdCtx, pi, basePath);
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// ── Dispatch table ──
|
|
1373
|
-
const dispatchResult = await resolveDispatch({ basePath: s.basePath, mid, midTitle: midTitle!, state, prefs,
|
|
1374
|
-
});
|
|
1375
|
-
|
|
1376
|
-
if (dispatchResult.action === "stop") {
|
|
1377
|
-
if (s.currentUnit) {
|
|
1378
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1379
|
-
}
|
|
1380
|
-
await stopAuto(ctx, pi, dispatchResult.reason);
|
|
1381
|
-
return;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
if (dispatchResult.action !== "dispatch") {
|
|
1385
|
-
// Defer re-dispatch to next microtask so s.dispatching is released first,
|
|
1386
|
-
// preventing reentrancy guard bypass during concurrent entry (#1272).
|
|
1387
|
-
setImmediate(() => dispatchNextUnit(ctx, pi).catch(err => {
|
|
1388
|
-
ctx.ui.notify(`Deferred dispatch failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
1389
|
-
pauseAuto(ctx, pi).catch(() => {});
|
|
1390
|
-
}));
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
unitType = dispatchResult.unitType;
|
|
1395
|
-
unitId = dispatchResult.unitId;
|
|
1396
|
-
prompt = dispatchResult.prompt;
|
|
1397
|
-
|
|
1398
|
-
// ── Pre-dispatch hooks ──
|
|
1399
|
-
const preDispatchResult = runPreDispatchHooks(unitType, unitId, prompt, s.basePath);
|
|
1400
|
-
if (preDispatchResult.firedHooks.length > 0) {
|
|
1401
|
-
ctx.ui.notify(
|
|
1402
|
-
`Pre-dispatch hook${preDispatchResult.firedHooks.length > 1 ? "s" : ""}: ${preDispatchResult.firedHooks.join(", ")}`,
|
|
1403
|
-
"info",
|
|
1404
|
-
);
|
|
1405
|
-
}
|
|
1406
|
-
if (preDispatchResult.action === "skip") {
|
|
1407
|
-
ctx.ui.notify(`Skipping ${unitType} ${unitId} (pre-dispatch hook).`, "info");
|
|
1408
|
-
setImmediate(() => dispatchNextUnit(ctx, pi).catch(err => {
|
|
1409
|
-
ctx.ui.notify(`Deferred dispatch failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
1410
|
-
pauseAuto(ctx, pi).catch(() => {});
|
|
1411
|
-
}));
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
if (preDispatchResult.action === "replace") {
|
|
1415
|
-
prompt = preDispatchResult.prompt ?? prompt;
|
|
1416
|
-
if (preDispatchResult.unitType) unitType = preDispatchResult.unitType;
|
|
1417
|
-
} else if (preDispatchResult.prompt) {
|
|
1418
|
-
prompt = preDispatchResult.prompt;
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
const priorSliceBlocker = getPriorSliceCompletionBlocker(s.basePath, getMainBranch(s.basePath), unitType, unitId);
|
|
1422
|
-
if (priorSliceBlocker) {
|
|
1423
|
-
await stopAuto(ctx, pi, priorSliceBlocker);
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
const observabilityIssues = await _collectObservabilityWarnings(ctx, s.basePath, unitType, unitId);
|
|
1428
|
-
|
|
1429
|
-
// ── Idempotency check (delegated to auto-idempotency.ts) ──
|
|
1430
|
-
const idempotencyResult = checkIdempotency({
|
|
1431
|
-
s,
|
|
1432
|
-
unitType,
|
|
1433
|
-
unitId,
|
|
1434
|
-
basePath: s.basePath,
|
|
1435
|
-
notify: (msg, level) => ctx.ui.notify(msg, level),
|
|
1436
|
-
});
|
|
1437
|
-
|
|
1438
|
-
if (idempotencyResult.action === "skip") {
|
|
1439
|
-
if (idempotencyResult.reason === "completed" || idempotencyResult.reason === "fallback-persisted" || idempotencyResult.reason === "phantom-loop-cleared" || idempotencyResult.reason === "evicted") {
|
|
1440
|
-
if (!s.active) return;
|
|
1441
|
-
s.skipDepth++;
|
|
1442
|
-
const skipDelay = idempotencyResult.reason === "phantom-loop-cleared" ? 50 : 150;
|
|
1443
|
-
// Defer re-dispatch so s.dispatching is released first (#1272).
|
|
1444
|
-
setTimeout(() => {
|
|
1445
|
-
dispatchNextUnit(ctx, pi).catch(err => {
|
|
1446
|
-
ctx.ui.notify(`Deferred skip-dispatch failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
1447
|
-
pauseAuto(ctx, pi).catch(() => {});
|
|
1448
|
-
}).finally(() => {
|
|
1449
|
-
s.skipDepth = Math.max(0, s.skipDepth - 1);
|
|
1450
|
-
});
|
|
1451
|
-
}, skipDelay);
|
|
1452
|
-
return;
|
|
1453
|
-
}
|
|
1454
|
-
} else if (idempotencyResult.action === "stop") {
|
|
1455
|
-
await stopAuto(ctx, pi, idempotencyResult.reason);
|
|
1456
|
-
ctx.ui.notify(
|
|
1457
|
-
`Hard loop detected: ${unitType} ${unitId} hit lifetime cap during skip cycle.`,
|
|
1458
|
-
"error",
|
|
1459
|
-
);
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
// "rerun" and "proceed" fall through to stuck detection
|
|
1463
|
-
|
|
1464
|
-
// ── Stuck detection (delegated to auto-stuck-detection.ts) ──
|
|
1465
|
-
const stuckResult = await checkStuckAndRecover({
|
|
1466
|
-
s,
|
|
1467
|
-
ctx,
|
|
1468
|
-
unitType,
|
|
1469
|
-
unitId,
|
|
1470
|
-
basePath: s.basePath,
|
|
1471
|
-
buildSnapshotOpts: () => buildSnapshotOpts(unitType, unitId),
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
if (stuckResult.action === "stop") {
|
|
1475
|
-
await stopAuto(ctx, pi, stuckResult.reason);
|
|
1476
|
-
if (stuckResult.notifyMessage) {
|
|
1477
|
-
ctx.ui.notify(stuckResult.notifyMessage, "error");
|
|
1478
|
-
}
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
if (stuckResult.action === "recovered" && stuckResult.dispatchAgain) {
|
|
1482
|
-
// Defer re-dispatch so s.dispatching is released first (#1272).
|
|
1483
|
-
setImmediate(() => dispatchNextUnit(ctx, pi).catch(err => {
|
|
1484
|
-
ctx.ui.notify(`Deferred recovery-dispatch failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
1485
|
-
pauseAuto(ctx, pi).catch(() => {});
|
|
1486
|
-
}));
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// Snapshot metrics + activity log for the PREVIOUS unit before we reassign.
|
|
1491
|
-
if (s.currentUnit) {
|
|
1492
|
-
await closeoutUnit(ctx, s.basePath, s.currentUnit.type, s.currentUnit.id, s.currentUnit.startedAt, buildSnapshotOpts(s.currentUnit.type, s.currentUnit.id));
|
|
1493
|
-
|
|
1494
|
-
if (s.currentUnitRouting) {
|
|
1495
|
-
const isRetry = s.currentUnit.type === unitType && s.currentUnit.id === unitId;
|
|
1496
|
-
recordOutcome(
|
|
1497
|
-
s.currentUnit.type,
|
|
1498
|
-
s.currentUnitRouting.tier as "light" | "standard" | "heavy",
|
|
1499
|
-
!isRetry,
|
|
1500
|
-
);
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
|
-
const closeoutKey = `${s.currentUnit.type}/${s.currentUnit.id}`;
|
|
1504
|
-
const incomingKey = `${unitType}/${unitId}`;
|
|
1505
|
-
const isHookUnit = s.currentUnit.type.startsWith("hook/");
|
|
1506
|
-
const artifactVerified = isHookUnit || verifyExpectedArtifact(s.currentUnit.type, s.currentUnit.id, s.basePath);
|
|
1507
|
-
if (closeoutKey !== incomingKey && artifactVerified) {
|
|
1508
|
-
if (!isHookUnit) {
|
|
1509
|
-
persistCompletedKey(s.basePath, closeoutKey);
|
|
1510
|
-
s.completedKeySet.add(closeoutKey);
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
s.completedUnits.push({
|
|
1514
|
-
type: s.currentUnit.type,
|
|
1515
|
-
id: s.currentUnit.id,
|
|
1516
|
-
startedAt: s.currentUnit.startedAt,
|
|
1517
|
-
finishedAt: Date.now(),
|
|
1518
|
-
});
|
|
1519
|
-
if (s.completedUnits.length > 200) {
|
|
1520
|
-
s.completedUnits = s.completedUnits.slice(-200);
|
|
1521
|
-
}
|
|
1522
|
-
clearUnitRuntimeRecord(s.basePath, s.currentUnit.type, s.currentUnit.id);
|
|
1523
|
-
s.unitDispatchCount.delete(`${s.currentUnit.type}/${s.currentUnit.id}`);
|
|
1524
|
-
s.unitRecoveryCount.delete(`${s.currentUnit.type}/${s.currentUnit.id}`);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
s.currentUnit = { type: unitType, id: unitId, startedAt: Date.now() };
|
|
1528
|
-
captureAvailableSkills();
|
|
1529
|
-
writeUnitRuntimeRecord(s.basePath, unitType, unitId, s.currentUnit.startedAt, {
|
|
1530
|
-
phase: "dispatched",
|
|
1531
|
-
wrapupWarningSent: false,
|
|
1532
|
-
timeoutAt: null,
|
|
1533
|
-
lastProgressAt: s.currentUnit.startedAt,
|
|
1534
|
-
progressCount: 0,
|
|
1535
|
-
lastProgressKind: "dispatch",
|
|
1536
|
-
});
|
|
1537
|
-
|
|
1538
|
-
// Status bar + progress widget
|
|
1539
|
-
ctx.ui.setStatus("gsd-auto", "auto");
|
|
1540
|
-
if (mid) updateSliceProgressCache(s.basePath, mid, state.activeSlice?.id);
|
|
1541
|
-
updateProgressWidget(ctx, unitType, unitId, state);
|
|
1542
|
-
|
|
1543
|
-
ensurePreconditions(unitType, unitId, s.basePath, state);
|
|
1544
|
-
|
|
1545
|
-
// Fresh session — with timeout to prevent permanent hangs (#1073).
|
|
1546
|
-
// If newSession() hangs (e.g., session manager deadlock, network issue),
|
|
1547
|
-
// without this timeout the entire dispatch chain stalls permanently: no
|
|
1548
|
-
// timeouts are set, no gap watchdog fires, and auto-mode is left active
|
|
1549
|
-
// but idle until the user Ctrl+C's.
|
|
1550
|
-
let result: { cancelled: boolean };
|
|
1551
|
-
try {
|
|
1552
|
-
const sessionPromise = s.cmdCtx!.newSession();
|
|
1553
|
-
const timeoutPromise = new Promise<{ cancelled: true }>((resolve) =>
|
|
1554
|
-
setTimeout(() => resolve({ cancelled: true }), NEW_SESSION_TIMEOUT_MS),
|
|
1555
|
-
);
|
|
1556
|
-
result = await Promise.race([sessionPromise, timeoutPromise]);
|
|
1557
|
-
} catch (sessionErr) {
|
|
1558
|
-
const msg = getErrorMessage(sessionErr);
|
|
1559
|
-
ctx.ui.notify(`Session creation failed: ${msg}. Retrying via watchdog.`, "error");
|
|
1560
|
-
throw new Error(`newSession() failed: ${msg}`);
|
|
1561
|
-
}
|
|
1562
|
-
if (result.cancelled) {
|
|
1563
|
-
ctx.ui.notify(
|
|
1564
|
-
`Session creation timed out or was cancelled for ${unitType} ${unitId}. Will retry.`,
|
|
1565
|
-
"warning",
|
|
1566
|
-
);
|
|
1567
|
-
await stopAuto(ctx, pi, "Session creation failed");
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
1572
|
-
updateSessionLock(lockBase(), unitType, unitId, s.completedUnits.length, sessionFile);
|
|
1573
|
-
writeLock(lockBase(), unitType, unitId, s.completedUnits.length, sessionFile);
|
|
1574
|
-
|
|
1575
|
-
// Prompt injection
|
|
1576
|
-
const MAX_RECOVERY_CHARS = 50_000;
|
|
1577
|
-
let finalPrompt = prompt;
|
|
1578
|
-
|
|
1579
|
-
if (s.pendingVerificationRetry) {
|
|
1580
|
-
const retryCtx = s.pendingVerificationRetry;
|
|
1581
|
-
s.pendingVerificationRetry = null;
|
|
1582
|
-
const capped = retryCtx.failureContext.length > MAX_RECOVERY_CHARS
|
|
1583
|
-
? retryCtx.failureContext.slice(0, MAX_RECOVERY_CHARS) + "\n\n[...failure context truncated]"
|
|
1584
|
-
: retryCtx.failureContext;
|
|
1585
|
-
finalPrompt = `**VERIFICATION FAILED — AUTO-FIX ATTEMPT ${retryCtx.attempt}**\n\nThe verification gate ran after your previous attempt and found failures. Fix these issues before completing the task.\n\n${capped}\n\n---\n\n${finalPrompt}`;
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
if (s.pendingCrashRecovery) {
|
|
1589
|
-
const capped = s.pendingCrashRecovery.length > MAX_RECOVERY_CHARS
|
|
1590
|
-
? s.pendingCrashRecovery.slice(0, MAX_RECOVERY_CHARS) + "\n\n[...recovery briefing truncated to prevent memory exhaustion]"
|
|
1591
|
-
: s.pendingCrashRecovery;
|
|
1592
|
-
finalPrompt = `${capped}\n\n---\n\n${finalPrompt}`;
|
|
1593
|
-
s.pendingCrashRecovery = null;
|
|
1594
|
-
} else if ((s.unitDispatchCount.get(`${unitType}/${unitId}`) ?? 0) > 1) {
|
|
1595
|
-
const diagnostic = getDeepDiagnostic(s.basePath);
|
|
1596
|
-
if (diagnostic) {
|
|
1597
|
-
const cappedDiag = diagnostic.length > MAX_RECOVERY_CHARS
|
|
1598
|
-
? diagnostic.slice(0, MAX_RECOVERY_CHARS) + "\n\n[...diagnostic truncated to prevent memory exhaustion]"
|
|
1599
|
-
: diagnostic;
|
|
1600
|
-
finalPrompt = `**RETRY — your previous attempt did not produce the required artifact.**\n\nDiagnostic from previous attempt:\n${cappedDiag}\n\nFix whatever went wrong and make sure you write the required file this time.\n\n---\n\n${finalPrompt}`;
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
const repairBlock = buildObservabilityRepairBlock(observabilityIssues);
|
|
1605
|
-
if (repairBlock) {
|
|
1606
|
-
finalPrompt = `${finalPrompt}${repairBlock}`;
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
// ── Prompt char measurement ──
|
|
1610
|
-
s.lastPromptCharCount = finalPrompt.length;
|
|
1611
|
-
s.lastBaselineCharCount = undefined;
|
|
1612
|
-
if (isDbAvailable()) {
|
|
1613
|
-
try {
|
|
1614
|
-
const { inlineGsdRootFile } = await import("./auto-prompts.js");
|
|
1615
|
-
const [decisionsContent, requirementsContent, projectContent] = await Promise.all([
|
|
1616
|
-
inlineGsdRootFile(s.basePath, "decisions.md", "Decisions"),
|
|
1617
|
-
inlineGsdRootFile(s.basePath, "requirements.md", "Requirements"),
|
|
1618
|
-
inlineGsdRootFile(s.basePath, "project.md", "Project"),
|
|
1619
|
-
]);
|
|
1620
|
-
s.lastBaselineCharCount =
|
|
1621
|
-
(decisionsContent?.length ?? 0) +
|
|
1622
|
-
(requirementsContent?.length ?? 0) +
|
|
1623
|
-
(projectContent?.length ?? 0);
|
|
1624
|
-
} catch {
|
|
1625
|
-
// Non-fatal
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
// Cache-optimize prompt section ordering
|
|
1630
|
-
try {
|
|
1631
|
-
const { reorderForCaching } = await import("./prompt-ordering.js");
|
|
1632
|
-
finalPrompt = reorderForCaching(finalPrompt);
|
|
1633
|
-
} catch (reorderErr) {
|
|
1634
|
-
const msg = getErrorMessage(reorderErr);
|
|
1635
|
-
process.stderr.write(`[gsd] prompt reorder failed (non-fatal): ${msg}\n`);
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
// Select and apply model
|
|
1639
|
-
const modelResult = await selectAndApplyModel(ctx, pi, unitType, unitId, s.basePath, prefs, s.verbose, s.autoModeStartModel);
|
|
1640
|
-
s.currentUnitRouting = modelResult.routing;
|
|
1641
|
-
|
|
1642
|
-
// ── Start unit supervision (delegated to auto-timers.ts) ──
|
|
1643
|
-
clearUnitTimeout();
|
|
1644
|
-
startUnitSupervision({
|
|
1645
|
-
s,
|
|
1646
|
-
ctx,
|
|
1647
|
-
pi,
|
|
1648
|
-
unitType,
|
|
1649
|
-
unitId,
|
|
1650
|
-
prefs,
|
|
1651
|
-
buildSnapshotOpts: () => buildSnapshotOpts(unitType, unitId),
|
|
1652
|
-
buildRecoveryContext: () => buildRecoveryContext(),
|
|
1653
|
-
pauseAuto,
|
|
1654
|
-
});
|
|
1655
|
-
|
|
1656
|
-
// Inject prompt
|
|
1657
|
-
if (!s.active) return;
|
|
1658
|
-
pi.sendMessage(
|
|
1659
|
-
{ customType: "gsd-auto", content: finalPrompt, display: s.verbose },
|
|
1660
|
-
{ triggerTurn: true },
|
|
1661
|
-
);
|
|
1662
|
-
|
|
1663
|
-
} finally {
|
|
1664
|
-
s.dispatching = false;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// ─── Preconditions ────────────────────────────────────────────────────────────
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* Ensure directories, branches, and other prerequisites exist before
|
|
1672
|
-
* dispatching a unit. The LLM should never need to mkdir or git checkout.
|
|
1673
|
-
*/
|
|
1674
|
-
function ensurePreconditions(
|
|
1675
|
-
unitType: string, unitId: string, base: string, state: GSDState,
|
|
1676
|
-
): void {
|
|
1677
|
-
const { milestone: mid } = parseUnitId(unitId);
|
|
1678
|
-
|
|
1679
|
-
const mDir = resolveMilestonePath(base, mid);
|
|
1680
|
-
if (!mDir) {
|
|
1681
|
-
const newDir = join(milestonesDir(base), mid);
|
|
1682
|
-
mkdirSync(join(newDir, "slices"), { recursive: true });
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
const sid = parseUnitId(unitId).slice;
|
|
1686
|
-
if (sid) {
|
|
1687
|
-
|
|
1688
|
-
const mDirResolved = resolveMilestonePath(base, mid);
|
|
1689
|
-
if (mDirResolved) {
|
|
1690
|
-
const slicesDir = join(mDirResolved, "slices");
|
|
1691
|
-
const sDir = resolveDir(slicesDir, sid);
|
|
1692
|
-
if (!sDir) {
|
|
1693
|
-
mkdirSync(join(slicesDir, sid, "tasks"), { recursive: true });
|
|
1694
|
-
}
|
|
1695
|
-
const resolvedSliceDir = resolveDir(slicesDir, sid) ?? sid;
|
|
1696
|
-
const tasksDir = join(slicesDir, resolvedSliceDir, "tasks");
|
|
1697
|
-
if (!existsSync(tasksDir)) {
|
|
1698
|
-
mkdirSync(tasksDir, { recursive: true });
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
// ─── Diagnostics ──────────────────────────────────────────────────────────────
|
|
1706
|
-
|
|
1707
|
-
/** Build recovery context from module state for recoverTimedOutUnit */
|
|
1708
|
-
function buildRecoveryContext(): import("./auto-timeout-recovery.js").RecoveryContext {
|
|
1709
|
-
return { basePath: s.basePath, verbose: s.verbose,
|
|
1710
|
-
currentUnitStartedAt: s.currentUnit?.startedAt ?? Date.now(), unitRecoveryCount: s.unitRecoveryCount,
|
|
1711
|
-
dispatchNextUnit,
|
|
1712
|
-
};
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
// Re-export recovery functions for external consumers
|
|
1716
|
-
export {
|
|
1717
|
-
resolveExpectedArtifactPath,
|
|
1718
|
-
verifyExpectedArtifact,
|
|
1719
|
-
writeBlockerPlaceholder,
|
|
1720
|
-
skipExecuteTask,
|
|
1721
|
-
buildLoopRemediationSteps,
|
|
1722
|
-
} from "./auto-recovery.js";
|
|
1723
|
-
|
|
1724
|
-
/**
|
|
1725
|
-
* Test-only: expose skip-loop state for unit tests.
|
|
1726
|
-
* Not part of the public API.
|
|
1727
|
-
*/
|
|
1728
|
-
export function _getUnitConsecutiveSkips(): Map<string, number> { return s.unitConsecutiveSkips; }
|
|
1729
|
-
export function _resetUnitConsecutiveSkips(): void { s.unitConsecutiveSkips.clear(); }
|
|
1730
|
-
|
|
1731
|
-
/**
|
|
1732
|
-
* Test-only: expose dispatching / skipDepth state for reentrancy guard tests.
|
|
1733
|
-
* Not part of the public API.
|
|
1734
|
-
*/
|
|
1735
|
-
export function _getDispatching(): boolean { return s.dispatching; }
|
|
1736
|
-
export function _setDispatching(v: boolean): void { s.dispatching = v; }
|
|
1737
|
-
export function _getSkipDepth(): number { return s.skipDepth; }
|
|
1738
|
-
export function _setSkipDepth(v: number): void { s.skipDepth = v; }
|
|
1739
|
-
|
|
1740
|
-
/**
|
|
1741
|
-
* Dispatch a hook unit directly, bypassing normal pre-dispatch hooks.
|
|
1742
|
-
* Used for manual hook triggers via /gsd run-hook.
|
|
1743
|
-
*/
|
|
1744
|
-
export async function dispatchHookUnit(
|
|
1745
|
-
ctx: ExtensionContext,
|
|
1746
|
-
pi: ExtensionAPI,
|
|
1747
|
-
hookName: string,
|
|
1748
|
-
triggerUnitType: string,
|
|
1749
|
-
triggerUnitId: string,
|
|
1750
|
-
hookPrompt: string,
|
|
1751
|
-
hookModel: string | undefined,
|
|
1752
|
-
targetBasePath: string,
|
|
1753
|
-
): Promise<boolean> {
|
|
1754
|
-
if (!s.active) {
|
|
1755
|
-
s.active = true;
|
|
1756
|
-
s.stepMode = true;
|
|
1757
|
-
s.cmdCtx = ctx as ExtensionCommandContext;
|
|
1758
|
-
s.basePath = targetBasePath;
|
|
1759
|
-
s.autoStartTime = Date.now();
|
|
1760
|
-
s.currentUnit = null;
|
|
1761
|
-
s.completedUnits = [];
|
|
1762
|
-
s.pendingQuickTasks = [];
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
const hookUnitType = `hook/${hookName}`;
|
|
1766
|
-
const hookStartedAt = Date.now();
|
|
1767
|
-
|
|
1768
|
-
s.currentUnit = { type: triggerUnitType, id: triggerUnitId, startedAt: hookStartedAt };
|
|
1769
|
-
|
|
1770
|
-
const result = await s.cmdCtx!.newSession();
|
|
1771
|
-
if (result.cancelled) {
|
|
1772
|
-
await stopAuto(ctx, pi);
|
|
1773
|
-
return false;
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
s.currentUnit = { type: hookUnitType, id: triggerUnitId, startedAt: hookStartedAt };
|
|
1777
|
-
|
|
1778
|
-
writeUnitRuntimeRecord(s.basePath, hookUnitType, triggerUnitId, hookStartedAt, {
|
|
1779
|
-
phase: "dispatched",
|
|
1780
|
-
wrapupWarningSent: false,
|
|
1781
|
-
timeoutAt: null,
|
|
1782
|
-
lastProgressAt: hookStartedAt,
|
|
1783
|
-
progressCount: 0,
|
|
1784
|
-
lastProgressKind: "dispatch",
|
|
1785
|
-
});
|
|
1786
|
-
|
|
1787
|
-
if (hookModel) {
|
|
1788
|
-
const availableModels = ctx.modelRegistry.getAvailable();
|
|
1789
|
-
const match = availableModels.find(m =>
|
|
1790
|
-
m.id === hookModel || `${m.provider}/${m.id}` === hookModel,
|
|
1791
|
-
);
|
|
1792
|
-
if (match) {
|
|
1793
|
-
try {
|
|
1794
|
-
await pi.setModel(match);
|
|
1795
|
-
} catch { /* non-fatal */ }
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
1800
|
-
updateSessionLock(lockBase(), hookUnitType, triggerUnitId, s.completedUnits.length, sessionFile);
|
|
1801
|
-
writeLock(lockBase(), hookUnitType, triggerUnitId, s.completedUnits.length, sessionFile);
|
|
1802
|
-
|
|
1803
|
-
clearUnitTimeout();
|
|
1804
|
-
const supervisor = resolveAutoSupervisorConfig();
|
|
1805
|
-
const hookHardTimeoutMs = (supervisor.hard_timeout_minutes ?? 30) * 60 * 1000;
|
|
1806
|
-
s.unitTimeoutHandle = setTimeout(async () => {
|
|
1807
|
-
s.unitTimeoutHandle = null;
|
|
1808
|
-
if (!s.active) return;
|
|
1809
|
-
if (s.currentUnit) {
|
|
1810
|
-
writeUnitRuntimeRecord(s.basePath, hookUnitType, triggerUnitId, hookStartedAt, {
|
|
1811
|
-
phase: "timeout",
|
|
1812
|
-
timeoutAt: Date.now(),
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
ctx.ui.notify(
|
|
1816
|
-
`Hook ${hookName} exceeded ${supervisor.hard_timeout_minutes ?? 30}min timeout. Pausing auto-mode.`,
|
|
1817
|
-
"warning",
|
|
1818
|
-
);
|
|
1819
|
-
resetHookState();
|
|
1820
|
-
await pauseAuto(ctx, pi);
|
|
1821
|
-
}, hookHardTimeoutMs);
|
|
1822
|
-
|
|
1823
|
-
ctx.ui.setStatus("gsd-auto", s.stepMode ? "next" : "auto");
|
|
1824
|
-
ctx.ui.notify(`Running post-unit hook: ${hookName}`, "info");
|
|
1825
|
-
|
|
1826
|
-
pi.sendMessage(
|
|
1827
|
-
{ customType: "gsd-auto", content: hookPrompt, display: true },
|
|
1828
|
-
{ triggerTurn: true },
|
|
1829
|
-
);
|
|
1830
|
-
|
|
1831
|
-
return true;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
|