rustcodegraph 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +2 -0
- package/CHANGELOG.md +9 -0
- package/README.md +7 -9
- package/binary-install.js +212 -0
- package/binary.js +126 -0
- package/install.js +4 -0
- package/npm-shrinkwrap.json +900 -0
- package/package.json +93 -27
- package/run-rustcodegraph.js +4 -0
- package/README.zh-CN.md +0 -258
package/package.json
CHANGED
|
@@ -1,32 +1,98 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
"exports": {
|
|
6
|
-
"./package.json": "./package.json"
|
|
2
|
+
"artifactDownloadUrl": "https://github.com/hunzhiwange/rustcodegraph/releases/download/v1.1.0",
|
|
3
|
+
"bin": {
|
|
4
|
+
"rustcodegraph": "run-rustcodegraph.js"
|
|
7
5
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"eval": "cargo test --test evaluation_types",
|
|
19
|
-
"clean": "cargo clean"
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"axios": "^1.12.2",
|
|
8
|
+
"axios-proxy-builder": "^0.1.2",
|
|
9
|
+
"console.table": "^0.10.0",
|
|
10
|
+
"detect-libc": "^2.1.2",
|
|
11
|
+
"rimraf": "^6.0.1"
|
|
12
|
+
},
|
|
13
|
+
"description": "Local-first code intelligence graph and CLI for AI agents",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"prettier": "^3.6.2"
|
|
20
16
|
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"code-intelligence",
|
|
23
|
-
"knowledge-graph",
|
|
24
|
-
"static-analysis"
|
|
25
|
-
],
|
|
26
|
-
"author": "",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"dependencies": {},
|
|
29
17
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
18
|
+
"node": ">=14",
|
|
19
|
+
"npm": ">=6"
|
|
20
|
+
},
|
|
21
|
+
"glibcMinimum": {
|
|
22
|
+
"major": 2,
|
|
23
|
+
"series": 35
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/hunzhiwange/rustcodegraph",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"name": "rustcodegraph",
|
|
28
|
+
"preferUnplugged": true,
|
|
29
|
+
"repository": "https://github.com/hunzhiwange/rustcodegraph",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"fmt": "prettier --write **/*.js",
|
|
32
|
+
"fmt:check": "prettier --check **/*.js",
|
|
33
|
+
"postinstall": "node ./install.js"
|
|
34
|
+
},
|
|
35
|
+
"supportedPlatforms": {
|
|
36
|
+
"aarch64-apple-darwin": {
|
|
37
|
+
"artifactName": "rustcodegraph-aarch64-apple-darwin.tar.xz",
|
|
38
|
+
"bins": {
|
|
39
|
+
"rustcodegraph": "rustcodegraph"
|
|
40
|
+
},
|
|
41
|
+
"zipExt": ".tar.xz"
|
|
42
|
+
},
|
|
43
|
+
"aarch64-pc-windows-gnu": {
|
|
44
|
+
"artifactName": "rustcodegraph-aarch64-pc-windows-msvc.zip",
|
|
45
|
+
"bins": {
|
|
46
|
+
"rustcodegraph": "rustcodegraph.exe"
|
|
47
|
+
},
|
|
48
|
+
"zipExt": ".zip"
|
|
49
|
+
},
|
|
50
|
+
"aarch64-pc-windows-msvc": {
|
|
51
|
+
"artifactName": "rustcodegraph-aarch64-pc-windows-msvc.zip",
|
|
52
|
+
"bins": {
|
|
53
|
+
"rustcodegraph": "rustcodegraph.exe"
|
|
54
|
+
},
|
|
55
|
+
"zipExt": ".zip"
|
|
56
|
+
},
|
|
57
|
+
"aarch64-unknown-linux-gnu": {
|
|
58
|
+
"artifactName": "rustcodegraph-aarch64-unknown-linux-gnu.tar.xz",
|
|
59
|
+
"bins": {
|
|
60
|
+
"rustcodegraph": "rustcodegraph"
|
|
61
|
+
},
|
|
62
|
+
"zipExt": ".tar.xz"
|
|
63
|
+
},
|
|
64
|
+
"x86_64-apple-darwin": {
|
|
65
|
+
"artifactName": "rustcodegraph-x86_64-apple-darwin.tar.xz",
|
|
66
|
+
"bins": {
|
|
67
|
+
"rustcodegraph": "rustcodegraph"
|
|
68
|
+
},
|
|
69
|
+
"zipExt": ".tar.xz"
|
|
70
|
+
},
|
|
71
|
+
"x86_64-pc-windows-gnu": {
|
|
72
|
+
"artifactName": "rustcodegraph-x86_64-pc-windows-msvc.zip",
|
|
73
|
+
"bins": {
|
|
74
|
+
"rustcodegraph": "rustcodegraph.exe"
|
|
75
|
+
},
|
|
76
|
+
"zipExt": ".zip"
|
|
77
|
+
},
|
|
78
|
+
"x86_64-pc-windows-msvc": {
|
|
79
|
+
"artifactName": "rustcodegraph-x86_64-pc-windows-msvc.zip",
|
|
80
|
+
"bins": {
|
|
81
|
+
"rustcodegraph": "rustcodegraph.exe"
|
|
82
|
+
},
|
|
83
|
+
"zipExt": ".zip"
|
|
84
|
+
},
|
|
85
|
+
"x86_64-unknown-linux-gnu": {
|
|
86
|
+
"artifactName": "rustcodegraph-x86_64-unknown-linux-gnu.tar.xz",
|
|
87
|
+
"bins": {
|
|
88
|
+
"rustcodegraph": "rustcodegraph"
|
|
89
|
+
},
|
|
90
|
+
"zipExt": ".tar.xz"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"version": "1.1.0",
|
|
94
|
+
"volta": {
|
|
95
|
+
"node": "18.14.1",
|
|
96
|
+
"npm": "9.5.0"
|
|
31
97
|
}
|
|
32
|
-
}
|
|
98
|
+
}
|
package/README.zh-CN.md
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# RustCodeGraph
|
|
4
|
-
|
|
5
|
-
[English](README.md) · 简体中文
|
|
6
|
-
|
|
7
|
-
### 为 Claude Code、Cursor、Codex、opencode、Hermes Agent、Gemini、Antigravity 和 Kiro 提供本地语义代码智能
|
|
8
|
-
|
|
9
|
-
**100% 本地 · Rust 原生 · 面向 AI 编程代理的代码知识图谱**
|
|
10
|
-
|
|
11
|
-
RustCodeGraph 基于 [hunzhiwange/rustcodegraph](https://github.com/hunzhiwange/rustcodegraph) 的思路和使用经验,并用 Rust 重新实现。它保留了“让 AI 代理直接查询代码结构,而不是反复 grep/Read 探索文件”的核心目标,同时把解析、索引、CLI、MCP 服务和本地数据库运行时迁移为原生 Rust 实现。
|
|
12
|
-
|
|
13
|
-
[英文文档](docs/user/README.md)
|
|
14
|
-
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
## 这个项目是什么
|
|
18
|
-
|
|
19
|
-
RustCodeGraph 会在每个项目里建立一个本地 `.rustcodegraph/` 索引,用 tree-sitter 解析源码,把符号、调用关系、导入关系、框架路由和文件结构写入 SQLite。Claude Code、Cursor、Codex CLI、opencode 等 AI 编程代理可以通过 MCP 工具直接查询这个图谱。
|
|
20
|
-
|
|
21
|
-
换句话说,它让代理少做“到处找文件、反复搜索、再读取源码”的工作,更多地直接拿到结构化上下文:某个函数由谁调用、会调用谁、一次改动可能影响哪些文件,以及一条业务流程如何跨文件、跨框架甚至跨语言串起来。
|
|
22
|
-
|
|
23
|
-
> RustCodeGraph 是独立的 Rust 重写项目,不是旧 CodeGraph 包的就地升级。如果你之前安装过旧的 CodeGraph,需要单独安装并配置 `rustcodegraph`。
|
|
24
|
-
|
|
25
|
-
## 快速开始
|
|
26
|
-
|
|
27
|
-
### 1. 安装 CLI
|
|
28
|
-
|
|
29
|
-
不需要 Node.js。安装脚本会下载当前系统匹配的 Rust 二进制文件:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# macOS / Linux
|
|
33
|
-
curl -fsSL https://raw.githubusercontent.com/hunzhiwange/rustcodegraph/main/install.sh | sh
|
|
34
|
-
|
|
35
|
-
# Windows (PowerShell)
|
|
36
|
-
irm https://raw.githubusercontent.com/hunzhiwange/rustcodegraph/main/install.ps1 | iex
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
如果你已经有 Node.js,也可以使用 npm:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm i -g @hunzhiwange/rustcodegraph
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
安装完成后请打开一个新终端,让 `rustcodegraph` 出现在 PATH 中。
|
|
46
|
-
|
|
47
|
-
### 2. 连接你的 AI 代理
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
rustcodegraph install
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
安装器会自动检测并配置 Claude Code、Cursor、Codex CLI、opencode、Hermes Agent、Gemini CLI、Antigravity IDE 和 Kiro,把 RustCodeGraph MCP 服务写入它们的配置。
|
|
54
|
-
|
|
55
|
-
### 3. 初始化项目
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
cd your-project
|
|
59
|
-
rustcodegraph init -i
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
`rustcodegraph init -i` 会创建本地 `.rustcodegraph/` 目录,并立即构建完整代码图谱。之后 MCP 服务会自动监听文件变化并同步索引,一般不需要手动运行 `rustcodegraph sync`。
|
|
63
|
-
|
|
64
|
-
### 4. 卸载
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
rustcodegraph uninstall
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
这会移除 RustCodeGraph 写入各个代理的 MCP 配置和说明,但不会删除项目里的 `.rustcodegraph/` 索引。要移除某个项目的索引,请在项目目录运行:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
rustcodegraph uninit
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## 为什么需要 RustCodeGraph
|
|
77
|
-
|
|
78
|
-
AI 编程代理理解一个陌生代码库时,通常会用 grep、glob 和 Read 一步步探索文件。这个过程慢、工具调用多,而且容易在大型仓库里消耗大量上下文。
|
|
79
|
-
|
|
80
|
-
RustCodeGraph 提前把代码库索引成知识图谱,让代理直接查询:
|
|
81
|
-
|
|
82
|
-
- 某个符号的定义、源码和调用链
|
|
83
|
-
- 某个函数的调用者和被调用者
|
|
84
|
-
- 一次修改的影响半径
|
|
85
|
-
- Web 框架路由到处理函数的映射
|
|
86
|
-
- React / 回调 / 跨语言桥接等静态分析容易断开的流程
|
|
87
|
-
- 按文件和符号组织好的源码上下文
|
|
88
|
-
|
|
89
|
-
完整英文 README 中包含 7 个真实开源仓库的基准测试。当前结论是:启用 RustCodeGraph 后,代理通常用更少的工具调用、更少的 token 和更短的时间回答结构性问题。
|
|
90
|
-
|
|
91
|
-
## 核心功能
|
|
92
|
-
|
|
93
|
-
| 功能 | 说明 |
|
|
94
|
-
|---|---|
|
|
95
|
-
| 本地知识图谱 | 符号、文件、调用、导入、继承、路由等信息保存在项目本地 SQLite 中 |
|
|
96
|
-
| 语义探索 | `rustcodegraph_explore` 一次返回相关符号源码、关系图和影响范围 |
|
|
97
|
-
| 全文搜索 | 基于 SQLite FTS5 快速查找符号和代码 |
|
|
98
|
-
| 调用链分析 | 查询 callers、callees 和 impact radius |
|
|
99
|
-
| 自动同步 | 使用 FSEvents、inotify、ReadDirectoryChangesW 监听文件变化并增量更新 |
|
|
100
|
-
| 框架感知 | 识别 Django、Flask、FastAPI、Express、NestJS、Laravel、Rails、Spring、Gin、Axum、Vapor、React Router、SvelteKit、Vue/Nuxt、Astro 等路由 |
|
|
101
|
-
| 跨语言桥接 | 支持 Swift/Objective-C、React Native、Expo Modules、Fabric/Paper 视图等常见跨语言调用关系 |
|
|
102
|
-
| 隐私优先 | 代码不离开本机,不需要 API key,不依赖外部索引服务 |
|
|
103
|
-
|
|
104
|
-
## 支持的代理
|
|
105
|
-
|
|
106
|
-
`rustcodegraph install` 会自动检测并配置:
|
|
107
|
-
|
|
108
|
-
- Claude Code
|
|
109
|
-
- Cursor
|
|
110
|
-
- Codex CLI
|
|
111
|
-
- opencode
|
|
112
|
-
- Hermes Agent
|
|
113
|
-
- Gemini CLI
|
|
114
|
-
- Antigravity IDE
|
|
115
|
-
- Kiro
|
|
116
|
-
|
|
117
|
-
## 支持的语言
|
|
118
|
-
|
|
119
|
-
RustCodeGraph 支持 20 多种语言和文件类型,包括:
|
|
120
|
-
|
|
121
|
-
- TypeScript / JavaScript
|
|
122
|
-
- Python
|
|
123
|
-
- Go
|
|
124
|
-
- Rust
|
|
125
|
-
- Java
|
|
126
|
-
- C#
|
|
127
|
-
- PHP
|
|
128
|
-
- Ruby
|
|
129
|
-
- C / C++
|
|
130
|
-
- Objective-C
|
|
131
|
-
- Swift
|
|
132
|
-
- Kotlin
|
|
133
|
-
- Scala
|
|
134
|
-
- Dart
|
|
135
|
-
- Svelte
|
|
136
|
-
- Vue
|
|
137
|
-
- Astro
|
|
138
|
-
- Liquid
|
|
139
|
-
- Pascal / Delphi
|
|
140
|
-
- Lua / Luau
|
|
141
|
-
- R
|
|
142
|
-
|
|
143
|
-
语言支持会根据文件扩展名自动启用,不需要额外配置。
|
|
144
|
-
|
|
145
|
-
## 工作原理
|
|
146
|
-
|
|
147
|
-
```text
|
|
148
|
-
源码文件
|
|
149
|
-
-> tree-sitter 解析
|
|
150
|
-
-> 提取符号、调用、导入、继承和路由
|
|
151
|
-
-> 写入 .rustcodegraph/rustcodegraph.db
|
|
152
|
-
-> MCP 工具向 AI 代理提供结构化上下文
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
处理流程分为四层:
|
|
156
|
-
|
|
157
|
-
1. **提取**:tree-sitter 把源码解析成 AST,语言提取器从中抽取函数、类、方法、变量、导入等节点。
|
|
158
|
-
2. **存储**:所有节点、边和文件信息写入本地 SQLite,并启用 FTS5 全文搜索。
|
|
159
|
-
3. **解析**:导入、调用、继承和框架约定会被解析成跨文件关系。
|
|
160
|
-
4. **查询**:CLI 和 MCP 工具把图谱查询结果格式化为代理可直接使用的上下文。
|
|
161
|
-
|
|
162
|
-
## 常用 CLI
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
rustcodegraph install # 配置 AI 代理
|
|
166
|
-
rustcodegraph uninstall # 从代理配置中移除 RustCodeGraph
|
|
167
|
-
rustcodegraph init -i # 初始化并索引当前项目
|
|
168
|
-
rustcodegraph uninit # 删除当前项目的 RustCodeGraph 索引
|
|
169
|
-
rustcodegraph index # 全量重建索引
|
|
170
|
-
rustcodegraph sync # 增量同步
|
|
171
|
-
rustcodegraph status # 查看索引状态
|
|
172
|
-
rustcodegraph query UserService # 搜索符号
|
|
173
|
-
rustcodegraph explore "auth login" # 探索相关源码和调用路径
|
|
174
|
-
rustcodegraph node UserService # 查看单个符号或文件
|
|
175
|
-
rustcodegraph callers login # 查看调用者
|
|
176
|
-
rustcodegraph callees login # 查看被调用者
|
|
177
|
-
rustcodegraph impact login # 分析修改影响范围
|
|
178
|
-
rustcodegraph affected --stdin # 根据变更文件推导受影响测试
|
|
179
|
-
rustcodegraph upgrade # 原地升级
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## MCP 工具
|
|
183
|
-
|
|
184
|
-
作为 MCP 服务运行时,RustCodeGraph 默认暴露一组面向代理行为优化过的工具:
|
|
185
|
-
|
|
186
|
-
| 工具 | 用途 |
|
|
187
|
-
|---|---|
|
|
188
|
-
| `rustcodegraph_explore` | 首选工具。回答“X 如何工作”“X 如何到达 Y”这类结构性问题,返回相关源码、关系和影响范围 |
|
|
189
|
-
| `rustcodegraph_node` | 查看某个符号完整源码和调用轨迹,也可以像 Read 一样读取整个文件 |
|
|
190
|
-
| `rustcodegraph_search` | 按名称搜索符号 |
|
|
191
|
-
| `rustcodegraph_callers` | 找到某个函数或方法的所有调用点,包括回调注册位置 |
|
|
192
|
-
|
|
193
|
-
在没有 `.rustcodegraph/` 索引的工作区中,MCP 服务会报告自己未激活并隐藏工具;是否索引项目始终由用户决定。
|
|
194
|
-
|
|
195
|
-
## 配置和隐私
|
|
196
|
-
|
|
197
|
-
RustCodeGraph 默认零配置。它会自动跳过常见依赖、构建和缓存目录,例如 `node_modules`、`vendor`、`dist`、`build`、`target`、`.venv`、`Pods`、`.next` 等,也会尊重 `.gitignore`。
|
|
198
|
-
|
|
199
|
-
RustCodeGraph 会收集匿名使用统计,用来判断哪些语言和代理支持最值得改进。它不会上传代码、路径、文件名、符号名、查询内容或 IP 地址。你可以随时关闭:
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
rustcodegraph telemetry off
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
也可以设置环境变量:
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
RUSTCODEGRAPH_TELEMETRY=0
|
|
209
|
-
DO_NOT_TRACK=1
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
详细字段见 [TELEMETRY.md](TELEMETRY.md)。
|
|
213
|
-
|
|
214
|
-
## 故障排查
|
|
215
|
-
|
|
216
|
-
**提示 `RustCodeGraph not initialized`**
|
|
217
|
-
|
|
218
|
-
请先在项目目录运行:
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
rustcodegraph init -i
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
**索引很慢**
|
|
225
|
-
|
|
226
|
-
确认大型依赖或生成目录已经被 `.gitignore` 排除。RustCodeGraph 默认会跳过常见目录,但仓库中特殊的构建产物可能需要你自己加入 `.gitignore`。
|
|
227
|
-
|
|
228
|
-
**MCP server 连接不上**
|
|
229
|
-
|
|
230
|
-
代理会自己启动 MCP 服务,通常不需要手动运行 `serve --mcp`。请确认项目已经初始化并索引:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
rustcodegraph status
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
如果配置损坏,可以重新运行:
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
rustcodegraph install
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
**仍在使用旧 CodeGraph**
|
|
243
|
-
|
|
244
|
-
旧 CodeGraph 和 RustCodeGraph 是两个独立项目。请安装 `rustcodegraph`,并确认你的 MCP 配置指向 `rustcodegraph` 而不是旧的 `codegraph` 命令。
|
|
245
|
-
|
|
246
|
-
## 许可证
|
|
247
|
-
|
|
248
|
-
MIT
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
<div align="center">
|
|
253
|
-
|
|
254
|
-
**Made for AI coding agents — Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, and Kiro**
|
|
255
|
-
|
|
256
|
-
[Report Bug](https://github.com/hunzhiwange/rustcodegraph/issues) · [Request Feature](https://github.com/hunzhiwange/rustcodegraph/issues)
|
|
257
|
-
|
|
258
|
-
</div>
|