@travisennis/acai 0.0.5 → 0.0.7
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 +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -1,84 +1,219 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isValidModel, modelRegistry, models, } from "../models/providers.js";
|
|
2
|
+
import { getTerminalSize } from "../terminal/formatting.js";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Container, Input, Spacer, Text, } from "../tui/index.js";
|
|
2
5
|
export function modelCommand(options) {
|
|
3
|
-
const {
|
|
4
|
-
function switchModel(newModelName) {
|
|
5
|
-
try {
|
|
6
|
-
// Get current and new model configs
|
|
7
|
-
const currentModelConfig = modelManager.getModelMetadata("repl");
|
|
8
|
-
const newModelConfig = modelRegistry[newModelName]; // Ensure modelRegistry is available
|
|
9
|
-
if (!newModelConfig) {
|
|
10
|
-
terminal.error(`Model configuration not found for: ${newModelName}`);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
// Check for capability differences
|
|
14
|
-
if (currentModelConfig.supportsToolCalling &&
|
|
15
|
-
!newModelConfig.supportsToolCalling) {
|
|
16
|
-
terminal.warn("The new model doesn't support tool calling, which may limit functionality.");
|
|
17
|
-
}
|
|
18
|
-
if (currentModelConfig.supportsReasoning &&
|
|
19
|
-
!newModelConfig.supportsReasoning) {
|
|
20
|
-
terminal.warn("The new model doesn't support reasoning, which may change response quality.");
|
|
21
|
-
}
|
|
22
|
-
// Update model in ModelManager
|
|
23
|
-
modelManager.setModel("repl", newModelName);
|
|
24
|
-
// Assuming ModelManager handles the actual model instance switching internally.
|
|
25
|
-
terminal.info(`Model set to ${newModelName}.`); // Simplified message
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
terminal.error(`Failed to switch model: ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
6
|
+
const { modelManager } = options;
|
|
31
7
|
return {
|
|
32
8
|
command: "/model",
|
|
33
|
-
description: "List available models or switch to a different model. Usage: /model [provider:model-name|
|
|
9
|
+
description: "List available models or switch to a different model. Usage: /model [provider:model-name|provider]",
|
|
34
10
|
getSubCommands: () => Promise.resolve(models),
|
|
35
|
-
async
|
|
11
|
+
async handle(args, { tui, container, inputContainer, editor, }) {
|
|
36
12
|
const arg = args.join(" ").trim();
|
|
37
13
|
const modelConfig = modelManager.getModelMetadata("repl");
|
|
38
|
-
// No args - display
|
|
14
|
+
// No args - display model selector
|
|
39
15
|
if (!arg) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
16
|
+
// Create model selector with current model
|
|
17
|
+
const modelSelector = new ModelSelectorComponent(modelConfig.id, (model) => {
|
|
18
|
+
// Apply the selected model
|
|
19
|
+
modelManager.setModel("repl", model);
|
|
20
|
+
// Hide selector and show editor again
|
|
21
|
+
hideModelSelector(inputContainer, editor, tui);
|
|
22
|
+
tui.requestRender();
|
|
23
|
+
}, () => {
|
|
24
|
+
// Just hide the selector
|
|
25
|
+
hideModelSelector(inputContainer, editor, tui);
|
|
26
|
+
tui.requestRender();
|
|
27
|
+
});
|
|
28
|
+
// Replace editor with selector
|
|
29
|
+
inputContainer.clear();
|
|
30
|
+
inputContainer.addChild(modelSelector);
|
|
31
|
+
tui.setFocus(modelSelector);
|
|
32
|
+
tui.requestRender();
|
|
51
33
|
return "continue";
|
|
52
34
|
}
|
|
53
35
|
// Switch to a specific model
|
|
54
36
|
if (isValidModel(arg)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
try {
|
|
38
|
+
// Get current and new model configs
|
|
39
|
+
const currentModelConfig = modelManager.getModelMetadata("repl");
|
|
40
|
+
const newModelConfig = modelRegistry[arg];
|
|
41
|
+
if (!newModelConfig) {
|
|
42
|
+
container.addChild(new Text(style.red(`Model configuration not found for: ${arg}`), 1, 0));
|
|
43
|
+
tui.requestRender();
|
|
44
|
+
editor.setText("");
|
|
45
|
+
return "continue";
|
|
46
|
+
}
|
|
47
|
+
// Check for capability differences
|
|
48
|
+
if (currentModelConfig.supportsToolCalling &&
|
|
49
|
+
!newModelConfig.supportsToolCalling) {
|
|
50
|
+
container.addChild(new Text(style.yellow("The new model doesn't support tool calling, which may limit functionality."), 1, 0));
|
|
51
|
+
}
|
|
52
|
+
if (currentModelConfig.supportsReasoning &&
|
|
53
|
+
!newModelConfig.supportsReasoning) {
|
|
54
|
+
container.addChild(new Text(style.yellow("The new model doesn't support reasoning, which may change response quality."), 2, 0));
|
|
55
|
+
}
|
|
56
|
+
// Update model in ModelManager
|
|
57
|
+
modelManager.setModel("repl", arg);
|
|
58
|
+
// container.addChild(
|
|
59
|
+
// new Text(style.green(`Model set to ${arg}.`), 3, 0),
|
|
60
|
+
// );
|
|
61
|
+
tui.requestRender();
|
|
62
|
+
editor.setText("");
|
|
63
|
+
return "continue";
|
|
66
64
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Need to ensure modelRegistry is accessible and correctly typed
|
|
73
|
-
for (const model of Object.values(modelRegistry).filter((m) => m.provider === arg)) {
|
|
74
|
-
terminal.writeln(formatModelInfo(model));
|
|
65
|
+
catch (error) {
|
|
66
|
+
container.addChild(new Text(style.red(`Failed to switch model: ${error.message}`), 0, 0));
|
|
67
|
+
tui.requestRender();
|
|
68
|
+
editor.setText("");
|
|
69
|
+
return "continue";
|
|
75
70
|
}
|
|
76
|
-
return "continue";
|
|
77
71
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
terminal.info("Usage: /model [provider:model-name|category|provider]");
|
|
72
|
+
tui.requestRender();
|
|
73
|
+
editor.setText("");
|
|
81
74
|
return "continue";
|
|
82
75
|
},
|
|
83
76
|
};
|
|
84
77
|
}
|
|
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
|
+
class ModelSelectorComponent extends Container {
|
|
88
|
+
searchInput;
|
|
89
|
+
listContainer;
|
|
90
|
+
allModels = [];
|
|
91
|
+
filteredModels = [];
|
|
92
|
+
selectedIndex = 0;
|
|
93
|
+
currentModel;
|
|
94
|
+
onSelectCallback;
|
|
95
|
+
onCancelCallback;
|
|
96
|
+
constructor(currentModel, onSelect, onCancel) {
|
|
97
|
+
super();
|
|
98
|
+
this.currentModel = currentModel;
|
|
99
|
+
this.onSelectCallback = onSelect;
|
|
100
|
+
this.onCancelCallback = onCancel;
|
|
101
|
+
// Load all models
|
|
102
|
+
this.loadModels();
|
|
103
|
+
const { columns } = getTerminalSize();
|
|
104
|
+
// Add top border
|
|
105
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
106
|
+
this.addChild(new Spacer(1));
|
|
107
|
+
// Create search input
|
|
108
|
+
this.searchInput = new Input();
|
|
109
|
+
this.searchInput.onSubmit = () => {
|
|
110
|
+
// Enter on search input selects the first filtered item
|
|
111
|
+
if (this.filteredModels[this.selectedIndex]) {
|
|
112
|
+
this.handleSelect(this.filteredModels[this.selectedIndex]);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.addChild(this.searchInput);
|
|
116
|
+
this.addChild(new Spacer(1));
|
|
117
|
+
// Create list container
|
|
118
|
+
this.listContainer = new Container();
|
|
119
|
+
this.addChild(this.listContainer);
|
|
120
|
+
this.addChild(new Spacer(1));
|
|
121
|
+
// Add bottom border
|
|
122
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
123
|
+
// Initial render
|
|
124
|
+
this.updateList();
|
|
125
|
+
}
|
|
126
|
+
loadModels() {
|
|
127
|
+
this.allModels = models;
|
|
128
|
+
this.filteredModels = models;
|
|
129
|
+
}
|
|
130
|
+
filterModels(query) {
|
|
131
|
+
if (!query.trim()) {
|
|
132
|
+
this.filteredModels = this.allModels;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const searchTokens = query
|
|
136
|
+
.toLowerCase()
|
|
137
|
+
.split(/\s+/)
|
|
138
|
+
.filter((t) => t);
|
|
139
|
+
this.filteredModels = this.allModels.filter((model) => {
|
|
140
|
+
const searchText = `${model}`.toLowerCase();
|
|
141
|
+
return searchTokens.every((token) => searchText.includes(token));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredModels.length - 1));
|
|
145
|
+
this.updateList();
|
|
146
|
+
}
|
|
147
|
+
updateList() {
|
|
148
|
+
this.listContainer.clear();
|
|
149
|
+
const maxVisible = 10;
|
|
150
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredModels.length - maxVisible));
|
|
151
|
+
const endIndex = Math.min(startIndex + maxVisible, this.filteredModels.length);
|
|
152
|
+
// Show visible slice of filtered models
|
|
153
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
154
|
+
const item = this.filteredModels[i];
|
|
155
|
+
if (!item)
|
|
156
|
+
continue;
|
|
157
|
+
const isSelected = i === this.selectedIndex;
|
|
158
|
+
const isCurrent = this.currentModel === item;
|
|
159
|
+
let line = "";
|
|
160
|
+
if (isSelected) {
|
|
161
|
+
const prefix = style.blue("→ ");
|
|
162
|
+
const modelText = `${item}`;
|
|
163
|
+
// const providerBadge = style.gray(`[${item.provider}]`);
|
|
164
|
+
const checkmark = isCurrent ? style.green(" ✓") : "";
|
|
165
|
+
line = `${prefix + style.blue(modelText)} ${checkmark}`;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
const modelText = ` ${item}`;
|
|
169
|
+
// const providerBadge = style.gray(`[${item.provider}]`);
|
|
170
|
+
const checkmark = isCurrent ? style.green(" ✓") : "";
|
|
171
|
+
line = `${modelText} ${checkmark}`;
|
|
172
|
+
}
|
|
173
|
+
this.listContainer.addChild(new Text(line, 0, 0));
|
|
174
|
+
}
|
|
175
|
+
// Add scroll indicator if needed
|
|
176
|
+
if (startIndex > 0 || endIndex < this.filteredModels.length) {
|
|
177
|
+
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredModels.length})`);
|
|
178
|
+
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
179
|
+
}
|
|
180
|
+
// Show "no results" if empty
|
|
181
|
+
if (this.filteredModels.length === 0) {
|
|
182
|
+
this.listContainer.addChild(new Text(style.gray(" No matching models"), 0, 0));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
handleInput(keyData) {
|
|
186
|
+
// Up arrow
|
|
187
|
+
if (keyData === "\x1b[A") {
|
|
188
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
189
|
+
this.updateList();
|
|
190
|
+
}
|
|
191
|
+
// Down arrow
|
|
192
|
+
else if (keyData === "\x1b[B") {
|
|
193
|
+
this.selectedIndex = Math.min(this.filteredModels.length - 1, this.selectedIndex + 1);
|
|
194
|
+
this.updateList();
|
|
195
|
+
}
|
|
196
|
+
// Enter
|
|
197
|
+
else if (keyData === "\r") {
|
|
198
|
+
const selectedModel = this.filteredModels[this.selectedIndex];
|
|
199
|
+
if (selectedModel) {
|
|
200
|
+
this.handleSelect(selectedModel);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Escape
|
|
204
|
+
else if (keyData === "\x1b") {
|
|
205
|
+
this.onCancelCallback();
|
|
206
|
+
}
|
|
207
|
+
// Pass everything else to search input
|
|
208
|
+
else {
|
|
209
|
+
this.searchInput.handleInput(keyData);
|
|
210
|
+
this.filterModels(this.searchInput.getValue());
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
handleSelect(model) {
|
|
214
|
+
this.onSelectCallback(model);
|
|
215
|
+
}
|
|
216
|
+
getSearchInput() {
|
|
217
|
+
return this.searchInput;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const pasteCommand: ({
|
|
2
|
+
export declare const pasteCommand: ({ modelManager, promptManager, tokenCounter, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=paste-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-command.d.ts","sourceRoot":"","sources":["../../source/commands/paste-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paste-command.d.ts","sourceRoot":"","sources":["../../source/commands/paste-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAsH9D,eAAO,MAAM,YAAY,GAAI,gDAI1B,cAAc,KAAG,WAwKnB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Clipboard from "@crosscopy/clipboard";
|
|
2
2
|
import { formatBlock } from "../formatting.js";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
|
+
import style from "../terminal/style.js";
|
|
5
|
+
import { Text } from "../tui/index.js";
|
|
4
6
|
function extractBase64Content(dataUrl) {
|
|
5
7
|
return dataUrl.replace(/^data:.*?;base64,/, "");
|
|
6
8
|
}
|
|
@@ -98,18 +100,20 @@ function extractMimeTypeFromDataUrl(dataUrl) {
|
|
|
98
100
|
const match = dataUrl.match(/^data:([^;]+);base64,/);
|
|
99
101
|
return match?.[1] ? match[1] : "image/png";
|
|
100
102
|
}
|
|
101
|
-
export const pasteCommand = ({
|
|
103
|
+
export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) => {
|
|
102
104
|
return {
|
|
103
105
|
command: "/paste",
|
|
104
106
|
description: "Pastes image or text content from the clipboard into the next prompt.",
|
|
105
107
|
getSubCommands: () => Promise.resolve([]),
|
|
106
|
-
|
|
108
|
+
async handle(_args, { tui, container, editor, }) {
|
|
107
109
|
try {
|
|
108
110
|
if (Clipboard.hasImage()) {
|
|
109
111
|
const base64DataUrl = await Clipboard.getImageBase64();
|
|
110
112
|
// Validate the base64 data
|
|
111
113
|
if (!isValidBase64(base64DataUrl)) {
|
|
112
|
-
|
|
114
|
+
container.addChild(new Text(style.red("Invalid base64 data in clipboard. The image data may be corrupted."), 1, 0));
|
|
115
|
+
tui.requestRender();
|
|
116
|
+
editor.setText("");
|
|
113
117
|
return "continue";
|
|
114
118
|
}
|
|
115
119
|
// Extract MIME type with better error handling and actual image format detection
|
|
@@ -144,7 +148,9 @@ export const pasteCommand = ({ terminal, modelManager, promptManager, tokenCount
|
|
|
144
148
|
const correctedDataUrl = `data:${mimeType};base64,${base64Content}`;
|
|
145
149
|
// Final validation
|
|
146
150
|
if (!isValidBase64(correctedDataUrl)) {
|
|
147
|
-
|
|
151
|
+
container.addChild(new Text(style.red("Failed to correct base64 data format. The image data may be corrupted."), 1, 0));
|
|
152
|
+
tui.requestRender();
|
|
153
|
+
editor.setText("");
|
|
148
154
|
return "continue";
|
|
149
155
|
}
|
|
150
156
|
promptManager.addContext({
|
|
@@ -160,26 +166,34 @@ export const pasteCommand = ({ terminal, modelManager, promptManager, tokenCount
|
|
|
160
166
|
mediaType: mimeType,
|
|
161
167
|
});
|
|
162
168
|
}
|
|
163
|
-
|
|
169
|
+
container.addChild(new Text(style.green("Image from clipboard will be added to your next prompt."), 1, 0));
|
|
170
|
+
tui.requestRender();
|
|
171
|
+
editor.setText("");
|
|
164
172
|
return "continue";
|
|
165
173
|
}
|
|
166
174
|
const clipboardContent = await Clipboard.getText();
|
|
167
175
|
if (!clipboardContent || clipboardContent.trim() === "") {
|
|
168
|
-
|
|
176
|
+
container.addChild(new Text(style.yellow("Clipboard is empty."), 0, 1));
|
|
177
|
+
tui.requestRender();
|
|
178
|
+
editor.setText("");
|
|
169
179
|
return "continue";
|
|
170
180
|
}
|
|
171
181
|
const content = formatBlock(clipboardContent, "clipboard", modelManager.getModelMetadata("repl").promptFormat);
|
|
172
182
|
promptManager.addContext(content);
|
|
173
183
|
const tokenCount = tokenCounter.count(content);
|
|
174
|
-
|
|
184
|
+
container.addChild(new Text(style.green(`Clipboard content will be added to your next prompt. (${tokenCount} tokens)`), 1, 0));
|
|
185
|
+
tui.requestRender();
|
|
186
|
+
editor.setText("");
|
|
187
|
+
return "continue";
|
|
175
188
|
}
|
|
176
189
|
catch (error) {
|
|
177
190
|
const message = error instanceof Error ? error.message : String(error);
|
|
178
|
-
|
|
191
|
+
container.addChild(new Text(style.red(`Error processing clipboard content: ${message}`), 1, 0));
|
|
179
192
|
logger.error(error, "Paste command error:");
|
|
193
|
+
tui.requestRender();
|
|
194
|
+
editor.setText("");
|
|
180
195
|
return "continue";
|
|
181
196
|
}
|
|
182
|
-
return "continue";
|
|
183
197
|
},
|
|
184
198
|
};
|
|
185
199
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickup-command.d.ts","sourceRoot":"","sources":["../../source/commands/pickup-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,WAuIvD,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { logger } from "../logger.js";
|
|
4
|
+
import { createUserMessage } from "../messages.js";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { Text } from "../tui/index.js";
|
|
7
|
+
export const pickupCommand = (options) => {
|
|
8
|
+
return {
|
|
9
|
+
command: "/pickup",
|
|
10
|
+
description: "Loads a handoff file into a new session to continue previous work. Usage: /pickup <filename>",
|
|
11
|
+
getSubCommands: async () => {
|
|
12
|
+
const getHandoffFileNames = async () => {
|
|
13
|
+
try {
|
|
14
|
+
const dirents = await readdir(options.workspace.primaryDir, {
|
|
15
|
+
withFileTypes: true,
|
|
16
|
+
});
|
|
17
|
+
return dirents
|
|
18
|
+
.filter((dirent) => dirent.isFile() && dirent.name.match(/^handoff-.*\.md$/))
|
|
19
|
+
.map((dirent) => basename(dirent.name, ".md"));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code === "ENOENT") {
|
|
23
|
+
return []; // Directory doesn't exist, return empty array
|
|
24
|
+
}
|
|
25
|
+
logger.error(`Error reading handoff files: ${error}`);
|
|
26
|
+
return []; // Return empty on other errors too, but log them
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return await getHandoffFileNames();
|
|
30
|
+
},
|
|
31
|
+
async handle(args, { tui, container, editor, }) {
|
|
32
|
+
const { messageHistory, modelManager } = options;
|
|
33
|
+
// Validate that filename is provided
|
|
34
|
+
const filename = args.join(" ").trim();
|
|
35
|
+
if (!filename) {
|
|
36
|
+
const availableFiles = await getAvailableHandoffFiles(options);
|
|
37
|
+
if (availableFiles.length === 0) {
|
|
38
|
+
container.addChild(new Text(style.red("No handoff files found. Create a handoff file first using /handoff <purpose>"), 1, 0));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
container.addChild(new Text(style.red("Please specify a handoff file to load."), 0, 1));
|
|
42
|
+
container.addChild(new Text("Available handoff files:", 2, 0));
|
|
43
|
+
availableFiles.forEach((file, index) => {
|
|
44
|
+
container.addChild(new Text(` • ${file}.md`, 3 + index, 0));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
tui.requestRender();
|
|
48
|
+
editor.setText("");
|
|
49
|
+
return "continue";
|
|
50
|
+
}
|
|
51
|
+
// Ensure filename has .md extension for file operations
|
|
52
|
+
const filenameWithExt = filename.endsWith(".md")
|
|
53
|
+
? filename
|
|
54
|
+
: `${filename}.md`;
|
|
55
|
+
const filepath = `${options.workspace.primaryDir}/${filenameWithExt}`;
|
|
56
|
+
try {
|
|
57
|
+
// Read the handoff file
|
|
58
|
+
const handoffContent = await readFile(filepath, "utf8");
|
|
59
|
+
container.addChild(new Text(`Loading handoff file: ${style.blue(filenameWithExt)}`, 1, 0));
|
|
60
|
+
// Create new session (like compact-command does)
|
|
61
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
62
|
+
// Append handoff content as user message
|
|
63
|
+
messageHistory.appendUserMessage(createUserMessage([], handoffContent));
|
|
64
|
+
container.addChild(new Text(style.green("Handoff file loaded successfully into new session."), 2, 0));
|
|
65
|
+
container.addChild(new Text("You can now continue with your previous work.", 3, 0));
|
|
66
|
+
tui.requestRender();
|
|
67
|
+
editor.setText("");
|
|
68
|
+
return "use";
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.code === "ENOENT") {
|
|
72
|
+
container.addChild(new Text(style.red(`Handoff file not found: ${filenameWithExt}`), 1, 0));
|
|
73
|
+
// Show available files as helpful suggestion
|
|
74
|
+
const availableFiles = await getAvailableHandoffFiles(options);
|
|
75
|
+
if (availableFiles.length > 0) {
|
|
76
|
+
container.addChild(new Text("Available handoff files:", 2, 0));
|
|
77
|
+
availableFiles.forEach((file, index) => {
|
|
78
|
+
container.addChild(new Text(` • ${file}.md`, 3 + index, 0));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
container.addChild(new Text(style.red(`Error reading handoff file: ${error}`), 0, 1));
|
|
84
|
+
}
|
|
85
|
+
tui.requestRender();
|
|
86
|
+
editor.setText("");
|
|
87
|
+
return "continue";
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
async function getAvailableHandoffFiles(options) {
|
|
93
|
+
try {
|
|
94
|
+
const dirents = await readdir(options.workspace.primaryDir, {
|
|
95
|
+
withFileTypes: true,
|
|
96
|
+
});
|
|
97
|
+
return dirents
|
|
98
|
+
.filter((dirent) => dirent.isFile() && dirent.name.match(/^handoff-.*\.md$/))
|
|
99
|
+
.map((dirent) => basename(dirent.name, ".md"))
|
|
100
|
+
.sort();
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error.code === "ENOENT") {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
logger.error(`Error reading handoff files: ${error}`);
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import type { ConfigManager } from "../config.ts";
|
|
1
2
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
|
|
3
|
+
interface PromptMetadata {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
path: string;
|
|
8
|
+
type: "project" | "user";
|
|
9
|
+
}
|
|
10
|
+
interface ParsedPrompt {
|
|
11
|
+
content: string;
|
|
12
|
+
metadata: {
|
|
13
|
+
description: string;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function parsePromptFile(content: string): ParsedPrompt;
|
|
18
|
+
export declare function loadPrompts(config: ConfigManager): Promise<Map<string, PromptMetadata>>;
|
|
19
|
+
export declare const promptCommand: ({ modelManager, promptManager, config, promptHistory, workspace, }: CommandOptions) => ReplCommand;
|
|
20
|
+
export {};
|
|
3
21
|
//# sourceMappingURL=prompt-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/prompt-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/prompt-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA+C9D,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAmD7D;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,aAAa,wCA8DtD;AAED,eAAO,MAAM,aAAa,GAAI,oEAM3B,cAAc,KAAG,WA0HnB,CAAC"}
|