Codegraph下载安装和使用教程
·
一、下载安装
命令行安装
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
# Windows (PowerShell)
irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex
如果有node,node安装命令
npx @colbymchenry/codegraph # zero-install, or:
npm i -g @colbymchenry/codegraph
我是MacOS下用curl命令安装的,安装后出现如下情况,配置一下环境变量即可
(base) MacBook-Pro-140:codegraph XXXXX$ curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
Installing CodeGraph v0.9.8 (darwin-x64)...
Installed to /Users/XXXXX/.codegraph/versions/v0.9.8
Linked /Users/XXXXX/.local/bin/codegraph
/Users/xueyunzhen/.local/bin is not on your PATH. Add it:
export PATH="/Users/XXXXX/.local/bin:$PATH"
Done. Run: codegraph --help
配置环境变量,打开文件夹vi ~/.bash_profile,在文件最下面添加下面的环境变量,保存后source ~/.bash_profile执行。然后再运行codegraph --help测试是否安装成功
export PATH="/Users/XXXXX/.local/bin:$PATH
安装成功
(base) MacBook-Pro-140:.codegraph xxxxx$ codegraph --help
Usage: codegraph [options] [command]
Code intelligence and knowledge graph for any codebase
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
init [options] [path] Initialize CodeGraph in a project directory and
build the initial index
uninit [options] [path] Remove CodeGraph from a project (deletes
.codegraph/ directory)
index [options] [path] Index all files in the project
sync [options] [path] Sync changes since last index
status [options] [path] Show index status and statistics
query [options] <search> Search for symbols in the codebase
files [options] Show project file structure from the index
context [options] <task> Build context for a task (outputs markdown)
serve [options] Start CodeGraph as an MCP server for AI
assistants
unlock [path] Remove a stale lock file that is blocking
indexing
callers [options] <symbol> Find all functions/methods that call a specific
symbol
callees [options] <symbol> Find all functions/methods that a specific
symbol calls
impact [options] <symbol> Analyze what code is affected by changing a
symbol
affected [options] [files...] Find test files affected by changed source
files
install [options] Install codegraph MCP server into one or more
agents (Claude Code, Cursor, Codex CLI,
opencode, Hermes Agent)
uninstall [options] Remove codegraph from your agents (Claude Code,
Cursor, Codex CLI, opencode, Hermes Agent)
help [command] display help for command
二、使用
cd到你要解析的项目目录下,运行codegraph init -i,会生成一个隐藏文件.codegraph。这里一定要注意这是个隐藏文件,你要用命令查看用ls -all,别直接ls肯定看不到。- 打开codex,在使用过程中直接可以说
基于codegraph生成的.codegraph文件来XXXXXX,这样智能体会先解读codegraph生成的文件。
更多推荐

所有评论(0)