initial change to tools logic
This commit is contained in:
17
lua/chatgpt_nvim/tools/execute_command.lua
Normal file
17
lua/chatgpt_nvim/tools/execute_command.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local M = {}
|
||||
|
||||
M.run = function(tool_call, conf, prompt_user_tool_accept, is_subpath, read_file)
|
||||
local cmd = tool_call.command
|
||||
if not cmd then
|
||||
return "[executeCommand] Missing 'command'."
|
||||
end
|
||||
local handle = io.popen(cmd)
|
||||
if not handle then
|
||||
return string.format("Tool [executeCommand '%s'] FAILED to popen.", cmd)
|
||||
end
|
||||
local result = handle:read("*a") or ""
|
||||
handle:close()
|
||||
return string.format("Tool [executeCommand '%s'] Result:\n%s", cmd, result)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user