22
33local cc_common = require (" vectorcode.integrations.codecompanion.common" )
44local vc_config = require (" vectorcode.config" )
5+ local utils = require (" vectorcode.utils" )
56
67local default_opts = {
78 use_lsp = vc_config .get_user_config ().async_backend == " lsp" ,
@@ -57,10 +58,10 @@ The value should be one of the following:
5758 --- @return nil |{ status : string , data : string }
5859 function (tools , action , _ , cb )
5960 local args = { " files" , " rm" , " --pipe" }
61+ action = utils .fix_nil (action )
6062 if action .project_root then
6163 local project_root = vim .fs .abspath (vim .fs .normalize (action .project_root ))
62- local stat = vim .uv .fs_stat (project_root )
63- if stat and stat .type == " directory" then
64+ if utils .is_directory (project_root ) then
6465 vim .list_extend (args , { " --project_root" , project_root })
6566 else
6667 return { status = " error" , data = " Invalid path " .. project_root }
@@ -76,12 +77,7 @@ The value should be one of the following:
7677 :filter (
7778 --- @param item string
7879 function (item )
79- local stat = vim .uv .fs_stat (item )
80- if stat and stat .type == " file" then
81- return true
82- else
83- return false
84- end
80+ return utils .is_file (item )
8581 end
8682 )
8783 :totable ()
@@ -90,7 +86,7 @@ The value should be one of the following:
9086 args ,
9187 --- @param result VectoriseResult
9288 function (result , error , code , _ )
93- if result then
89+ if code == 0 then
9490 cb ({ status = " success" , data = result })
9591 else
9692 cb ({ status = " error" , data = { error = error , code = code } })
0 commit comments