feat: extract str_replace tool (#1710)

This commit is contained in:
yetone
2025-03-25 18:43:57 +08:00
committed by GitHub
parent 8c4244b940
commit a2aec079c9
7 changed files with 186 additions and 125 deletions

View File

@@ -75,6 +75,7 @@ M.returns = {
---@type AvanteLLMToolFunc<{ path: string, view_range?: { start_line: integer, end_line: integer } }>
function M.func(opts, on_log, on_complete, session_ctx)
if not on_complete then return false, "on_complete not provided" end
if on_log then on_log("path: " .. opts.path) end
if Helpers.already_in_context(opts.path) then
on_complete(nil, "Ooooops! This file is already in the context! Why you are trying to read it again?")
return
@@ -91,7 +92,6 @@ function M.func(opts, on_log, on_complete, session_ctx)
end
local abs_path = Helpers.get_abs_path(opts.path)
if not Helpers.has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end
if on_log then on_log("path: " .. abs_path) end
if not Path:new(abs_path):exists() then return false, "Path not found: " .. abs_path end
if Path:new(abs_path):is_dir() then
local files = vim.fn.glob(abs_path .. "/*", false, true)