@sarjallab09/figma-intelligence 1.0.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 (286) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +327 -0
  3. package/bin/cli.js +859 -0
  4. package/design-bridge/.env.example +5 -0
  5. package/design-bridge/bridge.js +196 -0
  6. package/design-bridge/lib/assets.js +367 -0
  7. package/design-bridge/lib/prompt.js +85 -0
  8. package/design-bridge/lib/server.js +66 -0
  9. package/design-bridge/lib/stitch.js +37 -0
  10. package/design-bridge/lib/tokens.js +82 -0
  11. package/design-bridge/package-lock.json +579 -0
  12. package/design-bridge/package.json +19 -0
  13. package/figma-bridge-plugin/README.md +97 -0
  14. package/figma-bridge-plugin/anthropic-chat-runner.js +192 -0
  15. package/figma-bridge-plugin/bridge-relay.js +2363 -0
  16. package/figma-bridge-plugin/chat-runner.js +459 -0
  17. package/figma-bridge-plugin/code.js +1528 -0
  18. package/figma-bridge-plugin/codex-runner.js +505 -0
  19. package/figma-bridge-plugin/component-schemas.js +110 -0
  20. package/figma-bridge-plugin/content-context.js +869 -0
  21. package/figma-bridge-plugin/create-button.js +216 -0
  22. package/figma-bridge-plugin/gemini-cli-runner.js +291 -0
  23. package/figma-bridge-plugin/gemini-runner.js +187 -0
  24. package/figma-bridge-plugin/html-to-figma.js +927 -0
  25. package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
  26. package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +159 -0
  27. package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +162 -0
  28. package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +148 -0
  29. package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +314 -0
  30. package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +175 -0
  31. package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +180 -0
  32. package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +165 -0
  33. package/figma-bridge-plugin/manifest.json +21 -0
  34. package/figma-bridge-plugin/package-lock.json +1936 -0
  35. package/figma-bridge-plugin/package.json +20 -0
  36. package/figma-bridge-plugin/perplexity-runner.js +188 -0
  37. package/figma-bridge-plugin/references/SKILL.md +178 -0
  38. package/figma-bridge-plugin/references/anatomy-spec.md +159 -0
  39. package/figma-bridge-plugin/references/api-spec.md +162 -0
  40. package/figma-bridge-plugin/references/color-spec.md +148 -0
  41. package/figma-bridge-plugin/references/full-spec-template.md +314 -0
  42. package/figma-bridge-plugin/references/property-spec.md +175 -0
  43. package/figma-bridge-plugin/references/screen-reader-spec.md +180 -0
  44. package/figma-bridge-plugin/references/structure-spec.md +165 -0
  45. package/figma-bridge-plugin/shared-prompt-config.js +604 -0
  46. package/figma-bridge-plugin/spec-helpers/build-table.js +269 -0
  47. package/figma-bridge-plugin/spec-helpers/classify-elements.js +189 -0
  48. package/figma-bridge-plugin/spec-helpers/index.js +35 -0
  49. package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +49 -0
  50. package/figma-bridge-plugin/spec-helpers/position-markers.js +158 -0
  51. package/figma-bridge-plugin/stitch-auth.js +322 -0
  52. package/figma-bridge-plugin/stitch-runner.js +1427 -0
  53. package/figma-bridge-plugin/token-resolver.js +107 -0
  54. package/figma-bridge-plugin/ui.html +4467 -0
  55. package/figma-intelligence-layer/.env.example +39 -0
  56. package/figma-intelligence-layer/docs/local-image-generation.md +60 -0
  57. package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +101 -0
  58. package/figma-intelligence-layer/jest.config.js +14 -0
  59. package/figma-intelligence-layer/mcp-config.json +19 -0
  60. package/figma-intelligence-layer/package-lock.json +5892 -0
  61. package/figma-intelligence-layer/package.json +48 -0
  62. package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +67 -0
  63. package/figma-intelligence-layer/scripts/start-comfyui.sh +33 -0
  64. package/figma-intelligence-layer/src/index.ts +2233 -0
  65. package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +404 -0
  66. package/figma-intelligence-layer/src/shared/cache.ts +187 -0
  67. package/figma-intelligence-layer/src/shared/color-operations.ts +533 -0
  68. package/figma-intelligence-layer/src/shared/color-utils.ts +138 -0
  69. package/figma-intelligence-layer/src/shared/component-script-builder.ts +413 -0
  70. package/figma-intelligence-layer/src/shared/component-templates.ts +2767 -0
  71. package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +694 -0
  72. package/figma-intelligence-layer/src/shared/decision-log.ts +128 -0
  73. package/figma-intelligence-layer/src/shared/design-system-context.ts +568 -0
  74. package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +131 -0
  75. package/figma-intelligence-layer/src/shared/design-system-matcher.ts +184 -0
  76. package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +196 -0
  77. package/figma-intelligence-layer/src/shared/design-system-tokens.ts +295 -0
  78. package/figma-intelligence-layer/src/shared/dtcg-validator.ts +530 -0
  79. package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +671 -0
  80. package/figma-intelligence-layer/src/shared/figma-bridge.ts +1408 -0
  81. package/figma-intelligence-layer/src/shared/font-config.ts +126 -0
  82. package/figma-intelligence-layer/src/shared/icon-catalog.ts +360 -0
  83. package/figma-intelligence-layer/src/shared/icon-fetch.ts +80 -0
  84. package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +162 -0
  85. package/figma-intelligence-layer/src/shared/response-compression.ts +440 -0
  86. package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +324 -0
  87. package/figma-intelligence-layer/src/shared/token-binder.ts +505 -0
  88. package/figma-intelligence-layer/src/shared/token-math.ts +427 -0
  89. package/figma-intelligence-layer/src/shared/token-naming.ts +468 -0
  90. package/figma-intelligence-layer/src/shared/token-utils.ts +420 -0
  91. package/figma-intelligence-layer/src/shared/types.ts +346 -0
  92. package/figma-intelligence-layer/src/shared/typography-presets.ts +94 -0
  93. package/figma-intelligence-layer/src/shared/unsplash.ts +165 -0
  94. package/figma-intelligence-layer/src/shared/vision-client.ts +607 -0
  95. package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +334 -0
  96. package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +446 -0
  97. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +782 -0
  98. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +496 -0
  99. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +230 -0
  100. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +66 -0
  101. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +810 -0
  102. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +1191 -0
  103. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +1346 -0
  104. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +148 -0
  105. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +499 -0
  106. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +910 -0
  107. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +989 -0
  108. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +1160 -0
  109. package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +424 -0
  110. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +38 -0
  111. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +111 -0
  112. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +114 -0
  113. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +103 -0
  114. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +1060 -0
  115. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +18 -0
  116. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +39 -0
  117. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +58 -0
  118. package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +298 -0
  119. package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +197 -0
  120. package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +494 -0
  121. package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +356 -0
  122. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +123 -0
  123. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +663 -0
  124. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +56 -0
  125. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +614 -0
  126. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +113 -0
  127. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +178 -0
  128. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +470 -0
  129. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +429 -0
  130. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +226 -0
  131. package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +535 -0
  132. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +660 -0
  133. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +209 -0
  134. package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +540 -0
  135. package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +391 -0
  136. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +2019 -0
  137. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +131 -0
  138. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +381 -0
  139. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +565 -0
  140. package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +764 -0
  141. package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +535 -0
  142. package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +84 -0
  143. package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +401 -0
  144. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +68 -0
  145. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +78 -0
  146. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +93 -0
  147. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +596 -0
  148. package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +462 -0
  149. package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +1470 -0
  150. package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +829 -0
  151. package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +702 -0
  152. package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +483 -0
  153. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +501 -0
  154. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +106 -0
  155. package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +676 -0
  156. package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +560 -0
  157. package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +1043 -0
  158. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +620 -0
  159. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +331 -0
  160. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +77 -0
  161. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +54 -0
  162. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +287 -0
  163. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +71 -0
  164. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +43 -0
  165. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +71 -0
  166. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +221 -0
  167. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +166 -0
  168. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +232 -0
  169. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +234 -0
  170. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +270 -0
  171. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +249 -0
  172. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +231 -0
  173. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +293 -0
  174. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +240 -0
  175. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +243 -0
  176. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +307 -0
  177. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +143 -0
  178. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +227 -0
  179. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +233 -0
  180. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +282 -0
  181. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +276 -0
  182. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +223 -0
  183. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +255 -0
  184. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +289 -0
  185. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +261 -0
  186. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +290 -0
  187. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +265 -0
  188. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +238 -0
  189. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +255 -0
  190. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +128 -0
  191. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +286 -0
  192. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +255 -0
  193. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +330 -0
  194. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +247 -0
  195. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +250 -0
  196. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +247 -0
  197. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +144 -0
  198. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +264 -0
  199. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +251 -0
  200. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +261 -0
  201. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +248 -0
  202. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +270 -0
  203. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +251 -0
  204. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +142 -0
  205. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +282 -0
  206. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +250 -0
  207. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +258 -0
  208. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +265 -0
  209. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +319 -0
  210. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +256 -0
  211. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +232 -0
  212. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +239 -0
  213. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +252 -0
  214. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +270 -0
  215. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +244 -0
  216. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +143 -0
  217. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +243 -0
  218. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +259 -0
  219. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +293 -0
  220. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +144 -0
  221. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +289 -0
  222. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +267 -0
  223. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +232 -0
  224. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +257 -0
  225. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +319 -0
  226. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +121 -0
  227. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +430 -0
  228. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +312 -0
  229. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +129 -0
  230. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +78 -0
  231. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +2333 -0
  232. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +100 -0
  233. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +32 -0
  234. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +59 -0
  235. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +18 -0
  236. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +53 -0
  237. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +19 -0
  238. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +91 -0
  239. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +71 -0
  240. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +19 -0
  241. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +110 -0
  242. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +19 -0
  243. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +67 -0
  244. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +58 -0
  245. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +79 -0
  246. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +50 -0
  247. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +33 -0
  248. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +55 -0
  249. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +73 -0
  250. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +81 -0
  251. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +409 -0
  252. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +198 -0
  253. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +701 -0
  254. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +88 -0
  255. package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +135 -0
  256. package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +491 -0
  257. package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +416 -0
  258. package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +722 -0
  259. package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +449 -0
  260. package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +393 -0
  261. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +406 -0
  262. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +292 -0
  263. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +24 -0
  264. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +172 -0
  265. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +409 -0
  266. package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +594 -0
  267. package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +710 -0
  268. package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +458 -0
  269. package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +134 -0
  270. package/figma-intelligence-layer/tests/apg-doc.test.ts +101 -0
  271. package/figma-intelligence-layer/tests/design-system-context.test.ts +152 -0
  272. package/figma-intelligence-layer/tests/design-system-matcher.test.ts +144 -0
  273. package/figma-intelligence-layer/tests/figma-bridge.test.ts +83 -0
  274. package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +56 -0
  275. package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +69 -0
  276. package/figma-intelligence-layer/tests/smoke.test.ts +174 -0
  277. package/figma-intelligence-layer/tests/spec-generator.test.ts +127 -0
  278. package/figma-intelligence-layer/tests/token-migrate.test.ts +21 -0
  279. package/figma-intelligence-layer/tests/token-naming.test.ts +30 -0
  280. package/figma-intelligence-layer/tsconfig.json +19 -0
  281. package/package.json +35 -0
  282. package/scripts/clean-existing-chunks.js +179 -0
  283. package/scripts/connect-ai-tool.js +490 -0
  284. package/scripts/convert-hub-pdfs.js +425 -0
  285. package/scripts/figma-mcp-status.js +349 -0
  286. package/scripts/register-codex-mcp.js +96 -0
@@ -0,0 +1,314 @@
1
+ # Component Specification Template
2
+
3
+ > This is the gold-standard reference for what a complete component spec should look like.
4
+ > When generating a spec with `figma_component_spec`, the output should match this quality,
5
+ > tone, and depth. Use this as a writing guide — adapt the content to the actual component
6
+ > but maintain the same level of detail and structure.
7
+
8
+ ---
9
+
10
+ ## Example: Button Component Specification
11
+
12
+ ---
13
+
14
+ ### 1. Overview
15
+
16
+ Component: Button
17
+ Type: COMPONENT_SET (24 variants)
18
+ Node ID: 1:234
19
+ Dimensions: 160 × 44 px (default variant)
20
+ Layout: HORIZONTAL auto layout, 8px gap, padding 12/16/12/16
21
+ Description: Button is a primary interactive component used to trigger actions
22
+ and submit forms. It supports 3 hierarchy levels (Primary, Secondary,
23
+ Tertiary), 4 sizes (XSmall, Small, Medium, Large), and full state
24
+ coverage (Default, Hover, Pressed, Focused, Disabled). Composed of
25
+ 5 elements including 2 optional icon slots controlled by boolean toggles.
26
+ All 8 color fills are bound to design tokens for full theme support.
27
+ States: Default, Hover, Pressed, Focused, Disabled
28
+ Detected pattern: button
29
+ Direct children: Leading Icon, Label, Trailing Icon, Loader, Focus Ring
30
+
31
+ ---
32
+
33
+ ### 2. Anatomy
34
+
35
+ # Element Type Role Visible Controlled By
36
+ ──────────────────────────────────────────────────────────────────────────────────
37
+ 1 Leading Icon INSTANCE optional-slot true Show Leading Icon
38
+ 2 Label TEXT content-element true —
39
+ 3 Trailing Icon INSTANCE optional-slot false Show Trailing Icon
40
+ 4 Loader INSTANCE optional-slot false Is Loading
41
+ 5 Focus Ring FRAME decorative false —
42
+
43
+ Anatomy notes:
44
+ - Leading Icon and Trailing Icon are optional slots controlled by boolean toggles.
45
+ When hidden, the button auto-resizes due to auto layout.
46
+ - Label is the primary content element and must always remain visible.
47
+ - Loader replaces the label content during async operations when Is Loading = true.
48
+ - Focus Ring is a decorative element rendered on keyboard focus via the Focused state variant.
49
+
50
+ ---
51
+
52
+ ### 3. Variants
53
+
54
+ Axis Values Default Count
55
+ ──────────────────────────────────────────────────────────────────
56
+ Hierarchy Primary, Secondary, Tertiary Primary 3
57
+ Size XSmall, Small, Medium, Large Medium 4
58
+ State Default, Hover, Pressed, Focused, Default 5
59
+ Disabled
60
+
61
+ Toggle Default Controls
62
+ ──────────────────────────────────────────────
63
+ Show Leading Icon false Leading Icon
64
+ Show Trailing Icon false Trailing Icon
65
+ Is Loading false Loader
66
+
67
+ Swap Slot Current Component
68
+ ──────────────────────────────────────────
69
+ Leading Icon Swap Icon / Arrow Left
70
+ Trailing Icon Swap Icon / Chevron Right
71
+
72
+ Total possible configurations: 60 (3 hierarchy × 4 size × 5 state).
73
+ Boolean multiplier: ×8 (3 toggles). Defined variants in file: 24.
74
+
75
+ Defined variant names:
76
+ - Hierarchy=Primary, Size=Large, State=Default
77
+ - Hierarchy=Primary, Size=Large, State=Hover
78
+ - Hierarchy=Primary, Size=Large, State=Pressed
79
+ - Hierarchy=Primary, Size=Large, State=Focused
80
+ - Hierarchy=Primary, Size=Medium, State=Default
81
+ - ... and 19 more
82
+
83
+ ---
84
+
85
+ ### 4. States
86
+
87
+ State Source Axis / Property
88
+ ───────────────────────────────────────────
89
+ Default variant-axis State
90
+ Hover variant-axis State
91
+ Pressed variant-axis State
92
+ Focused variant-axis State
93
+ Disabled variant-axis State
94
+
95
+ State behavior notes:
96
+ - Default: Normal idle state with standard fill colors and cursor: pointer.
97
+ - Hover: Background shifts to a lighter/darker tint (token: button/primary/hover).
98
+ Triggered on mouse enter. Transition: 150ms ease-out.
99
+ - Pressed: Background shifts further. Active fill token: button/primary/pressed.
100
+ Applied on mousedown, released on mouseup.
101
+ - Focused: Visible focus ring (2px offset, brand color) for keyboard navigation.
102
+ Must meet WCAG 2.4.7 — 3:1 contrast against adjacent colors.
103
+ - Disabled: Reduced opacity (0.4) or muted fill. Remove from tab order.
104
+ Use aria-disabled="true" rather than the disabled attribute when possible
105
+ to maintain focus for screen reader discoverability.
106
+
107
+ ---
108
+
109
+ ### 5. Properties / API
110
+
111
+ Property Type Values / Default Required
112
+ ────────────────────────────────────────────────────────────────────────────────────
113
+ Hierarchy Variant Primary, Secondary, Tertiary Yes
114
+ (default: Primary)
115
+ Size Variant XSmall, Small, Medium, Large Yes
116
+ (default: Medium)
117
+ State Variant Default, Hover, Pressed, Focused, Yes
118
+ Disabled (default: Default)
119
+ Show Leading Icon Boolean true / false (default: false) No
120
+ Show Trailing Icon Boolean true / false (default: false) No
121
+ Is Loading Boolean true / false (default: false) No
122
+ Leading Icon Swap Instance Swap Any icon component No
123
+ Trailing Icon Swap Instance Swap Any icon component No
124
+ Label Text Text Override "Button" (editable) No
125
+
126
+ Total properties: 9 (3 variants, 3 booleans, 2 instance swaps, 1 text override).
127
+
128
+ Implementation notes:
129
+ - Variant properties (Hierarchy, Size, State) are required and must always be set.
130
+ - Boolean toggles control child visibility — they do not add/remove DOM elements,
131
+ only toggle display.
132
+ - Instance swap slots accept any component from the Icon library. Ensure swapped
133
+ icons maintain the same bounding box (20×20 for Medium size) to avoid layout shift.
134
+ - Label Text supports single-line text only. Truncation with ellipsis should be
135
+ handled if text overflows the maximum width.
136
+
137
+ ---
138
+
139
+ ### 6. Spacing & Structure
140
+
141
+ Root layout: HORIZONTAL auto layout
142
+ Dimensions: 160 × 44 px (Medium)
143
+ Padding: 12 / 16 / 12 / 16 (T/R/B/L)
144
+ Item spacing: 8px
145
+
146
+ Element Layout W × H Padding (T/R/B/L) Gap Sizing (H/V)
147
+ ──────────────────────────────────────────────────────────────────────────────────────
148
+ Button (root) HORIZONTAL 160 × 44 12/16/12/16 8px HUG / FIXED
149
+ Leading Icon — 20 × 20 — — FIXED / FIXED
150
+ Label — auto × 20 — — HUG / HUG
151
+ Trailing Icon — 20 × 20 — — FIXED / FIXED
152
+
153
+ Size scale:
154
+ - XSmall: 28px height, 8/12 padding, 6px gap, 14px font
155
+ - Small: 32px height, 8/12 padding, 6px gap, 14px font
156
+ - Medium: 44px height, 12/16 padding, 8px gap, 16px font
157
+ - Large: 52px height, 16/20 padding, 8px gap, 18px font
158
+
159
+ Touch target compliance:
160
+ - XSmall (28px): Below 44×44 WCAG minimum — ensure adequate spacing or hit area padding.
161
+ - Small (32px): Below 44×44 — same concern.
162
+ - Medium (44px): Meets 44×44 minimum touch target.
163
+ - Large (52px): Exceeds minimum. Recommended for primary CTAs on mobile.
164
+
165
+ ---
166
+
167
+ ### 7. Color Tokens
168
+
169
+ Element Property Hex Value Token Name
170
+ ────────────────────────────────────────────────────────────────
171
+ Button (root) fill #0F62FE color/interactive/primary
172
+ Button (root) fill #0043CE color/interactive/primary/hover
173
+ Button (root) fill #002D9C color/interactive/primary/pressed
174
+ Label fill #FFFFFF color/text/on-color
175
+ Leading Icon fill #FFFFFF color/icon/on-color
176
+ Focus Ring stroke #0F62FE color/focus/outline
177
+ Disabled fill fill #C6C6C6 color/interactive/disabled
178
+ Disabled text fill #8D8D8D color/text/disabled
179
+
180
+ Token coverage: 8/8 colors are bound to design tokens. Fully theme-ready.
181
+
182
+ Token architecture notes:
183
+ - All interactive colors use the `color/interactive/*` namespace.
184
+ - Text and icon colors on filled backgrounds use `color/*/on-color` tokens
185
+ which automatically invert in dark mode.
186
+ - The Disabled state uses dedicated disabled tokens — do not use opacity
187
+ reduction as it creates inconsistent results across themes.
188
+ - Focus ring uses `color/focus/outline` which must maintain 3:1 contrast
189
+ against any background.
190
+
191
+ ---
192
+
193
+ ### 8. Typography
194
+
195
+ Element Content Font Size Line Height Token
196
+ ────────────────────────────────────────────────────────────────────────
197
+ Label "Button" Inter SemiBold 16px 20px type/body/semibold/md
198
+
199
+ Font families used: Inter SemiBold. Size range: 14px–18px across 4 size variants.
200
+
201
+ Typography scale by size variant:
202
+ - XSmall / Small: Inter SemiBold 14px / 18px line height
203
+ - Medium: Inter SemiBold 16px / 20px line height
204
+ - Large: Inter SemiBold 18px / 24px line height
205
+
206
+ Accessibility notes:
207
+ - Minimum font size (14px) meets readability guidelines.
208
+ - All text uses SemiBold weight for adequate legibility on colored backgrounds.
209
+ - Line height ratio (1.25–1.33) is within WCAG recommended range.
210
+
211
+ ---
212
+
213
+ ### 9. Accessibility
214
+
215
+ Touch target:
216
+ - Medium (44×44px) and Large (52×52px) variants meet WCAG 2.5.8 minimum.
217
+ - XSmall (28px) and Small (32px) are below minimum — add padding or spacing.
218
+
219
+ Typography:
220
+ - Label: Inter SemiBold 16px / 20px line height
221
+ - All text sizes ≥ 14px — meets readability guidelines.
222
+
223
+ Keyboard interaction:
224
+ - Component must be focusable and operable via keyboard.
225
+ - Focus state detected — visible focus indicator (2px ring) meets 3:1 contrast.
226
+ - Disabled state: use aria-disabled="true" rather than removing from tab order.
227
+ - Expected keyboard behavior: Enter/Space activates the button.
228
+
229
+ Screen reader:
230
+ - Role: button (native HTML or role="button" for custom elements)
231
+ - Label: Computed from visible text content. If icon-only, provide aria-label.
232
+ - State: Announce disabled state. Announce loading state with aria-busy="true"
233
+ and aria-live="polite" on the status region.
234
+
235
+ Color contrast:
236
+ - Primary: White text (#FFF) on blue (#0F62FE) = 4.66:1 ratio (passes AA)
237
+ - Disabled: Gray text (#8D8D8D) on light gray (#C6C6C6) — verify ≥ 3:1 for
238
+ decorative non-text contrast.
239
+
240
+ Structure:
241
+ - 8 token aliases bound — supports theming.
242
+ - Drop shadow: none on default. If added for elevation, verify contrast in all themes.
243
+ - Expected ARIA pattern: WAI-ARIA Button pattern
244
+ - Minimum contrast requirement: 4.5:1 for normal text, 3:1 for large text
245
+
246
+ ---
247
+
248
+ ### 10. Usage Guidelines
249
+
250
+ ✓ DO:
251
+ ✓ Use the variant properties (Hierarchy, Size, State) to configure the button.
252
+ Don't detach instances to create custom variations.
253
+ ✓ Use boolean toggles (Show Leading Icon, Show Trailing Icon, Is Loading) to
254
+ show/hide optional elements instead of deleting layers.
255
+ ✓ Keep required elements intact: Label.
256
+ ✓ Support all defined states (Default, Hover, Pressed, Focused, Disabled).
257
+ ✓ Use Primary hierarchy for the most important action on the page.
258
+ Only one Primary button per view/section.
259
+ ✓ Use Secondary for supporting actions, Tertiary for low-emphasis actions.
260
+ ✓ Preserve auto layout settings — don't switch to absolute positioning.
261
+ ✓ Maintain the 8px gap between icon and label.
262
+ ✓ Use instance swap properties for icons — only swap in compatible 20×20 icons.
263
+ ✓ Test the component in both light and dark themes before publishing.
264
+
265
+ ✗ DON'T:
266
+ ✗ Don't remove or hide the Label element — this breaks semantic structure.
267
+ ✗ Don't create undocumented state variations — extend the variant set formally.
268
+ ✗ Don't use buttons for navigation — use Link component instead.
269
+ ✗ Don't replace icon swap slots with non-icon components.
270
+ ✗ Don't override internal padding or spacing values.
271
+ ✗ Don't use opacity to create disabled appearance — use the Disabled state variant.
272
+ ✗ Don't place more than one Primary button in the same section.
273
+
274
+ ---
275
+
276
+ ### 11. Related Components
277
+
278
+ Related Component When to Use Instead
279
+ ──────────────────────────────────────────────────────────────────
280
+ Link / Anchor Use for navigation instead of triggering actions
281
+ Icon Button Use for icon-only actions with a tooltip
282
+ FAB (Floating Action) Use for the primary page-level action on mobile
283
+ Split Button Use when the button needs a dropdown for secondary actions
284
+ Toggle Button Use when the button represents an on/off state
285
+
286
+ ---
287
+
288
+ ## Template Usage Notes
289
+
290
+ This template demonstrates the expected quality bar:
291
+
292
+ 1. **Every section has content** — even when data is sparse, provide guidance,
293
+ recommendations, or explain what's missing and why it matters.
294
+
295
+ 2. **Tables are clean and aligned** — use consistent column widths, separator
296
+ lines, and clear headers.
297
+
298
+ 3. **Descriptive prose accompanies data** — don't just dump a table. Explain
299
+ what the data means, why it matters, and what to do about it.
300
+
301
+ 4. **Accessibility is specific** — mention exact WCAG criteria, contrast ratios,
302
+ keyboard patterns, and screen reader behavior.
303
+
304
+ 5. **Usage guidelines are actionable** — each do/don't references a specific
305
+ component feature or behavior, not generic advice.
306
+
307
+ 6. **Token architecture is explained** — don't just list token names. Explain
308
+ the naming pattern, theme behavior, and contrast requirements.
309
+
310
+ 7. **States include behavior notes** — describe transitions, timing, cursor
311
+ changes, and ARIA state management.
312
+
313
+ 8. **Spacing includes size scale** — if the component has size variants, show
314
+ how spacing/typography scales across all sizes.
@@ -0,0 +1,175 @@
1
+ # Property Spec Reference
2
+
3
+ Generate visual property annotations with live instance previews for every configurable property — variant axes, boolean toggles, variable modes, and child component properties.
4
+
5
+ ## What This Spec Produces
6
+
7
+ 1. **Variant axis exhibits** — One section per axis with instance previews for every value
8
+ 2. **Boolean toggle exhibits** — On/off states shown side by side, defaults labeled
9
+ 3. **Variable mode exhibits** — Shape, density, and other mode-driven properties as visual chapters
10
+ 4. **Child component chapters** — Nested component properties shown in-context on parent instances
11
+
12
+ ---
13
+
14
+ ## Step-by-Step Pipeline
15
+
16
+ ### Phase 1: Extract All Properties
17
+
18
+ Read `componentPropertyDefinitions` from the component set:
19
+ ```
20
+ get_component_property_definitions(node_id)
21
+ ```
22
+
23
+ Collect four categories:
24
+
25
+ **1. Variant Axes** — From variant names (e.g., Size=Large, Hierarchy=Primary)
26
+ - Property name
27
+ - All values
28
+ - Default value
29
+
30
+ **2. Boolean Toggles** — From component property definitions
31
+ - Property name (e.g., "Show Leading Icon")
32
+ - Default state (true/false)
33
+ - Which child layer it controls
34
+
35
+ **3. Variable Mode Collections** — Check for component-scoped variable collections
36
+ ```
37
+ get_local_variable_collections()
38
+ ```
39
+ - Collection name (e.g., "Button Shape", "Density")
40
+ - Mode names (e.g., ["Rounded", "Square", "Pill"])
41
+
42
+ **4. Child Component Properties** — For each INSTANCE child layer:
43
+ - Resolve to source component
44
+ - Read its `componentPropertyDefinitions`
45
+ - Group by child component name
46
+
47
+ ### Phase 2: Normalize Properties (AI Reasoning)
48
+
49
+ Consolidation rules to avoid redundant exhibits:
50
+
51
+ - **Coupled axes**: If two variant axes always change together (e.g., "Icon Size" always matches "Button Size"), merge them into a single exhibit showing the coupling
52
+ - **Container-gated booleans**: If a boolean only matters when a specific variant value is active, show it within that variant's context rather than as a standalone exhibit
53
+ - **Unified slots**: If multiple instance swap properties represent the same conceptual slot (e.g., "Leading Content" accepts both Icon and Avatar), combine into one exhibit
54
+ - **Sibling booleans**: If two booleans are mutually exclusive (toggling one forces the other off), show them as a single either/or exhibit
55
+
56
+ ### Phase 3: Plan Exhibits
57
+
58
+ For each property, determine the exhibit type:
59
+
60
+ | Property Type | Exhibit Layout |
61
+ |--------------|----------------|
62
+ | Variant axis (≤6 values) | Horizontal row of instances, one per value |
63
+ | Variant axis (>6 values) | 2-column or 3-column grid |
64
+ | Boolean toggle | Side-by-side: OFF (default labeled) and ON |
65
+ | Variable mode | Row of instances, one per mode value |
66
+ | Child component | Show on parent instance with callout arrows |
67
+
68
+ **Instance creation for exhibits:**
69
+ - Start from the **default variant** of the component
70
+ - Change ONLY the property being exhibited (keep everything else at defaults)
71
+ - For variant axes: create one instance per value, changing only that axis
72
+ - For booleans: create two instances — one with false, one with true
73
+ - For modes: create one instance per mode, applying the mode via variable binding
74
+
75
+ ### Phase 4: Render the Documentation Frame
76
+
77
+ ```
78
+ Main Frame (1440px wide, auto-layout vertical, padding 60px, gap 40px)
79
+ ├── Header Section
80
+ │ ├── Title: "[Component Name] — Properties" (24px bold)
81
+ │ └── Subtitle: "Configurable properties and visual reference" (14px, #6B7280)
82
+
83
+ ├── Variant Axis Chapter(s)
84
+ │ ├── Chapter Header: "[Axis Name]" (20px bold)
85
+ │ ├── Values label: "Values: Large | Medium | Small | XSmall" (13px, #6B7280)
86
+ │ ├── Default label: "Default: Medium" (13px, bold tag on value)
87
+ │ └── Exhibit Row (horizontal auto-layout, gap 24px)
88
+ │ ├── [Instance: value 1] + Value Label below
89
+ │ ├── [Instance: value 2] + Value Label below (DEFAULT badge if applicable)
90
+ │ └── ...
91
+
92
+ ├── Boolean Toggle Chapter(s)
93
+ │ ├── Chapter Header: "[Boolean Name]" (20px bold)
94
+ │ ├── Default label: "Default: false"
95
+ │ └── Exhibit Row (horizontal, gap 40px)
96
+ │ ├── [Instance: OFF state] + "Off" label + (DEFAULT badge)
97
+ │ └── [Instance: ON state] + "On" label
98
+
99
+ ├── Variable Mode Chapter(s)
100
+ │ ├── Chapter Header: "[Collection Name]" (20px bold)
101
+ │ ├── Modes: "Rounded | Square | Pill"
102
+ │ └── Exhibit Row
103
+ │ ├── [Instance: Mode 1] + Mode Label
104
+ │ ├── [Instance: Mode 2] + Mode Label
105
+ │ └── ...
106
+
107
+ └── Child Component Chapter(s) (if applicable)
108
+ ├── Chapter Header: "[Child Name] Properties" (20px bold)
109
+ ├── Context note: "Shown in context on [Parent Name]"
110
+ └── Sub-exhibits for each child property
111
+ └── Same exhibit format but instances are parent component
112
+ with the child property varied
113
+ ```
114
+
115
+ **Exhibit instance sizing:**
116
+ - Use the default variant size for all exhibits within a chapter
117
+ - Exception: Size axis exhibits obviously show each size at its actual dimensions
118
+ - Maximum instance width: 300px (scale down if needed, maintaining aspect ratio)
119
+ - Minimum gap between instances: 24px
120
+
121
+ **Default badges:**
122
+ - Small rounded rectangle: 4px padding, #E5E7EB background, "DEFAULT" text 10px bold #6B7280
123
+ - Placed below the instance, centered
124
+
125
+ ### Phase 5: Validate
126
+
127
+ Checklist:
128
+ - [ ] Every variant axis has an exhibit with an instance per value
129
+ - [ ] Every boolean toggle has a side-by-side OFF/ON exhibit
130
+ - [ ] Variable mode collections are rendered (if present)
131
+ - [ ] Child component properties are shown in-context on parent
132
+ - [ ] Default values are labeled on every exhibit
133
+ - [ ] No duplicate or redundant exhibits (normalization applied)
134
+ - [ ] Instances render correctly (no broken components)
135
+
136
+ ---
137
+
138
+ ## Example: Button Properties
139
+
140
+ ### Size (Variant Axis)
141
+ ```
142
+ Values: Large | Medium | Small | XSmall
143
+ Default: Medium
144
+
145
+ [Large instance] [Medium instance] [Small instance] [XSmall instance]
146
+ Large Medium Small XSmall
147
+ DEFAULT
148
+ ```
149
+
150
+ ### Show Leading Icon (Boolean)
151
+ ```
152
+ Default: false
153
+
154
+ [Button without icon] [Button with icon]
155
+ Off On
156
+ DEFAULT
157
+ ```
158
+
159
+ ### Shape (Variable Mode)
160
+ ```
161
+ Modes: Rounded | Square | Pill
162
+ Default: Rounded
163
+
164
+ [Rounded button] [Square button] [Pill button]
165
+ Rounded Square Pill
166
+ DEFAULT
167
+ ```
168
+
169
+ ### Trailing Content — Icon Button Properties (Child Component)
170
+ ```
171
+ Shown in context on Button
172
+
173
+ [Button with small icon] [Button with medium icon]
174
+ Icon Size: Small Icon Size: Medium
175
+ ```
@@ -0,0 +1,180 @@
1
+ # Screen Reader Spec Reference
2
+
3
+ Generate accessibility specifications for VoiceOver (iOS), TalkBack (Android), and ARIA (Web).
4
+
5
+ ## What This Spec Produces
6
+
7
+ 1. **Focus order diagram** — Visual showing the tab/swipe order through interactive elements
8
+ 2. **Per-platform tables** — VoiceOver, TalkBack, and ARIA properties for each focus stop
9
+ 3. **State-specific announcements** — How announcements change across enabled, disabled, selected, etc.
10
+ 4. **Merge analysis** — Which visual elements combine into a single focus stop vs. independent stops
11
+
12
+ ---
13
+
14
+ ## Step-by-Step Pipeline
15
+
16
+ ### Phase 1: Extract Component Elements
17
+
18
+ 1. Read all child layers from the component:
19
+ ```
20
+ get_node_children(node_id, recursive=true)
21
+ ```
22
+ 2. Classify each element:
23
+ - **Interactive**: buttons, toggles, inputs, links (elements users can act on)
24
+ - **Informational**: labels, helper text, badges, icons (content that informs but isn't interactive)
25
+ - **Decorative**: backgrounds, shadows, dividers (invisible to screen readers)
26
+
27
+ ### Phase 2: Merge Analysis (Critical AI Step)
28
+
29
+ The merge analysis determines which visual parts become independent **focus stops** and which get merged into a parent element's announcement.
30
+
31
+ **Rules for merging:**
32
+
33
+ | Visual Part | Merge Behavior |
34
+ |-------------|---------------|
35
+ | Label text adjacent to a control | **Merge** into the control's accessibility label |
36
+ | Helper/hint text below a control | **Merge** as the accessibility hint/description |
37
+ | Decorative icons (bullets, arrows) | **Hide** from screen readers entirely |
38
+ | Functional icons (clear, search, edit) | **Separate** focus stop if independently tappable |
39
+ | Action buttons within a compound control | **Separate** focus stop |
40
+ | Static content (read-only text, images) | **Merge** into nearest logical container |
41
+ | Error messages | **Live region** announcement, not a focus stop |
42
+ | Badges/counts | **Merge** into parent element's value announcement |
43
+
44
+ **Decision framework:**
45
+ 1. Is this element independently interactive (tappable/clickable)? → **Separate focus stop**
46
+ 2. Does this element add information to an adjacent interactive element? → **Merge** into that element
47
+ 3. Is this element purely visual? → **Hide** (decorative)
48
+ 4. Is this element dynamic content that changes without user action? → **Live region**
49
+
50
+ ### Phase 3: Determine Focus Order
51
+
52
+ For compound components with multiple focus stops:
53
+
54
+ 1. List all independent focus stops in their natural reading/tab order
55
+ 2. Default order: **left-to-right, top-to-bottom** (LTR layouts)
56
+ 3. Note any exceptions requested by the user (e.g., "input should focus before clear button")
57
+ 4. For each focus stop, note:
58
+ - Focus stop number
59
+ - Element name
60
+ - Which visual parts merge into this stop
61
+
62
+ **Example — Text Field:**
63
+ ```
64
+ Focus Stop 1: Input Field
65
+ Merges: Label text, Placeholder text, Helper text
66
+
67
+ Focus Stop 2: Clear Button (only when text is entered)
68
+ Merges: Clear icon
69
+ ```
70
+
71
+ ### Phase 4: Build Per-Platform Specifications
72
+
73
+ For each focus stop, document platform-specific properties:
74
+
75
+ #### iOS (VoiceOver)
76
+
77
+ | Property | Description | Example |
78
+ |----------|-------------|---------|
79
+ | `accessibilityLabel` | What VoiceOver announces as the element's name | "Search" |
80
+ | `accessibilityTraits` | Element type: `.button`, `.textField`, `.staticText`, `.header`, `.adjustable`, `.selected` | `.button` |
81
+ | `accessibilityHint` | Action description, read after a pause | "Double tap to activate" |
82
+ | `accessibilityValue` | Current value for adjustable elements | "3 of 5" |
83
+ | `isAccessibilityElement` | Whether this is a single focus stop (true) or a container (false) | `true` |
84
+
85
+ #### Android (TalkBack)
86
+
87
+ | Property | Description | Example |
88
+ |----------|-------------|---------|
89
+ | `contentDescription` | What TalkBack announces | "Search, Edit field" |
90
+ | `role` | Android role: `Button`, `EditText`, `CheckBox`, `Switch`, `Tab` | `Button` |
91
+ | `stateDescription` | Current state in human-readable form | "Disabled" |
92
+ | `importantForAccessibility` | Whether element is visible to TalkBack | `yes` |
93
+ | `liveRegion` | For dynamic content: `polite` or `assertive` | — |
94
+
95
+ #### Web (ARIA)
96
+
97
+ | Property | Description | Example |
98
+ |----------|-------------|---------|
99
+ | `role` | ARIA role: `button`, `textbox`, `checkbox`, `tab`, `tabpanel`, `alert` | `button` |
100
+ | `aria-label` | Accessible name (when visual text is insufficient) | "Close dialog" |
101
+ | `aria-labelledby` | ID reference to visible label element | `"label-email"` |
102
+ | `aria-describedby` | ID reference to description/hint element | `"hint-email"` |
103
+ | `aria-expanded` | For expandable elements: `true` or `false` | `false` |
104
+ | `aria-selected` | For selectable elements | `true` |
105
+ | `aria-disabled` | Disabled state | `true` |
106
+ | `aria-live` | For live regions: `polite` or `assertive` | — |
107
+ | `tabindex` | Tab order: `0` (natural), `-1` (programmatic only) | `0` |
108
+
109
+ ### Phase 5: Document State Variations
110
+
111
+ For each state the component can be in, document how announcements change:
112
+
113
+ | State | What Changes |
114
+ |-------|-------------|
115
+ | **Enabled** | Base announcement — label, role, hint |
116
+ | **Disabled** | Add "dimmed" (VoiceOver) / "disabled" (TalkBack) / `aria-disabled="true"` (ARIA) |
117
+ | **Selected** | Add "selected" trait/state |
118
+ | **Loading** | Announce "loading" via live region, disable interaction |
119
+ | **Error** | Announce error message via live region or `aria-invalid` + `aria-errormessage` |
120
+ | **Expanded** | Toggle `aria-expanded`, announce "expanded"/"collapsed" |
121
+
122
+ ### Phase 6: Render the Documentation Frame
123
+
124
+ ```
125
+ Main Frame (1440px wide, auto-layout vertical, padding 60px, gap 40px)
126
+ ├── Header Section
127
+ │ ├── Title: "[Component Name] — Screen Reader" (24px bold)
128
+ │ └── Subtitle: "VoiceOver, TalkBack, and ARIA specifications" (14px, #6B7280)
129
+
130
+ ├── Focus Order Section (only for compound components)
131
+ │ ├── Section Header: "Focus Order" (20px bold)
132
+ │ ├── Component Artwork with numbered focus indicators
133
+ │ ├── Focus sequence: "1 → 2 → 3" with element names
134
+ │ └── Notes about conditional focus stops
135
+
136
+ ├── Platform Section: "iOS — VoiceOver"
137
+ │ ├── Section Header (20px bold)
138
+ │ ├── Per-Focus-Stop Tables:
139
+ │ │ ├── Focus Stop 1: [Element Name]
140
+ │ │ │ └── State Table:
141
+ │ │ │ Header: Property | Enabled | Disabled | Selected
142
+ │ │ │ Row: accessibilityLabel | "Save" | "Save" | "Save"
143
+ │ │ │ Row: accessibilityTraits | .button | .button, .notEnabled | .button, .selected
144
+ │ │ └── Focus Stop 2: [Element Name]
145
+ │ │ └── ...
146
+
147
+ ├── Platform Section: "Android — TalkBack"
148
+ │ └── (same structure, Android properties)
149
+
150
+ └── Platform Section: "Web — ARIA"
151
+ └── (same structure, ARIA properties)
152
+ ```
153
+
154
+ ### Phase 7: Validate
155
+
156
+ Checklist:
157
+ - [ ] All interactive elements have a focus stop
158
+ - [ ] Non-interactive informational elements are merged into appropriate focus stops
159
+ - [ ] Decorative elements are marked as hidden from screen readers
160
+ - [ ] All three platforms (VoiceOver, TalkBack, ARIA) are documented
161
+ - [ ] State variations are documented (at minimum: enabled, disabled)
162
+ - [ ] Focus order is specified for compound components
163
+ - [ ] Error messages and dynamic content use live regions
164
+ - [ ] Merge analysis is consistent across platforms
165
+
166
+ ---
167
+
168
+ ## Component Complexity Guide
169
+
170
+ **Simple components (1 focus stop):**
171
+ Button, Checkbox, Switch, Toggle, Badge, Tag, Avatar
172
+ → Single focus stop, all visual parts merged. Document state changes.
173
+
174
+ **Compound components (2–5 focus stops):**
175
+ Text Field + Clear Button, Chip + Dismiss, Search Bar, Stepper
176
+ → Focus order section + per-stop tables. Document conditional stops.
177
+
178
+ **Complex components (5+ focus stops):**
179
+ Tab Bar, Navigation Bar, Data Table Row, Form Section
180
+ → Full focus order diagram. Consider documenting as a composite of simpler components with cross-references.