@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
83 lines • 4.41 kB
TypeScript
import { type PathSpec } from '../../../../types.ts';
import { type Repo } from './repo.ts';
import { type TreeEntry } from './tree.ts';
import type { IndexEntry, IndexState, StatusEntry, WorkTree } from './types.ts';
import type { Files } from '../../../../workspace/files.ts';
export declare const MODIFIED = "M";
export declare const ADDED = "A";
export declare const DELETED = "D";
export declare const TYPE_CHANGED = "T";
/**
* One staged verdict: its letter, the path it was renamed from, and how similar
* the two are (0 when it is no rename).
*/
type StagedRow = readonly [string, string | null, number];
/** What a mode makes a path, for a rename pair that must not cross kinds. */
export declare function kindOf(mode: string): string;
/**
* Every path HEAD's tree holds, with its mode and blob id.
*
* Null rather than an empty map when HEAD resolves to nothing: a repository
* before its first commit is a different thing from one whose commit is empty,
* and git says so ("No commits yet").
*
* Resolved through the revision parser so a HEAD detached onto a tag peels to
* the commit it names, rather than being read as a tree it does not have.
*/
export declare function headEntries(repo: Repo): Promise<Map<string, TreeEntry> | null>;
/**
* Fold an add and a delete of the same file into one rename.
*
* Two passes, git's own order: identical content first, then what is merely
* similar enough. Both pair within one kind, and only the second is limited to
* regular files: a moved symlink is a rename git reports as one. Each rename
* carries its similarity, 100 for identical content.
*/
export declare function pairRenames(repo: Repo, staged: ReadonlyMap<string, string>, oids: ReadonlyMap<string, string>, kinds: ReadonlyMap<string, string>, threshold?: number): Promise<Map<string, StagedRow>>;
/** Compare the index with the working tree: what is not staged yet. */
export declare function workChanges(repo: Repo, vfs: Files, worktree: PathSpec, entries: ReadonlyMap<string, IndexEntry>, found: WorkTree): Promise<Map<string, string>>;
/** The index as entries, path to mode and id, conflict stages left out. */
export declare function stagedEntries(state: IndexState): Map<string, TreeEntry>;
/**
* The working tree as entries, for the side `git diff` compares.
*
* The index stands for every file the walk found unchanged; a modified file is
* hashed and its blob held on the repo for this invocation only, as git writes
* nothing on a diff. Untracked files are not part of it. A path the index holds
* only as conflict stages is the file standing there, if any: what a revision
* is compared with, while the index side leaves it out (git shows a combined
* diff there, which is not offered). `roots` (`patternRoots`) narrows the
* walk to what the pathspecs reach; an entry outside them reads as gone, for
* the caller to drop. Mirrors Python's work_entries.
*/
export declare function workEntries(repo: Repo, vfs: Files, state: IndexState, roots?: readonly string[] | null): Promise<Map<string, TreeEntry>>;
/**
* One path's status before renames pair, as the row `status` hands over.
*
* An added and a deleted path stay two rows, so a hide drops either alone and
* the renderer pairs only the renames the session sees. Mirrors Python's
* `StatusRow`.
*/
export interface StatusRow {
/** Where it sits in the session's tree. */
readonly path: PathSpec;
/** Git's repository-relative name; a collapsed untracked directory ends in `/`. */
readonly name: string;
/** HEAD against the index, `?` untracked and `!` ignored. */
readonly indexStatus: string;
/** The index against the working tree. */
readonly treeStatus: string;
/** The kind and blob id of a staged add or delete, which a rename pairs by. */
readonly end: readonly [string, string] | null;
/** Whether the two letters are a conflict code. */
readonly unmerged: boolean;
}
/**
* The status entries the rows a session sees make, renames paired. Mirrors
* Python's `assembled`.
*/
export declare function assembled(repo: Repo, shown: readonly StatusRow[]): Promise<StatusEntry[]>;
/** Everything `status` reports, in one pass over the three sources. */
export declare function collect(repo: Repo, vfs: Files, mode: string, showIgnored?: boolean): Promise<[StatusRow[], IndexState, boolean]>;
export {};
//# sourceMappingURL=changes.d.ts.map