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

@hemocode/pi-model-selector

v1.0.0

Published

A Pi extension that automatically selects the best model based on remaining usage quotas across various providers (Claude, OpenAI, Gemini, etc.).

Downloads

55

Readme

pi-model-selector

A Pi extension that automatically selects the best AI model based on remaining usage quotas across various providers. It helps you get the most out of your available tokens by switching to models with the most capacity or earliest reset times.

Features

  • Smart Model Selection: Automatically switches to the model with the most available quota or earliest reset time.
  • Multi-Provider Support: Tracks usage for:
    • Anthropic (Claude)
    • GitHub Copilot
    • Google Gemini
    • OpenAI (Codex)
    • Antigravity
    • Kiro
    • z.ai
  • Configurable Priorities: Define your own rules for selection (e.g., prioritize full availability over remaining percentage).
  • Flexible Mappings: Map specific usage windows (e.g., "5h quota", "Weekly limit") to specific models.
  • Interactive Configuration: Built-in wizard to easily set up mappings and priorities.

Installation

To install this extension, use the pi CLI:

pi install npm:@hemocode/pi-model-selector

Or install from GitHub directly:

pi install https://github.com/CTristan/pi-model-selector

Or if you have the source code locally:

pi package install .

Restart Pi after installation to load the extension.

Usage

The extension runs automatically when you start a new session. You can also use the following commands within Pi:

  • /model-select: Manually trigger the model selection process to switch to the best available model immediately.
  • /model-select-config: Open the interactive configuration wizard. This allows you to:
    • Map usage "buckets" (e.g., Claude 5h limit) to specific Pi models.
    • Ignore specific buckets you don't want to use.
    • Set the priority order for selection.
    • Run a config cleanup pass (remove unused examples, fix global debug log path, remove invalid/duplicate mapping entries, and prune mappings that target unavailable Pi provider/model IDs).

Configuration

Configuration is merged from two sources:

  1. Global Config: ~/.pi/model-selector.json (stored in your home directory). Use this for your personal model mappings and preferences.
  2. Project Config: .pi/model-selector.json (inside your project directory). Use this for project-specific overrides.

A template for the global configuration can be found in config/model-selector.example.json.

Priority Rules

You can prioritize candidates based on:

  • fullAvailability: Prefer models with 100% quota remaining.
  • remainingPercent: Prefer models with the highest percentage of quota remaining.
  • earliestReset: Prefer models that reset the soonest.

Mappings

Map a provider's usage window to a specific Pi model ID.

Note: The model.provider and model.id must match the names used in the Pi model registry (e.g., github-copilot, anthropic, google).

Reserve Threshold

You can optionally set a reserve percentage on model mappings to preserve a minimum amount of usage capacity. Candidates at or below their reserve threshold are excluded from model selection (treated the same as exhausted buckets). This is useful for keeping some quota available for other tools or manual use.

Example model-selector.json:

{
  "priority": ["fullAvailability", "remainingPercent", "earliestReset"],
  "mappings": [
    {
      "usage": { "provider": "anthropic", "window": "Sonnet" },
      "model": { "provider": "anthropic", "id": "claude-3-5-sonnet" }
    },
    {
      "usage": { "provider": "copilot", "window": "Chat" },
      "model": { "provider": "github-copilot", "id": "gpt-4o" },
      "reserve": 20
    },
    {
      "usage": { "provider": "gemini", "window": "Flash" },
      "ignore": true
    }
  ]
}

In this example, the Copilot Chat mapping has a reserve of 20%. This means the model selector will only use that model when more than 20% quota remains, preserving at least 20% for other purposes.