@monoes/monomindcli 2.16.0 → 2.16.1

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 (359) hide show
  1. package/.claude/helpers/handlers/route-handler.cjs +16 -3
  2. package/.claude/helpers/hook-handler.cjs +17 -2
  3. package/.claude/helpers/jev-picker.cjs +1 -1
  4. package/.claude/skills/monodesign/SKILL.md +257 -0
  5. package/.claude/skills/monodesign/adapt.md +53 -0
  6. package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +100 -0
  7. package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +103 -0
  8. package/.claude/skills/monodesign/animate.md +65 -0
  9. package/.claude/skills/monodesign/audit.md +89 -0
  10. package/.claude/skills/monodesign/bolder.md +50 -0
  11. package/.claude/skills/monodesign/clarify.md +64 -0
  12. package/.claude/skills/monodesign/colorize.md +68 -0
  13. package/.claude/skills/monodesign/craft.md +51 -0
  14. package/.claude/skills/monodesign/critique.md +66 -0
  15. package/.claude/skills/monodesign/delight.md +47 -0
  16. package/.claude/skills/monodesign/distill.md +56 -0
  17. package/.claude/skills/monodesign/document.md +83 -0
  18. package/.claude/skills/monodesign/extract.md +74 -0
  19. package/.claude/skills/monodesign/harden.md +65 -0
  20. package/.claude/skills/monodesign/init.md +30 -0
  21. package/.claude/skills/monodesign/layout.md +36 -0
  22. package/.claude/skills/monodesign/live.md +34 -0
  23. package/.claude/skills/monodesign/onboard.md +50 -0
  24. package/.claude/skills/monodesign/optimize.md +64 -0
  25. package/.claude/skills/monodesign/overdrive.md +56 -0
  26. package/.claude/skills/monodesign/polish.md +68 -0
  27. package/.claude/skills/monodesign/quieter.md +57 -0
  28. package/.claude/skills/monodesign/reference/adapt.md +312 -0
  29. package/.claude/skills/monodesign/reference/adapt.native.md +58 -0
  30. package/.claude/skills/monodesign/reference/android.md +40 -0
  31. package/.claude/skills/monodesign/reference/animate.md +203 -0
  32. package/.claude/skills/monodesign/reference/antipatterns-catalog.md +410 -0
  33. package/.claude/skills/monodesign/reference/audit.md +135 -0
  34. package/.claude/skills/monodesign/reference/audit.native.md +139 -0
  35. package/.claude/skills/monodesign/reference/bolder.md +120 -0
  36. package/.claude/skills/monodesign/reference/brand-workflow.md +180 -0
  37. package/.claude/skills/monodesign/reference/brand.md +108 -0
  38. package/.claude/skills/monodesign/reference/clarify.md +288 -0
  39. package/.claude/skills/monodesign/reference/codex.md +105 -0
  40. package/.claude/skills/monodesign/reference/cognitive-load.md +106 -0
  41. package/.claude/skills/monodesign/reference/color-and-contrast.md +105 -0
  42. package/.claude/skills/monodesign/reference/colorize.md +257 -0
  43. package/.claude/skills/monodesign/reference/component-specs.md +260 -0
  44. package/.claude/skills/monodesign/reference/component-states.md +274 -0
  45. package/.claude/skills/monodesign/reference/component-system.md +358 -0
  46. package/.claude/skills/monodesign/reference/copy-formulas.md +160 -0
  47. package/.claude/skills/monodesign/reference/craft.md +123 -0
  48. package/.claude/skills/monodesign/reference/critique.md +780 -0
  49. package/.claude/skills/monodesign/reference/delight.md +302 -0
  50. package/.claude/skills/monodesign/reference/design-principles.md +246 -0
  51. package/.claude/skills/monodesign/reference/distill.md +111 -0
  52. package/.claude/skills/monodesign/reference/document.md +429 -0
  53. package/.claude/skills/monodesign/reference/extract.md +69 -0
  54. package/.claude/skills/monodesign/reference/harden.md +347 -0
  55. package/.claude/skills/monodesign/reference/heuristics-scoring.md +234 -0
  56. package/.claude/skills/monodesign/reference/hooks.md +92 -0
  57. package/.claude/skills/monodesign/reference/image-prompts.md +130 -0
  58. package/.claude/skills/monodesign/reference/init.md +221 -0
  59. package/.claude/skills/monodesign/reference/interaction-design.md +189 -0
  60. package/.claude/skills/monodesign/reference/ios.md +45 -0
  61. package/.claude/skills/monodesign/reference/layout.md +185 -0
  62. package/.claude/skills/monodesign/reference/live.md +710 -0
  63. package/.claude/skills/monodesign/reference/motion-design.md +109 -0
  64. package/.claude/skills/monodesign/reference/onboard.md +234 -0
  65. package/.claude/skills/monodesign/reference/optimize.md +258 -0
  66. package/.claude/skills/monodesign/reference/overdrive.md +130 -0
  67. package/.claude/skills/monodesign/reference/personas.md +179 -0
  68. package/.claude/skills/monodesign/reference/polish.md +241 -0
  69. package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +108 -0
  70. package/.claude/skills/monodesign/reference/product.md +60 -0
  71. package/.claude/skills/monodesign/reference/quieter.md +99 -0
  72. package/.claude/skills/monodesign/reference/responsive-design.md +114 -0
  73. package/.claude/skills/monodesign/reference/shape.md +165 -0
  74. package/.claude/skills/monodesign/reference/spatial-design.md +100 -0
  75. package/.claude/skills/monodesign/reference/teach.md +10 -0
  76. package/.claude/skills/monodesign/reference/token-architecture.md +222 -0
  77. package/.claude/skills/monodesign/reference/typeset.md +301 -0
  78. package/.claude/skills/monodesign/reference/typography.md +159 -0
  79. package/.claude/skills/monodesign/reference/ux-research.md +143 -0
  80. package/.claude/skills/monodesign/reference/ux-rules.md +211 -0
  81. package/.claude/skills/monodesign/reference/ux-writing.md +107 -0
  82. package/.claude/skills/monodesign/scripts/command-metadata.json +94 -0
  83. package/.claude/skills/monodesign/scripts/context-signals.mjs +260 -0
  84. package/.claude/skills/monodesign/scripts/context.mjs +1065 -0
  85. package/.claude/skills/monodesign/scripts/critique-storage.mjs +416 -0
  86. package/.claude/skills/monodesign/scripts/detect-csp.mjs +193 -0
  87. package/.claude/skills/monodesign/scripts/detect.mjs +33 -0
  88. package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +1960 -0
  89. package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +321 -0
  90. package/.claude/skills/monodesign/scripts/detector/design-system.mjs +814 -0
  91. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +5628 -0
  92. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +50 -0
  93. package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +259 -0
  94. package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +339 -0
  95. package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +636 -0
  96. package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +1016 -0
  97. package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +253 -0
  98. package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +198 -0
  99. package/.claude/skills/monodesign/scripts/detector/findings.mjs +12 -0
  100. package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +181 -0
  101. package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +373 -0
  102. package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +426 -0
  103. package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +198 -0
  104. package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +166 -0
  105. package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +563 -0
  106. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +3024 -0
  107. package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +124 -0
  108. package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +101 -0
  109. package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +30 -0
  110. package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +148 -0
  111. package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +7 -0
  112. package/.claude/skills/monodesign/scripts/hook-admin.mjs +694 -0
  113. package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +516 -0
  114. package/.claude/skills/monodesign/scripts/hook-lib.mjs +1785 -0
  115. package/.claude/skills/monodesign/scripts/hook.mjs +61 -0
  116. package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +809 -0
  117. package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +69 -0
  118. package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +640 -0
  119. package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +129 -0
  120. package/.claude/skills/monodesign/scripts/lib/provider.mjs +4 -0
  121. package/.claude/skills/monodesign/scripts/lib/target-args.mjs +42 -0
  122. package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +50 -0
  123. package/.claude/skills/monodesign/scripts/live/completion.mjs +19 -0
  124. package/.claude/skills/monodesign/scripts/live/event-validation.mjs +137 -0
  125. package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +458 -0
  126. package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +939 -0
  127. package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +357 -0
  128. package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +152 -0
  129. package/.claude/skills/monodesign/scripts/live/session-store.mjs +293 -0
  130. package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +826 -0
  131. package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +279 -0
  132. package/.claude/skills/monodesign/scripts/live/ui-core.mjs +180 -0
  133. package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +36 -0
  134. package/.claude/skills/monodesign/scripts/live-accept.mjs +812 -0
  135. package/.claude/skills/monodesign/scripts/live-browser-dom.js +147 -0
  136. package/.claude/skills/monodesign/scripts/live-browser-session.js +124 -0
  137. package/.claude/skills/monodesign/scripts/live-browser.js +11213 -0
  138. package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +1241 -0
  139. package/.claude/skills/monodesign/scripts/live-complete.mjs +75 -0
  140. package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +683 -0
  141. package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +51 -0
  142. package/.claude/skills/monodesign/scripts/live-inject.mjs +596 -0
  143. package/.claude/skills/monodesign/scripts/live-insert.mjs +272 -0
  144. package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +363 -0
  145. package/.claude/skills/monodesign/scripts/live-poll.mjs +384 -0
  146. package/.claude/skills/monodesign/scripts/live-resume.mjs +94 -0
  147. package/.claude/skills/monodesign/scripts/live-server.mjs +1210 -0
  148. package/.claude/skills/monodesign/scripts/live-status.mjs +61 -0
  149. package/.claude/skills/monodesign/scripts/live-target.mjs +30 -0
  150. package/.claude/skills/monodesign/scripts/live-wrap.mjs +884 -0
  151. package/.claude/skills/monodesign/scripts/live.mjs +297 -0
  152. package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +14 -0
  153. package/.claude/skills/monodesign/scripts/palette.mjs +635 -0
  154. package/.claude/skills/monodesign/scripts/pin.mjs +221 -0
  155. package/.claude/skills/monodesign/shape.md +71 -0
  156. package/.claude/skills/monodesign/teach.md +18 -0
  157. package/.claude/skills/monodesign/typeset.md +59 -0
  158. package/README.md +1 -1
  159. package/dist/src/capabilities/cap-code.d.ts.map +1 -1
  160. package/dist/src/capabilities/cap-code.js +10 -5
  161. package/dist/src/capabilities/cap-code.js.map +1 -1
  162. package/dist/src/capabilities/manager.d.ts +2 -1
  163. package/dist/src/capabilities/manager.d.ts.map +1 -1
  164. package/dist/src/capabilities/manager.js +4 -1
  165. package/dist/src/capabilities/manager.js.map +1 -1
  166. package/dist/src/commands/doctor-project-checks.js +1 -1
  167. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  168. package/dist/src/commands/init-wizard.d.ts.map +1 -1
  169. package/dist/src/commands/init-wizard.js +2 -0
  170. package/dist/src/commands/init-wizard.js.map +1 -1
  171. package/dist/src/commands/init.d.ts.map +1 -1
  172. package/dist/src/commands/init.js +25 -26
  173. package/dist/src/commands/init.js.map +1 -1
  174. package/dist/src/commands/org-observe.d.ts.map +1 -1
  175. package/dist/src/commands/org-observe.js +5 -9
  176. package/dist/src/commands/org-observe.js.map +1 -1
  177. package/dist/src/commands/org-run-end.d.ts +26 -0
  178. package/dist/src/commands/org-run-end.d.ts.map +1 -0
  179. package/dist/src/commands/org-run-end.js +40 -0
  180. package/dist/src/commands/org-run-end.js.map +1 -0
  181. package/dist/src/commands/org.d.ts +2 -1
  182. package/dist/src/commands/org.d.ts.map +1 -1
  183. package/dist/src/commands/org.js +36 -15
  184. package/dist/src/commands/org.js.map +1 -1
  185. package/dist/src/commands/search-universal.d.ts.map +1 -1
  186. package/dist/src/commands/search-universal.js +1 -2
  187. package/dist/src/commands/search-universal.js.map +1 -1
  188. package/dist/src/init/executor.d.ts.map +1 -1
  189. package/dist/src/init/executor.js +7 -0
  190. package/dist/src/init/executor.js.map +1 -1
  191. package/dist/src/init/init-memory.d.ts +14 -0
  192. package/dist/src/init/init-memory.d.ts.map +1 -0
  193. package/dist/src/init/init-memory.js +44 -0
  194. package/dist/src/init/init-memory.js.map +1 -0
  195. package/dist/src/init/types.d.ts +13 -0
  196. package/dist/src/init/types.d.ts.map +1 -1
  197. package/dist/src/init/types.js.map +1 -1
  198. package/dist/src/init/upgrade.d.ts.map +1 -1
  199. package/dist/src/init/upgrade.js +9 -0
  200. package/dist/src/init/upgrade.js.map +1 -1
  201. package/dist/src/orgrt/agent-runner.d.ts +7 -0
  202. package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
  203. package/dist/src/orgrt/agent-runner.js +5 -1
  204. package/dist/src/orgrt/agent-runner.js.map +1 -1
  205. package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -1
  206. package/dist/src/orgrt/antigravity-runner.js +8 -14
  207. package/dist/src/orgrt/antigravity-runner.js.map +1 -1
  208. package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -1
  209. package/dist/src/orgrt/checkpoint-ops.js +2 -1
  210. package/dist/src/orgrt/checkpoint-ops.js.map +1 -1
  211. package/dist/src/orgrt/checkpoint.d.ts +10 -2
  212. package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
  213. package/dist/src/orgrt/checkpoint.js +8 -2
  214. package/dist/src/orgrt/checkpoint.js.map +1 -1
  215. package/dist/src/orgrt/codex-runner.d.ts.map +1 -1
  216. package/dist/src/orgrt/codex-runner.js +8 -14
  217. package/dist/src/orgrt/codex-runner.js.map +1 -1
  218. package/dist/src/orgrt/completion-gate.d.ts +6 -0
  219. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  220. package/dist/src/orgrt/completion-gate.js +18 -0
  221. package/dist/src/orgrt/completion-gate.js.map +1 -1
  222. package/dist/src/orgrt/copilot-runner.d.ts.map +1 -1
  223. package/dist/src/orgrt/copilot-runner.js +7 -10
  224. package/dist/src/orgrt/copilot-runner.js.map +1 -1
  225. package/dist/src/orgrt/crush-runner.d.ts.map +1 -1
  226. package/dist/src/orgrt/crush-runner.js +7 -10
  227. package/dist/src/orgrt/crush-runner.js.map +1 -1
  228. package/dist/src/orgrt/cumulative-meter.d.ts +26 -0
  229. package/dist/src/orgrt/cumulative-meter.d.ts.map +1 -0
  230. package/dist/src/orgrt/cumulative-meter.js +46 -0
  231. package/dist/src/orgrt/cumulative-meter.js.map +1 -0
  232. package/dist/src/orgrt/daemon.d.ts +6 -2
  233. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  234. package/dist/src/orgrt/daemon.js +25 -27
  235. package/dist/src/orgrt/daemon.js.map +1 -1
  236. package/dist/src/orgrt/dashboard-health.d.ts +54 -0
  237. package/dist/src/orgrt/dashboard-health.d.ts.map +1 -0
  238. package/dist/src/orgrt/dashboard-health.js +143 -0
  239. package/dist/src/orgrt/dashboard-health.js.map +1 -0
  240. package/dist/src/orgrt/decisions.d.ts +6 -1
  241. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  242. package/dist/src/orgrt/decisions.js +33 -5
  243. package/dist/src/orgrt/decisions.js.map +1 -1
  244. package/dist/src/orgrt/forwarder.d.ts +2 -1
  245. package/dist/src/orgrt/forwarder.d.ts.map +1 -1
  246. package/dist/src/orgrt/forwarder.js +87 -27
  247. package/dist/src/orgrt/forwarder.js.map +1 -1
  248. package/dist/src/orgrt/grok-runner.d.ts.map +1 -1
  249. package/dist/src/orgrt/grok-runner.js +7 -12
  250. package/dist/src/orgrt/grok-runner.js.map +1 -1
  251. package/dist/src/orgrt/hermes-runner.d.ts.map +1 -1
  252. package/dist/src/orgrt/hermes-runner.js +9 -15
  253. package/dist/src/orgrt/hermes-runner.js.map +1 -1
  254. package/dist/src/orgrt/kimicode-runner.d.ts +1 -1
  255. package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
  256. package/dist/src/orgrt/kimicode-runner.js +9 -15
  257. package/dist/src/orgrt/kimicode-runner.js.map +1 -1
  258. package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
  259. package/dist/src/orgrt/opencode-runner.js +7 -13
  260. package/dist/src/orgrt/opencode-runner.js.map +1 -1
  261. package/dist/src/orgrt/org-harness-tools.d.ts +8 -0
  262. package/dist/src/orgrt/org-harness-tools.d.ts.map +1 -0
  263. package/dist/src/orgrt/org-harness-tools.js +21 -0
  264. package/dist/src/orgrt/org-harness-tools.js.map +1 -0
  265. package/dist/src/orgrt/pi-rpc-runner.d.ts.map +1 -1
  266. package/dist/src/orgrt/pi-rpc-runner.js +9 -13
  267. package/dist/src/orgrt/pi-rpc-runner.js.map +1 -1
  268. package/dist/src/orgrt/pi-runner.d.ts.map +1 -1
  269. package/dist/src/orgrt/pi-runner.js +7 -11
  270. package/dist/src/orgrt/pi-runner.js.map +1 -1
  271. package/dist/src/orgrt/policy-git.d.ts +5 -1
  272. package/dist/src/orgrt/policy-git.d.ts.map +1 -1
  273. package/dist/src/orgrt/policy-git.js +56 -29
  274. package/dist/src/orgrt/policy-git.js.map +1 -1
  275. package/dist/src/orgrt/policy.d.ts +7 -0
  276. package/dist/src/orgrt/policy.d.ts.map +1 -1
  277. package/dist/src/orgrt/policy.js +10 -1
  278. package/dist/src/orgrt/policy.js.map +1 -1
  279. package/dist/src/orgrt/prompt-vars.d.ts +8 -1
  280. package/dist/src/orgrt/prompt-vars.d.ts.map +1 -1
  281. package/dist/src/orgrt/prompt-vars.js +60 -11
  282. package/dist/src/orgrt/prompt-vars.js.map +1 -1
  283. package/dist/src/orgrt/qwen-rpc-runner.d.ts.map +1 -1
  284. package/dist/src/orgrt/qwen-rpc-runner.js +9 -14
  285. package/dist/src/orgrt/qwen-rpc-runner.js.map +1 -1
  286. package/dist/src/orgrt/qwen-runner.d.ts.map +1 -1
  287. package/dist/src/orgrt/qwen-runner.js +7 -12
  288. package/dist/src/orgrt/qwen-runner.js.map +1 -1
  289. package/dist/src/orgrt/report-budget.d.ts +4 -0
  290. package/dist/src/orgrt/report-budget.d.ts.map +1 -0
  291. package/dist/src/orgrt/report-budget.js +12 -0
  292. package/dist/src/orgrt/report-budget.js.map +1 -0
  293. package/dist/src/orgrt/reporting.d.ts +4 -0
  294. package/dist/src/orgrt/reporting.d.ts.map +1 -1
  295. package/dist/src/orgrt/reporting.js +8 -2
  296. package/dist/src/orgrt/reporting.js.map +1 -1
  297. package/dist/src/orgrt/role-sandbox.d.ts +4 -1
  298. package/dist/src/orgrt/role-sandbox.d.ts.map +1 -1
  299. package/dist/src/orgrt/role-sandbox.js +24 -10
  300. package/dist/src/orgrt/role-sandbox.js.map +1 -1
  301. package/dist/src/orgrt/role-trace.d.ts +27 -0
  302. package/dist/src/orgrt/role-trace.d.ts.map +1 -0
  303. package/dist/src/orgrt/role-trace.js +28 -0
  304. package/dist/src/orgrt/role-trace.js.map +1 -0
  305. package/dist/src/orgrt/sandbox-deny-write.d.ts +52 -0
  306. package/dist/src/orgrt/sandbox-deny-write.d.ts.map +1 -0
  307. package/dist/src/orgrt/sandbox-deny-write.js +89 -0
  308. package/dist/src/orgrt/sandbox-deny-write.js.map +1 -0
  309. package/dist/src/orgrt/sandbox-fault.d.ts +40 -0
  310. package/dist/src/orgrt/sandbox-fault.d.ts.map +1 -0
  311. package/dist/src/orgrt/sandbox-fault.js +94 -0
  312. package/dist/src/orgrt/sandbox-fault.js.map +1 -0
  313. package/dist/src/orgrt/session.d.ts +4 -3
  314. package/dist/src/orgrt/session.d.ts.map +1 -1
  315. package/dist/src/orgrt/session.js +107 -64
  316. package/dist/src/orgrt/session.js.map +1 -1
  317. package/dist/src/orgrt/task-dag.d.ts +9 -1
  318. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  319. package/dist/src/orgrt/task-dag.js +6 -1
  320. package/dist/src/orgrt/task-dag.js.map +1 -1
  321. package/dist/src/orgrt/tool-fence.d.ts +21 -3
  322. package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
  323. package/dist/src/orgrt/tool-fence.js +45 -7
  324. package/dist/src/orgrt/tool-fence.js.map +1 -1
  325. package/dist/src/orgrt/tool-providers.d.ts +4 -0
  326. package/dist/src/orgrt/tool-providers.d.ts.map +1 -1
  327. package/dist/src/orgrt/tool-providers.js +10 -0
  328. package/dist/src/orgrt/tool-providers.js.map +1 -1
  329. package/dist/src/orgrt/types.d.ts +8 -0
  330. package/dist/src/orgrt/types.d.ts.map +1 -1
  331. package/dist/src/orgrt/types.js +11 -0
  332. package/dist/src/orgrt/types.js.map +1 -1
  333. package/dist/src/orgrt/vercel-runner.d.ts +23 -0
  334. package/dist/src/orgrt/vercel-runner.d.ts.map +1 -1
  335. package/dist/src/orgrt/vercel-runner.js +2 -26
  336. package/dist/src/orgrt/vercel-runner.js.map +1 -1
  337. package/dist/src/platform-adapters/merge.d.ts +11 -0
  338. package/dist/src/platform-adapters/merge.d.ts.map +1 -1
  339. package/dist/src/platform-adapters/merge.js +28 -0
  340. package/dist/src/platform-adapters/merge.js.map +1 -1
  341. package/dist/src/platform-adapters/mutation.d.ts +3 -0
  342. package/dist/src/platform-adapters/mutation.d.ts.map +1 -1
  343. package/dist/src/platform-adapters/mutation.js +43 -0
  344. package/dist/src/platform-adapters/mutation.js.map +1 -1
  345. package/dist/src/platform-adapters/operations.d.ts +1 -0
  346. package/dist/src/platform-adapters/operations.d.ts.map +1 -1
  347. package/dist/src/platform-adapters/operations.js +25 -9
  348. package/dist/src/platform-adapters/operations.js.map +1 -1
  349. package/dist/src/platform-adapters/renderers/skills.d.ts.map +1 -1
  350. package/dist/src/platform-adapters/renderers/skills.js +11 -2
  351. package/dist/src/platform-adapters/renderers/skills.js.map +1 -1
  352. package/dist/src/platform-adapters/shared-surface.d.ts +34 -0
  353. package/dist/src/platform-adapters/shared-surface.d.ts.map +1 -0
  354. package/dist/src/platform-adapters/shared-surface.js +89 -0
  355. package/dist/src/platform-adapters/shared-surface.js.map +1 -0
  356. package/dist/src/platform-adapters/types.d.ts +7 -0
  357. package/dist/src/platform-adapters/types.d.ts.map +1 -1
  358. package/dist/tsconfig.tsbuildinfo +1 -1
  359. package/package.json +7 -7
@@ -0,0 +1,253 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
5
+ import {
6
+ checkSourceDesignSystem,
7
+ collectStaticDesignSystemFindings,
8
+ mergeDesignSystemFindings,
9
+ } from '../../design-system.mjs';
10
+ import { isFullPage } from '../../shared/page.mjs';
11
+ import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
12
+ import { finding } from '../../findings.mjs';
13
+ import { profileFindings, profileStep, profileStepAsync } from '../../profile/profiler.mjs';
14
+ import {
15
+ checkElementBorders,
16
+ checkElementClippedOverflow,
17
+ checkElementColors,
18
+ checkElementGlow,
19
+ checkElementGptBorderShadow,
20
+ checkElementHeroEyebrow,
21
+ checkElementIconTile,
22
+ checkElementItalicSerif,
23
+ checkElementMotion,
24
+ checkElementOversizedH1,
25
+ checkElementQuality,
26
+ checkCreamPalette,
27
+ checkHtmlPatterns,
28
+ checkPageLayout,
29
+ checkPageQualityFromDoc,
30
+ checkRepeatedSectionKickersFromDoc,
31
+ checkElementImageDimensions,
32
+ checkElementSmallTouchTarget,
33
+ checkFocusVisible,
34
+ checkHoverOnlyAffordance,
35
+ checkDarkSchemeContrast,
36
+ resolveBackground,
37
+ resolveBorderRadiusPx,
38
+ } from '../../rules/checks.mjs';
39
+ import { filterByProviders } from '../../registry/antipatterns.mjs';
40
+ import { detectText, runTextContentAnalyzers } from '../regex/detect-text.mjs';
41
+ import {
42
+ StaticDocument,
43
+ buildStaticStyleMap,
44
+ buildStaticWindow,
45
+ collectStaticCssText,
46
+ } from './css-cascade.mjs';
47
+
48
+ function checkStaticPageTypography(document, window) {
49
+ const findings = [];
50
+ const fonts = new Set();
51
+ const overusedFound = new Set();
52
+ for (const el of document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, td, th, dd, blockquote, figcaption, a, button, label, span, div')) {
53
+ const hasText = el.childNodes.some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
54
+ if (!hasText) continue;
55
+ const ff = window.getComputedStyle(el).fontFamily || '';
56
+ const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
57
+ const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
58
+ if (!primary) continue;
59
+ fonts.add(primary);
60
+ if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
61
+ }
62
+ for (const font of overusedFound) {
63
+ findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
64
+ }
65
+ if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
66
+ findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
67
+ }
68
+ const sizes = new Set();
69
+ for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
70
+ const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
71
+ if (fontSize >= 8 && fontSize < 200) sizes.add(Math.round(fontSize * 10) / 10);
72
+ }
73
+ if (sizes.size >= 3) {
74
+ const sorted = [...sizes].sort((a, b) => a - b);
75
+ const ratio = sorted[sorted.length - 1] / sorted[0];
76
+ if (ratio < 2.0) {
77
+ findings.push({ id: 'flat-type-hierarchy', snippet: `Sizes: ${sorted.map(s => `${s}px`).join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
78
+ }
79
+ }
80
+ return findings;
81
+ }
82
+
83
+ function checkElementBrokenImage(el) {
84
+ const src = el.getAttribute?.('src') ?? el.attribs?.src;
85
+ // Missing src attribute entirely
86
+ if (src === undefined || src === null) {
87
+ return [{ id: 'broken-image', snippet: '<img> with no src attribute' }];
88
+ }
89
+ const trimmed = String(src).trim();
90
+ // Empty or placeholder-only src values
91
+ if (trimmed === '' || trimmed === '#') {
92
+ return [{ id: 'broken-image', snippet: `<img src="${src}">` }];
93
+ }
94
+ return [];
95
+ }
96
+
97
+ const STATIC_ELEMENT_RULES = [
98
+ { id: 'border-rules', selector: '*', run: (el, tag, style, window, _customPropMap) => checkElementBorders(tag, style, null, resolveBorderRadiusPx(el, style, parseFloat(style.width) || 0, window)) },
99
+ { id: 'color-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementColors(el, style, tag, window, customPropMap, false) },
100
+ { id: 'dark-glow', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementGlow(tag, style, resolveBackground(el.parentElement || el, window, customPropMap)) },
101
+ { id: 'motion-rules', selector: '*', run: (_el, tag, style) => checkElementMotion(tag, style) },
102
+ { id: 'icon-tile-stack', selector: 'h1,h2,h3,h4,h5,h6', run: (el, tag, _style, window) => checkElementIconTile(el, tag, window) },
103
+ { id: 'italic-serif-display', selector: 'h1,h2', run: (el, tag, style) => checkElementItalicSerif(el, style, tag) },
104
+ { id: 'hero-eyebrow-chip', selector: 'h1', run: (el, tag, style, window, customPropMap) => checkElementHeroEyebrow(el, style, tag, window, customPropMap) },
105
+ { id: 'broken-image', selector: 'img', run: (el) => checkElementBrokenImage(el) },
106
+ { id: 'quality-rules', selector: '*', run: (el, tag, style, window) => checkElementQuality(el, style, tag, window) },
107
+ { id: 'oversized-h1', selector: 'h1', run: (el, tag, style, window) => checkElementOversizedH1(el, style, tag, window) },
108
+ { id: 'clipped-overflow-container', selector: '*', run: (el, tag, style, window) => checkElementClippedOverflow(el, style, tag, window) },
109
+ { id: 'gpt-thin-border-wide-shadow', selector: '*', run: (el, _tag, style) => checkElementGptBorderShadow(el, style) },
110
+ { id: 'image-missing-dimensions', selector: 'img', run: (el, _tag, style) => checkElementImageDimensions(el, style) },
111
+ { id: 'small-touch-target', selector: 'a,button,input,select,summary,[role=button],[role=link],[role=menuitem],[role=tab],[role=switch]', run: (el, tag, style) => checkElementSmallTouchTarget(el, style, tag) },
112
+ ];
113
+
114
+ async function detectHtml(filePath, options = {}) {
115
+ const profile = options?.profile;
116
+ const html = profileStep(profile, {
117
+ engine: 'static-html',
118
+ phase: 'setup',
119
+ ruleId: 'read-html',
120
+ target: filePath,
121
+ }, () => fs.readFileSync(filePath, 'utf-8'));
122
+
123
+ let modules;
124
+ try {
125
+ modules = await profileStepAsync(profile, {
126
+ engine: 'static-html',
127
+ phase: 'setup',
128
+ ruleId: 'import-static-parser',
129
+ target: filePath,
130
+ }, async () => {
131
+ const [htmlparser2, cssSelect, csstree, domutils] = await Promise.all([
132
+ import('htmlparser2'),
133
+ import('css-select'),
134
+ import('css-tree'),
135
+ import('domutils'),
136
+ ]);
137
+ return {
138
+ parseDocument: htmlparser2.parseDocument,
139
+ selectAll: cssSelect.selectAll,
140
+ selectOne: cssSelect.selectOne,
141
+ is: cssSelect.is,
142
+ csstree,
143
+ domutils,
144
+ };
145
+ });
146
+ } catch {
147
+ return detectText(html, filePath, options);
148
+ }
149
+
150
+ const resolvedPath = path.resolve(filePath);
151
+ const fileDir = path.dirname(resolvedPath);
152
+ const root = profileStep(profile, {
153
+ engine: 'static-html',
154
+ phase: 'parse-html',
155
+ ruleId: 'parse-document',
156
+ target: filePath,
157
+ }, () => modules.parseDocument(html, { lowerCaseAttributeNames: false, lowerCaseTags: true }));
158
+
159
+ const cssText = collectStaticCssText(root, fileDir, profile, filePath, modules);
160
+ const document = new StaticDocument(root, modules);
161
+ buildStaticStyleMap(root, document, cssText, modules, profile, filePath);
162
+ const window = buildStaticWindow(document);
163
+
164
+ const customPropMap = null;
165
+
166
+ const findings = [];
167
+ const runElementCheck = (ruleId, callback) => profile
168
+ ? profileFindings(profile, { engine: 'static-html', phase: 'element', ruleId, target: filePath }, callback)
169
+ : callback();
170
+
171
+ const visitedByRule = new Map();
172
+ for (const rule of STATIC_ELEMENT_RULES) {
173
+ const elements = document.querySelectorAll(rule.selector);
174
+ visitedByRule.set(rule.id, elements.length);
175
+ for (const el of elements) {
176
+ const tag = el.tagName.toLowerCase();
177
+ const style = window.getComputedStyle(el);
178
+ for (const f of runElementCheck(rule.id, () => rule.run(el, tag, style, window, customPropMap))) {
179
+ findings.push(finding(f.id, filePath, f.snippet));
180
+ }
181
+ }
182
+ }
183
+
184
+ if (options?.designSystem) {
185
+ const sourceDesignFindings = profileFindings(profile, {
186
+ engine: 'static-html',
187
+ phase: 'source',
188
+ ruleId: 'design-system',
189
+ target: filePath,
190
+ }, () => checkSourceDesignSystem(html, filePath, { designSystem: options.designSystem }));
191
+ const staticDesignFindings = profileFindings(profile, {
192
+ engine: 'static-html',
193
+ phase: 'page',
194
+ ruleId: 'design-system',
195
+ target: filePath,
196
+ }, () => collectStaticDesignSystemFindings(document, window, filePath, options.designSystem));
197
+ findings.push(...mergeDesignSystemFindings(staticDesignFindings, sourceDesignFindings));
198
+ }
199
+
200
+ if (isFullPage(html)) {
201
+ const runPageCheck = (ruleId, callback) => profile
202
+ ? profileFindings(profile, { engine: 'static-html', phase: 'page', ruleId, target: filePath }, callback)
203
+ : callback();
204
+ for (const f of runPageCheck('typography-rules', () => checkStaticPageTypography(document, window))) {
205
+ findings.push(finding(f.id, filePath, f.snippet));
206
+ }
207
+ for (const f of runPageCheck('repeated-section-kickers', () => checkRepeatedSectionKickersFromDoc(document, window))) {
208
+ findings.push(finding(f.id, filePath, f.snippet));
209
+ }
210
+ for (const f of runPageCheck('layout-rules', () => checkPageLayout(document, window))) {
211
+ findings.push(finding(f.id, filePath, f.snippet));
212
+ }
213
+ for (const f of runPageCheck('cream-palette', () => checkCreamPalette(document, window))) {
214
+ findings.push(finding(f.id, filePath, f.snippet));
215
+ }
216
+ for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
217
+ findings.push(finding(f.id, filePath, f.snippet));
218
+ }
219
+ // Stylesheet-level accessibility rules operate on the concatenated CSS
220
+ // text (<style> blocks + linked sheets) — :hover / :focus-visible /
221
+ // prefers-color-scheme conditions can't be read off a resting element.
222
+ for (const f of runPageCheck('missing-focus-visible', () => checkFocusVisible(cssText))) {
223
+ findings.push(finding(f.id, filePath, f.snippet));
224
+ }
225
+ for (const f of runPageCheck('hover-only-affordance', () => checkHoverOnlyAffordance(cssText))) {
226
+ findings.push(finding(f.id, filePath, f.snippet));
227
+ }
228
+ for (const f of runPageCheck('dark-scheme-contrast-blindspot', () => checkDarkSchemeContrast(cssText))) {
229
+ findings.push(finding(f.id, filePath, f.snippet));
230
+ }
231
+ for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html).filter(item =>
232
+ item.id !== 'bounce-easing' && item.id !== 'layout-transition'
233
+ ))) {
234
+ findings.push(finding(f.id, filePath, f.snippet));
235
+ }
236
+ // Text-content analyzers (em-dash overuse, marketing buzzwords,
237
+ // numbered section markers, aphoristic cadence) live in the regex
238
+ // engine. Call them from here so .html files get the same coverage
239
+ // as .css/.tsx files. These are scoped to text content only and
240
+ // don't overlap with static-html's element/page rules.
241
+ for (const f of runPageCheck('text-content', () => runTextContentAnalyzers(html, filePath, options))) {
242
+ findings.push(finding(f.antipattern, filePath, f.snippet));
243
+ }
244
+ }
245
+
246
+ const byProvider = filterByProviders(findings, options.providers);
247
+ // Static-HTML findings carry no line number, so only whole-file
248
+ // `monodesign-disable` directives apply here — exactly the standalone-document
249
+ // waiver this primitive targets. Bypassed by `--no-config` / `--no-inline-ignores`.
250
+ return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, html);
251
+ }
252
+
253
+ export { checkStaticPageTypography, STATIC_ELEMENT_RULES, detectHtml };
@@ -0,0 +1,198 @@
1
+ //
2
+ // Visual-contrast pixel fallback. `page` is the driver page abstraction from
3
+ // ../browser/drivers.mjs (a raw puppeteer Page also satisfies it): it only
4
+ // needs `evaluate(fn, arg)` roundtrips and `screenshot({ encoding: 'base64',
5
+ // clip, captureBeyondViewport })` returning a base64 PNG string. The logic is
6
+ // driver-agnostic: hide the glyphs via CSS, screenshot the clip twice, and
7
+ // diff the pixels in-page on a canvas. Both the monobrowse (CDP
8
+ // Page.captureScreenshot + Runtime.evaluate) and puppeteer drivers support
9
+ // this fully.
10
+ function sanitizeScreenshotClip(clip, viewport) {
11
+ if (!clip) return null;
12
+ const x = Math.max(0, Math.floor(clip.x || 0));
13
+ const y = Math.max(0, Math.floor(clip.y || 0));
14
+ const width = Math.min(
15
+ Math.max(1, Math.ceil(clip.width || 0)),
16
+ Math.max(1, viewport?.width || 1600),
17
+ );
18
+ const height = Math.min(
19
+ Math.max(1, Math.ceil(clip.height || 0)),
20
+ 320,
21
+ );
22
+ if (width < 1 || height < 1) return null;
23
+ return { x, y, width, height };
24
+ }
25
+
26
+ async function compareScreenshotContrast(page, beforeBase64, afterBase64, candidate) {
27
+ return page.evaluate(async ({ beforeBase64, afterBase64, candidate }) => {
28
+ const loadImage = (base64) => new Promise((resolve, reject) => {
29
+ const img = new Image();
30
+ img.onload = () => resolve(img);
31
+ img.onerror = () => reject(new Error('Could not decode contrast screenshot'));
32
+ img.src = `data:image/png;base64,${base64}`;
33
+ });
34
+ const [before, after] = await Promise.all([loadImage(beforeBase64), loadImage(afterBase64)]);
35
+ const width = Math.min(before.width, after.width);
36
+ const height = Math.min(before.height, after.height);
37
+ if (width < 1 || height < 1) return null;
38
+
39
+ const canvas = document.createElement('canvas');
40
+ canvas.width = width;
41
+ canvas.height = height;
42
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
43
+ if (!ctx) return null;
44
+
45
+ ctx.drawImage(before, 0, 0, width, height);
46
+ const beforePixels = ctx.getImageData(0, 0, width, height).data;
47
+ ctx.clearRect(0, 0, width, height);
48
+ ctx.drawImage(after, 0, 0, width, height);
49
+ const afterPixels = ctx.getImageData(0, 0, width, height).data;
50
+
51
+ const luminance = ({ r, g, b }) => {
52
+ const convert = c => {
53
+ const v = c / 255;
54
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
55
+ };
56
+ return 0.2126 * convert(r) + 0.7152 * convert(g) + 0.0722 * convert(b);
57
+ };
58
+ const ratio = (a, b) => {
59
+ const l1 = luminance(a);
60
+ const l2 = luminance(b);
61
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
62
+ };
63
+
64
+ const cssTextColor = candidate.textColor && !candidate.preferRenderedForeground
65
+ ? {
66
+ r: candidate.textColor.r,
67
+ g: candidate.textColor.g,
68
+ b: candidate.textColor.b,
69
+ }
70
+ : null;
71
+ const ratios = [];
72
+ let glyphPixels = 0;
73
+ let strongestDelta = 0;
74
+ for (let i = 0; i < beforePixels.length; i += 4) {
75
+ const delta = Math.abs(beforePixels[i] - afterPixels[i])
76
+ + Math.abs(beforePixels[i + 1] - afterPixels[i + 1])
77
+ + Math.abs(beforePixels[i + 2] - afterPixels[i + 2])
78
+ + Math.abs(beforePixels[i + 3] - afterPixels[i + 3]);
79
+ strongestDelta = Math.max(strongestDelta, delta);
80
+ if (delta < 10) continue;
81
+ glyphPixels++;
82
+ const fg = cssTextColor || {
83
+ r: beforePixels[i],
84
+ g: beforePixels[i + 1],
85
+ b: beforePixels[i + 2],
86
+ };
87
+ const bg = {
88
+ r: afterPixels[i],
89
+ g: afterPixels[i + 1],
90
+ b: afterPixels[i + 2],
91
+ };
92
+ ratios.push(ratio(fg, bg));
93
+ }
94
+
95
+ if (ratios.length < 8) {
96
+ return {
97
+ glyphPixels,
98
+ strongestDelta,
99
+ worstRatio: null,
100
+ p10Ratio: null,
101
+ medianRatio: null,
102
+ };
103
+ }
104
+
105
+ ratios.sort((a, b) => a - b);
106
+ const pick = pct => ratios[Math.min(ratios.length - 1, Math.max(0, Math.floor((pct / 100) * ratios.length)))];
107
+ return {
108
+ glyphPixels,
109
+ strongestDelta,
110
+ worstRatio: ratios[0],
111
+ p10Ratio: pick(10),
112
+ medianRatio: pick(50),
113
+ };
114
+ }, { beforeBase64, afterBase64, candidate });
115
+ }
116
+
117
+ async function captureVisualContrastCandidate(page, candidate, viewport) {
118
+ const clip = sanitizeScreenshotClip(candidate.clip, viewport);
119
+ if (!clip) return null;
120
+
121
+ const beforeBase64 = await page.screenshot({
122
+ encoding: 'base64',
123
+ clip,
124
+ captureBeyondViewport: true,
125
+ });
126
+ const token = `monodesign-contrast-${Date.now()}-${Math.random().toString(36).slice(2)}`;
127
+ const applied = await page.evaluate(({ selector, token, backgroundClipText }) => {
128
+ let el;
129
+ try {
130
+ el = document.querySelector(selector);
131
+ } catch {
132
+ return false;
133
+ }
134
+ if (!el) return false;
135
+ let style = document.getElementById('monodesign-visual-contrast-hide-style');
136
+ if (!style) {
137
+ style = document.createElement('style');
138
+ style.id = 'monodesign-visual-contrast-hide-style';
139
+ style.textContent = [
140
+ '[data-monodesign-visual-contrast-target] {',
141
+ ' color: transparent !important;',
142
+ ' -webkit-text-fill-color: transparent !important;',
143
+ ' text-shadow: none !important;',
144
+ '}',
145
+ '[data-monodesign-visual-contrast-target][data-monodesign-bgclip-text="true"] {',
146
+ ' background-image: none !important;',
147
+ '}',
148
+ ].join('\n');
149
+ document.head.appendChild(style);
150
+ }
151
+ el.setAttribute('data-monodesign-visual-contrast-target', token);
152
+ if (backgroundClipText) el.setAttribute('data-monodesign-bgclip-text', 'true');
153
+ return true;
154
+ }, {
155
+ selector: candidate.selector,
156
+ token,
157
+ backgroundClipText: candidate.backgroundClipText,
158
+ });
159
+ if (!applied) return null;
160
+
161
+ let afterBase64;
162
+ try {
163
+ afterBase64 = await page.screenshot({
164
+ encoding: 'base64',
165
+ clip,
166
+ captureBeyondViewport: true,
167
+ });
168
+ } finally {
169
+ await page.evaluate(({ selector }) => {
170
+ try {
171
+ const el = document.querySelector(selector);
172
+ if (el) {
173
+ el.removeAttribute('data-monodesign-visual-contrast-target');
174
+ el.removeAttribute('data-monodesign-bgclip-text');
175
+ }
176
+ } catch {
177
+ // Ignore invalid or stale selectors during cleanup.
178
+ }
179
+ }, { selector: candidate.selector }).catch(() => {});
180
+ }
181
+
182
+ const metrics = await compareScreenshotContrast(page, beforeBase64, afterBase64, candidate);
183
+ if (!metrics || !Number.isFinite(metrics.p10Ratio) || metrics.glyphPixels < 8) return null;
184
+ const measuredRatio = metrics.p10Ratio;
185
+ if (measuredRatio >= candidate.threshold) return null;
186
+ const textLabel = candidate.text ? ` "${candidate.text}"` : '';
187
+ const reasonLabel = (candidate.reasons || []).slice(0, 3).join(', ') || 'visual background';
188
+ return {
189
+ id: 'low-contrast',
190
+ snippet: `pixel contrast ${measuredRatio.toFixed(1)}:1 median ${metrics.medianRatio.toFixed(1)}:1 (need ${candidate.threshold}:1) on ${reasonLabel}${textLabel}`,
191
+ };
192
+ }
193
+
194
+ export {
195
+ sanitizeScreenshotClip,
196
+ compareScreenshotContrast,
197
+ captureVisualContrastCandidate,
198
+ };
@@ -0,0 +1,12 @@
1
+ import { getAntipattern } from './registry/antipatterns.mjs';
2
+
3
+ function getAP(id) {
4
+ return getAntipattern(id);
5
+ }
6
+
7
+ function finding(id, filePath, snippet, line = 0) {
8
+ const ap = getAP(id);
9
+ return { antipattern: id, name: ap.name, description: ap.description, severity: ap.severity || 'warning', file: filePath, line, snippet };
10
+ }
11
+
12
+ export { getAP, finding };
@@ -0,0 +1,181 @@
1
+ /**
2
+ * CSS region extraction and declaration scanning for the auto-fix engine.
3
+ *
4
+ * Fixers never parse a full DOM — they operate on the raw source text of the
5
+ * "CSS-shaped" regions of a file:
6
+ * - whole file for .css/.scss/.sass/.less
7
+ * - <style> blocks and style="" attributes for HTML-family files
8
+ * - styled-components / emotion template literals for JS/TS files
9
+ *
10
+ * All offsets returned here are absolute within the original file content, so
11
+ * edits computed against a region can be applied directly to the file.
12
+ */
13
+
14
+ const CSS_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
15
+ const HTML_FAMILY_EXTENSIONS = new Set(['.html', '.htm', '.vue', '.svelte', '.astro']);
16
+ const JS_EXTENSIONS = new Set(['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs']);
17
+
18
+ /**
19
+ * A region of file content that can be scanned as CSS declarations.
20
+ * kind:
21
+ * 'css' — full stylesheet syntax (selectors + blocks)
22
+ * 'style-attr' — a bare declaration list from a style="" attribute;
23
+ * selectorHint carries the owning tag name
24
+ */
25
+ function extractCssRegions(content, ext) {
26
+ ext = (ext || '').toLowerCase();
27
+ if (CSS_EXTENSIONS.has(ext)) {
28
+ return [{ start: 0, end: content.length, text: content, kind: 'css', selectorHint: null }];
29
+ }
30
+
31
+ const regions = [];
32
+ if (HTML_FAMILY_EXTENSIONS.has(ext)) {
33
+ const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
34
+ let m;
35
+ while ((m = styleBlockRe.exec(content)) !== null) {
36
+ const start = m.index + m[0].indexOf(m[1]);
37
+ regions.push({ start, end: start + m[1].length, text: m[1], kind: 'css', selectorHint: null });
38
+ }
39
+ const styleAttrRe = /<([a-zA-Z][\w-]*)\b[^>]*?\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi;
40
+ while ((m = styleAttrRe.exec(content)) !== null) {
41
+ const value = m[3] !== undefined ? m[3] : m[4];
42
+ if (!value) continue;
43
+ const start = m.index + m[0].length - value.length - 1; // inside the closing quote
44
+ regions.push({
45
+ start,
46
+ end: start + value.length,
47
+ text: value,
48
+ kind: 'style-attr',
49
+ selectorHint: m[1].toLowerCase(),
50
+ });
51
+ }
52
+ return regions;
53
+ }
54
+
55
+ if (JS_EXTENSIONS.has(ext)) {
56
+ const cssInJsRe = /(?:styled(?:\.\w+|\([^)]+\))|css)\s*`([\s\S]*?)`/g;
57
+ let m;
58
+ while ((m = cssInJsRe.exec(content)) !== null) {
59
+ const start = m.index + m[0].indexOf('`') + 1;
60
+ regions.push({ start, end: start + m[1].length, text: m[1], kind: 'css', selectorHint: null });
61
+ }
62
+ return regions;
63
+ }
64
+
65
+ return regions;
66
+ }
67
+
68
+ /**
69
+ * Find every `prop: value` declaration in a CSS-shaped text. Returns local
70
+ * offsets (relative to the given text):
71
+ * { declStart, valueStart, valueEnd, value, terminator }
72
+ * `value` is the raw trimmed value text (may include !important).
73
+ * `terminator` is the index just past the trailing `;` when present,
74
+ * otherwise valueEnd.
75
+ */
76
+ function findDeclarations(text, prop) {
77
+ const re = new RegExp(`(^|[{;])(\\s*)(${prop})\\s*:\\s*([^;{}]*)`, 'gi');
78
+ const results = [];
79
+ let m;
80
+ while ((m = re.exec(text)) !== null) {
81
+ const declStart = m.index + m[1].length + m[2].length;
82
+ const rawValue = m[4];
83
+ const trimmed = rawValue.replace(/\s+$/, '');
84
+ const valueStart = m.index + m[0].length - rawValue.length;
85
+ const valueEnd = valueStart + trimmed.length;
86
+ const terminator = text[m.index + m[0].length] === ';'
87
+ ? m.index + m[0].length + 1
88
+ : valueEnd;
89
+ results.push({ declStart, valueStart, valueEnd, value: trimmed.trim(), terminator });
90
+ }
91
+ return results;
92
+ }
93
+
94
+ /**
95
+ * The enclosing `{ ... }` block for a declaration at `index`, with its
96
+ * selector text. For bare declaration lists (style attributes) there is no
97
+ * block — the whole text is the body and selector is null.
98
+ */
99
+ function declBlockInfo(text, index) {
100
+ let i = index - 1;
101
+ let depth = 0;
102
+ while (i >= 0) {
103
+ const ch = text[i];
104
+ if (ch === '}') depth++;
105
+ else if (ch === '{') {
106
+ if (depth === 0) break;
107
+ depth--;
108
+ }
109
+ i--;
110
+ }
111
+ if (i < 0) {
112
+ return { bodyStart: 0, bodyEnd: text.length, body: text, selector: null };
113
+ }
114
+ const braceIdx = i;
115
+ let s = braceIdx - 1;
116
+ while (s >= 0 && !'};{'.includes(text[s])) s--;
117
+ const selector = text.slice(s + 1, braceIdx).trim();
118
+ let j = braceIdx + 1;
119
+ let d = 0;
120
+ while (j < text.length) {
121
+ const ch = text[j];
122
+ if (ch === '{') d++;
123
+ else if (ch === '}') {
124
+ if (d === 0) break;
125
+ d--;
126
+ }
127
+ j++;
128
+ }
129
+ return { bodyStart: braceIdx + 1, bodyEnd: j, body: text.slice(braceIdx + 1, j), selector };
130
+ }
131
+
132
+ /** Parse a single CSS length/number value, tolerating !important. */
133
+ function parseCssValue(raw) {
134
+ const important = /!\s*important/i.test(raw);
135
+ const cleaned = raw.replace(/!\s*important/i, '').trim();
136
+ const m = cleaned.match(/^(-?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i);
137
+ if (!m) return null;
138
+ return { num: parseFloat(m[1]), unit: (m[2] || '').toLowerCase(), important };
139
+ }
140
+
141
+ /** Resolve a block's font-size to px when statically computable, else null. */
142
+ function blockFontSizePx(body) {
143
+ const decls = findDeclarations(body, 'font-size');
144
+ if (decls.length === 0) return null;
145
+ const parsed = parseCssValue(decls[decls.length - 1].value);
146
+ if (!parsed) return null;
147
+ if (parsed.unit === 'px') return parsed.num;
148
+ if (parsed.unit === 'rem') return parsed.num * 16;
149
+ return null;
150
+ }
151
+
152
+ /** Split a CSS value list on top-level commas (paren-aware, for cubic-bezier). */
153
+ function splitTopLevel(value) {
154
+ const parts = [];
155
+ let depth = 0;
156
+ let current = '';
157
+ for (const ch of value) {
158
+ if (ch === '(') depth++;
159
+ else if (ch === ')') depth--;
160
+ if (ch === ',' && depth === 0) {
161
+ parts.push(current.trim());
162
+ current = '';
163
+ } else {
164
+ current += ch;
165
+ }
166
+ }
167
+ if (current.trim()) parts.push(current.trim());
168
+ return parts;
169
+ }
170
+
171
+ export {
172
+ CSS_EXTENSIONS,
173
+ HTML_FAMILY_EXTENSIONS,
174
+ JS_EXTENSIONS,
175
+ extractCssRegions,
176
+ findDeclarations,
177
+ declBlockInfo,
178
+ parseCssValue,
179
+ blockFontSizePx,
180
+ splitTopLevel,
181
+ };