/** * Docs Fingerprints Manager Module * * Provides documentation file fingerprint tracking for delta detection during incremental indexing: * - Maps relative file paths to SHA256 content hashes * - Detects which doc files have changed since last index * - Supports atomic saves to prevent corruption * - Optimized batch operations for large projects * * This is separate from the code fingerprints to enable independent doc updates. */ /** * Fingerprints map type * * Maps relative file paths (forward-slash separated) to SHA256 content hashes. * - Key: relative path (e.g., "docs/README.md") * - Value: SHA256 hash of file content (64 hex characters) */ export type DocsFingerprints = Map; /** * Result of delta calculation between stored and current fingerprints */ export interface DocsDeltaResult { /** Files that exist in current but not in stored fingerprints */ added: string[]; /** Files that exist in both but have different hashes */ modified: string[]; /** Files that exist in stored but not in current fingerprints */ removed: string[]; /** Files that exist in both with the same hash */ unchanged: string[]; } /** Current docs fingerprints file version */ export declare const DOCS_FINGERPRINTS_VERSION = "1.0.0"; /** * Load docs fingerprints from an index path * * Loads docs-fingerprints.json from the index directory. * Returns an empty Map if file doesn't exist. * * @param indexPath - Absolute path to the index directory * @returns DocsFingerprints map (empty if file doesn't exist) * @throws MCPError if fingerprints file is corrupt * * @example * ```typescript * const fingerprints = await loadDocsFingerprints('/home/user/.mcp/search/indexes/abc123'); * console.log(fingerprints.size); // Number of tracked doc files * ``` */ export declare function loadDocsFingerprints(indexPath: string): Promise; /** * Save docs fingerprints to an index path * * Saves the fingerprints to docs-fingerprints.json with atomic write (temp + rename). * This prevents partial writes on crash. * * @param indexPath - Absolute path to the index directory * @param fingerprints - DocsFingerprints map to save * * @example * ```typescript * const fingerprints = new Map([['docs/README.md', 'abc123...']]); * await saveDocsFingerprints('/path/to/index', fingerprints); * ``` */ export declare function saveDocsFingerprints(indexPath: string, fingerprints: DocsFingerprints): Promise; /** * Calculate delta between stored fingerprints and current doc files * * Hashes current files and compares with stored fingerprints to detect: * - Added files (in current but not in stored) * - Modified files (different hash) * - Removed files (in stored but not in current) * - Unchanged files (same hash) * * @param stored - Previously stored fingerprints * @param currentFiles - List of relative paths for current doc files * @param projectPath - Absolute path to project root (for file access) * @returns Delta result with categorized files * * @example * ```typescript * const stored = await loadDocsFingerprints(indexPath); * const currentFiles = ['docs/README.md', 'docs/API.md']; * const delta = await calculateDocsDelta(stored, currentFiles, projectPath); * console.log(`Added: ${delta.added.length}, Modified: ${delta.modified.length}`); * ``` */ export declare function calculateDocsDelta(stored: DocsFingerprints, currentFiles: string[], projectPath: string): Promise; /** * Docs Fingerprints Manager class for managing documentation file fingerprints * * Provides: * - Loading and caching fingerprints * - Saving fingerprints with atomic writes * - Single file operations (get, set, delete) * - Batch delta calculation and updates * * @example * ```typescript * const manager = new DocsFingerprintsManager('/path/to/index', '/path/to/project'); * await manager.load(); * * // Check for changes * const delta = await manager.calculateDelta(['docs/README.md', 'docs/API.md']); * console.log(`Files to reindex: ${delta.added.length + delta.modified.length}`); * * // Update fingerprints after indexing * const newHashes = new Map([['docs/README.md', 'abc123...']]); * manager.updateFromDelta(delta, newHashes); * await manager.save(); * ``` */ export declare class DocsFingerprintsManager { private readonly indexPath; private readonly projectPath; private cachedFingerprints; private lastLoadedAt; private isDirty; /** * Create a new DocsFingerprintsManager instance * * @param indexPath - Absolute path to the index directory * @param projectPath - Absolute path to the project root */ constructor(indexPath: string, projectPath: string); /** * Load docs fingerprints from disk * * Always reads from disk, updating the cache. */ load(): Promise; /** * Save docs fingerprints to disk * * Uses atomic write to prevent corruption. * Only saves if there are cached fingerprints. */ save(): Promise; /** * Get the hash for a file path * * @param relativePath - Forward-slash separated relative path * @returns Hash string or undefined if not found */ get(relativePath: string): string | undefined; /** * Set the hash for a file path * * @param relativePath - Forward-slash separated relative path * @param hash - SHA256 hash of file content */ set(relativePath: string, hash: string): void; /** * Delete a file from fingerprints * * @param relativePath - Forward-slash separated relative path * @returns true if the file was deleted, false if it didn't exist */ delete(relativePath: string): boolean; /** * Check if a file exists in fingerprints * * @param relativePath - Forward-slash separated relative path * @returns true if the file exists in fingerprints */ has(relativePath: string): boolean; /** * Calculate delta between stored and current doc files * * Compares stored fingerprints with current file list to detect changes. * * @param currentFiles - List of relative paths for current doc files * @returns Delta result with categorized files */ calculateDelta(currentFiles: string[]): Promise; /** * Update fingerprints after indexing based on delta * * - Removes deleted files from fingerprints * - Updates added/modified files with new hashes * * @param delta - Delta result from calculateDelta * @param newHashes - Map of relative paths to new hashes for added/modified files */ updateFromDelta(delta: DocsDeltaResult, newHashes: Map): void; /** * Clear all fingerprints * * Useful when doing a full reindex. */ clear(): void; /** * Set all fingerprints from a map * * Replaces all existing fingerprints. * Useful for full indexing. * * @param fingerprints - New fingerprints map */ setAll(fingerprints: DocsFingerprints): void; /** * Get all fingerprints * * Returns a copy of the fingerprints map. * * @returns Copy of the fingerprints map */ getAll(): DocsFingerprints; /** * Get the number of tracked doc files * * @returns Number of files in fingerprints */ count(): number; /** * Check if fingerprints have been loaded */ isLoaded(): boolean; /** * Check if there are unsaved changes */ hasUnsavedChanges(): boolean; /** * Get the timestamp of the last load operation */ getLastLoadedAt(): number; /** * Get the path to the docs fingerprints file */ getDocsFingerprintsPath(): string; /** * Get the index path this manager is associated with */ getIndexPath(): string; /** * Get the project path this manager is associated with */ getProjectPath(): string; /** * Ensure fingerprints are loaded, throw if not */ private ensureLoaded; } //# sourceMappingURL=docsFingerprints.d.ts.map