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

@alexsun-top/opencode-turbo

v0.2.1

Published

Zero-config OpenCode plugin that recovers from provider stream errors, disconnects and rate limits by resuming the response where it was interrupted

Readme

opencode-turbo

让 OpenCode 安心运行。长会话可能遇到 OpenCode 默认不重试的提供方错误, 而侧边栏实时状态行让会话活动清晰可见。本插件处理明确失败,以及静默卡顿与 空输出回合——零配置可用,所有参数可选。

为什么能降低焦虑

  • 明确的瞬态错误自己处理。 会话遇到匹配的 API、SQL 或连接/传输错误时, 插件捕获模型已产出的内容,用同一模型重新发送续写提示,从断点处继续。
  • 看得见它在干活。 侧边栏一行实时状态,告诉你 OpenCode 此刻在做什么—— 推理、撰写、跑工具——安静的屏幕不再意味着卡死。放心走开,回来是完成的 会话,而不是死掉的会话。

功能

自动恢复

会话遇到明确的 API、SQL 或连接/传输错误时,从断点处恢复回复:

  • 明确 APIError 的状态码:400、402、403、405、408、409、422、429 (以及 500、502、503、504、524、529);没有状态码时只接受少数明确的服务端 瞬时文案,未分类错误即使文案相同也不会触发恢复
  • 明确的 SQL/SQLite/Database 错误,且消息包含 Failed to execute statement 或 database is locked;无错误名称时,仅当 Failed query: 后紧跟 insert、select、update 等 SQL 语句关键字才会处理
  • 窄范围的连接/传输错误,例如 connection reset/closed/lost(包括 connection was closed 等助动词形式)、ECONN*、unable to connect、 cannot connect to host / connect call failed、socket hang up、fetch 失败、 request/connection/response/read/SSE 超时、ETIMEDOUT、broken pipe, 以及 stream closed/ended 或 premature close
  • 接受未分类错误中的裸文案 the operation timed out(结尾句点可有可无); 带更大超时提示的工具超时变体仍不处理
  • 静默卡顿:会话在 stallTimeoutMs(默认 30 分钟)内没有任何流式进展且无正在 运行的工具时先做探测;仅在会话空闲时通过同一恢复路径续写,忙碌会话只做预检, 绝不中止
  • 空输出回合:回合结束但没有可见文本或工具输出时,发送简短提示要求给出实际答案

恢复流程(按会话):确认失败的 assistant 消息 → 捕获部分产出 → 保留完整历史并追加续写提示。 护栏:用户主动停止、鉴权错误、永久性失败、模型/工具输出错误绝不自动恢复。 TLS/证书错误只有精确的 Bun 错误码并搭配精确的 unknown certificate verification error、Error: unknown certificate verification error 或完整的 UNKNOWN_CERTIFICATE_VERIFICATION_ERROR: unknown certificate verification error 文案时才可恢复。唯一无需错误码的例外是 OpenCode 精确的 UnknownError 封装,且 data.message 必须为精确的裸文案 unknown certificate verification error(精确的 Error: unknown certificate verification error 序列化形式也支持)。单独证书文案、单独错误码及其他证书错误均不恢复;每会话最多连续恢复 10 次,指数退避上限 30 分钟 (仅确认续写成功后计数归零);模型/工具错误即使带有原本可重试的 API 状态码也会排除。 状态预检需同时等待失败消息就绪及会话状态探测为空闲,最长重试 10 分钟(指数退避 上限 30 秒)后可见地放弃;不会扩大错误匹配范围,绝不干涉 OpenCode 自带的重试循环。 日志:~/.local/share/opencode/logs/auto-recover.log。

用户主动中止(Esc)会永久取消该会话的恢复链:插件绝不重试用户中止,也绝不主动 中止忙碌会话,更不会自行复活已取消的链。只有下一条真实用户消息到来才会清除屏障, 此后的失败才可再次恢复。

实时状态行

侧边栏常驻一行,随流式输出实时刷新:

  • 🔧 bash · 12.5s — 正在运行的工具及耗时;模型显式设置了超时上限时显示 预算:🔧 bash · 12.5s / 30s;内容类工具额外显示输入 token 估算:🔧 edit · 2.5s · 567 tokens;带提示词的 task/subagent 调用(包括续跑)会显示 提示词 token 估算,例如 🔧 task · 2.5s · ~567 prompt tokens(不代表子代理上下文或计费用量)
  • 🤔 Thinking · 12.0s · 1,234 tokens — 耗时在前,推理 token 数(估算) 在后
  • ⠋ Working · 3.2s · 567 tokens — 动画转圈图标,该阶段耗时在前,已累计 token 在后
  • ⏳ Waiting · 1.5s — 等待首字节输出阶段
  • ✅ Done · 1m 30s · 14:30:22 — 上一轮完成耗时与本地时间
  • ❌ Failed — 终态失败的回合明确显示,不伪装成空闲

新状态经 300ms 驻留后替换当前显示(消除快速切换闪烁),而显示中的数字—— 转圈与计时——每心跳持续实时跳动,状态行永不冻结、永不像卡住。token 数为 估算(中英感知),非计费口径。

通知弹窗

重试类事件:OpenCode 自带重试(⚠️ Retrying · attempt 2)与本插件自动恢复 (🔄 Auto-recovering · 1/10)。恢复达到终止上限时还会显示 ⛔ Auto-recovery stopped。所有展示均为只读,绝不改动会话状态。

安装

支持 OpenCode V1 >=1.19.0,以及按 OpenCode V2 2.0.27 API 适配的版本。同一个包提供服务端恢复与 TUI 状态行;服务端插件会自动注册对应的 TUI 扩展。

OpenCode V2(推荐)

为当前 CLI 用户安装固定版本:

opencode plugin add @alexsun-top/[email protected]
opencode plugin list

这是用户级安装,不要使用 npm -g。插件同时提供服务端恢复和侧栏状态行,普通安装无需再把本包单独添加到 cli.json:该文件用于终端客户端设置和仅扩展终端界面的插件,而本包是服务端插件。通知通过公开 RPC 事件发送;没有打开 CLI 时服务端恢复仍可工作。

也可以将插件添加到全局服务端配置 ~/.config/opencode/opencode.json 或 opencode.jsonc:

{
  "plugins": ["@alexsun-top/[email protected]"]
}

需要设置选项时使用包对象写法:

{
  "plugins": [{
    "package": "@alexsun-top/[email protected]",
    "options": { "stallTimeoutMs": 1800000, "emptyOutput": true }
  }]
}

OpenCode 通常会监视服务端配置并自动重载,无需重启服务端。如果已打开的终端 CLI 没有显示状态行,只需重新打开 CLI。

V2 终端客户端设置使用全局 ~/.config/opencode/cli.json,取代 V1 的 tui.json / tui.jsonc 位置;仅当 cli.json 不存在时才会迁移,旧文件会保留。不要创建项目本地的 cli.json。

参考:V2 插件指南、V2 配置说明和V1 终端配置迁移说明。

OpenCode V1(>=1.19.0)

V1 使用单数 plugin 配置键;传选项时使用二元组:

{
  "plugin": ["@alexsun-top/[email protected]"]
}

V1 选项作为二元组第二项传入:

{
  "plugin": [
    ["@alexsun-top/[email protected]", { "stallTimeoutMs": 1800000, "emptyOutput": true }]
  ]
}
  • stallTimeoutMs(默认 1800000,即 30 分钟):判定为卡顿前的静默时长; 0 关闭看门狗。
  • emptyOutput(默认 true):恢复没有输出的回合。V2 可在上方包对象的 options 中使用相同设置。

本地开发

V1 和 V2 都指向包目录;V2 使用复数键 plugins,V1 使用单数键 plugin。V2 会从包目录同时解析共享的服务端与 TUI 导出,不要直接指向 src/index.ts:

{
  "plugins": ["file:///path/to/opencode-turbo"]
}
{
  "plugin": ["file:///path/to/opencode-turbo"]
}

TUI 状态行由构建后的 TUI 入口提供。修改 TUI TSX 文件后,测试或发布前需执行 bun run build:tui。

开发

bun install
bun run check   # 类型检查 + 自检

许可证

MIT