@thanhnguyxn/pixelcraft 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.claude-plugin/marketplace.json +20 -0
  3. package/.claude-plugin/plugin.json +11 -0
  4. package/LICENSE +21 -0
  5. package/README.md +407 -2
  6. package/assets/README.md +28 -0
  7. package/assets/pixelcraft-logo-512.png +0 -0
  8. package/bin/pixelcraft.mjs +444 -0
  9. package/docs/ARCHITECTURE.md +102 -0
  10. package/docs/DESIGN-RATIONALE.md +143 -0
  11. package/evals/README.md +27 -0
  12. package/evals/fixtures/README.md +36 -0
  13. package/evals/fixtures/direction-prototype-complexity.json +29 -0
  14. package/evals/fixtures/finish-gate-anti-slop.json +30 -0
  15. package/evals/fixtures/forms-accessibility-negative.json +29 -0
  16. package/evals/fixtures/handoff-fidelity-tolerance.json +29 -0
  17. package/evals/fixtures/plan-brownfield-evidence.json +28 -0
  18. package/evals/fixtures/visual-qa-task-evidence.json +29 -0
  19. package/evals/fixtures/workflow-checkpoints.json +30 -0
  20. package/evals/pixelcraft-accessibility.md +57 -0
  21. package/evals/pixelcraft-brandkit.md +58 -0
  22. package/evals/pixelcraft-chat-ui.md +55 -0
  23. package/evals/pixelcraft-constrained.md +55 -0
  24. package/evals/pixelcraft-craft.md +60 -0
  25. package/evals/pixelcraft-data-apps.md +55 -0
  26. package/evals/pixelcraft-dataviz.md +59 -0
  27. package/evals/pixelcraft-desktop.md +55 -0
  28. package/evals/pixelcraft-direction.md +60 -0
  29. package/evals/pixelcraft-document.md +55 -0
  30. package/evals/pixelcraft-email.md +55 -0
  31. package/evals/pixelcraft-extensions.md +55 -0
  32. package/evals/pixelcraft-game-ui.md +59 -0
  33. package/evals/pixelcraft-handoff.md +57 -0
  34. package/evals/pixelcraft-media.md +55 -0
  35. package/evals/pixelcraft-mobile.md +59 -0
  36. package/evals/pixelcraft-patterns.md +57 -0
  37. package/evals/pixelcraft-plan.md +65 -0
  38. package/evals/pixelcraft-review.md +63 -0
  39. package/evals/pixelcraft-spatial.md +55 -0
  40. package/evals/pixelcraft-tokens.md +57 -0
  41. package/evals/pixelcraft-tui.md +55 -0
  42. package/evals/pixelcraft-ux.md +59 -0
  43. package/evals/pixelcraft-visual-qa.md +80 -0
  44. package/evals/pixelcraft-web.md +71 -0
  45. package/evals/pixelcraft.md +70 -0
  46. package/gemini-extension.json +5 -0
  47. package/install.ps1 +295 -0
  48. package/install.sh +437 -0
  49. package/package.json +63 -4
  50. package/plugin.json +24 -0
  51. package/scripts/build-adapters.mjs +290 -0
  52. package/scripts/build-release-archives.mjs +61 -0
  53. package/scripts/build-skill-zips.mjs +94 -0
  54. package/scripts/test-build-adapters.mjs +48 -0
  55. package/scripts/test-distribution.mjs +124 -0
  56. package/scripts/test-export-tokens.mjs +105 -0
  57. package/scripts/test-finish-gate.mjs +148 -0
  58. package/scripts/test-installers.mjs +67 -0
  59. package/scripts/test-release-archives.mjs +42 -0
  60. package/scripts/test-shoot.mjs +65 -0
  61. package/scripts/test-slop-scan.mjs +29 -0
  62. package/scripts/test-style-inventory.mjs +211 -0
  63. package/scripts/test-validate-skills.mjs +117 -0
  64. package/scripts/validate-skills.mjs +512 -0
  65. package/skills/pixelcraft/SKILL.md +135 -0
  66. package/skills/pixelcraft/references/design-brief.md +75 -0
  67. package/skills/pixelcraft/references/floor.md +73 -0
  68. package/skills/pixelcraft/references/report-template.md +35 -0
  69. package/skills/pixelcraft/references/stack-detection.md +155 -0
  70. package/skills/pixelcraft/references/surface-acceptance.md +40 -0
  71. package/skills/pixelcraft/references/workflow-checkpoints.md +29 -0
  72. package/skills/pixelcraft-accessibility/SKILL.md +33 -0
  73. package/skills/pixelcraft-accessibility/references/apg-patterns.md +51 -0
  74. package/skills/pixelcraft-accessibility/references/platforms.md +58 -0
  75. package/skills/pixelcraft-accessibility/references/verification.md +59 -0
  76. package/skills/pixelcraft-accessibility/references/wcag22-checks.md +66 -0
  77. package/skills/pixelcraft-brandkit/SKILL.md +115 -0
  78. package/skills/pixelcraft-brandkit/references/asset-pipeline.md +125 -0
  79. package/skills/pixelcraft-brandkit/references/brand-governance.md +80 -0
  80. package/skills/pixelcraft-brandkit/references/layouts.md +88 -0
  81. package/skills/pixelcraft-brandkit/references/logo-concepting.md +83 -0
  82. package/skills/pixelcraft-brandkit/references/logo-methods.md +98 -0
  83. package/skills/pixelcraft-brandkit/references/pixel-art-logos.md +82 -0
  84. package/skills/pixelcraft-brandkit/references/prompt-template.md +85 -0
  85. package/skills/pixelcraft-brandkit/references/qa-checklist.md +88 -0
  86. package/skills/pixelcraft-brandkit/references/visual-modes.md +123 -0
  87. package/skills/pixelcraft-chat-ui/SKILL.md +53 -0
  88. package/skills/pixelcraft-chat-ui/references/conversation-design.md +78 -0
  89. package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +87 -0
  90. package/skills/pixelcraft-chat-ui/references/slack-discord.md +96 -0
  91. package/skills/pixelcraft-constrained/SKILL.md +51 -0
  92. package/skills/pixelcraft-constrained/references/specialized-hardware.md +66 -0
  93. package/skills/pixelcraft-constrained/references/tv-wearables.md +84 -0
  94. package/skills/pixelcraft-constrained/references/voice-ui.md +63 -0
  95. package/skills/pixelcraft-craft/SKILL.md +44 -0
  96. package/skills/pixelcraft-craft/references/color.md +69 -0
  97. package/skills/pixelcraft-craft/references/imagery-icons.md +37 -0
  98. package/skills/pixelcraft-craft/references/layout-quality.md +65 -0
  99. package/skills/pixelcraft-craft/references/layout.md +41 -0
  100. package/skills/pixelcraft-craft/references/motion.md +76 -0
  101. package/skills/pixelcraft-craft/references/typography.md +71 -0
  102. package/skills/pixelcraft-data-apps/SKILL.md +67 -0
  103. package/skills/pixelcraft-data-apps/references/dash.md +53 -0
  104. package/skills/pixelcraft-data-apps/references/evidence.md +75 -0
  105. package/skills/pixelcraft-data-apps/references/gradio.md +65 -0
  106. package/skills/pixelcraft-data-apps/references/julia-genie.md +54 -0
  107. package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +53 -0
  108. package/skills/pixelcraft-data-apps/references/nicegui.md +63 -0
  109. package/skills/pixelcraft-data-apps/references/observable-framework.md +67 -0
  110. package/skills/pixelcraft-data-apps/references/panel.md +53 -0
  111. package/skills/pixelcraft-data-apps/references/r-shiny.md +54 -0
  112. package/skills/pixelcraft-data-apps/references/reflex.md +62 -0
  113. package/skills/pixelcraft-data-apps/references/shiny.md +53 -0
  114. package/skills/pixelcraft-data-apps/references/streamlit.md +65 -0
  115. package/skills/pixelcraft-dataviz/SKILL.md +63 -0
  116. package/skills/pixelcraft-dataviz/references/chart-choice.md +55 -0
  117. package/skills/pixelcraft-dataviz/references/color-accessibility.md +112 -0
  118. package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +97 -0
  119. package/skills/pixelcraft-dataviz/references/libraries.md +57 -0
  120. package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +99 -0
  121. package/skills/pixelcraft-desktop/SKILL.md +71 -0
  122. package/skills/pixelcraft-desktop/references/appkit.md +58 -0
  123. package/skills/pixelcraft-desktop/references/avalonia.md +59 -0
  124. package/skills/pixelcraft-desktop/references/cpp-gui.md +52 -0
  125. package/skills/pixelcraft-desktop/references/electron.md +54 -0
  126. package/skills/pixelcraft-desktop/references/go-gui.md +54 -0
  127. package/skills/pixelcraft-desktop/references/gtk.md +54 -0
  128. package/skills/pixelcraft-desktop/references/javafx-swing.md +52 -0
  129. package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +61 -0
  130. package/skills/pixelcraft-desktop/references/rust-gui.md +65 -0
  131. package/skills/pixelcraft-desktop/references/tauri.md +54 -0
  132. package/skills/pixelcraft-desktop/references/uno-platform.md +52 -0
  133. package/skills/pixelcraft-desktop/references/winui-wpf.md +58 -0
  134. package/skills/pixelcraft-desktop/references/working-context.md +5 -0
  135. package/skills/pixelcraft-direction/SKILL.md +154 -0
  136. package/skills/pixelcraft-direction/references/composition-library.md +84 -0
  137. package/skills/pixelcraft-direction/references/direction-card.md +54 -0
  138. package/skills/pixelcraft-direction/references/direction-scoring.md +72 -0
  139. package/skills/pixelcraft-direction/references/movements.md +68 -0
  140. package/skills/pixelcraft-direction/references/repetition-history.md +75 -0
  141. package/skills/pixelcraft-direction/references/slop-fingerprints.md +58 -0
  142. package/skills/pixelcraft-direction/references/wildcards.md +47 -0
  143. package/skills/pixelcraft-document/SKILL.md +54 -0
  144. package/skills/pixelcraft-document/references/archetypes.md +83 -0
  145. package/skills/pixelcraft-document/references/pdf-tools.md +154 -0
  146. package/skills/pixelcraft-document/references/print-css.md +134 -0
  147. package/skills/pixelcraft-document/references/slides.md +102 -0
  148. package/skills/pixelcraft-email/SKILL.md +58 -0
  149. package/skills/pixelcraft-email/references/client-quirks.md +45 -0
  150. package/skills/pixelcraft-email/references/html-tables.md +53 -0
  151. package/skills/pixelcraft-email/references/mjml.md +52 -0
  152. package/skills/pixelcraft-email/references/react-email.md +53 -0
  153. package/skills/pixelcraft-extensions/SKILL.md +51 -0
  154. package/skills/pixelcraft-extensions/references/browser-extensions.md +31 -0
  155. package/skills/pixelcraft-extensions/references/figma-office.md +23 -0
  156. package/skills/pixelcraft-extensions/references/raycast.md +19 -0
  157. package/skills/pixelcraft-extensions/references/vscode-webviews.md +26 -0
  158. package/skills/pixelcraft-game-ui/SKILL.md +61 -0
  159. package/skills/pixelcraft-game-ui/references/bevy.md +52 -0
  160. package/skills/pixelcraft-game-ui/references/godot.md +57 -0
  161. package/skills/pixelcraft-game-ui/references/hud-principles.md +38 -0
  162. package/skills/pixelcraft-game-ui/references/love2d.md +51 -0
  163. package/skills/pixelcraft-game-ui/references/monogame.md +52 -0
  164. package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +65 -0
  165. package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -0
  166. package/skills/pixelcraft-handoff/SKILL.md +49 -0
  167. package/skills/pixelcraft-handoff/references/design-translation.md +104 -0
  168. package/skills/pixelcraft-handoff/references/fidelity-tolerance.md +78 -0
  169. package/skills/pixelcraft-media/SKILL.md +52 -0
  170. package/skills/pixelcraft-media/references/banners-video.md +112 -0
  171. package/skills/pixelcraft-media/references/og-generation.md +107 -0
  172. package/skills/pixelcraft-media/references/social-cards.md +72 -0
  173. package/skills/pixelcraft-mobile/SKILL.md +69 -0
  174. package/skills/pixelcraft-mobile/references/dotnet-maui.md +63 -0
  175. package/skills/pixelcraft-mobile/references/flet.md +53 -0
  176. package/skills/pixelcraft-mobile/references/flutter.md +69 -0
  177. package/skills/pixelcraft-mobile/references/ionic-capacitor.md +65 -0
  178. package/skills/pixelcraft-mobile/references/jetpack-compose.md +61 -0
  179. package/skills/pixelcraft-mobile/references/kivy.md +59 -0
  180. package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +60 -0
  181. package/skills/pixelcraft-mobile/references/react-native-expo.md +71 -0
  182. package/skills/pixelcraft-mobile/references/swiftui.md +70 -0
  183. package/skills/pixelcraft-mobile/references/task-state-composition.md +5 -0
  184. package/skills/pixelcraft-mobile/references/uikit.md +58 -0
  185. package/skills/pixelcraft-patterns/SKILL.md +58 -0
  186. package/skills/pixelcraft-patterns/references/auth-onboarding.md +25 -0
  187. package/skills/pixelcraft-patterns/references/commerce.md +28 -0
  188. package/skills/pixelcraft-patterns/references/communication.md +26 -0
  189. package/skills/pixelcraft-patterns/references/creative-tools.md +29 -0
  190. package/skills/pixelcraft-patterns/references/dashboard-admin.md +31 -0
  191. package/skills/pixelcraft-patterns/references/marketing.md +32 -0
  192. package/skills/pixelcraft-patterns/references/pattern-selection.md +74 -0
  193. package/skills/pixelcraft-patterns/references/search-filtering.md +42 -0
  194. package/skills/pixelcraft-patterns/references/settings.md +23 -0
  195. package/skills/pixelcraft-patterns/references/tables-crud.md +43 -0
  196. package/skills/pixelcraft-plan/SKILL.md +67 -0
  197. package/skills/pixelcraft-plan/references/design-input.md +69 -0
  198. package/skills/pixelcraft-plan/references/plan-template.md +99 -0
  199. package/skills/pixelcraft-plan/references/repo-discovery.md +42 -0
  200. package/skills/pixelcraft-plan/references/stack-freshness.md +50 -0
  201. package/skills/pixelcraft-plan/references/stack-selection.md +42 -0
  202. package/skills/pixelcraft-review/SKILL.md +64 -0
  203. package/skills/pixelcraft-review/references/audit-report.md +50 -0
  204. package/skills/pixelcraft-review/references/critique-protocol.md +89 -0
  205. package/skills/pixelcraft-review/references/heuristics.md +18 -0
  206. package/skills/pixelcraft-review/references/personas.md +26 -0
  207. package/skills/pixelcraft-review/references/polish.md +38 -0
  208. package/skills/pixelcraft-review/scripts/fixtures/brand-critique-waivers.json +14 -0
  209. package/skills/pixelcraft-review/scripts/fixtures/brand-critique.css +18 -0
  210. package/skills/pixelcraft-review/scripts/fixtures/clean.html +43 -0
  211. package/skills/pixelcraft-review/scripts/fixtures/focus-after-block.css +4 -0
  212. package/skills/pixelcraft-review/scripts/fixtures/focus-at-rules.css +17 -0
  213. package/skills/pixelcraft-review/scripts/fixtures/focus-comments.css +10 -0
  214. package/skills/pixelcraft-review/scripts/fixtures/focus-html-quote-leak.html +12 -0
  215. package/skills/pixelcraft-review/scripts/fixtures/focus-invalid-replacements.css +27 -0
  216. package/skills/pixelcraft-review/scripts/fixtures/focus-nested-rules.css +19 -0
  217. package/skills/pixelcraft-review/scripts/fixtures/focus-not-visible-skip.css +8 -0
  218. package/skills/pixelcraft-review/scripts/fixtures/focus-outline-shorthands.css +11 -0
  219. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-and-border.css +15 -0
  220. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-last-wins.css +19 -0
  221. package/skills/pixelcraft-review/scripts/fixtures/focus-valid-replacements-extended.css +29 -0
  222. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-no-replacement.css +3 -0
  223. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-valid-replacements.css +9 -0
  224. package/skills/pixelcraft-review/scripts/fixtures/slop.html +28 -0
  225. package/skills/pixelcraft-review/scripts/slop-scan.mjs +586 -0
  226. package/skills/pixelcraft-spatial/SKILL.md +52 -0
  227. package/skills/pixelcraft-spatial/references/comfort-accessibility.md +98 -0
  228. package/skills/pixelcraft-spatial/references/platforms.md +77 -0
  229. package/skills/pixelcraft-tokens/SKILL.md +56 -0
  230. package/skills/pixelcraft-tokens/assets/tokens.example.json +71 -0
  231. package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +47 -0
  232. package/skills/pixelcraft-tokens/references/adoption.md +55 -0
  233. package/skills/pixelcraft-tokens/references/format.md +54 -0
  234. package/skills/pixelcraft-tokens/references/governance.md +80 -0
  235. package/skills/pixelcraft-tokens/references/state-tokens.md +62 -0
  236. package/skills/pixelcraft-tokens/references/theme-presets.md +94 -0
  237. package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +285 -0
  238. package/skills/pixelcraft-tui/SKILL.md +60 -0
  239. package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +60 -0
  240. package/skills/pixelcraft-tui/references/ink.md +60 -0
  241. package/skills/pixelcraft-tui/references/ratatui.md +62 -0
  242. package/skills/pixelcraft-tui/references/rich.md +62 -0
  243. package/skills/pixelcraft-tui/references/textual.md +67 -0
  244. package/skills/pixelcraft-ux/SKILL.md +46 -0
  245. package/skills/pixelcraft-ux/references/cognitive-walkthrough.md +70 -0
  246. package/skills/pixelcraft-ux/references/feedback-performance.md +30 -0
  247. package/skills/pixelcraft-ux/references/flows-ia.md +44 -0
  248. package/skills/pixelcraft-ux/references/forms.md +97 -0
  249. package/skills/pixelcraft-ux/references/i18n.md +183 -0
  250. package/skills/pixelcraft-ux/references/laws.md +18 -0
  251. package/skills/pixelcraft-ux/references/locale-test-matrix.md +60 -0
  252. package/skills/pixelcraft-ux/references/state-matrix.md +39 -0
  253. package/skills/pixelcraft-ux/references/usability-testing.md +84 -0
  254. package/skills/pixelcraft-ux/references/ux-writing.md +43 -0
  255. package/skills/pixelcraft-visual-qa/SKILL.md +82 -0
  256. package/skills/pixelcraft-visual-qa/references/baseline-governance.md +70 -0
  257. package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +38 -0
  258. package/skills/pixelcraft-visual-qa/references/capture-email.md +34 -0
  259. package/skills/pixelcraft-visual-qa/references/capture-mobile.md +35 -0
  260. package/skills/pixelcraft-visual-qa/references/capture-terminal.md +31 -0
  261. package/skills/pixelcraft-visual-qa/references/critique-rubric.md +71 -0
  262. package/skills/pixelcraft-visual-qa/references/finish-gate.md +35 -0
  263. package/skills/pixelcraft-visual-qa/references/measured-craft.md +30 -0
  264. package/skills/pixelcraft-visual-qa/references/performance-budgets.md +65 -0
  265. package/skills/pixelcraft-visual-qa/references/task-verification.md +81 -0
  266. package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +135 -0
  267. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-aria-modal.html +19 -0
  268. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-audit.html +34 -0
  269. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-modal.html +17 -0
  270. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-deferred.js +1 -0
  271. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-edge.html +52 -0
  272. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.html +80 -0
  273. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.js +8 -0
  274. package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +513 -0
  275. package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +1154 -0
  276. package/skills/pixelcraft-web/SKILL.md +76 -0
  277. package/skills/pixelcraft-web/references/adaptive-layout.md +25 -0
  278. package/skills/pixelcraft-web/references/angular.md +61 -0
  279. package/skills/pixelcraft-web/references/astro.md +62 -0
  280. package/skills/pixelcraft-web/references/clojurescript.md +53 -0
  281. package/skills/pixelcraft-web/references/elm.md +53 -0
  282. package/skills/pixelcraft-web/references/fsharp-fable.md +53 -0
  283. package/skills/pixelcraft-web/references/html-css.md +88 -0
  284. package/skills/pixelcraft-web/references/htmx-alpine.md +53 -0
  285. package/skills/pixelcraft-web/references/java-web.md +52 -0
  286. package/skills/pixelcraft-web/references/kotlin-web.md +53 -0
  287. package/skills/pixelcraft-web/references/leptos-yew.md +54 -0
  288. package/skills/pixelcraft-web/references/lit-web-components.md +61 -0
  289. package/skills/pixelcraft-web/references/pwa.md +225 -0
  290. package/skills/pixelcraft-web/references/qwik.md +54 -0
  291. package/skills/pixelcraft-web/references/react-next.md +69 -0
  292. package/skills/pixelcraft-web/references/scala-laminar.md +53 -0
  293. package/skills/pixelcraft-web/references/server-rendered.md +71 -0
  294. package/skills/pixelcraft-web/references/solid.md +60 -0
  295. package/skills/pixelcraft-web/references/svelte.md +61 -0
  296. package/skills/pixelcraft-web/references/tailwind.md +73 -0
  297. package/skills/pixelcraft-web/references/vue-nuxt.md +62 -0
@@ -0,0 +1,94 @@
1
+ # Theme presets: light, dark, and high contrast
2
+
3
+ A theme is a semantic reassignment, not a filter. Do not invert colors, flip luminance mechanically, or assume every hue keeps the same saturation/contrast across modes.
4
+
5
+ ## Required preset model
6
+
7
+ Maintain at minimum:
8
+
9
+ | Mode | Purpose |
10
+ |---|---|
11
+ | light | default high-luminance surface system |
12
+ | dark | low-luminance surface system with adjusted elevation/accent behavior |
13
+ | high-contrast | accessibility-oriented variant increasing foreground/background separation and non-color redundancy; may exist in light and dark forms |
14
+
15
+ High contrast is not merely “more saturated.” It often means fewer decorative colors, stronger borders/focus indication, simpler surfaces, larger contrast ratios, and explicit system-color behavior. Decide whether it is a product theme, accessibility mode, or platform-mediated behavior and expose that choice consistently.
16
+
17
+ ## Semantic dark-mode mapping
18
+
19
+ Map roles deliberately:
20
+
21
+ | Semantic role | Light behavior | Dark behavior |
22
+ |---|---|---|
23
+ | `surface.base` | near-white/neutral paper | deep neutral, not pure black by default |
24
+ | `surface.raised` | white/light elevation | slightly lighter than base; dark elevation uses luminance/layering because black shadows disappear |
25
+ | `surface.overlay` | elevated card/popover | progressively lighter plus border/edge separation |
26
+ | `ink.primary` | dark high-contrast text | light high-contrast text, softened only enough to reduce glare |
27
+ | `ink.muted` | lower contrast but readable | carefully adjusted; dark muted text fails quickly |
28
+ | `action.primary` | saturated brand/action color | often lighter/desaturated to maintain contrast and avoid vibrating against dark surfaces |
29
+ | `focus.ring` | visible against surface/action | hue/luminance adjusted per surface; never same hue assumption as light |
30
+ | `border.subtle` | low-key gray | use actual semantic border tokens; hairlines behave differently in dark |
31
+ | `shadow.*` | darker shadow opacity | often reduce shadow opacity/size and add surface luminance/border instead |
32
+
33
+ Pure black backgrounds can cause smearing/halation and remove elevation cues. Pure white text can glare. Use measured contrast and real rendering, not aesthetic slogans.
34
+
35
+ Desaturate or lighten accents in dark mode when saturation vibrates or contrast fails. Preserve hue identity and state distinctness; do not make success/warning/error indistinguishable.
36
+
37
+ ## `prefers-contrast` and forced colors
38
+
39
+ CSS contrast preference media features:
40
+
41
+ ```css
42
+ @media (prefers-contrast: more) { /* stronger semantic tokens */ }
43
+ @media (prefers-contrast: less) { /* only when product intentionally supports it */ }
44
+ @media (forced-colors: active) { /* do not fight platform colors */ }
45
+ ```
46
+
47
+ `prefers-contrast` values include `no-preference`, `more`, `less`, and `custom` in current CSS media-query work; support is browser-dependent. Forced Colors Mode/Windows High Contrast is stronger: the platform constrains colors. Use system colors such as `Canvas`, `CanvasText`, `ButtonText`, `ButtonFace`, `LinkText`, `Highlight`, and `HighlightText` deliberately. Do not remove outlines/backgrounds that the platform needs for meaning, and do not use box shadows/background-only cues that disappear in forced colors.
48
+
49
+ ## DTCG modes example
50
+
51
+ DTCG 2025.10 does not impose one universal mode-extension shape. Pixelcraft's zero-dependency exporter supports token-level overrides under `$extensions.pixelcraft.modes` as a controlled subset. A replacement can be a raw value or an object containing `$value`.
52
+
53
+ ```json
54
+ {
55
+ "color": {
56
+ "$type": "color",
57
+ "surface": {
58
+ "$value": { "colorSpace": "oklch", "components": [0.98, 0.005, 95], "alpha": 1 },
59
+ "$extensions": {
60
+ "pixelcraft": {
61
+ "modes": {
62
+ "dark": { "$value": { "colorSpace": "oklch", "components": [0.2, 0.01, 265], "alpha": 1 } },
63
+ "high-contrast": { "$value": { "colorSpace": "oklch", "components": [1, 0, 0], "alpha": 1 } }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ Use [../assets/tokens.modes.example.json](../assets/tokens.modes.example.json) for a fuller working file. Export a mode with:
73
+
74
+ ```sh
75
+ node scripts/export-tokens.mjs assets/tokens.modes.example.json --format css --mode dark
76
+ ```
77
+
78
+ Rules:
79
+
80
+ - default/base `$value` remains the light or baseline theme;
81
+ - a mode may override only tokens that differ; unspecified tokens inherit the base value;
82
+ - references inside mode replacements resolve against the same token graph;
83
+ - mode names are lowercase hyphenated product semantics (`dark`, `high-contrast`, `dim`, brand/context modes), not implementation selectors;
84
+ - generated artifacts are output; do not manually patch one mode in generated CSS/native files.
85
+
86
+ ## Validation matrix
87
+
88
+ - verify all required foreground/background pairings in every mode rather than isolated swatches;
89
+ - test hover/active/focus/selected/disabled/destructive/success/warning/info states;
90
+ - test elevation/order overlaps: base → raised → overlay → modal/popover;
91
+ - test charts/data visualization semantic palettes separately;
92
+ - inspect forced-colors and high-contrast rendering where the platform supports them;
93
+ - test transition/flash behavior at page load and theme switch;
94
+ - verify screenshots at real scale—contrast math does not capture glare, halation, antialiasing, or visual vibration.
@@ -0,0 +1,285 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ const formats = ['css', 'tailwind', 'swift', 'kotlin', 'dart', 'python', 'qt', 'textual'];
6
+
7
+ function help() {
8
+ return `Usage: node export-tokens.mjs <tokens.json> --format <${formats.join('|')}|all> [--mode NAME] [--out-dir DIR]
9
+
10
+ Zero-dependency exporter for the common DTCG 2025.10 subset used by Pixelcraft.
11
+ Without --out-dir, generated text is written to stdout. Advanced DTCG features
12
+ such as advanced tool-specific extensions should be handled by a dedicated compiler.
13
+ Pixelcraft token-level mode overrides use $extensions.pixelcraft.modes.`;
14
+ }
15
+
16
+ function camel(parts) {
17
+ return parts.map((p, i) => {
18
+ const clean = p.replace(/[^a-zA-Z0-9]+(.)/g, (_, c) => c.toUpperCase()).replace(/[^a-zA-Z0-9]/g, '');
19
+ return i === 0 ? clean : clean.charAt(0).toUpperCase() + clean.slice(1);
20
+ }).join('');
21
+ }
22
+ const kebab = (parts) => parts.join('-').replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase();
23
+
24
+ function flatten(node, parts = [], inheritedType = '', out = []) {
25
+ const type = node.$type || inheritedType;
26
+ for (const [key, value] of Object.entries(node)) {
27
+ if (key.startsWith('$') || typeof value !== 'object' || value === null || Array.isArray(value)) continue;
28
+ const next = [...parts, key];
29
+ if (Object.hasOwn(value, '$value')) out.push({ path: next, type: value.$type || type, token: value });
30
+ else flatten(value, next, type, out);
31
+ }
32
+ return out;
33
+ }
34
+
35
+ function gamma(v) {
36
+ return v <= 0.0031308 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
37
+ }
38
+ function oklchToRgb(L, C, H) {
39
+ const a = C * Math.cos(H * Math.PI / 180), b = C * Math.sin(H * Math.PI / 180);
40
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
41
+ const m = (L - 0.1055613458 * a - 0.0638541729 * b) ** 3;
42
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
43
+ return [
44
+ gamma(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
45
+ gamma(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
46
+ gamma(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s)
47
+ ].map((v) => Math.max(0, Math.min(1, v)));
48
+ }
49
+ function rgbHex(rgb, alpha = 1) {
50
+ const vals = [...rgb, alpha].map((v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).padStart(2, '0'));
51
+ return `#${vals.slice(0, 3).join('')}${alpha < 1 ? vals[3] : ''}`;
52
+ }
53
+ function alphaByte(alpha) {
54
+ return Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, '0');
55
+ }
56
+ function parseHexString(str) {
57
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(str.trim());
58
+ if (!m) return null;
59
+ let hex = m[1].toLowerCase();
60
+ if (hex.length === 3 || hex.length === 4) {
61
+ hex = hex.split('').map((ch) => ch + ch).join('');
62
+ }
63
+ const r = parseInt(hex.slice(0, 2), 16) / 255;
64
+ const g = parseInt(hex.slice(2, 4), 16) / 255;
65
+ const b = parseInt(hex.slice(4, 6), 16) / 255;
66
+ const alpha = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
67
+ return { rgb: [r, g, b], alpha, hex: `#${hex.slice(0, 6)}${hex.length === 8 ? hex.slice(6, 8) : ''}`, css: str.trim() };
68
+ }
69
+ function requireTypedColor(token, format) {
70
+ if (!token.value.rgb) {
71
+ throw new Error(
72
+ `color token '${token.path.join('.')}' uses non-hex string '${token.value.css}' which cannot be exported to ${format}; use #rrggbb/#rrggbbaa hex or a DTCG srgb/oklch color object`
73
+ );
74
+ }
75
+ return token.value;
76
+ }
77
+ function argbHex(color) {
78
+ return `${alphaByte(color.alpha ?? 1)}${color.hex.slice(1, 7)}`;
79
+ }
80
+ function fmtNumber(value) {
81
+ return Number.isInteger(value) ? String(value) : String(Number(value.toFixed(6)));
82
+ }
83
+ function durationMs(value) {
84
+ const amount = Number(value.value);
85
+ if (value.unit === 'ms') return amount;
86
+ if (value.unit === 's') return amount * 1000;
87
+ throw new Error(`unsupported duration unit '${value.unit}'`);
88
+ }
89
+
90
+ function colorParts(value) {
91
+ if (typeof value === 'string') {
92
+ const parsed = parseHexString(value);
93
+ if (parsed) return parsed;
94
+ return { hex: value, css: value, rgb: null, alpha: 1 };
95
+ }
96
+ const space = value.colorSpace;
97
+ const alpha = value.alpha ?? 1;
98
+ if (space === 'srgb') {
99
+ const rgb = value.components.map(Number);
100
+ return { rgb, alpha, hex: rgbHex(rgb, alpha), css: rgbHex(rgb, alpha) };
101
+ }
102
+ if (space === 'oklch') {
103
+ const [L, C] = value.components.map(Number);
104
+ const rawHue = value.components[2];
105
+ const H = rawHue === 'none' ? 0 : Number(rawHue);
106
+ const rgb = oklchToRgb(L, C, H);
107
+ return { rgb, alpha, hex: rgbHex(rgb, alpha), css: `oklch(${L} ${C} ${H}${alpha < 1 ? ` / ${alpha}` : ''})` };
108
+ }
109
+ throw new Error(`unsupported colorSpace '${space}'`);
110
+ }
111
+
112
+ function scalar(token, type) {
113
+ const v = token.$value;
114
+ if (type === 'color') return colorParts(v);
115
+ if (typeof v === 'object' && v !== null && 'value' in v && 'unit' in v) return `${v.value}${v.unit}`;
116
+ if (Array.isArray(v)) return v.join(', ');
117
+ if (typeof v === 'object') return JSON.stringify(v);
118
+ return String(v);
119
+ }
120
+
121
+ function applyMode(token, mode) {
122
+ if (!mode) return token;
123
+ const replacement = token.token.$extensions?.pixelcraft?.modes?.[mode];
124
+ if (replacement === undefined) return token;
125
+ const value = replacement && typeof replacement === 'object' && Object.hasOwn(replacement, '$value') ? replacement.$value : replacement;
126
+ return { ...token, token: { ...token.token, $value: value } };
127
+ }
128
+
129
+ function createResolver(tokens) {
130
+ const byPath = new Map(tokens.map((t) => [t.path.join('.'), t]));
131
+ const resolving = new Set();
132
+ return function resolve(t) {
133
+ const v = t.token.$value;
134
+ if (typeof v !== 'string' || !/^\{[^}]+\}$/.test(v)) return t;
135
+ const key = v.slice(1, -1);
136
+ if (resolving.has(key)) throw new Error(`reference cycle at ${key}`);
137
+ const target = byPath.get(key);
138
+ if (!target) throw new Error(`unresolved token reference {${key}}`);
139
+ resolving.add(key);
140
+ const resolved = resolve(target);
141
+ resolving.delete(key);
142
+ return { ...t, type: t.type || resolved.type, token: { ...t.token, $value: resolved.token.$value } };
143
+ };
144
+ }
145
+
146
+ function collect(file, mode) {
147
+ const data = JSON.parse(fs.readFileSync(file, 'utf8'));
148
+ const flattened = flatten(data);
149
+ const modes = new Set();
150
+ for (const token of flattened) {
151
+ for (const name of Object.keys(token.token.$extensions?.pixelcraft?.modes || {})) modes.add(name);
152
+ }
153
+ if (mode && !modes.has(mode)) throw new Error(`unknown --mode ${mode}`);
154
+ const resolveBase = createResolver(flattened);
155
+ const baseTokens = flattened.map((token) => resolveBase(token));
156
+ const tokens = flattened.map((token, index) => {
157
+ const typed = token.type ? token : { ...token, type: baseTokens[index].type };
158
+ return applyMode(typed, mode);
159
+ });
160
+ const resolveTokens = createResolver(tokens);
161
+ return tokens.map((token) => resolveTokens(token));
162
+ }
163
+
164
+ function entries(tokens) {
165
+ const list = tokens.map((t) => ({ ...t, name: camel(t.path), varName: kebab(t.path), value: scalar(t.token, t.type) }));
166
+ const seen = new Map();
167
+ for (const t of list) {
168
+ for (const [kind, identifier] of [['identifier', t.name], ['variable', t.varName]]) {
169
+ const key = `${kind}:${identifier}`;
170
+ const previous = seen.get(key);
171
+ const current = t.path.join('.');
172
+ if (previous) throw new Error(`token collision: '${previous}' and '${current}' both map to ${kind} '${identifier}'`);
173
+ seen.set(key, current);
174
+ }
175
+ }
176
+ return list;
177
+ }
178
+
179
+ function render(format, list) {
180
+ const colors = list.filter((t) => t.type === 'color');
181
+ if (format === 'css' || format === 'tailwind') {
182
+ const body = list.map((t) => ` --${t.varName}: ${typeof t.value === 'object' ? t.value.css : t.value};`).join('\n');
183
+ return format === 'css' ? `:root {\n${body}\n}\n` : `@theme {\n${body}\n}\n`;
184
+ }
185
+ if (format === 'swift') {
186
+ const lines = list.map((t) => {
187
+ if (t.type === 'color') {
188
+ const col = requireTypedColor(t, 'swift');
189
+ const [r, g, b] = col.rgb;
190
+ return ` public static let ${t.name} = Color(red: ${r.toFixed(4)}, green: ${g.toFixed(4)}, blue: ${b.toFixed(4)}, opacity: ${fmtNumber(col.alpha ?? 1)})`;
191
+ }
192
+ if (t.type === 'duration' && typeof t.token.$value === 'object') {
193
+ const ms = durationMs(t.token.$value);
194
+ return ` public static let ${t.name}: TimeInterval = ${fmtNumber(ms / 1000)} // seconds`;
195
+ }
196
+ if (typeof t.token.$value === 'object' && 'value' in (t.token.$value || {})) return ` public static let ${t.name}: Double = ${t.token.$value.value} // ${t.token.$value.unit}`;
197
+ return ` public static let ${t.name} = ${JSON.stringify(String(t.value))}`;
198
+ });
199
+ return `import Foundation\nimport SwiftUI\n\npublic enum PixelcraftTokens {\n${lines.join('\n')}\n}\n`;
200
+ }
201
+ if (format === 'kotlin') {
202
+ const hasDuration = list.some((t) => t.type === 'duration');
203
+ const lines = list.map((t) => {
204
+ if (t.type === 'color') return `val ${t.name} = Color(0x${argbHex(requireTypedColor(t, 'kotlin'))})`;
205
+ if (t.type === 'duration' && typeof t.token.$value === 'object') {
206
+ return `val ${t.name} = ${fmtNumber(durationMs(t.token.$value))}.milliseconds`;
207
+ }
208
+ if (typeof t.token.$value === 'object' && 'value' in (t.token.$value || {})) {
209
+ const unit = t.path.join('.').includes('font.size') ? 'sp' : 'dp';
210
+ return `val ${t.name} = ${t.token.$value.value}.${unit}`;
211
+ }
212
+ return `val ${t.name} = ${JSON.stringify(String(t.value))}`;
213
+ });
214
+ const durationImport = hasDuration ? 'import kotlin.time.Duration.Companion.milliseconds\n' : '';
215
+ return `import androidx.compose.ui.graphics.Color\nimport androidx.compose.ui.unit.dp\nimport androidx.compose.ui.unit.sp\n${durationImport}\n${lines.join('\n')}\n`;
216
+ }
217
+ if (format === 'dart') {
218
+ const lines = list.map((t) => {
219
+ if (t.type === 'color') return `static const Color ${t.name} = Color(0x${argbHex(requireTypedColor(t, 'dart'))});`;
220
+ if (t.type === 'duration' && typeof t.token.$value === 'object') {
221
+ const ms = durationMs(t.token.$value);
222
+ const constructor = Number.isInteger(ms) ? `Duration(milliseconds: ${fmtNumber(ms)})` : `Duration(microseconds: ${Math.round(ms * 1000)})`;
223
+ return `static const Duration ${t.name} = ${constructor};`;
224
+ }
225
+ if (typeof t.token.$value === 'object' && 'value' in (t.token.$value || {})) return `static const double ${t.name} = ${t.token.$value.value}; // ${t.token.$value.unit}`;
226
+ return `static const String ${t.name} = ${JSON.stringify(String(t.value))};`;
227
+ });
228
+ return `import 'dart:ui';\n\nclass PixelcraftTokens {\n ${lines.join('\n ')}\n}\n`;
229
+ }
230
+ if (format === 'python') {
231
+ const obj = {};
232
+ for (const t of list) obj[t.varName] = t.type === 'color' ? t.value.hex : String(t.value);
233
+ return `PIXELCRAFT_TOKENS = ${JSON.stringify(obj, null, 2)}\n`;
234
+ }
235
+ if (format === 'qt') {
236
+ const lines = list.map((t) => `@${t.varName}: ${t.type === 'color' ? t.value.hex : t.value};`);
237
+ return `/* QSS has no runtime variables. Treat this file as preprocessor input. */\n${lines.join('\n')}\n`;
238
+ }
239
+ if (format === 'textual') {
240
+ return list.map((t) => `$${t.varName}: ${t.type === 'color' ? t.value.hex : t.value};`).join('\n') + '\n';
241
+ }
242
+ throw new Error(`unknown format ${format}`);
243
+ }
244
+
245
+ try {
246
+ const args = process.argv.slice(2);
247
+ if (args.includes('--help') || args.includes('-h')) { console.log(help()); process.exit(0); }
248
+ const input = args.find((a) => !a.startsWith('-'));
249
+ if (!input) throw new Error('missing tokens.json input');
250
+ const valueOptions = ['--format', '--mode', '--out-dir'];
251
+ const knownOptions = new Set([...valueOptions, '--help', '-h']);
252
+ const getOpt = (name) => {
253
+ const i = args.indexOf(name);
254
+ if (i >= 0) {
255
+ const value = args[i + 1];
256
+ return value !== undefined && !knownOptions.has(value) ? value : '';
257
+ }
258
+ const inline = args.find((a) => a.startsWith(`${name}=`));
259
+ return inline?.slice(name.length + 1);
260
+ };
261
+ for (const name of valueOptions) {
262
+ const specified = args.includes(name) || args.some((a) => a.startsWith(`${name}=`));
263
+ if (specified && !getOpt(name)) throw new Error(`${name} requires a value`);
264
+ }
265
+ const format = getOpt('--format') || 'all';
266
+ if (![...formats, 'all'].includes(format)) throw new Error(`unknown --format ${format}`);
267
+ const selected = format === 'all' ? formats : [format];
268
+ const mode = getOpt('--mode');
269
+ const list = entries(collect(input, mode));
270
+ const outDir = getOpt('--out-dir');
271
+ if (outDir) {
272
+ fs.mkdirSync(outDir, { recursive: true });
273
+ for (const f of selected) {
274
+ const extensions = { css: 'css', tailwind: 'tailwind.css', swift: 'swift', kotlin: 'kt', dart: 'dart', python: 'py', qt: 'qt', textual: 'textual' };
275
+ const file = path.join(outDir, `tokens${mode ? `.${mode}` : ''}.${extensions[f]}`);
276
+ fs.writeFileSync(file, render(f, list));
277
+ console.log(`wrote ${file}`);
278
+ }
279
+ } else {
280
+ for (const f of selected) console.log(`/* ${f}${mode ? ` mode=${mode}` : ''} */\n${render(f, list)}`);
281
+ }
282
+ } catch (error) {
283
+ console.error(`export-tokens: ${error.message}`);
284
+ process.exit(1);
285
+ }
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: pixelcraft-tui
3
+ description: Translates Pixelcraft direction, tokens, UX, and floor requirements into terminal user interfaces across Textual, Rich, Ink, Bubble Tea/Lip Gloss, and Ratatui. Use for keyboard-first CLI apps, dashboards, installers, logs, forms, terminal layout, character-grid composition, color/unicode fallback, NO_COLOR behavior, resizing, snapshots, accessibility, and state feedback.
4
+ license: MIT
5
+ metadata:
6
+ version: 0.1.0
7
+ ---
8
+
9
+ # Pixelcraft TUI
10
+
11
+ Use this skill when the rendering surface is a terminal character grid. Terminal constraints are design constraints, not an excuse for unstructured text output.
12
+
13
+ ## Surface craft
14
+
15
+ Give repeated keyboard work stable regions: list or prompt, result, status and a short reversible help layer. Preserve task progress through terminal resize; keep a text marker when terminal colors or Unicode are limited. Check the smallest supported columns/rows after switching panes, with no mouse and in a low-capability terminal.
16
+
17
+ ## Detection signals
18
+
19
+ Python `textual`/`rich`, Node `ink`, Go `bubbletea`/`lipgloss`/`tcell`/`tview`, Rust `ratatui`/`crossterm`, alternate-screen/raw-mode setup, keybinding tables, snapshot tests, terminal capability handling.
20
+
21
+ ## Translate direction to terminal idioms
22
+
23
+ 1. Treat cells/rows/columns as the layout system. Establish alignment, scanlines, density, focus, and rhythm explicitly.
24
+ 2. Map tokens to semantic styles supported by the framework; do not assume truecolor, Unicode width, mouse support, or persistent screen size.
25
+ 3. Keyboard-first means every task has discoverable keys, focus/order, escape/cancel behavior, help, and no hidden mouse-only path.
26
+ 4. Use color as enhancement; meaning must survive 16-color, monochrome, low contrast, and `NO_COLOR` environments.
27
+ 5. Unicode box glyphs/braille/sparklines need fallback glyphs or graceful degradation because width/support varies.
28
+ 6. Design resize behavior: minimum dimensions, truncation/wrapping, pane priority, scrollback vs alternate screen, and terminal reflow.
29
+
30
+ ## Platform-wide rules
31
+
32
+ - Do not spam full-screen redraws/log output; preserve orientation and make current state visible.
33
+ - Interactive UI and machine-readable output are different modes. Provide noninteractive/plain output where automation matters.
34
+ - Respect stdout/stderr separation, tty detection, piped output, terminal width, locale encoding, and CI constraints.
35
+ - Never require color, emoji, mouse, hyperlinks, or exact terminal emulator features unless detected or explicitly documented.
36
+ - Progress is truthful and cancellable; keyboard interrupt handling is part of UX.
37
+ - Terminal accessibility is limited and emulator-dependent: avoid color-only state, rapid flashing, cursor traps, and unreadable dense glyph art.
38
+
39
+ ## Common TUI failures
40
+
41
+ - decorative ASCII art consuming the only useful viewport;
42
+ - emoji/unicode width corruption in CJK or narrow terminals;
43
+ - color-only diffs/status;
44
+ - keybindings conflicting with shell/readline/IME expectations;
45
+ - panes disappearing at 80×24 or smaller;
46
+ - no noninteractive fallback in CI/pipes;
47
+ - focus invisible or state lost after resize;
48
+ - full-screen alternate buffer used for simple one-shot output.
49
+
50
+ ## Verification options
51
+
52
+ TUI rendering can be inspected with actual terminal runs, framework test backends, snapshot tests, width/height fixtures, piped-output tests, NO_COLOR/TERM/color-term matrices, and keyboard-driven integration tests. Textual supports SVG snapshot tests through `pytest-textual-snapshot`; Ratatui supports `TestBackend` and insta-style snapshot testing. Passing a unit test without a buffer/snapshot is not visual evidence.
53
+
54
+ ## Framework routing
55
+
56
+ - Read [references/textual.md](references/textual.md) for Textual apps/widgets/CSS.
57
+ - Read [references/rich.md](references/rich.md) for Rich output, live display, logging, and prompt-adjacent use.
58
+ - Read [references/ink.md](references/ink.md) for Ink/React terminal UI.
59
+ - Read [references/bubbletea-lipgloss.md](references/bubbletea-lipgloss.md) for Bubble Tea/Lip Gloss Go TUI.
60
+ - Read [references/ratatui.md](references/ratatui.md) for Rust Ratatui.
@@ -0,0 +1,60 @@
1
+ # Bubble Tea + Lip Gloss (Go)
2
+
3
+ ## Token mapping
4
+
5
+ Define semantic Lip Gloss styles centrally:
6
+
7
+ ```go
8
+ var actionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#0074ca"))
9
+ ```
10
+
11
+ Use semantic variables (`actionStyle`, `errorStyle`) rather than raw color/style literals scattered through model/view code. Color profile detection should influence output; do not assume truecolor.
12
+
13
+ ## Layout and responsive idioms
14
+
15
+ Use width/height messages to recompute layout, Lip Gloss join/place/align helpers deliberately, truncation/wrapping libraries/helpers carefully, and define minimum terminal dimensions. Keep scanlines/alignment stable across updates. Alternate screen vs inline output is an intentional choice.
16
+
17
+ ## Typography/custom fonts
18
+
19
+ Terminals control fonts. Use bold/faint/italic/underline/reverse/color and spacing. Unicode width and emoji/CJK behavior need width-aware libraries/fallbacks. Do not center everything by naive string length because printable width differs.
20
+
21
+ ## Motion/reduced motion
22
+
23
+ Use ticks/spinner/progress truthfully. Avoid high-frequency redraw loops. Provide quiet/no-color/noninteractive modes and cancel timers/ticks correctly. Reduced-motion support is terminal-limited; do not depend on motion for meaning.
24
+
25
+ ## Accessibility specifics
26
+
27
+ Keyboard-first key map, visible cursor/selection/focus, escape/cancel/back semantics, plaintext state markers, no color-only meaning, stdout/stderr separation, screen-reader-readable output where possible, and no hidden mouse-only functionality.
28
+
29
+ ## States idiom
30
+
31
+ Bubble Tea model-update-view architecture makes state explicit—use it. Represent loading/error/empty/offline/permission/cancelled/concurrent operations in the model. Commands need cancellation/timeout/error messages; avoid duplicate commands on repeated keys. Preserve input in model state across resize/navigation.
32
+
33
+ ## Forms idiom
34
+
35
+ Use textinput/textarea/list/help/bubbles-style components or explicit model state with labels/instructions, validation timing, cursor/paste behavior verification, error copy, back/cancel semantics, and noninteractive flags.
36
+
37
+ ## Do/don't pairs
38
+
39
+ | Do | Don't |
40
+ |---|---|
41
+ | centralized semantic styles | raw ANSI/color literals throughout views |
42
+ | update layout on `tea.WindowSizeMsg` | fixed width captured once at startup |
43
+ | explicit model state machine | boolean soup and duplicated async commands |
44
+ | plain marker + color for selection | color-only invisible selection |
45
+ | cancel/timeout command ownership | goroutine/cmd results mutating stale state |
46
+
47
+ ## Known traps
48
+
49
+ Unicode width miscalculation, unbounded redraw frequency, stale async command results, terminal color profile differences, focus/key conflicts, resize truncation, alternate-screen misuse, scrollback behavior, hidden noninteractive incompatibility.
50
+
51
+ ## Verification commands
52
+
53
+ ```sh
54
+ go test ./...
55
+ go vet ./...
56
+ go run ./cmd/app --help
57
+ NO_COLOR=1 go run ./cmd/app 2>/dev/null || true
58
+ ```
59
+
60
+ Use actual terminal runs, golden output/snapshot tests where configured, narrow/wide matrices, piped/non-TTY behavior, keyboard-driven tests, interrupt/cancel paths, and color-capability matrices.
@@ -0,0 +1,60 @@
1
+ # Ink (React for CLI)
2
+
3
+ ## Token mapping
4
+
5
+ Define semantic constants in a theme module/context and map them to Ink color props/style behavior:
6
+
7
+ ```tsx
8
+ export const theme = { action: '#0074ca', error: 'red' };
9
+ ```
10
+
11
+ Do not scatter chalk-style color literals through components. Terminal themes/capabilities vary, so semantic names must degrade gracefully.
12
+
13
+ ## Layout and responsive idioms
14
+
15
+ Ink uses Yoga-like flexbox in terminal cells. Use flex direction/width/margin/padding deliberately, measure terminal columns/rows, define truncation/wrapping/minimum size behavior, and avoid browser layout assumptions. Static vs interactive output should be separated intentionally.
16
+
17
+ ## Typography/custom fonts
18
+
19
+ Terminals control fonts. Use color/bold/dim/underline/inverse and spacing. Do not assume emoji/Unicode width consistency. Use plaintext fallbacks for symbols.
20
+
21
+ ## Motion/reduced motion
22
+
23
+ Use spinners/progress truthfully and avoid rapid render loops. Offer noninteractive/quiet mode in CI/piped contexts. Reduced-motion support is terminal-limited; avoid flashing/continuous animation by default.
24
+
25
+ ## Accessibility specifics
26
+
27
+ Keyboard input handling/focus semantics are application responsibility. Visible selection/focus, logical key order, escape/cancel, no color-only state, plaintext alternatives, stdout/stderr separation, and screen-reader-friendly linear output matter. Mouse support cannot be assumed.
28
+
29
+ ## States idiom
30
+
31
+ Use explicit React state/reducer state machines for loading/error/empty/offline/permission/optimistic/cancelled states. Async effects need cancellation/cleanup. Ctrl+C/EOF/interrupt behavior must be designed. Preserve input across step navigation/resize/render.
32
+
33
+ ## Forms idiom
34
+
35
+ Use text input components/hooks with labels/instructions, validation timing, paste behavior, cursor visibility, key conflict awareness, error copy, and input preservation. Multi-step CLI forms need back/cancel semantics and noninteractive equivalents.
36
+
37
+ ## Do/don't pairs
38
+
39
+ | Do | Don't |
40
+ |---|---|
41
+ | central semantic theme constants | hard-coded color props in every component |
42
+ | visible selected/focused row style plus text marker | color-only invisible focus |
43
+ | cleanup async effect/cancel operation | state update after unmount/interrupt |
44
+ | explicit noninteractive flags for automation | requiring full-screen input inside CI |
45
+ | width-aware truncation/wrapping | overwriting terminal output unpredictably |
46
+
47
+ ## Known traps
48
+
49
+ React effect lifecycle leaks, render-loop flicker, input key conflicts, Unicode width mismatch, terminal resize behavior, hidden state loss on rerender, stdout/stderr misuse, assuming TTY in automation, ANSI/INK version behavior differences.
50
+
51
+ ## Verification commands
52
+
53
+ ```sh
54
+ npm run lint
55
+ npm run test -- --run
56
+ node dist/cli.js --help
57
+ CI=1 node dist/cli.js 2>/dev/null || true
58
+ ```
59
+
60
+ Use actual terminal runs at multiple widths, keyboard-driven integration tests, ink-testing-library-style tests where configured, piped/non-TTY checks, NO_COLOR/TERM matrices, and interrupt-path testing.
@@ -0,0 +1,62 @@
1
+ # Ratatui
2
+
3
+ Evidence: Ratatui docs describe `TestBackend::new(width, height)` for integration testing and official recipes use `insta` snapshots of terminal output.
4
+
5
+ ## Token mapping
6
+
7
+ Define semantic `Style`/`Color` constants or theme structs centrally:
8
+
9
+ ```rust
10
+ pub struct PcTheme { pub action: Color, pub error: Color }
11
+ ```
12
+
13
+ Use semantic fields rather than raw colors in widgets. Respect terminal color capability; do not assume truecolor. Ratatui itself does not impose a token pipeline—ownership is yours.
14
+
15
+ ## Layout and responsive idioms
16
+
17
+ Use `Layout` constraints/direction/margins/splitting deliberately. Compute layout from current terminal area each frame; handle resize/minimum size/truncation/wrap/scroll state. Character-cell alignment, scanlines, density, and pane priority are explicit design decisions.
18
+
19
+ ## Typography/custom fonts
20
+
21
+ Terminals control fonts. Use modifier flags (`BOLD`, `DIM`, `UNDERLINED`, `REVERSED`) and semantic color/sparse symbols. Unicode width requires width-aware handling; CJK/emoji/box glyphs may not occupy the width you expect.
22
+
23
+ ## Motion/reduced motion
24
+
25
+ Animation is manual frame/tick state. Keep redraw frequency bounded and purposeful. Provide quiet/reduced-motion flags where relevant; terminal platforms lack a uniform hook. Do not flash or continuously repaint decorative noise.
26
+
27
+ ## Accessibility specifics
28
+
29
+ Keyboard-first input/event model, visible focus/selection, plain text state equivalents, no color-only meaning, Unicode/NO_COLOR fallback, cursor visibility/position control, escape/cancel behavior, and careful alternate-screen vs scrollback choice. Screen-reader behavior varies and must not be overstated.
30
+
31
+ ## States idiom
32
+
33
+ Use explicit application state/event ownership. Async/backend work requires channels/tasks with cancellation/timeout/stale-result handling. Render loading/error/empty/offline/permission/concurrency states into buffers rather than leaving blank panes. Preserve input/focus/scroll in app state across resize.
34
+
35
+ ## Forms idiom
36
+
37
+ Implement or reuse input widgets deliberately: cursor/selection/IME constraints are hard. Validate input timing, preserve values, expose errors textually, support paste/editing keys realistically, and provide noninteractive flags where automation matters.
38
+
39
+ ## Do/don't pairs
40
+
41
+ | Do | Don't |
42
+ |---|---|
43
+ | central semantic theme struct | raw `Color::Rgb` scattered through widgets |
44
+ | derive layout each frame from terminal area | fixed 120×40 assumptions |
45
+ | explicit async stale/cancel handling | backend result overwriting newer user state |
46
+ | text marker plus style for selection | color-only selection invisible/monochrome |
47
+ | `TestBackend`/buffer tests for critical views | visual QA only by occasional manual run |
48
+
49
+ ## Known traps
50
+
51
+ Unicode width errors, terminal capability mismatch, high-frequency event/render loops, stale async responses, panic leaving terminal in raw/alternate mode, scrollback/alt-screen misuse, focus/input ownership complexity, incomplete custom text editing/IME behavior.
52
+
53
+ ## Verification commands
54
+
55
+ ```sh
56
+ cargo test
57
+ cargo insta review 2>/dev/null || true
58
+ cargo clippy -- -D warnings 2>/dev/null || true
59
+ cargo run
60
+ ```
61
+
62
+ Use `TestBackend`/`insta` snapshots, actual terminal runs at multiple sizes, panic/cleanup behavior, piped/non-TTY modes where relevant, keyboard-driven tests, NO_COLOR/color matrices, and interrupt/cancellation checks.