OpenClaw 接入指南
🦞 OpenClaw + CLI-Anything
Section titled “🦞 OpenClaw + CLI-Anything”OpenClaw 是一个开源 AI Agent 平台,自 2026-03-15 起通过社区贡献实现了对 CLI-Anything 的支持。OpenClaw 采用 SKILL 机制来封装外部工具,可以无缝集成 CLI-Anything 生成的 CLI。
📋 前提条件
Section titled “📋 前提条件”- OpenClaw 已安装并运行
- Python 3.10+
- 目标软件已安装
🚀 快速接入
Section titled “🚀 快速接入”方式一:使用 CLI-Hub Meta Skill(推荐)
Section titled “方式一:使用 CLI-Hub Meta Skill(推荐)”这是最简便的方式,使用 CLI-Hub 的元技能来实现自治发现:
# 一键安装 cli-hub-meta-skillnpx skills add HKUDS/CLI-Anything --skill cli-hub-meta-skill -g -y安装完成后,向 OpenClaw 发送提示:
Find appropriate CLI software in CLI-Hub and complete the task: "用 GIMP 把 image.jpg 裁剪成 800x600"OpenClaw 会自动:
- 在 CLI-Hub 中搜索合适的 CLI
- 发现 cli-anything-gimp
- 执行相应的操作
方式二:通过 Skill 安装
Section titled “方式二:通过 Skill 安装”OpenClaw 的 Skill 系统可以直接安装 CLI-Anything:
# 搜索可用技能openclaw skills search gimp
# 安装技能openclaw skills install gimp安装后,AI Agent 会自动获得操控 GIMP 的能力。
方式三:手动配置
Section titled “方式三:手动配置”- 安装 CLI-Hub:
pip install cli-anything-hub- 安装目标 CLI:
cli-hub install gimp- 在 OpenClaw 配置中添加工具路径:
tools: cli-anything: enabled: true path: /usr/local/bin/cli-anything-gimp💬 使用示例
Section titled “💬 使用示例”图片处理工作流
Section titled “图片处理工作流”用户:帮我把这张照片调成暖色调,加个边框,导出 PNG
OpenClaw Agent:→ 调用 cli-anything-gimp image open --path ./photo.jpg→ 调用 cli-anything-gimp filter apply --name "warm-tone" --intensity 0.7→ 调用 cli-anything-gimp image border --width 10 --color "#333333"→ 调用 cli-anything-gimp export file --path ./output.png --format PNG✅ 完成!已导出到 ./output.png跨软件自动化
Section titled “跨软件自动化”用户:从 Excel 读取数据,生成图表,插入到 Word 文档
OpenClaw Agent:→ 调用 cli-anything-libreoffice calc read --file ./data.xlsx --range A1:D20→ 调用 cli-anything-libreoffice calc chart --type bar --data A1:D20 --output ./chart.png→ 调用 cli-anything-libreoffice writer insert-image --file ./chart.png --position "Page 3"✅ Word 文档已更新!视频编辑工作流
Section titled “视频编辑工作流”用户:用 Shotcut 把 intro.mp4 和 demo.mp4 合并,加上淡入淡出效果
OpenClaw Agent:→ 调用 cli-anything-shotcut project new --name "merged-project"→ 调用 cli-anything-shotcut import file --input ./intro.mp4 --track video→ 调用 cli-anything-shotcut import file --input ./demo.mp4 --track video→ 调用 cli-anything-shotcut transition add --type "fade" --duration 1→ 调用 cli-anything-shotcut render output --format mp4 --codec h264✅ 视频已导出!🔒 跨平台兼容性
Section titled “🔒 跨平台兼容性”OpenClaw 版本实现了 Windows 兼容的路径处理:
# cygpath guard for cross-platform compatibilityimport subprocessimport sysimport os
def get_native_path(path): """Convert path for the current platform.""" if sys.platform == 'win32': # Use cygpath on Windows if available try: result = subprocess.run( ['cygpath', '-w', path], capture_output=True, text=True ) if result.returncode == 0: return result.stdout.strip() except FileNotFoundError: # Fallback to os.path for MSYS/MSYS2 pass return path这确保了生成的 CLI 在 Windows、macOS、Linux 上都能正常工作。
⚙️ 高级配置
Section titled “⚙️ 高级配置”自定义 Skill 封装
Section titled “自定义 Skill 封装”将 CLI-Anything 生成的 CLI 封装为 OpenClaw Skill:
# GIMP CLI Skill
## 使用场景当用户需要处理图片(裁剪、滤镜、格式转换等)时使用此 Skill。
## 可用命令- `cli-anything-gimp image new` — 创建新图像- `cli-anything-gimp filter apply` — 应用滤镜- `cli-anything-gimp export file` — 导出文件- `cli-anything-gimp layer add` — 添加图层
## 示例用户说"把这张图裁剪成 800x600":→ 运行 cli-anything-gimp image crop --width 800 --height 600 --input <图片路径>利用 OpenClaw 的 Cron 功能实现定时自动化:
# 每天凌晨 2 点自动备份 LibreOffice 文档cron: - schedule: "0 2 * * *" task: "用 LibreOffice CLI 将 /docs 目录下所有 .odt 转为 PDF 并备份到 /backup"🐛 常见问题
Section titled “🐛 常见问题”Q: OpenClaw 找不到 CLI 命令
Section titled “Q: OpenClaw 找不到 CLI 命令”解决:
# 确认 CLI 在 PATH 中which cli-anything-gimp
# 如果不在,创建软链接sudo ln -s /path/to/cli-anything-gimp /usr/local/bin/Q: Skill 安装失败
Section titled “Q: Skill 安装失败”解决:
# 更新 OpenClaw Skill 索引openclaw skills update
# 清除缓存重试openclaw skills install gimp --forceQ: Windows 路径问题
Section titled “Q: Windows 路径问题”解决:确保安装 Git for Windows,它自带 cygpath 工具。如果没有,可以在 OpenClaw 配置中禁用 cygpath:
cli-anything: use_cygpath: false