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 避免命令行暴露
相关推荐
LightYoungLee1 小时前
大模型(七)Agent AI学习笔记
人工智能·笔记·学习
smilejingwei1 小时前
从同质化市场搅局的开源BI 到AI时代全链智胜的ChatBI
人工智能·bi·chatbi
avi91111 小时前
【AI相关】-Gradio和 Streamlit,怎么选, Streamlit 篇
人工智能·aigc·gradio·streamlit
Coovally AI模型快速验证1 小时前
2.5GB 塞进浏览器:Mistral 开源实时语音识别,延迟不到半秒
人工智能·5g·计算机视觉·开源·语音识别
AI营销资讯站1 小时前
AI营销内容增长瓶颈?原圈科技以AI Agents破局之道
大数据·人工智能
2501_945837431 小时前
OpenClaw 核心:开源 AI 执行网关的技术内核
人工智能·开源
代码哈士奇2 小时前
AI时代,思考探索一种新的交互方式
人工智能
i建模2 小时前
开源AI memory项目一览表
人工智能·开源
进击monkey2 小时前
2026 企业知识库首选:PandaWiki AGPL-3.0 开源,无绑定+合规+降本三不误
人工智能·开源·ai知识库