API Reference

Core data types, discovery functions, and the search pipeline used by every surface (CLI, TUI, MCP).

Core data

class agentgrep.PrivatePath
class
class
class agentgrep.PrivatePath

Bases: PosixPath

Path subclass that hides the user’s home directory in textual output.

agentgrep.format_display_path(path, *, directory=False)
function
function
agentgrep.format_display_path(path, *, directory=False)

Return a privacy-safe display path.

Parameters:
Return type:

str

class agentgrep.BackendSelection
class
class
class agentgrep.BackendSelection

Bases: object

Selected optional subprocess backends.

class agentgrep.SearchQuery
class
class
class agentgrep.SearchQuery

Bases: object

Compiled search configuration.

compiled carries the parsed-query predicates from agentgrep.query. When None (the default), the engine takes its legacy code path — pure-text queries and flag-only invocations stay on the fast path with no extra evaluation cost. When set, iter_search_events consults compiled.source_predicate to prune sources before any file is opened, and matches_record() consults compiled.record_predicate after the existing text match. match_surface lets line-oriented callers such as grep require a match in record text while fuzzy search and filtering can keep using the metadata-rich haystack.

class agentgrep.SourceHandle
class
class
class agentgrep.SourceHandle

Bases: object

A discovered, parseable source file or SQLite database.

class agentgrep.SearchRecord
class
class
class agentgrep.SearchRecord

Bases: object

Normalized prompt/history record.

class agentgrep.FindRecord
class
class
class agentgrep.FindRecord

Bases: object

Normalized discovery record for agentgrep find.

Search control and progress

class agentgrep.SearchControl
class
class
class agentgrep.SearchControl

Bases: object

Thread-safe cooperative controls for an active search.

class agentgrep.SearchProgress
class
class
class agentgrep.SearchProgress

Bases: Protocol

Progress reporter used by search internals.

class agentgrep.NoopSearchProgress
class
class
class agentgrep.NoopSearchProgress

Bases: object

Silent search progress reporter.

class agentgrep.ConsoleSearchProgress
class
class
class agentgrep.ConsoleSearchProgress

Bases: object

Human progress reporter for potentially long searches.

class agentgrep.SearchRuntime
class
class
class agentgrep.SearchRuntime

Bases: object

Reusable, explicit runtime state for one search frontend/session.

class agentgrep.SourceScanCache
class
class
class agentgrep.SourceScanCache

Bases: object

Bounded, in-process cache for reusable source-scan results.

class agentgrep.SourceScanCacheStats
class
class
class agentgrep.SourceScanCacheStats

Bases: object

Privacy-safe counters for one source-scan cache.