Commit Graph
5 Commits
Author SHA1 Message Date
yetone ace8ee1e1c plugins: a registry icon that is a picture is kept and drawn, not the cube
registry.json's `icon` can be an https URL: Kilo Code
(https://github.com/Kilo-Org.png), Search1API (https://s1.dev/icon.png),
PowerContext (a raw.githubusercontent SVG) and GoAnyAPI
(https://goanyapi.com/logo.png). It reached the page as it was, and app.js
icon() took any name for a bundled file (icons/<url>.svg), so the Discover
card, the plugin's page and Kilo's agent row showed the generic cube.

A market picture now goes through the path a plugin's own picture already
takes (pluginOwnIcon / RepoIcons). Only a public https host is fetched,
the size is capped, and the file is kept as file:<hash> and served from
/api/icons. The page never loads a remote URL. Until the picture is in,
the icon is "", which the page draws as the cube.
- provider.MarketIcon / MarketPicture. PluginIcon (installed plugins)
  uses them.
- agent pluggedIcon (an agent plugin's row, which is Kilo's case) uses
  them too.
- gui listingIcons: /api/plugins/listings and /api/plugins/market keep
  the market's picture icons and the npm icons in one RepoIcons call
  (the market waits up to 3s, the listings don't wait). The market's own
  slice is not changed.
- app.js icon(): a name with ':' or '/' that isn't file:/data: is drawn
  as the cube, never asked for as icons/<url>.svg. A kept picture that
  fails to load already falls back to the cube through the img's onerror.
  app.js stays under its budget: two comments were shortened, with no
  raise.

Tests:
- TestMarketIconURLKept (provider): an https icon becomes file: and is
  fetched once, a bundled name is unchanged, and http:// is refused.
- TestRegistryIconPictureKept (gui): listings give file: for a data:
  icon, keep a bundled name, and give "" for javascript:. The market's
  listing is not mutated.
- plugin-registry-icon.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de
  at 980 and 420. A kept picture is drawn on the card and on its page. A
  URL shows the cube. A 404 picture shows the cube, not a blank. A bundled
  icon stays bundled. Nothing is asked of another host.

What was run:
- Before the rebase (mote):
  - focused Go tests: ok.
  - plugin-registry-icon: 22/22.
  - real use, sandbox HOME, the four real registry URLs: each fetched
    and kept as file: (Kilo png 1455 B, s1 png 4426 B, PowerContext svg
    40309 B, goanyapi png 21878 B).
- At the rebased fix (on dca3e2d71), on mote:
  - go vet ./..., GOOS=linux go vet -tags nogui ./...,
    GOOS=windows go vet ./...: ok.
  - Linux and Windows builds: ok. gofmt clean.
  - go test -tags nogui -count=1 -timeout 45m: internal/gui, provider,
    agent and plugin all ok.
- GUI on mote: the 58 Plugins-page files were run twice. Both runs were
  red by browsers crashing or failing to launch (#4125: pboard crashes,
  SEGV, newContext "browser has been closed"). origin/main's
  agent-plugin-agents fails the same way there.
- GUI on the Linux box (wsl-run), at this head:
  - plugin-registry-icon, icon-tile, i18n-keys and plugin-card-update:
    ok, except plugin-card-update in WebKit, which is red the same at
    origin/main 46fb0c1b9 (#3079, commented).
  - plugin-registry-icon was first red there in WebKit: the Discover
    list is drawn again as the market comes in, so a card could detach
    mid-scroll. The test's scroll now looks again; it passes 20/20 in
    both engines.
- The Chromium reds plugin-github (80 -> 79) and plugin-move-unserved
  (Model 1) are red the same at origin/main 46fb0c1b9 (#3218,
  #4410/#4392).

Broken by hand:
- MarketIcon returning its input made both Go tests red. The listing
  gave the raw data URI and javascript:alert(1), and PluginIcon gave the
  https URL.
- Without the app.js guard, plugin-registry-icon was 0/22: it asked
  for http://magpie.test/icons/https://s1.dev/icon.png.svg.

Not run yet: the whole GUI suite, the full go test ./..., Windows test
runs and the real GUI app. They run after the push, and each red gets
its own issue.
2026-10-30 15:42:29 +08:00
yetone cb406c8425 plugins: a plugin can add an agent magpie has no setup of its own for
Plugins could be subscription providers or gateway middleware. Now a third
kind: an agent plugin, so a user whose agent magpie doesn't ship can still
put it on magpie.

- internal/agentplug: a plugin's magpie.agent module (or a *.agent.js file)
  exports agent = {id, name, config, format?, model, prefix?, bin?, dir?,
  ua?, icon?, notice?} and an optional connect({gateway, model, models,
  agent}) returning the other keys to write. Compiled in moejs, reloaded
  when plugins.json or the file changes; why one didn't load is kept.
- internal/jsmod: module compiling (imports kept inside the plugin), moved
  out of middleware so both share it.
- internal/agent/plugged.go: each becomes an Agent (Plugin set) after
  magpie's own. JSON, YAML and env files are edited key by key, comments
  kept; what each key held is stashed typed under plugin:<id>:<path>, and
  its own model or Disconnect puts every key back. A built-in id is
  refused; a connect that throws writes nothing. Key magpie-<id>; usage
  names it by key or ua (usage.PluginAgents).
- GUI Plugins page: an Agent kind chip and glyph, a Discover "Agents"
  section (market kind "agent"), and an installed row line "Adds X to
  Agents" or why it didn't load. zh, zh-TW, ja, de strings.
- Docs: site Plugins page (en, zh, ja) "Agent plugins", reference.md,
  agent-wiring.md, gateway-middleware.md.

Run:
- go test ./... (all ok); gofmt -l clean; GOOS=linux go vet -tags nogui
  ./... and GOOS=windows go vet ./... clean.
- TestPluggedYAML, TestPluggedJSONUnwire, TestPluggedRefused.
- GUI: plugin-agent.test.cjs 22/22 (en, zh, zh-TW, ja, de; 980 and 420;
  chromium and webkit); all plugin-*.test.cjs, i18n-keys,
  deprecated-subscriptions, filter-ime: 315 pass, 0 fail.
- Real use, in a sandbox HOME: an Aider plugin (~/.aider.conf.yml, prefix
  openai/, connect writes openai-api-base/key) installed in a dev build;
  picking DeepSeek V4.1 Flash on the Agents page wired the file keeping the
  user's comment and keys; real aider 0.86.2 `--message` answered through
  magpie from the real DeepSeek account; usage.jsonl recorded agent aider,
  provider deepseek, 200; Disconnect restored the file byte for byte.
2026-10-10 18:39:47 +08:00
yetone 52f6b3a3ab plugins: the GitHub list waits up to 3s for a repository's https icon fetched the first time (yetone: 非官方插件显示不出来 logo)
RepoIcons starts every fetch, then waits for those not in yet, so the
list's first answer has them; one slower than the wait shows the next
time. The fetch takes fetchPluginIcon before its goroutine starts.

Ran: go test ./internal/provider ./internal/gui; the new test -race
-count=10, and red with a 1ns wait. A sandbox build (fresh HOME, real
GitHub): the first /api/plugins/github answer has all 8 icons the 13
tagged repositories give, screenshot in light and dark.
2026-10-10 05:22:07 +08:00
yetone a3a8e25792 plugins: a repository tagged magpie-plugin shows the icon its package.json gives (yetone: 非官方的插件能否支持 icon)
magpie.icon, an https URL or a data:image URI, is read with the rest of
package.json and kept through pluginOwnIcon as an installed plugin's is;
the card shows it, else the puzzle piece.

Ran: go test ./internal/plugin ./internal/gui ./internal/provider; the
plugin GUI tests in Chromium and WebKit (en/zh/ja/de, 980 and 440).
2026-10-10 00:42:37 +08:00
yetone 4ba51bb627 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. 2026-10-01 11:42:45 +08:00