UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

79 lines • 4.46 kB
import type { FileStat, PathSpec, StatFn } from '../../types.ts'; import type { FileTypes } from './rg_filetypes.ts'; import { IgnoreRules, type Overrides } from './rg_glob.ts'; import type { LinkResolver } from './utils/links.ts'; import type { AsyncReaddirFn } from './utils/types.ts'; import type { MountRoot } from '../../view/types.ts'; /** * What ripgrep's walker keeps below a directory operand. The ignore crate's * order: a `-g` glob decides first and outranks everything after it, then * `-t`/`-T`, and a dot entry is left out unless a glob or a `-t` type kept * it or `--hidden` is on. A file is also left out past `--max-filesize`, * and for a binary extension unless `-a`/`--binary` asked for it. A name on * the line is never filtered: only walked entries are. `maxDepth` is the * deepest entry kept (1 is the operand's own children). */ export declare class WalkFilter { readonly overrides: Overrides; readonly types: FileTypes; readonly hidden: boolean; readonly maxDepth: number | null; readonly maxFilesize: number | null; readonly binary: boolean; readonly ignores: IgnoreRules; constructor(overrides: Overrides, types: FileTypes, hidden: boolean, maxDepth: number | null, maxFilesize: number | null, binary: boolean, ignores?: IgnoreRules); admits(candidate: string, name: string, isDir: boolean): boolean; admitsFile(candidate: string, name: string, stat: FileStat | null): boolean; } /** * One input rg searches: its virtual path (`-` for stdin), the path rg * prints for it, its stat when the walk read one (the time sorts read it), * the operand itself when it was named on the line, which a stream read * takes, and the dispatcher a file the walk reached through a link is read * through, since the link may lead onto a mount the operand's backend * cannot read. */ export interface Haystack { virtual: string; shown: string; stat: FileStat | null; spec: PathSpec | null; resolver: LinkResolver | null; } /** * An OS error the way ripgrep's Rust `io::Error` displays it: the strerror, * then the Linux errno it came from (`No such file or directory (os error * 2)`). A failure the vocabulary cannot number keeps its words alone. * Mirrors Python's os_error_text. */ export declare function osErrorText(err: unknown): string; export declare function walkErrorLine(shown: string, err: unknown, parallel?: boolean): string; export declare function loopErrorLine(shown: string, ancestor: string): string; export declare function openErrorLine(shown: string, err: unknown): string; /** * --one-file-system's test: whether a directory lies on another mount than * the operand's. A mount is mirage's filesystem boundary, which a directory * crosses by being a mount root and a link by leading onto another mount. * `path` has every link resolved. Mirrors Python's on_other_mount. */ export declare function onOtherMount(rootOf: MountRoot, home: string, path: string): boolean; /** * The files a walk of one directory operand searches, in walk order. `root` * is the operand's virtual path and `shownRoot` the operand as typed, which * every printed path below it starts with (empty for the implicit cwd, whose * matches print bare while the walker names `./x`); `cwd` is the root the * globs are matched from. `sortByName` is --sort path, each directory's * entries in name order rather than the backend's. `boundary` is * --one-file-system's test for a directory on another mount than the * operand's, which the walk does not enter, or null to enter everything. * `resolver` is the namespace's links and the dispatcher past them, null outside a * workspace, where no link can stand. * * A link the walk meets is skipped, as ripgrep skips one, unless `follow` * (-L) says to walk through it: then it stands for what it leads to, a * directory descended and a file searched under the link's own name, and * one that dangles, loops or leads back to a directory above it is reported * in ripgrep's words and skipped. Mirrors Python's walk_haystacks. */ export declare function walkHaystacks(readdirFn: AsyncReaddirFn, statFn: StatFn<[path: string]>, root: string, shownRoot: string, cwd: string, walk: WalkFilter, sortByName: boolean, warnings: string[] | null, boundary?: ((path: string) => boolean) | null, resolver?: LinkResolver | null, follow?: boolean, parallel?: boolean): AsyncGenerator<Haystack>; //# sourceMappingURL=rg_scan.d.ts.map