lybrary
Living structure-aware code memory for AI coding agents.
lybrary indexes your repository with real AST boundaries (functions, classes, methods), keeps the index fresh via a background daemon, and gives AI agents a high-signal memory they can query instead of reading raw files.
This reduces token burn and hallucinations compared to pure agentic search or flat embedding RAG.
Why lybrary?
Current IDE agents either:
- Re-explore the repo with grep/read every session (expensive, amnesiac), or
- Use flat semantic search that doesn't understand code structure.
lybrary sits in the middle:
- AST-aware chunks (cAST-style) — never splits a function in half
- Persistent daemon that auto-updates on every file change
- Hybrid retrieval (vector search + token-budget packing)
- Agent-first design — agents query memory instead of walking the tree
- MCP server — works natively with Kiro, Cursor, Claude Desktop, Windsurf, and any MCP-compatible IDE
- Fully local — no cloud, no API keys, embeddings run on your machine
Quick start
pip install lybrary
cd /path/to/your/repo
lybrary init
lybrary start # builds index + starts background daemon
lybrary query "authentication flow"
After lybrary start, the daemon keeps running even if you close the terminal. File changes are picked up automatically and only the affected chunks are re-indexed.
MCP integration (AI IDEs)
Add this to your MCP config (works with Kiro, Cursor, Claude Desktop, Windsurf):
{
"mcpServers": {
"lybrary": {
"command": "lybrary",
"args": ["mcp"]
}
}
}
The agent then has three tools available:
| Tool | What it does |
|---|---|
memory_query |
Semantic search — returns ranked code chunks with full source, file path, and line numbers |
memory_status |
Reports daemon state, chunk count, and tracked files |
memory_update |
Triggers incremental or full re-index, optionally scoped to specific files |
Agents should call memory_query before reading any files. This replaces multi-file reads with a single targeted query, cutting token usage by 80–90% on large codebases.
CLI
| Command | Description |
|---|---|
lybrary init |
Create .lybrary/ and default config |
lybrary start |
Index (if needed) + start persistent daemon |
lybrary stop |
Stop the daemon |
lybrary status |
Show running state, chunk count, tracked files |
lybrary index |
Force (re)index |
lybrary query |
Semantic search over the memory |
lybrary logs |
View / follow daemon log |
lybrary mcp |
Start MCP server (stdio transport) |
How chunking works
- Detect language from file extension
- Parse with tree-sitter
- Extract definition nodes (functions, classes, methods, interfaces, impls…)
- Container nodes (classes, impls) emit as a chunk and recurse so nested methods get their own chunks
- Attach rich metadata + a context header used for embedding
- Fall back to careful line-based splitting only when a grammar is missing
Supported languages: Python, JavaScript, TypeScript, TSX, Go, Rust, Java, C, C++.
Architecture (v0.1)
.lybrary/
├── config.toml
├── index.db # SQLite: chunks + vectors (numpy float32 blobs)
├── file_hashes.json # content-hash map for incremental updates
├── daemon.pid
└── daemon.log
- Indexer: tree-sitter → AST chunks → local embeddings (fastembed / all-MiniLM-L6-v2, ONNX Runtime)
- Store: SQLite + numpy (cosine similarity via batched dot product)
- Daemon: watchdog file watcher + debounce + incremental re-chunk/embed
- Query: vector search + token-budget packing
- 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,memory_update) - Call/import graph + expansion
- Hierarchical file/package summaries
- Cross-session decision memory
- systemd/launchd user service helper
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lybrary-0.1.0.tar.gz.
File metadata
- Download URL: lybrary-0.1.0.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dfb6bb5d48732a5b272a57998dfa7067bb78e90b378ca58b1c11e2ae6501d87
|
|
| MD5 |
3ad4c26b9b91ce1deff88d4c113d4111
|
|
| BLAKE2b-256 |
7ad83a715e8407cf1516b3c6cc006b4452a89cafa9bdf871d38b1181370457f2
|
File details
Details for the file lybrary-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lybrary-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
366e9b792141eb3fe065f1c7fd989f86a8b32aecc45bfc55fb11c7c57050bb45
|
|
| MD5 |
2c9209275688a48137b3709becfb0611
|
|
| BLAKE2b-256 |
16cddc7f898c20cadda0f4dc2359f0cd56c27b49eb6d44891e2d8d02c7208808
|