/** * Docs LanceDB Store Module * * Vector database wrapper using LanceDB for storing and searching documentation chunk embeddings. * This is a separate store from the code store, using a different database path and table name. * * Features: * - Vector similarity search with configurable top-k results * - Batch insert for efficient indexing * - Delete by file path for incremental updates * - Path pattern matching for file-based queries * - Stale lockfile detection and cleanup * * Storage path: ~/.mcp/search/indexes//docs.lancedb/ * Table name: project_docs_prose */ import { ChunkRecord, SearchResult } from './lancedb.js'; import { getDocsLanceDbPath } from '../utils/paths.js'; /** Name of the table storing documentation chunks */ declare const DOCS_TABLE_NAME = "project_docs_prose"; /** * LanceDB Store wrapper for documentation vector search operations * * Provides a high-level interface for storing and searching documentation chunk embeddings. * Uses a separate database path (docs.lancedb/) and table (project_docs_prose) from the code store. * Supports configurable vector dimensions for dual-model embeddings: * - Default: 384 (CODE_VECTOR_DIMENSION) for backward compatibility with current EmbeddingEngine * - Future: 768 (DOCS_VECTOR_DIMENSION) when using docs-specific embedding model (SMCP-074) * * @example * ```typescript * // Use default dimension (384 for backward compatibility) * const store = new DocsLanceDBStore('/path/to/index'); * await store.open(); * * // Or specify 768 dimensions for docs embedding model * const docsStore = new DocsLanceDBStore('/path/to/index', DOCS_VECTOR_DIMENSION); * * // Insert chunks * await store.insertChunks(chunks); * * // Search * const results = await store.search(queryVector, 10); * * await store.close(); * ``` */ export declare class DocsLanceDBStore { private indexPath; private dbPath; private db; private table; private isOpen; /** The vector dimension for this store */ private readonly vectorDimension; /** Mutex for protecting concurrent database operations */ private readonly mutex; /** Reference to cleanup handler for unregistration */ private cleanupHandler; /** * Create a new DocsLanceDBStore instance * * @param indexPath - Path to the index directory (e.g., ~/.mcp/search/indexes/) * @param vectorDimension - Dimension of embedding vectors (defaults to CODE_VECTOR_DIMENSION = 384 for backward compatibility) * Set to DOCS_VECTOR_DIMENSION (768) when using the docs embedding model (SMCP-074) */ constructor(indexPath: string, vectorDimension?: number); /** * Get the vector dimension for this store * @returns The dimension of embedding vectors used by this store */ getVectorDimension(): number; /** * Open the database connection * * Creates the database directory if it doesn't exist. * Cleans up any stale lockfiles before connecting. * Creates the table with correct schema if it doesn't exist. */ open(): Promise; /** * Close the database connection * * Safe to call multiple times - will be a no-op if already closed. */ close(): Promise; /** * Delete the entire database * * Removes all data and the database directory. * The store will be closed after this operation. */ delete(): Promise; /** * Ensure the database is open */ private ensureOpen; /** * Ensure the table exists, creating it if necessary with initial data */ private ensureTable; /** * Get the table, throwing if it doesn't exist */ private getTable; /** * Insert chunks into the database * * Handles large batches efficiently by splitting into smaller batches. * Creates the table on first insert if it doesn't exist. * Protected by mutex to prevent concurrent write operations. * * @param chunks - Array of chunk records to insert */ insertChunks(chunks: ChunkRecord[]): Promise; /** * Internal method to insert chunks in batches */ private insertChunksInternal; /** * Delete all chunks for a given file path * Protected by mutex to prevent concurrent write operations. * * @param relativePath - Relative path of the file (forward-slash separated) * @returns Number of chunks deleted */ deleteByPath(relativePath: string): Promise; /** * Get list of all indexed file paths * Protected by mutex to ensure consistent reads during concurrent operations. * Uses limit to avoid unbounded memory usage (Bug #11). * * @param limit - Maximum number of unique paths to return (default: 10000) * @returns Array of unique file paths */ getIndexedFiles(limit?: number): Promise; /** * Count total number of chunks in the database * * @returns Total chunk count */ countChunks(): Promise; /** * Count number of unique indexed files * * @returns Number of unique files */ countFiles(): Promise; /** * Perform vector similarity search * Protected by mutex to prevent reads during concurrent write operations. * * @param queryVector - Query embedding vector (768 dimensions for docs) * @param topK - Maximum number of results to return (default: 10) * @returns Search results sorted by similarity score (descending) */ search(queryVector: number[], topK?: number): Promise; /** * Search for files matching a glob pattern * Protected by mutex to ensure consistent reads during concurrent operations. * * @param pattern - Glob pattern (e.g., "*.md", "docs/*.md") * @param limit - Maximum number of results (default: 20) * @returns Array of matching file paths */ searchByPath(pattern: string, limit?: number): Promise; /** * Get the storage size of the database in bytes * * Uses async file operations to avoid blocking the event loop. * * @returns Size in bytes */ getStorageSize(): Promise; /** * Check if the store has been opened */ get opened(): boolean; /** * Check if the table exists and has data */ hasData(): Promise; } export { DOCS_TABLE_NAME, getDocsLanceDbPath }; //# sourceMappingURL=docsLancedb.d.ts.map