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-copilot-usage

v0.1.1

Published

OpenCode plugin to track GitHub Copilot premium request usage

Readme

opencode-copilot-usage

OpenCode plugin to track GitHub Copilot premium request usage, persist monthly state, and warn when usage approaches configured limits.

What it does

  • Fetches Copilot premium usage from GitHub internal endpoint GET /copilot_internal/user (primary source)
  • Falls back to GitHub billing summary endpoint when internal endpoint is unavailable
  • Falls back to local estimate from OpenCode events when API data is unavailable
  • Shows a per-request info toast for each user message (enabled by default)
  • Persists state at .opencode/state/copilot-usage.json
  • Emits warn toasts at configured thresholds (75%, 90%, 100% by default)
  • Provides custom tool copilot_usage_status for on-demand usage status

Sidebar note

OpenCode plugin hooks currently do not expose custom sidebar widget injection. This plugin surfaces usage through warning toasts and tool output.

Installation

Add plugin package to your OpenCode config:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-copilot-usage"]
}

Configuration

This plugin reads environment variables:

  • GITHUB_TOKEN: GitHub token used for Copilot usage API
  • GH_TOKEN: Alternate token env var
  • COPILOT_API_GITHUB_TOKEN: Alternate token env var
  • If no env token is set, plugin also reads OpenCode auth storage at ~/.local/share/opencode/auth.json (github-copilot.access)
  • GITHUB_USERNAME: Optional GitHub username override
  • OPENCODE_COPILOT_USAGE_MONTHLY_LIMIT: Default 300
  • OPENCODE_COPILOT_USAGE_WARN_THRESHOLDS: Comma-separated ratios (example: 0.75,0.9,1)
  • OPENCODE_COPILOT_USAGE_WARN_COOLDOWN_MINUTES: Default 360
  • OPENCODE_COPILOT_USAGE_REPEAT_OVER_LIMIT_EVERY: Default 25
  • OPENCODE_COPILOT_USAGE_BILLING_START_DAY: Default 1 (supports 1-28)
  • OPENCODE_COPILOT_USAGE_BILLING_TIMEZONE: utc (default) or local
  • OPENCODE_COPILOT_USAGE_TOAST_EVERY_PREMIUM_REQUEST: true/false (default true)
  • OPENCODE_COPILOT_USAGE_REQUEST_TOAST_DURATION_MS: toast duration (default 3000)
  • OPENCODE_COPILOT_USAGE_STATE_FILE: Optional custom state path
  • OPENCODE_COPILOT_USAGE_DEBUG: true/false

Usage

After plugin loads, ask OpenCode to run tool copilot_usage_status to see current status snapshot.

Local development

npm install
npm run build

Then point OpenCode to your built plugin package (or publish to npm).

Publish to npm

  1. Create the npm package (first time):
npm login
npm run build
npm publish --access public
  1. Release updates:
npm version patch
git push --follow-tags

If GitHub Actions is configured with NPM_TOKEN, pushing tags like v0.1.1 will auto-publish.