Mnemoteca
Mnemoteca — local memory for every agent.
Mnemoteca is a local document storage and retrieval CLI built in Go. Store short
memories and retrieve them with hybrid search: vector similarity with a small
BM25 lexical boost, plus optional local cross-encoder reranking.
All ML inference runs locally with ONNX Runtime. No cloud API is required.
Features
- SQLite document storage with metadata support.
- Semantic Markdown chunking with
yuin/goldmark AST.
- SQLite FTS5 full-text search with BM25 ranking.
- sqlite-vec vector search with cosine similarity.
- Vector-first hybrid search with BM25 lexical reranking.
- Explicit legacy RRF fusion mode.
- Local ONNX embedding and optional reranking models.
- Automatic setup for ONNX Runtime and model downloads.
- Configurable local models.
- No cloud dependency.
Prerequisites
For the one-command install, you need sh, curl or wget, and tar.
For building from source:
- Go 1.21+ — Install Go.
- GCC — required by
mattn/go-sqlite3 (CGO). On macOS, run
xcode-select --install.
- Task — install with
brew install go-task or see
taskfile.dev.
Installation
Install the CLI
Install Mnemoteca from the
Homebrew tap:
brew install gandazgul/tap/mnemoteca
Alternatively, install the latest macOS or Linux release to ~/.local/bin:
curl -fsSL https://raw.githubusercontent.com/RunWield/mnemoteca/main/install.sh | sh
The installer installs mnemoteca. If it finds a final Mnemosyne command, it
can guide an explicit export/import migration and offer an optional compatibility
link. If no terminal is available for prompts, it installs Mnemoteca and skips
migration, cleanup, and link creation.
Make sure ~/.local/bin is on your PATH, then run:
mnemoteca --help
mnemoteca setup
mnemoteca setup downloads ONNX Runtime and the Jina v5 nano retrieval embedding
model. The optional cross-encoder reranker is downloaded only when enabled.
Setup is idempotent. It also runs automatically on first add or search. No HuggingFace account or API token is required for the built-in
models.
Windows release ZIP
Download the Windows release artifact named
mnemoteca_VERSION_windows_amd64.zip from the Mnemoteca GitHub release, extract
it, place mnemoteca.exe in a directory on PATH, then run:
mnemoteca.exe --help
mnemoteca.exe setup
The POSIX install.sh migration prompts and compatibility symlink do not apply
on Windows. See the migration guide before you replace an old installation.
Mnemoteca runs without administrator privileges, but restricted Windows devices
must trust the executable and ONNX Runtime DLL. If PowerShell reports that the
operation was canceled before Mnemoteca starts, see the
Windows startup and offline provisioning guide. It covers
security-event diagnostics, administrator approval, and staging models without
outbound access. Releases are unsigned unless release signing is configured.
Migrating from Mnemosyne
Use Migrate from Mnemosyne before you remove
old data or integrations. The guide covers:
- installer-guided macOS/Linux migration;
- manual macOS/Linux migration;
- manual Windows migration with no compatibility shim;
- partial-import recovery;
- cleanup safety;
- integration replacement order.
Connect Mnemoteca to your agent
Install the CLI once, then add the integration for each assistant you use. The
integrations share the same local Mnemoteca collections, so memories can follow
you across agents.
See each integration README for install commands, agent-specific configuration,
upgrade-from-Mnemosyne steps, and usage details. The agent-facing memory_*
tool names stay stable.
Other agents
For agents or IDEs that support AGENTS.md, project instructions, or similar
custom guidance, add this instruction block after installing the CLI:
## Memory System
- Use `mnemoteca search -f plain [query]` and `mnemoteca search -g -f plain [query]` to recall relevant context before decisions.
- Core memories are strong guidance; other memories are useful, non-authoritative context. Neither overrides the user, current project docs, the applicable plan, or code as evidence of implemented behavior. Resolve conflicts against those authorities; distinguish intended requirements from delivered behavior.
- Use `mnemoteca add "memory content"` only for current durable decisions, preferences, constraints, rationale, and reusable lessons. Use `-g` for cross-project defaults. Honor explicit requests to remember something.
- Do not store routine release dates, commit hashes, completed PR inventories, one-off test counts, or task-completion receipts. Extract a durable lesson when one exists; otherwise store nothing. Completion alone does not require a memory.
- Keep history only when it explains a still-relevant decision. State the current rule directly, not an obsolete claim beside a correction. Do not present proposed work or unverified recollections as current facts.
- Correct outdated memories with `mnemoteca update [memory id] "current guidance"`, or add and verify a replacement before removing the source with `mnemoteca delete [memory id]`. Remove routine bookkeeping after retaining any durable lesson.
- Mark only critical, always-relevant guidance as core with `-t core`. Core changes injection priority, not authority. Other tags can be supplied with repeated `-t` flags.
Sleep
For conservative memory maintenance, use the Sleep prompt.
It checks memories against current project authority, preserves durable understanding,
and removes obsolete guidance and routine bookkeeping with a backup and deletion manifest.
Quick Start
# See available commands
mnemoteca --help
# Check version
mnemoteca version
# Download ONNX Runtime and ML models
# This also happens automatically on first 'add' or 'search'.
mnemoteca setup
# Initialize a collection. The default name comes from the current directory.
mnemoteca init
# Add documents
mnemoteca add "Go is a statically typed programming language"
mnemoteca add "Rust focuses on memory safety and zero-cost abstractions"
mnemoteca add --file notes.txt
mnemoteca add --file README.md # Automatically chunks by semantic headings
printf 'Piped note' | mnemoteca add --stdin
mnemoteca add "Important project preference" -t core -t preference
# Search documents. Hybrid vector-first BM25 fusion is the default.
mnemoteca search "programming language"
mnemoteca search --limit 5 "systems programming"
mnemoteca search -f json --limit 10 "programming language"
mnemoteca search --fts-only --no-rerank "programming language"
mnemoteca search --vector-only --no-rerank "programming language"
mnemoteca search --fusion rrf --no-rerank "programming language"
# List documents
mnemoteca list
mnemoteca list -f plain
mnemoteca list --limit 5
mnemoteca list -t core
# List tags used in a collection
mnemoteca tags
# Update an existing document by ID
mnemoteca update 1 "Revised memory content"
mnemoteca update 1 --file revised-note.txt
printf 'Revised piped note' | mnemoteca update 1 --stdin
mnemoteca update 1 -t reviewed
mnemoteca update 1 --replace-tags -t core
mnemoteca update 1 --replace-tags
# Delete a document by ID
mnemoteca delete 1
# Use a named collection
mnemoteca init -n myproject
mnemoteca add -n myproject "some text"
mnemoteca update -n myproject 1 "revised text"
mnemoteca search -n myproject "some query"
# Use the global collection shortcut
mnemoteca add -g "Global memory"
mnemoteca list -g
mnemoteca update -g 1 "Revised global memory"
mnemoteca search --global "global memory"
# Show collections and database stats
mnemoteca collections
mnemoteca stats
mnemoteca stats --format json
# Delete an entire collection
mnemoteca forget -n myproject
mnemoteca forget -n myproject --yes
# Export a collection to JSONL. Vectors are included for fast import.
mnemoteca export --name myproject
# Export without vectors. Import will re-embed documents.
mnemoteca export --name myproject --no-embeddings
# Export all collections
mnemoteca export --all -o ./backups/
# Import a collection or a directory of collection JSONL files
mnemoteca import myproject.jsonl
mnemoteca import myproject.jsonl --name other
mnemoteca import memories.jsonl --global
mnemoteca import --dir ./backups/
# Import Claude Code memory without modifying Claude files
mnemoteca import --agent claude --dry-run
mnemoteca import --agent claude --include-user
Search Output Formats
The search command supports three output formats:
mnemoteca search -f color "query" # default human-readable color output
mnemoteca search -f plain "query" # stable plain text output
mnemoteca search -f json "query" # machine-readable output for scripts and benchmarks
JSON search output is an object with query, collection, count, and a
ranked results array. Each result includes:
rank, document_id, collection_id, content, created_at;
- parsed
metadata when document metadata contains valid JSON;
metadata_raw when metadata is present but not valid JSON;
rrf_score, fts_rank, vec_distance, reranker_score, is_reranked;
sources, such as ["fts", "vector"].
This format is intended for evaluation harnesses that must map retrieved
documents back to external corpus IDs stored in metadata.
Configuration
Fresh installs use Jina v5 nano retrieval (768 dimensions, last-token pooling),
vector-BM25 fusion with weight 0.10, 300 candidates, and cross-encoder reranking
disabled. These settings match the best saved FiQA nDCG@10 run; the LongMemEval
runs used the same model and fusion with 50 candidates.
Existing config files override these defaults. When switching an existing Arctic
database to Jina, export with --no-embeddings and import into a fresh database
to regenerate vectors with the new model.
Mnemoteca reads ~/.config/mnemoteca/config.yaml when it exists. You can also
point a command or benchmark run at another config file:
MNEMOTECA_CONFIG=./configs/jina-v5-text-nano-retrieval.yaml mnemoteca search "query"
MNEMOTECA_CONFIG_PATH=./configs/jina-v5-text-nano-retrieval.yaml mnemoteca search "query"
MNEMOTECA_DB_PATH=/tmp/mnemoteca.db mnemoteca add "temporary note"
Default data locations:
- macOS/Linux:
$XDG_DATA_HOME/mnemoteca or ~/.local/share/mnemoteca;
- Windows:
%LOCALAPPDATA%\mnemoteca, then %APPDATA%\mnemoteca, then
~/AppData/Local/mnemoteca;
- database:
<data-dir>/mnemoteca.db.
Use config.example.yaml as a starting point. Important
model fields are:
embedding.model_path: directory containing tokenizer.json, config.json,
and the configured ONNX file;
embedding.onnx_file: model path relative to embedding.model_path, usually
onnx/model.onnx;
embedding.dimensions: vector size stored in SQLite. Use a fresh DB or
re-import documents when this changes;
embedding.pooling: none, mean, cls, or last;
embedding.query_prefix and embedding.document_prefix: model-specific text
prefixes;
reranker.model_path: directory containing an ONNX cross-encoder reranker;
reranker.enabled: set false to disable reranking globally for that config.
mnemoteca setup auto-downloads the built-in default models. For custom model
paths, place the model files yourself and run with MNEMOTECA_CONFIG or copy
the config to the default location.
The configs/ directory includes benchmark-oriented profiles for larger
retrieval models, such as Jina v5 text retrieval. These profiles use a separate
benchmark DB when passed through the harness with --config and --run-label.
Mnemoteca does not read legacy config or environment names. If you migrate from
Mnemosyne, map each custom setting to MNEMOTECA_CONFIG,
MNEMOTECA_CONFIG_PATH, MNEMOTECA_DB_PATH, or
~/.config/mnemoteca/config.yaml explicitly.
Export and Import
Mnemoteca supports JSONL export and import for backup and transfer.
Export writes one JSONL file per collection. Each document includes:
content and metadata — the original document data;
vector — the raw embedding, omitted with --no-embeddings;
original_document_id — the source database ID for inspection.
Import reads a JSONL file and inserts documents into the database:
- If vectors are present, import is fast and model-independent.
- If vectors are missing, Mnemoteca initializes the embedder and creates vectors.
- If vectors are missing and the embedder cannot initialize, import returns an
error.