Skip to main content

Fast, structured code search and analysis for Python, backed by a native Rust (Tree-sitter) extension

Project description

brokk-bifrost-searchtools

Fast, structured code search and analysis for Python, backed by a native Rust extension. This is the Python distribution of bifrost, the Tree-sitter-backed analyzer suite that powers Brokk.

It gives you one in-process client that talks straight to the Rust analyzer (no subprocess, no MCP server) and returns typed results plus ready-to-render text. It understands Java, JavaScript, TypeScript, Rust, Go, Python, C++, C#, PHP, and Scala.

  • Install: pip install brokk-bifrost-searchtools
  • Import as: bifrost_searchtools

What it does

Index a project once, then ask fast structural questions:

  • Symbol search: find classes, functions, and fields by name pattern.
  • Locations and sources: jump to a symbol's definition or pull its source.
  • Summaries: get a signature-level outline of a file or directory.
  • Usages and call graph: scan references to a symbol, or build the whole-workspace caller/callee graph (feed it to PageRank for a code map).
  • Most-relevant files: rank the files most related to one or more seed files.
  • Semantic search: find code by meaning, using ONNX embeddings and a cross-encoder reranker (opt-in).

Quick start

from bifrost_searchtools import SearchToolsClient

with SearchToolsClient("/path/to/project") as client:
    # Signature-level outline of a file
    print(client.get_summaries(["src/main.py"]).render_text())

    # Find symbols by name pattern
    for file in client.search_symbols(["parse_*"], limit=10).files:
        print(file.path)

    # Rank the files most related to a seed file
    print(client.most_relevant_files(["src/main.py"]).render_text())

The client indexes on first use, keeps the index warm for the session, and watches the filesystem so later queries see your edits. Every result has typed fields plus a render_text() helper.

For a runnable end-to-end demo, examples/searchtools_demo.py declares its dependency inline (PEP 723), so uv fetches the package and runs it with no manual install:

uv run examples/searchtools_demo.py --root /path/to/repo Calculator compute

API overview

SearchToolsClient(root, library_path=None, render_line_numbers=True, manual=False) exposes:

Method Purpose
search_symbols(patterns, *, include_tests=False, limit=20) Find symbols by name pattern.
get_symbol_locations(symbols, *, kind_filter=...) Resolve symbols to definition sites.
get_symbol_ancestors(symbols, *, kind_filter=...) Walk the enclosing type/scope chain.
get_symbol_sources(symbols, *, kind_filter=...) Pull full source for symbols.
get_summaries(targets) Signature-level outline of files / classes / directories.
list_symbols(file_patterns) Skim the symbols declared in matching files.
scan_usages(symbols, *, include_tests=False, paths=None) Find references to a symbol.
usage_graph(*, include_tests=False, paths=None) Whole-workspace caller/callee graph.
most_relevant_files(seed_files, *, limit=20, ...) Rank files related to seed files.
semantic_search(query, *, k=10) Meaning-based code search (opt-in).
semantic_search_status() Report whether the semantic index is ready.
refresh() Force a full re-index (recovery escape hatch).
update_paths(paths) Incrementally re-analyze specific paths (with manual=True).

Pass render_line_numbers=False to drop line numbers from rendered text while keeping the structured line metadata on the result objects.

Semantic search

semantic_search(...) finds files by meaning rather than name: function-level chunks are embedded, fused with BM25 and git co-edit signals, then reranked by a cross-encoder. It searches code, not prose.

It is opt-in. Set BIFROST_SEMANTIC_INDEX=auto to enable background indexing; the models load via ONNX and download from the HuggingFace hub on first use. The main bifrost README lists every environment override.

License

LGPL-3.0-or-later. See LICENSE.md.

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

brokk_bifrost_searchtools-0.6.4.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

brokk_bifrost_searchtools-0.6.4-cp312-abi3-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.12+Windows x86-64

brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.2 MB view details)

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

brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_11_0_arm64.whl (10.6 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_10_12_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file brokk_bifrost_searchtools-0.6.4.tar.gz.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4.tar.gz
Algorithm Hash digest
SHA256 f15b907c5e1cd1bc349407ad350ac8110dbe0008ed86e78c3e30b78287ceb894
MD5 b135d8f0d03f5d137ae64bcf1afa88fc
BLAKE2b-256 98c5fa9d01d9394b9caba73e7b05fbaadf94be4b805574ca849ae0de98a25b94

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4.tar.gz:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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

File details

Details for the file brokk_bifrost_searchtools-0.6.4-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 42c6530f637613a4af3abbac9ce81ea306eca793006cbc2185f432903f38b56a
MD5 f5195576bd0a883470d8309a1b9cd42f
BLAKE2b-256 2ca0d3694f1e61456b3502b07ebcee2e1f9ad7c74f8529c317a0bd9096ba3bec

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4-cp312-abi3-win_amd64.whl:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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

File details

Details for the file brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ab41afd465150586bd9054e4a8bc2308c1df20810a078e53eb8ab5e0618fdd1
MD5 8e85070880a1b2ddbd655f08fc714ff9
BLAKE2b-256 b4e03e95c5263c2740f22c73c88f47f7a97a197a813b19f6aa5b694ce468c97f

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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

File details

Details for the file brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e015bd28ed08e547c2e0fc20cf08eba9abf085ab2064912fcea0e058f4298977
MD5 201e0e422090931b57a593ca846b8741
BLAKE2b-256 968f18f7d7c79fcafba693e768589ce13767dc863360a4daa25d0de37f33b581

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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

File details

Details for the file brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e9343c1da6242def8a26a54fbb97adeb19a1e2b06f19ffd15c01716996b2cc4
MD5 ed154d0b96cec6dd366c0e1ef4245c65
BLAKE2b-256 d5eb51efc94a03b3484b88e1bf1f43157597c2723959734f4141c233452e350d

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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

File details

Details for the file brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c96e2aa8b24925dcc34c11736d58981ccc390155415117f1f97e3ee219374460
MD5 bb9ec203a009b7852c40e15f707ce80c
BLAKE2b-256 f5280adb8c19886c51423f471ca68e43976b9df7aac9180c3ab4699746d05b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.4-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-wheels.yml on BrokkAi/bifrost

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