Skip to main content

Crate harness_grep

Crate harness_grep 

Source
Expand description

Grep tool — Rust port of @agent-sh/harness-grep.

Conforms to agent-knowledge/design/grep.md (language-neutral spec). Public surface mirrors the TS package: grep(params, session) returns a discriminated GrepResult union. Alias pushback, zero-match hint, NOT_FOUND with fuzzy siblings, INVALID_REGEX with escape hint — all carry over.

Engine: BurntSushi/ripgrep’s library form (grep-searcher + grep-regex) and ignore for .gitignore-aware file walking. No WASM, no shell-out.

Structs§

ContentMeta
ContentResult
CountMeta
CountResult
ErrorResult
FilesMatchMeta
FilesMatchResult
GrepEngineInput
Inputs to the engine. Shape-compatible with the TS GrepEngineInput; the only divergence is signal — Rust tool calls don’t take an explicit cancel signal at this layer (yet), so the engine runs to natural completion.
GrepParams
Parsed + validated input params. Mirrors GrepParams in TS — all fields optional except pattern. The camelCase→snake_case rename at the wire boundary is handled by serde rename_all.
GrepSessionConfig
RgCount
Per-file count from the engine. Mirrors TS RgCount.
RgMatch
One matching line from the engine. Mirrors TS RgMatch.

Enums§

GrepOutputMode
GrepParseError
Errors produced by the parsing/validation layer. These always end up as INVALID_PARAM with the .message() rendered into the tool error.
GrepResult

Constants§

DEFAULT_HEAD_LIMIT
DEFAULT_OFFSET
DEFAULT_TIMEOUT_MS
FUZZY_SUGGESTION_LIMIT
GREP_MAX_BYTES
GREP_MAX_FILE_SIZE
GREP_MAX_LINE_LENGTH
GREP_TOOL_DESCRIPTION
GREP_TOOL_NAME

Traits§

GrepEngine
Same pluggable-backend idea as the TS GrepEngine: default wraps ripgrep’s library, tests or SSH-remote harnesses can substitute.

Functions§

default_engine
format_content
format_count
format_files_with_matches
grep
Top-level entry point. Parse + fence + engine + format, returning a discriminated result shape. This is the grep() function from the TS package, same contract.
parse_grep_params
safe_parse_grep_params
suggest_siblings
Return up to FUZZY_SUGGESTION_LIMIT entries in the parent directory of missing_path that look like its basename, sorted most-similar first. Same algorithm as the TS suggestSiblings.