@xynogen/pix-models 0.2.6 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-models",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Pi extension — enhanced /models picker with BenchLM ranks",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@xynogen/pix-data": "^0.5.0",
47
47
  "@xynogen/pix-pretty": "^1.11.2",
48
- "@xynogen/pix-runtime": "^0.8.0"
48
+ "@xynogen/pix-runtime": "^0.10.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@earendil-works/pi-coding-agent": "*",
package/src/models.ts CHANGED
@@ -8,7 +8,11 @@
8
8
  * Sorted by benchlm rank when available (best first), then alphabetical.
9
9
  */
10
10
 
11
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
11
+ import {
12
+ type ExtensionAPI,
13
+ type ExtensionContext,
14
+ SettingsManager,
15
+ } from "@earendil-works/pi-coding-agent";
12
16
  import {
13
17
  fuzzyFilter,
14
18
  Input,
@@ -574,8 +578,23 @@ async function showEnhancedPicker(pi: ExtensionAPI, ctx: ExtensionContext): Prom
574
578
  return;
575
579
  }
576
580
  const ok = await pi.setModel(picked);
577
- if (ok) ctx.ui.notify(`Switched to ${picked.name ?? picked.id}`, "info");
578
- else ctx.ui.notify(`Failed to switch to ${picked.id}`, "error");
581
+ if (!ok) {
582
+ ctx.ui.notify(`Failed to switch to ${picked.id}`, "error");
583
+ return;
584
+ }
585
+
586
+ const settings = SettingsManager.create(ctx.cwd);
587
+ settings.setDefaultModelAndProvider(picked.provider, picked.id);
588
+ await settings.flush();
589
+ const saveError = settings.drainErrors()[0];
590
+ if (saveError) {
591
+ ctx.ui.notify(
592
+ `Switched to ${picked.name ?? picked.id}, but failed to save the default: ${saveError.error.message}`,
593
+ "warning",
594
+ );
595
+ return;
596
+ }
597
+ ctx.ui.notify(`Default model: ${picked.provider}/${picked.id}`, "info");
579
598
  }
580
599
 
581
600
  export default function modelPickerExtension(pi: ExtensionAPI) {
@@ -19,30 +19,21 @@
19
19
  * 3. createRequire against the extension's own node_modules.
20
20
  */
21
21
 
22
- import {
23
- accessSync,
24
- constants,
25
- existsSync,
26
- readdirSync,
27
- readFileSync,
28
- realpathSync,
29
- writeFileSync,
30
- } from "node:fs";
22
+ import { existsSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
31
23
  import { createRequire } from "node:module";
32
24
  import { homedir } from "node:os";
33
- import { delimiter, join, sep } from "node:path";
25
+ import { join, sep } from "node:path";
26
+ import { findExecutableSync } from "@xynogen/pix-runtime/which";
34
27
 
35
- /** Locate `pi` on PATH (a pure-JS `which`), returning its real (symlink-resolved) path. */
28
+ /** Locate `pi` on PATH, returning its real (symlink-resolved) path. */
36
29
  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 {}
30
+ const found = findExecutableSync("pi");
31
+ if (!found) return undefined;
32
+ try {
33
+ return realpathSync(found);
34
+ } catch {
35
+ return found;
44
36
  }
45
- return undefined;
46
37
  }
47
38
 
48
39
  // The assignment appears once per build. `\s*=\s*\[` avoids the `.map(...)`