Open source CapCut alternative.
TypeScript
docs(app): place model-facing text by scope; teach the subtitle workflow in its skill
David Le80871ac24914
diff --git a/apps/Donkey/Sources/DonkeyAI/DonkeyPrompts.swift b/apps/Donkey/Sources/DonkeyAI/DonkeyPrompts.swiftindex 5eb80dd3..d31adbb4 100644--- a/apps/Donkey/Sources/DonkeyAI/DonkeyPrompts.swift+++ b/apps/Donkey/Sources/DonkeyAI/DonkeyPrompts.swift@@ -16,19 +16,28 @@ import Foundation/// - `harnessStep` — the per-observation planning step of the harness loop/// (`HostedHarnessStepPlanner`).///-/// What the models read but does NOT live here, by design:+/// BEFORE ADDING ANYTHING HERE, PLACE IT BY SCOPE. Most model-facing text is NOT+/// cross-tool doctrine and belongs elsewhere — the planner still reads it, just from a+/// better home. The recurring mistake is dropping a single-tool fact into the prompt+/// because the prompt is the obvious place: it bloats every turn and drifts away from the+/// tool it describes.///-/// - Tool descriptors (name, summary, schemas) stay with their tools:-/// `DonkeyCommandLayer` (fast command tools), `BuiltInHarnessToolCatalog`-/// (harness tools), and the Live escalation descriptors in-/// `GeminiLiveVoiceController`. A descriptor states only that tool's own-/// factual contract — cross-tool doctrine belongs here.-/// - App-specific operating knowledge lives in discoverable skill packs-/// (`Resources/BuiltInSkills/<app>/SKILL.md`), never in prompts.-/// - Narrow task adapters keep their specialized prompts next to their parsing:-/// `VisionActionPlanner`, `GeminiVertexVisionBoxPlanner`,-/// `DebugUIInspectionHostedAdapter`, `HostedAppleScriptGenerationAdapter`,-/// `HostedConversationFollowUpResolver`, and `HostedLocalAppCatalogProfileGenerator`.+/// - A fact about ONE tool — where it runs, when to prefer it, a parameter caveat, a+/// safety note → that tool's DESCRIPTOR (`DonkeyCommandLayer` for the fast command+/// tools, `BuiltInHarnessToolCatalog` for harness tools, the Live escalation+/// descriptors in `GeminiLiveVoiceController`). The planner reads descriptors in the+/// `AVAILABLE TOOLS` block, so the fact reaches the model co-located with its tool and+/// only when that tool is offered.+/// - A workflow for ONE app or domain — how to subtitle a video, fill a PDF form, drive+/// a specific app → its discoverable SKILL pack (`Resources/BuiltInSkills/<id>/SKILL.md`),+/// never a prompt.+/// - Only doctrine that holds across tools AND tasks — retry discipline, see-before-act,+/// shell-first — belongs in the prompt text here.+///+/// Narrow task adapters keep their own specialized prompts next to their parsing, not here:+/// `VisionActionPlanner`, `GeminiVertexVisionBoxPlanner`, `DebugUIInspectionHostedAdapter`,+/// `HostedAppleScriptGenerationAdapter`, `HostedConversationFollowUpResolver`, and+/// `HostedLocalAppCatalogProfileGenerator`.public enum DonkeyPrompts {// MARK: - Realtime command sessiondiff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.mdindex b65d5b5a..5040af58 100644--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.md+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.md@@ -4,7 +4,7 @@ id: mediadescription: Expert audio and video — download from a URL with yt-dlp, transcode/trim/extract/grab frames with ffmpeg, and transcribe, subtitle, or translate with the model.tags: video, audio, media, download, convert, youtube, subtitles, transcribekeywords: video, audio, download, youtube, vimeo, mp4, mp3, convert, trim, clip, extract audio, transcode, frame, subtitle, subtitles, caption, captions, transcribe, transcript, translate, srt, vtt-tools: shell_exec, llm.generate+tools: shell_exec, llm.generate, files.write`yt-dlp` and `ffmpeg`/`ffprobe` are bundled, signed, and on the PATH, so use themby bare name. They are first-party capability tools: downloading from the user's@@ -22,6 +22,7 @@ case say the media tools are still installing and stop. Do not try to install an- **These calls are slow — always pass `timeoutSeconds`.** Extracting a YouTube page (it solves a JS challenge first) can take ~15s *before any bytes download*, so the default short timeout kills it mid-extract. Pass `timeoutSeconds: 120` on the shell_exec call for every yt-dlp download.- Always single-quote the URL — `?` and `&` are shell metacharacters: `yt-dlp -P ~/Downloads 'URL'`.- Default the destination to `~/Downloads`; honor a different folder only if the user names one. yt-dlp already picks the best quality.+- **Pin a known output path so later steps never hunt for the file.** Pass `-o ~/Downloads/clip.%(ext)s` and add `--print after_move:filepath` — yt-dlp prints the EXACT final path (the container may resolve to `.mp4` or `.webm`). Use that path verbatim for ffprobe/ffmpeg; do NOT run `find`/`ls` to go looking for the download, and never re-download to "check" — you already know where it landed.- A specific time range (a clip) downloads just that span: `yt-dlp --download-sections '*15:00-16:00' -P ~/Downloads 'URL'`.- Audio only: `yt-dlp -x --audio-format mp3 -P ~/Downloads 'URL'`.- A specific resolution if asked: `yt-dlp -f 'bestvideo[height<=1080]+bestaudio' -P ~/Downloads 'URL'`.@@ -42,12 +43,12 @@ Get the subtitle text, then apply it. Prefer the cheapest source that gives corr`yt-dlp --write-subs --write-auto-subs --sub-langs 'en.*' --convert-subs srt --skip-download -P ~/Downloads 'URL'` (drop `--skip-download` to grab the video too).2. **Otherwise transcribe with the model.** Timing matters: **clip first, then transcribe the clip** so timestamps start at zero and line up. Extract compact mono audio, then call `llm.generate` with that file:- `ffmpeg -i clip.mp4 -vn -ac 1 -c:a libmp3lame -b:a 64k clip.mp3`- - `llm.generate filePath=clip.mp3 prompt="Transcribe this audio to SRT with timestamps, one cue per sentence" toFile=true` → the returned file holds your SRT text; save/rename it to `subs.srt`.+ - `llm.generate filePath=clip.mp3 prompt="Transcribe this audio to SRT with timestamps, one cue per sentence" toFile=true` → the returned file ALREADY holds your SRT text. Use that path directly (or `mv` it to `subs.srt`); never re-type its contents into a `cat`/`echo` heredoc — that re-typing is the most common way this task stalls.3. **Translate** by asking in the same call: `prompt="Transcribe this audio and translate the text to Spanish; output SRT, keep the timestamps"`.4. **Long media — chunk it.** Inline audio is size-limited (`llm.generate` rejects a file that is too large or a transcript it had to truncate — both mean "use smaller chunks"). Split, transcribe each zero-based, then shift by each segment's *real* start:- `ffmpeg -i audio.mp3 -f segment -segment_time 600 -reset_timestamps 1 -c copy seg_%03d.mp3` splits into ~10-min pieces.- `-c copy` cuts on frame boundaries, so a segment's real length is not exactly 600s. Read each one's true duration with `ffprobe -v error -show_entries format=duration -of csv=p=0 seg_000.mp3` and accumulate; that running sum is the next segment's start offset — do not assume `index × 600`.- - Transcribe each segment with a plain zero-based prompt (`"Transcribe to SRT with timestamps"`), then add the accumulated offset to every cue in that segment's SRT and concatenate in order, renumbering cue indices. Sanity-check that timestamps only increase.+ - Transcribe each segment with a plain zero-based prompt (`"Transcribe to SRT with timestamps"`), then add the accumulated offset to every cue in that segment's SRT and concatenate in order, renumbering cue indices. Sanity-check that timestamps only increase. Persist the assembled SRT with `files.write path=~/Downloads/subs.srt content=…` (the whole multi-line file in one call) — not a shell heredoc.5. **Apply to the video (ffmpeg):**- Burn-in (default for a shareable clip — always-visible, what social players expect): `ffmpeg -i clip.mp4 -vf "subtitles=subs.srt" -c:a copy out.mp4`. The bundled ffmpeg ships with libass, so this works out of the box. If it ever fails with `No such filter: 'subtitles'` (a stripped ffmpeg without libass), fall back to the soft track below and tell the user why.- Soft, toggleable track (offer for an archive copy): `ffmpeg -i clip.mp4 -i subs.srt -c copy -c:s mov_text out.mp4`.diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.mdindex ff7a0ff1..1bfc6dd7 100644--- a/docs/guides/agent-harness.md+++ b/docs/guides/agent-harness.md@@ -157,6 +157,22 @@ plugin id, schemas, required permissions, safety class, required context,verification hints, and metadata. The planner sees descriptors and schemas,never Swift implementations.+**Three homes for model-facing text, split by scope.** Everything the model reads+is placed by how widely it applies, and the split is deliberate:++- a **tool descriptor** carries one tool's own contract — what it does, its+ parameters, where it runs, its safety. It travels with the tool and reaches the+ model only when that tool is offered.+- a **skill pack** carries one app's or domain's workflow — how to subtitle a video,+ fill a form — and is surfaced when the task matches it.+- the **planner prompt** carries only doctrine that holds no matter which tool or task+ is in play: retry discipline, see-before-act, shell-first.++When a new fact for the model is needed, place it by scope: one tool → its descriptor;+one domain → its skill; true everywhere → the prompt. A single-tool fact in the prompt+is the easy mistake — it bloats every turn and drifts from the tool it describes, so the+two fall out of sync.+Tool results come back as structured observations that update the world model.Four situations are hard stops, not things to push through: