ui-gateway 0.1.1 → 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 +136 -41
  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 +29 -6
  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
@@ -0,0 +1,41 @@
1
+ # Distribution
2
+
3
+ ## What ships
4
+
5
+ `npm pack` includes `dist/`, `scripts/`, `evals/`, `references/`, `examples/`,
6
+ `docs/`, `templates/`, `skills/`, `action.yml`, `SKILL.md` and the policy files.
7
+ The CLI shebang is `node`; consumers do not need `tsx`.
8
+
9
+ ## Listings
10
+
11
+ 1. Build the plugin bundle: `npm run plugin:bundle` (writes `.tmp/ui-gateway-plugin`).
12
+ 2. MCP registry: publish the server entry (`npx ui-gateway mcp`).
13
+ 3. Claude Code plugin marketplace / skills directories: the bundle contains
14
+ `SKILL.md`, `references/`, `examples/` and `.mcp.json`.
15
+ 4. npm keywords already include `mcp`, `design-system`, `shadcn`, `mui`,
16
+ `chakra`, `mantine`.
17
+
18
+ External listing submission, launch posts, demo videos and design-partner case
19
+ studies are outreach tasks; this repository cannot perform them. The assets they
20
+ need (templates, plugin bundle, benchmark method, refusal catalog) are here.
21
+
22
+ ## Starter templates
23
+
24
+ - `templates/next-shadcn`
25
+ - `templates/vite-mui`
26
+ - `templates/vite-mantine`
27
+
28
+ Each has a working `.mcp.json`, a valid `DESIGN.md`, a CI workflow and a page the
29
+ agent can edit.
30
+
31
+ ## Launch story
32
+
33
+ Lead with `BENCHMARK.md`, including where the gateway loses. The honest claim is
34
+ narrow: verified mappings and typed refusals, not "the model always picks right".
35
+
36
+ ## Case studies
37
+
38
+ Use `evals/out/*.json` and `ui-gateway receipt` output as the before/after
39
+ evidence. A receipt is self-contained HTML: mapped intents, the single blocking
40
+ cause with its concrete fix, the closest rejected candidates and why, refusals
41
+ and confidence signals.
@@ -0,0 +1,152 @@
1
+ # UI Gateway: Engineering Principles
2
+
3
+ Rules for building and maintaining the gateway and its agent skill. They come
4
+ from what worked in the codebase (typed refusals, no guessing) and what failed
5
+ in a real first run (too many rounds, unclear refusals, placeholder output).
6
+
7
+ Use "must" for rules a release can be blocked on, and "should" for strong
8
+ defaults.
9
+
10
+ ---
11
+
12
+ ## 1. Correctness over convenience
13
+
14
+ 1. **Fail closed.** When the gateway cannot answer safely, it returns a typed
15
+ refusal. It must never return a plausible guess.
16
+ 2. **Never invent.** Component ids, imports, props, variants and packages come
17
+ from the knowledge base. Generated code must not contain anything the KB does
18
+ not declare.
19
+ 3. **Verify what you claim.** A result says `COMPLETED` only if acceptance
20
+ checks passed. Docs, logs and reports must not claim a file was written or a
21
+ check passed unless it was.
22
+ 4. **Determinism.** The same input produces the same output and the same hash.
23
+ Anything non-deterministic (time, ids) stays out of hashed fields.
24
+ 5. **Pin versions.** Scaffolds target a specific (library, version) pair. A
25
+ scaffold that works on one major version must not be silently reused on
26
+ another.
27
+
28
+ ## 2. Honest interfaces
29
+
30
+ 1. **Status fields mean what they say.** Top-level `ok` must agree with
31
+ `outcome`. `ok: true` with `NEEDS_INPUT` is a bug.
32
+ 2. **One blocking reason.** Every non-success result exposes a single `blocking`
33
+ field with the cause, so the caller does not hunt through nested checks.
34
+ 3. **Stable output shape.** Every command writes the same JSON shape to stdout.
35
+ Types do not change between calls (a scaffold is always an object, never
36
+ sometimes a string).
37
+ 4. **Exit codes carry meaning.** Success is 0. `NEEDS_INPUT`, `PARTIAL` and
38
+ `FAILED` each have a distinct non-zero code.
39
+ 5. **Write nothing by surprise.** The gateway returns code and never writes
40
+ files, installs packages or opens pull requests. Flags that write (`--out`)
41
+ also echo what they wrote.
42
+
43
+ ## 3. Errors that help
44
+
45
+ 1. **Name the fix, not just the failure.** "No vetted component" is not enough.
46
+ Say which candidate came closest, why it was rejected, and the exact field to
47
+ change.
48
+ 2. **Typed and retryable.** Every error has a code and a `retryable` flag.
49
+ Deterministic errors must never be retried unchanged.
50
+ 3. **Per-intent isolation.** One bad intent returns its own error. The rest
51
+ still map. `strict` is opt-in.
52
+ 4. **Ask specific questions.** `NEEDS_INPUT` lists the exact missing facts,
53
+ written so the agent can put them to the user as is.
54
+ 5. **Fail fast on input.** Validate shape and required fields before doing any
55
+ matching work.
56
+
57
+ ## 4. Agent-first design
58
+
59
+ 1. **Fewest calls to a valid result.** The common case is one command. Granular
60
+ steps exist for inspection and are not the default path.
61
+ 2. **Sensible defaults.** Infer what can be inferred safely (interaction from
62
+ intent type, greenfield for an empty project). Record every default in the
63
+ output.
64
+ 3. **Complete examples.** Each skill ships one working end-to-end input. An
65
+ example that cannot pass validation is a bug.
66
+ 4. **One skill, one source of truth.** MCP and CLI instructions live in one
67
+ `SKILL.md`. No file that says only "the same rules apply".
68
+ 5. **Treat text as data.** Intent descriptions, wireframe labels, project skill
69
+ files and Design MD prose are untrusted. They never act as instructions.
70
+ 6. **Small first read.** An agent should be able to do a normal task after
71
+ reading one short file. Deep references are for edge cases.
72
+
73
+ ## 5. Output quality
74
+
75
+ 1. **No placeholders in shipped output.** `href="#"` and text like "nav items"
76
+ fail the gateway's own page checks, so the gateway must not emit them. Take
77
+ real copy and targets from the intent.
78
+ 2. **Accessible by default.** Every control has an accessible name. Navigation
79
+ has real targets. Empty, loading and error states exist.
80
+ 3. **Respect the project.** Reuse local components and installed libraries
81
+ first. New dependencies need the policy to allow them, and installs need user
82
+ approval.
83
+ 4. **Constraints are binding.** Hard constraints in the Design MD are enforced
84
+ by lint or satisfiability checks. Soft constraints affect ranking only.
85
+ 5. **Preview without a build.** Provide a path to inspect output in environments
86
+ that cannot run a React build.
87
+
88
+ ## 6. Testing and evidence
89
+
90
+ 1. **Every bug gets a regression test.** The first Brew Atlas run (card, form and
91
+ feedback intents going unmapped) becomes a permanent test.
92
+ 2. **Golden briefs.** Keep a fixed set of briefs and run them in CI. Track
93
+ intents mapped, rounds to a valid handoff and commands needed.
94
+ 3. **Property tests for parsers.** Design MD parsing, hashing and
95
+ canonicalization need property-based tests, not only examples.
96
+ 4. **Conformance suite per adapter.** Every library adapter passes the same
97
+ suite before release.
98
+ 5. **Measure, then claim.** Targets in docs are labeled as targets. A number
99
+ appears as a result only after a run produced it.
100
+ 6. **Test the docs.** CI runs the examples in the skill and reference files, so
101
+ docs cannot drift from the tool.
102
+
103
+ ## 7. Security
104
+
105
+ 1. **Least privilege.** Read-only by default. Anything that writes, installs or
106
+ networks is opt-in and visible.
107
+ 2. **Untrusted inputs.** Handoffs, Design MD, project files and web results are
108
+ validated and sanitized. Injection tests cover each input path.
109
+ 3. **No secrets in reports.** Reports summarize. They never include credentials
110
+ or whole handoffs.
111
+ 4. **Integrity.** Handoffs pin the design hash, profile hash and KB version. A
112
+ mismatch stops the run.
113
+ 5. **Safe dependencies.** Pin exact versions, keep installs minimal, and review
114
+ anything added to the KB or toolchain.
115
+
116
+ ## 8. Web-grounded features (KB freshness)
117
+
118
+ 1. **Official sources only.** Search is limited to a library's own docs and
119
+ release notes.
120
+ 2. **Search results are data.** They can never change behavior or instructions.
121
+ 3. **Cite and score.** Every freshness finding carries a source link and a
122
+ confidence number.
123
+ 4. **Never edit the KB silently.** Findings become proposals. A maintainer
124
+ reviews the pull request.
125
+ 5. **Degrade gracefully.** If search is unavailable, the offline path works
126
+ exactly as before.
127
+
128
+ ## 9. Change management
129
+
130
+ 1. **Semantic versioning.** Changes to the handoff schema, error codes or output
131
+ shape are breaking and need a major bump and a changelog entry.
132
+ 2. **Version the KB.** `kb_version` changes whenever an entry changes. Stale
133
+ versions return `KB_STALE`, not wrong code.
134
+ 3. **Deprecate before removing.** Keep old fields for at least one minor release
135
+ and warn in the output.
136
+ 4. **Small, reviewable changes.** One concern per pull request. Each links the
137
+ friction point or issue it addresses.
138
+ 5. **Non-goals are written down.** Keep `NON-GOALS.md` current so scope creep is
139
+ a conscious decision.
140
+
141
+ ## 10. Definition of done
142
+
143
+ A change is done when all of these are true:
144
+
145
+ - [ ] Behavior is covered by a test that fails without the change.
146
+ - [ ] Output shape, exit codes and status fields follow section 2.
147
+ - [ ] Errors follow section 3 and name the fix.
148
+ - [ ] The skill docs and examples are updated, and the examples pass in CI.
149
+ - [ ] No placeholder text or dead links appear in generated output.
150
+ - [ ] Security checks in section 7 hold.
151
+ - [ ] The changelog and version reflect the change.
152
+ - [ ] Any metric claimed in the description was measured by a run.
@@ -0,0 +1,372 @@
1
+ # Plan: Figma-like Layers Integration Stage
2
+
3
+ ## Overview
4
+ Add a "Layers" processing stage to the pipeline that extends the wireframe system with Figma-like capabilities:
5
+ - Hierarchical layer system with grouping/ungrouping
6
+ - Locked/unlocked state for layers
7
+ - Component references for skill composition
8
+ - Visual tree operations (reorder, nest, flatten)
9
+
10
+ ## Current Pipeline Position
11
+ ```
12
+ Handoff → Profile Detection → Design MD Compile → Satisfiability → KB Build → Intent Matching → Verification → Result
13
+ ↑
14
+ NEW: Layer Processing Stage
15
+ ```
16
+
17
+ The layer stage runs after profile detection and before satisfiability, enriching the wireframe with layer metadata that flows through to intent matching and skill execution.
18
+
19
+ ## Implementation Status: ✅ COMPLETED (All 5 Phases)
20
+
21
+ | Phase | Description | Status |
22
+ |-------|-------------|--------|
23
+ | 1 | Schema & Types | ✅ Done |
24
+ | 2 | Layer Processor | ✅ Done |
25
+ | 3 | Pipeline Integration | ✅ Done |
26
+ | 4 | Skill Integration | ✅ Done |
27
+ | 5 | CLI & Testing | ✅ Done |
28
+
29
+ ## Schema Extensions (packages/protocol/src/schemas.ts)
30
+
31
+ ### Extended WireframeNode
32
+ ```typescript
33
+ // New properties added to WireframeNodeSchema
34
+ interface WireframeNode {
35
+ // ...existing fields
36
+ id: string;
37
+ kind: "page" | "section" | "region" | "element" | "component";
38
+ label?: string;
39
+ role?: string;
40
+ text?: string;
41
+ children?: WireframeNode[];
42
+
43
+ // NEW: Layer properties
44
+ locked?: boolean; // Prevents modification
45
+ visible?: boolean; // Visibility toggle
46
+ componentRef?: string; // Reference to KB component_id (e.g., "shadcn/button")
47
+ componentInstanceId?: string; // Unique instance ID for duplicate components
48
+ groupId?: string; // Group membership for grouping/ungrouping
49
+ zIndex?: number; // Explicit z-order within parent
50
+ constraints?: LayerConstraints; // Layout constraints (Figma-like)
51
+ pluginData?: Record<string, unknown>; // Extensible metadata for skills
52
+ }
53
+
54
+ interface LayerConstraints {
55
+ horizontal?: "left" | "center" | "right" | "scale" | "left-right";
56
+ vertical?: "top" | "center" | "bottom" | "scale" | "top-bottom";
57
+ minWidth?: number;
58
+ minHeight?: number;
59
+ maxWidth?: number;
60
+ maxHeight?: number;
61
+ }
62
+ ```
63
+
64
+ ### Layer Operations (new types)
65
+ ```typescript
66
+ // Layer tree operations
67
+ type LayerOperation =
68
+ | { type: "group"; nodeIds: string[]; groupId: string; parentId?: string }
69
+ | { type: "ungroup"; groupId: string }
70
+ | { type: "lock"; nodeIds: string[]; locked: boolean }
71
+ | { type: "visibility"; nodeIds: string[]; visible: boolean }
72
+ | { type: "reorder"; nodeId: string; newIndex: number; newParentId?: string }
73
+ | { type: "setComponentRef"; nodeId: string; componentRef: string; instanceId: string }
74
+ | { type: "setConstraints"; nodeId: string; constraints: LayerConstraints };
75
+
76
+ // Layer processing result
77
+ interface LayerProcessingResult {
78
+ wireframe: Wireframe; // Enhanced wireframe with layer metadata
79
+ layerTree: LayerTree; // Flattened layer list with hierarchy info
80
+ operations: LayerOperation[]; // Operations applied
81
+ componentInstances: ComponentInstance[]; // Resolved component references
82
+ }
83
+
84
+ interface LayerTree {
85
+ nodes: LayerNode[];
86
+ groups: Record<string, LayerGroup>; // Changed from Map to Record for Zod compatibility
87
+ rootId: string;
88
+ }
89
+
90
+ interface LayerNode {
91
+ id: string;
92
+ parentId: string | null;
93
+ depth: number;
94
+ order: number;
95
+ locked: boolean;
96
+ visible: boolean;
97
+ componentRef?: string;
98
+ componentInstanceId?: string;
99
+ groupId?: string;
100
+ constraints?: LayerConstraints;
101
+ kind: WireframeKind;
102
+ label?: string;
103
+ }
104
+
105
+ interface LayerGroup {
106
+ id: string;
107
+ name: string;
108
+ memberIds: string[];
109
+ locked: boolean;
110
+ expanded: boolean;
111
+ }
112
+
113
+ interface ComponentInstance {
114
+ instanceId: string;
115
+ nodeId: string;
116
+ componentRef: string;
117
+ kbEntry?: ComponentEntry; // Resolved from KB
118
+ props: Record<string, unknown>; // Merged from KB defaults + wireframe overrides
119
+ }
120
+ ```
121
+
122
+ ## Pipeline Integration (packages/gateway/src/gateway.ts)
123
+
124
+ ### New Stage: `processLayers`
125
+ ```typescript
126
+ private async processLayers(
127
+ handoff: Handoff,
128
+ design: CompiledDesign,
129
+ kb: KnowledgeBase,
130
+ ): Promise<LayerProcessingResult> {
131
+ // 1. Parse wireframe into layer tree
132
+ const layerTree = buildLayerTree(handoff.wireframe.root);
133
+
134
+ // 2. Apply any layer operations from handoff.metadata.layers
135
+ const operations = handoff.metadata?.layers as LayerOperation[] ?? [];
136
+ const processedTree = applyLayerOperations(layerTree, operations);
137
+
138
+ // 3. Resolve component references against KB
139
+ const componentInstances = resolveComponentRefs(processedTree, kb);
140
+
141
+ // 4. Merge component props with wireframe data
142
+ const enrichedWireframe = enrichWireframeWithLayers(handoff.wireframe, processedTree, componentInstances);
143
+
144
+ return { wireframe: enrichedWireframe, layerTree: processedTree, operations, componentInstances };
145
+ }
146
+ ```
147
+
148
+ ### Integration Point
149
+ In `process()` method, after KB build and before intent matching:
150
+ ```typescript
151
+ // After KB build, before intent matching
152
+ const layerResult = await this.processLayers(handoff, design, kb);
153
+ // Use layerResult.wireframe for downstream processing
154
+ // Pass layerResult.componentInstances to intent matching for skill composition
155
+ ```
156
+
157
+ ### Skill Layer Operations in runIntent
158
+ ```typescript
159
+ // Execute skill layer operations if profile has layer-aware skills
160
+ let currentLayerTree = layerTree;
161
+ let currentComponentInstances = componentInstances;
162
+ if (profile && layerTree && componentInstances) {
163
+ const skillContext = createSkillLayerContext(layerTree, componentInstances);
164
+ const allLayerOps: LayerOperation[] = [];
165
+ for (const skill of profile.skills.value ?? []) {
166
+ if (skill.layerOperations && skill.layerOperations.length > 0) {
167
+ allLayerOps.push(...skill.layerOperations);
168
+ }
169
+ }
170
+ if (allLayerOps.length > 0) {
171
+ currentLayerTree = executeSkillLayerOperations(skillContext, allLayerOps);
172
+ // Re-resolve component instances after layer operations
173
+ currentComponentInstances = resolveComponentRefs(currentLayerTree, kb);
174
+ }
175
+ }
176
+ ```
177
+
178
+ ## Skill Integration (packages/profile/src/skill-layer-context.ts)
179
+
180
+ ### Extended SkillRef
181
+ ```typescript
182
+ interface SkillRef {
183
+ // ...existing
184
+ path: string;
185
+ name: string;
186
+ version: string;
187
+ // NEW: Layer awareness
188
+ layerSelectors?: string[]; // CSS-like selectors for target layers
189
+ layerOperations?: LayerOperation[]; // Operations this skill applies
190
+ requiresComponents?: string[]; // Component refs this skill needs
191
+ }
192
+ ```
193
+
194
+ ### Skill Layer API
195
+ ```typescript
196
+ // Skills receive layer context
197
+ interface SkillLayerContext {
198
+ layerTree: LayerTree;
199
+ componentInstances: ComponentInstance[];
200
+ selectLayers(selector: string): LayerNode[];
201
+ applyOperation(op: LayerOperation): LayerTree;
202
+ getComponentInstance(instanceId: string): ComponentInstance | undefined;
203
+ getGroupMembers(groupId: string): LayerNode[];
204
+ getNodeGroup(nodeId: string): LayerGroup | undefined;
205
+ isLocked(nodeId: string): boolean;
206
+ isVisible(nodeId: string): boolean;
207
+ getNodePath(nodeId: string): LayerNode[];
208
+ }
209
+ ```
210
+
211
+ ### CSS-like Selectors Supported
212
+ - `#id` - Select by node ID
213
+ - `[attr=value]` - Select by attribute (e.g., `[componentRef="shadcn/button"]`)
214
+ - `.group:name` - Select all members of a group
215
+ - `.kind:name` - Select by node kind (page, section, region, element, component)
216
+ - `.locked` - Select locked nodes
217
+ - `.visible` - Select visible nodes
218
+ - `.component` - Select nodes with componentRef
219
+ - `tag` - Select by kind or label
220
+
221
+ ### Skill Execution
222
+ Skills declare `layerSelectors`, `layerOperations`, and `requiresComponents` in their frontmatter. The gateway automatically:
223
+ 1. Creates a `SkillLayerContext` from the layer tree and component instances
224
+ 2. Executes all `layerOperations` from all skills before intent matching
225
+ 3. Re-resolves component instances after layer operations
226
+
227
+ ## Component Composition (packages/kb/src/entry.ts)
228
+
229
+ ### Enhanced EntryPart for Layer Mapping
230
+ ```typescript
231
+ // EntryPart already has slots, props - extend with layer mapping
232
+ interface EntryPart {
233
+ name: string;
234
+ props: PropDefinition[];
235
+ slots: string[];
236
+ description?: string;
237
+ // NEW: Layer mapping for Figma-like component composition
238
+ layerMapping?: {
239
+ targetKind: "section" | "region" | "element"; // What layer kind this part maps to
240
+ slotName?: string; // Which slot in the parent component
241
+ constraints?: LayerConstraints; // Default constraints
242
+ };
243
+ }
244
+ ```
245
+
246
+ ## CLI Integration (packages/transports/src/cli.ts)
247
+
248
+ ### New Commands
249
+ ```bash
250
+ # Layer operations
251
+ uigateway layers list <handoff.json> [--project <dir>] # List all layers in hierarchy
252
+ uigateway layers apply <handoff.json> <operations.json> [--project <dir>] # Apply layer operations
253
+ uigateway layers select <handoff.json> <selector> [--project <dir>] # Select layers by CSS-like selector
254
+ ```
255
+
256
+ Note: CLI commands take handoff JSON files directly (not handoff IDs), making them suitable for file-based workflows.
257
+
258
+ ### Example Usage
259
+ ```bash
260
+ # List layers from a handoff
261
+ uigateway layers list handoff.json --project ./my-project
262
+
263
+ # Apply layer operations from a JSON file
264
+ uigateway layers apply handoff.json operations.json --project ./my-project
265
+
266
+ # Select layers using CSS-like selector
267
+ uigateway layers select handoff.json ".component"
268
+ uigateway layers select handoff.json "#node-123"
269
+ uigateway layers select handoff.json "[componentRef=\"shadcn/button\"]"
270
+ uigateway layers select handoff.json ".group:header-group"
271
+ ```
272
+
273
+ ### Operations File Format (operations.json)
274
+ ```json
275
+ [
276
+ { "type": "group", "nodeIds": ["node-1", "node-2"], "groupId": "header-group", "parentId": "root" },
277
+ { "type": "lock", "nodeIds": ["node-1"], "locked": true },
278
+ { "type": "setComponentRef", "nodeId": "node-1", "componentRef": "shadcn/button", "instanceId": "btn-instance-1" }
279
+ ]
280
+ ```
281
+
282
+ ## Testing
283
+
284
+ ### Property-Based Tests (packages/verifier/src/verifier.pbt.test.ts)
285
+ Added 10 new property-based tests covering:
286
+ - `buildLayerTree` preserves all nodes and hierarchy
287
+ - `applyLayerOperations` - group/ungroup idempotency
288
+ - `applyLayerOperations` - lock/unlock toggles correctly
289
+ - `applyLayerOperations` - visibility toggles correctly
290
+ - `selectLayers` - ID selector returns correct node
291
+ - `selectLayers` - kind selector returns matching nodes
292
+ - `selectLayers` - component selector returns nodes with componentRef
293
+ - `SkillLayerContext` - isLocked returns true for locked nodes
294
+ - `SkillLayerContext` - isVisible returns false for hidden nodes
295
+ - `SkillLayerContext` - getNodePath returns correct ancestry
296
+
297
+ All 117 tests pass (107 original + 10 new).
298
+
299
+ ## Example Handoff with Layers
300
+
301
+ ```json
302
+ {
303
+ "schema_version": "1.0",
304
+ "handoff_id": "h-123",
305
+ "wireframe": {
306
+ "root": {
307
+ "id": "page-1",
308
+ "kind": "page",
309
+ "label": "Dashboard",
310
+ "children": [
311
+ {
312
+ "id": "header-group",
313
+ "kind": "section",
314
+ "label": "Header",
315
+ "groupId": "header-group",
316
+ "locked": true,
317
+ "children": [
318
+ { "id": "logo", "kind": "element", "label": "Logo", "componentRef": "shadcn/avatar" },
319
+ { "id": "nav", "kind": "component", "label": "Navigation", "componentRef": "shadcn/navigation-menu" }
320
+ ]
321
+ },
322
+ {
323
+ "id": "content",
324
+ "kind": "region",
325
+ "label": "Main Content",
326
+ "children": [
327
+ { "id": "card-1", "kind": "component", "label": "Stats Card", "componentRef": "shadcn/card", "componentInstanceId": "card-1" },
328
+ { "id": "card-2", "kind": "component", "label": "Stats Card", "componentRef": "shadcn/card", "componentInstanceId": "card-2" }
329
+ ]
330
+ }
331
+ ]
332
+ }
333
+ },
334
+ "metadata": {
335
+ "layers": [
336
+ { "type": "lock", "nodeIds": ["header-group"], "locked": true },
337
+ { "type": "group", "nodeIds": ["card-1", "card-2"], "groupId": "stats-cards", "parentId": "content" }
338
+ ]
339
+ }
340
+ }
341
+ ```
342
+
343
+ ## Benefits
344
+
345
+ 1. **Visual Consistency**: Layer hierarchy mirrors Figma, making design-to-code handoff precise
346
+ 2. **Component Composition**: Skills can compose complex components from layer trees (Card → CardHeader + CardContent + CardFooter)
347
+ 3. **Locked Regions**: Design system teams can lock brand/header sections from modification
348
+ 4. **Skill Targeting**: Skills operate on specific layer selections (e.g., "apply dark mode to all unlocked regions")
349
+ 5. **Reusability**: Component instances with instanceIds enable proper multi-instance handling
350
+ 6. **Constraints**: Layout constraints flow through to scaffold generation for responsive code
351
+
352
+ ## Risk Mitigation
353
+
354
+ - **Backward Compatibility**: All new fields optional; existing handoffs work unchanged
355
+ - **Performance**: Layer tree built once, reused; max 200 nodes per wireframe
356
+ - **Complexity**: Layer operations are pure functions, easily testable
357
+ - **Scope Creep**: Start with core operations (group, lock, componentRef); add constraints later
358
+
359
+ ## Files Modified
360
+
361
+ | File | Description |
362
+ |------|-------------|
363
+ | `packages/protocol/src/schemas.ts` | Extended WireframeNode, LayerOperation, LayerTree, LayerNode, LayerGroup, ComponentInstance, SkillRef |
364
+ | `packages/gateway/src/layers.ts` | Layer processor: buildLayerTree, applyLayerOperations, resolveComponentRefs, enrichWireframeWithLayers, processLayers, selectLayers |
365
+ | `packages/gateway/src/gateway.ts` | Integrated processLayers, skill layer operations execution |
366
+ | `packages/profile/src/skills.ts` | Extended collectSkills to parse layerSelectors, layerOperations, requiresComponents |
367
+ | `packages/profile/src/skill-layer-context.ts` | New: SkillLayerContext API with CSS-like selectors |
368
+ | `packages/profile/src/index.ts` | Export skill-layer-context |
369
+ | `packages/kb/src/entry.ts` | Added EntryPart.layerMapping |
370
+ | `packages/transports/src/cli.ts` | Added layers list/apply/select commands |
371
+ | `packages/verifier/src/verifier.pbt.test.ts` | Added 10 property-based tests for layer operations |
372
+ | `docs/layers-plan.md` | Updated with implementation details |