/**
 * Undo/Checkpoint System
 *
 * Features:
 * - File state checkpoints
 * - Undo/redo operations
 * - Checkpoint naming and tagging
 * - Diff viewing between checkpoints
 * - Automatic checkpoints before dangerous operations
 * - Git integration for version control
 *
 * Allows reverting changes made by Code Buddy.
 */
import { TypedEventEmitter, CheckpointEvents } from '../events/index.js';
export interface Checkpoint {
    id: string;
    name: string;
    description?: string;
    timestamp: Date;
    files: CheckpointFile[];
    metadata: CheckpointMetadata;
    tags: string[];
    parentId?: string;
}
export interface CheckpointFile {
    path: string;
    relativePath: string;
    hash: string;
    size: number;
    mode: number;
    exists: boolean;
    isNew: boolean;
    isDeleted: boolean;
}
export interface CheckpointMetadata {
    workingDirectory: string;
    gitBranch?: string;
    gitCommit?: string;
    sessionId?: string;
    operation: string;
    tool?: string;
    automatic: boolean;
}
export interface FileChange {
    path: string;
    type: 'created' | 'modified' | 'deleted';
    oldContent?: string;
    newContent?: string;
    diff?: string;
}
export interface UndoResult {
    success: boolean;
    checkpoint: Checkpoint;
    restoredFiles: string[];
    errors: Array<{
        path: string;
        error: string;
    }>;
}
export interface CheckpointConfig {
    enabled: boolean;
    maxCheckpoints: number;
    autoCheckpoint: boolean;
    autoCheckpointInterval: number;
    checkpointOnDangerousOps: boolean;
    excludePatterns: string[];
    maxFileSize: number;
    compressCheckpoints: boolean;
}
/**
 * Checkpoint Manager
 *
 * Uses TypedEventEmitter for type-safe event handling.
 * Emits events: checkpoint:created, checkpoint:deleted, undo:noop, redo:noop,
 * undo:complete, redo:complete, restore:complete
 */
export declare class CheckpointManager extends TypedEventEmitter<CheckpointEvents> {
    private config;
    private dataDir;
    private checkpointsDir;
    private checkpoints;
    private currentIndex;
    private workingDirectory;
    private autoCheckpointTimer;
    private dmp;
    constructor(workingDirectory: string, config?: Partial<CheckpointConfig>);
    /**
     * Initialize checkpoint manager
     */
    private initialize;
    /**
     * Hash a path for storage
     */
    private hashPath;
    /**
     * Load checkpoints from disk
     */
    private loadCheckpoints;
    /**
     * Save checkpoints index
     */
    private saveIndex;
    /**
     * Create a new checkpoint
     */
    createCheckpoint(options: {
        name?: string;
        description?: string;
        operation: string;
        tool?: string;
        files?: string[];
        tags?: string[];
        automatic?: boolean;
    }): Promise<Checkpoint>;
    /**
     * Snapshot a single file
     */
    private snapshotFile;
    /**
     * Check if a path matches exclude patterns
     */
    private isExcluded;
    /**
     * Simple glob matching
     */
    private matchGlob;
    /**
     * Get tracked files in working directory
     */
    private getTrackedFiles;
    /**
     * Execute a git command asynchronously using spawn (secure)
     */
    private execGitCommand;
    /**
     * Get git info (async version)
     */
    private getGitInfoAsync;
    /**
     * Get git info (sync wrapper for compatibility - prefers cached value)
     */
    private getGitInfo;
    /**
     * Undo to previous checkpoint
     */
    undo(): Promise<UndoResult | null>;
    /**
     * Redo to next checkpoint
     */
    redo(): Promise<UndoResult | null>;
    /**
     * Restore a specific checkpoint
     */
    restoreCheckpoint(checkpoint: Checkpoint, operation: 'undo' | 'redo' | 'restore'): Promise<UndoResult>;
    /**
     * Get diff between two checkpoints
     */
    getDiff(fromId: string, toId: string): Promise<FileChange[]>;
    /**
     * Get file content from checkpoint
     */
    private getCheckpointFileContent;
    /**
     * Delete checkpoint files
     */
    private deleteCheckpointFiles;
    /**
     * Enforce maximum checkpoints
     */
    private enforceMaxCheckpoints;
    /**
     * Check if operation should trigger auto-checkpoint
     */
    shouldAutoCheckpoint(operation: string): boolean;
    /**
     * Start auto-checkpoint timer
     */
    private startAutoCheckpoint;
    /**
     * Stop auto-checkpoint timer
     */
    private stopAutoCheckpoint;
    /**
     * Get all checkpoints
     */
    getCheckpoints(): Checkpoint[];
    /**
     * Get current checkpoint
     */
    getCurrentCheckpoint(): Checkpoint | null;
    /**
     * Get checkpoint by ID
     */
    getCheckpoint(id: string): Checkpoint | undefined;
    /**
     * Search checkpoints by tag or name
     */
    searchCheckpoints(query: string): Checkpoint[];
    /**
     * Tag a checkpoint
     */
    tagCheckpoint(id: string, tag: string): Promise<void>;
    /**
     * Rename a checkpoint
     */
    renameCheckpoint(id: string, name: string): Promise<void>;
    /**
     * Delete a checkpoint
     */
    deleteCheckpoint(id: string): Promise<void>;
    /**
     * Can undo
     */
    canUndo(): boolean;
    /**
     * Can redo
     */
    canRedo(): boolean;
    /**
     * Format status
     */
    formatStatus(): string;
    /**
     * Dispose and clean up resources
     */
    dispose(): void;
}
export declare function createCheckpointManager(workingDirectory: string, config?: Partial<CheckpointConfig>): CheckpointManager;
