Skip to main content

Module files

Module files 

Source
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, library api::*).
  • 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 pattern no_matches when unreadable paths may have masked the scan; sole paths use Strict IO errors.
  • Byte rule: classify_text_bytes (NUL probe + UTF-8).

Enums§

SoftTextSkip
Why a soft walk skipped a path (#1894).
TextBytesKind
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 None if 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 path appears 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 path matches any of the globs (always true if no globs).
matches_glob_with_roots
Check whether path matches 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 base prefix.
try_read_text_file
Soft-path text load with typed skip reason (#1894).