devin 0.1.24: the CLI sign-in's metadata is all strings (#396)

Releases #396 (metadata.cli saved as "true", so OpenCode 1 keeps the
account). Adds the test #396 lacked: the "Devin CLI's sign-in" method,
with a sandbox credentials.toml and a stubbed GetUserStatus, must save
cli as "true" and every metadata value as a string.

Run: bun test in packages/devin (sandbox HOME): 102 pass, 0 fail.
bun scripts/check.mjs devin passes. With index.mjs put back to
`cli = true`, the new test fails and the other cli-key test passes.
This commit is contained in:
yetone
2026-10-26 15:57:33 +08:00
parent 5068cc3219
commit 6bd998a3f8
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -5,7 +5,7 @@ import { afterAll, expect, test } from "bun:test"
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { _internal } from "./index.mjs"
import { DevinAuthPlugin, _internal } from "./index.mjs"
const was = process.env.XDG_DATA_HOME
const wasAppData = process.env.APPDATA
@@ -25,3 +25,23 @@ test("the CLI's account follows credentials.toml; a browser sign-in stays", asyn
expect(await _internal.live(cli)).toEqual({ key: "rotated", server: "https://t.example" })
expect(await _internal.live({ type: "api", key: "own", metadata: {} })).toMatchObject({ key: "own" })
})
// OpenCode 1 keeps an auth's metadata as strings only and drops an
// auth.json entry with any other value (#396), so the CLI sign-in saves
// every value, cli included, as a string.
test("the CLI sign-in saves only string metadata", async () => {
mkdirSync(join(data, "devin"), { recursive: true })
writeFileSync(join(data, "devin", "credentials.toml"), 'windsurf_api_key = "cli-key"\napi_server_url = "https://server.codeium.com"\n')
const realFetch = globalThis.fetch
globalThis.fetch = async () => new Response(JSON.stringify({ userStatus: { email: "me@example.com", planStatus: { planInfo: { planName: "Pro", devinInfo: { orgId: "org-1" } } }, teamId: "team-1" } }), { status: 200, headers: { "content-type": "application/json" } })
try {
const hooks = await DevinAuthPlugin({})
const method = hooks.auth.methods.find((m) => m.authorize && m.label === "Devin CLI's sign-in")
const r = await (await method.authorize()).callback()
expect(r.type).toBe("success")
expect(r.metadata.cli).toBe("true")
for (const [k, v] of Object.entries(r.metadata)) expect([k, typeof v]).toEqual([k, "string"])
} finally {
globalThis.fetch = realFetch
}
})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-devin-auth",
"version": "0.1.23",
"version": "0.1.24",
"description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie",
"type": "module",
"main": "./index.mjs",