/** * Searching a task's output file for a plain substring. * * The tail reader answers "what did it say last"; this one answers "where does it * say X", so it walks the whole file instead of its end — a twenty megabyte * output is read in chunks and never lands in memory at once. The answer is * bounded the same way every other reader of these files is: by matching lines * returned and by the bytes the rendered `line: text` list may spend. The match * count keeps running after both caps stop collecting, because the caller has to * be able to say how many matches it left out. * * There is no pattern language here on purpose: a substring is what a model * asking "where does it say this" means, and a regex is one more thing a caller * can get subtly wrong. Case folding is the only option. * * Bytes become text through `decodeOutput`, the decoder `pretty_task_bg_logs`, the panel and * the completion notice already share (ADR-0008). It is applied per line, so one * file can hold strict UTF-8 and a legacy console's code page side by side. A * line longer than one read is walked in segments with a raw-byte carry, so a * pattern split across two of them is still found, and only the first segment is * kept for display. * * @author mystery4f <40482524+mystery4f@users.noreply.github.com> */ /** Matching lines one answer returns when the caller names no cap. */ export declare const DEFAULT_SEARCH_MATCHES = 50; /** Hard ceiling on matching lines one answer may return, whatever the caller asks. */ export declare const MAX_SEARCH_MATCHES = 500; /** Bytes one rendered `line: text` list may spend when the caller names no cap. */ export declare const DEFAULT_SEARCH_BYTES: number; export interface OutputSearchOptions { /** Literal text to look for; `.` and `*` are ordinary characters. */ pattern: string; /** Match regardless of case. Defaults to true. */ ignoreCase?: boolean; /** Matching lines to return at most; defaults to 50, capped at 500. */ maxMatches?: number; /** Bytes the rendered list may spend; defaults to 8 KiB. */ maxBytes?: number; /** Platform whose console encoding the reader falls back to; defaults to this host. */ platform?: NodeJS.Platform; } /** One matching line. */ export interface OutputMatch { /** 1-based line number in the output file. */ line: number; /** The line's text without its line ending, shortened when a cap demanded it. */ text: string; } /** What a search found, whether or not the caps let it return everything. */ export interface OutputSearch { readonly matches: readonly OutputMatch[]; /** Matching lines in the whole file, returned or not. */ readonly total: number; /** Matching lines found after the match cap or the byte cap stopped collecting. */ readonly omitted: number; /** Lines the reader walked: the whole file, never a tail of it. */ readonly scannedLines: number; /** True when a returned line's text is shorter than the line it came from. */ readonly clipped: boolean; } /** * A match cap is a whole number of lines between 1 and the ceiling. A value the * caller cannot have means the default, never a silent zero: an answer of "no * matches" caused by a bad cap would read as an answer about the output. */ export declare function clampSearchMatches(value?: number): number; /** Search one output file. A file that does not exist yet has no matches. */ export declare function searchOutputFile(path: string, options: OutputSearchOptions): Promise;