API Reference¶
Core data types, discovery functions, and the search pipeline used by every surface (CLI, TUI, MCP).
Core data¶
-
class agentgrep.PrivatePath¶class agentgrep.PrivatePath¶
Bases:
PosixPathPath subclass that hides the user’s home directory in textual output.
-
agentgrep.format_display_path(path, *, directory=False)¶agentgrep.format_display_path(path, *, directory=False)¶
Return a privacy-safe display path.
-
class agentgrep.BackendSelection¶class agentgrep.BackendSelection¶
Bases:
objectSelected optional subprocess backends.
-
class agentgrep.SearchQuery¶class agentgrep.SearchQuery¶
Bases:
objectCompiled search configuration.
compiledcarries the parsed-query predicates fromagentgrep.query. WhenNone(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_eventsconsultscompiled.source_predicateto prune sources before any file is opened, andmatches_record()consultscompiled.record_predicateafter the existing text match.match_surfacelets line-oriented callers such asgreprequire a match in record text while fuzzy search and filtering can keep using the metadata-rich haystack.
-
class agentgrep.SourceHandle¶class agentgrep.SourceHandle¶
Bases:
objectA discovered, parseable source file or SQLite database.
Search control and progress¶
-
class agentgrep.SearchControl¶class agentgrep.SearchControl¶
Bases:
objectThread-safe cooperative controls for an active search.
-
class agentgrep.SearchProgress¶class agentgrep.SearchProgress¶
Bases:
ProtocolProgress reporter used by search internals.
-
class agentgrep.NoopSearchProgress¶class agentgrep.NoopSearchProgress¶
Bases:
objectSilent search progress reporter.
-
class agentgrep.ConsoleSearchProgress¶class agentgrep.ConsoleSearchProgress¶
Bases:
objectHuman progress reporter for potentially long searches.
-
class agentgrep.SearchRuntime¶class agentgrep.SearchRuntime¶
Bases:
objectReusable, explicit runtime state for one search frontend/session.
Discovery and search¶
-
agentgrep.select_backends()¶agentgrep.select_backends()¶
Return the best available subprocess helpers.
- Return type:
-
agentgrep.discover_sources(home, agents, backends, *, include_non_default=False, version_detail='shape', store_roles=None)¶agentgrep.discover_sources(home, agents, backends, *, include_non_default=False, version_detail='shape', store_roles=None)¶
Discover all known parseable sources for the selected agents.
version_detailcontrols how eagerly source handles are enriched:"none"leavesversion_detectionempty for fast search paths,"catalog"attaches low-cost catalog observations, and"shape"inspects concrete source shape for inventory surfaces.store_roleslets latency-sensitive search paths enumerate only the catalogue roles that can satisfy a coarse query scope.- Parameters:
home (
Path)agents (
tuple[AgentName, ...])backends (
BackendSelection)include_non_default (
bool)version_detail (
DiscoveryVersionDetail)store_roles (
DiscoveryStoreRoles)
- Return type:
-
agentgrep.run_search_query(home, query, *, backends=None, progress=None, control=None, runtime=None)¶agentgrep.run_search_query(home, query, *, backends=None, progress=None, control=None, runtime=None)¶
Discover sources and run a normalized search query.
- Parameters:
home (
Path)query (
SearchQuery)backends (
BackendSelection|None)progress (
SearchProgress|None)control (
SearchControl|None)runtime (
SearchRuntime|None)
- Return type:
-
agentgrep.search_sources(query, sources, backends, *, progress=None, control=None, runtime=None)¶agentgrep.search_sources(query, sources, backends, *, progress=None, control=None, runtime=None)¶
Parse and filter search results across all selected sources.
- Parameters:
query (
SearchQuery)sources (
list[SourceHandle])backends (
BackendSelection)progress (
SearchProgress|None)control (
SearchControl|None)runtime (
SearchRuntime|None)
- Return type:
-
agentgrep.run_find_query(home, agents, *, pattern, limit, backends=None)¶agentgrep.run_find_query(home, agents, *, pattern, limit, backends=None)¶
Discover sources and build normalized
findresults.- Parameters:
- Return type: