Open source CapCut alternative.
TypeScript
feat(site): the assistant knows every safe zone without a guide on
David Lef48b94bd69c9
diff --git a/site/src/cut/components/TopBar.tools.ts b/site/src/cut/components/TopBar.tools.tsindex 54fbd472..d782fab8 100644--- a/site/src/cut/components/TopBar.tools.ts+++ b/site/src/cut/components/TopBar.tools.ts@@ -18,7 +18,7 @@ export const TOP_BAR_TOOLS = [{name: "set_guides",description:- `Choose the guides drawn over the preview — lines and shaded keep-out regions that show where titles, stickers and captions can sit. They draw in the editor only and never export. Presets: ${GUIDE_PRESETS.map((p) => `${p.id} (${p.name}${p.sublabel ? `, ${p.sublabel.toLowerCase()}` : ""})`).join(", ")}. The short-form preset shades the phone UI of TikTok, Instagram Reels and YouTube Shorts merged — top bar, right-hand action rail, bottom caption block — and fits portrait frames. The custom preset draws the user's own lines, which they drag on the preview; \`lines\` writes that list (frame fractions: v is x positions, h is y) and turns custom on. \`show\` replaces the whole set; [] turns every guide off. editor_state project.guides then reports the set with the safeArea it leaves and the custom lines.`,+ `Choose the guides drawn over the preview — lines and shaded keep-out regions that show where titles, stickers and captions can sit. They draw in the editor only and never export. Presets: ${GUIDE_PRESETS.map((p) => `${p.id} (${p.name}${p.sublabel ? `, ${p.sublabel.toLowerCase()}` : ""})`).join(", ")}. The short-form preset shades the phone UI of TikTok, Instagram Reels and YouTube Shorts merged — top bar, right-hand action rail, bottom caption block — and fits portrait frames. The custom preset draws the user's own lines, which they drag on the preview; \`lines\` writes that list (frame fractions: v is x positions, h is y) and turns custom on. \`show\` replaces the whole set; [] turns every guide off. Placement never needs a guide on: editor_state project.safeZones already carries every preset's safe area for the frame. project.guides reports what shows and the custom lines.`,inputSchema: obj({show: {diff --git a/site/src/cut/lib/aiContext.ts b/site/src/cut/lib/aiContext.tsindex 1910355e..3f911e68 100644--- a/site/src/cut/lib/aiContext.ts+++ b/site/src/cut/lib/aiContext.ts@@ -1,6 +1,6 @@"use client";-import { guideGeometry, safeAreaOf } from "./guides";+import { GUIDE_PRESETS, guideFits, guideGeometry, safeAreaOf } from "./guides";import { hasOverlayAnim, retimeOf, speedCurveOf, type ClipSound, type SpeedNode } from "@donkeycut/effects-kit";import { chatOwner } from "./chatAssets";import { useGenerate } from "./generate";@@ -233,21 +233,29 @@ export function buildAiContext(opts?: { fullCues?: boolean; chatId?: string | nu...(s.fadeIn > 0 ? { fadeIn: r(s.fadeIn) } : {}),...(s.fadeOut > 0 ? { fadeOut: r(s.fadeOut) } : {}),background: s.background,- // The guides showing on the preview, with the room they leave for- // graphics: safeArea and keepOut are frame fractions (x, y, w, h).+ // Every guide preset's safe area for this frame, whether or not it+ // shows, so placement can respect a platform's UI without a guide on:+ // safeArea and keepOut are frame fractions (x, y, w, h).+ safeZones: Object.fromEntries(+ GUIDE_PRESETS.filter((p) => p.id !== "custom" && guideFits(p.id, s.aspect)).flatMap((p) => {+ const safeArea = safeAreaOf([p.id], s.aspect);+ if (!safeArea) return [];+ const keepOut = guideGeometry([p.id], s.aspect).boxes.map((b) => ({+ label: b.label,+ x: r(b.x),+ y: r(b.y),+ w: r(b.w),+ h: r(b.h),+ }));+ return [[p.id, { safeArea, ...(keepOut.length ? { keepOut } : {}) }]];+ })+ ),+ // The guides showing on the preview and the user's own lines....(s.guides.length > 0? {guides: {on: s.guides,- safeArea: safeAreaOf(s.guides, s.aspect),...(s.guides.includes("custom") ? { customLines: s.guideLines } : {}),- keepOut: guideGeometry(s.guides, s.aspect).boxes.map((b) => ({- label: b.label,- x: r(b.x),- y: r(b.y),- w: r(b.w),- h: r(b.h),- })),},}: {}),diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex de4da6dc..48a73b4e 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -1,6 +1,6 @@"use client";-import { GUIDE_IDS, isGuideId, safeAreaOf, sanitizeGuideLines, type GuideId } from "./guides";+import { GUIDE_IDS, isGuideId, sanitizeGuideLines, type GuideId } from "./guides";import {ALL_EFFECT_IDS,autoGradeFromImageData,@@ -3801,7 +3801,6 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {const after = useEditor.getState();return {guides: after.guides,- safeArea: safeAreaOf(after.guides, after.aspect),...(after.guides.includes("custom") ? { customLines: after.guideLines } : {}),};},diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.tsindex baa189cd..39fd831f 100644--- a/site/src/cut/server/ai/catalog.ts+++ b/site/src/cut/server/ai/catalog.ts@@ -407,7 +407,7 @@ Rules:- Keep replies short and concrete — one or two sentences. When the work is done: state what changed, in terms your tool results confirm, and end there. You may close with at most one suggestion, phrased as a statement ("A 0.5s crossfade on the middle cut would smooth the jump."); a suggestion the user has already passed on stays retired. A question belongs in a reply only when the request is genuinely ambiguous or you are blocked. The same cadence holds for answers in chat: give the answer and stop — no trailing offer, no "would you like me to", no "let me know if". You have no name and never name the app; a message that asks for nothing (a greeting, thanks) gets a short "How can I help?" / "What would you like to do?" back — words alone, no tool calls. No headings, no fluff, and never paste the editor_state snapshot or raw JSON back — say what it means in plain words (a failed render: name the error and offer to retry).- Edits are undoable (unlimited undo), so prefer doing over asking; only ask when the request is genuinely ambiguous. Ambiguous means the target itself is unresolvable — "shorten that clip" with nothing selected and several clips gets "Which clip?" and no edit; guessing a target and editing it is worse than the question. The existing cut is the user's work: adding media adds — never delete, trim, or reorder a timeline clip unless the user said to. Read "change it / make it X / try again / closer to the original" as a fresh take that lands on its own card beside the old, never as license to delete the old clip first; only an explicit "replace / delete / remove this" clears what's already there. Items you placed yourself while working the current ask are your own scaffolding: revise, retime, or delete them freely until the result matches the ask — tearing down your own misstep and rebuilding is part of doing the job. The guardrail covers the user's media and the settled work of earlier turns. Generation is different: undo removes the clip but the credits stay spent, so be certain the user asked for the media before calling a generation tool. Removing media is different too — delete_asset and library_organize deletes don't come back with undo, so they take an explicit ask naming the media.- Times are seconds. The frame follows project.aspect in editor_state — any "W:H" ratio, short side 1080px; project.frame has the exact pixels. The frame is the user's setting: work within the shape they chose, and change it only when they ask for a different one. A generation that renders in another shape letterboxes inside their frame — mention that if it matters, and leave the choice to them.-- When project.guides carries a safeArea, keep every title, sticker and caption inside it (frame fractions, x/y/w/h) and out of the keepOut boxes — that is where the platform draws its own UI over the video. Turn the short-form guide on with set_guides when the user names a platform they are posting to or asks to see the safe zone; guides are a view, so showing one changes nothing in the cut.+- project.safeZones in editor_state gives, for this frame, the safe area of every guide preset (frame fractions, x/y/w/h) and the keepOut boxes where TikTok, Reels and Shorts draw their own UI — known whether or not a guide shows. When the user names a platform, asks for a safe zone, or wants graphics kept clear of the app's UI, place every title, sticker and caption inside safeZones.shortform.safeArea and check with capture_frame; safeZones.margins is the general 5% inset. Guides are a view: set_guides shows one when the user asks to see it, and showing one changes nothing in the cut.- 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.- 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.- 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.