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-agent-ghost-panel

v0.1.10

Published

Agent Ghost Panel Plugin for OpenCode

Readme

AGP OpenCode Plugin

Agent Ghost Panel 的 OpenCode 插件,提供无缝的终端多路复用集成。

✨ 特性

  • 🔌 自动启动:OpenCode 启动时自动启动 AGP 守护进程
  • 🛠️ 原生命令:直接在 OpenCode 中使用 /diff/logs 等命令
  • 🌙 幽灵模式:Agent 在后台静默运行,不阻塞交互
  • 🎨 语法高亮:通过 lumen 实现 git diff 语法高亮
  • 🔄 交互支持:支持 ssh、sudo 等交互式命令
  • 📡 多路复用:tmux 窗口管理

📦 安装

# 1. 安装 AGP
pip install -e .

# 2. 安装 OpenCode 插件
agp install opencode

# 3. 安装 lumen(diff 高亮需要)
pip install lumen

# 4. 重启 OpenCode,插件自动加载

🚀 使用方法

启动 OpenCode + AGP

# 一键启动 OpenCode + AGP(自动管理 tmux)
agp opencode

# 这将自动:
# 1. 启动 AGP 守护进程
# 2. 创建 tmux 会话 (agp-opencode)
# 3. 启动 OpenCode
# 4. 加载 AGP 插件

OpenCode 命令

启动 OpenCode 后,直接在对话中使用以下命令:

| 命令 | 别名 | 功能 | |------|------|------| | /diff | /d | 在 tmux 新窗口显示 git diff(带高亮) | | /diff <file> | /d <file> | 显示指定文件的 diff | | /logs <file> | /l | 实时监控日志文件 | | /interactive | /i | 打开交互式终端(ssh/sudo 等) | | /status | /s | 查看 AGP 状态 | | /sessions | /ss | 列出所有 tmux 会话 |

使用示例

用户: 查看当前的 git 修改
Agent: 好的,让我用 AGP 在 diff 窗口显示修改
      [执行 /diff 命令]
      ✅ 已在 tmux diff 窗口显示 git diff(带颜色高亮)

用户: 需要登录服务器
Agent: 好的,我来创建一个交互式终端
      [执行 /interactive 命令]
      ✅ 交互式终端已创建,您可以输入 SSH 命令

用户: 监控应用日志
Agent: 好的,启动日志监控
      [执行 /logs app.log 命令]
      ✅ 日志监控已启动

⌨️ tmux 快捷键

在 tmux 窗口中:

Ctrl+b, n    # 下一个窗口
Ctrl+b, p    # 上一个窗口
Ctrl+b, 0    # 切换到 OpenCode 窗口
Ctrl+b, 1    # 切换到 diff 窗口
Ctrl+b, 2    # 切换到 logs 窗口
Ctrl+b, 3    # 切换到 interactive 窗口
Ctrl+b, d    # 分离会话(保留后台运行)

状态栏会显示当前窗口的操作提示。

🏗️ 架构

┌─────────────────────────────────────────────────────────┐
│                   OpenCode                              │
│                                                 │
│  ┌───────────────────────────────────────────────┐  │
│  │  AGP 插件                                      │  │
│  │  • /diff → 创建 tmux diff 窗口                 │  │
│  │  • /logs → 创建 tmux logs 窗口                 │  │
│  │  • /interactive → 创建交互式终端               │  │
│  └───────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              AGP 守护进程 (WebSocket)                    │
│              ws://127.0.0.1:8765                        │
└─────────────────────────────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│                   Tmux 会话                             │
│                   agp-opencode                          │
│                                                         │
│  [opencode]  ← OpenCode 主窗口                          │
│     │                                                   │
│     ├── [diff]  ← lumen git diff(语法高亮)            │
│     ├── [logs]  ← tail -f 日志监控                      │
│     └── [interactive] ← 交互式终端                      │
└─────────────────────────────────────────────────────────┘

🔧 开发

添加新命令

  1. __init__.py 中添加命令处理函数:
async def _cmd_newcommand(args: list) -> Dict[str, Any]:
    """新命令说明"""
    # 1. 检查依赖
    # 2. 执行 tmux 命令
    # 3. 返回结果

    return {
        "success": True,
        "message": "✅ 命令已执行",
        "details": {...}
    }
  1. AGPPlugin.execute() 中添加分支:
elif cmd in ["newcommand", "nc"]:
    return await _cmd_newcommand(args)
  1. get_commands() 中注册命令:
{
    "name": "newcommand",
    "description": "新命令说明",
    "usage": "/newcommand",
    "aliases": ["nc"]
}

测试

# 安装测试
agp install opencode

# 重启 OpenCode 测试

📝 命令说明

/diff

在 tmux 新窗口显示 git diff,使用 lumen 实现语法高亮。

/diff              # 当前目录的 diff
/diff src/main.py  # 指定文件的 diff

特点:

  • 自动创建 tmux diff 窗口
  • 使用 lumen 渲染,带语法高亮
  • 状态栏显示操作提示

/logs

实时监控日志文件。

/logs app.log      # 监控日志文件
/logs /var/log/app.log  # 绝对路径

特点:

  • 使用 tail -f 实时监控
  • 新窗口显示,不阻塞 OpenCode
  • 可以同时监控多个日志文件

/interactive

打开交互式终端,用于需要用户输入的命令。

/interactive              # 打开空白交互终端
/interactive ssh user@host  # 直接执行 ssh

适用场景:

  • SSH 登录远程服务器
  • sudo 命令需要密码
  • 其他需要交互的命令

使用后:

  • 输入命令并回车执行
  • 输入 exit 退出交互终端
  • 使用 Ctrl+b, d 关闭窗口

/status

查看 AGP 守护进程状态。

/status  # 或 /s

显示:

  • 守护进程是否运行
  • API 端点地址
  • 会话数量

/sessions

列出所有 tmux 会话。

/sessions  # 或 /ss

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 或 Pull Request!