@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
151 lines • 6.25 kB
TypeScript
import { type TreeObject } from 'isomorphic-git';
import { type Repo } from './repo.ts';
import type { GitObject, RepoLocation } from './types.ts';
/** A leaf as a tree or the index lists it: its mode and its object id. */
interface Entry {
readonly mode: string;
readonly oid: string;
}
/**
* Whether a hide or a rule in force could cover anything in the repository's
* working tree for the running command; when nothing can, every object is shown
* as stored and nothing is looked up.
*
* @param repo the opened repository
*/
export declare function guarded(repo: Repo): boolean;
/**
* Refuse a place as the dispatcher refuses its file: a rule in force for the
* running command throws `PolicyDenied` naming it.
*
* @param location the discovered repository
* @param relative the repository-relative place
*/
export declare function checkRules(location: RepoLocation, relative: string): void;
/**
* Whether a rule in force could refuse anything at or under a place for the
* running command; when none can, nothing there is asked.
*
* @param location the discovered repository
* @param relative the repository-relative place, the root by default
*/
export declare function ruledUnder(location: RepoLocation, relative?: string): boolean;
/**
* Whether no rule in force refuses a place for the running command, asked
* without refusing it.
*
* @param location the discovered repository
* @param relative the repository-relative place
*/
export declare function permitted(location: RepoLocation, relative: string): boolean;
/**
* An object a revision found at a place, which the session may be shown there:
* noted, so a tree prints what that place holds, and a blob's content refused
* where a rule keeps the place from the command. A rule guards content, not
* names, so a tree is listed.
*
* The caller has already refused a hidden place in its own words.
*
* @param repo the opened repository
* @param obj the object found
* @param relative the repository-relative place
* @param revision the operand that named it, whose place this is whatever other
* place holds the same object
*/
export declare function placed<T extends GitObject>(repo: Repo, obj: T, relative: string, revision?: string | null): T;
/**
* Note a commit's tree, which stands at the repository's root.
*
* @param repo the opened repository
* @param tree the root tree's id
* @param revision the operand that named it
*/
export declare function rooted(repo: Repo, tree: string, revision?: string | null): void;
/**
* An object named by id, if the session may be shown it: one reachable at a
* place it sees and no rule keeps from the command; null when it is shown
* nowhere.
*
* A commit and a tag carry no place and are always shown. A tree or a blob is
* looked for where the history and the index hold it, so an id an agent
* computed for content it guessed answers exactly as an id nothing holds. A
* blob held only where a rule keeps it throws that rule's `PolicyDenied`.
*
* @param repo the opened repository
* @param obj the object the id names
*/
export declare function located<T extends GitObject>(repo: Repo, obj: T): Promise<T | null>;
/**
* Whether an id names an object the session may be shown: one the store holds,
* which `located` finds wherever it stands.
*
* @param repo the opened repository
* @param oid the object's id
*/
export declare function visibleObject(repo: Repo, oid: string): Promise<boolean>;
/**
* Where this command found an object, for a tree whose entries are shown
* relative to it; the root when nothing narrows what is shown.
*
* @param repo the opened repository
* @param oid the object's id
*/
export declare function placeOf(repo: Repo, oid: string): Promise<string>;
/**
* Where the object an operand names stands for that operand: the place its own
* path gave it (`HEAD:b` is `b` even where `HEAD:a` holds the same tree), else
* where this command found it.
*
* @param repo the opened repository
* @param name the operand as typed
* @param oid the object's id
*/
export declare function placeNamed(repo: Repo, name: string, oid: string): Promise<string>;
/**
* A tree's entries the session sees, at the place it was found.
*
* @param repo the opened repository
* @param tree the tree's id
* @param base the place it stands at, null for where this command found it
*/
export declare function shownItems(repo: Repo, tree: string, base?: string | null): Promise<TreeObject>;
/**
* An object's stored bytes as the session is shown them: a tree's with only the
* entries it sees, so neither the bytes nor their count name a hidden one. Only
* a tree is placed, so a commit's or a blob's bytes cost no lookup.
*
* A tree's entries stand in its bytes in git's order, each its mode, its name
* and its id, so dropping the ones the session does not see leaves exactly the
* tree git would store for the rest.
*
* @param repo the opened repository
* @param obj the object
* @param name the operand that named it, whose place a tree is listed at; null
* for where this command found it
*/
export declare function shownRaw(repo: Repo, obj: GitObject, name?: string | null): Promise<Uint8Array>;
/**
* A tree's leaves the session sees, keyed relative to `base`.
*
* What a diff, a log or a search reads its sides from, so a hidden path is no
* change, no match and no count, as if never committed. A leaf at a place a
* rule keeps from the command stays listed, a rule guarding content rather
* than names, and its blob is noted so `readable` refuses to read it there.
*
* @param repo the opened repository
* @param entries leaves keyed by git name
* @param base the place the tree stands at
*/
export declare function shownEntries(repo: Repo, entries: ReadonlyMap<string, Entry>, base?: string): Map<string, Entry>;
/**
* Refuse a blob's content where this command found it only at a place a rule
* keeps from it: the same bytes anywhere it may read are no secret, so those
* read.
*
* @param repo the opened repository
* @param sha the blob's id
* @throws PolicyDenied the rule's refusal, naming the place
*/
export declare function readable(repo: Repo, sha: string): void;
export {};
//# sourceMappingURL=seen.d.ts.map