Logo di Duo Intelligence

Duo Intelligence

Community
Kimeur
duo-intelligence

Adds Foundation Models to an iPhone Duo app: the on-device model (SystemLanguageModel) and the Private Cloud Compute server model (PrivateCloudComputeLanguageModel) behind one LanguageModelSession API, an AI side pane beside the content when the phone is open or in book pose (split ArrangementView) and a one-line summary when it is closed or in tabletop, streaming (streamResponse with @Generable partial snapshots) into a pane that keeps going through fold and unfold, availability checks and non-AI fallbacks, quota and error handling (LanguageModelError), tool calling, image prompts (Attachment), reasoning levels (ContextOptions) and privacy. Use when someone adds summaries, an assistant, chat, tagging or image understanding to an app that runs on iPhone Duo, or when an AI feature restarts on a fold, sits in the fold or doesn't fit the outer display.

Panoramica

AutoreKimeur
Repositoryduology
Nome della skillduo-intelligence
Stelle
40
Fork
2
File inclusi
4
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 4 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da Kimeur su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Duo Intelligence in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/Kimeur/duology/tree/main/plugins/duology-features/skills/duo-intelligence
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Kimeur/duology.git /tmp/duology
mkdir -p .claude/skills
cp -r /tmp/duology/plugins/duology-features/skills/duo-intelligence .claude/skills/duo-intelligence
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Duo Intelligence in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Duo Intelligence non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Duo Intelligence non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

duo-intelligence

The Foundation Models framework gives an app Apple's on-device language model and, from iOS 27, the larger Private Cloud Compute model, through the same Swift API (Foundation Models). On iPhone Duo the question is where the result goes and what happens when the phone folds mid-answer. This skill answers both.

Load neighbours when the task needs them: duo-continuity (state that survives a fold), duo-layout (size classes, the fold, ArrangementView), duo-postures (book and tabletop layouts), duo-app-intents (let Siri and Shortcuts run the same feature). To start a new notes app with all of this in place, use recipe-notes-ai.

Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1) on 20 October 2026; see references/evidence.md. Unverified means we could not confirm it. Everything else comes from Apple's pages, linked inline. Full source list: reference/sources.md.

What Apple says, and what it doesn't

Apple's iPhone Duo pages and the six Duo Tech Talks say nothing about Foundation Models (we searched the transcripts, the HIG page and the developer overview). The Duo advice below applies Apple's general Duo rules to AI features: keep the same features on both displays, let the open phone add one level of detail, keep controls out of the fold (HIG: Designing for iPhone Duo). An AI pane is a supporting pane, like the Podcasts transcript Apple puts beside Now Playing with a split ArrangementView (talk 111463). The model facts come from the Foundation Models docs and WWDC26 sessions 241 and 319.

On device: SystemLanguageModelServer: PrivateCloudComputeLanguageModel
SinceiOS 26.0iOS 27.0, plus a managed entitlement
NetworkNot neededNeeded
Context4,096 tokens32K tokens
LimitsNoneA daily limit per person; iCloud+ raises it
ReasoningNolight, moderate, deep
ImagesYes, iOS 27 (.vision capability)Yes

Sources: Adding server-side intelligence with Private Cloud Compute, Managing the context window, Analyzing images with multimodal prompting. Both models conform to the iOS 27 LanguageModel protocol, so LanguageModelSession(model:instructions:) takes either one and the rest of your code stays the same.

Rules

  1. Start on device. Use Private Cloud Compute only when evaluation (Apple's Evaluations framework, new in Xcode 27) shows the on-device model can't do the job, the app has the entitlement, and the person knows the text leaves the phone (PCC guide, HIG: Generative AI).
  2. Check availability, then still expect failure. Measured: the simulator reported both models .available, yet every on-device request failed. Every request needs a non-AI fallback.
  3. One feature, two sizes. Open and wide: the result in a pane beside the content. Closed, or any window that can't fit the pane beside: one line, with a way to the full pane. Same feature, same data.
  4. Own the request in a model, not a view. One AssistantModel per window, created in the window root. A fold resizes the window; the stream must not notice (duo-continuity).
  5. Ask for structure. A @Generable type with a short headline first feeds the closed phone early and the open pane fully, from one request.
  6. Let the arrangement keep the pane off the fold. A split ArrangementView puts the note and the pane one on each side. Text in a scroll view may cross the fold; Stop, Retry and text fields may not.
  7. Say where AI is used and keep people in control. Label the pane, say what the model is doing, and let people dismiss or retry the result (HIG: Generative AI). Add Stop too: a request can hang (measured).
  8. Gate the APIs. SystemLanguageModel and sessions are iOS 26.0. PrivateCloudComputeLanguageModel, LanguageModel, Attachment, ContextOptions and LanguageModelError are iOS 27.0. ArrangementView is iOS 27.1. iPhone Duo ships with iOS 27.1, so #available only matters for other iPhones.

1. Pick the model

swift
import FoundationModels

/// Picks the model for one request. Start on device; move to Private Cloud Compute
/// only when the task needs it, the app has the entitlement and the person agreed.
@available(iOS 27.0, *)
enum AssistantModels {
    static func choose(needsLargeContext: Bool, cloudAllowed: Bool) -> (any LanguageModel)? {
        if needsLargeContext && cloudAllowed {
            let cloud = PrivateCloudComputeLanguageModel()
            if cloud.isAvailable && !cloud.quotaUsage.isLimitReached { return cloud }
        }
        let onDevice = SystemLanguageModel.default
        return onDevice.isAvailable ? onDevice : nil   // nil: show the non-AI fallback
    }

    /// Words for the fallback when the on-device model can't run.
    static var unavailableReason: String? {
        switch SystemLanguageModel.default.availability {
        case .available: nil
        case .unavailable(.deviceNotEligible): "This iPhone can't run Apple Intelligence."
        case .unavailable(.appleIntelligenceNotEnabled): "Turn on Apple Intelligence in Settings to get summaries."
        case .unavailable(.modelNotReady): "Summaries will work once the model finishes downloading."
        case .unavailable: "Summaries aren't available right now."
        }
    }
}
  • SystemLanguageModel is Observable in the SDK, so a view that reads availability can follow it as the model downloads (unverified on a device).
  • Private Cloud Compute needs the com.apple.developer.private-cloud-compute entitlement, which Apple grants to eligible apps on request (entitlement, Accessing Private Cloud Compute). Measured: without it, the simulator still reported .available, and a request never returned in 9 minutes. Keep Stop on screen for every request.
  • Network failure on Private Cloud Compute: Apple says to retry on device. Quota: show a quiet, persistent note, not an alert. Code for both: references/models-and-availability.md.

2. Stream into a model the window owns

swift
import FoundationModels
import Observation

@available(iOS 26.0, *)
@Generable
struct NoteDigest {
    @Guide(description: "One line of at most eight words, shown on the closed phone")
    var headline: String
    @Guide(description: "The key points, shown in the side pane", .count(3))
    var points: [String]
}

/// One per window, created in the window's root view. The stream lives here,
/// not in a view, so closing or opening the phone never restarts it.
@available(iOS 27.0, *)
@MainActor @Observable
final class AssistantModel {
    enum Phase: Equatable { case idle, working, done, failed(String) }

    private(set) var digest: NoteDigest.PartiallyGenerated?
    private(set) var phase = Phase.idle
    private var task: Task<Void, Never>?
    @ObservationIgnored private var lastRequest: (note: String, model: any LanguageModel)?

    func summarize(_ note: String, with model: any LanguageModel) {
        task?.cancel()                       // one summary at a time; a new one replaces the old
        lastRequest = (note, model)
        digest = nil
        phase = .working
        task = Task {
            let session = LanguageModelSession(model: model, instructions: "Summarize the note for a busy reader.")
            do {
                for try await snapshot in session.streamResponse(to: note, generating: NoteDigest.self) {
                    if Task.isCancelled { return }   // stop() or a newer request owns the state now
                    digest = snapshot.content        // partial: fields fill in as they arrive
                }
                if !Task.isCancelled { phase = .done }
            } catch {
                // Keep the note usable without AI. A cancelled task must not overwrite a newer one.
                if !Task.isCancelled { phase = .failed(error.localizedDescription) }
            }
        }
    }

    func retry() {
        if let lastRequest { summarize(lastRequest.note, with: lastRequest.model) }
    }

    func stop() {
        task?.cancel()
        task = nil
        if phase == .working { phase = .idle }
    }
}
  • The model generates @Generable properties in the order you declare them (guided generation). Put the closed-phone headline first: it shows before the points are done.
  • A session handles one request at a time; a second call while one runs is an error (Generating content). Cancel the old task or check isResponding.
  • Measured (stand-in stream, because the simulator's model failed): a task held by a window-owned model kept appending through close, open, book and tabletop. The note view kept its identity and the selection survived. The stream fell up to 1.4 s behind its pace around a fold, then went on as before (evidence).
  • Never start a request in onAppear or .task below a layout switch. A fold can run it again (duo-continuity).

3. Pane when open, one line when closed

swift
import SwiftUI

// requires: Note, NoteBody (your types); AssistantPane, AssistantSummaryBar (references/assistant-pane.md)

/// Wide (open, book): the note leading, the assistant pane trailing, one on each side of the fold.
/// Otherwise (closed, tabletop, a narrow window): the note with a one-line digest at the bottom;
/// Details shows the same pane in a sheet.
@available(iOS 27.1, *)
struct NoteScreen: View {
    let note: Note
    let assistant: AssistantModel                 // owned by the window root
    @Environment(\.horizontalSizeClass) private var widthClass
    @State private var paneIsBeside = false
    @State private var showsPaneSheet = false

    var body: some View {
        ArrangementView {
            NoteBody(note: note)                  // primary: shown in every pose
        } secondary: {
            AssistantPane(model: assistant)       // shown only when it fits beside
        }
        .arrangementViewStyle(.split.axes(.horizontal))   // beside, never below
        .safeAreaInset(edge: .bottom) {
            if !paneIsBeside {
                AssistantSummaryBar(model: assistant) { showsPaneSheet = true }
            }
        }
        .onGeometryChange(for: CGSize.self) { $0.size } action: { size in
            // The split rule duo-patterns measured: side by side needs regular width and a wide view.
            paneIsBeside = widthClass == .regular && size.width > size.height
        }
        .sheet(isPresented: $showsPaneSheet) { AssistantPane(model: assistant) }
        .onChange(of: paneIsBeside) { _, beside in
            if beside { showsPaneSheet = false }  // the pane is on screen now
        }
    }
}
  • Put it inside the window's NavigationStack, never inside a List, ScrollView or NavigationSplitView (HIG).
  • No API says "the secondary is hidden", so paneIsBeside mirrors the split rule (duo-patterns, supporting pane). Measure it after the inset, so the bar's height can't flip the result.
  • AssistantPane, AssistantSummaryBar, the window root and a UIKit version: references/assistant-pane.md.

What each pose gets (layout by size class and shape, never by pose; see duo-postures):

PhoneWindowThe AI feature
Closed, portrait or sideways466 × 678 or 678 × 466 pt, compact widthThe note, and one line at the bottom: the headline, or what the model is doing. Details opens the full pane in a sheet.
Open, flat, held wide951 × 669 ptNote leading, pane trailing, half each.
Book (partly folded, held wide)951 × 669 ptThe same, one on each side of the fold. The pane sits in the trailing region, where controls stay once the phone closes (duo-postures).
Tabletop (partly folded, held tall)669 × 951 ptThe note, with the one-line bar in the bottom region, near the hands. Details opens the sheet.
Split View on the inner displayHalf the displayWhatever its width class and shape allow; unverified.

Window sizes come from device facts. What our probe showed in each pose: references/evidence.md.

Apple lets the open phone add one level of hierarchy, as Mail adds the message beside the list (HIG). The pane is that level. The closed phone keeps the feature; it only shows less of it.

4. Errors and fallbacks

  • Catch LanguageModelError (iOS 27) for guardrail violations, refusals, context overflow, rate limits and time-outs. iOS 26's LanguageModelSession.GenerationError is deprecated in iOS 27. Its missing-assets case moved to SystemLanguageModel.Error.assetsUnavailable; treat that like .modelNotReady.
  • Measured: the simulator's failure arrived as a plain NSError (domain FoundationModels.LanguageModelError, code -1), so typed catch clauses missed it. Always end with a plain catch that shows the fallback.
  • A refusal or guardrail error on text the person typed: say the feature can't handle that input and let them try again (Improving the safety of generative model output).
  • Context overflow: trim the transcript, or split the text into chunks with one session each (Managing the context window).
  • Code: references/models-and-availability.md.

5. Privacy

  • On-device requests stay on the phone. Private Cloud Compute sends the prompt to Apple's servers; Apple says it stores nothing and lets researchers check that (WWDC26 session 319). Still tell people before their text leaves the phone, and let them say no (HIG: Generative AI).
  • Never put text from the person or a web page in instructions. The model trusts instructions more than prompts, so that opens the door to prompt injection (safety guide).
  • A third-party model behind the LanguageModel protocol: fetch its access token securely (Apple suggests OAuth) and keep it in the Keychain (WWDC26 session 241). Its privacy terms are not Apple's; say so.

6. Tools, images and reasoning

  • A Tool lets the model ask your app for data. Keep tools small and read-only unless the person confirms an action.
  • Attachment(cgImage) in a prompt sends an image (iOS 27). Check capabilities.contains(.vision) first; the on-device model reported it (measured).
  • ContextOptions(reasoningLevel:) works with Private Cloud Compute; the on-device model reported no reasoning capability (measured).
  • Code for all three: references/tools-images-reasoning.md.

Test it

  1. Test the quota note without using up a quota: in the scheme's Run options, "Simulated Apple Foundation Models Availability" has "Approaching Quota Usage Limit" and "Quota Usage Limit Reached" (PCC guide; the WWDC26 video shows slightly different labels).
  2. Start a summary on the closed phone, then press Open in Device Hub while it streams, and Closed again. The text must keep growing, with no restart and no second request.
  3. Check book and tabletop (duo-pose set book, duo-pose set tabletop from duo-pose-matrix, or Device Hub's buttons): no button of the pane in the fold, and the bar sits in the bottom region in tabletop.
  4. Profile token use with the Foundation Models instrument (Product > Profile) (Managing the context window).
  5. Judge output quality on a device with Apple Intelligence. Measured: on our Mac the simulator's model failed every request, and contextSize read 0. On 29 October the log showed why: the simulator isn't supported (evidence).

Checklist

  • On-device model first; Private Cloud Compute only with the entitlement, a reason, and the person's consent.
  • Availability checked before showing the feature; every request also has a fallback for failure.
  • The final catch is untyped and shows the non-AI path.
  • One AssistantModel per window, owned by the window root; no request starts in onAppear or .task below a layout switch.
  • A @Generable result with the closed-phone headline as its first property.
  • Open and book: pane beside the content in a split ArrangementView. Closed and tabletop: one line plus a way to the full pane. Same feature on both displays.
  • Sheet closes when the pane fits beside; the pane shows the same text in place.
  • No Stop, Retry or text field in the fold in book or tabletop.
  • The pane says it is AI, says what the model is doing, and has Stop and Retry.
  • No user or web text in instructions; people told before text goes to Private Cloud Compute.
  • iOS 26 and iOS 27 APIs behind @available when the app deploys lower.
  • Tested through close and open while streaming, and on a device with Apple Intelligence.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Duo Intelligence?

Adds Foundation Models to an iPhone Duo app: the on-device model (SystemLanguageModel) and the Private Cloud Compute server model (PrivateCloudComputeLanguageModel) behind one LanguageModelSession API, an AI side pane beside the content when the phone is open or in book pose (split ArrangementView) and a one-line summary when it is closed or in tabletop, streaming (streamResponse with @Generable partial snapshots) into a pane that keeps going through fold and unfold, availability checks and non-AI fallbacks, quota and error handling (LanguageModelError), tool calling, image prompts (Attachm...

Perché usare Duo Intelligence su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Duo Intelligence è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Duo Intelligence in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/Kimeur/duology/tree/main/plugins/duology-features/skills/duo-intelligence. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Duo Intelligence?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Duo Intelligence?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Duo Intelligence: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Duo Intelligence è gratuita?

Sì. È pubblicata su GitHub da Kimeur con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇