From b6000d5bbcb85e3b11177846220bfd438fc013dd Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 28 Mar 2025 00:31:57 +0800 Subject: [PATCH] fix: selectively enable text editor tool (#1747) --- lua/avante/llm_tools/create.lua | 2 ++ lua/avante/llm_tools/insert.lua | 2 ++ lua/avante/llm_tools/str_replace.lua | 2 ++ lua/avante/llm_tools/undo_edit.lua | 2 ++ 4 files changed, 8 insertions(+) diff --git a/lua/avante/llm_tools/create.lua b/lua/avante/llm_tools/create.lua index 7ad274d..8e4e0e5 100644 --- a/lua/avante/llm_tools/create.lua +++ b/lua/avante/llm_tools/create.lua @@ -10,6 +10,8 @@ M.name = "create" M.description = "The create tool allows you to create a new file with specified content." +function M.enabled() return require("avante.config").behaviour.enable_claude_text_editor_tool_mode end + ---@type AvanteLLMToolParam M.param = { type = "table", diff --git a/lua/avante/llm_tools/insert.lua b/lua/avante/llm_tools/insert.lua index 2080009..45af507 100644 --- a/lua/avante/llm_tools/insert.lua +++ b/lua/avante/llm_tools/insert.lua @@ -10,6 +10,8 @@ M.name = "insert" M.description = "The insert tool allows you to insert text at a specific location in a file." +function M.enabled() return require("avante.config").behaviour.enable_claude_text_editor_tool_mode end + ---@type AvanteLLMToolParam M.param = { type = "table", diff --git a/lua/avante/llm_tools/str_replace.lua b/lua/avante/llm_tools/str_replace.lua index 5c3f336..f029b71 100644 --- a/lua/avante/llm_tools/str_replace.lua +++ b/lua/avante/llm_tools/str_replace.lua @@ -12,6 +12,8 @@ M.name = "str_replace" M.description = "The str_replace tool allows you to replace a specific string in a file with a new string. This is used for making precise edits." +function M.enabled() return require("avante.config").behaviour.enable_claude_text_editor_tool_mode end + ---@type AvanteLLMToolParam M.param = { type = "table", diff --git a/lua/avante/llm_tools/undo_edit.lua b/lua/avante/llm_tools/undo_edit.lua index cbcbb47..1502ebb 100644 --- a/lua/avante/llm_tools/undo_edit.lua +++ b/lua/avante/llm_tools/undo_edit.lua @@ -10,6 +10,8 @@ M.name = "undo_edit" M.description = "The undo_edit tool allows you to revert the last edit made to a file." +function M.enabled() return require("avante.config").behaviour.enable_claude_text_editor_tool_mode end + ---@type AvanteLLMToolParam M.param = { type = "table",