diff --git a/lua/codecompanion/_extensions/vectorcode/init.lua b/lua/codecompanion/_extensions/vectorcode/init.lua index dd834b29..68c19236 100644 --- a/lua/codecompanion/_extensions/vectorcode/init.lua +++ b/lua/codecompanion/_extensions/vectorcode/init.lua @@ -14,7 +14,7 @@ local logger = vc_config.logger ---@type VectorCode.CodeCompanion.ExtensionOpts|{} local default_extension_opts = { - tool_opts = { ls = {}, query = {}, vectorise = {} }, + tool_opts = { ls = {}, query = {}, vectorise = { requires_approval = true } }, tool_group = { enabled = true, collapse = true, extras = {} }, } @@ -50,6 +50,7 @@ local M = { cc_config.strategies.chat.tools[tool_name] = { description = string.format("Run VectorCode %s tool", sub_cmd), callback = cc_integration.make_tool(sub_cmd, opts.tool_opts[sub_cmd]), + opts = { requires_approval = opts.tool_opts[sub_cmd].requires_approval }, } logger.info(string.format("%s tool has been created.", tool_name)) end diff --git a/lua/vectorcode/integrations/codecompanion/query_tool.lua b/lua/vectorcode/integrations/codecompanion/query_tool.lua index f02de129..03ac3ff8 100644 --- a/lua/vectorcode/integrations/codecompanion/query_tool.lua +++ b/lua/vectorcode/integrations/codecompanion/query_tool.lua @@ -160,7 +160,7 @@ For example, you should include `parameter`, `arguments` and `return value` for }, project_root = { type = "string", - description = "Project path to search within (must be from 'ls' results or user instructions). Use empty string for the current project.", + description = "Project path to search within (must be from 'ls' results or user instructions). Use empty string for the current project. If the user did not specify a project, assume that they're referring to the current project and use an empty string for this parameter. If this fails, use the `vectorcode_ls` tool and ask the user to clarify the project.", }, }, required = { "query", "count", "project_root" }, diff --git a/lua/vectorcode/integrations/codecompanion/vectorise_tool.lua b/lua/vectorcode/integrations/codecompanion/vectorise_tool.lua index 7cb15953..0bea4d8b 100644 --- a/lua/vectorcode/integrations/codecompanion/vectorise_tool.lua +++ b/lua/vectorcode/integrations/codecompanion/vectorise_tool.lua @@ -35,7 +35,7 @@ return function(opts) }, project_root = { type = "string", - description = "The project that the files belong to. Either use a path from the `vectorcode_ls` tool, or leave empty to use the current git project.", + description = "The project that the files belong to. Either use a path from the `vectorcode_ls` tool, or leave empty to use the current git project. If the user did not specify a path, use empty string for this parameter.", }, }, required = { "paths", "project_root" }, @@ -99,6 +99,10 @@ return function(opts) end, }, output = { + ---@param self CodeCompanion.Agent.Tool + prompt = function(self, _) + return string.format("Vectorise %d files with VectorCode?", #self.args.paths) + end, ---@param self CodeCompanion.Agent.Tool ---@param agent CodeCompanion.Agent ---@param stdout VectorCode.VectoriseResult[] diff --git a/lua/vectorcode/types.lua b/lua/vectorcode/types.lua index c53c62d4..7421a343 100644 --- a/lua/vectorcode/types.lua +++ b/lua/vectorcode/types.lua @@ -71,6 +71,7 @@ ---@class VectorCode.CodeCompanion.ToolOpts --- Whether to use the LSP backend. Default: `false` ---@field use_lsp boolean? +---@field requires_approval boolean? ---@class VectorCode.CodeCompanion.LsToolOpts: VectorCode.CodeCompanion.ToolOpts