diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index fae6910bf..738ae57af 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -3486,6 +3486,15 @@ const I18N = { "Getting Bun…": "正在下载 Bun…", "Plugins run on Bun {v}, downloaded once": "插件运行在 Bun {v} 上,只需下载一次", "Coming soon": "即将上线", + "Unofficial": "非官方", + "Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者在 GitHub 上给它打了 {topic} 标签,magpie 没有审阅过:安装前请先看看它的代码", + "{n} stars on GitHub": "GitHub 上 {n} 个 Star", + "Unofficial, on GitHub": "非官方插件 · GitHub", + "repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one": "作者自己打了 {topic} 标签的仓库,未经审阅,安装前请先看代码", + "Stars": "Star", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from the repository as it stands, and runs with your sign-in or your requests.": "非官方插件:{owner} 在 GitHub 上给它打了 {topic} 标签,magpie 没有审阅过。安装的是仓库当前的代码,它会用到你的登录信息或经手你的请求。", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from npm, as its author published it from the repository, and runs with your sign-in or your requests.": "非官方插件:{owner} 在 GitHub 上给它打了 {topic} 标签,magpie 没有审阅过。安装的是作者从这个仓库发布到 npm 的版本,它会用到你的登录信息或经手你的请求。", + "GitHub didn't answer: {error}": "GitHub 没有响应:{error}", "Not on npm yet": "还没有发布到 npm", "Install": "安装", "Sign in to {name}": "登录 {name}", @@ -7041,6 +7050,15 @@ const I18N = { "Getting Bun…": "Bun を取得中…", "Plugins run on Bun {v}, downloaded once": "プラグインは Bun {v} で動作します(ダウンロードは一度だけ)", "Coming soon": "近日公開", + "Unofficial": "非公式", + "Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者が GitHub で {topic} タグを付けたものです。magpie はレビューしていません。インストール前にコードを確認してください", + "{n} stars on GitHub": "GitHub のスター {n}", + "Unofficial, on GitHub": "非公式 · GitHub", + "repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one": "作者自身が {topic} タグを付けたリポジトリ。レビューされていないので、インストール前にコードを確認してください", + "Stars": "スター", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from the repository as it stands, and runs with your sign-in or your requests.": "非公式:{owner} が GitHub で {topic} タグを付けたもので、magpie はレビューしていません。リポジトリの現在のコードがインストールされ、あなたのサインインやリクエストを扱います。", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from npm, as its author published it from the repository, and runs with your sign-in or your requests.": "非公式:{owner} が GitHub で {topic} タグを付けたもので、magpie はレビューしていません。作者がこのリポジトリから npm に公開したものがインストールされ、あなたのサインインやリクエストを扱います。", + "GitHub didn't answer: {error}": "GitHub から応答がありません:{error}", "Not on npm yet": "まだ npm にありません", "Install": "インストール", "Sign in to {name}": "{name} にサインイン", @@ -10616,6 +10634,15 @@ const I18N = { "Getting Bun…": "Bun wird geladen…", "Plugins run on Bun {v}, downloaded once": "Erweiterungen laufen auf Bun {v}, einmalig heruntergeladen", "Coming soon": "Demnächst", + "Unofficial": "Inoffiziell", + "Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "Vom Autor auf GitHub mit {topic} getaggt. Niemand bei magpie hat es geprüft: Lies den Code, bevor du es installierst", + "{n} stars on GitHub": "{n} Sterne auf GitHub", + "Unofficial, on GitHub": "Inoffiziell, auf GitHub", + "repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one": "Repositories, die ihre Autoren mit {topic} getaggt haben – ungeprüft; lies den Code, bevor du eines installierst", + "Stars": "Sterne", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from the repository as it stands, and runs with your sign-in or your requests.": "Inoffiziell: {owner} hat es auf GitHub mit {topic} getaggt, und niemand bei magpie hat es geprüft. Installiert wird das Repository, wie es gerade ist; es arbeitet mit deiner Anmeldung oder deinen Anfragen.", + "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from npm, as its author published it from the repository, and runs with your sign-in or your requests.": "Inoffiziell: {owner} hat es auf GitHub mit {topic} getaggt, und niemand bei magpie hat es geprüft. Installiert wird, was der Autor aus dem Repository auf npm veröffentlicht hat; es arbeitet mit deiner Anmeldung oder deinen Anfragen.", + "GitHub didn't answer: {error}": "GitHub hat nicht geantwortet: {error}", "Not on npm yet": "Noch nicht auf npm", "Install": "Installieren", "Sign in to {name}": "Bei {name} anmelden", diff --git a/internal/gui/assets/plugins.css b/internal/gui/assets/plugins.css index 5b1cfaa49..e2e116b6c 100644 --- a/internal/gui/assets/plugins.css +++ b/internal/gui/assets/plugins.css @@ -118,6 +118,8 @@ button.pm-chip:disabled { cursor: default; opacity: .6; } .pm-note { margin: 0; padding: 4px 2px; font-size: 12px; color: var(--muted); } .pm-note.bad { color: var(--red); } +.pm-note.warn { display: flex; align-items: flex-start; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--amber-soft); color: var(--fg); line-height: 1.5; } +.pm-note.warn svg { flex: none; margin-top: 2px; color: var(--amber); } .pm-empty { margin: 24px 4px; font-size: 12.5px; color: var(--red); } /* a package the market doesn't list */ diff --git a/internal/gui/assets/plugins.js b/internal/gui/assets/plugins.js index 8c51c078f..86c15a269 100644 --- a/internal/gui/assets/plugins.js +++ b/internal/gui/assets/plugins.js @@ -13,6 +13,8 @@ let mine = null; // /api/plugins: what's installed let listings = null; // /api/plugins/listings: the plugins suggested + let tagged = null; // /api/plugins/github: repositories their authors tagged magpie-plugin, as listings + let topic = "magpie-plugin"; const npm = {}; // /api/plugins/npm: package → what npm says of it let failed = ""; // why what's installed couldn't be loaded let failedList = ""; // ...and the plugins suggested @@ -30,6 +32,7 @@ const SEARCH = "M7 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8z M10 10l3 3"; const DOWN = "M8 3v7.5 M4.8 7.6 8 10.8l3.2-3.2 M3.5 13h9"; + const STAR = "M8 2.2l1.8 3.7 4 .6-2.9 2.8.7 4L8 11.4l-3.6 1.9.7-4L2.2 6.5l4-.6z"; const SHIELD = "M8 2.3 13 4v3.8c0 3-2.1 5.1-5 5.9-2.9-.8-5-2.9-5-5.9V4z M5.8 8l1.6 1.6 2.9-3"; const OUTL = "M9.5 3.5h3v3 M12.5 3.5 7.5 8.5 M11 9.5v3H3.5V5h3"; const PLUG = "M6 2v3 M10 2v3 M4.5 5h7v2.5a3.5 3.5 0 0 1-7 0z M8 11v3"; @@ -55,7 +58,14 @@ const lang = () => (document.documentElement.lang || "en").slice(0, 2); const summary = (l) => l.summary?.[lang()] || l.summary?.en || l.npm?.description || ""; const count = (n) => n >= 1e6 ? (n / 1e6).toFixed(n >= 1e7 ? 0 : 1) + "M" : n >= 1e3 ? (n / 1e3).toFixed(n >= 1e4 ? 0 : 1) + "k" : String(n || 0); - const entryOf = (pkg) => mine?.plugins?.find((e) => name(e.spec) === pkg); + // a repository tagged magpie-plugin is installed by whichever spec + // names it (github:owner/repo, its page's URL), or as the package its + // package.json names + const ghRepo = (spec) => { const m = /^(?:github:|https?:\/\/(?:www\.)?github\.com\/)([^/#\s]+\/[^/#\s]+?)(?:\.git)?(?:[/#].*)?$/i.exec(spec) || (isGit(spec) && /^([^:/#]+\/[^:/#]+)(?:#.*)?$/.exec(spec)); return m ? m[1].toLowerCase() : ""; }; + const entryOf = (pkg) => { + const g = (tagged || []).find((x) => x.package === pkg)?.github; + return mine?.plugins?.find((e) => name(e.spec) === pkg || (g && (ghRepo(e.spec) === g.repo.toLowerCase() || (g.package && isGit(e.spec) && e.package === g.package)))); + }; // npm has the versions of a package: not a folder's, nor a git one's const onNPM = (spec) => !isPath(spec) && !isGit(spec); // the providers a plugin signs in to, as the add sheet knows them @@ -107,6 +117,22 @@ } merge(); } + // a repository tagged magpie-plugin as the market's cards read a + // listing: its owner as the publisher, its version, and installed by its + // spec (its npm name when its author published it there from the + // repository, else github:owner/repo) + const ghListing = (r) => ({ + package: r.spec, name: r.repo.split("/")[1], kind: r.kind, github: r, + summary: r.description ? { en: r.description } : undefined, + npm: { version: r.version || "", publisher: r.owner, repository: r.url, license: r.license, weekly: 0 }, + }); + async function loadTagged() { + try { + const r = await api("plugins/github"); + tagged = (r.repos || []).map(ghListing); + if (r.topic) topic = r.topic; + } catch { tagged = tagged || []; } + } async function loadListings() { try { const r = await api("plugins/listings"); @@ -138,6 +164,7 @@ const parts = [ loadMine().then(() => { redraw(); window.renderPluginDot?.(); }), loadListings().then(redraw), + loadTagged().then(drawBody), providers ? null : loadProviders().then(drawBody, () => {}), ]; await Promise.all(parts); @@ -302,7 +329,7 @@ return b; } if (!e) { - if (listed && !listed.npm?.version) { + if (listed && !listed.github && !listed.npm?.version) { b.textContent = t("Coming soon"); b.disabled = true; b.title = t("Not on npm yet"); @@ -370,10 +397,12 @@ by.append(v); } else by.append(el("span", "", l.npm?.publisher || l.package)); who.append(by); + if (l.github) c.classList.add("gh"); top.append(logo(l.icon, false, l.kind === "middleware"), who, actionFor(l.package, l.name, l)); const sum = el("p", "pm-sum", summary(l)); const meta = el("div", "pm-meta"); meta.append(kindChip(l.kind === "middleware")); + if (l.github) meta.append(unofficial(), stars(l.github.stars)); if (l.npm?.weekly) { const d = el("span", "pm-dl"); d.append(glyph(DOWN, 11, 1.5), el("span", "", t("{n}/week", { n: count(l.npm.weekly) }))); @@ -408,6 +437,19 @@ return c; } + // a repository's author put it here, nobody reviewed it: said on its card + function unofficial() { + const u = el("span", "pm-chip warn", t("Unofficial")); + u.title = t("Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it", { topic }); + return u; + } + function stars(n) { + const d = el("span", "pm-dl"); + d.append(glyph(STAR, 11, 1.4), el("span", "", count(n))); + d.title = t("{n} stars on GitHub", { n: (n || 0).toLocaleString() }); + return d; + } + function skeleton(n) { const g = el("div", "pm-grid"); for (let i = 0; i < n; i++) { @@ -541,7 +583,11 @@ return; } const f = query.trim().toLowerCase(); - const ls = listings.filter((l) => !f || [l.name, l.package, summary(l), (l.providers || []).join(" "), l.npm?.publisher || ""].join(" ").toLowerCase().includes(f)); + const match = (l) => !f || [l.name, l.package, summary(l), (l.providers || []).join(" "), l.npm?.publisher || ""].join(" ").toLowerCase().includes(f); + const ls = listings.filter(match); + // a tagged repository the market already lists is the market's card + const listed = new Set(listings.map((l) => l.package)); + const gh = (tagged || []).filter((l) => !(l.github.package && listed.has(l.github.package)) && match(l)); if (!f) { body.append(intro()); // magpie's community's alone: others' plugins are found by a search @@ -549,11 +595,13 @@ const mws = ls.filter((l) => l.community && l.kind === "middleware"); if (ours.length) body.append(section(t("Subscriptions"), t("written for magpie, checked against its own sign-ins"), ours)); if (mws.length) body.append(section(t("Gateway middleware"), t("runs in magpie's gateway on what every agent sends and gets back, whichever provider serves it"), mws)); + if (gh.length) body.append(section(t("Unofficial, on GitHub"), t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic }), gh)); body.append(manual()); return; } if (ls.length) body.append(section(t("Suggested"), "", ls)); - const known = new Set(listings.map((l) => l.package)); + if (gh.length) body.append(section(t("Unofficial, on GitHub"), t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic }), gh)); + const known = new Set([...listings.map((l) => l.package), ...(tagged || []).map((l) => l.github.package).filter(Boolean)]); const box = el("section", "pm-sec"); const h = el("div", "pm-sechead"); h.append(el("h3", "", t("On npm")), el("span", "", t("OpenCode plugins and pi packages anyone published — read what one does before you install it"))); @@ -969,6 +1017,7 @@ const fact = (k, v) => { if (!v) return; const f = el("div", "pm-fact"); f.append(el("span", "k", k), typeof v === "string" ? el("span", "v", v) : v); facts.append(f); }; fact(t("Version"), l.npm?.version && "v" + l.npm.version); fact(t("Downloads"), l.npm?.weekly ? t("{n}/week", { n: count(l.npm.weekly) }) : ""); + if (l.github) fact(t("Stars"), count(l.github.stars)); fact(t("License"), l.npm?.license); const upd = el("span", "v", "…"); fact(t("Updated"), upd); @@ -985,9 +1034,18 @@ }; // npm is where a package's page is; a folder on this computer has none if (!local) link("npm", "https://www.npmjs.com/package/" + l.package); - link(t("Source"), l.npm?.repository); + link(l.github ? "GitHub" : t("Source"), l.npm?.repository); if (l.npm?.homepage && l.npm.homepage !== l.npm.repository && !l.npm.homepage.startsWith(l.npm.repository + "#")) link(t("Homepage"), l.npm.homepage); main.append(links); + if (l.github) { + const w = el("p", "pm-note warn"); + // from npm when its author published it there from the repository + const from = isGit(l.package) + ? "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from the repository as it stands, and runs with your sign-in or your requests." + : "Unofficial: {owner} tagged it {topic} on GitHub, and nobody at magpie has reviewed it. It is installed from npm, as its author published it from the repository, and runs with your sign-in or your requests."; + w.append(glyph(SHIELD, 12, 1.5), el("span", "", t(from, { owner: l.github.owner, topic }))); + main.append(w); + } if (l.replaces) main.append(el("p", "pm-note", t("magpie also signs in to this itself, for now; the plugin keeps it working if the built-in one is retired."))); const readme = el("div", "pm-readme"); readme.append(el("div", "pm-rskel"), el("div", "pm-rskel short"), el("div", "pm-rskel")); @@ -1005,11 +1063,12 @@ function stop() { clearInterval(tick); } try { const p = await api("plugins/page?name=" + encodeURIComponent(l.package)); - upd.textContent = p.updated && !p.updated.startsWith("0001") ? new Date(p.updated).toLocaleDateString(document.documentElement.lang || undefined, { year: "numeric", month: "short", day: "numeric" }) : "—"; + const at = l.github && !entryOf(l.package) ? l.github.pushed : p.updated; + upd.textContent = at && !at.startsWith("0001") ? new Date(at).toLocaleDateString(document.documentElement.lang || undefined, { year: "numeric", month: "short", day: "numeric" }) : "—"; readme.replaceChildren(markdown(p.readme || t("No README"))); } catch (e) { upd.textContent = "—"; - readme.replaceChildren(el("p", "pm-note", t(local ? "Couldn't read the folder's README: {error}" : "npm didn't answer: {error}", { error: e.message }))); + readme.replaceChildren(el("p", "pm-note", t(l.github && isGit(l.package) && !entryOf(l.package) ? "GitHub didn't answer: {error}" : local ? "Couldn't read the folder's README: {error}" : "npm didn't answer: {error}", { error: e.message }))); } } diff --git a/internal/gui/plugins.go b/internal/gui/plugins.go index 36848f912..742218f01 100644 --- a/internal/gui/plugins.go +++ b/internal/gui/plugins.go @@ -253,6 +253,11 @@ func pluginRoutes(mux *http.ServeMux, w Windows) { mux.HandleFunc("GET /api/plugins/listings", func(rw http.ResponseWriter, r *http.Request) { writeJSON(rw, map[string]any{"listings": pluginListings(r.Context())}) }) + // repositories on GitHub tagged magpie-plugin: nobody's list, shown + // apart as not reviewed, installed from the repository + mux.HandleFunc("GET /api/plugins/github", func(rw http.ResponseWriter, r *http.Request) { + writeJSON(rw, map[string]any{"repos": plugin.TaggedRepos(r.Context()), "topic": plugin.Topic}) + }) mux.HandleFunc("GET /api/plugins/npm", func(rw http.ResponseWriter, r *http.Request) { names := []string{} for _, n := range strings.Split(r.URL.Query().Get("names"), ",") { diff --git a/internal/gui/tests/plugin-github.test.cjs b/internal/gui/tests/plugin-github.test.cjs new file mode 100644 index 000000000..c762c7ae9 --- /dev/null +++ b/internal/gui/tests/plugin-github.test.cjs @@ -0,0 +1,208 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Repositories their authors tagged magpie-plugin on GitHub (yetone: 在插件页 +//能否自动识别打了 magpie-plugin 的 github repo 来显示为非官方插件): Discover +// shows them in a section of their own after the community's, each card +// saying Unofficial, its owner and its stars. One whose package the market +// already lists is the market's card alone. Install sends the spec magpie +// gave: the npm name of one its author published there from the +// repository, else github:owner/repo; one installed by any spec naming the +// repository reads Installed. Its page warns that nobody reviewed it and +// says which of the two is installed, links GitHub (and npm when it is +// npm's), shows the README and when the repository was last pushed. A +// search finds them too. The repositories are /api/plugins/github's real +// answer for four repositories (asked of a magpie built to search topic:opencode-plugin, as +// none is tagged magpie-plugin yet); the API is faked here. English, +// Chinese, Japanese and German, wide and 440px, nothing scrolls on a click. +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 REPOS = [ + { spec: "opencode-claude-auth", repo: "griffinmartin/opencode-claude-auth", url: "https://github.com/griffinmartin/opencode-claude-auth", owner: "griffinmartin", ownerAvatar: "https://avatars.githubusercontent.com/u/1090329?v=4", description: "OpenCode plugin that uses your existing Claude Code credentials — no separate login needed. ", stars: 1301, license: "MIT", pushed: "2026-09-22T23:47:15Z", package: "opencode-claude-auth", version: "2.2.1" }, + { spec: "@slkiser/opencode-quota", repo: "slkiser/opencode-quota", url: "https://github.com/slkiser/opencode-quota", owner: "slkiser", ownerAvatar: "https://avatars.githubusercontent.com/u/35721408?v=4", description: "OpenCode quota & tokens usage with zero context window pollution. Supports OpenCode Go, Cursor, GitHub Copilot, OpenAl, Kimi Code, Alibaba Coding Plan, Chutes Al, Google Antigravity, Z.ai Coding Plan and more.", stars: 1000, license: "MIT", pushed: "2026-10-06T13:25:50Z", package: "@slkiser/opencode-quota", version: "5.0.2" }, + { spec: "github:keli-wen/agy-staff", repo: "keli-wen/agy-staff", url: "https://github.com/keli-wen/agy-staff", owner: "keli-wen", ownerAvatar: "https://avatars.githubusercontent.com/u/103916249?v=4", description: "Hire Google's Antigravity CLI (agy) as a fast Gemini staffer for Claude Code and OpenAI Codex.", stars: 723, license: "MIT", pushed: "2026-10-06T16:29:15Z", package: "agy-staff", version: "0.7.4" }, + { spec: "@rama_nigg/open-cursor", repo: "Nomadcxx/opencode-cursor", url: "https://github.com/Nomadcxx/opencode-cursor", owner: "Nomadcxx", ownerAvatar: "https://avatars.githubusercontent.com/u/143774106?v=4", description: "Use Cursor Pro models in OpenCode via HTTP proxy with OAuth", stars: 704, license: "BSD-3-Clause", pushed: "2026-10-02T12:34:45Z", package: "@rama_nigg/open-cursor", version: "2.5.11" }, +]; +// the market lists the fourth's package: its card is the market's +const LISTINGS = [ + { package: "@rama_nigg/open-cursor", name: "Open Cursor", community: true, npm: { version: "2.5.11", weekly: 900, license: "BSD-3-Clause" } }, +]; +const README = { "opencode-claude-auth": "# opencode-claude-auth\n\nUses your existing Claude Code credentials.", "github:keli-wen/agy-staff": "# agy-staff\n\nHire agy as a staffer." }; + +function server(lang, asked) { + // installed before: the quota plugin, by its repository's page URL + const installed = [{ spec: "https://github.com/slkiser/opencode-quota", package: "@slkiser/opencode-quota", providers: [], version: "5.0.2", moved: [] }]; + const state = () => ({ bun: true, bunVersion: "1.4.2", plugins: installed, picker: false, movable: [] }); + return async (route) => { + const url = new URL(route.request().url()); + const json = (data) => route.fulfill({ json: data }); + const body = () => route.request().postDataJSON(); + 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: LISTINGS.map((l) => ({ ...l, npm: undefined })) }); + if (url.pathname === "/api/plugins/npm") return json({ npm: { "@rama_nigg/open-cursor": LISTINGS[0].npm } }); + if (url.pathname === "/api/plugins/github") { asked.push(["github"]); return json({ repos: REPOS, topic: "magpie-plugin" }); } + if (url.pathname === "/api/plugins/search") return json({ hits: [] }); + if (url.pathname === "/api/plugins/updates") return json({ waiting: [], updated: [] }); + if (url.pathname === "/api/plugins/page") { + asked.push(["page", url.searchParams.get("name")]); + return json({ readme: README[url.searchParams.get("name")] || "", updated: "0001-01-01T00:00:00Z" }); + } + if (url.pathname === "/api/plugins/add") { + const b = body(); + asked.push(["add", b]); + const r = REPOS.find((x) => x.spec === b.spec); + installed.push({ spec: b.spec, package: r.package, providers: [], version: r.version, moved: [] }); + return json(state()); + } + if (url.pathname === "/api/open") { asked.push(["open", body()]); return route.fulfill({ status: 204 }); } + if (url.pathname.startsWith("/api/")) return json({}); + if (!/^\/[\w./-]*$/.test(url.pathname) || url.host !== "magpie.test") { asked.push(["fetched", url.href]); return route.fulfill({ status: 404, body: "" }); } + 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: { section: "Unofficial, on GitHub", chip: "Unofficial", install: "Install", installed: "Installed", updated: "Updated", warn: /Unofficial: griffinmartin tagged it magpie-plugin on GitHub/, fromNPM: /installed from npm/, fromGit: /installed from the repository as it stands/ }, + zh: { section: "非官方插件 · GitHub", chip: "非官方", install: "安装", installed: "已安装", updated: "更新于", warn: /非官方插件:griffinmartin 在 GitHub 上给它打了 magpie-plugin 标签/, fromNPM: /从这个仓库发布到 npm/, fromGit: /仓库当前的代码/ }, + ja: { section: "非公式 · GitHub", chip: "非公式", install: "インストール", installed: "インストール済み", updated: "更新日", warn: /非公式:griffinmartin が GitHub で magpie-plugin タグを付けた/, fromNPM: /npm に公開したもの/, fromGit: /リポジトリの現在のコード/ }, + de: { section: "Inoffiziell, auf GitHub", chip: "Inoffiziell", install: "Installieren", installed: "Installiert", updated: "Aktualisiert", warn: /Inoffiziell: griffinmartin hat es auf GitHub mit magpie-plugin getaggt/, fromNPM: /auf npm veröffentlicht/, fromGit: /das Repository, wie es gerade ist/ }, +}; + +const shot = async (loc, name) => { + if (!process.env.ARTIFACT_DIR) return; + await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); + await loc.screenshot({ path: path.join(process.env.ARTIFACT_DIR, name + ".png") }); +}; + +const scrolls = (page) => page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join(",")); + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": repositories tagged magpie-plugin, as unofficial plugins", async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" })); + t.after(() => browser.close()); + for (const lang of Object.keys(L)) { + for (const width of [980, 440]) { + await t.test(lang + " " + width, async () => { + const w = L[lang]; + const asked = []; + const page = await (await browser.newContext({ viewport: { width, height: 860 } })).newPage(); + page.setDefaultTimeout(5000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang, asked)); + await page.addInitScript(() => { try { localStorage.setItem("magpie.pluginTab", "discover"); } catch {} }); + + await page.goto("http://magpie.test/?view=plugins"); + const view = page.locator("#view-plugins"); + await view.waitFor({ state: "visible" }); + + // a section of their own, after the community's, before the field + const sec = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) }); + await sec.waitFor(); + const order = await view.locator(".pm-body > *").evaluateAll((es) => es.map((e) => e.className.split(" ")[0])); + assert.ok(order.indexOf("pm-manual") > order.lastIndexOf("pm-sec"), "the field stays last: " + order); + assert.match(await sec.locator(".pm-sechead span").innerText(), /magpie-plugin/); + const cards = sec.locator(".pm-card"); + assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), ["opencode-claude-auth", "opencode-quota", "agy-staff"], "the market's own package is its card alone"); + assert.equal(await view.locator(".pm-card", { hasText: "Open Cursor" }).count(), 1); + + const c = cards.first(); + assert.equal((await c.locator(".pm-by").innerText()).trim(), "griffinmartin"); + assert.equal((await c.locator(".pm-chip.warn").innerText()).trim(), w.chip); + assert.match(await c.locator(".pm-chip.warn").getAttribute("title"), /magpie-plugin/); + assert.equal((await c.locator(".pm-dl").innerText()).trim(), "1.3k"); + assert.equal((await c.locator(".pm-ver").innerText()).trim(), "v2.2.1"); + // installed by its page's URL: Installed all the same + await cards.nth(1).locator(".pm-act.done").waitFor(); + assert.match(await cards.nth(1).locator(".pm-act").innerText(), new RegExp(w.installed)); + // nothing cut or spilling at this width + for (const card of await cards.all()) { + const fit = await card.evaluate((e) => [e.scrollWidth <= e.clientWidth + 1, ...[...e.querySelectorAll(".pm-chip, .pm-act, .pm-name b")].map((x) => x.getBoundingClientRect().width > 8 && x.getBoundingClientRect().right <= e.getBoundingClientRect().right + 1)]); + assert.ok(fit.every(Boolean), "fits: " + fit); + } + await shot(sec, `plugins-github-${engine}-${lang}-${width}`); + + // its page: the warning, npm's and GitHub's links and the README, + // when it was pushed + // a reader scrolls to a card (narrow, below the fold); magpie + // undoes a scroll nobody asked for, so Playwright's own wouldn't do + const reach = async (card) => { + const box = await view.boundingBox(); + await page.mouse.move(box.x + box.width / 2, Math.min(box.y + 200, 800)); + for (let i = 0; i < 60 && !(await card.evaluate((e) => { const r = e.getBoundingClientRect(), v = e.closest(".view").getBoundingClientRect(); return r.top >= v.top && r.bottom <= v.bottom; })); i++) { + await page.mouse.wheel(0, 80); + await page.waitForTimeout(15); + } + }; + // and clicks it where it is: Playwright's own click scrolls a card + // already in sight in Chromium at this width, as a reader's doesn't + const press = async (card) => { + const b = await card.boundingBox(); + await page.mouse.click(b.x + b.width / 2, b.y + 20); + }; + await reach(c); + const before = await scrolls(page); + await press(c); + const dlg = page.locator("#modal .pm-detail"); + await dlg.locator(".pm-md", { hasText: "Uses your existing Claude Code credentials." }).waitFor(); + assert.deepEqual(asked.filter(([k]) => k === "page").pop(), ["page", "opencode-claude-auth"]); + assert.match(await dlg.locator(".pm-note.warn").innerText(), w.warn); + assert.match(await dlg.locator(".pm-note.warn").innerText(), w.fromNPM); + assert.equal(await dlg.locator(".pm-links a", { hasText: "npm" }).getAttribute("href"), "https://www.npmjs.com/package/opencode-claude-auth"); + assert.equal(await dlg.locator(".pm-links a", { hasText: "GitHub" }).getAttribute("href"), "https://github.com/griffinmartin/opencode-claude-auth"); + const upd = dlg.locator(".pm-fact", { has: page.locator(".k", { hasText: w.updated }) }).locator(".v"); + assert.match(await upd.innerText(), /2026/, "the repository's last push"); + await shot(page.locator("#modal .dialog"), `plugins-github-page-${engine}-${lang}-${width}`); + + // Install from the page: npm's name + const install = async (spec) => { + const n = asked.filter(([k]) => k === "add").length; + await dlg.locator(".pm-act", { hasText: new RegExp("^" + w.install + "$") }).click(); + for (let i = 0; i < 100 && asked.filter(([k]) => k === "add").length === n; i++) await new Promise((r) => setTimeout(r, 20)); + assert.deepEqual(asked.filter(([k]) => k === "add").pop()[1], { spec }); + await dlg.locator(".pm-act.done").waitFor(); + await dlg.locator(".bar button.text").last().click(); + await page.waitForFunction(() => document.querySelector("#modal").hidden); + }; + await install("opencode-claude-auth"); + assert.equal(await scrolls(page), before, "a click scrolls nothing"); + await cards.first().locator(".pm-act.done").waitFor(); + + // one npm hasn't from its repository: GitHub's, installed from there + await reach(cards.nth(2)); + await press(cards.nth(2)); + await dlg.locator(".pm-md", { hasText: "Hire agy as a staffer." }).waitFor(); + assert.deepEqual(asked.filter(([k]) => k === "page").pop(), ["page", "github:keli-wen/agy-staff"]); + assert.match(await dlg.locator(".pm-note.warn").innerText(), w.fromGit); + assert.equal(await dlg.locator(".pm-links a", { hasText: "npm" }).count(), 0, "npm has no page for it"); + assert.equal(await dlg.locator(".pm-links a", { hasText: "GitHub" }).getAttribute("href"), "https://github.com/keli-wen/agy-staff"); + await install("github:keli-wen/agy-staff"); + await cards.nth(2).locator(".pm-act.done").waitFor(); + + // a search finds them too + await view.locator(".pm-find input").fill("quota"); + const found = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) }); + await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec .pm-card").length === 1); + assert.deepEqual(await found.locator(".pm-name b").allInnerTexts(), ["opencode-quota"]); + await view.locator(".pm-find input").fill("nothing-like-it"); + await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-sec .pm-card .pm-chip.warn")); + + assert.equal(asked.filter(([k]) => k === "fetched").length, 0, "nothing fetched from outside: " + JSON.stringify(asked.filter(([k]) => k === "fetched"))); + assert.deepEqual(errors, []); + }); + } + } + }); +} diff --git a/internal/plugin/github.go b/internal/plugin/github.go new file mode 100644 index 000000000..c3df5ff0b --- /dev/null +++ b/internal/plugin/github.go @@ -0,0 +1,281 @@ +package plugin + +import ( + "context" + "encoding/json" + "errors" + "net/url" + "os" + "path" + "path/filepath" + "strings" + "sync" + "time" +) + +// Plugins on GitHub that nobody listed: a repository its author tagged +// with the magpie-plugin topic. The market shows them apart from the +// community's, as not reviewed by anyone: installed from npm when its +// author published it there from the repository, else from the repository +// itself (github:owner/repo). + +// Topic is the GitHub topic that puts a repository on the Plugins page. +const Topic = "magpie-plugin" + +// Tagged is a repository tagged with Topic. +type Tagged struct { + Spec string `json:"spec"` // what Install adds: its npm name when npm has it from this repository, else github:owner/repo + Repo string `json:"repo"` // owner/repo + URL string `json:"url"` // its page on GitHub + Owner string `json:"owner"` // its owner's login + OwnerAvatar string `json:"ownerAvatar,omitempty"` + Description string `json:"description,omitempty"` + Stars int `json:"stars"` + License string `json:"license,omitempty"` // SPDX id + Pushed time.Time `json:"pushed"` + // from its package.json on the default branch: what bun will install + // it as, its version, and whether it is gateway middleware + Package string `json:"package,omitempty"` + Version string `json:"version,omitempty"` + Kind string `json:"kind,omitempty"` // "middleware" when that is all it is +} + +// Where GitHub is asked, moved by tests. +var ( + githubAPI = "https://api.github.com" + githubRaw = "https://raw.githubusercontent.com" +) + +var ( + taggedMu sync.Mutex + taggedL []Tagged + taggedAt time.Time +) + +func taggedCache() string { return filepath.Join(filepath.Dir(marketCache()), "plugin-github.json") } + +// TaggedRepos are the repositories tagged with Topic, the most starred +// first: GitHub asked at most every six hours (its search lets 10 a minute +// through without a token), else what it said last, kept on disk. Archived +// repositories, forks and magpie-community's own (the market lists those) +// are left out, as is one whose package.json doesn't parse, which bun +// couldn't install either. MAGPIE_PLUGIN_MARKET=off keeps to none. +func TaggedRepos(ctx context.Context) []Tagged { + taggedMu.Lock() + defer taggedMu.Unlock() + if taggedL != nil && time.Since(taggedAt) < 6*time.Hour { + return taggedL + } + if os.Getenv("MAGPIE_PLUGIN_MARKET") == "off" { + return []Tagged{} + } + // a magpie started again within the six hours: what GitHub said then, + // without the wait of asking (a package.json read for each) + if taggedL == nil { + if fi, err := os.Stat(taggedCache()); err == nil && time.Since(fi.ModTime()) < 6*time.Hour { + var l []Tagged + if b, err := os.ReadFile(taggedCache()); err == nil && json.Unmarshal(b, &l) == nil && l != nil { + taggedL, taggedAt = l, fi.ModTime() + return l + } + } + } + if l, err := askTagged(ctx); err == nil { + taggedL, taggedAt = l, time.Now() + if b, err := json.Marshal(l); err == nil { + _ = os.MkdirAll(filepath.Dir(taggedCache()), 0o755) + _ = os.WriteFile(taggedCache(), b, 0o644) + } + return l + } + // GitHub didn't answer: what it said last, asked again in a minute + var l []Tagged + if b, err := os.ReadFile(taggedCache()); err == nil { + _ = json.Unmarshal(b, &l) + } + if l == nil { + l = []Tagged{} + } + taggedL, taggedAt = l, time.Now().Add(-6*time.Hour+time.Minute) + return l +} + +func askTagged(ctx context.Context) ([]Tagged, error) { + c, cancel := context.WithTimeout(ctx, 8*time.Second) + defer cancel() + v := url.Values{"q": {"topic:" + Topic + " archived:false fork:false"}, "sort": {"stars"}, "order": {"desc"}, "per_page": {"50"}} + b, err := fetchJSON(c, githubAPI+"/search/repositories?"+v.Encode(), 4<<20) + if err != nil { + return nil, err + } + var r struct { + Items []struct { + FullName string `json:"full_name"` + HTMLURL string `json:"html_url"` + Description string `json:"description"` + Stars int `json:"stargazers_count"` + DefaultBranch string `json:"default_branch"` + Pushed time.Time `json:"pushed_at"` + Archived bool `json:"archived"` + Fork bool `json:"fork"` + Owner struct { + Login string `json:"login"` + AvatarURL string `json:"avatar_url"` + } `json:"owner"` + License *struct { + SPDX string `json:"spdx_id"` + } `json:"license"` + } `json:"items"` + } + if err := json.Unmarshal(b, &r); err != nil { + return nil, err + } + out := make([]Tagged, len(r.Items)) + keep := make([]bool, len(r.Items)) + var wg sync.WaitGroup + sem := make(chan struct{}, 6) + for i, it := range r.Items { + if it.Archived || it.Fork || strings.EqualFold(it.Owner.Login, "magpie-community") || !strings.Contains(it.FullName, "/") { + continue + } + t := Tagged{ + Spec: "github:" + it.FullName, Repo: it.FullName, URL: it.HTMLURL, Owner: it.Owner.Login, OwnerAvatar: it.Owner.AvatarURL, + Description: it.Description, Stars: it.Stars, Pushed: it.Pushed, + } + if it.License != nil && it.License.SPDX != "NOASSERTION" { + t.License = it.License.SPDX + } + wg.Add(1) + go func(i int, t Tagged, branch string) { + defer wg.Done() + sem <- struct{}{} + defer func() { <-sem }() + pc, cancel := context.WithTimeout(c, 6*time.Second) + defer cancel() + if branch == "" { + branch = "HEAD" + } + pb, err := fetchJSON(pc, githubRaw+"/"+t.Repo+"/"+url.PathEscape(branch)+"/package.json", 256<<10) + if err != nil { + return + } + var pj struct { + Name string `json:"name"` + Version string `json:"version"` + Main string `json:"main"` + Exports json.RawMessage `json:"exports"` + Magpie struct { + Middleware string `json:"middleware"` + } `json:"magpie"` + } + if json.Unmarshal(pb, &pj) != nil || !pkgName.MatchString(pj.Name) { + return + } + t.Package, t.Version = pj.Name, pj.Version + if strings.TrimSpace(pj.Magpie.Middleware) != "" && pj.Main == "" && len(pj.Exports) == 0 { + t.Kind = "middleware" + } + // published to npm from this repository: npm's copy is the one + // built to be installed (a repository often leaves its dist out, + // built only to publish), so it is installed from npm + if b, err := fetchJSON(pc, npmRegistry+"/"+npmPath(pj.Name)+"/latest", 1<<20); err == nil { + var l npmLatest + if json.Unmarshal(b, &l) == nil && l.Version != "" && strings.EqualFold(githubRepo(repoURL(l.Repository)), t.Repo) { + t.Spec, t.Version = pj.Name, l.Version + } + } + // installed from the repository, the file it loads must be in + // it: one whose dist is built only to publish couldn't load + // (GitHub not answering is no answer, and keeps it; so is a + // name Bun would add .js or /index.js to) + if IsGit(t.Spec) { + entry := pj.Magpie.Middleware + if t.Kind != "middleware" { + entry = pkgEntry(pj.Exports, pj.Main) + } + if path.Ext(entry) != "" { + _, err := fetchJSON(pc, githubRaw+"/"+t.Repo+"/"+url.PathEscape(branch)+"/"+strings.TrimPrefix(path.Clean("/"+entry), "/"), 1) + if errors.Is(err, errNotFound) { + return + } + } + } + out[i], keep[i] = t, true + }(i, t, it.DefaultBranch) + } + wg.Wait() + l := []Tagged{} + for i := range out { + if keep[i] { + l = append(l, out[i]) + } + } + return l, nil +} + +// pkgEntry is the file importing a package loads, as Bun resolves it: its +// exports' "." (import, else default), else main, else index.js. +func pkgEntry(exports json.RawMessage, main string) string { + var pick func(v any) string + pick = func(v any) string { + switch v := v.(type) { + case string: + return v + case map[string]any: + if d, ok := v["."]; ok { + return pick(d) + } + for _, k := range []string{"bun", "import", "default", "node", "require"} { + if s := pick(v[k]); s != "" { + return s + } + } + } + return "" + } + var v any + if len(exports) > 0 && json.Unmarshal(exports, &v) == nil { + if s := pick(v); s != "" { + return s + } + } + if main != "" { + return main + } + return "index.js" +} + +// githubReadme is the README of a GitHub repository not installed yet, as +// its default branch has it. +func githubReadme(ctx context.Context, repo string) (Page, error) { + ctx, cancel := context.WithTimeout(ctx, 12*time.Second) + defer cancel() + var last error + for _, f := range []string{"README.md", "readme.md", "Readme.md", "README"} { + b, err := fetchJSON(ctx, githubRaw+"/"+repo+"/HEAD/"+f, 200<<10) + if err == nil { + return Page{Readme: string(b)}, nil + } + last = err + } + return Page{}, last +} + +// githubRepo is owner/repo of a github: spec or a GitHub page's URL, "" +// for any other. +func githubRepo(spec string) string { + s := strings.TrimSuffix(strings.SplitN(spec, "#", 2)[0], ".git") + switch { + case strings.HasPrefix(s, "github:"): + s = strings.TrimPrefix(s, "github:") + case strings.HasPrefix(s, "https://github.com/"), strings.HasPrefix(s, "https://www.github.com/"): + s = s[strings.Index(s, "github.com/")+len("github.com/"):] + default: + return "" + } + p := strings.Split(strings.Trim(s, "/"), "/") + if len(p) < 2 || p[0] == "" || p[1] == "" { + return "" + } + return p[0] + "/" + p[1] +} diff --git a/internal/plugin/github_test.go b/internal/plugin/github_test.go new file mode 100644 index 000000000..97bff040b --- /dev/null +++ b/internal/plugin/github_test.go @@ -0,0 +1,229 @@ +package plugin + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "strings" + "sync/atomic" + "testing" + "time" +) + +// fakeGitHub answers as GitHub's search, raw.githubusercontent.com and npm +// do, from testdata/github (npm's real answers for the packages it has): search.json is a real answer for a topic (five +// 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; 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. +func fakeGitHub(t *testing.T, up *atomic.Bool, asked *atomic.Int32) { + t.Helper() + t.Setenv("XDG_CACHE_HOME", t.TempDir()) + t.Setenv("MAGPIE_PLUGIN_MARKET", "") + b, err := os.ReadFile("testdata/github/search.json") + if err != nil { + t.Fatal(err) + } + var r map[string]any + if err := json.Unmarshal(b, &r); err != nil { + t.Fatal(err) + } + items := r["items"].([]any) + like := func(full string, set map[string]any) map[string]any { + var it map[string]any + raw, _ := json.Marshal(items[0]) + _ = json.Unmarshal(raw, &it) + it["full_name"], it["html_url"] = full, "https://github.com/"+full + it["owner"].(map[string]any)["login"] = strings.Split(full, "/")[0] + for k, v := range set { + it[k] = v + } + return it + } + items = append(items, + like("someone/word-guard", map[string]any{"description": "word guard", "stargazers_count": 3, "license": nil}), + like("alfaoz/opencode-see-image", nil), + like("someone/flaky-entry", map[string]any{"license": map[string]any{"key": "other", "spdx_id": "NOASSERTION"}}), + like("forker/opencode-claude-auth", map[string]any{"fork": true}), + like("old/opencode-old", map[string]any{"archived": true}), + like("magpie-community/plugins", nil)) + r["items"] = items + search, _ := json.Marshal(r) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, q *http.Request) { + if !up.Load() || q.URL.Path == "/raw/someone/flaky-entry/main/index.js" { + http.Error(w, "down", 503) + return + } + if q.URL.Path == "/search/repositories" { + asked.Add(1) + if got := q.URL.Query().Get("q"); got != "topic:magpie-plugin archived:false fork:false" { + t.Errorf("searched %q", got) + } + w.Write(search) + return + } + if name, ok := strings.CutPrefix(q.URL.Path, "/npm/"); ok { + f, err := os.ReadFile(filepath.Join("testdata/github/npm", strings.ReplaceAll(strings.TrimSuffix(name, "/latest"), "/", "_")+".json")) + if err != nil { + http.Error(w, `"Not Found"`, 404) + return + } + w.Write(f) + return + } + f, err := os.ReadFile(filepath.Join("testdata/github/raw", filepath.FromSlash(strings.TrimPrefix(q.URL.Path, "/raw/")))) + if err != nil { + http.NotFound(w, q) + return + } + w.Write(f) + })) + t.Cleanup(srv.Close) + api, raw, reg := githubAPI, githubRaw, npmRegistry + githubAPI, githubRaw, npmRegistry = srv.URL, srv.URL+"/raw", srv.URL+"/npm" + forget := func() { taggedMu.Lock(); taggedL = nil; taggedMu.Unlock() } + forget() + t.Cleanup(func() { githubAPI, githubRaw, npmRegistry = api, raw, reg; forget() }) +} + +// Repositories tagged magpie-plugin: each with what its package.json says, +// in GitHub's order; forks, archived ones and magpie-community's left out. +// Asked once in six hours; with GitHub down, what it said last. +func TestTaggedRepos(t *testing.T) { + var up atomic.Bool + var asked atomic.Int32 + up.Store(true) + fakeGitHub(t, &up, &asked) + ctx := context.Background() + + l := TaggedRepos(ctx) + var repos []string + for _, x := range l { + repos = append(repos, x.Repo) + } + // iPolloWork and learn-opencode (a workspace and a course) have no + // index.js to load, nor see-image its dist: installed from GitHub, + // none would load + want := "rynfar/meridian griffinmartin/opencode-claude-auth slkiser/opencode-quota someone/word-guard someone/flaky-entry" + if strings.Join(repos, " ") != want { + t.Fatalf("repos %v\nwant %s", repos, want) + } + byRepo := map[string]Tagged{} + for _, x := range l { + byRepo[x.Repo] = x + } + c := byRepo["griffinmartin/opencode-claude-auth"] + if c.Spec != "opencode-claude-auth" || c.Package != "opencode-claude-auth" || c.Version != "2.2.1" || + c.Owner != "griffinmartin" || c.License != "MIT" || c.Stars != 1301 || c.Kind != "" || c.Pushed.IsZero() || c.URL != "https://github.com/griffinmartin/opencode-claude-auth" { + t.Fatalf("claude auth: %+v", c) + } + if x := byRepo["someone/flaky-entry"]; x.License != "" { + t.Fatalf("NOASSERTION is no license: %+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) + } + // npm's copy when npm has it from this very repository (its build is + // on npm only); else the repository: not on npm, or npm's is another's + for repo, spec := range map[string]string{ + "rynfar/meridian": "@rynfar/meridian", "slkiser/opencode-quota": "@slkiser/opencode-quota", + "someone/word-guard": "github:someone/word-guard", "someone/flaky-entry": "github:someone/flaky-entry", + } { + if x := byRepo[repo]; x.Spec != spec { + t.Errorf("%s installs as %q, want %q", repo, x.Spec, spec) + } + } + if x := byRepo["someone/word-guard"]; !IsGit(x.Spec) { + t.Fatalf("%s isn't a spec Add installs from git", x.Spec) + } + + TaggedRepos(ctx) + if n := asked.Load(); n != 1 { + t.Fatalf("asked %d times in six hours", n) + } + + // started again within the six hours: the copy on disk, GitHub not + // asked + forget := func() { taggedMu.Lock(); taggedL = nil; taggedMu.Unlock() } + forget() + if l := TaggedRepos(ctx); len(l) != 5 || asked.Load() != 1 { + t.Fatalf("restarted: asked %d times, %d repos", asked.Load(), len(l)) + } + + // started again later, with GitHub down: the copy on disk all the same + old := time.Now().Add(-7 * time.Hour) + if err := os.Chtimes(taggedCache(), old, old); err != nil { + t.Fatal(err) + } + up.Store(false) + forget() + if l := TaggedRepos(ctx); len(l) != 5 || l[1].Package != "opencode-claude-auth" || asked.Load() != 1 { + t.Fatalf("down: %+v", l) + } + + // nothing ever kept, GitHub down: none, not an error + t.Setenv("XDG_CACHE_HOME", t.TempDir()) + taggedMu.Lock() + taggedL = nil + taggedMu.Unlock() + if l := TaggedRepos(ctx); l == nil || len(l) != 0 { + t.Fatalf("down, nothing kept: %#v", l) + } + + // off: GitHub never asked + up.Store(true) + t.Setenv("MAGPIE_PLUGIN_MARKET", "off") + taggedMu.Lock() + taggedL = nil + taggedMu.Unlock() + before := asked.Load() + if l := TaggedRepos(ctx); len(l) != 0 || asked.Load() != before { + t.Fatalf("off: %+v", l) + } +} + +// A tagged repository's page, before it is installed, is its README on +// GitHub; installed, the folder's. +func TestReadmeOfTaggedRepo(t *testing.T) { + var up atomic.Bool + var asked atomic.Int32 + up.Store(true) + fakeGitHub(t, &up, &asked) + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + p, err := Readme(context.Background(), "github:griffinmartin/opencode-claude-auth") + if err != nil || !strings.Contains(p.Readme, "opencode-claude-auth") { + t.Fatalf("readme %q, %v", p.Readme[:min(80, len(p.Readme))], err) + } + if _, err := Readme(context.Background(), "github:rynfar/meridian"); err == nil { + t.Fatal("a repository with no README read as one") + } + for spec, want := range map[string]string{ + "github:a/b": "a/b", "github:a/b#v1": "a/b", "https://github.com/a/b": "a/b", "https://github.com/a/b.git": "a/b", + "https://github.com/a/b/tree/main": "a/b", "gitlab:a/b": "", "github:a": "", + } { + if got := githubRepo(spec); got != want { + t.Errorf("githubRepo(%q) = %q, want %q", spec, got, want) + } + } +} + +// The file importing a package loads, as Bun resolves it. +func TestPkgEntry(t *testing.T) { + for _, c := range []struct{ exports, main, want string }{ + {"", "", "index.js"}, + {"", "./dist/index.js", "./dist/index.js"}, + {`"./x.js"`, "./dist/index.js", "./x.js"}, + {`{".": "./a.js", "./b": "./b.js"}`, "", "./a.js"}, + {`{".": {"types": "./a.d.ts", "import": "./a.mjs", "require": "./a.cjs"}}`, "", "./a.mjs"}, + {`{"import": "./a.mjs", "default": "./a.js"}`, "", "./a.mjs"}, + {`{"./server": "./s.js"}`, "./m.js", "./m.js"}, + } { + if got := pkgEntry(json.RawMessage(c.exports), c.main); got != c.want { + t.Errorf("pkgEntry(%s, %q) = %q, want %q", c.exports, c.main, got, c.want) + } + } +} diff --git a/internal/plugin/market.go b/internal/plugin/market.go index 90a85acf1..acd039550 100644 --- a/internal/plugin/market.go +++ b/internal/plugin/market.go @@ -525,6 +525,15 @@ type Page struct { // from a folder on this computer or a git repository — the one its folder // carries. func Readme(ctx context.Context, name string) (Page, error) { + if IsGit(name) { + // one not installed yet (a repository tagged magpie-plugin): its + // README as GitHub has it + if _, err := os.Stat(Target(name)); err != nil { + if repo := githubRepo(name); repo != "" { + return githubReadme(ctx, repo) + } + } + } if IsPath(name) || IsGit(name) { return folderReadme(Target(name)) } diff --git a/internal/plugin/testdata/github/npm/@magpie-community_middleware-word-guard.json b/internal/plugin/testdata/github/npm/@magpie-community_middleware-word-guard.json new file mode 100644 index 000000000..e4d370488 --- /dev/null +++ b/internal/plugin/testdata/github/npm/@magpie-community_middleware-word-guard.json @@ -0,0 +1 @@ +{"bugs":{"url":"https://github.com/magpie-community/plugins/issues"},"dist":{"shasum":"f8f4eda2527b5e41cf6379aa669e9895a083227d","tarball":"https://registry.npmjs.org/@magpie-community/middleware-word-guard/-/middleware-word-guard-0.1.0.tgz","fileCount":3,"integrity":"sha512-wY3oIvkEYVQHJzrcSPbP8C+UIIeqxgjNZc/LhSnFKOrTrkJWodikdIsN9mK2a4XE8Za75iyuoPn8jHjRpc/rrQ==","signatures":[{"sig":"MEUCIEwEv3bsHfuLeAw4NlD/G2K19OiOMtAMR0tcf+FuSew4AiEAk8df8v4zo9EUtEutE6Ct9z58h51voDFcXx08i+2a4ZA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDWGUXN7OIS621n2oaW6UxdOzOkNHcKiPq5TWv27q2sfAIhAITgR1F8aBsxKqAjgQbqwakE1UfRB+mnLzIsSJ6HCWNE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8409},"name":"@magpie-community/middleware-word-guard","type":"module","magpie":{"options":{"check":"last","words":["project-codename"],"action":"reject","patterns":[]},"middleware":"./word-guard.middleware.js"},"gitHead":"719ba0c6212999f3f15a7d3d1fc85dfdc06263a8","license":"MIT","_npmUser":{"name":"yetone","email":"yetoneful@gmail.com"},"homepage":"https://github.com/magpie-community/plugins#readme","keywords":["magpie","magpie-middleware","new-api","sensitive-words","guardrails","llm-gateway"],"repository":{"url":"git+https://github.com/magpie-community/plugins.git","type":"git","directory":"packages/word-guard"},"_npmVersion":"10.9.4","description":"New API's sensitive-word filter (敏感词过滤) as magpie gateway middleware: turn away or mask words and patterns in what agents send, and in replies","directories":{},"maintainers":[{"name":"yetone","email":"yetoneful@gmail.com"}],"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/middleware-word-guard_0.1.0_1791223429841_0.8373448730695063","host":"s3://npm-registry-packages-npm-production"},"_id":"@magpie-community/middleware-word-guard@0.1.0","version":"0.1.0"} \ No newline at end of file diff --git a/internal/plugin/testdata/github/npm/@rynfar_meridian.json b/internal/plugin/testdata/github/npm/@rynfar_meridian.json new file mode 100644 index 000000000..1317d609a --- /dev/null +++ b/internal/plugin/testdata/github/npm/@rynfar_meridian.json @@ -0,0 +1 @@ +{"bin":{"meridian":"dist/cli.js","claude-max-proxy":"dist/cli.js"},"bugs":{"url":"https://github.com/rynfar/meridian/issues"},"dist":{"shasum":"9d60a764970249e850db5a754beb388920ceef7f","tarball":"https://registry.npmjs.org/@rynfar/meridian/-/meridian-1.79.0.tgz","fileCount":382,"integrity":"sha512-ZB40fhpDX9nuz68pgHcTTGa/ThPKhQHnhTbAguXw7wx1PNqTHkAxWLqj+tyPSm+pjo3M93oJ+SQc2VhS59gxaA==","signatures":[{"sig":"MEYCIQClHytf4oBFuZngseCLkFpthQAXt4YoewHOIXdpGBkjAwIhAKWdqs1drw6XZ3WF8B8JYQQ9bU614hQpTjEY5md3sIcm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQC7YSZts9Q3ZYCx0fsIQEUIMEjBuMcWDZkDHrDvQQWsGgIhAP9Lcw4eA9vsJPeGqR8e1vMkauan/otmii1hld3ckdqY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@rynfar%2fmeridian@1.79.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5221930},"main":"./dist/server.js","name":"@rynfar/meridian","type":"module","types":"./dist/proxy/server.d.ts","author":{"name":"rynfar"},"engines":{"node":">=22"},"exports":{".":{"types":"./dist/proxy/server.d.ts","default":"./dist/server.js"}},"gitHead":"0ec52a28d9c70d0f9aa84767613c7a08125d25e4","license":"MIT","private":false,"scripts":{"test":"bun test --timeout 30000 --path-ignore-patterns '**/*session-store*' --path-ignore-patterns '**/*session-fingerprint-context*' --path-ignore-patterns '**/*priority-routing-integration*' --path-ignore-patterns '**/*proxy-async-ops*' --path-ignore-patterns '**/*models-auth-status*' --path-ignore-patterns '**/*proxy-context-usage-store*' --path-ignore-patterns '**/*proxy-passthrough-thinking*' --path-ignore-patterns '**/*proxy-thinking-setting*' --path-ignore-patterns '**/*session-recovery*' --path-ignore-patterns '**/*models.test*' --path-ignore-patterns '**/*proxy-health-build*' --path-ignore-patterns '**/*follow-active-integration*' && bun test --timeout 30000 src/__tests__/proxy-async-ops.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-store.test.ts && bun test --timeout 30000 src/__tests__/session-store-pruning.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-store-locking.test.ts && bun test --timeout 30000 src/__tests__/session-fingerprint-context.test.ts && bun test --timeout 30000 src/__tests__/proxy-context-usage-store.test.ts && bun test --timeout 30000 src/__tests__/models-auth-status.test.ts && bun test --timeout 30000 src/__tests__/proxy-passthrough-thinking.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-recovery.test.ts && bun test --timeout 30000 src/__tests__/proxy-thinking-setting.test.ts && bun test --timeout 30000 src/__tests__/models.test.ts && bun test --timeout 30000 src/__tests__/proxy-health-build.test.ts && bun test --timeout 30000 src/__tests__/priority-routing-integration.test.ts && bun test --timeout 30000 src/__tests__/follow-active-integration.test.ts","build":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && bun build bin/cli.ts src/proxy/server.ts plugin/meridian-v2.ts --outdir dist --target node --splitting --external @anthropic-ai/claude-agent-sdk --external jsonc-parser --entry-naming \"[name].js\" && bun build plugin/meridian/index.js --outdir dist/meridian --target node --splitting --external @anthropic-ai/claude-agent-sdk --external jsonc-parser --entry-naming \"[name].js\" && bun build plugin/meridian-v2/index.js --outdir dist/meridian-v2 --target node --splitting --external @anthropic-ai/claude-agent-sdk --external jsonc-parser --entry-naming \"[name].js\" && node scripts/package-opencode-plugins.mjs && tsc -p tsconfig.build.json","proxy":"./bin/claude-proxy-supervisor.sh","start":"./bin/claude-proxy-supervisor.sh","pretest":"tsc --noEmit","nix:lock":"bun2nix -o bun.nix","postbuild":"node scripts/fix-bun-exports.mjs && node --check dist/cli.js && node --check dist/server.js && node --check dist/meridian-v2.js && node --check dist/meridian/index.js && node --check dist/meridian-v2/index.js && node -e \"if(!require('fs').existsSync('dist/proxy/server.d.ts'))process.exit(1)\"","typecheck":"tsc --noEmit","postinstall":"node -e \"try{require('child_process').spawnSync(process.execPath,[require.resolve('@anthropic-ai/claude-code/install.cjs')],{stdio:'inherit'})}catch(e){console.error('[meridian] claude-code postinstall skipped:',e.message)}\"","proxy:direct":"bun run ./bin/cli.ts","prepublishOnly":"bun run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"5343fc60-c008-4b3b-8a5f-92ef46526ac0"}},"homepage":"https://github.com/rynfar/meridian#readme","keywords":["meridian","claude","claude-max","claude-code","anthropic","anthropic-api","claude-agent-sdk","ai-coding","ai-assistant","proxy","opencode","cline","aider","crush","charmbracelet","droid","factory-ai","pi-coding-agent","open-webui","llm","coding-assistant","opencode-claude-max-proxy","antigravity","google-antigravity","gemini","openai-compatible","ai-agents"],"repository":{"url":"git+https://github.com/rynfar/meridian.git","type":"git"},"_npmVersion":"11.19.1","description":"Use Claude and Antigravity subscriptions with Pi, OpenCode and other coding clients. Local API bridge, usage dashboard and optional Mac app.","directories":{},"maintainers":[{"name":"rynfar","email":"rynfar@gmail.com"}],"_nodeVersion":"22.23.2","dependencies":{"ajv":"^8.20.0","zod":"4.4.3","libsql":"^0.5.29","ajv-formats":"^3.0.1","cross-spawn":"7.0.6","jsonc-parser":"^3.3.1","@anthropic-ai/claude-code":"^2.1.284","@anthropic-ai/claude-agent-sdk":"^0.2.141"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.11","devDependencies":{"glob":"^13.0.0","hono":"^4.12.34","bun2nix":"^2.0.8","@types/bun":"^1.3.11","typescript":"^5.8.2","@types/node":"^22.0.0","@hono/node-server":"^1.19.15","@types/cross-spawn":"6.0.6","@opencode-ai/plugin":"0.0.0-beta-18314"},"_npmOperationalInternal":{"tmp":"tmp/meridian_1.79.0_1790704941239_0.989653156470637","host":"s3://npm-registry-packages-npm-production"},"_id":"@rynfar/meridian@1.79.0","version":"1.79.0"} \ No newline at end of file diff --git a/internal/plugin/testdata/github/npm/@slkiser_opencode-quota.json b/internal/plugin/testdata/github/npm/@slkiser_opencode-quota.json new file mode 100644 index 000000000..e45f06b42 --- /dev/null +++ b/internal/plugin/testdata/github/npm/@slkiser_opencode-quota.json @@ -0,0 +1 @@ +{"bin":{"opencode-quota":"dist/bin/opencode-quota.js"},"bugs":{"url":"https://github.com/slkiser/opencode-quota/issues"},"dist":{"shasum":"3def785003b03a719fbe1cdc09a74dfb0a014429","tarball":"https://registry.npmjs.org/@slkiser/opencode-quota/-/opencode-quota-5.0.2.tgz","fileCount":663,"integrity":"sha512-8NuHpP0joxhRvcYYRaFvBjdi1hAX0b/WEq+tQlDJh//YxXlbYY2SL6bFojg1D8QC8o6Sb40lQvswa6Nuek9KiA==","signatures":[{"sig":"MEUCIQCdZ9nosILn51g/MbRdtUX/qHtybvIryGXTrKU89QvFuAIgAa5tPLFg/M0CyHUTy7IF/q+vih6qJviCqNadqBSlU78=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQC2NkBfkX0UYddUH3DzMcrdQIZIH1KRzT73p1l3wiavyAIhANgR8+HXq1pzbsDi+NZ+f35Zfxl88aa/P3FdpXOuu9Q9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@slkiser%2fopencode-quota@5.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3126452},"main":"./dist/index.js","name":"@slkiser/opencode-quota","type":"module","_from":"file:package-artifacts/slkiser-opencode-quota-5.0.2.tgz","types":"./dist/index.d.ts","author":"","engines":{"node":"^22.13.0 || >=23.4.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./tui":{"types":"./dist/tui.d.ts","default":"./dist/tui.js"},"./server":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"license":"MIT","scripts":{"lint":"biome lint .","test":"vitest run","build":"node scripts/clean-dist.mjs && tsc && node scripts/copy-data.mjs && node scripts/prepare-tui-dist.mjs","check":"biome check .","format":"biome format --write .","verify":"pnpm run check && pnpm run verify:typescript-version && pnpm run verify:v4-history && pnpm run typecheck && pnpm run build && pnpm test && pnpm run test:four-surfaces && pnpm run verify:package-contents","typecheck":"tsc --noEmit","test:watch":"vitest","build:check":"pnpm run build && pnpm pack --dry-run","format:check":"biome format .","release:check":"pnpm verify && pnpm run verify:release-version","smoke:package":"node scripts/smoke-packed-package.mjs","upstream:sync":"node scripts/sync-upstream-plugin-references.mjs","upstream:check":"node scripts/check-upstream-plugin-updates.mjs","pricing:refresh":"node scripts/refresh-modelsdev-pricing.mjs","verify:v4-history":"node scripts/verify-v4-history.mjs","test:four-surfaces":"vitest run tests/v4-phase5-cross-surface.test.ts","pack:release-package":"node scripts/pack-release-package.mjs","verify:release-package":"node scripts/verify-release-package.mjs","verify:release-version":"node scripts/verify-release-version.mjs","upstream:prepare-review":"node scripts/prepare-upstream-plugin-review.mjs","verify:package-contents":"node scripts/verify-package-contents.mjs","pricing:refresh:if-stale":"node scripts/refresh-modelsdev-pricing-if-stale.mjs","verify:typescript-version":"node scripts/verify-typescript-version.mjs"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"7b1aebec-13eb-4027-b667-6cb8aac61130"}},"homepage":"https://github.com/slkiser/opencode-quota#readme","keywords":["opencode","plugin","quota","toast","github","copilot","google","gemini","claude"],"_resolved":"/home/runner/work/opencode-quota/opencode-quota/package-artifacts/slkiser-opencode-quota-5.0.2.tgz","_integrity":"sha512-8NuHpP0joxhRvcYYRaFvBjdi1hAX0b/WEq+tQlDJh//YxXlbYY2SL6bFojg1D8QC8o6Sb40lQvswa6Nuek9KiA==","repository":{"url":"git+https://github.com/slkiser/opencode-quota.git","type":"git"},"_npmVersion":"11.19.0","description":"OpenCode quota & tokens usage with zero context window pollution. Supports GitHub Copilot, OpenAI (Plus/Pro), Chutes AI, Synthetic, Google AGY, Z.ai coding plan and more.","directories":{},"maintainers":[{"name":"slkiser","email":"ringed-halcyon9d@icloud.com"}],"_nodeVersion":"24.21.0","dependencies":{"solid-js":"^1.9.12","comment-json":"^5.0.0","jsonc-parser":"^3.3.1","@opentui/core":"^0.5.10","@clack/prompts":"^1.2.0","@opentui/solid":"^0.5.10","@opentelemetry/api":"^1.9.1"},"_hasShrinkwrap":false,"devDependencies":{"yaml":"^2.8.3","vitest":"^4.0.17","lefthook":"2.0.15","typescript":"7.0.2","@babel/core":"^7.28.0","@types/node":"^22.0.0","@biomejs/biome":"2.3.11","@opencode/plugin":"2.0.16","babel-preset-solid":"^1.9.12","@babel/preset-typescript":"^7.27.1","@opentelemetry/sdk-metrics":"2.10.0"},"peerDependencies":{"@opencode/plugin":"2.0.16"},"_npmOperationalInternal":{"tmp":"tmp/opencode-quota_5.0.2_1791285766641_0.5334631555493552","host":"s3://npm-registry-packages-npm-production"},"_id":"@slkiser/opencode-quota@5.0.2","version":"5.0.2"} \ No newline at end of file diff --git a/internal/plugin/testdata/github/npm/opencode-claude-auth.json b/internal/plugin/testdata/github/npm/opencode-claude-auth.json new file mode 100644 index 000000000..c9996016f --- /dev/null +++ b/internal/plugin/testdata/github/npm/opencode-claude-auth.json @@ -0,0 +1 @@ +{"bugs":{"url":"https://github.com/griffinmartin/opencode-claude-auth/issues"},"dist":{"shasum":"c7f661cfb6155f680d42633b3c090b434e5bbe86","tarball":"https://registry.npmjs.org/opencode-claude-auth/-/opencode-claude-auth-2.2.1.tgz","fileCount":50,"integrity":"sha512-iEXMVh2J/l8ZlNiMNp7QmtGQtAwjXgaSgXvA2zZzJbUZEOBKvuoq9gKRtqSjYB3faDwOVwwiGAj+S2N/8sgolA==","signatures":[{"sig":"MEUCIFlCVQCCjw/3gOn/BsGCbi8Vmoxa3T2SOA8S5WNcm/WIAiEA75xVO+gDs8UqnNFLZgGbPFjHC8cOPf/KrVOZQUifArY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIAkVobFswS/xBX21Y0YZIowGwldu1iAQb1OA3HUZyuelAiEAgNePxwcAwKjYb62MSZQQuO/zy4LuNoQxl7kjVV7xBQQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/opencode-claude-auth@2.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":287180},"main":"opencode-claude-auth.js","name":"opencode-claude-auth","type":"module","_from":"file:opencode-claude-auth-2.2.1.tgz","types":"dist/index.d.ts","module":"opencode-claude-auth.js","exports":{".":{"types":"./dist/index.d.ts","import":"./opencode-claude-auth.js"},"./server":{"types":"./dist/index.d.ts","import":"./opencode-claude-auth.js"},"./claude-auth-plugin":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./opencode-claude-auth":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./claude-auth-plugin.js":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./opencode-claude-auth.js":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"license":"MIT","scripts":{"lint":"oxlint && oxfmt --check .","test":"node --test --experimental-strip-types src/**/*.test.ts scripts/**/*.test.ts","build":"rm -rf dist && tsc && cp src/anthropic-prompt.txt dist/","format":"oxfmt --write .","lint:fix":"oxlint --fix . && oxfmt --write .","intercept":"pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts","test:models":"pnpm run build && node scripts/test-models.ts","intercept:all":"pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts --all","test:headless":"pnpm run build && node --experimental-strip-types scripts/test-headless.ts","validate:oauth":"pnpm run build && node --experimental-strip-types scripts/validate-oauth-refresh.ts","intercept:update":"pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts --all --update"},"_npmUser":{"name":"himboslice","email":"me@griffinmartin.dev"},"homepage":"https://github.com/griffinmartin/opencode-claude-auth#readme","keywords":["anthropic","auth","claude","opencode","plugin"],"_resolved":"/tmp/2dade726ab49f6121da0b9719dd1c8f4/opencode-claude-auth-2.2.1.tgz","_integrity":"sha512-iEXMVh2J/l8ZlNiMNp7QmtGQtAwjXgaSgXvA2zZzJbUZEOBKvuoq9gKRtqSjYB3faDwOVwwiGAj+S2N/8sgolA==","repository":{"url":"git+https://github.com/griffinmartin/opencode-claude-auth.git","type":"git"},"_npmVersion":"10.9.8","description":"OpenCode plugin that uses your Claude Code credentials — no separate login needed.","directories":{},"maintainers":[{"name":"himboslice","email":"me@griffinmartin.dev"}],"_nodeVersion":"22.23.2","_hasShrinkwrap":false,"devDependencies":{"oxfmt":"0.41.0","oxlint":"1.56.0","typescript":"^5.0.0","@types/node":"^25.5.0","@opencode-ai/plugin":"latest"},"peerDependencies":{"@opencode-ai/plugin":"*"},"_npmOperationalInternal":{"tmp":"tmp/opencode-claude-auth_2.2.1_1790120917685_0.949883343134486","host":"s3://npm-registry-packages-npm-production"},"_id":"opencode-claude-auth@2.2.1","version":"2.2.1"} \ No newline at end of file diff --git a/internal/plugin/testdata/github/npm/opencode-see-image.json b/internal/plugin/testdata/github/npm/opencode-see-image.json new file mode 100644 index 000000000..25026f94a --- /dev/null +++ b/internal/plugin/testdata/github/npm/opencode-see-image.json @@ -0,0 +1 @@ +{"dist":{"shasum":"9d9223c7553b0cec22ebe55a4d6f49708c28fff9","tarball":"https://registry.npmjs.org/opencode-see-image/-/opencode-see-image-1.4.0.tgz","fileCount":9,"integrity":"sha512-jome1OvQK37L/PcSSryUe7jXOMaPa/IbK1c2u2c02pILEoLEmJC6X+WbmbHEIsKdUtX5TbOtZPJYFwGyCC02+g==","signatures":[{"sig":"MEQCIAZhy49YRhBo8SqTuPS344sUu5qMYLf8kyA4lbAqiPSFAiBnSH1cKU6Mua2IRDsN2dtV1E6PmwWq6EIxz/6KauGdZg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIAa2y7efaVb/Glympv0gNp2vWQPOUb9qXSoi6DfWXXvsAiAjoS6pTb19KKZ4Be5pdQLiJh1SRIMovExTaMG3xHF1mg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":530316},"main":"./dist/index.js","name":"opencode-see-image","type":"module","exports":{".":"./dist/index.js"},"gitHead":"08aa4ff1bfef2f0ebe10fca0469e2d855cf66c4a","license":"MIT","scripts":{"build":"bun build index.ts --target=node --format=esm --outdir=dist --external bun:sqlite","typecheck":"bun build index.ts --target=node --format=esm --outdir=/tmp/see-image-check --external bun:sqlite","prepublishOnly":"bun run build"},"_npmUser":{"name":"alfaoz","email":"alfa.ozaltin@gmail.com"},"keywords":["opencode","opencode-plugin","vision","image","screenshot","minimax","glm"],"_npmVersion":"11.11.1","description":"Give non-vision opencode models the ability to see images/screenshots by routing them to a vision-capable model (MiniMax M3 via opencode-go by default). Supports both OpenCode v1 and v2.","directories":{},"maintainers":[{"name":"alfaoz","email":"alfa.ozaltin@gmail.com"}],"_nodeVersion":"25.8.2","dependencies":{"@opencode-ai/plugin":"^1.15.0","opencode-plugin-update-kit":"0.6.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/opencode-see-image_1.4.0_1790519484625_0.2005969489187931","host":"s3://npm-registry-packages-npm-production"},"_id":"opencode-see-image@1.4.0","version":"1.4.0"} \ No newline at end of file diff --git a/internal/plugin/testdata/github/raw/Devin-AXIS/iPolloWork/main/package.json b/internal/plugin/testdata/github/raw/Devin-AXIS/iPolloWork/main/package.json new file mode 100644 index 000000000..f8cd22d59 --- /dev/null +++ b/internal/plugin/testdata/github/raw/Devin-AXIS/iPolloWork/main/package.json @@ -0,0 +1,76 @@ +{ + "name": "@ipollo/ipollowork-workspace", + "private": true, + "version": "0.18.0", + "scripts": { + "setup": "node scripts/ipollowork.mjs setup", + "dev:cloud": "node scripts/ipollowork.mjs dev:cloud", + "check": "node scripts/ipollowork.mjs check", + "document:design": "node scripts/document-to-design-compiler.mjs", + "document:video": "node scripts/document-to-design-compiler.mjs --target video", + "readme:zh-hant": "node scripts/sync-readme-zh-hant.mjs", + "readme:zh-hant:check": "node scripts/sync-readme-zh-hant.mjs --check", + "package": "node scripts/ipollowork.mjs package", + "package:dir": "node scripts/ipollowork.mjs package:dir", + "package:windows": "cross-env IPOLLOWORK_WINDOWS_INSTALLER=1 pnpm --filter @ipollowork/desktop package:windows", + "dev": "cross-env IPOLLOWORK_DEV_MODE=1 IPOLLOWORK_ELECTRON_REMOTE_DEBUG_PORT=9823 pnpm_config_verify_deps_before_run=warn pnpm --filter @ipollowork/desktop dev", + "dev:electron": "cross-env IPOLLOWORK_DEV_MODE=1 pnpm_config_verify_deps_before_run=warn pnpm --filter @ipollowork/desktop dev:electron", + "dev:electron:two": "cross-env IPOLLOWORK_DEV_MODE=1 node scripts/dev-two-electron-demo.mjs", + "demo:electron": "cross-env IPOLLOWORK_DEV_MODE=1 node scripts/dev-two-electron-demo.mjs --reset", + "demo:electron:reset": "node scripts/dev-two-electron-demo.mjs --reset-only", + "demo:reset": "pnpm demo:electron:reset", + "dev:sandbox": "bash .devcontainer/dev-sandbox.sh", + "dev:ui": "cross-env IPOLLOWORK_DEV_MODE=1 pnpm --filter @ipollowork/app dev", + "dev:ui-demo": "pnpm --filter @ipollowork/ui-demo dev", + "email:dev": "pnpm --filter @ipollowork/email dev", + "dev:headless-web": "cross-env IPOLLOWORK_DEV_MODE=1 bun scripts/dev-headless-web.ts", + "build": "node scripts/build.mjs", + "build:ui": "pnpm --filter @ipollowork/app build", + "preview": "pnpm --filter @ipollowork/app preview", + "typecheck": "pnpm --filter @ipollowork/app typecheck", + "coverage": "pnpm coverage:app && pnpm coverage:server && pnpm coverage:desktop", + "coverage:app": "pnpm --filter @ipollowork/app coverage", + "coverage:server": "pnpm --filter ipollowork-server coverage", + "coverage:desktop": "pnpm --filter @ipollowork/desktop coverage", + "test:health": "pnpm --filter @ipollowork/app test:health", + "test:sessions": "pnpm --filter @ipollowork/app test:sessions", + "test:refactor": "pnpm --filter @ipollowork/app test:refactor", + "test:events": "pnpm --filter @ipollowork/app test:events", + "test:todos": "pnpm --filter @ipollowork/app test:todos", + "test:permissions": "pnpm --filter @ipollowork/app test:permissions", + "test:session-scope": "pnpm --filter @ipollowork/app test:session-scope", + "test:session-switch": "pnpm --filter @ipollowork/app test:session-switch", + "test:fs-engine": "pnpm --filter @ipollowork/app test:fs-engine", + "test:e2e": "pnpm --filter @ipollowork/app test:e2e", + "audit:template-fidelity": "node scripts/audit-template-preview-fidelity.mjs", + "export:deepseek-design": "node scripts/export-deepseek-design-repository.mjs", + "import:deepseek-design": "node scripts/import-deepseek-design-repository.mjs", + "test:deepseek-design-import": "node --test scripts/import-deepseek-design-repository.test.mjs", + "check:hyperframes-version-sync": "node scripts/check-hyperframes-version-sync.mjs", + "evals": "node evals/runner/run.mjs", + "fraimz": "node evals/runner/run.mjs", + "gsap:generate": "bun vendor/hyperframes/scripts/gsap-catalog.ts generate", + "gsap:check": "bun vendor/hyperframes/scripts/gsap-catalog.ts check", + "gsap:check-updates": "bun vendor/hyperframes/scripts/gsap-catalog.ts upstream", + "gsap:sync": "bun vendor/hyperframes/scripts/gsap-catalog.ts sync", + "test:orchestrator": "pnpm --filter ipollowork-orchestrator test:files", + "bump:patch": "pnpm --filter @ipollowork/app bump:patch", + "bump:minor": "pnpm --filter @ipollowork/app bump:minor", + "bump:major": "pnpm --filter @ipollowork/app bump:major", + "bump:set": "pnpm --filter @ipollowork/app bump:set", + "release:review": "node scripts/release/review.mjs", + "release:prepare": "node scripts/release/prepare.mjs", + "release:prepare:dry": "node scripts/release/prepare.mjs --dry-run", + "release:ship": "node scripts/release/ship.mjs", + "release:ship:watch": "node scripts/release/ship.mjs --watch" + }, + "devDependencies": { + "cross-env": "^10.1.0", + "knip": "6.29.0", + "opencc-js": "^1.4.0" + }, + "engines": { + "pnpm": ">=11.4.0 <12" + }, + "packageManager": "pnpm@11.4.0" +} diff --git a/internal/plugin/testdata/github/raw/alfaoz/opencode-see-image/main/package.json b/internal/plugin/testdata/github/raw/alfaoz/opencode-see-image/main/package.json new file mode 100644 index 000000000..9852a6b24 --- /dev/null +++ b/internal/plugin/testdata/github/raw/alfaoz/opencode-see-image/main/package.json @@ -0,0 +1,37 @@ +{ + "name": "opencode-see-image", + "version": "1.4.0", + "description": "Give non-vision opencode models the ability to see images/screenshots by routing them to a vision-capable model (MiniMax M3 via opencode-go by default). Supports both OpenCode v1 and v2.", + "type": "module", + "main": "./dist/index.js", + "exports": { + ".": "./dist/index.js" + }, + "files": [ + "dist", + "index.ts", + "lib.ts", + "core.ts", + "v1.ts", + "v2.ts" + ], + "scripts": { + "build": "bun build index.ts --target=node --format=esm --outdir=dist --external bun:sqlite", + "typecheck": "bun build index.ts --target=node --format=esm --outdir=/tmp/see-image-check --external bun:sqlite", + "prepublishOnly": "bun run build" + }, + "keywords": [ + "opencode", + "opencode-plugin", + "vision", + "image", + "screenshot", + "minimax", + "glm" + ], + "license": "MIT", + "dependencies": { + "@opencode-ai/plugin": "^1.15.0", + "opencode-plugin-update-kit": "0.6.0" + } +} diff --git a/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/HEAD/README.md b/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/HEAD/README.md new file mode 100644 index 000000000..d720f6d87 --- /dev/null +++ b/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/HEAD/README.md @@ -0,0 +1,225 @@ +# opencode-claude-auth + +[![npm](https://img.shields.io/npm/v/opencode-claude-auth)](https://www.npmjs.com/package/opencode-claude-auth) +[![CI](https://github.com/griffinmartin/opencode-claude-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/griffinmartin/opencode-claude-auth/actions/workflows/ci.yml) +[![Socket Badge](https://socket.dev/api/badge/npm/package/opencode-claude-auth)](https://socket.dev/npm/package/opencode-claude-auth) + +Self-contained Anthropic auth provider for OpenCode using your Claude Code credentials — no separate login or API key needed. + +## How it works + +The plugin registers its own auth provider with a custom fetch handler that intercepts all Anthropic API requests. It reads OAuth tokens from the macOS Keychain (or `~/.claude/.credentials.json` — or `$CLAUDE_CONFIG_DIR/.credentials.json` if that env var is set — on other platforms), caches them in memory with a 30-second TTL, and handles the full request lifecycle — no builtin Anthropic auth plugin required. On macOS, multiple Claude Code accounts are detected automatically and can be switched via `opencode auth login`. + +It also syncs credentials to OpenCode's `auth.json` as a fallback (on Windows, it writes to both `%USERPROFILE%\.local\share\opencode\auth.json` and `%LOCALAPPDATA%\opencode\auth.json` to cover all installation methods). If a token is near expiry, it refreshes directly via Anthropic's OAuth endpoint (zero LLM tokens consumed), falling back to the Claude CLI if the direct refresh fails. Background re-sync runs every 5 minutes. + +## Alternative: CLIProxyAPI (plugin not required) + +If you run [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI), you don't need this plugin. CLIProxyAPI logs in to your Claude Code account with OAuth, handles token refresh, and exposes a Claude-compatible API on `http://localhost:8317` by default. Point OpenCode's built-in Anthropic provider at it: + +1. Log in with your Claude Code account (via the proxy's `-claude-login` flag) and set an `api-keys` entry in its `config.yaml`. +2. Configure the Anthropic provider in `~/.config/opencode/opencode.json`: + + ```json + { + "provider": { + "anthropic": { + "options": { + "baseURL": "http://localhost:8317", + "apiKey": "your-api-key-1" + } + } + } + } + ``` + +Remove `opencode-claude-auth` from your `plugin` list when using this setup — the two approaches shouldn't be combined. CLIProxyAPI also supports multi-account load balancing and other providers (Codex, Gemini, Grok). This plugin remains the lighter option if you only need Claude Code credentials in OpenCode with no extra service running. + +## Prerequisites + +- Claude Code installed and authenticated (run `claude` at least once) +- OpenCode installed + +macOS is preferred (uses Keychain). Linux and Windows work via the credentials file fallback. + +## Installation + +**For Humans** + +**Option A: Let an LLM do it** + +Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.): + +``` +Install the opencode-claude-auth plugin and configure it by following: https://raw.githubusercontent.com/griffinmartin/opencode-claude-auth/main/installation.md +``` + +**Option B: Manual setup** + +1. **Add the plugin** to `~/.config/opencode/opencode.json`: + + ```json + { + "plugin": ["opencode-claude-auth@latest"] + } + ``` + + > The `@latest` tag ensures OpenCode always pulls the newest version on startup. No manual `npm install` is needed — OpenCode [automatically installs npm plugins using Bun at startup](https://opencode.ai/docs/plugins/#how-plugins-are-installed). + +2. **Use it** — just run OpenCode. The plugin handles auth automatically using your Claude Code credentials. + +**For LLM Agents** + +See [installation.md](installation.md) for step-by-step agent instructions. + +## Usage + +Just run OpenCode. The plugin handles auth automatically — it reads your Claude Code credentials, provides them to the Anthropic API, and refreshes them in the background. If your credentials aren't OAuth-based, the plugin falls through to standard API key auth. + +## Supported models + +14 supported models. Run `pnpm run test:models` to verify against your account. + +| Model | +| -------------------------- | +| claude-fable-5 | +| claude-fable-5-1 | +| claude-haiku-4-5 | +| claude-haiku-4-5-20251001 | +| claude-opus-4-5 | +| claude-opus-4-5-20251101 | +| claude-opus-4-6 | +| claude-opus-4-7 | +| claude-opus-4-8 | +| claude-opus-5 | +| claude-sonnet-4-5 | +| claude-sonnet-4-5-20250929 | +| claude-sonnet-4-6 | +| claude-sonnet-5 | + +## Credential sources + +The plugin checks these in order: + +1. macOS Keychain (all `Claude Code-credentials*` entries — multiple accounts are detected automatically) +2. `~/.claude/.credentials.json` (fallback, works on all platforms; if `CLAUDE_CONFIG_DIR` is set, reads `$CLAUDE_CONFIG_DIR/.credentials.json` instead) + +## Multiple accounts (macOS) + +If you have [multiple Claude Code accounts](https://gist.github.com/KMJ-007/0979814968722051620461ab2aa01bf2) authenticated on macOS, the plugin detects all of them from the Keychain automatically. Each account is labeled by its subscription tier (Claude Pro, Claude Max, etc.). + +To switch accounts: + +```bash +opencode auth login +``` + +Select "Switch Claude Code account" and pick the account you want to use. Your selection is persisted across sessions. + +If only one account is found, the switcher is hidden and the plugin uses it directly. + +## Troubleshooting + +| Problem | Solution | +| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| "Credentials not found" | Run `claude` to authenticate with Claude Code first | +| "Keychain is locked" | Run `security unlock-keychain ~/Library/Keychains/login.keychain-db` | +| "Token expired and refresh failed" | The plugin runs `claude` CLI to refresh automatically. If this fails, re-authenticate manually by running `claude` | +| Not working on Linux/Windows | Ensure `~/.claude/.credentials.json` exists (or `$CLAUDE_CONFIG_DIR/.credentials.json` if that env var is set). Run `claude` to create it | +| Keychain access denied | Grant access when macOS prompts you | +| Keychain read timed out | Restart Keychain Access (can happen on macOS Tahoe) | +| "Credentials are unavailable or expired" | Run `claude` to refresh your Claude Code credentials | +| "Extra usage is required for long context requests" | Your conversation exceeded 200k tokens. See [Long context (1M)](#long-context-1m) below | +| Plugin not updating to latest version | Delete the cached package: `rm -rf ~/.cache/opencode/packages/opencode-claude-auth@latest/` then restart OpenCode | + +### Diagnostic logging + +If you're hitting auth errors that are hard to reproduce, enable debug logging to capture the full auth flow: + +```bash +export CLAUDE_AUTH_DEBUG=1 +``` + +Restart OpenCode and reproduce the issue. The plugin writes structured JSON logs to `~/.local/share/opencode/claude-auth-debug.log`. All secrets (tokens, API keys) are automatically redacted — the log file is safe to paste into a GitHub issue. + +To write logs to a custom path: + +```bash +export CLAUDE_AUTH_DEBUG=/tmp/claude-auth-debug.log +``` + +Disable when done: + +```bash +unset CLAUDE_AUTH_DEBUG +``` + +## Long context (1M) + +1M token context is supported natively — the API no longer requires a beta flag for it, so the plugin doesn't send the legacy `context-1m-2025-08-07` header. + +If your plan doesn't cover long context billing, requests beyond the standard window fail with "Extra usage is required for long context requests". When a long context error is caused by a beta flag (e.g. one added via `ANTHROPIC_BETA_FLAGS`), the plugin retries without the offending flag. + +## Validating OAuth refresh + +To verify the direct OAuth token refresh works with your credentials: + +```bash +pnpm run validate:oauth # refresh + write-back (safe, keeps credentials valid) +pnpm run validate:oauth -- --dry-run # show what would be sent without making the request +``` + +This reads your stored credentials, calls Anthropic's OAuth token endpoint, and writes the new tokens back to storage. Refresh tokens rotate on each use, so write-back is enabled by default to keep your stored credentials valid. + +## Environment variable overrides + +All configurable parameters can be overridden via environment variables. If Anthropic changes something before we publish an update, set an env var and keep working: + +| Variable | Description | Default | +| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | +| `ANTHROPIC_CLI_VERSION` | Claude CLI version for user-agent and billing headers | `config.ccVersion` in [`src/model-config.ts`](src/model-config.ts) | +| `ANTHROPIC_USER_AGENT` | Full User-Agent string (overrides CLI version) | `claude-cli/{version} (external, sdk-cli)` | +| `ANTHROPIC_BETA_FLAGS` | Comma-separated beta feature flags | `baseBetas` list in [`src/model-config.ts`](src/model-config.ts) | +| `CLAUDE_AUTH_DEBUG` | Enable diagnostic logging (`1` for default path, or a custom file path) | disabled | +| `CLAUDE_CONFIG_DIR` | Claude Code config directory used for the credentials-file fallback (reads `$CLAUDE_CONFIG_DIR/.credentials.json`). macOS still checks the Keychain first. | `~/.claude` | +| `OPENCODE_CLAUDE_AUTH_MAX_RETRY_MS` | Max ms the plugin waits when honouring a 429/529 `retry-after` header. Beyond this cap the response surfaces immediately so OpenCode doesn't appear to hang on hour-long quota resets. | `30000` | +| `OPENCODE_CLAUDE_AUTH_TOOL_REPAIR` | Strategy for reconciling `tool_use`/`tool_result` adjacency broken by OpenCode auto-compaction. `placeholder` synthesizes a paired result for orphaned `tool_use` blocks (lossless, preserves `thinking` blocks); `drop` removes orphaned blocks (omitting whole thinking turns). | `placeholder` | +| `OPENCODE_CLAUDE_AUTH_REFRESH_WAIT_MS` | Max ms a single request waits through a transient token-refresh rate-limit (429) before returning a retryable error instead of a hard "run `claude`". | `45000` | +| `OPENCODE_CLAUDE_AUTH_REFRESH_COOLDOWN_MS` | Base per-account cooldown after a rate-limited refresh, before the plugin retries the token endpoint. Escalates with consecutive failures and is jittered; capped at 60s. | `15000` | +| `OPENCODE_CLAUDE_AUTH_REFRESH_LOCK_TTL_MS` | TTL for the cross-process refresh lock. A held lock older than this is treated as stale (crashed holder) and taken over. | `20000` | +| `OPENCODE_CLAUDE_AUTH_REFRESH_LOCK_DIR` | Directory for the advisory cross-process refresh lock files. | OpenCode data dir (`~/.local/share/opencode`) | + +Example: + +```bash +export ANTHROPIC_CLI_VERSION=2.2.0 +``` + +## How it works (technical) + +- Registers an `auth.loader` with a custom `fetch` that intercepts all Anthropic API requests +- Sets `Authorization: Bearer` with fresh OAuth tokens (cached in memory, 30s TTL, updated in-place after refresh) +- Translates tool names between OpenCode and Anthropic API formats (adds/strips `mcp_` prefix) +- Buffers SSE response streams at event boundaries for reliable tool name translation +- Injects Claude Code identity into system prompts via `experimental.chat.system.transform` +- Sets required API headers (beta flags, billing, user-agent) with model-aware selection +- On macOS, enumerates all `Claude Code-credentials*` Keychain entries and labels them by subscription tier +- Provides an account switcher via `opencode auth login` when multiple accounts are found; persists selection to `~/.local/share/opencode/claude-account-source.txt` +- Syncs credentials to `auth.json` on startup and every 5 minutes as a fallback; that same tick proactively refreshes once the token is within an hour of expiry +- On Windows, writes to both `%USERPROFILE%\.local\share\opencode\auth.json` and `%LOCALAPPDATA%\opencode\auth.json` +- Re-reads the credential source on every cache miss, so an account rotated by something other than this plugin — the `claude` CLI in another terminal, a second OpenCode instance, or a switcher like [claude-swap](https://github.com/realiti4/claude-swap) — gets picked up mid-session without a restart. Bounded by the same 30s cache, so it adds at most about two source reads a minute under load. A stored token is adopted whenever it is usable, and when it isn't only if the one already held is also unusable — otherwise a failed write-back would resurrect the pre-refresh token it left behind +- Guards credential write-back with the access token the refresh started from, so a switch landing mid-refresh can't write one account's rotated tokens into another account's slot +- Retries API requests on 429 (rate limit) and 529 (overloaded) with exponential backoff, respecting `retry-after` headers +- On a 429 that outlives those backoff retries, re-reads the source once and retries only if the access token changed, so a rate limit another process has already resolved by switching accounts isn't surfaced. A changed token isn't proof of a switch — a routine refresh of the same account changes it too — so this costs at most one extra request +- On a 401, recovers in place rather than surfacing it: adopts an externally rotated token if the source now holds one, otherwise forces an OAuth refresh, then retries the request. Bounded at two attempts, so a rejected token costs at most three API calls. A 401 that survives recovery is returned unmodified, without SSE stream transformation, since it carries an error body rather than a stream +- Refreshes directly via `POST https://claude.ai/v1/oauth/token` using the runtime's own `fetch` (no LLM tokens consumed, no subprocess). Requests are triggered within 60 seconds of expiry on the API request path and within an hour on the background tick; concurrent refreshes of one account share a single request, since each rotation invalidates the previous refresh token +- Falls back to the `claude` CLI only within the 60-second window, the point at which Claude Code will actually rotate the token — running it earlier costs a real API request and returns the same token. New tokens are written back to Keychain (macOS) or credentials file (Linux/Windows) to keep stored credentials in sync with rotated refresh tokens +- If credentials aren't OAuth-based, the auth loader returns `{}` and falls through to API key auth +- If credentials are unavailable or unreadable, the plugin disables itself and OpenCode continues without Claude auth + +## Disclaimer + +This plugin uses Claude Code's OAuth credentials to authenticate with Anthropic's API. Anthropic's Terms of Service state that Claude Pro/Max subscription tokens should only be used with official Anthropic clients. This plugin exists as a community workaround and may stop working if Anthropic changes their OAuth infrastructure. Use at your own discretion. + +## License + +MIT diff --git a/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/main/package.json b/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/main/package.json new file mode 100644 index 000000000..f8175038a --- /dev/null +++ b/internal/plugin/testdata/github/raw/griffinmartin/opencode-claude-auth/main/package.json @@ -0,0 +1,77 @@ +{ + "name": "opencode-claude-auth", + "version": "2.2.1", + "description": "OpenCode plugin that uses your Claude Code credentials — no separate login needed.", + "keywords": [ + "anthropic", + "auth", + "claude", + "opencode", + "plugin" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/griffinmartin/opencode-claude-auth.git" + }, + "files": [ + "opencode-claude-auth.js", + "dist", + "installation.md" + ], + "type": "module", + "main": "opencode-claude-auth.js", + "module": "opencode-claude-auth.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./opencode-claude-auth.js" + }, + "./server": { + "types": "./dist/index.d.ts", + "import": "./opencode-claude-auth.js" + }, + "./claude-auth-plugin": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./claude-auth-plugin.js": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./opencode-claude-auth": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./opencode-claude-auth.js": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "scripts": { + "build": "rm -rf dist && tsc && cp src/anthropic-prompt.txt dist/", + "test": "node --test --experimental-strip-types src/**/*.test.ts scripts/**/*.test.ts", + "test:models": "pnpm run build && node scripts/test-models.ts", + "test:headless": "pnpm run build && node --experimental-strip-types scripts/test-headless.ts", + "intercept": "pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts", + "intercept:all": "pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts --all", + "intercept:update": "pnpm run build && node --experimental-strip-types scripts/intercept-claude.ts --all --update", + "validate:oauth": "pnpm run build && node --experimental-strip-types scripts/validate-oauth-refresh.ts", + "lint": "oxlint && oxfmt --check .", + "lint:fix": "oxlint --fix . && oxfmt --write .", + "format": "oxfmt --write .", + "prepublishOnly": "pnpm run build && pnpm test" + }, + "devDependencies": { + "@opencode-ai/plugin": "latest", + "@types/node": "^25.5.0", + "oxfmt": "0.41.0", + "oxlint": "1.56.0", + "typescript": "^5.0.0" + }, + "peerDependencies": { + "@opencode-ai/plugin": "*" + }, + "packageManager": "pnpm@10.32.1" +} diff --git a/internal/plugin/testdata/github/raw/rynfar/meridian/main/package.json b/internal/plugin/testdata/github/raw/rynfar/meridian/main/package.json new file mode 100644 index 000000000..617e590b7 --- /dev/null +++ b/internal/plugin/testdata/github/raw/rynfar/meridian/main/package.json @@ -0,0 +1,102 @@ +{ + "name": "@rynfar/meridian", + "version": "1.79.0", + "description": "Use Claude and Antigravity subscriptions with Pi, OpenCode and other coding clients. Local API bridge, usage dashboard and optional Mac app.", + "type": "module", + "main": "./dist/server.js", + "types": "./dist/proxy/server.d.ts", + "bin": { + "meridian": "./dist/cli.js", + "claude-max-proxy": "./dist/cli.js" + }, + "exports": { + ".": { + "types": "./dist/proxy/server.d.ts", + "default": "./dist/server.js" + } + }, + "engines": { + "node": ">=22" + }, + "scripts": { + "start": "./bin/claude-proxy-supervisor.sh", + "proxy": "./bin/claude-proxy-supervisor.sh", + "build": "bun scripts/build.ts", + "postinstall": "node -e \"try{require('child_process').spawnSync(process.execPath,[require.resolve('@anthropic-ai/claude-code/install.cjs')],{stdio:'inherit'})}catch(e){console.error('[meridian] claude-code postinstall skipped:',e.message)}\"", + "prepublishOnly": "bun run build", + "pretest": "tsc --noEmit", + "test": "bun test --timeout 30000 --path-ignore-patterns '**/*session-store*' --path-ignore-patterns '**/*store-mutation-loop-lag*' --path-ignore-patterns '**/*session-fingerprint-context*' --path-ignore-patterns '**/*priority-routing-integration*' --path-ignore-patterns '**/*proxy-async-ops*' --path-ignore-patterns '**/*models-auth-status*' --path-ignore-patterns '**/*proxy-context-usage-store*' --path-ignore-patterns '**/*proxy-passthrough-thinking*' --path-ignore-patterns '**/*proxy-thinking-setting*' --path-ignore-patterns '**/*session-recovery*' --path-ignore-patterns '**/*models.test*' --path-ignore-patterns '**/*replay-budget*' --path-ignore-patterns '**/*proxy-health-build*' --path-ignore-patterns '**/*follow-active-integration*' --path-ignore-patterns '**/*profile-credential-isolation*' --path-ignore-patterns '**/*header-settings-routes*' && bun test --timeout 30000 src/__tests__/proxy-async-ops.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-store.test.ts && bun test --timeout 30000 src/__tests__/session-store-pruning.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-store-locking.test.ts && bun test --timeout 30000 src/__tests__/session-fingerprint-context.test.ts && bun test --timeout 30000 src/__tests__/proxy-context-usage-store.test.ts && bun test --timeout 30000 src/__tests__/models-auth-status.test.ts && bun test --timeout 30000 src/__tests__/proxy-passthrough-thinking.test.ts && bun test --timeout 30000 src/__tests__/proxy-session-recovery.test.ts && bun test --timeout 30000 src/__tests__/proxy-thinking-setting.test.ts && bun test --timeout 30000 src/__tests__/models.test.ts && bun test --timeout 30000 src/__tests__/replay-budget.test.ts && bun test --timeout 30000 src/__tests__/proxy-health-build.test.ts && bun test --timeout 30000 src/__tests__/priority-routing-integration.test.ts && bun test --timeout 30000 src/__tests__/follow-active-integration.test.ts && bun test --timeout 30000 src/__tests__/store-mutation-loop-lag.test.ts && bun test --timeout 30000 src/__tests__/profile-credential-isolation.test.ts && bun test --timeout 30000 src/__tests__/header-settings-routes.test.ts", + "nix:lock": "bun2nix -o bun.nix", + "typecheck": "tsc --noEmit", + "proxy:direct": "bun run ./bin/cli.ts" + }, + "dependencies": { + "@anthropic-ai/claude-agent-sdk": "^0.2.141", + "@anthropic-ai/claude-code": "^2.1.284", + "ajv": "^8.20.0", + "ajv-formats": "^3.0.1", + "cross-spawn": "7.0.6", + "jsonc-parser": "^3.3.1", + "libsql": "^0.5.29", + "zod": "4.4.3" + }, + "devDependencies": { + "@hono/node-server": "^1.19.15", + "@opencode-ai/plugin": "0.0.0-beta-18314", + "@types/bun": "^1.3.11", + "@types/cross-spawn": "6.0.6", + "@types/node": "^22.0.0", + "bun2nix": "^2.0.8", + "glob": "^13.0.0", + "hono": "^4.12.34", + "typescript": "^5.8.2" + }, + "files": [ + "dist/", + "plugin/", + "assets/", + "bin/meridian-launchd.sh", + "README.md" + ], + "keywords": [ + "meridian", + "claude", + "claude-max", + "claude-code", + "anthropic", + "anthropic-api", + "claude-agent-sdk", + "ai-coding", + "ai-assistant", + "proxy", + "opencode", + "cline", + "aider", + "crush", + "charmbracelet", + "droid", + "factory-ai", + "pi-coding-agent", + "open-webui", + "llm", + "coding-assistant", + "opencode-claude-max-proxy", + "antigravity", + "google-antigravity", + "gemini", + "openai-compatible", + "ai-agents" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/rynfar/meridian.git" + }, + "homepage": "https://github.com/rynfar/meridian#readme", + "bugs": { + "url": "https://github.com/rynfar/meridian/issues" + }, + "author": "rynfar", + "license": "MIT", + "private": false, + "packageManager": "bun@1.3.11" +} diff --git a/internal/plugin/testdata/github/raw/slkiser/opencode-quota/main/package.json b/internal/plugin/testdata/github/raw/slkiser/opencode-quota/main/package.json new file mode 100644 index 000000000..1648fb0b7 --- /dev/null +++ b/internal/plugin/testdata/github/raw/slkiser/opencode-quota/main/package.json @@ -0,0 +1,108 @@ +{ + "name": "@slkiser/opencode-quota", + "version": "5.0.2", + "packageManager": "pnpm@11.0.0", + "description": "OpenCode quota & tokens usage with zero context window pollution. Supports GitHub Copilot, OpenAI (Plus/Pro), Chutes AI, Synthetic, Google AGY, Z.ai coding plan and more.", + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "bin": { + "opencode-quota": "./dist/bin/opencode-quota.js" + }, + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./server": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./tui": { + "types": "./dist/tui.d.ts", + "default": "./dist/tui.js" + } + }, + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "scripts": { + "build": "node scripts/clean-dist.mjs && tsc && node scripts/copy-data.mjs && node scripts/prepare-tui-dist.mjs", + "build:check": "pnpm run build && pnpm pack --dry-run", + "check": "biome check .", + "format": "biome format --write .", + "format:check": "biome format .", + "lint": "biome lint .", + "pack:release-package": "node scripts/pack-release-package.mjs", + "pricing:refresh": "node scripts/refresh-modelsdev-pricing.mjs", + "pricing:refresh:if-stale": "node scripts/refresh-modelsdev-pricing-if-stale.mjs", + "upstream:check": "node scripts/check-upstream-plugin-updates.mjs", + "upstream:prepare-review": "node scripts/prepare-upstream-plugin-review.mjs", + "upstream:sync": "node scripts/sync-upstream-plugin-references.mjs", + "release:check": "pnpm verify && pnpm run verify:release-version", + "smoke:package": "node scripts/smoke-packed-package.mjs", + "test:four-surfaces": "vitest run tests/v4-phase5-cross-surface.test.ts", + "verify:package-contents": "node scripts/verify-package-contents.mjs", + "verify:release-package": "node scripts/verify-release-package.mjs", + "verify:release-version": "node scripts/verify-release-version.mjs", + "verify:typescript-version": "node scripts/verify-typescript-version.mjs", + "verify:v4-history": "node scripts/verify-v4-history.mjs", + "typecheck": "tsc --noEmit", + "test": "vitest run", + "test:watch": "vitest", + "verify": "pnpm run check && pnpm run verify:typescript-version && pnpm run verify:v4-history && pnpm run typecheck && pnpm run build && pnpm test && pnpm run test:four-surfaces && pnpm run verify:package-contents", + "prepublishOnly": "pnpm run build", + "prepare": "lefthook install" + }, + "keywords": [ + "opencode", + "plugin", + "quota", + "toast", + "github", + "copilot", + "google", + "gemini", + "claude" + ], + "author": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/slkiser/opencode-quota.git" + }, + "bugs": { + "url": "https://github.com/slkiser/opencode-quota/issues" + }, + "homepage": "https://github.com/slkiser/opencode-quota#readme", + "devDependencies": { + "@babel/core": "^7.28.0", + "@babel/preset-typescript": "^7.27.1", + "@biomejs/biome": "2.3.11", + "@opencode/plugin": "2.0.16", + "@opentelemetry/sdk-metrics": "2.10.0", + "@types/node": "^22.0.0", + "babel-preset-solid": "^1.9.12", + "lefthook": "2.0.15", + "typescript": "7.0.2", + "vitest": "^4.0.17", + "yaml": "^2.8.3" + }, + "dependencies": { + "@clack/prompts": "^1.2.0", + "@opentelemetry/api": "^1.9.1", + "@opentui/core": "^0.5.10", + "@opentui/solid": "^0.5.10", + "comment-json": "^5.0.0", + "jsonc-parser": "^3.3.1", + "solid-js": "^1.9.12" + }, + "peerDependencies": { + "@opencode/plugin": "2.0.16" + }, + "engines": { + "node": "^22.13.0 || >=23.4.0" + } +} diff --git a/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json b/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json new file mode 100644 index 000000000..242d8e5bd --- /dev/null +++ b/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json @@ -0,0 +1,6 @@ +{ + "name": "flaky-entry", + "version": "0.1.0", + "type": "module", + "main": "./index.js" +} diff --git a/internal/plugin/testdata/github/raw/someone/word-guard/main/package.json b/internal/plugin/testdata/github/raw/someone/word-guard/main/package.json new file mode 100644 index 000000000..7a7ee6ab8 --- /dev/null +++ b/internal/plugin/testdata/github/raw/someone/word-guard/main/package.json @@ -0,0 +1,14 @@ +{ + "name": "@magpie-community/middleware-word-guard", + "version": "0.1.1", + "description": "New API's sensitive-word filter (敏感词过滤) as magpie gateway middleware: turn away or mask words and patterns in what agents send, and in replies", + "type": "module", + "files": ["word-guard.middleware.js", "README.md"], + "keywords": ["magpie", "magpie-middleware", "new-api", "sensitive-words", "guardrails", "llm-gateway"], + "license": "MIT", + "repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/word-guard" }, + "magpie": { + "middleware": "./word-guard.middleware.js", + "options": { "words": ["project-codename"], "patterns": [], "action": "reject", "check": "last" } + } +} diff --git a/internal/plugin/testdata/github/raw/someone/word-guard/main/word-guard.middleware.js b/internal/plugin/testdata/github/raw/someone/word-guard/main/word-guard.middleware.js new file mode 100644 index 000000000..c5e81f8ce --- /dev/null +++ b/internal/plugin/testdata/github/raw/someone/word-guard/main/word-guard.middleware.js @@ -0,0 +1,140 @@ +// New API's 敏感词过滤 as magpie gateway middleware: words or patterns you +// list are kept out of what agents send, turned away or masked, and can be +// masked in what comes back. +// +// {"words": ["project-x"], "patterns": ["\\b\\d{3}-\\d{4}\\b"], +// "action": "reject", "check": "last", "mask": "***", +// "replies": false, "message": ""} +// +// Only the user's own text is read: the API's user messages' text, not +// tool results, tool calls or the system prompt. "check": "last" reads the +// last user message that has text (New API reads the prompt, that is, the +// turn being sent), "all" every user message. Words match ignoring case. +// "action": "reject" turns the request away with an error naming the word; +// "mask" swaps each match for "mask". "replies": true masks matches in the +// text that comes back as well; a word split across two streamed events +// isn't seen. + +export function onRequest(body, ctx) { + const re = matcher(ctx.options) + if (!re) return + const o = ctx.options + const all = o.check === "all" + if (o.action === "mask") { + const mask = typeof o.mask === "string" ? o.mask : "***" + let changed = false + userTexts(body, ctx.protocol, all, (t) => { + re.lastIndex = 0 + const u = t.replace(re, mask) + if (u !== t) changed = true + return u + }) + return changed ? body : undefined + } + let hit = null + userTexts(body, ctx.protocol, all, (t) => { + if (hit === null) { + re.lastIndex = 0 + const m = re.exec(t) + if (m) hit = m[0] + } + return t + }) + if (hit !== null) ctx.reject(400, o.message || `this request has "${hit}", which this gateway doesn't send`) +} + +export function onEvent(ev, ctx) { + const o = ctx.options + if (!o || !o.replies || o.action !== "mask") return + const re = matcher(o) + if (!re) return + const mask = typeof o.mask === "string" ? o.mask : "***" + const sub = (t) => { + re.lastIndex = 0 + return typeof t === "string" ? t.replace(re, mask) : t + } + let changed = false + const set = (obj, k) => { + if (obj && typeof obj[k] === "string") { + const u = sub(obj[k]) + if (u !== obj[k]) { + obj[k] = u + changed = true + } + } + } + if (ev.type === "content_block_delta") set(ev.delta, "text") + else if (ev.type === "response.output_text.delta") set(ev, "delta") + else if (ev.type === "response.output_text.done") set(ev, "text") + else if (Array.isArray(ev.choices)) for (const c of ev.choices) set(c.delta, "content") + // Gemini streams its text in candidates[].content.parts[].text, the shape + // onResponse below already masks + else if (Array.isArray(ev.candidates)) + for (const c of ev.candidates) { + if (c && c.content && Array.isArray(c.content.parts)) for (const p of c.content.parts) set(p, "text") + } + return changed ? ev : undefined +} + +export function onResponse(body, ctx) { + const o = ctx.options + if (!o || !o.replies || o.action !== "mask" || ctx.status >= 400) return + const re = matcher(o) + if (!re) return + const mask = typeof o.mask === "string" ? o.mask : "***" + let changed = false + const fix = (obj, k) => { + if (obj && typeof obj[k] === "string") { + re.lastIndex = 0 + const u = obj[k].replace(re, mask) + if (u !== obj[k]) { + obj[k] = u + changed = true + } + } + } + if (Array.isArray(body.content)) for (const b of body.content) if (b && b.type === "text") fix(b, "text") + if (Array.isArray(body.choices)) for (const c of body.choices) fix(c.message, "content") + if (Array.isArray(body.output)) for (const it of body.output) if (it && Array.isArray(it.content)) for (const p of it.content) fix(p, "text") + if (Array.isArray(body.candidates)) for (const c of body.candidates) if (c.content && Array.isArray(c.content.parts)) for (const p of c.content.parts) fix(p, "text") + return changed ? body : undefined +} + +// matcher is one expression for every word and pattern; null for none. +// A runtime is kept for a request's hooks, so it is built once a request. +let cached = null +function matcher(o) { + if (!o || typeof o !== "object") return null + const key = JSON.stringify([o.words, o.patterns]) + if (cached && cached.key === key) return cached.re + const parts = [] + for (const w of Array.isArray(o.words) ? o.words : []) if (typeof w === "string" && w.trim()) parts.push(w.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) + for (const p of Array.isArray(o.patterns) ? o.patterns : []) if (typeof p === "string" && p) parts.push("(?:" + p + ")") + const re = parts.length ? new RegExp(parts.join("|"), "gi") : null + cached = { key, re } + return re +} + +// userTexts calls fn on each text of the user's own in body, in its API's +// shape, and puts back what fn gives: the last user message with text, or +// all of them. +function userTexts(body, protocol, all, fn) { + let msgs = [] + if (protocol === "gemini") { + msgs = (Array.isArray(body.contents) ? body.contents : []).filter((m) => m && (m.role === "user" || !m.role)).map((m) => ({ m, list: m.parts, key: "text", only: (p) => p && typeof p.text === "string" })) + } else if (protocol === "responses") { + if (typeof body.input === "string") { + body.input = fn(body.input) + return + } + msgs = (Array.isArray(body.input) ? body.input : []).filter((m) => m && m.role === "user").map((m) => ({ m, list: m.content, key: "text", only: (p) => p && (p.type === "input_text" || p.type === "text") })) + } else { + msgs = (Array.isArray(body.messages) ? body.messages : []).filter((m) => m && m.role === "user").map((m) => ({ m, list: m.content, key: "text", only: (p) => p && p.type === "text" })) + } + const hasText = (x) => typeof x.m.content === "string" || (Array.isArray(x.list) && x.list.some(x.only)) + const chosen = all ? msgs.filter(hasText) : msgs.filter(hasText).slice(-1) + for (const x of chosen) { + if (typeof x.m.content === "string") x.m.content = fn(x.m.content) + else for (const p of x.list) if (x.only(p)) p[x.key] = fn(p[x.key]) + } +} diff --git a/internal/plugin/testdata/github/raw/vbgate/learn-opencode/main/package.json b/internal/plugin/testdata/github/raw/vbgate/learn-opencode/main/package.json new file mode 100644 index 000000000..be4a320ef --- /dev/null +++ b/internal/plugin/testdata/github/raw/vbgate/learn-opencode/main/package.json @@ -0,0 +1,25 @@ +{ + "name": "opencode-tutorial", + "version": "1.0.0", + "description": "OpenCode 中文实战课 - 零基础学会用 AI 干实际工作", + "type": "module", + "scripts": { + "dev": "bash scripts/stats.sh && vitepress dev docs", + "build": "bash scripts/stats.sh && vitepress build docs", + "preview": "vitepress preview docs" + }, + "keywords": [ + "opencode", + "ai", + "tutorial", + "vitepress" + ], + "license": "CC-BY-NC-SA-4.0", + "devDependencies": { + "vitepress": "^2.0.0-alpha.15", + "vue": "^3.5.0" + }, + "dependencies": { + "medium-zoom": "^1.1.0" + } +} diff --git a/internal/plugin/testdata/github/search.json b/internal/plugin/testdata/github/search.json new file mode 100644 index 000000000..5206e65e8 --- /dev/null +++ b/internal/plugin/testdata/github/search.json @@ -0,0 +1,617 @@ +{ + "total_count": 1042, + "incomplete_results": false, + "items": [ + { + "id": 1044010907, + "node_id": "R_kgDOPjpXmw", + "name": "iPolloWork", + "full_name": "Devin-AXIS/iPolloWork", + "private": false, + "owner": { + "login": "Devin-AXIS", + "id": 228423313, + "node_id": "U_kgDODZ12kQ", + "avatar_url": "https://avatars.githubusercontent.com/u/228423313?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Devin-AXIS", + "html_url": "https://github.com/Devin-AXIS", + "followers_url": "https://api.github.com/users/Devin-AXIS/followers", + "following_url": "https://api.github.com/users/Devin-AXIS/following{/other_user}", + "gists_url": "https://api.github.com/users/Devin-AXIS/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Devin-AXIS/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Devin-AXIS/subscriptions", + "organizations_url": "https://api.github.com/users/Devin-AXIS/orgs", + "repos_url": "https://api.github.com/users/Devin-AXIS/repos", + "events_url": "https://api.github.com/users/Devin-AXIS/events{/privacy}", + "received_events_url": "https://api.github.com/users/Devin-AXIS/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/Devin-AXIS/iPolloWork", + "description": "Enterprise-grade, local-first Agent Workbench for people and agent teams. A unified multi-engine workspace for Codex Harness, DeepSeek Harness, and OpenCode, with unified plugins and Skills, multi-agent projects and tasks, and editable code, documents, presentations, design, and video.", + "fork": false, + "url": "https://api.github.com/repos/Devin-AXIS/iPolloWork", + "forks_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/forks", + "keys_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/teams", + "hooks_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/hooks", + "issue_events_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/issues/events{/number}", + "events_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/events", + "assignees_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/assignees{/user}", + "branches_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/branches{/branch}", + "tags_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/tags", + "blobs_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/languages", + "stargazers_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/stargazers", + "contributors_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/contributors", + "subscribers_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/subscribers", + "subscription_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/subscription", + "commits_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/contents/{+path}", + "compare_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/merges", + "archive_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/downloads", + "issues_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/issues{/number}", + "pulls_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/labels{/name}", + "releases_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/releases{/id}", + "deployments_url": "https://api.github.com/repos/Devin-AXIS/iPolloWork/deployments", + "created_at": "2025-08-25T03:57:40Z", + "updated_at": "2026-10-07T00:22:56Z", + "pushed_at": "2026-10-06T15:43:14Z", + "git_url": "git://github.com/Devin-AXIS/iPolloWork.git", + "ssh_url": "git@github.com:Devin-AXIS/iPolloWork.git", + "clone_url": "https://github.com/Devin-AXIS/iPolloWork.git", + "svn_url": "https://github.com/Devin-AXIS/iPolloWork", + "homepage": "https://www.ipollo.ai/", + "size": 639617, + "stargazers_count": 6707, + "watchers_count": 6707, + "language": "TypeScript", + "has_issues": true, + "has_projects": false, + "has_downloads": false, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 1136, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 86, + "license": { + "key": "other", + "name": "Other", + "spdx_id": "NOASSERTION", + "url": null, + "node_id": "MDc6TGljZW5zZTA=" + }, + "allow_forking": true, + "is_template": true, + "web_commit_signoff_required": true, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [ + "agent-collaboration", + "agent-skills", + "ai-agents", + "ai-work", + "claude-code", + "codex", + "codex-plugin", + "deepseek-harness", + "dsh-plugin", + "enterprise-agent-workspace", + "hermes-agent", + "ipollowork-plugin", + "ipollowork-skill", + "multi-agent-workspace", + "opencode", + "opencode-plugin", + "self-evolving-ai", + "visual-editor" + ], + "visibility": "public", + "forks": 1136, + "open_issues": 86, + "watchers": 6707, + "default_branch": "main", + "score": 1.0 + }, + { + "id": 1138589051, + "node_id": "R_kgDOQ919ew", + "name": "meridian", + "full_name": "rynfar/meridian", + "private": false, + "owner": { + "login": "rynfar", + "id": 11325514, + "node_id": "MDQ6VXNlcjExMzI1NTE0", + "avatar_url": "https://avatars.githubusercontent.com/u/11325514?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/rynfar", + "html_url": "https://github.com/rynfar", + "followers_url": "https://api.github.com/users/rynfar/followers", + "following_url": "https://api.github.com/users/rynfar/following{/other_user}", + "gists_url": "https://api.github.com/users/rynfar/gists{/gist_id}", + "starred_url": "https://api.github.com/users/rynfar/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/rynfar/subscriptions", + "organizations_url": "https://api.github.com/users/rynfar/orgs", + "repos_url": "https://api.github.com/users/rynfar/repos", + "events_url": "https://api.github.com/users/rynfar/events{/privacy}", + "received_events_url": "https://api.github.com/users/rynfar/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/rynfar/meridian", + "description": "Use Claude and Antigravity with Pi, OpenCode and other coding clients. Local API bridge, usage dashboard and Mac app. Antigravity preview available in 1.74.0.", + "fork": false, + "url": "https://api.github.com/repos/rynfar/meridian", + "forks_url": "https://api.github.com/repos/rynfar/meridian/forks", + "keys_url": "https://api.github.com/repos/rynfar/meridian/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/rynfar/meridian/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/rynfar/meridian/teams", + "hooks_url": "https://api.github.com/repos/rynfar/meridian/hooks", + "issue_events_url": "https://api.github.com/repos/rynfar/meridian/issues/events{/number}", + "events_url": "https://api.github.com/repos/rynfar/meridian/events", + "assignees_url": "https://api.github.com/repos/rynfar/meridian/assignees{/user}", + "branches_url": "https://api.github.com/repos/rynfar/meridian/branches{/branch}", + "tags_url": "https://api.github.com/repos/rynfar/meridian/tags", + "blobs_url": "https://api.github.com/repos/rynfar/meridian/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/rynfar/meridian/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/rynfar/meridian/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/rynfar/meridian/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/rynfar/meridian/statuses/{sha}", + "languages_url": "https://api.github.com/repos/rynfar/meridian/languages", + "stargazers_url": "https://api.github.com/repos/rynfar/meridian/stargazers", + "contributors_url": "https://api.github.com/repos/rynfar/meridian/contributors", + "subscribers_url": "https://api.github.com/repos/rynfar/meridian/subscribers", + "subscription_url": "https://api.github.com/repos/rynfar/meridian/subscription", + "commits_url": "https://api.github.com/repos/rynfar/meridian/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/rynfar/meridian/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/rynfar/meridian/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/rynfar/meridian/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/rynfar/meridian/contents/{+path}", + "compare_url": "https://api.github.com/repos/rynfar/meridian/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/rynfar/meridian/merges", + "archive_url": "https://api.github.com/repos/rynfar/meridian/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/rynfar/meridian/downloads", + "issues_url": "https://api.github.com/repos/rynfar/meridian/issues{/number}", + "pulls_url": "https://api.github.com/repos/rynfar/meridian/pulls{/number}", + "milestones_url": "https://api.github.com/repos/rynfar/meridian/milestones{/number}", + "notifications_url": "https://api.github.com/repos/rynfar/meridian/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/rynfar/meridian/labels{/name}", + "releases_url": "https://api.github.com/repos/rynfar/meridian/releases{/id}", + "deployments_url": "https://api.github.com/repos/rynfar/meridian/deployments", + "created_at": "2026-01-20T21:39:40Z", + "updated_at": "2026-10-06T23:51:47Z", + "pushed_at": "2026-10-06T21:32:54Z", + "git_url": "git://github.com/rynfar/meridian.git", + "ssh_url": "git@github.com:rynfar/meridian.git", + "clone_url": "https://github.com/rynfar/meridian.git", + "svn_url": "https://github.com/rynfar/meridian", + "homepage": "https://www.npmjs.com/package/@rynfar/meridian", + "size": 11614, + "stargazers_count": 2098, + "watchers_count": 2098, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": false, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 241, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 42, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [ + "ai-agents", + "ai-coding", + "aider", + "anthropic", + "antigravity", + "bun", + "claude", + "claude-agent-sdk", + "claude-max", + "cline", + "crush-cli", + "gemini", + "google-antigravity", + "jcode", + "llm", + "mcp", + "opencode", + "opencode-plugin", + "pi-coding-agent", + "proxy" + ], + "visibility": "public", + "forks": 241, + "open_issues": 42, + "watchers": 2098, + "default_branch": "main", + "score": 1.0 + }, + { + "id": 1129612380, + "node_id": "R_kgDOQ1SEXA", + "name": "learn-opencode", + "full_name": "vbgate/learn-opencode", + "private": false, + "owner": { + "login": "vbgate", + "id": 251357112, + "node_id": "O_kgDODvtnuA", + "avatar_url": "https://avatars.githubusercontent.com/u/251357112?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/vbgate", + "html_url": "https://github.com/vbgate", + "followers_url": "https://api.github.com/users/vbgate/followers", + "following_url": "https://api.github.com/users/vbgate/following{/other_user}", + "gists_url": "https://api.github.com/users/vbgate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/vbgate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/vbgate/subscriptions", + "organizations_url": "https://api.github.com/users/vbgate/orgs", + "repos_url": "https://api.github.com/users/vbgate/repos", + "events_url": "https://api.github.com/users/vbgate/events{/privacy}", + "received_events_url": "https://api.github.com/users/vbgate/received_events", + "type": "Organization", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/vbgate/learn-opencode", + "description": "OpenCode 中文实战课源码与内容仓库:一课一页,覆盖入门到实战工作流。", + "fork": false, + "url": "https://api.github.com/repos/vbgate/learn-opencode", + "forks_url": "https://api.github.com/repos/vbgate/learn-opencode/forks", + "keys_url": "https://api.github.com/repos/vbgate/learn-opencode/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/vbgate/learn-opencode/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/vbgate/learn-opencode/teams", + "hooks_url": "https://api.github.com/repos/vbgate/learn-opencode/hooks", + "issue_events_url": "https://api.github.com/repos/vbgate/learn-opencode/issues/events{/number}", + "events_url": "https://api.github.com/repos/vbgate/learn-opencode/events", + "assignees_url": "https://api.github.com/repos/vbgate/learn-opencode/assignees{/user}", + "branches_url": "https://api.github.com/repos/vbgate/learn-opencode/branches{/branch}", + "tags_url": "https://api.github.com/repos/vbgate/learn-opencode/tags", + "blobs_url": "https://api.github.com/repos/vbgate/learn-opencode/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/vbgate/learn-opencode/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/vbgate/learn-opencode/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/vbgate/learn-opencode/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/vbgate/learn-opencode/statuses/{sha}", + "languages_url": "https://api.github.com/repos/vbgate/learn-opencode/languages", + "stargazers_url": "https://api.github.com/repos/vbgate/learn-opencode/stargazers", + "contributors_url": "https://api.github.com/repos/vbgate/learn-opencode/contributors", + "subscribers_url": "https://api.github.com/repos/vbgate/learn-opencode/subscribers", + "subscription_url": "https://api.github.com/repos/vbgate/learn-opencode/subscription", + "commits_url": "https://api.github.com/repos/vbgate/learn-opencode/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/vbgate/learn-opencode/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/vbgate/learn-opencode/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/vbgate/learn-opencode/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/vbgate/learn-opencode/contents/{+path}", + "compare_url": "https://api.github.com/repos/vbgate/learn-opencode/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/vbgate/learn-opencode/merges", + "archive_url": "https://api.github.com/repos/vbgate/learn-opencode/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/vbgate/learn-opencode/downloads", + "issues_url": "https://api.github.com/repos/vbgate/learn-opencode/issues{/number}", + "pulls_url": "https://api.github.com/repos/vbgate/learn-opencode/pulls{/number}", + "milestones_url": "https://api.github.com/repos/vbgate/learn-opencode/milestones{/number}", + "notifications_url": "https://api.github.com/repos/vbgate/learn-opencode/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/vbgate/learn-opencode/labels{/name}", + "releases_url": "https://api.github.com/repos/vbgate/learn-opencode/releases{/id}", + "deployments_url": "https://api.github.com/repos/vbgate/learn-opencode/deployments", + "created_at": "2026-01-07T10:34:02Z", + "updated_at": "2026-10-06T13:48:40Z", + "pushed_at": "2026-08-25T04:56:55Z", + "git_url": "git://github.com/vbgate/learn-opencode.git", + "ssh_url": "git@github.com:vbgate/learn-opencode.git", + "clone_url": "https://github.com/vbgate/learn-opencode.git", + "svn_url": "https://github.com/vbgate/learn-opencode", + "homepage": "https://learnopencode.com/", + "size": 632427, + "stargazers_count": 1740, + "watchers_count": 1740, + "language": "Shell", + "has_issues": true, + "has_projects": true, + "has_downloads": false, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 225, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": { + "key": "other", + "name": "Other", + "spdx_id": "NOASSERTION", + "url": null, + "node_id": "MDc6TGljZW5zZTA=" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [ + "opencode", + "opencode-ai", + "opencode-cluster", + "opencode-plugin", + "opencode-plugins" + ], + "visibility": "public", + "forks": 225, + "open_issues": 1, + "watchers": 1740, + "default_branch": "main", + "score": 1.0 + }, + { + "id": 1186664179, + "node_id": "R_kgDORrsO8w", + "name": "opencode-claude-auth", + "full_name": "griffinmartin/opencode-claude-auth", + "private": false, + "owner": { + "login": "griffinmartin", + "id": 1090329, + "node_id": "MDQ6VXNlcjEwOTAzMjk=", + "avatar_url": "https://avatars.githubusercontent.com/u/1090329?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/griffinmartin", + "html_url": "https://github.com/griffinmartin", + "followers_url": "https://api.github.com/users/griffinmartin/followers", + "following_url": "https://api.github.com/users/griffinmartin/following{/other_user}", + "gists_url": "https://api.github.com/users/griffinmartin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/griffinmartin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/griffinmartin/subscriptions", + "organizations_url": "https://api.github.com/users/griffinmartin/orgs", + "repos_url": "https://api.github.com/users/griffinmartin/repos", + "events_url": "https://api.github.com/users/griffinmartin/events{/privacy}", + "received_events_url": "https://api.github.com/users/griffinmartin/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/griffinmartin/opencode-claude-auth", + "description": "OpenCode plugin that uses your existing Claude Code credentials — no separate login needed. ", + "fork": false, + "url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth", + "forks_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/forks", + "keys_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/teams", + "hooks_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/hooks", + "issue_events_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/issues/events{/number}", + "events_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/events", + "assignees_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/assignees{/user}", + "branches_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/branches{/branch}", + "tags_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/tags", + "blobs_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/statuses/{sha}", + "languages_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/languages", + "stargazers_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/stargazers", + "contributors_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/contributors", + "subscribers_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/subscribers", + "subscription_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/subscription", + "commits_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/contents/{+path}", + "compare_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/merges", + "archive_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/downloads", + "issues_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/issues{/number}", + "pulls_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/pulls{/number}", + "milestones_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/milestones{/number}", + "notifications_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/labels{/name}", + "releases_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/releases{/id}", + "deployments_url": "https://api.github.com/repos/griffinmartin/opencode-claude-auth/deployments", + "created_at": "2026-03-19T21:35:23Z", + "updated_at": "2026-10-06T20:37:46Z", + "pushed_at": "2026-09-22T23:47:15Z", + "git_url": "git://github.com/griffinmartin/opencode-claude-auth.git", + "ssh_url": "git@github.com:griffinmartin/opencode-claude-auth.git", + "clone_url": "https://github.com/griffinmartin/opencode-claude-auth.git", + "svn_url": "https://github.com/griffinmartin/opencode-claude-auth", + "homepage": "", + "size": 326, + "stargazers_count": 1301, + "watchers_count": 1301, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": false, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 190, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 27, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [ + "ai", + "anthropic", + "authentication", + "claude", + "claude-code", + "homebrew", + "nodejs", + "oauth", + "opencode", + "opencode-plugin", + "typescript" + ], + "visibility": "public", + "forks": 190, + "open_issues": 27, + "watchers": 1301, + "default_branch": "main", + "score": 1.0 + }, + { + "id": 1140158649, + "node_id": "R_kgDOQ_VwuQ", + "name": "opencode-quota", + "full_name": "slkiser/opencode-quota", + "private": false, + "owner": { + "login": "slkiser", + "id": 35721408, + "node_id": "MDQ6VXNlcjM1NzIxNDA4", + "avatar_url": "https://avatars.githubusercontent.com/u/35721408?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/slkiser", + "html_url": "https://github.com/slkiser", + "followers_url": "https://api.github.com/users/slkiser/followers", + "following_url": "https://api.github.com/users/slkiser/following{/other_user}", + "gists_url": "https://api.github.com/users/slkiser/gists{/gist_id}", + "starred_url": "https://api.github.com/users/slkiser/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/slkiser/subscriptions", + "organizations_url": "https://api.github.com/users/slkiser/orgs", + "repos_url": "https://api.github.com/users/slkiser/repos", + "events_url": "https://api.github.com/users/slkiser/events{/privacy}", + "received_events_url": "https://api.github.com/users/slkiser/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/slkiser/opencode-quota", + "description": "OpenCode quota & tokens usage with zero context window pollution. Supports OpenCode Go, Cursor, GitHub Copilot, OpenAl, Kimi Code, Alibaba Coding Plan, Chutes Al, Google Antigravity, Z.ai Coding Plan and more.", + "fork": false, + "url": "https://api.github.com/repos/slkiser/opencode-quota", + "forks_url": "https://api.github.com/repos/slkiser/opencode-quota/forks", + "keys_url": "https://api.github.com/repos/slkiser/opencode-quota/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/slkiser/opencode-quota/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/slkiser/opencode-quota/teams", + "hooks_url": "https://api.github.com/repos/slkiser/opencode-quota/hooks", + "issue_events_url": "https://api.github.com/repos/slkiser/opencode-quota/issues/events{/number}", + "events_url": "https://api.github.com/repos/slkiser/opencode-quota/events", + "assignees_url": "https://api.github.com/repos/slkiser/opencode-quota/assignees{/user}", + "branches_url": "https://api.github.com/repos/slkiser/opencode-quota/branches{/branch}", + "tags_url": "https://api.github.com/repos/slkiser/opencode-quota/tags", + "blobs_url": "https://api.github.com/repos/slkiser/opencode-quota/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/slkiser/opencode-quota/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/slkiser/opencode-quota/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/slkiser/opencode-quota/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/slkiser/opencode-quota/statuses/{sha}", + "languages_url": "https://api.github.com/repos/slkiser/opencode-quota/languages", + "stargazers_url": "https://api.github.com/repos/slkiser/opencode-quota/stargazers", + "contributors_url": "https://api.github.com/repos/slkiser/opencode-quota/contributors", + "subscribers_url": "https://api.github.com/repos/slkiser/opencode-quota/subscribers", + "subscription_url": "https://api.github.com/repos/slkiser/opencode-quota/subscription", + "commits_url": "https://api.github.com/repos/slkiser/opencode-quota/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/slkiser/opencode-quota/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/slkiser/opencode-quota/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/slkiser/opencode-quota/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/slkiser/opencode-quota/contents/{+path}", + "compare_url": "https://api.github.com/repos/slkiser/opencode-quota/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/slkiser/opencode-quota/merges", + "archive_url": "https://api.github.com/repos/slkiser/opencode-quota/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/slkiser/opencode-quota/downloads", + "issues_url": "https://api.github.com/repos/slkiser/opencode-quota/issues{/number}", + "pulls_url": "https://api.github.com/repos/slkiser/opencode-quota/pulls{/number}", + "milestones_url": "https://api.github.com/repos/slkiser/opencode-quota/milestones{/number}", + "notifications_url": "https://api.github.com/repos/slkiser/opencode-quota/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/slkiser/opencode-quota/labels{/name}", + "releases_url": "https://api.github.com/repos/slkiser/opencode-quota/releases{/id}", + "deployments_url": "https://api.github.com/repos/slkiser/opencode-quota/deployments", + "created_at": "2026-01-22T22:45:14Z", + "updated_at": "2026-10-07T00:02:35Z", + "pushed_at": "2026-10-06T13:25:50Z", + "git_url": "git://github.com/slkiser/opencode-quota.git", + "ssh_url": "git@github.com:slkiser/opencode-quota.git", + "clone_url": "https://github.com/slkiser/opencode-quota.git", + "svn_url": "https://github.com/slkiser/opencode-quota", + "homepage": "", + "size": 18391, + "stargazers_count": 1000, + "watchers_count": 1000, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": false, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 113, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [ + "opencode", + "opencode-plugin", + "opencode-plugins", + "quota", + "quota-monitor", + "token-usage", + "tokens", + "usage" + ], + "visibility": "public", + "forks": 113, + "open_issues": 3, + "watchers": 1000, + "default_branch": "main", + "score": 1.0 + } + ] +}