From 99259efc4b27325efc82890ebc40fb31eb0b7059 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Sun, 23 Nov 2025 07:52:40 -0600 Subject: [PATCH] Fix document path lookup in get_babylon_doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed pathToDocId to properly match document IDs generated during indexing. Problem: - During indexing, doc IDs are generated as: Documentation_content_ - During retrieval, pathToDocId was not prepending the prefix - This caused get_babylon_doc to fail with "Document not found" errors Solution: - Updated pathToDocId to prepend "Documentation_content_" prefix - Now handles paths with or without "content/" correctly - Matches the ID format used during indexing Example: - User provides: "features/featuresDeepDive/audio/v2/migrateFromV1" - Now correctly converts to: "Documentation_content_features_featuresDeepDive_audio_v2_migrateFromV1" All 152 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/search/lancedb-search.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/search/lancedb-search.ts b/src/search/lancedb-search.ts index 41cfee3..614060a 100644 --- a/src/search/lancedb-search.ts +++ b/src/search/lancedb-search.ts @@ -197,10 +197,16 @@ export class LanceDBSearch { } private pathToDocId(filePath: string): string { - return filePath - .replace(/^.*\/content\//, '') - .replace(/\.md$/, '') - .replace(/\//g, '_'); + // Remove .md extension if present + let normalizedPath = filePath.replace(/\.md$/, ''); + + // If path already starts with content/, strip everything before it + normalizedPath = normalizedPath.replace(/^.*\/content\//, ''); + + // If path doesn't have content/ prefix, assume it's relative to content/ + // and prepend Documentation_content_ to match indexing + const pathWithUnderscores = normalizedPath.replace(/\//g, '_'); + return `Documentation_content_${pathWithUnderscores}`; } async searchSourceCode(