From 3ad0e49bafbaa649ed8896cb2ecd85c63d31ad1c Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 4 Oct 2026 13:25:12 +0800 Subject: [PATCH] =?UTF-8?q?cline=200.1.2:=20each=20model=20says=20the=20co?= =?UTF-8?q?ntext=20window=20Cline's=20catalog=20gives=20it,=20rather=20tha?= =?UTF-8?q?n=20none=20(Discord,=20ARNO=20on=20magpie=20v0.1.815:=20cline?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=9A=84=E6=A8=A1=E5=9E=8B=E9=83=BD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=BB=98=E8=AE=A4=E7=9A=84=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F)=20=E2=80=94=20configModel?= =?UTF-8?q?=20and=20runtimeModel=20wrote=20limit=20{context:=20m.context?= =?UTF-8?q?=20=3F=3F=200,=20output:=200}=20and=20nothing=20ever=20set=20m.?= =?UTF-8?q?context,=20so=20every=20Cline=20model=20came=20to=20magpie=20an?= =?UTF-8?q?d=20OpenCode=20with=20a=20window=20of=200.=20Cline's=20/api/v1/?= =?UTF-8?q?ai/cline/models=20(the=20cloud=20catalog=20the=20plugin=20alrea?= =?UTF-8?q?dy=20merges=20in)=20gives=20each=20entry=20OpenRouter's=20conte?= =?UTF-8?q?xt=5Flength=20and=20top=5Fprovider.{context=5Flength,=20max=5Fc?= =?UTF-8?q?ompletion=5Ftokens}:=20fetchCloudModels=20now=20keeps=20the=20w?= =?UTF-8?q?indow=20as=20context=20(tokens():=20a=20positive=20count,=20str?= =?UTF-8?q?ings=20read=20as=20numbers),=20and=20fetchFeed=20gives=20a=20re?= =?UTF-8?q?commended-feed=20model=20the=20catalog's=20window=20for=20its?= =?UTF-8?q?=20id,=20as=20the=20recommended=20feed=20has=20none.=20The=20re?= =?UTF-8?q?ply=20limit=20stays=200:=20max=5Fcompletion=5Ftokens=20can=20be?= =?UTF-8?q?=20most=20of=20the=20window=20(kimi-k3=20943718=20of=201048576)?= =?UTF-8?q?,=20and=20OpenCode=20keeps=20a=20model's=20output=20limit=20fre?= =?UTF-8?q?e=20of=20its=20window,=20so=20it=20would=20compact=20a=20tenth?= =?UTF-8?q?=20of=20the=20way=20in.=20The=20cline-free/=E2=80=A6=20and=20cl?= =?UTF-8?q?ine-pass/=E2=80=A6=20ids=20aren't=20in=20that=20catalog=20and?= =?UTF-8?q?=20still=20say=200;=20magpie=20takes=20models.dev's=20window=20?= =?UTF-8?q?for=20the=20id=20after=20the=20prefix=20there=20(README=20says?= =?UTF-8?q?=20so).=20index.test.mjs=20gains=20"the=20models=20hook=20gives?= =?UTF-8?q?=20each=20model=20the=20window=20Cline's=20catalog=20has=20for?= =?UTF-8?q?=20it,=20and=20no=20reply=20limit"=20(fails=20on=200.1.1);=20bu?= =?UTF-8?q?n=20test=20(59=20pass)=20and=20bun=20scripts/check.mjs=20cline?= =?UTF-8?q?=20under=20a=20temp=20HOME=20pass.=20Against=20the=20live=20api?= =?UTF-8?q?.cline.bot=20(no=20sign-in):=20466=20of=20484=20models=20now=20?= =?UTF-8?q?carry=20a=20window=20(claude-sonnet-5.5=201000000/128000,=20gpt?= =?UTF-8?q?-6.1-sol=201050000/128000,=20kimi-k3=201048576/943718=20as=20Cl?= =?UTF-8?q?ine=20gives=20it),=20cline-free/mimo-v2.6-flash=200.=20Not=20tr?= =?UTF-8?q?ied=20with=20a=20signed-in=20Cline=20account.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cline/README.md | 7 +++++++ packages/cline/index.mjs | 32 ++++++++++++++++++++++++++++---- packages/cline/index.test.mjs | 22 ++++++++++++++++++++++ packages/cline/package.json | 2 +- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/packages/cline/README.md b/packages/cline/README.md index 8df5cac..147f724 100644 --- a/packages/cline/README.md +++ b/packages/cline/README.md @@ -64,6 +64,13 @@ recommended list, Cline's own default (`anthropic/claude-sonnet-5`) among it. Cline's `clineCloud` group is left out, as Cline's own clients leave it out unless they opt in. +Each model's context window is the cloud catalog's (`context_length`). Its +reply limit is left unsaid: the catalog's `max_completion_tokens` can be most +of the window, and an agent keeps that much free for the reply. The `cline-free/…` +and `cline-pass/…` models aren't in that catalog, so they say none, and magpie +takes the window models.dev gives the model after the prefix +(`cline-free/mimo-v2.6-flash` is `mimo-v2.6-flash`). + - The **free** group (`cline-free/…`, `stealth/…`) costs nothing — the names say "(free)". They are gated on the client surface a request claims; the plugin claims what it is, and the gate takes it. If Cline ever narrows that diff --git a/packages/cline/index.mjs b/packages/cline/index.mjs index 191993e..f373695 100644 --- a/packages/cline/index.mjs +++ b/packages/cline/index.mjs @@ -412,10 +412,20 @@ async function fetchRecommended() { return parseFeed(env && typeof env === "object" && "data" in env ? env.data : env) } +// tokens is a positive whole count of tokens, or undefined +function tokens(...vs) { + for (const v of vs) { + const n = typeof v === "string" ? Number(v) : v + if (Number.isFinite(n) && n > 0) return Math.floor(n) + } + return undefined +} + // fetchCloudModels is Cline's whole cloud catalog, which its clients load // beside the recommended feed (loadCloudModels reads /ai/cline/models): the -// usage-billed models the recommended feed doesn't name. Entries carry an id -// and a display name. +// usage-billed models the recommended feed doesn't name. Entries carry an id, +// a display name and, OpenRouter's way, the window (context_length, or its +// top provider's). async function fetchCloudModels() { let res try { @@ -436,7 +446,12 @@ async function fetchCloudModels() { if (!id) return [] const given = firstOf(e.display_name, e.displayName, e.name) const last = id.split("/").pop() - return [{ id, name: given && given !== id && given !== last ? given : prettify(id), free: false, pass: id.startsWith("cline-pass/") }] + const context = tokens(e.context_length, e.top_provider?.context_length, e.context) + // the reply limit is left out: OpenRouter's max_completion_tokens can + // be most of the window (kimi-k3: 943718 of 1048576), and an agent + // keeps that much of the window free for the reply, so it would + // compact a tenth of the way in + return [{ id, name: given && given !== id && given !== last ? given : prettify(id), free: false, pass: id.startsWith("cline-pass/"), ...(context && { context }) }] }) } @@ -444,7 +459,13 @@ async function fetchCloudModels() { // recommended feed is required, the cloud catalog is what it adds. async function fetchFeed() { const [rec, cloud] = await Promise.all([fetchRecommended(), fetchCloudModels().catch(() => [])]) - const ms = [...rec] + // a recommended model takes the catalog's window for it: the recommended + // feed gives none + const sizes = new Map(cloud.map((m) => [m.id, m])) + const ms = rec.map((m) => { + const c = sizes.get(m.id) + return c?.context ? { ...m, context: c.context } : m + }) const seen = new Set(ms.map((m) => m.id)) for (const m of cloud) { if (seen.has(m.id)) continue @@ -470,6 +491,9 @@ const runtimeModel = (m) => ({ headers: {}, options: {}, cost: { input: 0, output: 0, cache: { read: 0, write: 0 } }, + // 0 where Cline's catalog doesn't list the model (its cline-free/… and + // cline-pass/… ids): magpie then gives the window models.dev has for the + // model after the prefix limit: { context: m.context ?? 0, output: 0 }, capabilities: { temperature: true, diff --git a/packages/cline/index.test.mjs b/packages/cline/index.test.mjs index e1f98e5..3cc2937 100644 --- a/packages/cline/index.test.mjs +++ b/packages/cline/index.test.mjs @@ -699,6 +699,28 @@ test("the models hook merges the cloud catalog with the recommended feed", async expect(out["cline-free/mimo-v2.6-flash"].name).toBe("MiMo V2.6 Flash (free)") }) +test("the models hook gives each model the window Cline's catalog has for it, and no reply limit", async () => { + const { client: c } = client() + const hooks = await ClinePlugin({ client: c }) + serve([ + ["/ai/cline/recommended-models", () => Response.json({ recommended: [{ id: "anthropic/claude-sonnet-5.5" }], free: [{ id: "cline-free/mimo-v2.6-flash" }] })], + ["/ai/cline/models", () => Response.json({ data: [ + { id: "anthropic/claude-sonnet-5.5", context: 0, context_length: 1000000, top_provider: { context_length: 1000000, max_completion_tokens: 128000 } }, + { id: "inclusionai/ling-3.1-flash", context_length: "262144", top_provider: { max_completion_tokens: 32768 } }, + { id: "only/top", top_provider: { context_length: 200000 } }, + { id: "no/size", context_length: null }, + ] })], + ]) + const out = await hooks.provider.models({ models: {} }) + expect(out["anthropic/claude-sonnet-5.5"].limit).toEqual({ context: 1000000, output: 0 }) + expect(out["inclusionai/ling-3.1-flash"].limit).toEqual({ context: 262144, output: 0 }) + expect(out["only/top"].limit).toEqual({ context: 200000, output: 0 }) + // one the catalog doesn't list, or lists without a size, says none: magpie + // gives it models.dev's for the model after its prefix + expect(out["cline-free/mimo-v2.6-flash"].limit).toEqual({ context: 0, output: 0 }) + expect(out["no/size"].limit).toEqual({ context: 0, output: 0 }) +}) + test("prettify reads a model id as a name", () => { expect(prettify("anthropic/claude-sonnet-5.5")).toBe("Claude Sonnet 5.5") expect(prettify("openai/gpt-6-astra")).toBe("GPT 6 Astra") diff --git a/packages/cline/package.json b/packages/cline/package.json index 69fe5f3..021de41 100644 --- a/packages/cline/package.json +++ b/packages/cline/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-cline-auth", - "version": "0.1.1", + "version": "0.1.2", "description": "Cline (cline.bot) on your own account — usage billing, ClinePass and the free models — in OpenCode and magpie", "type": "module", "main": "./index.mjs",