import type { ExecResult } from "@earendil-works/pi-coding-agent"; import type { GitOperations } from "./git-operations.js"; /** * Narrow seam used by the commit reorganiser to interact with the underlying * git state. * * The interface exposes only the operations the reorganiser policy actually * needs: repository checks, checkpoint commit inspection, soft reset, staged-material * reads, staging manipulation, and commit execution. This keeps the * reorganiser module deep (the policy is hidden) while making the seam real * with two adapters: a production wrapper around {@link GitOperations} and an * in-memory fake for tests. */ export interface CommitStore { /** Check whether the current directory is inside a git working tree. */ isInsideGitRepo(): Promise; /** * Get the current HEAD commit SHA, or `null` when it cannot be resolved. */ getHead(): Promise; /** * Count how many consecutive commits at HEAD match the given marker. * The reorganiser uses this to discover checkpoint commits created at * `turn_end`. * * @param sessionId When provided, only count commits whose * `Checkpoint-Session` trailer matches (stops at the first non-matching * subject or trailer). */ countCheckpointCommits(marker: string, sessionId?: string): Promise; /** Check whether there are any uncommitted changes in the working tree. */ checkUncommittedChanges(): Promise; /** * Soft reset the last N commits, keeping their changes staged. * Equivalent to `git reset --soft HEAD~N`. */ resetSoft(commitCount: number): Promise; /** * Read the staged materials needed for commit-message generation: * full diff, name-status, and stat summary. */ getStagedMaterials(): Promise<{ diff: string; nameStatus: string; stat: string; }>; /** Unstage all changes. */ unstageAll(): Promise; /** * Check whether the index contains any staged changes. * Returns true when there are staged differences vs HEAD. */ hasStagedChanges(): Promise; /** Stage only the given files. */ stageFiles(files: string[]): Promise; /** Stage all changes. */ stageAll(): Promise; /** * Stage all changes except submodule-related paths (gitlink updates and * `.gitmodules`). Used when `ignoreSubmodules` is enabled. */ stageAllIgnoringSubmodules(): Promise; /** Execute a commit with the given message. */ commit(message: string): Promise; /** * Return the last N commits in `%H%x00%s` format, newest first. * * @param maxCount maximum number of commits to return * @param skip number of commits to skip from HEAD (for pagination) */ getRecentCommits(maxCount: number, skip?: number): Promise; /** * Walk backwards from HEAD and return every reachable commit whose * subject starts with `marker`, along with its SHA and * `Checkpoint-Session` trailer value (or `null` when absent). */ findReachableCheckpoints(marker: string): Promise>; /** * Extract the diff of a single commit (relative to its first parent) and * apply it to the index via `git apply --cached`. * * Used for scattered checkpoint reassembly. Returns `{ success: true }` * on success, or `{ success: false, error }` when the apply fails. */ applyCommitDiffToIndex(sha: string): Promise<{ success: boolean; error?: string; }>; /** * Hard reset HEAD, index, and working tree to a specific commit. */ hardReset(sha: string): Promise; /** * Compute the diff between two commits and apply it to both the working * tree and the index via `git apply --3way --index`. */ applyRangeDiff(ancestor: string, descendant: string): Promise<{ success: boolean; error?: string; }>; /** * Cherry-pick a single commit onto the current HEAD. */ cherryPick(sha: string): Promise<{ success: boolean; error?: string; }>; } /** * Information about a single reachable checkpoint commit, returned by * {@link CommitStore.findReachableCheckpoints}. */ export interface ReachableCheckpoint { sha: string; subject: string; session: string | null; } /** * Production adapter: satisfies {@link CommitStore} by delegating to * {@link GitOperations}. */ export declare class GitCommitStore implements CommitStore { private readonly git; constructor(git: GitOperations); isInsideGitRepo(): Promise; getHead(): Promise; countCheckpointCommits(marker: string, sessionId?: string): Promise; checkUncommittedChanges(): Promise; resetSoft(commitCount: number): Promise; getStagedMaterials(): Promise<{ diff: string; nameStatus: string; stat: string; }>; unstageAll(): Promise; hasStagedChanges(): Promise; stageFiles(files: string[]): Promise; stageAll(): Promise; stageAllIgnoringSubmodules(): Promise; commit(message: string): Promise; getRecentCommits(maxCount: number, skip?: number): Promise; findReachableCheckpoints(marker: string): Promise>; applyCommitDiffToIndex(sha: string): Promise<{ success: boolean; error?: string; }>; hardReset(sha: string): Promise; applyRangeDiff(ancestor: string, descendant: string): Promise<{ success: boolean; error?: string; }>; cherryPick(sha: string): Promise<{ success: boolean; error?: string; }>; } //# sourceMappingURL=commit-store.d.ts.map