trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
51 lines • 1.44 kB
TypeScript
/**
* Filesystem Watcher
*
* Monitors a directory tree for changes using Bun's fs.watch.
* Debounces rapid events and filters ignored paths.
* Emits FileChangeEvents to a callback.
*/
import type { FileChangeEvent } from '../vcs/types.js';
export interface FileWatcherConfig {
rootPath: string;
ignorePatterns: string[];
debounceMs: number;
onEvent: (event: FileChangeEvent) => void | Promise<void>;
}
export interface ScanProgress {
phase: 'discovering' | 'hashing' | 'done';
current: number;
total: number;
message: string;
}
export declare class FileWatcher {
private config;
private watchers;
private debounceTimers;
private knownFiles;
private running;
constructor(config: FileWatcherConfig);
/**
* Scans the directory tree and builds an initial map of all tracked files.
* Returns the list of FileChangeEvents for the initial state (all adds).
*/
scan(opts?: {
onProgress?: (progress: ScanProgress) => void;
}): Promise<FileChangeEvent[]>;
/**
* Starts watching the directory tree for changes.
*/
start(): void;
/**
* Stops all watchers.
*/
stop(): void;
/**
* Returns the current known file map (path → contentHash).
*/
getKnownFiles(): Map<string, string>;
private debouncedHandle;
private handleChange;
private walkDir;
}
//# sourceMappingURL=fs-watcher.d.ts.map