src/ + tests/(440 檔)· 對齊 commit 2c50c77 · graphify 0.9.36worked/cbm-source/。codebase-memory-mcp(CBM)本身就是一個把 codebase 變知識圖譜的工具。用 graphify 再掃一次 CBM 的源碼,有幾個教學價值:
上游 main @ 2c50c77(2026-08-08)的第一方程式碼:
| 部分 | 內容 | 檔案數 |
|---|---|---|
src/ | CBM 主體 C 源碼(main/mcp/store/cypher/cli/pipeline/daemon/discover/semantic/ui…) | 193 |
tests/ | 測試(6,768 tests 的 C 測試碼、Hybrid LSP 各語系測試) | 247 |
| 合計 | 純 C 語料(--code-only,零 LLM 成本) | 440 |
刻意排除 internal/cbm/vendored/(974 檔第三方 tree-sitter grammars 生成碼)與 docs/assets——圖要呈現「CBM 自己的工程」,不是第三方生成碼。
| 指標 | 本站實測 |
|---|---|
| 語料檔案數 | 440 |
| 節點 | 15,815 |
| 邊 | 61,988 |
| 社群 | 343(最大社群 602 節點 = C++ Hybrid LSP tests) |
| 互動圖 | 社群聚合檢視(343 社群節點 / 1,977 跨社群邊) |
| LLM / API 成本 | 0(純 AST,本機執行) |
| 工具版本 | graphify 0.9.36 |
graphify 報告指出連接最多邊的「樞紐節點」——正是 CBM 架構中最關鍵的函式:
| 函式 | 邊數 | 位置 |
|---|---|---|
find_resolved() | 679 | LSP 解析核心(各語系共用) |
extract_cpp() | 609 | C++ AST 抽取器 |
cbm_store_close() | 568 | SQLite 圖儲存關閉(全域生命週期) |
cbm_mkdtemp() | 522 | 平台相容的臨時目錄(跨模組共用) |
extract_rust() | 498 | Rust AST 抽取器 |
343 個社群,最大的幾個直接對應 CBM 的模組:
| 社群(graphify 命名) | 節點 | 對應 CBM 模組 |
|---|---|---|
| C++ Hybrid LSP tests | 602 | tests/test_c_lsp.c |
| Rust LSP resolution tests | 355 | tests/test_rust_lsp.c |
| Agent registry & profiles | 287 | src/cli/agent_profiles.c |
| MCP JSON-RPC server | 219 | src/mcp/mcp.c |
| Daemon IPC & sockets | 196 | src/daemon/ipc.c |
| Cypher query engine | 136 | src/cypher/cypher.c |
| File discovery & gitignore | 147 | src/discover/ |
完整 343 社群清單見 GRAPH_REPORT.md。
因為全圖 15,815 節點超過 graphify 的 5,000 節點視覺化上限,自動聚合為社群檢視——這反而是好事:一眼看到整個 CBM 的模組結構與跨模組呼叫。
# 0. 安裝 graphify(PyPI 套件名 graphifyy,雙 y)
uv tool install graphifyy
# 1. 準備語料(只保留第一方程式碼)
git clone https://github.com/DeusData/codebase-memory-mcp.git cbm
git -C cbm checkout 2c50c7741ec89dbcf43c2c85e005c0b58a4dbbf3
mkdir corpus && cp -R cbm/src corpus/ && cp -R cbm/tests corpus/
# 2. 跑完整 pipeline(code-only,零 API key)
graphify corpus --code-only
# 3. 產出在 graphify-out/
# graph.html 互動圖(社群聚合檢視)
# graph.json 全量圖資料(15,815 nodes / 61,988 edges)
# GRAPH_REPORT.md 審計報告
# 4. 中文化 UI(選擇性)
cp graphify-out/graph.html graphify-out/graph-zh.html
# 替換 lang="en" → lang="zh-Hant" 及 UI 字串(Search / Node Info / Communities…)
graph.json 或改掃 src/ 單一目錄(193 檔,較可能落在節點級檢視範圍)。cbm_store_close() 是所有模組的生命週期樞紐、以及 graphify 與 CBM 兩種知識圖譜工具的哲學差異。