@litfamily/litcodex 1.0.29 → 1.0.31

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 (388) hide show
  1. package/README-Ko-KR.md +11 -11
  2. package/README.md +11 -11
  3. package/dist/install/generated-skill-payload-hashes.d.ts +191 -85
  4. package/dist/install/generated-skill-payload-hashes.js +191 -85
  5. package/dist/install/marketplace.js +10 -1
  6. package/dist/install/skill-catalog.d.ts +1 -1
  7. package/dist/install/skill-catalog.js +12 -1
  8. package/dist/install/skill-resource-hashes.d.ts +1 -1
  9. package/dist/install/skill-resource-hashes.js +1 -1
  10. package/marketplace/.agents/plugins/marketplace.json +4 -1
  11. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +14 -2
  12. package/marketplace/plugins/litcodex/assets/screenshot-lit-ignited.png +0 -0
  13. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  14. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  15. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  16. package/marketplace/plugins/litcodex/components/lit-loop/directive.md +10 -4
  17. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-adhd.md +191 -0
  18. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-handoff.md +2 -0
  19. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-hijack.md +219 -0
  20. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-recap.md +2 -0
  21. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-schematic.md +199 -0
  22. package/marketplace/plugins/litcodex/components/lit-loop/directives/litwork.md +2 -1
  23. package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.d.ts +10 -0
  24. package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.js +67 -0
  25. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.d.ts +1 -1
  26. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.js +128 -8
  27. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.d.ts +19 -0
  28. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.js +58 -0
  29. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +27 -0
  30. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +94 -7
  31. package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +13 -3
  32. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +2 -0
  33. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +8 -9
  34. package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.d.ts +5 -0
  35. package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.js +23 -0
  36. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +8 -0
  37. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +118 -11
  38. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.d.ts +1 -1
  39. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.js +29 -13
  40. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.d.ts +13 -0
  41. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.js +85 -0
  42. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.d.ts +55 -0
  43. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.js +227 -0
  44. package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.d.ts +5 -1
  45. package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.js +17 -1
  46. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +6 -0
  47. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +6 -0
  48. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
  49. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +25 -1
  50. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.d.ts +79 -0
  51. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.js +310 -0
  52. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +5 -1
  53. package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +10 -0
  54. package/marketplace/plugins/litcodex/components/lit-loop/dist/redaction.js +18 -0
  55. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +15 -0
  56. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +46 -9
  57. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.d.ts +10 -0
  58. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.js +88 -0
  59. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.d.ts +20 -0
  60. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.js +84 -0
  61. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.d.ts +6 -0
  62. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.js +41 -0
  63. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.d.ts +3 -0
  64. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.js +40 -0
  65. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.d.ts +48 -0
  66. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.js +292 -0
  67. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.d.ts +162 -0
  68. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.js +773 -0
  69. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +44 -2
  70. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.js +1 -0
  71. package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.d.ts +6 -0
  72. package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.js +35 -0
  73. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.d.ts +3 -0
  74. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.js +15 -5
  75. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +6 -0
  76. package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.d.ts +8 -0
  77. package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.js +57 -0
  78. package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.js +8 -3
  79. package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.d.ts +50 -0
  80. package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.js +178 -0
  81. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +1 -1
  82. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +31 -6
  83. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +10 -0
  84. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +11 -1
  85. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.d.ts +132 -0
  86. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.js +488 -0
  87. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  88. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  89. package/marketplace/plugins/litcodex/components/rules/node_modules/picomatch/README.md +15 -21
  90. package/marketplace/plugins/litcodex/components/rules/node_modules/picomatch/lib/parse.js +49 -10
  91. package/marketplace/plugins/litcodex/components/rules/node_modules/picomatch/lib/picomatch.js +14 -2
  92. package/marketplace/plugins/litcodex/components/rules/node_modules/picomatch/lib/scan.js +30 -18
  93. package/marketplace/plugins/litcodex/components/rules/node_modules/picomatch/package.json +3 -2
  94. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  95. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.d.ts +6 -0
  96. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.js +65 -0
  97. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  98. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  99. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  100. package/marketplace/plugins/litcodex/hooks/hooks.json +24 -0
  101. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +6 -0
  102. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/components.css +414 -0
  103. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/fonts.json +22 -0
  104. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
  105. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
  106. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
  107. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
  108. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
  109. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
  110. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
  111. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
  112. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/ui.js +228 -0
  113. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/brand-and-imagery.md +1 -1
  114. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/complete-contract.md +1 -0
  115. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/craft-floor.md +2 -2
  116. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/default-editorial-pixel.json +15 -8
  117. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/design-choice.md +19 -0
  118. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/house-styles.md +235 -0
  119. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/motion-guide.md +2 -2
  120. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/probe-and-review.md +6 -0
  121. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/production-interview.md +2 -0
  122. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/slop-register.md +4 -4
  123. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
  124. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/lock-probe.mjs +196 -0
  125. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/page-probe.mjs +22 -4
  126. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
  127. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/probe.mjs +59 -13
  128. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/rule-data.mjs +38 -4
  129. package/marketplace/plugins/litcodex/skills/lit-adhd/SKILL.md +181 -0
  130. package/marketplace/plugins/litcodex/skills/lit-adhd/agents/openai.yaml +6 -0
  131. package/marketplace/plugins/litcodex/skills/lit-adhd/references/card-examples.md +147 -0
  132. package/marketplace/plugins/litcodex/skills/lit-adhd/references/status-taxonomy.md +37 -0
  133. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/SKILL.md +18 -7
  134. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/style-guide.md +20 -11
  135. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
  136. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
  137. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-swimlane.md +1 -1
  138. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree-block-decomposition.md +1 -1
  139. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree.md +3 -3
  140. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
  141. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/verifier-guide.md +1 -0
  142. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
  143. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
  144. package/marketplace/plugins/litcodex/skills/lit-docx/SKILL.md +12 -3
  145. package/marketplace/plugins/litcodex/skills/lit-docx/references/direction-step.md +6 -3
  146. package/marketplace/plugins/litcodex/skills/lit-hijack/SKILL.md +449 -0
  147. package/marketplace/plugins/litcodex/skills/lit-hijack/agents/openai.yaml +6 -0
  148. package/marketplace/plugins/litcodex/skills/lit-hijack/references/capture-and-provenance.md +100 -0
  149. package/marketplace/plugins/litcodex/skills/lit-hijack/references/clean-room-build.md +111 -0
  150. package/marketplace/plugins/litcodex/skills/lit-hijack/references/distil-and-licence.md +102 -0
  151. package/marketplace/plugins/litcodex/skills/lit-hijack/references/gap-and-port-design.md +125 -0
  152. package/marketplace/plugins/litcodex/skills/lit-hijack/references/parity-and-report.md +108 -0
  153. package/marketplace/plugins/litcodex/skills/lit-hijack/scripts/hijack.mjs +1050 -0
  154. package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +13 -4
  155. package/marketplace/plugins/litcodex/skills/lit-plan/SKILL.md +6 -0
  156. package/marketplace/plugins/litcodex/skills/lit-pptx/NOTICE +1 -0
  157. package/marketplace/plugins/litcodex/skills/lit-pptx/SKILL.md +35 -8
  158. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  159. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  160. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
  161. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/SOURCE.md +21 -0
  162. package/marketplace/plugins/litcodex/skills/lit-pptx/references/anti-slop-checklist.md +5 -2
  163. package/marketplace/plugins/litcodex/skills/lit-pptx/references/authoring-guide.md +3 -4
  164. package/marketplace/plugins/litcodex/skills/lit-pptx/references/density-and-fill.md +20 -6
  165. package/marketplace/plugins/litcodex/skills/lit-pptx/references/direction-step.md +26 -8
  166. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/14-engineering-review-computational-brutalism-ko.md +173 -0
  167. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/15-launch-pitch-neo-brutalism-ko.md +154 -0
  168. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/16-design-lecture-bauhaus-ko.md +139 -0
  169. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/17-community-programme-riso-ko.md +158 -0
  170. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/18-public-data-briefing-newsroom-ko.md +179 -0
  171. package/marketplace/plugins/litcodex/skills/lit-pptx/references/layout-families.md +42 -27
  172. package/marketplace/plugins/litcodex/skills/lit-pptx/references/title-treatments.md +31 -27
  173. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/bauhaus.md +136 -0
  174. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/chalk.md +1 -1
  175. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/computational-brutalism.md +145 -0
  176. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/neo-brutalism.md +155 -0
  177. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/newsroom.md +141 -0
  178. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/riso.md +133 -0
  179. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/signal.md +1 -1
  180. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/studio.md +1 -1
  181. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/compile-deck.js +1 -1
  182. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/craft_extras.py +136 -94
  183. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/embed_fonts.py +13 -1
  184. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
  185. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
  186. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/render-pack.js +386 -579
  187. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
  188. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
  189. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +2 -1
  190. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/qa_deck.py +7 -13
  191. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/render_pages.py +124 -0
  192. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
  193. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
  194. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
  195. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +100 -0
  196. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
  197. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
  198. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
  199. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
  200. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
  201. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
  202. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
  203. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
  204. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
  205. package/marketplace/plugins/litcodex/skills/lit-recap/SKILL.md +2 -0
  206. package/marketplace/plugins/litcodex/skills/lit-schematic/SKILL.md +198 -0
  207. package/marketplace/plugins/litcodex/skills/lit-schematic/agents/openai.yaml +6 -0
  208. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
  209. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
  210. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
  211. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
  212. package/marketplace/plugins/litcodex/skills/lit-schematic/references/cutaway-outputs.md +70 -0
  213. package/marketplace/plugins/litcodex/skills/lit-schematic/references/isometric-craft.md +101 -0
  214. package/marketplace/plugins/litcodex/skills/lit-schematic/references/journal-figures.md +72 -0
  215. package/marketplace/plugins/litcodex/skills/lit-schematic/references/kit-api.md +134 -0
  216. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pfd-and-layout.md +53 -0
  217. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-drafting.md +103 -0
  218. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-symbols.md +163 -0
  219. package/marketplace/plugins/litcodex/skills/lit-schematic/references/verification.md +100 -0
  220. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/doctor.mjs +57 -0
  221. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
  222. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/fonts.mjs +28 -0
  223. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
  224. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
  225. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
  226. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
  227. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
  228. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
  229. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/png.mjs +132 -0
  230. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
  231. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/route.mjs +218 -0
  232. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
  233. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
  234. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
  235. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/motion.mjs +129 -0
  236. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/qa.mjs +92 -0
  237. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/render.mjs +233 -0
  238. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/scaffold.mjs +60 -0
  239. package/marketplace/plugins/litcodex/skills/lit-scientific-visualization/SKILL.md +34 -8
  240. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +18 -14
  241. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +12 -0
  242. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/assets.mjs +388 -0
  243. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender/runner.py +221 -0
  244. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender.mjs +132 -0
  245. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/board.mjs +142 -0
  246. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +6 -0
  247. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +7 -4
  248. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +8 -7
  249. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +14 -2
  250. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +38 -3
  251. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +19 -4
  252. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +8 -8
  253. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/gallery.mjs +147 -0
  254. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/house.mjs +45 -0
  255. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/image.mjs +89 -0
  256. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +58 -25
  257. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +59 -14
  258. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/safe-read.mjs +32 -0
  259. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/scaffold.mjs +208 -0
  260. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/score.mjs +668 -0
  261. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/sound.mjs +174 -31
  262. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-gate.mjs +45 -3
  263. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-kit.js +99 -1
  264. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.js +8 -1
  265. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.mjs +180 -11
  266. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-render.mjs +42 -12
  267. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-worker.mjs +7 -4
  268. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +96 -10
  269. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/styles.mjs +233 -0
  270. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +291 -14
  271. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
  272. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
  273. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
  274. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
  275. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/expected.json +33 -0
  276. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
  277. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +44 -7
  278. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/depth.md +156 -0
  279. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/design-choice.md +22 -0
  280. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +29 -7
  281. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +1 -1
  282. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/sound.md +87 -0
  283. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +19 -7
  284. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/studio.md +246 -0
  285. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/style-bibles.md +2 -2
  286. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +41 -21
  287. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/runtime/requirements-audio.txt +3 -3
  288. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +51 -4
  289. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/paper.json +185 -0
  290. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/swiss-signal.json +188 -0
  291. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/terminalcore.json +182 -0
  292. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/tidal.json +187 -0
  293. package/marketplace/plugins/litcodex/skills/litresearch/SKILL.md +7 -0
  294. package/marketplace/plugins/litcodex/skills/litwork/SKILL.md +2 -1
  295. package/marketplace/plugins/litcodex/skills/lsp-setup/SKILL.md +2 -1
  296. package/marketplace/plugins/litcodex/skills/readme-studio/SKILL.md +10 -0
  297. package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/package-lock.json +3 -3
  298. package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
  299. package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +7 -1
  300. package/marketplace/plugins/litcodex/skills/start-work/SKILL.md +10 -0
  301. package/node_modules/@litcodex/lit-loop/directive.md +10 -4
  302. package/node_modules/@litcodex/lit-loop/directives/lit-adhd.md +191 -0
  303. package/node_modules/@litcodex/lit-loop/directives/lit-handoff.md +2 -0
  304. package/node_modules/@litcodex/lit-loop/directives/lit-hijack.md +219 -0
  305. package/node_modules/@litcodex/lit-loop/directives/lit-recap.md +2 -0
  306. package/node_modules/@litcodex/lit-loop/directives/lit-schematic.md +199 -0
  307. package/node_modules/@litcodex/lit-loop/directives/litwork.md +2 -1
  308. package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.d.ts +10 -0
  309. package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.js +67 -0
  310. package/node_modules/@litcodex/lit-loop/dist/card-html.d.ts +1 -1
  311. package/node_modules/@litcodex/lit-loop/dist/card-html.js +128 -8
  312. package/node_modules/@litcodex/lit-loop/dist/card-looks.d.ts +19 -0
  313. package/node_modules/@litcodex/lit-loop/dist/card-looks.js +58 -0
  314. package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +27 -0
  315. package/node_modules/@litcodex/lit-loop/dist/card-status.js +94 -7
  316. package/node_modules/@litcodex/lit-loop/dist/cli.js +13 -3
  317. package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +2 -0
  318. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +8 -9
  319. package/node_modules/@litcodex/lit-loop/dist/control-chars.d.ts +5 -0
  320. package/node_modules/@litcodex/lit-loop/dist/control-chars.js +23 -0
  321. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +8 -0
  322. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +118 -11
  323. package/node_modules/@litcodex/lit-loop/dist/hud.d.ts +1 -1
  324. package/node_modules/@litcodex/lit-loop/dist/hud.js +29 -13
  325. package/node_modules/@litcodex/lit-loop/dist/lane-events.d.ts +13 -0
  326. package/node_modules/@litcodex/lit-loop/dist/lane-events.js +85 -0
  327. package/node_modules/@litcodex/lit-loop/dist/lane-state.d.ts +55 -0
  328. package/node_modules/@litcodex/lit-loop/dist/lane-state.js +227 -0
  329. package/node_modules/@litcodex/lit-loop/dist/live-step.d.ts +5 -1
  330. package/node_modules/@litcodex/lit-loop/dist/live-step.js +17 -1
  331. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +6 -0
  332. package/node_modules/@litcodex/lit-loop/dist/markers.js +6 -0
  333. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
  334. package/node_modules/@litcodex/lit-loop/dist/modes.js +25 -1
  335. package/node_modules/@litcodex/lit-loop/dist/motion-gate.d.ts +79 -0
  336. package/node_modules/@litcodex/lit-loop/dist/motion-gate.js +310 -0
  337. package/node_modules/@litcodex/lit-loop/dist/motion-route.js +5 -1
  338. package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +10 -0
  339. package/node_modules/@litcodex/lit-loop/dist/redaction.js +18 -0
  340. package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +15 -0
  341. package/node_modules/@litcodex/lit-loop/dist/reentry.js +46 -9
  342. package/node_modules/@litcodex/lit-loop/dist/rewind-cli.d.ts +10 -0
  343. package/node_modules/@litcodex/lit-loop/dist/rewind-cli.js +88 -0
  344. package/node_modules/@litcodex/lit-loop/dist/rewind-go.d.ts +20 -0
  345. package/node_modules/@litcodex/lit-loop/dist/rewind-go.js +84 -0
  346. package/node_modules/@litcodex/lit-loop/dist/rewind-look.d.ts +6 -0
  347. package/node_modules/@litcodex/lit-loop/dist/rewind-look.js +41 -0
  348. package/node_modules/@litcodex/lit-loop/dist/rewind-redact.d.ts +3 -0
  349. package/node_modules/@litcodex/lit-loop/dist/rewind-redact.js +40 -0
  350. package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.d.ts +48 -0
  351. package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.js +292 -0
  352. package/node_modules/@litcodex/lit-loop/dist/rewind.d.ts +162 -0
  353. package/node_modules/@litcodex/lit-loop/dist/rewind.js +773 -0
  354. package/node_modules/@litcodex/lit-loop/dist/route-heads.js +44 -2
  355. package/node_modules/@litcodex/lit-loop/dist/run-panel.js +1 -0
  356. package/node_modules/@litcodex/lit-loop/dist/schematic-route.d.ts +6 -0
  357. package/node_modules/@litcodex/lit-loop/dist/schematic-route.js +35 -0
  358. package/node_modules/@litcodex/lit-loop/dist/screen-card.d.ts +3 -0
  359. package/node_modules/@litcodex/lit-loop/dist/screen-card.js +15 -5
  360. package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +6 -0
  361. package/node_modules/@litcodex/lit-loop/dist/stack-hook.d.ts +8 -0
  362. package/node_modules/@litcodex/lit-loop/dist/stack-hook.js +57 -0
  363. package/node_modules/@litcodex/lit-loop/dist/statusline.js +8 -3
  364. package/node_modules/@litcodex/lit-loop/dist/threads.d.ts +50 -0
  365. package/node_modules/@litcodex/lit-loop/dist/threads.js +178 -0
  366. package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +1 -1
  367. package/node_modules/@litcodex/lit-loop/dist/trigger.js +31 -6
  368. package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +10 -0
  369. package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +11 -1
  370. package/node_modules/@litcodex/lit-loop/dist/workflow-stack.d.ts +132 -0
  371. package/node_modules/@litcodex/lit-loop/dist/workflow-stack.js +488 -0
  372. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  373. package/node_modules/@litcodex/lit-loop/skills/lit-adhd/SKILL.md +181 -0
  374. package/node_modules/@litcodex/lit-loop/skills/lit-hijack/SKILL.md +449 -0
  375. package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +13 -4
  376. package/node_modules/@litcodex/lit-loop/skills/lit-plan/SKILL.md +6 -0
  377. package/node_modules/@litcodex/lit-loop/skills/lit-recap/SKILL.md +2 -0
  378. package/node_modules/@litcodex/lit-loop/skills/lit-schematic/SKILL.md +198 -0
  379. package/node_modules/@litcodex/lit-loop/skills/lit-scientific-visualization/SKILL.md +34 -8
  380. package/node_modules/@litcodex/lit-loop/skills/litresearch/SKILL.md +7 -0
  381. package/node_modules/@litcodex/lit-loop/skills/litwork/SKILL.md +2 -1
  382. package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +7 -1
  383. package/node_modules/@litcodex/lit-loop/skills/start-work/SKILL.md +10 -0
  384. package/package.json +2 -2
  385. package/readme-assets/badge-version.svg +1 -1
  386. package/readme-assets/skills/lit-adhd.webp +0 -0
  387. package/readme-assets/skills/lit-hijack.webp +0 -0
  388. package/readme-assets/skills/lit-schematic.webp +0 -0
@@ -19,13 +19,13 @@ Read this with the craft floor in every frontend mode. The register identifies r
19
19
  | Id | Signal, gate, and repair |
20
20
  | --- | --- |
21
21
  | SLOP-008 | A heading or gradient stop in HSL 260°–310° with ≥50/255 RGB channel spread can be a reflex violet accent. Exempt a documented brand hue. MEDIUM, DET assist. |
22
- | SLOP-009 | Gradient fill and text clipping on one headline make decorative gradient type. Use a solid accessible ink color. MEDIUM, DET. |
23
- | SLOP-010 | A wide chromatic glow recurs on primary actions/headings outside focus. Remove the repeated halo. MEDIUM when recurring, DET. |
22
+ | SLOP-009 | Gradient fill with text clipping is decorative type only when a stop is violet, the treatment repeats, or a stop falls below 4.5:1 (3:1 for large text). One legible, on-palette gradient word is allowed. MEDIUM, DET. |
23
+ | SLOP-010 | A wide chromatic glow recurs on three or more primary actions/headings outside focus. Remove the repeated halo. MEDIUM when recurring, DET. |
24
24
  | SLOP-011 | An unanchored translucent radial blob has no information role. Check its purpose, then delete or integrate it. MEDIUM, JUDG. |
25
25
  | SLOP-012 | A repeated dot/grid ground with no adjacent data and another slop cue is decoration by reflex. Remove it or make its data referent explicit. MEDIUM, DET assist. |
26
26
  | SLOP-013 | Hide a noise texture in review; if hierarchy improves, remove the texture. LOW, JUDG. |
27
27
  | SLOP-014 | Glass blur needs a surface reason and a transparency fallback. Use an opaque surface when neither exists. LOW, JUDG. |
28
- | SLOP-015 | A single-side accent, inset strip, or geometric pseudo-element tab recurs on rounded cards. Delete decorative stripes; preserve alert/status and real nav tabs. MEDIUM, DET. |
28
+ | SLOP-015 | A single-side accent, inset strip, or geometric pseudo-element tab recurs on three or more rounded cards. Delete decorative stripes; preserve alert/status and real nav tabs. MEDIUM, DET. |
29
29
  | SLOP-016 | Match only the first loaded family against the fixed overused-font list. This is a candidate for a human type-rationale review, not a bare-font verdict. MEDIUM, DET assist + JUDG. |
30
30
  | SLOP-017 | A shortlisted display serif without a stated content reason is a candidate for correction, not a universal ban. MEDIUM, JUDG. |
31
31
  | SLOP-018 | A ≥3.5× headline/subhead size ratio with subhead <14px may bury meaning. Check content importance, then rebalance. MEDIUM, JUDG. |
@@ -76,7 +76,7 @@ Read this with the craft floor in every frontend mode. The register identifies r
76
76
  | SLOP-048 | Autoplay carousel dots without controls or keyboard binding are inert decoration. Add functional controls or remove them. LOW, DET. |
77
77
  | SLOP-049 | A stock silhouette avatar used as a person placeholder needs a more honest state treatment. LOW, DET. |
78
78
  | SLOP-050 | Repeated category captions under every trust logo can be removed when the marks identify themselves. LOW, DET. |
79
- | SLOP-051 | An SVG of ≥200×200px, ≥8 simple primitives, ≥3 fills, ≤2 text nodes and no pattern needs visual review before simplification. MEDIUM, DET assist + JUDG. |
79
+ | SLOP-051 | An SVG of ≥200×200px, ≥8 simple primitives, ≥3 fills, ≤2 text nodes, no pattern and no accessible name (`<title>`, or `role=img` with a label) needs visual review before simplification. MEDIUM, DET assist + JUDG. |
80
80
  | SLOP-052 | A clip polygon with ≥10 vertices and at least half its coordinates off the 25% grid, or `path()` with ≥3 curves, needs review. LOW, DET assist + JUDG. |
81
81
  | SLOP-053 | Emoji standing in for a coherent icon system is a candidate. Respect an explicit emoji policy. LOW, JUDG after detection. |
82
82
  | SLOP-054 | An image node itself scales on hover. Move the effect to its frame if the interaction remains useful. LOW, DET. |
@@ -0,0 +1,400 @@
1
+ #!/usr/bin/env node
2
+ // Design lock: the one place a build picks its look. It writes the chosen house style into the
3
+ // project as design.lock.json plus ui/tokens.css, ui/components.css, ui/ui.js and the fonts, and
4
+ // the interface probe then checks the rendered page against that lock (DS-* rules).
5
+ //
6
+ // node design-lock.mjs list
7
+ // node design-lock.mjs init --family <landing|workspace|settings> --dir <project> [--style <id>]
8
+ // [--brief "<request text>"] [--density rich|calm] [--moment <kind> --moment-note "<what it is>"
9
+ // [--moment-place "<where it sits>"]] [--scaffold] [--from <style.json>] [--force]
10
+ // node design-lock.mjs moment --dir <project> --kind <kind> --note "<what it is>" [--place "<where>"]
11
+ // Without --style a style the brief names by keyword applies (styleForBrief), else the family
12
+ // default (DEFAULT_STYLE_BY_FAMILY).
13
+ // node design-lock.mjs match "<request text>"
14
+ // node design-lock.mjs show --dir <project>
15
+ //
16
+ // `--from` takes a brand's own style file in the same schema as kit/styles/*.json; its id must not
17
+ // reuse a kit style id. Nothing here fetches from the network or installs anything.
18
+ import { createHash } from "node:crypto";
19
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
20
+ import { dirname, join, resolve } from "node:path";
21
+ import process from "node:process";
22
+ import { fileURLToPath } from "node:url";
23
+
24
+ const SKILL_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
25
+ const KIT = join(SKILL_ROOT, "kit");
26
+ export const LOCK_FILE = "design.lock.json";
27
+ export const LOCK_SCHEMA = "litcodex.design-lock/v1";
28
+ export const STYLE_SCHEMA = "litcodex.frontend-style/v1";
29
+ export const FAMILIES = Object.freeze({
30
+ landing: "read-once pages: landing, product, launch, portfolio, docs home",
31
+ workspace: "screens people work in: dashboards, consoles, admin, tools, tables",
32
+ settings: "guided forms: settings, account, onboarding, checkout steps",
33
+ });
34
+ // The decided defaults when a brief gives no visual direction: read-once pages
35
+ // keep the authored field-notes profile; work surfaces use graphite. meadow is never a default.
36
+ export const DEFAULT_STYLE_BY_FAMILY = Object.freeze({ landing: "field-notes", workspace: "graphite", settings: "graphite" });
37
+ // The lock fixes the look, and every page names the one place
38
+ // it is allowed to be bold. Read-once pages take a bold moment above the fold; work surfaces stay
39
+ // calm and take a small one. The probe checks the declared kind against [data-ui-moment] (DS-008).
40
+ export const MOMENT_SCALE_BY_FAMILY = Object.freeze({ landing: "bold", workspace: "small", settings: "small" });
41
+ export const MOMENT_KINDS = Object.freeze({
42
+ bold: Object.freeze(["hero-composition", "type-set-piece", "data-moment", "diagram", "motion-detail", "interactive-object"]),
43
+ small: Object.freeze(["chart", "empty-state", "header-detail"]),
44
+ });
45
+ export const MOMENT_SELECTOR = "[data-ui-moment]";
46
+ export const COLOR_ROLES = Object.freeze(["canvas", "surface", "sunken", "ink", "ink-2", "ink-3", "line", "line-strong", "control", "accent", "accent-hover", "on-accent", "accent-wash", "accent-ink", "accent-2", "accent-2-ink", "accent-2-wash", "on-accent-2", "support", "support-ink", "focus", "positive", "positive-wash", "warning", "warning-wash", "negative", "negative-wash", "info", "info-wash", "chart-1", "chart-2", "chart-3", "chart-4", "chart-5"]);
47
+ const SCALE_KEYS = ["xs", "sm", "md", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl"];
48
+ const RADIUS_KEYS = ["xs", "sm", "md", "lg", "pill"];
49
+ const HEX = /^#[0-9a-f]{6}$/u;
50
+ // The shape block carries what makes a register more than a palette: border weights, which role
51
+ // draws outlines, the elevation grammar the probe enforces (DS-007), how a button presses, and the
52
+ // case and family of meta text. Every value is closed so components.css can stay token-only.
53
+ export const SHAPE_CHOICES = Object.freeze({
54
+ surface_line: ["line", "line-strong", "ink"],
55
+ control_edge: ["control", "ink"],
56
+ elevation: ["soft", "offset", "flat"],
57
+ press: ["scale", "shift", "none"],
58
+ meta_font: ["text", "mono"],
59
+ meta_case: ["none", "uppercase"],
60
+ display_case: ["none", "uppercase"],
61
+ canvas_pattern: ["none", "dots", "grid", "plot"],
62
+ heading_font: ["display", "mono"],
63
+ panel_head: ["plain", "inverse", "accent"],
64
+ section_marks: ["none", "coord"],
65
+ });
66
+
67
+ export function kitStyles() {
68
+ return readdirSync(join(KIT, "styles")).filter((name) => name.endsWith(".json")).sort()
69
+ .map((name) => JSON.parse(readFileSync(join(KIT, "styles", name), "utf8")));
70
+ }
71
+
72
+ // Returns a list of problems; an empty list means the style can be locked.
73
+ export function validateStyle(style) {
74
+ const issues = [];
75
+ if (!style || typeof style !== "object") return ["style is not an object"];
76
+ if (style.schema_id !== STYLE_SCHEMA) issues.push(`schema_id must be ${STYLE_SCHEMA}`);
77
+ if (!/^[a-z][a-z0-9-]{1,31}$/u.test(style.id ?? "")) issues.push("id must be a short kebab-case name");
78
+ for (const role of ["text", "display", "mono"]) if (typeof style.fonts?.[role] !== "string" || !style.fonts[role].trim()) issues.push(`fonts.${role} is required`);
79
+ for (const key of SCALE_KEYS) if (!Number.isFinite(style.type?.scale_px?.[key])) issues.push(`type.scale_px.${key} is required`);
80
+ if (!(style.type?.display_px?.min > 0 && style.type.display_px.max >= style.type.display_px.min)) issues.push("type.display_px needs min ≤ max");
81
+ if (!(style.type?.moment_px?.max > style.type?.display_px?.max)) issues.push("type.moment_px.max must sit above type.display_px.max");
82
+ for (const key of ["text", "medium", "strong", "display"]) if (!Number.isFinite(style.type?.weights?.[key])) issues.push(`type.weights.${key} is required`);
83
+ for (const key of RADIUS_KEYS) if (!Number.isFinite(style.radius_px?.[key])) issues.push(`radius_px.${key} is required`);
84
+ if (!Array.isArray(style.space_px) || style.space_px.some((v) => !Number.isInteger(v) || v % 4 !== 0)) issues.push("space_px must be multiples of 4");
85
+ for (const theme of ["light", "dark"]) {
86
+ for (const role of COLOR_ROLES) if (!HEX.test(style.color?.[theme]?.[role] ?? "")) issues.push(`color.${theme}.${role} must be #rrggbb`);
87
+ }
88
+ const shape = style.shape;
89
+ for (const key of ["rule", "surface", "control"]) if (!(Number.isInteger(shape?.border_px?.[key]) && shape.border_px[key] >= 1 && shape.border_px[key] <= 4)) issues.push(`shape.border_px.${key} must be 1 to 4`);
90
+ for (const [key, allowed] of Object.entries(SHAPE_CHOICES)) if (!allowed.includes(shape?.[key])) issues.push(`shape.${key} must be one of ${allowed.join(", ")}`);
91
+ for (const key of ["surface", "control"]) if (!(Number.isInteger(shape?.offset_px?.[key]) && shape.offset_px[key] >= 0)) issues.push(`shape.offset_px.${key} is required`);
92
+ if (shape?.elevation === "offset" && !(shape.offset_px?.surface > 0 && shape.offset_px?.control > 0)) issues.push("an offset elevation needs offset_px above 0");
93
+ if (shape?.elevation !== "offset" && (shape?.offset_px?.surface || shape?.offset_px?.control || shape?.press === "shift")) issues.push("offset_px and press shift belong to an offset elevation");
94
+ for (const key of ["keywords", "signature", "forbid"]) if (!Array.isArray(style[key]) || !style[key].length || style[key].some((item) => typeof item !== "string" || !item.trim())) issues.push(`${key} needs at least one entry`);
95
+ return issues;
96
+ }
97
+
98
+ // The kit style a brief names, or null. A brief that names a register by one of a style's keywords
99
+ // picks it; when two styles match ("neo-brutalism" also contains "brutalism") the longer keyword
100
+ // wins. Latin keywords must start at a word boundary so "crt" does not match inside a word.
101
+ export function styleForBrief(text, styles = kitStyles()) {
102
+ const haystack = String(text ?? "").toLowerCase();
103
+ let best = null;
104
+ for (const style of styles) {
105
+ for (const keyword of style.keywords ?? []) {
106
+ const word = keyword.toLowerCase();
107
+ const escaped = word.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
108
+ const pattern = /^[a-z]/u.test(word) ? new RegExp(`(?<![a-z0-9])${escaped}`, "u") : new RegExp(escaped, "u");
109
+ if (pattern.test(haystack) && (!best || word.length > best.keyword.length)) best = { id: style.id, keyword: word };
110
+ }
111
+ }
112
+ return best;
113
+ }
114
+
115
+ // Density: rich is the default register; calm only when the request asks
116
+ // for a minimal, quiet or restrained page, or --density calm. Calm keeps the broad, flat page the
117
+ // kit shipped before; rich tightens the section rhythm and turns on texture and a glow token.
118
+ export const DENSITIES = Object.freeze(["rich", "calm"]);
119
+ const CALM_WORDS = [/(?<![a-z])minimal(?:ist|ism)?(?![a-z])/u, /(?<![a-z])(?:calm|quiet|restrained|understated|pared[- ]back|sparse)(?![a-z])/u, /미니멀/u, /차분/u, /절제/u, /담백/u, /간결/u];
120
+ export function densityForBrief(text) {
121
+ const haystack = String(text ?? "").toLowerCase();
122
+ return CALM_WORDS.some((pattern) => pattern.test(haystack)) ? "calm" : "rich";
123
+ }
124
+ const checkDensity = (density) => {
125
+ if (!DENSITIES.includes(density)) throw new Error(`--density must be rich or calm, not "${density}"`);
126
+ return density;
127
+ };
128
+
129
+ const fontStack = (family, kind) => {
130
+ const tail = kind === "mono"
131
+ ? `ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace`
132
+ : `"Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif`;
133
+ return `"${family}", ${tail}`;
134
+ };
135
+
136
+ export function tokensCss(style, fontFiles, density = "rich") {
137
+ const calm = checkDensity(density) === "calm";
138
+ const t = style.type;
139
+ const { min, max } = t.display_px;
140
+ const slope = (max - min) / (1440 - 390);
141
+ const intercept = min - slope * 390;
142
+ const colors = (theme, indent = " ") => COLOR_ROLES.map((role) => `${indent}--c-${role}: ${style.color[theme][role]};`).join("\n");
143
+ const shape = style.shape;
144
+ const control = shape.offset_px.control;
145
+ const press = { scale: "scale(0.96)", shift: `translate(${control}px, ${control}px)`, none: "none" }[shape.press];
146
+ const grid = "linear-gradient(color-mix(in srgb, var(--c-line) 70%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--c-line) 70%, transparent) 1px, transparent 1px)";
147
+ // The plot grid: minor lines lighter than the grid style, a stronger line every five cells.
148
+ // Both stay on --c-line so body text keeps its contrast over every stop (CF-204) in light and dark.
149
+ const minor = grid.replaceAll("70%", "50%");
150
+ const major = grid.replaceAll("70%", "85%");
151
+ // Notebook dots are texture, so the calm register drops them; grid and plot are a register's structure and stay.
152
+ const dots = "radial-gradient(circle, color-mix(in srgb, var(--c-line-strong) 55%, transparent) 1px, transparent 1.5px)";
153
+ const pattern = { none: ["none", "auto"], dots: calm ? ["none", "auto"] : [dots, "24px 24px"], grid: [grid, "32px 32px"], plot: [`${minor}, ${major}`, "32px 32px, 32px 32px, 160px 160px, 160px 160px"] }[shape.canvas_pattern];
154
+ // A soft accent glow for one atmosphere surface; flat and offset registers keep their own elevation grammar (DS-007).
155
+ const glow = calm || shape.elevation !== "soft" ? "none" : "0 0 48px color-mix(in srgb, var(--c-accent) 30%, transparent), 0 0 96px color-mix(in srgb, var(--c-accent-2) 18%, transparent)";
156
+ const pad = calm ? { section: [64, 96, 128], hero: [48, 64, 80] } : { section: [48, 72, 96], hero: [40, 56, 64] };
157
+ const head = { plain: ["transparent", "inherit", "initial", 0], inverse: ["var(--c-ink)", "var(--c-canvas)", "var(--c-canvas)", 1], accent: ["var(--c-accent)", "var(--c-on-accent)", "var(--c-on-accent)", 1] }[shape.panel_head];
158
+ const moment = t.moment_px.max;
159
+ const momentSlope = (moment - min) / (1440 - 390);
160
+ const faces = fontFiles.map((font) => `@font-face {\n font-family: "${font.family}";\n src: url("fonts/${font.file}") format("woff2");\n font-weight: ${font.weight};\n font-style: normal;\n font-display: swap;\n}`).join("\n");
161
+ return `/* Generated by frontend-ui-ux scripts/design-lock.mjs for the "${style.id}" style. Do not edit by hand:
162
+ re-run design-lock.mjs, or change the style file and lock again. */
163
+ ${faces}
164
+ :root {
165
+ --ui-lock: "${style.id}";
166
+ --density: "${calm ? "calm" : "rich"}";
167
+ --font-text: ${fontStack(style.fonts.text, "text")};
168
+ --font-display: ${fontStack(style.fonts.display, "text")};
169
+ --font-mono: ${fontStack(style.fonts.mono, "mono")};
170
+ --font-text-ko: ${style.fonts.text === style.fonts.mono ? fontStack(style.fonts.display, "text") : "var(--font-text)"};
171
+ ${SCALE_KEYS.map((key) => ` --fs-${key}: ${t.scale_px[key]}px;`).join("\n")}
172
+ --fs-display: clamp(${min}px, ${intercept.toFixed(2)}px + ${(slope * 100).toFixed(3)}vw, ${max}px);
173
+ --fs-moment: clamp(${min}px, ${(min - momentSlope * 390).toFixed(2)}px + ${(momentSlope * 100).toFixed(3)}vw, ${moment}px);
174
+ --fw-text: ${t.weights.text};
175
+ --fw-medium: ${t.weights.medium};
176
+ --fw-strong: ${t.weights.strong};
177
+ --fw-display: ${t.weights.display};
178
+ --track-display: ${t.tracking_em.display}em;
179
+ --track-label: ${t.tracking_em.label}em;
180
+ --lh-body: ${t.leading.body};
181
+ --lh-tight: ${t.leading.tight};
182
+ --lh-display: ${t.leading.display_latin};
183
+ --lh-display-ko: ${t.leading.display_korean};
184
+ ${style.space_px.map((value) => ` --sp-${value}: ${value}px;`).join("\n")}
185
+ ${RADIUS_KEYS.map((key) => ` --radius-${key}: ${style.radius_px[key]}px;`).join("\n")}
186
+ --shadow-raised: ${style.shadow.raised};
187
+ --shadow-overlay: ${style.shadow.overlay};
188
+ --shadow-control: ${shape.elevation === "offset" ? `${control}px ${control}px 0 0 var(--c-ink)` : "none"};
189
+ --shadow-control-pressed: ${shape.elevation === "offset" ? "0 0 0 0 var(--c-ink)" : "none"};
190
+ --press: ${press};
191
+ --bw-rule: ${shape.border_px.rule}px;
192
+ --bw-surface: ${shape.border_px.surface}px;
193
+ --bw-control: ${shape.border_px.control}px;
194
+ --c-frame: var(--c-${shape.surface_line});
195
+ --control-edge: ${shape.control_edge === "ink" ? "var(--c-ink)" : "initial"};
196
+ --font-meta: ${shape.meta_font === "mono" ? "var(--font-mono)" : "var(--font-text)"};
197
+ --font-heading: ${shape.heading_font === "mono" ? "var(--font-mono)" : "var(--font-display)"};
198
+ --font-heading-ko: ${shape.heading_font === "mono" ? "var(--font-display)" : "var(--font-heading)"};
199
+ --panel-head-bg: ${head[0]};
200
+ --panel-head-ink: ${head[1]};
201
+ --panel-head-status: ${head[2]};
202
+ --panel-head-bleed: ${head[3]};
203
+ --section-marks: ${shape.section_marks === "coord" ? "block" : "none"};
204
+ --meta-case: ${shape.meta_case};
205
+ --display-case: ${shape.display_case};
206
+ --canvas-pattern: ${pattern[0]};
207
+ --canvas-pattern-size: ${pattern[1]};
208
+ --glow: ${glow};
209
+ --dur-fast: ${style.motion.fast_ms}ms;
210
+ --dur-ui: ${style.motion.ui_ms}ms;
211
+ --dur-enter: ${style.motion.enter_ms}ms;
212
+ --dur-exit: ${style.motion.exit_ms}ms;
213
+ --ease: ${style.motion.ease};
214
+ --gutter: 16px;
215
+ --work-gutter: 16px;
216
+ --section-pad: ${pad.section[0]}px;
217
+ --hero-pad: ${pad.hero[0]}px;
218
+ ${colors("light")}
219
+ }
220
+ @media (min-width: 640px) { :root { --gutter: 24px; --work-gutter: 24px; --section-pad: ${pad.section[1]}px; --hero-pad: ${pad.hero[1]}px; } }
221
+ @media (min-width: 1024px) { :root { --gutter: 40px; --work-gutter: 32px; --section-pad: ${pad.section[2]}px; --hero-pad: ${pad.hero[2]}px; } }
222
+ @media (prefers-color-scheme: dark) {
223
+ :root:not([data-theme="light"]) {
224
+ ${colors("dark", " ")}
225
+ }
226
+ }
227
+ :root[data-theme="dark"] {
228
+ ${colors("dark")}
229
+ }
230
+ `;
231
+ }
232
+
233
+ const sha256 = (path) => createHash("sha256").update(readFileSync(path)).digest("hex");
234
+
235
+ function kitFonts() {
236
+ const manifest = JSON.parse(readFileSync(join(KIT, "fonts.json"), "utf8"));
237
+ return manifest.fonts.map((font) => {
238
+ const source = resolve(KIT, font.source);
239
+ const licence = resolve(KIT, font.licence.source);
240
+ if (!existsSync(source) || sha256(source) !== font.sha256) throw new Error(`font ${font.file} is missing or does not match kit/fonts.json`);
241
+ if (!existsSync(licence) || sha256(licence) !== font.licence.sha256) throw new Error(`licence for ${font.family} is missing or does not match kit/fonts.json`);
242
+ return { ...font, sourcePath: source, licencePath: licence };
243
+ });
244
+ }
245
+
246
+ // What a moment is and where it sits. A lock without a kind is valid to write (the page is not
247
+ // built yet) but DS-008 fails every render until the moment is declared and present.
248
+ function momentRecord(family, { kind = null, note = null, place = null } = {}) {
249
+ const scale = MOMENT_SCALE_BY_FAMILY[family];
250
+ if (kind !== null) {
251
+ const all = [...MOMENT_KINDS.bold, ...MOMENT_KINDS.small];
252
+ if (!all.includes(kind)) throw new Error(`unknown moment "${kind}"; one of ${all.join(", ")}`);
253
+ if (!MOMENT_KINDS[scale].includes(kind)) throw new Error(`a ${scale === "small" ? "work surface takes a small" : "read-once page takes a bold"} moment: ${MOMENT_KINDS[scale].join(", ")}`);
254
+ if (!String(note ?? "").trim()) throw new Error("a moment needs --moment-note: what it shows, in a few words");
255
+ }
256
+ return { scale, kind, note: kind === null ? null : String(note).trim(), place: kind === null || !String(place ?? "").trim() ? null : String(place).trim(), selector: MOMENT_SELECTOR, above_fold: scale === "bold" };
257
+ }
258
+
259
+ export function lockRecord(style, family, moment = {}, density = "rich") {
260
+ return {
261
+ schema_id: LOCK_SCHEMA,
262
+ style: style.id,
263
+ family,
264
+ density: checkDensity(density),
265
+ fonts: [...new Set([style.fonts.text, style.fonts.display, style.fonts.mono])],
266
+ type: { scale_px: Object.values(style.type.scale_px), display_px: style.type.display_px, moment_px: style.type.moment_px },
267
+ radius_px: [...new Set([0, ...RADIUS_KEYS.map((key) => style.radius_px[key])])],
268
+ space_px: style.space_px,
269
+ colors: { light: style.color.light, dark: style.color.dark },
270
+ elevation: style.shape.elevation,
271
+ files: { tokens: "ui/tokens.css", components: "ui/components.css", script: "ui/ui.js" },
272
+ accent_art: style.accent_art ?? "none",
273
+ moment: momentRecord(family, moment),
274
+ };
275
+ }
276
+
277
+ export function setMoment({ dir, kind, note, place = null }) {
278
+ const lockPath = join(resolve(dir), LOCK_FILE);
279
+ const lock = JSON.parse(readFileSync(lockPath, "utf8"));
280
+ lock.moment = momentRecord(lock.family, { kind, note, place });
281
+ writeFileSync(lockPath, `${JSON.stringify(lock, null, 2)}\n`);
282
+ return lock.moment;
283
+ }
284
+
285
+ export function initLock({ styleId = null, family, dir, scaffold = false, from = null, force = false, brief = null, moment = null, momentNote = null, momentPlace = null, density = null }) {
286
+ if (!FAMILIES[family]) throw new Error(`--family must be one of ${Object.keys(FAMILIES).join(", ")}`);
287
+ const register = checkDensity(density ?? densityForBrief(brief));
288
+ const declared = momentRecord(family, { kind: moment, note: momentNote, place: momentPlace });
289
+ const styles = kitStyles();
290
+ let style;
291
+ if (from) {
292
+ style = JSON.parse(readFileSync(resolve(from), "utf8"));
293
+ if (styles.some((kit) => kit.id === style.id)) throw new Error(`--from style id "${style.id}" reuses a kit style id; give the brand style its own id`);
294
+ } else {
295
+ style = styles.find((kit) => kit.id === (styleId ?? styleForBrief(brief, styles)?.id ?? DEFAULT_STYLE_BY_FAMILY[family]));
296
+ if (!style) throw new Error(`unknown style "${styleId}"; run \`design-lock.mjs list\``);
297
+ }
298
+ const issues = validateStyle(style);
299
+ if (issues.length) throw new Error(`style ${style.id} cannot be locked:\n- ${issues.join("\n- ")}`);
300
+ const project = resolve(dir);
301
+ mkdirSync(join(project, "ui", "fonts"), { recursive: true });
302
+ const lockPath = join(project, LOCK_FILE);
303
+ if (existsSync(lockPath) && !force) {
304
+ const current = JSON.parse(readFileSync(lockPath, "utf8"));
305
+ if (current.style !== style.id) throw new Error(`${LOCK_FILE} already locks "${current.style}"; pass --force only if the user changed the direction`);
306
+ }
307
+ const fonts = kitFonts();
308
+ for (const font of fonts) {
309
+ copyFileSync(font.sourcePath, join(project, "ui", "fonts", font.file));
310
+ copyFileSync(font.licencePath, join(project, "ui", "fonts", font.licence.file));
311
+ }
312
+ writeFileSync(join(project, "ui", "tokens.css"), tokensCss(style, fonts, register));
313
+ copyFileSync(join(KIT, "components.css"), join(project, "ui", "components.css"));
314
+ copyFileSync(join(KIT, "ui.js"), join(project, "ui", "ui.js"));
315
+ writeFileSync(lockPath, `${JSON.stringify({ ...lockRecord(style, family, {}, register), moment: declared }, null, 2)}\n`);
316
+ let scaffolded = null;
317
+ if (scaffold) {
318
+ const page = join(project, "index.html");
319
+ if (existsSync(page) && !force) scaffolded = "kept existing index.html";
320
+ else {
321
+ copyFileSync(join(KIT, "layouts", `${family}.html`), page);
322
+ scaffolded = "index.html";
323
+ }
324
+ }
325
+ return { style, family, project, scaffolded, density: register };
326
+ }
327
+
328
+ function parse(argv) {
329
+ const [command, ...rest] = argv;
330
+ const options = { command };
331
+ for (let i = 0; i < rest.length; i += 1) {
332
+ const arg = rest[i];
333
+ if (arg === "--scaffold" || arg === "--force") options[arg.slice(2)] = true;
334
+ else if (["--style", "--family", "--dir", "--from", "--brief", "--moment", "--moment-note", "--moment-place", "--density", "--kind", "--note", "--place"].includes(arg)) options[arg.slice(2)] = rest[++i];
335
+ else if (command === "match" && options.text === undefined) options.text = arg;
336
+ else throw new Error(`unknown argument ${arg}`);
337
+ }
338
+ return options;
339
+ }
340
+
341
+ function main(argv) {
342
+ const options = parse(argv);
343
+ if (options.command === "list") {
344
+ for (const style of kitStyles()) {
345
+ console.log(`${style.id} — ${style.name}\n ${style.summary}\n use when: ${style.use_when.join("; ")}\n avoid when: ${style.avoid_when.join("; ")}\n picked by: ${style.keywords.join(", ")}\n signature: ${style.signature.join("; ")}\n never: ${style.forbid.join("; ")}\n`);
346
+ }
347
+ console.log("Families (layout starters in kit/layouts/):");
348
+ for (const [id, text] of Object.entries(FAMILIES)) console.log(` ${id} — ${text} (default style: ${DEFAULT_STYLE_BY_FAMILY[id]})\n moments (${id}): ${MOMENT_KINDS[MOMENT_SCALE_BY_FAMILY[id]].join(", ")}`);
349
+ return 0;
350
+ }
351
+ if (options.command === "init") {
352
+ if (!options.dir || !options.family) throw new Error("init needs --family and --dir (--style or --from only to override the family default)");
353
+ const result = initLock({ styleId: options.style, family: options.family, dir: options.dir, scaffold: options.scaffold, from: options.from, force: options.force, brief: options.brief, density: options.density ?? null, moment: options.moment ?? null, momentNote: options["moment-note"] ?? null, momentPlace: options["moment-place"] ?? null });
354
+ console.log(`Locked "${result.style.id}" (${result.family}, ${result.density}) in ${result.project}`);
355
+ console.log(`Wrote ${LOCK_FILE}, ui/tokens.css, ui/components.css, ui/ui.js and ui/fonts/.${result.scaffolded ? ` Scaffold: ${result.scaffolded}.` : ""}`);
356
+ console.log("Link ui/tokens.css then ui/components.css (and ui/ui.js with defer when you use charts, sortable tables or tabs).");
357
+ console.log("Build with the kit's ui-* classes and var(--c-*), var(--fs-*), var(--sp-*), var(--radius-*) only; the interface probe checks the page against this lock.");
358
+ const declared = JSON.parse(readFileSync(join(result.project, LOCK_FILE), "utf8")).moment;
359
+ console.log(declared.kind
360
+ ? `Signature moment: ${declared.kind} (${declared.note}). Mark that one element with data-ui-moment="${declared.kind}"${declared.above_fold ? " in the first screen" : ""}.`
361
+ : `No signature moment yet: decide the ${declared.scale} moment (${MOMENT_KINDS[declared.scale].join(", ")}) and record it with \`design-lock.mjs moment\`; the probe fails the page until it is declared and present (DS-008).`);
362
+ return 0;
363
+ }
364
+ if (options.command === "moment") {
365
+ if (!options.dir || !options.kind) throw new Error("moment needs --dir, --kind and --note");
366
+ const moment = setMoment({ dir: options.dir, kind: options.kind, note: options.note, place: options.place ?? null });
367
+ console.log(`Recorded ${moment.scale} moment ${moment.kind}: mark it with data-ui-moment="${moment.kind}"${moment.above_fold ? " in the first screen" : ""}.`);
368
+ return 0;
369
+ }
370
+ if (options.command === "match") {
371
+ const hit = styleForBrief(options.text);
372
+ console.log(hit ? `${hit.id} (keyword "${hit.keyword}")` : "no style named; the family default applies");
373
+ const density = densityForBrief(options.text);
374
+ console.log(`density: ${density}${density === "calm" ? " (the request asks for a calm page)" : " (the default; calm only when the request asks)"}`);
375
+ return 0;
376
+ }
377
+ if (options.command === "show") {
378
+ const lock = JSON.parse(readFileSync(join(resolve(options.dir ?? "."), LOCK_FILE), "utf8"));
379
+ console.log(JSON.stringify({ style: lock.style, family: lock.family, density: lock.density ?? null, fonts: lock.fonts, type: lock.type, radius_px: lock.radius_px, moment: lock.moment ?? null }, null, 2));
380
+ return 0;
381
+ }
382
+ throw new Error("usage: design-lock.mjs list | init [--style <id>] [--brief <text>] [--density rich|calm] --family <landing|workspace|settings> --dir <project> [--moment <kind> --moment-note <text> [--moment-place <text>]] [--scaffold] [--from <style.json>] [--force] | moment --dir <project> --kind <kind> --note <text> [--place <text>] | match <text> | show --dir <project>");
383
+ }
384
+
385
+ const startedDirectly = () => {
386
+ try {
387
+ return Boolean(process.argv[1]) && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
388
+ } catch {
389
+ return false;
390
+ }
391
+ };
392
+
393
+ if (startedDirectly()) {
394
+ try {
395
+ process.exitCode = main(process.argv.slice(2));
396
+ } catch (error) {
397
+ console.error(`design-lock: ${error.message}`);
398
+ process.exitCode = 1;
399
+ }
400
+ }
@@ -0,0 +1,196 @@
1
+ // In-page design-lock conformance (DS-001..DS-008). probe.mjs serialises this function
2
+ // into the page, so it may not import anything or close over module scope; every threshold comes
3
+ // from the rule table through `options.rules` (LOCK_RULES in rule-data.mjs), and the lock arrives as `options.lock`.
4
+ export function measureLock(options) {
5
+ const { rules, limits, lock } = options;
6
+ const findings = [];
7
+ const notVerified = [];
8
+ const push = (rule, selector, value, threshold, severity) => {
9
+ if (findings.filter((f) => f.rule === rule).length >= limits.findingsPerRule) return;
10
+ findings.push({ rule, severity: severity ?? rules[rule].severity, tier: rules[rule].tier, viewport: options.viewport, selector, value, threshold });
11
+ };
12
+ const describe = (el) => {
13
+ if (el.id) return `#${el.id}`;
14
+ const cls = [...el.classList].slice(0, 2).map((c) => `.${c}`).join("");
15
+ return `${el.tagName.toLowerCase()}${cls}`;
16
+ };
17
+ const exempt = (el) => Boolean(el.closest("[data-lock-exempt], img, video, canvas, iframe, picture, object"));
18
+ const visible = (el) => {
19
+ if (typeof el.checkVisibility === "function" && !el.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true })) return false;
20
+ const box = el.getBoundingClientRect();
21
+ return box.width >= 1 && box.height >= 1;
22
+ };
23
+
24
+ // DS-001: the generated tokens.css carries the lock id on :root.
25
+ const applied = getComputedStyle(document.documentElement).getPropertyValue(rules["DS-001"].threshold.property).trim().replace(/^["']|["']$/gu, "");
26
+ if (applied !== lock.style) {
27
+ push("DS-001", ":root", applied ? `${rules["DS-001"].threshold.property}: ${applied}` : `${rules["DS-001"].threshold.property} missing`, `"${lock.style}" from design.lock.json`);
28
+ return { findings, notVerified };
29
+ }
30
+
31
+ const parse = (value) => {
32
+ let match = /^rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?\)$/u.exec(value);
33
+ if (match) return { rgb: [Number(match[1]), Number(match[2]), Number(match[3])], alpha: match[4] === undefined ? 1 : Number(match[4]) };
34
+ match = /^color\(srgb\s+([-\d.e]+)\s+([-\d.e]+)\s+([-\d.e]+)(?:\s*\/\s*([\d.]+))?\)$/u.exec(value);
35
+ if (match) return { rgb: [match[1], match[2], match[3]].map((n) => Math.round(Number(n) * 255)), alpha: match[4] === undefined ? 1 : Number(match[4]) };
36
+ return null;
37
+ };
38
+ const hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));
39
+ const palette = [...Object.values(lock.colors.light), ...Object.values(lock.colors.dark)].map(hex);
40
+ const tolerance = rules["DS-003"].threshold.channelTolerance;
41
+ const onPalette = (rgb) => palette.some((p) => Math.abs(p[0] - rgb[0]) <= tolerance && Math.abs(p[1] - rgb[1]) <= tolerance && Math.abs(p[2] - rgb[2]) <= tolerance);
42
+ const toHex = (rgb) => `#${rgb.map((n) => Math.max(0, Math.min(255, n)).toString(16).padStart(2, "0")).join("")}`;
43
+ const families = new Set(lock.fonts.map((f) => f.toLowerCase()));
44
+ const sizes = lock.type.scale_px;
45
+ const display = lock.type.display_px;
46
+ // Inside the declared signature moment type may run past the display range up to the lock's ceiling.
47
+ const momentMax = lock.type.moment_px?.max ?? display.max;
48
+ const momentAttr = rules["DS-008"].threshold.attribute;
49
+ const sizeTolerance = rules["DS-004"].threshold.tolerancePx;
50
+ const radii = lock.radius_px;
51
+ const radiusTolerance = rules["DS-005"].threshold.tolerancePx;
52
+
53
+ const offColours = new Map();
54
+ const offFamilies = new Map();
55
+ const offSizes = new Map();
56
+ const offRadii = new Map();
57
+ const offShadows = new Map();
58
+ let unparsed = 0;
59
+ // DS-007: the lock names an elevation grammar. "flat" allows only rings (no blur, no offset past a
60
+ // hairline); "offset" allows hard offsets but no blur; "soft" is left to CF-403. Insets never count.
61
+ const elevation = lock.elevation ?? "soft";
62
+ const hairline = rules["DS-007"].threshold.hairlinePx;
63
+ const shadowLengths = (value) => (value === "none" ? [] : value.split(/,(?![^()]*\))/u)).filter((part) => !/\binset\b/u.test(part))
64
+ .map((part) => part.replace(/\b(?:rgba?|color|hsla?|oklch|lab|lch)\([^)]*\)/gu, "").match(/-?[\d.]+px/gu)?.map(Number.parseFloat) ?? []);
65
+ const noteColour = (value, el, where) => {
66
+ const colour = parse(value);
67
+ if (!colour) { if (value !== "transparent" && value !== "none") unparsed += 1; return; }
68
+ if (colour.alpha < rules["DS-003"].threshold.minAlpha || onPalette(colour.rgb)) return;
69
+ const key = toHex(colour.rgb);
70
+ if (!offColours.has(key)) offColours.set(key, `${describe(el)} ${where}`);
71
+ };
72
+
73
+ const elements = [...document.body.querySelectorAll("*")].slice(0, limits.nodes);
74
+ for (const el of elements) {
75
+ if (exempt(el) || !visible(el)) continue;
76
+ const style = getComputedStyle(el);
77
+ const isSvgShape = el instanceof SVGElement && !(el instanceof SVGSVGElement);
78
+ if (isSvgShape) {
79
+ if (["rect", "path", "circle", "ellipse", "polygon", "polyline", "line"].includes(el.tagName.toLowerCase())) {
80
+ if (style.fill !== "none") noteColour(style.fill, el, "fill");
81
+ if (style.stroke !== "none") noteColour(style.stroke, el, "stroke");
82
+ }
83
+ continue;
84
+ }
85
+ const ownText = [...el.childNodes].some((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim());
86
+ if (ownText) {
87
+ noteColour(style.color, el, "text");
88
+ const family = style.fontFamily.split(",")[0].trim().replace(/^["']|["']$/gu, "").toLowerCase();
89
+ if (!families.has(family) && !offFamilies.has(family)) offFamilies.set(family, describe(el));
90
+ const px = Number.parseFloat(style.fontSize);
91
+ const ceiling = el.closest(`[${momentAttr}]`) ? momentMax : display.max;
92
+ const onScale = sizes.some((s) => Math.abs(s - px) <= sizeTolerance) || (px >= display.min - sizeTolerance && px <= ceiling + sizeTolerance);
93
+ if (!onScale && !offSizes.has(px)) offSizes.set(px, describe(el));
94
+ }
95
+ noteColour(style.backgroundColor, el, "background");
96
+ for (const side of ["Top", "Right", "Bottom", "Left"]) {
97
+ if (Number.parseFloat(style[`border${side}Width`]) > 0 && style[`border${side}Style`] !== "none") noteColour(style[`border${side}Color`], el, "border");
98
+ }
99
+ if (elevation !== "soft") {
100
+ for (const [x = 0, y = 0, blur = 0] of shadowLengths(style.boxShadow)) {
101
+ const offset = Math.abs(x) > hairline || Math.abs(y) > hairline;
102
+ if ((blur > 0 || (elevation === "flat" && offset)) && !offShadows.has(describe(el))) offShadows.set(describe(el), `${x}px ${y}px ${blur}px`);
103
+ }
104
+ }
105
+ const box = el.getBoundingClientRect();
106
+ for (const corner of ["TopLeft", "TopRight", "BottomRight", "BottomLeft"]) {
107
+ const raw = style[`border${corner}Radius`];
108
+ if (!raw || raw.includes(" ") || raw.includes("%")) continue;
109
+ const r = Number.parseFloat(raw);
110
+ if (!(r > 0)) continue;
111
+ const round = r >= Math.min(box.width, box.height) / 2 - radiusTolerance;
112
+ if (!round && !radii.some((v) => Math.abs(v - r) <= radiusTolerance) && !offRadii.has(r)) offRadii.set(r, describe(el));
113
+ }
114
+ }
115
+
116
+ for (const [family, where] of offFamilies) push("DS-002", where, `font-family "${family}"`, `one of ${lock.fonts.join(", ")}`);
117
+ if (offColours.size) {
118
+ const list = [...offColours.entries()];
119
+ const severity = list.length >= rules["DS-003"].threshold.highCount ? "HIGH" : rules["DS-003"].threshold.lowSeverity;
120
+ push("DS-003", list.slice(0, 4).map(([, where]) => where).join(" | "), `${list.length} off-palette colour(s): ${list.slice(0, 8).map(([c]) => c).join(", ")}`, `the ${lock.style} palette (light and dark roles)`, severity);
121
+ }
122
+ if (offSizes.size) push("DS-004", [...offSizes.values()].slice(0, 3).join(" | "), `${offSizes.size} size(s) off scale: ${[...offSizes.keys()].slice(0, 8).map((n) => `${n}px`).join(", ")}`, `${sizes.join("/")}px or display ${display.min}–${display.max}px`);
123
+ if (offRadii.size) push("DS-005", [...offRadii.values()].slice(0, 3).join(" | "), `${offRadii.size} radius value(s) off lock: ${[...offRadii.keys()].slice(0, 6).map((n) => `${n}px`).join(", ")}`, `${radii.join("/")}px or fully round`);
124
+ if (offShadows.size) push("DS-007", [...offShadows.keys()].slice(0, 3).join(" | "), `${offShadows.size} element(s) with ${[...offShadows.values()].slice(0, 3).join(", ")} shadows`, elevation === "flat" ? "flat lock: rings only, no blur or offset" : "offset lock: zero-blur offsets only");
125
+ if (unparsed) notVerified.push({ rule: "DS-003", viewport: options.viewport, reason: `${unparsed} colour value(s) in a format the probe cannot compare` });
126
+
127
+ // DS-006: a starter-layout slot such as {{Product}} left in visible text or a labelling attribute.
128
+ const slot = new RegExp(rules["DS-006"].threshold.pattern, "u");
129
+ const textHit = slot.exec(document.body.innerText.slice(0, limits.textChars * 10));
130
+ if (textHit) push("DS-006", "page text", textHit[0], "no {{slot}} from the kit layouts");
131
+ for (const el of document.querySelectorAll("[title], [aria-label], [alt], [placeholder]")) {
132
+ for (const attr of ["title", "aria-label", "alt", "placeholder"]) {
133
+ const value = el.getAttribute(attr);
134
+ const hit = value && slot.exec(value);
135
+ if (hit) push("DS-006", `${describe(el)}[${attr}]`, hit[0], "no {{slot}} from the kit layouts");
136
+ }
137
+ }
138
+ const title = slot.exec(document.title);
139
+ if (title) push("DS-006", "title", title[0], "no {{slot}} from the kit layouts");
140
+
141
+ // DS-008: the one signature moment the lock declares. It must be declared, marked, big enough to
142
+ // read, in the first screen on a read-once page, hold what its kind promises, and not be the
143
+ // generic gradient-and-centred-text hero.
144
+ const m = rules["DS-008"].threshold;
145
+ const declared = lock.moment;
146
+ if (!declared) {
147
+ push("DS-008", "design.lock.json", "the lock predates signature moments and records none", "a moment recorded with design-lock.mjs moment");
148
+ return { findings, notVerified };
149
+ }
150
+ if (!declared.kind) {
151
+ push("DS-008", "design.lock.json", "the lock declares no signature moment", `a ${declared.scale} moment recorded with design-lock.mjs moment`);
152
+ return { findings, notVerified };
153
+ }
154
+ const marked = [...document.querySelectorAll(`[${m.attribute}]`)].filter(visible);
155
+ if (!marked.length) {
156
+ push("DS-008", "page", `no [${m.attribute}] element for the declared ${declared.kind}`, `one element marked ${m.attribute}="${declared.kind}"`);
157
+ return { findings, notVerified };
158
+ }
159
+ if (marked.length > 1) push("DS-008", marked.slice(0, 3).map(describe).join(" | "), `${marked.length} elements claim the signature moment`, "one moment per page", "MEDIUM");
160
+ const el = marked.find((node) => node.getAttribute(m.attribute) === declared.kind) ?? marked[0];
161
+ const where = describe(el);
162
+ const kind = el.getAttribute(m.attribute);
163
+ if (kind !== declared.kind) push("DS-008", where, `marked "${kind}" but the lock declares "${declared.kind}"`, "the declared kind");
164
+ const box = el.getBoundingClientRect();
165
+ const area = box.width * box.height;
166
+ const minArea = declared.scale === "bold" ? m.boldMinAreaPx : m.smallMinAreaPx;
167
+ if (area < minArea) push("DS-008", where, `${Math.round(box.width)}×${Math.round(box.height)} px moment is too small to read as one`, `≥ ${minArea} px²`);
168
+ const base = options.pass === "base";
169
+ if (declared.scale === "small" && base && innerWidth >= m.foldMinViewportPx && area > m.smallMaxViewportShare * innerWidth * innerHeight) push("DS-008", where, `a work-surface moment covering ${Math.round((100 * area) / (innerWidth * innerHeight))}% of the screen`, `≤ ${m.smallMaxViewportShare * 100}%: work surfaces stay calm`, "MEDIUM");
170
+ if (declared.above_fold && base) {
171
+ const top = box.top + scrollY;
172
+ const wide = innerWidth >= m.foldMinViewportPx;
173
+ const limit = wide ? innerHeight - m.foldMinVisiblePx : innerHeight * m.phoneScreens;
174
+ if (top > limit) push("DS-008", where, `moment starts ${Math.round(top)} px down, below the fold`, wide ? `starts by ${Math.round(limit)} px (first screen)` : `starts within ${m.phoneScreens} screens (${Math.round(limit)} px)`);
175
+ }
176
+ const has = (selector) => el.matches(selector) || [...el.querySelectorAll(selector)].some(visible);
177
+ const media = has(m.media);
178
+ const inside = [el, ...el.querySelectorAll("*")].filter(visible);
179
+ const texts = inside.filter((node) => [...node.childNodes].some((child) => child.nodeType === Node.TEXT_NODE && child.textContent.trim()));
180
+ const need = m.needs[declared.kind];
181
+ const wants = {
182
+ media: ["an image, drawing, figure, frame or product view", () => media],
183
+ data: ["chart, table, figure or readout", () => has(m.data)],
184
+ control: ["control a reader can operate", () => has(m.control)],
185
+ "display-type": ["type at display size or above", () => texts.some((node) => Number.parseFloat(getComputedStyle(node).fontSize) >= display.min - sizeTolerance)],
186
+ motion: ["animation or transition", () => options.pass === "reduced-motion" || inside.some((node) => { const cs = getComputedStyle(node); return cs.animationName !== "none" || cs.transitionDuration.split(",").some((d) => Number.parseFloat(d) > 0); })],
187
+ }[need];
188
+ if (wants && !wants[1]()) push("DS-008", where, `declared ${declared.kind} but it holds no ${wants[0]}`, `a ${declared.kind} built from the page's content`);
189
+ const gradient = (node) => /gradient\(/u.test(getComputedStyle(node).backgroundImage) && !node.matches(".ui-scan, .ui-ruler");
190
+ const chain = [];
191
+ for (let node = el; node && node !== document.body && node !== document.documentElement; node = node.parentElement) chain.push(node);
192
+ const behind = chain.some(gradient) || inside.some((node) => { const b = node.getBoundingClientRect(); return gradient(node) && b.width * b.height >= m.coverShare * area; });
193
+ const biggest = texts.reduce((best, node) => (Number.parseFloat(getComputedStyle(node).fontSize) > (best ? Number.parseFloat(getComputedStyle(best).fontSize) : 0) ? node : best), null);
194
+ if (behind && !media && biggest && getComputedStyle(biggest).textAlign === "center") push("DS-008", where, "a generic gradient-and-centred-text hero", "a moment built from this page's content (composition, set piece, data, diagram, motion or object)");
195
+ return { findings, notVerified };
196
+ }