# CLI-Anything 安装指南
## 什么是 CLI-Anything
CLI-Anything 是一个由香港大学数据科学实验室(HKUDS)开发的开源项目,旨在通过命令行接口让任何软件都能被 AI 代理使用。它的核心理念是 “Making ALL Software Agent-Native”(让所有软件都支持智能体)。
## 主要功能
– **通用访问**:通过结构化 CLI 使任何软件立即可被代理控制
– **无缝集成**:代理无需 API、GUI、重建或复杂包装即可控制任何应用
– **未来就绪生态系统**:通过一个命令将人类设计的软件转变为代理原生工具
– **自动化 7 阶段流程**:从代码分析到 PyPI 发布,完全自动化
– **真实软件集成**:直接调用实际应用程序进行渲染
– **智能会话管理**:具有撤销/重做功能的持久项目状态
– **零配置安装**:简单的 pip 安装即可将命令添加到 PATH
– **生产级测试**:多层验证,包括单元测试和端到端测试
– **干净的包架构**:所有 CLI 都组织在 cli_anything.* 命名空间下
## 支持的软件
CLI-Anything 已经为以下 11 个软件生成了完整的 CLI 接口:
| 软件 | 领域 | CLI 命令 | 后端 | 测试数 |
|——|——|———|——|——–|
| GIMP | 图像编辑 | `cli-anything-gimp` | Pillow + GEGL/Script-Fu | ✅ 107 |
| Blender | 3D 建模与渲染 | `cli-anything-blender` | bpy (Python 脚本) | ✅ 208 |
| Inkscape | 矢量图形 | `cli-anything-inkscape` | 直接 SVG/XML 操作 | ✅ 202 |
| Audacity | 音频制作 | `cli-anything-audacity` | Python wave + sox | ✅ 161 |
| LibreOffice | 办公套件 | `cli-anything-libreoffice` | ODF 生成 + 无头 LO | ✅ 158 |
| OBS Studio | 直播与录制 | `cli-anything-obs-studio` | JSON 场景 + obs-websocket | ✅ 153 |
| Kdenlive | 视频编辑 | `cli-anything-kdenlive` | MLT XML + melt 渲染器 | ✅ 155 |
| Shotcut | 视频编辑 | `cli-anything-shotcut` | 直接 MLT XML + melt | ✅ 154 |
| Zoom | 视频会议 | `cli-anything-zoom` | Zoom REST API (OAuth2) | ✅ 22 |
| Draw.io | 图表绘制 | `cli-anything-drawio` | mxGraph XML + draw.io CLI | ✅ 138 |
| AnyGen | AI 内容生成 | `cli-anything-anygen` | AnyGen REST API (anygen.io) | ✅ 50 |
## 系统要求
– **Python 3.10+**
– 目标软件已安装(如 GIMP、Blender、LibreOffice 等)
– 支持的 AI 编码代理:Claude Code、OpenCode、Codex 等
## 安装方法
### 方法一:通过 Claude Code 插件市场安装(推荐)
1. **添加 Marketplace**
“`bash
/plugin marketplace add HKUDS/CLI-Anything
“`
2. **安装插件**
“`bash
/plugin install cli-anything
“`
3. **构建 CLI**
“`bash
# 为 GIMP 生成完整 CLI
/cli-anything ./gimp
# 从 GitHub 仓库构建
/cli-anything https://github.com/blender/blender
“`
### 方法二:手动安装插件
1. **克隆仓库**
“`bash
git clone https://github.com/HKUDS/CLI-Anything.git
“`
2. **复制插件到 Claude Code 插件目录**
“`bash
cp -r CLI-Anything/cli-anything-plugin ~/.claude/plugins/cli-anything
“`
3. **重新加载插件**
“`bash
/reload-plugins
“`
### 方法三:使用 OpenCode(实验性)
1. **安装命令**
“`bash
# 克隆仓库
git clone https://github.com/HKUDS/CLI-Anything.git
# 全局安装
cp CLI-Anything/opencode-commands/*.md ~/.config/opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md ~/.config/opencode/commands/
# 或项目级安装
cp CLI-Anything/opencode-commands/*.md .opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md .opencode/commands/
“`
2. **构建 CLI**
“`bash
# 为 GIMP 生成完整 CLI
/cli-anything ./gimp
“`
### 方法四:使用 Codex(实验性)
1. **安装技能**
“`bash
# 克隆仓库
git clone https://github.com/HKUDS/CLI-Anything.git
# 安装技能
bash CLI-Anything/codex-skill/scripts/install.sh
“`
2. **从 Codex 使用**
“`text
Use CLI-Anything to build a harness for ./gimp
Use CLI-Anything to refine ./shotcut for picture-in-picture workflows
Use CLI-Anything to validate ./libreoffice
“`
## 使用生成的 CLI
无论使用哪个平台构建,生成的 CLI 都以相同的方式工作:
1. **安装到 PATH**
“`bash
cd gimp/agent-harness && pip install -e .
“`
2. **从任何地方使用**
“`bash
cli-anything-gimp –help
cli-anything-gimp project new –width 1920 –height 1080 -o poster.json
cli-anything-gimp –json layer add -n “Background” –type solid –color “#1a1a2e”
“`
3. **进入交互式 REPL**
“`bash
cli-anything-gimp
“`
## 示例:使用生成的 LibreOffice CLI
“`bash
# 创建新的 Writer 文档
$ cli-anything-libreoffice document new -o report.json –type writer
✓ Created Writer document: report.json
# 添加内容
$ cli-anything-libreoffice –project report.json writer add-heading -t “Q1 Report” –level 1
✓ Added heading: “Q1 Report”
$ cli-anything-libreoffice –project report.json writer add-table –rows 4 –cols 3
✓ Added 4×3 table
# 通过 LibreOffice 无头模式导出为真实 PDF
$ cli-anything-libreoffice –project report.json export render output.pdf -p pdf –overwrite
✓ Exported: output.pdf (42,831 bytes) via libreoffice-headless
# 为代理消费使用 JSON 模式
$ cli-anything-libreoffice –json document info –project report.json
{
“name”: “Q1 Report”,
“type”: “writer”,
“pages”: 1,
“elements”: 2,
“modified”: true
}
“`
## 运行测试
“`bash
# 为特定 CLI 运行测试
cd
python3 -m pytest cli_anything/
# 强制安装模式(推荐用于验证)
CLI_ANYTHING_FORCE_INSTALLED=1 python3 -m pytest cli_anything/
“`
## 插件命令
| 命令 | 描述 |
|——|——|
| `/cli-anything
| `/cli-anything:refine
| `/cli-anything:test
| `/cli-anything:validate
## 注意事项
1. **需要强大的基础模型**:CLI-Anything 依赖于前沿模型(如 Claude Opus 4.6、Claude Sonnet 4.6、GPT-5.4)来可靠地生成工具包。较弱或较小的模型可能会产生不完整或不正确的 CLI。
2. **依赖可用的源代码**:7 阶段流程从源代码分析和生成。当目标软件只提供需要反编译的编译二进制文件时,工具包质量和覆盖范围会大幅下降。
3. **可能需要迭代改进**:单次 `/cli-anything` 运行可能无法完全覆盖所有功能。通常需要运行 `/refine` 一次或多次,以将 CLI 的性能和覆盖范围提升到生产质量。
## 项目结构
“`
cli-anything/
├── 📄 README.md # 项目文档
├── 📁 assets/ # 图像和媒体
├── 🔌 cli-anything-plugin/ # Claude Code 插件
├── 🤖 codex-skill/ # Codex 技能入口点
├── 🎨 gimp/agent-harness/ # GIMP CLI (107 测试)
├── 🧊 blender/agent-harness/ # Blender CLI (208 测试)
├── ✏️ inkscape/agent-harness/ # Inkscape CLI (202 测试)
├── 🎵 audacity/agent-harness/ # Audacity CLI (161 测试)
├── 📄 libreoffice/agent-harness/ # LibreOffice CLI (158 测试)
├── 📹 obs-studio/agent-harness/ # OBS Studio CLI (153 测试)
├── 🎞️ kdenlive/agent-harness/ # Kdenlive CLI (155 测试)
├── 🎬 shotcut/agent-harness/ # Shotcut CLI (154 测试)
├── 📞 zoom/agent-harness/ # Zoom CLI (22 测试)
├── 📐 drawio/agent-harness/ # Draw.io CLI (138 测试)
└── ✨ anygen/agent-harness/ # AnyGen CLI (50 测试)
“`
## 结论
CLI-Anything 是一个强大的工具,它通过命令行接口桥接了 AI 代理和世界软件之间的 gap。通过一个简单的命令,它可以将任何具有代码库的软件转变为代理原生工具,使 AI 能够使用专业软件的全部功能。
无论是用于创意工作流(如 GIMP、Blender)还是日常任务(如 LibreOffice、OBS Studio),CLI-Anything 都能为 AI 代理提供结构化、可靠的接口,从而实现更复杂的自动化工作流。