feat: remove unneeded debug command approach
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
local tools_module = require("chatgpt_nvim.tools")
|
||||
local uv = vim.loop
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Simple destructive command check
|
||||
local function is_destructive_command(cmd)
|
||||
if not cmd then return false end
|
||||
local destructive_list = { "rm", "sudo", "mv", "cp" }
|
||||
@@ -14,7 +13,6 @@ local function is_destructive_command(cmd)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Prompt user if not auto-accepted or if command is destructive
|
||||
local function prompt_user_tool_accept(tool_call, conf)
|
||||
local function ask_user(msg)
|
||||
vim.api.nvim_out_write(msg .. " [y/N]: ")
|
||||
@@ -39,11 +37,9 @@ local function prompt_user_tool_accept(tool_call, conf)
|
||||
end
|
||||
end
|
||||
|
||||
-- We'll pass references to `read_file` from init.
|
||||
local function handle_tool_calls(tools, conf, is_subpath_fn, read_file_fn)
|
||||
local messages = {}
|
||||
for _, call in ipairs(tools) do
|
||||
-- Prompt user acceptance
|
||||
local accepted = prompt_user_tool_accept(call, conf)
|
||||
if not accepted then
|
||||
table.insert(messages, string.format("Tool [%s] was rejected by user.", call.tool or "nil"))
|
||||
@@ -58,7 +54,12 @@ local function handle_tool_calls(tools, conf, is_subpath_fn, read_file_fn)
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(messages, "\n\n")
|
||||
local combined = table.concat(messages, "\n\n")
|
||||
local limit = conf.prompt_char_limit or 8000
|
||||
if #combined > limit then
|
||||
return "The combined tool output is too large ("..#combined.."). Please break down the operations into smaller steps."
|
||||
end
|
||||
return combined
|
||||
end
|
||||
|
||||
M.handle_tool_calls = handle_tool_calls
|
||||
|
||||
Reference in New Issue
Block a user