docs: make Chinese README the default
CI / skillgen-check (push) Waiting to run
CI / test (3.10) (push) Waiting to run
CI / test (3.12) (push) Waiting to run
CI / security-scan (push) Waiting to run

This commit is contained in:
wehub-resource-sync
2026-07-13 09:55:17 +00:00
parent 54baa1cf0b
commit f067c55691
+247 -246
View File
@@ -1,3 +1,9 @@
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/Graphify-Labs/graphify) · [上游 README](https://github.com/Graphify-Labs/graphify/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<p align="center">
<a href="https://graphify.com"><img src="https://raw.githubusercontent.com/Graphify-Labs/graphify/v8/docs/logo.png" width="300" height="140" alt="Graphify"/></a>
</p>
@@ -7,7 +13,7 @@
</p>
<div align="center">
<details><summary><b>Read this in other languages</b></summary>
<details><summary><b>其他语言版本</b></summary>
🇺🇸 <a href="README.md">English</a> | 🇨🇳 <a href="docs/translations/README.zh-CN.md">简体中文</a> | 🇯🇵 <a href="docs/translations/README.ja-JP.md">日本語</a> | 🇰🇷 <a href="docs/translations/README.ko-KR.md">한국어</a> | 🇩🇪 <a href="docs/translations/README.de-DE.md">Deutsch</a> | 🇫🇷 <a href="docs/translations/README.fr-FR.md">Français</a> | 🇪🇸 <a href="docs/translations/README.es-ES.md">Español</a> | 🇮🇳 <a href="docs/translations/README.hi-IN.md">हिन्दी</a> | 🇧🇷 <a href="docs/translations/README.pt-BR.md">Português</a> | 🇷🇺 <a href="docs/translations/README.ru-RU.md">Русский</a> | 🇸🇦 <a href="docs/translations/README.ar-SA.md">العربية</a> | 🇮🇷 <a href="docs/translations/README.fa-IR.md">فارسی</a> | 🇮🇹 <a href="docs/translations/README.it-IT.md">Italiano</a> | 🇵🇱 <a href="docs/translations/README.pl-PL.md">Polski</a> | 🇳🇱 <a href="docs/translations/README.nl-NL.md">Nederlands</a> | 🇹🇷 <a href="docs/translations/README.tr-TR.md">Türkçe</a> | 🇺🇦 <a href="docs/translations/README.uk-UA.md">Українська</a> | 🇻🇳 <a href="docs/translations/README.vi-VN.md">Tiếng Việt</a> | 🇮🇩 <a href="docs/translations/README.id-ID.md">Bahasa Indonesia</a> | 🇸🇪 <a href="docs/translations/README.sv-SE.md">Svenska</a> | 🇬🇷 <a href="docs/translations/README.el-GR.md">Ελληνικά</a> | 🇷🇴 <a href="docs/translations/README.ro-RO.md">Română</a> | 🇨🇿 <a href="docs/translations/README.cs-CZ.md">Čeština</a> | 🇫🇮 <a href="docs/translations/README.fi-FI.md">Suomi</a> | 🇩🇰 <a href="docs/translations/README.da-DK.md">Dansk</a> | 🇳🇴 <a href="docs/translations/README.no-NO.md">Norsk</a> | 🇭🇺 <a href="docs/translations/README.hu-HU.md">Magyar</a> | 🇹🇭 <a href="docs/translations/README.th-TH.md">ภาษาไทย</a> | 🇺🇿 <a href="docs/translations/README.uz-UZ.md">Oʻzbekcha</a> | 🇹🇼 <a href="docs/translations/README.zh-TW.md">繁體中文</a> | 🇵🇭 <a href="docs/translations/README.fil-PH.md">Filipino</a> | 🇮🇱 <a href="docs/translations/README.he-IL.md">עברית</a>
@@ -22,33 +28,33 @@
<img src="https://img.shields.io/badge/Y%20Combinator-S26-F0652F?style=flat&logo=ycombinator&logoColor=white" alt="YC S26"/>
</p>
Type `/graphify` in your AI coding assistant and it maps your entire project (code, docs, PDFs, images, videos) into a **knowledge graph** you can **query instead of grepping** through files.
在 AI 编程助手中输入 `/graphify`,即可将整个项目(代码、文档、PDF、图片、视频)映射为可**查询**的**知识图谱(knowledge graph**,无需再在文件中 **grep** 搜索。
- **Code maps for free, fully local.** Code is parsed with tree-sitter AST: deterministic, no LLM, nothing leaves your machine. (Docs, PDFs, images and video use your assistant's model, or a configured API key, for a semantic pass.)
- **Every edge is explained.** Each connection is tagged `EXTRACTED` (explicit in the source) or `INFERRED` (resolved by graphify), so you can tell what was read directly from what was inferred.
- **Not a vector index.** No embeddings, no vector store: a real graph you traverse. Ask a question, trace the path between two things, or explain one concept.
- **代码映射免费且完全本地运行。** 代码通过 tree-sitter AST 解析:确定性、无需 LLM、数据不离开你的机器。(文档、PDF、图片和视频会使用助手的模型或已配置的 API 密钥进行语义分析。)
- **每条边都有说明。** 每个连接都会标注 `EXTRACTED`(源码中显式声明)或 `INFERRED`(由 graphify 解析得出),因此你可以区分哪些是直接读取的、哪些是推断得出的。
- **不是向量索引。** 不使用嵌入(embeddings)、也不使用向量存储:这是一个可遍历的真实图。你可以提问、追踪两个事物之间的路径,或解释某个概念。
<p align="center">
<img src="https://raw.githubusercontent.com/Graphify-Labs/graphify/v8/docs/graph-hero.png" alt="graphify's interactive graph.html showing the FastAPI codebase as a force-directed knowledge graph with a legend of detected communities" width="900">
</p>
<p align="center">
<em>The FastAPI codebase mapped by graphify. Every node is a concept, colors are detected communities, and the whole thing is clickable in graph.html.</em>
<em>由 graphify 映射的 FastAPI 代码库。每个节点代表一个概念,颜色表示检测到的社区,整个图谱可在 graph.html 中点击交互。</em>
</p>
**Get started** (30 seconds):
**快速开始**30 秒):
```bash
uv tool install graphifyy # install the CLI (or: pipx install graphifyy)
graphify install # register the skill with your AI assistant
```
Then, in your AI assistant:
然后,在你的 AI 助手中:
```
/graphify .
```
That's it. You get **three files**:
就这么简单。你会得到 **三个文件**
```
graphify-out/
@@ -57,17 +63,17 @@ graphify-out/
└── graph.json the full graph — query it anytime without re-reading your files
```
**Works in** Claude Code, Cursor, Codex, Gemini CLI, GitHub Copilot, and 15+ more — [pick your platform](#install).
**适用于** Claude CodeCursorCodexGemini CLIGitHub Copilot 15+ 平台 — [选择你的平台](#install)
---
## See it in action
## 实际效果
<p align="center">
<img src="https://raw.githubusercontent.com/Graphify-Labs/graphify/v8/docs/demo-path.svg" alt="graphify path query: a terminal asks for the shortest path between FastAPI and ModelField, and the answer lights up hop by hop across the knowledge graph" width="900">
</p>
Once the graph is built you query it instead of reading files. Real output, graphify run on the FastAPI codebase shown above:
图谱构建完成后,你可以直接查询它,而无需逐个阅读文件。以下为真实输出,展示在上述 FastAPI 代码库上运行的 graphify
```text
$ graphify explain "APIRouter"
@@ -88,58 +94,58 @@ Shortest path (3 hops):
FastAPI --uses--> DefaultPlaceholder <--references-- get_request_handler() --references--> ModelField
```
Every edge carries a **confidence tag** (`EXTRACTED` = explicit in the source, `INFERRED` = derived by resolution), so you can tell what was read directly from what was inferred. `graphify query "<question>"` returns a scoped subgraph for a plain-language question, and `graphify path A B` traces how any two things connect.
每条边都带有**置信度标签**`EXTRACTED` = 源码中显式声明,`INFERRED` = 通过解析推导得出),因此你可以区分哪些是直接读取的、哪些是推断得出的。`graphify query "<question>"` 会针对自然语言问题返回限定范围的子图,`graphify path A B` 可追踪任意两个事物之间的连接方式。
---
## What it does
## 功能概览
What you get out of the box:
开箱即用,你将获得:
| Capability | What you get |
| 能力 | 你将获得 |
|---|---|
| **God nodes** | The most-connected concepts, so you see what everything flows through |
| **Communities** | The graph split into subsystems (Leiden), with LLM-free labels |
| **Cross-file links** | `calls` / `imports` / `inherits` / `mixes_in` resolved across ~40 languages via tree-sitter AST |
| **Query, path, explain** | Ask a question, trace the path between two things, or explain one concept, all against `graph.json` |
| **Rationale + doc refs** | `# NOTE:` / `# WHY:` comments and ADR/RFC citations become first-class nodes linked to the code |
| **Beyond code** | Docs, PDFs, images, and video/audio all map into the same graph |
| **Local-first** | Code is parsed locally with tree-sitter (no LLM, nothing leaves your machine); only the semantic pass over docs/media calls a backend, and only if you configure one |
| **God nodes** | 连接最多的概念,便于看清一切流经何处 |
| **Communities** | 图谱按子系统划分(Leiden),并附带无需 LLM 的标签 |
| **跨文件链接** | 通过 tree-sitter AST 在约 40 种语言中解析 `calls` / `imports` / `inherits` / `mixes_in` |
| **查询、路径、解释** | 提问、追踪两个事物之间的路径,或解释某个概念,全部基于 `graph.json` |
| **理由说明 + 文档引用** | `# NOTE:` / `# WHY:` 注释以及 ADR/RFC 引用会成为与代码关联的一等节点 |
| **超越代码** | 文档、PDF、图片以及音视频都会映射到同一张图谱中 |
| **本地优先** | 代码在本地通过 tree-sitter 解析(无需 LLM,数据不离开你的机器);仅对文档/媒体的语义分析会调用后端,且仅在你完成配置时才会调用 |
---
## Benchmarks
## 基准测试
| Benchmark | Metric | graphify | Field |
| 基准测试 | 指标 | graphify | 对比 |
|---|---|---|---|
| LOCOMO (n=300) | recall@10 | **0.497** | mem0 0.048, supermemory 0.149 |
| LOCOMO (n=300) | QA accuracy | 45.3% | supermemory 49.7%, mem0 27.3% |
| LongMemEval-S (n=50) | QA accuracy | **76%** | tied with dense RAG |
| Graph build | LLM credits | **0** | per-token for most systems |
| LOCOMO (n=300) | recall@10 | **0.497** | mem0 0.048supermemory 0.149 |
| LOCOMO (n=300) | QA 准确率 | 45.3% | supermemory 49.7%mem0 27.3% |
| LongMemEval-S (n=50) | QA 准确率 | **76%** | dense RAG 持平 |
| 图谱构建 | LLM 额度 | **0** | 大多数系统按 token 计费 |
Every system ran on the same harness with the same model and budgets, scored by a judge blind-validated against a second judge (90.6% agreement, Cohen's kappa 0.81). Full per-system tables, the code-intelligence result, and reproduction commands: **[BENCHMARKS.md](./BENCHMARKS.md)**.
所有系统均在同一测试框架、同一模型和预算下运行,并由评审员打分,评审结果经第二位评审员盲测验证(一致率 90.6%Cohen's kappa 0.81)。完整的各系统对比表、代码智能(code-intelligence)结果及复现命令:**[BENCHMARKS.md](./BENCHMARKS.md)**
---
## Prerequisites
## 前置要求
| Requirement | Minimum | Check | Install |
| 要求 | 最低版本 | 检查 | 安装 |
|---|---|---|---|
| Python | 3.10+ | `python --version` | [python.org](https://www.python.org/downloads/) |
| uv *(recommended)* | any | `uv --version` | `curl -LsSf https://astral.sh/uv/install.sh \| sh` |
| pipx *(alternative)* | any | `pipx --version` | `pip install pipx` |
| uv *(推荐)* | any | `uv --version` | `curl -LsSf https://astral.sh/uv/install.sh \| sh` |
| pipx *(备选)* | any | `pipx --version` | `pip install pipx` |
**macOS quick install (Homebrew):**
**macOS 快速安装(Homebrew):**
```bash
brew install python@3.12 uv
```
**Windows quick install:**
**Windows 快速安装:**
```powershell
winget install astral-sh.uv
```
**Ubuntu/Debian:**
**Ubuntu/Debian**
```bash
sudo apt install python3.12 python3-pip pipx
# or install uv:
@@ -148,11 +154,11 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
---
## Install
## 安装
> **Official package:** The PyPI package is `graphifyy` (double-y). Other `graphify*` packages on PyPI are not affiliated. The CLI command is still `graphify`.
> **官方包:** PyPI 上的官方包为 `graphifyy`(双 y)。PyPI 上其他 `graphify*` 包与此无关。CLI 命令仍为 `graphify`
**Step 1 — install the package:**
**步骤 1 — 安装软件包:**
```bash
# Recommended (isolated env; if 'graphify' isn't found after, run: uv tool update-shell):
@@ -163,46 +169,40 @@ pipx install graphifyy
pip install graphifyy # may need PATH setup — see note below
```
**Step 2 — register the skill with your AI assistant:**
**步骤 2 — 向你的 AI 助手注册该 skill**
```bash
graphify install
```
That's it. Open your AI assistant and type `/graphify .`
就这么简单。打开 AI 助手并输入 `/graphify .`
To install the assistant skill into the current repository instead of your user
profile, add `--project`:
若要将 assistant skill 安装到当前仓库而非用户配置目录,请添加 `--project`
```bash
graphify install --project
graphify install --project --platform codex
```
Project-scoped installs write under the current directory, for example
`.claude/skills/graphify/SKILL.md` or `.agents/skills/graphify/SKILL.md` (plus a
`references/` sidecar the skill loads on demand), and
print a `git add` hint for files that can be committed.
Per-platform commands that support project-scoped installs accept the same flag,
for example `graphify claude install --project` or `graphify codex install --project`.
项目级安装会写入当前目录,例如 `.claude/skills/graphify/SKILL.md``.agents/skills/graphify/SKILL.md`(另有一个 `references/` 旁载文件供 skill 按需加载),并会打印 `git add` 提示,说明哪些文件可以提交。支持项目级安装的各平台命令接受相同标志,例如 `graphify claude install --project``graphify codex install --project`
> **PowerShell note:** Use `graphify .` not `/graphify .` — the leading slash is a path separator in PowerShell.
> **PowerShell 说明:** 请使用 `graphify .`,不要使用 `/graphify .` —— 前导斜杠在 PowerShell 中是路径分隔符。
> **`graphify: command not found`?** `uv tool install` / `pipx install` put the `graphify` command in their tool bin dir (`~/.local/bin`). If your shell can't find it right after install — common on a fresh macOS + zsh setup — that dir isn't on your `PATH` yet: run `uv tool update-shell` (or `pipx ensurepath`), then open a new terminal. With plain `pip`, add `~/.local/bin` (Linux) or `~/Library/Python/3.x/bin` (Mac) to your PATH, or run `python -m graphify`.
> **`graphify: command not found`** `uv tool install` / `pipx install` 会将 `graphify` 命令放入其工具 bin 目录(`~/.local/bin`)。若安装后 shell 找不到该命令 —— 在全新的 macOS + zsh 环境中很常见 —— 说明该目录尚未加入 `PATH`:运行 `uv tool update-shell`(或 `pipx ensurepath`),然后打开新终端。若使用普通 `pip`,请将 `~/.local/bin`Linux)或 `~/Library/Python/3.x/bin`Mac)加入 PATH,或运行 `python -m graphify`
> **Running with `uvx` / `uv tool run` instead of installing?** Name the package, not the command: `uvx --from graphifyy graphify install`. Plain `uvx graphify …` fails (`No solution found … no versions of graphify`) because `uv tool run` reads the first word as a *package*, and the package is `graphifyy` — the `graphify` command lives inside it.
> **使用 `uvx` / `uv tool run` 运行而不安装?** 应写包名,而非命令名:`uvx --from graphifyy graphify install`。直接使用 `uvx graphify …` 会失败(`No solution found … no versions of graphify`),因为 `uv tool run` 将第一个单词视为*包名*,而包名是 `graphifyy` — `graphify` 命令位于该包内部。
> **Avoid `pip install` on Mac/Windows** if possible. The skill resolves Python at runtime from `graphify-out/.graphify_python`; if that points to a different environment than where `pip` installed the package, you'll get `ModuleNotFoundError: No module named 'graphify'`. `uv tool install` and `pipx install` isolate the package in their own env and avoid this entirely.
> **尽量在 Mac/Windows 上避免使用 `pip install`。** skill 会在运行时从 `graphify-out/.graphify_python` 解析 Python;若该路径指向的环境与 `pip` 安装包的环境不同,就会出现 `ModuleNotFoundError: No module named 'graphify'``uv tool install` `pipx install` 会将包隔离在各自环境中,可完全避免此问题。
> **Git hooks and uv tool / pipx:** `graphify hook install` embeds the current interpreter path directly into the hook scripts at install time, so the post-commit hook fires correctly even in GUI git clients and CI runners where `~/.local/bin` is not on PATH. If you reinstall or upgrade graphify, re-run `graphify hook install` to refresh the embedded path.
> **Git hooks uv tool / pipx** `graphify hook install` 会在安装时把当前解释器路径直接嵌入 hook 脚本,因此即使在使用 GUI git 客户端和 CI runner `~/.local/bin` 不在 PATH 上的情况下,post-commit hook 也能正确触发。若你重新安装或升级 graphify,请重新运行 `graphify hook install` 以刷新嵌入路径。
<details>
<summary><b>Pick your platform</b> (20+ assistants, click to expand)</summary>
<summary><b>选择你的平台</b>20+ 款助手,点击展开)</summary>
| Platform | Install command |
| 平台 | 安装命令 |
|----------|----------------|
| Claude Code (Linux/Mac) | `graphify install` |
| Claude Code (Windows) | `graphify install` (auto-detected) or `graphify install --platform windows` |
| Claude Code (Windows) | `graphify install`(自动检测)或 `graphify install --platform windows` |
| CodeBuddy | `graphify install --platform codebuddy` |
| Codex | `graphify install --platform codex` |
| OpenCode | `graphify install --platform opencode` |
@@ -218,58 +218,58 @@ for example `graphify claude install --project` or `graphify codex install --pro
| Hermes | `graphify install --platform hermes` |
| Kimi Code | `graphify install --platform kimi` |
| Amp | `graphify amp install` |
| Agent Skills (cross-framework) | `graphify install --platform agents` (alias `--platform skills`) |
| Agent Skills (cross-framework) | `graphify install --platform agents`(别名 `--platform skills` |
| Kiro IDE/CLI | `graphify kiro install` |
| Pi coding agent | `graphify install --platform pi` |
| Cursor | `graphify cursor install` |
| Devin CLI | `graphify devin install` |
| Google Antigravity | `graphify antigravity install` |
Codex users also need `multi_agent = true` under `[features]` in `~/.codex/config.toml` for parallel extraction. CodeBuddy uses the same Agent tool and PreToolUse hook mechanism as Claude Code. Factory Droid uses the `Task` tool for parallel subagent dispatch. OpenClaw and Aider use sequential extraction (parallel agent support is still early on those platforms). Trae uses the Agent tool for parallel subagent dispatch and does **not** support `PreToolUse` hooks, so AGENTS.md is the always-on mechanism.
Codex 用户还需要在 `~/.codex/config.toml``[features]` 下配置 `multi_agent = true` 以支持并行提取。CodeBuddy 使用与 Claude Code 相同的 Agent 工具和 PreToolUse hook 机制。Factory Droid 使用 `Task` 工具进行并行子代理调度。OpenClaw Aider 使用顺序提取(这些平台上的并行 agent 支持仍处于早期阶段)。Trae 使用 Agent 工具进行并行子代理调度,且**不**支持 `PreToolUse` hooks,因此 AGENTS.md 是始终生效的机制。
`--platform agents` (alias `--platform skills`) targets the generic cross-framework [Agent-Skills](https://github.com/anthropics/skills) locations: the spec's user-global `~/.agents/skills/` (read by `npx skills` and spec-compliant frameworks) for a global install, and `./.agents/skills/` for a project (`--project`) install. The bare `graphify install` stays single-platform (Claude Code) by design — use the named `agents` platform when you want the skill discoverable by any framework that reads `.agents/skills`.
`--platform agents`(别名 `--platform skills`)面向通用跨框架 [Agent-Skills](https://github.com/anthropics/skills) 位置:全局安装使用规范的用户全局 `~/.agents/skills/`(由 `npx skills` 及符合规范的框架读取),项目(`--project`)安装使用 `./.agents/skills/`。裸 `graphify install` 命令按设计保持单平台(Claude Code)—— 若希望 skill 可被任何读取 `.agents/skills` 的框架发现,请使用具名的 `agents` 平台。
> Codex uses `$graphify` instead of `/graphify`.
> Codex 使用 `$graphify`,而非 `/graphify`
</details>
<details>
<summary><b>Optional extras</b> (install only what you need)</summary>
<summary><b>可选扩展</b>(按需安装)</summary>
| Extra | What it adds | Install |
| 扩展 | 功能 | 安装 |
|---|---|---|
| `pdf` | PDF extraction | `uv tool install "graphifyy[pdf]"` |
| `office` | `.docx` and `.xlsx` support | `uv tool install "graphifyy[office]"` |
| `google` | Google Sheets rendering | `uv tool install "graphifyy[google]"` |
| `video` | Video/audio transcription (faster-whisper + yt-dlp) | `uv tool install "graphifyy[video]"` |
| `pdf` | PDF 提取 | `uv tool install "graphifyy[pdf]"` |
| `office` | `.docx` `.xlsx` 支持 | `uv tool install "graphifyy[office]"` |
| `google` | Google Sheets 渲染 | `uv tool install "graphifyy[google]"` |
| `video` | 视频/音频转写(faster-whisper + yt-dlp | `uv tool install "graphifyy[video]"` |
| `mcp` | MCP stdio server | `uv tool install "graphifyy[mcp]"` |
| `neo4j` | Neo4j push support | `uv tool install "graphifyy[neo4j]"` |
| `falkordb` | FalkorDB push support | `uv tool install "graphifyy[falkordb]"` |
| `svg` | SVG graph export | `uv tool install "graphifyy[svg]"` |
| `leiden` | Leiden community detection (Python < 3.13 only) | `uv tool install "graphifyy[leiden]"` |
| `ollama` | Ollama local inference | `uv tool install "graphifyy[ollama]"` |
| `openai` | OpenAI / OpenAI-compatible APIs | `uv tool install "graphifyy[openai]"` |
| `neo4j` | Neo4j push 支持 | `uv tool install "graphifyy[neo4j]"` |
| `falkordb` | FalkorDB push 支持 | `uv tool install "graphifyy[falkordb]"` |
| `svg` | SVG 图导出 | `uv tool install "graphifyy[svg]"` |
| `leiden` | Leiden 社区检测(仅 Python < 3.13 | `uv tool install "graphifyy[leiden]"` |
| `ollama` | Ollama 本地推理 | `uv tool install "graphifyy[ollama]"` |
| `openai` | OpenAI / OpenAI 兼容 API | `uv tool install "graphifyy[openai]"` |
| `gemini` | Google Gemini API | `uv tool install "graphifyy[gemini]"` |
| `anthropic` | Anthropic Claude API (`--backend claude`, uses `ANTHROPIC_API_KEY`) | `uv tool install "graphifyy[anthropic]"` |
| `bedrock` | AWS Bedrock (uses IAM, no API key) | `uv tool install "graphifyy[bedrock]"` |
| `azure` | Azure OpenAI Service (`--backend azure`, uses `AZURE_OPENAI_API_KEY` + `AZURE_OPENAI_ENDPOINT`) | `uv tool install "graphifyy[openai]"` |
| `sql` | SQL schema extraction | `uv tool install "graphifyy[sql]"` |
| `postgres` | Live PostgreSQL introspection (`--postgres DSN`) | `uv tool install "graphifyy[postgres]"` |
| `dm` | BYOND DreamMaker `.dm`/`.dme` AST extraction (may need a C compiler + `python3-dev` if no wheel matches your platform) | `uv tool install "graphifyy[dm]"` |
| `terraform` | Terraform / HCL `.tf`/`.tfvars`/`.hcl` AST extraction | `uv tool install "graphifyy[terraform]"` |
| `pascal` | Pascal / Delphi `.pas`/`.dpr`/`.dpk`/`.inc` AST extraction (more accurate `calls`/`inherits` edges; falls back to a regex extractor when absent) | `uv tool install "graphifyy[pascal]"` |
| `chinese` | Chinese query segmentation (jieba) | `uv tool install "graphifyy[chinese]"` |
| `all` | Everything above | `uv tool install "graphifyy[all]"` |
| `anthropic` | Anthropic Claude API`--backend claude`,使用 `ANTHROPIC_API_KEY` | `uv tool install "graphifyy[anthropic]"` |
| `bedrock` | AWS Bedrock(使用 IAM,无需 API key | `uv tool install "graphifyy[bedrock]"` |
| `azure` | Azure OpenAI Service`--backend azure`,使用 `AZURE_OPENAI_API_KEY` + `AZURE_OPENAI_ENDPOINT` | `uv tool install "graphifyy[openai]"` |
| `sql` | SQL schema 提取 | `uv tool install "graphifyy[sql]"` |
| `postgres` | 实时 PostgreSQL 内省(`--postgres DSN` | `uv tool install "graphifyy[postgres]"` |
| `dm` | BYOND DreamMaker `.dm`/`.dme` AST 提取(若当前平台没有匹配的 wheel,可能需要 C 编译器 + `python3-dev` | `uv tool install "graphifyy[dm]"` |
| `terraform` | Terraform / HCL `.tf`/`.tfvars`/`.hcl` AST 提取 | `uv tool install "graphifyy[terraform]"` |
| `pascal` | Pascal / Delphi `.pas`/`.dpr`/`.dpk`/`.inc` AST 提取(更精确的 `calls`/`inherits` 边;缺失时回退到 regex 提取器) | `uv tool install "graphifyy[pascal]"` |
| `chinese` | 中文查询分词(jieba | `uv tool install "graphifyy[chinese]"` |
| `all` | 以上全部 | `uv tool install "graphifyy[all]"` |
</details>
---
## Make your assistant always use the graph
## 让你的助手始终使用图谱
Run this once in your project after building a graph:
在构建图谱后,在项目中运行一次:
| Platform | Command |
| 平台 | 命令 |
|----------|---------|
| Claude Code | `graphify claude install` |
| CodeBuddy | `graphify codebuddy install` |
@@ -288,64 +288,64 @@ Run this once in your project after building a graph:
| Hermes | `graphify hermes install` |
| Kimi Code | `graphify install --platform kimi` |
| Amp | `graphify amp install` |
| Agent Skills (cross-framework) | `graphify agents install` (alias `graphify skills install`) |
| Agent Skills(跨框架) | `graphify agents install` (alias `graphify skills install`) |
| Kiro IDE/CLI | `graphify kiro install` |
| Pi coding agent | `graphify pi install` |
| Devin CLI | `graphify devin install` |
| Google Antigravity | `graphify antigravity install` |
This writes a small config file that tells your assistant to consult the knowledge graph for codebase questions, preferring scoped queries like `graphify query "<question>"` over reading the full report or grepping raw files.
这会写入一个小型配置文件,指示你的助手在回答代码库相关问题时查阅知识图谱,优先使用像 `graphify query "<question>"` 这样的范围化查询,而不是阅读完整报告或直接 grep 原始文件。
- **Hook platforms** (Claude Code, Gemini CLI): a hook fires automatically before search-style tool calls (and, on Claude Code, before reading source files one by one via the Read/Glob tools) and nudges your assistant toward the graph path.
- **Instruction-file platforms** (Codex, OpenCode, Cursor, etc.): persistent instruction files (`AGENTS.md`, `.cursor/rules/`, etc.) provide the same query-first guidance.
- **Hook 平台**Claude CodeGemini CLI):在搜索类工具调用之前会自动触发 hook(在 Claude Code 上还会在通过 Read/Glob 工具逐个读取源文件之前触发),引导你的助手走图谱路径。
- **指令文件平台**CodexOpenCodeCursor 等):持久化指令文件(`AGENTS.md``.cursor/rules/` 等)提供相同的“先查询”引导。
`GRAPH_REPORT.md` is still available for broad architecture review.
`GRAPH_REPORT.md` 仍可用于广泛的架构审查。
**CodeBuddy** does the same two things as Claude Code: writes a `CODEBUDDY.md` section telling CodeBuddy to read `graphify-out/GRAPH_REPORT.md` before answering architecture questions, and installs `PreToolUse` hooks (`.codebuddy/settings.json`) that fire before Bash search commands and file reads, nudging toward `graphify query` instead.
**CodeBuddy** Claude Code 做同样两件事:写入 `CODEBUDDY.md` 节,告诉 CodeBuddy 在回答架构问题前先读 `graphify-out/GRAPH_REPORT.md`;并安装 `PreToolUse` hooks`.codebuddy/settings.json`),在 Bash 搜索命令和文件读取之前触发,引导使用 `graphify query`
**Codex** writes to `AGENTS.md` and also installs a `PreToolUse` hook in `.codex/hooks.json` that fires before every Bash tool call, same always-on mechanism as Claude Code.
**Codex** 写入 `AGENTS.md`,并在 `.codex/hooks.json` 中安装 `PreToolUse` hook,在每次 Bash 工具调用之前触发,与 Claude Code 相同的始终开启机制。
**Kilo Code** installs the Graphify skill to `~/.config/kilo/skills/graphify/SKILL.md` and a native `/graphify` command to `~/.config/kilo/command/graphify.md`. `graphify kilo install` also writes `AGENTS.md` plus a native `tool.execute.before` plugin (`.kilo/plugins/graphify.js` + `.kilo/kilo.json` or `.kilo/kilo.jsonc` registration) so Kilo gets the same always-on graph reminder behavior through native `.kilo` config.
**Kilo Code** Graphify skill 安装到 `~/.config/kilo/skills/graphify/SKILL.md`,并将原生 `/graphify` 命令安装到 `~/.config/kilo/command/graphify.md``graphify kilo install` 还会写入 `AGENTS.md`,以及原生 `tool.execute.before` 插件(`.kilo/plugins/graphify.js` + `.kilo/kilo.json` `.kilo/kilo.jsonc` 注册),这样 Kilo 可通过原生 `.kilo` 配置获得相同的始终开启的图谱提醒行为。
**Cursor** writes `.cursor/rules/graphify.mdc` with `alwaysApply: true`, so Cursor includes it in every conversation automatically, no hook needed.
**Cursor** 写入带有 `alwaysApply: true` `.cursor/rules/graphify.mdc`,因此 Cursor 会在每次对话中自动包含它,无需 hook。
To remove graphify from all platforms at once: `graphify uninstall` (add `--purge` to also delete `graphify-out/`). Or use the per-platform command (e.g. `graphify claude uninstall`).
要一次性从所有平台移除 graphify:`graphify uninstall`(添加 `--purge` 可同时删除 `graphify-out/`)。或使用各平台专属命令(例如 `graphify claude uninstall`)。
---
## What's in the report
## 报告包含什么
- **God nodes** — the most-connected concepts in your project. Everything flows through these.
- **Surprising connections** — links between things that live in different files or modules. Ranked by how unexpected they are.
- **The "why"** — inline comments (`# NOTE:`, `# WHY:`, `# HACK:`), docstrings, and design rationale from docs are extracted as separate nodes linked to the code they explain.
- **Suggested questions** — 45 questions the graph is uniquely positioned to answer.
- **Confidence tags** — every inferred relationship is marked `EXTRACTED`, `INFERRED`, or `AMBIGUOUS`. You always know what was found vs guessed.
- **God 节点** — 项目中连接最多的概念,一切流经这些节点。
- **意外连接** — 位于不同文件或模块中的事物之间的链接,按意外程度排序。
- **“原因”(why** — 行内注释(`# NOTE:``# WHY:``# HACK:`)、文档字符串以及文档中的设计理由会被提取为独立节点,并链接到它们所解释的代码。
- **建议问题** — 4–5 个图谱最能独特回答的问题。
- **置信度标签** — 每个推断关系均标记为 `EXTRACTED``INFERRED` `AMBIGUOUS`。你始终能区分哪些是发现的、哪些是推测的。
---
## What files it handles
## 支持哪些文件
| Type | Extensions |
| 类型 | 扩展名 |
|------|-----------|
| Code (36 tree-sitter grammars) | `.py .ts .mts .cts .js .jsx .tsx .mjs .go .rs .java .c .cpp .cc .cxx .h .hpp .cu .cuh .metal .rb .cs .kt .kts .scala .php .swift .lua .luau .toc .zig .ps1 .psm1 .psd1 .ex .exs .m .mm .jl .vue .svelte .astro .groovy .gradle .dart .v .sv .svh .sql .f .f90 .f95 .f03 .f08 .pas .pp .dpr .dpk .lpr .inc .dfm .lfm .lpk .sh .bash .json .dm .dme .dmi .dmm .dmf .sln .slnx .csproj .fsproj .vbproj .xaml .razor .cshtml` (`.dm`/`.dme` requires `uv tool install graphifyy[dm]`; `.mts`/`.cts` reuse the TypeScript grammar, `.cc`/`.cxx` and CUDA `.cu`/`.cuh` and Metal `.metal` reuse the C++ grammar) |
| 代码(36 种 tree-sitter 语法) | `.py .ts .mts .cts .js .jsx .tsx .mjs .go .rs .java .c .cpp .cc .cxx .h .hpp .cu .cuh .metal .rb .cs .kt .kts .scala .php .swift .lua .luau .toc .zig .ps1 .psm1 .psd1 .ex .exs .m .mm .jl .vue .svelte .astro .groovy .gradle .dart .v .sv .svh .sql .f .f90 .f95 .f03 .f08 .pas .pp .dpr .dpk .lpr .inc .dfm .lfm .lpk .sh .bash .json .dm .dme .dmi .dmm .dmf .sln .slnx .csproj .fsproj .vbproj .xaml .razor .cshtml` (`.dm`/`.dme` requires `uv tool install graphifyy[dm]`; `.mts`/`.cts` reuse the TypeScript grammar, `.cc`/`.cxx` and CUDA `.cu`/`.cuh` and Metal `.metal` reuse the C++ grammar) |
| Salesforce Apex | `.cls .trigger` (regex-based; classes, interfaces, enums, methods, triggers, SOQL/DML edges) |
| Terraform / HCL | `.tf .tfvars .hcl` (requires `uv tool install graphifyy[terraform]`) |
| MCP configs | `.mcp.json` `mcp.json` `mcp_servers.json` `claude_desktop_config.json` — extracts server nodes, package refs, env var requirements |
| Package manifests | `apm.yml` `pyproject.toml` `go.mod` `pom.xml` — one canonical package node per package (by name) plus `depends_on` edges, so a package referenced from many manifests is a single hub |
| Docs | `.md .mdx .qmd .html .txt .rst .yaml .yml` (markdown `[text](./other.md)` links and `[[wikilinks]]` become `references` edges between docs) |
| MCP 配置 | `.mcp.json` `mcp.json` `mcp_servers.json` `claude_desktop_config.json` — extracts server nodes, package refs, env var requirements |
| 包清单 | `apm.yml` `pyproject.toml` `go.mod` `pom.xml` — one canonical package node per package (by name) plus `depends_on` edges, so a package referenced from many manifests is a single hub |
| 文档 | `.md .mdx .qmd .html .txt .rst .yaml .yml` (markdown `[text](./other.md)` links and `[[wikilinks]]` become `references` edges between docs) |
| Office | `.docx .xlsx` (requires `uv tool install graphifyy[office]`) |
| Google Workspace | `.gdoc .gsheet .gslides` (opt-in; requires `gws` auth and `--google-workspace`; Sheets need `uv tool install graphifyy[google]`) |
| PDFs | `.pdf` |
| Images | `.png .jpg .webp .gif` |
| Video / Audio | `.mp4 .mov .mp3 .wav` and more (requires `uv tool install graphifyy[video]`) |
| YouTube / URLs | any video URL (requires `uv tool install graphifyy[video]`) |
| PDF | `.pdf` |
| 图片 | `.png .jpg .webp .gif` |
| 视频 / 音频 | `.mp4 .mov .mp3 .wav` and more (requires `uv tool install graphifyy[video]`) |
| YouTube / URL | any video URL (requires `uv tool install graphifyy[video]`) |
Code is extracted **locally with no API calls** (AST via tree-sitter). Everything else goes through your AI assistant's model API.
代码在**本地提取,无需 API 调用**(通过 tree-sitter 的 AST)。其余内容均通过你的 AI 助手模型 API 处理。
Google Drive for desktop `.gdoc`, `.gsheet`, and `.gslides` files are shortcut
pointers, not document content. To include native Google Docs, Sheets, and Slides
in a headless extraction, install and authenticate the
[`gws` CLI](https://github.com/googleworkspace/cli), then run:
桌面版 Google Drive `.gdoc``.gsheet` `.gslides` 文件是快捷方式
指针,而非文档内容。若要在无头提取中包含原生 Google DocsSheets Slides
请安装并认证
[`gws` CLI](https://github.com/googleworkspace/cli),),然后运行:
```bash
uv tool install "graphifyy[google]" # needed for Google Sheets table rendering
@@ -353,12 +353,12 @@ gws auth login -s drive
graphify extract ./docs --google-workspace
```
You can also set `GRAPHIFY_GOOGLE_WORKSPACE=1`. Graphify exports shortcuts into
`graphify-out/converted/` as Markdown sidecars, then extracts those files.
你也可以设置 `GRAPHIFY_GOOGLE_WORKSPACE=1`Graphify 会将快捷方式导出为
`graphify-out/converted/` 中的 Markdown 侧车文件,然后提取这些文件。
---
## Common commands
## 常用命令
```bash
/graphify . # build graph for current folder
@@ -386,15 +386,15 @@ graphify prs --triage # AI ranks your review queue (uses whatever b
graphify prs --conflicts # PRs sharing graph communities — merge-order risk
```
See the [full command reference](#full-command-reference) below.
请参阅下方的[完整命令参考](#full-command-reference)
---
## Ignoring files
## 忽略文件
Create a `.graphifyignore` in your project root — same syntax as `.gitignore`, including `!` negation.
在项目根目录创建 `.graphifyignore` — 语法与 `.gitignore` 相同,包括 `!` 取反。
**`.gitignore` is respected automatically.** graphify reads the `.gitignore` in each directory. If a `.graphifyignore` is also present, the two are **merged**`.graphifyignore` patterns are evaluated last, so they win on conflicts (including `!` negations). Adding a `.graphifyignore` only ever excludes more; it never re-includes a file your `.gitignore` already excluded. Subdirectory scoping works the same way as git — an ignore file only affects its own subtree.
**`.gitignore` 会自动生效。** graphify 会读取每个目录中的 `.gitignore`。如果还存在 `.graphifyignore`,两者会**合并**——`.graphifyignore` 中的模式最后求值,因此在冲突时优先生效(包括 `!` 的否定规则)。添加 `.graphifyignore` 只会进一步排除文件;它绝不会重新纳入已被 `.gitignore` 排除的文件。子目录作用域与 git 相同——忽略文件只影响其自身子树。
```
# .graphifyignore
@@ -410,27 +410,27 @@ dist/
---
## Team setup
## 团队配置
`graphify-out/` is meant to be committed to git so everyone on the team starts with a map.
`graphify-out/` 应提交到 git,以便团队中的每个人都能从同一份图谱起步。
**Recommended `.gitignore` additions:**
**建议添加到 `.gitignore`**
```
graphify-out/cost.json # local only
# graphify-out/cache/ # optional: commit for speed, skip to keep repo small
```
> `manifest.json` is now portable — keys are stored as relative paths and re-anchored on load, so committing it is safe and avoids a full rebuild on first checkout.
> `manifest.json` 现已可移植——键以相对路径存储,并在加载时重新锚定,因此提交它是安全的,也能避免首次检出时进行完整重建。
**Workflow:**
1. One person runs `/graphify .` and commits `graphify-out/`.
2. Everyone pulls — their assistant reads the graph immediately.
3. Run `graphify hook install` to auto-rebuild after each commit (AST only, no API cost). This also sets up a git merge driver so `graph.json` is never left with conflict markers — two devs committing in parallel get their graphs union-merged automatically.
4. When docs or papers change, run `/graphify --update` to refresh those nodes.
**工作流程:**
1. 由一人运行 `/graphify .` 并提交 `graphify-out/`
2. 所有人拉取代码——其助手可立即读取图谱。
3. 运行 `graphify hook install`,在每次提交后自动重建(仅 AST,无 API 费用)。这还会配置 git merge driver,确保 `graph.json` 不会残留冲突标记——两名开发者并行提交时,其图谱会自动做并集合并。
4. 当文档或论文变更时,运行 `/graphify --update` 以刷新相应节点。
---
## Using the graph directly
## 直接使用图谱
```bash
# query the graph from the terminal
@@ -449,24 +449,24 @@ python -m graphify.serve graphify-out/graph.json --transport http --port 8080
python -m graphify.serve graphify-out/graph.json --transport http --host 0.0.0.0 --api-key "$SECRET"
```
The MCP server gives your assistant structured access: `query_graph`, `get_node`, `get_neighbors`, `shortest_path`, `list_prs`, `get_pr_impact`, `triage_prs`.
MCP 服务器为你的助手提供结构化访问:`query_graph``get_node``get_neighbors``shortest_path``list_prs``get_pr_impact``triage_prs`
### Shared HTTP server
### 共享 HTTP 服务器
`--transport stdio` (the default) spawns one local server per developer. `--transport http` serves the same tools over the MCP Streamable HTTP transport, so a single shared process can serve the graph for the whole team — clients point their IDE MCP config at `http://<host>:8080/mcp` instead of running graphify locally.
`--transport stdio`(默认)会为每位开发者启动一个本地服务器。`--transport http` 通过 MCP Streamable HTTP 传输提供相同工具,因此单个共享进程即可为整个团队提供图谱服务——客户端将 IDE MCP 配置指向 `http://<host>:8080/mcp`,而无需在本地运行 graphify。
| Flag | Default | Purpose |
|---|---|---|
| `--transport {stdio,http}` | `stdio` | Transport to serve on |
| `--host` | `127.0.0.1` | HTTP bind host (use `0.0.0.0` to expose beyond localhost) |
| `--port` | `8080` | HTTP bind port |
| `--api-key` | env `GRAPHIFY_API_KEY` | Require `Authorization: Bearer <key>` (or `X-API-Key`) |
| `--path` | `/mcp` | HTTP mount path |
| `--json-response` | off | Return plain JSON instead of SSE streams |
| `--stateless` | off | No per-session state (for load-balanced / CI deployments) |
| `--session-timeout` | `3600` | Reap idle stateful sessions after N seconds (`0` disables) |
| `--transport {stdio,http}` | `stdio` | 要提供的传输方式 |
| `--host` | `127.0.0.1` | HTTP 绑定主机(使用 `0.0.0.0` 可暴露到 localhost 之外) |
| `--port` | `8080` | HTTP 绑定端口 |
| `--api-key` | env `GRAPHIFY_API_KEY` | 要求 `Authorization: Bearer <key>`(或 `X-API-Key` |
| `--path` | `/mcp` | HTTP 挂载路径 |
| `--json-response` | off | 返回纯 JSON,而非 SSE 流 |
| `--stateless` | off | 无每会话状态(适用于负载均衡 / CI 部署) |
| `--session-timeout` | `3600` | N 秒后回收空闲的有状态会话(`0` 可禁用) |
The default `127.0.0.1` bind is loopback-only. Set `--host 0.0.0.0` **and** `--api-key` together when exposing on a shared host. Run it in a container:
默认的 `127.0.0.1` 绑定仅限 loopback。在共享主机上对外暴露时,请同时设置 `--host 0.0.0.0` **** `--api-key`。在容器中运行:
```bash
docker build -t graphify .
@@ -474,130 +474,130 @@ docker run -p 8080:8080 -v "$(pwd)/graphify-out:/data" graphify \
/data/graph.json --transport http --host 0.0.0.0 --api-key "$SECRET"
```
> **WSL / Linux note:** Ubuntu ships `python3`, not `python`. Use a venv to avoid conflicts:
> **WSL / Linux 说明:** Ubuntu 自带 `python3`,而非 `python`。请使用 venv 以避免冲突:
> ```bash
> python3 -m venv .venv && .venv/bin/pip install "graphifyy[mcp]"
> ```
---
## Environment variables
## 环境变量
These are only needed for **headless / CI extraction** (`graphify extract`). When running via the `/graphify` skill inside your IDE, the model API is provided by your IDE session — no extra keys needed.
这些仅在**无头 / CI 提取**`graphify extract`)时需要。通过 IDE 内的 `/graphify` skill 运行时,模型 API 由 IDE 会话提供——无需额外密钥。
| Variable | Used for | When required |
|---|---|---|
| `ANTHROPIC_API_KEY` | Claude (Anthropic) backend | `--backend claude` |
| `ANTHROPIC_BASE_URL` | Anthropic-compatible endpoint URL (LiteLLM proxy, gateways, ...) | `--backend claude` (default: `https://api.anthropic.com`) |
| `ANTHROPIC_MODEL` | Model name for the Claude backend — for custom endpoints, use the model name/alias your server exposes | `--backend claude` (default: `claude-sonnet-4-6`) |
| `GEMINI_API_KEY` or `GOOGLE_API_KEY` | Google Gemini backend | `--backend gemini` |
| `OPENAI_API_KEY` | OpenAI or OpenAI-compatible APIs | `--backend openai` (local servers accept any non-empty value) |
| `OPENAI_BASE_URL` | OpenAI-compatible server URL (llama.cpp, vLLM, LM Studio, ...) | `--backend openai` (default: `https://api.openai.com/v1`) |
| `OPENAI_MODEL` | Model name for the OpenAI backend — for self-hosted servers, use the model name/alias your server exposes (check its `/v1/models` endpoint), e.g. `LFM2.5-8B-A1B-UD-Q4_K_XL` for llama.cpp | `--backend openai` (default: `gpt-4.1-mini`) |
| `DEEPSEEK_API_KEY` | DeepSeek backend | `--backend deepseek` |
| `MOONSHOT_API_KEY` | Kimi Code backend | `--backend kimi` |
| `OLLAMA_BASE_URL` | Ollama local inference URL | `--backend ollama` (default: `http://localhost:11434`) |
| `OLLAMA_MODEL` | Ollama model name | `--backend ollama` (default: auto-detect) |
| `GRAPHIFY_OLLAMA_NUM_CTX` | Override Ollama KV-cache window size | optional — auto-sized by default |
| `GRAPHIFY_OLLAMA_KEEP_ALIVE` | Minutes to keep Ollama model loaded | optional — set `0` to unload after each chunk |
| `AZURE_OPENAI_API_KEY` | Azure OpenAI Service backend | `--backend azure` |
| `AZURE_OPENAI_ENDPOINT` | Azure resource endpoint URL | `--backend azure` (required alongside API key) |
| `AZURE_OPENAI_API_VERSION` | Azure API version override | optional — default `2024-12-01-preview` |
| `AZURE_OPENAI_DEPLOYMENT` or `GRAPHIFY_AZURE_MODEL` | Azure deployment name | optional — default `gpt-4o` |
| `AWS_*` / `~/.aws/credentials` | AWS Bedrock — standard credential chain | `--backend bedrock` (no API key, uses IAM) |
| `GRAPHIFY_MAX_WORKERS` | AST parallelism thread count | optional — also `--max-workers` flag |
| `GRAPHIFY_MAX_OUTPUT_TOKENS` | Raise output cap for dense corpora | optional — e.g. `32768` for large files |
| `GRAPHIFY_API_TIMEOUT` | Per-call timeout in seconds for HTTP, claude-cli, and Anthropic SDK backends (default: 600) | optional — also `--api-timeout` flag |
| `GRAPHIFY_MAX_RETRIES` | How many times to retry a rate-limited (429) request before giving up (default: 6; honors `Retry-After`) | optional — raise for strict per-org limits (e.g. kimi); `0` disables |
| `GRAPHIFY_FORCE` | Force graph rebuild even with fewer nodes | optional — also `--force` flag |
| `GRAPHIFY_GOOGLE_WORKSPACE` | Auto-enable Google Workspace export | optional — set to `1` |
| `GRAPHIFY_TRIAGE_BACKEND` | Backend for `graphify prs --triage` | optional — auto-detected from available keys |
| `GRAPHIFY_TRIAGE_MODEL` | Model override for triage | optional — e.g. `claude-opus-4-7` |
| `GRAPHIFY_QUERY_LOG_ENABLE` | Set to `1` to turn on the local query log at `~/.cache/graphify-queries.log` (records each query/path/explain question + corpus path). Off by default — nothing is written unless you opt in (#1797) | optional |
| `GRAPHIFY_QUERY_LOG` | Enable the query log and write it to this path instead of the default | optional — off unless this or `_ENABLE` is set |
| `GRAPHIFY_QUERY_LOG_DISABLE` | Set to `1` to force the query log off (wins over the enable vars) | optional |
| `GRAPHIFY_QUERY_LOG_RESPONSES` | When the log is enabled, also record full subgraph responses (off by default) | optional |
| `GRAPHIFY_MAX_GRAPH_BYTES` | Override the 512 MiB graph.json size cap — e.g. `700MB`, `2GB`, or plain bytes | optional — useful for very large corpora |
| `GRAPHIFY_LLM_TEMPERATURE` | Override LLM temperature for semantic extraction — e.g. `0.7`, or `none` to omit | optional — auto-omitted for o1/o3/o4/gpt-5 reasoning models |
| `ANTHROPIC_API_KEY` | ClaudeAnthropic)后端 | `--backend claude` |
| `ANTHROPIC_BASE_URL` | Anthropic 兼容端点 URLLiteLLM 代理、网关等) | `--backend claude`(默认:`https://api.anthropic.com` |
| `ANTHROPIC_MODEL` | Claude 后端的模型名称——对于自定义端点,请使用你的服务器暴露的模型名称/别名 | `--backend claude`(默认:`claude-sonnet-4-6` |
| `GEMINI_API_KEY` `GOOGLE_API_KEY` | Google Gemini 后端 | `--backend gemini` |
| `OPENAI_API_KEY` | OpenAI OpenAI 兼容 API | `--backend openai`(本地服务器接受任意非空值) |
| `OPENAI_BASE_URL` | OpenAI 兼容服务器 URLllama.cppvLLMLM Studio 等) | `--backend openai`(默认:`https://api.openai.com/v1` |
| `OPENAI_MODEL` | OpenAI 后端的模型名称——对于自托管服务器,请使用你的服务器暴露的模型名称/别名(查看其 `/v1/models` 端点),例如 llama.cpp 使用 `LFM2.5-8B-A1B-UD-Q4_K_XL` | `--backend openai`(默认:`gpt-4.1-mini` |
| `DEEPSEEK_API_KEY` | DeepSeek 后端 | `--backend deepseek` |
| `MOONSHOT_API_KEY` | Kimi Code 后端 | `--backend kimi` |
| `OLLAMA_BASE_URL` | Ollama 本地推理 URL | `--backend ollama`(默认:`http://localhost:11434` |
| `OLLAMA_MODEL` | Ollama 模型名称 | `--backend ollama`(默认:自动检测) |
| `GRAPHIFY_OLLAMA_NUM_CTX` | 覆盖 Ollama KV-cache 窗口大小 | 可选——默认自动调整 |
| `GRAPHIFY_OLLAMA_KEEP_ALIVE` | 保持 Ollama 模型加载的分钟数 | 可选——设置 `0` 可在每个分块后卸载 |
| `AZURE_OPENAI_API_KEY` | Azure OpenAI Service 后端 | `--backend azure` |
| `AZURE_OPENAI_ENDPOINT` | Azure 资源端点 URL | `--backend azure`(需与 API 密钥一并提供) |
| `AZURE_OPENAI_API_VERSION` | Azure API 版本覆盖 | 可选——默认 `2024-12-01-preview` |
| `AZURE_OPENAI_DEPLOYMENT` `GRAPHIFY_AZURE_MODEL` | Azure 部署名称 | 可选——默认 `gpt-4o` |
| `AWS_*` / `~/.aws/credentials` | AWS Bedrock——标准凭证链 | `--backend bedrock`(无需 API 密钥,使用 IAM |
| `GRAPHIFY_MAX_WORKERS` | AST 并行线程数 | 可选——也可通过 `--max-workers` 标志设置 |
| `GRAPHIFY_MAX_OUTPUT_TOKENS` | 提高密集语料库的输出上限 | 可选——例如大文件使用 `32768` |
| `GRAPHIFY_API_TIMEOUT` | HTTPclaude-cli Anthropic SDK 后端的每次调用超时(秒)(默认:600 | 可选——也可通过 `--api-timeout` 标志设置 |
| `GRAPHIFY_MAX_RETRIES` | 放弃前对限速(429)请求的重试次数(默认:6;遵守 `Retry-After` | 可选——对于严格的组织级限制(例如 kimi)可提高;`0` 可禁用 |
| `GRAPHIFY_FORCE` | 即使节点更少也强制重建图谱 | 可选——也可通过 `--force` 标志设置 |
| `GRAPHIFY_GOOGLE_WORKSPACE` | 自动启用 Google Workspace 导出 | 可选——设置为 `1` |
| `GRAPHIFY_TRIAGE_BACKEND` | `graphify prs --triage` 的后端 | 可选——根据可用密钥自动检测 |
| `GRAPHIFY_TRIAGE_MODEL` | 分类(triage)的模型覆盖 | 可选——例如 `claude-opus-4-7` |
| `GRAPHIFY_QUERY_LOG_ENABLE` | 设置为 `1` 可在 `~/.cache/graphify-queries.log` 启用本地查询日志(记录每次 query/path/explain 问题及语料库路径)。默认关闭——除非你主动启用,否则不会写入任何内容(#1797 | 可选 |
| `GRAPHIFY_QUERY_LOG` | 启用查询日志并写入此路径,而非默认路径 | 可选——除非设置此项或 `_ENABLE`,否则关闭 |
| `GRAPHIFY_QUERY_LOG_DISABLE` | 设置为 `1` 可强制关闭查询日志(优先于启用变量) | 可选 |
| `GRAPHIFY_QUERY_LOG_RESPONSES` | 启用日志时,同时记录完整子图响应(默认关闭) | 可选 |
| `GRAPHIFY_MAX_GRAPH_BYTES` | 覆盖 512 MiB graph.json 大小上限——例如 `700MB``2GB` 或纯字节数 | 可选——适用于非常大的语料库 |
| `GRAPHIFY_LLM_TEMPERATURE` | 覆盖语义提取的 LLM 温度——例如 `0.7`,或 `none` 以省略 | 可选——对 o1/o3/o4/gpt-5 推理模型会自动省略 |
---
## Privacy
## 隐私
- **Code files** — processed locally via tree-sitter. Nothing leaves your machine. A code-only corpus requires no API key`graphify extract` runs fully offline.
- **Video / audio** — transcribed locally with faster-whisper. Nothing leaves your machine.
- **Docs, PDFs, images** — sent to your AI assistant for semantic extraction (via the `/graphify` skill, using whatever model your IDE session runs). Headless `graphify extract` requires `GEMINI_API_KEY` / `GOOGLE_API_KEY` (Gemini), `MOONSHOT_API_KEY` (Kimi), `ANTHROPIC_API_KEY` (Claude), `OPENAI_API_KEY` (OpenAI), `DEEPSEEK_API_KEY` (DeepSeek), a running Ollama instance (`OLLAMA_BASE_URL`), AWS credentials via the standard provider chain (Bedrock - no API key needed, uses IAM), or the `claude` CLI binary (Claude Code - no API key needed, uses your Claude subscription). The `--dedup-llm` flag uses the same key.
- **Data residency** — `graphify extract` auto-detects which provider to use based on which API key is set (priority: Gemini → Kimi → Claude → OpenAI → DeepSeek → Azure → Bedrock → Ollama). For code with data-residency requirements, use `--backend ollama` (fully local) or pass an explicit `--backend` flag. Kimi (`MOONSHOT_API_KEY`) routes to Moonshot AI servers in China.
- **No telemetry**, no usage tracking, no analytics.
- **Query logging** — every `graphify query`, `graphify path`, `graphify explain`, and MCP `query_graph` call is logged to `~/.cache/graphify-queries.log` in JSON Lines format (timestamp, question, corpus, nodes returned, duration). Full subgraph responses are **not** stored by default. Set `GRAPHIFY_QUERY_LOG_DISABLE=1` to opt out, or `GRAPHIFY_QUERY_LOG=/dev/null` to silence without disabling the code path.
- **代码文件** — 通过 tree-sitter 在本地处理。数据不会离开你的机器。仅含代码的语料库无需 API 密钥`graphify extract` 可完全离线运行。
- **视频 / 音频** — 使用 faster-whisper 在本地转写。数据不会离开你的机器。
- **文档、PDF、图片** — 发送给你的 AI 助手进行语义提取(通过 `/graphify` 技能,使用你 IDE 会话中运行的任意模型)。无头(headless`graphify extract` 需要 `GEMINI_API_KEY` / `GOOGLE_API_KEY`Gemini)、`MOONSHOT_API_KEY`Kimi)、`ANTHROPIC_API_KEY`Claude)、`OPENAI_API_KEY`OpenAI)、`DEEPSEEK_API_KEY`DeepSeek)、正在运行的 Ollama 实例(`OLLAMA_BASE_URL`)、通过标准提供程序链的 AWS 凭证(Bedrock — 无需 API 密钥,使用 IAM),或 `claude` CLI 二进制文件(Claude Code — 无需 API 密钥,使用你的 Claude 订阅)。`--dedup-llm` 标志使用相同的密钥。
- **数据驻留** — `graphify extract` 会根据已设置的 API 密钥自动检测使用哪个提供程序(优先级:Gemini → Kimi → Claude → OpenAI → DeepSeek → Azure → Bedrock → Ollama)。对于有数据驻留要求的代码,请使用 `--backend ollama`(完全本地),或传入显式的 `--backend` 标志。Kimi`MOONSHOT_API_KEY`)会路由到中国境内的 Moonshot AI 服务器。
- **无遥测**、无使用跟踪、无分析。
- **查询日志** — 每次 `graphify query``graphify path``graphify explain` MCP `query_graph` 调用都会以 JSON Lines 格式记录到 `~/.cache/graphify-queries.log`(时间戳、问题、语料库、返回的节点、耗时)。默认情况下**不会**存储完整的子图响应。设置 `GRAPHIFY_QUERY_LOG_DISABLE=1` 可退出,或设置 `GRAPHIFY_QUERY_LOG=/dev/null` 可在不关闭代码路径的情况下静默日志。
---
## Troubleshooting
## 故障排除
**`graphify: command not found` after installing**
The CLI is installed but its bin directory isn't on your shell's `PATH`. Pick the fix for how you installed:
- **uv** (`uv tool install graphifyy`): the command lands in uv's tool bin dir (`~/.local/bin`), which a fresh macOS/zsh setup often doesn't have on `PATH`. Run `uv tool update-shell`, then open a new terminal. (Find the dir with `uv tool dir --bin`.)
- **pipx** (`pipx install graphifyy`): run `pipx ensurepath`, then open a new terminal.
- **pip** (`pip install graphifyy`): pip installs scripts to a user bin dir that may not be on `PATH` — add `~/Library/Python/3.x/bin` (macOS) or `~/.local/bin` (Linux) to your `PATH` in `~/.zshrc`/`~/.bashrc`, or just run `python -m graphify`.
**安装后出现 `graphify: command not found`**
CLI 已安装,但其 bin 目录不在 shell `PATH` 中。根据你的安装方式选择修复方法:
- **uv**`uv tool install graphifyy`):命令会安装到 uv 的工具 bin 目录(`~/.local/bin`),全新的 macOS/zsh 环境通常不会将其加入 `PATH`。运行 `uv tool update-shell`,然后打开新终端。(使用 `uv tool dir --bin` 查找该目录。)
- **pipx**`pipx install graphifyy`):运行 `pipx ensurepath`,然后打开新终端。
- **pip**`pip install graphifyy`):pip 将脚本安装到用户 bin 目录,该目录可能不在 `PATH` 中 — 将 `~/Library/Python/3.x/bin`macOS)或 `~/.local/bin`Linux)添加到你的 `PATH` 中的 `~/.zshrc`/`~/.bashrc`,或直接运行 `python -m graphify`
**`uvx graphify …` or `uv tool run graphify …` fails to resolve `graphify`**
The PyPI package is `graphifyy`; `graphify` is only the command it provides. `uv tool run` treats the first word as a *package name*, so it looks for a package called `graphify` and reports `No solution found … no versions of graphify`. Name the package explicitly: `uvx --from graphifyy graphify install` (same as `uv tool run --from graphifyy graphify install`). Or `uv tool install graphifyy` once and then call `graphify` directly.
**`uvx graphify …` `uv tool run graphify …` 无法解析 `graphify`**
PyPI 包名为 `graphifyy``graphify` 只是它提供的命令。`uv tool run` 将第一个词视为*包名*,因此会查找名为 `graphify` 的包并报告 `No solution found … no versions of graphify`。请显式指定包名:`uvx --from graphifyy graphify install`(与 `uv tool run --from graphifyy graphify install` 相同)。或先运行一次 `uv tool install graphifyy`,然后直接调用 `graphify`
**`python -m graphify` works but `graphify` command doesn't**
Your shell's `PATH` doesn't include the bin directory the command was installed to. Prefer `uv tool install` / `pipx install` over plain `pip`, then run `uv tool update-shell` / `pipx ensurepath` and open a new terminal (see the install notes above).
**`python -m graphify` 可用但 `graphify` 命令不可用**
你的 shell `PATH` 不包含命令所安装到的 bin 目录。优先使用 `uv tool install` / `pipx install`,而非普通的 `pip`,然后运行 `uv tool update-shell` / `pipx ensurepath` 并打开新终端(参见上文安装说明)。
**`/graphify .` causes "path not recognized" in PowerShell**
PowerShell treats a leading `/` as a path separator. Use `graphify .` (no slash) on Windows.
**`/graphify .` 在 PowerShell 中导致“路径无法识别”**
PowerShell 将开头的 `/` 视为路径分隔符。在 Windows 上请使用 `graphify .`(无斜杠)。
**Graph has fewer nodes after `--update` or rebuild**
If a refactor deleted files, the old nodes linger. Pass `--force` (or set `GRAPHIFY_FORCE=1`) to overwrite even when the rebuild has fewer nodes.
**`--update` 或重建后图的节点变少**
如果重构删除了文件,旧节点会残留。传入 `--force`(或设置 `GRAPHIFY_FORCE=1`)以在重建后节点更少时仍覆盖写入。
**Graph has duplicate nodes for the same entity (ghost duplicates)**
Ghost duplicates (same symbol appearing twice — once from AST extraction with a source location, once from semantic extraction without) are now automatically merged at build time. If you see this in a graph built before v0.8.33, run a full re-extract to clean up:
**图中同一实体出现重复节点(幽灵重复)**
幽灵重复(同一符号出现两次 — 一次来自带源码位置的 AST 提取,一次来自无语义位置的语义提取)现已在构建时自动合并。如果你在 v0.8.33 之前构建的图中看到此问题,请运行完整重新提取以清理:
```bash
graphify extract . --force
```
**Ollama runs out of VRAM / context window exceeded**
The KV-cache window is auto-sized but may be too large for your GPU. Reduce it:
**Ollama 显存不足 / 超出上下文窗口**
KV-cache 窗口会自动调整大小,但可能对你的 GPU 来说过大。缩小它:
```bash
GRAPHIFY_OLLAMA_NUM_CTX=8192 graphify extract ./docs --backend ollama --token-budget 4000
```
**`LLM returned invalid JSON` / `Unterminated string` warnings**
The model's JSON response hit its output-token limit and was cut off mid-string. graphify auto-recovers (it splits the chunk and re-extracts the halves, and an oversized single document is first sliced at heading/paragraph boundaries so the whole file is still covered), so these warnings are noisy but not data loss. To reduce the churn, raise the output cap or shrink each chunk's output:
**`LLM returned invalid JSON` / `Unterminated string` 警告**
模型的 JSON 响应达到了输出 token 上限,在字符串中间被截断。graphify 会自动恢复(它会拆分块并重新提取两半,过大的单个文档会先在标题/段落边界处切片,以确保仍覆盖整个文件),因此这些警告很嘈杂但不会造成数据丢失。要减少反复处理,可提高输出上限或缩小每个块的输出:
```bash
GRAPHIFY_MAX_OUTPUT_TOKENS=16384 graphify extract . --mode deep # lift the cap
graphify extract . --mode deep --token-budget 4000 # smaller input chunks -> smaller output
```
With a cloud gateway like OpenRouter, prefer `--backend openai` (set `OPENAI_BASE_URL`) over the Ollama shim — it's a cleaner OpenAI-compatible path. If the model has its own max-output ceiling, lowering `--token-budget` is the reliable lever.
对于 OpenRouter 等云端网关,优先使用 `--backend openai`(设置 `OPENAI_BASE_URL`),而非 Ollama shim — 这是更简洁的 OpenAI 兼容路径。如果模型本身有最大输出上限,降低 `--token-budget` 是更可靠的手段。
**Graph HTML is too large to open in a browser (>5000 nodes)**
Skip HTML generation and use the JSON directly:
** HTML 过大无法在浏览器中打开(>5000 个节点)**
跳过 HTML 生成,直接使用 JSON
```bash
graphify cluster-only ./my-project --no-viz
graphify query "..."
```
**`graph.json` has conflict markers after two devs commit at once**
Run `graphify hook install`it sets up a git merge driver that union-merges `graph.json` automatically so conflicts never happen.
**两名开发者同时提交后 `graph.json` 出现冲突标记**
运行 `graphify hook install`它会设置 git 合并驱动程序,自动对 `graph.json` 进行并集合并,从而避免冲突。
**Extraction returns empty nodes/edges for docs or PDFs**
Docs, PDFs, and images require an LLM call — code-only corpora need no key. Check that your API key is set and the backend is correct:
**文档或 PDF 的提取返回空节点/边**
文档、PDF 和图片需要 LLM 调用 — 仅含代码的语料库无需密钥。请检查 API 密钥是否已设置且后端是否正确:
```bash
ANTHROPIC_API_KEY=sk-... graphify extract ./docs --backend claude
```
**Skill version mismatch warning in your IDE**
Your installed graphify version is different from the skill file. Update:
**IDE 中出现技能版本不匹配警告**
你安装的 graphify 版本与技能文件不同。请更新:
```bash
uv tool upgrade graphifyy
graphify install # overwrites the skill file
```
**Claude Code prompt cache invalidated after every `graphify extract`**
Graphify writes output files (`graph.json`, `graphify-out/`) into the workspace. If those paths aren't ignored, every write invalidates Claude Code's prompt cache, forcing a full re-upload at cache-write rates on the next turn. Add them to `.claudeignore`:
**每次 `graphify extract` 后 Claude Code 提示缓存失效**
Graphify 会将输出文件(`graph.json``graphify-out/`)写入工作区。如果这些路径未被忽略,每次写入都会使 Claude Code 的提示缓存失效,迫使下一轮以缓存写入费率进行完整重新上传。将它们添加到 `.claudeignore`
```text
# .claudeignore
graph.json
@@ -606,7 +606,7 @@ graphify-out/
---
## Full command reference
## 完整命令参考
```
/graphify # run on current directory
@@ -758,35 +758,35 @@ graphify label ./my-project # (re)name commun
graphify label ./my-project --backend=openai --model gpt-4o # force a specific backend and model
```
> **Community names:** inside an agent (Claude Code, Gemini CLI) the agent names communities itself. When you run the bare CLI, `cluster-only` auto-names them with the configured backend (built-in or custom OpenAI-compatible provider) — pass `--no-label` to keep `Community N`, or run `graphify label` to (re)generate names on demand.
> **社区名称:** 在 agent 内部(Claude CodeGemini CLI)时,agent 会自行命名社区。当你运行裸 CLI 时,`cluster-only` 会使用已配置的后端(内置或自定义 OpenAI 兼容提供商)自动命名——传入 `--no-label` 以保留 `Community N`,或运行 `graphify label` 按需(重新)生成名称。
---
## Learn more
## 了解更多
- [How it works](docs/how-it-works.md) — the extraction pipeline, community detection, confidence scoring, benchmarks
- [ARCHITECTURE.md](ARCHITECTURE.md) — module breakdown, how to add a language
- [How it works](docs/how-it-works.md) — 抽取流水线、社区检测、置信度评分、基准测试
- [ARCHITECTURE.md](ARCHITECTURE.md) — 模块划分、如何添加一门语言
- [Optional integrations](docs/docker-mcp-sqlite.md) — Docker MCP Toolkit + SQLite
- [The Memory Layer](https://safishamsi.gumroad.com/l/qetvlo) — the book on the ideas behind graphify, the architecture end to end
- [The Memory Layer](https://safishamsi.gumroad.com/l/qetvlo) — 介绍 graphify 背后理念与端到端架构的著作
---
## Built on graphify: Penpax
## 基于 graphify 构建:Penpax
[**Penpax**](https://graphify.com) is the always-on layer built on top of graphify — it applies the same graph approach to your entire working life: meetings, browser history, emails, files, and code, updating continuously in the background.
[**Penpax**](https://graphify.com) 是基于 graphify 之上构建的常驻层——它将同样的图方法应用于你的整个工作生活:会议、浏览器历史、电子邮件、文件和代码,并在后台持续更新。
Built for people whose work lives across hundreds of conversations and documents they can never fully reconstruct. No cloud, fully on-device.
专为那些工作分散在数百次对话和文档中、永远无法完整回溯的人而打造。无云端,完全在设备本地运行。
**Free trial launching soon.** [Join the waitlist](https://www.graphify.com)
**免费试用即将推出。** [加入候补名单](https://www.graphify.com)
---
<details>
<summary>Contributing</summary>
<summary>参与贡献</summary>
### Development setup
### 开发环境配置
The project uses [uv](https://docs.astral.sh/uv/) for dev workflow. Install it once, then:
项目使用 [uv](https://docs.astral.sh/uv/) 进行开发工作流。安装一次后:
```bash
git clone https://github.com/safishamsi/graphify.git
@@ -799,13 +799,14 @@ git checkout v8 # active development branch
uv sync --all-extras
```
Verify the editable install:
验证可编辑安装:
```bash
uv run graphify --version
uv run python -c "import graphify; print(graphify.__file__)"
```
### Running tests
### 运行测试
```bash
uv run pytest tests/ -q # run the full suite
@@ -813,22 +814,22 @@ uv run pytest tests/test_extract.py -q # one module
uv run pytest tests/ -q -k "python" # filter by name
```
> macOS note: the test suite includes both `sample.f90` and `sample.F90` fixtures. These collide on case-insensitive HFS+ / APFS file systems. Run on Linux or in a Docker container if you need to test both Fortran variants simultaneously.
> macOS 说明:测试套件同时包含 `sample.f90` `sample.F90` 测试夹具。这些在大小写不敏感的 HFS+ / APFS 文件系统上会冲突。如需同时测试两种 Fortran 变体,请在 Linux 或 Docker 容器中运行。
### Git workflow
### Git 工作流
- Active development happens on the `v8` branch.
- Commit style: `fix: <description>` / `feat: <description>` / `docs: <description>`
- Before opening a PR, run `uv run pytest tests/ -q` and confirm it passes.
- Add a fixture file to `tests/fixtures/` and tests to `tests/test_languages.py` for any new language extractor.
- 活跃开发在 `v8` 分支上进行。
- 提交风格:`fix: <description>` / `feat: <description>` / `docs: <description>`
- 提交 PR 前,运行 `uv run pytest tests/ -q` 并确认通过。
- 为任何新的语言抽取器,在 `tests/fixtures/` 中添加夹具文件,并在 `tests/test_languages.py` 中添加测试。
### What to contribute
### 可以贡献什么
**Worked examples** are the most useful contribution. Run `/graphify` on a real corpus, save the output to `worked/{slug}/`, write an honest `review.md` covering what the graph got right and wrong, and open a PR.
**实战示例** 是最有价值的贡献。在真实语料上运行 `/graphify`,将输出保存到 `worked/{slug}/`,撰写一份客观的 `review.md`,说明图分析哪些做对了、哪些做错了,然后提交 PR
**Extraction bugs** — open an issue with the input file, the cache entry (`graphify-out/cache/`), and what was missed or wrong.
**抽取缺陷** — 提交 issue 时请附上输入文件、缓存条目(`graphify-out/cache/`),以及遗漏或错误之处。
See [ARCHITECTURE.md](ARCHITECTURE.md) for module responsibilities and how to add a language.
模块职责与如何添加语言,请参阅 [ARCHITECTURE.md](ARCHITECTURE.md)。
</details>
@@ -842,7 +843,7 @@ See [ARCHITECTURE.md](ARCHITECTURE.md) for module responsibilities and how to ad
---
## Community and links
## 社区与链接
<p align="center">
<a href="https://discord.gg/598Ad9zQZ"><img src="https://img.shields.io/badge/Discord-Join-5865F2?style=flat&logo=discord&logoColor=white" alt="Discord"/></a>