Open source CapCut alternative.
TypeScript
feat(site): text runs come out plain unless a look is asked for
David Le130617b04c4d
diff --git a/site/src/cut/components/Timeline.tools.ts b/site/src/cut/components/Timeline.tools.tsindex dde58002..4d233238 100644--- a/site/src/cut/components/Timeline.tools.ts+++ b/site/src/cut/components/Timeline.tools.ts@@ -205,14 +205,14 @@ export const TIMELINE_TOOLS = [{name: "add_text_sequence",description:- "Place a run of text on the timeline in one call — a lyric video, a kinetic-typography passage, a quote sequence — composed by a named look. `look` carries the design of one line (frame color, cards, type, entrance) AND the ensemble the run walks across its whole length: where successive lines land, which faces they rotate through, which entrances, and what each line does while it holds. So one call already produces a varied, composed run; it never lays a hundred identical lines at dead center. Lines come from `lines` ({text, start, end} in timeline seconds), or from the caption track with from_captions when a sync already timed them. Mark the loud lines with `emphasis: \"hero\"` and the quiet ones `\"whisper\"`, and label passages with `section` (\"verse\", \"chorus\") — a new section restarts the type and color rotas, so a chorus does not look like the verse before it. Anything you set per line (font, x/y, rotation, in_style, move, color, size) wins over the ensemble. The words land on `lane` and each card on the row under them. It sets the project background to the look's frame color unless background is false. Look ids, layouts and moves are in the text-videos and text-creativity skills.",+ "Place a run of text on the timeline in one call — plain lines timed to speech, a lyric video, a kinetic-typography passage, a quote sequence. Design is opt-in: with no `look` the run comes out plain — one readable face, one place in the frame, a short fade, no cards, no moves, and the project's frame color untouched. That is what a bare \"add the text\" or \"put the words on screen\" asks for. Name a `look` when the user asked for a designed run (a lyric video, kinetic type, a style, a vibe, \"make it interesting\"): `look` carries the design of one line (frame color, cards, type, entrance) AND the ensemble the run walks across its whole length: where successive lines land, which faces they rotate through, which entrances, and what each line does while it holds. So one such call already produces a varied, composed run without a hundred repair calls after it. Lines come from `lines` ({text, start, end} in timeline seconds), or from the caption track with from_captions when a sync already timed them. In a designed run, mark the loud lines with `emphasis: \"hero\"` and the quiet ones `\"whisper\"`, and label passages with `section` (\"verse\", \"chorus\") — a new section restarts the type and color rotas, so a chorus does not look like the verse before it. Anything you set per line (font, x/y, rotation, in_style, move, color, size) wins over the ensemble. The words land on `lane` and each card on the row under them. A look that paints a frame color sets the project background to it unless background is false; the plain and over-footage looks leave the background alone unless background is true. Look ids, layouts and moves are in the text-videos and text-creativity skills.",inputSchema: obj({- look: str("Look id from the text-videos skill (default lyric-card)"),+ look: str("Look id from the text-videos skill. Omit it for the plain run — that is the default and the right answer whenever the user did not ask for a design."),variation: {type: "string",enum: [...TEXT_VARIATION_IDS],description:- "How far the run departs from one repeated design. bold (default) walks the look's whole ensemble — faces, tilts, palette, keyframe moves; subtle keeps one typeface and varies placement and entrance; none lays every line identical, for a run you intend to hand-compose.",+ "How far the run departs from one repeated design. Defaults to what the look carries: the plain look runs at none, the designed looks at bold. bold walks the look's whole ensemble — faces, tilts, palette, keyframe moves; subtle keeps one typeface and varies placement and entrance; none lays every line identical.",},layout: {type: "string",diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex 4cfe89f2..3672622d 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -100,7 +100,7 @@ import {type TextLayout,type TextVariation,} from "./textCompose";-import { requireTextLook } from "./textLooks";+import { requireTextLook, type TextLook } from "./textLooks";import {MOVE_STRENGTH_MAX,MOVE_STRENGTH_MIN,@@ -1469,11 +1469,11 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {const variation: TextVariation =input.variation === "none" || input.variation === "subtle" || input.variation === "bold"? input.variation- : "bold";+ : (look.defaultVariation ?? "bold");if (typeof input.layout === "string" && !TEXT_LAYOUT_IDS.includes(input.layout as TextLayout))throw new ToolError(`Unknown layout. Use one of: ${TEXT_LAYOUT_IDS.join(", ")}.`);const layout = typeof input.layout === "string" ? (input.layout as TextLayout) : undefined;- if (input.background !== false) s.setBackground(look.frame.background);+ if (paintsFrame(look, input.background)) s.setBackground(look.frame.background);// Row 0 is the front of the element stack, so the words take the row the// caller named and each card goes one row under them. Cards over words// would paint the line out.@@ -1550,7 +1550,9 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {note:cards.length > 0? `Words on row ${lane} with their cards on row ${cardLane} behind them, colors cycling ${look.frame.cards.join(" \u2192 ")}.`- : `Words on row ${lane} over the ${look.frame.background} frame.`,+ : look.keepsFrame+ ? `Words on row ${lane} over the cut as it already looks; the frame color is untouched.`+ : `Words on row ${lane} over the ${look.frame.background} frame.`,};},@@ -1564,7 +1566,7 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {if (look.captions.font) patch.font = look.captions.font;if (look.captions.accentColor) patch.accentColor = look.captions.accentColor;if (look.captions.accentMode) patch.accentMode = look.captions.accentMode;- if (input.background !== false) s.setBackground(look.frame.background);+ if (paintsFrame(look, input.background)) s.setBackground(look.frame.background);}if (typeof input.style === "string") {if (!(input.style in CAPTION_STYLES))@@ -1628,7 +1630,7 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {...(look.captions.accentColor ? { accentColor: look.captions.accentColor } : {}),...(look.captions.accentMode ? { accentMode: look.captions.accentMode } : {}),});- if (input.background !== false) st.setBackground(look.frame.background);+ if (paintsFrame(look, input.background)) st.setBackground(look.frame.background);}const heardWords = cueWords(cues).length;return {@@ -3179,6 +3181,14 @@ function cueWords(cues: { start: number; end: number; text: string; words?: Timeparts.forEach((w, i) => out.push({ w, t0: c.start + step * i, t1: c.start + step * (i + 1) }));}return out;+/** Whether dressing the project in this look repaints the frame color. A look+ * that keeps the frame only repaints it when the caller asked for it in so+ * many words — adding words to a cut is not a reason to recolor it. */+function paintsFrame(look: TextLook, background: unknown): boolean {+ if (typeof background === "boolean") return background;+ return look.keepsFrame !== true;+}+}/** The lines a text sequence should place: the ones passed in, or the captiondiff --git a/site/src/cut/lib/textLooks.ts b/site/src/cut/lib/textLooks.tsindex bd728bf5..9bad0c38 100644--- a/site/src/cut/lib/textLooks.ts+++ b/site/src/cut/lib/textLooks.ts@@ -1,5 +1,5 @@import type { OverlayAnimStyle, OverlayLoopStyle, WordAccentMode } from "@donkeycut/effects-kit";-import type { TextEnsemble } from "./textCompose";+import type { TextEnsemble, TextVariation } from "./textCompose";import type { CaptionStyleId, FontId } from "./types";/**@@ -23,6 +23,14 @@ export interface TextLook {* `cards` are full-frame color cards a sequence cycles through, one per* line; empty means the words sit straight on the frame or on footage. */frame: { background: string; cards: string[] };+ /** This look leaves the project's frame color alone — the words ride over+ * whatever is already there. A caller can still repaint it by asking for+ * the background explicitly. */+ keepsFrame?: boolean;+ /** How far a run in this look departs from one repeated design when the+ * caller names no variation. Absent = `bold`, the designed looks' whole+ * ensemble; `plain` sits at `none` so an unstyled ask stays unstyled. */+ defaultVariation?: TextVariation;/** The type. `onCards` is the text color per card color, index-matched to* `frame.cards`; without cards, `color` carries every line. */text: {@@ -75,6 +83,35 @@ export interface TextLook {}export const TEXT_LOOKS: Record<string, TextLook> = {+ plain: {+ id: "plain",+ label: "Plain",+ when: "One clean sans line low in the frame, white with a shadow, a short fade in and out. The look for text the user asked for without asking for a design — same face, same place, same entrance on every line, no cards, and the frame color untouched.",+ frame: { background: "#000000", cards: [] },+ keepsFrame: true,+ defaultVariation: "none",+ text: {+ font: "sf",+ size: 72,+ weight: 700,+ color: "#FFFFFF",+ lineHeight: 1.25,+ shadow: true,+ x: 0.5,+ y: 0.78,+ widthRatio: 0.52,+ },+ accent: "#FFFFFF",+ motion: { in: { style: "fade", seconds: 0.25 }, out: { style: "fade", seconds: 0.2 } },+ ensemble: {+ faces: [{ font: "sf", weight: 700 }],+ motion: ["fade"],+ layout: "center",+ moves: ["none"],+ },+ captions: { style: "clean", wordHighlight: false },+ },+"lyric-card": {id: "lyric-card",label: "Lyric cards",@@ -276,6 +313,7 @@ export const TEXT_LOOKS: Record<string, TextLook> = {label: "Over footage",when: "No cards at all — heavy outlined white type over whatever is playing. The look for words on the user's own video.",frame: { background: "#000000", cards: [] },+ keepsFrame: true,text: {font: "anton",size: 96,@@ -447,7 +485,10 @@ export const TEXT_LOOKS: Record<string, TextLook> = {export const TEXT_LOOK_IDS = Object.keys(TEXT_LOOKS);-export const DEFAULT_TEXT_LOOK = "lyric-card";+/** The look a run takes when the caller named none. Plain: a design is+ * something the user asks for, so an unasked run comes out as one readable+ * face where it was put. */+export const DEFAULT_TEXT_LOOK = "plain";export function textLook(id: string | undefined): TextLook {return TEXT_LOOKS[id ?? ""] ?? TEXT_LOOKS[DEFAULT_TEXT_LOOK];@@ -471,5 +512,6 @@ export const textLookCatalog = (): string =>TEXT_LOOK_IDS.map((id) => {const l = TEXT_LOOKS[id];const cards = l.frame.cards.length > 0 ? `cards ${l.frame.cards.join("/")}` : "no cards";- return `- ${l.id} (${l.label}): ${l.when} Frame ${l.frame.background}, ${cards}; ${l.text.font} ${l.text.size}px; ${l.motion.in?.style ?? "no"} in; captions ${l.captions.style}${l.captions.wordHighlight ? " + karaoke" : ""}.`;+ const frame = l.keepsFrame ? "Frame untouched" : `Frame ${l.frame.background}`;+ return `- ${l.id} (${l.label}): ${l.when} ${frame}, ${cards}; ${l.text.font} ${l.text.size}px; ${l.motion.in?.style ?? "no"} in; ${l.defaultVariation ?? "bold"} by default; captions ${l.captions.style}${l.captions.wordHighlight ? " + karaoke" : ""}.`;}).join("\n");diff --git a/site/src/cut/lib/textVideo.test.ts b/site/src/cut/lib/textVideo.test.tsindex 3c1e1ef7..e333a4f5 100644--- a/site/src/cut/lib/textVideo.test.ts+++ b/site/src/cut/lib/textVideo.test.ts@@ -53,6 +53,30 @@ describe("add_text_sequence", () => {expect(useEditor.getState().background).toBe(look.frame.background);});+ test("a run nobody asked to design comes out plain and leaves the cut alone", async () => {+ useEditor.setState({ background: "#123456" });+ await runAiTool("add_text_sequence", {+ lines: [+ { text: "first line", start: 0, end: 2 },+ { text: "second line", start: 2, end: 4 },+ { text: "third line", start: 4, end: 6 },+ ],+ });+ const words = overlays().filter(isTextOverlay);+ expect(overlays().filter(isShapeOverlay)).toHaveLength(0);+ expect(words).toHaveLength(3);+ // One face, one place, one entrance, no keyframe moves, no tilt.+ expect(new Set(words.map((w) => w.font)).size).toBe(1);+ expect(new Set(words.map((w) => w.y)).size).toBe(1);+ expect(new Set(words.map((w) => w.x)).size).toBe(1);+ expect(new Set(words.map((w) => w.color)).size).toBe(1);+ expect(words.every((w) => (w.rotation ?? 0) === 0)).toBe(true);+ expect(words.every((w) => !w.kf || w.kf.length === 0)).toBe(true);+ expect(words.every((w) => w.anim?.in?.style === "fade")).toBe(true);+ // The frame color is the user's, not the look's.+ expect(useEditor.getState().background).toBe("#123456");+ });+test("a look with no cards puts the words straight on the frame", async () => {await runAiTool("add_text_sequence", {look: "over-footage",diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.tsindex 72e4cfec..0f56aa67 100644--- a/site/src/cut/server/ai/catalog.ts+++ b/site/src/cut/server/ai/catalog.ts@@ -166,7 +166,7 @@ What the user sees on the transitions row: one badge per bar, and nothing elseThe title lanes hold three overlay element kinds, all sharing timing (start/end), center position (x/y fractions 0..1), rotation (degrees), opacity, and a lane; \`overlays\` in editor_state lists them with their \`kind\`. All burn into the export exactly as previewed.Rows are how elements stack (\`lane\`, 0 = the front row; a higher row draws further back). Two elements on ONE row never overlap in time — placing a title where a shape already sits slides it clear instead of laying it on top — so anything meant to sit over something else names a LOWER row: title on lane 0, the background shape behind it on lane 1. Every add tool and update_overlay take \`lane\`.The frame's own color is set_background, not a full-frame rectangle: it fills the frame behind every clip and element, holds for the whole cut, letterboxes fitted footage, and shows through gaps on track 0. "Make the background white", a colored card behind a title sequence, a text-and-graphics video with no footage at all — all of them start with set_background. A rectangle element is for a panel or a band inside the frame, not for the frame itself.-A whole run of text — a lyric video, a kinetic-typography passage, a quote sequence — is add_text_sequence, one call carrying a named look. A look is the design of the whole run, not one line: the frame color, the cards, and the ensemble the run walks across its length — faces, entrances, where successive lines land, and what each holds. Read the text-videos skill for the looks and the flow, and text-creativity for the fifty devices that keep a long run from reading flat. Never lay a run of identical centered lines and then repair it element by element. A video needs no footage. Titles, shapes and stickers over a background color are a complete cut on their own: it plays, exports, and shares like any other. Build one by setting the background, then placing elements on the rows the stack needs — reach for footage only when the user asks for it.+A whole run of text — lines timed to speech, a lyric video, a kinetic-typography passage, a quote sequence — is add_text_sequence, one call. Design is opt-in: called with no look it lays a plain run — one readable face, one place in the frame, a short fade, no cards, no keyframe moves, the frame color untouched — which is what a bare "add the text" asks for. Name a look when the user asked for a designed run, and then the look is the design of the whole run, not one line: the frame color, the cards, and the ensemble the run walks across its length — faces, entrances, where successive lines land, and what each holds. Read the text-videos skill for the looks and the flow, and text-creativity for the fifty devices that keep a long run from reading flat. A designed run is composed in the call, never laid identical and then repaired element by element. A video needs no footage. Titles, shapes and stickers over a background color are a complete cut on their own: it plays, exports, and shares like any other. Build one by setting the background, then placing elements on the rows the stack needs — reach for footage only when the user asks for it.Titles (add_title / update_overlay): text, size (frame px; the design short side is 1080), font (${FONTS.map((f) => `${f.id}=${f.label}`).join(", ")}), weight (400/700), color, shadow, plate (translucent dark backdrop).Shapes (add_shape): rect, ellipse, line, arrow. w/h are frame fractions; rect/ellipse take fill + fill_opacity, corner radius (rect), and an outline (stroke_color/stroke_width); line/arrow draw in \`fill\` with h as their thickness, and rotation gives them their direction (0° points right, 90° points down).Stickers (add_sticker): a project image asset (generated cutouts in the Elements panel carry origin "sticker"); w is a frame-width fraction and height follows the source's aspect. Lottie JSON uploads become animated stickers that loop for the element's duration.@@ -190,9 +190,11 @@ In the UI: the timeline toolbar adds Text; the Elements side-panel tab browses s"text-videos": `# Text-driven videos: lyrics, kinetic type, quote cardsA video whose picture is words. Three pieces: the frame behind them (set_background, or the user's footage), the words themselves, and the clock that says when each line lands. For the device list — fifty ways to make a run of text worth watching — read the text-creativity skill.+**Design is something the user asks for.** "Add the text", "put what he says on screen", "add text from the audio" is a plain job: get the words and their times — the cues already in editor_state, a source's transcript, listen_audio, or subtitles_generate when the user wants a caption track — then place them with add_text_sequence and no \`look\`. That lays one readable face at one spot with a short fade, no cards, no keyframe moves, no tilts, and no repaint of the frame. Then align_to_audio: the times you placed came from a transcript, and that pass measures them against the mix's own waveform and moves each edge onto the speech. Reach for a look, cards, moves, or a variation only when the ask carries a design in it: a lyric video, kinetic type, a named style or vibe, "make it fun", a reference to match. A cut that comes back restyled when the user asked for words on screen is the failure this default exists to prevent.+**Two ways to carry the words.** A caption track is one styled row of text that follows a voice — it holds word timings, so karaoke (each word lighting as it is sung) is only possible here, and one call restyles every line. Elements are separate titles and cards on the timeline — per-line face, per-line placement, per-glyph motion, a color card behind each line — which is what kinetic typography and lyric cards are made of. Captions for a song you want to sing along to; elements when each line is its own picture. Both burn into the export.-**The looks.** A look is not one line's styling — it is the design of a whole run. It sets the frame color, the cards it cycles, the type, the entrance, the caption equivalent, AND the ensemble the run walks across its length: the faces it rotates through, the entrances, where successive lines land, and what each line does while it holds. So one add_text_sequence call already produces a composed, varied run:+**The looks.** A look is opt-in, and it is not one line's styling — it is the design of a whole run. It sets the frame color, the cards it cycles, the type, the entrance, the caption equivalent, AND the ensemble the run walks across its length: the faces it rotates through, the entrances, where successive lines land, and what each line does while it holds. So one add_text_sequence call already produces a composed, varied run:${textLookCatalog()}**Composing a run (this is the part that decides whether it reads as creative).** add_text_sequence takes the whole run in one call and walks the look's rotas by index, so no two neighbouring lines land the same. Steer it:@@ -332,7 +334,7 @@ How to decide the details the user left open. Make the call, apply it, and state- One transition family per video. Pick the style that fits the footage (crossfade for calm, a push or crosszoom for energy, dipblack for a chapter turn) and repeat it at every styled joint; mixed families read as indecision. 0.4–0.6s is the working range — long enough to register, short enough to keep pace.- Pace lives in the trims. Cut into motion and out of stillness: start a clip after the camera settles, end it before the action dies. Shots that hold one composition past ~4s want trimming or a speed-up; a beat of black between chapters is a choice, and inside a chapter it is a hole.- Sound sits under the picture. Music beds stay low with speech ducked over them; a fade-out at the end of the video beats a hard stop. Match the music's energy to the footage's pace.-- One treatment at a time. A single look, one accent element per scene, effect amounts under 0.5. Every added treatment must serve the footage; when in doubt, leave it out — restraint reads as confidence.+- One treatment at a time. A single look, one accent element per scene, effect amounts under 0.5. Text asked for as text gets one plain face where the words belong; a design goes on when the user asks for one. Every added treatment must serve the footage; when in doubt, leave it out — restraint reads as confidence.- "Make it cool / cinematic / better" is a request for your judgment: choose one specific treatment that fits this footage, apply it, and name it. A menu of options is an answer only when two readings genuinely diverge.`,"media-and-library": `# Media, Library & organizing@@ -367,6 +369,7 @@ Rules:- Exercise judgment on details the user left open, and state the choice you made. Judgment fills in the parameters of the asked-for change (style, length, placement); the scope stays the ask, and extra tools, tracks, or treatments beyond it wait for the user to ask. Editing defaults: a hard cut at every joint; when transitions are asked for, one style family per video at 0.4–0.6s. The editing-taste skill carries the full doctrine.- Read list_skills / read_skill before working in an area you're unsure about — they document every setting. A tool whose description already answers the ask goes straight through.- 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.+- 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, keyframe moves, karaoke highlights 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.- 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.