@everme/kimicode
v0.3.4
Published
EverMe native plugin for Kimi Code — automatic memory recall via SessionStart/UserPromptSubmit/Stop/SessionEnd hooks, plus bundled MCP server. Single self-contained kimi.plugin.json manifest.
Readme
EverMe — Kimi Code plugin
Automatic memory recall + persistence for Kimi Code, backed by the EverMe gateway.
What it does
- SessionStart → loads recent context (profile + episodes) from past sessions and prints it to stdout, which Kimi Code appends to the model context (wrapped in
<everme_profile>). - UserPromptSubmit → searches your memory for content relevant to the prompt you just typed and prints it (wrapped in
<everme_recall>) BEFORE the model sees the prompt. Silent when no relevant hit (no nag). - Stop → after each Kimi reply, locates the session's
wire.jsonltranscript, extracts the just-finished raw turn (including tool calls), and persists it to/mem/agent-memory. - SessionEnd → no persistence; Stop owns runtime writes so Kimi Code does not create
/mem/sources.
Plus:
- MCP server (
everme-memory, the standalone@everme/memory-mcp) exposingmem_search+mem_context(explicit recall) andmem_save_turn+mem_save_fact(explicit write). - Skills
memory-recall(session-start primer) andmemory-tools(when/how to use the search tools).
Manifest
Unlike the Claude Code plugin (which splits plugin.json + hooks/hooks.json + .mcp.json), Kimi Code uses a single self-contained kimi.plugin.json at the plugin root that declares mcpServers, hooks, skills, and sessionStart inline.
Hook output contract
The hooks emit a JSON envelope on stdout — a single line {"message":"<recall/profile text>"} — and Kimi Code injects the message field into the model context. So SessionStart / UserPromptSubmit write JSON.stringify({ message: block }); the recall/profile text is carried in message, not printed as bare stdout. On any error or no-data, the hooks exit 0 with no output and never block the host.
Transcript location (Stop hook)
Kimi Code's Stop hook receives no transcript path on stdin. The transcript lives at:
$KIMI_CODE_HOME/sessions/<workDirKey>/<session_id>/agents/main/wire.jsonlwhere <workDirKey> = wd_<slug>_<first-12-hex-of-sha256(cwd)> and <session_id> is the stdin session_id. The Stop hook derives this from session_id + cwd + KIMI_CODE_HOME (default ~/.kimi-code). Kimi's slug rule preserves characters (e.g. hyphens) that a naive reconstruction would rewrite, so the bucket dir is located by its sha256(cwd)[:12] suffix — identical on both sides — rather than by rebuilding <slug>. It then reads wire.jsonl, extracts the last turn, and persists it.
Credentials
Kimi Code's mcpServers.env cannot carry per-user secrets (no ${VAR} expansion), so credentials are NOT placed in the manifest. Both the MCP server and the hooks read them at runtime from:
$KIMI_CODE_HOME/everme.env (default ~/.kimi-code/everme.env)This file is written by the EverMe Go CLI installer (evercli), in KEY=value form.
Configuration
| Env var | Purpose |
|---|---|
| EVERME_API_KEY | Account-level emk. Supports recall-only mode. |
| EVERME_AGENT_TOKEN | Per-machine evt. Required for realtime writes and wins over emk when both are set. |
| EVERME_AGENT_ID | Required with EVERME_AGENT_TOKEN for realtime writes; also pins recall to a specific cloud agent. |
| EVERME_API_BASE | Gateway host. Defaults to https://api.everme.evermind.ai. Set to http://localhost:8080 for local dev. |
| EVERME_ENV_FILE_PATH | Override the env-file location (defaults to $KIMI_CODE_HOME/everme.env). |
| EVERME_DEBUG | 1 to print hook traces to stderr (with token redaction). |
| KIMI_CODE_HOME | Kimi Code home dir; the hook process always sets this. Defaults to ~/.kimi-code. |
Files
kimi.plugin.json single self-contained manifest (mcpServers + hooks + skills + sessionStart)
hooks/scripts/inject-memories.mjs UserPromptSubmit handler
hooks/scripts/store-memories.mjs Stop handler
hooks/scripts/session-start.mjs SessionStart handler
hooks/scripts/session-summary.mjs SessionEnd handler
hooks/scripts/lib/api.js Gateway HTTP client (agent-memory, search, context) [copied from claude-code]
hooks/scripts/lib/config.js Env-var resolution (emk vs evt); env-file at $KIMI_CODE_HOME/everme.env
hooks/scripts/lib/profile.js /mem/context profile renderers [copied from claude-code]
hooks/scripts/lib/redact.js evt/emk/X-Amz-Signature scrub for logs [copied from claude-code]
hooks/scripts/lib/kimi-transcript.js wire.jsonl locator + parser (readLastTurn)
hooks/scripts/lib/kimi-stdin.js snake_case stdin JSON reader
skills/memory-recall/SKILL.md session-start primer skill
skills/memory-tools/SKILL.md always-injected skill — when/how to use the tools
LICENSE
README.mdLicense
Apache-2.0
