feat(models-dev): 高级设置新增 models.dev 在线同步 — 上下文/能力/单价即时生效 + 一键恢复内置;修复 public 快照构建漂移;确认适配 kimi-code 2.1.0 — bump to v0.7.21
Release / Version consistency (push) Canceled after 0s
Release / Build (macos-latest) (push) Canceled after 0s
Release / Build (ubuntu-latest) (push) Canceled after 0s
Release / Build (windows-latest) (push) Canceled after 0s
Release / Attach macOS install script (push) Canceled after 0s

This commit is contained in:
KimiSwitch Dev committed 2026-09-24 00:19:10 +08:00
1 parent 26e783c2ba
commit 11286419b1
17 files changed
+282395 -267694

No files matched your search

+16 -3
View File
@@ -1,9 +1,17 @@
#!/usr/bin/env node
/**
* Fetch the latest model reference data from models.dev and write:
* 1. src/lib/models-dev.json — compact per-model snapshot (frontend)
* 2. src/lib/models-dev-full.json — provider-grouped full list incl. pricing
* 3. src/lib/models-dev.last-good.json — local backup of the last success
* 1. src/lib/models-dev.json — compact per-model snapshot; embedded
* into the Rust binary by dashboard.rs
* (include_str!) and loaded by the
* frontend as fallback
* 2. public/models-dev.json — the same snapshot as a static asset;
* this is what the frontend actually
* serves at runtime (must stay in sync
* with #1 — they serve different halves
* of the app)
* 3. src/lib/models-dev-full.json — provider-grouped full list incl. pricing
* 4. src/lib/models-dev.last-good.json — local backup of the last success
*
* The data source is https://models.dev/api.json (176 providers; each model
* carries `cost` = { input, output, cache_read?, cache_write? } in $/M tokens).
@@ -63,6 +71,8 @@ if (proxy && process.env.NODE_USE_ENV_PROXY !== "1") {
const SOURCE_URL = "https://models.dev/api.json";
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
const SNAPSHOT = join(ROOT, "src", "lib", "models-dev.json");
// Static-asset copy served to the frontend (see header — must equal SNAPSHOT).
const SNAPSHOT_PUBLIC = join(ROOT, "public", "models-dev.json");
const FULL = join(ROOT, "src", "lib", "models-dev-full.json");
// Local backup of the last successful snapshot. Not committed to git (see
// .gitignore); the committed models-dev.json itself is the versioned fallback.
@@ -168,12 +178,15 @@ async function main() {
}
await mkdir(dirname(SNAPSHOT), { recursive: true });
await mkdir(dirname(SNAPSHOT_PUBLIC), { recursive: true });
const json = JSON.stringify(snapshot, null, 2) + "\n";
await writeFile(SNAPSHOT, json, "utf8");
await writeFile(SNAPSHOT_PUBLIC, json, "utf8");
await writeFile(FULL, JSON.stringify(full, null, 2) + "\n", "utf8");
await writeFile(BACKUP, json, "utf8");
console.log(`models.dev snapshot: ${modelCount} models -> ${SNAPSHOT}`);
console.log(`models.dev static asset: -> ${SNAPSHOT_PUBLIC}`);
console.log(
`models.dev full list: ${Object.keys(full.providers).length} providers -> ${FULL}`,
);