Open source CapCut alternative.
TypeScript
test(app): add prompt + functional evals for the book skill
David Le50d4fb0b973c
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/expect.json b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/expect.jsonnew file mode 100644index 00000000..22ea366f--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/expect.json@@ -0,0 +1,8 @@+{+ "frontmostApp": "Finder",+ "maxSteps": 40,+ "expectProduced": [+ { "kind": "fileExists", "extension": "pdf" },+ { "kind": "epubValid" }+ ]+}diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3001.jpg b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3001.jpgnew file mode 100644index 00000000..07d83928Binary files /dev/null and b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3001.jpg differdiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3002.jpg b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3002.jpgnew file mode 100644index 00000000..07d83928Binary files /dev/null and b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3002.jpg differdiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3003.jpg b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3003.jpgnew file mode 100644index 00000000..07d83928Binary files /dev/null and b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/inputs/IMG_3003.jpg differdiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/prompt.txt b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/prompt.txtnew file mode 100644index 00000000..2f35d537--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/FunctionalEval/comic-book-epub/prompt.txt@@ -0,0 +1 @@+In the folder {DIR} there are three photos (IMG_3001.jpg, IMG_3002.jpg, IMG_3003.jpg) of a dad and his young son learning to swim. Make a short comic book from them — a cover plus one page per photo with a short caption — and save BOTH a PDF and an EPUB of the book into {DIR}. Just save the two files; do not open them in any app.diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/prompt.txt b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/prompt.txtnew file mode 100644index 00000000..3e7f7557--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/prompt.txt@@ -0,0 +1 @@+make a comic book about me and my son learning to swim from the photos in ~/Pictures/swim, then put it in Apple Booksdiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/scenario.json b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/scenario.jsonnew file mode 100644index 00000000..49da223f--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/Fixtures/HarnessEval/comic-book-from-photos/scenario.json@@ -0,0 +1,25 @@+{+ "frontmostApp": "Finder",+ "maxSteps": 40,+ "disk": [+ { "path": "~/Pictures/swim", "describe": "Folder of 3 JPEG photos (4032x3024, ~5MB each) of a father and young son at a pool." },+ { "path": "~/Pictures/swim/IMG_3001.jpg", "describe": "JPEG, 4032x3024 — dad and son at the pool edge." },+ { "path": "~/Pictures/swim/IMG_3002.jpg", "describe": "JPEG, 4032x3024 — first float, dad supporting." },+ { "path": "~/Pictures/swim/IMG_3003.jpg", "describe": "JPEG, 4032x3024 — high-five at the finish." }+ ],+ "responses": [+ { "tool": "files.describe", "summary": "~/Pictures/swim — 8 JPEG photos, 4032x3024, a dad and son learning to swim across a session." },+ { "tool": "llm.generate", "summary": "Drafted the story arc and one caption + a line of speech-bubble text per page, plus a title: \"Swim Day\"." },+ { "tool": "shell_exec", "contains": ["sips"], "summary": "Downscaled the 8 photos into pages/img at 1600px wide." },+ { "tool": "files.write", "summary": "Wrote a page XHTML into the workspace pages/ folder." },+ { "tool": "image_render", "contains": ["pdf"], "summary": "Rendered a page to a one-page PDF in pdf/." },+ { "tool": "shell_exec", "contains": ["qpdf"], "summary": "Merged the page PDFs into book.pdf.", "produces": ["book.pdf"] },+ { "tool": "shell_exec", "contains": ["epub-pack", "build"], "summary": "Built book.epub (pageCount 9).", "produces": ["book.epub"] },+ { "tool": "shell_exec", "contains": ["epub-pack", "validate"], "summary": "{\"valid\":true}." },+ { "tool": "shell_exec", "contains": ["open"], "summary": "Apple Books came forward and imported the book." }+ ],+ "expect": {+ "turnKind": "act",+ "skills": ["book"]+ }+}diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalFixture.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalFixture.swiftindex b3ed4286..1871a152 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalFixture.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalFixture.swift@@ -54,7 +54,15 @@ struct FunctionalEvalFixture: Sendable, CustomStringConvertible {at: root,includingPropertiesForKeys: [.isDirectoryKey])) ?? []- return dirs.compactMap(load).sorted { $0.name < $1.name }+ var fixtures = dirs.compactMap(load).sorted { $0.name < $1.name }+ // Optional single-fixture focus: `DONKEY_EVAL_ONLY=comic-book-epub` runs just the fixtures whose name+ // contains that substring — the same knob the prompt eval honors, so one expensive real-execution+ // scenario can be run alone. Empty/unset runs everything.+ if let only = ProcessInfo.processInfo.environment["DONKEY_EVAL_ONLY"]?+ .trimmingCharacters(in: .whitespacesAndNewlines), !only.isEmpty {+ fixtures = fixtures.filter { $0.name.localizedCaseInsensitiveContains(only) }+ }+ return fixtures}static func load(_ dir: URL) -> FunctionalEvalFixture? {diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalVerifier.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalVerifier.swiftindex 4dad71f0..4babcc0f 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalVerifier.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/FunctionalEval/FunctionalEvalVerifier.swift@@ -24,6 +24,8 @@ enum FunctionalEvalVerifier {return jsonMinRecords(check.minRecords, producedFiles: producedFiles, sandbox: sandbox)case "fileExists":return fileExists(extension: check.ext, producedFiles: producedFiles)+ case "epubValid":+ return epubValid(producedFiles: producedFiles, sandbox: sandbox)default:return Outcome(ok: false, detail: "unknown check kind '\(check.kind)'")}@@ -83,6 +85,18 @@ enum FunctionalEvalVerifier {return Outcome(ok: ok, detail: "expected a produced JSON with ≥\(minRecords) records; produced json lengths: \(counts)")}+ /// A produced `.epub` must exist and pass `epub-pack validate` (mimetype first/stored, container + OPF+ /// present) — the real structural check the same bundled tool the agent used can run.+ private static func epubValid(producedFiles: [URL], sandbox: URL) -> Outcome {+ let epubs = producedFiles.filter { $0.pathExtension.lowercased() == "epub" }+ if epubs.isEmpty {+ return Outcome(ok: false, detail: "expected a produced .epub; produced: \(producedFiles.map(\.lastPathComponent))")+ }+ let results = epubs.map { ShellHelper.run("epub-pack validate \(quoted($0))", in: sandbox) }+ let ok = results.contains { $0.contains("\"valid\" : true") || $0.contains("\"valid\":true") }+ return Outcome(ok: ok, detail: "expected a produced .epub that passes `epub-pack validate`; results: \(results)")+ }+private static func fileExists(extension ext: String?, producedFiles: [URL]) -> Outcome {guard let ext else { return Outcome(ok: false, detail: "fileExists missing `extension`") }let matches = producedFiles.filter { $0.pathExtension.lowercased() == ext.lowercased() }diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swiftindex 22645d38..059b49ac 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift@@ -51,6 +51,10 @@ struct ShellCommandClassifierTests {#expect(tier("ffprobe -v error -show_entries format=duration -of csv=p=0 out.mp4") == .read)#expect(tier("qpdf --decrypt in.pdf out.pdf") == .read)#expect(tier("exiftool -all= photo.jpg") == .read)+ // epub-pack writes the .epub for the book skill — bundled and first-party, so building one+ // must not raise an Approve/Deny gate.+ #expect(tier("epub-pack build ./pages --meta book.json -o book.epub") == .read)+ #expect(tier("epub-pack validate book.epub") == .read)// A path-qualified invocation normalizes to the bare tool name and is still trusted.#expect(tier("/opt/donkey-tools/yt-dlp -P ~/Downloads 'https://youtu.be/x'") == .read)// The real install path lives under "Application Support" — a space inside a quoted executable