omp packages

pi-better-model-select0.1.4

Better model select for pi — /bms opens a searchable model picker sorted by how often you actually use each model, with inline add, update and delete.

msenebald Published 17 days ago MIT ~342 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-better-model-select

A searchable, usage-ranked model picker for pi.

/bms opens the effective model list from models.json plus the optional BMS-owned models.bms.json overlay, sorted by how often you pick each model. Start typing to filter; press enter to switch the session to the highlighted model. Add, update and delete live on ctrl-chords so plain keystrokes always go to the search box.

Install

pi install npm:pi-better-model-select

If you installed the package under its old name, migrate with:

pi remove npm:@msenebald/better-model-select
pi install npm:pi-better-model-select

Commands

Command What it does
/bms Open the searchable, usage-ranked picker
/bms-add Jump straight to the add-a-model flow

Keys

Key Action
↑ ↓ Move through the list
type Fuzzy filter by display name, model id or provider
enter Load the highlighted model
ctrl+a Add a model
ctrl+u Update the highlighted model
ctrl+x Delete the highlighted model
ctrl+o Open BMS options
ctrl+r Reset usage statistics
esc Close

Options

Press ctrl+o in /bms to configure:

  • Write mode. Overlay mode keeps Pi's models.json unchanged and stores BMS edits in models.bms.json. Direct mode writes add, update and delete operations to models.json.
  • Provider filters. Enable or disable providers in the /bms model list. These filters do not change Pi's /model picker or either model file.

BMS stores these choices in <agent-dir>/bms-settings.json.

Ranking

Every model loaded through /bms increments a counter in <agent-dir>/bms-usage.json. The list sorts by count, then by most recent use, then alphabetically — so an unused config starts in plain alphabetical order and drifts toward your habits.

Only /bms selections count. Switching via /model, ctrl+p cycling, or a session restore does not, which keeps the ranking a record of deliberate choices rather than of how often you restart pi.

Stats for models that disappear from the effective configuration are pruned when the picker opens. ctrl+r clears everything.

Metadata discovery

When adding or updating, the extension tries to fill in context window, output cap, reasoning support and input modalities from, in order:

  1. GET {baseUrl}/model/info — LiteLLM proxies
  2. GET {baseUrl}/models/{id} — OpenAI-style, plus proxy-specific fields
  3. The public LiteLLM model cost map on GitHub

Each step is best-effort. A plain OpenAI-compatible endpoint usually yields nothing from steps 1 and 2, and the flow falls back to name-based heuristics with editable defaults. Choose the default write mode from ctrl+o in /bms. Overlay mode writes to models.bms.json; direct mode edits Pi's models.json. The selected file is re-read immediately before the write so a concurrent edit in another pi session is not clobbered.

Paths

All files resolve through pi's getAgentDir(), so PI_CODING_AGENT_DIR and rebranded distributions work without special handling:

  • <agent-dir>/models.json is Pi's documented compatible-endpoint configuration.
  • <agent-dir>/models.bms.json is the optional overlay owned and loaded by BMS.
  • <agent-dir>/bms-settings.json stores the write mode and provider filters.
  • <agent-dir>/bms-usage.json stores selection counters.

Pi does not load models.bms.json itself. In overlay mode, BMS merges it over models.json by provider and model id, then registers the merged providers through Pi's extension API. If the same model exists in both files, fields from models.bms.json win. Existing models.local.json overlays from BMS 0.1.x are renamed to models.bms.json automatically.

Deleting a model that exists only in models.json leaves that file untouched. BMS writes { "id": "...", "bmsDeleted": true } to the overlay instead. This tombstone keeps generated or externally managed model entries hidden across restarts. Delete it from models.bms.json to restore the inherited model.

Writes are atomic using a temporary file and rename, so an interrupted write cannot truncate either configuration file.

Development

npm install
npm run typecheck
node --experimental-strip-types --test extensions/lib/picker.test.ts
pi -e . -p "say OK"      # load the extension without installing it

Publishing

Set the new version in package.json and package-lock.json, then run:

make publish

The target runs the full package gate, checks npm authentication, opens npm's browser login when needed, skips the upload if that exact version already exists, publishes the public scoped package, and waits for npm to expose the new version. npm can take several minutes to process a package. If verification times out, rerun make verify-publish; do not publish the same version again.

License

MIT