@@ -156,26 +156,26 @@ local process_result = function(result)
156156end
157157
158158--- @alias chat_id integer
159- --- @alias result_id string
160- --- @type <chat_id : result_id >
159+ --- @alias results table< string,boolean>
160+ --- @type table <chat_id, results >
161161local result_tracker = {}
162162
163163--- @param results VectorCode.QueryResult[]
164164--- @param chat CodeCompanion.Chat
165165--- @return VectorCode.QueryResult[]
166166local filter_results = function (results , chat )
167- local existing_refs = chat .refs or {}
167+ local existing_refs = chat .context_items or chat . refs or {}
168168
169169 existing_refs = vim
170170 .iter (existing_refs )
171171 :filter (
172- --- @param ref CodeCompanion.Chat.Ref
172+ --- @param ref CodeCompanion.Chat.ContextItem
173173 function (ref )
174174 return ref .source == cc_common .tool_result_source or ref .path or ref .bufnr
175175 end
176176 )
177177 :map (
178- --- @param ref CodeCompanion.Chat.Ref
178+ --- @param ref CodeCompanion.Chat.ContextItem
179179 function (ref )
180180 if ref .source == cc_common .tool_result_source then
181181 return ref .id
@@ -345,6 +345,7 @@ return check_cli_wrap(function(opts)
345345 " CodeCompanion query tool called with the following arguments:\n " ,
346346 action
347347 )
348+
348349 job_runner = cc_common .initialise_runner (opts .use_lsp )
349350 assert (job_runner ~= nil , " Jobrunner not initialised!" )
350351 assert (
@@ -386,10 +387,12 @@ return check_cli_wrap(function(opts)
386387 end
387388 end
388389
389- if opts .no_duplicate and agent .chat .refs ~= nil and action .deduplicate then
390+ -- TODO: remove the `chat.refs` compatibility code when the upstream PR is released.
391+ local context_items = agent .chat .context_items or agent .chat .refs
392+ if opts .no_duplicate and context_items ~= nil and action .deduplicate then
390393 -- exclude files that has been added to the context
391394 local existing_files = { " --exclude" }
392- for _ , ref in pairs (agent . chat . refs ) do
395+ for _ , ref in pairs (context_items ) do
393396 if ref .source == cc_common .tool_result_source then
394397 table.insert (existing_files , ref .id )
395398 elseif type (ref .path ) == " string" then
@@ -594,9 +597,10 @@ DO NOT MODIFY UNLESS INSTRUCTED BY THE USER, OR A PREVIOUS QUERY RETURNED NO RES
594597 string.format (" **VectorCode Tool**: Retrieved %d %s(s)" , stdout .count , mode )
595598 )
596599 if not opts .chunk_mode then
600+ local context = agent .chat .context or agent .chat .references
597601 for _ , result in pairs (stdout .raw_results ) do
598602 -- skip referencing because there will be multiple chunks with the same path (id).
599- agent . chat . references :add ({
603+ context :add ({
600604 source = cc_common .tool_result_source ,
601605 id = result .path ,
602606 path = result .path ,
0 commit comments