/** * Dirty Files Manager Module * * Tracks files pending indexing for lazy/deferred indexing strategies. * Persists to disk to survive server restarts. * * Key features: * - Tracks files that need to be indexed (adds/changes) * - Tracks file deletions separately using `__deleted__:` prefix * - Atomic saves to prevent corruption * - Only saves to disk when modified (optimization) */ /** Current dirty files file version */ export declare const DIRTY_FILES_VERSION = "1.0.0"; /** Prefix used to mark deleted files */ export declare const DELETED_PREFIX = "__deleted__:"; /** * Dirty Files Manager class for tracking files pending indexing * * Provides: * - Loading and caching dirty files * - Saving dirty files with atomic writes * - Tracking file additions/modifications * - Tracking file deletions (with prefix) * * @example * ```typescript * const manager = new DirtyFilesManager('/path/to/index'); * await manager.load(); * * // Track file changes * manager.add('src/modified.ts'); * manager.markDeleted('src/removed.ts'); * * // Get files to process * const dirty = manager.getAll(); // ['src/modified.ts'] * const deleted = manager.getDeleted(); // ['src/removed.ts'] * * // After processing, clear and save * manager.clear(); * await manager.save(); * ``` */ export declare class DirtyFilesManager { private readonly indexPath; private dirtyFiles; private loaded; private modified; /** * Create a new DirtyFilesManager instance * * @param indexPath - Absolute path to the index directory */ constructor(indexPath: string); /** * Load dirty files from disk * * Always reads from disk, updating the cache. * Returns empty set if file doesn't exist. */ load(): Promise; /** * Save dirty files to disk (only if modified) * * Uses atomic write to prevent corruption. */ save(): Promise; /** * Add a file to the dirty set * * Marks a file as needing indexing (for adds and modifications). * If the file was previously marked as deleted, removes the deletion marker. * * @param relativePath - Forward-slash separated relative path */ add(relativePath: string): void; /** * Remove a file from the dirty set * * Removes a file from tracking (after it has been processed). * * @param relativePath - Forward-slash separated relative path */ remove(relativePath: string): void; /** * Mark a file as deleted * * Tracks file deletions using a special prefix. * If the file was pending indexing, removes it from the regular dirty set. * * @param relativePath - Forward-slash separated relative path */ markDeleted(relativePath: string): void; /** * Get all dirty files (excluding deletion markers) * * Returns files that need to be indexed (adds/modifications). * * @returns Array of relative paths */ getAll(): string[]; /** * Get all deleted files * * Returns files that need to be removed from the index. * * @returns Array of relative paths (without the __deleted__: prefix) */ getDeleted(): string[]; /** * Check if a file is dirty (pending indexing) * * @param relativePath - Forward-slash separated relative path * @returns true if the file is marked as dirty */ has(relativePath: string): boolean; /** * Check if a file is marked as deleted * * @param relativePath - Forward-slash separated relative path * @returns true if the file is marked for deletion */ isDeleted(relativePath: string): boolean; /** * Clear all dirty files * * Removes all entries (both dirty files and deletion markers). */ clear(): void; /** * Get the total count of tracked items * * Includes both dirty files and deletion markers. * * @returns Total number of tracked items */ count(): number; /** * Get the count of dirty files (excluding deletions) * * @returns Number of files pending indexing */ dirtyCount(): number; /** * Get the count of deleted files * * @returns Number of files pending removal */ deletedCount(): number; /** * Check if there are any dirty files or deletions * * @returns true if there are no tracked items */ isEmpty(): boolean; /** * Check if dirty files have been loaded */ isLoaded(): boolean; /** * Check if there are unsaved changes */ hasUnsavedChanges(): boolean; /** * Get the path to the dirty files file */ getDirtyFilesPath(): string; /** * Get the index path this manager is associated with */ getIndexPath(): string; /** * Delete the dirty files file from disk * * Used when deleting an index or during cleanup. */ delete(): Promise; } //# sourceMappingURL=dirtyFiles.d.ts.map