@mmerterden/multi-agent-pipeline 20.7.0 → 20.8.0

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 (264) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +0 -10
  3. package/docs/facts.json +1 -1
  4. package/manifest.json +266 -267
  5. package/package.json +2 -2
  6. package/pipeline/scripts/_notices.mjs +1 -1
  7. package/pipeline/skills/.skill-manifest.json +68 -68
  8. package/pipeline/skills/shared/README.md +70 -70
  9. package/pipeline/skills/shared/external/alarmkit/SKILL.md +373 -381
  10. package/pipeline/skills/shared/external/alarmkit/evals/evals.json +23 -18
  11. package/pipeline/skills/shared/external/alarmkit/references/alarmkit-patterns.md +328 -378
  12. package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
  13. package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
  14. package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
  15. package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
  16. package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
  17. package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
  18. package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
  19. package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
  20. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +339 -277
  21. package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
  22. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +105 -122
  23. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +143 -166
  24. package/pipeline/skills/shared/external/app-store-review/SKILL.md +307 -326
  25. package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
  26. package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
  27. package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
  28. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +333 -360
  29. package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
  30. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
  31. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
  32. package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
  33. package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
  34. package/pipeline/skills/shared/external/authentication/SKILL.md +265 -381
  35. package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
  36. package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +133 -178
  37. package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
  38. package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
  39. package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
  40. package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
  41. package/pipeline/skills/shared/external/background-processing/SKILL.md +270 -382
  42. package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
  43. package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +169 -317
  44. package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
  45. package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
  46. package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
  47. package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
  48. package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
  49. package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
  50. package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
  51. package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
  52. package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
  53. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +226 -376
  54. package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
  55. package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
  56. package/pipeline/skills/shared/external/core-data/SKILL.md +292 -368
  57. package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
  58. package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
  59. package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
  60. package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
  61. package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
  62. package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
  63. package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
  64. package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
  65. package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
  66. package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
  67. package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
  68. package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
  69. package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
  70. package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
  71. package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
  72. package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
  73. package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
  74. package/pipeline/skills/shared/external/device-integrity/SKILL.md +230 -353
  75. package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
  76. package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
  77. package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
  78. package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
  79. package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
  80. package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
  81. package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
  82. package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
  83. package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
  84. package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
  85. package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
  86. package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
  87. package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
  88. package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
  89. package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
  90. package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
  91. package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
  92. package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
  93. package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
  94. package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
  95. package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
  96. package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
  97. package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
  98. package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
  99. package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
  100. package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
  101. package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
  102. package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
  103. package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
  104. package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
  105. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
  106. package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
  107. package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
  108. package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
  109. package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
  110. package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
  111. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +295 -267
  112. package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
  113. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
  114. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
  115. package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
  116. package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
  117. package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
  118. package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
  119. package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
  120. package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
  121. package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
  122. package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
  123. package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
  124. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
  125. package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
  126. package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
  127. package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
  128. package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
  129. package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
  130. package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
  131. package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
  132. package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
  133. package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
  134. package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
  135. package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
  136. package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
  137. package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
  138. package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
  139. package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
  140. package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
  141. package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
  142. package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
  143. package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
  144. package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
  145. package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
  146. package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
  147. package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
  148. package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
  149. package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
  150. package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
  151. package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
  152. package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
  153. package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
  154. package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
  155. package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
  156. package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
  157. package/pipeline/skills/shared/external/storekit/references/core-patterns.md +298 -242
  158. package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
  159. package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
  160. package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
  161. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
  162. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
  163. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
  164. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
  165. package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
  166. package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
  167. package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
  168. package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
  169. package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
  170. package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
  171. package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
  172. package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +303 -351
  173. package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
  174. package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
  175. package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
  176. package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
  177. package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
  178. package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
  179. package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
  180. package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
  181. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
  182. package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
  183. package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
  184. package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
  185. package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
  186. package/pipeline/skills/shared/external/swift-security/SKILL.md +180 -161
  187. package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
  188. package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
  189. package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +408 -476
  190. package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
  191. package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
  192. package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
  193. package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
  194. package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
  195. package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
  196. package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +352 -472
  197. package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
  198. package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
  199. package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
  200. package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +396 -457
  201. package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
  202. package/pipeline/skills/shared/external/swift-testing/SKILL.md +188 -175
  203. package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
  204. package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +80 -84
  205. package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
  206. package/pipeline/skills/shared/external/swiftdata/SKILL.md +392 -256
  207. package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
  208. package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
  209. package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
  210. package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
  211. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
  212. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
  213. package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
  214. package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
  215. package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
  216. package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
  217. package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
  218. package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
  219. package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
  220. package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
  221. package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
  222. package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
  223. package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
  224. package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
  225. package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
  226. package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
  227. package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
  228. package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
  229. package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
  230. package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
  231. package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +193 -168
  232. package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
  233. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +132 -133
  234. package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
  235. package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +106 -140
  236. package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
  237. package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
  238. package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
  239. package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
  240. package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
  241. package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
  242. package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
  243. package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
  244. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
  245. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
  246. package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
  247. package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
  248. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
  249. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
  250. package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
  251. package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
  252. package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
  253. package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
  254. package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
  255. package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
  256. package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
  257. package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
  258. package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
  259. package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
  260. package/pipeline/skills/shared/external/weatherkit/SKILL.md +152 -310
  261. package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
  262. package/pipeline/skills/shared/external/widgetkit/SKILL.md +216 -288
  263. package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +414 -719
  264. package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
@@ -1,493 +1,466 @@
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 and MLTensor, 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, and hooking
324
+ models into Vision requests.
363
325
 
364
- ## MLX Swift Overview
326
+ Conversion: [the conversion guide](references/coreml-conversion.md).
327
+ Compression and profiling: [the optimization guide](references/coreml-optimization.md).
365
328
 
366
- Apple's ML framework for Swift. Highest sustained generation throughput on
367
- Apple Silicon via unified memory architecture.
329
+ ## MLX Swift
368
330
 
369
- ### Loading and Running LLMs
331
+ MLX Swift gets the highest sustained throughput on Apple Silicon because CPU
332
+ and GPU share unified memory.
370
333
 
371
334
  ```swift
372
- import MLX
373
- import MLXLLM
374
335
  import MLXLMCommon
336
+ import MLXLLM
375
337
  import MLXLMHFAPI
338
+ import MLX
376
339
 
377
- let container = try await LLMModelFactory.shared.loadContainer(
340
+ let factory = LLMModelFactory.shared
341
+ let modelContainer = try await factory.loadContainer(
378
342
  from: HubClient.default,
379
343
  using: TokenizersLoader(),
380
- configuration: .init(id: "mlx-community/Qwen3-4B-4bit")
344
+ configuration: ModelConfiguration(id: "mlx-community/Qwen3-1.7B-4bit")
381
345
  )
382
- let session = ChatSession(container)
383
- print(try await session.respond(to: "Hello"))
346
+ let chat = ChatSession(modelContainer)
347
+ let text = try await chat.respond(to: "List three uses of chlorophyll.")
384
348
  ```
385
349
 
386
- ### Model Selection by Device
350
+ Starting points by device:
387
351
 
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 |
352
+ | Device and RAM | Resident memory | Suggested model |
353
+ |---|---|---|
354
+ | iPhone 12 to 14, 4 to 6 GB | about 0.3 GB | SmolLM2-135M, or Qwen 2.5 at 0.5B |
355
+ | iPhone 15 Pro or newer, 8 GB | about 3.5 GB | Gemma 3n E4B at 4 bits |
356
+ | Mac, 8 GB | about 3 GB | Llama 3.2 3B at 4 bits |
357
+ | Mac, 16 GB or more | about 6 GB | Mistral 7B at 4 bits |
394
358
 
395
- ### Memory Management
359
+ Memory rules:
396
360
 
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
361
+ - On iOS stay under 60% of total RAM.
362
+ - Cap the MLX cache: `Memory.cacheLimit = 512 * 1024 * 1024`.
363
+ - Release llama.cpp and MLX models on backgrounding or a memory warning, and
364
+ after heavy MLX generation also call `Memory.clearCache()`.
365
+ - Larger models need the Increased Memory Limit entitlement.
366
+ - Test MLX and llama.cpp code on real Apple Silicon hardware. The Simulator
367
+ does not run Metal inference and shows neither real memory limits nor real
368
+ speed.
404
369
 
405
- > See [references/mlx-swift.md](references/mlx-swift.md) for full MLX Swift
406
- > patterns and llama.cpp integration.
370
+ MLX lifecycle, llama.cpp and GGUF: [the MLX and llama.cpp guide](references/mlx-swift.md).
407
371
 
408
- ## Multi-Backend Architecture
372
+ ## Running several backends
409
373
 
410
- When an app needs multiple AI backends (e.g., Foundation Models + MLX fallback):
374
+ Try the system model first, then a local open model, and fail clearly when
375
+ neither is there:
411
376
 
412
377
  ```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
- }
378
+ func pickBackend() async throws -> Backend {
379
+ let systemModel = SystemLanguageModel.default
380
+ if systemModel.isAvailable { return .foundationModels }
381
+ if await mlxModelCanLoad() { return .mlx }
382
+ throw AIError.noBackendAvailable
421
383
  }
422
384
  ```
423
385
 
424
- Serialize all model access through a coordinator actor to prevent contention:
386
+ Send every model call through one actor so requests never compete for the same
387
+ hardware. Actors are reentrant: a method that awaits lets the next caller in,
388
+ so an actor that only forwards the call does not serialise anything. Chain the
389
+ work instead:
425
390
 
426
391
  ```swift
427
- actor ModelCoordinator {
428
- func withExclusiveAccess<T>(_ work: () async throws -> T) async rethrows -> T {
429
- try await work()
392
+ actor InferenceGate {
393
+ private var last: Task<Void, Never>?
394
+
395
+ func exclusive<Value: Sendable>(
396
+ _ work: @escaping @Sendable () async throws -> Value
397
+ ) async throws -> Value {
398
+ let previous = last
399
+ let current = Task { () async throws -> Value in
400
+ await previous?.value
401
+ return try await work()
402
+ }
403
+ last = Task { _ = try? await current.value }
404
+ return try await current.value
430
405
  }
431
406
  }
432
407
  ```
433
408
 
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
409
+ - For a custom Core ML model, this skill stops at conversion and
410
+ optimisation. Swift integration, loading, Vision hookup and running
411
+ predictions are for `coreml`.
412
+ - Private material such as journals or health notes stays on the device unless
413
+ the product has deliberately chosen a non-local fallback.
414
+
415
+ ## Performance habits
416
+
417
+ 1. Benchmark without the debugger: in the scheme's Run action (Cmd-Opt-R),
418
+ clear "Debug executable".
419
+ 2. Prewarm Foundation Models sessions before the user needs them.
420
+ 3. Ship Core ML models precompiled to `.mlmodelc`.
421
+ 4. For the Neural Engine, prefer `EnumeratedShapes` to `RangeDim`.
422
+ 5. Palettize to 4 bits for the lowest Neural Engine memory and latency.
423
+ 6. Runtime code for Vision, Natural Language and Core ML in Swift belongs to
424
+ the skills for those frameworks.
425
+
426
+ ## Mistakes to catch
427
+
428
+ | Mistake | Consequence | Fix |
429
+ |---|---|---|
430
+ | No availability check | Unsupported devices fail instead of degrading | Switch on `availability` first |
431
+ | No fallback UI | Users on older systems or with Apple Intelligence off get a blank feature | Always offer a degraded path |
432
+ | Overflowing the context | Input plus output exceed the window | Measure with `tokenCount(for:)` (iOS 26.4+), summarise |
433
+ | Two requests on one session | `concurrentRequests` error | Check `isResponding` or serialise |
434
+ | User text in instructions | Weakens the instruction boundary and guardrails | Keep user text in the prompt |
435
+ | Tracing without `model.eval()` | Dropout and batch-norm training behaviour baked in | Call `eval()` before trace or export |
436
+ | Converting to neural network format | Deprecated, missing features | Use ML program |
437
+ | MLX using over 60% RAM on iOS | App killed for memory | Pick a smaller model, cap caches |
438
+ | Trusting Simulator numbers for MLX | Misleading; it only proves UI and control flow | Measure on hardware |
439
+ | Releasing an MLX model but not its cache | Memory stays high | Call `Memory.clearCache()` as part of unloading |
440
+
441
+ ## Before approving
442
+
443
+ - [ ] The framework matches the use case and the deployment target.
444
+ - [ ] Foundation Models: every call is preceded by an availability check, and
445
+ a degraded path exists.
446
+ - [ ] Foundation Models: sessions prewarmed, `@Generable` fields in dependency
447
+ order, token use compared with `contextSize`.
448
+ - [ ] Core ML: ML program `.mlpackage` (iOS 15+); the conversion, its
449
+ deployment target and any compression were verified.
450
+ - [ ] MLX: the model fits in the device's memory, the cache has a limit, and
451
+ caches are cleared when models are released.
452
+ - [ ] One coordinating actor mediates every model call.
453
+ - [ ] Model types and tools are `Sendable` or isolated to `@MainActor`.
454
+ - [ ] Tested on physical devices, not only the Simulator.
455
+
456
+ ## Reference files
457
+
458
+ - [Foundation Models reference](references/foundation-models.md): the full API,
459
+ long conversations, feedback.
460
+ - [Conversion guide](references/coreml-conversion.md): coremltools from each
461
+ source framework, input types, shapes, deployment targets, stateful and
462
+ multifunction models.
463
+ - [Optimization guide](references/coreml-optimization.md): quantizing,
464
+ palettizing, pruning, QAT, Swift loading basics, profiling.
465
+ - [MLX and llama.cpp guide](references/mlx-swift.md): MLX Swift lifecycle,
466
+ llama.cpp, GGUF levels, routing between backends, built-in frameworks.