UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

51 lines • 2.36 kB
import type { FlagView } from '../spec/flag_view.ts'; /** * GNU's file-selection flags, threaded as one value. * * `fileGlobs` holds the --include/--exclude rules in command-line * order (the order decides ties, see `fileAdmitted`), `excludeDir` * prunes directories from the -r walk, and `text` (-a) lets the walk * read the extensions it would otherwise skip as binary. The empty * value admits everything, which is what every caller without the * flags passes. */ /** One --include/--exclude rule: a basename glob and its verdict. */ export interface FileGlob { glob: string; admit: boolean; } export interface WalkFilters { fileGlobs: readonly FileGlob[]; excludeDir: readonly string[]; text: boolean; } /** * The --include/--exclude rules a line typed, in line order, an * --exclude-from's globs (read by the executor) where it stood. * * The bag lists each dest's values in occurrence order and the dests * themselves in first-typed order, so the rebuilt list is exact unless * a line alternates the two kinds three or more times (`--include a * --exclude b --include c`), where each kind's rules stay grouped at * its first position. Deliberate approximation: the bag is the only * channel a generic reads, and it carries no per-occurrence positions * across two dests. */ export declare function parseFileGlobs(fl: FlagView): readonly FileGlob[]; /** * GNU's --include/--exclude gate for one candidate file. * * Globs match the base name with fnmatch wildcards, case sensitively (a * glob carrying a slash therefore matches nothing, which is what GNU * 3.11 answers too). The rules resolve in command-line order: the last * matching rule decides, and a file matching none is admitted only when the * first rule is an exclude (both pinned against GNU 3.11, where * `--include='*.txt' --exclude='*.txt'` skips a .txt file and the reversed * order searches it). Applies to command-line files exactly as to walked * ones, which is pinned GNU behavior: an explicit operand --include passes * over is silently no match, not an error. */ export declare function fileAdmitted(path: string, filters: WalkFilters): boolean; /** Whether the -r walk may descend into this directory. */ export declare function dirAdmitted(path: string, filters: WalkFilters): boolean; //# sourceMappingURL=grep_select.d.ts.map