plugin: a plugin names its own icon and the key field's title and hint (Lemon on Discord) — a plugin's provider took only the market's icon, and an api method's key field always read "<name> API key" with no hint. auth.icon (or package.json "magpie": {"icon"}) as an https URL, fetched once through the public-only icon path, or a data:image URI now comes before the market icon; an api method's label titles the key field as in OpenCode, and a new placeholder hints it, in the window and in magpie plugin login. README has a For plugin authors section. TestPluginOwnIcon, TestPluginOwnIconAndKeyHint and plugin-key-hint.test.cjs (Chromium, WebKit, en/zh) fail without the change.

This commit is contained in:
yetone committed 2026-10-01 11:42:45 +08:00
1 parent 49c98f40f5
commit 4ba51bb627
18 files changed
+542 -19

No files matched your search

+11 -1
View File
@@ -285,7 +285,7 @@ func pluginLogin(ctx context.Context, name, method string) error {
}
var saved plugin.Saved
if pp.Methods[m].Type == "api" {
key, err := secret("key", pp.Name+" API key: ", false)
key, err := secret("key", keyPrompt(pp.Name, pp.Methods[m]), false)
if err != nil {
return err
}
@@ -324,6 +324,16 @@ func pluginLogin(ctx context.Context, name, method string) error {
return nil
}
// keyPrompt asks an "api" method's key: its title, then the hint the
// plugin gives (its placeholder), as a question's is.
func keyPrompt(name string, m plugin.Method) string {
p := m.KeyTitle(name)
if m.Placeholder != "" {
p += " " + muted.Render("("+m.Placeholder+")")
}
return p + ": "
}
func askNumber(n int) (int, error) {
for {
fmt.Print("> ")