$ luarocks install luamemoluamemo is a persistent semantic memory store for AI agents
and conversational apps. It works in any Lua 5.1+ runtime:
plain Lua, LuaJIT, Lapis / OpenResty, CLI scripts, background
workers — no framework dependency.
Features:
* Hybrid vector + full-text retrieval over PostgreSQL.
* Three-tier ANN search: pgvector HNSW (O(log N)), LSH index
(pure Lua, auto-activates at >10k rows per scope, ~O(N^0.9)),
and brute-force REAL[] (always available, zero extension dep).
* Pluggable embedders: Ollama, OpenAI, Voyage, Cohere, DeepSeek,
Anthropic, generic HTTP, TEI (Hugging Face text-embeddings-
inference), and a built-in pure-Lua "hash" embedder with no
external dependencies.
* Pluggable rerankers (Ollama, OpenAI, cross-encoder via TEI).
* Background summarizer + decay/importance scoring.
* Knowledge-graph adjunct for currently-valid facts with temporal
validity (table: lm_kg_facts).
* Encrypted secrets management: AES-256-CBC + HMAC-SHA256
implemented in pure Lua (luamemo.crypto) — no lua-openssl
required. execute_with_secret substitutes {secret} server-side
without ever returning the raw value. Secrets stored in a JSON
file on disk (not a DB table).
* Batch write_many() dedup: O(1) DB queries per batch regardless
of batch size; intra-batch cosine dedup + async parallel embedding
via luamemo.async (pure-Lua coroutine scheduler).
* MCP server bundled (mcp/server.lua) so models can read/write
memory and execute secrets directly through Model Context Protocol.
Direct DB access via MEMO_DB_URL — no HTTP intermediary required.
* MCP prompts capability: built-in session_start prompt instructs
any MCP client to load context at session start, write decisions
during work, and summarise at the end. Includes proactive security
guidance: agents are instructed to recommend the terminal workflow
for storing secrets rather than asking users to type credentials
in chat.
* `memo` CLI: write, search, recent, get, update, delete,
summarize, promote, context, consolidate,
secret-store/list/delete/execute, migrate,
calibrate (host probe + codebase ingest), doctor (corpus health).
* `memo calibrate`: probes host (GPU, Docker, Ollama, RAM),
recommends the best-fit embedder, auto-applies schema migrations
when the DB is incomplete (Phase 2.5), detects VS Code / Cursor /
Claude Desktop and offers to write MCP config (Phase 5). Flags:
--no-migrate (skip schema check), --no-mcp (skip IDE detection).
* `memo doctor`: corpus health report with truncation counts,
p95 row size, and backend scale warnings.
* luamemo.cli.api: single-operation Lua dispatcher — CLI and
MCP server use direct lib calls; no HTTP server dependency.
Includes schema-check command (information_schema.columns
verification of both lm_memories and lm_kg_facts tables).
Benchmarks (R@10, LongMemEval n=500):
* hash embedder: 81.5%
* nomic-embed-text: 83.0%
* bge-m3 via TEI (GPU): 97.8%