// // PocheIntents.swift // Poche // // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // import AppIntents import SwiftData // App Intents let Raccourcis and Siri reach Poche (CLAUDE.md §4). These // writes are user-initiated — the person explicitly runs the shortcut, which // IS the confirmation. The Confirm layer guards the *model's* proposals; no // model is involved here, and no EventKit bridge is exposed this way. struct SaveNoteIntent: AppIntent { static let title: LocalizedStringResource = "Ajouter une note à Poche" static let description = IntentDescription("Enregistre une note dans Poche, entièrement en local.") @Parameter(title: "Titre") var noteTitle: String @Parameter(title: "Contenu") var content: String @MainActor func perform() async throws -> some IntentResult & ProvidesDialog { let store = PocheStore(container: PocheContainer.shared) store.addNote(title: String(noteTitle.prefix(80)), content: String(content.prefix(2000))) return .result(dialog: "Note « \(noteTitle) » enregistrée dans Poche.") } } struct CreateTaskIntent: AppIntent { static let title: LocalizedStringResource = "Ajouter une tâche à Poche" static let description = IntentDescription("Crée une tâche dans Poche, entièrement en local.") @Parameter(title: "Titre") var taskTitle: String @MainActor func perform() async throws -> some IntentResult & ProvidesDialog { let store = PocheStore(container: PocheContainer.shared) store.addTask(title: String(taskTitle.prefix(80)), details: nil, due: nil) return .result(dialog: "Tâche « \(taskTitle) » créée dans Poche.") } } struct PocheShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: SaveNoteIntent(), phrases: ["Ajoute une note dans \(.applicationName)"], shortTitle: "Nouvelle note", systemImageName: "note.text" ) AppShortcut( intent: CreateTaskIntent(), phrases: ["Ajoute une tâche dans \(.applicationName)"], shortTitle: "Nouvelle tâche", systemImageName: "checklist" ) } }