@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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
5
|
+
export const addDirectoryCommand = ({ workspace, }) => {
|
|
6
|
+
return {
|
|
7
|
+
command: "/add-directory",
|
|
8
|
+
description: "Add a directory to the list of allowed working directories",
|
|
9
|
+
getSubCommands: async () => {
|
|
10
|
+
return [];
|
|
11
|
+
},
|
|
12
|
+
async handle(args, { tui, container, editor, }) {
|
|
13
|
+
const directoryPath = args?.[0];
|
|
14
|
+
if (!directoryPath) {
|
|
15
|
+
container.addChild(new Text(style.red("Usage: /add-directory <path>"), 0, 1));
|
|
16
|
+
tui.requestRender();
|
|
17
|
+
editor.setText("");
|
|
18
|
+
return "continue";
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// Resolve and validate the directory
|
|
22
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
23
|
+
const stats = await fs.stat(resolvedPath);
|
|
24
|
+
if (!stats.isDirectory()) {
|
|
25
|
+
container.addChild(new Text(style.red(`Path is not a directory: ${resolvedPath}`), 1, 0));
|
|
26
|
+
tui.requestRender();
|
|
27
|
+
editor.setText("");
|
|
28
|
+
return "continue";
|
|
29
|
+
}
|
|
30
|
+
// Check if directory is already in the list
|
|
31
|
+
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
32
|
+
container.addChild(new Text(style.yellow(`Directory already in allowed list: ${resolvedPath}`), 1, 0));
|
|
33
|
+
tui.requestRender();
|
|
34
|
+
editor.setText("");
|
|
35
|
+
return "continue";
|
|
36
|
+
}
|
|
37
|
+
// Add the directory to the workspace
|
|
38
|
+
workspace.allowedDirs.push(resolvedPath);
|
|
39
|
+
container.addChild(new Text(`Added directory to allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
40
|
+
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
41
|
+
tui.requestRender();
|
|
42
|
+
editor.setText("");
|
|
43
|
+
return "continue";
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
47
|
+
container.addChild(new Text(style.red(`Failed to add directory: ${errorMessage}`), 0, 1));
|
|
48
|
+
tui.requestRender();
|
|
49
|
+
editor.setText("");
|
|
50
|
+
return "continue";
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const applicationLogCommand: (
|
|
2
|
+
export declare const applicationLogCommand: (_options: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=application-log-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,qBAAqB,GAChC,UAAU,cAAc,KACvB,WAiFF,CAAC"}
|
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { config } from "../config.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
5
|
+
export const applicationLogCommand = (_options) => {
|
|
5
6
|
return {
|
|
6
7
|
command: "/application-logs",
|
|
7
8
|
description: "Opens the application log file defined in acai.json in the editor.",
|
|
8
9
|
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
|
|
10
|
+
async handle(_args, { tui, container, editor, }) {
|
|
10
11
|
let logFilePath;
|
|
11
12
|
try {
|
|
12
|
-
const projectConfig = await config.
|
|
13
|
+
const projectConfig = await config.getConfig();
|
|
13
14
|
logFilePath = projectConfig.logs?.path;
|
|
14
15
|
if (!logFilePath) {
|
|
15
|
-
|
|
16
|
+
container.addChild(new Text(style.red("Application log path is not defined in .acai/acai.json under the 'logs.path' key."), 1, 0));
|
|
17
|
+
tui.requestRender();
|
|
18
|
+
editor.setText("");
|
|
16
19
|
return "continue";
|
|
17
20
|
}
|
|
18
21
|
const content = await readFile(logFilePath, { encoding: "utf8" });
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
: ".log",
|
|
26
|
-
default: content,
|
|
27
|
-
// By not providing an onSubmit or similar handler to write the file,
|
|
28
|
-
// and not calling writeFileSync after, this effectively becomes read-only.
|
|
29
|
-
skipPrompt: true,
|
|
30
|
-
});
|
|
31
|
-
terminal.info(`Closed log view for: ${logFilePath}`);
|
|
22
|
+
// For TUI mode, we'll just display a message since we can't use the editor prompt
|
|
23
|
+
container.addChild(new Text(`Viewing application log: ${style.blue(logFilePath)}`, 0, 1));
|
|
24
|
+
container.addChild(new Text(`Content length: ${content.length} characters`, 2, 0));
|
|
25
|
+
container.addChild(new Text(style.dim("Note: Full log viewing not available in TUI mode"), 3, 0));
|
|
26
|
+
tui.requestRender();
|
|
27
|
+
editor.setText("");
|
|
32
28
|
return "continue";
|
|
33
29
|
}
|
|
34
30
|
catch (error) {
|
|
35
31
|
if (logFilePath && error.code === "ENOENT") {
|
|
36
|
-
|
|
32
|
+
container.addChild(new Text(style.red(`Application log file not found at: ${logFilePath}`), 1, 0));
|
|
37
33
|
}
|
|
38
34
|
else {
|
|
39
|
-
|
|
35
|
+
container.addChild(new Text(style.red(`Error reading log file ${logFilePath ?? "specified in config"}: ${error}`), 1, 0));
|
|
40
36
|
}
|
|
37
|
+
tui.requestRender();
|
|
38
|
+
editor.setText("");
|
|
41
39
|
return "continue";
|
|
42
40
|
}
|
|
43
41
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WAqBvD,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export const clearCommand = (
|
|
1
|
+
export const clearCommand = (_options) => {
|
|
2
2
|
return {
|
|
3
3
|
command: "/clear",
|
|
4
4
|
description: "Clears the terminal screen.",
|
|
5
5
|
getSubCommands: () => Promise.resolve([]),
|
|
6
|
-
|
|
7
|
-
terminal.clear()
|
|
6
|
+
async handle(_args, { tui, container, editor, }) {
|
|
7
|
+
// In TUI mode, we can't clear the screen like terminal.clear()
|
|
8
|
+
// Instead, we'll just clear the input and show a message
|
|
9
|
+
container.clear();
|
|
10
|
+
tui.requestRender();
|
|
11
|
+
editor.setText("");
|
|
8
12
|
return "continue";
|
|
9
13
|
},
|
|
10
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WA6BxD,CAAC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { generateText } from "ai";
|
|
2
2
|
import { createUserMessage } from "../messages.js";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
3
5
|
export const compactCommand = (options) => {
|
|
4
6
|
return {
|
|
5
7
|
command: "/compact",
|
|
6
8
|
description: "Saves, summarizes, and resets the chat history. Optional instructions can be provided for the summary.",
|
|
7
9
|
getSubCommands: () => Promise.resolve([]),
|
|
8
|
-
|
|
9
|
-
const { messageHistory
|
|
10
|
+
async handle(args, { tui, container, editor, }) {
|
|
11
|
+
const { messageHistory } = options;
|
|
10
12
|
if (!messageHistory.isEmpty()) {
|
|
11
13
|
const additionalInstructions = args.join(" ");
|
|
12
14
|
await summarizeAndReset(options, additionalInstructions);
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
container.addChild(new Text(style.green("Message history summarized and reset."), 0, 1));
|
|
17
|
+
tui.requestRender();
|
|
18
|
+
editor.setText("");
|
|
15
19
|
return "continue";
|
|
16
20
|
},
|
|
17
21
|
};
|
|
@@ -45,7 +49,7 @@ Your summary should include the following sections:
|
|
|
45
49
|
messages: messageHistory.get(),
|
|
46
50
|
});
|
|
47
51
|
tokenTracker.trackUsage(app, usage);
|
|
48
|
-
//
|
|
49
|
-
messageHistory.
|
|
52
|
+
//create new session
|
|
53
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
50
54
|
messageHistory.appendUserMessage(createUserMessage([text]));
|
|
51
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-command.d.ts","sourceRoot":"","sources":["../../source/commands/context-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9D,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,GACV,EAAE,cAAc,GAAG,WAAW,CAuH9B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { systemPrompt } from "../prompts.js";
|
|
2
|
+
import { initCliTools } from "../tools/index.js";
|
|
3
|
+
import { prepareTools } from "../tools/utils.js";
|
|
4
|
+
import { Container, Modal, ModalText, TableComponent } from "../tui/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Count tokens from message history
|
|
7
|
+
*/
|
|
8
|
+
function countMessageTokens(messages, counter) {
|
|
9
|
+
if (messages.length === 0) {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
// Serialize messages to JSON for token counting
|
|
13
|
+
const serializedMessages = JSON.stringify(messages);
|
|
14
|
+
return counter.count(serializedMessages);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Format numbers for display (e.g., 1.2k, 5.1m)
|
|
18
|
+
*/
|
|
19
|
+
function formatNum(n) {
|
|
20
|
+
if (n < 1000)
|
|
21
|
+
return `${n}`;
|
|
22
|
+
if (n < 1_000_000)
|
|
23
|
+
return `${(n / 1000).toFixed(1)}k`;
|
|
24
|
+
return `${(n / 1_000_000).toFixed(1)}m`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Calculate percentage for display
|
|
28
|
+
*/
|
|
29
|
+
function pct(n, d) {
|
|
30
|
+
if (d <= 0)
|
|
31
|
+
return "0.0%";
|
|
32
|
+
return `${((n / d) * 100).toFixed(1)}%`;
|
|
33
|
+
}
|
|
34
|
+
export function contextCommand({ config, tokenCounter, modelManager, messageHistory, workspace, }) {
|
|
35
|
+
return {
|
|
36
|
+
command: "/context",
|
|
37
|
+
description: "Show context window usage breakdown",
|
|
38
|
+
getSubCommands: () => Promise.resolve(["--details", "--json"]),
|
|
39
|
+
async handle(args, { tui, editor }) {
|
|
40
|
+
const meta = modelManager.getModelMetadata("repl");
|
|
41
|
+
const window = meta.contextWindow;
|
|
42
|
+
const projectConfig = await config.getConfig();
|
|
43
|
+
// 1) System prompt
|
|
44
|
+
const sys = await systemPrompt({
|
|
45
|
+
type: projectConfig.systemPromptType,
|
|
46
|
+
activeTools: projectConfig.tools.activeTools,
|
|
47
|
+
allowedDirs: workspace.allowedDirs,
|
|
48
|
+
includeRules: true,
|
|
49
|
+
});
|
|
50
|
+
const systemPromptTokens = tokenCounter.count(sys);
|
|
51
|
+
// 2) Tools (MVP approximation)
|
|
52
|
+
let toolsTokens = 0;
|
|
53
|
+
try {
|
|
54
|
+
const tools = await initCliTools({
|
|
55
|
+
tokenCounter,
|
|
56
|
+
workspace,
|
|
57
|
+
});
|
|
58
|
+
const toolDefs = tools.toolDefs;
|
|
59
|
+
const toolNames = JSON.stringify(prepareTools(toolDefs));
|
|
60
|
+
toolsTokens = tokenCounter.count(toolNames);
|
|
61
|
+
// v2: replace with exact serialized definitions
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error(error);
|
|
65
|
+
toolsTokens = 0;
|
|
66
|
+
}
|
|
67
|
+
// 3) Messages
|
|
68
|
+
const messagesTokens = countMessageTokens(messageHistory.get(), tokenCounter);
|
|
69
|
+
// 4) Totals
|
|
70
|
+
const used = systemPromptTokens + toolsTokens + messagesTokens;
|
|
71
|
+
const free = Math.max(0, window - used);
|
|
72
|
+
const breakdown = {
|
|
73
|
+
systemPrompt: systemPromptTokens,
|
|
74
|
+
tools: toolsTokens,
|
|
75
|
+
messages: messagesTokens,
|
|
76
|
+
totalUsed: used,
|
|
77
|
+
window,
|
|
78
|
+
free,
|
|
79
|
+
};
|
|
80
|
+
// Build modal content
|
|
81
|
+
const modalContent = new Container();
|
|
82
|
+
// Context usage table
|
|
83
|
+
const tableData = [
|
|
84
|
+
[
|
|
85
|
+
"System prompt",
|
|
86
|
+
formatNum(breakdown.systemPrompt),
|
|
87
|
+
pct(breakdown.systemPrompt, window),
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"System tools",
|
|
91
|
+
formatNum(breakdown.tools),
|
|
92
|
+
pct(breakdown.tools, window),
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"Messages",
|
|
96
|
+
formatNum(breakdown.messages),
|
|
97
|
+
pct(breakdown.messages, window),
|
|
98
|
+
],
|
|
99
|
+
["Free space", formatNum(breakdown.free), pct(breakdown.free, window)],
|
|
100
|
+
];
|
|
101
|
+
modalContent.addChild(new ModalText("Context Usage", 0, 1));
|
|
102
|
+
modalContent.addChild(new TableComponent(tableData, {
|
|
103
|
+
headers: ["Section", "Tokens", "Percent"],
|
|
104
|
+
}));
|
|
105
|
+
// Progress bar
|
|
106
|
+
const progressBar = `[${"#".repeat(Math.floor((used / window) * 20))}${"-".repeat(20 - Math.floor((used / window) * 20))}] ${pct(used, window)}`;
|
|
107
|
+
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
108
|
+
modalContent.addChild(new ModalText(progressBar, 0, 1));
|
|
109
|
+
if (args.includes("--json")) {
|
|
110
|
+
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
111
|
+
modalContent.addChild(new ModalText("JSON Output:", 0, 1));
|
|
112
|
+
modalContent.addChild(new ModalText(JSON.stringify(breakdown, null, 2), 0, 1));
|
|
113
|
+
}
|
|
114
|
+
// Create and show modal
|
|
115
|
+
const modal = new Modal("Context Window Usage", modalContent, true, () => {
|
|
116
|
+
// Modal closed callback
|
|
117
|
+
editor.setText("");
|
|
118
|
+
tui.requestRender();
|
|
119
|
+
});
|
|
120
|
+
tui.showModal(modal);
|
|
121
|
+
return "continue";
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyB9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmDhE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Clipboard from "@crosscopy/clipboard";
|
|
2
|
+
import style from "../terminal/style.js";
|
|
3
|
+
import { Spacer, Text } from "../tui/index.js";
|
|
2
4
|
function extractLastAssistantText(messages) {
|
|
3
5
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
4
6
|
const msg = messages[i];
|
|
@@ -29,22 +31,29 @@ export function copyCommand(options) {
|
|
|
29
31
|
async getSubCommands() {
|
|
30
32
|
return [];
|
|
31
33
|
},
|
|
32
|
-
async
|
|
33
|
-
const { messageHistory
|
|
34
|
+
async handle(_args, { tui, container, editor, }) {
|
|
35
|
+
const { messageHistory } = options;
|
|
34
36
|
const history = messageHistory.get();
|
|
37
|
+
container.addChild(new Spacer(1));
|
|
35
38
|
const lastText = extractLastAssistantText(history);
|
|
36
39
|
if (!lastText) {
|
|
37
|
-
|
|
40
|
+
container.addChild(new Text(style.dim("No assistant response to copy."), 0, 1));
|
|
41
|
+
tui.requestRender();
|
|
42
|
+
editor.setText("");
|
|
38
43
|
return "continue";
|
|
39
44
|
}
|
|
40
45
|
try {
|
|
41
46
|
await Clipboard.setText(lastText);
|
|
42
|
-
|
|
47
|
+
container.addChild(new Text(style.dim("Copied last response to clipboard."), 0, 1));
|
|
48
|
+
tui.requestRender();
|
|
49
|
+
editor.setText("");
|
|
43
50
|
return "continue";
|
|
44
51
|
}
|
|
45
52
|
catch (err) {
|
|
46
53
|
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
-
|
|
54
|
+
container.addChild(new Text(style.dim(`Could not copy to clipboard: ${message}`), 0, 1));
|
|
55
|
+
tui.requestRender();
|
|
56
|
+
editor.setText("");
|
|
48
57
|
return "continue";
|
|
49
58
|
}
|
|
50
59
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,UAAU,cAAc,KAAG,WAkEtD,CAAC"}
|
|
@@ -1,54 +1,41 @@
|
|
|
1
|
-
import { existsSync, readFileSync
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export const editCommand = ({ terminal }) => {
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
5
|
+
export const editCommand = (_options) => {
|
|
7
6
|
return {
|
|
8
7
|
command: "/edit",
|
|
9
8
|
description: "Opens file in $EDITOR for editing. Usage: /edit [file-path]",
|
|
10
9
|
getSubCommands: () => Promise.resolve([]),
|
|
11
|
-
|
|
10
|
+
async handle(args, { tui, container, editor, }) {
|
|
12
11
|
let fileToEdit;
|
|
13
12
|
if (args.length > 0) {
|
|
14
13
|
// File path provided as argument
|
|
15
14
|
const filePath = args.join(" "); // Handle file paths with spaces
|
|
16
15
|
const resolvedPath = resolve(filePath);
|
|
17
16
|
if (!existsSync(resolvedPath)) {
|
|
18
|
-
|
|
17
|
+
container.addChild(new Text(style.red(`File not found: ${filePath}`), 0, 1));
|
|
18
|
+
tui.requestRender();
|
|
19
|
+
editor.setText("");
|
|
19
20
|
return "continue";
|
|
20
21
|
}
|
|
21
22
|
fileToEdit = filePath;
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
// No file path provided,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
const foundFiles = await glob(`**/*${input}*`, {
|
|
32
|
-
gitignore: true,
|
|
33
|
-
});
|
|
34
|
-
return foundFiles.map((file) => ({
|
|
35
|
-
name: file,
|
|
36
|
-
value: file,
|
|
37
|
-
}));
|
|
38
|
-
},
|
|
39
|
-
});
|
|
25
|
+
// No file path provided, show message for TUI
|
|
26
|
+
container.addChild(new Text(style.red("File path required for /edit in TUI mode"), 0, 1));
|
|
27
|
+
container.addChild(new Text(style.dim("Usage: /edit <file-path>"), 2, 0));
|
|
28
|
+
tui.requestRender();
|
|
29
|
+
editor.setText("");
|
|
30
|
+
return "continue";
|
|
40
31
|
}
|
|
41
32
|
const content = readFileSync(fileToEdit, { encoding: "utf8" });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
writeFileSync(fileToEdit, edit);
|
|
49
|
-
if (content !== edit) {
|
|
50
|
-
terminal.info(`File updated: ${fileToEdit}`);
|
|
51
|
-
}
|
|
33
|
+
// For TUI mode, we can't use the editor prompt, so we'll just show file info
|
|
34
|
+
container.addChild(new Text(`Editing file: ${style.blue(fileToEdit)}`, 0, 1));
|
|
35
|
+
container.addChild(new Text(`Content length: ${content.length} characters`, 2, 0));
|
|
36
|
+
container.addChild(new Text(style.dim("Note: Full file editing not available in TUI mode"), 3, 0));
|
|
37
|
+
tui.requestRender();
|
|
38
|
+
editor.setText("");
|
|
52
39
|
return "continue";
|
|
53
40
|
},
|
|
54
41
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const editPromptCommand: ({
|
|
2
|
+
export declare const editPromptCommand: ({ promptManager, promptHistory, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=edit-prompt-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,iBAAiB,GAAI,mCAG/B,cAAc,KAAG,WAuDnB,CAAC"}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { syncTry } from "@travisennis/stdlib/try";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import style from "../terminal/style.js";
|
|
3
|
+
import { Text } from "../tui/index.js";
|
|
4
|
+
export const editPromptCommand = ({ promptManager, promptHistory, }) => {
|
|
4
5
|
return {
|
|
5
6
|
command: "/edit-prompt",
|
|
6
7
|
description: "Edit the prompt. Accepts optional arguments as initial content.",
|
|
7
8
|
getSubCommands: () => Promise.resolve([]),
|
|
8
|
-
|
|
9
|
+
async handle(args, { tui, container, editor, }) {
|
|
9
10
|
try {
|
|
10
11
|
const prompt = syncTry(() => promptManager.get());
|
|
11
12
|
const initialContent = args.length > 0 ? args.join(" ") : prompt.unwrapOr("");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (updatedPrompt.trim().length === 0) {
|
|
19
|
-
throw new Error("Prompt was empty.");
|
|
13
|
+
// For TUI mode, we can't use the editor prompt, so we'll just set the prompt
|
|
14
|
+
if (initialContent.trim().length === 0) {
|
|
15
|
+
container.addChild(new Text(style.red("Prompt cannot be empty"), 0, 1));
|
|
16
|
+
tui.requestRender();
|
|
17
|
+
editor.setText("");
|
|
18
|
+
return "continue";
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
promptManager.set(updatedPrompt);
|
|
20
|
+
promptManager.set(initialContent);
|
|
23
21
|
// Add the edited prompt to history
|
|
24
|
-
promptHistory.push(
|
|
22
|
+
promptHistory.push(initialContent);
|
|
23
|
+
container.addChild(new Text(`Prompt set to: ${style.blue(initialContent)}`, 0, 1));
|
|
24
|
+
tui.requestRender();
|
|
25
|
+
editor.setText("");
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
27
|
-
|
|
28
|
+
container.addChild(new Text(style.red(`Error editing prompt: ${error.message}`), 1, 0));
|
|
29
|
+
tui.requestRender();
|
|
30
|
+
editor.setText("");
|
|
28
31
|
return "continue";
|
|
29
32
|
}
|
|
30
33
|
return "use";
|
|
@@ -4,10 +4,7 @@ export interface ExitCommandOptions {
|
|
|
4
4
|
isEmpty: () => boolean;
|
|
5
5
|
save: () => Promise<void>;
|
|
6
6
|
};
|
|
7
|
-
terminal: {
|
|
8
|
-
clear: () => void;
|
|
9
|
-
};
|
|
10
7
|
baseDir?: string | null;
|
|
11
8
|
}
|
|
12
|
-
export declare const exitCommand: ({ messageHistory,
|
|
9
|
+
export declare const exitCommand: ({ messageHistory, baseDir, }: ExitCommandOptions) => ReplCommand;
|
|
13
10
|
//# sourceMappingURL=exit-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,8BAGzB,kBAAkB,KAAG,WAiCvB,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { logger } from "../logger.js";
|
|
3
|
+
import { Text } from "../tui/index.js";
|
|
4
|
+
import { clearDirectory } from "../utils/filesystem/operations.js";
|
|
5
|
+
export const exitCommand = ({ messageHistory, baseDir, }) => {
|
|
4
6
|
return {
|
|
5
7
|
command: "/exit",
|
|
6
8
|
aliases: ["/bye", "/quit"],
|
|
7
9
|
description: "Exits and saves the chat history.",
|
|
8
10
|
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
|
|
10
|
-
terminal.clear();
|
|
11
|
+
async handle(_args, { tui, container, editor, }) {
|
|
11
12
|
if (!messageHistory.isEmpty()) {
|
|
12
13
|
await messageHistory.save();
|
|
13
14
|
}
|
|
@@ -18,8 +19,11 @@ export const exitCommand = ({ messageHistory, terminal, baseDir, }) => {
|
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
20
21
|
// Log error but don't block exit
|
|
21
|
-
|
|
22
|
+
logger.error(error, "Failed to clear .tmp directory:");
|
|
22
23
|
}
|
|
24
|
+
container.addChild(new Text("Exiting...", 0, 1));
|
|
25
|
+
tui.requestRender();
|
|
26
|
+
editor.setText("");
|
|
23
27
|
return "break";
|
|
24
28
|
},
|
|
25
29
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const filesCommand: ({
|
|
2
|
+
export declare const filesCommand: ({ promptManager, modelManager, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=files-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,kCAG1B,cAAc,KAAG,WA4GnB,CAAC"}
|