UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

70 lines • 4 kB
import type { HiddenPaths, Visibility } from '../types.ts'; /** Whether a document entry is a pattern (any of `*`, `?`, `[`). */ export declare function isGlob(entry: string): boolean; /** * Compile document path entries into the matcher's shape: glob = * pattern, plain = exact subtree, in the order written. The same split * serves `paths.hide` and a `CommandRule`'s `paths`, so both planes * match the same way. Null when there is nothing to match, * which is what "unrestricted" reads as. */ export declare function classifyPaths(entries: readonly string[]): HiddenPaths | null; /** * The place a show entry anchors to: the entry itself when exact, the * fixed directory above its first glob segment when a pattern. */ export declare function showHead(entry: string): string; /** * Whether one session's path axis leaves this virtual path visible: * the whole composition law for the VFS axis. * * Three steps, each the anchor-depth rule: no hide covers the path and * it is visible; a show covers it more deeply than the deepest hide * and it is visible (hide wins the tie); and a hidden directory stays * visible when a visible show anchors strictly below it, so the road * to a carve-out exists (`hide /repo` + `show /repo/public` keeps * `/repo` listable, holding only the carve-out). */ export declare function pathVisible(vis: Visibility | null | undefined, virtual: string): boolean; /** * Whether relocating `src` to `dst` could surface a hidden path. * * The reveal half of the subtree law: a session's mutation may destroy * what it cannot see (`rm -r`, a remnant `rmdir`), but may never reveal * it, and a rename or a native directory copy is the relocation that * would. A source the session reaches only through a show below it is * hidden itself, so whatever the show does not reopen reveals wherever the * session sees `dst`. Beyond that, three arms, one per entry kind. A * component pattern follows * the name wherever the content goes, so it never reveals. An exact * entry anchored strictly below `src` re-anchors to `dst` plus its * suffix, and reveals when the session would see that mapped path (a * show anchored below the mapped path counts, through `pathVisible`'s * own carve-out rule). An anchored pattern's coverage does not move * with the content, so any pattern whose match space could reach below * `src` refuses, failing toward refusal the way `readonlyBelow` blames * a pattern. */ export declare function moveReveals(vis: Visibility | null | undefined, src: string, dst: string): boolean; /** * Whether a visible name leads where the session cannot see: a link the walk * follows names a hidden path. The walk judges what a link brings in, not the * typed path, which the caller judges whole (a carve-out keeps its hidden * parents traversable): each link's own path, every name a stored target * spells before a later `..` takes it back (`/data/secret/../pub` still * prints `secret`), and the place the walk lands. Such a link is as hidden as * its target, since its listing row, `readlink` and `ls -l` would print the * hidden name; a link that leads nowhere (dangling, or a loop) leads nowhere * hidden. Mirrors Python's leads_hidden. */ export declare function leadsHidden(vis: Visibility | null | undefined, virtual: string, links: ReadonlyMap<string, string>): boolean; export declare function visibleLinks(vis: Visibility | null | undefined, paths: readonly string[], links: ReadonlyMap<string, string>): boolean[]; /** * Whether the session could hide anything at or under this path, for * the view a native walk asks before it trusts the raw tree: a hide at * or under the path, or a pattern whose head could reach it. */ export declare function hiddenUnder(vis: Visibility | null | undefined, virtual: string): boolean; /** Whether the session hides this variable name. */ export declare function varHidden(vis: Visibility | null | undefined, name: string): boolean; //# sourceMappingURL=hidden.d.ts.map