Theme / v0.9.56

Graphify

Codebase 知識圖譜

實戰範例

實戰範例 003:PR 審查 + 團隊共享 graphify-out

圖譜化的 code review:把 graphify-out/ commit 進 repo;多人並行 PR 用 prs 排序;HTTP MCP server 共用

背景

中大型團隊面臨的兩個難題:

  1. review 心智負擔:每位 reviewer 都要自己重新理解 graph impact 才能判斷 PR 風險
  2. knowledge transfer 慢:新人 clone 後要重讀 README、自己探索

graphify 透過「commit graphify-out/ 進 repo」+「prs –triage 排序」+「HTTP MCP server 共用」三招解決。

⚠️ 與舊版(已刪除)差異:舊範例展示虛構的「企業 KB + Neo4j」。graphify 真實的多人協作是基於 graph.json + git workflow,跟 Neo4j 無關。


適用情境

  • 5+ 人團隊
  • 多 PR 平行開發
  • 新人 onboarding 流程需要加速
  • 想把 graphify 整合到 CI/CD pipeline

完整流程

步驟 1:團隊共識 + repo 設定

cd ~/team-monorepo

# 設定 baseline graph
uv tool install graphifyy
graphify extract . --mode deep

# 加 git hook(重點:merge driver 避免 graph.json conflict)
graphify hook install

# commit baseline
git add graphify-out/
git commit -m "chore(graphify): baseline graph v0.9.32"

# 把 cost.json 與 cache/ 排除
cat > .gitignore << 'EOF'
graphify-out/cost.json
graphify-out/cache/
EOF
git commit -am "chore: ignore graphify local cache"

💡 manifest.json 自 v0.9.18 起以 relative path 儲存,可安全 commit。1

步驟 2:每人 onboarding kit

新人入職只要:

git clone <repo>
cd <repo>
uv tool install graphifyy
graphify claude install --project --strict     # 或其他平台
graphify hook install                          # 加上自己的 hook

clone 後助理直接讀 graphify-out/GRAPH_REPORT.md,不用重新建圖。

步驟 3:daily review queue

週一到週五 reviewer 的例行:

# 看今天 review 優先度
graphify prs --triage

# 找有合併風險的配對
graphify prs --conflicts

# 看 worktree ↔ PR mapping
graphify prs --worktrees

reviewer 據此排定今天要看哪幾個 PR、merge 順序如何。

步驟 4:單一 PR 的 graph-impact 評估

收到 PR #58 想評估:

graphify prs 58

輸出會列出:

  • 修改的檔案 → 對應的 graph nodes
  • 觸動的 community
  • 觸動的 god node
  • 建議的 reviewer(domain owner)

reviewer 不需要自己讀全部 diff,graph-impact 在 graph 層級幫你 filter。

步驟 5:把圖譜開成 HTTP MCP server(團隊共用)

避免每人都重新建圖,把圖譜開成共用 HTTP MCP server:

# CI 或 shared dev box 上
python -m graphify.serve graphify-out/graph.json \
  --transport http \
  --host 0.0.0.0 \
  --api-key "$TEAM_GRAPHIFY_KEY"

每人的 IDE MCP 設定指向同一個 URL:

// .cursor/mcp.json or claude_desktop_config.json
{
  "graphify": {
    "url": "http://graphify.internal:8080/mcp",
    "headers": { "Authorization": "Bearer $TEAM_GRAPHIFY_KEY" }
  }
}

助理呼叫 MCP 工具(query_graphshortest_pathget_neighborslist_prsget_pr_impacttriage_prs),全部命中共享圖譜。

步驟 6:CI 整合 graph-impact gate

.github/workflows/pr-graph-impact.yml:

name: PR Graph Impact
on: pull_request
jobs:
  graph:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install graphify
        run: pipx install graphifyy
      - name: Show graph impact
        run: graphify prs ${{ github.event.pull_request.number }} > pr-graph-impact.md
      - uses: actions/upload-artifact@v4
        with:
          name: pr-graph-impact
          path: pr-graph-impact.md

每個 PR 自動 attach graph-impact 報告,reviewer 不需親自跑指令。


對比傳統 team workflow

任務 傳統 graphify
新人 onboarding 讀 README + 探索 1 週 clone 直接讀 GRAPH_REPORT.md,1 天
PR review 心智負擔 全部 diff 評估 graph impact 幫 filter 觸動的 god node
PR 衝突預警 等 git conflict 才發現 prs --conflicts 預先警報
多人共用圖譜 每人各自 grep HTTP MCP server 共享

真實輸出範例

$ graphify prs --triage
Triage ranking:
1. #58 (HIGH) billing refactor
   - 3 god nodes touched in Community 3
   - 12 modified files, CI failing
   - Suggested: pair with domain owner
2. #52 (MED) export endpoint
   - Community 3 (billing)
   - 3 files, CI passing
3. #41 (LOW) typo fix
   - 1 file, CI passing

$ graphify prs --conflicts
PR #52 ↔ #58  shared community: billing (Community 3)
→ merge order: #58 first (or rebase #52 after #58)

失敗處理

情境 排查
prs 在 CI 拿不到 gh token 在 GitHub Actions 設 GITHUB_TOKEN
HTTP MCP server 連不上 確認 --host 0.0.0.0、防火牆、API key
triage 沒排序 沒設 GRAPHIFY_TRIAGE_BACKEND,graphify auto-detect 失敗;手動設 kimi / claude / openai / gemini
graph.json 兩人 commit 衝突 沒裝 graphify hook installmerge=graphify driver,立即裝上

內部連結


下一步

  1. 探索陌生 codebase 範例
  2. 大型 monorepo 重購範例
  3. Graphify 是什麼

Footnotes

  1. v0.9.18 changelog: manifest portable 化。