@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
15 lines • 1.02 kB
TypeScript
import type { FileIdentity } from "./session-transcript-journal.ts";
type CaptureIdentity = (identity: Promise<FileIdentity | undefined>) => void;
/**
* Replaces `filePath` with the concatenated `chunks` so that no failure can leave a
* partial file behind: the content goes to a temp file in the same directory, is
* fsynced, and is renamed over the target (on Windows libuv renames with
* MOVEFILE_REPLACE_EXISTING), then the directory entry is fsynced where supported.
* A failure before the rename leaves the original byte-identical, removes the temp
* file, and rethrows; if the temp file cannot be removed either, both errors surface.
* When the directory refuses the temp file (EACCES/EPERM/EROFS) the file is rewritten
* in place as before, so a writable file in a read-only directory still migrates.
*/
export declare function replaceFileAtomically(filePath: string, chunks: Iterable<string | Uint8Array>, capture?: CaptureIdentity): void;
export {};
//# sourceMappingURL=session-file-replace.d.ts.map