Software Brain Engine

Open-source semantic graph engine for code context

Stop sending entire codebases to AI.

LLM coding tools waste tokens when they load broad folders before understanding the change.

SBE turns repositories into semantic graphs for precise AI context retrieval.

$ sbe impact createUser --json
sbe graph createUser semantic graph query
symbol: createUser
kind: Function
file: src/users/user.service.ts:18-42

dependencies:
  -> validateCreateUserDto
  -> UserRepository.save
  -> hashPassword

dependents:
  <- POST /users controller
  <- createUserHandler

context:
  4 files, 7 symbols, exact source ranges

Before / After

Give the model a code graph, not a scavenger hunt.

Before SBE

  • LLM reads 10-20 files to find the relevant path.
  • Guesses dependencies from imports and naming.
  • Burns tokens on unrelated controllers, services, and DTOs.
  • Misses downstream impact during refactors.

After SBE

  • LLM queries the semantic graph first.
  • Gets exact functions, classes, dependencies, and dependents.
  • Receives file paths and source code ranges.
  • Uses focused context instead of broad repository dumps.

What It Does

A local index for code structure and change impact.

Builds a semantic graphFiles, symbols, imports, references, and containment edges.
Extracts code structureFunctions, classes, methods, interfaces, enums, variables, and type aliases.
Maps exact rangesSymbols point back to concrete source lines for retrieval.
Computes impactReverse graph traversal shows what changes when a symbol changes.
Compresses AI contextSend focused graph context instead of the whole repository.

Demo

Ask the repository what matters.

Scan

$ sbe scan ./repo

SBE scan complete
  indexed files : 214
  graph         : 918 symbols, 301 imports, 1440 edges
  storage       : ./repo/.sbe
  elapsed       : 682 ms

Graph

$ sbe graph createUser --json

{
  "symbol": "createUser",
  "dependencies": ["CreateUserDto", "hashPassword", "UserRepository.save"],
  "dependents": ["UsersController.create", "createUserHandler"]
}

Impact

$ sbe impact saveUser

origin: saveUser
affected:
  UsersService.createUser
  UsersController.create
  AuthService.register
  tests/users/create-user.spec.ts

Download

Install SBE as a native developer tool.

Download the latest release artifact for your platform from GitHub Releases.

Why It Matters

Context is the bottleneck in AI-assisted development.

AI tools are strongest when they receive the right code. They become expensive and unreliable when they read entire repositories, infer architecture from partial searches, or miss hidden dependents.

SBE reduces unnecessary context by retrieving code through a semantic graph. The result is smaller prompts, clearer dependency awareness, and better refactoring decisions.

Live Demo Case Study

Debugging a Hono middleware lifecycle issue with graph context.

This is a realistic simulated demo using honojs/hono, a TypeScript web framework. It shows how SBE would guide an AI assistant through a multi-file middleware bug without loading broad framework context.

Issue

Middleware post-processing after await next() should still apply headers when a downstream handler throws and onError creates the final response.

app.use(async (c, next) => {
  await next()
  c.header('x-request-processed', 'true')
})

SBE Query

$ sbe scan ./hono
$ sbe graph compose --json
$ sbe impact compose --json

The graph starts from the middleware composition function and follows dependents into dispatch, context response mutation, factory helpers, and tests.

Metric Without SBE With SBE
Files read 12-16 broad files 5-7 focused files
Context size ~22k-30k tokens ~5k-7k tokens
Dependency awareness Manual inference Graph-guided
Estimated reduction Baseline ~68-78%

Focused file/range packet

src/compose.ts:18-102
src/hono-base.ts:210-275
src/context.ts:120-175
src/types.ts:40-88
src/helper/factory/index.ts:12-44
src/compose.test.ts:1-90
src/hono-base.test.ts:300-370

The numbers are demo estimates until reproduced against a checked-out Hono commit. The purpose is to show the SBE workflow: graph first, focused code ranges second, AI context last.

Architecture

Simple pipeline. Local storage. Tool-friendly output.

Codebase Scanner Semantic Graph Context Compiler AI

V1 uses practical syntax-based TypeScript analysis through Tree-sitter. It is not a TypeScript type checker or language server. The goal is fast local graph retrieval for AI context.

Use Cases

Built for real code-navigation work.

Impact analysis before refactoring

See dependents and affected files before editing a shared symbol.

Understanding large codebases

Trace services, controllers, DTOs, and database layers without opening broad folders.

AI-assisted development

Give agents structured context packets instead of raw repository dumps.

Dependency visualization

Query relationships between symbols, files, and code layers from the CLI.

Roadmap

Focused milestones, not feature sprawl.

  1. v1Graph + impact analysis for TypeScript/TSX repositories.
  2. v2Semantic diff for pull requests and code review.
  3. v3AI context compiler with richer retrieval packets.