Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1023 B
Raw Blame
#!/usr/bin/env node
// STRICT gate: KNOWN_MODEL_PRICING must have been touched within PRICING_STALE_AFTER_DAYS,
// or tiers silently drift from real prices. Exits 1 on stale, 0 on fresh.
// Run: node scripts/check/check-pricing-freshness.mjs
import { execFileSync } from "node:child_process";

const PRICING_STALE_AFTER_DAYS = 90;
const TARGET = "open-sse/services/providerCostData.ts";

function lastTouchDays() {
  const out = execFileSync("git", ["log", "--follow", "-1", "--format=%ct", "--", TARGET], {
    encoding: "utf8",
  }).trim();
  const touched = Number(out);
  if (!Number.isFinite(touched) || touched <= 0) return Infinity;
  return (Date.now() / 1000 - touched) / 86400;
}

const days = lastTouchDays();
if (days > PRICING_STALE_AFTER_DAYS) {
  console.error(
    `STALE: ${TARGET} untouched for ${Math.floor(days)}d (> ${PRICING_STALE_AFTER_DAYS}d) — refresh prices or bump the gate with justification`
  );
  process.exit(1);
}
console.log(`pricing fresh: ${TARGET} touched ${Math.floor(days)}d ago`);