@@ -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" ),
5863local M = {
5964 --- @param opts VectorCode.CodeCompanion.ExtensionOpts
6065 setup = vc_config .check_cli_wrap (function (opts )
66+ if
67+ opts
68+ and opts .tool_opts
69+ and vim .iter (opts .tool_opts ):any (function (_ , v )
70+ return v .requires_approval ~= nil
71+ end )
72+ then
73+ vim .deprecate (
74+ " requires_approval" ,
75+ " require_approval_before" ,
76+ " 1.0.0" ,
77+ " VectorCode" ,
78+ false
79+ )
80+ end
6181 opts = vim .tbl_deep_extend (" force" , default_extension_opts , opts or {})
6282 opts .tool_opts = merge_tool_opts (opts .tool_opts )
6383 logger .info (" Received codecompanion extension opts:\n " , opts )
6484 local cc_config = require (" codecompanion.config" ).config
6585 local cc_integration = require (" vectorcode.integrations" ).codecompanion
6686 local cc_chat_integration = cc_integration .chat
87+
88+ local interactions = cc_config .strategies or cc_config .interactions
6789 for _ , sub_cmd in pairs (valid_tools ) do
6890 local tool_name = string.format (" vectorcode_%s" , sub_cmd )
69- if cc_config . interactions .chat .tools [tool_name ] ~= nil then
91+ if interactions .chat .tools [tool_name ] ~= nil then
7092 vim .notify (
7193 string.format (
7294 " There's an existing tool named `%s`. Please either remove it or rename it." ,
@@ -82,10 +104,16 @@ local M = {
82104 )
83105 )
84106 else
85- cc_config .interactions .chat .tools [tool_name ] = {
107+ local require_approval = opts .tool_opts [sub_cmd ].requires_approval
108+ or opts .tool_opts [sub_cmd ].require_approval_before
109+
110+ interactions .chat .tools [tool_name ] = {
86111 description = string.format (" Run VectorCode %s tool" , sub_cmd ),
87112 callback = cc_chat_integration .make_tool (sub_cmd , opts .tool_opts [sub_cmd ]),
88- opts = { requires_approval = opts .tool_opts [sub_cmd ].requires_approval },
113+ opts = {
114+ requires_approval = require_approval ,
115+ require_approval_before = require_approval ,
116+ },
89117 }
90118 logger .info (string.format (" %s tool has been created." , tool_name ))
91119 end
@@ -110,7 +138,7 @@ local M = {
110138 vim .inspect (included_tools )
111139 )
112140 )
113- cc_config . interactions .chat .tools .groups [" vectorcode_toolbox" ] = {
141+ interactions .chat .tools .groups [" vectorcode_toolbox" ] = {
114142 opts = { collapse_tools = opts .tool_group .collapse },
115143 description = " Use VectorCode to automatically build and retrieve repository-level context." ,
116144 tools = included_tools ,
0 commit comments