Open source CapCut alternative.
TypeScript
Add json theme
David Le54f973707899
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swiftindex a4445fc8..515ce144 100644--- a/apps/Donkey/Package.swift+++ b/apps/Donkey/Package.swift@@ -40,6 +40,9 @@ let package = Package("DonkeyContracts","DonkeyRuntime","DonkeyUI"+ ],+ resources: [+ .copy("Resources/theme.json")])]diff --git a/apps/Donkey/README.md b/apps/Donkey/README.mdindex 80c2724a..3d9af671 100644--- a/apps/Donkey/README.md+++ b/apps/Donkey/README.md@@ -16,7 +16,9 @@ swift buildswift run Donkey```-Customize the pointer accent color with a six-digit hex value:+Customize the pointer colors in [Sources/Donkey/Resources/theme.json](Sources/Donkey/Resources/theme.json). The app supports `#RRGGBB` and `rgba(r, g, b, a)` color strings.++For one-off local runs, the accent can also be overridden with a six-digit hex value:```shDONKEY_POINTER_ACCENT=0A84FF swift run Donkeydiff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swiftindex 6afcdcf3..e0968c93 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift@@ -61,25 +61,30 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkprivate static func configuredTheme() -> PointerPromptTheme {guard let hexColor = ProcessInfo.processInfo.environment["DONKEY_POINTER_ACCENT"],let color = PointerPromptColor(hexRGB: hexColor) else {- return .defaultBlue+ return bundledTheme()}return .accent(color)}++ private static func bundledTheme() -> PointerPromptTheme {+ guard let themeURL = Bundle.module.url(forResource: "theme", withExtension: "json"),+ let themeData = try? Data(contentsOf: themeURL),+ let themeConfig = try? JSONDecoder().decode(PointerPromptThemeConfig.self, from: themeData),+ let theme = PointerPromptTheme.fromConfig(themeConfig) else {+ return .defaultBlue+ }++ return theme+ }}private extension PointerPromptColor {init?(hexRGB: String) {- let trimmed = hexRGB.trimmingCharacters(in: CharacterSet(charactersIn: "# "))- guard trimmed.count == 6, let value = Int(trimmed, radix: 16) else {+ guard let color = PointerPromptColor(cssString: hexRGB) else {return nil}- self.init(- red: Double((value >> 16) & 0xFF) / 255.0,- green: Double((value >> 8) & 0xFF) / 255.0,- blue: Double(value & 0xFF) / 255.0,- alpha: 1- )+ self = color}}diff --git a/apps/Donkey/Sources/Donkey/Resources/theme.json b/apps/Donkey/Sources/Donkey/Resources/theme.jsonnew file mode 100644index 00000000..b7cad6f7--- /dev/null+++ b/apps/Donkey/Sources/Donkey/Resources/theme.json@@ -0,0 +1,6 @@+{+ "accent": "#0D6ED9",+ "fill": "#E0F0FF",+ "pointerFill": "#D1EDFF",+ "activeShadow": "rgba(0, 36, 82, 0.26)"+}diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swiftindex 018651df..9bf06b53 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift@@ -53,6 +53,20 @@ public struct PointerPromptTheme: Equatable, Sendable {activeShadow: PointerPromptColor(red: 0.0, green: 0.14, blue: 0.32, alpha: 0.26))+ public static func fromConfig(_ config: PointerPromptThemeConfig) -> PointerPromptTheme? {+ guard let accent = PointerPromptColor(cssString: config.accent) else {+ return nil+ }++ let baseTheme = PointerPromptTheme.accent(accent)+ return PointerPromptTheme(+ accent: accent,+ fill: PointerPromptColor(cssString: config.fill) ?? baseTheme.fill,+ pointerFill: PointerPromptColor(cssString: config.pointerFill) ?? baseTheme.pointerFill,+ activeShadow: PointerPromptColor(cssString: config.activeShadow) ?? baseTheme.activeShadow+ )+ }+public static func accent(_ accent: PointerPromptColor) -> PointerPromptTheme {PointerPromptTheme(accent: accent,@@ -68,6 +82,25 @@ public struct PointerPromptTheme: Equatable, Sendable {}}+public struct PointerPromptThemeConfig: Codable, Equatable, Sendable {+ public var accent: String+ public var fill: String?+ public var pointerFill: String?+ public var activeShadow: String?++ public init(+ accent: String,+ fill: String? = nil,+ pointerFill: String? = nil,+ activeShadow: String? = nil+ ) {+ self.accent = accent+ self.fill = fill+ self.pointerFill = pointerFill+ self.activeShadow = activeShadow+ }+}+public struct PointerPromptColor: Equatable, Sendable {public var red: Doublepublic var green: Double@@ -83,6 +116,47 @@ public struct PointerPromptColor: Equatable, Sendable {public static let white = PointerPromptColor(red: 1, green: 1, blue: 1, alpha: 1)+ public init?(cssString: String?) {+ guard let cssString else { return nil }++ let trimmed = cssString.trimmingCharacters(in: .whitespacesAndNewlines)+ if trimmed.lowercased().hasPrefix("rgba("), trimmed.hasSuffix(")") {+ let rawValues = trimmed+ .dropFirst(5)+ .dropLast()+ .split(separator: ",")+ .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }++ guard rawValues.count == 4,+ let red = Double(rawValues[0]),+ let green = Double(rawValues[1]),+ let blue = Double(rawValues[2]),+ let alpha = Double(rawValues[3]) else {+ return nil+ }++ self.init(+ red: red / 255.0,+ green: green / 255.0,+ blue: blue / 255.0,+ alpha: alpha+ )+ return+ }++ let hex = trimmed.trimmingCharacters(in: CharacterSet(charactersIn: "#"))+ guard hex.count == 6, let value = Int(hex, radix: 16) else {+ return nil+ }++ self.init(+ red: Double((value >> 16) & 0xFF) / 255.0,+ green: Double((value >> 8) & 0xFF) / 255.0,+ blue: Double(value & 0xFF) / 255.0,+ alpha: 1+ )+ }+public func mixed(with other: PointerPromptColor,accentWeight: Double,diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.mdindex 9abb3cc3..d2fdddb6 100644--- a/docs/guides/pointer-prompt-overlay.md+++ b/docs/guides/pointer-prompt-overlay.md@@ -12,7 +12,7 @@ Donkey supports a floating macOS pointer prompt overlay:- flips to the left, top, or top-left side when the default position would leave the screen- animates side changes along an invisible box around the user pointer- renders a shadow underneath the agent pointer when active-- supports accent-color customization through `DONKEY_POINTER_ACCENT`+- supports user-accessible theme customization through `apps/Donkey/Sources/Donkey/Resources/theme.json`- keeps runtime and AI harness behavior behind explicit integration boundariesThis is a visual UI capability. It does not capture the screen, send input, call models, or require Accessibility permission.@@ -24,7 +24,7 @@ This is a visual UI capability. It does not capture the screen, send input, call- Product state stays in `PointerPromptOverlayModel`.- Treat the composer like a ChatGPT input box: one surface can contain typed text, submission, and adjacent controls.- Composer controls should emit typed `PointerPromptIntent` values instead of reaching into runtime, AI, or controller code.-- Pointer colors live in `PointerPromptTheme`; views must not hard-code product colors.+- Pointer colors load from JSON into `PointerPromptTheme`; views must not hard-code product colors.- Placement is one of `bottomRight`, `bottomLeft`, `topLeft`, or `topRight`.- The controller must clamp the final panel frame to `NSScreen.visibleFrame` before applying it.- Diagonal placement changes should route through a side placement first, so bottom-right overflow can animate to left and then top-left.@@ -42,7 +42,7 @@ swift run DonkeyCommand-click anywhere and confirm the composer appears with keyboard focus. Type a message, confirm the send control enables, and move the mouse near the bottom-right screen edge to confirm the prompt moves left, then top-left if needed, without clipping off screen.-To verify color customization:+To verify color customization, edit `apps/Donkey/Sources/Donkey/Resources/theme.json`, rebuild, and run Donkey. For one-off local runs, the accent can also be overridden:```shDONKEY_POINTER_ACCENT=FF375F swift run Donkey