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 避免命令行暴露
相关推荐
半兽先生1 分钟前
03阶段:机器学习
人工智能·机器学习
.柒宇.1 分钟前
LLM大模型认识
人工智能·深度学习·神经网络·阿里云·ai
泉城嵌入式2 分钟前
AI工程概念解析:从提示词工程到驾驭工程
人工智能
ModelWhale2 分钟前
和鲸科技CEO范向伟亮相“AI极客夜话”:畅谈智能体时代的人才培养与创业路径
人工智能·科技
这张生成的图像能检测吗2 分钟前
(论文速读)ControlNet-XS: 从反馈控制系统视角重新思考图像生成的控制机制
人工智能·计算机视觉·controlnet·扩散模型·条件控制扩散模型
拾薪3 分钟前
Brainstorming 深度分析 - 实现机制
ai·superpower·brainstorming
Ztop4 分钟前
一文说清ChatGPT Pro 5x 和 20x 区别,以及国内如何升级ChatGPT Pro 最新教程
人工智能·gpt·chatgpt
AI品信智慧数智人6 分钟前
AI赋能景区|山东品信智慧科技,解锁文旅数字化新范式✨
人工智能·科技·旅游
码云数智-大飞7 分钟前
CSS 优先级详解:告别样式冲突,掌控网页“层叠”艺术
人工智能·python·tensorflow
墨染天姬10 分钟前
【AI】稀疏注意力机制
人工智能