File Watching
Lucerna uses chokidar for debounced incremental re-indexing. Only changed files are re-processed — no full DB scan on each file change.
Start and stop watching
Section titled “Start and stop watching”await indexer.startWatching();await indexer.stopWatching();Start watching on initialization
Section titled “Start watching on initialization”Pass watch: true to the constructor to start watching automatically when initialize() is called:
const indexer = new CodeIndexer({ projectRoot: '/path/to/project', watch: true, watchDebounce: 500, // ms, default onIndexed: (event) => { if (event.type === 'indexed') { console.log(`[indexed] ${event.filePath} (${event.chunksAffected} chunks)`); } else if (event.type === 'removed') { console.log(`[removed] ${event.filePath}`); } else if (event.type === 'error') { console.error(`[error] ${event.filePath}:`, event.error); } },});
await indexer.initialize(); // starts watching immediately