@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
package/src/utils/git.ts
ADDED
|
@@ -0,0 +1,1536 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { $which, hasFsCode, isEnoent, Snowflake } from "@gajae-code/utils";
|
|
5
|
+
import {
|
|
6
|
+
parseDiffHunks as parseCommitDiffHunks,
|
|
7
|
+
parseFileDiffs,
|
|
8
|
+
parseFileHunks,
|
|
9
|
+
parseNumstat,
|
|
10
|
+
} from "../commit/git/diff";
|
|
11
|
+
import type { FileDiff, FileHunks, NumstatEntry } from "../commit/types";
|
|
12
|
+
import { ToolAbortError, ToolError, throwIfAborted } from "../tools/tool-errors";
|
|
13
|
+
|
|
14
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
15
|
+
// Types
|
|
16
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
17
|
+
|
|
18
|
+
export interface GitCommandResult {
|
|
19
|
+
exitCode: number;
|
|
20
|
+
stdout: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GitRepository {
|
|
25
|
+
commonDir: string;
|
|
26
|
+
gitDir: string;
|
|
27
|
+
gitEntryPath: string;
|
|
28
|
+
headPath: string;
|
|
29
|
+
repoRoot: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface GitStatusSummary {
|
|
33
|
+
staged: number;
|
|
34
|
+
unstaged: number;
|
|
35
|
+
untracked: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type HunkSelection = {
|
|
39
|
+
path: string;
|
|
40
|
+
hunks: { type: "all" } | { type: "indices"; indices: number[] } | { type: "lines"; start: number; end: number };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export interface StageHunksOptions {
|
|
44
|
+
readonly diffCached?: boolean;
|
|
45
|
+
readonly rawDiff?: string;
|
|
46
|
+
readonly signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface DiffOptions {
|
|
50
|
+
readonly allowFailure?: boolean;
|
|
51
|
+
readonly base?: string;
|
|
52
|
+
readonly binary?: boolean;
|
|
53
|
+
readonly cached?: boolean;
|
|
54
|
+
readonly env?: Record<string, string | undefined>;
|
|
55
|
+
readonly files?: readonly string[];
|
|
56
|
+
readonly head?: string;
|
|
57
|
+
readonly nameOnly?: boolean;
|
|
58
|
+
readonly noIndex?: { left: string; right: string };
|
|
59
|
+
readonly numstat?: boolean;
|
|
60
|
+
readonly signal?: AbortSignal;
|
|
61
|
+
readonly stat?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface StatusOptions {
|
|
65
|
+
readonly pathspecs?: readonly string[];
|
|
66
|
+
readonly porcelainV1?: boolean;
|
|
67
|
+
readonly signal?: AbortSignal;
|
|
68
|
+
readonly untrackedFiles?: "all" | "no" | "normal";
|
|
69
|
+
readonly z?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface CommitOptions {
|
|
73
|
+
readonly allowEmpty?: boolean;
|
|
74
|
+
readonly files?: readonly string[];
|
|
75
|
+
readonly signal?: AbortSignal;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface PushOptions {
|
|
79
|
+
readonly forceWithLease?: boolean;
|
|
80
|
+
readonly refspec?: string;
|
|
81
|
+
readonly remote?: string;
|
|
82
|
+
readonly signal?: AbortSignal;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface PatchOptions {
|
|
86
|
+
readonly cached?: boolean;
|
|
87
|
+
readonly check?: boolean;
|
|
88
|
+
readonly env?: Record<string, string | undefined>;
|
|
89
|
+
readonly signal?: AbortSignal;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface RestoreOptions {
|
|
93
|
+
readonly files?: readonly string[];
|
|
94
|
+
readonly signal?: AbortSignal;
|
|
95
|
+
readonly source?: string;
|
|
96
|
+
readonly staged?: boolean;
|
|
97
|
+
readonly worktree?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface CloneOptions {
|
|
101
|
+
readonly ref?: string;
|
|
102
|
+
readonly sha?: string;
|
|
103
|
+
readonly signal?: AbortSignal;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface GitHeadBase extends GitRepository {
|
|
107
|
+
headContent: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface GitRefHead extends GitHeadBase {
|
|
111
|
+
branchName: string | null;
|
|
112
|
+
commit: string | null;
|
|
113
|
+
kind: "ref";
|
|
114
|
+
ref: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface GitDetachedHead extends GitHeadBase {
|
|
118
|
+
commit: string | null;
|
|
119
|
+
kind: "detached";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type GitHeadState = GitRefHead | GitDetachedHead;
|
|
123
|
+
|
|
124
|
+
export interface GitWorktreeEntry {
|
|
125
|
+
branch?: string;
|
|
126
|
+
detached: boolean;
|
|
127
|
+
head?: string;
|
|
128
|
+
path: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
132
|
+
// Error
|
|
133
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
134
|
+
|
|
135
|
+
export class GitCommandError extends Error {
|
|
136
|
+
readonly args: readonly string[];
|
|
137
|
+
readonly result: GitCommandResult;
|
|
138
|
+
|
|
139
|
+
constructor(args: readonly string[], result: GitCommandResult) {
|
|
140
|
+
super(formatCommandFailure(args, result));
|
|
141
|
+
this.name = "GitCommandError";
|
|
142
|
+
this.args = [...args];
|
|
143
|
+
this.result = result;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
148
|
+
// Internal: Core execution
|
|
149
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
150
|
+
|
|
151
|
+
const NO_OPTIONAL_LOCKS = "--no-optional-locks";
|
|
152
|
+
const HEAD_REF_PREFIX = "ref:";
|
|
153
|
+
const LOCAL_BRANCH_PREFIX = "refs/heads/";
|
|
154
|
+
const DEFAULT_BRANCH_REFS = ["refs/remotes/origin/HEAD", "refs/remotes/upstream/HEAD"] as const;
|
|
155
|
+
const SHORT_LIVED_GIT_CONFIG: readonly (readonly [key: string, value: string])[] = [
|
|
156
|
+
["core.fsmonitor", "false"],
|
|
157
|
+
["core.untrackedCache", "false"],
|
|
158
|
+
];
|
|
159
|
+
const REMOTE_ALREADY_EXISTS = /remote .* already exists/i;
|
|
160
|
+
|
|
161
|
+
interface CommandOptions {
|
|
162
|
+
readonly env?: Record<string, string | undefined>;
|
|
163
|
+
readonly readOnly?: boolean;
|
|
164
|
+
readonly signal?: AbortSignal;
|
|
165
|
+
readonly stdin?: string | Uint8Array | ArrayBuffer | SharedArrayBuffer;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function normalizeStdin(input: CommandOptions["stdin"]): "ignore" | Uint8Array {
|
|
169
|
+
if (input === undefined) return "ignore";
|
|
170
|
+
if (typeof input === "string") return new TextEncoder().encode(input);
|
|
171
|
+
if (input instanceof Uint8Array) return input;
|
|
172
|
+
return new Uint8Array(input);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function ensureAvailable(): void {
|
|
176
|
+
if (!$which("git")) {
|
|
177
|
+
throw new Error("git is not installed.");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function formatCommandFailure(
|
|
182
|
+
args: readonly string[],
|
|
183
|
+
result: Pick<GitCommandResult, "exitCode" | "stdout" | "stderr">,
|
|
184
|
+
): string {
|
|
185
|
+
const stderr = result.stderr.trim();
|
|
186
|
+
if (stderr) return stderr;
|
|
187
|
+
const stdout = result.stdout.trim();
|
|
188
|
+
if (stdout) return stdout;
|
|
189
|
+
return `git ${args.join(" ")} failed with exit code ${result.exitCode}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function runCommand(
|
|
193
|
+
cwd: string,
|
|
194
|
+
args: readonly string[],
|
|
195
|
+
options: CommandOptions = {},
|
|
196
|
+
): Promise<GitCommandResult> {
|
|
197
|
+
const commandArgs = withShortLivedGitConfig(options.readOnly ? withNoOptionalLocks(args) : [...args]);
|
|
198
|
+
const child = Bun.spawn(["git", ...commandArgs], {
|
|
199
|
+
cwd,
|
|
200
|
+
env: options.env ? { ...process.env, GIT_OPTIONAL_LOCKS: "0", ...options.env } : undefined,
|
|
201
|
+
signal: options.signal,
|
|
202
|
+
stdin: normalizeStdin(options.stdin),
|
|
203
|
+
stdout: "pipe",
|
|
204
|
+
stderr: "pipe",
|
|
205
|
+
windowsHide: true,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
if (!child.stdout || !child.stderr) {
|
|
209
|
+
throw new Error("Failed to capture git command output.");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
213
|
+
new Response(child.stdout).text(),
|
|
214
|
+
new Response(child.stderr).text(),
|
|
215
|
+
child.exited,
|
|
216
|
+
]);
|
|
217
|
+
|
|
218
|
+
return { exitCode: exitCode ?? 0, stdout, stderr };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function withNoOptionalLocks(args: readonly string[]): string[] {
|
|
222
|
+
if (args.includes(NO_OPTIONAL_LOCKS)) return [...args];
|
|
223
|
+
return [NO_OPTIONAL_LOCKS, ...args];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function withShortLivedGitConfig(args: readonly string[]): string[] {
|
|
227
|
+
const prefix: string[] = [];
|
|
228
|
+
for (const [key, value] of SHORT_LIVED_GIT_CONFIG) {
|
|
229
|
+
if (hasGitConfig(args, key, value)) continue;
|
|
230
|
+
prefix.push("-c", `${key}=${value}`);
|
|
231
|
+
}
|
|
232
|
+
return [...prefix, ...args];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function hasGitConfig(args: readonly string[], key: string, value: string): boolean {
|
|
236
|
+
const expected = `${key}=${value}`;
|
|
237
|
+
for (let index = 0; index < args.length - 1; index += 1) {
|
|
238
|
+
if (args[index] === "-c" && args[index + 1] === expected) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async function runChecked(
|
|
246
|
+
cwd: string,
|
|
247
|
+
args: readonly string[],
|
|
248
|
+
options: CommandOptions = {},
|
|
249
|
+
): Promise<GitCommandResult> {
|
|
250
|
+
ensureAvailable();
|
|
251
|
+
const result = await runCommand(cwd, args, options);
|
|
252
|
+
if (result.exitCode !== 0) {
|
|
253
|
+
throw new GitCommandError(args, result);
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async function runEffect(cwd: string, args: readonly string[], options: CommandOptions = {}): Promise<void> {
|
|
259
|
+
await runChecked(cwd, args, options);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function runText(cwd: string, args: readonly string[], options: CommandOptions = {}): Promise<string> {
|
|
263
|
+
return (await runChecked(cwd, args, options)).stdout;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async function tryText(
|
|
267
|
+
cwd: string,
|
|
268
|
+
args: readonly string[],
|
|
269
|
+
options: CommandOptions = {},
|
|
270
|
+
): Promise<string | undefined> {
|
|
271
|
+
ensureAvailable();
|
|
272
|
+
const result = await runCommand(cwd, args, options);
|
|
273
|
+
if (result.exitCode !== 0) return undefined;
|
|
274
|
+
return result.stdout;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
278
|
+
// Internal: per-repo write serialization
|
|
279
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
280
|
+
|
|
281
|
+
// Git uses lock files (`.git/config.lock`, commit-graph chain locks,
|
|
282
|
+
// `packed-refs.lock`, …) for many of its mutating operations. Each is created
|
|
283
|
+
// O_EXCL with no waiter, so concurrent in-process git invocations against the
|
|
284
|
+
// same repository fail immediately rather than block. Worktrees share the
|
|
285
|
+
// primary repo's `.git` directory, so racing across worktrees has the same
|
|
286
|
+
// failure mode. We give callers a single per-repo serialization point keyed by
|
|
287
|
+
// the primary repo root: any block that mutates repo state should hold this
|
|
288
|
+
// lock so unrelated callers cannot collide on git's internal locks.
|
|
289
|
+
const repoWriteChain = new Map<string, Promise<unknown>>();
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Serialize an async block that mutates a git repository against other
|
|
293
|
+
* in-process callers operating on the same repository. The lock is keyed by
|
|
294
|
+
* the primary repo root so worktrees of the same repo share a single queue.
|
|
295
|
+
* Failures in one block do not poison the queue for the next caller.
|
|
296
|
+
*
|
|
297
|
+
* Not reentrant: do NOT nest acquisitions for the same repo. Helpers in this
|
|
298
|
+
* module never auto-acquire — callers wrap the critical section themselves.
|
|
299
|
+
*/
|
|
300
|
+
export async function withRepoLock<T>(cwd: string, fn: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
301
|
+
const key = (await repo.primaryRoot(cwd, signal)) ?? cwd;
|
|
302
|
+
const prior = repoWriteChain.get(key);
|
|
303
|
+
const run = (async () => {
|
|
304
|
+
if (prior) {
|
|
305
|
+
try {
|
|
306
|
+
await prior;
|
|
307
|
+
} catch {
|
|
308
|
+
// A prior caller failing must not block us from running.
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
throwIfAborted(signal);
|
|
312
|
+
return fn();
|
|
313
|
+
})();
|
|
314
|
+
repoWriteChain.set(key, run);
|
|
315
|
+
try {
|
|
316
|
+
return await run;
|
|
317
|
+
} finally {
|
|
318
|
+
if (repoWriteChain.get(key) === run) repoWriteChain.delete(key);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function splitLines(text: string): string[] {
|
|
323
|
+
return text
|
|
324
|
+
.split("\n")
|
|
325
|
+
.map(line => line.trim())
|
|
326
|
+
.filter(Boolean);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function trimScalar(text: string | undefined): string | undefined {
|
|
330
|
+
const trimmed = text?.trim();
|
|
331
|
+
return trimmed || undefined;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
335
|
+
// Internal: Argument builders
|
|
336
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
337
|
+
|
|
338
|
+
function buildDiffArgs(options: DiffOptions): string[] {
|
|
339
|
+
const args = ["diff"];
|
|
340
|
+
if (options.binary) args.push("--binary");
|
|
341
|
+
if (options.cached) args.push("--cached");
|
|
342
|
+
if (options.nameOnly) args.push("--name-only");
|
|
343
|
+
if (options.stat) args.push("--stat");
|
|
344
|
+
if (options.numstat) args.push("--numstat");
|
|
345
|
+
if (options.noIndex) {
|
|
346
|
+
args.push("--no-index", options.noIndex.left, options.noIndex.right);
|
|
347
|
+
return args;
|
|
348
|
+
}
|
|
349
|
+
if (options.base) {
|
|
350
|
+
args.push(options.base);
|
|
351
|
+
if (options.head) args.push(options.head);
|
|
352
|
+
}
|
|
353
|
+
if (options.files?.length) args.push("--", ...options.files);
|
|
354
|
+
return args;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function buildApplyArgs(patchPath: string, options: PatchOptions): string[] {
|
|
358
|
+
const args = ["apply"];
|
|
359
|
+
if (options.check) args.push("--check");
|
|
360
|
+
if (options.cached) args.push("--cached");
|
|
361
|
+
args.push("--binary", patchPath);
|
|
362
|
+
return args;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function writeTempPatch(content: string): Promise<string> {
|
|
366
|
+
const tempPath = path.join(os.tmpdir(), `gjc-git-patch-${Snowflake.next()}.patch`);
|
|
367
|
+
await Bun.write(tempPath, content);
|
|
368
|
+
return tempPath;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
372
|
+
// Internal: Repository resolution
|
|
373
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
374
|
+
|
|
375
|
+
type EntryType = "directory" | "file";
|
|
376
|
+
|
|
377
|
+
function shouldRetry(err: unknown, n: number) {
|
|
378
|
+
if (isEnoent(err) || hasFsCode(err, "ENFILE") || hasFsCode(err, "EMFILE")) return false;
|
|
379
|
+
if (hasFsCode(err, "EINTR")) return n < EINTR_MAX_RETRIES;
|
|
380
|
+
if (n > EINTR_MAX_RETRIES) throw err;
|
|
381
|
+
throw err;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Bounded retry for synchronous I/O against `EINTR`. POSIX permits short syscalls
|
|
386
|
+
* to be interrupted by signals; when that happens libc traditionally retries.
|
|
387
|
+
* Node's sync wrappers surface the raw `EINTR` so we replicate the retry locally.
|
|
388
|
+
* Any other error (and persistent EINTR after `EINTR_MAX_RETRIES`) is rethrown
|
|
389
|
+
* for the caller's normal "optional metadata" classifier to handle.
|
|
390
|
+
*/
|
|
391
|
+
const EINTR_MAX_RETRIES = 3;
|
|
392
|
+
function retryOnEintrSync<T>(op: () => T): T | null {
|
|
393
|
+
for (let attempt = 0; attempt <= EINTR_MAX_RETRIES; attempt += 1) {
|
|
394
|
+
try {
|
|
395
|
+
return op();
|
|
396
|
+
} catch (err) {
|
|
397
|
+
if (shouldRetry(err, attempt)) continue;
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
throw new Error("retryOnEintrSync: exhausted without resolution");
|
|
402
|
+
}
|
|
403
|
+
async function retryOnEintr<T>(op: () => Promise<T>): Promise<T | null> {
|
|
404
|
+
for (let attempt = 0; attempt <= EINTR_MAX_RETRIES; attempt += 1) {
|
|
405
|
+
try {
|
|
406
|
+
return await op();
|
|
407
|
+
} catch (err) {
|
|
408
|
+
if (shouldRetry(err, attempt)) continue;
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
throw new Error("retryOnEintr: exhausted without resolution");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function getEntryTypeSync(gitEntryPath: string): EntryType | null {
|
|
416
|
+
return retryOnEintrSync(() => {
|
|
417
|
+
const stat = fs.statSync(gitEntryPath);
|
|
418
|
+
if (stat.isDirectory()) return "directory";
|
|
419
|
+
if (stat.isFile()) return "file";
|
|
420
|
+
return null;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async function getEntryType(gitEntryPath: string): Promise<EntryType | null> {
|
|
425
|
+
return retryOnEintr(async () => {
|
|
426
|
+
const stat = await fs.promises.stat(gitEntryPath);
|
|
427
|
+
if (stat.isDirectory()) return "directory";
|
|
428
|
+
if (stat.isFile()) return "file";
|
|
429
|
+
return null;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function readOptionalTextSync(filePath: string): string | null {
|
|
434
|
+
return retryOnEintrSync(() => fs.readFileSync(filePath, "utf8"));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
async function readOptionalText(filePath: string): Promise<string | null> {
|
|
438
|
+
return retryOnEintr(async () => await Bun.file(filePath).text());
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function parseGitDirPointer(content: string): string | null {
|
|
442
|
+
const match = /^gitdir:\s*(.+)\s*$/iu.exec(content.trim());
|
|
443
|
+
return match?.[1] ?? null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function resolveGitDirSync(gitEntryPath: string, entryType: EntryType): string | null {
|
|
447
|
+
if (entryType === "directory") return gitEntryPath;
|
|
448
|
+
const content = readOptionalTextSync(gitEntryPath);
|
|
449
|
+
if (content === null) return null;
|
|
450
|
+
const parsed = parseGitDirPointer(content);
|
|
451
|
+
if (!parsed) return null;
|
|
452
|
+
const gitDir = path.resolve(path.dirname(gitEntryPath), parsed);
|
|
453
|
+
return getEntryTypeSync(gitDir) === "directory" ? gitDir : null;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
async function resolveGitDir(gitEntryPath: string, entryType: EntryType): Promise<string | null> {
|
|
457
|
+
if (entryType === "directory") return gitEntryPath;
|
|
458
|
+
const content = await readOptionalText(gitEntryPath);
|
|
459
|
+
if (content === null) return null;
|
|
460
|
+
const parsed = parseGitDirPointer(content);
|
|
461
|
+
if (!parsed) return null;
|
|
462
|
+
const gitDir = path.resolve(path.dirname(gitEntryPath), parsed);
|
|
463
|
+
return (await getEntryType(gitDir)) === "directory" ? gitDir : null;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function resolveCommonDirSync(gitDir: string): string {
|
|
467
|
+
const content = readOptionalTextSync(path.join(gitDir, "commondir"));
|
|
468
|
+
const relative = content?.trim();
|
|
469
|
+
if (!relative) return gitDir;
|
|
470
|
+
return path.resolve(gitDir, relative);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async function resolveCommonDir(gitDir: string): Promise<string> {
|
|
474
|
+
const content = await readOptionalText(path.join(gitDir, "commondir"));
|
|
475
|
+
const relative = content?.trim();
|
|
476
|
+
if (!relative) return gitDir;
|
|
477
|
+
return path.resolve(gitDir, relative);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function resolveRepoFromEntrySync(repoRoot: string, gitEntryPath: string, entryType: EntryType): GitRepository | null {
|
|
481
|
+
const gitDir = resolveGitDirSync(gitEntryPath, entryType);
|
|
482
|
+
if (!gitDir) return null;
|
|
483
|
+
return {
|
|
484
|
+
commonDir: resolveCommonDirSync(gitDir),
|
|
485
|
+
gitDir,
|
|
486
|
+
gitEntryPath,
|
|
487
|
+
headPath: path.join(gitDir, "HEAD"),
|
|
488
|
+
repoRoot,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async function resolveRepoFromEntry(
|
|
493
|
+
repoRoot: string,
|
|
494
|
+
gitEntryPath: string,
|
|
495
|
+
entryType: EntryType,
|
|
496
|
+
): Promise<GitRepository | null> {
|
|
497
|
+
const gitDir = await resolveGitDir(gitEntryPath, entryType);
|
|
498
|
+
if (!gitDir) return null;
|
|
499
|
+
return {
|
|
500
|
+
commonDir: await resolveCommonDir(gitDir),
|
|
501
|
+
gitDir,
|
|
502
|
+
gitEntryPath,
|
|
503
|
+
headPath: path.join(gitDir, "HEAD"),
|
|
504
|
+
repoRoot,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function resolveRepositorySync(startDir: string): GitRepository | null {
|
|
509
|
+
let current = path.resolve(startDir);
|
|
510
|
+
while (true) {
|
|
511
|
+
const gitEntryPath = path.join(current, ".git");
|
|
512
|
+
const entryType = getEntryTypeSync(gitEntryPath);
|
|
513
|
+
if (entryType) {
|
|
514
|
+
const repository = resolveRepoFromEntrySync(current, gitEntryPath, entryType);
|
|
515
|
+
if (repository) return repository;
|
|
516
|
+
}
|
|
517
|
+
const parent = path.dirname(current);
|
|
518
|
+
if (parent === current) return null;
|
|
519
|
+
current = parent;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async function resolveRepository(startDir: string): Promise<GitRepository | null> {
|
|
524
|
+
let current = path.resolve(startDir);
|
|
525
|
+
while (true) {
|
|
526
|
+
const gitEntryPath = path.join(current, ".git");
|
|
527
|
+
const entryType = await getEntryType(gitEntryPath);
|
|
528
|
+
if (entryType) {
|
|
529
|
+
const repository = await resolveRepoFromEntry(current, gitEntryPath, entryType);
|
|
530
|
+
if (repository) return repository;
|
|
531
|
+
}
|
|
532
|
+
const parent = path.dirname(current);
|
|
533
|
+
if (parent === current) return null;
|
|
534
|
+
current = parent;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
539
|
+
// Internal: Ref resolution
|
|
540
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
541
|
+
|
|
542
|
+
function getRefLookupDirs(repository: GitRepository): string[] {
|
|
543
|
+
if (repository.gitDir === repository.commonDir) return [repository.gitDir];
|
|
544
|
+
return [repository.gitDir, repository.commonDir];
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function normalizeRefValue(content: string | null): string | null {
|
|
548
|
+
const trimmed = content?.trim() ?? "";
|
|
549
|
+
return trimmed || null;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function parsePackedRefs(content: string | null, targetRef: string): string | null {
|
|
553
|
+
if (!content) return null;
|
|
554
|
+
for (const line of content.split("\n")) {
|
|
555
|
+
const trimmed = line.trim();
|
|
556
|
+
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("^")) continue;
|
|
557
|
+
const [sha, refName] = trimmed.split(" ", 2);
|
|
558
|
+
if (refName === targetRef && sha) return sha;
|
|
559
|
+
}
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function readRefSync(repository: GitRepository, targetRef: string): string | null {
|
|
564
|
+
for (const dir of getRefLookupDirs(repository)) {
|
|
565
|
+
const value = normalizeRefValue(readOptionalTextSync(path.join(dir, targetRef)));
|
|
566
|
+
if (value) return value;
|
|
567
|
+
}
|
|
568
|
+
for (const dir of getRefLookupDirs(repository)) {
|
|
569
|
+
const value = parsePackedRefs(readOptionalTextSync(path.join(dir, "packed-refs")), targetRef);
|
|
570
|
+
if (value) return value;
|
|
571
|
+
}
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
async function readRef(repository: GitRepository, targetRef: string): Promise<string | null> {
|
|
576
|
+
for (const dir of getRefLookupDirs(repository)) {
|
|
577
|
+
const value = normalizeRefValue(await readOptionalText(path.join(dir, targetRef)));
|
|
578
|
+
if (value) return value;
|
|
579
|
+
}
|
|
580
|
+
for (const dir of getRefLookupDirs(repository)) {
|
|
581
|
+
const value = parsePackedRefs(await readOptionalText(path.join(dir, "packed-refs")), targetRef);
|
|
582
|
+
if (value) return value;
|
|
583
|
+
}
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
588
|
+
// Internal: Head state parsing
|
|
589
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
590
|
+
|
|
591
|
+
function parseHeadStateSync(repository: GitRepository, headContent: string): GitHeadState {
|
|
592
|
+
const trimmed = headContent.trim();
|
|
593
|
+
if (!trimmed?.startsWith(HEAD_REF_PREFIX)) {
|
|
594
|
+
return { ...repository, commit: trimmed || null, headContent, kind: "detached" };
|
|
595
|
+
}
|
|
596
|
+
const refValue = trimmed.slice(HEAD_REF_PREFIX.length).trim();
|
|
597
|
+
const branchName = refValue.startsWith(LOCAL_BRANCH_PREFIX) ? refValue.slice(LOCAL_BRANCH_PREFIX.length) : null;
|
|
598
|
+
return {
|
|
599
|
+
...repository,
|
|
600
|
+
branchName,
|
|
601
|
+
commit: readRefSync(repository, refValue),
|
|
602
|
+
headContent,
|
|
603
|
+
kind: "ref",
|
|
604
|
+
ref: refValue,
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
async function parseHeadState(repository: GitRepository, headContent: string): Promise<GitHeadState> {
|
|
609
|
+
const trimmed = headContent.trim();
|
|
610
|
+
if (!trimmed?.startsWith(HEAD_REF_PREFIX)) {
|
|
611
|
+
return { ...repository, commit: trimmed || null, headContent, kind: "detached" };
|
|
612
|
+
}
|
|
613
|
+
const refValue = trimmed.slice(HEAD_REF_PREFIX.length).trim();
|
|
614
|
+
const branchName = refValue.startsWith(LOCAL_BRANCH_PREFIX) ? refValue.slice(LOCAL_BRANCH_PREFIX.length) : null;
|
|
615
|
+
return {
|
|
616
|
+
...repository,
|
|
617
|
+
branchName,
|
|
618
|
+
commit: await readRef(repository, refValue),
|
|
619
|
+
headContent,
|
|
620
|
+
kind: "ref",
|
|
621
|
+
ref: refValue,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function parseDefaultBranchRef(refPath: string, target: string | null): string | null {
|
|
626
|
+
if (!target?.startsWith(HEAD_REF_PREFIX)) return null;
|
|
627
|
+
const resolvedRef = target.slice(HEAD_REF_PREFIX.length).trim();
|
|
628
|
+
const remotePrefix = refPath.slice(0, -"HEAD".length);
|
|
629
|
+
if (!resolvedRef.startsWith(remotePrefix)) return null;
|
|
630
|
+
return resolvedRef.slice(remotePrefix.length) || null;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function stripRemotePrefix(refValue: string): string | null {
|
|
634
|
+
const slash = refValue.indexOf("/");
|
|
635
|
+
if (slash < 0) return refValue || null;
|
|
636
|
+
return refValue.slice(slash + 1) || null;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function parseWorktreeList(text: string): GitWorktreeEntry[] {
|
|
640
|
+
const trimmed = text.trim();
|
|
641
|
+
if (!trimmed) return [];
|
|
642
|
+
return trimmed
|
|
643
|
+
.split(/\n\s*\n/)
|
|
644
|
+
.map(block => block.trim())
|
|
645
|
+
.filter(Boolean)
|
|
646
|
+
.map(block => {
|
|
647
|
+
const entry: GitWorktreeEntry = { detached: false, path: "" };
|
|
648
|
+
for (const line of block.split("\n")) {
|
|
649
|
+
if (line.startsWith("worktree ")) entry.path = line.slice("worktree ".length);
|
|
650
|
+
else if (line.startsWith("HEAD ")) entry.head = line.slice("HEAD ".length);
|
|
651
|
+
else if (line.startsWith("branch ")) entry.branch = line.slice("branch ".length);
|
|
652
|
+
else if (line === "detached") entry.detached = true;
|
|
653
|
+
}
|
|
654
|
+
return entry;
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
659
|
+
// Internal: Hunk selection
|
|
660
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
661
|
+
|
|
662
|
+
function extractFileHeader(diffText: string): string {
|
|
663
|
+
const lines = diffText.split("\n");
|
|
664
|
+
const headerLines: string[] = [];
|
|
665
|
+
for (const line of lines) {
|
|
666
|
+
if (line.startsWith("@@")) break;
|
|
667
|
+
headerLines.push(line);
|
|
668
|
+
}
|
|
669
|
+
return headerLines.join("\n");
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function selectHunks(file: FileHunks, selector: HunkSelection["hunks"]): FileHunks["hunks"] {
|
|
673
|
+
if (selector.type === "indices") {
|
|
674
|
+
const wanted = new Set(selector.indices.map(v => Math.max(1, Math.floor(v))));
|
|
675
|
+
return file.hunks.filter(hunk => wanted.has(hunk.index + 1));
|
|
676
|
+
}
|
|
677
|
+
if (selector.type === "lines") {
|
|
678
|
+
const start = Math.floor(selector.start);
|
|
679
|
+
const end = Math.floor(selector.end);
|
|
680
|
+
return file.hunks.filter(hunk => hunk.newStart <= end && hunk.newStart + hunk.newLines - 1 >= start);
|
|
681
|
+
}
|
|
682
|
+
return file.hunks;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function parseStatusPorcelain(text: string): GitStatusSummary {
|
|
686
|
+
let staged = 0;
|
|
687
|
+
let unstaged = 0;
|
|
688
|
+
let untracked = 0;
|
|
689
|
+
for (const line of text.split("\n")) {
|
|
690
|
+
if (!line) continue;
|
|
691
|
+
const x = line[0];
|
|
692
|
+
const y = line[1];
|
|
693
|
+
if (x === "?" && y === "?") {
|
|
694
|
+
untracked += 1;
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (x && x !== " " && x !== "?") staged += 1;
|
|
698
|
+
if (y && y !== " ") unstaged += 1;
|
|
699
|
+
}
|
|
700
|
+
return { staged, unstaged, untracked };
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
704
|
+
// API: diff
|
|
705
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
706
|
+
|
|
707
|
+
/** Run `git diff` with the given options. Returns raw diff text. */
|
|
708
|
+
export const diff = Object.assign(
|
|
709
|
+
async function diff(cwd: string, options: DiffOptions = {}): Promise<string> {
|
|
710
|
+
const args = buildDiffArgs(options);
|
|
711
|
+
if (options.allowFailure) {
|
|
712
|
+
return (await runCommand(cwd, args, { env: options.env, readOnly: true, signal: options.signal })).stdout;
|
|
713
|
+
}
|
|
714
|
+
return runText(cwd, args, { env: options.env, readOnly: true, signal: options.signal });
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
/** List changed file paths. */
|
|
718
|
+
async changedFiles(
|
|
719
|
+
cwd: string,
|
|
720
|
+
options: Pick<DiffOptions, "cached" | "files" | "signal"> = {},
|
|
721
|
+
): Promise<string[]> {
|
|
722
|
+
return splitLines(await diff(cwd, { ...options, nameOnly: true }));
|
|
723
|
+
},
|
|
724
|
+
/** Parsed per-file add/remove counts. */
|
|
725
|
+
async numstat(cwd: string, options: Pick<DiffOptions, "cached" | "signal"> = {}): Promise<NumstatEntry[]> {
|
|
726
|
+
return parseNumstat(await diff(cwd, { ...options, numstat: true }));
|
|
727
|
+
},
|
|
728
|
+
/** Parsed diff hunks for the given files. */
|
|
729
|
+
async hunks(
|
|
730
|
+
cwd: string,
|
|
731
|
+
files: readonly string[],
|
|
732
|
+
options: { cached?: boolean; signal?: AbortSignal } = {},
|
|
733
|
+
): Promise<FileHunks[]> {
|
|
734
|
+
return parseCommitDiffHunks(
|
|
735
|
+
await diff(cwd, { cached: options.cached ?? true, files, signal: options.signal }),
|
|
736
|
+
);
|
|
737
|
+
},
|
|
738
|
+
/** Check whether a diff exists (uses `--quiet` for efficiency). */
|
|
739
|
+
async has(cwd: string, options: Pick<DiffOptions, "cached" | "files" | "signal"> = {}): Promise<boolean> {
|
|
740
|
+
const args = ["diff"];
|
|
741
|
+
if (options.cached) args.push("--cached");
|
|
742
|
+
args.push("--quiet");
|
|
743
|
+
if (options.files?.length) args.push("--", ...options.files);
|
|
744
|
+
const result = await runCommand(cwd, args, { readOnly: true, signal: options.signal });
|
|
745
|
+
if (result.exitCode === 0) return false;
|
|
746
|
+
if (result.exitCode === 1) return true;
|
|
747
|
+
throw new GitCommandError(args, result);
|
|
748
|
+
},
|
|
749
|
+
/** Diff between two tree-ish objects (`git diff-tree`). */
|
|
750
|
+
async tree(
|
|
751
|
+
cwd: string,
|
|
752
|
+
base: string,
|
|
753
|
+
headRef: string,
|
|
754
|
+
options: { binary?: boolean; signal?: AbortSignal; allowFailure?: boolean } = {},
|
|
755
|
+
): Promise<string> {
|
|
756
|
+
const args = ["diff-tree", "-r", "-p"];
|
|
757
|
+
if (options.binary) args.push("--binary");
|
|
758
|
+
args.push(base, headRef);
|
|
759
|
+
if (options.allowFailure) {
|
|
760
|
+
return (await runCommand(cwd, args, { readOnly: true, signal: options.signal })).stdout;
|
|
761
|
+
}
|
|
762
|
+
return runText(cwd, args, { readOnly: true, signal: options.signal });
|
|
763
|
+
},
|
|
764
|
+
/** Parse raw diff text into per-file diffs. */
|
|
765
|
+
parseFiles(text: string): FileDiff[] {
|
|
766
|
+
return parseFileDiffs(text);
|
|
767
|
+
},
|
|
768
|
+
/** Parse raw diff text into per-file hunks. */
|
|
769
|
+
parseHunks(text: string): FileHunks[] {
|
|
770
|
+
return parseCommitDiffHunks(text);
|
|
771
|
+
},
|
|
772
|
+
},
|
|
773
|
+
);
|
|
774
|
+
|
|
775
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
776
|
+
// API: status
|
|
777
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
778
|
+
|
|
779
|
+
/** Run `git status --porcelain`. Returns raw status text. */
|
|
780
|
+
export const status = Object.assign(
|
|
781
|
+
async function status(cwd: string, options: StatusOptions = {}): Promise<string> {
|
|
782
|
+
const args = ["status"];
|
|
783
|
+
args.push(options.porcelainV1 ? "--porcelain=v1" : "--porcelain");
|
|
784
|
+
if (options.z) args.push("-z");
|
|
785
|
+
if (options.untrackedFiles) args.push(`--untracked-files=${options.untrackedFiles}`);
|
|
786
|
+
if (options.pathspecs?.length) args.push("--", ...options.pathspecs);
|
|
787
|
+
return runText(cwd, args, { readOnly: true, signal: options.signal });
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
/** Parsed status counts (staged, unstaged, untracked). */
|
|
791
|
+
async summary(cwd: string, signal?: AbortSignal): Promise<GitStatusSummary | null> {
|
|
792
|
+
const result = await runCommand(cwd, ["status", "--porcelain"], { readOnly: true, signal });
|
|
793
|
+
if (result.exitCode !== 0) return null;
|
|
794
|
+
return parseStatusPorcelain(result.stdout);
|
|
795
|
+
},
|
|
796
|
+
/** Parse porcelain status text into counts. */
|
|
797
|
+
parse: parseStatusPorcelain,
|
|
798
|
+
},
|
|
799
|
+
);
|
|
800
|
+
|
|
801
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
802
|
+
// API: stage
|
|
803
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
804
|
+
|
|
805
|
+
export const stage = {
|
|
806
|
+
/** Stage files. Empty array stages all (`git add -A`). */
|
|
807
|
+
async files(cwd: string, files: readonly string[] = [], signal?: AbortSignal): Promise<void> {
|
|
808
|
+
const args = files.length === 0 ? ["add", "-A"] : ["add", "--", ...files];
|
|
809
|
+
await runEffect(cwd, args, { signal });
|
|
810
|
+
},
|
|
811
|
+
|
|
812
|
+
/** Selectively stage hunks from the provided diff or the current working tree diff. */
|
|
813
|
+
async hunks(cwd: string, selections: HunkSelection[], options: StageHunksOptions = {}): Promise<void> {
|
|
814
|
+
if (selections.length === 0) return;
|
|
815
|
+
const rawDiff = options.rawDiff ?? (await diff(cwd, { cached: options.diffCached, signal: options.signal }));
|
|
816
|
+
const fileDiffs = parseFileDiffs(rawDiff);
|
|
817
|
+
const fileDiffMap = new Map(fileDiffs.map(entry => [entry.filename, entry]));
|
|
818
|
+
const patchParts: string[] = [];
|
|
819
|
+
|
|
820
|
+
for (const selection of selections) {
|
|
821
|
+
const fileDiff = fileDiffMap.get(selection.path);
|
|
822
|
+
if (!fileDiff) throw new Error(`No diff found for ${selection.path}`);
|
|
823
|
+
if (fileDiff.isBinary) {
|
|
824
|
+
if (selection.hunks.type !== "all")
|
|
825
|
+
throw new Error(`Cannot select hunks for binary file ${selection.path}`);
|
|
826
|
+
patchParts.push(fileDiff.content);
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
if (selection.hunks.type === "all") {
|
|
830
|
+
patchParts.push(fileDiff.content);
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
const fileHunks = parseFileHunks(fileDiff);
|
|
834
|
+
const selected = selectHunks(fileHunks, selection.hunks);
|
|
835
|
+
if (selected.length === 0) throw new Error(`No hunks selected for ${selection.path}`);
|
|
836
|
+
const header = extractFileHeader(fileDiff.content);
|
|
837
|
+
patchParts.push([header, ...selected.map(h => h.content)].join("\n"));
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
const patchText = patch.join(patchParts);
|
|
841
|
+
if (!patchText.trim()) return;
|
|
842
|
+
await patch.applyText(cwd, patchText, { cached: true, signal: options.signal });
|
|
843
|
+
},
|
|
844
|
+
|
|
845
|
+
/** Unstage files. Empty array unstages all (`git reset`). */
|
|
846
|
+
async reset(cwd: string, files: readonly string[] = [], signal?: AbortSignal): Promise<void> {
|
|
847
|
+
const args = files.length === 0 ? ["reset"] : ["reset", "--", ...files];
|
|
848
|
+
await runEffect(cwd, args, { signal });
|
|
849
|
+
},
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
853
|
+
// API: commit, push, checkout
|
|
854
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
855
|
+
|
|
856
|
+
/** Create a commit with the given message (passed via stdin). */
|
|
857
|
+
export async function commit(cwd: string, message: string, options: CommitOptions = {}): Promise<GitCommandResult> {
|
|
858
|
+
const args = ["commit", "-F", "-"];
|
|
859
|
+
if (options.allowEmpty) args.push("--allow-empty");
|
|
860
|
+
if (options.files?.length) args.push("--", ...options.files);
|
|
861
|
+
return runChecked(cwd, args, { signal: options.signal, stdin: message });
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** Push the current branch. */
|
|
865
|
+
export async function push(cwd: string, options: PushOptions = {}): Promise<void> {
|
|
866
|
+
const args = ["push"];
|
|
867
|
+
if (options.forceWithLease) args.push("--force-with-lease");
|
|
868
|
+
if (options.remote) args.push(options.remote);
|
|
869
|
+
if (options.refspec) args.push(options.refspec);
|
|
870
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/** Checkout a ref. */
|
|
874
|
+
export async function checkout(cwd: string, ref: string, signal?: AbortSignal): Promise<void> {
|
|
875
|
+
await runEffect(cwd, ["checkout", ref], { signal });
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/** Fetch a specific refspec from a remote. */
|
|
879
|
+
export async function fetch(
|
|
880
|
+
cwd: string,
|
|
881
|
+
remote: string,
|
|
882
|
+
source: string,
|
|
883
|
+
target: string,
|
|
884
|
+
signal?: AbortSignal,
|
|
885
|
+
): Promise<void> {
|
|
886
|
+
await runEffect(cwd, ["fetch", remote, `+${source}:${target}`], { signal });
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Read a tree-ish into the index. */
|
|
890
|
+
export async function readTree(
|
|
891
|
+
cwd: string,
|
|
892
|
+
treeish: string,
|
|
893
|
+
options: Pick<CommandOptions, "env" | "signal"> = {},
|
|
894
|
+
): Promise<void> {
|
|
895
|
+
await runEffect(cwd, ["read-tree", treeish], options);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Write the current index as a tree and return its object id. */
|
|
899
|
+
export async function writeTree(cwd: string, options: Pick<CommandOptions, "env" | "signal"> = {}): Promise<string> {
|
|
900
|
+
return (await runText(cwd, ["write-tree"], options)).trim();
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
904
|
+
// API: show
|
|
905
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
906
|
+
|
|
907
|
+
/** Run `git show` on a revision. */
|
|
908
|
+
export const show = Object.assign(
|
|
909
|
+
async function show(
|
|
910
|
+
cwd: string,
|
|
911
|
+
revision: string,
|
|
912
|
+
options: { format?: string; signal?: AbortSignal } = {},
|
|
913
|
+
): Promise<string> {
|
|
914
|
+
return runText(cwd, ["show", `--format=${options.format ?? ""}`, revision], {
|
|
915
|
+
readOnly: true,
|
|
916
|
+
signal: options.signal,
|
|
917
|
+
});
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
/** Get the path prefix of the current directory relative to the repo root. */
|
|
921
|
+
async prefix(cwd: string, signal?: AbortSignal): Promise<string> {
|
|
922
|
+
return (await runText(cwd, ["rev-parse", "--show-prefix"], { readOnly: true, signal })).trim();
|
|
923
|
+
},
|
|
924
|
+
},
|
|
925
|
+
);
|
|
926
|
+
|
|
927
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
928
|
+
// API: log
|
|
929
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
930
|
+
|
|
931
|
+
export const log = {
|
|
932
|
+
/** Recent commit subjects (one-line each). */
|
|
933
|
+
async subjects(cwd: string, count: number, signal?: AbortSignal): Promise<string[]> {
|
|
934
|
+
return splitLines(await runText(cwd, ["log", `-n${count}`, "--pretty=format:%s"], { readOnly: true, signal }));
|
|
935
|
+
},
|
|
936
|
+
/** Recent commits as `<short-sha> <subject>` onelines. */
|
|
937
|
+
async onelines(cwd: string, count: number, signal?: AbortSignal): Promise<string[]> {
|
|
938
|
+
return splitLines(
|
|
939
|
+
await runText(cwd, ["log", `-${count}`, "--oneline", "--no-decorate"], { readOnly: true, signal }),
|
|
940
|
+
);
|
|
941
|
+
},
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
945
|
+
// API: branch
|
|
946
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
947
|
+
|
|
948
|
+
export const branch = {
|
|
949
|
+
/** Current branch name, or null if detached/unavailable. */
|
|
950
|
+
async current(cwd: string, signal?: AbortSignal): Promise<string | null> {
|
|
951
|
+
const headState = await resolveHead(cwd);
|
|
952
|
+
if (headState?.kind === "ref") return headState.branchName ?? headState.ref;
|
|
953
|
+
const result = await runCommand(cwd, ["symbolic-ref", "--short", "HEAD"], { readOnly: true, signal });
|
|
954
|
+
if (result.exitCode !== 0) return null;
|
|
955
|
+
return result.stdout.trim() || null;
|
|
956
|
+
},
|
|
957
|
+
|
|
958
|
+
/** Default branch name (from remote HEAD refs). */
|
|
959
|
+
async default(cwd: string, signal?: AbortSignal): Promise<string | null> {
|
|
960
|
+
const repository = await resolveRepository(cwd);
|
|
961
|
+
if (repository) {
|
|
962
|
+
for (const refPath of DEFAULT_BRANCH_REFS) {
|
|
963
|
+
const target = await readRef(repository, refPath);
|
|
964
|
+
const branchName = parseDefaultBranchRef(refPath, target);
|
|
965
|
+
if (branchName) return branchName;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
for (const remoteRef of ["origin/HEAD", "upstream/HEAD"]) {
|
|
969
|
+
const result = await runCommand(cwd, ["rev-parse", "--abbrev-ref", remoteRef], { readOnly: true, signal });
|
|
970
|
+
if (result.exitCode !== 0) continue;
|
|
971
|
+
const branchName = stripRemotePrefix(result.stdout.trim());
|
|
972
|
+
if (branchName) return branchName;
|
|
973
|
+
}
|
|
974
|
+
return null;
|
|
975
|
+
},
|
|
976
|
+
|
|
977
|
+
/** Create a new branch at the given start point. */
|
|
978
|
+
async create(cwd: string, name: string, startPoint = "HEAD", signal?: AbortSignal): Promise<void> {
|
|
979
|
+
await runEffect(cwd, ["branch", name, startPoint], { signal });
|
|
980
|
+
},
|
|
981
|
+
|
|
982
|
+
/** Force-move a branch to a new start point. */
|
|
983
|
+
async force(cwd: string, name: string, startPoint: string, signal?: AbortSignal): Promise<void> {
|
|
984
|
+
await runEffect(cwd, ["branch", "--force", name, startPoint], { signal });
|
|
985
|
+
},
|
|
986
|
+
|
|
987
|
+
/** Delete a branch. Throws on failure. */
|
|
988
|
+
async delete(cwd: string, name: string, options: { force?: boolean; signal?: AbortSignal } = {}): Promise<void> {
|
|
989
|
+
await runEffect(cwd, ["branch", options.force === false ? "-d" : "-D", name], { signal: options.signal });
|
|
990
|
+
},
|
|
991
|
+
|
|
992
|
+
/** Delete a branch. Returns false on failure instead of throwing. */
|
|
993
|
+
async tryDelete(
|
|
994
|
+
cwd: string,
|
|
995
|
+
name: string,
|
|
996
|
+
options: { force?: boolean; signal?: AbortSignal } = {},
|
|
997
|
+
): Promise<boolean> {
|
|
998
|
+
const result = await runCommand(cwd, ["branch", options.force === false ? "-d" : "-D", name], {
|
|
999
|
+
signal: options.signal,
|
|
1000
|
+
});
|
|
1001
|
+
return result.exitCode === 0;
|
|
1002
|
+
},
|
|
1003
|
+
|
|
1004
|
+
/** Create and checkout a new branch. */
|
|
1005
|
+
async checkoutNew(cwd: string, name: string, signal?: AbortSignal): Promise<void> {
|
|
1006
|
+
await runEffect(cwd, ["checkout", "-b", name], { signal });
|
|
1007
|
+
},
|
|
1008
|
+
|
|
1009
|
+
/** List branches. Pass `{ all: true }` to include remotes. */
|
|
1010
|
+
async list(cwd: string, options: { all?: boolean; signal?: AbortSignal } = {}): Promise<string[]> {
|
|
1011
|
+
const args = ["branch"];
|
|
1012
|
+
if (options.all) args.push("-a");
|
|
1013
|
+
args.push("--format=%(refname:short)");
|
|
1014
|
+
return splitLines(await runText(cwd, args, { readOnly: true, signal: options.signal }));
|
|
1015
|
+
},
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1019
|
+
// API: remote
|
|
1020
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1021
|
+
|
|
1022
|
+
export const remote = {
|
|
1023
|
+
/** List remote names. */
|
|
1024
|
+
async list(cwd: string, signal?: AbortSignal): Promise<string[]> {
|
|
1025
|
+
return splitLines(await runText(cwd, ["remote"], { readOnly: true, signal }));
|
|
1026
|
+
},
|
|
1027
|
+
|
|
1028
|
+
/** Get the URL for a remote. */
|
|
1029
|
+
async url(cwd: string, name: string, signal?: AbortSignal): Promise<string | undefined> {
|
|
1030
|
+
return trimScalar(await tryText(cwd, ["remote", "get-url", name], { readOnly: true, signal }));
|
|
1031
|
+
},
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Add a remote pointing at `url`. Idempotent: if a remote named `name`
|
|
1035
|
+
* already exists with the same URL (e.g. an in-process race or a leftover
|
|
1036
|
+
* remote from a previous run), this is treated as success. Throws when the
|
|
1037
|
+
* remote exists with a different URL — that's a real conflict the caller
|
|
1038
|
+
* needs to resolve, not paper over.
|
|
1039
|
+
*/
|
|
1040
|
+
async add(cwd: string, name: string, url: string, signal?: AbortSignal): Promise<void> {
|
|
1041
|
+
const result = await runCommand(cwd, ["remote", "add", name, url], { signal });
|
|
1042
|
+
if (result.exitCode === 0) return;
|
|
1043
|
+
if (REMOTE_ALREADY_EXISTS.test(result.stderr)) {
|
|
1044
|
+
const existing = await remote.url(cwd, name, signal);
|
|
1045
|
+
if (existing === url) return;
|
|
1046
|
+
throw new ToolError(`remote ${name} already exists with URL ${existing ?? "(unset)"}, expected ${url}`);
|
|
1047
|
+
}
|
|
1048
|
+
throw new GitCommandError(["remote", "add", name, url], result);
|
|
1049
|
+
},
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1053
|
+
// API: ref
|
|
1054
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1055
|
+
|
|
1056
|
+
export const ref = {
|
|
1057
|
+
/** Check if a ref exists. */
|
|
1058
|
+
async exists(cwd: string, refName: string, signal?: AbortSignal): Promise<boolean> {
|
|
1059
|
+
if (refName === "HEAD") return (await head.sha(cwd, signal)) !== null;
|
|
1060
|
+
const repository = await resolveRepository(cwd);
|
|
1061
|
+
if (repository && refName.startsWith("refs/")) return (await readRef(repository, refName)) !== null;
|
|
1062
|
+
const result = await runCommand(cwd, ["show-ref", "--verify", "--quiet", refName], { readOnly: true, signal });
|
|
1063
|
+
return result.exitCode === 0;
|
|
1064
|
+
},
|
|
1065
|
+
|
|
1066
|
+
/** Resolve a ref to its commit SHA. */
|
|
1067
|
+
async resolve(cwd: string, refName: string, signal?: AbortSignal): Promise<string | null> {
|
|
1068
|
+
if (refName === "HEAD") return head.sha(cwd, signal);
|
|
1069
|
+
const repository = await resolveRepository(cwd);
|
|
1070
|
+
if (repository && refName.startsWith("refs/")) return readRef(repository, refName);
|
|
1071
|
+
const result = await runCommand(cwd, ["rev-parse", refName], { readOnly: true, signal });
|
|
1072
|
+
if (result.exitCode !== 0) return null;
|
|
1073
|
+
return result.stdout.trim() || null;
|
|
1074
|
+
},
|
|
1075
|
+
|
|
1076
|
+
/** Tags pointing at a ref. */
|
|
1077
|
+
async tags(cwd: string, refName = "HEAD", signal?: AbortSignal): Promise<string[]> {
|
|
1078
|
+
return splitLines(
|
|
1079
|
+
await runText(
|
|
1080
|
+
cwd,
|
|
1081
|
+
[
|
|
1082
|
+
"for-each-ref",
|
|
1083
|
+
"--points-at",
|
|
1084
|
+
refName,
|
|
1085
|
+
"--sort=-version:refname",
|
|
1086
|
+
"--format=%(refname:strip=2)",
|
|
1087
|
+
"refs/tags",
|
|
1088
|
+
],
|
|
1089
|
+
{ readOnly: true, signal },
|
|
1090
|
+
),
|
|
1091
|
+
);
|
|
1092
|
+
},
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1096
|
+
// API: config
|
|
1097
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1098
|
+
|
|
1099
|
+
export const config = {
|
|
1100
|
+
async get(cwd: string, key: string, signal?: AbortSignal): Promise<string | undefined> {
|
|
1101
|
+
return trimScalar(await tryText(cwd, ["config", "--get", key], { readOnly: true, signal }));
|
|
1102
|
+
},
|
|
1103
|
+
|
|
1104
|
+
async set(cwd: string, key: string, value: string, signal?: AbortSignal): Promise<void> {
|
|
1105
|
+
await runEffect(cwd, ["config", key, value], { signal });
|
|
1106
|
+
},
|
|
1107
|
+
|
|
1108
|
+
async getBranch(cwd: string, branchName: string, key: string, signal?: AbortSignal): Promise<string | undefined> {
|
|
1109
|
+
return config.get(cwd, `branch.${branchName}.${key}`, signal);
|
|
1110
|
+
},
|
|
1111
|
+
|
|
1112
|
+
async setBranch(cwd: string, branchName: string, key: string, value: string, signal?: AbortSignal): Promise<void> {
|
|
1113
|
+
return config.set(cwd, `branch.${branchName}.${key}`, value, signal);
|
|
1114
|
+
},
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1118
|
+
// API: worktree
|
|
1119
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1120
|
+
|
|
1121
|
+
export const worktree = {
|
|
1122
|
+
async add(
|
|
1123
|
+
cwd: string,
|
|
1124
|
+
worktreePath: string,
|
|
1125
|
+
refName: string,
|
|
1126
|
+
options: { detach?: boolean; signal?: AbortSignal } = {},
|
|
1127
|
+
): Promise<void> {
|
|
1128
|
+
const args = ["worktree", "add"];
|
|
1129
|
+
if (options.detach) args.push("--detach");
|
|
1130
|
+
args.push(worktreePath, refName);
|
|
1131
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
1132
|
+
},
|
|
1133
|
+
|
|
1134
|
+
async remove(
|
|
1135
|
+
cwd: string,
|
|
1136
|
+
worktreePath: string,
|
|
1137
|
+
options: { force?: boolean; signal?: AbortSignal } = {},
|
|
1138
|
+
): Promise<void> {
|
|
1139
|
+
const args = ["worktree", "remove"];
|
|
1140
|
+
if (options.force ?? true) args.push("-f");
|
|
1141
|
+
args.push(worktreePath);
|
|
1142
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
1143
|
+
},
|
|
1144
|
+
|
|
1145
|
+
async tryRemove(
|
|
1146
|
+
cwd: string,
|
|
1147
|
+
worktreePath: string,
|
|
1148
|
+
options: { force?: boolean; signal?: AbortSignal } = {},
|
|
1149
|
+
): Promise<boolean> {
|
|
1150
|
+
const args = ["worktree", "remove"];
|
|
1151
|
+
if (options.force ?? true) args.push("-f");
|
|
1152
|
+
args.push(worktreePath);
|
|
1153
|
+
const result = await runCommand(cwd, args, { signal: options.signal });
|
|
1154
|
+
return result.exitCode === 0;
|
|
1155
|
+
},
|
|
1156
|
+
|
|
1157
|
+
async list(cwd: string, signal?: AbortSignal): Promise<GitWorktreeEntry[]> {
|
|
1158
|
+
return parseWorktreeList(await runText(cwd, ["worktree", "list", "--porcelain"], { readOnly: true, signal }));
|
|
1159
|
+
},
|
|
1160
|
+
|
|
1161
|
+
async prune(cwd: string, signal?: AbortSignal): Promise<void> {
|
|
1162
|
+
await runEffect(cwd, ["worktree", "prune"], { signal });
|
|
1163
|
+
},
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1167
|
+
// API: patch
|
|
1168
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1169
|
+
|
|
1170
|
+
export const patch = {
|
|
1171
|
+
/** Apply a patch file. */
|
|
1172
|
+
async apply(cwd: string, patchPath: string, options: PatchOptions = {}): Promise<void> {
|
|
1173
|
+
await runEffect(cwd, buildApplyArgs(patchPath, options), { env: options.env, signal: options.signal });
|
|
1174
|
+
},
|
|
1175
|
+
|
|
1176
|
+
/** Apply a patch from a string (writes to a temp file). */
|
|
1177
|
+
async applyText(cwd: string, patchText: string, options: PatchOptions = {}): Promise<void> {
|
|
1178
|
+
if (!patchText.trim()) return;
|
|
1179
|
+
const tempPath = await writeTempPatch(patchText);
|
|
1180
|
+
try {
|
|
1181
|
+
await patch.apply(cwd, tempPath, options);
|
|
1182
|
+
} finally {
|
|
1183
|
+
await fs.promises.rm(tempPath, { force: true });
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
|
|
1187
|
+
/** Check if a patch file can be applied cleanly. */
|
|
1188
|
+
async canApply(cwd: string, patchPath: string, options: Omit<PatchOptions, "check"> = {}): Promise<boolean> {
|
|
1189
|
+
const result = await runCommand(cwd, buildApplyArgs(patchPath, { ...options, check: true }), {
|
|
1190
|
+
env: options.env,
|
|
1191
|
+
readOnly: true,
|
|
1192
|
+
signal: options.signal,
|
|
1193
|
+
});
|
|
1194
|
+
return result.exitCode === 0;
|
|
1195
|
+
},
|
|
1196
|
+
|
|
1197
|
+
/** Check if a patch string can be applied cleanly. */
|
|
1198
|
+
async canApplyText(cwd: string, patchText: string, options: Omit<PatchOptions, "check"> = {}): Promise<boolean> {
|
|
1199
|
+
if (!patchText.trim()) return true;
|
|
1200
|
+
const tempPath = await writeTempPatch(patchText);
|
|
1201
|
+
try {
|
|
1202
|
+
return await patch.canApply(cwd, tempPath, options);
|
|
1203
|
+
} finally {
|
|
1204
|
+
await fs.promises.rm(tempPath, { force: true });
|
|
1205
|
+
}
|
|
1206
|
+
},
|
|
1207
|
+
|
|
1208
|
+
/** Join patch parts into a single patch string. */
|
|
1209
|
+
join(parts: string[]): string {
|
|
1210
|
+
return `${parts
|
|
1211
|
+
.map(part => (part.endsWith("\n") ? part : `${part}\n`))
|
|
1212
|
+
.join("\n")
|
|
1213
|
+
.replace(/\n+$/, "")}\n`;
|
|
1214
|
+
},
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1218
|
+
// API: cherryPick
|
|
1219
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1220
|
+
|
|
1221
|
+
export const cherryPick = Object.assign(
|
|
1222
|
+
async function cherryPick(cwd: string, revision: string, signal?: AbortSignal): Promise<void> {
|
|
1223
|
+
await runEffect(cwd, ["cherry-pick", revision], { signal });
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
async abort(cwd: string, signal?: AbortSignal): Promise<void> {
|
|
1227
|
+
await runEffect(cwd, ["cherry-pick", "--abort"], { signal });
|
|
1228
|
+
},
|
|
1229
|
+
},
|
|
1230
|
+
);
|
|
1231
|
+
|
|
1232
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1233
|
+
// API: stash
|
|
1234
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1235
|
+
|
|
1236
|
+
export const stash = {
|
|
1237
|
+
/** Stash working tree + index changes. Returns true when git created a new stash entry. */
|
|
1238
|
+
async push(cwd: string, message?: string): Promise<boolean> {
|
|
1239
|
+
ensureAvailable();
|
|
1240
|
+
const previousStash = await ref.resolve(cwd, "refs/stash");
|
|
1241
|
+
const args = ["stash", "push", "--include-untracked"];
|
|
1242
|
+
if (message) args.push("-m", message);
|
|
1243
|
+
await runEffect(cwd, args);
|
|
1244
|
+
const nextStash = await ref.resolve(cwd, "refs/stash");
|
|
1245
|
+
return nextStash !== null && nextStash !== previousStash;
|
|
1246
|
+
},
|
|
1247
|
+
/** Pop the most recent stash entry, optionally restoring its staged state. */
|
|
1248
|
+
async pop(cwd: string, options?: { index?: boolean }): Promise<void> {
|
|
1249
|
+
const args = ["stash", "pop"];
|
|
1250
|
+
if (options?.index) args.push("--index");
|
|
1251
|
+
await runEffect(cwd, args);
|
|
1252
|
+
},
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1256
|
+
// API: clone, restore, clean
|
|
1257
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1258
|
+
|
|
1259
|
+
export async function clone(url: string, targetDir: string, options: CloneOptions = {}): Promise<void> {
|
|
1260
|
+
ensureAvailable();
|
|
1261
|
+
const absoluteTarget = path.resolve(targetDir);
|
|
1262
|
+
await fs.promises.mkdir(path.dirname(absoluteTarget), { recursive: true });
|
|
1263
|
+
|
|
1264
|
+
const args = ["clone", "--depth", "1"];
|
|
1265
|
+
if (options.ref) args.push("--branch", options.ref, "--single-branch");
|
|
1266
|
+
else args.push("--single-branch");
|
|
1267
|
+
args.push(url, absoluteTarget);
|
|
1268
|
+
|
|
1269
|
+
try {
|
|
1270
|
+
await runEffect(path.dirname(absoluteTarget), args, { signal: options.signal });
|
|
1271
|
+
if (options.sha) {
|
|
1272
|
+
try {
|
|
1273
|
+
await checkout(absoluteTarget, options.sha, options.signal);
|
|
1274
|
+
} catch {
|
|
1275
|
+
await fs.promises.rm(absoluteTarget, { force: true, recursive: true });
|
|
1276
|
+
throw new Error(`Failed to checkout SHA ${options.sha} - shallow clone may not contain this commit`);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
} catch (err) {
|
|
1280
|
+
await fs.promises.rm(absoluteTarget, { force: true, recursive: true });
|
|
1281
|
+
throw err;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
export async function restore(cwd: string, options: RestoreOptions = {}): Promise<void> {
|
|
1286
|
+
const args = ["restore"];
|
|
1287
|
+
if (options.source) args.push(`--source=${options.source}`);
|
|
1288
|
+
if (options.staged) args.push("--staged");
|
|
1289
|
+
if (options.worktree) args.push("--worktree");
|
|
1290
|
+
if (options.files?.length) args.push("--", ...options.files);
|
|
1291
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Run `git reset` with options. Default is a soft reset (no flag); pass `hard: true` for a destructive reset.
|
|
1296
|
+
*
|
|
1297
|
+
* NOTE: stage.reset() handles the per-file unstaging case. This helper exists for tree-wide resets.
|
|
1298
|
+
*/
|
|
1299
|
+
export async function reset(
|
|
1300
|
+
cwd: string,
|
|
1301
|
+
options: { hard?: boolean; mixed?: boolean; soft?: boolean; target?: string; signal?: AbortSignal } = {},
|
|
1302
|
+
): Promise<void> {
|
|
1303
|
+
const args = ["reset"];
|
|
1304
|
+
if (options.hard) args.push("--hard");
|
|
1305
|
+
else if (options.mixed) args.push("--mixed");
|
|
1306
|
+
else if (options.soft) args.push("--soft");
|
|
1307
|
+
if (options.target) args.push(options.target);
|
|
1308
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
export async function clean(
|
|
1312
|
+
cwd: string,
|
|
1313
|
+
options: { ignoredOnly?: boolean; paths?: readonly string[]; signal?: AbortSignal } = {},
|
|
1314
|
+
): Promise<void> {
|
|
1315
|
+
const args = ["clean", options.ignoredOnly ? "-fdX" : "-fd"];
|
|
1316
|
+
if (options.paths?.length) args.push("--", ...options.paths);
|
|
1317
|
+
await runEffect(cwd, args, { signal: options.signal });
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1321
|
+
// API: ls
|
|
1322
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1323
|
+
|
|
1324
|
+
export const ls = {
|
|
1325
|
+
/** List files tracked or untracked by git. */
|
|
1326
|
+
async files(
|
|
1327
|
+
cwd: string,
|
|
1328
|
+
options: { others?: boolean; excludeStandard?: boolean; signal?: AbortSignal } = {},
|
|
1329
|
+
): Promise<string[]> {
|
|
1330
|
+
const args = ["ls-files"];
|
|
1331
|
+
if (options.others) args.push("--others");
|
|
1332
|
+
if (options.excludeStandard) args.push("--exclude-standard");
|
|
1333
|
+
return splitLines(await runText(cwd, args, { readOnly: true, signal: options.signal }));
|
|
1334
|
+
},
|
|
1335
|
+
|
|
1336
|
+
/** List untracked files (excludes ignored). */
|
|
1337
|
+
async untracked(cwd: string, signal?: AbortSignal): Promise<string[]> {
|
|
1338
|
+
return ls.files(cwd, { others: true, excludeStandard: true, signal });
|
|
1339
|
+
},
|
|
1340
|
+
|
|
1341
|
+
/** List submodule paths (recursive). */
|
|
1342
|
+
async submodules(cwd: string, signal?: AbortSignal): Promise<string[]> {
|
|
1343
|
+
const output = await runCommand(cwd, ["submodule", "--quiet", "foreach", "--recursive", "echo $sm_path"], {
|
|
1344
|
+
readOnly: true,
|
|
1345
|
+
signal,
|
|
1346
|
+
});
|
|
1347
|
+
return splitLines(output.stdout);
|
|
1348
|
+
},
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1352
|
+
// API: head
|
|
1353
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1354
|
+
|
|
1355
|
+
export const head = {
|
|
1356
|
+
/** Full HEAD state (branch, commit, repo info). */
|
|
1357
|
+
async resolve(cwd: string): Promise<GitHeadState | null> {
|
|
1358
|
+
const repository = await resolveRepository(cwd);
|
|
1359
|
+
if (!repository) return null;
|
|
1360
|
+
const content = await readOptionalText(repository.headPath);
|
|
1361
|
+
if (content === null) return null;
|
|
1362
|
+
return parseHeadState(repository, content);
|
|
1363
|
+
},
|
|
1364
|
+
|
|
1365
|
+
/** Full HEAD state (synchronous). */
|
|
1366
|
+
resolveSync(cwd: string): GitHeadState | null {
|
|
1367
|
+
const repository = resolveRepositorySync(cwd);
|
|
1368
|
+
if (!repository) return null;
|
|
1369
|
+
const content = readOptionalTextSync(repository.headPath);
|
|
1370
|
+
if (content === null) return null;
|
|
1371
|
+
return parseHeadStateSync(repository, content);
|
|
1372
|
+
},
|
|
1373
|
+
|
|
1374
|
+
/** Current HEAD commit SHA. */
|
|
1375
|
+
async sha(cwd: string, signal?: AbortSignal): Promise<string | null> {
|
|
1376
|
+
const headState = await head.resolve(cwd);
|
|
1377
|
+
if (headState?.commit) return headState.commit;
|
|
1378
|
+
const result = await runCommand(cwd, ["rev-parse", "HEAD"], { readOnly: true, signal });
|
|
1379
|
+
if (result.exitCode !== 0) return null;
|
|
1380
|
+
return result.stdout.trim() || null;
|
|
1381
|
+
},
|
|
1382
|
+
|
|
1383
|
+
/** Abbreviated HEAD commit SHA. */
|
|
1384
|
+
async short(cwd: string, length = 7, signal?: AbortSignal): Promise<string | null> {
|
|
1385
|
+
const result = await runCommand(cwd, ["rev-parse", `--short=${length}`, "HEAD"], { readOnly: true, signal });
|
|
1386
|
+
if (result.exitCode !== 0) return null;
|
|
1387
|
+
return result.stdout.trim() || null;
|
|
1388
|
+
},
|
|
1389
|
+
};
|
|
1390
|
+
|
|
1391
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1392
|
+
// API: repo
|
|
1393
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1394
|
+
|
|
1395
|
+
export const repo = {
|
|
1396
|
+
/** Resolve the repository root (may be a worktree root). */
|
|
1397
|
+
async root(cwd: string, signal?: AbortSignal): Promise<string | null> {
|
|
1398
|
+
const repository = await resolveRepository(cwd);
|
|
1399
|
+
if (repository) return repository.repoRoot;
|
|
1400
|
+
const result = await runCommand(cwd, ["rev-parse", "--show-toplevel"], { readOnly: true, signal });
|
|
1401
|
+
if (result.exitCode !== 0) return null;
|
|
1402
|
+
return result.stdout.trim() || null;
|
|
1403
|
+
},
|
|
1404
|
+
|
|
1405
|
+
/** Resolve the primary repository root (not a worktree — the main checkout). */
|
|
1406
|
+
async primaryRoot(cwd: string, signal?: AbortSignal): Promise<string | null> {
|
|
1407
|
+
const repository = await resolveRepository(cwd);
|
|
1408
|
+
if (repository) {
|
|
1409
|
+
if (path.basename(repository.commonDir) === ".git") return path.dirname(repository.commonDir);
|
|
1410
|
+
return repository.repoRoot;
|
|
1411
|
+
}
|
|
1412
|
+
const repoRoot = await repo.root(cwd, signal);
|
|
1413
|
+
if (!repoRoot) return null;
|
|
1414
|
+
const commonDir = await runText(repoRoot, ["rev-parse", "--path-format=absolute", "--git-common-dir"], {
|
|
1415
|
+
readOnly: true,
|
|
1416
|
+
signal,
|
|
1417
|
+
});
|
|
1418
|
+
if (path.basename(commonDir.trim()) === ".git") return path.dirname(commonDir.trim());
|
|
1419
|
+
return repoRoot;
|
|
1420
|
+
},
|
|
1421
|
+
|
|
1422
|
+
/** Full GitRepository metadata (sync). */
|
|
1423
|
+
resolveSync(cwd: string): GitRepository | null {
|
|
1424
|
+
return resolveRepositorySync(cwd);
|
|
1425
|
+
},
|
|
1426
|
+
|
|
1427
|
+
/** Full GitRepository metadata. */
|
|
1428
|
+
resolve(cwd: string): Promise<GitRepository | null> {
|
|
1429
|
+
return resolveRepository(cwd);
|
|
1430
|
+
},
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1433
|
+
// Helper used during head resolution — defined here to reference `head` namespace.
|
|
1434
|
+
async function resolveHead(cwd: string): Promise<GitHeadState | null> {
|
|
1435
|
+
return head.resolve(cwd);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1439
|
+
// API: github (GitHub CLI)
|
|
1440
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1441
|
+
|
|
1442
|
+
export interface GhCommandResult {
|
|
1443
|
+
exitCode: number;
|
|
1444
|
+
stdout: string;
|
|
1445
|
+
stderr: string;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
export interface GhCommandOptions {
|
|
1449
|
+
repoProvided?: boolean;
|
|
1450
|
+
trimOutput?: boolean;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
function formatGhFailure(args: readonly string[], stdout: string, stderr: string, options?: GhCommandOptions): string {
|
|
1454
|
+
const message = (stderr || stdout).trim();
|
|
1455
|
+
if (message.includes("gh auth login") || message.includes("not logged into any GitHub hosts")) {
|
|
1456
|
+
return "GitHub CLI is not authenticated. Run `gh auth login`.";
|
|
1457
|
+
}
|
|
1458
|
+
if (
|
|
1459
|
+
!options?.repoProvided &&
|
|
1460
|
+
(message.includes("not a git repository") ||
|
|
1461
|
+
message.includes("no git remotes found") ||
|
|
1462
|
+
message.includes("unable to determine current repository"))
|
|
1463
|
+
) {
|
|
1464
|
+
return "GitHub repository context is unavailable. Pass `repo` explicitly or run the tool inside a GitHub checkout.";
|
|
1465
|
+
}
|
|
1466
|
+
if (message.length > 0) return message;
|
|
1467
|
+
return `GitHub CLI command failed: gh ${args.join(" ")}`;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
export const github = {
|
|
1471
|
+
/** Check if `gh` CLI is installed. */
|
|
1472
|
+
available(): boolean {
|
|
1473
|
+
return Boolean($which("gh"));
|
|
1474
|
+
},
|
|
1475
|
+
|
|
1476
|
+
/** Run a raw `gh` CLI command. Does not throw on non-zero exit. */
|
|
1477
|
+
async run(cwd: string, args: string[], signal?: AbortSignal, options?: GhCommandOptions): Promise<GhCommandResult> {
|
|
1478
|
+
throwIfAborted(signal);
|
|
1479
|
+
if (!$which("gh")) {
|
|
1480
|
+
throw new ToolError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/.");
|
|
1481
|
+
}
|
|
1482
|
+
try {
|
|
1483
|
+
const child = Bun.spawn(["gh", ...args], {
|
|
1484
|
+
cwd,
|
|
1485
|
+
stdin: "ignore",
|
|
1486
|
+
stdout: "pipe",
|
|
1487
|
+
stderr: "pipe",
|
|
1488
|
+
windowsHide: true,
|
|
1489
|
+
signal,
|
|
1490
|
+
});
|
|
1491
|
+
if (!child.stdout || !child.stderr) {
|
|
1492
|
+
throw new ToolError("Failed to capture GitHub CLI output.");
|
|
1493
|
+
}
|
|
1494
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
1495
|
+
new Response(child.stdout).text(),
|
|
1496
|
+
new Response(child.stderr).text(),
|
|
1497
|
+
child.exited,
|
|
1498
|
+
]);
|
|
1499
|
+
throwIfAborted(signal);
|
|
1500
|
+
const trim = options?.trimOutput !== false;
|
|
1501
|
+
return {
|
|
1502
|
+
exitCode: exitCode ?? 0,
|
|
1503
|
+
stdout: trim ? stdout.trim() : stdout,
|
|
1504
|
+
stderr: trim ? stderr.trim() : stderr,
|
|
1505
|
+
};
|
|
1506
|
+
} catch (error) {
|
|
1507
|
+
if (signal?.aborted) throw new ToolAbortError();
|
|
1508
|
+
throw error;
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
|
|
1512
|
+
/** Run `gh` and parse stdout as JSON. Throws on non-zero exit or invalid JSON. */
|
|
1513
|
+
async json<T>(cwd: string, args: string[], signal?: AbortSignal, options?: GhCommandOptions): Promise<T> {
|
|
1514
|
+
const result = await github.run(cwd, args, signal, options);
|
|
1515
|
+
if (result.exitCode !== 0) {
|
|
1516
|
+
throw new ToolError(formatGhFailure(args, result.stdout, result.stderr, options));
|
|
1517
|
+
}
|
|
1518
|
+
if (!result.stdout) {
|
|
1519
|
+
throw new ToolError("GitHub CLI returned empty output.");
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
return JSON.parse(result.stdout) as T;
|
|
1523
|
+
} catch {
|
|
1524
|
+
throw new ToolError("GitHub CLI returned invalid JSON output.");
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
|
|
1528
|
+
/** Run `gh` and return stdout as text. Throws on non-zero exit. */
|
|
1529
|
+
async text(cwd: string, args: string[], signal?: AbortSignal, options?: GhCommandOptions): Promise<string> {
|
|
1530
|
+
const result = await github.run(cwd, args, signal, options);
|
|
1531
|
+
if (result.exitCode !== 0) {
|
|
1532
|
+
throw new ToolError(formatGhFailure(args, result.stdout, result.stderr, options));
|
|
1533
|
+
}
|
|
1534
|
+
return result.stdout;
|
|
1535
|
+
},
|
|
1536
|
+
};
|