import { type SearchResult, type IndexedFile, type Codebase } from "./db/store.ts"; import type { Embedder } from "./embed/types.ts"; export type { SearchResult, IndexedFile, Codebase } from "./db/store.ts"; export type { CodeChunk } from "./chunk/types.ts"; export type { Embedder } from "./embed/types.ts"; export type SearchMode = "semantic" | "keyword" | "hybrid"; export interface SearchOptions { limit?: number; threshold?: number; includeSnippet?: boolean; mode?: SearchMode; } export type IndexPhase = "scan" | "hash" | "chunk" | "embed" | "cleanup" | "fts"; export interface IndexProgress { phase: IndexPhase; /** Current item within the phase (0 before work starts, 1-based during) */ current: number; /** Total items in this phase (0 if unknown) */ total: number; } export interface IndexOptions { languages?: string[]; verbose?: boolean; onProgress?: (progress: IndexProgress) => void; } export interface IndexResult { files: number; chunks: number; embedded: number; skipped: number; removed: number; errors: string[]; duration: number; } export interface CodeIndexOptions { dbPath: string; /** Embedding function - SDK users must provide their own */ embedder: Embedder; /** Model name stored alongside embeddings (e.g. "all-MiniLM-L6-v2") */ embeddingModel: string; } /** Compute the default DB path for a project directory: /.codemogger/index.db */ export declare function projectDbPath(dir: string): string; export declare class CodeIndex { private store; private dbPath; private embedder; private embeddingModel; private searchVerified; constructor(opts: CodeIndexOptions); private getStore; /** Index a directory: scan files, chunk with tree-sitter, embed, store */ index(dir: string, opts?: IndexOptions): Promise; /** Search for code chunks relevant to a query. * - "semantic": natural language / conceptual queries (vector search, global) * - "keyword": precise identifier or term lookup (FTS, queries all codebases) * - "hybrid": combine both via reciprocal rank fusion */ search(query: string, opts?: SearchOptions): Promise; /** * Verify the database is in a searchable state (once per instance). * Detects when the DB file is large but has no visible chunks * (e.g., WAL locked by another process, missing WAL file). */ private verifySearchable; /** List all indexed files (optionally scoped to a directory/codebase) */ listFiles(): Promise; /** List all codebases */ listCodebases(): Promise; /** Close the database connection */ close(): Promise; }