@@ -22,14 +22,19 @@ local utils = require("vectorcode.utils")
2222
2323--- @type VectorCode.CodeCompanion.ExtensionOpts |{}
2424local default_extension_opts = {
25+ --- @type table<sub_cmd , VectorCode.CodeCompanion.ToolOpts |{} >
2526 tool_opts = {
2627 -- NOTE: the other default opts are defined in the source code files of the tools.
2728 -- `include_in_toolbox` is here so that the extension setup works as expected.
2829 ls = { include_in_toolbox = true },
2930 query = { include_in_toolbox = true },
30- vectorise = { include_in_toolbox = true },
31+ vectorise = {
32+ requires_approval = true ,
33+ require_approval_before = true ,
34+ include_in_toolbox = true ,
35+ },
3136 files_ls = {},
32- files_rm = {},
37+ files_rm = { require_approval_before = true , requires_approval = true },
3338 },
3439 tool_group = { enabled = true , collapse = true , extras = {} },
3540 prompt_library = require (" vectorcode.integrations.codecompanion.prompts.presets" ),
@@ -64,9 +69,11 @@ local M = {
6469 local cc_config = require (" codecompanion.config" ).config
6570 local cc_integration = require (" vectorcode.integrations" ).codecompanion
6671 local cc_chat_integration = cc_integration .chat
72+
73+ local interactions = cc_config .interactions or cc_config .strategies
6774 for _ , sub_cmd in pairs (valid_tools ) do
6875 local tool_name = string.format (" vectorcode_%s" , sub_cmd )
69- if cc_config . interactions .chat .tools [tool_name ] ~= nil then
76+ if interactions .chat .tools [tool_name ] ~= nil then
7077 vim .notify (
7178 string.format (
7279 " There's an existing tool named `%s`. Please either remove it or rename it." ,
@@ -82,10 +89,23 @@ local M = {
8289 )
8390 )
8491 else
85- cc_config .interactions .chat .tools [tool_name ] = {
92+ local require_approval = opts .tool_opts [sub_cmd ].requires_approval
93+ or opts .tool_opts [sub_cmd ].require_approval_before
94+ if opts .tool_opts [sub_cmd ].requires_approval ~= nil then
95+ vim .deprecate (
96+ " requires_approval" ,
97+ " require_approval_before" ,
98+ " 1.0.0" ,
99+ " VectorCode"
100+ )
101+ end
102+ interactions .chat .tools [tool_name ] = {
86103 description = string.format (" Run VectorCode %s tool" , sub_cmd ),
87104 callback = cc_chat_integration .make_tool (sub_cmd , opts .tool_opts [sub_cmd ]),
88- opts = { requires_approval = opts .tool_opts [sub_cmd ].requires_approval },
105+ opts = {
106+ requires_approval = require_approval ,
107+ require_approval_before = require_approval ,
108+ },
89109 }
90110 logger .info (string.format (" %s tool has been created." , tool_name ))
91111 end
@@ -110,7 +130,7 @@ local M = {
110130 vim .inspect (included_tools )
111131 )
112132 )
113- cc_config . interactions .chat .tools .groups [" vectorcode_toolbox" ] = {
133+ interactions .chat .tools .groups [" vectorcode_toolbox" ] = {
114134 opts = { collapse_tools = opts .tool_group .collapse },
115135 description = " Use VectorCode to automatically build and retrieve repository-level context." ,
116136 tools = included_tools ,
0 commit comments