@mmerterden/multi-agent-pipeline 20.6.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 (326) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +0 -10
  3. package/docs/facts.json +1 -1
  4. package/manifest.json +328 -329
  5. package/package.json +2 -2
  6. package/pipeline/multi-agent-refs/features/design-conformance.md +62 -64
  7. package/pipeline/scripts/_notices.mjs +12 -1
  8. package/pipeline/scripts/gen-skills-index.mjs +1 -1
  9. package/pipeline/skills/.skill-manifest.json +106 -106
  10. package/pipeline/skills/shared/README.md +71 -71
  11. package/pipeline/skills/shared/external/agent-introspection-debugging/SKILL.md +1 -0
  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/android-architecture/SKILL.md +2 -0
  16. package/pipeline/skills/shared/external/android-performance/SKILL.md +2 -0
  17. package/pipeline/skills/shared/external/android-security/SKILL.md +2 -0
  18. package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
  19. package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
  20. package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
  21. package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
  22. package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
  23. package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
  24. package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
  25. package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
  26. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +339 -277
  27. package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
  28. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +105 -122
  29. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +143 -166
  30. package/pipeline/skills/shared/external/app-store-review/SKILL.md +307 -326
  31. package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
  32. package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
  33. package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
  34. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +333 -360
  35. package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
  36. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
  37. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
  38. package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
  39. package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
  40. package/pipeline/skills/shared/external/authentication/SKILL.md +265 -381
  41. package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
  42. package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +133 -178
  43. package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
  44. package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
  45. package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
  46. package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
  47. package/pipeline/skills/shared/external/background-processing/SKILL.md +270 -382
  48. package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
  49. package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +169 -317
  50. package/pipeline/skills/shared/external/backlog/BACKLOG.md +1 -1
  51. package/pipeline/skills/shared/external/backlog/SKILL.md +56 -33
  52. package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
  53. package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
  54. package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
  55. package/pipeline/skills/shared/external/ci-cd-pipelines/SKILL.md +1 -0
  56. package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
  57. package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
  58. package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
  59. package/pipeline/skills/shared/external/compose-components/SKILL.md +2 -0
  60. package/pipeline/skills/shared/external/compose-navigation/SKILL.md +3 -2
  61. package/pipeline/skills/shared/external/compose-testing/SKILL.md +2 -0
  62. package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
  63. package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
  64. package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
  65. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +226 -376
  66. package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
  67. package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
  68. package/pipeline/skills/shared/external/core-data/SKILL.md +292 -368
  69. package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
  70. package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
  71. package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
  72. package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
  73. package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
  74. package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
  75. package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
  76. package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
  77. package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
  78. package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
  79. package/pipeline/skills/shared/external/council/SKILL.md +1 -0
  80. package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
  81. package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
  82. package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
  83. package/pipeline/skills/shared/external/css-modern/SKILL.md +1 -0
  84. package/pipeline/skills/shared/external/database-patterns/SKILL.md +1 -0
  85. package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
  86. package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
  87. package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
  88. package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
  89. package/pipeline/skills/shared/external/device-integrity/SKILL.md +230 -353
  90. package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
  91. package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
  92. package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
  93. package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
  94. package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
  95. package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
  96. package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
  97. package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
  98. package/pipeline/skills/shared/external/evidence-github/SKILL.md +2 -0
  99. package/pipeline/skills/shared/external/evidence-registry/SKILL.md +2 -0
  100. package/pipeline/skills/shared/external/gradle-kotlin-dsl/SKILL.md +2 -0
  101. package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
  102. package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
  103. package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
  104. package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
  105. package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
  106. package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
  107. package/pipeline/skills/shared/external/html-semantic/SKILL.md +1 -0
  108. package/pipeline/skills/shared/external/humanizer/SKILL.md +1 -0
  109. package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
  110. package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
  111. package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
  112. package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
  113. package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
  114. package/pipeline/skills/shared/external/ios-coding-standard/SKILL.md +1 -0
  115. package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
  116. package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
  117. package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
  118. package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
  119. package/pipeline/skills/shared/external/ios-module-structure/SKILL.md +1 -0
  120. package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
  121. package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
  122. package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
  123. package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
  124. package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
  125. package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
  126. package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
  127. package/pipeline/skills/shared/external/ios-security/SKILL.md +2 -0
  128. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
  129. package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
  130. package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
  131. package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
  132. package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
  133. package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
  134. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +91 -283
  135. package/pipeline/skills/shared/external/localization-reuse-map/reference/format-and-output.md +119 -151
  136. package/pipeline/skills/shared/external/localization-reuse-map/reference/publish-and-snapshot.md +60 -90
  137. package/pipeline/skills/shared/external/localization-reuse-map/reference/sources-and-recipes.md +119 -156
  138. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-artifact.py +726 -787
  139. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-spreadsheet.py +253 -288
  140. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-annotations.py +243 -304
  141. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-legacy-labels.py +88 -104
  142. package/pipeline/skills/shared/external/localization-reuse-map/scripts/publish-confluence.py +181 -235
  143. package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-key-shots.py +198 -263
  144. package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-overlay.py +461 -466
  145. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-legacy-values.py +145 -151
  146. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-new-values.py +123 -141
  147. package/pipeline/skills/shared/external/localization-reuse-map/scripts/scan-screen-keys.py +146 -157
  148. package/pipeline/skills/shared/external/localization-reuse-map/scripts/snapshot-resources.sh +22 -19
  149. package/pipeline/skills/shared/external/localization-reuse-map/scripts/verify-map.py +156 -140
  150. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +295 -267
  151. package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
  152. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
  153. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
  154. package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
  155. package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
  156. package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
  157. package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
  158. package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
  159. package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
  160. package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
  161. package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
  162. package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
  163. package/pipeline/skills/shared/external/nextjs-app-router/SKILL.md +1 -0
  164. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
  165. package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
  166. package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
  167. package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
  168. package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
  169. package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
  170. package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
  171. package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
  172. package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
  173. package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
  174. package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
  175. package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
  176. package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
  177. package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
  178. package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
  179. package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
  180. package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
  181. package/pipeline/skills/shared/external/play-store-review/SKILL.md +2 -0
  182. package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
  183. package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
  184. package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
  185. package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
  186. package/pipeline/skills/shared/external/python-patterns/SKILL.md +1 -0
  187. package/pipeline/skills/shared/external/react-best-practices/SKILL.md +1 -0
  188. package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
  189. package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
  190. package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
  191. package/pipeline/skills/shared/external/rest-api-design/SKILL.md +1 -0
  192. package/pipeline/skills/shared/external/retrofit-networking/SKILL.md +2 -0
  193. package/pipeline/skills/shared/external/room-database/SKILL.md +2 -0
  194. package/pipeline/skills/shared/external/search-first/SKILL.md +1 -0
  195. package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
  196. package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
  197. package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
  198. package/pipeline/skills/shared/external/signal-community/SKILL.md +2 -0
  199. package/pipeline/skills/shared/external/skill-creator/SKILL.md +80 -41
  200. package/pipeline/skills/shared/external/skill-creator/audit.md +63 -59
  201. package/pipeline/skills/shared/external/skill-creator/checklist.md +28 -20
  202. package/pipeline/skills/shared/external/skill-creator/examples.md +40 -40
  203. package/pipeline/skills/shared/external/skill-creator/label-check.md +48 -36
  204. package/pipeline/skills/shared/external/skill-creator/scripts/audit-panel.js +91 -100
  205. package/pipeline/skills/shared/external/skill-creator/template.md +51 -39
  206. package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
  207. package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
  208. package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
  209. package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
  210. package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
  211. package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
  212. package/pipeline/skills/shared/external/storekit/references/core-patterns.md +298 -242
  213. package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
  214. package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
  215. package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
  216. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
  217. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
  218. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
  219. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
  220. package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
  221. package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
  222. package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
  223. package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
  224. package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
  225. package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
  226. package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
  227. package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +303 -351
  228. package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
  229. package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
  230. package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
  231. package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
  232. package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
  233. package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
  234. package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
  235. package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
  236. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
  237. package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
  238. package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
  239. package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
  240. package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
  241. package/pipeline/skills/shared/external/swift-security/SKILL.md +180 -161
  242. package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
  243. package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
  244. package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +408 -476
  245. package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
  246. package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
  247. package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
  248. package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
  249. package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
  250. package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
  251. package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +352 -472
  252. package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
  253. package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
  254. package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
  255. package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +396 -457
  256. package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
  257. package/pipeline/skills/shared/external/swift-testing/SKILL.md +188 -175
  258. package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
  259. package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +80 -84
  260. package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
  261. package/pipeline/skills/shared/external/swiftdata/SKILL.md +392 -256
  262. package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
  263. package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
  264. package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
  265. package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
  266. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
  267. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
  268. package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
  269. package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
  270. package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
  271. package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
  272. package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
  273. package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
  274. package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
  275. package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
  276. package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
  277. package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
  278. package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
  279. package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
  280. package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
  281. package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
  282. package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
  283. package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
  284. package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
  285. package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
  286. package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +193 -168
  287. package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
  288. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +132 -133
  289. package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
  290. package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +106 -140
  291. package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
  292. package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
  293. package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
  294. package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
  295. package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
  296. package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
  297. package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
  298. package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
  299. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
  300. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
  301. package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
  302. package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
  303. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
  304. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
  305. package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
  306. package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
  307. package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
  308. package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
  309. package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
  310. package/pipeline/skills/shared/external/tailwind-css/SKILL.md +1 -0
  311. package/pipeline/skills/shared/external/testing-backend/SKILL.md +1 -0
  312. package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
  313. package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
  314. package/pipeline/skills/shared/external/typescript-patterns/SKILL.md +1 -0
  315. package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
  316. package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
  317. package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
  318. package/pipeline/skills/shared/external/vue-composition/SKILL.md +1 -0
  319. package/pipeline/skills/shared/external/weatherkit/SKILL.md +152 -310
  320. package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
  321. package/pipeline/skills/shared/external/web-accessibility/SKILL.md +1 -0
  322. package/pipeline/skills/shared/external/web-performance/SKILL.md +1 -0
  323. package/pipeline/skills/shared/external/web-testing/SKILL.md +1 -0
  324. package/pipeline/skills/shared/external/widgetkit/SKILL.md +216 -288
  325. package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +414 -719
  326. package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
@@ -1,477 +1,362 @@
1
1
  ---
2
2
  name: vision-framework
3
- description: "Implement computer vision features including text recognition (OCR), face detection, barcode scanning, image segmentation, object tracking, and document scanning in iOS apps. Covers both the modern Swift-native Vision API (iOS 16+) and legacy VNRequest patterns, VisionKit DataScannerViewController for live camera scanning, and VNCoreMLRequest for custom model inference. Use when adding OCR, barcode scanning, face detection, or custom Core ML model inference with Vision."
3
+ description: "On-device computer vision with Vision and VisionKit: OCR, face detection and landmarks, barcode and QR scanning, person and instance segmentation, object tracking, document reading and scanning, saliency, pose, Core ML inference, Swift-native (iOS 18+) and legacy VNRequest APIs, DataScannerViewController live scanning. Use when adding OCR, barcode scanning, face detection, segmentation, tracking or Core ML image inference through Vision. Not for Core ML model conversion."
4
4
  metadata:
5
- source: "dpearson2699/swift-ios-skills (PolyForm Perimeter 1.0.0)"
5
+ source: multi-agent-pipeline
6
6
  ---
7
7
 
8
8
  # Vision Framework
9
9
 
10
- Detect text, faces, barcodes, objects, and body poses in images and video using
11
- on-device computer vision. Patterns target iOS 26+ with Swift 6.3,
12
- backward-compatible where noted.
10
+ Vision finds text, faces, barcodes, objects, people and body poses in still
11
+ images and video frames. Everything runs on the device; no image leaves it.
12
+ VisionKit sits on top and supplies ready-made camera UI for live scanning and
13
+ document capture.
13
14
 
14
- See [references/vision-requests.md](references/vision-requests.md) for complete code patterns and
15
- [references/visionkit-scanner.md](references/visionkit-scanner.md) for DataScannerViewController integration.
15
+ Baseline for this skill: iOS 26 and Swift 6.3. Where an API has a lower floor
16
+ it is stated next to the API, so older deployment targets can still use the
17
+ guidance.
16
18
 
17
- ## Contents
19
+ Load a reference when the section below is not enough:
18
20
 
19
- - [Two API Generations](#two-api-generations)
20
- - [Request Pattern (Modern API)](#request-pattern-modern-api)
21
- - [Text Recognition (OCR)](#text-recognition-ocr)
22
- - [Face Detection](#face-detection)
23
- - [Barcode Detection](#barcode-detection)
24
- - [Document Scanning (iOS 26+)](#document-scanning-ios-26)
25
- - [Image Segmentation](#image-segmentation)
26
- - [Object Tracking](#object-tracking)
27
- - [Other Request Types](#other-request-types)
28
- - [Core ML Integration](#core-ml-integration)
29
- - [VisionKit: DataScannerViewController](#visionkit-datascannerviewcontroller)
30
- - [Common Mistakes](#common-mistakes)
31
- - [Review Checklist](#review-checklist)
32
- - [References](#references)
21
+ - `references/vision-requests.md`: longer request recipes (OCR pipeline, faces,
22
+ barcodes, segmentation and blur, saliency, rectangles, horizon, batching,
23
+ camera frames, tracking, coordinate helpers, performance).
24
+ - `references/visionkit-scanner.md`: camera permission, `DataScannerViewController`
25
+ in UIKit and SwiftUI, delegate and async item streams, overlays, and
26
+ `VNDocumentCameraViewController` with an OCR pass.
33
27
 
34
- ## Two API Generations
28
+ ## Choosing an API generation
35
29
 
36
- Vision has two distinct API layers. Prefer the modern API for new code.
30
+ Vision ships two parallel APIs. New code should use the Swift-native one.
37
31
 
38
- | Aspect | Modern (iOS 18+) | Legacy |
32
+ | Aspect | Swift-native API | Legacy API |
39
33
  |---|---|---|
40
- | Pattern | `let result = try await request.perform(on: image)` | `VNImageRequestHandler` + completion handler |
41
- | Request types | Swift types - structs and classes (`RecognizeTextRequest`, `DetectFaceRectanglesRequest`) | ObjC classes (`VNRecognizeTextRequest`, `VNDetectFaceRectanglesRequest`) |
42
- | Concurrency | Native async/await | Completion handlers or synchronous `perform` |
43
- | Observations | Typed return values | Cast `results` from `[Any]` |
44
- | Availability | iOS 18+ / macOS 15+ | iOS 11+ |
34
+ | Availability | iOS 18, macOS 15, tvOS 18, visionOS 2 | iOS 11 and later (individual requests vary, e.g. `VNRecognizeTextRequest` is iOS 13) |
35
+ | Types | Swift structs such as `RecognizeTextRequest`, `DetectFaceRectanglesRequest` | Objective-C classes such as `VNRecognizeTextRequest`, `VNDetectFaceRectanglesRequest` |
36
+ | Running | `try await request.perform(on: image)` | `VNImageRequestHandler` plus `perform([request])` and a completion closure |
37
+ | Results | Typed return value (`[RecognizedTextObservation]`, `[FaceObservation]`) | `request.results` cast from a generic observation array |
38
+ | Geometry | `NormalizedRect` / `NormalizedPoint` with conversion helpers | `CGRect` / `CGPoint` in normalized space |
45
39
 
46
- The modern API uses the `ImageProcessingRequest` protocol. Each request type
47
- has a `perform(on:orientation:)` method that accepts `CGImage`, `CIImage`,
48
- `CVPixelBuffer`, `CMSampleBuffer`, `Data`, or `URL`. Most requests are
49
- structs; stateful requests for video tracking (e.g., `TrackObjectRequest`,
50
- `TrackRectangleRequest`, `DetectTrajectoriesRequest`) are final classes.
40
+ Every Swift-native image request conforms to `ImageProcessingRequest`, whose
41
+ `perform(on:orientation:)` accepts a `CGImage`, `CIImage`, `CVPixelBuffer`,
42
+ `CMSampleBuffer`, image `Data` or a file `URL`. The orientation argument is
43
+ optional.
51
44
 
52
- ## Request Pattern (Modern API)
45
+ Most requests are value types. Requests that must remember earlier frames are
46
+ `final class` types conforming to `StatefulRequest`: `TrackObjectRequest`,
47
+ `TrackRectangleRequest`, `TrackOpticalFlowRequest`, `DetectTrajectoriesRequest`,
48
+ `DetectHumanBodyPose3DRequest` and `GeneratePersonSegmentationRequest`. Keep one
49
+ instance alive for the whole sequence.
53
50
 
54
- All modern Vision requests follow the same pattern: create a request struct,
55
- call `perform(on:)`, and handle the typed result.
51
+ ## The request pattern
52
+
53
+ Build the request, set options, await `perform(on:)`, read typed results.
56
54
 
57
55
  ```swift
58
56
  import Vision
59
57
 
60
- func recognizeText(in image: CGImage) async throws -> [String] {
58
+ func menuLines(in photo: CGImage) async throws -> [String] {
61
59
  var request = RecognizeTextRequest()
62
60
  request.recognitionLevel = .accurate
63
- request.recognitionLanguages = [Locale.Language(identifier: "en-US")]
64
-
65
- let observations = try await request.perform(on: image)
66
- return observations.compactMap { observation in
67
- observation.topCandidates(1).first?.string
68
- }
61
+ request.recognitionLanguages = [Locale.Language(identifier: "it-IT")]
62
+ let observations = try await request.perform(on: photo)
63
+ return observations.compactMap { $0.topCandidates(1).first?.string }
69
64
  }
70
65
  ```
71
66
 
72
- ### Legacy Pattern (Pre-iOS 18)
73
-
74
- Use `VNImageRequestHandler` with completion-based requests when targeting
75
- older deployment versions.
67
+ The same job with the legacy API, for deployment targets below iOS 18:
76
68
 
77
69
  ```swift
78
70
  import Vision
79
71
 
80
- func recognizeTextLegacy(in image: CGImage) throws -> [String] {
81
- var recognized: [String] = []
82
- let request = VNRecognizeTextRequest { request, error in
83
- guard let observations = request.results as? [VNRecognizedTextObservation] else { return }
84
- recognized = observations.compactMap { $0.topCandidates(1).first?.string }
72
+ func legacyMenuLines(in photo: CGImage) throws -> [String] {
73
+ var lines: [String] = []
74
+ let request = VNRecognizeTextRequest { finished, _ in
75
+ let found = finished.results as? [VNRecognizedTextObservation] ?? []
76
+ lines = found.compactMap { $0.topCandidates(1).first?.string }
85
77
  }
86
78
  request.recognitionLevel = .accurate
87
-
88
- let handler = VNImageRequestHandler(cgImage: image)
89
- try handler.perform([request])
90
- return recognized
79
+ try VNImageRequestHandler(cgImage: photo).perform([request])
80
+ return lines
91
81
  }
92
82
  ```
93
83
 
94
- ## Text Recognition (OCR)
95
-
96
- ### Modern: RecognizeTextRequest (iOS 18+)
97
-
98
- ```swift
99
- var request = RecognizeTextRequest()
100
- request.recognitionLevel = .accurate // .fast for real-time
101
- request.recognitionLanguages = [
102
- Locale.Language(identifier: "en-US"),
103
- Locale.Language(identifier: "fr-FR"),
104
- ]
105
- request.usesLanguageCorrection = true
106
- request.customWords = ["SwiftUI", "Xcode"] // domain-specific terms
107
-
108
- let observations = try await request.perform(on: cgImage)
109
- for observation in observations {
110
- guard let candidate = observation.topCandidates(1).first else { continue }
111
- let text = candidate.string
112
- let confidence = candidate.confidence // 0.0 ... 1.0
113
- let bounds = observation.boundingBox // normalized coordinates
114
- }
115
- ```
84
+ `VNImageRequestHandler.perform` is synchronous and calls the completion before
85
+ it returns, so run it on a background queue.
116
86
 
117
- ### Legacy: VNRecognizeTextRequest
87
+ ## Text recognition (OCR)
118
88
 
119
- ```swift
120
- let request = VNRecognizeTextRequest()
121
- request.recognitionLevel = .accurate
122
- request.recognitionLanguages = ["en-US", "fr-FR"]
123
- request.usesLanguageCorrection = true
124
- ```
89
+ `RecognizeTextRequest` (iOS 18+) options:
125
90
 
126
- **Key differences:** Modern API uses `Locale.Language` for languages; legacy
127
- uses string identifiers. Both support `.accurate` (best quality) and `.fast`
128
- (real-time suitable) recognition levels.
91
+ - `recognitionLevel`: `.accurate` for stills and offline work, `.fast` for
92
+ live video.
93
+ - `recognitionLanguages`: `[Locale.Language]`, ordered by priority.
94
+ - `usesLanguageCorrection`: applies language-model correction; turn it off for
95
+ codes, serial numbers and similar strings.
96
+ - `customWords`: domain vocabulary the corrector should accept.
129
97
 
130
- ## Face Detection
98
+ Each `RecognizedTextObservation` offers `topCandidates(_:)`; a candidate
99
+ (`RecognizedText`) has `string` and a `confidence` from 0.0 to 1.0. The
100
+ observation's `boundingBox` is a `NormalizedRect`.
131
101
 
132
- Detect face rectangles, landmarks (eyes, nose, mouth), and capture quality.
102
+ `VNRecognizeTextRequest` has the same `recognitionLevel` and
103
+ `usesLanguageCorrection` switches but takes languages as identifier strings
104
+ such as `["de-DE", "en-GB"]`. That is the practical difference: `Locale.Language`
105
+ values in the new API, strings in the old one.
133
106
 
134
- ```swift
135
- // Modern API
136
- let faceRequest = DetectFaceRectanglesRequest()
137
- let faces = try await faceRequest.perform(on: cgImage)
138
-
139
- for face in faces {
140
- let boundingBox = face.boundingBox // normalized CGRect
141
- let roll = face.roll // Measurement<UnitAngle>
142
- let yaw = face.yaw // Measurement<UnitAngle>
143
- }
107
+ ## Faces
144
108
 
145
- // Landmarks (eyes, nose, mouth contours)
146
- var landmarkRequest = DetectFaceLandmarksRequest()
147
- let landmarkFaces = try await landmarkRequest.perform(on: cgImage)
148
- for face in landmarkFaces {
149
- let landmarks = face.landmarks
150
- let leftEye = landmarks?.leftEye?.normalizedPoints
151
- let nose = landmarks?.nose?.normalizedPoints
152
- }
153
- ```
109
+ - `DetectFaceRectanglesRequest` returns `[FaceObservation]`. Each has a
110
+ `boundingBox` (`NormalizedRect`) and `roll`, `yaw` and `pitch` as
111
+ `Measurement<UnitAngle>`.
112
+ - `DetectFaceLandmarksRequest` fills the optional `landmarks`. Regions such as
113
+ `leftEye`, `rightEye`, `nose`, `outerLips` and `faceContour` expose `points`
114
+ (`[NormalizedPoint]`) and `pointsInImageCoordinates(_:origin:)`. The legacy
115
+ `VNFaceLandmarkRegion2D` calls the same data `normalizedPoints`.
116
+ - `DetectFaceCaptureQualityRequest` fills `captureQuality?.score`.
154
117
 
155
- ### Coordinate System
118
+ ### Coordinates
156
119
 
157
- Vision uses a normalized coordinate system with origin at the bottom-left.
158
- Convert to UIKit (top-left origin) before display:
120
+ Vision coordinates are normalized to 0...1 with the origin at the lower left.
121
+ UIKit and SwiftUI put the origin at the top left, so flip before drawing:
159
122
 
160
123
  ```swift
161
- func convertToUIKit(_ rect: CGRect, imageHeight: CGFloat) -> CGRect {
162
- CGRect(
163
- x: rect.origin.x,
164
- y: imageHeight - rect.origin.y - rect.height,
165
- width: rect.width,
166
- height: rect.height
167
- )
168
- }
169
- ```
170
-
171
- ## Barcode Detection
124
+ import Vision
172
125
 
173
- Detect 1D and 2D barcodes including QR codes.
126
+ func overlayFrame(for face: FaceObservation, imageSize: CGSize) -> CGRect {
127
+ face.boundingBox.toImageCoordinates(imageSize, origin: .upperLeft)
128
+ }
174
129
 
175
- ```swift
176
- var request = DetectBarcodesRequest()
177
- request.symbologies = [.qr, .ean13, .code128, .pdf417]
178
-
179
- let barcodes = try await request.perform(on: cgImage)
180
- for barcode in barcodes {
181
- let payload = barcode.payloadString // decoded content
182
- let symbology = barcode.symbology // .qr, .ean13, etc.
183
- let bounds = barcode.boundingBox // normalized rect
130
+ func flippedRect(_ normalized: CGRect, imageSize: CGSize) -> CGRect {
131
+ let w = normalized.width * imageSize.width
132
+ let h = normalized.height * imageSize.height
133
+ let x = normalized.minX * imageSize.width
134
+ let y = imageSize.height - normalized.minY * imageSize.height - h
135
+ return CGRect(x: x, y: y, width: w, height: h)
184
136
  }
185
137
  ```
186
138
 
187
- Common symbologies: `.qr`, `.aztec`, `.pdf417`, `.dataMatrix`, `.ean8`,
188
- `.ean13`, `.code39`, `.code128`, `.upce`, `.itf14`.
139
+ The manual version keeps x, width and height and computes
140
+ `y = imageHeight - originY - height`.
189
141
 
190
- ## Document Scanning (iOS 26+)
142
+ ## Barcodes
191
143
 
192
- `RecognizeDocumentsRequest` provides structured document reading with layout
193
- understanding beyond basic OCR. Returns `DocumentObservation` objects with a
194
- nested `Container` structure for paragraphs, tables, lists, and barcodes.
144
+ `DetectBarcodesRequest` reads 1D and 2D codes, QR included. Set `symbologies`
145
+ to only what the product accepts, for example `[.qr, .pdf417, .ean13, .code128]`.
146
+ Each `BarcodeObservation` carries `payloadString` (decoded text, optional),
147
+ `symbology` and a normalized `boundingBox`. Frequently used symbologies:
148
+ `.qr`, `.aztec`, `.dataMatrix`, `.pdf417`, `.ean8`, `.ean13`, `.upce`,
149
+ `.code39`, `.code128`, `.itf14`. The full list is in
150
+ `references/vision-requests.md`.
195
151
 
196
- ```swift
197
- var request = RecognizeDocumentsRequest()
198
- let documents = try await request.perform(on: cgImage)
199
-
200
- for observation in documents {
201
- let container = observation.document
152
+ ## Structured documents (iOS 26+)
202
153
 
203
- // Full text content
204
- let fullText = container.text
205
-
206
- // Structured access to paragraphs
207
- for paragraph in container.paragraphs {
208
- let paragraphText = paragraph.text
209
- }
154
+ `RecognizeDocumentsRequest` goes beyond line-by-line OCR and understands layout.
155
+ It returns `[DocumentObservation]`; `observation.document` is a
156
+ `DocumentObservation.Container` with:
210
157
 
211
- // Tables and lists
212
- for table in container.tables { /* structured table data */ }
213
- for list in container.lists { /* structured list data */ }
158
+ - `text`: the whole document as a text block (`.transcript` for the string)
159
+ - `paragraphs`: text blocks, each with `.transcript`
160
+ - `tables` (rows and cells), `lists` (items), `barcodes`
161
+ - `title`: optional text block
214
162
 
215
- // Embedded barcodes detected within the document
216
- for barcode in container.barcodes { /* barcode data */ }
163
+ ```swift
164
+ import Vision
217
165
 
218
- // Document title if detected
219
- if let title = container.title { print(title) }
166
+ func invoiceParagraphs(from scan: CGImage) async throws -> [String] {
167
+ let request = RecognizeDocumentsRequest()
168
+ guard let document = try await request.perform(on: scan).first?.document else { return [] }
169
+ return document.paragraphs.map(\.transcript)
220
170
  }
221
171
  ```
222
172
 
223
- For simpler document camera scanning, use VisionKit's
224
- `VNDocumentCameraViewController` which provides a full-screen camera UI with
225
- auto-capture, perspective correction, and multi-page scanning.
173
+ When the user should photograph paper with the camera, VisionKit's
174
+ `VNDocumentCameraViewController` is simpler: a full-screen camera with
175
+ automatic capture, perspective correction and multi-page scans. See
176
+ `references/visionkit-scanner.md`.
226
177
 
227
- ## Image Segmentation
178
+ ## Segmentation
228
179
 
229
- ### Modern: GeneratePersonSegmentationRequest (iOS 18+)
230
-
231
- ```swift
232
- var request = GeneratePersonSegmentationRequest()
233
- request.qualityLevel = .accurate // .balanced, .fast
180
+ `GeneratePersonSegmentationRequest` (iOS 18+, a stateful class) returns a
181
+ `PixelBufferObservation` mask. Read it as a `CGImage` with `try mask.cgImage`,
182
+ wrap it in `CIImage`, and composite with Core Image's
183
+ `CIFilter.blendWithMask()`.
234
184
 
235
- let mask = try await request.perform(on: cgImage)
236
- // mask is a PersonSegmentationObservation with a pixelBuffer property
237
- let maskBuffer = mask.pixelBuffer
238
- // Apply mask using Core Image: CIFilter.blendWithMask()
239
- ```
185
+ `qualityLevel` trades speed for detail. Approximate figures, to be confirmed
186
+ on the target device:
240
187
 
241
- ### Legacy: VNGeneratePersonSegmentationRequest
188
+ | Level | Detail | Rough cost | Mask size |
189
+ |---|---|---|---|
190
+ | `.accurate` | best edges | about 1 s | full resolution |
191
+ | `.balanced` | good | about 100 ms | 960 x 540 |
192
+ | `.fast` | coarse | about 10 ms | 256 x 144, suits real time |
242
193
 
243
- ```swift
244
- let request = VNGeneratePersonSegmentationRequest()
245
- request.qualityLevel = .accurate // .balanced, .fast
246
- request.outputPixelFormat = kCVPixelFormatType_OneComponent8
194
+ Legacy equivalent: `VNGeneratePersonSegmentationRequest` (iOS 15+) with
195
+ `qualityLevel`, `outputPixelFormat = kCVPixelFormatType_OneComponent8`, run
196
+ through `VNImageRequestHandler`; the mask is `request.results?.first?.pixelBuffer`.
247
197
 
248
- let handler = VNImageRequestHandler(cgImage: cgImage)
249
- try handler.perform([request])
198
+ Instance segmentation separates people from each other:
250
199
 
251
- guard let mask = request.results?.first?.pixelBuffer else { return }
252
- // Apply mask using Core Image: CIFilter.blendWithMask()
253
- ```
200
+ - `GeneratePersonInstanceMaskRequest` (iOS 18+) returns an optional
201
+ `InstanceMaskObservation`. `allInstances` is an `IndexSet`;
202
+ `generateMask(for: IndexSet(integer: n))` returns a `CVPixelBuffer` showing
203
+ only person `n`.
204
+ - `VNGeneratePersonInstanceMaskRequest` (iOS 17+) returns
205
+ `VNInstanceMaskObservation` with `allInstances`, `generateMask(forInstances:)`
206
+ and `generateMaskedImage(ofInstances:from:croppedToInstancesExtent:)`, which
207
+ takes the request handler and a crop flag.
254
208
 
255
- Quality levels:
256
- - `.accurate` -- best quality, slowest (~1s), full resolution
257
- - `.balanced` -- good quality, moderate speed (~100ms), 960x540
258
- - `.fast` -- lowest quality, fastest (~10ms), 256x144, suitable for real-time
209
+ Code for masks, background blur and instances is in `references/vision-requests.md`.
259
210
 
260
- ### Instance Segmentation (iOS 18+)
211
+ ## Object tracking
261
212
 
262
- Separate masks per person for individual effects.
213
+ `TrackObjectRequest` (iOS 18+) is a `final class` that conforms to
214
+ `ImageProcessingRequest` and `StatefulRequest` and keeps the tracking context
215
+ between frames itself. Seed it once, then call `perform(on:)` on each frame
216
+ with the same instance:
263
217
 
264
218
  ```swift
265
- // Modern API (iOS 18+)
266
- let request = GeneratePersonInstanceMaskRequest()
267
- let observation = try await request.perform(on: cgImage)
268
- let indices = observation.allInstances
269
-
270
- for index in indices {
271
- let mask = try observation.generateMask(forInstances: IndexSet(integer: index))
272
- // mask is a CVPixelBuffer with only this person visible
273
- }
274
- ```
275
-
276
- ```swift
277
- // Legacy API (iOS 17+)
278
- let request = VNGeneratePersonInstanceMaskRequest()
279
- let handler = VNImageRequestHandler(cgImage: cgImage)
280
- try handler.perform([request])
281
-
282
- guard let result = request.results?.first else { return }
283
- let indices = result.allInstances
284
- for index in indices {
285
- let instanceMask = try result.generateMaskedImage(
286
- ofInstances: IndexSet(integer: index),
287
- from: handler,
288
- croppedToInstancesExtent: false
289
- )
290
- }
291
- ```
292
-
293
- See [references/vision-requests.md](references/vision-requests.md) for mask composition and Core Image filter
294
- integration patterns.
295
-
296
- ## Object Tracking
219
+ import Vision
297
220
 
298
- ### Modern: TrackObjectRequest (iOS 18+)
221
+ final class BallTracker {
222
+ private let request: TrackObjectRequest
299
223
 
300
- `TrackObjectRequest` is a stateful request that maintains tracking context
301
- across frames. Conforms to both `ImageProcessingRequest` and `StatefulRequest`.
224
+ init(startBox: NormalizedRect) {
225
+ request = TrackObjectRequest(detectedObject: DetectedObjectObservation(boundingBox: startBox))
226
+ }
302
227
 
303
- ```swift
304
- // Initialize with a detected object's bounding box
305
- let initialObservation = DetectedObjectObservation(boundingBox: detectedRect)
306
- var request = TrackObjectRequest(observation: initialObservation)
307
- request.trackingLevel = .accurate
308
-
309
- // For each video frame:
310
- let results = try await request.perform(on: pixelBuffer)
311
- if let tracked = results.first {
312
- let updatedBounds = tracked.boundingBox
313
- let confidence = tracked.confidence
228
+ func follow(_ frame: CVPixelBuffer) async throws -> (NormalizedRect, Float)? {
229
+ guard let hit = try await request.perform(on: frame) else { return nil }
230
+ return (hit.boundingBox, hit.confidence)
231
+ }
314
232
  }
315
233
  ```
316
234
 
317
- ### Legacy: VNTrackObjectRequest
318
-
319
- ```swift
320
- let trackRequest = VNTrackObjectRequest(detectedObjectObservation: initialObservation)
321
- trackRequest.trackingLevel = .accurate
322
-
323
- let sequenceHandler = VNSequenceRequestHandler()
324
- // For each frame:
325
- try sequenceHandler.perform([trackRequest], on: pixelBuffer)
326
- if let result = trackRequest.results?.first {
327
- let updatedBounds = result.boundingBox
328
- trackRequest.inputObservation = result
329
- }
330
- ```
235
+ The Swift-native `TrackObjectRequest` has no `trackingLevel`;
236
+ `TrackRectangleRequest` does. With the legacy API, create
237
+ `VNTrackObjectRequest(detectedObjectObservation:)`, set
238
+ `trackingLevel = .accurate`, reuse one `VNSequenceRequestHandler` for every
239
+ frame via `perform([request], on: pixelBuffer)`, and feed each result back
240
+ through `inputObservation`.
331
241
 
332
- ## Other Request Types
242
+ ## Other requests
333
243
 
334
- Vision provides additional requests covered in [references/vision-requests.md](references/vision-requests.md):
244
+ All of these are Swift-native request types available on iOS 18 and macOS 15.
335
245
 
336
- | Request | Purpose |
246
+ | Request | What it gives you |
337
247
  |---|---|
338
- | `ClassifyImageRequest` | Classify scene content (outdoor, food, animal, etc.) |
339
- | `GenerateAttentionBasedSaliencyImageRequest` | Heat map of where viewers focus attention |
340
- | `GenerateObjectnessBasedSaliencyImageRequest` | Heat map of object-like regions |
341
- | `GenerateForegroundInstanceMaskRequest` | Foreground object segmentation (not person-specific) |
342
- | `DetectRectanglesRequest` | Detect rectangular shapes (documents, cards, screens) |
343
- | `DetectHorizonRequest` | Detect horizon angle for auto-leveling photos |
344
- | `DetectHumanBodyPoseRequest` | Detect body joints (shoulders, elbows, knees) |
345
- | `DetectHumanBodyPose3DRequest` | 3D human body pose estimation |
346
- | `DetectHumanHandPoseRequest` | Detect hand joints and finger positions |
347
- | `DetectAnimalBodyPoseRequest` | Detect animal body joint positions |
348
- | `DetectFaceCaptureQualityRequest` | Face capture quality scoring (0-1) for photo selection |
349
- | `TrackRectangleRequest` | Track rectangular objects across video frames |
350
- | `TrackOpticalFlowRequest` | Optical flow between video frames |
351
- | `DetectTrajectoriesRequest` | Detect object trajectories in video |
352
-
353
- All modern request types above are iOS 18+ / macOS 15+.
354
-
355
- ## Core ML Integration
356
-
357
- Run custom Core ML models through Vision for automatic image preprocessing
358
- (resizing, normalization, color space conversion).
248
+ | `ClassifyImageRequest` | Scene labels (beach, food, dog, and so on) |
249
+ | `GenerateAttentionBasedSaliencyImageRequest` | Heat map of where a viewer's eye goes |
250
+ | `GenerateObjectnessBasedSaliencyImageRequest` | Heat map of regions that look like objects |
251
+ | `GenerateForegroundInstanceMaskRequest` | Masks for foreground subjects of any kind, not only people |
252
+ | `DetectRectanglesRequest` | Rectangular shapes: cards, receipts, screens |
253
+ | `DetectHorizonRequest` | Horizon angle for straightening a photo |
254
+ | `DetectHumanBodyPoseRequest` / `DetectHumanBodyPose3DRequest` | 2D body joints / 3D body pose |
255
+ | `DetectHumanHandPoseRequest` | Hand and finger joints |
256
+ | `DetectAnimalBodyPoseRequest` | Animal joints |
257
+ | `DetectFaceCaptureQualityRequest` | Face capture quality score 0...1, for choosing the best shot |
258
+ | `TrackRectangleRequest` | Follows a rectangle across frames |
259
+ | `TrackOpticalFlowRequest` | Motion field between consecutive frames |
260
+ | `DetectTrajectoriesRequest` | Paths of moving objects in video |
261
+
262
+ ## Running Core ML models through Vision
263
+
264
+ Vision prepares the image for the model (scaling, cropping, pixel format,
265
+ color space, orientation), so hand it the original image.
359
266
 
360
267
  ```swift
361
- // Modern API (iOS 18+)
362
- let model = try MLModel(contentsOf: modelURL)
363
- let request = CoreMLRequest(model: .init(model))
364
- let results = try await request.perform(on: cgImage)
365
-
366
- // Classification model
367
- if let classification = results.first as? ClassificationObservation {
368
- let label = classification.identifier
369
- let confidence = classification.confidence
370
- }
371
- ```
268
+ import CoreML
269
+ import Vision
372
270
 
373
- ```swift
374
- // Legacy API
375
- let vnModel = try VNCoreMLModel(for: model)
376
- let request = VNCoreMLRequest(model: vnModel) { request, error in
377
- guard let results = request.results as? [VNClassificationObservation] else { return }
378
- let topResult = results.first
271
+ func plantSpecies(in leaf: CGImage, modelURL: URL) async throws -> (String, Float)? {
272
+ let model = try await MLModel.load(contentsOf: modelURL)
273
+ let request = CoreMLRequest(model: try CoreMLModelContainer(model: model))
274
+ let results = try await request.perform(on: leaf)
275
+ guard let best = results.first as? ClassificationObservation else { return nil }
276
+ return (best.identifier, best.confidence)
379
277
  }
380
- let handler = VNImageRequestHandler(cgImage: cgImage)
381
- try handler.perform([request])
382
278
  ```
383
279
 
384
- For model conversion and optimization, see the `coreml` skill.
280
+ Before iOS 18: wrap the model with `VNCoreMLModel(for:)`, create
281
+ `VNCoreMLRequest(model:completionHandler:)`, cast `results` to
282
+ `[VNClassificationObservation]`, and run it with `VNImageRequestHandler`.
385
283
 
386
- ## VisionKit: DataScannerViewController
284
+ Model loading, compute units, conversion and optimization belong to the
285
+ `coreml` skill.
387
286
 
388
- `DataScannerViewController` provides a full-screen live camera scanner for text
389
- and barcodes. See [references/visionkit-scanner.md](references/visionkit-scanner.md) for complete patterns.
287
+ ## VisionKit live scanning: DataScannerViewController
390
288
 
391
- ### Quick Start
289
+ `DataScannerViewController` (iOS 16+) is a full-screen live camera that finds
290
+ text and barcodes and highlights them.
392
291
 
393
292
  ```swift
293
+ import UIKit
394
294
  import VisionKit
395
295
 
396
- // Check availability (requires A12+ chip and camera)
397
- guard DataScannerViewController.isSupported,
398
- DataScannerViewController.isAvailable else { return }
399
-
400
- let scanner = DataScannerViewController(
401
- recognizedDataTypes: [
402
- .text(languages: ["en"]),
403
- .barcode(symbologies: [.qr, .ean13])
404
- ],
405
- qualityLevel: .balanced,
406
- recognizesMultipleItems: true,
407
- isHighFrameRateTrackingEnabled: true,
408
- isHighlightingEnabled: true
409
- )
410
- scanner.delegate = self
411
- present(scanner, animated: true) {
412
- try? scanner.startScanning()
296
+ @MainActor
297
+ func presentTicketScanner(from host: UIViewController, delegate: DataScannerViewControllerDelegate) {
298
+ guard DataScannerViewController.isSupported, DataScannerViewController.isAvailable else { return }
299
+ let scanner = DataScannerViewController(
300
+ recognizedDataTypes: [.text(languages: ["en"]), .barcode(symbologies: [.qr, .aztec])],
301
+ qualityLevel: .balanced,
302
+ recognizesMultipleItems: false,
303
+ isHighFrameRateTrackingEnabled: true,
304
+ isHighlightingEnabled: true
305
+ )
306
+ scanner.delegate = delegate
307
+ host.present(scanner, animated: true) {
308
+ try? scanner.startScanning()
309
+ }
413
310
  }
414
311
  ```
415
312
 
416
- ### SwiftUI Integration
417
-
418
- Wrap `DataScannerViewController` in `UIViewControllerRepresentable`. See
419
- [references/visionkit-scanner.md](references/visionkit-scanner.md) for the full implementation.
420
-
421
- ## Common Mistakes
422
-
423
- **DON'T:** Use the legacy `VNImageRequestHandler` API for new iOS 18+ projects.
424
- **DO:** Use modern struct-based requests with `perform(on:)` and async/await.
425
- **Why:** Modern API provides type safety, better Swift concurrency support, and cleaner error handling.
426
-
427
- **DON'T:** Forget to convert normalized coordinates before drawing bounding boxes.
428
- **DO:** Use `VNImageRectForNormalizedRect(_:_:_:)` or manual conversion from bottom-left origin to UIKit top-left origin.
429
- **Why:** Vision uses normalized coordinates (0...1) with bottom-left origin; UIKit uses points with top-left origin.
430
-
431
- **DON'T:** Run Vision requests on the main thread.
432
- **DO:** Perform requests on a background thread or use async/await from a detached task.
433
- **Why:** Image analysis is CPU/GPU-intensive and blocks the UI if run on the main actor.
434
-
435
- **DON'T:** Use `.accurate` recognition level for real-time camera feeds.
436
- **DO:** Use `.fast` for live video, `.accurate` for still images or offline processing.
437
- **Why:** Accurate recognition is too slow for 30fps video; fast recognition trades quality for speed.
438
-
439
- **DON'T:** Ignore the `confidence` score on observations.
440
- **DO:** Filter results by confidence threshold (e.g., > 0.5) appropriate for your use case.
441
- **Why:** Low-confidence results are often incorrect and degrade user experience.
442
-
443
- **DON'T:** Create a new `VNImageRequestHandler` for each frame when tracking objects.
444
- **DO:** Use `VNSequenceRequestHandler` for video frame sequences.
445
- **Why:** Sequence handler maintains temporal context for tracking; per-frame handlers lose state.
446
-
447
- **DON'T:** Request all barcode symbologies when you only need QR codes.
448
- **DO:** Specify only the symbologies you need in the request.
449
- **Why:** Fewer symbologies means faster detection and fewer false positives.
450
-
451
- **DON'T:** Assume `DataScannerViewController` is available on all devices.
452
- **DO:** Check both `isSupported` (hardware) and `isAvailable` (user permissions) before presenting.
453
- **Why:** Requires A12+ chip; `isAvailable` also checks camera access authorization.
454
-
455
- ## Review Checklist
456
-
457
- - [ ] Uses modern Vision API (iOS 18+) unless targeting older deployments
458
- - [ ] Vision requests run off the main thread (async/await or background queue)
459
- - [ ] Normalized coordinates converted before UI display
460
- - [ ] Confidence threshold applied to filter low-quality observations
461
- - [ ] Recognition level matches use case (`.fast` for video, `.accurate` for stills)
462
- - [ ] Language hints set for text recognition when input language is known
463
- - [ ] Barcode symbologies limited to only those needed
464
- - [ ] `DataScannerViewController` availability checked before presentation
465
- - [ ] Camera usage description (`NSCameraUsageDescription`) in Info.plist for VisionKit
466
- - [ ] Person segmentation quality level appropriate for use case
467
- - [ ] `VNSequenceRequestHandler` used for video frame tracking (not per-frame handler)
468
- - [ ] Error handling covers request failures and empty results
313
+ `isSupported` checks the hardware (A12 Bionic or later); `isAvailable`
314
+ additionally requires camera permission. In SwiftUI, wrap the controller in a
315
+ `UIViewControllerRepresentable`; see `references/visionkit-scanner.md`.
316
+
317
+ ## Common mistakes
318
+
319
+ 1. **Legacy handlers in new code.** A project targeting iOS 18 or later should
320
+ use the struct requests and `perform(on:)`: typed results, async/await, and
321
+ Swift errors instead of casts and callbacks.
322
+ 2. **Drawing normalized coordinates directly.** Vision uses 0...1 with a
323
+ lower-left origin; UIKit uses points from the top left. Convert with
324
+ `toImageCoordinates(_:origin:)`, `VNImageRectForNormalizedRect(_:_:_:)` or a
325
+ manual flip.
326
+ 3. **Running requests on the main thread.** Recognition is heavy CPU/GPU work.
327
+ Await the async API from a task, or dispatch legacy handlers to a
328
+ background queue, never block the main actor.
329
+ 4. **`.accurate` on a live camera feed.** It cannot keep up with 30 fps. Use
330
+ `.fast` for video and `.accurate` for photos and offline batches.
331
+ 5. **Ignoring confidence.** Low-confidence results are often wrong; drop
332
+ anything under a threshold that fits the feature (0.5 is a common start).
333
+ 6. **A new image handler per video frame when tracking.** Legacy tracking
334
+ needs `VNSequenceRequestHandler`, which carries temporal state across frames.
335
+ 7. **Asking for every symbology.** Each extra symbology costs time and invites
336
+ false positives; list only the ones you accept, for example just `.qr`.
337
+ 8. **Assuming the scanner exists.** Check `DataScannerViewController.isSupported`
338
+ (hardware) and `isAvailable` (hardware plus camera authorization) first.
339
+
340
+ ## Review checklist
341
+
342
+ - [ ] Swift-native API used unless the deployment target is below iOS 18
343
+ - [ ] No Vision work blocks the main thread
344
+ - [ ] Normalized coordinates converted before anything is drawn
345
+ - [ ] Results filtered by a confidence threshold
346
+ - [ ] Recognition level fits the input: `.fast` for video, `.accurate` for stills
347
+ - [ ] Recognition languages set when the input language is known
348
+ - [ ] Barcode symbologies restricted to the needed set
349
+ - [ ] `DataScannerViewController` support and availability checked before presenting
350
+ - [ ] `NSCameraUsageDescription` present in Info.plist for VisionKit cameras
351
+ - [ ] Person segmentation quality level matches the use case
352
+ - [ ] Legacy video tracking uses one `VNSequenceRequestHandler`, not a handler per frame
353
+ - [ ] Request failures and empty results handled
469
354
 
470
355
  ## References
471
356
 
472
- - Vision request patterns: [references/vision-requests.md](references/vision-requests.md)
473
- - VisionKit scanner integration: [references/visionkit-scanner.md](references/visionkit-scanner.md)
474
- - Apple docs: [Vision](https://sosumi.ai/documentation/vision) |
475
- [VisionKit](https://sosumi.ai/documentation/visionkit) |
476
- [RecognizeTextRequest](https://sosumi.ai/documentation/vision/recognizetextrequest) |
477
- [DataScannerViewController](https://sosumi.ai/documentation/visionkit/datascannerviewcontroller)
357
+ - `references/vision-requests.md`
358
+ - `references/visionkit-scanner.md`
359
+ - https://developer.apple.com/documentation/vision
360
+ - https://developer.apple.com/documentation/visionkit
361
+ - https://developer.apple.com/documentation/vision/recognizetextrequest
362
+ - https://developer.apple.com/documentation/visionkit/datascannerviewcontroller