MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / selectKnowledgeFilePaths

Function selectKnowledgeFilePaths

sdk/src/run-state.ts:412–436  ·  view source on GitHub ↗
(allFilePaths: string[])

Source from the content-addressed store, hash-verified

410 * @internal Exported for testing
411 */
412export function selectKnowledgeFilePaths(allFilePaths: string[]): string[] {
413 const knowledgeCandidates = allFilePaths.filter(isKnowledgeFile)
414
415 // Group candidates by directory
416 const byDirectory = new Map<string, string[]>()
417 for (const filePath of knowledgeCandidates) {
418 const dir = path.dirname(filePath)
419 if (!byDirectory.has(dir)) {
420 byDirectory.set(dir, [])
421 }
422 byDirectory.get(dir)!.push(filePath)
423 }
424
425 const selectedFiles: string[] = []
426
427 // For each directory, select one knowledge file using priority fallback
428 for (const files of byDirectory.values()) {
429 const selected = selectHighestPriorityKnowledgeFile(files)
430 if (selected) {
431 selectedFiles.push(selected)
432 }
433 }
434
435 return selectedFiles
436}
437
438/**
439 * Auto-derives knowledge files from project files if knowledgeFiles is undefined.

Callers 3

deriveKnowledgeFilesFunction · 0.85

Calls 3

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected