forked from Davidyz/VectorCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
59 lines (56 loc) · 1.91 KB
/
Copy pathinit.lua
File metadata and controls
59 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---@module "codecompanion"
local vc_config = require("vectorcode.config")
local check_cli_wrap = vc_config.check_cli_wrap
return {
chat = {
---@param component_cb (fun(result:VectorCode.QueryResult):string)?
make_slash_command = check_cli_wrap(function(component_cb)
vim.deprecate(
"vectorcode slash command",
"vectorcode tool/extension",
"0.8.0",
"VectorCode",
true
)
return {
description = "Add relevant files from the codebase.",
---@param chat CodeCompanion.Chat
callback = function(chat)
local codebase_prompt = ""
local vc_cache = vc_config.get_cacher_backend()
local bufnr = chat.context.bufnr
if not vc_cache.buf_is_registered(bufnr) then
return
end
codebase_prompt =
"The following are relevant files from the repository. Use them as extra context."
local query_result = vc_cache.make_prompt_component(bufnr, component_cb)
local id = tostring(query_result.count) .. " file(s) from codebase"
codebase_prompt = codebase_prompt .. query_result.content
chat:add_message(
{ content = codebase_prompt, role = "user" },
{ visible = false, id = id }
)
chat.references:add({
source = "VectorCode",
name = "VectorCode",
id = id,
})
end,
}
end),
---@param subcommand sub_cmd
---@param opts VectorCode.CodeCompanion.ToolOpts
---@return CodeCompanion.Agent.Tool
make_tool = function(subcommand, opts)
local has = require("codecompanion").has
if has ~= nil and has("function-calling") then
return require(
string.format("vectorcode.integrations.codecompanion.%s_tool", subcommand)
)(opts)
else
error("Unsupported version of codecompanion!")
end
end,
},
}