/** * commit-safety — detect when a commit would sweep up work that this session * did NOT author. * * When several coding agents (or a separate wrongstack process, or a human) * edit the same worktree at once, a blanket `git add .` / commit-all captures * everyone's uncommitted changes — including half-finished work from another * agent. There is no way to un-bake that once it lands in a shared commit. * * This module reads the working tree and cross-references it against the * per-project {@link file-author-tracker} log (which records the sessionId that * created/edited each file). Dirty files whose latest author is a DIFFERENT * session are flagged as "foreign"; dirty files with no recorded author are * "unverified" (a concurrent non-wrongstack agent, a build/format step, or a * human). The result is a plain-text warning callers render before committing. * * Warn-only by design: this never blocks or rewrites what gets committed — it * surfaces the risk so the agent (or user) can scope the commit to its own * files or coordinate first. * * @module commit-safety */ export interface CommitSafetyOptions { /** Directory to run git in (the agent's cwd is fine). */ cwd: string; /** Project root, used to locate the file-author log. */ projectRoot: string; /** * The current session's id — the "self" key. Dirty files authored by a * different sessionId are flagged as foreign. When omitted, every authored * file counts as foreign (we cannot prove ownership). */ sessionId?: string | undefined; /** * Directory holding the file-author log. Defaults to the resolved per-project * dir (`~/.wrongstack/projects/`). Mainly an injection seam for tests. */ storageDir?: string | undefined; /** Abort signal for the git subprocesses. */ signal?: AbortSignal | undefined; } export interface ForeignFile { /** Repo-relative path. */ path: string; /** Human-readable name of the agent that last authored it, if known. */ agentName?: string | undefined; /** Session that last authored it, if known. */ sessionId?: string | undefined; } export interface CommitSafetyReport { /** Total uncommitted (staged + unstaged + untracked) paths. */ dirtyCount: number; /** Dirty files whose latest recorded author is a DIFFERENT session. */ foreignFiles: ForeignFile[]; /** Dirty files with no recorded author for any session. */ unverifiedFiles: string[]; /** Branch names of OTHER active worktrees of this repo (excludes ours). */ otherWorktrees: string[]; /** * Pre-formatted, plain-text (no ANSI) multi-line warning, or '' when there * is nothing notable to surface. Callers may colorize/wrap as they see fit. */ warning: string; } /** * Assess whether committing now risks capturing another agent's work. * * Best-effort: any git failure (not a repo, git missing, timeout) yields an * empty report rather than throwing — commit-safety must never break a commit. */ export declare function assessCommitSafety(opts: CommitSafetyOptions): Promise; //# sourceMappingURL=commit-safety.d.ts.map