OpenCode plugin + CLI tool for launching AI agents in tmux with diff viewing
npm install opencode-diff-viewer

一个 CLI 工具,用于在 tmux 中启动各种 AI Agent 工具,并提供 OpenCode diff 查看插件。
view_diff 工具``bashnpm
npm install -g opencode-diff-viewer
CLI 使用方法
$3
`bash
启动 OpenCode
diffviewer opencode启动 Claude CLI
diffviewer claude启动 Codex CLI
diffviewer codex查看 git diff
diffviewer diff
`$3
`bash
列出所有工具
diffviewer list查看运行中的会话
diffviewer status附加到会话
diffviewer attach opencode终止会话
diffviewer kill opencode
`$3
`bash
diffviewer --help
`OpenCode 插件配置
$3
创建或编辑
~/.config/opencode/opencode.json:`bash
mkdir -p ~/.config/opencode
cat > ~/.config/opencode/opencode.json << 'EOF'
{
"command": {
"diff": {
"template": "View git diff using lumen in tmux.",
"description": "View diff of modified files using lumen TUI"
}
},
"plugin": ["opencode-diff-viewer"]
}
EOF
`$3
`bash
使用 CLI 启动
diffviewer opencode或使用启动脚本
opencode-diff-viewer
./start-opencode.sh
`$3
在 OpenCode TUI 中输入:
`bash
/diff # 查看所有修改文件的 diff
/diff src/app.ts # 查看指定文件的 diff
`tmux 快捷键
| 快捷键 | 功能 |
|--------|------|
|
Ctrl+B 然后 D | 分离会话 |
| Ctrl+B 然后 ? | 查看帮助 |
| Ctrl+C | 终止会话 |lumen 快捷键
| 快捷键 | 功能 |
|--------|------|
|
j / k 或 ↑ / ↓ | 上/下移动 |
| { / } | 跳转到上/下一个变更块 |
| Tab | 切换侧边栏 |
| e | 在编辑器中打开文件 |
| q | 退出 |自定义工具配置
创建
~/.config/diffviewer/config.json 添加自定义工具:`json
{
"tools": {
"custom": {
"name": "Custom Tool",
"command": "custom-command",
"description": "My custom tool",
"install": "npm install -g custom-tool"
}
}
}
`前置条件
$3
CLI 会自动安装 tmux。如果失败,手动安装:
`bash
brew install tmux
or
apt install tmux
`$3
插件会自动安装 lumen。如果失败,手动安装:
`bash
brew install jnsahaj/lumen/lumen
or
cargo install lumen
`项目结构
`
opencode-diff-viewer/
├── bin/
│ └── diffviewer # CLI 入口
├── start-opencode.sh # 启动脚本
├── src/
│ ├── index.ts # OpenCode 插件
│ └── command-diff.md # /diff 命令定义
├── dist/ # 编译输出
├── package.json # npm 配置
└── tsconfig.json # TypeScript 配置
`开发
`bash
克隆项目
git clone https://github.com/AruNi-01/opencode-diff-viewer.git
cd opencode-diff-viewer安装依赖
npm install构建
npm run build链接本地包
npm link -g opencode-diff-viewer测试 CLI
./bin/diffviewer opencode
`发布
`bash
npm version patch # 1.0.0 -> 1.0.1
npm publish
``- tmux - 终端复用器
- lumen - TUI Diff 查看器
- @opencode-ai/plugin - OpenCode 插件 SDK
MIT