@dirgha/code 1.2.0
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/LICENSE +101 -0
- package/README.md +674 -0
- package/dist/dirgha.mjs +2185 -0
- package/dist_v2/acp/index.d.ts +1 -0
- package/dist_v2/acp/index.js +2 -0
- package/dist_v2/acp/server.d.ts +31 -0
- package/dist_v2/acp/server.js +137 -0
- package/dist_v2/cli/auth-cmd.d.ts +10 -0
- package/dist_v2/cli/auth-cmd.js +69 -0
- package/dist_v2/cli/config.d.ts +46 -0
- package/dist_v2/cli/config.js +70 -0
- package/dist_v2/cli/flags.d.ts +10 -0
- package/dist_v2/cli/flags.js +49 -0
- package/dist_v2/cli/flows/full-cycle.d.ts +30 -0
- package/dist_v2/cli/flows/full-cycle.js +39 -0
- package/dist_v2/cli/flows/index.d.ts +2 -0
- package/dist_v2/cli/flows/index.js +3 -0
- package/dist_v2/cli/flows/tarball.d.ts +10 -0
- package/dist_v2/cli/flows/tarball.js +47 -0
- package/dist_v2/cli/index.d.ts +4 -0
- package/dist_v2/cli/index.js +5 -0
- package/dist_v2/cli/interactive.d.ts +21 -0
- package/dist_v2/cli/interactive.js +207 -0
- package/dist_v2/cli/main.d.ts +10 -0
- package/dist_v2/cli/main.js +173 -0
- package/dist_v2/cli/models-cmd.d.ts +6 -0
- package/dist_v2/cli/models-cmd.js +50 -0
- package/dist_v2/cli/setup.d.ts +13 -0
- package/dist_v2/cli/setup.js +128 -0
- package/dist_v2/cli/slash/account.d.ts +10 -0
- package/dist_v2/cli/slash/account.js +59 -0
- package/dist_v2/cli/slash/clear.d.ts +8 -0
- package/dist_v2/cli/slash/clear.js +15 -0
- package/dist_v2/cli/slash/compact.d.ts +7 -0
- package/dist_v2/cli/slash/compact.js +13 -0
- package/dist_v2/cli/slash/config.d.ts +8 -0
- package/dist_v2/cli/slash/config.js +49 -0
- package/dist_v2/cli/slash/exit.d.ts +7 -0
- package/dist_v2/cli/slash/exit.js +16 -0
- package/dist_v2/cli/slash/fleet.d.ts +7 -0
- package/dist_v2/cli/slash/fleet.js +22 -0
- package/dist_v2/cli/slash/help.d.ts +9 -0
- package/dist_v2/cli/slash/help.js +31 -0
- package/dist_v2/cli/slash/history.d.ts +7 -0
- package/dist_v2/cli/slash/history.js +42 -0
- package/dist_v2/cli/slash/index.d.ts +30 -0
- package/dist_v2/cli/slash/index.js +52 -0
- package/dist_v2/cli/slash/init.d.ts +8 -0
- package/dist_v2/cli/slash/init.js +57 -0
- package/dist_v2/cli/slash/keys.d.ts +8 -0
- package/dist_v2/cli/slash/keys.js +101 -0
- package/dist_v2/cli/slash/login.d.ts +10 -0
- package/dist_v2/cli/slash/login.js +47 -0
- package/dist_v2/cli/slash/memory.d.ts +8 -0
- package/dist_v2/cli/slash/memory.js +101 -0
- package/dist_v2/cli/slash/mode.d.ts +8 -0
- package/dist_v2/cli/slash/mode.js +30 -0
- package/dist_v2/cli/slash/models.d.ts +8 -0
- package/dist_v2/cli/slash/models.js +73 -0
- package/dist_v2/cli/slash/resume.d.ts +8 -0
- package/dist_v2/cli/slash/resume.js +24 -0
- package/dist_v2/cli/slash/session.d.ts +8 -0
- package/dist_v2/cli/slash/session.js +74 -0
- package/dist_v2/cli/slash/setup.d.ts +8 -0
- package/dist_v2/cli/slash/setup.js +50 -0
- package/dist_v2/cli/slash/status.d.ts +7 -0
- package/dist_v2/cli/slash/status.js +37 -0
- package/dist_v2/cli/slash/theme.d.ts +9 -0
- package/dist_v2/cli/slash/theme.js +53 -0
- package/dist_v2/cli/slash/types.d.ts +14 -0
- package/dist_v2/cli/slash/types.js +9 -0
- package/dist_v2/cli/slash/upgrade.d.ts +9 -0
- package/dist_v2/cli/slash/upgrade.js +66 -0
- package/dist_v2/cli/slash.d.ts +72 -0
- package/dist_v2/cli/slash.js +77 -0
- package/dist_v2/cli/subcommands/ask.d.ts +17 -0
- package/dist_v2/cli/subcommands/ask.js +76 -0
- package/dist_v2/cli/subcommands/audit.d.ts +15 -0
- package/dist_v2/cli/subcommands/audit.js +128 -0
- package/dist_v2/cli/subcommands/chat.d.ts +13 -0
- package/dist_v2/cli/subcommands/chat.js +72 -0
- package/dist_v2/cli/subcommands/compact.d.ts +14 -0
- package/dist_v2/cli/subcommands/compact.js +114 -0
- package/dist_v2/cli/subcommands/doctor.d.ts +11 -0
- package/dist_v2/cli/subcommands/doctor.js +103 -0
- package/dist_v2/cli/subcommands/export-session.d.ts +10 -0
- package/dist_v2/cli/subcommands/export-session.js +60 -0
- package/dist_v2/cli/subcommands/import-session.d.ts +11 -0
- package/dist_v2/cli/subcommands/import-session.js +77 -0
- package/dist_v2/cli/subcommands/index.d.ts +40 -0
- package/dist_v2/cli/subcommands/index.js +38 -0
- package/dist_v2/cli/subcommands/init.d.ts +10 -0
- package/dist_v2/cli/subcommands/init.js +74 -0
- package/dist_v2/cli/subcommands/keys.d.ts +12 -0
- package/dist_v2/cli/subcommands/keys.js +136 -0
- package/dist_v2/cli/subcommands/login.d.ts +10 -0
- package/dist_v2/cli/subcommands/login.js +60 -0
- package/dist_v2/cli/subcommands/logout.d.ts +10 -0
- package/dist_v2/cli/subcommands/logout.js +21 -0
- package/dist_v2/cli/subcommands/models.d.ts +14 -0
- package/dist_v2/cli/subcommands/models.js +144 -0
- package/dist_v2/cli/subcommands/setup.d.ts +11 -0
- package/dist_v2/cli/subcommands/setup.js +107 -0
- package/dist_v2/cli/subcommands/stats.d.ts +13 -0
- package/dist_v2/cli/subcommands/stats.js +148 -0
- package/dist_v2/cli/subcommands/status.d.ts +14 -0
- package/dist_v2/cli/subcommands/status.js +91 -0
- package/dist_v2/cli/submit-paper.d.ts +15 -0
- package/dist_v2/cli/submit-paper.js +68 -0
- package/dist_v2/context/_fts.d.ts +62 -0
- package/dist_v2/context/_fts.js +195 -0
- package/dist_v2/context/branch.d.ts +18 -0
- package/dist_v2/context/branch.js +66 -0
- package/dist_v2/context/compaction.d.ts +26 -0
- package/dist_v2/context/compaction.js +120 -0
- package/dist_v2/context/index.d.ts +5 -0
- package/dist_v2/context/index.js +6 -0
- package/dist_v2/context/knowledge.d.ts +38 -0
- package/dist_v2/context/knowledge.js +146 -0
- package/dist_v2/context/memory.d.ts +80 -0
- package/dist_v2/context/memory.js +276 -0
- package/dist_v2/context/mode.d.ts +25 -0
- package/dist_v2/context/mode.js +81 -0
- package/dist_v2/context/session.d.ts +56 -0
- package/dist_v2/context/session.js +108 -0
- package/dist_v2/daemon/index.d.ts +2 -0
- package/dist_v2/daemon/index.js +3 -0
- package/dist_v2/daemon/protocol.d.ts +73 -0
- package/dist_v2/daemon/protocol.js +6 -0
- package/dist_v2/daemon/server.d.ts +35 -0
- package/dist_v2/daemon/server.js +191 -0
- package/dist_v2/eval/index.d.ts +5 -0
- package/dist_v2/eval/index.js +6 -0
- package/dist_v2/eval/regression.d.ts +14 -0
- package/dist_v2/eval/regression.js +106 -0
- package/dist_v2/eval/reporter.d.ts +7 -0
- package/dist_v2/eval/reporter.js +34 -0
- package/dist_v2/eval/swe-bench.d.ts +18 -0
- package/dist_v2/eval/swe-bench.js +23 -0
- package/dist_v2/eval/terminal-bench.d.ts +13 -0
- package/dist_v2/eval/terminal-bench.js +19 -0
- package/dist_v2/eval/types.d.ts +36 -0
- package/dist_v2/eval/types.js +5 -0
- package/dist_v2/fleet/apply-back.d.ts +27 -0
- package/dist_v2/fleet/apply-back.js +191 -0
- package/dist_v2/fleet/cli-command.d.ts +61 -0
- package/dist_v2/fleet/cli-command.js +329 -0
- package/dist_v2/fleet/index.d.ts +21 -0
- package/dist_v2/fleet/index.js +21 -0
- package/dist_v2/fleet/runner.d.ts +28 -0
- package/dist_v2/fleet/runner.js +347 -0
- package/dist_v2/fleet/tripleshot.d.ts +21 -0
- package/dist_v2/fleet/tripleshot.js +222 -0
- package/dist_v2/fleet/types.d.ts +193 -0
- package/dist_v2/fleet/types.js +24 -0
- package/dist_v2/fleet/worktree.d.ts +51 -0
- package/dist_v2/fleet/worktree.js +176 -0
- package/dist_v2/hooks/index.d.ts +1 -0
- package/dist_v2/hooks/index.js +2 -0
- package/dist_v2/hooks/registry.d.ts +21 -0
- package/dist_v2/hooks/registry.js +40 -0
- package/dist_v2/index.d.ts +12 -0
- package/dist_v2/index.js +11 -0
- package/dist_v2/integrations/arniko-client.d.ts +42 -0
- package/dist_v2/integrations/arniko-client.js +86 -0
- package/dist_v2/integrations/auth.d.ts +45 -0
- package/dist_v2/integrations/auth.js +54 -0
- package/dist_v2/integrations/billing.d.ts +71 -0
- package/dist_v2/integrations/billing.js +107 -0
- package/dist_v2/integrations/bucky-client.d.ts +105 -0
- package/dist_v2/integrations/bucky-client.js +76 -0
- package/dist_v2/integrations/deploy-client.d.ts +60 -0
- package/dist_v2/integrations/deploy-client.js +87 -0
- package/dist_v2/integrations/device-auth.d.ts +48 -0
- package/dist_v2/integrations/device-auth.js +192 -0
- package/dist_v2/integrations/entitlements.d.ts +34 -0
- package/dist_v2/integrations/entitlements.js +43 -0
- package/dist_v2/integrations/http.d.ts +22 -0
- package/dist_v2/integrations/http.js +114 -0
- package/dist_v2/integrations/index.d.ts +8 -0
- package/dist_v2/integrations/index.js +15 -0
- package/dist_v2/intelligence/cost.d.ts +28 -0
- package/dist_v2/intelligence/cost.js +58 -0
- package/dist_v2/intelligence/error-classifier.d.ts +8 -0
- package/dist_v2/intelligence/error-classifier.js +71 -0
- package/dist_v2/intelligence/index.d.ts +5 -0
- package/dist_v2/intelligence/index.js +6 -0
- package/dist_v2/intelligence/prices.d.ts +13 -0
- package/dist_v2/intelligence/prices.js +26 -0
- package/dist_v2/intelligence/smart-router.d.ts +21 -0
- package/dist_v2/intelligence/smart-router.js +59 -0
- package/dist_v2/intelligence/telemetry.d.ts +22 -0
- package/dist_v2/intelligence/telemetry.js +31 -0
- package/dist_v2/kernel/agent-loop.d.ts +32 -0
- package/dist_v2/kernel/agent-loop.js +151 -0
- package/dist_v2/kernel/event-stream.d.ts +18 -0
- package/dist_v2/kernel/event-stream.js +102 -0
- package/dist_v2/kernel/index.d.ts +4 -0
- package/dist_v2/kernel/index.js +5 -0
- package/dist_v2/kernel/message.d.ts +29 -0
- package/dist_v2/kernel/message.js +118 -0
- package/dist_v2/kernel/types.d.ts +206 -0
- package/dist_v2/kernel/types.js +9 -0
- package/dist_v2/mcp/client.d.ts +44 -0
- package/dist_v2/mcp/client.js +63 -0
- package/dist_v2/mcp/index.d.ts +3 -0
- package/dist_v2/mcp/index.js +4 -0
- package/dist_v2/mcp/tool-bridge.d.ts +11 -0
- package/dist_v2/mcp/tool-bridge.js +33 -0
- package/dist_v2/mcp/transport.d.ts +29 -0
- package/dist_v2/mcp/transport.js +73 -0
- package/dist_v2/parity/index.d.ts +3 -0
- package/dist_v2/parity/index.js +4 -0
- package/dist_v2/parity/mock-openai-compat.d.ts +15 -0
- package/dist_v2/parity/mock-openai-compat.js +35 -0
- package/dist_v2/parity/runner.d.ts +21 -0
- package/dist_v2/parity/runner.js +76 -0
- package/dist_v2/parity/scenarios.d.ts +20 -0
- package/dist_v2/parity/scenarios.js +70 -0
- package/dist_v2/providers/anthropic.d.ts +21 -0
- package/dist_v2/providers/anthropic.js +191 -0
- package/dist_v2/providers/dispatch.d.ts +11 -0
- package/dist_v2/providers/dispatch.js +45 -0
- package/dist_v2/providers/fireworks.d.ts +18 -0
- package/dist_v2/providers/fireworks.js +44 -0
- package/dist_v2/providers/gemini.d.ts +19 -0
- package/dist_v2/providers/gemini.js +188 -0
- package/dist_v2/providers/http.d.ts +41 -0
- package/dist_v2/providers/http.js +188 -0
- package/dist_v2/providers/iface.d.ts +18 -0
- package/dist_v2/providers/iface.js +18 -0
- package/dist_v2/providers/index.d.ts +39 -0
- package/dist_v2/providers/index.js +51 -0
- package/dist_v2/providers/nvidia.d.ts +27 -0
- package/dist_v2/providers/nvidia.js +142 -0
- package/dist_v2/providers/ollama.d.ts +15 -0
- package/dist_v2/providers/ollama.js +37 -0
- package/dist_v2/providers/openai-compat.d.ts +29 -0
- package/dist_v2/providers/openai-compat.js +239 -0
- package/dist_v2/providers/openai.d.ts +20 -0
- package/dist_v2/providers/openai.js +107 -0
- package/dist_v2/providers/openrouter.d.ts +24 -0
- package/dist_v2/providers/openrouter.js +69 -0
- package/dist_v2/safety/approval-bus.d.ts +26 -0
- package/dist_v2/safety/approval-bus.js +48 -0
- package/dist_v2/safety/audit-log.d.ts +27 -0
- package/dist_v2/safety/audit-log.js +71 -0
- package/dist_v2/safety/index.d.ts +4 -0
- package/dist_v2/safety/index.js +5 -0
- package/dist_v2/safety/policy.d.ts +32 -0
- package/dist_v2/safety/policy.js +131 -0
- package/dist_v2/safety/sandbox/bwrap.d.ts +11 -0
- package/dist_v2/safety/sandbox/bwrap.js +52 -0
- package/dist_v2/safety/sandbox/iface.d.ts +29 -0
- package/dist_v2/safety/sandbox/iface.js +8 -0
- package/dist_v2/safety/sandbox/index.d.ts +7 -0
- package/dist_v2/safety/sandbox/index.js +8 -0
- package/dist_v2/safety/sandbox/landlock.d.ts +17 -0
- package/dist_v2/safety/sandbox/landlock.js +26 -0
- package/dist_v2/safety/sandbox/noop.d.ts +12 -0
- package/dist_v2/safety/sandbox/noop.js +52 -0
- package/dist_v2/safety/sandbox/seatbelt.d.ts +11 -0
- package/dist_v2/safety/sandbox/seatbelt.js +49 -0
- package/dist_v2/safety/sandbox/select.d.ts +6 -0
- package/dist_v2/safety/sandbox/select.js +42 -0
- package/dist_v2/safety/sandbox/windows.d.ts +13 -0
- package/dist_v2/safety/sandbox/windows.js +22 -0
- package/dist_v2/skills/index.d.ts +3 -0
- package/dist_v2/skills/index.js +4 -0
- package/dist_v2/skills/loader.d.ts +38 -0
- package/dist_v2/skills/loader.js +102 -0
- package/dist_v2/skills/matcher.d.ts +14 -0
- package/dist_v2/skills/matcher.js +72 -0
- package/dist_v2/skills/runtime.d.ts +13 -0
- package/dist_v2/skills/runtime.js +40 -0
- package/dist_v2/subagents/delegator.d.ts +36 -0
- package/dist_v2/subagents/delegator.js +82 -0
- package/dist_v2/subagents/index.d.ts +2 -0
- package/dist_v2/subagents/index.js +3 -0
- package/dist_v2/subagents/pool.d.ts +18 -0
- package/dist_v2/subagents/pool.js +31 -0
- package/dist_v2/tools/browser.d.ts +27 -0
- package/dist_v2/tools/browser.js +179 -0
- package/dist_v2/tools/checkpoint.d.ts +25 -0
- package/dist_v2/tools/checkpoint.js +222 -0
- package/dist_v2/tools/cron.d.ts +32 -0
- package/dist_v2/tools/cron.js +160 -0
- package/dist_v2/tools/diff.d.ts +18 -0
- package/dist_v2/tools/diff.js +117 -0
- package/dist_v2/tools/exec.d.ts +19 -0
- package/dist_v2/tools/exec.js +49 -0
- package/dist_v2/tools/fs-edit.d.ts +11 -0
- package/dist_v2/tools/fs-edit.js +81 -0
- package/dist_v2/tools/fs-ls.d.ts +7 -0
- package/dist_v2/tools/fs-ls.js +57 -0
- package/dist_v2/tools/fs-read.d.ts +7 -0
- package/dist_v2/tools/fs-read.js +60 -0
- package/dist_v2/tools/fs-write.d.ts +8 -0
- package/dist_v2/tools/fs-write.js +46 -0
- package/dist_v2/tools/git.d.ts +8 -0
- package/dist_v2/tools/git.js +57 -0
- package/dist_v2/tools/index.d.ts +25 -0
- package/dist_v2/tools/index.js +39 -0
- package/dist_v2/tools/multimodal.d.ts +41 -0
- package/dist_v2/tools/multimodal.js +381 -0
- package/dist_v2/tools/permission.d.ts +27 -0
- package/dist_v2/tools/permission.js +43 -0
- package/dist_v2/tools/registry.d.ts +44 -0
- package/dist_v2/tools/registry.js +62 -0
- package/dist_v2/tools/search-glob.d.ts +7 -0
- package/dist_v2/tools/search-glob.js +98 -0
- package/dist_v2/tools/search-grep.d.ts +7 -0
- package/dist_v2/tools/search-grep.js +109 -0
- package/dist_v2/tools/shell.d.ts +10 -0
- package/dist_v2/tools/shell.js +76 -0
- package/dist_v2/tools/task.d.ts +8 -0
- package/dist_v2/tools/task.js +37 -0
- package/dist_v2/tui/approval.d.ts +7 -0
- package/dist_v2/tui/approval.js +55 -0
- package/dist_v2/tui/index.d.ts +4 -0
- package/dist_v2/tui/index.js +5 -0
- package/dist_v2/tui/ink/App.d.ts +39 -0
- package/dist_v2/tui/ink/App.js +206 -0
- package/dist_v2/tui/ink/components/AtFileComplete.d.ts +25 -0
- package/dist_v2/tui/ink/components/AtFileComplete.js +158 -0
- package/dist_v2/tui/ink/components/HelpOverlay.d.ts +24 -0
- package/dist_v2/tui/ink/components/HelpOverlay.js +130 -0
- package/dist_v2/tui/ink/components/InputBox.d.ts +35 -0
- package/dist_v2/tui/ink/components/InputBox.js +153 -0
- package/dist_v2/tui/ink/components/Logo.d.ts +12 -0
- package/dist_v2/tui/ink/components/Logo.js +27 -0
- package/dist_v2/tui/ink/components/ModelPicker.d.ts +26 -0
- package/dist_v2/tui/ink/components/ModelPicker.js +80 -0
- package/dist_v2/tui/ink/components/PasteCollapse.d.ts +36 -0
- package/dist_v2/tui/ink/components/PasteCollapse.js +59 -0
- package/dist_v2/tui/ink/components/StatusBar.d.ts +18 -0
- package/dist_v2/tui/ink/components/StatusBar.js +41 -0
- package/dist_v2/tui/ink/components/StreamingText.d.ts +14 -0
- package/dist_v2/tui/ink/components/StreamingText.js +11 -0
- package/dist_v2/tui/ink/components/ThinkingBlock.d.ts +13 -0
- package/dist_v2/tui/ink/components/ThinkingBlock.js +13 -0
- package/dist_v2/tui/ink/components/ToolBox.d.ts +20 -0
- package/dist_v2/tui/ink/components/ToolBox.js +63 -0
- package/dist_v2/tui/ink/components/vim-bindings.d.ts +43 -0
- package/dist_v2/tui/ink/components/vim-bindings.js +135 -0
- package/dist_v2/tui/ink/index.d.ts +39 -0
- package/dist_v2/tui/ink/index.js +47 -0
- package/dist_v2/tui/ink/use-event-projection.d.ts +51 -0
- package/dist_v2/tui/ink/use-event-projection.js +126 -0
- package/dist_v2/tui/ink/use-overlays.d.ts +24 -0
- package/dist_v2/tui/ink/use-overlays.js +50 -0
- package/dist_v2/tui/renderer.d.ts +19 -0
- package/dist_v2/tui/renderer.js +64 -0
- package/dist_v2/tui/status-bar.d.ts +12 -0
- package/dist_v2/tui/status-bar.js +16 -0
- package/dist_v2/tui/theme.d.ts +27 -0
- package/dist_v2/tui/theme.js +56 -0
- package/dist_v2/utils/json-repair.d.ts +7 -0
- package/dist_v2/utils/json-repair.js +45 -0
- package/package.json +113 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Dropdown shown below the InputBox while the user is typing an
|
|
4
|
+
* `@…` file reference. The list is fuzzy-matched against a cached
|
|
5
|
+
* snapshot of the working tree (walked once on first open).
|
|
6
|
+
*
|
|
7
|
+
* Contract with App/InputBox:
|
|
8
|
+
* - Parent renders this component when `query !== null`.
|
|
9
|
+
* - Parent extracts the query token itself (substring after last `@`).
|
|
10
|
+
* - Parent calls `onPick(path)` to splice the chosen path back into
|
|
11
|
+
* the input buffer, replacing the `@query` segment.
|
|
12
|
+
* - Parent calls `onCancel()` on Esc.
|
|
13
|
+
*
|
|
14
|
+
* Matching: a simple subsequence filter — every character of the
|
|
15
|
+
* query must appear in the candidate in order, case-insensitive.
|
|
16
|
+
* Score = negative distance between matched positions, so tight
|
|
17
|
+
* matches float to the top.
|
|
18
|
+
*/
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
21
|
+
import { join, relative } from 'node:path';
|
|
22
|
+
import { Box, Text, useInput, useStdout } from 'ink';
|
|
23
|
+
const IGNORED_DIRS = new Set([
|
|
24
|
+
'node_modules',
|
|
25
|
+
'.git',
|
|
26
|
+
'.next',
|
|
27
|
+
'.turbo',
|
|
28
|
+
'.cache',
|
|
29
|
+
'dist',
|
|
30
|
+
'dist_v2',
|
|
31
|
+
'build',
|
|
32
|
+
'coverage',
|
|
33
|
+
'.pnpm-store',
|
|
34
|
+
'.venv',
|
|
35
|
+
'.mypy_cache',
|
|
36
|
+
'.ruff_cache',
|
|
37
|
+
'.pytest_cache',
|
|
38
|
+
'__pycache__',
|
|
39
|
+
]);
|
|
40
|
+
const MAX_MATCHES = 8;
|
|
41
|
+
const MAX_WALK_ENTRIES = 5000;
|
|
42
|
+
function fuzzyMatch(path, query) {
|
|
43
|
+
if (query === '')
|
|
44
|
+
return { ok: true, score: 0 };
|
|
45
|
+
const p = path.toLowerCase();
|
|
46
|
+
const q = query.toLowerCase();
|
|
47
|
+
let pi = 0;
|
|
48
|
+
let lastHit = -1;
|
|
49
|
+
let firstHit = -1;
|
|
50
|
+
let score = 0;
|
|
51
|
+
for (let qi = 0; qi < q.length; qi += 1) {
|
|
52
|
+
const target = q[qi];
|
|
53
|
+
while (pi < p.length && p[pi] !== target)
|
|
54
|
+
pi += 1;
|
|
55
|
+
if (pi >= p.length)
|
|
56
|
+
return { ok: false, score: 0 };
|
|
57
|
+
if (firstHit === -1)
|
|
58
|
+
firstHit = pi;
|
|
59
|
+
if (lastHit !== -1)
|
|
60
|
+
score -= pi - lastHit - 1;
|
|
61
|
+
lastHit = pi;
|
|
62
|
+
pi += 1;
|
|
63
|
+
}
|
|
64
|
+
// Bonus for matching near the start.
|
|
65
|
+
score -= firstHit;
|
|
66
|
+
return { ok: true, score };
|
|
67
|
+
}
|
|
68
|
+
async function walk(root, budget = MAX_WALK_ENTRIES) {
|
|
69
|
+
const out = [];
|
|
70
|
+
const queue = [root];
|
|
71
|
+
while (queue.length > 0 && out.length < budget) {
|
|
72
|
+
const dir = queue.shift();
|
|
73
|
+
if (dir === undefined)
|
|
74
|
+
break;
|
|
75
|
+
const names = await readdir(dir).catch(() => []);
|
|
76
|
+
for (const name of names) {
|
|
77
|
+
if (name.startsWith('.') && name !== '.env')
|
|
78
|
+
continue;
|
|
79
|
+
if (IGNORED_DIRS.has(name))
|
|
80
|
+
continue;
|
|
81
|
+
const full = join(dir, name);
|
|
82
|
+
const info = await stat(full).catch(() => undefined);
|
|
83
|
+
if (!info)
|
|
84
|
+
continue;
|
|
85
|
+
if (info.isDirectory()) {
|
|
86
|
+
queue.push(full);
|
|
87
|
+
}
|
|
88
|
+
else if (info.isFile()) {
|
|
89
|
+
out.push(relative(root, full));
|
|
90
|
+
if (out.length >= budget)
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
export function AtFileComplete(props) {
|
|
98
|
+
const { stdout } = useStdout();
|
|
99
|
+
const cols = stdout?.columns ?? 80;
|
|
100
|
+
const width = Math.min(cols - 2, 70);
|
|
101
|
+
const [index, setIndex] = React.useState(null);
|
|
102
|
+
const [cursor, setCursor] = React.useState(0);
|
|
103
|
+
const [error, setError] = React.useState(null);
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
let cancelled = false;
|
|
106
|
+
walk(props.cwd)
|
|
107
|
+
.then(paths => { if (!cancelled)
|
|
108
|
+
setIndex(paths); })
|
|
109
|
+
.catch(err => { if (!cancelled)
|
|
110
|
+
setError(err instanceof Error ? err.message : String(err)); });
|
|
111
|
+
return () => { cancelled = true; };
|
|
112
|
+
}, [props.cwd]);
|
|
113
|
+
const matches = React.useMemo(() => {
|
|
114
|
+
if (index === null)
|
|
115
|
+
return [];
|
|
116
|
+
const scored = [];
|
|
117
|
+
for (const p of index) {
|
|
118
|
+
const m = fuzzyMatch(p, props.query);
|
|
119
|
+
if (m.ok)
|
|
120
|
+
scored.push({ path: p, score: m.score });
|
|
121
|
+
}
|
|
122
|
+
scored.sort((a, b) => b.score - a.score);
|
|
123
|
+
return scored.slice(0, MAX_MATCHES);
|
|
124
|
+
}, [index, props.query]);
|
|
125
|
+
React.useEffect(() => {
|
|
126
|
+
setCursor(c => Math.max(0, Math.min(c, matches.length - 1)));
|
|
127
|
+
}, [matches.length]);
|
|
128
|
+
useInput((_ch, key) => {
|
|
129
|
+
if (key.escape) {
|
|
130
|
+
props.onCancel();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (key.upArrow) {
|
|
134
|
+
setCursor(c => Math.max(0, c - 1));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (key.downArrow) {
|
|
138
|
+
setCursor(c => Math.min(matches.length - 1, c + 1));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (key.tab || key.return) {
|
|
142
|
+
const pick = matches[cursor];
|
|
143
|
+
if (pick)
|
|
144
|
+
props.onPick(pick.path);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (error !== null) {
|
|
148
|
+
return (_jsx(Box, { borderStyle: "single", borderColor: "red", paddingX: 1, width: width, children: _jsxs(Text, { color: "red", children: ["walk failed: ", error] }) }));
|
|
149
|
+
}
|
|
150
|
+
if (index === null) {
|
|
151
|
+
return (_jsx(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, width: width, children: _jsx(Text, { color: "gray", dimColor: true, children: "indexing files\u2026" }) }));
|
|
152
|
+
}
|
|
153
|
+
if (matches.length === 0) {
|
|
154
|
+
return (_jsx(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, width: width, children: _jsxs(Text, { color: "gray", dimColor: true, children: ["no matches for @", props.query] }) }));
|
|
155
|
+
}
|
|
156
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "magenta", paddingX: 1, width: width, children: [_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Text, { color: "magenta", bold: true, children: ["@", props.query] }), _jsx(Text, { color: "gray", dimColor: true, children: "\u2191\u2193 \u00B7 tab/enter \u00B7 esc" })] }), matches.map((m, i) => (_jsxs(Box, { gap: 1, paddingLeft: 1, children: [_jsx(Text, { color: i === cursor ? 'magentaBright' : 'gray', children: i === cursor ? '>' : ' ' }), _jsx(Text, { color: i === cursor ? 'white' : 'gray', bold: i === cursor, children: m.path })] }, m.path)))] }));
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=AtFileComplete.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full-width modal overlay showing every available slash command plus
|
|
3
|
+
* the TUI keyboard shortcuts.
|
|
4
|
+
*
|
|
5
|
+
* The command list is supplied as props so the caller decides whether
|
|
6
|
+
* to feed it the built-in catalogue, the live `SlashRegistry.names()`
|
|
7
|
+
* output, or a test-only stub. Shortcuts live here (they're TUI state,
|
|
8
|
+
* not slash state).
|
|
9
|
+
*
|
|
10
|
+
* Navigation: type-to-filter, arrow keys or j/k to scroll, Esc / q to
|
|
11
|
+
* close. Pure presentational; the parent owns visibility.
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
export interface HelpSlashCommand {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
aliases?: string[];
|
|
18
|
+
group?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HelpOverlayProps {
|
|
21
|
+
slashCommands: HelpSlashCommand[];
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function HelpOverlay(props: HelpOverlayProps): React.JSX.Element;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Full-width modal overlay showing every available slash command plus
|
|
4
|
+
* the TUI keyboard shortcuts.
|
|
5
|
+
*
|
|
6
|
+
* The command list is supplied as props so the caller decides whether
|
|
7
|
+
* to feed it the built-in catalogue, the live `SlashRegistry.names()`
|
|
8
|
+
* output, or a test-only stub. Shortcuts live here (they're TUI state,
|
|
9
|
+
* not slash state).
|
|
10
|
+
*
|
|
11
|
+
* Navigation: type-to-filter, arrow keys or j/k to scroll, Esc / q to
|
|
12
|
+
* close. Pure presentational; the parent owns visibility.
|
|
13
|
+
*/
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { Box, Text, useInput, useStdout } from 'ink';
|
|
16
|
+
const KEYBOARD_SHORTCUTS = [
|
|
17
|
+
{ key: 'Ctrl+C ×2', desc: 'exit' },
|
|
18
|
+
{ key: 'Ctrl+M', desc: 'model picker' },
|
|
19
|
+
{ key: 'Ctrl+H', desc: 'this help' },
|
|
20
|
+
{ key: '?', desc: 'help (when input empty)' },
|
|
21
|
+
{ key: 'Tab', desc: 'autocomplete @file' },
|
|
22
|
+
{ key: 'Ctrl+E', desc: 'expand / collapse pasted block' },
|
|
23
|
+
{ key: 'Esc', desc: 'close overlay · vim NORMAL mode' },
|
|
24
|
+
{ key: 'i', desc: 'vim INSERT mode' },
|
|
25
|
+
];
|
|
26
|
+
function inferGroup(name) {
|
|
27
|
+
if (['help', 'exit', 'quit', 'clear', 'upgrade'].includes(name))
|
|
28
|
+
return 'navigation';
|
|
29
|
+
if (['login', 'logout', 'keys', 'account', 'setup'].includes(name))
|
|
30
|
+
return 'auth';
|
|
31
|
+
if (['session', 'resume', 'history', 'compact', 'memory'].includes(name))
|
|
32
|
+
return 'session';
|
|
33
|
+
if (['fleet', 'mode'].includes(name))
|
|
34
|
+
return 'fleet';
|
|
35
|
+
if (['model', 'models', 'theme', 'config', 'status', 'init'].includes(name))
|
|
36
|
+
return 'config';
|
|
37
|
+
if (['skills', 'cost'].includes(name))
|
|
38
|
+
return 'tools';
|
|
39
|
+
return 'other';
|
|
40
|
+
}
|
|
41
|
+
const GROUP_ORDER = [
|
|
42
|
+
'navigation',
|
|
43
|
+
'auth',
|
|
44
|
+
'session',
|
|
45
|
+
'config',
|
|
46
|
+
'fleet',
|
|
47
|
+
'tools',
|
|
48
|
+
'other',
|
|
49
|
+
];
|
|
50
|
+
const GROUP_TITLES = {
|
|
51
|
+
navigation: 'Navigation',
|
|
52
|
+
auth: 'Auth & Keys',
|
|
53
|
+
session: 'Session & Memory',
|
|
54
|
+
config: 'Model & Config',
|
|
55
|
+
fleet: 'Fleet & Modes',
|
|
56
|
+
tools: 'Tools & Skills',
|
|
57
|
+
other: 'Other',
|
|
58
|
+
};
|
|
59
|
+
export function HelpOverlay(props) {
|
|
60
|
+
const { stdout } = useStdout();
|
|
61
|
+
const cols = stdout?.columns ?? 80;
|
|
62
|
+
const rows = stdout?.rows ?? 24;
|
|
63
|
+
const width = Math.min(cols - 2, 100);
|
|
64
|
+
const [filter, setFilter] = React.useState('');
|
|
65
|
+
const [scroll, setScroll] = React.useState(0);
|
|
66
|
+
useInput((input, key) => {
|
|
67
|
+
if (key.escape || input === 'q') {
|
|
68
|
+
props.onClose();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (key.backspace || key.delete) {
|
|
72
|
+
setFilter(f => f.slice(0, -1));
|
|
73
|
+
setScroll(0);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (key.downArrow || input === 'j') {
|
|
77
|
+
setScroll(s => s + 1);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (key.upArrow || input === 'k') {
|
|
81
|
+
setScroll(s => Math.max(0, s - 1));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (key.pageDown) {
|
|
85
|
+
setScroll(s => s + 10);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (key.pageUp) {
|
|
89
|
+
setScroll(s => Math.max(0, s - 10));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!key.ctrl && !key.meta && input && input.length === 1 && input >= ' ') {
|
|
93
|
+
setFilter(f => f + input);
|
|
94
|
+
setScroll(0);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const q = filter.trim().toLowerCase();
|
|
98
|
+
const filtered = props.slashCommands.filter(c => q === '' || c.name.toLowerCase().includes(q) || c.description.toLowerCase().includes(q));
|
|
99
|
+
const byGroup = new Map();
|
|
100
|
+
for (const c of filtered) {
|
|
101
|
+
const g = c.group ?? inferGroup(c.name);
|
|
102
|
+
const list = byGroup.get(g) ?? [];
|
|
103
|
+
list.push(c);
|
|
104
|
+
byGroup.set(g, list);
|
|
105
|
+
}
|
|
106
|
+
const lines = [];
|
|
107
|
+
for (const group of GROUP_ORDER) {
|
|
108
|
+
const cmds = byGroup.get(group);
|
|
109
|
+
if (!cmds || cmds.length === 0)
|
|
110
|
+
continue;
|
|
111
|
+
cmds.sort((a, b) => a.name.localeCompare(b.name));
|
|
112
|
+
lines.push(_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "magenta", bold: true, children: GROUP_TITLES[group] ?? group }) }, `h-${group}`));
|
|
113
|
+
for (const c of cmds) {
|
|
114
|
+
lines.push(_jsxs(Box, { gap: 2, children: [_jsxs(Text, { color: "cyan", children: ["/", c.name.padEnd(14)] }), _jsx(Text, { color: "gray", children: c.description })] }, `c-${c.name}`));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Shortcut block always visible — append after command lines.
|
|
118
|
+
lines.push(_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "magenta", bold: true, children: "Keyboard" }) }, "kb-h"));
|
|
119
|
+
for (const kb of KEYBOARD_SHORTCUTS) {
|
|
120
|
+
lines.push(_jsxs(Box, { gap: 2, children: [_jsx(Text, { color: "yellow", children: kb.key.padEnd(14) }), _jsx(Text, { color: "gray", children: kb.desc })] }, `kb-${kb.key}`));
|
|
121
|
+
}
|
|
122
|
+
const maxVisible = Math.max(5, rows - 10);
|
|
123
|
+
const visible = lines.slice(scroll, scroll + maxVisible);
|
|
124
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 1, width: width, children: [_jsxs(Box, { gap: 1, justifyContent: "space-between", children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "magenta", bold: true, children: "help" }), _jsxs(Text, { color: "gray", dimColor: true, children: [filtered.length, " command", filtered.length === 1 ? '' : 's', filter !== '' ? ` · filter: "${filter}"` : ''] })] }), _jsx(Text, { color: "gray", dimColor: true, children: "type to filter \u00B7 \u2191\u2193 \u00B7 esc" })] }), visible.length === 0
|
|
125
|
+
? _jsxs(Text, { color: "gray", dimColor: true, children: ["No commands match \"", filter, "\""] })
|
|
126
|
+
: _jsx(_Fragment, { children: visible }), lines.length > maxVisible && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", dimColor: true, children: scroll + maxVisible < lines.length
|
|
127
|
+
? `↓ ${lines.length - scroll - maxVisible} more below`
|
|
128
|
+
: '· end ·' }) }))] }));
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=HelpOverlay.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bottom-anchored prompt input.
|
|
3
|
+
*
|
|
4
|
+
* Uses `ink-text-input` for the editable field. Ctrl+C is handled here
|
|
5
|
+
* (two presses within 1.5s exits) rather than relying on Ink's default
|
|
6
|
+
* SIGINT so App can own the exit policy. Enter triggers onSubmit with
|
|
7
|
+
* the trimmed value and clears the buffer.
|
|
8
|
+
*
|
|
9
|
+
* Extensions layered on top of the plain field (all feature-flagged and
|
|
10
|
+
* callback-driven so App stays in charge):
|
|
11
|
+
* - Vim mode (Esc → NORMAL, `i` → INSERT) when `vimMode` is true.
|
|
12
|
+
* - Paste-collapse: large single-tick buffer jumps are hidden behind
|
|
13
|
+
* a placeholder until Ctrl+E expands them.
|
|
14
|
+
* - @-mention hook: emits `onAtQueryChange` whenever the token after
|
|
15
|
+
* the last `@` changes, so the parent can show AtFileComplete.
|
|
16
|
+
* - Ctrl+M and Ctrl+H bubble up via `onRequestOverlay` so App can
|
|
17
|
+
* mount the appropriate modal without InputBox knowing about them.
|
|
18
|
+
* - `?` on an empty buffer also bubbles up, mirroring the README.
|
|
19
|
+
*/
|
|
20
|
+
import * as React from 'react';
|
|
21
|
+
export interface InputBoxProps {
|
|
22
|
+
value: string;
|
|
23
|
+
onChange: (value: string) => void;
|
|
24
|
+
onSubmit: (value: string) => void;
|
|
25
|
+
busy: boolean;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
vimMode?: boolean;
|
|
28
|
+
/** Parent wants to know when the @-token changes (null = none active). */
|
|
29
|
+
onAtQueryChange?: (query: string | null) => void;
|
|
30
|
+
/** Parent wants to know when to surface a modal overlay. */
|
|
31
|
+
onRequestOverlay?: (kind: 'models' | 'help') => void;
|
|
32
|
+
/** Parent owns the focus so it can be stolen when an overlay is up. */
|
|
33
|
+
inputFocus?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function InputBox(props: InputBoxProps): React.JSX.Element;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Bottom-anchored prompt input.
|
|
4
|
+
*
|
|
5
|
+
* Uses `ink-text-input` for the editable field. Ctrl+C is handled here
|
|
6
|
+
* (two presses within 1.5s exits) rather than relying on Ink's default
|
|
7
|
+
* SIGINT so App can own the exit policy. Enter triggers onSubmit with
|
|
8
|
+
* the trimmed value and clears the buffer.
|
|
9
|
+
*
|
|
10
|
+
* Extensions layered on top of the plain field (all feature-flagged and
|
|
11
|
+
* callback-driven so App stays in charge):
|
|
12
|
+
* - Vim mode (Esc → NORMAL, `i` → INSERT) when `vimMode` is true.
|
|
13
|
+
* - Paste-collapse: large single-tick buffer jumps are hidden behind
|
|
14
|
+
* a placeholder until Ctrl+E expands them.
|
|
15
|
+
* - @-mention hook: emits `onAtQueryChange` whenever the token after
|
|
16
|
+
* the last `@` changes, so the parent can show AtFileComplete.
|
|
17
|
+
* - Ctrl+M and Ctrl+H bubble up via `onRequestOverlay` so App can
|
|
18
|
+
* mount the appropriate modal without InputBox knowing about them.
|
|
19
|
+
* - `?` on an empty buffer also bubbles up, mirroring the README.
|
|
20
|
+
*/
|
|
21
|
+
import * as React from 'react';
|
|
22
|
+
import { Box, Text, useApp, useInput, useStdout } from 'ink';
|
|
23
|
+
import TextInput from 'ink-text-input';
|
|
24
|
+
import { applyVimKey, createVimState } from './vim-bindings.js';
|
|
25
|
+
import { detectPaste, PasteCollapseView } from './PasteCollapse.js';
|
|
26
|
+
const CTRL_C_TIMEOUT_MS = 1500;
|
|
27
|
+
function lastAtToken(value) {
|
|
28
|
+
// The last `@` must be at column 0 or preceded by whitespace to count.
|
|
29
|
+
const idx = value.lastIndexOf('@');
|
|
30
|
+
if (idx === -1)
|
|
31
|
+
return null;
|
|
32
|
+
if (idx > 0) {
|
|
33
|
+
const prev = value[idx - 1];
|
|
34
|
+
if (prev !== ' ' && prev !== '\t' && prev !== '\n')
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const tail = value.slice(idx + 1);
|
|
38
|
+
if (/\s/.test(tail))
|
|
39
|
+
return null;
|
|
40
|
+
return tail;
|
|
41
|
+
}
|
|
42
|
+
export function InputBox(props) {
|
|
43
|
+
const { stdout } = useStdout();
|
|
44
|
+
const { exit } = useApp();
|
|
45
|
+
const cols = stdout?.columns ?? 80;
|
|
46
|
+
const [ctrlCArmed, setCtrlCArmed] = React.useState(false);
|
|
47
|
+
const armTimerRef = React.useRef(null);
|
|
48
|
+
const [vimState, setVimState] = React.useState(() => createVimState());
|
|
49
|
+
const [pasteSegment, setPasteSegment] = React.useState(null);
|
|
50
|
+
const [pasteExpanded, setPasteExpanded] = React.useState(false);
|
|
51
|
+
const prevValueRef = React.useRef(props.value);
|
|
52
|
+
const focus = props.inputFocus ?? !props.busy;
|
|
53
|
+
const vimActive = props.vimMode === true && vimState.mode === 'NORMAL';
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
return () => {
|
|
56
|
+
if (armTimerRef.current)
|
|
57
|
+
clearTimeout(armTimerRef.current);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
// Notify parent whenever the active @-token shifts.
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (props.onAtQueryChange) {
|
|
63
|
+
props.onAtQueryChange(lastAtToken(props.value));
|
|
64
|
+
}
|
|
65
|
+
}, [props.value, props.onAtQueryChange]);
|
|
66
|
+
// Invalidate paste-collapse if the buffer shrinks past the pasted region.
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (pasteSegment === null)
|
|
69
|
+
return;
|
|
70
|
+
if (props.value.length < pasteSegment.end) {
|
|
71
|
+
setPasteSegment(null);
|
|
72
|
+
setPasteExpanded(false);
|
|
73
|
+
}
|
|
74
|
+
}, [props.value, pasteSegment]);
|
|
75
|
+
// Wrap onChange so we can detect paste bursts and strip pending `@` updates.
|
|
76
|
+
const handleChange = React.useCallback((next) => {
|
|
77
|
+
const prev = prevValueRef.current;
|
|
78
|
+
prevValueRef.current = next;
|
|
79
|
+
const seg = detectPaste(prev, next);
|
|
80
|
+
if (seg !== null) {
|
|
81
|
+
setPasteSegment(seg);
|
|
82
|
+
setPasteExpanded(false);
|
|
83
|
+
}
|
|
84
|
+
props.onChange(next);
|
|
85
|
+
}, [props]);
|
|
86
|
+
useInput((inputCh, key) => {
|
|
87
|
+
// Ctrl+C handling (two-press exit) — highest priority.
|
|
88
|
+
if (key.ctrl && inputCh === 'c') {
|
|
89
|
+
if (ctrlCArmed) {
|
|
90
|
+
exit();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setCtrlCArmed(true);
|
|
94
|
+
if (armTimerRef.current)
|
|
95
|
+
clearTimeout(armTimerRef.current);
|
|
96
|
+
armTimerRef.current = setTimeout(() => setCtrlCArmed(false), CTRL_C_TIMEOUT_MS);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Overlay hotkeys bubble up to App.
|
|
100
|
+
if (props.onRequestOverlay) {
|
|
101
|
+
if (key.ctrl && inputCh === 'm') {
|
|
102
|
+
props.onRequestOverlay('models');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (key.ctrl && inputCh === 'h') {
|
|
106
|
+
props.onRequestOverlay('help');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (inputCh === '?' && props.value === '' && !key.ctrl && !key.meta) {
|
|
110
|
+
props.onRequestOverlay('help');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Paste-collapse toggle.
|
|
115
|
+
if (key.ctrl && inputCh === 'e' && pasteSegment !== null) {
|
|
116
|
+
setPasteExpanded(v => !v);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Vim mode transitions + NORMAL key handling.
|
|
120
|
+
if (props.vimMode === true) {
|
|
121
|
+
if (key.escape) {
|
|
122
|
+
setVimState(s => ({ ...s, mode: 'NORMAL', pending: '' }));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (vimState.mode === 'NORMAL' && !key.ctrl && !key.meta) {
|
|
126
|
+
if (key.return) {
|
|
127
|
+
// In NORMAL mode, Enter still submits.
|
|
128
|
+
props.onSubmit(props.value);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const r = applyVimKey(props.value, vimState, inputCh);
|
|
132
|
+
if (r.exitRequested === true) {
|
|
133
|
+
exit();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (r.handled) {
|
|
137
|
+
if (r.value !== props.value)
|
|
138
|
+
props.onChange(r.value);
|
|
139
|
+
setVimState(r.state);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, { isActive: focus });
|
|
145
|
+
const borderColour = props.busy ? 'cyan' : 'magenta';
|
|
146
|
+
const promptColour = props.busy ? 'cyan' : 'magenta';
|
|
147
|
+
const collapsed = pasteSegment !== null && !pasteExpanded;
|
|
148
|
+
return (_jsxs(Box, { flexDirection: "column", width: cols, children: [_jsx(Box, { borderStyle: "single", borderColor: borderColour, paddingX: 1, children: _jsxs(Box, { gap: 1, flexGrow: 1, children: [_jsx(Text, { color: promptColour, children: "\u276F" }), collapsed && pasteSegment !== null ? (_jsx(PasteCollapseView, { value: props.value, segment: pasteSegment, expanded: false })) : (_jsx(TextInput, { value: props.value, onChange: handleChange, onSubmit: props.onSubmit, placeholder: props.placeholder ?? 'Ask dirgha anything…', showCursor: !props.busy && !vimActive, focus: focus && !vimActive }))] }) }), _jsxs(Box, { paddingX: 1, justifyContent: "space-between", children: [_jsxs(Box, { gap: 1, children: [props.vimMode === true && (_jsxs(Text, { color: vimActive ? 'yellow' : 'green', bold: true, children: ["[", vimModeLabel(vimState.mode), "]"] })), pasteSegment !== null && pasteExpanded && (_jsx(Text, { color: "gray", dimColor: true, children: "pasted block expanded (Ctrl+E collapse)" }))] }), ctrlCArmed && _jsx(Text, { color: "yellow", children: "Press Ctrl+C again to exit." })] })] }));
|
|
149
|
+
}
|
|
150
|
+
function vimModeLabel(m) {
|
|
151
|
+
return m === 'NORMAL' ? 'NORMAL' : 'INSERT';
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=InputBox.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logo: single-item banner shown once at startup.
|
|
3
|
+
*
|
|
4
|
+
* Rendered inside <Static> by App so it never re-renders and never
|
|
5
|
+
* participates in scroll-jitter. Width-adaptive: wide ASCII block on
|
|
6
|
+
* terminals >= 60 cols, compact one-liner otherwise.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
export interface LogoProps {
|
|
10
|
+
version: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Logo({ version }: LogoProps): React.JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useStdout } from 'ink';
|
|
3
|
+
const WIDE_ROWS = [
|
|
4
|
+
' ██████╗ ██╗██████╗ ██████╗ ██╗ ██╗ █████╗ ',
|
|
5
|
+
' ██╔══██╗██║██╔══██╗██╔════╝ ██║ ██║██╔══██╗',
|
|
6
|
+
' ██║ ██║██║██████╔╝██║ ███╗███████║███████║',
|
|
7
|
+
' ██║ ██║██║██╔══██╗██║ ██║██╔══██║██╔══██║',
|
|
8
|
+
' ██████╔╝██║██║ ██║╚██████╔╝██║ ██║██║ ██║',
|
|
9
|
+
' ╚═════╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝',
|
|
10
|
+
];
|
|
11
|
+
const ROW_COLOURS = [
|
|
12
|
+
'#C4B5FD', '#A78BFA', '#8B5CF6', '#7C3AED', '#6D28D9', '#5B21B6',
|
|
13
|
+
];
|
|
14
|
+
const BORDER = '#5B21B6';
|
|
15
|
+
const TAG = '#A78BFA';
|
|
16
|
+
export function Logo({ version }) {
|
|
17
|
+
const { stdout } = useStdout();
|
|
18
|
+
const cols = stdout?.columns ?? 80;
|
|
19
|
+
if (cols < 60) {
|
|
20
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, marginBottom: 1, children: [_jsxs(Text, { color: BORDER, children: [_jsx(Text, { color: ROW_COLOURS[0], children: "\u25C6 " }), _jsx(Text, { color: ROW_COLOURS[1], children: "DIRGHA" }), _jsx(Text, { color: BORDER, children: " \u25C6" })] }), _jsxs(Text, { color: TAG, children: ["\u2726 Dirgha Code", ' ', _jsxs(Text, { color: ROW_COLOURS[2], children: ["v", version] }), ' ', "\u2726"] }), _jsx(Text, { color: ROW_COLOURS[3], children: "dirgha.ai \u00B7 /help" })] }));
|
|
21
|
+
}
|
|
22
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, marginBottom: 1, children: [_jsx(Text, { color: BORDER, children: ' ╭──────────────────────────────────────────────────────────╮' }), WIDE_ROWS.map((row, i) => {
|
|
23
|
+
const colour = ROW_COLOURS[i] ?? ROW_COLOURS[0];
|
|
24
|
+
return (_jsxs(Text, { color: BORDER, children: [' │', _jsx(Text, { color: colour, children: row }), '│'] }, i));
|
|
25
|
+
}), _jsx(Text, { color: BORDER, children: ' ╰──────────────────────────────────────────────────────────╯' }), _jsxs(Text, { color: TAG, children: [' ✦ ', _jsx(Text, { color: ROW_COLOURS[1], children: "Dirgha Code" }), _jsx(Text, { color: ROW_COLOURS[2], children: " \u00B7 " }), _jsx(Text, { color: ROW_COLOURS[3], children: "dirgha.ai" }), ' ✦', _jsx(Text, { color: ROW_COLOURS[5], children: ` v${version} /help` })] })] }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Logo.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal overlay for picking a model.
|
|
3
|
+
*
|
|
4
|
+
* Presentation: a bordered, centred box with the model catalogue
|
|
5
|
+
* grouped by provider. Arrow keys move the cursor, Enter selects,
|
|
6
|
+
* Esc / `q` cancels. Digit keys 1-9 pick by position within the
|
|
7
|
+
* visible list for muscle-memory speed.
|
|
8
|
+
*
|
|
9
|
+
* Shape of the overlay is deliberately small (≤200 LOC); the
|
|
10
|
+
* catalogue itself is owned upstream so this file stays purely
|
|
11
|
+
* presentational.
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
export interface ModelEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
provider: string;
|
|
17
|
+
tier?: 'free' | 'basic' | 'pro' | 'premium';
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ModelPickerProps {
|
|
21
|
+
models: ModelEntry[];
|
|
22
|
+
current: string;
|
|
23
|
+
onPick: (id: string) => void;
|
|
24
|
+
onCancel: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function ModelPicker(props: ModelPickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Modal overlay for picking a model.
|
|
4
|
+
*
|
|
5
|
+
* Presentation: a bordered, centred box with the model catalogue
|
|
6
|
+
* grouped by provider. Arrow keys move the cursor, Enter selects,
|
|
7
|
+
* Esc / `q` cancels. Digit keys 1-9 pick by position within the
|
|
8
|
+
* visible list for muscle-memory speed.
|
|
9
|
+
*
|
|
10
|
+
* Shape of the overlay is deliberately small (≤200 LOC); the
|
|
11
|
+
* catalogue itself is owned upstream so this file stays purely
|
|
12
|
+
* presentational.
|
|
13
|
+
*/
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { Box, Text, useInput, useStdout } from 'ink';
|
|
16
|
+
const TIER_COLOR = {
|
|
17
|
+
free: 'greenBright',
|
|
18
|
+
basic: 'cyan',
|
|
19
|
+
pro: 'magenta',
|
|
20
|
+
premium: 'yellow',
|
|
21
|
+
};
|
|
22
|
+
function groupByProvider(models) {
|
|
23
|
+
const map = new Map();
|
|
24
|
+
for (const m of models) {
|
|
25
|
+
const list = map.get(m.provider) ?? [];
|
|
26
|
+
list.push(m);
|
|
27
|
+
map.set(m.provider, list);
|
|
28
|
+
}
|
|
29
|
+
return [...map.entries()].map(([provider, items]) => ({ provider, items }));
|
|
30
|
+
}
|
|
31
|
+
export function ModelPicker(props) {
|
|
32
|
+
const { stdout } = useStdout();
|
|
33
|
+
const cols = stdout?.columns ?? 80;
|
|
34
|
+
const width = Math.min(cols - 4, 72);
|
|
35
|
+
const initial = Math.max(0, props.models.findIndex(m => m.id === props.current));
|
|
36
|
+
const [cursor, setCursor] = React.useState(initial);
|
|
37
|
+
useInput((ch, key) => {
|
|
38
|
+
if (key.escape || ch === 'q') {
|
|
39
|
+
props.onCancel();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (key.upArrow || ch === 'k') {
|
|
43
|
+
setCursor(c => Math.max(0, c - 1));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (key.downArrow || ch === 'j') {
|
|
47
|
+
setCursor(c => Math.min(props.models.length - 1, c + 1));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (key.return) {
|
|
51
|
+
const picked = props.models[cursor];
|
|
52
|
+
if (picked)
|
|
53
|
+
props.onPick(picked.id);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (ch && /^[1-9]$/.test(ch)) {
|
|
57
|
+
const n = Number(ch) - 1;
|
|
58
|
+
if (n < props.models.length) {
|
|
59
|
+
const picked = props.models[n];
|
|
60
|
+
if (picked)
|
|
61
|
+
props.onPick(picked.id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const groups = groupByProvider(props.models);
|
|
66
|
+
const selected = props.models[cursor];
|
|
67
|
+
// Build a flat row index so digit shortcuts map to the visible ordering.
|
|
68
|
+
let idx = 0;
|
|
69
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 1, width: width, children: [_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { color: "magenta", bold: true, children: "model picker" }), _jsx(Text, { color: "gray", dimColor: true, children: "\u2191\u2193 enter \u00B7 1-9 \u00B7 esc" })] }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: groups.map(group => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: "cyan", dimColor: true, children: group.provider }), group.items.map(m => {
|
|
70
|
+
const myIdx = idx;
|
|
71
|
+
idx += 1;
|
|
72
|
+
const isCursor = myIdx === cursor;
|
|
73
|
+
const isCurrent = m.id === props.current;
|
|
74
|
+
const prefix = isCursor ? '>' : isCurrent ? '•' : ' ';
|
|
75
|
+
const num = myIdx < 9 ? String(myIdx + 1) : ' ';
|
|
76
|
+
const tierColor = m.tier ? TIER_COLOR[m.tier] : 'gray';
|
|
77
|
+
return (_jsxs(Box, { gap: 1, paddingLeft: 1, children: [_jsx(Text, { color: isCursor ? 'magentaBright' : 'gray', children: prefix }), _jsx(Text, { color: "gray", dimColor: true, children: num }), _jsx(Text, { color: isCursor ? 'white' : isCurrent ? 'magenta' : 'gray', bold: isCursor, children: m.label ?? m.id }), m.tier !== undefined && (_jsx(Text, { color: tierColor, dimColor: !isCursor, children: m.tier }))] }, m.id));
|
|
78
|
+
})] }, group.provider))) }), _jsx(Box, { borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray", children: _jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "gray", dimColor: true, children: "\u2192" }), _jsx(Text, { color: "magenta", children: selected?.id ?? props.current })] }) })] }));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=ModelPicker.js.map
|