@travisennis/acai 0.0.8 → 0.0.10
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 +48 -729
- 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 +378 -168
- 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 -76
- package/dist/cli/stdin.d.ts +9 -0
- package/dist/cli/stdin.d.ts.map +1 -0
- package/dist/cli/stdin.js +37 -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 -100
- package/dist/commands/generate-rules/service.d.ts +21 -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.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.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 +57 -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 +9 -0
- 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 +134 -112
- package/dist/commands/session/types.d.ts +7 -0
- package/dist/commands/session/types.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.d.ts +25 -0
- package/dist/commands/share/html-renderer.d.ts.map +1 -0
- package/dist/commands/share/html-renderer.js +384 -0
- package/dist/commands/share/index.d.ts +3 -0
- package/dist/commands/share/index.d.ts.map +1 -0
- package/dist/commands/share/index.js +122 -0
- 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 +170 -127
- 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 +5 -5
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +27 -40
- package/dist/models/opencode-zen-provider.d.ts +8 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +68 -11
- package/dist/models/openrouter-provider.d.ts +24 -30
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +92 -177
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- 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 +23 -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 +143 -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} +21 -80
- package/dist/prompts/system-prompt.d.ts +26 -0
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/{prompts.js → prompts/system-prompt.js} +50 -22
- 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} +399 -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 +93 -1
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +264 -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.d.ts → skills/index.d.ts} +14 -2
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +294 -0
- package/dist/subagents/index.d.ts +15 -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 +30 -9
- 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.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 +172 -103
- 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/bash.d.ts +4 -3
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +343 -121
- package/dist/tools/code-search.d.ts +41 -0
- package/dist/tools/code-search.d.ts.map +1 -0
- package/dist/tools/code-search.js +195 -0
- 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 +2 -5
- 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 +164 -66
- package/dist/tools/glob.d.ts +6 -6
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +95 -55
- package/dist/tools/grep.d.ts +15 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +300 -192
- package/dist/tools/index.d.ts +143 -5
- 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 +3 -3
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +74 -34
- 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 +11 -11
- 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 +62 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +429 -0
- package/dist/tools/web-search.d.ts +62 -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 +36 -16
- 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.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 +21 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +228 -236
- 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 +8 -5
- 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 +37 -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.js +2 -2
- package/dist/tui/editor-launcher.d.ts +13 -0
- package/dist/tui/editor-launcher.d.ts.map +1 -0
- package/dist/tui/editor-launcher.js +39 -0
- package/dist/tui/index.d.ts +3 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +1 -0
- package/dist/tui/terminal.d.ts +27 -0
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +144 -15
- package/dist/tui/tui.d.ts +43 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +172 -41
- 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 +32 -31
- 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 +34 -25
- package/dist/cli.d.ts +0 -23
- package/dist/cli.d.ts.map +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 -126
- 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/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 +0 -10
- package/dist/prompts.d.ts.map +0 -1
- package/dist/repl-new.d.ts +0 -62
- package/dist/repl-new.d.ts.map +0 -1
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js +0 -233
- 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/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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
3
|
+
export declare const CodeSearchTool: {
|
|
4
|
+
name: "CodeSearch";
|
|
5
|
+
};
|
|
6
|
+
declare const inputSchema: z.ZodObject<{
|
|
7
|
+
query: z.ZodString;
|
|
8
|
+
path: z.ZodDefault<z.ZodString>;
|
|
9
|
+
regexPattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
10
|
+
filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
11
|
+
excludePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
12
|
+
excludeDir: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
13
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
14
|
+
contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
15
|
+
filesOnly: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
16
|
+
showContent: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
17
|
+
codeOnly: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type CodeSearchInputSchema = z.infer<typeof inputSchema>;
|
|
20
|
+
export declare const createCodeSearchTool: () => {
|
|
21
|
+
toolDef: {
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: z.ZodObject<{
|
|
24
|
+
query: z.ZodString;
|
|
25
|
+
path: z.ZodDefault<z.ZodString>;
|
|
26
|
+
regexPattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
27
|
+
filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
28
|
+
excludePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
29
|
+
excludeDir: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
|
|
30
|
+
maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
31
|
+
contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
32
|
+
filesOnly: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
33
|
+
showContent: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
34
|
+
codeOnly: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
};
|
|
37
|
+
display({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }: CodeSearchInputSchema): string;
|
|
38
|
+
execute({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }: CodeSearchInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=code-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-search.d.ts","sourceRoot":"","sources":["../../source/tools/code-search.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;iBA8Bf,CAAC;AAEH,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AA4GzD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;iJAkB1B,qBAAqB;iJAsDnB,qBAAqB,mBACP,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;CAgCrB,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { inspect } from "node:util";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import style from "../terminal/style.js";
|
|
5
|
+
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
6
|
+
import { convertNullString } from "../utils/zod.js";
|
|
7
|
+
// default limit
|
|
8
|
+
const DEFAULT_MAX_RESULTS = 15;
|
|
9
|
+
const DEFAULT_CONTEXT_LINES = 6;
|
|
10
|
+
export const CodeSearchTool = {
|
|
11
|
+
name: "CodeSearch",
|
|
12
|
+
};
|
|
13
|
+
const inputSchema = z.object({
|
|
14
|
+
query: z.string().describe("Natural language query for semantic search"),
|
|
15
|
+
path: z.string().describe("Path to search in").default("."),
|
|
16
|
+
regexPattern: z
|
|
17
|
+
.preprocess((val) => convertNullString(val), z.string().nullable())
|
|
18
|
+
.describe("Regex pre-filter (-e flag)"),
|
|
19
|
+
filePattern: z
|
|
20
|
+
.preprocess((val) => convertNullString(val), z.string().nullable())
|
|
21
|
+
.describe("File filter (--include flag)"),
|
|
22
|
+
excludePattern: z
|
|
23
|
+
.preprocess((val) => convertNullString(val), z.string().nullable())
|
|
24
|
+
.describe("Exclude pattern (--exclude flag)"),
|
|
25
|
+
excludeDir: z
|
|
26
|
+
.preprocess((val) => convertNullString(val), z.string().nullable())
|
|
27
|
+
.describe("Exclude directories (--exclude-dir flag)"),
|
|
28
|
+
maxResults: z
|
|
29
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
30
|
+
.describe("Number of results (-k flag)"),
|
|
31
|
+
contextLines: z
|
|
32
|
+
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
33
|
+
.describe("Context lines (-n flag)"),
|
|
34
|
+
filesOnly: z
|
|
35
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
36
|
+
.describe("List only files (-l flag)"),
|
|
37
|
+
showContent: z
|
|
38
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
39
|
+
.describe("Show full content (-c flag)"),
|
|
40
|
+
codeOnly: z
|
|
41
|
+
.preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
|
|
42
|
+
.describe("Skip config/text files (--code-only flag)"),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Converts string "null"/"undefined" back to actual null.
|
|
46
|
+
* Zod preprocess converts null to "null" string, this reverses that.
|
|
47
|
+
*/
|
|
48
|
+
function normalizeNullableString(value) {
|
|
49
|
+
if (value === "null" || value === "undefined") {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Builds colgrep command arguments from search options
|
|
56
|
+
*/
|
|
57
|
+
function buildColgrepArgs(options) {
|
|
58
|
+
const effectivePath = options.path !== "." ? options.path : ".";
|
|
59
|
+
const effectiveMaxResults = options.maxResults ?? DEFAULT_MAX_RESULTS;
|
|
60
|
+
const effectiveContextLines = options.contextLines ?? DEFAULT_CONTEXT_LINES;
|
|
61
|
+
const safeRegexPattern = normalizeNullableString(options.regexPattern);
|
|
62
|
+
const safeFilePattern = normalizeNullableString(options.filePattern);
|
|
63
|
+
const safeExcludePattern = normalizeNullableString(options.excludePattern);
|
|
64
|
+
const safeExcludeDir = normalizeNullableString(options.excludeDir);
|
|
65
|
+
const quotedQuery = JSON.stringify(options.query);
|
|
66
|
+
const args = [quotedQuery];
|
|
67
|
+
if (effectivePath !== ".") {
|
|
68
|
+
args.push(effectivePath);
|
|
69
|
+
}
|
|
70
|
+
if (safeRegexPattern) {
|
|
71
|
+
args.push("-e", safeRegexPattern);
|
|
72
|
+
}
|
|
73
|
+
if (safeFilePattern) {
|
|
74
|
+
args.push("--include", safeFilePattern);
|
|
75
|
+
}
|
|
76
|
+
if (safeExcludePattern) {
|
|
77
|
+
args.push("--exclude", safeExcludePattern);
|
|
78
|
+
}
|
|
79
|
+
if (safeExcludeDir) {
|
|
80
|
+
args.push("--exclude-dir", safeExcludeDir);
|
|
81
|
+
}
|
|
82
|
+
if (effectiveMaxResults !== DEFAULT_MAX_RESULTS) {
|
|
83
|
+
args.push("-k", String(effectiveMaxResults));
|
|
84
|
+
}
|
|
85
|
+
if (effectiveContextLines !== DEFAULT_CONTEXT_LINES) {
|
|
86
|
+
args.push("-n", String(effectiveContextLines));
|
|
87
|
+
}
|
|
88
|
+
if (options.filesOnly) {
|
|
89
|
+
args.push("-l");
|
|
90
|
+
}
|
|
91
|
+
if (options.showContent) {
|
|
92
|
+
args.push("-c");
|
|
93
|
+
}
|
|
94
|
+
if (options.codeOnly) {
|
|
95
|
+
args.push("--code-only");
|
|
96
|
+
}
|
|
97
|
+
return args;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Converts execSync error to user-friendly message
|
|
101
|
+
*/
|
|
102
|
+
function handleColgrepError(error, query, path) {
|
|
103
|
+
const errorMessage = error.message;
|
|
104
|
+
// Check if colgrep is not installed
|
|
105
|
+
if (errorMessage.includes("ENOENT") || errorMessage.includes("not found")) {
|
|
106
|
+
throw new Error("colgrep is not installed. Please install it from https://github.com/lightonai/next-plaid");
|
|
107
|
+
}
|
|
108
|
+
let userFriendlyError = `Error searching "${query}" in ${path}: ${errorMessage}`;
|
|
109
|
+
if (errorMessage.includes("No such file or directory")) {
|
|
110
|
+
userFriendlyError = `Path not found: "${path}" - check if the path exists and is accessible`;
|
|
111
|
+
}
|
|
112
|
+
else if (errorMessage.includes("permission denied")) {
|
|
113
|
+
userFriendlyError = `Permission denied accessing "${path}"`;
|
|
114
|
+
}
|
|
115
|
+
else if (errorMessage.includes("timed out")) {
|
|
116
|
+
userFriendlyError =
|
|
117
|
+
"Search timed out after 30 seconds - try reducing maxResults";
|
|
118
|
+
}
|
|
119
|
+
throw new Error(userFriendlyError);
|
|
120
|
+
}
|
|
121
|
+
export const createCodeSearchTool = () => {
|
|
122
|
+
return {
|
|
123
|
+
toolDef: {
|
|
124
|
+
description: "Semantic code search using natural language.",
|
|
125
|
+
inputSchema,
|
|
126
|
+
},
|
|
127
|
+
display({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }) {
|
|
128
|
+
const safeRegexPattern = normalizeNullableString(regexPattern);
|
|
129
|
+
const safeFilePattern = normalizeNullableString(filePattern);
|
|
130
|
+
const safeExcludePattern = normalizeNullableString(excludePattern);
|
|
131
|
+
const safeExcludeDir = normalizeNullableString(excludeDir);
|
|
132
|
+
const displayPath = toDisplayPath(path);
|
|
133
|
+
const effectiveMaxResults = maxResults ?? DEFAULT_MAX_RESULTS;
|
|
134
|
+
const effectiveContextLines = contextLines ?? DEFAULT_CONTEXT_LINES;
|
|
135
|
+
let initMessage = `${style.cyan(inspect(query))} in ${style.cyan(displayPath)}`;
|
|
136
|
+
if (safeRegexPattern) {
|
|
137
|
+
initMessage += ` ${style.dim(`(regex: ${safeRegexPattern})`)}`;
|
|
138
|
+
}
|
|
139
|
+
if (safeFilePattern) {
|
|
140
|
+
initMessage += ` ${style.dim(`(include: ${safeFilePattern})`)}`;
|
|
141
|
+
}
|
|
142
|
+
if (safeExcludePattern) {
|
|
143
|
+
initMessage += ` ${style.dim(`(exclude: ${safeExcludePattern})`)}`;
|
|
144
|
+
}
|
|
145
|
+
if (safeExcludeDir) {
|
|
146
|
+
initMessage += ` ${style.dim(`(exclude-dir: ${safeExcludeDir})`)}`;
|
|
147
|
+
}
|
|
148
|
+
if (effectiveMaxResults !== DEFAULT_MAX_RESULTS) {
|
|
149
|
+
initMessage += ` ${style.dim(`(max: ${effectiveMaxResults})`)}`;
|
|
150
|
+
}
|
|
151
|
+
if (effectiveContextLines !== DEFAULT_CONTEXT_LINES) {
|
|
152
|
+
initMessage += ` ${style.dim(`(context: ${effectiveContextLines})`)}`;
|
|
153
|
+
}
|
|
154
|
+
if (filesOnly) {
|
|
155
|
+
initMessage += ` ${style.dim("(files only)")}`;
|
|
156
|
+
}
|
|
157
|
+
if (showContent) {
|
|
158
|
+
initMessage += ` ${style.dim("(show content)")}`;
|
|
159
|
+
}
|
|
160
|
+
if (codeOnly) {
|
|
161
|
+
initMessage += ` ${style.dim("(code only)")}`;
|
|
162
|
+
}
|
|
163
|
+
return initMessage;
|
|
164
|
+
},
|
|
165
|
+
async execute({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }, { abortSignal }) {
|
|
166
|
+
if (abortSignal?.aborted) {
|
|
167
|
+
throw new Error("CodeSearch aborted");
|
|
168
|
+
}
|
|
169
|
+
const args = buildColgrepArgs({
|
|
170
|
+
query,
|
|
171
|
+
path,
|
|
172
|
+
regexPattern: normalizeNullableString(regexPattern),
|
|
173
|
+
filePattern: normalizeNullableString(filePattern),
|
|
174
|
+
excludePattern: normalizeNullableString(excludePattern),
|
|
175
|
+
excludeDir: normalizeNullableString(excludeDir),
|
|
176
|
+
maxResults,
|
|
177
|
+
contextLines,
|
|
178
|
+
filesOnly,
|
|
179
|
+
showContent,
|
|
180
|
+
codeOnly,
|
|
181
|
+
});
|
|
182
|
+
try {
|
|
183
|
+
const colgrepResult = execSync(["colgrep", ...args].join(" "), {
|
|
184
|
+
encoding: "utf-8",
|
|
185
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
186
|
+
timeout: 30000,
|
|
187
|
+
});
|
|
188
|
+
return colgrepResult;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
handleColgrepError(error, query, path);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
};
|
|
@@ -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 DirectoryTreeTool: {
|
|
4
5
|
name: "DirectoryTree";
|
|
@@ -9,9 +10,8 @@ declare const inputSchema: z.ZodObject<{
|
|
|
9
10
|
maxDepth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
10
11
|
}, z.core.$strip>;
|
|
11
12
|
type DirectoryTreeInputSchema = z.infer<typeof inputSchema>;
|
|
12
|
-
export declare const createDirectoryTreeTool: (
|
|
13
|
-
|
|
14
|
-
allowedDirs?: string[];
|
|
13
|
+
export declare const createDirectoryTreeTool: (options: {
|
|
14
|
+
workspace: WorkspaceContext;
|
|
15
15
|
}) => Promise<{
|
|
16
16
|
toolDef: {
|
|
17
17
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;iBAYf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,SAAS;IACrD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;4CAQ2C,wBAAwB;4CAY9B,wBAAwB,mBACvC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAyBrB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import style from "../terminal/style.js";
|
|
5
|
+
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
5
6
|
import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
|
|
6
7
|
import ignore from "../utils/ignore.js";
|
|
7
8
|
import { convertNullString } from "../utils/zod.js";
|
|
@@ -19,15 +20,17 @@ const inputSchema = z.object({
|
|
|
19
20
|
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
20
21
|
.describe(`Maximum recursion depth. Set to 0 for no limit. (default: ${DEFAULT_DEPTH_LIMIT})`),
|
|
21
22
|
});
|
|
22
|
-
export const createDirectoryTreeTool = async (
|
|
23
|
-
const
|
|
23
|
+
export const createDirectoryTreeTool = async (options) => {
|
|
24
|
+
const { primaryDir, allowedDirs } = options.workspace;
|
|
25
|
+
const allowedDirectory = allowedDirs ?? [primaryDir];
|
|
24
26
|
return {
|
|
25
27
|
toolDef: {
|
|
26
|
-
description:
|
|
28
|
+
description: "Show directory structure as a tree.",
|
|
27
29
|
inputSchema,
|
|
28
30
|
},
|
|
29
31
|
display({ path, maxDepth, maxResults }) {
|
|
30
|
-
|
|
32
|
+
const displayPath = toDisplayPath(path);
|
|
33
|
+
let display = `${style.cyan(displayPath)}`;
|
|
31
34
|
if (maxDepth || maxResults) {
|
|
32
35
|
const parts = [];
|
|
33
36
|
if (maxDepth)
|
|
@@ -42,7 +45,7 @@ export const createDirectoryTreeTool = async ({ workingDir, allowedDirs, }) => {
|
|
|
42
45
|
if (abortSignal?.aborted) {
|
|
43
46
|
throw new Error("Directory tree listing aborted");
|
|
44
47
|
}
|
|
45
|
-
const validPath = await validatePath(joinWorkingDir(path,
|
|
48
|
+
const validPath = await validatePath(joinWorkingDir(path, primaryDir), allowedDirectory, { abortSignal });
|
|
46
49
|
if (abortSignal?.aborted) {
|
|
47
50
|
throw new Error("Directory tree listing aborted before tree generation");
|
|
48
51
|
}
|
|
@@ -24,13 +24,10 @@ interface DynamicToolObject {
|
|
|
24
24
|
inputSchema: any;
|
|
25
25
|
};
|
|
26
26
|
execute: (input: Record<string, unknown>, options: ToolExecutionOptions) => Promise<string>;
|
|
27
|
-
ask?: (input: Record<string, unknown>, options: ToolExecutionOptions) => Promise<{
|
|
28
|
-
approve: boolean;
|
|
29
|
-
reason?: string;
|
|
30
|
-
}>;
|
|
31
27
|
}
|
|
32
|
-
export declare function loadDynamicTools({ baseDir }: {
|
|
28
|
+
export declare function loadDynamicTools({ baseDir, existingToolNames, }: {
|
|
33
29
|
baseDir: string;
|
|
30
|
+
existingToolNames?: string[];
|
|
34
31
|
}): Promise<Record<string, DynamicToolObject>>;
|
|
35
32
|
export {};
|
|
36
33
|
//# sourceMappingURL=dynamic-tool-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-tool-loader.d.ts","sourceRoot":"","sources":["../../source/tools/dynamic-tool-loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;iBAatB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS9D;AA2LD,UAAU,iBAAiB;IACzB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QAEpB,WAAW,EAAE,GAAG,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,CACP,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"dynamic-tool-loader.d.ts","sourceRoot":"","sources":["../../source/tools/dynamic-tool-loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;iBAatB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS9D;AA2LD,UAAU,iBAAiB;IACzB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QAEpB,WAAW,EAAE,GAAG,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,CACP,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAwCD,wBAAsB,gBAAgB,CAAC,EACrC,OAAO,EACP,iBAAsB,GACvB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,8CA2FA"}
|
|
@@ -3,8 +3,8 @@ import fs from "node:fs";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { config } from "../config.js";
|
|
7
|
-
import { logger } from "../logger.js";
|
|
6
|
+
import { config } from "../config/index.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
8
|
// Tool Metadata Schema and Parser
|
|
9
9
|
const toolMetadataSchema = z.object({
|
|
10
10
|
name: z.string().regex(/^[a-zA-Z_][a-zA-Z0-9_-]*$/),
|
|
@@ -183,7 +183,7 @@ async function spawnChildProcess(scriptPath, params, abortSignal) {
|
|
|
183
183
|
}
|
|
184
184
|
function createDynamicTool(scriptPath, metadata) {
|
|
185
185
|
const inputSchema = generateZodSchema(metadata.parameters);
|
|
186
|
-
const toolName =
|
|
186
|
+
const toolName = metadata.name;
|
|
187
187
|
return {
|
|
188
188
|
[toolName]: {
|
|
189
189
|
toolDef: {
|
|
@@ -208,7 +208,7 @@ function createDynamicTool(scriptPath, metadata) {
|
|
|
208
208
|
},
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
export async function loadDynamicTools({ baseDir }) {
|
|
211
|
+
export async function loadDynamicTools({ baseDir, existingToolNames = [], }) {
|
|
212
212
|
const projectConfig = await config.getConfig();
|
|
213
213
|
const dynamicConfig = projectConfig.tools.dynamicTools;
|
|
214
214
|
if (!dynamicConfig.enabled) {
|
|
@@ -260,8 +260,24 @@ export async function loadDynamicTools({ baseDir }) {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
const tools = {};
|
|
263
|
+
const conflictingTools = [];
|
|
263
264
|
for (const [_, { path, metadata }] of toolMap) {
|
|
265
|
+
const toolName = metadata.name;
|
|
266
|
+
// Check for conflicts with existing tools
|
|
267
|
+
if (existingToolNames.includes(toolName)) {
|
|
268
|
+
conflictingTools.push(toolName);
|
|
269
|
+
logger.warn(`Dynamic tool '${toolName}' conflicts with existing tool. Skipping.`);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
// Check for duplicate dynamic tool names
|
|
273
|
+
if (tools[toolName]) {
|
|
274
|
+
logger.warn(`Duplicate dynamic tool name '${toolName}' found. Skipping duplicate.`);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
264
277
|
Object.assign(tools, createDynamicTool(path, metadata));
|
|
265
278
|
}
|
|
279
|
+
if (conflictingTools.length > 0) {
|
|
280
|
+
logger.warn(`Warning: ${conflictingTools.length} dynamic tool(s) skipped due to name conflicts: ${conflictingTools.join(", ")}`);
|
|
281
|
+
}
|
|
266
282
|
return tools;
|
|
267
283
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
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 EditFileTool: {
|
|
4
5
|
name: "Edit";
|
|
5
6
|
};
|
|
6
7
|
declare const inputSchema: z.ZodObject<{
|
|
7
8
|
path: z.ZodString;
|
|
8
|
-
edits: z.ZodArray<z.ZodObject<{
|
|
9
|
+
edits: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
9
10
|
oldText: z.ZodString;
|
|
10
11
|
newText: z.ZodString;
|
|
11
|
-
}, z.core.$strip
|
|
12
|
+
}, z.core.$strip>>>;
|
|
12
13
|
}, z.core.$strip>;
|
|
13
14
|
type EditFileInputSchema = z.infer<typeof inputSchema>;
|
|
14
|
-
export declare const createEditFileTool: (
|
|
15
|
-
|
|
16
|
-
allowedDirs?: string[];
|
|
15
|
+
export declare const createEditFileTool: (options: {
|
|
16
|
+
workspace: WorkspaceContext;
|
|
17
17
|
}) => Promise<{
|
|
18
18
|
toolDef: {
|
|
19
19
|
description: string;
|
|
20
20
|
inputSchema: z.ZodObject<{
|
|
21
21
|
path: z.ZodString;
|
|
22
|
-
edits: z.ZodArray<z.ZodObject<{
|
|
22
|
+
edits: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
23
23
|
oldText: z.ZodString;
|
|
24
24
|
newText: z.ZodString;
|
|
25
|
-
}, z.core.$strip
|
|
25
|
+
}, z.core.$strip>>>;
|
|
26
26
|
}, z.core.$strip>;
|
|
27
27
|
};
|
|
28
28
|
display({ path, edits }: EditFileInputSchema): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-file.d.ts","sourceRoot":"","sources":["../../source/tools/edit-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"edit-file.d.ts","sourceRoot":"","sources":["../../source/tools/edit-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAIF,QAAA,MAAM,WAAW;;;;;;iBAqCf,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;;;;;;;;;;;6BAY4B,mBAAmB;6BAKzB,mBAAmB,mBACnB,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6BrB,CAAC;AAiDF,UAAU,QAAQ;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAwDD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,UAAQ,EACd,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,CAAC,CA6CjB"}
|