@travisennis/acai 0.0.7 → 0.0.9
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 +76 -27
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +145 -103
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -17
- 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} +57 -96
- 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 +35 -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 +122 -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 +230 -0
- package/dist/commands/session/types.d.ts +20 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- 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 +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 +194 -95
- 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 +14 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +39 -0
- package/dist/models/opencode-zen-provider.d.ts +24 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +94 -0
- package/dist/models/openrouter-provider.d.ts +35 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +108 -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 +12 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +74 -411
- 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 +18 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +256 -43
- 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} +62 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/stdin.d.ts +9 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +26 -0
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +29 -6
- 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 +104 -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 +6 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +166 -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 +64 -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/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 +7 -3
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +3 -2
- package/dist/tui/terminal.d.ts +29 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +153 -28
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +39 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +4 -1
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/zod.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
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { generateObject, NoSuchToolError, } from "ai";
|
|
2
|
-
import { jsonrepair } from "jsonrepair";
|
|
3
|
-
import { logger } from "../logger.js";
|
|
4
|
-
async function remoteToolCallRepair(modelManager, toolCall, tool, inputSchema) {
|
|
5
|
-
const { object: repairedArgs } = await generateObject({
|
|
6
|
-
model: modelManager.getModel("tool-repair"),
|
|
7
|
-
schema: tool.inputSchema,
|
|
8
|
-
prompt: [
|
|
9
|
-
`The model tried to call the tool "${toolCall.toolName}" with the following arguments:`,
|
|
10
|
-
JSON.stringify(toolCall.input),
|
|
11
|
-
"The tool accepts the following schema:",
|
|
12
|
-
JSON.stringify(inputSchema(toolCall)),
|
|
13
|
-
"Please fix the arguments.",
|
|
14
|
-
].join("\n"),
|
|
15
|
-
});
|
|
16
|
-
return { ...toolCall, input: JSON.stringify(repairedArgs) };
|
|
17
|
-
}
|
|
18
|
-
const localToolCallRepair = async (toolCall, tool) => {
|
|
19
|
-
const schema = tool.inputSchema;
|
|
20
|
-
const repairedArgs = jsonrepair(toolCall.input);
|
|
21
|
-
const validatedArgs = schema.parse(JSON.parse(repairedArgs));
|
|
22
|
-
return { ...toolCall, input: JSON.stringify(validatedArgs) };
|
|
23
|
-
};
|
|
24
|
-
export const toolCallRepair = (modelManager) => {
|
|
25
|
-
const fn = async ({ toolCall, tools, inputSchema, error, }) => {
|
|
26
|
-
if (NoSuchToolError.isInstance(error)) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
logger.warn(`Attempting to repair tool call: ${toolCall.toolName}.`);
|
|
30
|
-
const tool = tools[toolCall.toolName];
|
|
31
|
-
if (typeof tool === "undefined") {
|
|
32
|
-
logger.error(new Error("Tool not found"), `Failed to repair tool call: ${toolCall.toolName}.`);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const repaired = await localToolCallRepair(toolCall, tool);
|
|
37
|
-
logger.debug(`Tool call repaired with jsonrepair ${repaired.input}`);
|
|
38
|
-
return repaired;
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
logger.error(err, `Failed to repair tool call locally: ${toolCall.toolName}.`);
|
|
42
|
-
try {
|
|
43
|
-
const repaired = await remoteToolCallRepair(modelManager, toolCall, tool, inputSchema);
|
|
44
|
-
logger.debug(`Tool call repaired with remote repair ${repaired.input}`);
|
|
45
|
-
return repaired;
|
|
46
|
-
}
|
|
47
|
-
catch (err2) {
|
|
48
|
-
logger.error(err2, `Failed to repair tool call remotely: ${toolCall.toolName}.`);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return fn;
|
|
54
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../source/terminal/markdown.ts"],"names":[],"mappings":"AAcA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { EOL } from "node:os";
|
|
2
|
-
import { marked } from "marked";
|
|
3
|
-
import { logger } from "../logger.js";
|
|
4
|
-
import { DEFAULT_HIGHLIGHT_THEME } from "./default-theme.js";
|
|
5
|
-
import { link as terminalLink } from "./formatting.js";
|
|
6
|
-
import { highlight, supportsLanguage } from "./highlight/index.js";
|
|
7
|
-
import { getListNumber } from "./markdown-utils.js";
|
|
8
|
-
import style from "./style.js";
|
|
9
|
-
import { Table } from "./table/index.js";
|
|
10
|
-
function logError(msg) {
|
|
11
|
-
logger.error(msg);
|
|
12
|
-
}
|
|
13
|
-
export function applyMarkdown(content) {
|
|
14
|
-
return marked
|
|
15
|
-
.lexer(content)
|
|
16
|
-
.map((token) => format(token))
|
|
17
|
-
.join("")
|
|
18
|
-
.trim();
|
|
19
|
-
}
|
|
20
|
-
function format(token, listDepth = 0, orderedListNumber = null, parent = null) {
|
|
21
|
-
switch (token.type) {
|
|
22
|
-
case "blockquote":
|
|
23
|
-
return style.dim.italic((token.tokens ?? [])
|
|
24
|
-
.map((_) => format(_))
|
|
25
|
-
.map((l) => ` ${l}`)
|
|
26
|
-
.join(""));
|
|
27
|
-
case "code": {
|
|
28
|
-
if (token.lang && supportsLanguage(token.lang)) {
|
|
29
|
-
return (highlight(token.text, {
|
|
30
|
-
language: token.lang,
|
|
31
|
-
theme: DEFAULT_HIGHLIGHT_THEME,
|
|
32
|
-
}) + EOL);
|
|
33
|
-
}
|
|
34
|
-
logError(`Language not supported while highlighting code, falling back to markdown: ${token.lang}`);
|
|
35
|
-
return (highlight(token.text, {
|
|
36
|
-
language: "markdown",
|
|
37
|
-
theme: DEFAULT_HIGHLIGHT_THEME,
|
|
38
|
-
}) + EOL);
|
|
39
|
-
}
|
|
40
|
-
case "codespan":
|
|
41
|
-
// inline code
|
|
42
|
-
return style.blue(token.text);
|
|
43
|
-
case "em":
|
|
44
|
-
return style.italic((token.tokens ?? []).map((_) => format(_)).join(""));
|
|
45
|
-
case "strong":
|
|
46
|
-
return style.bold((token.tokens ?? []).map((_) => format(_)).join(""));
|
|
47
|
-
case "heading":
|
|
48
|
-
switch (token.depth) {
|
|
49
|
-
case 1: // h1
|
|
50
|
-
return (style.bold.italic.underline((token.tokens ?? []).map((_) => format(_)).join("")) +
|
|
51
|
-
EOL +
|
|
52
|
-
EOL);
|
|
53
|
-
case 2: // h2
|
|
54
|
-
return (style.bold((token.tokens ?? []).map((_) => format(_)).join("")) +
|
|
55
|
-
EOL +
|
|
56
|
-
EOL);
|
|
57
|
-
default: // h3+
|
|
58
|
-
return (style.bold.dim((token.tokens ?? []).map((_) => format(_)).join("")) +
|
|
59
|
-
EOL +
|
|
60
|
-
EOL);
|
|
61
|
-
}
|
|
62
|
-
case "hr":
|
|
63
|
-
return "---";
|
|
64
|
-
case "image": {
|
|
65
|
-
const alt = (token.title ?? token.text ?? "").toString().trim();
|
|
66
|
-
if (alt.length > 0) {
|
|
67
|
-
return `[Image: ${alt} (${token.href})]`;
|
|
68
|
-
}
|
|
69
|
-
return `[Image: ${token.href}]`;
|
|
70
|
-
}
|
|
71
|
-
case "link":
|
|
72
|
-
return terminalLink(token.text, token.href);
|
|
73
|
-
case "list": {
|
|
74
|
-
return token.items
|
|
75
|
-
.map((_, index) => format(_, listDepth, token.ordered ? token.start + index : null, token))
|
|
76
|
-
.join("");
|
|
77
|
-
}
|
|
78
|
-
case "list_item":
|
|
79
|
-
return (token.tokens ?? [])
|
|
80
|
-
.map((_) => `${" ".repeat(listDepth)}${format(_, listDepth + 1, orderedListNumber, token)}`)
|
|
81
|
-
.join("");
|
|
82
|
-
case "paragraph":
|
|
83
|
-
return (token.tokens ?? []).map((_) => format(_)).join("") + EOL;
|
|
84
|
-
case "space":
|
|
85
|
-
return EOL;
|
|
86
|
-
case "text": {
|
|
87
|
-
if (parent?.type === "list_item") {
|
|
88
|
-
return `${orderedListNumber === null ? "-" : `${getListNumber(listDepth, orderedListNumber)}.`} ${token.tokens ? token.tokens.map((_) => format(_, listDepth, orderedListNumber, token)).join("") : token.text}${EOL}`;
|
|
89
|
-
}
|
|
90
|
-
return token.text;
|
|
91
|
-
}
|
|
92
|
-
case "table": {
|
|
93
|
-
const header = Array.isArray(token.header)
|
|
94
|
-
? token.header
|
|
95
|
-
: [token.header];
|
|
96
|
-
const rows = Array.isArray(token.rows) ? token.rows : [token.rows];
|
|
97
|
-
// Calculate column widths based on terminal width
|
|
98
|
-
const padding = 5; // Account for table borders and padding
|
|
99
|
-
const availableWidth = Math.max(10, (process.stdout.columns || 80) - padding);
|
|
100
|
-
const colCount = header?.length ?? 1;
|
|
101
|
-
const width = Math.max(10, Math.floor(availableWidth / Math.max(1, colCount)));
|
|
102
|
-
const computedColWidths = new Array(colCount).fill(width);
|
|
103
|
-
const table = new Table({
|
|
104
|
-
head: header.map((h) => h.text),
|
|
105
|
-
colWidths: computedColWidths,
|
|
106
|
-
wordWrap: true, // Enable word wrapping for the description column
|
|
107
|
-
});
|
|
108
|
-
table.push(...rows.map((row) => row.map((c) => c.text)));
|
|
109
|
-
return `${table.toString()}\n`;
|
|
110
|
-
}
|
|
111
|
-
case "del": {
|
|
112
|
-
return style.strikethrough(token.text);
|
|
113
|
-
}
|
|
114
|
-
case "html":
|
|
115
|
-
// Render HTML tags with dim styling and content as normal text
|
|
116
|
-
return style.dim(token.text);
|
|
117
|
-
default:
|
|
118
|
-
return "";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TokenCounter } from "./counter.ts";
|
|
2
|
-
export declare function clearTokenCache(): void;
|
|
3
|
-
export declare class TokenLimitExceededError extends Error {
|
|
4
|
-
constructor(toolName: string, tokenCount: number, maxTokens: number, guidance?: string);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Check if content exceeds token limit
|
|
8
|
-
* @param content - The content to check
|
|
9
|
-
* @param tokenCounter - Token counter instance
|
|
10
|
-
* @param toolName - Name of the tool for messages
|
|
11
|
-
* @param additionalGuidance - Optional tool-specific guidance
|
|
12
|
-
* @param encoding - Optional encoding type for non-text file handling
|
|
13
|
-
* @returns Content with token count if under limit
|
|
14
|
-
* @throws TokenLimitExceededError if content exceeds token limit
|
|
15
|
-
*/
|
|
16
|
-
export declare function manageTokenLimit<T extends string>(content: T, tokenCounter: TokenCounter, toolName: string, additionalGuidance?: string, encoding?: string): Promise<{
|
|
17
|
-
content: T;
|
|
18
|
-
tokenCount: number;
|
|
19
|
-
}>;
|
|
20
|
-
//# sourceMappingURL=threshold.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"threshold.d.ts","sourceRoot":"","sources":["../../source/tokens/threshold.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAQjD,wBAAgB,eAAe,SAG9B;AAyBD,qBAAa,uBAAwB,SAAQ,KAAK;gBAE9C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM;CASpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EACrD,OAAO,EAAE,CAAC,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CA2B7C"}
|
package/dist/tokens/threshold.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { config } from "../config.js";
|
|
2
|
-
// Cache for maxTokens config to avoid repeated async calls
|
|
3
|
-
let maxTokensCache = null;
|
|
4
|
-
let cacheExpiry = 0;
|
|
5
|
-
const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
|
|
6
|
-
// Export cache management for testing
|
|
7
|
-
export function clearTokenCache() {
|
|
8
|
-
maxTokensCache = null;
|
|
9
|
-
cacheExpiry = 0;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Get maxTokens from config with caching
|
|
13
|
-
*/
|
|
14
|
-
async function getMaxTokens() {
|
|
15
|
-
const now = Date.now();
|
|
16
|
-
if (maxTokensCache !== null && now < cacheExpiry) {
|
|
17
|
-
return maxTokensCache;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const projectConfig = await config.getConfig();
|
|
21
|
-
maxTokensCache = projectConfig.tools.maxTokens;
|
|
22
|
-
cacheExpiry = now + CACHE_DURATION;
|
|
23
|
-
return maxTokensCache;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.info("Failed to read config for maxTokens, using default:", error);
|
|
27
|
-
maxTokensCache = 8000; // Default fallback
|
|
28
|
-
cacheExpiry = now + CACHE_DURATION;
|
|
29
|
-
return maxTokensCache;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export class TokenLimitExceededError extends Error {
|
|
33
|
-
constructor(toolName, tokenCount, maxTokens, guidance) {
|
|
34
|
-
super(`${toolName}: Content (${tokenCount} tokens) exceeds maximum allowed tokens (${maxTokens}). ${guidance || "Please adjust parameters to reduce content size."}`);
|
|
35
|
-
this.name = "TokenLimitExceededError";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if content exceeds token limit
|
|
40
|
-
* @param content - The content to check
|
|
41
|
-
* @param tokenCounter - Token counter instance
|
|
42
|
-
* @param toolName - Name of the tool for messages
|
|
43
|
-
* @param additionalGuidance - Optional tool-specific guidance
|
|
44
|
-
* @param encoding - Optional encoding type for non-text file handling
|
|
45
|
-
* @returns Content with token count if under limit
|
|
46
|
-
* @throws TokenLimitExceededError if content exceeds token limit
|
|
47
|
-
*/
|
|
48
|
-
export async function manageTokenLimit(content, tokenCounter, toolName, additionalGuidance, encoding) {
|
|
49
|
-
// For non-text files, return content directly without token management
|
|
50
|
-
if (encoding && !encoding.startsWith("utf")) {
|
|
51
|
-
return { content, tokenCount: 0 };
|
|
52
|
-
}
|
|
53
|
-
let tokenCount = 0;
|
|
54
|
-
try {
|
|
55
|
-
tokenCount = tokenCounter.count(content);
|
|
56
|
-
}
|
|
57
|
-
catch (tokenError) {
|
|
58
|
-
console.info("Error calculating token count:", tokenError);
|
|
59
|
-
// Return content if token counting fails
|
|
60
|
-
return { content, tokenCount: 0 };
|
|
61
|
-
}
|
|
62
|
-
const maxTokens = await getMaxTokens();
|
|
63
|
-
if (tokenCount <= maxTokens) {
|
|
64
|
-
return { content, tokenCount };
|
|
65
|
-
}
|
|
66
|
-
throw new TokenLimitExceededError(toolName, tokenCount, maxTokens, additionalGuidance);
|
|
67
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { ToolCallOptions } from "ai";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { ToolResult } from "./types.ts";
|
|
4
|
-
export declare const AdvancedEditFileTool: {
|
|
5
|
-
name: "advancedEditFile";
|
|
6
|
-
};
|
|
7
|
-
declare const inputSchema: z.ZodObject<{
|
|
8
|
-
path: z.ZodString;
|
|
9
|
-
mode: z.ZodDefault<z.ZodEnum<{
|
|
10
|
-
exact: "exact";
|
|
11
|
-
regex: "regex";
|
|
12
|
-
ast: "ast";
|
|
13
|
-
}>>;
|
|
14
|
-
operations: z.ZodArray<z.ZodObject<{
|
|
15
|
-
type: z.ZodEnum<{
|
|
16
|
-
replace: "replace";
|
|
17
|
-
"insert-before": "insert-before";
|
|
18
|
-
"insert-after": "insert-after";
|
|
19
|
-
delete: "delete";
|
|
20
|
-
}>;
|
|
21
|
-
pattern: z.ZodString;
|
|
22
|
-
replacement: z.ZodOptional<z.ZodString>;
|
|
23
|
-
flags: z.ZodOptional<z.ZodString>;
|
|
24
|
-
}, z.core.$strip>>;
|
|
25
|
-
astPattern: z.ZodOptional<z.ZodString>;
|
|
26
|
-
astReplacement: z.ZodOptional<z.ZodString>;
|
|
27
|
-
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
|
-
type AdvancedEditFileInputSchema = z.infer<typeof inputSchema>;
|
|
30
|
-
interface FileOperation {
|
|
31
|
-
type: "replace" | "insert-before" | "insert-after" | "delete";
|
|
32
|
-
pattern: string;
|
|
33
|
-
replacement?: string;
|
|
34
|
-
flags?: string;
|
|
35
|
-
}
|
|
36
|
-
export declare const createAdvancedEditFileTool: ({ workingDir, allowedDirs, }: {
|
|
37
|
-
workingDir: string;
|
|
38
|
-
allowedDirs?: string[];
|
|
39
|
-
}) => Promise<{
|
|
40
|
-
toolDef: {
|
|
41
|
-
description: string;
|
|
42
|
-
inputSchema: z.ZodObject<{
|
|
43
|
-
path: z.ZodString;
|
|
44
|
-
mode: z.ZodDefault<z.ZodEnum<{
|
|
45
|
-
exact: "exact";
|
|
46
|
-
regex: "regex";
|
|
47
|
-
ast: "ast";
|
|
48
|
-
}>>;
|
|
49
|
-
operations: z.ZodArray<z.ZodObject<{
|
|
50
|
-
type: z.ZodEnum<{
|
|
51
|
-
replace: "replace";
|
|
52
|
-
"insert-before": "insert-before";
|
|
53
|
-
"insert-after": "insert-after";
|
|
54
|
-
delete: "delete";
|
|
55
|
-
}>;
|
|
56
|
-
pattern: z.ZodString;
|
|
57
|
-
replacement: z.ZodOptional<z.ZodString>;
|
|
58
|
-
flags: z.ZodOptional<z.ZodString>;
|
|
59
|
-
}, z.core.$strip>>;
|
|
60
|
-
astPattern: z.ZodOptional<z.ZodString>;
|
|
61
|
-
astReplacement: z.ZodOptional<z.ZodString>;
|
|
62
|
-
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
};
|
|
65
|
-
execute({ path, mode, operations, astPattern, astReplacement, dryRun, }: AdvancedEditFileInputSchema, { toolCallId, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
|
|
66
|
-
}>;
|
|
67
|
-
export declare function applyAdvancedFileEdits(filePath: string, mode: "exact" | "regex" | "ast", operations: FileOperation[], astPattern?: string, astReplacement?: string, dryRun?: boolean, abortSignal?: AbortSignal): Promise<string>;
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=advanced-edit-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-edit-file.d.ts","sourceRoot":"","sources":["../../source/tools/advanced-edit-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,oBAAoB;;CAEhC,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;iBAuCf,CAAC;AAEH,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE/D,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,GAAG,eAAe,GAAG,cAAc,GAAG,QAAQ,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,0BAA0B,GAAU,8BAG9C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;6EAiBQ,2BAA2B,+BACD,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EAoDhC,CAAC;AA2MF,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,EAC/B,UAAU,EAAE,aAAa,EAAE,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,MAAM,UAAQ,EACd,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,CAAC,CAyEjB"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import { createTwoFilesPatch } from "diff";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { config } from "../config.js";
|
|
6
|
-
import style from "../terminal/style.js";
|
|
7
|
-
import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
|
|
8
|
-
export const AdvancedEditFileTool = {
|
|
9
|
-
name: "advancedEditFile",
|
|
10
|
-
};
|
|
11
|
-
const inputSchema = z.object({
|
|
12
|
-
path: z.string().describe("The path of the file to edit."),
|
|
13
|
-
mode: z
|
|
14
|
-
.enum(["exact", "regex", "ast"])
|
|
15
|
-
.default("exact")
|
|
16
|
-
.describe("Editing mode: exact (literal text), regex (pattern matching), or ast (AST-aware)"),
|
|
17
|
-
operations: z.array(z.object({
|
|
18
|
-
type: z
|
|
19
|
-
.enum(["replace", "insert-before", "insert-after", "delete"])
|
|
20
|
-
.describe("Type of operation to perform"),
|
|
21
|
-
pattern: z
|
|
22
|
-
.string()
|
|
23
|
-
.describe("Pattern to match (text, regex, or AST pattern depending on mode)"),
|
|
24
|
-
replacement: z
|
|
25
|
-
.string()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe("Replacement text (required for replace operations)"),
|
|
28
|
-
flags: z
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe("Regex flags for regex mode (e.g., 'g', 'i', 'm')"),
|
|
32
|
-
})),
|
|
33
|
-
astPattern: z
|
|
34
|
-
.string()
|
|
35
|
-
.optional()
|
|
36
|
-
.describe("AST-grep search pattern for AST mode (e.g., 'var $V = $VAL')"),
|
|
37
|
-
astReplacement: z
|
|
38
|
-
.string()
|
|
39
|
-
.optional()
|
|
40
|
-
.describe("AST-grep replacement pattern for AST mode (e.g., 'let $V = $VAL')"),
|
|
41
|
-
dryRun: z.boolean().default(false).describe("Show changes without writing"),
|
|
42
|
-
});
|
|
43
|
-
export const createAdvancedEditFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
44
|
-
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
45
|
-
return {
|
|
46
|
-
toolDef: {
|
|
47
|
-
description: "Advanced file editing with multiple modes: exact text matching, regex pattern matching, and AST-aware editing. " +
|
|
48
|
-
"Supports replace, insert-before, insert-after, and delete operations. AST mode requires ast-grep to be installed.",
|
|
49
|
-
inputSchema,
|
|
50
|
-
},
|
|
51
|
-
async *execute({ path, mode, operations, astPattern, astReplacement, dryRun, }, { toolCallId, abortSignal }) {
|
|
52
|
-
try {
|
|
53
|
-
if (abortSignal?.aborted) {
|
|
54
|
-
throw new Error("File editing aborted");
|
|
55
|
-
}
|
|
56
|
-
yield {
|
|
57
|
-
name: AdvancedEditFileTool.name,
|
|
58
|
-
id: toolCallId,
|
|
59
|
-
event: "tool-init",
|
|
60
|
-
data: `${style.cyan(path)} (mode: ${mode})`,
|
|
61
|
-
};
|
|
62
|
-
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
63
|
-
// Check if file is read-only
|
|
64
|
-
const projectConfig = await config.getConfig();
|
|
65
|
-
validateFileNotReadOnly(validPath, projectConfig, workingDir);
|
|
66
|
-
const result = await applyAdvancedFileEdits(validPath, mode, operations, astPattern, astReplacement, dryRun, abortSignal);
|
|
67
|
-
yield {
|
|
68
|
-
name: AdvancedEditFileTool.name,
|
|
69
|
-
id: toolCallId,
|
|
70
|
-
event: "tool-completion",
|
|
71
|
-
data: `Applied ${operations.length} edits`,
|
|
72
|
-
};
|
|
73
|
-
yield result;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
yield {
|
|
77
|
-
name: AdvancedEditFileTool.name,
|
|
78
|
-
event: "tool-error",
|
|
79
|
-
id: toolCallId,
|
|
80
|
-
data: error.message,
|
|
81
|
-
};
|
|
82
|
-
yield `Failed to edit file: ${error.message}`;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
// file editing and diffing utilities
|
|
88
|
-
function normalizeLineEndings(text) {
|
|
89
|
-
return text.replace(/\r\n/g, "\n");
|
|
90
|
-
}
|
|
91
|
-
function createUnifiedDiff(originalContent, newContent, filepath = "file") {
|
|
92
|
-
// Ensure consistent line endings for diff
|
|
93
|
-
const normalizedOriginal = normalizeLineEndings(originalContent);
|
|
94
|
-
const normalizedNew = normalizeLineEndings(newContent);
|
|
95
|
-
return createTwoFilesPatch(filepath, filepath, normalizedOriginal, normalizedNew, "original", "modified");
|
|
96
|
-
}
|
|
97
|
-
function applyExactModeEdits(content, operations) {
|
|
98
|
-
let modifiedContent = content;
|
|
99
|
-
for (const op of operations) {
|
|
100
|
-
switch (op.type) {
|
|
101
|
-
case "replace": {
|
|
102
|
-
if (!op.replacement) {
|
|
103
|
-
throw new Error("Replacement text required for replace operation");
|
|
104
|
-
}
|
|
105
|
-
// Exact text replacement (global)
|
|
106
|
-
let currentIndex = 0;
|
|
107
|
-
let matchCount = 0;
|
|
108
|
-
while (currentIndex < modifiedContent.length) {
|
|
109
|
-
const matchIndex = modifiedContent.indexOf(op.pattern, currentIndex);
|
|
110
|
-
if (matchIndex === -1) {
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
matchCount++;
|
|
114
|
-
modifiedContent =
|
|
115
|
-
modifiedContent.slice(0, matchIndex) +
|
|
116
|
-
op.replacement +
|
|
117
|
-
modifiedContent.slice(matchIndex + op.pattern.length);
|
|
118
|
-
currentIndex = matchIndex + op.replacement.length;
|
|
119
|
-
}
|
|
120
|
-
if (matchCount === 0) {
|
|
121
|
-
throw new Error(`Pattern not found in content: ${op.pattern}`);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
case "insert-before": {
|
|
126
|
-
if (!op.replacement) {
|
|
127
|
-
throw new Error("Replacement text required for insert-before operation");
|
|
128
|
-
}
|
|
129
|
-
const beforeIndex = modifiedContent.indexOf(op.pattern);
|
|
130
|
-
if (beforeIndex === -1) {
|
|
131
|
-
throw new Error(`Pattern not found for insert-before: ${op.pattern}`);
|
|
132
|
-
}
|
|
133
|
-
modifiedContent =
|
|
134
|
-
modifiedContent.slice(0, beforeIndex) +
|
|
135
|
-
op.replacement +
|
|
136
|
-
"\n" +
|
|
137
|
-
modifiedContent.slice(beforeIndex);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case "insert-after": {
|
|
141
|
-
if (!op.replacement) {
|
|
142
|
-
throw new Error("Replacement text required for insert-after operation");
|
|
143
|
-
}
|
|
144
|
-
const afterIndex = modifiedContent.indexOf(op.pattern);
|
|
145
|
-
if (afterIndex === -1) {
|
|
146
|
-
throw new Error(`Pattern not found for insert-after: ${op.pattern}`);
|
|
147
|
-
}
|
|
148
|
-
const insertPosition = afterIndex + op.pattern.length;
|
|
149
|
-
modifiedContent =
|
|
150
|
-
modifiedContent.slice(0, insertPosition) +
|
|
151
|
-
"\n" +
|
|
152
|
-
op.replacement +
|
|
153
|
-
modifiedContent.slice(insertPosition);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case "delete": {
|
|
157
|
-
// For delete operations, use line-based approach to handle newlines properly
|
|
158
|
-
const lines = modifiedContent.split("\n");
|
|
159
|
-
const filteredLines = lines.filter((line) => !line.includes(op.pattern));
|
|
160
|
-
if (filteredLines.length === lines.length) {
|
|
161
|
-
throw new Error(`Pattern not found for delete: ${op.pattern}`);
|
|
162
|
-
}
|
|
163
|
-
modifiedContent = filteredLines.join("\n");
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return modifiedContent;
|
|
169
|
-
}
|
|
170
|
-
function applyRegexModeEdits(content, operations) {
|
|
171
|
-
let modifiedContent = content;
|
|
172
|
-
for (const op of operations) {
|
|
173
|
-
const flags = op.flags || "g";
|
|
174
|
-
const regex = new RegExp(op.pattern, flags);
|
|
175
|
-
switch (op.type) {
|
|
176
|
-
case "replace":
|
|
177
|
-
if (!op.replacement) {
|
|
178
|
-
throw new Error("Replacement text required for replace operation");
|
|
179
|
-
}
|
|
180
|
-
modifiedContent = modifiedContent.replace(regex, op.replacement);
|
|
181
|
-
break;
|
|
182
|
-
case "insert-before":
|
|
183
|
-
if (!op.replacement) {
|
|
184
|
-
throw new Error("Replacement text required for insert-before operation");
|
|
185
|
-
}
|
|
186
|
-
modifiedContent = modifiedContent.replace(regex, `${op.replacement}\n$&`);
|
|
187
|
-
break;
|
|
188
|
-
case "insert-after":
|
|
189
|
-
if (!op.replacement) {
|
|
190
|
-
throw new Error("Replacement text required for insert-after operation");
|
|
191
|
-
}
|
|
192
|
-
modifiedContent = modifiedContent.replace(regex, `$&\n${op.replacement}`);
|
|
193
|
-
break;
|
|
194
|
-
case "delete":
|
|
195
|
-
modifiedContent = modifiedContent.replace(regex, "");
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return modifiedContent;
|
|
200
|
-
}
|
|
201
|
-
function applyAstModeEdits(filePath, astPattern, astReplacement, dryRun) {
|
|
202
|
-
if (!astPattern || !astReplacement) {
|
|
203
|
-
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
204
|
-
}
|
|
205
|
-
try {
|
|
206
|
-
const cmd = [
|
|
207
|
-
"ast-grep",
|
|
208
|
-
"--pattern",
|
|
209
|
-
`"${astPattern}"`,
|
|
210
|
-
"--rewrite",
|
|
211
|
-
`"${astReplacement}"`,
|
|
212
|
-
dryRun ? "--dry-run" : "--write",
|
|
213
|
-
filePath,
|
|
214
|
-
].join(" ");
|
|
215
|
-
if (dryRun) {
|
|
216
|
-
const output = execSync(cmd, { encoding: "utf-8" });
|
|
217
|
-
return `AST edit preview:\n${output}`;
|
|
218
|
-
}
|
|
219
|
-
execSync(cmd, { stdio: "inherit" });
|
|
220
|
-
return `AST edit applied to ${filePath}`;
|
|
221
|
-
}
|
|
222
|
-
catch (err) {
|
|
223
|
-
throw new Error(`AST edit failed: ${err.message}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
export async function applyAdvancedFileEdits(filePath, mode, operations, astPattern, astReplacement, dryRun = false, abortSignal) {
|
|
227
|
-
if (abortSignal?.aborted) {
|
|
228
|
-
throw new Error("File edit operation aborted");
|
|
229
|
-
}
|
|
230
|
-
// Read file content literally with signal
|
|
231
|
-
const originalContent = await readFile(filePath, {
|
|
232
|
-
encoding: "utf-8",
|
|
233
|
-
signal: abortSignal,
|
|
234
|
-
});
|
|
235
|
-
let modifiedContent = originalContent;
|
|
236
|
-
let resultMessage = "";
|
|
237
|
-
if (mode === "ast") {
|
|
238
|
-
// AST mode uses external ast-grep tool
|
|
239
|
-
if (!astPattern || !astReplacement) {
|
|
240
|
-
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
241
|
-
}
|
|
242
|
-
resultMessage = applyAstModeEdits(filePath, astPattern, astReplacement, dryRun);
|
|
243
|
-
if (dryRun) {
|
|
244
|
-
return resultMessage;
|
|
245
|
-
}
|
|
246
|
-
// For actual AST edits, read the modified content back
|
|
247
|
-
modifiedContent = await readFile(filePath, {
|
|
248
|
-
encoding: "utf-8",
|
|
249
|
-
signal: abortSignal,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
// Text-based modes (exact and regex)
|
|
254
|
-
if (operations.length === 0) {
|
|
255
|
-
throw new Error("No operations specified for text-based editing mode");
|
|
256
|
-
}
|
|
257
|
-
switch (mode) {
|
|
258
|
-
case "exact":
|
|
259
|
-
modifiedContent = applyExactModeEdits(originalContent, operations);
|
|
260
|
-
break;
|
|
261
|
-
case "regex":
|
|
262
|
-
modifiedContent = applyRegexModeEdits(originalContent, operations);
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
// Create unified diff
|
|
266
|
-
const diff = createUnifiedDiff(originalContent, modifiedContent, filePath);
|
|
267
|
-
// Format diff with appropriate number of backticks
|
|
268
|
-
let numBackticks = 3;
|
|
269
|
-
while (diff.includes("`".repeat(numBackticks))) {
|
|
270
|
-
numBackticks++;
|
|
271
|
-
}
|
|
272
|
-
resultMessage = `${"`".repeat(numBackticks)}diff\n${diff}${"`".repeat(numBackticks)}\n\n`;
|
|
273
|
-
if (!dryRun) {
|
|
274
|
-
if (abortSignal?.aborted) {
|
|
275
|
-
throw new Error("File edit operation aborted before writing");
|
|
276
|
-
}
|
|
277
|
-
// Write the modified content with signal
|
|
278
|
-
await writeFile(filePath, modifiedContent, {
|
|
279
|
-
encoding: "utf-8",
|
|
280
|
-
signal: abortSignal,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return resultMessage;
|
|
285
|
-
}
|
package/dist/tools/agent.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type ToolCallOptions } from "ai";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { WorkspaceContext } from "../index.ts";
|
|
4
|
-
import type { ModelManager } from "../models/manager.ts";
|
|
5
|
-
import type { TokenCounter } from "../tokens/counter.ts";
|
|
6
|
-
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
7
|
-
import type { ToolResult } from "./types.ts";
|
|
8
|
-
export declare const AgentTool: {
|
|
9
|
-
name: "agent";
|
|
10
|
-
};
|
|
11
|
-
declare const inputSchema: z.ZodObject<{
|
|
12
|
-
prompt: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export declare const createAgentTools: (options: {
|
|
15
|
-
modelManager: ModelManager;
|
|
16
|
-
tokenTracker: TokenTracker;
|
|
17
|
-
tokenCounter: TokenCounter;
|
|
18
|
-
workspace: WorkspaceContext;
|
|
19
|
-
}) => {
|
|
20
|
-
toolDef: {
|
|
21
|
-
description: string;
|
|
22
|
-
inputSchema: z.ZodObject<{
|
|
23
|
-
prompt: z.ZodString;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
};
|
|
26
|
-
execute: ({ prompt }: z.infer<typeof inputSchema>, { toolCallId, abortSignal }: ToolCallOptions) => AsyncGenerator<ToolResult>;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../source/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,SAAS;;CAErB,CAAC;AAiCF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,eAAO,MAAM,gBAAgB,GAAI,SAAS;IACxC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;0BASe,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,+BACV,eAAe,KAC3C,cAAc,CAAC,UAAU,CAAC;CA+E9B,CAAC"}
|