UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

86 lines • 4.28 kB
export declare function norm(path: string): string; export declare function globPrefixMatch(path: string, pattern: string): boolean; export declare function resolvePath(path: string, cwd: string): string; export declare function posixNormpath(path: string): string; /** * The absolute spelling of a typed path whose dots a walk proves. * * The kernel resolves `.` and `..` against the directory they sit in, so * every component in front of one has to be a directory, while the textual * simplification a virtual path gets lets `nope/../f` reach `f` past a * missing `nope`. This keeps the spelling a walk needs. A trailing slash is * kept too, since `x/` resolves as `x/.` and so names a directory. Null when * neither follows a named component: a leading climb (`../x`) only walks up * from `base`, a directory already, so the common `cd ..` and `cat ../f` * cost nothing. Mirrors Python's dotted_spelling. */ /** * Whether a name's last component, before any trailing slash, is `.` or * `..`: then a trailing slash says nothing on its own, and the walk through * the dot answers first (`missing/./` is ENOENT, `f/./` ENOTDIR, where * `missing/` and `f/` are EISDIR). */ export declare function endsAtDot(spelling: string): boolean; export declare function dottedSpelling(word: string, base?: string): string | null; /** * The directories a walk of `dotted` has to find, in walk order. * * Whatever stands in front of a `.` or `..` is where it resolves, so it has * to be a directory; each is spelled as the walk has simplified it so far, * and the root, always one, is left out. Mirrors Python's dot_prefixes. */ export declare function dotPrefixes(dotted: string, follow?: ((path: string) => string) | null): string[]; /** * The names a walk of `dotted` looks up in front of a dot, in walk order, * each as the walk reached it and before a link there is followed: the * simplified path no longer names them, so a hide has to answer for them * here. A caller that stops at one never follows it. Mirrors Python's * dot_lookups. */ export declare function dotLookups(dotted: string, follow?: ((path: string) => string) | null): Generator<string>; /** * The names a walk of `dotted` enters, each with its spelling in `raw`. * * What `mkdir -p` creates on the way and names when it cannot: GNU makes each * component as it reaches it, so `mkdir -p nope/../m` leaves `nope` behind as * well as `m`, and a plain file in the way is quoted as the operand spells it * (`'a.txt'`, not the absolute path). Only the typed components are entered: * the directory a relative word starts from is there already. Mirrors * Python's walk_nodes. */ export declare function walkNodes(dotted: string, raw: string, follow?: ((path: string) => string) | null): [string, string][]; export declare function expandTilde(word: string, home: string | null): string; export declare function respellRaw(paths: string[], virtual: string, raw: string): string[]; export declare function dropTrailingSegments(path: string, count: number): string; export declare function respellOne(path: string, virtual: string, raw: string): string; export declare function parent(path: string): string; export declare function ancestors(path: string): string[]; export declare const MAX_SYMLINK_HOPS = 40; export interface LinkFollow { readonly kind: 'follow'; readonly path: string; } export interface LinkEnter { readonly kind: 'enter'; readonly path: string; readonly nextIsParent: boolean; } export interface LinkLanding { readonly kind: 'landing'; readonly path: string; } export interface LinkHopLimit { readonly kind: 'hop_limit'; } export type LinkStep = LinkFollow | LinkEnter | LinkLanding | LinkHopLimit; export declare class CycleError extends Error { readonly path: string; readonly code = "ELOOP"; readonly virtualPath: string; constructor(path: string); } export declare function resolveSymlinks(path: string, links: ReadonlyMap<string, string>): string; export declare function traceSymlinks(path: string, links: ReadonlyMap<string, string>): LinkStep[]; export declare function gnuBasename(path: string, suffix?: string): string; export declare function gnuDirname(path: string): string; //# sourceMappingURL=path.d.ts.map