@gajae-code/coding-agent 0.1.1
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 +8662 -0
- package/README.md +37 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +101 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +61 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +53 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +30 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +31 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/update-cli.d.ts +38 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +32 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/deep-interview.d.ts +7 -0
- package/dist/types/commands/gjc-runtime-bridge.d.ts +6 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/launch.d.ts +121 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/question.d.ts +7 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/setup.d.ts +48 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/ultragoal.d.ts +7 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +34 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/config-file.d.ts +58 -0
- package/dist/types/config/file-lock.d.ts +6 -0
- package/dist/types/config/keybindings.d.ts +334 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-registry.d.ts +390 -0
- package/dist/types/config/model-resolver.d.ts +230 -0
- package/dist/types/config/models-config-schema.d.ts +504 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +3337 -0
- package/dist/types/config/settings.d.ts +132 -0
- package/dist/types/config/skill-settings-defaults.d.ts +14 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/dap/client.d.ts +38 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/defaults/gjc-defaults.d.ts +44 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +268 -0
- package/dist/types/discovery/index.d.ts +48 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +59 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +142 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +24 -0
- package/dist/types/eval/js/executor.d.ts +28 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +83 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +61 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +21 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +45 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +41 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +1 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +44 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +226 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/runner.d.ts +134 -0
- package/dist/types/extensibility/extensions/types.d.ts +864 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +431 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +279 -0
- package/dist/types/extensibility/skills.d.ts +74 -0
- package/dist/types/extensibility/slash-commands.d.ts +48 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/gjc-runtime/goal-mode-request.d.ts +46 -0
- package/dist/types/gjc-runtime/launch-tmux.d.ts +45 -0
- package/dist/types/gjc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +204 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +85 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +68 -0
- package/dist/types/goals/state.d.ts +35 -0
- package/dist/types/goals/tools/goal-tool.d.ts +128 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +70 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +16 -0
- package/dist/types/hooks/skill-keywords.d.ts +17 -0
- package/dist/types/hooks/skill-state.d.ts +80 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/gjc-protocol.d.ts +12 -0
- package/dist/types/internal-urls/index.d.ts +20 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/local-protocol.d.ts +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +10 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +105 -0
- package/dist/types/lsp/client.d.ts +65 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +302 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +50 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +15 -0
- package/dist/types/memory-backend/types.d.ts +61 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +32 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +16 -0
- package/dist/types/modes/components/bash-execution.d.ts +29 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +47 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/eval-execution.d.ts +23 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +151 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +23 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +26 -0
- package/dist/types/modes/components/oauth-selector.d.ts +14 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/read-tool-group.d.ts +30 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +25 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +54 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +9 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +80 -0
- package/dist/types/modes/components/status-line.d.ts +80 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +53 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +7 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +34 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +36 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +35 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +46 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/index.d.ts +9 -0
- package/dist/types/modes/interactive-mode.d.ts +271 -0
- package/dist/types/modes/loop-limit.d.ts +22 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +27 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +16 -0
- package/dist/types/modes/rpc/host-uris.d.ts +38 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +249 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +17 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +586 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +9559 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +273 -0
- package/dist/types/modes/types.d.ts +278 -0
- package/dist/types/modes/utils/context-usage.d.ts +47 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +53 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
- package/dist/types/runtime-mcp/config.d.ts +75 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +43 -0
- package/dist/types/runtime-mcp/manager.d.ts +193 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +32 -0
- package/dist/types/runtime-mcp/types.d.ts +333 -0
- package/dist/types/sdk.d.ts +216 -0
- package/dist/types/secrets/index.d.ts +9 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +930 -0
- package/dist/types/session/agent-storage.d.ts +100 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +63 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +162 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +549 -0
- package/dist/types/session/session-storage.d.ts +82 -0
- package/dist/types/session/streaming-output.d.ts +185 -0
- package/dist/types/session/tool-choice-queue.d.ts +78 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +8 -0
- package/dist/types/setup/provider-onboarding.d.ts +28 -0
- package/dist/types/skill-state/active-state.d.ts +50 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +23 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
- package/dist/types/slash-commands/types.d.ts +118 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +93 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +19 -0
- package/dist/types/task/executor.d.ts +106 -0
- package/dist/types/task/gjc-command.d.ts +7 -0
- package/dist/types/task/index.d.ts +38 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/render.d.ts +22 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +295 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking.d.ts +30 -0
- package/dist/types/tool-discovery/tool-index.d.ts +112 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask.d.ts +109 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +130 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +42 -0
- package/dist/types/tools/browser/render.d.ts +50 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +114 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +61 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +356 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/hindsight-recall.d.ts +23 -0
- package/dist/types/tools/hindsight-reflect.d.ts +25 -0
- package/dist/types/tools/hindsight-retain.d.ts +29 -0
- package/dist/types/tools/image-gen.d.ts +78 -0
- package/dist/types/tools/index.d.ts +242 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +31 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +65 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +146 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +90 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/sqlite-reader.d.ts +93 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent.d.ts +58 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +20 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +11 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +10 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +31 -0
- package/dist/types/utils/tool-choice.d.ts +7 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/kagi.d.ts +23 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +84 -0
- package/dist/types/web/search/provider.d.ts +21 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +67 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +57 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +35 -0
- package/dist/types/web/search/types.d.ts +344 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +141 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/tools.ts +144 -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 +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -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 +533 -0
- package/scripts/build-binary.ts +77 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +71 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +586 -0
- package/src/async/support.ts +6 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +475 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -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 +436 -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 +244 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +56 -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 +269 -0
- package/src/cli/auth-broker-cli.ts +746 -0
- package/src/cli/auth-gateway-cli.ts +411 -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 +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/plugin-cli.ts +942 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +433 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/update-cli.ts +408 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli.ts +99 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +96 -0
- package/src/commands/auth-gateway.ts +63 -0
- package/src/commands/codex-native-hook.ts +11 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/deep-interview.ts +12 -0
- package/src/commands/gjc-runtime-bridge.ts +81 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/launch.ts +161 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/question.ts +12 -0
- package/src/commands/ralplan.ts +12 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/setup.ts +52 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/state.ts +12 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/team.ts +130 -0
- package/src/commands/ultragoal.ts +32 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +56 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +355 -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 +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -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 +64 -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 +97 -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 +49 -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 +243 -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/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/config-file.ts +232 -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 +811 -0
- package/src/config/model-registry.ts +2384 -0
- package/src/config/model-resolver.ts +1398 -0
- package/src/config/models-config-schema.ts +175 -0
- package/src/config/prompt-templates.ts +310 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +2939 -0
- package/src/config/settings.ts +919 -0
- package/src/config/skill-settings-defaults.ts +27 -0
- package/src/config.ts +212 -0
- package/src/cursor.ts +350 -0
- package/src/dap/client.ts +675 -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 +1306 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +459 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +213 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +111 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +795 -0
- package/src/defaults/gjc/skills/ralplan/SKILL.md +142 -0
- package/src/defaults/gjc/skills/team/SKILL.md +373 -0
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +176 -0
- package/src/defaults/gjc-defaults.ts +151 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/builtin.ts +932 -0
- package/src/discovery/claude-plugins.ts +387 -0
- package/src/discovery/claude.ts +313 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +330 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +964 -0
- package/src/discovery/index.ts +76 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -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/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +810 -0
- package/src/edit/file-read-cache.ts +95 -0
- package/src/edit/index.ts +528 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1103 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/notebook.ts +222 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +683 -0
- package/src/edit/streaming.ts +561 -0
- package/src/eval/backend.ts +43 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +414 -0
- package/src/eval/js/executor.ts +134 -0
- package/src/eval/js/index.ts +46 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +70 -0
- package/src/eval/js/shared/rewrite-imports.ts +416 -0
- package/src/eval/js/shared/runtime.ts +301 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +144 -0
- package/src/eval/js/worker-core.ts +146 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +602 -0
- package/src/eval/py/index.ts +58 -0
- package/src/eval/py/kernel.ts +668 -0
- package/src/eval/py/prelude.py +462 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +910 -0
- package/src/eval/py/runtime.ts +210 -0
- package/src/eval/py/tool-bridge.ts +137 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +364 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +309 -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 +164 -0
- package/src/export/html/template.css +1060 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +47 -0
- package/src/export/html/template.js +2268 -0
- package/src/export/html/template.macro.ts +25 -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 +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +245 -0
- package/src/extensibility/custom-tools/types.ts +254 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +80 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +545 -0
- package/src/extensibility/extensions/runner.ts +900 -0
- package/src/extensibility/extensions/types.ts +1259 -0
- package/src/extensibility/extensions/wrapper.ts +189 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +599 -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/legacy-pi-compat.ts +336 -0
- package/src/extensibility/plugins/loader.ts +288 -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 +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -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 +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +343 -0
- package/src/extensibility/skills.ts +391 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/gjc-runtime/goal-mode-request.ts +212 -0
- package/src/gjc-runtime/launch-tmux.ts +162 -0
- package/src/gjc-runtime/launch-worktree.ts +291 -0
- package/src/gjc-runtime/team-runtime.ts +2025 -0
- package/src/gjc-runtime/ultragoal-runtime.ts +564 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +524 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +371 -0
- package/src/hashline/anchors.ts +113 -0
- package/src/hashline/apply.ts +737 -0
- package/src/hashline/bigrams.json +649 -0
- package/src/hashline/constants.ts +25 -0
- package/src/hashline/diff-preview.ts +43 -0
- package/src/hashline/diff.ts +56 -0
- package/src/hashline/execute.ts +267 -0
- package/src/hashline/grammar.lark +21 -0
- package/src/hashline/hash.ts +173 -0
- package/src/hashline/index.ts +13 -0
- package/src/hashline/input.ts +130 -0
- package/src/hashline/parser.ts +246 -0
- package/src/hashline/prefixes.ts +101 -0
- package/src/hashline/recovery.ts +113 -0
- package/src/hashline/stream.ts +123 -0
- package/src/hashline/types.ts +68 -0
- package/src/hindsight/backend.ts +205 -0
- package/src/hindsight/bank.ts +131 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +210 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +382 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +469 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/hooks/codex-native-hooks-config.ts +143 -0
- package/src/hooks/native-skill-hook.ts +279 -0
- package/src/hooks/skill-keywords.ts +86 -0
- package/src/hooks/skill-state.ts +416 -0
- package/src/index.ts +56 -0
- package/src/internal-urls/agent-protocol.ts +129 -0
- package/src/internal-urls/artifact-protocol.ts +80 -0
- package/src/internal-urls/docs-index.generated.ts +81 -0
- package/src/internal-urls/gjc-protocol.ts +83 -0
- package/src/internal-urls/index.ts +21 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +249 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +164 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +25 -0
- package/src/internal-urls/router.ts +78 -0
- package/src/internal-urls/rule-protocol.ts +38 -0
- package/src/internal-urls/skill-protocol.ts +103 -0
- package/src/internal-urls/types.ts +110 -0
- package/src/lsp/client.ts +951 -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 +492 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/edits.ts +166 -0
- package/src/lsp/index.ts +2282 -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 +443 -0
- package/src/lsp/utils.ts +678 -0
- package/src/main.ts +961 -0
- package/src/memories/index.ts +1135 -0
- package/src/memories/storage.ts +577 -0
- package/src/memory-backend/index.ts +4 -0
- package/src/memory-backend/local-backend.ts +30 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +24 -0
- package/src/memory-backend/types.ts +79 -0
- package/src/modes/acp/acp-agent.ts +2170 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +879 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +231 -0
- package/src/modes/components/bash-execution.ts +228 -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 +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +237 -0
- package/src/modes/components/custom-message.ts +65 -0
- package/src/modes/components/diff.ts +266 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/eval-execution.ts +164 -0
- package/src/modes/components/execution-shared.ts +102 -0
- package/src/modes/components/extensions/extension-dashboard.ts +350 -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 +628 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +270 -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 +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +190 -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/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +794 -0
- package/src/modes/components/oauth-selector.ts +248 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +488 -0
- package/src/modes/components/provider-onboarding-selector.ts +88 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +267 -0
- package/src/modes/components/runtime-mcp-add-wizard.ts +1341 -0
- package/src/modes/components/session-observer-overlay.ts +839 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +175 -0
- package/src/modes/components/settings-selector.ts +635 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-hud/render.ts +47 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +105 -0
- package/src/modes/components/status-line/segments.ts +560 -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 +93 -0
- package/src/modes/components/status-line.ts +839 -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 +40 -0
- package/src/modes/components/tool-execution.ts +830 -0
- package/src/modes/components/tree-selector.ts +930 -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 +51 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +389 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1630 -0
- package/src/modes/controllers/event-controller.ts +786 -0
- package/src/modes/controllers/extension-ui-controller.ts +927 -0
- package/src/modes/controllers/input-controller.ts +858 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
- package/src/modes/controllers/selector-controller.ts +1039 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +2756 -0
- package/src/modes/loop-limit.ts +140 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +121 -0
- package/src/modes/prompt-action-autocomplete.ts +345 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-client.ts +810 -0
- package/src/modes/rpc/rpc-mode.ts +851 -0
- package/src/modes/rpc/rpc-types.ts +378 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +55 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +142 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +201 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +142 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/red-claw.json +123 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +219 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2413 -0
- package/src/modes/types.ts +313 -0
- package/src/modes/utils/context-usage.ts +335 -0
- package/src/modes/utils/hotkeys-markdown.ts +59 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +741 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +37 -0
- package/src/prompts/agents/architect.md +79 -0
- package/src/prompts/agents/critic.md +55 -0
- package/src/prompts/agents/executor.md +45 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +12 -0
- package/src/prompts/agents/init.md +34 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/planner.md +49 -0
- package/src/prompts/agents/reviewer.md +141 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/commands/orchestrate.md +49 -0
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -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 +75 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.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 +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +28 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -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/project-prompt.md +46 -0
- package/src/prompts/system/subagent-system-prompt.md +54 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +267 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +29 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +39 -0
- package/src/prompts/tools/browser.md +70 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/create-goal.md +3 -0
- package/src/prompts/tools/debug.md +33 -0
- package/src/prompts/tools/eval.md +75 -0
- package/src/prompts/tools/find.md +34 -0
- package/src/prompts/tools/get-goal.md +3 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +18 -0
- package/src/prompts/tools/hashline.md +130 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +19 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +82 -0
- package/src/prompts/tools/recall.md +5 -0
- package/src/prompts/tools/recipe.md +16 -0
- package/src/prompts/tools/reflect.md +5 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +6 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +33 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/subagent.md +21 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +79 -0
- package/src/prompts/tools/todo-write.md +50 -0
- package/src/prompts/tools/update-goal.md +3 -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/registry/agent-registry.ts +140 -0
- package/src/runtime-mcp/client.ts +482 -0
- package/src/runtime-mcp/config-writer.ts +225 -0
- package/src/runtime-mcp/config.ts +365 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
- package/src/runtime-mcp/index.ts +29 -0
- package/src/runtime-mcp/json-rpc.ts +84 -0
- package/src/runtime-mcp/loader.ts +124 -0
- package/src/runtime-mcp/manager.ts +1172 -0
- package/src/runtime-mcp/oauth-discovery.ts +349 -0
- package/src/runtime-mcp/oauth-flow.ts +407 -0
- package/src/runtime-mcp/render.ts +123 -0
- package/src/runtime-mcp/smithery-auth.ts +104 -0
- package/src/runtime-mcp/smithery-connect.ts +145 -0
- package/src/runtime-mcp/smithery-registry.ts +477 -0
- package/src/runtime-mcp/tool-bridge.ts +416 -0
- package/src/runtime-mcp/tool-cache.ts +117 -0
- package/src/runtime-mcp/transports/http.ts +477 -0
- package/src/runtime-mcp/transports/index.ts +6 -0
- package/src/runtime-mcp/transports/stdio.ts +325 -0
- package/src/runtime-mcp/types.ts +423 -0
- package/src/sdk.ts +2064 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +277 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +8794 -0
- package/src/session/agent-storage.ts +466 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +23 -0
- package/src/session/blob-store.ts +168 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/history-storage.ts +311 -0
- package/src/session/messages.ts +403 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +3333 -0
- package/src/session/session-storage.ts +389 -0
- package/src/session/streaming-output.ts +1093 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/setup/model-onboarding-guidance.ts +36 -0
- package/src/setup/provider-onboarding.ts +195 -0
- package/src/skill-state/active-state.ts +272 -0
- package/src/slash-commands/acp-builtins.ts +46 -0
- package/src/slash-commands/builtin-registry.ts +955 -0
- package/src/slash-commands/helpers/context-report.ts +39 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +91 -0
- package/src/slash-commands/types.ts +125 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -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 +581 -0
- package/src/task/agents.ts +162 -0
- package/src/task/commands.ts +135 -0
- package/src/task/discovery.ts +130 -0
- package/src/task/executor.ts +1564 -0
- package/src/task/gjc-command.ts +26 -0
- package/src/task/index.ts +1366 -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 +1136 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +315 -0
- package/src/task/worktree.ts +506 -0
- package/src/thinking.ts +87 -0
- package/src/tool-discovery/tool-index.ts +400 -0
- package/src/tools/archive-reader.ts +321 -0
- package/src/tools/ask.ts +790 -0
- package/src/tools/ast-edit.ts +542 -0
- package/src/tools/ast-grep.ts +423 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1061 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +194 -0
- package/src/tools/browser/render.ts +212 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +577 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1054 -0
- package/src/tools/browser.ts +301 -0
- package/src/tools/calculator.ts +540 -0
- package/src/tools/checkpoint.ts +134 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1014 -0
- package/src/tools/eval.ts +1101 -0
- package/src/tools/fetch.ts +1482 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +540 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3499 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +96 -0
- package/src/tools/hindsight-recall.ts +68 -0
- package/src/tools/hindsight-reflect.ts +57 -0
- package/src/tools/hindsight-retain.ts +56 -0
- package/src/tools/image-gen.ts +1248 -0
- package/src/tools/index.ts +519 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +165 -0
- package/src/tools/irc.ts +239 -0
- package/src/tools/job.ts +520 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -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/match-line-format.ts +22 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/path-utils.ts +739 -0
- package/src/tools/plan-mode-guard.ts +68 -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/read.ts +2332 -0
- package/src/tools/recipe/index.ts +80 -0
- package/src/tools/recipe/render.ts +19 -0
- package/src/tools/recipe/runner.ts +219 -0
- package/src/tools/recipe/runners/cargo.ts +131 -0
- package/src/tools/recipe/runners/index.ts +8 -0
- package/src/tools/recipe/runners/just.ts +73 -0
- package/src/tools/recipe/runners/make.ts +101 -0
- package/src/tools/recipe/runners/pkg.ts +167 -0
- package/src/tools/recipe/runners/task.ts +72 -0
- package/src/tools/render-mermaid.ts +68 -0
- package/src/tools/render-utils.ts +774 -0
- package/src/tools/renderers.ts +75 -0
- package/src/tools/resolve.ts +258 -0
- package/src/tools/review.ts +252 -0
- package/src/tools/search-tool-bm25.ts +360 -0
- package/src/tools/search.ts +786 -0
- package/src/tools/sqlite-reader.ts +736 -0
- package/src/tools/ssh.ts +310 -0
- package/src/tools/subagent.ts +312 -0
- package/src/tools/todo-write.ts +695 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +949 -0
- package/src/tools/write.ts +953 -0
- package/src/tools/yield.ts +268 -0
- package/src/tui/code-cell.ts +201 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +126 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +150 -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 +156 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +142 -0
- package/src/utils/edit-mode.ts +42 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/git.ts +1536 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +43 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +223 -0
- package/src/utils/tool-choice.ts +33 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2409 -0
- package/src/vim/parser.ts +134 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +183 -0
- package/src/web/parallel.ts +349 -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 +97 -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 +173 -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 +189 -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 +318 -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 +319 -0
- package/src/web/search/index.ts +288 -0
- package/src/web/search/provider.ts +173 -0
- package/src/web/search/providers/anthropic.ts +302 -0
- package/src/web/search/providers/base.ts +71 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +556 -0
- package/src/web/search/providers/exa.ts +193 -0
- package/src/web/search/providers/gemini.ts +455 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +75 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +575 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +108 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +436 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,1934 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Command Controller
|
|
3
|
+
*
|
|
4
|
+
* Handles /mcp subcommands for managing MCP servers.
|
|
5
|
+
*/
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { Spacer, Text } from "@gajae-code/tui";
|
|
8
|
+
import { getMCPConfigPath, getProjectDir } from "@gajae-code/utils";
|
|
9
|
+
import type { SourceMeta } from "../../capability/types";
|
|
10
|
+
import { analyzeAuthError, discoverOAuthEndpoints, MCPManager } from "../../runtime-mcp";
|
|
11
|
+
import { connectToServer, disconnectServer, listTools } from "../../runtime-mcp/client";
|
|
12
|
+
import {
|
|
13
|
+
addMCPServer,
|
|
14
|
+
readDisabledServers,
|
|
15
|
+
readMCPConfigFile,
|
|
16
|
+
removeMCPServer,
|
|
17
|
+
setServerDisabled,
|
|
18
|
+
updateMCPServer,
|
|
19
|
+
} from "../../runtime-mcp/config-writer";
|
|
20
|
+
import { MCPOAuthFlow } from "../../runtime-mcp/oauth-flow";
|
|
21
|
+
import {
|
|
22
|
+
clearSmitheryApiKey,
|
|
23
|
+
createSmitheryCliAuthSession,
|
|
24
|
+
getSmitheryApiKey,
|
|
25
|
+
getSmitheryLoginUrl,
|
|
26
|
+
pollSmitheryCliAuthSession,
|
|
27
|
+
saveSmitheryApiKey,
|
|
28
|
+
} from "../../runtime-mcp/smithery-auth";
|
|
29
|
+
import { SmitheryConnectError } from "../../runtime-mcp/smithery-connect";
|
|
30
|
+
import {
|
|
31
|
+
SmitheryRegistryError,
|
|
32
|
+
type SmitherySearchResult,
|
|
33
|
+
searchSmitheryRegistry,
|
|
34
|
+
toConfigName,
|
|
35
|
+
} from "../../runtime-mcp/smithery-registry";
|
|
36
|
+
import type { MCPAuthConfig, MCPServerConfig, MCPServerConnection } from "../../runtime-mcp/types";
|
|
37
|
+
import type { OAuthCredential } from "../../session/auth-storage";
|
|
38
|
+
import { shortenPath } from "../../tools/render-utils";
|
|
39
|
+
import { openPath } from "../../utils/open";
|
|
40
|
+
import { MCPAddWizard } from "../components/runtime-mcp-add-wizard";
|
|
41
|
+
import { parseCommandArgs } from "../shared";
|
|
42
|
+
import { theme } from "../theme/theme";
|
|
43
|
+
import type { InteractiveModeContext } from "../types";
|
|
44
|
+
import { groupBySource, parseRemoveArgs, readScopeFlag, showCommandMessage } from "./command-controller-shared";
|
|
45
|
+
|
|
46
|
+
function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> {
|
|
47
|
+
const { promise: timeoutPromise, reject } = Promise.withResolvers<T>();
|
|
48
|
+
const timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
49
|
+
return Promise.race([promise, timeoutPromise]).finally(() => clearTimeout(timer));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Outcome of {@link MCPCommandController}'s OAuth handler.
|
|
54
|
+
*
|
|
55
|
+
* `clientId`/`clientSecret` are populated when the OAuth provider required (or
|
|
56
|
+
* accepted) dynamic client registration; callers MUST persist them alongside
|
|
57
|
+
* `credentialId` so subsequent token refreshes and reauthorizations can reuse
|
|
58
|
+
* the same registered client. Both are also set when the caller pre-supplied a
|
|
59
|
+
* client id via the wizard or `oauth.clientId` in `mcp.json`, in which case the
|
|
60
|
+
* write-back is a no-op.
|
|
61
|
+
*/
|
|
62
|
+
interface OAuthFlowResult {
|
|
63
|
+
credentialId: string;
|
|
64
|
+
clientId?: string;
|
|
65
|
+
clientSecret?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type MCPAddScope = "user" | "project";
|
|
69
|
+
type MCPAddTransport = "http" | "sse";
|
|
70
|
+
|
|
71
|
+
type MCPAddParsed = {
|
|
72
|
+
initialName?: string;
|
|
73
|
+
scope: MCPAddScope;
|
|
74
|
+
quickConfig?: MCPServerConfig;
|
|
75
|
+
isCommandQuickAdd?: boolean;
|
|
76
|
+
hasAuthToken?: boolean;
|
|
77
|
+
error?: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type MCPSearchParsed = {
|
|
81
|
+
keyword: string;
|
|
82
|
+
scope: MCPAddScope;
|
|
83
|
+
limit: number;
|
|
84
|
+
semantic: boolean;
|
|
85
|
+
error?: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export class MCPCommandController {
|
|
89
|
+
constructor(private ctx: InteractiveModeContext) {}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Handle /mcp command and route to subcommands
|
|
93
|
+
*/
|
|
94
|
+
async handle(text: string): Promise<void> {
|
|
95
|
+
const parts = text.trim().split(/\s+/);
|
|
96
|
+
const subcommand = parts[1]?.toLowerCase();
|
|
97
|
+
|
|
98
|
+
if (!subcommand || subcommand === "help") {
|
|
99
|
+
this.#showHelp();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
switch (subcommand) {
|
|
104
|
+
case "add":
|
|
105
|
+
await this.#handleAdd(text);
|
|
106
|
+
break;
|
|
107
|
+
case "list":
|
|
108
|
+
await this.#handleList();
|
|
109
|
+
break;
|
|
110
|
+
case "remove":
|
|
111
|
+
case "rm":
|
|
112
|
+
await this.#handleRemove(text);
|
|
113
|
+
break;
|
|
114
|
+
case "test":
|
|
115
|
+
await this.#handleTest(parts[2]);
|
|
116
|
+
break;
|
|
117
|
+
case "reauth":
|
|
118
|
+
await this.#handleReauth(parts[2]);
|
|
119
|
+
break;
|
|
120
|
+
case "unauth":
|
|
121
|
+
await this.#handleUnauth(parts[2]);
|
|
122
|
+
break;
|
|
123
|
+
case "enable":
|
|
124
|
+
await this.#handleSetEnabled(parts[2], true);
|
|
125
|
+
break;
|
|
126
|
+
case "disable":
|
|
127
|
+
await this.#handleSetEnabled(parts[2], false);
|
|
128
|
+
break;
|
|
129
|
+
case "resources":
|
|
130
|
+
await this.#handleResources();
|
|
131
|
+
break;
|
|
132
|
+
case "prompts":
|
|
133
|
+
await this.#handlePrompts();
|
|
134
|
+
break;
|
|
135
|
+
case "notifications":
|
|
136
|
+
await this.#handleNotifications();
|
|
137
|
+
break;
|
|
138
|
+
case "smithery-search":
|
|
139
|
+
await this.#handleSearch(text);
|
|
140
|
+
break;
|
|
141
|
+
case "smithery-login":
|
|
142
|
+
await this.#handleSmitheryLogin();
|
|
143
|
+
break;
|
|
144
|
+
case "smithery-logout":
|
|
145
|
+
await this.#handleSmitheryLogout();
|
|
146
|
+
break;
|
|
147
|
+
case "reconnect":
|
|
148
|
+
await this.#handleReconnect(parts[2]);
|
|
149
|
+
break;
|
|
150
|
+
case "reload":
|
|
151
|
+
await this.#handleReload();
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
this.ctx.showError(`Unknown subcommand: ${subcommand}. Type /mcp help for usage.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Show help text
|
|
160
|
+
*/
|
|
161
|
+
#showHelp(): void {
|
|
162
|
+
const helpText = [
|
|
163
|
+
"",
|
|
164
|
+
theme.bold("MCP Server Management"),
|
|
165
|
+
"",
|
|
166
|
+
"Manage Model Context Protocol (MCP) servers for external tool integrations.",
|
|
167
|
+
"",
|
|
168
|
+
theme.fg("accent", "Commands:"),
|
|
169
|
+
" /mcp add Add a new MCP server (interactive wizard)",
|
|
170
|
+
" /mcp add <name> [--scope project|user] [--url <url> --transport http|sse] [--token <token>] [-- <command...>]",
|
|
171
|
+
" /mcp list List all configured MCP servers",
|
|
172
|
+
" /mcp remove <name> [--scope project|user] Remove an MCP server (default: project)",
|
|
173
|
+
" /mcp test <name> Test connection to an MCP server",
|
|
174
|
+
" /mcp reauth <name> Reauthorize OAuth for an MCP server",
|
|
175
|
+
" /mcp unauth <name> Remove OAuth auth from an MCP server",
|
|
176
|
+
" /mcp enable <name> Enable an MCP server",
|
|
177
|
+
" /mcp disable <name> Disable an MCP server",
|
|
178
|
+
" /mcp smithery-search <keyword> [--scope project|user] [--limit <1-100>] [--semantic]",
|
|
179
|
+
" Search Smithery registry and deploy from picker",
|
|
180
|
+
" /mcp smithery-login Login to Smithery and cache API key",
|
|
181
|
+
" /mcp smithery-logout Remove cached Smithery API key",
|
|
182
|
+
" /mcp reconnect <name> Reconnect to a specific MCP server",
|
|
183
|
+
" /mcp reload Force reload and rediscover MCP runtime tools",
|
|
184
|
+
" /mcp resources List available resources from connected servers",
|
|
185
|
+
" /mcp prompts List available prompts from connected servers",
|
|
186
|
+
" /mcp notifications Show notification capabilities and subscription state",
|
|
187
|
+
" /mcp help Show this help message",
|
|
188
|
+
"",
|
|
189
|
+
].join("\n");
|
|
190
|
+
|
|
191
|
+
this.#showMessage(helpText);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#parseAddCommand(text: string): MCPAddParsed {
|
|
195
|
+
const prefixMatch = text.match(/^\/mcp\s+add\b\s*(.*)$/i);
|
|
196
|
+
const rest = prefixMatch?.[1]?.trim() ?? "";
|
|
197
|
+
if (!rest) {
|
|
198
|
+
return { scope: "project" };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const tokens = parseCommandArgs(rest);
|
|
202
|
+
if (tokens.length === 0) {
|
|
203
|
+
return { scope: "project" };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let name: string | undefined;
|
|
207
|
+
let scope: MCPAddScope = "project";
|
|
208
|
+
let url: string | undefined;
|
|
209
|
+
let transport: MCPAddTransport = "http";
|
|
210
|
+
let authToken: string | undefined;
|
|
211
|
+
let commandTokens: string[] | undefined;
|
|
212
|
+
|
|
213
|
+
let i = 0;
|
|
214
|
+
if (!tokens[0].startsWith("-")) {
|
|
215
|
+
name = tokens[0];
|
|
216
|
+
i = 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
while (i < tokens.length) {
|
|
220
|
+
const argToken = tokens[i];
|
|
221
|
+
if (argToken === "--") {
|
|
222
|
+
commandTokens = tokens.slice(i + 1);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (argToken === "--scope") {
|
|
226
|
+
const r = readScopeFlag(tokens[i + 1]);
|
|
227
|
+
if (!r.ok) {
|
|
228
|
+
return { scope, error: r.error };
|
|
229
|
+
}
|
|
230
|
+
scope = r.scope;
|
|
231
|
+
i += 2;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (argToken === "--url") {
|
|
235
|
+
const value = tokens[i + 1];
|
|
236
|
+
if (!value) {
|
|
237
|
+
return { scope, error: "Missing value for --url." };
|
|
238
|
+
}
|
|
239
|
+
url = value;
|
|
240
|
+
i += 2;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (argToken === "--transport") {
|
|
244
|
+
const value = tokens[i + 1];
|
|
245
|
+
if (!value || (value !== "http" && value !== "sse")) {
|
|
246
|
+
return { scope, error: "Invalid --transport value. Use http or sse." };
|
|
247
|
+
}
|
|
248
|
+
transport = value;
|
|
249
|
+
i += 2;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (argToken === "--token") {
|
|
253
|
+
const value = tokens[i + 1];
|
|
254
|
+
if (!value) {
|
|
255
|
+
return { scope, error: "Missing value for --token." };
|
|
256
|
+
}
|
|
257
|
+
authToken = value;
|
|
258
|
+
i += 2;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
return { scope, error: `Unknown option: ${argToken}` };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const hasQuick = Boolean(url) || Boolean(commandTokens && commandTokens.length > 0);
|
|
265
|
+
if (!hasQuick) {
|
|
266
|
+
return { scope, initialName: name };
|
|
267
|
+
}
|
|
268
|
+
if (!name) {
|
|
269
|
+
return { scope, error: "Server name required for quick add. Usage: /mcp add <name> ..." };
|
|
270
|
+
}
|
|
271
|
+
if (url && commandTokens && commandTokens.length > 0) {
|
|
272
|
+
return { scope, error: "Use either --url or -- <command...>, not both." };
|
|
273
|
+
}
|
|
274
|
+
if (authToken && !url) {
|
|
275
|
+
return { scope, error: "--token requires --url (HTTP/SSE transport)." };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (commandTokens && commandTokens.length > 0) {
|
|
279
|
+
const [command, ...args] = commandTokens;
|
|
280
|
+
const config: MCPServerConfig = {
|
|
281
|
+
type: "stdio",
|
|
282
|
+
command,
|
|
283
|
+
args: args.length > 0 ? args : undefined,
|
|
284
|
+
};
|
|
285
|
+
return { scope, initialName: name, quickConfig: config, isCommandQuickAdd: true };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const useHttpTransport = transport === "http";
|
|
289
|
+
let normalizedUrl = url!;
|
|
290
|
+
if (!/^https?:\/\//i.test(normalizedUrl)) {
|
|
291
|
+
normalizedUrl = `https://${normalizedUrl}`;
|
|
292
|
+
}
|
|
293
|
+
const config: MCPServerConfig = {
|
|
294
|
+
type: useHttpTransport ? "http" : "sse",
|
|
295
|
+
url: normalizedUrl,
|
|
296
|
+
headers: authToken ? { Authorization: `Bearer ${authToken}` } : undefined,
|
|
297
|
+
};
|
|
298
|
+
return {
|
|
299
|
+
scope,
|
|
300
|
+
initialName: name,
|
|
301
|
+
quickConfig: config,
|
|
302
|
+
isCommandQuickAdd: false,
|
|
303
|
+
hasAuthToken: Boolean(authToken),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
#parseSearchCommand(text: string): MCPSearchParsed {
|
|
308
|
+
const prefixMatch = text.match(/^\/mcp\s+smithery-search\b\s*(.*)$/i);
|
|
309
|
+
const rest = prefixMatch?.[1]?.trim() ?? "";
|
|
310
|
+
const tokens = parseCommandArgs(rest);
|
|
311
|
+
if (tokens.length === 0) {
|
|
312
|
+
return {
|
|
313
|
+
keyword: "",
|
|
314
|
+
scope: "project",
|
|
315
|
+
limit: 20,
|
|
316
|
+
semantic: false,
|
|
317
|
+
error: "Keyword required. Usage: /mcp smithery-search <keyword> [--scope project|user] [--limit <1-100>] [--semantic]",
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const keywordParts: string[] = [];
|
|
322
|
+
let scope: MCPAddScope = "project";
|
|
323
|
+
let limit = 20;
|
|
324
|
+
let semantic = false;
|
|
325
|
+
|
|
326
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
327
|
+
const token = tokens[i];
|
|
328
|
+
if (token === "--scope") {
|
|
329
|
+
const value = tokens[i + 1];
|
|
330
|
+
if (!value || (value !== "project" && value !== "user")) {
|
|
331
|
+
return { keyword: "", scope, limit, semantic, error: "Invalid --scope value. Use project or user." };
|
|
332
|
+
}
|
|
333
|
+
scope = value;
|
|
334
|
+
i++;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (token === "--limit") {
|
|
338
|
+
const value = tokens[i + 1];
|
|
339
|
+
if (!value) {
|
|
340
|
+
return { keyword: "", scope, limit, semantic, error: "Missing value for --limit." };
|
|
341
|
+
}
|
|
342
|
+
const parsed = Number(value);
|
|
343
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100) {
|
|
344
|
+
return {
|
|
345
|
+
keyword: "",
|
|
346
|
+
scope,
|
|
347
|
+
limit,
|
|
348
|
+
semantic,
|
|
349
|
+
error: "Invalid --limit value. Use an integer between 1 and 100.",
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
limit = parsed;
|
|
353
|
+
i++;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (token === "--semantic") {
|
|
357
|
+
semantic = true;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (token.startsWith("--")) {
|
|
361
|
+
return { keyword: "", scope, limit, semantic, error: `Unknown option: ${token}` };
|
|
362
|
+
}
|
|
363
|
+
keywordParts.push(token);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const keyword = keywordParts.join(" ").trim();
|
|
367
|
+
if (!keyword) {
|
|
368
|
+
return {
|
|
369
|
+
keyword: "",
|
|
370
|
+
scope,
|
|
371
|
+
limit,
|
|
372
|
+
semantic,
|
|
373
|
+
error: "Keyword required. Usage: /mcp smithery-search <keyword> [--scope project|user] [--limit <1-100>] [--semantic]",
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return { keyword, scope, limit, semantic };
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Handle /mcp add - Launch interactive wizard or quick-add from args
|
|
382
|
+
*/
|
|
383
|
+
async #handleAdd(text: string): Promise<void> {
|
|
384
|
+
const parsed = this.#parseAddCommand(text);
|
|
385
|
+
if (parsed.error) {
|
|
386
|
+
this.ctx.showError(parsed.error);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (parsed.quickConfig && parsed.initialName) {
|
|
390
|
+
let finalConfig = parsed.quickConfig;
|
|
391
|
+
|
|
392
|
+
// Quick-add with URL should still perform auth detection and OAuth flow,
|
|
393
|
+
// matching wizard behavior. Command quick-add intentionally skips this.
|
|
394
|
+
if (!parsed.isCommandQuickAdd && (finalConfig.type === "http" || finalConfig.type === "sse")) {
|
|
395
|
+
try {
|
|
396
|
+
await this.#handleTestConnection(finalConfig);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
if (parsed.hasAuthToken) {
|
|
399
|
+
this.ctx.showError(
|
|
400
|
+
`Authentication failed for "${parsed.initialName}": ${error instanceof Error ? error.message : String(error)}`,
|
|
401
|
+
);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const authResult = analyzeAuthError(error as Error);
|
|
405
|
+
if (authResult.requiresAuth) {
|
|
406
|
+
let oauth = authResult.authType === "oauth" ? (authResult.oauth ?? null) : null;
|
|
407
|
+
if (!oauth && finalConfig.url) {
|
|
408
|
+
try {
|
|
409
|
+
oauth = await discoverOAuthEndpoints(finalConfig.url, authResult.authServerUrl);
|
|
410
|
+
} catch {
|
|
411
|
+
// Ignore discovery error and handle below.
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (!oauth) {
|
|
416
|
+
this.ctx.showError(
|
|
417
|
+
`Authentication required for "${parsed.initialName}", but OAuth endpoints could not be discovered. ` +
|
|
418
|
+
`Use /mcp add ${parsed.initialName} (wizard) or configure auth manually.`,
|
|
419
|
+
);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
try {
|
|
424
|
+
const oauthClientSecret = finalConfig.oauth?.clientSecret ?? "";
|
|
425
|
+
const oauthResult = await this.#handleOAuthFlow(
|
|
426
|
+
oauth.authorizationUrl,
|
|
427
|
+
oauth.tokenUrl,
|
|
428
|
+
oauth.clientId ?? finalConfig.oauth?.clientId ?? "",
|
|
429
|
+
oauthClientSecret,
|
|
430
|
+
oauth.scopes ?? "",
|
|
431
|
+
finalConfig.oauth?.callbackPort,
|
|
432
|
+
finalConfig.oauth?.callbackPath,
|
|
433
|
+
finalConfig.oauth?.redirectUri,
|
|
434
|
+
);
|
|
435
|
+
const persistedClientId = oauthResult.clientId ?? oauth.clientId ?? finalConfig.oauth?.clientId;
|
|
436
|
+
const persistedClientSecret = oauthResult.clientSecret ?? finalConfig.oauth?.clientSecret;
|
|
437
|
+
finalConfig = {
|
|
438
|
+
...finalConfig,
|
|
439
|
+
auth: {
|
|
440
|
+
type: "oauth",
|
|
441
|
+
credentialId: oauthResult.credentialId,
|
|
442
|
+
tokenUrl: oauth.tokenUrl,
|
|
443
|
+
clientId: persistedClientId,
|
|
444
|
+
clientSecret: persistedClientSecret,
|
|
445
|
+
},
|
|
446
|
+
oauth: {
|
|
447
|
+
...finalConfig.oauth,
|
|
448
|
+
clientId: persistedClientId ?? finalConfig.oauth?.clientId,
|
|
449
|
+
clientSecret: persistedClientSecret ?? finalConfig.oauth?.clientSecret,
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
} catch (oauthError) {
|
|
453
|
+
this.ctx.showError(
|
|
454
|
+
`OAuth flow failed for "${parsed.initialName}": ${oauthError instanceof Error ? oauthError.message : String(oauthError)}`,
|
|
455
|
+
);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
await this.#handleWizardComplete(parsed.initialName, finalConfig, parsed.scope);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Save current editor state
|
|
467
|
+
const done = () => {
|
|
468
|
+
this.ctx.editorContainer.clear();
|
|
469
|
+
this.ctx.editorContainer.addChild(this.ctx.editor);
|
|
470
|
+
this.ctx.ui.setFocus(this.ctx.editor);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// Create wizard with OAuth handler and connection test
|
|
474
|
+
const wizard = new MCPAddWizard(
|
|
475
|
+
async (name: string, config: MCPServerConfig, scope: "user" | "project") => {
|
|
476
|
+
done();
|
|
477
|
+
await this.#handleWizardComplete(name, config, scope);
|
|
478
|
+
},
|
|
479
|
+
() => {
|
|
480
|
+
done();
|
|
481
|
+
this.#handleWizardCancel();
|
|
482
|
+
},
|
|
483
|
+
async (authUrl: string, tokenUrl: string, clientId: string, clientSecret: string, scopes: string) => {
|
|
484
|
+
return await this.#handleOAuthFlow(authUrl, tokenUrl, clientId, clientSecret, scopes);
|
|
485
|
+
},
|
|
486
|
+
async (config: MCPServerConfig) => {
|
|
487
|
+
return await this.#handleTestConnection(config);
|
|
488
|
+
},
|
|
489
|
+
() => {
|
|
490
|
+
this.ctx.ui.requestRender();
|
|
491
|
+
},
|
|
492
|
+
parsed.initialName,
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
// Replace editor with wizard
|
|
496
|
+
this.ctx.editorContainer.clear();
|
|
497
|
+
this.ctx.editorContainer.addChild(wizard);
|
|
498
|
+
this.ctx.ui.setFocus(wizard);
|
|
499
|
+
this.ctx.ui.requestRender();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Handle OAuth authentication flow for MCP server
|
|
504
|
+
*/
|
|
505
|
+
async #handleOAuthFlow(
|
|
506
|
+
authUrl: string,
|
|
507
|
+
tokenUrl: string,
|
|
508
|
+
clientId: string,
|
|
509
|
+
clientSecret: string,
|
|
510
|
+
scopes: string,
|
|
511
|
+
callbackPort?: number,
|
|
512
|
+
callbackPath?: string,
|
|
513
|
+
redirectUri?: string,
|
|
514
|
+
): Promise<OAuthFlowResult> {
|
|
515
|
+
const authStorage = this.ctx.session.modelRegistry.authStorage;
|
|
516
|
+
let parsedAuthUrl: URL;
|
|
517
|
+
|
|
518
|
+
// Validate OAuth URLs
|
|
519
|
+
try {
|
|
520
|
+
parsedAuthUrl = new URL(authUrl);
|
|
521
|
+
new URL(tokenUrl);
|
|
522
|
+
} catch (_error) {
|
|
523
|
+
throw new Error(
|
|
524
|
+
`Invalid OAuth URLs. Please check:\n Authorization URL: ${authUrl}\n Token URL: ${tokenUrl}`,
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const resolvedClientId = clientId.trim() || parsedAuthUrl.searchParams.get("client_id") || undefined;
|
|
529
|
+
const resolvedClientSecret = clientSecret.trim() || undefined;
|
|
530
|
+
|
|
531
|
+
try {
|
|
532
|
+
// Create OAuth flow
|
|
533
|
+
const flow = new MCPOAuthFlow(
|
|
534
|
+
{
|
|
535
|
+
authorizationUrl: authUrl,
|
|
536
|
+
tokenUrl: tokenUrl,
|
|
537
|
+
clientId: resolvedClientId,
|
|
538
|
+
clientSecret: resolvedClientSecret,
|
|
539
|
+
scopes: scopes || undefined,
|
|
540
|
+
redirectUri,
|
|
541
|
+
callbackPort,
|
|
542
|
+
callbackPath,
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
onAuth: (info: { url: string; instructions?: string }) => {
|
|
546
|
+
// Show auth URL prominently in chat
|
|
547
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
548
|
+
this.ctx.chatContainer.addChild(
|
|
549
|
+
new Text(theme.fg("accent", "━━━ OAuth Authorization Required ━━━"), 1, 0),
|
|
550
|
+
);
|
|
551
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
552
|
+
this.ctx.chatContainer.addChild(
|
|
553
|
+
new Text(theme.fg("muted", "Preparing browser authorization..."), 1, 0),
|
|
554
|
+
);
|
|
555
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
556
|
+
this.ctx.chatContainer.addChild(
|
|
557
|
+
new Text(
|
|
558
|
+
theme.fg("muted", "Waiting for authorization... (Press Ctrl+C to cancel, 5 minute timeout)"),
|
|
559
|
+
1,
|
|
560
|
+
0,
|
|
561
|
+
),
|
|
562
|
+
);
|
|
563
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
564
|
+
this.ctx.chatContainer.addChild(
|
|
565
|
+
new Text(theme.fg("accent", "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), 1, 0),
|
|
566
|
+
);
|
|
567
|
+
this.ctx.ui.requestRender();
|
|
568
|
+
// Try to open browser automatically
|
|
569
|
+
try {
|
|
570
|
+
openPath(info.url);
|
|
571
|
+
|
|
572
|
+
// Show confirmation that browser should open
|
|
573
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
574
|
+
this.ctx.chatContainer.addChild(
|
|
575
|
+
new Text(theme.fg("success", "→ Opening browser automatically..."), 1, 0),
|
|
576
|
+
);
|
|
577
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
578
|
+
this.ctx.chatContainer.addChild(
|
|
579
|
+
new Text(theme.fg("muted", "Alternative if browser did not open:"), 1, 0),
|
|
580
|
+
);
|
|
581
|
+
this.ctx.chatContainer.addChild(
|
|
582
|
+
new Text(theme.fg("success", "Copy this exact URL in your browser:"), 1, 0),
|
|
583
|
+
);
|
|
584
|
+
this.ctx.chatContainer.addChild(new Text(theme.fg("accent", info.url), 1, 0));
|
|
585
|
+
this.ctx.ui.requestRender();
|
|
586
|
+
} catch (_error) {
|
|
587
|
+
// Show error if browser doesn't open
|
|
588
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
589
|
+
this.ctx.chatContainer.addChild(
|
|
590
|
+
new Text(theme.fg("warning", "→ Could not open browser automatically"), 1, 0),
|
|
591
|
+
);
|
|
592
|
+
this.ctx.chatContainer.addChild(
|
|
593
|
+
new Text(theme.fg("success", "Copy this exact URL in your browser:"), 1, 0),
|
|
594
|
+
);
|
|
595
|
+
this.ctx.chatContainer.addChild(new Text(theme.fg("accent", info.url), 1, 0));
|
|
596
|
+
this.ctx.ui.requestRender();
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
onProgress: (message: string) => {
|
|
600
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
601
|
+
this.ctx.chatContainer.addChild(new Text(theme.fg("muted", message), 1, 0));
|
|
602
|
+
this.ctx.ui.requestRender();
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// Execute OAuth flow with 5 minute timeout
|
|
608
|
+
const credentials = await withTimeout(flow.login(), 5 * 60 * 1000, "OAuth flow timed out after 5 minutes");
|
|
609
|
+
|
|
610
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
611
|
+
this.ctx.chatContainer.addChild(new Text(theme.fg("success", "✓ Authorization completed in browser."), 1, 0));
|
|
612
|
+
this.ctx.ui.requestRender();
|
|
613
|
+
|
|
614
|
+
// Generate a unique credential ID
|
|
615
|
+
const credentialId = `mcp_oauth_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
616
|
+
|
|
617
|
+
// Store credentials in auth storage
|
|
618
|
+
const oauthCredential: OAuthCredential = {
|
|
619
|
+
type: "oauth",
|
|
620
|
+
...credentials,
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// Store under a synthetic provider name
|
|
624
|
+
await authStorage.set(credentialId, oauthCredential);
|
|
625
|
+
|
|
626
|
+
return {
|
|
627
|
+
credentialId,
|
|
628
|
+
clientId: flow.resolvedClientId,
|
|
629
|
+
clientSecret: flow.registeredClientSecret,
|
|
630
|
+
};
|
|
631
|
+
} catch (error) {
|
|
632
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
633
|
+
|
|
634
|
+
// Provide helpful error messages based on failure type
|
|
635
|
+
if (errorMsg.includes("timeout") || errorMsg.includes("timed out")) {
|
|
636
|
+
throw new Error("OAuth flow timed out. Please try again.");
|
|
637
|
+
} else if (errorMsg.includes("403") || errorMsg.includes("unauthorized")) {
|
|
638
|
+
throw new Error("OAuth authorization failed. Please check your client credentials.");
|
|
639
|
+
} else if (errorMsg.includes("invalid_grant")) {
|
|
640
|
+
throw new Error("OAuth authorization code is invalid or expired. Please try again.");
|
|
641
|
+
} else if (errorMsg.includes("ECONNREFUSED") || errorMsg.includes("fetch failed")) {
|
|
642
|
+
throw new Error("Could not connect to OAuth server. Please check the URLs and your network connection.");
|
|
643
|
+
} else {
|
|
644
|
+
throw new Error(`OAuth authentication failed: ${errorMsg}`);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Test connection to an MCP server.
|
|
651
|
+
* Throws an error if connection fails (used for auto-detection).
|
|
652
|
+
*/
|
|
653
|
+
async #handleTestConnection(config: MCPServerConfig): Promise<void> {
|
|
654
|
+
// Create temporary connection using a test name
|
|
655
|
+
const testName = `test_${Date.now()}`;
|
|
656
|
+
let resolvedConfig: MCPServerConfig;
|
|
657
|
+
if (this.ctx.mcpManager) {
|
|
658
|
+
resolvedConfig = await this.ctx.mcpManager.prepareConfig(config);
|
|
659
|
+
} else {
|
|
660
|
+
const tempManager = new MCPManager(getProjectDir());
|
|
661
|
+
tempManager.setAuthStorage(this.ctx.session.modelRegistry.authStorage);
|
|
662
|
+
resolvedConfig = await tempManager.prepareConfig(config);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const connection = await connectToServer(testName, resolvedConfig);
|
|
666
|
+
await disconnectServer(connection);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async #findConfiguredServer(
|
|
670
|
+
name: string,
|
|
671
|
+
): Promise<{ filePath: string; scope: "user" | "project"; config: MCPServerConfig } | null> {
|
|
672
|
+
const cwd = getProjectDir();
|
|
673
|
+
const userPath = getMCPConfigPath("user", cwd);
|
|
674
|
+
const projectPath = getMCPConfigPath("project", cwd);
|
|
675
|
+
|
|
676
|
+
const [userConfig, projectConfig] = await Promise.all([
|
|
677
|
+
readMCPConfigFile(userPath),
|
|
678
|
+
readMCPConfigFile(projectPath),
|
|
679
|
+
]);
|
|
680
|
+
|
|
681
|
+
if (userConfig.mcpServers?.[name]) {
|
|
682
|
+
return { filePath: userPath, scope: "user", config: userConfig.mcpServers[name] };
|
|
683
|
+
}
|
|
684
|
+
if (projectConfig.mcpServers?.[name]) {
|
|
685
|
+
return { filePath: projectPath, scope: "project", config: projectConfig.mcpServers[name] };
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// Check standalone fallback files (mcp.json, .mcp.json) in the project root —
|
|
689
|
+
// these match the discovery paths used by the mcp-json provider. Reads run in
|
|
690
|
+
// parallel (mirroring user/project above) but precedence is preserved by the
|
|
691
|
+
// for-loop's iteration order: mcp.json wins over .mcp.json on a same-name hit.
|
|
692
|
+
const standalonePaths = [path.join(cwd, "mcp.json"), path.join(cwd, ".mcp.json")];
|
|
693
|
+
const fallbackConfigs = await Promise.all(
|
|
694
|
+
standalonePaths.map(async fallbackPath => {
|
|
695
|
+
try {
|
|
696
|
+
return await readMCPConfigFile(fallbackPath);
|
|
697
|
+
} catch {
|
|
698
|
+
// Malformed JSON in a standalone file — skip and continue lookup.
|
|
699
|
+
return null;
|
|
700
|
+
}
|
|
701
|
+
}),
|
|
702
|
+
);
|
|
703
|
+
for (const [index, fallbackConfig] of fallbackConfigs.entries()) {
|
|
704
|
+
const config = fallbackConfig?.mcpServers?.[name];
|
|
705
|
+
if (config) {
|
|
706
|
+
return { filePath: standalonePaths[index]!, scope: "project", config };
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return null;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
async #removeManagedOAuthCredential(credentialId: string | undefined): Promise<void> {
|
|
713
|
+
if (!credentialId?.startsWith("mcp_oauth_")) return;
|
|
714
|
+
await this.ctx.session.modelRegistry.authStorage.remove(credentialId);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
#stripOAuthAuth(config: MCPServerConfig): MCPServerConfig {
|
|
718
|
+
const next = { ...config } as MCPServerConfig & { auth?: MCPAuthConfig };
|
|
719
|
+
delete next.auth;
|
|
720
|
+
return next;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
async #resolveOAuthEndpointsFromServer(config: MCPServerConfig): Promise<{
|
|
724
|
+
authorizationUrl: string;
|
|
725
|
+
tokenUrl: string;
|
|
726
|
+
clientId?: string;
|
|
727
|
+
scopes?: string;
|
|
728
|
+
}> {
|
|
729
|
+
// First test if server actually needs auth by connecting without OAuth
|
|
730
|
+
let connectionSucceeded = false;
|
|
731
|
+
let connectionError: Error | undefined;
|
|
732
|
+
try {
|
|
733
|
+
await this.#handleTestConnection(this.#stripOAuthAuth(config));
|
|
734
|
+
connectionSucceeded = true;
|
|
735
|
+
} catch (error) {
|
|
736
|
+
connectionError = error as Error;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// Server connected fine without auth — reauth is not needed
|
|
740
|
+
if (connectionSucceeded) {
|
|
741
|
+
throw new Error("Server connection succeeded without OAuth; reauthorization is not required.");
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// Analyze the connection error to extract OAuth endpoints
|
|
745
|
+
const authResult = analyzeAuthError(connectionError!);
|
|
746
|
+
let oauth = authResult.authType === "oauth" ? (authResult.oauth ?? null) : null;
|
|
747
|
+
|
|
748
|
+
if (!oauth && (config.type === "http" || config.type === "sse") && config.url) {
|
|
749
|
+
oauth = await discoverOAuthEndpoints(config.url, authResult.authServerUrl);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (!oauth) {
|
|
753
|
+
throw new Error("Could not discover OAuth endpoints from server response.");
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return oauth;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
async #waitForServerConnectionWithAnimation(
|
|
760
|
+
name: string,
|
|
761
|
+
options?: { suppressDisconnectedWarning?: boolean },
|
|
762
|
+
): Promise<"connected" | "connecting" | "disconnected"> {
|
|
763
|
+
if (!this.ctx.mcpManager) return "disconnected";
|
|
764
|
+
|
|
765
|
+
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
766
|
+
const frames = theme.spinnerFrames;
|
|
767
|
+
const initialFrame = frames[0] ?? "|";
|
|
768
|
+
const statusText = new Text(theme.fg("muted", `${initialFrame} Connecting to "${name}"...`), 1, 0);
|
|
769
|
+
this.ctx.chatContainer.addChild(statusText);
|
|
770
|
+
this.ctx.ui.requestRender();
|
|
771
|
+
|
|
772
|
+
let frame = 0;
|
|
773
|
+
const interval = setInterval(() => {
|
|
774
|
+
statusText.setText(theme.fg("muted", `${frames[frame % frames.length]} Connecting to "${name}"...`));
|
|
775
|
+
frame++;
|
|
776
|
+
this.ctx.ui.requestRender();
|
|
777
|
+
}, 80);
|
|
778
|
+
|
|
779
|
+
try {
|
|
780
|
+
try {
|
|
781
|
+
await withTimeout(this.ctx.mcpManager.waitForConnection(name), 10_000, "Connection still pending");
|
|
782
|
+
} catch {
|
|
783
|
+
// Ignore timeout/errors here and use status check below.
|
|
784
|
+
}
|
|
785
|
+
const state = this.ctx.mcpManager.getConnectionStatus(name);
|
|
786
|
+
if (state === "connected") {
|
|
787
|
+
// Connection may complete after initial reload; rebind runtime MCP tools now.
|
|
788
|
+
await this.ctx.session.refreshMCPTools(this.ctx.mcpManager.getTools());
|
|
789
|
+
}
|
|
790
|
+
if (state === "connected") {
|
|
791
|
+
statusText.setText(theme.fg("success", `✓ Connected to "${name}"`));
|
|
792
|
+
} else if (state === "connecting") {
|
|
793
|
+
statusText.setText(theme.fg("muted", `◌ "${name}" is still connecting...`));
|
|
794
|
+
} else {
|
|
795
|
+
statusText.setText(
|
|
796
|
+
options?.suppressDisconnectedWarning
|
|
797
|
+
? theme.fg("muted", `◌ Connection check complete for "${name}"`)
|
|
798
|
+
: theme.fg("warning", `⚠ Could not connect to "${name}" yet`),
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
this.ctx.ui.requestRender();
|
|
802
|
+
return state;
|
|
803
|
+
} finally {
|
|
804
|
+
clearInterval(interval);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
async #syncManagerConnection(name: string, config: MCPServerConfig): Promise<void> {
|
|
809
|
+
if (!this.ctx.mcpManager) return;
|
|
810
|
+
if (this.ctx.mcpManager.getConnectionStatus(name) !== "disconnected") return;
|
|
811
|
+
await this.ctx.mcpManager.connectServers({ [name]: config }, {});
|
|
812
|
+
if (this.ctx.mcpManager.getConnectionStatus(name) === "connected") {
|
|
813
|
+
await this.ctx.session.refreshMCPTools(this.ctx.mcpManager.getTools());
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
async #handleWizardComplete(name: string, config: MCPServerConfig, scope: "user" | "project"): Promise<void> {
|
|
818
|
+
try {
|
|
819
|
+
// Determine file path
|
|
820
|
+
const cwd = getProjectDir();
|
|
821
|
+
const filePath = getMCPConfigPath(scope, cwd);
|
|
822
|
+
|
|
823
|
+
// Add server to config
|
|
824
|
+
await addMCPServer(filePath, name, config);
|
|
825
|
+
|
|
826
|
+
// Reload MCP manager
|
|
827
|
+
await this.#reloadMCP();
|
|
828
|
+
const state =
|
|
829
|
+
config.enabled === false
|
|
830
|
+
? "disconnected"
|
|
831
|
+
: await this.#waitForServerConnectionWithAnimation(name, { suppressDisconnectedWarning: true });
|
|
832
|
+
let isConnected = state === "connected";
|
|
833
|
+
const isConnecting = state === "connecting";
|
|
834
|
+
|
|
835
|
+
// Fallback: if manager state is still disconnected but direct test works,
|
|
836
|
+
// report as connected to avoid false-negative messaging.
|
|
837
|
+
if (!isConnected && !isConnecting && config.enabled !== false) {
|
|
838
|
+
try {
|
|
839
|
+
await this.#handleTestConnection(config);
|
|
840
|
+
isConnected = true;
|
|
841
|
+
await this.#syncManagerConnection(name, config);
|
|
842
|
+
} catch {
|
|
843
|
+
// Keep disconnected status
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// refreshMCPTools preserves the prior MCP tool selection, so tools from
|
|
848
|
+
// brand-new servers are registered in the registry but never activated.
|
|
849
|
+
// Explicitly activate the newly added server's tools now.
|
|
850
|
+
if (isConnected && this.ctx.mcpManager) {
|
|
851
|
+
const serverTools = this.ctx.mcpManager.getTools().filter(t => t.mcpServerName === name);
|
|
852
|
+
if (serverTools.length > 0) {
|
|
853
|
+
const currentActive = this.ctx.session.getActiveToolNames();
|
|
854
|
+
const toActivate = serverTools.map(t => t.name).filter(n => this.ctx.session.getToolByName(n));
|
|
855
|
+
if (toActivate.length > 0) {
|
|
856
|
+
await this.ctx.session.setActiveToolsByName([...new Set([...currentActive, ...toActivate])]);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// Show success message
|
|
862
|
+
const scopeLabel = scope === "user" ? "user" : "project";
|
|
863
|
+
const lines = ["", theme.fg("success", `✓ Added server "${name}" to ${scopeLabel} config`), ""];
|
|
864
|
+
|
|
865
|
+
if (isConnected) {
|
|
866
|
+
lines.push(theme.fg("success", `✓ Successfully connected to server`));
|
|
867
|
+
lines.push("");
|
|
868
|
+
} else if (isConnecting) {
|
|
869
|
+
lines.push(theme.fg("muted", `◌ Server is connecting in background...`));
|
|
870
|
+
lines.push(theme.fg("muted", ` Run ${theme.fg("accent", `/mcp test ${name}`)} in a few seconds.`));
|
|
871
|
+
lines.push("");
|
|
872
|
+
} else {
|
|
873
|
+
lines.push(theme.fg("warning", `⚠ Server added but not yet connected`));
|
|
874
|
+
lines.push(theme.fg("muted", ` Run ${theme.fg("accent", `/mcp test ${name}`)} to test the connection.`));
|
|
875
|
+
lines.push("");
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
lines.push(theme.fg("muted", `Run ${theme.fg("accent", "/mcp list")} to see all configured servers.`));
|
|
879
|
+
lines.push("");
|
|
880
|
+
|
|
881
|
+
this.#showMessage(lines.join("\n"));
|
|
882
|
+
} catch (error) {
|
|
883
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
884
|
+
|
|
885
|
+
// Provide helpful error messages
|
|
886
|
+
let helpText = "";
|
|
887
|
+
if (errorMsg.includes("EACCES") || errorMsg.includes("permission denied")) {
|
|
888
|
+
helpText = "\n\nTip: Check file permissions for the config directory.";
|
|
889
|
+
} else if (errorMsg.includes("ENOSPC")) {
|
|
890
|
+
helpText = "\n\nTip: Insufficient disk space.";
|
|
891
|
+
} else if (errorMsg.includes("already exists")) {
|
|
892
|
+
helpText = `\n\nTip: Use ${theme.fg("accent", "/mcp list")} to see existing servers.`;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
this.ctx.showError(`Failed to add server: ${errorMsg}${helpText}`);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
#handleWizardCancel(): void {
|
|
900
|
+
this.#showMessage(
|
|
901
|
+
[
|
|
902
|
+
"",
|
|
903
|
+
theme.fg("muted", "Server creation cancelled."),
|
|
904
|
+
"",
|
|
905
|
+
theme.fg("dim", "Tip: Press Ctrl+C or Esc anytime to cancel"),
|
|
906
|
+
"",
|
|
907
|
+
].join("\n"),
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Handle /mcp list - Show all configured servers
|
|
913
|
+
*/
|
|
914
|
+
async #handleList(): Promise<void> {
|
|
915
|
+
try {
|
|
916
|
+
const cwd = getProjectDir();
|
|
917
|
+
|
|
918
|
+
// Load from both user and project configs
|
|
919
|
+
const userPath = getMCPConfigPath("user", cwd);
|
|
920
|
+
const projectPath = getMCPConfigPath("project", cwd);
|
|
921
|
+
|
|
922
|
+
const userPathLabel = shortenPath(userPath);
|
|
923
|
+
const projectPathLabel = shortenPath(projectPath);
|
|
924
|
+
const [userConfig, projectConfig] = await Promise.all([
|
|
925
|
+
readMCPConfigFile(userPath),
|
|
926
|
+
readMCPConfigFile(projectPath),
|
|
927
|
+
]);
|
|
928
|
+
|
|
929
|
+
const userServers = Object.keys(userConfig.mcpServers ?? {});
|
|
930
|
+
const projectServers = Object.keys(projectConfig.mcpServers ?? {});
|
|
931
|
+
|
|
932
|
+
// Collect runtime-discovered servers not in config files
|
|
933
|
+
const configServerNames = new Set([...userServers, ...projectServers]);
|
|
934
|
+
const disabledServerNames = new Set(await readDisabledServers(userPath));
|
|
935
|
+
const discoveredServers: { name: string; source: SourceMeta }[] = [];
|
|
936
|
+
if (this.ctx.mcpManager) {
|
|
937
|
+
for (const name of this.ctx.mcpManager.getAllServerNames()) {
|
|
938
|
+
if (configServerNames.has(name)) continue;
|
|
939
|
+
if (disabledServerNames.has(name)) continue;
|
|
940
|
+
const source = this.ctx.mcpManager.getSource(name);
|
|
941
|
+
if (source) {
|
|
942
|
+
discoveredServers.push({ name, source });
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (
|
|
948
|
+
userServers.length === 0 &&
|
|
949
|
+
projectServers.length === 0 &&
|
|
950
|
+
discoveredServers.length === 0 &&
|
|
951
|
+
disabledServerNames.size === 0
|
|
952
|
+
) {
|
|
953
|
+
this.#showMessage(
|
|
954
|
+
[
|
|
955
|
+
"",
|
|
956
|
+
theme.fg("muted", "No MCP servers configured."),
|
|
957
|
+
"",
|
|
958
|
+
`Use ${theme.fg("accent", "/mcp add")} to add a server.`,
|
|
959
|
+
"",
|
|
960
|
+
].join("\n"),
|
|
961
|
+
);
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
const lines: string[] = ["", theme.bold("Configured MCP Servers"), ""];
|
|
966
|
+
|
|
967
|
+
// Show user-level servers
|
|
968
|
+
if (userServers.length > 0) {
|
|
969
|
+
lines.push(theme.fg("accent", "User level") + theme.fg("muted", ` (${userPathLabel}):`));
|
|
970
|
+
for (const name of userServers) {
|
|
971
|
+
const config = userConfig.mcpServers![name];
|
|
972
|
+
const type = config.type ?? "stdio";
|
|
973
|
+
const state =
|
|
974
|
+
config.enabled === false
|
|
975
|
+
? "inactive"
|
|
976
|
+
: (this.ctx.mcpManager?.getConnectionStatus(name) ?? "disconnected");
|
|
977
|
+
const status =
|
|
978
|
+
state === "inactive"
|
|
979
|
+
? theme.fg("warning", " ◌ inactive")
|
|
980
|
+
: state === "connected"
|
|
981
|
+
? theme.fg("success", " ● connected")
|
|
982
|
+
: state === "connecting"
|
|
983
|
+
? theme.fg("muted", " ◌ connecting")
|
|
984
|
+
: theme.fg("muted", " ○ not connected");
|
|
985
|
+
lines.push(` ${theme.fg("accent", name)}${status} ${theme.fg("dim", `[${type}]`)}`);
|
|
986
|
+
}
|
|
987
|
+
lines.push("");
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Show project-level servers
|
|
991
|
+
if (projectServers.length > 0) {
|
|
992
|
+
lines.push(theme.fg("accent", "Project level") + theme.fg("muted", ` (${projectPathLabel}):`));
|
|
993
|
+
for (const name of projectServers) {
|
|
994
|
+
const config = projectConfig.mcpServers![name];
|
|
995
|
+
const type = config.type ?? "stdio";
|
|
996
|
+
const state =
|
|
997
|
+
config.enabled === false
|
|
998
|
+
? "inactive"
|
|
999
|
+
: (this.ctx.mcpManager?.getConnectionStatus(name) ?? "disconnected");
|
|
1000
|
+
const status =
|
|
1001
|
+
state === "inactive"
|
|
1002
|
+
? theme.fg("warning", " ◌ inactive")
|
|
1003
|
+
: state === "connected"
|
|
1004
|
+
? theme.fg("success", " ● connected")
|
|
1005
|
+
: state === "connecting"
|
|
1006
|
+
? theme.fg("muted", " ◌ connecting")
|
|
1007
|
+
: theme.fg("muted", " ○ not connected");
|
|
1008
|
+
lines.push(` ${theme.fg("accent", name)}${status} ${theme.fg("dim", `[${type}]`)}`);
|
|
1009
|
+
}
|
|
1010
|
+
lines.push("");
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// Show discovered servers (from .Anthropic model.json, .cursor/mcp.json, .vscode/mcp.json, etc.)
|
|
1014
|
+
if (discoveredServers.length > 0) {
|
|
1015
|
+
for (const { providerName, shortPath, items: entries } of groupBySource(discoveredServers, e => e.source)) {
|
|
1016
|
+
lines.push(theme.fg("accent", providerName) + theme.fg("muted", ` (${shortPath}):`));
|
|
1017
|
+
for (const { name } of entries) {
|
|
1018
|
+
const state = this.ctx.mcpManager!.getConnectionStatus(name);
|
|
1019
|
+
const status =
|
|
1020
|
+
state === "connected"
|
|
1021
|
+
? theme.fg("success", " ● connected")
|
|
1022
|
+
: state === "connecting"
|
|
1023
|
+
? theme.fg("muted", " ◌ connecting")
|
|
1024
|
+
: theme.fg("muted", " ○ not connected");
|
|
1025
|
+
lines.push(` ${theme.fg("accent", name)}${status}`);
|
|
1026
|
+
}
|
|
1027
|
+
lines.push("");
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// Show servers disabled via /mcp disable (from third-party configs)
|
|
1032
|
+
const relevantDisabled = [...disabledServerNames].filter(n => !configServerNames.has(n));
|
|
1033
|
+
if (relevantDisabled.length > 0) {
|
|
1034
|
+
lines.push(theme.fg("accent", "Disabled") + theme.fg("muted", " (discovered servers):"));
|
|
1035
|
+
for (const name of relevantDisabled) {
|
|
1036
|
+
lines.push(` ${theme.fg("accent", name)}${theme.fg("warning", " ◌ disabled")}`);
|
|
1037
|
+
}
|
|
1038
|
+
lines.push("");
|
|
1039
|
+
}
|
|
1040
|
+
this.#showMessage(lines.join("\n"));
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
this.ctx.showError(`Failed to list servers: ${error instanceof Error ? error.message : String(error)}`);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Handle /mcp remove <name> - Remove a server
|
|
1048
|
+
*/
|
|
1049
|
+
async #handleRemove(text: string): Promise<void> {
|
|
1050
|
+
const match = text.match(/^\/mcp\s+(?:remove|rm)\b\s*(.*)$/i);
|
|
1051
|
+
const rest = match?.[1]?.trim() ?? "";
|
|
1052
|
+
const parsed = parseRemoveArgs(rest);
|
|
1053
|
+
if (!parsed.ok) {
|
|
1054
|
+
this.ctx.showError(parsed.error);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
const { name, scope } = parsed.value;
|
|
1058
|
+
|
|
1059
|
+
if (!name) {
|
|
1060
|
+
this.ctx.showError("Server name required. Usage: /mcp remove <name> [--scope project|user]");
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
try {
|
|
1065
|
+
const cwd = getProjectDir();
|
|
1066
|
+
const userPath = getMCPConfigPath("user", cwd);
|
|
1067
|
+
const projectPath = getMCPConfigPath("project", cwd);
|
|
1068
|
+
const filePath = scope === "user" ? userPath : projectPath;
|
|
1069
|
+
const config = await readMCPConfigFile(filePath);
|
|
1070
|
+
if (!config.mcpServers?.[name]) {
|
|
1071
|
+
this.ctx.showError(`Server "${name}" not found in ${scope} config.`);
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Disconnect if connected
|
|
1076
|
+
if (this.ctx.mcpManager?.getConnection(name)) {
|
|
1077
|
+
await this.ctx.mcpManager.disconnectServer(name);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// Remove from config
|
|
1081
|
+
await removeMCPServer(filePath, name);
|
|
1082
|
+
|
|
1083
|
+
// Reload MCP manager
|
|
1084
|
+
await this.#reloadMCP();
|
|
1085
|
+
|
|
1086
|
+
this.#showMessage(["", theme.fg("success", `✓ Removed server "${name}" from ${scope} config`), ""].join("\n"));
|
|
1087
|
+
} catch (error) {
|
|
1088
|
+
this.ctx.showError(`Failed to remove server: ${error instanceof Error ? error.message : String(error)}`);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Handle /mcp test <name> - Test connection to a server
|
|
1094
|
+
*/
|
|
1095
|
+
async #handleTest(name: string | undefined): Promise<void> {
|
|
1096
|
+
if (!name) {
|
|
1097
|
+
this.ctx.showError("Server name required. Usage: /mcp test <name>");
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
const originalOnEscape = this.ctx.editor.onEscape;
|
|
1102
|
+
const abortController = new AbortController();
|
|
1103
|
+
this.ctx.editor.onEscape = () => {
|
|
1104
|
+
abortController.abort();
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
let connection: MCPServerConnection | undefined;
|
|
1108
|
+
try {
|
|
1109
|
+
const found = await this.#findConfiguredServer(name);
|
|
1110
|
+
|
|
1111
|
+
if (!found) {
|
|
1112
|
+
this.ctx.showError(
|
|
1113
|
+
`Server "${name}" not found.\n\nTip: Run ${theme.fg("accent", "/mcp list")} to see available servers.`,
|
|
1114
|
+
);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const { config } = found;
|
|
1119
|
+
if (config.enabled === false) {
|
|
1120
|
+
this.ctx.showError(`Server "${name}" is disabled. Run /mcp enable ${name} first.`);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
this.#showMessage(
|
|
1125
|
+
["", theme.fg("muted", `Testing connection to "${name}"... (esc to cancel)`), ""].join("\n"),
|
|
1126
|
+
);
|
|
1127
|
+
|
|
1128
|
+
// Resolve auth config if needed
|
|
1129
|
+
let resolvedConfig: MCPServerConfig;
|
|
1130
|
+
if (this.ctx.mcpManager) {
|
|
1131
|
+
resolvedConfig = await this.ctx.mcpManager.prepareConfig(config);
|
|
1132
|
+
} else {
|
|
1133
|
+
const tempManager = new MCPManager(getProjectDir());
|
|
1134
|
+
tempManager.setAuthStorage(this.ctx.session.modelRegistry.authStorage);
|
|
1135
|
+
resolvedConfig = await tempManager.prepareConfig(config);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// Create temporary connection
|
|
1139
|
+
connection = await connectToServer(name, resolvedConfig, { signal: abortController.signal });
|
|
1140
|
+
|
|
1141
|
+
// List tools to verify connection
|
|
1142
|
+
const tools = await listTools(connection, { signal: abortController.signal });
|
|
1143
|
+
|
|
1144
|
+
const lines = [
|
|
1145
|
+
"",
|
|
1146
|
+
theme.fg("success", `✓ Successfully connected to "${name}"`),
|
|
1147
|
+
"",
|
|
1148
|
+
` Server: ${connection.serverInfo.name} v${connection.serverInfo.version}`,
|
|
1149
|
+
` Tools: ${tools.length}`,
|
|
1150
|
+
];
|
|
1151
|
+
|
|
1152
|
+
// Show tool names if there are any
|
|
1153
|
+
if (tools.length > 0 && tools.length <= 10) {
|
|
1154
|
+
lines.push("");
|
|
1155
|
+
lines.push(" Available tools:");
|
|
1156
|
+
for (const tool of tools) {
|
|
1157
|
+
lines.push(` • ${tool.name}`);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
lines.push("");
|
|
1162
|
+
await this.#syncManagerConnection(name, config);
|
|
1163
|
+
this.#showMessage(lines.join("\n"));
|
|
1164
|
+
} catch (error) {
|
|
1165
|
+
if (abortController.signal.aborted || (error instanceof Error && error.name === "AbortError")) {
|
|
1166
|
+
this.ctx.showStatus(`Cancelled MCP test for "${name}"`);
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1171
|
+
|
|
1172
|
+
// Provide helpful error messages
|
|
1173
|
+
let helpText = "";
|
|
1174
|
+
if (errorMsg.includes("ENOENT") || errorMsg.includes("not found")) {
|
|
1175
|
+
helpText = "\n\nTip: Check that the command or URL is correct.";
|
|
1176
|
+
} else if (errorMsg.includes("EACCES")) {
|
|
1177
|
+
helpText = "\n\nTip: Check file/command permissions.";
|
|
1178
|
+
} else if (errorMsg.includes("ECONNREFUSED")) {
|
|
1179
|
+
helpText = "\n\nTip: Check that the server is running and the URL/port is correct.";
|
|
1180
|
+
} else if (errorMsg.includes("timeout")) {
|
|
1181
|
+
helpText = "\n\nTip: The server may be slow or unresponsive. Try increasing the timeout.";
|
|
1182
|
+
} else if (errorMsg.includes("401") || errorMsg.includes("403")) {
|
|
1183
|
+
helpText = "\n\nTip: Check your authentication credentials.";
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
this.ctx.showError(`Failed to connect to "${name}": ${errorMsg}${helpText}`);
|
|
1187
|
+
} finally {
|
|
1188
|
+
this.ctx.editor.onEscape = originalOnEscape;
|
|
1189
|
+
if (connection) {
|
|
1190
|
+
// Best-effort: don't block UI on cleanup.
|
|
1191
|
+
void disconnectServer(connection);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
async #handleSetEnabled(name: string | undefined, enabled: boolean): Promise<void> {
|
|
1197
|
+
if (!name) {
|
|
1198
|
+
this.ctx.showError(`Server name required. Usage: /mcp ${enabled ? "enable" : "disable"} <name>`);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
try {
|
|
1203
|
+
const found = await this.#findConfiguredServer(name);
|
|
1204
|
+
if (!found) {
|
|
1205
|
+
// Check if this is a discovered server from a third-party config
|
|
1206
|
+
const userConfigPath = getMCPConfigPath("user", getProjectDir());
|
|
1207
|
+
const disabledServers = new Set(await readDisabledServers(userConfigPath));
|
|
1208
|
+
const isDiscovered = this.ctx.mcpManager?.getSource(name);
|
|
1209
|
+
const isCurrentlyDisabled = disabledServers.has(name);
|
|
1210
|
+
if (!isDiscovered && !isCurrentlyDisabled) {
|
|
1211
|
+
this.ctx.showError(`Server "${name}" not found.`);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
if (isCurrentlyDisabled === !enabled) {
|
|
1215
|
+
this.#showMessage(
|
|
1216
|
+
["", theme.fg("muted", `Server "${name}" is already ${enabled ? "enabled" : "disabled"}.`), ""].join(
|
|
1217
|
+
"\n",
|
|
1218
|
+
),
|
|
1219
|
+
);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
await setServerDisabled(userConfigPath, name, !enabled);
|
|
1223
|
+
if (enabled) {
|
|
1224
|
+
await this.#reloadMCP();
|
|
1225
|
+
const state = await this.#waitForServerConnectionWithAnimation(name);
|
|
1226
|
+
const status =
|
|
1227
|
+
state === "connected"
|
|
1228
|
+
? theme.fg("success", "Connected")
|
|
1229
|
+
: state === "connecting"
|
|
1230
|
+
? theme.fg("muted", "Connecting")
|
|
1231
|
+
: theme.fg("warning", "Not connected yet");
|
|
1232
|
+
this.#showMessage(
|
|
1233
|
+
["", theme.fg("success", `✓ Enabled "${name}"`), "", ` Status: ${status}`, ""].join("\n"),
|
|
1234
|
+
);
|
|
1235
|
+
} else {
|
|
1236
|
+
await this.ctx.mcpManager?.disconnectServer(name);
|
|
1237
|
+
await this.ctx.session.refreshMCPTools(this.ctx.mcpManager?.getTools() ?? []);
|
|
1238
|
+
this.#showMessage(["", theme.fg("success", `✓ Disabled "${name}"`), ""].join("\n"));
|
|
1239
|
+
}
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
if ((found.config.enabled ?? true) === enabled) {
|
|
1244
|
+
this.#showMessage(
|
|
1245
|
+
["", theme.fg("muted", `Server "${name}" is already ${enabled ? "enabled" : "disabled"}.`), ""].join(
|
|
1246
|
+
"\n",
|
|
1247
|
+
),
|
|
1248
|
+
);
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
const updated: MCPServerConfig = { ...found.config, enabled };
|
|
1253
|
+
await updateMCPServer(found.filePath, name, updated);
|
|
1254
|
+
await this.#reloadMCP();
|
|
1255
|
+
|
|
1256
|
+
let status = "";
|
|
1257
|
+
if (enabled) {
|
|
1258
|
+
const state = await this.#waitForServerConnectionWithAnimation(name);
|
|
1259
|
+
status =
|
|
1260
|
+
state === "connected"
|
|
1261
|
+
? theme.fg("success", "Connected")
|
|
1262
|
+
: state === "connecting"
|
|
1263
|
+
? theme.fg("muted", "Connecting")
|
|
1264
|
+
: theme.fg("warning", "Not connected yet");
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
const lines = [
|
|
1268
|
+
"",
|
|
1269
|
+
theme.fg("success", `✓ ${enabled ? "Enabled" : "Disabled"} "${name}" (${found.scope} config)`),
|
|
1270
|
+
];
|
|
1271
|
+
if (status) {
|
|
1272
|
+
lines.push("");
|
|
1273
|
+
lines.push(` Status: ${status}`);
|
|
1274
|
+
}
|
|
1275
|
+
lines.push("");
|
|
1276
|
+
this.#showMessage(lines.join("\n"));
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
this.ctx.showError(
|
|
1279
|
+
`Failed to ${enabled ? "enable" : "disable"} server: ${error instanceof Error ? error.message : String(error)}`,
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
async #handleUnauth(name: string | undefined): Promise<void> {
|
|
1285
|
+
if (!name) {
|
|
1286
|
+
this.ctx.showError("Server name required. Usage: /mcp unauth <name>");
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
try {
|
|
1291
|
+
const found = await this.#findConfiguredServer(name);
|
|
1292
|
+
if (!found) {
|
|
1293
|
+
this.ctx.showError(`Server "${name}" not found.`);
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
const currentAuth = (found.config as MCPServerConfig & { auth?: MCPAuthConfig }).auth;
|
|
1298
|
+
if (currentAuth?.type === "oauth") {
|
|
1299
|
+
await this.#removeManagedOAuthCredential(currentAuth.credentialId);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
const updated = this.#stripOAuthAuth(found.config);
|
|
1303
|
+
await updateMCPServer(found.filePath, name, updated);
|
|
1304
|
+
await this.#reloadMCP();
|
|
1305
|
+
|
|
1306
|
+
this.#showMessage(
|
|
1307
|
+
["", theme.fg("success", `✓ Cleared auth for "${name}" (${found.scope} config)`), ""].join("\n"),
|
|
1308
|
+
);
|
|
1309
|
+
} catch (error) {
|
|
1310
|
+
this.ctx.showError(`Failed to clear auth: ${error instanceof Error ? error.message : String(error)}`);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
async #handleReauth(name: string | undefined): Promise<void> {
|
|
1315
|
+
if (!name) {
|
|
1316
|
+
this.ctx.showError("Server name required. Usage: /mcp reauth <name>");
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
try {
|
|
1321
|
+
const found = await this.#findConfiguredServer(name);
|
|
1322
|
+
if (!found) {
|
|
1323
|
+
this.ctx.showError(`Server "${name}" not found.`);
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
if (found.config.enabled === false) {
|
|
1328
|
+
this.ctx.showError(`Server "${name}" is disabled. Run /mcp enable ${name} first.`);
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
const currentAuth = (found.config as MCPServerConfig & { auth?: MCPAuthConfig }).auth;
|
|
1333
|
+
if (currentAuth?.type === "oauth") {
|
|
1334
|
+
await this.#removeManagedOAuthCredential(currentAuth.credentialId);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
const baseConfig = this.#stripOAuthAuth(found.config);
|
|
1338
|
+
const oauth = await this.#resolveOAuthEndpointsFromServer(baseConfig);
|
|
1339
|
+
const oauthClientSecret = found.config.oauth?.clientSecret ?? currentAuth?.clientSecret ?? "";
|
|
1340
|
+
|
|
1341
|
+
this.#showMessage(["", theme.fg("muted", `Reauthorizing "${name}"...`), ""].join("\n"));
|
|
1342
|
+
|
|
1343
|
+
const oauthResult = await this.#handleOAuthFlow(
|
|
1344
|
+
oauth.authorizationUrl,
|
|
1345
|
+
oauth.tokenUrl,
|
|
1346
|
+
oauth.clientId ?? found.config.oauth?.clientId ?? "",
|
|
1347
|
+
oauthClientSecret,
|
|
1348
|
+
oauth.scopes ?? "",
|
|
1349
|
+
found.config.oauth?.callbackPort,
|
|
1350
|
+
found.config.oauth?.callbackPath,
|
|
1351
|
+
found.config.oauth?.redirectUri,
|
|
1352
|
+
);
|
|
1353
|
+
|
|
1354
|
+
const persistedClientId = oauthResult.clientId ?? oauth.clientId ?? found.config.oauth?.clientId;
|
|
1355
|
+
const persistedClientSecret = oauthResult.clientSecret ?? (oauthClientSecret || undefined);
|
|
1356
|
+
|
|
1357
|
+
const updated: MCPServerConfig = {
|
|
1358
|
+
...baseConfig,
|
|
1359
|
+
auth: {
|
|
1360
|
+
type: "oauth",
|
|
1361
|
+
credentialId: oauthResult.credentialId,
|
|
1362
|
+
tokenUrl: oauth.tokenUrl,
|
|
1363
|
+
clientId: persistedClientId,
|
|
1364
|
+
clientSecret: persistedClientSecret,
|
|
1365
|
+
},
|
|
1366
|
+
oauth: {
|
|
1367
|
+
...found.config.oauth,
|
|
1368
|
+
clientId: persistedClientId ?? found.config.oauth?.clientId,
|
|
1369
|
+
clientSecret: persistedClientSecret ?? found.config.oauth?.clientSecret,
|
|
1370
|
+
},
|
|
1371
|
+
};
|
|
1372
|
+
await updateMCPServer(found.filePath, name, updated);
|
|
1373
|
+
await this.#reloadMCP();
|
|
1374
|
+
const state = await this.#waitForServerConnectionWithAnimation(name);
|
|
1375
|
+
|
|
1376
|
+
const lines = [
|
|
1377
|
+
"",
|
|
1378
|
+
theme.fg("success", `✓ Reauthorized "${name}" (${found.scope} config)`),
|
|
1379
|
+
"",
|
|
1380
|
+
` Status: ${
|
|
1381
|
+
state === "connected"
|
|
1382
|
+
? theme.fg("success", "connected")
|
|
1383
|
+
: state === "connecting"
|
|
1384
|
+
? theme.fg("muted", "connecting")
|
|
1385
|
+
: theme.fg("warning", "not connected")
|
|
1386
|
+
}`,
|
|
1387
|
+
"",
|
|
1388
|
+
];
|
|
1389
|
+
this.#showMessage(lines.join("\n"));
|
|
1390
|
+
} catch (error) {
|
|
1391
|
+
this.ctx.showError(`Failed to reauthorize server: ${error instanceof Error ? error.message : String(error)}`);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
async #handleReload(): Promise<void> {
|
|
1396
|
+
try {
|
|
1397
|
+
this.#showMessage(["", theme.fg("muted", "Reloading MCP servers and runtime tools..."), ""].join("\n"));
|
|
1398
|
+
await this.#reloadMCP();
|
|
1399
|
+
const connectedCount = this.ctx.mcpManager?.getConnectedServers().length ?? 0;
|
|
1400
|
+
this.#showMessage(
|
|
1401
|
+
["", theme.fg("success", "✓ MCP reload complete"), ` Connected servers: ${connectedCount}`, ""].join("\n"),
|
|
1402
|
+
);
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
this.ctx.showError(`Failed to reload MCP: ${error instanceof Error ? error.message : String(error)}`);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Handle /mcp reconnect <name> - Reconnect to a specific server.
|
|
1410
|
+
*/
|
|
1411
|
+
async #handleReconnect(name: string | undefined): Promise<void> {
|
|
1412
|
+
if (!name) {
|
|
1413
|
+
this.ctx.showError("Server name required. Usage: /mcp reconnect <name>");
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
if (!this.ctx.mcpManager) {
|
|
1417
|
+
this.ctx.showError("MCP manager not available.");
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
this.#showMessage(["", theme.fg("muted", `Reconnecting to "${name}"...`), ""].join("\n"));
|
|
1422
|
+
|
|
1423
|
+
try {
|
|
1424
|
+
const connection = await this.ctx.mcpManager.reconnectServer(name);
|
|
1425
|
+
if (connection) {
|
|
1426
|
+
// refreshMCPTools re-registers tools and preserves the user's prior
|
|
1427
|
+
// MCP tool selection. No need to call activateDiscoveredMCPTools —
|
|
1428
|
+
// that would broaden the selection to all server tools.
|
|
1429
|
+
await this.ctx.session.refreshMCPTools(this.ctx.mcpManager.getTools());
|
|
1430
|
+
const serverTools = this.ctx.mcpManager.getTools().filter(t => t.mcpServerName === name);
|
|
1431
|
+
this.#showMessage(
|
|
1432
|
+
["\n", theme.fg("success", `✓ Reconnected to "${name}"`), ` Tools: ${serverTools.length}`, "\n"].join(
|
|
1433
|
+
"\n",
|
|
1434
|
+
),
|
|
1435
|
+
);
|
|
1436
|
+
} else {
|
|
1437
|
+
this.ctx.showError(`Failed to reconnect to "${name}". Check server status and logs.`);
|
|
1438
|
+
}
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
this.ctx.showError(
|
|
1441
|
+
`Failed to reconnect to "${name}": ${error instanceof Error ? error.message : String(error)}`,
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Reload MCP manager with new configs
|
|
1448
|
+
*/
|
|
1449
|
+
async #reloadMCP(): Promise<void> {
|
|
1450
|
+
if (!this.ctx.mcpManager) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// Disconnect all existing servers
|
|
1455
|
+
await this.ctx.mcpManager.disconnectAll();
|
|
1456
|
+
|
|
1457
|
+
// Rediscover and connect
|
|
1458
|
+
const result = await this.ctx.mcpManager.discoverAndConnect();
|
|
1459
|
+
await this.ctx.session.refreshMCPTools(this.ctx.mcpManager.getTools());
|
|
1460
|
+
|
|
1461
|
+
// Show any connection errors
|
|
1462
|
+
if (result.errors.size > 0) {
|
|
1463
|
+
const errorLines = ["", theme.fg("warning", "Some servers failed to connect:"), ""];
|
|
1464
|
+
for (const [serverName, error] of result.errors.entries()) {
|
|
1465
|
+
errorLines.push(` ${serverName}: ${error}`);
|
|
1466
|
+
}
|
|
1467
|
+
errorLines.push("");
|
|
1468
|
+
this.#showMessage(errorLines.join("\n"));
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* Handle /mcp resources - Show available resources from connected servers
|
|
1474
|
+
*/
|
|
1475
|
+
async #handleResources(): Promise<void> {
|
|
1476
|
+
if (!this.ctx.mcpManager) {
|
|
1477
|
+
this.ctx.showError("No MCP manager available.");
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const servers = this.ctx.mcpManager.getConnectedServers();
|
|
1482
|
+
const lines: string[] = ["", theme.bold("MCP Resources"), ""];
|
|
1483
|
+
let hasAny = false;
|
|
1484
|
+
|
|
1485
|
+
for (const name of servers) {
|
|
1486
|
+
const data = this.ctx.mcpManager.getServerResources(name);
|
|
1487
|
+
if (!data) continue;
|
|
1488
|
+
const { resources, templates } = data;
|
|
1489
|
+
if (resources.length === 0 && templates.length === 0) continue;
|
|
1490
|
+
hasAny = true;
|
|
1491
|
+
|
|
1492
|
+
lines.push(`${theme.fg("accent", name)}:`);
|
|
1493
|
+
for (const r of resources) {
|
|
1494
|
+
const desc = r.description ? ` ${theme.fg("dim", r.description)}` : "";
|
|
1495
|
+
const mime = r.mimeType ? ` ${theme.fg("dim", `[${r.mimeType}]`)}` : "";
|
|
1496
|
+
lines.push(` ${theme.fg("success", r.uri)}${mime}${desc}`);
|
|
1497
|
+
}
|
|
1498
|
+
if (templates.length > 0) {
|
|
1499
|
+
lines.push(` ${theme.fg("muted", "Templates:")}`);
|
|
1500
|
+
for (const t of templates) {
|
|
1501
|
+
const desc = t.description ? ` ${theme.fg("dim", t.description)}` : "";
|
|
1502
|
+
lines.push(` ${theme.fg("accent", t.uriTemplate)}${desc}`);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
lines.push("");
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
if (!hasAny) {
|
|
1509
|
+
lines.push(theme.fg("muted", "No resources available on connected servers."));
|
|
1510
|
+
lines.push("");
|
|
1511
|
+
}
|
|
1512
|
+
this.#showMessage(lines.join("\n"));
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Handle /mcp prompts - Show available prompts from connected servers
|
|
1517
|
+
*/
|
|
1518
|
+
async #handlePrompts(): Promise<void> {
|
|
1519
|
+
if (!this.ctx.mcpManager) {
|
|
1520
|
+
this.ctx.showError("No MCP manager available.");
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
const servers = this.ctx.mcpManager.getConnectedServers();
|
|
1525
|
+
const lines: string[] = ["", theme.bold("MCP Prompts"), ""];
|
|
1526
|
+
let hasAny = false;
|
|
1527
|
+
|
|
1528
|
+
for (const name of servers) {
|
|
1529
|
+
const prompts = this.ctx.mcpManager.getServerPrompts(name);
|
|
1530
|
+
if (!prompts?.length) continue;
|
|
1531
|
+
hasAny = true;
|
|
1532
|
+
|
|
1533
|
+
lines.push(`${theme.fg("accent", name)}:`);
|
|
1534
|
+
for (const p of prompts) {
|
|
1535
|
+
const commandName = `${name}:${p.name}`;
|
|
1536
|
+
const desc = p.description ? ` ${theme.fg("dim", p.description)}` : "";
|
|
1537
|
+
lines.push(` ${theme.fg("success", `/${commandName}`)}${desc}`);
|
|
1538
|
+
if (p.arguments?.length) {
|
|
1539
|
+
for (const arg of p.arguments) {
|
|
1540
|
+
const required = arg.required ? theme.fg("warning", " *") : "";
|
|
1541
|
+
const argDesc = arg.description ? ` - ${arg.description}` : "";
|
|
1542
|
+
lines.push(` ${arg.name}=${required}${theme.fg("dim", argDesc)}`);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
lines.push("");
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
if (!hasAny) {
|
|
1550
|
+
lines.push(theme.fg("muted", "No prompts available on connected servers."));
|
|
1551
|
+
lines.push("");
|
|
1552
|
+
}
|
|
1553
|
+
this.#showMessage(lines.join("\n"));
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Handle /mcp notifications - Show notification and subscription state
|
|
1558
|
+
*/
|
|
1559
|
+
async #handleNotifications(): Promise<void> {
|
|
1560
|
+
if (!this.ctx.mcpManager) {
|
|
1561
|
+
this.ctx.showError("No MCP manager available.");
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
const { enabled, subscriptions } = this.ctx.mcpManager.getNotificationState();
|
|
1566
|
+
const servers = this.ctx.mcpManager.getConnectedServers();
|
|
1567
|
+
const statusIcon = enabled ? theme.fg("success", "enabled") : theme.fg("warning", "disabled");
|
|
1568
|
+
const lines: string[] = ["", theme.bold("MCP Notifications"), ""];
|
|
1569
|
+
lines.push(` Status: ${statusIcon} ${theme.fg("dim", "(mcp.notifications setting)")}`);
|
|
1570
|
+
lines.push("");
|
|
1571
|
+
|
|
1572
|
+
let hasAny = false;
|
|
1573
|
+
for (const name of servers) {
|
|
1574
|
+
const connection = this.ctx.mcpManager.getConnection(name);
|
|
1575
|
+
if (!connection) continue;
|
|
1576
|
+
const caps = connection.capabilities;
|
|
1577
|
+
const supportsResources = caps.resources !== undefined;
|
|
1578
|
+
const supportsSubscribe = caps.resources?.subscribe === true;
|
|
1579
|
+
const supportsToolsChanged = caps.tools?.listChanged === true;
|
|
1580
|
+
const supportsPromptsChanged = caps.prompts?.listChanged === true;
|
|
1581
|
+
const supportsResourcesChanged = caps.resources?.listChanged === true;
|
|
1582
|
+
|
|
1583
|
+
const hasNotifications =
|
|
1584
|
+
supportsToolsChanged || supportsPromptsChanged || supportsResourcesChanged || supportsSubscribe;
|
|
1585
|
+
if (!hasNotifications) continue;
|
|
1586
|
+
hasAny = true;
|
|
1587
|
+
|
|
1588
|
+
lines.push(`${theme.fg("accent", name)}:`);
|
|
1589
|
+
const check = theme.fg("success", "✓");
|
|
1590
|
+
const cross = theme.fg("dim", "✗");
|
|
1591
|
+
if (supportsToolsChanged) lines.push(` ${check} tools/list_changed`);
|
|
1592
|
+
if (supportsResourcesChanged) lines.push(` ${check} resources/list_changed`);
|
|
1593
|
+
if (supportsPromptsChanged) lines.push(` ${check} prompts/list_changed`);
|
|
1594
|
+
|
|
1595
|
+
if (supportsSubscribe) {
|
|
1596
|
+
const subscribedUris = subscriptions.get(name);
|
|
1597
|
+
const subCount = subscribedUris?.size ?? 0;
|
|
1598
|
+
const subStatus =
|
|
1599
|
+
enabled && subCount > 0
|
|
1600
|
+
? theme.fg("success", `subscribed (${subCount} URI${subCount !== 1 ? "s" : ""})`)
|
|
1601
|
+
: enabled
|
|
1602
|
+
? theme.fg("muted", "no active subscriptions")
|
|
1603
|
+
: theme.fg("dim", "inactive (notifications disabled)");
|
|
1604
|
+
lines.push(` ${check} resources/subscribe ${subStatus}`);
|
|
1605
|
+
if (enabled && subscribedUris && subscribedUris.size > 0) {
|
|
1606
|
+
for (const uri of subscribedUris) {
|
|
1607
|
+
lines.push(` ${theme.fg("success", "✓")} ${theme.fg("dim", uri)}`);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
} else if (supportsResources) {
|
|
1611
|
+
lines.push(` ${cross} resources/subscribe ${theme.fg("dim", "not supported")}`);
|
|
1612
|
+
}
|
|
1613
|
+
lines.push("");
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
if (!hasAny) {
|
|
1617
|
+
lines.push(theme.fg("muted", "No servers support notifications."));
|
|
1618
|
+
lines.push("");
|
|
1619
|
+
}
|
|
1620
|
+
this.#showMessage(lines.join("\n"));
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
async #validateSmitheryApiKey(apiKey: string): Promise<void> {
|
|
1624
|
+
await searchSmitheryRegistry("mcp", { limit: 1, apiKey });
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
async #promptSmitheryApiKey(promptLabel: string): Promise<string | null> {
|
|
1628
|
+
for (;;) {
|
|
1629
|
+
const input = await this.ctx.showHookInput(promptLabel);
|
|
1630
|
+
if (input === undefined) return null;
|
|
1631
|
+
const apiKey = input.trim();
|
|
1632
|
+
if (!apiKey) {
|
|
1633
|
+
this.ctx.showError("Smithery API key cannot be empty.");
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
try {
|
|
1637
|
+
await this.#validateSmitheryApiKey(apiKey);
|
|
1638
|
+
return apiKey;
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
this.ctx.showError(
|
|
1641
|
+
`Smithery API key validation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
async #handleSmitheryLoginWithApiKey(): Promise<boolean> {
|
|
1648
|
+
const apiKey = await this.#promptSmitheryApiKey("Smithery API key (Esc to cancel)");
|
|
1649
|
+
if (!apiKey) return false;
|
|
1650
|
+
await saveSmitheryApiKey(apiKey);
|
|
1651
|
+
this.ctx.showStatus("Smithery API key saved.");
|
|
1652
|
+
return true;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
async #waitForSmitheryCliApiKey(sessionId: string, signal: AbortSignal): Promise<string> {
|
|
1656
|
+
const pollIntervalMs = 2_000;
|
|
1657
|
+
const timeoutMs = 300_000;
|
|
1658
|
+
const startedAt = Date.now();
|
|
1659
|
+
|
|
1660
|
+
while (!signal.aborted) {
|
|
1661
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
1662
|
+
throw new Error("Smithery authorization timed out after 5 minutes.");
|
|
1663
|
+
}
|
|
1664
|
+
const response = await pollSmitheryCliAuthSession(sessionId, signal);
|
|
1665
|
+
if (response.status === "success" && response.apiKey) {
|
|
1666
|
+
return response.apiKey;
|
|
1667
|
+
}
|
|
1668
|
+
if (response.status === "error") {
|
|
1669
|
+
throw new Error(response.message ?? "Smithery authorization failed.");
|
|
1670
|
+
}
|
|
1671
|
+
await Bun.sleep(pollIntervalMs);
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
throw new Error("Smithery authorization cancelled.");
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
async #handleSmitheryBrowserLogin(): Promise<boolean> {
|
|
1678
|
+
const session = await createSmitheryCliAuthSession();
|
|
1679
|
+
const fallbackLoginUrl = getSmitheryLoginUrl();
|
|
1680
|
+
this.#showMessage(
|
|
1681
|
+
[
|
|
1682
|
+
"",
|
|
1683
|
+
theme.bold("Smithery Login"),
|
|
1684
|
+
theme.fg("muted", "Browser authorization started. Complete auth in your browser."),
|
|
1685
|
+
theme.fg("dim", "Authorize URL:"),
|
|
1686
|
+
theme.fg("accent", session.authUrl),
|
|
1687
|
+
theme.fg("dim", `Fallback: ${fallbackLoginUrl}`),
|
|
1688
|
+
"",
|
|
1689
|
+
].join("\n"),
|
|
1690
|
+
);
|
|
1691
|
+
try {
|
|
1692
|
+
openPath(session.authUrl);
|
|
1693
|
+
} catch {
|
|
1694
|
+
// URL is already shown above.
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
const apiKey = await this.#waitForSmitheryCliApiKey(session.sessionId, new AbortController().signal);
|
|
1698
|
+
await this.#validateSmitheryApiKey(apiKey);
|
|
1699
|
+
await saveSmitheryApiKey(apiKey);
|
|
1700
|
+
this.ctx.showStatus("Smithery API key saved.");
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
async #promptSmitheryLogin(reason: string): Promise<boolean> {
|
|
1705
|
+
this.#showMessage(
|
|
1706
|
+
[
|
|
1707
|
+
"",
|
|
1708
|
+
theme.fg("muted", `Smithery authentication required (${reason}).`),
|
|
1709
|
+
theme.fg("muted", "If browser auth fails, you can paste an API key."),
|
|
1710
|
+
"",
|
|
1711
|
+
].join("\n"),
|
|
1712
|
+
);
|
|
1713
|
+
try {
|
|
1714
|
+
return await this.#handleSmitheryBrowserLogin();
|
|
1715
|
+
} catch (error) {
|
|
1716
|
+
this.ctx.showWarning(
|
|
1717
|
+
`Browser authorization failed: ${error instanceof Error ? error.message : String(error)}. Falling back to API key.`,
|
|
1718
|
+
);
|
|
1719
|
+
return await this.#handleSmitheryLoginWithApiKey();
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
#getSmitheryErrorStatus(error: unknown): number | undefined {
|
|
1724
|
+
if (error instanceof SmitheryRegistryError || error instanceof SmitheryConnectError) {
|
|
1725
|
+
return error.status;
|
|
1726
|
+
}
|
|
1727
|
+
return undefined;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
#toSmitheryAuthReason(status: number): string {
|
|
1731
|
+
return status === 429 ? "rate limited by Smithery" : "forbidden/unauthorized with Smithery";
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
async #requireSmitheryApiKey(reason: string): Promise<string> {
|
|
1735
|
+
let apiKey = await getSmitheryApiKey();
|
|
1736
|
+
if (apiKey) return apiKey;
|
|
1737
|
+
|
|
1738
|
+
const loggedIn = await this.#promptSmitheryLogin(reason);
|
|
1739
|
+
if (!loggedIn) {
|
|
1740
|
+
throw new Error("Smithery login cancelled. Run /mcp smithery-login, then retry /mcp smithery-search.");
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
apiKey = await getSmitheryApiKey();
|
|
1744
|
+
if (!apiKey) {
|
|
1745
|
+
throw new Error("Smithery API key not found after login.");
|
|
1746
|
+
}
|
|
1747
|
+
return apiKey;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
async #runSmitheryOperationWithAuthRetry<T>(operation: (apiKey: string) => Promise<T>, reason: string): Promise<T> {
|
|
1751
|
+
const apiKey = await this.#requireSmitheryApiKey(reason);
|
|
1752
|
+
try {
|
|
1753
|
+
return await operation(apiKey);
|
|
1754
|
+
} catch (error) {
|
|
1755
|
+
const status = this.#getSmitheryErrorStatus(error);
|
|
1756
|
+
if (status === undefined || ![401, 403, 429].includes(status)) {
|
|
1757
|
+
throw error;
|
|
1758
|
+
}
|
|
1759
|
+
const loggedIn = await this.#promptSmitheryLogin(this.#toSmitheryAuthReason(status));
|
|
1760
|
+
if (!loggedIn) {
|
|
1761
|
+
throw error;
|
|
1762
|
+
}
|
|
1763
|
+
const retryApiKey = await this.#requireSmitheryApiKey(reason);
|
|
1764
|
+
return await operation(retryApiKey);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
async #handleSmitheryLogin(): Promise<void> {
|
|
1769
|
+
const ok = await this.#promptSmitheryLogin("login");
|
|
1770
|
+
if (!ok) {
|
|
1771
|
+
this.ctx.showStatus("Smithery login cancelled.");
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
async #handleSmitheryLogout(): Promise<void> {
|
|
1776
|
+
const removed = await clearSmitheryApiKey();
|
|
1777
|
+
this.ctx.showStatus(removed ? "Smithery API key removed." : "No cached Smithery API key found.");
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
async #nextAvailableServerName(scope: MCPAddScope, baseName: string): Promise<string> {
|
|
1781
|
+
const filePath = getMCPConfigPath(scope, getProjectDir());
|
|
1782
|
+
const config = await readMCPConfigFile(filePath);
|
|
1783
|
+
const existingNames = new Set(Object.keys(config.mcpServers ?? {}));
|
|
1784
|
+
if (!existingNames.has(baseName)) return baseName;
|
|
1785
|
+
for (let i = 2; i <= 999; i++) {
|
|
1786
|
+
const candidate = `${baseName}-${i}`;
|
|
1787
|
+
if (!existingNames.has(candidate)) return candidate;
|
|
1788
|
+
}
|
|
1789
|
+
return `${baseName}-${Date.now()}`;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
async #promptDeploymentServerName(scope: MCPAddScope, defaultName: string): Promise<string | null> {
|
|
1793
|
+
for (;;) {
|
|
1794
|
+
const input = await this.ctx.showHookInput(`Server name for deploy (default: ${defaultName})`, defaultName);
|
|
1795
|
+
if (input === undefined) return null;
|
|
1796
|
+
const proposed = input.trim() || defaultName;
|
|
1797
|
+
if (!proposed) {
|
|
1798
|
+
this.ctx.showError("Server name cannot be empty.");
|
|
1799
|
+
continue;
|
|
1800
|
+
}
|
|
1801
|
+
const filePath = getMCPConfigPath(scope, getProjectDir());
|
|
1802
|
+
const config = await readMCPConfigFile(filePath);
|
|
1803
|
+
if (config.mcpServers?.[proposed]) {
|
|
1804
|
+
this.ctx.showError(`Server "${proposed}" already exists in ${scope} config.`);
|
|
1805
|
+
continue;
|
|
1806
|
+
}
|
|
1807
|
+
return proposed;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
async #promptRequiredRegistryInputs(result: SmitherySearchResult): Promise<Record<string, string> | null> {
|
|
1812
|
+
const values: Record<string, string> = {};
|
|
1813
|
+
for (const input of result.requiredInputs) {
|
|
1814
|
+
const label = input.required ? `${input.key} (required)` : `${input.key} (optional)`;
|
|
1815
|
+
const prompt = `${label}${input.description ? ` - ${input.description}` : ""}`;
|
|
1816
|
+
const userInput = await this.ctx.showHookInput(prompt, input.defaultValue);
|
|
1817
|
+
if (userInput === undefined) {
|
|
1818
|
+
if (input.required) return null;
|
|
1819
|
+
continue;
|
|
1820
|
+
}
|
|
1821
|
+
const value = userInput.trim();
|
|
1822
|
+
if (!value) {
|
|
1823
|
+
if (input.required) {
|
|
1824
|
+
this.ctx.showError(`Missing required value for "${input.key}".`);
|
|
1825
|
+
return null;
|
|
1826
|
+
}
|
|
1827
|
+
continue;
|
|
1828
|
+
}
|
|
1829
|
+
values[input.key] = value;
|
|
1830
|
+
}
|
|
1831
|
+
return values;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
#applyRegistryInputOverrides(config: MCPServerConfig, values: Record<string, string>): MCPServerConfig {
|
|
1835
|
+
if (Object.keys(values).length === 0) return config;
|
|
1836
|
+
if (config.type !== "stdio") {
|
|
1837
|
+
return config;
|
|
1838
|
+
}
|
|
1839
|
+
const args = [...(config.args ?? [])];
|
|
1840
|
+
const configJson = JSON.stringify(values);
|
|
1841
|
+
const index = args.indexOf("--config");
|
|
1842
|
+
if (index >= 0) {
|
|
1843
|
+
if (index + 1 < args.length) {
|
|
1844
|
+
args[index + 1] = configJson;
|
|
1845
|
+
} else {
|
|
1846
|
+
args.push(configJson);
|
|
1847
|
+
}
|
|
1848
|
+
} else {
|
|
1849
|
+
args.push("--config", configJson);
|
|
1850
|
+
}
|
|
1851
|
+
return { ...config, args };
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
async #pickRegistryResult(results: SmitherySearchResult[], keyword: string): Promise<SmitherySearchResult | null> {
|
|
1855
|
+
const options = results.map((result, index) => {
|
|
1856
|
+
const label = `${index + 1}. ${result.display.displayName} (${result.display.transport}, uses ${result.display.useCount})`;
|
|
1857
|
+
return label.length > 120 ? `${label.slice(0, 117)}...` : label;
|
|
1858
|
+
});
|
|
1859
|
+
const selected = await this.ctx.showHookSelector(`Registry results for "${keyword}"`, options);
|
|
1860
|
+
if (!selected) return null;
|
|
1861
|
+
const prefix = selected.split(".", 1)[0];
|
|
1862
|
+
const index = Number(prefix) - 1;
|
|
1863
|
+
if (!Number.isInteger(index) || index < 0 || index >= results.length) return null;
|
|
1864
|
+
return results[index] ?? null;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
async #deployRegistryResult(result: SmitherySearchResult, scope: MCPAddScope): Promise<void> {
|
|
1868
|
+
const baseName = toConfigName(result.name);
|
|
1869
|
+
const defaultName = await this.#nextAvailableServerName(scope, baseName);
|
|
1870
|
+
const serverName = await this.#promptDeploymentServerName(scope, defaultName);
|
|
1871
|
+
if (!serverName) {
|
|
1872
|
+
this.ctx.showStatus("MCP deploy cancelled.");
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
const inputValues = await this.#promptRequiredRegistryInputs(result);
|
|
1876
|
+
if (inputValues === null) {
|
|
1877
|
+
this.ctx.showStatus("MCP deploy cancelled.");
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
const config = this.#applyRegistryInputOverrides(result.config, inputValues);
|
|
1881
|
+
await this.#handleWizardComplete(serverName, config, scope);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
async #handleSearch(text: string): Promise<void> {
|
|
1885
|
+
const parsed = this.#parseSearchCommand(text);
|
|
1886
|
+
if (parsed.error) {
|
|
1887
|
+
this.ctx.showError(parsed.error);
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
try {
|
|
1892
|
+
this.#showMessage(
|
|
1893
|
+
["", theme.fg("muted", `Searching Smithery registry for "${parsed.keyword}"...`), ""].join("\n"),
|
|
1894
|
+
);
|
|
1895
|
+
const results = await this.#runSmitheryOperationWithAuthRetry(
|
|
1896
|
+
apiKey =>
|
|
1897
|
+
searchSmitheryRegistry(parsed.keyword, {
|
|
1898
|
+
limit: parsed.limit,
|
|
1899
|
+
apiKey,
|
|
1900
|
+
includeSemantic: parsed.semantic,
|
|
1901
|
+
}),
|
|
1902
|
+
"required for smithery-search",
|
|
1903
|
+
);
|
|
1904
|
+
if (results.length === 0) {
|
|
1905
|
+
this.#showMessage(
|
|
1906
|
+
["", theme.fg("warning", `No Smithery results found for "${parsed.keyword}".`), ""].join("\n"),
|
|
1907
|
+
);
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
const selected = await this.#pickRegistryResult(results, parsed.keyword);
|
|
1912
|
+
if (!selected) {
|
|
1913
|
+
this.ctx.showStatus("MCP Smithery selection cancelled.");
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
await this.#deployRegistryResult(selected, parsed.scope);
|
|
1918
|
+
} catch (error) {
|
|
1919
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1920
|
+
if (/authentication was cancelled|login cancelled/i.test(message)) {
|
|
1921
|
+
this.ctx.showError(`${message} Run /mcp smithery-login to authenticate first.`);
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
this.ctx.showError(`Smithery search failed: ${message}`);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
/**
|
|
1929
|
+
* Show a message in the chat
|
|
1930
|
+
*/
|
|
1931
|
+
#showMessage(text: string): void {
|
|
1932
|
+
showCommandMessage(this.ctx, text);
|
|
1933
|
+
}
|
|
1934
|
+
}
|