/** * SQLite-based persistent index for codebase data. * Uses sql.js (WASM) — zero native compilation, works everywhere. * Drop-in replacement for JsonStore with dramatically faster queries at scale. * * Storage: .codedev-mcp/index.sqlite in the project root. */ interface IndexedFile { path: string; mtime: number; lines: number; language: string; size: number; } interface IndexedSymbol { name: string; type: string; file: string; line: number; exported: boolean; } /** * SQLite-backed persistent index for codebase data using sql.js WASM. */ export declare class SqliteStore { private dbPath; private db; private dirty; private SQL; private saveTimeout; private readonly AUTO_SAVE_DELAY; /** * Create a new SqliteStore instance. * @param cwd - The working directory for the database file. */ constructor(cwd: string); /** * Initialize sql.js WASM module. * @returns The initialized sql.js static instance. */ private initSqlJs; /** * Run a query with bind parameters. * Replaces db.run() which doesn't support params in all cases. * @param sql - The SQL query string. * @param params - Bind parameters for the query. * @returns An array of result rows. */ private query; /** * Execute a statement with bind parameters (INSERT, UPDATE, DELETE). * Uses prepared statements to properly handle parameters. * @param sql - The SQL statement string. * @param params - Bind parameters for the statement. */ private execute; /** * Create tables if they don't exist. */ private createSchema; /** * Load existing database from disk. Returns false if none exists or version mismatch. * @returns True if the database was loaded successfully. */ load(): Promise; /** * Save database to disk. */ save(): Promise; /** * Schedule an automatic save after a delay. * Debounces multiple rapid updates into a single save operation. */ private scheduleAutoSave; /** * Initialize a new empty database. * @param _ - The working directory (unused, kept for interface compatibility). */ init(_: string): Promise; /** * Check if a file needs re-indexing (mtime changed). * @param filePath - The file path to check. * @returns True if the file needs re-indexing. */ needsReindex(filePath: string): Promise; /** * Update file entry in index. * @param file - The file entry to update. */ updateFile(file: IndexedFile): void; /** * Update symbols for a file (replaces all). * @param filePath - The file path whose symbols are being updated. * @param symbols - The new symbols for the file. */ updateSymbols(filePath: string, symbols: IndexedSymbol[]): void; /** * Update imports for a file. * @param filePath - The file path whose imports are being updated. * @param imports - The new import paths for the file. */ updateImports(filePath: string, imports: string[]): void; /** * Query symbols by name pattern. * @param pattern - Pattern to match symbol names (uses SQL LIKE). * @param type - Optional symbol type filter. * @returns Matching symbols. */ findSymbols(pattern: string, type?: string): IndexedSymbol[]; /** * Get all files in index. * @returns All indexed files. */ getFiles(): IndexedFile[]; /** * Get imports for a file. * @param filePath - The file path to look up. * @returns The import paths for the file. */ getImports(filePath: string): string[]; /** * Get importers of a file (reverse lookup). * @param filePath - The file path to find importers for. * @returns Files that import the given file. */ getImporters(filePath: string): string[]; /** * Remove a file from the index. * @param filePath - The file path to remove. */ removeFile(filePath: string): void; /** * Get index stats. * @returns Stats object or null if no database loaded. */ stats(): { files: number; symbols: number; imports: number; updated: string; engine: string; } | null; /** * Close the database. * Saves any pending changes before closing. */ close(): Promise; /** * Log tool usage to DB. * @param tool - Tool name. * @param duration - Duration in milliseconds. * @param success - Whether the operation succeeded. * @param cached - Whether the result was cached. */ logUsage(tool: string, duration: number, success: boolean, cached: boolean): void; /** * Get usage stats. * @returns Aggregated usage statistics per tool. */ getUsageStats(): { tool: string; count: number; errorCount: number; avgDuration: number; }[]; } export {}; //# sourceMappingURL=sqlite-store.d.ts.map