@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
60 lines • 2.87 kB
TypeScript
import { type Repo } from './repo.ts';
import type { TreeEntry } from './tree.ts';
export declare const BINARY_SNIFF = 8000;
/** One changed path as the diffstat table renders it. */
export interface FileStat {
readonly path: string;
/** Lines added, 0 for a binary file. */
readonly insertions: number;
/** Lines removed, 0 for a binary file. */
readonly deletions: number;
/** Whether either side sniffs as binary. */
readonly binary: boolean;
/** Byte length of the old blob, 0 when created. */
readonly oldSize: number;
/** Byte length of the new blob, 0 when deleted. */
readonly newSize: number;
}
/**
* Per-path change counts between two trees, in path order.
*
* A binary file (NUL in the first 8000 bytes of either side, git's own sniff)
* counts zero lines; a mode-only change counts zero too but still occupies a
* row, which is how git prints `path | 0`.
*/
export declare function diffstat(repo: Repo, before: ReadonlyMap<string, TreeEntry>, after: ReadonlyMap<string, TreeEntry>): Promise<FileStat[]>;
/**
* git's diffstat table: one row per path, then the summary line.
*
* A row is ` <name> | <count> <graph>`, at most `width - 1` columns, and never
* narrower than a 10-column name and a 6-column graph allow. The count column
* fits the largest change, and `Bin` when a binary row reads
* `Bin <old> -> <new> bytes`, whose text after `Bin` claims graph room too.
* When the names and the graph do not both fit, a graph needing no more than
* its share (three eighths of the width, less the count column and six) keeps
* what it needs and the names take the rest; a wider one gets that share, at
* least 6 columns, or more if the names are short, and is scaled into it: the
* total, and then the smaller side (deletions on a tie), take their marks and
* the larger side keeps the rest, with two marks at least when both are
* nonzero. Measured against git 2.50.1 and 2.47.3 over 400 tables at 24 widths
* each.
*
* @param stats per-path counts from `diffstat`
* @param width total line budget, git's `--stat-width`
*/
export declare function statTable(stats: readonly FileStat[], width?: number): string[];
/**
* What `git commit` prints once the commit exists.
*
* The title line, then the counts and `--summary` lines that `commitSummary`
* renders for the change the commit records.
*
* @param oid the commit just written
* @param message its message
* @param branch the branch it landed on, null when detached
* @param changes the rendered counts and summary lines
* @param width how many hex digits to abbreviate the id to
* @param root whether this is the repository's first commit
*/
export declare function report(oid: string, message: string, branch: string | null, changes: string, width: number, root: boolean): string;
//# sourceMappingURL=summary.d.ts.map