commit 7e487af1f114a0b93f6ee03ba846e9b999df708d
parent 4663c3160e50cada0cab3e111e9dc2398dea3e6f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 17:04:09 -0400
common: reports import-sweep — a report made in Claude Code becomes the article's next iteration
A task routed to `code` runs in a Claude Code session, which writes its
report to a file; only the editor's API and local report-draft jobs made
iterations, so the only door into the registry was the release-27 one-off
import-local-runs (which labels the result as the retired stopgap's).
`archilyzer reports import-sweep <report.json> --article <id> --question …`
writes the next iteration through the iterations store: kind sweep, done,
$0, the question, channels and minutes, `imported {from, at, report}`; the
report's id set to the article's and its audience dropped; refused unless it
parses as a report; never made current. A dry run unless --apply.
Tests (temp corpus), COMMANDS.md regenerated, an OPERATING.md line.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 342 insertions(+), 0 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -38,6 +38,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer reports delete` | `<articleId> [--iteration <n>] [--apply] [--force] [--json]` | delete an article — its directory (report, video, history, notes, iterations), its iterations' video projects under settings.generation.projectsRoot and its staged exports — or, with --iteration, one iteration and its project, through the article registry. A dry run printing the plan (every path with its size, what is kept and why, what refuses) unless --apply. Refused: a published article, or a site page naming it with no report of its own (--force unpublishes it and drops the page first); a queued or running iteration; an iteration that is current (article, its report's source, video) or that another revises or copies (exit 1 when refused; 2 for no such article or iteration) |
| `archilyzer reports bench-verdicts` | `--models <a,b,…> [--report <id,…>] [--window <s>] [--window-mode seconds\|turn] [--max-usd <n>] [--limit <n>] [--items-from <run>] [--run <id>] [--dry] [--here] [--wait] [--json]` | the verdict bench (release 28; release 29 V1): every claim of the registry's fact-checks (or of --report) with the operator's verdict and a citation with cues, asked of each model one claim per call — the report's title, the claim's section, the claim, its quotes (their speaker and the recording's date) and the transcript within --window seconds (default 60) of each cited span, or with --window-mode turn the cited speaker's turn bounded by --window, never the findings or the verdict — and scored against the rulings (agreement, the confusion matrix, CONTRADICTED and NOT\_FOUND recall, not-CORROBORATED precision and recall, against an always-CORROBORATED baseline). --limit takes a stratified sample (by the operator's verdict: every verdict kept); --items-from takes an earlier run's exact items (no --report, --window, --window-mode or --limit with it). The run records its prompt version and its items' hash. --dry lists the items, the skipped claims and the dropped citations and estimates the cost, asking nothing. Otherwise through the editor (`pnpm ops bench-verdicts`; a local model through the GPU arbiter; --wait follows the job), or --here in this process for API models only. The run stops at --max-usd (default 5, the whole run); a --run that exists continues with this invocation's --models only (refused under another prompt version). Results stay local, in .generation/bench/verdicts/<run>/ (umtool's /tools/bench) (exit 1 when the run stopped early or was refused; 2 for usage) |
| `archilyzer reports import-local-runs` | `[--apply] [--runs <dir>] [--only <run,…>] [--move-projects] [--generation <file>]` | ONE-OFF (release 27): the stopgap's kept runs (--runs: its directory, default ~/reports/local-reports; --only: those runs, default piratesoftware-ai-friends and api-shondo-recent) become i1 of their article through the iterations store — made current only when the run's report.json is the article's; a run with no article becomes an article in the making — and each video project is copied (--move-projects: moved) to the generation projects root; ~/.config/archilyzer/generation.json, when there is one, becomes settings.generation's routes and models. Lists the stopgap's test runs, projects and drafts to delete after the operator's OK (deletes nothing). A dry run printing the plan unless --apply (exit 1 when a run is refused) |
+| `archilyzer reports import-sweep` | `<report.json> --article <id> --question <question> [--sweep <sweep.md>] [--channels <a,b>] [--model <m>] [--from <where>] [--minutes <n>] [--apply]` | a report made outside the editor's report-draft jobs (a Claude Code session's /sweep, a task routed to code) becomes the next iteration of its article through the iterations store: kind sweep, status done, $0, its question, channels and minutes, `imported` naming where it came from (--from, default claude-code; --model default claude-code); its report.json the file given (id set to the article's, audience dropped), refused unless it parses as a report; never made current (umtool's Iterations tab, or `umtool chain <id> <n>`); a new id makes an article in the making. A dry run printing the plan unless --apply (exit 1 when refused; 2 for usage) |
| `archilyzer gen policy` | `[--json]` | the generation policy: where each task runs (code = Claude Code, api = the Claude API, local = the local model), the models, the caps and the day's Claude API spend — from the editor, or settings.json when none answers |
| `archilyzer gen preset` | `<code\|balanced\|api\|local>` | route every generation task by a preset (its routes are written; settings.generation.routes) |
| `archilyzer gen set` | `<task> <code\|api\|local>` | route one generation task (sweep, revise-report, revise-video, research; the media drafts cut, onscreen, teaser, flips, threads, narrate, youtube, social) |
diff --git a/OPERATING.md b/OPERATING.md
@@ -248,6 +248,10 @@ pnpm ops get generation-usage
- `gen run` exits 3 and runs nothing for a task routed to `code`. In Claude Code, `/gen` and the MCP's `generate`
run a routed task through the editor and review what it made; `generation_policy` reads the policy and moves it
when you ask. `/sweep` follows the policy too.
+- A report made in Claude Code (a task routed to `code`) enters the registry as the article's next iteration with
+ `pnpm archilyzer reports import-sweep <report.json> --article <id> --question "…" [--sweep sweep.md] [--channels a,b]
+ [--model m] [--minutes n] --apply` (a dry run without `--apply`): kind sweep, done, $0, `imported` naming where it
+ came from; never made current — **Use this iteration** in umtool, or `umtool chain <id> <n>`.
- **Caps (USD, Claude API only):** a job's `maxUsd`, else $5 a sweep or research run, $2 a revision, $1 a narration;
never above `caps.max` ($10). The editor refuses a job once the day's API spend (UTC) reaches `caps.daily` ($20),
naming the day's total; a job already running stops at its own cap. The ledger is `.generation/usage.jsonl` in
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -427,6 +427,15 @@ export const COMMANDS: Command[] = [
flags: { apply: "boolean", runs: "string", only: "string", "move-projects": "boolean", generation: "string" },
run: async ({ flags }) => (await import("./reports-import-local-runs")).importRow(flags as Parameters<typeof import("./reports-import-local-runs").importRow>[0]),
},
+ {
+ path: ["reports", "import-sweep"],
+ usage:
+ "<report.json> --article <id> --question <question> [--sweep <sweep.md>] [--channels <a,b>] [--model <m>] [--from <where>] [--minutes <n>] [--apply] a report made outside the editor's report-draft jobs (a Claude Code session's /sweep, a task routed to code) becomes the next iteration of its article through the iterations store: kind sweep, status done, $0, its question, channels and minutes, `imported` naming where it came from (--from, default claude-code; --model default claude-code); its report.json the file given (id set to the article's, audience dropped), refused unless it parses as a report; never made current (umtool's Iterations tab, or `umtool chain <id> <n>`); a new id makes an article in the making. A dry run printing the plan unless --apply (exit 1 when refused; 2 for usage)",
+ flags: { article: "string", question: "string", sweep: "string", channels: "string", model: "string", from: "string", minutes: "string", apply: "boolean" },
+ maxPositionals: 1,
+ run: async ({ positionals, flags }) =>
+ (await import("./reports-import-sweep")).importSweepRow(positionals[0], flags as Parameters<typeof import("./reports-import-sweep").importSweepRow>[1]),
+ },
// The generation balance (release 27 S9; bin/gen.ts): settings.generation
// through the editor's ops API, or settings.json when no editor answers.
{
diff --git a/common/bin/reports-import-sweep.test.ts b/common/bin/reports-import-sweep.test.ts
@@ -0,0 +1,130 @@
+// `archilyzer reports import-sweep`: a report made outside the editor's
+// report-draft jobs becomes the next iteration of its article, a dry run by
+// default. A temp corpus only — never the real store.
+//
+// Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test bin/reports-import-sweep.test.ts
+
+import { after, test } from "node:test";
+import assert from "node:assert/strict";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const ROOT = mkdtempSync(path.join(tmpdir(), "import-sweep-"));
+Object.assign(process.env, {
+ TRANSCRIPTS_DIR: path.join(ROOT, "transcripts"),
+ SITES_DIR: path.join(ROOT, "transcripts", "sites"),
+ SETTINGS_FILE: path.join(ROOT, "settings.json"),
+ EXPORT_INDEX_DIR: path.join(ROOT, ".export-index"),
+});
+after(() => rmSync(ROOT, { recursive: true, force: true }));
+
+const { getPaths } = await import("../lib/paths");
+const { writeArticle } = await import("../lib/report/registry");
+const { currentIteration, readIteration, readIterationFile } = await import("../lib/report/iterations");
+const imp = await import("./reports-import-sweep");
+
+const paths = getPaths();
+const KIT = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "testing", "draft");
+const BASIC = JSON.parse(readFileSync(path.join(KIT, "reports", "basic.report.json"), "utf8")) as Record<string, unknown>;
+const SWEEP = readFileSync(path.join(KIT, "sweeps", "basic.md"), "utf8");
+const IN = path.join(ROOT, "in");
+mkdirSync(IN, { recursive: true });
+const reportFile = path.join(IN, "report.json");
+writeFileSync(reportFile, JSON.stringify({ ...BASIC, id: "some-other-id", audience: "public" }));
+const sweepFile = path.join(IN, "sweep.md");
+writeFileSync(sweepFile, SWEEP);
+
+const silent = () => {
+ const lines: string[] = [];
+ return { lines, out: { log: (s: string) => lines.push(s), error: (s: string) => lines.push(s) } };
+};
+const base = { reportFile, question: "What does the baker say about the bakery?", paths } as const;
+
+test("a dry run plans the next iteration and writes nothing", async () => {
+ const { lines, out } = silent();
+ const code = await imp.importSweepMain({ ...base, article: "baker-sweep", sweepFile, channels: ["synth-kitchen"], apply: false }, out);
+ assert.equal(code, 0);
+ assert.match(lines.join("\n"), /DRY RUN/);
+ assert.match(lines.join("\n"), /i1 of "baker-sweep", a NEW article in the making/);
+ assert.match(lines.join("\n"), /its id "some-other-id" becomes "baker-sweep"/);
+ assert.equal(existsSync(path.join(paths.articlesDir, "baker-sweep")), false);
+});
+
+test("apply writes a done sweep iteration, id set, audience dropped, provenance named, never current", async () => {
+ const { out } = silent();
+ const code = await imp.importSweepMain(
+ { ...base, article: "baker-sweep", sweepFile, channels: ["synth-kitchen"], minutes: 42, model: "claude-opus (Claude Code)", apply: true, now: () => new Date("2026-10-15T12:00:00Z") },
+ out,
+ );
+ assert.equal(code, 0);
+ const it = await readIteration("baker-sweep", 1, paths);
+ assert.ok(it);
+ assert.equal(it.kind, "sweep");
+ assert.equal(it.status, "done");
+ assert.equal(it.model, "claude-opus (Claude Code)");
+ assert.equal(it.question, "What does the baker say about the bakery?");
+ assert.deepEqual(it.scope?.channels, ["synth-kitchen"]);
+ assert.equal(it.minutes, 42);
+ assert.deepEqual((it as Record<string, unknown>).imported, { from: "claude-code", at: "2026-10-15T12:00:00.000Z", report: "report.json" });
+ const report = JSON.parse((await readIterationFile("baker-sweep", 1, "report.json", paths)) ?? "{}");
+ assert.equal(report.id, "baker-sweep");
+ assert.equal(report.audience, undefined);
+ assert.equal(await readIterationFile("baker-sweep", 1, "sweep.md", paths), SWEEP);
+ // Never made current: an article in the making stays one.
+ assert.equal((await currentIteration("baker-sweep", paths)).report, null);
+ assert.equal(existsSync(path.join(paths.articlesDir, "baker-sweep", "report.json")), false);
+});
+
+test("a second import is the next iteration", async () => {
+ const { lines, out } = silent();
+ assert.equal(await imp.importSweepMain({ ...base, article: "baker-sweep", apply: true }, out), 0);
+ assert.match(lines.join("\n"), /i2 of "baker-sweep"/);
+ const it = await readIteration("baker-sweep", 2, paths);
+ assert.equal(it?.model, imp.DEFAULT_IMPORT_MODEL);
+ assert.equal(await readIterationFile("baker-sweep", 2, "sweep.md", paths), null);
+});
+
+test("an article the registry has gets an iteration; its report is untouched", async () => {
+ await writeArticle({ ...BASIC, id: "baker-live" }, { paths });
+ const before = readFileSync(path.join(paths.articlesDir, "baker-live", "report.json"), "utf8");
+ const { lines, out } = silent();
+ assert.equal(await imp.importSweepMain({ ...base, article: "baker-live", apply: true }, out), 0);
+ assert.match(lines.join("\n"), /an article the registry has \(it is NOT made current\)/);
+ assert.ok(await readIteration("baker-live", 1, paths));
+ assert.equal(readFileSync(path.join(paths.articlesDir, "baker-live", "report.json"), "utf8"), before);
+});
+
+test("refusals: a bad id, no question, a bad channel, a missing file, a report that does not parse", async () => {
+ const cases: [Partial<Parameters<typeof imp.importSweepMain>[0]>, RegExp][] = [
+ [{ article: "Not An Id" }, /is not an article id/],
+ [{ article: "new" }, /is not an article id/],
+ [{ article: "baker-x", question: " " }, /names its question/],
+ [{ article: "baker-x", channels: ["bad slug!"] }, /is not a channel slug/],
+ [{ article: "baker-x", reportFile: path.join(IN, "nope.json") }, /no such file/],
+ [{ article: "baker-x", sweepFile: path.join(IN, "nope.md") }, /no such file/],
+ ];
+ const notReport = path.join(IN, "not-a-report.json");
+ writeFileSync(notReport, JSON.stringify({ format: "archilyzer-report", version: 1, title: "x" }));
+ cases.push([{ article: "baker-x", reportFile: notReport }, /does not parse/]);
+ for (const [o, why] of cases) {
+ const { lines, out } = silent();
+ const code = await imp.importSweepMain({ ...base, apply: true, ...o } as Parameters<typeof imp.importSweepMain>[0], out);
+ assert.equal(code, 1, JSON.stringify(o));
+ assert.match(lines.join("\n"), why);
+ }
+ assert.equal(existsSync(path.join(paths.articlesDir, "baker-x")), false);
+});
+
+test("the CLI row: usage errors exit 2", async () => {
+ const err = console.error;
+ console.error = () => {};
+ try {
+ assert.equal(await imp.importSweepRow(undefined, { article: "a", question: "q" }), 2);
+ assert.equal(await imp.importSweepRow(reportFile, { question: "q" }), 2);
+ assert.equal(await imp.importSweepRow(reportFile, { article: "a", question: "q", minutes: "soon" }), 2);
+ } finally {
+ console.error = err;
+ }
+});
diff --git a/common/bin/reports-import-sweep.ts b/common/bin/reports-import-sweep.ts
@@ -0,0 +1,198 @@
+// `archilyzer reports import-sweep <report.json> --article <id> --question <q>
+// [--sweep <sweep.md>] [--channels <a,b>] [--model <m>] [--minutes <n>] [--apply]`
+// — a report made OUTSIDE the editor's report-draft jobs (a Claude Code
+// session's /sweep, a hand-run research pass) becomes the next ITERATION of its
+// article, through the iterations store (lib/report/iterations.ts), never by
+// hand. A DRY RUN unless `--apply`: it prints what it would do and writes
+// nothing.
+//
+// Why: a task routed to `code` (settings.generation) runs in Claude Code, which
+// writes its report to a file; only the editor's API and local jobs made
+// iterations. Without this the only path into the registry was the release-27
+// one-off `import-local-runs`, which labels the result as the retired
+// stopgap's. This is the general door, and it says where the iteration came
+// from: `imported: { from: "claude-code" | <--from>, at, report }`.
+//
+// The iteration is kind `sweep`, status `done`, `$0` (a Claude Code session is
+// not billed through the generation ledger), with the question, the channels
+// and the minutes given. Its report.json is the file given, its `id` set to the
+// article's and its `audience` dropped (the registry's alone); it must parse as
+// a report. It is NEVER made current: the operator chooses it in umtool
+// ("Use this iteration") or `umtool chain <id> <n>` makes it current as its
+// first step. A new article id makes an article in the making.
+//
+// Exit 0 when the plan is sound (dry run) or the iteration is written (apply);
+// 1 when it is refused; 2 for a usage error.
+
+import { readFile } from "node:fs/promises";
+import path from "node:path";
+import type { Paths } from "../lib/paths";
+import { createIteration, iterationLabel, readIterations, updateIteration, writeIterationFile } from "../lib/report/iterations";
+import { RESERVED_ARTICLE_IDS, readArticleState } from "../lib/report/registry";
+import { isReportId } from "../lib/report/schema";
+import { parseReport } from "../lib/report/validate";
+
+type StorePaths = Pick<Paths, "articlesDir" | "exportIndexDir">;
+type Out = { log: (s: string) => void; error: (s: string) => void };
+
+export type ImportSweepOptions = {
+ reportFile: string;
+ article: string;
+ question: string;
+ sweepFile?: string;
+ channels?: string[];
+ model?: string;
+ from?: string;
+ minutes?: number;
+ apply: boolean;
+ paths: StorePaths;
+ now?: () => Date;
+};
+
+export type ImportSweepPlan =
+ | { ok: false; refused: string }
+ | {
+ ok: true;
+ article: string;
+ articleExists: boolean;
+ nextLabel: string;
+ report: Record<string, unknown>;
+ reportIdWas?: string;
+ problems: string[];
+ sweepMd?: string;
+ model: string;
+ from: string;
+ channels: string[];
+ };
+
+export const DEFAULT_IMPORT_MODEL = "claude-code";
+const CHANNEL_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
+
+const obj = (v: unknown): Record<string, unknown> => (v && typeof v === "object" && !Array.isArray(v) ? (v as Record<string, unknown>) : {});
+
+export async function planImportSweep(o: ImportSweepOptions): Promise<ImportSweepPlan> {
+ const refuse = (refused: string): ImportSweepPlan => ({ ok: false, refused });
+ const article = o.article.trim();
+ if (!isReportId(article) || RESERVED_ARTICLE_IDS.includes(article)) return refuse(`"${article}" is not an article id`);
+ if (!o.question.trim()) return refuse("an imported sweep names its question (--question)");
+ const channels = (o.channels ?? []).map((c) => c.trim()).filter(Boolean);
+ const badChannel = channels.find((c) => !CHANNEL_RE.test(c));
+ if (badChannel) return refuse(`"${badChannel}" is not a channel slug`);
+
+ let raw: unknown;
+ try {
+ raw = JSON.parse(await readFile(o.reportFile, "utf8"));
+ } catch (err) {
+ return refuse(`${o.reportFile}: ${(err as NodeJS.ErrnoException).code === "ENOENT" ? "no such file" : "not JSON"}`);
+ }
+ const report = { ...obj(raw) };
+ const wasId = typeof report.id === "string" ? report.id : undefined;
+ report.id = article;
+ // An iteration's report never carries an audience: the registry's alone.
+ delete report.audience;
+ const parsed = parseReport(report, { id: article });
+ if (!parsed.ok) {
+ return refuse(`the report does not parse: ${parsed.problems.slice(0, 3).map((p) => `${p.path || "(root)"}: ${p.message}`).join("; ")}`);
+ }
+
+ let sweepMd: string | undefined;
+ if (o.sweepFile) {
+ try {
+ sweepMd = await readFile(o.sweepFile, "utf8");
+ } catch {
+ return refuse(`${o.sweepFile}: no such file`);
+ }
+ }
+
+ const its = await readIterations(article, o.paths).catch(() => null);
+ if (its?.problems.length) return refuse(`"${article}" has unsound iterations (${its.problems.map((p) => iterationLabel(p.n)).join(", ")}); fix them first`);
+ const highest = Math.max(0, ...(its?.iterations ?? []).map((i) => i.n), its?.current?.highest ?? 0);
+ const state = await readArticleState(article, o.paths);
+
+ return {
+ ok: true,
+ article,
+ articleExists: state?.exists === true,
+ nextLabel: iterationLabel(highest + 1),
+ report,
+ ...(wasId !== article ? { reportIdWas: wasId ?? "(none)" } : {}),
+ problems: parsed.problems.map((p) => `${p.path || "(root)"}: ${p.message}`),
+ ...(sweepMd !== undefined ? { sweepMd } : {}),
+ model: o.model?.trim() || DEFAULT_IMPORT_MODEL,
+ from: o.from?.trim() || "claude-code",
+ channels,
+ };
+}
+
+export function formatImportSweep(plan: ImportSweepPlan, o: { apply: boolean; reportFile: string }): string[] {
+ if (!plan.ok) return [`reports import-sweep: REFUSED — ${plan.refused}`];
+ const L = [o.apply ? "reports import-sweep: APPLY" : "reports import-sweep: DRY RUN — nothing is written (--apply writes)"];
+ L.push(
+ `${o.reportFile} → ${plan.nextLabel} of "${plan.article}", ${plan.articleExists ? "an article the registry has (it is NOT made current)" : "a NEW article in the making (not listed, not a draft, until it is made current)"}`,
+ );
+ L.push(` sweep on ${plan.model} · from ${plan.from} · $0.00${plan.channels.length ? ` · channels ${plan.channels.join(", ")}` : ""}`);
+ L.push(` files: report.json${plan.reportIdWas ? ` (its id "${plan.reportIdWas}" becomes "${plan.article}")` : ""}${plan.sweepMd !== undefined ? ", sweep.md" : ""}`);
+ if (plan.problems.length) L.push(` the report has ${plan.problems.length} problem(s), so it cannot be made current until they are fixed: ${plan.problems.slice(0, 3).join("; ")}`);
+ L.push(` make it current: umtool's Iterations tab ("Use this iteration"), or \`umtool chain ${plan.article} <n>\` (its first step)`);
+ return L;
+}
+
+export async function importSweepMain(o: ImportSweepOptions, out: Out = console): Promise<number> {
+ const plan = await planImportSweep(o);
+ for (const l of formatImportSweep(plan, { apply: o.apply, reportFile: o.reportFile })) out.log(l);
+ if (!plan.ok) return 1;
+ if (!o.apply) return 0;
+ const now = (o.now ?? (() => new Date()))();
+ const created = await createIteration(
+ plan.article,
+ { kind: "sweep", model: plan.model, question: o.question.trim(), ...(plan.channels.length ? { scope: { channels: plan.channels } } : {}), status: "running" },
+ o.paths,
+ now,
+ );
+ const n = created.n;
+ await writeIterationFile(plan.article, n, "report.json", plan.report, o.paths);
+ if (plan.sweepMd !== undefined) await writeIterationFile(plan.article, n, "sweep.md", plan.sweepMd, o.paths);
+ await updateIteration(
+ plan.article,
+ n,
+ {
+ status: "done",
+ ...(o.minutes !== undefined && Number.isFinite(o.minutes) && o.minutes >= 0 ? { minutes: o.minutes } : {}),
+ endedAt: now.toISOString(),
+ imported: { from: plan.from, at: now.toISOString(), report: path.basename(o.reportFile) },
+ } as Parameters<typeof updateIteration>[2],
+ o.paths,
+ now,
+ );
+ out.log(`wrote "${plan.article}" ${iterationLabel(n)} (done)`);
+ return 0;
+}
+
+// The CLI row.
+export async function importSweepRow(
+ reportFile: string | undefined,
+ flags: { article?: string; question?: string; sweep?: string; channels?: string; model?: string; from?: string; minutes?: string; apply?: boolean },
+): Promise<number> {
+ if (!reportFile || typeof flags.article !== "string" || typeof flags.question !== "string") {
+ console.error("reports import-sweep: give <report.json> --article <id> --question <question>");
+ return 2;
+ }
+ const minutes = typeof flags.minutes === "string" ? Number(flags.minutes) : undefined;
+ if (minutes !== undefined && !(Number.isFinite(minutes) && minutes >= 0)) {
+ console.error("reports import-sweep: --minutes is a number of minutes");
+ return 2;
+ }
+ const { getPaths } = await import("../lib/paths");
+ return importSweepMain({
+ reportFile: path.resolve(reportFile),
+ article: flags.article,
+ question: flags.question,
+ ...(typeof flags.sweep === "string" ? { sweepFile: path.resolve(flags.sweep) } : {}),
+ ...(typeof flags.channels === "string" ? { channels: flags.channels.split(",") } : {}),
+ ...(typeof flags.model === "string" ? { model: flags.model } : {}),
+ ...(typeof flags.from === "string" ? { from: flags.from } : {}),
+ ...(minutes !== undefined ? { minutes } : {}),
+ apply: flags.apply === true,
+ paths: getPaths(),
+ });
+}