Skip to content

Open source CapCut alternative.

TypeScript

feat(app): expand and rename the built-in skill catalog; learned packs compound

David Le15bb45d74835
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
index ffadb661..fccd0165 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
@@ -324,6 +324,13 @@ public struct HarnessApplicationSkillPackWriter: Sendable {
.appendingPathComponent("LearnedApplications", isDirectory: true)
}
+ /// Decodes a profile `save` wrote (`app-profile.json`), matching its iso8601 date encoding.
+ public static func loadProfile(from url: URL) throws -> HarnessApplicationProfile {
+ let decoder = JSONDecoder()
+ decoder.dateDecodingStrategy = .iso8601
+ return try decoder.decode(HarnessApplicationProfile.self, from: Data(contentsOf: url))
+ }
+
public func save(
profile: HarnessApplicationProfile,
scripts: [HarnessGeneratedScriptArtifact] = []
@@ -414,6 +421,9 @@ public struct HarnessApplicationSkillPackWriter: Sendable {
metadata: [
"appName": profile.appName,
"bundleIdentifier": profile.bundleIdentifier ?? "",
+ "apps": [profile.appName, profile.bundleIdentifier ?? ""]
+ .filter { !$0.isEmpty }
+ .joined(separator: ", "),
"directory": skillDirectory.path,
"source": "applicationLearning"
]
@@ -455,11 +465,15 @@ public struct HarnessApplicationSkillPackWriter: Sendable {
.map { "- \($0.id): \($0.metadata["purpose"] ?? $0.id)" }
.joined(separator: "\n")
+ let apps = [profile.appName, profile.bundleIdentifier ?? ""]
+ .filter { !$0.isEmpty }
+ .joined(separator: ", ")
return """
# \(profile.appName) Learned Application
id: \(skillID)
description: Learned surfaces and safe workflows for \(profile.appName).
tags: application-learning, learned-app, \(sanitizedSlug(profile.appName))
+ apps: \(apps)
tools: screen.observe, elements.get, element.perform, state.verify
Use this skill when operating \(profile.appName) or a compatible app surface.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
index 67ec98e2..565ef8a1 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
@@ -18,8 +18,40 @@ public enum BuiltInLocalAppSkillPacks {
).discover()
}()
+ /// Learned application skill packs (saved by `application.learning.saveSkillPack`) can appear
+ /// mid-session, so unlike the bundled packs they are re-discovered with a short TTL. This is
+ /// what makes learning compound: a pack saved in one session is matched and preloaded like a
+ /// built-in in every later session.
+ private final class LearnedPackCache: @unchecked Sendable {
+ private let lock = NSLock()
+ private var cached: (descriptors: [HarnessSkillDescriptor], at: Date)?
+
+ func descriptors(ttl: TimeInterval, discover: () -> [HarnessSkillDescriptor]) -> [HarnessSkillDescriptor] {
+ lock.lock()
+ defer { lock.unlock() }
+ if let cached, Date().timeIntervalSince(cached.at) < ttl {
+ return cached.descriptors
+ }
+ let fresh = discover()
+ cached = (fresh, Date())
+ return fresh
+ }
+ }
+
+ private static let learnedPackCache = LearnedPackCache()
+
+ public static func learnedDescriptors() -> [HarnessSkillDescriptor] {
+ learnedPackCache.descriptors(ttl: 30) {
+ HarnessSkillFileSystemSource(
+ roots: [HarnessApplicationSkillPackWriter.defaultRootDirectory()],
+ sourceKind: .userDirectory
+ ).discover()
+ }
+ }
+
+ /// Bundled packs first so a curated built-in wins over a learned pack for the same app.
public static func descriptors() -> [HarnessSkillDescriptor] {
- cachedDescriptors
+ cachedDescriptors + learnedDescriptors()
}
public static func instructionSnippet(
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser-navigation/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser-navigation/SKILL.md
deleted file mode 100644
index 1809828d..00000000
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser-navigation/SKILL.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Browser Navigation
-id: browser-navigation
-description: Plan opening websites and URLs in a supported browser.
-tags: browser, website, navigation, local-app
-tools: app.openOrFocus, app.observe, ui.focusAddressBar, ui.setText, ui.pressReturn, app.verifyCommand
-
-Use this skill for website or URL navigation when the app finder catalog exposes a supported browser capability.
-
-Set `query` to the normalized URL or website string to open. Prefer the user's named browser when present; otherwise choose a supported browser catalog entry.
-
-When planning generic `local_app_interaction`, use `goal=open requested website`, `inputEntity=query`, `controlID=addressBar`, `focusKey=Command+L`, and tools `app.openOrFocus`, `app.observe`, `ui.focusAddressBar`, `ui.setText`, `ui.pressReturn`, `app.verifyCommand`.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser/SKILL.md
new file mode 100644
index 00000000..1687cfd9
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/browser/SKILL.md
@@ -0,0 +1,19 @@
+# Browser
+
+id: browser
+description: Open websites in any browser — `open` for the default browser, `open -a` for a named one, Cmd+L + typing for in-browser navigation.
+tags: browser, website, navigation, local-app
+keywords: browser, website, url, open site, chrome, firefox, arc, edge
+tools: shell_exec, app_skill
+
+Opening a URL never needs GUI automation:
+
+- Default browser: `open https://example.com`.
+- A specific browser: `open -a "Google Chrome" https://example.com` (use `apps_list` to get the exact name).
+- Web search: `open "https://www.google.com/search?q=URL+ENCODED+QUERY"`.
+
+To navigate an already-open browser window instead of opening a new tab: focus the browser, press Cmd+L (keyboard.press key=l modifiers=command) to focus the address bar, type the URL with text.enter, then press return. `wait` 1–2s after navigation before observing the page.
+
+Safari has its own richer skill (tab management, reading tab state via AppleScript) — prefer it when the browser is Safari. Chromium browsers also answer `osascript -e 'tell app "Google Chrome" to get URL of active tab of front window'` when installed.
+
+Verify by re-reading the frontmost browser tab (AppleScript when scriptable, otherwise observe the window title).
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/calendar/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/calendar/SKILL.md
new file mode 100644
index 00000000..88edf44f
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/calendar/SKILL.md
@@ -0,0 +1,30 @@
+# Calendar
+
+id: calendar
+description: Read and create Calendar events through AppleScript with bounded date windows; deleting or moving events asks first.
+tags: calendar, events, schedule, local-app
+keywords: calendar, event, meeting, appointment, schedule, today, tomorrow, remind, invite
+apps: Calendar, com.apple.iCal
+tools: shell_exec, app_skill
+
+Calendar is scriptable. Always bound queries to a named calendar and a date window — unbounded `every event` queries crawl years of history and time out.
+
+## Read events
+- List calendars first: `osascript -e 'tell app "Calendar" to get name of every calendar'`.
+- Today's events in one calendar:
+ `osascript -e 'tell app "Calendar" to tell calendar "Home" to get summary of (every event whose start date ≥ (current date) - (time of (current date)) and start date < (current date) - (time of (current date)) + 1 * days)'`.
+- Keep windows to a day or a week; never query all calendars at once.
+
+## Create an event (reversible; runs after one consent)
+- `osascript -e 'tell app "Calendar" to tell calendar "Home" to make new event with properties {summary:"Dentist", start date:date "2026-06-12 14:00", end date:date "2026-06-12 15:00"}'`
+- Use the calendar the user names; otherwise pick their primary writable calendar and say which one you used.
+- Date literals depend on system locale; when a date fails to parse, build it in pieces: `set d to current date` then set its year/month/day/time properties before `make new event`.
+
+## Delete or move events
+- Destructive for the user's schedule — confirm the exact event (summary + start date) with the user before deleting or rescheduling.
+
+## Verify
+- Re-read the day's events after creating and confirm the new summary appears before completing.
+
+## GUI fallback
+- Invitee responses, travel time, and complex recurrence are easier in the GUI: focus Calendar, ax.observe, and drive the event editor.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/contacts/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/contacts/SKILL.md
new file mode 100644
index 00000000..4702c101
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/contacts/SKILL.md
@@ -0,0 +1,29 @@
+# Contacts
+
+id: contacts
+description: Look up people in Apple Contacts through AppleScript — emails, phones, addresses, birthdays — feeding the result into mail, notes, events, or Maps.
+tags: contacts, people, address-book, local-app
+keywords: contact, person, email address, phone number, birthday, address, company
+apps: Contacts, com.apple.AddressBook
+tools: shell_exec, app_skill
+
+Contacts is fully scriptable and read-mostly. Reading contact data is one `osascript` line; editing contacts is rare — ask before changing anything.
+
+## Find a person
+- By name: `osascript -e 'tell app "Contacts" to get name of (people whose name contains "Alex")'` — disambiguate with the user when several match.
+- By company: `osascript -e 'tell app "Contacts" to get name of (people whose organization contains "Acme")'`.
+
+## Read their details
+- Email: `osascript -e 'tell app "Contacts" to get value of email 1 of (person 1 whose name contains "Alex")'`.
+- Phone: `osascript -e 'tell app "Contacts" to get value of phone 1 of (person 1 whose name contains "Alex")'`.
+- Address (one formatted string): `osascript -e 'tell app "Contacts" to get formatted address of address 1 of (person 1 whose name contains "Alex")'`.
+- Birthday: `osascript -e 'tell app "Contacts" to get birth date of (person 1 whose name contains "Alex")'`.
+- A person may have several emails/phones (`email 2`, `every email`); pick the labeled one the task implies when it matters.
+
+## Feed the result onward
+- Draft an email to them: pass the address to the Mail skill's outgoing-message flow.
+- Open their address in Maps: `open "maps://?q=ADDRESS"` (URL-encode spaces as %20 or quote the whole URL).
+- Save to a note / copy to clipboard: Notes skill or `pbcopy`.
+
+## Verify
+- Echo the exact value read (the address, number, email) into the next step's input and confirm the downstream effect — a contact lookup alone is not task completion.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/documents/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/documents/SKILL.md
new file mode 100644
index 00000000..d5a99f5e
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/documents/SKILL.md
@@ -0,0 +1,38 @@
+# Documents
+
+id: documents
+description: Work with PDFs and images in Preview — which is NOT scriptable — using keyboard shortcuts and shell tools (sips, mdls) for the heavy lifting.
+tags: preview, pdf, image, documents, local-app
+keywords: pdf, preview, image, rotate, export, extract, text, page, scan, receipt, invoice, form
+apps: Preview, com.apple.Preview
+tools: shell_exec, app_skill
+
+Preview has no useful AppleScript dictionary. Open files with `open`, do file-level work with shell tools, and use keyboard shortcuts for in-app actions. Expect a short `wait` after opening before the document is ready.
+
+## Find the newest PDF or image
+- Commands run under `zsh`, where a glob that matches nothing ABORTS the whole command (`no matches found`). To find the newest file of several types, list by time and filter with grep instead of globbing many extensions:
+ - Newest image: `ls -t ~/Downloads | grep -iE '\.png$|\.jpg$|\.jpeg$|\.gif$|\.heic$|\.webp$|\.tiff$' | head -1`
+ - Newest PDF: `ls -t ~/Downloads/*.pdf | head -1` (single extension is safe), or `ls -t ~/Downloads | grep -i '\.pdf$' | head -1`.
+ - The result is a bare filename; prefix `~/Downloads/` when passing it on.
+- Keep parentheses OUT of shell commands: the safety classifier treats `(`/`)` (subshells, `find \( \)`, glob qualifiers like `(N)`) as separate commands and prompts for approval even on a read-only command. The `ls … | grep -iE` form above is parenthesis-free and runs instantly.
+- Never conclude "no images/files exist" from a `no matches found` error — that means the glob was too strict, not that the folder is empty. Retry with the `ls | grep` form.
+
+## Open
+- `open -a Preview ~/Downloads/file.pdf` (or just `open file.pdf` when Preview is the default). Then `wait` ~1s before acting.
+
+## Read text out of a PDF without the GUI
+- Spotlight has already extracted most PDFs' text: `mdls -name kMDItemTextContent ~/Downloads/receipt.pdf` returns the document text — search it for totals, invoice numbers, confirmation codes with `grep`.
+- Title metadata: `mdls -name kMDItemTitle -name kMDItemDisplayName file.pdf`.
+- When Spotlight has no text (unindexed or scanned image PDF), fall back to the GUI: focus Preview, select all and copy (`keyboard.press key=a modifiers=command`, then `key=c modifiers=command`), then read it with `pbpaste`.
+
+## Image operations — prefer sips over the GUI
+- Rotate the FILE directly: `sips -r 90 image.png` (90 = right/clockwise; use the GUI only if the user wants to see it happen: open in Preview, then Cmd+R rotates right, Cmd+L left).
+- Resize/convert: `sips -Z 800 image.png`, `sips -s format pdf image.png --out image.pdf`.
+
+## In-Preview actions (keyboard, after focusing Preview)
+- Rotate right/left: Cmd+R / Cmd+L. Select all text: Cmd+A. Copy selection: Cmd+C (then `pbpaste` to read it).
+- PDF form fields: press Tab to move to the first/next fillable field, then type with text.enter.
+- Export/Save As has no shortcut: use ax.observe on the menu bar (File → Export as PDF…) and click the menu items.
+
+## Verify
+- File-level edits: re-read with `mdls`/`stat`/`sips -g pixelWidth -g pixelHeight`. Clipboard copies: `pbpaste | head`. GUI actions: re-observe Preview.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/finder/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/finder/SKILL.md
new file mode 100644
index 00000000..64a38a1f
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/finder/SKILL.md
@@ -0,0 +1,30 @@
+# Finder
+
+id: finder
+description: File management the expert way — shell for finding and reading, Finder scripting for selection, reveal, and reversible trash instead of rm.
+tags: finder, files, folders, trash, local-app
+keywords: file, folder, move, copy, rename, trash, delete, reveal, selection, desktop, downloads
+apps: Finder, com.apple.finder
+tools: shell_exec, app_skill
+
+Almost everything Finder does is faster through shell_exec. Use Finder scripting for what only Finder knows (the user's current selection) and for deletions, where Finder's trash is reversible and `rm` is not.
+
+## Find and read
+- Locate files: `mdfind -name budget.xlsx`, `find ~/Documents -name '*.key' -mtime -7`.
+- Newest download: `ls -t ~/Downloads | head -1`.
+- What the user has selected in Finder: `osascript -e 'tell app "Finder" to get selection as alias list'`.
+
+## Move, copy, rename (asks for consent once)
+- `mkdir -p ~/Documents/Reports`, `mv ~/Downloads/report.pdf ~/Documents/Reports/`, `cp a.txt b.txt`.
+- Reveal the result so the user sees it: `open -R ~/Documents/Reports/report.pdf`.
+
+## Delete = trash, not rm
+- Prefer the reversible Finder trash: `osascript -e 'tell app "Finder" to delete POSIX file "/Users/me/old.txt"'`.
+- `rm` is destructive and asks every time; reach for it only when the user explicitly wants permanent deletion.
+- Emptying the trash is irreversible — always confirm with the user first.
+
+## Verify
+- After a move/copy/trash, confirm with a read: `ls ~/Documents/Reports`, `stat -f '%N' file`, or check the Trash: `ls ~/.Trash`.
+
+## GUI fallback
+- Drag-to-arrange, tagging UI, and preview interactions need the GUI: focus Finder, ax.observe, then click or mouse.drag observed items.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/imessage/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/imessage/SKILL.md
new file mode 100644
index 00000000..4448fe3b
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/imessage/SKILL.md
@@ -0,0 +1,23 @@
+# iMessage
+
+id: imessage
+description: Send iMessages through AppleScript only after explicit user confirmation; read conversations through the GUI, never the private database.
+tags: messages, imessage, chat, local-app
+keywords: message, imessage, text, sms, chat, send, conversation, reply
+apps: Messages, com.apple.MobileSMS
+tools: shell_exec, app_skill
+
+Messages can send through AppleScript, but sending a message is external and irreversible — it lands on someone else's phone. Reading is mostly a GUI job.
+
+## Sending requires confirmation
+- Before sending ANYTHING, confirm the exact recipient and the exact text with the user in this task (user.clarify), unless they already dictated both precisely.
+- Send to a phone/email over iMessage:
+ `osascript -e 'tell app "Messages" to send "On my way!" to participant "+15551234567" of (1st account whose service type is iMessage)'`.
+- Send into an existing named chat: get chats first (`osascript -e 'tell app "Messages" to get name of every chat'`), then `send "text" to chat "Name"`.
+
+## Reading conversations
+- AppleScript exposes very little message history. Read conversations through the GUI: focus Messages, ax.observe (the conversation list and transcript are accessible), scroll with mouse.scroll to load older messages.
+- Never read `~/Library/Messages/chat.db` directly — it is privacy-sensitive, needs Full Disk Access, and is not a supported path.
+
+## Verify
+- After sending, the GUI transcript shows the sent bubble: re-observe and confirm the text appears before completing.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/mail/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/mail/SKILL.md
new file mode 100644
index 00000000..f8d18a64
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/mail/SKILL.md
@@ -0,0 +1,45 @@
+# Mail
+
+id: mail
+description: Operate Apple Mail through AppleScript first — read inbox state, search, and compose — with the GUI as fallback and explicit confirmation before anything is sent.
+tags: mail, email, compose, inbox, local-app
+keywords: email, mail, inbox, unread, compose, send, reply, message, attachment, recipient
+apps: Mail, com.apple.mail
+tools: shell_exec, app_skill
+
+Mail is fully scriptable. Prefer one-line `osascript` through shell_exec over driving the GUI; click only for content AppleScript cannot reach (rendered message bodies, complex search UI).
+
+## Read state
+- Unread count: `osascript -e 'tell app "Mail" to get unread count of inbox'`.
+- Recent subjects: `osascript -e 'tell app "Mail" to get subject of messages 1 thru 5 of inbox'`.
+- Sender of the newest message: `osascript -e 'tell app "Mail" to get sender of message 1 of inbox'`.
+- A message's plain-text body: `osascript -e 'tell app "Mail" to get content of message 1 of inbox'` (long output is truncated; read specific messages, not whole mailboxes). Search the body for confirmation/tracking numbers with `grep` on the output.
+
+## Find messages
+- By subject: `osascript -e 'tell app "Mail" to get subject of (messages 1 thru 20 of inbox whose subject contains "receipt")'`. Always bound the range (`messages 1 thru 20`) — whose-queries over a whole mailbox are slow.
+- Unread only: `… whose read status is false`.
+- The newest match is the lowest index; act on `message N of inbox` by the index you found.
+
+## Attachments
+- List a message's attachments: `osascript -e 'tell app "Mail" to get name of mail attachments of message 1 of inbox'`.
+- Save one to Downloads (two steps in one line — the target file must name the attachment):
+ `osascript -e 'tell app "Mail" to save (mail attachment 1 of message 1 of inbox) in POSIX file ((POSIX path of (path to downloads folder)) & "report.pdf")'`
+- After saving, verify with `ls -t ~/Downloads | head -3`, then hand the file to shell/Preview steps (`open -a Preview …`, `mv … ~/Documents/Receipts/`).
+
+## Compose
+- Create a visible draft (safe, reversible — nothing is sent):
+ `osascript -e 'tell app "Mail" to make new outgoing message with properties {subject:"Subject", content:"Body", visible:true}'`.
+- Add a recipient to the draft:
+ `osascript -e 'tell app "Mail" to tell outgoing message 1 to make new to recipient with properties {address:"[email protected]"}'`.
+- Composing and leaving the draft open for the user to review is the default finish for "write an email" requests.
+
+## Sending is external and irreversible
+- Never send without the user's explicit confirmation of recipient and content in THIS task. Ask first (user.clarify), then `osascript -e 'tell app "Mail" to send outgoing message 1'`.
+- The same applies to replies and forwards.
+
+## Verify
+- After composing, confirm the draft exists: `osascript -e 'tell app "Mail" to get subject of outgoing messages'`.
+- After sending, the outgoing message disappears from `outgoing messages`.
+
+## GUI fallback
+- Search UI, message threading, and rendered HTML need the GUI: focus Mail, use ax.observe, and drive the search field (Cmd+Option+F focuses search).
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music-media/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music/SKILL.md
similarity index 99%
rename from apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music-media/SKILL.md
rename to apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music/SKILL.md
index 57adb106..10dd95df 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music-media/SKILL.md
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music/SKILL.md
@@ -1,5 +1,5 @@
-# Music Media
-id: music-media
+# Music
+id: music
description: Plan low-risk media playback in Apple Music or another supported media app.
tags: media, music, playback, local-app
keywords: play, listen, music, song, track, tune, album, playlist, artist, band, audio, podcast, radio, pause, resume, volume
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music-media/scripts/play-media-by-search.applescript b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music/scripts/play-media-by-search.applescript
similarity index 100%
rename from apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music-media/scripts/play-media-by-search.applescript
rename to apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/music/scripts/play-media-by-search.applescript
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes-writing/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes-writing/SKILL.md
deleted file mode 100644
index 30eebf81..00000000
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes-writing/SKILL.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Notes Writing
-id: notes-writing
-description: Plan writing finished text into a supported notes or text editor app.
-tags: notes, writing, text, local-app
-tools: app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand
-
-Use this skill for writing into a notes or text-editor app when the requested content is meaningful enough to type safely.
-
-Set `query` to the complete final text to type. Do not set `query` to a category label, a restatement of the request, or placeholder text from instructions. If the writing form is clear but details are sparse, compose a short finished piece that satisfies the requested form.
-
-If the requested object is malformed or nonsensical, choose conversation and ask for a clearer payload instead of opening the app.
-
-When planning generic `local_app_interaction`, use `goal=write requested text`, `inputEntity=query`, `controlID=editor`, and tools `app.openOrFocus`, `app.observe`, `ui.newDocument`, `ui.setText`, `app.verifyCommand`.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes/SKILL.md
new file mode 100644
index 00000000..3e22266f
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/notes/SKILL.md
@@ -0,0 +1,38 @@
+# Notes
+
+id: notes
+description: Create, find, and read Apple Notes through AppleScript — the destination step of most capture workflows — without driving the Notes GUI.
+tags: notes, writing, text, capture, local-app
+keywords: note, notes, save, write, jot, capture, checklist, remember
+apps: Notes, com.apple.Notes
+tools: shell_exec, app_skill
+
+Notes is fully scriptable; almost every "save … to Notes" step is one `osascript` line. Do not open the Notes GUI to create a note.
+
+## Create a note
+- `osascript -e 'tell app "Notes" to make new note with properties {name:"Title", body:"First line<br>Second line"}'`
+- The body is HTML: use `<br>` for line breaks, `<b>…</b>` for bold, `<ul><li>…</li></ul>` for lists.
+- Always give a concrete `name` — it is the note's title. Compose the full finished body yourself; never save placeholder text.
+- Escape any double quotes inside the text for the AppleScript string literal.
+
+## Putting computed values (date, battery, system state) in a note
+- Do this in two plain steps, not one fragile command. First READ each value with its own simple command (`date '+%Y-%m-%d'`, `pmset -g batt | grep -o '[0-9]*%' | head -1`, `df -h /`), look at the output, then create the note with those literal values pasted into the body.
+- Do NOT nest command substitutions (`$( … )`) inside the osascript string — the parentheses and quoting are error-prone and the parens also trip the safety classifier. Read first, then write the finished literal body.
+- Example: after `date '+%Y-%m-%d'` returns `2026-06-10` and the battery read returns `100%`, run `osascript -e 'tell app "Notes" to make new note with properties {name:"Status", body:"Date: 2026-06-10<br>Battery: 100%"}'`.
+
+## Find and read notes
+- Titles of recent notes: `osascript -e 'tell app "Notes" to get name of notes 1 thru 5'`.
+- Find by title: `osascript -e 'tell app "Notes" to get body of (note 1 whose name contains "Grocery")'` (body returns HTML).
+- Newest note: `osascript -e 'tell app "Notes" to get name of note 1'` (notes list is most-recent first).
+
+## Append to an existing note
+- `osascript -e 'tell app "Notes" to set body of (note 1 whose name contains "Grocery") to (body of (note 1 whose name contains "Grocery")) & "<br>- milk"'`
+
+## Show the result
+- After creating, reveal it so the user sees it: `osascript -e 'tell app "Notes" to show note 1'` (opens Notes on that note).
+
+## Verify
+- Re-read the created note's name/body and confirm the content landed before completing.
+
+## GUI fallback
+- Locked notes, drawings, and attachments inside notes need the GUI: focus Notes, ax.observe, and drive the visible list and editor.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/numbers/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/numbers/SKILL.md
new file mode 100644
index 00000000..a575ee42
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/numbers/SKILL.md
@@ -0,0 +1,34 @@
+# Numbers
+
+id: numbers
+description: Work with CSVs in the shell first; drive Numbers through AppleScript for opening, reading cells, and exporting PDFs.
+tags: spreadsheet, table, numbers, csv, local-app
+keywords: csv, spreadsheet, numbers, table, rows, columns, export, header, total
+apps: Numbers, com.apple.iWork.Numbers
+tools: shell_exec, app_skill
+
+A CSV is a text file — read, filter, and summarize it with shell tools before reaching for Numbers. Open Numbers only when the user wants the document itself (viewing, editing, exporting).
+
+## CSV in the shell (no app needed)
+- Header row: `head -1 ~/Downloads/data.csv`. First rows: `head -5 data.csv`.
+- Rows matching a term: `grep -i invoice data.csv`.
+- A column (e.g. 3rd): `awk -F, '{print $3}' data.csv | head`.
+- Newest CSV in Downloads: `ls -t ~/Downloads/*.csv | head -1`.
+
+## Open in Numbers
+- `open -a Numbers ~/Downloads/data.csv` — Numbers imports the CSV into a new document. `wait` ~2s for the import before observing or scripting.
+
+## Read and edit cells via AppleScript
+- Read a cell: `osascript -e 'tell app "Numbers" to get value of cell "B2" of table 1 of sheet 1 of front document'`.
+- Set a cell: `… to set value of cell "B2" of table 1 of sheet 1 of front document to "42"'`.
+- Row/column counts: `get row count of table 1 of sheet 1 of front document`.
+
+## Export as PDF
+- `osascript -e 'tell app "Numbers" to export front document to file ((path to desktop folder as text) & "data.pdf") as PDF'`
+- Verify the file exists afterwards: `ls -t ~/Desktop | head -3`.
+
+## Sorting and complex layout
+- Sorting rows and visual table work are GUI tasks: focus Numbers, ax.observe, and click the column header or use the Organize sidebar. For pure data questions, prefer `sort -t, -k<col>` on the CSV instead.
+
+## Verify
+- Shell answers verify themselves (the output IS the evidence). Numbers edits: re-read the cell. Exports: `ls` the target file.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/reminders/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/reminders/SKILL.md
new file mode 100644
index 00000000..941e079c
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/reminders/SKILL.md
@@ -0,0 +1,27 @@
+# Reminders
+
+id: reminders
+description: Create and read Apple Reminders through AppleScript — with due dates and alerts — without driving the Reminders GUI.
+tags: reminders, tasks, todo, local-app
+keywords: reminder, remind, task, todo, due, checklist, alert
+apps: Reminders, com.apple.reminders
+tools: shell_exec, app_skill
+
+Reminders is fully scriptable; creating a reminder is one `osascript` line. Creating reminders is reversible — act directly.
+
+## Create a reminder
+- Simple: `osascript -e 'tell app "Reminders" to make new reminder with properties {name:"Call Alex"}'`
+- With a due date/alert: build the date in pieces (locale-proof), then create:
+ `osascript -e 'set d to current date' -e 'set hours of d to 9' -e 'set minutes of d to 0' -e 'set d to d + 1 * days' -e 'tell app "Reminders" to make new reminder with properties {name:"Call Alex", remind me date:d}'`
+- Into a specific list: `tell app "Reminders" to tell list "Work" to make new reminder …`. List the lists first: `osascript -e 'tell app "Reminders" to get name of every list'`.
+- Several reminders (e.g. a checklist from a note): one `make new reminder` per item; keep each item's text as the reminder name.
+
+## Read reminders
+- Incomplete reminders in a list: `osascript -e 'tell app "Reminders" to get name of (reminders of list "Work" whose completed is false)'`. Always bound by list and completion state — unbounded queries over all reminders are slow.
+
+## Complete or delete
+- Mark done is reversible: `set completed of reminder "Call Alex" of list "Work" to true`.
+- Deleting a reminder asks the user first.
+
+## Verify
+- Re-read the list and confirm the new reminder's name (and date when set) before completing.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/safari/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/safari/SKILL.md
new file mode 100644
index 00000000..61e05f05
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/safari/SKILL.md
@@ -0,0 +1,40 @@
+# Safari
+
+id: safari
+description: Drive Safari through AppleScript — open, read, and manage tabs — falling back to AX/vision for in-page content and forms.
+tags: browser, safari, web, tabs, local-app
+keywords: browser, safari, web, url, tab, page, website, link, search, open
+apps: Safari, com.apple.Safari
+tools: shell_exec, app_skill
+
+Safari is scriptable for navigation and tab management; in-page reading and form filling usually need the GUI tools.
+
+## Navigate
+- Open a URL (new tab in front window): `open https://example.com`.
+- Navigate the current tab instead: `osascript -e 'tell app "Safari" to set URL of current tab of front window to "https://example.com"'`.
+- Web search: `open "https://www.google.com/search?q=swift+concurrency"` (URL-encode the query).
+
+## Read tab state
+- Current page: `osascript -e 'tell app "Safari" to get URL of current tab of front window'` and `…get name of current tab…` for the title.
+- All open tabs: `osascript -e 'tell app "Safari" to get name of every tab of front window'`.
+- Find a tab by site: get every tab's URL, then act on the matching index.
+
+## Manage tabs
+- Close the current tab: `osascript -e 'tell app "Safari" to close current tab of front window'`.
+- New window: `osascript -e 'tell app "Safari" to make new document'`.
+
+## Capture the page
+- Bookmark the current page: focus Safari and press Cmd+D, then return to accept the dialog.
+- Save the page as PDF: GUI only — File → Export as PDF… via ax.observe on the menu bar.
+- Screenshot the page to a file: `screencapture -x ~/Desktop/page.png` captures the screen (make Safari frontmost first); crop afterwards with `sips` if needed.
+- Save title + URL elsewhere: read both via AppleScript above, then hand them to the Notes skill or `pbcopy`.
+
+## History
+- Recent history has no supported scripting path (the History database is private). Use the GUI: Cmd+Y opens History, then observe and drive the list; or re-open a known URL directly.
+
+## In-page content and forms
+- `do JavaScript` is gated behind Safari's Develop menu setting; do not rely on it. Read page content and fill forms through the GUI: focus Safari, vision.capture or ax.observe, then click/type on observed elements.
+- Wait for pages to load before observing (`wait` 1–2s after navigation), and scroll (`mouse.scroll`) to reach content below the fold.
+
+## Verify
+- After navigation, re-read the current tab URL/title and confirm it matches the goal before completing.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/settings/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/settings/SKILL.md
new file mode 100644
index 00000000..774f155c
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/settings/SKILL.md
@@ -0,0 +1,41 @@
+# System Settings
+
+id: settings
+description: Change macOS settings with defaults/networksetup/osascript instead of clicking through System Settings; deep-link a pane only when the user must finish there.
+tags: settings, preferences, system, local-app
+keywords: settings, preferences, dark mode, wifi, bluetooth, sound, volume, display, dock, wallpaper, notifications
+apps: System Settings, System Preferences, com.apple.systempreferences
+tools: shell_exec, app_skill
+
+System Settings' GUI is slow to drive and its Accessibility tree is uneven. An expert changes settings from the command line; state-changing commands ask for one-time or always-allow consent, so propose them directly.
+
+## Read current state
+- `defaults read com.apple.dock autohide`, `defaults read NSGlobalDomain AppleInterfaceStyle` (errors when light mode).
+- macOS version: `sw_vers`. Storage: `df -h /`. Battery and charging state: `pmset -g batt`.
+- Pending software updates: `softwareupdate -l --no-scan` (fast, cached) or `softwareupdate -l` (slow scan — pass timeoutSeconds 60).
+- Network: `networksetup -getairportpower en0`, `networksetup -getinfo Wi-Fi`.
+- Bluetooth: `system_profiler SPBluetoothDataType` lists power state and connected devices.
+- Volume: `osascript -e 'output volume of (get volume settings)'`.
+- Low Power Mode state: `pmset -g | grep lowpowermode`.
+
+## Change settings
+- Dock: `defaults write com.apple.dock autohide -bool true` then `killall Dock` to apply.
+- Dark mode: `osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to true'`.
+- Volume: `osascript -e 'set volume output volume 40'`; mute: `osascript -e 'set volume with output muted'`.
+- Wi-Fi: `networksetup -setairportpower en0 off`.
+- Wallpaper: `osascript -e 'tell app "System Events" to set picture of every desktop to "/path/to/image.jpg"'`.
+- Low Power Mode: `pmset -a lowpowermode 1` (0 to turn off).
+- Many `defaults` changes need the owning process restarted (`killall Dock`, `killall Finder`, `killall SystemUIServer`) to take effect — include it.
+
+## Do Not Disturb / Focus
+- There is no supported command-line toggle for Focus modes. If the user has a Shortcuts shortcut that toggles a Focus, run it: `shortcuts run "Set Focus"` (list available ones with `shortcuts list`). Otherwise drive Control Center through the GUI (click the Control Center menu-bar item, then the Focus tile) — or tell the user it needs a one-time Shortcuts setup for reliable automation.
+
+## When only the GUI will do
+- Deep-link straight to a pane rather than navigating: `open "x-apple.systempreferences:com.apple.preference.security"` (Privacy & Security), `…com.apple.preference.notifications`, `…com.apple.preference.displays`.
+- Toggles that require user authentication (privacy permissions, FileVault, Touch ID) must be flipped by the user; open the right pane, tell them exactly what to click, and wait.
+
+## Boundaries
+- Privacy/TCC, security, login, and keychain settings are high-risk: every command asks, nothing is remembered. Never edit the TCC database.
+
+## Verify
+- Re-read the value you changed (`defaults read …`, `networksetup -get…`) and confirm the new value before completing.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spreadsheet-tables/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spreadsheet-tables/SKILL.md
deleted file mode 100644
index d5127db7..00000000
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spreadsheet-tables/SKILL.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Spreadsheet Tables
-id: spreadsheet-tables
-description: Plan creating compact tables in a supported spreadsheet app.
-tags: spreadsheet, table, numbers, local-app
-tools: app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand
-
-Use this skill for simple table or spreadsheet creation when a supported spreadsheet app is available.
-
-Set `query` to compact tab-separated table content, including a header row. If exact live data is unavailable, make a table-shaped brief with a data-needed note instead of a single sentence.
-
-When a table request needs fresh data from another local app before creating the final spreadsheet, keep the final destination app as `targetAppName` and record the source-to-destination sequence in `metadata.appChain` as a JSON string array of app names.
-
-When planning generic `local_app_interaction`, use `goal=create requested table`, `inputEntity=query`, `controlID=editor`, and tools `app.openOrFocus`, `app.observe`, `ui.newDocument`, `ui.setText`, `app.verifyCommand`.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
index 79c5776c..dbd20e9e 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
@@ -8,9 +8,19 @@ tools: shell_exec, apps_list
Use `shell_exec` as the first choice for anything an expert terminal user would do without touching the GUI. Read-only commands run immediately; state-changing ones ask the user for one-time or always-allow consent, so propose them directly rather than falling back to clicking. Keep each command to a single line.
+## Drive Mac apps with AppleScript, not URL schemes
+- To read or change content inside a Mac app — create a note, read mail, add a calendar event, look up a contact, get the current browser tab — drive the app with AppleScript: `osascript -e 'tell application "App" to …'`. Look the app's skill up first (`app_skill`) for the exact script.
+- NEVER invent an app URL scheme such as `notes://` or `mobilenotes://create?…` to do this. Those schemes are not registered on macOS and silently fail with "No application knows how to open URL".
+- Use `open` only to open files, folders, and web URLs, or to launch an app by name (`open -a "App"`). Not to manipulate an app's content.
+
+## Shell safety: zsh globs and parentheses
+- Commands run under `zsh`, where a filename glob that matches nothing ABORTS the whole command with `no matches found`. To find the newest file of several types, do NOT glob multiple extensions — list by time and filter with grep: `ls -t ~/Downloads | grep -iE '\.png$|\.jpg$|\.jpeg$|\.heic$|\.gif$' | head -1`.
+- Never read `no matches found` as "no such files exist" — it means the glob was too strict. Widen the search (the `ls | grep` form) and retry.
+- Keep parentheses out of commands. The safety classifier treats `(`/`)` (subshells, `find \( \)`, glob qualifiers like `(N)`) as separate commands and will prompt for approval on an otherwise read-only command. The `ls … | grep -iE` form above is parenthesis-free and runs instantly.
+
## Find and inspect files
- Spotlight search by name or content: `mdfind -name report.pdf`, `mdfind "kMDItemTextContent == '*invoice*'"`.
-- Newest / largest in a folder: `ls -t ~/Downloads/*.pdf | head -1`, `ls -S ~/Downloads | head`.
+- Newest of one type / largest in a folder: `ls -t ~/Downloads/*.pdf | head -1`, `ls -S ~/Downloads | head`. For several types at once, use the `ls … | grep -iE` form from Shell safety above.
- Walk a tree: `find ~/Documents -name '*.key' -mtime -7`.
- Read metadata or contents: `mdls file.pdf`, `stat -f '%Sm %N' file`, `cat file`, `head -50 file`.
@@ -32,6 +42,14 @@ Use `shell_exec` as the first choice for anything an expert terminal user would
- Wi-Fi power: `networksetup -setairportpower en0 off`.
- Clipboard: `pbcopy < file.txt`, `pbpaste`. Image convert/resize: `sips -Z 800 image.png`.
+## More expert one-liners
+- Open an address in Maps: `open "maps://?q=1%20Apple%20Park%20Way"` (URL-encode the address).
+- Screenshot to a file: `screencapture -x ~/Desktop/shot.png` (whole screen, no sound).
+- Top memory/CPU processes (instead of Activity Monitor): `ps aux -m | head -8`, `ps aux -r | head -8`.
+- Text file conversions: `textutil -convert pdf notes.rtf`, `textutil -convert txt page.html`.
+- Run a user Shortcuts shortcut: `shortcuts run "Name"`; list them: `shortcuts list`.
+- Text the screen selection: press Cmd+C first (keyboard.press key=c modifiers=command on the focused app), then read it with `pbpaste`.
+
## Boundaries
- Security- and privacy-sensitive changes (TCC/privacy, FileVault, login window, passwords, keychain) and destructive or privileged commands (`sudo`, `rm`, `dd`, piping into a shell) ask every time and are never remembered.
- Use the GUI (ax.observe / vision.capture and clicks) only when there is no system-tool equivalent — canvas, Electron, or proprietary interfaces.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather-lookup/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather/SKILL.md
similarity index 94%
rename from apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather-lookup/SKILL.md
rename to apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather/SKILL.md
index e041aee1..d3cdf162 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather-lookup/SKILL.md
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/weather/SKILL.md
@@ -1,5 +1,5 @@
-# Weather Lookup
-id: weather-lookup
+# Weather
+id: weather
description: Plan low-risk weather lookup workflows when a weather capability is provided.
tags: weather, lookup, local-app
tools: app.openOrFocus, app.observe, ui.focusSearch, ui.setText, ui.pressReturn, app.verifyVisibleText
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
index 6de90204..d14f6ecf 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
@@ -33,6 +33,35 @@ struct AppSkillCommandTests {
}
}
+ @Test
+ @MainActor
+ func discoversCorePlaybooksForHighTrafficApps() async {
+ // The built-in catalog covers the apps people actually drive daily, each
+ // matched by display name and bundle id from its `apps:` frontmatter.
+ let coverage: [(key: String, marker: String)] = [
+ ("Mail", "outgoing message"),
+ ("com.apple.mail", "mail attachment"),
+ ("Finder", "trash"),
+ ("Safari", "current tab"),
+ ("com.apple.Safari", "current tab"),
+ ("Calendar", "make new event"),
+ ("Messages", "iMessage"),
+ ("System Settings", "defaults write"),
+ ("Notes", "make new note"),
+ ("com.apple.Notes", "make new note"),
+ ("Reminders", "make new reminder"),
+ ("Preview", "kMDItemTextContent"),
+ ("Contacts", "formatted address"),
+ ("Numbers", "export front document"),
+ ("com.apple.iWork.Numbers", "export front document")
+ ]
+ for (key, marker) in coverage {
+ let result = await lookup(key)
+ #expect(result?.metadata["found"] == "true", "no skill found for \(key)")
+ #expect(result?.summary.contains(marker) == true, "playbook for \(key) is missing \(marker)")
+ }
+ }
+
@Test
@MainActor
func reportsMissingSkillsPlainly() async {
@@ -50,7 +79,7 @@ struct AppSkillCommandTests {
for key in ["Music", "Apple Music", "com.apple.Music"] {
let result = await lookup(key)
#expect(result?.metadata["found"] == "true")
- #expect(result?.metadata["skillID"] == "music-media")
+ #expect(result?.metadata["skillID"] == "music")
#expect(result?.metadata["scriptIDs"]?.contains("scripts-play-media-by-search") == true)
#expect(result?.summary.contains("skill_run") == true)
}
@@ -79,7 +108,7 @@ struct AppSkillCommandTests {
#expect(mismatched?.status == .failed)
#expect(mismatched?.metadata["reason"] == "skillScriptUnavailable")
- let unknown = await run(["skillID": "music-media", "scriptID": "no-such-script"])
+ let unknown = await run(["skillID": "music", "scriptID": "no-such-script"])
#expect(unknown?.status == .failed)
#expect(unknown?.metadata["reason"] == "skillScriptUnavailable")
}
diff --git a/docs/guides/authoring-skills.md b/docs/guides/authoring-skills.md
new file mode 100644
index 00000000..772d6972
--- /dev/null
+++ b/docs/guides/authoring-skills.md
@@ -0,0 +1,55 @@
+# Authoring Skills
+
+A skill is a folder with a `SKILL.md` that teaches the agent how to do something
+the way an expert would. The model reads the body; deterministic code reads the
+frontmatter. App-specific operating knowledge belongs here, never in prompts.
+
+Built-in skills live in
+`apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/<id>/SKILL.md`.
+Learned skills are written to the app-support learned directory and discovered
+the same way. The folder name is the skill id; keep it the clean app or
+capability name (`notes`, `mail`, `system-tools`), not a description.
+
+## Two kinds of skill
+
+**App skills** operate one Mac app. They carry an `apps:` line listing the app's
+display names and bundle ids. That line is how the runtime auto-matches and
+preloads the skill when a turn targets that app — match is on the typed app
+identity, never on the user's words. Name the skill after the app.
+
+**Other skills** are capabilities not tied to a single app (`system-tools` for
+the shell, `browser` for any browser, `weather`). They omit `apps:` and surface
+through search on their `tags`/`keywords` when a workflow needs them.
+
+## Frontmatter
+
+Lines the discovery parser reads (everything else is the playbook body):
+
+```text
+# Notes <- heading becomes the display name
+id: notes <- defaults to the folder name
+description: One line; used for ranking in search.
+tags: notes, writing <- comma-separated
+keywords: note, save, jot <- natural trigger words for lexical search
+apps: Notes, com.apple.Notes <- APP SKILLS ONLY: display names + bundle ids
+tools: shell_exec, app_skill <- tools the skill expects to use
+```
+
+## Body
+
+Write the operating playbook as an expert would brief a teammate: the reliable
+way to do the common tasks, the exact commands or AppleScript, the pitfalls, and
+how to verify. Prefer `shell_exec` with `osascript` over driving the GUI; reach
+for vision only when scripting can't. Keep commands single-line and
+parenthesis-free where possible (see `system-tools`). State boundaries — what
+must ask the user first (sending, deleting, purchases).
+
+## Scripts
+
+A skill may ship validated scripts in a `scripts/` subfolder — discovery picks
+them up from there automatically (no frontmatter line needed). The agent runs
+them with `skill_run` instead of reinventing the steps, so name and reference
+them in the body. Scripts must be bounded and deterministic.
+
+See existing packs under `BuiltInSkills/` for the shape — `notes` and `mail` for
+app skills, `system-tools` for an other-skill.