@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,30 @@
|
|
|
1
|
+
import style from "../../terminal/style.js";
|
|
2
|
+
import { getPackageVersion } from "../../version.js";
|
|
3
|
+
export class Welcome {
|
|
4
|
+
render(_width) {
|
|
5
|
+
const version = getPackageVersion();
|
|
6
|
+
const result = [];
|
|
7
|
+
result.push(style.magenta(this.getLogo()));
|
|
8
|
+
result.push("");
|
|
9
|
+
result.push(style.magenta("Greetings! I am acai."));
|
|
10
|
+
result.push(style.gray(` Version ${version}`));
|
|
11
|
+
result.push("");
|
|
12
|
+
result.push(style.white(` Type ${style.cyan("/help")} to see available commands.`));
|
|
13
|
+
result.push(style.white(" You can ask acai to explain code, fix issues, or perform tasks."));
|
|
14
|
+
result.push(style.white(` Example: "${style.italic("Please analyze this codebase and explain its structure.")}"`));
|
|
15
|
+
result.push(style.dim(" Use Ctrl+C to interrupt acai and exit."));
|
|
16
|
+
result.push("");
|
|
17
|
+
result.push(style.yellow(`The current working directory is ${process.cwd()}`));
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
getLogo() {
|
|
21
|
+
return `
|
|
22
|
+
█████╗ ██████╗ █████╗ ██╗
|
|
23
|
+
██╔══██╗██╔════╝██╔══██╗██║
|
|
24
|
+
███████║██║ ███████║██║
|
|
25
|
+
██╔══██║██║ ██╔══██║██║
|
|
26
|
+
██║ ██║╚██████╗██║ ██║██║
|
|
27
|
+
╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { type AutocompleteItem, CombinedAutocompleteProvider, type SlashCommand, } from "./autocomplete.ts";
|
|
2
|
+
export { BoxComponent } from "./components/box.ts";
|
|
3
|
+
export { Editor } from "./components/editor.ts";
|
|
4
|
+
export { HeaderComponent } from "./components/header.ts";
|
|
5
|
+
export { Input } from "./components/input.ts";
|
|
6
|
+
export { Loader } from "./components/loader.ts";
|
|
7
|
+
export { Markdown } from "./components/markdown.ts";
|
|
8
|
+
export { Modal, ModalText } from "./components/modal.ts";
|
|
9
|
+
export { ProgressBarComponent } from "./components/progress-bar.ts";
|
|
10
|
+
export { SelectList } from "./components/select-list.ts";
|
|
11
|
+
export { Spacer } from "./components/spacer.ts";
|
|
12
|
+
export { TableComponent } from "./components/table.ts";
|
|
13
|
+
export { Text } from "./components/text.ts";
|
|
14
|
+
export { UserMessageComponent } from "./components/user-message.ts";
|
|
15
|
+
export { ProcessTerminal } from "./terminal.ts";
|
|
16
|
+
export { type Component, Container, TUI } from "./tui.ts";
|
|
17
|
+
export { visibleWidth } from "./utils.ts";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tui/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,gBAAgB,EACrB,4BAA4B,EAC5B,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Core TUI interfaces and classes
|
|
2
|
+
// Autocomplete support
|
|
3
|
+
export { CombinedAutocompleteProvider, } from "./autocomplete.js";
|
|
4
|
+
// Components
|
|
5
|
+
export { BoxComponent } from "./components/box.js";
|
|
6
|
+
export { Editor } from "./components/editor.js";
|
|
7
|
+
export { HeaderComponent } from "./components/header.js";
|
|
8
|
+
export { Input } from "./components/input.js";
|
|
9
|
+
export { Loader } from "./components/loader.js";
|
|
10
|
+
export { Markdown } from "./components/markdown.js";
|
|
11
|
+
export { Modal, ModalText } from "./components/modal.js";
|
|
12
|
+
export { ProgressBarComponent } from "./components/progress-bar.js";
|
|
13
|
+
export { SelectList } from "./components/select-list.js";
|
|
14
|
+
export { Spacer } from "./components/spacer.js";
|
|
15
|
+
export { TableComponent } from "./components/table.js";
|
|
16
|
+
export { Text } from "./components/text.js";
|
|
17
|
+
export { UserMessageComponent } from "./components/user-message.js";
|
|
18
|
+
// Terminal interface and implementations
|
|
19
|
+
export { ProcessTerminal } from "./terminal.js";
|
|
20
|
+
export { Container, TUI } from "./tui.js";
|
|
21
|
+
// Utilities
|
|
22
|
+
export { visibleWidth } from "./utils.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal terminal interface for TUI
|
|
3
|
+
*/
|
|
4
|
+
export interface Terminal {
|
|
5
|
+
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
6
|
+
stop(): void;
|
|
7
|
+
write(data: string): void;
|
|
8
|
+
get columns(): number;
|
|
9
|
+
get rows(): number;
|
|
10
|
+
moveBy(lines: number): void;
|
|
11
|
+
hideCursor(): void;
|
|
12
|
+
showCursor(): void;
|
|
13
|
+
clearLine(): void;
|
|
14
|
+
clearFromCursor(): void;
|
|
15
|
+
clearScreen(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Real terminal using process.stdin/stdout
|
|
19
|
+
*/
|
|
20
|
+
export declare class ProcessTerminal implements Terminal {
|
|
21
|
+
private wasRaw;
|
|
22
|
+
private sigintHandler?;
|
|
23
|
+
private inputHandler?;
|
|
24
|
+
private resizeHandler?;
|
|
25
|
+
private stopped;
|
|
26
|
+
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
27
|
+
stop(): void;
|
|
28
|
+
write(data: string): void;
|
|
29
|
+
get columns(): number;
|
|
30
|
+
get rows(): number;
|
|
31
|
+
moveBy(lines: number): void;
|
|
32
|
+
hideCursor(): void;
|
|
33
|
+
showCursor(): void;
|
|
34
|
+
clearLine(): void;
|
|
35
|
+
clearFromCursor(): void;
|
|
36
|
+
clearScreen(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../source/tui/terminal.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IAEvB,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAGnE,IAAI,IAAI,IAAI,CAAC;IAGb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,IAAI,OAAO,IAAI,MAAM,CAAC;IACtB,IAAI,IAAI,IAAI,MAAM,CAAC;IAGnB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,UAAU,IAAI,IAAI,CAAC;IACnB,UAAU,IAAI,IAAI,CAAC;IAGnB,SAAS,IAAI,IAAI,CAAC;IAClB,eAAe,IAAI,IAAI,CAAC;IACxB,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,YAAY,CAAC,CAAyB;IAC9C,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAiClE,IAAI,IAAI,IAAI;IA6BZ,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIzB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAW3B,UAAU,IAAI,IAAI;IAIlB,UAAU,IAAI,IAAI;IAIlB,SAAS,IAAI,IAAI;IAIjB,eAAe,IAAI,IAAI;IAIvB,WAAW,IAAI,IAAI;CAGpB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real terminal using process.stdin/stdout
|
|
3
|
+
*/
|
|
4
|
+
export class ProcessTerminal {
|
|
5
|
+
wasRaw = false;
|
|
6
|
+
sigintHandler;
|
|
7
|
+
inputHandler;
|
|
8
|
+
resizeHandler;
|
|
9
|
+
stopped = false;
|
|
10
|
+
start(onInput, onResize) {
|
|
11
|
+
this.inputHandler = onInput;
|
|
12
|
+
this.resizeHandler = onResize;
|
|
13
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
14
|
+
throw new Error("Terminal requires TTY environment");
|
|
15
|
+
}
|
|
16
|
+
// Save previous state and enable raw mode
|
|
17
|
+
this.wasRaw = process.stdin.isRaw ?? false;
|
|
18
|
+
if (process.stdin.setRawMode) {
|
|
19
|
+
process.stdin.setRawMode(true);
|
|
20
|
+
}
|
|
21
|
+
process.stdin.setEncoding("utf8");
|
|
22
|
+
process.stdin.resume();
|
|
23
|
+
// Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~
|
|
24
|
+
process.stdout.write("\x1b[?2004h");
|
|
25
|
+
// Set up event handlers with proper binding and type conversion
|
|
26
|
+
process.stdin.on("data", (data) => {
|
|
27
|
+
this.inputHandler?.(typeof data === "string" ? data : data.toString("utf8"));
|
|
28
|
+
});
|
|
29
|
+
process.stdout.on("resize", () => {
|
|
30
|
+
this.resizeHandler?.();
|
|
31
|
+
});
|
|
32
|
+
this.sigintHandler = () => this.stop();
|
|
33
|
+
process.on("SIGINT", this.sigintHandler);
|
|
34
|
+
}
|
|
35
|
+
stop() {
|
|
36
|
+
if (this.stopped)
|
|
37
|
+
return;
|
|
38
|
+
this.stopped = true;
|
|
39
|
+
if (this.sigintHandler) {
|
|
40
|
+
process.off("SIGINT", this.sigintHandler);
|
|
41
|
+
}
|
|
42
|
+
// Disable bracketed paste mode
|
|
43
|
+
process.stdout.write("\x1b[?2004l");
|
|
44
|
+
// Remove event handlers
|
|
45
|
+
if (this.inputHandler) {
|
|
46
|
+
process.stdin.removeListener("data", this.inputHandler);
|
|
47
|
+
this.inputHandler = undefined;
|
|
48
|
+
}
|
|
49
|
+
if (this.resizeHandler) {
|
|
50
|
+
process.stdout.removeListener("resize", this.resizeHandler);
|
|
51
|
+
this.resizeHandler = undefined;
|
|
52
|
+
}
|
|
53
|
+
process.stdin.pause();
|
|
54
|
+
// Restore raw mode state
|
|
55
|
+
if (process.stdin.setRawMode) {
|
|
56
|
+
process.stdin.setRawMode(this.wasRaw);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
write(data) {
|
|
60
|
+
process.stdout.write(data);
|
|
61
|
+
}
|
|
62
|
+
get columns() {
|
|
63
|
+
return process.stdout.columns || 80;
|
|
64
|
+
}
|
|
65
|
+
get rows() {
|
|
66
|
+
return process.stdout.rows || 24;
|
|
67
|
+
}
|
|
68
|
+
moveBy(lines) {
|
|
69
|
+
if (lines > 0) {
|
|
70
|
+
// Move down
|
|
71
|
+
process.stdout.write(`\x1b[${lines}B`);
|
|
72
|
+
}
|
|
73
|
+
else if (lines < 0) {
|
|
74
|
+
// Move up
|
|
75
|
+
process.stdout.write(`\x1b[${-lines}A`);
|
|
76
|
+
}
|
|
77
|
+
// lines === 0: no movement
|
|
78
|
+
}
|
|
79
|
+
hideCursor() {
|
|
80
|
+
process.stdout.write("\x1b[?25l");
|
|
81
|
+
}
|
|
82
|
+
showCursor() {
|
|
83
|
+
process.stdout.write("\x1b[?25h");
|
|
84
|
+
}
|
|
85
|
+
clearLine() {
|
|
86
|
+
process.stdout.write("\x1b[K");
|
|
87
|
+
}
|
|
88
|
+
clearFromCursor() {
|
|
89
|
+
process.stdout.write("\x1b[J");
|
|
90
|
+
}
|
|
91
|
+
clearScreen() {
|
|
92
|
+
process.stdout.write("\x1b[2J\x1b[H"); // Clear screen and move to home (1,1)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TUI implementation with differential rendering
|
|
3
|
+
*/
|
|
4
|
+
import type { Modal } from "./components/modal.ts";
|
|
5
|
+
import type { Terminal } from "./terminal.ts";
|
|
6
|
+
import { visibleWidth } from "./utils.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Component interface - all components must implement this
|
|
9
|
+
*/
|
|
10
|
+
export interface Component {
|
|
11
|
+
/**
|
|
12
|
+
* Render the component to lines for the given viewport width
|
|
13
|
+
* @param width - Current viewport width
|
|
14
|
+
* @returns Array of strings, each representing a line
|
|
15
|
+
*/
|
|
16
|
+
render(width: number): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional handler for keyboard input when component has focus
|
|
19
|
+
*/
|
|
20
|
+
handleInput?(data: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Optional method to get cursor position relative to component
|
|
23
|
+
* Returns [row, col] where row is 0-indexed within component
|
|
24
|
+
* and col is 0-indexed column position
|
|
25
|
+
*/
|
|
26
|
+
getCursorPosition?(): [number, number] | null;
|
|
27
|
+
}
|
|
28
|
+
export { visibleWidth };
|
|
29
|
+
/**
|
|
30
|
+
* Container - a component that contains other components
|
|
31
|
+
*/
|
|
32
|
+
export declare class Container implements Component {
|
|
33
|
+
children: Component[];
|
|
34
|
+
addChild(component: Component): void;
|
|
35
|
+
removeChild(component: Component): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
render(width: number): string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
41
|
+
*/
|
|
42
|
+
export declare class TUI extends Container {
|
|
43
|
+
private terminal;
|
|
44
|
+
private focusedComponent;
|
|
45
|
+
private renderRequested;
|
|
46
|
+
private isRendering;
|
|
47
|
+
private renderAgain;
|
|
48
|
+
private activeModal;
|
|
49
|
+
constructor(terminal: Terminal);
|
|
50
|
+
setFocus(component: Component | null): void;
|
|
51
|
+
start(): void;
|
|
52
|
+
stop(): void;
|
|
53
|
+
requestRender(): void;
|
|
54
|
+
private handleInput;
|
|
55
|
+
private doRender;
|
|
56
|
+
/**
|
|
57
|
+
* Show a modal dialog
|
|
58
|
+
*/
|
|
59
|
+
showModal(modal: Modal): void;
|
|
60
|
+
/**
|
|
61
|
+
* Hide the active modal
|
|
62
|
+
*/
|
|
63
|
+
hideModal(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a modal is currently active
|
|
66
|
+
*/
|
|
67
|
+
isModalActive(): boolean;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=tui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../source/tui/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC/C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,qBAAa,SAAU,YAAW,SAAS;IACzC,QAAQ,EAAE,SAAS,EAAE,CAAM;IAE3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIpC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAOvC,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAOhC;AAED;;GAEG;AAGH,qBAAa,GAAI,SAAQ,SAAS;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAsB;gBAE7B,QAAQ,EAAE,QAAQ;IAK9B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAI3C,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAKZ,aAAa,IAAI,IAAI;IAarB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,QAAQ;IAgGhB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
|
package/dist/tui/tui.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TUI implementation with differential rendering
|
|
3
|
+
*/
|
|
4
|
+
import { getTerminalSize } from "../terminal/formatting.js";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { visibleWidth } from "./utils.js";
|
|
7
|
+
export { visibleWidth };
|
|
8
|
+
/**
|
|
9
|
+
* Container - a component that contains other components
|
|
10
|
+
*/
|
|
11
|
+
export class Container {
|
|
12
|
+
children = [];
|
|
13
|
+
addChild(component) {
|
|
14
|
+
this.children.push(component);
|
|
15
|
+
}
|
|
16
|
+
removeChild(component) {
|
|
17
|
+
const index = this.children.indexOf(component);
|
|
18
|
+
if (index !== -1) {
|
|
19
|
+
this.children.splice(index, 1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.children = [];
|
|
24
|
+
}
|
|
25
|
+
render(width) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
for (const child of this.children) {
|
|
28
|
+
lines.push(...child.render(width));
|
|
29
|
+
}
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
35
|
+
*/
|
|
36
|
+
// biome-ignore lint/style/useNamingConvention: override
|
|
37
|
+
export class TUI extends Container {
|
|
38
|
+
terminal;
|
|
39
|
+
focusedComponent = null;
|
|
40
|
+
renderRequested = false;
|
|
41
|
+
isRendering = false;
|
|
42
|
+
renderAgain = false;
|
|
43
|
+
activeModal = null;
|
|
44
|
+
constructor(terminal) {
|
|
45
|
+
super();
|
|
46
|
+
this.terminal = terminal;
|
|
47
|
+
}
|
|
48
|
+
setFocus(component) {
|
|
49
|
+
this.focusedComponent = component;
|
|
50
|
+
}
|
|
51
|
+
start() {
|
|
52
|
+
this.terminal.start((data) => this.handleInput(data), () => this.requestRender());
|
|
53
|
+
this.terminal.hideCursor();
|
|
54
|
+
this.requestRender();
|
|
55
|
+
}
|
|
56
|
+
stop() {
|
|
57
|
+
this.terminal.showCursor();
|
|
58
|
+
this.terminal.stop();
|
|
59
|
+
}
|
|
60
|
+
requestRender() {
|
|
61
|
+
if (this.isRendering) {
|
|
62
|
+
this.renderAgain = true;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.renderRequested)
|
|
66
|
+
return;
|
|
67
|
+
this.renderRequested = true;
|
|
68
|
+
setImmediate(() => {
|
|
69
|
+
this.renderRequested = false;
|
|
70
|
+
this.doRender();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
handleInput(data) {
|
|
74
|
+
// Handle Ctrl+C globally - exit the application
|
|
75
|
+
if (data.charCodeAt(0) === 3) {
|
|
76
|
+
console.info("\nCtrl+C pressed - exiting...");
|
|
77
|
+
this.stop();
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
// Handle Escape key to close modal if one is active
|
|
81
|
+
if (data === "\x1b" && this.activeModal) {
|
|
82
|
+
this.hideModal();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Pass input to active modal first, then focused component
|
|
86
|
+
if (this.activeModal?.handleInput) {
|
|
87
|
+
this.activeModal.handleInput(data);
|
|
88
|
+
this.requestRender();
|
|
89
|
+
}
|
|
90
|
+
else if (this.focusedComponent?.handleInput) {
|
|
91
|
+
this.focusedComponent.handleInput(data);
|
|
92
|
+
this.requestRender();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
doRender() {
|
|
96
|
+
if (this.isRendering) {
|
|
97
|
+
this.renderAgain = true;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.isRendering = true;
|
|
101
|
+
try {
|
|
102
|
+
const width = this.terminal.columns;
|
|
103
|
+
// Render all components to get new lines
|
|
104
|
+
const newLines = this.render(width);
|
|
105
|
+
// Always do full re-render for simplicity and reliability
|
|
106
|
+
// This ensures that previous content is properly cleared
|
|
107
|
+
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
|
108
|
+
buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
|
|
109
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
110
|
+
if (i > 0)
|
|
111
|
+
buffer += "\r\n";
|
|
112
|
+
buffer += newLines[i];
|
|
113
|
+
}
|
|
114
|
+
// Render modal on top if active
|
|
115
|
+
if (this.activeModal) {
|
|
116
|
+
const modalLines = this.activeModal.render(width);
|
|
117
|
+
// Render backdrop first if modal has backdrop
|
|
118
|
+
if (this.activeModal.backdrop) {
|
|
119
|
+
const backdropLine = style.bgRgb(0, 0, 0)(" ".repeat(width));
|
|
120
|
+
const { columns } = getTerminalSize(); // 24
|
|
121
|
+
for (let i = 0; i < columns; i++) {
|
|
122
|
+
// Cover entire terminal
|
|
123
|
+
buffer += `\x1b[${i + 1};1H`;
|
|
124
|
+
buffer += backdropLine;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Render modal content
|
|
128
|
+
for (let i = 0; i < modalLines.length; i++) {
|
|
129
|
+
if (modalLines[i]) {
|
|
130
|
+
// Position cursor and overwrite existing content
|
|
131
|
+
buffer += `\x1b[${i + 1};1H`;
|
|
132
|
+
buffer += modalLines[i];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
buffer += "\x1b[?2026l"; // End synchronized output
|
|
137
|
+
this.terminal.write(buffer);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
this.isRendering = false;
|
|
141
|
+
if (this.renderAgain) {
|
|
142
|
+
this.renderAgain = false;
|
|
143
|
+
this.requestRender();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// private positionCursor(
|
|
148
|
+
// componentCursorPos: [number, number] | null,
|
|
149
|
+
// ): void {
|
|
150
|
+
// if (!componentCursorPos) {
|
|
151
|
+
// // No cursor position from component, hide cursor
|
|
152
|
+
// this.terminal.hideCursor();
|
|
153
|
+
// return;
|
|
154
|
+
// }
|
|
155
|
+
// const [cursorRow, cursorCol] = componentCursorPos;
|
|
156
|
+
//
|
|
157
|
+
// // Calculate absolute cursor position in the terminal
|
|
158
|
+
// // We need to find which line in newLines corresponds to the component's cursor row
|
|
159
|
+
// // and then position the cursor at that line and column
|
|
160
|
+
//
|
|
161
|
+
// // Find the line offset for the focused component
|
|
162
|
+
// let componentStartLine = 0;
|
|
163
|
+
// if (this.focusedComponent) {
|
|
164
|
+
// // Find the line where this component starts by summing heights of previous components
|
|
165
|
+
// for (const child of this.children) {
|
|
166
|
+
// if (child === this.focusedComponent) {
|
|
167
|
+
// break;
|
|
168
|
+
// }
|
|
169
|
+
// // Use the already-rendered lines to calculate height, not re-render
|
|
170
|
+
// const childLines = child.render(this.terminal.columns);
|
|
171
|
+
// componentStartLine += childLines.length;
|
|
172
|
+
// }
|
|
173
|
+
// }
|
|
174
|
+
//
|
|
175
|
+
// const absoluteRow = componentStartLine + cursorRow;
|
|
176
|
+
// const absoluteCol = cursorCol;
|
|
177
|
+
//
|
|
178
|
+
// // Position cursor using absolute positioning
|
|
179
|
+
// // Move to home position first, then move down to row, then right to column
|
|
180
|
+
// // Note: terminal rows/columns are 1-indexed, so we add 1
|
|
181
|
+
// this.terminal.write(`\x1b[H\x1b[${absoluteRow + 1}B\x1b[${absoluteCol + 1}G`);
|
|
182
|
+
// this.terminal.showCursor();
|
|
183
|
+
// }
|
|
184
|
+
/**
|
|
185
|
+
* Show a modal dialog
|
|
186
|
+
*/
|
|
187
|
+
showModal(modal) {
|
|
188
|
+
this.activeModal = modal;
|
|
189
|
+
this.requestRender();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Hide the active modal
|
|
193
|
+
*/
|
|
194
|
+
hideModal() {
|
|
195
|
+
this.activeModal = null;
|
|
196
|
+
this.requestRender();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if a modal is currently active
|
|
200
|
+
*/
|
|
201
|
+
isModalActive() {
|
|
202
|
+
return this.activeModal !== null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the visible width of a string in terminal columns.
|
|
3
|
+
* This correctly handles:
|
|
4
|
+
* - ANSI escape codes (ignored)
|
|
5
|
+
* - Emojis and wide characters (counted as 2 columns)
|
|
6
|
+
* - Combining characters (counted correctly)
|
|
7
|
+
* - Tabs (replaced with 3 spaces for consistent width)
|
|
8
|
+
*/
|
|
9
|
+
export declare function visibleWidth(str: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Truncate text to fit within a maximum visible width, preserving ANSI codes.
|
|
12
|
+
* Adds ellipsis if truncation occurs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function truncateToWidth(text: string, maxWidth: number, ellipsis?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Apply background color to a line, padding to full width.
|
|
17
|
+
*
|
|
18
|
+
* @param line - Line of text (may contain ANSI codes)
|
|
19
|
+
* @param width - Total width to pad to
|
|
20
|
+
* @param bgFn - Background color function
|
|
21
|
+
* @returns Line with background applied and padded to width
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AA4BD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAQ,GACf,MAAM,CA+DR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,CASR"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import stringWidth from "../terminal/string-width.js";
|
|
2
|
+
// Grapheme segmenter for proper Unicode iteration (handles emojis, etc.)
|
|
3
|
+
const segmenter = new Intl.Segmenter();
|
|
4
|
+
/**
|
|
5
|
+
* Calculate the visible width of a string in terminal columns.
|
|
6
|
+
* This correctly handles:
|
|
7
|
+
* - ANSI escape codes (ignored)
|
|
8
|
+
* - Emojis and wide characters (counted as 2 columns)
|
|
9
|
+
* - Combining characters (counted correctly)
|
|
10
|
+
* - Tabs (replaced with 3 spaces for consistent width)
|
|
11
|
+
*/
|
|
12
|
+
export function visibleWidth(str) {
|
|
13
|
+
// Replace tabs with 3 spaces before measuring
|
|
14
|
+
const normalized = str.replace(/\t/g, " ");
|
|
15
|
+
return stringWidth(normalized);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extract ANSI escape sequences from a string at the given position.
|
|
19
|
+
*/
|
|
20
|
+
function extractAnsiCode(str, pos) {
|
|
21
|
+
if (pos >= str.length || str[pos] !== "\x1b" || str[pos + 1] !== "[") {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
let j = pos + 2;
|
|
25
|
+
while (j < str.length && str[j] && !/[mGKHJ]/.test(str[j])) {
|
|
26
|
+
j++;
|
|
27
|
+
}
|
|
28
|
+
if (j < str.length) {
|
|
29
|
+
return {
|
|
30
|
+
code: str.substring(pos, j + 1),
|
|
31
|
+
length: j + 1 - pos,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Truncate text to fit within a maximum visible width, preserving ANSI codes.
|
|
38
|
+
* Adds ellipsis if truncation occurs.
|
|
39
|
+
*/
|
|
40
|
+
export function truncateToWidth(text, maxWidth, ellipsis = "...") {
|
|
41
|
+
const textVisibleWidth = visibleWidth(text);
|
|
42
|
+
if (textVisibleWidth <= maxWidth) {
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
45
|
+
const ellipsisWidth = visibleWidth(ellipsis);
|
|
46
|
+
const targetWidth = maxWidth - ellipsisWidth;
|
|
47
|
+
if (targetWidth <= 0) {
|
|
48
|
+
return ellipsis.substring(0, maxWidth);
|
|
49
|
+
}
|
|
50
|
+
// Separate ANSI codes from visible content using grapheme segmentation
|
|
51
|
+
let i = 0;
|
|
52
|
+
const segments = [];
|
|
53
|
+
while (i < text.length) {
|
|
54
|
+
const ansiResult = extractAnsiCode(text, i);
|
|
55
|
+
if (ansiResult) {
|
|
56
|
+
segments.push({ type: "ansi", value: ansiResult.code });
|
|
57
|
+
i += ansiResult.length;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Find the next ANSI code or end of string
|
|
61
|
+
let end = i;
|
|
62
|
+
while (end < text.length) {
|
|
63
|
+
const nextAnsi = extractAnsiCode(text, end);
|
|
64
|
+
if (nextAnsi)
|
|
65
|
+
break;
|
|
66
|
+
end++;
|
|
67
|
+
}
|
|
68
|
+
// Segment this non-ANSI portion into graphemes
|
|
69
|
+
const textPortion = text.slice(i, end);
|
|
70
|
+
for (const seg of segmenter.segment(textPortion)) {
|
|
71
|
+
segments.push({ type: "grapheme", value: seg.segment });
|
|
72
|
+
}
|
|
73
|
+
i = end;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Build truncated string from segments
|
|
77
|
+
let result = "";
|
|
78
|
+
let currentWidth = 0;
|
|
79
|
+
for (const seg of segments) {
|
|
80
|
+
if (seg.type === "ansi") {
|
|
81
|
+
result += seg.value;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const grapheme = seg.value;
|
|
85
|
+
const graphemeWidth = visibleWidth(grapheme);
|
|
86
|
+
if (currentWidth + graphemeWidth > targetWidth) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
result += grapheme;
|
|
90
|
+
currentWidth += graphemeWidth;
|
|
91
|
+
}
|
|
92
|
+
// Add reset code before ellipsis to prevent styling leaking into it
|
|
93
|
+
return `${result}\x1b[0m${ellipsis}`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Apply background color to a line, padding to full width.
|
|
97
|
+
*
|
|
98
|
+
* @param line - Line of text (may contain ANSI codes)
|
|
99
|
+
* @param width - Total width to pad to
|
|
100
|
+
* @param bgFn - Background color function
|
|
101
|
+
* @returns Line with background applied and padded to width
|
|
102
|
+
*/
|
|
103
|
+
export function applyBackgroundToLine(line, width, bgFn) {
|
|
104
|
+
// Calculate padding needed
|
|
105
|
+
const visibleLen = visibleWidth(line);
|
|
106
|
+
const paddingNeeded = Math.max(0, width - visibleLen);
|
|
107
|
+
const padding = " ".repeat(paddingNeeded);
|
|
108
|
+
// Apply background to content + padding
|
|
109
|
+
const withPadding = line + padding;
|
|
110
|
+
return bgFn(withPadding);
|
|
111
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function validatePaths(command: string, allowedDirs: string[], cwd: string): {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const resolveCwd: (cwdInput: string | null | undefined, workingDir: string, allowedDirs?: string[]) => string;
|
|
6
|
+
export declare const isMutatingCommand: (rawCommand: string) => boolean;
|
|
7
|
+
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../source/utils/bash.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,EACrB,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CA0EtC;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,YAAY,MAAM,EAClB,cAAc,MAAM,EAAE,KACrB,MAkEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,OAmHtD,CAAC"}
|