commit 147392d48e6cfc212e1cc75f314f569060a61d41
parent 842aed3ba4e7108d1d3e969f376bb6df4b3d3e73
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 1 Nov 2026 11:23:59 -0500
umtool: place -- an entry dropped before another, its clips joining a section, every other clip keeping its own (sectionEdit.mjs placeIn; placeEntries; POST /api/report/timeline {op: "place"}; umtool timeline <p> place <id…> --before <id|-> [--section N])
What Play's reel strip will write on a drop. A plain `move --to` takes the
boundary with the clip a marker follows; a place re-anchors the markers so
the sections hold, takes the drop's section at a seam (the end of §k or the
start of §k+1 -- the same slot), and refuses in words a section the slot
cannot be in or a section left with no clip. Each place is its own undo point
(autoSnapshot `every: 0`: no 2-minute coalescing, so the strip's Undo takes
back exactly one drop), and the take patches' markers in step follow
(sectionWrite → syncSectionMarkers). Nothing assumes a section count.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 289 insertions(+), 11 deletions(-)
diff --git a/umtool/app/api/report/timeline/route.ts b/umtool/app/api/report/timeline/route.ts
@@ -10,6 +10,7 @@ import {
moveEntry,
moveSectionBoundary,
moveToSection,
+ placeEntries,
removeEntry,
removeSection,
sectionsOf,
@@ -49,6 +50,8 @@ export const dynamic = "force-dynamic";
// post-remove { id }
// factcheck { factcheck: { verdicts?, stamp?, tally? } | null }
// undo {} restore the newest auto snapshot
+// place { ids: [id…], before: id | null, section? } a drop on Play's reel strip: before that entry
+// (null: the end), the clips joining that section; its own undo point
// section-move { ids: [id…], section, position?: "start" | "end" } clips into a section
// section-add { afterId, label?, color? } new section here (a marker after the clip)
// section-boundary { marker, afterId } drag a boundary (between its neighbours)
@@ -142,6 +145,12 @@ export async function POST(request: Request) {
return updateFactcheck(dir, (body.factcheck ?? null) as Record<string, unknown> | null, { token });
case "undo":
return undoStructural(dir, { token });
+ case "place":
+ return placeEntries(dir, Array.isArray(body.ids) ? body.ids.map(String) : [id], {
+ token,
+ before: typeof body.before === "string" && body.before ? body.before : null,
+ section: body.section === undefined || body.section === null || body.section === "" ? null : Number(body.section),
+ });
case "section-move":
return moveToSection(dir, Array.isArray(body.ids) ? body.ids.map(String) : [id], Number(body.section), { token, position: body.position === "start" ? "start" : "end" });
case "section-add":
@@ -153,7 +162,7 @@ export async function POST(request: Request) {
case "section-set":
return updateSection(dir, Number(body.marker), Object.fromEntries(["label", "color"].filter((k) => k in body).map((k) => [k, body[k]])), { token });
default:
- throw new Error("op must be move, remove, reject, wrong-speaker, duplicate, insert, teaser, post, post-remove, factcheck, undo, section-move, section-add, section-boundary, section-remove or section-set");
+ throw new Error("op must be move, place, remove, reject, wrong-speaker, duplicate, insert, teaser, post, post-remove, factcheck, undo, section-move, section-add, section-boundary, section-remove or section-set");
}
};
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -41,7 +41,7 @@ import { LOOK_KEYS, applyLookPatch, lookOf } from "yt-dlp-transcript-common/lib/
import { validateRoom } from "umtool-report-to-video/room";
import { applySectionEnter } from "./sections.mjs";
import { citeUrlAt, parseClipSpec } from "./clipEditorModel.mjs";
-import { addSectionIn, followSplitMarkers, moveBoundaryIn, moveToSectionIn, removeBoundaryIn, sectionModel, sectionWords, setSectionIn } from "./sectionEdit.mjs";
+import { addSectionIn, followSplitMarkers, moveBoundaryIn, moveToSectionIn, placeIn, removeBoundaryIn, sectionModel, sectionWords, setSectionIn } from "./sectionEdit.mjs";
import { normalizeClaim, validateClaims } from "umtool-report-to-video/factcheck";
import { migrateManifest } from "umtool-report-to-video/modules/migrate";
import { loadPreset, resolvePresetLayers } from "umtool-report-to-video/presets";
@@ -1698,11 +1698,11 @@ const ENTRY_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
* same op was taken in the last two minutes. Never fatal: an undo point that
* cannot be taken is reported, and the edit still lands.
*/
-export async function autoSnapshot(dir, op, { now = Date.now() } = {}) {
+export async function autoSnapshot(dir, op, { now = Date.now(), every = AUTO_SNAPSHOT_EVERY_MS } = {}) {
const label = `${AUTO_SNAPSHOT_PREFIX}${op}`;
try {
- const recent = (await listSnapshots(dir)).find((s) => !s.legacy && s.label === label);
- if (recent && now - recent.mtimeMs < AUTO_SNAPSHOT_EVERY_MS) return { skipped: true, rel: recent.rel };
+ const recent = every > 0 ? (await listSnapshots(dir)).find((s) => !s.legacy && s.label === label) : null;
+ if (recent && now - recent.mtimeMs < every) return { skipped: true, rel: recent.rel };
return { skipped: false, ...(await createSnapshot(dir, { label })) };
} catch (e) {
return { skipped: true, error: e instanceof Error ? e.message : String(e) };
@@ -1971,14 +1971,14 @@ export function reanchorAfterRemove(m, removed, i) {
* One structural write: token, read, `mutate` (which throws to refuse), the
* build's checks, the auto snapshot of the file as it still is, then the write.
*/
-async function structural(dir, op, token, mutate) {
+async function structural(dir, op, token, mutate, { snapshotEvery = undefined } = {}) {
return withManifestLock(async () => {
const current = await manifestToken(dir);
if (token !== null && current !== token) throw new StaleToken(token, current);
const manifest = JSON.parse(await readFile(manifestFile(dir), "utf8"));
const timelineBefore = Array.isArray(manifest.timeline) ? [...manifest.timeline] : [];
const result = applyStructural(manifest, mutate);
- const snapshot = await autoSnapshot(dir, op);
+ const snapshot = await autoSnapshot(dir, op, snapshotEvery === undefined ? {} : { every: snapshotEvery });
const nextToken = await writeManifestAtomic(dir, manifest);
// The project's take patches follow a removal as the manifest's markers
// did (patchMarkers.mjs): a marker after a clip that is gone moves to the
@@ -2193,7 +2193,7 @@ export async function insertEntry(dir, afterId, spec, { token = null, at = null
* checked by validateChrome (refused only for what this edit breaks), an
* emptied list is removed, and every take patch in step is synced after.
*/
-async function sectionWrite(dir, op, token, mutate) {
+async function sectionWrite(dir, op, token, mutate, opts = {}) {
let before = [];
let after = [];
const res = await structural(dir, op, token, (m) => {
@@ -2211,7 +2211,7 @@ async function sectionWrite(dir, op, token, mutate) {
}
after = clone(m.render?.chrome?.deck?.markers ?? []);
return r;
- });
+ }, opts);
// `sectionPatches`: a section edit's take-patch sync (`patches` is a removal's, patchMarkers.mjs).
const sectionPatches = await syncSectionMarkers(dir, before, after);
return { ...res, sectionPatches };
@@ -2231,6 +2231,22 @@ export async function moveToSection(dir, ids, section, { token = null, position
}
/**
+ * PLACE (Play's reel strip, a drop): entries `ids` land before entry `before`
+ * (null: the end), their clips joining section `section` (sectionEdit.mjs
+ * placeIn), the markers re-anchored so every other clip keeps its section.
+ * EVERY drop is its own undo point (no 2-minute coalescing: a drag is a
+ * decision, and the strip's Undo takes back exactly the one) and brings the
+ * take patches' markers along.
+ *
+ * @param {string} dir
+ * @param {string[]} ids
+ * @param {{ token?: string | null, before?: string | null, section?: number | null }} [opts]
+ */
+export async function placeEntries(dir, ids, { token = null, before = null, section = null } = {}) {
+ return sectionWrite(dir, "place", token, (m) => placeIn(m, ids, { before, section }), { snapshotEvery: 0 });
+}
+
+/**
* New section here: a marker after clip `afterId`, with a label and a colour.
*
* @param {string} dir
diff --git a/umtool/lib/report/placeIn.test.mjs b/umtool/lib/report/placeIn.test.mjs
@@ -0,0 +1,154 @@
+// PLACE: a drop on Play's reel strip (sectionEdit.mjs placeIn, manifest.mjs placeEntries,
+// `umtool timeline <p> place`): before an entry, into a section, the markers following.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { execFile } from "node:child_process";
+import { mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+import { promisify } from "node:util";
+
+import { placeIn, sectionModel } from "./sectionEdit.mjs";
+import { MANIFEST_NAME, placeEntries, undoStructural } from "./manifest.mjs";
+
+const clip = (id, start, end) => ({ type: "clip", id, video: "v1", start, end });
+// §0 a b | §1 "Two" c d | card k | §2 "Three" e f
+const deckCut = () => ({
+ slug: "s",
+ provenance: { siteOrigin: "https://example.test", channelSlug: "chan" },
+ render: {
+ width: 1920,
+ height: 1080,
+ chrome: { engine: "hyperframes", layout: "deck", deck: { markers: [{ after: "b", label: "Two" }, { after: "d", label: "Three" }] } },
+ },
+ timeline: [clip("a", 10, 20), clip("b", 30, 40), clip("c", 50, 60), clip("d", 70, 80), { type: "card", id: "k", seconds: 3 }, clip("e", 90, 100), clip("f", 110, 120)],
+});
+const ids = (m) => m.timeline.map((e) => e.id);
+const afters = (m) => m.render.chrome.deck.markers.map((mk) => mk.after);
+const secs = (m) => sectionModel(m).sections.map((s) => s.clips.join(""));
+
+test("within a section: the order changes, no boundary moves", () => {
+ const m = deckCut();
+ const r = placeIn(m, ["a"], { before: "c", section: 0 });
+ assert.deepEqual(ids(m), ["b", "a", "c", "d", "k", "e", "f"]);
+ assert.deepEqual(afters(m), ["a", "d"], "the marker that followed b follows a, the clip now last in §0");
+ assert.deepEqual(secs(m), ["ba", "cd", "ef"]);
+ assert.equal(r.section, 0);
+ assert.equal(r.from, 0);
+ assert.equal(r.to, 1);
+});
+
+test("moving the clip a marker follows keeps the boundary where it was", () => {
+ const m = deckCut();
+ placeIn(m, ["b"], { before: "a" });
+ assert.deepEqual(ids(m), ["b", "a", "c", "d", "k", "e", "f"]);
+ assert.deepEqual(secs(m), ["ba", "cd", "ef"], "c and d stay in §1 (a plain `move` took the boundary with b)");
+});
+
+test("at a seam the section decides: the end of §0 or the start of §1, the same slot", () => {
+ const end = deckCut();
+ placeIn(end, ["e"], { before: "c", section: 0 });
+ assert.deepEqual(ids(end), ["a", "b", "e", "c", "d", "k", "f"]);
+ assert.deepEqual(secs(end), ["abe", "cd", "f"]);
+ const start = deckCut();
+ placeIn(start, ["e"], { before: "c", section: 1 });
+ assert.deepEqual(ids(start), ["a", "b", "e", "c", "d", "k", "f"]);
+ assert.deepEqual(secs(start), ["ab", "ecd", "f"]);
+ // The default is the section of the clip it lands after.
+ const def = deckCut();
+ assert.equal(placeIn(def, ["e"], { before: "c" }).section, 0);
+});
+
+test("across sections, inside one: the drop's section is the slot's", () => {
+ const m = deckCut();
+ const r = placeIn(m, ["a"], { before: "f" });
+ assert.deepEqual(ids(m), ["b", "c", "d", "k", "e", "a", "f"]);
+ assert.deepEqual(secs(m), ["b", "cd", "eaf"]);
+ assert.equal(r.section, 2);
+ assert.deepEqual(r.fromSections, { a: 0 });
+ // At the end.
+ const m2 = deckCut();
+ placeIn(m2, ["c"], { before: null });
+ assert.deepEqual(ids(m2).slice(-1), ["c"]);
+ assert.deepEqual(secs(m2), ["ab", "d", "efc"]);
+});
+
+test("refused in words: an emptied section, a section the slot cannot be in, nothing to do", () => {
+ const m = deckCut();
+ placeIn(m, ["c"], { before: "e", section: 2 });
+ assert.throws(() => placeIn(m, ["d"], { before: "a", section: 0 }), /§1 \(Two\) would have no clip left/);
+ assert.throws(() => placeIn(deckCut(), ["a"], { before: "f", section: 0 }), /cannot join §0 \(the opening\)/);
+ assert.throws(() => placeIn(deckCut(), ["a"], { before: "b", section: 0 }), /already stands there in §0/);
+ assert.throws(() => placeIn(deckCut(), ["a"], { before: "a" }), /one of the entries being placed/);
+ assert.throws(() => placeIn(deckCut(), ["zz"], { before: "a" }), /no timeline entry with id zz/);
+ assert.throws(() => placeIn(deckCut(), ["a"], { before: "zz" }), /no timeline entry with id zz to place before/);
+});
+
+test("a section's only clip may move within its own seam; a card moves to the slot", () => {
+ const m = deckCut();
+ // §1 down to one clip (d), then d moves across the card: still §1, alone.
+ placeIn(m, ["c"], { before: "a", section: 0 });
+ placeIn(m, ["d"], { before: "e", section: 1 });
+ assert.deepEqual(secs(m), ["cab", "d", "ef"]);
+ const k = deckCut();
+ placeIn(k, ["k"], { before: "a" });
+ assert.deepEqual(ids(k), ["k", "a", "b", "c", "d", "e", "f"]);
+ assert.deepEqual(secs(k), ["ab", "cd", "ef"]);
+});
+
+test("no deck: a plain move to the slot", () => {
+ const m = deckCut();
+ delete m.render.chrome;
+ const r = placeIn(m, ["f"], { before: "a", section: 2 });
+ assert.deepEqual(ids(m), ["f", "a", "b", "c", "d", "k", "e"]);
+ assert.equal(r.section, null);
+});
+
+async function project() {
+ const dir = await mkdtemp(path.join(tmpdir(), "place-"));
+ await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(deckCut(), null, 2) + "\n");
+ // A take patch in step with the manifest's markers.
+ await writeFile(path.join(dir, "draft-1.patch.json"), JSON.stringify({ title: "x", render: { chrome: { deck: { markers: deckCut().render.chrome.deck.markers } } } }, null, 2) + "\n");
+ return dir;
+}
+
+test("placeEntries: one write, its own undo point every time, the take patch's markers in step", async () => {
+ const dir = await project();
+ try {
+ const r1 = await placeEntries(dir, ["b"], { before: "f" });
+ assert.ok(r1.snapshot?.rel && !r1.snapshot.skipped, "an undo point");
+ assert.deepEqual(r1.sectionPatches.synced, ["draft-1.patch.json"]);
+ const patch = JSON.parse(await readFile(path.join(dir, "draft-1.patch.json"), "utf8"));
+ assert.deepEqual(patch.render.chrome.deck.markers.map((x) => x.after), ["a", "d"], "the boundary b followed is after a now, in the patch too");
+ // A second drop straight after is its own undo point (no 2-minute coalescing).
+ await new Promise((res) => setTimeout(res, 1100));
+ const r2 = await placeEntries(dir, ["c"], { before: "a", section: 0, token: r1.token });
+ assert.ok(r2.snapshot?.rel && !r2.snapshot.skipped && r2.snapshot.rel !== r1.snapshot.rel);
+ // Undo takes back exactly the second.
+ await undoStructural(dir, { token: r2.token });
+ const m = JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8"));
+ assert.deepEqual(ids(m), ["a", "c", "d", "k", "e", "b", "f"]);
+ const snaps = (await readdir(path.join(dir, "revisions"))).filter((n) => n.includes("place"));
+ assert.equal(snaps.length, 2);
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+});
+
+test("umtool timeline place: the same writer from a terminal", async () => {
+ const dir = await project();
+ const root = path.dirname(dir);
+ try {
+ const bin = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "bin", "umtool.mjs");
+ const { stdout } = await promisify(execFile)(process.execPath, [bin, "timeline", dir, "place", "e", "--before", "c", "--section", "1"], { env: { ...process.env, REPORTS_DIR: root } });
+ assert.match(stdout, /placed e before c \(index 5 -> 2\) in §1 \(Two\)/);
+ assert.match(stdout, /undo point: revisions\//);
+ const m = JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8"));
+ assert.deepEqual(secs(m), ["ab", "ecd", "f"]);
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+});
diff --git a/umtool/lib/report/sectionEdit.mjs b/umtool/lib/report/sectionEdit.mjs
@@ -198,6 +198,89 @@ export function moveToSectionIn(m, ids, target, { position = "end", allowNoop =
}
/**
+ * PLACE (a drop on Play's reel strip, 1 Nov 2026): entries `ids` -- in the
+ * order they stand in the cut -- land right before entry `before` (null: at
+ * the end), and the CLIPS among them join section `section`; every other clip
+ * keeps the section it is in, and the markers are re-anchored so that holds.
+ * One edit for "drag c04 between o01 and o02" whatever the boundaries do --
+ * `timeline move --to` index arithmetic moved a boundary with the clip it
+ * followed.
+ *
+ * `section` defaults to the section of the clip the drop lands next to (the
+ * one before it, else the one after). It must be one the slot can belong to:
+ * between a clip of §a and a clip of §b the moved clips join §a, §b, or a
+ * section between them that has no other clip left (a section's only clip
+ * moved within its own seam). Anything else is refused in words, as an emptied
+ * section is. A card (not a clip) is moved to the slot and belongs to no
+ * section of its own.
+ *
+ * The section model is the deck's markers (sectionModel): nothing here
+ * assumes a flat list of at most N sections, nor knows the limit.
+ *
+ * @param {Record<string, any>} m
+ * @param {string[] | string} ids
+ * @param {{ before?: string | null, section?: number | null }} [opts]
+ */
+export function placeIn(m, ids, { before = null, section = null } = {}) {
+ const tl = m.timeline;
+ if (!Array.isArray(tl)) throw new Error("the manifest has no timeline");
+ const want = [...new Set((Array.isArray(ids) ? ids : [ids]).map((x) => String(x ?? "").trim()).filter(Boolean))];
+ if (!want.length) throw new Error("name one or more entries to place");
+ for (const id of want) {
+ const n = tl.filter((x) => x?.id === id).length;
+ if (!n) throw new Error(`no timeline entry with id ${id}`);
+ if (n > 1) throw new Error(`${id} is in the timeline more than once — move one twin with \`timeline move\``);
+ }
+ const b = before === null || before === undefined || before === "" ? null : String(before).trim();
+ if (b !== null && want.includes(b)) throw new Error(`${b} is one of the entries being placed: name the entry they land before`);
+ if (b !== null && !tl.some((x) => x?.id === b)) throw new Error(`no timeline entry with id ${b} to place before`);
+ const model = sectionModel(m);
+ const hasDeck = deckMarkers(m) !== null;
+ const moving = new Set(want);
+ const moved = tl.filter((e) => moving.has(e?.id));
+ const rest = tl.filter((e) => !moving.has(e?.id));
+ const at = b === null ? rest.length : rest.findIndex((e) => e?.id === b);
+ const clipsMoved = moved.filter(isClip).map((e) => e.id);
+ const fromIndex = tl.findIndex((e) => e?.id === want[0]);
+ // The sections either side of the slot, among the clips that stay.
+ const prevClip = [...rest.slice(0, at)].reverse().find(isClip) ?? null;
+ const nextClip = rest.slice(at).find(isClip) ?? null;
+ const lo = prevClip ? model.sectionOf.get(prevClip.id) : 0;
+ const hi = nextClip ? model.sectionOf.get(nextClip.id) : model.sections.length - 1;
+ let target = section === null || section === undefined || section === "" ? (prevClip ? lo : hi) : Number(section);
+ if (!hasDeck || !clipsMoved.length) target = prevClip ? lo : hi;
+ if (!Number.isInteger(target) || target < 0 || target >= model.sections.length) {
+ throw new Error(`section must be 0–${model.sections.length - 1} (§0 is before the first marker)`);
+ }
+ if (clipsMoved.length && hasDeck && (target < lo || target > hi)) {
+ const where = prevClip && nextClip ? `between ${prevClip.id} (${sectionWords(model.sections[lo])}) and ${nextClip.id} (${sectionWords(model.sections[hi])})` : prevClip ? `after ${prevClip.id} (${sectionWords(model.sections[lo])})` : `before ${nextClip.id} (${sectionWords(model.sections[hi])})`;
+ throw new Error(`a clip dropped ${where} cannot join ${sectionWords(model.sections[target])} — drop it inside that section, or move it there (section-move)`);
+ }
+ const membership = new Map(model.sectionOf);
+ const fromSections = Object.fromEntries(clipsMoved.map((id) => [id, membership.get(id)]));
+ for (const id of clipsMoved) membership.set(id, target);
+ // A section strictly between lo and hi other than the target would be left with no clip.
+ rest.splice(at, 0, ...moved);
+ const beforeOrder = tl.map((e) => e?.id).join("\n");
+ m.timeline.splice(0, m.timeline.length, ...rest);
+ const reanchored = hasDeck ? reanchorMarkers(m, model, membership) : [];
+ const changed = beforeOrder !== m.timeline.map((e) => e?.id).join("\n");
+ if (!changed && !reanchored.length) {
+ throw new Error(`${want.join(", ")} already ${want.length === 1 ? "stands" : "stand"} there${hasDeck && clipsMoved.length ? ` in ${sectionWords(model.sections[target])}` : ""}`);
+ }
+ return {
+ ids: moved.map((e) => e.id),
+ before: b,
+ from: fromIndex,
+ to: m.timeline.findIndex((e) => e?.id === want[0]),
+ section: hasDeck && clipsMoved.length ? target : null,
+ label: hasDeck && clipsMoved.length ? model.sections[target].label : null,
+ fromSections,
+ reanchored,
+ };
+}
+
+/**
* NEW SECTION HERE: a marker right after clip `afterId`, so the clips after it
* (to the next boundary) are a section of their own, labelled and coloured.
*
diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs
@@ -13,6 +13,7 @@
// [--id ID] [--section N] [--lock] [--lock-end]
// [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]
// umtool timeline <project> move <id> --to <index>
+// umtool timeline <project> place <id…> --before <id|-> [--section N]
// umtool timeline <project> remove <id> | duplicate <id>
// umtool timeline <project> post <json|@file> | post-remove <id>
// umtool timeline <project> teaser <id> <patch-json|@file>
@@ -57,6 +58,7 @@ import {
insertEntry,
manifestToken,
moveEntry,
+ placeEntries,
moveSectionBoundary,
moveToSection,
addSection,
@@ -85,6 +87,10 @@ export const TIMELINE_USAGE = [
" Under the deck --title is the deck's title (onscreen.title); a cut whose deck titles",
" are dates gets --date as one too. The section is <id>'s unless --section says",
" umtool timeline <project> move <id> --to <index> <index> is its place AFTER the move (0 first)",
+ " umtool timeline <project> place <id> [<id>…] --before <id|-> [--section N] Play's drag on the reel strip:",
+ " before that entry (`-`: at the end), the clips joining section N (default: the section",
+ " of the clip they land after); every other clip keeps its section, the markers follow,",
+ " an emptied section is refused; each place is its own undo point",
" umtool timeline <project> remove <id> | duplicate <id> (--at <index> names one of an id's twins)",
" umtool timeline <project> reject <id> <why> [--note TEXT] reject it and remove it, on the record (removed.json):",
` <why> is ${REJECT_REASON_IDS.join("|")} -- not-matching and wrong-speaker are fact`,
@@ -115,8 +121,8 @@ export const TIMELINE_USAGE = [
].join("\n");
const SECTION_VERBS = ["sections", "section-move", "section-add", "section-boundary", "section-remove", "section-set"];
-const VERBS = ["ls", "insert", "move", "remove", "reject", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo", ...SECTION_VERBS, "split", "flash-forward"];
-const VALUED = new Set(["--after", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note", "--to-section", "--label", "--color"]);
+const VERBS = ["ls", "insert", "move", "place", "remove", "reject", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo", ...SECTION_VERBS, "split", "flash-forward"];
+const VALUED = new Set(["--after", "--before", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note", "--to-section", "--label", "--color"]);
/** What `--take <id>` does on a take's timeline (takeEdit.mjs): the walk's structure and its undo. */
const TAKE_VERBS = ["ls", "move", "remove", "undo"];
@@ -456,6 +462,14 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) =>
({ result, editNotes } = await write((token) => removeEntry(project.dir, id, { token, at })));
break;
}
+ case "place": {
+ if (!rest.length) throw new CliError("place needs one or more entry ids");
+ const before = flags.get("--before");
+ if (typeof before !== "string" || !before) throw new CliError("place needs --before <id> (`-`: at the end)");
+ const section = intFlag(flags, "--section");
+ ({ result, editNotes } = await write((token) => placeEntries(project.dir, rest, { token, before: before === "-" ? null : before, section })));
+ break;
+ }
case "reject": {
const id = need(rest[0], "a clip id");
const why = need(rest[1], `why: ${REJECT_REASON_IDS.join(", ")}`);
@@ -683,6 +697,8 @@ function summaryOf(verb, r, attribution) {
}
case "move":
return `moved ${r.id}: ${r.from} -> ${r.to}`;
+ case "place":
+ return `placed ${r.ids.join(", ")} ${r.before ? `before ${r.before}` : "at the end"} (index ${r.from} -> ${r.to})${r.section !== null ? ` in §${r.section}${r.label ? ` (${r.label})` : ""}` : ""}`;
case "remove":
return `removed ${r.id} (was at ${r.at})`;
case "wrong-speaker":