Adding memory to CodeBuddy Code

the CLI and WorkBuddy desktop share the same session layout and Claude-shape hooks

CodeBuddy Code (@tencent-ai/codebuddy-code) writes every conversation to disk and starts the next session blank. Its desktop counterpart, WorkBuddy, runs the same agent under its own configuration directory. Both stores sit on disk alongside whatever the other forty-two coding agents on the machine wrote.

What CodeBuddy already has

Sessions live under ${CODEBUDDY_CONFIG_DIR:-~/.codebuddy}/projects/<mangled-cwd>/<session-id>.jsonl, one JSONL file per conversation, with sub-agent runs under <session-id>/subagents/agent-<id>.jsonl. WorkBuddy writes the same layout under ~/.workbuddy/projects (workbuddy.cn), ~/.workbuddy-ai/projects (workbuddy.ai), or $WORKBUDDY_CONFIG_DIR/projects.

Adding recall

deja install codebuddy-auto

That wires the MCP server, the recall hooks and the status line for CodeBuddy Code. If you only want the MCP tool without automatic hook injection, run deja install codebuddy.

Because WorkBuddy launches the agent with CODEBUDDY_CONFIG_DIR pointed at its own home, wiring in ~/.codebuddy never reaches the desktop app. Wire WorkBuddy in its own directory with:

deja install workbuddy-auto

WorkBuddy writes its MCP configuration to mcp.json in the WorkBuddy home. In WorkBuddy AI, new MCP servers start disabled until you click Trust in Settings > MCP and restart the app; deja doctor reports the server as untrusted until you do.

What gets wired

deja install codebuddy writes the MCP server to the first of ~/.codebuddy/.mcp.json, ~/.codebuddy/mcp.json or ~/.codebuddy.json that already exists, or creates ~/.codebuddy/.mcp.json. deja install codebuddy-auto also writes six hooks in Claude Code's schema (with timeout in seconds) into ~/.codebuddy/settings.json and sets statusLine.command there if none is set:

  • SessionStart delivers the project digest before the first turn.
  • UserPromptSubmit injects matching history for the prompt and stays silent when nothing matches.
  • PostToolUse and PostToolUseFailure on Bash|PowerShell attach the prior fix when a shell command fails with an error solved on this machine before.
  • PostToolUse on Read|Edit|Write|MultiEdit adds the decisions past sessions recorded for that file.
  • PreCompact and SessionEnd preserve the pre-compaction state and close out the active session stamp.

Resuming a session

codebuddy -r <id> looks for the session only under the folder of the current working directory, and -r by itself drops the SessionStart hook context. Passing -c alongside -r keeps the SessionStart context while still selecting the session id, so deja resume <id> runs codebuddy -c -r <id> in the project directory.

The part that is not about this harness

The index covers every agent's transcripts on the machine — forty-three of them today, each in its own format — so a fix found in Claude Code or Qwen Code answers a question asked in CodeBuddy. Indexing and search stay local, and credentials are stripped as the index is built (privacy).

Getting started · Deleting CodeBuddy sessions · How CodeBuddy's store is read

Found this useful? Star deja-vu on GitHub.