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

@astrolimit/opencode-peak-guard

v0.1.0

Published

opencode 插件:模型高峰期自动降级——在配置的时间段内把拥堵模型的请求切换到备用模型

Readme

@astrolimit/opencode-peak-guard

opencode 插件:模型高峰期自动降级。在配置的时间段内,把发往「拥堵模型」的请求自动切换到备用模型;高峰一过,自动恢复。

工作原理

  • 插件通过 opencode 的 chat.message 钩子,在每条用户消息处理前判断**当前时刻(北京时间)**是否处于该模型配置的高峰窗口;
  • 命中则把该消息的模型改写为规则指定的 fallback,未命中则完全不动——无状态、按请求实时切换、高峰结束自动恢复;
  • 每次实际降级都会 toast 提醒 + 写入结构化日志(client.app.log,service 为 peak-guard);
  • 降级目标未在 opencode 中配置时 fail open:保持原模型并警告,绝不中断工作。

安装

在 opencode 配置(全局 ~/.config/opencode/opencode.json 或项目级 opencode.json)中加入:

{
  "plugin": ["@astrolimit/opencode-peak-guard"]
}

配置

配置文件为全局唯一的 ~/.config/opencode/peak-guard.jsonc(遵循 $XDG_CONFIG_HOME;无 jsonc 时回退 peak-guard.json,两者并存以 jsonc 为准,文件在插件启动时确定)。支持 JSONC 语法——// 行注释、/* */ 块注释、尾逗号均可。修改后即时生效,无需重启。

{
  // key:高峰时要避开的模型,格式 "providerID/modelID",支持 * 通配
  "deepseek/*": {
    // 高峰窗口,HHMM 整数,半开区间 [start, end);支持多条;start > end 表示跨午夜
    "windows": [
      { "start": 900, "end": 1200 },
      { "start": 1400, "end": 1800 }
    ],
    // 可选:仅工作日(按北京时间周一~周五)生效
    "weekdaysOnly": true,
    // 命中高峰时切换到的备用模型
    "fallback": "zhipuai-coding-plan/glm-5.2"
  },
  "zhipuai-coding-plan/glm-5.2": {
    "windows": [{ "start": 1400, "end": 1800 }],
    "weekdaysOnly": true,
    "fallback": "deepseek/deepseek-v3"
  }
}

规则要点:

  • 时区固定为北京时间(UTC+8),与运行机器的时区无关;
  • 时间段为 HHMM 整数(900 = 09:00,1400 = 14:00),半开区间 [start, end);
  • 多条规则同时命中时,最具体(非通配字符最多)的模式优先;
  • 不做链式解析:fallback 即终点,即使它自己也处于高峰;
  • 配置错误(非法 JSON/JSONC、规则缺字段等)不会中断 opencode——坏规则被跳过并 toast/日志告警;
  • 作用于主会话与 task 子代理的请求;标题生成等小模型调用不受影响。

许可证

本项目基于 SFR 许可证(第二版)开源,详见 LICENSE 与 http://www.shared-future.ren/licenses/。