ui-gateway 0.1.0 → 0.1.2

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 (362) hide show
  1. package/AGENTS.md +41 -6
  2. package/BENCHMARK.md +141 -0
  3. package/CHANGELOG.md +200 -2
  4. package/CONTRIBUTING.md +48 -6
  5. package/NON-GOALS.md +9 -6
  6. package/README.md +148 -38
  7. package/SECURITY.md +22 -1
  8. package/SKILL.md +71 -17
  9. package/action.yml +90 -0
  10. package/dist/evals/src/baseline.d.ts +4 -1
  11. package/dist/evals/src/baseline.d.ts.map +1 -1
  12. package/dist/evals/src/baseline.js +28 -6
  13. package/dist/evals/src/baseline.js.map +1 -1
  14. package/dist/evals/src/metrics.d.ts +35 -0
  15. package/dist/evals/src/metrics.d.ts.map +1 -1
  16. package/dist/evals/src/metrics.js +24 -0
  17. package/dist/evals/src/metrics.js.map +1 -1
  18. package/dist/packages/adapters/src/angular/index.js +2 -2
  19. package/dist/packages/adapters/src/angular/manifest.d.ts.map +1 -1
  20. package/dist/packages/adapters/src/angular/manifest.js +2 -8
  21. package/dist/packages/adapters/src/angular/manifest.js.map +1 -1
  22. package/dist/packages/adapters/src/antd/index.js +2 -2
  23. package/dist/packages/adapters/src/antd/manifest.d.ts.map +1 -1
  24. package/dist/packages/adapters/src/antd/manifest.js +2 -8
  25. package/dist/packages/adapters/src/antd/manifest.js.map +1 -1
  26. package/dist/packages/adapters/src/bootstrap/index.js +2 -2
  27. package/dist/packages/adapters/src/bootstrap/manifest.d.ts.map +1 -1
  28. package/dist/packages/adapters/src/bootstrap/manifest.js +2 -8
  29. package/dist/packages/adapters/src/bootstrap/manifest.js.map +1 -1
  30. package/dist/packages/adapters/src/chakra/index.d.ts.map +1 -1
  31. package/dist/packages/adapters/src/chakra/index.js +30 -5
  32. package/dist/packages/adapters/src/chakra/index.js.map +1 -1
  33. package/dist/packages/adapters/src/chakra/manifest.d.ts.map +1 -1
  34. package/dist/packages/adapters/src/chakra/manifest.js +309 -10
  35. package/dist/packages/adapters/src/chakra/manifest.js.map +1 -1
  36. package/dist/packages/adapters/src/index.d.ts +4 -0
  37. package/dist/packages/adapters/src/index.d.ts.map +1 -1
  38. package/dist/packages/adapters/src/index.js +18 -14
  39. package/dist/packages/adapters/src/index.js.map +1 -1
  40. package/dist/packages/adapters/src/local.d.ts.map +1 -1
  41. package/dist/packages/adapters/src/local.js +4 -2
  42. package/dist/packages/adapters/src/local.js.map +1 -1
  43. package/dist/packages/adapters/src/mantine/index.js +3 -3
  44. package/dist/packages/adapters/src/mantine/manifest.d.ts.map +1 -1
  45. package/dist/packages/adapters/src/mantine/manifest.js +8 -21
  46. package/dist/packages/adapters/src/mantine/manifest.js.map +1 -1
  47. package/dist/packages/adapters/src/mui/index.js +3 -3
  48. package/dist/packages/adapters/src/mui/manifest.d.ts.map +1 -1
  49. package/dist/packages/adapters/src/mui/manifest.js +2 -11
  50. package/dist/packages/adapters/src/mui/manifest.js.map +1 -1
  51. package/dist/packages/adapters/src/nuxt-ui/index.d.ts +5 -0
  52. package/dist/packages/adapters/src/nuxt-ui/index.d.ts.map +1 -0
  53. package/dist/packages/adapters/src/nuxt-ui/index.js +79 -0
  54. package/dist/packages/adapters/src/nuxt-ui/index.js.map +1 -0
  55. package/dist/packages/adapters/src/nuxt-ui/manifest.d.ts +3 -0
  56. package/dist/packages/adapters/src/nuxt-ui/manifest.d.ts.map +1 -0
  57. package/dist/packages/adapters/src/nuxt-ui/manifest.js +295 -0
  58. package/dist/packages/adapters/src/nuxt-ui/manifest.js.map +1 -0
  59. package/dist/packages/adapters/src/radix/index.d.ts +5 -0
  60. package/dist/packages/adapters/src/radix/index.d.ts.map +1 -0
  61. package/dist/packages/adapters/src/radix/index.js +71 -0
  62. package/dist/packages/adapters/src/radix/index.js.map +1 -0
  63. package/dist/packages/adapters/src/radix/manifest.d.ts +3 -0
  64. package/dist/packages/adapters/src/radix/manifest.d.ts.map +1 -0
  65. package/dist/packages/adapters/src/radix/manifest.js +331 -0
  66. package/dist/packages/adapters/src/radix/manifest.js.map +1 -0
  67. package/dist/packages/adapters/src/registry.d.ts +1 -1
  68. package/dist/packages/adapters/src/registry.d.ts.map +1 -1
  69. package/dist/packages/adapters/src/registry.js +16 -12
  70. package/dist/packages/adapters/src/registry.js.map +1 -1
  71. package/dist/packages/adapters/src/shadcn/index.js +3 -3
  72. package/dist/packages/adapters/src/shadcn/manifest.d.ts.map +1 -1
  73. package/dist/packages/adapters/src/shadcn/manifest.js +2 -11
  74. package/dist/packages/adapters/src/shadcn/manifest.js.map +1 -1
  75. package/dist/packages/adapters/src/solid/index.js +2 -2
  76. package/dist/packages/adapters/src/solid/manifest.d.ts.map +1 -1
  77. package/dist/packages/adapters/src/solid/manifest.js +2 -8
  78. package/dist/packages/adapters/src/solid/manifest.js.map +1 -1
  79. package/dist/packages/adapters/src/svelte/index.js +2 -2
  80. package/dist/packages/adapters/src/svelte/manifest.d.ts.map +1 -1
  81. package/dist/packages/adapters/src/svelte/manifest.js +2 -8
  82. package/dist/packages/adapters/src/svelte/manifest.js.map +1 -1
  83. package/dist/packages/adapters/src/vue/index.js +2 -2
  84. package/dist/packages/adapters/src/vue/manifest.d.ts.map +1 -1
  85. package/dist/packages/adapters/src/vue/manifest.js +2 -8
  86. package/dist/packages/adapters/src/vue/manifest.js.map +1 -1
  87. package/dist/packages/design-md/src/compile.js +2 -2
  88. package/dist/packages/design-md/src/derive.d.ts +41 -0
  89. package/dist/packages/design-md/src/derive.d.ts.map +1 -0
  90. package/dist/packages/design-md/src/derive.js +341 -0
  91. package/dist/packages/design-md/src/derive.js.map +1 -0
  92. package/dist/packages/design-md/src/index.d.ts +1 -0
  93. package/dist/packages/design-md/src/index.d.ts.map +1 -1
  94. package/dist/packages/design-md/src/index.js +6 -5
  95. package/dist/packages/design-md/src/index.js.map +1 -1
  96. package/dist/packages/gateway/src/confidence.d.ts +51 -1
  97. package/dist/packages/gateway/src/confidence.d.ts.map +1 -1
  98. package/dist/packages/gateway/src/confidence.js +198 -6
  99. package/dist/packages/gateway/src/confidence.js.map +1 -1
  100. package/dist/packages/gateway/src/gateway.d.ts +10 -2
  101. package/dist/packages/gateway/src/gateway.d.ts.map +1 -1
  102. package/dist/packages/gateway/src/gateway.js +190 -14
  103. package/dist/packages/gateway/src/gateway.js.map +1 -1
  104. package/dist/packages/gateway/src/index.d.ts +1 -0
  105. package/dist/packages/gateway/src/index.d.ts.map +1 -1
  106. package/dist/packages/gateway/src/index.js +7 -6
  107. package/dist/packages/gateway/src/index.js.map +1 -1
  108. package/dist/packages/gateway/src/preview.d.ts +12 -0
  109. package/dist/packages/gateway/src/preview.d.ts.map +1 -0
  110. package/dist/packages/gateway/src/preview.js +113 -0
  111. package/dist/packages/gateway/src/preview.js.map +1 -0
  112. package/dist/packages/gateway/src/validate.d.ts +5 -2
  113. package/dist/packages/gateway/src/validate.d.ts.map +1 -1
  114. package/dist/packages/gateway/src/validate.js +46 -18
  115. package/dist/packages/gateway/src/validate.js.map +1 -1
  116. package/dist/packages/kb/src/bundle-size.d.ts +8 -9
  117. package/dist/packages/kb/src/bundle-size.d.ts.map +1 -1
  118. package/dist/packages/kb/src/bundle-size.js +14 -12
  119. package/dist/packages/kb/src/bundle-size.js.map +1 -1
  120. package/dist/packages/kb/src/entry.d.ts +19 -1
  121. package/dist/packages/kb/src/entry.d.ts.map +1 -1
  122. package/dist/packages/kb/src/entry.js +13 -1
  123. package/dist/packages/kb/src/entry.js.map +1 -1
  124. package/dist/packages/kb/src/freshness.d.ts +76 -0
  125. package/dist/packages/kb/src/freshness.d.ts.map +1 -0
  126. package/dist/packages/kb/src/freshness.js +186 -0
  127. package/dist/packages/kb/src/freshness.js.map +1 -0
  128. package/dist/packages/kb/src/index.d.ts +2 -1
  129. package/dist/packages/kb/src/index.d.ts.map +1 -1
  130. package/dist/packages/kb/src/index.js +6 -5
  131. package/dist/packages/kb/src/index.js.map +1 -1
  132. package/dist/packages/kb/src/ingest.d.ts +3 -0
  133. package/dist/packages/kb/src/ingest.d.ts.map +1 -1
  134. package/dist/packages/kb/src/ingest.js +7 -1
  135. package/dist/packages/kb/src/ingest.js.map +1 -1
  136. package/dist/packages/kb/src/kb.d.ts +5 -0
  137. package/dist/packages/kb/src/kb.d.ts.map +1 -1
  138. package/dist/packages/kb/src/kb.js +5 -2
  139. package/dist/packages/kb/src/kb.js.map +1 -1
  140. package/dist/packages/matcher/src/anthropic.js +1 -1
  141. package/dist/packages/matcher/src/index.d.ts +8 -1
  142. package/dist/packages/matcher/src/index.d.ts.map +1 -1
  143. package/dist/packages/matcher/src/index.js +21 -11
  144. package/dist/packages/matcher/src/index.js.map +1 -1
  145. package/dist/packages/matcher/src/scaffold.d.ts.map +1 -1
  146. package/dist/packages/matcher/src/scaffold.js +62 -19
  147. package/dist/packages/matcher/src/scaffold.js.map +1 -1
  148. package/dist/packages/matcher/src/score.d.ts +8 -1
  149. package/dist/packages/matcher/src/score.d.ts.map +1 -1
  150. package/dist/packages/matcher/src/score.js +90 -25
  151. package/dist/packages/matcher/src/score.js.map +1 -1
  152. package/dist/packages/matcher/src/select.d.ts +15 -1
  153. package/dist/packages/matcher/src/select.d.ts.map +1 -1
  154. package/dist/packages/matcher/src/select.js +53 -3
  155. package/dist/packages/matcher/src/select.js.map +1 -1
  156. package/dist/packages/orchestrator/src/figma.d.ts +12 -0
  157. package/dist/packages/orchestrator/src/figma.d.ts.map +1 -0
  158. package/dist/packages/orchestrator/src/figma.js +102 -0
  159. package/dist/packages/orchestrator/src/figma.js.map +1 -0
  160. package/dist/packages/orchestrator/src/index.d.ts +1 -0
  161. package/dist/packages/orchestrator/src/index.d.ts.map +1 -1
  162. package/dist/packages/orchestrator/src/index.js +3 -2
  163. package/dist/packages/orchestrator/src/index.js.map +1 -1
  164. package/dist/packages/orchestrator/src/orchestrator.d.ts.map +1 -1
  165. package/dist/packages/orchestrator/src/orchestrator.js +14 -3
  166. package/dist/packages/orchestrator/src/orchestrator.js.map +1 -1
  167. package/dist/packages/profile/src/detect.d.ts +9 -0
  168. package/dist/packages/profile/src/detect.d.ts.map +1 -1
  169. package/dist/packages/profile/src/detect.js +52 -5
  170. package/dist/packages/profile/src/detect.js.map +1 -1
  171. package/dist/packages/profile/src/index.js +7 -7
  172. package/dist/packages/profile/src/local-components.d.ts.map +1 -1
  173. package/dist/packages/profile/src/local-components.js +70 -1
  174. package/dist/packages/profile/src/local-components.js.map +1 -1
  175. package/dist/packages/profile/src/registry.d.ts.map +1 -1
  176. package/dist/packages/profile/src/registry.js +3 -1
  177. package/dist/packages/profile/src/registry.js.map +1 -1
  178. package/dist/packages/profile/src/skills.js +1 -1
  179. package/dist/packages/protocol/src/errors.js +1 -1
  180. package/dist/packages/protocol/src/errors.js.map +1 -1
  181. package/dist/packages/protocol/src/event-log.d.ts.map +1 -1
  182. package/dist/packages/protocol/src/event-log.js +11 -5
  183. package/dist/packages/protocol/src/event-log.js.map +1 -1
  184. package/dist/packages/protocol/src/events.js +5 -5
  185. package/dist/packages/protocol/src/hashing.d.ts +6 -0
  186. package/dist/packages/protocol/src/hashing.d.ts.map +1 -1
  187. package/dist/packages/protocol/src/hashing.js +8 -2
  188. package/dist/packages/protocol/src/hashing.js.map +1 -1
  189. package/dist/packages/protocol/src/index.js +12 -12
  190. package/dist/packages/protocol/src/lease.js +2 -2
  191. package/dist/packages/protocol/src/schemas.d.ts +2803 -116
  192. package/dist/packages/protocol/src/schemas.d.ts.map +1 -1
  193. package/dist/packages/protocol/src/schemas.js +54 -4
  194. package/dist/packages/protocol/src/schemas.js.map +1 -1
  195. package/dist/packages/protocol/src/semantic.js +1 -1
  196. package/dist/packages/protocol/src/state-machine.js +1 -1
  197. package/dist/packages/transports/src/check.d.ts +30 -0
  198. package/dist/packages/transports/src/check.d.ts.map +1 -0
  199. package/dist/packages/transports/src/check.js +190 -0
  200. package/dist/packages/transports/src/check.js.map +1 -0
  201. package/dist/packages/transports/src/cli.d.ts +1 -1
  202. package/dist/packages/transports/src/cli.js +278 -25
  203. package/dist/packages/transports/src/cli.js.map +1 -1
  204. package/dist/packages/transports/src/exit-codes.d.ts +8 -0
  205. package/dist/packages/transports/src/exit-codes.d.ts.map +1 -0
  206. package/dist/packages/transports/src/exit-codes.js +19 -0
  207. package/dist/packages/transports/src/exit-codes.js.map +1 -0
  208. package/dist/packages/transports/src/http.js +2 -2
  209. package/dist/packages/transports/src/http.js.map +1 -1
  210. package/dist/packages/transports/src/index.d.ts +5 -0
  211. package/dist/packages/transports/src/index.d.ts.map +1 -1
  212. package/dist/packages/transports/src/index.js +11 -6
  213. package/dist/packages/transports/src/index.js.map +1 -1
  214. package/dist/packages/transports/src/init.d.ts +32 -0
  215. package/dist/packages/transports/src/init.d.ts.map +1 -0
  216. package/dist/packages/transports/src/init.js +110 -0
  217. package/dist/packages/transports/src/init.js.map +1 -0
  218. package/dist/packages/transports/src/mcp-config.d.ts +27 -0
  219. package/dist/packages/transports/src/mcp-config.d.ts.map +1 -0
  220. package/dist/packages/transports/src/mcp-config.js +99 -0
  221. package/dist/packages/transports/src/mcp-config.js.map +1 -0
  222. package/dist/packages/transports/src/mcp.js +3 -3
  223. package/dist/packages/transports/src/paths.d.ts +9 -0
  224. package/dist/packages/transports/src/paths.d.ts.map +1 -0
  225. package/dist/packages/transports/src/paths.js +32 -0
  226. package/dist/packages/transports/src/paths.js.map +1 -0
  227. package/dist/packages/transports/src/receipt.d.ts +8 -0
  228. package/dist/packages/transports/src/receipt.d.ts.map +1 -0
  229. package/dist/packages/transports/src/receipt.js +87 -0
  230. package/dist/packages/transports/src/receipt.js.map +1 -0
  231. package/dist/packages/transports/src/resources.js +3 -3
  232. package/dist/packages/transports/src/resources.js.map +1 -1
  233. package/dist/packages/transports/src/tools.d.ts.map +1 -1
  234. package/dist/packages/transports/src/tools.js +284 -10
  235. package/dist/packages/transports/src/tools.js.map +1 -1
  236. package/dist/packages/verifier/src/index.js +7 -7
  237. package/dist/packages/verifier/src/lint.js +1 -1
  238. package/dist/packages/verifier/src/page.js +2 -2
  239. package/dist/packages/verifier/src/render-axe.js +1 -1
  240. package/dist/packages/verifier/src/verify.js +4 -4
  241. package/dist/scripts/build-site.d.ts +2 -0
  242. package/dist/scripts/build-site.d.ts.map +1 -0
  243. package/dist/scripts/build-site.js +254 -0
  244. package/dist/scripts/build-site.js.map +1 -0
  245. package/dist/scripts/calibration.js +33 -2
  246. package/dist/scripts/calibration.js.map +1 -1
  247. package/dist/scripts/fix-imports.js +32 -2
  248. package/dist/scripts/fix-imports.js.map +1 -1
  249. package/dist/scripts/generate-kb.d.ts +3 -0
  250. package/dist/scripts/generate-kb.d.ts.map +1 -0
  251. package/dist/scripts/generate-kb.js +195 -0
  252. package/dist/scripts/generate-kb.js.map +1 -0
  253. package/dist/scripts/generate-refusal-catalog.d.ts +3 -0
  254. package/dist/scripts/generate-refusal-catalog.d.ts.map +1 -0
  255. package/dist/scripts/generate-refusal-catalog.js +50 -0
  256. package/dist/scripts/generate-refusal-catalog.js.map +1 -0
  257. package/dist/scripts/generate-tool-docs.d.ts +3 -0
  258. package/dist/scripts/generate-tool-docs.d.ts.map +1 -0
  259. package/dist/scripts/generate-tool-docs.js +24 -0
  260. package/dist/scripts/generate-tool-docs.js.map +1 -0
  261. package/dist/scripts/mcp-config.js +28 -60
  262. package/dist/scripts/mcp-config.js.map +1 -1
  263. package/docs/archive/UI Gateway Final Project Roadmap.md +285 -0
  264. package/docs/benchmarks/external-repos.json +26 -0
  265. package/docs/benchmarks/local-gemma3-1b-stride32.json +455 -0
  266. package/docs/calibration.svg +44 -0
  267. package/docs/design-import.md +19 -0
  268. package/docs/design-md.md +109 -0
  269. package/docs/distribution.md +41 -0
  270. package/docs/engineering-principles.md +152 -0
  271. package/docs/layers-plan.md +372 -0
  272. package/docs/metrics.md +153 -0
  273. package/docs/modes.md +22 -0
  274. package/docs/parking-lot.md +25 -0
  275. package/docs/quickstart.md +72 -0
  276. package/docs/refusal-catalog.md +32 -0
  277. package/docs/spike-source-discovery.md +36 -0
  278. package/docs/telemetry.md +26 -0
  279. package/evals/fixtures/external-repos.json +55 -0
  280. package/evals/fixtures/kb-generated/angular.json +72 -0
  281. package/evals/fixtures/kb-generated/antd.json +72 -0
  282. package/evals/fixtures/kb-generated/bootstrap.json +72 -0
  283. package/evals/fixtures/kb-generated/chakra.json +14939 -0
  284. package/evals/fixtures/kb-generated/mantine.json +192 -0
  285. package/evals/fixtures/kb-generated/mui.json +8997 -0
  286. package/evals/fixtures/kb-generated/shadcn.json +192 -0
  287. package/evals/fixtures/kb-generated/solid.json +72 -0
  288. package/evals/fixtures/kb-generated/svelte.json +72 -0
  289. package/evals/fixtures/kb-generated/vue.json +72 -0
  290. package/evals/fixtures/projects/existing-chakra-v3/package.json +10 -0
  291. package/evals/fixtures/projects/existing-nuxt-ui/package.json +9 -0
  292. package/evals/fixtures/projects/existing-radix/package.json +9 -0
  293. package/evals/out/agent-report.json +190 -11
  294. package/evals/out/baseline-report.json +1441 -387
  295. package/evals/out/calibration.json +387 -42
  296. package/evals/out/external-repos-report.json +112 -0
  297. package/evals/out/local-benchmark-report.json +455 -0
  298. package/evals/src/agent-eval.test.ts +3 -0
  299. package/evals/src/agent-eval.ts +26 -4
  300. package/evals/src/baseline.ts +48 -7
  301. package/evals/src/blind-labeling-cli.ts +5 -0
  302. package/evals/src/blind-labeling.ts +46 -0
  303. package/evals/src/external-repos.ts +179 -0
  304. package/evals/src/metrics.ts +70 -0
  305. package/evals/src/mutations.ts +6 -6
  306. package/evals/src/page-a11y-eval.ts +37 -36
  307. package/evals/src/page-real-eval.ts +8 -7
  308. package/evals/src/plain-agent.test.ts +14 -0
  309. package/evals/src/plain-agent.ts +240 -0
  310. package/evals/src/run-agent-evals.ts +3 -0
  311. package/evals/src/run-external-repos.ts +43 -0
  312. package/evals/src/run-local-benchmark.ts +105 -0
  313. package/evals/src/run-plain-agent.ts +81 -0
  314. package/examples/README.md +32 -0
  315. package/examples/build-handoff.ts +106 -0
  316. package/examples/design-md.md +24 -0
  317. package/examples/handoff-input.json +59 -0
  318. package/examples/handoff.json +216 -0
  319. package/examples/layer-operations.json +18 -0
  320. package/examples/website-demo-handoff.json +580 -0
  321. package/package.json +30 -7
  322. package/references/design-md.md +3 -1
  323. package/references/errors.md +1 -1
  324. package/references/handoff.md +16 -1
  325. package/references/outcomes.md +60 -11
  326. package/references/patterns.md +3 -3
  327. package/references/tools.md +86 -27
  328. package/scripts/action-review.mjs +59 -0
  329. package/scripts/bench-latency.ts +90 -0
  330. package/scripts/build-site.ts +324 -0
  331. package/scripts/calibration.ts +50 -14
  332. package/scripts/fix-imports.ts +31 -2
  333. package/scripts/generate-kb.ts +214 -0
  334. package/scripts/generate-refusal-catalog.ts +58 -0
  335. package/scripts/generate-tool-docs.ts +31 -0
  336. package/scripts/mcp-config.ts +26 -83
  337. package/scripts/package-plugin.mjs +50 -0
  338. package/scripts/sbom.mjs +46 -0
  339. package/scripts/visual-diff.mjs +52 -0
  340. package/site/data.json +187 -0
  341. package/site/index.html +151 -0
  342. package/skills/ui-gateway-cli/SKILL.md +41 -0
  343. package/templates/next-shadcn/.github/workflows/ui-check.yml +14 -0
  344. package/templates/next-shadcn/.mcp.json +8 -0
  345. package/templates/next-shadcn/DESIGN.md +35 -0
  346. package/templates/next-shadcn/README.md +14 -0
  347. package/templates/next-shadcn/app/page.tsx +8 -0
  348. package/templates/next-shadcn/package.json +19 -0
  349. package/templates/vite-mantine/.github/workflows/ui-check.yml +14 -0
  350. package/templates/vite-mantine/.mcp.json +8 -0
  351. package/templates/vite-mantine/DESIGN.md +30 -0
  352. package/templates/vite-mantine/README.md +7 -0
  353. package/templates/vite-mantine/package.json +21 -0
  354. package/templates/vite-mantine/src/App.tsx +10 -0
  355. package/templates/vite-mui/.github/workflows/ui-check.yml +14 -0
  356. package/templates/vite-mui/.mcp.json +8 -0
  357. package/templates/vite-mui/DESIGN.md +30 -0
  358. package/templates/vite-mui/README.md +8 -0
  359. package/templates/vite-mui/package.json +22 -0
  360. package/templates/vite-mui/src/App.tsx +12 -0
  361. package/scripts/fetch-bundle-sizes.ts +0 -106
  362. package/scripts/test-bundlephobia.ts +0 -11
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  [![npm version](https://img.shields.io/npm/v/ui-gateway.svg?style=flat-square)](https://www.npmjs.com/package/ui-gateway)
2
2
  [![npm downloads](https://img.shields.io/npm/dm/ui-gateway.svg?style=flat-square)](https://www.npmjs.com/package/ui-gateway)
3
3
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
4
- [![Node 22.5+](https://img.shields.io/badge/node-%3E%3D22.5-green.svg?style=flat-square)](https://nodejs.org/)
4
+ [![Node 20+](https://img.shields.io/badge/node-%3E%3D20-green.svg?style=flat-square)](https://nodejs.org/)
5
+ [![ci](https://github.com/yuvraajnarula/uigateway/actions/workflows/ci.yml/badge.svg)](https://github.com/yuvraajnarula/uigateway/actions/workflows/ci.yml)
5
6
 
6
7
  # UI Gateway
7
8
 
@@ -9,7 +10,7 @@ A library-agnostic, project-aware gateway that turns a design handoff into
9
10
  **verified** UI component mappings. It fails closed: when it cannot answer
10
11
  safely it returns a typed refusal that names what is missing.
11
12
 
12
- - **Ten adapters, one conformance suite.** shadcn/ui, MUI, Chakra UI v2, Mantine, Vue, Svelte, Angular, SolidJS, Bootstrap and Ant Design. Every adapter implements the same interface and passes the same suite.
13
+ - **12 adapters, one conformance suite.** shadcn/ui, MUI, Chakra UI v2 and v3, Mantine, Nuxt UI, unified Radix, Vue, Svelte, Angular, SolidJS, Bootstrap and Ant Design. Every adapter implements the same interface and passes the same suite.
13
14
  - **Project-aware.** Detects framework, styling systems, installed UI libraries,
14
15
  local components and project skill files. Mode is `greenfield` or `existing`,
15
16
  detected and overridable.
@@ -21,10 +22,58 @@ safely it returns a typed refusal that names what is missing.
21
22
  - **Protocol with ownership.** Leases, a hash-chained append-only event log,
22
23
  idempotency, and `RETURNED` as the only exit.
23
24
 
24
- This repo implements Phases 0-8 of
25
- [`UI Gateway Final Project Roadmap.md`](./UI%20Gateway%20Final%20Project%20Roadmap.md).
26
- Phase 8 features (render/axe checks, bundle-size scoring) are opt-in. See
27
- [NON-GOALS.md](./NON-GOALS.md) for deliberate limits.
25
+ ## Quality
26
+
27
+ - **CI:** typecheck, build, tests, coverage thresholds, docs examples, evals and
28
+ the end-to-end demo run on Linux, Windows and macOS; packed-install smoke tests
29
+ run on Node 20/22/24. See `.github/workflows/ci.yml`.
30
+ - **Coverage:** `npm run test:coverage` enforces floors (statements/lines 78%,
31
+ branches 74%, functions 76%); current coverage is ~79% statements.
32
+ - **Latency:** `npm run bench` reports handoff-to-result percentiles (p50/p90/p99).
33
+ - **Evals:** the pre-registered harness compares the gateway against a plain-agent
34
+ baseline. The only committed model-backed sample (a 6-item CPU run, `gemma3:1b`)
35
+ is directional, not a frontier result:
36
+
37
+ | Arm | Hit rate | Compiles | Constraints | Mean wall |
38
+ | --- | --- | --- | --- | --- |
39
+ | gateway full skill | 66.7% (30.0–90.3) | 100% (51.0–100) | 100% | 5.6 s |
40
+ | plain agent, no gateway | 0% | 16.7% | 83.3% | 24.3 s |
41
+
42
+ Intervals are Wilson 95%. See `BENCHMARK.md` for method and reproduction.
43
+ A key-backed frontier run at full stride is pending; `BENCHMARK.md` has the
44
+ exact steps and a table to fill from the committed JSON.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ npm install ui-gateway
50
+ ```
51
+
52
+ Then set up your target project with one command:
53
+
54
+ ```bash
55
+ npx ui-gateway init --project /absolute/path/to/your/app
56
+ ```
57
+
58
+ `init` detects Claude Code, Cursor, VS Code, OpenCode or a generic MCP client,
59
+ writes/merges the client config, copies the skill into `.ui-gateway/skill`, and
60
+ prints project detection plus any `needs_input` questions. To print a config
61
+ without writing anything:
62
+
63
+ ```bash
64
+ npx ui-gateway mcp:config --project /absolute/path/to/your/app
65
+ npx ui-gateway mcp:config --project /absolute/path/to/your/app --client cursor
66
+ ```
67
+
68
+ Clients without MCP can use the CLI equivalent:
69
+
70
+ ```bash
71
+ npx ui-gateway init --project /absolute/path/to/your/app --print-skill
72
+ ```
73
+
74
+ The gateway never writes to your project — it returns scaffolds, mappings and
75
+ typed refusals for you to apply. See [NON-GOALS.md](./NON-GOALS.md) for
76
+ deliberate limits.
28
77
 
29
78
  ## Quick start
30
79
 
@@ -37,14 +86,18 @@ npm run eval # pre-registered eval harness (offline stand-in arms)
37
86
  npm run eval:agent # build -> validate -> submit contract over the golden set
38
87
  npm run eval:claude # real Claude three-arm run (requires ANTHROPIC_API_KEY)
39
88
  npm run eval:groq # OpenAI-compatible/Groq run (requires GROQ_API_KEY)
89
+ npm run eval:local # real local Ollama benchmark + plain-agent arm
90
+ npm run eval:repos # pinned external repos; add -- --pins-only to resolve commits
91
+ npm run site # regenerate site/index.html from eval artifacts
40
92
  npm run eval:site # Playwright site eval over the dashboard fixture
41
93
  npm run eval:page # generated page shell: axe, keyboard, states, disclosure
42
94
  npm run eval:page:real # actual MUI/Chakra/Mantine scaffolds and themes
43
- npm run calibration # reliability curve -> docs/calibration.svg
95
+ npm run calibration # reliability curve -> docs/calibration.svg\nnpm run site # generated open-caveats status page -> site/index.html
44
96
  ```
45
97
 
46
- Node 22.5+ is required (the event log uses `node:sqlite`; Node prints an
47
- experimental warning).
98
+ Node 20+ is required. The default in-memory event log has no native
99
+ dependencies. `--sqlite <file>` needs Node 22.5+ because it uses `node:sqlite`,
100
+ and fails with an explicit message on older Node.
48
101
 
49
102
  ## Agent skill
50
103
 
@@ -64,26 +117,28 @@ references and examples:
64
117
  | `examples/handoff-input.json` | Builder input for regenerating the example handoff. |
65
118
  | `examples/handoff.json` | Complete, hash-pinned example handoff. |
66
119
 
67
- The skill expects the MCP server. Print a ready-to-paste config from the gateway
68
- repository:
120
+ The skill expects the MCP server. Print a ready-to-paste config:
69
121
 
70
122
  ```bash
71
- npm run mcp:config -- --project /absolute/path/to/your/app
72
- npm run mcp:config -- --project /absolute/path/to/your/app --client opencode
123
+ npx ui-gateway mcp:config --project /absolute/path/to/your/app
124
+ npx ui-gateway mcp:config --project /absolute/path/to/your/app --client opencode
73
125
  ```
74
126
 
75
- The first form prints a generic `mcpServers` config; the second prints an
76
- OpenCode `mcp` config. `--project` is the application the agent edits, not this
77
- repository.
127
+ The first form prints a generic `mcpServers` config; `--client` also accepts
128
+ `claude`, `cursor` and `vscode`. `--project` is the application the agent edits,
129
+ not this repository. `npx ui-gateway init` writes the config for you.
78
130
 
79
131
  ## MCP
80
132
 
81
- The MCP server exposes nine tools over stdio:
133
+ The MCP server exposes 14 tools over stdio:
82
134
 
83
135
  - `detect_project` — profile, provenance, confidence, `needs_input`.
84
136
  - `describe_kb` — supported libraries, entries, `kb_version`.
85
137
  - `hash_design_md` — normalized Design MD hash.
138
+ - `import_design_md` — read and validate a Design MD file from disk.
139
+ - `import_design_tokens` — convert DTCG JSON into Design MD tokens.
86
140
  - `validate_design_md` — grammar, normalizations, policy, satisfiability.
141
+ - `derive_design_md` — infer a valid Design MD from the project's tokens.
87
142
  - `build_handoff` — generates the wireframe, pins the profile/hash and returns a
88
143
  validation report.
89
144
  - `validate_handoff` — the gateway's pre-flight checks plus a strict semantic
@@ -91,11 +146,32 @@ The MCP server exposes nine tools over stdio:
91
146
  satisfiability.
92
147
  - `submit_handoff` — returns the result, `state` and `ownership_returned`,
93
148
  plus `page_plan`, `page`, `token_projection` and `warnings` when present.
149
+ - `map_ui` — two-call happy path: detect/derive, build, validate and submit.
94
150
  - `verify_page` — read-only page check for anchors, ids, unused imports, basic
95
151
  a11y, the main landmark, duplicate display utilities and responsive
96
152
  breakpoint conflicts; can optionally compile the page and its related
97
153
  scaffolds in a throwaway TypeScript project.
98
154
  - `get_handoff` — state, ownership, lease and result from the event log.
155
+ - `refusal_ledger` — repeated refusal reasons and suggested fixes.
156
+
157
+ <!-- TOOLS:START -->
158
+ | Tool | Purpose |
159
+ | --- | --- |
160
+ | `detect_project` | Detect the UI profile of a project: framework, styling, libraries, local components and project skill files. |
161
+ | `describe_kb` | List supported libraries, licenses, availability and component entries. |
162
+ | `hash_design_md` | Compute the Design MD sha256 after the gateway's deterministic normalization. |
163
+ | `import_design_md` | Read a Design MD file from the project filesystem, validate it against the strict grammar, and return its normalized content, hash and validation report. |
164
+ | `import_design_tokens` | Read a DTCG (Design Tokens Community Group) JSON file and convert its tokens into Design MD token entries. |
165
+ | `validate_design_md` | Validate a Design MD against the strict grammar and the project profile. |
166
+ | `build_handoff` | Build a complete, hash-pinned handoff from a Design MD and intents. |
167
+ | `validate_handoff` | Run the gateway's pre-flight checks plus a strict semantic gate: schema, supported schema version, design hash, Design MD compilation, semantics, satisfiability, profile hash, KB freshness and adapter support. |
168
+ | `submit_handoff` | Submit a validated handoff and receive verified component mappings. |
169
+ | `verify_page` | Read-only page check: syntax, broken or dead anchors, missing page_plan region ids, duplicate ids, unused imports, missing img alt, unlabeled links/buttons and the main landmark. |
170
+ | `derive_design_md` | Infer a strict Design MD from the project's CSS variables, Tailwind config, DTCG token files and an existing DESIGN.md. |
171
+ | `map_ui` | Two-call happy path. |
172
+ | `refusal_ledger` | Summarize repeated refusals from the event log (missing information, ambiguity, unsatisfiable constraints) and suggest fixes. |
173
+ | `get_handoff` | Read a handoff's state, ownership and result from the event log. |
174
+ <!-- TOOLS:END -->
99
175
 
100
176
  It also serves the references and examples as MCP resources
101
177
  (`ui-gateway://reference/handoff`, `ui-gateway://example/handoff`, and so on).
@@ -116,20 +192,36 @@ gateway expects.
116
192
  ## CLI
117
193
 
118
194
  ```bash
195
+ npm run cli -- init evals/fixtures/projects/existing-mui --dry-run
119
196
  npm run cli -- detect evals/fixtures/projects/existing-mui
120
197
  npm run cli -- kb --library shadcn
121
198
  npm run cli -- validate examples/handoff.json
122
199
  npm run cli -- validate-design examples/design-md.md
123
200
  npm run cli -- build-handoff examples/handoff-input.json --out examples/handoff.json
124
201
  npm run cli -- submit examples/handoff.json --project evals/fixtures/projects/greenfield-react
202
+ npm run cli -- submit examples/handoff.json --out .tmp/response.json # echoes "wrote <path>" on stderr
203
+ npm run cli -- preview .tmp/response.json --out .tmp/preview.html
125
204
  npm run cli -- submit examples/handoff.json --sqlite .tmp/events.sqlite
126
205
  npm run cli -- status <handoff_id> --sqlite .tmp/events.sqlite
127
206
  npm run cli -- label evals/fixtures/labels.jsonl
128
207
  ```
129
208
 
130
- `submit` prints the full `SubmitResponse` JSON. Exit code 1 means the gateway
131
- refused the handoff. `build-handoff` reads a `HandoffInput` JSON file and writes
132
- or prints the complete handoff.
209
+ `submit` prints the full `SubmitResponse` JSON; `--out` writes it to a file and
210
+ confirms the path on stderr, so stdout stays JSON. Exit codes follow the outcome
211
+ (0 `COMPLETED`, 1 `REJECTED`, 3 `NEEDS_INPUT`, …) — see `references/outcomes.md`.
212
+ `build-handoff` reads a `HandoffInput` JSON file and writes or prints the complete
213
+ handoff. `preview` renders a result as standalone, dependency-free HTML.
214
+ `check` prints JSON by default; add `--text` for the one-line-per-finding list.
215
+ `kb-freshness <library> --current <version>` fetches the npm registry and any
216
+ `--docs <url>` pages and prints drift proposals with citations and a 0–1
217
+ confidence score; it never edits the KB or opens a PR. Documentation URLs must
218
+ be on the library's official host (from its `source_url`, plus any
219
+ `--official <host>`), and non-official URLs are rejected rather than cited.
220
+
221
+ Every KB library records the version line its entries were verified against
222
+ (`describe_kb` → `libraries[].library_version`, entries and mappings carry the
223
+ same field). Generated scaffolds start with `// library@line`, so a scaffold is
224
+ never silently reused across majors.
133
225
 
134
226
  ## HTTP transport
135
227
 
@@ -171,10 +263,19 @@ project — it returns scaffolds, mappings, and typed refusals for you to apply.
171
263
 
172
264
  ### Releasing
173
265
 
174
- ```bash
175
- npm version patch # or minor / major
176
- npm publish
177
- ```
266
+ Versioning and the changelog are managed by
267
+ [Changesets](https://github.com/changesets/changesets). Maintainers merge the
268
+ automated **Version Packages** pull request, then push a `vX.Y.Z` tag; the
269
+ `release` workflow publishes to npm with provenance and uploads the SBOM. See
270
+ `CONTRIBUTING.md`.
271
+
272
+ ## Maintainers
273
+
274
+ - [@yuvraajnarula](https://github.com/yuvraajnarula)
275
+
276
+ Maintainers are the default owners in [`.github/CODEOWNERS`](./.github/CODEOWNERS).
277
+ Want to help maintain the project? See the "Becoming a maintainer" section in
278
+ [`CONTRIBUTING.md`](./CONTRIBUTING.md).
178
279
 
179
280
  The repo is MIT licensed. See `LICENSE` for details.
180
281
 
@@ -234,7 +335,7 @@ Error codes (retryable in brackets): `INVALID_HANDOFF`, `INTEGRITY_MISMATCH`
234
335
  | `@uigw/design-md` | strict Design MD parser, normalizer, constraint compiler, satisfiability |
235
336
  | `@uigw/profile` | project detector with provenance/confidence, local component derivation, skill capture, conflicts |
236
337
  | `@uigw/kb` | three-layer knowledge base, provenance tiers, ingest quarantine, staleness, drift |
237
- | `@uigw/adapters` | adapter interface, shadcn, MUI, Chakra v2, Mantine, Vue, Svelte, Angular, SolidJS, Bootstrap, Ant Design, local-components adapter, conformance suite |
338
+ | `@uigw/adapters` | adapter interface, shadcn, MUI, Chakra v2/v3, Mantine, Nuxt UI, Radix, Vue, Svelte, Angular, SolidJS, Bootstrap, Ant Design, local-components adapter, conformance suite |
238
339
  | `@uigw/matcher` | filter, rank, closed-ID selection, code-written scaffolds |
239
340
  | `@uigw/verifier` | TSX AST checks, design lint, coverage, optional tsc sandbox |
240
341
  | `@uigw/gateway` | wiring, leases, retries, acceptance, validation report, result assembly |
@@ -289,9 +390,11 @@ const handoff = buildHandoff({
289
390
  });
290
391
 
291
392
  const response = await gateway.submit(handoff);
292
- if (response.ok) {
293
- console.log(response.result.outcome, response.result.intents.map((intent) => intent.mappings[0]?.component_id));
294
- }
393
+ // `ok` is true only for COMPLETED; every other outcome still carries a result.
394
+ console.log(
395
+ response.outcome,
396
+ response.result?.intents.map((intent) => intent.mappings[0]?.component_id),
397
+ );
295
398
  ```
296
399
 
297
400
  ## Evaluations
@@ -300,9 +403,17 @@ if (response.ok) {
300
403
  - `npm run eval:agent` runs the exact agent path (`build_handoff` ->
301
404
  `validate_handoff` -> `submit_handoff`) and writes
302
405
  `evals/out/agent-report.json`. It fails if any item cannot be built, validated
303
- or submitted, or if the positive mapped rate drops below 70%.
406
+ or submitted, or if the positive mapped rate drops below 70%. It also reports
407
+ rounds (`tool_calls_total`, `tool_calls_per_item`, `max_tool_calls`) so a
408
+ contract change that adds retries is visible.
304
409
  - `npm run eval:claude` runs the real Claude arms (`ANTHROPIC_API_KEY`).
305
410
  - `npm run eval:groq` runs the OpenAI-compatible/Groq arms (`GROQ_API_KEY`).
411
+ - `npm run eval:local` runs the gateway and plain-agent arms against Ollama
412
+ (`UIGW_LOCAL_MODEL`; results are local-model results, not frontier numbers).
413
+ - `npm run eval:repos -- --pins-only` resolves every external fixture commit
414
+ with `git ls-remote`; `npm run eval:repos` shallow-clones and detects them.
415
+ - `npm run site` writes `site/index.html`, a generated status page for the open
416
+ caveats, benchmark numbers, adapters and external pins.
306
417
  - `npm run eval:site` serves the dashboard fixture and drives it in installed
307
418
  Chrome with `playwright-core`; it checks anchors, search/empty state, row
308
419
  detail, mobile navigation and console errors. It is not part of `npm test`.
@@ -343,15 +454,14 @@ if (response.ok) {
343
454
  offline evals also include simulated behaviors; see `docs/metrics.md`.
344
455
  - The `tsc` sandbox stubs library types. It catches syntax and local type
345
456
  errors; prop correctness comes from the KB AST check.
346
- - Local component derivation handles exported function and arrow components with
347
- object destructuring or type aliases. Class components and re-exported library
348
- components are not derived.
349
- - v1 supports React-family frameworks (shadcn, MUI, Chakra v2, Mantine), Vue,
350
- Svelte, Angular, SolidJS, Bootstrap and Ant Design. Chakra v3 dotted namespaces
351
- are parked.
352
- - The Chakra adapter targets Chakra UI v2's flat named exports. Chakra v3 moved
353
- most families to dotted namespaces (`Table.Root`, `Dialog.Root`), which the
354
- current KB/scaffold contract does not model; v3 support is parked.
457
+ - Local component derivation handles exported function and arrow components,
458
+ class components, and re-exported library components.
459
+ - v1 supports React-family frameworks (shadcn, MUI, Chakra v2/v3, Mantine,
460
+ unified Radix), Vue, Svelte, Angular, SolidJS, Bootstrap and Ant Design.
461
+ - The Chakra adapter is version-aware: v2 projects receive flat exports, v3
462
+ projects receive dotted namespaces (`Table.Root`, `Dialog.Root`). Nuxt UI and
463
+ Radix output is a component sketch; Nuxt UI does not yet emit a compiled Vue
464
+ SFC, and both adapters remain experimental until labeled eval data exists.
355
465
  - The golden set meets the Phase 6 count gate (124 dev + 48 test) across five
356
466
  fixtures — greenfield, existing-shadcn, existing-MUI, existing-Chakra and
357
467
  existing-Mantine — so every shipping adapter has labeled positives. Its labels are
package/SECURITY.md CHANGED
@@ -8,11 +8,13 @@
8
8
 
9
9
  ## Reporting a Vulnerability
10
10
 
11
- Please report security vulnerabilities to opensource@yuvraajnarula.com.
11
+ Please report security vulnerabilities to ynarula678@gmail.com.
12
12
 
13
13
  Do not open a public GitHub issue for security concerns. We will acknowledge
14
14
  your report within 48 hours and provide an initial assessment within 7 days.
15
15
 
16
+ Maintainers are listed in [`.github/CODEOWNERS`](./.github/CODEOWNERS).
17
+
16
18
  ## Security Practices
17
19
 
18
20
  - UI Gateway never writes files to your project, installs packages or opens pull requests.
@@ -25,6 +27,25 @@ your report within 48 hours and provide an initial assessment within 7 days.
25
27
  - The `tsc` compile sandbox runs in the OS temp directory, never inside the repo,
26
28
  and stubs all library modules so untrusted code cannot resolve installed packages.
27
29
 
30
+ ## Threat model
31
+
32
+ | Asset | Threat | Control |
33
+ | --- | --- | --- |
34
+ | Design MD constraints | prompt injection in prose or project skill files | Design MD is parsed by a strict grammar; free text is data, never instructions. `injection.test.ts` asserts hostile `AGENTS.md`/`SKILL.md` text cannot change mappings, scaffolds or confidence. |
35
+ | Generated code | a model invents imports/props/components | closed-ID selection, AST checks, adapter conformance, throwaway `tsc` sandbox |
36
+ | Host project | generated code escapes the sandbox or reads host `node_modules` | sandbox lives in the OS temp dir, stubs every bare module, `types: []`; real types are copied from a pinned source only when explicitly requested |
37
+ | KB integrity | stale or tampered manifests | schema validation, provenance tiers, quarantine, freshness pins, hash chain in the event log |
38
+ | Event log | tampering or replay | hash-chained append-only events, idempotency by content hash, lease ownership |
39
+ | Release supply chain | compromised dependency or build | `npm publish --provenance`, generated SBOM, CI checks on the packed tarball across Node 20/22/24 |
40
+ | Untrusted Figma/text input | injected instructions become code | deterministic layer-to-intent mapping; text is escaped into descriptions; generated code still passes the verifier |
41
+ | Oversized request body | memory exhaustion during validation (DoS) | the HTTP transport caps request bodies (`maxBodyBytes`, default 5 MiB) and returns `413` |
42
+
43
+ ## Accepted risks
44
+
45
+ | Advisory | Status | Mitigation / plan |
46
+ | --- | --- | --- |
47
+ | GHSA-mrhx-c7xc-m3w5 (zod memory exhaustion on oversized constrained collections) | Accepted for 0.1.x | The HTTP transport caps body size (default 5 MiB). The fix is `zod@4` (a major with breaking schema changes); migration is tracked separately and automated by Renovate. `npm audit` runs report-only in CI until then. |
48
+
28
49
  ## Disclosure Policy
29
50
 
30
51
  We follow coordinated disclosure. Once a fix is ready, we will:
package/SKILL.md CHANGED
@@ -36,7 +36,24 @@ libraries, and obey explicit design constraints.
36
36
  Read `references/tools.md` for the tool contract and
37
37
  `references/handoff.md` before building your first handoff.
38
38
 
39
- ## Workflow
39
+ ## Fast path (two calls)
40
+
41
+ For a normal task, use `map_ui` and skip the granular flow:
42
+
43
+ ```text
44
+ map_ui({ intents, path: "." })
45
+ ```
46
+
47
+ `map_ui` detects the project, derives a Design MD when none is supplied,
48
+ builds and validates the handoff, submits it, and returns the mappings plus
49
+ scaffolds. It defaults to `submit`; use `mode: "lookup"` when the user only
50
+ asks "which component should I use?" (no lease or event-log write). If the
51
+ same intent keeps being refused, call `refusal_ledger` to group the reasons and
52
+ suggest a local component or a Design MD change. Only fall
53
+ back to the granular workflow below when you need to inspect or edit the
54
+ handoff, the Design MD, or the KB.
55
+
56
+ ## Workflow (granular)
40
57
 
41
58
  1. **Detect.** Call `detect_project`. Use `"."` for the target project.
42
59
  - Read `profile.framework`, `profile.styling`, `profile.libraries` and
@@ -52,9 +69,12 @@ Read `references/tools.md` for the tool contract and
52
69
  - Use only component ids returned here or by `preferred_components`.
53
70
  - Supported libraries are dynamic; do not assume shadcn.
54
71
 
55
- 3. **Write the Design MD.** Use the strict grammar in
56
- `references/design-md.md`. Author tokens, preferences, policy, and
57
- hard/soft constraints.
72
+ 3. **Get the Design MD.** Call `derive_design_md` first. It reads CSS
73
+ variables, Tailwind config, DTCG token files and an existing `DESIGN.md`,
74
+ and validates the result. If it returns `questions`, ask the user only those
75
+ (defaulted brand tokens, unresolved constraints) instead of authoring a full
76
+ Design MD. Only edit it when the user needs a constraint it could not infer.
77
+ The strict grammar is in `references/design-md.md`.
58
78
  - If the Design MD already exists as a file in the project, call
59
79
  `import_design_md` with its path to read and validate it; the returned
60
80
  `design_md` and `hash` are pinned for `build_handoff`.
@@ -99,6 +119,9 @@ Read `references/tools.md` for the tool contract and
99
119
  `PARTIAL`.
100
120
  - Preserve the scaffold's imports, component names, props, variants and
101
121
  `data-element` attributes. Formatting-only changes are fine.
122
+ - Keep the scaffold's `library_version` header: a scaffold verified against
123
+ one major line (for example MUI 6.x) must not be reused on another. If the
124
+ project is on a different major, re-detect and rebuild.
102
125
  - The gateway never writes files; you do.
103
126
  - If `dependency_changes` contains `requires_approval: true`, ask before
104
127
  installing anything.
@@ -120,9 +143,10 @@ Read `references/tools.md` for the tool contract and
120
143
  imported from; if no prefix is supplied the gateway infers one from the
121
144
  project's `tsconfig.json` `paths` (first `@/*`, then `~/`, then the first
122
145
  non-relative alias).
123
- - Call `verify_page` on the page source (pass the intent scaffolds as
124
- `files` and the same `page_plan`). Fix broken anchors, missing ids,
125
- unused imports and missing accessible names before claiming done. A
146
+ - Call `verify_page` on the page source (pass the intent scaffolds as
147
+ `files` and the same `page_plan`). Fix broken anchors, missing ids,
148
+ unused imports, missing accessible names and any `MISSING_STATE`
149
+ (declared required states that are not wired) before claiming done. A
126
150
  `COMPILE_ERROR` whose message says `tsc timed out in the compile sandbox`
127
151
  is a slow sandbox, not a code defect: retry once, then report the exact
128
152
  message instead of rewriting the page.
@@ -141,19 +165,27 @@ Read `references/tools.md` for the tool contract and
141
165
  | `FAILED` | Write nothing. Report the error code and details. |
142
166
  | `EXPIRED` | Check `get_handoff`; rebuild with a fresh deadline only if the user still wants it. |
143
167
 
144
- `submit_handoff` can return `ok: false` with `outcome: "REJECTED"`,
145
- `"FAILED"` or `"EXPIRED"`. `REJECTED` means pre-flight validation failed; no
146
- result exists. Report the typed error.
168
+ `submit_handoff` sets `ok: true` only when `outcome` is `COMPLETED`. Every other
169
+ outcome returns `ok: false`, a single `blocking` object (`kind`, `code`,
170
+ `message`, `retryable`, `fix`) and usually the result, so read `blocking.code`
171
+ and `blocking.fix` before the rest of the result. `REJECTED` means pre-flight
172
+ validation
173
+ failed and there is no result; report the typed error.
174
+
175
+ In page mode, `result.page.verification` is the gateway's own check of the page
176
+ it composed. If any of those checks fail the outcome is `PARTIAL`, and
177
+ `verification.issues` names the problem (for example a nav target that matches
178
+ no id). Fix the plan or ask; do not write a page that failed its checks.
147
179
 
148
180
  ## Error and retry policy
149
181
 
150
182
  - `INVALID_HANDOFF`, `UNSATISFIABLE_CONSTRAINTS`, `UNSUPPORTED`, `CONFLICT`,
151
- `RESULT_REJECTED`: deterministic. Fix the payload or ask the user; never
152
- resubmit unchanged.
183
+ `INTEGRITY_MISMATCH`, `RESULT_REJECTED`: deterministic. Fix the payload or ask
184
+ the user; never resubmit unchanged. `INTEGRITY_MISMATCH` means re-detect and
185
+ rebuild — the same bytes will fail the same way.
153
186
  - `KB_STALE`: call `describe_kb`, update `kb_version`, rebuild, resubmit once.
154
187
  - `LEASE_EXPIRED` / `LEASE_CONFLICT`: call `get_handoff`; wait for the lease,
155
188
  do not submit in parallel.
156
- - `INTEGRITY_MISMATCH`: re-detect, rebuild, resubmit once. If it persists, stop.
157
189
  - Validation errors: at most two repair attempts. Then report the exact report
158
190
  and ask.
159
191
 
@@ -202,7 +234,29 @@ Files:
202
234
  ```
203
235
 
204
236
  For `PARTIAL` / `NEEDS_INPUT` / `AMBIGUOUS` / `FAILED`, list what was not
205
- applied and ask the exact questions. Do not dump the full gateway JSON.
237
+ applied and ask the exact questions. Do not dump the full gateway JSON. Read
238
+ `blocking.fix` first — it names the concrete next step. For a shareable report,
239
+ `ui-gateway receipt <result.json>` renders the outcome, the blocking cause and
240
+ fix, the closest rejected candidates and confidence as standalone HTML.
241
+
242
+ Non-COMPLETED shape (fill from the result; never invent fields):
243
+
244
+ ```markdown
245
+ ## UI Gateway result
246
+
247
+ Outcome: PARTIAL (2/3 mapped, acceptance failed)
248
+
249
+ Applied:
250
+ - `submit-order` -> shadcn `Button` (verification: passed)
251
+
252
+ Not applied:
253
+ - `orders-table` — no candidate passed verification (closest: shadcn/Table, role overlap). Fix: add a local `OrdersTable` or relax the constraint.
254
+
255
+ Blocking: acceptance / ACCEPTANCE_FAILED — acceptance criteria failed: all_intents_mapped. Do next: satisfy the failed criteria, or change acceptance_criteria if the criteria are wrong.
256
+
257
+ Checks:
258
+ - `all_intents_mapped`: failed
259
+ ```
206
260
 
207
261
  ## References
208
262
 
@@ -217,13 +271,13 @@ applied and ask the exact questions. Do not dump the full gateway JSON.
217
271
  - `references/tools.md` — tool order, inputs, resources and MCP setup.
218
272
  - `examples/design-md.md`, `examples/handoff.json` — complete examples.
219
273
 
220
- ## Definition of done
274
+ ## Before reporting done
221
275
 
222
- Before submitting, verify:
276
+ After writing the files, verify:
223
277
 
224
278
  - Every navigation item has a target (href/route).
225
279
  - Every button/link does something (action or navigation).
226
- - Empty, loading, and error states exist.
280
+ - Empty, loading, and error states exist and `verify_page`'s `states` check passes.
227
281
  - Keyboard and mobile paths work.
228
282
  - No hidden-only labels.
229
283
  - Typecheck, lint, and browser smoke test pass.
package/action.yml ADDED
@@ -0,0 +1,90 @@
1
+ name: "UI Gateway Check"
2
+ description: "Check changed UI files against a Design MD: forbidden libraries/patterns, anchors, a11y and compile errors."
3
+ author: "ui-gateway"
4
+ branding:
5
+ icon: "check-circle"
6
+ color: "blue"
7
+
8
+ inputs:
9
+ project:
10
+ description: "Project directory to resolve paths and the Design MD against."
11
+ required: false
12
+ default: "."
13
+ files:
14
+ description: "Space-separated files or directories. Defaults to files changed in the PR/push."
15
+ required: false
16
+ default: ""
17
+ design-md:
18
+ description: "Path to the Design MD. Defaults to DESIGN.md/design.md/docs/DESIGN.md."
19
+ required: false
20
+ default: ""
21
+ version:
22
+ description: "ui-gateway version to run from npm."
23
+ required: false
24
+ default: "latest"
25
+ compile:
26
+ description: "Run the throwaway TypeScript compile sandbox."
27
+ required: false
28
+ default: "false"
29
+ post-comments:
30
+ description: "Post inline PR review comments for findings."
31
+ required: false
32
+ default: "true"
33
+
34
+ outputs:
35
+ report:
36
+ description: "Path to the JSON check report."
37
+ value: ${{ steps.check.outputs.report }}
38
+
39
+ runs:
40
+ using: "composite"
41
+ steps:
42
+ - name: Resolve changed files
43
+ id: files
44
+ shell: bash
45
+ run: |
46
+ set -euo pipefail
47
+ if [ -n "${{ inputs.files }}" ]; then
48
+ echo "files=${{ inputs.files }}" >> "$GITHUB_OUTPUT"
49
+ exit 0
50
+ fi
51
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
52
+ base="${{ github.event.pull_request.base.sha }}"
53
+ elif [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
54
+ base="${{ github.event.before }}"
55
+ else
56
+ base="HEAD~1"
57
+ fi
58
+ changed=$(git diff --name-only --diff-filter=ACMR "$base"...HEAD -- '*.tsx' '*.jsx' '*.ts' '*.js' '*.vue' '*.svelte' | tr '\n' ' ')
59
+ echo "files=$changed" >> "$GITHUB_OUTPUT"
60
+
61
+ - name: Run check
62
+ id: check
63
+ shell: bash
64
+ run: |
65
+ set -uo pipefail
66
+ report="$RUNNER_TEMP/ui-gateway-report.json"
67
+ echo "report=$report" >> "$GITHUB_OUTPUT"
68
+ files="${{ steps.files.outputs.files }}"
69
+ if [ -z "${files// /}" ]; then
70
+ echo "No UI source files changed; nothing to check."
71
+ printf '{"ok":true,"checked":[],"findings":[],"summary":{"errors":0,"warnings":0},"design_path":null}\n' > "$report"
72
+ exit 0
73
+ fi
74
+ args=(check $files --project "${{ inputs.project }}" --json)
75
+ if [ -n "${{ inputs.design-md }}" ]; then args+=(--design "${{ inputs.design-md }}"); fi
76
+ if [ "${{ inputs.compile }}" = "true" ]; then args+=(--compile); fi
77
+ npx --yes "ui-gateway@${{ inputs.version }}" "${args[@]}" > "$report" || true
78
+ cat "$report"
79
+
80
+ - name: Post inline review comments
81
+ if: ${{ inputs.post-comments == 'true' && github.event_name == 'pull_request' }}
82
+ shell: bash
83
+ env:
84
+ GITHUB_TOKEN: ${{ github.token }}
85
+ run: node "${{ github.action_path }}/scripts/action-review.mjs" "$RUNNER_TEMP/ui-gateway-report.json"
86
+
87
+ - name: Fail on hard findings
88
+ shell: bash
89
+ run: |
90
+ node -e "const r=require(process.argv[1]); if(!r.ok) process.exit(1)" "$RUNNER_TEMP/ui-gateway-report.json"
@@ -1,6 +1,7 @@
1
+ import { type ConfidenceSignals } from "@uigw/protocol";
1
2
  import { type ModelCall, type SelectionModel } from "@uigw/matcher";
2
3
  import { coverageMatrix, type GoldenSet } from "./golden";
3
- import { checkThresholds, type CalibrationReport, type MetricsReport, type Thresholds } from "./metrics";
4
+ import { checkThresholds, type CalibrationReport, type MetricsReport, type TaskOutcomeReport, type Thresholds } from "./metrics";
4
5
  import { type LocalLlmOptions, type OpenAiCompatibleOptions, type SimulatedBehaviorName } from "./local-llm";
5
6
  export interface ArmReport {
6
7
  name: string;
@@ -11,6 +12,7 @@ export interface ArmReport {
11
12
  predicted: string[];
12
13
  acceptable: string[];
13
14
  confidence: number;
15
+ signals?: ConfidenceSignals;
14
16
  }>;
15
17
  }
16
18
  export interface BaselineModelInfo {
@@ -36,6 +38,7 @@ export interface BaselineReport {
36
38
  threshold_checks: ReturnType<typeof checkThresholds>;
37
39
  thresholds_passed: boolean;
38
40
  calibration: CalibrationReport;
41
+ task_outcomes: TaskOutcomeReport;
39
42
  model_info: BaselineModelInfo | null;
40
43
  n_sample_agreement: NSampleAgreementReport | null;
41
44
  notes: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../../evals/src/baseline.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,cAAc,EAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAA+C,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACvG,OAAO,EACL,eAAe,EAGf,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAsK,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,KAAK,qBAAqB,EAA2D,MAAM,aAAa,CAAC;AAE1U,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxG;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,KAAK,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,CAAC,CAAC;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,c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