diff --git a/packages/trae/README.md b/packages/trae/README.md index 5e4d264..5843e6c 100644 --- a/packages/trae/README.md +++ b/packages/trae/README.md @@ -105,8 +105,9 @@ magpie's usage card shows the account's credits: - **Source:** `api.trae.cn/trae/api/v2/pay/ide_user_ent_usage`. - **What it adds up:** each entitlement pack's `credits_limit` (-1 means unlimited) and what the pack has used. -- **What it shows:** credits left as the balance, and the share used as a - window. +- **What it shows:** one Credits window: the credits used of the packs' + total, with the share, which magpie shows as used or left like + WorkBuddy's. ## Daily check-in diff --git a/packages/trae/index.mjs b/packages/trae/index.mjs index 11ad04f..2ce6e2b 100644 --- a/packages/trae/index.mjs +++ b/packages/trae/index.mjs @@ -881,8 +881,11 @@ export const TraeCNAuthPlugin = async ({ client }) => { const out = { plan: r.v.is_credits_billing ? "Credits" : "Free", user: a.name || a.uid, signIn } if (c.unlimited) out.balance = "unlimited" else if (c.limit > 0) { - out.balance = `${round(Math.max(0, c.limit - c.used))} of ${round(c.limit)} credits left` - const w = { name: "Credits", used: Math.max(0, Math.min(100, (c.used / c.limit) * 100)) } + // the count rides on the window (amount of limit, in credits), as + // WorkBuddy's does, so magpie says it in the window's row, used or + // left, in its own words and number format, rather than as an + // English balance line beside it (yetone/magpie#694) + const w = { name: "Credits", used: Math.max(0, Math.min(100, (c.used / c.limit) * 100)), amount: round(c.used), limit: round(c.limit), unit: "credits" } if (c.until) w.resetsAt = new Date(c.until).toISOString() out.windows = [w] } diff --git a/packages/trae/package.json b/packages/trae/package.json index e9637ff..de8a813 100644 --- a/packages/trae/package.json +++ b/packages/trae/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-trae-auth", - "version": "0.1.5", + "version": "0.1.6", "description": "OpenCode provider plugin for Trae CN (trae.cn): your Trae CN account's models, free tier included, with Trae's own browser sign-in", "type": "module", "main": "./index.mjs", diff --git a/packages/trae/usage.test.mjs b/packages/trae/usage.test.mjs index 2fcbd74..b52c71e 100644 --- a/packages/trae/usage.test.mjs +++ b/packages/trae/usage.test.mjs @@ -22,8 +22,8 @@ test("credits are the packs' limits and what they used", async () => { expect(u.plan).toBe("Free") expect(u.user).toBe("Ann") expect(u.signIn).toBe("kept") - expect(u.balance).toBe("300 of 400 credits left") - expect(u.windows).toEqual([{ name: "Credits", used: 25, resetsAt: new Date(1790000000 * 1000).toISOString() }]) + expect(u.balance).toBeUndefined() // the window carries the count (yetone/magpie#694) + expect(u.windows).toEqual([{ name: "Credits", used: 25, amount: 100, limit: 400, unit: "credits", resetsAt: new Date(1790000000 * 1000).toISOString() }]) }) test("unlimited packs say so", () => {