import type { CodeChunk } from "../chunk/types.ts"; export interface SearchResult { chunkKey: string; filePath: string; name: string; kind: string; signature: string; snippet: string; startLine: number; endLine: number; score: number; } export interface IndexedFile { filePath: string; fileHash: string; chunkCount: number; indexedAt: number; } export interface Codebase { id: number; rootPath: string; name: string; indexedAt: number; fileCount: number; chunkCount: number; } export declare class Store { private db; private initialized; private constructor(); static open(dbPath: string): Promise; private init; /** Get or create a codebase entry, returns its id */ getOrCreateCodebase(rootPath: string, name?: string): Promise; /** List all codebases */ listCodebases(): Promise; /** Update codebase indexed_at timestamp */ touchCodebase(codebaseId: number): Promise; /** Get stored file hash, or null if not indexed */ getFileHash(codebaseId: number, filePath: string): Promise; /** Batch insert chunks for multiple files in one transaction */ batchUpsertAllFileChunks(codebaseId: number, fileChunks: { filePath: string; fileHash: string; chunks: CodeChunk[]; }[]): Promise; /** Remove all chunks and file records for a codebase */ removeCodebaseChunks(codebaseId: number): Promise; /** Remove files that are no longer on disk (scoped to codebase) */ removeStaleFiles(codebaseId: number, activeFiles: Set): Promise; /** Batch store embeddings */ batchUpsertEmbeddings(items: { chunkKey: string; embedding: number[]; modelName: string; }[]): Promise; countStaleEmbeddings(codebaseId: number, modelName: string): Promise; /** Get chunks that need (re-)embedding (scoped to codebase) */ getStaleEmbeddings(codebaseId: number, modelName: string, limit?: number): Promise<{ chunkKey: string; name: string; signature: string; filePath: string; kind: string; snippet: string; }[]>; /** Drop FTS table for a codebase if it doesn't exist yet (idempotent) */ ensureFtsTable(codebaseId: number): Promise; /** Insert FTS entries for all chunks belonging to the given file paths */ populateFtsForFiles(codebaseId: number, filePaths: string[]): Promise; /** Optimize the FTS index (call once after a batch of changes) */ optimizeFts(codebaseId: number): Promise; /** Vector search across all codebases (global) */ vectorSearch(queryEmbedding: number[], limit: number, includeSnippet: boolean): Promise; /** FTS search across all codebases (queries each FTS table, merges results) */ ftsSearch(query: string, limit: number, includeSnippet: boolean): Promise; /** Count chunks that have embeddings (i.e., are searchable) */ countEmbeddedChunks(): Promise; /** List all indexed files (optionally scoped to codebase) */ listFiles(codebaseId?: number): Promise; close(): void; }