pi-hide-providers 0.1.6 → 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.
- package/hide-providers.ts +45 -3
- package/package.json +3 -3
package/hide-providers.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getAgentDir, CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import {
|
|
4
4
|
HIDE_COMMAND_DESCRIPTION,
|
|
5
5
|
CONFIG_FILENAME,
|
|
@@ -31,7 +31,7 @@ const globalConfigDir = getAgentDir();
|
|
|
31
31
|
const globalConfigPath = join(globalConfigDir, CONFIG_FILENAME);
|
|
32
32
|
|
|
33
33
|
function getProjectConfigPath(cwd: string): string {
|
|
34
|
-
return join(cwd,
|
|
34
|
+
return join(cwd, CONFIG_DIR_NAME, CONFIG_FILENAME);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// Read config from disk (project overrides global)
|
|
@@ -59,7 +59,7 @@ function readConfig(cwd: string): HideProvidersConfig {
|
|
|
59
59
|
function writeConfig(cwd: string, config: HideProvidersConfig): string {
|
|
60
60
|
const projectPath = getProjectConfigPath(cwd);
|
|
61
61
|
const path = existsSync(getProjectConfigPath(cwd)) ? projectPath : globalConfigPath;
|
|
62
|
-
const dir = path === projectPath ? join(cwd,
|
|
62
|
+
const dir = path === projectPath ? join(cwd, CONFIG_DIR_NAME) : globalConfigDir;
|
|
63
63
|
|
|
64
64
|
if (!existsSync(dir)) {
|
|
65
65
|
mkdirSync(dir, { recursive: true });
|
|
@@ -366,6 +366,48 @@ async function showHideSelector(
|
|
|
366
366
|
name: (m.name ?? m.id) as string,
|
|
367
367
|
}));
|
|
368
368
|
|
|
369
|
+
if (ctx.mode !== "tui") {
|
|
370
|
+
if (!ctx.hasUI) {
|
|
371
|
+
ctx.ui.notify("/hide-models requires a UI (TUI or GUI).", "error");
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (models.length === 0) {
|
|
375
|
+
ctx.ui.notify("No models found.", "warning");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const items = models.map((m) => {
|
|
379
|
+
const hidden = isHidden(currentRules, m.provider, m.id);
|
|
380
|
+
return `${m.name} (${formatRule({ provider: m.provider, model: m.id })}): ${hidden ? "hidden" : "visible"}`;
|
|
381
|
+
});
|
|
382
|
+
const pick = await ctx.ui.select("Hide models \u2014 pick a model to toggle", items);
|
|
383
|
+
if (pick === undefined) return;
|
|
384
|
+
const idx = items.indexOf(pick);
|
|
385
|
+
if (idx < 0) return;
|
|
386
|
+
const m = models[idx];
|
|
387
|
+
if (!m) return;
|
|
388
|
+
const matches = (r: HideRule) => r.provider === m.provider && r.model === m.id;
|
|
389
|
+
const hasExact = currentRules.some(matches);
|
|
390
|
+
const newRules = hasExact
|
|
391
|
+
? currentRules.filter((r) => !matches(r))
|
|
392
|
+
: deduplicateRules([...currentRules, { provider: m.provider, model: m.id }]);
|
|
393
|
+
const configPath = writeConfig(ctx.cwd, { hide: newRules });
|
|
394
|
+
setRules(newRules);
|
|
395
|
+
if (newRules.length === 0) {
|
|
396
|
+
unpatchRegistry(registry);
|
|
397
|
+
ctx.ui.notify(
|
|
398
|
+
`Model ${m.name} visible. All models visible — registry unpatched (config: ${configPath}). Run /hide-models again for more.`,
|
|
399
|
+
"info",
|
|
400
|
+
);
|
|
401
|
+
} else {
|
|
402
|
+
patchRegistry(registry, () => newRules);
|
|
403
|
+
ctx.ui.notify(
|
|
404
|
+
`Model ${m.name} ${hasExact ? "visible" : "hidden"}. ${newRules.length} rule(s) active (config: ${configPath}). Run /hide-models again for more.`,
|
|
405
|
+
"info",
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
369
411
|
const result = await ctx.ui.custom<HideProviderSelectorResult>(
|
|
370
412
|
(tui, theme, _kb, done) => {
|
|
371
413
|
const selector = new HideProviderSelectorComponent(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-hide-providers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Hide providers and models from pi's model selector — filter the /model list and Ctrl+P cycling via a configurable blocklist",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Tom X Nguyen",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
35
|
-
"@earendil-works/pi-tui": "0.
|
|
34
|
+
"@earendil-works/pi-coding-agent": "0.80.6",
|
|
35
|
+
"@earendil-works/pi-tui": "0.80.6",
|
|
36
36
|
"@types/node": "25.9.1",
|
|
37
37
|
"@vitest/coverage-v8": "4.1.7",
|
|
38
38
|
"knip": "6.14.1",
|