// `umtool refresh` -- an article's Refresh from a terminal (plans/umtool- // redesign.md, R4; lib/articles/refresh.ts, lib/inbox/refresh.ts). Run by // bin/umtool.mjs through tsx, from umtool/ (the `@/` paths). // // umtool refresh
[--iteration N] [--no-fetch] [--yes] [--json] // the plan (the editor's dry run: the iteration refreshed, its queries, // each channel's fetches or why skipped, the site built, the model and // the cap); --yes starts it -- one editor job -- and prints where to // follow it // umtool refresh --check [
] [--force] [--json] // the daily suggestion check now: each active article's current report's // enumerations again (no fetch, no model), kept a day import { planArticleRefresh, startArticleRefresh } from "../lib/articles/refresh"; import { checkable, runRefreshChecks } from "../lib/inbox/refresh"; import { readLifecycle } from "../lib/lifecycle"; import { readMutes } from "../lib/mutes"; import { readPieceGraph } from "../lib/pieces"; const args = process.argv.slice(2); const has = (f: string) => args.includes(f); const val = (f: string) => { const i = args.indexOf(f); return i >= 0 ? args[i + 1] : undefined; }; const json = has("--json"); const positional = args.filter((a, i) => !a.startsWith("--") && args[i - 1] !== "--iteration"); const die = (msg: string): never => { console.error(`umtool refresh: ${msg}`); process.exit(1); }; if (has("--check")) { const [graph, life, mutes] = await Promise.all([readPieceGraph(), readLifecycle(), readMutes()]); const out = await runRefreshChecks(checkable(graph, life, mutes), { force: has("--force"), ...(positional[0] ? { only: positional[0] } : {}) }); if (json) { console.log(JSON.stringify(out, null, 2)); process.exit(0); } for (const c of out.checked) { console.log( c.status === "unchecked" ? `${c.article} i${c.iteration}: UNCHECKED — ${c.reason ?? c.error ?? "no corpus here holds its scope"}` : `${c.article} i${c.iteration}: ${c.newCount} new recording${c.newCount === 1 ? "" : "s"} since ${c.since.slice(0, 10)}${c.titles.length ? ` (${c.titles.join(", ")})` : ""}${c.partial ? ` — PARTIAL (${c.unreached?.length ? `not reached: ${c.unreached.join(", ")}` : "a cap was hit"})` : ""} · over ${c.corpus ?? c.source}`, ); } for (const s of out.skipped) console.log(`${s.article}: ${s.why}`); if (!out.checked.length && !out.skipped.length) console.log("no active article with a current report"); process.exit(0); } const article = positional[0]; if (!article) die("usage: umtool refresh
[--iteration N] [--no-fetch] [--yes] [--json] | umtool refresh --check [
] [--force]"); const iteration = val("--iteration") ? Number(val("--iteration")) : undefined; if (iteration !== undefined && !(Number.isInteger(iteration) && iteration > 0)) die("--iteration is an iteration number"); const o = { ...(iteration ? { iteration } : {}), ...(has("--no-fetch") ? { fetch: false } : {}) }; try { if (has("--yes")) { const r = await startArticleRefresh(article!, o); if (json) console.log(JSON.stringify(r, null, 2)); else console.log(`${article} i${r.iteration}: the refresh is running (job ${r.jobId}) — ${r.href}`); process.exit(0); } const p = await planArticleRefresh(article!, o); if (json) { console.log(JSON.stringify(p, null, 2)); process.exit(0); } console.log(`# Refresh ${p.article} — i${p.parent.n} (${p.parent.kind}, made ${p.parent.at.slice(0, 10)})`); if (p.parent.question) console.log(` question ${p.parent.question}`); console.log(` searched ${p.parent.queries.map((q) => `"${q}"`).join(", ")} (from its ${p.parent.from}; ${p.parent.knownCount} matched then, ${p.parent.citedCount} cited quotes read again)`); if (!p.fetch) console.log(" fetch none: the corpus is read as it stands"); for (const c of p.channels) console.log(` fetch ${c.slug}${c.platform ? ` (${c.platform})` : ""}: ${c.skip ? `skipped — ${c.skip}` : c.actions.join(" → ")}`); console.log(` build ${p.build.site ? `${p.build.site}, locally (never deployed)` : (p.build.reason ?? "none")}`); console.log( ` update ${p.model}${p.capUsd !== null ? `, up to $${p.capUsd.toFixed(2)}` : " (local, no cap)"} — about $${p.estimate.perRecordingUsd.toFixed(2)} a new recording + $${p.estimate.revisionUsd.toFixed(2)}, only when something changed` + (p.daily ? `; today $${p.daily.usd.toFixed(2)} of $${p.daily.cap.toFixed(2)}` : ""), ); for (const w of p.warnings) console.log(` note ${w}`); for (const r of p.refusals) console.log(` REFUSED ${r}`); console.log(p.refusals.length ? "\nNothing was started." : `\nNothing was started. \`umtool refresh ${article}${iteration ? ` --iteration ${iteration}` : ""}${has("--no-fetch") ? " --no-fetch" : ""} --yes\` runs it.`); process.exit(p.refusals.length ? 1 : 0); } catch (e) { die((e as Error).message); }