@cagov/ca-ds 1.1.0 → 1.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.
Files changed (3) hide show
  1. package/README.md +39 -24
  2. package/ca-ds.js +129 -76
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -29,24 +29,39 @@ The package's version covers the `ca-ds` command: its commands, flags, `--json`
29
29
 
30
30
  ## Collections
31
31
 
32
- A collection is a folder of items with two root files. `ca-ds` finds it by walking up from the working folder to the nearest `collection.json`. A command that needs one exits with the usage code when there's none.
32
+ A collection is a folder of items with two root files: `ca-ds-config.json`, which you write, and `collection.lock.json`, which `ca-ds` writes. `ca-ds` finds it by walking up from the working folder to the nearest `ca-ds-config.json`. A command that needs one exits with the usage code when there's none.
33
33
 
34
- ### collection.json
34
+ ### ca-ds-config.json
35
35
 
36
- `collection.json` says what the collection asks for. `./src/schema/collection.schema.json` owns its shape. Its fields, each optional:
36
+ `ca-ds-config.json` says what the collection asks for. `./src/schema/ca-ds-config.schema.json` owns its shape. Its fields, each optional:
37
37
 
38
38
  - **`registry`**: the registry's base URL
39
39
  - **`namespaces`**: the namespaces the collection authors
40
40
  - **`release`**: a system release, such as `v0.1.0`, that `add` and `update` take their pins from
41
41
  - **`items`**: the items asked for, each with a semver range, such as `{ "standard/button": "^0.3.1" }`
42
- - **`presets`**: named subsets, each `{ "items": [...] }`, for `build --preset`
42
+ - **`presets`**: named subsets, each `{ "description": "...", "items": [...] }`, for `build --preset`
43
43
  - **`pages`**: globs of your own HTML pages, which `preview` serves
44
44
  - **`install`**: the folder `add` writes to, `items` by default. A skill installs to `skills` instead
45
45
  - **`skills`**: the folders an installed skill goes in, each relative to the collection, `[".agents/skills", ".claude/skills"]` by default. The first holds the skill's files, and each later one a link to them (§ *Skills*, under *add*)
46
46
  - **`dist`**: the folder `build` writes to, `dist` by default
47
+ - **`system`**: the system's own definition, which only the collection that authors `standard` holds (§ *The system*)
47
48
 
48
49
  `ca-ds init` writes one. A command that changes it rewrites it as two-space JSON.
49
50
 
51
+ ### The system
52
+
53
+ The collection that authors `standard` defines the system in `system`. No other collection sets it, since an installed set takes its foundation from the lock. Its fields:
54
+
55
+ - **`foundation`**: the items every component depends on without naming them, in load order. Required
56
+ - **`fixtures`**: the media collection whose members answer `/media/<slug>/<file>`
57
+ - **`release`**: the pinned set for a tag being cut, `{ "tag": "v0.2.0", "items": { "standard/button": "0.3.1" } }`. Without it no tag is pinned, and `pack --release` and `publish --release` take the tag from the command line
58
+
59
+ A collection with `system` also names three `presets`, `everything`, `foundation`, and `starter`, the sets a release builds as bundles. A preset leaves the foundation out, since every set starts with it.
60
+
61
+ ### The legacy files
62
+
63
+ `ca-ds` still reads a collection whose config is `collection.json`, and a system defined in a `system.json` beside it, and warns on each run. To move, rename `collection.json` to `ca-ds-config.json`. Then move `system.json`'s `foundation`, `fixtures`, and `release` under `system` and its `presets` to `presets`, and delete it. A folder that holds both config files reads `ca-ds-config.json` alone.
64
+
50
65
  ### collection.lock.json
51
66
 
52
67
  `collection.lock.json` records what resolved. `./src/schema/collection.lock.schema.json` owns its shape:
@@ -68,7 +83,7 @@ A collection is a folder of items with two root files. `ca-ds` finds it by walki
68
83
 
69
84
  - **`release`**: the release the items resolved against, or `null`
70
85
  - **`foundation`**: the items every build and validation loads first, in order. Absent, the collection has none
71
- - **`items`**: each installed item by scoped name, sorted by name. `requested` is true for an item `collection.json` asks for, and false for a dependency. `files` holds the SHA-256 of each file as installed, the baseline `diff` and `update` compare against. `path` is the item's folder, which for a skill sits in the first skills folder. `links`, on a skill alone, lists the links and copies the install made in the later skills folders
86
+ - **`items`**: each installed item by scoped name, sorted by name. `requested` is true for an item `ca-ds-config.json` asks for, and false for a dependency. `files` holds the SHA-256 of each file as installed, the baseline `diff` and `update` compare against. `path` is the item's folder, which for a skill sits in the first skills folder. `links`, on a skill alone, lists the links and copies the install made in the later skills folders
72
87
 
73
88
  A collection that installs nothing holds `{ "release": null, "items": {} }`.
74
89
 
@@ -85,14 +100,14 @@ An authored skill stays where you keep it. No command places it in the skills fo
85
100
 
86
101
  ### A bundle
87
102
 
88
- A bundle ZIP from the registry's `/bundles` page or `POST /api/bundles` is a collection. It unzips to `collection.json`, `collection.lock.json`, `items/<scope>/<name>/`, `dist/`, and a `README.md`, so every command runs in its folder.
103
+ A bundle ZIP from the registry's `/bundles` page or `POST /api/bundles` is a collection. It unzips to `ca-ds-config.json`, `collection.lock.json`, `items/<scope>/<name>/`, `dist/`, and a `README.md`, so every command runs in its folder.
89
104
 
90
105
  ## The registry and your token
91
106
 
92
107
  The commands that read the registry find it in this order:
93
108
 
94
109
  1. `CA_DS_URL`
95
- 2. `collection.json`'s `registry`
110
+ 2. `ca-ds-config.json`'s `registry`
96
111
  3. `https://v0.ds.innovation.ca.gov`
97
112
 
98
113
  They take a token in this order:
@@ -141,7 +156,7 @@ These commands run offline:
141
156
 
142
157
  | Command | Does |
143
158
  |---|---|
144
- | `init` | writes an empty `collection.json`, and with `--ci github` a workflow |
159
+ | `init` | writes an empty `ca-ds-config.json`, and with `--ci github` a workflow |
145
160
  | `new <kind> <scope>/<name>` | scaffolds an item folder that passes `validate` |
146
161
  | `add <name>[@range]...` | installs items and their dependencies |
147
162
  | `remove <name>...` | removes installed items, with `--prune` |
@@ -169,7 +184,7 @@ Every command takes `--json` and `--help`. An item argument names an item by its
169
184
  ca-ds init [--registry <url>] [--namespace <namespace> ...] [--ci github] [--branch <branch>]
170
185
  ```
171
186
 
172
- Writes `collection.json` in the working folder. Its `registry` is `--registry`, then `CA_DS_URL`, then the production host. Each `--namespace` adds one namespace the collection authors.
187
+ Writes `ca-ds-config.json` in the working folder. Its `registry` is `--registry`, then `CA_DS_URL`, then the production host. Each `--namespace` adds one namespace the collection authors.
173
188
 
174
189
  `--ci github` also writes `.github/workflows/ca-ds.yml`:
175
190
 
@@ -177,10 +192,10 @@ Writes `collection.json` in the working folder. Its `registry` is `--registry`,
177
192
  - on a push to `<branch>`, `ca-ds publish --summary` with the commit's subject, with the token from `CA_DS_TOKEN`
178
193
  - hourly on weekdays and by hand, `ca-ds pull`, committing what it writes straight to `<branch>`, which a protected branch refuses
179
194
 
180
- `--branch` names the branch, `main` by default. In a folder that already holds a `collection.json`, `--ci github` alone writes the workflow and keeps the file.
195
+ `--branch` names the branch, `main` by default. In a folder that already holds a `ca-ds-config.json`, `--ci github` alone writes the workflow and keeps the file.
181
196
 
182
197
  - **`--json`**: `{ collection, workflow }`, each a path, or `null` when it wasn't written
183
- - **Exit 3**: `collection.json` exists and `--ci` wasn't given alone, or the workflow file exists
198
+ - **Exit 3**: `ca-ds-config.json` exists and `--ci` wasn't given alone, or the workflow file exists
184
199
 
185
200
  ### new
186
201
 
@@ -200,7 +215,7 @@ Scaffolds an item folder that `validate` passes with zero rejections, its `item.
200
215
  Its answer and its refusals:
201
216
 
202
217
  - **`--json`**: `{ name, kind, dir, files }`, `files` the paths written inside `dir`
203
- - **Exit 2**: a scope `collection.json` doesn't author, a name the collection holds, a doc named `notes.md`, a folder that holds files, a skill name the frontmatter's rules refuse, or `--skill-name` with a kind other than `skill`
218
+ - **Exit 2**: a scope `ca-ds-config.json` doesn't author, a name the collection holds, a doc named `notes.md`, a folder that holds files, a skill name the frontmatter's rules refuse, or `--skill-name` with a kind other than `skill`
204
219
 
205
220
  ### add
206
221
 
@@ -210,11 +225,11 @@ ca-ds add <scope>/<name>[@<range>]... [--token <token>]
210
225
 
211
226
  Installs items and their dependencies, resolved through the registry's `POST /api/resolve`. Each item lands in `<install>/<scope>/<name>/` and in the lock. Each version comes from these rules:
212
227
 
213
- - with `collection.json`'s `release`, a `standard` item takes the release's pin
228
+ - with `ca-ds-config.json`'s `release`, a `standard` item takes the release's pin
214
229
  - any other item takes the highest version in its range, or its latest
215
230
  - an item already installed stays at its version. `update` moves it
216
231
 
217
- An item asked for joins `collection.json`'s `items`, with the range given, or with a caret range of its version, such as `^0.3.1`. A dependency is recorded as not asked for. The foundation installs with the first item. A skill installs as § *Skills* describes.
232
+ An item asked for joins `ca-ds-config.json`'s `items`, with the range given, or with a caret range of its version, such as `^0.3.1`. A dependency is recorded as not asked for. The foundation installs with the first item. A skill installs as § *Skills* describes.
218
233
 
219
234
  - **`--json`**: `{ release, added, requested, warnings }`, `added` as `[{ name, version, path, requested, links? }]`, `links` on a skill alone, `requested` as `[{ name, range, version }]`, and `warnings` as `[{ rule, name, message }]`
220
235
  - **Exit 1**: no live version satisfies a range, or a range misses the release's pin or the installed version
@@ -244,7 +259,7 @@ ca-ds remove <scope>/<name>... [--prune]
244
259
  ca-ds remove --prune
245
260
  ```
246
261
 
247
- Deletes installed items, their folders, and their lock entries, and drops them from `collection.json`'s `items`. A skill's recorded links and copies go too, even when its own folder was already deleted, and so does each folder they leave empty. `--prune` also deletes every dependency nothing asked for or authored still reaches. The foundation stays while anything else remains.
262
+ Deletes installed items, their folders, and their lock entries, and drops them from `ca-ds-config.json`'s `items`. A skill's recorded links and copies go too, even when its own folder was already deleted, and so does each folder they leave empty. `--prune` also deletes every dependency nothing asked for or authored still reaches. The foundation stays while anything else remains.
248
263
 
249
264
  - **`--json`**: `{ removed, warnings }`, `removed` as `[{ name, version, path, requested }]`, and `warnings` as `add`'s
250
265
  - **Exit 2**: a name that isn't installed, or a range
@@ -258,9 +273,9 @@ ca-ds update [<scope>/<name>...] [--dry-run] [--latest] [--token <token>]
258
273
 
259
274
  Moves installed items to newer versions. It merges each file three ways: the installed version is the base, your file is ours, and the new version is theirs. Where the items move:
260
275
 
261
- - **with `collection.json`'s `release`**: to the latest release, which `collection.json` then names. A `standard` item takes its pin. Names are refused, since a release moves the set together
276
+ - **with `ca-ds-config.json`'s `release`**: to the latest release, which `ca-ds-config.json` then names. A `standard` item takes its pin. Names are refused, since a release moves the set together
262
277
  - **with no release**: each item asked for to the highest version in its range, and each dependency to its latest
263
- - **with `--latest`**: every item to its latest version, and `collection.json` drops its `release`
278
+ - **with `--latest`**: every item to its latest version, and `ca-ds-config.json` drops its `release`
264
279
 
265
280
  With names, only the named items and their dependencies move. Under a release or `--latest`, a range the new version leaves becomes a caret range of the new version.
266
281
 
@@ -325,8 +340,8 @@ Turns an installed item into an authored one. `standard/card` becomes `<namespac
325
340
  - its manifest takes the new name, the version `0.1.0`, `forkedFrom: "standard/card@<version>"`, and a `source` naming its new folder
326
341
  - its folder moves to `<install>/<namespace>/card/`. A skill moves there too, out of the skills folders, and its links and copies go, since an authored skill is never placed in them
327
342
  - every dependency and related load of `standard/card` in the collection names the fork
328
- - it leaves the lock and `collection.json`'s `items`, so `update` never touches it again
329
- - `collection.json`'s `namespaces` gains the namespace
343
+ - it leaves the lock and `ca-ds-config.json`'s `items`, so `update` never touches it again
344
+ - `ca-ds-config.json`'s `namespaces` gains the namespace
330
345
 
331
346
  A collection that holds both the original and its fork fails `validate`.
332
347
 
@@ -348,7 +363,7 @@ Builds the collection into its `dist` folder:
348
363
  - `tokens.css`: the tokens alone
349
364
  - each file the CSS links, such as the fonts, at its path inside its item
350
365
 
351
- With no preset, it builds the `everything` preset when the collection defines one, and otherwise every item, the ones `collection.json` asks for first. `--preset` names a preset of `collection.json`, or else of `system.json`. A set with no tokens item builds with a warning. `build` doesn't clear the folder first.
366
+ With no preset, it builds the `everything` preset when the collection defines one, and otherwise every item, the ones `ca-ds-config.json` asks for first. `--preset` names a preset of `ca-ds-config.json`. A set with no tokens item builds with a warning. `build` doesn't clear the folder first.
352
367
 
353
368
  - **`--json`**: `{ dist, from, order, files, warnings }`. `dist` is the folder, `from` names the set, `order` is the load order, `files` lists every path written, and `warnings` is `[{ rule, message }]`
354
369
 
@@ -383,7 +398,7 @@ The run is offline first. Two checks need a `standard` item, and skip with a war
383
398
 
384
399
  The links check skips a link the same way when its target's item sits in a namespace the collection doesn't author and the collection lacks it, and its warning names the item in `needs`.
385
400
 
386
- When one skips and the collection names a registry, in `collection.json`'s `registry` or `CA_DS_URL`, the run goes online. It reads the registry's version for the handshake, fetches the latest copy of each missing item, and validates again. A link whose target's item the registry lacks too resolves to nothing then. A registry that refuses or doesn't answer within 20 seconds leaves the offline result, with a warning. `--offline` never reads the registry.
401
+ When one skips and the collection names a registry, in `ca-ds-config.json`'s `registry` or `CA_DS_URL`, the run goes online. It reads the registry's version for the handshake, fetches the latest copy of each missing item, and validates again. A link whose target's item the registry lacks too resolves to nothing then. A registry that refuses or doesn't answer within 20 seconds leaves the offline result, with a warning. `--offline` never reads the registry.
387
402
 
388
403
  When the collection names a registry, the run also reads the items the registry purged, through `GET /api/purges`, with the same timeout, before it validates. A page or a template that still links a purged media leaf, or still names it in `dependencies`, then warns `purged-media`, naming the leaf, as a publish's checks do. Without the read, once `pull` removes the leaf's folder, the link and the dependency each reject as ones to an item the registry never held. Remove the image and the dependency, then publish the page. A registry that refuses the read, or doesn't answer, skips it with a warning.
389
404
 
@@ -499,7 +514,7 @@ An item stops on any of these:
499
514
  A stopped item stops itself alone, and the run writes every other item. `--dry-run` reports the same and writes nothing.
500
515
 
501
516
  - **`--json`**: `{ registry, dryRun, current, items }`. `current` counts the current items, and `items` is `[{ name, from, to, versions, path, status, written, removed, files, reason? }]`, one for each item not current, sorted by name. `from` is `null` for an added item, `to` is `null` for a removed one, `versions` the registry's live versions past `from` up to `to`, or a removed item's purged versions, `path` the folder written, `written` the files whose bytes changed, `removed` the files deleted, and `files` each file a merge changed, as `{ path, outcome, conflicts?, reason?, keys? }`
502
- - **Exit 2**: a name, or a `collection.json` with no `namespaces`
517
+ - **Exit 2**: a name, or a `ca-ds-config.json` with no `namespaces`
503
518
  - **Exit 3**: a conflict or a stopped item
504
519
 
505
520
  ### login
@@ -558,7 +573,7 @@ Text output is for people, and `--json` is the contract. With `--json`:
558
573
  |---|---|---|
559
574
  | 0 | `ok` | the command did its work |
560
575
  | 1 | `rejected` | the collection fails a check, such as a validator rejection or a build its content breaks, and any failure no other code names |
561
- | 2 | `usage` | the command line is wrong, such as an unknown command or flag, a missing argument, or no `collection.json` at or above the folder |
576
+ | 2 | `usage` | the command line is wrong, such as an unknown command or flag, a missing argument, or no `ca-ds-config.json` at or above the folder |
562
577
  | 3 | `conflict` | a merge conflict, which leaves markers, or a hard stop, which leaves the files untouched |
563
578
  | 4 | `auth` | the registry refused the token, or there is none, or a browser sign-in was denied, failed its checks, or timed out |
564
579
  | 5 | `registry` | the registry can't be reached, answers with an error, or lacks an item asked for. A file whose hash doesn't match ends here too |
@@ -583,7 +598,7 @@ The previewer's routes:
583
598
  | `/` | the index: your pages first, then the templates, then every other item |
584
599
  | `/preview/item/<scope>/<name>/<file>` | an example or a check page in the preview shell |
585
600
  | `/frame/item/<scope>/<name>/<file>` | the same page's bare frame |
586
- | `/preview/page/<path>` and `/frame/page/<path>` | a page `collection.json`'s `pages` globs match |
601
+ | `/preview/page/<path>` and `/frame/page/<path>` | a page `ca-ds-config.json`'s `pages` globs match |
587
602
  | `/assets/tokens.css`, `/assets/bundle.css`, and `/assets/bundle.js` | the in-memory build, with source maps beside each |
588
603
  | `/media/<slug>/<file>` | a file of the media item in folder `<slug>` |
589
604
  | `/__preview__` | the previewer's identity: its name, collection, PID, port, and version |
package/ca-ds.js CHANGED
@@ -7891,7 +7891,7 @@ var init_system_schema = __esm({
7891
7891
  $schema: "https://json-schema.org/draft/2020-12/schema",
7892
7892
  $id: "system.schema.json",
7893
7893
  title: "system.json",
7894
- description: "What no single item owns: the foundation, the fixtures, the presets, and the release pin set.",
7894
+ description: "The legacy file ca-ds-config.json's system block and presets replace: the foundation, the fixtures, the presets, and the release pin set. The other schemas share its definitions.",
7895
7895
  type: "object",
7896
7896
  additionalProperties: false,
7897
7897
  required: ["foundation", "presets", "release"],
@@ -7965,15 +7965,15 @@ var init_system_schema = __esm({
7965
7965
  }
7966
7966
  });
7967
7967
 
7968
- // src/schema/collection.schema.json
7969
- var collection_schema_default;
7970
- var init_collection_schema = __esm({
7971
- "src/schema/collection.schema.json"() {
7972
- collection_schema_default = {
7968
+ // src/schema/ca-ds-config.schema.json
7969
+ var ca_ds_config_schema_default;
7970
+ var init_ca_ds_config_schema = __esm({
7971
+ "src/schema/ca-ds-config.schema.json"() {
7972
+ ca_ds_config_schema_default = {
7973
7973
  $schema: "https://json-schema.org/draft/2020-12/schema",
7974
- $id: "collection.schema.json",
7975
- title: "collection.json",
7976
- description: "What a collection asks for: the registry it reads, the namespaces it authors, and the items it installs. collection.lock.json records what resolved.",
7974
+ $id: "ca-ds-config.schema.json",
7975
+ title: "ca-ds-config.json",
7976
+ description: "A collection's one config file: the registry it reads, the namespaces it authors, the items it installs, and, in the collection that authors standard, the system's own definition. collection.lock.json records what resolved.",
7977
7977
  type: "object",
7978
7978
  additionalProperties: false,
7979
7979
  properties: {
@@ -8000,7 +8000,7 @@ var init_collection_schema = __esm({
8000
8000
  additionalProperties: { $ref: "item.schema.json#/$defs/range" }
8001
8001
  },
8002
8002
  presets: {
8003
- description: "Named subsets of the collection's items, for a build of one.",
8003
+ description: "Named subsets of the collection's items, for a build of one. In the collection that defines the system, the sets built as bundles, where the foundation is implied and not listed.",
8004
8004
  type: "object",
8005
8005
  propertyNames: { pattern: "^[a-z0-9]+(-[a-z0-9]+)*$" },
8006
8006
  additionalProperties: { $ref: "system.schema.json#/$defs/preset" }
@@ -8021,11 +8021,30 @@ var init_collection_schema = __esm({
8021
8021
  uniqueItems: true,
8022
8022
  items: { $ref: "item.schema.json#/$defs/path" }
8023
8023
  },
8024
+ system: {
8025
+ description: "What no single item owns, in the collection that authors standard alone: the foundation, the fixtures, and the release pin set. Its presets are the collection's presets.",
8026
+ type: "object",
8027
+ additionalProperties: false,
8028
+ required: ["foundation"],
8029
+ properties: {
8030
+ foundation: { $ref: "system.schema.json#/properties/foundation" },
8031
+ fixtures: { $ref: "system.schema.json#/properties/fixtures" },
8032
+ release: { $ref: "system.schema.json#/properties/release" }
8033
+ }
8034
+ },
8024
8035
  dist: {
8025
8036
  description: "The folder the build writes to. dist by default.",
8026
8037
  $ref: "item.schema.json#/$defs/path"
8027
8038
  }
8028
8039
  },
8040
+ if: { required: ["system"] },
8041
+ then: {
8042
+ required: ["namespaces", "presets"],
8043
+ properties: {
8044
+ namespaces: { type: "array", contains: { const: "standard" } },
8045
+ presets: { type: "object", required: ["everything", "foundation", "starter"] }
8046
+ }
8047
+ },
8029
8048
  $defs: {
8030
8049
  namespace: {
8031
8050
  description: "A scope, the part of a scoped name before the slash.",
@@ -8056,7 +8075,7 @@ var init_collection_lock_schema = __esm({
8056
8075
  oneOf: [{ type: "null" }, { $ref: "system.schema.json#/$defs/tag" }]
8057
8076
  },
8058
8077
  foundation: {
8059
- description: "The foundation the items resolved with, in load order, which leads a build's order and a validation's set when the collection has no system.json. Absent, the collection has none.",
8078
+ description: "The foundation the items resolved with, in load order, which leads a build's order and a validation's set when the collection defines no system. Absent, the collection has none.",
8060
8079
  type: "array",
8061
8080
  uniqueItems: true,
8062
8081
  items: { $ref: "system.schema.json#/$defs/scopedName" }
@@ -8080,7 +8099,7 @@ var init_collection_lock_schema = __esm({
8080
8099
  $ref: "item.schema.json#/$defs/path"
8081
8100
  },
8082
8101
  requested: {
8083
- description: "True for an item collection.json asks for, and false for one pulled in as a dependency.",
8102
+ description: "True for an item ca-ds-config.json asks for, and false for one pulled in as a dependency.",
8084
8103
  type: "boolean"
8085
8104
  },
8086
8105
  links: {
@@ -8777,7 +8796,7 @@ var init_schema = __esm({
8777
8796
  import__ = __toESM(require__(), 1);
8778
8797
  init_item_schema();
8779
8798
  init_system_schema();
8780
- init_collection_schema();
8799
+ init_ca_ds_config_schema();
8781
8800
  init_collection_lock_schema();
8782
8801
  init_release_schema();
8783
8802
  init_contract_schema();
@@ -8790,7 +8809,7 @@ var init_schema = __esm({
8790
8809
  ajv.addSchema(system_schema_default);
8791
8810
  validateItem = ajv.getSchema("item.schema.json");
8792
8811
  validateSystem = ajv.getSchema("system.schema.json");
8793
- validateCollection = ajv.compile(collection_schema_default);
8812
+ validateCollection = ajv.compile(ca_ds_config_schema_default);
8794
8813
  validateLock = ajv.compile(collection_lock_schema_default);
8795
8814
  validateReleaseManifest = ajv.compile(release_schema_default);
8796
8815
  validateContract = ajv.compile(contract_schema_default);
@@ -8814,7 +8833,7 @@ import { dirname, join as join2, resolve as resolvePath } from "node:path";
8814
8833
  function findCollection(start = process.cwd()) {
8815
8834
  let dir = resolvePath(start);
8816
8835
  for (; ; ) {
8817
- if (existsSync(join2(dir, COLLECTION))) return dir;
8836
+ if (configFile(dir)) return dir;
8818
8837
  const up = dirname(dir);
8819
8838
  if (up === dir) return null;
8820
8839
  dir = up;
@@ -8835,32 +8854,49 @@ function readRoot(root, file, check19) {
8835
8854
  }
8836
8855
  return data;
8837
8856
  }
8857
+ function systemAt(root, config) {
8858
+ const file = config === void 0 ? configFile(root) : null;
8859
+ const own = systemIn(file ? readJson(join2(root, file)) : config);
8860
+ if (own) return own;
8861
+ const legacy = join2(root, LEGACY_SYSTEM);
8862
+ return existsSync(legacy) ? readJson(legacy) : null;
8863
+ }
8864
+ function legacyFiles(root) {
8865
+ const config = configFile(root);
8866
+ const system = config && !systemIn(readJson(join2(root, config))) && existsSync(join2(root, LEGACY_SYSTEM));
8867
+ return [...config === LEGACY_CONFIG ? [LEGACY_CONFIG] : [], ...system ? [LEGACY_SYSTEM] : []];
8868
+ }
8838
8869
  function openCollection(root) {
8839
8870
  root = resolvePath(root);
8840
- const config = readRoot(root, COLLECTION, validateCollection);
8871
+ const file = configFile(root) ?? CONFIG;
8872
+ const config = readRoot(root, file, validateCollection);
8841
8873
  const lock = readRoot(root, LOCK, validateLock) ?? emptyLock();
8842
- const systemPath = join2(root, "system.json");
8843
- const system = existsSync(systemPath) ? JSON.parse(readFileSync2(systemPath, "utf8")) : null;
8874
+ const system = systemAt(root, config);
8844
8875
  const namespaces = new Set(config?.namespaces ?? []);
8845
8876
  const items2 = loadItems(root).map((entry) => ({
8846
8877
  ...entry,
8847
8878
  authored: config ? namespaces.has(scopeOf(entry.manifest?.name)) : null,
8848
8879
  installed: config ? Object.hasOwn(lock.items, entry.manifest?.name ?? "") : null
8849
8880
  }));
8850
- return { root, config, lock, system, items: items2 };
8881
+ return { root, file, config, lock, system, items: items2 };
8851
8882
  }
8852
- var COLLECTION, LOCK, emptyLock, DEFAULT_SKILLS, skillFolders, foundationOf, scopeOf;
8883
+ var CONFIG, LEGACY_CONFIG, LEGACY_SYSTEM, LOCK, emptyLock, DEFAULT_SKILLS, skillFolders, configFile, foundationOf, scopeOf, systemIn, readJson;
8853
8884
  var init_collection = __esm({
8854
8885
  "src/lib/collection.js"() {
8855
8886
  init_catalog();
8856
8887
  init_schema();
8857
- COLLECTION = "collection.json";
8888
+ CONFIG = "ca-ds-config.json";
8889
+ LEGACY_CONFIG = "collection.json";
8890
+ LEGACY_SYSTEM = "system.json";
8858
8891
  LOCK = "collection.lock.json";
8859
8892
  emptyLock = () => ({ release: null, items: {} });
8860
8893
  DEFAULT_SKILLS = [".agents/skills", ".claude/skills"];
8861
8894
  skillFolders = (config) => (config?.skills?.length ? config.skills : DEFAULT_SKILLS).map((f) => f.replace(/\/+$/, ""));
8895
+ configFile = (root) => [CONFIG, LEGACY_CONFIG].find((file) => existsSync(join2(root, file))) ?? null;
8862
8896
  foundationOf = (collection) => collection.system?.foundation ?? collection.lock?.foundation ?? [];
8863
8897
  scopeOf = (name) => typeof name === "string" && name.includes("/") ? name.slice(0, name.indexOf("/")) : null;
8898
+ systemIn = (config) => config?.system ? { ...config.system, presets: config.presets ?? {}, release: config.system.release ?? { tag: null, items: {} } } : null;
8899
+ readJson = (path) => JSON.parse(readFileSync2(path, "utf8"));
8864
8900
  }
8865
8901
  });
8866
8902
 
@@ -9325,7 +9361,7 @@ function distFolder(collection) {
9325
9361
  const dir = resolvePath2(collection.root, named2);
9326
9362
  const r = relative2(collection.root, dir);
9327
9363
  if (!r || r.startsWith("..") || isAbsolute(r)) {
9328
- throw Object.assign(new Error(`collection.json's dist, ${named2}, is not a folder inside the collection.`), { usage: true });
9364
+ throw Object.assign(new Error(`ca-ds-config.json's dist, ${named2}, is not a folder inside the collection.`), { usage: true });
9329
9365
  }
9330
9366
  return dir;
9331
9367
  }
@@ -9406,6 +9442,7 @@ var MEDIA_LINK, ITEM_MEDIA_LINK, DRAFT_MEDIA_LINK, MEDIA_PATHS, linkedMediaItems
9406
9442
  var init_fixtures = __esm({
9407
9443
  "src/lib/fixtures.js"() {
9408
9444
  init_catalog();
9445
+ init_collection();
9409
9446
  MEDIA_LINK = /^\/media\/([A-Za-z0-9_-]+)\/((?!\.+$)[A-Za-z0-9_.-]+)$/;
9410
9447
  ITEM_MEDIA_LINK = /^\/media\/([a-z0-9]+(?:-[a-z0-9]+)*)\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?!\.+$)[A-Za-z0-9_.-]+)$/;
9411
9448
  DRAFT_MEDIA_LINK = /^\/media\/~draft\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/((?!\.+$)[A-Za-z0-9_.~%-]+)$/;
@@ -24109,7 +24146,7 @@ var require_dist = __commonJS({
24109
24146
  var package_default;
24110
24147
  var init_package = __esm({
24111
24148
  "package.json"() {
24112
- package_default = { version: "1.1.0" };
24149
+ package_default = { version: "1.2.0" };
24113
24150
  }
24114
24151
  });
24115
24152
 
@@ -24729,7 +24766,7 @@ data: ${String(data).replace(/\n/g, "\\n")}
24729
24766
  if (watchers.size) return;
24730
24767
  readDist();
24731
24768
  const top = watch(root, (event, file) => {
24732
- if (String(file) === COLLECTION) readDist();
24769
+ if ([CONFIG, LEGACY_CONFIG].includes(String(file))) readDist();
24733
24770
  if (!file || skipped2(String(file))) return;
24734
24771
  watchFolder(String(file));
24735
24772
  changed();
@@ -38382,9 +38419,9 @@ async function run2(item, ctx, { reject }) {
38382
38419
  if (typeof name !== "string" || item.authored == null) return;
38383
38420
  const scope = name.includes("/") ? name.slice(0, name.indexOf("/")) : name;
38384
38421
  if (!item.authored && !item.installed) {
38385
- reject("neither", `\`${name}\` is neither authored nor installed: \`${scope}\` is none of ${COLLECTION}'s namespaces, and ${LOCK} doesn't record it.`, { file: "item.json" });
38422
+ reject("neither", `\`${name}\` is neither authored nor installed: \`${scope}\` is none of ${CONFIG}'s namespaces, and ${LOCK} doesn't record it.`, { file: "item.json" });
38386
38423
  } else if (item.authored && item.installed) {
38387
- reject("both", `\`${name}\` is both authored and installed: \`${scope}\` is one of ${COLLECTION}'s namespaces, and ${LOCK} records it too. An item is one or the other.`, { file: "item.json" });
38424
+ reject("both", `\`${name}\` is both authored and installed: \`${scope}\` is one of ${CONFIG}'s namespaces, and ${LOCK} records it too. An item is one or the other.`, { file: "item.json" });
38388
38425
  }
38389
38426
  const forkedFrom = item.manifest.forkedFrom;
38390
38427
  const original = typeof forkedFrom === "string" && forkedFrom.includes("@") ? forkedFrom.slice(0, forkedFrom.lastIndexOf("@")) : null;
@@ -43247,7 +43284,7 @@ async function run9(item, ctx, { reject, warn }) {
43247
43284
  for (const [url, { line, count }] of unlinked) {
43248
43285
  const times = count > 1 ? ` (${count} uses)` : "";
43249
43286
  const target = mediaTarget(url);
43250
- const message = target?.kind === "item" && ctx.purged?.has(target.name) ? `The link \`${url}\`${times} names a file of \`${target.name}\`, which the registry purged, so the image shows nothing. Remove the image, or place another.` : target?.kind === "item" ? `The link \`${url}\`${times} names a file of \`${target.name}\`, which \`dependencies\` leaves out, or which is no media leaf declaring that file. A published media leaf's link is \`/media/<scope>/<name>/<file>\`, where the item depends on the leaf and the leaf declares the file.` : target?.kind === "draft" ? `The link \`${url}\`${times} names a file uploaded to a draft, which only the draft's own views answer. A publish rewrites it to the path of the media leaf it publishes.` : ctx.fixtures === null ? `The link \`${url}\`${times} names no fixtures file, since system.json names no fixtures collection.` : `The link \`${url}\`${times} names no file of a member of \`${ctx.fixtures}\`, the fixtures collection. A /media/ link is \`/media/<folder>/<file>\`, where the member in that folder declares the file.`;
43287
+ const message = target?.kind === "item" && ctx.purged?.has(target.name) ? `The link \`${url}\`${times} names a file of \`${target.name}\`, which the registry purged, so the image shows nothing. Remove the image, or place another.` : target?.kind === "item" ? `The link \`${url}\`${times} names a file of \`${target.name}\`, which \`dependencies\` leaves out, or which is no media leaf declaring that file. A published media leaf's link is \`/media/<scope>/<name>/<file>\`, where the item depends on the leaf and the leaf declares the file.` : target?.kind === "draft" ? `The link \`${url}\`${times} names a file uploaded to a draft, which only the draft's own views answer. A publish rewrites it to the path of the media leaf it publishes.` : ctx.fixtures === null ? `The link \`${url}\`${times} names no fixtures file, since ca-ds-config.json's system names no fixtures collection.` : `The link \`${url}\`${times} names no file of a member of \`${ctx.fixtures}\`, the fixtures collection. A /media/ link is \`/media/<folder>/<file>\`, where the member in that folder declares the file.`;
43251
43288
  warn("media-link", message, { file: path, line });
43252
43289
  }
43253
43290
  }
@@ -44310,7 +44347,7 @@ import { readFileSync as readFileSync16 } from "node:fs";
44310
44347
  import { join as join17 } from "node:path";
44311
44348
  var check15 = "template";
44312
44349
  var POINTED = /* @__PURE__ */ new Set(["variants", "interface"]);
44313
- var readJson = (item, path) => JSON.parse(readFileSync16(join17(item.dir, path), "utf8"));
44350
+ var readJson2 = (item, path) => JSON.parse(readFileSync16(join17(item.dir, path), "utf8"));
44314
44351
  var readText2 = (member) => (path) => {
44315
44352
  if (!member.present.has(path)) return null;
44316
44353
  try {
@@ -44356,7 +44393,7 @@ function seeGap(ctx, item, see) {
44356
44393
  }
44357
44394
  let data;
44358
44395
  try {
44359
- data = readJson(holder.member, holder.file);
44396
+ data = readJson2(holder.member, holder.file);
44360
44397
  } catch {
44361
44398
  return `\`${path}\` doesn't parse.`;
44362
44399
  }
@@ -44384,7 +44421,7 @@ async function run15(item, ctx, { reject, warn }) {
44384
44421
  if (!entry || examples.length === 0) return;
44385
44422
  let composition;
44386
44423
  try {
44387
- composition = readJson(item, entry.path);
44424
+ composition = readJson2(item, entry.path);
44388
44425
  } catch {
44389
44426
  return;
44390
44427
  }
@@ -44975,7 +45012,7 @@ async function validateRelease(dir, { label: label2 = dir } = {}) {
44975
45012
  if (file.endsWith(".zip") && !listed.has(file)) reject("unlisted", `\`${file}\` is in the release folder and not in release.json.`, { file });
44976
45013
  }
44977
45014
  for (const name of [...release4.foundation, ...release4.fixtures ? [release4.fixtures] : [], ...Object.values(release4.presets).flatMap((p) => p.items)]) {
44978
- if (!names.has(name)) reject("unknown-item", `system.json names ${name}, which the release doesn't hold.`, { file: "release.json" });
45015
+ if (!names.has(name)) reject("unknown-item", `The release names ${name}, which the release doesn't hold.`, { file: "release.json" });
44979
45016
  }
44980
45017
  const root = mkdtempSync2(join21(tmpdir2(), "ca-release-"));
44981
45018
  try {
@@ -45176,9 +45213,9 @@ function saveRoots(collection, { config, lock }) {
45176
45213
  const items2 = Object.fromEntries(Object.entries(lock.items).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
45177
45214
  const sorted2 = { release: lock.release, ...lock.foundation ? { foundation: lock.foundation } : {}, items: items2 };
45178
45215
  if (config.items && Object.keys(config.items).length === 0) delete config.items;
45179
- if (!validateCollection(config)) throw new Error(`The new ${COLLECTION} fails its schema: ${failing(validateCollection)}.`);
45216
+ if (!validateCollection(config)) throw new Error(`The new ${collection.file ?? CONFIG} fails its schema: ${failing(validateCollection)}.`);
45180
45217
  if (!validateLock(sorted2)) throw new Error(`The new ${LOCK} fails its schema: ${failing(validateLock)}.`);
45181
- if (!isDeepStrictEqual2(config, collection.config)) write(join23(collection.root, COLLECTION), config);
45218
+ if (!isDeepStrictEqual2(config, collection.config)) write(join23(collection.root, collection.file ?? CONFIG), config);
45182
45219
  write(join23(collection.root, LOCK), sorted2);
45183
45220
  }
45184
45221
  function rootsOf(collection) {
@@ -45341,15 +45378,16 @@ var command2 = {
45341
45378
  };
45342
45379
 
45343
45380
  // src/cli/pack.js
45344
- import { existsSync as existsSync7, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "node:fs";
45381
+ import { existsSync as existsSync6, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "node:fs";
45345
45382
  import { join as join26, relative as relative5, resolve as resolvePath4, sep as sep4 } from "node:path";
45346
45383
 
45347
45384
  // src/lib/release.js
45348
45385
  var import_semver4 = __toESM(require_semver2(), 1);
45349
- import { existsSync as existsSync6, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync21, rmSync as rmSync5, writeFileSync as writeFileSync6 } from "node:fs";
45386
+ import { mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync21, rmSync as rmSync5, writeFileSync as writeFileSync6 } from "node:fs";
45350
45387
  import { join as join25 } from "node:path";
45351
45388
  init_schema();
45352
45389
  init_resolve();
45390
+ init_collection();
45353
45391
  async function packItem(item, ctx) {
45354
45392
  const result = await validate(item, ctx);
45355
45393
  if (result.rejections.length > 0) return { result, file: null, bytes: null, count: 0 };
@@ -45363,16 +45401,16 @@ function releaseTag(system, catalog, tag = null) {
45363
45401
  const problems = [...versions.keys()].filter((n) => !isSystemItem(n)).map((n) => `${n} is outside ${SYSTEM_NAMESPACE}, and only ${SYSTEM_NAMESPACE}'s items enter a release.`);
45364
45402
  const { tag: pinned, items: pins } = system.release;
45365
45403
  if (pinned) {
45366
- if (tag && tag !== pinned) problems.push(`system.json's release is ${pinned}, and --tag names ${tag}.`);
45404
+ if (tag && tag !== pinned) problems.push(`${CONFIG}'s system release is ${pinned}, and --tag names ${tag}.`);
45367
45405
  for (const [name, version] of versions) {
45368
- if (!(name in pins)) problems.push(`system.json's release doesn't pin ${name}.`);
45369
- else if (pins[name] !== version) problems.push(`system.json pins ${name} at ${pins[name]}, and the checkout holds ${version}.`);
45406
+ if (!(name in pins)) problems.push(`${CONFIG}'s system release doesn't pin ${name}.`);
45407
+ else if (pins[name] !== version) problems.push(`${CONFIG} pins ${name} at ${pins[name]}, and the checkout holds ${version}.`);
45370
45408
  }
45371
45409
  for (const name of Object.keys(pins)) {
45372
- if (!versions.has(name)) problems.push(`system.json pins ${name}, which the checkout doesn't hold.`);
45410
+ if (!versions.has(name)) problems.push(`${CONFIG} pins ${name}, which the checkout doesn't hold.`);
45373
45411
  }
45374
45412
  } else if (!tag) {
45375
- problems.push("system.json's release has no tag. Name one with --tag v<semver>.");
45413
+ problems.push(`${CONFIG}'s system release has no tag. Name one with --tag v<semver>.`);
45376
45414
  } else if (!tag.startsWith("v") || !import_semver4.default.valid(tag.slice(1)) || tag.includes("+")) {
45377
45415
  problems.push(`${tag} is not a release tag. A tag is v<semver>, as in v0.1.0.`);
45378
45416
  }
@@ -45396,8 +45434,8 @@ function publishOrder(catalog, foundation) {
45396
45434
  return resolve([...manifests.keys()].sort(), manifests, { foundation });
45397
45435
  }
45398
45436
  async function packRelease({ root, tag = null, out = null, system = null }) {
45399
- if (!system && !existsSync6(join25(root, "system.json"))) throw new ReleaseError("A release takes its tag and pins from system.json's release block, and the collection holds no system.json.");
45400
- system ??= JSON.parse(readFileSync21(join25(root, "system.json"), "utf8"));
45437
+ system ??= systemAt(root);
45438
+ if (!system) throw new ReleaseError(`A release takes its foundation, presets, and pins from ${CONFIG}'s system block, and the collection defines no system.`);
45401
45439
  const ctx = await loadContext(root);
45402
45440
  const members2 = new Map([...ctx.catalog].filter(([n]) => isSystemItem(n)));
45403
45441
  if (members2.size === 0) throw new ReleaseError(`The collection holds no ${SYSTEM_NAMESPACE} item, and only ${SYSTEM_NAMESPACE}'s items enter a release.`);
@@ -45491,7 +45529,7 @@ var command3 = {
45491
45529
  const ctx = await loadContext(c);
45492
45530
  const targets3 = positionals.length ? positionals.map((arg) => {
45493
45531
  const abs = argPath(c, arg);
45494
- if (!existsSync7(abs)) throw usageError(`${arg} is no item in the collection and no folder.`);
45532
+ if (!existsSync6(abs)) throw usageError(`${arg} is no item in the collection and no folder.`);
45495
45533
  return itemAt(ctx, abs, arg);
45496
45534
  }) : c.items.filter((i2) => i2.authored !== false).map((i2) => itemAt(ctx, join26(c.root, i2.dir)));
45497
45535
  const packed = [];
@@ -45515,7 +45553,7 @@ var command3 = {
45515
45553
 
45516
45554
  // src/cli/new.js
45517
45555
  var import_semver5 = __toESM(require_semver2(), 1);
45518
- import { existsSync as existsSync8, mkdirSync as mkdirSync8, readdirSync as readdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
45556
+ import { existsSync as existsSync7, mkdirSync as mkdirSync8, readdirSync as readdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
45519
45557
  import { dirname as dirname7, join as join27, relative as relative6, resolve as resolvePath5, sep as sep5 } from "node:path";
45520
45558
  var NAME5 = /^([a-z0-9]+(?:-[a-z0-9]+)*)\/([a-z0-9]+(?:-[a-z0-9]+)*)$/;
45521
45559
  var json = (data) => `${JSON.stringify(data, null, 2)}
@@ -45699,13 +45737,13 @@ function scaffold(collection, { kind, name, dir, title = null, skillName = null
45699
45737
  const [, scope, base] = match;
45700
45738
  if (!Object.hasOwn(KINDS, kind)) throw usageError(`${kind} is not a kind new scaffolds. The kinds are ${Object.keys(KINDS).join(", ")}.`);
45701
45739
  const namespaces = collection.config?.namespaces ?? [];
45702
- if (!namespaces.includes(scope)) throw usageError(`${scope} is not among the namespaces collection.json authors${namespaces.length ? `, ${namespaces.join(", ")}` : ""}. Add it there first.`);
45740
+ if (!namespaces.includes(scope)) throw usageError(`${scope} is not among the namespaces ca-ds-config.json authors${namespaces.length ? `, ${namespaces.join(", ")}` : ""}. Add it there first.`);
45703
45741
  if (itemNamed(collection, name)) throw usageError(`The collection already holds ${name}.`);
45704
45742
  if (base === "notes" && kind !== "media") throw usageError("A doc named notes.md is a folder's notes, which never ship. Pick another name.");
45705
45743
  if (skillName !== null && kind !== "skill") throw usageError("--skill-name names a skill, so it takes kind skill alone.");
45706
45744
  const source = relative6(collection.root, dir).split(sep5).join("/");
45707
45745
  if (!source || source.startsWith("..") || resolvePath5(collection.root, source) !== dir) throw usageError(`${dir} is not a folder inside the collection.`);
45708
- if (existsSync8(dir) && readdirSync7(dir).length) throw usageError(`${source} already exists and holds files.`);
45746
+ if (existsSync7(dir) && readdirSync7(dir).length) throw usageError(`${source} already exists and holds files.`);
45709
45747
  const shape = KINDS[kind]({ name, base, title: title ?? titleOf2(base), skillName }, collection);
45710
45748
  const { kind: k, description, ...rest } = shape.manifest;
45711
45749
  const manifest = { name, kind: k, version: "0.1.0", title: title ?? titleOf2(base), description, ...rest, source };
@@ -45765,7 +45803,7 @@ var command5 = {
45765
45803
 
45766
45804
  // src/cli/add.js
45767
45805
  var import_semver6 = __toESM(require_semver2(), 1);
45768
- import { existsSync as existsSync9, readdirSync as readdirSync8 } from "node:fs";
45806
+ import { existsSync as existsSync8, readdirSync as readdirSync8 } from "node:fs";
45769
45807
  import { join as join31 } from "node:path";
45770
45808
  var liveVersions = (record) => (record?.versions ?? []).filter((v) => !v.yankedAt).map((v) => v.version);
45771
45809
  async function highestIn(client, name, range) {
@@ -45804,9 +45842,9 @@ async function fetchFresh(collection, client, config, fresh, taken = installedSk
45804
45842
  path = skillPath(config, skillName);
45805
45843
  }
45806
45844
  const abs = join31(collection.root, path);
45807
- if (existsSync9(abs) && readdirSync8(abs).length) throw new CliError(`${path} already holds files, so ${name} can't install there. Move them, or set ${skill2 ? "skills" : "install"} in collection.json.`, EXIT.conflict);
45845
+ if (existsSync8(abs) && readdirSync8(abs).length) throw new CliError(`${path} already holds files, so ${name} can't install there. Move them, or set ${skill2 ? "skills" : "install"} in ca-ds-config.json.`, EXIT.conflict);
45808
45846
  const clash = skill2 ? linkClash(collection.root, config, path) : null;
45809
- if (clash) throw new CliError(`${clash} already holds a skill, so ${name} can't link it there. Move it, or set skills in collection.json.`, EXIT.conflict);
45847
+ if (clash) throw new CliError(`${clash} already holds a skill, so ${name} can't link it there. Move it, or set skills in ca-ds-config.json.`, EXIT.conflict);
45810
45848
  out.push({ name, version, path, files, baseline: baselineOf(record), skill: skill2, scripts: skill2 && shipsScripts(manifest.files ?? []) });
45811
45849
  }
45812
45850
  return out;
@@ -45942,7 +45980,7 @@ var command7 = {
45942
45980
 
45943
45981
  // src/cli/update.js
45944
45982
  var import_semver8 = __toESM(require_semver2(), 1);
45945
- import { existsSync as existsSync10, mkdirSync as mkdirSync9, readdirSync as readdirSync9, renameSync as renameSync2 } from "node:fs";
45983
+ import { existsSync as existsSync9, mkdirSync as mkdirSync9, readdirSync as readdirSync9, renameSync as renameSync2 } from "node:fs";
45946
45984
  import { basename as basename2, dirname as dirname8, join as join32 } from "node:path";
45947
45985
 
45948
45986
  // src/lib/merge.js
@@ -46404,7 +46442,7 @@ async function targets(collection, client) {
46404
46442
  let newest = null;
46405
46443
  if (release4) {
46406
46444
  newest = await client.release("latest");
46407
- if (!newest) throw new CliError(`collection.json names the release ${release4}, and the registry at ${client.url} records none.`, EXIT.registry);
46445
+ if (!newest) throw new CliError(`ca-ds-config.json names the release ${release4}, and the registry at ${client.url} records none.`, EXIT.registry);
46408
46446
  }
46409
46447
  const pins = new Map((newest?.items ?? []).map((e) => [e.name, e.version]));
46410
46448
  const out = [];
@@ -46446,7 +46484,7 @@ var command8 = {
46446
46484
  const items2 = client ? await targets(c, client) : { items: [], release: null };
46447
46485
  const listed = items2.items.filter((i2) => above(i2.wanted, i2.current) || above(i2.latest, i2.current));
46448
46486
  for (const i2 of listed) i2.changelog = await entriesBetween(client, i2.name, i2.current, [i2.wanted, i2.latest].filter(Boolean).sort(import_semver7.default.rcompare)[0]);
46449
- if (release4) io.log(`Against the latest release, ${items2.release.tag}. collection.json names ${release4}.`);
46487
+ if (release4) io.log(`Against the latest release, ${items2.release.tag}. ca-ds-config.json names ${release4}.`);
46450
46488
  if (!listed.length) io.log("Every installed item is current.");
46451
46489
  else {
46452
46490
  const rows = [["name", "current", "wanted", "latest"], ...listed.map((i2) => [i2.name, i2.current, i2.wanted ?? "-", i2.latest ?? "-"])];
@@ -46519,7 +46557,7 @@ function planMove(collection, config, name, entry, plan, taken) {
46519
46557
  const holder = taken.get(skillName);
46520
46558
  let clash = null;
46521
46559
  if (holder) clash = `${holder} already installs as the skill ${skillName}`;
46522
- else if (existsSync10(abs) && readdirSync9(abs).length) clash = `${to} already holds files`;
46560
+ else if (existsSync9(abs) && readdirSync9(abs).length) clash = `${to} already holds files`;
46523
46561
  else if (link) clash = `${link} already holds a skill`;
46524
46562
  if (clash) {
46525
46563
  plan.status = "stopped";
@@ -46542,12 +46580,12 @@ var command9 = {
46542
46580
  const latest = values.latest === true;
46543
46581
  const names = positionals.map((arg) => {
46544
46582
  const { name, range } = parseSpec(arg);
46545
- if (range !== null) throw usageError(`update takes a name, with no range: ${name}. Set a range in collection.json's items.`);
46583
+ if (range !== null) throw usageError(`update takes a name, with no range: ${name}. Set a range in ca-ds-config.json's items.`);
46546
46584
  if (!lock.items[name]) throw usageError(`${name} is not installed.`);
46547
46585
  return name;
46548
46586
  });
46549
46587
  const from = config.release ?? null;
46550
- if (from && !latest && names.length) throw usageError(`collection.json names the release ${from}, and a release moves every item together. Drop the names, or pass --latest.`);
46588
+ if (from && !latest && names.length) throw usageError(`ca-ds-config.json names the release ${from}, and a release moves every item together. Drop the names, or pass --latest.`);
46551
46589
  if (!Object.keys(lock.items).length) {
46552
46590
  io.log("Nothing is installed.");
46553
46591
  return { result: { dryRun, release: null, items: [], ranges: [] } };
@@ -46556,7 +46594,7 @@ var command9 = {
46556
46594
  let release4 = null;
46557
46595
  if (from && !latest) {
46558
46596
  const newest = await client.release("latest");
46559
- if (!newest) throw new CliError(`collection.json names the release ${from}, and the registry at ${client.url} records none.`, EXIT.registry);
46597
+ if (!newest) throw new CliError(`ca-ds-config.json names the release ${from}, and the registry at ${client.url} records none.`, EXIT.registry);
46560
46598
  release4 = newest.tag;
46561
46599
  }
46562
46600
  const free = names.length ? moving(c, names) : new Set(Object.keys(lock.items));
@@ -46643,9 +46681,9 @@ var command9 = {
46643
46681
  }
46644
46682
  for (const i2 of items2) if (i2.moved) io.log(`moved ${i2.name} from ${i2.moved.from} to ${i2.moved.to}, the folder its new skill name takes`);
46645
46683
  for (const w of warnings) io.warn(`warning: ${w.message}`);
46646
- for (const r of ranges) io.log(`range ${r.name} ${r.from} to ${r.to} in collection.json`);
46684
+ for (const r of ranges) io.log(`range ${r.name} ${r.from} to ${r.to} in ca-ds-config.json`);
46647
46685
  if (release4 && release4 !== from) io.log(`release ${from} to ${release4}`);
46648
- if (latest && from) io.log(`release ${from} dropped from collection.json`);
46686
+ if (latest && from) io.log(`release ${from} dropped from ca-ds-config.json`);
46649
46687
  const conflicted = items2.some((i2) => i2.status === "conflict");
46650
46688
  if (conflicted) io.warn(`A file with conflict markers ${verb} left to resolve. ca-ds validate rejects it until the markers are gone.`);
46651
46689
  if (stopped) io.warn(`A stopped item ${verb} left at its version, untouched. Settle the changes it names, then run ca-ds update again.`);
@@ -47211,7 +47249,7 @@ var command10 = {
47211
47249
  };
47212
47250
 
47213
47251
  // src/cli/eject.js
47214
- import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync22, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "node:fs";
47252
+ import { existsSync as existsSync10, mkdirSync as mkdirSync10, readFileSync as readFileSync22, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "node:fs";
47215
47253
  import { dirname as dirname9, join as join34 } from "node:path";
47216
47254
  import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
47217
47255
  var NAMESPACE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
@@ -47262,7 +47300,7 @@ var command11 = {
47262
47300
  if (c.items.some((i2) => i2.manifest.name === fork)) throw new CliError(`The collection already holds ${fork}.`, EXIT.conflict);
47263
47301
  const path = installPath(config, fork);
47264
47302
  const target = join34(c.root, path);
47265
- if (existsSync11(target)) throw new CliError(`${path} already exists, so ${name} can't move there.`, EXIT.conflict);
47303
+ if (existsSync10(target)) throw new CliError(`${path} already exists, so ${name} can't move there.`, EXIT.conflict);
47266
47304
  const source = join34(c.root, entry.path);
47267
47305
  const file = join34(source, "item.json");
47268
47306
  const text3 = readFileSync22(file, "utf8");
@@ -47303,14 +47341,14 @@ $1"forkedFrom"$2"${forkedFrom}"`],
47303
47341
  const rewritten = edits.map((e) => e.name).sort();
47304
47342
  io.log(`ejected ${forkedFrom} as ${fork} ${VERSION2} at ${path}`);
47305
47343
  for (const r of rewritten) io.log(`rewrote ${r}'s item.json to name ${fork}`);
47306
- if (namespaceAdded) io.log(`namespace ${ns} added to collection.json`);
47344
+ if (namespaceAdded) io.log(`namespace ${ns} added to ca-ds-config.json`);
47307
47345
  for (const w of warnings) io.warn(`warning: ${w.message}`);
47308
47346
  return { result: { from: forkedFrom, name: fork, version: VERSION2, path, rewritten, namespaceAdded, warnings } };
47309
47347
  }
47310
47348
  };
47311
47349
 
47312
47350
  // src/cli/publish.js
47313
- import { existsSync as existsSync12 } from "node:fs";
47351
+ import { existsSync as existsSync11 } from "node:fs";
47314
47352
  import { join as join35, relative as relative10, resolve as resolvePath6, sep as sep9 } from "node:path";
47315
47353
  import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
47316
47354
  init_version();
@@ -47474,7 +47512,7 @@ async function notCurrent(c, client) {
47474
47512
  }
47475
47513
  async function release3(c, client, values, io, shook) {
47476
47514
  if (!(c.config.namespaces ?? []).includes(SYSTEM_NAMESPACE)) {
47477
- throw usageError(`Only the ${SYSTEM_NAMESPACE} namespace records releases, and collection.json doesn't author it.`);
47515
+ throw usageError(`Only the ${SYSTEM_NAMESPACE} namespace records releases, and ca-ds-config.json doesn't author it.`);
47478
47516
  }
47479
47517
  const tag = values.release;
47480
47518
  const out = { registry: client.url, handshake: shook, tag, dir: null, published: [], existing: [], release: null, warmed: [], rejected: [], behind: [] };
@@ -47484,7 +47522,7 @@ async function release3(c, client, values, io, shook) {
47484
47522
  try {
47485
47523
  if (values.from !== void 0) {
47486
47524
  dir = resolvePath6(values.from);
47487
- if (!existsSync12(dir)) throw usageError(`${values.from} is no folder.`);
47525
+ if (!existsSync11(dir)) throw usageError(`${values.from} is no folder.`);
47488
47526
  } else {
47489
47527
  out.behind = await notCurrent(c, client);
47490
47528
  if (out.behind.length) {
@@ -47578,7 +47616,7 @@ var command12 = {
47578
47616
  // src/cli/pull.js
47579
47617
  var import_semver9 = __toESM(require_semver2(), 1);
47580
47618
  init_catalog();
47581
- import { existsSync as existsSync13, readFileSync as readFileSync23 } from "node:fs";
47619
+ import { existsSync as existsSync12, readFileSync as readFileSync23 } from "node:fs";
47582
47620
  import { join as join36 } from "node:path";
47583
47621
  import { isDeepStrictEqual as isDeepStrictEqual8 } from "node:util";
47584
47622
  var sorted = (list) => [...list].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
@@ -47666,7 +47704,7 @@ async function planOf(collection, client, hit, mine) {
47666
47704
  if (nest) return stop(nest);
47667
47705
  const abs = join36(collection.root, source);
47668
47706
  if (!mine) {
47669
- const taken = shipped.filter((p) => existsSync13(join36(abs, p)));
47707
+ const taken = shipped.filter((p) => existsSync12(join36(abs, p)));
47670
47708
  if (taken.length) return stop(`files already sit where it would be written, at \`${source}\`: ${taken.join(", ")}`);
47671
47709
  const { files } = await client.files(name, hit.version);
47672
47710
  return { ...out, written: sorted(files.keys()), write: files, remove: [] };
@@ -47678,7 +47716,7 @@ async function planOf(collection, client, hit, mine) {
47678
47716
  const { files } = await client.files(name, hit.version);
47679
47717
  const next = new Set(shipped);
47680
47718
  const removed = sorted(baseRecord.files.map((f) => f.path).filter((p) => !next.has(p)));
47681
- const changed = new Map([...files].filter(([path, bytes]) => !existsSync13(join36(abs, path)) || !Buffer.from(bytes).equals(readFileSync23(join36(abs, path)))));
47719
+ const changed = new Map([...files].filter(([path, bytes]) => !existsSync12(join36(abs, path)) || !Buffer.from(bytes).equals(readFileSync23(join36(abs, path)))));
47682
47720
  return { ...out, written: sorted(changed.keys()), removed, write: changed, remove: removed };
47683
47721
  }
47684
47722
  const merged = await mergeLocal(client, name, { from, to: hit.version, baseRecord, record, local });
@@ -47710,7 +47748,7 @@ var command13 = {
47710
47748
  if (positionals.length) throw usageError("pull reads every authored item. Name none.");
47711
47749
  const c = collection();
47712
47750
  const namespaces = c.config?.namespaces ?? [];
47713
- if (namespaces.length === 0) throw usageError("collection.json's namespaces names none, so the collection authors no item to pull.");
47751
+ if (namespaces.length === 0) throw usageError("ca-ds-config.json's namespaces names none, so the collection authors no item to pull.");
47714
47752
  const dryRun = values["dry-run"] === true;
47715
47753
  const client = connect(c, { values, env, fetch: fetch2 });
47716
47754
  const local = new Map(c.items.filter((i2) => i2.manifest && i2.authored).map((i2) => [i2.manifest.name, i2]));
@@ -47808,7 +47846,7 @@ var command14 = {
47808
47846
 
47809
47847
  // src/cli/init.js
47810
47848
  init_collection();
47811
- import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "node:fs";
47849
+ import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "node:fs";
47812
47850
  import { join as join38 } from "node:path";
47813
47851
  init_schema();
47814
47852
  init_version();
@@ -47908,7 +47946,7 @@ jobs:
47908
47946
  }
47909
47947
  var command15 = {
47910
47948
  synopsis: "init",
47911
- summary: "write an empty collection.json, and with --ci github a workflow",
47949
+ summary: `write an empty ${CONFIG}, and with --ci github a workflow`,
47912
47950
  usage: ["ca-ds init [--registry <url>] [--namespace <namespace> ...] [--ci github] [--branch <branch>]"],
47913
47951
  options: {
47914
47952
  registry: { type: "string" },
@@ -47922,22 +47960,22 @@ var command15 = {
47922
47960
  if (values.branch !== void 0 && values.ci === void 0) throw usageError("--branch names the workflow's branch. Use it with --ci github.");
47923
47961
  const branch = values.branch ?? "main";
47924
47962
  if (!BRANCH.test(branch)) throw usageError(`${branch} is not a branch name.`);
47925
- const collectionFile = join38(cwd, COLLECTION);
47963
+ const collectionFile = join38(cwd, configFile(cwd) ?? CONFIG);
47926
47964
  const workflowFile = join38(cwd, WORKFLOW_PATH);
47927
47965
  const asks = values.registry !== void 0 || values.namespace !== void 0;
47928
- const keep = existsSync14(collectionFile);
47966
+ const keep = existsSync13(collectionFile);
47929
47967
  if (keep && (asks || values.ci === void 0)) throw new CliError(`${collectionFile} exists already, and ca-ds init leaves it as it is.`, EXIT.conflict);
47930
- if (values.ci !== void 0 && existsSync14(workflowFile)) throw new CliError(`${workflowFile} exists already, and ca-ds init leaves it as it is.`, EXIT.conflict);
47968
+ if (values.ci !== void 0 && existsSync13(workflowFile)) throw new CliError(`${workflowFile} exists already, and ca-ds init leaves it as it is.`, EXIT.conflict);
47931
47969
  const registry = (values.registry ?? env.CA_DS_URL ?? DEFAULT_REGISTRY).replace(/\/+$/, "");
47932
47970
  const config = { registry, namespaces: [...new Set(values.namespace ?? [])] };
47933
47971
  if (!keep && !validateCollection(config)) {
47934
47972
  const errors = validateCollection.errors.map((e) => `${e.instancePath || "(root)"} ${e.message}`);
47935
- throw usageError(`That collection.json would fail its schema: ${errors.join("; ")}.`);
47973
+ throw usageError(`That ${CONFIG} would fail its schema: ${errors.join("; ")}.`);
47936
47974
  }
47937
47975
  if (!keep) {
47938
47976
  writeFileSync12(collectionFile, `${JSON.stringify(config, null, 2)}
47939
47977
  `);
47940
- io.log(`wrote ${COLLECTION}, for ${registry}${config.namespaces.length ? `, authoring ${config.namespaces.join(", ")}` : ""}`);
47978
+ io.log(`wrote ${CONFIG}, for ${registry}${config.namespaces.length ? `, authoring ${config.namespaces.join(", ")}` : ""}`);
47941
47979
  }
47942
47980
  if (values.ci !== void 0) {
47943
47981
  mkdirSync11(join38(cwd, ".github/workflows"), { recursive: true });
@@ -48254,6 +48292,20 @@ var GLOBAL = {
48254
48292
  json: { type: "boolean" },
48255
48293
  help: { type: "boolean", short: "h" }
48256
48294
  };
48295
+ function warnLegacy(root, io) {
48296
+ let legacy;
48297
+ try {
48298
+ legacy = legacyFiles(root);
48299
+ } catch {
48300
+ return;
48301
+ }
48302
+ if (!legacy.length) return;
48303
+ const steps = [
48304
+ ...legacy.includes(LEGACY_CONFIG) ? [`rename ${LEGACY_CONFIG} to ${CONFIG}`] : [],
48305
+ ...legacy.includes(LEGACY_SYSTEM) ? [`move ${LEGACY_SYSTEM}'s foundation, fixtures, and release under ${CONFIG}'s system, and its presets to presets`] : []
48306
+ ];
48307
+ io.warn(`warning: ${legacy.join(" and ")} ${legacy.length > 1 ? "are" : "is"} deprecated, and a later ca-ds reads ${CONFIG} alone. To move, ${steps.join(", then ")}.`);
48308
+ }
48257
48309
  var pad = (s, n) => s + " ".repeat(Math.max(1, n - s.length));
48258
48310
  function help() {
48259
48311
  const rows = Object.entries(COMMANDS).map(([name, c]) => ` ${pad(c.synopsis ?? name, 34)}${c.summary}`);
@@ -48322,7 +48374,8 @@ ${command16.summary}`);
48322
48374
  };
48323
48375
  const collection = () => {
48324
48376
  const root = findCollection(cwd);
48325
- if (!root) throw usageError(`No ${COLLECTION} sits in ${cwd} or any folder above it.`);
48377
+ if (!root) throw usageError(`No ${CONFIG} sits in ${cwd} or any folder above it.`);
48378
+ warnLegacy(root, io);
48326
48379
  return openCollection(root);
48327
48380
  };
48328
48381
  const { exit = EXIT.ok, result = {} } = await command16.run({ values, positionals, io, collection, cwd, env, fetch: fetch2, stdin }) ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cagov/ca-ds",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "The California Design System's toolbelt: validate, build, pack, preview, and publish a collection of items",
5
5
  "license": "MIT",
6
6
  "repository": {