plugins: a plugin's package.json names its row with magpie.name (#4558, MYCF711)

A plugin installed from git whose package.json says
"magpie": { "name": "华为云 HUAWEI" } read as its dependency key
(magpie-officeace) on Settings → Plugins. Bun takes no non-ASCII key, so
a package outside the community's list had no way to show a readable
name. magpie.name was never read at all: #3608's route (MYCF711's branch
1cc33700) didn't reach main, so no release has it, git or npm.

plugin.InstalledName reads magpie.name from the installed package's own
package.json, beside magpie.icon (installedOwn, one parse for both): one
line of at most 80 bytes, no control or format characters (a bidi
override would show it as another name), else nothing. /api/plugins gives
each row it as ownName, and plugins.js's shownName takes it after the
community list's name and before the git package or the spec, so a
listed package is still named by the list. The row's page, the "is up to
date" status and every message that names the row (options, prefer, Update
all) go through shownName; a page plugin's sidebar tab takes it when the
page names no title (windowParts). It is never used to resolve a name and
never shown with the community badge. Not changed: the CLI's plugin list
(the dependency key, as the reporter expects), Discover's cards for
uninstalled GitHub/npm packages, and magpie.summary. Documented in
docs/reference.md and site/public/docs (en, zh, ja).

Run:
- mote: go test -timeout 45m ./internal/plugin/ ./internal/gui/ — plugin
  ok; gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  the AppKit window tests killed at their deadline (TestPanelCloseHidesIt,
  TestPluginPageLoadsItsFilesInTheWindow, TestMainWindowCorners, …;
  #4125, #2645). The first three run the same red on origin/main 7aa67e9e5.
- mote: go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  internal/plugin and internal/gui: clean. gofmt -l internal/: nothing.
- wsl-run (magpie-desktop): plugin-own-name.test.cjs, Chromium and
  WebKit, en/zh/zh-TW/ja/de at 980 and 420: 22/22. Every plugin*,
  plugins-*, agent-plugin*, account-plugin*, signin-paste-plugin,
  sidebar* and i18n-keys file (67): all green but i18n-keys "a plugin's words are its own" (#4524), plugin-card-update webkit en/zh (#3079) and plugin-github-filter webkit ja 420px (#4564, filed now), each red the same at origin/main 7aa67e9e5
- Rebased on origin/main 7b883cc61, mote: -run "Budget|OwnName|TestPluginsState|
  TestWindowParts" on internal/gui and internal/plugin: ok (core scripts
  under the budget, no raise).

Broken by hand:
- InstalledName returning "": TestPluginsStateGivesAGitPackagesOwnName red
  (ownName "", and the sidebar title magpie-officeace).
- shownName without e.ownName: plugin-own-name.test.cjs red, the row
  reads 'magpie-officeace'.

Not tried: the desktop window itself, and a real git repository with
magpie.name (the fixture is shaped from the reporter's installed
package.json: name magpie-officeace, version 0.2.4).
This commit is contained in:
yetone
2026-10-31 18:30:39 +08:00
parent 7b883cc617
commit d8cf4f74f9
11 changed files with 259 additions and 15 deletions
+7
View File
@@ -1087,6 +1087,13 @@ OpenCode ignores:
and the icon the plugin market lists for the plugin is shown instead.
The `package.json` icon is also the card's picture under Discover →
Unofficial, on GitHub for a repository tagged `magpie-plugin`.
- **The plugin's name**: `"magpie": { "name": "…" }` in its `package.json`
names its row in Settings → Plugins, and its sidebar tab when its page
gives no title, for a plugin the community's list doesn't name (that
list's name wins). A package's npm name, which Bun keys it by, has to be
ASCII, so this is where a name like 华为云 HUAWEI goes. One line of at
most 80 bytes; anything else is ignored. It is the package's own word:
never shown as reviewed, and never used to find a plugin by name.
- **An API key's field**: a `type: "api"` method's `label` titles the key's
field, as OpenCode's dialog does (one that only says "API key" reads
"<provider> API key"), and its `placeholder` is the hint inside the field
+4 -3
View File
@@ -463,7 +463,7 @@
} else b.title = t("Fetches it from {repo} again", { repo: e.spec }) + "\n" + t("{have} installed, {repo} is at {head}", { have: e.commit, repo: e.spec, head: e.head });
b.onclick = (ev) => {
ev.stopPropagation();
act(pkg, "upgrade", { spec: e.spec }, () => status(npm ? t("{name} updated to v{v}", { name: l?.name || pkg, v: e.latest }) : t("{name} is up to date", { name: e.package || e.spec }), "ok"));
act(pkg, "upgrade", { spec: e.spec }, () => status(npm ? t("{name} updated to v{v}", { name: l?.name || pkg, v: e.latest }) : t("{name} is up to date", { name: shownName(e) }), "ok"));
};
b.onkeydown = (ev) => ev.stopPropagation();
return true;
@@ -1154,10 +1154,11 @@
}
// an installed plugin's name as its row shows it: the market's, else the
// one its package.json gives itself (magpie.name, #4558), else the
// package's or the folder's
function shownName(e) {
const pkg = name(e.spec);
return (listings || []).find((x) => x.package === pkg)?.name || (isGit(e.spec) && e.package) || label(e.spec);
return (listings || []).find((x) => x.package === pkg)?.name || e.ownName || (isGit(e.spec) && e.package) || label(e.spec);
}
function installedRow(e) {
@@ -1351,7 +1352,7 @@
};
val.append(onoff, rm);
r.append(val);
r.onclick = (ev) => { if (!ev.target.closest("button, .pm-opts")) detail(l || (isGit(e.spec) ? { package: e.spec, name: e.package || e.spec, icon: e.icon, npm: { version: e.version, repository: gitWeb(e.spec) } } : { package: pkg, name: label(e.spec), icon: e.icon, npm: { version: e.latest } })); };
r.onclick = (ev) => { if (!ev.target.closest("button, .pm-opts")) detail(l || (isGit(e.spec) ? { package: e.spec, name: shownName(e), icon: e.icon, npm: { version: e.version, repository: gitWeb(e.spec) } } : { package: pkg, name: shownName(e), icon: e.icon, npm: { version: e.latest } })); };
return r;
}
+5 -4
View File
@@ -1,6 +1,7 @@
package gui
import (
"cmp"
"context"
"crypto/hmac"
"crypto/rand"
@@ -69,7 +70,7 @@ type pluginPage struct {
Spec string `json:"spec"`
Name string `json:"name"` // its package's
Key string `json:"key"` // the window's page key
Title string `json:"title"` // the page's, or the package's short name
Title string `json:"title"` // the page's, or the package's magpie.name or short name
// Titles are its title by the window's language (plugin.PageSpec)
Titles map[string]string `json:"titles,omitempty"`
URL string `json:"url"` // the page, under pluginPagePrefix
@@ -108,7 +109,7 @@ type pluginPanel struct {
Name string `json:"name"` // its package's
Key string `json:"key"` // the panel's, among every plugin's
Slot string `json:"slot"` // the page it is in
Title string `json:"title"` // the panel's, or the package's short name
Title string `json:"title"` // the panel's, or the package's magpie.name or short name
Titles map[string]string `json:"titles,omitempty"`
URL string `json:"url"` // the panel, under pluginPagePrefix
Reads []string `json:"reads"` // what it may read, of plugin.PageReads
@@ -160,7 +161,7 @@ func windowParts() (pages []pluginPage, panels []pluginPanel) {
p.service = spec.Service
}
if p.Title == "" {
p.Title = plugin.ShortName(name)
p.Title = cmp.Or(plugin.InstalledName(e.Spec), plugin.ShortName(name))
}
if spec.Icon != "" {
p.Icon = pluginPagePrefix + tok + "/" + spec.Icon
@@ -185,7 +186,7 @@ func windowParts() (pages []pluginPage, panels []pluginPanel) {
p := pluginPanel{Spec: e.Spec, Name: name, Key: fmt.Sprintf("%s-%d", key, i), Slot: spec.Slot, Title: spec.Title, Titles: spec.Titles, Reads: reads,
token: tok, dir: spec.Dir, URL: pluginPagePrefix + tok + "/" + filepath.ToSlash(rel), file: filepath.ToSlash(rel), hosted: !only}
if p.Title == "" {
p.Title = plugin.ShortName(name)
p.Title = cmp.Or(plugin.InstalledName(e.Spec), plugin.ShortName(name))
}
panels = append(panels, p)
}
+4 -1
View File
@@ -105,6 +105,9 @@ type pluginEntryJSON struct {
// Package is the package installed from a git repository, which its
// own package.json names
Package string `json:"package,omitempty"`
// OwnName is the name its package.json gives itself (magpie.name),
// which its row shows when the community's list doesn't name it
OwnName string `json:"ownName,omitempty"`
// Commit is the commit of its repository a git one was installed at,
// and Head the commit the repository was at when last asked (asking
// it again is /api/plugins/git's): an update is out only when they
@@ -297,7 +300,7 @@ func pluginsState(ctx context.Context, w Windows) pluginsJSON {
}
}
for _, e := range l.Plugins {
j := pluginEntryJSON{Entry: e, Error: errs[e.Spec], Providers: names[e.Spec], Version: plugin.Installed(e.Spec), Named: answered}
j := pluginEntryJSON{Entry: e, Error: errs[e.Spec], Providers: names[e.Spec], Version: plugin.Installed(e.Spec), Named: answered, OwnName: plugin.InstalledName(e.Spec)}
if plugin.Gateway(plugin.Target(e.Spec)) != "" {
j.IsGateway = true
j.GatewayOnly = plugin.GatewayOnly(plugin.Target(e.Spec))
+86
View File
@@ -0,0 +1,86 @@
package gui
import (
"context"
"encoding/json"
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/plugin"
"github.com/yetone/magpie/internal/settings"
)
// #4558 (MYCF711): a plugin installed from git whose package.json says
// magpie.name ("华为云 HUAWEI") read as its dependency key
// (magpie-officeace) in Settings → Plugins. Bun takes no non-ASCII key, so
// the package's own name is the only readable one it has. The row is told
// it (ownName), as is the sidebar's title for a page that names none; a
// package that gives none is told none, and the community's list still
// names a package it lists.
func TestPluginsStateGivesAGitPackagesOwnName(t *testing.T) {
h := t.TempDir()
t.Setenv("HOME", h)
t.Setenv("USERPROFILE", h)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache"))
t.Setenv("MAGPIE_BUN", "")
t.Setenv("PATH", "")
write := func(path string, v any) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
b, _ := json.Marshal(v)
if err := os.WriteFile(path, b, 0o644); err != nil {
t.Fatal(err)
}
}
const (
office = "github:example/magpie-officeace"
plain = "github:example/magpie-loomy-auth"
bidi = "github:example/magpie-bidi"
)
dir := plugin.Dir()
// the reporter's: the dependency key bun installed it under, and the
// installed copy's package.json carrying the field
write(filepath.Join(dir, "package.json"), map[string]any{"dependencies": map[string]string{
"magpie-officeace": office, "magpie-loomy-auth": plain, "magpie-bidi": bidi,
}})
write(filepath.Join(dir, "node_modules", "magpie-officeace", "package.json"), map[string]any{
"name": "magpie-officeace", "version": "0.2.4", "main": "index.js",
"magpie": map[string]any{"name": "华为云 HUAWEI", "summary": "…", "page": map[string]any{"file": "page.html"}},
})
if err := os.WriteFile(filepath.Join(dir, "node_modules", "magpie-officeace", "page.html"), []byte("<p>hi</p>"), 0o644); err != nil {
t.Fatal(err)
}
write(filepath.Join(dir, "node_modules", "magpie-loomy-auth", "package.json"), map[string]any{
"name": "magpie-loomy-auth", "version": "0.1.0", "main": "index.js",
})
// a right-to-left override would show it as another name
write(filepath.Join(dir, "node_modules", "magpie-bidi", "package.json"), map[string]any{
"name": "magpie-bidi", "version": "0.1.0", "main": "index.js", "magpie": map[string]any{"name": "Qoder‮"},
})
write(filepath.Join(settings.Dir(), "plugins.json"), map[string]any{"plugins": []map[string]any{{"spec": office}, {"spec": plain}, {"spec": bidi}}})
got := map[string]pluginEntryJSON{}
for _, p := range pluginsState(context.Background(), nil).Plugins {
got[p.Spec] = p
}
if len(got) != 3 {
t.Fatalf("plugins: %v", got)
}
if o := got[office]; o.OwnName != "华为云 HUAWEI" || o.Package != "magpie-officeace" {
t.Errorf("the reporter's: ownName %q, package %q; want 华为云 HUAWEI, magpie-officeace", o.OwnName, o.Package)
}
if n := got[plain].OwnName; n != "" {
t.Errorf("one that gives no name: ownName %q, want none", n)
}
if n := got[bidi].OwnName; n != "" {
t.Errorf("a name with a bidi override: ownName %q, want none", n)
}
pages, _ := windowParts()
if len(pages) != 1 || pages[0].Title != "华为云 HUAWEI" {
t.Errorf("its page's sidebar title: %+v, want 华为云 HUAWEI", pages)
}
}
@@ -0,0 +1,83 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// #4558 (MYCF711): a plugin installed from git whose package.json gives
// itself a name in magpie.name ("华为云 HUAWEI") read as its dependency key
// (magpie-officeace) on Installed. Bun takes no non-ASCII key, so the
// package's own name is the only readable one it has. Its row and its page
// say that name, with the package beside it on the page; a git one that
// gives none still says its package; a package the community's list names
// is still named by the list, whatever its package.json says. Every
// language, both engines, wide and narrow; the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const OFFICE = "github:example/magpie-officeace", LOOMY = "github:example/magpie-loomy-auth", LISTED = "@magpie-community/opencode-qoder-auth";
const state = { bun: true, bunVersion: "1.3.0", picker: false, movable: [], plugins: [
{ spec: OFFICE, package: "magpie-officeace", ownName: "华为云 HUAWEI", version: "0.2.4", commit: "c594984", head: "c594984", providers: [], moved: [] },
{ spec: LOOMY, package: "magpie-loomy-auth", version: "0.1.0", commit: "8fd2d9a", head: "8fd2d9a", providers: [], moved: [] },
{ spec: LISTED, ownName: "Not the list's", version: "0.3.0", providers: [], moved: [] },
] };
const listings = [{ package: LISTED, name: "Qoder", summary: "Qoder's plan", providers: ["qoder"], community: true, github: { owner: "magpie-community", repo: "plugins" } }];
function server(lang) {
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
if (url.pathname === "/api/gateway/trace") return json({ routes: [] });
if (url.pathname === "/api/plugins") return json(state);
if (url.pathname === "/api/plugins/listings") return json({ listings });
if (url.pathname === "/api/plugins/market") return json({ listings, state });
if (url.pathname === "/api/plugins/search") return json({ hits: [] });
if (url.pathname === "/api/plugins/updates") return json({ waiting: [], updated: [] });
if (url.pathname === "/api/plugins/git") return json({ heads: { [OFFICE]: "c594984", [LOOMY]: "8fd2d9a" } });
if (url.pathname === "/api/plugins/page") return json({ readme: "# magpie-officeace", updated: "2026-10-01T10:00:00Z" });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
};
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(engine + ": a git plugin's row says the name its package.json gives", async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [980, 420]) {
await t.test(lang + " " + width, async () => {
const page = await (await browser.newContext({ viewport: { width, height: 820 } })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", server(lang));
await page.goto("http://magpie.test/?view=plugins");
const view = page.locator("#view-plugins");
const installed = await page.evaluate((l) => l === "en" ? "Installed" : I18N[l]["Installed"], lang);
await view.page().locator(":is(.lib-tabs .opt, .nav-s):visible", { hasText: installed }).click();
await view.locator(".pm-row").nth(2).waitFor();
const names = await view.locator(".pm-row .name > span:first-child").allTextContents();
assert.deepEqual([...names].sort(), ["Qoder", "magpie-loomy-auth", "华为云 HUAWEI"].sort(), "the package's own name, the package where it gives none, the list's where it lists one");
const row = view.locator(".pm-row").filter({ has: page.locator(".name", { hasText: "华为云 HUAWEI" }) });
const box = await row.boundingBox();
assert.ok(box.x >= 0 && box.x + box.width <= width, `the row fits: ${JSON.stringify(box)}`);
// its page says it too, with the repository it came from
await row.locator(".name").click();
const dlg = page.locator("#modal .pm-detail");
await dlg.waitFor();
assert.equal(await dlg.locator(".pm-dhead .pm-name b").textContent(), "华为云 HUAWEI");
assert.ok((await dlg.locator(".pm-dhead .pm-by").textContent()).includes(OFFICE), "the page names where it came from");
assert.deepEqual(errors, []);
await page.context().close();
});
}
});
}
+40 -7
View File
@@ -15,6 +15,8 @@ import (
"strings"
"sync"
"time"
"unicode"
"unicode/utf8"
"github.com/yetone/magpie/internal/appdir"
"github.com/yetone/magpie/internal/ghtoken"
@@ -707,20 +709,51 @@ func Installed(spec string) string {
// gives in magpie.icon, as ownIcon takes one: the plugin's own, for its
// row, apart from those its providers give themselves in the auth hook
// (#1775). "" for none, or a plugin that is one file.
func InstalledIcon(spec string) string {
func InstalledIcon(spec string) string { return ownIcon(installedOwn(spec).Icon) }
// InstalledName is the name the installed plugin spec's package.json
// gives itself in magpie.name, for its row when the community's list
// doesn't name it: a package's dependency key has to be ASCII for Bun,
// so one installed from git, or from npm outside the list, had no other
// way to show a readable name (#4558). It is the package's own word,
// never used to resolve a name; "" for none, one that isn't one short
// line, or a plugin that is one file.
func InstalledName(spec string) string { return ownName(installedOwn(spec).Name) }
// installedOwn is the magpie block of the installed plugin spec's
// package.json, as the package says it: zero for none, or one that
// can't be read.
func installedOwn(spec string) (own struct {
Icon string `json:"icon"`
Name string `json:"name"`
}) {
b, err := os.ReadFile(filepath.Join(Target(spec), "package.json"))
if err != nil {
return ""
return own
}
var p struct {
Magpie struct {
Icon string `json:"icon"`
} `json:"magpie"`
Magpie json.RawMessage `json:"magpie"`
}
if json.Unmarshal(b, &p) != nil {
if json.Unmarshal(b, &p) != nil || json.Unmarshal(p.Magpie, &own) != nil {
own.Icon, own.Name = "", ""
}
return own
}
// ownName is a package's magpie.name as a row may show it: one line of
// at most 80 bytes, with no control or format characters (a bidi
// override would make it read as another name); "" otherwise.
func ownName(said string) string {
n := strings.TrimSpace(said)
if n == "" || len(n) > 80 || !utf8.ValidString(n) {
return ""
}
return ownIcon(p.Magpie.Icon)
for _, r := range n {
if unicode.IsControl(r) || unicode.Is(unicode.Cf, r) {
return ""
}
}
return n
}
// Upgrade installs the newest version of one plugin: npm's, or its git
+27
View File
@@ -0,0 +1,27 @@
package plugin
import (
"strings"
"testing"
)
// A package's magpie.name is its own word on its row (#4558): one short
// line, as written, and nothing that could make it read as another name.
func TestOwnNameBounds(t *testing.T) {
for said, want := range map[string]string{
"华为云 HUAWEI": "华为云 HUAWEI",
" OfficeAce \n": "OfficeAce",
"": "",
"Two\nlines": "",
"Tab\tbed": "",
"Qoder‮": "",
"zero​width": "",
strings.Repeat("a", 80): strings.Repeat("a", 80),
strings.Repeat("a", 81): "",
"bad \xff utf-8": "",
} {
if got := ownName(said); got != want {
t.Errorf("ownName(%q) = %q, want %q", said, got, want)
}
}
}
+1
View File
@@ -264,6 +264,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
<div class="table-wrap"><table>
<tr><th>フィールド</th><th>意味</th></tr>
<tr><td><code>magpie.icon</code></td><td>プラグイン自身の画像。「発見」のカード(npm から、GitHub のものはリポジトリから読み込み)と「インストール済み」の行に表示され、自分の画像を持たないプロバイダにも使われます:<code>https://</code> URL または <code>data:image/…</code> URI、最大 1 MB。SVG、PNG など。</td></tr>
<tr><td><code>magpie.name</code></td><td>「インストール済み」の行に表示されるプラグインの名前。ページがタイトルを持たないときはサイドバーのタブ名にもなります。コミュニティのリストに載っていないプラグインだけに効きます(リストの名前が優先)。npm のパッケージ名は ASCII に限られるので、「华为云 HUAWEI」のような名前はここに書きます。1 行、最大 80 バイト。それ以外は無視されます。パッケージ自身の言葉として扱われ、レビュー済みとは表示されず、名前でプラグインを探すのにも使われません。</td></tr>
<tr><td><code>magpie.maxConcurrency</code></td><td>各アカウントが同時に受けるリクエスト数。1 から 1000 の整数。ユーザーがプロバイダに設定した上限が優先されます。</td></tr>
</table></div>
<p>同じフィールドは <code>auth</code> フックにも設定でき(<code>auth.icon</code>、<code>auth.maxConcurrency</code>)、そちらが <code>package.json</code> より優先されます。複数のプロバイダにサインインするプラグインは、プロバイダごとに <code>auth.icon</code> を設定し、<code>magpie.icon</code> をプラグイン自身のものにできます。</p>
+1
View File
@@ -264,6 +264,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
<div class="table-wrap"><table>
<tr><th>Field</th><th>Meaning</th></tr>
<tr><td><code>magpie.icon</code></td><td>The plugin’s picture, on its card in Discover (read from npm, or from the repository for one on GitHub) and its row in Installed, and the picture of each of its providers that doesn’t give its own: an <code>https://</code> URL or a <code>data:image/…</code> URI, at most 1 MB. SVG, PNG and the like.</td></tr>
<tr><td><code>magpie.name</code></td><td>The plugin’s name on its row in Installed, and on its sidebar tab when its page gives no title, for a plugin the community’s list doesn’t name (the list’s name wins). The package’s npm name has to be ASCII, so a name like 华为云 HUAWEI goes here. One line, at most 80 bytes; anything else is ignored. It is never shown as reviewed, and never used to find a plugin by name.</td></tr>
<tr><td><code>magpie.maxConcurrency</code></td><td>How many requests each account takes at once, a whole number from 1 to 1000. A limit the user sets on the provider wins over it.</td></tr>
</table></div>
<p>The same fields can be set on the <code>auth</code> hook (<code>auth.icon</code>, <code>auth.maxConcurrency</code>), where they win over <code>package.json</code>. A plugin that signs in to several providers can give each its own <code>auth.icon</code> and keep <code>magpie.icon</code> for the plugin itself.</p>
+1
View File
@@ -264,6 +264,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
<div class="table-wrap"><table>
<tr><th>字段</th><th>含义</th></tr>
<tr><td><code>magpie.icon</code></td><td>插件自己的图标,用在「发现」里的卡片(从 npm 读取,GitHub 上的插件从仓库读取)和「已安装」里的那一行;没有自己图标的供应商也用它:<code>https://</code> 地址或 <code>data:image/…</code> URI,最大 1 MB,SVG、PNG 等都行。</td></tr>
<tr><td><code>magpie.name</code></td><td>插件在「已安装」里那一行的名字;它的页面没写标题时,也是侧边栏标签的名字。只对社区列表没收录的插件有效(列表里的名字优先)。npm 包名只能是 ASCII,所以「华为云 HUAWEI」这样的名字写在这里。一行,最多 80 字节,否则忽略。它只是包自己的说法:不会显示为已审核,也不会用来按名字查找插件。</td></tr>
<tr><td><code>magpie.maxConcurrency</code></td><td>每个账号同时接多少个请求,1 到 1000 的整数。用户在供应商上设置的上限优先。</td></tr>
</table></div>
<p>同样的字段也可以写在 <code>auth</code> 钩子上(<code>auth.icon</code>、<code>auth.maxConcurrency</code>),优先于 <code>package.json</code>。一个插件登录多个供应商时,可以给每个供应商各写一个 <code>auth.icon</code>,<code>magpie.icon</code> 留给插件本身。</p>