mcky.space
mcky.space

คลังความจํา

mem

A memory service for agents that is really just a wiki: markdown pages on disk are the source of truth, a derived SQLite index makes them searchable, and every agent can write.

go + sqlite markdown files no embeddings loopback by default

Repository The other tool: vaultctl

ปัญหาที่แก้ · the problem

An agent that starts empty re-learns the same facts

Every new session begins by rediscovering the host, the ports, the command that almost worked. Notes and transcripts both fail the same way: the fact is in there somewhere, and the agent cannot find it in time to use it.

mem holds those facts where an agent can write them in one call and read them back instantly. The first attempt here, minimem, proved the shape of the problem: search was easy, keeping a store worth reading was not. The second attempt, mem v1, over-corrected with a review gate and a graph. This version goes back to the plain thing that works, a wiki.

the store

Markdown files, one page per topic

~/mem-wiki/*.md · derived SQLite index

Markdown is the interface, not an export. Any agent with filesystem access can read or append a page directly, with the same result as the HTTP API, and the file on disk is always the thing that is true.

writing

Every agent writes, the writer is provenance

v1 routed agent writes through a steward and an inbox, and the inbox was the whole problem: nothing an agent wrote was real until a human accepted it. v2 has no gate. A valid token writes immediately; the identity it carries is recorded next to the fact, not enforced on top of it.

What a write does
Call Result
POST /v1/memory/nodes append a fact line to the page for its topic, active at once
POST /v1/memory/extract the same append, for a remembered blob
POST /v1/wiki/pages create or upsert a page
PUT /v1/wiki/pages/<slug> replace a page body
DELETE /v1/wiki/pages/<slug> move the page to the trash

The compat endpoints from v1 still answer, so older clients keep working: inbox is always empty and promote / reject answer noop, because there is no queue left to move through.

search

The index tokenizer is trigram, not a word tokenizer. That is the whole trick: ระบบความจํา has no spaces, so a word tokenizer would file it as one long unknown term, while a trigram index matches it by substring, the same way it matches postmarketOS. Queries of three characters or more run as an FTS match; shorter queries and zero-hit results fall back to a plain LIKE scan. No tokenizer to tune, no embedding provider, and nothing to fall back from.

# find the page, then read it back
mem search "salt backup"
mem show "mem service"

http api

The whole surface

base url http://127.0.0.1:3200

Endpoint Method Purpose
/healthGETliveness, no auth
/v1/wiki/pagesGET, POSTlist pages, or create and upsert one
/v1/wiki/pages/<slug>GET, PUT, DELETEread, replace or trash a page
/v1/wiki/reindexPOSTrebuild the index from the files
/v1/memory/nodesGET, POSTlist pages as nodes, or append a fact
/v1/memory/searchGET, POSTtrigram search with a LIKE fallback
/v1/memory/contextGET, POSTsearch results joined into one block for a prompt
/v1/memory/extractPOSTappend a remembered blob as a fact
/v1/memory/statsGETpage and fact counts
/v1/memory/briefGETa short digest of recent pages
/v1/memory/inboxGETalways empty; kept for old clients
/v1/memory/backupGETthe wiki as one gzipped tar (index excluded)
/v1/memory/restorePOSTreplace the pages from that tar, then rescan
/GETthe web UI (basic auth)

surfaces

A terminal, a browser, and an MCP shim

# the whole store in one file, then back again
mem backup --file /var/backups/mem-$(date +%F).tar.gz
mem backup --file - | ssh other-host mem restore --file -

running it

One binary, loopback by default

ข้อจํากัด · known limits

What it will not do