spec-layer 0.5.0 → 0.6.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.
Files changed (3) hide show
  1. package/README.md +100 -17
  2. package/dist/cli.js +1029 -276
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,9 +14,12 @@ After publishing a library from the plugin's Library screen, it shows a setup
14
14
  command. Run it once in your repository:
15
15
 
16
16
  ```bash
17
- npx spec-layer setup --id lib_... --key sl_...
17
+ npx spec-layer setup --id lib_... --key sl_... --platform web
18
18
  ```
19
19
 
20
+ `--platform` says what you build; without it, `setup` reads the repository
21
+ root and writes a token file only when it finds a web signal.
22
+
20
23
  That records the library id, stores the key in a gitignored
21
24
  `speclayer.local.json`, and writes `.speclayer/`. Every later command needs no
22
25
  flags at all:
@@ -55,15 +58,17 @@ also keeps `.speclayer/manifest.json` on one format: 0.1.0 wrote no
55
58
  versions have no such command, so the setup command the plugin copies fails
56
59
  against them. The Foundation landing under `tokens/` as Design Tokens Format
57
60
  Module 2025.10 files, rather than `ai/foundation.yaml`, needs 0.4.0 or later.
58
- `tools` and `skill` need 0.5.0 or later.
61
+ `tools` and `skill` need 0.5.0 or later. `components/` in place of
62
+ `ai/components/`, `path` in place of `aiPath` in the manifest, and the
63
+ `outputs` block need 0.6.0 or later.
59
64
 
60
65
  ## Commands
61
66
 
62
67
  | Command | What it does |
63
68
  |---|---|
64
- | `setup --id lib_... --key sl_... [--out DIR] [selection]` | Writes `speclayer.json`, stores the key in `speclayer.local.json`, then pulls. The command the plugin copies. |
65
- | `init --id lib_... [--out DIR] [selection]` | Writes `speclayer.json` so later commands need no flags. No key, no network. |
66
- | `pull [--id lib_...] [--key sl_...] [selection]` | Fetches the library and writes it into `DIR` (default `.speclayer`). |
69
+ | `setup --id lib_... --key sl_... [--out DIR] [--platform P]... [selection]` | Writes `speclayer.json`, stores the key in `speclayer.local.json`, then pulls. The command the plugin copies. |
70
+ | `init --id lib_... [--out DIR] [--platform P]... [selection]` | Writes `speclayer.json` so later commands need no flags. No key, no network. |
71
+ | `pull [--id lib_...] [--key sl_...] [--platform P]... [selection]` | Fetches the library and writes it into `DIR` (default `.speclayer`). |
67
72
  | `status [--id lib_...] [--key sl_...]` | Checks freshness without writing. Exits `2` when the local copy is behind. |
68
73
  | `list` | Lists every artifact in the last pull, with its file path or `not written`. |
69
74
  | `show foundation [--canonical]` | Prints the Foundation's DTCG document to stdout. |
@@ -141,7 +146,7 @@ carry no key and are meant to be committed with the rest of the repository.
141
146
  ## Pulling part of a library
142
147
 
143
148
  By default `pull` writes the Foundation and every documented component. When
144
- your repo implements only some of them, narrow what lands in `ai/`:
149
+ your repo implements only some of them, narrow what lands in `components/`:
145
150
 
146
151
  ```bash
147
152
  npx spec-layer pull --only foundation # tokens and styles, no components
@@ -172,7 +177,7 @@ That stores an `include` block in `speclayer.json`:
172
177
  Selection flags on `pull` replace the stored selection for that run; they are
173
178
  never merged with it.
174
179
 
175
- The selection only decides which `ai/` files are written. `bundle.json`
180
+ The selection only decides which `components/` files are written. `bundle.json`
176
181
  always holds the whole library, so `list` and `show` can answer for any
177
182
  artifact, written or not, and `status` compares one hash.
178
183
 
@@ -239,7 +244,7 @@ matter what the ignore rules say.
239
244
  ```text
240
245
  .speclayer/
241
246
  bundle.json the published bundle, verbatim
242
- manifest.json every artifact indexed by content hash and path, plus the selection
247
+ manifest.json every artifact indexed by content hash and path, plus the selection and outputs
243
248
  tokens/ the Foundation as Design Tokens Format Module 2025.10 files
244
249
  <collection>.<mode>.json one file per collection and mode, rooted at the collection name
245
250
  styles.typography.json text styles as typography composites (when present)
@@ -247,15 +252,21 @@ matter what the ignore rules say.
247
252
  resolver.json Design Tokens Resolver Module 2025.10: sets, modifiers, order
248
253
  spec-layer.meta.json Figma ids, scopes, code syntax, publication, keyed by DTCG path
249
254
  report.json what DTCG could not express, with reasons and stable ids
250
- ai/components/<name>.yaml one file per selected component
255
+ components/<name>.yaml one file per selected component
256
+ outputs/
257
+ web-css.map.json DTCG path -> CSS custom property, with where the name came from
258
+ web-css.report.json what the CSS file could not express
259
+ spec-layer/
260
+ tokens.css the web token file, written in place at outputs[].path
251
261
  ```
252
262
 
253
- Point your agent at `.speclayer/ai/` and `.speclayer/tokens/`. The component
254
- YAML is the same compact form the plugin's **Copy for AI** puts on your
255
- clipboard; `bundle.json` additionally holds the full canonical artifacts if
256
- you need them.
263
+ Point your agent at `.speclayer/components/` and `.speclayer/tokens/`, and
264
+ import the token file for your platform from where `outputs` puts it. The
265
+ component YAML is the same compact form the plugin's **Copy for AI** puts on
266
+ your clipboard; `bundle.json` additionally holds the full canonical artifacts
267
+ if you need them.
257
268
 
258
- In `manifest.json`, an artifact the selection left unwritten has `"aiPath":
269
+ In `manifest.json`, an artifact the selection left unwritten has `"path":
259
270
  null`. A manifest from CLI 0.1.0 has no `selection` field and means
260
271
  everything was written.
261
272
 
@@ -268,7 +279,8 @@ When nothing changed since the last pull with the same selection, `pull`
268
279
  prints `Already up to date` and writes nothing. Every republish stamps a new
269
280
  export id and time into the canonical artifacts, so `bundle.json` and
270
281
  `manifest.json` change on each republish even when the content did not. The
271
- `ai/` YAML files, the `tokens/` files, and the content hashes stay stable.
282
+ `components/` YAML files, the `tokens/` files, and the content hashes stay
283
+ stable.
272
284
 
273
285
  ## Configuring the token output
274
286
 
@@ -295,6 +307,77 @@ Point Style Dictionary at `.speclayer/tokens/` and load the files
295
307
  `resolver.json` names for the mode you are building. The metadata sidecar and
296
308
  the report are not token files; exclude them from token globs.
297
309
 
310
+ ## Token files for your code
311
+
312
+ `pull` also writes a file your build compiles, one per platform output. For
313
+ the web that is a CSS file of custom properties. The file is written only
314
+ when that pull writes the Foundation; with `--only components` it is left
315
+ exactly as it was, and `list` shows it as `not written`.
316
+
317
+ ```css
318
+ :root {
319
+ /* Foundation */
320
+ --foundation-colors-blue-500: #2e72d1;
321
+ --foundation-spacing-200: 8px;
322
+ /* Mapped Colors, Light */
323
+ --mapped-colors-surface-primary-default: var(--foundation-colors-blue-500);
324
+ }
325
+
326
+ [data-theme="dark"] {
327
+ /* Mapped Colors, Dark */
328
+ --mapped-colors-surface-primary-default: var(--foundation-colors-blue-900);
329
+ }
330
+ ```
331
+
332
+ Sets and every collection's default mode sit at `:root`; every other mode is
333
+ a block under `[data-theme="<mode>"]`. Aliases stay as `var()`. A number whose
334
+ Figma scopes state no unit stays a bare number. Nothing about a mode's name
335
+ selects a media query; wire `data-theme` to `prefers-color-scheme` yourself if
336
+ the OS should choose.
337
+
338
+ The file is written **in place** at the path in `speclayer.json`, outside the
339
+ managed directory, so your bundler keeps watching it and the diff shows up in
340
+ review. It begins with a header naming the library and the Foundation's
341
+ content hash, and `pull` refuses to overwrite a file at that path that lacks
342
+ the header.
343
+
344
+ ```json
345
+ {
346
+ "platforms": ["web"],
347
+ "outputs": [
348
+ { "platform": "web", "format": "css", "path": "spec-layer/tokens.css", "case": "kebab" }
349
+ ]
350
+ }
351
+ ```
352
+
353
+ `setup` and `init` write this block from `--platform`, or from what they detect
354
+ at the repository root, so the path is always on record. `pull` writes every
355
+ entry; `"outputs": []` writes none. `case` chooses how derived names are
356
+ spelled: `kebab` (default), `camel`, `pascal`, `snake`, or `constant`. A name
357
+ the designer declared as `code_syntax` in Figma is used verbatim and never
358
+ re-cased. `.speclayer/outputs/web-css.map.json` records every emitted name and
359
+ whether it was declared or derived; two tokens that would share a name are
360
+ both omitted and listed in `web-css.report.json`.
361
+
362
+ Two collections with modes share one attribute by default, which cannot be
363
+ right for both; the report says so, and `modes` declares a selector per
364
+ collection:
365
+
366
+ ```json
367
+ { "platform": "web", "format": "css", "path": "spec-layer/tokens.css",
368
+ "modes": { "Density": "[data-density=\"{mode}\"]" } }
369
+ ```
370
+
371
+ `root` and `modeSelector` override the defaults `:root` and
372
+ `[data-theme="{mode}"]`; `{mode}` and `{collection}` are replaced by slugs.
373
+ A repository that already builds tokens with Style Dictionary can keep reading
374
+ `tokens/`: the CSS file is a projection of the same files, not a second
375
+ source, so import one or the other.
376
+
377
+ Commit `.speclayer/`, `speclayer.json`, and the output paths. A repository
378
+ that would rather regenerate in CI ignores them and runs `pull` there;
379
+ `status` exits `2` when a pull is due.
380
+
298
381
  ## Exit codes
299
382
 
300
383
  | Code | Meaning |
@@ -308,5 +391,5 @@ the report are not token files; exclude them from token globs.
308
391
 
309
392
  ## Requirements
310
393
 
311
- Node 22 or newer. Publishing requires a Spec Layer Pro license; pulling does
312
- not.
394
+ Node 22 or newer. Publishing one Figma file is free; Pro publishes up to ten.
395
+ Pulling needs only the library id and pull key.