@travisennis/acai 0.0.5 → 0.0.7
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 +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import stringWidth from "../string-width.js";
|
|
2
|
+
function codeRegex(capture) {
|
|
3
|
+
return capture
|
|
4
|
+
? // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences for terminal formatting
|
|
5
|
+
/\u001b\[((?:\d*;){0,5}\d*)m/g
|
|
6
|
+
: // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences for terminal formatting
|
|
7
|
+
/\u001b\[(?:\d*;){0,5}\d*m/g;
|
|
8
|
+
}
|
|
9
|
+
export function strlen(str) {
|
|
10
|
+
const code = codeRegex(false);
|
|
11
|
+
const stripped = `${str}`.replace(code, "");
|
|
12
|
+
const split = stripped.split("\n");
|
|
13
|
+
return split.reduce((memo, s) => {
|
|
14
|
+
return stringWidth(s) > memo ? stringWidth(s) : memo;
|
|
15
|
+
}, 0);
|
|
16
|
+
}
|
|
17
|
+
export function repeat(str, times) {
|
|
18
|
+
return Array(times + 1).join(str);
|
|
19
|
+
}
|
|
20
|
+
export function pad(str, len, padChar, dir) {
|
|
21
|
+
const length = strlen(str);
|
|
22
|
+
let result = str;
|
|
23
|
+
if (len + 1 >= length) {
|
|
24
|
+
const padlen = len - length;
|
|
25
|
+
switch (dir) {
|
|
26
|
+
case "right": {
|
|
27
|
+
result = repeat(padChar, padlen) + result;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "center": {
|
|
31
|
+
const right = Math.ceil(padlen / 2);
|
|
32
|
+
const left = padlen - right;
|
|
33
|
+
result = repeat(padChar, left) + result + repeat(padChar, right);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
default: {
|
|
37
|
+
result = result + repeat(padChar, padlen);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
const codeCache = {};
|
|
45
|
+
function addToCodeCache(name, on, off) {
|
|
46
|
+
const onCode = `\u001b[${on}m`;
|
|
47
|
+
const offCode = `\u001b[${off}m`;
|
|
48
|
+
codeCache[onCode] = { set: name, to: true };
|
|
49
|
+
codeCache[offCode] = { set: name, to: false };
|
|
50
|
+
codeCache[name] = { on: onCode, off: offCode };
|
|
51
|
+
}
|
|
52
|
+
// https://github.com/Marak/colors.js/blob/master/lib/styles.js
|
|
53
|
+
addToCodeCache("bold", "1", "22");
|
|
54
|
+
addToCodeCache("italics", "3", "23");
|
|
55
|
+
addToCodeCache("underline", "4", "24");
|
|
56
|
+
addToCodeCache("inverse", "7", "27");
|
|
57
|
+
addToCodeCache("strikethrough", "9", "29");
|
|
58
|
+
function updateState(state, controlChars) {
|
|
59
|
+
const controlCode = controlChars[1]
|
|
60
|
+
? Number.parseInt(controlChars[1].split(";")[0], 10)
|
|
61
|
+
: 0;
|
|
62
|
+
if ((controlCode >= 30 && controlCode <= 39) ||
|
|
63
|
+
(controlCode >= 90 && controlCode <= 97)) {
|
|
64
|
+
state.lastForegroundAdded = controlChars[0];
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if ((controlCode >= 40 && controlCode <= 49) ||
|
|
68
|
+
(controlCode >= 100 && controlCode <= 107)) {
|
|
69
|
+
state.lastBackgroundAdded = controlChars[0];
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (controlCode === 0) {
|
|
73
|
+
for (const i in state) {
|
|
74
|
+
/* istanbul ignore else */
|
|
75
|
+
if (Object.hasOwn(state, i)) {
|
|
76
|
+
delete state[i];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const info = codeCache[controlChars[0]];
|
|
82
|
+
if (info) {
|
|
83
|
+
state[info.set] = info.to;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function readState(line) {
|
|
87
|
+
const code = codeRegex(true);
|
|
88
|
+
let controlChars = code.exec(line);
|
|
89
|
+
const state = {};
|
|
90
|
+
while (controlChars !== null) {
|
|
91
|
+
updateState(state, controlChars);
|
|
92
|
+
controlChars = code.exec(line);
|
|
93
|
+
}
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
96
|
+
function unwindState(state, ret) {
|
|
97
|
+
const lastBackgroundAdded = state.lastBackgroundAdded;
|
|
98
|
+
const lastForegroundAdded = state.lastForegroundAdded;
|
|
99
|
+
delete state.lastBackgroundAdded;
|
|
100
|
+
delete state.lastForegroundAdded;
|
|
101
|
+
let result = ret;
|
|
102
|
+
Object.keys(state).forEach((key) => {
|
|
103
|
+
if (state[key]) {
|
|
104
|
+
const cacheEntry = codeCache[key];
|
|
105
|
+
result += cacheEntry.off;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (lastBackgroundAdded && lastBackgroundAdded !== "\u001b[49m") {
|
|
109
|
+
result += "\u001b[49m";
|
|
110
|
+
}
|
|
111
|
+
if (lastForegroundAdded && lastForegroundAdded !== "\u001b[39m") {
|
|
112
|
+
result += "\u001b[39m";
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
function rewindState(state, ret) {
|
|
117
|
+
const lastBackgroundAdded = state.lastBackgroundAdded;
|
|
118
|
+
const lastForegroundAdded = state.lastForegroundAdded;
|
|
119
|
+
delete state.lastBackgroundAdded;
|
|
120
|
+
delete state.lastForegroundAdded;
|
|
121
|
+
let result = ret;
|
|
122
|
+
Object.keys(state).forEach((key) => {
|
|
123
|
+
if (state[key]) {
|
|
124
|
+
const cacheEntry = codeCache[key];
|
|
125
|
+
result = cacheEntry.on + result;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
if (lastBackgroundAdded && lastBackgroundAdded !== "\u001b[49m") {
|
|
129
|
+
result = lastBackgroundAdded + result;
|
|
130
|
+
}
|
|
131
|
+
if (lastForegroundAdded && lastForegroundAdded !== "\u001b[39m") {
|
|
132
|
+
result = lastForegroundAdded + result;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
function truncateWidth(str, desiredLength) {
|
|
137
|
+
if (str.length === strlen(str)) {
|
|
138
|
+
return str.substr(0, desiredLength);
|
|
139
|
+
}
|
|
140
|
+
let result = str;
|
|
141
|
+
while (strlen(result) > desiredLength) {
|
|
142
|
+
result = result.slice(0, -1);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
function truncateWidthWithAnsi(str, desiredLength) {
|
|
147
|
+
const code = codeRegex(true);
|
|
148
|
+
const split = str.split(codeRegex(false));
|
|
149
|
+
let splitIndex = 0;
|
|
150
|
+
let retLen = 0;
|
|
151
|
+
let ret = "";
|
|
152
|
+
let myArray;
|
|
153
|
+
const state = {};
|
|
154
|
+
while (retLen < desiredLength) {
|
|
155
|
+
myArray = code.exec(str);
|
|
156
|
+
let toAdd = split[splitIndex];
|
|
157
|
+
splitIndex++;
|
|
158
|
+
if (retLen + strlen(toAdd) > desiredLength) {
|
|
159
|
+
toAdd = truncateWidth(toAdd, desiredLength - retLen);
|
|
160
|
+
}
|
|
161
|
+
ret += toAdd;
|
|
162
|
+
retLen += strlen(toAdd);
|
|
163
|
+
if (retLen < desiredLength) {
|
|
164
|
+
if (!myArray) {
|
|
165
|
+
break;
|
|
166
|
+
} // full-width chars may cause a whitespace which cannot be filled
|
|
167
|
+
ret += myArray[0];
|
|
168
|
+
updateState(state, myArray);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return unwindState(state, ret);
|
|
172
|
+
}
|
|
173
|
+
export function truncate(str, desiredLength, truncateChar) {
|
|
174
|
+
const finalTruncateChar = truncateChar || "…";
|
|
175
|
+
const lengthOfStr = strlen(str);
|
|
176
|
+
if (lengthOfStr <= desiredLength) {
|
|
177
|
+
return str;
|
|
178
|
+
}
|
|
179
|
+
const finalDesiredLength = desiredLength - strlen(finalTruncateChar);
|
|
180
|
+
let ret = truncateWidthWithAnsi(str, finalDesiredLength);
|
|
181
|
+
ret += finalTruncateChar;
|
|
182
|
+
const hrefTag = "\x1B]8;;\x07";
|
|
183
|
+
if (str.includes(hrefTag) && !ret.includes(hrefTag)) {
|
|
184
|
+
ret += hrefTag;
|
|
185
|
+
}
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
188
|
+
export function defaultOptions() {
|
|
189
|
+
return {
|
|
190
|
+
chars: {
|
|
191
|
+
top: "─",
|
|
192
|
+
topMid: "┬",
|
|
193
|
+
topLeft: "┌",
|
|
194
|
+
topRight: "┐",
|
|
195
|
+
bottom: "─",
|
|
196
|
+
bottomMid: "┴",
|
|
197
|
+
bottomLeft: "└",
|
|
198
|
+
bottomRight: "┘",
|
|
199
|
+
left: "│",
|
|
200
|
+
leftMid: "├",
|
|
201
|
+
mid: "─",
|
|
202
|
+
midMid: "┼",
|
|
203
|
+
right: "│",
|
|
204
|
+
rightMid: "┤",
|
|
205
|
+
middle: "│",
|
|
206
|
+
},
|
|
207
|
+
truncate: "…",
|
|
208
|
+
colWidths: [],
|
|
209
|
+
rowHeights: [],
|
|
210
|
+
colAligns: [],
|
|
211
|
+
rowAligns: [],
|
|
212
|
+
style: {
|
|
213
|
+
"padding-left": 1,
|
|
214
|
+
"padding-right": 1,
|
|
215
|
+
head: ["red"],
|
|
216
|
+
border: ["grey"],
|
|
217
|
+
compact: false,
|
|
218
|
+
},
|
|
219
|
+
head: [],
|
|
220
|
+
wordWrap: false,
|
|
221
|
+
wrapOnWordBoundary: true,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function mergeOptions(options, defaults) {
|
|
225
|
+
const finalOptions = options || {};
|
|
226
|
+
const finalDefaults = defaults || defaultOptions();
|
|
227
|
+
const ret = Object.assign({}, finalDefaults, finalOptions);
|
|
228
|
+
ret.chars = Object.assign({}, finalDefaults.chars, finalOptions.chars);
|
|
229
|
+
ret.style = Object.assign({}, finalDefaults.style, finalOptions.style);
|
|
230
|
+
return ret;
|
|
231
|
+
}
|
|
232
|
+
// Wrap on word boundary
|
|
233
|
+
function wordWrap(maxLength, input) {
|
|
234
|
+
const lines = [];
|
|
235
|
+
const split = input.split(/(\s+)/g);
|
|
236
|
+
const line = [];
|
|
237
|
+
let lineLength = 0;
|
|
238
|
+
let whitespace = "";
|
|
239
|
+
for (let i = 0; i < split.length; i += 2) {
|
|
240
|
+
const word = split[i];
|
|
241
|
+
let newLength = lineLength + strlen(word);
|
|
242
|
+
if (lineLength > 0 && whitespace) {
|
|
243
|
+
newLength += whitespace.length;
|
|
244
|
+
}
|
|
245
|
+
if (newLength > maxLength) {
|
|
246
|
+
if (lineLength !== 0) {
|
|
247
|
+
lines.push(line.join(""));
|
|
248
|
+
}
|
|
249
|
+
line.length = 0;
|
|
250
|
+
line.push(word);
|
|
251
|
+
lineLength = strlen(word);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
line.push(whitespace || "", word);
|
|
255
|
+
lineLength = newLength;
|
|
256
|
+
}
|
|
257
|
+
whitespace = split[i + 1];
|
|
258
|
+
}
|
|
259
|
+
if (lineLength) {
|
|
260
|
+
lines.push(line.join(""));
|
|
261
|
+
}
|
|
262
|
+
return lines;
|
|
263
|
+
}
|
|
264
|
+
// Wrap text (ignoring word boundaries)
|
|
265
|
+
function textWrap(maxLength, input) {
|
|
266
|
+
const lines = [];
|
|
267
|
+
let line = "";
|
|
268
|
+
function pushLine(str, ws) {
|
|
269
|
+
if (line.length && ws)
|
|
270
|
+
line += ws;
|
|
271
|
+
line += str;
|
|
272
|
+
while (line.length > maxLength) {
|
|
273
|
+
lines.push(line.slice(0, maxLength));
|
|
274
|
+
line = line.slice(maxLength);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const split = input.split(/(\s+)/g);
|
|
278
|
+
for (let i = 0; i < split.length; i += 2) {
|
|
279
|
+
pushLine(split[i], i ? split[i - 1] : "");
|
|
280
|
+
}
|
|
281
|
+
if (line.length)
|
|
282
|
+
lines.push(line);
|
|
283
|
+
return lines;
|
|
284
|
+
}
|
|
285
|
+
export function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
|
|
286
|
+
const output = [];
|
|
287
|
+
const lines = input.split("\n");
|
|
288
|
+
const handler = wrapOnWordBoundary ? wordWrap : textWrap;
|
|
289
|
+
for (let i = 0; i < lines.length; i++) {
|
|
290
|
+
output.push(...handler(maxLength, lines[i]));
|
|
291
|
+
}
|
|
292
|
+
return output;
|
|
293
|
+
}
|
|
294
|
+
export function colorizeLines(input) {
|
|
295
|
+
let state = {};
|
|
296
|
+
const output = [];
|
|
297
|
+
for (let i = 0; i < input.length; i++) {
|
|
298
|
+
const line = rewindState(state, input[i]);
|
|
299
|
+
state = readState(line);
|
|
300
|
+
const temp = Object.assign({}, state);
|
|
301
|
+
output.push(unwindState(temp, line));
|
|
302
|
+
}
|
|
303
|
+
return output;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Credit: Matheus Sampaio https://github.com/matheussampaio
|
|
307
|
+
*/
|
|
308
|
+
export function hyperlink(url, text) {
|
|
309
|
+
const Osc = "\u001B]";
|
|
310
|
+
const Bel = "\u0007";
|
|
311
|
+
const Sep = ";";
|
|
312
|
+
return [
|
|
313
|
+
Osc,
|
|
314
|
+
"8",
|
|
315
|
+
Sep,
|
|
316
|
+
Sep,
|
|
317
|
+
url || text,
|
|
318
|
+
Bel,
|
|
319
|
+
text,
|
|
320
|
+
Osc,
|
|
321
|
+
"8",
|
|
322
|
+
Sep,
|
|
323
|
+
Sep,
|
|
324
|
+
Bel,
|
|
325
|
+
].join("");
|
|
326
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|