GitHub - vibhu-dixit/lybrary: Living structure-aware code memory for AI coding agents Β· GitHub
/" data-turbo-transient="true" />
Skip to content
Type / to search
Sign in<br>Sign upAppearance settings
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
vibhu-dixit
lybrary
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>1 Commit<br>1 Commit
.github/workflows
.github/workflows
lybrary
lybrary
tests
tests
.gitignore
.gitignore
CHANGELOG.md
CHANGELOG.md
README.md
README.md
pyproject.toml
pyproject.toml
View all files
Repository files navigation
π§ lybrary
Living structure-aware code memory for AI coding agents.
pip install lybrary
The problem
Every time an AI agent starts a session, it re-reads your codebase from scratch.
agent: let me grep for auth logic...<br>agent: reading src/auth/middleware.py...<br>agent: reading src/auth/jwt.py...<br>agent: reading src/auth/session.py...<br>agent: reading src/utils/crypto.py...<br>β³ 4,000 tokens burned before writing a single line.
On a large codebase this happens dozens of times per session. Tokens wasted. Context filled. Same files read over and over.
The solution
lybrary gives your agent a persistent memory it can query instead of reading files.
agent: memory_query("authentication flow")<br>β³ 3 chunks returned. 180 tokens. Done.
It indexes your repo using real AST boundaries, keeps the index fresh automatically, and exposes it as an MCP server that any AI IDE connects to natively.
β¨ Features
π³ AST-aware chunking<br>tree-sitter parses your code β never splits a function in half
β‘ Background daemon<br>watches for file changes, re-indexes only what changed
π Semantic search<br>vector search with token-budget packing
π MCP server<br>works with Kiro, Cursor, Claude Desktop, Windsurf out of the box
π¦ Fully local<br>no cloud, no API keys, embeddings run on your machine
π Pure pip install<br>Python 3.11β3.14, no PyTorch, no compilation needed
Supported languages: Python Β· JavaScript Β· TypeScript Β· TSX Β· Go Β· Rust Β· Java Β· C Β· C++
π Quick start
pip install lybrary
cd /path/to/your/repo<br>lybrary init<br>lybrary start # builds index + starts background daemon<br>lybrary query "authentication flow"
After lybrary start, the daemon keeps running even after you close the terminal. File changes are picked up automatically β only affected chunks are re-indexed.
π MCP integration
Add to your MCP config (Kiro, Cursor, Claude Desktop, Windsurf):
"mcpServers": {<br>"lybrary": {<br>"command": "lybrary",<br>"args": ["mcp"]
Your agent now has three tools:
Tool<br>What it does
memory_query<br>Semantic search β returns ranked chunks with full source, file path, and line numbers
memory_status<br>Reports daemon state, chunk count, and tracked files
memory_update<br>Triggers incremental or full re-index, optionally scoped to specific files
Agents should call memory_query before reading any files.<br>This replaces multi-file reads with a single targeted query β cutting token usage by 80β90% on large codebases.
π₯οΈ CLI reference
Command<br>Description
lybrary init<br>Create .lybrary/ and default config
lybrary start<br>Index (if needed) + start persistent daemon
lybrary stop<br>Stop the daemon
lybrary status<br>Show running state, chunk count, tracked files
lybrary index<br>Force (re)index
lybrary query<br>Semantic search over the memory
lybrary logs<br>View / follow daemon log
lybrary mcp<br>Start MCP server (stdio transport)
ποΈ How chunking works
your file<br>tree-sitter parser<br>AST definition nodes β functions, classes, methods, interfaces<br>βββ class Foo βββββββββββΊ chunk: entire class body<br>β βββ def bar ββββββββΊ chunk: method bar (its own chunk too)<br>β βββ def baz ββββββββΊ chunk: method baz (its own chunk too)<br>βββ module-level βββββββββΊ chunk: imports, constants, top-level statements
Each chunk gets a context header and is embedded with MiniLM-L6-v2 via ONNX Runtime β fast, local, no GPU needed.
ποΈ Architecture
.lybrary/<br>βββ config.toml # model, chunk size, ignore patterns<br>βββ index.db # SQLite: chunks + float32 vector blobs<br>βββ file_hashes.json # content-hash map for incremental updates<br>βββ daemon.pid<br>βββ daemon.log
Indexer β tree-sitter β AST chunks β fastembed / ONNX Runtime embeddings
Store β SQLite + numpy (cosine similarity via batched dot product, no external vector DB)
Daemon β watchdog file watcher + debounce + incremental re-chunk/embed
MCP β FastMCP server over stdio
πΊοΈ Roadmap
AST chunker (multi-language, cAST-style)
Incremental indexing via content hashes
Background daemon + file watcher (Windows + Unix)
CLI (init / start / stop / status / index / query / logs / mcp)
MCP server (memory_query, memory_status,...