Skip to content

Open source CapCut alternative.

TypeScript

feat(cut): teach the sweep loop to the chat [rebuild]

David Le15572891b7ef
diff --git a/site/src/cut/lib/turnQuality.test.ts b/site/src/cut/lib/turnQuality.test.ts
index 28430ecf..4d4f7f65 100644
--- a/site/src/cut/lib/turnQuality.test.ts
+++ b/site/src/cut/lib/turnQuality.test.ts
@@ -311,6 +311,8 @@ describe("qualityVerdict", () => {
const verdict = qualityVerdict(answers({ finished: 0.2, closeness: "exact" }), blind, settings);
expect(verdict?.step).toBe("check");
expect(verdict?.steer).toContain("compare_to_source");
+ // The check starts with the sweep, which finds what to look at.
+ expect(verdict?.steer).toContain("sweep");
});
@@ -521,6 +523,22 @@ describe("recordLook", () => {
expect(looks.get("a1")!.unwatched).toBe(0);
});
+ test("a sweep counts the frames it scored", () => {
+ const looks = new Map<string, WatchedSource>();
+ recordLook(looks, "watch_video", {
+ source: { assetId: "a1", name: "reference.mp4", duration: 71.6, type: "video", sound: "yes" },
+ coveredTo: 71.6,
+ unwatchedSeconds: 0,
+ });
+ recordLook(looks, "compare_to_source", {
+ source: { assetId: "a1", name: "reference.mp4", duration: 71.6, type: "video", sound: "yes" },
+ mode: "sweep",
+ sampled: 120,
+ worst: [],
+ });
+ expect(looks.get("a1")!.compared).toBe(120);
+ });
+
test("a comparison alone opens no record, because it says nothing about coverage", () => {
const looks = new Map<string, WatchedSource>();
recordLook(looks, "compare_to_source", {
diff --git a/site/src/cut/lib/turnQuality.ts b/site/src/cut/lib/turnQuality.ts
index b82ffdb6..4280e64f 100644
--- a/site/src/cut/lib/turnQuality.ts
+++ b/site/src/cut/lib/turnQuality.ts
@@ -385,9 +385,10 @@ export function qualityVerdict(
// A replica nobody held up against the thing it copies. Watching measures
// what went in and the counts measure what came out; neither says the two
- // look alike. The number here is moments checked, and it is only asked of a
- // turn that wrote something down about the source and then made a picture to
- // hold up — so a comparison has something on both sides to compare.
+ // look alike. The number here is moments and swept frames checked, and it is
+ // only asked of a turn that wrote something down about the source and then
+ // made a picture to hold up — so a comparison has something on both sides to
+ // compare.
//
// Only the source the cut was copied from is owed one, and that is the one
// the turn read furthest into: a turn also picks shots out of the user's own
@@ -405,8 +406,8 @@ export function qualityVerdict(
step: "check",
steer:
`${QUALITY_STEER_PREFIX} Not yet. Nothing has been held up against "${unchecked.name}": you have what it does written down, and no look at whether the cut does it too. ` +
- "compare_to_source on it, a few moments at a time, spread across what you built — the source's frame and yours side by side. " +
- "Name what differs and fix it, then check the moments you changed." +
+ "compare_to_source on it with mode sweep, which scores every frame of the cut against the source and names the worst stretches; " +
+ "look at those in moments mode, fix what differs, and sweep again until the median is under its target." +
standing(work),
};
@@ -523,7 +524,8 @@ export function recordLook(
cur.kind = kind;
cur.sound = sound;
if (tool === "compare_to_source") {
- cur.compared += Array.isArray(response.checked) ? response.checked.length : 0;
+ // A picture call counts its moments, a sweep the frames it scored.
+ cur.compared += Array.isArray(response.checked) ? response.checked.length : numOf(response.sampled);
sources.set(id, cur);
return;
}
diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.ts
index c2d8e4c4..65c6c92b 100644
--- a/site/src/cut/server/ai/catalog.ts
+++ b/site/src/cut/server/ai/catalog.ts
@@ -13,6 +13,7 @@ import { EXPORT_RESOLUTIONS } from "@/cut/lib/exportPresets";
import { UI_TOOLS } from "@/cut/lib/projectCommands";
import { STOCK_SFX_CATEGORIES } from "@/cut/lib/stock";
import { SPLIT_EDIT_MAX_S } from "@/cut/lib/soundSource";
+import { SWEEP_TARGET } from "@/cut/lib/frameDiff";
import { builtinLutCatalogText } from "@/cut/lib/builtinLuts";
import { AI_PANEL_TOOLS } from "@/cut/components/AiPanel.tools";
import {
@@ -358,7 +359,7 @@ Someone points at a video — a file they imported, a link you brought in, a cli
**Then the motion.** set_overlay_keyframes gives each card its own pose track — where it sits, at what scale, at what second — which is how the timing lands on the reference's own frames. set_overlay_animation composes on top for the entrance, the exit, a loop, and what a line does while it holds; 0.3-0.6s reads as an entrance, and a per-letter style is what makes a card read as typed. add_shape is the rest of the graphics: bars, cards, rules, a block of color behind a line.
-**Look at what you made.** Watching told you what the reference does; it does not tell you whether what you made does it too, and a build that reads right from your own notes is still a guess until you see it. compare_to_source puts the source's frame and yours side by side at the same moment, a few at a time. Run it as you build, not once at the end: the first few shots, then each stretch as you finish it — an error in the first card is in every card after it. Spread the moments over what you laid down, including the middle of a move, and read each pair for colour, the words and their face, where a thing sits, its size, and how far along a move is. A title the same colour as the block behind it, or a shape covering the thing it was meant to sit beside, reads as correct in the document and is only visible here. Fix what differs, check the moments you changed, and keep going until a pass turns up nothing.
+**Look at what you made.** Watching told you what the reference does; it does not tell you whether what you made does it too, and a build that reads right from your own notes is still a guess until you measure it. compare_to_source does: mode sweep scores every frame of the cut against the source — 0 is the same picture, under ${SWEEP_TARGET} reads as one — and names the worst stretches with a grid of where each differs; mode moments shows those peaks beside the source's frames. Sweep as you build, since an error in the first card is in every card after it: look at the worst stretches, fix what differs, sweep again, and stop when the median is under ${SWEEP_TARGET} and no stretch stands out. A \`shift\` means the right thing lands early or late by that much. Read each picture for colour, the words and their face, where a thing sits, its size, and how far along a move is; a title the same colour as the block behind it reads as correct in the document and shows up here. A block keeps its footage's difference, so judge a shot by the cells over what you built.
**Say what plays.** Close by naming what fills the shots, and what you checked. A shell gets what to drop in: how many shots, how long each one runs, and that the titles and timing are built around them.`,
@@ -656,13 +657,13 @@ Rules:
- Styling is part of the ask, never a bonus. Words the user asked to put on screen — a title, the lines from the audio, a caption run — go on in one plain readable face at one place, timed to what they are for. Per-line typefaces, tilts, color cards, moves, word effects and a repainted frame are a design, and a design is something the user asks for: a lyric video, kinetic type, a named style or vibe, a reference to match, "make it fun". Call add_text_sequence with no \`look\` for the plain job, and leave the caption styling and the background as you found them.
- A skill attached to the message (<skill_relevance>) is the reference for its area: read it before touching that area's settings. It never changes which tool the ask maps to — the tool descriptions decide that ("a better version" is a render, whatever skill rode along). list_skills / read_skill cover an area the attachment left out.
- A reference image or clip the user attaches ("do this", "put our video in this style") carries one of two asks — decide which before acting. When its footage's look is the point (color, lighting, film grade), route to color grading — match_color_grade computes the grade from the reference's own pixels, then the grading tools refine (color-grading skill) — or to look effects or restyle when the reference is a stylized treatment. When it demonstrates an editing device — a tile grid, a mosaic reveal, a split layout, an animated title treatment — the ask is to construct that device on the user's own footage: read the graphics skill's composite-builds section and build it with overlay tracks, masks, and keyframes. Your tools compose into effects far beyond the preset lists, so reach for construction before declaring something out of reach. Construction is free and undoable; a whole-look re-render (restyle_scene) spends credits — when the reading is ambiguous, say what each path would do and let the user pick.
-- A video held up as a reference — a file they imported, a link you brought in, a clip on the timeline — is watched all the way through before anything is copied from it, then rebuilt out of this editor's parts: everything on the screen, every card of type, every shape, every colour and every move, at the time it happens. The footage inside the shots is the one thing you cannot rebuild — add_clip \`blocks\` holds each shot's place in the colour behind it, for the person to fill — and when they want the reference's own picture playing, add_clip \`spans\` lays its shots down instead. What you built is a guess until you look at it beside the thing it copies: compare_to_source holds the source's frame against yours at the same moment, and what differs gets fixed and checked again. The replicating-a-video skill has the flow.
+- A video held up as a reference — a file they imported, a link you brought in, a clip on the timeline — is watched all the way through before anything is copied from it, then rebuilt out of this editor's parts: everything on the screen, every card of type, every shape, every colour and every move, at the time it happens. The footage inside the shots is the one thing you cannot rebuild — add_clip \`blocks\` holds each shot's place in the colour behind it, for the person to fill — and when they want the reference's own picture playing, add_clip \`spans\` lays its shots down instead. What you built is a guess until you look at it beside the thing it copies: compare_to_source scores the cut against the source frame by frame and shows the worst moments side by side, and what differs gets fixed and checked again. The replicating-a-video skill has the flow.
- A Donkey Cut project link or share link the user gives you is a document: read it with read_project (the document is the edit — never watch a reference to learn what its document already states), decide which of this project's sources plays each of its parts from the reference's observed notes and transcripts (a reference look with watch_video's project_link where those leave it dark), then call replicate_project once — the whole edit, or only the items they asked for: a title, one clip's treatment, the music, the caption look — and tune from there. copy_project_media brings files over on their own. The replicating-a-project skill has the flow.
- Captions that sit off the speech are re-timed, never re-transcribed: align_to_audio measures the cut's own waveform and moves each edge onto the voice, on a caption track or on the elements of a text run. Re-transcribing to fix timing throws away the user's wording, and hand-retiming with update_cue guesses at what the audio already says.
- Transcription tools write tracks the user sees — run subtitles_generate / captions_generate only when captions were asked for, never just to read the words: existing cues are in editor_state, sources you have watched or listened to carry their own transcript (media entries marked speech: "transcribed"; get_state includes the timed segments), and audio plays to you via listen_audio. Don't transcribe a video with no speech (subtitles_from_visuals narrates silent footage), and never invent a spoken transcript.
- Voiceovers duck other audio by default so they stay audible. Steer a voiceover's delivery with \`direction\` and inline tags like [whispers] rather than rewriting the script.
- generate_image / generate_video / generate_character_video / voiceover_generate / read_subtitles_aloud / generate_music make media through hosted models (spends the user's Donkey credits, needs sign-in); call them when the user asked for the media itself — a request for the prompt or script gets text in chat. generate_music makes a music track — a vocal-free background bed by default ("add music to this video"), or a full sung song (instrumental:false); it's sung music, so a spoken narration is voiceover_generate. Bundled stock media (stock_search / stock_add) is free — use it when it fits. Media the user attached is in \`media\`; pass those asset ids as generation references when they say "use this", and place project assets in the cut with add_clip when they ask for them there ("make a movie from these photos"). Generated media previews on a chat card the user can expand, drag in, or file away; add it to the timeline (add_to_timeline:true or an index) only when they asked for it in the cut. When it lands on a card, close with a statement of where it is ("The voiceover is on the card — drag it in or tell me to place it."). Write a rich, specific prompt from their shorthand. Video renders take a minute or two. "Generate a video of/about X" means one generate_video clip; only when they name a narrated multi-shot production (a story, episode, narrated short) does generate_scene plan it and stop at the storyboard — the user reviews the frames (regenerate_shot redraws any before approval, no credits), then call approve_scene, since it renders many paid shots (regenerate_shot / recut_scene / restyle_scene revise it after). Close a plan message with the approval path as a statement: "Approve it — say so or hit Approve on the card — and I'll render the shots." Tweaks before approval are theirs to name.
-- You can see and hear: audio the user attaches to their message plays right in it — answer "what does this say" from what you hear, no tool call. For project footage, watch_video samples a source's frames into timestamped contact sheets (scene changes included) — watch before cutting footage you haven't seen, and write each look down with note_source — sheets are conversation-local, notes stay on the source; listen_audio plays a source's audio — an audio asset or a video/clip's own track, one stretch per call, with \`coveredTo\` and \`unheardSeconds\` saying how far it reached and what nobody has played (an ask about how a whole source sounds listens on from \`unheardFrom\` until that is 0); detect_silence finds dead air; find_highlights ranks the stretches of a long source worth clipping, from what is said over them; detect_beats reads the music's beat grid (persisted on the asset, drawn as dots on its clips, snapped to by every drag) for cutting to the music; capture_frame shows one rendered frame, at the time you pass or the playhead; compare_to_source puts that frame beside the source's own at the same moment, which is how work copied from something is checked against it. The watching-and-cutting skill has the flow.
+- You can see and hear: audio the user attaches to their message plays right in it — answer "what does this say" from what you hear, no tool call. For project footage, watch_video samples a source's frames into timestamped contact sheets (scene changes included) — watch before cutting footage you haven't seen, and write each look down with note_source — sheets are conversation-local, notes stay on the source; listen_audio plays a source's audio — an audio asset or a video/clip's own track, one stretch per call, with \`coveredTo\` and \`unheardSeconds\` saying how far it reached and what nobody has played (an ask about how a whole source sounds listens on from \`unheardFrom\` until that is 0); detect_silence finds dead air; find_highlights ranks the stretches of a long source worth clipping, from what is said over them; detect_beats reads the music's beat grid (persisted on the asset, drawn as dots on its clips, snapped to by every drag) for cutting to the music; capture_frame shows one rendered frame, at the time you pass or the playhead; compare_to_source scores the cut against the source it copies and shows the two side by side, which is how copied work is checked. The watching-and-cutting skill has the flow.
- A figure the video states — a number, date, price, name or release in the narration, a title or a caption — goes through check_facts before it goes on screen. Report every claim it does not support, with what the sources say and where, and leave the user's words as they wrote them until they ask.
- End on a statement. The final sentence of every reply states what changed, what failed, or the one suggestion you're making; "let me know if", "would you like", "do you want me to", and every other trailing offer or question are banned closers. The only question that may end a reply is the single clarifying one a genuinely ambiguous or blocked ask earns.`;
}