Skip to content

OpenCode 接入指南

OpenCode 是一款新兴的 AI 编程助手,支持通过插件机制扩展功能。CLI-Anything 可以集成到 OpenCode 中,让 AI 能够操控各种桌面软件。


  • OpenCode 已安装并运行
  • Python 3.10+
  • Git(用于克隆插件仓库)
  • 目标软件已安装

OpenCode 支持从插件市场安装:

Terminal window
# 在 OpenCode 中安装
/plugin market install cli-anything
Terminal window
# 克隆插件仓库
git clone https://github.com/HKUDS/CLI-Anything.git ~/.opencode/plugins/cli-anything
# 进入目录
cd ~/.opencode/plugins/cli-anything
# 运行安装脚本
./install.sh

插件安装后,使用以下命令生成 CLI:

/cli-anything gimp

OpenCode 会:

  1. 分析目标软件
  2. 设计 CLI 命令架构
  3. 生成可用的 CLI
/cli-anything /path/to/software
/cli-anything list

User: 用 GIMP 把 logo.png 的背景改为透明
OpenCode:
→ cli-anything-gimp image alpha set --input ./logo.png --operation remove-background
✅ 透明背景已设置
User: 把 report.docx 转为 PDF
OpenCode:
→ cli-anything-libreoffice convert --input ./report.docx --output ./report.pdf --format pdf
✅ 转换完成
User: 批量把 screenshots/ 目录的图片加上水印
OpenCode:
→ for f in screenshots/*.{png,jpg}; do
cli-anything-gimp watermark add --input "$f" --watermark ./logo.png --position southeast
done
✅ 处理完成 (12 个文件)

~/.opencode/config.json
{
"cli-anything": {
"cli_dir": "~/.opencode/clis"
}
}

对于批量操作,可以设置并发数:

{
"cli-anything": {
"batch_concurrency": 4
}
}

解决

Terminal window
# 重启 OpenCode
/opencode restart
# 或者重新加载插件
/plugin reload

解决

Terminal window
chmod +x ~/.opencode/plugins/cli-anything/install.sh