@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
|
@@ -5,7 +5,28 @@ import path from "node:path";
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { config } from "../config.js";
|
|
7
7
|
import { logger } from "../logger.js";
|
|
8
|
-
|
|
8
|
+
// Tool Metadata Schema and Parser
|
|
9
|
+
const toolMetadataSchema = z.object({
|
|
10
|
+
name: z.string().regex(/^[a-zA-Z_][a-zA-Z0-9_-]*$/),
|
|
11
|
+
description: z.string().min(1),
|
|
12
|
+
parameters: z.array(z.object({
|
|
13
|
+
name: z.string().regex(/^[a-zA-Z_][a-zA-Z0-9_-]*$/),
|
|
14
|
+
type: z.enum(["string", "number", "boolean"]),
|
|
15
|
+
description: z.string().min(1),
|
|
16
|
+
required: z.boolean().default(true),
|
|
17
|
+
default: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
18
|
+
})),
|
|
19
|
+
needsApproval: z.boolean().default(true),
|
|
20
|
+
});
|
|
21
|
+
export function parseToolMetadata(output) {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(output.trim());
|
|
24
|
+
return toolMetadataSchema.parse(parsed);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error(`Failed to parse tool metadata: ${error instanceof Error ? error.message : String(error)}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
9
30
|
function generateZodSchema(parameters) {
|
|
10
31
|
const fields = {};
|
|
11
32
|
for (const param of parameters) {
|
|
@@ -15,10 +36,14 @@ function generateZodSchema(parameters) {
|
|
|
15
36
|
schema = z.string();
|
|
16
37
|
break;
|
|
17
38
|
case "number":
|
|
18
|
-
schema = z.
|
|
39
|
+
schema = z.preprocess((val) => typeof val === "string" && val.toLowerCase() === "null"
|
|
40
|
+
? null
|
|
41
|
+
: val, z.coerce.number().nullable());
|
|
19
42
|
break;
|
|
20
43
|
case "boolean":
|
|
21
|
-
schema = z.
|
|
44
|
+
schema = z.preprocess((val) => typeof val === "string" && val.toLowerCase() === "null"
|
|
45
|
+
? null
|
|
46
|
+
: val, z.coerce.boolean().nullable());
|
|
22
47
|
break;
|
|
23
48
|
default:
|
|
24
49
|
continue;
|
|
@@ -156,7 +181,7 @@ async function spawnChildProcess(scriptPath, params, abortSignal) {
|
|
|
156
181
|
}
|
|
157
182
|
});
|
|
158
183
|
}
|
|
159
|
-
|
|
184
|
+
function createDynamicTool(scriptPath, metadata) {
|
|
160
185
|
const inputSchema = generateZodSchema(metadata.parameters);
|
|
161
186
|
const toolName = `dynamic-${metadata.name}`;
|
|
162
187
|
return {
|
|
@@ -165,56 +190,26 @@ export function createDynamicTool(scriptPath, metadata) {
|
|
|
165
190
|
description: metadata.description,
|
|
166
191
|
inputSchema,
|
|
167
192
|
},
|
|
168
|
-
|
|
193
|
+
display() {
|
|
194
|
+
return "running";
|
|
195
|
+
},
|
|
196
|
+
async execute(input, { abortSignal }) {
|
|
197
|
+
if (abortSignal?.aborted) {
|
|
198
|
+
throw new Error("Execution aborted");
|
|
199
|
+
}
|
|
169
200
|
try {
|
|
170
|
-
|
|
171
|
-
throw new Error("Execution aborted");
|
|
172
|
-
}
|
|
173
|
-
yield {
|
|
174
|
-
name: metadata.name,
|
|
175
|
-
event: "tool-init",
|
|
176
|
-
id: toolCallId,
|
|
177
|
-
data: "Running",
|
|
178
|
-
};
|
|
179
|
-
// Validate params again for safety
|
|
180
|
-
try {
|
|
181
|
-
inputSchema.parse(input);
|
|
182
|
-
}
|
|
183
|
-
catch (e) {
|
|
184
|
-
const errMsg = `Invalid parameters for tool ${metadata.name}: ${e.message}`;
|
|
185
|
-
yield {
|
|
186
|
-
name: metadata.name,
|
|
187
|
-
event: "tool-error",
|
|
188
|
-
id: toolCallId,
|
|
189
|
-
data: errMsg,
|
|
190
|
-
};
|
|
191
|
-
yield errMsg;
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const result = await spawnChildProcess(scriptPath, input, abortSignal);
|
|
195
|
-
yield {
|
|
196
|
-
name: metadata.name,
|
|
197
|
-
event: "tool-completion",
|
|
198
|
-
id: toolCallId,
|
|
199
|
-
data: "Completed",
|
|
200
|
-
};
|
|
201
|
-
yield result;
|
|
201
|
+
inputSchema.parse(input);
|
|
202
202
|
}
|
|
203
|
-
catch (
|
|
204
|
-
|
|
205
|
-
name: metadata.name,
|
|
206
|
-
event: "tool-error",
|
|
207
|
-
id: toolCallId,
|
|
208
|
-
data: `${metadata.name}: ${error.message}`,
|
|
209
|
-
};
|
|
210
|
-
yield error.message;
|
|
203
|
+
catch (e) {
|
|
204
|
+
throw new Error(`Invalid parameters for tool ${metadata.name}: ${e.message}`);
|
|
211
205
|
}
|
|
206
|
+
return spawnChildProcess(scriptPath, input, abortSignal);
|
|
212
207
|
},
|
|
213
208
|
},
|
|
214
209
|
};
|
|
215
210
|
}
|
|
216
211
|
export async function loadDynamicTools({ baseDir }) {
|
|
217
|
-
const projectConfig = await config.
|
|
212
|
+
const projectConfig = await config.getConfig();
|
|
218
213
|
const dynamicConfig = projectConfig.tools.dynamicTools;
|
|
219
214
|
if (!dynamicConfig.enabled) {
|
|
220
215
|
logger.info("Dynamic tools disabled in config.");
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { ToolCallOptions } from "ai";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import type {
|
|
4
|
-
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
5
|
-
import type { ToolResult } from "./types.ts";
|
|
2
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
6
3
|
export declare const EditFileTool: {
|
|
7
|
-
name: "
|
|
4
|
+
name: "Edit";
|
|
8
5
|
};
|
|
9
6
|
declare const inputSchema: z.ZodObject<{
|
|
10
7
|
path: z.ZodString;
|
|
@@ -14,12 +11,9 @@ declare const inputSchema: z.ZodObject<{
|
|
|
14
11
|
}, z.core.$strip>>;
|
|
15
12
|
}, z.core.$strip>;
|
|
16
13
|
type EditFileInputSchema = z.infer<typeof inputSchema>;
|
|
17
|
-
export declare const createEditFileTool: ({ workingDir, allowedDirs,
|
|
14
|
+
export declare const createEditFileTool: ({ workingDir, allowedDirs, }: {
|
|
18
15
|
workingDir: string;
|
|
19
16
|
allowedDirs?: string[];
|
|
20
|
-
modelManager?: ModelManager;
|
|
21
|
-
tokenTracker?: TokenTracker;
|
|
22
|
-
enableLlmFix?: boolean;
|
|
23
17
|
}) => Promise<{
|
|
24
18
|
toolDef: {
|
|
25
19
|
description: string;
|
|
@@ -31,17 +25,13 @@ export declare const createEditFileTool: ({ workingDir, allowedDirs, modelManage
|
|
|
31
25
|
}, z.core.$strip>>;
|
|
32
26
|
}, z.core.$strip>;
|
|
33
27
|
};
|
|
34
|
-
|
|
28
|
+
display({ path, edits }: EditFileInputSchema): string;
|
|
29
|
+
execute({ path, edits }: EditFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
35
30
|
}>;
|
|
36
31
|
interface FileEdit {
|
|
37
32
|
oldText: string;
|
|
38
33
|
newText: string;
|
|
39
34
|
}
|
|
40
|
-
export declare function applyFileEdits(filePath: string, edits: FileEdit[], dryRun?: boolean, abortSignal?: AbortSignal
|
|
41
|
-
modelManager?: ModelManager;
|
|
42
|
-
tokenTracker?: TokenTracker;
|
|
43
|
-
enableLlmFix?: boolean;
|
|
44
|
-
instruction?: string;
|
|
45
|
-
}): Promise<string>;
|
|
35
|
+
export declare function applyFileEdits(filePath: string, edits: FileEdit[], dryRun?: boolean, abortSignal?: AbortSignal): Promise<string>;
|
|
46
36
|
export {};
|
|
47
37
|
//# sourceMappingURL=edit-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-file.d.ts","sourceRoot":"","sources":["../../source/tools/edit-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-file.d.ts","sourceRoot":"","sources":["../../source/tools/edit-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;iBAcf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,8BAGtC;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;;6BAa4B,mBAAmB;6BAIzB,mBAAmB,mBACnB,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAqBrB,CAAC;AAyBF,UAAU,QAAQ;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,UAAQ,EACd,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,CAAC,CAsDjB"}
|
package/dist/tools/edit-file.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { createTwoFilesPatch } from "diff";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import { config } from "../config.js";
|
|
5
|
+
import { clearProjectStatusCache } from "../repl/project-status.js";
|
|
5
6
|
import style from "../terminal/style.js";
|
|
6
|
-
import { joinWorkingDir, validatePath } from "
|
|
7
|
-
import { fixLlmEditWithInstruction } from "./llm-edit-fixer.js";
|
|
7
|
+
import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
|
|
8
8
|
export const EditFileTool = {
|
|
9
|
-
name: "
|
|
9
|
+
name: "Edit",
|
|
10
10
|
};
|
|
11
11
|
const inputSchema = z.object({
|
|
12
12
|
path: z.string().describe("The path of the file to edit."),
|
|
@@ -19,7 +19,7 @@ const inputSchema = z.object({
|
|
|
19
19
|
newText: z.string().describe("Text to replace with"),
|
|
20
20
|
})),
|
|
21
21
|
});
|
|
22
|
-
export const createEditFileTool = async ({ workingDir, allowedDirs,
|
|
22
|
+
export const createEditFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
23
23
|
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
24
24
|
return {
|
|
25
25
|
toolDef: {
|
|
@@ -31,40 +31,19 @@ export const createEditFileTool = async ({ workingDir, allowedDirs, modelManager
|
|
|
31
31
|
"Multi-line strings require exact character-by-character matching including whitespace.",
|
|
32
32
|
inputSchema,
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
name: EditFileTool.name,
|
|
41
|
-
id: toolCallId,
|
|
42
|
-
event: "tool-init",
|
|
43
|
-
data: `${style.cyan(path)}`,
|
|
44
|
-
};
|
|
45
|
-
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
46
|
-
const result = await applyFileEdits(validPath, edits, false, abortSignal, {
|
|
47
|
-
modelManager,
|
|
48
|
-
tokenTracker,
|
|
49
|
-
enableLlmFix,
|
|
50
|
-
});
|
|
51
|
-
yield {
|
|
52
|
-
name: EditFileTool.name,
|
|
53
|
-
id: toolCallId,
|
|
54
|
-
event: "tool-completion",
|
|
55
|
-
data: `Applied ${edits.length} edits`,
|
|
56
|
-
};
|
|
57
|
-
yield result;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
yield {
|
|
61
|
-
name: EditFileTool.name,
|
|
62
|
-
event: "tool-error",
|
|
63
|
-
id: toolCallId,
|
|
64
|
-
data: error.message,
|
|
65
|
-
};
|
|
66
|
-
yield `Failed to edit file: ${error.message}`;
|
|
34
|
+
display({ path, edits }) {
|
|
35
|
+
return `\n> ${style.cyan(path)} (${edits.length} edit${edits.length === 1 ? "" : "s"})`;
|
|
36
|
+
},
|
|
37
|
+
async execute({ path, edits }, { abortSignal }) {
|
|
38
|
+
if (abortSignal?.aborted) {
|
|
39
|
+
throw new Error("File editing aborted");
|
|
67
40
|
}
|
|
41
|
+
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
42
|
+
const projectConfig = await config.getConfig();
|
|
43
|
+
validateFileNotReadOnly(validPath, projectConfig, workingDir);
|
|
44
|
+
const result = await applyFileEdits(validPath, edits, false, abortSignal);
|
|
45
|
+
clearProjectStatusCache();
|
|
46
|
+
return result;
|
|
68
47
|
},
|
|
69
48
|
};
|
|
70
49
|
};
|
|
@@ -78,7 +57,7 @@ function createUnifiedDiff(originalContent, newContent, filepath = "file") {
|
|
|
78
57
|
const normalizedNew = normalizeLineEndings(newContent);
|
|
79
58
|
return createTwoFilesPatch(filepath, filepath, normalizedOriginal, normalizedNew, "original", "modified");
|
|
80
59
|
}
|
|
81
|
-
export async function applyFileEdits(filePath, edits, dryRun = false, abortSignal
|
|
60
|
+
export async function applyFileEdits(filePath, edits, dryRun = false, abortSignal) {
|
|
82
61
|
if (abortSignal?.aborted) {
|
|
83
62
|
throw new Error("File edit operation aborted");
|
|
84
63
|
}
|
|
@@ -96,7 +75,7 @@ export async function applyFileEdits(filePath, edits, dryRun = false, abortSigna
|
|
|
96
75
|
if (abortSignal?.aborted) {
|
|
97
76
|
throw new Error("File edit operation aborted during processing");
|
|
98
77
|
}
|
|
99
|
-
const result = await applyEditWithLlmFix(edit, modifiedContent
|
|
78
|
+
const result = await applyEditWithLlmFix(edit, modifiedContent);
|
|
100
79
|
if (result.success) {
|
|
101
80
|
modifiedContent = result.content;
|
|
102
81
|
}
|
|
@@ -111,7 +90,7 @@ export async function applyFileEdits(filePath, edits, dryRun = false, abortSigna
|
|
|
111
90
|
while (diff.includes("`".repeat(numBackticks))) {
|
|
112
91
|
numBackticks++;
|
|
113
92
|
}
|
|
114
|
-
const formattedDiff = `${"`".repeat(numBackticks)}diff\n${diff}${"`".repeat(numBackticks)}
|
|
93
|
+
const formattedDiff = `${"`".repeat(numBackticks)} diff\n${diff}\n${"`".repeat(numBackticks)}`;
|
|
115
94
|
if (!dryRun) {
|
|
116
95
|
if (abortSignal?.aborted) {
|
|
117
96
|
throw new Error("File edit operation aborted before writing");
|
|
@@ -125,38 +104,15 @@ export async function applyFileEdits(filePath, edits, dryRun = false, abortSigna
|
|
|
125
104
|
return formattedDiff;
|
|
126
105
|
}
|
|
127
106
|
/**
|
|
128
|
-
* Applies a single edit
|
|
107
|
+
* Applies a single edit
|
|
129
108
|
*/
|
|
130
|
-
async function applyEditWithLlmFix(edit, content
|
|
109
|
+
async function applyEditWithLlmFix(edit, content) {
|
|
131
110
|
const { oldText, newText } = edit;
|
|
132
111
|
// Try the original edit first
|
|
133
112
|
const originalResult = applyLiteralEdit(content, oldText, newText);
|
|
134
113
|
if (originalResult.matchCount > 0) {
|
|
135
114
|
return { success: true, content: originalResult.content };
|
|
136
115
|
}
|
|
137
|
-
// If LLM fix is enabled and dependencies are available, try to fix the edit
|
|
138
|
-
if (options?.enableLlmFix !== false &&
|
|
139
|
-
options?.modelManager &&
|
|
140
|
-
options?.tokenTracker) {
|
|
141
|
-
try {
|
|
142
|
-
const fixedEdit = await fixLlmEditWithInstruction(options.instruction, oldText, newText, "oldText not found in content", content, options.modelManager ?? undefined, abortSignal);
|
|
143
|
-
if (fixedEdit && !fixedEdit.noChangesRequired) {
|
|
144
|
-
// Retry the edit with the corrected search string
|
|
145
|
-
const correctedResult = applyLiteralEdit(content, fixedEdit.search, fixedEdit.replace);
|
|
146
|
-
if (correctedResult.matchCount > 0) {
|
|
147
|
-
return { success: true, content: correctedResult.content };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else if (fixedEdit?.noChangesRequired) {
|
|
151
|
-
// No changes required, skip this edit
|
|
152
|
-
return { success: true, content };
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (llmError) {
|
|
156
|
-
// If LLM fix fails, fall back to original error
|
|
157
|
-
logger.warn(llmError, "LLM edit fix failed:");
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
116
|
return { success: false, content };
|
|
161
117
|
}
|
|
162
118
|
/**
|
package/dist/tools/glob.d.ts
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
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 GlobTool: {
|
|
6
|
-
name: "
|
|
4
|
+
name: "Glob";
|
|
7
5
|
};
|
|
8
6
|
export declare const inputSchema: z.ZodObject<{
|
|
9
7
|
patterns: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
10
8
|
path: z.ZodString;
|
|
11
|
-
gitignore: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
12
|
-
recursive: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
13
|
-
expandDirectories: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
9
|
+
gitignore: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
10
|
+
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
11
|
+
expandDirectories: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
14
12
|
ignoreFiles: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
15
|
-
cwd: z.ZodNullable<z.ZodCoercedString<unknown
|
|
13
|
+
cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
|
|
14
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
16
15
|
}, z.core.$strip>;
|
|
17
16
|
type GlobInputSchema = z.infer<typeof inputSchema>;
|
|
18
|
-
export declare const createGlobTool: (
|
|
19
|
-
tokenCounter: TokenCounter;
|
|
20
|
-
}) => {
|
|
17
|
+
export declare const createGlobTool: () => {
|
|
21
18
|
toolDef: {
|
|
22
19
|
description: string;
|
|
23
20
|
inputSchema: z.ZodObject<{
|
|
24
21
|
patterns: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
25
22
|
path: z.ZodString;
|
|
26
|
-
gitignore: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
27
|
-
recursive: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
28
|
-
expandDirectories: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
23
|
+
gitignore: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
24
|
+
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
25
|
+
expandDirectories: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
29
26
|
ignoreFiles: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
30
|
-
cwd: z.ZodNullable<z.ZodCoercedString<unknown
|
|
27
|
+
cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
|
|
28
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
31
29
|
}, z.core.$strip>;
|
|
32
30
|
};
|
|
33
|
-
|
|
31
|
+
display({ patterns, path }: GlobInputSchema): string;
|
|
32
|
+
execute({ patterns, path, gitignore, recursive, expandDirectories, ignoreFiles, cwd, maxResults, }: GlobInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
34
33
|
};
|
|
35
34
|
export {};
|
|
36
35
|
//# sourceMappingURL=glob.d.ts.map
|
package/dist/tools/glob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../source/tools/glob.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../source/tools/glob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIvD,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;iBA4BtB,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;gCAMK,eAAe;wGAkBtC,eAAe,mBACD,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;CA4ErB,CAAC"}
|
package/dist/tools/glob.js
CHANGED
|
@@ -1,143 +1,112 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as nodePath from "node:path";
|
|
3
|
-
import { inspect } from "node:util";
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
import style from "../terminal/style.js";
|
|
6
|
-
import { manageTokenLimit } from "../tokens/threshold.js";
|
|
7
5
|
import { glob } from "../utils/glob.js";
|
|
6
|
+
import { convertNullString } from "../utils/zod.js";
|
|
7
|
+
const DEFAULT_MAX_RESULTS = 100;
|
|
8
8
|
export const GlobTool = {
|
|
9
|
-
name: "
|
|
9
|
+
name: "Glob",
|
|
10
10
|
};
|
|
11
11
|
export const inputSchema = z.object({
|
|
12
12
|
patterns: z
|
|
13
13
|
.union([z.string(), z.array(z.string())])
|
|
14
14
|
.describe("Glob patterns to search for (e.g., '*.ts', '**/*.test.ts', 'src/**/*.js')"),
|
|
15
15
|
path: z.string().describe("Base directory to search in"),
|
|
16
|
-
gitignore: z
|
|
17
|
-
.boolean()
|
|
18
|
-
.nullable()
|
|
16
|
+
gitignore: z
|
|
17
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
19
18
|
.describe("Respect ignore patterns in .gitignore files. (default: true)"),
|
|
20
|
-
recursive: z
|
|
21
|
-
.boolean()
|
|
22
|
-
.nullable()
|
|
19
|
+
recursive: z
|
|
20
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
23
21
|
.describe("Search recursively. (default: true)"),
|
|
24
|
-
expandDirectories: z
|
|
25
|
-
.boolean()
|
|
26
|
-
.nullable()
|
|
22
|
+
expandDirectories: z
|
|
23
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
27
24
|
.describe("Automatically expand directories to files. (default: true)"),
|
|
28
25
|
ignoreFiles: z
|
|
29
26
|
.union([z.string(), z.array(z.string())])
|
|
30
27
|
.nullable()
|
|
31
28
|
.describe("Glob patterns to look for ignore files. (default: undefined)"),
|
|
32
|
-
cwd: z
|
|
33
|
-
.string()
|
|
34
|
-
.nullable()
|
|
29
|
+
cwd: z
|
|
30
|
+
.preprocess((val) => convertNullString(val), z.coerce.string().nullable())
|
|
35
31
|
.describe("Current working directory override. (default: process.cwd())"),
|
|
32
|
+
maxResults: z
|
|
33
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
34
|
+
.describe("Maximum number of files to return. Set to 0 for no limit. (Default: 100)"),
|
|
36
35
|
});
|
|
37
|
-
export const createGlobTool = (
|
|
38
|
-
const { tokenCounter } = options;
|
|
36
|
+
export const createGlobTool = () => {
|
|
39
37
|
return {
|
|
40
38
|
toolDef: {
|
|
41
|
-
description:
|
|
39
|
+
description: `Search for files using glob patterns (e.g., [1m*.ts[0m, [1m**/*.test.ts[0m, [1msrc/**/*.js[0m). Uses the fast-glob library with support for .gitignore, recursive searching, directory expansion, and automatic result limiting to prevent overwhelming output. Default limit is ${DEFAULT_MAX_RESULTS} files. Use maxResults parameter to override this limit.`,
|
|
42
40
|
inputSchema,
|
|
43
41
|
},
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
display({ patterns, path }) {
|
|
43
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
44
|
+
const patternStr = patternArray.length === 1
|
|
45
|
+
? patternArray[0]
|
|
46
|
+
: JSON.stringify(patternArray);
|
|
47
|
+
return `\n> ${style.cyan(patternStr)} in ${style.cyan(path)}`;
|
|
48
|
+
},
|
|
49
|
+
async execute({ patterns, path, gitignore, recursive, expandDirectories, ignoreFiles, cwd, maxResults, }, { abortSignal }) {
|
|
46
50
|
if (abortSignal?.aborted) {
|
|
47
51
|
throw new Error("Glob search aborted");
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
54
|
+
const globOptions = {
|
|
55
|
+
cwd: cwd || process.cwd(),
|
|
56
|
+
};
|
|
57
|
+
if (gitignore !== null) {
|
|
58
|
+
globOptions["gitignore"] = gitignore;
|
|
59
|
+
}
|
|
60
|
+
if (recursive !== null) {
|
|
61
|
+
globOptions["recursive"] = recursive;
|
|
62
|
+
}
|
|
63
|
+
if (expandDirectories !== null) {
|
|
64
|
+
globOptions["expandDirectories"] = expandDirectories;
|
|
65
|
+
}
|
|
66
|
+
if (ignoreFiles !== null) {
|
|
67
|
+
globOptions["ignoreFiles"] = ignoreFiles;
|
|
68
|
+
}
|
|
69
|
+
const matchingFiles = await glob(patternArray, {
|
|
70
|
+
...globOptions,
|
|
71
|
+
cwd: path,
|
|
72
|
+
});
|
|
73
|
+
const filesWithStats = await Promise.all(matchingFiles.map(async (filePath) => {
|
|
74
|
+
const fullPath = nodePath.join(path, filePath);
|
|
75
|
+
try {
|
|
76
|
+
const stats = await fs.promises.stat(fullPath);
|
|
77
|
+
return {
|
|
78
|
+
path: filePath,
|
|
79
|
+
mtime: stats.mtime,
|
|
80
|
+
isRecent: Date.now() - stats.mtime.getTime() < 7 * 24 * 60 * 60 * 1000,
|
|
81
|
+
};
|
|
69
82
|
}
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
catch {
|
|
84
|
+
return {
|
|
85
|
+
path: filePath,
|
|
86
|
+
mtime: new Date(0),
|
|
87
|
+
isRecent: false,
|
|
88
|
+
};
|
|
72
89
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const stats = await fs.promises.stat(fullPath);
|
|
83
|
-
return {
|
|
84
|
-
path: filePath,
|
|
85
|
-
mtime: stats.mtime,
|
|
86
|
-
isRecent: Date.now() - stats.mtime.getTime() < 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// If stat fails, treat as old file
|
|
91
|
-
return {
|
|
92
|
-
path: filePath,
|
|
93
|
-
mtime: new Date(0),
|
|
94
|
-
isRecent: false,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
// Sort files: recent files first (newest to oldest), then older files alphabetically
|
|
99
|
-
const sortedFiles = filesWithStats
|
|
100
|
-
.sort((a, b) => {
|
|
101
|
-
// Recent files come first
|
|
102
|
-
if (a.isRecent && !b.isRecent)
|
|
103
|
-
return -1;
|
|
104
|
-
if (!a.isRecent && b.isRecent)
|
|
105
|
-
return 1;
|
|
106
|
-
// Both recent: sort by modification time (newest first)
|
|
107
|
-
if (a.isRecent && b.isRecent) {
|
|
108
|
-
return b.mtime.getTime() - a.mtime.getTime();
|
|
109
|
-
}
|
|
110
|
-
// Both old: sort alphabetically by path
|
|
111
|
-
return a.path.localeCompare(b.path);
|
|
112
|
-
})
|
|
113
|
-
.map((file) => file.path);
|
|
114
|
-
// Format results
|
|
115
|
-
const resultContent = sortedFiles.length > 0
|
|
116
|
-
? sortedFiles.join("\n")
|
|
117
|
-
: "No files found matching the specified patterns.";
|
|
118
|
-
const result = await manageTokenLimit(resultContent, tokenCounter, "Glob", "Use more specific glob patterns or recursive=false to reduce matches");
|
|
119
|
-
let completionMessage = `Found ${style.cyan(sortedFiles.length)} files.`;
|
|
120
|
-
if (result.truncated) {
|
|
121
|
-
completionMessage += ` ${result.content}`;
|
|
90
|
+
}));
|
|
91
|
+
const sortedFiles = filesWithStats
|
|
92
|
+
.sort((a, b) => {
|
|
93
|
+
if (a.isRecent && !b.isRecent)
|
|
94
|
+
return -1;
|
|
95
|
+
if (!a.isRecent && b.isRecent)
|
|
96
|
+
return 1;
|
|
97
|
+
if (a.isRecent && b.isRecent) {
|
|
98
|
+
return b.mtime.getTime() - a.mtime.getTime();
|
|
122
99
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
yield {
|
|
134
|
-
name: GlobTool.name,
|
|
135
|
-
event: "tool-error",
|
|
136
|
-
id: toolCallId,
|
|
137
|
-
data: error.message,
|
|
138
|
-
};
|
|
139
|
-
yield error.message;
|
|
140
|
-
}
|
|
100
|
+
return a.path.localeCompare(b.path);
|
|
101
|
+
})
|
|
102
|
+
.map((file) => file.path);
|
|
103
|
+
const effectiveMaxResults = maxResults ?? DEFAULT_MAX_RESULTS;
|
|
104
|
+
const limitedFiles = effectiveMaxResults && effectiveMaxResults > 0
|
|
105
|
+
? sortedFiles.slice(0, effectiveMaxResults)
|
|
106
|
+
: sortedFiles;
|
|
107
|
+
return limitedFiles.length > 0
|
|
108
|
+
? limitedFiles.join("\n")
|
|
109
|
+
: "No files found matching the specified patterns.";
|
|
141
110
|
},
|
|
142
111
|
};
|
|
143
112
|
};
|