Skip to content

Commit 0ed0e2b

Browse files
Zhe YuDavidyz
authored andcommitted
fix(nvim): Improve VectorCode tool prompts and add approval option
1 parent fae0bf3 commit 0ed0e2b

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

lua/codecompanion/_extensions/vectorcode/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local logger = vc_config.logger
1414

1515
---@type VectorCode.CodeCompanion.ExtensionOpts|{}
1616
local default_extension_opts = {
17-
tool_opts = { ls = {}, query = {}, vectorise = {} },
17+
tool_opts = { ls = {}, query = {}, vectorise = { requires_approval = true } },
1818
tool_group = { enabled = true, collapse = true, extras = {} },
1919
}
2020

@@ -50,6 +50,7 @@ local M = {
5050
cc_config.strategies.chat.tools[tool_name] = {
5151
description = string.format("Run VectorCode %s tool", sub_cmd),
5252
callback = cc_integration.make_tool(sub_cmd, opts.tool_opts[sub_cmd]),
53+
opts = { requires_approval = opts.tool_opts[sub_cmd].requires_approval },
5354
}
5455
logger.info(string.format("%s tool has been created.", tool_name))
5556
end

lua/vectorcode/integrations/codecompanion/query_tool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ For example, you should include `parameter`, `arguments` and `return value` for
160160
},
161161
project_root = {
162162
type = "string",
163-
description = "Project path to search within (must be from 'ls' results or user instructions). Use empty string for the current project.",
163+
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.",
164164
},
165165
},
166166
required = { "query", "count", "project_root" },

lua/vectorcode/integrations/codecompanion/vectorise_tool.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ return function(opts)
3535
},
3636
project_root = {
3737
type = "string",
38-
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.",
38+
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.",
3939
},
4040
},
4141
required = { "paths", "project_root" },
@@ -99,6 +99,10 @@ return function(opts)
9999
end,
100100
},
101101
output = {
102+
---@param self CodeCompanion.Agent.Tool
103+
prompt = function(self, _)
104+
return string.format("Vectorise %d files with VectorCode?", #self.args.paths)
105+
end,
102106
---@param self CodeCompanion.Agent.Tool
103107
---@param agent CodeCompanion.Agent
104108
---@param stdout VectorCode.VectoriseResult[]

lua/vectorcode/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
---@class VectorCode.CodeCompanion.ToolOpts
7272
--- Whether to use the LSP backend. Default: `false`
7373
---@field use_lsp boolean?
74+
---@field requires_approval boolean?
7475

7576
---@class VectorCode.CodeCompanion.LsToolOpts: VectorCode.CodeCompanion.ToolOpts
7677

0 commit comments

Comments
 (0)