import { type FSWatcher } from 'chokidar'; import type { ServerContext } from '../context.js'; export interface WatcherOptions { /** Per-file reindex debounce (ms). Collapses bursts of writes from * Obsidian's autosave into a single reindex. */ debounceMs?: number; /** Graph-wide Louvain-recompute debounce (ms). Longer than debounceMs so * community detection runs at most once per quiet period. */ communityDebounceMs?: number; } export interface WatcherHandle { /** Stop watching and release all resources. */ close: () => Promise; /** Underlying chokidar watcher (exposed for tests + advanced callers). */ watcher: FSWatcher; } /** * Watch the vault and keep the index live. Chokidar's awaitWriteFinish + * our own per-file debounce collapses Obsidian's ~2s autosave cadence into * a single reindex per editing pause. Community detection (Louvain over the * whole graph) runs on a separate, longer debounce — it's the only expensive * thing and doesn't need to fire for every keystroke. */ export declare function startWatcher(ctx: ServerContext, opts?: WatcherOptions): WatcherHandle;