/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */ import type { WorkspaceCheckpoint } from './checkpoint/types.js'; /** Thrown when a hunk cannot be reverse-applied cleanly (stale/drifted/malformed). */ export declare class HunkRevertConflictError extends Error { constructor(message: string); } /** Successful reverse-apply of one hunk: the next file content and what changed. */ export interface RevertHunkSuccess { readonly ok: true; /** The full file content after the single hunk has been reversed. */ readonly nextContent: string; /** The `@@ … @@` header line of the hunk, echoed back for the receipt. */ readonly hunkHeader: string; /** Count of `+` (added) lines the forward hunk introduced, removed by the revert. */ readonly addedLinesRemoved: number; /** Count of `-` (removed) lines the forward hunk deleted, restored by the revert. */ readonly removedLinesRestored: number; /** 1-based line where the hunk's new-side block matched the current file. */ readonly matchedAtLine: number; } /** A hunk that will not reverse-apply cleanly (never a partial write). */ export interface RevertHunkConflict { readonly ok: false; readonly reason: string; } export type RevertHunkResult = RevertHunkSuccess | RevertHunkConflict; /** * Reverse-apply ONE hunk to `fileContent`, pure. Succeeds only when the hunk's * new-side block still matches the file, at the header's line, or (if line * numbers drifted from unrelated edits) at a single unambiguous location. Any * ambiguity or mismatch is a conflict, never a partial write. */ export declare function reverseApplyHunk(fileContent: string, hunk: string): RevertHunkResult; /** A read-only preview of whether one hunk would reverse-apply cleanly right now. */ export interface HunkRevertPreview { readonly path: string; readonly applies: boolean; readonly conflict: string | null; readonly hunkHeader: string | null; readonly addedLinesRemoved: number; readonly removedLinesRestored: number; readonly matchedAtLine: number | null; } /** Compute, WITHOUT mutating anything, whether reverting `hunk` in `path` would apply cleanly. */ export declare function previewHunkRevert(workspaceRoot: string, path: string, hunk: string): HunkRevertPreview; /** The workspace surface `applyHunkRevert` needs: where files live, and the safety-snapshot idiom. */ export interface HunkRevertWorkspace { readonly workspaceRoot: string; /** Take a whole-tree snapshot; returns null when the tree is unchanged since the last checkpoint. */ create(opts: { kind: 'manual'; label: string; }): Promise; } /** Receipt of a single applied hunk revert, reversible via the safety checkpoint. */ export interface HunkRevertReceipt { readonly reverted: boolean; readonly path: string; readonly hunkHeader: string; readonly addedLinesRemoved: number; readonly removedLinesRestored: number; /** The pre-revert whole-tree checkpoint; restore it to undo. Null only when the tree was already identical to the latest checkpoint. */ readonly safetyCheckpointId: string | null; readonly undo: { readonly restoreCheckpointId: string; } | null; } /** * Reverse-apply one hunk to a workspace file, snapshotting first. Re-reads and * re-validates the current file (a hunk that went stale between preview and here * is a conflict, never a partial write), takes a whole-tree safety checkpoint as * the undo point, then writes the reversed content. */ export declare function applyHunkRevert(workspace: HunkRevertWorkspace, path: string, hunk: string): Promise; //# sourceMappingURL=hunk-revert.d.ts.map