/**
 * Git service for Studiograph
 *
 * Handles Git operations with transaction-based commits,
 * proper user attribution, and security.
 */
export interface GitUser {
    id: string;
    name: string;
    email: string;
}
export interface GitChange {
    operation: 'create' | 'update' | 'delete';
    filePath: string;
    entityType: string;
    entityId: string;
}
export interface GitCommit {
    hash: string;
    author: {
        name: string;
        email: string;
    };
    timestamp: number;
    message: string;
}
export declare class GitService {
    private repoPath;
    constructor(repoPath: string);
    /**
     * Ensure the repo path exists and is a directory
     */
    private ensureValidPath;
    /**
     * Initialize Git repository if not already initialized
     */
    private initializeIfNeeded;
    /**
     * Check if repository has any commits
     */
    hasCommits(): boolean;
    /**
     * Return the current HEAD commit hash, or null if the repo has no commits.
     * Used by callers (MCP update_entity) that want to surface the post-write
     * commit hash so external agents can verify a write landed in git.
     */
    getHeadCommit(): string | null;
    /**
     * Get current branch name
     */
    getCurrentBranch(): string;
    /**
     * Create a transaction for batched commits
     */
    createTransaction(): GitTransaction;
    /**
     * Get commit history
     */
    getHistory(limit?: number): GitCommit[];
    /**
     * Get file history for a specific file
     */
    getFileHistory(filePath: string, limit?: number): GitCommit[];
    /**
     * Get file content at a specific commit
     */
    getFileAtCommit(filePath: string, commitHash: string): string | null;
    /**
     * List every file path tracked in `commitHash`, repo-relative POSIX.
     * Returns an empty array on error (unknown hash, malformed history).
     * Used by restore flows that need to find a deleted entity's file
     * inside its last-known commit without knowing the path up-front.
     */
    listFilesAtCommit(commitHash: string): string[];
    /**
     * Unified diff between two commits for a single file. `toCommitHash` may
     * be 'HEAD' or any rev-spec git accepts. All three params flow through
     * passed as argv entries so shell metacharacters in paths or revs are never
     * interpreted by a shell. Returns the raw diff (or empty string on failure).
     */
    getDiff(fromCommitHash: string, toCommitHash: string, filePath: string): string;
    /**
     * Recent file deletions from the commit log, scoped to a time window.
     *
     * Uses `git log --diff-filter=D --name-only` to find every commit that
     * deleted at least one file, then walks the output and pairs each
     * deleted path with the commit that removed it. The returned list is
     * deduped on `filePath` so a file deleted-and-recreated-and-deleted
     * surfaces only its most recent removal — that's the one a "restore"
     * action is going to target.
     *
     * `withinDays` clamps to a 1-90 day window. The default of 7 covers
     * the most common "I deleted that yesterday" workflows without
     * dragging in months of forgotten removals.
     */
    listRecentDeletions(withinDays?: number): Array<{
        filePath: string;
        deletedAtCommit: string;
        deletedAt: number;
        deletedBy: {
            name: string;
            email: string;
        };
        lastVersionCommit: string;
        commitMessage: string;
    }>;
    /**
     * Get current status (modified, added, deleted files)
     */
    getStatus(): {
        modified: string[];
        added: string[];
        deleted: string[];
        untracked: string[];
    };
    /**
     * Check if there are uncommitted changes
     */
    hasUncommittedChanges(): boolean;
    /**
     * Fetch from the remote to update tracking refs.
     */
    fetch(): void;
    /**
     * Get ahead/behind counts relative to the tracking remote branch.
     * Returns { ahead: 0, behind: 0 } if no remote is configured.
     */
    getAheadBehind(): {
        ahead: number;
        behind: number;
    };
    /**
     * Revert all uncommitted changes (staged + unstaged + untracked).
     */
    revertAll(): void;
    /**
     * Stage all and commit with user attribution.
     */
    commitAll(message: string, user: GitUser): void;
    /**
     * Stage specific files and commit with user attribution.
     * Unlike commitAll, this only stages the given files — unrelated
     * untracked files (e.g. sync-created entities) are left untouched.
     *
     * Uses `git add -A <pathspec>` so deletions, modifications, and
     * additions under the listed paths are all staged. The path scoping
     * still prevents pulling in unrelated untracked files outside the
     * listed paths. Throws on git failure with stderr in the error.
     */
    commitFiles(filePaths: string[], message: string, user: GitUser): void;
    /**
     * Push to remote
     */
    push(): void;
    /**
     * Pull from remote
     */
    pull(): void;
    /**
     * Repo-relative POSIX paths of files that differ between two commits
     * (`git diff --name-only <from> <to>`). Both revs flow through argv so
     * shell metacharacters are never interpreted. Returns `[]` on failure or
     * when nothing changed. Used by `graph.pullAndReconcile` to find the .md
     * files a pull rewrote so any live editor Y.Doc can be reconciled.
     */
    diffNameOnly(fromCommitHash: string, toCommitHash: string): string[];
    /**
     * Get status as array of { path, status } entries
     */
    status(): Array<{
        path: string;
        status: string;
    }>;
}
/**
 * Transaction class for batched Git commits
 */
export declare class GitTransaction {
    private repoPath;
    private changes;
    constructor(repoPath: string);
    /**
     * Add a change to this transaction
     */
    add(change: GitChange): void;
    /**
     * Get all changes in this transaction
     */
    getChanges(): GitChange[];
    /**
     * Commit all changes in this transaction
     */
    commit(user: GitUser, message?: string): Promise<void>;
    /**
     * Generate commit message from changes
     */
    private generateMessage;
    /**
     * Rollback all changes (git reset)
     */
    rollback(): Promise<void>;
}
