refactor: rename run_command llm tool to bash (#1428)

This commit is contained in:
yetone
2025-02-28 14:50:41 +08:00
committed by GitHub
parent ae8497faf1
commit 6d24da510e
2 changed files with 5 additions and 9 deletions

View File

@@ -388,10 +388,6 @@ M._defaults = {
--- Disable by setting to -1. --- Disable by setting to -1.
override_timeoutlen = 500, override_timeoutlen = 500,
}, },
run_command = {
-- Only applies to macOS and Linux
shell_cmd = "sh -c",
},
--- @class AvanteHintsConfig --- @class AvanteHintsConfig
hints = { hints = {
enabled = true, enabled = true,

View File

@@ -238,7 +238,7 @@ function M.delete_dir(opts, on_log)
end end
---@type AvanteLLMToolFunc<{ rel_path: string, command: string }> ---@type AvanteLLMToolFunc<{ rel_path: string, command: string }>
function M.run_command(opts, on_log, on_complete) function M.bash(opts, on_log, on_complete)
local abs_path = get_abs_path(opts.rel_path) local abs_path = get_abs_path(opts.rel_path)
if not has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end if not has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end
if not Path:new(abs_path):exists() then return false, "Path not found: " .. abs_path end if not Path:new(abs_path):exists() then return false, "Path not found: " .. abs_path end
@@ -264,13 +264,13 @@ function M.run_command(opts, on_log, on_complete)
return output, nil return output, nil
end end
if on_complete then if on_complete then
Utils.shell_run_async(opts.command, Config.run_command.shell_cmd, function(output, exit_code) Utils.shell_run_async(opts.command, "bash -c", function(output, exit_code)
local result, err = handle_result(output, exit_code) local result, err = handle_result(output, exit_code)
on_complete(result, err) on_complete(result, err)
end) end)
return nil, nil return nil, nil
end end
local res = Utils.shell_run(opts.command, Config.run_command.shell_cmd) local res = Utils.shell_run(opts.command, "bash -c")
return handle_result(res.stdout, res.code) return handle_result(res.stdout, res.code)
end end
@@ -1024,8 +1024,8 @@ M._tools = {
}, },
}, },
{ {
name = "run_command", name = "bash",
description = "Run a command in a directory", description = "Run a bash command in a directory",
param = { param = {
type = "table", type = "table",
fields = { fields = {