Files
plugins/packages/warp/entrypoints.test.mjs
guoqchen1001andguoqchen1001 54a55b8b67 warp 0.1.0: Warp AI credits through the Warp app's sign-in (#57)
New provider package @magpie-community/opencode-warp-auth 0.1.0: Warp (the
terminal) AI request credits through the Warp app's sign-in (macOS
Keychain, Windows DPAPI, Linux Secret Service, read-only) or a refresh
token; the account's model list, usage/bonus credits, streaming and tool
calls over Warp's HTTP/2 protobuf API with backpressure. Ships the 1.x
entry (opencode.mjs, main) and the shared 2.x adapter (opencode2.mjs,
exports["."]). Registry entry added. Released through the dist branch
until an owner does the first npm publish.

Reviewed head 62db17e93, merged onto main 6de02a0a. Run there (mote,
temporary HOME): bun test packages/warp 122 pass 0 fail; bun
scripts/check.mjs warp ok; whole repo bun test --timeout 60000 6371 pass
20 skip 0 fail; 2.x load via exports["."] with a fake context registers
both sign-in methods, the warp provider (11 models) and its sdk hook.
Broken by hand: exports -> index.mjs, _internal exported from main,
opencode2.mjs out of files, a one-byte drift in opencode2.mjs, and main
exporting no plugin each make check.mjs fail (the last also the entry
test). Earlier rounds (10-09/10-12, at 0ae2bc3, identical warp code)
broke backpressure, the refresh-token method and the Keychain hex decode
by hand and saw their tests fail.
Not tried: a real Warp account through OpenCode 2.x; Linux with a real
account.

Co-authored-by: guoqchen1001 <guoqchen1001@users.noreply.github.com>
2026-11-06 17:36:54 +08:00

20 lines
813 B
JavaScript

import { expect, test } from "bun:test"
import { readFileSync } from "node:fs"
import { join } from "node:path"
test("1.x entry exports plugin functions only", async () => {
const mod = await import("./opencode.mjs")
// WarpAuthPlugin should be a function (plugin)
expect(typeof mod.WarpAuthPlugin).toBe("function")
// No accidental non-function default export
expect(typeof mod.default === "undefined" || typeof mod.default === "function").toBe(true)
})
test("2.x entry default export has { id, setup }", async () => {
const mod = await import("./opencode2.mjs")
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"))
expect(typeof mod.default?.id).toBe("string")
expect(mod.default.id).toBe(pkg.name)
expect(typeof mod.default?.setup).toBe("function")
})