/** * File watcher for incremental indexing * * Best practices implemented: * - Debouncing: Batches rapid file changes (e.g., IDE saves, git operations) * - Queuing: Prevents concurrent index operations * - Efficient filtering: Only watches relevant file types * - Graceful shutdown: Proper cleanup on SIGINT/SIGTERM * - Error recovery: Continues watching after index errors */ import { type IndexOptions, type IndexResult } from './index'; export interface WatchOptions extends IndexOptions { /** Debounce delay in milliseconds (default: 300) */ debounceMs?: number; /** Callback when indexing starts */ onIndexStart?: (files: string[]) => void; /** Callback when indexing completes */ onIndexComplete?: (results: IndexResult[]) => void; /** Callback when a file change is detected */ onFileChange?: (event: 'add' | 'change' | 'unlink', filepath: string) => void; /** Callback for errors */ onError?: (error: Error) => void; } export interface FileWatcher { /** Stop watching and clean up */ stop: () => Promise; /** Whether the watcher is currently running */ isRunning: () => boolean; } /** * Start watching a directory for file changes and index incrementally */ export declare function watchDirectory(rootDir: string, options?: WatchOptions): Promise;