Skip to content

Open source CapCut alternative.

TypeScript

Add app-specific operating skills discovered by app name

David Le7900b0888649
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessSkillRegistry.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessSkillRegistry.swift
index 89f8ee54..2b6a3609 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessSkillRegistry.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessSkillRegistry.swift
@@ -331,7 +331,11 @@ public struct HarnessSkillFileSystemSource: Sendable {
"directory": directory.path,
// File-based discovery signal: natural trigger words for lexical skill matching
// (no embeddings). Comma-separated `keywords:` line in the SKILL.md frontmatter.
- "keywords": metadataList(named: "keywords", in: contents).joined(separator: " ")
+ "keywords": metadataList(named: "keywords", in: contents).joined(separator: " "),
+ // App-specific skills: comma-separated app names / bundle identifiers this skill knows
+ // how to operate (e.g. `apps: Spotify, com.spotify.client`). Lets the runtime fetch an
+ // app's operating playbook by name without hardcoding any app list in code.
+ "apps": metadataList(named: "apps", in: contents).joined(separator: ", ")
]
)
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
index c54ff858..3e70c744 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift
@@ -37,6 +37,34 @@ public enum BuiltInLocalAppSkillPacks {
.joined(separator: "\n")
}
+ /// Returns the operating playbook for an app-specific skill (one whose `apps:` frontmatter names
+ /// this app by display name or bundle identifier), or nil if no app-specific skill is installed.
+ /// This is how the runtime learns how to drive a particular app WITHOUT any hardcoded app list:
+ /// add a `BuiltInSkills/<app>/SKILL.md` with an `apps:` line and the guidance is discovered here.
+ public static func appOperatingGuidance(
+ forApp appName: String,
+ bundleIdentifier: String? = nil,
+ maxCharacters: Int = 4_000
+ ) -> String? {
+ let wanted = Set(
+ ([appName, bundleIdentifier].compactMap { $0 })
+ .map { $0.lowercased().trimmingCharacters(in: .whitespacesAndNewlines) }
+ .filter { !$0.isEmpty }
+ )
+ guard !wanted.isEmpty else { return nil }
+
+ let match = descriptors().first { descriptor in
+ let apps = (descriptor.metadata["apps"] ?? "")
+ .split(separator: ",")
+ .map { $0.lowercased().trimmingCharacters(in: .whitespacesAndNewlines) }
+ .filter { !$0.isEmpty }
+ return apps.contains { app in wanted.contains { $0 == app || $0.contains(app) || app.contains($0) } }
+ }
+ guard let match else { return nil }
+ let body = bounded(strippedSkillMetadata(from: match.description), maxCharacters: maxCharacters)
+ return body.isEmpty ? nil : body
+ }
+
public static func scriptSource(
skillID: String,
relativePath: String
@@ -66,6 +94,8 @@ public enum BuiltInLocalAppSkillPacks {
&& !lowered.hasPrefix("description:")
&& !lowered.hasPrefix("tags:")
&& !lowered.hasPrefix("keywords:")
+ && !lowered.hasPrefix("apps:")
+ && !lowered.hasPrefix("scripts:")
&& !lowered.hasPrefix("tools:")
}
.joined(separator: "\n")
@@ -131,7 +161,11 @@ public struct LocalAppTaskSkillContext: Equatable, Sendable {
taskDefinitions: [LocalAppTaskDefinition],
appFinderCatalog: [LocalAppFinderCatalogEntry]
) -> [(descriptor: HarnessSkillDescriptor, score: Int)] {
+ // App-specific operating skills (those declaring `apps:`) are vision-driving playbooks
+ // consumed only via `appOperatingGuidance(forApp:)` during execution — they are not
+ // intent-planning skills, so keep them out of the planner's skill catalog/ranking.
let descriptors = BuiltInLocalAppSkillPacks.descriptors()
+ .filter { ($0.metadata["apps"] ?? "").trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }
guard !descriptors.isEmpty else { return [] }
var taskValues: [String] = []
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spotify/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spotify/SKILL.md
new file mode 100644
index 00000000..62c54710
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/spotify/SKILL.md
@@ -0,0 +1,35 @@
+# Spotify
+
+id: spotify-operate
+description: Operate the Spotify desktop app by vision to search for and play music.
+tags: media, music, playback, spotify, electron, vision
+keywords: spotify, play, listen, music, song, track, album, playlist, artist, band
+apps: Spotify, com.spotify.client
+
+Spotify is an Electron app, so accessibility and AppleScript expose almost no useful controls — drive it by VISION (look at the screenshot and click). This skill is the operating playbook the per-turn vision driver follows; it describes WHERE things are conceptually, never fixed pixel coordinates (the window can be any size — always read the current screenshot).
+
+## Layout you will see
+
+- Top center: a search field with placeholder text like "What do you want to play?". Click it to focus, then type.
+- Left: "Your Library" sidebar with recent items.
+- Main area: the current page (artist page, search results, etc.). An artist page shows the artist name, a large round green Play button, and a "Popular" list of songs numbered 1, 2, 3…
+- Bottom: the persistent PLAYBACK BAR spanning the whole window. Its center holds the transport controls: shuffle, previous, the round PLAY/PAUSE button, next, repeat. The currently loaded track (name + artist) shows at the far bottom-left, with a progress time like "0:05 / 4:26".
+
+## How to play an artist's music
+
+1. Click the top search field, then `type` the artist or song name, then `key` "return" to submit.
+2. On the results/artist page, click the artist (or the specific song row) to open it.
+3. Start playback. The most reliable control is the round PLAY button in the bottom playback bar (it is centered HORIZONTALLY in the window and centered VERTICALLY within the bar — it is NOT at the very bottom edge of the window; aim for the middle of the bar, not its bottom pixel row). The large green button on an artist page also works and plays the artist's top song.
+
+## Reading playback state (critical — do not toggle music off)
+
+The bottom transport button is a PLAY/PAUSE toggle, so its icon tells you the current state:
+
+- ▶ TRIANGLE icon = PAUSED/STOPPED. The progress time is frozen (e.g. stuck at 0:05). Music is NOT playing — click it to start.
+- ⏸ TWO VERTICAL BARS icon = PLAYING right now. Also, a small green animated equalizer bars icon appears next to the playing track. Only when you see ⏸ (or the track time is advancing) is the goal met — stop and report done.
+
+Never click the transport button while it shows ⏸; that pauses the music. Only emit "done" once the screenshot shows the ⏸ icon or a clearly advancing track time.
+
+## If a click does not change anything
+
+If you clicked a control and the next screenshot looks identical (same ▶ icon, same frozen time), your click MISSED the target — do not repeat the exact same coordinate. Re-locate the button in the new screenshot and aim for its precise visual center; for the bottom transport button, move your aim UP into the middle of the playback bar rather than toward the window's bottom edge.