@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
80 lines • 3.77 kB
TypeScript
import { UsageError } from '../errors.ts';
export declare const UNCLOSED_CLASS = "unclosed character class; missing ']'";
export declare const UNCLOSED_ALTERNATES = "unclosed alternate group; missing '}' (maybe escape '{' with '[{]'?)";
export declare const UNOPENED_ALTERNATES = "unopened alternate group; missing '{' (maybe escape '}' with '[}]'?)";
export declare const NESTED_ALTERNATES = "nested alternate groups are not allowed";
export declare const DANGLING_ESCAPE = "dangling '\\'";
/**
* What one of ripgrep's path matchers says about a path: nothing, leave it
* out, or keep it whatever the later filters would say (the ignore crate's
* `Match`).
*/
export declare enum Verdict {
NONE = "none",
IGNORE = "ignore",
WHITELIST = "whitelist"
}
export declare function globError(glob: string, reason: string): UsageError;
/**
* ripgrep's glob syntax as one anchored matcher: globset with literal
* separators and backslash escapes, which is what ripgrep builds every `-g`
* and `--type` glob with. `*` and `?` stay inside one path component, `**`
* spans components, `[...]` and `{a,b}` are classes and alternatives.
* `shown` is the glob as the line typed it, when that is not `glob` itself
* (a `-g` line after ignore-rule rewriting), for the refusal wording.
*/
export declare function compileGlob(glob: string, caseInsensitive?: boolean, shown?: string): RegExp;
/**
* One `-g` glob read as ripgrep reads it: a gitignore line whose sense is
* inverted, so a plain glob keeps a path and `!glob` drops it. `dirOnly`:
* the glob ended in `/`, so it speaks only for directories.
*/
export interface OverrideGlob {
matcher: RegExp;
keep: boolean;
dirOnly: boolean;
}
/**
* Parse one `-g` value the way the ignore crate parses a gitignore line, or
* null for a line that says nothing (empty, or a `#` comment). A glob with
* no `/` in it matches at any depth; one with a `/`, or a leading `/`, is
* anchored to the path as walked. A trailing `/` limits it to directories,
* and `dir/**` keeps everything below the directory but not the directory
* itself.
*/
export declare function overrideGlob(line: string, caseInsensitive: boolean): OverrideGlob | null;
/**
* ripgrep's `-g`/`--iglob` matcher (the ignore crate's `Override`). The last
* glob that matches a path decides it, a `!` one dropping it and a plain one
* keeping it whatever the type and hidden filters would say. Once any plain
* glob exists, a file no glob matches is dropped, while a directory no glob
* matches is still walked. `iglobs` come after every `-g`, whatever order
* the line gave them.
*/
export declare class Overrides {
private readonly globs;
private readonly keeps;
constructor(globs: readonly string[], iglobs: readonly string[], caseInsensitive: boolean);
verdict(path: string, isDir: boolean): Verdict;
}
/**
* --ignore-file's rules: gitignore lines rooted at the working directory, the
* last one that matches a walked path deciding it, a plain one ignoring it and
* a `!` one keeping it. Mirrors Python's IgnoreRules.
*/
export declare class IgnoreRules {
private readonly globs;
constructor(lines?: readonly string[]);
/** Whether the files held no rule. */
get empty(): boolean;
/** What the rules say about one walked path (`walkCandidate`). */
verdict(path: string, isDir: boolean): Verdict;
}
/**
* The path ripgrep matches a walked entry's globs against: the walked path
* as printed, with a leading `./` dropped and the working directory stripped
* off an absolute one, which is what the ignore crate's `strip` does with
* the override root (the cwd).
*/
export declare function walkCandidate(shown: string, cwd: string): string;
//# sourceMappingURL=rg_glob.d.ts.map