codeagent-memory

io.github.HanochZhu由 GitHub 帳號 HanochZhu 發布v0.1.6更新於 Oct 30, 2026

Local code graph and solution memory for coding agents via CLI and MCP.

發布方自己的服務:Memory.fit

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

為編碼代理設計的本地程式碼圖譜與記憶庫,讓助理透過 MCP 或 CLI 瀏覽符號並召回專案事實。

可以做什麼
  • 將程式碼倉庫索引成本地 SQLite 程式碼圖譜,並支援增量更新
  • 列出檔案與符號、依名稱搜尋符號、讀取單一符號內容、追蹤一跳呼叫者或被呼叫者
  • 以向量加 BM25 的混合檢索召回已存的專案事實、架構決策與除錯紀錄
  • 寫入原子記憶,可指定主題父節點、修訂鏈以及相關事實之間的連結
  • 檢視記憶樹與單筆記憶,並檢查專案狀態與設定
適用情境
適合編碼代理反覆重新探索同一個倉庫、且跨工作階段遺失上下文的情況,希望取得符號層級的讀取與持久專案記憶,同時不依賴外部 API。
執行需求
以本地程序透過 stdio 執行。需用 Rust 工具鏈透過 cargo 安裝 CLI,或掛載專案目錄執行已發布的 Docker 映像。未宣告 API 金鑰;首次 recall 或 add 會把預設嵌入模型下載到本地快取,離線時改用雜湊嵌入。
安裝前請注意
會在專案內寫入 .cam 目錄存放索引與記憶資料庫,記憶不會被刪除,只會被新版本取代。首次使用會從 Hugging Face 下載嵌入模型,除非設定離線嵌入器。可選的基準測試腳本需要 DeepSeek API 金鑰。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 codeagent-memory,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[cam logo]

cam

English · 中文 · 日本語 · 한국어 · العربية · 🌐 Website

A local multi-turn conversational memory system purpose-built for coding agents

Code graph + memory · surgical reads · 100% local · MCP + CLI

Kernel written in Rust

[Website] [License: MIT] [Rust] [Install]

[Windows] [macOS] [Linux]

[Claude Code] [Cursor] [Codex] [Windsurf] [GitHub Copilot] [Continue] [Cline] [JetBrains]

Contents

Guides: Interactive Showcase (Website) · Main Agent vs Subagent · MCP Configs by IDE · 中文说明


Why cam?

When an AI coding agent explores a repository, it usually rediscovers structure the slow way — running grep, glob, and full-file Read one file at a time — and forgets everything in the next session.

cam gives the agent two local retrieval planes in a single binary:

PlaneWhat it storesHow the agent uses it
Code GraphTree-sitter symbols (functions, types, methods) as a virtual filesystem + 1-hop callers/calleesls, find, read src/file.rs/symbol, ref symbol --dir in|out — surgical symbol reads instead of whole-file dumps
Memory TreeProject facts, architecture decisions, debugging write-ups, and user habitsrecall (Vector + BM25 fused with RRF) and add (with branching --parent and revision --supersedes)

One binary, two interfaces: The main agent calls cam over MCP (cam mcp); subagents (which rarely inherit MCP tools) call the exact same CLI (cam --json …). Both share .cam/cam.db on disk, 100% local, zero API cost.


Get Started

Option 1: One-Sentence Agent Install (Recommended)

Paste this prompt directly into your coding agent (Cursor, Claude Code, Codex, Windsurf, GitHub Copilot, Cline, etc.) and let it install, index, and wire cam for you:

text
Install cam from https://github.com/HanochZhu/codeagent_memory: require a working Rust toolchain (rustup), run `cargo install --git https://github.com/HanochZhu/codeagent_memory --locked`, ensure ~/.cargo/bin (or %USERPROFILE%\.cargo\bin on Windows) is on PATH, then verify with `cam --help`. In this repo run `cam index`. For the main agent, register MCP stdio: command `cam`, args `["mcp"]` (Cursor: .cursor/mcp.json; Claude Code: .mcp.json). Subagents call `cam --json` in the shell. Do not add extra docs.
How each IDE / agent handles this prompt
EnvironmentWhat to do
Cursor / Windsurf / Claude Code / CodexPaste into Agent / Chat; the agent runs the terminal install, builds .cam/cam.db, and writes the MCP config
VS Code (Copilot / Continue / Cline)Paste into Agent / Chat mode with terminal access enabled
JetBrains (IntelliJ / RustRover / GoLand)Paste into AI Assistant, or run cargo install in the built-in terminal

Note: cargo install places cam in ~/.cargo/bin (Windows: %USERPROFILE%\.cargo\bin). Restart your terminal or IDE if cam is not immediately found on PATH.


Option 2: Manual Setup

1. Install the CLI

Requires a Rust toolchain:

bash
cargo install --git https://github.com/HanochZhu/codeagent_memory --lockedcam --help
Alternative: Build from local clone or run via Docker

From a local clone:

bash
git clone https://github.com/HanochZhu/codeagent_memory.gitcd codeagent_memorycargo install --path . --locked

Docker (no Rust toolchain required):

bash
docker pull ghcr.io/hanochzhu/codeagent-memory:0.1.6docker run -i --rm -v "$PWD:/work" -w /work ghcr.io/hanochzhu/codeagent-memory:0.1.6

Or build locally: docker build -t cam https://github.com/HanochZhu/codeagent_memory.git

2. Index & query your project
bash
cd your-projectcam index                                              # parse repo into .cam/cam.db
# Query the code graphcam ls src/                                            # list files or symbols in a filecam read src/main.rs/main                              # read a single symbol bodycam ref main --dir in                                  # 1-hop callers (in) or callees (out)
# Query & write to the memory treecam recall "how does hybrid recall fuse BM25 and vectors"cam add --summary "..." < notes.md

cam auto-initializes .cam/ on first use. Run cam watch in the background if you want live incremental graph updates as files change.

3. Connect MCP for the main agent

Add cam mcp to your host's MCP configuration (e.g. .cursor/mcp.json or .mcp.json):

json
{  "mcpServers": {    "cam": {      "command": "cam",      "args": ["mcp"]    }  }}

See docs/mcp.md for host-specific config paths and docs/agents.md for main-agent / subagent prompt rules.

The first recall or add downloads the default embedding model (potion-multilingual-128M to ~/.cam/models/) and falls back to a lexical hash embedder if offline.


Key Features

FeatureDetails
SQLite Code GraphTree-sitter parses functions, types, and call edges into .cam/cam.db for instant symbol-level navigation
Virtual Pathssrc/main.rs addresses a file outline; src/main.rs/main addresses the symbol body directly
Live Incremental Synccam sync hashes file contents; cam watch keeps the graph updated on save
Hybrid Recall (RRF)Combines local dense embeddings (model2vec) + identifier-aware BM25 via Reciprocal Rank Fusion ($k=60$)
Revision Chains & Tree--parent builds branching topic hierarchies; --supersedes links linear revisions and folds older entries automatically
Ebbinghaus RetentionRetention $R = e^{-t / S}$ gently weights ranking ($\le 10%$) and flags stale / needs_update memories without deleting history
Dual Interface (MCP + CLI)Main agent uses cam_* MCP tools; subagents run cam --json … in the shell
100% Local & PrivateZero external API keys; runs entirely on local SQLite and on-disk embeddings
9 LanguagesRust, Python, TypeScript, JavaScript, Go, Java, C, C++, C#

How It Works

[How cam works]

  1. Extract — tree-sitter walks the workspace and stores symbol definitions and call edges in .cam/cam.db.
  2. Surgical Read — Agents navigate via virtual paths (ls → find → read → ref). Reading a file returns its symbol outline; reading file/symbol returns only that symbol's source slice.
  3. Hybrid Recall — recall takes an English query, embeds it locally, runs identifier-aware BM25 (splitting snake_case, kebab-case, camelCase + English stemming), prunes low-confidence tails, and fuses both lists with RRF ($k=60$) scaled by $0.9 + 0.1 \times R$. Superseded revisions are automatically expanded to their newest replacement.
  4. Write-Back — When an agent solves a non-trivial task, it extracts atomic facts so each add stores only one fact (English summary; body supports non-Latin characters). Related facts are connected via --link / links into a knowledge graph (inspected via mem show; recall does not traverse graph links yet). --parent attaches a memory to a structural topic; --supersedes replaces an outdated memory while preserving lineage.

Architecture deep dive (Chinese): DESIGN.md.


Agent Workflow

Every coding task follows the same four-step loop:

  1. Recall first — Query cam_recall / cam recall in English before grepping. Reuse a hit if it is latest and not needs_update.
  2. Ensure indexed — If graph tools return not_indexed, run cam_index / cam index once for the project.
  3. Walk the graph — On a memory miss, locate symbols with find or ls, read symbol bodies with read <file>/<symbol>, and trace callers/callees with ref <symbol> --dir in|out.
  4. Write back — Persist newly discovered architecture facts or fixes with cam_add / cam add as atomic facts (one fact per memory, English summary; body supports non-Latin characters), linking related facts with links / --link.
RoleInterfaceTypical Usage
Main Agent (Chat / IDE session)MCP (cam mcp)Calls cam_recall, cam_find, cam_ls, cam_read, cam_ref, cam_add, cam_mem_tree, cam_mem_show directly
Subagent (Task / explore / CLI)CLI (cam --json)Runs cam --json --project <dir> <cmd> in the shell (subagents rarely inherit MCP tools)

Full agent rules & copy-paste system prompts: docs/agents.md.


CLI Reference

Code Graph Commands

CommandDescription
cam indexParse the project with tree-sitter into .cam/cam.db (creates .cam/ if needed)
cam syncIncrementally update the graph for modified files using content hashes
cam watch [--debounce-ms N]Watch source files and auto-sync (--json streams one JSON report per sync)
cam ls [virt_path]List directories, files, or symbols inside a file
cam read <virt_path> [--full]Read a file's symbol outline, a specific symbol body (path/symbol), or the --full file
cam find <query> [--kind K] [--file S] [--scope D] [--limit N]Case-insensitive substring search over symbol names (exact matches first, then prefixes)
cam ref <symbol> --dir in|out [--file S] [--kind K] [--scope D]1-hop callers (in / --callers) or callees (out / --callees). Returns ranked candidates on ambiguous names

Memory Commands

CommandDescription
cam recall "<query>" [--limit N] [--no-expand] [--include-superseded] [--snippets]Hybrid RRF recall (English query). --no-expand skips newest-revision expansion; --include-superseded keeps old revisions; --snippets clips long bodies below rank 1
cam add --summary "..." [--parent ID] [--supersedes ID] [--link ID]... [--body TEXT | --file PATH]Store one atomic fact as a memory (English summary required; body supports non-Latin characters; via --body, --file, or stdin). --link connects related facts in the knowledge graph; --parent for topic hierarchy; --supersedes to replace an older memory
cam mem treeRender the memory hierarchy and revision chains
cam mem show <id>Inspect a single memory entry in full

Server & Configuration Commands

CommandDescription
cam mcpStart the stdio MCP server for the main agent (see docs/mcp.md)
cam statusShow resolved project root, database path, node/edge/memory counts, and active config
cam config getPrint current ~/.cam/config.toml settings
cam config set stale_days <N>Set age threshold (in days) for marking memories stale
cam config set embedding_model <model>Set Hugging Face model2vec repo, local model directory, hash, or default

Global flags & conventions:

  • --project <dir> (or CAM_PROJECT env var) overrides automatic upward .cam / .git root detection.
  • --json emits compact JSON (--pretty for indented JSON). Errors on --json print {"error":{"code":…,"message":…}} to stdout and exit non-zero.
  • Ambiguous symbols: When read or ref matches multiple definitions, cam returns status: "ambiguous" with candidate node IDs (e.g. src/main.rs:function:main:12) that can be passed directly back to read or ref.
  • Ignore rules & multi-repo directories: Honors .gitignore and .camignore at any depth. A nested directory with its own .git (standalone clone, submodule, or linked worktree) is indexed into that directory's .cam/cam.db. The parent database keeps a catalog of those graphs and queries fan out into them, so opening the nested directory reuses the graph. cam ls lists them as kind: "project" (passable to --scope).

Memory Rules

  • Atomic facts & knowledge graph links: Store only one atomic fact per memory to avoid packing excessive information into a single entry. When multiple facts are related, link them with --link / links to form a knowledge graph (graph recall is not enabled yet).
  • English queries and summaries: Recall queries and memory summaries must be written in English. Memory bodies support non-Latin characters.
  • Retention & reinforcement: Ebbinghaus retention $R = e^{-t / S}$ adjusts recall score via $\text{relevance} \times (0.9 + 0.1 \times R)$. Entries with $R < 0.3$ are marked needs_update; entries older than stale_days (default 30) are marked stale. Every valid recall hit (needs_update = false) refreshes last-accessed time and multiplies stability $S$ by 1.7.
  • Non-destructive lineage: Memories are never deleted. --parent forms branching trees; --supersedes forms linear revision chains where only the tail is marked latest and older revisions are folded out of default recall results.

Configuration

Global settings live in ~/.cam/config.toml:

toml
stale_days = 30# embedding_model = "minishlab/potion-multilingual-128M" # default (cached under ~/.cam/models/)# embedding_model = "minishlab/potion-base-8M"           # lighter Hugging Face model2vec repo# embedding_model = "/path/to/local/model2vec"           # dir with tokenizer.json, config.json, model.safetensors# embedding_model = "hash"                               # zero-download lexical hash embedder

Use CAM_EMBED_MODEL to override the model for a single process, or cam config set embedding_model default to reset. When the embedding model changes, the next recall automatically re-embeds existing memories before scoring.


Benchmarks

cam evaluates its code graph and memory planes separately against the closest open-source systems on identical corpora:

PlaneBaseline / AnalogueBenchmark CorpusHeadline Takeaway
Memoryagentmemory hybrid + tokenized grepcoding-agent-life-v11.000 R@5 / 0.240 P@5 (matches hybrid ceiling, 1.000 newest R@5 on revision chains)
Long-term MemoryBM25 / dense retrieversLongMemEval-S0.909 R@5 / 0.980 Hit@5 / 0.840 MRR with potion-multilingual-128M
Code Graphcodegraph v0.9.6LongMemCode (clap)0.769 vs 0.768 on supported 1-hop tasks, P95 ≈ 5.2 ms, $0
Workflow RetrievalLexical / BM25 file retrievalAgent Retrieval Bench V2 edit2ripple0.297 MRR (best first-hit rank, P95 7.3 ms)
Multi-turn TokensFull context dumpDeepSeek multi-turn57% fewer tokens on memory track, 98% fewer tokens on code track

General chat memory frameworks (Mem0, Zep, Letta) target conversational logs rather than these coding-agent corpora and are omitted from the tables below.

System Comparison

camagentmemorycodegraph
What it storesCode graph + memory treeSession / chat memoriesCode graph
Query primitivesrecall / ls / find / read / refsmart-search / rememberexplore / callers / callees
InterfaceMCP + CLIMCP + REST + hooksMCP + CLI
Ranking / FusionVector + BM25 + RRF + retentionBM25 + embed + rerankFTS5 + graph walk
Cost100% local ($0)Local serverLocal

1. Memory — coding-agent-life-v1

15 sessions, 15 queries, $k=5$ (same scoring as agentmemory score.ts; P@5 ceiling is 0.240).

SystemHit RateR@5P@5Source
grep (tokenized substring)15 / 150.9670.227this repo, 2026-09-23
cam min-max sum (legacy)15 / 150.9330.213historical, hash embed
cam RRF15 / 151.0000.240this repo, hash embed
agentmemory hybrid15 / 151.0000.240published v0.9.26

[coding-agent-life headline R@5 and P@5 / ceiling]

[coding-agent-life R@5 by question type]

Revision chains (--lineage): Re-ingesting every turn as a --supersedes revision tests whether top-$k$ returns the newest node of each gold chain (newest R@k) and whether any superseded node falsely claims latest (stale latest).

kR@kP@knewest R@kstale latest
51.0000.2401.0000
101.0000.1201.0000

2. Long-Term Memory — LongMemEval-S

100 non-abstention questions sampled with seed 42 from cleaned LongMemEval-S. Retrieval fuses embeddings + BM25 with RRF at $k=10$ without an LLM reader.

EmbedderR@1R@5R@10Hit@1Hit@5Hit@10MRRRetrieval P50 / P95
hash (offline test)0.3820.8030.9220.5800.9100.9700.71824.1 / 35.5 ms
potion-multilingual-128M0.4740.9090.9520.7400.9800.9900.8401.12 / 1.34 s

3. Workflow Retrieval — Agent Retrieval Bench V2 (edit2ripple)

58 anchored-change queries across 44 frozen repository snapshots (no LLM; BCY = Budgeted Context Yield under the canonical 8K-token file-packing protocol).

SystemRecall@5Recall@10Recall@20MRRBCY@8k
cam graph0.3000.3350.3780.2970.300
Lexical0.4120.5360.5880.2430.447
BM250.2070.2870.4990.1540.243

cam graph achieves the highest first-hit rank (MRR 0.297, query P95 7.3 ms), while lexical search provides broader multi-file coverage — motivating graph + lexical rank fusion.

4. Code Graph — LongMemCode (clap)

clap v4.6.1, 536 scenarios against SCIP gold (no LLM, P95 ≈ 5.2 ms, $/1k = 0).

Slicencamcodegraph 0.9.6
Supported (1-hop)4780.7690.768
lookup / file_symbols293 / 550.808 / 0.9150.808 / 0.915
callers / callees67 / 180.397 / 0.8110.355 / 0.867
implementors400.1190.094
Raw / Weighted (all 536)5360.709 / 0.7040.704 / 0.700

[LongMemCode clap accuracy bars]

[LongMemCode clap accuracy by operation]

5. Multi-Turn Token Savings — DeepSeek

Full context dump vs. per-turn cam retrieval (deepseek-flash, hash embedder, 2026-10-13):

TracknFull Acc.cam Acc.Full Tokenscam TokensToken Saving
Memory (coding-agent-life)151.000.8722,7969,90457% (1,471 → 616 / turn)
Code (this repo indexed)60.830.33379,0666,34298% (63,076 → 1,000 / turn)

[DeepSeek multi-turn prompt token bars]

[DeepSeek multi-turn prompt tokens]

6. Memory writing — who decides what one memory is

The notes are a separate case set, cam-write-memory-eval. This repo keeps the runner. The first eval/write_memory/run.py downloads cases.json to eval/write_memory/data/ (override with CAM_EVAL_WRITE_MEMORY). That is the same split as LongMemEval and LoCoMo: the corpus stays outside, and the script here fetches it when you run the benchmark.

A model receives one note and calls cam_add. legacy asks for one full write-up. split asks for one fact, or one problem's solution path, and links pieces from the same solution with #0. A fact counts as exclusive when one stored memory contains every required phrase and no other gold fact. The notes are public behavior of this repository: recall fusion, the stale-binary restart notice, retention, and read versus delete. Labels and source files are in the case-set README.

Reproduce all benchmarks

Dataset paths are configured in eval/datasets.toml (coding-agent-life-v1 defaults to ../agentmemory or CAM_EVAL_CODING_LIFE).

bash
python3 eval/coding_life/run.py --adapter greppython3 eval/coding_life/run.py                                             # potion; errors if the model failspython3 eval/coding_life/run.py --hash-embed                                # hash embedderpython3 eval/longmemeval/run.py --sample 100 --seed 42 --workers 8          # potionpython3 eval/longmemeval/run.py --sample 100 --seed 42 --workers 8 --hash-embedpython3 eval/locomo/run.py --workers 4                                      # potion, evidence recall
git clone --depth 1 https://github.com/eyuansu62/agent-retrieval-bench \  eval/agent_retrieval/vendor/agent-retrieval-benchpython3 -m pip install -e eval/agent_retrieval/vendor/agent-retrieval-bencharb download-benchmark --version v2_edit2ripple --local-dir eval/agent_retrieval/data --forcepython3 eval/agent_retrieval/run.py --workers 8
python3 eval/llm_multiturn/run.py --track both   # potion; requires DEEPSEEK_API_KEYpython3 eval/write_memory/test_score.py          # downloads the case set; no model callpython3 eval/write_memory/run.py                 # downloads the case set; DEEPSEEK_API_KEYpython3 eval/longmemcode/run.py --corpus clappython3 eval/charts/generate.py

Supported Agents

Register cam mcp (stdio) for the main agent; subagents use the cam --json CLI directly with zero extra setup.

HostMCP ConfigurationSubagent / Notes
Cursor.cursor/mcp.json, ~/.cursor/mcp.json, or .cursor-plugin/plugin.jsonTask / explore subagents use CLI
Claude Code.mcp.json, ~/.claude.json, or claude mcp add cam -- cam mcpLimited-tool subagents use CLI
Codex~/.codex/config.toml → [mcp_servers.cam]codex exec uses CLI
Windsurf~/.codeium/windsurf/mcp_config.jsonCascade uses MCP
GitHub Copilot.vscode/mcp.json or ~/.copilot/mcp-config.jsonChat uses MCP; CLI scripts use CLI
Continue / Cline~/.continue/config.yaml / ~/.cline/mcp.json
JetBrainsAI Assistant → MCP (cam / mcp)Use absolute path to cam if IDE PATH is empty
Gemini CLI / Antigravity / OpenCode / Zed / DroidSee docs/mcp.md

Copy-paste configs: docs/mcp.md · System prompts: docs/agents.md.


Supported Languages

LanguageExtensionsIndexed Nodes & Edges
Rust.rsfunctions, structs, enums, traits, calls
Python.pyfunctions, classes, calls
TypeScript.ts, .tsxfunctions, methods, classes, calls
JavaScript.js, .jsxfunctions, methods, classes, calls
Go.gofunctions, methods, structs, calls
Java.javafunctions, methods, classes, interfaces, calls
C.cfunctions, structs, calls
C++.cc, .cpp, .cxx, .h, .hppfunctions, methods, classes, structs, calls
C#.csfunctions, methods, classes, interfaces, calls

Supported Platforms

cam compiles natively on macOS, Linux, and Windows via cargo install --git https://github.com/HanochZhu/codeagent_memory --locked, or runs anywhere via Docker (ghcr.io/hanochzhu/codeagent-memory:0.1.6). See Get Started.


License

MIT


Made for AI coding agents — Claude Code, Cursor, Codex, Windsurf, Copilot, and JetBrains

Report Bug · Request Feature

來源:README.md,提交 ea61458

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:該軟體包類型無法在沙箱中執行。

版本歷史

4
  1. v0.1.6最新Oct 30, 2026
  2. v0.1.5Oct 20, 2026
  3. v0.1.4Oct 16, 2026
  4. v0.1.3Oct 13, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Memory 整合