| 396 | } |
| 397 | |
| 398 | function computeCombinedScore(semanticScore: number, keywordScore: number, options: ResolvedSearchQueryOptions): number { |
| 399 | const semanticComponent = Math.max(semanticScore, 0); |
| 400 | const totalWeight = options.semanticWeight + options.keywordWeight; |
| 401 | if (totalWeight <= 0) return semanticComponent; |
| 402 | return clamp01((options.semanticWeight * semanticComponent + options.keywordWeight * keywordScore) / totalWeight); |
| 403 | } |
| 404 | |
| 405 | async function loadCache(rootDir: string): Promise<EmbeddingCache> { |
| 406 | return loadEmbeddingCache(rootDir, CACHE_FILE); |