Skip to main content

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

  1. Detect language from file extension
  2. Parse with tree-sitter
  3. Extract definition nodes (functions, classes, methods, interfaces, impls…)
  4. Container nodes (classes, impls) emit as a chunk and recurse so nested methods get their own chunks
  5. Attach rich metadata + a context header used for embedding
  6. 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

Release files for lybrary 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lybrary 0.1.0
File Size Uploaded
lybrary-0.1.0.tar.gz 29.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lybrary 0.1.0
File Interpreter ABI Platform
lybrary-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 56.5 kB

Release files / lybrary-0.1.0.tar.gz

Download URL lybrary-0.1.0.tar.gz
Size 29.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2dfb6bb5d48732a5b272a57998dfa7067bb78e90b378ca58b1c11e2ae6501d87
BLAKE2b-256 checksum
How to use checksums
7ad83a715e8407cf1516b3c6cc006b4452a89cafa9bdf871d38b1181370457f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / lybrary-0.1.0-py3-none-any.whl

Download URL lybrary-0.1.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
366e9b792141eb3fe065f1c7fd989f86a8b32aecc45bfc55fb11c7c57050bb45
BLAKE2b-256 checksum
How to use checksums
16cddc7f898c20cadda0f4dc2359f0cd56c27b49eb6d44891e2d8d02c7208808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page