/** * ContentStore — FTS5 BM25-based knowledge base for context-mode. * * Chunks markdown content by headings (keeping code blocks intact), * stores in SQLite FTS5, and retrieves via BM25-ranked search. * * Use for documentation, API references, and any content where * you need EXACT text later — not summaries. */ type SourceMatchMode = "like" | "exact"; import type { IndexResult, SearchResult, StoreStats } from "./types.js"; export type { IndexResult, SearchResult, StoreStats } from "./types.js"; export declare function sanitizeQuery(query: string, mode?: "AND" | "OR"): string; export declare function sanitizeTrigramQuery(query: string, mode?: "AND" | "OR"): string; /** * Remove stale DB files from previous sessions whose processes no longer exist. */ export declare function cleanupStaleDBs(): number; /** * Clean up stale per-project content store DBs older than maxAgeDays. * Scans the given directory for *.db files and checks mtime. * Also detects zombie processes holding WAL locks — if a WAL file exists * but the owning PID is dead, the DB files are cleaned up regardless of age. */ export declare function cleanupStaleContentDBs(contentDir: string, maxAgeDays: number): number; export declare class ContentStore { #private; static readonly OPTIMIZE_EVERY = 50; static readonly FUZZY_CACHE_SIZE = 256; constructor(dbPath?: string); /** Delete this session's DB files. Call on process exit. */ cleanup(): void; index(options: { content?: string; path?: string; source?: string; }): IndexResult; /** * Index plain-text output (logs, build output, test results) by splitting * into fixed-size line groups. Unlike markdown indexing, this does not * look for headings — it chunks by line count with overlap. */ indexPlainText(content: string, source: string, linesPerChunk?: number): IndexResult; /** * Index JSON content by walking the object tree and using key paths * as chunk titles (analogous to heading hierarchy in markdown). Objects * recurse by key; arrays batch items by size. * * Falls back to `indexPlainText` if the content is not valid JSON. */ indexJSON(content: string, source: string, maxChunkBytes?: number): IndexResult; search(query: string, limit?: number, source?: string, mode?: "AND" | "OR", contentType?: "code" | "prose", sourceMatchMode?: SourceMatchMode): SearchResult[]; searchTrigram(query: string, limit?: number, source?: string, mode?: "AND" | "OR", contentType?: "code" | "prose", sourceMatchMode?: SourceMatchMode): SearchResult[]; fuzzyCorrect(query: string): string | null; searchWithFallback(query: string, limit?: number, source?: string, contentType?: "code" | "prose", sourceMatchMode?: SourceMatchMode): SearchResult[]; getSourceMeta(label: string): { label: string; chunkCount: number; codeChunkCount: number; indexedAt: string; } | null; listSources(): Array<{ label: string; chunkCount: number; }>; /** * Get all chunks for a given source by ID — bypasses FTS5 MATCH entirely. * Use this for inventory/listing where you need all sections, not search. */ getChunksBySource(sourceId: number): SearchResult[]; getDistinctiveTerms(sourceId: number, maxTerms?: number): string[]; getStats(): StoreStats; /** * Delete sources (and their chunks) older than maxAgeDays. * Returns count of deleted sources. */ cleanupStaleSources(maxAgeDays: number): number; /** Get DB file size in bytes. */ getDBSizeBytes(): number; close(): void; }