@mcowger/pi-plexus 1.2.3 → 1.2.4
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/README.md +8 -2
- package/dist/extension.js +58 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,7 +98,6 @@ You will be prompted for:
|
|
|
98
98
|
|
|
99
99
|
- **Plexus base URL** — e.g. `https://plexus.example.com`
|
|
100
100
|
- **Plexus API key**
|
|
101
|
-
- **Default model** (optional)
|
|
102
101
|
|
|
103
102
|
To force a model refresh:
|
|
104
103
|
|
|
@@ -106,6 +105,13 @@ To force a model refresh:
|
|
|
106
105
|
/plexus refresh
|
|
107
106
|
```
|
|
108
107
|
|
|
108
|
+
Set the model Pi should use by default. With no model ID, Pi opens a selector; you can also pass the exact Plexus model ID directly:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
/plexus set-default-model
|
|
112
|
+
/plexus set-default-model claude-sonnet-4-5
|
|
113
|
+
```
|
|
114
|
+
|
|
109
115
|
Use `/login plexus` for setup and `/logout plexus` to remove stored credentials.
|
|
110
116
|
|
|
111
117
|
### OpenCode
|
|
@@ -157,7 +163,7 @@ export PLEXUS_API_KEY=your-api-key
|
|
|
157
163
|
|
|
158
164
|
```
|
|
159
165
|
~/.pi/agent/extensions/plexus/
|
|
160
|
-
config.json # base URL and optional default model
|
|
166
|
+
config.json # base URL and optional default model (set via /plexus set-default-model)
|
|
161
167
|
plexus-models-cache.json # last-fetched model list (startup cache)
|
|
162
168
|
plexus-models-response.json # raw API response (diagnostics)
|
|
163
169
|
plexus.log # extension activity log
|
package/dist/extension.js
CHANGED
|
@@ -328,6 +328,13 @@ async function saveBaseUrl(baseUrl, defaultModel) {
|
|
|
328
328
|
`, "utf8");
|
|
329
329
|
cachedConfig = config;
|
|
330
330
|
}
|
|
331
|
+
async function saveDefaultModel(defaultModel) {
|
|
332
|
+
await mkdir(getConfigDir(), { recursive: true });
|
|
333
|
+
const config = { ...getConfigSync(), defaultModel };
|
|
334
|
+
await writeFile(getConfigPath(), `${JSON.stringify(config, null, 2)}
|
|
335
|
+
`, "utf8");
|
|
336
|
+
cachedConfig = config;
|
|
337
|
+
}
|
|
331
338
|
function getRawBaseUrl() {
|
|
332
339
|
const config = getConfigSync();
|
|
333
340
|
return resolveStringOption(process.env[ENV_API_URL]) ?? resolveStringOption(process.env[ENV_BASE_URL]) ?? resolveStringOption(config.baseUrl) ?? null;
|
|
@@ -504,17 +511,38 @@ function plexusExtension(pi) {
|
|
|
504
511
|
await doRefresh(pi, apiKey, ctx, true);
|
|
505
512
|
});
|
|
506
513
|
pi.registerCommand("plexus", {
|
|
507
|
-
description: "Plexus provider commands: refresh (setup: /login plexus)",
|
|
508
|
-
getArgumentCompletions: () =>
|
|
509
|
-
|
|
510
|
-
|
|
514
|
+
description: "Plexus provider commands: refresh, set-default-model (setup: /login plexus)",
|
|
515
|
+
getArgumentCompletions: (prefix) => {
|
|
516
|
+
const subcommands = [
|
|
517
|
+
{ value: "refresh", label: "refresh", description: "Refresh Plexus models from the API" },
|
|
518
|
+
{ value: "set-default-model", label: "set-default-model", description: "Choose the model Pi should use by default" }
|
|
519
|
+
];
|
|
520
|
+
if (!prefix.includes(" ")) {
|
|
521
|
+
return subcommands.filter((command) => command.value.startsWith(prefix));
|
|
522
|
+
}
|
|
523
|
+
const [subcommand, ...rest] = prefix.split(/\s+/);
|
|
524
|
+
if (subcommand !== "set-default-model")
|
|
525
|
+
return null;
|
|
526
|
+
const modelPrefix = rest.join(" ");
|
|
527
|
+
const choices = currentModels.map((model) => ({
|
|
528
|
+
value: model.id,
|
|
529
|
+
label: model.name === model.id ? model.id : `${model.name} (${model.id})`
|
|
530
|
+
}));
|
|
531
|
+
const filtered = choices.filter((choice) => choice.value.toLowerCase().startsWith(modelPrefix.toLowerCase()));
|
|
532
|
+
return filtered.length > 0 ? filtered : null;
|
|
533
|
+
},
|
|
511
534
|
handler: async (args, ctx) => {
|
|
512
|
-
const
|
|
535
|
+
const trimmed = args.trim();
|
|
536
|
+
const sub = trimmed.toLowerCase();
|
|
513
537
|
if (sub === "refresh" || sub === "") {
|
|
514
538
|
await handleRefresh(pi, ctx);
|
|
515
539
|
return;
|
|
516
540
|
}
|
|
517
|
-
|
|
541
|
+
if (sub === "set-default-model" || sub.startsWith("set-default-model ")) {
|
|
542
|
+
await handleSetDefaultModel(pi, ctx, trimmed.slice("set-default-model".length).trim());
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
ctx.ui.notify(`Unknown sub-command: "${args}". Use /login plexus, /plexus refresh, or /plexus set-default-model.`, "warning");
|
|
518
546
|
}
|
|
519
547
|
});
|
|
520
548
|
}
|
|
@@ -552,7 +580,7 @@ function createPlexusLoginProvider(pi) {
|
|
|
552
580
|
if (!baseUrl)
|
|
553
581
|
return models;
|
|
554
582
|
const apiBase = baseUrl.trim().replace(/\/+$/, "").endsWith("/v1") ? baseUrl.trim().replace(/\/+$/, "") : `${baseUrl.trim().replace(/\/+$/, "")}/v1`;
|
|
555
|
-
return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: apiBase } : model);
|
|
583
|
+
return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: adjustBaseUrl(apiBase, model.api) } : model);
|
|
556
584
|
}
|
|
557
585
|
};
|
|
558
586
|
}
|
|
@@ -565,6 +593,29 @@ async function handleRefresh(pi, ctx) {
|
|
|
565
593
|
ctx.ui.notify("Refreshing Plexus models\u2026", "info");
|
|
566
594
|
await doRefresh(pi, apiKey, ctx, true);
|
|
567
595
|
}
|
|
596
|
+
async function handleSetDefaultModel(pi, ctx, requestedModelId) {
|
|
597
|
+
let modelId = requestedModelId;
|
|
598
|
+
if (!modelId) {
|
|
599
|
+
if (currentModels.length === 0) {
|
|
600
|
+
ctx.ui.notify("No Plexus models are available. Run /plexus refresh first.", "warning");
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const choices = currentModels.map((model2) => model2.name === model2.id ? model2.id : `${model2.name} (${model2.id})`);
|
|
604
|
+
const selected = await ctx.ui.select("Select the Plexus default model:", choices);
|
|
605
|
+
if (!selected)
|
|
606
|
+
return;
|
|
607
|
+
const selectedIndex = choices.indexOf(selected);
|
|
608
|
+
modelId = currentModels[selectedIndex]?.id ?? "";
|
|
609
|
+
}
|
|
610
|
+
const model = currentModels.find((candidate) => candidate.id === modelId);
|
|
611
|
+
if (!model) {
|
|
612
|
+
ctx.ui.notify(`Plexus model not found: "${modelId}". Run /plexus refresh and choose a model from the available list.`, "error");
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
await saveDefaultModel(model.id);
|
|
616
|
+
const active = await pi.setModel(model);
|
|
617
|
+
ctx.ui.notify(active ? `Default Plexus model set to ${model.id}.` : `Default Plexus model set to ${model.id}; it will be selected when Plexus authentication is available.`, active ? "info" : "warning");
|
|
618
|
+
}
|
|
568
619
|
async function doRefresh(pi, apiKey, ctx, setDefault) {
|
|
569
620
|
const modelsUrl = getModelsUrl();
|
|
570
621
|
const baseUrl = getBaseUrl();
|