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.
New package @magpie-community/opencode-joycode-auth 0.1.1 (provider id `joycode`) and its registry entry (en and zh). JoyCode is JD Cloud's own coding IDE subscription (joycode.jd.com, api-ai.jd.com), not a relay.
- Browser sign-in through JoyCode's own login page. The page sends the browser to http://127.0.0.1:<authPort>/ with authKey and pt_key; I checked this against the page's bundle. A request without the right authKey gets a 404 and leaves the sign-in pending. A ptKey can also be pasted, with an optional tenant.
- Chat completions are signed per request (HMAC over a fresh t), with userId, tenant and orgFullName from joycode_userInfo. A bare JSON error sent as HTTP 200 SSE becomes an error reply: code 401 is 401 with sign-in expired, AI_GRAY_ACCESS_DENIED is 403, anything else is 502. JD's msg is kept as the error text.
- Account models come from joycode_modelList, credit multipliers from plugin_config billingRate, and credit usage from get_newpoint_ide (windows set aside).
- Contacts only JD's hosts. No runtime dependencies, no install scripts, no logging. The ptKey is kept only in magpie's plugin-auth.json.
Reviewed every line at c80068f and again at 1cac30c, which fixed all five review points: the README link, JD's `msg`, tests for the authKey check and for the HTTP 200 SSE code 401, the stale header comment, and stray loopback requests.
Run at the reviewed head 1cac30cce31a1f3efeb39b2c61df257963e655a, whose parent is main 57ec655:
- packages/joycode: `bun test` (Bun 1.4.2) 30 pass, 0 fail. `node --test` (Node 22) 30 pass.
- Whole repo, as CI runs it: `HOME=$(mktemp -d) bun test` 2373 pass, 0 fail. `bun scripts/check.mjs` all ✓.
- Broke the code by hand: removed the authKey check, made a wrong authKey end the sign-in, mapped the SSE code 401 to 502, and dropped `msg` in chat and in usage. Each one turns a test red.
- magpie built from main, in a sandbox HOME: `plugin add` lists `joycode (JoyCode, 5 models)`, and `plugin login joycode` offers both methods. With a made-up ptKey, provider.models, `provider test` and `quota` each fail with "JoyCode 登录已失效" and mark the sign-in expired. plugin-auth.json is mode 600.
- JD's gateway answered the made-up ptKey with HTTP 200 `{"code":401,"data":…,"msg":…}` on joycode_userInfo, chat_completions (as text/event-stream) and get_newpoint_ide.
Not tried: no JoyCode account was available, so no successful chat, model list, multiplier or quota read was made against JD. The author reports live JoyAI-Code-1.6 streaming and tool-call runs.