refactor: use friendly model ids globally

Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-08-31 16:29:52 +00:00
co-authored by Simon Shi
parent ca17a95270
commit aaac381d76
6 changed files with 125 additions and 83 deletions
+8 -8
View File
@@ -14,7 +14,7 @@ import {
getQoderUserEmailFallback,
getQoderUserInfoURL,
isQoderCNMode,
toQoderCNModelId,
toQoderModelId,
} from "../cosy.js";
// ── getQoderMode ──────────────────────────────────────────────────────────
@@ -159,24 +159,24 @@ describe("getQoderUserEmailFallback", () => {
});
});
// ── toQoderCNModelId ──────────────────────────────────────────────────────
// ── toQoderModelId ────────────────────────────────────────────────────────
describe("toQoderCNModelId", () => {
describe("toQoderModelId", () => {
it("strips whitespace from the upstream display_name", () => {
// The display name is used directly as the pi-visible model id, with
// whitespace removed so it stays a clean token for persistence keys and
// search. "Qwen3.8-Flash" has no spaces already.
expect(toQoderCNModelId("Qwen3.8-Flash")).toBe("Qwen3.8-Flash");
expect(toQoderModelId("Qwen3.8-Flash")).toBe("Qwen3.8-Flash");
});
it("collapses internal spaces", () => {
expect(toQoderCNModelId("Qwen 3.8 Max")).toBe("Qwen3.8Max");
expect(toQoderCNModelId("DeepSeek V4 Pro")).toBe("DeepSeekV4Pro");
expect(toQoderModelId("Qwen 3.8 Max")).toBe("Qwen3.8Max");
expect(toQoderModelId("DeepSeek V4 Pro")).toBe("DeepSeekV4Pro");
});
it("falls back to a default when no display name is given", () => {
expect(toQoderCNModelId()).toBe("QoderCNModel");
expect(toQoderCNModelId("")).toBe("QoderCNModel");
expect(toQoderModelId()).toBe("QoderModel");
expect(toQoderModelId("")).toBe("QoderModel");
});
});
+12 -5
View File
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import {
contextWindowFromCatalog,
DEFAULT_CONTEXT_WINDOW,
getCachedModelConfig,
staticCnModels,
staticModels,
ZERO_COST,
@@ -16,7 +17,7 @@ describe("staticModels", () => {
});
it("has auto as first entry", () => {
expect(staticModels[0].id).toBe("auto");
expect(staticModels[0].id).toBe("Auto");
});
it("every model has required fields", () => {
@@ -43,16 +44,22 @@ describe("staticModels", () => {
it("uses a 1M context window for models confirmed to support it", () => {
// Global lite was live-tested through 1,000K tokens (issue #13). auto,
// efficient, and gm51model share the same Qoder 1M catalog family.
for (const id of ["auto", "efficient", "lite", "gm51model"]) {
const model = staticModels.find((m) => m.id === id);
expect(model, id).toBeDefined();
for (const key of ["auto", "efficient", "lite", "gm51model"]) {
const model = staticModels.find((m) => m.upstreamKey === key);
expect(model, key).toBeDefined();
expect(model?.contextWindow).toBe(DEFAULT_CONTEXT_WINDOW);
expect(model?.contextWindow).toBe(1_000_000);
}
});
it("keeps kmodel at the catalog-advertised 256K window", () => {
expect(staticModels.find((m) => m.id === "kmodel")?.contextWindow).toBe(256000);
expect(staticModels.find((m) => m.upstreamKey === "kmodel")?.contextWindow).toBe(256000);
});
it("maps friendly ids and legacy keys to the same static upstream key", () => {
expect(getCachedModelConfig("Lite", "global")?.key).toBe("lite");
expect(getCachedModelConfig("lite", "global")?.key).toBe("lite");
expect(getCachedModelConfig("Qwen3.8-Max", "global")?.key).toBe("qmodel_preview");
});
});