cline 0.1.2: each model says the context window Cline's catalog gives it, rather than none (Discord, ARNO on magpie v0.1.815: cline插件的模型都没有默认的上下文窗口大小) — configModel and runtimeModel wrote limit {context: m.context ?? 0, output: 0} and nothing ever set m.context, so every Cline model came to magpie and OpenCode with a window of 0. Cline's /api/v1/ai/cline/models (the cloud catalog the plugin already merges in) gives each entry OpenRouter's context_length and top_provider.{context_length, max_completion_tokens}: fetchCloudModels now keeps the window as context (tokens(): a positive count, strings read as numbers), and fetchFeed gives a recommended-feed model the catalog's window for its id, as the recommended feed has none. The reply limit stays 0: max_completion_tokens can be most of the window (kimi-k3 943718 of 1048576), and OpenCode keeps a model's output limit free of its window, so it would compact a tenth of the way in. The cline-free/… and cline-pass/… ids aren't in that catalog and still say 0; magpie takes models.dev's window for the id after the prefix there (README says so). index.test.mjs gains "the models hook gives each model the window Cline's catalog has for it, and no reply limit" (fails on 0.1.1); bun test (59 pass) and bun scripts/check.mjs cline under a temp HOME pass. Against the live api.cline.bot (no sign-in): 466 of 484 models now carry a window (claude-sonnet-5.5 1000000/128000, gpt-6.1-sol 1050000/128000, kimi-k3 1048576/943718 as Cline gives it), cline-free/mimo-v2.6-flash 0. Not tried with a signed-in Cline account.

This commit is contained in:
yetone
2026-10-04 13:36:38 +08:00
parent 709e4dc79b
commit 3ad0e49baf
4 changed files with 58 additions and 5 deletions
+7
View File
@@ -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
+28 -4
View File
@@ -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,
+22
View File
@@ -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")
+1 -1
View File
@@ -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",