@travisennis/acai 0.0.9 → 0.0.11
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 +51 -760
- package/bin/acai +52 -0
- package/dist/agent/index.d.ts +12 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +380 -199
- package/dist/agent/sub-agent.d.ts +23 -0
- package/dist/agent/sub-agent.d.ts.map +1 -0
- package/dist/agent/sub-agent.js +109 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/{cli.js → cli/index.js} +84 -77
- package/dist/{stdin.d.ts → cli/stdin.d.ts} +2 -1
- package/dist/cli/stdin.d.ts.map +1 -0
- package/dist/{stdin.js → cli/stdin.js} +11 -0
- package/dist/commands/copy/index.js +2 -2
- package/dist/commands/copy/utils.d.ts.map +1 -1
- package/dist/commands/copy/utils.js +15 -13
- package/dist/commands/generate-rules/index.d.ts +1 -1
- package/dist/commands/generate-rules/index.d.ts.map +1 -1
- package/dist/commands/generate-rules/index.js +16 -101
- package/dist/commands/generate-rules/service.d.ts +22 -0
- package/dist/commands/generate-rules/service.d.ts.map +1 -0
- package/dist/commands/generate-rules/service.js +103 -0
- package/dist/commands/handoff/index.js +2 -2
- package/dist/commands/health/index.js +1 -1
- package/dist/commands/health/utils.d.ts +3 -2
- package/dist/commands/health/utils.d.ts.map +1 -1
- package/dist/commands/health/utils.js +6 -0
- package/dist/commands/history/index.d.ts +1 -1
- package/dist/commands/history/index.d.ts.map +1 -1
- package/dist/commands/history/index.js +17 -18
- package/dist/commands/history/types.d.ts +38 -0
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/history/utils.d.ts.map +1 -1
- package/dist/commands/history/utils.js +63 -58
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +3 -8
- package/dist/commands/init-project/index.d.ts.map +1 -1
- package/dist/commands/init-project/index.js +3 -3
- package/dist/commands/init-project/utils.d.ts +2 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +10 -2
- package/dist/commands/list-tools/index.d.ts.map +1 -1
- package/dist/commands/list-tools/index.js +7 -31
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +55 -33
- package/dist/commands/model/index.d.ts.map +1 -1
- package/dist/commands/model/index.js +20 -151
- package/dist/commands/model/model-panel.d.ts +4 -0
- package/dist/commands/model/model-panel.d.ts.map +1 -0
- package/dist/commands/model/model-panel.js +144 -0
- package/dist/commands/paste/index.d.ts.map +1 -1
- package/dist/commands/paste/index.js +59 -62
- package/dist/commands/paste/utils.d.ts.map +1 -1
- package/dist/commands/paste/utils.js +88 -58
- package/dist/commands/pickup/index.d.ts.map +1 -1
- package/dist/commands/pickup/index.js +6 -3
- package/dist/commands/pickup/utils.js +3 -3
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +33 -50
- package/dist/commands/review/index.d.ts.map +1 -1
- package/dist/commands/review/index.js +3 -117
- package/dist/commands/review/review-panel.d.ts +3 -0
- package/dist/commands/review/review-panel.d.ts.map +1 -0
- package/dist/commands/review/review-panel.js +186 -0
- package/dist/commands/review/utils.d.ts +15 -1
- package/dist/commands/review/utils.d.ts.map +1 -1
- package/dist/commands/review/utils.js +127 -68
- package/dist/commands/session/index.d.ts +1 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +124 -135
- package/dist/commands/shell/index.d.ts.map +1 -1
- package/dist/commands/shell/index.js +16 -1
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/{config.d.ts → config/index.d.ts} +20 -9
- package/dist/config/index.d.ts.map +1 -0
- package/dist/{config.js → config/index.js} +43 -42
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +75 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -141
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +18 -36
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +4 -3
- package/dist/models/anthropic-provider.d.ts +2 -5
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -70
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +2 -3
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -26
- package/dist/models/groq-provider.d.ts +1 -0
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +13 -2
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +20 -8
- package/dist/models/openai-provider.d.ts +2 -5
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -52
- package/dist/models/opencode-go-provider.d.ts +25 -0
- package/dist/models/opencode-go-provider.d.ts.map +1 -0
- package/dist/models/opencode-go-provider.js +78 -0
- package/dist/models/opencode-zen-provider.d.ts +7 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +49 -10
- package/dist/models/openrouter-provider.d.ts +27 -31
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +121 -180
- package/dist/models/providers.d.ts +3 -3
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +6 -0
- package/dist/models/xai-provider.d.ts +4 -3
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +18 -18
- package/dist/modes/manager.d.ts +24 -0
- package/dist/modes/manager.d.ts.map +1 -0
- package/dist/modes/manager.js +77 -0
- package/dist/modes/prompts.d.ts +2 -0
- package/dist/modes/prompts.d.ts.map +1 -0
- package/dist/modes/prompts.js +142 -0
- package/dist/prompts/mentions.d.ts +11 -0
- package/dist/prompts/mentions.d.ts.map +1 -0
- package/dist/{mentions.js → prompts/mentions.js} +55 -85
- package/dist/{prompts.d.ts → prompts/system-prompt.d.ts} +7 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/{prompts.js → prompts/system-prompt.js} +31 -16
- package/dist/repl/index.d.ts +174 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/{repl-new.js → repl/index.js} +397 -76
- package/dist/repl/project-status.d.ts +1 -0
- package/dist/repl/project-status.d.ts.map +1 -1
- package/dist/repl/project-status.js +4 -1
- package/dist/sessions/manager.d.ts +92 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +262 -9
- package/dist/sessions/summary.d.ts +4 -0
- package/dist/sessions/summary.d.ts.map +1 -0
- package/dist/sessions/summary.js +30 -0
- package/dist/skills/index.d.ts +29 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +294 -0
- package/dist/subagents/index.d.ts +16 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +231 -0
- package/dist/terminal/control.d.ts +1 -1
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +3 -3
- package/dist/terminal/east-asian-width.d.ts.map +1 -1
- package/dist/terminal/east-asian-width.js +404 -351
- package/dist/terminal/keys.d.ts +17 -0
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +37 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +24 -12
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +25 -27
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/style.js +4 -7
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +41 -27
- package/dist/terminal/table/cell.d.ts +12 -0
- package/dist/terminal/table/cell.d.ts.map +1 -1
- package/dist/terminal/table/cell.js +40 -25
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +100 -68
- package/dist/terminal/table/utils.d.ts +1 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +17 -10
- package/dist/terminal/wrap-ansi.d.ts.map +1 -1
- package/dist/terminal/wrap-ansi.js +174 -105
- package/dist/tokens/tracker.d.ts +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +3 -0
- package/dist/tools/agent.d.ts +27 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +81 -0
- package/dist/tools/apply-patch.d.ts +62 -0
- package/dist/tools/apply-patch.d.ts.map +1 -0
- package/dist/tools/apply-patch.js +377 -0
- package/dist/tools/bash.d.ts +4 -3
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +349 -141
- package/dist/tools/directory-tree.d.ts +3 -3
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +8 -5
- package/dist/tools/dynamic-tool-loader.d.ts +3 -6
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +20 -4
- package/dist/tools/edit-file.d.ts +7 -7
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +292 -85
- package/dist/tools/glob.d.ts +6 -6
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +110 -63
- package/dist/tools/grep.d.ts +15 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +315 -193
- package/dist/tools/index.d.ts +114 -9
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +39 -24
- package/dist/tools/ls.d.ts +2 -2
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +7 -5
- package/dist/tools/read-file.d.ts +4 -6
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -39
- package/dist/tools/save-file.d.ts +3 -3
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +36 -31
- package/dist/tools/skill.d.ts +23 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +65 -0
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +2 -9
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +12 -0
- package/dist/tools/web-fetch.d.ts +50 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +446 -0
- package/dist/tools/web-search.d.ts +44 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +226 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/attachment-provider.js +25 -78
- package/dist/tui/autocomplete/base-provider.d.ts +1 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.js +3 -17
- package/dist/tui/autocomplete/command-provider.d.ts +1 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/command-provider.js +3 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/file-search-provider.js +37 -17
- package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
- package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/skill-provider.js +49 -0
- package/dist/tui/autocomplete/utils.d.ts +2 -1
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +25 -23
- package/dist/tui/autocomplete.d.ts +2 -2
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +3 -5
- package/dist/tui/components/assistant-message.d.ts.map +1 -1
- package/dist/tui/components/assistant-message.js +0 -4
- package/dist/tui/components/editor.d.ts +18 -3
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +211 -237
- package/dist/tui/components/footer.d.ts +6 -4
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +49 -25
- package/dist/tui/components/markdown.d.ts +10 -7
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +57 -39
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +35 -33
- package/dist/tui/components/notification.d.ts +13 -2
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/notification.js +36 -2
- package/dist/tui/components/progress-bar.js +1 -1
- package/dist/tui/components/select-list.d.ts +1 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +14 -11
- package/dist/tui/components/text.d.ts +16 -0
- package/dist/tui/components/text.d.ts.map +1 -1
- package/dist/tui/components/text.js +72 -57
- package/dist/tui/components/thinking-block.d.ts +9 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +43 -11
- package/dist/tui/components/tool-execution.d.ts +5 -1
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +19 -10
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +0 -3
- package/dist/tui/components/welcome.d.ts +2 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +2 -2
- package/dist/tui/editor-launcher.d.ts +3 -2
- package/dist/tui/editor-launcher.d.ts.map +1 -1
- package/dist/tui/index.d.ts +0 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +10 -2
- package/dist/tui/tui.d.ts +43 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +166 -41
- package/dist/tui/utils.d.ts +1 -5
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +271 -44
- package/dist/utils/bash/parse.d.ts +19 -0
- package/dist/utils/bash/parse.d.ts.map +1 -0
- package/dist/utils/bash/parse.js +223 -0
- package/dist/utils/bash/quote.d.ts +6 -0
- package/dist/utils/bash/quote.d.ts.map +1 -0
- package/dist/utils/bash/quote.js +23 -0
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +211 -126
- package/dist/utils/command-protection.d.ts +28 -0
- package/dist/utils/command-protection.d.ts.map +1 -0
- package/dist/utils/command-protection.js +324 -0
- package/dist/utils/dedent.d.ts.map +1 -0
- package/dist/utils/env-expand.d.ts +2 -0
- package/dist/utils/env-expand.d.ts.map +1 -0
- package/dist/utils/env-expand.js +8 -0
- package/dist/utils/filesystem/path-display.d.ts +11 -0
- package/dist/utils/filesystem/path-display.d.ts.map +1 -0
- package/dist/utils/filesystem/path-display.js +32 -0
- package/dist/utils/filesystem/security.d.ts +2 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +28 -30
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/{formatting.js → utils/formatting.js} +1 -1
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +30 -0
- package/dist/utils/glob.d.ts +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/{logger.js → utils/logger.js} +1 -1
- package/dist/utils/parsing.d.ts.map +1 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +90 -37
- package/dist/utils/templates.d.ts +2 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +24 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/package.json +35 -26
- package/dist/cli.d.ts +0 -23
- package/dist/cli.d.ts.map +0 -1
- package/dist/commands/add-directory/types.d.ts +0 -6
- package/dist/commands/add-directory/types.d.ts.map +0 -1
- package/dist/commands/add-directory/types.js +0 -1
- package/dist/commands/copy/types.d.ts +0 -3
- package/dist/commands/copy/types.d.ts.map +0 -1
- package/dist/commands/copy/types.js +0 -1
- package/dist/commands/exit/index.d.ts +0 -10
- package/dist/commands/exit/index.d.ts.map +0 -1
- package/dist/commands/exit/index.js +0 -21
- package/dist/commands/exit/types.d.ts +0 -8
- package/dist/commands/exit/types.d.ts.map +0 -1
- package/dist/commands/exit/types.js +0 -1
- package/dist/commands/exit/utils.d.ts +0 -2
- package/dist/commands/exit/utils.d.ts.map +0 -1
- package/dist/commands/exit/utils.js +0 -13
- package/dist/commands/prompt/index.d.ts +0 -5
- package/dist/commands/prompt/index.d.ts.map +0 -1
- package/dist/commands/prompt/index.js +0 -122
- package/dist/commands/prompt/types.d.ts +0 -15
- package/dist/commands/prompt/types.d.ts.map +0 -1
- package/dist/commands/prompt/types.js +0 -1
- package/dist/commands/prompt/utils.d.ts +0 -12
- package/dist/commands/prompt/utils.d.ts.map +0 -1
- package/dist/commands/prompt/utils.js +0 -107
- package/dist/commands/reset/index.d.ts +0 -3
- package/dist/commands/reset/index.d.ts.map +0 -1
- package/dist/commands/reset/index.js +0 -25
- package/dist/commands/reset/types.d.ts +0 -1
- package/dist/commands/reset/types.d.ts.map +0 -1
- package/dist/commands/reset/types.js +0 -3
- package/dist/commands/review/types.d.ts +0 -12
- package/dist/commands/review/types.d.ts.map +0 -1
- package/dist/commands/review/types.js +0 -1
- package/dist/commands/save/index.d.ts +0 -3
- package/dist/commands/save/index.d.ts.map +0 -1
- package/dist/commands/save/index.js +0 -19
- package/dist/config.d.ts.map +0 -1
- package/dist/dedent.d.ts.map +0 -1
- package/dist/formatting.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mentions.d.ts +0 -14
- package/dist/mentions.d.ts.map +0 -1
- package/dist/parsing.d.ts.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/repl-new.d.ts +0 -65
- package/dist/repl-new.d.ts.map +0 -1
- package/dist/skills.d.ts +0 -16
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js +0 -233
- package/dist/stdin.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.d.ts +0 -21
- package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.js +0 -164
- package/dist/utils/iterables.d.ts +0 -2
- package/dist/utils/iterables.d.ts.map +0 -1
- package/dist/utils/iterables.js +0 -6
- package/dist/version.d.ts.map +0 -1
- /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
- /package/dist/{dedent.js → utils/dedent.js} +0 -0
- /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
- /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
- /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
- /package/dist/{parsing.js → utils/parsing.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
package/dist/tools/index.d.ts
CHANGED
|
@@ -11,15 +11,29 @@ export type CompleteToolNames = keyof CompleteToolSet;
|
|
|
11
11
|
export declare function initTools({ workspace, }: {
|
|
12
12
|
workspace: WorkspaceContext;
|
|
13
13
|
}): Promise<{
|
|
14
|
+
readonly ApplyPatch: {
|
|
15
|
+
toolDef: {
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: import("zod").ZodObject<{
|
|
18
|
+
patchText: import("zod").ZodString;
|
|
19
|
+
}, import("zod/v4/core").$strip>;
|
|
20
|
+
};
|
|
21
|
+
display({ patchText }: {
|
|
22
|
+
patchText: string;
|
|
23
|
+
}): string;
|
|
24
|
+
execute({ patchText }: {
|
|
25
|
+
patchText: string;
|
|
26
|
+
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
27
|
+
};
|
|
14
28
|
readonly Edit: {
|
|
15
29
|
toolDef: {
|
|
16
30
|
description: string;
|
|
17
31
|
inputSchema: import("zod").ZodObject<{
|
|
18
32
|
path: import("zod").ZodString;
|
|
19
|
-
edits: import("zod").ZodArray<import("zod").ZodObject<{
|
|
33
|
+
edits: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodArray<import("zod").ZodObject<{
|
|
20
34
|
oldText: import("zod").ZodString;
|
|
21
35
|
newText: import("zod").ZodString;
|
|
22
|
-
}, import("zod/v4/core").$strip
|
|
36
|
+
}, import("zod/v4/core").$strip>>>;
|
|
23
37
|
}, import("zod/v4/core").$strip>;
|
|
24
38
|
};
|
|
25
39
|
display({ path, edits }: {
|
|
@@ -112,7 +126,6 @@ export declare function initTools({ workspace, }: {
|
|
|
112
126
|
}>>>;
|
|
113
127
|
startLine: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
114
128
|
lineCount: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
115
|
-
maxBytes: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
116
129
|
}, import("zod/v4/core").$strip>;
|
|
117
130
|
};
|
|
118
131
|
display({ path: providedPath, startLine, lineCount }: {
|
|
@@ -120,26 +133,24 @@ export declare function initTools({ workspace, }: {
|
|
|
120
133
|
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | null;
|
|
121
134
|
startLine: number | null;
|
|
122
135
|
lineCount: number | null;
|
|
123
|
-
maxBytes: number | null;
|
|
124
136
|
}): string;
|
|
125
|
-
execute({ path: providedPath, encoding, startLine, lineCount,
|
|
137
|
+
execute({ path: providedPath, encoding, startLine, lineCount, }: {
|
|
126
138
|
path: string;
|
|
127
139
|
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | null;
|
|
128
140
|
startLine: number | null;
|
|
129
141
|
lineCount: number | null;
|
|
130
|
-
maxBytes: number | null;
|
|
131
142
|
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
132
143
|
};
|
|
133
144
|
readonly Glob: {
|
|
134
145
|
toolDef: {
|
|
135
146
|
description: string;
|
|
136
147
|
inputSchema: import("zod").ZodObject<{
|
|
137
|
-
patterns: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]
|
|
138
|
-
path: import("zod").ZodString
|
|
148
|
+
patterns: import("zod").ZodPipe<import("zod").ZodTransform<{}, unknown>, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
|
|
149
|
+
path: import("zod").ZodPipe<import("zod").ZodTransform<{}, unknown>, import("zod").ZodString>;
|
|
139
150
|
gitignore: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
140
151
|
recursive: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
141
152
|
expandDirectories: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
142
|
-
ignoreFiles: import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]
|
|
153
|
+
ignoreFiles: import("zod").ZodPipe<import("zod").ZodTransform<{} | null | undefined, unknown>, import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>>;
|
|
143
154
|
cwd: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedString<unknown>>>;
|
|
144
155
|
maxResults: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
145
156
|
}, import("zod/v4/core").$strip>;
|
|
@@ -252,5 +263,99 @@ export declare function initTools({ workspace, }: {
|
|
|
252
263
|
path?: string | undefined;
|
|
253
264
|
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
254
265
|
};
|
|
266
|
+
readonly Skill: {
|
|
267
|
+
toolDef: {
|
|
268
|
+
description: string;
|
|
269
|
+
inputSchema: import("zod").ZodObject<{
|
|
270
|
+
skill: import("zod").ZodString;
|
|
271
|
+
args: import("zod").ZodOptional<import("zod").ZodString>;
|
|
272
|
+
}, import("zod/v4/core").$strip>;
|
|
273
|
+
};
|
|
274
|
+
display({ skill: skillName }: {
|
|
275
|
+
skill: string;
|
|
276
|
+
args?: string | undefined;
|
|
277
|
+
}): string;
|
|
278
|
+
execute({ skill: skillName, args }: {
|
|
279
|
+
skill: string;
|
|
280
|
+
args?: string | undefined;
|
|
281
|
+
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
282
|
+
};
|
|
283
|
+
readonly Agent: {
|
|
284
|
+
toolDef: {
|
|
285
|
+
description: string;
|
|
286
|
+
inputSchema: import("zod").ZodObject<{
|
|
287
|
+
prompt: import("zod").ZodString;
|
|
288
|
+
type: import("zod").ZodString;
|
|
289
|
+
timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
290
|
+
}, import("zod/v4/core").$strip>;
|
|
291
|
+
};
|
|
292
|
+
display: ({ prompt, type }: import("zod").infer<import("zod").ZodObject<{
|
|
293
|
+
prompt: import("zod").ZodString;
|
|
294
|
+
type: import("zod").ZodString;
|
|
295
|
+
timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
296
|
+
}, import("zod/v4/core").$strip>>) => string;
|
|
297
|
+
execute: ({ prompt, type, timeout }: import("zod").infer<import("zod").ZodObject<{
|
|
298
|
+
prompt: import("zod").ZodString;
|
|
299
|
+
type: import("zod").ZodString;
|
|
300
|
+
timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
301
|
+
}, import("zod/v4/core").$strip>>, { abortSignal }: import("./types.ts").ToolExecutionOptions) => Promise<string>;
|
|
302
|
+
};
|
|
303
|
+
readonly WebSearch: {
|
|
304
|
+
toolDef: {
|
|
305
|
+
description: string;
|
|
306
|
+
inputSchema: import("zod").ZodObject<{
|
|
307
|
+
query: import("zod").ZodString;
|
|
308
|
+
numResults: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
309
|
+
timeout: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
310
|
+
provider: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
311
|
+
exa: "exa";
|
|
312
|
+
duckduckgo: "duckduckgo";
|
|
313
|
+
}>>;
|
|
314
|
+
}, import("zod/v4/core").$strip>;
|
|
315
|
+
};
|
|
316
|
+
display({ query }: {
|
|
317
|
+
query: string;
|
|
318
|
+
numResults?: number | null | undefined;
|
|
319
|
+
timeout?: number | null | undefined;
|
|
320
|
+
provider?: "exa" | "duckduckgo" | undefined;
|
|
321
|
+
}): string;
|
|
322
|
+
execute(options: {
|
|
323
|
+
query: string;
|
|
324
|
+
numResults?: number | null | undefined;
|
|
325
|
+
timeout?: number | null | undefined;
|
|
326
|
+
provider?: "exa" | "duckduckgo" | undefined;
|
|
327
|
+
}, executionOptions: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
328
|
+
};
|
|
329
|
+
readonly WebFetch: {
|
|
330
|
+
toolDef: {
|
|
331
|
+
description: string;
|
|
332
|
+
inputSchema: import("zod").ZodObject<{
|
|
333
|
+
url: import("zod").ZodString;
|
|
334
|
+
output: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
335
|
+
markdown: "markdown";
|
|
336
|
+
text: "text";
|
|
337
|
+
html: "html";
|
|
338
|
+
json: "json";
|
|
339
|
+
}>>;
|
|
340
|
+
jina: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
341
|
+
timeout: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
342
|
+
headers: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
343
|
+
}, import("zod/v4/core").$strip>;
|
|
344
|
+
};
|
|
345
|
+
display({ url }: {
|
|
346
|
+
url: string;
|
|
347
|
+
output: "markdown" | "text" | "html" | "json";
|
|
348
|
+
jina?: boolean | null | undefined;
|
|
349
|
+
timeout?: number | null | undefined;
|
|
350
|
+
headers?: boolean | null | undefined;
|
|
351
|
+
}): string;
|
|
352
|
+
execute(options: {
|
|
353
|
+
url: string;
|
|
354
|
+
output: "markdown" | "text" | "html" | "json";
|
|
355
|
+
jina?: boolean | null | undefined;
|
|
356
|
+
timeout?: number | null | undefined;
|
|
357
|
+
headers?: boolean | null | undefined;
|
|
358
|
+
}, executionOptions: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
359
|
+
};
|
|
255
360
|
}>;
|
|
256
361
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAoBpD,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,eAAe,CACvE,OAAO,SAAS,CACjB,CAAC,CAAC,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,IAAI,CAC5D,OAAO,EACP,MAAM,CACP;CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC;AAEtD,wBAAsB,SAAS,CAAC,EAC9B,SAAS,GACV,EAAE;IACD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EA"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { config } from "../config/index.js";
|
|
2
|
+
import { AgentTool, createAgentTools } from "./agent.js";
|
|
3
|
+
import { ApplyPatchTool, createApplyPatchTool } from "./apply-patch.js";
|
|
1
4
|
import { BashTool, createBashTool } from "./bash.js";
|
|
2
5
|
import { createDirectoryTreeTool, DirectoryTreeTool, } from "./directory-tree.js";
|
|
3
6
|
import { loadDynamicTools } from "./dynamic-tool-loader.js";
|
|
@@ -7,40 +10,48 @@ import { createGrepTool, GrepTool } from "./grep.js";
|
|
|
7
10
|
import { createLsTool, LsTool } from "./ls.js";
|
|
8
11
|
import { createReadFileTool, ReadFileTool } from "./read-file.js";
|
|
9
12
|
import { createSaveFileTool, SaveFileTool } from "./save-file.js";
|
|
13
|
+
import { createSkillTool, SkillTool } from "./skill.js";
|
|
10
14
|
import { createThinkTool, ThinkTool } from "./think.js";
|
|
15
|
+
import { createWebFetchTool, WebFetchTool } from "./web-fetch.js";
|
|
16
|
+
import { createWebSearchTool, WebSearchTool } from "./web-search.js";
|
|
11
17
|
export async function initTools({ workspace, }) {
|
|
12
|
-
const readFileTool = await createReadFileTool({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
const editFileTool = await createEditFileTool({
|
|
17
|
-
workingDir: workspace.primaryDir,
|
|
18
|
-
allowedDirs: workspace.allowedDirs,
|
|
19
|
-
});
|
|
20
|
-
const saveFileTool = await createSaveFileTool({
|
|
21
|
-
workingDir: workspace.primaryDir,
|
|
22
|
-
allowedDirs: workspace.allowedDirs,
|
|
23
|
-
});
|
|
24
|
-
const directoryTreeTool = await createDirectoryTreeTool({
|
|
25
|
-
workingDir: workspace.primaryDir,
|
|
26
|
-
allowedDirs: workspace.allowedDirs,
|
|
27
|
-
});
|
|
18
|
+
const readFileTool = await createReadFileTool({ workspace });
|
|
19
|
+
const editFileTool = await createEditFileTool({ workspace });
|
|
20
|
+
const saveFileTool = await createSaveFileTool({ workspace });
|
|
21
|
+
const directoryTreeTool = await createDirectoryTreeTool({ workspace });
|
|
28
22
|
const globTool = createGlobTool();
|
|
29
23
|
const grepTool = createGrepTool();
|
|
30
24
|
const thinkTool = createThinkTool();
|
|
31
|
-
const lsTool = await createLsTool({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
25
|
+
const lsTool = await createLsTool({ workspace });
|
|
26
|
+
const projectConfig = await config.getConfig();
|
|
27
|
+
const bashTool = await createBashTool({ workspace, env: projectConfig.env });
|
|
28
|
+
const skillTool = await createSkillTool();
|
|
29
|
+
const agentTool = await createAgentTools({ workspace });
|
|
30
|
+
const webSearchTool = await createWebSearchTool();
|
|
31
|
+
const webFetchTool = await createWebFetchTool();
|
|
32
|
+
const applyPatchTool = await createApplyPatchTool({ workspace });
|
|
39
33
|
const dynamicTools = await loadDynamicTools({
|
|
40
34
|
baseDir: workspace.primaryDir,
|
|
35
|
+
existingToolNames: [
|
|
36
|
+
ApplyPatchTool.name,
|
|
37
|
+
EditFileTool.name,
|
|
38
|
+
BashTool.name,
|
|
39
|
+
SaveFileTool.name,
|
|
40
|
+
ReadFileTool.name,
|
|
41
|
+
GlobTool.name,
|
|
42
|
+
GrepTool.name,
|
|
43
|
+
DirectoryTreeTool.name,
|
|
44
|
+
ThinkTool.name,
|
|
45
|
+
LsTool.name,
|
|
46
|
+
SkillTool.name,
|
|
47
|
+
AgentTool.name,
|
|
48
|
+
WebSearchTool.name,
|
|
49
|
+
WebFetchTool.name,
|
|
50
|
+
],
|
|
41
51
|
});
|
|
42
52
|
// Build tools object for AI SDK
|
|
43
53
|
const tools = {
|
|
54
|
+
[ApplyPatchTool.name]: applyPatchTool,
|
|
44
55
|
[EditFileTool.name]: editFileTool,
|
|
45
56
|
[BashTool.name]: bashTool,
|
|
46
57
|
[SaveFileTool.name]: saveFileTool,
|
|
@@ -50,6 +61,10 @@ export async function initTools({ workspace, }) {
|
|
|
50
61
|
[DirectoryTreeTool.name]: directoryTreeTool,
|
|
51
62
|
[ThinkTool.name]: thinkTool,
|
|
52
63
|
[LsTool.name]: lsTool,
|
|
64
|
+
[SkillTool.name]: skillTool,
|
|
65
|
+
[AgentTool.name]: agentTool,
|
|
66
|
+
[WebSearchTool.name]: webSearchTool,
|
|
67
|
+
[WebFetchTool.name]: webFetchTool,
|
|
53
68
|
// Add dynamic tools - they already have toolDef structure
|
|
54
69
|
...Object.fromEntries(Object.entries(dynamicTools).map(([name, toolObj]) => [name, toolObj])),
|
|
55
70
|
};
|
package/dist/tools/ls.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
2
3
|
import type { ToolExecutionOptions } from "./types.ts";
|
|
3
4
|
export declare const LsTool: {
|
|
4
5
|
name: "LS";
|
|
@@ -9,8 +10,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
9
10
|
}, z.core.$strip>;
|
|
10
11
|
type LsInputSchema = z.infer<typeof inputSchema>;
|
|
11
12
|
export declare const createLsTool: (options: {
|
|
12
|
-
|
|
13
|
-
allowedDirs?: string[];
|
|
13
|
+
workspace: WorkspaceContext;
|
|
14
14
|
}) => Promise<{
|
|
15
15
|
toolDef: {
|
|
16
16
|
description: string;
|
package/dist/tools/ls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,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,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;2CAU0C,aAAa;2CAOnB,aAAa,mBAC3B,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6DrB,CAAC"}
|
package/dist/tools/ls.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import style from "../terminal/style.js";
|
|
5
5
|
import { isDirectory } from "../utils/filesystem/operations.js";
|
|
6
|
+
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
6
7
|
import { validatePath } from "../utils/filesystem/security.js";
|
|
7
8
|
import { convertNullString } from "../utils/zod.js";
|
|
8
9
|
export const LsTool = {
|
|
@@ -19,17 +20,18 @@ const inputSchema = z.object({
|
|
|
19
20
|
});
|
|
20
21
|
const DEFAULT_ENTRY_LIMIT = 500;
|
|
21
22
|
export const createLsTool = async (options) => {
|
|
22
|
-
const {
|
|
23
|
-
const allowedDirectory = allowedDirs ?? [
|
|
23
|
+
const { primaryDir, allowedDirs } = options.workspace;
|
|
24
|
+
const allowedDirectory = allowedDirs ?? [primaryDir];
|
|
24
25
|
return {
|
|
25
26
|
toolDef: {
|
|
26
|
-
description:
|
|
27
|
+
description: "List files in a single directory. Fast and simple - use this when you need a quick flat list of files in one directory. For recursive tree views, use DirectoryTree instead.",
|
|
27
28
|
inputSchema,
|
|
28
29
|
},
|
|
29
30
|
display({ path: providedPath, limit }) {
|
|
30
31
|
const dirPath = providedPath ?? ".";
|
|
31
32
|
const effectiveLimit = limit ?? 500;
|
|
32
|
-
|
|
33
|
+
const displayPath = toDisplayPath(dirPath);
|
|
34
|
+
return `${style.cyan(displayPath)} (limit: ${effectiveLimit})`;
|
|
33
35
|
},
|
|
34
36
|
async execute({ path: providedPath, limit }, { abortSignal }) {
|
|
35
37
|
if (abortSignal?.aborted) {
|
|
@@ -37,7 +39,7 @@ export const createLsTool = async (options) => {
|
|
|
37
39
|
}
|
|
38
40
|
const dirPath = providedPath ?? ".";
|
|
39
41
|
const effectiveLimit = limit ?? DEFAULT_ENTRY_LIMIT;
|
|
40
|
-
const resolvedPath = await validatePath(path.resolve(
|
|
42
|
+
const resolvedPath = await validatePath(path.resolve(primaryDir, dirPath), allowedDirectory, { requireExistence: true, abortSignal });
|
|
41
43
|
if (abortSignal?.aborted) {
|
|
42
44
|
throw new Error("Directory listing aborted before validation");
|
|
43
45
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
2
3
|
import type { ToolExecutionOptions } from "./types.ts";
|
|
3
4
|
export declare const ReadFileTool: {
|
|
4
5
|
name: "Read";
|
|
@@ -20,12 +21,10 @@ declare const inputSchema: z.ZodObject<{
|
|
|
20
21
|
}>>>;
|
|
21
22
|
startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
22
23
|
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>>>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
type ReadFileInputSchema = z.infer<typeof inputSchema>;
|
|
26
|
-
export declare const createReadFileTool: (
|
|
27
|
-
|
|
28
|
-
allowedDirs?: string[];
|
|
26
|
+
export declare const createReadFileTool: (options: {
|
|
27
|
+
workspace: WorkspaceContext;
|
|
29
28
|
}) => Promise<{
|
|
30
29
|
toolDef: {
|
|
31
30
|
description: string;
|
|
@@ -46,11 +45,10 @@ export declare const createReadFileTool: ({ workingDir, allowedDirs, }: {
|
|
|
46
45
|
}>>>;
|
|
47
46
|
startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
48
47
|
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>>>;
|
|
50
48
|
}, z.core.$strip>;
|
|
51
49
|
};
|
|
52
50
|
display({ path: providedPath, startLine, lineCount }: ReadFileInputSchema): string;
|
|
53
|
-
execute({ path: providedPath, encoding, startLine, lineCount,
|
|
51
|
+
execute({ path: providedPath, encoding, startLine, lineCount, }: ReadFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
54
52
|
}>;
|
|
55
53
|
export {};
|
|
56
54
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAsBvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;iBAkBf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;0DAOyD,mBAAmB;qEAUpE,mBAAmB,mBACL,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAsBrB,CAAC"}
|
package/dist/tools/read-file.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { createInterface } from "node:readline/promises";
|
|
2
5
|
import { isNumber } from "@travisennis/stdlib/typeguards";
|
|
3
6
|
import { z } from "zod";
|
|
4
7
|
import style from "../terminal/style.js";
|
|
5
|
-
import {
|
|
8
|
+
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
6
9
|
import { convertNullString } from "../utils/zod.js";
|
|
7
10
|
import { fileEncodingSchema } from "./types.js";
|
|
8
|
-
//
|
|
9
|
-
const
|
|
11
|
+
// hardcoded limit in bytes (50KB) - not configurable by the agent
|
|
12
|
+
const BYTE_LIMIT = 50 * 1024;
|
|
13
|
+
// Resolve a path for reading, expanding ~ and handling relative paths
|
|
14
|
+
function resolveReadPath(providedPath, workingDir) {
|
|
15
|
+
// Expand ~ to home directory
|
|
16
|
+
let resolved = providedPath;
|
|
17
|
+
if (resolved.startsWith("~/") || resolved === "~") {
|
|
18
|
+
resolved = path.join(os.homedir(), resolved.slice(1));
|
|
19
|
+
}
|
|
20
|
+
// If not absolute, join with working directory
|
|
21
|
+
if (!path.isAbsolute(resolved)) {
|
|
22
|
+
resolved = path.join(workingDir, resolved);
|
|
23
|
+
}
|
|
24
|
+
return path.normalize(resolved);
|
|
25
|
+
}
|
|
10
26
|
export const ReadFileTool = {
|
|
11
27
|
name: "Read",
|
|
12
28
|
};
|
|
@@ -22,53 +38,82 @@ const inputSchema = z.object({
|
|
|
22
38
|
lineCount: z
|
|
23
39
|
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
24
40
|
.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)"),
|
|
28
41
|
});
|
|
29
|
-
export const createReadFileTool = async (
|
|
30
|
-
const
|
|
42
|
+
export const createReadFileTool = async (options) => {
|
|
43
|
+
const { primaryDir } = options.workspace;
|
|
31
44
|
return {
|
|
32
45
|
toolDef: {
|
|
33
|
-
description:
|
|
46
|
+
description: "Read the contents of a file.",
|
|
34
47
|
inputSchema,
|
|
35
48
|
},
|
|
36
49
|
display({ path: providedPath, startLine, lineCount }) {
|
|
37
|
-
|
|
50
|
+
const displayPath = toDisplayPath(providedPath);
|
|
51
|
+
return `${style.cyan(displayPath)}${startLine ? style.cyan(`:${startLine}`) : ""}${lineCount ? style.cyan(`:${lineCount}`) : ""}`;
|
|
38
52
|
},
|
|
39
|
-
async execute({ path: providedPath, encoding, startLine, lineCount,
|
|
53
|
+
async execute({ path: providedPath, encoding, startLine, lineCount, }, { abortSignal }) {
|
|
40
54
|
if (abortSignal?.aborted) {
|
|
41
55
|
throw new Error("File reading aborted");
|
|
42
56
|
}
|
|
43
|
-
const filePath =
|
|
44
|
-
|
|
45
|
-
|
|
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.`);
|
|
57
|
-
}
|
|
58
|
-
const endIndex = Math.min(startIndex + count, totalLines);
|
|
59
|
-
file = lines.slice(startIndex, endIndex).join("\n");
|
|
60
|
-
}
|
|
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
|
-
}
|
|
70
|
-
}
|
|
57
|
+
const filePath = resolveReadPath(providedPath, primaryDir);
|
|
58
|
+
const effectiveEncoding = encoding ?? "utf-8";
|
|
59
|
+
const file = await readFileContent(filePath, effectiveEncoding, startLine, lineCount, abortSignal);
|
|
60
|
+
validateByteLimit(file, effectiveEncoding, BYTE_LIMIT);
|
|
71
61
|
return file;
|
|
72
62
|
},
|
|
73
63
|
};
|
|
74
64
|
};
|
|
65
|
+
// Read file content either line-by-line or as a whole
|
|
66
|
+
async function readFileContent(filePath, encoding, startLine, lineCount, abortSignal) {
|
|
67
|
+
const useLineBasedRead = isNumber(startLine) || isNumber(lineCount);
|
|
68
|
+
if (useLineBasedRead) {
|
|
69
|
+
return readFileLines(filePath, startLine, lineCount, abortSignal);
|
|
70
|
+
}
|
|
71
|
+
if (abortSignal?.aborted) {
|
|
72
|
+
throw new Error("File reading aborted before file read");
|
|
73
|
+
}
|
|
74
|
+
return fs.readFile(filePath, { encoding });
|
|
75
|
+
}
|
|
76
|
+
// Read specific lines from a file using streaming
|
|
77
|
+
async function readFileLines(filePath, startLine, lineCount, abortSignal) {
|
|
78
|
+
const fileStream = await fs.open(filePath, "r");
|
|
79
|
+
const rl = createInterface({
|
|
80
|
+
input: fileStream.createReadStream(),
|
|
81
|
+
crlfDelay: Number.POSITIVE_INFINITY,
|
|
82
|
+
});
|
|
83
|
+
const lines = [];
|
|
84
|
+
const startIndex = (startLine ?? 1) - 1;
|
|
85
|
+
const count = lineCount ?? Number.POSITIVE_INFINITY;
|
|
86
|
+
let currentIndex = 0;
|
|
87
|
+
for await (const line of rl) {
|
|
88
|
+
if (currentIndex >= startIndex && currentIndex < startIndex + count) {
|
|
89
|
+
lines.push(line);
|
|
90
|
+
}
|
|
91
|
+
currentIndex++;
|
|
92
|
+
if (currentIndex >= startIndex + count) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (abortSignal?.aborted) {
|
|
96
|
+
rl.close();
|
|
97
|
+
await fileStream.close();
|
|
98
|
+
throw new Error("File reading aborted");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
rl.close();
|
|
102
|
+
await fileStream.close();
|
|
103
|
+
if (startIndex >= currentIndex) {
|
|
104
|
+
throw new Error(`startLine ${startLine} is out of bounds for file with ${currentIndex} lines.`);
|
|
105
|
+
}
|
|
106
|
+
return lines.join("\n");
|
|
107
|
+
}
|
|
108
|
+
// Validate that file content doesn't exceed byte limit
|
|
109
|
+
function validateByteLimit(file, encoding, maxBytes) {
|
|
110
|
+
const byteLength = Buffer.byteLength(file, encoding);
|
|
111
|
+
if (byteLength > maxBytes) {
|
|
112
|
+
const fileSizeKb = (byteLength / 1024).toFixed(1);
|
|
113
|
+
const limitKb = (maxBytes / 1024).toFixed(0);
|
|
114
|
+
throw new Error(`File (${fileSizeKb}KB) exceeds the ${limitKb}KB read limit. To read this file, use one of these options:\n` +
|
|
115
|
+
"• Use startLine and lineCount to read specific portions (e.g., startLine: 1, lineCount: 100)\n" +
|
|
116
|
+
"• Use the Grep tool to search for specific content\n" +
|
|
117
|
+
`• Use the Bash tool with 'tail' or 'head' commands`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
2
3
|
import { type ToolExecutionOptions } from "./types.ts";
|
|
3
4
|
export declare const SaveFileTool: {
|
|
4
5
|
name: "Write";
|
|
@@ -21,9 +22,8 @@ declare const inputSchema: z.ZodObject<{
|
|
|
21
22
|
}>>;
|
|
22
23
|
}, z.core.$strip>;
|
|
23
24
|
type SaveFileInputSchema = z.infer<typeof inputSchema>;
|
|
24
|
-
export declare const createSaveFileTool: (
|
|
25
|
-
|
|
26
|
-
allowedDirs?: string[];
|
|
25
|
+
export declare const createSaveFileTool: (options: {
|
|
26
|
+
workspace: WorkspaceContext;
|
|
27
27
|
}) => Promise<{
|
|
28
28
|
toolDef: {
|
|
29
29
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AA8BvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;sBAUqB,mBAAmB;mDAKI,mBAAmB,mBACzC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA8BrB,CAAC"}
|
package/dist/tools/save-file.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { config } from "../config.js";
|
|
4
|
+
import { config } from "../config/index.js";
|
|
5
5
|
import { clearProjectStatusCache } from "../repl/project-status.js";
|
|
6
6
|
import style from "../terminal/style.js";
|
|
7
|
+
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
7
8
|
import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
|
|
8
9
|
import { fileEncodingSchema } from "./types.js";
|
|
9
10
|
export const SaveFileTool = {
|
|
@@ -16,46 +17,50 @@ const inputSchema = z.object({
|
|
|
16
17
|
.describe('Encoding format for saving the file. Use "utf-8" as default for text files')
|
|
17
18
|
.default("utf-8"),
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
async function checkFileNotReadOnly(filePath, projectConfig, primaryDir) {
|
|
21
|
+
try {
|
|
22
|
+
await fs.stat(filePath);
|
|
23
|
+
validateFileNotReadOnly(filePath, projectConfig, primaryDir);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error.code !== "ENOENT") {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function ensurePathIsFile(filePath) {
|
|
32
|
+
try {
|
|
33
|
+
const stat = await fs.stat(filePath);
|
|
34
|
+
if (stat.isDirectory()) {
|
|
35
|
+
throw new Error(`Cannot save file - path is a directory: ${filePath}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.code !== "ENOENT") {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export const createSaveFileTool = async (options) => {
|
|
45
|
+
const { primaryDir, allowedDirs } = options.workspace;
|
|
46
|
+
const allowedDirectory = allowedDirs ?? [primaryDir];
|
|
47
|
+
const projectConfig = await config.getConfig();
|
|
21
48
|
return {
|
|
22
49
|
toolDef: {
|
|
23
|
-
description: "Create
|
|
24
|
-
"Automatically creates all missing parent directories. " +
|
|
25
|
-
"Use with caution as it will overwrite existing files without warning. " +
|
|
26
|
-
"Handles text content with proper encoding. Only works within allowed directories.",
|
|
50
|
+
description: "Create or overwrite a file with new content.",
|
|
27
51
|
inputSchema,
|
|
28
52
|
},
|
|
29
53
|
display({ path }) {
|
|
30
|
-
|
|
54
|
+
const displayPath = toDisplayPath(path);
|
|
55
|
+
return `${style.cyan(displayPath)}`;
|
|
31
56
|
},
|
|
32
57
|
async execute({ path: userPath, content, encoding }, { abortSignal }) {
|
|
33
58
|
if (abortSignal?.aborted) {
|
|
34
59
|
throw new Error("File saving aborted");
|
|
35
60
|
}
|
|
36
|
-
const filePath = await validatePath(joinWorkingDir(userPath,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const projectConfig = await config.getConfig();
|
|
40
|
-
validateFileNotReadOnly(filePath, projectConfig, workingDir);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
if (error.code !== "ENOENT") {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const stat = await fs.stat(filePath);
|
|
49
|
-
if (stat.isDirectory()) {
|
|
50
|
-
throw new Error(`Cannot save file - path is a directory: ${filePath}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
if (error instanceof Error &&
|
|
55
|
-
error.message.includes("is a directory")) {
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
61
|
+
const filePath = await validatePath(joinWorkingDir(userPath, primaryDir), allowedDirectory, { requireExistence: false, abortSignal });
|
|
62
|
+
await checkFileNotReadOnly(filePath, projectConfig, primaryDir);
|
|
63
|
+
await ensurePathIsFile(filePath);
|
|
59
64
|
if (abortSignal?.aborted) {
|
|
60
65
|
throw new Error("File saving aborted before writing");
|
|
61
66
|
}
|