Repository navigation
v0.2.0 — the memory layer release
The "memory layer" release
loci turns scattered notes, project docs, and chat logs into a queryable second brain — local index, hybrid retrieval, cited answers, and an MCP server so your AI agents can use it. The core is ~300 lines of plain Python: no LangChain, no Docker, no daemons.
Highlights
- Hybrid retrieval by default — native BM25 (CJK-aware) fused with vector search via Reciprocal Rank Fusion. Measured on a bilingual corpus: 9/10 → 10/10 hit@5 vs vector-only.
- MCP server, zero extra dependencies —
brain_search/brain_ask/brain_links/brain_stats/brain_ingestover stdio; plus resources (brain://note/…,brain://stats) and three prompts (brain-briefing / study-plan / contradiction-check). - Fully offline verified — point both endpoints at a local Ollama and the whole pipeline runs with zero cloud calls.
- Section-level citations — every answer and hit carries
file > headingbreadcrumbs; optionalask --verifyaudits the answer claim-by-claim against the sources (✓ / ~ / ✗). - Reranking, two providers — LLM pointwise scoring, or a local cross-encoder (
BAAI/bge-reranker-base, ~30–70 ms for 5 pairs on GPU) via an optional extra. - Obsidian-native details — frontmatter tags (
--tag),[[wikilink]]graph (links), fenced code blocks never split, one-line notes stay searchable. - Office & PDF — PyMuPDF4LLM extracts PDFs as markdown with tables as pipe rows;
.docxparagraphs and tables via an optional extra. - Chat-log loader — ChatGPT / Claude
conversations.jsonexports become one searchable document per conversation. - Per-directory chunk config —
[[sources]]entries overridechunk_size/chunk_overlap. - Quality signals — 115 offline tests (no API keys needed), GitHub Actions CI (3.11–3.13 + packaging smoke), built-in retrieval eval harness,
stats/doctor/watch/chatcommands.
Quick start
pip install -e ".[pdf,docx]"
cp config.example.toml config.toml # add your API key + source dirs
second-brain ingest
second-brain ask "what did I write about X?"Full notes in CHANGELOG.md. MIT licensed.