Skip to content

Commit 62bef8e

Browse files
author
Zhe Yu
committed
feat(nvim): show vectorise stats for the vectorise tool
1 parent f584643 commit 62bef8e

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

lua/vectorcode/integrations/codecompanion/ls_tool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ return function(opts)
1717
name = tool_name,
1818
cmds = {
1919
---@param agent CodeCompanion.Agent
20-
---@return nil|{ status: string, msg: string }
20+
---@return nil|{ status: string, data: string }
2121
function(agent, _, _, cb)
2222
job_runner.run_async({ "ls", "--pipe" }, function(result, error)
2323
if vim.islist(result) and #result > 0 then

lua/vectorcode/integrations/codecompanion/query_tool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ return check_cli_wrap(function(opts)
3737
cmds = {
3838
---@param agent CodeCompanion.Agent
3939
---@param action QueryToolArgs
40-
---@return nil|{ status: string, msg: string }
40+
---@return nil|{ status: string, data: string }
4141
function(agent, action, _, cb)
4242
logger.info(
4343
"CodeCompanion query tool called with the following arguments:\n",

lua/vectorcode/integrations/codecompanion/vectorise_tool.lua

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ return function(opts)
4747
cmds = {
4848
---@param agent CodeCompanion.Agent
4949
---@param action VectoriseToolArgs
50-
---@return nil|{ status: string, msg: string }
50+
---@return nil|{ status: string, data: string }
5151
function(agent, action, _, cb)
5252
local args = { "vectorise", "--pipe" }
5353
local project_root = action.project_root or ""
@@ -78,7 +78,6 @@ return function(opts)
7878
args,
7979
---@param result VectoriseResult
8080
function(result, error, code, _)
81-
vim.schedule_wrap(vim.notify)(vim.inspect(result))
8281
if result then
8382
cb({ status = "success", data = result })
8483
else
@@ -89,5 +88,30 @@ return function(opts)
8988
)
9089
end,
9190
},
91+
output = {
92+
---@param self CodeCompanion.Agent.Tool
93+
---@param agent CodeCompanion.Agent
94+
---@param stdout VectorCode.VectoriseResult[]
95+
success = function(self, agent, _, stdout)
96+
stdout = stdout[1]
97+
agent.chat:add_tool_output(
98+
self,
99+
string.format(
100+
[[**VectorCode Vectorise Tool**:
101+
- Added: %d
102+
- Updated: %d
103+
- Removed: %d
104+
- Skipped: %d
105+
- Failed: %d
106+
]],
107+
stdout.add,
108+
stdout.update,
109+
stdout.removed,
110+
stdout.skipped,
111+
stdout.failed
112+
)
113+
)
114+
end,
115+
},
92116
}
93117
end

lua/vectorcode/types.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
---@class VectorCode.LsResult
1010
---@field project-root string
1111

12+
---@class VectorCode.VectoriseResult
13+
---@field add integer
14+
---@field update integer
15+
---@field removed integer
16+
---@field skipped integer
17+
---@field failed integer
18+
1219
---Type definitions for the cache of a buffer.
1320
---@class VectorCode.Cache
1421
---@field enabled boolean Whether the async jobs are enabled or not. If the buffer is disabled, no cache will be generated for it.

0 commit comments

Comments
 (0)