Open source CapCut alternative.
TypeScript
feat(app): add broad capability skills and extend the tool probe
David Le756b7f29105c
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/data/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/data/SKILL.mdnew file mode 100644index 00000000..5f00f920--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/data/SKILL.md@@ -0,0 +1,28 @@+# Data++id: data+description: Expert data manipulation — query, reshape, and convert CSV/JSON/TSV with python3 and sqlite3, which ship with macOS, plus jq and mlr when installed.+tags: data, csv, json, tsv, sql, transform+keywords: csv, json, tsv, data, convert, filter, group, aggregate, join, query, sql, spreadsheet, column+tools: shell_exec++`python3` and `sqlite3` ship with macOS — lead with them so a task never depends+on an uninstalled tool. `jq` and `mlr` are nicer for one-liners but are not+guaranteed; check the ENVIRONMENT tool list before reaching for them. Writing an+output file is reversible (consent gate).++## python3 — the always-available workhorse (stdlib csv + json)+- CSV to JSON: `python3 -c "import csv,json,sys; json.dump(list(csv.DictReader(open('in.csv'))), sys.stdout, indent=2)" > out.json`.+- JSON to CSV: `python3 -c "import csv,json,sys; r=json.load(open('in.json')); w=csv.DictWriter(sys.stdout, r[0].keys()); w.writeheader(); w.writerows(r)" > out.csv`.+- For multi-step reshaping (group, join, pivot), write the logic as a short python script and run it, rather than chaining fragile one-liners.+- XLSX needs pandas + openpyxl, which are usually NOT installed. If the user has them, `python3 -c "import pandas as pd; pd.read_excel('in.xlsx').to_csv('out.csv', index=False)"`; otherwise say plainly that Excel support isn't available and offer CSV.++## sqlite3 — SQL over a CSV without a database+- `sqlite3 :memory: -cmd '.mode csv' -cmd '.import in.csv t' 'select category, count(*) from t group by category'`.++## jq / mlr — only when the ENVIRONMENT block lists them+- Filter/reshape JSON: `jq '.items[] | {name, id}' in.json`.+- CSV↔JSON: `mlr --c2j cat in.csv`, `mlr --j2c cat in.json`.++## Verify+- Re-read the output and sanity-check shape: `head out.csv`, `wc -l out.csv`, or `python3 -c "import json; print(len(json.load(open('out.json'))))"`. A row/record count that matches the input is the success check.\ No newline at end of filediff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/images/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/images/SKILL.mdnew file mode 100644index 00000000..e2961407--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/images/SKILL.md@@ -0,0 +1,33 @@+# Images++id: images+description: Expert still-image work — resize, convert, and rotate with sips, crop/composite/batch with magick, and read or strip metadata with exiftool.+tags: image, photo, resize, convert, metadata, exif+keywords: image, photo, picture, resize, scale, convert, crop, rotate, jpeg, png, heic, metadata, exif, strip+tools: shell_exec++`sips` ships with macOS and `exiftool` is bundled and on the PATH — lead with+those; they cover almost every request. `magick` (ImageMagick) is only available+when the user has installed it (check the ENVIRONMENT tool list), so reach for it+only for what `sips` can't do. Editing a file in place is reversible (consent+gate); writing to a new `--out` path is safer, so prefer it when the user wants+to keep the original.++## sips — resize, convert, rotate (writes a new file with --out)+- Resize to a max dimension, aspect preserved: `sips -Z 1024 in.jpg --out small.jpg`.+- Convert format: `sips -s format jpeg in.png --out out.jpg` (formats: jpeg, png, tiff, gif, pdf).+- Rotate: `sips -r 90 in.jpg --out rotated.jpg` (degrees clockwise).+- Image to PDF: `sips -s format pdf in.png --out out.pdf`.+- Read dimensions: `sips -g pixelWidth -g pixelHeight in.jpg`.++## magick — crop, composite, batch (only if installed)+- Crop a region WxH+X+Y: `magick in.png -crop 200x200+0+0 out.png`.+- Batch convert a folder: `magick mogrify -format jpg *.png`. NOTE `mogrify` edits or replaces files in place — confirm before running it on originals.+- If `magick` is not in the ENVIRONMENT list, do what `sips` can and say plainly what needs ImageMagick; do not pretend it ran.++## exiftool — read and strip metadata+- Read all metadata: `exiftool in.jpg`. One tag: `exiftool -GPSLatitude -GPSLongitude in.jpg`.+- Strip everything (privacy): `exiftool -all= in.jpg` — keeps a `in.jpg_original` backup; delete it only if the user confirms.++## Verify+- Re-read the result: `sips -g pixelWidth -g pixelHeight out.jpg`, or `exiftool out.jpg` after stripping to confirm the tags are gone.\ No newline at end of filediff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.mdnew file mode 100644index 00000000..344d68e1--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/media/SKILL.md@@ -0,0 +1,29 @@+# Media++id: media+description: Expert audio and video — download from a URL with yt-dlp, then transcode, trim, extract audio, or grab frames with ffmpeg.+tags: video, audio, media, download, convert, youtube+keywords: video, audio, download, youtube, vimeo, mp4, mp3, convert, trim, clip, extract audio, transcode, frame+tools: shell_exec++`yt-dlp` and `ffmpeg`/`ffprobe` are bundled and on the PATH, so use them by bare+name. Downloading and writing files is reversible — propose the command and let+the consent gate handle approval; do not fall back to a browser.++## Download from a URL (yt-dlp)+- 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.+- 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'`.+- `Unable to extract` / `HTTP 403` usually means the bundled yt-dlp is older than the site's latest change, not a bad URL — report that plainly; do not retry blindly.++## Edit a local file (ffmpeg)+- Transcode by changing the extension: `ffmpeg -i in.mov out.mp4`.+- Trim without re-encoding: `ffmpeg -ss 00:00:10 -i in.mp4 -t 30 -c copy out.mp4` (start, then 30s).+- Extract audio: `ffmpeg -i in.mp4 -vn -acodec libmp3lame out.mp3`.+- One frame / thumbnail: `ffmpeg -ss 5 -i in.mp4 -frames:v 1 thumb.png`. Frames every second: `ffmpeg -i in.mp4 -vf fps=1 frame_%03d.png`.+- ffmpeg refuses to overwrite by default and prompts; pass `-y` to overwrite or choose a new output name.++## Verify+- Confirm the output exists and is real media: `ffprobe -v error -show_entries format=duration:format_name -of default=nw=1 out.mp4`.+- A zero-byte file or an ffprobe error means the operation failed — report it, don't claim success.\ No newline at end of filediff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/pdf/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/pdf/SKILL.mdnew file mode 100644index 00000000..2cabbfa9--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/pdf/SKILL.md@@ -0,0 +1,34 @@++id: pdf+description: Expert headless PDF and document work — extract text and structured data with liteparse, merge/split/rotate with qpdf, and convert document formats with textutil.+tags: pdf, document, convert, merge, split, ocr, extract+keywords: pdf, extract, parse, text, ocr, scan, json, merge, combine, split, extract pages, rotate, convert, docx, rtf, html+tools: shell_exec++`lit` (liteparse) and `qpdf` are bundled and on the PATH; `textutil` and `mdls`+ship with macOS. This is the headless path — for interactive Preview work+(filling a form, watching a rotation), use the `documents` skill instead.+Creating files is reversible (consent gate).++## qpdf — structure (page order in, page order out)+- Merge: `qpdf --empty --pages a.pdf b.pdf -- out.pdf`.+- Extract / split a range: `qpdf in.pdf --pages in.pdf 1-5 -- out.pdf`.+- Rotate page 1 by 90°: `qpdf in.pdf --rotate=+90:1 -- out.pdf`.+- Remove a known password: `qpdf --password=PW --decrypt in.pdf out.pdf`.+- Page count: `qpdf --show-npages in.pdf`.++## Convert document formats (textutil, built into macOS)+- `textutil` converts among txt, html, rtf, doc, docx, odt with no extra tools: `textutil -convert docx in.html -output out.docx`, `textutil -convert txt in.docx -output out.txt`, `textutil -convert html in.rtf -output out.html`.+- Markdown, LaTeX, and EPUB are NOT covered by textutil and need `pandoc`, which is not bundled — use it only when the ENVIRONMENT lists it (`pandoc in.md -o out.docx`); otherwise say plainly that those formats need pandoc installed.+- To make a PDF from a document: convert it to HTML with textutil, then render that HTML to PDF via the `web-capture` skill (headless print).++## Extract text or structured data from a PDF — use liteparse (`lit`)+- `lit` handles both digital and scanned PDFs; OCR is built in, so there is no separate rasterize/OCR step.+- Plain text: `lit parse in.pdf`. Specific pages: `lit parse in.pdf --target-pages "1-5,10"`.+- Structured JSON (per-element text with layout/bounding boxes — use this when the task needs fields, tables, or positions): `lit parse in.pdf --format json -o out.json`.+- Skip OCR for a known-digital PDF to go faster: `lit parse in.pdf --no-ocr`.+- For just a title/metadata lookup without parsing, `mdls -name kMDItemTitle in.pdf` still works.++## Verify+- After a structural edit, confirm with `qpdf --show-npages out.pdf` or re-read the text with `mdls`. After a conversion, confirm the output file exists and opens.\ No newline at end of filediff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/web-capture/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/web-capture/SKILL.mdnew file mode 100644index 00000000..ed45b328--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/web-capture/SKILL.md@@ -0,0 +1,28 @@+# Web Capture++id: web-capture+description: Save a web page to a file — clean markdown via web.fetch, or a PDF or full-page screenshot of the rendered page.+tags: web, capture, pdf, screenshot, archive, markdown+keywords: save page, web page, website, pdf, screenshot, archive, markdown, capture, print to pdf+tools: web.fetch, web_snapshot, shell_exec, apps_list++Pick the format the user asked for. Saving to a file is reversible; default the+destination to `~/Downloads`.++## Page to markdown or JSON — use web.fetch, not a browser+- `web.fetch` returns the page's main content as clean markdown already. Save it with the `web-research`/`notes` long-content pattern.+- For JSON, pass the fetched markdown through `llm.generate` ("structure this as JSON with fields …"). Do not screenshot or drive a browser for text.++## Page to PDF or screenshot — render it (free rungs first)+Capture the rendered page with the cheapest engine that works, in order:+1. **Local Chromium**, only if one is installed — check `apps_list` (Google Chrome, Brave, Microsoft Edge, Arc), then `'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --headless=new --disable-gpu --print-to-pdf=$HOME/Downloads/page.pdf 'URL'` (PDF) or `--screenshot=$HOME/Downloads/page.png --window-size=1280,2000 'URL'`.+2. **Built-in `web_snapshot`** — always available, no external browser. `web_snapshot` with `url` and `format=pdf` (default) or `format=png` (full page), optional `destination`. Use this whenever no Chromium is installed.+3. If the page needs a login or is blocked by bot-protection so neither renders it, say so plainly. (A hosted browser fallback for those cases is coming — see `plans/browser-use-integration.md`.)++Do not invent a headless flag for Safari; it has none. For just the visible+screen rather than the whole page, `screencapture -x ~/Downloads/shot.png` after+making a browser frontmost.++## Verify+- Markdown: confirm the saved file is non-empty and has the expected headings.+- PDF: `qpdf --show-npages page.pdf` (see the `pdf` skill) or open it. PNG: `sips -g pixelWidth -g pixelHeight page.png`.\ No newline at end of filediff --git a/apps/Donkey/Sources/DonkeyRuntime/SystemToolCapabilityProbe.swift b/apps/Donkey/Sources/DonkeyRuntime/SystemToolCapabilityProbe.swiftindex 4ea7a114..d884dd4b 100644--- a/apps/Donkey/Sources/DonkeyRuntime/SystemToolCapabilityProbe.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/SystemToolCapabilityProbe.swift@@ -11,9 +11,12 @@ public actor SystemToolCapabilityProbe {public static let shared = SystemToolCapabilityProbe()/// Curated tools an expert might reach for that are NOT guaranteed present.- /// (Ubiquitous system tools like `mdfind`/`defaults`/`open` are assumed.)+ /// (Ubiquitous system tools like `mdfind`/`defaults`/`open` are assumed, and the+ /// tools Donkey bundles — ffmpeg, yt-dlp, qpdf, exiftool, lit — are always present,+ /// so the skills assert them directly rather than probing.)private static let probedTools = [- "gh", "git", "jq", "python3", "node", "brew", "rg", "swift", "ffmpeg", "docker", "go", "cargo"+ "gh", "git", "jq", "python3", "node", "brew", "rg", "swift", "docker", "go", "cargo",+ "pandoc", "magick", "sqlite3", "pdftotext", "mlr"]private let cacheURL: URLdiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/SkillInstallTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/SkillInstallTests.swiftindex 8de3048e..aa917c2e 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/SkillInstallTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/SkillInstallTests.swift@@ -258,4 +258,14 @@ struct SkillInstallTests {let ids = descriptors.map(\.id)#expect(Set(ids).count == ids.count)}++ @Test+ func broadCapabilitySkillsAreDiscovered() {+ // The five capability skills (media, images, pdf, data, web-capture) ship built-in and are+ // discovered by walking the tree — no enumerated list to keep in sync.+ let ids = Set(BuiltInLocalAppSkillPacks.descriptors().map(\.id))+ for id in ["media", "images", "pdf", "data", "web-capture"] {+ #expect(ids.contains(id))+ }+ }}diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.mdindex cd60cc2d..b9221bd6 100644--- a/docs/guides/agent-harness.md+++ b/docs/guides/agent-harness.md@@ -191,6 +191,12 @@ Consent surfaces in the pointer/notch overlay and reuses the standardtools (and versions) exist on the machine, so the planner only reaches forwhat's installed.+Broad capability skills extend this power-user surface beyond the tools macOS+ships — media (`yt-dlp`, `ffmpeg`), images, PDF/document conversion, data+manipulation, and web capture. The uncommon command-line tools those skills+rely on are bundled inside the signed app, so the capability works without the+user installing anything.+## Observation and Action (Computer Use)Seeing and acting are plain tools the planner picks per step — not a fixed