From 52968f2d34e36b4c0a69e855588e1d4f679d4d55 Mon Sep 17 00:00:00 2001 From: lokic7123-star Date: Thu, 22 Oct 2026 22:12:09 +0900 Subject: [PATCH] zen-free: declare keyless single-identity access (#205, LoKi) Marks Zen Free's api method keyless and its auth single, so magpie's host (yetone/magpie#2695, 5871f02dd) signs it in with no key field and Sign in again instead of another account. authorize is unchanged; older hosts and OpenCode keep the public-key flow. Run at the PR head 29f0e9b38: bun test in packages/zen-free under a sandbox HOME, 175 pass, 0 fail. Checked against magpie main: host.js reads m.keyless (api method with authorize) and auth.single, the two fields this sets. Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com> --- packages/zen-free/README.md | 5 +++++ packages/zen-free/keyless.test.mjs | 10 ++++++++++ packages/zen-free/provider.mjs | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 packages/zen-free/keyless.test.mjs diff --git a/packages/zen-free/README.md b/packages/zen-free/README.md index ca69350..a1d72d6 100644 --- a/packages/zen-free/README.md +++ b/packages/zen-free/README.md @@ -20,6 +20,11 @@ magpie plugin login opencode-zen-free Enter `public` in the key field. No personal API key is needed. +Hosts supporting magpie's `keyless` and `single` auth metadata can enable +this public identity without a key field and offer Sign in again instead +of another account. Older hosts and OpenCode keep the public-key flow. +Personal keys still belong to the built-in OpenCode Zen provider. + Whatever is typed in the key field, the plugin signs in with the one shared `public` credential: a key made under your own OpenCode account does nothing here, and several of them don't make several accounts. Your diff --git a/packages/zen-free/keyless.test.mjs b/packages/zen-free/keyless.test.mjs new file mode 100644 index 0000000..6982b5f --- /dev/null +++ b/packages/zen-free/keyless.test.mjs @@ -0,0 +1,10 @@ +import {test,expect} from "bun:test" +import {ZenFreePlugin} from "./index.mjs" + +test("Zen Free declares one keyless public identity without changing authorize",async()=>{ + const hooks=await ZenFreePlugin({client:{auth:{set:async()=>{throw Error("unexpected auth write")}}}}) + expect(hooks.auth.single).toBe(true) + expect(hooks.auth.methods[0].keyless).toBe(true) + expect(await hooks.auth.methods[0].authorize({})).toEqual({type:"success",key:"public"}) + expect(await hooks.auth.methods[0].authorize({key:"personal-fixture"})).toEqual({type:"success",key:"public"}) +}) diff --git a/packages/zen-free/provider.mjs b/packages/zen-free/provider.mjs index a5d604d..e960652 100644 --- a/packages/zen-free/provider.mjs +++ b/packages/zen-free/provider.mjs @@ -252,11 +252,13 @@ async function server(_input, options = {}) { }, auth: { provider: PROVIDER, + single: true, icon: "https://opencode.ai/favicon-v3.ico", maxConcurrency: 2, methods: [ { type: "api", + keyless: true, label: "Zen 免费访问(密钥填 public;自己的 OpenCode Key 请加到内置的 OpenCode Zen)", placeholder: "public", async authorize() {