forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

help.rs2295 lines, 182.5 KiBHistoryRawDownload
1//! The agent's cheat sheet: the `edith://help` resource, the `help` tool, and the
2//! first lines of the initialize `instructions`. The tool list and the edit op
3//! list are read from the live tool table, so the sheet cannot drift from what
4//! the server accepts. The edit op manual is the `edit` tool's description, so the
5//! per-op entries are parsed from it rather than copied.
6
7use serde_json::{Value, json};
8
9use crate::server::{self, Reply, Server, Tool};
10
11/// The fixed topics, besides the edit op names and the tool names.
12const TOPICS: [&str; 20] = [
13 "ops",
14 "times",
15 "recipes",
16 "first_video",
17 "podcast",
18 "lanes",
19 "ripple",
20 "export",
21 "subtitles",
22 "captions",
23 "project",
24 "burn_captions",
25 "visualizer",
26 "looks",
27 "overlays",
28 "vertical",
29 "sequences",
30 "multicam",
31 "stretch",
32 "unsupported",
33];
34
35/// Tool groups in the order the sheet lists them. A registered tool that is in no
36/// group lands under `other`, and a test fails if that happens.
37const GROUPS: &[(&str, &[&str])] = &[
38 ("project", &["project_new", "templates", "project_open", "project_save", "project_collect", "project_export_timeline", "project_import_timeline", "project_status", "project_settings"]),
39 ("media", &["media_probe", "media_import", "media_list", "media_remove", "media_relink", "media_bin", "proxies"]),
40 ("look", &["timeline", "clip_info"]),
41 ("see", &["frame", "contact_sheet", "scopes"]),
42 ("scan", &["scenes", "stabilize_status", "track", "track_status"]),
43 ("hear", &["levels", "silence", "cut_silence", "loudness", "normalize", "clean_voice"]),
44 ("edit", &["edit", "sequence", "multicam_create", "multicam_flatten", "effect", "undo", "redo", "checkpoint", "restore", "checkpoints"]),
45 ("export", &["export_start", "export_presets", "export_status", "export_cancel", "export_queue", "export_captions", "render_preview"]),
46 ("listen", &["transcript", "find_words", "auto_captions", "speech_model"]),
47 ("captions", &["captions"]),
48 ("speak", &["voices", "voiceover"]),
49 ("record", &["record"]),
50 ("help", &["help"]),
51];
52
53/// The opening line of the sheet. Its topic list is `TOPICS`, so it cannot drift from what `section` answers.
54fn header() -> String {
55 format!(
56 "edith help: one page for driving the editor over MCP. Tool descriptions carry the full argument lists. Topics: {}.",
57 TOPICS.join(", ")
58 )
59}
60
61const ADDRESSES: &str = "\
62ADDRESSES
63 V1@450 clip: the clip on lane V1 that starts at frame 450 (starts are unique in a lane)
64 V1#0 clip by index, 0-based: V1#0 is the first clip on V1, V1#2 the third; resolved at once, so do not hold it across edits
65 V1 A1 S1 lanes, named as the GUI names them (S1 holds captions)
66 src:2 a source, as media_import reports it (src:2 interview_a.mp4)
67 C@450 / C#1 chapter: C@450 the chapter that starts at frame 450, C#1 the first chapter in the list
68 M@450 / M#1 comment marker: M@450 the first marker on frame 450, M#1 the first marker in the list
69 Every edit reply lists the NEW addresses of what it touched. Use those, not old ones.
70 Addresses in one batch refer to the timeline as the previous op left it.";
71
72const TIMES: &str = "\
73TIMES
74 450f frames (the model works in frames; replies show 450f (15.000s))
75 15.0s or 15 seconds
76 00:00:15:00 timecode at the project fps, HH:MM:SS:FF
77 02:14.300 minutes, seconds, milliseconds (MM:SS.fff)
78 end the end of the timeline: the latest end of any lane, not the end of one lane
79 Seconds round to the nearest frame: 2.5 s at 25 fps is frame 63 (62.5 rounds up).
80 A distance (`by` of roll, slip and slide) takes these forms with a sign: -15f, +0.5s, -00:00:01:00. A bare number is seconds.";
81
82const VALUES: &str = "\
83VALUES
84 color: brightness -1..1 (0 is none), contrast 0..2 (1 is none), saturation 0..2 (1 is none), tint -1..1 (0 is none)
85 gain db -60..24 · lane_gain db -60..12 · speed 0.25..4
86 A still image is placed 5 s long unless the project says otherwise (project_settings still_secs, 0.5 to 600 s), and a trim can take it up to 600 s.";
87
88const GROUPS_AND_LINKS: &str = "\
89GROUPS AND LINKS
90 Clips that share a link (a take, such as V1+A1) are one unit in the GUI.
91 The ops tagged [group] follow the whole take: trim, roll, slip, slide, move, delete, speed, sub_move. trim scope:\"clip\" unlinks the edge's clip first.
92 fade, dissolve and transition reach the linked sound too (linked:false keeps them on the one clip).
93 Every other op acts on the one clip alone: lift leaves a gap on that clip's lane only. group and ungroup set and clear a take.";
94
95const UNDO: &str = "\
96UNDO
97 One edit call is one undo step. Its ops run in order; if one fails, the earlier ones roll back and the error names it.
98 undo {steps} and redo {steps} take back or re-apply whole batches. dry_run:true reports, then rolls back.
99 A batch with no label is named after its first op (\"place V1\", \"trim V1@0\"); edit {label:\"…\", ops} names it.
100 media_remove {source} of a source other than the last one renumbers the sources after it, which clears undo: refused unless force:true.
101 checkpoint {name} saves the whole project under a name; restore {name} returns to it (it clears undo history).";
102
103/// `help {topic:"first_video"}`: the order to build a first video in, saving as it goes.
104const FIRST_VIDEO: &str = "\
105FIRST VIDEO: a first cut from nothing, one stage at a time. Save after every stage (project_save), and before you end a run: nothing is on disk until you do.
106 1. project_new {path:\"<dir>/talk.edith\", fps:30, resolution:\"1920x1080\"} — an empty project at a new path (nothing is written yet).
107 2. media_import {paths:[\"<clip>.mp4\", \"<music>.mp3\"]} — the files become src:0, src:1 ...; nothing is placed. A file already imported says \"already imported as src:N\" and adds nothing. project_save.
108 3. Each extra sound lane (music on A2, narration on A3) needs its own lane_add, one op per lane. For this recipe that is two: edit {ops:[{op:\"lane_add\", kind:\"audio\"}, {op:\"lane_add\", kind:\"audio\"}]} adds A2, then A3. A place or append to a lane that does not exist refuses; lane_add it first. project_save.
109 4. edit {ops:[{op:\"place\", source:\"src:0\", at:\"0s\"}]} puts the picture on V1 and its sound on A1; edit {ops:[{op:\"append\", source:\"src:0\"}]} adds after the last clip. length:\"5s\" sets the duration from in instead of out. Music bed: edit {ops:[{op:\"append\", source:\"src:1\", lane:\"A2\", until:\"30s\"}]} (A2 comes from step 3; src:1 is a song of 30 s or more, so the bed is one clip; until LOOPS a shorter source into one clip per repeat, and trims a longer one to the span). project_save.
110 5. voiceover {text:\"...\", pause:0.4, place:{lane:\"A3\", at:\"0s\"}} needs a project path (project_new or project_open); the WAV is written beside the .edith file in voiceover/, even before project_save. It imports the WAV as a source and places it when place is given. record {action:\"start\", lane:\"A3\"} then record {action:\"stop\"} is the microphone version: it records from the audio input and places the take the same way. voiceover speaks text with Piper and never records. The voiceover is unsaved until project_save: the project file does not name its WAV before then. project_save.
111 6. auto_captions {target:\"A3\"} transcribes the narration lane and writes the words to S1. project_save. (A1 is the picture's own sound: it has no words to caption here.)
112 7. export_start {out:\"<dir>/talk.mp4\"} returns job:1 at once; export_status {job:1} reports progress until it is done.
113 Length: a picture shorter than the music bed leaves black at the end, since the bed plays on over nothing. Trim the bed to the picture: edit {ops:[{op:\"trim\", clip:\"A2@0\", edge:\"out\", to:\"<the picture's end>\"}]}. Or make the picture longer: for a still, edit {ops:[{op:\"trim\", clip:\"V1@0\", edge:\"out\", to:\"<the bed's end>\"}]}; for video, append more picture after it. timeline shows where each lane ends.
114 Peaks: export_status warns when the job finishes if the file's true peak is above -1 dBTP (exactly -1 is within spec); the ceiling to aim at is -1 dBTP for lossless (wav, flac) and -2 dBTP for lossy (mp4, mkv, webm, mp3, ogg, m4a), since encoding can overshoot the mix; a true peak over 0 dBTP clips. Add the master limiter before export with project_settings {limiter:{on:true, ceiling_db:-1}} (ceiling_db:-2 for a lossy export); or normalize {target:\"mix\", allow_limiter:true, true_peak:-2} (-1 for lossless) sets the level in one undo step, and turns the limiter on at that ceiling only when the peak would otherwise hold the gain back (its reply says so).
115 After each stage, read the result with timeline (or frame / contact_sheet for a picture check). A reply that says \"no change\" or names a refusal means that step did not happen: fix it, then go on.";
116
117const PODCAST: &str = "\
118PODCAST: two speakers on A1 and A2, a music bed on A3 ducked under both, each speaker levelled on its own, then captions from both. Save after each stage (project_save).
119 1. project_new {path:\"<dir>/show.edith\", fps:30, resolution:\"1920x1080\"}, then media_import {paths:[\"<host>.wav\", \"<guest>.wav\", \"<bed>.mp3\"]}.
120 2. Speakers: edit {ops:[{op:\"place\", source:\"src:0\", lane:\"A1\", at:\"0s\"}]} puts the host on A1. A2 does not exist yet, so add it first: edit {ops:[{op:\"lane_add\", kind:\"audio\"}]}; then edit {ops:[{op:\"place\", source:\"src:1\", lane:\"A2\", at:\"0s\"}]} puts the guest there. Both start at 0 s, because each was recorded on its own track for the whole conversation: the two files play together, not one after the other.
121 Cut their silences together: cut_silence {lanes:[\"A1\",\"A2\"], dry_run:true}, then the same without dry_run. A joint cut (lanes with no target) removes a pause only where every listed lane is quiet at once, and a lane with no sound there (a gap between its clips, or no clip) counts as quiet. So while one speaker talks, the other lane is quiet but the talker's is not, and nothing is cut; only the stretches where both are quiet, the gaps between turns, are shortened, and the same span comes out of both lanes, so the turns stay in step. The reply's \"pauses now\" is measured on that joint quiet. Caption lanes ripple with the cut; locked caption lanes stay.
122 3. Bed: edit {ops:[{op:\"lane_add\", kind:\"audio\"}]} adds A3, then edit {ops:[{op:\"append\", source:\"src:2\", lane:\"A3\", until:\"<end of the talk>\"}]} lays the bed there. Lay it after the cuts in step 2, so <end of the talk> is where the talk now ends (timeline shows each lane's end). A cut made after the bed is placed (the step 5 fillers, or a later cut_silence) leaves the bed running past the talk: trim it to the new end with edit {ops:[{op:\"trim\", clip:\"A3@0\", edge:\"out\", to:\"<the talk's new end>\"}]}. Duck it under each speaker: edit {ops:[{op:\"duck\", lane:\"A3\", under:\"A1\"}, {op:\"duck\", lane:\"A3\", under:\"A2\"}]}.
123 4. Level each speaker alone: normalize {lanes:[\"A1\",\"A2\"], each:true, lufs:-16}. Its reply gives each lane's loudness before and after. A speaker with high peaks often cannot reach -16 LUFS under the -1 dBTP ceiling: the reply holds that lane to the true-peak ceiling (structuredContent carries it as capped_by: true_peak), and the lane stops short. This is expected for speech. A quiet speaker needs no manual clip gain: normalize takes the lane up to its +12 dB lane gain limit and puts the rest on that lane's clips (each up to +24 dB of clip gain), all in the same undo step. Only when even that is not enough does the reply say so with capped_by: clip_gain_limit; then raise that speaker's clip gain yourself (edit {ops:[{op:\"gain\", clip:\"A1@0\", add_db:3}]}) and normalize the lanes again. Then the whole mix: normalize {target:\"mix\", lufs:-16, allow_limiter:true, true_peak:-1} for a lossless or WAV export, true_peak:-2 for m4a or mp3 (lossy encoding overshoots the mix); the limiter is what lets the mix reach the target when the peak alone would hold it back. If the mix still falls short (its reply gives short_by_lu), the reply names the cap that holds it (capped_by): accept a target the peaks allow (-18 LUFS, say), or raise the quiet lane's clip gain as above. dry_run:true on either shows the plan first.
124 5. Fillers (optional, before the captions): do not cut a filler on one speaker's lane with find_words {cut:true} alone. A ripple moves only that lane, so the other speaker's lane falls out of step. Use the no-ripple form instead: find_words {query:\"um\", target:\"A1\", cut:\"lift\"} removes each match and leaves a hole where it was, and nothing moves. Pass the step 6 hint here too (hint:\"Jane Doe, LUFS\"): names and jargon come out spelt as the talk spells them, so the search reads them right. Or cut both lanes together, only at a joint pause (cut_silence with no target, step 2).
125 6. Captions from both speakers into one lane: auto_captions {target:\"A1\", lane:\"S1\", hint:\"Jane Doe, LUFS\"}, then auto_captions {target:\"A2\", lane:\"S1\", hint:\"Jane Doe, LUFS\"}. Each call transcribes its own lane and adds its cues to S1, so the two speakers' captions sit in one track. hint lists the names and words the talk uses; it may get their spelling and casing right, but that is not guaranteed, so check the names in the captions. A re-run on the same lane replaces the captions that lane made before; replace:true also removes overlapping captions that differ from what was heard now (a hand edit, or the other speaker's), so use it only when those are meant to go.
126 7. Check with timeline. A project with no picture (only A lanes) exports an .mp4 as sound alone, and its captions are dropped: export_start {out:\"<dir>/show.m4a\"} for the sound, or, for a captioned video, place a still on V1 and trim its out edge to the end of the talk (the still recipe in help {topic:\"recipes\"}). Then export_start {out:\"<dir>/show.mp4\"} (or the .m4a) and export_status {job:1} until it is done.";
127
128const RECIPES: &str = "\
129RECIPES
130 Rough cut from ranges: keep lays source ranges end to end (one undo step).
131 edit {ops:[{op:\"keep\", source:\"src:0\", ranges:[[\"10.0s\",\"22.5s\"],[\"40.0s\",\"52.0s\"]], lane:\"V1\"}]}
132 edit {ops:[{op:\"assemble\", items:[{source, in?, out?}]}]} does the same, one item per range, across several sources; each item is laid end to end after the last.
133 Trim: edit {ops:[{op:\"trim\", clip, edge, to}]} moves that edge to a timeline time. `to` is absolute (where the edge lands), not a length: edit {ops:[{op:\"trim\", clip:\"V1@0\", edge:\"out\", to:\"2s\"}]} makes the clip 2 s long from 0. There is no delta form. Add ripple:true to close the hole the edge leaves and move what follows with it (Premiere's ripple trim, Q and W in the editor).
134 edit {ops:[{op:\"trim\", clip, edge, to, scope:\"clip\"}]} on a take of three or more lanes: the other members stay linked to each other only if they have matching bounds. A 60 s picture with a 30 s bed cannot stay linked, so that trim is refused (\"its partners could not stay linked\") and nothing changes: give the members that stay together the same bounds first, or trim with the default scope (the whole take moves). A locked partner refuses (unlinking changes it).
135 Append to a lane that does not exist yet: add the lane first, edit {ops:[{op:\"lane_add\", kind:\"audio\"}]}. An append op naming A2 does not make A2: edit {ops:[{op:\"append\", source:\"src:1\", lane:\"A2\"}]} refuses until A2 exists.
136 assemble refuses a still image (src:N is a still): add a still with edit {ops:[{op:\"append\", source}]}, which puts it at the end of V1 with no hole, or edit {ops:[{op:\"place\", source, at:\"end\"}]}, which puts it at the timeline end (the latest end of any lane). They are not alternatives for one job: append extends V1, and place at:\"end\" goes to the timeline end, which leaves a hole on V1 when V1 ends sooner (a bed running on past it, say). Then trim its out edge (edit {ops:[{op:\"trim\", clip, edge:\"out\", to}]}) to change its length (5 s by default).
137 Countdown leader: edit {ops:[{op:\"generator_add\", kind:\"countdown\", from:5, at:\"0s\"}]} puts a 5 s countdown on V1 at 0 (add `lane`, `at` to put it elsewhere); insert_time first if the programme should start after it.
138 Tint everything under with an adjustment layer: edit {ops:[{op:\"adjustment_add\", at:\"0s\", duration:\"30s\"}, {op:\"color\", clip:\"V2@0\", tint:0.3, saturation:0.8}]} grades every lane below V2 for those 30 s; effect add on the layer does the same for blur or a vignette. enable {clip:\"V2@0\", on:false} switches it off without removing it. A transform on an adjustment layer moves the whole composite below it (uncovered area goes black); crop only limits where the layer reaches, so cropped-away areas keep the untouched picture. Adjacent adjustment layers hard-cut.
139 Reverse a clip: edit {ops:[{op:\"reverse\", clip:\"V1@0\"}]} toggles it (on:true or on:false sets it), picture and sound together with its take. It keeps its place and length and composes with speed: reverse, then speed x:2 plays it backward at double rate. clip_info and timeline say reversed.
140 Cut silence: read the regions, preview the cut, then cut.
141 silence {target:\"A1\"}, or {target:\"src:2\"} to scan a source (threshold_db, min_silence, padding, min_keep)
142 cut_silence {target:\"A1\", dry_run:true}, then cut_silence {target:\"A1\"}. It cuts only pauses of min_silence or longer. When none qualifies, the reply names the longest quiet it found and cuts nothing, so lower min_silence (or padding) and run it again.
143 min_silence (default 0.5 s, judged before padding) is the shortest quiet run it cuts: shorter ones are ignored.
144 keep:N is the total pause left in each silence, padding included (default 0.4). The padding at each end is never cut; under 2 × padding the pause is 2 × padding. The reply says \"pauses now X s\". A silence at or under keep is left alone, and when none is longer the reply says nothing was cut. lanes: with a target, it is the ripple scope, judged on the target alone (the target's lane is added if missing); by default the target's lane and its linked lanes, and a mix target cuts every lane. Without a target, two or more audio lanes are cut jointly where all are quiet: lanes:[\"A1\",\"A2\"] makes a joint cut with no target: the silence is where every listed lane is quiet at once, and the listed lanes are cut together, so their turns stay in step. Locked lanes: a locked lane named in lanes, or linked to the target, refuses the cut (unlock it with lane_flags); a mix's default scope (every lane) refuses the same way, naming each locked lane, and changes nothing. Unlisted audio lanes the cut runs through are reported as out of step.
145 silence: judged inside clips only; the timeline gaps between a lane's clips are structure and are reported, never listed or cut. Default threshold: 30 dB under the target's median speech level (−90..−10 dBFS); the reply names the value used. min_silence is judged before padding.
146 cut_silence: a silence that runs to the end of its clip keeps `keep` in all after the last speech, its end padding included. Gaps between clips are never cut.
147 Caption lanes ripple with the cut; locked caption lanes stay (a locked caption lane in the scope is skipped with a note).
148 mode:\"speed_up\" plays each silence faster instead of cutting it (rate 1.05–4, default 4); mode:\"keep_silence\" cuts the speech and keeps the silence (one target, no joint cut). Both take dry_run and undo like the cut.
149 Normalize loudness: measure the mix, then set it.
150 loudness {target:\"mix\"}, then normalize {target:\"mix\", lufs:-14}; its reply leads with whether the target was reached.
151 When the true-peak ceiling holds the gain back (the reply's capped_by is true_peak), add allow_limiter:true with true_peak set to the ceiling (-1 for lossless, -2 for lossy): the limiter then lets the mix reach the target, and the reply says it switched the limiter on.
152 dry_run:true reports the planned gain per lane and changes nothing.
153 Each lane alone: normalize {lanes:[\"A1\",\"A2\"], each:true, lufs:-16} sets each listed audio lane on its own, so each one alone measures lufs over its clips (two speakers at different levels come out even). Each lane's gain moves by itself, with the true-peak ceiling checked per lane; one undo step for all of them. Needs lanes, not target, and no allow_limiter.
154 Targets (lufs): streaming, YouTube and Spotify -14; Apple -16; podcasts -16 (stereo); broadcast (EBU R128) -23; TikTok and Instagram about -14.
155 Copy a look: edit {ops:[{op:\"copy_look\", from, to:[addrs] | to_lane, what?}]} copies the look of clip `from` onto each clip in `to` (or every clip on
156 `to_lane`) in one undo step. what is a list of \"color\" (the default), \"transform\", \"fit\", \"effects\" (picture clips only), \"eq\", \"gain\" (sound
157 clips only) or \"speed\" (rate, ramp and reverse, from and to any media clip); a target the part does not fit is named as skipped. from must carry a look: a plain clip has none, so copying it onto a plain clip replies \"nothing to copy\" (no change). e.g. edit {ops:[{op:\"copy_look\", from:\"V1@0\", to:[\"V1@30\"], what:[\"color\",\"transform\"]}]} Prerequisite: V1@0 is a picture clip with a look (a colour grade from the color op, or a transform) and V1@30 a second picture clip starting at frame 30; both must already exist.
158 Effects: vignette plus soft blur. effect {op:\"add\", clip:\"V1#0\", kind:\"vignette\", params:{amount:0.6}}, then effect {op:\"add\", clip:\"V1#0\", kind:\"blur\", params:{radius:4}}; effect {op:\"list\", clip:\"V1#0\"} shows the stack, effect {op:\"set\", clip:\"V1#0\", index:1, on:false} switches the blur off. The stack runs in order on the placed picture, in preview and export; distances are pixels at 1080 lines. Each op is one undo step. Prerequisite: V1#0 is a picture clip.
159 Green screen over a background: put the background on V1 and the green-screen take on V2, then effect {op:\"add\", clip:\"V2#0\", kind:\"chroma_key\", color:\"#00ff00\", params:{tolerance:0.35, softness:0.1, spill:0.5}}; the keyed-out part shows V1. effect {op:\"list\"} gives every kind with its ranges; masks (rect_mask, ellipse_mask) and blend {mode:\"screen\"} work the same way. pixelate {size} mosaics the picture (size is the block in pixels at 1080 lines); after a mask it censors only that shape, e.g. effect {op:\"add\", clip:\"V1#0\", kind:\"pixelate\", size:24} then an ellipse_mask. A mask moves with effect {op:\"mask_keys\"} (the ops topic lists its arguments).
160 Grade a clip: wheels to balance, curves to shape, a LUT for the look, the sliders to trim; read the scopes between steps.
161 edit {ops:[{op:\"wheels\", clip:\"V1@0\", lift:[0, 0.05, 0, -0.03]}, {op:\"curves\", clip:\"V1@0\", master:[[0.25, 0.2], [0.75, 0.8]]}, {op:\"lut\", clip:\"V1@0\", path:\"~/luts/warm.cube\", mix:0.7}]}
162 scopes {at:\"2s\"} gives the waveform, the RGB parade and the vectorscope of that frame as numbers: crushed and clipped shares, each channel's spread, the cast.
163 Check a cut before exporting it.
164 timeline {range:{from:\"10s\", to:\"30s\"}}, contact_sheet {range:{from:\"10s\", to:\"30s\"}, count:12}, frame {at:\"450f\"}
165 Cut by transcript: read the words, find the filler or phrase, then cut its spans. The filler list is um, uh, er, ah, hmm and
166 like, but like is a real word too often: check each hit with its context before cutting it, or search a phrase instead.
167 The transcript usually leaves fillers out but not always. A filler query runs with the prompt that keeps disfluencies, so a plain find_words {query:\"um\"} still finds the ones that remain, with no flag.
168 transcript {target:\"A1\"}, then find_words {query:\"um\", target:\"A1\"} lists each match with its span; cut the spans with edit {ops:[{op:\"cut_regions\", regions:[[\"450f\",\"512f\"]]}]}
169 or find_words {query:\"um\", target:\"A1\", cut:true} removes every match in one step (which:\"first\" or which:[0,2] picks some; dry_run:true reports only). keep:\"first\" or \"last\" keeps one word of a repeat such as \"I I\". The cut takes the target's lane and its linked lanes, or every lane for a mix or src target; help {topic:\"ripple\"} says which lanes move. On one speaker's lane of a two-speaker show, cut:true ripples only that lane and desyncs the other: use cut:\"lift\" instead, which leaves a hole and moves nothing (podcast has the joint-pause option). Caption lanes ripple with the cut; locked caption lanes stay (a locked caption lane in the scope is skipped with a note). A locked lane the cut would move refuses it, dry runs too (unlock it with lane_flags); a mix's default scope skips its locked lanes with a note. With cut, each edge snaps to a pause within 150 ms of Whisper's time, so a cut lands in quiet; snap:false cuts at Whisper's times.
170 Auto captions: transcribe and place captions, then adjust the caption track.
171 auto_captions {target:\"A1\"} writes the cues to S1; hint:\"Jane Doe, LUFS\" lists the words the talk uses; it may help their spelling and casing, and near-miss spellings of them are corrected after transcription (the reply names each one), but that is not guaranteed. help {topic:\"captions\"} covers the rest of the workflow.
172 Shorts captions: animated, a few words at a time, the word being spoken highlighted.
173 auto_captions {target:\"A1\"}, then project_settings {captions:{animation:\"karaoke\", words_per_line:3, uppercase:true, highlight:\"#ffd600\"}} (saved with the project; one undo step),
174 check a frame mid-word: frame {at:\"2s\", burn_captions:{size:70, place:\"centre\", outline:\"thick\", boxed:false}}, then export_start {out, burn_captions:{size:70, place:\"centre\", outline:\"thick\", boxed:false}}.
175 Or per call, without touching the project: burn_captions:{animation:\"karaoke\", words_per_line:3, box:true}. animation word is the one-big-word style; pop and bounce are the others. help {topic:\"burn_captions\"}.
176 Cut to the beat: mark the music's beats, then cut on the markers (cuts snap to markers).
177 edit {ops:[{op:\"beats\", clip:\"A2@0\"}]} finds the tempo of that clip's sound and marks every beat as a yellow comment marker noted \"Beat\"; every:2 or every:4 marks every second or fourth beat for bars. The reply gives the BPM, the count and the M@ addresses. Running it again replaces the earlier beat markers of that clip. A picture-only clip has no sound and is refused.
178 Intro title and a lower third: a centred card over black, then a boxed caption over the picture.
179 edit {ops:[{op:\"title_add\", at:\"0\", duration:3, text:\"Episode 17\", place:\"centre\", fade_in:12, fade_out:12}, {op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe, director\", place:\"bottom\", boxed:true, fade_in:12, fade_out:12}]}
180 A title past the last clip extends the timeline; edit {ops:[{op:\"title_set\", title:\"T2\", size:60}]} changes one, edit {ops:[{op:\"title_remove\", title:\"T1\"}]} takes it off (the titles after it renumber: T2 becomes T1), and timeline lists them as T lines.
181 A title can start in one of the app's looks with preset (lower_third, centered or caption_bar): edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\", preset:\"lower_third\"}]}; fields given with it win. A title can carry a look: color (\"#ffcc00\"), weight (regular|bold; Latin letters, other scripts keep their one weight), hplace (centre|left|right: the side the block sits against, the margin from the edge), align (centre|left|right: how its lines line up inside the block), box_color (\"#000000\" keeps the opacity, \"#000000c8\" sets it) and box_opacity (0..1). A lower third: edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\\nDirector\", place:\"bottom\", hplace:\"left\", align:\"left\", weight:\"bold\", boxed:true, box_color:\"#112233\", box_opacity:0.8}]}. A project that uses one saves as format v49 (an older edith refuses it by name). A title can animate in and out: in_anim and out_anim are none, fade, typewriter (letters appear one by one), slide_up, slide_left, pop (grows from 60% with a slight overshoot) or word_by_word; anim_secs is how long each takes (a bare number is seconds, default 0.5). An exit is the entrance played backwards. Example: edit {ops:[{op:\"title_add\", at:\"0\", duration:4, text:\"Episode 17\", in_anim:\"typewriter\", out_anim:\"fade\", anim_secs:0.6}]}. An animated title saves as format v54 (a titleanim line; an older edith refuses it by name). A title can also carry its own keys, which move, scale and fade it over its length: title_add keys:[{at:\"0s\", opacity:0}, {at:\"1s\", opacity:1, x:0.1, scale:1.2}] (at counts from the title's first frame; x and y are a share of the picture, scale multiplies its size, opacity its alpha; missing fields are 0, 0, 1, 1; keys:[] takes them off). Keys save as format v56 (a ttkeys line).
182 Black lead-in for an intro title: edit {ops:[{op:\"insert_time\", at:\"0\", duration:\"3s\"}]} opens black before the picture, then title_add at 0 sits over that black.
183 edit {ops:[{op:\"insert_time\", at:\"0\", duration:\"3s\"}, {op:\"title_add\", at:\"0\", duration:3, text:\"Episode 17\", place:\"centre\", fade_in:12, fade_out:12}]}
184 Speed a clip that has narration over it (the examples need a picture clip at V1@0, and the narration lane A3 from first_video): narration on its own lane (A3, as in first_video) is outside the ripple by default, so edit {ops:[{op:\"speed\", clip:\"V1@0\", x:0.5, ripple:true}]} changes the picture's length and the narration keeps its times.
185 The reply lists each clip left in place: a clip on another lane that spans the change (the music bed on A2, a narration clip on A3) stays where it is.
186 To move the narration with the picture, name its lane (prerequisite: A3 exists and holds the narration clip): edit {ops:[{op:\"speed\", clip:\"V1@0\", x:0.5, ripple:true, lanes:[\"V1\",\"A1\",\"A3\"]}]}. A lane named in lanes refuses a clip that spans the change, so move or trim that narration clip first (edit {ops:[{op:\"move\", clip, at}]}, or a trim).
187 Clips that start after the sped clip move by the length change on the lanes in scope. lanes:[\"V1\",\"A1\"] is the same as the default.
188 Dip music under a voice line: a volume envelope on the music clip, over the line's span. The span must lie inside that one clip: a file shorter than the span
189 loops into several clips under until, and a dip cannot cross them, so use a song at least as long as the span (the first_video bed is one clip).
190 Prerequisite: A2@0 is the music clip and runs to at least 25 s.
191 edit {ops:[{op:\"gain_dip\", clip:\"A2@0\", from:\"10s\", to:\"25s\", db:-18, ramp:\"0.5s\"}]}
192 The ramps start from the level there now; clip_info lists the points as timeline times. gain_key and gain_key_remove adjust one point, gain_ramp draws a single ramp, gain_keys replaces the whole envelope. For a dip that follows the speech by itself, edit {ops:[{op:\"duck\", lane:\"A2\", under:\"A1\"}]} is the automatic alternative.
193 Export: start, then poll until done.
194 export_start {out:\"~/cut.mp4\"} returns job:1; export_status {job:1} until it reports the outcome.";
195
196const LANES: &str = "\
197LANES
198 V1.. are picture lanes, A1.. sound lanes, S1.. caption lanes. Names are the GUI's.
199 lane_add {kind: video|audio|subtitle} adds one; lane_remove {lane}; lane_move {lane, to}: to is the 1-based position in the lane list as timeline prints it, and the reply maps every moved clip old → new.
200 Lanes are named by position, so a lane_move renumbers the lanes between its two places: lane_move {lane:\"V2\", to:1} makes the old V1 into V2. The reply lists each rename; use the new names after a move.
201 place {lane} sets where the picture goes; its sound still goes to A1 (or audio_lane) and stays linked to it, as with no lane (V1 and A1). audio:false places the picture alone.
202 place overwrite:true replaces only the span the new clip covers: a clip it partly covers keeps the part outside that span.
203 insert {source, in?, out?, at, to?, length?, lanes?} and overwrite {…}: the three-point edit. The source range in..out (the whole file when none) goes at `at`; `to` (a timeline out mark) or `length` sets the duration from in instead of out. It lands on `lanes` (one video lane, one audio lane), else the first unlocked V and A lanes the source has, linked as one take (a still on a video lane, a song on an audio lane). insert cuts the clip `at` falls inside and moves what follows later on those lanes only; it refuses, by name, when that would pull a linked take apart (add the partner lane to `lanes`). overwrite replaces what is there, trimming or splitting it, and moves nothing. A locked lane refuses; each is one undo step.
204 lane_name {lane, name}: the display label of a lane (like a track name), at most 40 characters; \"\" clears it. The address stays V1/A2: every op still takes V1, never the name. timeline shows the name on the lane's header line. One undo step; a locked lane refuses it.
205 lane_flags {lane, hidden?, muted?, locked?}: hidden applies to picture lanes, muted to sound
206 lanes (the other flag is refused there). A locked lane is never changed: an op that would change
207 it refuses, except that the titles and captions a ripple carries past it skip it with a note.
208 levels {target:\"A1\"} on a muted lane shows the lane's own sound, with a note that it is silent in the mix and export.
209 A sound-only source (a song, a WAV) goes on an A lane: edit {ops:[{op:\"place\", source, lane:\"A2\", at}]} or edit {ops:[{op:\"append\", source, lane:\"A2\"}]}.
210 An mp4 with no picture is sound-only too: placed with no lane, it goes to A1 alone.
211 A source with more than two sound channels (5.1, say) is mixed to stereo on export. media_probe lists each audio track's
212 channels and sample rate, and media_list names a chosen track that is not the first (\"audio 1 (fra)\").
213 audio_track:N on place and append picks which of the file's sound tracks plays (0-based, the numbers media_probe lists as \"audio track N\"); the first track is the default. An N past the last track is refused, and the reply lists the tracks. edit {ops:[{op:\"place\", source:\"src:0\", at:\"0s\", audio_track:1}]}.
214 lane_gain {lane, db} sets a lane's level, -60..12 dB. Each clip's own gain adds on top.
215 pan {clip, pan} and lane_pan {lane, pan} place sound between the speakers, -1 (left) to 1 (right), 0 the middle; a balance, so
216 the far side is turned down and the near one stays. A clip's pan and its lane's stack. Stereo mixes only. edit {ops:[{op:\"pan\", clip:\"A1@0\", pan:-0.5}]}
217 pitch {clip, semitones (-12..12)} shifts an audio clip's pitch in semitones, fractions too (0.37), and keeps its length (12 an octave up). edit {ops:[{op:\"pitch\", clip:\"A1@0\", semitones:12}]}
218 Ducks stack: a lane can carry one duck per key lane (`under`), so several keys can pull it down. edit {ops:[{op:\"duck\", lane, under, off:true}]}
219 removes that one; edit {ops:[{op:\"duck\", lane, off:true}]} with no under clears every duck on the lane.
220 Not supported (help {topic:\"unsupported\"}): custom transition shapes.
221 Do not search the tools for them.
222 close_gaps {lane} removes the gaps on a lane. The timeline's gaps line counts them per lane.
223 timeline {lanes:[\"V1\",\"A2\"]} shows only those lanes; timeline {range:{from,to}} only the clips that overlap it.
224 The brief timeline shows up to 40 clips per lane, within a text cap of about 4 KB, and says how many more there are; timeline {lanes:[\"V1\"], page:N} pages one lane at 40 clips per page, and a lane header counts its graded clips past the cut.
225 Source times on a clip are the source's own clock: `src 0.0s–4.0s` is the part of the file it plays.";
226
227const EXPORT: &str = "\
228EXPORT
229 export_start {out, preset?, loudness?, format?, range?, size?, fit?, bitrate_kbps?, qp?, keyframe_s?, faststart?, audio_kbps?, bit_depth?, prores_profile?, hevc_speed?, hdr?, audio_bit_depth?, chapters?, intra_only?, seat?, subtitles?, burn_captions?, overwrite?}
230 returns job:<n> at once. Poll it with export_status {job?}; export_cancel {job} stops it and deletes the partial file.
231 out: the file to write; ~/ is expanded and its folder must exist. The extension picks the format:
232 .mp4 mp4 · .mkv av1 · .webm · .wav · .flac · .mp3 · .ogg · .m4a · .opus · .mov prores. Refuses an existing file unless overwrite:true.
233 format (overrides the extension): mp4 (H.264) · av1 (AV1 in mkv) · av1-mp4 · hevc (I+P GOPs, mkv) · hevc-mp4 ·
234 webm · wav and flac (lossless audio) · mp3, ogg and m4a (audio only; m4a is AAC in an mp4 box) · opus (audio only; Opus in Ogg at 48 kHz) · prores (Apple ProRes in a QuickTime .mov with PCM sound) ·
235 png_sequence (a folder of PNG pictures, one per frame, named <folder>_00001.png; out is the folder, which may not already hold files unless overwrite:true; the project's size, no sound) · still (one PNG: the frame at the start of range, the poster frame) · gif (animated GIF of range, at most 30 s and 720 px wide: gif_width (default 480), gif_fps 1-60 (default 15), gif_loop (default true); pictures are composed at the project size and the GIF is refused by name for a range or width past those).
236 loudness: a number of LUFS from -30 to -5, the whole mix's integrated loudness target (-14 for streaming, -16 for podcasts). It takes one gain, cut back where the true peak would pass the preset's ceiling or -1 dBTP; never a limiter. Beside preset it replaces the preset's own loudness. export_captions {format:\"srt\"|\"vtt\", path?, overwrite?} writes the timeline's captions (every cue on the subtitle lanes, in start order) to a text file: SRT or WebVTT, with picture cues left out. Without path it is `<first source> edit.<format>` in the Videos folder.
237 preset: an id from export_presets (youtube_1080p, youtube_1080p60, youtube_1080p_hevc, youtube_4k, youtube_4k60, youtube_4k_hevc, shorts_reels, podcast, podcast_ogg, podcast_opus, archive, archive_prores, hdr10_hevc, archive_flac, archive_wav). It fills format, bitrate_kbps, audio_kbps, size, bit_depth, prores_profile, hdr and, for the podcast rows, a -16 LUFS / -1 dBTP loudness target applied to the exported sound. Anything you pass beside it overrides the preset's value; out's extension must match the preset's format. export_presets {} lists the rows.
238 range {from, to}: that part of the timeline, to excluded. Times as in TIMES.
239 seat: auto (the GPU for H.264 and HEVC where this machine has a GPU encoder, else the CPU; AV1 is always the CPU) · hardware (GPU or refuse) · software.
240 size: this export's picture size, WIDTHxHEIGHT (1280x720) or a height with p (720p, 1080p, 2160p, 16:9 at that height); 1080x1920 is vertical. Both sides even. Omitted: the project's resolution, which stays as it is.
241 fit: how every picture clip meets this export's canvas: keep (the default: each clip's own fit), fit (whole picture, bars) or fill (the canvas covered, the picture cropped). It changes this export's copy only; the project's clips keep their fit. Captions and titles keep their place on the canvas.
242 A 16:9 timeline as 9:16: export_start {out, size:\"1080x1920\", fit:\"fill\"}. The reply names the size and the fit, and the clip count they applied to.
243 bitrate_kbps: video, chosen from the picture size and frame rate when omitted. qp: a constant quantiser 0..51 instead of a bitrate (not with bitrate_kbps): the hardware seat for H.264, HEVC and AV1, and the software HEVC encoder; the software H.264 and AV1 encoders refuse it. keyframe_s: seconds between key frames, 0.1 to 10 (not with intra_only). faststart: mp4, hevc-mp4, av1-mp4 and m4a only, moov before mdat so it plays before it is fully read. audio_kbps: 128, 192, 256 or 320, and 384 for AAC only.
244 intra_only: hevc and hevc-mp4: true codes every picture as an IDR (intra only, large files, every frame a cut point). false, the default, codes I+P GOPs (an IDR a second, P pictures between). h264 mp4 uses it the same way.
245 Captions: burn_captions draws one track into the picture, so every player and WebM show it. subtitles adds soft
246 tracks a player can switch off (WebM has none). Both together: burned and soft. burn_captions alone: no soft track.
247 subtitles (off unless given): true for every subtitle track, placed or not, or an array of track indices (0-based, as the
248 captions tool lists them) for just those, soft, in the order given. Omitted or [] adds none. A picked track that is not placed
249 on a caption lane is still written whole (all its cues). In mp4, overlapping cues are merged into one line each; mkv keeps them as they are.
250 Still and picture-sequence exports draw each frame as the export would (titles and burnt captions included). They write no sound, so a subtitle track or a sound setting does not apply to them.
251 An .mp4 of a timeline with no picture is the sound alone (AAC, no picture track); it is not refused. burn_captions is refused for it, and for the audio-only formats (m4a, mp3, ogg, opus, wav, flac): it draws into the picture, so drop burn_captions or add a picture.
252 chapters (default true): the project's chapter markers are written into the file, timed from the start of the range. Written to mp4, av1-mp4, hevc-mp4, m4a, webm, opus and Matroska (.mkv: av1, hevc); wav, flac, mp3 and ogg say they are not written. chapters:false leaves them out, and chapters:\"markers\" writes the comment markers as the chapter list instead. The reply counts them, e.g. \"3 chapters\".
253 bit_depth: 8 or 10 for the picture. 10 writes a 10-bit AV1 or HEVC (Main 10) file: format av1 (.mkv), av1-mp4, hevc (.mkv) or hevc-mp4; H.264 and every other format refuse it. Omitted: a 10-bit source gives a 10-bit AV1 or HEVC file, an 8-bit source 8-bit. The reply says which (\"output 10-bit, from the source\").
254 prores_profile (format prores): proxy, lt, standard, hq (the default) or 4444, 4444xq. The profile is the quality and sets the rate; bitrate_kbps means nothing to ProRes. proxy, lt, standard and hq are 4:2:2, 4444 and 4444xq are 4:4:4. ProRes is always 10-bit. A ProRes .mov carries no subtitles.
255 hevc_speed (hevc and hevc-mp4): default (the full search), fast (about 1.2-1.6x quicker, 0-3% more bits) or faster (about 1.5-2x quicker, up to 27% more bits). Other formats refuse it.
256 audio_bit_depth (format prores): 16 or 24 (the default), the bits per sample of the PCM sound.
257 hdr (hevc and hevc-mp4): off (the default), pq (HDR10) or hlg. The file is 10-bit BT.2020 tagged with that transfer, HDR sources are not tone-mapped, and bit_depth 8 is refused. Other formats refuse it.
258 Pictures are 8-bit 4:2:0 except in a 10-bit AV1 or HEVC export. (ProRes is always 10-bit.) A 10-bit export still composes edits (grades, titles, captions, transitions, layers) at 8-bit precision and shifts them up. A stream copy keeps the source's own bits.
259 The sound is as wide as its widest clip: a mono clip alone exports mono, and a mono clip beside a stereo one is widened to stereo.
260 A burn-only export reports \"subtitles: burned into the picture (no soft track)\".
261 The export keeps running while you do other things. If the client closes the server's input, the server waits for running exports to finish before it exits. A stop signal (SIGTERM or SIGINT) cancels them and deletes their partial files. Poll export_status until it finishes; export_cancel {job} stops one.
262 export_status reports progress, ETA, the encoder and the outcome; a done export reports its file size.
263 Queue: export_start {queue:true} lines an export up. It keeps its own copy of the timeline as it is at that moment (later edits do not change it) and starts when every earlier export has finished, one encode at a time, with no polling needed; export_status shows it as `waiting` with the number of exports ahead. export_cancel {job} on a waiting job removes it from the queue. Without queue the export starts at once, beside any others.
264 export_queue {action:\"pause\"} pauses the queue: the running export finishes, and the queued ones stay waiting until export_queue {action:\"start\"}, which lifts the pause and starts the next one now if nothing is running. export_queue {action:\"status\"} (the default) says whether the queue is paused, the running export and the queued ones in order. A pause holds only queued exports; a direct export starts at once. export_status says when the queue is paused.
265 Render preview: render_preview {range?} pre-renders a stretch (default: the whole timeline) so playback over the heavy parts of a cut reads finished frames instead of compositing them. It runs in the background; project_status shows the progress and the cached ranges. An edit inside a cached range drops that render. render_preview {cancel:true} stops it.
266 export_status {out} for a file this session did not write reports whether it is there, its size and its time; the progress
267 of a job from an earlier session is not known.
268 A finished file whose true peak is above -1 dBTP warns (exactly -1 is within spec, for every format); over 0 dBTP its samples clip, and that warning is the stronger one. The fix is the master limiter:
269 project_settings {limiter:{on:true, ceiling_db:-1}} for lossless, ceiling_db:-2 for lossy. The ceiling is -1 dBTP for lossless (wav, flac) and -2 dBTP for lossy (mp4, mkv, webm, mp3, ogg, m4a), since a lossy encoder can add about a dB of overshoot above the mix. The warning fires above -1 dBTP for every format, lossy ones included, since a true peak there clips on some players; the -2 figure is the limiter target that keeps a lossy encode clear of it. The mix is held to the same ceiling by normalize {target:\"mix\", allow_limiter:true, true_peak:-1} (-2 for lossy).";
270
271const SUBTITLES: &str = "\
272SUBTITLES
273 A subtitle track is a list of cues (text with a start and an end), kept in the project. Nothing shows until
274 a track is placed on a caption lane (S1..) or exported. Tracks are numbered from 0; the captions tool's footer lists them.
275 Import: edit {ops:[{op:\"subtitles_import\", path:\"talk.srt\"}]} adds the tracks of a subtitle file, or a video's
276 own subtitle tracks. They wait off the timeline until edit {ops:[{op:\"captions_place\", track:0, lane?:\"S1\", at?:\"0\"}]}
277 puts one on a caption lane (S1 by default, at frame 0 by default).
278 Language: subtitles_import {path, lang?} takes an optional language: an ISO 639-2 code (fra, deu, eng; fr or French also work). Without one, it is guessed from the file name (talk.fr.srt, fra.srt, talk_en.srt, eng.srt); a name that says none leaves it unset, written as und. subtitles_lang {track, lang} sets it later. The mp4 and MKV exports carry the language, and an MKV track's title is the language name.
279 Reading: in WebVTT and SRT, <br> is a line break; ASS is read as UTF-8. An unreadable or reversed cue, a wrong arrow (`->`) or a cue with no timing line is skipped, and the subtitles_import reply names it with its line number.
280 Placed captions, by address: the edit ops sub_move {clip, at, to_lane?} (its group follows), sub_trim {clip, edge:\"in\"|\"out\", to}
281 (moves its start or end: edge is \"in\" or \"out\") and sub_delete {clip} (a lone caption lifts and leaves a gap; a grouped one takes its group).
282 Cue text, by track and cue number: edit {ops:[{op:\"cue_text\", track:0, index:3, text:\"Hello\\nthere\"}]} rewrites one
283 (\\n is a line break; empty text removes it). edit {ops:[{op:\"cue_delete\", track:0, index:3}]} removes one and moves nothing.
284 edit {ops:[{op:\"cue_replace\", find:\"Jon\", replace:\"John\"}]} changes words in one track, or in every track when
285 track is left out; it is case-insensitive unless case_sensitive is true.
286 edit {ops:[{op:\"cue_time\", track:0, index:3, at?:\"12s\", to?:\"14s\"}]} trims or moves one cue (timeline times; give at, to or both); it stays inside its neighbours and at least 0.1 s long.
287 edit {ops:[{op:\"cue_merge\", track:0, index:3}]} joins a cue with the next one; edit {ops:[{op:\"cue_split\", track:0, index:3, at:\"12s\"}]} divides one in two at a time.
288 edit {ops:[{op:\"cue_add\", track:0, at:\"12s\", to:\"14s\", text:\"Hello\"}]} adds a cue at timeline times (track_clock:true for the track's own); an overlap is refused unless overwrite is true.
289 The captions tool lists the placed cues as \"track T cue C\": the track and cue numbers the cue ops take.";
290
291const CAPTIONS: &str = "\
292CAPTIONS
293 Captions are the words drawn over the picture. Three steps make them.
294 1. Put the words on a caption lane (S1..).
295 auto_captions {target:\"A1\"} transcribes a sound lane (A1 by default) and writes its cues to S1 at frame 0, as one
296 undo step. Cues are cut at pauses, sentence ends, max_chars and max_secs; the .srt is saved beside the project and
297 imported as a track. lane names another caption lane. A path that already holds a track is refused.
298 Words move between neighbouring cues to hold 0.8 s; cues the limits force shorter are named in the reply.
299 A lane with no speech is refused, \"no speech to caption in A2: the transcript has no words\", and nothing is written.
300 A lane that already holds captions takes the new run merged in; a mix splits cues at speaker changes.
301 or edit {ops:[{op:\"subtitles_import\", path}]}, then edit {ops:[{op:\"captions_place\", track, lane?, at?}]} (see SUBTITLES).
302 hint:\"Edith, LUFS\" may help spelling and vocabulary, but is not guaranteed: after transcription, a near-miss spelling of a hinted word is corrected to it, and the reply names each correction (\"hint corrected: 'Jane Dough' → 'Jane Doe'\"); numbers come out as digits (\"40 years\"). cue_replace fixes words after the fact.
303 2. Fix them. The captions tool lists the cues as track T cue C [S1@F] (its range is from inclusive, to exclusive, in exact seconds).
304 [S1@F] is the placement that shows the cue, the address sub_move, sub_trim and sub_delete take. Cues inside one placement share its
305 address, and a cue that a cut split lists one line per part. The edit ops cue_text rewrites one, cue_delete removes one,
306 and cue_replace fixes a word in every cue.
307 Time edits (insert_time, remove_time, cut_regions and the other cuts) split a cue that a cut runs through, at the word boundary
308 nearest the cut; words inside a removed span are dropped. A one-word cue keeps its word on the longer piece only (ties: the earlier one).
309 Caption lanes ripple with the cut; locked caption lanes stay (cut_silence, find_words cut and delete all cut).
310 3. Show them in the file. export_start with burn_captions draws the text into the picture, so every player and WebM
311 shows it. With subtitles it adds soft tracks a player can switch off (WebM has none). Both is fine too.
312 frame and contact_sheet take burn_captions as well, so a check frame shows what the export will draw.
313 The burn options (track, size, outline, boxed, place, family, animation, highlight, box, uppercase, words_per_line) are in help {topic:\"burn_captions\"}; the export keys in help {topic:\"export\"}.";
314
315const RIPPLE: &str = "\
316RIPPLE
317 A ripple moves the items after a cut or a length change, so the timeline closes up (or opens) without a gap.
318 The ripple ops: delete, ripple_delete, speed with ripple:true, cut_regions, insert_time, remove_time, and the cut
319 tools find_words with cut:true and cut_silence. Each takes lanes:[\"V1\",\"A2\"] to name the lanes it may move.
320 Default scope (no lanes): the edited lane, plus the lanes of clips linked or grouped to it (a take moves whole),
321 closed over what the ripple reaches. On a picture lane, captions and titles over the moved picture move too.
322 find_words cut: the target's lane and its linked lanes, or every lane for a mix or src target.
323 lanes replaces that default and must name the edited lane. cut_regions, insert_time and remove_time default to
324 every unlocked lane, so lanes narrows them.
325 Lanes outside the scope never move and are never split. Titles move only when a picture lane is in scope. A locked caption lane in the default scope is skipped with
326 a note; any other locked lane the ripple must move refuses the op.
327 Replies list the clips a ripple shifted, as old → new addresses. Addresses in one batch refer to the timeline as
328 the previous op left it, so use the new address from that reply before naming the clip again.
329 ripple_delete also lists the caption cues it removes or trims.
330 lift is not a ripple: it removes one clip alone and leaves its gap, so nothing after it moves.
331 A dissolve or crossfade next to a gap fades the sound to or from silence.
332 A linked trim moves every member's edge to one time. Each reply carries an effects: line for side effects
333 (clips split, holes left, takes unlinked).
334 A separate narration lane (its own A lane, not linked to the picture) is outside the default scope: a ripple that
335 lengthens, shortens or closes the picture leaves its clips at their times. Name it in lanes to move it too (see the
336 speed recipe in help {topic:\"recipes\"}).
337 split {at, lanes?} is a cut, not a ripple: it cuts the lanes it names at one time and moves nothing.";
338
339const PROJECT: &str = "\
340PROJECT
341 project_new {path, template?, resolution?, fps?, overwrite?, discard?} starts an empty project at a new path, creating its folder if it is missing; nothing is written
342 until project_save, and project_save needs at least one source in the project (media_import first). template:\"<name>\" starts from a template (see templates): the canvas, rate, lanes and caption style come with it, so resolution and fps are refused with it.
343 templates {} lists the built-in templates (YouTube 1080p 30, Vertical 1080×1920 30, Square 1080 30) and the saved ones, each marked as keeping clips or not. Saved ones come from File > Save as template in the window. overwrite:true lets the later project_save replace a file already at path, since project_new makes that file this project's (without it a save refuses
344 to replace one). discard:true drops the open project's unsaved edits to start this one (its autosave keeps them when
345 one can be written); without it a dirty open project refuses.
346 A path with an earlier session's unsaved autosave is refused before anything is created, unless overwrite:true: the reply names the autosave and offers project_open {recover:true} to continue from it; overwrite:true sets the autosave aside as a dated copy (the newest three dated copies and any from the last 7 days are kept; older ones are deleted).
347 project_open {path, recover?, discard_autosave?, search?, discard?} opens a .edith file, or a media file as a new project.
348 An autosave beside the project that holds an earlier session's unsaved edits refuses the open, and nothing is loaded: the refusal names the edits and both choices. recover:true opens the saved file with the autosave's edits on top as one undo step, so undo takes them back
349 (with this session's own unsaved edits open it needs discard:true, which drops those edits; the recovered edits are unsaved until project_save). A never-saved project has no saved file under them, so undo has nothing earlier to return to.
350 discard_autosave:true opens the saved file and sets the autosave aside (<stem>.autosave-<stamp>.edith; the newest three dated copies and any from the last 7 days are kept, older ones are deleted). recover:\"<file name or time stamp>\" loads one of the dated autosaves the reply
351 lists (<stem>.autosave-<stamp>.edith; the stamp is local time, e.g. 20261016-223636), and the newest autosave stays unloaded.
352 search:[folders] relinks offline sources by file name; the project is then unsaved until project_save writes the new paths.
353 project_save {path?, force?, discard_autosave?} saves, or saves as a new path; it needs at least one source in the project (media_import first). It refuses to overwrite a file that changed on
354 disk since the project was opened, unless force is true (force also replaces a file at path that this session did not open). project_save takes no overwrite key. It also refuses while an autosave that appeared after the open holds edits this
355 project lacks (\"an autosave from <time> holds unsaved edits ...\"): recover them with project_open {recover:true}, or pass
356 discard_autosave:true: this session's edits are saved, and that autosave is set aside as a dated copy (the newest three dated copies and any from the last 7 days are kept).
357 project_collect {folder?} copies every file the project plays into one folder (default <project stem>_media beside the project file) and points the project at the copies,
358 so the folder and the .edith can be moved or archived together. Generated sources (solids, bars, adjustment layers) are skipped; a source whose file is missing is skipped and named; a source already in the folder stays;
359 a name taken by another file becomes name-2.ext; the same bytes already there are reused. One undo step; unsaved until project_save. A failed copy changes nothing.
360 project_export_timeline {format, path?} writes the active sequence for another editor: format otio (OpenTimelineIO .otio), fcpxml (Final Cut Pro XML 1.10, for Final Cut Pro, Resolve and Premiere) or edl (CMX3600: V1 and A1/A2). Subtitles are left out and the reply says so. Default path: beside the project file. Only the file is written.
361 project_import_timeline {path} reads an .otio file as a new sequence of the project and makes it the active one, relinking each clip by its path; a missing file becomes offline. One undo step.
362 proxies {action:status|make|cancel|delete, source} manages editing copies: make starts one in the background (its progress shows in status), cancel stops it and leaves the film off, delete removes it and keeps the film off. With auto_proxies on, each media_import starts its stand-ins.
363 speech_model {download?, model?, device?, cancel?} shows the speech models installed per device (cpu, gpu) and any download in progress; download:true fetches one in the background (base by default).
364 export_captions {chapters:true} returns the chapter list as the YouTube description text, with JSON lines, writing no file. export_cancel {all:true} cancels every unfinished export.
365 render_preview {clear:true} deletes every render file in the cache (refused while a render runs).
366 project_status reports the open project. project_settings sets resolution, fps, tonemap, proxies,
367 auto_proxies, encoder, the master limiter, the notes (free text, several lines, shown by project_status when set) and the still length
368 (still_secs, 0.5 to 600 s, 5 by default: stills placed after the change take it), the speech model and device (speech_model, speech_device auto|cpu|gpu). Each change and each refusal is reported.
369 sample_rate sets the mix's rate: \"source\" (unset: the highest rate among the sources, or 48 kHz when every source is below 44.1 kHz), 44100, 48000 or 96000, the rows the GUI offers.
370 project_status {history:true} also lists every undo and redo step with the steps count that undo or redo takes to reach it (undo {steps:3} takes back the three newest).
371 templates {save:{name, with_clips?}} saves the open project as a template (settings, and the clips too with with_clips:true); a built-in's name is refused.
372 An fps change keeps clips, captions and titles at the same seconds; their frame numbers, and so
373 their addresses (V1@450), change with the rate. Positions are rounded to whole frames at the new rate,
374 so a round trip (to another fps and back) can shift a cut by up to a frame; check the cut with timeline.
375 Autosave: when the server's input closes (the client exits), a dirty project is written beside its file as
376 <stem>.autosave.edith, or to ~/.cache/edith/autosave/ when untitled. It never overwrites the project's own file.
377 project_open refuses over a newer autosave, and lists the dated autosaves beside the file (newest first) with their
378 local time and what they change. Only the newest three dated copies and any from the last 7 days are kept: setting one aside deletes the older ones. An open removes only an autosave that matches the file.
379 Voiceover sources are unsaved until project_save: the WAV is imported as a source, and the project file names it only after a save.
380 frame and contact_sheet also save their PNGs to ~/.cache/edith/frames/<project>/ (<project> is the project file's name, or untitled;
381 $XDG_CACHE_HOME/edith/frames/ when that is set to an absolute path) and print the path.
382 A frame shows the file's own pixels: edith draws no stamp on it, so a source with a timecode burned into its picture
383 (the test clips have one) shows it. A contact sheet labels each tile with its time in a band above the tile.
384 Undo: one edit call is one step, 100 steps for the session; the history is lost when the server exits.
385 media_relink is one undo step: undo puts the old file back and redo points the source at the new one.
386 media_bin {action: create|rename|remove|move|favourite} files sources in bins (named folders, one level of nesting) and stars favourites; each call is one undo step. media_list shows each source's bin and star. Saved as format v51 lines (bin, srcbin, srcfav).
387 Checkpoints last longer: checkpoint {name} saves a full copy to <project dir>/checkpoints/<stem>/<name>.edith
388 (beside the project file, once the project has a path: project_new {path} or project_save; with no path at all
389 the copy goes to the temp directory and is lost on reboot). The open project is untouched.
390 checkpoints lists them, including ones from an earlier run.
391 restore {name} first saves the open project as a checkpoint named before-restore-<name> (a suffix when that name is
392 taken), so the state before the restore stays on disk and checkpoints lists it; then it replaces the open project with
393 the named one. The undo history is cleared, and the restore itself cannot be undone, but the before-restore checkpoint can be restored.";
394
395const BURN_CAPTIONS: &str = "\
396BURN_CAPTIONS
397 burn_captions {track?, size?, outline?, boxed?, place?, family?, animation?, highlight?, box?, uppercase?, words_per_line?} draws one subtitle track's text into the picture. Pass the object, true for the defaults, or false for none.
398 Accepted by export_start, frame and contact_sheet (not with a source: those draw no timeline captions).
399 family: the font family the caption is set in, by the name the GUI's font list shows (family:\"Noto Serif\"). Default: the bundled Archivo; a name the system does not have draws in Archivo.
400 track: the track index, as in subtitles. Default: the track placed on the first caption lane with clips,
401 else track 0. A bitmap track (PGS) is refused, and so is a track with no text.
402 size: text height (the em size) as permille of the frame HEIGHT, not the width. 50 (the default) is 5% of the height; 10 to 200.
403 In pixels: size × height / 1000. At 1920x1080 the default is 54 px; at 1080x1920 (9:16) it is 96 px, nearly 9% of the width,
404 so a cue wraps at about 23 characters. For 9:16 use size 30 (58 px, about 5% of the width, about 38 characters a line on one line).
405 outline: none, thin (default) or thick. boxed: a translucent black box behind the text (default true).
406 place: bottom (default), top or centre. A lower third at the bottom collides with bottom captions: burn them at
407 place:\"top\", or move the lower third (title_add with place:\"top\", or transform) when the bottom is wanted for captions.
408 export_start and frame name a clash: a caption burned in the same place as a title on screen at the same time, as \"at 86.5s the caption overlaps title '...' (both at the bottom): burn_captions {place:\"top\"} or move the title\".
409 animation: none (default, the static cue), karaoke (the whole chunk shown, the word being spoken in the highlight colour),
410 pop (words appear as they are spoken, each popping from 125% to 100% in 120 ms), bounce (the word being spoken is raised and enlarged, easing down)
411 or word (one big word at a time, popping in). The highlighted word is the one whose time has come: in karaoke, pop, bounce and word it is drawn in `highlight`.
412 highlight: #rrggbb or #rgb (default #ffd600). box: true makes the highlight a rounded box of that colour behind white text (not the black `boxed`). uppercase: capitals.
413 words_per_line: at most N words on screen at once (2 to 4 is the shorts style); a longer cue is re-chunked by its word times, and a pause of 0.7 s or more
414 also starts a new chunk. 0 (default) keeps each cue whole, with its own line breaks. words_per_line and uppercase work with animation none too.
415 Word times: a cue made by auto_captions keeps the transcript's real word times (saved in the project), so karaoke follows the speech. Editing the cue's text drops them;
416 move and trim shift and clip them. A cue without them (SRT, VTT, typed) spreads its words over the span by letter count; a cue with no words draws nothing.
417 Clip speed and speed ramps are already in the cue times, so a sped-up clip animates at its own pace.
418 The defaults for animation, highlight, box, uppercase and words_per_line come from the project (project_settings {captions:{...}}, saved with it, undoable);
419 a key in burn_captions overrides it for that call. Preview and export draw the same pixels: frame {burn_captions} shows what the export will.
420 Lines keep the cue's own line breaks when they fit; a line too wide for the frame wraps, its words spread evenly over the lines.
421 Text is drawn from bundled Noto faces for Latin, Greek, Cyrillic, Arabic, Hebrew, Devanagari and Thai, shaped, with right-to-left text in order. Colour emoji and CJK come from the system's Noto Color Emoji and Noto Sans CJK when those are installed; without them emoji draw monochrome and CJK draws as empty boxes here: use soft subtitles (export_start subtitles) for CJK then. A character no face has draws as a box, and the reply names it.
422 Overlapping cues are all drawn, stacked upward from the bottom in start order.
423 Burned captions are pixels, not a track: a re-imported export has no caption text to read back. Check them by eye with frame or contact_sheet.";
424
425const OVERLAYS: &str = "\
426OVERLAYS (a logo or still over the picture)
427 A still is a picture with no sound. A lane higher up draws over the lanes below it, so a still on V2 sits over V1 wherever it is placed.
428 1. Import the still: media_import {paths:[\"<dir>/logo.png\"]}. It becomes a source (src:N).
429 2. Add the lane above the picture, then place the still on it: edit {ops:[{op:\"lane_add\", kind:\"video\"}]}, then edit {ops:[{op:\"place\", source:\"src:1\", lane:\"V2\", at:\"1s\"}]}. A still is placed 5 s long; set its length with edit {ops:[{op:\"trim\", clip:\"V2@30\", edge:\"out\", to:\"4s\"}]} (to is the timeline time the edge lands on; V2@30 is the still placed at 1s, which is frame 30 at 30 fps). Without a lane, place links V1 and A1, and a still has no sound to put there.
430 3. Put it in a corner: edit {ops:[{op:\"transform\", clip:\"V2@30\", corner:\"bottom-right\", scale:0.3}]} puts a picture 30% of the canvas wide in the bottom-right corner, 32 px in from each edge. corner is centre, top-left, top-right, bottom-left or bottom-right; it keeps the scale you give (or the one already set), and margin:N sets the gap in pixels. The engine measures the picture itself, so a 16:9 still and a square logo both land flush. Giving x or y with corner is refused. Picture in picture is corner:\"bottom-right\" with scale:0.3.
431 x and y still work for any spot off a corner: they move the centre off the canvas centre, as fractions of the canvas width (x) and height (y), positive right and down, negative left and up. x:0.6 puts the still past the right edge, and the reply warns when a clip is mostly off the canvas. scale multiplies the size the picture is fitted to (0.05 to 8).
432 4. Choose how it fills its box: edit {ops:[{op:\"fit\", clip:\"V2@30\", policy:\"fit\"}]}. The policies are fit, fill, stretch and center.
433 5. Make it translucent: edit {ops:[{op:\"transform\", clip:\"V2@30\", opacity:0.5}]} is a 50% logo over the picture below. opacity runs from 0 (clear) to 1 (opaque, the default), and it keeps the placement set in step 3.
434 Check it with frame {at:\"2s\"}: the reply lists the lanes at that time and which one is on top.
435";
436
437const SEQUENCES: &str = "\
438SEQUENCES AND COMPOUND CLIPS
439 A project holds several named sequences (timelines). Size, frame rate and the look settings are the project's; lanes, clips, markers and chapters belong to each sequence. One is active, and every tool works on it.
440 1. sequence {action:\"list\"} shows them (* is active); new {name?}, rename {sequence, new_name}, duplicate {sequence, name?}, delete {sequence} and switch {sequence} manage them. Switching is not an undo step; the others are.
441 2. Group a stretch of clips into one: edit {ops:[{op:\"nest\", clips:[\"V1@0\",\"V1@90\"], name:\"Intro\"}]}. The picked clips (and their linked sound) move into a new sequence and a compound clip stands where they were; the picture and sound are the same. One undo step. break_apart {clips:[\"V1@0\"]} puts the contents back.
442 3. Reuse a sequence: place_sequence {sequence:\"Intro\", at:\"30s\"}. A sequence that holds itself, directly or through others, is refused.
443 4. Work inside one: sequence {action:\"switch\", sequence:\"Intro\"}, edit, switch back. Or give timeline, clip_info, edit or export_start a `sequence` argument: the read leaves the active sequence alone; edit leaves the named one active.
444 5. export_start exports the active sequence, or `sequence`. Nested sound and picture render as the flat timeline would.
445 A compound clip trims, splits, moves, fades and takes gain like any clip; it has no speed, ramp or reverse (refused), and its own colour, effects and transform are not applied (grade the clips inside). Captions and titles inside a sequence play only when that sequence is exported or active, not inside a compound. The frame rate cannot change once there are two sequences. Saved as format v45 only when a project has more than one sequence.
446";
447
448const MULTICAM: &str = "\
449MULTICAM (several cameras of one event, cut by angle)
450 1. media_import every camera's file (they should share a sound the cameras heard: a clap, a voice, a song).
451 2. multicam_create {sources:[\"src:0\",\"src:1\",\"src:2\"], name?:\"Interview\", sync?:\"audio\"}: the cameras are lined up by the shape of their sound (accurate to 20 ms; sync:\"start\" lines them up at their starts instead) and one multicam clip goes on V1 (picture) + A1 (sound), linked. The reply lists every angle, how it was synced and a match score; an angle that did not match (or has no sound) starts with the others and says so. It plays angle 1.
452 3. Cut between the cameras: edit {ops:[{op:\"angle\", clip:\"V1@0\", at:\"12s\", angle:2},{op:\"angle\", clip:\"V1@0\", at:\"20s\", angle:1}]}. Each op cuts the clip at `at` and shows the angle from there; the sound follows the picture. audio:2 keeps the sound on angle 2 (a lav mic, say) whatever the picture shows; audio:\"follow\" lets it follow again. Angles are numbers from 1 or the names the reply shows. Every segment is an ordinary clip: trim, move or delete it with the usual ops.
453 4. frame {at} and contact_sheet show the cut; timeline names each segment's angle (multicam \"Interview\" angle 2 \"cam_b\").
454 5. multicam_flatten {clip:\"V1@0\"} replaces all the segments with the plain camera clips they play (the picture does not change), for effects or colour on one camera's stretch; the multicam sequence stays until deleted.
455 A multicam clip is a compound clip: it has no speed, ramp or reverse. One undo step each. Saved as format v47 (`mcam` and `angle` lines); a project without one keeps its older version.
456";
457
458const VERTICAL: &str = "\
459VERTICAL (9:16 from a 16:9 cut)
460 1. Start at the vertical size: project_new {path:\"<dir>/short.edith\", resolution:\"1080x1920\"}, or on an open project project_settings {resolution:\"1080x1920\"}. The canvas changes; the clips keep their times.
461 2. Choose how a 16:9 clip fits the 9:16 canvas, with edit {ops:[{op:\"fit\", clip:\"V1@0\", policy:\"...\"}]} on each picture clip. The policies:
462 fit (the default): the whole picture, aspect kept, with bars left and right. Nothing is cropped, but the sides are empty.
463 fill: the canvas is covered, aspect kept, and the sides of the picture are cropped away. The usual choice for a talking head or footage with the subject in the middle.
464 stretch: the whole picture is squeezed onto the canvas, aspect not kept. Avoid it for people.
465 center: 1:1 pixels, centred, padded or cropped per axis. Use it for a graphic that must keep its pixel size.
466 Choose fill when the subject is in the middle of the frame and cropping is fine; choose fit when the whole frame matters (a slide, a screen, a wide shot). Then check with frame.
467 Text-heavy 16:9 art (slides, screens with words): fit letterboxes it with bars, and fill crops the words off the sides. For the best result, make 9:16 versions of the slides instead.
468 3. Follow the subject automatically: edit {ops:[{op:\"reframe\", clip:\"V1@0\"}]} finds the subject in the footage (movement and contrast, no models), keeps the crop still while the subject stays put, and writes transform keys that fill the 9:16 canvas without ever showing an edge. It sets the clip's fit to fit, replaces the clip's transform keys, and is one undo step; smoothness 0..1 (default 0.5) sets how slowly the crop follows, and aspect:\"9:16\" checks the project is that shape. Refine the keys with transform_keys, or take them off with transform_keys {clip, clear:true}. A talking head that stays put needs only fill; reframe pays off when the subject moves across a wide shot.
469 3b. Or reframe by hand: crop first, in fractions of the source, then move and zoom. A 16:9 picture keeps about a third of its width for 9:16, so crop [0.34,0.34,0,0] keeps the middle: edit {ops:[{op:\"transform\", clip:\"V1@0\", crop:[0.34,0.34,0,0], x:-0.1}]}.
470 4. Titles and captions are laid out on the canvas, so they adapt to the new size; look at a frame to check where they sit. CJK draws as empty boxes in titles and burned captions unless the system has Noto Sans CJK: use soft subtitles (export_start subtitles) for CJK, as help {topic:\"unsupported\"} says.
471 5. Or skip the project change: export_start {out:\"<dir>/short.mp4\", size:\"1080x1920\", fit:\"fill\"} draws this export at 9:16 and fills every picture clip to the canvas, with the project kept at 16:9. fit:\"fit\" keeps the whole picture with bars instead. Check the file with media_probe.
472";
473
474const STRETCH: &str = "\
475STRETCH (a short shot made to fill a longer slot)
476 place with stretch:true plays the whole source over `length`, sped up or slowed to fit: edit {ops:[{op:\"place\", source:\"src:0\", lane:\"V1\", at:\"6s\", length:\"6s\", stretch:true}]}. A 5 s shot in a 6 s slot runs at 0.83 speed. Prerequisite: src:0 is that 5 s shot, and stretch takes a slot only within 0.25..4 of the shot's length, so a 5 s shot fits slots from 1.25 s to 20 s. Without stretch, a length shorter than the source takes the source from its in point over that span, which cuts rather than slows; a length longer than the source is refused (\"runs past the source end\"), not cut short, so add stretch:true to fill the slot.
477 A placed clip can be slowed afterwards with edit {ops:[{op:\"speed\", clip, x}]}: x 0.5 runs it twice as long, and the range is 0.25 to 4. x is the absolute rate, not a multiplier: sending 0.5 on a clip already at 0.5 changes nothing. Its end moves; ripple:true moves the clips after it too: edit {ops:[{op:\"speed\", clip:\"V1@12\", x:0.5, ripple:true}]}.
478";
479
480const UNSUPPORTED: &str = "\
481NOT SUPPORTED (these are not in the tools; do not search for them)
482 Transitions beyond the seven kinds (dissolve, dip-black, dip-white, wipe, slide, push, zoom): no custom shapes, no easing or keyframed progress, no transition between layered pictures (only the clips of one lane blend). A kind changes the picture only; the sound always crossfades.
483 Reversed clips (reverse) have limits: they decode at 8 bits, so a 10-bit source loses its low 2 bits on a 10-bit export (banding is possible on HDR); hardware decode is off for them; the B side of a dissolve plays forward; waveforms and thumbnails draw forward.
484 CJK text in the picture, unless the system has Noto Sans CJK: it draws as empty boxes in a title or in burned captions (burn_captions). Colour emoji need the system's Noto Color Emoji; without it emoji draw monochrome. A character no face has draws as a box either way; title_add names it in a warning, and frame names it in a caption. Soft subtitle tracks (export_start subtitles, in mp4 or mkv) keep that text, since the player draws it: use them for CJK when the font is missing.
485 10-bit: AV1 and HEVC only (export_start bit_depth:10, or a 10-bit source); H.264 and the other formats are 8-bit and refuse bit_depth:10. Grades, titles, captions, transitions and layers are composed at 8-bit precision and shifted up, so their extra range is not used.
486 Sources the decoder refuses: HEVC in 4:4:4, 4:0:0 (monochrome) or 12-bit, and AV1 in 4:4:0. AV1 in 4:2:2, 4:4:4 or 12-bit, and HEVC 4:2:2, decode.
487 Source picture files that the decoder refuses (for example 12-bit HEVC, or a display matrix that is not a quarter turn):
488 media_probe names the reason, and media_import refuses them.
489 Sound codecs nothing here decodes (for example WavPack): media_probe names the codec and warns that its sound will be silent.";
490
491/// The notes under the chapter ops in `help {topic:"ops"}`, after the op signatures.
492const MARKERS: &str = "\
493MARKERS
494 A chapter is C@<frame> (the frame it starts on) or C#n (its place in the list, 1 first). chapter_add, chapter_set and chapter_remove take them.
495 Cuts and inserts move chapters with the picture. timeline prints a chapters: line and a chapters_text YouTube description, with warnings.
496 Comment markers are separate from chapters: marker_add {at, name, note?, color?, length?}, marker_set {marker, ...}, marker_remove {marker}. A marker is M@<frame> (the first on that frame) or M#n. color is red, orange, yellow, green, blue or purple; a length makes a range. They move with the picture as chapters do; timeline prints a markers: line and a markers list. export_start chapters:\"markers\" writes them as the file's chapters. beats {clip, every?} marks a sound clip's beats as yellow \"Beat\" markers (every:1 default, 2 or 4 for bars), replacing that clip's earlier beat markers.";
497
498/// The `looks` topic: what a look is, the built-ins, and where saved ones live.
499const LOOKS: &str = "looks: a look is a whole colour grade under one name. The look op applies it; the colour card's Looks row shows the same list.
500 Built-in (colour presets, no LUT file needed):
501 Warm warmer temperature, red up and blue down in the wheels
502 Cool cooler temperature, blue up
503 Teal & orange teal shadows, orange highlights, a little more colour
504 Bleach bypass low colour, more contrast, an S curve on the master
505 Black & white no colour at all
506 Faded film lifted blacks, softer contrast, muted colour
507 High contrast more contrast and a little more colour
508 Vintage muted colour, a warm cast, lifted blacks
509 Saved: 'Save current as look' on the colour card writes $XDG_DATA_HOME/edith/looks/<name>.look (or ~/.local/share/edith/looks). The file is plain text: the sliders, the wheels, the curves, and a LUT's path and mix if the grade has one.
510 edit {ops:[{op:\"look\", clip:\"V1@0\", name:\"Warm\"}]} replaces the clip's grade with the look in one undo step. A name nobody has is refused with the list of looks there are.
511 auto_color is not a look: it reads the clip and sets a correction from its own frame.";
512
513const VISUALIZER: &str = "\
514VISUALIZER
515 clip_info says \"visualizer off\" for an ordinary clip. \"visualizer on (style S, fast)\" means the clip is a
516 visualizer: its picture is drawn from the sound it plays, as a waveform, not from its source picture.
517 Set it on a clip whose sound is drawn. On an AUDIO clip (a voiceover or music with no picture) on:true makes a linked
518 waveform picture: the op places it on a free video lane at that clip's start, over the same span, grouped with the sound
519 clip so moves, trims and deletes carry it. The waveform goes on a new top picture lane (V2 or V3, the next free one above
520 the picture; the reply names it, e.g. V2@0), and it covers the picture under it where they overlap. style defaults to fill:
521 edit {ops:[{op:\"visualizer\", clip:\"A2@0\", on:true, style:\"ring\", fast:true}]}.
522 Position and size it with transform on that picture: edit {ops:[{op:\"transform\", clip:\"V2@0\", x:0, y:0.27, scale:0.4}]} puts it as a bottom band, 40% of the height, inside the canvas.
523 (x and y move its centre by a share of the canvas, -1 to 1, y positive down; scale multiplies its size). opacity under 1 lets the picture show through.
524 Keep it on the canvas: its centre sits at (0.5 + x, 0.5 + y) of the canvas, so a box of height scale (a 16:9 waveform on a 16:9 canvas) stays inside when y is at most 0.5 − scale / 2. With scale 0.4, y:0.27 puts its bottom edge at 0.97 of the height; y:0.7 would put the centre at 1.2 of the height, entirely off the canvas.
525 Turn it off with on:false on the waveform picture (V2@0), or on the sound clip it draws (A2@0), which also turns the picture off.
526 on: true or false (false turns it off). style: fill, ribbon, ring or wave, the look of the trace.
527 fast: true paints the trace from a 0.2 s window instead of 2 s, so it reads as a line (an Audacity-style view).
528 Omitted keys keep their setting. One undo step.";
529
530/// Full text for ops whose manual line is cut short or leaves out the ranges. These
531/// replace the manual's text in `help {topic: op}`; the signature still comes from the manual.
532const OP_TEXTS: &[(&str, &str)] = &[
533 (
534 "replace",
535 "replace {clip, source, in?} — the replace edit: the clip is overwritten by `source` from `in` (a source time, default the source's start; a still takes none), keeping its place and its length, and nothing else moves. The clip's linked other half (the sound of a picture clip, the picture of a sound clip) is replaced too when it covers the same frames and the new source has that half. Refused when the source has fewer frames after `in` than the clip is long, when the source lacks the clip's kind (a picture-less file onto V1), or when a lane is locked. The new clip starts plain: the old one's effects, colour and speed are not carried (copy_look first reads them, then copy_look back). e.g. edit {ops:[{op:\"replace\", clip:\"V1@0\", source:\"src:1\", in:\"2s\"}]} Prerequisite: V1@0 exists and src:1 is imported and at least as long as the clip after 2 s. One undo step.",
536 ),
537 (
538 "nudge",
539 "nudge {clips:[addrs], by} [group] — moves the clips and their link groups `by` along their lanes (-1f, +0.5s, -00:00:01:00), the nudge key's move. All or nothing: a neighbour in the way refuses the whole move and names nothing moved; the start clamps at 0. Unlike slide it needs no neighbours, unlike move it takes a distance, not a place. e.g. edit {ops:[{op:\"nudge\", clips:[\"V1@120\"], by:\"-5f\"}]} Prerequisite: V1@120 exists with at least 5 free frames before it. One undo step.",
540 ),
541 (
542 "swap",
543 "swap {a, b, ripple?=true} [clip] — two clips on one lane trade places: b takes a's start and a lands where b was. With ripple:true (the default) what lies between them ripples by the difference in their lengths, so the later clips move; the reply lists every clip that moved. With ripple:false nothing else moves: the two clips trade slots, a shorter clip leaves a gap in its slot, and a longer one is refused where it would overlap what follows. A clip in a take (linked to a clip on another lane, such as a picture with its sound) is refused, since swap does not move a take apart: the refusal names the clip, and the take must be ungrouped first. One undo step, and a refusal changes nothing.",
544 ),
545 (
546 "move",
547 "move {clip, at, to_lane?, titles?, insert?, split_captions?} [group] — slide the clip, with its take, to `at` on its own kind of lane (V to V, A to A; to_lane names another lane of that kind). A drop on empty frames lands exactly there, jumping over any clips between. Into occupied space it refuses and names the clip in the way; a head that would land inside a clip goes as far as the room allows, and the reply says what `at` was asked for. insert:true is a ripple move: the clip leaves its slot, the slot closes as ripple_delete closes one, and the clip lands at `at` with the later clips on those lanes pushed to make room. If the ripple would close over a clip outside the moved clip's take, insert:true refuses and names it: move without insert, or lift that clip and close_gaps. Titles: one wholly over the moved picture moves with it; titles:true also carries one it only partly covers; titles:false carries none, and the reply names each that stays. A caption spanning the clip's old edges is refused by name with insert:true unless split_captions:true, which splits it at the edge and reports both halves.",
548 ),
549 (
550 "speed",
551 "speed {clip, x, ripple?, lanes?} [group] — rate 0.25..4, absolute: x is the clip's new rate, not a multiplier, so re-sending 0.5 on a clip already at 0.5 changes nothing. The clip's length is divided by x: x 0.5 runs it twice as long and its end moves. A neighbour in its way refuses unless ripple:true, which moves the later items in the ripple scope by the change in length (slower pushes them later, faster closes the gap). Clip speed on audio keeps pitch (time-stretch). A voiceover's pace is set when it is rendered: voiceover's speed argument (0.5..2), not speed. The scope is the edited lane and the lanes of its linked clips; lanes:[...] changes it. A clip on another lane that spans the change is never cut: outside the scope it is left in place and the reply says so (\"A2@0 spans the change and was left in place\"); inside an explicit lanes it refuses by name. This holds for shortening and lengthening alike. help {topic:\"ripple\"} says which lanes move, and help {topic:\"recipes\"} has the narration case.",
552 ),
553 (
554 "freeze",
555 "freeze {at, duration, lane?, insert?=true} — holds the picture at `at` for `duration`. The composed frame is written to <project folder>/freeze/ when the op runs, so the project needs a path (project_new {path} gives one, saved or not) and that folder must exist; the project file itself need not be saved yet, and project_save writes the timeline. A project with no path is refused: project_save {path} first. insert=true ripples first, as insert_time: everything after moves `duration` later, and audio gets silence. insert:false overlays the still without pushing: with a lane it overwrites `lane` for `duration` (what is under it there is covered or cut, nothing after it moves); insert:false with no lane puts the still on a new top video lane over the picture, and nothing underneath is touched. The lane defaults to V1 only when insert is true. A dry run writes nothing. An undone freeze leaves its still in the media library (media_remove drops it).",
556 ),
557 (
558 "ripple_delete",
559 "ripple_delete {clip, lanes?} — cut the clip's span out of every lane in the ripple scope, so the later clips there move up to close the gap. Which lanes are in scope, and how lanes:[...] changes it: help {topic:\"ripple\"}. It is the same ripple as delete, and also reports the sound drift and what the ripple leaves behind.",
560 ),
561 (
562 "delete",
563 "delete {clip} [group] — remove the clip and RIPPLE: the clips after it move up to close the gap, the same cut as ripple_delete over the same ripple scope (its lane and the lanes of its linked or grouped clips; lanes:[...] changes it, help {topic:\"ripple\"}). The reply lists each clip that moved, as old → new. A take cut to one span on every member moves whole; a take whose members differ in length closes only each member's own lane. Titles and caption cues in the cut go with it, and the reply names them. If the ripple would cut a clip outside the deleted clip's take (a detached picture under a detached sound, say), delete refuses and names it: lift the clip, or lift that one too and close_gaps. One undo step.",
564 ),
565 (
566 "lift",
567 "lift {clip} [clip] — remove the clip alone and LEAVE A GAP where it was: nothing moves, on its lane or any other. Use delete or ripple_delete to close the gap. One undo step.",
568 ),
569 (
570 "gain",
571 "gain {clip, db (-60..24) | add_db} — the clip's own volume in dB, on top of its lane's. db is absolute, add_db relative to where the clip is now; the result is clamped to -60..24. Audio clips only: a video clip has no volume of its own here, so it is refused by name; set it on the audio clip split from the same take.",
572 ),
573 (
574 "duck",
575 "duck {lane, under, depth_db?=-12, threshold_db?=-40, attack_ms?=80, release_ms?=400, off?} — the audio lane `lane` drops by depth_db while the audio lane `under` (the key) is above threshold_db. off:true removes the duck and needs no `under`. A locked lane refuses it.",
576 ),
577 (
578 "deinterlace",
579 "deinterlace {clip, mode: frame|field|off} — how a video clip's interlaced source is made progressive; frame is the default. It only matters for an interlaced source (media_probe reports interlaced tff or bff); on a progressive one it does nothing. field (double rate) and off are stored and saved but the render acts on frame for now.",
580 ),
581 (
582 "generator_add",
583 "generator_add {kind: solid|gradient|countdown|bars|tone|rectangle|ellipse|line|arrow, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?, lane?=V1, at?, duration?=5s} — places a generated clip: a picture made from numbers, not a file. tone (a sine on an audio lane) takes hz?=1000 (20–20000), level?=-20 (RMS dBFS, −60 to −3), lane?=A1, at?, duration? in whole seconds (10 by default); it is written once as a 48 kHz mono WAV under the data folder solid takes color (\"#ff3366\" or \"ff3366\"); gradient takes color, color2 and angle (0..359 degrees, 0 left to right, 90 top to bottom); countdown takes from (whole seconds, 1..3600; its duration defaults to the count) and draws a big number with a sweep; bars is colour bars. rectangle, ellipse, line and arrow are shapes on a transparent canvas that composite over the lanes below (put them on V2 or higher): fill and stroke are \"#rrggbb\" or \"none\", width is the stroke in pixels (0..400; a line and an arrow are all stroke, so they need width above 0), radius rounds a rectangle (0..2000); a line runs left to right across the canvas and an arrow points right, turn them with the transform op. A shape lands at 40% scale; its size and place are the clip's transform. A param the kind does not take is refused by name, as is a colour that is not six hex digits. `lane` must be a video lane the timeline has (lane_add first); `at` defaults to the end of that lane; the clip overwrites what it lands on, as a still does. It is an ordinary clip afterwards: trim, move, split, color, transform and effects all work on it. The reply gives its address (V1@0). A project that uses one saves as format v48.",
584 ),
585 (
586 "generator_set",
587 "generator_set {clip, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?} — changes the params of a generator clip (V2@450), merged onto its current ones; the clip keeps its place and length. A clip that plays a file is refused by name, an adjustment layer has no params, and a param the kind does not take is refused. One undo step.",
588 ),
589 (
590 "adjustment_add",
591 "adjustment_add {lane?=V2, at?, duration?=5s} — places an adjustment layer: a clip with no picture whose color grade and effects (color, wheels, curves, lut, effect add) reach everything composed beneath it on the lanes under. Put it on a lane above what it should tint. With no lane it goes on V2, added when the timeline has only V1; a named lane must exist. at defaults to the end of the lane. Saved as format v48.",
592 ),
593 (
594 "label",
595 "label {clip | clips, value} — sets the colour label of one clip (clip:\"V1@0\") or several (clips:[\"V1@0\",\"A1@0\"]). value is a label name (Violet, Iris, Caribbean, …; any case), a number 1..8, or none to clear it. A label is for finding clips in the timeline and changes nothing in the render. Undoes in one step; the reply lists the addresses it touched. Saved as format v48.",
596 ),
597 (
598 "enable",
599 "enable {clip | clips, on} — on:false switches the clip off: it stays on the timeline, but playback, frames and export skip its picture and sound (an off adjustment layer stops adjusting); on:true brings it back. The timeline shows `disabled`. A single undo brings it back; the reply names the clips it changed. Saved as format v48.",
600 ),
601 (
602 "lane_name",
603 "lane_name {lane, name} — the lane's display label; \"\" clears it. See help {topic:\"lanes\"}.",
604 ),
605 ("stabilize", crate::tools::stabilise::STABILIZE_OP_DOC),
606 ("reframe", crate::tools::reframe::REFRAME_OP_DOC),
607 ("angle", crate::tools::multicam::ANGLE_OP_DOC),
608 ("nest", crate::tools::sequence::NEST_OP_DOC),
609 ("break_apart", crate::tools::sequence::BREAK_APART_OP_DOC),
610 ("place_sequence", crate::tools::sequence::PLACE_SEQUENCE_OP_DOC),
611 (
612 "dynamics",
613 "dynamics {lane, gate?, nr?, compressor?, deesser?, reset?} — the audio lane's voice processors, run in this order on the lane's mix: noise gate, spectral noise reduction, compressor, de-esser (after each clip's own EQ, before the limiter). Each of gate, nr, compressor, deesser is true (on, defaults), false (off) or an object of settings: gate {threshold_db, attack_ms, release_ms, hold_ms, range_db}; nr {strength 0..1, floor_db, from:{from,to} (the noise to learn, else the quietest half second is found), learn:false}; compressor {threshold_db, ratio, attack_ms, release_ms, knee_db, makeup_db | auto_makeup}; deesser {threshold_db, amount 0..1, lo_hz, hi_hz}. reset:true turns all four off. nr needs a noise profile: it is learned when nr is turned on. The reply and timeline show which are on. A locked or non-audio lane refuses it. One undo step. clean_voice sets the whole chain at once.",
614 ),
615 (
616 "lane_gain",
617 "lane_gain {lane, db (-60..12)} — the lane's own level, -60 to +12 dB. Each clip's own gain adds on top of it.",
618 ),
619 (
620 "pan",
621 "pan {clip, pan (-1..1)} — the audio clip's place between the speakers: -1 left, 0 the middle (the default), 1 right. A balance: the far side is turned down along a quarter sine, the near side is left alone. The lane's lane_pan stacks on it. Audio clips only.",
622 ),
623 (
624 "pitch",
625 "pitch {clip, semitones (-12..12)} — the audio clip's pitch in semitones, fractions allowed (0.37): 12 an octave up, -12 an octave down, 0 the original (the default). The speed does not change, so the clip is the same length. Playback and export hear it. Audio clips only.",
626 ),
627 (
628 "lane_pan",
629 "lane_pan {lane, pan (-1..1)} — an audio lane's place between the speakers, on top of each clip's own pan.",
630 ),
631 (
632 "gain_key_remove",
633 "gain_key_remove {clip, at} — takes out the volume point within a frame of `at`. A miss refuses by name and lists the clip's points, so the time can be read off them.",
634 ),
635 (
636 "assemble",
637 "assemble {items:[{source,in?,out?}...], lane?, at?, gap?, audio?, audio_lane?, overwrite?} — keep, from several sources at once: each item is laid end to end after the last. Its start is the end of V1 (or of lane, when given) unless at is given, and 0 when that lane is empty or absent. With no lane the picture goes to V1 and its sound to A1, as place does. Stills are refused here (no in and out to cut): add one with place {source, at:\"end\"} or append {source}.",
638 ),
639 (
640 "captions_place",
641 "captions_place {track, lane?, at?} — puts a subtitle track (from subtitles_import) on a caption lane: lane (S1 by default) and at (frame 0 by default) are optional. Until a track is placed it shows nothing on the timeline or in an export.",
642 ),
643 (
644 "subtitles_lang",
645 crate::tools::edit_subs::SUBTITLES_LANG_DOC,
646 ),
647 (
648 "split",
649 "split {at, lanes?} — cut every lane at `at`, or only `lanes`. The lanes not named keep their clip across `at`. A linked partner of a clip cut is cut too, and the reply names it. A cut is not a ripple: nothing moves.",
650 ),
651 (
652 "eq",
653 "eq {clip, bands:[{f, db, q?, kind?}], reset?} — the clip's equalizer, up to 20 bands. f 20-20000 Hz; \
654 db -12 to +12; q 0.3-12 (default 0.707); kind: peak (default), low_shelf, high_shelf, low_cut \
655 (high-pass: rumble, mic handling), high_cut (low-pass: hiss, air). bands replaces the whole \
656 equalizer; reset:true takes it off.",
657 ),
658 (
659 "limiter",
660 "limiter {on?, ceiling_db?} — the master limiter on the output: on true or false; ceiling_db -24 to 0 dBTP, \
661 the highest TRUE PEAK (dBTP, between samples included) the output may reach. Give either or both; it merges onto the current setting. \
662 project_settings takes a limiter object too.",
663 ),
664 (
665 "transform",
666 "transform {clip, x?, y?, scale?, rotate?, crop?:[l,r,t,b], opacity?, reset?} — the clip's place on the canvas. \
667 Units: x moves its centre right by x × canvas width (centre at (0.5 + x) × width), y moves it down \
668 by y × canvas height (positive down); both −1 to 1. scale multiplies the fit size, so with a fit that \
669 fills the canvas width scale 0.3 is 30% of the canvas width (0.05–8). rotate: degrees clockwise, drawn \
670 at the nearest 90. crop: [left, right, top, bottom], each a fraction of the source, 0 to 0.5. A clip \
671 moved off the canvas is clipped; on a layer above another, the clip beneath shows wherever this one \
672 does not cover. opacity: 0 (clear) to 1 (opaque, the default); below 1 the clip blends over the layers \
673 beneath it. reset:true clears all of it. A move or zoom over time is transform_keys (keyed placement; a keyed clip refuses transform).",
674 ),
675 (
676 "transform_keys",
677 "transform_keys {clip, keys:[{at, x?, y?, scale?, rotate?, opacity?, ease?}], clear?} — the clip's placement over its own time: \
678 a slow zoom (Ken Burns) on a still, or a move. Video clips only. Each key is the placement at one moment, with the \
679 same units as transform. at is clip-relative: \"0s\", \"2.5s\" or a frame count from the clip's start, \"50%\" of the \
680 clip, or \"end\". Between two keys every field moves in a straight line unless the key has an ease, which shapes \
681 the stretch that leaves it (the last key has no stretch): linear (the default), ease_in (slow start), ease_out \
682 (slow landing), ease_in_out (slow both ends; \"ease\" is the older name for it) or hold (keep this key's value until the next key, then jump). \
683 A custom curve is ease:\"bezier(x1,y1,x2,y2)\" or ease:[x1,y1,x2,y2], two control points each from 0 to 1 (no overshoot). \
684 The same ease works on opacity_keys, color_keys and the gain points. A key leaves a field it does not name held from the \
685 previous key, and the first key from the clip's own transform. The reply lists the keys in timeline time. \
686 clear:true takes the animation off, back to the clip's single transform. A keyed clip refuses transform: change \
687 its keys, or clear them, first. Up to 256 keys. Keys sit on the footage: trimming either edge drops the keys \
688 outside the clip and adds a key at the new edge holding the value there, so the picture on screen is unchanged; \
689 split and move carry the keys with them. \
690 Slow zoom, 20% over six seconds on a still (import it first, as in OVERLAYS): edit {ops:[{op:\"place\", source:\"src:1\", \
691 lane:\"V1\", at:\"0s\", length:\"6s\"}, {op:\"transform_keys\", clip:\"V1@0\", keys:[{at:\"0s\", scale:1.0}, \
692 {at:\"end\", scale:1.2, ease:\"ease_in_out\"}]}]}. The zoom holds at its first and last key; add {at:\"50%\", scale:1.1} \
693 for a middle key. A pan is the same with x and y: {at:\"0s\", x:-0.05}, {at:\"end\", x:0.05}.",
694 ),
695 (
696 "color",
697 "color {clip, brightness?, contrast?, saturation?, tint?, reset?} — the clip's grade: brightness -1..1 (0 is none), contrast 0..2 (1 is none), saturation 0..2 (1 is none), tint -1..1 (0 is none). A grade that changes over the clip is color_keys; a clip with colour keys refuses color until they are cleared.",
698 ),
699 (
700 "look",
701 "look {clip, name} — the clip's whole grade becomes a look: a built-in (Warm, Cool, Teal & orange, Bleach bypass, Black & white, Faded film, High contrast, Vintage) or one saved from the colour card as \"Save current as look\". It replaces the colour sliders, wheels, curves and LUT in one undo step, and a keyed clip is refused until its keys are cleared. A name nobody has is refused with the list of looks there are. e.g. edit {ops:[{op:\"look\", clip:\"V1@0\", name:\"Teal & orange\"}]}. look {clip, save:\"My look\"} goes the other way: the clip's grade is saved as a look of that name (no undo step, the project does not change). help {topic:\"looks\"} explains them.",
702 ),
703 (
704 "auto_color",
705 "auto_color {clip} — reads a correction off the clip's middle frame as shot and writes it onto the grade: grey-world white balance into the wheels' red, green and blue gains, then brightness and contrast so the 0.5 % and 99.5 % luma percentiles land near 0.02 and 0.98. Saturation, tint, curves and the LUT are kept. The reply gives the values it set. Absolute, so a second run lands where the first did; one undo step. A keyed clip is refused. e.g. edit {ops:[{op:\"auto_color\", clip:\"V1@0\"}]}.",
706 ),
707 (
708 "wheels",
709 "wheels {clip, lift?, gamma?, gain?, reset?} — the colour wheels of the clip's grade. Each wheel is [master, red, green, blue], every value -1..1 with 0 neutral, \
710 or one number for the master alone; a channel's amount is its own plus the master's. lift moves the blacks and keeps white (1 puts black at half grey), \
711 gamma bends the mid-tones and keeps both ends (positive is brighter), gain scales from black (1 doubles, -1 is black). A wheel named replaces that wheel; \
712 the others stay. reset:true sets all three neutral. Order of the grade: wheels, curves, lut, then the color sliders. Colour keys animate the sliders only; \
713 the wheels hold steady under them. Warm the shadows, cool the highlights: edit {ops:[{op:\"wheels\", clip:\"V1@0\", lift:[0, 0.06, 0, -0.04], gain:[0, -0.03, 0, 0.04]}]}.",
714 ),
715 (
716 "curves",
717 "curves {clip, master?, red?, green?, blue?, reset?} — RGB curves on the clip's grade, after the wheels. Each is a list of up to 16 [input, output] points, \
718 both 0..1, inputs strictly rising, joined by a monotone cubic spline (no overshoot). An end the points leave open is pinned: (0,0) and (1,1). The master curve \
719 runs on all three channels first, then each channel's own. [] straightens that curve; reset:true straightens all four. A gentle S-curve: \
720 edit {ops:[{op:\"curves\", clip:\"V1@0\", master:[[0.25, 0.2], [0.75, 0.8]]}]}.",
721 ),
722 (
723 "lut",
724 "lut {clip, path?, mix?, clear?} or lut {relink, path} — a .cube LUT on the clip's grade, after the wheels and curves and before the color sliders. \
725 path: a .cube file (Adobe/Resolve format: 1D up to 65536 entries or 3D up to 65 per side, DOMAIN_MIN/MAX or LUT_3D_INPUT_RANGE honoured, 3D sampled \
726 tetrahedrally as ffmpeg's lut3d interp=tetrahedral is); the file is read now, and a missing or malformed one is refused with the line that is wrong. \
727 mix: how much of the LUT shows, 0..1 (default 1 when a path is set). clear:true takes it off. The path is saved in the project (relative when inside \
728 the project folder); if the file later goes missing the project still opens, the clip plays without its LUT, and project_status and clip_info name it: \
729 relink with lut {relink:\"<old path>\", path:\"<new path>\"} (every clip that used it, one undo step). The LUT reads Rec. 709 R'G'B' 0..1, as LUTs made for \
730 video expect. Recipe, a warm look at 80%: edit {ops:[{op:\"lut\", clip:\"V1@0\", path:\"~/luts/warm.cube\", mix:0.8}]}, then scopes {at:\"2s\"} to see the \
731 shift (red above blue in the parade, the cast toward red-yellow), then frame {at:\"2s\"} to look.",
732 ),
733 (
734 "mask_keys",
735 "mask_keys {clip, effect, keys:[{at, x?, y?, w?, h?, feather?, ease?}], clear?} — a rect or ellipse mask's centre (x, y), size (w, h) \
736 and soft edge (feather), all 0..1 of the frame, over the clip's own time. effect is the mask's stack position. A key that names \
737 no field holds the previous key's, and the first the mask's own. Pixelate under a mask takes the mask's keys too, so a face \
738 stays censored as it moves. clear:true takes the keys off. Up to 256 keys, sorted and clamped like opacity_keys. \
739 edit {ops:[{op:\"mask_keys\", clip:\"V1@0\", effect:1, keys:[{at:\"0s\", x:0.3, y:0.5}, {at:\"2s\", x:0.7}]}]}.",
740 ),
741 (
742 "effect_keys",
743 "effect_keys {clip, effect, keys:[{at, <parameter>?, ease?}], clear?} — animates any numeric parameter of the effect at stack \
744 position effect over the clip's own time: every effect's parameters can be keyed (a blur's radius, a vignette's amount and \
745 softness, a glow's threshold, a pixelate's size, a chroma key's tolerance, a mask's x, y, width, height and feather), named as \
746 the effect names them. A switch or a choice (a blend's mode, a mask's invert) cannot be keyed. A parameter a key leaves out \
747 takes the value the effect shows at that time. Up to 256 keys, sorted and clamped. \
748 edit {ops:[{op:\"effect_keys\", clip:\"V1@0\", effect:0, keys:[{at:\"0s\", radius:2}, {at:\"3s\", radius:20, ease:\"ease_in_out\"}]}]}.",
749 ),
750 (
751 "opacity_keys",
752 "opacity_keys {clip, keys:[{at, opacity, ease?}], clear?} — the clip's opacity over its own time, 0 (clear) to 1 (opaque): \
753 a fade-in of an overlay, a pulse. Video clips only. at is clip-relative as in transform_keys (\"0s\", \"50%\", \"end\"). A key that \
754 names no opacity holds the previous key's, and the first the clip's own. ease (linear, ease_in, ease_out, ease_in_out, hold, or bezier(x1,y1,x2,y2)) \
755 shapes the stretch that leaves the key. While a clip has opacity keys they give its opacity (transform's opacity is refused); \
756 the clip's fades multiply on top, so a fade-in over a half-opaque clip reaches half. clear:true takes them off. Up to 256 keys; \
757 trims, splits and moves carry them as they do transform_keys. A layer above another shows the one beneath through it as it \
758 fades; a lone clip fades toward black. Fade an overlay in over two seconds, easing: \
759 edit {ops:[{op:\"opacity_keys\", clip:\"V2@0\", keys:[{at:\"0s\", opacity:0, ease:\"ease_in_out\"}, {at:\"2s\", opacity:1}]}]}.",
760 ),
761 (
762 "color_keys",
763 "color_keys {clip, keys:[{at, brightness?, contrast?, saturation?, tint?, ease?}], clear?} — the clip's grade over its own time, \
764 with the value ranges of color (brightness -1..1, contrast 0..2, saturation 0..2, tint -1..1). Video clips only. at is \
765 clip-relative as in transform_keys. A key leaves a field it does not name at the previous key's value, and the first key \
766 at the clip's own grade. Each frame is graded exactly as a constant color of the interpolated numbers would be. ease \
767 shapes the stretch that leaves a key. While a clip has colour keys they give its grade (color is refused); clear:true takes \
768 them off. Up to 256 keys. A day-to-dusk grade: edit {ops:[{op:\"color_keys\", clip:\"V1@0\", keys:[{at:\"0s\", brightness:0, \
769 saturation:1}, {at:\"end\", brightness:-0.3, saturation:0.6, tint:0.2, ease:\"ease_in_out\"}]}]}.",
770 ),
771 (
772 "cut_regions",
773 "cut_regions {regions:[[from,to]...], lanes?} — ripple-cut spans (silence scans); titles move with the cut too. A fade at a cut point is dropped, and the reply reports each one. A music bed cut mid-bed leaves a seam: add a crossfade {clip, frames} on the clip before the join.",
774 ),
775 (
776 "transition",
777 "transition {clip, kind?=dissolve, length?, direction?, linked?} — how the clip's tail meets the next clip on its lane (the two must abut). kind: dissolve (the default, what `dissolve` sets), dip-black, dip-white (through the colour at the midpoint), wipe (soft edge), slide (the next clip moves in over this one), push (the next clip pushes this one out), zoom (cross-zoom: this clip scales up and fades while the next scales from 1.2 to 1). direction left|right|up|down (default left) is the way things move: wipe-left reveals the next clip from the right edge, so at the midpoint the left half is still this clip. length (or frames) is the overlap, clamped to the shorter clip; omitted, it keeps the clip's current one. timeline and clip_info show the kind. Sound is the usual crossfade for every kind. One undo step. A 1 s push to the left: edit {ops:[{op:\"transition\", clip:\"V1@0\", kind:\"push\", direction:\"left\", length:\"1s\"}]}.",
778 ),
779 (
780 "fit",
781 "fit {clip, policy: fit|fill|stretch|center} — how the clip's picture meets a canvas of another shape. \
782 fit (default): whole picture, aspect kept, centred; the bars are empty, so on a layer above another \
783 the clip beneath shows through them. fill: whole canvas, aspect kept, the picture is cropped. stretch: \
784 whole picture on the whole canvas, aspect not kept. center: no resampling, 1:1, padded or cropped.",
785 ),
786];
787
788/// The tools the server answers: the registered table plus `help` itself.
789pub fn catalogue() -> Vec<Tool> {
790 let mut all = server::tools();
791 all.push(tool());
792 all
793}
794
795/// The whole cheat sheet, as the `edith://help` resource and the `help` tool give it.
796pub fn sheet(tools: &[Tool]) -> String {
797 let header = header();
798 [header.as_str(), ADDRESSES, TIMES, VALUES, GROUPS_AND_LINKS, UNDO, &tool_list(tools), &ops_names(tools), RECIPES].join("\n\n")
799}
800
801/// The first 25 lines of the sheet, for the initialize `instructions`.
802pub fn short(tools: &[Tool]) -> String {
803 let head: Vec<String> = sheet(tools).lines().take(25).map(str::to_owned).collect();
804 format!("{}\nThe full sheet is the edith://help resource or the help tool.", head.join("\n").trim_end())
805}
806
807/// One topic of the help, or the whole sheet when `name` is None. A name is a fixed
808/// topic, an edit op name, or a tool name, in that order.
809pub fn section(tools: &[Tool], name: Option<&str>) -> Result<String, String> {
810 let Some(name) = name else {
811 return Ok(sheet(tools));
812 };
813 match name {
814 "ops" => Ok(ops_detail(tools)),
815 "times" => Ok(TIMES.to_owned()),
816 "recipes" => Ok(RECIPES.to_owned()),
817 "first_video" => Ok(FIRST_VIDEO.to_owned()),
818 "podcast" => Ok(PODCAST.to_owned()),
819 "lanes" => Ok(LANES.to_owned()),
820 "ripple" => Ok(RIPPLE.to_owned()),
821 "export" => Ok(EXPORT.to_owned()),
822 "subtitles" => Ok(SUBTITLES.to_owned()),
823 "captions" => Ok(captions_topic(tools)),
824 "project" => Ok(PROJECT.to_owned()),
825 "burn_captions" => Ok(BURN_CAPTIONS.to_owned()),
826 "overlays" => Ok(OVERLAYS.to_owned()),
827 "vertical" => Ok(VERTICAL.to_owned()),
828 "sequences" => Ok(SEQUENCES.to_owned()),
829 "multicam" => Ok(MULTICAM.to_owned()),
830 "stretch" => Ok(STRETCH.to_owned()),
831 "unsupported" => Ok(UNSUPPORTED.to_owned()),
832 "visualizer" => Ok(VISUALIZER.to_owned()),
833 "looks" => Ok(LOOKS.to_owned()),
834 other => {
835 if let Some(text) = op_topic(tools, other) {
836 return Ok(text);
837 }
838 if let Some(tool) = tools.iter().find(|t| t.name == other) {
839 return Ok(tool_topic(tool));
840 }
841 Err(unknown_topic(tools, other))
842 }
843 }
844}
845
846pub fn tool() -> Tool {
847 Tool {
848 name: "help",
849 description: "The edith cheat sheet: addresses, times, undo, the tool list, edit ops and recipes. Pass topic for one part: ops (every edit op with its arguments), times, recipes, lanes, ripple, export, subtitles, captions, project, burn_captions or visualizer, an edit op name (its manual entry), or a tool name (its arguments).",
850 schema: help_schema,
851 run: run_help,
852 }
853}
854
855fn help_schema() -> Value {
856 json!({
857 "type": "object",
858 "properties": {
859 "topic": {
860 "type": "string",
861 "description": topic_description()
862 }
863 }
864 })
865}
866
867/// The schema's description of `topic`: every fixed topic, from `TOPICS`, then the op and tool forms.
868fn topic_description() -> String {
869 format!(
870 "Omit for the cheat sheet. Topics: {}. An edit op name gives its manual entry; a tool name gives its arguments. \"ops\" lists every edit op with its arguments.",
871 TOPICS.join(", ")
872 )
873}
874
875fn run_help(_server: &mut Server, args: &Value) -> Reply {
876 let name = args.get("topic").and_then(Value::as_str);
877 match section(&catalogue(), name) {
878 Ok(text) => Reply::ok(text),
879 Err(text) => Reply::err(text),
880 }
881}
882
883/// The first sentence of a tool description, with its whitespace flattened. A sentence
884/// ends at a full stop followed by a capital, so `"<n>. track"` inside a description
885/// does not end it.
886fn first_sentence(text: &str) -> String {
887 let flat = text.split_whitespace().collect::<Vec<_>>().join(" ");
888 let end = flat
889 .char_indices()
890 .filter(|&(i, c)| c == '.' && flat[i + 1..].starts_with(' ') && flat[i + 2..].starts_with(|n: char| n.is_uppercase()))
891 .map(|(i, _)| i)
892 .next();
893 match end {
894 Some(i) => flat[..=i].to_owned(),
895 None => flat,
896 }
897}
898
899/// The note under the tool list: every tool takes its own arguments, and the two
900/// shapes an agent most often gets wrong.
901const TOOL_ARGS: &str = " Every tool takes its own arguments: help {topic:\"<tool>\"} lists any tool's arguments (media_probe takes paths, a glob, or both).
902 burn_captions {track:N} (on export_start, frame, contact_sheet) draws one caption track into the picture.
903 N is 0-based: the track index as the captions tool lists it, so the first track is 0.";
904
905fn tool_list(tools: &[Tool]) -> String {
906 let mut lines = vec!["TOOLS".to_owned(), TOOL_ARGS.to_owned()];
907 for (group, names) in GROUPS {
908 let rows: Vec<&Tool> = names.iter().filter_map(|n| tools.iter().find(|t| t.name == *n)).collect();
909 if rows.is_empty() {
910 continue;
911 }
912 lines.push(format!(" {group}:"));
913 lines.extend(rows.iter().map(|t| format!(" {:<18}{}", t.name, first_sentence(t.description))));
914 }
915 let grouped = |name: &str| GROUPS.iter().any(|(_, ns)| ns.contains(&name));
916 let rest: Vec<&Tool> = tools.iter().filter(|t| !grouped(t.name)).collect();
917 if !rest.is_empty() {
918 lines.push(" other:".to_owned());
919 lines.extend(rest.iter().map(|t| format!(" {:<18}{}", t.name, first_sentence(t.description))));
920 }
921 lines.join("\n")
922}
923
924/// The op names of the `edit` tool, read from the enum in its schema.
925fn edit_ops(tools: &[Tool]) -> Vec<String> {
926 let Some(edit) = tools.iter().find(|t| t.name == "edit") else {
927 return Vec::new();
928 };
929 let schema = (edit.schema)();
930 schema["properties"]["ops"]["items"]["properties"]["op"]["enum"]
931 .as_array()
932 .map(|ops| ops.iter().filter_map(|v| v.as_str().map(str::to_owned)).collect())
933 .unwrap_or_default()
934}
935
936/// The manual for the edit ops: the `edit` tool's description, or "" if it is not registered.
937fn edit_manual(tools: &[Tool]) -> &'static str {
938 tools.iter().find(|t| t.name == "edit").map_or("", |t| t.description)
939}
940
941/// The op names on one wrapped list, for the overview.
942fn ops_names(tools: &[Tool]) -> String {
943 let ops = edit_ops(tools);
944 let mut lines = vec!["EDIT OPS edit {ops:[{op, ...}]}".to_owned()];
945 if ops.is_empty() {
946 lines.push(" (the edit tool is not registered)".to_owned());
947 }
948 lines.extend(wrap(&ops, 78).into_iter().map(|l| format!(" {l}")));
949 lines.push(" help {topic:\"ops\"} for every edit op with its arguments; help {topic:\"<op>\"} for one op.".to_owned());
950 lines.push(" help {topic:\"ripple\"}: which lanes a ripple op moves, and lanes:[...].".to_owned());
951 lines.join("\n")
952}
953
954/// One entry of the edit manual: the section it sits under, the op it describes, and
955/// the entry as the manual writes it.
956struct OpEntry {
957 heading: String,
958 op: String,
959 text: String,
960}
961
962/// Every entry the manual gives an edit op, in manual order. An entry starts at an
963/// op name followed by ` {` where the line starts or follows a `·` or a `.`; so
964/// `title_set ... title_remove {title} ...` splits into two entries.
965fn manual_entries(manual: &str, ops: &[String]) -> Vec<OpEntry> {
966 let mut entries = Vec::new();
967 let mut heading = String::new();
968 for line in manual.lines() {
969 if is_heading(line) {
970 line.trim().clone_into(&mut heading);
971 continue;
972 }
973 let mut starts: Vec<(usize, &str)> = Vec::new();
974 for op in ops {
975 let pattern = format!("{op} {{");
976 for (i, _) in line.match_indices(&pattern) {
977 if starts_entry(&line[..i]) {
978 starts.push((i, op.as_str()));
979 }
980 }
981 }
982 starts.sort_by_key(|(i, _)| *i);
983 for (k, (start, op)) in starts.iter().enumerate() {
984 let end = starts.get(k + 1).map_or(line.len(), |(next, _)| *next);
985 let text = line[*start..end].trim().trim_end_matches('·').trim_end().to_owned();
986 entries.push(OpEntry { heading: heading.clone(), op: (*op).to_owned(), text });
987 }
988 }
989 entries
990}
991
992/// A manual section heading: a line of capitals and spaces only.
993fn is_heading(line: &str) -> bool {
994 !line.is_empty() && line.chars().all(|c| c.is_ascii_uppercase() || c == ' ')
995}
996
997/// Whether an op entry can begin right after `before` on its line.
998fn starts_entry(before: &str) -> bool {
999 let t = before.trim_end();
1000 t.is_empty() || t.ends_with('·') || t.ends_with('.')
1001}
1002
1003/// The argument signature of an entry: its head before the dash, with a `[group]` or
1004/// `[clip]` tag where the entry gives one.
1005fn signature(text: &str) -> String {
1006 let head = text.split(" — ").next().unwrap_or(text).trim_end_matches('.');
1007 let mut sig = head.replace("[group]", "").replace("[clip]", "").trim().to_owned();
1008 for tag in ["[group]", "[clip]"] {
1009 if text.contains(tag) {
1010 sig.push(' ');
1011 sig.push_str(tag);
1012 }
1013 }
1014 sig
1015}
1016
1017/// An op named inside another op's entry, such as `captions_place {track}` on the
1018/// subtitles_import line: the heading it sits under, its signature as written, and the line.
1019struct Mention {
1020 heading: String,
1021 sig: String,
1022 line: String,
1023}
1024
1025/// The first manual line that names `op` as `op {...}` inside another entry. The
1026/// name must not be the tail of a longer one (`move {` is not `sub_move {`).
1027fn mention(manual: &str, op: &str) -> Option<Mention> {
1028 let pattern = format!("{op} {{");
1029 let mut heading = String::new();
1030 for line in manual.lines() {
1031 if is_heading(line) {
1032 line.trim().clone_into(&mut heading);
1033 continue;
1034 }
1035 for (i, _) in line.match_indices(&pattern) {
1036 let bounded = line[..i].chars().last().is_none_or(|c| !(c.is_alphanumeric() || c == '_'));
1037 if !bounded {
1038 continue;
1039 }
1040 let rest = &line[i + op.len() + 1..];
1041 if let Some(close) = rest.find('}') {
1042 return Some(Mention {
1043 heading: heading.clone(),
1044 sig: format!("{op} {}", &rest[..=close]),
1045 line: line.trim().to_owned(),
1046 });
1047 }
1048 }
1049 }
1050 None
1051}
1052
1053/// Adds a signature under its heading, opening the heading the first time it is seen.
1054fn push_row(groups: &mut Vec<(String, Vec<String>)>, heading: &str, sig: String) {
1055 match groups.iter_mut().find(|(h, _)| h == heading) {
1056 Some((_, sigs)) => sigs.push(sig),
1057 None => groups.push((heading.to_owned(), vec![sig])),
1058 }
1059}
1060
1061/// The signature of an op from its `OP_TEXTS` override, when it has one. The manual line can
1062/// be shorter than the op (the manual's transform line has no `opacity`), so the override's
1063/// head wins, as its entry does in `help {topic:"<op>"}`.
1064fn override_signature(op: &str) -> Option<String> {
1065 OP_TEXTS.iter().find(|(o, _)| *o == op).map(|(_, text)| signature(text))
1066}
1067
1068/// `help {topic:"ops"}`: every edit op with its argument signature, one per line,
1069/// under the manual's headings. Each heading appears once, and an op the manual only
1070/// names inside another entry gets the signature written there.
1071/// A whole batch in the form `edit` takes: each op is a flat object, `{"op": name, ...args}`.
1072/// The op-list lines below show `place {source, at, …}`, which is the argument list, not the shape.
1073const OPS_EXAMPLE: &str = r#" Example batch (each op is a flat object with "op" and its arguments): edit {"ops":[{"op":"place","source":"src:0","at":"0s"},{"op":"fade","clip":"V1@0","in":"15f"}]}"#;
1074
1075fn ops_detail(tools: &[Tool]) -> String {
1076 let ops = edit_ops(tools);
1077 let mut lines = vec![
1078 "EDIT OPS, with arguments (help {topic:\"<op>\"} for one op's full entry)".to_owned(),
1079 " [group] = the op moves, trims or deletes the whole linked take; [clip] = it acts on that one clip alone.".to_owned(),
1080 " swap is tagged [clip], but a clip in a linked take is refused until the take is ungrouped (ungroup first).".to_owned(),
1081 OPS_EXAMPLE.to_owned(),
1082 ];
1083 if ops.is_empty() {
1084 lines.push(" (the edit tool is not registered)".to_owned());
1085 return lines.join("\n");
1086 }
1087 let manual = edit_manual(tools);
1088 let entries = manual_entries(manual, &ops);
1089 let mut groups: Vec<(String, Vec<String>)> = Vec::new();
1090 let mut placed: Vec<&str> = Vec::new();
1091 for e in &entries {
1092 if placed.contains(&e.op.as_str()) {
1093 continue;
1094 }
1095 placed.push(&e.op);
1096 push_row(&mut groups, &e.heading, override_signature(&e.op).unwrap_or_else(|| signature(&e.text)));
1097 }
1098 for op in &ops {
1099 if placed.contains(&op.as_str()) {
1100 continue;
1101 }
1102 match mention(manual, op) {
1103 Some(m) => push_row(&mut groups, &m.heading, override_signature(op).unwrap_or(m.sig)),
1104 // An edit_subs op the manual does not mention still sits under CAPTIONS.
1105 None if crate::tools::edit_subs::OPS.contains(&op.as_str()) => {
1106 push_row(&mut groups, "CAPTIONS", override_signature(op).unwrap_or_else(|| op.clone()));
1107 }
1108 None => push_row(&mut groups, "OTHER", op.clone()),
1109 }
1110 }
1111 for (heading, sigs) in groups {
1112 lines.push(heading);
1113 lines.extend(sigs.into_iter().map(|s| format!(" {s}")));
1114 }
1115 lines.push(MARKERS.to_owned());
1116 lines.join("\n")
1117}
1118
1119/// `help {topic:"<op>"}`: that op's manual entry, or None if `op` is not an edit op.
1120/// An `OP_TEXTS` override replaces the manual's text; the heading still comes from the manual.
1121fn op_topic(tools: &[Tool], op: &str) -> Option<String> {
1122 let ops = edit_ops(tools);
1123 if !ops.iter().any(|o| o == op) {
1124 return None;
1125 }
1126 let manual = edit_manual(tools);
1127 let text = OP_TEXTS.iter().find(|(o, _)| *o == op).map(|(_, t)| (*t).to_owned());
1128 if let Some(e) = manual_entries(manual, &ops).into_iter().find(|e| e.op == op) {
1129 let text = text.unwrap_or(e.text);
1130 return Some(format!("edit op `{op}` (under {}):\n {text}", e.heading));
1131 }
1132 Some(match (mention(manual, op), text) {
1133 (Some(m), Some(text)) => format!("edit op `{op}` (under {}):\n {text}", m.heading),
1134 (Some(m), None) => format!(
1135 "edit op `{op}` (under {}):\n {}\n the manual names it in another entry: {}",
1136 m.heading, m.sig, m.line
1137 ),
1138 (None, Some(text)) => format!("edit op `{op}`:\n {text}"),
1139 (None, None) => format!("edit op `{op}`: the edit manual has no entry for it"),
1140 })
1141}
1142
1143/// The refusal for a tool name nothing answers. An edit op name gets the shape it
1144/// goes in; any other name gets the nearest tool names.
1145pub fn unknown_tool(tools: &[Tool], name: &str) -> String {
1146 if edit_ops(tools).iter().any(|o| o == name) {
1147 return format!("{name} is an edit op: edit {{ops:[{{op:\"{name}\", …}}]}} — help {{topic:\"{name}\"}}");
1148 }
1149 let limit = (name.chars().count() / 3).max(2);
1150 let mut near: Vec<(usize, &str)> = tools
1151 .iter()
1152 .map(|t| (edit_distance(name, t.name), t.name))
1153 .filter(|(d, _)| *d <= limit)
1154 .collect();
1155 near.sort();
1156 let names: Vec<&str> = near.iter().take(3).map(|(_, n)| *n).collect();
1157 if names.is_empty() {
1158 format!("unknown tool `{name}`; help lists every tool")
1159 } else {
1160 format!("unknown tool `{name}`; did you mean {}? help lists every tool", names.join(", "))
1161 }
1162}
1163
1164/// The Levenshtein distance between two names, in characters.
1165fn edit_distance(a: &str, b: &str) -> usize {
1166 let b: Vec<char> = b.chars().collect();
1167 let mut prev: Vec<usize> = (0..=b.len()).collect();
1168 for (i, ca) in a.chars().enumerate() {
1169 let mut cur = vec![i + 1];
1170 for (j, cb) in b.iter().enumerate() {
1171 let sub = prev[j] + usize::from(ca != *cb);
1172 cur.push(sub.min(prev[j + 1] + 1).min(cur[j] + 1));
1173 }
1174 prev = cur;
1175 }
1176 prev[b.len()]
1177}
1178
1179/// `help {topic:"<tool>"}`: the tool's description and its argument list from its schema.
1180fn tool_topic(tool: &Tool) -> String {
1181 let schema = (tool.schema)();
1182 let mut lines = vec![format!("tool `{}`", tool.name), tool.description.to_owned(), String::new(), "ARGUMENTS".to_owned()];
1183 let Some(props) = schema.get("properties").and_then(Value::as_object).filter(|p| !p.is_empty()) else {
1184 lines.push(" (none)".to_owned());
1185 return lines.join("\n");
1186 };
1187 let required: Vec<&str> = schema
1188 .get("required")
1189 .and_then(Value::as_array)
1190 .map(|a| a.iter().filter_map(Value::as_str).collect())
1191 .unwrap_or_default();
1192 // The name column is as wide as the longest name, so no two names run together.
1193 let width = props.keys().map(|n| n.chars().count()).max().unwrap_or(0).max(12) + 2;
1194 for (name, prop) in props {
1195 let types = schema_types(prop);
1196 let kind = if types.is_empty() { "any".to_owned() } else { types.join("|") };
1197 let req = if required.contains(&name.as_str()) { "required" } else { "optional" };
1198 let mut desc = prop.get("description").and_then(Value::as_str).unwrap_or("").to_owned();
1199 if let Some(options) = prop.get("enum").and_then(Value::as_array) {
1200 let names: Vec<String> = options.iter().map(scalar_text).collect();
1201 if !names.is_empty() {
1202 desc = format!("{desc} one of: {}", names.join(", ")).trim_start().to_owned();
1203 }
1204 }
1205 let e_g = format!("(e.g. {})", example(name, prop));
1206 let desc = if desc.is_empty() { e_g } else { format!("{desc} {e_g}") };
1207 lines.push(format!(" {name:<width$}{kind:<16}{req:<10}{desc}"));
1208 }
1209 lines.join("\n")
1210}
1211
1212/// The JSON types a schema property takes: its `type` (one name or a list), or, when it has
1213/// none, the types of its `anyOf` or `oneOf` branches. Empty when the property names no type.
1214fn schema_types(prop: &Value) -> Vec<String> {
1215 match prop.get("type") {
1216 Some(Value::String(t)) => return vec![t.clone()],
1217 Some(Value::Array(ts)) => return ts.iter().filter_map(Value::as_str).map(str::to_owned).collect(),
1218 _ => {}
1219 }
1220 let mut types: Vec<String> = Vec::new();
1221 for branch in prop.get("oneOf").or_else(|| prop.get("anyOf")).and_then(Value::as_array).into_iter().flatten() {
1222 for t in schema_types(branch) {
1223 if !types.contains(&t) {
1224 types.push(t);
1225 }
1226 }
1227 }
1228 types
1229}
1230
1231/// One value of an argument's schema as JSON text, for the `e.g.` in help and in a refusal:
1232/// the schema's `examples` or `default` when it has one, else the first enum option, else a
1233/// value of its type. An array shows its item shape, `["clip.mp4"]`. Untyped parts show `…`.
1234pub fn example(key: &str, prop: &Value) -> String {
1235 let desc = prop.get("description").and_then(Value::as_str).unwrap_or("");
1236 shaped_example(key, prop, desc, false)
1237}
1238
1239/// The example for a value of `prop`, named `key`, described by `desc`. `in_list` is set for the
1240/// item of a list, where a time description does not make the item a time.
1241fn shaped_example(key: &str, prop: &Value, desc: &str, in_list: bool) -> String {
1242 if let Some(first) = prop.get("examples").and_then(Value::as_array).and_then(|a| a.first()) {
1243 return first.to_string();
1244 }
1245 if let Some(options) = prop.get("enum").and_then(Value::as_array).filter(|o| !o.is_empty()) {
1246 return options[0].to_string();
1247 }
1248 if let Some(default) = prop.get("default") {
1249 return default.to_string();
1250 }
1251 // An anyOf or oneOf with no type of its own shows its first branch.
1252 if prop.get("type").is_none()
1253 && let Some(branch) = prop.get("oneOf").or_else(|| prop.get("anyOf")).and_then(Value::as_array).and_then(|b| b.first())
1254 {
1255 return shaped_example(key, branch, desc, in_list);
1256 }
1257 let types = schema_types(prop);
1258 // A type that allows a list shows the list: the usual shape, and the one a caller most needs.
1259 let Some(ty) = types.iter().find(|t| t.as_str() == "array").or(types.first()) else {
1260 return "…".to_owned();
1261 };
1262 match ty.as_str() {
1263 "string" => string_example(key, desc, in_list),
1264 // The schema's minimum is a valid value, so it is the example, except a bitrate, where 1 kbps is valid but useless.
1265 "integer" | "number" => match (key, prop.get("minimum")) {
1266 ("bitrate_kbps", _) => "8000".to_owned(),
1267 (_, Some(min)) => min.to_string(),
1268 _ => "1".to_owned(),
1269 },
1270 "boolean" => "true".to_owned(),
1271 "array" => {
1272 // The usual lists, by name: a list of lanes, and the edit batch.
1273 match key {
1274 "lanes" => return "[\"V1\",\"A1\"]".to_owned(),
1275 "sources" => return "[\"src:0\",\"src:1\"]".to_owned(),
1276 "speakers" => return "[\"A1\",\"A2\"]".to_owned(),
1277 "range" => return "[\"0s\",\"5s\"]".to_owned(),
1278 "search" => return "[\"~/Videos\"]".to_owned(),
1279 "ops" => return OPS_EXAMPLE_VALUE.to_owned(),
1280 _ => {}
1281 }
1282 let items = prop.get("items").cloned().unwrap_or_else(|| json!({"type": "string"}));
1283 format!("[{}]", shaped_example(key, &items, desc, true))
1284 }
1285 "object" => {
1286 if key == "range" {
1287 return "{\"from\": \"0s\", \"to\": \"5s\"}".to_owned();
1288 }
1289 let fields: Vec<String> = prop
1290 .get("properties")
1291 .and_then(Value::as_object)
1292 .map(|p| p.iter().map(|(k, v)| format!("\"{k}\": {}", example(k, v))).collect())
1293 .unwrap_or_default();
1294 if fields.is_empty() { "{}".to_owned() } else { format!("{{{}}}", fields.join(", ")) }
1295 }
1296 _ => "…".to_owned(),
1297 }
1298}
1299
1300/// The example for the `ops` argument: a list holding one place op, a flat object with "op" and its arguments.
1301const OPS_EXAMPLE_VALUE: &str = r#"[{"op": "place", "source": "src:0", "at": "0s"}]"#;
1302
1303/// A string argument's example, by its name, then by its description. A file name shows the file it
1304/// takes (a project, a subtitle file, an output movie, or an input clip); an address, a source, a
1305/// lane or a time shows one of its own kind. A name it does not know shows "text".
1306fn string_example(key: &str, desc: &str, in_list: bool) -> String {
1307 let is_out = key == "out" || key.starts_with("out_") || key.ends_with("_out");
1308 let text = match key {
1309 _ if is_out => "cut.mp4",
1310 "save" => "cut.png",
1311 "glob" => "*.mp4",
1312 "folder" => "film_media",
1313 "clip" => "V1@0",
1314 "source" => "src:0",
1315 "lane" | "target" => "A1",
1316 "at" | "until" | "length" => "2s",
1317 "size" | "resolution" => "1280x720",
1318 "label" => "Draft cut",
1319 "name" | "new_name" | "sequence" => "Intro",
1320 "bin" | "parent" => "bin:1",
1321 "hint" => "Edith, LUFS",
1322 "language" => "en",
1323 "voice" => "en_US-ryan-high",
1324 "query" => "um",
1325 "text" => "Hello there",
1326 "notes" => "Rough cut, music to come",
1327 _ if key.contains("path") || key.contains("file") => {
1328 if desc.contains(".edith") {
1329 "talk.edith"
1330 } else if desc.contains(".srt") {
1331 "talk.srt"
1332 } else {
1333 "clip.mp4"
1334 }
1335 }
1336 _ if !in_list && desc.to_ascii_lowercase().contains("time") => "2s",
1337 _ if desc.contains("address") => "V1@0",
1338 _ => "text",
1339 };
1340 format!("\"{text}\"")
1341}
1342
1343/// An enum option as the help shows it: a string as is, a number as its digits.
1344fn scalar_text(v: &Value) -> String {
1345 match v {
1346 Value::String(s) => s.clone(),
1347 other => other.to_string(),
1348 }
1349}
1350
1351/// The captions workflow, then the `captions` tool's own arguments: the tool shares its
1352/// name with this topic, so the topic has to answer for both.
1353fn captions_topic(tools: &[Tool]) -> String {
1354 match tools.iter().find(|t| t.name == "captions") {
1355 Some(tool) => format!("{CAPTIONS}\n\n{}", tool_topic(tool)),
1356 None => CAPTIONS.to_owned(),
1357 }
1358}
1359
1360fn unknown_topic(tools: &[Tool], name: &str) -> String {
1361 let ops = edit_ops(tools);
1362 let names: Vec<&str> = tools.iter().map(|t| t.name).collect();
1363 format!(
1364 "unknown help topic `{name}`. Topics: {}. Edit ops: {}. Tools: {}.",
1365 TOPICS.join(", "),
1366 ops.join(", "),
1367 names.join(", ")
1368 )
1369}
1370
1371fn wrap(words: &[String], width: usize) -> Vec<String> {
1372 let mut lines = Vec::new();
1373 let mut cur = String::new();
1374 for w in words {
1375 if !cur.is_empty() && cur.len() + 2 + w.len() > width {
1376 lines.push(std::mem::take(&mut cur));
1377 }
1378 if !cur.is_empty() {
1379 cur.push_str(", ");
1380 }
1381 cur.push_str(w);
1382 }
1383 if !cur.is_empty() {
1384 lines.push(cur);
1385 }
1386 lines
1387}
1388
1389#[cfg(test)]
1390mod tests {
1391 use super::*;
1392
1393 #[test]
1394 fn the_ops_example_batch_uses_real_op_names_and_arguments() {
1395 let tools = catalogue();
1396 let text = section(&tools, Some("ops")).expect("ops topic");
1397 assert!(text.contains(OPS_EXAMPLE), "{text}");
1398 let json_text = &OPS_EXAMPLE[OPS_EXAMPLE.find("{\"ops\"").expect("the example has an ops list")..];
1399 let batch: Value = serde_json::from_str(json_text).expect("the example is valid JSON");
1400 let manual = edit_manual(&tools);
1401 let ops = edit_ops(&tools);
1402 for op in batch["ops"].as_array().expect("an ops array") {
1403 let name = op["op"].as_str().expect("each op is a flat object with an \"op\" name");
1404 assert!(ops.iter().any(|o| o == name), "`{name}` is not an edit op");
1405 // The manual line is `name {arg, arg?, …} — …`: every key of the example must be one of its arguments.
1406 let line = manual
1407 .lines()
1408 .map(str::trim_start)
1409 .find(|l| l.starts_with(&format!("{name} {{")))
1410 .unwrap_or_else(|| panic!("no manual line for `{name}`"));
1411 let args = line[name.len() + 2..].split('}').next().unwrap_or("");
1412 let known: Vec<&str> = args.split(',').map(|a| a.trim().trim_end_matches('?').split('=').next().unwrap_or("").trim()).collect();
1413 for key in op.as_object().expect("an object").keys().filter(|k| k.as_str() != "op") {
1414 assert!(known.contains(&key.as_str()), "`{name}` has no argument `{key}`: {line}");
1415 }
1416 }
1417 }
1418
1419 #[test]
1420 fn a_tool_summary_stops_at_a_sentence_not_at_a_numbered_cue() {
1421 let captions = "List the cues on caption lanes (S1..) in timeline time, one line per cue: \"<n>. track T cue C text\". Use the track and cue numbers with the cue_text op. Only cues that a placed caption shows.";
1422 assert_eq!(
1423 first_sentence(captions),
1424 "List the cues on caption lanes (S1..) in timeline time, one line per cue: \"<n>. track T cue C text\"."
1425 );
1426 assert_eq!(first_sentence("One sentence only."), "One sentence only.");
1427 }
1428
1429 #[test]
1430 fn sheet_names_every_tool_and_groups_them_all() {
1431 let tools = catalogue();
1432 let text = sheet(&tools);
1433 for t in &tools {
1434 assert!(text.contains(t.name), "sheet does not name `{}`", t.name);
1435 }
1436 assert!(!text.contains(" other:"), "a registered tool is missing from GROUPS");
1437 }
1438
1439 #[test]
1440 fn sheet_covers_addresses_and_undo() {
1441 let text = sheet(&catalogue());
1442 assert!(text.contains("V1@"));
1443 assert!(text.contains("keep"));
1444 assert!(text.contains("undo"));
1445 }
1446
1447 #[test]
1448 fn overview_points_at_the_ops_and_op_topics_without_their_arguments() {
1449 let text = sheet(&catalogue());
1450 assert!(text.contains("help {topic:\"ops\"}"));
1451 assert!(text.contains("help {topic:\"<op>\"}"));
1452 assert!(!text.contains("rate 0.25..4"), "the overview should not carry op entries");
1453 }
1454
1455 #[test]
1456 fn ops_come_from_the_edit_schema() {
1457 let ops = edit_ops(&catalogue());
1458 assert!(ops.iter().any(|o| o == "keep"));
1459 assert!(ops.iter().any(|o| o == "cut_regions"));
1460 let text = section(&catalogue(), Some("ops")).expect("ops topic");
1461 for op in &ops {
1462 assert!(text.contains(op.as_str()), "ops topic lacks `{op}`");
1463 }
1464 }
1465
1466 #[test]
1467 fn ops_topic_gives_one_signature_per_line_under_headings() {
1468 let text = section(&catalogue(), Some("ops")).expect("ops topic");
1469 assert!(text.lines().any(|l| l.starts_with(" speed {clip, x, ripple?") && l.ends_with("[group]")), "speed takes x:\n{text}");
1470 assert!(!text.contains("factor"));
1471 assert!(text.lines().any(|l| l == " lane_remove {lane}"), "lane_remove has its own line");
1472 assert!(text.lines().any(|l| l == "TIME"), "headings group the ops");
1473 assert!(text.lines().any(|l| l.starts_with(" captions_place")), "an op without its own entry is still listed");
1474 assert!(!text.lines().any(|l| l == "OTHER"), "named ops file under their heading");
1475 assert!(text.lines().any(|l| l == " trim {clip, edge:in|out, to, scope?} [group]"));
1476 assert!(text.lines().any(|l| l == " subtitles_lang {track, lang}"), "subtitles_lang is listed under CAPTIONS");
1477 }
1478
1479 #[test]
1480 fn one_op_gives_its_manual_entry() {
1481 let text = section(&catalogue(), Some("speed")).expect("speed topic");
1482 assert!(text.contains("speed {clip, x, ripple?") && text.contains("— rate 0.25..4"), "{text}");
1483 assert!(text.contains("TIME"));
1484 }
1485
1486 #[test]
1487 fn new_topics_answer_and_the_limiter_and_eq_entries_are_whole() {
1488 let tools = catalogue();
1489 for topic in ["lanes", "ripple", "export", "subtitles", "captions", "project", "burn_captions", "visualizer"] {
1490 let text = section(&tools, Some(topic)).unwrap_or_else(|e| panic!("{topic}: {e}"));
1491 assert!(text.lines().count() > 2, "{topic} is a real section:\n{text}");
1492 }
1493 let captions = section(&tools, Some("captions")).unwrap();
1494 assert!(captions.contains("tool `captions`"), "the captions topic also gives the tool's arguments");
1495 assert!(captions.contains("burn_captions") && captions.contains("auto_captions"), "{captions}");
1496 let subtitles = section(&tools, Some("subtitles")).unwrap();
1497 assert!(!subtitles.contains("auto_captions") && !subtitles.contains("export_start"), "{subtitles}");
1498 assert_ne!(captions.lines().nth(2), subtitles.lines().nth(2), "captions does not repeat subtitles");
1499 let limiter = section(&tools, Some("limiter")).unwrap();
1500 assert!(limiter.contains("ceiling_db -24 to 0 dB"), "{limiter}");
1501 assert!(!limiter.ends_with("— ceiling"), "{limiter}");
1502 let eq = section(&tools, Some("eq")).unwrap();
1503 assert!(eq.contains("low_cut") && eq.contains("f 20-20000 Hz"), "{eq}");
1504 let err = section(&tools, Some("nonsense")).unwrap_err();
1505 assert!(err.contains("lanes") && err.contains("visualizer"), "{err}");
1506 }
1507
1508 #[test]
1509 fn two_ops_on_one_line_get_their_own_entries() {
1510 let remove = section(&catalogue(), Some("title_remove")).expect("title_remove topic");
1511 assert!(remove.contains("title_remove {title} — takes it off."), "{remove}");
1512 assert!(!remove.contains("merged onto the title"), "title_set text leaked: {remove}");
1513 let title_set = section(&catalogue(), Some("title_set")).expect("title_set topic");
1514 assert!(!title_set.contains("takes it off"), "title_remove text leaked: {title_set}");
1515 }
1516
1517 #[test]
1518 fn tool_name_gives_its_description_and_arguments() {
1519 let text = section(&catalogue(), Some("edit")).expect("edit topic");
1520 assert!(text.starts_with("tool `edit`"));
1521 assert!(text.contains("Batched edit"));
1522 assert!(text.contains("ARGUMENTS"));
1523 assert!(text.contains(" ops"), "the ops argument is listed:\n{text}");
1524 }
1525
1526 /// A name longer than the old fixed column keeps a gap before its type, and a type given as a
1527 /// list (`boolean` or `string`) is shown as `boolean|string`.
1528 #[test]
1529 fn long_argument_names_keep_a_gap_and_list_types_are_shown() {
1530 let text = section(&catalogue(), Some("project_open")).expect("project_open topic");
1531 assert!(text.contains(" discard_autosave boolean"), "{text}");
1532 assert!(text.contains(" recover boolean|string"), "{text}");
1533 assert!(!text.contains("discard_autosaveboolean"), "{text}");
1534 }
1535
1536 #[test]
1537 fn unknown_topic_lists_the_valid_ones() {
1538 let err = section(&catalogue(), Some("nope")).unwrap_err();
1539 assert!(err.contains("ops, times, recipes"));
1540 assert!(err.contains("speed"));
1541 assert!(err.contains("help"));
1542 }
1543
1544 #[test]
1545 fn recipes_mention_silence_on_a_source_and_a_black_lead_in() {
1546 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
1547 assert!(text.contains("src:2"));
1548 assert!(text.contains("Black lead-in"));
1549 }
1550
1551 #[test]
1552 fn recipes_say_assemble_refuses_stills_and_how_to_add_one() {
1553 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
1554 assert!(text.contains("assemble refuses a still image"), "{text}");
1555 assert!(text.contains("{op:\"place\", source, at:\"end\"}"), "{text}");
1556 assert!(text.contains("{op:\"append\", source}"), "{text}");
1557 assert!(text.contains("items:[{source, in?, out?}]"), "{text}");
1558 }
1559
1560 #[test]
1561 fn short_is_the_first_25_lines_plus_a_pointer() {
1562 let text = short(&catalogue());
1563 assert!(text.contains("V1@"));
1564 assert!(text.lines().count() <= 26);
1565 assert!(text.contains("edith://help"));
1566 }
1567
1568 #[test]
1569 fn ops_topic_has_no_empty_one_of_and_no_repeated_heading() {
1570 let text = section(&catalogue(), Some("ops")).expect("ops topic");
1571 assert!(!text.contains("one of:\n") && !text.trim_end().ends_with("one of:"), "{text}");
1572 assert_eq!(text.lines().filter(|l| *l == "CAPTIONS").count(), 1, "CAPTIONS heading repeats:\n{text}");
1573 assert!(!text.contains("(named in another entry)"), "{text}");
1574 for heading in ["PLACE", "CUT", "TIME", "LOOK", "SOUND", "LANES", "CAPTIONS", "TITLES"] {
1575 assert_eq!(text.lines().filter(|l| *l == heading).count(), 1, "{heading} once:\n{text}");
1576 }
1577 }
1578
1579 #[test]
1580 fn captions_place_lists_its_full_arguments_in_ops_and_its_topic() {
1581 let text = section(&catalogue(), Some("captions_place")).expect("captions_place topic");
1582 assert!(text.contains("edit op `captions_place` (under CAPTIONS):\n captions_place {track, lane?, at?}"), "{text}");
1583 assert!(!text.contains("as the edit manual mentions it"), "{text}");
1584 let ops = section(&catalogue(), Some("ops")).expect("ops topic");
1585 assert!(ops.lines().any(|l| l == " captions_place {track, lane?, at?}"), "{ops}");
1586 assert!(!ops.lines().any(|l| l == " captions_place {track}"), "{ops}");
1587 }
1588
1589 /// The facts the topics state about current behaviour: captions addresses and time edits,
1590 /// the assemble lane default, transform keys across trims, surround and sound-only sources,
1591 /// the export peak warning and the earlier-session status, and the autosave options.
1592 #[test]
1593 fn current_behaviour_is_named_in_its_topic() {
1594 let tools = catalogue();
1595 let text = |t: &str| section(&tools, Some(t)).unwrap_or_else(|e| panic!("{t}: {e}"));
1596 let captions = text("captions");
1597 assert!(captions.contains("track T cue C [S1@F]"), "{captions}");
1598 assert!(captions.contains("nearest the cut"), "{captions}");
1599 assert!(captions.contains("no speech to caption"), "{captions}");
1600 let assemble = section(&tools, Some("assemble")).expect("assemble topic");
1601 assert!(assemble.contains("With no lane the picture goes to V1 and its sound to A1"), "{assemble}");
1602 assert!(assemble.contains("0 when that lane is empty"), "{assemble}");
1603 let keys = section(&tools, Some("transform_keys")).expect("transform_keys topic");
1604 assert!(keys.contains("adds a key at the new edge"), "{keys}");
1605 assert!(keys.contains("split and move carry the keys"), "{keys}");
1606 let lanes = text("lanes");
1607 assert!(lanes.contains("mixed to stereo on export"), "{lanes}");
1608 assert!(lanes.contains("placed with no lane, it goes to A1 alone"), "{lanes}");
1609 let export = text("export");
1610 assert!(export.contains("project_settings {limiter:{on:true, ceiling_db:-1}}"), "{export}");
1611 assert!(export.contains("the progress\n of a job from an earlier session is not known"), "{export}");
1612 let project = text("project");
1613 assert!(project.contains("discard_autosave:true: this session's edits are saved"), "{project}");
1614 assert!(project.contains("recover:true opens the saved file with the autosave's edits on top as one undo step, so undo takes them back\n (with this session's own unsaved edits open it needs discard:true"), "{project}");
1615 assert!(project.contains("~/.cache/edith/frames/<project>/"), "{project}");
1616 // The cut, the captions, the export wait, freeze and burn, and the times: each states what the code does.
1617 let cut = text("recipes");
1618 assert!(cut.contains("keep:N is the total pause left in each silence, padding included"), "{cut}");
1619 assert!(cut.contains("makes a joint cut with no target"), "{cut}");
1620 assert!(cut.contains("reported as out of step"), "{cut}");
1621 assert!(cut.contains("keeps `keep` in all after the last speech"), "{cut}");
1622 assert!(captions.contains("keeps its word on the longer piece only (ties: the earlier one)"), "{captions}");
1623 assert!(captions.contains("numbers come out as digits"), "{captions}");
1624 assert!(export.contains("A stop signal (SIGTERM or SIGINT) cancels them"), "{export}");
1625 assert!(export.contains("m4a (audio only; m4a is AAC in an mp4 box)"), "{export}");
1626 assert!(export.contains("is the sound alone (AAC, no picture track)"), "{export}");
1627 assert!(export.contains("Pictures are 8-bit 4:2:0 except in a 10-bit AV1 or HEVC export"), "{export}");
1628 assert!(export.contains("chapters (default true)") && export.contains("chapters:false leaves them out"), "{export}");
1629 assert!(export.contains("H.264 and every other format refuse it"), "{export}");
1630 assert!(export.contains("Poll export_status until it finishes"), "{export}");
1631 let burn = text("burn_captions");
1632 assert!(burn.contains("false for none"), "{burn}");
1633 assert!(burn.contains("at 1080x1920"), "{burn}");
1634 assert!(burn.contains("Lines keep the cue's own line breaks"), "{burn}");
1635 assert!(text("times").contains("2.5 s at 25 fps is frame 63"), "{}", text("times"));
1636 assert!(text("freeze").contains("insert:false overlays the still without pushing"), "{}", text("freeze"));
1637 }
1638
1639 #[test]
1640 fn mention_does_not_match_the_tail_of_a_longer_op() {
1641 let manual = "CUT\nsub_move {clip, at, to_lane?} [group]\nmove {clip, at, to_lane?} [group]";
1642 let m = mention(manual, "move").expect("move is named");
1643 assert_eq!(m.sig, "move {clip, at, to_lane?}");
1644 assert_eq!(m.heading, "CUT");
1645 assert!(mention("CUT\nsub_move {clip} [group]", "move").is_none());
1646 }
1647
1648 #[test]
1649 fn enum_options_show_numbers_and_skip_an_empty_list() {
1650 let text = section(&catalogue(), Some("export_start")).expect("export_start topic");
1651 assert!(text.contains("one of: 128, 192, 256, 320"), "audio_kbps lists its values:\n{text}");
1652 assert!(!text.contains("one of: \n") && !text.trim_end().ends_with("one of:"), "{text}");
1653 fn empty_enum() -> Value {
1654 json!({"properties": {"x": {"type": "integer", "enum": []}}})
1655 }
1656 let tool = Tool { name: "fake", description: "d", schema: empty_enum, run: run_help };
1657 let shown = tool_topic(&tool);
1658 assert!(!shown.contains("one of"), "an empty enum shows no list: {shown}");
1659 }
1660
1661 #[test]
1662 fn overview_says_tools_take_their_own_arguments_and_burn_captions_shape() {
1663 let text = sheet(&catalogue());
1664 assert!(text.contains("help {topic:\"<tool>\"} lists any tool's arguments"));
1665 assert!(text.contains("media_probe takes paths, a glob, or both"));
1666 assert!(text.contains("burn_captions {track:N}"));
1667 assert!(text.contains("N is 0-based"));
1668 }
1669
1670 #[test]
1671 fn unknown_tool_hints_an_edit_op_and_suggests_near_names() {
1672 let tools = catalogue();
1673 assert_eq!(
1674 unknown_tool(&tools, "lane_add"),
1675 "lane_add is an edit op: edit {ops:[{op:\"lane_add\", …}]} — help {topic:\"lane_add\"}"
1676 );
1677 let near = unknown_tool(&tools, "project_sav");
1678 assert!(near.contains("did you mean") && near.contains("project_save"), "{near}");
1679 let far = unknown_tool(&tools, "zzzzzzzzzz");
1680 assert!(far.starts_with("unknown tool `zzzzzzzzzz`") && !far.contains("did you mean"), "{far}");
1681 }
1682
1683 /// The body of a section: its text without the first line (the op heading or the topic title).
1684 fn body(text: &str) -> &str {
1685 text.split_once('\n').map_or("", |(_, rest)| rest).trim()
1686 }
1687
1688 #[test]
1689 fn every_op_entry_ends_at_a_sentence_end() {
1690 let tools = catalogue();
1691 for op in edit_ops(&tools) {
1692 let text = section(&tools, Some(&op)).expect("op topic");
1693 let last = body(&text).trim_end_matches(" [group]").trim_end_matches(" [clip]");
1694 assert!(
1695 last.ends_with(['.', ')', '}', '"', '`']),
1696 "`{op}` ends mid-sentence: {last:?}"
1697 );
1698 }
1699 }
1700
1701 #[test]
1702 fn every_topic_ends_at_a_sentence_end_or_a_list_line() {
1703 let tools = catalogue();
1704 for topic in ["times", "recipes", "lanes", "ripple", "export", "subtitles", "project", "burn_captions", "visualizer", "values"] {
1705 let Ok(text) = section(&tools, Some(topic)) else { continue };
1706 let last = text.lines().last().unwrap_or("").trim_end();
1707 assert!(
1708 last.ends_with(['.', ')', '}', '"', '`']) || last.contains(" "),
1709 "`{topic}` ends mid-sentence: {last:?}"
1710 );
1711 }
1712 }
1713
1714 #[test]
1715 fn no_sentence_is_copied_into_two_op_entries() {
1716 let tools = catalogue();
1717 let mut seen: Vec<(String, String)> = Vec::new();
1718 for op in edit_ops(&tools) {
1719 let text = section(&tools, Some(&op)).expect("op topic");
1720 for sentence in body(&text).split(". ").map(str::trim).filter(|s| s.len() >= 40) {
1721 if let Some((other, _)) = seen.iter().find(|(_, s)| s == sentence) {
1722 panic!("`{op}` repeats a sentence from `{other}`: {sentence}");
1723 }
1724 seen.push((op.clone(), sentence.to_owned()));
1725 }
1726 }
1727 }
1728
1729 /// delete ripples, ripple_delete is the same cut with more reported, and lift is the one that leaves a gap.
1730 #[test]
1731 fn delete_ripples_and_lift_leaves_a_gap() {
1732 let tools = catalogue();
1733 let delete = section(&tools, Some("delete")).expect("delete topic");
1734 assert!(delete.contains("RIPPLE") && delete.contains("close the gap"), "{delete}");
1735 assert!(delete.contains("same cut as ripple_delete"), "{delete}");
1736 let lift = section(&tools, Some("lift")).expect("lift topic");
1737 assert!(lift.contains("LEAVE A GAP") && lift.contains("nothing moves"), "{lift}");
1738 assert!(!lift.contains("RIPPLE"), "{lift}");
1739 let ripple = section(&tools, Some("ripple")).expect("ripple topic");
1740 assert!(ripple.contains("lift is not a ripple"), "{ripple}");
1741 }
1742
1743 #[test]
1744 fn ops_header_defines_the_group_and_clip_tags() {
1745 let text = section(&catalogue(), Some("ops")).expect("ops topic");
1746 assert!(text.contains("[group] = ") && text.contains("[clip] = "), "{text}");
1747 let lift = section(&catalogue(), Some("lift")).expect("lift topic");
1748 assert!(lift.contains("[clip]"), "lift is tagged [clip]: {lift}");
1749 }
1750
1751 #[test]
1752 fn captions_and_subtitles_show_their_ops_as_edit_calls() {
1753 let tools = catalogue();
1754 for topic in ["subtitles", "captions"] {
1755 let text = section(&tools, Some(topic)).expect("topic");
1756 assert!(!text.contains("cue_text {track") && !text.contains("subtitles_import {path}"), "{topic} writes ops as tool calls:\n{text}");
1757 }
1758 let subtitles = section(&tools, Some("subtitles")).expect("subtitles topic");
1759 for op in ["subtitles_import", "captions_place", "cue_text", "cue_delete", "cue_replace"] {
1760 assert!(subtitles.contains(&format!("edit {{ops:[{{op:\"{op}\"")), "subtitles does not show `{op}` as an edit call:\n{subtitles}");
1761 }
1762 }
1763
1764 #[test]
1765 fn locked_lanes_are_described_as_the_rule_has_it() {
1766 let text = section(&catalogue(), Some("lanes")).expect("lanes topic");
1767 assert!(!text.contains("refuses every edit"), "{text}");
1768 assert!(text.contains("never changed") && text.contains("skip it with a note"), "{text}");
1769 }
1770
1771 #[test]
1772 fn cut_silence_lanes_say_what_the_scope_and_the_locks_do() {
1773 let recipe = RECIPES;
1774 assert!(recipe.contains("with a target, it is the ripple scope, judged on the target alone"), "{recipe}");
1775 assert!(recipe.contains("the target's lane is added if missing"), "{recipe}");
1776 assert!(recipe.contains("Without a target, two or more audio lanes are cut jointly where all are quiet"), "{recipe}");
1777 assert!(recipe.contains("a locked lane named in lanes, or linked to the target, refuses the cut (unlock it with lane_flags)"), "{recipe}");
1778 assert!(recipe.contains("a mix's default scope (every lane) refuses the same way, naming each locked lane, and changes nothing"), "{recipe}");
1779 }
1780
1781 #[test]
1782 fn find_words_cut_says_what_the_locks_do() {
1783 let recipe = RECIPES;
1784 assert!(recipe.contains("A locked lane the cut would move refuses it, dry runs too (unlock it with lane_flags)"), "{recipe}");
1785 assert!(recipe.contains("a mix's default scope skips its locked lanes with a note"), "{recipe}");
1786 }
1787
1788 #[test]
1789 fn the_true_peak_warning_names_the_ceiling_it_checks() {
1790 assert!(EXPORT.contains("-1 dBTP for lossless") && EXPORT.contains("-2 dBTP for lossy"), "export help names both ceilings");
1791 assert!(EXPORT.contains("above -1 dBTP warns") && !EXPORT.contains("over 0 dBTP warns"), "export help states the warning ceiling");
1792 assert!(EXPORT.contains("intra_only: hevc and hevc-mp4: true codes every picture as an IDR"), "export help names intra_only");
1793 assert!(EXPORT.contains("burn_captions is refused for it"), "export help says burn_captions is refused sound-only");
1794 }
1795
1796 #[test]
1797 fn gain_and_ripple_delete_are_whole_entries() {
1798 let tools = catalogue();
1799 let gain = section(&tools, Some("gain")).expect("gain topic");
1800 assert!(gain.contains("Audio clips only") && gain.ends_with('.'), "{gain}");
1801 let ripple_delete = section(&tools, Some("ripple_delete")).expect("ripple_delete topic");
1802 assert!(!ripple_delete.contains("RIPPLE RULE above"), "{ripple_delete}");
1803 assert!(ripple_delete.contains("help {topic:\"ripple\"}"), "{ripple_delete}");
1804 }
1805
1806 #[test]
1807 fn move_says_a_drop_on_empty_frames_may_jump_over_clips() {
1808 let text = section(&catalogue(), Some("move")).expect("move topic");
1809 assert!(text.contains("jumping over any clips between"), "{text}");
1810 }
1811
1812 #[test]
1813 fn move_insert_says_it_refuses_a_ripple_over_a_clip_outside_the_take() {
1814 let text = section(&catalogue(), Some("move")).expect("move topic");
1815 assert!(text.contains("insert:true refuses and names it: move without insert, or lift that clip and close_gaps"), "{text}");
1816 }
1817
1818 #[test]
1819 fn help_tool_answers_a_topic() {
1820 let mut server = Server::new();
1821 let reply = (tool().run)(&mut server, &json!({"topic": "ops"}));
1822 assert!(!reply.is_error);
1823 assert!(reply.text.contains("keep"));
1824 let op = (tool().run)(&mut server, &json!({"topic": "keep"}));
1825 assert!(!op.is_error);
1826 let bad = (tool().run)(&mut server, &json!({"topic": "nope"}));
1827 assert!(bad.is_error);
1828 }
1829}
1830
1831#[cfg(test)]
1832mod topic_tests {
1833 use super::*;
1834
1835 /// The top-level topic list names every topic the help answers, the new ones included.
1836 #[test]
1837 fn the_header_lists_every_topic() {
1838 for t in TOPICS {
1839 assert!(header().contains(t), "header misses topic {t}");
1840 }
1841 }
1842
1843 /// The topic names after `Topics: ` in a sentence, in the order given.
1844 fn listed_topics(text: &str) -> Vec<String> {
1845 let after = text.split_once("Topics: ").expect("a Topics: list").1;
1846 after.split('.').next().unwrap_or("").split(", ").map(str::to_owned).collect()
1847 }
1848
1849 /// The cheat sheet's topic list and the `help` schema's both name exactly the topics that
1850 /// `section` answers, in `TOPICS` order, and every one of them answers.
1851 #[test]
1852 fn schema_and_sheet_list_the_same_topics_as_section_answers() {
1853 let tools = catalogue();
1854 let expected: Vec<String> = TOPICS.iter().map(|t| (*t).to_owned()).collect();
1855 assert_eq!(listed_topics(&header()), expected, "the cheat sheet's topic list");
1856 assert_eq!(listed_topics(&topic_description()), expected, "the schema's topic list");
1857 assert_eq!(listed_topics(&sheet(&tools)), expected, "the sheet's own topic list");
1858 let schema = help_schema();
1859 let described = schema["properties"]["topic"]["description"].as_str().expect("topic description");
1860 assert!(described.contains("\"ops\""), "{described}");
1861 for t in TOPICS {
1862 assert!(section(&tools, Some(t)).is_ok(), "topic `{t}` is listed but does not answer");
1863 }
1864 for name in ["overlays", "vertical", "stretch", "unsupported"] {
1865 assert!(expected.iter().any(|t| t == name), "{name} is missing from TOPICS");
1866 }
1867 }
1868
1869 /// `transform` documents `opacity` in its signature, as its help entry does.
1870 #[test]
1871 fn transform_signature_lists_opacity() {
1872 let ops = section(&catalogue(), Some("ops")).expect("ops topic");
1873 assert!(ops.lines().any(|l| l == " transform {clip, x?, y?, scale?, rotate?, crop?:[l,r,t,b], opacity?, reset?}"), "{ops}");
1874 }
1875
1876 /// The first_video recipe names the same lanes and sources at every step: the music is src:1
1877 /// (its second import), the narration is A3, and the captions read A3, not the picture's sound.
1878 #[test]
1879 fn first_video_recipe_is_self_consistent() {
1880 let text = section(&catalogue(), Some("first_video")).expect("first_video topic");
1881 assert!(text.contains(r#"{op:"append", source:"src:1", lane:"A2", until:"30s"}"#), "{text}");
1882 assert!(text.contains(r#"auto_captions {target:"A3"}"#), "{text}");
1883 assert!(!text.contains(r#"auto_captions {target:"A1"}"#), "{text}");
1884 assert!(text.contains(r#"voiceover {text:"...", pause:0.4, place:{lane:"A3", at:"0s"}}"#), "{text}");
1885 // Step 3 adds both sound lanes: one lane_add op per lane, so A2 (music) and then A3 (narration).
1886 assert!(text.contains(r#"{op:"lane_add", kind:"audio"}, {op:"lane_add", kind:"audio"}]} adds A2, then A3"#), "{text}");
1887 }
1888
1889 /// The speed recipe leaves the music bed's lane out of its lanes, since a bed under the whole
1890 /// picture spans the change and a listed lane refuses such a clip.
1891 #[test]
1892 fn speed_recipe_leaves_the_music_bed_out_of_lanes() {
1893 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
1894 assert!(text.contains(r#"lanes:["V1","A1","A3"]"#), "{text}");
1895 assert!(!text.contains(r#"lanes:["V1","A1","A2"]"#), "{text}");
1896 assert!(text.contains("spans the change"), "{text}");
1897 }
1898
1899 /// The dip recipe says its span must sit inside one clip, and that a short file loops into several.
1900 #[test]
1901 fn gain_dip_recipe_names_the_one_clip_span() {
1902 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
1903 assert!(text.contains("The span must lie inside that one clip"), "{text}");
1904 assert!(text.contains("a dip cannot cross them"), "{text}");
1905 }
1906
1907 /// Dated autosave copies are capped, not kept forever: the project topic says which are kept.
1908 #[test]
1909 fn project_topic_says_which_dated_copies_are_kept() {
1910 let text = section(&catalogue(), Some("project")).expect("project topic");
1911 assert!(!text.contains("never deleted"), "{text}");
1912 assert!(!text.contains("kept, not deleted"), "{text}");
1913 assert!(!text.contains("only the newest three dated copies"), "{text}");
1914 assert!(text.contains("the newest three dated copies and any from the last 7 days are kept"), "{text}");
1915 assert!(text.contains("setting one aside deletes the older ones"), "{text}");
1916 }
1917
1918 /// project_save takes no overwrite key: project_new's overwrite is what lets its save replace a file.
1919 #[test]
1920 fn project_topic_names_what_lets_a_save_replace_a_file() {
1921 let text = section(&catalogue(), Some("project")).expect("project topic");
1922 assert!(text.contains("overwrite:true lets the later project_save replace a file already at path"), "{text}");
1923 assert!(text.contains("project_save takes no overwrite key"), "{text}");
1924 assert!(text.contains("force also replaces a file at path"), "{text}");
1925 }
1926
1927 #[test]
1928 fn swap_documents_ripple_and_the_take_refusal() {
1929 let tools = catalogue();
1930 let text = section(&tools, Some("swap")).expect("swap topic");
1931 assert!(text.contains("ripple:true (the default)"), "{text}");
1932 assert!(text.contains("ripple:false"), "{text}");
1933 assert!(text.contains("is refused"), "{text}");
1934 assert!(text.contains("ungrouped first"), "{text}");
1935 // swap refuses a take rather than moving it, so it is tagged [clip], not [group].
1936 assert!(text.starts_with("edit op `swap`") && text.contains("swap {a, b, ripple?=true} [clip]"), "{text}");
1937 let ops = section(&tools, Some("ops")).expect("ops topic");
1938 assert!(ops.lines().any(|l| l == " swap {a, b, ripple?=true} [clip]"), "{ops}");
1939 }
1940
1941 #[test]
1942 fn overlay_corner_values_are_the_verified_ones() {
1943 let text = section(&catalogue(), Some("overlays")).expect("overlays topic");
1944 assert!(text.contains("corner:\"bottom-right\", scale:0.3"), "{text}");
1945 assert!(!text.contains("x:0.6, y:-0.6"), "{text}");
1946 }
1947
1948 /// The corner form is one step, and the overlays topic still says x and y work.
1949 #[test]
1950 fn overlays_give_the_corner_form_and_keep_x_and_y() {
1951 let text = section(&catalogue(), Some("overlays")).expect("overlays topic");
1952 assert!(text.contains("corner:\"top-right\"") || text.contains("corner is centre, top-left"), "{text}");
1953 assert!(text.contains("Giving x or y with corner is refused"), "{text}");
1954 assert!(text.contains("x and y still work"), "{text}");
1955 assert!(!text.contains("half-height = half-width"), "the hand-math recipe is gone:\n{text}");
1956 }
1957
1958 /// The recipes and the topics that carry them write edit ops as `edit {ops:[{op:…}]}`, never as bare calls.
1959 #[test]
1960 fn recipe_topics_write_edit_ops_as_edit_calls() {
1961 const OPS: [&str; 16] = [
1962 "place", "append", "trim", "speed", "duck", "insert_time", "title_add", "title_set", "title_remove",
1963 "copy_look", "assemble", "transform", "fit", "lane_add", "keep", "gain_dip",
1964 ];
1965 let tools = catalogue();
1966 for topic in ["first_video", "podcast", "recipes", "overlays", "vertical", "stretch"] {
1967 let text = section(&tools, Some(topic)).unwrap_or_else(|e| panic!("{topic}: {e}"));
1968 for op in OPS {
1969 assert!(!text.contains(&format!("{op} {{")), "{topic} writes `{op}` as a bare call:\n{text}");
1970 }
1971 }
1972 }
1973
1974 /// Each example that needs earlier steps or clips says so beside it.
1975 #[test]
1976 fn examples_state_their_prerequisites() {
1977 let tools = catalogue();
1978 let recipes = section(&tools, Some("recipes")).unwrap();
1979 assert!(recipes.contains("both must already exist"), "{recipes}");
1980 assert!(recipes.contains("Prerequisite: A2@0 is the music clip and runs to at least 25 s."), "{recipes}");
1981 assert!(recipes.contains("prerequisite: A3 exists and holds the narration clip"), "{recipes}");
1982 let stretch = section(&tools, Some("stretch")).unwrap();
1983 assert!(stretch.contains("a 5 s shot fits slots from 1.25 s to 20 s"), "{stretch}");
1984 let overlays = section(&tools, Some("overlays")).unwrap();
1985 assert!(overlays.contains("V2@30 is the still placed at 1s"), "{overlays}");
1986 }
1987
1988 /// Non-Latin scripts draw as boxes in titles and burned captions, so the topics that place them point at soft subtitles.
1989 #[test]
1990 fn title_and_caption_topics_point_non_latin_text_at_soft_subtitles() {
1991 let tools = catalogue();
1992 for topic in ["vertical", "burn_captions"] {
1993 let text = section(&tools, Some(topic)).unwrap_or_else(|e| panic!("{topic}: {e}"));
1994 assert!(text.contains("CJK") && text.contains("empty boxes") && text.contains("soft subtitles"), "{topic}:\n{text}");
1995 }
1996 let titles = section(&tools, Some("recipes")).unwrap();
1997 assert!(titles.contains("T2 becomes T1"), "{titles}");
1998 }
1999
2000 #[test]
2001 fn lane_move_says_to_is_a_position_and_names_renumber() {
2002 let lanes = section(&catalogue(), Some("lanes")).expect("lanes topic");
2003 assert!(lanes.contains("to is the 1-based position"), "{lanes}");
2004 assert!(lanes.contains("renumbers the lanes between its two places"), "{lanes}");
2005 assert!(lanes.contains("lane_move {lane:\"V2\", to:1}"), "{lanes}");
2006 }
2007
2008 #[test]
2009 fn vertical_checks_the_file_with_media_probe() {
2010 let text = section(&catalogue(), Some("vertical")).expect("vertical topic");
2011 assert!(text.contains("Check the file with media_probe."), "{text}");
2012 assert!(!text.contains("with probe"), "{text}");
2013 }
2014
2015 #[test]
2016 fn unsupported_names_cjk_and_the_open_gaps() {
2017 let text = section(&catalogue(), Some("unsupported")).expect("unsupported topic");
2018 assert!(text.contains("CJK text in the picture") && text.contains("Noto Sans CJK"), "{text}");
2019 assert!(text.contains("empty boxes in a title or in burned captions"), "{text}");
2020 assert!(text.contains("Soft subtitle tracks") && text.contains("mp4 or mkv"), "{text}");
2021 // Scripts the bundled faces draw are no longer listed as unsupported.
2022 assert!(!text.contains("Cyrillic"), "{text}");
2023 assert!(!text.contains("Speed ramps"), "speed ramps are supported now: {text}");
2024 assert!(!text.contains("Keyframes on colour"), "colour keys are supported now: {text}");
2025 let tools = catalogue();
2026 assert!(section(&tools, Some("color_keys")).expect("color_keys topic").contains("ease"));
2027 assert!(section(&tools, Some("opacity_keys")).expect("opacity_keys topic").contains("fades multiply"));
2028 for gap in ["10-bit: AV1 and HEVC only", "HEVC in 4:4:4", "AV1 in 4:4:0", "12-bit"] {
2029 assert!(text.contains(gap), "{gap} missing:\n{text}");
2030 }
2031 assert!(!text.contains("Chapter markers in the exported file"), "chapters are written now: {text}");
2032 }
2033
2034 #[test]
2035 fn normalize_puts_the_boost_past_plus_twelve_on_the_clips() {
2036 let text = section(&catalogue(), Some("podcast")).expect("podcast topic");
2037 assert!(text.contains("puts the rest on that lane's clips (each up to +24 dB"), "{text}");
2038 assert!(text.contains("capped_by: clip_gain_limit"), "{text}");
2039 assert!(!text.contains("capped_by: lane_gain_limit"), "{text}");
2040 }
2041
2042 #[test]
2043 fn find_words_cut_snaps_to_a_pause_and_names_the_switch() {
2044 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
2045 assert!(text.contains("snaps to a pause within 150 ms") && text.contains("snap:false"), "{text}");
2046 }
2047
2048 #[test]
2049 fn hint_corrections_are_named_in_the_help() {
2050 let text = section(&catalogue(), Some("captions")).expect("captions topic");
2051 assert!(text.contains("near-miss") && text.contains("hint corrected"), "{text}");
2052 }
2053
2054 #[test]
2055 fn visualizer_and_speed_and_export_say_what_the_code_does() {
2056 let vis = section(&catalogue(), Some("visualizer")).unwrap();
2057 assert!(vis.contains("new top picture lane") && vis.contains("covers the picture under it"), "{vis}");
2058 assert!(vis.contains("transform") && vis.contains("V2@0"), "{vis}");
2059 let speed = section(&catalogue(), Some("speed")).unwrap();
2060 assert!(speed.contains("absolute") && speed.contains("not a multiplier"), "{speed}");
2061 let export = section(&catalogue(), Some("export")).unwrap();
2062 assert!(export.contains("placed or not") && export.contains("written whole"), "{export}");
2063 assert!(export.contains("mp4, overlapping cues are merged") && export.contains("mkv keeps them"), "{export}");
2064 let subs = section(&catalogue(), Some("subtitles")).unwrap();
2065 assert!(subs.contains("edge:\"in\"|\"out\""), "{subs}");
2066 }
2067
2068 #[test]
2069 fn podcast_warns_about_the_peak_and_the_one_lane_ripple() {
2070 let podcast = section(&catalogue(), Some("podcast")).unwrap();
2071 assert!(podcast.contains("holds that lane to the true-peak ceiling"), "{podcast}");
2072 assert!(podcast.contains("structuredContent carries it as capped_by: true_peak"), "{podcast}");
2073 assert!(podcast.contains("cut:\"lift\"") && podcast.contains("falls out of step"), "{podcast}");
2074 assert!(podcast.contains("normalize {target:\"mix\", lufs:-16, allow_limiter:true, true_peak:-1}"), "{podcast}");
2075 assert!(podcast.contains("true_peak:-2 for m4a or mp3"), "{podcast}");
2076 assert!(podcast.contains("trim it to the new end with edit {ops:[{op:\"trim\", clip:\"A3@0\", edge:\"out\""), "{podcast}");
2077 assert!(podcast.contains("hint:\"Jane Doe, LUFS\"") && podcast.contains("recorded on its own track"), "{podcast}");
2078 }
2079
2080 #[test]
2081 fn move_names_split_captions() {
2082 let text = section(&catalogue(), Some("move")).expect("move topic");
2083 assert!(text.contains("split_captions?"), "{text}");
2084 assert!(text.contains("unless split_captions:true"), "{text}");
2085 }
2086
2087 #[test]
2088 fn find_words_has_no_fillers_flag_and_a_plain_filler_query_keeps_them() {
2089 let recipes = section(&catalogue(), Some("recipes")).expect("recipes topic");
2090 assert!(!recipes.contains("fillers:true"), "{recipes}");
2091 assert!(recipes.contains("find_words {query:\"um\"}"), "{recipes}");
2092 assert!(recipes.contains("with no flag"), "{recipes}");
2093 }
2094
2095 #[test]
2096 fn recipes_write_lane_and_append_as_edit_ops() {
2097 let recipes = section(&catalogue(), Some("recipes")).expect("recipes topic");
2098 assert!(!recipes.contains("lane_add {kind"), "{recipes}");
2099 assert!(recipes.contains("edit {ops:[{op:\"lane_add\", kind:\"audio\"}]}"), "{recipes}");
2100 assert!(recipes.contains("edit {ops:[{op:\"append\", source:\"src:1\", lane:\"A2\"}]}"), "{recipes}");
2101 }
2102
2103 #[test]
2104 fn cut_silence_states_its_default_min_silence() {
2105 let recipes = section(&catalogue(), Some("recipes")).expect("recipes topic");
2106 assert!(recipes.contains("min_silence (default 0.5 s, judged before padding)"), "{recipes}");
2107 assert!(recipes.contains("It cuts only pauses of min_silence or longer"), "{recipes}");
2108 assert!(recipes.contains("the reply names the longest quiet it found and cuts nothing"), "{recipes}");
2109 }
2110
2111 /// The copy_look example needs a source clip with a look; a plain clip replies "nothing to copy".
2112 #[test]
2113 fn copy_look_example_says_its_source_needs_a_look() {
2114 let recipes = section(&catalogue(), Some("recipes")).expect("recipes topic");
2115 assert!(recipes.contains("from must carry a look: a plain clip has none"), "{recipes}");
2116 assert!(recipes.contains("a colour grade from the color op, or a transform"), "{recipes}");
2117 }
2118
2119 #[test]
2120 fn podcast_adds_speaker_lanes_as_edit_ops_and_explains_the_joint_cut() {
2121 let text = section(&catalogue(), Some("podcast")).expect("podcast topic");
2122 assert!(text.contains("A2 does not exist yet, so add it first: edit {ops:[{op:\"lane_add\", kind:\"audio\"}]}"), "{text}");
2123 assert!(!text.contains("lane_add {kind"), "{text}");
2124 assert!(!text.contains("append {source"), "{text}");
2125 assert!(text.contains("edit {ops:[{op:\"append\", source:\"src:2\", lane:\"A3\""), "{text}");
2126 assert!(text.contains("a lane with no sound there (a gap between its clips, or no clip) counts as quiet"), "{text}");
2127 assert!(text.contains("the turns stay in step"), "{text}");
2128 assert!(text.contains("hint:\"Jane Doe, LUFS\""), "{text}");
2129 }
2130
2131 /// The speed recipe's example and its text agree: the default leaves narration in place, and
2132 /// naming its lane is the example that moves it.
2133 #[test]
2134 fn speed_recipe_example_and_text_agree_on_the_narration_lane() {
2135 let text = section(&catalogue(), Some("recipes")).expect("recipes topic");
2136 assert!(text.contains("edit {ops:[{op:\"speed\", clip:\"V1@0\", x:0.5, ripple:true}]} changes the picture's length and the narration keeps its times"), "{text}");
2137 assert!(text.contains("lanes:[\"V1\",\"A1\",\"A3\"]"), "{text}");
2138 assert!(text.contains("spans the change"), "{text}");
2139 assert!(text.contains("lanes:[\"V1\",\"A1\"]"), "{text}");
2140 }
2141
2142 #[test]
2143 fn vertical_says_how_the_fit_policies_frame_a_16_9_clip() {
2144 let text = section(&catalogue(), Some("vertical")).expect("vertical topic");
2145 assert!(text.contains("fit (the default)"), "{text}");
2146 assert!(text.contains("fill:"), "{text}");
2147 assert!(text.contains("bars"), "{text}");
2148 }
2149
2150 #[test]
2151 fn subtitles_say_skipped_cues_include_wrong_arrows_and_missing_timing() {
2152 let text = section(&catalogue(), Some("subtitles")).expect("subtitles topic");
2153 assert!(text.contains("a wrong arrow (`->`) or a cue with no timing line is skipped"), "{text}");
2154 }
2155
2156 /// subtitles_import takes an optional language, guessed from the file name when left out; unset is und.
2157 #[test]
2158 fn subtitles_topic_says_how_a_track_gets_its_language() {
2159 let text = section(&catalogue(), Some("subtitles")).expect("subtitles topic");
2160 assert!(text.contains("subtitles_import {path, lang?} takes an optional language"), "{text}");
2161 assert!(text.contains("talk.fr.srt, fra.srt, talk_en.srt, eng.srt"), "{text}");
2162 assert!(text.contains("written as und"), "{text}");
2163 assert!(text.contains("subtitles_lang {track, lang}"), "{text}");
2164 }
2165
2166 #[test]
2167 fn append_until_says_it_loops_a_short_source() {
2168 let text = section(&catalogue(), Some("first_video")).expect("first_video topic");
2169 assert!(text.contains("until LOOPS"), "{text}");
2170 }
2171
2172 /// The argument row a tool's help gives for `name`: its line under ARGUMENTS.
2173 fn arg_row(tool: &str, name: &str) -> String {
2174 let tools = catalogue();
2175 let text = section(&tools, Some(tool)).unwrap_or_else(|e| panic!("{tool}: {e}"));
2176 let prefix = format!(" {name} ");
2177 text.lines().find(|l| l.starts_with(&prefix)).unwrap_or_else(|| panic!("{tool} has no `{name}` row:\n{text}")).to_owned()
2178 }
2179
2180 #[test]
2181 fn media_import_help_says_paths_is_a_list_of_paths_with_an_example() {
2182 let row = arg_row("media_import", "paths");
2183 assert!(row.contains("array|string") && row.contains("(e.g. [\"clip.mp4\"])"), "{row}");
2184 assert!(row.contains("a list"), "{row}");
2185 }
2186
2187 #[test]
2188 fn levels_help_says_per_sec_is_a_number_with_an_example() {
2189 let row = arg_row("levels", "per_sec");
2190 assert!(row.contains("number") && row.contains("(e.g. 10)"), "{row}");
2191 assert!(row.contains("Buckets per second: a number"), "{row}");
2192 }
2193
2194 #[test]
2195 fn example_follows_the_schema_type() {
2196 assert_eq!(example("x", &json!({"type": "boolean"})), "true");
2197 assert_eq!(example("x", &json!({"type": "integer", "default": 5})), "5");
2198 assert_eq!(example("x", &json!({"type": "array", "items": {"type": "integer"}})), "[1]");
2199 assert_eq!(example("x", &json!({"type": "string", "enum": ["mp4", "mov"]})), "\"mp4\"");
2200 assert_eq!(example("x", &json!({"examples": ["A1@0"], "type": "string"})), "\"A1@0\"");
2201 assert_eq!(example("paths", &json!({"type": ["array", "string"], "items": {"type": "string"}})), "[\"clip.mp4\"]");
2202 assert_eq!(example("x", &json!({"type": ["array", "string"], "items": {"type": "string"}})), "[\"text\"]");
2203 assert_eq!(example("out_path", &json!({"type": "string"})), "\"cut.mp4\"");
2204 // anyOf and oneOf with no type of their own: the first branch's example, and the union of types.
2205 assert_eq!(example("x", &json!({"anyOf": [{"type": "boolean"}, {"type": "array", "items": {"type": "integer"}}]})), "true");
2206 assert_eq!(example("x", &json!({"oneOf": [{"type": "string", "enum": ["all", "first"]}]})), "\"all\"");
2207 assert_eq!(schema_types(&json!({"oneOf": [{"type": "string"}, {"type": "array"}, {"type": "string"}]})), ["string", "array"]);
2208 assert_eq!(example("range", &json!({"type": "object", "properties": {"from": {}, "to": {}}})), "{\"from\": \"0s\", \"to\": \"5s\"}");
2209 }
2210
2211 /// A number's example is the schema's minimum when it has one, so burn_captions size shows 10, not 1.
2212 #[test]
2213 fn numeric_examples_use_the_schema_minimum() {
2214 assert_eq!(example("size", &json!({"type": "integer", "minimum": 10, "maximum": 200})), "10");
2215 assert_eq!(example("max_secs", &json!({"type": "number", "minimum": 0.5})), "0.5");
2216 assert_eq!(example("bitrate_kbps", &json!({"type": "integer", "minimum": 1})), "8000");
2217 assert_eq!(example("x", &json!({"type": "integer"})), "1");
2218 }
2219
2220 /// Each name a tool's argument takes gets an example of its own kind, not `"text"`.
2221 #[test]
2222 fn named_arguments_get_examples_of_their_kind() {
2223 let string = |desc: &str| json!({"type": "string", "description": desc});
2224 let list = json!({"type": "array", "items": {"type": "string"}});
2225 assert_eq!(example("lanes", &list), "[\"V1\",\"A1\"]");
2226 assert_eq!(example("lane", &string("A caption lane.")), "\"A1\"");
2227 assert_eq!(example("glob", &string("Files to match.")), "\"*.mp4\"");
2228 assert_eq!(example("out", &string("The file to write.")), "\"cut.mp4\"");
2229 assert_eq!(example("clip", &string("A clip address.")), "\"V1@0\"");
2230 assert_eq!(example("source", &string("A source.")), "\"src:0\"");
2231 assert_eq!(example("at", &string("Timeline time, such as 5s or 150f.")), "\"2s\"");
2232 assert_eq!(example("time", &string("A time.")), "\"2s\"");
2233 assert_eq!(example("until", &string("Up to this time.")), "\"2s\"");
2234 assert_eq!(example("path", &string("Where the .edith file will be saved.")), "\"talk.edith\"");
2235 assert_eq!(example("path", &string("Where to write the .srt.")), "\"talk.srt\"");
2236 assert_eq!(example("path", &string("The file the source now is.")), "\"clip.mp4\"");
2237 let range = json!({"type": "object", "properties": {"from": {"description": "Start."}, "to": {"description": "End."}}});
2238 assert_eq!(example("range", &range), "{\"from\": \"0s\", \"to\": \"5s\"}");
2239 let ops = json!({"type": "array", "items": {"type": "object", "properties": {"op": {"type": "string", "enum": ["keep", "place"]}}}});
2240 assert_eq!(example("ops", &ops), "[{\"op\": \"place\", \"source\": \"src:0\", \"at\": \"0s\"}]");
2241 // A list of items takes the item's example, so a list of clip addresses reads as one.
2242 assert_eq!(example("clip", &json!({"type": "array", "items": {"type": "string"}})), "[\"V1@0\"]");
2243 }
2244
2245 /// The generated help shows the new examples for real arguments, not the placeholder ones.
2246 #[test]
2247 fn generated_help_shows_real_examples_for_real_arguments() {
2248 let tools = catalogue();
2249 let row = |tool: &str, name: &str| {
2250 let text = section(&tools, Some(tool)).unwrap_or_else(|e| panic!("{tool}: {e}"));
2251 text.lines().find(|l| l.starts_with(&format!(" {name} "))).unwrap_or_else(|| panic!("{tool} has no `{name}` row:\n{text}")).to_owned()
2252 };
2253 assert!(row("edit", "ops").contains("(e.g. [{\"op\": \"place\", \"source\": \"src:0\", \"at\": \"0s\"}])"), "{}", row("edit", "ops"));
2254 let all = tools.iter().map(|t| section(&tools, Some(t.name)).unwrap_or_default()).collect::<Vec<_>>().join("\n");
2255 let placeholders = ["(e.g. [\"text\"])", "(e.g. \"text\")", "{\"from\": \"text\", \"to\": \"text\"}", "(e.g. [{\"op\": \"place\"}])"];
2256 let shown: Vec<&str> = all.lines().filter(|l| placeholders.iter().any(|p| l.contains(p))).collect();
2257 assert!(shown.is_empty(), "generated help rows still show a placeholder example:\n{}", shown.join("\n"));
2258 }
2259
2260 /// Every argument of every tool has a type and an example in its help, so no row is left
2261 /// with a bare name. A refusal that names the expected type can reuse the same example.
2262 #[test]
2263 fn every_tool_argument_has_a_type_and_an_example() {
2264 let mut gaps = Vec::new();
2265 for tool in catalogue() {
2266 let text = section(&catalogue(), Some(tool.name)).expect("tool topic");
2267 let schema = (tool.schema)();
2268 let Some(props) = schema.get("properties").and_then(Value::as_object) else { continue };
2269 for (name, prop) in props {
2270 let row = text.lines().find(|l| l.starts_with(&format!(" {name} "))).unwrap_or("");
2271 let typed = !schema_types(prop).is_empty();
2272 if !typed || !row.contains("(e.g. ") || row.contains("(e.g. …)") {
2273 gaps.push(format!("{}.{name}", tool.name));
2274 }
2275 }
2276 }
2277 assert!(gaps.is_empty(), "arguments without a type or an example: {gaps:?}");
2278 }
2279
2280 /// The cut tools and the caption recipes say captions follow the cut, and locked caption lanes stay.
2281 #[test]
2282 fn cuts_and_caption_topics_say_caption_lanes_ripple_with_the_cut() {
2283 const PHRASE: &str = "caption lanes ripple with the cut; locked caption lanes stay";
2284 let tools = catalogue();
2285 for topic in ["recipes", "captions", "podcast"] {
2286 let text = section(&tools, Some(topic)).unwrap_or_else(|e| panic!("{topic}: {e}"));
2287 assert!(text.to_lowercase().contains(PHRASE), "{topic} lacks the caption ripple rule:\n{text}");
2288 }
2289 let recipes = section(&tools, Some("recipes")).unwrap();
2290 for tool in ["cut_silence:", "find_words"] {
2291 let line = recipes.lines().find(|l| l.contains(tool)).unwrap_or_else(|| panic!("no {tool} line"));
2292 assert!(line.contains("ripple") || recipes.to_lowercase().contains(PHRASE), "{tool}: {line}");
2293 }
2294 }
2295}