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-zai-quota

v1.0.2

Published

OpenCode TUI plugin - Z.AI coding plan quota gauges (5h window + plan) in the sidebar

Readme

opencode-zai-quota

OpenCode TUI plugin that shows your Z.AI coding plan quota (zai-coding-plan) directly in the sidebar: a gauge for the short usage window and one for the plan-level allowance, with live colors as you approach the limits.

Features

  • Panel in the session sidebar with one gauge per quota limit:
    • Bar (26 cells) filled according to consumption percentage.
    • Dynamic colors: green < 70%, yellow 70-89%, red >= 90%.
    • Reset countdown per limit (from nextResetTime).
    • Usage / allowance numbers, plan level, and last-refresh time in the header.
  • Compact zai:N% chip next to the session prompt input.
  • Refreshes every minute, on session.idle, and on demand via the /zai-quota command (also in the command palette, ctrl+p).
  • Colors read from the active OpenCode theme (api.theme.current.*) — no hardcoded hex values.

Install

OpenCode TUI plugins are not auto-discovered: installing the package only downloads it — the plugin must also be registered in tui.json. Two ways:

Option 1 — Plugin manager inside OpenCode (recommended)

  1. npm install -g opencode-zai-quota
  2. Open OpenCode, press ctrl+p and run plugin install (or open the plugin manager and add opencode-zai-quota).
  3. The plugin manager writes the entry to tui.json for you. Restart OpenCode.

Option 2 — Manual registration

  1. npm install -g opencode-zai-quota
  2. Add the plugin to ~/.config/opencode/tui.json (a project-level .opencode/tui.json also works):
{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": ["opencode-zai-quota"]
}
  1. Restart OpenCode. The Z.AI PLAN panel appears in the session sidebar and the zai:N% chip next to the prompt input.

Editing tui.json requires a restart: config is not hot-reloaded. Unknown top-level keys in tui.json are rejected and will crash startup — keep the shape shown above.

Authentication

The token is read automatically from OpenCode's own credentials (~/.local/share/opencode/auth.json): the zai-coding-plan entry first, then zai. If you can chat with a zai-coding-plan model in OpenCode, the widget works with zero configuration.

Environment fallbacks: ZAI_TOKEN / Z_AI_TOKEN.

Data source

GET https://api.z.ai/api/monitor/usage/quota/limit
Authorization: Bearer <token>

Commands

| Slash command | Palette title | Description | |---|---|---| | /zai-quota (/zq) | Z.AI quota: refresh now | Force a refresh and show a toast with the result |

Note

This is a community plugin, not affiliated with Z.AI or OpenCode.

Freeze guard (v1.0.2)

When the Z.AI provider kills a stream with Weekly/Monthly Limit Exhausted, the turn used to hang in the TUI (looking frozen). The plugin now listens for the session.error event, shows an error toast with the reset time, refreshes the gauges, and aborts the stuck turn automatically so the UI unfreezes immediately. Switch model with /models to keep working until the reset.

License

MIT