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

wechat-opencode-bot

v0.2.4

Published

微信 ⇄ opencode 桥接机器人:微信消息通过 opencode serve 驱动 AI 回复,支持定时任务主动推送、媒体收发,跨平台(macOS/Windows/Linux)。

Readme

wechat-opencode-bot

微信 ⇄ opencode 桥接机器人。微信消息通过 opencode serve 驱动 AI 回复,支持定时任务主动推送、图片/文件收发。跨平台(macOS / Windows / Linux)。

原理

cc-wechat 的 notifications/claude/channel 是 Claude Code 专属协议,opencode 不处理。本工具由桥接进程独占轮询微信 iLink API,拿到消息后通过 opencode serve 的 HTTP API 触发 AI 回复,再回传微信。

微信用户 ⇄ iLink API ⇄ bridge(独占轮询) ⇄ opencode serve(HTTP) ⇄ LLM

安装

npm install -g wechat-opencode-bot
# 首次登录微信(扫码)
wechat-bot login

依赖 cc-wechat(自动安装)。需要 opencode 在 PATH 中,或设置 OPENCODE_BIN 指向其可执行文件。

快速开始

wechat-bot serve     # 启动 opencode serve(前台)
wechat-bot bridge    # 启动桥接进程(前台)
wechat-bot status    # 查看状态

或使用自启动:

wechat-bot install   # macOS: 生成 launchd plist 到 ~/Library/LaunchAgents
# 然后加载(一次性):
launchctl load ~/Library/LaunchAgents/com.opencode-wechat-bot.serve.plist
launchctl load ~/Library/LaunchAgents/com.opencode-wechat-bot.bridge.plist
./bin/start.sh start # 或手动启动脚本(macOS/Linux)
./bin/start.bat start# Windows

注:install 生成的 plist 含 RunAtLoad + KeepAlive,开机自启 + 崩溃自动重启。若 opencode 不在 PATH,install 会自动探测并把其目录加入 plist 的 PATH。

环境变量

| 变量 | 默认值 | 说明 | |---|---|---| | WECHAT_BOT_HOME | ~/.wechat-bot | 数据目录(sessions/tasks/media/logs/pids) | | WECHAT_PROFILE | default | cc-wechat 账号 profile,状态目录为 ~/.claude/channels/wechat/<profile> | | OPENCODE_SERVER_URL | http://127.0.0.1:4100 | opencode serve 地址 | | OPENCODE_PORT | 4100 | opencode serve 端口 | | OPENCODE_BIN | 自动探测 | opencode 可执行文件路径 | | OPENCODE_SERVER_PASSWORD | 空 | 可选: opencode serve 鉴权密码(设置后 bridge 自动携带) | | LLM_TIMEOUT_MS | 300000 | LLM 响应超时 | | BOT_PREFIX | 空 | 仅响应带此前缀的消息 |

功能

  • 自动回复:每用户独立 opencode session(会话历史持久化)。
  • 流式回复:AI 边生成边分段推送到微信(块约 400 字,句号/换行处断句)。
  • 可靠发送:校验微信业务返回码(ret!=0 自动指数退避重试),发送间隔 1s 避免高频触发微信限流。
  • 定时任务:对 bot 说"每天早上9点提醒我喝水",AI 输出 [schedule: 09:00 | 提醒喝水] 标记,bridge 解析存储,到点主动推送。
    • 时间表达式:HH:MM(每天) / 每N小时 / 每N分钟 / YYYY-MM-DD HH:MM(一次性)
    • 查看/删除:[schedule_list] / [schedule_del: id]
  • 图片/文件:接收时下载到本地供 AI 读取([图片: 路径]);发送时用 [media: /绝对/路径] 标记上传。
  • 微信友好格式:系统提示要求 AI 不用 ASCII 表格(box-drawing 字符),改纯文本列表,避免微信显示乱码。
  • 自动重连:网络错误指数退避,session 过期自动提示重新登录。

权限配置

opencode serve 为无人值守环境。建议在 opencode 配置(~/.config/opencode/opencode.json)中设置权限,让工具自动执行而不触发权限确认(权限确认在无头环境会卡住会话):

{
  "permission": {
    "bash": { "*": "allow" },
    "read": { "*": "allow" },
    "write": { "*": "allow" },
    "edit": { "*": "allow" },
    "skill": { "*": "deny" },
    "question": "allow",
    "webfetch": "allow"
  }
}
  • bash/read 等放行:微信里可直接让 AI 执行 teagit 等命令并读取文件
  • skill 设为 deny:skill 工具在 serve 环境可能不触发事件结束(卡住会话),建议禁止

数据文件

  • sessions.json:微信用户 → opencode session 映射
  • tasks.json:定时任务
  • media/:接收的媒体文件
  • logs/:serve/bridge 日志

开发

npm install
node src/cli.js bridge   # 直接运行

手动部署说明(Windows 自启)

Windows 建议用任务计划程序(schtasks)或 NSSM 注册为服务:

schtasks /create /tn wechat-serve /tr "node C:\...\cli.js serve" /sc onstart
schtasks /create /tn wechat-bridge /tr "node C:\...\cli.js bridge" /sc onstart

License

MIT