@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,2409 @@
|
|
|
1
|
+
import type { FileDiagnosticsResult } from "../lsp";
|
|
2
|
+
import { snapshotEqual, type VimBuffer } from "./buffer";
|
|
3
|
+
import { parseExCommand } from "./commands";
|
|
4
|
+
import { replayTokens } from "./parser";
|
|
5
|
+
import type {
|
|
6
|
+
Position,
|
|
7
|
+
VimBufferSnapshot,
|
|
8
|
+
VimInputMode,
|
|
9
|
+
VimKeyToken,
|
|
10
|
+
VimLineRange,
|
|
11
|
+
VimLoadedFile,
|
|
12
|
+
VimPendingInput,
|
|
13
|
+
VimRegister,
|
|
14
|
+
VimSearchState,
|
|
15
|
+
VimSelection,
|
|
16
|
+
VimUndoEntry,
|
|
17
|
+
} from "./types";
|
|
18
|
+
import { clonePosition, maxPosition, minPosition, toPublicMode, VimInputError as VimError } from "./types";
|
|
19
|
+
|
|
20
|
+
export interface VimSaveResult {
|
|
21
|
+
loaded: VimLoadedFile;
|
|
22
|
+
diagnostics?: FileDiagnosticsResult;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface VimEngineCallbacks {
|
|
26
|
+
beforeMutate: (buffer: VimBuffer) => Promise<void>;
|
|
27
|
+
loadBuffer: (path: string) => Promise<VimLoadedFile>;
|
|
28
|
+
saveBuffer: (buffer: VimBuffer, options?: { force?: boolean }) => Promise<VimSaveResult>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface PendingChange {
|
|
32
|
+
before: VimBufferSnapshot;
|
|
33
|
+
tokens: string[];
|
|
34
|
+
moveCursorLeftOnEscape: boolean;
|
|
35
|
+
inserted: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface MotionResult {
|
|
39
|
+
nextIndex: number;
|
|
40
|
+
target: Position;
|
|
41
|
+
inclusive?: boolean;
|
|
42
|
+
linewise?: boolean;
|
|
43
|
+
range?: { start: number; end: number; linewise?: boolean };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const WORD_CHAR = /[A-Za-z0-9_]/;
|
|
47
|
+
const DEFAULT_VIEWPORT_HEIGHT = 10;
|
|
48
|
+
const BRACKET_PAIRS = new Map<string, string>([
|
|
49
|
+
["(", ")"],
|
|
50
|
+
["[", "]"],
|
|
51
|
+
["{", "}"],
|
|
52
|
+
["<", ">"],
|
|
53
|
+
]);
|
|
54
|
+
const CLOSING_BRACKETS = new Map<string, string>(
|
|
55
|
+
Array.from(BRACKET_PAIRS.entries()).map(([open, close]) => [close, open]),
|
|
56
|
+
);
|
|
57
|
+
const NOOP_Z_COMMANDS = new Set(["a", "A", "c", "C", "m", "M", "o", "O", "r", "R", "v", "x", "X"]);
|
|
58
|
+
|
|
59
|
+
function escapeRegex(value: string): string {
|
|
60
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isWhitespace(char: string): boolean {
|
|
64
|
+
return /\s/.test(char);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isWordChar(char: string): boolean {
|
|
68
|
+
return WORD_CHAR.test(char);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function wordCategory(char: string, bigWord: boolean): "space" | "word" | "punct" {
|
|
72
|
+
if (char.length === 0 || isWhitespace(char)) {
|
|
73
|
+
return "space";
|
|
74
|
+
}
|
|
75
|
+
if (bigWord) {
|
|
76
|
+
return "word";
|
|
77
|
+
}
|
|
78
|
+
return isWordChar(char) ? "word" : "punct";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function decodeReplacement(replacement: string): string {
|
|
82
|
+
return replacement.replace(/\\\//g, "/").replace(/\\\\/g, "\\");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function literalTextToReplayTokens(text: string): string[] {
|
|
86
|
+
const tokens: string[] = [];
|
|
87
|
+
for (const char of text) {
|
|
88
|
+
if (char === "\n") {
|
|
89
|
+
tokens.push("CR");
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (char === "\t") {
|
|
93
|
+
tokens.push("Tab");
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
tokens.push(char);
|
|
97
|
+
}
|
|
98
|
+
return tokens;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Convert a vim-style search pattern to a JavaScript RegExp.
|
|
102
|
+
// In vim's default ("magic") mode, (, ), {, }, |, + are literal unless backslash-escaped.
|
|
103
|
+
// In JS regex these are metacharacters. Swap the escaping so bare chars are literal
|
|
104
|
+
// and \( etc. become regex groups.
|
|
105
|
+
function vimPatternToJsRegex(pattern: string): string {
|
|
106
|
+
return pattern.replace(/\\([(){}|+])|([(){}|+])/g, (_match, escaped, bare) => {
|
|
107
|
+
if (escaped) return escaped; // \( -> ( (regex group)
|
|
108
|
+
return `\\${bare}`; // ( -> \( (literal paren)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function createSearchRegex(pattern: string, flags = "g"): RegExp {
|
|
113
|
+
try {
|
|
114
|
+
return new RegExp(vimPatternToJsRegex(pattern), flags);
|
|
115
|
+
} catch {
|
|
116
|
+
return new RegExp(escapeRegex(pattern), flags);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function detectIndentUnit(lines: string[]): string {
|
|
121
|
+
for (const line of lines) {
|
|
122
|
+
if (line.startsWith("\t")) {
|
|
123
|
+
return "\t";
|
|
124
|
+
}
|
|
125
|
+
if (line.startsWith(" ")) {
|
|
126
|
+
return " ";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return "\t";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function normalizeRange(start: number, end: number): { start: number; end: number } {
|
|
133
|
+
return {
|
|
134
|
+
start: Math.min(start, end),
|
|
135
|
+
end: Math.max(start, end),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function selectionFromAnchor(buffer: VimBuffer, anchor: Position, linewise: boolean): VimSelection {
|
|
140
|
+
if (linewise) {
|
|
141
|
+
const startLine = Math.min(anchor.line, buffer.cursor.line);
|
|
142
|
+
const endLine = Math.max(anchor.line, buffer.cursor.line);
|
|
143
|
+
return {
|
|
144
|
+
kind: "line",
|
|
145
|
+
start: { line: startLine + 1, col: 1 },
|
|
146
|
+
end: { line: endLine + 1, col: buffer.getLine(endLine).length + 1 },
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const start = minPosition(anchor, buffer.cursor);
|
|
150
|
+
const end = maxPosition(anchor, buffer.cursor);
|
|
151
|
+
return {
|
|
152
|
+
kind: "char",
|
|
153
|
+
start: { line: start.line + 1, col: start.col + 1 },
|
|
154
|
+
end: { line: end.line + 1, col: end.col + 1 },
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function expandVisualOffsets(
|
|
159
|
+
buffer: VimBuffer,
|
|
160
|
+
anchor: Position,
|
|
161
|
+
linewise: boolean,
|
|
162
|
+
): { start: number; end: number; linewise: boolean } {
|
|
163
|
+
if (linewise) {
|
|
164
|
+
const startLine = Math.min(anchor.line, buffer.cursor.line);
|
|
165
|
+
const endLine = Math.max(anchor.line, buffer.cursor.line);
|
|
166
|
+
const startOffset = buffer.positionToOffset({ line: startLine, col: 0 });
|
|
167
|
+
const endOffset =
|
|
168
|
+
endLine >= buffer.lastLineIndex()
|
|
169
|
+
? buffer.getText().length
|
|
170
|
+
: buffer.positionToOffset({ line: endLine + 1, col: 0 });
|
|
171
|
+
return { start: startOffset, end: endOffset, linewise: true };
|
|
172
|
+
}
|
|
173
|
+
const anchorOffset = buffer.positionToOffset(anchor);
|
|
174
|
+
const cursorOffset = buffer.positionToOffset(buffer.cursor);
|
|
175
|
+
const { start, end } = normalizeRange(anchorOffset, cursorOffset);
|
|
176
|
+
return { start, end: end + 1, linewise: false };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function nextWordStart(text: string, offset: number, bigWord: boolean): number {
|
|
180
|
+
let index = Math.min(Math.max(offset, 0), text.length);
|
|
181
|
+
if (index >= text.length) {
|
|
182
|
+
return text.length;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const currentCategory = wordCategory(text[index] ?? "", bigWord);
|
|
186
|
+
if (currentCategory === "space") {
|
|
187
|
+
while (index < text.length && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
188
|
+
index += 1;
|
|
189
|
+
}
|
|
190
|
+
return index;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
while (index < text.length && wordCategory(text[index] ?? "", bigWord) === currentCategory) {
|
|
194
|
+
index += 1;
|
|
195
|
+
}
|
|
196
|
+
while (index < text.length && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
197
|
+
index += 1;
|
|
198
|
+
}
|
|
199
|
+
return index;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function previousWordStart(text: string, offset: number, bigWord: boolean): number {
|
|
203
|
+
let index = Math.min(Math.max(offset - 1, 0), text.length);
|
|
204
|
+
while (index > 0 && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
205
|
+
index -= 1;
|
|
206
|
+
}
|
|
207
|
+
const category = wordCategory(text[index] ?? "", bigWord);
|
|
208
|
+
while (index > 0 && wordCategory(text[index - 1] ?? "", bigWord) === category) {
|
|
209
|
+
index -= 1;
|
|
210
|
+
}
|
|
211
|
+
return index;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function endOfWord(text: string, offset: number, bigWord: boolean): number {
|
|
215
|
+
let index = Math.min(Math.max(offset, 0), text.length);
|
|
216
|
+
while (index < text.length && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
217
|
+
index += 1;
|
|
218
|
+
}
|
|
219
|
+
const category = wordCategory(text[index] ?? "", bigWord);
|
|
220
|
+
while (index < text.length && wordCategory(text[index] ?? "", bigWord) === category) {
|
|
221
|
+
index += 1;
|
|
222
|
+
}
|
|
223
|
+
return Math.max(0, index - 1);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function endOfPreviousWord(text: string, offset: number, bigWord: boolean): number {
|
|
227
|
+
if (text.length === 0) {
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let index = Math.min(Math.max(offset - 1, 0), text.length - 1);
|
|
232
|
+
while (index >= 0 && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
233
|
+
index -= 1;
|
|
234
|
+
}
|
|
235
|
+
if (index < 0) {
|
|
236
|
+
return 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const currentCategory = wordCategory(text[index] ?? "", bigWord);
|
|
240
|
+
while (index >= 0 && wordCategory(text[index] ?? "", bigWord) === currentCategory) {
|
|
241
|
+
index -= 1;
|
|
242
|
+
}
|
|
243
|
+
while (index >= 0 && wordCategory(text[index] ?? "", bigWord) === "space") {
|
|
244
|
+
index -= 1;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return Math.max(0, index);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function toggleCase(text: string): string {
|
|
251
|
+
let toggled = "";
|
|
252
|
+
for (const char of text) {
|
|
253
|
+
if (char >= "a" && char <= "z") {
|
|
254
|
+
toggled += char.toUpperCase();
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (char >= "A" && char <= "Z") {
|
|
258
|
+
toggled += char.toLowerCase();
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
toggled += char;
|
|
262
|
+
}
|
|
263
|
+
return toggled;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function lastNonBlankColumn(line: string): number {
|
|
267
|
+
for (let index = line.length - 1; index >= 0; index -= 1) {
|
|
268
|
+
if (!isWhitespace(line[index] ?? "")) {
|
|
269
|
+
return index;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function findParagraphStart(lines: string[], line: number): number {
|
|
276
|
+
let index = Math.max(0, line - 1);
|
|
277
|
+
while (index > 0 && lines[index]!.trim().length > 0) {
|
|
278
|
+
index -= 1;
|
|
279
|
+
}
|
|
280
|
+
while (index > 0 && lines[index - 1]!.trim().length === 0) {
|
|
281
|
+
index -= 1;
|
|
282
|
+
}
|
|
283
|
+
return index;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function findParagraphEnd(lines: string[], line: number): number {
|
|
287
|
+
let index = Math.min(lines.length - 1, line + 1);
|
|
288
|
+
while (index < lines.length - 1 && lines[index]!.trim().length > 0) {
|
|
289
|
+
index += 1;
|
|
290
|
+
}
|
|
291
|
+
while (index < lines.length - 1 && lines[index + 1]!.trim().length === 0) {
|
|
292
|
+
index += 1;
|
|
293
|
+
}
|
|
294
|
+
return index;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function cloneUndoStack(stack: VimUndoEntry[]): VimUndoEntry[] {
|
|
298
|
+
return stack.map(entry => ({
|
|
299
|
+
before: {
|
|
300
|
+
...entry.before,
|
|
301
|
+
lines: [...entry.before.lines],
|
|
302
|
+
cursor: clonePosition(entry.before.cursor),
|
|
303
|
+
baseFingerprint: entry.before.baseFingerprint ? { ...entry.before.baseFingerprint } : null,
|
|
304
|
+
},
|
|
305
|
+
after: {
|
|
306
|
+
...entry.after,
|
|
307
|
+
lines: [...entry.after.lines],
|
|
308
|
+
cursor: clonePosition(entry.after.cursor),
|
|
309
|
+
baseFingerprint: entry.after.baseFingerprint ? { ...entry.after.baseFingerprint } : null,
|
|
310
|
+
},
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export class VimEngine {
|
|
315
|
+
buffer: VimBuffer;
|
|
316
|
+
inputMode: VimInputMode = "normal";
|
|
317
|
+
selectionAnchor: Position | null = null;
|
|
318
|
+
register: VimRegister = { kind: "char", text: "" };
|
|
319
|
+
lastSearch: VimSearchState | null = null;
|
|
320
|
+
lastCharFind: { char: string; mode: "f" | "F" | "t" | "T" } | null = null;
|
|
321
|
+
lastVisual: { anchor: Position; cursor: Position; mode: VimInputMode } | null = null;
|
|
322
|
+
lastCommand?: string;
|
|
323
|
+
statusMessage?: string;
|
|
324
|
+
diagnostics?: FileDiagnosticsResult;
|
|
325
|
+
viewportStart = 1;
|
|
326
|
+
closed = false;
|
|
327
|
+
|
|
328
|
+
#callbacks: VimEngineCallbacks;
|
|
329
|
+
#undoStack: VimUndoEntry[] = [];
|
|
330
|
+
#redoStack: VimUndoEntry[] = [];
|
|
331
|
+
#pendingInput = "";
|
|
332
|
+
#lastChangeTokens: string[] | null = null;
|
|
333
|
+
#pendingChange: PendingChange | null = null;
|
|
334
|
+
#stepCallback?: () => Promise<void>;
|
|
335
|
+
|
|
336
|
+
constructor(buffer: VimBuffer, callbacks: VimEngineCallbacks) {
|
|
337
|
+
this.buffer = buffer;
|
|
338
|
+
this.#callbacks = callbacks;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
clone(callbacks?: Partial<VimEngineCallbacks>): VimEngine {
|
|
342
|
+
const next = new VimEngine(this.buffer.clone(), {
|
|
343
|
+
beforeMutate: callbacks?.beforeMutate ?? this.#callbacks.beforeMutate,
|
|
344
|
+
loadBuffer: callbacks?.loadBuffer ?? this.#callbacks.loadBuffer,
|
|
345
|
+
saveBuffer: callbacks?.saveBuffer ?? this.#callbacks.saveBuffer,
|
|
346
|
+
});
|
|
347
|
+
next.inputMode = this.inputMode;
|
|
348
|
+
next.selectionAnchor = this.selectionAnchor ? clonePosition(this.selectionAnchor) : null;
|
|
349
|
+
next.register = { ...this.register };
|
|
350
|
+
next.lastSearch = this.lastSearch ? { ...this.lastSearch } : null;
|
|
351
|
+
next.lastCharFind = this.lastCharFind ? { ...this.lastCharFind } : null;
|
|
352
|
+
next.lastVisual = this.lastVisual
|
|
353
|
+
? {
|
|
354
|
+
anchor: clonePosition(this.lastVisual.anchor),
|
|
355
|
+
cursor: clonePosition(this.lastVisual.cursor),
|
|
356
|
+
mode: this.lastVisual.mode,
|
|
357
|
+
}
|
|
358
|
+
: null;
|
|
359
|
+
next.lastCommand = this.lastCommand;
|
|
360
|
+
next.statusMessage = this.statusMessage;
|
|
361
|
+
next.diagnostics = this.diagnostics;
|
|
362
|
+
next.viewportStart = this.viewportStart;
|
|
363
|
+
next.closed = this.closed;
|
|
364
|
+
next.#pendingInput = this.#pendingInput;
|
|
365
|
+
next.#lastChangeTokens = this.#lastChangeTokens ? [...this.#lastChangeTokens] : null;
|
|
366
|
+
next.#pendingChange = this.#pendingChange
|
|
367
|
+
? {
|
|
368
|
+
before: {
|
|
369
|
+
...this.#pendingChange.before,
|
|
370
|
+
lines: [...this.#pendingChange.before.lines],
|
|
371
|
+
cursor: clonePosition(this.#pendingChange.before.cursor),
|
|
372
|
+
baseFingerprint: this.#pendingChange.before.baseFingerprint
|
|
373
|
+
? { ...this.#pendingChange.before.baseFingerprint }
|
|
374
|
+
: null,
|
|
375
|
+
},
|
|
376
|
+
tokens: [...this.#pendingChange.tokens],
|
|
377
|
+
moveCursorLeftOnEscape: this.#pendingChange.moveCursorLeftOnEscape,
|
|
378
|
+
inserted: this.#pendingChange.inserted,
|
|
379
|
+
}
|
|
380
|
+
: null;
|
|
381
|
+
next.#undoStack = cloneUndoStack(this.#undoStack);
|
|
382
|
+
next.#redoStack = cloneUndoStack(this.#redoStack);
|
|
383
|
+
return next;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
getPublicMode() {
|
|
387
|
+
return toPublicMode(this.inputMode);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
getSelection(): VimSelection | undefined {
|
|
391
|
+
if (this.selectionAnchor === null) {
|
|
392
|
+
return undefined;
|
|
393
|
+
}
|
|
394
|
+
return selectionFromAnchor(this.buffer, this.selectionAnchor, this.inputMode === "visual-line");
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
getPendingInput(): VimPendingInput | undefined {
|
|
398
|
+
switch (this.inputMode) {
|
|
399
|
+
case "insert":
|
|
400
|
+
return { kind: "insert", text: "" };
|
|
401
|
+
case "command":
|
|
402
|
+
case "search-forward":
|
|
403
|
+
case "search-backward":
|
|
404
|
+
return { kind: this.inputMode, text: this.#pendingInput };
|
|
405
|
+
default:
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
rollbackPendingInsert(): void {
|
|
411
|
+
if (this.#pendingChange) {
|
|
412
|
+
this.buffer.restore(this.#pendingChange.before);
|
|
413
|
+
this.#pendingChange = null;
|
|
414
|
+
}
|
|
415
|
+
this.inputMode = "normal";
|
|
416
|
+
this.selectionAnchor = null;
|
|
417
|
+
this.#pendingInput = "";
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
setCursor(line: number, col: number): void {
|
|
421
|
+
this.buffer.setCursor({ line, col });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async executeTokens(
|
|
425
|
+
tokens: readonly VimKeyToken[],
|
|
426
|
+
lastCommand?: string,
|
|
427
|
+
onStep?: () => Promise<void>,
|
|
428
|
+
): Promise<void> {
|
|
429
|
+
const previousStepCallback = this.#stepCallback;
|
|
430
|
+
this.#stepCallback = onStep ?? previousStepCallback;
|
|
431
|
+
this.lastCommand = lastCommand;
|
|
432
|
+
this.statusMessage = undefined;
|
|
433
|
+
this.diagnostics = undefined;
|
|
434
|
+
|
|
435
|
+
try {
|
|
436
|
+
for (let index = 0; index < tokens.length; ) {
|
|
437
|
+
switch (this.inputMode) {
|
|
438
|
+
case "insert":
|
|
439
|
+
index = await this.#executeInsert(tokens, index);
|
|
440
|
+
break;
|
|
441
|
+
case "command":
|
|
442
|
+
case "search-forward":
|
|
443
|
+
case "search-backward":
|
|
444
|
+
index = await this.#executePrompt(tokens, index);
|
|
445
|
+
break;
|
|
446
|
+
case "visual":
|
|
447
|
+
case "visual-line":
|
|
448
|
+
index = await this.#executeVisual(tokens, index);
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
index = await this.#executeNormal(tokens, index);
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
if (this.closed) {
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
this.#ensureCursorVisible();
|
|
458
|
+
await this.#stepCallback?.();
|
|
459
|
+
}
|
|
460
|
+
} finally {
|
|
461
|
+
this.#stepCallback = previousStepCallback;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async close(force: boolean): Promise<void> {
|
|
466
|
+
if (this.buffer.modified && !force) {
|
|
467
|
+
throw new VimError("Unsaved changes; use force to discard");
|
|
468
|
+
}
|
|
469
|
+
this.closed = true;
|
|
470
|
+
this.statusMessage = `Closed ${this.buffer.displayPath}`;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
#ensureCursorVisible(): void {
|
|
474
|
+
const line = this.buffer.cursor.line + 1;
|
|
475
|
+
if (line < this.viewportStart) {
|
|
476
|
+
this.viewportStart = line;
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const viewportEnd = this.viewportStart + DEFAULT_VIEWPORT_HEIGHT - 1;
|
|
480
|
+
if (line > viewportEnd) {
|
|
481
|
+
this.viewportStart = Math.max(1, line - DEFAULT_VIEWPORT_HEIGHT + 1);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
centerViewportOnCursor(size = DEFAULT_VIEWPORT_HEIGHT): void {
|
|
486
|
+
const lineCount = Math.max(this.buffer.lineCount(), 1);
|
|
487
|
+
const clampedSize = Math.max(1, Math.min(size, lineCount));
|
|
488
|
+
const maxStart = Math.max(1, lineCount - clampedSize + 1);
|
|
489
|
+
this.viewportStart = Math.max(1, Math.min(this.buffer.cursor.line + 1 - Math.floor(clampedSize / 2), maxStart));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
#clearSelection(): void {
|
|
493
|
+
if (this.selectionAnchor && (this.inputMode === "visual" || this.inputMode === "visual-line")) {
|
|
494
|
+
this.lastVisual = {
|
|
495
|
+
anchor: clonePosition(this.selectionAnchor),
|
|
496
|
+
cursor: clonePosition(this.buffer.cursor),
|
|
497
|
+
mode: this.inputMode,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
this.selectionAnchor = null;
|
|
501
|
+
if (this.inputMode === "visual" || this.inputMode === "visual-line") {
|
|
502
|
+
this.inputMode = "normal";
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
async #ensureEditable(): Promise<void> {
|
|
507
|
+
await this.#callbacks.beforeMutate(this.buffer);
|
|
508
|
+
this.diagnostics = undefined;
|
|
509
|
+
this.statusMessage = undefined;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
#pushUndo(entry: VimUndoEntry, changeTokens?: readonly string[]): void {
|
|
513
|
+
if (snapshotEqual(entry.before, entry.after)) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
this.#undoStack.push(entry);
|
|
517
|
+
this.#redoStack = [];
|
|
518
|
+
if (changeTokens && changeTokens.length > 0) {
|
|
519
|
+
this.#lastChangeTokens = [...changeTokens];
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
#beginPendingChange(prefixTokens: readonly string[], moveCursorLeftOnEscape: boolean): void {
|
|
524
|
+
this.#pendingChange = {
|
|
525
|
+
before: this.buffer.createSnapshot(),
|
|
526
|
+
tokens: [...prefixTokens],
|
|
527
|
+
moveCursorLeftOnEscape,
|
|
528
|
+
inserted: false,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
#markPendingInserted(): void {
|
|
533
|
+
if (this.#pendingChange) {
|
|
534
|
+
this.#pendingChange.inserted = true;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
#commitPendingChange(): void {
|
|
539
|
+
if (!this.#pendingChange) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const entry: VimUndoEntry = {
|
|
543
|
+
before: this.#pendingChange.before,
|
|
544
|
+
after: this.buffer.createSnapshot(),
|
|
545
|
+
};
|
|
546
|
+
this.#pushUndo(entry, this.#pendingChange.tokens);
|
|
547
|
+
this.#pendingChange = null;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
async #applyAtomicChange(tokens: readonly string[], mutator: () => void): Promise<void> {
|
|
551
|
+
await this.#ensureEditable();
|
|
552
|
+
const before = this.buffer.createSnapshot();
|
|
553
|
+
mutator();
|
|
554
|
+
this.buffer.modified = true;
|
|
555
|
+
this.#pushUndo({ before, after: this.buffer.createSnapshot() }, tokens);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
async #startInsertChange(
|
|
559
|
+
tokens: readonly string[],
|
|
560
|
+
mutator?: () => void,
|
|
561
|
+
moveCursorLeftOnEscape = true,
|
|
562
|
+
): Promise<void> {
|
|
563
|
+
await this.#ensureEditable();
|
|
564
|
+
this.#beginPendingChange(tokens, moveCursorLeftOnEscape);
|
|
565
|
+
mutator?.();
|
|
566
|
+
this.buffer.modified = true;
|
|
567
|
+
this.inputMode = "insert";
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
async #executePrompt(tokens: readonly VimKeyToken[], index: number): Promise<number> {
|
|
571
|
+
const token = tokens[index]!;
|
|
572
|
+
if (token.value === "Esc") {
|
|
573
|
+
this.#pendingInput = "";
|
|
574
|
+
this.inputMode = "normal";
|
|
575
|
+
return index + 1;
|
|
576
|
+
}
|
|
577
|
+
if (token.value === "BS") {
|
|
578
|
+
this.#pendingInput = this.#pendingInput.slice(0, -1);
|
|
579
|
+
return index + 1;
|
|
580
|
+
}
|
|
581
|
+
if (token.value !== "CR") {
|
|
582
|
+
this.#pendingInput += token.value === "Tab" ? "\t" : token.value;
|
|
583
|
+
return index + 1;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const input = this.#pendingInput;
|
|
587
|
+
this.#pendingInput = "";
|
|
588
|
+
const mode = this.inputMode;
|
|
589
|
+
this.inputMode = "normal";
|
|
590
|
+
if (mode === "command") {
|
|
591
|
+
await this.#executeEx(input);
|
|
592
|
+
} else {
|
|
593
|
+
await this.#runSearch(input, mode === "search-forward" ? 1 : -1, true);
|
|
594
|
+
}
|
|
595
|
+
return index + 1;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
#exitInsertMode(): void {
|
|
599
|
+
if (this.#pendingChange) {
|
|
600
|
+
this.#pendingChange.tokens.push("Esc");
|
|
601
|
+
if (this.#pendingChange.moveCursorLeftOnEscape && this.#pendingChange.inserted && this.buffer.cursor.col > 0) {
|
|
602
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line, col: this.buffer.cursor.col - 1 });
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
this.inputMode = "normal";
|
|
606
|
+
this.#commitPendingChange();
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
async applyLiteralInsert(text: string, exitInsertMode: boolean): Promise<void> {
|
|
610
|
+
if (this.inputMode !== "insert" || !this.#pendingChange) {
|
|
611
|
+
throw new VimError("Insert payload requires INSERT mode.");
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (text.length > 0) {
|
|
615
|
+
const offset = this.buffer.currentOffset();
|
|
616
|
+
this.buffer.replaceOffsets(offset, offset, text, offset + text.length);
|
|
617
|
+
this.buffer.modified = true;
|
|
618
|
+
if (text.includes("\n")) {
|
|
619
|
+
this.buffer.trailingNewline = this.buffer.trailingNewline || text.endsWith("\n");
|
|
620
|
+
}
|
|
621
|
+
this.#pendingChange.tokens.push(...literalTextToReplayTokens(text));
|
|
622
|
+
this.#markPendingInserted();
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if (exitInsertMode) {
|
|
626
|
+
this.#exitInsertMode();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
async #executeInsert(tokens: readonly VimKeyToken[], index: number): Promise<number> {
|
|
631
|
+
const token = tokens[index]!;
|
|
632
|
+
if (token.value === "Esc") {
|
|
633
|
+
this.#exitInsertMode();
|
|
634
|
+
return index + 1;
|
|
635
|
+
}
|
|
636
|
+
if (token.value === "CR") {
|
|
637
|
+
const offset = this.buffer.currentOffset();
|
|
638
|
+
this.buffer.replaceOffsets(offset, offset, "\n", offset + 1);
|
|
639
|
+
this.buffer.modified = true;
|
|
640
|
+
this.buffer.trailingNewline = true;
|
|
641
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
642
|
+
this.#markPendingInserted();
|
|
643
|
+
return index + 1;
|
|
644
|
+
}
|
|
645
|
+
if (token.value === "BS") {
|
|
646
|
+
const offset = this.buffer.currentOffset();
|
|
647
|
+
if (offset > 0) {
|
|
648
|
+
this.buffer.deleteOffsets(offset - 1, offset);
|
|
649
|
+
this.buffer.modified = true;
|
|
650
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
651
|
+
this.#markPendingInserted();
|
|
652
|
+
}
|
|
653
|
+
return index + 1;
|
|
654
|
+
}
|
|
655
|
+
if (token.value === "Tab") {
|
|
656
|
+
const offset = this.buffer.currentOffset();
|
|
657
|
+
this.buffer.replaceOffsets(offset, offset, "\t", offset + 1);
|
|
658
|
+
this.buffer.modified = true;
|
|
659
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
660
|
+
this.#markPendingInserted();
|
|
661
|
+
return index + 1;
|
|
662
|
+
}
|
|
663
|
+
if (token.value === "C-w") {
|
|
664
|
+
const offset = this.buffer.currentOffset();
|
|
665
|
+
const text = this.buffer.getText();
|
|
666
|
+
let start = previousWordStart(text, offset, false);
|
|
667
|
+
if (start === offset && start > 0) {
|
|
668
|
+
start -= 1;
|
|
669
|
+
}
|
|
670
|
+
this.buffer.deleteOffsets(start, offset);
|
|
671
|
+
this.buffer.modified = true;
|
|
672
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
673
|
+
this.#markPendingInserted();
|
|
674
|
+
return index + 1;
|
|
675
|
+
}
|
|
676
|
+
if (token.value === "C-u") {
|
|
677
|
+
const offset = this.buffer.currentOffset();
|
|
678
|
+
const lineStart = this.buffer.positionToOffset({ line: this.buffer.cursor.line, col: 0 });
|
|
679
|
+
if (offset > lineStart) {
|
|
680
|
+
this.buffer.deleteOffsets(lineStart, offset);
|
|
681
|
+
this.buffer.modified = true;
|
|
682
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
683
|
+
this.#markPendingInserted();
|
|
684
|
+
}
|
|
685
|
+
return index + 1;
|
|
686
|
+
}
|
|
687
|
+
if (token.value === "C-o") {
|
|
688
|
+
// Execute one normal-mode command, then return to insert
|
|
689
|
+
const nextToken = tokens[index + 1];
|
|
690
|
+
if (!nextToken) {
|
|
691
|
+
return index + 1;
|
|
692
|
+
}
|
|
693
|
+
const savedMode = this.inputMode;
|
|
694
|
+
this.inputMode = "normal";
|
|
695
|
+
const nextIdx = await this.#executeNormal(tokens, index + 1);
|
|
696
|
+
this.inputMode = savedMode;
|
|
697
|
+
return nextIdx;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const insertText = token.value;
|
|
701
|
+
const offset = this.buffer.currentOffset();
|
|
702
|
+
this.buffer.replaceOffsets(offset, offset, insertText, offset + insertText.length);
|
|
703
|
+
this.buffer.modified = true;
|
|
704
|
+
this.#pendingChange?.tokens.push(token.value);
|
|
705
|
+
this.#markPendingInserted();
|
|
706
|
+
return index + 1;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
async #executeVisual(tokens: readonly VimKeyToken[], index: number): Promise<number> {
|
|
710
|
+
const token = tokens[index]!;
|
|
711
|
+
if (token.value === "Esc") {
|
|
712
|
+
this.#clearSelection();
|
|
713
|
+
return index + 1;
|
|
714
|
+
}
|
|
715
|
+
if (token.value === "v") {
|
|
716
|
+
if (this.inputMode === "visual") {
|
|
717
|
+
this.#clearSelection();
|
|
718
|
+
}
|
|
719
|
+
return index + 1;
|
|
720
|
+
}
|
|
721
|
+
if (token.value === "V") {
|
|
722
|
+
this.inputMode = this.inputMode === "visual-line" ? "visual" : "visual-line";
|
|
723
|
+
return index + 1;
|
|
724
|
+
}
|
|
725
|
+
if (token.value === "o") {
|
|
726
|
+
if (this.selectionAnchor) {
|
|
727
|
+
const tmp = clonePosition(this.buffer.cursor);
|
|
728
|
+
this.buffer.setCursor(this.selectionAnchor);
|
|
729
|
+
this.selectionAnchor = tmp;
|
|
730
|
+
}
|
|
731
|
+
return index + 1;
|
|
732
|
+
}
|
|
733
|
+
if (token.value === "J") {
|
|
734
|
+
const visual = expandVisualOffsets(
|
|
735
|
+
this.buffer,
|
|
736
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
737
|
+
this.inputMode === "visual-line",
|
|
738
|
+
);
|
|
739
|
+
const startLine = this.buffer.offsetToPosition(visual.start).line;
|
|
740
|
+
const endLine = this.buffer.offsetToPosition(Math.max(visual.start, visual.end - 1)).line;
|
|
741
|
+
await this.#applyAtomicChange(["J"], () => {
|
|
742
|
+
this.buffer.joinLines(startLine, endLine - startLine);
|
|
743
|
+
});
|
|
744
|
+
this.#clearSelection();
|
|
745
|
+
return index + 1;
|
|
746
|
+
}
|
|
747
|
+
if (token.value === "u" || token.value === "U") {
|
|
748
|
+
const visual = expandVisualOffsets(
|
|
749
|
+
this.buffer,
|
|
750
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
751
|
+
this.inputMode === "visual-line",
|
|
752
|
+
);
|
|
753
|
+
await this.#applyAtomicChange([token.value], () => {
|
|
754
|
+
const original = this.buffer.getText().slice(visual.start, visual.end);
|
|
755
|
+
const transformed = token.value === "U" ? original.toUpperCase() : original.toLowerCase();
|
|
756
|
+
this.buffer.replaceOffsets(visual.start, visual.end, transformed, visual.start);
|
|
757
|
+
});
|
|
758
|
+
this.#clearSelection();
|
|
759
|
+
return index + 1;
|
|
760
|
+
}
|
|
761
|
+
if (token.value === "p" || token.value === "P") {
|
|
762
|
+
const visual = expandVisualOffsets(
|
|
763
|
+
this.buffer,
|
|
764
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
765
|
+
this.inputMode === "visual-line",
|
|
766
|
+
);
|
|
767
|
+
await this.#applyAtomicChange([token.value], () => {
|
|
768
|
+
const removed = this.buffer.getText().slice(visual.start, visual.end);
|
|
769
|
+
const pasteText = this.register.text;
|
|
770
|
+
this.buffer.replaceOffsets(visual.start, visual.end, pasteText, visual.start + pasteText.length);
|
|
771
|
+
this.register = { kind: visual.linewise ? "line" : "char", text: removed };
|
|
772
|
+
});
|
|
773
|
+
this.#clearSelection();
|
|
774
|
+
return index + 1;
|
|
775
|
+
}
|
|
776
|
+
if (token.value === "g") {
|
|
777
|
+
const next = tokens[index + 1];
|
|
778
|
+
if (!next) {
|
|
779
|
+
throw new VimError("g requires a second key", token);
|
|
780
|
+
}
|
|
781
|
+
if (next.value === "J") {
|
|
782
|
+
const visual = expandVisualOffsets(
|
|
783
|
+
this.buffer,
|
|
784
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
785
|
+
this.inputMode === "visual-line",
|
|
786
|
+
);
|
|
787
|
+
const startLine = this.buffer.offsetToPosition(visual.start).line;
|
|
788
|
+
const endLine = this.buffer.offsetToPosition(Math.max(visual.start, visual.end - 1)).line;
|
|
789
|
+
await this.#applyAtomicChange(["g", "J"], () => {
|
|
790
|
+
const start = this.buffer.clampLine(startLine);
|
|
791
|
+
const end = this.buffer.clampLine(endLine);
|
|
792
|
+
if (start < end) {
|
|
793
|
+
const joined = this.buffer.lines.slice(start, end + 1).join("");
|
|
794
|
+
this.buffer.lines.splice(start, end - start + 1, joined);
|
|
795
|
+
this.buffer.setCursor({ line: start, col: Math.max(0, joined.length - 1) });
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
this.#clearSelection();
|
|
799
|
+
return index + 2;
|
|
800
|
+
}
|
|
801
|
+
if (next.value === "u" || next.value === "U" || next.value === "~") {
|
|
802
|
+
const visual = expandVisualOffsets(
|
|
803
|
+
this.buffer,
|
|
804
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
805
|
+
this.inputMode === "visual-line",
|
|
806
|
+
);
|
|
807
|
+
await this.#applyAtomicChange(["g", next.value], () => {
|
|
808
|
+
const original = this.buffer.getText().slice(visual.start, visual.end);
|
|
809
|
+
const transformed =
|
|
810
|
+
next.value === "u"
|
|
811
|
+
? original.toLowerCase()
|
|
812
|
+
: next.value === "U"
|
|
813
|
+
? original.toUpperCase()
|
|
814
|
+
: toggleCase(original);
|
|
815
|
+
this.buffer.replaceOffsets(visual.start, visual.end, transformed, visual.start);
|
|
816
|
+
});
|
|
817
|
+
this.#clearSelection();
|
|
818
|
+
return index + 2;
|
|
819
|
+
}
|
|
820
|
+
throw new VimError(`Unsupported g command: g${next.display}`, next);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const { count, hasCount, nextIndex } = this.#readCount(tokens, index);
|
|
824
|
+
const opToken = tokens[nextIndex];
|
|
825
|
+
if (!opToken) {
|
|
826
|
+
return nextIndex;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
switch (opToken.value) {
|
|
830
|
+
case "d":
|
|
831
|
+
case "x":
|
|
832
|
+
case "X":
|
|
833
|
+
case "D":
|
|
834
|
+
case "y":
|
|
835
|
+
case "c":
|
|
836
|
+
case "s":
|
|
837
|
+
case "S":
|
|
838
|
+
case "C":
|
|
839
|
+
case ">":
|
|
840
|
+
case "<":
|
|
841
|
+
case "~": {
|
|
842
|
+
const visual = expandVisualOffsets(
|
|
843
|
+
this.buffer,
|
|
844
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
845
|
+
this.inputMode === "visual-line",
|
|
846
|
+
);
|
|
847
|
+
const consumeExtraIndent =
|
|
848
|
+
(opToken.value === ">" || opToken.value === "<") && tokens[nextIndex + 1]?.value === opToken.value;
|
|
849
|
+
const operatorValue =
|
|
850
|
+
opToken.value === "x" || opToken.value === "X" || opToken.value === "D"
|
|
851
|
+
? "d"
|
|
852
|
+
: opToken.value === "s" || opToken.value === "S" || opToken.value === "C"
|
|
853
|
+
? "c"
|
|
854
|
+
: opToken.value;
|
|
855
|
+
const visualTokens = consumeExtraIndent ? [opToken.value, opToken.value] : [opToken.value];
|
|
856
|
+
await this.#applyVisualOperator(operatorValue, visual, count, visualTokens);
|
|
857
|
+
return nextIndex + visualTokens.length;
|
|
858
|
+
}
|
|
859
|
+
case "r": {
|
|
860
|
+
const replacement = tokens[nextIndex + 1];
|
|
861
|
+
if (!replacement || replacement.value.length !== 1) {
|
|
862
|
+
throw new VimError("Visual replace requires a literal character", opToken);
|
|
863
|
+
}
|
|
864
|
+
const visual = expandVisualOffsets(
|
|
865
|
+
this.buffer,
|
|
866
|
+
this.selectionAnchor ?? this.buffer.cursor,
|
|
867
|
+
this.inputMode === "visual-line",
|
|
868
|
+
);
|
|
869
|
+
await this.#applyAtomicChange(["r", replacement.value], () => {
|
|
870
|
+
const original = this.buffer.getText().slice(visual.start, visual.end);
|
|
871
|
+
let replaced = "";
|
|
872
|
+
for (const char of original) {
|
|
873
|
+
replaced += char === "\n" ? "\n" : replacement.value;
|
|
874
|
+
}
|
|
875
|
+
this.buffer.replaceOffsets(visual.start, visual.end, replaced, visual.start);
|
|
876
|
+
});
|
|
877
|
+
this.#clearSelection();
|
|
878
|
+
return nextIndex + 2;
|
|
879
|
+
}
|
|
880
|
+
default:
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const motion = this.#resolveMotion(tokens, nextIndex, count, hasCount);
|
|
885
|
+
this.buffer.setCursor(motion.target);
|
|
886
|
+
return motion.nextIndex;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
async #applyVisualOperator(
|
|
890
|
+
operator: string,
|
|
891
|
+
visual: { start: number; end: number; linewise: boolean },
|
|
892
|
+
count: number,
|
|
893
|
+
tokens: readonly string[],
|
|
894
|
+
): Promise<void> {
|
|
895
|
+
switch (operator) {
|
|
896
|
+
case "y": {
|
|
897
|
+
this.register = {
|
|
898
|
+
kind: visual.linewise ? "line" : "char",
|
|
899
|
+
text: this.buffer.getText().slice(visual.start, visual.end),
|
|
900
|
+
};
|
|
901
|
+
this.#clearSelection();
|
|
902
|
+
this.statusMessage = `Yanked ${count} selection${count === 1 ? "" : "s"}`;
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
case "d": {
|
|
906
|
+
await this.#applyAtomicChange(tokens, () => {
|
|
907
|
+
this.#yankAndDeleteRange(visual);
|
|
908
|
+
});
|
|
909
|
+
this.#clearSelection();
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
case "c": {
|
|
913
|
+
await this.#startInsertChange(tokens, () => {
|
|
914
|
+
this.#yankAndDeleteRange(visual);
|
|
915
|
+
});
|
|
916
|
+
this.#clearSelection();
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
case ">":
|
|
920
|
+
case "<": {
|
|
921
|
+
const startLine = this.buffer.offsetToPosition(visual.start).line;
|
|
922
|
+
const endLine = this.buffer.offsetToPosition(Math.max(visual.start, visual.end - 1)).line;
|
|
923
|
+
await this.#applyAtomicChange(tokens, () => {
|
|
924
|
+
this.buffer.indentLines(
|
|
925
|
+
startLine,
|
|
926
|
+
endLine,
|
|
927
|
+
detectIndentUnit(this.buffer.lines),
|
|
928
|
+
operator === ">" ? 1 : -1,
|
|
929
|
+
);
|
|
930
|
+
});
|
|
931
|
+
this.#clearSelection();
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
case "~": {
|
|
935
|
+
await this.#applyAtomicChange(tokens, () => {
|
|
936
|
+
const original = this.buffer.getText().slice(visual.start, visual.end);
|
|
937
|
+
this.buffer.replaceOffsets(visual.start, visual.end, toggleCase(original), visual.start);
|
|
938
|
+
});
|
|
939
|
+
this.#clearSelection();
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
default:
|
|
943
|
+
throw new VimError(`Unsupported visual operator: ${operator}`);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
async #executeNormal(tokens: readonly VimKeyToken[], index: number): Promise<number> {
|
|
948
|
+
const { count, hasCount, nextIndex } = this.#readCount(tokens, index);
|
|
949
|
+
const token = tokens[nextIndex];
|
|
950
|
+
if (!token) {
|
|
951
|
+
return nextIndex;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
switch (token.value) {
|
|
955
|
+
case "h":
|
|
956
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line, col: this.buffer.cursor.col - count });
|
|
957
|
+
return nextIndex + 1;
|
|
958
|
+
case "j":
|
|
959
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line + count, col: this.buffer.cursor.col });
|
|
960
|
+
return nextIndex + 1;
|
|
961
|
+
case "k":
|
|
962
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line - count, col: this.buffer.cursor.col });
|
|
963
|
+
return nextIndex + 1;
|
|
964
|
+
case "l":
|
|
965
|
+
case " ":
|
|
966
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line, col: this.buffer.cursor.col + count });
|
|
967
|
+
return nextIndex + 1;
|
|
968
|
+
case "w":
|
|
969
|
+
case "W":
|
|
970
|
+
case "b":
|
|
971
|
+
case "B":
|
|
972
|
+
case "e":
|
|
973
|
+
case "E":
|
|
974
|
+
case "0":
|
|
975
|
+
case "$":
|
|
976
|
+
case "^":
|
|
977
|
+
case "|":
|
|
978
|
+
case ";":
|
|
979
|
+
case ",":
|
|
980
|
+
case "G":
|
|
981
|
+
case "f":
|
|
982
|
+
case "F":
|
|
983
|
+
case "t":
|
|
984
|
+
case "T":
|
|
985
|
+
case "{":
|
|
986
|
+
case "}":
|
|
987
|
+
case "%":
|
|
988
|
+
case "H":
|
|
989
|
+
case "M":
|
|
990
|
+
case "+":
|
|
991
|
+
case "-":
|
|
992
|
+
case "_":
|
|
993
|
+
case "L": {
|
|
994
|
+
const motion = this.#resolveMotion(tokens, nextIndex, count, hasCount);
|
|
995
|
+
this.buffer.setCursor(motion.target);
|
|
996
|
+
return motion.nextIndex;
|
|
997
|
+
}
|
|
998
|
+
case "*":
|
|
999
|
+
case "#": {
|
|
1000
|
+
const text = this.buffer.getText();
|
|
1001
|
+
const offset = this.buffer.currentOffset();
|
|
1002
|
+
const cat = wordCategory(text[offset] ?? "", false);
|
|
1003
|
+
if (cat === "space") {
|
|
1004
|
+
throw new VimError("No word under cursor", token);
|
|
1005
|
+
}
|
|
1006
|
+
let start = offset;
|
|
1007
|
+
while (start > 0 && wordCategory(text[start - 1] ?? "", false) === cat) start -= 1;
|
|
1008
|
+
let end = offset;
|
|
1009
|
+
while (end < text.length && wordCategory(text[end] ?? "", false) === cat) end += 1;
|
|
1010
|
+
const word = text.slice(start, end);
|
|
1011
|
+
const pattern = `\\b${escapeRegex(word)}\\b`;
|
|
1012
|
+
const direction = token.value === "*" ? 1 : -1;
|
|
1013
|
+
for (let step = 0; step < count; step += 1) {
|
|
1014
|
+
await this.#runSearch(pattern, direction, true);
|
|
1015
|
+
}
|
|
1016
|
+
return nextIndex + 1;
|
|
1017
|
+
}
|
|
1018
|
+
case "n":
|
|
1019
|
+
await this.#repeatSearch(this.lastSearch?.direction ?? 1, count);
|
|
1020
|
+
return nextIndex + 1;
|
|
1021
|
+
case "N":
|
|
1022
|
+
await this.#repeatSearch(((this.lastSearch?.direction ?? 1) * -1) as 1 | -1, count);
|
|
1023
|
+
return nextIndex + 1;
|
|
1024
|
+
case "/":
|
|
1025
|
+
this.inputMode = "search-forward";
|
|
1026
|
+
this.#pendingInput = "";
|
|
1027
|
+
return nextIndex + 1;
|
|
1028
|
+
case "?":
|
|
1029
|
+
this.inputMode = "search-backward";
|
|
1030
|
+
this.#pendingInput = "";
|
|
1031
|
+
return nextIndex + 1;
|
|
1032
|
+
case ":":
|
|
1033
|
+
this.inputMode = "command";
|
|
1034
|
+
this.#pendingInput = "";
|
|
1035
|
+
return nextIndex + 1;
|
|
1036
|
+
case "v":
|
|
1037
|
+
this.inputMode = "visual";
|
|
1038
|
+
this.selectionAnchor = clonePosition(this.buffer.cursor);
|
|
1039
|
+
return nextIndex + 1;
|
|
1040
|
+
case "V":
|
|
1041
|
+
this.inputMode = "visual-line";
|
|
1042
|
+
this.selectionAnchor = clonePosition(this.buffer.cursor);
|
|
1043
|
+
return nextIndex + 1;
|
|
1044
|
+
case "i":
|
|
1045
|
+
// When count > 1 (e.g. `2i`), interpret as `2Gi` — go to line N then insert.
|
|
1046
|
+
// Models confuse `Ni` with `NGi`; bare `i` with a high count is almost never intended.
|
|
1047
|
+
if (hasCount) {
|
|
1048
|
+
this.buffer.setCursor({ line: Math.min(count, this.buffer.lineCount()) - 1, col: 0 });
|
|
1049
|
+
}
|
|
1050
|
+
await this.#startInsertChange(["i"]);
|
|
1051
|
+
return nextIndex + 1;
|
|
1052
|
+
case "a":
|
|
1053
|
+
this.buffer.setCursor({ line: this.buffer.cursor.line, col: this.buffer.cursor.col + 1 });
|
|
1054
|
+
await this.#startInsertChange(["a"]);
|
|
1055
|
+
return nextIndex + 1;
|
|
1056
|
+
case "I":
|
|
1057
|
+
this.buffer.setCursor({
|
|
1058
|
+
line: this.buffer.cursor.line,
|
|
1059
|
+
col: this.buffer.firstNonBlank(this.buffer.cursor.line),
|
|
1060
|
+
});
|
|
1061
|
+
await this.#startInsertChange(["I"]);
|
|
1062
|
+
return nextIndex + 1;
|
|
1063
|
+
case "A":
|
|
1064
|
+
this.buffer.setCursor({
|
|
1065
|
+
line: this.buffer.cursor.line,
|
|
1066
|
+
col: this.buffer.getLine(this.buffer.cursor.line).length,
|
|
1067
|
+
});
|
|
1068
|
+
await this.#startInsertChange(["A"]);
|
|
1069
|
+
return nextIndex + 1;
|
|
1070
|
+
case "o":
|
|
1071
|
+
// When count > 1 (e.g. `13o`), interpret as `13Go` — go to line N then open below.
|
|
1072
|
+
// Models confuse `No` with `NGo`; bare `o` with a high count is almost never intended.
|
|
1073
|
+
if (hasCount) {
|
|
1074
|
+
this.buffer.setCursor({ line: Math.min(count, this.buffer.lineCount()) - 1, col: 0 });
|
|
1075
|
+
}
|
|
1076
|
+
await this.#startInsertChange(["o"], () => {
|
|
1077
|
+
const line = this.buffer.cursor.line + 1;
|
|
1078
|
+
this.buffer.insertLines(line, [""]);
|
|
1079
|
+
});
|
|
1080
|
+
return nextIndex + 1;
|
|
1081
|
+
case "O":
|
|
1082
|
+
if (hasCount) {
|
|
1083
|
+
this.buffer.setCursor({ line: Math.min(count, this.buffer.lineCount()) - 1, col: 0 });
|
|
1084
|
+
}
|
|
1085
|
+
await this.#startInsertChange(["O"], () => {
|
|
1086
|
+
const line = this.buffer.cursor.line;
|
|
1087
|
+
this.buffer.insertLines(line, [""]);
|
|
1088
|
+
});
|
|
1089
|
+
return nextIndex + 1;
|
|
1090
|
+
case "s":
|
|
1091
|
+
await this.#startInsertChange(["s"], () => {
|
|
1092
|
+
this.#deleteCharsForward(count);
|
|
1093
|
+
});
|
|
1094
|
+
return nextIndex + 1;
|
|
1095
|
+
case "S":
|
|
1096
|
+
await this.#changeWholeLines(count, ["S"]);
|
|
1097
|
+
return nextIndex + 1;
|
|
1098
|
+
case "x":
|
|
1099
|
+
await this.#applyAtomicChange(["x"], () => {
|
|
1100
|
+
this.#deleteCharsForward(count);
|
|
1101
|
+
});
|
|
1102
|
+
return nextIndex + 1;
|
|
1103
|
+
case "X":
|
|
1104
|
+
await this.#applyAtomicChange(["X"], () => {
|
|
1105
|
+
const end = this.buffer.currentOffset();
|
|
1106
|
+
const start = Math.max(0, end - count);
|
|
1107
|
+
this.register = { kind: "char", text: this.buffer.deleteOffsets(start, end) };
|
|
1108
|
+
});
|
|
1109
|
+
return nextIndex + 1;
|
|
1110
|
+
case "r": {
|
|
1111
|
+
const replacement = tokens[nextIndex + 1];
|
|
1112
|
+
if (!replacement || replacement.value.length !== 1) {
|
|
1113
|
+
throw new VimError("r requires a replacement character", token);
|
|
1114
|
+
}
|
|
1115
|
+
await this.#applyAtomicChange(["r", replacement.value], () => {
|
|
1116
|
+
const start = this.buffer.currentOffset();
|
|
1117
|
+
this.buffer.replaceOffsets(
|
|
1118
|
+
start,
|
|
1119
|
+
Math.min(this.buffer.getText().length, start + count),
|
|
1120
|
+
replacement.value.repeat(count),
|
|
1121
|
+
start,
|
|
1122
|
+
);
|
|
1123
|
+
});
|
|
1124
|
+
return nextIndex + 2;
|
|
1125
|
+
}
|
|
1126
|
+
case "~":
|
|
1127
|
+
await this.#applyAtomicChange(["~"], () => {
|
|
1128
|
+
const start = this.buffer.currentOffset();
|
|
1129
|
+
const end = Math.min(this.buffer.getText().length, start + count);
|
|
1130
|
+
const text = this.buffer.getText().slice(start, end);
|
|
1131
|
+
this.buffer.replaceOffsets(start, end, toggleCase(text), end);
|
|
1132
|
+
});
|
|
1133
|
+
return nextIndex + 1;
|
|
1134
|
+
case "J":
|
|
1135
|
+
await this.#applyAtomicChange(["J"], () => {
|
|
1136
|
+
this.buffer.joinLines(this.buffer.cursor.line, count);
|
|
1137
|
+
});
|
|
1138
|
+
return nextIndex + 1;
|
|
1139
|
+
case "p":
|
|
1140
|
+
case "P":
|
|
1141
|
+
await this.#applyAtomicChange([token.value], () => {
|
|
1142
|
+
this.#paste(token.value === "p", count);
|
|
1143
|
+
});
|
|
1144
|
+
return nextIndex + 1;
|
|
1145
|
+
case "u":
|
|
1146
|
+
await this.#undo(count);
|
|
1147
|
+
return nextIndex + 1;
|
|
1148
|
+
case "C-r":
|
|
1149
|
+
await this.#redo(count);
|
|
1150
|
+
return nextIndex + 1;
|
|
1151
|
+
case ".":
|
|
1152
|
+
await this.#repeatLastChange(count, token);
|
|
1153
|
+
return nextIndex + 1;
|
|
1154
|
+
case "d":
|
|
1155
|
+
case "c":
|
|
1156
|
+
case "y":
|
|
1157
|
+
case ">":
|
|
1158
|
+
case "<":
|
|
1159
|
+
return this.#executeOperator(tokens, nextIndex, count, hasCount, token.value);
|
|
1160
|
+
case "D":
|
|
1161
|
+
await this.#applyAtomicChange(["D"], () => {
|
|
1162
|
+
const start = this.buffer.currentOffset();
|
|
1163
|
+
const line = this.buffer.getLine(this.buffer.cursor.line);
|
|
1164
|
+
const end = start + (line.length - this.buffer.cursor.col);
|
|
1165
|
+
this.register = { kind: "char", text: this.buffer.deleteOffsets(start, end) };
|
|
1166
|
+
});
|
|
1167
|
+
return nextIndex + 1;
|
|
1168
|
+
case "C":
|
|
1169
|
+
await this.#startInsertChange(["C"], () => {
|
|
1170
|
+
const start = this.buffer.currentOffset();
|
|
1171
|
+
const line = this.buffer.getLine(this.buffer.cursor.line);
|
|
1172
|
+
const end = start + (line.length - this.buffer.cursor.col);
|
|
1173
|
+
this.register = { kind: "char", text: this.buffer.deleteOffsets(start, end) };
|
|
1174
|
+
});
|
|
1175
|
+
return nextIndex + 1;
|
|
1176
|
+
case "z": {
|
|
1177
|
+
const zTarget = tokens[nextIndex + 1];
|
|
1178
|
+
if (!zTarget) {
|
|
1179
|
+
throw new VimError("z requires a second key", token);
|
|
1180
|
+
}
|
|
1181
|
+
if (zTarget.value === "z") {
|
|
1182
|
+
this.centerViewportOnCursor();
|
|
1183
|
+
} else if (zTarget.value === "t" || zTarget.value === "CR") {
|
|
1184
|
+
this.viewportStart = this.buffer.cursor.line + 1;
|
|
1185
|
+
this.buffer.setCursor({
|
|
1186
|
+
line: this.buffer.cursor.line,
|
|
1187
|
+
col: this.buffer.firstNonBlank(this.buffer.cursor.line),
|
|
1188
|
+
});
|
|
1189
|
+
} else if (zTarget.value === "b" || zTarget.value === "-") {
|
|
1190
|
+
this.viewportStart = Math.max(1, this.buffer.cursor.line + 1 - (DEFAULT_VIEWPORT_HEIGHT - 1));
|
|
1191
|
+
this.buffer.setCursor({
|
|
1192
|
+
line: this.buffer.cursor.line,
|
|
1193
|
+
col: this.buffer.firstNonBlank(this.buffer.cursor.line),
|
|
1194
|
+
});
|
|
1195
|
+
} else if (zTarget.value === ".") {
|
|
1196
|
+
this.centerViewportOnCursor();
|
|
1197
|
+
this.buffer.setCursor({
|
|
1198
|
+
line: this.buffer.cursor.line,
|
|
1199
|
+
col: this.buffer.firstNonBlank(this.buffer.cursor.line),
|
|
1200
|
+
});
|
|
1201
|
+
} else if (NOOP_Z_COMMANDS.has(zTarget.value)) {
|
|
1202
|
+
this.statusMessage = `Ignored z${zTarget.display} (folds unsupported)`;
|
|
1203
|
+
} else {
|
|
1204
|
+
throw new VimError(`Unsupported z command: z${zTarget.display}`, zTarget);
|
|
1205
|
+
}
|
|
1206
|
+
return nextIndex + 2;
|
|
1207
|
+
}
|
|
1208
|
+
case "C-f":
|
|
1209
|
+
this.buffer.setCursor({
|
|
1210
|
+
line: this.buffer.cursor.line + Math.max(1, (DEFAULT_VIEWPORT_HEIGHT - 2) * count),
|
|
1211
|
+
col: this.buffer.cursor.col,
|
|
1212
|
+
});
|
|
1213
|
+
return nextIndex + 1;
|
|
1214
|
+
case "C-b":
|
|
1215
|
+
this.buffer.setCursor({
|
|
1216
|
+
line: this.buffer.cursor.line - Math.max(1, (DEFAULT_VIEWPORT_HEIGHT - 2) * count),
|
|
1217
|
+
col: this.buffer.cursor.col,
|
|
1218
|
+
});
|
|
1219
|
+
return nextIndex + 1;
|
|
1220
|
+
case "C-d":
|
|
1221
|
+
this.buffer.setCursor({
|
|
1222
|
+
line: this.buffer.cursor.line + Math.max(1, Math.floor(DEFAULT_VIEWPORT_HEIGHT / 2) * count),
|
|
1223
|
+
col: this.buffer.cursor.col,
|
|
1224
|
+
});
|
|
1225
|
+
return nextIndex + 1;
|
|
1226
|
+
case "C-u":
|
|
1227
|
+
this.buffer.setCursor({
|
|
1228
|
+
line: this.buffer.cursor.line - Math.max(1, Math.floor(DEFAULT_VIEWPORT_HEIGHT / 2) * count),
|
|
1229
|
+
col: this.buffer.cursor.col,
|
|
1230
|
+
});
|
|
1231
|
+
return nextIndex + 1;
|
|
1232
|
+
case "Esc":
|
|
1233
|
+
return nextIndex + 1;
|
|
1234
|
+
case "Y": {
|
|
1235
|
+
const start = this.buffer.cursor.line;
|
|
1236
|
+
const end = this.buffer.clampLine(start + count - 1);
|
|
1237
|
+
this.register = { kind: "line", text: this.buffer.lines.slice(start, end + 1).join("\n") };
|
|
1238
|
+
this.statusMessage = `Yanked ${end - start + 1} line${end === start ? "" : "s"}`;
|
|
1239
|
+
return nextIndex + 1;
|
|
1240
|
+
}
|
|
1241
|
+
case "R":
|
|
1242
|
+
await this.#startInsertChange(["R"], undefined, false);
|
|
1243
|
+
return nextIndex + 1;
|
|
1244
|
+
case "g": {
|
|
1245
|
+
const gNext = tokens[nextIndex + 1];
|
|
1246
|
+
if (!gNext) {
|
|
1247
|
+
throw new VimError("g requires a second key", token);
|
|
1248
|
+
}
|
|
1249
|
+
if (gNext.value === "g") {
|
|
1250
|
+
this.buffer.setCursor({ line: hasCount ? Math.max(0, count - 1) : 0, col: 0 });
|
|
1251
|
+
return nextIndex + 2;
|
|
1252
|
+
}
|
|
1253
|
+
if (gNext.value === "v") {
|
|
1254
|
+
if (this.lastVisual) {
|
|
1255
|
+
this.selectionAnchor = clonePosition(this.lastVisual.anchor);
|
|
1256
|
+
this.buffer.setCursor(this.lastVisual.cursor);
|
|
1257
|
+
this.inputMode = this.lastVisual.mode;
|
|
1258
|
+
}
|
|
1259
|
+
return nextIndex + 2;
|
|
1260
|
+
}
|
|
1261
|
+
if (gNext.value === "*" || gNext.value === "#") {
|
|
1262
|
+
const text = this.buffer.getText();
|
|
1263
|
+
const offset = this.buffer.currentOffset();
|
|
1264
|
+
const cat = wordCategory(text[offset] ?? "", false);
|
|
1265
|
+
if (cat === "space") {
|
|
1266
|
+
throw new VimError("No word under cursor", gNext);
|
|
1267
|
+
}
|
|
1268
|
+
let start = offset;
|
|
1269
|
+
while (start > 0 && wordCategory(text[start - 1] ?? "", false) === cat) start -= 1;
|
|
1270
|
+
let end = offset;
|
|
1271
|
+
while (end < text.length && wordCategory(text[end] ?? "", false) === cat) end += 1;
|
|
1272
|
+
const word = text.slice(start, end);
|
|
1273
|
+
const direction = gNext.value === "*" ? 1 : -1;
|
|
1274
|
+
for (let step = 0; step < count; step += 1) {
|
|
1275
|
+
await this.#runSearch(escapeRegex(word), direction, true);
|
|
1276
|
+
}
|
|
1277
|
+
return nextIndex + 2;
|
|
1278
|
+
}
|
|
1279
|
+
if (gNext.value === "U" || gNext.value === "u") {
|
|
1280
|
+
const caseOp = gNext.value;
|
|
1281
|
+
const {
|
|
1282
|
+
count: motionCount,
|
|
1283
|
+
hasCount: hasMotionCount,
|
|
1284
|
+
nextIndex: motionStart,
|
|
1285
|
+
} = this.#readCount(tokens, nextIndex + 2);
|
|
1286
|
+
const motionToken = tokens[motionStart];
|
|
1287
|
+
if (!motionToken) {
|
|
1288
|
+
throw new VimError(`g${caseOp} requires a motion`, gNext);
|
|
1289
|
+
}
|
|
1290
|
+
if ((motionToken.value === "U" && caseOp === "U") || (motionToken.value === "u" && caseOp === "u")) {
|
|
1291
|
+
const effectiveCount = hasMotionCount ? count * motionCount : count;
|
|
1292
|
+
await this.#applyAtomicChange(["g", caseOp, motionToken.value], () => {
|
|
1293
|
+
const start = this.buffer.cursor.line;
|
|
1294
|
+
const end = this.buffer.clampLine(start + effectiveCount - 1);
|
|
1295
|
+
for (let line = start; line <= end; line++) {
|
|
1296
|
+
const content = this.buffer.getLine(line);
|
|
1297
|
+
this.buffer.replaceLine(line, caseOp === "U" ? content.toUpperCase() : content.toLowerCase());
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
return motionStart + 1;
|
|
1301
|
+
}
|
|
1302
|
+
const effectiveCount = hasMotionCount ? count * motionCount : count;
|
|
1303
|
+
const motion = this.#resolveMotion(tokens, motionStart, effectiveCount, hasCount || hasMotionCount);
|
|
1304
|
+
const range = this.#resolveMotionRange(motion);
|
|
1305
|
+
await this.#applyAtomicChange(
|
|
1306
|
+
tokens.slice(nextIndex, motion.nextIndex).map(tokenEntry => tokenEntry.value),
|
|
1307
|
+
() => {
|
|
1308
|
+
const text = this.buffer.getText();
|
|
1309
|
+
const slice = text.slice(range.start, range.end);
|
|
1310
|
+
const transformed = caseOp === "U" ? slice.toUpperCase() : slice.toLowerCase();
|
|
1311
|
+
this.buffer.replaceOffsets(range.start, range.end, transformed, range.start);
|
|
1312
|
+
},
|
|
1313
|
+
);
|
|
1314
|
+
return motion.nextIndex;
|
|
1315
|
+
}
|
|
1316
|
+
if (gNext.value === "~") {
|
|
1317
|
+
const {
|
|
1318
|
+
count: motionCount,
|
|
1319
|
+
hasCount: hasMotionCount,
|
|
1320
|
+
nextIndex: motionStart,
|
|
1321
|
+
} = this.#readCount(tokens, nextIndex + 2);
|
|
1322
|
+
const motionToken = tokens[motionStart];
|
|
1323
|
+
if (!motionToken) {
|
|
1324
|
+
throw new VimError("g~ requires a motion", gNext);
|
|
1325
|
+
}
|
|
1326
|
+
if (motionToken.value === "~") {
|
|
1327
|
+
const effectiveCount = hasMotionCount ? count * motionCount : count;
|
|
1328
|
+
await this.#applyAtomicChange(["g", "~", motionToken.value], () => {
|
|
1329
|
+
const start = this.buffer.cursor.line;
|
|
1330
|
+
const end = this.buffer.clampLine(start + effectiveCount - 1);
|
|
1331
|
+
for (let line = start; line <= end; line += 1) {
|
|
1332
|
+
this.buffer.replaceLine(line, toggleCase(this.buffer.getLine(line)));
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
return motionStart + 1;
|
|
1336
|
+
}
|
|
1337
|
+
const effectiveCount = hasMotionCount ? count * motionCount : count;
|
|
1338
|
+
const motion = this.#resolveMotion(tokens, motionStart, effectiveCount, hasCount || hasMotionCount);
|
|
1339
|
+
const range = this.#resolveMotionRange(motion);
|
|
1340
|
+
await this.#applyAtomicChange(
|
|
1341
|
+
tokens.slice(nextIndex, motion.nextIndex).map(tokenEntry => tokenEntry.value),
|
|
1342
|
+
() => {
|
|
1343
|
+
const text = this.buffer.getText();
|
|
1344
|
+
const slice = text.slice(range.start, range.end);
|
|
1345
|
+
this.buffer.replaceOffsets(range.start, range.end, toggleCase(slice), range.start);
|
|
1346
|
+
},
|
|
1347
|
+
);
|
|
1348
|
+
return motion.nextIndex;
|
|
1349
|
+
}
|
|
1350
|
+
if (gNext.value === "J") {
|
|
1351
|
+
await this.#applyAtomicChange(["g", "J"], () => {
|
|
1352
|
+
const start = this.buffer.clampLine(this.buffer.cursor.line);
|
|
1353
|
+
const end = this.buffer.clampLine(start + Math.max(count, 1));
|
|
1354
|
+
if (start < end) {
|
|
1355
|
+
const joined = this.buffer.lines.slice(start, end + 1).join("");
|
|
1356
|
+
this.buffer.lines.splice(start, end - start + 1, joined);
|
|
1357
|
+
this.buffer.setCursor({ line: start, col: Math.max(0, joined.length - 1) });
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
return nextIndex + 2;
|
|
1361
|
+
}
|
|
1362
|
+
throw new VimError(`Unsupported g command: g${gNext.display}`, gNext);
|
|
1363
|
+
}
|
|
1364
|
+
case "Z": {
|
|
1365
|
+
const zNext = tokens[nextIndex + 1];
|
|
1366
|
+
if (!zNext) {
|
|
1367
|
+
throw new VimError("Z requires a second key", token);
|
|
1368
|
+
}
|
|
1369
|
+
if (zNext.value === "Z") {
|
|
1370
|
+
await this.#executeEx("wq");
|
|
1371
|
+
return nextIndex + 2;
|
|
1372
|
+
}
|
|
1373
|
+
if (zNext.value === "Q") {
|
|
1374
|
+
await this.#executeEx("q!");
|
|
1375
|
+
return nextIndex + 2;
|
|
1376
|
+
}
|
|
1377
|
+
throw new VimError(`Unsupported Z command: Z${zNext.display}`, zNext);
|
|
1378
|
+
}
|
|
1379
|
+
default:
|
|
1380
|
+
throw new VimError(`Unsupported command: ${token.display}`, token);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
async #repeatLastChange(count: number, token: VimKeyToken): Promise<void> {
|
|
1385
|
+
if (!this.#lastChangeTokens || this.#lastChangeTokens.length === 0) {
|
|
1386
|
+
throw new VimError("No previous change to repeat", token);
|
|
1387
|
+
}
|
|
1388
|
+
for (let index = 0; index < count; index += 1) {
|
|
1389
|
+
await this.executeTokens(replayTokens(this.#lastChangeTokens), ".");
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
async #undo(count: number): Promise<void> {
|
|
1394
|
+
await this.#ensureEditable();
|
|
1395
|
+
let applied = 0;
|
|
1396
|
+
for (let index = 0; index < count; index += 1) {
|
|
1397
|
+
const entry = this.#undoStack.pop();
|
|
1398
|
+
if (!entry) {
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
this.#redoStack.push(entry);
|
|
1402
|
+
this.buffer.restore(entry.before);
|
|
1403
|
+
applied += 1;
|
|
1404
|
+
}
|
|
1405
|
+
this.inputMode = "normal";
|
|
1406
|
+
this.selectionAnchor = null;
|
|
1407
|
+
this.#pendingChange = null;
|
|
1408
|
+
this.statusMessage = `Undid ${applied} change${applied === 1 ? "" : "s"}`;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
async #redo(count: number): Promise<void> {
|
|
1412
|
+
await this.#ensureEditable();
|
|
1413
|
+
let applied = 0;
|
|
1414
|
+
for (let index = 0; index < count; index += 1) {
|
|
1415
|
+
const entry = this.#redoStack.pop();
|
|
1416
|
+
if (!entry) {
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
this.#undoStack.push(entry);
|
|
1420
|
+
this.buffer.restore(entry.after);
|
|
1421
|
+
applied += 1;
|
|
1422
|
+
}
|
|
1423
|
+
this.inputMode = "normal";
|
|
1424
|
+
this.selectionAnchor = null;
|
|
1425
|
+
this.#pendingChange = null;
|
|
1426
|
+
this.statusMessage = `Redid ${applied} change${applied === 1 ? "" : "s"}`;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
async #executeOperator(
|
|
1430
|
+
tokens: readonly VimKeyToken[],
|
|
1431
|
+
operatorIndex: number,
|
|
1432
|
+
operatorCount: number,
|
|
1433
|
+
hasOperatorCount: boolean,
|
|
1434
|
+
operator: string,
|
|
1435
|
+
): Promise<number> {
|
|
1436
|
+
const { count: motionCount, hasCount: hasMotionCount, nextIndex } = this.#readCount(tokens, operatorIndex + 1);
|
|
1437
|
+
const token = tokens[nextIndex];
|
|
1438
|
+
if (!token) {
|
|
1439
|
+
throw new VimError(`Operator ${operator} requires a motion`, tokens[operatorIndex]);
|
|
1440
|
+
}
|
|
1441
|
+
const hasAnyCount = hasOperatorCount || hasMotionCount;
|
|
1442
|
+
const effectiveCount = hasMotionCount ? operatorCount * motionCount : operatorCount;
|
|
1443
|
+
|
|
1444
|
+
if (token.value === operator) {
|
|
1445
|
+
if (operator === "d") {
|
|
1446
|
+
await this.#applyAtomicChange([operator, operator], () => {
|
|
1447
|
+
const start = this.buffer.cursor.line;
|
|
1448
|
+
const removed = this.buffer.deleteLines(start, start + Math.max(1, effectiveCount) - 1);
|
|
1449
|
+
this.register = { kind: "line", text: removed.join("\n") };
|
|
1450
|
+
});
|
|
1451
|
+
return nextIndex + 1;
|
|
1452
|
+
}
|
|
1453
|
+
if (operator === "y") {
|
|
1454
|
+
const start = this.buffer.cursor.line;
|
|
1455
|
+
const end = this.buffer.clampLine(start + Math.max(1, effectiveCount) - 1);
|
|
1456
|
+
this.register = { kind: "line", text: this.buffer.lines.slice(start, end + 1).join("\n") };
|
|
1457
|
+
this.statusMessage = `Yanked ${end - start + 1} line${end === start ? "" : "s"}`;
|
|
1458
|
+
return nextIndex + 1;
|
|
1459
|
+
}
|
|
1460
|
+
if (operator === "c") {
|
|
1461
|
+
await this.#changeWholeLines(Math.max(1, effectiveCount), [operator, operator]);
|
|
1462
|
+
return nextIndex + 1;
|
|
1463
|
+
}
|
|
1464
|
+
if (operator === ">" || operator === "<") {
|
|
1465
|
+
await this.#applyAtomicChange([operator, operator], () => {
|
|
1466
|
+
this.buffer.indentLines(
|
|
1467
|
+
this.buffer.cursor.line,
|
|
1468
|
+
this.buffer.cursor.line + Math.max(1, effectiveCount) - 1,
|
|
1469
|
+
detectIndentUnit(this.buffer.lines),
|
|
1470
|
+
operator === ">" ? 1 : -1,
|
|
1471
|
+
);
|
|
1472
|
+
});
|
|
1473
|
+
return nextIndex + 1;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
if (token.value === "i" || token.value === "a") {
|
|
1478
|
+
const object = tokens[nextIndex + 1];
|
|
1479
|
+
if (!object) {
|
|
1480
|
+
throw new VimError(`Missing text object after ${operator}${token.value}`, token);
|
|
1481
|
+
}
|
|
1482
|
+
const textObject = this.#resolveTextObject(token.value === "i", object.value, object);
|
|
1483
|
+
await this.#applyOperatorToMotion(
|
|
1484
|
+
operator,
|
|
1485
|
+
{ nextIndex: nextIndex + 2, target: this.buffer.cursor, range: textObject },
|
|
1486
|
+
[operator, token.value, object.value],
|
|
1487
|
+
);
|
|
1488
|
+
return nextIndex + 2;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// In vim, `cw` and `cW` act like `ce` and `cE` (don't include trailing whitespace)
|
|
1492
|
+
const motionToken = tokens[nextIndex];
|
|
1493
|
+
let motion: MotionResult;
|
|
1494
|
+
if (operator === "c" && motionToken && (motionToken.value === "w" || motionToken.value === "W")) {
|
|
1495
|
+
const eMotionValue = motionToken.value === "w" ? "e" : "E";
|
|
1496
|
+
const syntheticTokens: readonly VimKeyToken[] = [
|
|
1497
|
+
...tokens.slice(0, nextIndex),
|
|
1498
|
+
{ ...motionToken, value: eMotionValue },
|
|
1499
|
+
...tokens.slice(nextIndex + 1),
|
|
1500
|
+
];
|
|
1501
|
+
motion = this.#resolveMotion(syntheticTokens, nextIndex, effectiveCount, hasAnyCount);
|
|
1502
|
+
} else {
|
|
1503
|
+
motion = this.#resolveMotion(tokens, nextIndex, effectiveCount, hasAnyCount);
|
|
1504
|
+
}
|
|
1505
|
+
await this.#applyOperatorToMotion(
|
|
1506
|
+
operator,
|
|
1507
|
+
motion,
|
|
1508
|
+
tokens.slice(operatorIndex, motion.nextIndex).map(tokenEntry => tokenEntry.value),
|
|
1509
|
+
);
|
|
1510
|
+
return motion.nextIndex;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
async #applyOperatorToMotion(operator: string, motion: MotionResult, tokens: readonly string[]): Promise<void> {
|
|
1514
|
+
if (operator === "y") {
|
|
1515
|
+
const range = this.#resolveMotionRange(motion);
|
|
1516
|
+
this.register = {
|
|
1517
|
+
kind: range.linewise ? "line" : "char",
|
|
1518
|
+
text: this.buffer.getText().slice(range.start, range.end),
|
|
1519
|
+
};
|
|
1520
|
+
this.statusMessage = `Yanked ${range.linewise ? "line" : "selection"}`;
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
if (operator === ">" || operator === "<") {
|
|
1525
|
+
const range = this.#resolveMotionRange(motion);
|
|
1526
|
+
const startLine = this.buffer.offsetToPosition(range.start).line;
|
|
1527
|
+
const endLine = this.buffer.offsetToPosition(Math.max(range.start, range.end - 1)).line;
|
|
1528
|
+
await this.#applyAtomicChange(tokens, () => {
|
|
1529
|
+
this.buffer.indentLines(startLine, endLine, detectIndentUnit(this.buffer.lines), operator === ">" ? 1 : -1);
|
|
1530
|
+
});
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
if (operator === "d") {
|
|
1535
|
+
const range = this.#resolveMotionRange(motion);
|
|
1536
|
+
await this.#applyAtomicChange(tokens, () => {
|
|
1537
|
+
this.#yankAndDeleteRange(range);
|
|
1538
|
+
});
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
if (operator === "c") {
|
|
1543
|
+
const range = this.#resolveMotionRange(motion);
|
|
1544
|
+
await this.#startInsertChange(tokens, () => {
|
|
1545
|
+
this.#yankAndDeleteRange(range);
|
|
1546
|
+
});
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
#yankAndDeleteRange(range: { start: number; end: number; linewise: boolean }): void {
|
|
1552
|
+
this.register = {
|
|
1553
|
+
kind: range.linewise ? "line" : "char",
|
|
1554
|
+
text: this.buffer.getText().slice(range.start, range.end),
|
|
1555
|
+
};
|
|
1556
|
+
this.buffer.deleteOffsets(range.start, range.end);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
#deleteCharsForward(count: number): void {
|
|
1560
|
+
const start = this.buffer.currentOffset();
|
|
1561
|
+
this.register = {
|
|
1562
|
+
kind: "char",
|
|
1563
|
+
text: this.buffer.deleteOffsets(start, Math.min(this.buffer.getText().length, start + count)),
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
async #changeWholeLines(count: number, tokens: readonly string[]): Promise<void> {
|
|
1568
|
+
await this.#startInsertChange(tokens, () => {
|
|
1569
|
+
const start = this.buffer.cursor.line;
|
|
1570
|
+
const end = this.buffer.clampLine(start + count - 1);
|
|
1571
|
+
const removed = this.buffer.lines.slice(start, end + 1);
|
|
1572
|
+
this.register = { kind: "line", text: removed.join("\n") };
|
|
1573
|
+
this.buffer.lines.splice(start, end - start + 1, "");
|
|
1574
|
+
if (this.buffer.lines.length === 0) {
|
|
1575
|
+
this.buffer.lines = [""];
|
|
1576
|
+
}
|
|
1577
|
+
this.buffer.setCursor({ line: Math.min(start, this.buffer.lastLineIndex()), col: 0 });
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
#resolveMotionRange(motion: MotionResult): { start: number; end: number; linewise: boolean } {
|
|
1582
|
+
if (motion.range) {
|
|
1583
|
+
return {
|
|
1584
|
+
start: motion.range.start,
|
|
1585
|
+
end: motion.range.end,
|
|
1586
|
+
linewise: motion.range.linewise ?? false,
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
if (motion.linewise) {
|
|
1591
|
+
const startLine = Math.min(this.buffer.cursor.line, motion.target.line);
|
|
1592
|
+
const endLine = Math.max(this.buffer.cursor.line, motion.target.line);
|
|
1593
|
+
const start = this.buffer.positionToOffset({ line: startLine, col: 0 });
|
|
1594
|
+
const end =
|
|
1595
|
+
endLine >= this.buffer.lastLineIndex()
|
|
1596
|
+
? this.buffer.getText().length
|
|
1597
|
+
: this.buffer.positionToOffset({ line: endLine + 1, col: 0 });
|
|
1598
|
+
return { start, end, linewise: true };
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
const from = this.buffer.positionToOffset(this.buffer.cursor);
|
|
1602
|
+
const to = this.buffer.positionToOffset(motion.target);
|
|
1603
|
+
const normalized = normalizeRange(from, to);
|
|
1604
|
+
return {
|
|
1605
|
+
start: normalized.start,
|
|
1606
|
+
end: normalized.end + (motion.inclusive === false ? 0 : 1),
|
|
1607
|
+
linewise: false,
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
#resolveMotion(tokens: readonly VimKeyToken[], index: number, count: number, hasCount = true): MotionResult {
|
|
1612
|
+
const token = tokens[index];
|
|
1613
|
+
if (!token) {
|
|
1614
|
+
throw new VimError("Missing motion");
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
const text = this.buffer.getText();
|
|
1618
|
+
switch (token.value) {
|
|
1619
|
+
case "h":
|
|
1620
|
+
return {
|
|
1621
|
+
nextIndex: index + 1,
|
|
1622
|
+
target: { line: this.buffer.cursor.line, col: this.buffer.cursor.col - count },
|
|
1623
|
+
};
|
|
1624
|
+
case "j":
|
|
1625
|
+
return {
|
|
1626
|
+
nextIndex: index + 1,
|
|
1627
|
+
target: { line: this.buffer.cursor.line + count, col: this.buffer.cursor.col },
|
|
1628
|
+
linewise: true,
|
|
1629
|
+
};
|
|
1630
|
+
case "k":
|
|
1631
|
+
return {
|
|
1632
|
+
nextIndex: index + 1,
|
|
1633
|
+
target: { line: this.buffer.cursor.line - count, col: this.buffer.cursor.col },
|
|
1634
|
+
linewise: true,
|
|
1635
|
+
};
|
|
1636
|
+
case "l":
|
|
1637
|
+
case " ":
|
|
1638
|
+
return {
|
|
1639
|
+
nextIndex: index + 1,
|
|
1640
|
+
target: { line: this.buffer.cursor.line, col: this.buffer.cursor.col + count },
|
|
1641
|
+
};
|
|
1642
|
+
case "w":
|
|
1643
|
+
case "W": {
|
|
1644
|
+
let offset = this.buffer.currentOffset();
|
|
1645
|
+
for (let step = 0; step < count; step += 1) {
|
|
1646
|
+
offset = nextWordStart(text, step === 0 ? offset + 1 : offset, token.value === "W");
|
|
1647
|
+
}
|
|
1648
|
+
return { nextIndex: index + 1, target: this.buffer.offsetToPosition(offset), inclusive: false };
|
|
1649
|
+
}
|
|
1650
|
+
case "b":
|
|
1651
|
+
case "B": {
|
|
1652
|
+
let offset = this.buffer.currentOffset();
|
|
1653
|
+
for (let step = 0; step < count; step += 1) {
|
|
1654
|
+
offset = previousWordStart(text, offset, token.value === "B");
|
|
1655
|
+
}
|
|
1656
|
+
return { nextIndex: index + 1, target: this.buffer.offsetToPosition(offset) };
|
|
1657
|
+
}
|
|
1658
|
+
case "e":
|
|
1659
|
+
case "E": {
|
|
1660
|
+
let offset = this.buffer.currentOffset();
|
|
1661
|
+
for (let step = 0; step < count; step += 1) {
|
|
1662
|
+
offset = endOfWord(text, step === 0 ? offset : offset + 1, token.value === "E");
|
|
1663
|
+
}
|
|
1664
|
+
return { nextIndex: index + 1, target: this.buffer.offsetToPosition(offset) };
|
|
1665
|
+
}
|
|
1666
|
+
case "0":
|
|
1667
|
+
return { nextIndex: index + 1, target: { line: this.buffer.cursor.line, col: 0 } };
|
|
1668
|
+
case "^":
|
|
1669
|
+
return {
|
|
1670
|
+
nextIndex: index + 1,
|
|
1671
|
+
target: { line: this.buffer.cursor.line, col: this.buffer.firstNonBlank(this.buffer.cursor.line) },
|
|
1672
|
+
};
|
|
1673
|
+
case "|":
|
|
1674
|
+
return {
|
|
1675
|
+
nextIndex: index + 1,
|
|
1676
|
+
target: { line: this.buffer.cursor.line, col: Math.max(0, count - 1) },
|
|
1677
|
+
};
|
|
1678
|
+
case "$":
|
|
1679
|
+
return {
|
|
1680
|
+
nextIndex: index + 1,
|
|
1681
|
+
target: {
|
|
1682
|
+
line: this.buffer.cursor.line,
|
|
1683
|
+
col: Math.max(0, this.buffer.getLine(this.buffer.cursor.line).length - 1),
|
|
1684
|
+
},
|
|
1685
|
+
};
|
|
1686
|
+
case "+": {
|
|
1687
|
+
const targetLine = this.buffer.clampLine(this.buffer.cursor.line + count);
|
|
1688
|
+
return {
|
|
1689
|
+
nextIndex: index + 1,
|
|
1690
|
+
target: { line: targetLine, col: this.buffer.firstNonBlank(targetLine) },
|
|
1691
|
+
linewise: true,
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
case "-": {
|
|
1695
|
+
const targetLine = this.buffer.clampLine(this.buffer.cursor.line - count);
|
|
1696
|
+
return {
|
|
1697
|
+
nextIndex: index + 1,
|
|
1698
|
+
target: { line: targetLine, col: this.buffer.firstNonBlank(targetLine) },
|
|
1699
|
+
linewise: true,
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
case "_": {
|
|
1703
|
+
const targetLine = this.buffer.clampLine(this.buffer.cursor.line + (count - 1));
|
|
1704
|
+
return {
|
|
1705
|
+
nextIndex: index + 1,
|
|
1706
|
+
target: { line: targetLine, col: this.buffer.firstNonBlank(targetLine) },
|
|
1707
|
+
linewise: true,
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
case "g": {
|
|
1711
|
+
const next = tokens[index + 1];
|
|
1712
|
+
if (!next) {
|
|
1713
|
+
throw new VimError("Unsupported g motion", token);
|
|
1714
|
+
}
|
|
1715
|
+
if (next.value === "g") {
|
|
1716
|
+
return {
|
|
1717
|
+
nextIndex: index + 2,
|
|
1718
|
+
target: { line: hasCount ? Math.max(0, count - 1) : 0, col: 0 },
|
|
1719
|
+
linewise: true,
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
if (next.value === "e" || next.value === "E") {
|
|
1723
|
+
let offset = this.buffer.currentOffset();
|
|
1724
|
+
for (let step = 0; step < count; step += 1) {
|
|
1725
|
+
offset = endOfPreviousWord(text, offset, next.value === "E");
|
|
1726
|
+
}
|
|
1727
|
+
return { nextIndex: index + 2, target: this.buffer.offsetToPosition(offset) };
|
|
1728
|
+
}
|
|
1729
|
+
if (next.value === "_") {
|
|
1730
|
+
const targetLine = this.buffer.clampLine(this.buffer.cursor.line + (count - 1));
|
|
1731
|
+
return {
|
|
1732
|
+
nextIndex: index + 2,
|
|
1733
|
+
target: { line: targetLine, col: lastNonBlankColumn(this.buffer.getLine(targetLine)) },
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
throw new VimError("Unsupported g motion", token);
|
|
1737
|
+
}
|
|
1738
|
+
case "G":
|
|
1739
|
+
return {
|
|
1740
|
+
nextIndex: index + 1,
|
|
1741
|
+
target: { line: hasCount ? count - 1 : this.buffer.lastLineIndex(), col: 0 },
|
|
1742
|
+
linewise: true,
|
|
1743
|
+
};
|
|
1744
|
+
case "f":
|
|
1745
|
+
case "F":
|
|
1746
|
+
case "t":
|
|
1747
|
+
case "T": {
|
|
1748
|
+
const searchToken = tokens[index + 1];
|
|
1749
|
+
if (!searchToken || searchToken.value.length !== 1) {
|
|
1750
|
+
throw new VimError(`${token.value} requires a literal character`, token);
|
|
1751
|
+
}
|
|
1752
|
+
this.lastCharFind = { char: searchToken.value, mode: token.value as "f" | "F" | "t" | "T" };
|
|
1753
|
+
const line = this.buffer.getLine(this.buffer.cursor.line);
|
|
1754
|
+
const cursorCol = this.buffer.cursor.col;
|
|
1755
|
+
let matchIndex = -1;
|
|
1756
|
+
if (token.value === "f" || token.value === "t") {
|
|
1757
|
+
let start = cursorCol + 1;
|
|
1758
|
+
for (let step = 0; step < count; step += 1) {
|
|
1759
|
+
matchIndex = line.indexOf(searchToken.value, start);
|
|
1760
|
+
if (matchIndex === -1) break;
|
|
1761
|
+
start = matchIndex + 1;
|
|
1762
|
+
}
|
|
1763
|
+
if (matchIndex === -1) {
|
|
1764
|
+
throw new VimError(`Character not found: ${searchToken.value}`, searchToken);
|
|
1765
|
+
}
|
|
1766
|
+
if (token.value === "t") {
|
|
1767
|
+
matchIndex -= 1;
|
|
1768
|
+
}
|
|
1769
|
+
} else {
|
|
1770
|
+
let start = Math.max(0, cursorCol - 1);
|
|
1771
|
+
for (let step = 0; step < count; step += 1) {
|
|
1772
|
+
matchIndex = line.lastIndexOf(searchToken.value, start);
|
|
1773
|
+
if (matchIndex === -1) break;
|
|
1774
|
+
start = matchIndex - 1;
|
|
1775
|
+
}
|
|
1776
|
+
if (matchIndex === -1) {
|
|
1777
|
+
throw new VimError(`Character not found: ${searchToken.value}`, searchToken);
|
|
1778
|
+
}
|
|
1779
|
+
if (token.value === "T") {
|
|
1780
|
+
matchIndex += 1;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
return {
|
|
1784
|
+
nextIndex: index + 2,
|
|
1785
|
+
target: { line: this.buffer.cursor.line, col: Math.max(0, matchIndex) },
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
case "{":
|
|
1789
|
+
return {
|
|
1790
|
+
nextIndex: index + 1,
|
|
1791
|
+
target: { line: findParagraphStart(this.buffer.lines, this.buffer.cursor.line), col: 0 },
|
|
1792
|
+
linewise: true,
|
|
1793
|
+
};
|
|
1794
|
+
case "}":
|
|
1795
|
+
return {
|
|
1796
|
+
nextIndex: index + 1,
|
|
1797
|
+
target: { line: findParagraphEnd(this.buffer.lines, this.buffer.cursor.line), col: 0 },
|
|
1798
|
+
linewise: true,
|
|
1799
|
+
};
|
|
1800
|
+
case "%": {
|
|
1801
|
+
const match = this.#findMatchingBracket();
|
|
1802
|
+
return { nextIndex: index + 1, target: match };
|
|
1803
|
+
}
|
|
1804
|
+
case "H":
|
|
1805
|
+
return {
|
|
1806
|
+
nextIndex: index + 1,
|
|
1807
|
+
target: { line: Math.max(0, this.viewportStart - 1), col: 0 },
|
|
1808
|
+
linewise: true,
|
|
1809
|
+
};
|
|
1810
|
+
case "M":
|
|
1811
|
+
return {
|
|
1812
|
+
nextIndex: index + 1,
|
|
1813
|
+
target: { line: Math.max(0, this.viewportStart - 1 + 20), col: 0 },
|
|
1814
|
+
linewise: true,
|
|
1815
|
+
};
|
|
1816
|
+
case "L":
|
|
1817
|
+
return {
|
|
1818
|
+
nextIndex: index + 1,
|
|
1819
|
+
target: { line: Math.max(0, this.viewportStart - 1 + 39), col: 0 },
|
|
1820
|
+
linewise: true,
|
|
1821
|
+
};
|
|
1822
|
+
case ";":
|
|
1823
|
+
case ",": {
|
|
1824
|
+
if (!this.lastCharFind) {
|
|
1825
|
+
throw new VimError(
|
|
1826
|
+
"No previous character search. If you meant an ex-command range like `:4,5d`, add the `:` prefix and `<CR>` suffix.",
|
|
1827
|
+
token,
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
let mode = this.lastCharFind.mode;
|
|
1831
|
+
if (token.value === ",") {
|
|
1832
|
+
const reverseMap: Record<string, "f" | "F" | "t" | "T"> = { f: "F", F: "f", t: "T", T: "t" };
|
|
1833
|
+
mode = reverseMap[mode]!;
|
|
1834
|
+
}
|
|
1835
|
+
const line = this.buffer.getLine(this.buffer.cursor.line);
|
|
1836
|
+
const cursorCol = this.buffer.cursor.col;
|
|
1837
|
+
let matchIndex = -1;
|
|
1838
|
+
if (mode === "f" || mode === "t") {
|
|
1839
|
+
let start = cursorCol + 1;
|
|
1840
|
+
for (let step = 0; step < count; step += 1) {
|
|
1841
|
+
matchIndex = line.indexOf(this.lastCharFind.char, start);
|
|
1842
|
+
if (matchIndex === -1) break;
|
|
1843
|
+
start = matchIndex + 1;
|
|
1844
|
+
}
|
|
1845
|
+
if (matchIndex !== -1 && mode === "t") matchIndex -= 1;
|
|
1846
|
+
} else {
|
|
1847
|
+
let start = Math.max(0, cursorCol - 1);
|
|
1848
|
+
for (let step = 0; step < count; step += 1) {
|
|
1849
|
+
matchIndex = line.lastIndexOf(this.lastCharFind.char, start);
|
|
1850
|
+
if (matchIndex === -1) break;
|
|
1851
|
+
start = matchIndex - 1;
|
|
1852
|
+
}
|
|
1853
|
+
if (matchIndex !== -1 && mode === "T") matchIndex += 1;
|
|
1854
|
+
}
|
|
1855
|
+
if (matchIndex === -1) {
|
|
1856
|
+
throw new VimError(`Character not found: ${this.lastCharFind.char}`, token);
|
|
1857
|
+
}
|
|
1858
|
+
return {
|
|
1859
|
+
nextIndex: index + 1,
|
|
1860
|
+
target: { line: this.buffer.cursor.line, col: Math.max(0, matchIndex) },
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
default:
|
|
1864
|
+
throw new VimError(`Unsupported motion: ${token.display}`, token);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
#resolveTextObject(
|
|
1869
|
+
inner: boolean,
|
|
1870
|
+
objectToken: string,
|
|
1871
|
+
sourceToken: VimKeyToken,
|
|
1872
|
+
): { start: number; end: number; linewise?: boolean } {
|
|
1873
|
+
if (objectToken === "w" || objectToken === "W") {
|
|
1874
|
+
return this.#resolveWordTextObject(inner, objectToken === "W");
|
|
1875
|
+
}
|
|
1876
|
+
if (objectToken === '"' || objectToken === "'" || objectToken === "`") {
|
|
1877
|
+
return this.#resolveQuoteTextObject(inner, objectToken, sourceToken);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
if (objectToken === "p") {
|
|
1881
|
+
return this.#resolveParagraphTextObject(inner);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
const normalized =
|
|
1885
|
+
objectToken === ")"
|
|
1886
|
+
? "("
|
|
1887
|
+
: objectToken === "}"
|
|
1888
|
+
? "{"
|
|
1889
|
+
: objectToken === "]"
|
|
1890
|
+
? "["
|
|
1891
|
+
: objectToken === ">"
|
|
1892
|
+
? "<"
|
|
1893
|
+
: objectToken;
|
|
1894
|
+
if (!BRACKET_PAIRS.has(normalized)) {
|
|
1895
|
+
throw new VimError(`Unsupported text object: ${objectToken}`, sourceToken);
|
|
1896
|
+
}
|
|
1897
|
+
return this.#resolveBracketTextObject(inner, normalized, sourceToken);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
#resolveWordTextObject(inner: boolean, bigWord: boolean): { start: number; end: number } {
|
|
1901
|
+
const text = this.buffer.getText();
|
|
1902
|
+
const cursor = this.buffer.currentOffset();
|
|
1903
|
+
let start = cursor;
|
|
1904
|
+
if (wordCategory(text[start] ?? "", bigWord) === "space") {
|
|
1905
|
+
start = nextWordStart(text, start, bigWord);
|
|
1906
|
+
}
|
|
1907
|
+
const category = wordCategory(text[start] ?? "", bigWord);
|
|
1908
|
+
while (start > 0 && wordCategory(text[start - 1] ?? "", bigWord) === category) {
|
|
1909
|
+
start -= 1;
|
|
1910
|
+
}
|
|
1911
|
+
let end = start;
|
|
1912
|
+
while (end < text.length && wordCategory(text[end] ?? "", bigWord) === category) {
|
|
1913
|
+
end += 1;
|
|
1914
|
+
}
|
|
1915
|
+
if (!inner) {
|
|
1916
|
+
while (end < text.length && wordCategory(text[end] ?? "", bigWord) === "space") {
|
|
1917
|
+
end += 1;
|
|
1918
|
+
}
|
|
1919
|
+
while (start > 0 && wordCategory(text[start - 1] ?? "", bigWord) === "space") {
|
|
1920
|
+
start -= 1;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
return { start, end };
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
#resolveParagraphTextObject(inner: boolean): { start: number; end: number; linewise: boolean } {
|
|
1927
|
+
const lines = this.buffer.lines;
|
|
1928
|
+
const cursorLine = this.buffer.cursor.line;
|
|
1929
|
+
let start = cursorLine;
|
|
1930
|
+
let end = cursorLine;
|
|
1931
|
+
// Find paragraph boundaries (delimited by blank lines)
|
|
1932
|
+
if (lines[cursorLine]?.trim().length === 0) {
|
|
1933
|
+
// On a blank line: select contiguous blank lines
|
|
1934
|
+
while (start > 0 && lines[start - 1]!.trim().length === 0) start -= 1;
|
|
1935
|
+
while (end < lines.length - 1 && lines[end + 1]!.trim().length === 0) end += 1;
|
|
1936
|
+
if (!inner) {
|
|
1937
|
+
// Include following non-blank paragraph
|
|
1938
|
+
while (end < lines.length - 1 && lines[end + 1]!.trim().length > 0) end += 1;
|
|
1939
|
+
}
|
|
1940
|
+
} else {
|
|
1941
|
+
// On a non-blank line: select contiguous non-blank lines
|
|
1942
|
+
while (start > 0 && lines[start - 1]!.trim().length > 0) start -= 1;
|
|
1943
|
+
while (end < lines.length - 1 && lines[end + 1]!.trim().length > 0) end += 1;
|
|
1944
|
+
if (!inner) {
|
|
1945
|
+
// Include trailing blank lines
|
|
1946
|
+
while (end < lines.length - 1 && lines[end + 1]!.trim().length === 0) end += 1;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
const startOffset = this.buffer.positionToOffset({ line: start, col: 0 });
|
|
1950
|
+
const endOffset =
|
|
1951
|
+
end >= this.buffer.lastLineIndex()
|
|
1952
|
+
? this.buffer.getText().length
|
|
1953
|
+
: this.buffer.positionToOffset({ line: end + 1, col: 0 });
|
|
1954
|
+
return { start: startOffset, end: endOffset, linewise: true };
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
#resolveQuoteTextObject(inner: boolean, quote: string, sourceToken: VimKeyToken): { start: number; end: number } {
|
|
1958
|
+
const line = this.buffer.getLine(this.buffer.cursor.line);
|
|
1959
|
+
const col = this.buffer.cursor.col;
|
|
1960
|
+
const before = line.lastIndexOf(quote, col);
|
|
1961
|
+
const after = line.indexOf(quote, col + (line[col] === quote ? 1 : 0));
|
|
1962
|
+
if (before === -1 || after === -1 || before === after) {
|
|
1963
|
+
throw new VimError(`Quote text object not found for ${quote}`, sourceToken);
|
|
1964
|
+
}
|
|
1965
|
+
const startCol = inner ? before + 1 : before;
|
|
1966
|
+
const endCol = inner ? after : after + 1;
|
|
1967
|
+
return {
|
|
1968
|
+
start: this.buffer.positionToOffset({ line: this.buffer.cursor.line, col: startCol }),
|
|
1969
|
+
end: this.buffer.positionToOffset({ line: this.buffer.cursor.line, col: endCol }),
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
#resolveBracketTextObject(inner: boolean, open: string, sourceToken: VimKeyToken): { start: number; end: number } {
|
|
1974
|
+
const close = BRACKET_PAIRS.get(open)!;
|
|
1975
|
+
const text = this.buffer.getText();
|
|
1976
|
+
const cursor = this.buffer.currentOffset();
|
|
1977
|
+
let start = -1;
|
|
1978
|
+
let depth = 0;
|
|
1979
|
+
for (let index = cursor; index >= 0; index -= 1) {
|
|
1980
|
+
const char = text[index] ?? "";
|
|
1981
|
+
if (char === close) {
|
|
1982
|
+
depth += 1;
|
|
1983
|
+
} else if (char === open) {
|
|
1984
|
+
if (depth === 0) {
|
|
1985
|
+
start = index;
|
|
1986
|
+
break;
|
|
1987
|
+
}
|
|
1988
|
+
depth -= 1;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
if (start === -1) {
|
|
1992
|
+
throw new VimError(`Text object ${open}${close} not found`, sourceToken);
|
|
1993
|
+
}
|
|
1994
|
+
let end = -1;
|
|
1995
|
+
depth = 0;
|
|
1996
|
+
for (let index = start; index < text.length; index += 1) {
|
|
1997
|
+
const char = text[index] ?? "";
|
|
1998
|
+
if (char === open) {
|
|
1999
|
+
depth += 1;
|
|
2000
|
+
} else if (char === close) {
|
|
2001
|
+
depth -= 1;
|
|
2002
|
+
if (depth === 0) {
|
|
2003
|
+
end = index;
|
|
2004
|
+
break;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
if (end === -1) {
|
|
2009
|
+
throw new VimError(`Text object ${open}${close} not found`, sourceToken);
|
|
2010
|
+
}
|
|
2011
|
+
return {
|
|
2012
|
+
start: inner ? start + 1 : start,
|
|
2013
|
+
end: inner ? end : end + 1,
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
#findMatchingBracket(): Position {
|
|
2018
|
+
const text = this.buffer.getText();
|
|
2019
|
+
const cursor = this.buffer.currentOffset();
|
|
2020
|
+
let offset = cursor;
|
|
2021
|
+
let char = text[offset] ?? "";
|
|
2022
|
+
if (!BRACKET_PAIRS.has(char) && !CLOSING_BRACKETS.has(char)) {
|
|
2023
|
+
offset += 1;
|
|
2024
|
+
char = text[offset] ?? "";
|
|
2025
|
+
}
|
|
2026
|
+
if (BRACKET_PAIRS.has(char)) {
|
|
2027
|
+
const close = BRACKET_PAIRS.get(char)!;
|
|
2028
|
+
let depth = 0;
|
|
2029
|
+
for (let index = offset; index < text.length; index += 1) {
|
|
2030
|
+
const current = text[index] ?? "";
|
|
2031
|
+
if (current === char) depth += 1;
|
|
2032
|
+
if (current === close) {
|
|
2033
|
+
depth -= 1;
|
|
2034
|
+
if (depth === 0) {
|
|
2035
|
+
return this.buffer.offsetToPosition(index);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
if (CLOSING_BRACKETS.has(char)) {
|
|
2041
|
+
const open = CLOSING_BRACKETS.get(char)!;
|
|
2042
|
+
let depth = 0;
|
|
2043
|
+
for (let index = offset; index >= 0; index -= 1) {
|
|
2044
|
+
const current = text[index] ?? "";
|
|
2045
|
+
if (current === char) depth += 1;
|
|
2046
|
+
if (current === open) {
|
|
2047
|
+
depth -= 1;
|
|
2048
|
+
if (depth === 0) {
|
|
2049
|
+
return this.buffer.offsetToPosition(index);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
throw new VimError("Matching bracket not found");
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
async #runSearch(pattern: string, direction: 1 | -1, updateState: boolean): Promise<void> {
|
|
2058
|
+
const text = this.buffer.getText();
|
|
2059
|
+
const regex = createSearchRegex(pattern, "g");
|
|
2060
|
+
const cursor = this.buffer.currentOffset();
|
|
2061
|
+
let matchOffset = -1;
|
|
2062
|
+
|
|
2063
|
+
if (direction > 0) {
|
|
2064
|
+
regex.lastIndex = Math.min(text.length, cursor + 1);
|
|
2065
|
+
const match = regex.exec(text);
|
|
2066
|
+
if (match && match.index >= 0) {
|
|
2067
|
+
matchOffset = match.index;
|
|
2068
|
+
} else {
|
|
2069
|
+
regex.lastIndex = 0;
|
|
2070
|
+
const wrapMatch = regex.exec(text);
|
|
2071
|
+
if (wrapMatch && wrapMatch.index >= 0) {
|
|
2072
|
+
matchOffset = wrapMatch.index;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
} else {
|
|
2076
|
+
const matches = Array.from(text.matchAll(regex));
|
|
2077
|
+
for (let index = matches.length - 1; index >= 0; index -= 1) {
|
|
2078
|
+
const match = matches[index];
|
|
2079
|
+
if ((match.index ?? -1) < cursor) {
|
|
2080
|
+
matchOffset = match.index ?? -1;
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
if (matchOffset === -1 && matches.length > 0) {
|
|
2085
|
+
matchOffset = matches[matches.length - 1]?.index ?? -1;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
if (matchOffset === -1) {
|
|
2090
|
+
throw new VimError(`Pattern not found: ${pattern}`);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
this.buffer.setCursor(this.buffer.offsetToPosition(matchOffset));
|
|
2094
|
+
this.statusMessage = `${direction > 0 ? "/" : "?"}${pattern}`;
|
|
2095
|
+
if (updateState) {
|
|
2096
|
+
this.lastSearch = { pattern, direction };
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
async #repeatSearch(direction: 1 | -1, count: number): Promise<void> {
|
|
2101
|
+
if (!this.lastSearch) {
|
|
2102
|
+
throw new VimError("No previous search");
|
|
2103
|
+
}
|
|
2104
|
+
for (let index = 0; index < count; index += 1) {
|
|
2105
|
+
await this.#runSearch(this.lastSearch.pattern, direction, false);
|
|
2106
|
+
}
|
|
2107
|
+
this.lastSearch = { pattern: this.lastSearch.pattern, direction };
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
#resolveExRange(
|
|
2111
|
+
range: VimLineRange | "all" | undefined,
|
|
2112
|
+
defaultStart: number,
|
|
2113
|
+
defaultEnd = defaultStart,
|
|
2114
|
+
): VimLineRange {
|
|
2115
|
+
const totalLines = Math.max(1, this.buffer.lineCount());
|
|
2116
|
+
if (range === "all") {
|
|
2117
|
+
return { start: 1, end: totalLines };
|
|
2118
|
+
}
|
|
2119
|
+
const next = range ?? { start: defaultStart, end: defaultEnd };
|
|
2120
|
+
const start = Math.max(1, Math.min(next.start, totalLines));
|
|
2121
|
+
const end = Math.max(start, Math.min(next.end, totalLines));
|
|
2122
|
+
return { start, end };
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
async #executeEx(input: string): Promise<void> {
|
|
2126
|
+
const command = parseExCommand(input, {
|
|
2127
|
+
currentLine: this.buffer.cursor.line + 1,
|
|
2128
|
+
lastLine: this.buffer.lineCount(),
|
|
2129
|
+
});
|
|
2130
|
+
switch (command.kind) {
|
|
2131
|
+
case "goto-line":
|
|
2132
|
+
this.buffer.setCursor({ line: Math.max(0, command.line - 1), col: 0 });
|
|
2133
|
+
this.statusMessage = `Line ${command.line}`;
|
|
2134
|
+
return;
|
|
2135
|
+
case "write": {
|
|
2136
|
+
const result = await this.#callbacks.saveBuffer(this.buffer, { force: command.force });
|
|
2137
|
+
this.buffer.markSaved(result.loaded);
|
|
2138
|
+
this.diagnostics = result.diagnostics;
|
|
2139
|
+
this.statusMessage = result.diagnostics
|
|
2140
|
+
? `Wrote ${this.buffer.displayPath} (${result.diagnostics.summary})`
|
|
2141
|
+
: `Wrote ${this.buffer.displayPath}`;
|
|
2142
|
+
this.#undoStack = [];
|
|
2143
|
+
this.#redoStack = [];
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
case "update":
|
|
2147
|
+
if (!this.buffer.modified) {
|
|
2148
|
+
this.statusMessage = `${this.buffer.displayPath} unchanged`;
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
await this.#executeEx(command.force ? "w!" : "w");
|
|
2152
|
+
return;
|
|
2153
|
+
case "write-quit":
|
|
2154
|
+
await this.#executeEx(command.force ? "w!" : "w");
|
|
2155
|
+
this.closed = true;
|
|
2156
|
+
this.statusMessage = `Wrote and closed ${this.buffer.displayPath}`;
|
|
2157
|
+
return;
|
|
2158
|
+
case "quit":
|
|
2159
|
+
if (this.buffer.modified && !command.force) {
|
|
2160
|
+
throw new VimError("Unsaved changes; use :q! to discard");
|
|
2161
|
+
}
|
|
2162
|
+
this.closed = true;
|
|
2163
|
+
this.statusMessage = `Closed ${this.buffer.displayPath}`;
|
|
2164
|
+
return;
|
|
2165
|
+
case "edit": {
|
|
2166
|
+
if (this.buffer.modified && !command.force) {
|
|
2167
|
+
throw new VimError("Unsaved changes; use :e! to reload or force open");
|
|
2168
|
+
}
|
|
2169
|
+
const next = await this.#callbacks.loadBuffer(command.path ?? this.buffer.displayPath);
|
|
2170
|
+
this.buffer.replaceLoadedFile(next);
|
|
2171
|
+
this.inputMode = "normal";
|
|
2172
|
+
this.selectionAnchor = null;
|
|
2173
|
+
this.#pendingInput = "";
|
|
2174
|
+
this.#pendingChange = null;
|
|
2175
|
+
this.#undoStack = [];
|
|
2176
|
+
this.#redoStack = [];
|
|
2177
|
+
this.statusMessage = command.path
|
|
2178
|
+
? `Opened ${this.buffer.displayPath}`
|
|
2179
|
+
: `Reloaded ${this.buffer.displayPath}`;
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
case "substitute": {
|
|
2183
|
+
const range = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2184
|
+
const startLine = range.start;
|
|
2185
|
+
const endLine = range.end;
|
|
2186
|
+
const regexFlags = command.flags.includes("i") ? "gi" : "g";
|
|
2187
|
+
const regex = createSearchRegex(command.pattern, regexFlags);
|
|
2188
|
+
let replacements = 0;
|
|
2189
|
+
await this.#applyAtomicChange([":substitute"], () => {
|
|
2190
|
+
for (let lineIndex = startLine - 1; lineIndex <= endLine - 1; lineIndex += 1) {
|
|
2191
|
+
const line = this.buffer.getLine(lineIndex);
|
|
2192
|
+
let lineReplacements = 0;
|
|
2193
|
+
const nextLine = line.replace(regex, match => {
|
|
2194
|
+
if (!command.flags.includes("g") && lineReplacements > 0) {
|
|
2195
|
+
return match;
|
|
2196
|
+
}
|
|
2197
|
+
lineReplacements += 1;
|
|
2198
|
+
replacements += 1;
|
|
2199
|
+
return decodeReplacement(command.replacement).replace(/&/g, match);
|
|
2200
|
+
});
|
|
2201
|
+
this.buffer.replaceLine(lineIndex, nextLine);
|
|
2202
|
+
regex.lastIndex = 0;
|
|
2203
|
+
}
|
|
2204
|
+
});
|
|
2205
|
+
if (replacements === 0) {
|
|
2206
|
+
throw new VimError(`Pattern not found: ${command.pattern}`);
|
|
2207
|
+
}
|
|
2208
|
+
this.statusMessage = `${replacements} substitution${replacements === 1 ? "" : "s"}`;
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
case "delete": {
|
|
2212
|
+
const range = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2213
|
+
await this.#applyAtomicChange([":delete"], () => {
|
|
2214
|
+
const removed = this.buffer.deleteLines(range.start - 1, range.end - 1);
|
|
2215
|
+
this.register = { kind: "line", text: removed.join("\n") };
|
|
2216
|
+
});
|
|
2217
|
+
this.statusMessage = `Deleted ${range.end - range.start + 1} line${range.end === range.start ? "" : "s"}`;
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
case "yank": {
|
|
2221
|
+
const range = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2222
|
+
this.register = {
|
|
2223
|
+
kind: "line",
|
|
2224
|
+
text: this.buffer.lines.slice(range.start - 1, range.end).join("\n"),
|
|
2225
|
+
};
|
|
2226
|
+
this.statusMessage = `Yanked ${range.end - range.start + 1} line${range.end === range.start ? "" : "s"}`;
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
case "put": {
|
|
2230
|
+
if (!this.register.text) {
|
|
2231
|
+
this.statusMessage = "Register empty";
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
const anchorRange = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2235
|
+
const anchorLine = command.before ? anchorRange.start : anchorRange.end;
|
|
2236
|
+
const lines = this.register.text.split("\n");
|
|
2237
|
+
await this.#applyAtomicChange([":put"], () => {
|
|
2238
|
+
const insertAt = command.before
|
|
2239
|
+
? Math.max(0, anchorLine - 1)
|
|
2240
|
+
: Math.min(anchorLine, this.buffer.lineCount());
|
|
2241
|
+
this.buffer.insertLines(insertAt, lines);
|
|
2242
|
+
});
|
|
2243
|
+
this.statusMessage = `Put ${lines.length} line${lines.length === 1 ? "" : "s"}`;
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
case "copy": {
|
|
2247
|
+
const totalLines = this.buffer.lineCount();
|
|
2248
|
+
const range = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2249
|
+
const dest = Math.max(0, Math.min(command.destination, totalLines));
|
|
2250
|
+
await this.#applyAtomicChange([":copy"], () => {
|
|
2251
|
+
const lines = this.buffer.lines.slice(range.start - 1, range.end);
|
|
2252
|
+
this.buffer.insertLines(dest, lines);
|
|
2253
|
+
});
|
|
2254
|
+
this.statusMessage = `Copied ${range.end - range.start + 1} line${range.end === range.start ? "" : "s"}`;
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
case "move": {
|
|
2258
|
+
const totalLines = this.buffer.lineCount();
|
|
2259
|
+
const range = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2260
|
+
const dest = Math.max(0, Math.min(command.destination, totalLines));
|
|
2261
|
+
await this.#applyAtomicChange([":move"], () => {
|
|
2262
|
+
const lines = this.buffer.lines.splice(range.start - 1, range.end - range.start + 1);
|
|
2263
|
+
const adjustedDest = dest > range.end - 1 ? dest - lines.length : dest;
|
|
2264
|
+
this.buffer.lines.splice(adjustedDest, 0, ...lines);
|
|
2265
|
+
if (this.buffer.lines.length === 0) this.buffer.lines = [""];
|
|
2266
|
+
this.buffer.setCursor({ line: adjustedDest, col: 0 });
|
|
2267
|
+
});
|
|
2268
|
+
this.statusMessage = `Moved ${range.end - range.start + 1} line${range.end === range.start ? "" : "s"}`;
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
case "sort": {
|
|
2272
|
+
const range = this.#resolveExRange(command.range ?? "all", 1, this.buffer.lineCount());
|
|
2273
|
+
const startLine = range.start;
|
|
2274
|
+
const endLine = range.end;
|
|
2275
|
+
const reverse = command.flags.includes("!");
|
|
2276
|
+
const ignoreCase = command.flags.includes("i");
|
|
2277
|
+
await this.#applyAtomicChange([":sort"], () => {
|
|
2278
|
+
const slice = this.buffer.lines.slice(startLine - 1, endLine);
|
|
2279
|
+
slice.sort((a, b) => {
|
|
2280
|
+
const left = ignoreCase ? a.toLowerCase() : a;
|
|
2281
|
+
const right = ignoreCase ? b.toLowerCase() : b;
|
|
2282
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
2283
|
+
});
|
|
2284
|
+
if (reverse) slice.reverse();
|
|
2285
|
+
for (let i = 0; i < slice.length; i++) {
|
|
2286
|
+
this.buffer.lines[startLine - 1 + i] = slice[i]!;
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
this.statusMessage = `Sorted ${endLine - startLine + 1} line${endLine === startLine ? "" : "s"}`;
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
case "join": {
|
|
2293
|
+
const currentLine = this.buffer.cursor.line + 1;
|
|
2294
|
+
const baseRange = this.#resolveExRange(
|
|
2295
|
+
command.range,
|
|
2296
|
+
currentLine,
|
|
2297
|
+
command.range ? undefined : Math.min(this.buffer.lineCount(), currentLine + 1),
|
|
2298
|
+
);
|
|
2299
|
+
const startLine = baseRange.start;
|
|
2300
|
+
const endLine =
|
|
2301
|
+
baseRange.start === baseRange.end ? Math.min(this.buffer.lineCount(), baseRange.end + 1) : baseRange.end;
|
|
2302
|
+
const lineCount = endLine - startLine + 1;
|
|
2303
|
+
if (lineCount < 2) {
|
|
2304
|
+
this.statusMessage = "Nothing to join";
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
await this.#applyAtomicChange([":join"], () => {
|
|
2308
|
+
const startIndex = startLine - 1;
|
|
2309
|
+
if (command.trimWhitespace) {
|
|
2310
|
+
this.buffer.joinLines(startIndex, lineCount - 1);
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
const joined = this.buffer.lines.slice(startIndex, endLine).join("");
|
|
2314
|
+
this.buffer.lines.splice(startIndex, lineCount, joined);
|
|
2315
|
+
this.buffer.setCursor({ line: startIndex, col: Math.max(0, joined.length - 1) });
|
|
2316
|
+
});
|
|
2317
|
+
this.statusMessage = `Joined ${lineCount} lines`;
|
|
2318
|
+
return;
|
|
2319
|
+
}
|
|
2320
|
+
case "append": {
|
|
2321
|
+
const anchorRange = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2322
|
+
const anchorLine = anchorRange.end;
|
|
2323
|
+
const lines = command.text.length > 0 ? command.text.split("\n") : [""];
|
|
2324
|
+
await this.#applyAtomicChange([":append"], () => {
|
|
2325
|
+
const insertAt = Math.min(anchorLine, this.buffer.lineCount());
|
|
2326
|
+
this.buffer.insertLines(insertAt, lines);
|
|
2327
|
+
});
|
|
2328
|
+
this.statusMessage = `Appended ${lines.length} line${lines.length === 1 ? "" : "s"}`;
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
case "insert-before": {
|
|
2332
|
+
const anchorRange = this.#resolveExRange(command.range, this.buffer.cursor.line + 1);
|
|
2333
|
+
const anchorLine = anchorRange.start;
|
|
2334
|
+
const lines = command.text.length > 0 ? command.text.split("\n") : [""];
|
|
2335
|
+
await this.#applyAtomicChange([":insert"], () => {
|
|
2336
|
+
const insertAt = Math.max(0, anchorLine - 1);
|
|
2337
|
+
this.buffer.insertLines(insertAt, lines);
|
|
2338
|
+
});
|
|
2339
|
+
this.statusMessage = `Inserted ${lines.length} line${lines.length === 1 ? "" : "s"}`;
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
case "global": {
|
|
2343
|
+
const regex = createSearchRegex(command.pattern);
|
|
2344
|
+
const range = this.#resolveExRange(command.range ?? "all", 1, this.buffer.lineCount());
|
|
2345
|
+
await this.#applyAtomicChange([":global"], () => {
|
|
2346
|
+
const linesToProcess: number[] = [];
|
|
2347
|
+
for (let i = range.start - 1; i <= range.end - 1; i += 1) {
|
|
2348
|
+
const matches = regex.test(this.buffer.getLine(i));
|
|
2349
|
+
regex.lastIndex = 0;
|
|
2350
|
+
if (command.invert ? !matches : matches) {
|
|
2351
|
+
linesToProcess.push(i);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
if (command.command === "d" || command.command === "delete") {
|
|
2355
|
+
// Delete matching lines in reverse to preserve indices
|
|
2356
|
+
for (let i = linesToProcess.length - 1; i >= 0; i--) {
|
|
2357
|
+
this.buffer.lines.splice(linesToProcess[i]!, 1);
|
|
2358
|
+
}
|
|
2359
|
+
if (this.buffer.lines.length === 0) this.buffer.lines = [""];
|
|
2360
|
+
this.buffer.clampCursor();
|
|
2361
|
+
this.buffer.trailingNewline = true;
|
|
2362
|
+
} else {
|
|
2363
|
+
throw new VimError(`Unsupported :global sub-command: ${command.command}`);
|
|
2364
|
+
}
|
|
2365
|
+
});
|
|
2366
|
+
this.statusMessage = `Global: processed ${command.pattern}`;
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
#paste(after: boolean, count: number): void {
|
|
2373
|
+
if (!this.register.text) {
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
if (this.register.kind === "line") {
|
|
2377
|
+
const lines = this.register.text.split("\n");
|
|
2378
|
+
const insertAt = after ? this.buffer.cursor.line + 1 : this.buffer.cursor.line;
|
|
2379
|
+
for (let iteration = 0; iteration < count; iteration += 1) {
|
|
2380
|
+
this.buffer.insertLines(insertAt + iteration * lines.length, lines);
|
|
2381
|
+
}
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
const text = this.register.text.repeat(count);
|
|
2385
|
+
const offset = this.buffer.currentOffset() + (after ? 1 : 0);
|
|
2386
|
+
this.buffer.replaceOffsets(offset, offset, text, offset + text.length);
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
#readCount(tokens: readonly VimKeyToken[], index: number): { count: number; hasCount: boolean; nextIndex: number } {
|
|
2390
|
+
let cursor = index;
|
|
2391
|
+
let digits = "";
|
|
2392
|
+
while (cursor < tokens.length) {
|
|
2393
|
+
const value = tokens[cursor]?.value ?? "";
|
|
2394
|
+
if (!/^\d$/.test(value)) {
|
|
2395
|
+
break;
|
|
2396
|
+
}
|
|
2397
|
+
if (digits.length === 0 && value === "0") {
|
|
2398
|
+
break;
|
|
2399
|
+
}
|
|
2400
|
+
digits += value;
|
|
2401
|
+
cursor += 1;
|
|
2402
|
+
}
|
|
2403
|
+
return {
|
|
2404
|
+
count: digits.length > 0 ? Number.parseInt(digits, 10) : 1,
|
|
2405
|
+
hasCount: digits.length > 0,
|
|
2406
|
+
nextIndex: cursor,
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
}
|