Adding memory to Kimi Code

one /plugins install, and the sessions stop starting empty

Kimi Code starts each session empty, and the sessions it has kept are its own. The history that would answer today's question is usually spread across whatever else you were using in the months before.

What Kimi already has

Sessions are written under ~/.kimi-code/sessions as JSONL wire logs, one per agent within a session (KIMI_CODE_HOME moves the tree). They are readable and complete; nothing reads them back for you.

Adding recall

/plugins install https://github.com/vshulcz/deja-vu

Kimi installs the plugin from the repository — the manifest sits at the root, which is the only reason that file is there. It needs the deja binary, which is what indexes and searches:

brew install deja-vu
# or
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh

With the CLI instead, deja install kimi-auto writes the MCP server into mcp.json and a [[hooks]] block into config.toml. Having both is fine: the plugin reads those two files and skips whatever the installer already covers.

What arrives

  • The MCP server, with the deja tool and the eight modes it serves everywhere.
  • The deja-history skill, so the agent knows the CLI contract when the tools are not reachable.
  • /deja:recall <query> for asking directly.
  • The project digest on the first prompt of a session, and recall on every prompt after it — both through UserPromptSubmit hooks. Kimi appends a hook's stdout to the turn's context, and it runs every hook on that event, so the two sit side by side; the digest is held to one per session. Recall stays silent when the history has no answer.
  • Compaction recovery, through a PreCompact hook: Kimi waits for it before compacting, so deja reads the session from its wire.jsonl and the next prompt gets the task, the commands with whether they passed, and what was still open. The list of blocks already shown goes too, so recall can say them again.

Measured on Kimi Code 0.28.1 by reading the requests it sent: UserPromptSubmit is the only event whose output reaches the model. A SessionStart hook runs and its output goes nowhere, which is why the digest rides the first prompt instead; PreToolUse can block a tool but not add anything to it; PostToolUse and PostToolUseFailure are fire-and-forget, so deja install kimi-auto wires them on Bash with --defer: the repair that follows a failed command is held and handed over once, on this session's next prompt. PreToolUse on Edit and Write works the same way, so the line about the edited file arrives with the next prompt.

The part that is not about this harness

The index covers every agent's transcripts on the machine — forty-one of them today, each in its own format — so a fix found in one tool answers a question asked in another, including sessions from before any of this was installed. That is the reason to index rather than to capture.

Nothing here writes memories, so there is nothing to hallucinate into your history; indexing and search are local, and credentials are stripped as the index is built (privacy). An injection is capped at 1,536 bytes per prompt and about 4 KB per tool call — what memory costs has the measured comparison.

Getting started · When the same wall comes back · The Kimi Code session format · The plugin source

Found this useful? Star deja-vu on GitHub.