Expand description
File walking, binary detection, and text-read helpers shared by CLI commands.
size-waiver: accepted single-domain bulk (policy #1408). One module owns ignore-aware walks, glob/exclude filtering, binary/UTF-8 guards, and path-missing helpers used by search/replace/tidy; co-located unit tests push the file over 1000 lines. Do not split for LOC alone.
§Text I/O honesty (#1894)
- Strict sole-path:
load_text_strict— binary →BinaryError, invalid UTF-8 →InvalidEncodingError(CLI, MCP/tx sole path, libraryapi::*). - Soft content skip (walks):
try_read_text_file/read_text_file— binary / invalid UTF-8 →SoftTextSkip(content not agent-editable). - Unreadable is not content SoftSkip: open/read IO is
SoftTextSkip::Unreadable. Callers decide: directory walks may continue but must not report patternno_matcheswhen unreadable paths may have masked the scan; sole paths use Strict IO errors. - Byte rule:
classify_text_bytes(NUL probe + UTF-8).
Enums§
- Soft
Text Skip - Why a soft walk skipped a path (#1894).
- Text
Bytes Kind - Result of classifying on-disk (or in-memory) bytes as agent-editable text.
Functions§
- build_
glob_ matcher - Build a compiled glob matcher from globs, or
Noneif no globs given. Available for library use when “files” feature is enabled. - classify_
text_ bytes - Classify bytes as text, binary, or invalid UTF-8.
- collect_
file_ paths - Simple file collection for library use (sequential for simplicity; full parallel in par_process_files).
- collect_
file_ paths_ with_ ignores - Collect files while respecting .gitignore + custom ignore files (e.g. .agentignore)
- collect_
glob_ roots - Collect roots used for matching globs against walked files. Lib version.
- is_
binary - is_
binary_ file - Returns whether the file at
pathappears to be binary by reading only its first 8 KiB (streaming, no full allocation for large files). - load_
text_ strict - Load a path as UTF-8 text under the Strict sole-path policy (#1894).
- matches_
glob - Check whether
pathmatches any of the globs (always true if no globs). - matches_
glob_ with_ roots - Check whether
pathmatches any of the globs, either directly or relative to one of the provided roots (always true if no globs). - par_
process_ files - Process file paths using adaptive parallelism via
std::thread::scope. - read_
text_ file - Soft-skip text load for walks; collapses all skip reasons to
None. - relative_
display - Compute a display-friendly relative path by stripping a
baseprefix. - try_
read_ text_ file - Soft-path text load with typed skip reason (#1894).