@joralvmel/cosmos-mcp 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jorge Andrés Álvarez Melchor (joralvmel)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # @joralvmel/cosmos-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Model Context Protocol](https://modelcontextprotocol.io/) server of [Cosmos UI](../../README.md). It
4
+ gives AI assistants the real API of the installed version: components with snippets for every platform,
5
+ their status, themes, tokens, setup guides and a docs search.
6
+
7
+ ## Use
8
+
9
+ ```bash
10
+ npx -y @joralvmel/cosmos-mcp # stdio server
11
+ ```
12
+
13
+ VS Code (`.vscode/mcp.json`, or run `npx @joralvmel/cosmos-cli init-ai`):
14
+
15
+ ```json
16
+ { "servers": { "cosmos-ui": { "type": "stdio", "command": "npx", "args": ["-y", "@joralvmel/cosmos-mcp"] } } }
17
+ ```
18
+
19
+ | Tool | Returns |
20
+ | --- | --- |
21
+ | `list_components` | Catalog components with category, platforms, dependencies and status |
22
+ | `get_component` | Contract, API table, snippets (HTML, React, Angular, React Native), imports and status |
23
+ | `list_themes` / `get_tokens` | Built-in themes; semantic tokens of a theme and mode |
24
+ | `get_setup` | Install commands, setup code and rules for `react`, `next`, `angular`, `html`, `react-native`, `tailwind` |
25
+ | `search_docs` | Docs pages and package references matching a query |
26
+
27
+ Resources: `cosmos://llms/<package>` (the `llms.md` of each package).
28
+
29
+ ## Programmatic use
30
+
31
+ ```ts
32
+ import { createServer, getComponent } from '@joralvmel/cosmos-mcp';
33
+ ```
34
+
35
+ The data (status, docs and references) is bundled at build time by `scripts/build-data.mjs`.
36
+
37
+ ## License
38
+
39
+ MIT
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { createServer } from './server.js';
4
+ await createServer().connect(new StdioServerTransport());
5
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,YAAY,EAAE,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ [{"slug":"ai/mcp","title":"MCP server","markdown":"# MCP server\n\n> Connect AI assistants to the Cosmos UI MCP server to query components, themes, tokens and setup.\n\n`@joralvmel/cosmos-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io/) server\n(stdio). It ships the contracts, snippets, status, themes and docs of its version, so the answers match\nwhat you install.\n\n## Connect\n\n**VS Code**\n`npx @joralvmel/cosmos-cli init-ai` does it for you, or add to `.vscode/mcp.json`:\n\n```json\n{\n \"servers\": {\n \"cosmos-ui\": { \"type\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"@joralvmel/cosmos-mcp\"] }\n }\n}\n```\n**Claude Code**\n```bash\nclaude mcp add cosmos-ui -- npx -y @joralvmel/cosmos-mcp\n```\n**Other clients**\nRun the command `npx -y @joralvmel/cosmos-mcp` as a stdio server in your client configuration.\n\n## Tools\n\n| Tool | Arguments | Returns |\n| --- | --- | --- |\n| `list_components` | `status?` (`planned`, `in-progress`, `stable`) | Every catalog component with category, platforms, dependencies and status. |\n| `get_component` | `name` | Contract (props, events per platform, slots, parts, keyboard), API table, snippets for HTML, React, Angular and React Native, imports and status. |\n| `list_themes` | — | Built-in themes and their modes. |\n| `get_tokens` | `theme?`, `mode?` | Semantic color tokens and radii of a theme and mode. |\n| `get_setup` | `framework` (`react`, `next`, `angular`, `html`, `react-native`, `tailwind`) | Install commands, setup code and rules. |\n| `search_docs` | `query`, `limit?` | Matching docs pages and package references with an excerpt. |\n\nResources: `cosmos://llms/<package>` returns the `llms.md` of each package.\n\n## Example questions\n\n- \"Which Cosmos components are stable, and which ones can I use for a form?\"\n- \"Show me the Angular code for a danger outline button that is loading.\"\n- \"What are the dark-mode tokens of the nebula theme?\"\n"},{"slug":"ai/overview","title":"Use Cosmos UI with AI","markdown":"# Use Cosmos UI with AI\n\n> Give AI assistants the real Cosmos API with init-ai, llms.txt, Markdown pages and the MCP server.\n\nAI assistants write better UI code when they know the real components, props, events and tokens. Cosmos\ngives them that knowledge in three ways, all generated from the component contracts.\n\n## 1. Prepare your project with `init-ai`\n\n1. Run it in your project folder with your stack (`react`, `next`, `angular`, `html` or `react-native`):\n\n ```bash\n npx @joralvmel/cosmos-cli init-ai --stack react\n ```\n\n2. It writes a marked block with the Cosmos rules into `.github/copilot-instructions.md` and\n `AGENTS.md` (add `--claude` for `CLAUDE.md`), registers the MCP server in `.vscode/mcp.json` and\n prints the installation steps. Run it again at any time: only the marked block is replaced.\n\n3. Ask your assistant to install Cosmos UI (see the [ready-made prompts](../prompts/)).\n\n## 2. Reference files\n\n| Resource | Use |\n| --- | --- |\n| [`/llms.txt`](../../llms.txt) | Index of every package reference and page, for assistants that read `llms.txt`. |\n| [`/llms-full.txt`](../../llms-full.txt) | The whole documentation and every package reference in one file. |\n| `/<page>.md` | Every page as Markdown (button **Copy page for AI** below each title). |\n| `node_modules/@joralvmel/cosmos-*/llms.md` | Reference of each installed package: setup, components with props, events and examples, themes and rules. |\n\n## 3. MCP server\n\nThe [MCP server](../mcp/) answers questions about components, themes, tokens and setup with data that\nmatches the installed version.\n\n## Install with AI (copy and paste)\n\n```text\nInstall Cosmos UI in this project. First run `npx @joralvmel/cosmos-cli init-ai --stack <my stack>`,\nthen follow the steps it prints. Use the cosmos-ui MCP server (get_setup, list_components,\nget_component) or https://joralvmel.github.io/cosmos-ui/llms.txt to check every component and prop\nbefore using it. Style only with Cosmos tokens or the Cosmos Tailwind theme.\n```\n"},{"slug":"ai/prompts","title":"Ready-made prompts","markdown":"# Ready-made prompts\n\n> Copyable prompts to build UI with Cosmos in React, Next.js, Angular, HTML and React Native.\n\nCopy a prompt, replace the part in angle brackets and paste it in your assistant. They assume you ran\n[`init-ai`](../overview/) or that the assistant can read `llms.txt` or the MCP server.\n\n**React**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this React + Vite app, build <a settings page with a\nform and a save button>. Check each component with the cosmos-ui MCP server (get_component) before\nusing it, handle events through event.detail, style the layout with Cosmos tokens or the Cosmos\nTailwind theme, support light and dark mode and keep keyboard access.\n```\n**Next.js**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this Next.js App Router project, build <a dashboard\nheader with actions>. Put Cosmos components in Client Components ('use client'), keep pages as\nServer Components, load @joralvmel/cosmos-tokens/tokens.css in app/layout.tsx and use\nthemeInitScript() to avoid a theme flash. Check props with the cosmos-ui MCP server.\n```\n**Angular**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-angular) in this standalone Angular app, build <a profile form>.\nImport the Cosmos standalone components you need, bind inputs with signals, listen to outputs with\n$event.detail and keep forms accessible. Check each component with the cosmos-ui MCP server.\n```\n**HTML**\n```text\nBuild <a landing page section> in plain HTML with Cosmos UI Web Components from a CDN\n(@joralvmel/cosmos-elements and @joralvmel/cosmos-tokens). Use <cosm-*> elements, listen to cosm-*\nevents, set data-theme and data-mode on <html> and use only var(--cosm-*) tokens in custom CSS.\n```\n**React Native**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-native) in this Expo app, build <a login screen>. Wrap the app in\nCosmosThemeProvider with mode=\"system\", use useTheme() for custom styles, keep touch targets of at\nleast 44 points and accessibility labels. Check each component with the cosmos-ui MCP server.\n```\n\n## Prompts for the component library itself\n\nTo add or change components in the Cosmos repository, use the agents and prompts of the repository\n(`/create-component`, `/component-status`…): see [Working with agents](../../contribute/working-with-agents/).\n"},{"slug":"components/button","title":"Button","markdown":"# Button\n\n> Triggers an action or submits a form. Web Component, React, Angular and React Native.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-button>` triggers an action. It follows the\n[WAI-ARIA button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/), renders a native\n`<button>` and takes part in forms (`type=\"submit\"` / `type=\"reset\"`). Use it for actions; use a link\nfor navigation.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-button>Save changes</cosm-button>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/button';\n\n const element = document.querySelector('cosm-button');\n element.addEventListener('cosm-press', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Button onPress={event => console.log(event.detail)}>Save changes</Button>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\nimport type { ButtonPressDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"onPress($event.detail)\">Save changes</cosm-button>`,\n})\nexport class ExampleComponent {\n onPress(detail: ButtonPressDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Button onPress={detail => console.log(detail)}>Save changes</Button>\n );\n}\n```\n\n## Variants\n\n`variant` sets the emphasis and `tone` the color role. Use one `solid` button per view for the main\naction.\n\n```html\n<cosm-button>Solid</cosm-button>\n<cosm-button variant=\"soft\">Soft</cosm-button>\n<cosm-button variant=\"outline\">Outline</cosm-button>\n<cosm-button variant=\"ghost\">Ghost</cosm-button>\n<cosm-button tone=\"neutral\">Neutral</cosm-button>\n<cosm-button tone=\"danger\">Delete</cosm-button>\n```\n\n```html\n<cosm-button size=\"sm\">Small</cosm-button>\n<cosm-button>Medium</cosm-button>\n<cosm-button size=\"lg\">Large</cosm-button>\n```\n\n## States\n\n```html\n<cosm-button loading>Saving</cosm-button>\n<cosm-button disabled>Disabled</cosm-button>\n```\n\n- `loading` keeps the button focusable, sets `aria-busy` and ignores presses.\n- `disabled` removes it from the tab order and ignores presses.\n- Hover, active and `:focus-visible` states use the theme tokens of the selected tone.\n\n## Accessibility\n\n- Native `<button>` semantics: <kbd>Enter</kbd> and <kbd>Space</kbd> activate it.\n- Give icon-only buttons a `label`; it becomes the accessible name.\n- Use `tone=\"danger\"` together with explicit text for destructive actions; color is never the only cue.\n- On React Native, small buttons extend their touch area to 44 points.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `variant` | 'solid' \\| 'soft' \\| 'outline' \\| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |\n| `tone` | 'primary' \\| 'neutral' \\| 'danger' | `primary` | Color role. Use danger for destructive actions. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Control height and padding. |\n| `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |\n| `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |\n| `fullWidth` | boolean | `false` | Stretches the button to the width of its container. |\n| `type` | 'button' \\| 'submit' \\| 'reset' | `button` | Form behavior of the button. |\n| `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Button label. |\n| `start` | Content before the label, usually an icon. |\n| `end` | Content after the label, usually an icon. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | The native button element. |\n| `label` | Wrapper of the label slot. |\n| `spinner` | Loading indicator. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-button-radius` | Corner radius. |\n| `--cosm-button-gap` | Space between icon and label. |\n| `--cosm-button-font-weight` | Label font weight. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Enter`, `Space` | Activates the button. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-press` | `onPress` | `(press)` | `onPress` | `ButtonPressDetail` | The button was activated by pointer, keyboard or programmatically. |\n"},{"slug":"components/status","title":"Component status","markdown":"# Component status\n\n> Inventory of every planned Cosmos component, with what exists on each platform.\n\nThis page is generated from the repository on every build: the canonical list lives in\n`packages/core/src/catalog.ts` and `npm run status` detects which pieces exist for each component\n(contract, scenarios, each platform, tests, docs, AI reference and changeset).\n\n- **Stable**: every piece exists for every platform of the component.\n- **In progress**: some pieces exist.\n- **Planned**: nothing exists yet. A planned component can start when its dependencies are stable.\n\n1 stable · 0 in progress · 37 planned (38 total)\n\nNext: `icon`, `badge`, `avatar`, `divider`, `listbox`\n\n| Component | Status | Priority | Contract | Scenarios | Web Component | React | Angular | React Native | Native demo | Tests | Docs (EN) | Docs (ES) | llms.md | Changeset | Depends on |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| button | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| icon | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| icon-button | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon |\n| badge | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| spinner | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| avatar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| divider | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| listbox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| calendar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button |\n| text-field | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| textarea | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| checkbox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| radio-group | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| switch | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| number-field | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | text-field, icon-button |\n| select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, icon |\n| combobox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, text-field |\n| multi-select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, badge, checkbox |\n| slider | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| popover | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| tooltip | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| dialog | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| drawer | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | dialog |\n| toast | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon, icon-button |\n| menu | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| split-button | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, menu |\n| tabs | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| accordion | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| pagination | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| steps | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| breadcrumb | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| card | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| table | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | checkbox, pagination, icon-button |\n| date-picker | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, calendar, text-field |\n| date-range-picker | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | date-picker |\n| bottom-sheet | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| skeleton | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| list-item | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n\nRun it locally:\n\n```bash\nnpm run status # table\nnpm run status -- --markdown\nnpm run status -- --json\n```\n"},{"slug":"contribute/example-switch","title":"Example: from issue to release","markdown":"# Example: from issue to release\n\n> A complete walkthrough that creates the cosm-switch component with the agents and skills, from the issue to the npm release.\n\nThis walkthrough adds `cosm-switch` (WAI-ARIA switch) on every platform. Each step names the skill to\nrun (as a `/prompt` in VS Code or by asking the agent) and shows the commands it runs and the expected\noutput.\n\n## 1. Check the inventory — `component-status`\n\n```bash\nnpm run status\n```\n\n```text\nComponents: 38 · stable 1 · in progress 0 · planned 37\n…\nplanned 1 switch\n…\nNext suggested: icon, badge, avatar, divider, listbox\n```\n\n`switch` is planned, priority 1 and has no dependencies, so it can start now.\n\n## 2. Issue and branch — `start-work`\n\n```bash\ngh issue create --template component_request.yml --title \"Component: switch\"\n# → https://github.com/joralvmel/cosmos-ui/issues/12\ngh issue develop 12 --base develop --name feat/elements-switch --checkout\n```\n\n```text\ngithub.com/joralvmel/cosmos-ui/tree/feat/elements-switch\nSwitched to a new branch 'feat/elements-switch'\n```\n\n## 3. Research — `research-reference`\n\nThe `researcher` agent summarizes the\n[APG switch pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/): role `switch`,\n`aria-checked`, <kbd>Space</kbd> toggles, visible label, and recommends a native\n`<input type=\"checkbox\" role=\"switch\">` inside the Web Component (form participation for free).\n\n## 4. Contract — `define-contract`\n\nThe `architect` agent writes `packages/core/src/specs/switch.ts` (props `checked`, `disabled`,\n`required`, `name`, `value`, `label`; event `change` → DOM `cosm-change`, React `onChange`, Angular\n`(checkedChange)`, React Native `onCheckedChange`; state `checked` with `defaultChecked`) and the shared\nscenarios (toggle by pointer and keyboard, disabled, controlled proposal without commit).\n\n## 5. Visual spec — `design-component`\n\nThe `design-system` agent writes `docs/design/switch.md`: track and thumb sizes per `size`, states\n(hover, focus-visible, checked, disabled, invalid), tokens (`--cosm-primary`, `--cosm-border-strong`,\n`--cosm-surface`), motion with `prefers-reduced-motion`, and checks contrast in every theme.\n\n## 6. Generate — `create-component`\n\n```bash\nnpm run generate -- component switch\n```\n\n```text\nWrote 21 files:\n packages/core/src/specs/switch.ts\n packages/core/src/specs/switch.scenarios.ts\n packages/core/src/index.ts\n packages/elements/src/components/switch/cosm-switch.ts\n …\n apps/docs/src/content/docs/es/components/switch.mdx\n .changeset/add-switch.md\n\nNext: resolve every TODO(generator) marker, then run\n npx biome ci . && npx turbo run typecheck test build\n```\n\n`component-builder` replaces the generated placeholders with the real contract, the Lit\nimplementation (anatomy order: imports, types, styles, class, registration), the React events map and\nthe Angular inputs and `(checkedChange)` output with a `ControlValueAccessor`.\n\n## 7. React Native — `create-native-component`\n\n`native-expert` implements `Switch` with `Pressable`, `accessibilityRole=\"switch\"`,\n`accessibilityState={{ checked, disabled }}`, a 44-point touch area and `useTheme()` colors, and\nfinishes the demo screen `apps/native-demo/app/switch.tsx`.\n\n## 8. Tests — `add-contract-tests`\n\n```bash\nnpx turbo run test --filter=...@joralvmel/cosmos-core\ncd tools && npx vitest run test/structure.test.mjs test/status.test.mjs\n```\n\n```text\n Tasks: N successful, N total\n ✓ test/structure.test.mjs\n ✓ test/status.test.mjs\n```\n\n## 9. Docs and AI references — `add-docs-page`, `add-playground`, `update-ai-references`\n\nThe pages follow the anatomy order (status, Playground, variants, states, accessibility, API, events by\nplatform) in English and Spanish. The Playground already shows HTML, React, Angular and React Native\ncode from the contract.\n\n```bash\nnpm run llms\nnpm run status\n```\n\n```text\nstable 1 switch\n```\n\nWhen every piece exists, `component-builder` sets `status: 'stable'` in the catalog entry.\n\n## 10. Changeset — `add-changeset`\n\n```md\n---\n'@joralvmel/cosmos-core': minor\n'@joralvmel/cosmos-elements': minor\n'@joralvmel/cosmos-react': minor\n'@joralvmel/cosmos-angular': minor\n'@joralvmel/cosmos-native': minor\n---\n\nAdd the Switch component (`cosm-switch`) on every platform.\n```\n\n## 11. Pull request — `finish-work`\n\n```bash\nnpx biome ci . && npx turbo run typecheck test build && npm run check-terms\ngit push -u origin HEAD\ngh pr create --base develop --title \"feat(elements): add cosm-switch\" --body-file pr.md --label type:component\n```\n\n```text\nhttps://github.com/joralvmel/cosmos-ui/pull/13\n```\n\nCI runs lint, terms, typecheck, tests and build, the docs build (preview artifact), the changeset check\nand commit hygiene; the labeler adds `pkg:core`, `pkg:elements`, `pkg:react`, `pkg:angular`,\n`pkg:native`, `app:docs` and `app:native-demo`.\n\n## 12. Review and merge\n\nAsk the `reviewer` agent for a review, address the comments and wait for the code owner approval. Merge\nwith **Squash and merge** (the PR title becomes the commit message); the branch is deleted\nautomatically.\n\n## 13. Back to develop — `sync-after-merge`\n\n```bash\ngit switch develop && git pull --prune --ff-only && git branch -D feat/elements-switch\n```\n\n## 14. Release pull request — `release-pr`\n\n```bash\nnpx changeset status --since=origin/main\ngh pr create --base main --head develop --title \"chore(release): switch\" --label release\n```\n\nMerge it with **Create a merge commit**.\n\n## 15. Publish — `release`\n\nThe `Release` workflow opens **Version Packages** on main (versions `0.2.0`, changelogs). Merging it\npublishes to npm with provenance and creates the GitHub Releases:\n\n```bash\nnpm view @joralvmel/cosmos-elements version\n```\n\n```text\n0.2.0\n```\n"},{"slug":"contribute/getting-started","title":"Getting started","markdown":"# Getting started\n\n> Set up the Cosmos UI repository, run the docs and the native demo, and solve common problems.\n\n## Requirements\n\n- **Node.js 24** (see `.nvmrc`; `nvm use` or `fnm use`) and **npm 11**.\n- Git, and the [GitHub CLI](https://cli.github.com/) (`gh`) for the branch and pull request skills.\n- VS Code with GitHub Copilot to use the [agents](../working-with-agents/) (optional).\n- For the native demo: the Expo Go app on a phone, Android Studio (emulator) or Xcode (iOS simulator,\n macOS only).\n\n## First run\n\n1. Clone and install. `npm ci` also points Git to the hooks in `.githooks`:\n\n ```bash\n git clone https://github.com/joralvmel/cosmos-ui.git\n cd cosmos-ui\n npm ci\n ```\n\n2. Build, test and check everything (the same commands as CI):\n\n ```bash\n npx biome ci . && npx turbo run typecheck test build\n ```\n\n Turborepo caches results: a second run takes seconds.\n\n3. Open the docs site at http://localhost:4321:\n\n ```bash\n npm run docs\n ```\n\n4. See what exists and what is next:\n\n ```bash\n npm run status\n ```\n\n## Native demo\n\nThe Expo Router app in `apps/native-demo` has one screen per React Native component and a theme and\nmode switcher.\n\n```bash\nnpm run build # the demo uses the built packages\nnpm run dev --workspace=@joralvmel/cosmos-native-demo\n```\n\n- **Expo Go** (any OS): scan the QR code with the Expo Go app (Android) or the camera (iOS). The phone\n and the computer must be on the same network.\n- **Android emulator**: install Android Studio, create a virtual device, start it, then press `a` in\n the Expo terminal.\n- **iOS simulator** (macOS): install Xcode and its command line tools, then press `i`.\n\n## Repository structure\n\n| Folder | Contents |\n| --- | --- |\n| `packages/*` | Publishable packages (`tokens`, `tailwind`, `core`, `elements`, `react`, `angular`, `native`, charts, `icons`, `i18n`, `mcp`, `cli`) |\n| `apps/docs` | This site (Astro + Starlight, English and Spanish) |\n| `apps/native-demo` | Expo demo app |\n| `tools/` | Generator, component status, AI references, Git and GitHub checks, release helpers |\n| `docs/adr`, `docs/conventions` | Architecture decisions and the component anatomy |\n| `.github/` | Workflows, agents, skills, prompts and path-specific instructions |\n\n## Browser tests\n\nUnit and behavior tests run in Vitest with happy-dom, so no browser is needed. Browser checks\n(Playwright with axe) are planned for keyboard behavior and accessibility; when they land they will\nneed `npx playwright install` once.\n\n## Troubleshooting\n\n| Problem | Fix |\n| --- | --- |\n| `EBADENGINE` / unsupported engine | Use Node.js 24 (`nvm use`). |\n| `EBUSY: resource busy or locked` on Windows during `npm ci` | An editor or language server holds a file in `node_modules`; close the project in other IDEs and run it again. |\n| `File content differs from formatting output` | `npm run lint:fix` (Biome formats with LF line endings). |\n| Hooks do not run | `npm ci` with `ignore-scripts` skips `prepare`: run `node tools/git/install-hooks.mjs`. |\n| `Commit blocked: the Git identity does not match` | Your `.local/git-identity.json` expects another identity; fix `git config --local user.*` or the file. |\n| `llms.md files are outdated` | `npm run llms` (the AI references are generated from the contracts). |\n| Strange cached results | `npx turbo run build --force`. |\n"},{"slug":"contribute/git-workflow","title":"Git workflow","markdown":"# Git workflow\n\n> Branches, commits, pull requests, reviews and releases in Cosmos UI.\n\n## Branches\n\n| Branch | Purpose | How changes arrive |\n| --- | --- | --- |\n| `main` | Released code; every push runs the release and docs deployment | Merge commit from `develop` (release pull request) |\n| `develop` | Integration, default branch | Squash merge of work branches |\n| `<type>/<scope>-<description>` | One task | Created from `develop`, deleted after merge |\n\nTypes: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`. Scope: package or area (`elements`, `tokens`,\n`docs`…). Example: `feat/elements-switch`. Contributors without write access fork the repository and\nopen the pull request from their fork.\n\n## Commits\n\n- [Conventional Commits](https://www.conventionalcommits.org/): `type(scope): summary`, several scopes\n separated by commas (`feat(mcp,cli): …`). The `commit-msg` hook checks it.\n- Use your own Git identity; prefer your GitHub noreply email. Sign off with `git commit -s`\n ([DCO](https://developercertificate.org/)) if you can.\n- Never use `--no-verify`.\n\n## Pull requests\n\n1. `start-work` → work → `finish-work` (validates, pushes and opens the pull request to `develop`).\n2. Required: green checks (lint, terms, typecheck, tests, build, packs, docs build, changeset, commit\n hygiene) and resolution of review conversations. Approvals are optional.\n3. Squash merge: the pull request title must be a Conventional Commit (checked by CI).\n4. `sync-after-merge` cleans up the local branch.\n\nApprovals are optional on `main` and `develop` so a sole maintainer can merge their own pull requests.\nThis policy applies to all contributors: classic branch protection on a personal repository does not\nsupport individual review exemptions. Pull requests, required checks and conversation resolution\nremain mandatory. Copilot reviews are advisory, not approving reviews.\n\n## Releases\n\n`release-pr` opens `develop → main` with the pending changesets; merge it with a merge commit. The\n[Release and publishing](../publishing/) page explains the rest.\n\n## Repository settings\n\nBranch protection, merge options and labels are code: `npm run setup-repo` shows the changes and\n`npm run setup-repo -- --apply` applies them with the GitHub CLI. Settings that only exist in the\nGitHub UI are printed at the end of the command.\n\n## Personal safeguards (optional)\n\nOn a computer with several GitHub accounts, create `.local/git-identity.json` (ignored by Git) with\nyour name, email and GitHub login: the `pre-commit` hook and the `verify-identity` skill then block\ncommits and pushes with another identity. On a computer with a single personal account nothing is\nneeded.\n"},{"slug":"contribute/publishing","title":"Release and publishing","markdown":"# Release and publishing\n\n> How Cosmos UI is versioned and published to npm, and the one-time setup for maintainers.\n\nCosmos UI uses [Changesets](https://github.com/changesets/changesets) for versions and changelogs and\npublishes to the public npm registry with\n[trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC, no npm token) and\n[provenance](https://docs.npmjs.com/generating-provenance-statements).\n\n## How releases work\n\n1. Every pull request that changes `packages/*` adds a changeset (`npm run changeset`).\n2. When `develop` is ready, a maintainer opens the release pull request `develop → main`\n (skill `release-pr`) and merges it with a **merge commit**.\n3. On `main`, the `Release` workflow opens or updates the **Version Packages** pull request: it bumps\n versions and writes the changelogs.\n4. Merging **Version Packages** runs `changeset publish`: new versions go to npm with provenance, Git\n tags are pushed and a GitHub Release is created per package.\n5. The `Docs` workflow deploys the documentation site from `main`.\n\nPrereleases: run the `Release` workflow manually on `develop` (Actions → Release → Run workflow). It\npublishes a snapshot such as `0.2.0-next-20261110120000` with the dist-tag `next`:\n\n```bash\nnpm install @joralvmel/cosmos-react@next\n```\n\n## One-time setup (maintainers)\n\nThe skill `publish-setup` walks an agent through the same checklist.\n\n1. **npm account.** Create an account on [npmjs.com](https://www.npmjs.com/signup), verify the email\n and enable two-factor authentication (Account → Two-Factor Authentication, \"Authorization and\n writes\"). The scope `@joralvmel` is the account's user scope.\n\n2. **Check the packages.**\n\n ```bash\n npm ci\n npm run check-packs # builds, validates manifests and runs npm pack --dry-run\n npm run publish-order # dependencies first\n ```\n\n3. **First publication by hand.** Trusted publishing can only be configured for packages that exist.\n Publish the current version of every package once, in the order printed above:\n\n ```bash\n npm login\n cd packages/core && npm publish --access public --otp <code> && cd ../..\n # …repeat for each package in publish order\n ```\n\n The first version is a placeholder (`0.0.0`); you can mark it with\n `npm deprecate @joralvmel/cosmos-core@0.0.0 \"placeholder\"`.\n\n4. **Trusted publisher per package.** On npmjs.com open each package → Settings → Trusted Publisher →\n GitHub Actions and enter: owner `joralvmel`, repository `cosmos-ui`, workflow `release.yml`,\n environment `npm`. Then, under \"Publishing access\", choose\n \"Require two-factor authentication and disallow tokens\".\n\n5. **GitHub.** In the repository settings:\n - Environments → create `npm` (optionally with required reviewers).\n - Secrets and variables → Actions → Variables: `COSMOS_PUBLISH_ENABLED` = `true`.\n - For the docs site: Pages → Source \"GitHub Actions\" and the variable `COSMOS_DOCS_ENABLED` = `true`.\n\n6. **Verify** after the first automated release:\n\n ```bash\n npm view @joralvmel/cosmos-core versions dist-tags\n npm audit signatures # inside a project that installed the packages\n ```\n\n The package page on npmjs.com shows the provenance badge linking to the workflow run.\n\n## Troubleshooting\n\n| Symptom | Fix |\n| --- | --- |\n| `E404` / `ENEEDAUTH` on publish | The trusted publisher does not match: check owner, repository, workflow file name and environment. |\n| No \"Version Packages\" pull request | Allow GitHub Actions to create pull requests (`npm run setup-repo -- --apply` does it). |\n| Workflow skipped | `COSMOS_PUBLISH_ENABLED` is not `true`. |\n| `check-packs` fails | A manifest misses `publishConfig.access`, `files`, `exports`, `repository`, `license` or `llms.md`. |\n"},{"slug":"contribute/recipes","title":"Recipes","markdown":"# Recipes\n\n> Short guides to create a theme, add a token, build a component from Figma, change a component and create a chart.\n\nEach recipe names the skill that automates it (run it as a `/prompt` or ask its agent).\n\n## Create a theme — `add-theme`\n\n```bash\nnpm run generate -- theme aurora --seed \"oklch(0.58 0.14 165)\"\nnpx turbo run test build --filter=@joralvmel/cosmos-tokens...\n```\n\n1. Tune the definition in `packages/tokens/src/themes.ts`: seeds (OKLCH), `harmony`, neutral tint and\n `radius`. Add mode overrides only when unavoidable.\n2. The tokens tests check WCAG 2.2 AA and color vision deficiencies in light and dark. Never lower the\n thresholds; change the seeds instead.\n3. The theme appears in the theme gallery, the header picker, Tailwind (`theme-aurora:`) and\n `CosmosThemeProvider`.\n\n## Add a token — `add-token`\n\n1. Semantic color: add it to `semanticColors` (`packages/tokens/src/types.ts`), derive it in\n `generate.ts` and add contrast pairs in `validate.ts` when it carries text or UI.\n2. Base token (spacing, radius, motion…): add it to `base.ts`; map it in `toTailwindTheme` / `toNative`.\n3. Update the tokens and Tailwind tests, then `npm run llms`.\n\n## Component from Figma — `component-from-design`\n\n1. Share the Figma link of the frame (`?node-id=`) or a screenshot with the `design-system` agent.\n2. It extracts anatomy, variants and states and maps every value to existing tokens; a new token goes\n through `add-token`.\n3. `architect` writes the contract and `component-builder` runs `create-component`.\n\n## Change a component — `modify-component`\n\n1. `component-status` for the component and for any component it will use.\n2. Change the contract and scenarios first; decide the semver bump with `architect`.\n3. Update every platform, tests and docs; keep the anatomy (the structure test checks it).\n4. `npm run llms` and a changeset (`major` with a migration note when breaking).\n\n## Create a chart — `create-chart`\n\n```bash\nnpm run generate -- chart sparkline\n```\n\n1. Implement the pure layout in `packages/charts-core/src/sparkline-layout.ts` and test it without DOM.\n2. Render SVG in `packages/charts` and React Native in `packages/charts-native` with the same layout.\n3. Use theme chart colors (`--cosm-chart-1..8`), add a text description and a data table alternative.\n"},{"slug":"contribute/working-with-agents","title":"Working with agents","markdown":"# Working with agents\n\n> What each AI agent and skill of the repository does, how to use them in VS Code and what to ask.\n\nThe repository ships a team of specialized agents (`.github/agents/`) and step-by-step skills\n(`.github/skills/`, each with a prompt in `.github/prompts/`). They follow `AGENTS.md`, the rules in\n`.github/instructions/` and the [component anatomy](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-anatomy.md).\n\n## How to use them in VS Code\n\n1. Open the repository in VS Code with GitHub Copilot and open the **Chat** view.\n2. **Agents**: pick one in the agent selector of the chat (for example `component-builder`), then\n describe the task. The agent loads its rules and uses its skills.\n3. **Prompts**: type `/` and the skill name, e.g. `/create-component`, `/component-status`,\n `/start-work`. The prompt asks for its inputs and runs the skill with the right agent.\n4. Attach context with `#` (a file, a folder or a Figma link) when it helps.\n\nOther assistants (Codex, Claude Code, Cursor…) read `AGENTS.md`; point them to a skill file, e.g.\n\"follow `.github/skills/create-component/SKILL.md` for `switch`\".\n\n## Agents\n\n| Agent | What it does | Skills |\n| --- | --- | --- |\n| `ai-tooling` | Maintains the AI tooling for consumers: MCP server, `cosmos init-ai`, consumer instructions and drift tests of llms.md against contracts. | `update-ai-references` |\n| `angular-expert` | Angular specialist: standalone proxy components, ControlValueAccessors for form controls, signals and zoneless apps, Angular examples. | `modify-component` |\n| `architect` | Owns architecture and patterns: package boundaries, component contracts in core, ADRs, new dependencies, performance, public API and breaking changes. Use before adding a component, a package, a dependency or changing a public API. | `write-adr`, `define-contract`, `component-status`, `research-reference` |\n| `chart-builder` | Builds charts: pure layout in charts-core, SVG rendering as Web Components, interaction and accessibility, and coordinates native rendering with native-expert. | `create-chart` |\n| `component-builder` | Builds or extends Cosmos web components end-to-end with the generator: contract, Lit Web Component, form association, React and Angular wrappers, React Native stub, tests and docs pages. Use for any \"create/add/extend a component\" task. | `component-status`, `create-component`, `modify-component` |\n| `design-system` | Design and layout specialist with deep color theory and visual accessibility knowledge: themes, palettes, light/dark modes, typography, spacing, motion, component anatomy and states, responsive layout, Tailwind theme and translation of Figma designs into tokens. | `design-component`, `component-from-design`, `add-theme`, `add-token` |\n| `devops` | GitHub Actions, Turborepo caching, docs and demo deployments (GitHub Pages), Expo EAS, workflow security, SBOM and license reports. | `setup-ci`, `deploy-docs`, `publish-setup` |\n| `docs-writer` | Writes the English and Spanish documentation site, playgrounds, theme gallery, icon catalog, READMEs and the llms.md / llms.txt AI references. | `add-docs-page`, `add-playground` |\n| `github-ops` | Handles branches, commits, pull requests, issues, labels and GitHub releases. Verifies the collaborator identity (verify-identity) before any commit or push. | `verify-identity`, `start-work`, `commit`, `finish-work`, `sync-after-merge`, `open-pr` |\n| `native-expert` | React Native and Expo specialist: native components on the shared contracts and themes, gestures, mobile accessibility, native charts with charts-core and the Expo Router demo app. | `component-status`, `create-native-component`, `modify-component` |\n| `react-expert` | React specialist: React 19 custom elements and @lit/react wrappers, SSR/Next.js compatibility, React examples and the portfolio demo app. | `modify-component` |\n| `release-manager` | Owns Changesets, semantic versioning, changelogs, deprecations and npm publishing. | `add-changeset`, `release-pr`, `release`, `publish-setup` |\n| `researcher` | Read-only researcher: studies specifications (WAI-ARIA APG, HTML, Open UI) and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends using a dependency or implementing it in Cosmos. | `research-reference` |\n| `reviewer` | Read-only reviewer: conventions, contract parity across platforms, accessibility, security, blocked terms, third-party licenses and changesets. Use before merging. | — |\n| `test-engineer` | Test strategy owner: shared contract scenarios, drift tests, Playwright and axe accessibility checks, coverage and flaky tests. | `add-contract-tests` |\n\n## Skills\n\n| Skill (prompt) | Main agent | What it does |\n| --- | --- | --- |\n| `/add-changeset` | `release-manager` | Writes a Changesets release note for every publishable package changed in the branch. |\n| `/add-contract-tests` | `test-engineer` | Adds shared behavior scenarios to a contract and runs them on the web, React, Angular and React Native through drivers. |\n| `/add-docs-page` | `docs-writer` | Adds a documentation page in English and Spanish with Playground, examples per framework, API table and accessibility notes. |\n| `/add-playground` | `docs-writer` | Adds the interactive Playground to a component page: controls generated from the contract, code tabs for HTML, React, Angular and React Native, copy button, theme/mode pickers and the native demo link. |\n| `/add-theme` | `design-system` | Adds a theme with defineTheme (seeds, harmony, light/dark), validates contrast and color vision deficiencies, and shows it in the docs gallery and in React Native. |\n| `/add-token` | `design-system` | Adds a token to every output (CSS variables, Tailwind theme, React Native values, JSON) with tests. |\n| `/audit-a11y` | `test-engineer` | Audits accessibility on web and React Native: axe, keyboard, focus, screen readers, contrast and motion. |\n| `/commit` | `github-ops` | Creates a Conventional Commit on a work branch after verifying identity, running validation and the blocked-terms check. |\n| `/component-from-design` | `design-system` | Turns a Figma URL (via Figma MCP), screenshot or image into a contract, a visual spec mapped to Cosmos tokens and a generated component. |\n| `/component-status` | `architect` | Reports the component inventory (npm run status), explains gaps and proposes or creates the next components according to their dependencies. Run it before creating, modifying or composing components. |\n| `/create-chart` | `chart-builder` | Creates a chart: pure layout in charts-core, SVG rendering on the web, React Native rendering, accessibility and docs. |\n| `/create-component` | `component-builder` | Creates a new Cosmos component end-to-end following docs/conventions/component-anatomy.md: contract and scenarios, Lit Web Component, React and Angular wrappers, React Native component and demo, tests, docs pages (EN/ES), llms.md and changeset. |\n| `/create-native-component` | `native-expert` | Creates a React Native component on a contract, core logic and tokens, with shared scenarios, drift test, demo screen and docs, following the component anatomy. |\n| `/define-contract` | `architect` | Creates or updates a component contract (props, events, states, slots, parts, keyboard, ARIA) and its shared scenarios in core, with the DOM/React/Angular/React Native mapping. |\n| `/deploy-docs` | `devops` | Deploys the docs site (and demos) to GitHub Pages once enabled. |\n| `/design-component` | `design-system` | Writes the visual spec of a component: anatomy, sizes, variants, states, tokens used, responsive behavior and light/dark notes, then styles it with tokens only. |\n| `/finish-work` | `github-ops` | Finishes a task: validates, pushes the branch and opens a pull request to develop with the template filled, labels and reviewers; optionally requests a Copilot review. |\n| `/modify-component` | `component-builder` | Changes the API or behavior of an existing component while keeping parity and the anatomy: contract → Lit → wrappers → React Native → scenarios → docs → llms.md → changeset. |\n| `/open-pr` | `github-ops` | Opens a pull request for an existing pushed branch (develop for work branches, main only for release PRs). Prefer finish-work, which validates first. |\n| `/publish-setup` | `release-manager` | One-time checklist to start publishing to npm: npm account with 2FA, first manual publication in dependency order, trusted publishers, GitHub environment and variables, verification. |\n| `/release` | `release-manager` | Runs the release flow: release PR develop → main, the Changesets \"Version Packages\" PR, npm publish with provenance and GitHub Releases; also snapshot prereleases with the next dist-tag. |\n| `/release-pr` | `release-manager` | Opens the release pull request develop → main with the summary of pending changesets. |\n| `/research-reference` | `researcher` | Researches specifications and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends a dependency or an own implementation. |\n| `/setup-ci` | `devops` | Creates or updates GitHub Actions workflows (CI, identity, release, docs) following the workflow rules. |\n| `/start-work` | `github-ops` | Starts a task: syncs develop, creates a work branch with a normalized name and optionally links it to an issue. |\n| `/sync-after-merge` | `github-ops` | After a pull request is merged: returns to develop, pulls with prune and deletes the local work branch. |\n| `/sync-icons` | `component-builder` | Updates the Lucide version, regenerates the icon definitions and catalog, and refreshes the license notice. |\n| `/update-ai-references` | `ai-tooling` | Keeps every AI reference in sync with the code: llms.md blocks (npm run llms), docs .md pages, /llms.txt, /llms-full.txt, the MCP server data and tools, and cosmos init-ai. |\n| `/verify-identity` | `github-ops` | Checks the Git and GitHub identity before a commit or push. Enforces .local/git-identity.json when it exists; otherwise reports the current identity and asks for confirmation. |\n| `/write-adr` | `architect` | Writes an architecture decision record NNNN-title.md (context → decision → consequences). |\n\n## What to ask\n\n- **One task at a time**, with the outcome you expect: \"Create the `switch` component for all\n platforms\" rather than \"work on forms\".\n- **Give references**: an issue number, a Figma link, a pattern of the WAI-ARIA APG.\n- **Let them validate**: every skill ends with tests and `npx biome ci . && npx turbo run typecheck test\n build`; ask for the output when in doubt.\n- **Review before merging**: ask `reviewer` for a review of the branch.\n\n## Copyable prompts\n\n```text\n/component-status all — and tell me which three components I should build next and why.\n```\n\n```text\n/start-work feat elements switch, linked to issue #12\n```\n\n```text\nUse the component-builder agent: create the \"switch\" component (WAI-ARIA switch pattern) for web,\nReact, Angular and React Native, with controlled and uncontrolled `checked` state and a `cosm-change`\nevent. Follow the create-component skill and finish with the structure test.\n```\n\n```text\n/component-from-design https://www.figma.com/design/<file>?node-id=<node> as \"chip\"\n```\n\n```text\nUse the design-system agent: add a theme called \"aurora\" with a teal primary and a triadic harmony;\nit must pass the accessibility validation in light and dark.\n```\n\n```text\nUse the reviewer agent: review the current branch against develop and list only high-confidence\nproblems.\n```\n\n```text\n/finish-work \"feat(elements): add cosm-switch\" closes #12\n```\n"},{"slug":"getting-started/installation","title":"Installation","markdown":"# Installation\n\n> Install Cosmos UI for the web, React, Angular, React Native and Tailwind CSS.\n\nCosmos UI is not published yet. Once released, packages are installed from npm. Each framework has a\ncomplete guide: [React](../../guides/react-vite/), [Next.js](../../guides/nextjs/),\n[Angular](../../guides/angular/), [HTML / CDN](../../guides/html-cdn/),\n[React Native](../../guides/react-native/) and [Tailwind CSS](../../guides/tailwind/). To let an AI\nassistant do it, see [Use with AI](../../ai/overview/).\n\n**Web Components**\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button';\n```\n\n**React**\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n\nexport const Save = () => <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n```\n\n**Angular**\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save()\">Save</cosm-button>`,\n})\nexport class SaveComponent {\n save() {}\n}\n```\n\n**React Native**\n```bash\nnpm install @joralvmel/cosmos-native\n```\n\n```tsx\n\nexport default function App() {\n return (\n <CosmosThemeProvider theme=\"nebula\" mode=\"system\">\n <Button onPress={({ source }) => console.log(source)}>Save</Button>\n </CosmosThemeProvider>\n );\n}\n```\n\n## Theme and mode\n\nSet the theme and mode on any element (usually `<html>`). `data-mode=\"system\"` follows the operating\nsystem; without `data-mode` the light mode is used.\n\n```html\n<html data-theme=\"nebula\" data-mode=\"system\"></html>\n```\n\n## Tailwind CSS v4 (optional)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\nUtilities such as `bg-primary`, `text-fg-muted`, `rounded-md`, `dark:bg-surface` or\n`theme-nebula:text-accent` use the Cosmos tokens.\n"},{"slug":"getting-started/introduction","title":"Introduction","markdown":"# Introduction\n\n> What Cosmos UI is and how its packages fit together.\n\nCosmos UI is a design system that ships the same components to the web (Web Components, React,\nAngular) and to React Native. Each component is defined once as a **contract** in\n`@joralvmel/cosmos-core`; every platform implementation is tested against that contract and its shared\nbehavior scenarios.\n\n## Packages\n\n| Package | Purpose |\n| --- | --- |\n| `@joralvmel/cosmos-tokens` | Theme engine and design tokens (CSS variables, JSON, React Native values) |\n| `@joralvmel/cosmos-tailwind` | Tailwind CSS v4 theme mapped to the tokens |\n| `@joralvmel/cosmos-core` | Contracts, shared scenarios and headless logic |\n| `@joralvmel/cosmos-elements` | Web Components built with Lit |\n| `@joralvmel/cosmos-react` | React wrappers |\n| `@joralvmel/cosmos-angular` | Angular standalone components |\n| `@joralvmel/cosmos-native` | React Native components |\n\nCharts, icons, i18n, the MCP server and the CLI are in early development.\n\n## Principles\n\n- **Contracts first**: props, events, slots, keyboard support and ARIA roles are decided before code.\n- **Tokens only**: components are styled with `--cosm-*` variables, so every theme and mode works.\n- **Accessible by default**: WAI-ARIA patterns, visible focus, reduced motion and verified contrast.\n"},{"slug":"guides/angular","title":"Angular","markdown":"# Angular\n\n> Use Cosmos UI in Angular with standalone components, signals and forms.\n\n`@joralvmel/cosmos-angular` provides one standalone component per Web Component, with the same\nselector (`cosm-button`…). Inputs set element properties; outputs re-emit the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n**Load the tokens** (`angular.json`)\n\n```json\n\"styles\": [\"node_modules/@joralvmel/cosmos-tokens/dist/tokens.css\", \"src/styles.css\"]\n```\n\n**Choose theme and mode** (`src/index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Import components** (`src/app/app.component.ts`)\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\n\n@Component({\n selector: 'app-root',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save($event.detail.source)\">Save</cosm-button>`,\n})\nexport class AppComponent {\n save(source: string) {}\n}\n```\n\n- Components are standalone; import them individually or spread `COSMOS_COMPONENTS`.\n- Outputs re-emit the original CustomEvent: use `$event.detail`. Form controls provide ControlValueAccessors.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/angular/\n\n## Inputs, outputs and signals\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `\n <cosm-button [loading]=\"saving()\" variant=\"soft\" (press)=\"save()\">Save</cosm-button>\n `,\n})\nexport class SaveComponent {\n readonly saving = signal(false);\n\n save() {\n this.saving.set(true);\n }\n}\n```\n\n- Boolean inputs accept attributes (`loading`, `fullWidth`) and bindings (`[loading]=\"saving()\"`).\n- Outputs use the contract names: `(press)`, `(valueChange)`, `(openChange)`… Read `$event.detail`.\n- The components work in zoneless applications.\n\n## Forms\n\n`<cosm-button type=\"submit\">` submits the surrounding `<form>`. Form controls (text field, checkbox…)\nship `ControlValueAccessor`s so they work with `formControlName` and `[(ngModel)]` as they become\navailable (see the [component status](../../components/status/)).\n\n## All components at once\n\n```ts\n\n@Component({ imports: [...COSMOS_COMPONENTS], template: '…' })\nexport class Page {}\n```\n"},{"slug":"guides/html-cdn","title":"HTML and CDN","markdown":"# HTML and CDN\n\n> Use Cosmos UI Web Components in plain HTML, from a CDN or with any bundler.\n\nThe Web Components of `@joralvmel/cosmos-elements` work in any page: no framework needed.\n\n## Setup\n\n**Load tokens and components from a CDN** (`index.html`)\n\n```html\n<!doctype html>\n<html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\">\n <head>\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@joralvmel/cosmos-tokens/dist/tokens.css\" />\n <script type=\"module\" src=\"https://esm.sh/@joralvmel/cosmos-elements/button\"></script>\n </head>\n <body>\n <cosm-button variant=\"soft\">Save</cosm-button>\n <script type=\"module\">\n document.querySelector('cosm-button').addEventListener('cosm-press', event => {\n console.log(event.detail.source);\n });\n </script>\n </body>\n</html>\n```\n\n- With a bundler, `npm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens` and import `@joralvmel/cosmos-elements/<component>`.\n- DOM events are `cosm-*` CustomEvents that bubble and cross shadow roots.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/html-cdn/\n\n## With a bundler\n\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button'; // one import per component\n```\n\n## Properties, attributes and events\n\n- Styling props are attributes in kebab-case (`full-width`, `variant=\"soft\"`); every prop is also a\n JavaScript property (`button.fullWidth = true`).\n- Events are `cosm-*` `CustomEvent`s that bubble and cross shadow roots, so you can listen on a parent.\n- Theme hooks: `--cosm-<component>-*` custom properties and `::part()` selectors (see each component API).\n\n```html\n<form>\n <cosm-button type=\"submit\">Send</cosm-button>\n</form>\n<script type=\"module\">\n document.addEventListener('cosm-press', event => console.log(event.target, event.detail));\n</script>\n```\n\n## Switching theme and mode\n\n```html\n<script type=\"module\">\n setTheme('nebula');\n setMode('dark');\n</script>\n```\n"},{"slug":"guides/nextjs","title":"Next.js","markdown":"# Next.js\n\n> Use Cosmos UI with the Next.js App Router, Server and Client Components.\n\nCosmos components are Web Components wrapped for React. They work with the App Router as long as they\nare rendered from **Client Components**.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens and avoid a theme flash** (`app/layout.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport { themeInitScript } from '@joralvmel/cosmos-tokens/runtime';\nimport Script from 'next/script';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\" suppressHydrationWarning>\n <body>\n <Script id=\"cosmos-theme\" strategy=\"beforeInteractive\">\n {themeInitScript()}\n </Script>\n {children}\n </body>\n </html>\n );\n}\n```\n\n**Use components in Client Components** (`app/save-button.tsx`)\n\n```tsx\n'use client';\n\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function SaveButton() {\n return <Button onPress={() => console.log('saved')}>Save</Button>;\n}\n```\n\n- Cosmos components are Web Components: render them from Client Components (`'use client'`). Server Components can render the Client Component that wraps them.\n- The server HTML contains the custom element tag; it upgrades in the browser.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/nextjs/\n\n## Server and Client Components\n\n- The wrappers set element properties and listen to events in effects, so the file that imports\n `@joralvmel/cosmos-react` must start with `'use client'`.\n- Server Components can render those Client Components and pass serializable props (strings,\n numbers, booleans). Handlers stay inside the Client Component.\n- The server HTML contains the custom element tag and its text; the element upgrades in the browser.\n\n```tsx\n// app/page.tsx (Server Component)\n\nexport default function Page() {\n return <SaveButton />;\n}\n```\n\n## Avoiding a theme flash\n\n`themeInitScript()` returns a small, validated inline script that restores the theme and mode stored by\n`setTheme()` / `setMode()` before the first paint. Load it with `next/script` and\n`strategy=\"beforeInteractive\"` as shown above, and keep `suppressHydrationWarning` on `<html>` because\nthe script may change `data-theme` / `data-mode` before hydration.\n\n## Tailwind\n\nUse `@tailwindcss/postcss` with the [Cosmos Tailwind theme](../tailwind/).\n"},{"slug":"guides/react-native","title":"React Native and Expo","markdown":"# React Native and Expo\n\n> Use Cosmos UI components and themes in React Native apps with Expo.\n\n`@joralvmel/cosmos-native` implements the same component contracts with React Native primitives and\nuses the same themes as the web.\n\n## Setup\n\n```bash\nnpx expo install @joralvmel/cosmos-native\n```\n\n**Provide a theme** (`app/_layout.tsx`)\n\n```tsx\nimport { CosmosThemeProvider } from '@joralvmel/cosmos-native';\nimport { Stack } from 'expo-router';\n\nexport default function Layout() {\n return (\n <CosmosThemeProvider theme=\"cosmos\" mode=\"system\">\n <Stack />\n </CosmosThemeProvider>\n );\n}\n```\n\n**Use components** (`app/index.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport default function Home() {\n return <Button onPress={({ source }) => console.log(source)}>Save</Button>;\n}\n```\n\n- Callbacks receive the event detail directly (`onPress(detail)`).\n- `useTheme()` returns colors, spacing, radius and typography as numbers for your own styles.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-native/\n\n## Theme and mode\n\n`CosmosThemeProvider` accepts `theme` (`cosmos`, `nebula`…) and `mode` (`light`, `dark` or `system`,\nwhich follows the device appearance).\n\n## Your own styles with the theme\n\n```tsx\n\nexport function Card({ title }: { title: string }) {\n const theme = useTheme();\n return (\n <View style={{ backgroundColor: theme.colors.surface, borderRadius: theme.radius.lg, padding: theme.space.lg }}>\n <Text style={{ color: theme.colors.fg, fontSize: theme.text.lg }}>{title}</Text>\n </View>\n );\n}\n```\n\n## Accessibility\n\nComponents set `accessibilityRole`, `accessibilityState` and labels, and small controls extend their\ntouch area to 44 points. Test with TalkBack and VoiceOver.\n\n## Demo app\n\nThe repository includes an Expo Router app with a screen per component: see\n[Contribute → Getting started](../../contribute/getting-started/#native-demo).\n"},{"slug":"guides/react-vite","title":"React (Vite)","markdown":"# React (Vite)\n\n> Use Cosmos UI in a React 19 app built with Vite.\n\n`@joralvmel/cosmos-react` wraps the Cosmos Web Components for React 19. Props are set as element\nproperties and event props receive the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens once** (`src/main.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n```\n\n**Choose theme and mode** (`index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Use components** (`src/App.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport default function App() {\n return <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n}\n```\n\n- Event props (`onPress`, `onChange`…) receive the original CustomEvent: read `event.detail`.\n- Change theme and mode at runtime with `setTheme()` / `setMode()` from `@joralvmel/cosmos-tokens/runtime`.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-vite/\n\n## Events\n\nEvent props follow the contract names (`onPress`, `onChange`, `onOpenChange`…). Read the payload from\n`event.detail`; its type is exported by `@joralvmel/cosmos-core`.\n\n```tsx\n\nfunction Save() {\n const onPress = (event: CustomEvent<ButtonPressDetail>) => console.log(event.detail.source);\n return <Button onPress={onPress}>Save</Button>;\n}\n```\n\n## Controlled and uncontrolled state\n\nStateful components (value, open, selected tab…) work uncontrolled by default. Pass the state prop to\ncontrol it: the component then proposes changes through its event and waits for your new prop value\n([ADR 0003](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/adr/0003-state-ownership-and-events.md)).\n\n## Switching theme and mode\n\n```tsx\n\nsetTheme('nebula');\nsetMode('dark'); // 'light' | 'dark' | 'system'\n```\n\nThe choice is stored in `localStorage`. To restore it before the first paint, add the script returned\nby `themeInitScript()` to `<head>` (see the [Next.js guide](../nextjs/)).\n\n## Next steps\n\n- Style your own UI with tokens or the [Tailwind theme](../tailwind/).\n- Browse the [components](../../components/status/) and their playgrounds.\n"},{"slug":"guides/tailwind","title":"Tailwind CSS","markdown":"# Tailwind CSS\n\n> Style your app with Tailwind CSS v4 utilities mapped to Cosmos tokens and themes.\n\n`@joralvmel/cosmos-tailwind` turns the Cosmos tokens into a Tailwind CSS v4 theme. Every utility follows\nthe active theme and mode, and Cosmos components keep working without Tailwind.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-tailwind && npm install -D tailwindcss @tailwindcss/vite\n```\n\n**Import the Cosmos theme after Tailwind** (`src/styles.css`)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\n**Use token utilities**\n\n```html\n<div class=\"bg-surface text-fg rounded-lg shadow-md p-4 dark:bg-surface-raised\">\n <p class=\"text-fg-muted\">Uses Cosmos tokens in every theme and mode.</p>\n</div>\n```\n\n- Default Tailwind colors are disabled: use semantic colors (`bg-primary`, `text-danger-text`…).\n- `dark:` follows `data-mode` (including `system`); `theme-<name>:` targets one theme.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/tailwind/\n\nPlugins: Vite uses `@tailwindcss/vite`; Next.js and Angular use `@tailwindcss/postcss`.\n\n## Utilities\n\n| Group | Examples |\n| --- | --- |\n| Colors | `bg-bg`, `bg-surface`, `text-fg`, `text-fg-muted`, `bg-primary text-primary-fg`, `bg-danger-subtle text-danger-text`, `border-border`, `ring-focus-ring` |\n| Scales | `bg-primary-3`, `text-neutral-11` (steps 1–12) |\n| Spacing | `p-4` (= 4 × `--cosm-space-unit`), `gap-sm`, `px-lg` |\n| Shape | `rounded-sm` … `rounded-xl`, `rounded-full`, `shadow-sm` / `shadow-md` / `shadow-lg` |\n| Typography | `text-xs` … `text-4xl`, `font-semibold`, `leading-tight` |\n\nDefault Tailwind colors (`bg-blue-500`…) are disabled so only theme colors are used.\n\n## Variants\n\n- `dark:` applies in dark mode, including `data-mode=\"system\"` when the OS is dark.\n- `theme-<name>:` targets one theme, e.g. `theme-nebula:rounded-none`.\n"},{"slug":"","title":"Cosmos UI","markdown":"# Cosmos UI\n\n> Themeable design system with Web Components, React, Angular and React Native built from one contract per component.\n\n### Contracts first\n Every component starts as a typed contract: props, events, slots, keyboard and ARIA. Web, React,\n Angular and React Native implementations are tested against it.\n### Themes you can generate\n Pick seed colors and a harmony; Cosmos builds light and dark palettes in OKLCH and verifies WCAG\n contrast and color vision deficiencies.\n### Tailwind friendly\n Utilities like `bg-primary` or `rounded-md` map to Cosmos tokens through a Tailwind CSS v4 theme.\n### AI ready\n Machine-readable references (`llms.txt`) and an MCP server keep assistants aligned with the real API.\n"},{"slug":"theming/themes","title":"Themes","markdown":"# Themes\n\n> Built-in Cosmos themes in light and dark mode, with their accessibility report.\n\nEach theme is generated from seed colors and a color harmony with `defineTheme`. The engine builds\n12-step OKLCH scales, a dark mode with its own lightness curve, status colors that keep their meaning and\nan 8-color chart palette. Every theme is validated against WCAG 2.2 AA (normative), APCA (informative)\nand simulated protanopia, deuteranopia and tritanopia.\n\n- **Cosmos** (`data-theme=\"cosmos\"`), light and dark.\n- **Nebula** (`data-theme=\"nebula\"`), light and dark.\n\n## Create a theme\n\n```ts\n\nconst aurora = defineTheme({\n name: 'aurora',\n seeds: { primary: 'oklch(0.56 0.15 165)' },\n harmony: 'triadic',\n radius: 'pill',\n});\n\nconst resolved = resolveTheme(aurora);\nconsole.log(validateTheme(resolved).pass);\nconst css = toCss([resolved]);\n```\n\nTheme names cannot be `light`, `dark` or `system`; those are mode names.\n"}]
@@ -0,0 +1,104 @@
1
+ # @joralvmel/cosmos-angular
2
+
3
+ Angular standalone components for the Cosmos Web Components. Inputs map to element properties; outputs re-emit the original CustomEvent; form controls provide ControlValueAccessors.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Setup: Angular (standalone)
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens
11
+ ```
12
+
13
+ **Load the tokens** (`angular.json`)
14
+
15
+ ```json
16
+ "styles": ["node_modules/@joralvmel/cosmos-tokens/dist/tokens.css", "src/styles.css"]
17
+ ```
18
+
19
+ **Choose theme and mode** (`src/index.html`)
20
+
21
+ ```html
22
+ <html data-theme="cosmos" data-mode="system">
23
+ ```
24
+
25
+ **Import components** (`src/app/app.component.ts`)
26
+
27
+ ```ts
28
+ import { Component } from '@angular/core';
29
+ import { CosmButtonComponent } from '@joralvmel/cosmos-angular';
30
+
31
+ @Component({
32
+ selector: 'app-root',
33
+ imports: [CosmButtonComponent],
34
+ template: `<cosm-button (press)="save($event.detail.source)">Save</cosm-button>`,
35
+ })
36
+ export class AppComponent {
37
+ save(source: string) {}
38
+ }
39
+ ```
40
+
41
+ - Components are standalone; import them individually or spread `COSMOS_COMPONENTS`.
42
+ - Outputs re-emit the original CustomEvent: use `$event.detail`. Form controls provide ControlValueAccessors.
43
+
44
+ Guide: https://joralvmel.github.io/cosmos-ui/guides/angular/
45
+
46
+ ## Components
47
+
48
+ Every component of this package (status of planned ones: https://joralvmel.github.io/cosmos-ui/components/status/).
49
+
50
+ ### `CosmButtonComponent` (`<cosm-button>`)
51
+
52
+ Triggers an action or submits a form.
53
+
54
+ | Prop | Type | Default | Description |
55
+ | --- | --- | --- | --- |
56
+ | `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
57
+ | `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
58
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Control height and padding. |
59
+ | `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |
60
+ | `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |
61
+ | `fullWidth` | boolean | `false` | Stretches the button to the width of its container. |
62
+ | `type` | 'button' \| 'submit' \| 'reset' | `button` | Form behavior of the button. |
63
+ | `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |
64
+
65
+ Events: `(press)` → `ButtonPressDetail`.
66
+
67
+ ```ts
68
+ import { Component } from '@angular/core';
69
+ import { CosmButtonComponent } from '@joralvmel/cosmos-angular';
70
+ import type { ButtonPressDetail } from '@joralvmel/cosmos-core';
71
+
72
+ @Component({
73
+ selector: 'app-example',
74
+ imports: [CosmButtonComponent],
75
+ template: `<cosm-button (press)="onPress($event.detail)">Button</cosm-button>`,
76
+ })
77
+ export class ExampleComponent {
78
+ onPress(detail: ButtonPressDetail) {
79
+ console.log(detail);
80
+ }
81
+ }
82
+ ```
83
+
84
+ ## Themes
85
+
86
+ Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
87
+
88
+ ```html
89
+ <html data-theme="nebula" data-mode="system">
90
+ <!-- runtime: setTheme(name), setMode(mode) from @joralvmel/cosmos-tokens/runtime -->
91
+ ```
92
+
93
+ Custom themes: `defineTheme()` in `@joralvmel/cosmos-tokens` (https://joralvmel.github.io/cosmos-ui/theming/themes/).
94
+
95
+ ## Rules for AI assistants
96
+
97
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
98
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
99
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
100
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
101
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
102
+ - Import the standalone components from `@joralvmel/cosmos-angular` (`CosmButtonComponent`…); outputs emit the CustomEvent (`$event.detail`).
103
+
104
+ <!-- generated:end -->
@@ -0,0 +1,23 @@
1
+ # @joralvmel/cosmos-charts-core
2
+
3
+ Pure, DOM-free chart layout (scales, ticks, series colors) shared by web and native charts.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-charts-core
11
+ ```
12
+
13
+ Status: early development; the API may change. Component status: https://joralvmel.github.io/cosmos-ui/components/status/
14
+
15
+ ## Rules for AI assistants
16
+
17
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
18
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
19
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
20
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
21
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
22
+
23
+ <!-- generated:end -->
@@ -0,0 +1,23 @@
1
+ # @joralvmel/cosmos-charts-native
2
+
3
+ React Native charts (`react-native-svg`) built on the shared chart layout.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-charts-native
11
+ ```
12
+
13
+ Status: early development; the API may change. Component status: https://joralvmel.github.io/cosmos-ui/components/status/
14
+
15
+ ## Rules for AI assistants
16
+
17
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
18
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
19
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
20
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
21
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
22
+
23
+ <!-- generated:end -->
@@ -0,0 +1,23 @@
1
+ # @joralvmel/cosmos-charts
2
+
3
+ Chart Web Components (SVG + Lit) built on the shared chart layout.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-charts
11
+ ```
12
+
13
+ Status: early development; the API may change. Component status: https://joralvmel.github.io/cosmos-ui/components/status/
14
+
15
+ ## Rules for AI assistants
16
+
17
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
18
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
19
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
20
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
21
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
22
+
23
+ <!-- generated:end -->
@@ -0,0 +1,23 @@
1
+ # @joralvmel/cosmos-cli
2
+
3
+ Command line of Cosmos UI. `init-ai` prepares a consumer project for AI assistants.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Use
8
+
9
+ ```bash
10
+ npx @joralvmel/cosmos-cli init-ai --stack react # react | next | angular | html | react-native
11
+ ```
12
+
13
+ Writes a marked, regenerable block into `.github/copilot-instructions.md` and `AGENTS.md` (`--claude` adds `CLAUDE.md`) and registers the MCP server in `.vscode/mcp.json`.
14
+
15
+ ## Rules for AI assistants
16
+
17
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
18
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
19
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
20
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
21
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
22
+
23
+ <!-- generated:end -->
@@ -0,0 +1,77 @@
1
+ # @joralvmel/cosmos-core
2
+
3
+ Contracts (source of truth of every component on every platform), the component catalog, shared behavior scenarios, headless logic and helpers to generate code snippets and setup guides.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-core
11
+ ```
12
+
13
+ ## Contracts
14
+
15
+ Each contract is the source of truth of a component on every platform (`contracts.<name>`).
16
+
17
+ ### `button` (`<cosm-button>`)
18
+
19
+ Triggers an action or submits a form.
20
+
21
+ | Prop | Type | Default | Description |
22
+ | --- | --- | --- | --- |
23
+ | `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
24
+ | `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
25
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Control height and padding. |
26
+ | `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |
27
+ | `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |
28
+ | `fullWidth` | boolean | `false` | Stretches the button to the width of its container. |
29
+ | `type` | 'button' \| 'submit' \| 'reset' | `button` | Form behavior of the button. |
30
+ | `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |
31
+
32
+ **Events**
33
+
34
+ | DOM | React | Angular | React Native | Detail | Description |
35
+ | --- | --- | --- | --- | --- | --- |
36
+ | `cosm-press` | `onPress` | `(press)` | `onPress` | `ButtonPressDetail` | The button was activated by pointer, keyboard or programmatically. |
37
+
38
+ **Slots**
39
+
40
+ | Name | Description |
41
+ | --- | --- |
42
+ | `(default)` | Button label. |
43
+ | `start` | Content before the label, usually an icon. |
44
+ | `end` | Content after the label, usually an icon. |
45
+
46
+ **CSS parts**
47
+
48
+ | Name | Description |
49
+ | --- | --- |
50
+ | `base` | The native button element. |
51
+ | `label` | Wrapper of the label slot. |
52
+ | `spinner` | Loading indicator. |
53
+
54
+ **CSS custom properties**
55
+
56
+ | Name | Description |
57
+ | --- | --- |
58
+ | `--cosm-button-radius` | Corner radius. |
59
+ | `--cosm-button-gap` | Space between icon and label. |
60
+ | `--cosm-button-font-weight` | Label font weight. |
61
+
62
+ **Keyboard**
63
+
64
+ | Keys | Action |
65
+ | --- | --- |
66
+ | `Enter`, `Space` | Activates the button. |
67
+
68
+
69
+ ## Rules for AI assistants
70
+
71
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
72
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
73
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
74
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
75
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
76
+
77
+ <!-- generated:end -->
@@ -0,0 +1,86 @@
1
+ # @joralvmel/cosmos-elements
2
+
3
+ Framework-agnostic Web Components (Lit) of Cosmos UI. Use them in plain HTML or any framework; React and Angular users should prefer `@joralvmel/cosmos-react` / `@joralvmel/cosmos-angular`.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Setup: HTML / CDN
8
+
9
+ **Load tokens and components from a CDN** (`index.html`)
10
+
11
+ ```html
12
+ <!doctype html>
13
+ <html lang="en" data-theme="cosmos" data-mode="system">
14
+ <head>
15
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@joralvmel/cosmos-tokens/dist/tokens.css" />
16
+ <script type="module" src="https://esm.sh/@joralvmel/cosmos-elements/button"></script>
17
+ </head>
18
+ <body>
19
+ <cosm-button variant="soft">Save</cosm-button>
20
+ <script type="module">
21
+ document.querySelector('cosm-button').addEventListener('cosm-press', event => {
22
+ console.log(event.detail.source);
23
+ });
24
+ </script>
25
+ </body>
26
+ </html>
27
+ ```
28
+
29
+ - With a bundler, `npm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens` and import `@joralvmel/cosmos-elements/<component>`.
30
+ - DOM events are `cosm-*` CustomEvents that bubble and cross shadow roots.
31
+
32
+ Guide: https://joralvmel.github.io/cosmos-ui/guides/html-cdn/
33
+
34
+ ## Components
35
+
36
+ Every component of this package (status of planned ones: https://joralvmel.github.io/cosmos-ui/components/status/).
37
+
38
+ ### `<cosm-button>`
39
+
40
+ Triggers an action or submits a form.
41
+
42
+ | Prop | Type | Default | Description |
43
+ | --- | --- | --- | --- |
44
+ | `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
45
+ | `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
46
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Control height and padding. |
47
+ | `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |
48
+ | `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |
49
+ | `fullWidth` (`full-width`) | boolean | `false` | Stretches the button to the width of its container. |
50
+ | `type` | 'button' \| 'submit' \| 'reset' | `button` | Form behavior of the button. |
51
+ | `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |
52
+
53
+ Events: `cosm-press` → `ButtonPressDetail`.
54
+
55
+ ```html
56
+ <cosm-button>Button</cosm-button>
57
+
58
+ <script type="module">
59
+ import '@joralvmel/cosmos-elements/button';
60
+
61
+ const element = document.querySelector('cosm-button');
62
+ element.addEventListener('cosm-press', event => console.log(event.detail));
63
+ </script>
64
+ ```
65
+
66
+ ## Themes
67
+
68
+ Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
69
+
70
+ ```html
71
+ <html data-theme="nebula" data-mode="system">
72
+ <!-- runtime: setTheme(name), setMode(mode) from @joralvmel/cosmos-tokens/runtime -->
73
+ ```
74
+
75
+ Custom themes: `defineTheme()` in `@joralvmel/cosmos-tokens` (https://joralvmel.github.io/cosmos-ui/theming/themes/).
76
+
77
+ ## Rules for AI assistants
78
+
79
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
80
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
81
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
82
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
83
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
84
+ - Use `<cosm-*>` elements and listen to `cosm-*` DOM events; import each component from `@joralvmel/cosmos-elements/<name>`.
85
+
86
+ <!-- generated:end -->
@@ -0,0 +1,21 @@
1
+ # @joralvmel/cosmos-i18n
2
+
3
+ Message formatting with `{name}` arguments and `Intl` helpers: `createTranslator(locale, messages, fallback?)` → `{ t, number, date, list }`.
4
+
5
+ <!-- generated:start (npm run llms, do not edit this block by hand) -->
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @joralvmel/cosmos-i18n
11
+ ```
12
+
13
+ ## Rules for AI assistants
14
+
15
+ - Use Cosmos components before writing custom UI; check `list_components` / the component status page for what exists.
16
+ - Style with Cosmos tokens: `var(--cosm-*)` in CSS or the Tailwind theme utilities (`bg-primary`, `text-fg-muted`, `rounded-md`). Never hard-code colors.
17
+ - Set the theme and mode with `data-theme` and `data-mode` on the root element (or `CosmosThemeProvider` on React Native).
18
+ - Keep accessibility: give icon-only buttons a `label`, never rely on color alone, keep keyboard support.
19
+ - Never render untrusted HTML (`innerHTML`, `dangerouslySetInnerHTML`) and never build class names from user input.
20
+
21
+ <!-- generated:end -->