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 避免命令行暴露
相关推荐
code2cat11 分钟前
【随笔】打印第11页突然变慢,ReLU怎样让预测拐个弯?
人工智能·深度学习·机器学习
段一凡-华北理工大学23 分钟前
工业智能体实战:从概念到落地~系列文章05:工业Agent的核心驱动范式
人工智能·工业智能体·高炉炼铁智能化·agent驱动范式·react 范式·plan-execute 范式
翰墨之道1 小时前
AI加密预警与游戏创作平民化:模型安全边界再受关注
人工智能·安全·游戏
天远API2 小时前
零信任架构实战:基于天远单人婚姻查询构建自动化保障房准入审核网关
运维·人工智能·架构·自动化
CDA数据分析师干货分享2 小时前
AI会取代会计吗?未来哪些财务岗位更容易受到AI冲击?
大数据·人工智能·财务·cda证书·cda数据分析
沐飞工具箱2 小时前
从 SEO 到 GEO:AI 搜索如何理解网页内容?一次完整的可见性测试实践
大数据·人工智能·新媒体运营·内容运营
骑着蜗牛撵大象3272 小时前
AI Agent 工程化开发实战(十四):拆开 Deep Agents 看家底——计划、子代理与文件系统内置了什么
人工智能·架构·langgraph·mcp·deepagents·子代理
lingyubb2 小时前
适合短视频配音 操作简单的AI配音软件推荐怎么落地?从文案到成片的四步实操拆解
人工智能·音视频·状态模式
上弦外贸新观察3 小时前
ChatGPT广告服务商哪家好?分享OpenAI广告业务服务评估思路,从平台政策核实、账户支持、广告策略到运营流程逐项了解
人工智能·chatgpt
镜象科技3 小时前
大学AI心理健康解决方案服务商的危机联动设计:从宿舍楼到精神科的多方接力
人工智能