MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / aggregateToFiles

Function aggregateToFiles

src/context/retrieval.ts:325–337  ·  view source on GitHub ↗
(scored: ScoredChunk[], maxFiles: number)

Source from the content-addressed store, hash-verified

323 * at files is more useful to the model than pointing at arbitrary 30-line windows.
324 */
325export function aggregateToFiles(scored: ScoredChunk[], maxFiles: number): RankedFile[] {
326 const best = new Map<string, { score: number; startLine: number; endLine: number; text: string }>();
327 for (const { chunk, score } of scored) {
328 const cur = best.get(chunk.file);
329 if (!cur || score > cur.score) {
330 best.set(chunk.file, { score, startLine: chunk.startLine, endLine: chunk.endLine, text: chunk.text });
331 }
332 }
333 return [...best.entries()]
334 .map(([file, v]) => ({ file, score: v.score, bestLines: `${v.startLine}-${v.endLine}`, text: v.text }))
335 .sort((a, b) => b.score - a.score)
336 .slice(0, maxFiles);
337}
338
339/**
340 * Expand a ranked file list with import-graph neighbors of the top hits, so the

Callers 3

retrieval.test.tsFile · 0.85
retrieveRelevantFilesFunction · 0.85

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected