@travisennis/acai 0.0.7 → 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 +42 -25
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +115 -104
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -16
- 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-command.js → add-directory/index.js} +6 -10
- 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/types.js +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} +0 -2
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/{copy-command.js → copy/index.js} +4 -26
- 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-command.d.ts → exit/index.d.ts} +4 -4
- 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} +55 -95
- 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-command.js → handoff/utils.js} +24 -92
- 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-command.d.ts → help/index.d.ts} +2 -2
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +1 -1
- 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} +16 -100
- 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} +16 -7
- 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} +1 -1
- 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-command.js → list-tools/index.js} +4 -16
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +33 -43
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/{model-command.js → model/index.js} +15 -52
- 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-command.d.ts → paste/index.d.ts} +2 -2
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/{paste-command.js → paste/index.js} +6 -111
- 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} +2 -2
- 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} +7 -2
- 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 -3
- 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} +3 -3
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +25 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -20
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +60 -64
- package/dist/formatting.d.ts +27 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -75
- 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/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -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/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 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +95 -80
- package/dist/models/providers.d.ts +4 -4
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +7 -1
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- 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 +0 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +56 -406
- 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 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +245 -42
- package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +60 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +2 -0
- package/dist/terminal/formatting.d.ts +1 -2
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +1 -2
- 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/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +9 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +69 -123
- package/dist/tools/directory-tree.d.ts +9 -7
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +89 -70
- package/dist/tools/dynamic-tool-loader.d.ts +22 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +39 -44
- 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 +19 -76
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +77 -119
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -108
- package/dist/tools/index.d.ts +200 -179
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -315
- 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 +49 -82
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +37 -66
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -38
- package/dist/tools/types.d.ts +5 -25
- 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/box.d.ts.map +1 -1
- package/dist/tui/components/box.js +16 -10
- package/dist/tui/components/editor.d.ts +1 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +148 -107
- package/dist/tui/components/footer.d.ts +20 -7
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +89 -196
- 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 +2 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +7 -2
- package/dist/tui/components/markdown.d.ts +5 -4
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +51 -40
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -8
- 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.map +1 -1
- package/dist/tui/components/progress-bar.js +3 -15
- package/dist/tui/components/select-list.d.ts +0 -15
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +5 -28
- package/dist/tui/components/tool-execution.d.ts +3 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +26 -38
- 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 +4 -2
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/tui/terminal.d.ts +2 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +23 -19
- package/dist/tui/tui.d.ts +1 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +24 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- 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.d.ts +1 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +17 -0
- package/package.json +31 -29
- package/bin/acai-wrapper.js +0 -26
- 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/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 -43
- 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 -55
- 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 -124
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- 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 -42
- 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 -36
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -30
- 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 -68
- 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/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -118
- 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 -71
- 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/model-command.d.ts +0 -3
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/paste-command.d.ts.map +0 -1
- 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 -109
- package/dist/commands/prompt-command.d.ts +0 -21
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -258
- 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 -73
- 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 -31
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/project-status-line.d.ts +0 -3
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -61
- 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/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -120
- package/dist/tokens/threshold.d.ts +0 -20
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -67
- 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 -285
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -117
- package/dist/tools/batch.d.ts +0 -34
- package/dist/tools/batch.d.ts.map +0 -1
- package/dist/tools/batch.js +0 -174
- 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 -183
- 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 -77
- 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/llm-edit-fixer.d.ts +0 -24
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -136
- 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 -65
- 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 -196
- 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 -148
- package/dist/tui/components/prompt-status.d.ts +0 -17
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -26
package/dist/tools/glob.js
CHANGED
|
@@ -1,154 +1,112 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as nodePath from "node:path";
|
|
3
|
-
import { inspect } from "node:util";
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
import style from "../terminal/style.js";
|
|
6
|
-
import { manageTokenLimit, TokenLimitExceededError, } from "../tokens/threshold.js";
|
|
7
5
|
import { glob } from "../utils/glob.js";
|
|
6
|
+
import { convertNullString } from "../utils/zod.js";
|
|
7
|
+
const DEFAULT_MAX_RESULTS = 100;
|
|
8
8
|
export const GlobTool = {
|
|
9
|
-
name: "
|
|
9
|
+
name: "Glob",
|
|
10
10
|
};
|
|
11
11
|
export const inputSchema = z.object({
|
|
12
12
|
patterns: z
|
|
13
13
|
.union([z.string(), z.array(z.string())])
|
|
14
14
|
.describe("Glob patterns to search for (e.g., '*.ts', '**/*.test.ts', 'src/**/*.js')"),
|
|
15
15
|
path: z.string().describe("Base directory to search in"),
|
|
16
|
-
gitignore: z
|
|
17
|
-
.boolean()
|
|
18
|
-
.nullable()
|
|
16
|
+
gitignore: z
|
|
17
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
19
18
|
.describe("Respect ignore patterns in .gitignore files. (default: true)"),
|
|
20
|
-
recursive: z
|
|
21
|
-
.boolean()
|
|
22
|
-
.nullable()
|
|
19
|
+
recursive: z
|
|
20
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
23
21
|
.describe("Search recursively. (default: true)"),
|
|
24
|
-
expandDirectories: z
|
|
25
|
-
.boolean()
|
|
26
|
-
.nullable()
|
|
22
|
+
expandDirectories: z
|
|
23
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
27
24
|
.describe("Automatically expand directories to files. (default: true)"),
|
|
28
25
|
ignoreFiles: z
|
|
29
26
|
.union([z.string(), z.array(z.string())])
|
|
30
27
|
.nullable()
|
|
31
28
|
.describe("Glob patterns to look for ignore files. (default: undefined)"),
|
|
32
|
-
cwd: z
|
|
33
|
-
.string()
|
|
34
|
-
.nullable()
|
|
29
|
+
cwd: z
|
|
30
|
+
.preprocess((val) => convertNullString(val), z.coerce.string().nullable())
|
|
35
31
|
.describe("Current working directory override. (default: process.cwd())"),
|
|
32
|
+
maxResults: z
|
|
33
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
34
|
+
.describe("Maximum number of files to return. Set to 0 for no limit. (Default: 100)"),
|
|
36
35
|
});
|
|
37
|
-
export const createGlobTool = (
|
|
38
|
-
const { tokenCounter } = options;
|
|
36
|
+
export const createGlobTool = () => {
|
|
39
37
|
return {
|
|
40
38
|
toolDef: {
|
|
41
|
-
description:
|
|
39
|
+
description: `Search for files using glob patterns (e.g., [1m*.ts[0m, [1m**/*.test.ts[0m, [1msrc/**/*.js[0m). Uses the fast-glob library with support for .gitignore, recursive searching, directory expansion, and automatic result limiting to prevent overwhelming output. Default limit is ${DEFAULT_MAX_RESULTS} files. Use maxResults parameter to override this limit.`,
|
|
42
40
|
inputSchema,
|
|
43
41
|
},
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
display({ patterns, path }) {
|
|
43
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
44
|
+
const patternStr = patternArray.length === 1
|
|
45
|
+
? patternArray[0]
|
|
46
|
+
: JSON.stringify(patternArray);
|
|
47
|
+
return `\n> ${style.cyan(patternStr)} in ${style.cyan(path)}`;
|
|
48
|
+
},
|
|
49
|
+
async execute({ patterns, path, gitignore, recursive, expandDirectories, ignoreFiles, cwd, maxResults, }, { abortSignal }) {
|
|
46
50
|
if (abortSignal?.aborted) {
|
|
47
51
|
throw new Error("Glob search aborted");
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
globOptions["ignoreFiles"] = ignoreFiles;
|
|
72
|
-
}
|
|
73
|
-
// Execute glob search
|
|
74
|
-
const matchingFiles = await glob(patternArray, {
|
|
75
|
-
...globOptions,
|
|
76
|
-
cwd: path,
|
|
77
|
-
});
|
|
78
|
-
// Get file stats and sort by recency then alphabetically
|
|
79
|
-
const filesWithStats = await Promise.all(matchingFiles.map(async (filePath) => {
|
|
80
|
-
const fullPath = nodePath.join(path, filePath);
|
|
81
|
-
try {
|
|
82
|
-
const stats = await fs.promises.stat(fullPath);
|
|
83
|
-
return {
|
|
84
|
-
path: filePath,
|
|
85
|
-
mtime: stats.mtime,
|
|
86
|
-
isRecent: Date.now() - stats.mtime.getTime() < 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// If stat fails, treat as old file
|
|
91
|
-
return {
|
|
92
|
-
path: filePath,
|
|
93
|
-
mtime: new Date(0),
|
|
94
|
-
isRecent: false,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
// Sort files: recent files first (newest to oldest), then older files alphabetically
|
|
99
|
-
const sortedFiles = filesWithStats
|
|
100
|
-
.sort((a, b) => {
|
|
101
|
-
// Recent files come first
|
|
102
|
-
if (a.isRecent && !b.isRecent)
|
|
103
|
-
return -1;
|
|
104
|
-
if (!a.isRecent && b.isRecent)
|
|
105
|
-
return 1;
|
|
106
|
-
// Both recent: sort by modification time (newest first)
|
|
107
|
-
if (a.isRecent && b.isRecent) {
|
|
108
|
-
return b.mtime.getTime() - a.mtime.getTime();
|
|
109
|
-
}
|
|
110
|
-
// Both old: sort alphabetically by path
|
|
111
|
-
return a.path.localeCompare(b.path);
|
|
112
|
-
})
|
|
113
|
-
.map((file) => file.path);
|
|
114
|
-
// Format results
|
|
115
|
-
const resultContent = sortedFiles.length > 0
|
|
116
|
-
? sortedFiles.join("\n")
|
|
117
|
-
: "No files found matching the specified patterns.";
|
|
53
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
54
|
+
const globOptions = {
|
|
55
|
+
cwd: cwd || process.cwd(),
|
|
56
|
+
};
|
|
57
|
+
if (gitignore !== null) {
|
|
58
|
+
globOptions["gitignore"] = gitignore;
|
|
59
|
+
}
|
|
60
|
+
if (recursive !== null) {
|
|
61
|
+
globOptions["recursive"] = recursive;
|
|
62
|
+
}
|
|
63
|
+
if (expandDirectories !== null) {
|
|
64
|
+
globOptions["expandDirectories"] = expandDirectories;
|
|
65
|
+
}
|
|
66
|
+
if (ignoreFiles !== null) {
|
|
67
|
+
globOptions["ignoreFiles"] = ignoreFiles;
|
|
68
|
+
}
|
|
69
|
+
const matchingFiles = await glob(patternArray, {
|
|
70
|
+
...globOptions,
|
|
71
|
+
cwd: path,
|
|
72
|
+
});
|
|
73
|
+
const filesWithStats = await Promise.all(matchingFiles.map(async (filePath) => {
|
|
74
|
+
const fullPath = nodePath.join(path, filePath);
|
|
118
75
|
try {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
id: toolCallId,
|
|
125
|
-
data: completionMessage,
|
|
76
|
+
const stats = await fs.promises.stat(fullPath);
|
|
77
|
+
return {
|
|
78
|
+
path: filePath,
|
|
79
|
+
mtime: stats.mtime,
|
|
80
|
+
isRecent: Date.now() - stats.mtime.getTime() < 7 * 24 * 60 * 60 * 1000,
|
|
126
81
|
};
|
|
127
|
-
yield result.content;
|
|
128
82
|
}
|
|
129
|
-
catch
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
data: error.message,
|
|
136
|
-
};
|
|
137
|
-
yield error.message;
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
throw error;
|
|
83
|
+
catch {
|
|
84
|
+
return {
|
|
85
|
+
path: filePath,
|
|
86
|
+
mtime: new Date(0),
|
|
87
|
+
isRecent: false,
|
|
88
|
+
};
|
|
141
89
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
90
|
+
}));
|
|
91
|
+
const sortedFiles = filesWithStats
|
|
92
|
+
.sort((a, b) => {
|
|
93
|
+
if (a.isRecent && !b.isRecent)
|
|
94
|
+
return -1;
|
|
95
|
+
if (!a.isRecent && b.isRecent)
|
|
96
|
+
return 1;
|
|
97
|
+
if (a.isRecent && b.isRecent) {
|
|
98
|
+
return b.mtime.getTime() - a.mtime.getTime();
|
|
99
|
+
}
|
|
100
|
+
return a.path.localeCompare(b.path);
|
|
101
|
+
})
|
|
102
|
+
.map((file) => file.path);
|
|
103
|
+
const effectiveMaxResults = maxResults ?? DEFAULT_MAX_RESULTS;
|
|
104
|
+
const limitedFiles = effectiveMaxResults && effectiveMaxResults > 0
|
|
105
|
+
? sortedFiles.slice(0, effectiveMaxResults)
|
|
106
|
+
: sortedFiles;
|
|
107
|
+
return limitedFiles.length > 0
|
|
108
|
+
? limitedFiles.join("\n")
|
|
109
|
+
: "No files found matching the specified patterns.";
|
|
152
110
|
},
|
|
153
111
|
};
|
|
154
112
|
};
|
package/dist/tools/grep.d.ts
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
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 GrepTool: {
|
|
6
|
-
name: "
|
|
4
|
+
name: "Grep";
|
|
7
5
|
};
|
|
8
6
|
declare const inputSchema: z.ZodObject<{
|
|
9
7
|
pattern: z.ZodString;
|
|
10
8
|
path: z.ZodString;
|
|
11
|
-
recursive: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
12
|
-
ignoreCase: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
13
|
-
filePattern: z.ZodNullable<z.ZodCoercedString<unknown
|
|
14
|
-
contextLines: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
15
|
-
searchIgnored: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
16
|
-
literal: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
17
|
-
maxResults: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
9
|
+
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
10
|
+
ignoreCase: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
11
|
+
filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
|
|
12
|
+
contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
13
|
+
searchIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
14
|
+
literal: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
15
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
18
16
|
}, z.core.$strip>;
|
|
19
17
|
type GrepInputSchema = z.infer<typeof inputSchema>;
|
|
20
|
-
export declare const createGrepTool: (
|
|
21
|
-
tokenCounter: TokenCounter;
|
|
22
|
-
}) => {
|
|
18
|
+
export declare const createGrepTool: () => {
|
|
23
19
|
toolDef: {
|
|
24
20
|
description: string;
|
|
25
21
|
inputSchema: z.ZodObject<{
|
|
26
22
|
pattern: z.ZodString;
|
|
27
23
|
path: z.ZodString;
|
|
28
|
-
recursive: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
29
|
-
ignoreCase: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
30
|
-
filePattern: z.ZodNullable<z.ZodCoercedString<unknown
|
|
31
|
-
contextLines: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
32
|
-
searchIgnored: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
33
|
-
literal: z.ZodNullable<z.ZodCoercedBoolean<unknown
|
|
34
|
-
maxResults: z.ZodNullable<z.ZodCoercedNumber<unknown
|
|
24
|
+
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
25
|
+
ignoreCase: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
26
|
+
filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
|
|
27
|
+
contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
28
|
+
searchIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
29
|
+
literal: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
30
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
35
31
|
}, z.core.$strip>;
|
|
36
32
|
};
|
|
37
|
-
|
|
33
|
+
display({ pattern, path, filePattern, recursive, ignoreCase, contextLines, }: GrepInputSchema): string;
|
|
34
|
+
execute({ pattern, path, recursive, ignoreCase, filePattern, contextLines, searchIgnored, literal, maxResults, }: GrepInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
38
35
|
};
|
|
39
36
|
interface GrepOptions {
|
|
40
37
|
recursive?: boolean | null;
|
package/dist/tools/grep.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../source/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../source/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;iBAoCf,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;kFAapB,eAAe;sHAmCb,eAAe,mBACD,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;CA6DrB,CAAC;AAEF,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAQD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAiI9D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CA+DR;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CA4EjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC;IAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CA6BpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAWxD;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CAGR;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,UAAU,CAwDZ"}
|
package/dist/tools/grep.js
CHANGED
|
@@ -1,84 +1,72 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
import { inspect } from "node:util";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { config } from "../config.js";
|
|
5
4
|
import style from "../terminal/style.js";
|
|
6
|
-
import {
|
|
5
|
+
import { convertNullString } from "../utils/zod.js";
|
|
6
|
+
// default limit
|
|
7
|
+
const DEFAULT_MAX_RESULTS = 100;
|
|
7
8
|
export const GrepTool = {
|
|
8
|
-
name: "
|
|
9
|
+
name: "Grep",
|
|
9
10
|
};
|
|
10
11
|
const inputSchema = z.object({
|
|
11
12
|
pattern: z
|
|
12
13
|
.string()
|
|
13
14
|
.describe("The search pattern (regex by default, or fixed-string if literal=true or auto-detected as unbalanced)"),
|
|
14
15
|
path: z.string().describe("The path to search in"),
|
|
15
|
-
recursive: z
|
|
16
|
-
.boolean()
|
|
17
|
-
.nullable()
|
|
16
|
+
recursive: z
|
|
17
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
18
18
|
.describe("Search recursively. (default: true))"),
|
|
19
|
-
ignoreCase: z
|
|
20
|
-
.boolean()
|
|
21
|
-
.nullable()
|
|
19
|
+
ignoreCase: z
|
|
20
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
22
21
|
.describe("Use case-sensitive search. (default: false)"),
|
|
23
|
-
filePattern: z
|
|
24
|
-
.string()
|
|
25
|
-
.nullable()
|
|
22
|
+
filePattern: z
|
|
23
|
+
.preprocess((val) => convertNullString(val), z.coerce.string().nullable())
|
|
26
24
|
.describe("Glob pattern to filter files (e.g., '*.ts', '**/*.test.js'). (Default: no filtering)"),
|
|
27
|
-
contextLines: z
|
|
28
|
-
.number()
|
|
29
|
-
.nullable()
|
|
25
|
+
contextLines: z
|
|
26
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
30
27
|
.describe("The number of context lines needed in search results. (Default: 0)"),
|
|
31
|
-
searchIgnored: z
|
|
32
|
-
.boolean()
|
|
33
|
-
.nullable()
|
|
28
|
+
searchIgnored: z
|
|
29
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
34
30
|
.describe("Search ignored files. (Default: false)"),
|
|
35
|
-
literal: z
|
|
36
|
-
.boolean()
|
|
37
|
-
.nullable()
|
|
31
|
+
literal: z
|
|
32
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
38
33
|
.describe("Pass true for fixed-string search (-F), false for regex, (Default: auto-detects unbalanced patterns like mismatched parentheses/brackets.)"),
|
|
39
|
-
maxResults: z
|
|
40
|
-
.number()
|
|
41
|
-
.
|
|
42
|
-
.describe("Maximum number of matches to return. Set to 0 for no limit. (Default: configured value)"),
|
|
34
|
+
maxResults: z
|
|
35
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
36
|
+
.describe("Maximum number of matches to return. Set to 0 for no limit. (Default: 100)"),
|
|
43
37
|
});
|
|
44
|
-
export const createGrepTool = (
|
|
45
|
-
const { tokenCounter } = options;
|
|
38
|
+
export const createGrepTool = () => {
|
|
46
39
|
return {
|
|
47
40
|
toolDef: {
|
|
48
|
-
description: `Search files for patterns using ripgrep (rg). Uses glob patterns for file filtering (e.g., "*.ts", "**/*.test.ts"). Auto-detects unbalanced regex patterns and falls back to fixed-string search for safety. Results are limited to prevent overwhelming output
|
|
41
|
+
description: `Search files for patterns using ripgrep (rg). Uses glob patterns for file filtering (e.g., "*.ts", "**/*.test.ts"). Auto-detects unbalanced regex patterns and falls back to fixed-string search for safety. Results are automatically limited to prevent overwhelming output using a hybrid approach: ripgrep's --max-count flag limits matches per file for efficiency, and post-processing ensures reasonable result counts. Default limit is ${DEFAULT_MAX_RESULTS} matches. Use maxResults parameter to override this limit.`,
|
|
49
42
|
inputSchema,
|
|
50
43
|
},
|
|
51
|
-
|
|
52
|
-
//
|
|
44
|
+
display({ pattern, path, filePattern, recursive, ignoreCase, contextLines, }) {
|
|
45
|
+
// grok doesn't follow my instructions
|
|
46
|
+
const safeFilePattern = filePattern === "null" || filePattern === "undefined"
|
|
47
|
+
? null
|
|
48
|
+
: filePattern;
|
|
49
|
+
// Enhanced tool-init with detailed search parameters
|
|
50
|
+
let initMessage = `${style.cyan(inspect(pattern))} in ${style.cyan(path)}`;
|
|
51
|
+
if (safeFilePattern) {
|
|
52
|
+
initMessage += ` ${style.dim(`(filter: ${safeFilePattern})`)}`;
|
|
53
|
+
}
|
|
54
|
+
if (recursive === false) {
|
|
55
|
+
initMessage += ` ${style.dim("(non-recursive)")}`;
|
|
56
|
+
}
|
|
57
|
+
if (ignoreCase) {
|
|
58
|
+
initMessage += ` ${style.dim("(case-insensitive)")}`;
|
|
59
|
+
}
|
|
60
|
+
if (contextLines && contextLines > 0) {
|
|
61
|
+
initMessage += ` ${style.dim(`(with ${contextLines} context line${contextLines === 1 ? "" : "s"})`)}`;
|
|
62
|
+
}
|
|
63
|
+
return initMessage;
|
|
64
|
+
},
|
|
65
|
+
async execute({ pattern, path, recursive, ignoreCase, filePattern, contextLines, searchIgnored, literal, maxResults, }, { abortSignal }) {
|
|
53
66
|
if (abortSignal?.aborted) {
|
|
54
67
|
throw new Error("Grep search aborted");
|
|
55
68
|
}
|
|
56
69
|
try {
|
|
57
|
-
// grok doesn't follow my instructions
|
|
58
|
-
const safeFilePattern = filePattern === "null" || filePattern === "undefined"
|
|
59
|
-
? null
|
|
60
|
-
: filePattern;
|
|
61
|
-
// Enhanced tool-init with detailed search parameters
|
|
62
|
-
let initMessage = `${style.cyan(inspect(pattern))} in ${style.cyan(path)}`;
|
|
63
|
-
if (safeFilePattern) {
|
|
64
|
-
initMessage += ` ${style.dim(`(filter: ${safeFilePattern})`)}`;
|
|
65
|
-
}
|
|
66
|
-
if (recursive === false) {
|
|
67
|
-
initMessage += ` ${style.dim("(non-recursive)")}`;
|
|
68
|
-
}
|
|
69
|
-
if (ignoreCase) {
|
|
70
|
-
initMessage += ` ${style.dim("(case-insensitive)")}`;
|
|
71
|
-
}
|
|
72
|
-
if (contextLines && contextLines > 0) {
|
|
73
|
-
initMessage += ` ${style.dim(`(with ${contextLines} context line${contextLines === 1 ? "" : "s"})`)}`;
|
|
74
|
-
}
|
|
75
|
-
yield {
|
|
76
|
-
name: GrepTool.name,
|
|
77
|
-
event: "tool-init",
|
|
78
|
-
id: toolCallId,
|
|
79
|
-
data: initMessage,
|
|
80
|
-
};
|
|
81
|
-
// Normalize literal option: if null => auto-detect using heuristic
|
|
82
70
|
let effectiveLiteral = null;
|
|
83
71
|
if (literal === true) {
|
|
84
72
|
effectiveLiteral = true;
|
|
@@ -87,7 +75,6 @@ export const createGrepTool = (options) => {
|
|
|
87
75
|
effectiveLiteral = false;
|
|
88
76
|
}
|
|
89
77
|
else {
|
|
90
|
-
// auto-detect
|
|
91
78
|
try {
|
|
92
79
|
if (likelyUnbalancedRegex(pattern)) {
|
|
93
80
|
effectiveLiteral = true;
|
|
@@ -100,9 +87,10 @@ export const createGrepTool = (options) => {
|
|
|
100
87
|
effectiveLiteral = false;
|
|
101
88
|
}
|
|
102
89
|
}
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
90
|
+
const effectiveMaxResults = maxResults ?? DEFAULT_MAX_RESULTS;
|
|
91
|
+
const safeFilePattern = filePattern === "null" || filePattern === "undefined"
|
|
92
|
+
? null
|
|
93
|
+
: filePattern;
|
|
106
94
|
const grepResult = grepFilesStructured(pattern, path, {
|
|
107
95
|
recursive,
|
|
108
96
|
ignoreCase,
|
|
@@ -112,51 +100,11 @@ export const createGrepTool = (options) => {
|
|
|
112
100
|
literal: effectiveLiteral,
|
|
113
101
|
maxResults: effectiveMaxResults,
|
|
114
102
|
});
|
|
115
|
-
|
|
116
|
-
const result = await manageTokenLimit(grepResult.rawOutput, tokenCounter, "Grep", "Use maxResults parameter, more specific patterns, or contextLines=0 to reduce output");
|
|
117
|
-
const matchCount = grepResult.matchCount;
|
|
118
|
-
// Build completion message with preview information
|
|
119
|
-
let completionMessage = `Found ${style.cyan(matchCount)} match${matchCount === 1 ? "" : "es"}`;
|
|
120
|
-
if (matchCount === 0) {
|
|
121
|
-
completionMessage = "Search completed - no matches found";
|
|
122
|
-
}
|
|
123
|
-
// Calculate unique files with matches
|
|
124
|
-
const filesWithMatches = new Set(grepResult.parsedMatches
|
|
125
|
-
.filter((match) => match.isMatch && !match.isContext && match.file)
|
|
126
|
-
.map((match) => match.file)).size;
|
|
127
|
-
if (filesWithMatches > 0) {
|
|
128
|
-
completionMessage += ` across ${style.cyan(filesWithMatches)} file${filesWithMatches === 1 ? "" : "s"}`;
|
|
129
|
-
}
|
|
130
|
-
if (grepResult.contextCount > 0) {
|
|
131
|
-
completionMessage += ` with ${style.cyan(grepResult.contextCount)} context line${grepResult.contextCount === 1 ? "" : "s"}`;
|
|
132
|
-
}
|
|
133
|
-
completionMessage += ` (${result.tokenCount} tokens)`;
|
|
134
|
-
yield {
|
|
135
|
-
name: GrepTool.name,
|
|
136
|
-
event: "tool-completion",
|
|
137
|
-
id: toolCallId,
|
|
138
|
-
data: completionMessage,
|
|
139
|
-
};
|
|
140
|
-
yield result.content;
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (error instanceof TokenLimitExceededError) {
|
|
144
|
-
yield {
|
|
145
|
-
name: GrepTool.name,
|
|
146
|
-
event: "tool-error",
|
|
147
|
-
id: toolCallId,
|
|
148
|
-
data: error.message,
|
|
149
|
-
};
|
|
150
|
-
yield error.message;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
throw error;
|
|
154
|
-
}
|
|
103
|
+
return grepResult.rawOutput;
|
|
155
104
|
}
|
|
156
105
|
catch (error) {
|
|
157
106
|
const errorMessage = error.message;
|
|
158
107
|
let userFriendlyError = `Error searching for "${pattern}" in ${path}: ${errorMessage}`;
|
|
159
|
-
// Provide more helpful error messages for common cases
|
|
160
108
|
if (errorMessage.includes("No such file or directory")) {
|
|
161
109
|
userFriendlyError = `Path not found: "${path}"`;
|
|
162
110
|
if (filePattern) {
|
|
@@ -170,13 +118,7 @@ export const createGrepTool = (options) => {
|
|
|
170
118
|
else if (errorMessage.includes("Regex parse error")) {
|
|
171
119
|
userFriendlyError = `Invalid search pattern "${pattern}" - try using literal=true for fixed-string search`;
|
|
172
120
|
}
|
|
173
|
-
|
|
174
|
-
name: GrepTool.name,
|
|
175
|
-
event: "tool-error",
|
|
176
|
-
id: toolCallId,
|
|
177
|
-
data: userFriendlyError,
|
|
178
|
-
};
|
|
179
|
-
yield errorMessage;
|
|
121
|
+
throw new Error(userFriendlyError);
|
|
180
122
|
}
|
|
181
123
|
},
|
|
182
124
|
};
|
|
@@ -347,6 +289,15 @@ export function buildGrepCommand(pattern, path, options = {}) {
|
|
|
347
289
|
if (effectiveLiteral) {
|
|
348
290
|
command += " -F";
|
|
349
291
|
}
|
|
292
|
+
// Use ripgrep's --max-count flag to limit matches per file for efficiency
|
|
293
|
+
// This helps prevent any single file from dominating results
|
|
294
|
+
if (options.maxResults !== null &&
|
|
295
|
+
options.maxResults !== undefined &&
|
|
296
|
+
options.maxResults > 0) {
|
|
297
|
+
// Use a reasonable per-file limit (max 100 per file) to balance efficiency and completeness
|
|
298
|
+
const perFileLimit = Math.min(options.maxResults, 100);
|
|
299
|
+
command += ` --max-count=${perFileLimit}`;
|
|
300
|
+
}
|
|
350
301
|
command += ` ${JSON.stringify(pattern)}`;
|
|
351
302
|
command += ` ${JSON.stringify(path)}`;
|
|
352
303
|
return command;
|
|
@@ -490,7 +441,9 @@ export function grepFilesStructured(pattern, path, options = {}) {
|
|
|
490
441
|
});
|
|
491
442
|
const parsedMatches = parseRipgrepOutput(rawOutput);
|
|
492
443
|
const matchCount = countActualMatches(parsedMatches);
|
|
493
|
-
|
|
444
|
+
// Use the maxResults from options (which will be set by the execute function)
|
|
445
|
+
const maxResults = options.maxResults;
|
|
446
|
+
const { truncated, isTruncated } = truncateMatches(parsedMatches, maxResults);
|
|
494
447
|
const displayedCount = countActualMatches(truncated);
|
|
495
448
|
const displayedContextCount = countContextLines(truncated);
|
|
496
449
|
return {
|