/** * Incremental update logic for codebase map cache * * Provides efficient change detection by comparing file mtimes and hashes * against cached values, enabling incremental re-summarization of only * changed files. */ import type { FileInfo } from "../utils/files.js"; import type { CodebaseMap } from "./map.js"; /** * Result of comparing current files against cache */ export interface FileChanges { /** Files that exist on disk but not in cache */ added: string[]; /** Files that exist in both but have changed content */ modified: string[]; /** Files that exist in cache but not on disk */ deleted: string[]; } /** * Determine which files have changed compared to the cache * * Uses a two-phase detection strategy: * 1. Fast path: Compare mtime (sub-millisecond operation) * 2. Verification: If mtime is suspicious (close match), compare content hash * * A file is considered "suspicious" when its mtime is very close to the cached * value but not exactly equal, which can happen due to filesystem timestamp * precision differences or time zone issues. * * @param projectDir - Absolute path to the project root directory * @param currentFiles - Array of FileInfo from walkDirectory() * @param cache - The loaded CodebaseMap cache * @returns Object with arrays of added, modified, and deleted file paths (relative) * * @example * ```typescript * const files = await walkDirectory(projectDir); * const cache = loadCache(projectDir) ?? createEmptyCache(projectDir); * const changes = await getChangedFiles(projectDir, files, cache); * * console.log(`Added: ${changes.added.length}`); * console.log(`Modified: ${changes.modified.length}`); * console.log(`Deleted: ${changes.deleted.length}`); * ``` */ export declare function getChangedFiles(projectDir: string, currentFiles: FileInfo[], cache: CodebaseMap): Promise; /** * Remove deleted files from the cache * * Modifies the cache object in place by removing entries for files * that no longer exist on disk. * * @param cache - The CodebaseMap to update (modified in place) * @param deletedPaths - Array of relative file paths to remove * @returns Number of entries removed * * @example * ```typescript * const changes = await getChangedFiles(projectDir, files, cache); * const removed = updateCacheForDeletedFiles(cache, changes.deleted); * console.log(`Removed ${removed} deleted files from cache`); * saveCache(projectDir, cache); * ``` */ export declare function updateCacheForDeletedFiles(cache: CodebaseMap, deletedPaths: string[]): number; //# sourceMappingURL=incremental.d.ts.map