lea

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT

README

lea

Go Version Build Status Go Report Card

Structural context operating system for AI-native software engineering.

lea is a terminal-first structural memory system designed to help AI models and developers navigate and understand large codebases with minimal context and maximum precision.

Unlike traditional RAG systems that treat code as flat text, lea models repositories as living structural graphs, preserving the deterministic relationships (calls, dependencies, implementations) that define software systems.


The Vision

Modern AI coding systems suffer from context window limitations, token inflation, and "context entropy." Most rely on probabilistic semantic chunking (embeddings), which often loses the architectural "big picture."

Software is symbolic, not just semantic. lea focuses on:

  1. Structural Retrieval First: Symbols, dependencies, call graphs, and architectural boundaries.
  2. Semantic Retrieval Second: Natural language understanding on top of structural certainty.

Key Features

  • Multi-Language AST Indexing: Native support for Go (go/ast) and Python, TypeScript, and Rust via Tree-sitter.
  • Structural Graph Engine: Models your codebase as a graph of functions, structs, interfaces, and their relationships (CALLS, IMPLEMENTS, USES).
  • AI Context Compiler: Generates high-signal, markdown-optimized context for LLMs (Claude, GPT, Gemini) using deterministic retrieval.
  • Model Context Protocol (MCP): Expose your codebase structure directly to AI agents via a standardized protocol.
  • Interactive TUI: A rich, terminal-based explorer for fuzzy symbol navigation and dependency browsing.
  • Control Flow & Architecture: Trace execution paths and detect boundary violations against architectural constraints.
  • Incremental & Reactive: Real-time graph updates using fsnotify without re-indexing the entire repository.
  • Local-First: Powered by an embedded SQLite database. Works offline and over SSH.

Architecture

lea is built with a modular, performance-oriented architecture designed for local execution:

  • Parser Layer: Pluggable parsers using native ASTs and Tree-sitter for high-fidelity symbol extraction.
  • Graph Engine: A high-performance relationship model that treats your codebase as a first-class graph.
  • Storage Layer: SQLite-backed storage utilizing recursive CTEs for complex graph traversals.
  • Integration Layer: Built-in MCP server for AI agents and a Bubble Tea-powered TUI for humans.

       ┌────────────────────────────────────────────────────────┐
       │                 Local Filesystem Event                 │
       └───────────────────────────┬────────────────────────────┘
                                   │ (fsnotify)
                                   ▼
       ┌────────────────────────────────────────────────────────┐
       │ Incremental Parser Layer (Native Go AST / Tree-sitter) │
       └───────────────────────────┬────────────────────────────┘
                                   │ (Extracted Symbols)
                                   ▼
       ┌────────────────────────────────────────────────────────┐
       │   Storage Layer: SQLite Graph Engine (Recursive CTEs)  │
       └───────────────────────────┬────────────────────────────┘
                                   │
                    ┌──────────────┴──────────────┐
                    ▼                             ▼
       ┌────────────────────────┐    ┌──────────────────────────┐
       │   Integration Layer    │    │     Retrieval Engine     │
       │   (Bubble Tea TUI)     │    │   (MCP Server for AIs)   │
       └────────────────────────┘    └──────────────────────────┘

Installation

From Source
# Clone the repository
git clone https://github.com/PizenLabs/lea.git
cd lea

# Build the binary
make build

# Install to your GOPATH/bin
make install

Quick Start

1. Index your project

Initialize the structural graph for your repository.

lea index .
2. Start the MCP Server

Connect your favorite AI agent (like Claude Code or Aider) directly to your codebase.

lea mcp
3. Interactive Exploration

Launch the TUI to browse symbols and relationships visually.

lea tui

Command Guide

Command Description Example
index Build or update the structural graph lea index .
tui Open the interactive symbol explorer lea tui
mcp Start the Model Context Protocol server lea mcp
context Generate LLM-optimized context for a symbol lea context "type:internal/storage/sqlite:Store"
trace Follow the call graph from a specific function lea trace "func:internal/cli/commands:Execute"
flow Inspect ordered call flow within a symbol lea flow "func:internal/cli/commands:Execute"
neighbors Find immediate dependencies of a symbol lea neighbors AuthService
impact Analyze the impact of changing a symbol lea impact TokenService
violations Check for architectural boundary violations lea violations --config arch.yaml
watch Watch for file changes and update the graph lea watch .

Roadmap

  • Phase 1: MVP: Go parser, SQLite storage, basic graph queries.
  • Phase 2: AI Context Layer: High-signal markdown generation and context compilation.
  • Phase 3: Incremental Updates: Real-time file watching and partial re-indexing.
  • Phase 4: MCP Integration: Standardized protocol for AI agent connectivity.
  • Phase 5: Interactive TUI: Fuzzy navigation and visual dependency exploration.
  • Phase 6: Multi-Language Support: Tree-sitter integration for Python, Rust, and TypeScript.
  • Phase 7: Advanced Retrieval: Control flow analysis and architecture guardrails.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on development, testing, and pull requests.


License

lea is licensed under the MIT License.


Built for the future of AI-native engineering. 🦾

Directories

Path Synopsis
cmd
lea command
Package main provides the lea CLI entrypoint.
Package main provides the lea CLI entrypoint.
internal
ai/context
Package context provides functionality for compiling AI context from the graph.
Package context provides functionality for compiling AI context from the graph.
architecture
Package architecture defines the configuration and logic for architecture validation.
Package architecture defines the configuration and logic for architecture validation.
cli/commands
Package commands defines CLI subcommands for lea.
Package commands defines CLI subcommands for lea.
graph/contracts
Package contracts defines the core data structures for the structural graph.
Package contracts defines the core data structures for the structural graph.
mcp
Package mcp exposes the Model Context Protocol server.
Package mcp exposes the Model Context Protocol server.
parser/contracts
Package contracts defines parser interfaces used across the app.
Package contracts defines parser interfaces used across the app.
parser/golang
Package golang provides a Go source parser for graph extraction.
Package golang provides a Go source parser for graph extraction.
parser/treesitter
Package treesitter parses non-Go sources using tree-sitter.
Package treesitter parses non-Go sources using tree-sitter.
parser/treesitter/python
Package python provides tree-sitter queries for Python.
Package python provides tree-sitter queries for Python.
storage/contracts
Package contracts defines the interfaces for graph storage.
Package contracts defines the interfaces for graph storage.
storage/sqlite
Package sqlite provides a SQLite implementation of the Store interface.
Package sqlite provides a SQLite implementation of the Store interface.
tui
Package tui provides the interactive terminal UI.
Package tui provides the interactive terminal UI.
watcher
Package watcher provides filesystem monitoring for incremental indexing.
Package watcher provides filesystem monitoring for incremental indexing.
workspace/ignore
Package ignore provides workspace ignore rules for indexing.
Package ignore provides workspace ignore rules for indexing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL