Glean 拾遗
日刊 /2026-07-24 / 将任意代码库转化为可查询知识图谱,专为AI编码助手设计

将任意代码库转化为可查询知识图谱,专为AI编码助手设计

原文 github.com 收录 2026-07-24 06:01 阅读 59 min
AI 解读

Graphify 是一个开源工具,能够将代码、文档、PDF、图片等资源转化为结构化的知识图谱。它使用 tree-sitter 在本地进行确定性 AST 解析,无需 LLM 即可提取代码中的调用、继承、引用等关系;对于非代码文件,则通过 AI 助手进行语义提取。生成的图谱支持交互式可视化(graph.html)、CLI 查询(graphify query/path/explain),并可作为 MCP 服务器供团队共享。所有边均标记为“显式提取”或“推断”,明确区分原始代码中的直接关系与解析生成的间接关系。适合需要在大型代码库中快速定位概念、追溯依赖、理解架构的工程师。

原文 59 分钟
原文 github.com ↗
§ 1

Graphify turns any codebase—including code, docs, SQL schemas, PDFs, and images—into a queryable knowledge graph. Target users are developers using AI coding assistants (Claude Code, Cursor, Codex, Gemini CLI, etc.) who want instant answers about their project structure without reading files manually.

Graphify 可以将任何代码库(包括代码、文档、SQL 模式、PDF 和图片)转化为可查询的知识图谱。目标用户是使用 AI 编码助手(如 Claude Code、Cursor、Codex、Gemini CLI 等)的开发者,他们希望无需手动阅读文件即可即时了解项目结构。

§ 2

When working with large or unfamiliar codebases, understanding how components connect is time-consuming. Traditional tools like grep give raw text matches but no structural relationships, and LLMs alone often lack context about your specific project. Graphify solves this by building a persistent graph of concepts and their connections, allowing you to query rather than grep.

在处理大型或不熟悉的代码库时,理解组件之间的关联非常耗时。传统的 grep 只能给出文本匹配,无法展示结构关系,而单独的 LLM 往往缺乏对你项目的特定上下文。Graphify 通过构建概念及其连接关系的持久图来解决这个问题,让你用查询替代 grep。

§ 3

Graphify uses tree-sitter AST to parse code in ~40 languages entirely locally—no LLM calls, no data leaves your machine. Every edge in the graph carries a confidence tag: EXTRACTED (explicitly found in source) or INFERRED (resolved by graphify). This makes it distinct from vector-search approaches: no embeddings, no vector store, just a real graph you traverse.

Graphify 使用 tree-sitter AST 完全在本地解析近 40 种语言的代码——无需调用 LLM,数据不会离开你的机器。图中的每条边都带有置信度标签:EXTRACTED(从源码中明确找到)或 INFERRED(由 graphify 推断得出)。这使其区别于向量搜索方案:不使用嵌入或向量存储,只需遍历真实图。

§ 4

Running /graphify . in your AI assistant produces three files under graphify-out/: graph.html (interactive force-directed graph), GRAPH_REPORT.md (key concepts, surprising connections, suggested questions), and graph.json (full graph for programmatic query). The system supports incremental updates (--update), clustering (--cluster-only), and exports to Neo4j, FalkorDB, Obsidian, and more.

在 AI 助手中执行 /graphify . 会在 graphify-out/ 下生成三个文件:graph.html(交互式力导向图)、GRAPH_REPORT.md(关键概念、意外连接、建议问题)和 graph.json(完整图,可用于程序化查询)。该工具支持增量更新(--update)、仅重新聚类(--cluster-only),并可导出到 Neo4j、FalkorDB、Obsidian 等。

§ 5

Install via uv tool install graphifyy (or pipx/pip), then run graphify install to register the skill with your IDE. After that, open your AI assistant and type /graphify .. No API key is needed for code-only extraction—the code is parsed locally. For docs/PDFs/images, the assistant's model API is used; you can also run headless graphify extract with your own backend key.

通过 uv tool install graphifyy(或 pipx/pip)安装,然后运行 graphify install 注册技能到你的 IDE。之后,打开你的 AI 助手并输入 /graphify .。仅代码提取无需 API 密钥——代码在本地解析。对于文档/PDF/图片,会使用助手的模型 API;你也可以使用自己的后端密钥运行无头模式 graphify extract

§ 6

Graphify excels at codebase comprehension, architecture exploration, dependency tracing, and onboarding. It's ideal for monorepos, multi-service projects, and any context where knowing 'how X connects to Y' is crucial. However, it is not a vector search engine for natural-language similarity; it returns graph traversals, not ranked document lists. The HTML visualization can become unwieldy above ~5000 nodes (use --no-viz). Mature tool, but still under active development.

Graphify 在代码库理解、架构探索、依赖追踪和项目上手方面表现出色。非常适合单体仓库、多服务项目以及任何需要了解“X 如何连接到 Y”的场景。但它不是基于自然语言相似度的向量搜索引擎;返回的是图遍历结果,而非排序的文档列表。当节点超过约 5000 时,HTML 可视化可能变得不实用(可使用 --no-viz)。该项目已成熟但仍在积极开发中。

打开原文 ↗