@xynogen/pix-models 0.1.7 → 0.1.8

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 +3 -2
  2. package/src/models.ts +27 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-models",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Pi extension — enhanced /models picker with BenchLM ranks",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -38,7 +38,8 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@xynogen/pix-data": "*"
41
+ "@xynogen/pix-data": "*",
42
+ "@xynogen/pix-pretty": "*"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "@earendil-works/pi-coding-agent": "*",
package/src/models.ts CHANGED
@@ -12,15 +12,12 @@ import type {
12
12
  ExtensionAPI,
13
13
  ExtensionContext,
14
14
  } from "@earendil-works/pi-coding-agent";
15
- import { DynamicBorder } from "@earendil-works/pi-coding-agent";
16
15
  import {
17
- Container,
18
16
  fuzzyFilter,
19
17
  Input,
20
18
  matchesKey,
21
19
  type SelectItem,
22
20
  SelectList,
23
- Text,
24
21
  visibleWidth,
25
22
  } from "@earendil-works/pi-tui";
26
23
  import {
@@ -28,6 +25,7 @@ import {
28
25
  lookupBenchmark,
29
26
  lookupModelsDev,
30
27
  } from "@xynogen/pix-data";
28
+ import { frameLines, modalWidth } from "@xynogen/pix-pretty/modal-frame";
31
29
  import { patchOutBuiltinModelCommand } from "./patch-builtin";
32
30
 
33
31
  // ─── Pure logic (exported for tests) ─────────────────────────────────────────
@@ -148,7 +146,6 @@ async function showEnhancedPicker(
148
146
 
149
147
  const result = await ctx.ui.custom<string | null>(
150
148
  (_tui, theme, _kb, done) => {
151
- const container = new Container();
152
149
  const accent = "accent";
153
150
 
154
151
  // Find max rank width across all benchmarked rows for # padding
@@ -236,19 +233,6 @@ async function showEnhancedPicker(
236
233
  )
237
234
  : 0;
238
235
 
239
- container.addChild(new DynamicBorder((s) => theme.fg(accent, s)));
240
- container.addChild(
241
- new Text(theme.fg(accent, theme.bold("󰚩 Select model"))),
242
- );
243
- container.addChild(
244
- new Text(
245
- theme.fg(
246
- "dim",
247
- "context · pricing · coding rank & score from modelgrep.com",
248
- ),
249
- ),
250
- );
251
-
252
236
  // Widest label (visible width, ANSI-stripped) so the model name
253
237
  // column never truncates to "…". Add gap headroom.
254
238
  const widestLabel = items.reduce(
@@ -317,25 +301,34 @@ async function showEnhancedPicker(
317
301
  internal.invalidate();
318
302
  };
319
303
 
320
- container.addChild(new Text(theme.fg("muted", "Search:")));
321
- container.addChild(search);
322
- container.addChild(list);
323
- container.addChild(
324
- new Text(
325
- theme.fg(
326
- "dim",
327
- "fuzzy search · ↑↓ navigate · enter select · esc cancel",
328
- ),
329
- ),
330
- );
331
- container.addChild(new DynamicBorder((s) => theme.fg(accent, s)));
332
-
333
304
  return {
334
305
  render(w: number) {
335
- return container.render(w);
306
+ const mw = modalWidth(w);
307
+ const inner = mw - 4; // CHROME = 2 border + 2 padding
308
+ const lines: string[] = [
309
+ theme.fg(accent, theme.bold("󰈩 Select model")),
310
+ theme.fg(
311
+ "dim",
312
+ "context · pricing · coding rank & score from modelgrep.com",
313
+ ),
314
+ theme.fg("muted", "Search:"),
315
+ ...search.render(inner),
316
+ ...list.render(inner),
317
+ theme.fg(
318
+ "dim",
319
+ "fuzzy search · ↑↓ navigate · enter select · esc cancel",
320
+ ),
321
+ ];
322
+ return frameLines({
323
+ width: mw,
324
+ lines,
325
+ color: (s) => theme.fg(accent, s),
326
+ bg: (s) => theme.bg("customMessageBg", s),
327
+ });
336
328
  },
337
329
  invalidate() {
338
- container.invalidate();
330
+ list.invalidate();
331
+ search.invalidate();
339
332
  },
340
333
  handleInput(data: string) {
341
334
  // Detect keys via pi-tui's own parser — the same recognition
@@ -350,10 +343,11 @@ async function showEnhancedPicker(
350
343
  search.handleInput?.(data);
351
344
  applyFuzzy(search.getValue?.() ?? "");
352
345
  }
353
- container.invalidate();
346
+ list.invalidate();
354
347
  },
355
348
  };
356
349
  },
350
+ { overlay: true },
357
351
  );
358
352
 
359
353
  if (!result) return;