@metamorph-labs/polymorph 1.0.18 → 1.0.19
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.
- package/CHANGELOG.md +242 -0
- package/dist/design/systems/desktop.json +1 -1
- package/dist/design/systems/dew.json +1 -1
- package/dist/design/systems/flint.json +1 -1
- package/dist/design/systems/glassmorphic.json +1 -1
- package/dist/design/systems/harbor.json +1 -1
- package/dist/design/systems/journal.json +1 -1
- package/dist/design/systems/pastel.json +1 -1
- package/dist/design/systems/pebble.json +1 -1
- package/dist/design/systems/plain.json +1 -1
- package/dist/design/systems/pop.json +1 -1
- package/dist/design/systems/press.json +1 -1
- package/dist/packages/angular-ui/src/ai/ArtifactPane.ts +15 -4
- package/dist/packages/angular-ui/src/ai/PromptInput.ts +3 -1
- package/dist/packages/angular-ui/src/archetypes/Dashboard.ts +38 -20
- package/dist/packages/angular-ui/src/archetypes/dashboard.states.ts +52 -0
- package/dist/packages/angular-ui/src/controls/ColorInput.ts +62 -34
- package/dist/packages/angular-ui/src/controls/Combobox.ts +28 -7
- package/dist/packages/angular-ui/src/controls/DatePicker.ts +12 -11
- package/dist/packages/angular-ui/src/controls/DateRangePicker.ts +22 -17
- package/dist/packages/angular-ui/src/controls/DateRangePickerRangeCalendar.ts +3 -2
- package/dist/packages/angular-ui/src/controls/FileUpload.ts +18 -12
- package/dist/packages/angular-ui/src/controls/FileUploadRow.ts +24 -4
- package/dist/packages/angular-ui/src/controls/MultiSelect.ts +49 -12
- package/dist/packages/angular-ui/src/controls/NumberInput.ts +27 -3
- package/dist/packages/angular-ui/src/controls/PhoneInput.ts +9 -5
- package/dist/packages/angular-ui/src/controls/Select.ts +36 -7
- package/dist/packages/angular-ui/src/controls/TagInput.ts +61 -7
- package/dist/packages/angular-ui/src/controls/TimeInput.ts +15 -1
- package/dist/packages/angular-ui/src/controls/select.states.ts +79 -58
- package/dist/packages/angular-ui/src/overlays/Command.ts +50 -13
- package/dist/packages/angular-ui/src/overlays/CommandPanel.ts +11 -7
- package/dist/packages/angular-ui/src/overlays/ToastViewport.ts +1 -1
- package/dist/packages/angular-ui/src/structure/CodeBlock.ts +18 -4
- package/dist/packages/angular-ui/src/structure/Stat.ts +295 -84
- package/dist/packages/angular-ui/src/structure/stat.states.ts +116 -0
- package/dist/packages/cli/src/agents.js +4 -3
- package/dist/packages/cli/src/apply.js +43 -18
- package/dist/packages/cli/src/check.js +4 -0
- package/dist/packages/cli/src/cli.js +6 -2
- package/dist/packages/cli/src/elements.js +12 -2
- package/dist/packages/cli/src/emit.js +43 -8
- package/dist/packages/cli/src/readings.js +29 -3
- package/dist/packages/cli/src/skills/bridge.js +1197 -0
- package/dist/packages/cli/src/skills/facts.js +190 -0
- package/dist/packages/cli/src/skills/native.js +1580 -0
- package/dist/packages/cli/src/skills/rules.js +199 -0
- package/dist/packages/cli/src/skills/runtime.js +1020 -0
- package/dist/packages/cli/src/skills/screen-charts.js +334 -0
- package/dist/packages/cli/src/skills/screen-chat.js +247 -0
- package/dist/packages/cli/src/skills/screen-code.js +565 -0
- package/dist/packages/cli/src/skills/screen-rich-text.js +305 -0
- package/dist/packages/cli/src/skills/screen.js +378 -0
- package/dist/packages/cli/src/skills/setup-packages.js +307 -0
- package/dist/packages/cli/src/skills/setup.js +125 -0
- package/dist/packages/cli/src/skills/theme-documents.js +351 -0
- package/dist/packages/cli/src/skills/theme.js +208 -0
- package/dist/packages/cli/src/skills.js +13 -794
- package/dist/packages/cli/src/theme.js +42 -1
- package/dist/packages/cli/src/tool-verbs.js +19 -4
- package/dist/packages/cli/src/verbs.js +28 -2
- package/dist/packages/elements-ui/dist/cdn/chunks/{AppShellUserCard-0eCCnnN_.js → AppShellUserCard-XT4br4fr.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AreaChart-DftfzLG0.js → AreaChart-CXNFfbJ8.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-Pr9_K2uM.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcdMgxgY.js → Avatar-3WXoBPLv.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcuvZwe7.js → Avatar-BKqjM8qW.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarButton-D5XKVduu.js → AvatarButton-BasMQCSM.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarGroup-DgFwJUNO.js → AvatarGroup-COch2-O0.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{BarChart-myuR0aHc.js → BarChart-ugae8zfr.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ChatMessage-CgQ1h_JP.js → ChatMessage-Bx4yrF2x.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-B_e5ma3K.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-Fgtr48Vb.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-CD7rsWRp.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-CUw7z6TS.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Combobox-DB2FT7so.js → Combobox-hWIFU9X_.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Command-BXgqRd3I.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{ConfirmDialog-BtQOAHY2.js → ConfirmDialog-CAaBRKxl.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Dashboard-ChMPH4_Q.js → Dashboard-DwNw5Wnd.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-DjqtswQR.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-LsXFHOzm.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{DonutChart-BEK89BeL.js → DonutChart-DYXx6eTe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-3gbZTSSx.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-PlLLDKqc.js → FormField-Bvw4cLBc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-C6L3vYp4.js → FormField-DzhcinED.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{FunnelChart-DVQz_gad.js → FunnelChart-D24XhrGw.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-fAcu6Vrw.js → Heading-Cvfyu8pc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-CgzEi9OQ.js → Heading-XDJzlwt9.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heatmap-BRwR-n-V.js → Heatmap-BQoUS6gY.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Hero-CV2YWeb4.js → Hero-CXuuFceS.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Histogram-CCYwlinB.js → Histogram-DW_ZPHpR.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{LineChart-BH6Pq1P1.js → LineChart-kf-zlNWe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Markdown-DmZEch4i.js → Markdown-C3rjhIbt.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-DQ86CK9h.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-DbSx9QtV.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-B4ZZOGLl.js +7 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-BsMfbNi6.js +210 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-l_-zAXSZ.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{RadarChart-Coje7Sb0.js → RadarChart-CwJAWRki.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextContent-CufjptHF.js → RichTextContent-D51UfuWk.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextInput-Dz7yBFUA.js → RichTextInput-B32fN_p9.js} +3 -3
- package/dist/packages/elements-ui/dist/cdn/chunks/{ScatterChart-Do5tQTC5.js → ScatterChart-Mps7l5-i.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Select-CpsRP0NR.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-CXR6bP7X.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-DGcx2ZZq.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-BhkLU4gE.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-r2jNTOLN.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Toast-CAYGbn7g.js → Toast-BTfcZn0I.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ToastViewport-CFslglYc.js → ToastViewport-BBQMRCQT.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ToolCall-DUCoKsoE.js → ToolCall-DNU5kk9_.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Treemap-Bh3ruYGJ.js → Treemap-BV8TlZHB.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/agent-DfOqpL9c.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/api-DJBiUXxK.js +4 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-D4YdFevY.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/cap-DA71oFHt.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{cartesian-I5uPfyqv.js → cartesian-CEn2lJCc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{chart-annotations.module-xUExw4pu.js → chart-annotations.module-hA_KO_Pe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-C_8txUW5.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-BpfyTQ9R.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/check-CHvc4yHL.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/css-vars-DeZ4TCna.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/draw-BiQ3Of6N.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/drawing-nhJNBahV.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/field-labels-Df5HuYC5.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/frame-CtTY4oCn.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/on-call-YKLF3-FH.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/runtime-QRQ3CjZg.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/series-uUg6_JtL.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/src-XnWjGSDr.js +67 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/toast-pwGvxH2T.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/urls-Qks0KJ_p.js +6 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-Dro53ATH.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/polymorph-all.js +52 -50
- package/dist/packages/elements-ui/dist/cdn/polymorph.css +1 -1
- package/dist/packages/elements-ui/dist/cdn/polymorph.js +1 -1
- package/dist/packages/elements-ui/dist/cdn/prepaint.js +1 -1
- package/dist/packages/elements-ui/dist/cdn/themes/desktop.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/dew.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/flint.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/glassmorphic.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/harbor.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/journal.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pastel.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pebble.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/plain.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pop.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/press.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/terminal.css +5 -4
- package/dist/packages/elements-ui/src/ai/ArtifactPane.ts +2 -0
- package/dist/packages/elements-ui/src/archetypes/dashboard.states.ts +9 -0
- package/dist/packages/elements-ui/src/controls/ColorInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/NumberInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/TagInput.ts +4 -0
- package/dist/packages/elements-ui/src/controls/TimeInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/select.states.ts +10 -0
- package/dist/packages/elements-ui/src/overlays/Command.ts +2 -0
- package/dist/packages/elements-ui/src/structure/CodeBlock.ts +5 -2
- package/dist/packages/elements-ui/src/structure/Stat.ts +6 -0
- package/dist/packages/elements-ui/src/structure/stat.states.ts +33 -0
- package/dist/packages/mcp/src/propose.js +92 -15
- package/dist/packages/mcp/src/server.js +19 -8
- package/dist/packages/mcp/src/tools.js +80 -5
- package/dist/packages/mcp/src/write.js +95 -13
- package/dist/packages/react-ui/src/ai/ArtifactPane.tsx +5 -2
- package/dist/packages/react-ui/src/ai/PromptInput.tsx +5 -2
- package/dist/packages/react-ui/src/archetypes/dashboard.states.tsx +28 -0
- package/dist/packages/react-ui/src/controls/ColorInput.tsx +69 -13
- package/dist/packages/react-ui/src/controls/Combobox.tsx +13 -5
- package/dist/packages/react-ui/src/controls/DatePicker.tsx +3 -0
- package/dist/packages/react-ui/src/controls/DateRangePicker.tsx +22 -5
- package/dist/packages/react-ui/src/controls/FileUpload.tsx +2 -0
- package/dist/packages/react-ui/src/controls/MultiSelect.tsx +30 -6
- package/dist/packages/react-ui/src/controls/NumberInput.tsx +19 -1
- package/dist/packages/react-ui/src/controls/PhoneInput.tsx +3 -3
- package/dist/packages/react-ui/src/controls/Select.tsx +59 -23
- package/dist/packages/react-ui/src/controls/TagInput.tsx +43 -10
- package/dist/packages/react-ui/src/controls/TimeInput.tsx +10 -0
- package/dist/packages/react-ui/src/controls/date-segments.tsx +16 -0
- package/dist/packages/react-ui/src/controls/select.states.tsx +13 -0
- package/dist/packages/react-ui/src/overlays/Command.tsx +23 -2
- package/dist/packages/react-ui/src/overlays/Toaster.tsx +2 -2
- package/dist/packages/react-ui/src/structure/CodeBlock.tsx +7 -3
- package/dist/packages/react-ui/src/structure/Stat.tsx +90 -13
- package/dist/packages/react-ui/src/structure/stat.states.tsx +68 -0
- package/dist/packages/recipes/src/ai/artifact-pane.module.css +4 -4
- package/dist/packages/recipes/src/controls/rich-text-input.module.css +1 -1
- package/dist/packages/recipes/src/structure/avatar.module.css +3 -1
- package/dist/packages/recipes/src/structure/heading.module.css +5 -4
- package/dist/packages/recipes/src/structure/hero.module.css +3 -1
- package/dist/packages/recipes/src/structure/stat.module.css +7 -0
- package/dist/packages/registry/src/card.js +4 -3
- package/dist/packages/registry/src/frameworks.js +28 -1
- package/dist/packages/registry/src/runtime-card.js +300 -0
- package/dist/packages/registry/src/runtime-members.js +176 -0
- package/dist/packages/registry/src/screen-table.js +166 -0
- package/dist/packages/rules/package.js +1 -1
- package/dist/packages/solid-ui/src/ai/ArtifactPane.tsx +11 -3
- package/dist/packages/solid-ui/src/ai/PromptInput.tsx +3 -1
- package/dist/packages/solid-ui/src/archetypes/Dashboard.tsx +3 -0
- package/dist/packages/solid-ui/src/archetypes/dashboard.states.tsx +39 -0
- package/dist/packages/solid-ui/src/controls/ColorInput.tsx +38 -17
- package/dist/packages/solid-ui/src/controls/Combobox.tsx +27 -6
- package/dist/packages/solid-ui/src/controls/DatePicker.tsx +12 -11
- package/dist/packages/solid-ui/src/controls/DateRangePicker.tsx +21 -16
- package/dist/packages/solid-ui/src/controls/DateRangePickerRangeCalendar.tsx +3 -4
- package/dist/packages/solid-ui/src/controls/FileUpload.tsx +1 -0
- package/dist/packages/solid-ui/src/controls/FileUploadRow.tsx +6 -0
- package/dist/packages/solid-ui/src/controls/MultiSelect.tsx +51 -11
- package/dist/packages/solid-ui/src/controls/NumberInput.tsx +21 -2
- package/dist/packages/solid-ui/src/controls/PhoneInput.tsx +8 -4
- package/dist/packages/solid-ui/src/controls/Select.tsx +37 -6
- package/dist/packages/solid-ui/src/controls/TagInput.tsx +26 -5
- package/dist/packages/solid-ui/src/controls/TimeInput.tsx +10 -1
- package/dist/packages/solid-ui/src/controls/select.states.tsx +18 -0
- package/dist/packages/solid-ui/src/overlays/Command.tsx +15 -2
- package/dist/packages/solid-ui/src/overlays/CommandPanel.tsx +7 -7
- package/dist/packages/solid-ui/src/overlays/ToastViewport.tsx +1 -1
- package/dist/packages/solid-ui/src/structure/CodeBlock.tsx +9 -5
- package/dist/packages/solid-ui/src/structure/Stat.tsx +86 -25
- package/dist/packages/solid-ui/src/structure/stat.states.tsx +73 -0
- package/dist/packages/svelte-ui/src/ai/ArtifactPane.svelte +8 -2
- package/dist/packages/svelte-ui/src/ai/PromptInput.svelte +3 -1
- package/dist/packages/svelte-ui/src/archetypes/Dashboard.svelte +3 -0
- package/dist/packages/svelte-ui/src/archetypes/dashboard.states.svelte +2 -0
- package/dist/packages/svelte-ui/src/controls/ColorInput.svelte +29 -8
- package/dist/packages/svelte-ui/src/controls/Combobox.svelte +26 -5
- package/dist/packages/svelte-ui/src/controls/DatePicker.svelte +7 -5
- package/dist/packages/svelte-ui/src/controls/DateRangePicker.svelte +15 -9
- package/dist/packages/svelte-ui/src/controls/DateRangePickerRangeCalendar.svelte +3 -2
- package/dist/packages/svelte-ui/src/controls/FileUpload.svelte +1 -0
- package/dist/packages/svelte-ui/src/controls/FileUploadRow.svelte +8 -1
- package/dist/packages/svelte-ui/src/controls/MultiSelect.svelte +36 -10
- package/dist/packages/svelte-ui/src/controls/NumberInput.svelte +14 -1
- package/dist/packages/svelte-ui/src/controls/PhoneInput.svelte +3 -3
- package/dist/packages/svelte-ui/src/controls/Select.svelte +20 -6
- package/dist/packages/svelte-ui/src/controls/TagInput.svelte +21 -3
- package/dist/packages/svelte-ui/src/controls/TimeInput.svelte +11 -1
- package/dist/packages/svelte-ui/src/controls/select.states.svelte +26 -24
- package/dist/packages/svelte-ui/src/overlays/Command.svelte +13 -1
- package/dist/packages/svelte-ui/src/overlays/CommandPanel.svelte +11 -6
- package/dist/packages/svelte-ui/src/overlays/ToastViewport.svelte +1 -1
- package/dist/packages/svelte-ui/src/structure/CodeBlock.svelte +7 -2
- package/dist/packages/svelte-ui/src/structure/Stat.svelte +70 -17
- package/dist/packages/svelte-ui/src/structure/stat.states.svelte +27 -0
- package/dist/packages/theme/src/admit.js +6 -3
- package/dist/packages/theme/src/color/resolve.js +19 -2
- package/dist/packages/theme/src/derive.js +13 -6
- package/dist/packages/theme/src/emit.js +1 -1
- package/dist/packages/theme/src/runtime.js +58 -0
- package/dist/packages/theme/src/seeds.js +30 -4
- package/dist/packages/theme/src/systems.js +1 -1
- package/dist/packages/theme/src/tokens.js +15 -6
- package/dist/packages/vue-ui/src/ai/ArtifactPane.vue +11 -2
- package/dist/packages/vue-ui/src/ai/PromptInput.vue +3 -1
- package/dist/packages/vue-ui/src/archetypes/Dashboard.vue +3 -0
- package/dist/packages/vue-ui/src/archetypes/dashboard.states.ts +49 -0
- package/dist/packages/vue-ui/src/controls/ColorInput.vue +33 -12
- package/dist/packages/vue-ui/src/controls/Combobox.vue +26 -5
- package/dist/packages/vue-ui/src/controls/DatePicker.vue +12 -11
- package/dist/packages/vue-ui/src/controls/DateRangePicker.vue +20 -15
- package/dist/packages/vue-ui/src/controls/DateRangePickerRangeCalendar.vue +3 -4
- package/dist/packages/vue-ui/src/controls/FileUpload.vue +1 -0
- package/dist/packages/vue-ui/src/controls/FileUploadRow.vue +6 -0
- package/dist/packages/vue-ui/src/controls/MultiSelect.vue +37 -10
- package/dist/packages/vue-ui/src/controls/NumberInput.vue +17 -1
- package/dist/packages/vue-ui/src/controls/PhoneInput.vue +7 -3
- package/dist/packages/vue-ui/src/controls/Select.vue +22 -7
- package/dist/packages/vue-ui/src/controls/TagInput.vue +21 -3
- package/dist/packages/vue-ui/src/controls/TimeInput.vue +10 -1
- package/dist/packages/vue-ui/src/controls/select.states.ts +17 -0
- package/dist/packages/vue-ui/src/overlays/Command.vue +13 -1
- package/dist/packages/vue-ui/src/overlays/CommandPanel.vue +7 -7
- package/dist/packages/vue-ui/src/overlays/ToastViewport.vue +1 -1
- package/dist/packages/vue-ui/src/structure/CodeBlock.vue +7 -2
- package/dist/packages/vue-ui/src/structure/Stat.vue +71 -18
- package/dist/packages/vue-ui/src/structure/stat.states.ts +67 -0
- package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Contracts.kt +144 -33
- package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Members.kt +17 -7
- package/dist/platforms/ios/Sources/PolymorphUI/Generated/Contracts.swift +204 -31
- package/dist/registry/registry.json +371 -75
- package/dist/screen/assets/{screen-CuQbskb8.css → screen-B22PTPwF.css} +1 -1
- package/dist/screen/assets/screen-Cpbh7XMb.js +372 -0
- package/dist/screen/screen.html +3 -3
- package/package.json +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-DsmRlr6d.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-BqP8HZKM.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-D8VARz0a.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-BrzZOVeL.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-BiUq0h-w.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Command-hmxVRdFg.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-C8prGbJ2.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-CO1ioqwN.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-HPQe-ttb.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-CerqbGv3.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-CQq7jPgI.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-Dre9GwBy.js +0 -7
- package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-D6_J6Es_.js +0 -210
- package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-BXcsUQ5W.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Select-DxGQgv2q.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-FsMUWigK.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-WS8v6BQv.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-D-uIQEGS.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-Dho571vA.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/agent-DBDk4wLH.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/api-B9sGZiYn.js +0 -4
- package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-CQwnWhWo.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/cap-Ct4k7zNC.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-DycBfben.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-Cks7VwS5.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/check-dOfCSYFA.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/draw-DclRgiWM.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/drawing-DjkZr0z8.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/frame-BSvl4y47.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/on-call-Jk1sYJc_.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/receivers-BpRfF6dV.js +0 -4
- package/dist/packages/elements-ui/dist/cdn/chunks/series-C_1TNd2n.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/src-Bub3C9YP.js +0 -67
- package/dist/packages/elements-ui/dist/cdn/chunks/toast-AarMGYJn.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-eEPzSqph.js +0 -1
- package/dist/screen/assets/screen-Clj2u6_s.js +0 -372
|
@@ -1,797 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SKILL_NAMES, SKILL_USES } from "./skills/facts.js";
|
|
2
|
+
import { bridgeSkill } from "./skills/bridge.js";
|
|
3
|
+
import { nativeSkill } from "./skills/native.js";
|
|
4
|
+
import { rulesSkill } from "./skills/rules.js";
|
|
5
|
+
import { runtimeSkill } from "./skills/runtime.js";
|
|
6
|
+
import { screenSkill } from "./skills/screen.js";
|
|
7
|
+
import { setupSkill } from "./skills/setup.js";
|
|
8
|
+
import { themeSkill } from "./skills/theme.js";
|
|
3
9
|
//#region ../cli/src/skills.ts
|
|
4
10
|
/**
|
|
5
|
-
* The texts of the agent skills, in the Agent Skills format
|
|
6
|
-
* (agentskills.io): a directory per skill with a `SKILL.md` whose front
|
|
7
|
-
* matter holds `name` and `description`, and a `references/` directory for
|
|
8
|
-
* what a model reads only when a step sends it there.
|
|
9
|
-
*
|
|
10
|
-
* Each text is a function of the registry and of `run`, the command that
|
|
11
|
-
* reaches the tools (`npx -y @metamorph-labs/polymorph@^<version>`, or a
|
|
12
|
-
* checkout's bin), so a skill always names the release that wrote it. The
|
|
13
|
-
* ladder's rungs and the application rules are read from the registry, not
|
|
14
|
-
* copied into the text. What does not change with the vocabulary (the spec
|
|
15
|
-
* format's outline, each rung's procedure) is in `references/`.
|
|
16
|
-
*
|
|
17
|
-
* The texts are written for a model that has never seen polymorph and has a
|
|
18
|
-
* shell. `agents.test.ts` holds every command they name to the verb list, and
|
|
19
|
-
* each skill to the format's limits.
|
|
20
|
-
*/
|
|
21
|
-
/** A skill names a member, a prop, a part or a value the registry does not have. */
|
|
22
|
-
var SkillFactError = class extends Error {
|
|
23
|
-
constructor(message) {
|
|
24
|
-
super(`skills: ${message}`);
|
|
25
|
-
this.name = "SkillFactError";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* What the texts say about members, read from the registry. Every member,
|
|
30
|
-
* prop, part and value a sentence names comes through here, and one the
|
|
31
|
-
* registry lacks throws, so a renamed prop stops the texts from being written
|
|
32
|
-
* rather than reaching a model.
|
|
33
|
-
*/
|
|
34
|
-
var Facts = class {
|
|
35
|
-
registry;
|
|
36
|
-
constructor(registry) {
|
|
37
|
-
this.registry = registry;
|
|
38
|
-
}
|
|
39
|
-
member(name) {
|
|
40
|
-
const found = [...this.registry.components, ...this.registry.exceptions.primitives].find((member) => member.name === name);
|
|
41
|
-
if (found === void 0) throw new SkillFactError(`no member called ${name}`);
|
|
42
|
-
return found;
|
|
43
|
-
}
|
|
44
|
-
/** `name` in code font, once the registry has the member. */
|
|
45
|
-
m(name) {
|
|
46
|
-
this.member(name);
|
|
47
|
-
return `\`${name}\``;
|
|
48
|
-
}
|
|
49
|
-
/** The type of a member's prop, which must exist. */
|
|
50
|
-
type(member, prop) {
|
|
51
|
-
const found = this.member(member).props.find((entry) => entry.name === prop);
|
|
52
|
-
if (found === void 0) throw new SkillFactError(`${member} has no prop ${prop}`);
|
|
53
|
-
return found.type;
|
|
54
|
-
}
|
|
55
|
-
/** `prop` in code font, once `member` has it. */
|
|
56
|
-
p(member, prop) {
|
|
57
|
-
this.type(member, prop);
|
|
58
|
-
return `\`${prop}\``;
|
|
59
|
-
}
|
|
60
|
-
/** The string values a prop's type allows, in its order. */
|
|
61
|
-
values(member, prop) {
|
|
62
|
-
return [...this.type(member, prop).matchAll(/"([^"]+)"/g)].map((match) => match[1]);
|
|
63
|
-
}
|
|
64
|
-
/** `prop="value"` in code font, once the prop takes the value. */
|
|
65
|
-
v(member, prop, value) {
|
|
66
|
-
if (!this.values(member, prop).includes(value)) throw new SkillFactError(`${member}'s ${prop} takes no "${value}"`);
|
|
67
|
-
return `\`${prop}="${value}"\``;
|
|
68
|
-
}
|
|
69
|
-
/** `Member.Part` in code font, once the member has the part. */
|
|
70
|
-
part(member, part) {
|
|
71
|
-
const parts = this.member(member).parts;
|
|
72
|
-
if (!Array.isArray(parts) || !parts.some((entry) => entry.name === part)) throw new SkillFactError(`${member} has no part ${part}`);
|
|
73
|
-
return `\`${member}.${part}\``;
|
|
74
|
-
}
|
|
75
|
-
/** The props every one of `members` has, among `wanted`, in code font. */
|
|
76
|
-
shared(members, wanted) {
|
|
77
|
-
const found = wanted.filter((prop) => members.every((member) => this.member(member).props.some((entry) => entry.name === prop)));
|
|
78
|
-
if (found.length === 0) throw new SkillFactError(`${members.join(", ")} share none of ${wanted}`);
|
|
79
|
-
return found.map((prop) => `\`${prop}\``);
|
|
80
|
-
}
|
|
81
|
-
/** The prop of `member` whose type lists the icon roles. */
|
|
82
|
-
roleProp(member) {
|
|
83
|
-
const role = this.registry.icons.roles[0]?.name;
|
|
84
|
-
const found = this.member(member).props.find((entry) => entry.type.includes(`"${role}"`));
|
|
85
|
-
if (role === void 0 || found === void 0) throw new SkillFactError(`${member} has no prop that takes an icon role`);
|
|
86
|
-
return `\`${found.name}\``;
|
|
87
|
-
}
|
|
88
|
-
/** Each type a member's `patch` takes, with the members that take it and its keys. */
|
|
89
|
-
patches() {
|
|
90
|
-
const byType = /* @__PURE__ */ new Map();
|
|
91
|
-
for (const member of this.registry.components) {
|
|
92
|
-
const patch = member.props.find((entry) => entry.name === "patch");
|
|
93
|
-
if (patch === void 0) continue;
|
|
94
|
-
const type = patch.type.split("|")[0]?.trim() ?? "";
|
|
95
|
-
byType.set(type, [...byType.get(type) ?? [], member.name]);
|
|
96
|
-
}
|
|
97
|
-
return [...byType].map(([type, members]) => {
|
|
98
|
-
const declared = this.registry.dataTypes.find((entry) => entry.name === type);
|
|
99
|
-
if (declared === void 0) throw new SkillFactError(`no data type called ${type}`);
|
|
100
|
-
return {
|
|
101
|
-
type,
|
|
102
|
-
members,
|
|
103
|
-
keys: declared.fields.map((field) => field.name)
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/** The names of the theme's design axes. */
|
|
108
|
-
axes() {
|
|
109
|
-
return this.registry.theme.axes.map((axis) => axis.name);
|
|
110
|
-
}
|
|
111
|
-
/** The members of a tier, in the registry's order. */
|
|
112
|
-
tier(name) {
|
|
113
|
-
return this.registry.components.filter((member) => member.tier === name).map((m) => m.name);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
/** Words in code font in a sentence: `a`, `a and b`, `a, b and c`. */
|
|
117
|
-
function all(words) {
|
|
118
|
-
return words.length <= 1 ? words.join("") : `${words.slice(0, -1).join(", ")} and ${words.at(-1)}`;
|
|
119
|
-
}
|
|
120
|
-
/** The skills, in the order the always-loaded text names them. */
|
|
121
|
-
var SKILL_NAMES = [
|
|
122
|
-
"polymorph-screen",
|
|
123
|
-
"polymorph-rules",
|
|
124
|
-
"polymorph-setup",
|
|
125
|
-
"polymorph-theme"
|
|
126
|
-
];
|
|
127
|
-
/** A fenced shell block of commands, each starting with `run`. */
|
|
128
|
-
function commands(run, ...lines) {
|
|
129
|
-
return [
|
|
130
|
-
"```sh",
|
|
131
|
-
...lines.map((line) => `${run} ${line}`),
|
|
132
|
-
"```"
|
|
133
|
-
].join("\n");
|
|
134
|
-
}
|
|
135
|
-
/** Words in a sentence as alternatives: `a`, `a or b`, `a, b or c`. */
|
|
136
|
-
function either(words) {
|
|
137
|
-
return words.length <= 1 ? words.join("") : `${words.slice(0, -1).join(", ")} or ${words.at(-1)}`;
|
|
138
|
-
}
|
|
139
|
-
/** Front matter and body, as one `SKILL.md`. */
|
|
140
|
-
function skill(name, description, body) {
|
|
141
|
-
return `---\nname: ${name}\ndescription: ${description}\n---\n\n${body.trim()}\n`;
|
|
142
|
-
}
|
|
143
|
-
/** The table that tells a framework from the packages a project depends on. */
|
|
144
|
-
function frameworkTable() {
|
|
145
|
-
return [
|
|
146
|
-
"| The project has | The framework |",
|
|
147
|
-
"| --- | --- |",
|
|
148
|
-
...FRAMEWORKS.filter((framework) => framework !== "elements").map((framework) => `| \`@polymorph/${framework}-ui\` | \`${framework}\` |`),
|
|
149
|
-
"| `\"framework\": \"elements\"` in `polymorph.json` | `elements`: `<poly-*>` custom elements in HTML pages with no build |"
|
|
150
|
-
].join("\n");
|
|
151
|
-
}
|
|
152
|
-
function screenSkill(registry, run) {
|
|
153
|
-
const f = new Facts(registry);
|
|
154
|
-
const spacing = all(f.shared([
|
|
155
|
-
"Stack",
|
|
156
|
-
"Inline",
|
|
157
|
-
"Grid"
|
|
158
|
-
], [
|
|
159
|
-
"gap",
|
|
160
|
-
"p",
|
|
161
|
-
"px",
|
|
162
|
-
"py"
|
|
163
|
-
]));
|
|
164
|
-
const pages = f.tier("archetypes").filter((name) => name.endsWith("Page")).slice(0, 3).map((name) => f.m(name));
|
|
165
|
-
return [{
|
|
166
|
-
path: "polymorph-screen/SKILL.md",
|
|
167
|
-
contents: skill("polymorph-screen", "Build or change a screen, page, form, dialog or layout in an app that uses the polymorph design system, in React, Vue, Svelte, Solid, Angular or an HTML page. Use for any UI work in a repository whose package.json depends on a @polymorph/* or @metamorph-labs/polymorph-* package, or that has a polymorph.json or polymorph/system-card.md. Covers reading the system card, choosing members, writing a screen spec or framework code, validating it against the red rules, fixing violations, emitting a spec, and rendering it at phone and desktop width to read its layout faults.", `
|
|
168
|
-
# Build a screen with polymorph
|
|
169
|
-
|
|
170
|
-
Polymorph is a closed vocabulary of interface components, called members, and a set of lint rules,
|
|
171
|
-
the red rules, that keep design decisions out of application code. The theme decides every colour,
|
|
172
|
-
size, font and motion. A screen composes members, sets their props and binds content to them.
|
|
173
|
-
|
|
174
|
-
You reach the tools from a shell. Every command in this skill starts with the same words:
|
|
175
|
-
|
|
176
|
-
${commands(run, "card --framework <framework>")}
|
|
177
|
-
|
|
178
|
-
If the session also has an MCP server named \`polymorph\`, its tools do the same jobs:
|
|
179
|
-
\`get_system_card\` for \`card\`, \`search_components\` for \`search\`, \`get_component\` for
|
|
180
|
-
\`component\`, \`validate\`, \`fix\`, \`emit_screen\` for \`emit\` and \`render_screen\` for \`render\`.
|
|
181
|
-
Pass the app's framework as \`framework\` to every one that takes it. A server started for no
|
|
182
|
-
project, as a plugin's is, cannot read the framework from the project, and reads code as React's.
|
|
183
|
-
|
|
184
|
-
## 1. Find the framework and how the app writes screens
|
|
185
|
-
|
|
186
|
-
Read \`package.json\` and \`polymorph.json\` at the project root. A package may be listed under its
|
|
187
|
-
published name, \`@metamorph-labs/polymorph-<name>\`.
|
|
188
|
-
|
|
189
|
-
${frameworkTable()}
|
|
190
|
-
|
|
191
|
-
That is \`<framework>\` in every command below. A project that vendors members has their source under
|
|
192
|
-
the \`dir\` that \`polymorph.json\` names, usually \`src/polymorph/\`, and imports them from there.
|
|
193
|
-
Those files are the vocabulary: do not edit them to make a screen work.
|
|
194
|
-
|
|
195
|
-
Then look for screen specs: JSON files with \`"spec": "polymorph-screen/1"\`, usually in
|
|
196
|
-
\`src/screens/\`, each beside the component emitted from it. If the app has them, write the new
|
|
197
|
-
screen as a spec (step 4). Otherwise write it in the framework's own code (step 5).
|
|
198
|
-
|
|
199
|
-
## 2. Read the card
|
|
200
|
-
|
|
201
|
-
${commands(run, "card --framework <framework>")}
|
|
202
|
-
|
|
203
|
-
The card lists every member with its props, the variants and tones each takes, its compound parts
|
|
204
|
-
(such as ${f.part("Table", "Row")}), the icon roles, the token families, the red rules and the
|
|
205
|
-
exception ladder. \`polymorph/system-card.md\` holds the card as it was when the project was set up.
|
|
206
|
-
The command answers for the release it names.
|
|
207
|
-
|
|
208
|
-
A member or a prop that is not in the card does not exist. Do not invent one, and do not bring in
|
|
209
|
-
components from another interface library.
|
|
210
|
-
|
|
211
|
-
## 3. Choose the members
|
|
212
|
-
|
|
213
|
-
${commands(run, "search date picker --framework <framework>", "component DatePicker --framework <framework>")}
|
|
214
|
-
|
|
215
|
-
\`search\` takes plain words and finds members by name, purpose, prop or variant. With no words it
|
|
216
|
-
lists every member. \`component\` prints one member: each prop with its type and default, the
|
|
217
|
-
lawful variant and tone pairs, its states, its parts and what it depends on. A wrong name is
|
|
218
|
-
answered with suggestions and exit code 1.
|
|
219
|
-
|
|
220
|
-
- Lay out with ${f.m("Stack")}, ${f.m("Inline")} and ${f.m("Grid")} and their spacing props
|
|
221
|
-
(${spacing}), which take steps of the space scale, never lengths.
|
|
222
|
-
- Start a page from a page archetype, such as ${either(pages)}, or from ${f.m("PageHeader")}.
|
|
223
|
-
- Show an icon with ${f.m("Icon")}, its ${f.roleProp("Icon")} one of the card's icon roles.
|
|
224
|
-
- Put text in ${f.m("Text")}, whose ${f.p("Text", "tone")} and ${f.p("Text", "size")} take the
|
|
225
|
-
place of a colour or a font size, and a heading in ${f.m("Heading")}, whose
|
|
226
|
-
${f.p("Heading", "level")} sets its rank.
|
|
227
|
-
|
|
228
|
-
## 4. Write a spec, then emit it
|
|
229
|
-
|
|
230
|
-
The format is in [references/screen-spec.md](references/screen-spec.md). Check the spec, then
|
|
231
|
-
compile it into a component:
|
|
232
|
-
|
|
233
|
-
${commands(run, "validate src/screens/inbox.json --framework <framework>", "emit src/screens/inbox.json <out> --framework <framework>")}
|
|
234
|
-
|
|
235
|
-
\`validate\` lists each fault at its path, such as \`$.root.children[1]\`, with suggestions for a
|
|
236
|
-
wrong name, and exits 0 when the spec is lawful. \`emit\` validates again, compiles the spec, checks
|
|
237
|
-
the output against the red rules, and writes nothing when either fails. \`<out>\` is the component
|
|
238
|
-
to write, with the framework's extension: \`.tsx\` for React and Solid, \`.vue\`, \`.svelte\`, and
|
|
239
|
-
\`.ts\` for an Angular standalone component.
|
|
240
|
-
|
|
241
|
-
The emitted component holds no state and no logic. A container you write renders it, owns the
|
|
242
|
-
state, and passes the data and the callbacks the spec declares as \`inputs\`. Never edit an emitted
|
|
243
|
-
file: change the spec and emit it again.
|
|
244
|
-
|
|
245
|
-
## 5. Or write the screen in code
|
|
246
|
-
|
|
247
|
-
Import members from the framework's vocabulary package, or from the vendored directory in a project
|
|
248
|
-
that vendors. Then check the file:
|
|
249
|
-
|
|
250
|
-
${commands(run, "validate src/pages/Settings.tsx --framework <framework>")}
|
|
251
|
-
|
|
252
|
-
\`validate\` takes several files. For a whole directory, use \`check\`, which reads each file in its
|
|
253
|
-
own framework:
|
|
254
|
-
|
|
255
|
-
${commands(run, "check src")}
|
|
256
|
-
|
|
257
|
-
The red rules do not read an HTML page. In an \`elements\` project, check a page by reading it
|
|
258
|
-
against the card.
|
|
259
|
-
|
|
260
|
-
## 6. Fix every violation
|
|
261
|
-
|
|
262
|
-
Each violation is a line with the file, the position, the rule and its message. Under it are the
|
|
263
|
-
lawful answers:
|
|
264
|
-
|
|
265
|
-
- \`fix\`: a rewrite with exactly one lawful answer. The \`fix\` command below applies them.
|
|
266
|
-
- \`use\`: the members, props or tokens the message names. A colour, size or spacing becomes a prop
|
|
267
|
-
of a member, as \`component\` lists them. A clickable \`<div>\` becomes a ${f.m("Button")}. A
|
|
268
|
-
glyph from an icon set becomes ${f.m("Icon")} with a role as its ${f.roleProp("Icon")}.
|
|
269
|
-
- \`climb\`: the rungs of the exception ladder that answer the rule. When no member, variant or prop
|
|
270
|
-
fits, follow the \`polymorph-rules\` skill.
|
|
271
|
-
|
|
272
|
-
Apply every rewrite that has one answer, then work through what is left:
|
|
273
|
-
|
|
274
|
-
${commands(run, "fix src/pages/Settings.tsx --framework <framework>")}
|
|
275
|
-
|
|
276
|
-
With \`--dry-run\`, \`fix\` prints the fixed code and writes nothing. Never add an \`eslint-disable\`
|
|
277
|
-
comment for a polymorph rule. Run \`validate\` again until it exits 0.
|
|
278
|
-
|
|
279
|
-
## 7. Look at the screen
|
|
280
|
-
|
|
281
|
-
${commands(run, `render src/screens/inbox.json --system ${DEFAULT_SYSTEM}`)}
|
|
282
|
-
|
|
283
|
-
\`render\` draws a spec in a browser at a phone width (375 by 812) and a desktop width (1440 by
|
|
284
|
-
900), writes the pictures beside the spec (\`src/screens/inbox.render/sampled-phone.png\`), and lists
|
|
285
|
-
the layout faults it measured in each. Open the pictures and look at them. With no data, each input
|
|
286
|
-
is sampled from its type, so the pictures show where content goes. \`--data <file>\` draws the screen
|
|
287
|
-
with a JSON value for each input, and \`--empty <file>\` adds a second drawing with its values laid
|
|
288
|
-
over those.
|
|
289
|
-
|
|
290
|
-
| Fault | What to change |
|
|
291
|
-
| --- | --- |
|
|
292
|
-
| \`sideways-scroll\` | Something is wider than the window. Let an ${f.m("Inline")} wrap (${f.p("Inline", "wrap")}), move actions into a menu, or use a member built to scroll. |
|
|
293
|
-
| \`clipped-text\` | Text does not fit its box. Shorten it, or give its container room. |
|
|
294
|
-
| \`small-target\` | Controls are too small or too close together. Use a larger size or more space between them. |
|
|
295
|
-
| \`cut-off\` | Content lies where nothing scrolls to it. Change the composition. |
|
|
296
|
-
| \`no-gap\` | Two members touch. Put them in a ${f.m("Stack")} or ${f.m("Inline")} with a ${f.p("Stack", "gap")}. |
|
|
297
|
-
| \`unseen-focus\` | A control's focus mark is hidden. Do not put the control in a box that clips it. |
|
|
298
|
-
|
|
299
|
-
Change the composition or a prop to fix a fault, never a style. \`--system\` names a shipped system:
|
|
300
|
-
the one the app's theme starts from, or \`${DEFAULT_SYSTEM}\`. \`axes\` lists them. The first \`render\`
|
|
301
|
-
on a machine may answer that its browser is missing, with the command that downloads it. Run that
|
|
302
|
-
command once, then render again.
|
|
303
|
-
|
|
304
|
-
\`render\` draws specs only. For a screen written in code, run the app and look at it in a browser
|
|
305
|
-
when the session can.
|
|
306
|
-
|
|
307
|
-
## 8. Run the checks
|
|
308
|
-
|
|
309
|
-
${commands(run, "check src")}
|
|
310
|
-
|
|
311
|
-
\`check\` runs the red rules over the directory whatever the project's lint config holds, and exits 1
|
|
312
|
-
on any violation. Then run the project's own lint and typecheck, as \`package.json\` names them. Its
|
|
313
|
-
lint runs the red rules too only when its ESLint config loads them: it imports \`@polymorph/rules\`
|
|
314
|
-
or spreads the fragment \`polymorph.eslint.js\` that \`init\` and \`add\` write.
|
|
315
|
-
|
|
316
|
-
## What application code may not contain
|
|
317
|
-
|
|
318
|
-
- CSS files, \`<style>\` blocks, CSS-in-JS, or a stylesheet import other than a font package's.
|
|
319
|
-
- A \`style\`, \`className\` or \`css\` prop, on a member or a plain element, and a \`class\` on either
|
|
320
|
-
in a framework that writes one. A declared zone lifts this for a plain element (the
|
|
321
|
-
\`polymorph-rules\` skill).
|
|
322
|
-
- A colour (\`#7c3aed\`, \`rgb()\`, \`oklch()\`) or a length (\`12px\`, \`1.5rem\`) in a string.
|
|
323
|
-
- A raw \`<button>\`, \`<input>\`, \`<select>\`, \`<textarea>\` or \`<option>\`, or a click, key or pointer
|
|
324
|
-
handler on a \`<div>\`, \`<span>\`, \`<li>\` or \`<a>\`.
|
|
325
|
-
- An import from an icon set, a motion library or a chart library, or an inline \`<svg>\`.
|
|
326
|
-
- A \`--pm-*\` custom property declared by the app.
|
|
327
|
-
- An \`eslint-disable\` comment for a polymorph rule.
|
|
328
|
-
`)
|
|
329
|
-
}, {
|
|
330
|
-
path: "polymorph-screen/references/screen-spec.md",
|
|
331
|
-
contents: specReference(registry)
|
|
332
|
-
}];
|
|
333
|
-
}
|
|
334
|
-
/** The spec format's outline, which does not change with the vocabulary. */
|
|
335
|
-
function specReference(registry) {
|
|
336
|
-
const rungs = registry.exceptions.ladder.filter((rung) => rung.declaredAs !== null && rung.declaredAs !== "patch").map((rung) => rung.rung);
|
|
337
|
-
return `# The screen spec: \`polymorph-screen/1\`
|
|
338
|
-
|
|
339
|
-
A screen spec is a JSON document that describes one screen: which members it composes, the value of
|
|
340
|
-
each prop, and the inputs its content is bound to. It has no field for a style and no expression
|
|
341
|
-
language. \`validate\` checks it against the vocabulary, and \`emit\` compiles it for the app's
|
|
342
|
-
framework.
|
|
343
|
-
|
|
344
|
-
\`\`\`json
|
|
345
|
-
{
|
|
346
|
-
"spec": "polymorph-screen/1",
|
|
347
|
-
"name": "KeysView",
|
|
348
|
-
"purpose": "The API keys an integration uses, with a way to make another.",
|
|
349
|
-
"inputs": [
|
|
350
|
-
{ "name": "count", "type": "string", "doc": "How many keys exist, already formatted." },
|
|
351
|
-
{ "name": "onCreate", "type": "() => void" }
|
|
352
|
-
],
|
|
353
|
-
"root": {
|
|
354
|
-
"component": "Stack",
|
|
355
|
-
"props": { "gap": 5 },
|
|
356
|
-
"children": [
|
|
357
|
-
{ "component": "Heading", "children": ["API keys"] },
|
|
358
|
-
{ "component": "Text", "props": { "tone": "secondary" }, "children": [{ "$": "count" }] },
|
|
359
|
-
{
|
|
360
|
-
"component": "Button",
|
|
361
|
-
"props": { "variant": "solid", "tone": "accent", "label": "Create key", "onClick": { "$": "onCreate" } }
|
|
362
|
-
}
|
|
363
|
-
]
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
\`\`\`
|
|
367
|
-
|
|
368
|
-
## Fields
|
|
369
|
-
|
|
370
|
-
| Field | Meaning |
|
|
371
|
-
| --- | --- |
|
|
372
|
-
| \`spec\` | Always \`polymorph-screen/1\`. |
|
|
373
|
-
| \`name\` | PascalCase: the name of the component \`emit\` writes. |
|
|
374
|
-
| \`purpose\` | One sentence. It becomes the emitted file's doc comment. |
|
|
375
|
-
| \`inputs\` | What the screen is handed: \`{ "name", "type", "doc"? }\`. \`type\` is one TypeScript type, such as \`string\`, \`Ticket[]\` or \`(id: string) => void\`. Every binding names one of these, a callback included. |
|
|
376
|
-
| \`types\` | Optional. A module mapped to the type names the inputs use, emitted as \`import type\` lines. |
|
|
377
|
-
| \`root\` | One element: the screen's tree. Write it last. |
|
|
378
|
-
|
|
379
|
-
## Elements and values
|
|
380
|
-
|
|
381
|
-
An element is \`{ "component", "props"?, "children"?, "exception"? }\`. \`component\` is a member or
|
|
382
|
-
one of its parts (such as ${new Facts(registry).part("Table", "Row")}), as the card lists them for the
|
|
383
|
-
app's framework.
|
|
384
|
-
|
|
385
|
-
A value, as a prop or a child, is a string, a number, a boolean, \`null\`, an element, a list, a
|
|
386
|
-
binding \`{ "$": "inputName" }\`, or a structured object \`{ "$object": { … } }\` for data a prop
|
|
387
|
-
takes.
|
|
388
|
-
|
|
389
|
-
A binding names a declared input, or a dotted path into one (\`draft.subject\`). It is never an
|
|
390
|
-
expression: no call, operator or index. A value the screen needs computed, such as a count or a
|
|
391
|
-
filtered list, is computed by the container and passed in as an input of its own.
|
|
392
|
-
|
|
393
|
-
A spec has no condition. Every element is rendered whenever the screen is. Content that is
|
|
394
|
-
sometimes absent is a prop bound to an input that is empty while there is nothing to show, on a
|
|
395
|
-
member that draws nothing when it is given nothing.
|
|
396
|
-
|
|
397
|
-
## Exceptions
|
|
398
|
-
|
|
399
|
-
An element may declare a rung of the exception ladder (rungs ${rungs.join(" and ")} on a
|
|
400
|
-
primitive, and rung 3 as a \`patch\` prop) with the reason:
|
|
401
|
-
|
|
402
|
-
\`\`\`json
|
|
403
|
-
{
|
|
404
|
-
"component": "DensityScope",
|
|
405
|
-
"props": { "value": "compact" },
|
|
406
|
-
"exception": { "rung": 2, "because": "A queue is scanned, so more rows per screen is worth more here." },
|
|
407
|
-
"children": []
|
|
408
|
-
}
|
|
409
|
-
\`\`\`
|
|
410
|
-
|
|
411
|
-
## The loop
|
|
412
|
-
|
|
413
|
-
1. Write the spec from the card and the members \`component\` describes.
|
|
414
|
-
2. \`validate\` it. Each fault names its path and, for a wrong name, the nearest real ones.
|
|
415
|
-
3. Correct and validate again until it is lawful.
|
|
416
|
-
4. \`render\` it and read the pictures and the layout faults. Correct the composition and render
|
|
417
|
-
again.
|
|
418
|
-
5. \`emit\` it into the app, and write or update the container that renders it.
|
|
419
|
-
`;
|
|
420
|
-
}
|
|
421
|
-
function rulesSkill(registry, run) {
|
|
422
|
-
const f = new Facts(registry);
|
|
423
|
-
const ladder = registry.exceptions.ladder.map((rung) => {
|
|
424
|
-
const declared = rung.declaredAs === null ? "" : ` (${rung.declaredAs.split("|").map((name) => `\`${name.trim()}\``).join(", ")})`;
|
|
425
|
-
return `${rung.rung}. **${rung.name}**${declared}: ${rung.summary}.`;
|
|
426
|
-
}).join("\n");
|
|
427
|
-
const rules = registry.laws.filter((law) => law.applies === "application").map((law) => `| \`${law.name}\` | ${law.summary} | ${law.climb.length === 0 ? "none" : law.climb.join(", ")} |`);
|
|
428
|
-
return [{
|
|
429
|
-
path: "polymorph-rules/SKILL.md",
|
|
430
|
-
contents: skill("polymorph-rules", "Resolve a polymorph red-rule violation, a lint error whose rule starts with polymorph/ such as polymorph/no-raw-styles, polymorph/no-raw-interactive or polymorph/no-app-css, or a design need the polymorph vocabulary does not seem to cover. Use when ESLint, Stylelint, polymorph validate or polymorph check reports a polymorph/ rule, before adding any eslint-disable comment, and when a screen needs a style, a control, an icon, a chart, motion or another library's component that no member provides. Walks the exception ladder rung by rung.", `
|
|
431
|
-
# Answer a red rule
|
|
432
|
-
|
|
433
|
-
The red rules are lint rules that keep design decisions out of application code. Exceptions are
|
|
434
|
-
allowed when they are declared: a declared exception names its reason, where a reviewer can read
|
|
435
|
-
it. A silenced rule is not allowed. Never add \`eslint-disable\`, \`eslint-disable-next-line\`
|
|
436
|
-
or \`stylelint-disable\` for a polymorph rule, and never change a lint config to turn one off.
|
|
437
|
-
|
|
438
|
-
Every command in this skill starts with the same words, the polymorph tools run from a shell.
|
|
439
|
-
\`<framework>\` is the app's: the \`polymorph-screen\` skill says how to tell it. An MCP server
|
|
440
|
-
named \`polymorph\` does the same jobs through \`validate\` and \`fix\`, given the framework as
|
|
441
|
-
\`framework\`, and \`get_component\`.
|
|
442
|
-
|
|
443
|
-
## 1. Read what the rule says
|
|
444
|
-
|
|
445
|
-
${commands(run, "validate src/App.tsx --framework <framework>")}
|
|
446
|
-
|
|
447
|
-
Each violation is a line with the file, the position, the rule and its message. Under it:
|
|
448
|
-
|
|
449
|
-
- \`fix\`: a rewrite with exactly one lawful answer.
|
|
450
|
-
- \`use\`: the members, props and tokens the message names, each with its rung.
|
|
451
|
-
- \`climb\`: every rung of the ladder that answers this rule.
|
|
452
|
-
|
|
453
|
-
## 2. Take the rewrite when there is one
|
|
454
|
-
|
|
455
|
-
${commands(run, "fix src/App.tsx --dry-run --framework <framework>", "fix src/App.tsx --framework <framework>")}
|
|
456
|
-
|
|
457
|
-
The first prints the fixed code, and the second writes it. The project's own \`eslint --fix\`
|
|
458
|
-
applies the same rewrites. A violation left after the fix is a decision: take the next step.
|
|
459
|
-
|
|
460
|
-
## 3. Climb the exception ladder
|
|
461
|
-
|
|
462
|
-
Take the first rung that works. Each rung is more governed than the next.
|
|
463
|
-
|
|
464
|
-
${ladder}
|
|
465
|
-
|
|
466
|
-
[references/ladder.md](references/ladder.md) has each rung's procedure, with code.
|
|
467
|
-
|
|
468
|
-
## 4. Which rungs answer which rule
|
|
469
|
-
|
|
470
|
-
| Rule | What it holds | Rungs |
|
|
471
|
-
| --- | --- | --- |
|
|
472
|
-
${rules.join("\n")}
|
|
473
|
-
|
|
474
|
-
Common cases:
|
|
475
|
-
|
|
476
|
-
- A colour, length or style on a member: find the prop that decides it with \`component <Name>\`,
|
|
477
|
-
such as ${f.m("Button")}'s ${f.p("Button", "variant")} and ${f.p("Button", "tone")} or
|
|
478
|
-
${f.m("Stack")}'s ${f.p("Stack", "gap")}. A spacing the scale lacks for one instance is a
|
|
479
|
-
\`patch\` (rung 3). A one-off illustration is a ${f.m("Bespoke")} zone (rung 4).
|
|
480
|
-
- A raw control, or a click handler on a plain element: the member that is that control, such as
|
|
481
|
-
${all([
|
|
482
|
-
"Button",
|
|
483
|
-
"Checkbox",
|
|
484
|
-
"Select",
|
|
485
|
-
"Input",
|
|
486
|
-
"Textarea"
|
|
487
|
-
].map((name) => f.m(name)))}.
|
|
488
|
-
\`search\` finds it by what it does.
|
|
489
|
-
- An icon set or an inline \`<svg>\`: ${f.m("Icon")} with a role from the card as its
|
|
490
|
-
${f.roleProp("Icon")}. A glyph no role names is a ${f.m("Bespoke")} zone until the vocabulary adds
|
|
491
|
-
a role.
|
|
492
|
-
- A chart library: the chart members. A chart they cannot draw goes in a ${f.m("Bespoke")} zone.
|
|
493
|
-
- A motion library: members animate their own states. Motion the vocabulary has no member for goes
|
|
494
|
-
in a ${f.m("Bespoke")} zone.
|
|
495
|
-
- A stylesheet import: delete it. Another library's own stylesheet is imported in the file that
|
|
496
|
-
hosts the library inside ${f.m("ThirdParty")}.
|
|
497
|
-
- Another library's component, such as a map, an editor or a data grid: ${f.m("ThirdParty")}
|
|
498
|
-
(rung 4).
|
|
499
|
-
|
|
500
|
-
## 5. When the same exception keeps coming back
|
|
501
|
-
|
|
502
|
-
A patch or a zone that recurs is promoted into the vocabulary or deleted (rung 5). That is a
|
|
503
|
-
decision for whoever owns the design system: tell the person you are working for, with the zones
|
|
504
|
-
and their reasons. Do not build a private copy of a member.
|
|
505
|
-
`)
|
|
506
|
-
}, {
|
|
507
|
-
path: "polymorph-rules/references/ladder.md",
|
|
508
|
-
contents: ladderReference(registry, run)
|
|
509
|
-
}];
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Each rung's procedure. The procedure does not change with the vocabulary;
|
|
513
|
-
* the members, props and values it names are read from the registry.
|
|
514
|
-
*/
|
|
515
|
-
function ladderReference(registry, run) {
|
|
516
|
-
const f = new Facts(registry);
|
|
517
|
-
const values = (member, prop) => either(f.values(member, prop).map((value) => `\`${value}\``));
|
|
518
|
-
const patches = f.patches().map(({ members, keys }) => `${all(members.map((name) => f.m(name)))} ${members.length === 1 ? "takes" : "take"} ${all(keys.map((key) => `\`${key}\``))}.`).join(" ");
|
|
519
|
-
return `# The exception ladder, rung by rung
|
|
520
|
-
|
|
521
|
-
The examples are React. In Vue, Svelte and Solid the members have the same names and props. In
|
|
522
|
-
Angular a member is written by its selector (\`<pm-bespoke>\`, \`<pm-third-party>\`), and in a page
|
|
523
|
-
with no build as an element (\`<poly-bespoke>\`). A project that vendors members imports these from
|
|
524
|
-
its vendored directory and adds one with \`add\` (\`add bespoke\`, \`add third-party\`,
|
|
525
|
-
\`add density-scope\`, \`add tone-scope\`).
|
|
526
|
-
|
|
527
|
-
## Rung 1: variant selection
|
|
528
|
-
|
|
529
|
-
Every member exposes its range as typed props, such as a variant, a tone, a size and the spacing
|
|
530
|
-
steps. A value off the scale is a type error. Read the member first:
|
|
531
|
-
|
|
532
|
-
${commands(run, "component Button --framework <framework>")}
|
|
533
|
-
|
|
534
|
-
The answer lists each prop's values and the variant and tone pairs that are lawful. Most needs end
|
|
535
|
-
here: a quieter button is ${f.v("Button", "variant", "ghost")}, a destructive one
|
|
536
|
-
${f.v("Button", "tone", "danger")}, and more room is a larger ${f.p("Stack", "gap")}.
|
|
537
|
-
|
|
538
|
-
## Rung 2: ${f.m("DensityScope")} and ${f.m("ToneScope")}
|
|
539
|
-
|
|
540
|
-
A subtree re-assigns a decision the theme already makes for the whole page. Every value still comes
|
|
541
|
-
from the theme.
|
|
542
|
-
|
|
543
|
-
\`\`\`tsx
|
|
544
|
-
import { DensityScope, ToneScope } from '@polymorph/react-ui'
|
|
545
|
-
|
|
546
|
-
<DensityScope value="compact" as="section">
|
|
547
|
-
<DataTable … />
|
|
548
|
-
</DensityScope>
|
|
549
|
-
|
|
550
|
-
<ToneScope value="inverse">
|
|
551
|
-
…
|
|
552
|
-
</ToneScope>
|
|
553
|
-
\`\`\`
|
|
554
|
-
|
|
555
|
-
- ${f.m("DensityScope")}'s ${f.p("DensityScope", "value")} is ${values("DensityScope", "value")}.
|
|
556
|
-
It changes space and the size of controls, never the type scale.
|
|
557
|
-
- ${f.m("ToneScope")}'s ${f.p("ToneScope", "value")} is ${values("ToneScope", "value")}: the
|
|
558
|
-
surface, text and border roles of the opposite mode.
|
|
559
|
-
- ${f.p("DensityScope", "as")} is ${values("DensityScope", "as")}. A scope draws nothing of its own.
|
|
560
|
-
|
|
561
|
-
## Rung 3: an instance patch
|
|
562
|
-
|
|
563
|
-
One instance re-assigns token steps through its ${f.p("Stack", "patch")} prop. Each value is a step
|
|
564
|
-
of a scale, never a length.
|
|
565
|
-
|
|
566
|
-
\`\`\`tsx
|
|
567
|
-
<Stack gap={6} patch={{ gap: 2 }}>…</Stack>
|
|
568
|
-
<Card patch={{ p: 4, radius: 'sm' }}>…</Card>
|
|
569
|
-
\`\`\`
|
|
570
|
-
|
|
571
|
-
${patches}
|
|
572
|
-
|
|
573
|
-
## Rung 4: a ${f.m("Bespoke")} zone or a ${f.m("ThirdParty")} boundary
|
|
574
|
-
|
|
575
|
-
${f.m("Bespoke")} declares a one-off composition the vocabulary has no member for. Its
|
|
576
|
-
${f.p("Bespoke", "reason")} is required and is read by whoever reviews the code. Inside it the
|
|
577
|
-
application rules are lifted for plain elements: \`style\`, a \`className\`, raw values, raw controls
|
|
578
|
-
and inline \`<svg>\` are allowed there. A member inside it still takes no \`className\`. It draws
|
|
579
|
-
nothing itself, and the theme's tokens reach inside it, so write values as \`var(--pm-…)\`.
|
|
580
|
-
|
|
581
|
-
\`\`\`tsx
|
|
582
|
-
import { Bespoke } from '@polymorph/react-ui'
|
|
583
|
-
|
|
584
|
-
<Bespoke reason="Promo illustration: overlapping discs the vocabulary has no shape for.">
|
|
585
|
-
<div style={{ padding: 'var(--pm-space-4)', background: 'var(--pm-accent-subtle)' }}>…</div>
|
|
586
|
-
</Bespoke>
|
|
587
|
-
\`\`\`
|
|
588
|
-
|
|
589
|
-
${f.m("ThirdParty")} hosts a component another library draws, such as a map, a rich-text editor or
|
|
590
|
-
a data grid. It takes ${f.p("ThirdParty", "library")} and ${f.p("ThirdParty", "reason")}. The file
|
|
591
|
-
that declares it may import that library and its stylesheet, and what it holds may take a
|
|
592
|
-
\`style\`. Give the library the theme as \`var(--pm-…)\`, or as values from \`useThemeValues()\` in
|
|
593
|
-
the framework's foundation package. Controls and icons around it stay members.
|
|
594
|
-
|
|
595
|
-
\`\`\`tsx
|
|
596
|
-
import { ThirdParty } from '@polymorph/react-ui'
|
|
597
|
-
import { MapView } from 'some-map-library'
|
|
598
|
-
|
|
599
|
-
<ThirdParty library="some-map-library" reason="Store finder map: no member draws a map.">
|
|
600
|
-
<MapView center={center} />
|
|
601
|
-
</ThirdParty>
|
|
602
|
-
\`\`\`
|
|
603
|
-
|
|
604
|
-
Accessibility is never suspended, in a zone or anywhere else: a control in a zone still needs a name,
|
|
605
|
-
a role and a keyboard path.
|
|
606
|
-
|
|
607
|
-
## Rung 5: promotion
|
|
608
|
-
|
|
609
|
-
A patch or a zone that recurs is promoted into the vocabulary as a variant or a member, or it is
|
|
610
|
-
deleted. A one-off occurs once. Promotion is the design system owner's decision. Report the
|
|
611
|
-
recurring exception with its reasons, and keep each instance declared until then.
|
|
612
|
-
`;
|
|
613
|
-
}
|
|
614
|
-
function setupSkill(registry, run) {
|
|
615
|
-
const frameworks = either(FRAMEWORKS.map((framework) => `\`${framework}\``));
|
|
616
|
-
const systems = registry.theme.systems.map((system) => `\`${system.name}\``).join(", ");
|
|
617
|
-
return [{
|
|
618
|
-
path: "polymorph-setup/SKILL.md",
|
|
619
|
-
contents: skill("polymorph-setup", "Add the polymorph design system to a project, or set up the files a coding agent reads to work with it. Use when asked to start a new app with polymorph, add polymorph to an existing React, Vue, Svelte, Solid or Angular app or to an HTML page, vendor polymorph components into a repository, move to a newer polymorph release, or write the AGENTS.md block, skills and MCP configuration for Claude Code, Codex, Cursor or another agent. It tells a new app, the packages route and the vendoring route apart.", `
|
|
620
|
-
# Set up polymorph
|
|
621
|
-
|
|
622
|
-
Polymorph is a design system: a closed vocabulary of interface components for React, Vue, Svelte,
|
|
623
|
-
Solid and Angular, and as custom elements for an HTML page with no build, with a theme engine and
|
|
624
|
-
lint rules (the red rules) that keep design decisions out of application code. Its tools are one
|
|
625
|
-
npm package, \`@metamorph-labs/polymorph\`, which every command here runs. Always run that scoped
|
|
626
|
-
name: the unscoped \`polymorph\` package on npm is someone else's.
|
|
627
|
-
|
|
628
|
-
## Which route the repository is on
|
|
629
|
-
|
|
630
|
-
| You find | The route |
|
|
631
|
-
| --- | --- |
|
|
632
|
-
| No app yet | A new app: \`init\` |
|
|
633
|
-
| \`@polymorph/*\` packages in \`package.json\`, often as npm aliases of \`@metamorph-labs/polymorph-*\` | Packages: the app installs the vocabulary |
|
|
634
|
-
| \`polymorph.json\` with \`files\`, and member source under its \`dir\` (\`src/polymorph/\`) | Vendoring: the members are copied into the repository as source the team owns |
|
|
635
|
-
| \`polymorph.json\` with \`"framework": "elements"\` | A page with no build: the elements are copied into a static directory |
|
|
636
|
-
| An app with none of these | An existing app without polymorph: vendoring is one command; the packages route is a few manual steps |
|
|
637
|
-
|
|
638
|
-
## A new app
|
|
639
|
-
|
|
640
|
-
${commands(run, "init my-app", "init my-app --framework vue", `init my-app --system ${DEFAULT_SYSTEM} --no-install`, "init my-site --framework elements")}
|
|
641
|
-
|
|
642
|
-
\`init\` writes a new Vite app into an empty directory: the packages, a theme from a catalogue system
|
|
643
|
-
(${systems}), the red rules wired into ESLint and Stylelint, a first screen written as a spec and
|
|
644
|
-
emitted, the agent files (\`AGENTS.md\`, the skills, the MCP entries) and the system card. Then it
|
|
645
|
-
installs the packages with the package manager that ran it. \`--framework\` takes
|
|
646
|
-
${frameworks}. \`--framework elements\` writes a page with no build that loads the elements from copied files, and
|
|
647
|
-
installs nothing.
|
|
648
|
-
|
|
649
|
-
## An existing app: vendoring
|
|
650
|
-
|
|
651
|
-
${commands(run, "plan button dialog theme:pastel --framework <framework>", "add button dialog theme:pastel --framework <framework>", "diff", "update")}
|
|
652
|
-
|
|
653
|
-
\`<framework>\` is the app's framework: the one \`polymorph.json\` records, or, in an app with no
|
|
654
|
-
\`polymorph.json\` yet, the one its \`package.json\` depends on (\`vue\` for a Vue app). Name it on
|
|
655
|
-
every \`plan\` and \`add\`. The first \`add\` records the framework in \`polymorph.json\`, and with no
|
|
656
|
-
\`--framework\` it records \`react\` and copies React members, whatever the app is written in.
|
|
657
|
-
|
|
658
|
-
\`plan\` prints what \`add\` would copy and install, and writes nothing. \`add\` copies the members you
|
|
659
|
-
name, and every member they need, as source into \`src/polymorph/\` (\`--dir\` changes it), installs a
|
|
660
|
-
theme (\`theme:<system>\`, or \`palette:<name>\` for a palette alone), adds the packages the members
|
|
661
|
-
import to \`package.json\`, and links the red rules into the project's ESLint and Stylelint configs.
|
|
662
|
-
Install the new dependencies afterwards with the project's package manager. \`polymorph.json\`
|
|
663
|
-
records each file with a hash of what was written.
|
|
664
|
-
|
|
665
|
-
\`diff\` lists the files you have edited and the files that changed upstream. \`update\` copies again
|
|
666
|
-
the files you have not edited and keeps the ones you have; \`--force\` takes upstream's copy.
|
|
667
|
-
|
|
668
|
-
## An existing app: packages
|
|
669
|
-
|
|
670
|
-
The packages route installs \`@polymorph/engine\`, the framework's foundation and vocabulary, and
|
|
671
|
-
\`@polymorph/rules\` as npm aliases of their published names, adds the theme plugin to
|
|
672
|
-
\`vite.config\`, and spreads the red rules into the lint configs. The steps, with the exact lines, are
|
|
673
|
-
in https://github.com/metamorph-labs/polymorph/blob/main/docs/consuming.md. \`init\` writes the same
|
|
674
|
-
files for a new app, so an app it wrote is a working example.
|
|
675
|
-
|
|
676
|
-
## The agent's files
|
|
677
|
-
|
|
678
|
-
${commands(run, "agents", "agents --harness claude,codex", "agents --dry-run")}
|
|
679
|
-
|
|
680
|
-
\`agents\` writes what a coding agent reads in this repository: a marked block in \`AGENTS.md\` (and a
|
|
681
|
-
\`CLAUDE.md\` that includes it), these skills in \`.claude/skills/\` and \`.agents/skills/\`, the MCP
|
|
682
|
-
server's entry for each harness (\`.mcp.json\`, \`.cursor/mcp.json\`, \`.codex/config.toml\`), and the
|
|
683
|
-
system card in \`polymorph/system-card.md\`. \`--harness\` takes \`claude\`, \`codex\`, \`cursor\`,
|
|
684
|
-
\`generic\` or \`all\`. It records what it wrote in \`polymorph/agents.json\`. Run it again at any
|
|
685
|
-
time: a file it wrote and nobody edited is brought up to date, a file someone edited is kept and
|
|
686
|
-
named, and text outside its block in \`AGENTS.md\` and other servers in an MCP config are left as
|
|
687
|
-
they are. \`--force\` overwrites edited files. \`--remove <harness>\` stops writing for a harness
|
|
688
|
-
and removes the files only it reads that nobody edited. An older release refuses to write over a
|
|
689
|
-
newer one's files.
|
|
690
|
-
|
|
691
|
-
## Moving to a newer release
|
|
692
|
-
|
|
693
|
-
Every command in this skill names the release it runs. To move to a newer one, run the same
|
|
694
|
-
commands with the newer version in place of this one's. In every project, \`agents\` rewrites the
|
|
695
|
-
agent files and the card for that release. In a vendoring project, \`update\` copies the new
|
|
696
|
-
members. In a packages project, raise the ranges of the \`@polymorph/*\` aliases and of
|
|
697
|
-
\`@metamorph-labs/polymorph\` in \`package.json\`, and install.
|
|
698
|
-
|
|
699
|
-
## Check the setup
|
|
700
|
-
|
|
701
|
-
${commands(run, "check src", "card --framework <framework>")}
|
|
702
|
-
|
|
703
|
-
\`check\` runs the red rules over a directory with no lint config and exits 1 on any violation. The
|
|
704
|
-
card should list the members the app uses.
|
|
705
|
-
`)
|
|
706
|
-
}];
|
|
707
|
-
}
|
|
708
|
-
function themeSkill(registry, run) {
|
|
709
|
-
const f = new Facts(registry);
|
|
710
|
-
const pairings = registry.theme.systems.slice(0, 3).map((system) => `\`${system.name}/${system.defaultPalette}\``).join(", ");
|
|
711
|
-
const plain = registry.theme.systems.find((system) => system.name === DEFAULT_SYSTEM);
|
|
712
|
-
const basis = `${DEFAULT_SYSTEM}/${plain?.defaultPalette ?? ""}`.replace(/\/$/, "");
|
|
713
|
-
return [{
|
|
714
|
-
path: "polymorph-theme/SKILL.md",
|
|
715
|
-
contents: skill("polymorph-theme", "Change how an app built with polymorph looks, its colours, type, density, shape, motion or overall feel. Use when asked to restyle or rebrand a polymorph app, to make it calmer, denser, warmer, darker or more editorial, to pick or adjust a theme, system or palette, or when tempted to write a colour, font or length in application code. Proposes a theme from plain words, checks it against the theme laws and saves it.", `
|
|
716
|
-
# Change the theme
|
|
717
|
-
|
|
718
|
-
In polymorph, how an app looks is two JSON documents. A **system** decides how the product is
|
|
719
|
-
built: its design axes (${all(f.axes().map((axis) => `\`${axis}\``))}), its fonts and its
|
|
720
|
-
defaults. A **palette** decides its colours, in a light and a dark mode. One system worn with one
|
|
721
|
-
palette is a **pairing**, chosen by \`data-system\` and \`data-palette\` on \`<html>\`. The members
|
|
722
|
-
read every value from the theme as \`--pm-*\` tokens, so the look changes when the documents change
|
|
723
|
-
and in no other way. Application code never writes a colour, a length, a font or a duration.
|
|
724
|
-
|
|
725
|
-
Every command in this skill starts with the same words, the polymorph tools run from a shell. An
|
|
726
|
-
MCP server named \`polymorph\` gives the same answers through \`get_theme_axes\`, \`propose_theme\`
|
|
727
|
-
and \`save_theme\`.
|
|
728
|
-
|
|
729
|
-
## 1. Find the app's theme
|
|
730
|
-
|
|
731
|
-
- An app \`init\` wrote: \`src/theme/<system>.json\` and \`src/theme/<palette>.json\`, named in
|
|
732
|
-
\`vite.config\` by \`polymorphTheme({ systems, palettes })\`, which compiles them when the app
|
|
733
|
-
builds.
|
|
734
|
-
- A vendoring project: \`src/polymorph/themes/systems/\` and \`src/polymorph/themes/palettes/\`,
|
|
735
|
-
compiled by \`add\` into the sheets beside them.
|
|
736
|
-
- A page with no build: \`${ELEMENTS_DIR}/${ELEMENTS_THEME_SHEET}\`, compiled from a catalogue
|
|
737
|
-
system.
|
|
738
|
-
|
|
739
|
-
## 2. See what can move
|
|
740
|
-
|
|
741
|
-
${commands(run, "axes", "axes --values")}
|
|
742
|
-
|
|
743
|
-
\`axes\` lists the axes and their values, the shipped systems and palettes, the colour roles and the
|
|
744
|
-
scales. \`--values\` adds each system's token values with its own palette.
|
|
745
|
-
|
|
746
|
-
## 3. Propose a theme from words
|
|
747
|
-
|
|
748
|
-
${commands(run, "theme propose \"calmer, warmer paper, more editorial\"", `theme propose "denser and cooler" --based-on ${basis}`, "theme propose \"denser and cooler\" --save --dir design")}
|
|
749
|
-
|
|
750
|
-
The answer lists what each word moved, the words the table does not know, and the verdict of the
|
|
751
|
-
theme's laws. \`--based-on\` starts from a shipped pairing, such
|
|
752
|
-
as ${pairings}; either half may be left out. \`--save\` writes the two documents into
|
|
753
|
-
\`<dir>/systems/\` and \`<dir>/palettes/\` (the directory \`design\` when \`--dir\` is left out), and
|
|
754
|
-
\`--overwrite\` replaces files already saved under the same names. Then point the app at them: in an
|
|
755
|
-
app \`init\` wrote, name the two files in \`polymorphTheme\` in \`vite.config\`.
|
|
756
|
-
|
|
757
|
-
Words the table does not know move nothing. Say what should change in the words of the axes \`axes\`
|
|
758
|
-
lists, such as denser, rounder, calmer or warmer.
|
|
759
|
-
|
|
760
|
-
## 4. Edit a document by hand, then check it
|
|
761
|
-
|
|
762
|
-
${commands(run, "theme validate src/theme/system.json src/theme/palette.json", "theme schema system --out system.schema.json")}
|
|
763
|
-
|
|
764
|
-
\`theme validate\` admits a system and a palette under the same laws as the shipped ones, and names
|
|
765
|
-
each law a pairing breaks. \`theme schema\` writes the JSON Schema of a system or a palette, for an
|
|
766
|
-
editor.
|
|
767
|
-
|
|
768
|
-
## 5. Wear a shipped theme
|
|
769
|
-
|
|
770
|
-
${commands(run, "add theme:pastel --framework <framework>", "add palette:orchid --framework <framework>")}
|
|
771
|
-
|
|
772
|
-
\`<framework>\` is the app's framework, as the \`polymorph-setup\` skill tells it. In a vendoring
|
|
773
|
-
project, \`add theme:<system>\` installs a shipped system with its own palette and its fonts, and
|
|
774
|
-
\`add palette:<name>\` a palette alone, which any installed system can wear. In a page with no
|
|
775
|
-
build, \`add theme:<system>\` compiles it into the theme sheet.
|
|
776
|
-
|
|
777
|
-
An app that compiles its theme with the Vite plugin wears the documents \`vite.config\` names. To
|
|
778
|
-
wear a shipped pairing there, save it as two documents of the app's own: words the table does not
|
|
779
|
-
know move nothing, so the proposal is the shipped pairing as it is. Then name the two saved files in
|
|
780
|
-
\`polymorphTheme\`.
|
|
781
|
-
|
|
782
|
-
${commands(run, "theme propose \"as shipped\" --based-on journal/umber --save --dir src/theme")}
|
|
783
|
-
|
|
784
|
-
## What not to do
|
|
785
|
-
|
|
786
|
-
- No colour, length, font or duration in application code, and no \`--pm-*\` property declared by
|
|
787
|
-
the app. A value the theme does not derive belongs in the system or palette document.
|
|
788
|
-
- No stylesheet that overrides a member. A member's look is the theme's.
|
|
789
|
-
- No branching on which theme is active. A subtree that needs another density or the inverse tone
|
|
790
|
-
uses ${f.m("DensityScope")} or ${f.m("ToneScope")} (the \`polymorph-rules\` skill).
|
|
791
|
-
`)
|
|
792
|
-
}];
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
11
|
* Every file of every skill, at its path below a skills directory
|
|
796
12
|
* (`polymorph-screen/SKILL.md`), in the order of `SKILL_NAMES`.
|
|
797
13
|
*/
|
|
@@ -800,8 +16,11 @@ function skillFiles(registry, run) {
|
|
|
800
16
|
...screenSkill(registry, run),
|
|
801
17
|
...rulesSkill(registry, run),
|
|
802
18
|
...setupSkill(registry, run),
|
|
803
|
-
...themeSkill(registry, run)
|
|
19
|
+
...themeSkill(registry, run),
|
|
20
|
+
...runtimeSkill(registry, run),
|
|
21
|
+
...bridgeSkill(registry, run),
|
|
22
|
+
...nativeSkill(registry, run)
|
|
804
23
|
];
|
|
805
24
|
}
|
|
806
25
|
//#endregion
|
|
807
|
-
export { SKILL_NAMES,
|
|
26
|
+
export { SKILL_NAMES, SKILL_USES, skillFiles };
|