(allFilePaths: string[])
| 410 | * @internal Exported for testing |
| 411 | */ |
| 412 | export 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. |
no test coverage detected