Local semantic graph infrastructure for precise AI code context retrieval.
Software Brain Engine (sbe) is a local code-intelligence CLI for TypeScript, TSX, and Python projects. It builds a semantic index of your repository, then returns focused impact reports for planned code changes so LLMs do not need to read the whole codebase.
The goal is simple: install once, run sbe, and give developers or AI agents the smallest useful context for a change.
The logo represents SBE's core model: a central semantic graph node connected to the exact code symbols and dependency paths that matter for a change.
AI coding tools are powerful, but they often waste context by reading too much code before they understand the change. SBE acts like a local "brain index" for your repository:
- scan the repo once
- store a local binary index under
.sbe/ - ask a change question such as
jwt to passport - get impacted symbols, files, layers, dependencies, and token estimates
- update changed files incrementally without rebuilding the whole graph
- send the focused context to an LLM instead of the full codebase
SBE is useful when the change is specific enough to map to code layers: auth migrations, API changes, DTO updates, controller/service refactors, middleware rewrites, database model changes, and similar engineering work.
Large codebases waste tokens when an LLM has to inspect broad folders before it can understand a focused change. SBE indexes the project locally and answers questions like:
sbe benchmark C:\path\to\repo --query "jwt to passport"Instead of sending the full repository, SBE reports:
- matched symbols
- affected symbols
- impacted files
- impacted layers such as auth, middleware, controller, service, DTO, and database
- approximate full-context tokens vs SBE-focused tokens
- scan/query timing
Example real local validation:
indexed : 42 files, 88 symbols
impacted : 24 files, 49 symbols
tokens : full ~9469, sbe ~5319, saved ~4150 (44%)
query time : 3 ms
Graph Intelligence v2 was also validated against a real Fastify checkout:
indexed : 33 files, 506 symbols
graph : 207 imports, 2700 edges
impact : 230 affected symbols, 24 affected files, depth 4
tokens : full ~84633, sbe ~42335, saved ~42298 (50%)
query time : 184 ms
See docs/benchmark-fastify.md.
Python plugin validation on a real FastAPI checkout:
indexed : 1120 Python files, 6524 symbols
graph : 3582 imports, 67320 edges
impact : FastAPI -> 4481 affected symbols, 706 affected files, depth 6
tokens : full ~978145, sbe ~696741, saved ~281404 (29%)
update : 1 changed file, 3 modified symbols, 10815 ms
See docs/benchmark-fastapi.md.
This is not a promise that every query saves tokens. Small projects or broad changes may show no savings. That honesty is the point: SBE gives benchmark evidence, not marketing-only claims.
- Developers using AI coding assistants on TypeScript backends.
- Teams that want local-first code context before sending data to an LLM.
- Open-source maintainers who want repeatable impact analysis.
- Agent builders who need structured context packets instead of raw repository dumps.
- Engineers who want to benchmark token savings before pitching an AI workflow.
SBE includes a realistic demo based on honojs/hono, focused on a middleware lifecycle issue that requires multi-file understanding.
Demo question:
When middleware calls await next(), does post-processing still mutate an error response created by onError?
SBE flow:
sbe scan ./hono
sbe graph compose --json
sbe impact compose --jsonDemo estimate:
| Metric | Without SBE | With SBE |
|---|---|---|
| Files read | 12-16 | 5-7 |
| Context size | ~22k-30k tokens | ~5k-7k tokens |
| Dependency awareness | Manual inference | Graph-guided |
This is a simulated, reproducible-concept demo. It is not an upstream Hono bug claim until verified against a specific Hono commit with a failing test.
See docs/demo-hono.md.
SBE is a production-alpha CLI. It is usable for local TypeScript/TSX/Python validation and benchmarking, but it is not yet a full type-aware TypeScript compiler integration or Python static analyzer.
Current scope:
- syntax-based TypeScript/TSX parsing through Tree-sitter
- Python language plugin for classes, functions, async functions, methods, imports, variables, and local references
- binary
.sbe/index.binstorage - debug JSON export
- Graph Intelligence v2 typed symbol and relationship graph
- bidirectional caller/callee lookup
- incremental index updates with
sbe update - symbol version diffing for added, modified, and removed symbols
- Context Compiler v2.1 for deterministic, budgeted context packs
- Change Simulator v2.2 for modify, delete, and replace predictions
- deterministic risk scoring, affected-flow detection, and recommended test selection
- impact analysis and layer classification
- benchmark and validation reports
- Windows MSI release workflow
- Linux/macOS release archives
Not yet:
- full TypeScript type resolution
- full Python type resolution, decorator evaluation, or runtime import execution
- watch mode
- exact model-tokenizer counting
- editor extension
- large public benchmark suite
Download the release artifact for your platform:
Windows:
sbe-0.5.0-windows-x64.msi
Linux/macOS:
sbe-linux-x64.tar.gz
sbe-macos-arm64.tar.gz
Download locations:
| Platform | Artifact | Location |
|---|---|---|
| Windows x64 | sbe-0.5.0-windows-x64.msi |
GitHub Releases |
| Linux x64 | sbe-linux-x64.tar.gz |
GitHub Releases |
| macOS ARM64 | sbe-macos-arm64.tar.gz |
GitHub Releases |
After install:
sbe version
sbe --helpRecommended npm install:
npm install -g sbe-cli
sbe version
sbe scan .The npm package downloads the native Rust binary from GitHub Releases on install or first run. It does not require Rust.
Native release downloads:
Developer source install:
cargo install --path crates/cli --forceBuild folders such as target/, dist/, and artifacts/ are generated locally. They are not part of the source repo or public release.
Index a TypeScript, TSX, or Python project:
sbe scan C:\path\to\typescript-projectIncrementally refresh changed files after a scan:
sbe update C:\path\to\typescript-projectCheck index health:
sbe doctor C:\path\to\typescript-projectAnalyze a planned change:
sbe analyze-change "jwt to passport" C:\path\to\typescript-projectCompile an AI-ready context pack without calling an AI model:
sbe context createUser C:\path\to\typescript-project
sbe context createUser C:\path\to\typescript-project --budget 4000
sbe context createUser C:\path\to\typescript-project --budget 8000 --jsonPredict impact before changing code:
sbe simulate modify createUser C:\path\to\project
sbe simulate delete createUser C:\path\to\project --max-depth 6
sbe simulate replace createUser C:\path\to\project --record --jsonThe simulator answers four practical questions before an edit: what symbols and files are affected, how risky the operation is, which entry-point flows participate, and which connected existing tests should run. --record stores the JSON result under .sbe/reports/ for regression and release comparisons.
Benchmark token optimization:
sbe benchmark C:\path\to\typescript-project --query "jwt to passport"Run repeatable validation:
sbe validate C:\path\to\typescript-project --query "jwt to passport"Run the maintainer benchmark script:
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\validate-benchmark.ps1 -ProjectPath C:\path\to\typescript-project -Query "jwt to passport"On macOS/Linux:
scripts/validate-benchmark.sh /path/to/typescript-project "jwt to passport"Export the binary index for debugging:
sbe export-json C:\path\to\typescript-project| Command | Purpose |
|---|---|
sbe init <path> |
Create .sbe/ metadata. |
sbe scan <path> |
Build or refresh the local index. |
sbe update <path> |
Incrementally update changed files in the existing index. |
sbe inspect <symbol> <path> |
Return context packets for a symbol. |
sbe graph <symbol> <path> |
Show dependencies and dependents. |
sbe impact <symbol> <path> |
Show transitive impact. |
sbe context <symbol> <path> |
Compile a ranked, budgeted context pack. |
sbe simulate <modify|delete|replace> <symbol> <path> |
Predict blast radius, risk, flows, tests, and context before editing. |
sbe analyze-change <query> <path> |
Explain affected layers/files/symbols for a planned change. |
sbe benchmark <path> --query <query> |
Compare full-project tokens vs focused SBE context. |
sbe validate <path> --query <query> |
Scan, benchmark, and write .sbe/reports/validation-latest.json. |
sbe doctor <path> |
Check index health and stale files. |
sbe export-json <path> |
Export .sbe/index.bin to readable JSON. |
sbe version |
Print version and storage metadata. |
.sbe/ is local runtime index data, similar to a build cache. It is ignored by this repository and should be ignored in projects that use SBE.
No. SBE skips dependency, VCS, build, and generated folders by default, including:
node_modules
.git
.sbe
dist
build
target
.next
coverage
The goal is to index source code, not installed packages or generated output.
Yes. The npm package is sbe-cli, and it installs the sbe command.
npm install -g sbe-cli
sbe scan .The npm package does not compile Rust locally. It downloads the matching native binary from GitHub Releases and verifies it with checksums.txt.
SBE does not claim magic compression. It reduces context by selecting the code slice that appears relevant to a change.
Benchmark flow:
- Count approximate tokens for all indexed TypeScript/TSX/Python source.
- Match the query to symbols and files.
- Traverse dependencies and dependents.
- Merge overlapping symbol ranges so nested symbols are not double-counted.
- Estimate focused context tokens from actual source characters.
- Report saved tokens and reduction percentage.
See docs/benchmark.md for the benchmark methodology and how to interpret results.
SBE is a Rust workspace:
common: shared public data typesscanner: repository traversal and file hashingstorage: binary.sbe/persistenceparser: TypeScript extraction plus Python language pluginsymbols: in-memory symbol indexesgraph: typed dependency graph with forward/reverse indexes, diffs, impact traversal, and context packsimpact: reverse dependency analysis reportscontext: deterministic context compiler, ranking, budget pruning, dependency paths, and code rangessimulator: bounded graph traversal, risk scoring, flow detection, test selection, and context assemblyquery: context, benchmark, and change-analysis reportsindexer: full scan and incremental update pipelinecli: user-facing command line
See docs/architecture.md, docs/context-compiler.md, and docs/change-simulator.md. Review hardening notes are tracked in docs/review-issues.md. CodeRabbit setup and unresolved review findings are tracked in docs/coderabbit.md and docs/review-backlog.md.
GitHub Actions builds release artifacts.
Push to a tracked branch:
build and test
build installer artifacts
Push a version tag:
git tag v0.5.0
git push origin v0.5.0Then GitHub publishes release downloads.
See docs/install.md and docs/release.md. See docs/marketing.md for launch messaging and community posting templates. See docs/launch-campaign.md for a concrete 7-day launch plan and ready-to-post copy. See docs/governance.md for branch protection, PR review, and version automation rules.
The static website lives in website/. GitHub Pages deployment is configured in .github/workflows/pages.yml and runs on pushes to main that change the website.
Open locally:
website/index.html
cargo fmt --check
cargo check --workspace
cargo test --workspace
cargo clippy --workspace -- -D warnings
cargo build --release -p sbe-cliContributions should use pull requests and Conventional Commits. See CONTRIBUTING.md.
Community and project policies:
sbe watchfor automatic incremental indexing- exact tokenizer support
- richer TypeScript import/call resolution
- public benchmark corpus
- editor integration
- signed installers
- package-manager distribution
MIT