@mmerterden/multi-agent-pipeline 20.7.0 → 20.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +0 -10
  3. package/docs/facts.json +1 -1
  4. package/manifest.json +285 -285
  5. package/package.json +3 -3
  6. package/pipeline/lib/redact.mjs +3 -2
  7. package/pipeline/scripts/_notices.mjs +1 -1
  8. package/pipeline/scripts/gen-skills-index.mjs +13 -1
  9. package/pipeline/scripts/pre-commit-check.sh +4 -0
  10. package/pipeline/skills/.skill-manifest.json +69 -69
  11. package/pipeline/skills/shared/README.md +70 -70
  12. package/pipeline/skills/shared/external/alarmkit/SKILL.md +373 -381
  13. package/pipeline/skills/shared/external/alarmkit/evals/evals.json +23 -18
  14. package/pipeline/skills/shared/external/alarmkit/references/alarmkit-patterns.md +328 -378
  15. package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
  16. package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
  17. package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
  18. package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
  19. package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
  20. package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
  21. package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
  22. package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
  23. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +345 -277
  24. package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
  25. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +107 -121
  26. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +145 -165
  27. package/pipeline/skills/shared/external/app-store-review/SKILL.md +306 -326
  28. package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
  29. package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
  30. package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
  31. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +335 -360
  32. package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
  33. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
  34. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
  35. package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
  36. package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
  37. package/pipeline/skills/shared/external/authentication/SKILL.md +277 -381
  38. package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
  39. package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +135 -178
  40. package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
  41. package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
  42. package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
  43. package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
  44. package/pipeline/skills/shared/external/background-processing/SKILL.md +274 -384
  45. package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
  46. package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +173 -321
  47. package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
  48. package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
  49. package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
  50. package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
  51. package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
  52. package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
  53. package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
  54. package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
  55. package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
  56. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +228 -376
  57. package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
  58. package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
  59. package/pipeline/skills/shared/external/core-data/SKILL.md +302 -368
  60. package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
  61. package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
  62. package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
  63. package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
  64. package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
  65. package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
  66. package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
  67. package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
  68. package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
  69. package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
  70. package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
  71. package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
  72. package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
  73. package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
  74. package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
  75. package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
  76. package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
  77. package/pipeline/skills/shared/external/device-integrity/SKILL.md +236 -353
  78. package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
  79. package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
  80. package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
  81. package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
  82. package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
  83. package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
  84. package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
  85. package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
  86. package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
  87. package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
  88. package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
  89. package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
  90. package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
  91. package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
  92. package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
  93. package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
  94. package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
  95. package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
  96. package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
  97. package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
  98. package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
  99. package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
  100. package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
  101. package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
  102. package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
  103. package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
  104. package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
  105. package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
  106. package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
  107. package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
  108. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
  109. package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
  110. package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
  111. package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
  112. package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
  113. package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
  114. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +3 -3
  115. package/pipeline/skills/shared/external/localization-reuse-map/example-mapping.json +1 -1
  116. package/pipeline/skills/shared/external/localization-reuse-map/reference/format-and-output.md +8 -7
  117. package/pipeline/skills/shared/external/localization-reuse-map/reference/publish-and-snapshot.md +2 -2
  118. package/pipeline/skills/shared/external/localization-reuse-map/reference/sources-and-recipes.md +5 -2
  119. package/pipeline/skills/shared/external/localization-reuse-map/scripts/_shared.py +100 -0
  120. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-artifact.py +45 -26
  121. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-spreadsheet.py +14 -16
  122. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-annotations.py +12 -5
  123. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-legacy-labels.py +2 -1
  124. package/pipeline/skills/shared/external/localization-reuse-map/scripts/publish-confluence.py +6 -5
  125. package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-overlay.py +44 -18
  126. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-legacy-values.py +5 -2
  127. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-new-values.py +10 -11
  128. package/pipeline/skills/shared/external/localization-reuse-map/scripts/scan-screen-keys.py +4 -33
  129. package/pipeline/skills/shared/external/localization-reuse-map/scripts/verify-map.py +12 -59
  130. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +297 -267
  131. package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
  132. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
  133. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
  134. package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
  135. package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
  136. package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
  137. package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
  138. package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
  139. package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
  140. package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
  141. package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
  142. package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
  143. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
  144. package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
  145. package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
  146. package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
  147. package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
  148. package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
  149. package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
  150. package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
  151. package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
  152. package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
  153. package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
  154. package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
  155. package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
  156. package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
  157. package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
  158. package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
  159. package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
  160. package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
  161. package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
  162. package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
  163. package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
  164. package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
  165. package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
  166. package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
  167. package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
  168. package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
  169. package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
  170. package/pipeline/skills/shared/external/skill-creator/template.md +7 -1
  171. package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
  172. package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
  173. package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
  174. package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
  175. package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
  176. package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
  177. package/pipeline/skills/shared/external/storekit/references/core-patterns.md +302 -241
  178. package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
  179. package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
  180. package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
  181. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
  182. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
  183. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
  184. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
  185. package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
  186. package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
  187. package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
  188. package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
  189. package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
  190. package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
  191. package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
  192. package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +304 -351
  193. package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
  194. package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
  195. package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
  196. package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
  197. package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
  198. package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
  199. package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
  200. package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
  201. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
  202. package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
  203. package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
  204. package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
  205. package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
  206. package/pipeline/skills/shared/external/swift-security/SKILL.md +183 -162
  207. package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
  208. package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
  209. package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +411 -476
  210. package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
  211. package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
  212. package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
  213. package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
  214. package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
  215. package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
  216. package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +375 -491
  217. package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
  218. package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
  219. package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
  220. package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +397 -457
  221. package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
  222. package/pipeline/skills/shared/external/swift-testing/SKILL.md +191 -175
  223. package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
  224. package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +81 -84
  225. package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
  226. package/pipeline/skills/shared/external/swiftdata/SKILL.md +394 -256
  227. package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
  228. package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
  229. package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
  230. package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
  231. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
  232. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
  233. package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
  234. package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
  235. package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
  236. package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
  237. package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
  238. package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
  239. package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
  240. package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
  241. package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
  242. package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
  243. package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
  244. package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
  245. package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
  246. package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
  247. package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
  248. package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
  249. package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
  250. package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
  251. package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +201 -168
  252. package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
  253. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +134 -133
  254. package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
  255. package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +111 -138
  256. package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
  257. package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
  258. package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
  259. package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
  260. package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
  261. package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
  262. package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
  263. package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
  264. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
  265. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
  266. package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
  267. package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
  268. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
  269. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
  270. package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
  271. package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
  272. package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
  273. package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
  274. package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
  275. package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
  276. package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
  277. package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
  278. package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
  279. package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
  280. package/pipeline/skills/shared/external/weatherkit/SKILL.md +160 -315
  281. package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
  282. package/pipeline/skills/shared/external/widgetkit/SKILL.md +224 -288
  283. package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +416 -719
  284. package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
@@ -1,493 +1,468 @@
1
1
  ---
2
2
  name: apple-on-device-ai
3
- description: "Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, quantization, palettization, pruning, Neural Engine, MLTensor), MLX Swift (transformer inference, unified memory), and llama.cpp (GGUF, cross-platform LLM). Use when building tool-calling AI features, working with guided generation schemas, converting models, or running on-device inference."
3
+ description: "On-device AI on Apple hardware: Foundation Models (SystemLanguageModel, LanguageModelSession, @Generable and @Guide structured output, tool calling), coremltools conversion, quantization, palettization, pruning, Neural Engine, MLX Swift transformer inference on unified memory, llama.cpp GGUF models. Use when building tool-calling AI features, designing guided generation schemas, converting a model or running inference on device. Not for Swift-side Core ML integration (coreml), OCR, sentiment, NER or classifier training."
4
4
  metadata:
5
- source: "dpearson2699/swift-ios-skills (PolyForm Perimeter 1.0.0)"
5
+ source: multi-agent-pipeline
6
6
  ---
7
7
 
8
- # On-Device AI for Apple Platforms
8
+ # On-device AI on Apple platforms
9
9
 
10
- Guide for selecting, deploying, and optimizing on-device ML models. Covers Apple
11
- Foundation Models, Core ML, MLX Swift, and llama.cpp.
10
+ Four stacks run models locally on Apple hardware. Pick by the job, the OS floor
11
+ and the model you need, then follow the stack's rules for availability, memory
12
+ and testing.
12
13
 
13
14
  ## Contents
14
15
 
15
- - [Framework Selection Router](#framework-selection-router)
16
- - [Apple Foundation Models Overview](#apple-foundation-models-overview)
17
- - [Core ML Overview](#core-ml-overview)
18
- - [MLX Swift Overview](#mlx-swift-overview)
19
- - [Multi-Backend Architecture](#multi-backend-architecture)
20
- - [Performance Best Practices](#performance-best-practices)
21
- - [Common Mistakes](#common-mistakes)
22
- - [Review Checklist](#review-checklist)
23
- - [References](#references)
16
+ - [Choosing a stack](#choosing-a-stack)
17
+ - [Foundation Models](#foundation-models)
18
+ - [Core ML](#core-ml)
19
+ - [MLX Swift](#mlx-swift)
20
+ - [Running several backends](#running-several-backends)
21
+ - [Performance habits](#performance-habits)
22
+ - [Mistakes to catch](#mistakes-to-catch)
23
+ - [Before approving](#before-approving)
24
+ - [Reference files](#reference-files)
24
25
 
25
- ## Framework Selection Router
26
+ ## Choosing a stack
26
27
 
27
- Use this decision tree to pick the right framework for your use case.
28
+ **Foundation Models** gives apps the system language model. It runs on iOS 26+
29
+ and macOS 26+ where Apple Intelligence is enabled, and covers summaries, text
30
+ generation, typed output, pulling entities out of text, and brief back-and-forth
31
+ chat. The app ships no API key, runs no server and makes no network call, yet it
32
+ still has to cope with model assets that are not downloaded yet.
28
33
 
29
- ### Apple Foundation Models
34
+ - Fits: typed output with `@Generable`; summarizing, classifying and tagging;
35
+ generation that calls app code through the `Tool` protocol; features where
36
+ data must stay on the device.
37
+ - Does not fit: complex math, writing code, answers that must be factually
38
+ right, or apps that still support releases before iOS 26.
30
39
 
31
- **When to use:** Text generation, summarization, entity extraction, structured
32
- output, and short dialog on iOS 26+ / macOS 26+ devices with Apple Intelligence
33
- enabled. No app-managed API key, network round trip, or model hosting; still
34
- handle system model asset readiness.
40
+ **Core ML** runs models you trained yourself (vision, text, audio) on every
41
+ Apple platform, after coremltools converts them from scikit-learn, TensorFlow
42
+ or PyTorch.
35
43
 
36
- **Best for:**
37
- - Generating text or structured data with `@Generable` types
38
- - Summarization, classification, content tagging
39
- - Tool-augmented generation with the `Tool` protocol
40
- - Apps that need guaranteed on-device privacy
44
+ - Fits: image classification, detection and segmentation; custom text or
45
+ sentiment classifiers; audio through SoundAnalysis; tuning for the Neural
46
+ Engine; models that need compressing by quantization, pruning or
47
+ palettization.
41
48
 
42
- **Not suited for:** Complex math, code generation, factual accuracy tasks,
43
- or apps targeting pre-iOS 26 devices.
49
+ **MLX Swift** runs particular open-weight models (Gemma, Qwen, Mistral, Llama)
50
+ and reaches the best sustained speed on Apple Silicon. It is also a good
51
+ research and prototyping tool.
44
52
 
45
- ### Core ML
53
+ - Fits: highest token rate on Apple Silicon; models from the `mlx-community`
54
+ organisation on Hugging Face; research that needs automatic differentiation;
55
+ fine-tuning on a Mac.
46
56
 
47
- **When to use:** Deploying custom trained models (vision, NLP, audio) across all
48
- Apple platforms. Converting models from PyTorch, TensorFlow, or scikit-learn
49
- with coremltools.
57
+ **llama.cpp** runs GGUF models on nearly any platform and suits production apps
58
+ that need wide device coverage.
50
59
 
51
- **Best for:**
52
- - Image classification, object detection, segmentation
53
- - Custom NLP classifiers, sentiment analysis models
54
- - Audio/speech models via SoundAnalysis integration
55
- - Any scenario needing Neural Engine optimization
56
- - Models requiring quantization, palettization, or pruning
60
+ - Fits: quantized GGUF files (Q4_K_M, Q5_K_M, Q8_0); one engine across iOS,
61
+ Android and desktop; the broadest open model ecosystem.
57
62
 
58
- ### MLX Swift
63
+ Quick routing:
59
64
 
60
- **When to use:** Running specific open-source LLMs (Llama, Mistral, Qwen, Gemma)
61
- on Apple Silicon with maximum throughput. Research and prototyping.
62
-
63
- **Best for:**
64
- - Highest sustained token generation on Apple Silicon
65
- - Running Hugging Face models from `mlx-community`
66
- - Research requiring automatic differentiation
67
- - Fine-tuning workflows on Mac
68
-
69
- ### llama.cpp
70
-
71
- **When to use:** Cross-platform LLM inference using GGUF model format. Production
72
- deployments needing broad device support.
73
-
74
- **Best for:**
75
- - GGUF quantized models (Q4_K_M, Q5_K_M, Q8_0)
76
- - Cross-platform apps (iOS + Android + desktop)
77
- - Maximum compatibility with open-source model ecosystem
78
-
79
- ### Quick Reference
80
-
81
- | Scenario | Framework |
65
+ | Need | Go to |
82
66
  |---|---|
83
- | Text generation on Apple Intelligence devices (iOS 26+) | Foundation Models |
84
- | Structured output from on-device LLM | Foundation Models (`@Generable`) |
85
- | Image classification, object detection | Core ML |
86
- | Custom model from PyTorch/TensorFlow | Core ML + coremltools |
87
- | Running specific open-source LLMs | MLX Swift or llama.cpp |
88
- | Maximum throughput on Apple Silicon | MLX Swift |
89
- | Cross-platform LLM inference | llama.cpp |
90
- | OCR and text recognition | Vision framework |
91
- | Sentiment analysis, NER, tokenization | Natural Language framework |
92
- | Training custom classifiers on device | Create ML |
67
+ | Generate text where Apple Intelligence is on (iOS 26+) | Foundation Models |
68
+ | Typed LLM output | Foundation Models, `@Generable` |
69
+ | Image classification or object detection | Core ML |
70
+ | Bring a PyTorch or TensorFlow model | Core ML, converted with coremltools |
71
+ | Top speed on Apple Silicon | MLX Swift |
72
+ | A named open-weight LLM | MLX Swift or llama.cpp |
73
+ | One LLM engine on every platform | llama.cpp |
74
+ | Read text in images (OCR) | Vision |
75
+ | Sentiment, named entities, tokenization | Natural Language |
76
+ | Train a custom classifier on device | Create ML |
93
77
 
94
- ## Apple Foundation Models Overview
78
+ ## Foundation Models
95
79
 
96
- On-device language model optimized for Apple Silicon. Available on devices
97
- supporting Apple Intelligence (iOS 26+, macOS 26+).
80
+ Facts that shape every design:
98
81
 
99
- - Token budget covers input + output; check `contextSize` for the limit
100
- - Resolve locale before generation by checking `supportsLocale(_:)` against
101
- `Locale.current` and preferred fallbacks; do not raw-match `supportedLanguages`
102
- - Guardrails always enforced, cannot be disabled
82
+ - Prompt and reply draw on one token budget. `contextSize` gives its size.
83
+ - Choose the locale before generating: try `Locale.current`, then the user's
84
+ other preferred languages, with `supportsLocale(_:)`. Do not match against
85
+ `supportedLanguages` yourself.
86
+ - Guardrails are always on and cannot be disabled.
103
87
 
104
- ### Availability Checking (Required)
88
+ ### Check availability first
105
89
 
106
- Always check before using. Never crash on unavailability.
90
+ Every entry point checks availability and falls back without crashing.
107
91
 
108
92
  ```swift
93
+ import Foundation
109
94
  import FoundationModels
110
-
111
- switch SystemLanguageModel.default.availability {
112
- case .available:
113
- guard SystemLanguageModel.default.supportsLocale(Locale.current) else {
114
- // Use locale fallback before generating
115
- break
95
+ import os
96
+
97
+ private let aiLog = Logger(subsystem: "StudyApp", category: "AI")
98
+
99
+ enum SummaryState { case ready, openSettings, downloading, unsupported }
100
+
101
+ func summaryState() -> SummaryState {
102
+ let model = SystemLanguageModel.default
103
+ switch model.availability {
104
+ case .available:
105
+ return model.supportsLocale(Locale.current) ? .ready : .unsupported
106
+ case .unavailable(.appleIntelligenceNotEnabled):
107
+ return .openSettings // point the user to Settings
108
+ case .unavailable(.modelNotReady):
109
+ return .downloading // assets still arriving; show progress
110
+ case .unavailable(.deviceNotEligible):
111
+ return .unsupported // hardware cannot run it; use a fallback
112
+ case .unavailable(let other):
113
+ aiLog.notice("Model unavailable: \(String(describing: other))")
114
+ return .unsupported
116
115
  }
117
- // Proceed with model usage
118
- case .unavailable(.appleIntelligenceNotEnabled):
119
- // Guide user to enable Apple Intelligence in Settings
120
- case .unavailable(.modelNotReady):
121
- // System model assets are not ready; show loading state
122
- case .unavailable(.deviceNotEligible):
123
- // Device cannot run Apple Intelligence; use fallback
124
- case .unavailable(let reason):
125
- // Unknown or future unavailable reason; use fallback and log reason
126
116
  }
127
117
  ```
128
118
 
129
- ### Session Management
119
+ ### Sessions
130
120
 
131
121
  ```swift
132
- // Basic session
133
- let session = LanguageModelSession()
122
+ let plain = LanguageModelSession()
134
123
 
135
- // Session with instructions
136
- let session = LanguageModelSession {
137
- "You are a helpful cooking assistant."
124
+ let tutor = LanguageModelSession {
125
+ "You write short study notes for high-school biology."
138
126
  }
139
127
 
140
- // Session with tools
141
- let session = LanguageModelSession(
142
- tools: [weatherTool, recipeTool]
143
- ) {
144
- "You are a helpful assistant with access to tools."
128
+ let withTools = LanguageModelSession(tools: [GlossaryTool()]) {
129
+ "Explain terms using the glossary when a term is unfamiliar."
145
130
  }
131
+
132
+ let resumed = LanguageModelSession(model: .default, tools: [], transcript: savedTranscript)
146
133
  ```
147
134
 
148
- Key rules:
149
- - Sessions are stateful -- multi-turn conversations maintain context automatically
150
- - One request at a time per session (check `session.isResponding`)
151
- - Call `session.prewarm()` before user interaction for faster first response
152
- - Save/restore transcripts: `LanguageModelSession(model: model, tools: [], transcript: savedTranscript)`
135
+ - A session remembers the conversation; each turn sees the ones before it.
136
+ - A session serves a single request at once. `isResponding` is true while one
137
+ is in flight.
138
+ - Prewarm with `session.prewarm()` ahead of the user's first question so the
139
+ first reply arrives sooner.
140
+ - Restore a conversation by passing a saved `Transcript`.
153
141
 
154
- ### Structured Output with `@Generable`
142
+ ### Structured output
155
143
 
156
- The `@Generable` macro creates compile-time schemas for type-safe output:
144
+ `@Generable` builds the output schema at compile time, and the response comes
145
+ back as your type.
157
146
 
158
147
  ```swift
159
148
  @Generable
160
- struct Recipe {
161
- @Guide(description: "The recipe name")
162
- var name: String
163
-
164
- @Guide(description: "Cooking steps", .count(3))
165
- var steps: [String]
166
-
167
- @Guide(description: "Prep time in minutes", .range(1...120))
168
- var prepTime: Int
149
+ struct StudyCard {
150
+ @Guide(description: "The term being studied, two to four words")
151
+ var term: String
152
+ @Guide(description: "Plain-language definitions", .count(2))
153
+ var definitions: [String]
154
+ @Guide(.range(1...5))
155
+ var difficulty: Int
169
156
  }
170
157
 
171
- let response = try await session.respond(
172
- to: "Suggest a quick pasta recipe",
173
- generating: Recipe.self
174
- )
175
- print(response.content.name)
158
+ let reply = try await tutor.respond(to: "Make a card for osmosis",
159
+ generating: StudyCard.self)
160
+ let card = reply.content
176
161
  ```
177
162
 
178
- #### `@Guide` Constraints
163
+ `@Guide` options:
179
164
 
180
- | Constraint | Purpose |
165
+ | Guide | Effect |
181
166
  |---|---|
182
- | `description:` | Natural language hint for generation |
183
- | `.anyOf([values])` | Restrict to enumerated string values |
184
- | `.count(n)` | Fixed array length |
185
- | `.range(min...max)` | Numeric range |
186
- | `.minimum(n)` / `.maximum(n)` | One-sided numeric bound |
187
- | `.minimumCount(n)` / `.maximumCount(n)` | Array length bounds |
188
- | `.constant(value)` | Always returns this value |
189
- | `.pattern(regex)` | String format enforcement |
190
- | `.element(guide)` | Guide applied to each array element |
191
-
192
- Properties generate in declaration order. Place foundational data before
193
- dependent data for better results.
194
-
195
- ### Streaming Structured Output
167
+ | `description:` | Natural-language hint for the field |
168
+ | `.anyOf([...])` | String must be one of the listed values |
169
+ | `.count(n)` | Array has exactly `n` elements |
170
+ | `.range(a...b)` | Number within a closed range |
171
+ | `.minimum(n)` / `.maximum(n)` | Lower or upper limit on a number |
172
+ | `.minimumCount(n)` / `.maximumCount(n)` | Limits on how many elements an array has |
173
+ | `.constant(value)` | Field is always exactly this |
174
+ | `.pattern(regex)` | String matches a pattern |
175
+ | `.element(guide)` | Applies a guide to every array element |
176
+
177
+ Fields are generated in declaration order. Put the fields that others depend on
178
+ first.
179
+
180
+ Streaming gives partial values as they form; each property of
181
+ `StudyCard.PartiallyGenerated` is optional:
196
182
 
197
183
  ```swift
198
- let stream = session.streamResponse(
199
- to: "Suggest a recipe",
200
- generating: Recipe.self
201
- )
202
- for try await snapshot in stream {
203
- // snapshot.content is Recipe.PartiallyGenerated (all properties optional)
204
- if let name = snapshot.content.name { updateNameLabel(name) }
184
+ let cardStream = tutor.streamResponse(to: "Card for diffusion", generating: StudyCard.self)
185
+ for try await partial in cardStream {
186
+ draft.term = partial.content.term ?? draft.term
187
+ draft.definitions = partial.content.definitions ?? draft.definitions
205
188
  }
206
189
  ```
207
190
 
208
- ### Tool Calling
191
+ ### Tools
209
192
 
210
193
  ```swift
211
- struct WeatherTool: Tool {
212
- let name = "weather"
213
- let description = "Get current weather for a city."
194
+ struct GlossaryTool: Tool {
195
+ let name = "lookUpTerm"
196
+ let description = "Returns the course glossary entry for a biology term."
214
197
 
215
198
  @Generable
216
199
  struct Arguments {
217
- @Guide(description: "The city name")
218
- var city: String
200
+ @Guide(description: "Singular form of the term to look up")
201
+ var term: String
202
+ @Guide(.range(1...3))
203
+ var gradeLevel: Int
219
204
  }
220
205
 
221
206
  func call(arguments: Arguments) async throws -> String {
222
- let weather = try await fetchWeather(arguments.city)
223
- return weather.description
207
+ await Glossary.shared.entry(for: arguments.term, level: arguments.gradeLevel)
208
+ ?? "No entry found."
224
209
  }
225
210
  }
226
211
  ```
227
212
 
228
- Register only necessary tools at session creation. `Tool` is `Sendable`; tool
229
- descriptors and `@Generable` schemas consume the shared context window. The
230
- model chooses when to call tools, so prefetch deterministic required data into
231
- the prompt and reserve autonomous tools for dynamic lookups.
213
+ - Register tools when creating the session, and only the ones the task needs.
214
+ - `Tool` is `Sendable`; captured state must be safe to share.
215
+ - Tool names, descriptions and argument schemas, like `@Generable` schemas,
216
+ use up part of the context budget.
217
+ - Whether a tool runs is the model's decision. Data the answer always needs
218
+ should be fetched beforehand and put in the prompt; keep tools for lookups
219
+ that depend on the conversation.
232
220
 
233
- ### Error Handling
221
+ ### Errors
234
222
 
235
223
  ```swift
236
224
  do {
237
- let response = try await session.respond(to: prompt)
238
- } catch let error as LanguageModelSession.GenerationError {
239
- switch error {
240
- case .guardrailViolation(let context):
241
- // Content triggered safety filters
242
- case .exceededContextWindowSize(let context):
243
- // Too many tokens; summarize and retry
244
- case .concurrentRequests(let context):
245
- // Another request is in progress on this session
246
- case .unsupportedLanguageOrLocale(let context):
247
- // Current locale not supported
248
- case .unsupportedGuide(let context):
249
- // A @Guide constraint is not supported
250
- case .assetsUnavailable(let context):
251
- // Model assets not available on device
252
- case .refusal(let refusal, _):
253
- // Model refused; stream refusal.explanation for details
254
- case .rateLimited(let context):
255
- // Too many requests; back off and retry
256
- case .decodingFailure(let context):
257
- // Response could not be decoded into the expected type
258
- default: break
225
+ let answer = try await tutor.respond(to: question)
226
+ show(answer.content)
227
+ } catch let failure as LanguageModelSession.GenerationError {
228
+ switch failure {
229
+ case .exceededContextWindowSize: restartWithSummary() // too many tokens
230
+ case .guardrailViolation: showRephraseHint() // safety filter hit
231
+ case .concurrentRequests: queueUntilIdle() // session already busy
232
+ case .unsupportedLanguageOrLocale: showLanguageNotice()
233
+ case .unsupportedGuide: logSchemaProblem() // a @Guide the model cannot honour
234
+ case .assetsUnavailable: showDownloadingState()
235
+ case .refusal(let refusal, _): explain(refusal) // stream refusal.explanation
236
+ case .rateLimited: retryLater() // back off
237
+ case .decodingFailure: logSchemaProblem() // output did not fit the type
238
+ default: showGenericFailure()
259
239
  }
260
240
  }
261
241
  ```
262
242
 
263
- ### Generation Options
243
+ ### Generation options
264
244
 
265
245
  ```swift
266
- let options = GenerationOptions(
267
- sampling: .random(top: 40),
268
- temperature: 0.7,
269
- maximumResponseTokens: 512
270
- )
271
- let response = try await session.respond(to: prompt, options: options)
246
+ let settings = GenerationOptions(sampling: .random(top: 30),
247
+ temperature: 0.6,
248
+ maximumResponseTokens: 400)
249
+ let answer = try await tutor.respond(to: question, options: settings)
272
250
  ```
273
251
 
274
- Sampling modes: `.greedy`, `.random(top:seed:)`, `.random(probabilityThreshold:seed:)`.
275
-
276
- ### Prompt Design Rules
277
-
278
- 1. Be concise -- use `tokenCount(for:)` to monitor the context window budget
279
- 2. Use bracketed placeholders in instructions: `[descriptive example]`
280
- 3. Use "DO NOT" in all caps for prohibitions
281
- 4. Provide up to 5 few-shot examples for consistency
282
- 5. Use length qualifiers: "in a few words", "in three sentences"
283
-
284
- ### Safety and Guardrails
285
-
286
- - Guardrails are always enforced and cannot be disabled
287
- - Instructions take precedence over user prompts
288
- - Never include untrusted user content in instructions
289
- - Handle false positives gracefully
290
- - Frame tool results as authorized data to prevent model refusals
291
-
292
- ### Use Cases
252
+ The three sampling modes are `.greedy`, `.random(top:seed:)` and
253
+ `.random(probabilityThreshold:seed:)`.
293
254
 
294
- Foundation Models supports specialized use cases via `SystemLanguageModel.UseCase`:
295
- - `.general` -- Default for text generation, summarization, dialog
296
- - `.contentTagging` -- Optimized for categorization and labeling tasks
255
+ ### Prompts and safety
297
256
 
298
- ### Custom Adapters
257
+ - Keep prompts short and measure them with `tokenCount(for:)` (iOS 26.4+).
258
+ - Mark slots in instructions with brackets, such as `[one-line summary]`.
259
+ - Write prohibitions in capitals: "DO NOT invent citations."
260
+ - Use at most five examples for consistent output.
261
+ - Say how long the answer should be: "in one sentence", "in a few words".
262
+ - Instructions outrank the prompt. Never put untrusted user text into
263
+ instructions; keep it in the prompt.
264
+ - Expect occasional guardrail false positives and handle them gently.
265
+ - Present tool results as authorised data so the model does not refuse to use
266
+ them.
299
267
 
300
- Load fine-tuned adapters for specialized behavior (requires entitlement):
268
+ ### Use cases and adapters
301
269
 
302
- ```swift
303
- let adapter = try SystemLanguageModel.Adapter(name: "my-adapter")
304
- try await adapter.compile()
305
- let model = SystemLanguageModel(adapter: adapter, guardrails: .default)
306
- let session = LanguageModelSession(model: model)
307
- ```
270
+ `SystemLanguageModel.UseCase` has `.general` (the default: generation,
271
+ summaries, dialog) and `.contentTagging` (labelling and categorising).
308
272
 
309
- > See [references/foundation-models.md](references/foundation-models.md) for
310
- > the complete Foundation Models API reference.
273
+ A fine-tuned adapter needs an entitlement. Load it with
274
+ `SystemLanguageModel.Adapter(name:)`, compile it with
275
+ `try await adapter.compile()`, wrap it as
276
+ `SystemLanguageModel(adapter: adapter, guardrails: .default)`, and pass that
277
+ model to `LanguageModelSession(model:)`.
311
278
 
312
- ## Core ML Overview
279
+ Full API detail: [the Foundation Models reference](references/foundation-models.md).
313
280
 
314
- Apple's framework for deploying trained models. Automatically dispatches to the
315
- optimal compute unit (CPU, GPU, or Neural Engine).
281
+ ## Core ML
316
282
 
317
- ### Model Formats
283
+ Core ML dispatches work to the CPU, GPU or Neural Engine by itself.
318
284
 
319
- | Format | Extension | When to Use |
320
- |---|---|---|
321
- | `.mlpackage` | Directory (mlprogram) | All new models (iOS 15+) |
322
- | `.mlmodel` | Single file (neuralnetwork) | Legacy only (iOS 11-14) |
323
- | `.mlmodelc` | Compiled | Pre-compiled for faster loading |
324
-
325
- Always use mlprogram (`.mlpackage`) for new work.
285
+ | Format | Use |
286
+ |---|---|
287
+ | `.mlpackage` (ML program) | Every new model; iOS 15+ |
288
+ | `.mlmodel` (neural network) | Older format, the only choice for iOS 11 to 14; do not use for new work |
289
+ | `.mlmodelc` | Compiled form that loads faster |
326
290
 
327
- ### Conversion Pipeline (coremltools)
291
+ New conversions always target the ML program format:
328
292
 
329
293
  ```python
294
+ import torch
330
295
  import coremltools as ct
331
296
 
332
- # PyTorch conversion (torch.jit.trace)
333
- model.eval() # CRITICAL: always call eval() before tracing
334
- traced = torch.jit.trace(model, example_input)
335
- mlmodel = ct.convert(
297
+ net = build_segmenter()
298
+ net.eval() # never trace in training mode
299
+ sample = torch.rand(1, 3, 256, 256)
300
+ traced = torch.jit.trace(net, sample)
301
+
302
+ segmenter = ct.convert(
336
303
  traced,
337
- inputs=[ct.TensorType(shape=(1, 3, 224, 224), name="image")],
304
+ convert_to="mlprogram",
338
305
  minimum_deployment_target=ct.target.iOS18,
339
- convert_to='mlprogram',
306
+ inputs=[ct.TensorType(name="frame", shape=sample.shape)],
340
307
  )
341
- mlmodel.save("Model.mlpackage")
308
+ segmenter.save("Segmenter.mlpackage")
342
309
  ```
343
310
 
344
- ### Optimization Techniques
311
+ Compression at a glance:
345
312
 
346
- | Technique | Size Reduction | Accuracy Impact | Best Compute Unit |
313
+ | Technique | Size cut | Accuracy risk | Best on |
347
314
  |---|---|---|---|
348
- | INT8 per-channel | ~4x | Low | CPU/GPU |
349
- | INT4 per-block | ~8x | Medium | GPU |
350
- | Palettization 4-bit | ~8x | Low-Medium | Neural Engine |
351
- | W8A8 (weights+activations) | ~4x | Low | ANE (A17 Pro/M4+) |
352
- | Pruning 75% | ~4x | Medium | CPU/ANE |
353
-
354
- ### Boundary with `coreml`
355
-
356
- This skill owns Python-side conversion, compression, profiling, and framework
357
- selection. Use the sibling `coreml` skill for Swift app integration, prediction
358
- APIs, runtime configuration, Vision request wiring, and detailed model loading.
315
+ | 4-bit palettization | about 8x | low to medium | Neural Engine |
316
+ | INT8, per channel | about 4x | low | CPU and GPU |
317
+ | INT4, per block | about 8x | medium | GPU |
318
+ | W8A8 (weights and activations) | about 4x | low | Neural Engine on A17 Pro and M4 or later |
319
+ | 75% pruning | about 4x | medium | CPU, Neural Engine |
359
320
 
360
- > See [references/coreml-conversion.md](references/coreml-conversion.md) for the
361
- > full conversion pipeline and [references/coreml-optimization.md](references/coreml-optimization.md)
362
- > for optimization techniques.
321
+ Boundary: this skill decides which framework to use and owns the Python side
322
+ (conversion, compression, profiling). The `coreml` skill owns the Swift side:
323
+ loading models in the app, runtime settings, calling predictions, `MLTensor`
324
+ pre- and post-processing, and hooking models into Vision requests. The
325
+ [optimization guide](references/coreml-optimization.md#mltensor) keeps a short
326
+ `MLTensor` example.
363
327
 
364
- ## MLX Swift Overview
328
+ Conversion: [the conversion guide](references/coreml-conversion.md).
329
+ Compression and profiling: [the optimization guide](references/coreml-optimization.md).
365
330
 
366
- Apple's ML framework for Swift. Highest sustained generation throughput on
367
- Apple Silicon via unified memory architecture.
331
+ ## MLX Swift
368
332
 
369
- ### Loading and Running LLMs
333
+ MLX Swift gets the highest sustained throughput on Apple Silicon because CPU
334
+ and GPU share unified memory.
370
335
 
371
336
  ```swift
372
- import MLX
373
- import MLXLLM
374
337
  import MLXLMCommon
338
+ import MLXLLM
375
339
  import MLXLMHFAPI
340
+ import MLX
376
341
 
377
- let container = try await LLMModelFactory.shared.loadContainer(
342
+ let factory = LLMModelFactory.shared
343
+ let modelContainer = try await factory.loadContainer(
378
344
  from: HubClient.default,
379
345
  using: TokenizersLoader(),
380
- configuration: .init(id: "mlx-community/Qwen3-4B-4bit")
346
+ configuration: ModelConfiguration(id: "mlx-community/Qwen3-1.7B-4bit")
381
347
  )
382
- let session = ChatSession(container)
383
- print(try await session.respond(to: "Hello"))
348
+ let chat = ChatSession(modelContainer)
349
+ let text = try await chat.respond(to: "List three uses of chlorophyll.")
384
350
  ```
385
351
 
386
- ### Model Selection by Device
352
+ Starting points by device:
387
353
 
388
- | Device | RAM | Recommended Model | RAM Usage |
389
- |---|---|---|---|
390
- | iPhone 12-14 | 4-6 GB | SmolLM2-135M or Qwen 2.5 0.5B | ~0.3 GB |
391
- | iPhone 15 Pro+ | 8 GB | Gemma 3n E4B 4-bit | ~3.5 GB |
392
- | Mac 8 GB | 8 GB | Llama 3.2 3B 4-bit | ~3 GB |
393
- | Mac 16 GB+ | 16 GB+ | Mistral 7B 4-bit | ~6 GB |
354
+ | Device and RAM | Resident memory | Suggested model |
355
+ |---|---|---|
356
+ | iPhone 12 to 14, 4 to 6 GB | about 0.3 GB | SmolLM2-135M, or Qwen 2.5 at 0.5B |
357
+ | iPhone 15 Pro or newer, 8 GB | about 3.5 GB | Gemma 3n E4B at 4 bits |
358
+ | Mac, 8 GB | about 3 GB | Llama 3.2 3B at 4 bits |
359
+ | Mac, 16 GB or more | about 6 GB | Mistral 7B at 4 bits |
394
360
 
395
- ### Memory Management
361
+ Memory rules:
396
362
 
397
- 1. Never exceed 60% of total RAM on iOS
398
- 2. Set MLX cache limits: `Memory.cacheLimit = 512 * 1024 * 1024`
399
- 3. Unload MLX and llama.cpp models on backgrounding or memory pressure; for MLX,
400
- also call `Memory.clearCache()` after generation-heavy phases
401
- 4. Use "Increased Memory Limit" entitlement for larger models
402
- 5. Validate MLX Swift and llama.cpp on physical Apple Silicon; Simulator cannot
403
- exercise Metal-dependent inference, memory, or performance
363
+ - On iOS stay under 60% of total RAM.
364
+ - Cap the MLX cache: `Memory.cacheLimit = 512 * 1024 * 1024`.
365
+ - Release llama.cpp and MLX models on backgrounding or a memory warning, and
366
+ after heavy MLX generation also call `Memory.clearCache()`.
367
+ - Larger models need the Increased Memory Limit entitlement.
368
+ - Test MLX and llama.cpp code on real Apple Silicon hardware. The Simulator
369
+ does not run Metal inference and shows neither real memory limits nor real
370
+ speed.
404
371
 
405
- > See [references/mlx-swift.md](references/mlx-swift.md) for full MLX Swift
406
- > patterns and llama.cpp integration.
372
+ MLX lifecycle, llama.cpp and GGUF: [the MLX and llama.cpp guide](references/mlx-swift.md).
407
373
 
408
- ## Multi-Backend Architecture
374
+ ## Running several backends
409
375
 
410
- When an app needs multiple AI backends (e.g., Foundation Models + MLX fallback):
376
+ Try the system model first, then a local open model, and fail clearly when
377
+ neither is there:
411
378
 
412
379
  ```swift
413
- func respond(to prompt: String) async throws -> String {
414
- if SystemLanguageModel.default.isAvailable {
415
- return try await foundationModelsRespond(prompt)
416
- } else if canLoadMLXModel() {
417
- return try await mlxRespond(prompt)
418
- } else {
419
- throw AIError.noBackendAvailable
420
- }
380
+ func pickBackend() async throws -> Backend {
381
+ let systemModel = SystemLanguageModel.default
382
+ if systemModel.isAvailable { return .foundationModels }
383
+ if await mlxModelCanLoad() { return .mlx }
384
+ throw AIError.noBackendAvailable
421
385
  }
422
386
  ```
423
387
 
424
- Serialize all model access through a coordinator actor to prevent contention:
388
+ Send every model call through one actor so requests never compete for the same
389
+ hardware. Actors are reentrant: a method that awaits lets the next caller in,
390
+ so an actor that only forwards the call does not serialise anything. Chain the
391
+ work instead:
425
392
 
426
393
  ```swift
427
- actor ModelCoordinator {
428
- func withExclusiveAccess<T>(_ work: () async throws -> T) async rethrows -> T {
429
- try await work()
394
+ actor InferenceGate {
395
+ private var last: Task<Void, Never>?
396
+
397
+ func exclusive<Value: Sendable>(
398
+ _ work: @escaping @Sendable () async throws -> Value
399
+ ) async throws -> Value {
400
+ let previous = last
401
+ let current = Task { () async throws -> Value in
402
+ await previous?.value
403
+ return try await work()
404
+ }
405
+ last = Task { _ = try? await current.value }
406
+ return try await current.value
430
407
  }
431
408
  }
432
409
  ```
433
410
 
434
- For custom Core ML models, name only the conversion/optimization handoff here:
435
- send Swift app integration, model loading, Vision wiring, and prediction
436
- lifecycle to `coreml`. Keep private user content, such as journals, on device
437
- unless product explicitly opts into a nonlocal fallback.
438
-
439
- ## Performance Best Practices
440
-
441
- 1. Run outside debugger for accurate benchmarks (Xcode: Cmd-Opt-R, uncheck
442
- "Debug Executable")
443
- 2. Call `session.prewarm()` for Foundation Models before user interaction
444
- 3. Pre-compile Core ML models to `.mlmodelc` for faster loading
445
- 4. Use EnumeratedShapes over RangeDim for Neural Engine optimization
446
- 5. Use 4-bit palettization for best Neural Engine memory/latency gains
447
- 6. Hand off detailed Vision, Natural Language, and Swift Core ML runtime
448
- integration to the sibling framework skills
449
-
450
- ## Common Mistakes
451
-
452
- 1. **No availability check.** Starting generation without checking
453
- `SystemLanguageModel.default.availability` leaves unsupported devices with
454
- failures instead of fallback UI.
455
- 2. **No fallback UI.** Users on pre-iOS 26 or devices without Apple Intelligence
456
- see nothing. Always provide a graceful degradation path.
457
- 3. **Exceeding the context window.** The token budget covers input + output.
458
- Monitor usage via `tokenCount(for:)` and summarize when needed.
459
- 4. **Concurrent requests on one session.** `LanguageModelSession` supports one
460
- request at a time. Check `session.isResponding` or serialize access.
461
- 5. **Untrusted content in instructions.** User input placed in the instructions
462
- parameter bypasses guardrail boundaries. Keep user content in the prompt.
463
- 6. **Forgetting `model.eval()` before Core ML tracing.** PyTorch models must be
464
- in eval mode before `torch.jit.trace`. Training-mode artifacts corrupt output.
465
- 7. **Using neuralnetwork format.** Always use `mlprogram` (.mlpackage) for new
466
- Core ML models. The legacy neuralnetwork format is deprecated.
467
- 8. **Exceeding 60% RAM on iOS (MLX Swift).** Large models cause OOM kills.
468
- 9. **Trusting MLX simulator results.** Validate Metal-dependent behavior on
469
- physical devices; Simulator is only a UI/control-flow smoke test.
470
- 10. **Not clearing MLX caches.** Pair model unload with `Memory.clearCache()`.
471
-
472
- ## Review Checklist
473
-
474
- - [ ] Framework selection matches use case and target OS version
475
- - [ ] Foundation Models: availability checked before every API call
476
- - [ ] Foundation Models: graceful fallback when model unavailable
477
- - [ ] Foundation Models: session prewarm called before user interaction
478
- - [ ] Foundation Models: `@Generable` properties in logical generation order
479
- - [ ] Foundation Models: token budget accounted for (check `contextSize`)
480
- - [ ] Core ML: model format is mlprogram (.mlpackage) for iOS 15+
481
- - [ ] Core ML: conversion, deployment target, and compression validated
482
- - [ ] MLX Swift: model size appropriate for target device RAM
483
- - [ ] MLX Swift: cache limits set, caches cleared, models unloaded
484
- - [ ] All model access serialized through coordinator actor
485
- - [ ] Concurrency: model types and tool implementations are `Sendable`-conformant or `@MainActor`-isolated
486
- - [ ] Physical device testing performed (not simulator)
487
-
488
- ## References
489
-
490
- - [Foundation Models API](references/foundation-models.md) -- LanguageModelSession, `@Generable`, tool calling, prompt design
491
- - [Core ML Conversion](references/coreml-conversion.md) -- Model conversion from PyTorch, TensorFlow, other frameworks
492
- - [Core ML Optimization](references/coreml-optimization.md) -- Quantization, palettization, pruning, performance tuning
493
- - [MLX Swift & llama.cpp](references/mlx-swift.md) -- MLX Swift patterns, llama.cpp integration, memory management
411
+ - For a custom Core ML model, this skill stops at conversion and
412
+ optimisation. Swift integration, loading, Vision hookup and running
413
+ predictions are for `coreml`.
414
+ - Private material such as journals or health notes stays on the device unless
415
+ the product has deliberately chosen a non-local fallback.
416
+
417
+ ## Performance habits
418
+
419
+ 1. Benchmark without the debugger: in the scheme's Run action (Cmd-Opt-R),
420
+ clear "Debug executable".
421
+ 2. Prewarm Foundation Models sessions before the user needs them.
422
+ 3. Ship Core ML models precompiled to `.mlmodelc`.
423
+ 4. For the Neural Engine, prefer `EnumeratedShapes` to `RangeDim`.
424
+ 5. Palettize to 4 bits for the lowest Neural Engine memory and latency.
425
+ 6. Runtime code for Vision, Natural Language and Core ML in Swift belongs to
426
+ the skills for those frameworks.
427
+
428
+ ## Mistakes to catch
429
+
430
+ | Mistake | Consequence | Fix |
431
+ |---|---|---|
432
+ | No availability check | Unsupported devices fail instead of degrading | Switch on `availability` first |
433
+ | No fallback UI | Users on older systems or with Apple Intelligence off get a blank feature | Always offer a degraded path |
434
+ | Overflowing the context | Input plus output exceed the window | Measure with `tokenCount(for:)` (iOS 26.4+), summarise |
435
+ | Two requests on one session | `concurrentRequests` error | Check `isResponding` or serialise |
436
+ | User text in instructions | Weakens the instruction boundary and guardrails | Keep user text in the prompt |
437
+ | Tracing without `model.eval()` | Dropout and batch-norm training behaviour baked in | Call `eval()` before trace or export |
438
+ | Converting to neural network format | Deprecated, missing features | Use ML program |
439
+ | MLX using over 60% RAM on iOS | App killed for memory | Pick a smaller model, cap caches |
440
+ | Trusting Simulator numbers for MLX | Misleading; it only proves UI and control flow | Measure on hardware |
441
+ | Releasing an MLX model but not its cache | Memory stays high | Call `Memory.clearCache()` as part of unloading |
442
+
443
+ ## Before approving
444
+
445
+ - [ ] The framework matches the use case and the deployment target.
446
+ - [ ] Foundation Models: every call is preceded by an availability check, and
447
+ a degraded path exists.
448
+ - [ ] Foundation Models: sessions prewarmed, `@Generable` fields in dependency
449
+ order, token use compared with `contextSize`.
450
+ - [ ] Core ML: ML program `.mlpackage` (iOS 15+); the conversion, its
451
+ deployment target and any compression were verified.
452
+ - [ ] MLX: the model fits in the device's memory, the cache has a limit, and
453
+ caches are cleared when models are released.
454
+ - [ ] One coordinating actor mediates every model call.
455
+ - [ ] Model types and tools are `Sendable` or isolated to `@MainActor`.
456
+ - [ ] Tested on physical devices, not only the Simulator.
457
+
458
+ ## Reference files
459
+
460
+ - [Foundation Models reference](references/foundation-models.md): the full API,
461
+ long conversations, feedback.
462
+ - [Conversion guide](references/coreml-conversion.md): coremltools from each
463
+ source framework, input types, shapes, deployment targets, stateful and
464
+ multifunction models.
465
+ - [Optimization guide](references/coreml-optimization.md): quantizing,
466
+ palettizing, pruning, QAT, Swift loading basics, profiling.
467
+ - [MLX and llama.cpp guide](references/mlx-swift.md): MLX Swift lifecycle,
468
+ llama.cpp, GGUF levels, routing between backends, built-in frameworks.