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 避免命令行暴露
相关推荐
IT_陈寒1 天前
Redis内存爆了,原来我漏掉了这个致命配置
前端·人工智能·后端
用户3521802454751 天前
🎆从 Prompt 到 Skill:让 Spring AI Agent 学会"装新技能"
人工智能·spring boot·ai编程
米小虾1 天前
手把手教你搭建第一个生产级AI Agent:从选型到实战的完整指南
人工智能·agent
任沫1 天前
Agent之Function Call
javascript·人工智能·go
米小虾1 天前
2026年AI Agent全面爆发:从开源生态到企业级应用的进化之路
人工智能·agent
用户6919026813391 天前
Vibe Coding 开发项目的基本范式
人工智能·设计模式·代码规范
To_OC1 天前
别再跟 AI 死磕 prompt 了,我写了个 Loop 让它自己改到满意为止
人工智能·aigc·agent
血小溅1 天前
三大 AI 编码框架深度对比:GSD vs OpenSpec vs Superpowers
人工智能·后端
AlfredZhao1 天前
AI 编程工作总结:从体验问题到模块能力建设
ai·codex
武子康1 天前
调查研究-186 LangChain 和 LangGraph 的区别:从快速构建 Agent 到生产级工作流编排
人工智能·langchain·llm