@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,12 @@
|
|
|
1
|
+
import type { AgentState } from "../../agent/index.ts";
|
|
2
|
+
import { Container } from "../tui.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Footer component that shows pwd, token stats, and context usage
|
|
5
|
+
*/
|
|
6
|
+
export declare class FooterComponent extends Container {
|
|
7
|
+
private state;
|
|
8
|
+
constructor(state: AgentState);
|
|
9
|
+
updateState(state: AgentState): void;
|
|
10
|
+
render(width: number): string[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../source/tui/components/footer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,OAAO,CAAC,KAAK,CAAa;gBAEd,KAAK,EAAE,UAAU;IAK7B,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAI3B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CA+IzC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { formatDuration, formatNumber } from "../../formatting.js";
|
|
2
|
+
import { hr } from "../../terminal/index.js";
|
|
3
|
+
import style from "../../terminal/style.js";
|
|
4
|
+
import { Container } from "../tui.js";
|
|
5
|
+
/**
|
|
6
|
+
* Footer component that shows pwd, token stats, and context usage
|
|
7
|
+
*/
|
|
8
|
+
export class FooterComponent extends Container {
|
|
9
|
+
state;
|
|
10
|
+
constructor(state) {
|
|
11
|
+
super();
|
|
12
|
+
this.state = state;
|
|
13
|
+
}
|
|
14
|
+
updateState(state) {
|
|
15
|
+
this.state = state;
|
|
16
|
+
}
|
|
17
|
+
render(width) {
|
|
18
|
+
const results = [];
|
|
19
|
+
if (this.state.steps.length === 0) {
|
|
20
|
+
return results;
|
|
21
|
+
}
|
|
22
|
+
results.push(hr(width));
|
|
23
|
+
// Create a more visual representation of steps/tool usage
|
|
24
|
+
results.push(...displayToolUse(this.state));
|
|
25
|
+
let status = `Steps: ${this.state.steps.length} - `;
|
|
26
|
+
// Calculate total tool calls across all steps
|
|
27
|
+
const totalToolCalls = this.state.steps.reduce((total, step) => total + step.toolCalls.length, 0);
|
|
28
|
+
status += `Tools call: ${totalToolCalls} - `;
|
|
29
|
+
// Show time spend on this prompt
|
|
30
|
+
status += `Time: ${formatDuration(this.state.timestamps.stop - this.state.timestamps.start)} - `;
|
|
31
|
+
const total = this.state.totalUsage;
|
|
32
|
+
const inputTokens = total.inputTokens;
|
|
33
|
+
const outputTokens = total.outputTokens;
|
|
34
|
+
const cachedInputTokens = total.cachedInputTokens;
|
|
35
|
+
const tokenSummary = `Tokens: ↑ ${formatNumber(inputTokens)} (${formatNumber(cachedInputTokens)}) ↓ ${formatNumber(outputTokens)} - `;
|
|
36
|
+
status += tokenSummary;
|
|
37
|
+
const inputCost = this.state.modelConfig.costPerInputToken * inputTokens;
|
|
38
|
+
const outputCost = this.state.modelConfig.costPerOutputToken * outputTokens;
|
|
39
|
+
status += `Cost: $${(inputCost + outputCost).toFixed(2)}`;
|
|
40
|
+
results.push(style.dim(status));
|
|
41
|
+
return results;
|
|
42
|
+
// // Calculate cumulative usage from all assistant messages
|
|
43
|
+
// let totalInput = 0;
|
|
44
|
+
// let totalOutput = 0;
|
|
45
|
+
// let totalCacheRead = 0;
|
|
46
|
+
// let totalCacheWrite = 0;
|
|
47
|
+
// let totalCost = 0;
|
|
48
|
+
// for (const message of this.state.messages) {
|
|
49
|
+
// if (message.role === "assistant") {
|
|
50
|
+
// const assistantMsg = message as AssistantMessage;
|
|
51
|
+
// totalInput += assistantMsg.usage.input;
|
|
52
|
+
// totalOutput += assistantMsg.usage.output;
|
|
53
|
+
// totalCacheRead += assistantMsg.usage.cacheRead;
|
|
54
|
+
// totalCacheWrite += assistantMsg.usage.cacheWrite;
|
|
55
|
+
// totalCost += assistantMsg.usage.cost.total;
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
// // Get last assistant message for context percentage calculation (skip aborted messages)
|
|
59
|
+
// const lastAssistantMessage = this.state.messages
|
|
60
|
+
// .slice()
|
|
61
|
+
// .reverse()
|
|
62
|
+
// .find((m) => m.role === "assistant" && m.stopReason !== "aborted") as
|
|
63
|
+
// | AssistantMessage
|
|
64
|
+
// | undefined;
|
|
65
|
+
// // Calculate context percentage from last message (input + output + cacheRead + cacheWrite)
|
|
66
|
+
// const contextTokens = lastAssistantMessage
|
|
67
|
+
// ? lastAssistantMessage.usage.input +
|
|
68
|
+
// lastAssistantMessage.usage.output +
|
|
69
|
+
// lastAssistantMessage.usage.cacheRead +
|
|
70
|
+
// lastAssistantMessage.usage.cacheWrite
|
|
71
|
+
// : 0;
|
|
72
|
+
// const contextWindow = this.state.model.contextWindow;
|
|
73
|
+
// const contextPercent =
|
|
74
|
+
// contextWindow > 0
|
|
75
|
+
// ? ((contextTokens / contextWindow) * 100).toFixed(1)
|
|
76
|
+
// : "0.0";
|
|
77
|
+
// // Format token counts (similar to web-ui)
|
|
78
|
+
// const formatTokens = (count: number): string => {
|
|
79
|
+
// if (count < 1000) return count.toString();
|
|
80
|
+
// if (count < 10000) return (count / 1000).toFixed(1) + "k";
|
|
81
|
+
// return Math.round(count / 1000) + "k";
|
|
82
|
+
// };
|
|
83
|
+
// // Replace home directory with ~
|
|
84
|
+
// let pwd = process.cwd();
|
|
85
|
+
// const home = process.env.HOME || process.env.USERPROFILE;
|
|
86
|
+
// if (home && pwd.startsWith(home)) {
|
|
87
|
+
// pwd = "~" + pwd.slice(home.length);
|
|
88
|
+
// }
|
|
89
|
+
// // Truncate path if too long to fit width
|
|
90
|
+
// const maxPathLength = Math.max(20, width - 10); // Leave some margin
|
|
91
|
+
// if (pwd.length > maxPathLength) {
|
|
92
|
+
// const start = pwd.slice(0, Math.floor(maxPathLength / 2) - 2);
|
|
93
|
+
// const end = pwd.slice(-(Math.floor(maxPathLength / 2) - 1));
|
|
94
|
+
// pwd = `${start}...${end}`;
|
|
95
|
+
// }
|
|
96
|
+
// // Build stats line
|
|
97
|
+
// const statsParts = [];
|
|
98
|
+
// if (totalInput) statsParts.push(`↑${formatTokens(totalInput)}`);
|
|
99
|
+
// if (totalOutput) statsParts.push(`↓${formatTokens(totalOutput)}`);
|
|
100
|
+
// if (totalCacheRead) statsParts.push(`R${formatTokens(totalCacheRead)}`);
|
|
101
|
+
// if (totalCacheWrite) statsParts.push(`W${formatTokens(totalCacheWrite)}`);
|
|
102
|
+
// if (totalCost) statsParts.push(`$${totalCost.toFixed(3)}`);
|
|
103
|
+
// statsParts.push(`${contextPercent}%`);
|
|
104
|
+
// const statsLeft = statsParts.join(" ");
|
|
105
|
+
// // Add model name on the right side
|
|
106
|
+
// let modelName = this.state.model.id;
|
|
107
|
+
// const statsLeftWidth = visibleWidth(statsLeft);
|
|
108
|
+
// const modelWidth = visibleWidth(modelName);
|
|
109
|
+
// // Calculate available space for padding (minimum 2 spaces between stats and model)
|
|
110
|
+
// const minPadding = 2;
|
|
111
|
+
// const totalNeeded = statsLeftWidth + minPadding + modelWidth;
|
|
112
|
+
// let statsLine: string;
|
|
113
|
+
// if (totalNeeded <= width) {
|
|
114
|
+
// // Both fit - add padding to right-align model
|
|
115
|
+
// const padding = " ".repeat(width - statsLeftWidth - modelWidth);
|
|
116
|
+
// statsLine = statsLeft + padding + modelName;
|
|
117
|
+
// } else {
|
|
118
|
+
// // Need to truncate model name
|
|
119
|
+
// const availableForModel = width - statsLeftWidth - minPadding;
|
|
120
|
+
// if (availableForModel > 3) {
|
|
121
|
+
// // Truncate model name to fit
|
|
122
|
+
// modelName = modelName.substring(0, availableForModel);
|
|
123
|
+
// const padding = " ".repeat(
|
|
124
|
+
// width - statsLeftWidth - visibleWidth(modelName),
|
|
125
|
+
// );
|
|
126
|
+
// statsLine = statsLeft + padding + modelName;
|
|
127
|
+
// } else {
|
|
128
|
+
// // Not enough space for model name at all
|
|
129
|
+
// statsLine = statsLeft;
|
|
130
|
+
// }
|
|
131
|
+
// }
|
|
132
|
+
// // Return two lines: pwd and stats
|
|
133
|
+
// return [chalk.gray(pwd), chalk.gray(statsLine)];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Simple hash function to convert tool names to consistent numbers
|
|
137
|
+
function hashString(str) {
|
|
138
|
+
let hash = 0;
|
|
139
|
+
for (let i = 0; i < str.length; i++) {
|
|
140
|
+
const char = str.charCodeAt(i);
|
|
141
|
+
hash = (hash << 5) - hash + char;
|
|
142
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
143
|
+
}
|
|
144
|
+
return Math.abs(hash);
|
|
145
|
+
}
|
|
146
|
+
function displayToolUse(result) {
|
|
147
|
+
const toolsCalled = [];
|
|
148
|
+
const toolColors = new Map();
|
|
149
|
+
const styleColors = [
|
|
150
|
+
"red",
|
|
151
|
+
"green",
|
|
152
|
+
"yellow",
|
|
153
|
+
"blue",
|
|
154
|
+
"magenta",
|
|
155
|
+
"cyan",
|
|
156
|
+
"white",
|
|
157
|
+
"gray",
|
|
158
|
+
"redBright",
|
|
159
|
+
"greenBright",
|
|
160
|
+
"yellowBright",
|
|
161
|
+
"blueBright",
|
|
162
|
+
"magentaBright",
|
|
163
|
+
"cyanBright",
|
|
164
|
+
"whiteBright",
|
|
165
|
+
"blackBright",
|
|
166
|
+
];
|
|
167
|
+
const results = [];
|
|
168
|
+
for (const step of result.steps) {
|
|
169
|
+
let currentToolCalls = [];
|
|
170
|
+
if (step.toolResults.length > 0) {
|
|
171
|
+
currentToolCalls = step.toolResults;
|
|
172
|
+
}
|
|
173
|
+
else if (step.toolCalls.length > 0) {
|
|
174
|
+
currentToolCalls = step.toolCalls;
|
|
175
|
+
}
|
|
176
|
+
for (const toolCallOrResult of currentToolCalls) {
|
|
177
|
+
const toolName = toolCallOrResult.toolName;
|
|
178
|
+
if (!toolColors.has(toolName)) {
|
|
179
|
+
const hash = hashString(toolName);
|
|
180
|
+
const colorIndex = hash % styleColors.length;
|
|
181
|
+
const color = styleColors[colorIndex];
|
|
182
|
+
toolColors.set(toolName, style[color]);
|
|
183
|
+
}
|
|
184
|
+
toolsCalled.push(toolName);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (toolsCalled.length > 0) {
|
|
188
|
+
results.push(style.dim("Tools:"));
|
|
189
|
+
let toolBlocks = "";
|
|
190
|
+
for (const toolCalled of toolsCalled) {
|
|
191
|
+
const colorFn = toolColors.get(toolCalled) ?? style.white;
|
|
192
|
+
toolBlocks += `${colorFn("██")} `;
|
|
193
|
+
}
|
|
194
|
+
results.push(toolBlocks);
|
|
195
|
+
results.push("");
|
|
196
|
+
let toolLegend = "";
|
|
197
|
+
const uniqueTools = new Set(toolsCalled);
|
|
198
|
+
for (const [index, toolCalled] of Array.from(uniqueTools).entries()) {
|
|
199
|
+
const colorFn = toolColors.get(toolCalled) ?? style.white;
|
|
200
|
+
toolLegend += colorFn(toolCalled);
|
|
201
|
+
if (index < new Set(toolsCalled).size - 1) {
|
|
202
|
+
toolLegend += " - ";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
results.push(toolLegend);
|
|
206
|
+
results.push("");
|
|
207
|
+
}
|
|
208
|
+
return results;
|
|
209
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type StyleInstance } from "../../terminal/style.ts";
|
|
2
|
+
import type { Component } from "../tui.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Header component - displays styled header line
|
|
5
|
+
*/
|
|
6
|
+
export declare class HeaderComponent implements Component {
|
|
7
|
+
private header;
|
|
8
|
+
private styleFn;
|
|
9
|
+
private width;
|
|
10
|
+
private cachedOutput?;
|
|
11
|
+
private cachedHeader?;
|
|
12
|
+
private cachedStyleFn?;
|
|
13
|
+
private cachedWidth?;
|
|
14
|
+
constructor(header: string, styleFn?: StyleInstance, width?: number);
|
|
15
|
+
setHeader(header: string): void;
|
|
16
|
+
setStyleFn(styleFn: StyleInstance): void;
|
|
17
|
+
setWidth(width: number): void;
|
|
18
|
+
private invalidateCache;
|
|
19
|
+
render(width: number): string[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../source/tui/components/header.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAC/C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAS;IAGtB,OAAO,CAAC,YAAY,CAAC,CAAW;IAChC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAG3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,aAA0B,EACnC,KAAK,CAAC,EAAE,MAAM;IAOhB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAKxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,OAAO,CAAC,eAAe;IAOvB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CA+BhC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getTerminalSize } from "../../terminal/control.js";
|
|
2
|
+
import style from "../../terminal/style.js";
|
|
3
|
+
/**
|
|
4
|
+
* Header component - displays styled header line
|
|
5
|
+
*/
|
|
6
|
+
export class HeaderComponent {
|
|
7
|
+
header;
|
|
8
|
+
styleFn;
|
|
9
|
+
width;
|
|
10
|
+
// Cache for rendered output
|
|
11
|
+
cachedOutput;
|
|
12
|
+
cachedHeader;
|
|
13
|
+
cachedStyleFn;
|
|
14
|
+
cachedWidth;
|
|
15
|
+
constructor(header, styleFn = style.cyan, width) {
|
|
16
|
+
this.header = header;
|
|
17
|
+
this.styleFn = styleFn;
|
|
18
|
+
this.width = width || 0;
|
|
19
|
+
}
|
|
20
|
+
setHeader(header) {
|
|
21
|
+
this.header = header;
|
|
22
|
+
this.invalidateCache();
|
|
23
|
+
}
|
|
24
|
+
setStyleFn(styleFn) {
|
|
25
|
+
this.styleFn = styleFn;
|
|
26
|
+
this.invalidateCache();
|
|
27
|
+
}
|
|
28
|
+
setWidth(width) {
|
|
29
|
+
this.width = width;
|
|
30
|
+
this.invalidateCache();
|
|
31
|
+
}
|
|
32
|
+
invalidateCache() {
|
|
33
|
+
this.cachedOutput = undefined;
|
|
34
|
+
this.cachedHeader = undefined;
|
|
35
|
+
this.cachedStyleFn = undefined;
|
|
36
|
+
this.cachedWidth = undefined;
|
|
37
|
+
}
|
|
38
|
+
render(width) {
|
|
39
|
+
// Use provided width if specified, otherwise use component width or terminal size
|
|
40
|
+
let renderWidth = width || this.width;
|
|
41
|
+
if (renderWidth === 0) {
|
|
42
|
+
const { columns } = getTerminalSize();
|
|
43
|
+
const cols = columns > 0 ? columns : 80;
|
|
44
|
+
renderWidth = Math.max(0, cols - this.header.length - 4);
|
|
45
|
+
}
|
|
46
|
+
// Check cache
|
|
47
|
+
if (this.cachedOutput &&
|
|
48
|
+
this.cachedHeader === this.header &&
|
|
49
|
+
this.cachedStyleFn === this.styleFn &&
|
|
50
|
+
this.cachedWidth === renderWidth) {
|
|
51
|
+
return this.cachedOutput;
|
|
52
|
+
}
|
|
53
|
+
const result = [
|
|
54
|
+
`${style.gray("\n── ")}${this.styleFn(this.header)} ${style.gray("─".repeat(renderWidth))}`,
|
|
55
|
+
];
|
|
56
|
+
// Update cache
|
|
57
|
+
this.cachedOutput = result;
|
|
58
|
+
this.cachedHeader = this.header;
|
|
59
|
+
this.cachedStyleFn = this.styleFn;
|
|
60
|
+
this.cachedWidth = renderWidth;
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Component } from "../tui.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Input component - single-line text input with horizontal scrolling
|
|
4
|
+
*/
|
|
5
|
+
export declare class Input implements Component {
|
|
6
|
+
private value;
|
|
7
|
+
private cursor;
|
|
8
|
+
onSubmit?: (value: string) => void;
|
|
9
|
+
getValue(): string;
|
|
10
|
+
setValue(value: string): void;
|
|
11
|
+
handleInput(data: string): void;
|
|
12
|
+
render(width: number): string[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../source/tui/components/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C;;GAEG;AACH,qBAAa,KAAM,YAAW,SAAS;IACrC,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,MAAM,CAAK;IACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiE/B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAuDhC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { visibleWidth } from "../utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* Input component - single-line text input with horizontal scrolling
|
|
4
|
+
*/
|
|
5
|
+
export class Input {
|
|
6
|
+
value = "";
|
|
7
|
+
cursor = 0; // Cursor position in the value
|
|
8
|
+
onSubmit;
|
|
9
|
+
getValue() {
|
|
10
|
+
return this.value;
|
|
11
|
+
}
|
|
12
|
+
setValue(value) {
|
|
13
|
+
this.value = value;
|
|
14
|
+
this.cursor = Math.min(this.cursor, value.length);
|
|
15
|
+
}
|
|
16
|
+
handleInput(data) {
|
|
17
|
+
// Handle special keys
|
|
18
|
+
if (data === "\r" || data === "\n") {
|
|
19
|
+
// Enter - submit
|
|
20
|
+
if (this.onSubmit) {
|
|
21
|
+
this.onSubmit(this.value);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (data === "\x7f" || data === "\x08") {
|
|
26
|
+
// Backspace
|
|
27
|
+
if (this.cursor > 0) {
|
|
28
|
+
this.value =
|
|
29
|
+
this.value.slice(0, this.cursor - 1) + this.value.slice(this.cursor);
|
|
30
|
+
this.cursor--;
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (data === "\x1b[D") {
|
|
35
|
+
// Left arrow
|
|
36
|
+
if (this.cursor > 0) {
|
|
37
|
+
this.cursor--;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (data === "\x1b[C") {
|
|
42
|
+
// Right arrow
|
|
43
|
+
if (this.cursor < this.value.length) {
|
|
44
|
+
this.cursor++;
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (data === "\x1b[3~") {
|
|
49
|
+
// Delete
|
|
50
|
+
if (this.cursor < this.value.length) {
|
|
51
|
+
this.value =
|
|
52
|
+
this.value.slice(0, this.cursor) + this.value.slice(this.cursor + 1);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (data === "\x01") {
|
|
57
|
+
// Ctrl+A - beginning of line
|
|
58
|
+
this.cursor = 0;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (data === "\x05") {
|
|
62
|
+
// Ctrl+E - end of line
|
|
63
|
+
this.cursor = this.value.length;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Regular character input
|
|
67
|
+
if (data.length === 1 && data >= " " && data <= "~") {
|
|
68
|
+
this.value =
|
|
69
|
+
this.value.slice(0, this.cursor) + data + this.value.slice(this.cursor);
|
|
70
|
+
this.cursor++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
render(width) {
|
|
74
|
+
// Calculate visible window
|
|
75
|
+
const prompt = "> ";
|
|
76
|
+
const availableWidth = width - prompt.length;
|
|
77
|
+
if (availableWidth <= 0) {
|
|
78
|
+
return [prompt];
|
|
79
|
+
}
|
|
80
|
+
let visibleText = "";
|
|
81
|
+
let cursorDisplay = this.cursor;
|
|
82
|
+
if (this.value.length < availableWidth) {
|
|
83
|
+
// Everything fits (leave room for cursor at end)
|
|
84
|
+
visibleText = this.value;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Need horizontal scrolling
|
|
88
|
+
// Reserve one character for cursor if it's at the end
|
|
89
|
+
const scrollWidth = this.cursor === this.value.length ? availableWidth - 1 : availableWidth;
|
|
90
|
+
const halfWidth = Math.floor(scrollWidth / 2);
|
|
91
|
+
if (this.cursor < halfWidth) {
|
|
92
|
+
// Cursor near start
|
|
93
|
+
visibleText = this.value.slice(0, scrollWidth);
|
|
94
|
+
cursorDisplay = this.cursor;
|
|
95
|
+
}
|
|
96
|
+
else if (this.cursor > this.value.length - halfWidth) {
|
|
97
|
+
// Cursor near end
|
|
98
|
+
visibleText = this.value.slice(this.value.length - scrollWidth);
|
|
99
|
+
cursorDisplay = scrollWidth - (this.value.length - this.cursor);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// Cursor in middle
|
|
103
|
+
const start = this.cursor - halfWidth;
|
|
104
|
+
visibleText = this.value.slice(start, start + scrollWidth);
|
|
105
|
+
cursorDisplay = halfWidth;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Build line with fake cursor
|
|
109
|
+
// Insert cursor character at cursor position
|
|
110
|
+
const beforeCursor = visibleText.slice(0, cursorDisplay);
|
|
111
|
+
const atCursor = visibleText[cursorDisplay] || " "; // Character at cursor, or space if at end
|
|
112
|
+
const afterCursor = visibleText.slice(cursorDisplay + 1);
|
|
113
|
+
// Use inverse video to show cursor
|
|
114
|
+
const cursorChar = `\x1b[7m${atCursor}\x1b[27m`; // ESC[7m = reverse video, ESC[27m = normal
|
|
115
|
+
const textWithCursor = beforeCursor + cursorChar + afterCursor;
|
|
116
|
+
// Calculate visual width
|
|
117
|
+
const visualLength = visibleWidth(textWithCursor);
|
|
118
|
+
const padding = " ".repeat(Math.max(0, availableWidth - visualLength));
|
|
119
|
+
const line = prompt + textWithCursor + padding;
|
|
120
|
+
return [line];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TUI } from "../tui.ts";
|
|
2
|
+
import { Text } from "./text.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Loader component that updates every 80ms with spinning animation
|
|
5
|
+
*/
|
|
6
|
+
export declare class Loader extends Text {
|
|
7
|
+
private frames;
|
|
8
|
+
private currentFrame;
|
|
9
|
+
private intervalId;
|
|
10
|
+
private ui;
|
|
11
|
+
private message;
|
|
12
|
+
constructor(ui: TUI, message?: string, customBgRgb?: {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
});
|
|
17
|
+
render(width: number): string[];
|
|
18
|
+
start(): void;
|
|
19
|
+
stop(): void;
|
|
20
|
+
setMessage(message: string): void;
|
|
21
|
+
private updateDisplay;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../source/tui/components/loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,qBAAa,MAAO,SAAQ,IAAI;IAC9B,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,OAAO,CAAS;gBAGtB,EAAE,EAAE,GAAG,EACP,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAQ1C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC,KAAK;IAQL,IAAI;IAOJ,UAAU,CAAC,OAAO,EAAE,MAAM;IAK1B,OAAO,CAAC,aAAa;CAOtB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import style from "../../terminal/style.js";
|
|
2
|
+
import { Text } from "./text.js";
|
|
3
|
+
/**
|
|
4
|
+
* Loader component that updates every 80ms with spinning animation
|
|
5
|
+
*/
|
|
6
|
+
export class Loader extends Text {
|
|
7
|
+
frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
8
|
+
currentFrame = 0;
|
|
9
|
+
intervalId = null;
|
|
10
|
+
ui = null;
|
|
11
|
+
message;
|
|
12
|
+
constructor(ui, message, customBgRgb) {
|
|
13
|
+
super("", 1, 0, customBgRgb);
|
|
14
|
+
this.message = message ?? "Loading...";
|
|
15
|
+
this.ui = ui;
|
|
16
|
+
this.start();
|
|
17
|
+
}
|
|
18
|
+
render(width) {
|
|
19
|
+
return ["", ...super.render(width)];
|
|
20
|
+
}
|
|
21
|
+
start() {
|
|
22
|
+
this.updateDisplay();
|
|
23
|
+
this.intervalId = setInterval(() => {
|
|
24
|
+
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
25
|
+
this.updateDisplay();
|
|
26
|
+
}, 80);
|
|
27
|
+
}
|
|
28
|
+
stop() {
|
|
29
|
+
if (this.intervalId) {
|
|
30
|
+
clearInterval(this.intervalId);
|
|
31
|
+
this.intervalId = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
setMessage(message) {
|
|
35
|
+
this.message = message;
|
|
36
|
+
this.updateDisplay();
|
|
37
|
+
}
|
|
38
|
+
updateDisplay() {
|
|
39
|
+
const frame = this.frames[this.currentFrame];
|
|
40
|
+
this.setText(`${style.cyan(frame)} ${style.dim(this.message)}`);
|
|
41
|
+
if (this.ui) {
|
|
42
|
+
this.ui.requestRender();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Theme } from "../../terminal/highlight/theme.ts";
|
|
2
|
+
import type { Component } from "../tui.ts";
|
|
3
|
+
type Color = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray";
|
|
4
|
+
/**
|
|
5
|
+
* Theme functions for markdown elements.
|
|
6
|
+
* Each function takes text and returns styled text with ANSI codes.
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkdownTheme {
|
|
9
|
+
heading: (text: string) => string;
|
|
10
|
+
paragraph: (text: string) => string;
|
|
11
|
+
link: (text: string) => string;
|
|
12
|
+
linkUrl: (text: string) => string;
|
|
13
|
+
code: (text: string) => string;
|
|
14
|
+
codeBlock: (text: string) => string;
|
|
15
|
+
codeBlockBorder: (text: string) => string;
|
|
16
|
+
quote: (text: string) => string;
|
|
17
|
+
quoteBorder: (text: string) => string;
|
|
18
|
+
hr: (text: string) => string;
|
|
19
|
+
listBullet: (text: string) => string;
|
|
20
|
+
bold: (text: string) => string;
|
|
21
|
+
italic: (text: string) => string;
|
|
22
|
+
strikethrough: (text: string) => string;
|
|
23
|
+
underline: (text: string) => string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for configuring Markdown component
|
|
27
|
+
*/
|
|
28
|
+
export interface MarkdownOptions {
|
|
29
|
+
/** Background color */
|
|
30
|
+
bgColor?: Color;
|
|
31
|
+
/** Custom background RGB color */
|
|
32
|
+
customBgRgb?: {
|
|
33
|
+
r: number;
|
|
34
|
+
g: number;
|
|
35
|
+
b: number;
|
|
36
|
+
};
|
|
37
|
+
/** Horizontal padding */
|
|
38
|
+
paddingX?: number;
|
|
39
|
+
/** Vertical padding */
|
|
40
|
+
paddingY?: number;
|
|
41
|
+
/** Theme for markdown */
|
|
42
|
+
theme?: MarkdownTheme;
|
|
43
|
+
/** Theme for code highlighting */
|
|
44
|
+
highlightTheme?: Theme;
|
|
45
|
+
}
|
|
46
|
+
export declare class Markdown implements Component {
|
|
47
|
+
private text;
|
|
48
|
+
private bgColor?;
|
|
49
|
+
private customBgRgb?;
|
|
50
|
+
private paddingX;
|
|
51
|
+
private paddingY;
|
|
52
|
+
private theme;
|
|
53
|
+
private highlightTheme;
|
|
54
|
+
private cachedText?;
|
|
55
|
+
private cachedWidth?;
|
|
56
|
+
private cachedLines?;
|
|
57
|
+
constructor(text: string, options?: MarkdownOptions);
|
|
58
|
+
setText(text: string): void;
|
|
59
|
+
setBgColor(bgColor?: Color): void;
|
|
60
|
+
setCustomBgRgb(customBgRgb?: {
|
|
61
|
+
r: number;
|
|
62
|
+
g: number;
|
|
63
|
+
b: number;
|
|
64
|
+
}): void;
|
|
65
|
+
invalidate(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get the background color function based on current configuration
|
|
68
|
+
*/
|
|
69
|
+
private getBackgroundFunction;
|
|
70
|
+
render(width: number): string[];
|
|
71
|
+
private renderToken;
|
|
72
|
+
private renderInlineTokens;
|
|
73
|
+
private wrapLine;
|
|
74
|
+
/**
|
|
75
|
+
* Protect inline code spans by replacing them with placeholders
|
|
76
|
+
* This prevents wrapAnsi from breaking code spans across lines
|
|
77
|
+
*/
|
|
78
|
+
private protectCodeSpans;
|
|
79
|
+
/**
|
|
80
|
+
* Check if a potential code span is an actual code span (not escaped backticks)
|
|
81
|
+
*/
|
|
82
|
+
private isActualCodeSpan;
|
|
83
|
+
/**
|
|
84
|
+
* Check if a line represents a nested list item
|
|
85
|
+
*/
|
|
86
|
+
private isNestedListLine;
|
|
87
|
+
/**
|
|
88
|
+
* Restore code spans from placeholders after wrapping
|
|
89
|
+
*/
|
|
90
|
+
private restoreCodeSpans;
|
|
91
|
+
/**
|
|
92
|
+
* Render a list with proper nesting support
|
|
93
|
+
*/
|
|
94
|
+
private renderList;
|
|
95
|
+
/**
|
|
96
|
+
* Render list item tokens, handling nested lists
|
|
97
|
+
* Returns lines WITHOUT the parent indent (renderList will add it)
|
|
98
|
+
*/
|
|
99
|
+
private renderListItem;
|
|
100
|
+
/**
|
|
101
|
+
* Render a table
|
|
102
|
+
*/
|
|
103
|
+
private renderTable;
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../source/tui/components/markdown.ts"],"names":[],"mappings":"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"}
|