@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,528 +1,418 @@
1
- # Foundation Models API Reference
2
-
3
- Complete reference for Apple's Foundation Models framework (iOS 26+ / macOS 26+).
4
- On-device language model optimized for Apple Silicon. No app-managed API key,
5
- model hosting, or network round trip for generation; still handle Apple
6
- Intelligence and system model asset availability.
1
+ # Foundation Models reference
7
2
 
8
3
  ## Contents
9
4
 
10
- - [Framework Overview](#framework-overview)
11
- - [Availability Checking](#availability-checking)
12
- - [Use Cases](#use-cases)
13
- - [Session Management](#session-management)
14
- - [Generating Responses](#generating-responses)
15
- - [Structured Output with `@Generable`](#structured-output-with-generable)
16
- - [Tool Calling](#tool-calling)
17
- - [Error Handling](#error-handling)
18
- - [Generation Options](#generation-options)
19
- - [Safety and Guardrails](#safety-and-guardrails)
20
- - [Custom Adapters](#custom-adapters)
21
- - [Context Management](#context-management)
22
- - [Serialized Model Access](#serialized-model-access)
23
- - [Prompt Design Best Practices](#prompt-design-best-practices)
24
- - [Feedback](#feedback)
25
-
26
- ## Framework Overview
27
-
28
- - On-device language model optimized for Apple Silicon
29
- - Context window: limited total token budget (input + output combined); check
30
- `SystemLanguageModel.default.contextSize` for the current limit
31
- - Prefer `SystemLanguageModel.default.supportsLocale(_:)` before generation;
32
- use `supportedLanguages` only when listing broad language support
33
- - Capabilities: Summarization, entity extraction, text understanding, short
34
- dialog, creative content, content tagging
35
- - Limitations: Not suited for complex math, code generation, or factual accuracy
36
-
37
- ### SystemLanguageModel Properties
38
-
39
- - `contextSize`: Returns the model's maximum context window in tokens
40
- - `supportedLanguages`: `Set<Locale.Language>` values the model supports
41
- - `supportsLocale(_ locale: Locale) -> Bool`: Preferred locale check before generating because it accounts for fallbacks
42
-
43
- ## Availability Checking
44
-
45
- Always check before using. Never crash on unavailability.
5
+ - [What the framework is for](#what-the-framework-is-for)
6
+ - [SystemLanguageModel](#systemlanguagemodel)
7
+ - [Availability and locale](#availability-and-locale)
8
+ - [Use cases and guardrails](#use-cases-and-guardrails)
9
+ - [Sessions](#sessions)
10
+ - [Prewarming](#prewarming)
11
+ - [Text responses](#text-responses)
12
+ - [Generable types](#generable-types)
13
+ - [Tools](#tools)
14
+ - [Runtime schemas](#runtime-schemas)
15
+ - [Handling errors](#handling-errors)
16
+ - [Sampling and length](#sampling-and-length)
17
+ - [Safety](#safety)
18
+ - [Adapters](#adapters)
19
+ - [Long conversations](#long-conversations)
20
+ - [One coordinator for all calls](#one-coordinator-for-all-calls)
21
+ - [Writing prompts](#writing-prompts)
22
+ - [Sending feedback](#sending-feedback)
23
+
24
+ ## What the framework is for
25
+
26
+ The framework gives apps the system language model on iOS 26+ and macOS 26+.
27
+ Generation needs no key, hosting or network access from the app, but the app
28
+ must handle Apple Intelligence being off and model assets not being present.
29
+
30
+ Input and output share one context window; its size is
31
+ `SystemLanguageModel.default.contextSize`.
32
+
33
+ Good at: summaries, entity extraction, understanding and rewriting text, short
34
+ dialog, creative writing, content tagging. Weak at: complex math, generating
35
+ code, and anything that must be factually accurate.
36
+
37
+ ## SystemLanguageModel
38
+
39
+ | Member | Meaning |
40
+ |---|---|
41
+ | `contextSize` | Maximum tokens in the context window |
42
+ | `supportedLanguages` | `Set<Locale.Language>` the model supports |
43
+ | `supportsLocale(_ locale: Locale) -> Bool` | Whether a locale works, including fallbacks; prefer this |
44
+ | `isAvailable` | Quick `Bool` availability check |
45
+ | `availability` | Detailed status with an unavailability reason |
46
+
47
+ Use `supportsLocale(_:)` to decide whether to generate. Use
48
+ `supportedLanguages` only to show which languages are broadly supported.
49
+
50
+ ## Availability and locale
46
51
 
47
52
  ```swift
53
+ import Foundation
48
54
  import FoundationModels
49
55
 
50
- // Quick boolean check
51
- if SystemLanguageModel.default.isAvailable {
52
- // Proceed
56
+ enum AssistantRoute {
57
+ case generate(Locale)
58
+ case askToEnable
59
+ case waitForAssets
60
+ case fallback
53
61
  }
54
62
 
55
- // Detailed availability
56
- switch SystemLanguageModel.default.availability {
57
- case .available:
58
- let candidates = [Locale.current] + Locale.preferredLanguages.map(Locale.init(identifier:))
59
- guard let locale = candidates.first(where: SystemLanguageModel.default.supportsLocale) else {
60
- // Route to fallback UI before generating
61
- break
63
+ func assistantRoute() -> AssistantRoute {
64
+ let model = SystemLanguageModel.default
65
+ switch model.availability {
66
+ case .available:
67
+ let candidates = [Locale.current]
68
+ + Locale.preferredLanguages.map(Locale.init(identifier:))
69
+ if let locale = candidates.first(where: model.supportsLocale) {
70
+ return .generate(locale)
71
+ }
72
+ return .fallback
73
+ case .unavailable(.appleIntelligenceNotEnabled):
74
+ return .askToEnable // Settings > Apple Intelligence
75
+ case .unavailable(.modelNotReady):
76
+ return .waitForAssets // downloading, or another temporary system reason
77
+ case .unavailable(.deviceNotEligible):
78
+ return .fallback
79
+ default:
80
+ return .fallback // reasons added in future releases
62
81
  }
63
- // Proceed with model usage
64
- case .unavailable(.appleIntelligenceNotEnabled):
65
- // Guide user to Settings > Apple Intelligence
66
- case .unavailable(.modelNotReady):
67
- // System model assets are downloading or unavailable for other system reasons
68
- case .unavailable(.deviceNotEligible):
69
- // Device cannot run Apple Intelligence
70
- default:
71
- // Graceful fallback for unknown or future unavailable reasons
72
82
  }
73
83
  ```
74
84
 
75
- ## Use Cases
76
-
77
- Foundation Models supports specialized use cases:
85
+ ## Use cases and guardrails
78
86
 
79
87
  ```swift
80
- // General purpose (default)
81
- let model = SystemLanguageModel(useCase: .general, guardrails: .default)
82
-
83
- // Content tagging (optimized for categorization)
84
- let model = SystemLanguageModel(useCase: .contentTagging, guardrails: .default)
88
+ let general = SystemLanguageModel(useCase: .general, guardrails: .default)
89
+ let tagger = SystemLanguageModel(useCase: .contentTagging, guardrails: .default)
85
90
  ```
86
91
 
87
- ## Session Management
92
+ `.general` covers generation, summaries and dialog. `.contentTagging` is tuned
93
+ for labelling and categorising text.
88
94
 
89
- ### Creating Sessions
95
+ ## Sessions
90
96
 
91
97
  ```swift
92
- // Basic session (uses SystemLanguageModel.default)
98
+ // Uses SystemLanguageModel.default
93
99
  let session = LanguageModelSession()
94
100
 
95
- // Session with system instructions
96
- let session = LanguageModelSession {
97
- "You are a helpful cooking assistant."
98
- "Focus on quick, healthy recipes."
101
+ // Several instruction lines
102
+ let coach = LanguageModelSession {
103
+ "You are a running coach."
104
+ "Answer in at most three sentences."
99
105
  }
100
106
 
101
- // Session with tools
102
- let session = LanguageModelSession(
103
- tools: [weatherTool, recipeTool]
104
- ) {
105
- "You are a helpful assistant with access to tools."
107
+ // A specific model plus tools
108
+ let tagging = LanguageModelSession(model: tagger, tools: []) {
109
+ "Assign one topic label to each note."
106
110
  }
107
111
 
108
- // Session with specific model
109
- let model = SystemLanguageModel(useCase: .general, guardrails: .default)
110
- let session = LanguageModelSession(model: model, tools: []) {
111
- "You are a helpful assistant."
112
- }
112
+ // Continue a stored conversation
113
+ let restored = LanguageModelSession(model: general, tools: [], transcript: storedTranscript)
113
114
  ```
114
115
 
115
- ### Session Rules
116
-
117
- 1. Sessions are stateful. Multi-turn conversations maintain context automatically.
118
- 2. One request at a time per session. Check `session.isResponding` before new
119
- requests.
120
- 3. Prewarm with `session.prewarm()` before user interaction for faster first
121
- response.
122
- 4. Save and restore transcripts for session continuity:
123
- `LanguageModelSession(model: model, tools: [], transcript: savedTranscript)`.
116
+ - Sessions are stateful; each turn sees the earlier ones.
117
+ - One request at a time; `isResponding` tells you if one is running.
118
+ - Prewarm before use.
119
+ - Save `session.transcript` to continue the conversation later.
124
120
 
125
- ### Prewarming
121
+ ## Prewarming
126
122
 
127
123
  ```swift
128
- // Prewarm before user interaction
129
124
  session.prewarm()
130
-
131
- // Prewarm with a prompt prefix for faster specific responses
132
- session.prewarm(promptPrefix: Prompt("Summarize the following text:"))
125
+ coach.prewarm(promptPrefix: Prompt("Plan a training week for"))
133
126
  ```
134
127
 
135
- ## Generating Responses
128
+ A prefix lets the system prepare for prompts that begin the same way.
136
129
 
137
- ### Plain Text
130
+ ## Text responses
138
131
 
139
132
  ```swift
140
- // Simple text response
141
- let response = try await session.respond(to: "Summarize this article: \(text)")
142
- print(response.content) // String
143
-
144
- // With generation options
145
- let options = GenerationOptions(
146
- sampling: .random(top: 40),
147
- temperature: 0.7,
148
- maximumResponseTokens: 512
149
- )
150
- let response = try await session.respond(to: prompt, options: options)
133
+ let reply = try await coach.respond(to: "How should I taper before a 10K?")
134
+ let text: String = reply.content
135
+
136
+ let brief = try await coach.respond(to: "One tip for hills",
137
+ options: GenerationOptions(maximumResponseTokens: 80))
151
138
  ```
152
139
 
153
- ### Streaming Text
140
+ Streaming text:
154
141
 
155
142
  ```swift
156
- let stream = session.streamResponse(to: "Tell me a story")
157
- for try await snapshot in stream {
158
- print(snapshot.content, terminator: "")
143
+ let stream = coach.streamResponse(to: "Describe a tempo run")
144
+ for try await partial in stream {
145
+ liveText = partial.content
159
146
  }
160
-
161
- // Or collect the full response
162
- let response = try await stream.collect()
147
+ let complete = try await stream.collect()
163
148
  ```
164
149
 
165
- ## Structured Output with `@Generable`
150
+ ## Generable types
166
151
 
167
- The `@Generable` macro creates compile-time JSON schemas for type-safe output.
168
-
169
- ### Basic Usage
152
+ `@Generable` turns a type into a JSON schema at compile time. Property types it
153
+ accepts: `String`, `Int`, `Double`, `Float`, `Bool`, arrays of Generable or
154
+ scalar values, optionals of those, nested `@Generable` structs and
155
+ `@Generable` enums.
170
156
 
171
157
  ```swift
172
158
  @Generable
173
- struct Recipe {
174
- @Guide(description: "The name of the recipe")
175
- var name: String
176
-
177
- @Guide(description: "A brief description of the dish")
178
- var summary: String
179
-
180
- @Guide(description: "Cooking steps", .count(3))
181
- var steps: [String]
182
-
183
- @Guide(description: "Prep time in minutes", .range(1...120))
184
- var prepTime: Int
159
+ enum Effort: String {
160
+ case easy, moderate, hard
185
161
  }
186
162
 
187
- let response = try await session.respond(
188
- to: "Suggest a quick pasta recipe",
189
- generating: Recipe.self
190
- )
191
- let recipe = response.content
192
- print(recipe.name)
193
- print(recipe.steps)
194
- ```
195
-
196
- ### Supported Types for `@Generable` Properties
197
-
198
- - `String`
199
- - `Int`, `Double`, `Float`
200
- - `Bool`
201
- - `[Element]` where Element is Generable or a supported scalar
202
- - `Optional<T>` where T is Generable or a supported scalar
203
- - Other `@Generable` structs (nested)
204
- - Enums conforming to `@Generable`
205
-
206
- ### `@Guide` Constraints
207
-
208
- ```swift
209
163
  @Generable
210
- struct ProductReview {
211
- @Guide(description: "Product name")
212
- var product: String
164
+ struct WorkoutFeedback {
165
+ @Guide(.range(1...10))
166
+ var perceivedExertion: Int
213
167
 
214
- @Guide(description: "Rating", .range(1...5))
215
- var rating: Int
168
+ @Guide(.anyOf(["improving", "steady", "declining"]))
169
+ var trend: String
216
170
 
217
- @Guide(description: "Sentiment", .anyOf(["positive", "neutral", "negative"]))
218
- var sentiment: String
171
+ @Guide(description: "Actionable suggestions", .count(3))
172
+ var suggestions: [String]
219
173
 
220
- @Guide(description: "Key themes", .count(3))
221
- var themes: [String]
174
+ @Guide(.pattern(/^[A-Z][^.]*\.$/))
175
+ var headline: String
222
176
 
223
- @Guide(description: "Summary in one sentence", .pattern(/^[A-Z].*\.$/))
224
- var summary: String
177
+ @Guide(.constant("v1"))
178
+ var format: String
225
179
 
226
- @Guide(description: "Always English", .constant("en"))
227
- var language: String
180
+ var effort: Effort
228
181
  }
229
182
  ```
230
183
 
231
- Complete constraint list:
184
+ Which guides apply to which types:
232
185
 
233
- | Constraint | Type | Purpose |
234
- |---|---|---|
235
- | `description:` | All | Natural language hint for generation |
236
- | `.anyOf([values])` | String | Restrict to enumerated values |
237
- | `.count(n)` | Array | Fixed array length |
238
- | `.minimumCount(n)` | Array | Minimum array length |
239
- | `.maximumCount(n)` | Array | Maximum array length |
240
- | `.range(min...max)` | Numeric | Closed numeric range |
241
- | `.minimum(n)` | Numeric | Lower bound |
242
- | `.maximum(n)` | Numeric | Upper bound |
243
- | `.constant(value)` | String | Always returns this value |
244
- | `.pattern(regex)` | String | Regex format enforcement |
245
- | `.element(guide)` | Array | Guide applied to each element |
186
+ | Guide | Applies to |
187
+ |---|---|
188
+ | `description:` | Any property |
189
+ | `.anyOf`, `.constant`, `.pattern` | `String` |
190
+ | `.count`, `.minimumCount`, `.maximumCount`, `.element` | Arrays |
191
+ | `.range`, `.minimum`, `.maximum` | Numbers |
246
192
 
247
- ### Property Ordering
248
-
249
- Properties are generated in declaration order. Place foundational data before
250
- dependent data:
193
+ Generation follows declaration order, and later fields are written with the
194
+ earlier ones already in context. Order fields the way a person would reason:
251
195
 
252
196
  ```swift
253
197
  @Generable
254
- struct Summary {
255
- var title: String // Generated first
256
- var keyPoints: [String] // Generated with title context
257
- var conclusion: String // Generated with full context
198
+ struct RaceReport {
199
+ var headline: String // first: sets the topic
200
+ var highlights: [String] // then: details under that headline
201
+ var takeaway: String // last: draws on both
258
202
  }
259
203
  ```
260
204
 
261
- ### Streaming Structured Output
205
+ Streaming a Generable type yields `PartiallyGenerated` values whose fields are
206
+ all optional:
262
207
 
263
208
  ```swift
264
- let stream = session.streamResponse(
265
- to: "Suggest a recipe",
266
- generating: Recipe.self
267
- )
268
- for try await snapshot in stream {
269
- // snapshot.content is Recipe.PartiallyGenerated (all properties optional)
270
- if let name = snapshot.content.name { updateNameLabel(name) }
271
- if let steps = snapshot.content.steps { updateStepsList(steps) }
209
+ for try await snapshot in coach.streamResponse(to: prompt, generating: WorkoutFeedback.self) {
210
+ if let trend = snapshot.content.trend { trendLabel = trend }
211
+ if let tips = snapshot.content.suggestions { suggestionList = tips }
272
212
  }
273
213
  ```
274
214
 
275
- ### Enum Support
215
+ ## Tools
276
216
 
277
217
  ```swift
278
- @Generable
279
- enum Priority: String {
280
- case low, medium, high, critical
281
- }
282
-
283
- @Generable
284
- struct Task {
285
- var title: String
286
- var priority: Priority
287
- }
288
- ```
289
-
290
- ## Tool Calling
291
-
292
- ### Defining Tools
293
-
294
- ```swift
295
- struct WeatherTool: Tool {
296
- let name = "weather"
297
- let description = "Get current weather for a city."
218
+ struct PaceHistoryTool: Tool {
219
+ let name = "recentPaces"
220
+ let description = "Returns the runner's average pace for recent runs."
298
221
 
299
222
  @Generable
300
223
  struct Arguments {
301
- @Guide(description: "The city name")
302
- var city: String
224
+ @Guide(description: "How many recent runs to include", .range(1...20))
225
+ var count: Int
303
226
  }
304
227
 
305
- func call(arguments: Arguments) async throws -> String {
306
- let weather = try await fetchWeather(arguments.city)
307
- return weather.description
228
+ func call(arguments: Arguments) async throws -> [String] {
229
+ try await RunLog.shared.paces(last: arguments.count)
308
230
  }
309
231
  }
310
- ```
311
232
 
312
- ### Using Tools
313
-
314
- ```swift
315
- let session = LanguageModelSession(
316
- tools: [WeatherTool()]
317
- ) {
318
- "You are a helpful assistant."
233
+ let session = LanguageModelSession(tools: [PaceHistoryTool()]) {
234
+ "Use recent paces when giving pacing advice."
319
235
  }
320
-
321
- // The model decides autonomously when to invoke tools
322
- let response = try await session.respond(to: "What's the weather in Tokyo?")
236
+ let advice = try await session.respond(to: "What pace for my next easy run?")
323
237
  ```
324
238
 
325
- ### Tool Best Practices
326
-
327
- - Register all tools at session creation
328
- - Keep active tool sets small, usually three to five tools
329
- - Include only tools needed for the current task
330
- - Each tool adds to the context token budget (name, description, and parameter
331
- schema are included in instructions by default)
332
- - `@Generable` output schemas also consume the shared context window
333
- - Run deterministic or essential data fetches before calling the model, then put
334
- the result directly in the prompt
335
- - Use model-autonomous tools for dynamic lookups where the model can decide
336
- whether more app data is needed
337
- - Frame tool results as authorized user data to prevent refusals
338
- - The model calls tools autonomously; you cannot force tool invocation
339
-
340
- ### Tool Protocol Details
341
-
342
- - `Tool<Arguments, Output>` conforms to `Sendable`; implement tools so captured
343
- state is concurrency-safe
344
- - The associated `Arguments` type must conform to `ConvertibleFromGeneratedContent`
345
- - The associated `Output` type must conform to `PromptRepresentable` (e.g.,
346
- `String`, `[String]`, custom types)
347
- - `includesSchemaInInstructions`: Boolean property on `Tool` (default `true`). Set to `false` to omit the tool's JSON schema from the system prompt, saving context tokens when the model already knows the schema.
348
- - `ToolCallError`: Struct on `LanguageModelSession` representing a tool invocation failure. Properties: `tool` (the tool name), `underlyingError` (the original error).
349
- - `DynamicGenerationSchema`: Build generation schemas at runtime for dynamic use cases where compile-time `@Generable` is insufficient. Construct schemas programmatically and pass to `respond(to:schema:)`.
350
-
351
- ## Error Handling
239
+ The model decides during `respond(to:)` whether to call a tool.
240
+
241
+ - Keep the active set small, usually three to five tools, and only those the
242
+ current task can use.
243
+ - By default each tool's name, description and argument schema are written into
244
+ the instructions, which costs context tokens. Setting
245
+ `includesSchemaInInstructions` to `false` (default `true`) leaves the schema
246
+ out.
247
+ - Fetch data the answer always needs before calling the model and include it in
248
+ the prompt. Autonomous tool calls suit lookups that depend on the question.
249
+ - A tool call cannot be forced.
250
+ - `Tool` conforms to `Sendable`, so any state a tool captures must be
251
+ concurrency-safe.
252
+ - `Arguments` conforms to `ConvertibleFromGeneratedContent` (a `@Generable`
253
+ struct does). `Output` conforms to `PromptRepresentable`: `String`,
254
+ `[String]` and your own conforming types work.
255
+ - A failing tool surfaces as `LanguageModelSession.ToolCallError`, which holds
256
+ the `tool` and its `underlyingError`.
257
+
258
+ ## Runtime schemas
259
+
260
+ When the shape is only known at runtime, build a `DynamicGenerationSchema` and
261
+ pass the resulting schema to `respond(to:schema:)`:
352
262
 
353
263
  ```swift
354
- do {
355
- let response = try await session.respond(to: prompt)
356
- } catch let error as LanguageModelSession.GenerationError {
357
- switch error {
358
- case .guardrailViolation:
359
- // Content triggered safety filters; rephrase and retry
360
- case .exceededContextWindowSize:
361
- // Too many tokens; summarize earlier turns and create new session
362
- case .concurrentRequests:
363
- // Another request is already in progress on this session
364
- case .rateLimited:
365
- // Too many requests; back off and retry
366
- case .unsupportedLanguageOrLocale:
367
- // Current locale not supported by the model
368
- case .unsupportedGuide:
369
- // A @Guide constraint is not supported
370
- case .assetsUnavailable:
371
- // Model assets not available on device
372
- case .decodingFailure:
373
- // Failed to decode structured output
374
- case .refusal(let refusal, _):
375
- // Model refused the request
376
- let explanation = try await refusal.explanation.content
377
- print("Refused: \(explanation)")
378
- default: break
379
- }
264
+ let fields = userChosenFields.map {
265
+ DynamicGenerationSchema.Property(name: $0, schema: DynamicGenerationSchema(type: String.self))
380
266
  }
267
+ let form = DynamicGenerationSchema(name: "Form", properties: fields)
268
+ let schema = try GenerationSchema(root: form, dependencies: [])
269
+ let filled = try await session.respond(to: sourceText, schema: schema)
381
270
  ```
382
271
 
383
- ## Generation Options
272
+ ## Handling errors
384
273
 
385
- ```swift
386
- let options = GenerationOptions(
387
- sampling: .greedy, // Deterministic output
388
- temperature: nil, // Use default
389
- maximumResponseTokens: 256 // Limit response length
390
- )
391
-
392
- // Random sampling with top-k
393
- let options = GenerationOptions(
394
- sampling: .random(top: 40),
395
- temperature: 0.7
396
- )
397
-
398
- // Random sampling with probability threshold
399
- let options = GenerationOptions(
400
- sampling: .random(probabilityThreshold: 0.9)
401
- )
402
- ```
274
+ The `GenerationError` cases and the usual response are listed in SKILL.md. The
275
+ recovery for each:
403
276
 
404
- Sampling modes accept an optional `seed` parameter for reproducible output:
405
- `.random(top: 40, seed: 42)`, `.random(probabilityThreshold: 0.9, seed: 42)`.
277
+ - `guardrailViolation`: ask the user to rephrase, then retry.
278
+ - `exceededContextWindowSize`: summarise the earlier turns into a new session
279
+ and continue there.
280
+ - `rateLimited`: back off before retrying.
281
+ - `refusal(let refusal, _)`: read the reason with
282
+ `try await refusal.explanation.content` and show it.
406
283
 
407
- ## Safety and Guardrails
408
-
409
- ### Guardrail Types
284
+ ## Sampling and length
410
285
 
411
286
  ```swift
412
- // Default guardrails (recommended)
413
- let model = SystemLanguageModel(useCase: .general, guardrails: .default)
414
-
415
- // Permissive content transformations (for text rewriting tasks)
416
- let model = SystemLanguageModel(
417
- useCase: .general,
418
- guardrails: .permissiveContentTransformations
419
- )
287
+ let deterministic = GenerationOptions(sampling: .greedy)
288
+ let defaultTemp = GenerationOptions(temperature: nil, maximumResponseTokens: 256)
289
+ let topK = GenerationOptions(sampling: .random(top: 40))
290
+ let nucleus = GenerationOptions(sampling: .random(probabilityThreshold: 0.9))
291
+ let repeatable = GenerationOptions(sampling: .random(top: 40, seed: 7))
420
292
  ```
421
293
 
422
- ### Safety Rules
294
+ - `.greedy` always picks the most likely token, so output is deterministic.
295
+ - `temperature: nil` keeps the system default.
296
+ - `maximumResponseTokens` caps the reply length.
297
+ - `.random(top:)` samples from the top k tokens; `.random(probabilityThreshold:)`
298
+ samples from the smallest set whose probability reaches the threshold.
299
+ - Both random modes take `seed:` for reproducible output.
423
300
 
424
- - Guardrails are always enforced and cannot be disabled
425
- - Instructions take precedence over user prompts
426
- - Never include untrusted user content in instructions
427
- - Provide curated selections over free-form input when possible
428
- - Guardrails can produce false positives; handle gracefully
429
- - Frame tool results as authorized user data
301
+ ## Safety
430
302
 
431
- ## Custom Adapters
303
+ Guardrail settings:
432
304
 
433
- Load fine-tuned LoRA adapters for specialized model behavior:
305
+ - `.default`: the recommended setting.
306
+ - `.permissiveContentTransformations`: for rewriting or transforming text the
307
+ user supplied, where the default can be too strict.
434
308
 
435
- ```swift
436
- // Requires com.apple.developer.foundation-model-adapter entitlement
437
- let adapter = try SystemLanguageModel.Adapter(name: "my-adapter")
438
- try await adapter.compile()
309
+ Where you can, offer curated choices instead of free-form input. Keep user text
310
+ out of instructions.
439
311
 
440
- let model = SystemLanguageModel(adapter: adapter, guardrails: .default)
441
- let session = LanguageModelSession(model: model)
442
- let response = try await session.respond(to: "Generate styled text")
443
- ```
312
+ ## Adapters
444
313
 
445
- ### Adapter Management
314
+ Adapters are fine-tuned LoRA weights for the system model. They need the
315
+ `com.apple.developer.foundation-model-adapter` entitlement.
446
316
 
447
317
  ```swift
448
- // Check compatible adapters
449
- let ids = SystemLanguageModel.Adapter.compatibleAdapterIdentifiers(name: "my-adapter")
318
+ let adapter = try SystemLanguageModel.Adapter(name: "trail-guide")
319
+ try await adapter.compile()
320
+ let tuned = SystemLanguageModel(adapter: adapter, guardrails: .default)
321
+ let session = LanguageModelSession(model: tuned)
450
322
 
451
- // Remove obsolete adapters
323
+ let usable = SystemLanguageModel.Adapter.compatibleAdapterIdentifiers(name: "trail-guide")
452
324
  try SystemLanguageModel.Adapter.removeObsoleteAdapters()
453
325
  ```
454
326
 
455
- ## Context Management
327
+ `compatibleAdapterIdentifiers(name:)` lists adapter versions that match the
328
+ installed system model; `removeObsoleteAdapters()` deletes the ones that no
329
+ longer do.
456
330
 
457
- When conversations grow long:
331
+ ## Long conversations
458
332
 
459
- 1. Monitor token usage against `SystemLanguageModel.default.contextSize`
460
- 2. Use `SystemLanguageModel.default.tokenCount(for:)` to estimate usage
461
- 3. Summarize earlier turns into new session instructions
462
- 4. Create fresh sessions with summary context rather than overflowing
333
+ A conversation grows until it no longer fits. Measure it against
334
+ `contextSize`, estimate the cost of text with
335
+ `SystemLanguageModel.default.tokenCount(for:)` (iOS 26.4+; `contextSize` is
336
+ back-deployed to 26.0), and before it overflows, fold
337
+ the history into a summary and start a fresh session with that summary in its
338
+ instructions.
463
339
 
464
340
  ```swift
465
- if transcript.estimatedTokenCount > 3000 {
466
- let summary = try await summarizeSession(session)
467
- session = LanguageModelSession {
468
- "Previous conversation summary: \(summary)"
469
- "Continue helping the user."
341
+ @available(iOS 26.4, macOS 26.4, visionOS 26.4, *)
342
+ func continueOrCondense(_ session: LanguageModelSession,
343
+ history: String) async throws -> LanguageModelSession {
344
+ let model = SystemLanguageModel.default
345
+ let used = try await model.tokenCount(for: history)
346
+ guard used > model.contextSize * 3 / 4 else { return session }
347
+
348
+ let summary = try await LanguageModelSession().respond(
349
+ to: "Summarise this conversation in five bullet points:\n\(history)"
350
+ ).content
351
+ return LanguageModelSession {
352
+ "You are a running coach."
353
+ "Earlier conversation, summarised: \(summary)"
470
354
  }
471
355
  }
472
356
  ```
473
357
 
474
- ## Serialized Model Access
358
+ The 75 percent threshold leaves room for the next reply; tune it to your
359
+ typical answer length.
475
360
 
476
- When multiple parts of an app need the model:
361
+ ## One coordinator for all calls
362
+
363
+ Route every request through one actor that owns the session, so two features
364
+ never run the model at the same time and compete for the Neural Engine. Chain
365
+ requests as shown in SKILL.md, because an actor alone does not serialise across
366
+ `await`.
477
367
 
478
368
  ```swift
479
- actor FoundationModelCoordinator {
369
+ actor CoachService {
480
370
  private var session: LanguageModelSession?
481
-
482
- func respond(to prompt: String) async throws -> String {
483
- if session == nil {
484
- session = LanguageModelSession()
371
+ private var last: Task<Void, Never>?
372
+
373
+ func ask(_ prompt: String) async throws -> String {
374
+ let previous = last
375
+ let job = Task { () async throws -> String in
376
+ await previous?.value
377
+ let active = self.currentSession()
378
+ return try await active.respond(to: prompt).content
485
379
  }
486
- guard let activeSession = session else {
487
- throw FoundationModelError.sessionUnavailable
488
- }
489
- let response = try await activeSession.respond(to: prompt)
490
- return response.content
380
+ last = Task { _ = try? await job.value }
381
+ return try await job.value
382
+ }
383
+
384
+ private func currentSession() -> LanguageModelSession {
385
+ if let session { return session }
386
+ let created = LanguageModelSession { "You are a running coach." }
387
+ session = created
388
+ return created
491
389
  }
492
390
  }
493
391
  ```
494
392
 
495
- Serialize all Foundation Model access through a single coordinator to prevent
496
- Neural Engine contention.
497
-
498
- ## Prompt Design Best Practices
393
+ ## Writing prompts
499
394
 
500
- 1. **Be concise.** The context window covers both input and output tokens.
501
- Check `SystemLanguageModel.default.contextSize` for the current limit.
502
- 2. **Use bracketed placeholders** in instructions: `[descriptive example]`.
503
- 3. **Use "DO NOT" in all caps** for behavioral prohibitions.
504
- 4. **Provide up to 5 few-shot examples** for consistent output.
505
- 5. **Use length qualifiers:** "in a few words", "in three sentences".
506
- 6. **Estimate token usage** with `SystemLanguageModel.default.tokenCount(for:)`
507
- to avoid exceeding the context window.
395
+ The rules in SKILL.md apply; in addition, estimate prompt size with
396
+ `SystemLanguageModel.default.tokenCount(for:)` (iOS 26.4+) before sending long
397
+ inputs.
508
398
 
509
- ## Feedback
399
+ ## Sending feedback
510
400
 
511
- Log feedback for model improvement:
401
+ Attach structured feedback to a report when output is wrong:
512
402
 
513
403
  ```swift
514
- let data = session.logFeedbackAttachment(
404
+ let attachment = session.logFeedbackAttachment(
515
405
  sentiment: .negative,
516
406
  issues: [
517
- LanguageModelFeedback.Issue(
518
- category: .didNotFollowInstructions,
519
- explanation: "Ignored the word count constraint"
520
- )
407
+ LanguageModelFeedback.Issue(category: .incorrect,
408
+ explanation: "Recommended pace was faster than race pace.")
521
409
  ],
522
410
  desiredOutput: nil
523
411
  )
524
412
  ```
525
413
 
414
+ The call returns data to include in a Feedback Assistant report.
415
+
526
416
  Issue categories: `.didNotFollowInstructions`, `.incorrect`,
527
417
  `.stereotypeOrBias`, `.suggestiveOrSexual`, `.tooVerbose`,
528
418
  `.triggeredGuardrailUnexpectedly`, `.unhelpful`, `.vulgarOrOffensive`.