mcpField
S
sirikit

sirikit

github.com/ios-agent開発1240 回インストール34 週間前に更新
リポジトリ

sirikit について

sirikitは、SiriKit対応を実装するAppleアプリ開発者向けの開発スキルです。カスタムインテントやショートカット、提案機能の処理パターンと設定を扱います。

主な機能

  1. 01Intents拡張機能とSiriアクセスの設定
  2. 02カスタムインテントとパラメーターの定義
  3. 03インテントの解決・確認・実行処理
  4. 04ショートカットの提供と削除
  5. 05Siri UIとボキャブラリーのカスタマイズ

活用シーン

  1. 01アプリに音声操作を追加
  2. 02ユーザー操作に応じたショートカットの提案
  3. 03アプリでSiriインテントを受信して処理

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/ios-agent/iosagent.dev --skill sirikit

インストール後、Claude Code で/sirikitを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
app-intents.md
custom-intents.md
intent-handling.md
intents-ui.md
shortcuts.md
vocabulary.md

詳細

SiriKit 開発スキル

音声、ショートカット、インテリジェントな提案を通じて、ユーザーがアプリを操作できるようにします。

クイックスタート

インテント拡張機能を追加する
  1. ファイル → 新規 → ターゲット → インテント拡張機能
  2. Siri のインターフェースをカスタマイズする場合は、「UI 拡張機能を含める」を有効にします
  3. メインアプリのターゲットで Siri ケイパビリティを有効にします(署名とケイパビリティ)
最小限のインテントハンドラー
import Intents

class IntentHandler: INExtension {
    override func handler(for intent: INIntent) -> Any {
        switch intent {
        case is OrderSoupIntent:
            return OrderSoupIntentHandler()
        default:
            return self
        }
    }
}

class OrderSoupIntentHandler: NSObject, OrderSoupIntentHandling {
    // 1. Resolve parameters
    func resolveSoup(for intent: OrderSoupIntent) async -> SoupResolutionResult {
        guard let soup = intent.soup else {
            return .needsValue()
        }
        return .success(with: soup)
    }
    
    // 2. Confirm intent
    func confirm(intent: OrderSoupIntent) async -> OrderSoupIntentResponse {
        return OrderSoupIntentResponse(code: .ready, userActivity: nil)
    }
    
    // 3. Handle intent
    func handle(intent: OrderSoupIntent) async -> OrderSoupIntentResponse {
        // Fulfill the request
        return OrderSoupIntentResponse.success(message: "Your order is confirmed!")
    }
}

インテント処理フロー

┌─────────────────────────────────────────────────────────────┐
│                    User speaks to Siri                       │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│ 1. RESOLVE - Validate each parameter                         │
│    • Return .success(with:) if valid                        │
│    • Return .needsValue() if missing                        │
│    • Return .disambiguation(with:) for choices              │
│    • Return .unsupported() if invalid                       │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│ 2. CONFIRM - Final validation before execution               │
│    • Verify services are ready                              │
│    • Return .ready or appropriate failure code              │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│ 3. HANDLE - Fulfill the intent                               │
│    • Execute the action                                     │
│    • Return success/failure response                        │
└─────────────────────────────────────────────────────────────┘

システムインテントのドメイン

ドメインユースケース主なインテント
メッセージメッセージの送信・検索INSendMessageIntent、INSearchForMessagesIntent
通話VoIP 通話INStartCallIntent、INSearchCallHistoryIntent
支払い送金INSendPaymentIntent、INRequestPaymentIntent
配車予約配車のリクエストINRequestRideIntent、INGetRideStatusIntent
ワークアウトワークアウトの開始・終了INStartWorkoutIntent、INEndWorkoutIntent
メディアオーディオ・ビデオの再生INPlayMediaIntent、INAddMediaIntent
写真写真の検索INSearchForPhotosIntent
リストとメモメモ・タスクの作成INCreateNoteIntent、INAddTasksIntent
車のコマンド車両の操作INSetCarLockStatusIntent、INActivateCarSignalIntent
予約レストランの予約INGetReservationDetailsIntent

カスタムインテント

インテント定義ファイルで定義する
  1. Intents.intentdefinition ファイルを作成します
  2. 動詞+名詞の命名規則で新しいインテントを追加します(例:OrderSoup)
  3. 用途に合ったカテゴリを設定します
  4. 型を指定してパラメーターを定義します
パラメーターの型
  • システム:String、Integer、Boolean、Date、Person、Location、Currency
  • カスタム:列挙型またはオブジェクトとして独自の型を定義します

リファレンスドキュメント

主な設定

Info.plist(インテント拡張機能)
<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>IntentsSupported</key>
        <array>
            <string>OrderSoupIntent</string>
        </array>
        <key>IntentsRestrictedWhileLocked</key>
        <array>
            <string>INSendPaymentIntent</string>
        </array>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.intents-service</string>
    <key>NSExtensionPrincipalClass</key>
    <string>$(PRODUCT_MODULE_NAME).IntentHandler</string>
</dict>
Siri の使用許可をリクエストする
import Intents

INPreferences.requestSiriAuthorization { status in
    switch status {
    case .authorized: print("Siri authorized")
    case .denied: print("Siri denied")
    case .notDetermined: print("Not determined")
    case .restricted: print("Restricted")
    @unknown default: break
    }
}

よくあるパターン

ユーザー操作後にショートカットを提供する
import Intents

func donateOrderShortcut(order: Order) {
    let intent = OrderSoupIntent()
    intent.soup = order.soup
    intent.quantity = order.quantity
    
    let interaction = INInteraction(intent: intent, response: nil)
    interaction.identifier = order.id.uuidString
    
    interaction.donate { error in
        if let error = error {
            print("Donation failed: \(error)")
        }
    }
}
提供済みのショートカットを削除する
// Delete specific
INInteraction.delete(with: [orderID.uuidString]) { error in }

// Delete all from app
INInteraction.deleteAll { error in }
アプリ内でインテントを処理する(起動時)
// SwiftUI
.onContinueUserActivity(NSStringFromClass(OrderSoupIntent.self)) { activity in
    if let intent = activity.interaction?.intent as? OrderSoupIntent {
        handleOrderIntent(intent)
    }
}

// UIKit SceneDelegate
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    if let intent = userActivity.interaction?.intent as? OrderSoupIntent {
        handleOrderIntent(intent)
    }
}

主な制約

  • バックグラウンド実行:拡張機能が実行される時間は短いため、長時間のタスクではアプリを起動します
  • 共有データ:アプリと拡張機能間のデータには App Groups を使用します
  • 拡張機能内の UI は不可:カスタムビューには IntentsUI 拡張機能を使用します
  • テスト:Siri が新しいインテントを認識するまで、インストール後しばらく待ちます
  • ローカライズ:ローカライズされた AppIntentVocabulary.plist を用意します

コメント