/** * Defines default ignored directory names shared by the lifecycle pipeline. */ export declare const DEFAULT_IGNORED_DIRECTORY_NAMES: Set; /** * Defines the supported json validator values. */ export type JsonValidator = (value: unknown, context: string) => asserts value is T; /** * Resolves project root from the provided inputs. */ export declare function resolveProjectRoot(scriptFilePath: string): string; /** * Provides path exists for the lifecycle pipeline. */ export declare function pathExists(filePath: string): Promise; /** * Provides path entry exists for the lifecycle pipeline. */ export declare function pathEntryExists(filePath: string): Promise; /** * Ensures ensure directory exists or is ready for use. */ export declare function ensureDirectory(directoryPath: string): Promise; /** * Reads json file from project state. */ export declare function readJsonFile(filePath: string, validator?: JsonValidator): Promise; /** * Reads json file or null from project state. */ export declare function readJsonFileOrNull(filePath: string, validator?: JsonValidator): Promise; /** * Reads text file or null from project state. */ export declare function readTextFileOrNull(filePath: string): Promise; /** * Reads binary file bytes or null from project state. */ export declare function readBinaryFileOrNull(filePath: string): Promise; /** Test-only hook for simulating filesystem failures in the atomic JSON writer. */ type RenameFile = (sourcePath: string, destinationPath: string) => Promise; /** Test-only hook for simulating destination-removal failures (rm EPERM races). */ type RemoveFile = (path: string, options: { force?: boolean; }) => Promise; /** * Test-only hook for simulating open failures in the atomic-reader path * (#427/#428): readers retry the same Windows-transient window as the * writer, so the churn contract (old | absent | complete-new, never a * transient error) holds from both sides. */ type ReadFileOverride = (filePath: string, encoding?: BufferEncoding) => Promise; /** Test-only hook for simulating temp-content write failures (#489 YtB). */ type WriteTextOverride = (filePath: string, value: string, encoding: "utf8") => Promise; /** * Renames a write-temp onto its final path. * * Windows replaces an existing destination with a single `rename` in the * common case, but a momentarily locked destination (AV scan, open handle, * or a concurrent writer's own rename — observed as EPERM/EACCES) needs a * bounded retry with a remove-and-retry fallback. Readers never observe * partial content: at every point the destination holds the old file, no * file, or the complete new file. */ declare function renameJsonWriteTemp(tempPath: string, filePath: string): Promise; /** * Writes json file to project state. * * Atomic by design (#427): content is written to a `.tmp` sibling and then * renamed over the destination, so a crash or power loss mid-write can never * leave a truncated/corrupt JSON state file. On failure the temp file is * removed before the error propagates. */ export declare function writeJsonFile(filePath: string, value: unknown): Promise; /** * Writes text file to project state. * * Honors the test-only `writeTextOverride` seam (#489 YtB) so a temp-content * write failure can be injected without corrupting the real filesystem. */ export declare function writeTextFile(filePath: string, value: string): Promise; /** * Writes binary file bytes to project state. */ export declare function writeBinaryFile(filePath: string, value: Buffer): Promise; /** * Snapshots file if exists from the provided inputs. */ export declare function snapshotFileIfExists(sourcePath: string, snapshotPath: string): Promise; /** * Writes json file with snapshot to project state. */ export declare function writeJsonFileWithSnapshot(filePath: string, snapshotPath: string, value: unknown): Promise; /** * Writes json lines file with snapshot to project state. */ export declare function writeJsonLinesFileWithSnapshot(filePath: string, snapshotPath: string, values: unknown[]): Promise; /** * Reads json lines file from project state. */ export declare function readJsonLinesFile(filePath: string, validator?: JsonValidator): Promise; /** * Writes json lines file to project state. */ export declare function writeJsonLinesFile(filePath: string, values: unknown[]): Promise; /** * Provides copy path for the lifecycle pipeline. */ export declare function copyPath(sourcePath: string, destinationPath: string): Promise; /** * Creates directory link for use by the lifecycle pipeline. */ export declare function createDirectoryLink(linkPath: string, targetPath: string): Promise; /** * Provides replace directory link for the lifecycle pipeline. */ export declare function replaceDirectoryLink(linkPath: string, targetPath: string): Promise; /** * Provides remove path for the lifecycle pipeline. */ export declare function removePath(targetPath: string): Promise; /** * Ensures ensure clean directory exists or is ready for use. */ export declare function ensureCleanDirectory(directoryPath: string): Promise; /** * Creates content hash for use by the lifecycle pipeline. */ export declare function createContentHash(content: string | Buffer): string; /** * Provides upsert managed section for the lifecycle pipeline. */ export declare function upsertManagedSection(options: { originalContent: string; markerId: string; bodyLines: string[]; }): string; /** * Provides remove managed section for the lifecycle pipeline. */ export declare function removeManagedSection(options: { originalContent: string; markerId: string; }): string; type DirectorySymlinkType = "dir" | "junction"; /** * Returns true when the file should be sorted *after* source-code files * during budget accounting so the byte budget is spent on signal-rich * content first. */ declare function isLowPriorityForScanBudget(entryPath: string): boolean; interface PendingFileEntry { entryPath: string; relativeEntryPath: string; } interface CollectedFileStat extends PendingFileEntry { size: number; } interface FileLikeStats { isFile(): boolean; size: number; } declare function getDirectorySymlinkType(platform?: NodeJS.Platform): DirectorySymlinkType; declare function toCollectedFileStat(fileEntry: PendingFileEntry, stats: FileLikeStats | null): CollectedFileStat | null; declare function compactCollectedFileStats(fileStats: Array): CollectedFileStat[]; declare function shouldIgnoreEnsureDirectoryError(directoryPath: string, error: unknown): Promise; declare function isUsableDirectoryPath(directoryPath: string): Promise; declare function getErrorMessage(error: unknown): string; /** * Provides to posix path for the lifecycle pipeline. */ export declare function toPosixPath(filePath: string): string; /** * Provides to relative posix path for the lifecycle pipeline. */ export declare function toRelativePosixPath(rootPath: string, filePath: string): string; /** * Provides count non empty lines for the lifecycle pipeline. */ export declare function countNonEmptyLines(content: string): number; /** * Describes scan budget options data exchanged by the lifecycle pipeline. */ export interface ScanBudgetOptions { maxDepth?: number; maxFiles?: number; maxBytes?: number; } interface IgnorePattern { raw: string; normalized: string; directoryOnly: boolean; basenameOnly: boolean; negated: boolean; regex: RegExp; } /** * Describes scan budget telemetry data exchanged by the lifecycle pipeline. */ export interface ScanBudgetTelemetry { visitedFiles: number; visitedBytes: number; truncated: boolean; truncationReason?: string; } /** * Provides list files recursive for the lifecycle pipeline. */ export declare function listFilesRecursive(rootPath: string, ignoredDirectoryNames?: ReadonlySet, budgetOptions?: ScanBudgetOptions): Promise; /** * Provides list files recursive with telemetry for the lifecycle pipeline. */ export declare function listFilesRecursiveWithTelemetry(rootPath: string, ignoredDirectoryNames?: ReadonlySet, budgetOptions?: ScanBudgetOptions): Promise<{ files: string[]; telemetry: ScanBudgetTelemetry; }>; declare function collectFilesFromDirectory(rootPath: string, directoryPath: string, ignoredDirectoryNames: ReadonlySet, ignorePatterns: IgnorePattern[], budgetOptions: Required, telemetry: ScanBudgetTelemetry, depth: number): Promise; declare function globPatternToRegExp(pattern: string): RegExp; /** * Exposes narrow file-module internals for focused behavioral coverage. */ export declare const filesInternals: { shouldIgnoreEnsureDirectoryError: typeof shouldIgnoreEnsureDirectoryError; isUsableDirectoryPath: typeof isUsableDirectoryPath; getDirectorySymlinkType: typeof getDirectorySymlinkType; getErrorMessage: typeof getErrorMessage; collectFilesFromDirectory: typeof collectFilesFromDirectory; globPatternToRegExp: typeof globPatternToRegExp; compactCollectedFileStats: typeof compactCollectedFileStats; toCollectedFileStat: typeof toCollectedFileStat; isLowPriorityForScanBudget: typeof isLowPriorityForScanBudget; BINARY_SCAN_DEPRIORITY_EXTENSIONS: Set; renameJsonWriteTemp: typeof renameJsonWriteTemp; /** Test-only: replaces the atomic-writer remove step (failure injection, #428). */ setJsonWriteRemoveOverride(override: RemoveFile | undefined): void; /** Test-only: replaces the atomic-writer rename step (failure injection, #427). */ setJsonWriteRenameOverride(override: RenameFile | undefined): void; /** Test-only: replaces the atomic-reader open step (failure injection, #427/#428). */ setReadFileOpenOverride(override: ReadFileOverride | undefined): void; /** Test-only: replaces the temp-content write step (failure injection, #489 YtB). */ setWriteTextOverride(override: WriteTextOverride | undefined): void; }; export {};