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.5.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.5-cp312-abi3-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.12+Windows x86-64

brokk_bifrost_searchtools-0.6.5-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.5-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.5-cp312-abi3-macosx_11_0_arm64.whl (10.5 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

brokk_bifrost_searchtools-0.6.5-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.5.tar.gz.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5.tar.gz
Algorithm Hash digest
SHA256 fa7177a3f8ff037250f1b095ca5c6513ec8acd58fff2750f34ffb93be5e9f0e7
MD5 6782b41ab993399cecebb87bad076bc5
BLAKE2b-256 de5d392e55c2cd6b6066ce1096bcfb46ef14677f6f7175efd559eba5d044c9ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5.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.5-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ecdfc948e39a74132d0d5ee183a076ddba0a1f652318b039647faac18cf6212e
MD5 afd4275e1cacd024ad5f83452a99b9b4
BLAKE2b-256 054be71d6ca2ce220420ed2a48ef2ea096b9450d940d9c230503dcbe6cf8a30e

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5-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.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48f661ae74e69b1c892d110aa22c203c0526e85c01d669c9af8f60261604d781
MD5 8691accd61d963b20b7fba2e0b8ccec4
BLAKE2b-256 663d9a8c6db5bc53f9af4d18cca77163c8a5d45880e26863fd56a9751f53a5f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5-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.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f4e3cf3ac4d6369dd2091a3a42283b7cd00504157bc1dd442d0dc8cbf7de030
MD5 20c07f24b7f8fc932ab78589f96f7a6b
BLAKE2b-256 cbe06ee2845028b39a8a1896e3217c5bd6334a027e5ba5295f26165d9871109f

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5-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.5-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c2901cd20068a05c9ab29a227bd3ab17094db5e287ea9a0874bf4d07182838a
MD5 92a78c4fdbd4288902f1e4324cfd976a
BLAKE2b-256 c33db47b443215892a1cc9098c6dd831781e4dc64848fad3a6db67f565632ef1

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5-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.5-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for brokk_bifrost_searchtools-0.6.5-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d54ce8ed34611f38302d2f37b5204f48d9f57873b35a739a7c42c1296c0ad9f3
MD5 d16b79b56e6eb62d69cdb9df7ac6a398
BLAKE2b-256 2281cf0cee50ef89784a0187695336bb39a70933e75843ce408ab985de3103b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for brokk_bifrost_searchtools-0.6.5-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