1// Wipe a day's play on a running server and restart it from the same2// field: POST /admin/reset/<date> with the push token.3//4// MOSAIC_PUSH_TOKEN=... deno task reset-day 2026-08-27 [--host https://mosaic-daily.fly.dev]5//6// The default host is the local dev server. The old log is kept as7// data/games/<game>.reset-<n>.jsonl; the day restarts at revision 0 with8// clean health for everyone.9const args = Object.fromEntries(10 Deno.args.map((a, i, all) =>11 a.startsWith("--") ? [a.slice(2), all[i + 1] ?? ""] : []12 ).filter((p) => p.length),13);14const date = Deno.args.find((a) => /^\d{4}-\d{2}-\d{2}$/.test(a));15if (!date) {16 console.error("usage: deno task reset-day <YYYY-MM-DD> [--host <url>]");17 Deno.exit(2);18}19const host = (args.host ?? "http://127.0.0.1:8000").replace(/\/$/, "");20const token = Deno.env.get("MOSAIC_PUSH_TOKEN");21if (!token) {22 console.error("MOSAIC_PUSH_TOKEN is not set");23 Deno.exit(2);24}25const res = await fetch(`${host}/admin/reset/${date}`, {26 method: "POST",27 headers: { Authorization: `Bearer ${token}` },28});29const body = await res.text();30console.log(`${res.status} ${body}`);31Deno.exit(res.ok ? 0 : 1);