@travisennis/acai 0.0.6 → 0.0.8
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 +225 -39
- package/dist/agent/index.d.ts +30 -21
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +237 -198
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -18
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/add-directory/index.js +50 -0
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +1 -7
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/copy/index.js +39 -0
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/exit/index.d.ts +10 -0
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +65 -147
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/handoff/utils.js +123 -0
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/help/index.d.ts +3 -0
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +6 -14
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +40 -200
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +17 -27
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +2 -15
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/list-tools/index.js +89 -0
- package/dist/commands/manager.d.ts +2 -9
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +38 -83
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/model/index.js +182 -0
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/paste/index.d.ts +3 -0
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/paste/index.js +94 -0
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +3 -35
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +8 -11
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -10
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +4 -51
- package/dist/commands/types.d.ts +2 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +36 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -60
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +18 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +119 -81
- package/dist/formatting.d.ts +46 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +94 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -177
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts +9 -8
- 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 +10 -9
- 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 +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -28
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +148 -139
- package/dist/models/providers.d.ts +6 -16
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +8 -58
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +8 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +155 -177
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -6
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +266 -83
- package/dist/{messages.d.ts → sessions/manager.d.ts} +13 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +126 -16
- package/dist/skills.d.ts +16 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +233 -0
- package/dist/terminal/control.d.ts +56 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +111 -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 -26
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -53
- 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 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- 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/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +11 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +189 -81
- package/dist/tools/directory-tree.d.ts +9 -13
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +90 -60
- package/dist/tools/dynamic-tool-loader.d.ts +22 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +41 -46
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +22 -66
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +78 -109
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -93
- package/dist/tools/index.d.ts +202 -167
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -273
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +52 -76
- package/dist/tools/save-file.d.ts +8 -8
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +42 -53
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -32
- package/dist/tools/types.d.ts +5 -21
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/assistant-message.js +1 -1
- 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 +87 -0
- package/dist/tui/components/editor.d.ts +61 -7
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +630 -127
- package/dist/tui/components/footer.d.ts +19 -18
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +90 -185
- 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.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +6 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +8 -3
- package/dist/tui/components/markdown.d.ts +31 -27
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +131 -67
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -37
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -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 +66 -0
- package/dist/tui/components/select-list.d.ts +12 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +73 -32
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- 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/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +7 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +81 -85
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +12 -6
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +7 -3
- package/dist/tui/terminal.d.ts +4 -3
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +43 -49
- package/dist/tui/tui.d.ts +3 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +58 -43
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +80 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- 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/{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/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +2 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +24 -0
- package/package.json +31 -29
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/add-directory-command.js +0 -85
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -79
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -64
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -183
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/copy-command.js +0 -80
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -88
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -61
- package/dist/commands/exit-command.d.ts +0 -13
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -46
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -121
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.js +0 -202
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -213
- package/dist/commands/help-command.d.ts +0 -3
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -98
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.js +0 -124
- package/dist/commands/model-command.d.ts +0 -25
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/model-command.js +0 -340
- package/dist/commands/paste-command.d.ts +0 -3
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/paste-command.js +0 -277
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -161
- package/dist/commands/prompt-command.d.ts +0 -3
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -280
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -135
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -42
- package/dist/messages.d.ts.map +0 -1
- 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 -58
- 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 -9
- package/dist/repl/project-status-line.d.ts +0 -2
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -31
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- 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 -368
- 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 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -118
- 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 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/tokens/threshold.d.ts +0 -35
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -85
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -281
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -103
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -167
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -70
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -25
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -150
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -58
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -139
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -133
- package/dist/tui/components/prompt-status.d.ts +0 -16
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -21
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- package/dist/utils/zod-utils.js +0 -7
- /package/dist/{terminal → commands/add-directory}/types.js +0 -0
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
package/dist/repl.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { isRecord } from "@travisennis/stdlib/typeguards";
|
|
2
|
-
import { runManualLoop } from "./agent/manual-loop.js";
|
|
3
|
-
import { config as configManager } from "./config.js";
|
|
4
|
-
import { formatDuration } from "./formatting.js";
|
|
5
|
-
import { logger } from "./logger.js";
|
|
6
|
-
import { PromptError, processPrompt } from "./mentions.js";
|
|
7
|
-
import { systemPrompt } from "./prompts.js";
|
|
8
|
-
import { displayToolUse } from "./repl/display-tool-use.js";
|
|
9
|
-
import { getPromptHeader } from "./repl/get-prompt-header.js";
|
|
10
|
-
import { ReplPrompt } from "./repl/prompt.js";
|
|
11
|
-
import { toolCallRepair } from "./repl/tool-call-repair.js";
|
|
12
|
-
import style from "./terminal/style.js";
|
|
13
|
-
import { initAgents, initTools } from "./tools/index.js";
|
|
14
|
-
export class Repl {
|
|
15
|
-
options;
|
|
16
|
-
showLastMessage;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.options = options;
|
|
19
|
-
this.showLastMessage = options.showLastMessage;
|
|
20
|
-
}
|
|
21
|
-
async run() {
|
|
22
|
-
const { config, promptManager, terminal, modelManager, tokenTracker, messageHistory, commands, tokenCounter, promptHistory, } = this.options;
|
|
23
|
-
logger.info(config, "Config:");
|
|
24
|
-
terminal.displayWelcome();
|
|
25
|
-
let currentContextWindow = 0;
|
|
26
|
-
messageHistory.on("clear-history", () => {
|
|
27
|
-
currentContextWindow = 0;
|
|
28
|
-
});
|
|
29
|
-
// Initialize tools once outside the loop - all models support tool calling
|
|
30
|
-
const coreTools = await initTools({
|
|
31
|
-
tokenCounter,
|
|
32
|
-
workspace: this.options.workspace,
|
|
33
|
-
modelManager,
|
|
34
|
-
tokenTracker,
|
|
35
|
-
});
|
|
36
|
-
const agentTools = await initAgents({
|
|
37
|
-
terminal,
|
|
38
|
-
modelManager,
|
|
39
|
-
tokenTracker,
|
|
40
|
-
tokenCounter,
|
|
41
|
-
workspace: this.options.workspace,
|
|
42
|
-
});
|
|
43
|
-
const completeToolDefs = {
|
|
44
|
-
...coreTools.toolDefs,
|
|
45
|
-
...agentTools.toolDefs,
|
|
46
|
-
};
|
|
47
|
-
const tools = {
|
|
48
|
-
toolDefs: completeToolDefs,
|
|
49
|
-
executors: new Map([...coreTools.executors, ...agentTools.executors]),
|
|
50
|
-
};
|
|
51
|
-
let currentAbortController = null;
|
|
52
|
-
// Handle Ctrl+C (SIGINT) as a fallback when not in raw mode
|
|
53
|
-
process.on("SIGINT", () => {
|
|
54
|
-
currentAbortController?.abort();
|
|
55
|
-
});
|
|
56
|
-
while (true) {
|
|
57
|
-
currentAbortController = new AbortController();
|
|
58
|
-
const { signal } = currentAbortController;
|
|
59
|
-
const langModel = modelManager.getModel("repl");
|
|
60
|
-
const modelConfig = modelManager.getModelMetadata("repl");
|
|
61
|
-
// agent header/status line
|
|
62
|
-
await getPromptHeader({
|
|
63
|
-
terminal,
|
|
64
|
-
modelId: langModel.modelId,
|
|
65
|
-
contextWindow: modelConfig.contextWindow,
|
|
66
|
-
currentContextWindow,
|
|
67
|
-
});
|
|
68
|
-
const projectConfig = await configManager.readProjectConfig();
|
|
69
|
-
// Display last message when continuing/resuming a conversation
|
|
70
|
-
if (this.showLastMessage) {
|
|
71
|
-
const lastMessage = messageHistory.getLastMessage();
|
|
72
|
-
if (lastMessage) {
|
|
73
|
-
terminal.lineBreak();
|
|
74
|
-
terminal.writeln(style.dim("Continuing conversation:"));
|
|
75
|
-
terminal.display(lastMessage);
|
|
76
|
-
terminal.lineBreak();
|
|
77
|
-
terminal.hr();
|
|
78
|
-
}
|
|
79
|
-
// don't show the last message after showing it once
|
|
80
|
-
this.showLastMessage = false;
|
|
81
|
-
}
|
|
82
|
-
if (!promptManager.isPending()) {
|
|
83
|
-
// For interactive input
|
|
84
|
-
const prompt = new ReplPrompt({
|
|
85
|
-
commands,
|
|
86
|
-
history: promptHistory,
|
|
87
|
-
workspace: this.options.workspace,
|
|
88
|
-
});
|
|
89
|
-
const userInput = await prompt.input();
|
|
90
|
-
const pasteStore = prompt.getPasteStore();
|
|
91
|
-
prompt.close();
|
|
92
|
-
prompt.resetPasteStore();
|
|
93
|
-
terminal.startProgress();
|
|
94
|
-
// see if the userInput contains a command
|
|
95
|
-
const commandResult = await commands.handle({ userInput });
|
|
96
|
-
if (commandResult.break) {
|
|
97
|
-
terminal.stopProgress();
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (commandResult.continue) {
|
|
101
|
-
terminal.stopProgress();
|
|
102
|
-
terminal.lineBreak();
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (!userInput.trim()) {
|
|
106
|
-
terminal.stopProgress();
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
// if there is no pending prompt then use the user's input. otherwise, the prompt was loaded from a command
|
|
110
|
-
if (!promptManager.isPending()) {
|
|
111
|
-
try {
|
|
112
|
-
const processedPrompt = await processPrompt(userInput, {
|
|
113
|
-
baseDir: process.cwd(),
|
|
114
|
-
model: modelConfig,
|
|
115
|
-
pasteStore,
|
|
116
|
-
});
|
|
117
|
-
for (const context of processedPrompt.context) {
|
|
118
|
-
promptManager.addContext(context);
|
|
119
|
-
}
|
|
120
|
-
promptManager.set(processedPrompt.message);
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
if (error instanceof PromptError) {
|
|
124
|
-
terminal.error(`Prompt processing failed: ${error.message}`);
|
|
125
|
-
if (error.cause &&
|
|
126
|
-
typeof error.cause === "object" &&
|
|
127
|
-
"command" in error.cause &&
|
|
128
|
-
typeof error.cause.command === "string") {
|
|
129
|
-
terminal.error(`Command: ${error.cause.command}`);
|
|
130
|
-
}
|
|
131
|
-
terminal.lineBreak();
|
|
132
|
-
terminal.stopProgress();
|
|
133
|
-
continue; // Continue the REPL loop
|
|
134
|
-
}
|
|
135
|
-
throw error; // Re-throw other errors
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
promptHistory.push(promptManager.get());
|
|
140
|
-
}
|
|
141
|
-
terminal.lineBreak();
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
terminal.startProgress();
|
|
145
|
-
}
|
|
146
|
-
const start = performance.now();
|
|
147
|
-
// flag to see if the user prompt has added context
|
|
148
|
-
const hasAddedContext = promptManager.hasContext();
|
|
149
|
-
if (hasAddedContext) {
|
|
150
|
-
const contextTokenCount = promptManager.getContextTokenCount();
|
|
151
|
-
terminal.info(`Context will be added to prompt. (${contextTokenCount} tokens)`);
|
|
152
|
-
terminal.lineBreak();
|
|
153
|
-
}
|
|
154
|
-
const userPrompt = promptManager.get();
|
|
155
|
-
const userMsg = promptManager.getUserMessage();
|
|
156
|
-
messageHistory.appendUserMessage(userMsg);
|
|
157
|
-
const finalSystemPrompt = await systemPrompt();
|
|
158
|
-
try {
|
|
159
|
-
const { toolDefs, executors } = tools;
|
|
160
|
-
const result = await runManualLoop({
|
|
161
|
-
modelManager,
|
|
162
|
-
terminal,
|
|
163
|
-
messageHistory,
|
|
164
|
-
systemPrompt: finalSystemPrompt,
|
|
165
|
-
input: userPrompt,
|
|
166
|
-
toolDefs,
|
|
167
|
-
executors,
|
|
168
|
-
maxIterations: projectConfig.loop.maxIterations,
|
|
169
|
-
abortSignal: signal,
|
|
170
|
-
toolCallRepair: toolCallRepair(modelManager),
|
|
171
|
-
});
|
|
172
|
-
const stop = performance.now();
|
|
173
|
-
terminal.hr();
|
|
174
|
-
// Notify if configured in project config (acai.json)
|
|
175
|
-
if (projectConfig.notify) {
|
|
176
|
-
terminal.alert();
|
|
177
|
-
}
|
|
178
|
-
// Create a more visual representation of steps/tool usage
|
|
179
|
-
displayToolUse(result, terminal);
|
|
180
|
-
// Show time spend on this prompt
|
|
181
|
-
terminal.writeln(style.dim(`Time: ${formatDuration(stop - start)}`));
|
|
182
|
-
const total = result.totalUsage;
|
|
183
|
-
const inputTokens = total.inputTokens;
|
|
184
|
-
const outputTokens = total.outputTokens;
|
|
185
|
-
const cachedInputTokens = total.cachedInputTokens;
|
|
186
|
-
const tokenSummary = `Tokens: ↑ ${inputTokens} (${cachedInputTokens}) ↓ ${outputTokens}`;
|
|
187
|
-
terminal.writeln(style.dim(tokenSummary));
|
|
188
|
-
const inputCost = modelConfig.costPerInputToken * inputTokens;
|
|
189
|
-
const outputCost = modelConfig.costPerOutputToken * outputTokens;
|
|
190
|
-
terminal.writeln(style.dim(`Cost: $${(inputCost + outputCost).toFixed(2)}`));
|
|
191
|
-
// Track aggregate usage across all steps when available
|
|
192
|
-
tokenTracker.trackUsage("repl", total);
|
|
193
|
-
// Derive current context window from final step usage
|
|
194
|
-
currentContextWindow = result.usage.totalTokens;
|
|
195
|
-
messageHistory.save();
|
|
196
|
-
terminal.hr();
|
|
197
|
-
terminal.lineBreak();
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
if (isRecord(e) && isRecord(e["data"]) && "error" in e["data"]) {
|
|
201
|
-
terminal.error(e["data"]["error"].message);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
terminal.error(e.message.length > 100
|
|
205
|
-
? `${e.message.slice(0, 100)}...`
|
|
206
|
-
: e.message);
|
|
207
|
-
}
|
|
208
|
-
terminal.lineBreak();
|
|
209
|
-
if (e instanceof Error) {
|
|
210
|
-
logger.error(e);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
logger.error(JSON.stringify(e, null, 2));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Standalone checkbox prompt (inquirer-like)
|
|
4
|
-
* - TypeScript version
|
|
5
|
-
*/
|
|
6
|
-
interface TerminalIo {
|
|
7
|
-
stdin: NodeJS.ReadStream;
|
|
8
|
-
stdout: NodeJS.WriteStream;
|
|
9
|
-
}
|
|
10
|
-
interface ChoiceObject<T = unknown> {
|
|
11
|
-
name: string;
|
|
12
|
-
value: T;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
checked?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export type Choice<T = unknown> = string | ChoiceObject<T>;
|
|
17
|
-
export interface CheckboxOptions<T = unknown> {
|
|
18
|
-
message?: string;
|
|
19
|
-
choices: Choice<T>[];
|
|
20
|
-
initial?: number;
|
|
21
|
-
pageSize?: number;
|
|
22
|
-
loop?: boolean;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
signal?: AbortSignal;
|
|
25
|
-
terminal?: TerminalIo;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Interactive checkbox prompt for selecting multiple options
|
|
29
|
-
* @param options Configuration options for the checkbox prompt
|
|
30
|
-
* @returns Promise resolving to array of selected values
|
|
31
|
-
* @throws {PromptCancelError} When user cancels with Ctrl+C
|
|
32
|
-
* @throws {PromptAbortError} When signal is aborted
|
|
33
|
-
*/
|
|
34
|
-
export declare function checkbox<T = unknown>({ message, choices, initial, pageSize, required, signal, terminal, }: CheckboxOptions<T>): Promise<T[]>;
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=checkbox-prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-prompt.d.ts","sourceRoot":"","sources":["../../source/terminal/checkbox-prompt.ts"],"names":[],"mappings":";AACA;;;GAGG;AAoCH,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;CAC5B;AAED,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;AAS3D,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AA4GD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,EAC1C,OAAkB,EAClB,OAAO,EACP,OAAW,EACX,QAAY,EACZ,QAAgB,EAChB,MAAM,EACN,QAA2D,GAC5D,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAiQnC"}
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Standalone checkbox prompt (inquirer-like)
|
|
4
|
-
* - TypeScript version
|
|
5
|
-
*/
|
|
6
|
-
import { isAbortError, isCancelError, PromptAbortError, PromptCancelError, } from "./errors.js";
|
|
7
|
-
const Keys = {
|
|
8
|
-
up: "\x1b[A",
|
|
9
|
-
down: "\x1b[B",
|
|
10
|
-
home: "\x1b[H",
|
|
11
|
-
homeAlt: "\x1b[1~",
|
|
12
|
-
end: "\x1b[F",
|
|
13
|
-
endAlt: "\x1b[4~",
|
|
14
|
-
ctrlC: "\u0003",
|
|
15
|
-
enter: "\r",
|
|
16
|
-
newline: "\n",
|
|
17
|
-
backspace: "\x7f",
|
|
18
|
-
backspaceAlt: "\b",
|
|
19
|
-
};
|
|
20
|
-
const ANSI = {
|
|
21
|
-
hideCursor: "\x1b[?25l",
|
|
22
|
-
showCursor: "\x1b[?25h",
|
|
23
|
-
clearLine: "\x1b[2K",
|
|
24
|
-
carriageReturn: "\r",
|
|
25
|
-
moveToStart: "\x1b[0G",
|
|
26
|
-
clearFromCursor: "\x1b[0J",
|
|
27
|
-
moveUp: "\x1b[1A",
|
|
28
|
-
cyan: "\x1b[36m",
|
|
29
|
-
dim: "\x1b[2m",
|
|
30
|
-
reset: "\x1b[0m",
|
|
31
|
-
};
|
|
32
|
-
function normalizeChoice(choice) {
|
|
33
|
-
if (typeof choice === "string") {
|
|
34
|
-
return {
|
|
35
|
-
name: choice,
|
|
36
|
-
value: choice,
|
|
37
|
-
disabled: false,
|
|
38
|
-
checked: false,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const { name, value, disabled = false, checked = false } = choice;
|
|
42
|
-
return { name, value, disabled, checked };
|
|
43
|
-
}
|
|
44
|
-
function updatePageStart(pointerIndex, pageSize, totalItems) {
|
|
45
|
-
const currentPage = Math.floor(pointerIndex / pageSize);
|
|
46
|
-
const pageStart = currentPage * pageSize;
|
|
47
|
-
return Math.max(0, Math.min(pageStart, Math.max(0, totalItems - pageSize)));
|
|
48
|
-
}
|
|
49
|
-
function findNextEnabledIndex(choices, startIndex, direction) {
|
|
50
|
-
const len = choices.length;
|
|
51
|
-
let index = startIndex;
|
|
52
|
-
for (let i = 0; i < len; i++) {
|
|
53
|
-
index = (index + direction + len) % len;
|
|
54
|
-
if (!choices[index].disabled) {
|
|
55
|
-
return index;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return startIndex;
|
|
59
|
-
}
|
|
60
|
-
function findFirstEnabledIndex(choices) {
|
|
61
|
-
for (let i = 0; i < choices.length; i++) {
|
|
62
|
-
if (!choices[i].disabled) {
|
|
63
|
-
return i;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return 0;
|
|
67
|
-
}
|
|
68
|
-
function findLastEnabledIndex(choices) {
|
|
69
|
-
for (let i = choices.length - 1; i >= 0; i--) {
|
|
70
|
-
if (!choices[i].disabled) {
|
|
71
|
-
return i;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return choices.length - 1;
|
|
75
|
-
}
|
|
76
|
-
function render(choices, pointerIndex, pageStart, pageSize, prompt, typed, requiredError = false) {
|
|
77
|
-
const visible = choices.slice(pageStart, pageStart + pageSize);
|
|
78
|
-
const lines = [];
|
|
79
|
-
lines.push(`${prompt}${typed ? ` (search: ${typed})` : ""}`);
|
|
80
|
-
if (requiredError) {
|
|
81
|
-
lines.push(`${ANSI.dim}At least one option must be selected${ANSI.reset}`);
|
|
82
|
-
}
|
|
83
|
-
for (let i = 0; i < visible.length; i++) {
|
|
84
|
-
const actualIndex = pageStart + i;
|
|
85
|
-
const ch = visible[i];
|
|
86
|
-
const prefix = actualIndex === pointerIndex ? "›" : " ";
|
|
87
|
-
const checkbox = ch.checked ? "[x]" : "[ ]";
|
|
88
|
-
if (ch.disabled) {
|
|
89
|
-
lines.push(` ${prefix} ${checkbox} ${ch.name} (disabled)`);
|
|
90
|
-
}
|
|
91
|
-
else if (actualIndex === pointerIndex) {
|
|
92
|
-
lines.push(`${ANSI.cyan} ${prefix} ${checkbox} ${ch.name}${ANSI.reset}`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
lines.push(` ${prefix} ${checkbox} ${ch.name}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (choices.length > pageSize) {
|
|
99
|
-
const pageCount = Math.ceil(choices.length / pageSize);
|
|
100
|
-
const currentPage = Math.ceil(pageStart / pageSize) + 1;
|
|
101
|
-
lines.push(`${ANSI.dim}Page ${currentPage}/${pageCount}${ANSI.reset}`);
|
|
102
|
-
}
|
|
103
|
-
// Add keyboard shortcuts help
|
|
104
|
-
lines.push("");
|
|
105
|
-
lines.push(`${ANSI.dim}Controls: ↑↓ move, space toggle, a select all, i invert, enter confirm, ctrl+c cancel${ANSI.reset}`);
|
|
106
|
-
return lines.join("\n");
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Interactive checkbox prompt for selecting multiple options
|
|
110
|
-
* @param options Configuration options for the checkbox prompt
|
|
111
|
-
* @returns Promise resolving to array of selected values
|
|
112
|
-
* @throws {PromptCancelError} When user cancels with Ctrl+C
|
|
113
|
-
* @throws {PromptAbortError} When signal is aborted
|
|
114
|
-
*/
|
|
115
|
-
export async function checkbox({ message = "Select", choices, initial = 0, pageSize = 7, required = false, signal, terminal = { stdin: process.stdin, stdout: process.stdout }, }) {
|
|
116
|
-
if (!Array.isArray(choices) || choices.length === 0) {
|
|
117
|
-
throw new Error("choices must be a non-empty array");
|
|
118
|
-
}
|
|
119
|
-
const normalized = choices.map(normalizeChoice);
|
|
120
|
-
const hasEnabledChoice = normalized.some((ch) => !ch.disabled);
|
|
121
|
-
if (!hasEnabledChoice) {
|
|
122
|
-
throw new Error("At least one choice must be enabled");
|
|
123
|
-
}
|
|
124
|
-
let pointer = Math.max(0, Math.min(Math.floor(initial ?? 0), normalized.length - 1));
|
|
125
|
-
if (normalized[pointer].disabled) {
|
|
126
|
-
pointer = findNextEnabledIndex(normalized, pointer, 1);
|
|
127
|
-
}
|
|
128
|
-
let pageStart = updatePageStart(pointer, pageSize, normalized.length);
|
|
129
|
-
const { stdin, stdout } = terminal;
|
|
130
|
-
if (!stdin.isTTY) {
|
|
131
|
-
throw new Error("TTY required");
|
|
132
|
-
}
|
|
133
|
-
stdin.setRawMode(true);
|
|
134
|
-
stdin.resume();
|
|
135
|
-
stdin.setEncoding("utf8");
|
|
136
|
-
let searchBuffer = "";
|
|
137
|
-
let searchTimer = null;
|
|
138
|
-
let requiredError = false;
|
|
139
|
-
const resetSearchBuffer = () => {
|
|
140
|
-
if (searchTimer)
|
|
141
|
-
clearTimeout(searchTimer);
|
|
142
|
-
searchTimer = setTimeout(() => {
|
|
143
|
-
searchBuffer = "";
|
|
144
|
-
}, 800);
|
|
145
|
-
};
|
|
146
|
-
let previousOutputLines = 0;
|
|
147
|
-
function clearPreviousOutput(lineCount) {
|
|
148
|
-
for (let i = 0; i < lineCount; i++) {
|
|
149
|
-
stdout.write(`${ANSI.moveUp}${ANSI.clearLine}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function renderToScreen() {
|
|
153
|
-
// Clear current line and move to start
|
|
154
|
-
stdout.write(ANSI.clearLine);
|
|
155
|
-
stdout.write(ANSI.moveToStart);
|
|
156
|
-
// Clear from cursor to end of screen to remove any existing output below
|
|
157
|
-
stdout.write(ANSI.clearFromCursor);
|
|
158
|
-
// Clear previous output by moving up and clearing lines
|
|
159
|
-
clearPreviousOutput(previousOutputLines);
|
|
160
|
-
const out = render(normalized, pointer, pageStart, pageSize, message, searchBuffer, requiredError);
|
|
161
|
-
// Count lines in current output
|
|
162
|
-
previousOutputLines = out.split("\n").length;
|
|
163
|
-
stdout.write(`${out}\n`);
|
|
164
|
-
}
|
|
165
|
-
function move(delta) {
|
|
166
|
-
pointer = findNextEnabledIndex(normalized, pointer, delta);
|
|
167
|
-
pageStart = updatePageStart(pointer, pageSize, normalized.length);
|
|
168
|
-
renderToScreen();
|
|
169
|
-
}
|
|
170
|
-
function jumpToIndexStartingWith(prefix) {
|
|
171
|
-
const start = (pointer + 1) % normalized.length;
|
|
172
|
-
const lowerPref = prefix.toLowerCase();
|
|
173
|
-
for (let i = 0; i < normalized.length; i++) {
|
|
174
|
-
const idx = (start + i) % normalized.length;
|
|
175
|
-
if (normalized[idx].disabled)
|
|
176
|
-
continue;
|
|
177
|
-
if (normalized[idx].name.toLowerCase().startsWith(lowerPref)) {
|
|
178
|
-
pointer = idx;
|
|
179
|
-
pageStart = updatePageStart(pointer, pageSize, normalized.length);
|
|
180
|
-
renderToScreen();
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
function toggleCurrent() {
|
|
187
|
-
if (!normalized[pointer].disabled) {
|
|
188
|
-
normalized[pointer].checked = !normalized[pointer].checked;
|
|
189
|
-
renderToScreen();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function toggleAll() {
|
|
193
|
-
const allChecked = normalized.every((ch) => ch.disabled || ch.checked);
|
|
194
|
-
normalized.forEach((ch) => {
|
|
195
|
-
if (!ch.disabled) {
|
|
196
|
-
ch.checked = !allChecked;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
renderToScreen();
|
|
200
|
-
}
|
|
201
|
-
function invertSelection() {
|
|
202
|
-
normalized.forEach((ch) => {
|
|
203
|
-
if (!ch.disabled) {
|
|
204
|
-
ch.checked = !ch.checked;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
renderToScreen();
|
|
208
|
-
}
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
210
|
-
let resolved = false;
|
|
211
|
-
let cleanupCalled = false;
|
|
212
|
-
function cleanup() {
|
|
213
|
-
if (cleanupCalled)
|
|
214
|
-
return;
|
|
215
|
-
cleanupCalled = true;
|
|
216
|
-
stdin.setRawMode(false);
|
|
217
|
-
stdin.pause();
|
|
218
|
-
stdin.removeListener("data", onData);
|
|
219
|
-
if (searchTimer)
|
|
220
|
-
clearTimeout(searchTimer);
|
|
221
|
-
if (signal && abortHandler) {
|
|
222
|
-
signal.removeEventListener("abort", abortHandler);
|
|
223
|
-
}
|
|
224
|
-
stdout.write(ANSI.showCursor);
|
|
225
|
-
}
|
|
226
|
-
const abortHandler = signal
|
|
227
|
-
? () => {
|
|
228
|
-
cleanup();
|
|
229
|
-
reject(new PromptAbortError());
|
|
230
|
-
}
|
|
231
|
-
: null;
|
|
232
|
-
if (signal && abortHandler) {
|
|
233
|
-
signal.addEventListener("abort", abortHandler);
|
|
234
|
-
}
|
|
235
|
-
function onData(key) {
|
|
236
|
-
if (key === Keys.ctrlC) {
|
|
237
|
-
cleanup();
|
|
238
|
-
stdout.write("\n");
|
|
239
|
-
reject(new PromptCancelError());
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (key === Keys.enter || key === Keys.newline) {
|
|
243
|
-
const selected = normalized.filter((ch) => ch.checked && !ch.disabled);
|
|
244
|
-
if (required && selected.length === 0) {
|
|
245
|
-
// Show error but don't exit
|
|
246
|
-
requiredError = true;
|
|
247
|
-
renderToScreen();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
requiredError = false;
|
|
251
|
-
resolved = true;
|
|
252
|
-
cleanup();
|
|
253
|
-
stdout.write("\n");
|
|
254
|
-
resolve(selected.map((ch) => ch.value));
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (key === Keys.up) {
|
|
258
|
-
move(-1);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
if (key === Keys.down) {
|
|
262
|
-
move(1);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (key === Keys.home || key === Keys.homeAlt) {
|
|
266
|
-
pointer = findFirstEnabledIndex(normalized);
|
|
267
|
-
pageStart = updatePageStart(pointer, pageSize, normalized.length);
|
|
268
|
-
renderToScreen();
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (key === Keys.end || key === Keys.endAlt) {
|
|
272
|
-
pointer = findLastEnabledIndex(normalized);
|
|
273
|
-
pageStart = updatePageStart(pointer, pageSize, normalized.length);
|
|
274
|
-
renderToScreen();
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
if (key === Keys.backspace || key === Keys.backspaceAlt) {
|
|
278
|
-
if (searchBuffer.length > 0) {
|
|
279
|
-
searchBuffer = searchBuffer.slice(0, -1);
|
|
280
|
-
if (searchBuffer.length === 0)
|
|
281
|
-
resetSearchBuffer();
|
|
282
|
-
renderToScreen();
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
if (key === " ") {
|
|
287
|
-
toggleCurrent();
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
if (key === "a") {
|
|
291
|
-
toggleAll();
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (key === "i") {
|
|
295
|
-
invertSelection();
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
if (key && key >= " " && key <= "~") {
|
|
299
|
-
searchBuffer += key;
|
|
300
|
-
resetSearchBuffer();
|
|
301
|
-
const found = jumpToIndexStartingWith(searchBuffer);
|
|
302
|
-
if (!found) {
|
|
303
|
-
searchBuffer = key;
|
|
304
|
-
resetSearchBuffer();
|
|
305
|
-
jumpToIndexStartingWith(searchBuffer);
|
|
306
|
-
}
|
|
307
|
-
renderToScreen();
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
try {
|
|
312
|
-
stdout.write(ANSI.hideCursor);
|
|
313
|
-
// Reset previous output lines counter to ensure clean start
|
|
314
|
-
previousOutputLines = 0;
|
|
315
|
-
renderToScreen();
|
|
316
|
-
stdin.on("data", onData);
|
|
317
|
-
const exitHandler = () => {
|
|
318
|
-
if (!resolved) {
|
|
319
|
-
cleanup();
|
|
320
|
-
stdout.write("\n");
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
process.on("exit", exitHandler);
|
|
324
|
-
}
|
|
325
|
-
catch (error) {
|
|
326
|
-
cleanup();
|
|
327
|
-
throw error;
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
// Quick test when run directly
|
|
332
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
333
|
-
(async () => {
|
|
334
|
-
try {
|
|
335
|
-
const res = await checkbox({
|
|
336
|
-
message: "Pick fruits",
|
|
337
|
-
choices: [
|
|
338
|
-
"Apple",
|
|
339
|
-
"Banana",
|
|
340
|
-
{ name: "Date", value: "date", checked: true },
|
|
341
|
-
"Elderberry",
|
|
342
|
-
{ name: "Fig", value: "fig", disabled: true },
|
|
343
|
-
"Grapes",
|
|
344
|
-
"Honeydew",
|
|
345
|
-
"Orange",
|
|
346
|
-
],
|
|
347
|
-
pageSize: 3,
|
|
348
|
-
initial: 0,
|
|
349
|
-
});
|
|
350
|
-
console.info("You picked:", res);
|
|
351
|
-
process.exit(0);
|
|
352
|
-
}
|
|
353
|
-
catch (err) {
|
|
354
|
-
if (isCancelError(err)) {
|
|
355
|
-
console.error("Cancelled");
|
|
356
|
-
process.exit(2);
|
|
357
|
-
}
|
|
358
|
-
else if (isAbortError(err)) {
|
|
359
|
-
console.error("Aborted");
|
|
360
|
-
process.exit(3);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
console.error(err);
|
|
364
|
-
process.exit(1);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
})();
|
|
368
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface EditorPromptOptions {
|
|
2
|
-
message: string;
|
|
3
|
-
default?: string;
|
|
4
|
-
postfix?: string;
|
|
5
|
-
editor?: string;
|
|
6
|
-
skipPrompt?: boolean;
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
}
|
|
9
|
-
export declare function editor(options: EditorPromptOptions): Promise<string>;
|
|
10
|
-
//# sourceMappingURL=editor-prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-prompt.d.ts","sourceRoot":"","sources":["../../source/terminal/editor-prompt.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgF1E"}
|