tensor-grep
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.tgdoes not replacerg; it routes compatible cold text searches throughrgor 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 runandtg scanexpose 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, andtg 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tensor_grep-2.1.2.tar.gz | 2.4 MB | With provenance | Details for tensor_grep-2.1.2.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tensor_grep-2.1.2-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details for tensor_grep-2.1.2-cp311-abi3-win_amd64.whl |
| tensor_grep-2.1.2-cp311-abi3-manylinux_2_39_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.39+ x86-64 | Details for tensor_grep-2.1.2-cp311-abi3-manylinux_2_39_x86_64.whl |
| tensor_grep-2.1.2-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for tensor_grep-2.1.2-cp311-abi3-macosx_11_0_arm64.whl |
Total release size: 34.0 MB
Release files / tensor_grep-2.1.2.tar.gz
| Download URL | tensor_grep-2.1.2.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06807ae3b48f790bd9d3ccc4ed442d30ea88605fb2b6f816bc2e138cfeaee042
|
|
BLAKE2b-256 checksum How to use checksums |
b40e422868c40ffb3feff096484a495379dee1f8007307a51abc46d1ef7d7e7f
|
| 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 29, 2026.
Transparency logRelease files / tensor_grep-2.1.2-cp311-abi3-win_amd64.whl
| Download URL | tensor_grep-2.1.2-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 10.8 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ac28e521e661c6271b51f2eb75627355139bd882fe1beee88e5fb59706e1af13
|
|
BLAKE2b-256 checksum How to use checksums |
936e8b2ac99120f479420f8b4c0dc8be27c1513c40b130e7969295e8db32daf2
|
| 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 29, 2026.
Transparency logRelease files / tensor_grep-2.1.2-cp311-abi3-manylinux_2_39_x86_64.whl
| Download URL | tensor_grep-2.1.2-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 |
4d2b870dd91834958e97e85fa77a1ac607e44e329990150f21226655039a1a4e
|
|
BLAKE2b-256 checksum How to use checksums |
478b595e4cc30c945fe957eaac719d44df0ade9107747440203b52a59e9243cd
|
| 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 29, 2026.
Transparency logRelease files / tensor_grep-2.1.2-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | tensor_grep-2.1.2-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 |
3792a490898935bdf124608159c5c7f9d660f4db7016be1e74f918e9dd24c3bb
|
|
BLAKE2b-256 checksum How to use checksums |
2d6dc16919d77420bb7c52949ee3a9cf1fa304202cfc13978607f291623f88c7
|
| 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 29, 2026.
Transparency logSecurity for tensor-grep 2.1.2
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.
Attestation for tensor_grep-2.1.2.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 29, 2026.
Transparency logA 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.