Skip to content

write-surfaces

1. The block, verbatim

There are three ways to put a memory into the corpus, and they are all legitimate. First, this CLI: memhtml write for one memory, memhtml apply for many. Second, the MCP server: memhtml serve mcp speaks stdio with the same tools and resources over this same repo, and it is the door to use when you are already an MCP client. Third, editing files under $MEMHTML_ROOT directly with your normal file tools: the git tree IS the system of record and .memhtml/index.db is only a projection of it, so a hand-written or hand-edited memory file is as real as one this CLI wrote. memhtml index update projects uncommitted working-tree changes as well as committed ones, so a dirty edit is searchable before you commit it. What you take on by editing directly is everything the write path would have done for you: the file must satisfy the format (run memhtml doctor, and memhtml read <path> reports per-file format warnings), you own choosing a path that does not collide, you own noticing that the content already exists somewhere else, and you own the commit. A CLI command and a running memhtml serve mcp may share one store: the index is WAL SQLite, which admits one writer at a time and any number of concurrent readers, so a second writer waits its turn rather than failing. The git side is the same: every write that commits (any process’s write, apply, correct, link, archive, task status, publish, state export, doctor --fix, and every session commit and curate merge) holds the checkout lock .memhtml/checkout.lock from its first stage to its commit, so one writer’s commit never takes another’s staged file. A writer waits up to 15 s for it and then fails with ERR_STORAGE (checkout.locked), having written nothing; run it again. The one thing to keep clear of is a checked-out curate/<date> branch: a write landing while one is checked out commits onto that branch and is merged as if it were curation or lost when the branch is dropped. Under MEMHTML_SESSION (an agent runtime exports it to every subprocess of a run) the first door is the session one instead: write, apply, correct, and task add answer ERR_SESSION_BOUND, and a record goes in through memhtml session exec (a heredoc that writes the file under /mnt/memhtml) or memhtml session put, both held to the write bar, and the runtime commits the run’s session when the run ends. The store’s memhtml.config.json chooses that: v1Doors is closed-in-session (the default, as just described), open (the doors stay open even in a run), or closed (they answer ERR_V1_DOOR_CLOSED in every process, and records go in through a session you start, write, and commit). The MCP tools memory_write, memory_write_batch, and memory_correct follow the same mode, reading MEMHTML_SESSION from the MCP server’s own environment. memhtml config shows the store’s mode.

2. Commands it names

3. Provenance

A loader generates this page from apps/cli/src/commands.ts while the site builds, so no file in the repository holds it: the block is authored beside COMMANDS and is served verbatim by memhtml manifest, so this page and the live answer are the same bytes. Change the registry and this page changes with it.