@sarjallab09/figma-intelligence 1.0.1 → 1.2.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 (297) hide show
  1. package/README.md +67 -36
  2. package/dist/bin/cli.js +2 -0
  3. package/dist/design-bridge/bridge.js +2 -0
  4. package/dist/figma-bridge-plugin/bridge-relay.js +2 -0
  5. package/dist/figma-bridge-plugin/code.js +1 -0
  6. package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package-lock.json +0 -3
  7. package/dist/figma-bridge-plugin/ui.html +4970 -0
  8. package/dist/figma-intelligence-layer/dist/index.js +2 -0
  9. package/dist/scripts/clean-existing-chunks.js +2 -0
  10. package/dist/scripts/connect-ai-tool.js +2 -0
  11. package/dist/scripts/convert-hub-pdfs.js +2 -0
  12. package/dist/scripts/figma-mcp-status.js +2 -0
  13. package/dist/scripts/register-codex-mcp.js +2 -0
  14. package/dist/scripts/test-copilot-chat.js +2 -0
  15. package/package.json +11 -8
  16. package/bin/cli.js +0 -859
  17. package/design-bridge/bridge.js +0 -196
  18. package/design-bridge/lib/assets.js +0 -367
  19. package/design-bridge/lib/prompt.js +0 -85
  20. package/design-bridge/lib/server.js +0 -66
  21. package/design-bridge/lib/stitch.js +0 -37
  22. package/design-bridge/lib/tokens.js +0 -82
  23. package/design-bridge/package-lock.json +0 -579
  24. package/figma-bridge-plugin/README.md +0 -97
  25. package/figma-bridge-plugin/anthropic-chat-runner.js +0 -192
  26. package/figma-bridge-plugin/bridge-relay.js +0 -2363
  27. package/figma-bridge-plugin/chat-runner.js +0 -459
  28. package/figma-bridge-plugin/code.js +0 -1528
  29. package/figma-bridge-plugin/codex-runner.js +0 -505
  30. package/figma-bridge-plugin/component-schemas.js +0 -110
  31. package/figma-bridge-plugin/content-context.js +0 -869
  32. package/figma-bridge-plugin/create-button.js +0 -216
  33. package/figma-bridge-plugin/gemini-cli-runner.js +0 -291
  34. package/figma-bridge-plugin/gemini-runner.js +0 -187
  35. package/figma-bridge-plugin/html-to-figma.js +0 -927
  36. package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
  37. package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +0 -159
  38. package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +0 -162
  39. package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +0 -148
  40. package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +0 -314
  41. package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +0 -175
  42. package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +0 -180
  43. package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +0 -165
  44. package/figma-bridge-plugin/perplexity-runner.js +0 -188
  45. package/figma-bridge-plugin/references/SKILL.md +0 -178
  46. package/figma-bridge-plugin/references/anatomy-spec.md +0 -159
  47. package/figma-bridge-plugin/references/api-spec.md +0 -162
  48. package/figma-bridge-plugin/references/color-spec.md +0 -148
  49. package/figma-bridge-plugin/references/full-spec-template.md +0 -314
  50. package/figma-bridge-plugin/references/property-spec.md +0 -175
  51. package/figma-bridge-plugin/references/screen-reader-spec.md +0 -180
  52. package/figma-bridge-plugin/references/structure-spec.md +0 -165
  53. package/figma-bridge-plugin/shared-prompt-config.js +0 -604
  54. package/figma-bridge-plugin/spec-helpers/build-table.js +0 -269
  55. package/figma-bridge-plugin/spec-helpers/classify-elements.js +0 -189
  56. package/figma-bridge-plugin/spec-helpers/index.js +0 -35
  57. package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +0 -49
  58. package/figma-bridge-plugin/spec-helpers/position-markers.js +0 -158
  59. package/figma-bridge-plugin/stitch-auth.js +0 -322
  60. package/figma-bridge-plugin/stitch-runner.js +0 -1427
  61. package/figma-bridge-plugin/token-resolver.js +0 -107
  62. package/figma-bridge-plugin/ui.html +0 -4467
  63. package/figma-intelligence-layer/.env.example +0 -39
  64. package/figma-intelligence-layer/docs/local-image-generation.md +0 -60
  65. package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +0 -101
  66. package/figma-intelligence-layer/jest.config.js +0 -14
  67. package/figma-intelligence-layer/mcp-config.json +0 -19
  68. package/figma-intelligence-layer/package-lock.json +0 -5892
  69. package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +0 -67
  70. package/figma-intelligence-layer/scripts/start-comfyui.sh +0 -33
  71. package/figma-intelligence-layer/src/index.ts +0 -2233
  72. package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +0 -404
  73. package/figma-intelligence-layer/src/shared/cache.ts +0 -187
  74. package/figma-intelligence-layer/src/shared/color-operations.ts +0 -533
  75. package/figma-intelligence-layer/src/shared/color-utils.ts +0 -138
  76. package/figma-intelligence-layer/src/shared/component-script-builder.ts +0 -413
  77. package/figma-intelligence-layer/src/shared/component-templates.ts +0 -2767
  78. package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +0 -694
  79. package/figma-intelligence-layer/src/shared/decision-log.ts +0 -128
  80. package/figma-intelligence-layer/src/shared/design-system-context.ts +0 -568
  81. package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +0 -131
  82. package/figma-intelligence-layer/src/shared/design-system-matcher.ts +0 -184
  83. package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +0 -196
  84. package/figma-intelligence-layer/src/shared/design-system-tokens.ts +0 -295
  85. package/figma-intelligence-layer/src/shared/dtcg-validator.ts +0 -530
  86. package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +0 -671
  87. package/figma-intelligence-layer/src/shared/figma-bridge.ts +0 -1408
  88. package/figma-intelligence-layer/src/shared/font-config.ts +0 -126
  89. package/figma-intelligence-layer/src/shared/icon-catalog.ts +0 -360
  90. package/figma-intelligence-layer/src/shared/icon-fetch.ts +0 -80
  91. package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +0 -162
  92. package/figma-intelligence-layer/src/shared/response-compression.ts +0 -440
  93. package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +0 -324
  94. package/figma-intelligence-layer/src/shared/token-binder.ts +0 -505
  95. package/figma-intelligence-layer/src/shared/token-math.ts +0 -427
  96. package/figma-intelligence-layer/src/shared/token-naming.ts +0 -468
  97. package/figma-intelligence-layer/src/shared/token-utils.ts +0 -420
  98. package/figma-intelligence-layer/src/shared/types.ts +0 -346
  99. package/figma-intelligence-layer/src/shared/typography-presets.ts +0 -94
  100. package/figma-intelligence-layer/src/shared/unsplash.ts +0 -165
  101. package/figma-intelligence-layer/src/shared/vision-client.ts +0 -607
  102. package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +0 -334
  103. package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +0 -446
  104. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +0 -782
  105. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +0 -496
  106. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +0 -230
  107. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +0 -66
  108. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +0 -810
  109. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +0 -1191
  110. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +0 -1346
  111. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +0 -148
  112. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +0 -499
  113. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +0 -910
  114. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +0 -989
  115. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +0 -1160
  116. package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +0 -424
  117. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +0 -38
  118. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +0 -111
  119. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +0 -114
  120. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +0 -103
  121. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +0 -1060
  122. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +0 -18
  123. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +0 -39
  124. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +0 -58
  125. package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +0 -298
  126. package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +0 -197
  127. package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +0 -494
  128. package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +0 -356
  129. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +0 -123
  130. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +0 -663
  131. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +0 -56
  132. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +0 -614
  133. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +0 -113
  134. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +0 -178
  135. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +0 -470
  136. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +0 -429
  137. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +0 -226
  138. package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +0 -535
  139. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +0 -660
  140. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +0 -209
  141. package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +0 -540
  142. package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +0 -391
  143. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +0 -2019
  144. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +0 -131
  145. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +0 -381
  146. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +0 -565
  147. package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +0 -764
  148. package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +0 -535
  149. package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +0 -84
  150. package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +0 -401
  151. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +0 -68
  152. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +0 -78
  153. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +0 -93
  154. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +0 -596
  155. package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +0 -462
  156. package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +0 -1470
  157. package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +0 -829
  158. package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +0 -702
  159. package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +0 -483
  160. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +0 -501
  161. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +0 -106
  162. package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +0 -676
  163. package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +0 -560
  164. package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +0 -1043
  165. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +0 -620
  166. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +0 -331
  167. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +0 -77
  168. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +0 -54
  169. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +0 -287
  170. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +0 -71
  171. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +0 -43
  172. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +0 -71
  173. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +0 -221
  174. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +0 -166
  175. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +0 -232
  176. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +0 -234
  177. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +0 -270
  178. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +0 -249
  179. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +0 -231
  180. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +0 -293
  181. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +0 -240
  182. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +0 -243
  183. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +0 -307
  184. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +0 -143
  185. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +0 -227
  186. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +0 -233
  187. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +0 -282
  188. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +0 -276
  189. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +0 -223
  190. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +0 -255
  191. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +0 -289
  192. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +0 -261
  193. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +0 -290
  194. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +0 -265
  195. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +0 -238
  196. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +0 -255
  197. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +0 -128
  198. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +0 -286
  199. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +0 -255
  200. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +0 -330
  201. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +0 -247
  202. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +0 -250
  203. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +0 -247
  204. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +0 -144
  205. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +0 -264
  206. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +0 -251
  207. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +0 -261
  208. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +0 -248
  209. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +0 -270
  210. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +0 -251
  211. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +0 -142
  212. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +0 -282
  213. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +0 -250
  214. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +0 -258
  215. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +0 -265
  216. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +0 -319
  217. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +0 -256
  218. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +0 -232
  219. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +0 -239
  220. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +0 -252
  221. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +0 -270
  222. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +0 -244
  223. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +0 -143
  224. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +0 -243
  225. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +0 -259
  226. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +0 -293
  227. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +0 -144
  228. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +0 -289
  229. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +0 -267
  230. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +0 -232
  231. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +0 -257
  232. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +0 -319
  233. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +0 -121
  234. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +0 -430
  235. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +0 -312
  236. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +0 -129
  237. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +0 -78
  238. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +0 -2333
  239. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +0 -100
  240. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +0 -32
  241. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +0 -59
  242. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +0 -18
  243. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +0 -53
  244. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +0 -19
  245. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +0 -91
  246. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +0 -71
  247. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +0 -19
  248. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +0 -110
  249. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +0 -19
  250. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +0 -67
  251. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +0 -58
  252. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +0 -79
  253. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +0 -50
  254. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +0 -33
  255. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +0 -55
  256. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +0 -73
  257. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +0 -81
  258. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +0 -409
  259. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +0 -198
  260. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +0 -701
  261. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +0 -88
  262. package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +0 -135
  263. package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +0 -491
  264. package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +0 -416
  265. package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +0 -722
  266. package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +0 -449
  267. package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +0 -393
  268. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +0 -406
  269. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +0 -292
  270. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +0 -24
  271. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +0 -172
  272. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +0 -409
  273. package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +0 -594
  274. package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +0 -710
  275. package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +0 -458
  276. package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +0 -134
  277. package/figma-intelligence-layer/tests/apg-doc.test.ts +0 -101
  278. package/figma-intelligence-layer/tests/design-system-context.test.ts +0 -152
  279. package/figma-intelligence-layer/tests/design-system-matcher.test.ts +0 -144
  280. package/figma-intelligence-layer/tests/figma-bridge.test.ts +0 -83
  281. package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +0 -56
  282. package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +0 -69
  283. package/figma-intelligence-layer/tests/smoke.test.ts +0 -174
  284. package/figma-intelligence-layer/tests/spec-generator.test.ts +0 -127
  285. package/figma-intelligence-layer/tests/token-migrate.test.ts +0 -21
  286. package/figma-intelligence-layer/tests/token-naming.test.ts +0 -30
  287. package/figma-intelligence-layer/tsconfig.json +0 -19
  288. package/scripts/clean-existing-chunks.js +0 -179
  289. package/scripts/connect-ai-tool.js +0 -490
  290. package/scripts/convert-hub-pdfs.js +0 -425
  291. package/scripts/figma-mcp-status.js +0 -349
  292. package/scripts/register-codex-mcp.js +0 -96
  293. /package/{design-bridge → dist/design-bridge}/.env.example +0 -0
  294. /package/{design-bridge → dist/design-bridge}/package.json +0 -0
  295. /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/manifest.json +0 -0
  296. /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package.json +0 -0
  297. /package/{figma-intelligence-layer → dist/figma-intelligence-layer}/package.json +0 -0
@@ -1,989 +0,0 @@
1
- // ─────────────────────────────────────────────────────────────────────────────
2
- // WCAG Checker
3
- // Pure-function WCAG 2.2 compliance checks that operate on Figma node data.
4
- // Used by the a11y-audit tool.
5
- // ─────────────────────────────────────────────────────────────────────────────
6
-
7
- import { FigmaNode, WCAGIssue, RGBA } from "../../../shared/types.js";
8
- import {
9
- computeContrastRatio,
10
- figmaRgbaToHex,
11
- meetsWCAG,
12
- } from "../../../shared/token-utils.js";
13
-
14
- /** Minimum interactive touch target (WCAG 2.5.5). */
15
- export const MIN_TOUCH_TARGET = 44;
16
-
17
- // ─── Helpers ──────────────────────────────────────────────────────────────────
18
-
19
- export function extractSolidColor(node: FigmaNode): RGBA | null {
20
- if (!node.fills || node.fills.length === 0) return null;
21
- const solid = node.fills.find((f) => f.type === "SOLID" && f.color);
22
- return solid?.color ?? null;
23
- }
24
-
25
- export function findParentBgColor(
26
- nodeId: string,
27
- allNodes: FigmaNode[]
28
- ): RGBA | null {
29
- function findParent(id: string, nodes: FigmaNode[]): FigmaNode | null {
30
- for (const n of nodes) {
31
- if (n.children?.some((c) => c.id === id)) return n;
32
- if (n.children) {
33
- const found = findParent(id, n.children);
34
- if (found) return found;
35
- }
36
- }
37
- return null;
38
- }
39
-
40
- let current = nodeId;
41
- for (let depth = 0; depth < 12; depth++) {
42
- const parent = findParent(current, allNodes);
43
- if (!parent) break;
44
- const color = extractSolidColor(parent);
45
- if (color) return color;
46
- current = parent.id;
47
- }
48
- return { r: 1, g: 1, b: 1, a: 1 };
49
- }
50
-
51
- // ─── Individual checks ───────────────────────────────────────────────────────
52
-
53
- export function checkTextContrast(
54
- textNode: FigmaNode,
55
- allNodes: FigmaNode[],
56
- wcagLevel: "A" | "AA" | "AAA"
57
- ): WCAGIssue | null {
58
- const fgColor = extractSolidColor(textNode);
59
- if (!fgColor) return null;
60
-
61
- const bgColor = findParentBgColor(textNode.id, allNodes);
62
- if (!bgColor) return null;
63
-
64
- const fgHex = figmaRgbaToHex(fgColor.r, fgColor.g, fgColor.b);
65
- const bgHex = figmaRgbaToHex(bgColor.r, bgColor.g, bgColor.b);
66
-
67
- const fontSize = textNode.style?.fontSize ?? 16;
68
- const fontWeight = textNode.style?.fontWeight ?? 400;
69
- const isLargeText = fontSize >= 18 || (fontSize >= 14 && fontWeight >= 700);
70
-
71
- const ratio = computeContrastRatio(fgHex, bgHex);
72
- const effectiveLevel: "AA" | "AAA" = wcagLevel === "AAA" ? "AAA" : "AA";
73
- const passes = meetsWCAG(ratio, effectiveLevel, isLargeText);
74
-
75
- if (passes) return null;
76
-
77
- const minRatio = isLargeText
78
- ? (effectiveLevel === "AAA" ? 4.5 : 3.0)
79
- : (effectiveLevel === "AAA" ? 7.0 : 4.5);
80
-
81
- return {
82
- severity: ratio < 3.0 ? "error" : "warning",
83
- criterion: wcagLevel === "AAA" ? "1.4.6" : "1.4.3",
84
- nodeId: textNode.id,
85
- nodeName: textNode.name,
86
- issue: `Contrast ratio ${ratio.toFixed(2)}:1 below ${effectiveLevel} threshold (${minRatio}:1) for ${isLargeText ? "large" : "normal"} text`,
87
- currentValue: `${ratio.toFixed(2)}:1`,
88
- suggestedFix: `Increase contrast to at least ${minRatio}:1`,
89
- autoFixAvailable: true,
90
- };
91
- }
92
-
93
- export function checkTouchTarget(node: FigmaNode): WCAGIssue | null {
94
- if (!node.absoluteBoundingBox) return null;
95
- const w = node.width ?? 0;
96
- const h = node.height ?? 0;
97
-
98
- if (w < MIN_TOUCH_TARGET || h < MIN_TOUCH_TARGET) {
99
- return {
100
- severity: "error",
101
- criterion: "2.5.5",
102
- nodeId: node.id,
103
- nodeName: node.name,
104
- issue: `Interactive element is ${w}×${h}px, below the minimum ${MIN_TOUCH_TARGET}×${MIN_TOUCH_TARGET}px touch target`,
105
- currentValue: `${w}×${h}px`,
106
- suggestedFix: `Resize to at least ${MIN_TOUCH_TARGET}×${MIN_TOUCH_TARGET}px`,
107
- autoFixAvailable: true,
108
- };
109
- }
110
- return null;
111
- }
112
-
113
- export function checkFocusState(node: FigmaNode): WCAGIssue | null {
114
- if (node.type !== "COMPONENT_SET") return null;
115
- const hasFocus =
116
- Object.values(node.variantProperties ?? {}).some(
117
- (v) => typeof v === "string" && v.toLowerCase().includes("focus")
118
- ) ||
119
- node.children?.some(
120
- (c) =>
121
- c.name.toLowerCase().includes("focus") ||
122
- Object.values(c.variantProperties ?? {}).some(
123
- (v) => typeof v === "string" && v.toLowerCase().includes("focus")
124
- )
125
- );
126
-
127
- if (!hasFocus) {
128
- return {
129
- severity: "warning",
130
- criterion: "2.4.7",
131
- nodeId: node.id,
132
- nodeName: node.name,
133
- issue: "Component set has no focus state variant",
134
- currentValue: "No focus variant",
135
- suggestedFix: 'Add a "State=Focus" variant with a visible 2px focus ring',
136
- autoFixAvailable: false,
137
- };
138
- }
139
- return null;
140
- }
141
-
142
- export function checkFixedHeightTextContainer(node: FigmaNode): WCAGIssue | null {
143
- if (!node.children) return null;
144
- const hasTextChild = node.children.some((c) => c.type === "TEXT");
145
- if (!hasTextChild) return null;
146
-
147
- const isFixedHeight =
148
- node.primaryAxisSizingMode === "FIXED" ||
149
- (node.height !== undefined && node.primaryAxisSizingMode !== "AUTO");
150
-
151
- if (isFixedHeight && node.layoutMode && node.layoutMode !== "NONE") {
152
- return {
153
- severity: "warning",
154
- criterion: "1.4.4",
155
- nodeId: node.id,
156
- nodeName: node.name,
157
- issue: "Text container has fixed height which may clip text on resize",
158
- currentValue: `height: ${node.height}px (fixed)`,
159
- suggestedFix: 'Set vertical sizing to "Hug contents" (AUTO)',
160
- autoFixAvailable: true,
161
- };
162
- }
163
- return null;
164
- }
165
-
166
- // ─── New checks for comprehensive VPAT coverage ─────────────────────────────
167
-
168
- /** WCAG 2.5.8 Target Size (Minimum) – 24×24px at Level AA. */
169
- export const MIN_TARGET_SIZE_AA = 24;
170
-
171
- export function checkTargetSizeMinimum(node: FigmaNode): WCAGIssue | null {
172
- if (!node.absoluteBoundingBox) return null;
173
- const w = node.width ?? 0;
174
- const h = node.height ?? 0;
175
-
176
- if (w < MIN_TARGET_SIZE_AA || h < MIN_TARGET_SIZE_AA) {
177
- return {
178
- severity: "error",
179
- criterion: "2.5.8",
180
- nodeId: node.id,
181
- nodeName: node.name,
182
- issue: `Interactive element is ${w}×${h}px, below the minimum ${MIN_TARGET_SIZE_AA}×${MIN_TARGET_SIZE_AA}px target size`,
183
- currentValue: `${w}×${h}px`,
184
- suggestedFix: `Resize to at least ${MIN_TARGET_SIZE_AA}×${MIN_TARGET_SIZE_AA}px`,
185
- autoFixAvailable: true,
186
- };
187
- }
188
- return null;
189
- }
190
-
191
- /** WCAG 1.1.1 Non-text Content – heuristic check for images without descriptions. */
192
- export function checkNonTextContent(
193
- node: FigmaNode,
194
- allNodes: FigmaNode[]
195
- ): WCAGIssue | null {
196
- // Check IMAGE fill nodes and VECTOR nodes
197
- const isImage =
198
- node.fills?.some((f) => f.type === "IMAGE") ||
199
- node.type === "VECTOR" ||
200
- node.type === "BOOLEAN_OPERATION";
201
- if (!isImage) return null;
202
-
203
- // Skip decorative-sounding nodes
204
- const name = node.name.toLowerCase();
205
- if (name.includes("decorative") || name.includes("divider") || name.includes("separator")) {
206
- return null;
207
- }
208
-
209
- // Check if node has a description
210
- if (node.description && node.description.trim().length > 0) return null;
211
-
212
- // Check if a sibling TEXT node acts as a label
213
- const parent = findParentNode(node.id, allNodes);
214
- if (parent?.children) {
215
- const hasSiblingLabel = parent.children.some(
216
- (c) => c.type === "TEXT" && c.id !== node.id
217
- );
218
- if (hasSiblingLabel) return null;
219
- }
220
-
221
- return {
222
- severity: "warning",
223
- criterion: "1.1.1",
224
- nodeId: node.id,
225
- nodeName: node.name,
226
- issue: "Non-text content has no description or adjacent text label",
227
- currentValue: "No alt text / description",
228
- suggestedFix: "Add a description property or provide an adjacent text label. Mark decorative images by including 'decorative' in the name.",
229
- autoFixAvailable: false,
230
- };
231
- }
232
-
233
- /** WCAG 1.3.1 Info and Relationships – heuristic heading hierarchy check. */
234
- export function checkInfoAndRelationships(
235
- textNodes: FigmaNode[]
236
- ): WCAGIssue[] {
237
- const issues: WCAGIssue[] = [];
238
-
239
- // Identify heading-like text (large or bold)
240
- const headings = textNodes.filter((n) => {
241
- const fontSize = n.style?.fontSize ?? 16;
242
- const fontWeight = n.style?.fontWeight ?? 400;
243
- return fontSize >= 20 || fontWeight >= 700;
244
- });
245
-
246
- // Sort headings by visual position (top to bottom)
247
- headings.sort((a, b) => {
248
- const ay = a.absoluteBoundingBox?.y ?? 0;
249
- const by = b.absoluteBoundingBox?.y ?? 0;
250
- return ay - by;
251
- });
252
-
253
- // Check for logical hierarchy (font sizes should decrease or stay same going down)
254
- let prevFontSize = Infinity;
255
- for (const heading of headings) {
256
- const fontSize = heading.style?.fontSize ?? 16;
257
- if (fontSize > prevFontSize) {
258
- issues.push({
259
- severity: "warning",
260
- criterion: "1.3.1",
261
- nodeId: heading.id,
262
- nodeName: heading.name,
263
- issue: `Heading text (${fontSize}px) appears after smaller heading (${prevFontSize}px), suggesting inconsistent heading hierarchy`,
264
- currentValue: `${fontSize}px after ${prevFontSize}px`,
265
- suggestedFix: "Ensure headings follow a logical hierarchy (h1 > h2 > h3). Larger text should not appear after smaller headings.",
266
- autoFixAvailable: false,
267
- });
268
- }
269
- prevFontSize = fontSize;
270
- }
271
-
272
- return issues;
273
- }
274
-
275
- /** WCAG 1.3.2 Meaningful Sequence – heuristic reading order check. */
276
- export function checkMeaningfulSequence(
277
- allNodes: FigmaNode[]
278
- ): WCAGIssue[] {
279
- const issues: WCAGIssue[] = [];
280
-
281
- // Check top-level children: node tree order vs visual position
282
- for (const node of allNodes) {
283
- if (!node.children || node.children.length < 2) continue;
284
-
285
- const childrenWithPos = node.children
286
- .filter((c) => c.absoluteBoundingBox)
287
- .map((c, idx) => ({
288
- node: c,
289
- treeIndex: idx,
290
- visualY: c.absoluteBoundingBox!.y,
291
- visualX: c.absoluteBoundingBox!.x,
292
- }));
293
-
294
- // Sort by visual reading order (top-to-bottom, left-to-right)
295
- const visualOrder = [...childrenWithPos].sort(
296
- (a, b) => a.visualY - b.visualY || a.visualX - b.visualX
297
- );
298
-
299
- // Count significant order mismatches
300
- let mismatches = 0;
301
- for (let i = 0; i < visualOrder.length; i++) {
302
- if (visualOrder[i].treeIndex !== childrenWithPos[i]?.treeIndex) {
303
- mismatches++;
304
- }
305
- }
306
-
307
- // Only flag if more than 30% of children are out of order (to avoid noise)
308
- if (mismatches > childrenWithPos.length * 0.3 && mismatches >= 3) {
309
- issues.push({
310
- severity: "warning",
311
- criterion: "1.3.2",
312
- nodeId: node.id,
313
- nodeName: node.name,
314
- issue: `Layer order differs significantly from visual reading order (${mismatches} of ${childrenWithPos.length} elements mismatched)`,
315
- currentValue: `${mismatches} order mismatches`,
316
- suggestedFix: "Reorder layers to match the visual reading flow (top-to-bottom, left-to-right) so screen readers follow the intended sequence.",
317
- autoFixAvailable: false,
318
- });
319
- }
320
- }
321
-
322
- return issues;
323
- }
324
-
325
- /** WCAG 1.4.1 Use of Color – heuristic check for colour-only state differentiation. */
326
- export function checkUseOfColor(
327
- componentSetNodes: FigmaNode[]
328
- ): WCAGIssue[] {
329
- const issues: WCAGIssue[] = [];
330
-
331
- for (const set of componentSetNodes) {
332
- if (!set.children || set.children.length < 2) continue;
333
-
334
- // Compare variants pairwise for colour-only differences
335
- for (let i = 0; i < set.children.length - 1; i++) {
336
- for (let j = i + 1; j < set.children.length; j++) {
337
- const a = set.children[i];
338
- const b = set.children[j];
339
-
340
- const aColor = extractSolidColor(a);
341
- const bColor = extractSolidColor(b);
342
-
343
- // Both have fills and they differ
344
- if (aColor && bColor && !colorsEqual(aColor, bColor)) {
345
- // Check if structural content also differs (children count, types)
346
- const structurallyDifferent = hasStructuralDifference(a, b);
347
-
348
- if (!structurallyDifferent) {
349
- issues.push({
350
- severity: "warning",
351
- criterion: "1.4.1",
352
- nodeId: set.id,
353
- nodeName: set.name,
354
- issue: `Variants "${a.name}" and "${b.name}" differ only by colour — add an icon, text label, or pattern to distinguish states`,
355
- currentValue: "Colour-only differentiation",
356
- suggestedFix: "Add a non-colour indicator (icon, underline, text badge) to differentiate states for users who cannot perceive colour.",
357
- autoFixAvailable: false,
358
- });
359
- break; // One issue per component set is enough
360
- }
361
- }
362
- }
363
- if (issues.some((i) => i.nodeId === set.id)) break;
364
- }
365
- }
366
-
367
- return issues;
368
- }
369
-
370
- /** WCAG 1.4.11 Non-text Contrast – check stroke/border contrast against background. */
371
- export function checkNonTextContrast(
372
- node: FigmaNode,
373
- allNodes: FigmaNode[]
374
- ): WCAGIssue | null {
375
- // Check strokes on interactive/UI elements
376
- if (!node.strokes || node.strokes.length === 0) return null;
377
-
378
- const strokeColor = node.strokes.find(
379
- (s) => s.type === "SOLID" && s.color
380
- )?.color;
381
- if (!strokeColor) return null;
382
-
383
- const bgColor = findParentBgColor(node.id, allNodes);
384
- if (!bgColor) return null;
385
-
386
- const strokeHex = figmaRgbaToHex(strokeColor.r, strokeColor.g, strokeColor.b);
387
- const bgHex = figmaRgbaToHex(bgColor.r, bgColor.g, bgColor.b);
388
-
389
- const ratio = computeContrastRatio(strokeHex, bgHex);
390
- const MIN_NON_TEXT_CONTRAST = 3.0;
391
-
392
- if (ratio < MIN_NON_TEXT_CONTRAST) {
393
- return {
394
- severity: "error",
395
- criterion: "1.4.11",
396
- nodeId: node.id,
397
- nodeName: node.name,
398
- issue: `UI component border contrast ${ratio.toFixed(2)}:1 is below the ${MIN_NON_TEXT_CONTRAST}:1 minimum for non-text elements`,
399
- currentValue: `${ratio.toFixed(2)}:1`,
400
- suggestedFix: `Increase border/stroke contrast to at least ${MIN_NON_TEXT_CONTRAST}:1`,
401
- autoFixAvailable: true,
402
- };
403
- }
404
- return null;
405
- }
406
-
407
- /** WCAG 1.4.12 Text Spacing – check line-height, letter-spacing on text nodes. */
408
- export function checkTextSpacing(textNode: FigmaNode): WCAGIssue | null {
409
- if (textNode.type !== "TEXT") return null;
410
- const style = textNode.style;
411
- if (!style) return null;
412
-
413
- const fontSize = style.fontSize;
414
- const lineHeight = style.lineHeightPx;
415
- const letterSpacing = style.letterSpacing;
416
-
417
- // Line height should be >= 1.5x font size
418
- if (lineHeight > 0 && lineHeight < fontSize * 1.5) {
419
- return {
420
- severity: "warning",
421
- criterion: "1.4.12",
422
- nodeId: textNode.id,
423
- nodeName: textNode.name,
424
- issue: `Line height (${lineHeight.toFixed(1)}px) is less than 1.5x the font size (${fontSize}px = ${(fontSize * 1.5).toFixed(1)}px minimum)`,
425
- currentValue: `lineHeight: ${lineHeight.toFixed(1)}px (${(lineHeight / fontSize).toFixed(2)}x)`,
426
- suggestedFix: `Set line height to at least ${(fontSize * 1.5).toFixed(0)}px (1.5x font size)`,
427
- autoFixAvailable: true,
428
- };
429
- }
430
-
431
- // Letter spacing should not be negative (which would prevent user override)
432
- if (letterSpacing < 0) {
433
- return {
434
- severity: "warning",
435
- criterion: "1.4.12",
436
- nodeId: textNode.id,
437
- nodeName: textNode.name,
438
- issue: `Negative letter spacing (${letterSpacing}px) may prevent text spacing overrides`,
439
- currentValue: `letterSpacing: ${letterSpacing}px`,
440
- suggestedFix: "Use non-negative letter spacing to allow user text spacing adjustments",
441
- autoFixAvailable: true,
442
- };
443
- }
444
-
445
- return null;
446
- }
447
-
448
- /** WCAG 1.4.10 Reflow – heuristic check for responsive layout usage. */
449
- export function checkReflow(frameNodes: FigmaNode[]): WCAGIssue[] {
450
- const issues: WCAGIssue[] = [];
451
-
452
- for (const frame of frameNodes) {
453
- // Only check top-level or large frames (likely page/section containers)
454
- const width = frame.width ?? 0;
455
- if (width < 320) continue; // Skip small components
456
-
457
- const hasAutoLayout = frame.layoutMode && frame.layoutMode !== "NONE";
458
- const isFixedWidth =
459
- frame.counterAxisSizingMode === "FIXED" ||
460
- frame.primaryAxisSizingMode === "FIXED";
461
-
462
- if (!hasAutoLayout && isFixedWidth && frame.children && frame.children.length > 2) {
463
- issues.push({
464
- severity: "warning",
465
- criterion: "1.4.10",
466
- nodeId: frame.id,
467
- nodeName: frame.name,
468
- issue: "Large container uses fixed sizing without auto-layout, may not reflow at narrow viewports",
469
- currentValue: `${width}px wide, no auto-layout`,
470
- suggestedFix: "Use auto-layout with fill/hug sizing so content reflows at 320px viewport width without horizontal scrolling.",
471
- autoFixAvailable: false,
472
- });
473
- }
474
- }
475
-
476
- return issues;
477
- }
478
-
479
- /** WCAG 1.4.5 / 1.4.9 Images of Text – detect rasterised text. */
480
- export function checkImagesOfText(allNodes: FigmaNode[]): WCAGIssue[] {
481
- const issues: WCAGIssue[] = [];
482
- const textHints = ["text", "label", "title", "heading", "caption", "body", "paragraph", "description"];
483
-
484
- for (const node of allNodes) {
485
- const hasImageFill = node.fills?.some((f) => f.type === "IMAGE");
486
- if (!hasImageFill) continue;
487
-
488
- const nameLower = node.name.toLowerCase();
489
- const looksLikeText = textHints.some((hint) => nameLower.includes(hint));
490
-
491
- if (looksLikeText) {
492
- issues.push({
493
- severity: "warning",
494
- criterion: "1.4.5",
495
- nodeId: node.id,
496
- nodeName: node.name,
497
- issue: `Node "${node.name}" has an image fill but its name suggests it may contain text — use real text instead of images of text`,
498
- currentValue: "IMAGE fill with text-like name",
499
- suggestedFix: "Replace image of text with a real TEXT node. If the image is essential (e.g., logo), document that in the description.",
500
- autoFixAvailable: false,
501
- });
502
- }
503
- }
504
-
505
- return issues;
506
- }
507
-
508
- /** WCAG 1.4.13 Content on Hover or Focus – heuristic tooltip/hover pattern check. */
509
- export function checkContentOnHover(
510
- componentSetNodes: FigmaNode[]
511
- ): WCAGIssue[] {
512
- const issues: WCAGIssue[] = [];
513
-
514
- for (const set of componentSetNodes) {
515
- if (!set.children) continue;
516
-
517
- const hoverVariant = set.children.find((c) => {
518
- const name = c.name.toLowerCase();
519
- return name.includes("hover") || name.includes("tooltip");
520
- });
521
-
522
- if (!hoverVariant) continue;
523
-
524
- // Check if the hover variant has significantly more children (added content)
525
- const defaultVariant = set.children.find((c) => {
526
- const name = c.name.toLowerCase();
527
- return name.includes("default") || name.includes("rest") || name.includes("idle");
528
- }) || set.children[0];
529
-
530
- const defaultChildCount = countDescendants(defaultVariant);
531
- const hoverChildCount = countDescendants(hoverVariant);
532
-
533
- if (hoverChildCount > defaultChildCount + 1) {
534
- // Additional content appears on hover — check for dismiss mechanism
535
- const hasDismiss = hoverVariant.children?.some((c) => {
536
- const name = c.name.toLowerCase();
537
- return name.includes("close") || name.includes("dismiss") || name.includes("x");
538
- });
539
-
540
- if (!hasDismiss) {
541
- issues.push({
542
- severity: "warning",
543
- criterion: "1.4.13",
544
- nodeId: set.id,
545
- nodeName: set.name,
546
- issue: "Additional content appears on hover without a visible dismiss mechanism",
547
- currentValue: "Hover-triggered content, no close control",
548
- suggestedFix: "Ensure hover/focus-triggered content is: (1) dismissable via Escape, (2) hoverable without disappearing, (3) persistent until dismissed.",
549
- autoFixAvailable: false,
550
- });
551
- }
552
- }
553
- }
554
-
555
- return issues;
556
- }
557
-
558
- /** WCAG 2.4.3 Focus Order – heuristic check for tab order mismatches. */
559
- export function checkFocusOrder(
560
- interactiveNodes: FigmaNode[]
561
- ): WCAGIssue[] {
562
- const issues: WCAGIssue[] = [];
563
-
564
- const withPos = interactiveNodes
565
- .filter((n) => n.absoluteBoundingBox)
566
- .map((n, idx) => ({
567
- node: n,
568
- treeIndex: idx,
569
- y: n.absoluteBoundingBox!.y,
570
- x: n.absoluteBoundingBox!.x,
571
- }));
572
-
573
- if (withPos.length < 2) return issues;
574
-
575
- // Expected visual order: top-to-bottom, left-to-right
576
- const visualOrder = [...withPos].sort(
577
- (a, b) => a.y - b.y || a.x - b.x
578
- );
579
-
580
- let mismatches = 0;
581
- for (let i = 0; i < visualOrder.length; i++) {
582
- if (visualOrder[i].treeIndex !== withPos[i]?.treeIndex) {
583
- mismatches++;
584
- }
585
- }
586
-
587
- if (mismatches > withPos.length * 0.25 && mismatches >= 2) {
588
- issues.push({
589
- severity: "warning",
590
- criterion: "2.4.3",
591
- nodeId: withPos[0].node.id,
592
- nodeName: "Interactive elements",
593
- issue: `Focus order (layer order) differs from visual reading order for ${mismatches} of ${withPos.length} interactive elements`,
594
- currentValue: `${mismatches} order mismatches`,
595
- suggestedFix: "Reorder interactive element layers to match the visual top-to-bottom, left-to-right flow for logical tab order.",
596
- autoFixAvailable: false,
597
- });
598
- }
599
-
600
- return issues;
601
- }
602
-
603
- /** WCAG 2.4.4 / 2.4.9 Link Purpose – detect vague link text. */
604
- const VAGUE_LINK_TEXTS = [
605
- "click here",
606
- "read more",
607
- "learn more",
608
- "more",
609
- "here",
610
- "link",
611
- "go",
612
- "see more",
613
- "details",
614
- "info",
615
- ];
616
-
617
- export function checkLinkPurpose(
618
- interactiveNodes: FigmaNode[]
619
- ): WCAGIssue[] {
620
- const issues: WCAGIssue[] = [];
621
-
622
- for (const node of interactiveNodes) {
623
- const name = node.name.toLowerCase();
624
- const isLink =
625
- name.includes("link") ||
626
- name.includes("anchor") ||
627
- name.includes("cta") ||
628
- node.type === "INSTANCE";
629
-
630
- if (!isLink) continue;
631
-
632
- // Check visible text content
633
- const textContent = findTextContent(node);
634
- if (!textContent) continue;
635
-
636
- const normalised = textContent.toLowerCase().trim();
637
- if (VAGUE_LINK_TEXTS.includes(normalised)) {
638
- issues.push({
639
- severity: "warning",
640
- criterion: "2.4.4",
641
- nodeId: node.id,
642
- nodeName: node.name,
643
- issue: `Link text "${textContent}" is vague and does not describe its purpose`,
644
- currentValue: `"${textContent}"`,
645
- suggestedFix: `Replace with descriptive text that explains where the link goes (e.g., "View order details" instead of "${textContent}").`,
646
- autoFixAvailable: false,
647
- });
648
- }
649
- }
650
-
651
- return issues;
652
- }
653
-
654
- /** WCAG 2.4.6 Headings and Labels – check sections for heading presence. */
655
- export function checkHeadingsAndLabels(
656
- frameNodes: FigmaNode[]
657
- ): WCAGIssue[] {
658
- const issues: WCAGIssue[] = [];
659
-
660
- for (const frame of frameNodes) {
661
- // Only check substantial frames (likely content sections)
662
- if (!frame.children || frame.children.length < 3) continue;
663
- const width = frame.width ?? 0;
664
- const height = frame.height ?? 0;
665
- if (width < 200 || height < 100) continue;
666
-
667
- // Check if frame has any heading-like text child
668
- const hasHeading = hasHeadingChild(frame);
669
-
670
- if (!hasHeading) {
671
- issues.push({
672
- severity: "suggestion",
673
- criterion: "2.4.6",
674
- nodeId: frame.id,
675
- nodeName: frame.name,
676
- issue: "Content section has no visible heading text",
677
- currentValue: "No heading found",
678
- suggestedFix: "Add a descriptive heading to help users understand the section's topic or purpose.",
679
- autoFixAvailable: false,
680
- });
681
- }
682
- }
683
-
684
- return issues;
685
- }
686
-
687
- /** WCAG 2.4.11 Focus Not Obscured – check focus variants for overlapping elements. */
688
- export function checkFocusNotObscured(
689
- componentSetNodes: FigmaNode[]
690
- ): WCAGIssue[] {
691
- const issues: WCAGIssue[] = [];
692
-
693
- for (const set of componentSetNodes) {
694
- if (!set.children) continue;
695
-
696
- const focusVariant = set.children.find((c) => {
697
- const name = c.name.toLowerCase();
698
- return name.includes("focus");
699
- });
700
-
701
- if (!focusVariant || !focusVariant.children) continue;
702
-
703
- // Check if any child in the focus variant is positioned to overlap the main content
704
- // Heuristic: look for overlay/backdrop children that are full-size
705
- const overlays = focusVariant.children.filter((c) => {
706
- const name = c.name.toLowerCase();
707
- return name.includes("overlay") || name.includes("backdrop") || name.includes("scrim");
708
- });
709
-
710
- for (const overlay of overlays) {
711
- const overlayW = overlay.width ?? 0;
712
- const overlayH = overlay.height ?? 0;
713
- const parentW = focusVariant.width ?? 0;
714
- const parentH = focusVariant.height ?? 0;
715
-
716
- if (overlayW >= parentW * 0.8 && overlayH >= parentH * 0.8) {
717
- issues.push({
718
- severity: "warning",
719
- criterion: "2.4.11",
720
- nodeId: set.id,
721
- nodeName: set.name,
722
- issue: `Focus variant contains an overlay ("${overlay.name}") that may obscure the focused element`,
723
- currentValue: `Overlay ${overlayW}×${overlayH}px over ${parentW}×${parentH}px parent`,
724
- suggestedFix: "Ensure the focused element is not obscured by overlays. The focus indicator should remain fully visible.",
725
- autoFixAvailable: false,
726
- });
727
- }
728
- }
729
- }
730
-
731
- return issues;
732
- }
733
-
734
- /** WCAG 3.3.1 Error Identification – check error state variants for descriptive text. */
735
- export function checkErrorIdentification(
736
- componentSetNodes: FigmaNode[]
737
- ): WCAGIssue[] {
738
- const issues: WCAGIssue[] = [];
739
-
740
- for (const set of componentSetNodes) {
741
- if (!set.children) continue;
742
-
743
- const errorVariant = set.children.find((c) => {
744
- const name = c.name.toLowerCase();
745
- return name.includes("error") || name.includes("invalid") || name.includes("destructive");
746
- });
747
-
748
- if (!errorVariant) continue;
749
-
750
- // Check if the error variant has text describing the error
751
- const errorText = findTextContent(errorVariant);
752
- const hasErrorDescription =
753
- errorText &&
754
- errorText.length > 3 &&
755
- !errorText.toLowerCase().includes("placeholder");
756
-
757
- if (!hasErrorDescription) {
758
- // Check if only colour indicates the error (red fill without text)
759
- issues.push({
760
- severity: "warning",
761
- criterion: "3.3.1",
762
- nodeId: set.id,
763
- nodeName: set.name,
764
- issue: `Error variant "${errorVariant.name}" lacks descriptive error text — errors should be identified in text, not just by colour`,
765
- currentValue: "No error description text found",
766
- suggestedFix: "Add a text element describing the error (e.g., 'Email address is required') to the error state variant.",
767
- autoFixAvailable: false,
768
- });
769
- }
770
- }
771
-
772
- return issues;
773
- }
774
-
775
- /** WCAG 3.3.2 Labels or Instructions – check form inputs for visible labels. */
776
- export function checkLabelsOrInstructions(
777
- interactiveNodes: FigmaNode[],
778
- allNodes: FigmaNode[]
779
- ): WCAGIssue[] {
780
- const issues: WCAGIssue[] = [];
781
- const inputHints = ["input", "text field", "textfield", "textarea", "select", "dropdown", "combobox", "search", "form"];
782
-
783
- for (const node of interactiveNodes) {
784
- const name = node.name.toLowerCase();
785
- const isInput = inputHints.some((hint) => name.includes(hint));
786
- if (!isInput) continue;
787
-
788
- // Check for a visible label — either a child TEXT or a sibling TEXT
789
- const hasInternalLabel = node.children?.some(
790
- (c) =>
791
- c.type === "TEXT" &&
792
- c.characters &&
793
- c.characters.trim().length > 0 &&
794
- !c.name.toLowerCase().includes("placeholder")
795
- );
796
-
797
- if (hasInternalLabel) continue;
798
-
799
- // Check sibling labels
800
- const parent = findParentNode(node.id, allNodes);
801
- const hasSiblingLabel = parent?.children?.some(
802
- (c) =>
803
- c.type === "TEXT" &&
804
- c.id !== node.id &&
805
- c.characters &&
806
- c.characters.trim().length > 0 &&
807
- !c.name.toLowerCase().includes("placeholder")
808
- );
809
-
810
- if (hasSiblingLabel) continue;
811
-
812
- issues.push({
813
- severity: "warning",
814
- criterion: "3.3.2",
815
- nodeId: node.id,
816
- nodeName: node.name,
817
- issue: `Form input "${node.name}" has no visible label text`,
818
- currentValue: "No label found",
819
- suggestedFix: "Add a visible text label above or beside the input field. Do not rely solely on placeholder text as a label.",
820
- autoFixAvailable: false,
821
- });
822
- }
823
-
824
- return issues;
825
- }
826
-
827
- /** WCAG 4.1.2 Name, Role, Value – check interactive components for name/description. */
828
- export function checkNameRoleValue(
829
- interactiveNodes: FigmaNode[]
830
- ): WCAGIssue[] {
831
- const issues: WCAGIssue[] = [];
832
-
833
- for (const node of interactiveNodes) {
834
- // Icon-only interactive elements need accessible names
835
- const hasVisibleText = findTextContent(node);
836
- const hasDescription = node.description && node.description.trim().length > 0;
837
-
838
- if (!hasVisibleText && !hasDescription) {
839
- const name = node.name.toLowerCase();
840
- // Only flag icon-like elements (small, no text)
841
- const w = node.width ?? 0;
842
- const h = node.height ?? 0;
843
- if (w <= 48 && h <= 48) {
844
- issues.push({
845
- severity: "warning",
846
- criterion: "4.1.2",
847
- nodeId: node.id,
848
- nodeName: node.name,
849
- issue: `Interactive element "${node.name}" has no visible text or description — screen readers need an accessible name`,
850
- currentValue: "No accessible name",
851
- suggestedFix: "Add an aria-label (via description property in Figma) or include visible text for icon-only interactive elements.",
852
- autoFixAvailable: false,
853
- });
854
- }
855
- }
856
- }
857
-
858
- return issues;
859
- }
860
-
861
- /** WCAG 1.3.4 Orientation – check for portrait/landscape variant presence. */
862
- export function checkOrientation(
863
- componentSetNodes: FigmaNode[]
864
- ): WCAGIssue[] {
865
- // This is a page-level concern; at the component level, we just flag awareness
866
- // Only meaningful for screen/page-level component sets
867
- return [];
868
- }
869
-
870
- /** WCAG 1.3.5 Identify Input Purpose – check input names for autocomplete hints. */
871
- export function checkIdentifyInputPurpose(
872
- interactiveNodes: FigmaNode[]
873
- ): WCAGIssue[] {
874
- const issues: WCAGIssue[] = [];
875
- const purposeHints = [
876
- "name", "email", "tel", "phone", "address", "city", "state", "zip",
877
- "postal", "country", "password", "username", "birthday", "cc-number",
878
- "cc-name", "cc-exp", "credit",
879
- ];
880
-
881
- for (const node of interactiveNodes) {
882
- const name = node.name.toLowerCase();
883
- const isInput =
884
- name.includes("input") ||
885
- name.includes("text field") ||
886
- name.includes("textfield");
887
- if (!isInput) continue;
888
-
889
- // Check if the input name or description hints at a known purpose
890
- const matchesPurpose = purposeHints.some(
891
- (hint) => name.includes(hint) || (node.description ?? "").toLowerCase().includes(hint)
892
- );
893
-
894
- if (matchesPurpose && !node.description?.toLowerCase().includes("autocomplete")) {
895
- issues.push({
896
- severity: "suggestion",
897
- criterion: "1.3.5",
898
- nodeId: node.id,
899
- nodeName: node.name,
900
- issue: `Input "${node.name}" appears to collect personal data — annotate with autocomplete purpose (e.g., autocomplete="email")`,
901
- currentValue: "No autocomplete annotation",
902
- suggestedFix: "Add autocomplete purpose annotation in the description property to support browser autofill.",
903
- autoFixAvailable: false,
904
- });
905
- }
906
- }
907
-
908
- return issues;
909
- }
910
-
911
- // ─── Internal helpers for new checks ────────────────────────────────────────
912
-
913
- function findParentNode(
914
- nodeId: string,
915
- allNodes: FigmaNode[]
916
- ): FigmaNode | null {
917
- for (const n of allNodes) {
918
- if (n.children?.some((c) => c.id === nodeId)) return n;
919
- if (n.children) {
920
- const found = findParentNode(nodeId, n.children);
921
- if (found) return found;
922
- }
923
- }
924
- return null;
925
- }
926
-
927
- function colorsEqual(a: RGBA, b: RGBA): boolean {
928
- return (
929
- Math.abs(a.r - b.r) < 0.01 &&
930
- Math.abs(a.g - b.g) < 0.01 &&
931
- Math.abs(a.b - b.b) < 0.01
932
- );
933
- }
934
-
935
- function hasStructuralDifference(a: FigmaNode, b: FigmaNode): boolean {
936
- const aChildren = a.children || [];
937
- const bChildren = b.children || [];
938
-
939
- // Different child count
940
- if (aChildren.length !== bChildren.length) return true;
941
-
942
- // Different child types
943
- for (let i = 0; i < aChildren.length; i++) {
944
- if (aChildren[i].type !== bChildren[i]?.type) return true;
945
- }
946
-
947
- // Check for text content differences
948
- const aTexts = aChildren
949
- .filter((c) => c.type === "TEXT")
950
- .map((c) => c.characters ?? "");
951
- const bTexts = bChildren
952
- .filter((c) => c.type === "TEXT")
953
- .map((c) => c.characters ?? "");
954
- if (aTexts.join("|") !== bTexts.join("|")) return true;
955
-
956
- return false;
957
- }
958
-
959
- function countDescendants(node: FigmaNode): number {
960
- if (!node.children) return 0;
961
- let count = node.children.length;
962
- for (const child of node.children) {
963
- count += countDescendants(child);
964
- }
965
- return count;
966
- }
967
-
968
- function findTextContent(node: FigmaNode): string | null {
969
- if (node.type === "TEXT" && node.characters) return node.characters;
970
- if (node.children) {
971
- for (const child of node.children) {
972
- const text = findTextContent(child);
973
- if (text) return text;
974
- }
975
- }
976
- return null;
977
- }
978
-
979
- function hasHeadingChild(node: FigmaNode): boolean {
980
- if (node.type === "TEXT") {
981
- const fontSize = node.style?.fontSize ?? 16;
982
- const fontWeight = node.style?.fontWeight ?? 400;
983
- return fontSize >= 20 || fontWeight >= 700;
984
- }
985
- if (node.children) {
986
- return node.children.some((c) => hasHeadingChild(c));
987
- }
988
- return false;
989
- }