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() {