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
|
@@ -23,6 +23,12 @@ import * as _bundledYaml from "yaml";
|
|
|
23
23
|
import * as _bundledMcpClient from "@modelcontextprotocol/sdk/client";
|
|
24
24
|
import * as _bundledMcpStdio from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
25
25
|
import * as _bundledMcpStreamableHttp from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
26
|
+
import * as _bundledMcpSse from "@modelcontextprotocol/sdk/client/sse.js";
|
|
27
|
+
import * as _bundledMcpServer from "@modelcontextprotocol/sdk/server";
|
|
28
|
+
import * as _bundledMcpServerStdio from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
29
|
+
import * as _bundledMcpServerSse from "@modelcontextprotocol/sdk/server/sse.js";
|
|
30
|
+
import * as _bundledMcpServerStreamableHttp from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
31
|
+
import * as _bundledMcpTypes from "@modelcontextprotocol/sdk/types.js";
|
|
26
32
|
import { getAgentDir, isBunBinary } from "../../config.js";
|
|
27
33
|
// NOTE: This import works because loader.ts exports are NOT re-exported from index.ts,
|
|
28
34
|
// avoiding a circular dependency. Extensions can import from @gsd/pi-coding-agent.
|
|
@@ -44,8 +50,11 @@ import type {
|
|
|
44
50
|
ToolDefinition,
|
|
45
51
|
} from "./types.js";
|
|
46
52
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Statically imported modules for Bun binary virtualModules.
|
|
55
|
+
* Maps specifier -> module object for subpaths that must be available in compiled binaries.
|
|
56
|
+
*/
|
|
57
|
+
const STATIC_BUNDLED_MODULES: Record<string, unknown> = {
|
|
49
58
|
"@sinclair/typebox": _bundledTypebox,
|
|
50
59
|
"@gsd/pi-agent-core": _bundledPiAgentCore,
|
|
51
60
|
"@gsd/pi-tui": _bundledPiTui,
|
|
@@ -58,6 +67,17 @@ const VIRTUAL_MODULES: Record<string, unknown> = {
|
|
|
58
67
|
"@modelcontextprotocol/sdk/client/stdio.js": _bundledMcpStdio,
|
|
59
68
|
"@modelcontextprotocol/sdk/client/streamableHttp": _bundledMcpStreamableHttp,
|
|
60
69
|
"@modelcontextprotocol/sdk/client/streamableHttp.js": _bundledMcpStreamableHttp,
|
|
70
|
+
"@modelcontextprotocol/sdk/client/sse": _bundledMcpSse,
|
|
71
|
+
"@modelcontextprotocol/sdk/client/sse.js": _bundledMcpSse,
|
|
72
|
+
"@modelcontextprotocol/sdk/server": _bundledMcpServer,
|
|
73
|
+
"@modelcontextprotocol/sdk/server/stdio": _bundledMcpServerStdio,
|
|
74
|
+
"@modelcontextprotocol/sdk/server/stdio.js": _bundledMcpServerStdio,
|
|
75
|
+
"@modelcontextprotocol/sdk/server/sse": _bundledMcpServerSse,
|
|
76
|
+
"@modelcontextprotocol/sdk/server/sse.js": _bundledMcpServerSse,
|
|
77
|
+
"@modelcontextprotocol/sdk/server/streamableHttp": _bundledMcpServerStreamableHttp,
|
|
78
|
+
"@modelcontextprotocol/sdk/server/streamableHttp.js": _bundledMcpServerStreamableHttp,
|
|
79
|
+
"@modelcontextprotocol/sdk/types": _bundledMcpTypes,
|
|
80
|
+
"@modelcontextprotocol/sdk/types.js": _bundledMcpTypes,
|
|
61
81
|
// Aliases for external PI ecosystem packages that import from the original scope
|
|
62
82
|
"@mariozechner/pi-agent-core": _bundledPiAgentCore,
|
|
63
83
|
"@mariozechner/pi-tui": _bundledPiTui,
|
|
@@ -66,9 +86,198 @@ const VIRTUAL_MODULES: Record<string, unknown> = {
|
|
|
66
86
|
"@mariozechner/pi-coding-agent": _bundledPiCodingAgent,
|
|
67
87
|
};
|
|
68
88
|
|
|
89
|
+
/** Modules available to extensions via virtualModules (for compiled Bun binary) */
|
|
90
|
+
const VIRTUAL_MODULES: Record<string, unknown> = { ...STATIC_BUNDLED_MODULES };
|
|
91
|
+
|
|
69
92
|
const require = createRequire(import.meta.url);
|
|
70
93
|
const EXTENSION_TIMING_ENABLED = process.env.GSD_STARTUP_TIMING === "1" || process.env.PI_TIMING === "1";
|
|
71
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Bundled npm packages whose subpath exports should be auto-resolved for extensions.
|
|
97
|
+
* Each package listed here will have its `exports` field read from package.json,
|
|
98
|
+
* and all subpath exports will be registered as jiti aliases (Node.js mode) so that
|
|
99
|
+
* extensions can import any standard subpath without hitting jiti's CJS double-resolve bug.
|
|
100
|
+
*/
|
|
101
|
+
const BUNDLED_PACKAGES_WITH_EXPORTS = [
|
|
102
|
+
"@modelcontextprotocol/sdk",
|
|
103
|
+
"yaml",
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Read a package's `exports` field and return alias entries mapping
|
|
108
|
+
* specifiers (e.g. `@modelcontextprotocol/sdk/server`) to resolved file paths.
|
|
109
|
+
*
|
|
110
|
+
* Handles:
|
|
111
|
+
* - Explicit subpath exports: `./client` -> `@pkg/client`
|
|
112
|
+
* - Wildcard exports (`./*`): scans the package's dist directory for actual files
|
|
113
|
+
* - Both `.js`-suffixed and bare specifiers for each subpath
|
|
114
|
+
*/
|
|
115
|
+
function resolveSubpathExports(packageName: string): Record<string, string> {
|
|
116
|
+
const aliases: Record<string, string> = {};
|
|
117
|
+
|
|
118
|
+
let packageJsonPath: string;
|
|
119
|
+
try {
|
|
120
|
+
// Resolve the package's root directory via its package.json
|
|
121
|
+
packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
122
|
+
} catch {
|
|
123
|
+
// Package doesn't allow importing package.json via exports — find it manually
|
|
124
|
+
try {
|
|
125
|
+
const anyEntry = require.resolve(packageName);
|
|
126
|
+
// Walk up from the resolved entry to find package.json
|
|
127
|
+
let dir = path.dirname(anyEntry);
|
|
128
|
+
while (dir !== path.dirname(dir)) {
|
|
129
|
+
const candidate = path.join(dir, "package.json");
|
|
130
|
+
if (fs.existsSync(candidate)) {
|
|
131
|
+
try {
|
|
132
|
+
const pkg = JSON.parse(fs.readFileSync(candidate, "utf-8"));
|
|
133
|
+
if (pkg.name === packageName) {
|
|
134
|
+
packageJsonPath = candidate;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
// not valid JSON, keep walking
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
dir = path.dirname(dir);
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
return aliases;
|
|
145
|
+
}
|
|
146
|
+
if (!packageJsonPath!) return aliases;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let pkg: { exports?: Record<string, unknown> };
|
|
150
|
+
try {
|
|
151
|
+
pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
152
|
+
} catch {
|
|
153
|
+
return aliases;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const exports = pkg.exports;
|
|
157
|
+
if (!exports || typeof exports !== "object") return aliases;
|
|
158
|
+
|
|
159
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
160
|
+
|
|
161
|
+
for (const [subpath, target] of Object.entries(exports)) {
|
|
162
|
+
if (subpath === ".") continue; // Root export handled by static imports
|
|
163
|
+
|
|
164
|
+
// Handle wildcard exports like "./*"
|
|
165
|
+
if (subpath.includes("*")) {
|
|
166
|
+
resolveWildcardExports(packageName, packageDir, subpath, target, aliases);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Explicit subpath: "./client" -> "@pkg/client"
|
|
171
|
+
const specifier = `${packageName}/${subpath.replace(/^\.\//, "")}`;
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
const resolved = require.resolve(specifier);
|
|
175
|
+
aliases[specifier] = resolved;
|
|
176
|
+
|
|
177
|
+
// Add .js-suffixed variant if the specifier doesn't already end in .js
|
|
178
|
+
if (!specifier.endsWith(".js")) {
|
|
179
|
+
const jsSpecifier = `${specifier}.js`;
|
|
180
|
+
try {
|
|
181
|
+
const jsResolved = require.resolve(jsSpecifier);
|
|
182
|
+
aliases[jsSpecifier] = jsResolved;
|
|
183
|
+
} catch {
|
|
184
|
+
// .js variant doesn't resolve — that's fine
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Add bare variant (without .js) if it ends in .js
|
|
189
|
+
if (specifier.endsWith(".js")) {
|
|
190
|
+
const bareSpecifier = specifier.slice(0, -3);
|
|
191
|
+
try {
|
|
192
|
+
const bareResolved = require.resolve(bareSpecifier);
|
|
193
|
+
aliases[bareSpecifier] = bareResolved;
|
|
194
|
+
} catch {
|
|
195
|
+
// bare variant doesn't resolve — that's fine
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} catch {
|
|
199
|
+
// Subpath doesn't resolve — skip it
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return aliases;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Resolve wildcard export patterns (e.g. `./*`) by scanning the package's
|
|
208
|
+
* file structure to find all matching files and generate alias entries.
|
|
209
|
+
*/
|
|
210
|
+
function resolveWildcardExports(
|
|
211
|
+
packageName: string,
|
|
212
|
+
packageDir: string,
|
|
213
|
+
subpathPattern: string,
|
|
214
|
+
target: unknown,
|
|
215
|
+
aliases: Record<string, string>,
|
|
216
|
+
): void {
|
|
217
|
+
// Extract the target directory pattern from the export target
|
|
218
|
+
// e.g. { "require": "./dist/cjs/*" } -> "dist/cjs"
|
|
219
|
+
let targetDir: string | null = null;
|
|
220
|
+
|
|
221
|
+
if (typeof target === "string") {
|
|
222
|
+
targetDir = target.replace(/\/\*$/, "").replace(/^\.\//, "");
|
|
223
|
+
} else if (target && typeof target === "object") {
|
|
224
|
+
const targetObj = target as Record<string, unknown>;
|
|
225
|
+
// Prefer "require" for CJS compatibility with jiti, fall back to "import"
|
|
226
|
+
const resolved = targetObj.require ?? targetObj.import ?? targetObj.default;
|
|
227
|
+
if (typeof resolved === "string") {
|
|
228
|
+
targetDir = resolved.replace(/\/\*$/, "").replace(/^\.\//, "");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!targetDir) return;
|
|
233
|
+
|
|
234
|
+
const fullTargetDir = path.join(packageDir, targetDir);
|
|
235
|
+
if (!fs.existsSync(fullTargetDir)) return;
|
|
236
|
+
|
|
237
|
+
// Scan for .js files and generate specifiers
|
|
238
|
+
const subpathPrefix = subpathPattern.replace(/\/?\*$/, "").replace(/^\.\//, "");
|
|
239
|
+
scanDirForExports(packageName, fullTargetDir, subpathPrefix, aliases);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Recursively scan a directory for .js files and register them as aliases.
|
|
244
|
+
*/
|
|
245
|
+
function scanDirForExports(
|
|
246
|
+
packageName: string,
|
|
247
|
+
dir: string,
|
|
248
|
+
relativePath: string,
|
|
249
|
+
aliases: Record<string, string>,
|
|
250
|
+
): void {
|
|
251
|
+
let entries: fs.Dirent[];
|
|
252
|
+
try {
|
|
253
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
254
|
+
} catch {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
for (const entry of entries) {
|
|
259
|
+
const entryRelative = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
260
|
+
|
|
261
|
+
if (entry.isDirectory()) {
|
|
262
|
+
// Skip examples/test directories — extensions don't need them
|
|
263
|
+
if (entry.name === "examples" || entry.name === "__tests__" || entry.name === "test") continue;
|
|
264
|
+
scanDirForExports(packageName, path.join(dir, entry.name), entryRelative, aliases);
|
|
265
|
+
} else if (entry.name.endsWith(".js") && !entry.name.endsWith(".d.js")) {
|
|
266
|
+
const filePath = path.join(dir, entry.name);
|
|
267
|
+
const specifier = `${packageName}/${entryRelative}`;
|
|
268
|
+
// Only add if not already covered by an explicit export
|
|
269
|
+
if (!(specifier in aliases)) {
|
|
270
|
+
aliases[specifier] = filePath;
|
|
271
|
+
}
|
|
272
|
+
// Also add bare (no .js) variant
|
|
273
|
+
const bareSpecifier = specifier.replace(/\.js$/, "");
|
|
274
|
+
if (!(bareSpecifier in aliases)) {
|
|
275
|
+
aliases[bareSpecifier] = filePath;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
72
281
|
function logExtensionTiming(extensionPath: string, ms: number, outcome: "loaded" | "failed"): void {
|
|
73
282
|
if (!EXTENSION_TIMING_ENABLED) return;
|
|
74
283
|
console.error(`[startup] extension ${outcome}: ${extensionPath} (${ms}ms)`);
|
|
@@ -100,7 +309,19 @@ function getAliases(): Record<string, string> {
|
|
|
100
309
|
return fileURLToPath(import.meta.resolve(specifier));
|
|
101
310
|
};
|
|
102
311
|
|
|
312
|
+
// Auto-discover subpath exports from bundled npm packages.
|
|
313
|
+
// This ensures extensions can import any standard subpath (e.g. @modelcontextprotocol/sdk/server)
|
|
314
|
+
// without hitting jiti's CJS double-resolve bug.
|
|
315
|
+
const autoDiscovered: Record<string, string> = {};
|
|
316
|
+
for (const packageName of BUNDLED_PACKAGES_WITH_EXPORTS) {
|
|
317
|
+
const subpathAliases = resolveSubpathExports(packageName);
|
|
318
|
+
Object.assign(autoDiscovered, subpathAliases);
|
|
319
|
+
}
|
|
320
|
+
|
|
103
321
|
_aliases = {
|
|
322
|
+
// Auto-discovered subpath exports (lowest priority — overridden by manual entries below)
|
|
323
|
+
...autoDiscovered,
|
|
324
|
+
// Manual entries for workspace packages and packages needing special resolution
|
|
104
325
|
"@gsd/pi-coding-agent": packageIndex,
|
|
105
326
|
"@gsd/pi-agent-core": resolveWorkspaceOrImport("agent/dist/index.js", "@gsd/pi-agent-core"),
|
|
106
327
|
"@gsd/pi-tui": resolveWorkspaceOrImport("tui/dist/index.js", "@gsd/pi-tui"),
|
|
@@ -108,11 +329,6 @@ function getAliases(): Record<string, string> {
|
|
|
108
329
|
"@gsd/pi-ai/oauth": resolveWorkspaceOrImport("ai/dist/oauth.js", "@gsd/pi-ai/oauth"),
|
|
109
330
|
"@sinclair/typebox": typeboxRoot,
|
|
110
331
|
"yaml": yamlRoot,
|
|
111
|
-
"@modelcontextprotocol/sdk/client": require.resolve("@modelcontextprotocol/sdk/client"),
|
|
112
|
-
"@modelcontextprotocol/sdk/client/stdio": require.resolve("@modelcontextprotocol/sdk/client/stdio.js"),
|
|
113
|
-
"@modelcontextprotocol/sdk/client/stdio.js": require.resolve("@modelcontextprotocol/sdk/client/stdio.js"),
|
|
114
|
-
"@modelcontextprotocol/sdk/client/streamableHttp": require.resolve("@modelcontextprotocol/sdk/client/streamableHttp.js"),
|
|
115
|
-
"@modelcontextprotocol/sdk/client/streamableHttp.js": require.resolve("@modelcontextprotocol/sdk/client/streamableHttp.js"),
|
|
116
332
|
// Aliases for external PI ecosystem packages that import from the original scope
|
|
117
333
|
"@mariozechner/pi-coding-agent": packageIndex,
|
|
118
334
|
"@mariozechner/pi-agent-core": resolveWorkspaceOrImport("agent/dist/index.js", "@gsd/pi-agent-core"),
|
|
@@ -414,7 +414,13 @@ function resolveExtensionEntries(dir: string): string[] | null {
|
|
|
414
414
|
const packageJsonPath = join(dir, "package.json");
|
|
415
415
|
if (existsSync(packageJsonPath)) {
|
|
416
416
|
const manifest = readPiManifestFile(packageJsonPath);
|
|
417
|
-
if (manifest
|
|
417
|
+
if (manifest) {
|
|
418
|
+
// When a pi manifest exists, it is authoritative — don't fall through
|
|
419
|
+
// to index.ts/index.js auto-detection. This allows library directories
|
|
420
|
+
// (like cmux) to opt out by declaring "pi": {} with no extensions.
|
|
421
|
+
if (!manifest.extensions?.length) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
418
424
|
const entries: string[] = [];
|
|
419
425
|
for (const extPath of manifest.extensions) {
|
|
420
426
|
const resolvedExtPath = resolve(dir, extPath);
|
|
@@ -422,9 +428,7 @@ function resolveExtensionEntries(dir: string): string[] | null {
|
|
|
422
428
|
entries.push(resolvedExtPath);
|
|
423
429
|
}
|
|
424
430
|
}
|
|
425
|
-
|
|
426
|
-
return entries;
|
|
427
|
-
}
|
|
431
|
+
return entries.length > 0 ? entries : null;
|
|
428
432
|
}
|
|
429
433
|
}
|
|
430
434
|
|
|
@@ -81,6 +81,12 @@ export interface LoadSkillsResult {
|
|
|
81
81
|
diagnostics: ResourceDiagnostic[];
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
let loadedSkills: Skill[] = [];
|
|
85
|
+
|
|
86
|
+
export function getLoadedSkills(): Skill[] {
|
|
87
|
+
return [...loadedSkills];
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
/**
|
|
85
91
|
* Validate skill name per Agent Skills spec.
|
|
86
92
|
* Returns array of validation error messages (empty if valid).
|
|
@@ -449,8 +455,10 @@ export function loadSkills(options: LoadSkillsOptions = {}): LoadSkillsResult {
|
|
|
449
455
|
}
|
|
450
456
|
}
|
|
451
457
|
|
|
458
|
+
loadedSkills = Array.from(skillMap.values());
|
|
459
|
+
|
|
452
460
|
return {
|
|
453
|
-
skills:
|
|
461
|
+
skills: [...loadedSkills],
|
|
454
462
|
diagnostics: [...allDiagnostics, ...collisionDiagnostics],
|
|
455
463
|
};
|
|
456
464
|
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { Loader, Spacer, Text } from "@gsd/pi-tui";
|
|
2
|
+
|
|
3
|
+
import type { InteractiveModeEvent, InteractiveModeStateHost } from "../interactive-mode-state.js";
|
|
4
|
+
import { theme } from "../theme/theme.js";
|
|
5
|
+
import { AssistantMessageComponent } from "../components/assistant-message.js";
|
|
6
|
+
import { ToolExecutionComponent } from "../components/tool-execution.js";
|
|
7
|
+
import { appKey } from "../components/keybinding-hints.js";
|
|
8
|
+
|
|
9
|
+
export async function handleAgentEvent(host: InteractiveModeStateHost & {
|
|
10
|
+
init: () => Promise<void>;
|
|
11
|
+
getMarkdownThemeWithSettings: () => any;
|
|
12
|
+
addMessageToChat: (message: any, options?: any) => void;
|
|
13
|
+
formatWebSearchResult: (content: unknown) => string;
|
|
14
|
+
getRegisteredToolDefinition: (toolName: string) => any;
|
|
15
|
+
checkShutdownRequested: () => Promise<void>;
|
|
16
|
+
rebuildChatFromMessages: () => void;
|
|
17
|
+
flushCompactionQueue: (options?: { willRetry?: boolean }) => Promise<void>;
|
|
18
|
+
showStatus: (message: string) => void;
|
|
19
|
+
showError: (message: string) => void;
|
|
20
|
+
updatePendingMessagesDisplay: () => void;
|
|
21
|
+
}, event: InteractiveModeEvent): Promise<void> {
|
|
22
|
+
if (!host.isInitialized) {
|
|
23
|
+
await host.init();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
host.footer.invalidate();
|
|
27
|
+
|
|
28
|
+
switch (event.type) {
|
|
29
|
+
case "agent_start":
|
|
30
|
+
if (host.retryEscapeHandler) {
|
|
31
|
+
host.defaultEditor.onEscape = host.retryEscapeHandler;
|
|
32
|
+
host.retryEscapeHandler = undefined;
|
|
33
|
+
}
|
|
34
|
+
if (host.retryLoader) {
|
|
35
|
+
host.retryLoader.stop();
|
|
36
|
+
host.retryLoader = undefined;
|
|
37
|
+
}
|
|
38
|
+
if (host.loadingAnimation) {
|
|
39
|
+
host.loadingAnimation.stop();
|
|
40
|
+
}
|
|
41
|
+
host.statusContainer.clear();
|
|
42
|
+
host.loadingAnimation = new Loader(
|
|
43
|
+
host.ui,
|
|
44
|
+
(spinner) => theme.fg("accent", spinner),
|
|
45
|
+
(text) => theme.fg("muted", text),
|
|
46
|
+
host.defaultWorkingMessage,
|
|
47
|
+
);
|
|
48
|
+
host.statusContainer.addChild(host.loadingAnimation);
|
|
49
|
+
if (host.pendingWorkingMessage !== undefined) {
|
|
50
|
+
if (host.pendingWorkingMessage) {
|
|
51
|
+
host.loadingAnimation.setMessage(host.pendingWorkingMessage);
|
|
52
|
+
}
|
|
53
|
+
host.pendingWorkingMessage = undefined;
|
|
54
|
+
}
|
|
55
|
+
host.ui.requestRender();
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case "message_start":
|
|
59
|
+
if (event.message.role === "custom") {
|
|
60
|
+
host.addMessageToChat(event.message);
|
|
61
|
+
host.ui.requestRender();
|
|
62
|
+
} else if (event.message.role === "user") {
|
|
63
|
+
host.addMessageToChat(event.message);
|
|
64
|
+
host.updatePendingMessagesDisplay();
|
|
65
|
+
host.ui.requestRender();
|
|
66
|
+
} else if (event.message.role === "assistant") {
|
|
67
|
+
host.streamingComponent = new AssistantMessageComponent(
|
|
68
|
+
undefined,
|
|
69
|
+
host.hideThinkingBlock,
|
|
70
|
+
host.getMarkdownThemeWithSettings(),
|
|
71
|
+
);
|
|
72
|
+
host.streamingMessage = event.message;
|
|
73
|
+
host.chatContainer.addChild(host.streamingComponent);
|
|
74
|
+
host.streamingComponent.updateContent(host.streamingMessage);
|
|
75
|
+
host.ui.requestRender();
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case "message_update":
|
|
80
|
+
if (host.streamingComponent && event.message.role === "assistant") {
|
|
81
|
+
host.streamingMessage = event.message;
|
|
82
|
+
host.streamingComponent.updateContent(host.streamingMessage);
|
|
83
|
+
for (const content of host.streamingMessage.content) {
|
|
84
|
+
if (content.type === "toolCall") {
|
|
85
|
+
if (!host.pendingTools.has(content.id)) {
|
|
86
|
+
const component = new ToolExecutionComponent(
|
|
87
|
+
content.name,
|
|
88
|
+
content.arguments,
|
|
89
|
+
{ showImages: host.settingsManager.getShowImages() },
|
|
90
|
+
host.getRegisteredToolDefinition(content.name),
|
|
91
|
+
host.ui,
|
|
92
|
+
);
|
|
93
|
+
component.setExpanded(host.toolOutputExpanded);
|
|
94
|
+
host.chatContainer.addChild(component);
|
|
95
|
+
host.pendingTools.set(content.id, component);
|
|
96
|
+
} else {
|
|
97
|
+
host.pendingTools.get(content.id)?.updateArgs(content.arguments);
|
|
98
|
+
}
|
|
99
|
+
} else if (content.type === "serverToolUse") {
|
|
100
|
+
if (!host.pendingTools.has(content.id)) {
|
|
101
|
+
const component = new ToolExecutionComponent(
|
|
102
|
+
content.name,
|
|
103
|
+
content.input ?? {},
|
|
104
|
+
{ showImages: host.settingsManager.getShowImages() },
|
|
105
|
+
undefined,
|
|
106
|
+
host.ui,
|
|
107
|
+
);
|
|
108
|
+
component.setExpanded(host.toolOutputExpanded);
|
|
109
|
+
host.chatContainer.addChild(component);
|
|
110
|
+
host.pendingTools.set(content.id, component);
|
|
111
|
+
}
|
|
112
|
+
} else if (content.type === "webSearchResult") {
|
|
113
|
+
const component = host.pendingTools.get(content.toolUseId);
|
|
114
|
+
if (component) {
|
|
115
|
+
const searchContent = content.content;
|
|
116
|
+
const isError = searchContent && typeof searchContent === "object" && "type" in (searchContent as any) && (searchContent as any).type === "web_search_tool_result_error";
|
|
117
|
+
component.updateResult({
|
|
118
|
+
content: [{ type: "text", text: host.formatWebSearchResult(searchContent) }],
|
|
119
|
+
isError: !!isError,
|
|
120
|
+
});
|
|
121
|
+
host.pendingTools.delete(content.toolUseId);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
host.ui.requestRender();
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case "message_end":
|
|
130
|
+
if (event.message.role === "user") break;
|
|
131
|
+
if (host.streamingComponent && event.message.role === "assistant") {
|
|
132
|
+
host.streamingMessage = event.message;
|
|
133
|
+
let errorMessage: string | undefined;
|
|
134
|
+
if (host.streamingMessage.stopReason === "aborted") {
|
|
135
|
+
const retryAttempt = host.session.retryAttempt;
|
|
136
|
+
errorMessage = retryAttempt > 0
|
|
137
|
+
? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
|
|
138
|
+
: "Operation aborted";
|
|
139
|
+
host.streamingMessage.errorMessage = errorMessage;
|
|
140
|
+
}
|
|
141
|
+
host.streamingComponent.updateContent(host.streamingMessage);
|
|
142
|
+
if (host.streamingMessage.stopReason === "aborted" || host.streamingMessage.stopReason === "error") {
|
|
143
|
+
if (!errorMessage) {
|
|
144
|
+
errorMessage = host.streamingMessage.errorMessage || "Error";
|
|
145
|
+
}
|
|
146
|
+
for (const [, component] of host.pendingTools.entries()) {
|
|
147
|
+
component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
|
|
148
|
+
}
|
|
149
|
+
host.pendingTools.clear();
|
|
150
|
+
} else {
|
|
151
|
+
for (const [, component] of host.pendingTools.entries()) {
|
|
152
|
+
component.setArgsComplete();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
host.streamingComponent = undefined;
|
|
156
|
+
host.streamingMessage = undefined;
|
|
157
|
+
host.footer.invalidate();
|
|
158
|
+
}
|
|
159
|
+
host.ui.requestRender();
|
|
160
|
+
break;
|
|
161
|
+
|
|
162
|
+
case "tool_execution_start":
|
|
163
|
+
if (!host.pendingTools.has(event.toolCallId)) {
|
|
164
|
+
const component = new ToolExecutionComponent(
|
|
165
|
+
event.toolName,
|
|
166
|
+
event.args,
|
|
167
|
+
{ showImages: host.settingsManager.getShowImages() },
|
|
168
|
+
host.getRegisteredToolDefinition(event.toolName),
|
|
169
|
+
host.ui,
|
|
170
|
+
);
|
|
171
|
+
component.setExpanded(host.toolOutputExpanded);
|
|
172
|
+
host.chatContainer.addChild(component);
|
|
173
|
+
host.pendingTools.set(event.toolCallId, component);
|
|
174
|
+
host.ui.requestRender();
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
|
|
178
|
+
case "tool_execution_update": {
|
|
179
|
+
const component = host.pendingTools.get(event.toolCallId);
|
|
180
|
+
if (component) {
|
|
181
|
+
component.updateResult({ ...event.partialResult, isError: false }, true);
|
|
182
|
+
host.ui.requestRender();
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
case "tool_execution_end": {
|
|
188
|
+
const component = host.pendingTools.get(event.toolCallId);
|
|
189
|
+
if (component) {
|
|
190
|
+
component.updateResult({ ...event.result, isError: event.isError });
|
|
191
|
+
host.pendingTools.delete(event.toolCallId);
|
|
192
|
+
host.ui.requestRender();
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
case "agent_end":
|
|
198
|
+
if (host.loadingAnimation) {
|
|
199
|
+
host.loadingAnimation.stop();
|
|
200
|
+
host.loadingAnimation = undefined;
|
|
201
|
+
host.statusContainer.clear();
|
|
202
|
+
}
|
|
203
|
+
if (host.streamingComponent) {
|
|
204
|
+
host.chatContainer.removeChild(host.streamingComponent);
|
|
205
|
+
host.streamingComponent = undefined;
|
|
206
|
+
host.streamingMessage = undefined;
|
|
207
|
+
}
|
|
208
|
+
host.pendingTools.clear();
|
|
209
|
+
await host.checkShutdownRequested();
|
|
210
|
+
host.ui.requestRender();
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
case "auto_compaction_start":
|
|
214
|
+
host.autoCompactionEscapeHandler = host.defaultEditor.onEscape;
|
|
215
|
+
host.defaultEditor.onEscape = () => host.session.abortCompaction();
|
|
216
|
+
host.statusContainer.clear();
|
|
217
|
+
host.autoCompactionLoader = new Loader(
|
|
218
|
+
host.ui,
|
|
219
|
+
(spinner) => theme.fg("accent", spinner),
|
|
220
|
+
(text) => theme.fg("muted", text),
|
|
221
|
+
`${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... (${appKey(host.keybindings, "interrupt")} to cancel)`,
|
|
222
|
+
);
|
|
223
|
+
host.statusContainer.addChild(host.autoCompactionLoader);
|
|
224
|
+
host.ui.requestRender();
|
|
225
|
+
break;
|
|
226
|
+
|
|
227
|
+
case "auto_compaction_end":
|
|
228
|
+
if (host.autoCompactionEscapeHandler) {
|
|
229
|
+
host.defaultEditor.onEscape = host.autoCompactionEscapeHandler;
|
|
230
|
+
host.autoCompactionEscapeHandler = undefined;
|
|
231
|
+
}
|
|
232
|
+
if (host.autoCompactionLoader) {
|
|
233
|
+
host.autoCompactionLoader.stop();
|
|
234
|
+
host.autoCompactionLoader = undefined;
|
|
235
|
+
host.statusContainer.clear();
|
|
236
|
+
}
|
|
237
|
+
if (event.aborted) {
|
|
238
|
+
host.showStatus("Auto-compaction cancelled");
|
|
239
|
+
} else if (event.result) {
|
|
240
|
+
host.chatContainer.clear();
|
|
241
|
+
host.rebuildChatFromMessages();
|
|
242
|
+
host.addMessageToChat({
|
|
243
|
+
role: "compactionSummary",
|
|
244
|
+
tokensBefore: event.result.tokensBefore,
|
|
245
|
+
summary: event.result.summary,
|
|
246
|
+
timestamp: Date.now(),
|
|
247
|
+
});
|
|
248
|
+
host.footer.invalidate();
|
|
249
|
+
} else if (event.errorMessage) {
|
|
250
|
+
host.chatContainer.addChild(new Spacer(1));
|
|
251
|
+
host.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
|
|
252
|
+
}
|
|
253
|
+
void host.flushCompactionQueue({ willRetry: event.willRetry });
|
|
254
|
+
host.ui.requestRender();
|
|
255
|
+
break;
|
|
256
|
+
|
|
257
|
+
case "auto_retry_start":
|
|
258
|
+
host.retryEscapeHandler = host.defaultEditor.onEscape;
|
|
259
|
+
host.defaultEditor.onEscape = () => host.session.abortRetry();
|
|
260
|
+
host.statusContainer.clear();
|
|
261
|
+
host.retryLoader = new Loader(
|
|
262
|
+
host.ui,
|
|
263
|
+
(spinner) => theme.fg("warning", spinner),
|
|
264
|
+
(text) => theme.fg("muted", text),
|
|
265
|
+
`Retrying (${event.attempt}/${event.maxAttempts}) in ${Math.round(event.delayMs / 1000)}s... (${appKey(host.keybindings, "interrupt")} to cancel)`,
|
|
266
|
+
);
|
|
267
|
+
host.statusContainer.addChild(host.retryLoader);
|
|
268
|
+
host.ui.requestRender();
|
|
269
|
+
break;
|
|
270
|
+
|
|
271
|
+
case "auto_retry_end":
|
|
272
|
+
if (host.retryEscapeHandler) {
|
|
273
|
+
host.defaultEditor.onEscape = host.retryEscapeHandler;
|
|
274
|
+
host.retryEscapeHandler = undefined;
|
|
275
|
+
}
|
|
276
|
+
if (host.retryLoader) {
|
|
277
|
+
host.retryLoader.stop();
|
|
278
|
+
host.retryLoader = undefined;
|
|
279
|
+
host.statusContainer.clear();
|
|
280
|
+
}
|
|
281
|
+
if (!event.success) {
|
|
282
|
+
host.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || "Unknown error"}`);
|
|
283
|
+
}
|
|
284
|
+
host.ui.requestRender();
|
|
285
|
+
break;
|
|
286
|
+
|
|
287
|
+
case "fallback_provider_switch":
|
|
288
|
+
host.showStatus(`Switched from ${event.from} → ${event.to} (${event.reason})`);
|
|
289
|
+
host.ui.requestRender();
|
|
290
|
+
break;
|
|
291
|
+
|
|
292
|
+
case "fallback_provider_restored":
|
|
293
|
+
host.showStatus(`Restored to ${event.provider}`);
|
|
294
|
+
host.ui.requestRender();
|
|
295
|
+
break;
|
|
296
|
+
|
|
297
|
+
case "fallback_chain_exhausted":
|
|
298
|
+
host.showError(event.reason);
|
|
299
|
+
host.ui.requestRender();
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|