案例:codegraph 源碼

用知識圖譜工具分析知識圖譜工具——graphify 互動圖 + codegraph 自跑
上游對齊 c6aaa20 · graphify 0.9.36 · @colbymchenry/codegraph v1.5.0 · 分析日期 2026-08-10

案例亮點

本站數字

工具語料節點社群 / 種類
graphify 0.9.36--code-only501 個程式檔(src/ + kernel-src/ + tests/)7,98718,148683 社群(介面顯示 208 個,475 個細碎省略)
codegraph v1.5.0codegraph init570 檔(全 repo)12,73344,903function 2,706 · import 2,304 · method 1,850 · class 206 · route 16 …

兩者不可直接比——graphify 用 Leiden 分群、codegraph 用自家 resolver;但同語料下的結構對照很有參考價值(graphify 有 683 個社群 hub,codegraph 索引時間僅 1.7s)。

互動知識圖譜(graphify 產出)

codegraph 源碼 · 互動知識圖譜(中文界面) 新開視窗English

超過 graphify 5,000 節點視覺化上限,自動聚合為社群檢視(683 個社群);想看單節點細節可用 graph.json。報告見 GRAPH_REPORT.md

codegraph 自跑(dogfooding)

init — 570 檔全量索引 1.7s

codegraph init(v1.5.0)
$ codegraph init
┌  Initializing CodeGraph
◆  Initialized in <repo-root>
Scanning files...
Parsing code...
Resolving refs...
Linking dynamic dispatch...
◆  Indexed 570 files
●  12,733 nodes, 44,903 edges in 1.7s
└  Done

explore — 結構性問題一次回答

codegraph explore 實測(節錄)
$ codegraph explore "how does codegraph_explore build its answer"
**Exploration: how does codegraph_explore build its answer**
Found 35 symbols across 2 files.

**Blast radius — what depends on these ...**
- `CodeGraph` (src/index.ts:139) — 136 callers in ... +96

**Relationships**
instantiates:
- init → CodeGraph · initSync → CodeGraph
- open → CodeGraph · recreate → CodeGraph · openSync → CodeGraph
calls:
- constructor → wireLayers · sync → sync · watch → sync
- open → sync · init → indexAll · ... and 3 more

更多真實輸出(status / query / callers / impact / files / sync)見 worked/codegraph-source/dogfood.md,也都散落在各教學頁。

重現步驟

# 0. 準備:graphify 0.9.36(PyPI 套件名 graphifyy,雙 y)、Node ≥20
uv tool install graphifyy
npm i -g @colbymchenry/codegraph@1.5.0

# 1. 語料(codegraph 源碼,對齊 c6aaa20)
git clone https://github.com/colbymchenry/codegraph.git
git -C codegraph checkout c6aaa20
mkdir corpus && cp -R codegraph/src corpus/ && cp -R codegraph/codegraph-kernel/src corpus/kernel-src/
cp -R codegraph/__tests__ corpus/tests/

# 2. graphify 掃描(code-only,零 key)
graphify extract ./corpus --code-only
GRAPHIFY_VIZ_NODE_LIMIT=20000 graphify cluster-only ./corpus
#   → corpus/graphify-out/:graph.html(互動)、graph.json、GRAPH_REPORT.md
# 3. 中文化互動圖:複製 graph.html → 替換 UI 字串 → graph-zh.html

# 4. codegraph 自跑(dogfooding)
cd codegraph
codegraph init         # 570 檔 → 12,733 節點 / 44,903 邊 in 1.7s
codegraph status
codegraph explore "how does codegraph_explore build its answer"

已知限制

看完這頁你應該能說出:這個案例兩條產出線各自的工具與數字、社群聚合檢視的原因、以及如何照步驟重現並做出自己的「分析 X 用 X」案例。