@fanchaozz/provider-manager 0.2.3 → 1.0.1

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": "@fanchaozz/provider-manager",
3
- "version": "0.2.3",
3
+ "version": "1.0.1",
4
4
  "description": "A pi extension that manages custom providers and models in ~/.pi/agent/models.json via a TUI dashboard, /providers slash command, and remote model sync.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/sync.ts CHANGED
@@ -80,7 +80,8 @@ export function inferInput(id: string): ("text" | "image")[] {
80
80
  }
81
81
 
82
82
  /** 把 FetchedModel 变成 ModelConfig。缺省值以 DEFAULT_MODEL_CONFIG 为准(reasoning=yes / input=[text,image] / ctx/max / thinkingLevelMap.medium=medium),
83
- * 启发式仅在缺省为 no 时下调(比如「明显不是 reasoning」)。可选 3 个参传入覆盖上下文窗口 / max / defaults。 */
83
+ * 启发式仅在缺省为 no 时下调(比如「明显不是 reasoning」)。可选 3 个参传入覆盖上下文窗口 / max / defaults。
84
+ * compat 同步拷默认(用户模板里已带 supportsDeveloperRole=false,新增 model 不应丢这项) */
84
85
  export function inferModel(id: string, fetched: FetchedModel, overrides?: { contextWindow?: number; maxTokens?: number; defaults?: typeof DEFAULT_MODEL_CONFIG }): ModelConfig {
85
86
  const cfg = overrides?.defaults ?? DEFAULT_MODEL_CONFIG;
86
87
  const heuristicReasoning = inferReasoning(id);
@@ -95,6 +96,7 @@ export function inferModel(id: string, fetched: FetchedModel, overrides?: { cont
95
96
  contextWindow: overrides?.contextWindow ?? cfg.contextWindow,
96
97
  maxTokens: overrides?.maxTokens ?? cfg.maxTokens,
97
98
  thinkingLevelMap: { ...cfg.thinkingLevelMap },
99
+ compat: cfg.compat ? { ...cfg.compat } : undefined,
98
100
  };
99
101
  }
100
102
 
package/ui.ts CHANGED
@@ -12,6 +12,7 @@ import { readFileSync, existsSync } from "node:fs";
12
12
  import { readModelsJson, getModelsJsonPath, maskApiKey, type ModelsJson, type ProviderConfig, type ModelConfig } from "./store.ts";
13
13
  import {
14
14
  addProviderFlow,
15
+ addModelFlow,
15
16
  editProviderFlow,
16
17
  deleteProviderFlow,
17
18
  editModelFlow,
@@ -297,7 +298,10 @@ class Dashboard {
297
298
  if (this.pane === "provider") {
298
299
  void this.runForm(addProviderFlow);
299
300
  } else {
300
- this.ctx.ui.notify("model 不能直接新增,请用 sync(按 y)", "info");
301
+ // model 面板 n → 调用 addModelFlow(sync 拉不到时使用模板新增)
302
+ const sel = this.providers[this.providerIndex];
303
+ if (sel) void this.runForm(addModelFlow, sel.id);
304
+ else this.ctx.ui.notify("No provider selected", "warning");
301
305
  }
302
306
  return;
303
307
  }
@@ -487,7 +491,7 @@ class Dashboard {
487
491
  } else {
488
492
  const parts = ["↑↓/jk nav", "←→ pane"];
489
493
  if (this.pane === "provider") parts.push("n new", "Enter edit", "y sync");
490
- else parts.push("Enter edit", "y sync", "t test", "T test-all");
494
+ else parts.push("n new", "Enter edit", "y sync", "t test", "T test-all");
491
495
  parts.push("d del", "? help", "q close");
492
496
  lines.push(th.fg("dim", " " + parts.join(" · ")));
493
497
  }
@@ -698,9 +702,9 @@ class Dashboard {
698
702
  ];
699
703
  // 按面板增补特有项
700
704
  if (this.pane === "provider") {
701
- lines.splice(5, 0, " n new provider (models are added via sync)");
705
+ lines.splice(5, 0, " n new provider (model 仍走 sync)");
702
706
  } else {
703
- lines.splice(5, 0, " t / T test current model / test all in provider");
707
+ lines.splice(5, 0, " n new model manually (sync 拉不到时;走 defaultModel 模板)", " t / T test current model / test all in provider");
704
708
  }
705
709
  lines.push("", th.fg("dim", " y sync"));
706
710
  return lines.map((l) => truncateToWidth(l, width));