# The @sypnia/design package

> One npm package for reading tokens, running the check, serving the gallery and reading Design files.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://design.docs.sypnia.com/tools/sdk/

For agents: @sypnia/design subpaths: /tokens (readTokens(dir) → typed tokens with light/dark; token('color.accent') → CSS var name; for charts/canvas), /check (check({ root, renders?: 'local'|'cloud'|false }) → { findings[], errors, warnings }), /gallery (serveGallery({ port: 4520 })), /files (parse/validate the [design] table of sypnia.toml, gallery.yaml, screen files, rules.yaml against JSON Schemas), /client (createDesign({ token } | { baseUrl }) for the API: proposals, renders, exports). CLI npx @sypnia/design. ESM + types; Node 20+.

| Import                   | For                                                                                                       |
| ------------------------ | --------------------------------------------------------------------------------------------------------- |
| `@sypnia/design/tokens`  | reading your tokens in code (for charts, canvas, e-mails): `readTokens()`, `token('color.accent')`        |
| `@sypnia/design/check`   | running `design check` from your own scripts or tests                                                     |
| `@sypnia/design/gallery` | serving the gallery from your own dev server                                                              |
| `@sypnia/design/files`   | reading and validating the `[design]` table of `sypnia.toml`, `gallery.yaml`, screen files and icon rules |
| `@sypnia/design/client`  | the API: proposals, renders, exports **\[Cloud]** or your engine                                          |
| `npx @sypnia/design`     | [the CLI](https://design.docs.sypnia.com/tools/cli)                                                       |

```ts
import { readTokens, token } from '@sypnia/design/tokens';
const t = await readTokens();                 // reads design/tokens.json
t.color.accent.light;                         // "#E0A526"
token('color.accent');                        // "var(--espiga-color-accent)"
```

```ts
import { check } from '@sypnia/design/check';
const { errors, findings } = await check({ root: '.', renders: 'local' });
```

```ts
import { createDesign } from '@sypnia/design/client';
const design = createDesign({ token: process.env.SYPNIA_DESIGN_TOKEN! }); // or { baseUrl } for your engine
const p = await design.proposals.create({ project: 'la-espiga', kind: 'tokens', reason: 'Darker accent for the counter tablet', changes: { 'color.accent': '#C98E12' } });
```

The pieces themselves are not in this package: they are generated into your repository on top of `@sypnia/base`. ESM with types; Node 20 or later.
