一句话定位

两者都把代码库转成知识图谱、并集成进 AI Coding Agent(Claude Code / Cursor / Codex / Gemini CLI 等),但设计哲学截然不同:

  • CodeGraph = “给 Agent 用的确定性索引”——快、省、准、零 token 成本,让 AI 更高效地改代码。
  • Understand-Anything = “给人看的可教学图谱”——可视化、语义丰富、有业务视角,让人和 AI 一起理解代码。

关键认知:Graphs that work vs Graphs that teach

CodeGraph README 的哲学是 “fewer tokens, fewer tool calls, 100% local”——图谱是给 Agent 用的工具,核心是减少 grep/Read 调用、给外科手术式上下文。

Understand-Anything README 标语是 “Graphs that teach > graphs that impress”——图谱是给人看的,核心是"quietly teaches you how every piece fits together",目标是 onboarding、项目理解、可视化。


二、仓库元数据对比(2026-07-08)

维度CodeGraphUnderstand-Anything
仓库colbymchenry/codegraphEgonex-AI/Understand-Anything(原 Lum1104
Stars58.5k71.9k
Forks3.6k6k
最新版本v1.3.0(26 个 release)v2.7.3(7 个 release)
最近提交2026-07-07(13 小时前)2026-07-08(今天)
Contributors4748
主语言TypeScript 93% / JS 4.5% / Shell 1.8%TypeScript 71% / JS 16% / Python 9% / Astro 2.4%
许可证MITMIT
原作者colbymchenryYuxiang Lin (Lum1104),现归 Egonex

三、技术架构对比(本质差异)

这是两者最关键的区别所在。

CodeGraph —— 纯确定性、100% 本地、零 LLM

  • 提取方式:tree-sitter 解析 AST → 语言专属查询提取节点(函数/类/方法)和边(calls/imports/extends/implements)→ 存入本地 SQLite(.codegraph/codegraph.db)+ FTS5 全文搜索
  • 存储:SQLite 单文件,纯本地,无 API key,无外部服务
  • 同步:文件 watcher 用原生 OS 事件(FSEvents/inotify/ReadDirectoryChangesW),2 秒 debounce 增量同步,零配置自动保持新鲜
  • 跨语言桥接:手工实现的启发式规则——Swift↔ObjC @objc 桥接、React Native legacy bridge / TurboModules / Fabric、Expo Modules DSL,跨语言边打 provenance:'heuristic' 标记,Agent 能看出这条边怎么来的
  • 可复现:相同输入 → 相同输出,每次都一样

Understand-Anything —— Tree-sitter + LLM 混合

  • 提取方式:tree-sitter 做确定性结构提取(imports/exports/函数类定义/调用点/继承)+ LLM 做语义提取(自然语言摘要、标签、架构层归属、业务域映射、导览、语言概念)
  • 存储:JSON 文件(.understand-anything/knowledge-graph.json),可 commit 到仓库共享,大文件(10MB+)建议 git-lfs
  • 多 Agent Pipeline:6-7 个专门 Agent 协作
    • project-scanner 发现文件/语言/框架
    • file-analyzer 提取函数/类/导入(并行,5 并发,20-30 文件/批)
    • architecture-analyzer 识别架构层
    • tour-builder 生成学习导览
    • graph-reviewer 校验图完整性(默认内联,--review 走完整 LLM 审查)
    • domain-analyzer 提取业务域/流程/步骤
    • article-analyzer 分析 wiki 知识库
  • 同步:默认增量(只重分析改动文件);--auto-update 走 post-commit hook 在每次提交时打补丁
  • 可复现性:结构边可复现;语义部分依赖 LLM,不可完全复现

架构对比表

维度CodeGraphUnderstand-Anything
结构提取tree-sittertree-sitter
语义提取❌ 无✅ LLM
存储SQLite + FTS5JSON 文件
运行时依赖自包含二进制(bundled runtime,无需 Node)需 Node 22+ / pnpm 10+,需 LLM
同步机制文件 watcher 原生 OS 事件,实时增量默认增量重跑;--auto-update post-commit hook
可复现完全可复现结构可复现,语义不可
跨语言桥接手工启发式(Swift↔ObjC、RN bridge、Expo)依赖 tree-sitter 通用能力

四、给 Agent 的集成方式对比

维度CodeGraphUnderstand-Anything
集成形态MCP Server(CLI 自带运行时,无需 Node)Claude Code 插件 + slash commands
暴露给 Agent 的工具默认只暴露 1 个 codegraph_explore("一个强工具优于一堆窄工具"的设计哲学);其他 7 个(node/search/callers/callees/impact/files/status)默认隐藏,用 CODEGRAPH_MCP_TOOLS 环境变量启用slash commands:/understand/understand-dashboard/understand-chat/understand-diff/understand-explain/understand-onboard/understand-domain/understand-knowledge
Agent 能否直接调✅ 是,MCP 工具直接调,Agent 无需 prompt 触发❌ 否,依赖 slash command 显式触发或人对话引导
安装方式curl ... install.shnpx @colbymchenry/codegraphcodegraph install 自动配置各 Agent 的 MCP;codegraph init 建图Claude Code:/plugin marketplace add Egonex-AI/Understand-Anything + /plugin install understand-anything;其他平台 install.sh <platform>
支持的 AgentClaude Code / Cursor / Codex CLI / opencode / Hermes / Gemini CLI / Antigravity / Kiro(8 个)Claude Code / Cursor / VS Code Copilot / Copilot CLI / Codex / OpenCode / OpenClaw / Antigravity / Gemini CLI / Pi / Vibe / Hermes / Cline / KIMI / Trae / Nanobot / Kiro(17 个,更多)

五、功能能力对比

能力CodeGraphUnderstand-Anything
符号级精准上下文(入口点 + 相关符号 + 源码)✅ 强项,codegraph_explore 一次调用返回✅ 通过 /understand-chat 问答
调用路径追踪(含动态分派:回调、React re-render、接口→实现)✅ 强项,codegraph_trace 跨动态分派跳⚠️ 依赖 LLM 推理,非确定性
影响面分析(blast radius)codegraph_impact / affected(可接 git diff --name-only | codegraph affected --stdin/understand-diff
交互式可视化 Dashboard❌ 无(纯 Agent 工具)核心卖点:可缩放/搜索/点击的 web dashboard,按架构层着色,支持 persona 自适应(初级/PM/高级用户)
业务域映射(domains/flows/steps)❌ 无/understand-domain
新人 onboarding 导览❌ 无/understand-onboard 自动生成依赖顺序的学习导览
知识库/wiki 分析❌ 无/understand-knowledge 分析 Karpathy-pattern LLM wiki
语言概念讲解(泛型/闭包/装饰器等 12 种)❌ 无✅ 在上下文中讲解
多语言支持20+ 语言全覆盖(TS/JS/ArkTS/Python/Go/Rust/Java/C#/VB.NET/PHP/Ruby/C/C++/CUDA/ObjC/Metal/Swift/Kotlin/Scala/Dart/Lua/Luau/R/Nix/Erlang/CFML/COBOL/Solidity/Terraform/Svelte/Vue/Astro/Liquid/Pascal)⚠️ README 未明确列语言清单,依赖 tree-sitter 通用能力
框架路由识别✅ 17 个框架(Django/Flask/FastAPI/Express/NestJS/Laravel/Drupal/Rails/Spring/Play/Gin/chi/Axum/ASP.NET/Vapor/React Router/SvelteKit/Vue Router/Astro)❌ 未提及
全文搜索✅ FTS5✅ 模糊 + 语义搜索
团队共享图谱⚠️ 可共享 .codegraph/ 但通常不入库✅ 设计为 commit 到仓库共享,推荐 git-lfs
图谱可读性❌ 给机器读的 SQLite✅ JSON + web dashboard,给人读

六、成本与隐私对比

维度CodeGraphUnderstand-Anything
Token 消耗(纯本地 tree-sitter + SQLite,无 LLM 调用)(首次 /understand 全量分析消耗大量 token,README 明确建议跑在 token 订阅或本地模型上)
外部依赖无(自包含二进制,bundled runtime)需要 LLM(可用 Ollama 本地模型降本)
隐私✅ 100% 本地,无数据离开机器⚠️ 语义部分代码会发到 LLM(本地模型可规避)
遥测有匿名遥测(可 codegraph telemetry off 关闭)未明确提及
适合的代码库规模小到超大通用(benchmark 在 110 文件到 10k 文件都测过)官方明确"更适合大型代码库/Monorepo/企业项目",小项目 LLM 成本不划算

七、CodeGraph Benchmark 证据

CodeGraph README 给出了严格的 benchmark(7 个真实开源代码库,每 arm 4 次取中位数,2026-06-02 在 Opus 4.8 上重新验证):

代码库语言/规模工具调用速度文件读取Token成本
VS CodeTS · ~10k 文件-81%+11%0 vs 9-64%-18%
ExcalidrawTS · ~640-40%+27%0 vs 7-25%even
DjangoPython · ~3k-77%+13%0 vs 9-60%-8%
TokioRust · ~790-57%+18%0 vs 8-38%even
OkHttpJava · ~645-50%+31%0 vs 4-54%-25%
GinGo · ~110-44%+24%1 vs 6-23%-19%
AlamofireSwift · ~110-58%+33%0 vs 9-64%-40%

通用结论:每个代码库、每个规模都赢——工具调用减少 40-81%,速度提升 11-33%,文件读取降到接近 0。

Understand-Anything 未在 README 给出量化 benchmark,更侧重定性卖点(教学、onboarding、可视化)。


八、适用场景建议

选 CodeGraph 当你

  • 要让 AI Agent 在写代码/改代码时自动、频繁用图谱减少 grep/Read 调用
  • 在意确定性、可复现、零 token 成本
  • 项目跨多语言、多框架,需要框架路由识别
  • 团队不想维护 LLM 调用成本

选 Understand-Anything 当你

  • 要给人(新人/PM/非工程师)可视化探索代码库
  • 需要业务域映射、onboarding 导览、知识库分析这些"理解层"能力
  • 接受 LLM token 成本,或愿意配本地模型(Ollama)
  • 想把图谱 commit 到仓库做 docs-as-code、PR review 辅助
  • 团队有预算跑 token 订阅

两者并非互斥

  • CodeGraph 擅长日常 Agent 工作流的精准上下文
  • Understand-Anything 擅长项目理解 / onboarding / 可视化
  • 痛点是"Agent 老在 grep 浪费 token" → 用 CodeGraph
  • 痛点是"新人看不懂这个 20 万行项目" → 用 Understand-Anything

九、几个坑

  1. Understand-Anything 首次 /understand 烧 token:全量分析整个代码库,大项目消耗显著,README 自己都建议跑在订阅或本地模型上。后续增量才省钱。
  2. CodeGraph 的"一个工具"哲学:默认只暴露 codegraph_explore,想用 codegraph_callers/impact 等要手动开 CODEGRAPH_MCP_TOOLS 环境变量——有些 Agent 教程没提这个,会以为只有 explore。
  3. Understand-Anything 仓库重定向:原作者 Lum1104 已迁到 Egonex-AI 组织,老教程里的 clone 地址会自动重定向,但 issue/PR 要去新地址。
  4. CodeGraph 跨语言桥接是启发式:Swift↔ObjC、RN bridge 等边打 provenance:'heuristic' 标记,不是 100% 精确,Agent 能看到但不该盲信。
  5. Understand-Anything 语义部分不可复现:依赖 LLM,同一段代码两次分析可能出不同摘要——做 CI 校验时只信结构边,别拿语义摘要做断言。
  6. 两者都支持 Claude Code,但集成形态不同:CodeGraph 走 MCP server(Agent 自动调),Understand-Anything 走插件 slash command(人显式触发)——别混用安装方式。

十、官方链接清单

CodeGraph

  • 仓库:https://github.com/colbymchenry/codegraph
  • 官网:https://colbymchenry.github.io/codegraph/
  • 安装:curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
  • npm:npx @colbymchenry/codegraph

Understand-Anything

  • 仓库:https://github.com/Egonex-AI/Understand-Anything
  • Claude Code 安装:/plugin marketplace add Egonex-AI/Understand-Anything/plugin install understand-anything
  • 其他平台:curl -fsSL https://raw.githubusercontent.com/Egonex-AI/Understand-Anything/main/install.sh | bash -s <platform>
  • 支持平台:gemini / codex / opencode / pi / openclaw / antigravity / vibe / vscode / hermes / cline / kimi / trae / nanobot / kiro
Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐