@travisennis/acai 0.0.7 → 0.0.8
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/README.md +42 -25
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +115 -104
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -16
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/types.js +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +0 -2
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/{copy-command.js → copy/index.js} +4 -26
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +55 -95
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +1 -1
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +16 -100
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +16 -7
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +33 -43
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/{model-command.js → model/index.js} +15 -52
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/{paste-command.js → paste/index.js} +6 -111
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +7 -2
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -3
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +3 -3
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +25 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -20
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +60 -64
- package/dist/formatting.d.ts +27 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -75
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +95 -80
- package/dist/models/providers.d.ts +4 -4
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +7 -1
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +0 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +56 -406
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +245 -42
- package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +60 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +2 -0
- package/dist/terminal/formatting.d.ts +1 -2
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +1 -2
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +9 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +69 -123
- package/dist/tools/directory-tree.d.ts +9 -7
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +89 -70
- package/dist/tools/dynamic-tool-loader.d.ts +22 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +39 -44
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +19 -76
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +77 -119
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -108
- package/dist/tools/index.d.ts +200 -179
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -315
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +49 -82
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +37 -66
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -38
- package/dist/tools/types.d.ts +5 -25
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/box.d.ts.map +1 -1
- package/dist/tui/components/box.js +16 -10
- package/dist/tui/components/editor.d.ts +1 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +148 -107
- package/dist/tui/components/footer.d.ts +20 -7
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +89 -196
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +2 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +7 -2
- package/dist/tui/components/markdown.d.ts +5 -4
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +51 -40
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -8
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -1
- package/dist/tui/components/progress-bar.js +3 -15
- package/dist/tui/components/select-list.d.ts +0 -15
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +5 -28
- package/dist/tui/components/tool-execution.d.ts +3 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +26 -38
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +4 -2
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/tui/terminal.d.ts +2 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +23 -19
- package/dist/tui/tui.d.ts +1 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +24 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/zod.d.ts +1 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +17 -0
- package/package.json +31 -29
- package/bin/acai-wrapper.js +0 -26
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -43
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -55
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -124
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -42
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -36
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -30
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -68
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -118
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -71
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/model-command.d.ts +0 -3
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -109
- package/dist/commands/prompt-command.d.ts +0 -21
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -258
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -73
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -31
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/project-status-line.d.ts +0 -3
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -61
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -120
- package/dist/tokens/threshold.d.ts +0 -20
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -67
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -285
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -117
- package/dist/tools/batch.d.ts +0 -34
- package/dist/tools/batch.d.ts.map +0 -1
- package/dist/tools/batch.js +0 -174
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -183
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -77
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/llm-edit-fixer.d.ts +0 -24
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -136
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -65
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -196
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -148
- package/dist/tui/components/prompt-status.d.ts +0 -17
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -26
package/dist/commands/manager.js
CHANGED
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
import { addDirectoryCommand } from "./add-directory
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { resetCommand } from "./reset-command.js";
|
|
26
|
-
// import { rulesCommand } from "./rules-command.ts";
|
|
27
|
-
import { saveCommand } from "./save-command.js";
|
|
28
|
-
import { shellCommand } from "./shell-command.js";
|
|
29
|
-
import { usageCommand } from "./usage-command.js";
|
|
1
|
+
import { addDirectoryCommand } from "./add-directory/index.js";
|
|
2
|
+
import { clearCommand } from "./clear/index.js";
|
|
3
|
+
import { copyCommand } from "./copy/index.js";
|
|
4
|
+
import { exitCommand } from "./exit/index.js";
|
|
5
|
+
import { generateRulesCommand } from "./generate-rules/index.js";
|
|
6
|
+
import { handoffCommand } from "./handoff/index.js";
|
|
7
|
+
import { healthCommand } from "./health/index.js";
|
|
8
|
+
import { helpCommand } from "./help/index.js";
|
|
9
|
+
import { historyCommand } from "./history/index.js";
|
|
10
|
+
import { initCommand } from "./init/index.js";
|
|
11
|
+
import { initProjectCommand } from "./init-project/index.js";
|
|
12
|
+
import { listDirectoriesCommand } from "./list-directories/index.js";
|
|
13
|
+
import { listToolsCommand } from "./list-tools/index.js";
|
|
14
|
+
import { modelCommand } from "./model/index.js";
|
|
15
|
+
import { pasteCommand } from "./paste/index.js";
|
|
16
|
+
import { pickupCommand } from "./pickup/index.js";
|
|
17
|
+
import { loadPrompts, promptCommand } from "./prompt/index.js";
|
|
18
|
+
import { removeDirectoryCommand } from "./remove-directory/index.js";
|
|
19
|
+
import { resetCommand } from "./reset/index.js";
|
|
20
|
+
import { resourcesCommand } from "./resources/index.js";
|
|
21
|
+
import { reviewCommand } from "./review/index.js";
|
|
22
|
+
import { saveCommand } from "./save/index.js";
|
|
23
|
+
import { sessionCommand } from "./session/index.js";
|
|
24
|
+
import { shellCommand } from "./shell/index.js";
|
|
30
25
|
export class CommandManager {
|
|
31
26
|
commands;
|
|
32
27
|
promptManager;
|
|
33
28
|
modelManager;
|
|
34
|
-
|
|
29
|
+
sessionManager;
|
|
35
30
|
tokenTracker;
|
|
36
31
|
config;
|
|
37
32
|
tokenCounter;
|
|
38
33
|
promptHistory;
|
|
39
34
|
workspace;
|
|
40
35
|
initialized;
|
|
41
|
-
constructor({ promptManager, modelManager, messageHistory, tokenTracker, config, tokenCounter, promptHistory, workspace, }) {
|
|
36
|
+
constructor({ promptManager, modelManager, sessionManager: messageHistory, tokenTracker, config, tokenCounter, promptHistory, workspace, }) {
|
|
42
37
|
this.commands = new Map();
|
|
43
38
|
this.promptManager = promptManager;
|
|
44
39
|
this.modelManager = modelManager;
|
|
45
|
-
this.
|
|
40
|
+
this.sessionManager = messageHistory;
|
|
46
41
|
this.tokenTracker = tokenTracker;
|
|
47
42
|
this.config = config;
|
|
48
43
|
this.tokenCounter = tokenCounter;
|
|
@@ -58,7 +53,7 @@ export class CommandManager {
|
|
|
58
53
|
const options = {
|
|
59
54
|
promptManager: this.promptManager,
|
|
60
55
|
modelManager: this.modelManager,
|
|
61
|
-
|
|
56
|
+
sessionManager: this.sessionManager,
|
|
62
57
|
tokenTracker: this.tokenTracker,
|
|
63
58
|
config: this.config,
|
|
64
59
|
tokenCounter: this.tokenCounter,
|
|
@@ -69,31 +64,26 @@ export class CommandManager {
|
|
|
69
64
|
const cmds = [
|
|
70
65
|
addDirectoryCommand(options),
|
|
71
66
|
clearCommand(options),
|
|
72
|
-
// compactCommand(options),
|
|
73
|
-
contextCommand(options),
|
|
74
|
-
// editCommand(options),
|
|
75
|
-
// editPromptCommand(options),
|
|
76
67
|
exitCommand(options),
|
|
77
|
-
// filesCommand(options),
|
|
78
68
|
healthCommand(options),
|
|
79
69
|
historyCommand(options),
|
|
80
70
|
initCommand(options),
|
|
71
|
+
initProjectCommand(options),
|
|
81
72
|
listDirectoriesCommand(options),
|
|
82
73
|
pasteCommand(options),
|
|
83
74
|
pickupCommand(options),
|
|
84
75
|
promptCommand(options),
|
|
85
76
|
removeDirectoryCommand(options),
|
|
86
77
|
resetCommand(options),
|
|
78
|
+
reviewCommand(options),
|
|
87
79
|
saveCommand(options),
|
|
88
|
-
// rulesCommand(options),
|
|
89
80
|
modelCommand(options),
|
|
90
|
-
|
|
91
|
-
// lastLogCommand(options),
|
|
81
|
+
sessionCommand(options),
|
|
92
82
|
generateRulesCommand(options),
|
|
93
83
|
handoffCommand(options),
|
|
94
|
-
// applicationLogCommand(options),
|
|
95
84
|
copyCommand(options),
|
|
96
85
|
listToolsCommand(options),
|
|
86
|
+
resourcesCommand(options),
|
|
97
87
|
shellCommand(options),
|
|
98
88
|
];
|
|
99
89
|
// Add help command with access to all commands
|
|
@@ -161,7 +151,7 @@ export class CommandManager {
|
|
|
161
151
|
const commandArgs = userInput.split(" ");
|
|
162
152
|
const command = commandArgs.at(0);
|
|
163
153
|
const args = commandArgs.slice(1);
|
|
164
|
-
if (command) {
|
|
154
|
+
if (command !== undefined) {
|
|
165
155
|
const replCommand = this.commands.get(command);
|
|
166
156
|
if (replCommand) {
|
|
167
157
|
const result = await replCommand.handle(args, options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/model/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAqHjE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isValidModel, modelRegistry, models, } from "
|
|
2
|
-
import { getTerminalSize } from "
|
|
3
|
-
import style from "
|
|
4
|
-
import { Container, Input, Spacer, Text, } from "
|
|
1
|
+
import { isValidModel, modelRegistry, models, } from "../../models/providers.js";
|
|
2
|
+
import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, } from "../../terminal/control.js";
|
|
3
|
+
import style from "../../terminal/style.js";
|
|
4
|
+
import { Container, Input, Spacer, Text, } from "../../tui/index.js";
|
|
5
|
+
import { hideModelSelector } from "./utils.js";
|
|
5
6
|
export function modelCommand(options) {
|
|
6
7
|
const { modelManager } = options;
|
|
7
8
|
return {
|
|
@@ -11,40 +12,31 @@ export function modelCommand(options) {
|
|
|
11
12
|
async handle(args, { tui, container, inputContainer, editor, }) {
|
|
12
13
|
const arg = args.join(" ").trim();
|
|
13
14
|
const modelConfig = modelManager.getModelMetadata("repl");
|
|
14
|
-
// No args - display model selector
|
|
15
15
|
if (!arg) {
|
|
16
|
-
// Create model selector with current model
|
|
17
16
|
const modelSelector = new ModelSelectorComponent(modelConfig.id, (model) => {
|
|
18
|
-
// Apply the selected model
|
|
19
17
|
modelManager.setModel("repl", model);
|
|
20
|
-
// Hide selector and show editor again
|
|
21
18
|
hideModelSelector(inputContainer, editor, tui);
|
|
22
19
|
tui.requestRender();
|
|
23
20
|
}, () => {
|
|
24
|
-
// Just hide the selector
|
|
25
21
|
hideModelSelector(inputContainer, editor, tui);
|
|
26
22
|
tui.requestRender();
|
|
27
23
|
});
|
|
28
|
-
// Replace editor with selector
|
|
29
24
|
inputContainer.clear();
|
|
30
25
|
inputContainer.addChild(modelSelector);
|
|
31
26
|
tui.setFocus(modelSelector);
|
|
32
27
|
tui.requestRender();
|
|
33
28
|
return "continue";
|
|
34
29
|
}
|
|
35
|
-
// Switch to a specific model
|
|
36
30
|
if (isValidModel(arg)) {
|
|
37
31
|
try {
|
|
38
|
-
// Get current and new model configs
|
|
39
32
|
const currentModelConfig = modelManager.getModelMetadata("repl");
|
|
40
33
|
const newModelConfig = modelRegistry[arg];
|
|
41
|
-
if (
|
|
34
|
+
if (newModelConfig === undefined) {
|
|
42
35
|
container.addChild(new Text(style.red(`Model configuration not found for: ${arg}`), 1, 0));
|
|
43
36
|
tui.requestRender();
|
|
44
37
|
editor.setText("");
|
|
45
38
|
return "continue";
|
|
46
39
|
}
|
|
47
|
-
// Check for capability differences
|
|
48
40
|
if (currentModelConfig.supportsToolCalling &&
|
|
49
41
|
!newModelConfig.supportsToolCalling) {
|
|
50
42
|
container.addChild(new Text(style.yellow("The new model doesn't support tool calling, which may limit functionality."), 1, 0));
|
|
@@ -53,11 +45,7 @@ export function modelCommand(options) {
|
|
|
53
45
|
!newModelConfig.supportsReasoning) {
|
|
54
46
|
container.addChild(new Text(style.yellow("The new model doesn't support reasoning, which may change response quality."), 2, 0));
|
|
55
47
|
}
|
|
56
|
-
// Update model in ModelManager
|
|
57
48
|
modelManager.setModel("repl", arg);
|
|
58
|
-
// container.addChild(
|
|
59
|
-
// new Text(style.green(`Model set to ${arg}.`), 3, 0),
|
|
60
|
-
// );
|
|
61
49
|
tui.requestRender();
|
|
62
50
|
editor.setText("");
|
|
63
51
|
return "continue";
|
|
@@ -75,15 +63,6 @@ export function modelCommand(options) {
|
|
|
75
63
|
},
|
|
76
64
|
};
|
|
77
65
|
}
|
|
78
|
-
function hideModelSelector(editorContainer, editor, tui) {
|
|
79
|
-
// Replace selector with editor in the container
|
|
80
|
-
editorContainer.clear();
|
|
81
|
-
editorContainer.addChild(editor);
|
|
82
|
-
tui.setFocus(editor);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Component that renders a model selector with search
|
|
86
|
-
*/
|
|
87
66
|
class ModelSelectorComponent extends Container {
|
|
88
67
|
searchInput;
|
|
89
68
|
listContainer;
|
|
@@ -98,29 +77,23 @@ class ModelSelectorComponent extends Container {
|
|
|
98
77
|
this.currentModel = currentModel;
|
|
99
78
|
this.onSelectCallback = onSelect;
|
|
100
79
|
this.onCancelCallback = onCancel;
|
|
101
|
-
// Load all models
|
|
102
80
|
this.loadModels();
|
|
103
81
|
const { columns } = getTerminalSize();
|
|
104
|
-
// Add top border
|
|
105
82
|
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
106
83
|
this.addChild(new Spacer(1));
|
|
107
|
-
// Create search input
|
|
108
84
|
this.searchInput = new Input();
|
|
109
85
|
this.searchInput.onSubmit = () => {
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
this.handleSelect(
|
|
86
|
+
const model = this.filteredModels[this.selectedIndex];
|
|
87
|
+
if (model !== undefined) {
|
|
88
|
+
this.handleSelect(model);
|
|
113
89
|
}
|
|
114
90
|
};
|
|
115
91
|
this.addChild(this.searchInput);
|
|
116
92
|
this.addChild(new Spacer(1));
|
|
117
|
-
// Create list container
|
|
118
93
|
this.listContainer = new Container();
|
|
119
94
|
this.addChild(this.listContainer);
|
|
120
95
|
this.addChild(new Spacer(1));
|
|
121
|
-
// Add bottom border
|
|
122
96
|
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
123
|
-
// Initial render
|
|
124
97
|
this.updateList();
|
|
125
98
|
}
|
|
126
99
|
loadModels() {
|
|
@@ -149,10 +122,9 @@ class ModelSelectorComponent extends Container {
|
|
|
149
122
|
const maxVisible = 10;
|
|
150
123
|
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredModels.length - maxVisible));
|
|
151
124
|
const endIndex = Math.min(startIndex + maxVisible, this.filteredModels.length);
|
|
152
|
-
// Show visible slice of filtered models
|
|
153
125
|
for (let i = startIndex; i < endIndex; i++) {
|
|
154
126
|
const item = this.filteredModels[i];
|
|
155
|
-
if (
|
|
127
|
+
if (item === undefined)
|
|
156
128
|
continue;
|
|
157
129
|
const isSelected = i === this.selectedIndex;
|
|
158
130
|
const isCurrent = this.currentModel === item;
|
|
@@ -160,51 +132,42 @@ class ModelSelectorComponent extends Container {
|
|
|
160
132
|
if (isSelected) {
|
|
161
133
|
const prefix = style.blue("→ ");
|
|
162
134
|
const modelText = `${item}`;
|
|
163
|
-
// const providerBadge = style.gray(`[${item.provider}]`);
|
|
164
135
|
const checkmark = isCurrent ? style.green(" ✓") : "";
|
|
165
136
|
line = `${prefix + style.blue(modelText)} ${checkmark}`;
|
|
166
137
|
}
|
|
167
138
|
else {
|
|
168
139
|
const modelText = ` ${item}`;
|
|
169
|
-
// const providerBadge = style.gray(`[${item.provider}]`);
|
|
170
140
|
const checkmark = isCurrent ? style.green(" ✓") : "";
|
|
171
141
|
line = `${modelText} ${checkmark}`;
|
|
172
142
|
}
|
|
173
143
|
this.listContainer.addChild(new Text(line, 0, 0));
|
|
174
144
|
}
|
|
175
|
-
// Add scroll indicator if needed
|
|
176
145
|
if (startIndex > 0 || endIndex < this.filteredModels.length) {
|
|
177
146
|
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredModels.length})`);
|
|
178
147
|
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
179
148
|
}
|
|
180
|
-
// Show "no results" if empty
|
|
181
149
|
if (this.filteredModels.length === 0) {
|
|
182
150
|
this.listContainer.addChild(new Text(style.gray(" No matching models"), 0, 0));
|
|
183
151
|
}
|
|
184
152
|
}
|
|
185
153
|
handleInput(keyData) {
|
|
186
|
-
|
|
187
|
-
if (keyData === "\x1b[A") {
|
|
154
|
+
if (isArrowUp(keyData)) {
|
|
188
155
|
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
189
156
|
this.updateList();
|
|
190
157
|
}
|
|
191
|
-
|
|
192
|
-
else if (keyData === "\x1b[B") {
|
|
158
|
+
else if (isArrowDown(keyData)) {
|
|
193
159
|
this.selectedIndex = Math.min(this.filteredModels.length - 1, this.selectedIndex + 1);
|
|
194
160
|
this.updateList();
|
|
195
161
|
}
|
|
196
|
-
|
|
197
|
-
else if (keyData === "\r") {
|
|
162
|
+
else if (isEnter(keyData)) {
|
|
198
163
|
const selectedModel = this.filteredModels[this.selectedIndex];
|
|
199
|
-
if (selectedModel) {
|
|
164
|
+
if (selectedModel !== undefined) {
|
|
200
165
|
this.handleSelect(selectedModel);
|
|
201
166
|
}
|
|
202
167
|
}
|
|
203
|
-
|
|
204
|
-
else if (keyData === "\x1b") {
|
|
168
|
+
else if (isEscape(keyData)) {
|
|
205
169
|
this.onCancelCallback();
|
|
206
170
|
}
|
|
207
|
-
// Pass everything else to search input
|
|
208
171
|
else {
|
|
209
172
|
this.searchInput.handleInput(keyData);
|
|
210
173
|
this.filterModels(this.searchInput.getValue());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/model/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,SAAS,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,GACP,IAAI,CAIN"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { CommandOptions, ReplCommand } from "
|
|
1
|
+
import type { CommandOptions, ReplCommand } from "../types.ts";
|
|
2
2
|
export declare const pasteCommand: ({ modelManager, promptManager, tokenCounter, }: CommandOptions) => ReplCommand;
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/paste/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/D,eAAO,MAAM,YAAY,GAAI,gDAI1B,cAAc,KAAG,WAiKnB,CAAC"}
|
|
@@ -1,105 +1,9 @@
|
|
|
1
1
|
import Clipboard from "@crosscopy/clipboard";
|
|
2
|
-
import { formatBlock } from "
|
|
3
|
-
import { logger } from "
|
|
4
|
-
import style from "
|
|
5
|
-
import { Text } from "
|
|
6
|
-
|
|
7
|
-
return dataUrl.replace(/^data:.*?;base64,/, "");
|
|
8
|
-
}
|
|
9
|
-
function isValidBase64(str) {
|
|
10
|
-
try {
|
|
11
|
-
// Remove data URL prefix if present
|
|
12
|
-
const base64Content = extractBase64Content(str);
|
|
13
|
-
// Try to decode the base64 string
|
|
14
|
-
const decoded = Buffer.from(base64Content, "base64");
|
|
15
|
-
// Re-encode to verify it's valid base64
|
|
16
|
-
const reEncoded = decoded.toString("base64");
|
|
17
|
-
// Remove padding for comparison
|
|
18
|
-
const normalizedOriginal = base64Content.replace(/=/g, "");
|
|
19
|
-
const normalizedReEncoded = reEncoded.replace(/=/g, "");
|
|
20
|
-
return normalizedOriginal === normalizedReEncoded;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function detectImageFormatFromBase64(base64Content) {
|
|
27
|
-
try {
|
|
28
|
-
const buffer = Buffer.from(base64Content, "base64");
|
|
29
|
-
// Check for JPEG signature (FF D8 FF)
|
|
30
|
-
if (buffer.length >= 3 &&
|
|
31
|
-
buffer[0] === 0xff &&
|
|
32
|
-
buffer[1] === 0xd8 &&
|
|
33
|
-
buffer[2] === 0xff) {
|
|
34
|
-
return "image/jpeg";
|
|
35
|
-
}
|
|
36
|
-
// Check for PNG signature (89 50 4E 47 0D 0A 1A 0A)
|
|
37
|
-
if (buffer.length >= 8 &&
|
|
38
|
-
buffer[0] === 0x89 &&
|
|
39
|
-
buffer[1] === 0x50 &&
|
|
40
|
-
buffer[2] === 0x4e &&
|
|
41
|
-
buffer[3] === 0x47 &&
|
|
42
|
-
buffer[4] === 0x0d &&
|
|
43
|
-
buffer[5] === 0x0a &&
|
|
44
|
-
buffer[6] === 0x1a &&
|
|
45
|
-
buffer[7] === 0x0a) {
|
|
46
|
-
return "image/png";
|
|
47
|
-
}
|
|
48
|
-
// Check for GIF signature (GIF87a or GIF89a)
|
|
49
|
-
if (buffer.length >= 6 &&
|
|
50
|
-
((buffer[0] === 0x47 &&
|
|
51
|
-
buffer[1] === 0x49 &&
|
|
52
|
-
buffer[2] === 0x46 &&
|
|
53
|
-
buffer[3] === 0x38 &&
|
|
54
|
-
buffer[4] === 0x37 &&
|
|
55
|
-
buffer[5] === 0x61) ||
|
|
56
|
-
(buffer[0] === 0x47 &&
|
|
57
|
-
buffer[1] === 0x49 &&
|
|
58
|
-
buffer[2] === 0x46 &&
|
|
59
|
-
buffer[3] === 0x38 &&
|
|
60
|
-
buffer[4] === 0x39 &&
|
|
61
|
-
buffer[5] === 0x61))) {
|
|
62
|
-
return "image/gif";
|
|
63
|
-
}
|
|
64
|
-
// Check for WebP signature (RIFF .... WEBP)
|
|
65
|
-
if (buffer.length >= 12 &&
|
|
66
|
-
buffer[0] === 0x52 &&
|
|
67
|
-
buffer[1] === 0x49 &&
|
|
68
|
-
buffer[2] === 0x46 &&
|
|
69
|
-
buffer[3] === 0x46 &&
|
|
70
|
-
buffer[8] === 0x57 &&
|
|
71
|
-
buffer[9] === 0x45 &&
|
|
72
|
-
buffer[10] === 0x42 &&
|
|
73
|
-
buffer[11] === 0x50) {
|
|
74
|
-
return "image/webp";
|
|
75
|
-
}
|
|
76
|
-
// Check for BMP signature (BM)
|
|
77
|
-
if (buffer.length >= 2 && buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
|
78
|
-
return "image/bmp";
|
|
79
|
-
}
|
|
80
|
-
// Check for TIFF signatures (II* or MM*)
|
|
81
|
-
if (buffer.length >= 4 &&
|
|
82
|
-
((buffer[0] === 0x49 &&
|
|
83
|
-
buffer[1] === 0x49 &&
|
|
84
|
-
buffer[2] === 0x2a &&
|
|
85
|
-
buffer[3] === 0x00) ||
|
|
86
|
-
(buffer[0] === 0x4d &&
|
|
87
|
-
buffer[1] === 0x4d &&
|
|
88
|
-
buffer[2] === 0x00 &&
|
|
89
|
-
buffer[3] === 0x2a))) {
|
|
90
|
-
return "image/tiff";
|
|
91
|
-
}
|
|
92
|
-
// If no known signature found, fall back to the data URL MIME type
|
|
93
|
-
return "unknown";
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return "unknown";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function extractMimeTypeFromDataUrl(dataUrl) {
|
|
100
|
-
const match = dataUrl.match(/^data:([^;]+);base64,/);
|
|
101
|
-
return match?.[1] ? match[1] : "image/png";
|
|
102
|
-
}
|
|
2
|
+
import { formatBlock } from "../../formatting.js";
|
|
3
|
+
import { logger } from "../../logger.js";
|
|
4
|
+
import style from "../../terminal/style.js";
|
|
5
|
+
import { Text } from "../../tui/index.js";
|
|
6
|
+
import { detectImageFormatFromBase64, extractMimeTypeFromDataUrl, isValidBase64, } from "./utils.js";
|
|
103
7
|
export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) => {
|
|
104
8
|
return {
|
|
105
9
|
command: "/paste",
|
|
@@ -109,25 +13,19 @@ export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) =>
|
|
|
109
13
|
try {
|
|
110
14
|
if (Clipboard.hasImage()) {
|
|
111
15
|
const base64DataUrl = await Clipboard.getImageBase64();
|
|
112
|
-
// Validate the base64 data
|
|
113
16
|
if (!isValidBase64(base64DataUrl)) {
|
|
114
17
|
container.addChild(new Text(style.red("Invalid base64 data in clipboard. The image data may be corrupted."), 1, 0));
|
|
115
18
|
tui.requestRender();
|
|
116
19
|
editor.setText("");
|
|
117
20
|
return "continue";
|
|
118
21
|
}
|
|
119
|
-
// Extract MIME type with better error handling and actual image format detection
|
|
120
22
|
let mimeType;
|
|
121
23
|
try {
|
|
122
|
-
// First, try to get MIME type from data URL
|
|
123
24
|
const dataUrlMimeType = extractMimeTypeFromDataUrl(base64DataUrl);
|
|
124
|
-
|
|
125
|
-
const base64Content = extractBase64Content(base64DataUrl);
|
|
25
|
+
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
126
26
|
const detectedFormat = detectImageFormatFromBase64(base64Content);
|
|
127
|
-
// Use detected format if available, otherwise fall back to data URL MIME type
|
|
128
27
|
if (detectedFormat !== "unknown") {
|
|
129
28
|
mimeType = detectedFormat;
|
|
130
|
-
// Log if there's a mismatch between data URL and actual format
|
|
131
29
|
if (dataUrlMimeType !== detectedFormat) {
|
|
132
30
|
logger.warn(`Clipboard library reported ${dataUrlMimeType} but actual image format is ${detectedFormat}. Using detected format.`);
|
|
133
31
|
}
|
|
@@ -141,12 +39,9 @@ export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) =>
|
|
|
141
39
|
logger.warn(`Failed to extract MIME type from clipboard image: ${error}`);
|
|
142
40
|
mimeType = "image/png";
|
|
143
41
|
}
|
|
144
|
-
// Ensure the data URL format is correct
|
|
145
42
|
if (!base64DataUrl.startsWith(`data:${mimeType};base64,`)) {
|
|
146
|
-
// Fix malformed data URLs
|
|
147
43
|
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
148
44
|
const correctedDataUrl = `data:${mimeType};base64,${base64Content}`;
|
|
149
|
-
// Final validation
|
|
150
45
|
if (!isValidBase64(correctedDataUrl)) {
|
|
151
46
|
container.addChild(new Text(style.red("Failed to correct base64 data format. The image data may be corrupted."), 1, 0));
|
|
152
47
|
tui.requestRender();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function extractBase64Content(dataUrl: string): string;
|
|
2
|
+
export declare function isValidBase64(str: string): boolean;
|
|
3
|
+
export declare function detectImageFormatFromBase64(base64Content: string): string;
|
|
4
|
+
export declare function extractMimeTypeFromDataUrl(dataUrl: string): string;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/paste/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWlD;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAiFzE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGlE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function extractBase64Content(dataUrl) {
|
|
2
|
+
return dataUrl.replace(/^data:.*?;base64,/, "");
|
|
3
|
+
}
|
|
4
|
+
export function isValidBase64(str) {
|
|
5
|
+
try {
|
|
6
|
+
const base64Content = extractBase64Content(str);
|
|
7
|
+
const decoded = Buffer.from(base64Content, "base64");
|
|
8
|
+
const reEncoded = decoded.toString("base64");
|
|
9
|
+
const normalizedOriginal = base64Content.replace(/=/g, "");
|
|
10
|
+
const normalizedReEncoded = reEncoded.replace(/=/g, "");
|
|
11
|
+
return normalizedOriginal === normalizedReEncoded;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function detectImageFormatFromBase64(base64Content) {
|
|
18
|
+
try {
|
|
19
|
+
const buffer = Buffer.from(base64Content, "base64");
|
|
20
|
+
if (buffer.length >= 3 &&
|
|
21
|
+
buffer[0] === 0xff &&
|
|
22
|
+
buffer[1] === 0xd8 &&
|
|
23
|
+
buffer[2] === 0xff) {
|
|
24
|
+
return "image/jpeg";
|
|
25
|
+
}
|
|
26
|
+
if (buffer.length >= 8 &&
|
|
27
|
+
buffer[0] === 0x89 &&
|
|
28
|
+
buffer[1] === 0x50 &&
|
|
29
|
+
buffer[2] === 0x4e &&
|
|
30
|
+
buffer[3] === 0x47 &&
|
|
31
|
+
buffer[4] === 0x0d &&
|
|
32
|
+
buffer[5] === 0x0a &&
|
|
33
|
+
buffer[6] === 0x1a &&
|
|
34
|
+
buffer[7] === 0x0a) {
|
|
35
|
+
return "image/png";
|
|
36
|
+
}
|
|
37
|
+
if (buffer.length >= 6 &&
|
|
38
|
+
((buffer[0] === 0x47 &&
|
|
39
|
+
buffer[1] === 0x49 &&
|
|
40
|
+
buffer[2] === 0x46 &&
|
|
41
|
+
buffer[3] === 0x38 &&
|
|
42
|
+
buffer[4] === 0x37 &&
|
|
43
|
+
buffer[5] === 0x61) ||
|
|
44
|
+
(buffer[0] === 0x47 &&
|
|
45
|
+
buffer[1] === 0x49 &&
|
|
46
|
+
buffer[2] === 0x46 &&
|
|
47
|
+
buffer[3] === 0x38 &&
|
|
48
|
+
buffer[4] === 0x39 &&
|
|
49
|
+
buffer[5] === 0x61))) {
|
|
50
|
+
return "image/gif";
|
|
51
|
+
}
|
|
52
|
+
if (buffer.length >= 12 &&
|
|
53
|
+
buffer[0] === 0x52 &&
|
|
54
|
+
buffer[1] === 0x49 &&
|
|
55
|
+
buffer[2] === 0x46 &&
|
|
56
|
+
buffer[3] === 0x46 &&
|
|
57
|
+
buffer[8] === 0x57 &&
|
|
58
|
+
buffer[9] === 0x45 &&
|
|
59
|
+
buffer[10] === 0x42 &&
|
|
60
|
+
buffer[11] === 0x50) {
|
|
61
|
+
return "image/webp";
|
|
62
|
+
}
|
|
63
|
+
if (buffer.length >= 2 && buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
|
64
|
+
return "image/bmp";
|
|
65
|
+
}
|
|
66
|
+
if (buffer.length >= 4 &&
|
|
67
|
+
((buffer[0] === 0x49 &&
|
|
68
|
+
buffer[1] === 0x49 &&
|
|
69
|
+
buffer[2] === 0x2a &&
|
|
70
|
+
buffer[3] === 0x00) ||
|
|
71
|
+
(buffer[0] === 0x4d &&
|
|
72
|
+
buffer[1] === 0x4d &&
|
|
73
|
+
buffer[2] === 0x00 &&
|
|
74
|
+
buffer[3] === 0x2a))) {
|
|
75
|
+
return "image/tiff";
|
|
76
|
+
}
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return "unknown";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function extractMimeTypeFromDataUrl(dataUrl) {
|
|
84
|
+
const match = dataUrl.match(/^data:([^;]+);base64,/);
|
|
85
|
+
return match?.[1] ?? "image/png";
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ/D,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,WA0DvD,CAAC"}
|