@magpie-community/opencode-zcode-auth 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/index.mjs +13 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -96,9 +96,11 @@ showing.
96
96
  trust-build / gift plans (a day's ZCode Trust Build, say) that are not
97
97
  on the account until the ZCode app claims them. The plugin reads the
98
98
  app's own list of them (`GET /api/v1/zcode-plan/billing/preview`) with
99
- the card and names them there — "1 to claim · claim it in the ZCode app"
99
+ the card and names them there — the window is named "Gift plans to
100
+ claim in the ZCode app" and the display shows "1 · ZCode Trust Build"
100
101
  — set aside, so the line stops nothing and routing, usage caps and the
101
- menu bar pass it over. The plugin never claims one: the claim needs the
102
+ menu bar pass it over. The name is a fixed sentence magpie can
103
+ translate; the count and the plan's own name are the display. The plugin never claims one: the claim needs the
102
104
  Aliyun captcha attestation only the app's renderer can make. A preview
103
105
  that fails, or lists nothing, adds no line at all, and a card that is an
104
106
  error keeps its error. Claim the plan in the ZCode app (open it once);
package/index.mjs CHANGED
@@ -541,15 +541,23 @@ async function giftOf(s) {
541
541
  return out
542
542
  }
543
543
 
544
+ // CLAIM_HINT is the claim line's name: a fixed sentence, so magpie
545
+ // translates it with the interface's own language (the plan's name and
546
+ // the count are data, and go in the display, which is shown as it came).
547
+ const CLAIM_HINT = "Gift plans to claim in the ZCode app"
548
+
544
549
  // claimHint is the card's line for gift plans ZCode is holding for the
545
550
  // account but has not put on it: GET /billing/preview lists them, and
546
551
  // only the ZCode app claims one — its claim takes the Aliyun captcha
547
552
  // attestation the app's own renderer makes, so the plugin reads the list
548
553
  // and asks the user to claim it there. A window, set aside (it is no
549
554
  // allowance: using it up stops nothing), so the card shows it and
550
- // routing, caps and the menu bar pass it over. null when there is
551
- // nothing to claim, the preview failing or listing none among it: a
552
- // failed read is no line at all, never a card or a refusal of its own.
555
+ // routing, caps and the menu bar pass it over. The window's name is a
556
+ // fixed sentence, so magpie can translate it (a display is shown as it
557
+ // came); the count and the plan's own name go in the display. null when
558
+ // there is nothing to claim, the preview failing or listing none among
559
+ // it: a failed read is no line at all, never a card or a refusal of its
560
+ // own.
553
561
  async function claimHint(s) {
554
562
  if (!s.jwt || jwtExpired(s.jwt)) return null
555
563
  let d
@@ -561,8 +569,8 @@ async function claimHint(s) {
561
569
  const plans = (Array.isArray(d?.plans) ? d.plans : []).filter((p) => typeof p?.plan_id === "string" && p.plan_id.trim())
562
570
  if (!plans.length) return null
563
571
  const n = plans.length
564
- const name = first(...plans.map((p) => (typeof p?.name === "string" ? p.name : "")), "ZCode gift plan")
565
- return { name, used: 0, aside: true, display: `${n} to claim · claim ${n === 1 ? "it" : "them"} in the ZCode app` }
572
+ const plan = first(...plans.map((p) => (typeof p?.name === "string" ? p.name : "")), "ZCode gift plan")
573
+ return { name: CLAIM_HINT, used: 0, aside: true, display: `${n} · ${plan}` }
566
574
  }
567
575
 
568
576
  // startUsage is a gift-only account's card: its buckets, or the words
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-zcode-auth",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "OpenCode provider plugin: signs in to Z.ai's or BigModel's (智谱) GLM Coding Plan as ZCode does, including team seats and ZCode's Start Plan",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",