@xynogen/pix-models 0.1.27 → 0.1.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-models",
3
- "version": "0.1.27",
3
+ "version": "0.1.31",
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.0",
42
- "@xynogen/pix-pretty": "^1.7.9",
43
- "@xynogen/pix-runtime": "^0.4.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": "*",
@@ -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
@@ -31,6 +31,20 @@ import { patchOutBuiltinModelCommand } from "./patch-builtin";
31
31
 
32
32
  // ─── Pure logic (exported for tests) ─────────────────────────────────────────
33
33
 
34
+ export function resolveContextWindow(
35
+ model: { contextWindow?: number | null },
36
+ fallback?: number | null,
37
+ ): number {
38
+ if (
39
+ typeof model.contextWindow === "number" &&
40
+ Number.isFinite(model.contextWindow) &&
41
+ model.contextWindow > 0
42
+ )
43
+ return model.contextWindow;
44
+ if (typeof fallback === "number" && Number.isFinite(fallback) && fallback > 0) return fallback;
45
+ return 0;
46
+ }
47
+
34
48
  export function fmtCtx(n: number): string {
35
49
  if (!n || n < 1_000) return `${n}`;
36
50
  if (n >= 1_000_000) {
@@ -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
- const ctxRaw = fmtCtx(dev?.limit?.context ?? 0);
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;