cursor 0.2.9: 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 (#55)

With the default on the branch without thinking (thinking=false, low to
high) and xhigh only with thinking, claude-opus-5-low asked at xhigh went
as the default's slug with effort=xhigh: an id and parameters at odds.
branch() returned early whenever what was asked differed from the default
in the effort alone.

Decided: that early return now holds only when no variant at all is named
for the effort asked, so claude-opus-5-5-xhigh (no xhigh variant
anywhere) still goes at xhigh as a listed model does, and an effort
another branch has makes the default's branch go to its nearest.

Run: the new test (the issue's picker, plus every id x effort x fast
agreeing with its parameters) fails on the old index.mjs and passes here;
HOME=$(mktemp -d) bun test for the repo, 1154 pass 0 fail; bun
scripts/check.mjs green. Not seen on a real account (as the issue says).
This commit is contained in:
yetone
2026-10-13 04:45:03 +08:00
parent 0e2a52efdc
commit 6579c01711
3 changed files with 35 additions and 5 deletions
+27
View File
@@ -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) }])
}
})
+7 -4
View File
@@ -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
}
+1 -1
View File
@@ -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",