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§
- Content
Meta - Content
Result - Count
Meta - Count
Result - Error
Result - Files
Match Meta - Files
Match Result - Grep
Engine Input - Inputs to the engine. Shape-compatible with the TS
GrepEngineInput; the only divergence issignal— Rust tool calls don’t take an explicit cancel signal at this layer (yet), so the engine runs to natural completion. - Grep
Params - Parsed + validated input params. Mirrors
GrepParamsin TS — all fields optional exceptpattern. The camelCase→snake_case rename at the wire boundary is handled by serderename_all. - Grep
Session Config - RgCount
- Per-file count from the engine. Mirrors TS
RgCount. - RgMatch
- One matching line from the engine. Mirrors TS
RgMatch.
Enums§
- Grep
Output Mode - Grep
Parse Error - Errors produced by the parsing/validation layer. These always end up
as
INVALID_PARAMwith the.message()rendered into the tool error. - Grep
Result
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§
- Grep
Engine - 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_LIMITentries in the parent directory ofmissing_paththat look like its basename, sorted most-similar first. Same algorithm as the TSsuggestSiblings.