@xynogen/pix-models 0.1.27 → 0.1.32
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.
- package/package.json +4 -4
- package/src/models.test.ts +20 -0
- package/src/models.ts +20 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-models",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Pi extension — enhanced /models picker with BenchLM ranks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@xynogen/pix-data": "^0.4.
|
|
42
|
-
"@xynogen/pix-pretty": "^1.
|
|
43
|
-
"@xynogen/pix-runtime": "^0.
|
|
41
|
+
"@xynogen/pix-data": "^0.4.3",
|
|
42
|
+
"@xynogen/pix-pretty": "^1.11.2",
|
|
43
|
+
"@xynogen/pix-runtime": "^0.5.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/models.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
fmtCtx,
|
|
7
7
|
type ModelSearchLookup,
|
|
8
8
|
normalizeModelText,
|
|
9
|
+
resolveContextWindow,
|
|
9
10
|
sortModels,
|
|
10
11
|
stepEffectiveThinkingLevel,
|
|
11
12
|
stepThinkingLevel,
|
|
@@ -57,6 +58,25 @@ describe("stepEffectiveThinkingLevel", () => {
|
|
|
57
58
|
});
|
|
58
59
|
});
|
|
59
60
|
|
|
61
|
+
describe("resolveContextWindow", () => {
|
|
62
|
+
it("prefers provider contextWindow over fallback", () => {
|
|
63
|
+
expect(resolveContextWindow({ contextWindow: 200_000 }, 128_000)).toBe(200_000);
|
|
64
|
+
});
|
|
65
|
+
it("falls back to dev limit when provider is 0/missing", () => {
|
|
66
|
+
expect(resolveContextWindow({ contextWindow: 0 }, 128_000)).toBe(128_000);
|
|
67
|
+
expect(resolveContextWindow({}, 64_000)).toBe(64_000);
|
|
68
|
+
});
|
|
69
|
+
it("ignores non-finite and negative values", () => {
|
|
70
|
+
expect(resolveContextWindow({ contextWindow: Number.NaN }, 128_000)).toBe(128_000);
|
|
71
|
+
expect(resolveContextWindow({ contextWindow: Number.POSITIVE_INFINITY }, 50_000)).toBe(50_000);
|
|
72
|
+
expect(resolveContextWindow({ contextWindow: -1 }, 32_000)).toBe(32_000);
|
|
73
|
+
});
|
|
74
|
+
it("returns 0 when both missing/invalid", () => {
|
|
75
|
+
expect(resolveContextWindow({}, undefined)).toBe(0);
|
|
76
|
+
expect(resolveContextWindow({ contextWindow: null }, null)).toBe(0);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
60
80
|
describe("fmtCtx", () => {
|
|
61
81
|
it("formats 0 as 0", () => expect(fmtCtx(0)).toBe("0"));
|
|
62
82
|
it("formats small numbers as-is", () => expect(fmtCtx(512)).toBe("512"));
|
package/src/models.ts
CHANGED
|
@@ -27,10 +27,25 @@ import {
|
|
|
27
27
|
modalWidth,
|
|
28
28
|
terminalModalHeight,
|
|
29
29
|
} from "@xynogen/pix-pretty/modal-frame";
|
|
30
|
+
import { dotJoin } from "@xynogen/pix-pretty/utils";
|
|
30
31
|
import { patchOutBuiltinModelCommand } from "./patch-builtin";
|
|
31
32
|
|
|
32
33
|
// ─── Pure logic (exported for tests) ─────────────────────────────────────────
|
|
33
34
|
|
|
35
|
+
export function resolveContextWindow(
|
|
36
|
+
model: { contextWindow?: number | null },
|
|
37
|
+
fallback?: number | null,
|
|
38
|
+
): number {
|
|
39
|
+
if (
|
|
40
|
+
typeof model.contextWindow === "number" &&
|
|
41
|
+
Number.isFinite(model.contextWindow) &&
|
|
42
|
+
model.contextWindow > 0
|
|
43
|
+
)
|
|
44
|
+
return model.contextWindow;
|
|
45
|
+
if (typeof fallback === "number" && Number.isFinite(fallback) && fallback > 0) return fallback;
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
export function fmtCtx(n: number): string {
|
|
35
50
|
if (!n || n < 1_000) return `${n}`;
|
|
36
51
|
if (n >= 1_000_000) {
|
|
@@ -296,7 +311,6 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
296
311
|
|
|
297
312
|
// Mute low-info parts (separators, padding, #, ☆) so the actual values pop.
|
|
298
313
|
const mute = (s: string) => theme.fg("muted", s);
|
|
299
|
-
const sep = mute(" · ");
|
|
300
314
|
const guide = (key: string, action: string) =>
|
|
301
315
|
theme.fg("text", key) + theme.fg("dim", ` ${action}`);
|
|
302
316
|
const guideSep = theme.fg("dim", " · ");
|
|
@@ -346,7 +360,10 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
346
360
|
|
|
347
361
|
// Description: ctx · cost · score stars
|
|
348
362
|
// Colors: ctx muted · cost success (free muted) · score+stars warning
|
|
349
|
-
|
|
363
|
+
// Context: provider's `contextWindow` (source of truth) → fallback to modelgrep `dev.limit.context`.
|
|
364
|
+
const ctxRaw = fmtCtx(
|
|
365
|
+
resolveContextWindow(m as { contextWindow?: number }, dev?.limit?.context),
|
|
366
|
+
);
|
|
350
367
|
const ctxStr = mute(ctxRaw.padStart(4));
|
|
351
368
|
const rawCost = fmtCost(dev);
|
|
352
369
|
let costSeg: string;
|
|
@@ -372,7 +389,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
372
389
|
const starBar = theme.fg(scoreColor, "★".repeat(filled)) + mute("☆".repeat(5 - filled));
|
|
373
390
|
benchSeg = `⚡${theme.fg(scoreColor, String(score))} ${starBar}`;
|
|
374
391
|
}
|
|
375
|
-
const desc = [ctxStr, costSeg, benchSeg]
|
|
392
|
+
const desc = dotJoin([ctxStr, costSeg, benchSeg], mute);
|
|
376
393
|
|
|
377
394
|
return {
|
|
378
395
|
value: `${m.provider}/${m.id}`,
|