Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit e20af68f80aeed0f405ec0b233cad552a4ba6010
parent 0d8e361bba78ff085da0ec72f459217c1418cd78
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 23:28:55 -0400

mcp, gen: the media drafts — generate's checks and review guidance per task; /gen maps requests to them; archilyzer gen run takes them (r28 M9)

generate: a media draft (cut, onscreen, teaser, flips, threads, narrate,
youtube) names its iteration, takes no copyOf, question or feedback;
entries is a media draft's only; its done answer is mediaReviewGuidance —
the task's draft file, the drafted fields and what to check for that task,
the operator's approve or reject in umtool's review page (never
drafts.review.json by hand), the final gate, force's rule. The tool texts
name the media tasks. /gen maps phrasings to each task and says Draft
everything is umtool's. archilyzer gen run: a media draft needs
--iteration, takes no words, --entries; COMMANDS.md regenerated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
M.claude/commands/gen.md | 27++++++++++++++++++++-------
MCOMMANDS.md | 4++--
Mcommon/bin/archilyzer.ts | 5+++--
Mcommon/bin/gen.test.ts | 18++++++++++++++++++
Mcommon/bin/gen.ts | 17++++++++++++++---
Mmcp/src/generation.test.ts | 44++++++++++++++++++++++++++++++++++++++++++--
Mmcp/src/generation.ts | 32+++++++++++++++++++++++++-------
Mmcp/src/instructions.test.ts | 17++++++++++++++++-
Mmcp/src/instructions.ts | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 197 insertions(+), 24 deletions(-)

diff --git a/.claude/commands/gen.md b/.claude/commands/gen.md @@ -8,20 +8,33 @@ each task. Use the archilyzer MCP tools only; run no script for it. 1. Call `mcp__archilyzer__generation_policy` with no arguments and read the routes, the models and the day's spend. 2. Map the request below to tasks: `sweep` (a new cited report), `revise-report` (a new iteration of an article's - report from feedback), `revise-video` (a new iteration of its video cut: cards, narration, title), `narrate` - (card narration drafts for a done iteration's cut), `research` (find what the corpus lacks and propose - acquisitions — archive.org imports, channels, posts — under an autonomy: propose, limits or auto; a sweep with - the research run's iteration continues it over the widened scope). The clip fetches, voices, render and podcast are the - pipeline's code, not generation: the operator runs that chain from umtool (the article's Iterations tab). + report from feedback), `revise-video` (a new iteration of its video cut from feedback), `research` (find what the + corpus lacks and propose acquisitions — archive.org imports, channels, posts — under an autonomy: propose, limits + or auto; a sweep with the research run's iteration continues it over the widened scope). A request to draft part + of a done iteration's video cut is a media draft, a step on that iteration (`iteration`; `entries` to limit it): + - `cut` — "pick the clips", "reorder the cut", "cut it down"; + - `onscreen` — "draft the on-screen titles", "titles and subtitles"; + - `teaser` — "make a teaser", "the teaser lines"; + - `flips` — "then and now", "the flip-flops", "THEN/NOW pairs"; + - `threads` — "group the clips into threads", "the threads panel"; + - `narrate` — "narrate it", "the card narration"; + - `youtube` — "YouTube title", "YouTube description", "the upload text". + "Draft everything" (every media draft in order, then voices, a fast build and the podcast) is the operator's button + on umtool's Iterations tab, or `umtool chain <article> <n> --draft-all`; it is not a `generate` task. The clip + fetches, voices, render and podcast are the pipeline's code, not generation: the operator runs that chain from umtool. 3. For each task routed to `api` or `local`, call `mcp__archilyzer__generate` with the task, the article, its inputs (question and channels for a sweep or research run; iteration and concrete feedback for a revision; - iteration for a narration) and `wait: true`, and do not redo its work yourself. If it answers still running, call it again with + iteration, and `entries` when the operator named some, for a media draft) and `wait: true`, and do not redo its + work yourself. If it answers still running, call it again with the job, article and iteration it names — never start the same task twice. Then REVIEW what it made, as its answer says: read the iteration's files, spot-check its quotes with `mcp__archilyzer__get_transcript`, read the ops it refused and its checks, and tell the operator what is good and what is not. Recommend making it current (the operator does that in umtool) or a revision; for a revision, call `generate` again with that feedback. A research run's proposals are the operator's to approve (umtool's research queue); say which you would approve - and why. Edit an iteration's files by hand only if the operator asks. + and why. A media draft's review is as its answer says: its `<task>-draft.json` and the drafted fields; the + operator approves or rejects each field in umtool (the project page's Review drafts) — never write + `drafts.review.json` yourself. `force: true` re-drafts only what a model drafted; a field the operator wrote is + never replaced. Edit an iteration's files by hand only if the operator asks. 4. For each task routed to `code`, do it yourself as usual: `/sweep` for a report (its plan reads the same policy). 5. `via: "api"` or `"local"` on `generate` (or `via=` in a `/sweep` request) overrides one run when the operator asks diff --git a/COMMANDS.md b/COMMANDS.md @@ -40,8 +40,8 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi | `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 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, narrate, research) | -| `archilyzer gen run` | `<task> [<question\|feedback>] --article <id> [--via api\|local\|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--force] [--autonomy propose\|limits\|auto] [--source <handle>\|--build <id>] [--wait]` | enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once) | +| `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) | +| `archilyzer gen run` | `<task> [<question\|feedback>] --article <id> [--via api\|local\|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--entries a,b] [--force] [--autonomy propose\|limits\|auto] [--source <handle>\|--build <id>] [--wait]` | enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); a media draft (cut, onscreen, teaser, flips, threads, narrate, youtube) is a step on --iteration &lt;n&gt;, takes no words, --entries limits it, --force re-drafts only fields a model drafted; EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once) | | `archilyzer reports move-to-articles` | `[--keep <site>/<id>,…] [--drafts] [--apply]` | ONE-OFF (release 26): every report a site lists, but the pages named by --keep, moved to transcripts/reports/ as an article — audience private, published in reports/index.json in the sites' order (a report with problems as a draft), dropped from its site; --drafts moves unlisted ones too. A dry run printing the plan unless --apply *(passthrough)* | | `archilyzer reports convert` | `<sweep\|ask\|manifest> <in> --out <report.json> [--channels-dir <dir>] [--id <id>] [--title <title>]` | a /sweep report (markdown), an /ask answer or a report-to-video manifest as a report.json, written only when it validates (--channels-dir: widen spans from the cues, find posts' channels) | | `archilyzer reports to-manifest` | `<report.json> --out <manifest.json> [--channels-dir <dir>] [--site-origin <url>]` | a starter report-to-video manifest from a report (a chapter card per section, a claim's still and clips stamped with its verdict, its posts) | diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts @@ -444,14 +444,14 @@ export const COMMANDS: Command[] = [ }, { path: ["gen", "set"], - usage: "<task> <code|api|local> route one generation task (sweep, revise-report, revise-video, narrate, research)", + usage: "<task> <code|api|local> route one generation task (sweep, revise-report, revise-video, research; the media drafts cut, onscreen, teaser, flips, threads, narrate, youtube)", maxPositionals: 2, run: async (ctx) => (await import("./gen")).genSetRow(ctx), }, { path: ["gen", "run"], usage: - "<task> [<question|feedback>] --article <id> [--via api|local|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--force] [--autonomy propose|limits|auto] [--source <handle>|--build <id>] [--wait] enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once)", + "<task> [<question|feedback>] --article <id> [--via api|local|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--entries a,b] [--force] [--autonomy propose|limits|auto] [--source <handle>|--build <id>] [--wait] enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); a media draft (cut, onscreen, teaser, flips, threads, narrate, youtube) is a step on --iteration <n>, takes no words, --entries limits it, --force re-drafts only fields a model drafted; EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once)", flags: { via: "string", article: "string", @@ -465,6 +465,7 @@ export const COMMANDS: Command[] = [ model: "string", "max-usd": "string", cards: "string", + entries: "string", force: "boolean", autonomy: "string", source: "string", diff --git a/common/bin/gen.test.ts b/common/bin/gen.test.ts @@ -212,3 +212,21 @@ test("gen run research takes --autonomy; nothing else does", async () => { // A continuation: a sweep naming the research run. assert.deepEqual(gen.runBody("sweep", undefined, { article: "synth-a", iteration: "4", force: true }), { task: "sweep", article: "synth-a", iteration: 4, force: true }); }); + +test("gen run a media draft: a step on --iteration, no words, --entries and --force (release 28)", () => { + assert.deepEqual(gen.runBody("onscreen", undefined, { article: "synth-a", iteration: "2", entries: "c01, c02", force: true }), { + task: "onscreen", + article: "synth-a", + iteration: 2, + entries: ["c01", "c02"], + force: true, + }); + assert.deepEqual(gen.runBody("youtube", undefined, { article: "synth-a", iteration: "2", model: "qwen3:8b" }), { task: "youtube", article: "synth-a", iteration: 2, model: "qwen3:8b" }); + assert.deepEqual(gen.runBody("cut", undefined, { article: "synth-a" }), { error: "gen run: a cut draft names its iteration (--iteration <n>)" }); + assert.deepEqual(gen.runBody("teaser", "make it punchier", { article: "synth-a", iteration: "2" }), { + error: "gen run: a teaser draft takes no question or feedback: it drafts from the iteration's report and cut", + }); + assert.deepEqual(gen.runBody("flips", undefined, { article: "synth-a", iteration: "2", "copy-of": "1" }), { error: "gen run: a flips draft is a step on its iteration: no --copy-of" }); + assert.deepEqual(gen.runBody("sweep", "q", { article: "synth-a", entries: "c01" }), { error: "gen run: --entries is a media draft's" }); +}); + diff --git a/common/bin/gen.ts b/common/bin/gen.ts @@ -5,7 +5,9 @@ // archilyzer gen preset code|balanced|api|local route every task at once // archilyzer gen set <task> code|api|local route one task // archilyzer gen run <task> [<question|feedback>] --article <id> [--via api|local|code] […] [--wait] -// enqueue a report-draft job (`pnpm ops report-draft`) +// enqueue a report-draft job (`pnpm ops report-draft`); +// a media draft (cut, onscreen, teaser, flips, threads, +// narrate, youtube) takes --iteration, --entries, --force // // THROUGH THE EDITOR when it answers: `GET/POST /api/ops/settings` (its one // settings writer) and `GET /api/ops/generation-usage`, with the token @@ -33,6 +35,8 @@ import { GENERATION_PRESETS, GENERATION_PRESET_NAMES, GENERATION_ROUTES, + MEDIA_STEP_TASKS, + isStepTask, type GenerationPreset, type GenerationRoute, } from "../lib/generationSettings"; @@ -66,7 +70,7 @@ export type GenDeps = { out?: Out; }; -const TASKS_HELP = "sweep, revise-report, revise-video, narrate, research"; +const TASKS_HELP = `sweep, revise-report, revise-video, research, or a media draft: ${MEDIA_STEP_TASKS.join(", ")}`; const isRoute = (v: unknown): v is GenerationRoute => typeof v === "string" && (GENERATION_ROUTES as readonly string[]).includes(v); export function policyFrom(value: unknown): GenPolicy | null { @@ -263,12 +267,19 @@ export function runBody(task: string, text: string | undefined, flags: Record<st if (e) return { error: e }; } const words = text?.trim(); + // A media draft (release 28) is a step on the iteration it names; it takes + // no words — it drafts from the iteration's report and cut. + if (isStepTask(task)) { + if (body.iteration === undefined) return { error: `gen run: a ${task} draft names its iteration (--iteration <n>)` }; + if (body.copyOf !== undefined) return { error: `gen run: a ${task} draft is a step on its iteration: no --copy-of` }; + if (words || str("question") || str("feedback")) return { error: `gen run: a ${task} draft takes no question or feedback: it drafts from the iteration's report and cut` }; + } else if (str("entries")) return { error: "gen run: --entries is a media draft's" }; if (words) body[task === "sweep" || task === "research" ? "question" : "feedback"] = words; for (const k of ["question", "feedback", "from", "to", "model", "source", "build"] as const) { const v = str(k); if (v) body[k] = v; } - for (const k of ["channels", "cards"] as const) { + for (const k of ["channels", "cards", "entries"] as const) { const v = str(k); if (v) body[k] = v.split(",").map((x) => x.trim()).filter(Boolean); } diff --git a/mcp/src/generation.test.ts b/mcp/src/generation.test.ts @@ -35,7 +35,7 @@ type Sent = { url: string; method: string; body?: unknown }; // An editor that serves the policy, the day's usage, a report-draft POST, a // job that runs for `runPolls` polls and then ends `end`, and the iteration. -function editor(opts: { policy?: Record<string, unknown>; runPolls?: number; end?: string; iteration?: Record<string, unknown>; marker?: boolean } = {}) { +function editor(opts: { policy?: Record<string, unknown>; runPolls?: number; end?: string; iteration?: Record<string, unknown>; marker?: boolean; task?: string } = {}) { let policy = { ...POLICY, ...(opts.policy ?? {}) }; let polls = 0; const runPolls = opts.runPolls ?? 0; @@ -56,7 +56,7 @@ function editor(opts: { policy?: Record<string, unknown>; runPolls?: number; end steps: [], ...(opts.iteration ?? {}), }; - const marker = `@@report-draft ${JSON.stringify({ article: "synth-a", iteration: 3, task: "revise-report", status: opts.end ?? "done", summary: "2 op(s) applied, 1 refused — “A title”", usd: 0.45, minutes: 2.5 })}`; + const marker = `@@report-draft ${JSON.stringify({ article: "synth-a", iteration: 3, task: opts.task ?? "revise-report", status: opts.end ?? "done", summary: "2 op(s) applied, 1 refused — “A title”", usd: 0.45, minutes: 2.5 })}`; const fake = fakeEditor((s) => { const u = new URL(s.url); if (u.pathname === "/api/ops/settings" && s.method === "GET") return { status: 200, body: { ok: true, key: "generation", value: policy } }; @@ -278,6 +278,11 @@ test("generate: the arguments are checked before any request; research is a task for (const [args, re] of [ [{ task: "nope", article: "a" }, /task is one of sweep, revise-report, revise-video, narrate, research, cut, onscreen, teaser, flips, threads, youtube/], [{ task: "cut", article: "a", iteration: 1, entries: [] }, /entries is a non-empty list/], + // The media drafts (release 28): a step on the iteration it names. + [{ task: "onscreen", article: "a" }, /a onscreen draft names the iteration it drafts on/], + [{ task: "teaser", article: "a", iteration: 1, copyOf: 1 }, /a teaser draft is a step on its iteration: it has no copyOf/], + [{ task: "youtube", article: "a", iteration: 1, feedback: "shorter" }, /feedback is not a youtube draft's/], + [{ task: "sweep", article: "a", question: "q", channels: ["c"], entries: ["c01"] }, /entries is a media draft's/], [{ task: "sweep", article: "Not An Id" }, /article is an article id/], [{ task: "sweep", article: "a", channels: [] }, /channels is a non-empty list/], [{ task: "sweep", article: "a", iteration: 0 }, /iteration is an iteration number/], @@ -295,6 +300,41 @@ test("generate: the arguments are checked before any request; research is a task } }); +test("generate: a media draft is a step on its iteration, routed like any task; done, the review is the operator's in umtool", async () => { + for (const task of ["cut", "onscreen", "teaser", "flips", "threads", "narrate", "youtube"]) { + assert.ok(GENERATE_TASKS.includes(task), task); + const v = validateGenerateArgs({ task, article: "synth-a", iteration: 3, entries: ["c01"], force: true }); + assert.equal(v.ok, true, task); + } + // Routed by the policy: the editor runs it on the route's model. + const e = editor({ + task: "onscreen", + policy: { routes: { ...POLICY.routes, onscreen: "local" } }, + iteration: { + kind: "sweep", + ops: undefined, + checks: [{ name: "onscreen", ok: false, detail: "3 title(s) written, 1 not written (a hard check)" }], + steps: [{ task: "onscreen", model: "qwen3:8b", status: "done", jobId: "job-1", detail: "3 title(s) written" }], + projectDir: "/srv/projects/synth-a/i3", + }, + }); + const a = await generateTool({ task: "onscreen", article: "synth-a", iteration: 3, entries: ["c01", "c02"], wait: true }, e.deps as never); + assert.ok(!a.isError, a.text); + assert.deepEqual(e.sentOf("/api/ops/report-draft")[0].body, { task: "onscreen", article: "synth-a", iteration: 3, entries: ["c01", "c02"] }); + const queued = await generateTool({ task: "onscreen", article: "synth-a", iteration: 3 }, e.deps as never); + assert.match(queued.text, /drafting its onscreen on synth-a i3 on the policy's model/); + assert.match(a.text, /onscreen: 3 title\(s\) written/); + assert.match(a.text, /\*\*Review the draft — the approval is the operator's\.\*\* It drafted each clip's on-screen title and subtitle in the video project \(`\/srv\/projects\/synth-a\/i3`\)/); + assert.match(a.text, /`onscreen-draft\.json`/); + assert.match(a.text, /never by writing `drafts\.review\.json` yourself/); + assert.match(a.text, /A final build refuses any drafted field not approved/); + assert.doesNotMatch(a.text, /Review it — you are the reviewer/); + // A task routed to code is this session's, as any. + const code = await generateTool({ task: "youtube", article: "synth-a", iteration: 3 }, editor({ policy: { routes: { ...POLICY.routes, youtube: "code" } } }).deps as never); + assert.equal(code.isError, true); + assert.match(code.text, /youtube is routed to Claude Code/); +}); + test("resultMarkerOf reads the job's @@report-draft line", () => { assert.deepEqual(resultMarkerOf(["x", '@@report-draft {"article":"a","iteration":2}', "y"]), { article: "a", iteration: 2 }); assert.equal(resultMarkerOf(["nothing here"]), null); diff --git a/mcp/src/generation.ts b/mcp/src/generation.ts @@ -9,7 +9,7 @@ import { import { AUTONOMIES } from "yt-dlp-transcript-common/lib/report/draft/research/decide"; import { describeEditorFailure, editorGet, editorPost, type EditorAnswer } from "./editorOps"; import type { FetchClipDeps, PollProgress } from "./fetchClip"; -import { reviewGuidance, type GenerationRoute, type PlanGeneration } from "./instructions"; +import { mediaReviewGuidance, reviewGuidance, type GenerationRoute, type PlanGeneration } from "./instructions"; import type { ToolAnswer } from "./archivalTools"; // ─── The Claude Code balance (release 27 S9; D8) ─── @@ -282,6 +282,14 @@ export function validateGenerateArgs(args: Record<string, unknown>): { ok: true; if (body.model) return bad("give model or via, not both"); via = v; } + // A media draft (release 28) is a step on a done iteration: it names it. + if (isStepTask(task)) { + if (body.iteration === undefined) return bad(`a ${task} draft names the iteration it drafts on (iteration)`); + if (body.copyOf !== undefined) return bad(`a ${task} draft is a step on its iteration: it has no copyOf`); + for (const k of ["question", "feedback", "channels", "from", "to"] as const) { + if (body[k] !== undefined) return bad(`${k} is not a ${task} draft's: it drafts from the iteration's report and cut`); + } + } else if (body.entries !== undefined) return bad("entries is a media draft's (cut, onscreen, teaser, flips, threads, narrate, youtube)"); if (args.wait !== undefined && typeof args.wait !== "boolean") return bad("wait is true or false"); return { ok: true, request: { kind: "start", body, ...(via ? { via } : {}), wait: args.wait === true, waitSeconds } }; } @@ -421,7 +429,8 @@ export function renderIterationSummary( lines.push(`Research: phase ${r.phase ?? "?"}, autonomy ${r.autonomy ?? "?"}${r.continuedBy ? `, continued by i${r.continuedBy}` : ""}`); for (const note of (r.notes ?? []).slice(0, MAX_LISTED)) lines.push(` - ${note}`); if (status === "done") lines.push("", researchGuidance(o.article, it.n)); - } else if (status === "done") lines.push("", reviewGuidance()); + } else if (status === "done" && isStepTask(o.task)) lines.push("", mediaReviewGuidance(o.task, it.projectDir)); + else if (status === "done") lines.push("", reviewGuidance()); else if (status === "failed") lines.push("", "It failed: say why to the operator. Running it again, or here instead, is their call."); return lines.join("\n"); } @@ -571,7 +580,8 @@ export const GENERATION_TOOLS = [ name: "generation_policy", description: "The operator's generation balance (settings.generation, read from the local editor): for each " + - "generation task — sweep (a new cited report), revise-report, revise-video, narrate, research — whether this " + + "generation task — sweep (a new cited report), revise-report, revise-video, research, and the media drafts on a " + + "video cut (cut, onscreen, teaser, flips, threads, narrate, youtube) — whether this " + "Claude Code session does it (code), the Claude API does it (api) or the local model does it " + "(local), on which model; the spend caps; and the day's Claude API spend against the daily cap. " + "With preset (code, balanced, api, local) it routes every task at once; with task and route it " + @@ -585,7 +595,10 @@ export const GENERATION_TOOLS = [ enum: [...GENERATION_PRESET_NAMES], description: "Route every task by this preset: code (all here), balanced, api, local.", }, - task: { type: "string", description: "Route one task (with route): sweep, revise-report, revise-video, narrate, research." }, + task: { + type: "string", + description: "Route one task (with route): sweep, revise-report, revise-video, research, cut, onscreen, teaser, flips, threads, narrate, youtube.", + }, route: { type: "string", enum: [...GENERATION_ROUTES], description: "Where that task runs." }, }, additionalProperties: false, @@ -599,9 +612,13 @@ export const GENERATION_TOOLS = [ "with wait: true, follow it and return the iteration it made: status, cost, the ops applied and " + "refused, the checks, and where its files are on the editor's disk. task sweep makes a new " + "iteration of article from question over channels; revise-report and revise-video make one from " + - "iteration and feedback; narrate voices a done iteration's cut; research finds what the corpus lacks " + + "iteration and feedback; research finds what the corpus lacks " + "and proposes acquisitions under its autonomy (propose, limits, auto), and task sweep with a research " + "run's iteration continues it over the widened scope. copyOf runs an iteration again on another model. " + + "The media drafts are steps on a done iteration's video cut (iteration names it): cut (which cited clips, in " + + "what order), onscreen (each clip's title and subtitle), teaser (its lines), flips (THEN/NOW pairs), threads, " + + "narrate (each card's narration) and youtube (the upload's title and summary); each drafted field is marked " + + "for the operator's review, and a field the operator wrote is never replaced. " + "A task routed to code is refused: do it in this session. The wait is bounded (wait_seconds, " + "default 90, at most 300) and polite (one poll every 5 s, a progress notification each); if the " + "job is still running it answers its id — call again with job (and article, iteration) to keep " + @@ -616,7 +633,7 @@ export const GENERATION_TOOLS = [ type: "integer", minimum: 1, description: - "revise-report / revise-video: the iteration revised; narrate: the iteration voiced; sweep: the research run it continues; with job: the iteration to summarise.", + "revise-report / revise-video: the iteration revised; a media draft (cut, onscreen, teaser, flips, threads, narrate, youtube): the done iteration whose cut it drafts; sweep: the research run it continues; with job: the iteration to summarise.", }, question: { type: "string", description: "sweep / research: the question, in words." }, channels: { type: "array", items: { type: "string" }, description: "sweep / research: the channel slugs to read." }, @@ -635,7 +652,8 @@ export const GENERATION_TOOLS = [ entries: { type: "array", items: { type: "string" }, description: "A media draft (narrate, cut, onscreen, teaser, flips, threads, youtube): only these entry ids." }, force: { type: "boolean", - description: "narrate: redraft cards that already have narration; a sweep continuing a research run: continue while proposals still wait.", + description: + "A media draft: re-draft fields a model drafted (a field the operator wrote is never replaced; its draft is kept as an alternative); a sweep continuing a research run: continue while proposals still wait.", }, autonomy: { type: "string", diff --git a/mcp/src/instructions.test.ts b/mcp/src/instructions.test.ts @@ -1,6 +1,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { NARRATION_HARD_RULE, NARRATION_WRITING_RULES, buildSweepInstructions, buildAskInstructions, narrationStep } from "./instructions"; +import { MEDIA_REVIEW, NARRATION_HARD_RULE, NARRATION_WRITING_RULES, buildSweepInstructions, buildAskInstructions, mediaReviewGuidance, narrationStep } from "./instructions"; +import { MEDIA_STEP_TASKS } from "yt-dlp-transcript-common/lib/generationSettings"; import { parsePromptRequest } from "./promptRequest"; import { TOOLS } from "./server"; @@ -318,3 +319,17 @@ test("every tool a routed plan names exists", () => { } } }); + +test("every media task has its review guidance: the draft file, the fields, the operator's approval in umtool", () => { + assert.deepEqual(Object.keys(MEDIA_REVIEW).sort(), [...MEDIA_STEP_TASKS].sort()); + for (const task of MEDIA_STEP_TASKS) { + const g = mediaReviewGuidance(task, "/p/a/i2"); + assert.match(g, new RegExp(`\`${task === "narrate" ? "narration" : task}-draft\\.json\``), task); + assert.ok(g.includes(MEDIA_REVIEW[task]!.check), task); + assert.match(g, /\/browse\/<project>\/review/); + assert.match(g, /never by writing `drafts\.review\.json` yourself/); + assert.match(g, /--drafts-unreviewed/); + assert.match(g, /Use this/); + } +}); + diff --git a/mcp/src/instructions.ts b/mcp/src/instructions.ts @@ -282,6 +282,63 @@ export function reviewGuidance(corpus?: string): string { ); } +// ─── The media drafts (release 28) ─── +// +// A media draft (cut, onscreen, teaser, flips, threads, narrate, youtube) is a +// STEP on a done iteration's video manifest: it writes drafted fields, each +// marked with its provenance. The review is the operator's, in umtool, field +// by field — the agent reads what was drafted and says what it would approve. + +// What each media task drafts, and what its review checks beyond the code's. +export const MEDIA_REVIEW: Record<string, { what: string; check: string }> = { + cut: { + what: "the cut's clips and their order (ids from the report's citations only; the windows are untouched)", + check: "the order argues the report's case chapter by chapter, and no clip a conclusion rests on was dropped", + }, + onscreen: { + what: "each clip's on-screen title and subtitle", + check: "each title says what its clip shows, and a subtitle's quote is the clip's own words and its speaker's", + }, + teaser: { + what: "the teaser's 3 to 5 lines", + check: "the lines promise only what the cut delivers, and read no quote out", + }, + flips: { + what: "THEN/NOW pairs over the cut's clips (the dates and the order are code's)", + check: "both clips of a pair speak to the topic it names, so the change it shows is real", + }, + threads: { + what: "2 to 4 threads and each clip's thread (an outcome is its last clip's verdict)", + check: "each clip belongs to its thread, and each label names what the thread follows", + }, + narrate: { + what: "each card's narration", + check: "it is third person and says nothing the report does not, and no line restates a quote", + }, + youtube: { + what: "the upload's title and summary (the build adds the chapters and the sources to out/youtube.txt)", + check: "the summary says what the video shows, no more, and the title would not mislead", + }, +}; + +// The review of a media draft — the step Claude Code owns after `generate`. +export function mediaReviewGuidance(task: string, projectDir?: string): string { + const m = MEDIA_REVIEW[task]; + const where = projectDir ? ` (\`${projectDir}\`)` : ""; + return ( + `**Review the draft — the approval is the operator's.** It drafted ${m ? m.what : "fields of the cut"} in the video ` + + `project${where}. (1) Read the project's \`${task === "narrate" ? "narration" : task}-draft.json\`: what each unit wrote, ` + + `skipped, or had refused by a check, and the alternatives it kept. (2) Read the drafted fields in the manifest` + + (m ? `, and check that ${m.check}` : "") + + `; spot-check against the report and, where a field restates speech, \`get_transcript\`. (3) Tell me which ` + + `drafted fields you would approve or reject, and why. I approve or reject each one in umtool — the project page's ` + + `**Review drafts**, \`/browse/<project>/review\` — never by writing \`drafts.review.json\` yourself. A final build ` + + `refuses any drafted field not approved (\`--drafts-unreviewed\` overrides, and that is my call). A field I wrote ` + + `or edited is never replaced: a draft of it is kept as an alternative, which I take with **Use this**. To draft ` + + `again, call \`generate\` with the same task and iteration (force: true re-drafts only fields a model drafted).` + ); +} + // The generate call a routed sweep makes, with its scope settled. function generateSweepStep(req: PromptRequest, r: { route: GenerationRoute; model?: string; by: string }): string { const article = req.article