gsd-pi 2.38.0-dev.eeb3520 → 2.39.0-dev.38f11d1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/dist/app-paths.js +1 -1
- package/dist/cli.js +9 -0
- package/dist/extension-discovery.d.ts +5 -3
- package/dist/extension-discovery.js +14 -9
- package/dist/extension-registry.js +2 -2
- package/dist/remote-questions-config.js +2 -2
- package/dist/resource-loader.js +34 -1
- package/dist/resources/extensions/async-jobs/index.js +10 -0
- package/dist/resources/extensions/browser-tools/index.js +3 -1
- package/dist/resources/extensions/browser-tools/package.json +3 -1
- package/dist/resources/extensions/browser-tools/tools/verify.js +97 -0
- package/dist/resources/extensions/cmux/index.js +55 -1
- package/dist/resources/extensions/context7/package.json +1 -1
- package/dist/resources/extensions/env-utils.js +29 -0
- package/dist/resources/extensions/get-secrets-from-user.js +5 -24
- package/dist/resources/extensions/github-sync/cli.js +284 -0
- package/dist/resources/extensions/github-sync/index.js +73 -0
- package/dist/resources/extensions/github-sync/mapping.js +67 -0
- package/dist/resources/extensions/github-sync/sync.js +424 -0
- package/dist/resources/extensions/github-sync/templates.js +118 -0
- package/dist/resources/extensions/github-sync/types.js +7 -0
- package/dist/resources/extensions/google-search/package.json +3 -1
- package/dist/resources/extensions/gsd/auto/session.js +6 -23
- package/dist/resources/extensions/gsd/auto-dashboard.js +7 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +8 -9
- package/dist/resources/extensions/gsd/auto-loop.js +923 -787
- package/dist/resources/extensions/gsd/auto-post-unit.js +107 -70
- package/dist/resources/extensions/gsd/auto-prompts.js +205 -51
- package/dist/resources/extensions/gsd/auto-start.js +19 -3
- package/dist/resources/extensions/gsd/auto-worktree-sync.js +13 -5
- package/dist/resources/extensions/gsd/auto-worktree.js +3 -3
- package/dist/resources/extensions/gsd/auto.js +147 -98
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +126 -0
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +233 -0
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +59 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +38 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +156 -0
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +46 -0
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +300 -0
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +38 -0
- package/dist/resources/extensions/gsd/captures.js +9 -1
- package/dist/resources/extensions/gsd/commands/catalog.js +278 -0
- package/dist/resources/extensions/gsd/commands/context.js +84 -0
- package/dist/resources/extensions/gsd/commands/dispatcher.js +21 -0
- package/dist/resources/extensions/gsd/commands/handlers/auto.js +72 -0
- package/dist/resources/extensions/gsd/commands/handlers/core.js +246 -0
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +166 -0
- package/dist/resources/extensions/gsd/commands/handlers/parallel.js +94 -0
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +102 -0
- package/dist/resources/extensions/gsd/commands/index.js +11 -0
- package/dist/resources/extensions/gsd/commands-extensions.js +3 -2
- package/dist/resources/extensions/gsd/commands-handlers.js +17 -4
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +1 -1
- package/dist/resources/extensions/gsd/commands.js +8 -1169
- package/dist/resources/extensions/gsd/context-budget.js +2 -10
- package/dist/resources/extensions/gsd/dashboard-overlay.js +9 -0
- package/dist/resources/extensions/gsd/detection.js +1 -2
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +0 -2
- package/dist/resources/extensions/gsd/doctor-checks.js +82 -0
- package/dist/resources/extensions/gsd/doctor-environment.js +78 -0
- package/dist/resources/extensions/gsd/doctor-format.js +15 -0
- package/dist/resources/extensions/gsd/doctor-proactive.js +80 -10
- package/dist/resources/extensions/gsd/doctor-providers.js +30 -11
- package/dist/resources/extensions/gsd/doctor.js +234 -12
- package/dist/resources/extensions/gsd/exit-command.js +2 -1
- package/dist/resources/extensions/gsd/export-html.js +46 -0
- package/dist/resources/extensions/gsd/export.js +1 -1
- package/dist/resources/extensions/gsd/files.js +48 -9
- package/dist/resources/extensions/gsd/forensics.js +1 -1
- package/dist/resources/extensions/gsd/git-service.js +30 -12
- package/dist/resources/extensions/gsd/gitignore.js +16 -3
- package/dist/resources/extensions/gsd/guided-flow.js +149 -38
- package/dist/resources/extensions/gsd/health-widget-core.js +32 -70
- package/dist/resources/extensions/gsd/health-widget.js +4 -87
- package/dist/resources/extensions/gsd/index.js +4 -1111
- package/dist/resources/extensions/gsd/migrate/parsers.js +1 -1
- package/dist/resources/extensions/gsd/migrate-external.js +18 -1
- package/dist/resources/extensions/gsd/native-git-bridge.js +37 -0
- package/dist/resources/extensions/gsd/package.json +1 -1
- package/dist/resources/extensions/gsd/paths.js +3 -0
- package/dist/resources/extensions/gsd/preferences-models.js +0 -12
- package/dist/resources/extensions/gsd/preferences-types.js +1 -1
- package/dist/resources/extensions/gsd/preferences-validation.js +59 -11
- package/dist/resources/extensions/gsd/preferences.js +22 -11
- package/dist/resources/extensions/gsd/progress-score.js +20 -1
- package/dist/resources/extensions/gsd/prompt-loader.js +6 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/discuss.md +11 -14
- package/dist/resources/extensions/gsd/prompts/execute-task.md +5 -3
- package/dist/resources/extensions/gsd/prompts/forensics.md +121 -46
- package/dist/resources/extensions/gsd/prompts/guided-complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +11 -12
- package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +8 -10
- package/dist/resources/extensions/gsd/prompts/guided-execute-task.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-resume-task.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/queue.md +4 -8
- package/dist/resources/extensions/gsd/prompts/reactive-execute.md +11 -8
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/run-uat.md +28 -11
- package/dist/resources/extensions/gsd/prompts/workflow-start.md +2 -2
- package/dist/resources/extensions/gsd/repo-identity.js +21 -4
- package/dist/resources/extensions/gsd/resource-version.js +2 -1
- package/dist/resources/extensions/gsd/roadmap-mutations.js +24 -0
- package/dist/resources/extensions/gsd/state.js +42 -23
- package/dist/resources/extensions/gsd/templates/runtime.md +21 -0
- package/dist/resources/extensions/gsd/templates/task-plan.md +3 -0
- package/dist/resources/extensions/gsd/visualizer-data.js +27 -2
- package/dist/resources/extensions/gsd/visualizer-views.js +52 -0
- package/dist/resources/extensions/gsd/worktree.js +35 -16
- package/dist/resources/extensions/mcp-client/index.js +14 -1
- package/dist/resources/extensions/remote-questions/status.js +4 -1
- package/dist/resources/extensions/remote-questions/store.js +4 -1
- package/dist/resources/extensions/search-the-web/provider.js +2 -1
- package/dist/resources/extensions/shared/frontmatter.js +1 -1
- package/dist/resources/extensions/subagent/index.js +12 -3
- package/dist/resources/extensions/subagent/isolation.js +2 -1
- package/dist/resources/extensions/ttsr/rule-loader.js +2 -1
- package/dist/resources/extensions/universal-config/package.json +1 -1
- package/dist/welcome-screen.d.ts +12 -0
- package/dist/welcome-screen.js +53 -0
- package/package.json +1 -1
- package/packages/pi-ai/dist/utils/oauth/anthropic.js +2 -2
- package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +1 -1
- package/packages/pi-ai/src/utils/oauth/anthropic.ts +2 -2
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +205 -7
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.js +8 -4
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.js +6 -1
- package/packages/pi-coding-agent/dist/core/skills.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/dist/modes/interactive/controllers/chat-controller.d.ts +17 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +244 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.d.ts +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.js +58 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +54 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.d.ts +6 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js +63 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +38 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -453
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +223 -7
- package/packages/pi-coding-agent/src/core/package-manager.ts +8 -4
- package/packages/pi-coding-agent/src/core/skills.ts +9 -1
- package/packages/pi-coding-agent/src/index.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +302 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/extension-ui-controller.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +68 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/model-controller.ts +71 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +37 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +16 -506
- package/pkg/package.json +1 -1
- package/src/resources/extensions/async-jobs/index.ts +11 -0
- package/src/resources/extensions/browser-tools/index.ts +3 -0
- package/src/resources/extensions/browser-tools/tools/verify.ts +117 -0
- package/src/resources/extensions/cmux/index.ts +57 -1
- package/src/resources/extensions/env-utils.ts +31 -0
- package/src/resources/extensions/get-secrets-from-user.ts +5 -24
- package/src/resources/extensions/github-sync/cli.ts +364 -0
- package/src/resources/extensions/github-sync/index.ts +93 -0
- package/src/resources/extensions/github-sync/mapping.ts +81 -0
- package/src/resources/extensions/github-sync/sync.ts +556 -0
- package/src/resources/extensions/github-sync/templates.ts +183 -0
- package/src/resources/extensions/github-sync/tests/cli.test.ts +20 -0
- package/src/resources/extensions/github-sync/tests/commit-linking.test.ts +39 -0
- package/src/resources/extensions/github-sync/tests/mapping.test.ts +104 -0
- package/src/resources/extensions/github-sync/tests/templates.test.ts +110 -0
- package/src/resources/extensions/github-sync/types.ts +47 -0
- package/src/resources/extensions/gsd/auto/session.ts +7 -25
- package/src/resources/extensions/gsd/auto-dashboard.ts +10 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +7 -9
- package/src/resources/extensions/gsd/auto-loop.ts +1285 -1138
- package/src/resources/extensions/gsd/auto-post-unit.ts +90 -46
- package/src/resources/extensions/gsd/auto-prompts.ts +250 -53
- package/src/resources/extensions/gsd/auto-start.ts +24 -3
- package/src/resources/extensions/gsd/auto-worktree-sync.ts +15 -4
- package/src/resources/extensions/gsd/auto-worktree.ts +3 -3
- package/src/resources/extensions/gsd/auto.ts +143 -102
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +142 -0
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +238 -0
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +90 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +46 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +167 -0
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +55 -0
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +340 -0
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +51 -0
- package/src/resources/extensions/gsd/captures.ts +10 -1
- package/src/resources/extensions/gsd/commands/catalog.ts +301 -0
- package/src/resources/extensions/gsd/commands/context.ts +101 -0
- package/src/resources/extensions/gsd/commands/dispatcher.ts +32 -0
- package/src/resources/extensions/gsd/commands/handlers/auto.ts +74 -0
- package/src/resources/extensions/gsd/commands/handlers/core.ts +274 -0
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +169 -0
- package/src/resources/extensions/gsd/commands/handlers/parallel.ts +118 -0
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +109 -0
- package/src/resources/extensions/gsd/commands/index.ts +14 -0
- package/src/resources/extensions/gsd/commands-extensions.ts +4 -2
- package/src/resources/extensions/gsd/commands-handlers.ts +18 -3
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1 -1
- package/src/resources/extensions/gsd/commands.ts +10 -1307
- package/src/resources/extensions/gsd/context-budget.ts +2 -12
- package/src/resources/extensions/gsd/dashboard-overlay.ts +10 -0
- package/src/resources/extensions/gsd/detection.ts +2 -2
- package/src/resources/extensions/gsd/docs/preferences-reference.md +0 -2
- package/src/resources/extensions/gsd/doctor-checks.ts +75 -0
- package/src/resources/extensions/gsd/doctor-environment.ts +82 -1
- package/src/resources/extensions/gsd/doctor-format.ts +20 -0
- package/src/resources/extensions/gsd/doctor-proactive.ts +106 -10
- package/src/resources/extensions/gsd/doctor-providers.ts +30 -9
- package/src/resources/extensions/gsd/doctor-types.ts +16 -1
- package/src/resources/extensions/gsd/doctor.ts +243 -14
- package/src/resources/extensions/gsd/exit-command.ts +2 -2
- package/src/resources/extensions/gsd/export-html.ts +51 -0
- package/src/resources/extensions/gsd/export.ts +1 -1
- package/src/resources/extensions/gsd/files.ts +51 -11
- package/src/resources/extensions/gsd/forensics.ts +1 -1
- package/src/resources/extensions/gsd/git-service.ts +44 -10
- package/src/resources/extensions/gsd/gitignore.ts +17 -3
- package/src/resources/extensions/gsd/guided-flow.ts +177 -44
- package/src/resources/extensions/gsd/health-widget-core.ts +28 -80
- package/src/resources/extensions/gsd/health-widget.ts +4 -89
- package/src/resources/extensions/gsd/index.ts +12 -1307
- package/src/resources/extensions/gsd/migrate/parsers.ts +1 -1
- package/src/resources/extensions/gsd/migrate-external.ts +18 -1
- package/src/resources/extensions/gsd/native-git-bridge.ts +37 -0
- package/src/resources/extensions/gsd/paths.ts +4 -0
- package/src/resources/extensions/gsd/preferences-models.ts +0 -12
- package/src/resources/extensions/gsd/preferences-types.ts +4 -4
- package/src/resources/extensions/gsd/preferences-validation.ts +51 -11
- package/src/resources/extensions/gsd/preferences.ts +25 -11
- package/src/resources/extensions/gsd/progress-score.ts +23 -0
- package/src/resources/extensions/gsd/prompt-loader.ts +7 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/discuss.md +11 -14
- package/src/resources/extensions/gsd/prompts/execute-task.md +5 -3
- package/src/resources/extensions/gsd/prompts/forensics.md +121 -46
- package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +11 -12
- package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +8 -10
- package/src/resources/extensions/gsd/prompts/guided-execute-task.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-resume-task.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/queue.md +4 -8
- package/src/resources/extensions/gsd/prompts/reactive-execute.md +11 -8
- package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/run-uat.md +28 -11
- package/src/resources/extensions/gsd/prompts/workflow-start.md +2 -2
- package/src/resources/extensions/gsd/repo-identity.ts +23 -4
- package/src/resources/extensions/gsd/resource-version.ts +3 -1
- package/src/resources/extensions/gsd/roadmap-mutations.ts +29 -0
- package/src/resources/extensions/gsd/state.ts +39 -21
- package/src/resources/extensions/gsd/templates/runtime.md +21 -0
- package/src/resources/extensions/gsd/templates/task-plan.md +3 -0
- package/src/resources/extensions/gsd/tests/agent-end-retry.test.ts +21 -18
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +135 -77
- package/src/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +4 -3
- package/src/resources/extensions/gsd/tests/cmux.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/derive-state.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/doctor-enhancements.test.ts +266 -0
- package/src/resources/extensions/gsd/tests/doctor-proactive.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +86 -3
- package/src/resources/extensions/gsd/tests/gitignore-tracked-gsd.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +16 -54
- package/src/resources/extensions/gsd/tests/parsers.test.ts +131 -14
- package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +209 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +2 -7
- package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +59 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +16 -16
- package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +21 -1
- package/src/resources/extensions/gsd/tests/run-uat.test.ts +16 -4
- package/src/resources/extensions/gsd/tests/skill-activation.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +10 -10
- package/src/resources/extensions/gsd/tests/worktree.test.ts +47 -0
- package/src/resources/extensions/gsd/types.ts +18 -1
- package/src/resources/extensions/gsd/verification-evidence.ts +16 -0
- package/src/resources/extensions/gsd/visualizer-data.ts +52 -2
- package/src/resources/extensions/gsd/visualizer-views.ts +58 -0
- package/src/resources/extensions/gsd/worktree.ts +35 -15
- package/src/resources/extensions/mcp-client/index.ts +17 -1
- package/src/resources/extensions/remote-questions/status.ts +5 -1
- package/src/resources/extensions/remote-questions/store.ts +5 -1
- package/src/resources/extensions/search-the-web/provider.ts +2 -1
- package/src/resources/extensions/shared/frontmatter.ts +1 -1
- package/src/resources/extensions/subagent/index.ts +12 -3
- package/src/resources/extensions/subagent/isolation.ts +3 -1
- package/src/resources/extensions/ttsr/rule-loader.ts +3 -1
- package/dist/resources/extensions/gsd/prompt-compressor.js +0 -393
- package/dist/resources/extensions/gsd/semantic-chunker.js +0 -254
- package/dist/resources/extensions/gsd/summary-distiller.js +0 -212
- package/src/resources/extensions/gsd/prompt-compressor.ts +0 -508
- package/src/resources/extensions/gsd/semantic-chunker.ts +0 -336
- package/src/resources/extensions/gsd/summary-distiller.ts +0 -258
- package/src/resources/extensions/gsd/tests/context-compression.test.ts +0 -193
- package/src/resources/extensions/gsd/tests/prompt-compressor.test.ts +0 -529
- package/src/resources/extensions/gsd/tests/semantic-chunker.test.ts +0 -426
- package/src/resources/extensions/gsd/tests/summary-distiller.test.ts +0 -323
- package/src/resources/extensions/gsd/tests/token-optimization-benchmark.test.ts +0 -1272
- package/src/resources/extensions/gsd/tests/token-optimization-prefs.test.ts +0 -164
|
@@ -111,6 +111,7 @@ import {
|
|
|
111
111
|
recordHealthSnapshot,
|
|
112
112
|
checkHealEscalation,
|
|
113
113
|
resetProactiveHealing,
|
|
114
|
+
setLevelChangeCallback,
|
|
114
115
|
formatHealthSummary,
|
|
115
116
|
getConsecutiveErrorUnits,
|
|
116
117
|
} from "./doctor-proactive.js";
|
|
@@ -195,7 +196,7 @@ import {
|
|
|
195
196
|
postUnitPostVerification,
|
|
196
197
|
} from "./auto-post-unit.js";
|
|
197
198
|
import { bootstrapAutoSession, type BootstrapDeps } from "./auto-start.js";
|
|
198
|
-
import { autoLoop, resolveAgentEnd, type LoopDeps } from "./auto-loop.js";
|
|
199
|
+
import { autoLoop, resolveAgentEnd, isSessionSwitchInFlight, type LoopDeps } from "./auto-loop.js";
|
|
199
200
|
import {
|
|
200
201
|
WorktreeResolver,
|
|
201
202
|
type WorktreeResolverDeps,
|
|
@@ -536,129 +537,168 @@ export async function stopAuto(
|
|
|
536
537
|
if (!s.active && !s.paused) return;
|
|
537
538
|
const loadedPreferences = loadEffectiveGSDPreferences()?.preferences;
|
|
538
539
|
const reasonSuffix = reason ? ` — ${reason}` : "";
|
|
539
|
-
clearUnitTimeout();
|
|
540
|
-
if (lockBase()) clearLock(lockBase());
|
|
541
|
-
if (lockBase()) releaseSessionLock(lockBase());
|
|
542
|
-
clearSkillSnapshot();
|
|
543
|
-
resetSkillTelemetry();
|
|
544
540
|
|
|
545
|
-
|
|
546
|
-
|
|
541
|
+
try {
|
|
542
|
+
// ── Step 1: Timers and locks ──
|
|
543
|
+
try {
|
|
544
|
+
clearUnitTimeout();
|
|
545
|
+
if (lockBase()) clearLock(lockBase());
|
|
546
|
+
if (lockBase()) releaseSessionLock(lockBase());
|
|
547
|
+
} catch (e) {
|
|
548
|
+
debugLog("stop-cleanup-locks", { error: e instanceof Error ? e.message : String(e) });
|
|
549
|
+
}
|
|
547
550
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
});
|
|
556
|
-
}
|
|
551
|
+
// ── Step 2: Skill state ──
|
|
552
|
+
try {
|
|
553
|
+
clearSkillSnapshot();
|
|
554
|
+
resetSkillTelemetry();
|
|
555
|
+
} catch (e) {
|
|
556
|
+
debugLog("stop-cleanup-skills", { error: e instanceof Error ? e.message : String(e) });
|
|
557
|
+
}
|
|
557
558
|
|
|
558
|
-
|
|
559
|
-
if (isDbAvailable()) {
|
|
559
|
+
// ── Step 3: SIGTERM handler ──
|
|
560
560
|
try {
|
|
561
|
-
|
|
562
|
-
closeDatabase();
|
|
561
|
+
deregisterSigtermHandler();
|
|
563
562
|
} catch (e) {
|
|
564
|
-
debugLog("
|
|
565
|
-
error: e instanceof Error ? e.message : String(e),
|
|
566
|
-
});
|
|
563
|
+
debugLog("stop-cleanup-sigterm", { error: e instanceof Error ? e.message : String(e) });
|
|
567
564
|
}
|
|
568
|
-
}
|
|
569
565
|
|
|
570
|
-
|
|
571
|
-
s.basePath = s.originalBasePath;
|
|
566
|
+
// ── Step 4: Auto-worktree exit ──
|
|
572
567
|
try {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
568
|
+
if (s.currentMilestoneId) {
|
|
569
|
+
const notifyCtx = ctx
|
|
570
|
+
? { notify: ctx.ui.notify.bind(ctx.ui) }
|
|
571
|
+
: { notify: () => {} };
|
|
572
|
+
buildResolver().exitMilestone(s.currentMilestoneId, notifyCtx, {
|
|
573
|
+
preserveBranch: true,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
} catch (e) {
|
|
577
|
+
debugLog("stop-cleanup-worktree", { error: e instanceof Error ? e.message : String(e) });
|
|
576
578
|
}
|
|
577
|
-
}
|
|
578
579
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
580
|
+
// ── Step 5: DB cleanup ──
|
|
581
|
+
if (isDbAvailable()) {
|
|
582
|
+
try {
|
|
583
|
+
const { closeDatabase } = await import("./gsd-db.js");
|
|
584
|
+
closeDatabase();
|
|
585
|
+
} catch (e) {
|
|
586
|
+
debugLog("db-close-failed", {
|
|
587
|
+
error: e instanceof Error ? e.message : String(e),
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
589
591
|
|
|
590
|
-
|
|
592
|
+
// ── Step 6: Restore basePath and chdir ──
|
|
591
593
|
try {
|
|
592
|
-
|
|
594
|
+
if (s.originalBasePath) {
|
|
595
|
+
s.basePath = s.originalBasePath;
|
|
596
|
+
try {
|
|
597
|
+
process.chdir(s.basePath);
|
|
598
|
+
} catch {
|
|
599
|
+
/* best-effort */
|
|
600
|
+
}
|
|
601
|
+
}
|
|
593
602
|
} catch (e) {
|
|
594
|
-
debugLog("stop-
|
|
595
|
-
error: e instanceof Error ? e.message : String(e),
|
|
596
|
-
});
|
|
603
|
+
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
597
604
|
}
|
|
598
|
-
}
|
|
599
605
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
+
// ── Step 7: Ledger notification ──
|
|
607
|
+
try {
|
|
608
|
+
const ledger = getLedger();
|
|
609
|
+
if (ledger && ledger.units.length > 0) {
|
|
610
|
+
const totals = getProjectTotals(ledger.units);
|
|
611
|
+
ctx?.ui.notify(
|
|
612
|
+
`Auto-mode stopped${reasonSuffix}. Session: ${formatCost(totals.cost)} · ${formatTokenCount(totals.tokens.total)} tokens · ${ledger.units.length} units`,
|
|
613
|
+
"info",
|
|
614
|
+
);
|
|
615
|
+
} else {
|
|
616
|
+
ctx?.ui.notify(`Auto-mode stopped${reasonSuffix}.`, "info");
|
|
617
|
+
}
|
|
618
|
+
} catch (e) {
|
|
619
|
+
debugLog("stop-cleanup-ledger", { error: e instanceof Error ? e.message : String(e) });
|
|
620
|
+
}
|
|
606
621
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
622
|
+
// ── Step 8: Rebuild state ──
|
|
623
|
+
if (s.basePath) {
|
|
624
|
+
try {
|
|
625
|
+
await rebuildState(s.basePath);
|
|
626
|
+
} catch (e) {
|
|
627
|
+
debugLog("stop-rebuild-state-failed", {
|
|
628
|
+
error: e instanceof Error ? e.message : String(e),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
611
631
|
}
|
|
612
|
-
}
|
|
613
632
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
633
|
+
// ── Step 9: Cmux sidebar / event log ──
|
|
634
|
+
try {
|
|
635
|
+
clearCmuxSidebar(loadedPreferences);
|
|
636
|
+
logCmuxEvent(
|
|
637
|
+
loadedPreferences,
|
|
638
|
+
`Auto-mode stopped${reasonSuffix || ""}.`,
|
|
639
|
+
reason?.startsWith("Blocked:") ? "warning" : "info",
|
|
640
|
+
);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
debugLog("stop-cleanup-cmux", { error: e instanceof Error ? e.message : String(e) });
|
|
643
|
+
}
|
|
618
644
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
645
|
+
// ── Step 10: Debug summary ──
|
|
646
|
+
try {
|
|
647
|
+
if (isDebugEnabled()) {
|
|
648
|
+
const logPath = writeDebugSummary();
|
|
649
|
+
if (logPath) {
|
|
650
|
+
ctx?.ui.notify(`Debug log written → ${logPath}`, "info");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
} catch (e) {
|
|
654
|
+
debugLog("stop-cleanup-debug", { error: e instanceof Error ? e.message : String(e) });
|
|
655
|
+
}
|
|
624
656
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
s.currentUnit = null;
|
|
635
|
-
s.autoModeStartModel = null;
|
|
636
|
-
s.currentMilestoneId = null;
|
|
637
|
-
s.originalBasePath = "";
|
|
638
|
-
s.completedUnits = [];
|
|
639
|
-
s.pendingQuickTasks = [];
|
|
640
|
-
clearSliceProgressCache();
|
|
641
|
-
clearActivityLogState();
|
|
642
|
-
resetProactiveHealing();
|
|
643
|
-
s.pendingCrashRecovery = null;
|
|
644
|
-
s.pendingVerificationRetry = null;
|
|
645
|
-
s.verificationRetryCount.clear();
|
|
646
|
-
s.pausedSessionFile = null;
|
|
647
|
-
ctx?.ui.setStatus("gsd-auto", undefined);
|
|
648
|
-
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
649
|
-
ctx?.ui.setFooter(undefined);
|
|
657
|
+
// ── Step 11: Reset metrics, routing, hooks ──
|
|
658
|
+
try {
|
|
659
|
+
resetMetrics();
|
|
660
|
+
resetRoutingHistory();
|
|
661
|
+
resetHookState();
|
|
662
|
+
if (s.basePath) clearPersistedHookState(s.basePath);
|
|
663
|
+
} catch (e) {
|
|
664
|
+
debugLog("stop-cleanup-metrics", { error: e instanceof Error ? e.message : String(e) });
|
|
665
|
+
}
|
|
650
666
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
s.
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (original) await pi.setModel(original);
|
|
657
|
-
s.originalModelId = null;
|
|
658
|
-
s.originalModelProvider = null;
|
|
659
|
-
}
|
|
667
|
+
// ── Step 12: Remove paused-session metadata (#1383) ──
|
|
668
|
+
try {
|
|
669
|
+
const pausedPath = join(gsdRoot(s.originalBasePath || s.basePath), "runtime", "paused-session.json");
|
|
670
|
+
if (existsSync(pausedPath)) unlinkSync(pausedPath);
|
|
671
|
+
} catch { /* non-fatal */ }
|
|
660
672
|
|
|
661
|
-
|
|
673
|
+
// ── Step 13: Restore original model (before reset clears IDs) ──
|
|
674
|
+
try {
|
|
675
|
+
if (pi && ctx && s.originalModelId && s.originalModelProvider) {
|
|
676
|
+
const original = ctx.modelRegistry.find(
|
|
677
|
+
s.originalModelProvider,
|
|
678
|
+
s.originalModelId,
|
|
679
|
+
);
|
|
680
|
+
if (original) await pi.setModel(original);
|
|
681
|
+
}
|
|
682
|
+
} catch (e) {
|
|
683
|
+
debugLog("stop-cleanup-model", { error: e instanceof Error ? e.message : String(e) });
|
|
684
|
+
}
|
|
685
|
+
} finally {
|
|
686
|
+
// ── Critical invariants: these MUST execute regardless of errors ──
|
|
687
|
+
// External cleanup (not covered by session reset)
|
|
688
|
+
clearInFlightTools();
|
|
689
|
+
clearSliceProgressCache();
|
|
690
|
+
clearActivityLogState();
|
|
691
|
+
setLevelChangeCallback(null);
|
|
692
|
+
resetProactiveHealing();
|
|
693
|
+
|
|
694
|
+
// UI cleanup
|
|
695
|
+
ctx?.ui.setStatus("gsd-auto", undefined);
|
|
696
|
+
ctx?.ui.setWidget("gsd-progress", undefined);
|
|
697
|
+
ctx?.ui.setFooter(undefined);
|
|
698
|
+
|
|
699
|
+
// Reset all session state in one call
|
|
700
|
+
s.reset();
|
|
701
|
+
}
|
|
662
702
|
}
|
|
663
703
|
|
|
664
704
|
/**
|
|
@@ -1091,6 +1131,7 @@ const widgetStateAccessors: WidgetStateAccessors = {
|
|
|
1091
1131
|
getCmdCtx: () => s.cmdCtx,
|
|
1092
1132
|
getBasePath: () => s.basePath,
|
|
1093
1133
|
isVerbose: () => s.verbose,
|
|
1134
|
+
isSessionSwitching: isSessionSwitchInFlight,
|
|
1094
1135
|
};
|
|
1095
1136
|
|
|
1096
1137
|
// ─── Preconditions ────────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@gsd/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { checkAutoStartAfterDiscuss } from "../guided-flow.js";
|
|
4
|
+
import { getAutoDashboardData, getAutoModeStartModel, isAutoActive, pauseAuto } from "../auto.js";
|
|
5
|
+
import { getNextFallbackModel, isTransientNetworkError, resolveModelWithFallbacksForUnit } from "../preferences.js";
|
|
6
|
+
import { classifyProviderError, pauseAutoForProviderError } from "../provider-error-pause.js";
|
|
7
|
+
import { isSessionSwitchInFlight, resolveAgentEnd } from "../auto-loop.js";
|
|
8
|
+
import { clearDiscussionFlowState } from "./write-gate.js";
|
|
9
|
+
|
|
10
|
+
const networkRetryCounters = new Map<string, number>();
|
|
11
|
+
const MAX_TRANSIENT_AUTO_RESUMES = 3;
|
|
12
|
+
let consecutiveTransientErrors = 0;
|
|
13
|
+
|
|
14
|
+
export async function handleAgentEnd(
|
|
15
|
+
pi: ExtensionAPI,
|
|
16
|
+
event: { messages: any[] },
|
|
17
|
+
ctx: ExtensionContext,
|
|
18
|
+
): Promise<void> {
|
|
19
|
+
if (checkAutoStartAfterDiscuss()) {
|
|
20
|
+
clearDiscussionFlowState();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!isAutoActive()) return;
|
|
24
|
+
if (isSessionSwitchInFlight()) return;
|
|
25
|
+
|
|
26
|
+
const lastMsg = event.messages[event.messages.length - 1];
|
|
27
|
+
if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "aborted") {
|
|
28
|
+
await pauseAuto(ctx, pi);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "error") {
|
|
32
|
+
const errorDetail = "errorMessage" in lastMsg && lastMsg.errorMessage ? `: ${lastMsg.errorMessage}` : "";
|
|
33
|
+
const errorMsg = ("errorMessage" in lastMsg && lastMsg.errorMessage) ? String(lastMsg.errorMessage) : "";
|
|
34
|
+
|
|
35
|
+
if (isTransientNetworkError(errorMsg)) {
|
|
36
|
+
const currentModelId = ctx.model?.id ?? "unknown";
|
|
37
|
+
const retryKey = `network-retry:${currentModelId}`;
|
|
38
|
+
const currentRetries = networkRetryCounters.get(retryKey) ?? 0;
|
|
39
|
+
const maxRetries = 2;
|
|
40
|
+
if (currentRetries < maxRetries) {
|
|
41
|
+
networkRetryCounters.set(retryKey, currentRetries + 1);
|
|
42
|
+
const attempt = currentRetries + 1;
|
|
43
|
+
const delayMs = attempt * 3000;
|
|
44
|
+
ctx.ui.notify(`Network error on ${currentModelId}${errorDetail}. Retry ${attempt}/${maxRetries} in ${delayMs / 1000}s...`, "warning");
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
pi.sendMessage(
|
|
47
|
+
{ customType: "gsd-auto-timeout-recovery", content: "Continue execution — retrying after transient network error.", display: false },
|
|
48
|
+
{ triggerTurn: true },
|
|
49
|
+
);
|
|
50
|
+
}, delayMs);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
networkRetryCounters.delete(retryKey);
|
|
54
|
+
ctx.ui.notify(`Network retries exhausted for ${currentModelId}. Attempting model fallback.`, "warning");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const dash = getAutoDashboardData();
|
|
58
|
+
if (dash.currentUnit) {
|
|
59
|
+
const modelConfig = resolveModelWithFallbacksForUnit(dash.currentUnit.type);
|
|
60
|
+
if (modelConfig && modelConfig.fallbacks.length > 0) {
|
|
61
|
+
const availableModels = ctx.modelRegistry.getAvailable();
|
|
62
|
+
const nextModelId = getNextFallbackModel(ctx.model?.id, modelConfig);
|
|
63
|
+
if (nextModelId) {
|
|
64
|
+
networkRetryCounters.clear();
|
|
65
|
+
const slashIdx = nextModelId.indexOf("/");
|
|
66
|
+
const modelToSet = slashIdx !== -1
|
|
67
|
+
? availableModels.find((m) => m.provider.toLowerCase() === nextModelId.substring(0, slashIdx).toLowerCase() && m.id.toLowerCase() === nextModelId.substring(slashIdx + 1).toLowerCase())
|
|
68
|
+
: (availableModels.find((m) => m.id === nextModelId && m.provider === ctx.model?.provider) ?? availableModels.find((m) => m.id === nextModelId));
|
|
69
|
+
if (modelToSet) {
|
|
70
|
+
const ok = await pi.setModel(modelToSet, { persist: false });
|
|
71
|
+
if (ok) {
|
|
72
|
+
ctx.ui.notify(`Model error${errorDetail}. Switched to fallback: ${nextModelId} and resuming.`, "warning");
|
|
73
|
+
pi.sendMessage({ customType: "gsd-auto-timeout-recovery", content: "Continue execution.", display: false }, { triggerTurn: true });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const sessionModel = getAutoModeStartModel();
|
|
82
|
+
if (sessionModel) {
|
|
83
|
+
if (ctx.model?.id !== sessionModel.id || ctx.model?.provider !== sessionModel.provider) {
|
|
84
|
+
const startModel = ctx.modelRegistry.getAvailable().find((m) => m.provider === sessionModel.provider && m.id === sessionModel.id);
|
|
85
|
+
if (startModel) {
|
|
86
|
+
const ok = await pi.setModel(startModel, { persist: false });
|
|
87
|
+
if (ok) {
|
|
88
|
+
networkRetryCounters.clear();
|
|
89
|
+
ctx.ui.notify(`Model error${errorDetail}. Restored session model: ${sessionModel.provider}/${sessionModel.id} and resuming.`, "warning");
|
|
90
|
+
pi.sendMessage({ customType: "gsd-auto-timeout-recovery", content: "Continue execution.", display: false }, { triggerTurn: true });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const classification = classifyProviderError(errorMsg);
|
|
98
|
+
const explicitRetryAfterMs = ("retryAfterMs" in lastMsg && typeof lastMsg.retryAfterMs === "number") ? lastMsg.retryAfterMs : undefined;
|
|
99
|
+
if (classification.isTransient) {
|
|
100
|
+
consecutiveTransientErrors += 1;
|
|
101
|
+
} else {
|
|
102
|
+
consecutiveTransientErrors = 0;
|
|
103
|
+
}
|
|
104
|
+
const baseRetryAfterMs = explicitRetryAfterMs ?? classification.suggestedDelayMs;
|
|
105
|
+
const retryAfterMs = classification.isTransient
|
|
106
|
+
? baseRetryAfterMs * 2 ** Math.max(0, consecutiveTransientErrors - 1)
|
|
107
|
+
: baseRetryAfterMs;
|
|
108
|
+
const allowAutoResume = classification.isTransient && consecutiveTransientErrors <= MAX_TRANSIENT_AUTO_RESUMES;
|
|
109
|
+
if (classification.isTransient && !allowAutoResume) {
|
|
110
|
+
ctx.ui.notify(`Transient provider errors persisted after ${MAX_TRANSIENT_AUTO_RESUMES} auto-resume attempts. Pausing for manual review.`, "warning");
|
|
111
|
+
}
|
|
112
|
+
await pauseAutoForProviderError(ctx.ui, errorDetail, () => pauseAuto(ctx, pi), {
|
|
113
|
+
isRateLimit: classification.isRateLimit,
|
|
114
|
+
isTransient: allowAutoResume,
|
|
115
|
+
retryAfterMs,
|
|
116
|
+
resume: allowAutoResume
|
|
117
|
+
? () => {
|
|
118
|
+
pi.sendMessage(
|
|
119
|
+
{ customType: "gsd-auto-timeout-recovery", content: "Continue execution — provider error recovery delay elapsed.", display: false },
|
|
120
|
+
{ triggerTurn: true },
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
: undefined,
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
consecutiveTransientErrors = 0;
|
|
130
|
+
networkRetryCounters.clear();
|
|
131
|
+
resolveAgentEnd(event);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
134
|
+
ctx.ui.notify(`Auto-mode error in agent_end handler: ${message}. Stopping auto-mode.`, "error");
|
|
135
|
+
try {
|
|
136
|
+
await pauseAuto(ctx, pi);
|
|
137
|
+
} catch {
|
|
138
|
+
// best-effort
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import type { ExtensionAPI } from "@gsd/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
import { findMilestoneIds, nextMilestoneId } from "../guided-flow.js";
|
|
5
|
+
import { loadEffectiveGSDPreferences } from "../preferences.js";
|
|
6
|
+
import { ensureDbOpen } from "./dynamic-tools.js";
|
|
7
|
+
|
|
8
|
+
export function registerDbTools(pi: ExtensionAPI): void {
|
|
9
|
+
pi.registerTool({
|
|
10
|
+
name: "gsd_save_decision",
|
|
11
|
+
label: "Save Decision",
|
|
12
|
+
description:
|
|
13
|
+
"Record a project decision to the GSD database and regenerate DECISIONS.md. " +
|
|
14
|
+
"Decision IDs are auto-assigned — never provide an ID manually.",
|
|
15
|
+
promptSnippet: "Record a project decision to the GSD database (auto-assigns ID, regenerates DECISIONS.md)",
|
|
16
|
+
promptGuidelines: [
|
|
17
|
+
"Use gsd_save_decision when recording an architectural, pattern, library, or observability decision.",
|
|
18
|
+
"Decision IDs are auto-assigned (D001, D002, ...) — never guess or provide an ID.",
|
|
19
|
+
"All fields except revisable and when_context are required.",
|
|
20
|
+
"The tool writes to the DB and regenerates .gsd/DECISIONS.md automatically.",
|
|
21
|
+
],
|
|
22
|
+
parameters: Type.Object({
|
|
23
|
+
scope: Type.String({ description: "Scope of the decision (e.g. 'architecture', 'library', 'observability')" }),
|
|
24
|
+
decision: Type.String({ description: "What is being decided" }),
|
|
25
|
+
choice: Type.String({ description: "The choice made" }),
|
|
26
|
+
rationale: Type.String({ description: "Why this choice was made" }),
|
|
27
|
+
revisable: Type.Optional(Type.String({ description: "Whether this can be revisited (default: 'Yes')" })),
|
|
28
|
+
when_context: Type.Optional(Type.String({ description: "When/context for the decision (e.g. milestone ID)" })),
|
|
29
|
+
}),
|
|
30
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
31
|
+
const dbAvailable = await ensureDbOpen();
|
|
32
|
+
if (!dbAvailable) {
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text" as const, text: "Error: GSD database is not available. Cannot save decision." }],
|
|
35
|
+
details: { operation: "save_decision", error: "db_unavailable" } as any,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const { saveDecisionToDb } = await import("../db-writer.js");
|
|
40
|
+
const { id } = await saveDecisionToDb(
|
|
41
|
+
{
|
|
42
|
+
scope: params.scope,
|
|
43
|
+
decision: params.decision,
|
|
44
|
+
choice: params.choice,
|
|
45
|
+
rationale: params.rationale,
|
|
46
|
+
revisable: params.revisable,
|
|
47
|
+
when_context: params.when_context,
|
|
48
|
+
},
|
|
49
|
+
process.cwd(),
|
|
50
|
+
);
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: "text" as const, text: `Saved decision ${id}` }],
|
|
53
|
+
details: { operation: "save_decision", id } as any,
|
|
54
|
+
};
|
|
55
|
+
} catch (err) {
|
|
56
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
57
|
+
process.stderr.write(`gsd-db: gsd_save_decision tool failed: ${msg}\n`);
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text" as const, text: `Error saving decision: ${msg}` }],
|
|
60
|
+
details: { operation: "save_decision", error: msg } as any,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
pi.registerTool({
|
|
67
|
+
name: "gsd_update_requirement",
|
|
68
|
+
label: "Update Requirement",
|
|
69
|
+
description:
|
|
70
|
+
"Update an existing requirement in the GSD database and regenerate REQUIREMENTS.md. " +
|
|
71
|
+
"Provide the requirement ID (e.g. R001) and any fields to update.",
|
|
72
|
+
promptSnippet: "Update an existing GSD requirement by ID (regenerates REQUIREMENTS.md)",
|
|
73
|
+
promptGuidelines: [
|
|
74
|
+
"Use gsd_update_requirement to change status, validation, notes, or other fields on an existing requirement.",
|
|
75
|
+
"The id parameter is required — it must be an existing RXXX identifier.",
|
|
76
|
+
"All other fields are optional — only provided fields are updated.",
|
|
77
|
+
"The tool verifies the requirement exists before updating.",
|
|
78
|
+
],
|
|
79
|
+
parameters: Type.Object({
|
|
80
|
+
id: Type.String({ description: "The requirement ID (e.g. R001, R014)" }),
|
|
81
|
+
status: Type.Optional(Type.String({ description: "New status (e.g. 'active', 'validated', 'deferred')" })),
|
|
82
|
+
validation: Type.Optional(Type.String({ description: "Validation criteria or proof" })),
|
|
83
|
+
notes: Type.Optional(Type.String({ description: "Additional notes" })),
|
|
84
|
+
description: Type.Optional(Type.String({ description: "Updated description" })),
|
|
85
|
+
primary_owner: Type.Optional(Type.String({ description: "Primary owning slice" })),
|
|
86
|
+
supporting_slices: Type.Optional(Type.String({ description: "Supporting slices" })),
|
|
87
|
+
}),
|
|
88
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
89
|
+
const dbAvailable = await ensureDbOpen();
|
|
90
|
+
if (!dbAvailable) {
|
|
91
|
+
return {
|
|
92
|
+
content: [{ type: "text" as const, text: "Error: GSD database is not available. Cannot update requirement." }],
|
|
93
|
+
details: { operation: "update_requirement", id: params.id, error: "db_unavailable" } as any,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const db = await import("../gsd-db.js");
|
|
98
|
+
const existing = db.getRequirementById(params.id);
|
|
99
|
+
if (!existing) {
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: "text" as const, text: `Error: Requirement ${params.id} not found.` }],
|
|
102
|
+
details: { operation: "update_requirement", id: params.id, error: "not_found" } as any,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const { updateRequirementInDb } = await import("../db-writer.js");
|
|
106
|
+
const updates: Record<string, string | undefined> = {};
|
|
107
|
+
if (params.status !== undefined) updates.status = params.status;
|
|
108
|
+
if (params.validation !== undefined) updates.validation = params.validation;
|
|
109
|
+
if (params.notes !== undefined) updates.notes = params.notes;
|
|
110
|
+
if (params.description !== undefined) updates.description = params.description;
|
|
111
|
+
if (params.primary_owner !== undefined) updates.primary_owner = params.primary_owner;
|
|
112
|
+
if (params.supporting_slices !== undefined) updates.supporting_slices = params.supporting_slices;
|
|
113
|
+
await updateRequirementInDb(params.id, updates, process.cwd());
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text" as const, text: `Updated requirement ${params.id}` }],
|
|
116
|
+
details: { operation: "update_requirement", id: params.id } as any,
|
|
117
|
+
};
|
|
118
|
+
} catch (err) {
|
|
119
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
process.stderr.write(`gsd-db: gsd_update_requirement tool failed: ${msg}\n`);
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: "text" as const, text: `Error updating requirement: ${msg}` }],
|
|
123
|
+
details: { operation: "update_requirement", id: params.id, error: msg } as any,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
pi.registerTool({
|
|
130
|
+
name: "gsd_save_summary",
|
|
131
|
+
label: "Save Summary",
|
|
132
|
+
description:
|
|
133
|
+
"Save a summary, research, context, or assessment artifact to the GSD database and write it to disk. " +
|
|
134
|
+
"Computes the file path from milestone/slice/task IDs automatically.",
|
|
135
|
+
promptSnippet: "Save a GSD artifact (summary/research/context/assessment) to DB and disk",
|
|
136
|
+
promptGuidelines: [
|
|
137
|
+
"Use gsd_save_summary to persist structured artifacts (SUMMARY, RESEARCH, CONTEXT, ASSESSMENT).",
|
|
138
|
+
"milestone_id is required. slice_id and task_id are optional — they determine the file path.",
|
|
139
|
+
"The tool computes the relative path automatically: milestones/M001/M001-SUMMARY.md, milestones/M001/slices/S01/S01-SUMMARY.md, etc.",
|
|
140
|
+
"artifact_type must be one of: SUMMARY, RESEARCH, CONTEXT, ASSESSMENT.",
|
|
141
|
+
],
|
|
142
|
+
parameters: Type.Object({
|
|
143
|
+
milestone_id: Type.String({ description: "Milestone ID (e.g. M001)" }),
|
|
144
|
+
slice_id: Type.Optional(Type.String({ description: "Slice ID (e.g. S01)" })),
|
|
145
|
+
task_id: Type.Optional(Type.String({ description: "Task ID (e.g. T01)" })),
|
|
146
|
+
artifact_type: Type.String({ description: "One of: SUMMARY, RESEARCH, CONTEXT, ASSESSMENT" }),
|
|
147
|
+
content: Type.String({ description: "The full markdown content of the artifact" }),
|
|
148
|
+
}),
|
|
149
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
150
|
+
const dbAvailable = await ensureDbOpen();
|
|
151
|
+
if (!dbAvailable) {
|
|
152
|
+
return {
|
|
153
|
+
content: [{ type: "text" as const, text: "Error: GSD database is not available. Cannot save artifact." }],
|
|
154
|
+
details: { operation: "save_summary", error: "db_unavailable" } as any,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const validTypes = ["SUMMARY", "RESEARCH", "CONTEXT", "ASSESSMENT"];
|
|
158
|
+
if (!validTypes.includes(params.artifact_type)) {
|
|
159
|
+
return {
|
|
160
|
+
content: [{ type: "text" as const, text: `Error: Invalid artifact_type "${params.artifact_type}". Must be one of: ${validTypes.join(", ")}` }],
|
|
161
|
+
details: { operation: "save_summary", error: "invalid_artifact_type" } as any,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
let relativePath: string;
|
|
166
|
+
if (params.task_id && params.slice_id) {
|
|
167
|
+
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/tasks/${params.task_id}-${params.artifact_type}.md`;
|
|
168
|
+
} else if (params.slice_id) {
|
|
169
|
+
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/${params.slice_id}-${params.artifact_type}.md`;
|
|
170
|
+
} else {
|
|
171
|
+
relativePath = `milestones/${params.milestone_id}/${params.milestone_id}-${params.artifact_type}.md`;
|
|
172
|
+
}
|
|
173
|
+
const { saveArtifactToDb } = await import("../db-writer.js");
|
|
174
|
+
await saveArtifactToDb(
|
|
175
|
+
{
|
|
176
|
+
path: relativePath,
|
|
177
|
+
artifact_type: params.artifact_type,
|
|
178
|
+
content: params.content,
|
|
179
|
+
milestone_id: params.milestone_id,
|
|
180
|
+
slice_id: params.slice_id,
|
|
181
|
+
task_id: params.task_id,
|
|
182
|
+
},
|
|
183
|
+
process.cwd(),
|
|
184
|
+
);
|
|
185
|
+
return {
|
|
186
|
+
content: [{ type: "text" as const, text: `Saved ${params.artifact_type} artifact to ${relativePath}` }],
|
|
187
|
+
details: { operation: "save_summary", path: relativePath, artifact_type: params.artifact_type } as any,
|
|
188
|
+
};
|
|
189
|
+
} catch (err) {
|
|
190
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
191
|
+
process.stderr.write(`gsd-db: gsd_save_summary tool failed: ${msg}\n`);
|
|
192
|
+
return {
|
|
193
|
+
content: [{ type: "text" as const, text: `Error saving artifact: ${msg}` }],
|
|
194
|
+
details: { operation: "save_summary", error: msg } as any,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const reservedMilestoneIds = new Set<string>();
|
|
201
|
+
pi.registerTool({
|
|
202
|
+
name: "gsd_generate_milestone_id",
|
|
203
|
+
label: "Generate Milestone ID",
|
|
204
|
+
description:
|
|
205
|
+
"Generate the next milestone ID for a new GSD milestone. " +
|
|
206
|
+
"Scans existing milestones on disk and respects the unique_milestone_ids preference. " +
|
|
207
|
+
"Always use this tool when creating a new milestone — never invent milestone IDs manually.",
|
|
208
|
+
promptSnippet: "Generate a valid milestone ID (respects unique_milestone_ids preference)",
|
|
209
|
+
promptGuidelines: [
|
|
210
|
+
"ALWAYS call gsd_generate_milestone_id before creating a new milestone directory or writing milestone files.",
|
|
211
|
+
"Never invent or hardcode milestone IDs like M001, M002 — always use this tool.",
|
|
212
|
+
"Call it once per milestone you need to create. For multi-milestone projects, call it once for each milestone in sequence.",
|
|
213
|
+
"The tool returns the correct format based on project preferences (e.g. M001 or M001-r5jzab).",
|
|
214
|
+
],
|
|
215
|
+
parameters: Type.Object({}),
|
|
216
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
217
|
+
try {
|
|
218
|
+
const basePath = process.cwd();
|
|
219
|
+
const existingIds = findMilestoneIds(basePath);
|
|
220
|
+
const uniqueEnabled = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
221
|
+
const allIds = [...new Set([...existingIds, ...reservedMilestoneIds])];
|
|
222
|
+
const newId = nextMilestoneId(allIds, uniqueEnabled);
|
|
223
|
+
reservedMilestoneIds.add(newId);
|
|
224
|
+
return {
|
|
225
|
+
content: [{ type: "text" as const, text: newId }],
|
|
226
|
+
details: { operation: "generate_milestone_id", id: newId, existingCount: existingIds.length, reservedCount: reservedMilestoneIds.size, uniqueEnabled } as any,
|
|
227
|
+
};
|
|
228
|
+
} catch (err) {
|
|
229
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
230
|
+
return {
|
|
231
|
+
content: [{ type: "text" as const, text: `Error generating milestone ID: ${msg}` }],
|
|
232
|
+
details: { operation: "generate_milestone_id", error: msg } as any,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|