@xynogen/pix-models 0.2.1 → 0.2.3
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 +1 -1
- package/src/models.ts +10 -7
- package/src/patch-builtin.ts +26 -11
package/package.json
CHANGED
package/src/models.ts
CHANGED
|
@@ -231,6 +231,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
231
231
|
// ModelRegistry instance (verified in runner.js) with refresh() and an
|
|
232
232
|
// async-capable getAvailable(). Reach through the narrowed type.
|
|
233
233
|
type AvailableModels = ReturnType<typeof ctx.modelRegistry.getAvailable>;
|
|
234
|
+
// SAFETY: Runtime ModelRegistry includes refresh and async availability missing from public types.
|
|
234
235
|
const registry = ctx.modelRegistry as unknown as {
|
|
235
236
|
refresh?: () => void;
|
|
236
237
|
getAvailable(): AvailableModels | Promise<AvailableModels>;
|
|
@@ -313,8 +314,8 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
313
314
|
// Mute low-info parts (separators, padding, #, ☆) so the actual values pop.
|
|
314
315
|
const mute = (s: string) => theme.fg("muted", s);
|
|
315
316
|
const guide = (key: string, action: string) =>
|
|
316
|
-
theme.fg("text", key) + theme.fg("
|
|
317
|
-
const guideSep = theme.fg("
|
|
317
|
+
theme.fg("text", key) + theme.fg("muted", ` ${action}`);
|
|
318
|
+
const guideSep = theme.fg("muted", " · ");
|
|
318
319
|
|
|
319
320
|
// Track rank per item value so fuzzy results can prioritize ranked models.
|
|
320
321
|
const rankByValue = new Map<string, number>();
|
|
@@ -369,7 +370,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
369
370
|
const rawCost = fmtCost(dev);
|
|
370
371
|
let costSeg: string;
|
|
371
372
|
if (rawCost === "—") {
|
|
372
|
-
costSeg = theme.fg("
|
|
373
|
+
costSeg = theme.fg("muted", "—".padEnd(maxCostWidth));
|
|
373
374
|
} else if (rawCost === "free") {
|
|
374
375
|
costSeg = mute("free".padEnd(maxCostWidth));
|
|
375
376
|
} else {
|
|
@@ -415,7 +416,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
415
416
|
selectedPrefix: (t) => theme.fg(accent, t),
|
|
416
417
|
selectedText: (t) => theme.fg(accent, t),
|
|
417
418
|
description: (t) => t, // raw — per-segment colors set in items.map
|
|
418
|
-
scrollInfo: (t) => theme.fg("
|
|
419
|
+
scrollInfo: (t) => theme.fg("muted", t),
|
|
419
420
|
noMatch: (t) => theme.fg("warning", t),
|
|
420
421
|
},
|
|
421
422
|
{
|
|
@@ -430,6 +431,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
430
431
|
search.onEscape = () => done(null);
|
|
431
432
|
|
|
432
433
|
const applyFuzzy = (query: string) => {
|
|
434
|
+
// SAFETY: SelectList exposes these stable fields internally for in-place filtering.
|
|
433
435
|
const internal = list as unknown as {
|
|
434
436
|
items: SelectItem[];
|
|
435
437
|
filteredItems: SelectItem[];
|
|
@@ -464,11 +466,11 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
464
466
|
? theme.getThinkingBorderColor(resolved)(label)
|
|
465
467
|
: theme.fg("dim", label);
|
|
466
468
|
return (
|
|
467
|
-
theme.fg("
|
|
469
|
+
theme.fg("dim", "Thinking: ") +
|
|
468
470
|
coloredLabel +
|
|
469
|
-
theme.fg("
|
|
471
|
+
theme.fg("muted", " (") +
|
|
470
472
|
guide("←/→", "adjust") +
|
|
471
|
-
theme.fg("
|
|
473
|
+
theme.fg("muted", ")")
|
|
472
474
|
);
|
|
473
475
|
};
|
|
474
476
|
|
|
@@ -489,6 +491,7 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
|
|
|
489
491
|
],
|
|
490
492
|
body: list.render(inner),
|
|
491
493
|
selectedBodyRange: (() => {
|
|
494
|
+
// SAFETY: SelectList tracks selectedIndex internally for pager synchronization.
|
|
492
495
|
const internal = list as unknown as { selectedIndex: number };
|
|
493
496
|
return pager.selectedRange({
|
|
494
497
|
start: internal.selectedIndex,
|
package/src/patch-builtin.ts
CHANGED
|
@@ -19,11 +19,31 @@
|
|
|
19
19
|
* 3. createRequire against the extension's own node_modules.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
22
|
+
import {
|
|
23
|
+
accessSync,
|
|
24
|
+
constants,
|
|
25
|
+
existsSync,
|
|
26
|
+
readdirSync,
|
|
27
|
+
readFileSync,
|
|
28
|
+
realpathSync,
|
|
29
|
+
writeFileSync,
|
|
30
|
+
} from "node:fs";
|
|
24
31
|
import { createRequire } from "node:module";
|
|
25
32
|
import { homedir } from "node:os";
|
|
26
|
-
import { join, sep } from "node:path";
|
|
33
|
+
import { delimiter, join, sep } from "node:path";
|
|
34
|
+
|
|
35
|
+
/** Locate `pi` on PATH (a pure-JS `which`), returning its real (symlink-resolved) path. */
|
|
36
|
+
function resolvePiBinary(): string | undefined {
|
|
37
|
+
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
38
|
+
if (!dir) continue;
|
|
39
|
+
const candidate = join(dir, "pi");
|
|
40
|
+
try {
|
|
41
|
+
accessSync(candidate, constants.X_OK);
|
|
42
|
+
return realpathSync(candidate);
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
27
47
|
|
|
28
48
|
// The assignment appears once per build. `\s*=\s*\[` avoids the `.map(...)`
|
|
29
49
|
// references and tolerates both `= [` (pretty) and `=[` (minified) spacing.
|
|
@@ -42,16 +62,11 @@ function packageRoots(): string[] {
|
|
|
42
62
|
if (r && !roots.includes(r)) roots.push(r);
|
|
43
63
|
};
|
|
44
64
|
|
|
45
|
-
// 1. Resolve via the
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
encoding: "utf8",
|
|
49
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
50
|
-
}).trim();
|
|
65
|
+
// 1. Resolve via the `pi` binary on PATH → realpath → strip at /dist/.
|
|
66
|
+
const piReal = resolvePiBinary();
|
|
67
|
+
if (piReal) {
|
|
51
68
|
const idx = piReal.indexOf(`${sep}dist${sep}`);
|
|
52
69
|
if (idx >= 0) pushRoot(piReal.slice(0, idx));
|
|
53
|
-
} catch {
|
|
54
|
-
// `pi` not on PATH or `which`/`realpath` unavailable — skip
|
|
55
70
|
}
|
|
56
71
|
|
|
57
72
|
// 2. Well-known global install locations.
|