/** * The `.backup-*` copy a modify keeps of the file it changes. * * Outside a git work tree d365fo_file(action="undo") cannot revert a modify — it only * deletes files created in the current session — so a copy is kept there even with * createBackup=false. The copy is taken BEFORE the operation runs, as it always was, * so a write can never land without one; what changed is that it is removed again * when the call ends without having changed the file. A refused operation used to * leave a copy of an untouched file beside the AOT source on every call — four * refused calls on one view, four copies. */ /** * Create file backup and verify it was written successfully. * Throws if the source file is missing or the copy fails, so callers * always know whether a valid backup exists before overwriting. * Returns the backup file path. * * The name carries MILLISECONDS and, if that still collides, a counter. At the old * one-second resolution two modifies of the same file inside the same second * produced the same backup name, so the second copy overwrote the first with * already-modified content — on a target outside git (exactly the case that forces * a backup, see planRecoverableModification) the original was then unrecoverable. * COPYFILE_EXCL is what makes the retry a claim rather than a check: it fails * instead of overwriting, so two callers racing on the same name cannot both win. */ export declare function createFileBackup(filePath: string): Promise; /** A backup taken before a modify runs, until the call decides whether to keep it. */ export interface PendingBackup { filePath: string; backupPath: string; /** The file's bytes at backup time — what "the call changed the file" is measured against. */ original: Buffer; /** Taken because the target is outside git, not because the caller asked. */ forced: boolean; } /** The modify's backup, threaded from where it is taken to where it is settled. */ export interface BackupSlot { pending?: PendingBackup | null; settled?: boolean; } /** * Take the backup a modify needs, or none. Honors an explicit createBackup=true; * with createBackup=false it still takes one outside a git work tree, where the copy * is the only way back. * * Except for a file this server session created: undo deletes that outright (the * created-artifact ledger), so a copy restores nothing. That is every operations[] * entry on a create — one session left five copies of three files that had not * existed a minute earlier. */ export declare function planRecoverableModification(filePath: string, createBackup: boolean): Promise; /** The response line for a backup that is kept. */ export declare function keptBackupNote(pending: PendingBackup): string; /** Whether the file still holds the bytes it had when the backup was taken. */ export declare function fileUnchangedSince(pending: PendingBackup): Promise; /** The call wrote nothing (a skip): the copy is of an unchanged file. */ export declare function discardBackup(pending: PendingBackup): Promise; /** * The call failed. Keep the copy only when the file changed before it did (a batch * half-applied, a two-step bridge write that could not roll back); a refusal left * the file as it was. */ export declare function settleFailedModification(pending: PendingBackup): Promise; //# sourceMappingURL=modifyBackup.d.ts.map