@f5-sales-demo/xcsh 19.51.2
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/CHANGELOG.md +7073 -0
- package/README.md +14 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +109 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/todo/index.ts +206 -0
- package/examples/extensions/README.md +143 -0
- package/examples/extensions/api-demo.ts +89 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +32 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +551 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/todo.ts +296 -0
- package/examples/extensions/tools.ts +145 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +43 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +80 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +539 -0
- package/scripts/build-info/resolvers.ts +51 -0
- package/scripts/capture-ax-fixture.ts +84 -0
- package/scripts/capture-login-fixture.ts +30 -0
- package/scripts/check-workflow-field-coverage.ts +101 -0
- package/scripts/extension-uat-harness.ts +340 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-api-spec-index.ts +580 -0
- package/scripts/generate-branding-index.ts +81 -0
- package/scripts/generate-build-info.ts +106 -0
- package/scripts/generate-console-catalog.ts +88 -0
- package/scripts/generate-console-field-metadata.ts +74 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +32 -0
- package/scripts/generate-terraform-index.ts +81 -0
- package/scripts/mermaid-gallery.ts +132 -0
- package/scripts/uat-matrix-modalities.ts +451 -0
- package/scripts/uat-matrix-report.ts +175 -0
- package/scripts/uat-matrix.ts +353 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +416 -0
- package/src/async/support.ts +5 -0
- package/src/autoresearch/apply-contract-to-state.ts +1 -0
- package/src/autoresearch/command-resume.md +17 -0
- package/src/autoresearch/contract.ts +205 -0
- package/src/autoresearch/dashboard.ts +374 -0
- package/src/autoresearch/git.ts +191 -0
- package/src/autoresearch/helpers.ts +328 -0
- package/src/autoresearch/index.ts +402 -0
- package/src/autoresearch/prompt.md +236 -0
- package/src/autoresearch/resume-message.md +16 -0
- package/src/autoresearch/state.ts +303 -0
- package/src/autoresearch/tools/init-experiment.ts +400 -0
- package/src/autoresearch/tools/log-experiment.ts +793 -0
- package/src/autoresearch/tools/run-experiment.ts +679 -0
- package/src/autoresearch/types.ts +114 -0
- package/src/browser/acquire.ts +249 -0
- package/src/browser/actions.ts +126 -0
- package/src/browser/auth.ts +176 -0
- package/src/browser/ax.ts +134 -0
- package/src/browser/cdp-core.ts +45 -0
- package/src/browser/cdp-page-actions.ts +51 -0
- package/src/browser/chrome-locate.ts +66 -0
- package/src/browser/dom-context.ts +89 -0
- package/src/browser/dt-context.ts +100 -0
- package/src/browser/extension-bridge.ts +182 -0
- package/src/browser/extension-page-actions.ts +397 -0
- package/src/browser/extension-provider.ts +373 -0
- package/src/browser/index.ts +17 -0
- package/src/browser/input-commit.ts +74 -0
- package/src/browser/native-messaging.ts +20 -0
- package/src/browser/page-actions.ts +18 -0
- package/src/browser/provider.ts +155 -0
- package/src/browser/resolver.ts +126 -0
- package/src/browser/selector.ts +40 -0
- package/src/bun-imports.d.ts +22 -0
- package/src/capability/context-file.ts +43 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +438 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +224 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +50 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +286 -0
- package/src/cli/chrome-cli.ts +88 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/file-processor.ts +121 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +78 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/jupyter-cli.ts +106 -0
- package/src/cli/list-models.ts +128 -0
- package/src/cli/plugin-cli.ts +964 -0
- package/src/cli/read-cli.ts +68 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +479 -0
- package/src/cli/shell-cli.ts +174 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +182 -0
- package/src/cli/update-cli.ts +446 -0
- package/src/cli/web-search-cli.ts +203 -0
- package/src/cli.ts +123 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/chrome-host.ts +71 -0
- package/src/commands/chrome.ts +28 -0
- package/src/commands/commit.ts +36 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +20 -0
- package/src/commands/jupyter.ts +32 -0
- package/src/commands/launch.ts +144 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +33 -0
- package/src/commands/setup.ts +42 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +46 -0
- package/src/commit/agentic/agent.ts +314 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +354 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +139 -0
- package/src/commit/agentic/tools/propose-commit.ts +122 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +31 -0
- package/src/commit/agentic/tools/split-commit.ts +251 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +122 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +101 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +108 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +66 -0
- package/src/commit/pipeline.ts +242 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +44 -0
- package/src/config/auto-config.ts +698 -0
- package/src/config/context-schema.json +115 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +493 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +675 -0
- package/src/config/model-registry.ts +2265 -0
- package/src/config/model-resolver.ts +1289 -0
- package/src/config/prompt-templates.ts +271 -0
- package/src/config/resolve-config-value.ts +110 -0
- package/src/config/settings-schema.ts +2155 -0
- package/src/config/settings.ts +730 -0
- package/src/config.ts +418 -0
- package/src/cursor.ts +323 -0
- package/src/dap/client.ts +674 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1255 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +440 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +158 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +107 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +219 -0
- package/src/discovery/builtin.ts +851 -0
- package/src/discovery/claude-plugins.ts +297 -0
- package/src/discovery/claude.ts +543 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +535 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +396 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +934 -0
- package/src/discovery/index.ts +79 -0
- package/src/discovery/language.ts +46 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +393 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/diff.ts +818 -0
- package/src/edit/index.ts +481 -0
- package/src/edit/line-hash.ts +67 -0
- package/src/edit/modes/chunk.ts +762 -0
- package/src/edit/modes/hashline.ts +1366 -0
- package/src/edit/modes/patch.ts +1791 -0
- package/src/edit/modes/replace.ts +1115 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/renderer.ts +627 -0
- package/src/exa/factory.ts +61 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +293 -0
- package/src/exa/render.ts +232 -0
- package/src/exa/researcher.ts +47 -0
- package/src/exa/search.ts +86 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +247 -0
- package/src/exec/bash-executor.ts +332 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +161 -0
- package/src/export/html/template.css +1001 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +1950 -0
- package/src/export/html/template.macro.ts +24 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +236 -0
- package/src/extensibility/custom-commands/types.ts +111 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +238 -0
- package/src/extensibility/custom-tools/types.ts +251 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +572 -0
- package/src/extensibility/extensions/runner.ts +848 -0
- package/src/extensibility/extensions/types.ts +1394 -0
- package/src/extensibility/extensions/wrapper.ts +191 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +255 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +108 -0
- package/src/extensibility/hooks/types.ts +826 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/loader.ts +267 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +318 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +781 -0
- package/src/extensibility/plugins/marketplace/prerequisites.ts +255 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +201 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/skills.ts +269 -0
- package/src/extensibility/slash-commands.ts +246 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/utils.ts +38 -0
- package/src/index.ts +61 -0
- package/src/internal-urls/agent-protocol.ts +136 -0
- package/src/internal-urls/api-catalog-resolve.ts +495 -0
- package/src/internal-urls/api-catalog-types.ts +94 -0
- package/src/internal-urls/api-spec-resolve.ts +1036 -0
- package/src/internal-urls/api-spec-types.ts +239 -0
- package/src/internal-urls/artifact-protocol.ts +97 -0
- package/src/internal-urls/branding-index.generated.ts +88 -0
- package/src/internal-urls/build-info-runtime.ts +302 -0
- package/src/internal-urls/build-info.generated.ts +33 -0
- package/src/internal-urls/computer-profile.ts +692 -0
- package/src/internal-urls/console-catalog-types.ts +21 -0
- package/src/internal-urls/console-catalog.generated.ts +532 -0
- package/src/internal-urls/console-field-metadata-types.ts +59 -0
- package/src/internal-urls/console-field-metadata.generated.ts +4841 -0
- package/src/internal-urls/console-resolve.ts +178 -0
- package/src/internal-urls/docs-index.generated.ts +698 -0
- package/src/internal-urls/extension-api.md +147 -0
- package/src/internal-urls/index.ts +46 -0
- package/src/internal-urls/jobs-protocol.ts +119 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +206 -0
- package/src/internal-urls/mcp-protocol.ts +156 -0
- package/src/internal-urls/memory-protocol.ts +133 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/profile-collectors.ts +106 -0
- package/src/internal-urls/router.ts +55 -0
- package/src/internal-urls/rule-protocol.ts +55 -0
- package/src/internal-urls/skill-protocol.ts +111 -0
- package/src/internal-urls/terraform-index.generated.ts +1852 -0
- package/src/internal-urls/terraform-resolve.ts +184 -0
- package/src/internal-urls/terraform-types.ts +45 -0
- package/src/internal-urls/types.ts +52 -0
- package/src/internal-urls/user-profile.ts +363 -0
- package/src/internal-urls/xcsh-protocol.ts +644 -0
- package/src/ipy/cancellation.ts +28 -0
- package/src/ipy/executor.ts +1155 -0
- package/src/ipy/gateway-coordinator.ts +424 -0
- package/src/ipy/kernel.ts +1091 -0
- package/src/ipy/modules.ts +144 -0
- package/src/ipy/prelude.py +849 -0
- package/src/ipy/prelude.ts +3 -0
- package/src/ipy/runtime.ts +221 -0
- package/src/locales/ar.json +512 -0
- package/src/locales/de.json +512 -0
- package/src/locales/en.json +549 -0
- package/src/locales/es.json +512 -0
- package/src/locales/fr.json +512 -0
- package/src/locales/hi.json +512 -0
- package/src/locales/index.ts +29 -0
- package/src/locales/it.json +512 -0
- package/src/locales/ja.json +512 -0
- package/src/locales/ko.json +512 -0
- package/src/locales/pt-br.json +512 -0
- package/src/locales/th.json +512 -0
- package/src/locales/zh-cn.json +512 -0
- package/src/locales/zh-tw.json +512 -0
- package/src/lsp/client.ts +941 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +418 -0
- package/src/lsp/defaults.json +999 -0
- package/src/lsp/edits.ts +109 -0
- package/src/lsp/index.ts +1746 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +444 -0
- package/src/lsp/utils.ts +691 -0
- package/src/main.ts +944 -0
- package/src/mcp/client.ts +482 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/discoverable-tool-metadata.ts +202 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +84 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1152 -0
- package/src/mcp/oauth-discovery.ts +349 -0
- package/src/mcp/oauth-flow.ts +387 -0
- package/src/mcp/render.ts +157 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/tool-bridge.ts +417 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +475 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +325 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +1115 -0
- package/src/memories/storage.ts +577 -0
- package/src/modes/acp/acp-agent.ts +1361 -0
- package/src/modes/acp/acp-event-mapper.ts +538 -0
- package/src/modes/acp/acp-mode.ts +15 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/components/agent-dashboard.ts +1124 -0
- package/src/modes/components/assistant-message.ts +213 -0
- package/src/modes/components/bash-execution.ts +345 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +103 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/context-add-wizard.ts +534 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +238 -0
- package/src/modes/components/custom-message.ts +91 -0
- package/src/modes/components/diff.ts +210 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/extensions/extension-dashboard.ts +326 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +587 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +262 -0
- package/src/modes/components/gutter-block.ts +315 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +81 -0
- package/src/modes/components/hook-message.ts +100 -0
- package/src/modes/components/hook-selector.ts +192 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1314 -0
- package/src/modes/components/model-selector.ts +946 -0
- package/src/modes/components/oauth-selector.ts +211 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +477 -0
- package/src/modes/components/plugins/index.ts +5 -0
- package/src/modes/components/plugins/plugin-dashboard.ts +523 -0
- package/src/modes/components/plugins/plugin-inspector-pane.ts +84 -0
- package/src/modes/components/plugins/plugin-list-pane.ts +109 -0
- package/src/modes/components/plugins/state-manager.ts +229 -0
- package/src/modes/components/plugins/types.ts +51 -0
- package/src/modes/components/plugins/utils.ts +6 -0
- package/src/modes/components/python-execution.ts +244 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +137 -0
- package/src/modes/components/session-observer-overlay.ts +483 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +568 -0
- package/src/modes/components/settings-selector.ts +641 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-gradient.ts +64 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/hex-ansi.ts +29 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +174 -0
- package/src/modes/components/status-line/segments.ts +494 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +96 -0
- package/src/modes/components/status-line-segment-editor.ts +361 -0
- package/src/modes/components/status-line.ts +729 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +54 -0
- package/src/modes/components/tool-execution.ts +781 -0
- package/src/modes/components/tree-selector.ts +908 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +100 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome-checks.ts +313 -0
- package/src/modes/components/welcome.ts +270 -0
- package/src/modes/controllers/btw-controller.ts +193 -0
- package/src/modes/controllers/chord-routing.ts +37 -0
- package/src/modes/controllers/command-controller.ts +1293 -0
- package/src/modes/controllers/context-command-controller.ts +61 -0
- package/src/modes/controllers/event-controller.ts +743 -0
- package/src/modes/controllers/extension-ui-controller.ts +983 -0
- package/src/modes/controllers/input-controller.ts +877 -0
- package/src/modes/controllers/mcp-command-controller.ts +1940 -0
- package/src/modes/controllers/selector-controller.ts +1292 -0
- package/src/modes/controllers/ssh-command-controller.ts +421 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +1781 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +196 -0
- package/src/modes/prompt-action-autocomplete.ts +231 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/rpc-client.ts +762 -0
- package/src/modes/rpc/rpc-mode.ts +877 -0
- package/src/modes/rpc/rpc-types.ts +322 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +30 -0
- package/src/modes/theme/defaults/index.ts +7 -0
- package/src/modes/theme/defaults/xcsh-dark.json +113 -0
- package/src/modes/theme/defaults/xcsh-light.json +115 -0
- package/src/modes/theme/mermaid-cache.ts +151 -0
- package/src/modes/theme/mermaid-palette.ts +39 -0
- package/src/modes/theme/theme-schema.json +553 -0
- package/src/modes/theme/theme.ts +2563 -0
- package/src/modes/types.ts +273 -0
- package/src/modes/utils/hotkeys-markdown.ts +60 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/read-group-outcome-aggregator.ts +55 -0
- package/src/modes/utils/sanitize-error-message.ts +60 -0
- package/src/modes/utils/tools-markdown.ts +28 -0
- package/src/modes/utils/ui-helpers.ts +734 -0
- package/src/plan-mode/approved-plan.ts +55 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +37 -0
- package/src/prompts/agents/designer.md +67 -0
- package/src/prompts/agents/explore.md +61 -0
- package/src/prompts/agents/frontmatter.md +10 -0
- package/src/prompts/agents/init.md +36 -0
- package/src/prompts/agents/librarian.md +121 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/reviewer.md +127 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +35 -0
- package/src/prompts/compaction/branch-summary-context.md +5 -0
- package/src/prompts/compaction/branch-summary-preamble.md +2 -0
- package/src/prompts/compaction/branch-summary.md +30 -0
- package/src/prompts/compaction/compaction-short-summary.md +9 -0
- package/src/prompts/compaction/compaction-summary-context.md +5 -0
- package/src/prompts/compaction/compaction-summary.md +38 -0
- package/src/prompts/compaction/compaction-turn-prefix.md +17 -0
- package/src/prompts/compaction/compaction-update-summary.md +45 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +65 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-handoff-threshold-focus.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +82 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/file-operations.md +10 -0
- package/src/prompts/system/handoff-document.md +48 -0
- package/src/prompts/system/plan-mode-active.md +114 -0
- package/src/prompts/system/plan-mode-approved.md +23 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/subagent-submit-reminder.md +7 -0
- package/src/prompts/system/subagent-system-prompt.md +36 -0
- package/src/prompts/system/subagent-user-prompt.md +12 -0
- package/src/prompts/system/summarization-system.md +3 -0
- package/src/prompts/system/system-prompt.md +698 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/web-search.md +28 -0
- package/src/prompts/tools/ask.md +28 -0
- package/src/prompts/tools/ast-edit.md +48 -0
- package/src/prompts/tools/ast-grep.md +54 -0
- package/src/prompts/tools/async-result.md +5 -0
- package/src/prompts/tools/bash.md +67 -0
- package/src/prompts/tools/browser.md +26 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/cancel-job.md +5 -0
- package/src/prompts/tools/catalog-workflow-runner.md +13 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/chunk-edit.md +279 -0
- package/src/prompts/tools/debug.md +43 -0
- package/src/prompts/tools/display-image.md +23 -0
- package/src/prompts/tools/exit-plan-mode.md +41 -0
- package/src/prompts/tools/find.md +26 -0
- package/src/prompts/tools/gemini-image.md +7 -0
- package/src/prompts/tools/grep.md +29 -0
- package/src/prompts/tools/hashline.md +131 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/lsp.md +33 -0
- package/src/prompts/tools/patch.md +77 -0
- package/src/prompts/tools/poll.md +5 -0
- package/src/prompts/tools/python.md +60 -0
- package/src/prompts/tools/read-chunk.md +35 -0
- package/src/prompts/tools/read.md +63 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +8 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +34 -0
- package/src/prompts/tools/ssh.md +44 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +131 -0
- package/src/prompts/tools/todo-write.md +89 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/prompts/tools/xcsh-api.md +283 -0
- package/src/resource-management/index.ts +42 -0
- package/src/sdk.ts +2123 -0
- package/src/secrets/index.ts +146 -0
- package/src/secrets/obfuscator.ts +290 -0
- package/src/secrets/regex.ts +21 -0
- package/src/services/context-env.ts +102 -0
- package/src/services/xcsh-api-client.ts +230 -0
- package/src/services/xcsh-context-command.ts +803 -0
- package/src/services/xcsh-context-display.ts +49 -0
- package/src/services/xcsh-context-indicators.ts +17 -0
- package/src/services/xcsh-context-segment.ts +39 -0
- package/src/services/xcsh-context.ts +1410 -0
- package/src/services/xcsh-env.ts +107 -0
- package/src/services/xcsh-knowledge.ts +177 -0
- package/src/services/xcsh-table.ts +164 -0
- package/src/session/agent-session.ts +6690 -0
- package/src/session/agent-storage.ts +451 -0
- package/src/session/artifacts.ts +132 -0
- package/src/session/auth-storage.ts +17 -0
- package/src/session/blob-store.ts +135 -0
- package/src/session/compaction/branch-summarization.ts +322 -0
- package/src/session/compaction/compaction.ts +1388 -0
- package/src/session/compaction/index.ts +7 -0
- package/src/session/compaction/pruning.ts +91 -0
- package/src/session/compaction/utils.ts +184 -0
- package/src/session/history-storage.ts +253 -0
- package/src/session/messages.ts +597 -0
- package/src/session/session-dump-format.ts +203 -0
- package/src/session/session-manager.ts +2816 -0
- package/src/session/session-storage.ts +370 -0
- package/src/session/streaming-output.ts +770 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/slash-commands/builtin-registry.ts +1614 -0
- package/src/slash-commands/export-command.ts +178 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/slash-commands/resource-commands.ts +250 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +445 -0
- package/src/ssh/ssh-executor.ts +131 -0
- package/src/ssh/sshfs-mount.ts +137 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +688 -0
- package/src/task/agents.ts +166 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +126 -0
- package/src/task/executor.ts +1324 -0
- package/src/task/index.ts +1197 -0
- package/src/task/isolation-backend.ts +72 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +107 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1035 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/template.ts +33 -0
- package/src/task/types.ts +230 -0
- package/src/task/worktree.ts +580 -0
- package/src/task/xcsh-command.ts +26 -0
- package/src/thinking.ts +87 -0
- package/src/tools/action-renderer.ts +198 -0
- package/src/tools/archive-reader.ts +315 -0
- package/src/tools/ask.ts +791 -0
- package/src/tools/ast-edit.ts +492 -0
- package/src/tools/ast-grep.ts +453 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-interactive.ts +383 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-normalize.ts +107 -0
- package/src/tools/bash-skill-urls.ts +246 -0
- package/src/tools/bash.ts +878 -0
- package/src/tools/browser-renderer.ts +129 -0
- package/src/tools/browser.ts +1366 -0
- package/src/tools/calculator.ts +543 -0
- package/src/tools/cancel-job.ts +100 -0
- package/src/tools/catalog-workflow-runner.ts +718 -0
- package/src/tools/checkpoint.ts +133 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1004 -0
- package/src/tools/display-image-renderer.ts +96 -0
- package/src/tools/display-image.ts +109 -0
- package/src/tools/exit-plan-mode.ts +101 -0
- package/src/tools/fetch.ts +1462 -0
- package/src/tools/find.ts +437 -0
- package/src/tools/fs-cache-invalidation.ts +33 -0
- package/src/tools/gemini-image.ts +1004 -0
- package/src/tools/grep.ts +705 -0
- package/src/tools/index.ts +442 -0
- package/src/tools/inspect-image-renderer.ts +101 -0
- package/src/tools/inspect-image.ts +176 -0
- package/src/tools/json-tree.ts +266 -0
- package/src/tools/jtd-to-json-schema.ts +199 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/mermaid-renderer.ts +127 -0
- package/src/tools/notebook.ts +288 -0
- package/src/tools/output-meta.ts +588 -0
- package/src/tools/path-utils.ts +560 -0
- package/src/tools/plan-mode-guard.ts +41 -0
- package/src/tools/poll-tool.ts +177 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/python.ts +1184 -0
- package/src/tools/read.ts +1591 -0
- package/src/tools/render-mermaid.ts +93 -0
- package/src/tools/render-utils.ts +677 -0
- package/src/tools/renderers.ts +82 -0
- package/src/tools/report-tool-issue.ts +80 -0
- package/src/tools/resolve.ts +196 -0
- package/src/tools/review.ts +238 -0
- package/src/tools/search-tool-bm25.ts +288 -0
- package/src/tools/sqlite-reader.ts +623 -0
- package/src/tools/ssh.ts +322 -0
- package/src/tools/submit-result.ts +229 -0
- package/src/tools/todo-render.ts +33 -0
- package/src/tools/todo-write.ts +440 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +93 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +981 -0
- package/src/tools/write.ts +671 -0
- package/src/tools/xcsh-api-renderer.ts +402 -0
- package/src/tools/xcsh-api.ts +887 -0
- package/src/tui/code-cell.ts +101 -0
- package/src/tui/file-list.ts +47 -0
- package/src/tui/index.ts +11 -0
- package/src/tui/output-block.ts +175 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +98 -0
- package/src/utils/clipboard.ts +80 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +137 -0
- package/src/utils/edit-mode.ts +50 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +37 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/git.ts +1495 -0
- package/src/utils/gitstatus.ts +140 -0
- package/src/utils/image-convert.ts +27 -0
- package/src/utils/image-loading.ts +98 -0
- package/src/utils/image-passthrough.ts +118 -0
- package/src/utils/image-resize.ts +272 -0
- package/src/utils/image-viewer.ts +17 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +81 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +55 -0
- package/src/utils/shell-snapshot.ts +188 -0
- package/src/utils/title-generator.ts +193 -0
- package/src/utils/tool-choice.ts +28 -0
- package/src/utils/tools-manager.ts +356 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2426 -0
- package/src/vim/parser.ts +151 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +174 -0
- package/src/web/parallel.ts +346 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +110 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +169 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +190 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +267 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +313 -0
- package/src/web/search/errors.ts +120 -0
- package/src/web/search/index.ts +346 -0
- package/src/web/search/params.ts +129 -0
- package/src/web/search/provider.ts +97 -0
- package/src/web/search/providers/anthropic.ts +339 -0
- package/src/web/search/providers/base.ts +35 -0
- package/src/web/search/providers/brave.ts +150 -0
- package/src/web/search/providers/codex.ts +402 -0
- package/src/web/search/providers/exa.ts +264 -0
- package/src/web/search/providers/firecrawl.ts +115 -0
- package/src/web/search/providers/gemini.ts +566 -0
- package/src/web/search/providers/jina.ts +99 -0
- package/src/web/search/providers/kagi.ts +70 -0
- package/src/web/search/providers/kimi.ts +157 -0
- package/src/web/search/providers/parallel.ts +63 -0
- package/src/web/search/providers/perplexity.ts +546 -0
- package/src/web/search/providers/synthetic.ts +113 -0
- package/src/web/search/providers/tavily.ts +162 -0
- package/src/web/search/providers/utils.ts +36 -0
- package/src/web/search/providers/zai.ts +311 -0
- package/src/web/search/render.ts +348 -0
- package/src/web/search/types.ts +438 -0
- package/src/web/search/utils.ts +17 -0
|
@@ -0,0 +1,1781 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive mode for the coding agent.
|
|
3
|
+
* Handles TUI rendering and user interaction, delegating business logic to AgentSession.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import type { Agent, AgentMessage, ThinkingLevel } from "@f5xc-salesdemos/pi-agent-core";
|
|
8
|
+
import {
|
|
9
|
+
type AssistantMessage,
|
|
10
|
+
type ImageContent,
|
|
11
|
+
type Message,
|
|
12
|
+
type Model,
|
|
13
|
+
modelsAreEqual,
|
|
14
|
+
type UsageReport,
|
|
15
|
+
} from "@f5xc-salesdemos/pi-ai";
|
|
16
|
+
import type { Component, SlashCommand } from "@f5xc-salesdemos/pi-tui";
|
|
17
|
+
import { Container, Loader, Markdown, ProcessTerminal, Spacer, Text, TUI, visibleWidth } from "@f5xc-salesdemos/pi-tui";
|
|
18
|
+
import { getProjectDir, hsvToRgb, isEnoent, logger, postmortem, prompt } from "@f5xc-salesdemos/pi-utils";
|
|
19
|
+
import chalk from "chalk";
|
|
20
|
+
import { KeybindingsManager } from "../config/keybindings";
|
|
21
|
+
import { type Settings, settings } from "../config/settings";
|
|
22
|
+
import type {
|
|
23
|
+
ExtensionUIContext,
|
|
24
|
+
ExtensionUIDialogOptions,
|
|
25
|
+
ExtensionWidgetContent,
|
|
26
|
+
ExtensionWidgetOptions,
|
|
27
|
+
} from "../extensibility/extensions";
|
|
28
|
+
import type { CompactOptions } from "../extensibility/extensions/types";
|
|
29
|
+
import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slash-commands";
|
|
30
|
+
import { resolveLocalUrlToPath } from "../internal-urls";
|
|
31
|
+
import { seedComputerProfile } from "../internal-urls/computer-profile";
|
|
32
|
+
import { reconcileFromCollectors } from "../internal-urls/user-profile";
|
|
33
|
+
import { renameApprovedPlanFile } from "../plan-mode/approved-plan";
|
|
34
|
+
import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
|
|
35
|
+
import { ContextService } from "../services/xcsh-context";
|
|
36
|
+
import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
|
|
37
|
+
import { HistoryStorage } from "../session/history-storage";
|
|
38
|
+
import type { SessionContext, SessionManager } from "../session/session-manager";
|
|
39
|
+
import { STTController, type SttState } from "../stt";
|
|
40
|
+
import type { ExitPlanModeDetails } from "../tools";
|
|
41
|
+
import type { EventBus } from "../utils/event-bus";
|
|
42
|
+
import { getEditorCommand, openInEditor } from "../utils/external-editor";
|
|
43
|
+
import { popTerminalTitle, pushTerminalTitle, setSessionTerminalTitle } from "../utils/title-generator";
|
|
44
|
+
import type { AssistantMessageComponent } from "./components/assistant-message";
|
|
45
|
+
import type { BashExecutionComponent } from "./components/bash-execution";
|
|
46
|
+
import { CustomEditor } from "./components/custom-editor";
|
|
47
|
+
import { DynamicBorder } from "./components/dynamic-border";
|
|
48
|
+
import { DisposableContainer, type GutterBlock } from "./components/gutter-block";
|
|
49
|
+
import type { HookEditorComponent } from "./components/hook-editor";
|
|
50
|
+
import type { HookInputComponent } from "./components/hook-input";
|
|
51
|
+
import type { HookSelectorComponent } from "./components/hook-selector";
|
|
52
|
+
import type { PythonExecutionComponent } from "./components/python-execution";
|
|
53
|
+
import { StatusLineComponent } from "./components/status-line";
|
|
54
|
+
import type { ToolExecutionHandle } from "./components/tool-execution";
|
|
55
|
+
import { type UpdateStatus, WelcomeComponent } from "./components/welcome";
|
|
56
|
+
import {
|
|
57
|
+
buildUnifiedPluginList,
|
|
58
|
+
type FixableService,
|
|
59
|
+
mapContextStatus,
|
|
60
|
+
runWelcomeChecks,
|
|
61
|
+
type ServiceStatus,
|
|
62
|
+
} from "./components/welcome-checks";
|
|
63
|
+
import { BtwController } from "./controllers/btw-controller";
|
|
64
|
+
import { CommandController } from "./controllers/command-controller";
|
|
65
|
+
import { EventController } from "./controllers/event-controller";
|
|
66
|
+
import { ExtensionUiController } from "./controllers/extension-ui-controller";
|
|
67
|
+
import { InputController } from "./controllers/input-controller";
|
|
68
|
+
import { MCPCommandController } from "./controllers/mcp-command-controller";
|
|
69
|
+
import { SelectorController } from "./controllers/selector-controller";
|
|
70
|
+
import { SSHCommandController } from "./controllers/ssh-command-controller";
|
|
71
|
+
import { OAuthManualInputManager } from "./oauth-manual-input";
|
|
72
|
+
import { SessionObserverRegistry } from "./session-observer-registry";
|
|
73
|
+
import { setMermaidRenderCallback } from "./theme/mermaid-cache";
|
|
74
|
+
import type { Theme } from "./theme/theme";
|
|
75
|
+
import {
|
|
76
|
+
getEditorTheme,
|
|
77
|
+
getMarkdownTheme,
|
|
78
|
+
getSymbolTheme,
|
|
79
|
+
onTerminalAppearanceChange,
|
|
80
|
+
onThemeChange,
|
|
81
|
+
theme,
|
|
82
|
+
} from "./theme/theme";
|
|
83
|
+
import type { CompactionQueuedMessage, InteractiveModeContext, SubmittedUserInput, TodoItem, TodoPhase } from "./types";
|
|
84
|
+
import { UiHelpers } from "./utils/ui-helpers";
|
|
85
|
+
|
|
86
|
+
const EDITOR_MAX_HEIGHT_MIN = 6;
|
|
87
|
+
const EDITOR_MAX_HEIGHT_MAX = 18;
|
|
88
|
+
const EDITOR_RESERVED_ROWS = 12;
|
|
89
|
+
const EDITOR_FALLBACK_ROWS = 24;
|
|
90
|
+
|
|
91
|
+
/** Options for creating an InteractiveMode instance (for future API use) */
|
|
92
|
+
export interface InteractiveModeOptions {
|
|
93
|
+
/** Providers that were migrated during startup */
|
|
94
|
+
migratedProviders?: string[];
|
|
95
|
+
/** Warning message if model fallback occurred */
|
|
96
|
+
modelFallbackMessage?: string;
|
|
97
|
+
/** Initial message to send */
|
|
98
|
+
initialMessage?: string;
|
|
99
|
+
/** Initial images to include with the message */
|
|
100
|
+
initialImages?: ImageContent[];
|
|
101
|
+
/** Additional initial messages to queue */
|
|
102
|
+
initialMessages?: string[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class InteractiveMode implements InteractiveModeContext {
|
|
106
|
+
session: AgentSession;
|
|
107
|
+
sessionManager: SessionManager;
|
|
108
|
+
settings: Settings;
|
|
109
|
+
keybindings: KeybindingsManager;
|
|
110
|
+
agent: Agent;
|
|
111
|
+
historyStorage?: HistoryStorage;
|
|
112
|
+
|
|
113
|
+
ui: TUI;
|
|
114
|
+
chatContainer: Container;
|
|
115
|
+
pendingMessagesContainer: Container;
|
|
116
|
+
statusContainer: Container;
|
|
117
|
+
todoContainer: Container;
|
|
118
|
+
btwContainer: Container;
|
|
119
|
+
editor: CustomEditor;
|
|
120
|
+
editorContainer: Container;
|
|
121
|
+
hookWidgetContainerAbove: Container;
|
|
122
|
+
hookWidgetContainerBelow: Container;
|
|
123
|
+
statusLine: StatusLineComponent;
|
|
124
|
+
|
|
125
|
+
isInitialized = false;
|
|
126
|
+
isBackgrounded = false;
|
|
127
|
+
isBashMode = false;
|
|
128
|
+
toolOutputExpanded = false;
|
|
129
|
+
todoExpanded = false;
|
|
130
|
+
planModeEnabled = false;
|
|
131
|
+
planModePaused = false;
|
|
132
|
+
planModePlanFilePath: string | undefined = undefined;
|
|
133
|
+
todoPhases: TodoPhase[] = [];
|
|
134
|
+
hideThinkingBlock = false;
|
|
135
|
+
pendingImages: ImageContent[] = [];
|
|
136
|
+
compactionQueuedMessages: CompactionQueuedMessage[] = [];
|
|
137
|
+
pendingTools = new Map<string, ToolExecutionHandle>();
|
|
138
|
+
pendingBashComponents: BashExecutionComponent[] = [];
|
|
139
|
+
bashComponent: BashExecutionComponent | undefined = undefined;
|
|
140
|
+
pendingPythonComponents: PythonExecutionComponent[] = [];
|
|
141
|
+
pythonComponent: PythonExecutionComponent | undefined = undefined;
|
|
142
|
+
isPythonMode = false;
|
|
143
|
+
streamingComponent: AssistantMessageComponent | undefined = undefined;
|
|
144
|
+
streamingAssistantGutter: GutterBlock<AssistantMessageComponent> | undefined = undefined;
|
|
145
|
+
streamingMessage: AssistantMessage | undefined = undefined;
|
|
146
|
+
loadingAnimation: Loader | undefined = undefined;
|
|
147
|
+
autoCompactionLoader: Loader | undefined = undefined;
|
|
148
|
+
retryLoader: Loader | undefined = undefined;
|
|
149
|
+
#pendingWorkingMessage: string | undefined;
|
|
150
|
+
readonly #defaultWorkingMessage = `Working… (esc to interrupt)`;
|
|
151
|
+
autoCompactionEscapeHandler?: () => void;
|
|
152
|
+
retryEscapeHandler?: () => void;
|
|
153
|
+
unsubscribe?: () => void;
|
|
154
|
+
onInputCallback?: (input: SubmittedUserInput) => void;
|
|
155
|
+
optimisticUserMessageSignature: string | undefined = undefined;
|
|
156
|
+
#pendingSubmittedInput: SubmittedUserInput | undefined;
|
|
157
|
+
lastSigintTime = 0;
|
|
158
|
+
lastEscapeTime = 0;
|
|
159
|
+
shutdownRequested = false;
|
|
160
|
+
#isShuttingDown = false;
|
|
161
|
+
hookSelector: HookSelectorComponent | undefined = undefined;
|
|
162
|
+
hookInput: HookInputComponent | undefined = undefined;
|
|
163
|
+
hookEditor: HookEditorComponent | undefined = undefined;
|
|
164
|
+
lastStatusSpacer: Spacer | undefined = undefined;
|
|
165
|
+
lastStatusText: Text | undefined = undefined;
|
|
166
|
+
fileSlashCommands: Set<string> = new Set();
|
|
167
|
+
skillCommands: Map<string, string> = new Map();
|
|
168
|
+
oauthManualInput: OAuthManualInputManager = new OAuthManualInputManager();
|
|
169
|
+
|
|
170
|
+
#pendingSlashCommands: SlashCommand[] = [];
|
|
171
|
+
#cleanupUnsubscribe?: () => void;
|
|
172
|
+
readonly #version: string;
|
|
173
|
+
readonly #initialUpdateStatus: UpdateStatus | undefined;
|
|
174
|
+
#planModePreviousTools: string[] | undefined;
|
|
175
|
+
#planModePreviousModelState: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
|
|
176
|
+
#pendingModelSwitch: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
|
|
177
|
+
#planModeHasEntered = false;
|
|
178
|
+
#planReviewContainer: Container | undefined;
|
|
179
|
+
lspServers?: import("../tools").LspStartupServerInfo[];
|
|
180
|
+
mcpManager?: import("../mcp").MCPManager;
|
|
181
|
+
readonly #toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
|
|
182
|
+
|
|
183
|
+
readonly #btwController: BtwController;
|
|
184
|
+
readonly #commandController: CommandController;
|
|
185
|
+
readonly #eventController: EventController;
|
|
186
|
+
readonly #extensionUiController: ExtensionUiController;
|
|
187
|
+
readonly #inputController: InputController;
|
|
188
|
+
readonly #selectorController: SelectorController;
|
|
189
|
+
readonly #uiHelpers: UiHelpers;
|
|
190
|
+
#sttController: STTController | undefined;
|
|
191
|
+
#voiceAnimationInterval: NodeJS.Timeout | undefined;
|
|
192
|
+
#voiceHue = 0;
|
|
193
|
+
#voicePreviousShowHardwareCursor: boolean | null = null;
|
|
194
|
+
#voicePreviousUseTerminalCursor: boolean | null = null;
|
|
195
|
+
#resizeHandler?: () => void;
|
|
196
|
+
#observerRegistry: SessionObserverRegistry;
|
|
197
|
+
#eventBus?: EventBus;
|
|
198
|
+
#eventBusUnsubscribers: Array<() => void> = [];
|
|
199
|
+
#welcomeComponent?: WelcomeComponent;
|
|
200
|
+
#currentPlugins: import("./components/welcome-checks").UnifiedPluginStatus[] = [];
|
|
201
|
+
|
|
202
|
+
constructor(
|
|
203
|
+
session: AgentSession,
|
|
204
|
+
version: string,
|
|
205
|
+
initialUpdateStatus: UpdateStatus | undefined = undefined,
|
|
206
|
+
setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
|
|
207
|
+
lspServers?: import("../tools").LspStartupServerInfo[],
|
|
208
|
+
mcpManager?: import("../mcp").MCPManager,
|
|
209
|
+
eventBus?: EventBus,
|
|
210
|
+
) {
|
|
211
|
+
this.session = session;
|
|
212
|
+
this.sessionManager = session.sessionManager;
|
|
213
|
+
this.settings = session.settings;
|
|
214
|
+
this.keybindings = KeybindingsManager.inMemory();
|
|
215
|
+
this.agent = session.agent;
|
|
216
|
+
this.#version = version;
|
|
217
|
+
this.#initialUpdateStatus = initialUpdateStatus;
|
|
218
|
+
this.#toolUiContextSetter = setToolUIContext;
|
|
219
|
+
this.lspServers = lspServers;
|
|
220
|
+
this.mcpManager = mcpManager;
|
|
221
|
+
this.#eventBus = eventBus;
|
|
222
|
+
if (eventBus) {
|
|
223
|
+
this.#eventBusUnsubscribers.push(
|
|
224
|
+
eventBus.on("cwd:changed", () => {
|
|
225
|
+
this.ui.requestRender();
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.ui = new TUI(new ProcessTerminal(), settings.get("showHardwareCursor"));
|
|
231
|
+
this.ui.setClearOnShrink(settings.get("clearOnShrink"));
|
|
232
|
+
setMermaidRenderCallback(() => this.ui.requestRender());
|
|
233
|
+
this.chatContainer = new DisposableContainer();
|
|
234
|
+
this.pendingMessagesContainer = new Container();
|
|
235
|
+
this.statusContainer = new Container();
|
|
236
|
+
this.todoContainer = new Container();
|
|
237
|
+
this.btwContainer = new Container();
|
|
238
|
+
this.editor = new CustomEditor(getEditorTheme());
|
|
239
|
+
this.editor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
|
|
240
|
+
this.editor.setAutocompleteMaxVisible(settings.get("autocompleteMaxVisible"));
|
|
241
|
+
this.editor.onAutocompleteCancel = () => {
|
|
242
|
+
this.ui.requestRender(true);
|
|
243
|
+
};
|
|
244
|
+
this.editor.onAutocompleteUpdate = () => {
|
|
245
|
+
this.ui.requestRender();
|
|
246
|
+
};
|
|
247
|
+
this.#syncEditorMaxHeight();
|
|
248
|
+
this.#resizeHandler = () => {
|
|
249
|
+
this.#syncEditorMaxHeight();
|
|
250
|
+
};
|
|
251
|
+
process.stdout.on("resize", this.#resizeHandler);
|
|
252
|
+
try {
|
|
253
|
+
this.historyStorage = HistoryStorage.open();
|
|
254
|
+
this.editor.setHistoryStorage(this.historyStorage);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
logger.warn("History storage unavailable", { error: String(error) });
|
|
257
|
+
}
|
|
258
|
+
this.hookWidgetContainerAbove = new Container();
|
|
259
|
+
this.hookWidgetContainerBelow = new Container();
|
|
260
|
+
this.editorContainer = new Container();
|
|
261
|
+
this.editorContainer.addChild(this.editor);
|
|
262
|
+
this.statusLine = new StatusLineComponent(session);
|
|
263
|
+
this.statusLine.setAutoCompactEnabled(session.autoCompactionEnabled);
|
|
264
|
+
|
|
265
|
+
this.hideThinkingBlock = settings.get("hideThinkingBlock");
|
|
266
|
+
|
|
267
|
+
const builtinCommandNames = new Set(BUILTIN_SLASH_COMMANDS.map(c => c.name));
|
|
268
|
+
const hookCommands: SlashCommand[] = (
|
|
269
|
+
this.session.extensionRunner?.getRegisteredCommands(builtinCommandNames) ?? []
|
|
270
|
+
).map(cmd => ({
|
|
271
|
+
name: cmd.name,
|
|
272
|
+
description: cmd.description ?? "(hook command)",
|
|
273
|
+
getArgumentCompletions: cmd.getArgumentCompletions,
|
|
274
|
+
}));
|
|
275
|
+
|
|
276
|
+
// Convert custom commands (TypeScript) to SlashCommand format
|
|
277
|
+
const customCommands: SlashCommand[] = this.session.customCommands.map(loaded => ({
|
|
278
|
+
name: loaded.command.name,
|
|
279
|
+
description: `${loaded.command.description} (${loaded.source})`,
|
|
280
|
+
}));
|
|
281
|
+
|
|
282
|
+
// Build skill commands from session.skills (if enabled)
|
|
283
|
+
const skillCommandList: SlashCommand[] = [];
|
|
284
|
+
if (settings.get("skills.enableSkillCommands")) {
|
|
285
|
+
for (const skill of this.session.skills) {
|
|
286
|
+
const commandName = `skill:${skill.name}`;
|
|
287
|
+
this.skillCommands.set(commandName, skill.filePath);
|
|
288
|
+
skillCommandList.push({ name: commandName, description: skill.description });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Store pending commands for init() where file commands are loaded async
|
|
293
|
+
this.#pendingSlashCommands = [...BUILTIN_SLASH_COMMANDS, ...hookCommands, ...customCommands, ...skillCommandList];
|
|
294
|
+
|
|
295
|
+
this.#uiHelpers = new UiHelpers(this);
|
|
296
|
+
this.#btwController = new BtwController(this);
|
|
297
|
+
this.#extensionUiController = new ExtensionUiController(this);
|
|
298
|
+
this.#eventController = new EventController(this);
|
|
299
|
+
this.#commandController = new CommandController(this);
|
|
300
|
+
this.#selectorController = new SelectorController(this);
|
|
301
|
+
this.#inputController = new InputController(this);
|
|
302
|
+
this.#observerRegistry = new SessionObserverRegistry();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async init(): Promise<void> {
|
|
306
|
+
if (this.isInitialized) return;
|
|
307
|
+
|
|
308
|
+
logger.time("InteractiveMode.init:keybindings");
|
|
309
|
+
this.keybindings = KeybindingsManager.create();
|
|
310
|
+
|
|
311
|
+
// Register session manager flush for signal handlers (SIGINT, SIGTERM, SIGHUP)
|
|
312
|
+
this.#cleanupUnsubscribe = postmortem.register("session-manager-flush", () => this.sessionManager.flush());
|
|
313
|
+
|
|
314
|
+
await logger.time(
|
|
315
|
+
"InteractiveMode.init:slashCommands",
|
|
316
|
+
this.refreshSlashCommandState.bind(this),
|
|
317
|
+
getProjectDir(),
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// Run blocking welcome screen status checks
|
|
321
|
+
const welcomeResult = await logger.time("InteractiveMode.init:welcomeChecks", () =>
|
|
322
|
+
runWelcomeChecks(this.session.model, this.session.modelRegistry.authStorage),
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
// Refresh user profile in background — fire and forget
|
|
326
|
+
reconcileFromCollectors().catch(err => logger.warn("Background profile refresh failed", { error: String(err) }));
|
|
327
|
+
// Refresh computer profile in background — fire and forget
|
|
328
|
+
seedComputerProfile().catch(err =>
|
|
329
|
+
logger.warn("Background computer profile refresh failed", { error: String(err) }),
|
|
330
|
+
);
|
|
331
|
+
const startupQuiet = settings.get("startup.quiet");
|
|
332
|
+
this.#welcomeComponent = undefined;
|
|
333
|
+
|
|
334
|
+
const allWarnings = [...this.session.configWarnings];
|
|
335
|
+
for (const warning of allWarnings) {
|
|
336
|
+
this.ui.addChild(new Text(theme.fg("warning", `Warning: ${warning}`), 1, 0));
|
|
337
|
+
this.ui.addChild(new Spacer(1));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// When model is not connected, the wizard will auto-launch — show a clean
|
|
341
|
+
// welcome screen without plugins or confusing provider names.
|
|
342
|
+
const needsLogin = welcomeResult.model.state === "no_provider" || welcomeResult.model.state === "auth_error";
|
|
343
|
+
const welcomeModelStatus = needsLogin
|
|
344
|
+
? { state: "no_provider" as const, provider: undefined }
|
|
345
|
+
: welcomeResult.model;
|
|
346
|
+
|
|
347
|
+
const services: ServiceStatus[] =
|
|
348
|
+
!startupQuiet && !needsLogin ? [mapContextStatus(welcomeResult.context ?? { state: "no_context" })] : [];
|
|
349
|
+
|
|
350
|
+
// Build unified plugin list from service status contributions + marketplace
|
|
351
|
+
// Skip when model is not configured — nothing works without a model.
|
|
352
|
+
const pluginContributions = this.session.extensionRunner?.getAllRegisteredServiceStatuses() ?? [];
|
|
353
|
+
const plugins =
|
|
354
|
+
!startupQuiet && !needsLogin ? await buildUnifiedPluginList(pluginContributions).catch(() => []) : [];
|
|
355
|
+
this.#currentPlugins = plugins;
|
|
356
|
+
|
|
357
|
+
const fixableServices: FixableService[] = [];
|
|
358
|
+
if (!needsLogin) {
|
|
359
|
+
for (const contribution of pluginContributions) {
|
|
360
|
+
if (contribution.fix) {
|
|
361
|
+
const plugin = plugins.find(p => p.name.toLowerCase() === contribution.name.toLowerCase());
|
|
362
|
+
if (plugin && plugin.state === "unauthenticated") {
|
|
363
|
+
fixableServices.push({
|
|
364
|
+
name: contribution.name,
|
|
365
|
+
prompt: contribution.fix.prompt,
|
|
366
|
+
command: contribution.fix.command,
|
|
367
|
+
recheck: async () => {
|
|
368
|
+
try {
|
|
369
|
+
const result = await contribution.check();
|
|
370
|
+
return { name: contribution.name, ...result };
|
|
371
|
+
} catch {
|
|
372
|
+
return { name: contribution.name, state: "unavailable" as const, hint: "recheck failed" };
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (!startupQuiet) {
|
|
382
|
+
this.#welcomeComponent = new WelcomeComponent(
|
|
383
|
+
this.#version,
|
|
384
|
+
welcomeModelStatus,
|
|
385
|
+
services,
|
|
386
|
+
this.#initialUpdateStatus,
|
|
387
|
+
plugins,
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
// Setup UI layout
|
|
391
|
+
this.ui.addChild(new Spacer(1));
|
|
392
|
+
this.ui.addChild(this.#welcomeComponent);
|
|
393
|
+
this.ui.addChild(new Spacer(1));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this.ui.addChild(this.chatContainer);
|
|
397
|
+
this.ui.addChild(this.pendingMessagesContainer);
|
|
398
|
+
this.ui.addChild(this.statusContainer);
|
|
399
|
+
this.ui.addChild(this.todoContainer);
|
|
400
|
+
this.ui.addChild(this.btwContainer);
|
|
401
|
+
this.ui.addChild(this.statusLine); // Only renders hook statuses (main status in editor border)
|
|
402
|
+
this.ui.addChild(this.hookWidgetContainerAbove);
|
|
403
|
+
this.ui.addChild(this.editorContainer);
|
|
404
|
+
this.ui.addChild(this.hookWidgetContainerBelow);
|
|
405
|
+
this.ui.setFocus(this.editor);
|
|
406
|
+
|
|
407
|
+
// Auto-launch login wizard when model provider is missing or unreachable
|
|
408
|
+
if (needsLogin) {
|
|
409
|
+
queueMicrotask(() => void this.#selectorController.showFirstRunLogin());
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
this.#inputController.setupKeyHandlers();
|
|
413
|
+
this.#inputController.setupEditorSubmitHandler();
|
|
414
|
+
|
|
415
|
+
// Wire observer registry to EventBus
|
|
416
|
+
if (this.#eventBus) {
|
|
417
|
+
this.#observerRegistry.subscribeToEventBus(this.#eventBus);
|
|
418
|
+
}
|
|
419
|
+
this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
|
|
420
|
+
this.#observerRegistry.onChange(() => {
|
|
421
|
+
this.statusLine.setSubagentCount(this.#observerRegistry.getActiveSubagentCount());
|
|
422
|
+
this.ui.requestRender();
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Load initial todos
|
|
426
|
+
await this.#loadTodoList();
|
|
427
|
+
|
|
428
|
+
// Start the UI
|
|
429
|
+
const clearScreen = settings.get("startup.clearScreen");
|
|
430
|
+
this.ui.start(clearScreen);
|
|
431
|
+
pushTerminalTitle();
|
|
432
|
+
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
|
|
433
|
+
this.#syncEditorMaxHeight();
|
|
434
|
+
this.isInitialized = true;
|
|
435
|
+
|
|
436
|
+
// Initialize hooks with TUI-based UI context
|
|
437
|
+
await this.initHooksAndCustomTools();
|
|
438
|
+
|
|
439
|
+
// Offer to fix expired cloud credentials before entering the main loop
|
|
440
|
+
if (fixableServices.length > 0) {
|
|
441
|
+
await this.#offerCredentialFixes(fixableServices, services);
|
|
442
|
+
// Clear any gibberish that accumulated in the editor during the
|
|
443
|
+
// stop/start cycles (Kitty protocol re-negotiation can leave
|
|
444
|
+
// raw escape sequences in the input buffer).
|
|
445
|
+
this.editor.setText("");
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Restore mode from session (e.g. plan mode on resume)
|
|
449
|
+
await this.#restoreModeFromSession();
|
|
450
|
+
|
|
451
|
+
// Subscribe to agent events
|
|
452
|
+
this.#subscribeToAgent();
|
|
453
|
+
|
|
454
|
+
// Set up theme file watcher
|
|
455
|
+
onThemeChange(() => {
|
|
456
|
+
this.ui.invalidate();
|
|
457
|
+
this.updateEditorBorderColor();
|
|
458
|
+
this.ui.requestRender();
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Subscribe to terminal dark/light appearance changes.
|
|
462
|
+
// The terminal queries background color via OSC 11 at startup and on
|
|
463
|
+
// Mode 2031 notifications, computing luminance to detect dark/light.
|
|
464
|
+
this.ui.terminal.onAppearanceChange(mode => {
|
|
465
|
+
onTerminalAppearanceChange(mode);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Set up git branch watcher
|
|
469
|
+
this.statusLine.watchBranch(() => {
|
|
470
|
+
this.updateEditorTopBorder();
|
|
471
|
+
this.ui.requestRender();
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
this.statusLine.onStatusChanged(() => {
|
|
475
|
+
this.updateEditorTopBorder();
|
|
476
|
+
this.ui.requestRender();
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
if (this.#eventBus) {
|
|
480
|
+
this.statusLine.watchCwd(this.#eventBus);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Initial top border update
|
|
484
|
+
this.updateEditorTopBorder();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Reload slash commands and autocomplete for the provided working directory. */
|
|
488
|
+
async refreshSlashCommandState(cwd?: string): Promise<void> {
|
|
489
|
+
const basePath = cwd ?? this.sessionManager.getCwd();
|
|
490
|
+
const fileCommands = await loadSlashCommands({ cwd: basePath });
|
|
491
|
+
this.fileSlashCommands = new Set(fileCommands.map(cmd => cmd.name));
|
|
492
|
+
const fileSlashCommands: SlashCommand[] = fileCommands.map(cmd => ({
|
|
493
|
+
name: cmd.name,
|
|
494
|
+
description: cmd.description,
|
|
495
|
+
}));
|
|
496
|
+
const autocompleteProvider = this.#inputController.createAutocompleteProvider(
|
|
497
|
+
[...this.#pendingSlashCommands, ...fileSlashCommands],
|
|
498
|
+
basePath,
|
|
499
|
+
);
|
|
500
|
+
this.editor.setAutocompleteProvider(autocompleteProvider);
|
|
501
|
+
this.session.setSlashCommands(fileCommands);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async getUserInput(): Promise<SubmittedUserInput> {
|
|
505
|
+
const { promise, resolve } = Promise.withResolvers<SubmittedUserInput>();
|
|
506
|
+
this.onInputCallback = input => {
|
|
507
|
+
this.onInputCallback = undefined;
|
|
508
|
+
resolve(input);
|
|
509
|
+
};
|
|
510
|
+
return promise;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
startPendingSubmission(input: { text: string; images?: ImageContent[] }): SubmittedUserInput {
|
|
514
|
+
const submission: SubmittedUserInput = {
|
|
515
|
+
text: input.text,
|
|
516
|
+
images: input.images,
|
|
517
|
+
cancelled: false,
|
|
518
|
+
started: false,
|
|
519
|
+
};
|
|
520
|
+
this.#pendingSubmittedInput = submission;
|
|
521
|
+
this.optimisticUserMessageSignature = `${submission.text}\u0000${submission.images?.length ?? 0}`;
|
|
522
|
+
this.addMessageToChat({
|
|
523
|
+
role: "user",
|
|
524
|
+
content: [{ type: "text", text: submission.text }, ...(submission.images ?? [])],
|
|
525
|
+
attribution: "user",
|
|
526
|
+
timestamp: Date.now(),
|
|
527
|
+
});
|
|
528
|
+
this.editor.setText("");
|
|
529
|
+
this.ensureLoadingAnimation();
|
|
530
|
+
this.ui.requestRender();
|
|
531
|
+
return submission;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
cancelPendingSubmission(): boolean {
|
|
535
|
+
const submission = this.#pendingSubmittedInput;
|
|
536
|
+
if (!submission || submission.started) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
submission.cancelled = true;
|
|
541
|
+
this.#pendingSubmittedInput = undefined;
|
|
542
|
+
this.optimisticUserMessageSignature = undefined;
|
|
543
|
+
this.#pendingWorkingMessage = undefined;
|
|
544
|
+
if (this.loadingAnimation) {
|
|
545
|
+
this.loadingAnimation.stop();
|
|
546
|
+
this.loadingAnimation = undefined;
|
|
547
|
+
this.statusContainer.clear();
|
|
548
|
+
}
|
|
549
|
+
this.pendingImages = submission.images ? [...submission.images] : [];
|
|
550
|
+
this.rebuildChatFromMessages();
|
|
551
|
+
this.editor.setText(submission.text);
|
|
552
|
+
this.updateEditorBorderColor();
|
|
553
|
+
this.ui.requestRender();
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
markPendingSubmissionStarted(input: SubmittedUserInput): boolean {
|
|
558
|
+
if (this.#pendingSubmittedInput !== input || input.cancelled) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
input.started = true;
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
finishPendingSubmission(input: SubmittedUserInput): void {
|
|
566
|
+
if (this.#pendingSubmittedInput === input) {
|
|
567
|
+
this.#pendingSubmittedInput = undefined;
|
|
568
|
+
this.#pendingWorkingMessage = undefined;
|
|
569
|
+
if (this.loadingAnimation) {
|
|
570
|
+
this.loadingAnimation.stop();
|
|
571
|
+
this.loadingAnimation = undefined;
|
|
572
|
+
this.statusContainer.clear();
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
#computeEditorMaxHeight(): number {
|
|
578
|
+
const rows = this.ui.terminal.rows;
|
|
579
|
+
const terminalRows = Number.isFinite(rows) && rows > 0 ? rows : EDITOR_FALLBACK_ROWS;
|
|
580
|
+
const maxHeight = terminalRows - EDITOR_RESERVED_ROWS;
|
|
581
|
+
return Math.max(EDITOR_MAX_HEIGHT_MIN, Math.min(EDITOR_MAX_HEIGHT_MAX, maxHeight));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
#syncEditorMaxHeight(): void {
|
|
585
|
+
this.editor.setMaxHeight(this.#computeEditorMaxHeight());
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
updateEditorBorderColor(): void {
|
|
589
|
+
if (this.isBashMode) {
|
|
590
|
+
this.editor.borderColor = theme.getBashModeBorderColor();
|
|
591
|
+
} else if (this.isPythonMode) {
|
|
592
|
+
this.editor.borderColor = theme.getPythonModeBorderColor();
|
|
593
|
+
} else {
|
|
594
|
+
this.editor.borderColor = (str: string) => theme.fg("border", str);
|
|
595
|
+
}
|
|
596
|
+
this.updateEditorTopBorder();
|
|
597
|
+
this.ui.requestRender();
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
updateEditorTopBorder(): void {
|
|
601
|
+
const availableWidth = this.editor.getTopBorderAvailableWidth(this.ui.terminal.columns);
|
|
602
|
+
const topBorder = this.statusLine.getTopBorder(availableWidth);
|
|
603
|
+
this.editor.setTopBorder(topBorder);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
rebuildChatFromMessages(): void {
|
|
607
|
+
this.chatContainer.clear();
|
|
608
|
+
const context = this.session.buildDisplaySessionContext();
|
|
609
|
+
this.renderSessionContext(context);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
#formatTodoLine(todo: TodoItem, prefix: string): string {
|
|
613
|
+
const checkbox = theme.checkbox;
|
|
614
|
+
switch (todo.status) {
|
|
615
|
+
case "completed":
|
|
616
|
+
return theme.fg("success", `${prefix}${checkbox.checked} ${chalk.strikethrough(todo.content)}`);
|
|
617
|
+
case "in_progress": {
|
|
618
|
+
const main = theme.fg("contentAccent", `${prefix}${checkbox.unchecked} ${todo.content}`);
|
|
619
|
+
if (!todo.details) return main;
|
|
620
|
+
const detailLines = todo.details.split("\n").map(line => theme.fg("dim", `${prefix} ${line}`));
|
|
621
|
+
return [main, ...detailLines].join("\n");
|
|
622
|
+
}
|
|
623
|
+
case "abandoned":
|
|
624
|
+
return theme.fg("error", `${prefix}${checkbox.unchecked} ${chalk.strikethrough(todo.content)}`);
|
|
625
|
+
default:
|
|
626
|
+
return theme.fg("dim", `${prefix}${checkbox.unchecked} ${todo.content}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
#getActivePhase(phases: TodoPhase[]): TodoPhase | undefined {
|
|
631
|
+
const nonEmpty = phases.filter(phase => phase.tasks.length > 0);
|
|
632
|
+
const active = nonEmpty.find(phase =>
|
|
633
|
+
phase.tasks.some(task => task.status === "pending" || task.status === "in_progress"),
|
|
634
|
+
);
|
|
635
|
+
return active ?? nonEmpty[nonEmpty.length - 1];
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
#renderTodoList(): void {
|
|
639
|
+
this.todoContainer.clear();
|
|
640
|
+
if (!settings.get("todo.verbose")) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const phases = this.todoPhases.filter(phase => phase.tasks.length > 0);
|
|
644
|
+
if (phases.length === 0) {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const indent = " ";
|
|
649
|
+
const hook = theme.tree.hook;
|
|
650
|
+
const lines = ["", indent + theme.bold(theme.fg("contentAccent", "Todos"))];
|
|
651
|
+
|
|
652
|
+
if (!this.todoExpanded) {
|
|
653
|
+
const activePhase = this.#getActivePhase(phases);
|
|
654
|
+
if (!activePhase) return;
|
|
655
|
+
lines.push(`${indent}${theme.fg("contentAccent", `${hook} ${activePhase.name}`)}`);
|
|
656
|
+
const visibleTasks = activePhase.tasks.slice(0, 5);
|
|
657
|
+
visibleTasks.forEach((todo, index) => {
|
|
658
|
+
const prefix = `${indent}${index === 0 ? hook : " "} `;
|
|
659
|
+
lines.push(this.#formatTodoLine(todo, prefix));
|
|
660
|
+
});
|
|
661
|
+
if (visibleTasks.length < activePhase.tasks.length) {
|
|
662
|
+
const remaining = activePhase.tasks.length - visibleTasks.length;
|
|
663
|
+
lines.push(theme.fg("muted", `${indent} ${hook} +${remaining} more`));
|
|
664
|
+
}
|
|
665
|
+
this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
for (const phase of phases) {
|
|
670
|
+
lines.push(`${indent}${theme.fg("contentAccent", `${hook} ${phase.name}`)}`);
|
|
671
|
+
phase.tasks.forEach((todo, index) => {
|
|
672
|
+
const prefix = `${indent}${index === 0 ? hook : " "} `;
|
|
673
|
+
lines.push(this.#formatTodoLine(todo, prefix));
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
async #loadTodoList(): Promise<void> {
|
|
681
|
+
this.todoPhases = this.session.getTodoPhases();
|
|
682
|
+
this.#renderTodoList();
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
async #getPlanFilePath(): Promise<string> {
|
|
686
|
+
return "local://PLAN.md";
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
#resolvePlanFilePath(planFilePath: string): string {
|
|
690
|
+
if (planFilePath.startsWith("local://")) {
|
|
691
|
+
return resolveLocalUrlToPath(planFilePath, {
|
|
692
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
693
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
return path.resolve(this.sessionManager.getCwd(), planFilePath);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
#updatePlanModeStatus(): void {
|
|
700
|
+
const status =
|
|
701
|
+
this.planModeEnabled || this.planModePaused
|
|
702
|
+
? {
|
|
703
|
+
enabled: this.planModeEnabled,
|
|
704
|
+
paused: this.planModePaused,
|
|
705
|
+
}
|
|
706
|
+
: undefined;
|
|
707
|
+
this.statusLine.setPlanModeStatus(status);
|
|
708
|
+
this.updateEditorTopBorder();
|
|
709
|
+
this.ui.requestRender();
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
async #applyPlanModeModel(): Promise<void> {
|
|
713
|
+
const resolved = this.session.resolveRoleModelWithThinking("plan");
|
|
714
|
+
if (!resolved.model) return;
|
|
715
|
+
|
|
716
|
+
const currentModel = this.session.model;
|
|
717
|
+
const sameModel = modelsAreEqual(currentModel, resolved.model);
|
|
718
|
+
const planThinkingLevel = resolved.explicitThinkingLevel ? resolved.thinkingLevel : undefined;
|
|
719
|
+
|
|
720
|
+
this.#planModePreviousModelState = currentModel
|
|
721
|
+
? { model: currentModel, thinkingLevel: this.session.thinkingLevel }
|
|
722
|
+
: undefined;
|
|
723
|
+
|
|
724
|
+
if (!sameModel) {
|
|
725
|
+
if (this.session.isStreaming) {
|
|
726
|
+
this.#pendingModelSwitch = { model: resolved.model, thinkingLevel: planThinkingLevel };
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
try {
|
|
730
|
+
await this.session.setModelTemporary(resolved.model, planThinkingLevel);
|
|
731
|
+
} catch (error) {
|
|
732
|
+
this.showWarning(
|
|
733
|
+
`Failed to switch to plan model for plan mode: ${error instanceof Error ? error.message : String(error)}`,
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
} else if (planThinkingLevel) {
|
|
737
|
+
this.session.setThinkingLevel(planThinkingLevel);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/** Apply any deferred model switch after the current stream ends. */
|
|
742
|
+
async flushPendingModelSwitch(): Promise<void> {
|
|
743
|
+
const pending = this.#pendingModelSwitch;
|
|
744
|
+
if (!pending) return;
|
|
745
|
+
this.#pendingModelSwitch = undefined;
|
|
746
|
+
try {
|
|
747
|
+
await this.session.setModelTemporary(pending.model, pending.thinkingLevel);
|
|
748
|
+
} catch (error) {
|
|
749
|
+
this.showWarning(
|
|
750
|
+
`Failed to switch model after streaming: ${error instanceof Error ? error.message : String(error)}`,
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/** Restore mode state from session entries on resume (e.g. plan mode). */
|
|
756
|
+
async #restoreModeFromSession(): Promise<void> {
|
|
757
|
+
const sessionContext = this.sessionManager.buildSessionContext();
|
|
758
|
+
if (sessionContext.mode === "plan") {
|
|
759
|
+
const planFilePath = sessionContext.modeData?.planFilePath as string | undefined;
|
|
760
|
+
await this.#enterPlanMode({ planFilePath });
|
|
761
|
+
} else if (sessionContext.mode === "plan_paused") {
|
|
762
|
+
this.planModePaused = true;
|
|
763
|
+
this.#planModeHasEntered = true;
|
|
764
|
+
this.#updatePlanModeStatus();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
async #enterPlanMode(options?: { planFilePath?: string; workflow?: "parallel" | "iterative" }): Promise<void> {
|
|
769
|
+
if (this.planModeEnabled) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
this.planModePaused = false;
|
|
774
|
+
|
|
775
|
+
const planFilePath = options?.planFilePath ?? (await this.#getPlanFilePath());
|
|
776
|
+
const previousTools = this.session.getActiveToolNames();
|
|
777
|
+
const hasExitTool = this.session.getToolByName("exit_plan_mode") !== undefined;
|
|
778
|
+
const planTools = hasExitTool ? [...previousTools, "exit_plan_mode"] : previousTools;
|
|
779
|
+
const uniquePlanTools = [...new Set(planTools)];
|
|
780
|
+
|
|
781
|
+
this.#planModePreviousTools = previousTools;
|
|
782
|
+
this.planModePlanFilePath = planFilePath;
|
|
783
|
+
this.planModeEnabled = true;
|
|
784
|
+
|
|
785
|
+
await this.session.setActiveToolsByName(uniquePlanTools);
|
|
786
|
+
this.session.setPlanModeState({
|
|
787
|
+
enabled: true,
|
|
788
|
+
planFilePath,
|
|
789
|
+
workflow: options?.workflow ?? "parallel",
|
|
790
|
+
reentry: this.#planModeHasEntered,
|
|
791
|
+
});
|
|
792
|
+
if (this.session.isStreaming) {
|
|
793
|
+
await this.session.sendPlanModeContext({ deliverAs: "steer" });
|
|
794
|
+
}
|
|
795
|
+
this.#planModeHasEntered = true;
|
|
796
|
+
await this.#applyPlanModeModel();
|
|
797
|
+
this.#updatePlanModeStatus();
|
|
798
|
+
this.sessionManager.appendModeChange("plan", { planFilePath });
|
|
799
|
+
this.showStatus(`Plan mode enabled. Plan file: ${planFilePath}`);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
async #exitPlanMode(options?: { silent?: boolean; paused?: boolean }): Promise<void> {
|
|
803
|
+
if (!this.planModeEnabled) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
const previousTools = this.#planModePreviousTools;
|
|
808
|
+
if (previousTools && previousTools.length > 0) {
|
|
809
|
+
await this.session.setActiveToolsByName(previousTools);
|
|
810
|
+
}
|
|
811
|
+
if (this.#planModePreviousModelState) {
|
|
812
|
+
const prev = this.#planModePreviousModelState;
|
|
813
|
+
if (modelsAreEqual(this.session.model, prev.model)) {
|
|
814
|
+
// Same model — only thinking level may differ. Avoid setModelTemporary()
|
|
815
|
+
// which would reset provider-side sessions (openai-responses/Codex) and
|
|
816
|
+
// break conversation continuity.
|
|
817
|
+
this.session.setThinkingLevel(prev.thinkingLevel);
|
|
818
|
+
} else if (this.session.isStreaming) {
|
|
819
|
+
this.#pendingModelSwitch = { model: prev.model, thinkingLevel: prev.thinkingLevel };
|
|
820
|
+
} else {
|
|
821
|
+
await this.session.setModelTemporary(prev.model, prev.thinkingLevel);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
this.session.setPlanModeState(undefined);
|
|
825
|
+
this.planModeEnabled = false;
|
|
826
|
+
this.planModePaused = options?.paused ?? false;
|
|
827
|
+
this.planModePlanFilePath = undefined;
|
|
828
|
+
this.#planModePreviousTools = undefined;
|
|
829
|
+
this.#planModePreviousModelState = undefined;
|
|
830
|
+
this.#updatePlanModeStatus();
|
|
831
|
+
const paused = options?.paused ?? false;
|
|
832
|
+
this.sessionManager.appendModeChange(paused ? "plan_paused" : "none");
|
|
833
|
+
if (!options?.silent) {
|
|
834
|
+
this.showStatus(paused ? "Plan mode paused." : "Plan mode disabled.");
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
async #readPlanFile(planFilePath: string): Promise<string | null> {
|
|
839
|
+
const resolvedPath = this.#resolvePlanFilePath(planFilePath);
|
|
840
|
+
try {
|
|
841
|
+
return await Bun.file(resolvedPath).text();
|
|
842
|
+
} catch (error) {
|
|
843
|
+
if (isEnoent(error)) {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
throw error;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
#renderPlanPreview(planContent: string): void {
|
|
851
|
+
const planReviewContainer = this.#planReviewContainer ?? new Container();
|
|
852
|
+
if (this.#planReviewContainer) {
|
|
853
|
+
// Re-append the preview so repeated plan-review refreshes stay adjacent to the
|
|
854
|
+
// active selector instead of updating an older off-screen preview in place.
|
|
855
|
+
this.chatContainer.removeChild(this.#planReviewContainer);
|
|
856
|
+
}
|
|
857
|
+
planReviewContainer.clear();
|
|
858
|
+
planReviewContainer.addChild(new Spacer(1));
|
|
859
|
+
planReviewContainer.addChild(new DynamicBorder());
|
|
860
|
+
planReviewContainer.addChild(new Text(theme.bold(theme.fg("contentAccent", "Plan Review")), 1, 1));
|
|
861
|
+
planReviewContainer.addChild(new Spacer(1));
|
|
862
|
+
planReviewContainer.addChild(new Markdown(planContent, 1, 1, getMarkdownTheme()));
|
|
863
|
+
planReviewContainer.addChild(new DynamicBorder());
|
|
864
|
+
this.chatContainer.addChild(planReviewContainer);
|
|
865
|
+
this.#planReviewContainer = planReviewContainer;
|
|
866
|
+
this.ui.requestRender();
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
#getEditorTerminalPath(): string | null {
|
|
870
|
+
if (process.platform === "win32") {
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
return "/dev/tty";
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
async #openEditorTerminalHandle(): Promise<fs.FileHandle | null> {
|
|
877
|
+
const terminalPath = this.#getEditorTerminalPath();
|
|
878
|
+
if (!terminalPath) {
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
881
|
+
try {
|
|
882
|
+
return await fs.open(terminalPath, "r+");
|
|
883
|
+
} catch {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
#getPlanReviewHelpText(): string {
|
|
889
|
+
const externalEditorKey = this.keybindings.getDisplayString("app.editor.external");
|
|
890
|
+
if (!externalEditorKey) {
|
|
891
|
+
return "up/down navigate enter select esc cancel";
|
|
892
|
+
}
|
|
893
|
+
return `up/down navigate enter select ${externalEditorKey.toLowerCase()} open in editor esc cancel`;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
async #openPlanInExternalEditor(planFilePath: string): Promise<void> {
|
|
897
|
+
const editorCmd = getEditorCommand();
|
|
898
|
+
if (!editorCmd) {
|
|
899
|
+
this.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
const resolvedPath = this.#resolvePlanFilePath(planFilePath);
|
|
904
|
+
let currentText: string;
|
|
905
|
+
try {
|
|
906
|
+
currentText = await Bun.file(resolvedPath).text();
|
|
907
|
+
} catch (error) {
|
|
908
|
+
if (isEnoent(error)) {
|
|
909
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
let ttyHandle: fs.FileHandle | null = null;
|
|
917
|
+
try {
|
|
918
|
+
ttyHandle = await this.#openEditorTerminalHandle();
|
|
919
|
+
this.ui.stop();
|
|
920
|
+
|
|
921
|
+
const stdio: [number | "inherit", number | "inherit", number | "inherit"] = ttyHandle
|
|
922
|
+
? [ttyHandle.fd, ttyHandle.fd, ttyHandle.fd]
|
|
923
|
+
: ["inherit", "inherit", "inherit"];
|
|
924
|
+
|
|
925
|
+
const result = await openInEditor(editorCmd, currentText, {
|
|
926
|
+
extension: path.extname(resolvedPath) || ".md",
|
|
927
|
+
stdio,
|
|
928
|
+
trimTrailingNewline: false,
|
|
929
|
+
});
|
|
930
|
+
if (result !== null) {
|
|
931
|
+
await Bun.write(resolvedPath, result);
|
|
932
|
+
this.#renderPlanPreview(result);
|
|
933
|
+
this.showStatus("Plan updated in external editor.");
|
|
934
|
+
}
|
|
935
|
+
} catch (error) {
|
|
936
|
+
this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
|
|
937
|
+
} finally {
|
|
938
|
+
if (ttyHandle) {
|
|
939
|
+
await ttyHandle.close();
|
|
940
|
+
}
|
|
941
|
+
const clearScreen = settings.get("startup.clearScreen");
|
|
942
|
+
this.ui.start(clearScreen);
|
|
943
|
+
this.ui.requestRender(true);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
async #offerCredentialFixes(fixable: FixableService[], currentServices: ServiceStatus[]): Promise<void> {
|
|
948
|
+
for (const service of fixable) {
|
|
949
|
+
const confirmed = await this.#extensionUiController.showHookConfirm(
|
|
950
|
+
`${service.name} login`,
|
|
951
|
+
`${service.prompt}. Fix now?`,
|
|
952
|
+
);
|
|
953
|
+
if (!confirmed) continue;
|
|
954
|
+
|
|
955
|
+
// Drain pending terminal input (e.g. an in-flight OSC 11 poll response)
|
|
956
|
+
// before dropping raw mode, so it is consumed here instead of echoed as
|
|
957
|
+
// gibberish by the terminal while the cooked-mode subprocess runs.
|
|
958
|
+
await this.ui.suspendForSubprocess();
|
|
959
|
+
try {
|
|
960
|
+
const proc = Bun.spawn(service.command, {
|
|
961
|
+
stdin: "inherit",
|
|
962
|
+
stdout: "inherit",
|
|
963
|
+
stderr: "inherit",
|
|
964
|
+
});
|
|
965
|
+
await proc.exited;
|
|
966
|
+
} catch (error) {
|
|
967
|
+
logger.warn(`Auto-fix for ${service.name} failed`, { error: String(error) });
|
|
968
|
+
} finally {
|
|
969
|
+
const clearScreen = settings.get("startup.clearScreen");
|
|
970
|
+
this.ui.start(clearScreen);
|
|
971
|
+
this.ui.requestRender(true);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const updated = await service.recheck();
|
|
975
|
+
const idx = currentServices.findIndex(s => s.name === service.name);
|
|
976
|
+
if (idx !== -1) {
|
|
977
|
+
currentServices[idx] = updated;
|
|
978
|
+
this.#welcomeComponent?.setServices([...currentServices]);
|
|
979
|
+
}
|
|
980
|
+
const pluginIdx = this.#currentPlugins.findIndex(p => p.name.toLowerCase() === service.name.toLowerCase());
|
|
981
|
+
if (pluginIdx !== -1) {
|
|
982
|
+
this.#currentPlugins[pluginIdx] = {
|
|
983
|
+
...this.#currentPlugins[pluginIdx],
|
|
984
|
+
state: updated.state,
|
|
985
|
+
hint: updated.hint,
|
|
986
|
+
};
|
|
987
|
+
this.#welcomeComponent?.setPlugins([...this.#currentPlugins]);
|
|
988
|
+
}
|
|
989
|
+
this.ui.requestRender();
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
async #approvePlan(
|
|
994
|
+
planContent: string,
|
|
995
|
+
options: { planFilePath: string; finalPlanFilePath: string },
|
|
996
|
+
): Promise<void> {
|
|
997
|
+
await renameApprovedPlanFile({
|
|
998
|
+
planFilePath: options.planFilePath,
|
|
999
|
+
finalPlanFilePath: options.finalPlanFilePath,
|
|
1000
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
1001
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
1002
|
+
});
|
|
1003
|
+
const previousTools = this.#planModePreviousTools ?? this.session.getActiveToolNames();
|
|
1004
|
+
await this.#exitPlanMode({ silent: true, paused: false });
|
|
1005
|
+
await this.handleClearCommand();
|
|
1006
|
+
// The new session has a fresh local:// root — persist the approved plan there
|
|
1007
|
+
// so `local://<title>.md` resolves correctly in the execution session.
|
|
1008
|
+
const newLocalPath = resolveLocalUrlToPath(options.finalPlanFilePath, {
|
|
1009
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
1010
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
1011
|
+
});
|
|
1012
|
+
await Bun.write(newLocalPath, planContent);
|
|
1013
|
+
if (previousTools.length > 0) {
|
|
1014
|
+
await this.session.setActiveToolsByName(previousTools);
|
|
1015
|
+
}
|
|
1016
|
+
this.session.setPlanReferencePath(options.finalPlanFilePath);
|
|
1017
|
+
this.session.markPlanReferenceSent();
|
|
1018
|
+
const planModePrompt = prompt.render(planModeApprovedPrompt, {
|
|
1019
|
+
planContent,
|
|
1020
|
+
finalPlanFilePath: options.finalPlanFilePath,
|
|
1021
|
+
});
|
|
1022
|
+
await this.session.prompt(planModePrompt, { synthetic: true });
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
async handlePlanModeCommand(initialPrompt?: string): Promise<void> {
|
|
1026
|
+
if (this.planModeEnabled) {
|
|
1027
|
+
const confirmed = await this.showHookConfirm(
|
|
1028
|
+
"Exit plan mode?",
|
|
1029
|
+
"This exits plan mode without approving a plan.",
|
|
1030
|
+
);
|
|
1031
|
+
if (!confirmed) return;
|
|
1032
|
+
await this.#exitPlanMode({ paused: true });
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
await this.#enterPlanMode();
|
|
1036
|
+
if (initialPrompt && this.onInputCallback) {
|
|
1037
|
+
this.onInputCallback(this.startPendingSubmission({ text: initialPrompt }));
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
async handleExitPlanModeTool(details: ExitPlanModeDetails): Promise<void> {
|
|
1042
|
+
if (!this.planModeEnabled) {
|
|
1043
|
+
this.showWarning("Plan mode is not active.");
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Abort the agent to prevent it from continuing (e.g., calling exit_plan_mode
|
|
1048
|
+
// again) while the popup is showing. The event listener fires asynchronously
|
|
1049
|
+
// (agent's #emit is fire-and-forget), so without this the model sees "Plan
|
|
1050
|
+
// ready for approval." and immediately calls exit_plan_mode in a loop.
|
|
1051
|
+
await this.session.abort();
|
|
1052
|
+
|
|
1053
|
+
const planFilePath = details.planFilePath || this.planModePlanFilePath || (await this.#getPlanFilePath());
|
|
1054
|
+
this.planModePlanFilePath = planFilePath;
|
|
1055
|
+
const planContent = await this.#readPlanFile(planFilePath);
|
|
1056
|
+
if (!planContent) {
|
|
1057
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
this.#renderPlanPreview(planContent);
|
|
1062
|
+
const choice = await this.showHookSelector(
|
|
1063
|
+
"Plan mode - next step",
|
|
1064
|
+
["Approve and execute", "Refine plan", "Stay in plan mode"],
|
|
1065
|
+
{
|
|
1066
|
+
helpText: this.#getPlanReviewHelpText(),
|
|
1067
|
+
onExternalEditor: () => void this.#openPlanInExternalEditor(planFilePath),
|
|
1068
|
+
},
|
|
1069
|
+
);
|
|
1070
|
+
|
|
1071
|
+
if (choice === "Approve and execute") {
|
|
1072
|
+
const finalPlanFilePath = details.finalPlanFilePath || planFilePath;
|
|
1073
|
+
try {
|
|
1074
|
+
const latestPlanContent = await this.#readPlanFile(planFilePath);
|
|
1075
|
+
if (!latestPlanContent) {
|
|
1076
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
await this.#approvePlan(latestPlanContent, { planFilePath, finalPlanFilePath });
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
this.showError(
|
|
1082
|
+
`Failed to finalize approved plan: ${error instanceof Error ? error.message : String(error)}`,
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (choice === "Refine plan") {
|
|
1088
|
+
const refinement = (await this.showHookInput("What should be refined?"))?.trim();
|
|
1089
|
+
if (refinement) {
|
|
1090
|
+
if (this.onInputCallback) {
|
|
1091
|
+
this.onInputCallback(this.startPendingSubmission({ text: refinement }));
|
|
1092
|
+
} else {
|
|
1093
|
+
this.editor.setText(refinement);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
stop(): void {
|
|
1100
|
+
if (this.loadingAnimation) {
|
|
1101
|
+
this.loadingAnimation.stop();
|
|
1102
|
+
this.loadingAnimation = undefined;
|
|
1103
|
+
}
|
|
1104
|
+
this.#cleanupMicAnimation();
|
|
1105
|
+
if (this.#sttController) {
|
|
1106
|
+
this.#sttController.dispose();
|
|
1107
|
+
this.#sttController = undefined;
|
|
1108
|
+
}
|
|
1109
|
+
this.#extensionUiController.clearExtensionTerminalInputListeners();
|
|
1110
|
+
this.#extensionUiController.clearHookWidgets();
|
|
1111
|
+
for (const unsubscribe of this.#eventBusUnsubscribers) {
|
|
1112
|
+
unsubscribe();
|
|
1113
|
+
}
|
|
1114
|
+
this.#eventBusUnsubscribers = [];
|
|
1115
|
+
this.#observerRegistry.dispose();
|
|
1116
|
+
this.#eventController.dispose();
|
|
1117
|
+
this.statusLine.dispose();
|
|
1118
|
+
if (this.#resizeHandler) {
|
|
1119
|
+
process.stdout.removeListener("resize", this.#resizeHandler);
|
|
1120
|
+
this.#resizeHandler = undefined;
|
|
1121
|
+
}
|
|
1122
|
+
if (this.unsubscribe) {
|
|
1123
|
+
this.unsubscribe();
|
|
1124
|
+
}
|
|
1125
|
+
if (this.#cleanupUnsubscribe) {
|
|
1126
|
+
this.#cleanupUnsubscribe();
|
|
1127
|
+
}
|
|
1128
|
+
if (this.isInitialized) {
|
|
1129
|
+
this.ui.stop();
|
|
1130
|
+
this.isInitialized = false;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
async shutdown(): Promise<void> {
|
|
1135
|
+
if (this.#isShuttingDown) return;
|
|
1136
|
+
this.#isShuttingDown = true;
|
|
1137
|
+
|
|
1138
|
+
// Flush pending session writes before shutdown
|
|
1139
|
+
await this.sessionManager.flush();
|
|
1140
|
+
this.#btwController.dispose();
|
|
1141
|
+
|
|
1142
|
+
// Emit shutdown event to hooks
|
|
1143
|
+
await this.session.dispose();
|
|
1144
|
+
|
|
1145
|
+
if (this.isInitialized) {
|
|
1146
|
+
this.ui.requestRender();
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// Wait for any pending renders to complete
|
|
1150
|
+
// requestRender() uses process.nextTick(), so we wait one tick
|
|
1151
|
+
await new Promise(resolve => process.nextTick(resolve));
|
|
1152
|
+
|
|
1153
|
+
// Drain any in-flight Kitty key release events before stopping.
|
|
1154
|
+
// This prevents escape sequences from leaking to the parent shell over slow SSH.
|
|
1155
|
+
await this.ui.terminal.drainInput(1000);
|
|
1156
|
+
popTerminalTitle();
|
|
1157
|
+
this.stop();
|
|
1158
|
+
|
|
1159
|
+
// Transient prompt: erase the 2-line textarea frame and replace with green ❯
|
|
1160
|
+
// After stop(), cursor is 1 line below frame (stop() writes \r\n).
|
|
1161
|
+
// Move up 3 (2 frame lines + 1 blank), erase to end of screen, print prompt.
|
|
1162
|
+
process.stderr.write(`\x1b[3A\x1b[0J\x1b[32m❯\x1b[0m\n`);
|
|
1163
|
+
|
|
1164
|
+
await postmortem.quit(0);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
async checkShutdownRequested(): Promise<void> {
|
|
1168
|
+
if (!this.shutdownRequested) return;
|
|
1169
|
+
await this.shutdown();
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
// Extension UI integration
|
|
1173
|
+
setToolUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void {
|
|
1174
|
+
this.#toolUiContextSetter(uiContext, hasUI);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
initializeHookRunner(uiContext: ExtensionUIContext, hasUI: boolean): void {
|
|
1178
|
+
this.#extensionUiController.initializeHookRunner(uiContext, hasUI);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
createBackgroundUiContext(): ExtensionUIContext {
|
|
1182
|
+
return this.#extensionUiController.createBackgroundUiContext();
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// Event handling
|
|
1186
|
+
async handleBackgroundEvent(event: AgentSessionEvent): Promise<void> {
|
|
1187
|
+
await this.#eventController.handleBackgroundEvent(event);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// UI helpers
|
|
1191
|
+
showStatus(message: string, options?: { dim?: boolean }): void {
|
|
1192
|
+
this.#uiHelpers.showStatus(message, options);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
showError(message: string): void {
|
|
1196
|
+
this.#pendingSubmittedInput = undefined;
|
|
1197
|
+
this.optimisticUserMessageSignature = undefined;
|
|
1198
|
+
this.#pendingWorkingMessage = undefined;
|
|
1199
|
+
if (this.loadingAnimation) {
|
|
1200
|
+
this.loadingAnimation.stop();
|
|
1201
|
+
this.loadingAnimation = undefined;
|
|
1202
|
+
this.statusContainer.clear();
|
|
1203
|
+
}
|
|
1204
|
+
this.#uiHelpers.showError(message);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
showWarning(message: string): void {
|
|
1208
|
+
this.#uiHelpers.showWarning(message);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
ensureLoadingAnimation(): void {
|
|
1212
|
+
if (!this.loadingAnimation) {
|
|
1213
|
+
this.statusContainer.clear();
|
|
1214
|
+
this.loadingAnimation = new Loader(
|
|
1215
|
+
this.ui,
|
|
1216
|
+
spinner => theme.fg("spinnerAccent", spinner),
|
|
1217
|
+
text => theme.fg("muted", text),
|
|
1218
|
+
this.#defaultWorkingMessage,
|
|
1219
|
+
getSymbolTheme().spinnerFrames,
|
|
1220
|
+
);
|
|
1221
|
+
this.statusContainer.addChild(this.loadingAnimation);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
this.applyPendingWorkingMessage();
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
setWorkingMessage(message?: string): void {
|
|
1228
|
+
if (message === undefined) {
|
|
1229
|
+
this.#pendingWorkingMessage = undefined;
|
|
1230
|
+
if (this.loadingAnimation) {
|
|
1231
|
+
this.loadingAnimation.setMessage(this.#defaultWorkingMessage);
|
|
1232
|
+
}
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
if (this.loadingAnimation) {
|
|
1237
|
+
this.loadingAnimation.setMessage(message);
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
this.#pendingWorkingMessage = message;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
applyPendingWorkingMessage(): void {
|
|
1245
|
+
if (this.#pendingWorkingMessage === undefined) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const message = this.#pendingWorkingMessage;
|
|
1250
|
+
this.#pendingWorkingMessage = undefined;
|
|
1251
|
+
this.setWorkingMessage(message);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
setUpdateStatus(status: UpdateStatus | undefined): void {
|
|
1255
|
+
this.#welcomeComponent?.setUpdateStatus(status);
|
|
1256
|
+
this.ui.requestRender();
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
clearEditor(): void {
|
|
1260
|
+
this.#uiHelpers.clearEditor();
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
updatePendingMessagesDisplay(): void {
|
|
1264
|
+
this.#uiHelpers.updatePendingMessagesDisplay();
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
queueCompactionMessage(text: string, mode: "steer" | "followUp"): void {
|
|
1268
|
+
this.#uiHelpers.queueCompactionMessage(text, mode);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
flushCompactionQueue(options?: { willRetry?: boolean }): Promise<void> {
|
|
1272
|
+
return this.#uiHelpers.flushCompactionQueue(options);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
flushPendingBashComponents(): void {
|
|
1276
|
+
this.#uiHelpers.flushPendingBashComponents();
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
isKnownSlashCommand(text: string): boolean {
|
|
1280
|
+
return this.#uiHelpers.isKnownSlashCommand(text);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
addMessageToChat(message: AgentMessage, options?: { populateHistory?: boolean }): void {
|
|
1284
|
+
this.#uiHelpers.addMessageToChat(message, options);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
renderSessionContext(
|
|
1288
|
+
sessionContext: SessionContext,
|
|
1289
|
+
options?: { updateFooter?: boolean; populateHistory?: boolean },
|
|
1290
|
+
): void {
|
|
1291
|
+
this.#uiHelpers.renderSessionContext(sessionContext, options);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
renderInitialMessages(): void {
|
|
1295
|
+
this.#uiHelpers.renderInitialMessages();
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
getUserMessageText(message: Message): string {
|
|
1299
|
+
return this.#uiHelpers.getUserMessageText(message);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
findLastAssistantMessage(): AssistantMessage | undefined {
|
|
1303
|
+
return this.#uiHelpers.findLastAssistantMessage();
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
extractAssistantText(message: AssistantMessage): string {
|
|
1307
|
+
return this.#uiHelpers.extractAssistantText(message);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// Command handling
|
|
1311
|
+
handleExportCommand(text: string): Promise<void> {
|
|
1312
|
+
return this.#commandController.handleExportCommand(text);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
handleDumpCommand() {
|
|
1316
|
+
return this.#commandController.handleDumpCommand();
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
handleDebugTranscriptCommand(): Promise<void> {
|
|
1320
|
+
return this.#commandController.handleDebugTranscriptCommand();
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
handleShareCommand(): Promise<void> {
|
|
1324
|
+
return this.#commandController.handleShareCommand();
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
handleCopyCommand(sub?: string) {
|
|
1328
|
+
return this.#commandController.handleCopyCommand(sub);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
handleSessionCommand(): Promise<void> {
|
|
1332
|
+
return this.#commandController.handleSessionCommand();
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
handleJobsCommand(): Promise<void> {
|
|
1336
|
+
return this.#commandController.handleJobsCommand();
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
handleUsageCommand(reports?: UsageReport[] | null): Promise<void> {
|
|
1340
|
+
return this.#commandController.handleUsageCommand(reports);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
async handleChangelogCommand(showFull = false): Promise<void> {
|
|
1344
|
+
await this.#commandController.handleChangelogCommand(showFull);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
handleHotkeysCommand(): void {
|
|
1348
|
+
this.#commandController.handleHotkeysCommand();
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
handleToolsCommand(): void {
|
|
1352
|
+
this.#commandController.handleToolsCommand();
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
handleClearCommand(): Promise<void> {
|
|
1356
|
+
this.#btwController.dispose();
|
|
1357
|
+
this.#extensionUiController.clearExtensionTerminalInputListeners();
|
|
1358
|
+
this.#planReviewContainer = undefined;
|
|
1359
|
+
return this.#commandController.handleClearCommand();
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
handleForkCommand(): Promise<void> {
|
|
1363
|
+
this.#btwController.dispose();
|
|
1364
|
+
return this.#commandController.handleForkCommand();
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
handleMoveCommand(targetPath: string): Promise<void> {
|
|
1368
|
+
return this.#commandController.handleMoveCommand(targetPath);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
handleRenameCommand(title: string): Promise<void> {
|
|
1372
|
+
return this.#commandController.handleRenameCommand(title);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
handleMemoryCommand(text: string): Promise<void> {
|
|
1376
|
+
return this.#commandController.handleMemoryCommand(text);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
async handleSTTToggle(): Promise<void> {
|
|
1380
|
+
if (!settings.get("stt.enabled")) {
|
|
1381
|
+
this.showWarning("Speech-to-text is disabled. Enable it in settings: stt.enabled");
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
if (!this.#sttController) {
|
|
1385
|
+
this.#sttController = new STTController();
|
|
1386
|
+
}
|
|
1387
|
+
await this.#sttController.toggle(this.editor, {
|
|
1388
|
+
showWarning: (msg: string) => this.showWarning(msg),
|
|
1389
|
+
showStatus: (msg: string) => this.showStatus(msg),
|
|
1390
|
+
onStateChange: (state: SttState) => {
|
|
1391
|
+
if (state === "recording") {
|
|
1392
|
+
this.#voicePreviousShowHardwareCursor = this.ui.getShowHardwareCursor();
|
|
1393
|
+
this.#voicePreviousUseTerminalCursor = this.editor.getUseTerminalCursor();
|
|
1394
|
+
this.ui.setShowHardwareCursor(false);
|
|
1395
|
+
this.editor.setUseTerminalCursor(false);
|
|
1396
|
+
this.#startMicAnimation();
|
|
1397
|
+
} else if (state === "transcribing") {
|
|
1398
|
+
this.#stopMicAnimation();
|
|
1399
|
+
this.#setMicCursor({ r: 200, g: 200, b: 200 });
|
|
1400
|
+
} else {
|
|
1401
|
+
this.#cleanupMicAnimation();
|
|
1402
|
+
}
|
|
1403
|
+
this.updateEditorTopBorder();
|
|
1404
|
+
this.ui.requestRender();
|
|
1405
|
+
},
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
#setMicCursor(color: { r: number; g: number; b: number }): void {
|
|
1410
|
+
this.editor.cursorOverride = `\x1b[38;2;${color.r};${color.g};${color.b}m${theme.icon.mic}\x1b[0m`;
|
|
1411
|
+
// Theme symbols can be wide (for example, 🎤), so measure the rendered override.
|
|
1412
|
+
this.editor.cursorOverrideWidth = visibleWidth(this.editor.cursorOverride);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
#updateMicIcon(): void {
|
|
1416
|
+
const { r, g, b } = hsvToRgb({ h: this.#voiceHue, s: 0.9, v: 1.0 });
|
|
1417
|
+
this.#setMicCursor({ r, g, b });
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
#startMicAnimation(): void {
|
|
1421
|
+
if (this.#voiceAnimationInterval) return;
|
|
1422
|
+
this.#voiceHue = 0;
|
|
1423
|
+
this.#updateMicIcon();
|
|
1424
|
+
this.#voiceAnimationInterval = setInterval(() => {
|
|
1425
|
+
this.#voiceHue = (this.#voiceHue + 8) % 360;
|
|
1426
|
+
this.#updateMicIcon();
|
|
1427
|
+
this.ui.requestRender();
|
|
1428
|
+
}, 60);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
#stopMicAnimation(): void {
|
|
1432
|
+
if (this.#voiceAnimationInterval) {
|
|
1433
|
+
clearInterval(this.#voiceAnimationInterval);
|
|
1434
|
+
this.#voiceAnimationInterval = undefined;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
#cleanupMicAnimation(): void {
|
|
1439
|
+
if (this.#voiceAnimationInterval) {
|
|
1440
|
+
clearInterval(this.#voiceAnimationInterval);
|
|
1441
|
+
this.#voiceAnimationInterval = undefined;
|
|
1442
|
+
}
|
|
1443
|
+
this.editor.cursorOverride = undefined;
|
|
1444
|
+
this.editor.cursorOverrideWidth = undefined;
|
|
1445
|
+
if (this.#voicePreviousShowHardwareCursor !== null) {
|
|
1446
|
+
this.ui.setShowHardwareCursor(this.#voicePreviousShowHardwareCursor);
|
|
1447
|
+
this.#voicePreviousShowHardwareCursor = null;
|
|
1448
|
+
}
|
|
1449
|
+
if (this.#voicePreviousUseTerminalCursor !== null) {
|
|
1450
|
+
this.editor.setUseTerminalCursor(this.#voicePreviousUseTerminalCursor);
|
|
1451
|
+
this.#voicePreviousUseTerminalCursor = null;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
showDebugSelector(): void {
|
|
1456
|
+
this.#selectorController.showDebugSelector();
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
showSessionObserver(): void {
|
|
1460
|
+
const sessions = this.#observerRegistry.getSessions();
|
|
1461
|
+
if (sessions.length <= 1) {
|
|
1462
|
+
this.showStatus("No active subagent sessions");
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
this.#selectorController.showSessionObserver(this.#observerRegistry);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
resetObserverRegistry(): void {
|
|
1469
|
+
this.#observerRegistry.resetSessions();
|
|
1470
|
+
this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
async refreshWelcomeAfterLogin(): Promise<void> {
|
|
1474
|
+
this.#welcomeComponent?.setModelStatus({ state: "connected", provider: "anthropic" });
|
|
1475
|
+
|
|
1476
|
+
// Validate F5 XC Context independently — call validateToken() for a live
|
|
1477
|
+
// check instead of reading cached state (which may be "unknown" if
|
|
1478
|
+
// validation hasn't run yet in this session).
|
|
1479
|
+
const services: ServiceStatus[] = [];
|
|
1480
|
+
try {
|
|
1481
|
+
const ctxService = ContextService.instance;
|
|
1482
|
+
const ctxStatus = ctxService.getStatus();
|
|
1483
|
+
if (ctxStatus.isConfigured) {
|
|
1484
|
+
const name = ctxStatus.activeContextTenant ?? ctxStatus.activeContextName ?? undefined;
|
|
1485
|
+
const result = await ctxService.validateToken({ timeoutMs: 5000 });
|
|
1486
|
+
services.push(
|
|
1487
|
+
mapContextStatus({
|
|
1488
|
+
state:
|
|
1489
|
+
result.status === "connected"
|
|
1490
|
+
? "connected"
|
|
1491
|
+
: result.status === "auth_error"
|
|
1492
|
+
? "auth_error"
|
|
1493
|
+
: "offline",
|
|
1494
|
+
name,
|
|
1495
|
+
}),
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
} catch {
|
|
1499
|
+
// ContextService not initialized — skip
|
|
1500
|
+
}
|
|
1501
|
+
this.#welcomeComponent?.setServices(services);
|
|
1502
|
+
|
|
1503
|
+
// Run plugin checks and update the welcome screen
|
|
1504
|
+
const pluginContributions = this.session.extensionRunner?.getAllRegisteredServiceStatuses() ?? [];
|
|
1505
|
+
const plugins = await buildUnifiedPluginList(pluginContributions).catch(() => []);
|
|
1506
|
+
this.#currentPlugins = plugins;
|
|
1507
|
+
this.#welcomeComponent?.setPlugins(plugins);
|
|
1508
|
+
|
|
1509
|
+
// Restore editor
|
|
1510
|
+
this.editorContainer.clear();
|
|
1511
|
+
this.editorContainer.addChild(this.editor);
|
|
1512
|
+
this.ui.setFocus(this.editor);
|
|
1513
|
+
this.ui.requestRender();
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
handleBashCommand(command: string, excludeFromContext?: boolean): Promise<void> {
|
|
1517
|
+
return this.#commandController.handleBashCommand(command, excludeFromContext);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
handlePythonCommand(code: string, excludeFromContext?: boolean): Promise<void> {
|
|
1521
|
+
return this.#commandController.handlePythonCommand(code, excludeFromContext);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
async handleMCPCommand(text: string): Promise<void> {
|
|
1525
|
+
const controller = new MCPCommandController(this);
|
|
1526
|
+
await controller.handle(text);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
async handleSSHCommand(text: string): Promise<void> {
|
|
1530
|
+
const controller = new SSHCommandController(this);
|
|
1531
|
+
await controller.handle(text);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
handleCompactCommand(customInstructions?: string): Promise<void> {
|
|
1535
|
+
return this.#commandController.handleCompactCommand(customInstructions);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
handleHandoffCommand(customInstructions?: string): Promise<void> {
|
|
1539
|
+
return this.#commandController.handleHandoffCommand(customInstructions);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
executeCompaction(customInstructionsOrOptions?: string | CompactOptions, isAuto?: boolean): Promise<void> {
|
|
1543
|
+
return this.#commandController.executeCompaction(customInstructionsOrOptions, isAuto);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
openInBrowser(urlOrPath: string): void {
|
|
1547
|
+
this.#commandController.openInBrowser(urlOrPath);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// Selector handling
|
|
1551
|
+
showSettingsSelector(): void {
|
|
1552
|
+
this.#selectorController.showSettingsSelector();
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
showHistorySearch(): void {
|
|
1556
|
+
this.#selectorController.showHistorySearch();
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
showExtensionsDashboard(): void {
|
|
1560
|
+
void this.#selectorController.showExtensionsDashboard();
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
showAgentsDashboard(): void {
|
|
1564
|
+
void this.#selectorController.showAgentsDashboard();
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
showModelSelector(options?: { temporaryOnly?: boolean }): void {
|
|
1568
|
+
this.#selectorController.showModelSelector(options);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
showPluginSelector(mode?: "install" | "uninstall"): void {
|
|
1572
|
+
void this.#selectorController.showPluginSelector(mode);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
showPluginDashboard(): void {
|
|
1576
|
+
void this.#selectorController.showPluginDashboard();
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
showUserMessageSelector(): void {
|
|
1580
|
+
this.#selectorController.showUserMessageSelector();
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
showTreeSelector(): void {
|
|
1584
|
+
this.#selectorController.showTreeSelector();
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
showSessionSelector(): void {
|
|
1588
|
+
this.#selectorController.showSessionSelector();
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
handleResumeSession(sessionPath: string): Promise<void> {
|
|
1592
|
+
this.#btwController.dispose();
|
|
1593
|
+
this.resetObserverRegistry();
|
|
1594
|
+
return this.#selectorController.handleResumeSession(sessionPath);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
handleSessionDeleteCommand(): Promise<void> {
|
|
1598
|
+
return this.#selectorController.handleSessionDeleteCommand();
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
showOAuthSelector(mode: "login" | "logout", providerId?: string): Promise<void> {
|
|
1602
|
+
return this.#selectorController.showOAuthSelector(mode, providerId);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
showHookConfirm(title: string, message: string): Promise<boolean> {
|
|
1606
|
+
return this.#extensionUiController.showHookConfirm(title, message);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// Input handling
|
|
1610
|
+
handleCtrlC(): void {
|
|
1611
|
+
this.#inputController.handleCtrlC();
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
handleCtrlD(): void {
|
|
1615
|
+
this.#inputController.handleCtrlD();
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
handleCtrlZ(): void {
|
|
1619
|
+
this.#inputController.handleCtrlZ();
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
handleDequeue(): void {
|
|
1623
|
+
this.#inputController.handleDequeue();
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
handleBackgroundCommand(): void {
|
|
1627
|
+
this.#inputController.handleBackgroundCommand();
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
handleImagePaste(): Promise<boolean> {
|
|
1631
|
+
return this.#inputController.handleImagePaste();
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
handleBtwCommand(question: string): Promise<void> {
|
|
1635
|
+
return this.#btwController.start(question);
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
hasActiveBtw(): boolean {
|
|
1639
|
+
return this.#btwController.hasActiveRequest();
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
handleBtwEscape(): boolean {
|
|
1643
|
+
return this.#btwController.handleEscape();
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
cycleThinkingLevel(): void {
|
|
1647
|
+
this.#inputController.cycleThinkingLevel();
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
cycleRoleModel(options?: { temporary?: boolean }): Promise<void> {
|
|
1651
|
+
return this.#inputController.cycleRoleModel(options);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
toggleToolOutputExpansion(): void {
|
|
1655
|
+
this.#inputController.toggleToolOutputExpansion();
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
setToolsExpanded(expanded: boolean): void {
|
|
1659
|
+
this.#inputController.setToolsExpanded(expanded);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
toggleThinkingBlockVisibility(): void {
|
|
1663
|
+
this.#inputController.toggleThinkingBlockVisibility();
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
toggleTodoExpansion(): void {
|
|
1667
|
+
this.todoExpanded = !this.todoExpanded;
|
|
1668
|
+
this.#renderTodoList();
|
|
1669
|
+
this.ui.requestRender();
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
setTodos(todos: TodoItem[] | TodoPhase[]): void {
|
|
1673
|
+
if (todos.length > 0 && "tasks" in todos[0]) {
|
|
1674
|
+
this.todoPhases = todos as TodoPhase[];
|
|
1675
|
+
} else {
|
|
1676
|
+
this.todoPhases = [
|
|
1677
|
+
{
|
|
1678
|
+
id: "default",
|
|
1679
|
+
name: "Todos",
|
|
1680
|
+
tasks: todos as TodoItem[],
|
|
1681
|
+
},
|
|
1682
|
+
];
|
|
1683
|
+
}
|
|
1684
|
+
this.#renderTodoList();
|
|
1685
|
+
this.ui.requestRender();
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
async reloadTodos(): Promise<void> {
|
|
1689
|
+
await this.#loadTodoList();
|
|
1690
|
+
this.ui.requestRender();
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
openExternalEditor(): void {
|
|
1694
|
+
this.#inputController.openExternalEditor();
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
registerExtensionShortcuts(): void {
|
|
1698
|
+
this.#inputController.registerExtensionShortcuts();
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// Hook UI methods
|
|
1702
|
+
initHooksAndCustomTools(): Promise<void> {
|
|
1703
|
+
return this.#extensionUiController.initHooksAndCustomTools();
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
emitCustomToolSessionEvent(
|
|
1707
|
+
reason: "start" | "switch" | "branch" | "tree" | "shutdown",
|
|
1708
|
+
previousSessionFile?: string,
|
|
1709
|
+
): Promise<void> {
|
|
1710
|
+
return this.#extensionUiController.emitCustomToolSessionEvent(reason, previousSessionFile);
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
setHookWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void {
|
|
1714
|
+
this.#extensionUiController.setHookWidget(key, content, options);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
setHookStatus(key: string, text: string | undefined): void {
|
|
1718
|
+
this.#extensionUiController.setHookStatus(key, text);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
showHookSelector(
|
|
1722
|
+
title: string,
|
|
1723
|
+
options: string[],
|
|
1724
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
1725
|
+
): Promise<string | undefined> {
|
|
1726
|
+
return this.#extensionUiController.showHookSelector(title, options, dialogOptions);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
hideHookSelector(): void {
|
|
1730
|
+
this.#extensionUiController.hideHookSelector();
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
showHookInput(title: string, placeholder?: string): Promise<string | undefined> {
|
|
1734
|
+
return this.#extensionUiController.showHookInput(title, placeholder);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
hideHookInput(): void {
|
|
1738
|
+
this.#extensionUiController.hideHookInput();
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
showHookEditor(
|
|
1742
|
+
title: string,
|
|
1743
|
+
prefill?: string,
|
|
1744
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
1745
|
+
editorOptions?: { promptStyle?: boolean },
|
|
1746
|
+
): Promise<string | undefined> {
|
|
1747
|
+
return this.#extensionUiController.showHookEditor(title, prefill, dialogOptions, editorOptions);
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
hideHookEditor(): void {
|
|
1751
|
+
this.#extensionUiController.hideHookEditor();
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
showHookNotify(message: string, type?: "info" | "warning" | "error"): void {
|
|
1755
|
+
this.#extensionUiController.showHookNotify(message, type);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
showHookCustom<T>(
|
|
1759
|
+
factory: (
|
|
1760
|
+
tui: TUI,
|
|
1761
|
+
theme: Theme,
|
|
1762
|
+
keybindings: KeybindingsManager,
|
|
1763
|
+
done: (result: T) => void,
|
|
1764
|
+
) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,
|
|
1765
|
+
options?: { overlay?: boolean },
|
|
1766
|
+
): Promise<T> {
|
|
1767
|
+
return this.#extensionUiController.showHookCustom(factory, options);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
showExtensionError(extensionPath: string, error: string): void {
|
|
1771
|
+
this.#extensionUiController.showExtensionError(extensionPath, error);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
showToolError(toolName: string, error: string): void {
|
|
1775
|
+
this.#extensionUiController.showToolError(toolName, error);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
#subscribeToAgent(): void {
|
|
1779
|
+
this.#eventController.subscribeToAgent();
|
|
1780
|
+
}
|
|
1781
|
+
}
|