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

@lnilluv/pi-opencode-go-rotation

v1.2.0

Published

Rotate between multiple OpenCode Go API keys with best-effort reactive key rotation

Readme

pi-opencode-go-rotation

Rotate between multiple OpenCode Go API keys. The extension is best-effort and reactive: it rotates only when opencode surfaces a matching assistant error message.

Install

pi install npm:@lnilluv/pi-opencode-go-rotation

Setup

Add your API keys:

/opencode add personal sk-xxxx
/opencode add work sk-yyyy
/opencode add backup sk-zzzz

The first key added becomes active immediately.

How it works

The extension sets the active key as a runtime override, which takes priority over OPENCODE_API_KEY environment variables and auth.json credentials.

Because the extension hooks message_end error handling, it only reacts after opencode surfaces an assistant error. When that error text matches rate-limit or quota wording, the extension:

  1. Marks the current key as on cooldown
  2. Switches to the next key not on cooldown
  3. Applies the new key via setRuntimeApiKey

This is reactive only: it does not check usage or limits ahead of time.

Pi's built-in auto-retry picks up the new key on the next request.

Cooldowns default to 60 minutes. After cooldown expires, the key becomes available again.

Commands

| Command | Description | |---------|-------------| | /opencode or /opencode status | Show all keys, active key marker, cooldown status | | /opencode use <n> | Switch to key number n (1-based) | | /opencode next | Advance to the next configured key and clear its cooldown before activating it | | /opencode add <name> <key> | Add a new key | | /opencode rm <n> | Remove key number n | | /opencode reset | Clear all cooldowns | | /opencode cooldown <min> | Set or view cooldown duration in minutes |

Configuration

Keys are stored in ~/.pi/agent/opencode-keys.json with file permissions 0600.

{
  "keys": [
    { "name": "personal", "key": "sk-xxx" },
    { "name": "work", "key": "sk-yyy" }
  ],
  "activeKeyIndex": 0,
  "cooldownMinutes": 60,
  "cooldowns": {}
}

Retry settings

Pair with pi's auto-retry for best results. In ~/.pi/agent/settings.json:

{
  "retry": {
    "enabled": true,
    "maxRetries": 3
  }
}

Set maxRetries to at least the number of keys so all keys get a chance before pi gives up.

Limitations

  • OpenCode Go currently has no API endpoint for checking usage, remaining quota, or limits proactively.
  • If opencode hangs, masks the failure, or does not surface a matching error on message_end, the extension cannot detect it and will not rotate.
  • When all keys are rate-limited simultaneously, the extension force-advances to the next key and clears its cooldown.
  • Keys added via /opencode add are stored in plaintext. The config file is created with 0600 permissions.
  • If opencode later adds an API endpoint for Go plan usage/limit verification, this extension can be updated to use it.

License

MIT