diff --git a/README.md b/README.md index 9ff1665..d28457d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Interactive model selector for [pi](https://pi.dev/) with a provider-focused ter - Highlights the currently selected row - Marks current active model with `*` - Marks reasoning-capable models with `R` +- Displays prices as `$input/$output · context` - Avoids overriding pi's built-in `/model` command ## UI preview @@ -42,6 +43,12 @@ Interactive model selector for [pi](https://pi.dev/) with a provider-focused ter pi install git:github.com/sakuradairong/pi-model-selector ``` +For a pinned install, use a release tag: + +```bash +pi install git:github.com/sakuradairong/pi-model-selector@v0.1.0 +``` + Then restart pi, or run: ```text diff --git a/package.json b/package.json index 283f584..54ff0e0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,16 @@ { "name": "pi-model-selector", "version": "0.1.0", - "description": "Interactive provider-tabbed model selector extension for pi.", + "description": "Interactive provider-focused model selector extension for pi.", "type": "module", + "homepage": "https://github.com/sakuradairong/pi-model-selector#readme", + "repository": { + "type": "git", + "url": "https://github.com/sakuradairong/pi-model-selector.git" + }, + "bugs": { + "url": "https://github.com/sakuradairong/pi-model-selector/issues" + }, "keywords": [ "pi-package", "pi", diff --git a/src/index.ts b/src/index.ts index 9648b24..263b239 100644 --- a/src/index.ts +++ b/src/index.ts @@ -176,25 +176,21 @@ function buildProviderList(ctx: ExtensionContext): Provider[] { function buildCostLabel(model: Model): string { const c = model.cost; - if (!c) return "free"; + const ctxLabel = model.contextWindow ? formatContextWindow(model.contextWindow) : ""; + if (!c) return ctxLabel ? `free · ${ctxLabel}` : "free"; - const inputCost = c.input > 0 ? `$${c.input}` : "free"; - const outputCost = c.output > 0 ? `$${c.output}` : "free"; - - const ctxWin = model.contextWindow; - const ctxLabel = ctxWin ? formatContextWindow(ctxWin) : ""; - - if (inputCost === "free" && outputCost === "free") { - return ctxLabel || "free"; - } - - if (inputCost === outputCost) { - return ctxLabel ? `$${c.input}/${ctxLabel}` : `$${c.input}`; - } - - return ctxLabel - ? `${inputCost}/${outputCost} · ${ctxLabel}` + const inputCost = formatPrice(c.input); + const outputCost = formatPrice(c.output); + const priceLabel = inputCost === "free" && outputCost === "free" + ? "free" : `${inputCost}/${outputCost}`; + + return ctxLabel ? `${priceLabel} · ${ctxLabel}` : priceLabel; +} + +function formatPrice(value: number): string { + if (!Number.isFinite(value) || value <= 0) return "free"; + return `$${Number.isInteger(value) ? value : value.toFixed(3).replace(/0+$/, "").replace(/\.$/, "")}`; } function modelKey(model: Model): string {