[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75DSHW3HP0C5GGGZ2GNDP1H":3,"skill-same:01M75DSHW3HP0C5GGGZ2GNDP1H":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M75DSHW3HP0C5GGGZ2GNDP1H","foundation-models-on-device",null,"Apple FoundationModels framework for on-device LLM — text generation, guided generation with @Generable, tool calling, and snapshot streaming in iOS 26+.","agisota\u002Fold-one","agisota","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121413592?v=4","01M75B4BRNT67EC1NDRT8QZEP2","01M75B4BS7QR9VP580MSCPTS3X",3,"MIT","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Ffoundation-models-on-device\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: foundation-models-on-device\ndescription: Apple FoundationModels framework for on-device LLM — text generation, guided generation with @Generable, tool calling, and snapshot streaming in iOS 26+.\n---\n\n# FoundationModels: On-Device LLM (iOS 26)\n\nPatterns for integrating Apple's on-device language model into apps using the FoundationModels framework. Covers text generation, structured output with `@Generable`, custom tool calling, and snapshot streaming — all running on-device for privacy and offline support.\n\n## When to Activate\n\n- Building AI-powered features using Apple Intelligence on-device\n- Generating or summarizing text without cloud dependency\n- Extracting structured data from natural language input\n- Implementing custom tool calling for domain-specific AI actions\n- Streaming structured responses for real-time UI updates\n- Need privacy-preserving AI (no data leaves the device)\n\n## Core Pattern — Availability Check\n\nAlways check model availability before creating a session:\n\n```swift\nstruct GenerativeView: View {\n    private var model = SystemLanguageModel.default\n\n    var body: some View {\n        switch model.availability {\n        case .available:\n            ContentView()\n        case .unavailable(.deviceNotEligible):\n            Text(\"Device not eligible for Apple Intelligence\")\n        case .unavailable(.appleIntelligenceNotEnabled):\n            Text(\"Please enable Apple Intelligence in Settings\")\n        case .unavailable(.modelNotReady):\n            Text(\"Model is downloading or not ready\")\n        case .unavailable(let other):\n            Text(\"Model unavailable: \\(other)\")\n        }\n    }\n}\n```\n\n## Core Pattern — Basic Session\n\n```swift\n\u002F\u002F Single-turn: create a new session each time\nlet session = LanguageModelSession()\nlet response = try await session.respond(to: \"What's a good month to visit Paris?\")\nprint(response.content)\n\n\u002F\u002F Multi-turn: reuse session for conversation context\nlet session = LanguageModelSession(instructions: \"\"\"\n    You are a cooking assistant.\n    Provide recipe suggestions based on ingredients.\n    Keep suggestions brief and practical.\n    \"\"\")\n\nlet first = try await session.respond(to: \"I have chicken and rice\")\nlet followUp = try await session.respond(to: \"What about a vegetarian option?\")\n```\n\nKey points for instructions:\n- Define the model's role (\"You are a mentor\")\n- Specify what to do (\"Help extract calendar events\")\n- Set style preferences (\"Respond as briefly as possible\")\n- Add safety measures (\"Respond with 'I can't help with that' for dangerous requests\")\n\n## Core Pattern — Guided Generation with @Generable\n\nGenerate structured Swift types instead of raw strings:\n\n### 1. Define a Generable Type\n\n```swift\n@Generable(description: \"Basic profile information about a cat\")\nstruct CatProfile {\n    var name: String\n\n    @Guide(description: \"The age of the cat\", .range(0...20))\n    var age: Int\n\n    @Guide(description: \"A one sentence profile about the cat's personality\")\n    var profile: String\n}\n```\n\n### 2. Request Structured Output\n\n```swift\nlet response = try await session.respond(\n    to: \"Generate a cute rescue cat\",\n    generating: CatProfile.self\n)\n\n\u002F\u002F Access structured fields directly\nprint(\"Name: \\(response.content.name)\")\nprint(\"Age: \\(response.content.age)\")\nprint(\"Profile: \\(response.content.profile)\")\n```\n\n### Supported @Guide Constraints\n\n- `.range(0...20)` — numeric range\n- `.count(3)` — array element count\n- `description:` — semantic guidance for generation\n\n## Core Pattern — Tool Calling\n\nLet the model invoke custom code for domain-specific tasks:\n\n### 1. Define a Tool\n\n```swift\nstruct RecipeSearchTool: Tool {\n    let name = \"recipe_search\"\n    let description = \"Search for recipes matching a given term and return a list of results.\"\n\n    @Generable\n    struct Arguments {\n        var searchTerm: String\n        var numberOfResults: Int\n    }\n\n    func call(arguments: Arguments) async throws -> ToolOutput {\n        let recipes = await searchRecipes(\n            term: arguments.searchTerm,\n            limit: arguments.numberOfResults\n        )\n        return .string(recipes.map { \"- \\($0.name): \\($0.description)\" }.joined(separator: \"\\n\"))\n    }\n}\n```\n\n### 2. Create Session with Tools\n\n```swift\nlet session = LanguageModelSession(tools: [RecipeSearchTool()])\nlet response = try await session.respond(to: \"Find me some pasta recipes\")\n```\n\n### 3. Handle Tool Errors\n\n```swift\ndo {\n    let answer = try await session.respond(to: \"Find a recipe for tomato soup.\")\n} catch let error as LanguageModelSession.ToolCallError {\n    print(error.tool.name)\n    if case .databaseIsEmpty = error.underlyingError as? RecipeSearchToolError {\n        \u002F\u002F Handle specific tool error\n    }\n}\n```\n\n## Core Pattern — Snapshot Streaming\n\nStream structured responses for real-time UI with `PartiallyGenerated` types:\n\n```swift\n@Generable\nstruct TripIdeas {\n    @Guide(description: \"Ideas for upcoming trips\")\n    var ideas: [String]\n}\n\nlet stream = session.streamResponse(\n    to: \"What are some exciting trip ideas?\",\n    generating: TripIdeas.self\n)\n\nfor try await partial in stream {\n    \u002F\u002F partial: TripIdeas.PartiallyGenerated (all properties Optional)\n    print(partial)\n}\n```\n\n### SwiftUI Integration\n\n```swift\n@State private var partialResult: TripIdeas.PartiallyGenerated?\n@State private var errorMessage: String?\n\nvar body: some View {\n    List {\n        ForEach(partialResult?.ideas ?? [], id: \\.self) { idea in\n            Text(idea)\n        }\n    }\n    .overlay {\n        if let errorMessage { Text(errorMessage).foregroundStyle(.red) }\n    }\n    .task {\n        do {\n            let stream = session.streamResponse(to: prompt, generating: TripIdeas.self)\n            for try await partial in stream {\n                partialResult = partial\n            }\n        } catch {\n            errorMessage = error.localizedDescription\n        }\n    }\n}\n```\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| On-device execution | Privacy — no data leaves the device; works offline |\n| 4,096 token limit | On-device model constraint; chunk large data across sessions |\n| Snapshot streaming (not deltas) | Structured output friendly; each snapshot is a complete partial state |\n| `@Generable` macro | Compile-time safety for structured generation; auto-generates `PartiallyGenerated` type |\n| Single request per session | `isResponding` prevents concurrent requests; create multiple sessions if needed |\n| `response.content` (not `.output`) | Correct API — always access results via `.content` property |\n\n## Best Practices\n\n- **Always check `model.availability`** before creating a session — handle all unavailability cases\n- **Use `instructions`** to guide model behavior — they take priority over prompts\n- **Check `isResponding`** before sending a new request — sessions handle one request at a time\n- **Access `response.content`** for results — not `.output`\n- **Break large inputs into chunks** — 4,096 token limit applies to instructions + prompt + output combined\n- **Use `@Generable`** for structured output — stronger guarantees than parsing raw strings\n- **Use `GenerationOptions(temperature:)`** to tune creativity (higher = more creative)\n- **Monitor with Instruments** — use Xcode Instruments to profile request performance\n\n## Anti-Patterns to Avoid\n\n- Creating sessions without checking `model.availability` first\n- Sending inputs exceeding the 4,096 token context window\n- Attempting concurrent requests on a single session\n- Using `.output` instead of `.content` to access response data\n- Parsing raw string responses when `@Generable` structured output would work\n- Building complex multi-step logic in a single prompt — break into multiple focused prompts\n- Assuming the model is always available — device eligibility and settings vary\n\n## When to Use\n\n- On-device text generation for privacy-sensitive apps\n- Structured data extraction from user input (forms, natural language commands)\n- AI-assisted features that must work offline\n- Streaming UI that progressively shows generated content\n- Domain-specific AI actions via tool calling (search, compute, lookup)\n","# FoundationModels: On-Device LLM (iOS 26)\n\nPatterns for integrating Apple's on-device language model into apps using the FoundationModels framework. Covers text generation, structured output with `@Generable`, custom tool calling, and snapshot streaming — all running on-device for privacy and offline support.\n\n## When to Activate\n\n- Building AI-powered features using Apple Intelligence on-device\n- Generating or summarizing text without cloud dependency\n- Extracting structured data from natural language input\n- Implementing custom tool calling for domain-specific AI actions\n- Streaming structured responses for real-time UI updates\n- Need privacy-preserving AI (no data leaves the device)\n\n## Core Pattern — Availability Check\n\nAlways check model availability before creating a session:\n\n```swift\nstruct GenerativeView: View {\n    private var model = SystemLanguageModel.default\n\n    var body: some View {\n        switch model.availability {\n        case .available:\n            ContentView()\n        case .unavailable(.deviceNotEligible):\n            Text(\"Device not eligible for Apple Intelligence\")\n        case .unavailable(.appleIntelligenceNotEnabled):\n            Text(\"Please enable Apple Intelligence in Settings\")\n        case .unavailable(.modelNotReady):\n            Text(\"Model is downloading or not ready\")\n        case .unavailable(let other):\n            Text(\"Model unavailable: \\(other)\")\n        }\n    }\n}\n```\n\n## Core Pattern — Basic Session\n\n```swift\n\u002F\u002F Single-turn: create a new session each time\nlet session = LanguageModelSession()\nlet response = try await session.respond(to: \"What's a good month to visit Paris?\")\nprint(response.content)\n\n\u002F\u002F Multi-turn: reuse session for conversation context\nlet session = LanguageModelSession(instructions: \"\"\"\n    You are a cooking assistant.\n    Provide recipe suggestions based on ingredients.\n    Keep suggestions brief and practical.\n    \"\"\")\n\nlet first = try await session.respond(to: \"I have chicken and rice\")\nlet followUp = try await session.respond(to: \"What about a vegetarian option?\")\n```\n\nKey points for instructions:\n- Define the model's role (\"You are a mentor\")\n- Specify what to do (\"Help extract calendar events\")\n- Set style preferences (\"Respond as briefly as possible\")\n- Add safety measures (\"Respond with 'I can't help with that' for dangerous requests\")\n\n## Core Pattern — Guided Generation with @Generable\n\nGenerate structured Swift types instead of raw strings:\n\n### 1. Define a Generable Type\n\n```swift\n@Generable(description: \"Basic profile information about a cat\")\nstruct CatProfile {\n    var name: String\n\n    @Guide(description: \"The age of the cat\", .range(0...20))\n    var age: Int\n\n    @Guide(description: \"A one sentence profile about the cat's personality\")\n    var profile: String\n}\n```\n\n### 2. Request Structured Output\n\n```swift\nlet response = try await session.respond(\n    to: \"Generate a cute rescue cat\",\n    generating: CatProfile.self\n)\n\n\u002F\u002F Access structured fields directly\nprint(\"Name: \\(response.content.name)\")\nprint(\"Age: \\(response.content.age)\")\nprint(\"Profile: \\(response.content.profile)\")\n```\n\n### Supported @Guide Constraints\n\n- `.range(0...20)` — numeric range\n- `.count(3)` — array element count\n- `description:` — semantic guidance for generation\n\n## Core Pattern — Tool Calling\n\nLet the model invoke custom code for domain-specific tasks:\n\n### 1. Define a Tool\n\n```swift\nstruct RecipeSearchTool: Tool {\n    let name = \"recipe_search\"\n    let description = \"Search for recipes matching a given term and return a list of results.\"\n\n    @Generable\n    struct Arguments {\n        var searchTerm: String\n        var numberOfResults: Int\n    }\n\n    func call(arguments: Arguments) async throws -> ToolOutput {\n        let recipes = await searchRecipes(\n            term: arguments.searchTerm,\n            limit: arguments.numberOfResults\n        )\n        return .string(recipes.map { \"- \\($0.name): \\($0.description)\" }.joined(separator: \"\\n\"))\n    }\n}\n```\n\n### 2. Create Session with Tools\n\n```swift\nlet session = LanguageModelSession(tools: [RecipeSearchTool()])\nlet response = try await session.respond(to: \"Find me some pasta recipes\")\n```\n\n### 3. Handle Tool Errors\n\n```swift\ndo {\n    let answer = try await session.respond(to: \"Find a recipe for tomato soup.\")\n} catch let error as LanguageModelSession.ToolCallError {\n    print(error.tool.name)\n    if case .databaseIsEmpty = error.underlyingError as? RecipeSearchToolError {\n        \u002F\u002F Handle specific tool error\n    }\n}\n```\n\n## Core Pattern — Snapshot Streaming\n\nStream structured responses for real-time UI with `PartiallyGenerated` types:\n\n```swift\n@Generable\nstruct TripIdeas {\n    @Guide(description: \"Ideas for upcoming trips\")\n    var ideas: [String]\n}\n\nlet stream = session.streamResponse(\n    to: \"What are some exciting trip ideas?\",\n    generating: TripIdeas.self\n)\n\nfor try await partial in stream {\n    \u002F\u002F partial: TripIdeas.PartiallyGenerated (all properties Optional)\n    print(partial)\n}\n```\n\n### SwiftUI Integration\n\n```swift\n@State private var partialResult: TripIdeas.PartiallyGenerated?\n@State private var errorMessage: String?\n\nvar body: some View {\n    List {\n        ForEach(partialResult?.ideas ?? [], id: \\.self) { idea in\n            Text(idea)\n        }\n    }\n    .overlay {\n        if let errorMessage { Text(errorMessage).foregroundStyle(.red) }\n    }\n    .task {\n        do {\n            let stream = session.streamResponse(to: prompt, generating: TripIdeas.self)\n            for try await partial in stream {\n                partialResult = partial\n            }\n        } catch {\n            errorMessage = error.localizedDescription\n        }\n    }\n}\n```\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| On-device execution | Privacy — no data leaves the device; works offline |\n| 4,096 token limit | On-device model constraint; chunk large data across sessions |\n| Snapshot streaming (not deltas) | Structured output friendly; each snapshot is a complete partial state |\n| `@Generable` macro | Compile-time safety for structured generation; auto-generates `PartiallyGenerated` type |\n| Single request per session | `isResponding` prevents concurrent requests; create multiple sessions if needed |\n| `response.content` (not `.output`) | Correct API — always access results via `.content` property |\n\n## Best Practices\n\n- **Always check `model.availability`** before creating a session — handle all unavailability cases\n- **Use `instructions`** to guide model behavior — they take priority over prompts\n- **Check `isResponding`** before sending a new request — sessions handle one request at a time\n- **Access `response.content`** for results — not `.output`\n- **Break large inputs into chunks** — 4,096 token limit applies to instructions + prompt + output combined\n- **Use `@Generable`** for structured output — stronger guarantees than parsing raw strings\n- **Use `GenerationOptions(temperature:)`** to tune creativity (higher = more creative)\n- **Monitor with Instruments** — use Xcode Instruments to profile request performance\n\n## Anti-Patterns to Avoid\n\n- Creating sessions without checking `model.availability` first\n- Sending inputs exceeding the 4,096 token context window\n- Attempting concurrent requests on a single session\n- Using `.output` instead of `.content` to access response data\n- Parsing raw string responses when `@Generable` structured output would work\n- Building complex multi-step logic in a single prompt — break into multiple focused prompts\n- Assuming the model is always available — device eligibility and settings vary\n\n## When to Use\n\n- On-device text generation for privacy-sensitive apps\n- Structured data extraction from user input (forms, natural language commands)\n- AI-assisted features that must work offline\n- Streaming UI that progressively shows generated content\n- Domain-specific AI actions via tool calling (search, compute, lookup)\n",{"name":5,"description":7},"main","f37de8f681f0c0ca0e0ebab6e5fddf764ca7553d","skills\u002Ffoundation-models-on-device",1,"https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one","https:\u002F\u002Fagisota.github.io\u002Fold-one\u002F","https:\u002F\u002Fgithub.com\u002Fagisota","pzd.world","2026-07-04 22:32:06",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add agisota\u002Fold-one --skill foundation-models-on-device",{"tool":38,"command":39},"bunx","bunx skills add agisota\u002Fold-one --skill foundation-models-on-device",{"tool":41,"command":42},"pnpm","pnpm dlx skills add agisota\u002Fold-one --skill foundation-models-on-device","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Ffoundation-models-on-device\u002FSKILL.md",true,[],[47,54,61,70,77,84],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M75KRGZWQWE9JDBS6RX42NWV","zoom-out","Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-out\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M75KRCZHKE0ZYAQFFYHS0YNP","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":65,"licenseFileUrl":66,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M75KR94KYQ30DTE1P9WNDAE0","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M75KR3H13YJ9QHMD49818FA1","yara-rule-authoring","Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyara-rule-authoring\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M75KQMPY8A4Y8XTDD2DT0M9T","x-twitter-growth","X\u002FTwitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X\u002FTwitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-twitter-growth\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M75KQHNZ0ANZNJGZY6M8MDAK","x-api","X\u002FTwitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-api\u002FSKILL.md",[],[]]