Skip to main content
tensor-grep

tensor-grep

PyPI CI License

Find the code. Understand the change.

tensor-grep (tg) is a local-first code search, symbol-navigation, and AI context CLI. It combines regex and structural AST search with repository orientation, caller/blast-radius analysis, diff-impact slicing, rollback checkpoints, and an MCP server—with zero telemetry and no API key required for core workflows.

Get started · Installation · Upgrading (v1.x to v2.0) · How it works · Releases

30-second quickstart

With Python 3.11+ on Windows, macOS, and Linux (or the managed native installer in docs/installation.md):

python -m pip install tensor-grep
tg --version

From any repository:

# 1. Find literal text or regex matches with line numbers
tg search -F -n "TODO" src

# 2. Orient yourself in an unfamiliar codebase
tg orient src

# 3. Trace callers and prepare an edit-readiness capsule (add --json or --json --compact)
tg callers src create_invoice --json
tg prepare src "add invoice tax validation" --json --compact

# 4. Inspect git diff blast radius before committing
tg diff-impact . --json

Commands default to concise human-readable text when --json is omitted; pass --json for machine output or --json --compact for a bounded <= 4,000-byte JSON payload.

12-command core workflow (tg --help vs tg --help-all)

tg --help highlights the 12 core workflow commands so humans and agents can start without noise. Run tg --help-all for the complete command catalog.

Stage Core commands What it gives you
Search & structure search, find, run, scan Regex/literal search (--index, --rank), local hybrid BM25+RRF (find --hybrid), structural AST patterns (run), and bounded AST rulesets (scan)
Understand & trace orient, defs, callers, blast-radius Central files and entry points (orient), symbol definitions (defs), call sites (callers), and transitive file/test impact (blast-radius)
Prepare, edit & verify prepare, diff-impact, checkpoint One-call edit-readiness capsule (prepare), git diff blast radius + change slice (diff-impact), and scoped rollback snapshots (checkpoint)
Connect assistants mcp 15-tool compact default MCP server (< 12 KB tools/list, tg_batch step pipelines; TG_MCP_LEGACY_TOOLS=1 for all 61 legacy tools)

For AST structural search and rulesets via PyPI, install python -m pip install "tensor-grep[ast,scan]" (the managed native binary supports tg run directly). In PowerShell, wrap patterns containing $VALUE in single quotes:

tg run -p 'print($VALUE)' --lang python src

Why tg vs rg + ast-grep + IDE

  • rg (ripgrep) is the cold exact-text search baseline. tg does not replace rg; it routes compatible cold text searches through rg or its native CPU engine, and adds warm trigram indexing (tg search --index), symbol graphs, and bounded AI context on top.
  • ast-grep (sg) has the broader structural-rule surface. tg run and tg scan expose a validated AST search/rewrite slice alongside symbol navigation, diff impact, and checkpoints in one CLI.
  • IDEs hold rich semantic state interactively, but scripts, CI gates, and coding assistants need headless, deterministic, token-budgeted CLI/MCP outputs (--json, --json --compact, tg_batch, and tg review-bundle verify --require-change-slice) without GUI startup or cloud telemetry.
  • Zero-telemetry, local-first: Core search, indexing (.tg_cache/), symbol graphs, sessions, and checkpoints run 100% locally with no API key and no outbound telemetry.

Benchmark & verification surfaces

Performance and accuracy claims in tensor-grep are benchmark-governed and workload-specific. Rather than quoting cherry-picked numbers, each surface has a reproducible harness in benchmarks/ documented in docs/benchmarks.md and docs/tool_comparison.md:

Surface Reproducible script Verified behavior / contract
Text search (rg vs native CPU vs TrigramIndex) benchmarks/run_benchmarks.py, benchmarks/run_hot_query_benchmarks.py Cold exact-text baseline is rg; warm trigram indexes (.tg_cache/index_v1/*.tg_index) report routing_reason: "index-accelerated" (tg search --index); SWHForest (SWHF2 HMAC-SHA256) accelerates warm AST structural queries (tg run)
Agent localization & edit loop benchmarks/run_repo_retrieval_benchmarks.py, benchmarks/run_agent_workflow_benchmarks.py tg prepare, tg agent (context capsule), FastContext (tg_explore / tg_batch multi-turn span compaction), and tg orient --compact bound JSON output to <= 4,000 bytes and reuse warm .tg_cache/ views (manifest_v1.json, symbols_v1/, graph_v1/tdad_tests.sqlite3) alongside a 10-language warm LSP pool (capacity=12)
MCP schema & pipeline budget tests/unit/test_mcp_compact_parity.py Default tg mcp (contract 1.33.0) exposes 15 compact tools (< 12 KB tools/list, vs 61 with TG_MCP_LEGACY_TOOLS=1) and tg_batch ($prev / $steps[i])
Security & AST rulesets (tg scan) benchmarks/run_ast_benchmarks.py Built-in rulesets (e.g., secrets), multi-language UAST taint analysis, and 4D log-typicality anomaly detection via tensor-grep[scan]; fails closed when ast-grep is absent and discloses partial / partial_reason
Native GPU (experimental) benchmarks/run_gpu_native_benchmarks.py Explicit --gpu-device-ids only; never inferred from fallback/sidecar rows (docs/gpu_crossover.md)

Bounded scans can return partial results. Confidence scores and caller graphs are evidence to review, not proof that a change is safe or that a symbol is unused.

Installation & platform channels

Windows (x64), macOS (x64 / Apple Silicon), and Linux (x64 / ARM64) installation options are documented in docs/installation.md and the support matrix. npm, Homebrew, and Winget manifests exist in the repository but are not published to their registries yet.

Canonical docs

Guide Purpose
First search Sample project, 12-command core workflow, and glossary
Installation Install, verify, and troubleshoot the launcher
Upgrading (v1.x to v2.0) Step-by-step migration guide from v1.x to v2.0.0
Architecture Rust cli_app/ + native_search/, Python cli/ modules, and .tg_cache/
docs/harness_api.md Machine-readable CLI and MCP contracts (15-tool compact default + tg_batch)
docs/harness_cookbook.md End-to-end CLI, MCP, and diff-impact automation recipes
docs/runbooks/cache-management.md Unified .tg_cache/ layout, sessions, and rollback checkpoints
docs/enterprise_review_bundle_ci.md Signed evidence receipts and --require-change-slice CI gates
docs/routing_policy.md How execution paths are selected
docs/benchmarks.md Accepted measurements and regression checks
docs/tool_comparison.md Workload and language-coverage comparisons
docs/gpu_crossover.md GPU measurements and current limits
docs/SUPPORT_MATRIX.md Platforms, runtimes, and delivery channels
docs/CONTRACTS.md Compatibility and output guarantees
docs/CI_PIPELINE.md Testing, releases, and dependency maintenance
docs/HOTFIX_PROCEDURE.md Patch and rollback procedures
docs/EXPERIMENTAL.md Opt-in GPU, dense retrieval, and experimental surfaces

Contribute and get help

Report a bug, request a feature, or ask a question. Include the command, tg --version, your platform, and a small reproducible example.

See CONTRIBUTING.md for development and review conventions, and SECURITY.md for private vulnerability reporting.

Future Work

Ongoing work focuses on retrieval quality, cross-file navigation, larger repositories, and integrations. Experimental features graduate through measured results and compatibility checks. See the experimental-feature guide for current boundaries and GitHub issues for discussion.

License

Apache-2.0. See LICENSE. Related project: gotcontext.ai.

Optional runtime dependency security and verification: security floors.

Metadata

Release files for tensor-grep 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tensor-grep 2.1.0
File Size Uploaded Provenance Actions
tensor_grep-2.1.0.tar.gz 2.4 MB With provenance Details for tensor_grep-2.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tensor-grep 2.1.0
File Interpreter ABI Platform Actions
tensor_grep-2.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for tensor_grep-2.1.0-cp311-abi3-win_amd64.whl
tensor_grep-2.1.0-cp311-abi3-manylinux_2_39_x86_64.whl CPython 3.11 abi3 Linux glibc 2.39+ x86-64 Details for tensor_grep-2.1.0-cp311-abi3-manylinux_2_39_x86_64.whl
tensor_grep-2.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for tensor_grep-2.1.0-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 34.0 MB

Release files / tensor_grep-2.1.0.tar.gz

Download URL tensor_grep-2.1.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
a9567205664ef7dc148840e509b1cdaedc09ceebc177ac9bbf2dd1632b37e648
BLAKE2b-256 checksum
How to use checksums
1f5ee56ee83daebe7a65556a09f99d7f9057df5e80c0dd232ce486c7497b3fb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / tensor_grep-2.1.0-cp311-abi3-win_amd64.whl

Download URL tensor_grep-2.1.0-cp311-abi3-win_amd64.whl
Size 10.8 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
00d80dd3e240dd98fe7d380ca79d6f2622be2607d28f8b3053047900b888bf26
BLAKE2b-256 checksum
How to use checksums
acff12b357df0414ee1d3f99152890b27bb94db6608e1b50b2a8a5bc63eb63e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / tensor_grep-2.1.0-cp311-abi3-manylinux_2_39_x86_64.whl

Download URL tensor_grep-2.1.0-cp311-abi3-manylinux_2_39_x86_64.whl
Size 10.6 MB
Tags CPython 3.11 Linux glibc 2.39+ x86-64 abi3
SHA-256 checksum
How to use checksums
6b9564425ed07a8e8b3fdb6732e4b27c3e753e46f2d37239acc4970a1cc34004
BLAKE2b-256 checksum
How to use checksums
6725851ab8eab3e18117a034f37ba6825e40e3981cc01a1d679e03a64f23be21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / tensor_grep-2.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL tensor_grep-2.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 10.2 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
85b32eb36186bd3358c3c7fcc8ddb9b6f2d95ada2aae436f59faf3cd6ae5d117
BLAKE2b-256 checksum
How to use checksums
72dcb29d5349f2beec78b38315ab33b344eb94cfc261962d626ebbe7fe48c438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for tensor-grep 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for tensor_grep-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page