(files: RankedFile[])
| 376 | |
| 377 | /** Render the ranked files as a system-prompt context block (empty string if none). */ |
| 378 | export function formatRetrievalBlock(files: RankedFile[]): string { |
| 379 | if (files.length === 0) return ''; |
| 380 | const lines: string[] = []; |
| 381 | lines.push('# Likely-relevant files (auto-retrieved by semantic similarity + import-graph)'); |
| 382 | lines.push('Ranked by meaning, then widened along import edges so dependencies (state/db/types) of the top matches are included. Files marked "import-neighbor" are related via imports, not direct matches. Read the top ones with read_file before searching blindly.'); |
| 383 | lines.push(''); |
| 384 | for (const f of files) { |
| 385 | const tag = f.bestLines === 'import-neighbor' ? 'import-neighbor' : `lines ${f.bestLines}, similarity ${f.score.toFixed(3)}`; |
| 386 | lines.push(`- ${f.file} (${tag})`); |
| 387 | } |
| 388 | return lines.join('\n'); |
| 389 | } |
| 390 | |
| 391 | async function ollamaReachable(baseUrl: string, signal?: AbortSignal): Promise<boolean> { |
| 392 | try { |
no test coverage detected