diff --git a/packages/cursor/context.test.mjs b/packages/cursor/context.test.mjs index dc5366f..1ac13f5 100644 --- a/packages/cursor/context.test.mjs +++ b/packages/cursor/context.test.mjs @@ -257,3 +257,30 @@ test("an id of Cursor's own at an effort its branch hasn't goes as that branch's expect([id, effort, fast, params]).toEqual([id, effort, fast, { ...params, ...slug.get(sent) }]) } }) + +// #55: the same picker with the default on the branch without thinking +// (claude-opus-5-high). An id of that branch asked at an effort only the +// other has went as the default's id with the effort asked. +test("when the default's own branch stops short, an id of it asked past that goes as its nearest, not the default's id at the effort asked", async () => { + const OFF = { ...OPUS5, variants: OPUS5.variants.map((x) => { + const { isDefaultNonMaxConfig, ...rest } = x + return rest.legacySlug === "claude-opus-5-high" ? { ...rest, isDefaultNonMaxConfig: true } : rest + }) } + fakeAPI([OFF]) + const raw = await usable(tok()) + const q = (id, effort = "", fast) => { + const r = request(raw, id, effort, fast) + return [r.id, r.maxMode, Object.fromEntries(r.params.map((x) => [x.id, x.value]))] + } + expect(q("claude-opus-5-low", "xhigh")).toEqual(["claude-opus-5-high", false, { thinking: "false", context: "300k", effort: "high", fast: "false" }]) + expect(q("claude-opus-5-medium", "max")).toEqual(["claude-opus-5-high", false, { thinking: "false", context: "300k", effort: "high", fast: "false" }]) + expect(q("claude-opus-5-low", "medium")[0]).toBe("claude-opus-5-medium") + expect(q("claude-opus-5-thinking-low", "max")[0]).toBe("claude-opus-5-thinking-max") + const slug = new Map(OFF.variants.map((x) => [x.legacySlug, Object.fromEntries(x.parameterValues.map((p) => [p.id, p.value]))])) + for (const id of [...slug.keys(), "claude-opus-5", "claude-opus-5-fast", "claude-opus-5-thinking", "claude-opus-5-thinking-fast"]) + for (const effort of ["", "none", "low", "medium", "high", "xhigh", "max"]) + for (const fast of [undefined, true]) { + const [sent, , params] = q(id, effort, fast) + expect([id, effort, fast, params]).toEqual([id, effort, fast, { ...params, ...slug.get(sent) }]) + } +}) diff --git a/packages/cursor/index.mjs b/packages/cursor/index.mjs index 0e914ce..85917cf 100644 --- a/packages/cursor/index.mjs +++ b/packages/cursor/index.mjs @@ -723,17 +723,20 @@ function pick(entry, effort, fast, seed) { // without thinking stops at high), the variant with those parameters at the // nearest effort it has, not the default's id with parameters that // contradict it (claude-opus-5-thinking-high with thinking=false). Where -// the default differs from what is asked in the effort alone, the effort -// goes as asked, as for a listed model. +// the default differs from what is asked in the effort alone, and no +// variant at all is named for that effort, the effort goes as asked, as for +// a listed model (claude-opus-5-5-xhigh). When another branch has it, the +// default's own branch stops short there, and its nearest goes (#55). function branch(entry, want) { if (!entry.pid || entry.pid === "thinking") return undefined + const level = (x) => (x === "extra-high" ? "xhigh" : x) const def = valuesOf(entry.def) - if (Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined + const named = entry.variants.some((v) => level(valuesOf(v)[entry.pid]) === level(want[entry.pid])) + if (!named && Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined const vs = entry.variants.filter((v) => { const have = valuesOf(v) return entry.pid in have && Object.keys(want).every((k) => k === entry.pid || have[k] === undefined || have[k] === want[k]) }) - const level = (x) => (x === "extra-high" ? "xhigh" : x) const at = fitEffort(level(want[entry.pid]), vs.map((v) => level(valuesOf(v)[entry.pid]))) return at ? vs.find((v) => level(valuesOf(v)[entry.pid]) === at) : undefined } diff --git a/packages/cursor/package.json b/packages/cursor/package.json index 1162364..d8b35b0 100644 --- a/packages/cursor/package.json +++ b/packages/cursor/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-cursor-auth", - "version": "0.2.8", + "version": "0.2.9", "description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to", "type": "module", "main": "./index.mjs",