/** * Checkpoint Module v3 * * Bulletproof capture of file states before AI edits. * This replaces the file watcher approach with a deterministic checkpoint system. * * Strategy: * - Cursor: beforeSubmitPrompt captures modified files, afterFileEdit uses checkpoint * - Claude: PreToolUse captures target file, PostToolUse uses checkpoint * - OpenCode: tool.execute.before captures target file, tool.execute.after uses checkpoint * * Storage: .git/agentblame/checkpoints/{conversation_id}.json */ export interface FileCheckpoint { blobSha: string; contentHash: string; timestamp: string; } export interface Checkpoint { conversationId: string; timestamp: string; files: Record; } /** * Compute a fast content hash for comparison * Uses SHA256 truncated to 16 chars for efficiency */ export declare function hashContent(content: string): string; /** * Check if a file has changed since the checkpoint * Returns true if the file content differs from the checkpoint */ export declare function hasFileChanged(repoRoot: string, conversationId: string, filePath: string): Promise; /** * Get checkpoint content for a file (loads from git blob) */ export declare function getCheckpointContent(repoRoot: string, conversationId: string, filePath: string): Promise; /** * Get the checkpoints directory path */ export declare function getCheckpointsDir(repoRoot: string): string; /** * Get the checkpoint file path for a conversation */ export declare function getCheckpointPath(repoRoot: string, conversationId: string): string; /** * Ensure checkpoints directory exists */ export declare function ensureCheckpointsDir(repoRoot: string): void; /** * Save a checkpoint for a conversation */ export declare function saveCheckpoint(repoRoot: string, checkpoint: Checkpoint): void; /** * Load a checkpoint for a conversation */ export declare function loadCheckpoint(repoRoot: string, conversationId: string): Checkpoint | null; /** * Update a checkpoint with a new file state */ export declare function updateCheckpointFile(repoRoot: string, conversationId: string, filePath: string, blobSha: string, contentHash: string): void; /** * Update checkpoint with content (computes hash and stores blob) */ export declare function updateCheckpointWithContent(repoRoot: string, conversationId: string, filePath: string, content: string): Promise; /** * Get the "before" blob for a file from checkpoint * Returns null if no checkpoint exists for this file */ export declare function getCheckpointBlob(repoRoot: string, conversationId: string, filePath: string): string | null; /** * Delete a checkpoint (cleanup after commit or session end) */ export declare function deleteCheckpoint(repoRoot: string, conversationId: string): void; /** * Clean up old checkpoints (older than specified hours) */ export declare function cleanupOldCheckpoints(repoRoot: string, maxAgeHours?: number): number; /** * Get list of modified files from git status (staged + unstaged) * These are files that may have human edits since last commit */ export declare function getGitModifiedFiles(repoRoot: string): Promise; /** * Capture checkpoint for Cursor's beforeSubmitPrompt * Captures all modified files (from git status) since they may have human edits */ export declare function captureBeforePromptCheckpoint(repoRoot: string, conversationId: string): Promise; /** * Capture checkpoint for a single file (Claude PreToolUse / OpenCode tool.execute.before) * More efficient than capturing all modified files since we know the target */ export declare function captureFileCheckpoint(repoRoot: string, conversationId: string, filePath: string): Promise; /** * Get the "before" blob for a file, using checkpoint if available, else git HEAD */ export declare function getBeforeBlob(repoRoot: string, conversationId: string, filePath: string): Promise;