plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main cf21b71ff):
- go test ./internal/plugin: ok. Broken by hand: without the page case,
and with the page's entry not checked, TestTaggedRepos goes red.
- plugin-kinds-discover.test.cjs (new): 5 languages x 980/420 x chromium
and webkit, green. Broken by hand, each red: the old plugins.js (11/11
fail), no "tools" kind (11/11), no ja/zh-TW docs link (3), no Tools chip
on an installed row (11/11).
- plugin-middleware.test.cjs's intro test now checks the new copy and link;
it still checks the click scrolls nothing.
- Every plugin*.test.cjs and i18n*.test.cjs, both engines: 505 pass, 0 fail.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: 0.
- go test -timeout 45m ./...: all 66 packages ok (full=0).
This commit is contained in:
@@ -259,7 +259,7 @@ still means off; a page is its own plugin's to turn on and off.
|
||||
| Router strategy | A module's `export const strategies = {name: (pool, seats, options) => order}` (or `{order}` objects) are routings `<short name>/<name>`, registered with `routes.Register` while the gateway serves `middleware.Points()` and the plugin is on and loaded; off or reloaded, they are removed. 20ms each, fail open: an error, a timeout or what isn't an order of the seats is the listed order, counted on the Plugins page. The routing pickers offer the served ones (`jsRoutings` in the settings state); a routing saved whose plugin is gone shows as it is and is the listed order. providers.json keeps such a routing as saved (`provider.PluginRouting`), so a plugin turned off and on again routes its groups again. | `plugins/middleware` ("JS gateway plugins", from the same module as its [middleware](gateway-middleware.md)) | [`points.go`](../../internal/middleware/points.go), [`app.js`](../../internal/gui/assets/app.js), [`client.js`](../../internal/gui/assets/plugins/routing/client.js), [`groups_cli.go`](../../internal/cli/groups_cli.go), [`routing.go`](../../internal/provider/routing.go) |
|
||||
| Usage observer | `export function onUsage(row, options)` gets each usage row of an allow-list (no bodies, prompts or ids), from a bounded queue off the request path: a full queue drops and counts, and a request never waits. 250ms each, fail open. | `plugins/middleware` ("JS gateway plugins", from the same module as its [middleware](gateway-middleware.md)) | [`points.go`](../../internal/middleware/points.go) |
|
||||
| Tool | Its OpenCode `tool` hook's tools, offered to every agent by magpie's MCP server at `/mcp/magpie/tools`, each named `<plugin>_<tool>`, each call held to the calling key's limit and run in the host within 55s. Off, no tool is listed and a call says the plugin is off. | `plugins/tools` ("Plugin tools", Essential; `InUse` counts the plugins on that give tools, from `plugin-tools.json`), `gwtool.PluginTools` | [Plugin tools](plugin-tools.md) |
|
||||
| A page in the window | `magpie.page {title, file, icon}` and `magpie.permissions` in package.json, installed from npm, GitHub or a folder like any plugin (`plugin.WindowPage`: `file` an .html inside the plugin, the icon in the page's folder, reads kept to `plugin.PageReads`). An on plugin's page gets a tab in the sidebar's Plugins group, after the built-in pages (`pluginpages.js`, a kernel `page` part). It runs in an iframe sandboxed to `allow-scripts`, its files served from `/_magpie/plugin/<token>/` (an HMAC of the spec with a secret of this run) under a policy of `sandbox allow-scripts`, its own folder only, `connect-src 'none'`. The frame talks to the window by `postMessage`: the window answers only its own frame (`ev.source`), with the theme, its own options (`/api/plugin-pages/options`, at most once a second, saved without restarting the host for a page-only plugin) and the reads it declared (`/api/plugin-pages/read`, checked again by the server): `usage:summary` (totals and the top 20 models) and `providers:list` (ids and names). Nothing secret is readable, since a page can still send its frame to another site. `noFramedAPI` turns away every `/api/` request a sandboxed frame or another site can send (`Origin: null`, `Sec-Fetch-Dest` a frame, a cross-site subresource), since the desktop window's API has no key; `webGuard` lets the prefix through without the cookie the frame never sends, and the token is the key. A page that throws, or doesn't say hello in 10s, is broken through the kernel (`ctx.broke`), with Try again. The Plugins page shows the page and its reads on the row before the plugin is on. A plugin that is only a page is in-magpie-only: no Bun host starts for it. Tests: `TestWindowPageStaysInside`, `TestPluginPageServedShutIn`, `TestPluginPageReadsWhatItDeclared`, `TestPluginPageNoAPI`, `TestPluginPageWebGuard`, `plugin-page.test.cjs`. Example: `internal/gui/testdata/page-plugin`. | the window, no built-in plugin: the page is the plugin's own on/off | [`page.go`](../../internal/plugin/page.go), [`pluginpage.go`](../../internal/gui/pluginpage.go), [`pagebridge.js`](../../internal/gui/pagebridge.js), [`pluginpages.js`](../../internal/gui/assets/pluginpages.js) |
|
||||
| A page in the window | `magpie.page {title, file, icon}` and `magpie.permissions` in package.json, installed from npm, GitHub or a folder like any plugin (`plugin.WindowPage`: `file` an .html inside the plugin, the icon in the page's folder, reads kept to `plugin.PageReads`). An on plugin's page gets a tab in the sidebar's Plugins group, after the built-in pages (`pluginpages.js`, a kernel `page` part). It runs in an iframe sandboxed to `allow-scripts`, its files served from `/_magpie/plugin/<token>/` (an HMAC of the spec with a secret of this run) under a policy of `sandbox allow-scripts`, its own folder only, `connect-src 'none'`. The frame talks to the window by `postMessage`: the window answers only its own frame (`ev.source`), with the theme, its own options (`/api/plugin-pages/options`, at most once a second, saved without restarting the host for a page-only plugin) and the reads it declared (`/api/plugin-pages/read`, checked again by the server): `usage:summary` (totals and the top 20 models) and `providers:list` (ids and names). Nothing secret is readable, since a page can still send its frame to another site. `noFramedAPI` turns away every `/api/` request a sandboxed frame or another site can send (`Origin: null`, `Sec-Fetch-Dest` a frame, a cross-site subresource), since the desktop window's API has no key; `webGuard` lets the prefix through without the cookie the frame never sends, and the token is the key. A page that throws, or doesn't say hello in 10s, is broken through the kernel (`ctx.broke`), with Try again. The Plugins page shows the page and its reads on the row before the plugin is on. A plugin that is only a page is in-magpie-only: no Bun host starts for it. Discover lists a market entry of `kind: "page"` under Pages with the Page chip, and a GitHub repository tagged `magpie-plugin` whose package.json has `magpie.page.file` as a Page (`TaggedRepos`, which then checks that file is committed, as it does a provider's entry; `TestTaggedRepos`, `plugin-kinds-discover.test.cjs`). Tests: `TestWindowPageStaysInside`, `TestPluginPageServedShutIn`, `TestPluginPageReadsWhatItDeclared`, `TestPluginPageNoAPI`, `TestPluginPageWebGuard`, `plugin-page.test.cjs`. Example: `internal/gui/testdata/page-plugin`. | the window, no built-in plugin: the page is the plugin's own on/off | [`page.go`](../../internal/plugin/page.go), [`pluginpage.go`](../../internal/gui/pluginpage.go), [`pagebridge.js`](../../internal/gui/pagebridge.js), [`pluginpages.js`](../../internal/gui/assets/pluginpages.js) |
|
||||
|
||||
`plugins/middleware` is now "JS gateway plugins". Apply registers the chain and `usage.Observe(middleware.Points())`; off, no JS middleware, strategy or `onUsage` runs, and a pool routed by a JS strategy is its listed order. `InUse` is unchanged. ([`middleware.go`](../../plugins/middleware/middleware.go))
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ A community plugin (an OpenCode plugin, an npm package in the plugin host) can g
|
||||
| Note | After every load the host notes which plugins gave which tools in `plugin-tools.json` (settings dir), written whole and only when it changed. `ToolsOn` counts the plugins that are on in plugins.json and have tools there. A note that can't be read or parsed is an error, so the plugin stays on. `ToolNames` is the note for a Plugins page whose host isn't running. | `noteTools`, `ToolsOn`, `ToolNames` in `tools.go` |
|
||||
| Serve | `tools/list` names each tool `<plugin>_<tool>`: the plugin's short name, as its Plugins row names it (opencode-weather-tools → weather-tools; a plugin added from a folder, the folder's name), at most 24 characters, in `[A-Za-z0-9_-]`, then the tool. Each name is at most 64 characters, and a name two would share gets `_2`, `_3`. `tools/call` runs one; an unknown name is error -32602. It is guarded as the search MCP server is (`serveMCP`: a web page's request is refused, a remote one needs a key), with a 4 MiB body. | [`tools_mcp.go`](../../internal/gateway/tools_mcp.go) |
|
||||
| Gate | `plugins/tools` ("Plugin tools", requires `gateway`, Essential) serves `gwtool.PluginTools`. `InUse` is `plugin.ToolsOn`, so it is on while a plugin that is on gives a tool. The gateway's `KeepFresh` watches `plugin-tools.json` too. | [`plugins/tools`](../../plugins/tools/tools.go), [`gwtool.go`](../../internal/gwtool/gwtool.go), [`gateway.go`](../../internal/gateway/gateway.go) |
|
||||
| GUI | Each Installed row of a plugin that is on and gives tools lists them by their MCP names, each with its description on hover, plus a button that copies the server's address (`mcpAddress`). A plugin of tools alone has no Provider chip. | `pluginEntryJSON.Tools` in [`plugins.go`](../../internal/gui/plugins.go); `toolsLine` in `plugins.js` |
|
||||
| GUI | Each Installed row of a plugin that is on and gives tools lists them by their MCP names, each with its description on hover, plus a button that copies the server's address (`mcpAddress`). A plugin of tools alone wears the Tools chip, not Provider. Discover lists `kind: "tools"` market entries under Tools for agents. | `pluginEntryJSON.Tools` in [`plugins.go`](../../internal/gui/plugins.go); `toolsLine`, `kindOf` and `KINDS.tl` in `plugins.js` |
|
||||
| CLI | `magpie plugin` lists a plugin's tools by the same MCP names, and a plugin's page by its title and what it may read. The host loads no plugin that is off, so one lists no tools. | `toolsLine`, `pageLine` in [`plugins_cli.go`](../../internal/cli/plugins_cli.go) |
|
||||
| User docs | How to write a tool and add the address to an agent | [usemagpie.ai/docs/plugins#tools](https://usemagpie.ai/docs/plugins#tools) (`site/public/docs/*plugins.html`) |
|
||||
|
||||
|
||||
+32
-12
@@ -3463,9 +3463,14 @@ const I18N = {
|
||||
"Type two letters or more to search npm": "输入两个及以上字符以搜索 npm",
|
||||
"Nothing else on npm": "npm 上没有更多了",
|
||||
"No plugin called “{q}”": "没有叫「{q}」的插件",
|
||||
"Subscriptions and gateway middleware": "订阅与网关中间件",
|
||||
"A plugin can also be middleware in magpie's gateway: it reads and rewrites what agents send and get back, for every provider.": "插件也可以是 magpie 网关里的中间件:读取并改写 Agent 发出和收到的内容,对每个 provider 都有效。",
|
||||
"Write a middleware": "编写中间件",
|
||||
"Plugins extend magpie": "插件扩展 magpie",
|
||||
"A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.": "插件还可以在 magpie 网关里处理 Agent 发出和收到的内容、决定路由该用哪个账号、给每个 Agent 提供工具、接入一个 Agent,或加一个自己的页面。",
|
||||
"Write a plugin": "编写插件",
|
||||
"Gives every agent tools of its own, through magpie's MCP server": "通过 magpie 的 MCP 服务器,给每个 Agent 提供它自己的工具",
|
||||
"Tools for agents": "给 Agent 的工具",
|
||||
"tools every agent can call, through magpie's MCP server": "每个 Agent 都能调用的工具,经由 magpie 的 MCP 服务器",
|
||||
"Pages": "页面",
|
||||
"pages of their own in magpie's window, each shut off from the rest and reading only what it lists": "在 magpie 窗口里自成一页,与其他部分隔离,只能读取它列出的内容",
|
||||
"Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.": "插件负责登录编程套餐并发出请求,其模型可像其他供应商的一样用于所有 agent。插件为 OpenCode 的供应商插件或 pi 扩展包,运行在 Bun 上。",
|
||||
"A plugin is someone else's code with your sign-in or your requests: install the ones you trust.": "插件是他人的代码,会拿到你的登录或看到你的请求:只安装你信任的。",
|
||||
"Have one in mind?": "已有想装的?",
|
||||
@@ -7064,9 +7069,14 @@ const I18N = {
|
||||
"Type two letters or more to search npm": "輸入兩個及以上字元以搜尋 npm",
|
||||
"Nothing else on npm": "npm 上沒有更多了",
|
||||
"No plugin called “{q}”": "沒有叫「{q}」的外掛",
|
||||
"Subscriptions and gateway middleware": "訂閱與閘道中介軟體",
|
||||
"A plugin can also be middleware in magpie's gateway: it reads and rewrites what agents send and get back, for every provider.": "外掛也可以是 magpie 閘道裡的中介軟體:讀取並改寫 Agent 發出和收到的內容,對每個 provider 都有效。",
|
||||
"Write a middleware": "編寫中介軟體",
|
||||
"Plugins extend magpie": "外掛擴充 magpie",
|
||||
"A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.": "外掛還可以在 magpie 閘道裡處理 Agent 發出和收到的內容、決定路由該用哪個帳號、給每個 Agent 提供工具、接入一個 Agent,或加一個自己的頁面。",
|
||||
"Write a plugin": "編寫外掛",
|
||||
"Gives every agent tools of its own, through magpie's MCP server": "透過 magpie 的 MCP 伺服器,給每個 Agent 提供它自己的工具",
|
||||
"Tools for agents": "給 Agent 的工具",
|
||||
"tools every agent can call, through magpie's MCP server": "每個 Agent 都能呼叫的工具,經由 magpie 的 MCP 伺服器",
|
||||
"Pages": "頁面",
|
||||
"pages of their own in magpie's window, each shut off from the rest and reading only what it lists": "在 magpie 視窗裡自成一頁,與其他部分隔離,只能讀取它列出的內容",
|
||||
"Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.": "外掛負責登入程式設計套餐並發出請求,其模型可像其他供應商的一樣用於所有 agent。外掛為 OpenCode 的供應商外掛或 pi 擴充功能包,執行在 Bun 上。",
|
||||
"A plugin is someone else's code with your sign-in or your requests: install the ones you trust.": "外掛是他人的程式碼,會拿到你的登入或看到你的請求:只安裝你信任的。",
|
||||
"Have one in mind?": "已有想裝的?",
|
||||
@@ -10687,9 +10697,14 @@ const I18N = {
|
||||
"Type two letters or more to search npm": "2 文字以上入力して npm を検索",
|
||||
"Nothing else on npm": "npm に他のものはありません",
|
||||
"No plugin called “{q}”": "「{q}」という名前のプラグインはありません",
|
||||
"Subscriptions and gateway middleware": "サブスクリプションとゲートウェイミドルウェア",
|
||||
"A plugin can also be middleware in magpie's gateway: it reads and rewrites what agents send and get back, for every provider.": "プラグインは magpie のゲートウェイのミドルウェアにもなれます:エージェントが送受信する内容を、どのプロバイダでも読み取り・書き換えます。",
|
||||
"Write a middleware": "ミドルウェアを書く",
|
||||
"Plugins extend magpie": "プラグインで magpie を拡張",
|
||||
"A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.": "プラグインは、magpie のゲートウェイでエージェントの送受信を処理したり、ルーティングがどのアカウントに聞くかを選んだり、すべてのエージェントにツールを渡したり、エージェントを接続したり、独自のページを追加したりもできます。",
|
||||
"Write a plugin": "プラグインを書く",
|
||||
"Gives every agent tools of its own, through magpie's MCP server": "magpie の MCP サーバーを通じて、すべてのエージェントに独自のツールを渡します",
|
||||
"Tools for agents": "エージェント向けツール",
|
||||
"tools every agent can call, through magpie's MCP server": "すべてのエージェントが magpie の MCP サーバーを通じて呼べるツール",
|
||||
"Pages": "ページ",
|
||||
"pages of their own in magpie's window, each shut off from the rest and reading only what it lists": "magpie のウィンドウ内の独自ページ。ほかから切り離され、一覧にあるものだけを読み取ります",
|
||||
"Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.": "プラグインはコーディングプランにサインインしてリクエストを送ります。そのモデルは他のプロバイダと同様にすべてのエージェントで使えます。これらは OpenCode のプロバイダプラグインまたは pi のパッケージで、Bun 上で動作します。",
|
||||
"A plugin is someone else's code with your sign-in or your requests: install the ones you trust.": "プラグインはあなたのサインイン情報やリクエストを扱う他人のコードです:信頼できるものだけをインストールしてください。",
|
||||
"Have one in mind?": "入れたいものがありますか?",
|
||||
@@ -14323,9 +14338,14 @@ const I18N = {
|
||||
"Type two letters or more to search npm": "Mindestens zwei Zeichen eingeben, um npm zu durchsuchen",
|
||||
"Nothing else on npm": "Sonst nichts auf npm",
|
||||
"No plugin called “{q}”": "Keine Erweiterung namens „{q}“",
|
||||
"Subscriptions and gateway middleware": "Abos und Gateway-Middleware",
|
||||
"A plugin can also be middleware in magpie's gateway: it reads and rewrites what agents send and get back, for every provider.": "Eine Erweiterung kann auch Middleware im Gateway von magpie sein: Sie liest und ändert, was Agenten senden und erhalten, bei jedem Anbieter.",
|
||||
"Write a middleware": "Eine schreiben",
|
||||
"Plugins extend magpie": "Erweiterungen für magpie",
|
||||
"A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.": "Eine Erweiterung kann auch im Gateway von magpie bearbeiten, was Agenten senden und erhalten, wählen, welches Konto ein Routing fragt, jedem Agenten Werkzeuge geben, einen Agenten anbinden oder eine eigene Seite hinzufügen.",
|
||||
"Write a plugin": "Eine Erweiterung schreiben",
|
||||
"Gives every agent tools of its own, through magpie's MCP server": "Gibt jedem Agenten eigene Werkzeuge, über den MCP-Server von magpie",
|
||||
"Tools for agents": "Werkzeuge für Agenten",
|
||||
"tools every agent can call, through magpie's MCP server": "Werkzeuge, die jeder Agent über den MCP-Server von magpie aufrufen kann",
|
||||
"Pages": "Seiten",
|
||||
"pages of their own in magpie's window, each shut off from the rest and reading only what it lists": "eigene Seiten im Fenster von magpie, jede vom Rest getrennt und liest nur, was sie auflistet",
|
||||
"Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.": "Erweiterungen melden sich bei Coding-Abos an und stellen deren Anfragen; die Modelle funktionieren dann in jedem Agenten wie die jedes anderen Anbieters. Es sind Anbietererweiterungen von OpenCode oder Pakete von pi, ausgeführt auf Bun.",
|
||||
"A plugin is someone else's code with your sign-in or your requests: install the ones you trust.": "Eine Erweiterung ist fremder Code mit Ihrer Anmeldung oder Ihren Anfragen: Installieren Sie nur solche, denen Sie vertrauen.",
|
||||
"Have one in mind?": "Schon eines im Sinn?",
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
const PIPE = "M1.5 8h3 M11.5 8h3 M4.5 4.5h7v7h-7z";
|
||||
const TERM = "M2 3.5h12v9H2z M4.5 6.5l2 1.5-2 1.5 M8 9.5h3";
|
||||
const PAGE = "M2 3.5h12v9H2z M2 6h12 M4 4.75h.01";
|
||||
const TOOL = "M10.6 2.4a3 3 0 0 0-3.4 4L2.6 11a1.2 1.2 0 0 0 1.7 1.7l4.6-4.6a3 3 0 0 0 4-3.4l-1.7 1.7-1.6-.3-.3-1.6z";
|
||||
const FOLDER = "M14.7 12.7a1.3 1.3 0 0 1-1.3 1.3H2.6a1.3 1.3 0 0 1-1.3-1.3V3.3A1.3 1.3 0 0 1 2.6 2h3.3l1.3 2h6.2a1.3 1.3 0 0 1 1.3 1.3z";
|
||||
|
||||
// a folder's path is its name whole, as plugin.Name: C:\Users\me@corp\…
|
||||
@@ -113,15 +114,17 @@
|
||||
// subscription and serves its models; middleware ("mw") runs in the
|
||||
// gateway on every agent's requests and replies, whatever serves them;
|
||||
// an agent ("ag") is one magpie has no wiring of its own for, which it
|
||||
// then connects as it does its own; a page ("pg") is a page of its own
|
||||
// in the window's sidebar (pluginpages.js)
|
||||
// then connects as it does its own; tools ("tl") are given to every
|
||||
// agent through magpie's plugin tools MCP server; a page ("pg") is a
|
||||
// page of its own in the window's sidebar (pluginpages.js)
|
||||
const KINDS = {
|
||||
pv: [PLUG, "Provider", "Signs in to a subscription and serves its models"],
|
||||
mw: [PIPE, "Middleware", "Runs in magpie's gateway on the requests your agents send and on the replies"],
|
||||
ag: [TERM, "Agent", "Adds an agent magpie has no setup of its own for: pick its model on the Agents page and it goes through magpie"],
|
||||
tl: [TOOL, "Tools", "Gives every agent tools of its own, through magpie's MCP server"],
|
||||
pg: [PAGE, "Page", "Adds a page of its own to the sidebar. It runs shut off from the rest of magpie and can read only what its row lists"],
|
||||
};
|
||||
const kindOf = (l) => l.kind === "middleware" ? "mw" : l.kind === "agent" ? "ag" : "pv";
|
||||
const kindOf = (l) => ({ middleware: "mw", agent: "ag", tools: "tl", page: "pg" })[l.kind] || "pv";
|
||||
function kindChip(kind) {
|
||||
const [d, word, tip] = KINDS[kind];
|
||||
const c = el("span", "pm-chip kind " + kind);
|
||||
@@ -132,7 +135,7 @@
|
||||
function logo(ic, big, kind) {
|
||||
const box = el("span", "pm-logo" + (big ? " big" : ""));
|
||||
if (ic) box.append(icon(ic));
|
||||
else box.append(glyph(kind === "mw" ? PIPE : kind === "ag" ? TERM : kind === "pg" ? PAGE : PUZZLE, big ? 22 : 17, 1.4));
|
||||
else box.append(glyph({ mw: PIPE, ag: TERM, tl: TOOL, pg: PAGE }[kind] || PUZZLE, big ? 22 : 17, 1.4));
|
||||
return box;
|
||||
}
|
||||
|
||||
@@ -616,7 +619,7 @@
|
||||
// the kinds there are, in the market's order, each with how many the
|
||||
// field leaves of it; one kind alone needs no picking
|
||||
const found = ghList.filter(ghMatch);
|
||||
const kinds = ["pv", "mw", "ag"].filter((k) => ghList.some((l) => kindOf(l) === k));
|
||||
const kinds = ["pv", "mw", "ag", "tl", "pg"].filter((k) => ghList.some((l) => kindOf(l) === k));
|
||||
if (!kinds.includes(ghKind)) ghKind = "";
|
||||
// which of them are here, asked once each: the counts below would ask
|
||||
// it again for every pick in both strips. Like a kind alone, a list
|
||||
@@ -806,9 +809,13 @@
|
||||
const ours = ls.filter((l) => l.community && kindOf(l) === "pv");
|
||||
const mws = ls.filter((l) => l.community && kindOf(l) === "mw");
|
||||
const ags = ls.filter((l) => l.community && kindOf(l) === "ag");
|
||||
const tls = ls.filter((l) => l.community && kindOf(l) === "tl");
|
||||
const pgs = ls.filter((l) => l.community && kindOf(l) === "pg");
|
||||
if (ours.length) out.push(section(t("Subscriptions"), t("written for magpie, checked against its own sign-ins"), ours));
|
||||
if (mws.length) out.push(section(t("Gateway middleware"), t("runs in magpie's gateway on what every agent sends and gets back, whichever provider serves it"), mws));
|
||||
if (ags.length) out.push(section(t("Agents"), t("agents magpie has no setup of its own for, connected to it as its own are"), ags));
|
||||
if (tls.length) out.push(section(t("Tools for agents"), t("tools every agent can call, through magpie's MCP server"), tls));
|
||||
if (pgs.length) out.push(section(t("Pages"), t("pages of their own in magpie's window, each shut off from the rest and reading only what it lists"), pgs));
|
||||
if (gh.length) out.push(ghSection(gh));
|
||||
out.push(manual());
|
||||
replaceKeeping(body, out);
|
||||
@@ -838,14 +845,15 @@
|
||||
function intro() {
|
||||
const box = el("div", "pm-intro");
|
||||
const text = el("div", "pm-introtext");
|
||||
text.append(el("h2", "", t("Subscriptions and gateway middleware")));
|
||||
text.append(el("h2", "", t("Plugins extend magpie")));
|
||||
text.append(el("p", "", t("Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.")));
|
||||
const mw = el("p", "");
|
||||
mw.append(document.createTextNode(t("A plugin can also be middleware in magpie's gateway: it reads and rewrites what agents send and get back, for every provider.") + " "));
|
||||
// the docs in the reader's language: the site has en, zh and ja
|
||||
const how = el("a", "pm-link", "");
|
||||
how.href = "https://usemagpie.ai/docs/" + ({ zh: "zh/", ja: "ja/" }[lang()] || "") + "plugins#middleware";
|
||||
how.append(el("span", "", t("Write a middleware")), glyph(OUTL, 11, 1.5));
|
||||
mw.append(document.createTextNode(t("A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.") + " "));
|
||||
// the docs in the reader's language: the site has en, zh and ja, and
|
||||
// Chinese is nearer a zh-TW reader than English is
|
||||
const how = el("a", "pm-link pm-write", "");
|
||||
how.href = "https://usemagpie.ai/docs/" + ({ zh: "zh/", "zh-TW": "zh/", ja: "ja/" }[lang()] || "") + "plugins";
|
||||
how.append(el("span", "", t("Write a plugin")), glyph(OUTL, 11, 1.5));
|
||||
how.onclick = (ev) => { ev.preventDefault(); api("open", { url: how.href }).catch(() => {}); };
|
||||
mw.append(how);
|
||||
text.append(mw);
|
||||
@@ -1049,6 +1057,7 @@
|
||||
if (ag || e.isAgent) nm.append(kindChip("ag"));
|
||||
// a plugin of tools alone signs in to nothing: no Provider chip
|
||||
const toolsOnly = !!e.tools?.length && !e.providers?.length;
|
||||
if (e.tools?.length) nm.append(kindChip("tl"));
|
||||
if (e.page) nm.append(kindChip("pg"));
|
||||
if (e.providers?.length || !(e.middlewareOnly || e.inMagpieOnly || toolsOnly || (mw && !e.isMiddleware) || (ag && !e.isAgent))) nm.append(kindChip("pv"));
|
||||
who.append(nm);
|
||||
@@ -1101,7 +1110,7 @@
|
||||
if (mw && !e.off && !ask && editing?.pkg === pkg) who.append(optionsEditor(e));
|
||||
// the plugin's own picture (package.json's magpie.icon) before its
|
||||
// first provider's, which a plugin of several gives each its own (#1775)
|
||||
r.append(logo(l?.icon || l?.npm?.icon || e.icon || subs[0]?.icon || ag?.icon, false, e.middlewareOnly ? "mw" : e.inMagpieOnly && e.isAgent && !e.isMiddleware ? "ag" : e.inMagpieOnly && e.page && !e.isAgent && !e.isMiddleware ? "pg" : ""), who);
|
||||
r.append(logo(l?.icon || l?.npm?.icon || e.icon || subs[0]?.icon || ag?.icon, false, e.middlewareOnly ? "mw" : e.inMagpieOnly && e.isAgent && !e.isMiddleware ? "ag" : e.inMagpieOnly && e.page && !e.isAgent && !e.isMiddleware ? "pg" : toolsOnly && !e.page && !mw && !ag ? "tl" : ""), who);
|
||||
const val = el("div", "val");
|
||||
const b = busy.get(pkg) || busy.get(e.spec);
|
||||
// npm's newer version, or a git one's repository at a newer commit
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Every kind of plugin has its place on the Plugins page: Discover lists the
|
||||
// market's tools plugins and page plugins in sections of their own, with the
|
||||
// Tools and Page chips, never under Subscriptions; the intro's "Write a
|
||||
// plugin" link opens the plugin docs in the window's language; and an
|
||||
// installed plugin that only gives tools wears the Tools chip, not Provider.
|
||||
// Every language, both engines, at a narrow width too; 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 CALC = "/Users/x/pl/calc";
|
||||
const state = { bun: true, bunVersion: "1.3.0", plugins: [
|
||||
{ spec: CALC, providers: [], moved: [], inMagpieOnly: true, tools: [{ name: "add", mcp: "calc_add" }] },
|
||||
] };
|
||||
const listings = [
|
||||
{ package: "@magpie-community/provider-x", name: "X plan", community: true, providers: ["x"], summary: { en: "Signs in to X" }, npm: { version: "0.1.0" } },
|
||||
{ package: "@magpie-community/tools-calc", name: "Calc tools", kind: "tools", community: true, summary: { en: "Exact arithmetic" }, npm: { version: "0.1.0" } },
|
||||
{ package: "@magpie-community/page-glance", name: "Glance page", kind: "page", community: true, summary: { en: "Today's usage" }, npm: { version: "0.1.0" } },
|
||||
];
|
||||
const opened = [];
|
||||
|
||||
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/open") { opened.push(route.request().postDataJSON()?.url); return json({}); }
|
||||
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: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: { installed: "Installed", subs: "Subscriptions", tls: "Tools for agents", pgs: "Pages", tool: "Tools", page: "Page", provider: "Provider", write: "Write a plugin", docs: "https://usemagpie.ai/docs/plugins" },
|
||||
zh: { installed: "已安装", subs: "订阅", tls: "给 Agent 的工具", pgs: "页面", tool: "工具", page: "页面", provider: "供应商", write: "编写插件", docs: "https://usemagpie.ai/docs/zh/plugins" },
|
||||
"zh-TW": { installed: "已安裝", subs: "訂閱", tls: "給 Agent 的工具", pgs: "頁面", tool: "工具", page: "頁面", write: "編寫外掛", docs: "https://usemagpie.ai/docs/zh/plugins" },
|
||||
ja: { installed: "インストール済み", subs: "サブスクリプション", tls: "エージェント向けツール", pgs: "ページ", tool: "ツール", page: "ページ", write: "プラグインを書く", docs: "https://usemagpie.ai/docs/ja/plugins" },
|
||||
de: { installed: "Installiert", subs: "Abos", tls: "Werkzeuge für Agenten", pgs: "Seiten", tool: "Tools", page: "Seite", write: "Eine Erweiterung schreiben", docs: "https://usemagpie.ai/docs/plugins" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": tools and page plugins in Discover, and the way to write one", async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const lang of Object.keys(L)) for (const width of [980, 420]) {
|
||||
await t.test(lang + " " + width, async () => {
|
||||
const w = L[lang];
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 820 } })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
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 kinds = (r) => r.locator(".pm-chip.kind").allInnerTexts().then((a) => a.map((x) => x.trim()));
|
||||
const sec = (name) => view.locator(".pm-sec").filter({ has: page.locator(".pm-sechead h3", { hasText: new RegExp("^" + name + "$") }) });
|
||||
|
||||
// each kind in its own section, wearing its own chip
|
||||
await sec(w.tls).waitFor();
|
||||
const subs = await sec(w.subs).locator(".pm-card").allInnerTexts();
|
||||
assert.equal(subs.length, 1);
|
||||
assert.ok(subs[0].includes("X plan"));
|
||||
const tl = sec(w.tls).locator(".pm-card");
|
||||
assert.equal(await tl.count(), 1);
|
||||
assert.ok((await tl.innerText()).includes("Calc tools"));
|
||||
assert.deepEqual(await kinds(tl), [w.tool]);
|
||||
assert.ok(await tl.locator(".pm-chip.kind.tl").count());
|
||||
const pg = sec(w.pgs).locator(".pm-card");
|
||||
assert.equal(await pg.count(), 1);
|
||||
assert.ok((await pg.innerText()).includes("Glance page"));
|
||||
assert.deepEqual(await kinds(pg), [w.page]);
|
||||
|
||||
// the way to write one: the docs in the window's language, opened outside
|
||||
const how = view.locator(".pm-intro .pm-write");
|
||||
assert.equal((await how.innerText()).trim(), w.write);
|
||||
assert.equal(await how.getAttribute("href"), w.docs);
|
||||
opened.length = 0;
|
||||
await how.click();
|
||||
for (let i = 0; i < 50 && !opened.length; i++) await page.waitForTimeout(20);
|
||||
assert.deepEqual(opened, [w.docs]);
|
||||
assert.equal(page.url(), "http://magpie.test/?view=plugins", "the window stays on magpie");
|
||||
|
||||
const over = await page.evaluate(() => document.scrollingElement.scrollWidth - document.scrollingElement.clientWidth);
|
||||
assert.ok(over <= 0, "page scrolls sideways by " + over);
|
||||
|
||||
// installed: a plugin with tools alone is Tools, not Provider
|
||||
await view.page().locator(":is(.lib-tabs .opt, .nav-s):visible", { hasText: w.installed }).click();
|
||||
const calc = view.locator(".pm-row").filter({ has: page.locator(".name", { hasText: "calc" }) });
|
||||
await calc.waitFor();
|
||||
assert.deepEqual(await kinds(calc), [w.tool]);
|
||||
if (w.provider) assert.ok(!(await kinds(calc)).includes(w.provider));
|
||||
if (process.env.ARTIFACT_DIR) await view.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-kinds-${engine}-${lang}-${width}.png`) });
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -99,12 +99,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// Discover says plugins can be middleware too, not only subscriptions,
|
||||
// and links to how one is written in the reader's language
|
||||
test(engine + ": Discover's intro names middleware", async (t) => {
|
||||
test(engine + ": Discover's intro names what a plugin can be, and how to write one", async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const I = {
|
||||
en: { h: "Subscriptions and gateway middleware", p: /middleware in magpie's gateway/, a: "Write a middleware", url: "https://usemagpie.ai/docs/plugins#middleware", trust: /sign-in or your requests/ },
|
||||
zh: { h: "订阅与网关中间件", p: /magpie 网关里的中间件/, a: "编写中间件", url: "https://usemagpie.ai/docs/zh/plugins#middleware", trust: /登录或看到你的请求/ },
|
||||
en: { h: "Plugins extend magpie", p: /run in magpie's gateway .* give every agent tools, connect an agent, or add a page of its own/, a: "Write a plugin", url: "https://usemagpie.ai/docs/plugins", trust: /sign-in or your requests/ },
|
||||
zh: { h: "插件扩展 magpie", p: /在 magpie 网关里处理.*给每个 Agent 提供工具.*加一个自己的页面/, a: "编写插件", url: "https://usemagpie.ai/docs/zh/plugins", trust: /登录或看到你的请求/ },
|
||||
};
|
||||
for (const lang of ["en", "zh"]) {
|
||||
await t.test(lang, async () => {
|
||||
|
||||
@@ -37,7 +37,7 @@ type Tagged struct {
|
||||
// it as, its version, and whether it is gateway middleware or an agent
|
||||
Package string `json:"package,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Kind string `json:"kind,omitempty"` // "middleware" or "agent" when that is all it is
|
||||
Kind string `json:"kind,omitempty"` // "middleware", "agent" or "page" when that is all it is
|
||||
// its package.json's magpie.icon, as an installed plugin gives its
|
||||
// provider one: an https URL or a data:image URI, as it is written
|
||||
Icon string `json:"icon,omitempty"`
|
||||
@@ -304,6 +304,9 @@ func readTagged(pc context.Context, t Tagged, branch string) (Tagged, bool, bool
|
||||
Middleware string `json:"middleware"`
|
||||
Agent string `json:"agent"`
|
||||
Icon string `json:"icon"`
|
||||
Page struct {
|
||||
File string `json:"file"`
|
||||
} `json:"page"`
|
||||
} `json:"magpie"`
|
||||
}
|
||||
if json.Unmarshal(pb, &pj) != nil || !pkgName.MatchString(pj.Name) {
|
||||
@@ -319,6 +322,8 @@ func readTagged(pc context.Context, t Tagged, branch string) (Tagged, bool, bool
|
||||
t.Kind = "middleware"
|
||||
case strings.TrimSpace(pj.Magpie.Agent) != "":
|
||||
t.Kind = "agent"
|
||||
case strings.TrimSpace(pj.Magpie.Page.File) != "":
|
||||
t.Kind = "page"
|
||||
}
|
||||
}
|
||||
// published to npm from this repository: npm's copy is the one
|
||||
@@ -348,6 +353,8 @@ func readTagged(pc context.Context, t Tagged, branch string) (Tagged, bool, bool
|
||||
entry := pj.Magpie.Middleware
|
||||
if t.Kind == "agent" {
|
||||
entry = pj.Magpie.Agent
|
||||
} else if t.Kind == "page" {
|
||||
entry = pj.Magpie.Page.File
|
||||
} else if t.Kind != "middleware" {
|
||||
entry = pkgEntry(pj.Exports, pj.Main)
|
||||
if !IsGit(t.Spec) {
|
||||
|
||||
@@ -19,7 +19,9 @@ import (
|
||||
// repositories), with three more items made from its first — a fork, an
|
||||
// archived one and magpie-community's — and someone/word-guard, whose
|
||||
// package.json is word-guard's own, a middleware alone; someone/agent-aider,
|
||||
// magpie-community's agent-aider package.json and module, an agent alone; alfaoz's
|
||||
// magpie-community's agent-aider package.json and module, an agent alone;
|
||||
// someone/page-glance, a page alone (internal/gui/testdata/page-plugin's
|
||||
// package.json), and someone/page-gone, whose page file isn't there; alfaoz's
|
||||
// opencode-see-image (real), whose main is a dist the repository hasn't;
|
||||
// and someone/flaky-entry, whose main GitHub doesn't answer for.
|
||||
// reads counts what fakeGitHub answered other than searches: package.json,
|
||||
@@ -62,6 +64,8 @@ func fakeGitHub(t *testing.T, up *atomic.Bool, asked *atomic.Int32) {
|
||||
items = append(items,
|
||||
like("someone/word-guard", map[string]any{"description": "word guard", "stargazers_count": 3, "license": nil}),
|
||||
like("someone/agent-aider", nil),
|
||||
like("someone/page-glance", nil),
|
||||
like("someone/page-gone", nil),
|
||||
like("alfaoz/opencode-see-image", nil),
|
||||
like("someone/flaky-entry", map[string]any{"license": map[string]any{"key": "other", "spdx_id": "NOASSERTION"}}),
|
||||
like("cyberElar/magpie-x-search", nil),
|
||||
@@ -141,7 +145,7 @@ func TestTaggedRepos(t *testing.T) {
|
||||
// none would load. magpie-x-search (real, #1327) is on npm from its
|
||||
// repository, but a command alone, an MCP server: npm's copy names no
|
||||
// file to load, and it has no index.js
|
||||
want := "rynfar/meridian griffinmartin/opencode-claude-auth slkiser/opencode-quota someone/word-guard someone/agent-aider someone/flaky-entry"
|
||||
want := "rynfar/meridian griffinmartin/opencode-claude-auth slkiser/opencode-quota someone/word-guard someone/agent-aider someone/page-glance someone/flaky-entry"
|
||||
if strings.Join(repos, " ") != want {
|
||||
t.Fatalf("repos %v\nwant %s", repos, want)
|
||||
}
|
||||
@@ -168,6 +172,11 @@ func TestTaggedRepos(t *testing.T) {
|
||||
if x := byRepo["someone/agent-aider"]; x.Kind != "agent" || x.Spec != "github:someone/agent-aider" {
|
||||
t.Fatalf("an agent alone: %+v", x)
|
||||
}
|
||||
// a page alone: no module, magpie.page's file in the repository; one
|
||||
// whose file isn't there would show nothing, and isn't listed
|
||||
if x := byRepo["someone/page-glance"]; x.Kind != "page" || x.Spec != "github:someone/page-glance" || x.Package != "magpie-usage-glance" {
|
||||
t.Fatalf("a page alone: %+v", x)
|
||||
}
|
||||
if x := byRepo["someone/word-guard"]; x.Kind != "middleware" || x.Package != "@magpie-community/middleware-word-guard" || x.License != "" {
|
||||
t.Fatalf("a middleware alone: %+v", x)
|
||||
}
|
||||
@@ -197,7 +206,7 @@ func TestTaggedRepos(t *testing.T) {
|
||||
taggedAt = time.Now().Add(-taggedTTL - time.Second)
|
||||
taggedMu.Unlock()
|
||||
before := reads.Load()
|
||||
if l := TaggedRepos(ctx); len(l) != 6 || asked.Load() != 2 {
|
||||
if l := TaggedRepos(ctx); len(l) != 7 || asked.Load() != 2 {
|
||||
t.Fatalf("ten minutes on: asked %d times, %d repos", asked.Load(), len(l))
|
||||
}
|
||||
if n := reads.Load() - before; n != 3 {
|
||||
@@ -212,7 +221,7 @@ func TestTaggedRepos(t *testing.T) {
|
||||
if err := os.Chtimes(taggedCache(), time.Now(), time.Now()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if l := TaggedRepos(ctx); len(l) != 6 || asked.Load() != 1 {
|
||||
if l := TaggedRepos(ctx); len(l) != 7 || asked.Load() != 1 {
|
||||
t.Fatalf("restarted: asked %d times, %d repos", asked.Load(), len(l))
|
||||
}
|
||||
|
||||
@@ -223,7 +232,7 @@ func TestTaggedRepos(t *testing.T) {
|
||||
}
|
||||
up.Store(false)
|
||||
forget()
|
||||
if l := TaggedRepos(ctx); len(l) != 6 || l[1].Package != "opencode-claude-auth" || asked.Load() != 1 {
|
||||
if l := TaggedRepos(ctx); len(l) != 7 || l[1].Package != "opencode-claude-auth" || asked.Load() != 1 {
|
||||
t.Fatalf("down: %+v", l)
|
||||
}
|
||||
|
||||
@@ -258,7 +267,7 @@ func TestTaggedReposSlowRead(t *testing.T) {
|
||||
up.Store(true)
|
||||
fakeGitHub(t, &up, &asked)
|
||||
ctx := context.Background()
|
||||
if l := TaggedRepos(ctx); len(l) != 6 {
|
||||
if l := TaggedRepos(ctx); len(l) != 7 {
|
||||
t.Fatalf("%d repos", len(l))
|
||||
}
|
||||
|
||||
@@ -292,7 +301,7 @@ func TestTaggedReposSlowRead(t *testing.T) {
|
||||
cutAsked := time.Now()
|
||||
l := TaggedRepos(ctx)
|
||||
cutDone := time.Now()
|
||||
if x := has(l, "someone/word-guard"); len(l) != 6 || x == nil || x.Kind != "middleware" {
|
||||
if x := has(l, "someone/word-guard"); len(l) != 7 || x == nil || x.Kind != "middleware" {
|
||||
t.Fatalf("slow package.json: %d repos, word-guard %+v", len(l), x)
|
||||
}
|
||||
if n := asked.Load(); n != 2 {
|
||||
@@ -352,7 +361,7 @@ func TestTaggedReposSlowRead(t *testing.T) {
|
||||
if n := asked.Load(); n != 3 {
|
||||
t.Fatalf("a list cut short kept: asked %d times", n)
|
||||
}
|
||||
if x := has(l, "someone/word-guard"); len(l) != 6 || x == nil || x.Package != "@magpie-community/middleware-word-guard" {
|
||||
if x := has(l, "someone/word-guard"); len(l) != 7 || x == nil || x.Package != "@magpie-community/middleware-word-guard" {
|
||||
t.Fatalf("asked again: %d repos, word-guard %+v", len(l), x)
|
||||
}
|
||||
// flaky-entry's package.json, npm and entry, as ten minutes on
|
||||
|
||||
@@ -42,7 +42,7 @@ type Listing struct {
|
||||
Providers []string `json:"providers,omitempty"` // OpenCode's ids of those it signs in to
|
||||
Community bool `json:"community,omitempty"` // written by magpie's community
|
||||
Replaces string `json:"replaces,omitempty"` // the built-in subscription it does the work of
|
||||
Kind string `json:"kind,omitempty"` // "middleware" for gateway middleware, "agent" for an agent; none for a provider
|
||||
Kind string `json:"kind,omitempty"` // "middleware" for gateway middleware, "agent" for an agent, "tools" for tools alone, "page" for a page alone; none for a provider
|
||||
Summary map[string]string `json:"summary,omitempty"` // by language: en, zh
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "magpie-usage-glance",
|
||||
"version": "0.1.0",
|
||||
"description": "An example of a plugin's own page in magpie's window: today's usage at a glance",
|
||||
"magpie": {
|
||||
"page": { "title": "Usage glance", "file": "page/index.html", "icon": "page/icon.svg" },
|
||||
"permissions": ["usage:summary"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><title>Usage glance</title>
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "magpie-page-gone",
|
||||
"version": "0.1.0",
|
||||
"description": "An example of a plugin's own page in magpie's window: today's usage at a glance",
|
||||
"magpie": {
|
||||
"page": { "title": "Usage glance", "file": "page/index.html", "icon": "page/icon.svg" },
|
||||
"permissions": ["usage:summary"]
|
||||
}
|
||||
}
|
||||
@@ -598,11 +598,11 @@ m plugin logout acme</pre>
|
||||
<span class="s">"providers"</span>: [<span class="s">"acme"</span>],
|
||||
<span class="s">"summary"</span>: { <span class="s">"en"</span>: <span class="s">"Your Acme Coding Plan."</span>, <span class="s">"zh"</span>: <span class="s">"使用你的 Acme Coding Plan。"</span> } }</pre>
|
||||
</div>
|
||||
ミドルウェアのエントリには <code>"kind": "middleware"</code> を書き、<code>providers</code> は書きません。<span class="ui">ゲートウェイミドルウェア</span> の下に表示されます。<code>MAGPIE_PLUGIN_MARKET=<url></code> は magpie に別の一覧を参照させます(自分の一覧の確認に便利です)。<code>off</code> にすると内蔵のコピーだけを使います。</li>
|
||||
ミドルウェアのエントリには <code>"kind": "middleware"</code> を書き、<code>providers</code> は書きません。<span class="ui">ゲートウェイミドルウェア</span> の下に表示されます。ほかの種類も同じで、<code>"kind": "tools"</code> は <span class="ui">エージェント向けツール</span>、<code>"kind": "page"</code> は <span class="ui">ページ</span>、<code>"kind": "agent"</code> は <span class="ui">エージェント</span> の下に表示されます。<code>MAGPIE_PLUGIN_MARKET=<url></code> は magpie に別の一覧を参照させます(自分の一覧の確認に便利です)。<code>off</code> にすると内蔵のコピーだけを使います。</li>
|
||||
<li><b>GitHub のトピック。</b>GitHub で <code>magpie-plugin</code> トピックを付けたリポジトリは、<span class="ui">プラグイン → 発見 → 非公式 · GitHub</span> に、スターの多い順に、誰もレビューしていないものとして表示されます。<code>package.json</code> はリポジトリのルートに置いてください。<code>repository</code> がそのリポジトリを指す形で npm に公開されていれば npm からインストールされ、そうでなければリポジトリの現在のコードがインストールされます。そのため読み込むファイルはコミットしておく必要があり、<code>dist</code> を公開時にしかビルドしないリポジトリは表示されません。フォーク、アーカイブ済みのリポジトリ、magpie-community 自身のものも表示されません。magpie が GitHub に問い合わせるのは最大で 10 分に 1 回なので、トピックを付けたリポジトリは数分で表示されます。カードには <code>package.json</code> の <code>"magpie": { "icon": "…" }</code> で指定したアイコンが表示され、ない場合はパズルのアイコンになります。</li>
|
||||
<li><b>コミュニティのパッケージ。</b><a href="https://github.com/magpie-community/plugins">magpie-community/plugins</a> に貢献するには:
|
||||
<ul>
|
||||
<li><code>packages/<name></code> に置き、名前はプロバイダなら <code>@magpie-community/opencode-<name>-auth</code>、ミドルウェアなら <code>@magpie-community/middleware-<name></code> とします。本当に必要でない限り、ランタイムの依存は持たせないでください。</li>
|
||||
<li><code>packages/<name></code> に置き、名前はプロバイダなら <code>@magpie-community/opencode-<name>-auth</code>、ミドルウェアやルーティング戦略なら <code>@magpie-community/middleware-<name></code>、ツールなら <code>@magpie-community/tools-<name></code>、ページなら <code>@magpie-community/page-<name></code>、エージェントなら <code>@magpie-community/agent-<name></code> とします。本当に必要でない限り、ランタイムの依存は持たせないでください。</li>
|
||||
<li>バージョンを上げて <code>main</code> にプッシュすると公開されます。</li>
|
||||
<li>これらのパッケージは、どの magpie でも自動で更新されます。</li>
|
||||
</ul></li>
|
||||
|
||||
@@ -598,11 +598,11 @@ m plugin logout acme</pre>
|
||||
<span class="s">"providers"</span>: [<span class="s">"acme"</span>],
|
||||
<span class="s">"summary"</span>: { <span class="s">"en"</span>: <span class="s">"Your Acme Coding Plan."</span>, <span class="s">"zh"</span>: <span class="s">"使用你的 Acme Coding Plan。"</span> } }</pre>
|
||||
</div>
|
||||
A middleware’s entry has <code>"kind": "middleware"</code> and no <code>providers</code>; it is listed under <span class="ui">Gateway middleware</span>. <code>MAGPIE_PLUGIN_MARKET=<url></code> points magpie at another list, which is useful to check yours, and <code>off</code> keeps to the built-in copy.</li>
|
||||
A middleware’s entry has <code>"kind": "middleware"</code> and no <code>providers</code>; it is listed under <span class="ui">Gateway middleware</span>. The other kinds are listed the same way: <code>"kind": "tools"</code> under <span class="ui">Tools for agents</span>, <code>"kind": "page"</code> under <span class="ui">Pages</span> and <code>"kind": "agent"</code> under <span class="ui">Agents</span>. <code>MAGPIE_PLUGIN_MARKET=<url></code> points magpie at another list, which is useful to check yours, and <code>off</code> keeps to the built-in copy.</li>
|
||||
<li><b>A GitHub topic.</b> A repository tagged <code>magpie-plugin</code> on GitHub is shown under <span class="ui">Plugins → Discover → Unofficial, on GitHub</span>, the most starred first, marked as reviewed by no one. Keep <code>package.json</code> at the repository’s root. Published to npm with <code>repository</code> naming the repository, it is installed from npm; otherwise from the repository as it stands, so the file it loads must be committed: one whose <code>dist</code> is built only to publish is left out. Forks, archived repositories and magpie-community’s own are left out too. magpie asks GitHub at most every ten minutes, so a repository shows within minutes of being tagged. Its card shows the icon <code>"magpie": { "icon": "…" }</code> in its <code>package.json</code> gives, else a puzzle piece.</li>
|
||||
<li><b>The community packages.</b> To contribute one to <a href="https://github.com/magpie-community/plugins">magpie-community/plugins</a>:
|
||||
<ul>
|
||||
<li>Put it under <code>packages/<name></code>, named <code>@magpie-community/opencode-<name>-auth</code> (a provider) or <code>@magpie-community/middleware-<name></code> (middleware), with no runtime dependencies unless one is really needed.</li>
|
||||
<li>Put it under <code>packages/<name></code>, named <code>@magpie-community/opencode-<name>-auth</code> (a provider) , <code>@magpie-community/middleware-<name></code> (middleware or a routing strategy), <code>@magpie-community/tools-<name></code> (tools), <code>@magpie-community/page-<name></code> (a page) or <code>@magpie-community/agent-<name></code> (an agent), with no runtime dependencies unless one is really needed.</li>
|
||||
<li>Pushing a version bump to <code>main</code> publishes it.</li>
|
||||
<li>These packages update by themselves in every magpie.</li>
|
||||
</ul></li>
|
||||
|
||||
@@ -598,11 +598,11 @@ m plugin logout acme</pre>
|
||||
<span class="s">"providers"</span>: [<span class="s">"acme"</span>],
|
||||
<span class="s">"summary"</span>: { <span class="s">"en"</span>: <span class="s">"Your Acme Coding Plan."</span>, <span class="s">"zh"</span>: <span class="s">"使用你的 Acme Coding Plan。"</span> } }</pre>
|
||||
</div>
|
||||
中间件的条目写 <code>"kind": "middleware"</code>,不写 <code>providers</code>,列在<span class="ui">网关中间件</span>下。<code>MAGPIE_PLUGIN_MARKET=<url></code> 让 magpie 改用另一份列表,可以用来检查你的条目;设为 <code>off</code> 则只用内置副本。</li>
|
||||
中间件的条目写 <code>"kind": "middleware"</code>,不写 <code>providers</code>,列在<span class="ui">网关中间件</span>下。其他类型也一样:<code>"kind": "tools"</code> 列在<span class="ui">给 Agent 的工具</span>下,<code>"kind": "page"</code> 列在<span class="ui">页面</span>下,<code>"kind": "agent"</code> 列在 <span class="ui">Agent</span> 下。<code>MAGPIE_PLUGIN_MARKET=<url></code> 让 magpie 改用另一份列表,可以用来检查你的条目;设为 <code>off</code> 则只用内置副本。</li>
|
||||
<li><b>GitHub 标签。</b>在 GitHub 上打了 <code>magpie-plugin</code> topic 的仓库,会显示在 <span class="ui">插件 → 发现 → 非官方插件 · GitHub</span> 里,Star 多的在前,并标明没有人审阅过。<code>package.json</code> 要放在仓库根目录。发布到 npm 且 <code>repository</code> 指向这个仓库的,从 npm 安装;否则按仓库当前的代码安装,所以它加载的文件必须提交进仓库:<code>dist</code> 只在发布时才构建的仓库不会显示。fork、已归档的仓库和 magpie-community 自己的仓库也不显示。magpie 最多每十分钟问一次 GitHub,仓库打上标签后几分钟内就会出现。卡片显示 <code>package.json</code> 里 <code>"magpie": { "icon": "…" }</code> 给的图标,没有就显示拼图图标。</li>
|
||||
<li><b>社区包。</b>想把插件贡献到 <a href="https://github.com/magpie-community/plugins">magpie-community/plugins</a>:
|
||||
<ul>
|
||||
<li>放在 <code>packages/<name></code> 下,包名为 <code>@magpie-community/opencode-<name>-auth</code>(供应商)或 <code>@magpie-community/middleware-<name></code>(中间件),除非确实需要,不要有运行时依赖。</li>
|
||||
<li>放在 <code>packages/<name></code> 下,包名为 <code>@magpie-community/opencode-<name>-auth</code>(供应商)、<code>@magpie-community/middleware-<name></code>(中间件或路由策略)、<code>@magpie-community/tools-<name></code>(工具)、<code>@magpie-community/page-<name></code>(页面)或 <code>@magpie-community/agent-<name></code>(Agent),除非确实需要,不要有运行时依赖。</li>
|
||||
<li>把版本号的改动推到 <code>main</code> 就会发布。</li>
|
||||
<li>这些包在每个 magpie 里都会自动更新。</li>
|
||||
</ul></li>
|
||||
|
||||
Reference in New Issue
Block a user