@xynogen/pix-models 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/models.ts +68 -57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-models",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Pi extension — enhanced /models picker with BenchLM ranks",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/models.ts CHANGED
@@ -115,11 +115,14 @@ async function showEnhancedPicker(
115
115
  m: (typeof available)[number];
116
116
  dev: ReturnType<typeof lookupModelsDev>;
117
117
  bench: ReturnType<typeof lookupBenchmark>;
118
+ // Rank among the user's *available* models, not the global catalog.
119
+ localRank: number | null;
118
120
  };
119
121
  const rows: Row[] = available.map((m) => ({
120
122
  m,
121
123
  dev: lookupModelsDev(m.provider, m.id),
122
- bench: lookupBenchmark(m.name ?? m.id),
124
+ bench: lookupBenchmark(m.id),
125
+ localRank: null,
123
126
  }));
124
127
 
125
128
  // Sort: by score desc (highest first), unscored last alphabetical
@@ -130,6 +133,10 @@ async function showEnhancedPicker(
130
133
  return (a.m.name ?? a.m.id).localeCompare(b.m.name ?? b.m.id);
131
134
  });
132
135
 
136
+ // Local rank = position among scored available models (best pickable = #1).
137
+ let localRank = 0;
138
+ for (const r of rows) if (r.bench) r.localRank = ++localRank;
139
+
133
140
  // Show all models (no deduplication)
134
141
  const dedupedRows = rows;
135
142
 
@@ -142,7 +149,9 @@ async function showEnhancedPicker(
142
149
 
143
150
  // Find max rank width across all benchmarked rows for # padding
144
151
  const maxRankWidth = Math.max(
145
- ...dedupedRows.map((r) => (r.bench ? String(r.bench.rank).length : 0)),
152
+ ...dedupedRows.map((r) =>
153
+ r.localRank ? String(r.localRank).length : 0,
154
+ ),
146
155
  1,
147
156
  );
148
157
 
@@ -152,64 +161,66 @@ async function showEnhancedPicker(
152
161
 
153
162
  // Track rank per item value so fuzzy results can prioritize ranked models.
154
163
  const rankByValue = new Map<string, number>();
155
- for (const { m, bench } of dedupedRows) {
156
- if (bench) rankByValue.set(`${m.provider}/${m.id}`, bench.rank);
164
+ for (const { m, localRank } of dedupedRows) {
165
+ if (localRank) rankByValue.set(`${m.provider}/${m.id}`, localRank);
157
166
  }
158
167
 
159
- const items: SelectItem[] = dedupedRows.map(({ m, dev, bench }) => {
160
- const isCurrent =
161
- current && m.provider === current.provider && m.id === current.id;
162
-
163
- // Label: marker + muted '#' + bright rank + accent-colored model name
164
- const marker = isCurrent ? theme.fg(accent, "▶") : " ";
165
- let rankPrefix: string;
166
- if (bench) {
167
- const rankStr = String(bench.rank).padEnd(maxRankWidth);
168
- rankPrefix = mute("#") + theme.fg("warning", rankStr);
169
- } else {
170
- rankPrefix = " ".repeat(maxRankWidth + 1);
171
- }
172
- // Display model id only; m.provider is routing provider, not part of id.
173
- const idColored = theme.fg(accent, m.id);
174
- const label = `${marker} ${rankPrefix} ${idColored}`;
175
-
176
- // Description: ctx · cost · score stars
177
- // Colors: ctx muted · cost success (free muted) · score+stars warning
178
- const ctxRaw = fmtCtx(dev?.limit?.context ?? 0);
179
- const ctxStr = mute(ctxRaw.padStart(4));
180
- const rawCost = fmtCost(dev);
181
- let costSeg: string;
182
- if (rawCost === "—") {
183
- costSeg = theme.fg("dim", "—".padEnd(10));
184
- } else if (rawCost === "free") {
185
- costSeg = mute("free".padEnd(10));
186
- } else {
187
- costSeg = theme.fg("success", rawCost.padEnd(10));
188
- }
189
- let benchSeg = "";
190
- if (bench) {
191
- const score = bench.overallScore ?? "?";
192
- const s = bench.overallScore;
193
- let filled = 1;
194
- if (typeof s === "number") {
195
- if (s >= 90) filled = 5;
196
- else if (s >= 80) filled = 4;
197
- else if (s >= 70) filled = 3;
198
- else if (s >= 50) filled = 2;
168
+ const items: SelectItem[] = dedupedRows.map(
169
+ ({ m, dev, bench, localRank }) => {
170
+ const isCurrent =
171
+ current && m.provider === current.provider && m.id === current.id;
172
+
173
+ // Label: marker + muted '#' + bright rank + accent-colored model name
174
+ const marker = isCurrent ? theme.fg(accent, "▶") : " ";
175
+ let rankPrefix: string;
176
+ if (localRank) {
177
+ const rankStr = String(localRank).padEnd(maxRankWidth);
178
+ rankPrefix = mute("#") + theme.fg("warning", rankStr);
179
+ } else {
180
+ rankPrefix = " ".repeat(maxRankWidth + 1);
199
181
  }
200
- const starBar =
201
- theme.fg("warning", "★".repeat(filled)) +
202
- mute("☆".repeat(5 - filled));
203
- benchSeg = `⚡${theme.fg("warning", String(score))} ${starBar}`;
204
- }
205
- const desc = [ctxStr, costSeg, benchSeg].filter(Boolean).join(sep);
182
+ // Display model id only; m.provider is routing provider, not part of id.
183
+ const idColored = theme.fg(accent, m.id);
184
+ const label = `${marker} ${rankPrefix} ${idColored}`;
185
+
186
+ // Description: ctx · cost · score stars
187
+ // Colors: ctx muted · cost success (free muted) · score+stars warning
188
+ const ctxRaw = fmtCtx(dev?.limit?.context ?? 0);
189
+ const ctxStr = mute(ctxRaw.padStart(4));
190
+ const rawCost = fmtCost(dev);
191
+ let costSeg: string;
192
+ if (rawCost === "—") {
193
+ costSeg = theme.fg("dim", "—".padEnd(10));
194
+ } else if (rawCost === "free") {
195
+ costSeg = mute("free".padEnd(10));
196
+ } else {
197
+ costSeg = theme.fg("success", rawCost.padEnd(10));
198
+ }
199
+ let benchSeg = "";
200
+ if (bench) {
201
+ const score = bench.overallScore ?? "?";
202
+ const s = bench.overallScore;
203
+ let filled = 1;
204
+ if (typeof s === "number") {
205
+ if (s >= 90) filled = 5;
206
+ else if (s >= 80) filled = 4;
207
+ else if (s >= 70) filled = 3;
208
+ else if (s >= 50) filled = 2;
209
+ }
210
+ const starBar =
211
+ theme.fg("warning", "★".repeat(filled)) +
212
+ mute("☆".repeat(5 - filled));
213
+ benchSeg = `⚡${theme.fg("warning", String(score))} ${starBar}`;
214
+ }
215
+ const desc = [ctxStr, costSeg, benchSeg].filter(Boolean).join(sep);
206
216
 
207
- return {
208
- value: `${m.provider}/${m.id}`,
209
- label,
210
- description: desc,
211
- };
212
- });
217
+ return {
218
+ value: `${m.provider}/${m.id}`,
219
+ label,
220
+ description: desc,
221
+ };
222
+ },
223
+ );
213
224
 
214
225
  const currentIdx = current
215
226
  ? items.findIndex(
@@ -225,7 +236,7 @@ async function showEnhancedPicker(
225
236
  new Text(
226
237
  theme.fg(
227
238
  "dim",
228
- "context & pricing from models.dev · ranks from benchlm.ai",
239
+ "context · pricing · coding rank & score from modelgrep.com",
229
240
  ),
230
241
  ),
231
242
  );