AI(四): 工具 (GitNexus、CLI-Anything)

GitNexus

GitNexus 是一款能够将代码库转化为可查询知识图谱的智能工具。它的核心能力可以概括为三点:

  1. 解析 ------ 基于 Tree-sitter 深度解析代码,提取函数、类、变量之间的调用与依赖关系

  2. 建图 ------ 将代码结构存入 KuzuDB 图数据库,构建完整的代码知识图谱

  3. 适配 ------ 通过 MCP 协议与 Claude 等 AI 智能体无缝对接,提供结构化代码上下文

github:

https://github.com/abhigyanpatwari/GitNexus

install:

npm install -g gitnexus

analyze:

npx gitnexus analyze

config mcp:

npx gitnexus setup

or

claude mcp add gitnexus -- npx -y gitnexus@latest mcp

gitnexus serve Web UI

➜ ~ npx gitnexus serve

MCP HTTP endpoints mounted at /api/mcp

GitNexus server running on http://127.0.0.1:4747

为 GitNexus Web UI 提供索引数据接口

local Web UI Service

npm install

npm run dev

GitNexus Web UI 服务

Or

https://gitnexus.vercel.app/

bash 复制代码
➜  baili-web git:(feature/20260323_dataMasking) 
export http_proxy="http://127.0.0.1:7897"
export https_proxy="http://127.0.0.1:7897"
export all_proxy="socks5://127.0.0.1:7897"
➜  baili-web git:(feature/20260323_dataMasking) npm install -g gitnexus
npm warn deprecated boolean@3.2.0: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated glob@11.1.0: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me

added 292 packages in 10s

73 packages are looking for funding
  run `npm fund` for details
➜  baili-web git:(feature/20260323_dataMasking) npx gitnexus analyze

  GitNexus Analyzer

  Skipped 1 large files (>512KB, likely generated/vendored)
  ████████████████████████████████████████ 100% | Done

  Repository indexed successfully (38.6s)

  76,242 nodes | 201,151 edges | 1220 clusters | 300 flows
  LadybugDB 10.3s | FTS 9.7s | Embeddings off (use --embeddings to enable)
  /Users/edy/Workspace/gf/baili-web
  Context: AGENTS.md (created), CLAUDE.md (appended), .claude/skills/gitnexus/ (6 skills)

➜  baili-web git:(feature/20260323_dataMasking) ✗ git status
On branch feature/20260323_dataMasking
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .gitignore

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	AGENTS.md

no changes added to commit (use "git add" and/or "git commit -a")
➜  baili-web git:(feature/20260323_dataMasking) ✗ vim .gitignore
➜  baili-web git:(feature/20260323_dataMasking) ✗ vim .gitignore
➜  baili-web git:(feature/20260323_dataMasking) ✗
➜  baili-web git:(feature/20260323_dataMasking) ✗
➜  baili-web git:(feature/20260323_dataMasking) ✗ git diff
➜  baili-web git:(feature/20260323_dataMasking) ✗
➜  baili-web git:(feature/20260323_dataMasking) ✗ ls ~/.gitnexus
registry.json
➜  baili-web git:(feature/20260323_dataMasking) ✗ cat ~/.gitnexus/registry.json
[
  {
    "name": "baili-web",
    "path": "/Users/edy/Workspace/gf/baili-web",
    "storagePath": "/Users/edy/Workspace/gf/baili-web/.gitnexus",
    "indexedAt": "2026-03-23T05:45:14.974Z",
    "lastCommit": "xxxxxxxxx",
    "stats": {
      "files": 4563,
      "nodes": 76242,
      "edges": 201151,
      "communities": 1220,
      "processes": 300,
      "embeddings": 0
    }
  }
]%
➜  baili-web git:(feature/20260323_dataMasking) ✗ npx gitnexus setup

  GitNexus Setup
  ==============


  Claude Code detected. Run this command to add GitNexus MCP:

    claude mcp add gitnexus -- npx -y gitnexus mcp

  Configured:
    + Cursor
    + Claude Code (MCP manual step printed)
    + Claude Code skills (7 skills → ~/.claude/skills/)
    + Claude Code hooks (PreToolUse, PostToolUse)
    + Cursor skills (7 skills → ~/.cursor/skills/)

  Skipped:
    - OpenCode (not installed)

  Summary:
    MCP configured for: Cursor, Claude Code (MCP manual step printed), Claude Code hooks (PreToolUse, PostToolUse)
    Skills installed to: Claude Code skills (7 skills → ~/.claude/skills/), Cursor skills (7 skills → ~/.cursor/skills/)

  Next steps:
    1. cd into any git repo
    2. Run: gitnexus analyze
    3. Open the repo in your editor --- MCP is ready!

➜  baili-web git:(feature/20260323_dataMasking) ✗ claude mcp add gitnexus -- npx -y gitnexus mcp
Added stdio MCP server gitnexus with command: npx -y gitnexus mcp to local config
File modified: /Users/edy/.claude.json [project: /Users/edy/Workspace/gf/baili-web]
➜  baili-web git:(feature/20260323_dataMasking) ✗

CLI-Anything

https://github.com/HKUDS/CLI-Anything

步骤 1:安装 CLI-Anything Skill

克隆 CLI-Anything 仓库

git clone https://github.com/HKUDS/CLI-Anything.git

安装 Skill 到 OpenClaw 全局目录

mkdir -p ~/.openclaw/skills/cli-anything

cp CLI-Anything/openclaw-skill/SKILL.md ~/.openclaw/skills/cli-anything/SKILL.md

验证安装: 重启 OpenClaw 或在该会话中:

@cli-anything 检查是否可用

步骤 2:准备项目认证模块

在生成 CLI 之前,需要先创建一个认证模块来处理 Token 管理。

步骤 3:在 OpenClaw 中调用 CLI-Anything

@cli-anything 为 ./your-backend-project 构建一个 CLI,要求:

  1. 包含登录认证命令(用户名密码获取 Token)
  2. 所有 API 调用需要携带 Token
  3. 支持 Token 自动刷新
  4. 输出 JSON 格式供 Agent 使用

步骤 4:生成的 CLI 结构示例

CLI-Anything 会生成类似以下结构:

your-backend-project/

└── agent-harness/

├── setup.py

└── cli_anything/

└── your_backend/

├── init .py

├── cli.py # 主 CLI 入口

├── core.py # 核心业务逻辑

├── auth.py # 认证模块(步骤 2 创建的)

├── utils/

│ └── repl_skin.py # REPL 界面

└── tests/

└── test_core.py

步骤 5:生成的 CLI 命令示例

生成的 CLI 会包含以下命令:

1. 登录获取 Token

cli-anything-your-backend auth login

--username "your-username"

--password "your-password"

-o login-result.json

2. 使用 Token 调用 API(自动从登录结果读取)

cli-anything-your-backend

--project login-result.json

api list-users

--json

3. 直接带 Token 调用(不提供 --project 时)

cli-anything-your-backend

--token "your-existing-token"

api get-user --id 123

--json

4. 检查 Token 状态

cli-anything-your-backend auth check-token --project login-result.json

5. 刷新 Token

cli-anything-your-backend auth refresh --project login-result.json

步骤 6:完整的 CLI 实现模板

如果需要手动创建或参考,以下是完整的 CLI 模板:

步骤 7:在 OpenClaw 中使用

安装生成的 CLI

cd your-backend-project/agent-harness

pip install -e .

验证安装

cli-anything-your-backend --help

1. 首次登录

cli-anything-your-backend auth login

--username "admin"

--password "secret123"

--base-url "https://api.yourcompany.com"

-o ~/.cli-your-backend-state.json

2. 后续使用(自动读取 Token)

cli-anything-your-backend

--project ~/.cli-your-backend-state.json

api list-users

--json

3. 或者用环境变量

export CLI_TOKEN=$(cat ~/.cli-your-backend-state.json | jq -r .token)

cli-anything-your-backend api list-users --json

步骤 8:OpenClaw Skill 配置(可选)

在 ~/.openclaw/skills/cli-anything/SKILL.md 中添加认证说明:

认证流程

  1. 使用 auth login 命令登录获取 Token
  2. Token 保存在项目状态文件(JSON)中
  3. 后续命令通过 --project 指定状态文件自动使用 Token
  4. 或手动指定 --token 参数

安全提示

  • 不要将包含 Token 的状态文件提交到版本控制
  • 定期刷新 Token
  • 使用环境变量 CLI_TOKEN 避免命令行暴露
相关推荐
lizhihai_997 分钟前
股市学习心得—半导体12种核心材料
大数据·人工智能·学习
STLearner8 分钟前
SIGIR 2026 | LLM × Graph论文总结(图增强LLM,GraphRAG,Agent,多模态,知识图谱,搜索,推
人工智能·python·深度学习·神经网络·机器学习·数据挖掘·知识图谱
研究点啥好呢11 分钟前
快手产品经理面试题精选:10道高频考题+答案解析
人工智能·面试·产品经理
流年似水~18 分钟前
脚本策划:拍之前先想清楚要剪什么
人工智能·程序人生·语言模型·ai编程
郑寿昌22 分钟前
思维链三步法:让AI像人类一样推理
人工智能
圣殿骑士-Khtangc25 分钟前
AI Agent架构演进与三层安全防御体系深度解析
人工智能
ZGi.ai28 分钟前
智能客服系统设计:从工单分类到自动派单的工程实现
大数据·人工智能·分类
老陈说编程28 分钟前
12. LangChain 6大核心调用方法:invoke/stream/batch同步异步全解析,新手也能轻松学会
开发语言·人工智能·python·深度学习·机器学习·ai·langchain
给自己做减法33 分钟前
rag混合检索
人工智能·python·rag
天诚智能门锁39 分钟前
天诚公租房管控平台CAT.1人脸猫眼智能锁助力青神县公租房管理
人工智能·嵌入式硬件·物联网·智能家居·智能硬件