/** * Production write-path safety for editomatic. * * - Sidecar backup of previous content (*.editomatic-bak) * - Atomic replace via temp file + rename * - Best-effort Python syntax check before overwriting .py files * * Env overrides: * - EDITOMATIC_NO_BACKUP=1 — skip writing the sidecar backup * - EDITOMATIC_SKIP_PYTHON_CHECK=1 — skip py_compile even for .py paths */ export declare function backupPathFor(filePath: string): string; export declare function tempWritePathFor(filePath: string): string; export declare function isBackupDisabled(): boolean; export declare function isPythonCheckDisabled(): boolean; /** * True when the path looks like a Python source file. */ export declare function isPythonPath(filePath: string): boolean; /** * Resolve a Python interpreter for py_compile, or null if none found. */ export declare function resolvePythonBinary(): Promise; export type PythonValidationResult = { ok: true; skipped: true; reason: string; } | { ok: true; skipped: false; } | { ok: false; error: string; /** 1-based line in the proposed full file content, if parseable from compiler output. */ line?: number; /** e.g. IndentationError, SyntaxError */ errorType?: string; /** Compiler message with temp paths remapped to labelPath. */ remappedDetail?: string; }; /** * Parse and remap py_compile / Python traceback lines so agents see the real * file path and line numbers for the **proposed** full-file content (not the * ephemeral temp path under /tmp). */ export declare function remapPythonCompileError(detail: string, labelPath: string, tempPath?: string): { remapped: string; line?: number; errorType?: string; }; /** * Best-effort syntax check: write source to a temp file and run * `python -m py_compile`. Skips cleanly when no interpreter is available * or checks are disabled. Never mutates the target file path. * * On failure, error messages remap the temp file path to `labelPath` and * expose the 1-based line number in the proposed content. */ export declare function validatePythonSyntax(source: string, labelPath: string): Promise; /** * Attribute a proposed-file syntax error line to an applied edit range, and * optionally show a local newText snippet with 1-based local line numbers. */ export declare function formatSyntaxErrorAttribution(proposedLine1Based: number, appliedRanges: Array<{ editIndex: number; startLine: number; lineCount: number; }>, edits: Array<{ newText: string; }>, proposedContent: string): string; export type SafeWriteResult = { backupPath: string | null; wroteBackup: boolean; }; /** * Write newContent to absolutePath safely: * 1. Optionally write previousContent to *.editomatic-bak * 2. Write newContent to *.editomatic-tmp * 3. Rename tmp over the target (atomic on same filesystem) * * On failure after backup, the backup remains for recovery. */ export declare function safeWriteFile(absolutePath: string, previousContent: string | Buffer, newContent: string): Promise; /** * Human-readable recovery line for tool summaries. */ export declare function backupRecoveryHint(absolutePath: string, wroteBackup: boolean): string; //# sourceMappingURL=write-safety.d.ts.map