@fanchaozz/provider-manager 0.2.2 → 0.2.3
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 +47 -47
- package/ui.ts +13 -7
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fanchaozz/provider-manager",
|
|
3
|
-
"version": "0.2.
|
|
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
|
-
"type": "module",
|
|
6
|
-
"main": "index.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"*.ts",
|
|
9
|
-
"README.md",
|
|
10
|
-
"README_EN.md"
|
|
11
|
-
],
|
|
12
|
-
"keywords": [
|
|
13
|
-
"pi-package",
|
|
14
|
-
"pi-extension",
|
|
15
|
-
"provider",
|
|
16
|
-
"model",
|
|
17
|
-
"ai"
|
|
18
|
-
],
|
|
19
|
-
"pi": {
|
|
20
|
-
"extensions": [
|
|
21
|
-
"./"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"author": "fanchaozz <fanchaozz@users.noreply.github.com>",
|
|
26
|
-
"homepage": "https://github.com/fanchaozz/provider-manager#readme",
|
|
27
|
-
"repository": {
|
|
28
|
-
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/fanchaozz/provider-manager.git"
|
|
30
|
-
},
|
|
31
|
-
"bugs": {
|
|
32
|
-
"url": "https://github.com/fanchaozz/provider-manager/issues"
|
|
33
|
-
},
|
|
34
|
-
"engines": {
|
|
35
|
-
"node": ">=20"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"@earendil-works/pi-coding-agent": "*"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"test": "for f in _test_*.mts; do node --experimental-strip-types --no-warnings \"$f\" 2>&1 | tail -3; done",
|
|
42
|
-
"ci:test": "npm install --no-save @earendil-works/pi-coding-agent && for f in _test_*.mts; do node --experimental-strip-types --no-warnings \"$f\" 2>&1 | tail -3; done"
|
|
43
|
-
},
|
|
44
|
-
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fanchaozz/provider-manager",
|
|
3
|
+
"version": "0.2.3",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"*.ts",
|
|
9
|
+
"README.md",
|
|
10
|
+
"README_EN.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"pi-package",
|
|
14
|
+
"pi-extension",
|
|
15
|
+
"provider",
|
|
16
|
+
"model",
|
|
17
|
+
"ai"
|
|
18
|
+
],
|
|
19
|
+
"pi": {
|
|
20
|
+
"extensions": [
|
|
21
|
+
"./"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "fanchaozz <fanchaozz@users.noreply.github.com>",
|
|
26
|
+
"homepage": "https://github.com/fanchaozz/provider-manager#readme",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/fanchaozz/provider-manager.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/fanchaozz/provider-manager/issues"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "for f in _test_*.mts; do node --experimental-strip-types --no-warnings \"$f\" 2>&1 | tail -3; done",
|
|
42
|
+
"ci:test": "npm install --no-save @earendil-works/pi-coding-agent && for f in _test_*.mts; do node --experimental-strip-types --no-warnings \"$f\" 2>&1 | tail -3; done"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/ui.ts
CHANGED
|
@@ -291,6 +291,16 @@ class Dashboard {
|
|
|
291
291
|
this.invalidate();
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
|
+
// 空列表下"新增 provider"是唯一可执行动作,必须在导航块之前判定。
|
|
295
|
+
// 否则 n 会落到 else if 链外的 if (items.length === 0) 分支被吞掉。
|
|
296
|
+
if (data === "n") {
|
|
297
|
+
if (this.pane === "provider") {
|
|
298
|
+
void this.runForm(addProviderFlow);
|
|
299
|
+
} else {
|
|
300
|
+
this.ctx.ui.notify("model 不能直接新增,请用 sync(按 y)", "info");
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
294
304
|
// 导航(循环:第 1 个按 ↑ 跳最后,最后按 ↓ 跳第 1 个)
|
|
295
305
|
const items = this.pane === "provider" ? this.providers : (this.providers[this.providerIndex]?.models ?? []);
|
|
296
306
|
if (items.length === 0) {
|
|
@@ -313,13 +323,6 @@ class Dashboard {
|
|
|
313
323
|
const m = prov?.models[this.modelIndex];
|
|
314
324
|
if (prov && m) void this.runForm(editModelFlow, prov.id, m.id);
|
|
315
325
|
}
|
|
316
|
-
} else if (data === "n") {
|
|
317
|
-
// n: 新增 provider。仅 provider 面板支持;model 面板的 n 跳到 sync 提示。
|
|
318
|
-
if (this.pane === "provider") {
|
|
319
|
-
void this.runForm(addProviderFlow);
|
|
320
|
-
} else {
|
|
321
|
-
this.ctx.ui.notify("model 不能直接新增,请用 sync(按 y)", "info");
|
|
322
|
-
}
|
|
323
326
|
} else if (data === "d") {
|
|
324
327
|
const prov = this.providers[this.providerIndex];
|
|
325
328
|
if (this.pane === "provider" && prov) {
|
|
@@ -478,6 +481,9 @@ class Dashboard {
|
|
|
478
481
|
lines.push(th.fg("borderMuted", "─".repeat(width)));
|
|
479
482
|
if (this.help) {
|
|
480
483
|
lines.push(...this.renderHelp(width, th));
|
|
484
|
+
} else if (this.providers.length === 0) {
|
|
485
|
+
// 空态:导航/编辑/同步/删除 均无意义,只保留有效动作
|
|
486
|
+
lines.push(th.fg("dim", " n add first provider · ? help · q close"));
|
|
481
487
|
} else {
|
|
482
488
|
const parts = ["↑↓/jk nav", "←→ pane"];
|
|
483
489
|
if (this.pane === "provider") parts.push("n new", "Enter edit", "y sync");
|