@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/index.js
CHANGED
|
@@ -1,313 +1,57 @@
|
|
|
1
|
-
import { tool } from "ai";
|
|
2
|
-
import { AdvancedEditFileTool, createAdvancedEditFileTool, } from "./advanced-edit-file.js";
|
|
3
|
-
import { AgentTool, createAgentTools } from "./agent.js";
|
|
4
1
|
import { BashTool, createBashTool } from "./bash.js";
|
|
5
|
-
import { CodeInterpreterTool, createCodeInterpreterTool, } from "./code-interpreter.js";
|
|
6
|
-
import { createDeleteFileTool, DeleteFileTool } from "./delete-file.js";
|
|
7
2
|
import { createDirectoryTreeTool, DirectoryTreeTool, } from "./directory-tree.js";
|
|
8
3
|
import { loadDynamicTools } from "./dynamic-tool-loader.js";
|
|
9
4
|
import { createEditFileTool, EditFileTool } from "./edit-file.js";
|
|
10
5
|
import { createGlobTool, GlobTool } from "./glob.js";
|
|
11
6
|
import { createGrepTool, GrepTool } from "./grep.js";
|
|
12
|
-
import {
|
|
7
|
+
import { createLsTool, LsTool } from "./ls.js";
|
|
13
8
|
import { createReadFileTool, ReadFileTool } from "./read-file.js";
|
|
14
|
-
import { createReadMultipleFilesTool, ReadMultipleFilesTool, } from "./read-multiple-files.js";
|
|
15
9
|
import { createSaveFileTool, SaveFileTool } from "./save-file.js";
|
|
16
10
|
import { createThinkTool, ThinkTool } from "./think.js";
|
|
17
|
-
|
|
18
|
-
import { createWebSearchTool, WebSearchTool } from "./web-search.js";
|
|
19
|
-
export async function initTools({ tokenCounter, workspace, modelManager, tokenTracker, }) {
|
|
11
|
+
export async function initTools({ workspace, }) {
|
|
20
12
|
const readFileTool = await createReadFileTool({
|
|
21
13
|
workingDir: workspace.primaryDir,
|
|
22
14
|
allowedDirs: workspace.allowedDirs,
|
|
23
|
-
tokenCounter,
|
|
24
|
-
});
|
|
25
|
-
const readMultipleFilesTool = await createReadMultipleFilesTool({
|
|
26
|
-
workingDir: workspace.primaryDir,
|
|
27
|
-
allowedDirs: workspace.allowedDirs,
|
|
28
|
-
tokenCounter,
|
|
29
15
|
});
|
|
30
16
|
const editFileTool = await createEditFileTool({
|
|
31
17
|
workingDir: workspace.primaryDir,
|
|
32
18
|
allowedDirs: workspace.allowedDirs,
|
|
33
|
-
modelManager,
|
|
34
|
-
tokenTracker,
|
|
35
|
-
});
|
|
36
|
-
const advancedEditFileTool = await createAdvancedEditFileTool({
|
|
37
|
-
workingDir: workspace.primaryDir,
|
|
38
|
-
allowedDirs: workspace.allowedDirs,
|
|
39
19
|
});
|
|
40
20
|
const saveFileTool = await createSaveFileTool({
|
|
41
21
|
workingDir: workspace.primaryDir,
|
|
42
22
|
allowedDirs: workspace.allowedDirs,
|
|
43
23
|
});
|
|
44
|
-
const moveFileTool = await createMoveFileTool({
|
|
45
|
-
workingDir: workspace.primaryDir,
|
|
46
|
-
allowedDirs: workspace.allowedDirs,
|
|
47
|
-
});
|
|
48
24
|
const directoryTreeTool = await createDirectoryTreeTool({
|
|
49
25
|
workingDir: workspace.primaryDir,
|
|
50
26
|
allowedDirs: workspace.allowedDirs,
|
|
51
|
-
tokenCounter,
|
|
52
27
|
});
|
|
53
|
-
const
|
|
28
|
+
const globTool = createGlobTool();
|
|
29
|
+
const grepTool = createGrepTool();
|
|
30
|
+
const thinkTool = createThinkTool();
|
|
31
|
+
const lsTool = await createLsTool({
|
|
54
32
|
workingDir: workspace.primaryDir,
|
|
55
33
|
allowedDirs: workspace.allowedDirs,
|
|
56
34
|
});
|
|
57
|
-
const codeInterpreterTool = await createCodeInterpreterTool({
|
|
58
|
-
tokenCounter,
|
|
59
|
-
});
|
|
60
|
-
const globTool = createGlobTool({
|
|
61
|
-
tokenCounter,
|
|
62
|
-
});
|
|
63
|
-
const grepTool = createGrepTool({
|
|
64
|
-
tokenCounter,
|
|
65
|
-
});
|
|
66
|
-
const thinkTool = createThinkTool();
|
|
67
|
-
const webFetchTool = createWebFetchTool({
|
|
68
|
-
tokenCounter,
|
|
69
|
-
});
|
|
70
|
-
const webSearchTool = createWebSearchTool({
|
|
71
|
-
tokenCounter,
|
|
72
|
-
});
|
|
73
35
|
const bashTool = await createBashTool({
|
|
74
36
|
baseDir: workspace.primaryDir,
|
|
75
37
|
allowedDirs: workspace.allowedDirs,
|
|
76
|
-
tokenCounter,
|
|
77
38
|
});
|
|
78
39
|
const dynamicTools = await loadDynamicTools({
|
|
79
40
|
baseDir: workspace.primaryDir,
|
|
80
41
|
});
|
|
81
42
|
// Build tools object for AI SDK
|
|
82
43
|
const tools = {
|
|
83
|
-
[EditFileTool.name]:
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[GrepTool.name]: tool(grepTool.toolDef),
|
|
93
|
-
[DirectoryTreeTool.name]: tool(directoryTreeTool.toolDef),
|
|
94
|
-
[CodeInterpreterTool.name]: tool(codeInterpreterTool.toolDef),
|
|
95
|
-
[ThinkTool.name]: tool(thinkTool.toolDef),
|
|
96
|
-
[WebFetchTool.name]: tool(webFetchTool.toolDef),
|
|
97
|
-
[WebSearchTool.name]: tool(webSearchTool.toolDef),
|
|
44
|
+
[EditFileTool.name]: editFileTool,
|
|
45
|
+
[BashTool.name]: bashTool,
|
|
46
|
+
[SaveFileTool.name]: saveFileTool,
|
|
47
|
+
[ReadFileTool.name]: readFileTool,
|
|
48
|
+
[GlobTool.name]: globTool,
|
|
49
|
+
[GrepTool.name]: grepTool,
|
|
50
|
+
[DirectoryTreeTool.name]: directoryTreeTool,
|
|
51
|
+
[ThinkTool.name]: thinkTool,
|
|
52
|
+
[LsTool.name]: lsTool,
|
|
98
53
|
// Add dynamic tools - they already have toolDef structure
|
|
99
|
-
...Object.fromEntries(Object.entries(dynamicTools).map(([name, toolObj]) => [
|
|
100
|
-
name,
|
|
101
|
-
tool(toolObj.toolDef),
|
|
102
|
-
])),
|
|
103
|
-
};
|
|
104
|
-
// Build executors map for manual loop
|
|
105
|
-
const executors = new Map();
|
|
106
|
-
// Add bash tool
|
|
107
|
-
executors.set(BashTool.name, bashTool.execute);
|
|
108
|
-
// Add editFile tool
|
|
109
|
-
executors.set(EditFileTool.name, editFileTool.execute);
|
|
110
|
-
// Add advancedEditFile tool
|
|
111
|
-
executors.set(AdvancedEditFileTool.name, advancedEditFileTool.execute);
|
|
112
|
-
// Add saveFile tool
|
|
113
|
-
executors.set(SaveFileTool.name, saveFileTool.execute);
|
|
114
|
-
// Add deleteFile tool
|
|
115
|
-
executors.set(DeleteFileTool.name, deleteFileTool.execute);
|
|
116
|
-
// Add moveFile tool
|
|
117
|
-
executors.set(MoveFileTool.name, moveFileTool.execute);
|
|
118
|
-
// Add readFile tool
|
|
119
|
-
executors.set(ReadFileTool.name, readFileTool.execute);
|
|
120
|
-
// Add readMultipleFiles tool
|
|
121
|
-
executors.set(ReadMultipleFilesTool.name, readMultipleFilesTool.execute);
|
|
122
|
-
// Add glob tool
|
|
123
|
-
executors.set(GlobTool.name, globTool.execute);
|
|
124
|
-
// Add grep tool
|
|
125
|
-
executors.set(GrepTool.name, grepTool.execute);
|
|
126
|
-
// Add directoryTree tool
|
|
127
|
-
executors.set(DirectoryTreeTool.name, directoryTreeTool.execute);
|
|
128
|
-
// Add webFetch tool
|
|
129
|
-
executors.set(WebFetchTool.name, webFetchTool.execute);
|
|
130
|
-
// Add webSearch tool
|
|
131
|
-
executors.set(WebSearchTool.name, webSearchTool.execute);
|
|
132
|
-
// Add think tool
|
|
133
|
-
executors.set(ThinkTool.name, thinkTool.execute);
|
|
134
|
-
// Add codeInterpreter tool
|
|
135
|
-
executors.set(CodeInterpreterTool.name, codeInterpreterTool.execute);
|
|
136
|
-
// Add dynamic tools to executors
|
|
137
|
-
for (const [name, toolObj] of Object.entries(dynamicTools)) {
|
|
138
|
-
executors.set(name, toolObj.execute);
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
toolDefs: tools,
|
|
142
|
-
executors,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
export async function initCliTools({ tokenCounter, workspace, modelManager, tokenTracker, }) {
|
|
146
|
-
const readFileTool = await createReadFileTool({
|
|
147
|
-
workingDir: workspace.primaryDir,
|
|
148
|
-
allowedDirs: workspace.allowedDirs,
|
|
149
|
-
tokenCounter,
|
|
150
|
-
});
|
|
151
|
-
const readMultipleFilesTool = await createReadMultipleFilesTool({
|
|
152
|
-
workingDir: workspace.primaryDir,
|
|
153
|
-
allowedDirs: workspace.allowedDirs,
|
|
154
|
-
tokenCounter,
|
|
155
|
-
});
|
|
156
|
-
const editFileTool = await createEditFileTool({
|
|
157
|
-
workingDir: workspace.primaryDir,
|
|
158
|
-
allowedDirs: workspace.allowedDirs,
|
|
159
|
-
modelManager,
|
|
160
|
-
tokenTracker,
|
|
161
|
-
});
|
|
162
|
-
const advancedEditFileTool = await createAdvancedEditFileTool({
|
|
163
|
-
workingDir: workspace.primaryDir,
|
|
164
|
-
allowedDirs: workspace.allowedDirs,
|
|
165
|
-
});
|
|
166
|
-
const saveFileTool = await createSaveFileTool({
|
|
167
|
-
workingDir: workspace.primaryDir,
|
|
168
|
-
allowedDirs: workspace.allowedDirs,
|
|
169
|
-
});
|
|
170
|
-
const moveFileTool = await createMoveFileTool({
|
|
171
|
-
workingDir: workspace.primaryDir,
|
|
172
|
-
allowedDirs: workspace.allowedDirs,
|
|
173
|
-
});
|
|
174
|
-
const directoryTreeTool = await createDirectoryTreeTool({
|
|
175
|
-
workingDir: workspace.primaryDir,
|
|
176
|
-
allowedDirs: workspace.allowedDirs,
|
|
177
|
-
tokenCounter,
|
|
178
|
-
});
|
|
179
|
-
const deleteFileTool = await createDeleteFileTool({
|
|
180
|
-
workingDir: workspace.primaryDir,
|
|
181
|
-
allowedDirs: workspace.allowedDirs,
|
|
182
|
-
});
|
|
183
|
-
const codeInterpreterTool = await createCodeInterpreterTool({
|
|
184
|
-
tokenCounter,
|
|
185
|
-
});
|
|
186
|
-
const globTool = createGlobTool({
|
|
187
|
-
tokenCounter,
|
|
188
|
-
});
|
|
189
|
-
const grepTool = createGrepTool({
|
|
190
|
-
tokenCounter,
|
|
191
|
-
});
|
|
192
|
-
const thinkTool = createThinkTool();
|
|
193
|
-
const webFetchTool = createWebFetchTool({
|
|
194
|
-
tokenCounter,
|
|
195
|
-
});
|
|
196
|
-
const webSearchTool = createWebSearchTool({
|
|
197
|
-
tokenCounter,
|
|
198
|
-
});
|
|
199
|
-
const bashTool = await createBashTool({
|
|
200
|
-
baseDir: workspace.primaryDir,
|
|
201
|
-
allowedDirs: workspace.allowedDirs,
|
|
202
|
-
tokenCounter,
|
|
203
|
-
});
|
|
204
|
-
const dynamicTools = await loadDynamicTools({
|
|
205
|
-
baseDir: workspace.primaryDir,
|
|
206
|
-
});
|
|
207
|
-
const tools = {
|
|
208
|
-
[EditFileTool.name]: tool({
|
|
209
|
-
...editFileTool.toolDef,
|
|
210
|
-
execute: editFileTool.execute,
|
|
211
|
-
}),
|
|
212
|
-
[AdvancedEditFileTool.name]: tool({
|
|
213
|
-
...advancedEditFileTool.toolDef,
|
|
214
|
-
execute: advancedEditFileTool.execute,
|
|
215
|
-
}),
|
|
216
|
-
[BashTool.name]: tool({
|
|
217
|
-
...bashTool.toolDef,
|
|
218
|
-
execute: bashTool.execute,
|
|
219
|
-
}),
|
|
220
|
-
[SaveFileTool.name]: tool({
|
|
221
|
-
...saveFileTool.toolDef,
|
|
222
|
-
execute: saveFileTool.execute,
|
|
223
|
-
}),
|
|
224
|
-
[DeleteFileTool.name]: tool({
|
|
225
|
-
...deleteFileTool.toolDef,
|
|
226
|
-
execute: deleteFileTool.execute,
|
|
227
|
-
}),
|
|
228
|
-
[MoveFileTool.name]: tool({
|
|
229
|
-
...moveFileTool.toolDef,
|
|
230
|
-
execute: moveFileTool.execute,
|
|
231
|
-
}),
|
|
232
|
-
[ReadFileTool.name]: tool({
|
|
233
|
-
...readFileTool.toolDef,
|
|
234
|
-
execute: readFileTool.execute,
|
|
235
|
-
}),
|
|
236
|
-
[ReadMultipleFilesTool.name]: tool({
|
|
237
|
-
...readMultipleFilesTool.toolDef,
|
|
238
|
-
execute: readMultipleFilesTool.execute,
|
|
239
|
-
}),
|
|
240
|
-
[GlobTool.name]: tool({
|
|
241
|
-
...globTool.toolDef,
|
|
242
|
-
execute: globTool.execute,
|
|
243
|
-
}),
|
|
244
|
-
[GrepTool.name]: tool({
|
|
245
|
-
...grepTool.toolDef,
|
|
246
|
-
execute: grepTool.execute,
|
|
247
|
-
}),
|
|
248
|
-
[DirectoryTreeTool.name]: tool({
|
|
249
|
-
...directoryTreeTool.toolDef,
|
|
250
|
-
execute: directoryTreeTool.execute,
|
|
251
|
-
}),
|
|
252
|
-
[CodeInterpreterTool.name]: tool({
|
|
253
|
-
...codeInterpreterTool.toolDef,
|
|
254
|
-
execute: codeInterpreterTool.execute,
|
|
255
|
-
}),
|
|
256
|
-
[ThinkTool.name]: tool({
|
|
257
|
-
...thinkTool.toolDef,
|
|
258
|
-
execute: thinkTool.execute,
|
|
259
|
-
}),
|
|
260
|
-
[WebFetchTool.name]: tool({
|
|
261
|
-
...webFetchTool.toolDef,
|
|
262
|
-
execute: webFetchTool.execute,
|
|
263
|
-
}),
|
|
264
|
-
[WebSearchTool.name]: tool({
|
|
265
|
-
...webSearchTool.toolDef,
|
|
266
|
-
execute: webSearchTool.execute,
|
|
267
|
-
}),
|
|
268
|
-
// Add dynamic tools with execute functions
|
|
269
|
-
...Object.fromEntries(Object.entries(dynamicTools).map(([name, toolObj]) => [
|
|
270
|
-
name,
|
|
271
|
-
tool({
|
|
272
|
-
...toolObj.toolDef,
|
|
273
|
-
execute: toolObj.execute,
|
|
274
|
-
}),
|
|
275
|
-
])),
|
|
276
|
-
};
|
|
277
|
-
return {
|
|
278
|
-
toolDefs: tools,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
export async function initAgents({ modelManager, tokenTracker, tokenCounter, workspace, }) {
|
|
282
|
-
const agentTools = createAgentTools({
|
|
283
|
-
modelManager,
|
|
284
|
-
tokenTracker,
|
|
285
|
-
tokenCounter,
|
|
286
|
-
workspace,
|
|
287
|
-
});
|
|
288
|
-
const tools = {
|
|
289
|
-
[AgentTool.name]: tool(agentTools.toolDef),
|
|
290
|
-
};
|
|
291
|
-
// Build executors map for manual loop
|
|
292
|
-
const executors = new Map();
|
|
293
|
-
executors.set(AgentTool.name, agentTools.execute);
|
|
294
|
-
return {
|
|
295
|
-
toolDefs: tools,
|
|
296
|
-
executors,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
export async function initCliAgents({ modelManager, tokenTracker, tokenCounter, workspace, }) {
|
|
300
|
-
const agentTools = createAgentTools({
|
|
301
|
-
modelManager,
|
|
302
|
-
tokenTracker,
|
|
303
|
-
tokenCounter,
|
|
304
|
-
workspace,
|
|
305
|
-
});
|
|
306
|
-
const tools = {
|
|
307
|
-
[AgentTool.name]: tool({
|
|
308
|
-
...agentTools.toolDef,
|
|
309
|
-
execute: agentTools.execute,
|
|
310
|
-
}),
|
|
54
|
+
...Object.fromEntries(Object.entries(dynamicTools).map(([name, toolObj]) => [name, toolObj])),
|
|
311
55
|
};
|
|
312
|
-
return
|
|
56
|
+
return tools;
|
|
313
57
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
3
|
+
export declare const LsTool: {
|
|
4
|
+
name: "LS";
|
|
5
|
+
};
|
|
6
|
+
declare const inputSchema: z.ZodObject<{
|
|
7
|
+
path: z.ZodOptional<z.ZodString>;
|
|
8
|
+
limit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type LsInputSchema = z.infer<typeof inputSchema>;
|
|
11
|
+
export declare const createLsTool: (options: {
|
|
12
|
+
workingDir: string;
|
|
13
|
+
allowedDirs?: string[];
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
toolDef: {
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: z.ZodObject<{
|
|
18
|
+
path: z.ZodOptional<z.ZodString>;
|
|
19
|
+
limit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
};
|
|
22
|
+
display({ path: providedPath, limit }: LsInputSchema): string;
|
|
23
|
+
execute({ path: providedPath, limit }: LsInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
24
|
+
}>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,QAAA,MAAM,WAAW;;;iBAQf,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAIjD,eAAO,MAAM,YAAY,GAAU,SAAS;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;2CAS0C,aAAa;2CAMnB,aAAa,mBAC3B,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6DrB,CAAC"}
|
package/dist/tools/ls.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import style from "../terminal/style.js";
|
|
5
|
+
import { isDirectory } from "../utils/filesystem/operations.js";
|
|
6
|
+
import { validatePath } from "../utils/filesystem/security.js";
|
|
7
|
+
import { convertNullString } from "../utils/zod.js";
|
|
8
|
+
export const LsTool = {
|
|
9
|
+
name: "LS",
|
|
10
|
+
};
|
|
11
|
+
const inputSchema = z.object({
|
|
12
|
+
path: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Directory to list (default: current directory)"),
|
|
16
|
+
limit: z
|
|
17
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
18
|
+
.describe("Maximum number of entries to return (default: 500)"),
|
|
19
|
+
});
|
|
20
|
+
const DEFAULT_ENTRY_LIMIT = 500;
|
|
21
|
+
export const createLsTool = async (options) => {
|
|
22
|
+
const { workingDir, allowedDirs } = options;
|
|
23
|
+
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
24
|
+
return {
|
|
25
|
+
toolDef: {
|
|
26
|
+
description: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is limited to ${DEFAULT_ENTRY_LIMIT} entries by default. Use the limit parameter to adjust.`,
|
|
27
|
+
inputSchema,
|
|
28
|
+
},
|
|
29
|
+
display({ path: providedPath, limit }) {
|
|
30
|
+
const dirPath = providedPath ?? ".";
|
|
31
|
+
const effectiveLimit = limit ?? 500;
|
|
32
|
+
return `\n> Listing ${style.cyan(dirPath)} (limit: ${effectiveLimit})`;
|
|
33
|
+
},
|
|
34
|
+
async execute({ path: providedPath, limit }, { abortSignal }) {
|
|
35
|
+
if (abortSignal?.aborted) {
|
|
36
|
+
throw new Error("Directory listing aborted");
|
|
37
|
+
}
|
|
38
|
+
const dirPath = providedPath ?? ".";
|
|
39
|
+
const effectiveLimit = limit ?? DEFAULT_ENTRY_LIMIT;
|
|
40
|
+
const resolvedPath = await validatePath(path.resolve(workingDir, dirPath), allowedDirectory, { requireExistence: true, abortSignal });
|
|
41
|
+
if (abortSignal?.aborted) {
|
|
42
|
+
throw new Error("Directory listing aborted before validation");
|
|
43
|
+
}
|
|
44
|
+
const isDir = await isDirectory(resolvedPath);
|
|
45
|
+
if (!isDir) {
|
|
46
|
+
throw new Error(`Not a directory: ${resolvedPath}`);
|
|
47
|
+
}
|
|
48
|
+
let entries;
|
|
49
|
+
try {
|
|
50
|
+
entries = await fs.readdir(resolvedPath);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new Error(`Cannot read directory: ${e.message}`);
|
|
54
|
+
}
|
|
55
|
+
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
56
|
+
const results = [];
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (results.length >= effectiveLimit) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
const fullPath = path.join(resolvedPath, entry);
|
|
62
|
+
let suffix = "";
|
|
63
|
+
try {
|
|
64
|
+
const entryStat = await fs.stat(fullPath);
|
|
65
|
+
if (entryStat.isDirectory()) {
|
|
66
|
+
suffix = "/";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
results.push(entry + suffix);
|
|
73
|
+
}
|
|
74
|
+
if (results.length === 0) {
|
|
75
|
+
return "(empty directory)";
|
|
76
|
+
}
|
|
77
|
+
return results.join("\n");
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
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 ReadFileTool: {
|
|
6
|
-
name: "
|
|
4
|
+
name: "Read";
|
|
7
5
|
};
|
|
8
6
|
declare const inputSchema: z.ZodObject<{
|
|
9
7
|
path: z.ZodString;
|
|
10
|
-
encoding: z.ZodEnum<{
|
|
8
|
+
encoding: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
11
9
|
utf8: "utf8";
|
|
12
10
|
ascii: "ascii";
|
|
13
11
|
"utf-8": "utf-8";
|
|
@@ -19,21 +17,21 @@ declare const inputSchema: z.ZodObject<{
|
|
|
19
17
|
latin1: "latin1";
|
|
20
18
|
binary: "binary";
|
|
21
19
|
hex: "hex";
|
|
22
|
-
}
|
|
23
|
-
startLine: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
24
|
-
lineCount: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
20
|
+
}>>>;
|
|
21
|
+
startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
22
|
+
lineCount: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
23
|
+
maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
25
24
|
}, z.core.$strip>;
|
|
26
25
|
type ReadFileInputSchema = z.infer<typeof inputSchema>;
|
|
27
|
-
export declare const createReadFileTool: ({ workingDir, allowedDirs,
|
|
26
|
+
export declare const createReadFileTool: ({ workingDir, allowedDirs, }: {
|
|
28
27
|
workingDir: string;
|
|
29
28
|
allowedDirs?: string[];
|
|
30
|
-
tokenCounter: TokenCounter;
|
|
31
29
|
}) => Promise<{
|
|
32
30
|
toolDef: {
|
|
33
31
|
description: string;
|
|
34
32
|
inputSchema: z.ZodObject<{
|
|
35
33
|
path: z.ZodString;
|
|
36
|
-
encoding: z.ZodEnum<{
|
|
34
|
+
encoding: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
37
35
|
utf8: "utf8";
|
|
38
36
|
ascii: "ascii";
|
|
39
37
|
"utf-8": "utf-8";
|
|
@@ -45,12 +43,14 @@ export declare const createReadFileTool: ({ workingDir, allowedDirs, tokenCounte
|
|
|
45
43
|
latin1: "latin1";
|
|
46
44
|
binary: "binary";
|
|
47
45
|
hex: "hex";
|
|
48
|
-
}
|
|
49
|
-
startLine: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
50
|
-
lineCount: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
46
|
+
}>>>;
|
|
47
|
+
startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
48
|
+
lineCount: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
49
|
+
maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
51
50
|
}, z.core.$strip>;
|
|
52
51
|
};
|
|
53
|
-
|
|
52
|
+
display({ path: providedPath, startLine, lineCount }: ReadFileInputSchema): string;
|
|
53
|
+
execute({ path: providedPath, encoding, startLine, lineCount, maxBytes, }: ReadFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
54
54
|
}>;
|
|
55
55
|
export {};
|
|
56
56
|
//# sourceMappingURL=read-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;iBAuBf,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;;;;;;;;;;;;;;;;;;;;;;;0DAOyD,mBAAmB;+EAUpE,mBAAmB,mBACL,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAqDrB,CAAC"}
|
package/dist/tools/read-file.js
CHANGED
|
@@ -2,97 +2,73 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import { isNumber } from "@travisennis/stdlib/typeguards";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import style from "../terminal/style.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
|
|
6
|
+
import { convertNullString } from "../utils/zod.js";
|
|
7
7
|
import { fileEncodingSchema } from "./types.js";
|
|
8
|
+
// default limit in bytes
|
|
9
|
+
const DEFAULT_BYTE_LIMIT = 80 * 1024;
|
|
8
10
|
export const ReadFileTool = {
|
|
9
|
-
name: "
|
|
11
|
+
name: "Read",
|
|
10
12
|
};
|
|
11
13
|
const inputSchema = z.object({
|
|
12
14
|
path: z.string().describe("Absolute path to file to read"),
|
|
13
|
-
encoding: fileEncodingSchema
|
|
14
|
-
startLine: z.coerce
|
|
15
|
-
.number()
|
|
15
|
+
encoding: fileEncodingSchema
|
|
16
16
|
.nullable()
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.nullable()
|
|
21
|
-
.describe("
|
|
17
|
+
.default("utf-8")
|
|
18
|
+
.describe('Encoding format for reading the file. Use "utf-8" as default for text files'),
|
|
19
|
+
startLine: z
|
|
20
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
21
|
+
.describe("1-based line number to start reading from. Required but nullable. Pass null to start at beginning of file"),
|
|
22
|
+
lineCount: z
|
|
23
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
24
|
+
.describe("Maximum number of lines to read. Required but nullable. Pass null to get all lines."),
|
|
25
|
+
maxBytes: z
|
|
26
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
27
|
+
.describe("Maximum number of bytes to read. Set to 0 for no limit. (Default: 80KB)"),
|
|
22
28
|
});
|
|
23
|
-
export const createReadFileTool = async ({ workingDir, allowedDirs,
|
|
29
|
+
export const createReadFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
24
30
|
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
25
31
|
return {
|
|
26
32
|
toolDef: {
|
|
27
|
-
description:
|
|
28
|
-
"Handles various text encodings and provides detailed error messages " +
|
|
29
|
-
"if the file cannot be read. Use this tool when you need to examine " +
|
|
30
|
-
"the contents of a single file. Only works within allowed directories.",
|
|
33
|
+
description: `Read the complete contents of a file from the file system unless startLine and lineCount are given to read a file selection. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Only works within allowed directories. Automatically limits file size to prevent overwhelming output. Default limit is ${DEFAULT_BYTE_LIMIT} bytes (${DEFAULT_BYTE_LIMIT / 1024}KB). Use maxBytes parameter to override this limit.`,
|
|
31
34
|
inputSchema,
|
|
32
35
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const startIndex = (startLine ?? 1) - 1; // Default to start of file if only lineCount is given
|
|
55
|
-
const count = lineCount ?? totalLines - startIndex; // Default to read all lines from start if only startLine is given
|
|
56
|
-
if (startIndex < 0 || startIndex >= totalLines) {
|
|
57
|
-
const errorMsg = `startLine ${startLine} is out of bounds for file with ${totalLines} lines.`;
|
|
58
|
-
yield {
|
|
59
|
-
name: ReadFileTool.name,
|
|
60
|
-
event: "tool-error",
|
|
61
|
-
id: toolCallId,
|
|
62
|
-
data: errorMsg,
|
|
63
|
-
};
|
|
64
|
-
yield errorMsg;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const endIndex = Math.min(startIndex + count, totalLines);
|
|
68
|
-
file = lines.slice(startIndex, endIndex).join("\n");
|
|
36
|
+
display({ path: providedPath, startLine, lineCount }) {
|
|
37
|
+
return `\n> ${style.cyan(providedPath)}${startLine ? style.cyan(`:${startLine}`) : ""}${lineCount ? style.cyan(`:${lineCount}`) : ""}`;
|
|
38
|
+
},
|
|
39
|
+
async execute({ path: providedPath, encoding, startLine, lineCount, maxBytes, }, { abortSignal }) {
|
|
40
|
+
if (abortSignal?.aborted) {
|
|
41
|
+
throw new Error("File reading aborted");
|
|
42
|
+
}
|
|
43
|
+
const filePath = await validatePath(joinWorkingDir(providedPath, workingDir), allowedDirectory, { abortSignal });
|
|
44
|
+
if (abortSignal?.aborted) {
|
|
45
|
+
throw new Error("File reading aborted before file read");
|
|
46
|
+
}
|
|
47
|
+
let file = await fs.readFile(filePath, {
|
|
48
|
+
encoding: encoding ?? "utf-8",
|
|
49
|
+
});
|
|
50
|
+
if (isNumber(startLine) || isNumber(lineCount)) {
|
|
51
|
+
const lines = file.split("\n");
|
|
52
|
+
const totalLines = lines.length;
|
|
53
|
+
const startIndex = (startLine ?? 1) - 1;
|
|
54
|
+
const count = lineCount ?? totalLines - startIndex;
|
|
55
|
+
if (startIndex < 0 || startIndex >= totalLines) {
|
|
56
|
+
throw new Error(`startLine ${startLine} is out of bounds for file with ${totalLines} lines.`);
|
|
69
57
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
: "Use startLine and lineCount parameters to read specific portions, or use grepFiles for targeted access", encoding);
|
|
73
|
-
// Calculate line count for the returned content
|
|
74
|
-
const linesRead = result.content.split("\n").length;
|
|
75
|
-
yield {
|
|
76
|
-
name: ReadFileTool.name,
|
|
77
|
-
id: toolCallId,
|
|
78
|
-
event: "tool-completion",
|
|
79
|
-
// Include success, line count, and token count
|
|
80
|
-
data: !result.truncated
|
|
81
|
-
? `Read ${linesRead} lines (${result.tokenCount} tokens)`
|
|
82
|
-
: result.content,
|
|
83
|
-
};
|
|
84
|
-
yield result.content;
|
|
58
|
+
const endIndex = Math.min(startIndex + count, totalLines);
|
|
59
|
+
file = lines.slice(startIndex, endIndex).join("\n");
|
|
85
60
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
61
|
+
const effectiveMaxBytes = maxBytes ?? DEFAULT_BYTE_LIMIT;
|
|
62
|
+
if (effectiveMaxBytes !== null &&
|
|
63
|
+
effectiveMaxBytes !== undefined &&
|
|
64
|
+
effectiveMaxBytes > 0) {
|
|
65
|
+
const buffer = Buffer.from(file, encoding ?? "utf-8");
|
|
66
|
+
if (buffer.byteLength > effectiveMaxBytes) {
|
|
67
|
+
const truncatedBuffer = buffer.subarray(0, effectiveMaxBytes);
|
|
68
|
+
file = truncatedBuffer.toString(encoding ?? "utf-8");
|
|
69
|
+
}
|
|
95
70
|
}
|
|
71
|
+
return file;
|
|
96
72
|
},
|
|
97
73
|
};
|
|
98
74
|
};
|