From 47a8bb40d2b9f58535993e6b98668a391a88f730 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 16 Oct 2026 17:36:09 +0800 Subject: [PATCH] zed 0.1.8: a free account's card says "No plan", as the built-in's did, and the README says what the plugin and magpie now do What changed: - usage: magpie's built-in zedLoginQuota showed a free account's card (plan_v3 zed_free, or none) as "No plan", unless an overdue invoice was its error, while the account row kept zed.PlanName's "Free". magpie's card knows "No plan" (app.js noPlan) and translates it. The plugin's card said "Free". It now says "No plan" in the same case; the sign-in still saves planName "Free", and an overdue free card keeps "Free" with its error, as the built-in's switch did. - README: "Not included" listed the plan display, which the usage hook has shown since 0.1.x, and several accounts and the web-search stand-in, which magpie gives a plugin provider itself (plugin_accounts.go, the gateway's generic searchReply path). It is now a "Usage" section and an "In magpie, not the plugin" section. What was run: - usage.test.mjs: the free-account test (zed_free, "" and an overdue free account) fails on 0.1.7's index.mjs ("Free" for "No plan"), passes now. - packages/zed under a scratch HOME: 31 pass, 0 fail (4 files). - bun scripts/check.mjs zed passes. Not tried: a real free Zed account. --- packages/zed/README.md | 26 +++++++++++++++++++++----- packages/zed/index.mjs | 5 +++++ packages/zed/package.json | 2 +- packages/zed/usage.test.mjs | 9 +++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/packages/zed/README.md b/packages/zed/README.md index b9120eb..a81ec61 100644 --- a/packages/zed/README.md +++ b/packages/zed/README.md @@ -72,9 +72,25 @@ GitHub login. (Claude Sonnet 5, Opus 5.5, Haiku 4.5, GPT-5.5, Gemini 3.5 Flash, Grok 4.7), which the account's list replaces. -## Not included +## Usage -- magpie's plan display: plan name, billing period, overdue invoices. Zed - doesn't report how much of the allowance is spent. -- Several Zed accounts at once. OpenCode keeps one sign-in per provider. -- magpie's web-search stand-in. +magpie's `auth.usage` hook shows what Zed tells its editor of the plan, +as magpie's built-in Zed account did. Zed doesn't report how much of the +allowance is spent, so there are no windows: + +- the plan's name (Pro, Pro Trial, Business, Student, VIP). A free + account's card says "No plan"; its account row still names it Free; +- when the billing period ends; +- an overdue invoice, as the card's error ("its models are paused"); +- a sign-in Zed refuses (`/users/me` or the model list answering 401) + marks the account as needing to sign in again. A plan that changed is + saved with the sign-in. + +## In magpie, not the plugin + +These come from magpie itself, as they did for the built-in: + +- Several Zed accounts at once. magpie keeps a sign-in per account and + switches between them; plain OpenCode keeps one sign-in per provider. +- Web search. A model that can't search is given magpie's web-search + stand-in, when a search API is set up in magpie. diff --git a/packages/zed/index.mjs b/packages/zed/index.mjs index 364cbb5..dc08ad3 100644 --- a/packages/zed/index.mjs +++ b/packages/zed/index.mjs @@ -988,7 +988,12 @@ async function usage(auth, save) { } const end = me.plan?.subscription_period?.ended_at if (typeof end === "string" && RFC3339.test(end) && !isNaN(Date.parse(end))) out.until = end + // the account's row keeps naming a free plan "Free" (planName, saved + // above); its card says "No plan", which magpie's card knows and + // translates, unless an overdue invoice is what it says, as the + // built-in's zedLoginQuota did if (me.plan?.has_overdue_invoices) out.error = "Zed: this account has an overdue invoice, so its models are paused (see zed.dev/account)" + else if (plan === "zed_free" || plan === "") out.plan = "No plan" return out } diff --git a/packages/zed/package.json b/packages/zed/package.json index bc314d2..17262c4 100644 --- a/packages/zed/package.json +++ b/packages/zed/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-zed-auth", - "version": "0.1.7", + "version": "0.1.8", "description": "Sign in to a Zed subscription (Zed Pro, trial, student, business) from OpenCode or magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/zed/usage.test.mjs b/packages/zed/usage.test.mjs index 8a2aed5..e1b5da9 100644 --- a/packages/zed/usage.test.mjs +++ b/packages/zed/usage.test.mjs @@ -43,11 +43,16 @@ test("a Pro account: its plan and its period's end, no windows", async () => { expect(saved).toEqual([]) }) -test("a free account reads Free, as the built-in's row names it, and the plan it moved to is kept", async () => { +test("a free account's card says No plan, as the built-in's zedLoginQuota did; its row keeps Free, and the plan it moved to is kept", async () => { const { u, saved } = await run(auth(), () => new Response(me("zed_free"))) - expect(u).toEqual({ plan: "Free", until: "2026-10-01T00:00:00Z", signIn: "kept" }) + expect(u).toEqual({ plan: "No plan", until: "2026-10-01T00:00:00Z", signIn: "kept" }) expect(saved.length).toBe(1) expect(JSON.parse(saved[0].body.refresh)).toMatchObject({ plan: "zed_free", planName: "Free" }) + // an account that names no plan at all is free too + expect((await run(auth(), () => new Response(me("")))).u.plan).toBe("No plan") + // an overdue invoice is what a free card says, its plan named as the row names it + expect((await run(auth(), () => new Response(me("zed_free", true)))).u).toEqual({ plan: "Free", until: "2026-10-01T00:00:00Z", + error: "Zed: this account has an overdue invoice, so its models are paused (see zed.dev/account)", signIn: "kept" }) }) test("an overdue invoice is the error it is", async () => {