/** * Type definitions for the comment watcher. */ export type AICommentMode = "collect" | "edit" | "question" | "ignore"; export interface ParsedComment { filePath: string; lineNumber: number; rawLines: string[]; commentStartColumns: number[]; hasTrigger: boolean; mode: AICommentMode; } export interface CommentWatcherOptions { /** Patterns to ignore when watching files */ ignoredPatterns?: RegExp[]; /** Current working directory for relative paths */ cwd?: string; /** Whether to ignore initial files when starting watch */ ignoreInitial?: boolean; /** Stability threshold for file writes (ms) */ stabilityThreshold?: number; /** Poll interval for file writes (ms) */ pollInterval?: number; } export type CommentWatcherCallback = (comment: ParsedComment, allPending: ParsedComment[]) => void; export type TriggerCallback = (comments: ParsedComment[]) => void; export interface CommentWatcherCallbacks { /** Called when an AI comment (without trigger) is found */ onAIComment?: CommentWatcherCallback; /** Called when an AI! comment (with trigger) is found */ onAITrigger?: TriggerCallback; /** Called when an AI? comment (question trigger) is found */ onAIQuestion?: TriggerCallback; /** Called when the watcher is ready */ onReady?: () => void; /** Called when an error occurs */ onError?: (error: Error) => void; } /** * Creates the underlying file watcher for one or more paths. */ export type WatcherFactory = ( paths: string | string[], options?: Record ) => FSWatcherLike; export interface FSWatcherLike { /** * Close the underlying file watcher and release any resources it holds. */ close(): Promise; /** * Register a listener for file-system watcher events. */ on(event: string, listener: (...args: unknown[]) => void): FSWatcherLike; }