npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-diff-viewer

v1.0.11

Published

OpenCode plugin + CLI tool for launching AI agents in tmux with diff viewing

Readme

Agent Launcher + OpenCode Diff Viewer

npm version npm downloads

一个 CLI 工具,用于在 tmux 中启动各种 AI Agent 工具,并提供 OpenCode diff 查看插件。

功能特性

CLI 工具

  • 🚀 一键启动 - 在 tmux 中启动 OpenCode、Claude CLI、Codex CLI 等
  • 🔧 自动安装 tmux - 自动检测并安装 tmux
  • 📊 会话管理 - 列出、附加、终止 tmux 会话
  • ⚙️ 可配置 - 支持自定义工具配置

OpenCode 插件

  • 自动安装 lumen - 插件会自动检测并安装 lumen
  • 📝 /diff 命令 - 快速查看代码变更
  • 🤖 LLM 工具集成 - LLM 可自动调用 view_diff 工具

安装

# npm
npm install -g opencode-diff-viewer

# pnpm
pnpm add -g opencode-diff-viewer

# bun
bun add -g opencode-diff-viewer

CLI 使用方法

启动 AI 工具

# 启动 OpenCode
diffviewer opencode

# 启动 Claude CLI
diffviewer claude

# 启动 Codex CLI
diffviewer codex

# 查看 git diff
diffviewer diff

会话管理

# 列出所有工具
diffviewer list

# 查看运行中的会话
diffviewer status

# 附加到会话
diffviewer attach opencode

# 终止会话
diffviewer kill opencode

查看帮助

diffviewer --help

OpenCode 插件配置

1. 配置 OpenCode

创建或编辑 ~/.config/opencode/opencode.json

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

2. 在 tmux 中启动 OpenCode

# 使用 CLI 启动
diffviewer opencode

# 或使用启动脚本
opencode-diff-viewer
./start-opencode.sh

3. 使用 /diff 命令

在 OpenCode TUI 中输入:

/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 添加自定义工具:

{
  "tools": {
    "custom": {
      "name": "Custom Tool",
      "command": "custom-command",
      "description": "My custom tool",
      "install": "npm install -g custom-tool"
    }
  }
}

前置条件

tmux

CLI 会自动安装 tmux。如果失败,手动安装:

brew install tmux
# or
apt install tmux

lumen(用于 OpenCode 插件)

插件会自动安装 lumen。如果失败,手动安装:

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 配置

开发

# 克隆项目
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

发布

npm version patch   # 1.0.0 -> 1.0.1
npm publish

依赖

License

MIT

作者

AarynLu