@travisennis/acai 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
|
-
|
|
2
|
+
import { formatMemoryUsage } from "../formatting.js";
|
|
3
|
+
import { Container, Modal, ModalText, TableComponent } from "../tui/index.js";
|
|
4
|
+
export function healthCommand(_options, execFn = execSync) {
|
|
3
5
|
return {
|
|
4
6
|
command: "/health",
|
|
5
7
|
description: "Show application health status and environment variables",
|
|
6
8
|
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
async
|
|
9
|
+
async handle(_args, { tui, editor }) {
|
|
8
10
|
// Define the environment variables we care about
|
|
9
11
|
const envVars = [
|
|
10
12
|
// AI Provider API Keys
|
|
@@ -38,22 +40,6 @@ export function healthCommand({ terminal }, execFn = execSync) {
|
|
|
38
40
|
const status = hasValue ? "✓ Set" : "✗ Not set";
|
|
39
41
|
return [envVar.name, status, envVar.description];
|
|
40
42
|
});
|
|
41
|
-
// Display the table
|
|
42
|
-
terminal.info("Environment Variables Status:");
|
|
43
|
-
terminal.table(envStatus, {
|
|
44
|
-
header: ["Variable", "Status", "Description"],
|
|
45
|
-
colWidths: [30, 15, 55],
|
|
46
|
-
});
|
|
47
|
-
// Count how many are set (derived from envStatus to avoid re-checking process.env)
|
|
48
|
-
const setCount = envStatus.filter((row) => row[1] === "✓ Set").length;
|
|
49
|
-
const totalCount = envVars.length;
|
|
50
|
-
terminal.info(`Summary: ${setCount}/${totalCount} environment variables are set`);
|
|
51
|
-
if (setCount === 0) {
|
|
52
|
-
terminal.warn("⚠️ No AI provider API keys are configured. The app may not function properly.");
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
terminal.info("✓ At least one AI provider is configured.");
|
|
56
|
-
}
|
|
57
43
|
// Check for required bash tools
|
|
58
44
|
const tools = [
|
|
59
45
|
{ name: "git", command: "git --version" },
|
|
@@ -75,21 +61,57 @@ export function healthCommand({ terminal }, execFn = execSync) {
|
|
|
75
61
|
}
|
|
76
62
|
return [tool.name, status];
|
|
77
63
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
header: ["Tool", "Status"],
|
|
82
|
-
colWidths: [15, 20],
|
|
83
|
-
});
|
|
64
|
+
// Count how many are set
|
|
65
|
+
const setCount = envStatus.filter((row) => row[1] === "✓ Set").length;
|
|
66
|
+
const totalCount = envVars.length;
|
|
84
67
|
const installedCount = toolStatus.filter((row) => row[1] === "✓ Installed").length;
|
|
85
68
|
const totalTools = tools.length;
|
|
86
|
-
|
|
69
|
+
// Display memory usage
|
|
70
|
+
const usage = process.memoryUsage().rss;
|
|
71
|
+
const formattedUsage = formatMemoryUsage(usage);
|
|
72
|
+
// Build modal content
|
|
73
|
+
const modalContent = new Container();
|
|
74
|
+
// Environment variables section
|
|
75
|
+
modalContent.addChild(new ModalText("Environment Variables Status:", 0, 1));
|
|
76
|
+
modalContent.addChild(new TableComponent(envStatus, {
|
|
77
|
+
headers: ["Variable", "Status", "Description"],
|
|
78
|
+
}));
|
|
79
|
+
const envSummary = `Summary: ${setCount}/${totalCount} environment variables are set`;
|
|
80
|
+
modalContent.addChild(new ModalText(envSummary, 0, 1));
|
|
81
|
+
if (setCount === 0) {
|
|
82
|
+
modalContent.addChild(new ModalText("⚠️ No AI provider API keys are configured. The app may not function properly.", 0, 1));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
modalContent.addChild(new ModalText("✓ At least one AI provider is configured.", 0, 1));
|
|
86
|
+
}
|
|
87
|
+
// Tools section
|
|
88
|
+
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
89
|
+
modalContent.addChild(new ModalText("Bash Tools Status:", 0, 1));
|
|
90
|
+
modalContent.addChild(new TableComponent(toolStatus, {
|
|
91
|
+
headers: ["Tool", "Status"],
|
|
92
|
+
}));
|
|
93
|
+
const toolSummary = `Tool Summary: ${installedCount}/${totalTools} tools are installed.`;
|
|
94
|
+
modalContent.addChild(new ModalText(toolSummary, 0, 1));
|
|
87
95
|
if (installedCount < totalTools) {
|
|
88
|
-
|
|
96
|
+
modalContent.addChild(new ModalText("⚠️ Some tools are missing. Install them for full functionality.", 0, 1));
|
|
89
97
|
}
|
|
90
98
|
else {
|
|
91
|
-
|
|
99
|
+
modalContent.addChild(new ModalText("✓ All required tools are installed.", 0, 1));
|
|
92
100
|
}
|
|
101
|
+
// Memory usage
|
|
102
|
+
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
103
|
+
modalContent.addChild(new ModalText("Current Process:", 0, 1));
|
|
104
|
+
const memoryText = usage >= 2 * 1024 * 1024 * 1024
|
|
105
|
+
? `Memory Usage: ${formattedUsage}`
|
|
106
|
+
: `Memory Usage: ${formattedUsage}`;
|
|
107
|
+
modalContent.addChild(new ModalText(memoryText, 0, 1));
|
|
108
|
+
// Create and show modal
|
|
109
|
+
const modal = new Modal("Health Status", modalContent, true, () => {
|
|
110
|
+
// Modal closed callback
|
|
111
|
+
editor.setText("");
|
|
112
|
+
tui.requestRender();
|
|
113
|
+
});
|
|
114
|
+
tui.showModal(modal);
|
|
93
115
|
return "continue";
|
|
94
116
|
},
|
|
95
117
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const helpCommand: (
|
|
2
|
+
export declare const helpCommand: (_options: CommandOptions, cmds: Map<string, ReplCommand>) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=help-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-command.d.ts","sourceRoot":"","sources":["../../source/commands/help-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"help-command.d.ts","sourceRoot":"","sources":["../../source/commands/help-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GACtB,UAAU,cAAc,EACxB,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,KAC7B,WA6CF,CAAC"}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { Modal, Container as ModalContainer, ModalText, TableComponent, } from "../tui/index.js";
|
|
2
|
+
export const helpCommand = (_options, cmds) => {
|
|
2
3
|
return {
|
|
3
4
|
command: "/help",
|
|
4
5
|
description: "Shows available commands.",
|
|
5
6
|
getSubCommands: () => Promise.resolve([]),
|
|
6
|
-
|
|
7
|
+
async handle(_args, { tui, editor }) {
|
|
7
8
|
const commands = cmds;
|
|
8
9
|
const entries = Array.from(commands.entries())
|
|
9
10
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
10
11
|
.map(([key, cmd]) => [key, cmd.description]);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Build modal content
|
|
13
|
+
const modalContent = new ModalContainer();
|
|
14
|
+
if (entries.length === 0) {
|
|
15
|
+
modalContent.addChild(new ModalText("No commands available.", 0, 1));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Convert entries to table format
|
|
19
|
+
const tableData = entries.map(([command, description]) => [
|
|
20
|
+
command,
|
|
21
|
+
description,
|
|
22
|
+
]);
|
|
23
|
+
modalContent.addChild(new TableComponent(tableData, {
|
|
24
|
+
headers: ["Command", "Description"],
|
|
25
|
+
colWidths: [30, 70],
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
// Create and show modal
|
|
29
|
+
const modal = new Modal("Available Commands", modalContent, true, () => {
|
|
30
|
+
// Modal closed callback
|
|
31
|
+
editor.setText("");
|
|
32
|
+
tui.requestRender();
|
|
14
33
|
});
|
|
34
|
+
tui.showModal(modal);
|
|
15
35
|
return "continue";
|
|
16
36
|
},
|
|
17
37
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-command.d.ts","sourceRoot":"","sources":["../../source/commands/history-command.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2K9D,eAAO,MAAM,cAAc,GAAI,yDAK5B,cAAc,KAAG,WAkJnB,CAAC"}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { generateText } from "ai";
|
|
3
|
+
import { MessageHistory } from "../messages.js";
|
|
4
|
+
import { getTerminalSize, setTerminalTitle } from "../terminal/formatting.js";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { Container, Input, Markdown, Spacer, Text } from "../tui/index.js";
|
|
7
|
+
async function exportConversation(history) {
|
|
8
|
+
const sanitizedTitle = history.title
|
|
9
|
+
.replace(/[^a-zA-Z0-9\s-_]/g, "")
|
|
10
|
+
.replace(/\s+/g, "-")
|
|
11
|
+
.toLowerCase();
|
|
12
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, -5);
|
|
13
|
+
const filename = `${sanitizedTitle}_${timestamp}.md`;
|
|
14
|
+
const markdownContent = generateMarkdown(history);
|
|
15
|
+
await writeFile(filename, markdownContent);
|
|
16
|
+
return filename;
|
|
17
|
+
}
|
|
18
|
+
function generateMarkdown(history) {
|
|
19
|
+
const lines = [];
|
|
20
|
+
// Header
|
|
21
|
+
lines.push(`# ${history.title}`);
|
|
22
|
+
lines.push("");
|
|
23
|
+
lines.push("## Conversation Metadata");
|
|
24
|
+
lines.push(`- **Session ID**: ${history.sessionId}`);
|
|
25
|
+
lines.push(`- **Model**: ${history.modelId}`);
|
|
26
|
+
lines.push(`- **Created**: ${history.createdAt.toISOString()}`);
|
|
27
|
+
lines.push(`- **Last Updated**: ${history.updatedAt.toISOString()}`);
|
|
28
|
+
lines.push(`- **Total Messages**: ${history.messages.length}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
// Messages
|
|
31
|
+
lines.push("## Conversation History");
|
|
32
|
+
lines.push("");
|
|
33
|
+
history.messages.forEach((message, index) => {
|
|
34
|
+
const role = message.role.toUpperCase();
|
|
35
|
+
lines.push(`### ${role} (Message ${index + 1})`);
|
|
36
|
+
lines.push("");
|
|
37
|
+
if (Array.isArray(message.content)) {
|
|
38
|
+
message.content.forEach((part) => {
|
|
39
|
+
if (part.type === "text" && part.text?.trim()) {
|
|
40
|
+
lines.push(part.text);
|
|
41
|
+
lines.push("");
|
|
42
|
+
}
|
|
43
|
+
else if (part.type === "tool-call") {
|
|
44
|
+
lines.push(`**Tool Call**: ${part.toolName}`);
|
|
45
|
+
lines.push(`**Call ID**: ${part.toolCallId}`);
|
|
46
|
+
lines.push("**Input**:");
|
|
47
|
+
lines.push("```json");
|
|
48
|
+
lines.push(JSON.stringify(part.input, null, 2));
|
|
49
|
+
lines.push("```");
|
|
50
|
+
lines.push("");
|
|
51
|
+
}
|
|
52
|
+
else if (part.type === "tool-result") {
|
|
53
|
+
lines.push(`**Tool Result**: ${part.toolName}`);
|
|
54
|
+
lines.push(`**Call ID**: ${part.toolCallId}`);
|
|
55
|
+
lines.push("**Output**:");
|
|
56
|
+
if (typeof part.output === "object" &&
|
|
57
|
+
part.output !== null &&
|
|
58
|
+
"type" in part.output &&
|
|
59
|
+
part.output.type === "text" &&
|
|
60
|
+
"text" in part.output) {
|
|
61
|
+
lines.push("```");
|
|
62
|
+
lines.push(String(part.output.text));
|
|
63
|
+
lines.push("```");
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
lines.push("```json");
|
|
67
|
+
lines.push(JSON.stringify(part.output, null, 2));
|
|
68
|
+
lines.push("```");
|
|
69
|
+
}
|
|
70
|
+
lines.push("");
|
|
71
|
+
}
|
|
72
|
+
else if (part.type === "tool-error") {
|
|
73
|
+
lines.push(`**Tool Error**: ${part.toolName}`);
|
|
74
|
+
lines.push(`**Call ID**: ${part.toolCallId}`);
|
|
75
|
+
lines.push("**Error**:");
|
|
76
|
+
lines.push("```");
|
|
77
|
+
lines.push(String(part.output));
|
|
78
|
+
lines.push("```");
|
|
79
|
+
lines.push("");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (typeof message.content === "string" && message.content.trim()) {
|
|
84
|
+
lines.push(message.content);
|
|
85
|
+
lines.push("");
|
|
86
|
+
}
|
|
87
|
+
lines.push("---");
|
|
88
|
+
lines.push("");
|
|
89
|
+
});
|
|
90
|
+
return lines.join("\n");
|
|
91
|
+
}
|
|
92
|
+
async function summarizeConversation(history, modelManager, tokenTracker) {
|
|
93
|
+
const systemPrompt = `You are an expert at summarizing conversations between a coding assistant and a user. Your task is to provide a clear, concise summary of the conversation that captures:
|
|
94
|
+
|
|
95
|
+
1. The main topic and objectives
|
|
96
|
+
2. Key decisions and solutions discussed
|
|
97
|
+
3. Tools and techniques used
|
|
98
|
+
4. Overall outcome or current status
|
|
99
|
+
|
|
100
|
+
Keep the summary focused and informative, around 3-5 paragraphs. Use plain text without markdown formatting.`;
|
|
101
|
+
const conversationText = history.messages
|
|
102
|
+
.map((message) => {
|
|
103
|
+
const role = message.role.toUpperCase();
|
|
104
|
+
let content = "";
|
|
105
|
+
if (Array.isArray(message.content)) {
|
|
106
|
+
content = message.content
|
|
107
|
+
.filter((part) => part.type === "text" && part.text?.trim())
|
|
108
|
+
.map((part) => part.text)
|
|
109
|
+
.join("\n");
|
|
110
|
+
}
|
|
111
|
+
else if (typeof message.content === "string") {
|
|
112
|
+
content = message.content;
|
|
113
|
+
}
|
|
114
|
+
return `${role}: ${content}`;
|
|
115
|
+
})
|
|
116
|
+
.filter((text) => text?.trim())
|
|
117
|
+
.join("\n\n");
|
|
118
|
+
const { text, usage } = await generateText({
|
|
119
|
+
model: modelManager.getModel("conversation-summarizer"),
|
|
120
|
+
system: systemPrompt,
|
|
121
|
+
prompt: `Please summarize this conversation:\n\n${conversationText}`,
|
|
122
|
+
});
|
|
123
|
+
tokenTracker.trackUsage("conversation-summarizer", usage);
|
|
124
|
+
const results = [];
|
|
125
|
+
results.push(`# Summary of "${history.title}":`);
|
|
126
|
+
results.push("");
|
|
127
|
+
results.push(text);
|
|
128
|
+
results.push("");
|
|
129
|
+
return results.join("\n");
|
|
130
|
+
}
|
|
131
|
+
export const historyCommand = ({ messageHistory, config, modelManager, tokenTracker, }) => {
|
|
132
|
+
return {
|
|
133
|
+
command: "/history",
|
|
134
|
+
description: "Browse and manage previous conversations.",
|
|
135
|
+
getSubCommands: () => Promise.resolve([]),
|
|
136
|
+
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
137
|
+
const appDir = config.app;
|
|
138
|
+
const messageHistoryDir = await appDir.ensurePath("message-history");
|
|
139
|
+
// Load all histories (use a large number to get all)
|
|
140
|
+
const histories = await MessageHistory.load(messageHistoryDir, 1000);
|
|
141
|
+
if (histories.length === 0) {
|
|
142
|
+
container.addChild(new Text(style.yellow("No previous conversations found."), 0, 1));
|
|
143
|
+
tui.requestRender();
|
|
144
|
+
editor.setText("");
|
|
145
|
+
return "continue";
|
|
146
|
+
}
|
|
147
|
+
// Create conversation selector
|
|
148
|
+
const conversationSelector = new ConversationSelectorComponent(histories, async (conversation) => {
|
|
149
|
+
// Handle conversation selection
|
|
150
|
+
const actionSelector = new ActionSelectorComponent(conversation, async (action) => {
|
|
151
|
+
// Handle action selection
|
|
152
|
+
switch (action) {
|
|
153
|
+
case "resume":
|
|
154
|
+
messageHistory.restore(conversation);
|
|
155
|
+
container.addChild(new Text(style.green(`Resuming conversation: ${conversation.title}`), 0, 1));
|
|
156
|
+
setTerminalTitle(conversation.title || `acai: ${process.cwd()}`);
|
|
157
|
+
break;
|
|
158
|
+
case "export":
|
|
159
|
+
try {
|
|
160
|
+
const destFile = await exportConversation(conversation);
|
|
161
|
+
container.addChild(new Text(style.green(`Conversation exported successfully: ${destFile}`), 1, 0));
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
container.addChild(new Text(style.red(`Failed to export conversation: ${error}`), 1, 0));
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case "summarize":
|
|
168
|
+
try {
|
|
169
|
+
const result = await summarizeConversation(conversation, modelManager, tokenTracker);
|
|
170
|
+
container.addChild(new Markdown(result, {
|
|
171
|
+
customBgRgb: {
|
|
172
|
+
r: 52,
|
|
173
|
+
g: 53,
|
|
174
|
+
b: 65,
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
container.addChild(new Text(style.red(`Failed to summarize conversation: ${error}`), 1, 0));
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
// Hide selectors and show editor again
|
|
184
|
+
hideHistorySelectors(inputContainer, editor, tui);
|
|
185
|
+
tui.requestRender();
|
|
186
|
+
}, () => {
|
|
187
|
+
// Cancel action selection - go back to conversation selection
|
|
188
|
+
hideHistorySelectors(inputContainer, editor, tui);
|
|
189
|
+
inputContainer.addChild(conversationSelector);
|
|
190
|
+
tui.setFocus(conversationSelector);
|
|
191
|
+
tui.requestRender();
|
|
192
|
+
});
|
|
193
|
+
// Replace conversation selector with action selector
|
|
194
|
+
inputContainer.clear();
|
|
195
|
+
inputContainer.addChild(actionSelector);
|
|
196
|
+
tui.setFocus(actionSelector);
|
|
197
|
+
tui.requestRender();
|
|
198
|
+
}, () => {
|
|
199
|
+
// Cancel conversation selection - just hide selector
|
|
200
|
+
hideHistorySelectors(inputContainer, editor, tui);
|
|
201
|
+
tui.requestRender();
|
|
202
|
+
});
|
|
203
|
+
// Replace editor with conversation selector
|
|
204
|
+
inputContainer.clear();
|
|
205
|
+
inputContainer.addChild(conversationSelector);
|
|
206
|
+
tui.setFocus(conversationSelector);
|
|
207
|
+
tui.requestRender();
|
|
208
|
+
return "continue";
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
function hideHistorySelectors(editorContainer, editor, tui) {
|
|
213
|
+
// Replace selector with editor in the container
|
|
214
|
+
editorContainer.clear();
|
|
215
|
+
editorContainer.addChild(editor);
|
|
216
|
+
tui.setFocus(editor);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Component that renders a conversation selector with search
|
|
220
|
+
*/
|
|
221
|
+
class ConversationSelectorComponent extends Container {
|
|
222
|
+
searchInput;
|
|
223
|
+
listContainer;
|
|
224
|
+
allConversations = [];
|
|
225
|
+
filteredConversations = [];
|
|
226
|
+
selectedIndex = 0;
|
|
227
|
+
onSelectCallback;
|
|
228
|
+
onCancelCallback;
|
|
229
|
+
constructor(conversations, onSelect, onCancel) {
|
|
230
|
+
super();
|
|
231
|
+
this.onSelectCallback = onSelect;
|
|
232
|
+
this.onCancelCallback = onCancel;
|
|
233
|
+
// Load all conversations
|
|
234
|
+
this.allConversations = conversations;
|
|
235
|
+
this.filteredConversations = conversations;
|
|
236
|
+
const { columns } = getTerminalSize();
|
|
237
|
+
// Add top border
|
|
238
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
239
|
+
this.addChild(new Spacer(1));
|
|
240
|
+
// Create search input
|
|
241
|
+
this.searchInput = new Input();
|
|
242
|
+
// Note: setPlaceholder not available on Input component
|
|
243
|
+
this.searchInput.onSubmit = () => {
|
|
244
|
+
// Enter on search input selects the first filtered item
|
|
245
|
+
if (this.filteredConversations[this.selectedIndex]) {
|
|
246
|
+
this.handleSelect(this.filteredConversations[this.selectedIndex]);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
this.addChild(this.searchInput);
|
|
250
|
+
this.addChild(new Spacer(1));
|
|
251
|
+
// Create list container
|
|
252
|
+
this.listContainer = new Container();
|
|
253
|
+
this.addChild(this.listContainer);
|
|
254
|
+
this.addChild(new Spacer(1));
|
|
255
|
+
// Add bottom border
|
|
256
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
257
|
+
// Initial render
|
|
258
|
+
this.updateList();
|
|
259
|
+
}
|
|
260
|
+
filterConversations(query) {
|
|
261
|
+
if (!query.trim()) {
|
|
262
|
+
this.filteredConversations = this.allConversations;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const searchTokens = query
|
|
266
|
+
.toLowerCase()
|
|
267
|
+
.split(/\s+/)
|
|
268
|
+
.filter((t) => t);
|
|
269
|
+
this.filteredConversations = this.allConversations.filter((conversation) => {
|
|
270
|
+
const searchText = `${conversation.title} ${conversation.sessionId}`.toLowerCase();
|
|
271
|
+
return searchTokens.every((token) => searchText.includes(token));
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredConversations.length - 1));
|
|
275
|
+
this.updateList();
|
|
276
|
+
}
|
|
277
|
+
updateList() {
|
|
278
|
+
this.listContainer.clear();
|
|
279
|
+
const maxVisible = 10;
|
|
280
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredConversations.length - maxVisible));
|
|
281
|
+
const endIndex = Math.min(startIndex + maxVisible, this.filteredConversations.length);
|
|
282
|
+
// Show visible slice of filtered conversations
|
|
283
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
284
|
+
const conversation = this.filteredConversations[i];
|
|
285
|
+
if (!conversation)
|
|
286
|
+
continue;
|
|
287
|
+
const isSelected = i === this.selectedIndex;
|
|
288
|
+
let line = "";
|
|
289
|
+
if (isSelected) {
|
|
290
|
+
const prefix = style.blue("→ ");
|
|
291
|
+
const title = conversation.title;
|
|
292
|
+
const date = conversation.updatedAt.toLocaleString();
|
|
293
|
+
const messages = conversation.messages.length;
|
|
294
|
+
line = `${prefix + style.blue(title)} ${style.gray(`(${date}) - ${messages} messages`)}`;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
const title = ` ${conversation.title}`;
|
|
298
|
+
const date = conversation.updatedAt.toLocaleString();
|
|
299
|
+
const messages = conversation.messages.length;
|
|
300
|
+
line = `${title} ${style.gray(`(${date}) - ${messages} messages`)}`;
|
|
301
|
+
}
|
|
302
|
+
this.listContainer.addChild(new Text(line, 0, 0));
|
|
303
|
+
}
|
|
304
|
+
// Add scroll indicator if needed
|
|
305
|
+
if (startIndex > 0 || endIndex < this.filteredConversations.length) {
|
|
306
|
+
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredConversations.length})`);
|
|
307
|
+
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
308
|
+
}
|
|
309
|
+
// Show "no results" if empty
|
|
310
|
+
if (this.filteredConversations.length === 0) {
|
|
311
|
+
this.listContainer.addChild(new Text(style.gray(" No matching conversations"), 0, 0));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
handleInput(keyData) {
|
|
315
|
+
// Up arrow
|
|
316
|
+
if (keyData === "\x1b[A") {
|
|
317
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
318
|
+
this.updateList();
|
|
319
|
+
}
|
|
320
|
+
// Down arrow
|
|
321
|
+
else if (keyData === "\x1b[B") {
|
|
322
|
+
this.selectedIndex = Math.min(this.filteredConversations.length - 1, this.selectedIndex + 1);
|
|
323
|
+
this.updateList();
|
|
324
|
+
}
|
|
325
|
+
// Enter
|
|
326
|
+
else if (keyData === "\r") {
|
|
327
|
+
const selectedConversation = this.filteredConversations[this.selectedIndex];
|
|
328
|
+
if (selectedConversation) {
|
|
329
|
+
this.handleSelect(selectedConversation);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Escape
|
|
333
|
+
else if (keyData === "\x1b") {
|
|
334
|
+
this.onCancelCallback();
|
|
335
|
+
}
|
|
336
|
+
// Pass everything else to search input
|
|
337
|
+
else {
|
|
338
|
+
this.searchInput.handleInput(keyData);
|
|
339
|
+
this.filterConversations(this.searchInput.getValue());
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
handleSelect(conversation) {
|
|
343
|
+
this.onSelectCallback(conversation);
|
|
344
|
+
}
|
|
345
|
+
getSearchInput() {
|
|
346
|
+
return this.searchInput;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Component that renders an action selector for a conversation
|
|
351
|
+
*/
|
|
352
|
+
class ActionSelectorComponent extends Container {
|
|
353
|
+
selectedIndex = 0;
|
|
354
|
+
conversationTitle;
|
|
355
|
+
onSelectCallback;
|
|
356
|
+
onCancelCallback;
|
|
357
|
+
constructor(conversation, onSelect, onCancel) {
|
|
358
|
+
super();
|
|
359
|
+
this.conversationTitle = conversation.title;
|
|
360
|
+
this.onSelectCallback = onSelect;
|
|
361
|
+
this.onCancelCallback = onCancel;
|
|
362
|
+
const { columns } = getTerminalSize();
|
|
363
|
+
// Add top border
|
|
364
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
365
|
+
this.addChild(new Spacer(1));
|
|
366
|
+
// Show conversation title
|
|
367
|
+
this.addChild(new Text(`Selected: ${conversation.title}`, 0, 0));
|
|
368
|
+
this.addChild(new Spacer(1));
|
|
369
|
+
// Create action list
|
|
370
|
+
this.addChild(new Text("Choose an action:", 0, 0));
|
|
371
|
+
this.addChild(new Spacer(1));
|
|
372
|
+
const actions = [
|
|
373
|
+
{ name: "Resume - Continue this conversation", value: "resume" },
|
|
374
|
+
{ name: "Export - Save as markdown file", value: "export" },
|
|
375
|
+
{
|
|
376
|
+
name: "Summarize - Generate AI summary of conversation",
|
|
377
|
+
value: "summarize",
|
|
378
|
+
},
|
|
379
|
+
];
|
|
380
|
+
actions.forEach((action, index) => {
|
|
381
|
+
const isSelected = index === this.selectedIndex;
|
|
382
|
+
let line = "";
|
|
383
|
+
if (isSelected) {
|
|
384
|
+
line = `${style.blue("→ ") + style.blue(action.name)}`;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
line = ` ${action.name}`;
|
|
388
|
+
}
|
|
389
|
+
this.addChild(new Text(line, 0, 0));
|
|
390
|
+
});
|
|
391
|
+
this.addChild(new Spacer(1));
|
|
392
|
+
// Add bottom border
|
|
393
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
394
|
+
}
|
|
395
|
+
handleInput(keyData) {
|
|
396
|
+
// Up arrow
|
|
397
|
+
if (keyData === "\x1b[A") {
|
|
398
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
399
|
+
this.updateList();
|
|
400
|
+
}
|
|
401
|
+
// Down arrow
|
|
402
|
+
else if (keyData === "\x1b[B") {
|
|
403
|
+
this.selectedIndex = Math.min(2, this.selectedIndex + 1);
|
|
404
|
+
this.updateList();
|
|
405
|
+
}
|
|
406
|
+
// Enter
|
|
407
|
+
else if (keyData === "\r") {
|
|
408
|
+
const actions = ["resume", "export", "summarize"];
|
|
409
|
+
const selectedAction = actions[this.selectedIndex];
|
|
410
|
+
if (selectedAction) {
|
|
411
|
+
this.handleSelect(selectedAction);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// Escape
|
|
415
|
+
else if (keyData === "\x1b") {
|
|
416
|
+
this.onCancelCallback();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
updateList() {
|
|
420
|
+
// Clear and rebuild the action list
|
|
421
|
+
this.clear();
|
|
422
|
+
const { columns } = getTerminalSize();
|
|
423
|
+
// Add top border
|
|
424
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
425
|
+
this.addChild(new Spacer(1));
|
|
426
|
+
// Show conversation title
|
|
427
|
+
this.addChild(new Text(`Selected: ${this.conversationTitle}`, 0, 0));
|
|
428
|
+
this.addChild(new Spacer(1));
|
|
429
|
+
// Create action list
|
|
430
|
+
this.addChild(new Text("Choose an action:", 0, 0));
|
|
431
|
+
this.addChild(new Spacer(1));
|
|
432
|
+
const actions = [
|
|
433
|
+
{ name: "Resume - Continue this conversation", value: "resume" },
|
|
434
|
+
{ name: "Export - Save as markdown file", value: "export" },
|
|
435
|
+
{
|
|
436
|
+
name: "Summarize - Generate AI summary of conversation",
|
|
437
|
+
value: "summarize",
|
|
438
|
+
},
|
|
439
|
+
];
|
|
440
|
+
actions.forEach((action, index) => {
|
|
441
|
+
const isSelected = index === this.selectedIndex;
|
|
442
|
+
let line = "";
|
|
443
|
+
if (isSelected) {
|
|
444
|
+
line = `${style.blue("→ ") + style.blue(action.name)}`;
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
line = ` ${action.name}`;
|
|
448
|
+
}
|
|
449
|
+
this.addChild(new Text(line, 0, 0));
|
|
450
|
+
});
|
|
451
|
+
this.addChild(new Spacer(1));
|
|
452
|
+
// Add bottom border
|
|
453
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
454
|
+
}
|
|
455
|
+
handleSelect(action) {
|
|
456
|
+
this.onSelectCallback(action);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const initCommand: ({
|
|
2
|
+
export declare const initCommand: ({ modelManager, tokenCounter, workspace, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=init-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../source/commands/init-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../source/commands/init-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9D,eAAO,MAAM,WAAW,GAAI,4CAIzB,cAAc,KAAG,WAkDnB,CAAC"}
|