@travisennis/acai 0.0.4 → 0.0.6
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 +229 -8
- package/dist/agent/index.d.ts +119 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +406 -0
- package/dist/agent/manual-loop.d.ts +41 -0
- package/dist/agent/manual-loop.d.ts.map +1 -0
- package/dist/agent/manual-loop.js +278 -0
- package/dist/api/exa/index.d.ts +177 -0
- package/dist/api/exa/index.d.ts.map +1 -0
- package/dist/api/exa/index.js +439 -0
- package/dist/cli.d.ts +5 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +27 -33
- 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 +85 -0
- package/dist/commands/application-log-command.d.ts +1 -0
- package/dist/commands/application-log-command.d.ts.map +1 -0
- package/dist/commands/application-log-command.js +39 -3
- package/dist/commands/clear-command.d.ts +1 -0
- package/dist/commands/clear-command.d.ts.map +1 -0
- package/dist/commands/clear-command.js +10 -3
- package/dist/commands/compact-command.d.ts +1 -0
- package/dist/commands/compact-command.d.ts.map +1 -0
- package/dist/commands/compact-command.js +16 -3
- 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 +183 -0
- package/dist/commands/copy-command.d.ts +1 -0
- package/dist/commands/copy-command.d.ts.map +1 -0
- package/dist/commands/copy-command.js +31 -2
- package/dist/commands/edit-command.d.ts +1 -0
- package/dist/commands/edit-command.d.ts.map +1 -0
- package/dist/commands/edit-command.js +40 -5
- package/dist/commands/edit-prompt-command.d.ts +2 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -0
- package/dist/commands/edit-prompt-command.js +43 -7
- package/dist/commands/exit-command.d.ts +13 -2
- package/dist/commands/exit-command.d.ts.map +1 -0
- package/dist/commands/exit-command.js +34 -2
- package/dist/commands/files-command.d.ts +1 -0
- package/dist/commands/files-command.d.ts.map +1 -0
- package/dist/commands/files-command.js +66 -8
- package/dist/commands/generate-rules-command.d.ts +1 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -0
- package/dist/commands/generate-rules-command.js +315 -4
- 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 +202 -0
- package/dist/commands/health-command.d.ts +3 -1
- package/dist/commands/health-command.d.ts.map +1 -0
- package/dist/commands/health-command.js +160 -6
- package/dist/commands/help-command.d.ts +1 -0
- package/dist/commands/help-command.d.ts.map +1 -0
- package/dist/commands/help-command.js +30 -3
- 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 +534 -0
- package/dist/commands/init-command.d.ts +2 -1
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +56 -20
- package/dist/commands/last-log-command.d.ts +1 -0
- package/dist/commands/last-log-command.d.ts.map +1 -0
- package/dist/commands/last-log-command.js +39 -17
- 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 +48 -0
- package/dist/commands/list-tools-command.d.ts +3 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -0
- package/dist/commands/list-tools-command.js +124 -0
- package/dist/commands/manager.d.ts +20 -3
- package/dist/commands/manager.d.ts.map +1 -0
- package/dist/commands/manager.js +123 -26
- package/dist/commands/model-command.d.ts +23 -0
- package/dist/commands/model-command.d.ts.map +1 -0
- package/dist/commands/model-command.js +261 -5
- package/dist/commands/paste-command.d.ts +1 -0
- package/dist/commands/paste-command.d.ts.map +1 -0
- package/dist/commands/paste-command.js +98 -5
- 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 +161 -0
- package/dist/commands/prompt-command.d.ts +2 -1
- package/dist/commands/prompt-command.d.ts.map +1 -0
- package/dist/commands/prompt-command.js +178 -9
- 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 +87 -0
- package/dist/commands/reset-command.d.ts +2 -1
- package/dist/commands/reset-command.d.ts.map +1 -0
- package/dist/commands/reset-command.js +14 -3
- package/dist/commands/rules-command.d.ts +1 -0
- package/dist/commands/rules-command.d.ts.map +1 -0
- package/dist/commands/rules-command.js +70 -3
- package/dist/commands/save-command.d.ts +1 -0
- package/dist/commands/save-command.d.ts.map +1 -0
- package/dist/commands/save-command.js +13 -1
- package/dist/commands/shell-command.d.ts +3 -0
- package/dist/commands/shell-command.d.ts.map +1 -0
- package/dist/commands/shell-command.js +128 -0
- package/dist/commands/types.d.ts +16 -8
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/usage-command.d.ts +1 -0
- package/dist/commands/usage-command.d.ts.map +1 -0
- package/dist/commands/usage-command.js +24 -3
- package/dist/config.d.ts +21 -34
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -15
- package/dist/dedent.d.ts +1 -0
- package/dist/dedent.d.ts.map +1 -0
- package/dist/execution/index.d.ts +112 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +432 -0
- package/dist/formatting.d.ts +107 -10
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +150 -62
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +150 -38
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +6 -1
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +58 -11
- package/dist/messages.d.ts +16 -20
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +89 -72
- package/dist/middleware/audit-message.d.ts +1 -0
- package/dist/middleware/audit-message.d.ts.map +1 -0
- 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 +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/rate-limit.d.ts +1 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/models/ai-config.d.ts +5 -2
- package/dist/models/ai-config.d.ts.map +1 -0
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts +1 -0
- package/dist/models/anthropic-provider.d.ts.map +1 -0
- package/dist/models/anthropic-provider.js +3 -60
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -0
- package/dist/models/google-provider.d.ts +1 -0
- package/dist/models/google-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.d.ts +20 -0
- package/dist/models/groq-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.js +31 -0
- package/dist/models/manager.d.ts +3 -1
- package/dist/models/manager.d.ts.map +1 -0
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts +2 -1
- package/dist/models/openai-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.d.ts +25 -23
- package/dist/models/openrouter-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.js +181 -122
- package/dist/models/providers.d.ts +4 -5
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +7 -3
- package/dist/models/xai-provider.d.ts +1 -0
- package/dist/models/xai-provider.d.ts.map +1 -0
- package/dist/parsing.d.ts +2 -1
- package/dist/parsing.d.ts.map +1 -0
- package/dist/prompts/manager.d.ts +14 -2
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +65 -12
- package/dist/repl/display-tool-messages.d.ts +4 -0
- package/dist/repl/display-tool-messages.d.ts.map +1 -0
- package/dist/repl/display-tool-messages.js +58 -0
- package/dist/repl/display-tool-use.d.ts +14 -0
- package/dist/repl/display-tool-use.d.ts.map +1 -0
- package/dist/repl/display-tool-use.js +63 -0
- package/dist/repl/get-prompt-header.d.ts +8 -0
- package/dist/repl/get-prompt-header.d.ts.map +1 -0
- package/dist/repl/get-prompt-header.js +9 -0
- package/dist/repl/project-status-line.d.ts +2 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +31 -0
- package/dist/repl/prompt.d.ts +21 -0
- package/dist/repl/prompt.d.ts.map +1 -0
- package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
- package/dist/repl/tool-call-repair.d.ts +4 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -0
- package/dist/repl/tool-call-repair.js +54 -0
- package/dist/repl-new.d.ts +53 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +374 -0
- package/dist/repl.d.ts +9 -7
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +142 -378
- package/dist/terminal/ansi-styles.d.ts +77 -0
- package/dist/terminal/ansi-styles.d.ts.map +1 -0
- package/dist/terminal/ansi-styles.js +215 -0
- package/dist/terminal/checkbox-prompt.d.ts +36 -0
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
- package/dist/terminal/checkbox-prompt.js +368 -0
- package/dist/terminal/default-theme.d.ts +6 -0
- package/dist/terminal/default-theme.d.ts.map +1 -0
- package/dist/terminal/default-theme.js +182 -0
- package/dist/terminal/east-asian-width.d.ts +8 -0
- package/dist/terminal/east-asian-width.d.ts.map +1 -0
- package/dist/terminal/east-asian-width.js +409 -0
- package/dist/terminal/editor-prompt.d.ts +10 -0
- package/dist/terminal/editor-prompt.d.ts.map +1 -0
- package/dist/terminal/editor-prompt.js +61 -0
- package/dist/terminal/errors.d.ts +19 -0
- package/dist/terminal/errors.d.ts.map +1 -0
- package/dist/terminal/errors.js +37 -0
- package/dist/terminal/formatting.d.ts +1 -11
- package/dist/terminal/formatting.d.ts.map +1 -0
- package/dist/terminal/formatting.js +4 -20
- package/dist/terminal/highlight/index.d.ts +53 -0
- package/dist/terminal/highlight/index.d.ts.map +1 -0
- package/dist/terminal/highlight/index.js +90 -0
- package/dist/terminal/highlight/theme.d.ts +233 -0
- package/dist/terminal/highlight/theme.d.ts.map +1 -0
- package/dist/terminal/highlight/theme.js +83 -0
- package/dist/terminal/index.d.ts +23 -9
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +136 -126
- package/dist/terminal/input-prompt.d.ts +17 -0
- package/dist/terminal/input-prompt.d.ts.map +1 -0
- package/dist/terminal/input-prompt.js +181 -0
- package/dist/terminal/markdown-utils.d.ts +1 -0
- package/dist/terminal/markdown-utils.d.ts.map +1 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.d.ts.map +1 -0
- package/dist/terminal/markdown.js +20 -12
- package/dist/terminal/search-prompt.d.ts +20 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -0
- package/dist/terminal/search-prompt.js +280 -0
- package/dist/terminal/select-prompt.d.ts +26 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -0
- package/dist/terminal/select-prompt.js +306 -0
- package/dist/terminal/string-width.d.ts +7 -0
- package/dist/terminal/string-width.d.ts.map +1 -0
- package/dist/terminal/string-width.js +61 -0
- package/dist/terminal/strip-ansi.d.ts +2 -0
- package/dist/terminal/strip-ansi.d.ts.map +1 -0
- package/dist/terminal/strip-ansi.js +20 -0
- package/dist/terminal/style.d.ts +191 -0
- package/dist/terminal/style.d.ts.map +1 -0
- package/dist/terminal/style.js +259 -0
- package/dist/terminal/supports-color.d.ts +1 -0
- package/dist/terminal/supports-color.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.d.ts +1 -3
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.js +1 -1
- package/dist/terminal/types.d.ts +1 -37
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.d.ts +8 -0
- package/dist/terminal/wrap-ansi.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.js +190 -0
- package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
- package/dist/tokens/counter.d.ts.map +1 -0
- package/dist/{token-utils.js → tokens/counter.js} +1 -1
- package/dist/tokens/threshold.d.ts +35 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +85 -0
- package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -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 +281 -0
- package/dist/tools/agent.d.ts +19 -7
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +70 -54
- package/dist/tools/bash-utils.d.ts +7 -0
- package/dist/tools/bash-utils.d.ts.map +1 -0
- package/dist/tools/bash-utils.js +220 -0
- package/dist/tools/bash.d.ts +25 -14
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +87 -251
- package/dist/tools/code-interpreter.d.ts +22 -10
- package/dist/tools/code-interpreter.d.ts.map +1 -0
- package/dist/tools/code-interpreter.js +146 -210
- package/dist/tools/delete-file.d.ts +18 -9
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +55 -85
- package/dist/tools/directory-tree.d.ts +26 -6
- package/dist/tools/directory-tree.d.ts.map +1 -0
- package/dist/tools/directory-tree.js +109 -28
- package/dist/tools/dynamic-tool-loader.d.ts +22 -0
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-loader.js +272 -0
- package/dist/tools/dynamic-tool-parser.d.ts +21 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-parser.js +22 -0
- package/dist/tools/edit-file.d.ts +41 -13
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +173 -96
- package/dist/tools/filesystem-utils.d.ts +7 -21
- package/dist/tools/filesystem-utils.d.ts.map +1 -0
- package/dist/tools/filesystem-utils.js +111 -149
- package/dist/tools/git-utils.d.ts +1 -0
- package/dist/tools/git-utils.d.ts.map +1 -0
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +143 -0
- package/dist/tools/grep.d.ts +76 -13
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +420 -135
- package/dist/tools/index.d.ts +207 -133
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +245 -127
- package/dist/tools/llm-edit-fixer.d.ts +25 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +150 -0
- package/dist/tools/move-file.d.ts +20 -7
- package/dist/tools/move-file.d.ts.map +1 -0
- package/dist/tools/move-file.js +43 -29
- package/dist/tools/read-file.d.ts +49 -10
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +79 -67
- package/dist/tools/read-multiple-files.d.ts +19 -7
- package/dist/tools/read-multiple-files.d.ts.map +1 -0
- package/dist/tools/read-multiple-files.js +117 -33
- package/dist/tools/save-file.d.ts +46 -11
- package/dist/tools/save-file.d.ts.map +1 -0
- package/dist/tools/save-file.js +63 -78
- package/dist/tools/think.d.ts +16 -7
- package/dist/tools/think.d.ts.map +1 -0
- package/dist/tools/think.js +34 -22
- package/dist/tools/types.d.ts +18 -11
- package/dist/tools/types.d.ts.map +1 -0
- 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 +15 -6
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +40 -39
- package/dist/tools/web-search.d.ts +17 -7
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +86 -33
- 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/editor.d.ts +51 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +758 -0
- package/dist/tui/components/footer.d.ts +24 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +197 -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 +19 -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 +103 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +533 -0
- package/dist/tui/components/modal.d.ts +40 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +292 -0
- package/dist/tui/components/prompt-status.d.ts +16 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +21 -0
- package/dist/tui/components/select-list.d.ts +22 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +143 -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/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 +30 -0
- package/dist/tui/components/tool-execution.d.ts +17 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +153 -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 +21 -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 +14 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/terminal.d.ts +37 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +104 -0
- package/dist/tui/tui.d.ts +67 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +184 -0
- package/dist/tui/utils.d.ts +19 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +31 -0
- package/dist/utils/filesystem.d.ts +23 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +140 -0
- package/dist/utils/filetype-detection.d.ts +3 -0
- package/dist/utils/filetype-detection.d.ts.map +1 -0
- package/dist/utils/filetype-detection.js +112 -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/utils/glob.d.ts +52 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/glob.js +376 -0
- package/dist/utils/ignore.d.ts +104 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +649 -0
- 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/process.d.ts +3 -2
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +17 -2
- package/dist/utils/zod-utils.d.ts +4 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +34 -32
- package/dist/conversation-analyzer.d.ts +0 -10
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl-prompt.d.ts +0 -14
- package/dist/tools/command-validation.d.ts +0 -11
- package/dist/tools/command-validation.js +0 -45
- /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,4CAI1B,cAAc,KAAG,WA8KnB,CAAC"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { checkbox } from "@inquirer/prompts";
|
|
3
|
-
import { globby } from "globby";
|
|
4
2
|
import { formatFile } from "../formatting.js";
|
|
5
|
-
import {
|
|
3
|
+
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
4
|
+
import style from "../terminal/style.js";
|
|
5
|
+
import { TokenCounter } from "../tokens/counter.js";
|
|
6
|
+
import { Text } from "../tui/index.js";
|
|
7
|
+
import { glob } from "../utils/glob.js";
|
|
6
8
|
export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
7
9
|
return {
|
|
8
10
|
command: "/files",
|
|
9
11
|
description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
|
|
10
|
-
result: "continue",
|
|
11
12
|
getSubCommands: () => Promise.resolve([]),
|
|
12
13
|
execute: async (args) => {
|
|
13
14
|
try {
|
|
14
15
|
let workingFiles = [];
|
|
15
16
|
if (!args || args.length === 0) {
|
|
16
17
|
// Get all files in the current directory
|
|
17
|
-
const foundFiles = await
|
|
18
|
+
const foundFiles = await glob("**/*", { gitignore: true });
|
|
18
19
|
const selectedFiles = await checkbox({
|
|
19
20
|
message: "Select files to include:",
|
|
20
21
|
choices: foundFiles,
|
|
@@ -22,17 +23,17 @@ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
|
22
23
|
});
|
|
23
24
|
if (selectedFiles.length === 0) {
|
|
24
25
|
terminal.warn("No files selected.");
|
|
25
|
-
return;
|
|
26
|
+
return "continue";
|
|
26
27
|
}
|
|
27
28
|
// Process the selected files
|
|
28
29
|
workingFiles = selectedFiles;
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
32
|
const patternList = args.filter(Boolean);
|
|
32
|
-
const foundFiles = await
|
|
33
|
+
const foundFiles = await glob(patternList, { gitignore: true });
|
|
33
34
|
if (foundFiles.length === 0) {
|
|
34
35
|
terminal.warn("No files found matching the pattern(s)");
|
|
35
|
-
return;
|
|
36
|
+
return "continue";
|
|
36
37
|
}
|
|
37
38
|
// Process the selected files
|
|
38
39
|
workingFiles = foundFiles;
|
|
@@ -54,9 +55,66 @@ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
|
54
55
|
}));
|
|
55
56
|
tokenCounter.free();
|
|
56
57
|
terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
|
|
58
|
+
return "continue";
|
|
57
59
|
}
|
|
58
60
|
catch (error) {
|
|
59
61
|
terminal.error(`Error processing file patterns: ${error.message}`);
|
|
62
|
+
return "continue";
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async handle(args, { tui, container, editor, }) {
|
|
66
|
+
try {
|
|
67
|
+
let workingFiles = [];
|
|
68
|
+
if (!args || args.length === 0) {
|
|
69
|
+
// Get all files in the current directory
|
|
70
|
+
const foundFiles = await glob("**/*", { gitignore: true });
|
|
71
|
+
// For TUI mode, we'll just use the first few files
|
|
72
|
+
workingFiles = foundFiles.slice(0, 5);
|
|
73
|
+
if (workingFiles.length === 0) {
|
|
74
|
+
container.addChild(new Text(style.yellow("No files found"), 0, 1));
|
|
75
|
+
tui.requestRender();
|
|
76
|
+
editor.setText("");
|
|
77
|
+
return "continue";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const patternList = args.filter(Boolean);
|
|
82
|
+
const foundFiles = await glob(patternList, { gitignore: true });
|
|
83
|
+
if (foundFiles.length === 0) {
|
|
84
|
+
container.addChild(new Text(style.yellow("No files found matching the pattern(s)"), 1, 0));
|
|
85
|
+
tui.requestRender();
|
|
86
|
+
editor.setText("");
|
|
87
|
+
return "continue";
|
|
88
|
+
}
|
|
89
|
+
// Process the selected files
|
|
90
|
+
workingFiles = foundFiles;
|
|
91
|
+
}
|
|
92
|
+
// Read the content of the files and format them for the next prompt
|
|
93
|
+
const format = modelManager.getModelMetadata("repl").promptFormat;
|
|
94
|
+
let tokenCount = 0;
|
|
95
|
+
const tokenCounter = new TokenCounter();
|
|
96
|
+
await Promise.all(workingFiles.map(async (filePath) => {
|
|
97
|
+
try {
|
|
98
|
+
const content = await readFile(filePath, "utf-8");
|
|
99
|
+
const formattedFile = formatFile(filePath, content, format);
|
|
100
|
+
tokenCount += tokenCounter.count(formattedFile);
|
|
101
|
+
promptManager.addContext(formattedFile);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
container.addChild(new Text(style.red(`Error reading file ${filePath}: ${error.message}`), 1, 0));
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
tokenCounter.free();
|
|
108
|
+
container.addChild(new Text(style.green(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`), 1, 0));
|
|
109
|
+
tui.requestRender();
|
|
110
|
+
editor.setText("");
|
|
111
|
+
return "continue";
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
container.addChild(new Text(style.red(`Error processing file patterns: ${error.message}`), 1, 0));
|
|
115
|
+
tui.requestRender();
|
|
116
|
+
editor.setText("");
|
|
117
|
+
return "continue";
|
|
60
118
|
}
|
|
61
119
|
},
|
|
62
120
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuC9D,eAAO,MAAM,oBAAoB,GAAI,mEAMlC,cAAc,KAAG,WA6JnB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { generateText } from "ai";
|
|
2
|
+
import { config } from "../config.js";
|
|
3
3
|
import { logger } from "../logger.js"; // Import logger
|
|
4
|
+
import { createUserMessage } from "../messages.js";
|
|
5
|
+
import { systemPrompt } from "../prompts.js";
|
|
6
|
+
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
7
|
+
import { getTerminalSize } from "../terminal/formatting.js";
|
|
8
|
+
import style from "../terminal/style.js";
|
|
9
|
+
import { Container, Input, Spacer, Text, } from "../tui/index.js";
|
|
4
10
|
async function _processAndSaveRules(newRules, terminal, config) {
|
|
5
11
|
if (!newRules || newRules.length === 0) {
|
|
6
12
|
terminal.warn("No new generalizable rules were identified.");
|
|
@@ -32,12 +38,11 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
32
38
|
return {
|
|
33
39
|
command: "/generate-rules",
|
|
34
40
|
description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
|
|
35
|
-
result: "continue",
|
|
36
41
|
getSubCommands: () => Promise.resolve([]),
|
|
37
42
|
execute: async () => {
|
|
38
43
|
if (messageHistory.isEmpty()) {
|
|
39
44
|
terminal.writeln("Cannot generate rules from an empty conversation.");
|
|
40
|
-
return;
|
|
45
|
+
return "continue";
|
|
41
46
|
}
|
|
42
47
|
terminal.lineBreak();
|
|
43
48
|
terminal.info("Analyzing conversation to generate rules...");
|
|
@@ -55,7 +60,313 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
55
60
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
56
61
|
terminal.error(`Error generating rules: ${errorMessage}`);
|
|
57
62
|
logger.error(error, "Error during rule generation:");
|
|
63
|
+
return "continue";
|
|
64
|
+
}
|
|
65
|
+
return "continue";
|
|
66
|
+
},
|
|
67
|
+
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
68
|
+
if (messageHistory.isEmpty()) {
|
|
69
|
+
container.addChild(new Text(style.yellow("Cannot generate rules from an empty conversation."), 1, 0));
|
|
70
|
+
tui.requestRender();
|
|
71
|
+
editor.setText("");
|
|
72
|
+
return "continue";
|
|
73
|
+
}
|
|
74
|
+
container.addChild(new Text("Analyzing conversation to generate rules...", 0, 1));
|
|
75
|
+
tui.requestRender();
|
|
76
|
+
try {
|
|
77
|
+
const newRules = await analyzeConversation({
|
|
78
|
+
modelManager,
|
|
79
|
+
messages: messageHistory.get(),
|
|
80
|
+
tokenTracker,
|
|
81
|
+
terminal,
|
|
82
|
+
});
|
|
83
|
+
if (!newRules || newRules.length === 0) {
|
|
84
|
+
container.addChild(new Text(style.yellow("No new generalizable rules were identified."), 2, 0));
|
|
85
|
+
tui.requestRender();
|
|
86
|
+
editor.setText("");
|
|
87
|
+
return "continue";
|
|
88
|
+
}
|
|
89
|
+
// Create rule selector for TUI mode
|
|
90
|
+
const ruleSelector = new RuleSelectorComponent(newRules, async (selectedRules) => {
|
|
91
|
+
// Handle rule selection
|
|
92
|
+
if (selectedRules.length === 0) {
|
|
93
|
+
container.addChild(new Text(style.yellow("No rules selected to save."), 2, 0));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
try {
|
|
97
|
+
const existingRules = await config.readProjectLearnedRulesFile();
|
|
98
|
+
const rulesToAdd = selectedRules.join("\n");
|
|
99
|
+
const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
|
|
100
|
+
? `${existingRules}${rulesToAdd}`
|
|
101
|
+
: `${existingRules}\n${rulesToAdd}`;
|
|
102
|
+
await config.writeProjectLearnedRulesFile(updatedProjectRules);
|
|
103
|
+
container.addChild(new Text(style.green("Selected rules saved to project learned rules."), 2, 0));
|
|
104
|
+
container.addChild(new Text(style.dim("Saved rules:"), 3, 0));
|
|
105
|
+
selectedRules.forEach((rule, index) => {
|
|
106
|
+
container.addChild(new Text(`- ${rule}`, 4 + index, 0));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
container.addChild(new Text(style.red(`Failed to save rules: ${error}`), 2, 0));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Hide selector and show editor again
|
|
114
|
+
hideRuleSelector(inputContainer, editor, tui);
|
|
115
|
+
tui.requestRender();
|
|
116
|
+
}, () => {
|
|
117
|
+
// Cancel selection - just hide selector
|
|
118
|
+
hideRuleSelector(inputContainer, editor, tui);
|
|
119
|
+
tui.requestRender();
|
|
120
|
+
});
|
|
121
|
+
// Replace editor with rule selector
|
|
122
|
+
inputContainer.clear();
|
|
123
|
+
inputContainer.addChild(ruleSelector);
|
|
124
|
+
tui.setFocus(ruleSelector);
|
|
125
|
+
tui.requestRender();
|
|
126
|
+
return "continue";
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
130
|
+
container.addChild(new Text(style.red(`Error generating rules: ${errorMessage}`), 0, 1));
|
|
131
|
+
logger.error(error, "Error during rule generation:");
|
|
132
|
+
tui.requestRender();
|
|
133
|
+
editor.setText("");
|
|
134
|
+
return "continue";
|
|
58
135
|
}
|
|
59
136
|
},
|
|
60
137
|
};
|
|
61
138
|
};
|
|
139
|
+
// Modified System Prompt
|
|
140
|
+
const system = async () => `You are an expert analyst reviewing conversations between a coding agent and a software engineer. Your goal is to identify instances where the engineer corrected the agent's approach or understanding in a way that reveals a *generalizable principle* for improving the agent's future behavior across *different* tasks.
|
|
141
|
+
|
|
142
|
+
**Your Task:**
|
|
143
|
+
1. Analyze the conversation provided.
|
|
144
|
+
2. Identify significant corrections or redirections from the engineer. Ignore minor clarifications or task-specific adjustments.
|
|
145
|
+
3. For each significant correction, infer a *single, concise, broadly applicable, actionable rule* (starting with 'Always' or 'Never') that captures the underlying principle the agent should follow in the future.
|
|
146
|
+
4. Ensure the rule is general enough to be useful in various scenarios, not just the specific context of this conversation.
|
|
147
|
+
5. Provide a brief, illustrative quote or example from the conversation in parentheses after the rule.
|
|
148
|
+
6. List only the inferred rules in Markdown bullet points. Do not include explanations, summaries, or conversational filler.
|
|
149
|
+
|
|
150
|
+
**Crucially, AVOID generating rules that are:**
|
|
151
|
+
- Overly specific to the files, functions, or variables discussed (e.g., "Always check for null in the 'processUserData' function"). Instead, generalize (e.g., "Always validate data from external sources before processing").
|
|
152
|
+
- Merely restatements of the task requirements.
|
|
153
|
+
- Too narrow to be useful outside the immediate context.
|
|
154
|
+
- Related to minor typos or formatting preferences unless they represent a consistent pattern requested by the user.
|
|
155
|
+
|
|
156
|
+
**Good General Rule Examples:**
|
|
157
|
+
<examples>
|
|
158
|
+
- Always ask for clarification if the user's request is ambiguous.
|
|
159
|
+
- Never make assumptions about file paths without confirmation.
|
|
160
|
+
- Always follow the user's explicitly stated formatting preferences.
|
|
161
|
+
- Never provide incomplete code snippets without indicating they are partial.
|
|
162
|
+
- Always check for potential null or undefined values before accessing properties.
|
|
163
|
+
</examples>
|
|
164
|
+
|
|
165
|
+
**Bad Specific Rule Examples (Avoid These):**
|
|
166
|
+
<bad-examples>
|
|
167
|
+
- Always use 'const' instead of 'let' for the 'userId' variable in 'auth.ts'.
|
|
168
|
+
- Never forget to pass the 'config' object to the 'initializeDb' function.
|
|
169
|
+
- Always add a try-catch block around the 'api.fetchData()' call in 'dataService.ts'.
|
|
170
|
+
</bad-examples>
|
|
171
|
+
|
|
172
|
+
This is the original system prompt the agent operated under:
|
|
173
|
+
<systemPrompt>
|
|
174
|
+
${await systemPrompt()}
|
|
175
|
+
</systemPrompt>`;
|
|
176
|
+
async function analyzeConversation({ modelManager, messages, tokenTracker, }) {
|
|
177
|
+
const learnedRules = await config.readCachedLearnedRulesFile();
|
|
178
|
+
// Modified User Message within analyzeConversation
|
|
179
|
+
messages.push(createUserMessage([
|
|
180
|
+
`Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
|
|
181
|
+
|
|
182
|
+
**Key Requirements:**
|
|
183
|
+
- Focus on *generalizable* rules applicable to future, different tasks.
|
|
184
|
+
- Avoid rules tied to the specifics of *this* conversation.
|
|
185
|
+
- Ensure rules don't already exist in <existing-rules>.
|
|
186
|
+
- If no *new, general* rules can be inferred, return an empty list or response.
|
|
187
|
+
- Return *only* the Markdown list of rules, with no preamble or explanation.
|
|
188
|
+
|
|
189
|
+
<existing-rules>
|
|
190
|
+
${learnedRules}
|
|
191
|
+
</existing-rules>`,
|
|
192
|
+
]));
|
|
193
|
+
const { text, usage } = await generateText({
|
|
194
|
+
model: modelManager.getModel("conversation-analyzer"),
|
|
195
|
+
maxOutputTokens: 8192,
|
|
196
|
+
system: await system(),
|
|
197
|
+
messages: messages,
|
|
198
|
+
});
|
|
199
|
+
tokenTracker.trackUsage("conversation-analyzer", usage);
|
|
200
|
+
// Trim whitespace and check if the response is effectively empty or just whitespace
|
|
201
|
+
const potentialRulesText = text.trim();
|
|
202
|
+
// Basic check to prevent adding empty lines or just formatting
|
|
203
|
+
if (!potentialRulesText || potentialRulesText.length === 0) {
|
|
204
|
+
return []; // Return empty array if no valid rules generated
|
|
205
|
+
}
|
|
206
|
+
// Split into individual rules, filter out empty lines
|
|
207
|
+
const potentialRulesList = potentialRulesText
|
|
208
|
+
.split("\n")
|
|
209
|
+
.map((rule) => rule.trim())
|
|
210
|
+
.filter((rule) => rule.length > 0);
|
|
211
|
+
if (potentialRulesList.length === 0) {
|
|
212
|
+
return []; // Return empty array if splitting results in no rules
|
|
213
|
+
}
|
|
214
|
+
// Further validation could be added here (e.g., check if it starts with '- ', etc.)
|
|
215
|
+
// before writing to the file.
|
|
216
|
+
// Append only if there are non-empty potential rules
|
|
217
|
+
const updatedRules = learnedRules.endsWith("\n") || learnedRules.length === 0
|
|
218
|
+
? `${learnedRules}${potentialRulesList.join("\n")}`
|
|
219
|
+
: `${learnedRules}\n${potentialRulesList.join("\n")}`;
|
|
220
|
+
await config.writeCachedLearnedRulesFile(updatedRules);
|
|
221
|
+
return potentialRulesList; // Return the list of rules that were added
|
|
222
|
+
}
|
|
223
|
+
function hideRuleSelector(editorContainer, editor, tui) {
|
|
224
|
+
// Replace selector with editor in the container
|
|
225
|
+
editorContainer.clear();
|
|
226
|
+
editorContainer.addChild(editor);
|
|
227
|
+
tui.setFocus(editor);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Component that renders a rule selector with search and multi-selection
|
|
231
|
+
*/
|
|
232
|
+
class RuleSelectorComponent extends Container {
|
|
233
|
+
searchInput;
|
|
234
|
+
listContainer;
|
|
235
|
+
allRules = [];
|
|
236
|
+
filteredRules = [];
|
|
237
|
+
selectedIndex = 0;
|
|
238
|
+
selectedRules = new Set();
|
|
239
|
+
onSelectCallback;
|
|
240
|
+
onCancelCallback;
|
|
241
|
+
constructor(rules, onSelect, onCancel) {
|
|
242
|
+
super();
|
|
243
|
+
this.onSelectCallback = onSelect;
|
|
244
|
+
this.onCancelCallback = onCancel;
|
|
245
|
+
// Load all rules
|
|
246
|
+
this.allRules = rules;
|
|
247
|
+
this.filteredRules = rules;
|
|
248
|
+
const { columns } = getTerminalSize();
|
|
249
|
+
// Add top border
|
|
250
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
251
|
+
this.addChild(new Spacer(1));
|
|
252
|
+
// Create search input
|
|
253
|
+
this.searchInput = new Input();
|
|
254
|
+
this.searchInput.onSubmit = () => {
|
|
255
|
+
// Enter on search input toggles selection of current item
|
|
256
|
+
this.toggleSelection(this.selectedIndex);
|
|
257
|
+
};
|
|
258
|
+
this.addChild(this.searchInput);
|
|
259
|
+
this.addChild(new Spacer(1));
|
|
260
|
+
// Create list container
|
|
261
|
+
this.listContainer = new Container();
|
|
262
|
+
this.addChild(this.listContainer);
|
|
263
|
+
this.addChild(new Spacer(1));
|
|
264
|
+
// Add instructions
|
|
265
|
+
this.addChild(new Text(style.dim("Space: toggle selection, Enter: confirm, Escape: cancel"), 0, 0));
|
|
266
|
+
this.addChild(new Spacer(1));
|
|
267
|
+
// Add bottom border
|
|
268
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
269
|
+
// Initial render
|
|
270
|
+
this.updateList();
|
|
271
|
+
}
|
|
272
|
+
filterRules(query) {
|
|
273
|
+
if (!query.trim()) {
|
|
274
|
+
this.filteredRules = this.allRules;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
const searchTokens = query
|
|
278
|
+
.toLowerCase()
|
|
279
|
+
.split(/\s+/)
|
|
280
|
+
.filter((t) => t);
|
|
281
|
+
this.filteredRules = this.allRules.filter((rule) => {
|
|
282
|
+
const searchText = rule.toLowerCase();
|
|
283
|
+
return searchTokens.every((token) => searchText.includes(token));
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredRules.length - 1));
|
|
287
|
+
this.updateList();
|
|
288
|
+
}
|
|
289
|
+
updateList() {
|
|
290
|
+
this.listContainer.clear();
|
|
291
|
+
const maxVisible = 10;
|
|
292
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredRules.length - maxVisible));
|
|
293
|
+
const endIndex = Math.min(startIndex + maxVisible, this.filteredRules.length);
|
|
294
|
+
// Show visible slice of filtered rules
|
|
295
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
296
|
+
const rule = this.filteredRules[i];
|
|
297
|
+
if (!rule)
|
|
298
|
+
continue;
|
|
299
|
+
const isSelected = i === this.selectedIndex;
|
|
300
|
+
const isChecked = this.selectedRules.has(i);
|
|
301
|
+
let line = "";
|
|
302
|
+
if (isSelected) {
|
|
303
|
+
const prefix = style.blue("→ ");
|
|
304
|
+
const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
|
|
305
|
+
const ruleText = rule;
|
|
306
|
+
line = `${prefix + checkbox + style.blue(ruleText)}`;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
|
|
310
|
+
const ruleText = ` ${rule}`;
|
|
311
|
+
line = `${checkbox + ruleText}`;
|
|
312
|
+
}
|
|
313
|
+
this.listContainer.addChild(new Text(line, 0, 0));
|
|
314
|
+
}
|
|
315
|
+
// Add scroll indicator if needed
|
|
316
|
+
if (startIndex > 0 || endIndex < this.filteredRules.length) {
|
|
317
|
+
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredRules.length})`);
|
|
318
|
+
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
319
|
+
}
|
|
320
|
+
// Show "no results" if empty
|
|
321
|
+
if (this.filteredRules.length === 0) {
|
|
322
|
+
this.listContainer.addChild(new Text(style.gray(" No matching rules"), 0, 0));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
handleInput(keyData) {
|
|
326
|
+
// Up arrow
|
|
327
|
+
if (keyData === "\x1b[A") {
|
|
328
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
329
|
+
this.updateList();
|
|
330
|
+
}
|
|
331
|
+
// Down arrow
|
|
332
|
+
else if (keyData === "\x1b[B") {
|
|
333
|
+
this.selectedIndex = Math.min(this.filteredRules.length - 1, this.selectedIndex + 1);
|
|
334
|
+
this.updateList();
|
|
335
|
+
}
|
|
336
|
+
// Space - toggle selection
|
|
337
|
+
else if (keyData === " ") {
|
|
338
|
+
this.toggleSelection(this.selectedIndex);
|
|
339
|
+
}
|
|
340
|
+
// Enter - confirm selection
|
|
341
|
+
else if (keyData === "\r") {
|
|
342
|
+
this.handleConfirm();
|
|
343
|
+
}
|
|
344
|
+
// Escape
|
|
345
|
+
else if (keyData === "\x1b") {
|
|
346
|
+
this.onCancelCallback();
|
|
347
|
+
}
|
|
348
|
+
// Pass everything else to search input
|
|
349
|
+
else {
|
|
350
|
+
this.searchInput.handleInput(keyData);
|
|
351
|
+
this.filterRules(this.searchInput.getValue());
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
toggleSelection(index) {
|
|
355
|
+
if (this.selectedRules.has(index)) {
|
|
356
|
+
this.selectedRules.delete(index);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.selectedRules.add(index);
|
|
360
|
+
}
|
|
361
|
+
this.updateList();
|
|
362
|
+
}
|
|
363
|
+
handleConfirm() {
|
|
364
|
+
const selectedRuleTexts = Array.from(this.selectedRules)
|
|
365
|
+
.map((index) => this.filteredRules[index])
|
|
366
|
+
.filter((rule) => rule !== undefined);
|
|
367
|
+
this.onSelectCallback(selectedRuleTexts);
|
|
368
|
+
}
|
|
369
|
+
getSearchInput() {
|
|
370
|
+
return this.searchInput;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff-command.d.ts","sourceRoot":"","sources":["../../source/commands/handoff-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WAkExD,CAAC"}
|