spec-layer 0.1.0 → 0.2.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/README.md +77 -11
- package/dist/cli.js +1070 -77
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -28,42 +28,108 @@ npx spec-layer init --id lib_...
|
|
|
28
28
|
|
|
29
29
|
| Command | What it does |
|
|
30
30
|
|---|---|
|
|
31
|
-
| `init --id lib_... [--out DIR]` | Writes `speclayer.json` so later commands need no flags. |
|
|
32
|
-
| `pull [--id lib_...] [--key sl_...]` | Fetches the library and writes it into `DIR` (default `.speclayer`). |
|
|
31
|
+
| `init --id lib_... [--out DIR] [selection]` | Writes `speclayer.json` so later commands need no flags. |
|
|
32
|
+
| `pull [--id lib_...] [--key sl_...] [selection]` | Fetches the library and writes it into `DIR` (default `.speclayer`). |
|
|
33
33
|
| `status [--id lib_...] [--key sl_...]` | Checks freshness without writing. Exits `2` when the local copy is behind. |
|
|
34
|
+
| `list` | Lists every artifact in the last pull, with its file path or `not written`. |
|
|
35
|
+
| `show foundation [--canonical]` | Prints the Foundation's AI YAML to stdout. |
|
|
36
|
+
| `show component NAME [--canonical]` | Prints one component's AI YAML to stdout. |
|
|
34
37
|
|
|
35
38
|
`--api URL` overrides the API origin (default `https://api.spec-layer.com`).
|
|
36
39
|
|
|
40
|
+
## Pulling part of a library
|
|
41
|
+
|
|
42
|
+
By default `pull` writes the Foundation and every documented component. When
|
|
43
|
+
your repo implements only some of them, narrow what lands in `ai/`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx spec-layer pull --only foundation # tokens and styles, no components
|
|
47
|
+
npx spec-layer pull --only components # components, no foundation
|
|
48
|
+
npx spec-layer pull --component Button --component "Text field"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Names match by slug, so `button`, `Button`, and `icon-button` all find the
|
|
52
|
+
component they name. A name that matches nothing is an error listing what the
|
|
53
|
+
library holds, and nothing is written.
|
|
54
|
+
|
|
55
|
+
Record a selection once with `init` and plain `pull` reuses it:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx spec-layer init --id lib_... --component Button --component Card
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That stores an `include` block in `speclayer.json`:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"libraryId": "lib_...",
|
|
66
|
+
"outDir": ".speclayer",
|
|
67
|
+
"include": { "foundation": true, "components": ["Button", "Card"] }
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Selection flags on `pull` replace the stored selection for that run; they are
|
|
72
|
+
never merged with it.
|
|
73
|
+
|
|
74
|
+
The selection only decides which `ai/` files are written. `bundle.json`
|
|
75
|
+
always holds the whole library, so `list` and `show` can answer for any
|
|
76
|
+
artifact, written or not, and `status` compares one hash.
|
|
77
|
+
|
|
78
|
+
## Reading one artifact
|
|
79
|
+
|
|
80
|
+
`show` prints exactly one artifact and nothing else, so it pipes cleanly:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx spec-layer show component Button # the compact AI YAML
|
|
84
|
+
npx spec-layer show foundation --canonical # the canonical v5 JSON artifact
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Both read the last pull from disk and need no key. When two components share a
|
|
88
|
+
name, `show` refuses to guess and points you at `list`.
|
|
89
|
+
|
|
37
90
|
## The pull key
|
|
38
91
|
|
|
39
|
-
Every command reads the pull key from `SPEC_LAYER_KEY`
|
|
40
|
-
written to disk, and `speclayer.json` never contains
|
|
41
|
-
it grants read access to the published bundle. If it
|
|
42
|
-
plugin's Library screen
|
|
92
|
+
Every command that talks to the server reads the pull key from `SPEC_LAYER_KEY`
|
|
93
|
+
or `--key`. It is never written to disk, and `speclayer.json` never contains
|
|
94
|
+
it. Treat it as a secret: it grants read access to the published bundle. If it
|
|
95
|
+
leaks, rotate it from the plugin's Library screen. The old key stops working
|
|
96
|
+
once the change propagates, which can take up to about a minute.
|
|
43
97
|
|
|
44
98
|
## What `pull` writes
|
|
45
99
|
|
|
46
100
|
```text
|
|
47
101
|
.speclayer/
|
|
48
102
|
bundle.json the published bundle, verbatim
|
|
49
|
-
manifest.json every artifact indexed by content hash and ai path
|
|
50
|
-
ai/foundation.yaml tokens, styles, and modes (when the library has a Foundation)
|
|
51
|
-
ai/components/<name>.yaml one file per
|
|
103
|
+
manifest.json every artifact indexed by content hash and ai path, plus the selection
|
|
104
|
+
ai/foundation.yaml tokens, styles, and modes (when selected and the library has a Foundation)
|
|
105
|
+
ai/components/<name>.yaml one file per selected component
|
|
52
106
|
```
|
|
53
107
|
|
|
54
108
|
Point your agent at `.speclayer/ai/`. The YAML there is the same compact form
|
|
55
109
|
the plugin's **Copy for AI** puts on your clipboard; `bundle.json` additionally
|
|
56
110
|
holds the full canonical artifacts if you need them.
|
|
57
111
|
|
|
112
|
+
In `manifest.json`, an artifact the selection left unwritten has `"aiPath":
|
|
113
|
+
null`. A manifest from CLI 0.1.0 has no `selection` field and means
|
|
114
|
+
everything was written.
|
|
115
|
+
|
|
58
116
|
Writes stage into `.speclayer.partial` and rename into place, so an
|
|
59
|
-
interrupted pull never leaves a half-written directory.
|
|
117
|
+
interrupted pull never leaves a half-written directory. `pull` refuses an
|
|
118
|
+
output directory that is the current directory, a parent of it, or an existing
|
|
119
|
+
non-empty directory it did not write, since the swap replaces that directory.
|
|
120
|
+
|
|
121
|
+
When nothing changed since the last pull with the same selection, `pull`
|
|
122
|
+
prints `Already up to date` and writes nothing. Every republish stamps a new
|
|
123
|
+
export id and time into the canonical artifacts, so `bundle.json` and
|
|
124
|
+
`manifest.json` change on each republish even when the content did not. The
|
|
125
|
+
`ai/` YAML files and the content hashes stay stable.
|
|
60
126
|
|
|
61
127
|
## Exit codes
|
|
62
128
|
|
|
63
129
|
| Code | Meaning |
|
|
64
130
|
|---|---|
|
|
65
131
|
| `0` | Success, or `status` found the local copy up to date. |
|
|
66
|
-
| `1` | Usage error, bad key or id, or a network or server failure. |
|
|
132
|
+
| `1` | Usage error, bad key or id, unknown component name, or a network or server failure. |
|
|
67
133
|
| `2` | `status` only: the local copy is behind, or no local pull exists yet. |
|
|
68
134
|
|
|
69
135
|
`status` is safe in CI: it writes nothing, and exit `2` is the signal to run
|