trae 0.1.6: the usage card says Trae CN's credits in the Credits row, as WorkBuddy's, not as an English balance line under it (yetone/magpie#694, Hu9956 on magpie 0.1.784: 积分显示的样式有点不一样 — WorkBuddy's cards read "积分 1,689.01 / 2,400 积分 · 剩余 70.4%", Trae CN's "积分 剩余 60.7%" with "余额 2307.42 of 3800 credits left" in large type below) — usage gave the share alone on its Credits window and the count as a balance string, "<left> of <limit> credits left", which magpie shows as a separate 余额 row (balanceRow, beside windows) in the plugin's own English and number format, and never flips with 已用/剩余. The window now carries the count as WorkBuddy's does (amount = credits used, limit = the packs' total, unit "credits", magpie#659), so magpie's quotaCount writes "2,307.42 / 3,800 积分 · 剩余 60.7%" (or "1,492.58 / 3,800 积分 · 已用 39.3%"; "credits" in English) in the row itself, and the balance is left out; an unlimited account still says "unlimited" as its balance. No magpie change needed: plugin_usage.go already passes a plugin window's amount, limit and unit to the card. usage.test.mjs now expects the window's amount/limit/unit and no balance (fails on 0.1.5); HOME=$(mktemp -d) bun test (465 pass) and bun scripts/check.mjs trae pass. Checked in magpie's Usage page (webkit, zh and en, API faked with the old and new shapes beside WorkBuddy and WorkBuddy AI cards): the Trae CN card's row reads like WorkBuddy's and the 余额 line is gone. Not tried with a real Trae CN account.

This commit is contained in:
yetone
2026-10-04 13:07:10 +08:00
parent b2ddbc5017
commit 2caced14ef
4 changed files with 11 additions and 7 deletions
+3 -2
View File
@@ -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
+5 -2
View File
@@ -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]
}
+1 -1
View File
@@ -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",
+2 -2
View File
@@ -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", () => {