@thanhnguyxn/pixelcraft 0.0.0-stage → 0.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 (455) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.antigravity-plugin/plugin.json +32 -0
  3. package/.claude-plugin/marketplace.json +20 -0
  4. package/.claude-plugin/plugin.json +22 -0
  5. package/.codex-plugin/plugin.json +45 -0
  6. package/.cursor-plugin/marketplace.json +17 -0
  7. package/.cursor-plugin/plugin.json +27 -0
  8. package/.devin-plugin/plugin.json +21 -0
  9. package/.github/plugin/marketplace.json +34 -0
  10. package/CHANGELOG.md +159 -0
  11. package/GEMINI.md +1 -0
  12. package/LICENSE +21 -0
  13. package/README.md +264 -2
  14. package/SECURITY.md +28 -0
  15. package/assets/README.md +28 -0
  16. package/assets/pixelcraft-logo-128.png +0 -0
  17. package/assets/pixelcraft-logo-256.png +0 -0
  18. package/assets/pixelcraft-logo-512.png +0 -0
  19. package/bin/pixelcraft.mjs +852 -0
  20. package/docs/ARCHITECTURE.md +105 -0
  21. package/docs/DESIGN-RATIONALE.md +191 -0
  22. package/docs/INSTALL.md +221 -0
  23. package/evals/README.md +37 -0
  24. package/evals/fixtures/3d-web-engineering.json +69 -0
  25. package/evals/fixtures/README.md +36 -0
  26. package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
  27. package/evals/fixtures/ai-ui-libraries.json +53 -0
  28. package/evals/fixtures/audio-visual-accessibility.json +69 -0
  29. package/evals/fixtures/auth-and-checkout-ui.json +53 -0
  30. package/evals/fixtures/brandkit-identity-governance.json +48 -0
  31. package/evals/fixtures/build-and-architecture.json +53 -0
  32. package/evals/fixtures/canvas-and-node-editors.json +53 -0
  33. package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
  34. package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
  35. package/evals/fixtures/component-systems.json +53 -0
  36. package/evals/fixtures/component-testing.json +53 -0
  37. package/evals/fixtures/constrained-voice-and-tv.json +43 -0
  38. package/evals/fixtures/creative-code-rendering.json +69 -0
  39. package/evals/fixtures/creative-reference-evidence.json +67 -0
  40. package/evals/fixtures/data-app-python-marimo.json +49 -0
  41. package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
  42. package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
  43. package/evals/fixtures/desktop-native-workspace.json +48 -0
  44. package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
  45. package/evals/fixtures/direction-prototype-complexity.json +29 -0
  46. package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
  47. package/evals/fixtures/document-rust-typst-invoice.json +49 -0
  48. package/evals/fixtures/document-typst-and-print-css.json +43 -0
  49. package/evals/fixtures/email-mjml-dark-mode.json +49 -0
  50. package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
  51. package/evals/fixtures/enterprise-data-ui.json +53 -0
  52. package/evals/fixtures/extended-tui-toolkits.json +53 -0
  53. package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
  54. package/evals/fixtures/file-upload-media-ui.json +53 -0
  55. package/evals/fixtures/finish-gate-anti-slop.json +30 -0
  56. package/evals/fixtures/forms-accessibility-negative.json +29 -0
  57. package/evals/fixtures/forms-validation.json +53 -0
  58. package/evals/fixtures/game-go-ebitengine.json +49 -0
  59. package/evals/fixtures/game-godot-gdscript.json +49 -0
  60. package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
  61. package/evals/fixtures/handoff-fidelity-tolerance.json +29 -0
  62. package/evals/fixtures/i18n-engineering.json +53 -0
  63. package/evals/fixtures/local-first-sync.json +53 -0
  64. package/evals/fixtures/lynxjs.json +53 -0
  65. package/evals/fixtures/maizzle-email.json +53 -0
  66. package/evals/fixtures/maps-geospatial.json +53 -0
  67. package/evals/fixtures/media-og-and-video-export.json +43 -0
  68. package/evals/fixtures/media-players.json +53 -0
  69. package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
  70. package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
  71. package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
  72. package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
  73. package/evals/fixtures/mobile-jetpack-compose.json +49 -0
  74. package/evals/fixtures/mobile-swiftui-ios.json +49 -0
  75. package/evals/fixtures/motion-engineering.json +69 -0
  76. package/evals/fixtures/pdfjs-and-pptx.json +53 -0
  77. package/evals/fixtures/plan-brownfield-evidence.json +28 -0
  78. package/evals/fixtures/plan-discovery-interview.json +31 -0
  79. package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
  80. package/evals/fixtures/reactive-data-apps.json +53 -0
  81. package/evals/fixtures/review-evidence-audit.json +43 -0
  82. package/evals/fixtures/rich-text-and-code-editors.json +53 -0
  83. package/evals/fixtures/scrollytelling-resilience.json +70 -0
  84. package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
  85. package/evals/fixtures/state-architecture.json +53 -0
  86. package/evals/fixtures/styling-ecosystem.json +53 -0
  87. package/evals/fixtures/token-tooling.json +53 -0
  88. package/evals/fixtures/tui-go-bubbletea.json +49 -0
  89. package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
  90. package/evals/fixtures/tui-rust-ratatui.json +49 -0
  91. package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
  92. package/evals/fixtures/visual-qa-task-evidence.json +29 -0
  93. package/evals/fixtures/web-3d-engines.json +53 -0
  94. package/evals/fixtures/web-php-laravel-filament.json +49 -0
  95. package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
  96. package/evals/fixtures/workflow-checkpoints.json +30 -0
  97. package/evals/pixelcraft-accessibility.md +74 -0
  98. package/evals/pixelcraft-brandkit.md +58 -0
  99. package/evals/pixelcraft-chat-ui.md +55 -0
  100. package/evals/pixelcraft-constrained.md +55 -0
  101. package/evals/pixelcraft-craft.md +76 -0
  102. package/evals/pixelcraft-data-apps.md +55 -0
  103. package/evals/pixelcraft-dataviz.md +59 -0
  104. package/evals/pixelcraft-desktop.md +55 -0
  105. package/evals/pixelcraft-direction.md +77 -0
  106. package/evals/pixelcraft-document.md +55 -0
  107. package/evals/pixelcraft-email.md +55 -0
  108. package/evals/pixelcraft-extensions.md +55 -0
  109. package/evals/pixelcraft-game-ui.md +59 -0
  110. package/evals/pixelcraft-handoff.md +57 -0
  111. package/evals/pixelcraft-media.md +55 -0
  112. package/evals/pixelcraft-mobile.md +59 -0
  113. package/evals/pixelcraft-patterns.md +73 -0
  114. package/evals/pixelcraft-plan.md +127 -0
  115. package/evals/pixelcraft-review.md +63 -0
  116. package/evals/pixelcraft-spatial.md +55 -0
  117. package/evals/pixelcraft-tokens.md +57 -0
  118. package/evals/pixelcraft-tui.md +55 -0
  119. package/evals/pixelcraft-ux.md +59 -0
  120. package/evals/pixelcraft-visual-qa.md +86 -0
  121. package/evals/pixelcraft-web.md +89 -0
  122. package/evals/pixelcraft.md +70 -0
  123. package/gemini-extension.json +6 -0
  124. package/install.ps1 +341 -0
  125. package/install.sh +512 -0
  126. package/package.json +91 -4
  127. package/plugin.json +29 -0
  128. package/scripts/build-adapters.mjs +288 -0
  129. package/scripts/build-release-archives.mjs +61 -0
  130. package/scripts/build-skill-zips.mjs +94 -0
  131. package/scripts/run-evals.mjs +397 -0
  132. package/scripts/sync-docs.mjs +381 -0
  133. package/scripts/test-build-adapters.mjs +61 -0
  134. package/scripts/test-cross-platform-qa.mjs +359 -0
  135. package/scripts/test-distribution.mjs +203 -0
  136. package/scripts/test-export-tokens.mjs +361 -0
  137. package/scripts/test-finish-gate.mjs +271 -0
  138. package/scripts/test-installers.mjs +216 -0
  139. package/scripts/test-release-archives.mjs +42 -0
  140. package/scripts/test-shoot.mjs +87 -0
  141. package/scripts/test-slop-scan.mjs +416 -0
  142. package/scripts/test-style-inventory.mjs +234 -0
  143. package/scripts/test-sync-docs.mjs +140 -0
  144. package/scripts/test-validate-skills.mjs +195 -0
  145. package/scripts/validate-skills.mjs +658 -0
  146. package/skills/pixelcraft/SKILL.md +155 -0
  147. package/skills/pixelcraft/references/design-brief.md +75 -0
  148. package/skills/pixelcraft/references/floor.md +90 -0
  149. package/skills/pixelcraft/references/report-template.md +49 -0
  150. package/skills/pixelcraft/references/stack-detection.md +226 -0
  151. package/skills/pixelcraft/references/surface-acceptance.md +52 -0
  152. package/skills/pixelcraft/references/workflow-checkpoints.md +71 -0
  153. package/skills/pixelcraft-accessibility/SKILL.md +54 -0
  154. package/skills/pixelcraft-accessibility/references/apg-patterns.md +64 -0
  155. package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
  156. package/skills/pixelcraft-accessibility/references/platforms.md +86 -0
  157. package/skills/pixelcraft-accessibility/references/verification.md +64 -0
  158. package/skills/pixelcraft-accessibility/references/wcag22-checks.md +99 -0
  159. package/skills/pixelcraft-brandkit/SKILL.md +127 -0
  160. package/skills/pixelcraft-brandkit/references/asset-pipeline.md +165 -0
  161. package/skills/pixelcraft-brandkit/references/brand-governance.md +82 -0
  162. package/skills/pixelcraft-brandkit/references/layouts.md +88 -0
  163. package/skills/pixelcraft-brandkit/references/logo-concepting.md +83 -0
  164. package/skills/pixelcraft-brandkit/references/logo-methods.md +97 -0
  165. package/skills/pixelcraft-brandkit/references/pixel-art-logos.md +82 -0
  166. package/skills/pixelcraft-brandkit/references/prompt-template.md +87 -0
  167. package/skills/pixelcraft-brandkit/references/qa-checklist.md +93 -0
  168. package/skills/pixelcraft-brandkit/references/visual-modes.md +123 -0
  169. package/skills/pixelcraft-chat-ui/SKILL.md +57 -0
  170. package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
  171. package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
  172. package/skills/pixelcraft-chat-ui/references/conversation-design.md +84 -0
  173. package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +77 -0
  174. package/skills/pixelcraft-chat-ui/references/slack-discord.md +80 -0
  175. package/skills/pixelcraft-constrained/SKILL.md +52 -0
  176. package/skills/pixelcraft-constrained/references/specialized-hardware.md +90 -0
  177. package/skills/pixelcraft-constrained/references/tv-wearables.md +134 -0
  178. package/skills/pixelcraft-constrained/references/voice-ui.md +104 -0
  179. package/skills/pixelcraft-craft/SKILL.md +58 -0
  180. package/skills/pixelcraft-craft/references/color.md +125 -0
  181. package/skills/pixelcraft-craft/references/imagery-icons.md +37 -0
  182. package/skills/pixelcraft-craft/references/layout-quality.md +65 -0
  183. package/skills/pixelcraft-craft/references/layout.md +73 -0
  184. package/skills/pixelcraft-craft/references/motion.md +163 -0
  185. package/skills/pixelcraft-craft/references/typography.md +110 -0
  186. package/skills/pixelcraft-data-apps/SKILL.md +86 -0
  187. package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
  188. package/skills/pixelcraft-data-apps/references/dash.md +109 -0
  189. package/skills/pixelcraft-data-apps/references/evidence.md +90 -0
  190. package/skills/pixelcraft-data-apps/references/gradio.md +103 -0
  191. package/skills/pixelcraft-data-apps/references/julia-genie.md +89 -0
  192. package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +91 -0
  193. package/skills/pixelcraft-data-apps/references/nicegui.md +102 -0
  194. package/skills/pixelcraft-data-apps/references/observable-framework.md +105 -0
  195. package/skills/pixelcraft-data-apps/references/panel.md +99 -0
  196. package/skills/pixelcraft-data-apps/references/r-shiny.md +124 -0
  197. package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
  198. package/skills/pixelcraft-data-apps/references/reflex.md +116 -0
  199. package/skills/pixelcraft-data-apps/references/shiny.md +110 -0
  200. package/skills/pixelcraft-data-apps/references/streamlit.md +113 -0
  201. package/skills/pixelcraft-dataviz/SKILL.md +60 -0
  202. package/skills/pixelcraft-dataviz/references/chart-choice.md +55 -0
  203. package/skills/pixelcraft-dataviz/references/color-accessibility.md +112 -0
  204. package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +107 -0
  205. package/skills/pixelcraft-dataviz/references/libraries.md +176 -0
  206. package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
  207. package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +92 -0
  208. package/skills/pixelcraft-desktop/SKILL.md +93 -0
  209. package/skills/pixelcraft-desktop/references/appkit.md +92 -0
  210. package/skills/pixelcraft-desktop/references/avalonia.md +95 -0
  211. package/skills/pixelcraft-desktop/references/cpp-gui.md +129 -0
  212. package/skills/pixelcraft-desktop/references/electron.md +96 -0
  213. package/skills/pixelcraft-desktop/references/go-gui.md +83 -0
  214. package/skills/pixelcraft-desktop/references/gtk.md +97 -0
  215. package/skills/pixelcraft-desktop/references/javafx-swing.md +81 -0
  216. package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +88 -0
  217. package/skills/pixelcraft-desktop/references/rust-gui.md +83 -0
  218. package/skills/pixelcraft-desktop/references/tauri.md +110 -0
  219. package/skills/pixelcraft-desktop/references/uno-platform.md +71 -0
  220. package/skills/pixelcraft-desktop/references/winui-wpf.md +98 -0
  221. package/skills/pixelcraft-desktop/references/working-context.md +84 -0
  222. package/skills/pixelcraft-direction/SKILL.md +120 -0
  223. package/skills/pixelcraft-direction/references/composition-library.md +84 -0
  224. package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
  225. package/skills/pixelcraft-direction/references/direction-card.md +64 -0
  226. package/skills/pixelcraft-direction/references/direction-scoring.md +76 -0
  227. package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
  228. package/skills/pixelcraft-direction/references/movements.md +71 -0
  229. package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
  230. package/skills/pixelcraft-direction/references/repetition-history.md +75 -0
  231. package/skills/pixelcraft-direction/references/slop-fingerprints.md +83 -0
  232. package/skills/pixelcraft-direction/references/wildcards.md +47 -0
  233. package/skills/pixelcraft-document/SKILL.md +58 -0
  234. package/skills/pixelcraft-document/references/archetypes.md +106 -0
  235. package/skills/pixelcraft-document/references/pdf-tools.md +314 -0
  236. package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
  237. package/skills/pixelcraft-document/references/print-css.md +187 -0
  238. package/skills/pixelcraft-document/references/slides.md +198 -0
  239. package/skills/pixelcraft-email/SKILL.md +80 -0
  240. package/skills/pixelcraft-email/references/client-quirks.md +113 -0
  241. package/skills/pixelcraft-email/references/html-tables.md +114 -0
  242. package/skills/pixelcraft-email/references/maizzle.md +54 -0
  243. package/skills/pixelcraft-email/references/mjml.md +54 -0
  244. package/skills/pixelcraft-email/references/react-email.md +95 -0
  245. package/skills/pixelcraft-extensions/SKILL.md +56 -0
  246. package/skills/pixelcraft-extensions/references/browser-extensions.md +105 -0
  247. package/skills/pixelcraft-extensions/references/figma-office.md +106 -0
  248. package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
  249. package/skills/pixelcraft-extensions/references/raycast.md +98 -0
  250. package/skills/pixelcraft-extensions/references/vscode-webviews.md +100 -0
  251. package/skills/pixelcraft-game-ui/SKILL.md +80 -0
  252. package/skills/pixelcraft-game-ui/references/bevy.md +90 -0
  253. package/skills/pixelcraft-game-ui/references/godot.md +130 -0
  254. package/skills/pixelcraft-game-ui/references/hud-principles.md +67 -0
  255. package/skills/pixelcraft-game-ui/references/love2d.md +77 -0
  256. package/skills/pixelcraft-game-ui/references/monogame.md +68 -0
  257. package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
  258. package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +107 -0
  259. package/skills/pixelcraft-game-ui/references/unreal-umg.md +80 -0
  260. package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
  261. package/skills/pixelcraft-handoff/SKILL.md +50 -0
  262. package/skills/pixelcraft-handoff/references/design-translation.md +134 -0
  263. package/skills/pixelcraft-handoff/references/fidelity-tolerance.md +78 -0
  264. package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
  265. package/skills/pixelcraft-media/SKILL.md +49 -0
  266. package/skills/pixelcraft-media/references/banners-video.md +130 -0
  267. package/skills/pixelcraft-media/references/og-generation.md +154 -0
  268. package/skills/pixelcraft-media/references/social-cards.md +71 -0
  269. package/skills/pixelcraft-mobile/SKILL.md +86 -0
  270. package/skills/pixelcraft-mobile/references/dotnet-maui.md +91 -0
  271. package/skills/pixelcraft-mobile/references/flet.md +80 -0
  272. package/skills/pixelcraft-mobile/references/flutter.md +113 -0
  273. package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
  274. package/skills/pixelcraft-mobile/references/ionic-capacitor.md +87 -0
  275. package/skills/pixelcraft-mobile/references/jetpack-compose.md +129 -0
  276. package/skills/pixelcraft-mobile/references/kivy.md +82 -0
  277. package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +86 -0
  278. package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
  279. package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
  280. package/skills/pixelcraft-mobile/references/react-native-expo.md +106 -0
  281. package/skills/pixelcraft-mobile/references/swiftui.md +200 -0
  282. package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
  283. package/skills/pixelcraft-mobile/references/task-state-composition.md +85 -0
  284. package/skills/pixelcraft-mobile/references/uikit.md +92 -0
  285. package/skills/pixelcraft-patterns/SKILL.md +75 -0
  286. package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
  287. package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
  288. package/skills/pixelcraft-patterns/references/auth-onboarding.md +44 -0
  289. package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
  290. package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
  291. package/skills/pixelcraft-patterns/references/commerce.md +47 -0
  292. package/skills/pixelcraft-patterns/references/communication.md +45 -0
  293. package/skills/pixelcraft-patterns/references/creative-tools.md +42 -0
  294. package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
  295. package/skills/pixelcraft-patterns/references/dashboard-admin.md +35 -0
  296. package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
  297. package/skills/pixelcraft-patterns/references/marketing.md +44 -0
  298. package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
  299. package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
  300. package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
  301. package/skills/pixelcraft-patterns/references/pattern-selection.md +80 -0
  302. package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
  303. package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
  304. package/skills/pixelcraft-patterns/references/search-filtering.md +42 -0
  305. package/skills/pixelcraft-patterns/references/settings.md +51 -0
  306. package/skills/pixelcraft-patterns/references/tables-crud.md +43 -0
  307. package/skills/pixelcraft-plan/SKILL.md +103 -0
  308. package/skills/pixelcraft-plan/references/design-input.md +69 -0
  309. package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
  310. package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
  311. package/skills/pixelcraft-plan/references/plan-template.md +134 -0
  312. package/skills/pixelcraft-plan/references/repo-discovery.md +49 -0
  313. package/skills/pixelcraft-plan/references/stack-freshness.md +67 -0
  314. package/skills/pixelcraft-plan/references/stack-selection.md +98 -0
  315. package/skills/pixelcraft-review/SKILL.md +86 -0
  316. package/skills/pixelcraft-review/references/audit-report.md +69 -0
  317. package/skills/pixelcraft-review/references/critique-protocol.md +89 -0
  318. package/skills/pixelcraft-review/references/heuristics.md +63 -0
  319. package/skills/pixelcraft-review/references/personas.md +53 -0
  320. package/skills/pixelcraft-review/references/polish.md +78 -0
  321. package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
  322. package/skills/pixelcraft-review/scripts/fixtures/brand-critique-waivers.json +14 -0
  323. package/skills/pixelcraft-review/scripts/fixtures/brand-critique.css +18 -0
  324. package/skills/pixelcraft-review/scripts/fixtures/clean.html +43 -0
  325. package/skills/pixelcraft-review/scripts/fixtures/focus-after-block.css +4 -0
  326. package/skills/pixelcraft-review/scripts/fixtures/focus-at-rules.css +17 -0
  327. package/skills/pixelcraft-review/scripts/fixtures/focus-comments.css +10 -0
  328. package/skills/pixelcraft-review/scripts/fixtures/focus-html-quote-leak.html +12 -0
  329. package/skills/pixelcraft-review/scripts/fixtures/focus-invalid-replacements.css +27 -0
  330. package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
  331. package/skills/pixelcraft-review/scripts/fixtures/focus-nested-rules.css +19 -0
  332. package/skills/pixelcraft-review/scripts/fixtures/focus-not-visible-skip.css +8 -0
  333. package/skills/pixelcraft-review/scripts/fixtures/focus-outline-shorthands.css +11 -0
  334. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-and-border.css +15 -0
  335. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-last-wins.css +19 -0
  336. package/skills/pixelcraft-review/scripts/fixtures/focus-valid-replacements-extended.css +29 -0
  337. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-no-replacement.css +3 -0
  338. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-valid-replacements.css +9 -0
  339. package/skills/pixelcraft-review/scripts/fixtures/slop.html +28 -0
  340. package/skills/pixelcraft-review/scripts/slop-scan.mjs +1233 -0
  341. package/skills/pixelcraft-spatial/SKILL.md +51 -0
  342. package/skills/pixelcraft-spatial/references/comfort-accessibility.md +39 -0
  343. package/skills/pixelcraft-spatial/references/platforms.md +147 -0
  344. package/skills/pixelcraft-tokens/SKILL.md +60 -0
  345. package/skills/pixelcraft-tokens/assets/tokens.example.json +71 -0
  346. package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +47 -0
  347. package/skills/pixelcraft-tokens/references/adoption.md +55 -0
  348. package/skills/pixelcraft-tokens/references/format.md +84 -0
  349. package/skills/pixelcraft-tokens/references/governance.md +80 -0
  350. package/skills/pixelcraft-tokens/references/state-tokens.md +62 -0
  351. package/skills/pixelcraft-tokens/references/theme-presets.md +122 -0
  352. package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
  353. package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +847 -0
  354. package/skills/pixelcraft-tui/SKILL.md +76 -0
  355. package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +79 -0
  356. package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
  357. package/skills/pixelcraft-tui/references/ink.md +109 -0
  358. package/skills/pixelcraft-tui/references/ratatui.md +102 -0
  359. package/skills/pixelcraft-tui/references/rich.md +82 -0
  360. package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
  361. package/skills/pixelcraft-tui/references/textual.md +108 -0
  362. package/skills/pixelcraft-ux/SKILL.md +56 -0
  363. package/skills/pixelcraft-ux/references/cognitive-walkthrough.md +70 -0
  364. package/skills/pixelcraft-ux/references/feedback-performance.md +50 -0
  365. package/skills/pixelcraft-ux/references/flows-ia.md +44 -0
  366. package/skills/pixelcraft-ux/references/forms.md +151 -0
  367. package/skills/pixelcraft-ux/references/i18n.md +221 -0
  368. package/skills/pixelcraft-ux/references/laws.md +39 -0
  369. package/skills/pixelcraft-ux/references/locale-test-matrix.md +60 -0
  370. package/skills/pixelcraft-ux/references/state-matrix.md +53 -0
  371. package/skills/pixelcraft-ux/references/usability-testing.md +84 -0
  372. package/skills/pixelcraft-ux/references/ux-writing.md +44 -0
  373. package/skills/pixelcraft-visual-qa/SKILL.md +96 -0
  374. package/skills/pixelcraft-visual-qa/references/baseline-governance.md +70 -0
  375. package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +59 -0
  376. package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
  377. package/skills/pixelcraft-visual-qa/references/capture-email.md +38 -0
  378. package/skills/pixelcraft-visual-qa/references/capture-mobile.md +50 -0
  379. package/skills/pixelcraft-visual-qa/references/capture-terminal.md +35 -0
  380. package/skills/pixelcraft-visual-qa/references/critique-rubric.md +71 -0
  381. package/skills/pixelcraft-visual-qa/references/finish-gate.md +35 -0
  382. package/skills/pixelcraft-visual-qa/references/measured-craft.md +30 -0
  383. package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
  384. package/skills/pixelcraft-visual-qa/references/performance-budgets.md +78 -0
  385. package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
  386. package/skills/pixelcraft-visual-qa/references/task-verification.md +81 -0
  387. package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
  388. package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
  389. package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
  390. package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
  391. package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +174 -0
  392. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-aria-modal.html +19 -0
  393. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-audit.html +34 -0
  394. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-modal.html +17 -0
  395. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-deferred.js +1 -0
  396. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-edge.html +52 -0
  397. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.html +80 -0
  398. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.js +8 -0
  399. package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +668 -0
  400. package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +1226 -0
  401. package/skills/pixelcraft-web/SKILL.md +132 -0
  402. package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
  403. package/skills/pixelcraft-web/references/adaptive-layout.md +69 -0
  404. package/skills/pixelcraft-web/references/angular.md +108 -0
  405. package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
  406. package/skills/pixelcraft-web/references/astro.md +113 -0
  407. package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
  408. package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
  409. package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
  410. package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
  411. package/skills/pixelcraft-web/references/clojurescript.md +88 -0
  412. package/skills/pixelcraft-web/references/component-systems.md +102 -0
  413. package/skills/pixelcraft-web/references/component-testing.md +170 -0
  414. package/skills/pixelcraft-web/references/creative-effects.md +59 -0
  415. package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
  416. package/skills/pixelcraft-web/references/elm.md +53 -0
  417. package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
  418. package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
  419. package/skills/pixelcraft-web/references/forms-validation.md +123 -0
  420. package/skills/pixelcraft-web/references/fsharp-fable.md +54 -0
  421. package/skills/pixelcraft-web/references/gsap.md +102 -0
  422. package/skills/pixelcraft-web/references/html-css.md +220 -0
  423. package/skills/pixelcraft-web/references/htmx-alpine.md +103 -0
  424. package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
  425. package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
  426. package/skills/pixelcraft-web/references/java-web.md +61 -0
  427. package/skills/pixelcraft-web/references/kotlin-web.md +57 -0
  428. package/skills/pixelcraft-web/references/leptos-yew.md +97 -0
  429. package/skills/pixelcraft-web/references/lit-web-components.md +63 -0
  430. package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
  431. package/skills/pixelcraft-web/references/media-players.md +104 -0
  432. package/skills/pixelcraft-web/references/motion-react.md +96 -0
  433. package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
  434. package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
  435. package/skills/pixelcraft-web/references/pwa.md +230 -0
  436. package/skills/pixelcraft-web/references/qwik.md +94 -0
  437. package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
  438. package/skills/pixelcraft-web/references/react-next.md +168 -0
  439. package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
  440. package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
  441. package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
  442. package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
  443. package/skills/pixelcraft-web/references/scala-laminar.md +53 -0
  444. package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
  445. package/skills/pixelcraft-web/references/server-rendered.md +114 -0
  446. package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
  447. package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
  448. package/skills/pixelcraft-web/references/solid.md +111 -0
  449. package/skills/pixelcraft-web/references/state-architecture.md +107 -0
  450. package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
  451. package/skills/pixelcraft-web/references/svelte.md +111 -0
  452. package/skills/pixelcraft-web/references/tailwind.md +99 -0
  453. package/skills/pixelcraft-web/references/video-media.md +69 -0
  454. package/skills/pixelcraft-web/references/vue-nuxt.md +86 -0
  455. package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
@@ -0,0 +1,55 @@
1
+ # Canvas, WebGL, WebGPU and 3D verification
2
+
3
+ ## Runtime states
4
+
5
+ Verify:
6
+ - poster/placeholder before renderer initialization;
7
+ - ready state and the primary task;
8
+ - failed asset and offline/network failure;
9
+ - unsupported API or lost GPU context;
10
+ - document hidden/offscreen and restored;
11
+ - resize/orientation change and DPR change;
12
+ - reduced-motion or low-power mode;
13
+ - repeated open/close and memory cleanup (zero geometry/texture leak across remounts).
14
+
15
+ ## Profiling tools and concrete verification checks
16
+
17
+ | Check | Tool / API | What to verify |
18
+ |---|---|---|
19
+ | **WebGL draw-call & shader audit** | **Spector.js** (browser extension or `spectorjs` embed) | Capture a live frame; verify redundant state changes, draw-call count, framebuffer passes, and uncompressed textures |
20
+ | **Three.js / R3F resource leaks** | `renderer.info.render` (`calls`, `triangles`) and `renderer.info.memory` (`geometries`, `textures`) | Record baseline, navigate away and return 3×, confirm `geometries` and `textures` return to baseline (`dispose()` called) |
21
+ | **WebGL context loss recovery** | `WEBGL_lose_context` extension | Force loss + restore and confirm static fallback displays and scene recovers cleanly without unhandled errors |
22
+ | **WebGPU capability fallback** | `navigator.gpu` / `requestAdapter()` stub | Simulate missing `navigator.gpu` or `requestAdapter() => null`; confirm graceful fallback to WebGL2, 2D canvas, or static media |
23
+ | **FPS & GPU memory** | Chrome DevTools **Rendering → Frame Rendering Stats** (FPS meter), Performance GPU track, Chrome Task Manager **GPU Memory** column | Confirm steady frame pacing without sustained > 16.6 ms frames or unbounded GPU memory growth |
24
+
25
+ ```js
26
+ // Playwright / DevTools verification snippets for context loss & WebGPU fallback
27
+ // 1. Simulate WebGL context loss and recovery
28
+ await page.evaluate(() => {
29
+ const gl = document.querySelector('canvas')?.getContext('webgl2');
30
+ const ext = gl?.getExtension('WEBGL_lose_context');
31
+ ext?.loseContext();
32
+ setTimeout(() => ext?.restoreContext(), 500);
33
+ });
34
+
35
+ // 2. Simulate unsupported WebGPU before page load (verify fallback path)
36
+ await page.addInitScript(() => {
37
+ Object.defineProperty(navigator, 'gpu', { value: undefined, configurable: true });
38
+ });
39
+ ```
40
+
41
+ ## Performance record
42
+
43
+ Record browser/device/GPU where visible (`chrome://gpu` or `WEBGL_debug_renderer_info` where exposed), viewport, DPR, refresh rate, scene state, cold/warm cache, frame-time/FPS sample, long tasks, transfer/parse cost, asset sizes, `renderer.info` draw calls/texture counts, and measurement method. Distinguish actual hardware from software SwiftShader/emulation.
44
+
45
+ ## Visual evidence
46
+
47
+ A rendered screenshot supports composition, not frame stability, interaction, or GPU cost. Use a profiler/performance trace and actual interaction where available. If tooling cannot expose GPU/memory information, report the limitation (`not-checked`); do not estimate a passing number.
48
+
49
+ ## Quality gates
50
+
51
+ - Essential text/actions remain semantic DOM.
52
+ - Canvas has a fallback and accessible summary/control path.
53
+ - Render loop pauses when hidden/offscreen (`document.hidden` / `IntersectionObserver`) where appropriate.
54
+ - GPU buffers, geometries, textures, and event listeners are released on unmount/route change.
55
+ - No high-frequency flashing (`≤ 3 flashes/s`) or unpausable motion (`> 5 s`).
@@ -0,0 +1,81 @@
1
+ # Task-driven visual QA
2
+
3
+ Use this reference when judging whether the interface actually works. A screenshot is evidence about appearance at one instant; it is not proof that users can complete the task. Execute realistic tasks and capture the resulting evidence.
4
+
5
+ ## Task selection
6
+
7
+ Choose tasks from the design brief/plan rather than generic inspection:
8
+
9
+ | Task type | Examples | Required evidence |
10
+ |---|---|---|
11
+ | primary success | create, search, checkout, publish, configure, navigate to detail | initial state → key intermediate feedback → final end state |
12
+ | recovery | invalid input, offline retry, permission denied, conflict, cancellation | preserved input/context, truthful error, recovery path completion |
13
+ | orientation | deep link, back/forward/escape, refresh/relaunch, interruption | understandable restored state |
14
+ | adaptation | small viewport/window, text scaling, RTL/locale, input modality change | task remains possible and legible |
15
+ | destructive/high-cost | delete, reset, payment, irreversible publish, sending messages to real users | consequence communication, confirmation/undo/cancel behavior |
16
+
17
+ Define the expected end state before execution. “No console errors” or “page loads” is not a task outcome.
18
+
19
+ ## Destructive/high-cost execution boundary
20
+
21
+ Never execute destructive or high-cost tasks against live/production data, real customer accounts, real payment instruments, production publish targets, or real message recipients. These tasks may run only inside a sandbox, disposable fixture, mocked backend, local/test environment, or provider-approved test mode using test credentials.
22
+
23
+ Before execution, verify and record which boundary applies. If no safe boundary exists:
24
+
25
+ 1. exercise the flow only up to the final confirmation/commit step;
26
+ 2. verify consequence copy, friction, focus/keyboard behavior, cancellation, input preservation, and recovery affordances that do not commit the action;
27
+ 3. mark the irreversible submission/payment/deletion/publish/send step `not run` in the execution record;
28
+ 4. ask the user for a sandbox/test fixture/mock/test-mode credential or explicit direction before attempting completion.
29
+
30
+ A user interface being locally hosted does not make downstream effects safe: payment APIs, email delivery, production databases, publish endpoints, and shared remote state remain live side effects unless explicitly isolated.
31
+
32
+ ## Execution record
33
+
34
+ ```markdown
35
+ | Task | Fixture/context | Steps executed | Expected end state | Actual result | Evidence artifact | Label |
36
+ |---|---|---|---|---|---|---|
37
+ | invite teammate | empty project, keyboard only, 390px, en-LTR | | | pass/fail/blocked/not run | path/timestamp | rendered/not-checked |
38
+ ```
39
+
40
+ Record runtime/build/version, platform/emulation status, viewport/device, locale/direction, network state, input modality, and exact fixture. Redact secrets/private data.
41
+
42
+ ## Agent execution rules
43
+
44
+ 1. Drive the real surface using the most faithful available mechanism: browser interaction, device/simulator control, native test harness, terminal interaction, snapshot interaction runner, or manual capture.
45
+ 2. Do not only inspect static markup and infer behavior. Static evidence may supplement but not replace execution.
46
+ 3. Verify intermediate feedback: pending/disabled state, validation timing, focus movement, announcements/status where inspectable, progress, cancellation, and retry.
47
+ 4. Verify the end state in data/UI terms, not only visual similarity: object created, navigation location correct, input preserved, error shown, undo available, permission enforced.
48
+ 5. Capture failure traces at the moment of failure. Do not retry until evidence disappears.
49
+ 6. Fix one deterministic defect at a time and rerun the affected task only.
50
+ 7. Stop after the agreed repair budget (at most three rounds); report remaining defects or uncertainty instead of looping by taste.
51
+
52
+ ## Failure classification
53
+
54
+ Classify failures before repairing:
55
+
56
+ - **task blocker:** correct action impossible/missing/inaccessible;
57
+ - **navigation failure:** state lost, wrong back/escape/deep-link behavior;
58
+ - **feedback failure:** action occurred but status/result is invisible or misleading;
59
+ - **input failure:** keyboard/touch/controller/IME/paste/autofill path broken;
60
+ - **layout failure:** action/content clipped, obscured, unreachable, or unstable;
61
+ - **data/state failure:** stale response, duplication, lost input, wrong permission/conflict behavior;
62
+ - **visual fidelity issue:** implementation diverges visually without blocking behavior;
63
+ - **test fixture failure:** harness/data/environment invalid rather than product broken.
64
+
65
+ Do not repair a fixture failure by changing product behavior unless the product defect is independently proven.
66
+
67
+ ## Evidence precedence
68
+
69
+ Strongest evidence for behavior:
70
+
71
+ 1. real device/platform runtime (`rendered`);
72
+ 2. simulator/emulator/browser interaction (`rendered`, labeled emulation);
73
+ 3. deterministic interactive test harness/snapshot backend (`rendered` only for the behavior it truly exercises);
74
+ 4. static event/state analysis (`static`);
75
+ 5. model screenshot interpretation (`model-judgment`).
76
+
77
+ Never escalate a screenshot reading into task-completion evidence.
78
+
79
+ ## Lightweight two-width evidence floor
80
+
81
+ For a narrow review outside the finish gate, capture at least one desktop width and one narrow mobile width such as 390 px. Compare hierarchy, measure, navigation availability, clipping, touch target spacing, and whether the signature composition survives or intentionally degrades. If only one width is captured, mark responsive behavior `not-checked`. For a new or materially changed flow, use the full width matrix in [finish-gate.md](finish-gate.md).
@@ -0,0 +1,442 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ function help() {
7
+ return `Usage: node check-contrast.mjs <tokens.json> [--mode NAME] [--pairs FILE] [--json]
8
+
9
+ Compute exact WCAG 2.2 relative-luminance contrast ratios and APCA Lc (SAPC 0.0.98G-4g)
10
+ for DTCG color token pairs. Supports DTCG color objects (srgb, oklch, oklab, display-p3, hsl)
11
+ as well as hex, rgb(), rgba(), hsl(), and oklch() strings.
12
+
13
+ Options:
14
+ --mode NAME Apply mode overrides from $extensions.pixelcraft.modes
15
+ --pairs FILE JSON array (or { pairs: [...] }) of { foreground, background, role?, name? }
16
+ Role may be "text" (4.5:1), "ui" (3.0:1), or "large" (3.0:1).
17
+ When omitted, auto-detects surface/background vs ink/action pairs.
18
+ --json Print machine-readable JSON output
19
+ --help Show this help`;
20
+ }
21
+
22
+ function gamma(v) {
23
+ return v <= 0.0031308 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
24
+ }
25
+ function linearize(c) {
26
+ return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
27
+ }
28
+ function clamp01(v) {
29
+ return Math.max(0, Math.min(1, v));
30
+ }
31
+ function oklabToRgb(L, a, b) {
32
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
33
+ const m = (L - 0.1055613458 * a - 0.0638541729 * b) ** 3;
34
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
35
+ return [
36
+ gamma(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
37
+ gamma(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
38
+ gamma(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
39
+ ].map(clamp01);
40
+ }
41
+ function oklchToRgb(L, C, H) {
42
+ const rad = (H * Math.PI) / 180;
43
+ return oklabToRgb(L, C * Math.cos(rad), C * Math.sin(rad));
44
+ }
45
+ function displayP3ToRgb(r, g, b) {
46
+ const lr = linearize(r);
47
+ const lg = linearize(g);
48
+ const lb = linearize(b);
49
+ return [
50
+ gamma(1.2249401763 * lr - 0.2249401763 * lg),
51
+ gamma(-0.0420569547 * lr + 1.0420569547 * lg),
52
+ gamma(-0.0196375546 * lr - 0.0786360456 * lg + 1.0982736002 * lb),
53
+ ].map(clamp01);
54
+ }
55
+ function hslToRgb(H, S, L) {
56
+ const h = ((H % 360) + 360) % 360;
57
+ const s = Math.max(0, Math.min(100, S)) / 100;
58
+ const l = Math.max(0, Math.min(100, L)) / 100;
59
+ const c = (1 - Math.abs(2 * l - 1)) * s;
60
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
61
+ const m = l - c / 2;
62
+ let r = 0, g = 0, b = 0;
63
+ if (h < 60) [r, g, b] = [c, x, 0];
64
+ else if (h < 120) [r, g, b] = [x, c, 0];
65
+ else if (h < 180) [r, g, b] = [0, c, x];
66
+ else if (h < 240) [r, g, b] = [0, x, c];
67
+ else if (h < 300) [r, g, b] = [x, 0, c];
68
+ else [r, g, b] = [c, 0, x];
69
+ return [r + m, g + m, b + m].map(clamp01);
70
+ }
71
+ function rgbToHex(rgb, alpha = 1) {
72
+ const hex = rgb.map((v) => Math.round(clamp01(v) * 255).toString(16).padStart(2, '0')).join('');
73
+ if (alpha < 1) {
74
+ return `#${hex}${Math.round(clamp01(alpha) * 255).toString(16).padStart(2, '0')}`;
75
+ }
76
+ return `#${hex}`;
77
+ }
78
+
79
+ function parseAlpha(token) {
80
+ if (token === undefined || token === null || token === '') return 1;
81
+ const trimmed = String(token).trim();
82
+ if (trimmed.endsWith('%')) return clamp01(Number.parseFloat(trimmed) / 100);
83
+ return clamp01(Number.parseFloat(trimmed));
84
+ }
85
+
86
+ function parseAngleDeg(token) {
87
+ const trimmed = String(token).trim().toLowerCase();
88
+ if (trimmed === 'none') return 0;
89
+ if (trimmed.endsWith('turn')) return Number.parseFloat(trimmed) * 360;
90
+ if (trimmed.endsWith('rad')) return (Number.parseFloat(trimmed) * 180) / Math.PI;
91
+ if (trimmed.endsWith('grad')) return Number.parseFloat(trimmed) * 0.9;
92
+ return Number.parseFloat(trimmed);
93
+ }
94
+
95
+ function parseColorString(raw) {
96
+ const str = String(raw).trim();
97
+ const hexM = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(str);
98
+ if (hexM) {
99
+ let hex = hexM[1].toLowerCase();
100
+ if (hex.length === 3 || hex.length === 4) hex = hex.split('').map((c) => c + c).join('');
101
+ const r = parseInt(hex.slice(0, 2), 16) / 255;
102
+ const g = parseInt(hex.slice(2, 4), 16) / 255;
103
+ const b = parseInt(hex.slice(4, 6), 16) / 255;
104
+ const alpha = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
105
+ return { rgb: [r, g, b], alpha, hex: rgbToHex([r, g, b], alpha) };
106
+ }
107
+ const rgbM = /^rgba?\(\s*([^)]+)\s*\)$/i.exec(str);
108
+ if (rgbM) {
109
+ const inner = rgbM[1].trim();
110
+ let channels;
111
+ let alpha = 1;
112
+ if (inner.includes('/')) {
113
+ const [lhs, rhs] = inner.split('/');
114
+ channels = lhs.trim().split(/[\s,]+/).filter(Boolean);
115
+ alpha = parseAlpha(rhs);
116
+ } else {
117
+ const parts = inner.split(/[\s,]+/).filter(Boolean);
118
+ channels = parts.slice(0, 3);
119
+ if (parts[3] !== undefined) alpha = parseAlpha(parts[3]);
120
+ }
121
+ if (channels.length !== 3) throw new Error(`invalid rgb() color: ${str}`);
122
+ const rgb = channels.map((ch) => {
123
+ if (ch.endsWith('%')) return clamp01(Number.parseFloat(ch) / 100);
124
+ return clamp01(Number.parseFloat(ch) / 255);
125
+ });
126
+ return { rgb, alpha, hex: rgbToHex(rgb, alpha) };
127
+ }
128
+ const oklchM = /^oklch\(\s*([^)]+)\s*\)$/i.exec(str);
129
+ if (oklchM) {
130
+ const [lhs, rhs] = oklchM[1].split('/');
131
+ const parts = lhs.trim().split(/\s+/).filter(Boolean);
132
+ if (parts.length !== 3) throw new Error(`invalid oklch() color: ${str}`);
133
+ const L = parts[0].endsWith('%') ? Number.parseFloat(parts[0]) / 100 : Number.parseFloat(parts[0]);
134
+ const C = parts[1].endsWith('%') ? (Number.parseFloat(parts[1]) / 100) * 0.4 : Number.parseFloat(parts[1]);
135
+ const H = parseAngleDeg(parts[2]);
136
+ const alpha = rhs !== undefined ? parseAlpha(rhs) : 1;
137
+ const rgb = oklchToRgb(L, C, H);
138
+ return { rgb, alpha, hex: rgbToHex(rgb, alpha) };
139
+ }
140
+ const hslM = /^hsla?\(\s*([^)]+)\s*\)$/i.exec(str);
141
+ if (hslM) {
142
+ const [lhs, rhs] = hslM[1].split('/');
143
+ const parts = lhs.trim().split(/[\s,]+/).filter(Boolean);
144
+ if (parts.length < 3) throw new Error(`invalid hsl() color: ${str}`);
145
+ const H = parseAngleDeg(parts[0]);
146
+ const S = Number.parseFloat(parts[1]);
147
+ const L = Number.parseFloat(parts[2]);
148
+ const alpha = rhs !== undefined ? parseAlpha(rhs) : (parts[3] !== undefined ? parseAlpha(parts[3]) : 1);
149
+ const rgb = hslToRgb(H, S, L);
150
+ return { rgb, alpha, hex: rgbToHex(rgb, alpha) };
151
+ }
152
+ throw new Error(`unsupported color value '${str}'; use #hex, rgb(), oklch(), hsl(), or a DTCG color object`);
153
+ }
154
+
155
+ function parseColorValue(value) {
156
+ if (typeof value === 'string') return parseColorString(value);
157
+ if (!value || typeof value !== 'object') throw new Error(`invalid color token value: ${JSON.stringify(value)}`);
158
+ const alpha = value.alpha ?? 1;
159
+ if (typeof value.hex === 'string') {
160
+ const fallback = parseColorString(value.hex);
161
+ return { rgb: fallback.rgb, alpha, hex: rgbToHex(fallback.rgb, alpha) };
162
+ }
163
+ const nums = (value.components || []).map((c) => (c === 'none' ? 0 : Number(c)));
164
+ let rgb;
165
+ if (value.colorSpace === 'srgb') rgb = nums.map(clamp01);
166
+ else if (value.colorSpace === 'oklch') rgb = oklchToRgb(nums[0], nums[1], nums[2]);
167
+ else if (value.colorSpace === 'oklab') rgb = oklabToRgb(nums[0], nums[1], nums[2]);
168
+ else if (value.colorSpace === 'display-p3') rgb = displayP3ToRgb(nums[0], nums[1], nums[2]);
169
+ else if (value.colorSpace === 'hsl') rgb = hslToRgb(nums[0], nums[1], nums[2]);
170
+ else throw new Error(`unsupported DTCG colorSpace '${value.colorSpace}'`);
171
+ return { rgb, alpha, hex: rgbToHex(rgb, alpha) };
172
+ }
173
+
174
+ function compositeOver(fg, bg) {
175
+ const a = fg.alpha ?? 1;
176
+ if (a >= 1) return fg.rgb;
177
+ return [
178
+ fg.rgb[0] * a + bg.rgb[0] * (1 - a),
179
+ fg.rgb[1] * a + bg.rgb[1] * (1 - a),
180
+ fg.rgb[2] * a + bg.rgb[2] * (1 - a),
181
+ ];
182
+ }
183
+
184
+ function wcagLuminance([r, g, b]) {
185
+ return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
186
+ }
187
+
188
+ export function wcagContrast(fgRgb, bgRgb) {
189
+ const l1 = wcagLuminance(fgRgb);
190
+ const l2 = wcagLuminance(bgRgb);
191
+ const lighter = Math.max(l1, l2);
192
+ const darker = Math.min(l1, l2);
193
+ return (lighter + 0.05) / (darker + 0.05);
194
+ }
195
+
196
+ // APCA-W3 / SAPC 0.0.98G-4g formula
197
+ export function apcaContrast(txtRgb, bgRgb) {
198
+ const mainTRC = 2.4;
199
+ const sRco = 0.2126729;
200
+ const sGco = 0.7151522;
201
+ const sBco = 0.0721750;
202
+ const normBG = 0.56;
203
+ const normTXT = 0.57;
204
+ const revTXT = 0.62;
205
+ const revBG = 0.65;
206
+ const blkThrs = 0.022;
207
+ const blkClmp = 1.414;
208
+ const scaleBoW = 1.14;
209
+ const scaleWoB = 1.14;
210
+ const loBoWoffset = 0.027;
211
+ const loWoBoffset = 0.027;
212
+ const loClip = 0.1;
213
+ const deltaYmin = 0.0005;
214
+
215
+ let txtY = sRco * (txtRgb[0] ** mainTRC) + sGco * (txtRgb[1] ** mainTRC) + sBco * (txtRgb[2] ** mainTRC);
216
+ let bgY = sRco * (bgRgb[0] ** mainTRC) + sGco * (bgRgb[1] ** mainTRC) + sBco * (bgRgb[2] ** mainTRC);
217
+
218
+ txtY = txtY > blkThrs ? txtY : txtY + (blkThrs - txtY) ** blkClmp;
219
+ bgY = bgY > blkThrs ? bgY : bgY + (blkThrs - bgY) ** blkClmp;
220
+
221
+ if (Math.abs(bgY - txtY) < deltaYmin) return 0;
222
+
223
+ let outputContrast = 0;
224
+ if (bgY > txtY) {
225
+ const sapc = (bgY ** normBG - txtY ** normTXT) * scaleBoW;
226
+ outputContrast = sapc < loClip ? 0 : sapc - loBoWoffset;
227
+ } else {
228
+ const sapc = (bgY ** revBG - txtY ** revTXT) * scaleWoB;
229
+ outputContrast = sapc > -loClip ? 0 : sapc + loWoBoffset;
230
+ }
231
+ return Number((outputContrast * 100).toFixed(1));
232
+ }
233
+
234
+ function flattenTokens(node, parts = [], inheritedType = '', out = []) {
235
+ const type = node.$type || inheritedType;
236
+ if (parts.length > 0 && Object.hasOwn(node, '$root') && typeof node.$root === 'object' && node.$root !== null
237
+ && Object.hasOwn(node.$root, '$value')) {
238
+ out.push({ path: parts, type: node.$root.$type || type, token: node.$root, isRoot: true });
239
+ }
240
+ for (const [key, value] of Object.entries(node)) {
241
+ if (key.startsWith('$') || typeof value !== 'object' || value === null || Array.isArray(value)) continue;
242
+ const next = [...parts, key];
243
+ if (Object.hasOwn(value, '$value')) out.push({ path: next, type: value.$type || type, token: value });
244
+ else flattenTokens(value, next, type, out);
245
+ }
246
+ return out;
247
+ }
248
+
249
+ function loadColorTokens(file, mode) {
250
+ const data = JSON.parse(fs.readFileSync(file, 'utf8'));
251
+ const flattened = flattenTokens(data);
252
+ const availableModes = new Set();
253
+ for (const t of flattened) {
254
+ for (const m of Object.keys(t.token.$extensions?.pixelcraft?.modes || {})) availableModes.add(m);
255
+ }
256
+ if (mode && !availableModes.has(mode)) throw new Error(`unknown --mode '${mode}'`);
257
+
258
+ const byPath = new Map();
259
+ for (const t of flattened) {
260
+ const key = t.path.join('.');
261
+ byPath.set(key, t);
262
+ if (t.isRoot) byPath.set(`${key}.$root`, t);
263
+ }
264
+
265
+ const applyMode = (t) => {
266
+ if (!mode) return t;
267
+ const rep = t.token.$extensions?.pixelcraft?.modes?.[mode];
268
+ if (rep === undefined) return t;
269
+ const val = rep && typeof rep === 'object' && Object.hasOwn(rep, '$value') ? rep.$value : rep;
270
+ return { ...t, token: { ...t.token, $value: val } };
271
+ };
272
+
273
+ const modeTokens = flattened.map(applyMode);
274
+ const modeByPath = new Map();
275
+ for (const t of modeTokens) {
276
+ const key = t.path.join('.');
277
+ modeByPath.set(key, t);
278
+ if (t.isRoot) modeByPath.set(`${key}.$root`, t);
279
+ }
280
+
281
+ const resolving = new Set();
282
+ function resolve(t) {
283
+ const raw = t.token.$value;
284
+ if (typeof raw === 'string' && /^\{[^}]+\}$/.test(raw)) {
285
+ const ref = raw.slice(1, -1);
286
+ if (resolving.has(ref)) throw new Error(`reference cycle at {${ref}}`);
287
+ const target = modeByPath.get(ref);
288
+ if (!target) throw new Error(`unresolved token reference {${ref}}`);
289
+ resolving.add(ref);
290
+ const resolved = resolve(target);
291
+ resolving.delete(ref);
292
+ return { value: resolved.value, type: t.type || resolved.type };
293
+ }
294
+ return { value: raw, type: t.type };
295
+ }
296
+
297
+ const colors = new Map();
298
+ for (const t of modeTokens) {
299
+ const key = t.path.join('.');
300
+ const baseResolved = resolve(t);
301
+ if (baseResolved.type !== 'color') continue;
302
+ colors.set(key, parseColorValue(baseResolved.value));
303
+ }
304
+ return colors;
305
+ }
306
+
307
+ function autoDetectPairs(colors) {
308
+ const keys = [...colors.keys()];
309
+ const semanticKeys = keys.filter((k) => /^semantic\./i.test(k));
310
+ const pool = semanticKeys.length >= 2 ? semanticKeys : keys;
311
+
312
+ const isBg = (k) => /(?:^|\.)(?:background|bg|surface|canvas|base|panel|card)(?:\.|$)/i.test(k);
313
+ const isText = (k) => /(?:^|\.)(?:foreground|fg|ink|text|body|heading|muted|on-surface|on-background)(?:\.|$)/i.test(k);
314
+ const isUi = (k) => /(?:^|\.)(?:action|brand|accent|primary|secondary|link|error|danger|warning|success|focus|border)(?:\.|$)/i.test(k);
315
+
316
+ const bgs = pool.filter(isBg);
317
+ const texts = pool.filter((k) => isText(k) && !isBg(k));
318
+ const uis = pool.filter((k) => isUi(k) && !isBg(k) && !isText(k));
319
+
320
+ const pairs = [];
321
+ const seen = new Set();
322
+ const pushPair = (fg, bg, role) => {
323
+ if (fg === bg) return;
324
+ const id = `${fg}|${bg}|${role}`;
325
+ if (seen.has(id)) return;
326
+ seen.add(id);
327
+ pairs.push({ name: `${fg} on ${bg}`, foreground: fg, background: bg, role });
328
+ };
329
+
330
+ for (const bg of bgs) {
331
+ for (const fg of texts) pushPair(fg, bg, 'text');
332
+ for (const ui of uis) pushPair(ui, bg, 'ui');
333
+ }
334
+ return pairs;
335
+ }
336
+
337
+ function parseCli(args) {
338
+ const out = { help: false, json: false, mode: '', pairsFile: '', input: '' };
339
+ for (let i = 0; i < args.length; i += 1) {
340
+ const arg = args[i];
341
+ if (arg === '--help' || arg === '-h') out.help = true;
342
+ else if (arg === '--json') out.json = true;
343
+ else if (arg === '--mode') {
344
+ if (!args[i + 1]) throw new Error('--mode requires a value');
345
+ out.mode = args[++i];
346
+ } else if (arg.startsWith('--mode=')) out.mode = arg.slice('--mode='.length);
347
+ else if (arg === '--pairs') {
348
+ if (!args[i + 1]) throw new Error('--pairs requires a value');
349
+ out.pairsFile = args[++i];
350
+ } else if (arg.startsWith('--pairs=')) out.pairsFile = arg.slice('--pairs='.length);
351
+ else if (arg.startsWith('-')) throw new Error(`unknown option: ${arg}`);
352
+ else if (!out.input) out.input = arg;
353
+ else throw new Error(`unexpected argument: ${arg}`);
354
+ }
355
+ return out;
356
+ }
357
+
358
+ function main() {
359
+ const cli = parseCli(process.argv.slice(2));
360
+ if (cli.help) {
361
+ console.log(help());
362
+ return;
363
+ }
364
+ if (!cli.input) throw new Error('provide a DTCG tokens JSON file; see --help');
365
+ const colors = loadColorTokens(path.resolve(cli.input), cli.mode);
366
+
367
+ let pairs;
368
+ if (cli.pairsFile) {
369
+ const raw = JSON.parse(fs.readFileSync(path.resolve(cli.pairsFile), 'utf8'));
370
+ pairs = Array.isArray(raw) ? raw : raw?.pairs;
371
+ if (!Array.isArray(pairs) || pairs.length === 0) throw new Error('--pairs file must contain a non-empty array of color pairs');
372
+ } else {
373
+ pairs = autoDetectPairs(colors);
374
+ }
375
+
376
+ if (pairs.length === 0) {
377
+ throw new Error('no contrast pairs detected; pass --pairs <file> or define surface/background and ink/foreground/action color tokens');
378
+ }
379
+
380
+ const resolveRef = (ref) => {
381
+ if (colors.has(ref)) return colors.get(ref);
382
+ return parseColorString(ref);
383
+ };
384
+
385
+ const results = pairs.map((pair) => {
386
+ const role = pair.role || 'text';
387
+ if (!['text', 'ui', 'large'].includes(role)) throw new Error(`invalid role '${role}'; expected text, ui, or large`);
388
+ const fg = resolveRef(pair.foreground);
389
+ const bg = resolveRef(pair.background);
390
+ const effectiveFg = compositeOver(fg, bg);
391
+ const ratio = Number(wcagContrast(effectiveFg, bg.rgb).toFixed(2));
392
+ const apcaLc = apcaContrast(effectiveFg, bg.rgb);
393
+ const threshold = role === 'text' ? 4.5 : 3.0;
394
+ const pass = ratio >= threshold;
395
+ return {
396
+ name: pair.name || `${pair.foreground} on ${pair.background}`,
397
+ foreground: pair.foreground,
398
+ background: pair.background,
399
+ foregroundHex: fg.hex,
400
+ backgroundHex: bg.hex,
401
+ role,
402
+ threshold,
403
+ wcagRatio: ratio,
404
+ apcaLc,
405
+ apcaAdvisoryPass: Math.abs(apcaLc) >= (role === 'text' ? 60 : 45),
406
+ pass,
407
+ };
408
+ });
409
+
410
+ const failures = results.filter((r) => !r.pass);
411
+ const report = {
412
+ file: cli.input,
413
+ mode: cli.mode || 'default',
414
+ label: 'static',
415
+ note: 'Static token contrast math (WCAG 2.2 + APCA 0.0.98G-4g); live anti-aliasing, transparency stacking, and images still require rendered inspection.',
416
+ totalPairs: results.length,
417
+ failedPairs: failures.length,
418
+ pass: failures.length === 0,
419
+ results,
420
+ };
421
+
422
+ if (cli.json) {
423
+ console.log(JSON.stringify(report, null, 2));
424
+ } else {
425
+ console.log(`check-contrast [${report.label}] (${report.mode}): ${results.length - failures.length}/${results.length} pairs pass`);
426
+ for (const r of results) {
427
+ const status = r.pass ? 'PASS' : 'FAIL';
428
+ console.log(` ${status} [${r.role} >= ${r.threshold}:1] ${r.name} (${r.foregroundHex} on ${r.backgroundHex}) -> WCAG ${r.wcagRatio}:1, APCA Lc ${r.apcaLc}`);
429
+ }
430
+ console.log(`note: ${report.note}`);
431
+ }
432
+ if (!report.pass) process.exitCode = 1;
433
+ }
434
+
435
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
436
+ try {
437
+ main();
438
+ } catch (error) {
439
+ console.error(`check-contrast: ${error.message}`);
440
+ process.exit(1);
441
+ }
442
+ }