@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/tools/bash.js
CHANGED
|
@@ -1,108 +1,216 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import { config } from "../config.js";
|
|
3
3
|
import { initExecutionEnvironment } from "../execution/index.js";
|
|
4
4
|
import { logger } from "../logger.js";
|
|
5
5
|
import style from "../terminal/style.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { isPathWithinAllowedDirs } from "./filesystem-utils.js";
|
|
6
|
+
import { resolveCwd, validatePaths } from "../utils/bash.js";
|
|
7
|
+
import { convertNullString } from "../utils/zod.js";
|
|
9
8
|
export const BashTool = {
|
|
10
|
-
name: "
|
|
9
|
+
name: "Bash",
|
|
11
10
|
};
|
|
11
|
+
const installedTools = getInstalledTools();
|
|
12
|
+
const toolDescription = `Execute commands in a shell. Commands can execute only within the allowed directories. Always use absolute paths.
|
|
13
|
+
|
|
14
|
+
Tools available:
|
|
15
|
+
${installedTools}`;
|
|
12
16
|
// Command execution timeout in milliseconds
|
|
13
17
|
const DEFAULT_TIMEOUT = 1.5 * 60 * 1000; // 1.5 minutes
|
|
14
18
|
const inputSchema = z.object({
|
|
15
19
|
command: z.string().describe("Full CLI command to execute."),
|
|
16
20
|
cwd: z
|
|
17
|
-
.string()
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
.
|
|
21
|
+
.preprocess((val) => convertNullString(val), z.string().nullable())
|
|
22
|
+
.describe("Working directory file path (default: project root). Must be within the project directory. Required but nullable."),
|
|
23
|
+
timeout: z
|
|
24
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
25
|
+
.describe(`Command execution timeout in milliseconds. Required but nullable. If null, the default value is ${DEFAULT_TIMEOUT}ms`),
|
|
26
|
+
background: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Run command in background. If true, command will run until program exit."),
|
|
24
30
|
});
|
|
25
|
-
export const createBashTool = async ({ baseDir, allowedDirs,
|
|
31
|
+
export const createBashTool = async ({ baseDir, allowedDirs, }) => {
|
|
26
32
|
const execEnv = await initExecutionEnvironment();
|
|
27
|
-
const projectConfig = await config.readProjectConfig();
|
|
28
|
-
const allowedPaths = projectConfig.logs?.path
|
|
29
|
-
? [projectConfig.logs.path]
|
|
30
|
-
: [];
|
|
31
33
|
const allowedDirectories = allowedDirs ?? [baseDir];
|
|
32
34
|
return {
|
|
33
35
|
toolDef: {
|
|
34
|
-
description:
|
|
36
|
+
description: toolDescription,
|
|
35
37
|
inputSchema,
|
|
36
38
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
yield errorMsg;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const pathValidation = validatePaths(command, allowedDirectories, resolvedCwd, allowedPaths);
|
|
66
|
-
if (!pathValidation.isValid) {
|
|
67
|
-
yield {
|
|
68
|
-
name: BashTool.name,
|
|
69
|
-
event: "tool-error",
|
|
70
|
-
id: toolCallId,
|
|
71
|
-
data: pathValidation.error ?? "Unknown error.",
|
|
72
|
-
};
|
|
73
|
-
yield pathValidation.error ?? "Unknown error.";
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (abortSignal?.aborted) {
|
|
77
|
-
throw new Error("Command execution aborted before running the command");
|
|
39
|
+
display({ command }) {
|
|
40
|
+
return `\n> ${style.cyan(command)}`;
|
|
41
|
+
},
|
|
42
|
+
async execute({ command, cwd, timeout, background }, { abortSignal }) {
|
|
43
|
+
if (abortSignal?.aborted) {
|
|
44
|
+
throw new Error("Command execution aborted");
|
|
45
|
+
}
|
|
46
|
+
// grok doesn't follow my instructions
|
|
47
|
+
const safeCwd = cwd === "null" ? null : cwd;
|
|
48
|
+
const resolvedCwd = resolveCwd(safeCwd, baseDir, allowedDirectories);
|
|
49
|
+
const safeTimeout = timeout ?? DEFAULT_TIMEOUT;
|
|
50
|
+
const pathValidation = validatePaths(command, allowedDirectories, resolvedCwd);
|
|
51
|
+
if (!pathValidation.isValid) {
|
|
52
|
+
throw new Error(pathValidation.error ?? "Unknown error.");
|
|
53
|
+
}
|
|
54
|
+
if (abortSignal?.aborted) {
|
|
55
|
+
throw new Error("Command execution aborted before running the command");
|
|
56
|
+
}
|
|
57
|
+
// Handle background execution
|
|
58
|
+
if (background) {
|
|
59
|
+
// Strip any existing & from command to avoid double backgrounding
|
|
60
|
+
let processedCommand = command.trim();
|
|
61
|
+
if (processedCommand.endsWith("&")) {
|
|
62
|
+
logger.warn(`Stripping '&' from command since background=true: ${command}`);
|
|
63
|
+
processedCommand = processedCommand.slice(0, -1).trim();
|
|
78
64
|
}
|
|
79
|
-
|
|
65
|
+
// Fix rg commands that don't have an explicit path
|
|
66
|
+
processedCommand = fixRgCommand(processedCommand);
|
|
67
|
+
const backgroundProcess = execEnv.executeCommandInBackground(processedCommand, {
|
|
80
68
|
cwd: resolvedCwd,
|
|
81
|
-
timeout: safeTimeout,
|
|
82
69
|
abortSignal,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
onOutput: (output) => {
|
|
71
|
+
logger.debug({ output }, "Background command output:");
|
|
72
|
+
},
|
|
73
|
+
onError: (error) => {
|
|
74
|
+
logger.debug({ error }, "Background command error:");
|
|
75
|
+
},
|
|
76
|
+
onExit: (code) => {
|
|
77
|
+
logger.debug(`Background command exited with code ${code}`);
|
|
78
|
+
},
|
|
86
79
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
|
|
80
|
+
return `Background process started with PID: ${backgroundProcess.pid}`;
|
|
81
|
+
}
|
|
82
|
+
// Handle regular synchronous execution
|
|
83
|
+
// Strip & if present to ensure synchronous behavior
|
|
84
|
+
let processedCommand = command.trim();
|
|
85
|
+
if (processedCommand.endsWith("&")) {
|
|
86
|
+
logger.warn(`Stripping '&' from command since background=false: ${command}`);
|
|
87
|
+
processedCommand = processedCommand.slice(0, -1).trim();
|
|
95
88
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
// Fix rg commands that don't have an explicit path
|
|
90
|
+
// rg hangs when stdin is a socket and no path is given
|
|
91
|
+
processedCommand = fixRgCommand(processedCommand);
|
|
92
|
+
const { output, exitCode } = await execEnv.executeCommand(processedCommand, {
|
|
93
|
+
cwd: resolvedCwd,
|
|
94
|
+
timeout: safeTimeout,
|
|
95
|
+
abortSignal,
|
|
96
|
+
preserveOutputOnError: true,
|
|
97
|
+
captureStderr: true,
|
|
98
|
+
throwOnError: false,
|
|
99
|
+
});
|
|
100
|
+
if (exitCode !== 0) {
|
|
101
|
+
throw new Error(output);
|
|
105
102
|
}
|
|
103
|
+
return output;
|
|
106
104
|
},
|
|
107
105
|
};
|
|
108
106
|
};
|
|
107
|
+
function getInstalledTools() {
|
|
108
|
+
// Check for required bash tools
|
|
109
|
+
const tools = [
|
|
110
|
+
{
|
|
111
|
+
name: "git",
|
|
112
|
+
command: "git --version",
|
|
113
|
+
description: "Version control system - used for cloning repositories, checking out branches, committing changes, viewing history, and managing code versions",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "gh",
|
|
117
|
+
command: "gh --version",
|
|
118
|
+
description: "GitHub CLI - used for creating pull requests, managing issues, interacting with GitHub API, and automating GitHub workflows",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "rg",
|
|
122
|
+
command: "rg --version",
|
|
123
|
+
description: "ripgrep - fast text search tool for searching code patterns, file contents, and regular expressions across the codebase (use this instead of grep)",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "fd",
|
|
127
|
+
command: "fd --version",
|
|
128
|
+
description: "Fast file finder - alternative to find command, used for finding files by name, pattern, or type with intuitive syntax (use this instead of find)",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "ast-grep",
|
|
132
|
+
command: "ast-grep --version",
|
|
133
|
+
description: "AST-based code search - used for structural code search, refactoring, finding patterns in abstract syntax trees, and code transformations",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "jq",
|
|
137
|
+
command: "jq --version",
|
|
138
|
+
description: "JSON processor - used for parsing, filtering, and manipulating JSON output from APIs, commands, and configuration files",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "yq",
|
|
142
|
+
command: "yq --version",
|
|
143
|
+
description: "YAML processor - used for parsing and manipulating YAML files (configs, CI/CD pipelines, Kubernetes manifests) with jq-like syntax",
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
const toolStatus = tools
|
|
147
|
+
.map((tool) => {
|
|
148
|
+
let status = false;
|
|
149
|
+
try {
|
|
150
|
+
execSync(tool.command, { stdio: "ignore", timeout: 5000 });
|
|
151
|
+
status = true;
|
|
152
|
+
}
|
|
153
|
+
catch (_error) {
|
|
154
|
+
// Ignore error, tool is not installed
|
|
155
|
+
}
|
|
156
|
+
return { name: tool.name, description: tool.description, status };
|
|
157
|
+
})
|
|
158
|
+
.filter((tool) => tool.status)
|
|
159
|
+
.map((tool) => `- **${tool.name}**: ${tool.description}`)
|
|
160
|
+
.join("\n");
|
|
161
|
+
return toolStatus;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Fix rg commands that don't have an explicit path
|
|
165
|
+
* rg hangs when stdin is a socket and no path is given
|
|
166
|
+
* See: https://github.com/BurntSushi/ripgrep/discussions/2047
|
|
167
|
+
*/
|
|
168
|
+
function fixRgCommand(command) {
|
|
169
|
+
const trimmed = command.trim();
|
|
170
|
+
// Check if command starts with rg
|
|
171
|
+
if (!trimmed.startsWith("rg ") && !trimmed.startsWith("rg\\")) {
|
|
172
|
+
return command;
|
|
173
|
+
}
|
|
174
|
+
// Check if command already has stdin redirection or piping
|
|
175
|
+
// Don't modify commands like: cat file.txt | rg pattern
|
|
176
|
+
// or rg pattern < input.txt
|
|
177
|
+
if (trimmed.includes("|") || trimmed.includes("<") || trimmed.includes(">")) {
|
|
178
|
+
return command;
|
|
179
|
+
}
|
|
180
|
+
// Simple heuristic: if last token starts with -, add .
|
|
181
|
+
// This handles cases like: rg -l pattern --type ts --type js
|
|
182
|
+
const tokens = trimmed.split(/\\s+/);
|
|
183
|
+
const lastToken = tokens[tokens.length - 1];
|
|
184
|
+
if (lastToken?.startsWith("-")) {
|
|
185
|
+
// Command ends with an option, need to add path
|
|
186
|
+
logger.debug(`Adding '.' to rg command: ${command}`);
|
|
187
|
+
return `${command} .`;
|
|
188
|
+
}
|
|
189
|
+
// Last token doesn't start with -, could be a path or pattern
|
|
190
|
+
if (lastToken) {
|
|
191
|
+
// If it's ., ./, /, or contains /, assume it's a path
|
|
192
|
+
if (lastToken === "." ||
|
|
193
|
+
lastToken.startsWith("./") ||
|
|
194
|
+
lastToken.startsWith("/") ||
|
|
195
|
+
lastToken.includes("/") ||
|
|
196
|
+
lastToken === "..") {
|
|
197
|
+
// Already has a path
|
|
198
|
+
return command;
|
|
199
|
+
}
|
|
200
|
+
// Check if it's a simple pattern (no special chars that would make it a path)
|
|
201
|
+
// If it's just alphanumeric with maybe some regex chars, it's probably a pattern
|
|
202
|
+
// Common pattern chars: ., *, +, ?, [, ], ^, $, (, ), |, \\
|
|
203
|
+
// But we want to be conservative - if it looks like a filename without path, add .
|
|
204
|
+
if (!lastToken.includes("/") && !lastToken.includes("*")) {
|
|
205
|
+
// Doesn't look like a path with glob or directory, likely a pattern
|
|
206
|
+
// Need to add path
|
|
207
|
+
logger.debug(`Adding '.' to rg command: ${command}`);
|
|
208
|
+
return `${command} .`;
|
|
209
|
+
}
|
|
210
|
+
// Complex case with * or other chars, could be a glob pattern
|
|
211
|
+
// Default to adding . to be safe
|
|
212
|
+
}
|
|
213
|
+
// No last token or complex case, add . to be safe
|
|
214
|
+
logger.debug(`Adding '.' to rg command: ${command}`);
|
|
215
|
+
return `${command} .`;
|
|
216
|
+
}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import type { ToolCallOptions } from "ai";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import type {
|
|
4
|
-
import type { ToolResult } from "./types.ts";
|
|
2
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
5
3
|
export declare const DirectoryTreeTool: {
|
|
6
|
-
name: "
|
|
4
|
+
name: "DirectoryTree";
|
|
7
5
|
};
|
|
8
6
|
declare const inputSchema: z.ZodObject<{
|
|
9
7
|
path: z.ZodString;
|
|
8
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
9
|
+
maxDepth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
11
|
type DirectoryTreeInputSchema = z.infer<typeof inputSchema>;
|
|
12
|
-
export declare const createDirectoryTreeTool: ({ workingDir, allowedDirs,
|
|
12
|
+
export declare const createDirectoryTreeTool: ({ workingDir, allowedDirs, }: {
|
|
13
13
|
workingDir: string;
|
|
14
14
|
allowedDirs?: string[];
|
|
15
|
-
tokenCounter: TokenCounter;
|
|
16
15
|
}) => Promise<{
|
|
17
16
|
toolDef: {
|
|
18
17
|
description: string;
|
|
19
18
|
inputSchema: z.ZodObject<{
|
|
20
19
|
path: z.ZodString;
|
|
20
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
21
|
+
maxDepth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
21
22
|
}, z.core.$strip>;
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
display({ path, maxDepth, maxResults }: DirectoryTreeInputSchema): string;
|
|
25
|
+
execute({ path, maxResults, maxDepth }: DirectoryTreeInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
24
26
|
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Generates a string representation of a directory tree starting from the given path.
|
|
27
|
-
* @param dirPath - The path of the directory to generate the tree for.
|
|
28
|
-
* @returns A Promise that resolves to a string representation of the directory tree.
|
|
29
|
-
*/
|
|
30
|
-
export declare function directoryTree(dirPath: string): Promise<string>;
|
|
31
27
|
export {};
|
|
32
28
|
//# sourceMappingURL=directory-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;iBAYf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,8BAG3C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;4CAO2C,wBAAwB;4CAW9B,wBAAwB,mBACvC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAyBrB,CAAC"}
|
|
@@ -2,65 +2,55 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import style from "../terminal/style.js";
|
|
5
|
-
import {
|
|
5
|
+
import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
|
|
6
6
|
import ignore from "../utils/ignore.js";
|
|
7
|
-
import {
|
|
7
|
+
import { convertNullString } from "../utils/zod.js";
|
|
8
|
+
const DEFAULT_ITEM_LIMIT = 500;
|
|
9
|
+
const DEFAULT_DEPTH_LIMIT = 10;
|
|
8
10
|
export const DirectoryTreeTool = {
|
|
9
|
-
name: "
|
|
11
|
+
name: "DirectoryTree",
|
|
10
12
|
};
|
|
11
13
|
const inputSchema = z.object({
|
|
12
|
-
path: z.string().describe("The path
|
|
14
|
+
path: z.string().describe("The path"),
|
|
15
|
+
maxResults: z
|
|
16
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
17
|
+
.describe(`Maximum number of items (files + directories) to return. Set to 0 for no limit. (default: ${DEFAULT_ITEM_LIMIT})`),
|
|
18
|
+
maxDepth: z
|
|
19
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
20
|
+
.describe(`Maximum recursion depth. Set to 0 for no limit. (default: ${DEFAULT_DEPTH_LIMIT})`),
|
|
13
21
|
});
|
|
14
|
-
export const createDirectoryTreeTool = async ({ workingDir, allowedDirs,
|
|
22
|
+
export const createDirectoryTreeTool = async ({ workingDir, allowedDirs, }) => {
|
|
15
23
|
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
16
24
|
return {
|
|
17
25
|
toolDef: {
|
|
18
|
-
description:
|
|
26
|
+
description: `Get a directory tree structure for a given path. This tool will ignore any directories or files listed in a .gitignore file. Use this tool when you need to see a complete directory tree for a path in the allowed directories. This can be used to get an understanding of how a project is organized and what files are available before using other file system tools. Results are automatically limited to prevent overwhelming output. Default limits are ${DEFAULT_ITEM_LIMIT} items and ${DEFAULT_DEPTH_LIMIT} depth. Use maxResults and maxDepth parameters for better control over output size.`,
|
|
19
27
|
inputSchema,
|
|
20
28
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
event: "tool-init",
|
|
31
|
-
data: `${style.cyan(path)}`,
|
|
32
|
-
};
|
|
33
|
-
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
34
|
-
if (abortSignal?.aborted) {
|
|
35
|
-
throw new Error("Directory tree listing aborted before tree generation");
|
|
36
|
-
}
|
|
37
|
-
const rawTree = await directoryTree(validPath);
|
|
38
|
-
const result = await manageTokenLimit(rawTree, tokenCounter, "DirectoryTree", "Use excludeDirPatterns or recursive=false to reduce output");
|
|
39
|
-
// Count files in the tree output
|
|
40
|
-
const fileCount = (result.content.match(/\n/g) || []).length + 1;
|
|
41
|
-
let completionMessage = `Found ${fileCount} files`;
|
|
42
|
-
if (result.truncated) {
|
|
43
|
-
completionMessage += ` - ${result.content}`;
|
|
44
|
-
}
|
|
45
|
-
completionMessage += ` (${result.tokenCount} tokens)`;
|
|
46
|
-
yield {
|
|
47
|
-
name: DirectoryTreeTool.name,
|
|
48
|
-
id: toolCallId,
|
|
49
|
-
event: "tool-completion",
|
|
50
|
-
data: completionMessage,
|
|
51
|
-
};
|
|
52
|
-
yield result.content;
|
|
29
|
+
display({ path, maxDepth, maxResults }) {
|
|
30
|
+
let display = `\n> ${style.cyan(path)}`;
|
|
31
|
+
if (maxDepth || maxResults) {
|
|
32
|
+
const parts = [];
|
|
33
|
+
if (maxDepth)
|
|
34
|
+
parts.push(`depth: ${maxDepth}`);
|
|
35
|
+
if (maxResults)
|
|
36
|
+
parts.push(`max: ${maxResults}`);
|
|
37
|
+
display += ` (${parts.join(", ")})`;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
return display;
|
|
40
|
+
},
|
|
41
|
+
async execute({ path, maxResults, maxDepth }, { abortSignal }) {
|
|
42
|
+
if (abortSignal?.aborted) {
|
|
43
|
+
throw new Error("Directory tree listing aborted");
|
|
44
|
+
}
|
|
45
|
+
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
46
|
+
if (abortSignal?.aborted) {
|
|
47
|
+
throw new Error("Directory tree listing aborted before tree generation");
|
|
63
48
|
}
|
|
49
|
+
const treeResult = await directoryTree(validPath, {
|
|
50
|
+
maxResults: maxResults ?? DEFAULT_ITEM_LIMIT,
|
|
51
|
+
maxDepth: maxDepth ?? DEFAULT_DEPTH_LIMIT,
|
|
52
|
+
});
|
|
53
|
+
return treeResult.tree;
|
|
64
54
|
},
|
|
65
55
|
};
|
|
66
56
|
};
|
|
@@ -71,41 +61,74 @@ export const createDirectoryTreeTool = async ({ workingDir, allowedDirs, tokenCo
|
|
|
71
61
|
* @returns The indentation string for the current level.
|
|
72
62
|
*/
|
|
73
63
|
function getIndent(level, isLast) {
|
|
74
|
-
const indent = "│ ".repeat(level - 1);
|
|
64
|
+
const indent = "│ ".repeat(Math.max(level - 1, 0));
|
|
75
65
|
return level === 0 ? "" : `${indent}${isLast ? "└── " : "├── "}`;
|
|
76
66
|
}
|
|
77
67
|
/**
|
|
78
68
|
* Recursively generates a string representation of a directory tree.
|
|
79
69
|
* @param dirPath - The path of the directory to generate the tree for.
|
|
80
|
-
* @param
|
|
81
|
-
* @
|
|
70
|
+
* @param ig - The ignore instance for filtering files.
|
|
71
|
+
* @param level - The current level in the directory tree (default: 0).
|
|
72
|
+
* @param options - Options for limiting results.
|
|
73
|
+
* @returns A Promise that resolves to a string representation of the directory tree with counts.
|
|
82
74
|
* @throws Will log an error if there's an issue reading the directory.
|
|
83
75
|
*/
|
|
84
|
-
async function generateDirectoryTree(dirPath, ig, level =
|
|
76
|
+
async function generateDirectoryTree(dirPath, ig, level = 0, options = {}) {
|
|
85
77
|
const name = path.basename(dirPath);
|
|
86
78
|
let output = `${getIndent(level, false)}${name}\n`;
|
|
79
|
+
let fileCount = 0;
|
|
80
|
+
let directoryCount = 1; // Count the current directory
|
|
81
|
+
let totalCount = 1; // Count the current directory
|
|
82
|
+
let isTruncated = false;
|
|
83
|
+
// Check maxDepth limit - when maxDepth is reached, we should indicate truncation
|
|
84
|
+
if (options.maxDepth !== null &&
|
|
85
|
+
options.maxDepth !== undefined &&
|
|
86
|
+
options.maxDepth > 0 &&
|
|
87
|
+
level >= options.maxDepth) {
|
|
88
|
+
// When maxDepth is reached, return with truncation flag set
|
|
89
|
+
return {
|
|
90
|
+
tree: output,
|
|
91
|
+
fileCount: 0,
|
|
92
|
+
directoryCount: 1, // Count the current directory
|
|
93
|
+
totalCount: 1, // Count the current directory
|
|
94
|
+
isTruncated: true, // Set truncation flag when depth limit is reached
|
|
95
|
+
};
|
|
96
|
+
}
|
|
87
97
|
const items = await fs.readdir(dirPath);
|
|
88
98
|
const filteredItems = ig.filter(items);
|
|
89
99
|
for (let i = 0; i < filteredItems.length; i++) {
|
|
100
|
+
// Check maxResults limit BEFORE processing each item to ensure strict adherence to limits
|
|
101
|
+
if (options.maxResults !== null &&
|
|
102
|
+
options.maxResults !== undefined &&
|
|
103
|
+
options.maxResults > 0 &&
|
|
104
|
+
totalCount >= options.maxResults) {
|
|
105
|
+
isTruncated = true;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
90
108
|
const item = filteredItems[i] ?? "";
|
|
91
109
|
const itemPath = path.join(dirPath, item);
|
|
92
110
|
const isLast = i === filteredItems.length - 1;
|
|
93
111
|
const stats = await fs.stat(itemPath);
|
|
94
112
|
if (stats.isDirectory()) {
|
|
95
|
-
|
|
113
|
+
const subTreeResult = await generateDirectoryTree(itemPath, ig, level + 1, options);
|
|
114
|
+
output += subTreeResult.tree;
|
|
115
|
+
fileCount += subTreeResult.fileCount;
|
|
116
|
+
directoryCount += subTreeResult.directoryCount;
|
|
117
|
+
totalCount += subTreeResult.totalCount;
|
|
118
|
+
// Propagate truncation from subtree results
|
|
119
|
+
if (subTreeResult.isTruncated) {
|
|
120
|
+
isTruncated = true;
|
|
121
|
+
}
|
|
96
122
|
}
|
|
97
123
|
else {
|
|
98
124
|
output += `${getIndent(level + 1, isLast)}${item}\n`;
|
|
125
|
+
fileCount += 1;
|
|
126
|
+
totalCount += 1;
|
|
99
127
|
}
|
|
100
128
|
}
|
|
101
|
-
return output;
|
|
129
|
+
return { tree: output, fileCount, directoryCount, totalCount, isTruncated };
|
|
102
130
|
}
|
|
103
|
-
|
|
104
|
-
* Generates a string representation of a directory tree starting from the given path.
|
|
105
|
-
* @param dirPath - The path of the directory to generate the tree for.
|
|
106
|
-
* @returns A Promise that resolves to a string representation of the directory tree.
|
|
107
|
-
*/
|
|
108
|
-
export async function directoryTree(dirPath) {
|
|
131
|
+
async function directoryTree(dirPath, options = {}) {
|
|
109
132
|
let ig;
|
|
110
133
|
try {
|
|
111
134
|
const ignoreFile = await fs.readFile(path.join(process.cwd(), ".gitignore"));
|
|
@@ -115,5 +138,12 @@ export async function directoryTree(dirPath) {
|
|
|
115
138
|
// If .gitignore doesn't exist, create basic ignore with just .git
|
|
116
139
|
ig = ignore().add(".git");
|
|
117
140
|
}
|
|
118
|
-
|
|
141
|
+
const result = await generateDirectoryTree(dirPath, ig, 0, options);
|
|
142
|
+
return {
|
|
143
|
+
tree: result.tree.trim(),
|
|
144
|
+
fileCount: result.fileCount,
|
|
145
|
+
directoryCount: result.directoryCount,
|
|
146
|
+
totalCount: result.totalCount,
|
|
147
|
+
isTruncated: result.isTruncated,
|
|
148
|
+
};
|
|
119
149
|
}
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
3
|
+
declare const toolMetadataSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
parameters: z.ZodArray<z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
type: z.ZodEnum<{
|
|
9
|
+
string: "string";
|
|
10
|
+
number: "number";
|
|
11
|
+
boolean: "boolean";
|
|
12
|
+
}>;
|
|
13
|
+
description: z.ZodString;
|
|
14
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
needsApproval: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ToolMetadata = z.infer<typeof toolMetadataSchema>;
|
|
20
|
+
export declare function parseToolMetadata(output: string): ToolMetadata;
|
|
4
21
|
interface DynamicToolObject {
|
|
5
22
|
toolDef: {
|
|
6
23
|
description: string;
|
|
7
24
|
inputSchema: any;
|
|
8
25
|
};
|
|
9
|
-
execute: (input: Record<string, unknown>, options:
|
|
10
|
-
ask?: (input: Record<string, unknown>, options:
|
|
26
|
+
execute: (input: Record<string, unknown>, options: ToolExecutionOptions) => Promise<string>;
|
|
27
|
+
ask?: (input: Record<string, unknown>, options: ToolExecutionOptions) => Promise<{
|
|
11
28
|
approve: boolean;
|
|
12
29
|
reason?: string;
|
|
13
30
|
}>;
|
|
14
31
|
}
|
|
15
|
-
export declare function createDynamicTool(scriptPath: string, metadata: ToolMetadata): {
|
|
16
|
-
[x: string]: DynamicToolObject;
|
|
17
|
-
};
|
|
18
32
|
export declare function loadDynamicTools({ baseDir }: {
|
|
19
33
|
baseDir: string;
|
|
20
34
|
}): Promise<Record<string, DynamicToolObject>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-tool-loader.d.ts","sourceRoot":"","sources":["../../source/tools/dynamic-tool-loader.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"dynamic-tool-loader.d.ts","sourceRoot":"","sources":["../../source/tools/dynamic-tool-loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;iBAatB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS9D;AA2LD,UAAU,iBAAiB;IACzB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QAEpB,WAAW,EAAE,GAAG,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,CACP,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,GAAG,CAAC,EAAE,CACJ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AAwCD,wBAAsB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,8CAgEtE"}
|