UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

67 lines • 4.07 kB
import type { ByteSource } from '../../../io/types.ts'; import { type PathSpec, type ReadStreamFn } from '../../../types.ts'; import type { Context } from '../../config.ts'; import type { MountView } from '../../../view/types.ts'; import { FlagView } from '../../spec/flag_view.ts'; import type { GrepFlags } from '../grep_binary.ts'; import { type RgFlags } from '../generic/rg.ts'; import type { SearchTerms } from '../types.ts'; import type { CommandFiles } from './files.ts'; /** * What a grep line asks the mount's search; null when it must read every * file: -v, -f, or no plain text of three characters every match holds (under * -i, a word with a non-ASCII letter, or with i, k or s when case folds by * Unicode, counts as none). `f` is the line's flags, parsed. Throws the * refusal grep itself would print for a bad pattern. Mirrors Python's * `grep_terms`. */ export declare function grepTerms(f: GrepFlags, fl: FlagView, texts: string[], utf8: boolean): SearchTerms | null; /** * What an rg line asks the mount's search; null when it must read every file: * -v or --passthru, a listing of files that do not match * (--files-without-match, -c or --count-matches with --include-zero, without * -q; --stats, --json), -L, -z, --pre, -E naming an encoding, -f, or no plain * text every match holds. `f` is the line's flags, parsed. Throws the refusal * rg itself would print for a bad pattern. Mirrors Python's `rg_terms`. */ export declare function rgTerms(f: RgFlags, fl: FlagView, texts: string[]): Promise<SearchTerms | null>; /** * Reads that search what `narrowed` answers for a file. The walk still lists, * filters, orders and labels every file; a file `narrowed` answers empty * prints exactly what one with no match would (-c counts 0, -L lists it), one * it answers with lines is searched over them, and null reads the file. * Mirrors Python's `candidate_reads`. */ export declare function candidateReads(stream: ReadStreamFn, narrowed: (p: PathSpec) => Promise<ByteSource | null>): ReadStreamFn; /** * Reads that stop each walk at its mount's `walkLimit`. A file counts * once against the deepest walked operand above it, so a file named as an * operand counts nothing; the one past the limit throws WalkLimitError in its * place, and grep or rg stops walking the directory. The charge is returned * too, for a file whose matching lines the mount's search hands over in place * of a read; a file the search rules out is never read, so it costs nothing. * Mirrors Python's `capped_reads`. */ export declare function cappedReads(stream: ReadStreamFn, operands: readonly PathSpec[], mounts: MountView | undefined): [ReadStreamFn, (p: PathSpec) => void]; /** * grep's or rg's reads, narrowed by the mount's search where it can. * `filesContaining` rules out walked files no match can be in, of those the * mount's `searchable` names, and `linesContaining` hands a file's matching * lines in its place when the output shows nothing else, or tells whether it * is worth reading. An operand * named on the line is never ruled out by a search asked about directories, * nor is a path pinned to a revision, since a search sees the current content, * nor a file the read cache holds (`isWarm`), which a read serves as it was * cached, nor a path a link leads elsewhere, which the mount's search never * sees. * Both are asked through the dispatcher, which drops what the session hides * from a `filesContaining` answer, judges `linesContaining` as a read of its * file, judges each file a search rules out as the read it stands in for (the * `isWarm` call), so a file a path rule refuses reports `Permission denied`, * and answers null where a coded preVfs policy reaches below a directory, so * every file is read and judged. * Each walk stops at its mount's `walkLimit` (`cappedReads`). * Mirrors Python's `search_reads`. */ export declare function searchReads(files: CommandFiles, name: 'grep' | 'rg', paths: PathSpec[], texts: string[], ctx: Context): Promise<ReadStreamFn>; //# sourceMappingURL=search.d.ts.map