utils/ripgrep/ripgrep_utils library

Classes

RipgrepConfig
Configuration for how to invoke ripgrep.
RipgrepStatus
Singleton to store ripgrep availability status.

Enums

RipgrepMode
Ripgrep execution mode.

Constants

kDefaultTimeoutMs → const int
Default timeout for ripgrep operations (20 seconds, 60 for WSL).
kMaxBufferSize → const int
Maximum buffer size for ripgrep output (20MB). Large monorepos can have 200k+ files.
kWslTimeoutMs → const int

Functions

countFilesRoundedRg(String dirPath, {List<String> ignorePatterns = const [], Duration? timeout}) Future<int?>
Count files in a directory recursively using ripgrep and round to the nearest power of 10 for privacy.
getRipgrepConfig({bool? useSystemRipgrep, bool? isBundledMode, String? vendorRoot}) RipgrepConfig
Get the ripgrep configuration. Determines whether to use system, builtin, or embedded ripgrep. Memoized after first call.
getRipgrepStatus() → ({RipgrepMode mode, String path, bool? working})
Get ripgrep status and configuration info. Returns current configuration immediately, with working status if available.
resetFileCountCache() → void
Reset the file count cache (useful for testing).
resetRipgrepConfig() → void
Reset the cached config (useful for testing).
ripGrep(List<String> args, String target, {Duration? timeout}) Future<List<String>>
Execute ripgrep with the given arguments and target directory/file. Returns a list of matching lines.
ripgrepCommand() → ({String? argv0, List<String> rgArgs, String rgPath})
Public accessor for ripgrep command components.
ripGrepFileCount(List<String> args, String target, {Duration? timeout}) Future<int>
Stream-count lines from rg --files without buffering stdout.
ripGrepStream(List<String> args, String target, {required void onLines(List<String> lines)}) Future<void>
Stream lines from ripgrep as they arrive, calling onLines per stdout chunk.

Exceptions / Errors

RipgrepTimeoutError
Custom error class for ripgrep timeouts. Allows callers to distinguish between "no matches" and "timed out".