joycode 0.2.4: plan expiry, and one retry when gray access is denied (#701)

joycode 0.2.4 (kasisama):
- usage: the plan's expiry from the IDE's expireText (end of that day,
  China time) as `until`, with each pool's runsOutAt/runsOut; the package
  row decides, otherwise the earliest pool.
- a gray-access denial is retried once with the identity read again.
- gateway failures are read from a clone of the reply (64KB at most); a
  JSON reply over 8MB answers 502 response_too_large.
- an empty catalogue keeps the built-in models, which are text-only.

The first head (f16034b2) turned the repo suite red: usage.test.mjs
called t.mock.method(globalThis, 'fetch') several times in one test, Bun
1.4 restored the wrong function, and the next file (joycode/login.test)
and ~450 tests after it kept hitting the mock. b1f06b75 installs the
mock once per test; nothing outside usage.test.mjs changed.

Run at the reviewed head b1f06b7501bddb4f035eee069bf44d89f02e5349 (mote):
- whole repo `bun test`: 5374 pass, 19 skip, 0 fail (401 files).
- at f16034b2: the same run had its first red in joycode/login.test.mjs
  right after usage.test.mjs, an AssertionError from usage.test.mjs's
  mock (the leak above).
- CI run 41772835368 on b1f06b75: success.
Not tried: a real JoyCode account (none here); the gray-denial retry and
expiry phrases are checked against the tests' fixtures only.
This commit is contained in:
kassama
2026-11-04 12:42:45 +08:00
committed by GitHub
parent 075cd237e2
commit f6fdf8fee1
7 changed files with 317 additions and 53 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ flatten 模式会把 Chat Completions 消息压平成 `system + 单条 user prom
## 已知限制
- **额度展示**:通过 IDE 同款 `get_newpoint_ide` 接口读取套餐、已用/总积分、剩余积分和有效期文字,可在账号及用量页面刷新。有效期文字不等同于额度重置时间,因此不推算重置倒计时。多个积分池分别显示,不相加;额度窗口仅作展示,由上游判定具体模型能否继续使用。
- **额度展示**:通过 IDE 同款 `get_newpoint_ide` 接口读取套餐、已用/总积分、剩余积分和有效期文字,可在账号及用量页面刷新。套餐行上的「有效期至」会解析成中国时区当天 23:59:59:账号卡片上悬停用量会显示「N 积分 将于 … 过期」,同时写入套餐到期时间。没有套餐行时,套餐到期时间取各积分池里最早的一份,每条用量仍显示自己的过期时间。这不是额度重置,所以不会出现「重置于」,也不推算重置倒计时。无法解析的文字仍只留在用量说明里。多个积分池分别显示,不相加;额度窗口仅作展示,由上游判定具体模型能否继续使用。
- **ptKey 失效**:表现为账号被标记「需要重新登录」,重新 `magpie plugin login joycode` 即可。
- **签名 key 轮换**:签名 key 是内嵌在每份 JoyCode IDE 里的公开协议常量,不是密钥。若 JoyCode 轮换它,从新版 `extension.js` 重新提取后,可通过环境变量 `JOYCODE_SIGN_KEY` 覆盖,无需改代码。
- 登录方式默认 `loginType: PIN_JD_CLOUD`;如果你的账号是京东云企业域登录且请求被拒,改 `index.mjs` 顶部的 `LOGIN_TYPE` 常量。