UNPKG

mnemos-coder

Version:

CLI-based coding agent with graph-based execution loop and terminal UI

104 lines 2.64 kB
/** * SQLite database for codebase context storage * Uses better-sqlite3 for performance and simplicity */ export interface CodeChunk { id: string; file_path: string; start_line: number; end_line: number; content: string; chunk_type: 'function' | 'class' | 'interface' | 'import' | 'variable' | 'comment' | 'other'; language: string; content_hash: string; embedding?: number[]; metadata?: Record<string, any>; created_at: Date; updated_at: Date; } export interface FileInfo { file_path: string; content_hash: string; last_modified: Date; file_size: number; language: string; chunk_count: number; indexed_at: Date; } export interface SearchResult { chunk: CodeChunk; similarity_score?: number; rank?: number; } export declare class CodebaseDatabase { private db; private dbPath; constructor(projectRoot: string); private initializeTables; /** * Store file information */ storeFile(fileInfo: Omit<FileInfo, 'indexed_at'>): void; /** * Store code chunk with optional embedding */ storeChunk(chunk: Omit<CodeChunk, 'created_at' | 'updated_at'>): void; /** * Get file info by path */ getFileInfo(filePath: string): FileInfo | null; /** * Check if file needs reindexing */ needsReindexing(filePath: string, currentHash: string, currentModified: Date): boolean; /** * Get chunks by file path */ getChunksByFile(filePath: string): CodeChunk[]; /** * Text search using FTS */ textSearch(query: string, limit?: number, fileTypes?: string[]): SearchResult[]; /** * Get chunks by type */ getChunksByType(chunkType: string, limit?: number): CodeChunk[]; /** * Get all embeddings for vector search */ getAllEmbeddings(): Array<{ id: string; embedding: number[]; }>; /** * Get chunk by ID */ getChunkById(id: string): CodeChunk | null; /** * Remove chunks for a file */ removeFileChunks(filePath: string): void; /** * Get database statistics */ getStats(): { totalFiles: number; totalChunks: number; embeddedChunks: number; languages: Record<string, number>; chunkTypes: Record<string, number>; }; /** * Convert database row to CodeChunk */ private rowToChunk; /** * Create content hash */ static createContentHash(content: string): string; /** * Close database connection */ close(): void; } //# sourceMappingURL=database.d.ts.map