/** * Git-based filesystem checkpoints for the /rewind feature. * * Creates lightweight snapshots via `git stash create` at each agent turn, * allowing the user to restore the working tree to a previous state. */ /** A filesystem checkpoint associated with a session entry. */ export interface Checkpoint { /** Session entry ID this checkpoint is associated with. */ entryId: string; /** Git stash commit ref. Empty string means working tree was clean (HEAD is the checkpoint). */ stashRef: string; /** HEAD commit hash at checkpoint creation time. */ headRef: string; /** ISO timestamp when the checkpoint was created. */ timestamp: string; } /** Result of a filesystem restore operation. */ export interface RestoreResult { ok: boolean; /** Files that were changed by the restore. */ filesChanged: string[]; /** Error message if restore failed. */ error?: string; } /** Check if the cwd is inside a git repository. */ export declare function isGitRepo(cwd: string): boolean; /** Get the current HEAD commit hash. */ export declare function getHeadRef(cwd: string): string | undefined; /** * Create a stash commit without storing it in the stash list. * Returns the commit hash, or empty string if working tree is clean. */ export declare function createStashCommit(cwd: string): string; /** Check if a git object ref is still valid (not garbage-collected). */ export declare function isValidRef(cwd: string, ref: string): boolean; /** * Get the list of files that differ between two refs. * If `toRef` is omitted, compares against the current working tree. */ export declare function getChangedFilesBetween(cwd: string, fromRef: string, toRef?: string): string[]; /** * Get files that will change if we restore to a checkpoint. * Compares the checkpoint state against the current working tree. */ export declare function getFilesChangedByRewind(cwd: string, checkpoint: Checkpoint): string[]; /** * Restore the working tree to match a checkpoint. * * Strategy: * 1. Reset all tracked files to HEAD (`git checkout -- .`) * 2. Apply the checkpoint stash on top (`git stash apply `) * * If the checkpoint stash ref is empty (working tree was clean at checkpoint time), * only step 1 is performed. */ export declare function restoreCheckpoint(cwd: string, checkpoint: Checkpoint): RestoreResult; /** * Create a safety stash of the current working tree state. * Returns the stash ref (empty if working tree is clean). * This allows undoing a rewind operation. */ export declare function createSafetyStash(cwd: string): string; /** Get the checkpoints file path for a session file. */ export declare function getCheckpointsPath(sessionFile: string): string; /** Load checkpoints from a JSON file. Returns empty map if file doesn't exist. */ export declare function loadCheckpoints(path: string): Map; /** Save checkpoints to a JSON file. */ export declare function saveCheckpoints(filePath: string, checkpoints: Map): void; //# sourceMappingURL=git-checkpoint.d.ts.map