Open source CapCut alternative.
TypeScript
feat(app): group each step into one thread-transcript block and pin installed drive targets
David Le4ecad92699ac
diff --git a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swiftindex a5447fe0..49e075ed 100644--- a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift@@ -316,9 +316,9 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {progress?(restated)}- // Drive the understood target app when it names one that resolves to a running window; else the- // frontmost app. resolveTarget never falls back to an unrelated window, so a miss keeps us on- // the frontmost app and the planner can app.openOrFocus the target itself.+ // Drive the understood target app whenever it names a running or installed app; else the+ // frontmost app. An installed-but-not-running target stays pinned by name — the see/act tools+ // re-resolve its window each call, so it works as soon as the planner launches it.let driveTarget = Self.resolveDriveTarget(understanding: understanding,frontmostAppName: frontmostAppName,@@ -378,9 +378,14 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {analyzer: analyzer)let pointerProvider = PointerComputerUseToolProvider(appName: appName, bundleIdentifier: bundleIdentifier)- // Register the AX/vision/pointer see/act tools only when this turn holds their permissions,- // mirroring the built-in descriptor filter so the planner is never offered a tool it can't run.+ // Native music playback (MusicKit): search/play/transport/status with no Music-app GUI or+ // AppleScript. Declares no harness permissions — MusicKit runs its own consent flow.+ let musicProvider = MusicPlaybackToolProvider(service: MusicKitPlaybackService())+ // Register the AX/vision/pointer/music see/act tools only when this turn holds their+ // permissions, mirroring the built-in descriptor filter so the planner is never offered a+ // tool it can't run.for tool in axProvider.makeTools() + visionProvider.makeTools() + pointerProvider.makeTools()+ + musicProvider.makeTools()where Set(tool.descriptor.requiredPermissions).isSubset(of: granted) {await registry.register(tool)}@@ -422,17 +427,17 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {let transcript = ThreadTranscript(id: taskID)transcript.begin(id: taskID, app: appName)transcript.userMessage(command)- // The thread is the COMPLETE session record: the parsed understanding (or its absence) is part- // of the conversation, not just an internal step.+ // The thread is the COMPLETE session record: the turn's upfront planning (or its absence) is+ // part of the conversation, not just an internal step. A follow-up turn (clarification+ // answer, permission grant) appends its own planning block mid-thread.if let understanding {- var understood = "Understood request: \(understanding.restatedGoal)"- if let app = understanding.targetAppName, !app.isEmpty {- understood += " · target app: \(app)"- }- if understanding.needsClarification, let question = understanding.clarifyingQuestion, !question.isEmpty {- understood += " · needs clarification: \(question)"- }- transcript.systemEvent(understood)+ transcript.planning(+ goal: understanding.restatedGoal,+ targetApp: understanding.targetAppName,+ parameters: understanding.parameters,+ successCriteria: understanding.successCriteria,+ clarification: understanding.needsClarification ? understanding.clarifyingQuestion : nil+ )} else {transcript.systemEvent("Understanding was unavailable (timed out or failed); driving the raw command.")}@@ -443,18 +448,29 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {let onStep: (@Sendable (HarnessStepExecutionResult) async -> Void)? = { (step: HarnessStepExecutionResult) async -> Void inawait MainActor.run {let narration = Self.stepNarration(for: step, planner: planner)- // Planning failures (unusable replies, retries) are part of the session and must be- // readable in the thread — a step that ends in run.failSafe is otherwise a mystery.- for planningError in planner.lastPlanningErrors {- transcript.error(planningError)- }if let result = step.toolResult {- // The thread file gets the model's full thought summary (when thinking is on);- // the overlay/progress gets only the clipped one-line narration below. The full- // reasoning is persisted here and nowhere else, so the planning context stays bounded.- transcript.thinking(planner.lastThinking ?? narration)- transcript.toolCall(tool: result.toolName, input: step.task.toolHistory.last?.call.input ?? [:])- transcript.toolResult(tool: result.toolName, status: result.status.rawValue, output: result.summary)+ // One grouped block per step: the model's full thought summary (persisted here+ // and nowhere else, so the planning context stays bounded), its one-line reason,+ // the action with its input, and the output — plus any planning retries hit+ // while choosing this step, so a step that needed recovery reads as one unit.+ // The overlay/progress gets only the clipped one-line narration below.+ transcript.step(+ number: step.task.toolHistory.count,+ thought: planner.lastThinking,+ reason: planner.lastNarration,+ tool: result.toolName,+ input: step.task.toolHistory.last?.call.input ?? [:],+ status: result.status.rawValue,+ output: result.summary,+ planningErrors: planner.lastPlanningErrors+ )+ } else {+ // No tool executed (the call never ran), but planning failures are still part of+ // the session and must be readable in the thread — a step that ends in+ // run.failSafe is otherwise a mystery.+ for planningError in planner.lastPlanningErrors {+ transcript.error(planningError)+ }}// Every step narrates through the spawn label (a lightweight text update), so the user// is kept informed even on steps that don't move the pointer — observe, shell, wait,@@ -817,31 +833,46 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {]}- /// Picks the app the harness drive operates: the understood target app when it names one that- /// resolves to a running window, otherwise the frontmost app. `AccessibilityObserver.resolveTarget`- /// only ever returns the named app's window (never an unrelated frontmost one), so a non-running or- /// misnamed target safely falls back to the frontmost app.+ /// Picks the app the harness drive operates. The understood target app wins whenever it names a+ /// real app: a running window resolves to its exact name and bundle id, and an installed-but-not-+ /// running app is still pinned by name — the see/act providers re-resolve the target window on+ /// every call, so the target starts working the moment the planner launches it. Pinning to the+ /// frontmost app instead aims every observe/click (and the focus guard's recovery activation) at+ /// an unrelated window for the whole run, and preloads the wrong app's guidance. Only a name that+ /// matches nothing running and nothing installed falls back to the frontmost app.@MainActor- private static func resolveDriveTarget(+ static func resolveDriveTarget(understanding: HarnessRequestUnderstanding?,frontmostAppName: String,- frontmostBundleIdentifier: String?+ frontmostBundleIdentifier: String?,+ resolveRunningWindow: (String) -> (appName: String?, bundleIdentifier: String?)? = { requested in+ AccessibilityObserver.resolveTarget(appName: requested, bundleIdentifier: nil)+ .map { ($0.appName, $0.bundleIdentifier) }+ },+ resolveInstalledBundle: (String) -> URL? = { requested in+ MacAppScriptabilityProbe().bundleURL(bundleIdentifier: nil, appName: requested)+ }) -> (appName: String, bundleIdentifier: String?) {guard let requested = understanding?.targetAppName,!requested.isEmpty,- requested.caseInsensitiveCompare(frontmostAppName) != .orderedSame,- let resolved = AccessibilityObserver.resolveTarget(appName: requested, bundleIdentifier: nil)+ requested.caseInsensitiveCompare(frontmostAppName) != .orderedSameelse {return (frontmostAppName, frontmostBundleIdentifier)}- return (resolved.appName ?? requested, resolved.bundleIdentifier)+ if let resolved = resolveRunningWindow(requested) {+ return (resolved.appName ?? requested, resolved.bundleIdentifier)+ }+ if let bundleURL = resolveInstalledBundle(requested) {+ return (requested, Bundle(url: bundleURL)?.bundleIdentifier)+ }+ return (frontmostAppName, frontmostBundleIdentifier)}/// A compact, one-line-per-skill catalog of every installed app skill — id, description, the apps it/// covers, and any validated `skill_run` scripts — surfaced to the planner each step. App-specific/// guidance is only preloaded for the resolved GUI drive target, so without this the planner never- /// learns that a script-driven skill (e.g. Music playback, Notes capture) exists when the task has no- /// GUI target app — and it improvises fragile commands instead of running the validated script.+ /// learns that a skill owns a domain (e.g. native music playback, Notes capture by script) when the+ /// task has no GUI target app — and it improvises fragile commands instead of following the skill./// Lists every skill unconditionally; the planner does the routing, so no intent is matched here.private static func installedSkillCatalog() -> String? {let skills = BuiltInLocalAppSkillPacks.descriptors().sorted { $0.id < $1.id }diff --git a/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift b/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swiftindex a260aecc..2a4b520a 100644--- a/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift@@ -1,9 +1,10 @@import Foundation/// The canonical, human-readable record of a thread — the real conversation, the way ChatGPT or-/// Claude keeps one, not a debug dump. Every turn is captured with who said it and what kind of-/// message it is (a user request, the assistant thinking, a tool call, a tool result, the assistant's-/// answer), so you can read the whole reasoning trace and, later, render it to the user.+/// Claude keeps one, not a debug dump. The user's request, session events, and the assistant's+/// answer are flat entries; each executed step is one grouped block (the decision — thought, reason,+/// action with its input — then that action's output), so the whole reasoning trace reads+/// decision → output → next decision.////// Durable metadata stays in Core Data; the *contents* live here in markdown, one folder per thread/// under `~/Library/Application Support/Donkey/Threads/<id>/`:@@ -11,20 +12,16 @@ import Foundation/// - `thread.md` — the full conversation, appended live (`tail -f` to watch it unfold)./// - `summary.md` — a compacted, structured summary of the thread.public final class ThreadTranscript: @unchecked Sendable {- /// Who an entry is from.+ /// Who a flat entry is from.public enum Role: String, Sendable {case usercase assistant- case toolcase system}- /// What kind of message it is.+ /// What kind of flat (non-step) entry it is. Executed steps render through `step(...)` instead.public enum Kind: String, Sendable {case message // a plain user/system message- case thinking // the assistant's reasoning for the next move- case toolCall // the assistant invoking a tool- case toolResult // a tool's outputcase response // the assistant's answer to the usercase event // a session lifecycle event (understanding parsed, run finished, …)case error // something the session hit that wasn't a tool result (planner retry, aborted start, …)@@ -70,27 +67,70 @@ public final class ThreadTranscript: @unchecked Sendable {appendEntry(role: .user, kind: .message, title: nil, body: text, fenced: false)}- /// The assistant's reasoning before a tool call — the model's thought summary when thinking is on,- /// otherwise the one-line rationale. Bounded so a verbose chain of thought can't bloat the thread- /// file; the full reasoning lives only here, never in the per-step planning prompt.- public func thinking(_ text: String?) {- guard let text = text?.trimmingCharacters(in: .whitespacesAndNewlines), !text.isEmpty else { return }- appendEntry(role: .assistant, kind: .thinking, title: nil, body: Self.clip(text, 4_000), fenced: false)- }-- /// The assistant invoking a tool, with its input.- public func toolCall(tool: String, input: [String: String]) {- let body = input.isEmpty- ? "(no input)"- : input.sorted { $0.key < $1.key }- .map { "\($0.key): \(Self.clip($0.value, 600))" }- .joined(separator: "\n")- appendEntry(role: .assistant, kind: .toolCall, title: tool, body: body, fenced: true)+ /// The turn's upfront planning — the parsed understanding that anchors the run: the restated+ /// goal, the target app, the extracted parameters, the success criteria, and any clarification+ /// it decided to ask. Rendered as its own block at the start of every turn, so it appears at the+ /// beginning of the thread and again mid-thread when a clarification answer or permission grant+ /// opens a follow-up turn. Empty fields are omitted rather than printed as blank labels.+ public func planning(+ goal: String,+ targetApp: String? = nil,+ parameters: [String: String] = [:],+ successCriteria: String? = nil,+ clarification: String? = nil+ ) {+ var block = "\n### 🗺️ assistant · planning \(Self.shortStamp(Date()))\n"+ block += "\n**Goal:** \(Self.clip(goal, 600))\n"+ if let targetApp = targetApp?.trimmingCharacters(in: .whitespacesAndNewlines), !targetApp.isEmpty {+ block += "\n**Target app:** \(targetApp)\n"+ }+ if !parameters.isEmpty {+ block += "\n**Parameters:**\n"+ for (key, value) in parameters.sorted(by: { $0.key < $1.key }) {+ block += "- \(key): \(Self.clip(value, 600))\n"+ }+ }+ if let criteria = successCriteria?.trimmingCharacters(in: .whitespacesAndNewlines), !criteria.isEmpty {+ block += "\n**Success criteria:** \(Self.clip(criteria, 600))\n"+ }+ if let clarification = clarification?.trimmingCharacters(in: .whitespacesAndNewlines), !clarification.isEmpty {+ block += "\n**Clarification needed:** \(Self.clip(clarification, 600))\n"+ }+ write(block, append: true)}- /// A tool's result.- public func toolResult(tool: String, status: String, output: String) {- appendEntry(role: .tool, kind: .toolResult, title: "\(tool) → \(status)", body: Self.clip(output, 2_000), fenced: true)+ /// One executed step, rendered as a single grouped block so the trace reads decision → output →+ /// next decision. The decision carries the model's full thought summary (bounded so a verbose+ /// chain of thought can't bloat the file — it is persisted only here, never in the per-step+ /// planning prompt), its one-line reason, and the action with its complete input. Planning+ /// retries hit while choosing this step open the block, so a step that needed recovery reads as+ /// one unit instead of scattered entries. The thought is also where the model interprets the+ /// previous step's output, so each block's output is reasoned about at the top of the next.+ public func step(+ number: Int,+ thought: String?,+ reason: String?,+ tool: String,+ input: [String: String],+ status: String,+ output: String,+ planningErrors: [String] = []+ ) {+ var block = "\n## Step \(number) \(Self.shortStamp(Date()))\n"+ for planningError in planningErrors {+ let text = Self.clip(planningError, 2_000)+ if !text.isEmpty { block += "\n⚠️ \(text)\n" }+ }+ block += "\n### 🧠 Decision\n"+ if let thought = thought?.trimmingCharacters(in: .whitespacesAndNewlines), !thought.isEmpty {+ block += "\n**Thought:** \(Self.clip(thought, 4_000))\n"+ }+ if let reason = reason?.trimmingCharacters(in: .whitespacesAndNewlines), !reason.isEmpty {+ block += "\n**Reason:** \(Self.clip(reason, 600))\n"+ }+ block += "\n**Action:** `\(tool)`\n```\n\(Self.inputBody(input))\n```\n"+ block += "\n### 📄 Output — `\(status)`\n\n```\n\(Self.clip(output, 2_000))\n```\n"+ write(block, append: true)}/// The assistant's answer to the user, closing a turn.@@ -143,16 +183,21 @@ public final class ThreadTranscript: @unchecked Sendable {private static func icon(_ role: Role, _ kind: Kind) -> String {switch (role, kind) {case (.user, _): return "👤"- case (.assistant, .thinking): return "🧠"- case (.assistant, .toolCall): return "🔧"case (.assistant, .response): return "💬"- case (.tool, _): return "📄"case (.system, .error): return "⚠️"case (.system, _): return "⚙️"default: return "•"}}+ private static func inputBody(_ input: [String: String]) -> String {+ input.isEmpty+ ? "(no input)"+ : input.sorted { $0.key < $1.key }+ .map { "\($0.key): \(clip($0.value, 600))" }+ .joined(separator: "\n")+ }+private static func clip(_ text: String, _ max: Int) -> String {let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)return trimmed.count > max ? String(trimmed.prefix(max)) + " …[clipped]" : trimmeddiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ResolveDriveTargetTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ResolveDriveTargetTests.swiftnew file mode 100644index 00000000..ad5db6e5--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ResolveDriveTargetTests.swift@@ -0,0 +1,83 @@+import DonkeyAI+import Foundation+import Testing+@testable import Donkey++@Suite+@MainActor+struct ResolveDriveTargetTests {+ @Test+ func runningUnderstoodTargetWinsWithItsResolvedIdentity() {+ let target = LocalAppUserQueryCommandHandler.resolveDriveTarget(+ understanding: HarnessRequestUnderstanding(restatedGoal: "Play music", targetAppName: "Music"),+ frontmostAppName: "iTerm2",+ frontmostBundleIdentifier: "com.googlecode.iterm2",+ resolveRunningWindow: { _ in (appName: "Music", bundleIdentifier: "com.apple.Music") },+ resolveInstalledBundle: { _ in nil }+ )++ #expect(target.appName == "Music")+ #expect(target.bundleIdentifier == "com.apple.Music")+ }++ @Test+ func installedButNotRunningTargetStaysPinnedByName() {+ // The exact failure of the "play some blackpink" runs: Music named by the understanding but+ // not running at submit, so the run pinned to iTerm2 and every observe/click/focus-recovery+ // aimed at the wrong app. An installed target must stay pinned even with no window yet.+ let target = LocalAppUserQueryCommandHandler.resolveDriveTarget(+ understanding: HarnessRequestUnderstanding(restatedGoal: "Play music", targetAppName: "Music"),+ frontmostAppName: "iTerm2",+ frontmostBundleIdentifier: "com.googlecode.iterm2",+ resolveRunningWindow: { _ in nil },+ resolveInstalledBundle: { _ in URL(fileURLWithPath: "/System/Applications/Music.app") }+ )++ #expect(target.appName == "Music")+ #expect(target.bundleIdentifier == "com.apple.Music")+ }++ @Test+ func unknownTargetFallsBackToFrontmost() {+ // A name that matches nothing running and nothing installed (hallucinated/misheard app)+ // must not pin the run to a window that can never resolve.+ let target = LocalAppUserQueryCommandHandler.resolveDriveTarget(+ understanding: HarnessRequestUnderstanding(restatedGoal: "Do a thing", targetAppName: "Nonexistent App"),+ frontmostAppName: "iTerm2",+ frontmostBundleIdentifier: "com.googlecode.iterm2",+ resolveRunningWindow: { _ in nil },+ resolveInstalledBundle: { _ in nil }+ )++ #expect(target.appName == "iTerm2")+ #expect(target.bundleIdentifier == "com.googlecode.iterm2")+ }++ @Test+ func noNamedTargetKeepsFrontmost() {+ let target = LocalAppUserQueryCommandHandler.resolveDriveTarget(+ understanding: HarnessRequestUnderstanding(restatedGoal: "Check battery", targetAppName: nil),+ frontmostAppName: "iTerm2",+ frontmostBundleIdentifier: "com.googlecode.iterm2",+ resolveRunningWindow: { _ in nil },+ resolveInstalledBundle: { _ in nil }+ )++ #expect(target.appName == "iTerm2")+ #expect(target.bundleIdentifier == "com.googlecode.iterm2")+ }++ @Test+ func targetMatchingFrontmostKeepsFrontmostIdentity() {+ let target = LocalAppUserQueryCommandHandler.resolveDriveTarget(+ understanding: HarnessRequestUnderstanding(restatedGoal: "Type here", targetAppName: "iterm2"),+ frontmostAppName: "iTerm2",+ frontmostBundleIdentifier: "com.googlecode.iterm2",+ resolveRunningWindow: { _ in nil },+ resolveInstalledBundle: { _ in nil }+ )++ #expect(target.appName == "iTerm2")+ #expect(target.bundleIdentifier == "com.googlecode.iterm2")+ }+}diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swiftnew file mode 100644index 00000000..31d1b6a8--- /dev/null+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swift@@ -0,0 +1,122 @@+import Foundation+import Testing+@testable import DonkeyRuntime++@Suite+struct ThreadTranscriptTests {+ @Test+ func stepRendersDecisionThenOutputAsOneBlock() throws {+ let transcript = makeTranscript()+ transcript.step(+ number: 3,+ thought: "Search worked, so now I create the playlist container before adding songs.",+ reason: "Creating the \"Best of 2000\" playlist.",+ tool: "music.playlist",+ input: ["action": "create", "name": "Best of 2000"],+ status: "failed",+ output: "Playlist create call returned no playlist for \"Best of 2000\".",+ planningErrors: ["planning attempt 1/3: chose music.playlist without its required input (action)"]+ )++ let text = try threadText(transcript)+ #expect(text.contains("## Step 3"))+ #expect(text.contains("⚠️ planning attempt 1/3"))+ #expect(text.contains("### 🧠 Decision"))+ #expect(text.contains("**Thought:** Search worked"))+ #expect(text.contains("**Reason:** Creating the \"Best of 2000\" playlist."))+ #expect(text.contains("**Action:** `music.playlist`"))+ #expect(text.contains("action: create\nname: Best of 2000"))+ #expect(text.contains("### 📄 Output — `failed`"))+ #expect(text.contains("returned no playlist"))+ let decision = try #require(text.range(of: "### 🧠 Decision"))+ let action = try #require(text.range(of: "**Action:**"))+ let output = try #require(text.range(of: "### 📄 Output"))+ #expect(decision.lowerBound < action.lowerBound)+ #expect(action.lowerBound < output.lowerBound)+ }++ @Test+ func stepOmitsAbsentThoughtAndReasonLabels() throws {+ let transcript = makeTranscript()+ transcript.step(+ number: 1,+ thought: nil,+ reason: " ",+ tool: "music.status",+ input: [:],+ status: "succeeded",+ output: "Playback state: stopped."+ )++ let text = try threadText(transcript)+ #expect(!text.contains("**Thought:**"))+ #expect(!text.contains("**Reason:**"))+ #expect(text.contains("**Action:** `music.status`"))+ #expect(text.contains("(no input)"))+ #expect(text.contains("### 📄 Output — `succeeded`"))+ }++ @Test+ func planningBlockRendersGoalAppParametersAndCriteria() throws {+ let transcript = makeTranscript()+ transcript.planning(+ goal: "Create a playlist of the 10 best songs from 2000",+ targetApp: "Music",+ parameters: ["year": "2000", "count": "10"],+ successCriteria: "A playlist named \"Best of 2000\" exists with 10 songs",+ clarification: nil+ )++ let text = try threadText(transcript)+ #expect(text.contains("### 🗺️ assistant · planning"))+ #expect(text.contains("**Goal:** Create a playlist of the 10 best songs from 2000"))+ #expect(text.contains("**Target app:** Music"))+ #expect(text.contains("**Parameters:**\n- count: 10\n- year: 2000"))+ #expect(text.contains("**Success criteria:** A playlist named \"Best of 2000\" exists with 10 songs"))+ #expect(!text.contains("**Clarification needed:**"))+ }++ @Test+ func planningBlockOmitsAbsentFieldsAndShowsClarification() throws {+ let transcript = makeTranscript()+ transcript.planning(+ goal: "Send the draft",+ clarification: "Which draft should I send?"+ )++ let text = try threadText(transcript)+ #expect(text.contains("**Goal:** Send the draft"))+ #expect(!text.contains("**Target app:**"))+ #expect(!text.contains("**Parameters:**"))+ #expect(!text.contains("**Success criteria:**"))+ #expect(text.contains("**Clarification needed:** Which draft should I send?"))+ }++ @Test+ func flatEntriesStillRenderAroundSteps() throws {+ let transcript = makeTranscript()+ transcript.begin(id: "T1", app: "Music")+ transcript.userMessage("create a playlist")+ transcript.systemEvent("Run finished: completed after 1 step(s).")+ transcript.error("Run could not start (offline).")+ transcript.response("Done — playlist created.")++ let text = try threadText(transcript)+ #expect(text.contains("# Thread T1"))+ #expect(text.contains("👤 user · message"))+ #expect(text.contains("create a playlist"))+ #expect(text.contains("⚙️ system · event"))+ #expect(text.contains("⚠️ system · error"))+ #expect(text.contains("💬 assistant · response"))+ }++ private func makeTranscript() -> ThreadTranscript {+ let root = FileManager.default.temporaryDirectory+ .appendingPathComponent("thread-transcript-tests-\(UUID().uuidString)", isDirectory: true)+ return ThreadTranscript(id: UUID().uuidString, root: root)+ }++ private func threadText(_ transcript: ThreadTranscript) throws -> String {+ try String(contentsOfFile: transcript.threadPath, encoding: .utf8)+ }+}