OpenCode 接入指南
🔷 OpenCode + CLI-Anything
Section titled “🔷 OpenCode + CLI-Anything”OpenCode 是一款新兴的 AI 编程助手,支持通过插件机制扩展功能。CLI-Anything 可以集成到 OpenCode 中,让 AI 能够操控各种桌面软件。
📋 前提条件
Section titled “📋 前提条件”- OpenCode 已安装并运行
- Python 3.10+
- Git(用于克隆插件仓库)
- 目标软件已安装
🚀 安装步骤
Section titled “🚀 安装步骤”方式一:插件市场(推荐)
Section titled “方式一:插件市场(推荐)”OpenCode 支持从插件市场安装:
# 在 OpenCode 中安装/plugin market install cli-anything方式二:手动安装
Section titled “方式二:手动安装”# 克隆插件仓库git clone https://github.com/HKUDS/CLI-Anything.git ~/.opencode/plugins/cli-anything
# 进入目录cd ~/.opencode/plugins/cli-anything
# 运行安装脚本./install.sh💬 使用方法
Section titled “💬 使用方法”生成 CLI
Section titled “生成 CLI”插件安装后,使用以下命令生成 CLI:
/cli-anything gimpOpenCode 会:
- 分析目标软件
- 设计 CLI 命令架构
- 生成可用的 CLI
指定路径生成
Section titled “指定路径生成”/cli-anything /path/to/software列出已安装的 CLI
Section titled “列出已安装的 CLI”/cli-anything list📝 使用示例
Section titled “📝 使用示例”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✅ 转换完成自动化工作流
Section titled “自动化工作流”User: 批量把 screenshots/ 目录的图片加上水印
OpenCode:→ for f in screenshots/*.{png,jpg}; do cli-anything-gimp watermark add --input "$f" --watermark ./logo.png --position southeast done✅ 处理完成 (12 个文件)⚙️ 配置优化
Section titled “⚙️ 配置优化”设置默认 CLI 存储路径
Section titled “设置默认 CLI 存储路径”{ "cli-anything": { "cli_dir": "~/.opencode/clis" }}对于批量操作,可以设置并发数:
{ "cli-anything": { "batch_concurrency": 4 }}🐛 常见问题
Section titled “🐛 常见问题”Q: 插件安装后不生效
Section titled “Q: 插件安装后不生效”解决:
# 重启 OpenCode/opencode restart
# 或者重新加载插件/plugin reloadQ: 权限被拒绝
Section titled “Q: 权限被拒绝”解决:
chmod +x ~/.opencode/plugins/cli-anything/install.sh