pi-hide-providers 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/hide-providers.ts +42 -0
  2. package/package.json +1 -1
package/hide-providers.ts CHANGED
@@ -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.7",
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",