File size: 3,874 Bytes
7b2dfc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import AppIntents

/// Opens Dolphin with an inert, sanitized request in the composer.
///
/// Execution intentionally stops at handoff: it does not send the request,
/// load the Core ML model, invoke tools, or request permissions.
struct AskDolphinIntent: AppIntent {
  static let title: LocalizedStringResource = "Ask Dolphin"
  static let description = IntentDescription(
    "Open Dolphin with a request ready to review before sending."
  )

  // Compatibility path for iOS 18 and 19.
  static let openAppWhenRun = true

  // On iOS 26, foreground before `perform()` so the handoff remains an
  // explicitly visible, user-reviewed action.
  @available(iOS 26.0, *)
  static var supportedModes: IntentModes { [.foreground(.immediate)] }

  @Parameter(
    title: "Request",
    description: "The question or request to place in Dolphin's composer.",
    inputConnectionBehavior: .connectToPreviousIntentResult
  )
  var request: String

  static var parameterSummary: some ParameterSummary {
    Summary("Ask Dolphin \(\.$request)")
  }

  func perform() async throws -> some IntentResult {
    // A wrapper-only value is intentionally ignored. `openAppWhenRun` still
    // opens Dolphin, but no unsafe text is handed to the conversation.
    IntentHandoffStore.store(request)
    return .result()
  }
}

/// Opens the active local continuity context for review. Like Ask Dolphin, this
/// only prepares inert composer text and never restores or executes by itself.
struct ContinueDolphinIntent: AppIntent {
  static let title: LocalizedStringResource = "Continue with Dolphin"
  static let description = IntentDescription(
    "Open Dolphin with a project-context request ready to review."
  )
  static let openAppWhenRun = true

  @available(iOS 26.0, *)
  static var supportedModes: IntentModes { [.foreground(.immediate)] }

  func perform() async throws -> some IntentResult {
    IntentHandoffStore.store("Show project context")
    return .result()
  }
}

/// Prepares an explicit structured-capture command. The user still reviews,
/// sends, and approves the exact local write in Dolphin.
struct CaptureDolphinContextIntent: AppIntent {
  static let title: LocalizedStringResource = "Capture Dolphin Context"
  static let description = IntentDescription(
    "Open Dolphin with a local context note ready to review and save."
  )
  static let openAppWhenRun = true

  @available(iOS 26.0, *)
  static var supportedModes: IntentModes { [.foreground(.immediate)] }

  @Parameter(
    title: "Context",
    description: "The context note to prepare for capture.",
    inputConnectionBehavior: .connectToPreviousIntentResult
  )
  var context: String

  static var parameterSummary: some ParameterSummary {
    Summary("Capture \(\.$context) in Dolphin")
  }

  func perform() async throws -> some IntentResult {
    IntentHandoffStore.store("Capture context: \(context)")
    return .result()
  }
}

struct DolphinShortcutsProvider: AppShortcutsProvider {
  static var appShortcuts: [AppShortcut] {
    AppShortcut(
      intent: AskDolphinIntent(),
      phrases: [
        "Ask \(.applicationName)",
        "Start a request in \(.applicationName)",
      ],
      shortTitle: "Ask Dolphin",
      systemImageName: "bubble.left.and.text.bubble.right"
    )
    AppShortcut(
      intent: ContinueDolphinIntent(),
      phrases: [
        "Continue with \(.applicationName)",
        "Show context in \(.applicationName)",
      ],
      shortTitle: "Continue Dolphin",
      systemImageName: "arrow.triangle.branch"
    )
    AppShortcut(
      intent: CaptureDolphinContextIntent(),
      phrases: [
        "Capture context in \(.applicationName)",
        "Save context with \(.applicationName)",
      ],
      shortTitle: "Capture Context",
      systemImageName: "square.and.pencil"
    )
  }

  static let shortcutTileColor: ShortcutTileColor = .blue
}