Skip to main content

Index-free grep-based retrieval primitives for AI agent tool loops

Project description

grepsearch

Index-free, grep-based retrieval primitives for AI agent tool loops. The engine is the ripgrep search core, compiled into a native Python extension, so every query runs at Rust speed with no subprocess overhead and no index to build or sync.

Grep-based retrieval works by running search tools in a reasoning loop instead of pre-embedding a corpus into a vector index. Every query reads the live filesystem, so results are never stale. This package provides the search side of that loop; your agent framework provides the reasoning.

Installation

pip install grepsearch

Prebuilt wheels cover Linux (x86_64, aarch64), macOS (Apple silicon, Intel), and Windows (x64) for Python 3.9 and newer.

Usage

from grepsearch import SearchEngine

engine = SearchEngine("path/to/repo")

# Content search with budgets sized for a context window
result = engine.grep(
    "fn authenticate",
    literal=True,
    context_after=5,
    max_results=40,
    max_bytes=32_000,
)
for file in result.files:
    for match in file.matches:
        print(f"{file.path}:{match.line_number}: {match.line}")

# The result serializes straight into a tool output for a model
tool_output = result.to_json()

# Follow up around a promising hit
piece = engine.read_lines("src/auth.rs", 40, 80)

# Orient in the repository
for entry in engine.list_dir(".", max_depth=2):
    print(entry.path)

# Find files by name
hits = engine.find_files("**/*.toml")

Every grep result carries a truncated flag. When a budget cap stops the search early, the flag tells the caller that more matches may exist, which prevents an agent from mistaking a capped result for a complete one.

Behavior

  • Gitignore, ignore, and hidden file rules are honored by default; disable per engine with respect_gitignore=False or include_hidden=True
  • Binary files are detected and skipped
  • Searches run in parallel across files and release the interpreter lock while running
  • Result ordering is deterministic: files with more matches first, then shallower paths, then lexicographic
  • Errors map to familiar Python exceptions: ValueError for bad patterns, globs, and line ranges; FileNotFoundError for missing paths

Rust

The same engine ships as a Rust crate for agents and CLIs built in Rust: https://crates.io/crates/grepsearch

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grepsearch-0.1.54.tar.gz (27.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

grepsearch-0.1.54-cp39-abi3-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

grepsearch-0.1.54-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

grepsearch-0.1.54-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

grepsearch-0.1.54-cp39-abi3-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

grepsearch-0.1.54-cp39-abi3-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file grepsearch-0.1.54.tar.gz.

File metadata

  • Download URL: grepsearch-0.1.54.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for grepsearch-0.1.54.tar.gz
Algorithm Hash digest
SHA256 9a7eb4760b023fbb0029975fab16903df645f7a062bfb7847e63c147d512c349
MD5 79cc80d30b863ea74d10a5db5bf64fd3
BLAKE2b-256 368e3192bc080e4bd12b764c25057dcf433268d48390681dcb9fc91ef82922fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54.tar.gz:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grepsearch-0.1.54-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: grepsearch-0.1.54-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for grepsearch-0.1.54-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b72c840452f0aee97c3467d057638e3db09b6386fbbe2563bf3ef197020eeab6
MD5 0eda9308ecec280a178029d77926b23e
BLAKE2b-256 2e0feafeeeec4486476396931ad283fe0492da17f09e4ba2434de5228948c3e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54-cp39-abi3-win_amd64.whl:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grepsearch-0.1.54-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for grepsearch-0.1.54-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35cff4694abc8cdc87e6d82e006f7a310b376dd85606d654f1af96b53900b11a
MD5 05f449ee303404cb7d579f41ce1cda37
BLAKE2b-256 51eb79a22a8cb60246de0bd2c8dd68282931cba7c885d7bbf7ee2846d5025c85

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grepsearch-0.1.54-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for grepsearch-0.1.54-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 70cf7bc37067a9cc545e43538972d04047a444042c8f11f19aa22f00639f5f89
MD5 f02fa6846b6010fe3a3fc1faaa3ac638
BLAKE2b-256 180510853d03b34e079471254f6d46e76324a66909dce2abdfff627f97e0e1f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grepsearch-0.1.54-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grepsearch-0.1.54-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4cc145b056389237315019129609903b58e8c8a52418faa014407b9aed17b9aa
MD5 787afa2fb58a7fa9f36f9ad724b2a9ec
BLAKE2b-256 7a0a471c8094c7aa5c1a4a992f953741b8601208e26fcb0eaa0dc6fde07cd6a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grepsearch-0.1.54-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for grepsearch-0.1.54-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 29e0a72b93f22a69d26dce377814c7a60fdc24bc85c5e8036acc1ea47933948b
MD5 322e32d121e062a79d6e86122d67d24d
BLAKE2b-256 35c3f611444648726a28096d4ac0570be3de1933eeac2986699bc08c513c1ff9

See more details on using hashes here.

Provenance

The following attestation bundles were made for grepsearch-0.1.54-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on jagguvarma15/grepsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page