dreamteamer 0.50.0 → 0.51.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 (141) hide show
  1. package/bin/dreamteamer.js +16 -148
  2. package/collections/modules.collection.yaml +1 -1
  3. package/collections/repos.collection.yaml +1 -1
  4. package/dist/api.d.ts +1 -2
  5. package/dist/api.js +0 -1
  6. package/dist/changes/commitPending.js +2 -12
  7. package/dist/changes/consts.d.ts +1 -1
  8. package/dist/changes/consts.js +1 -1
  9. package/dist/changes/deriveEvents.d.ts +1 -3
  10. package/dist/changes/deriveEvents.js +8 -11
  11. package/dist/changes/foldChanges.d.ts +1 -2
  12. package/dist/changes/foldChanges.js +2 -3
  13. package/dist/changes/groupChanges.d.ts +1 -4
  14. package/dist/changes/groupChanges.js +2 -6
  15. package/dist/changes/lib/reportLine.d.ts +1 -1
  16. package/dist/changes/lib/reportLine.js +2 -2
  17. package/dist/changes/printChanges.d.ts +1 -1
  18. package/dist/changes/printChanges.js +2 -2
  19. package/dist/changes/recordChanges.d.ts +0 -1
  20. package/dist/changes/recordChanges.js +0 -2
  21. package/dist/changes/rowChanges.js +0 -3
  22. package/dist/changes/types.d.ts +0 -2
  23. package/dist/check/check.js +82 -188
  24. package/dist/check/unreadData.js +1 -2
  25. package/dist/cli.js +1 -2
  26. package/dist/collections/renameCollection.js +0 -5
  27. package/dist/commands/compileCommand.js +2 -2
  28. package/dist/commands/exportsCommand.js +1 -4
  29. package/dist/commands/fmtCommand.js +1 -2
  30. package/dist/commands/lib/unknownVerb.js +1 -1
  31. package/dist/commands/relationsCommand.js +2 -7
  32. package/dist/commands/updateCommand.js +3 -11
  33. package/dist/compile/compile.js +21 -86
  34. package/dist/compile/consts.js +1 -2
  35. package/dist/compile/lib/compileCollections.d.ts +4 -8
  36. package/dist/compile/lib/compileCollections.js +5 -97
  37. package/dist/compile/types.d.ts +0 -9
  38. package/dist/exports/planExports.d.ts +2 -2
  39. package/dist/exports/planExports.js +9 -24
  40. package/dist/exports/runExports.d.ts +2 -3
  41. package/dist/exports/runExports.js +72 -81
  42. package/dist/extensions/declaredExtensions.d.ts +2 -3
  43. package/dist/extensions/declaredExtensions.js +2 -30
  44. package/dist/fmt/formatDescriptors.d.ts +1 -1
  45. package/dist/fmt/formatDescriptors.js +1 -1
  46. package/dist/init/init.js +0 -1
  47. package/dist/init/seedBlock.js +0 -1
  48. package/dist/install/applyInstall.js +3 -13
  49. package/dist/install/installCommand.js +0 -6
  50. package/dist/install/npmAndCompile.js +1 -1
  51. package/dist/install/observeState.d.ts +0 -1
  52. package/dist/install/observeState.js +0 -23
  53. package/dist/install/planInstall.js +0 -10
  54. package/dist/lib/consts.js +1 -1
  55. package/dist/modules/removeModule.js +0 -3
  56. package/dist/modules/renameModule.js +0 -7
  57. package/dist/modules/runModuleScript.d.ts +1 -2
  58. package/dist/modules/runModuleScript.js +1 -2
  59. package/dist/modules/setModule.js +1 -1
  60. package/dist/record/exportsContext.d.ts +2 -10
  61. package/dist/record/exportsContext.js +5 -33
  62. package/dist/record/pathToRecord.js +7 -8
  63. package/dist/record/regenerate.d.ts +4 -5
  64. package/dist/record/regenerate.js +5 -5
  65. package/dist/record/sees.d.ts +2 -2
  66. package/dist/record/sees.js +3 -3
  67. package/dist/record/storageOf.js +1 -7
  68. package/dist/record/types.d.ts +7 -10
  69. package/dist/records/history.d.ts +1 -1
  70. package/dist/records/history.js +1 -1
  71. package/dist/records/lib/landedIn.d.ts +1 -1
  72. package/dist/records/lib/landedIn.js +1 -1
  73. package/dist/records/recordsCommand.js +2 -2
  74. package/dist/repos/lib/relPath.js +3 -4
  75. package/dist/repos/materializeRepo.js +1 -1
  76. package/dist/runtime/exportsFacts.d.ts +1 -13
  77. package/dist/runtime/exportsFacts.js +2 -6
  78. package/dist/scripts/migrate-stubs.js +54 -72
  79. package/dist/statusCommand.js +2 -83
  80. package/dist/store/Store.d.ts +13 -31
  81. package/dist/store/Store.js +17 -51
  82. package/dist/store/add.js +1 -1
  83. package/dist/store/addedDates.js +5 -5
  84. package/dist/store/external.d.ts +1 -3
  85. package/dist/store/external.js +2 -12
  86. package/dist/store/lib/applyMirrorEdits.js +2 -3
  87. package/dist/store/lib/assertUnambiguous.js +1 -1
  88. package/dist/store/lib/checkRefs.d.ts +2 -5
  89. package/dist/store/lib/checkRefs.js +4 -7
  90. package/dist/store/lib/commit.js +3 -6
  91. package/dist/store/lib/idsKey.js +2 -3
  92. package/dist/store/lib/indexAdd.js +0 -2
  93. package/dist/store/lib/validate.d.ts +1 -2
  94. package/dist/store/lib/validate.js +2 -2
  95. package/dist/store/lib/walkIds.js +0 -23
  96. package/dist/store/recordFiles.js +1 -4
  97. package/dist/store/recordRoot.js +0 -7
  98. package/dist/store/rename.js +2 -11
  99. package/dist/store/revert.js +2 -2
  100. package/dist/store/set.js +1 -1
  101. package/dist/store/types.d.ts +0 -5
  102. package/dist/store/vouched.d.ts +2 -2
  103. package/dist/store/vouched.js +4 -5
  104. package/dist/types.d.ts +3 -37
  105. package/dist/usage.d.ts +1 -1
  106. package/dist/usage.js +18 -28
  107. package/dist/workspace/discoverModules.d.ts +2 -4
  108. package/dist/workspace/discoverModules.js +5 -43
  109. package/dist/workspace/findWorkspace.js +3 -3
  110. package/dist/workspace/lib/aheadCount.d.ts +1 -1
  111. package/dist/workspace/lib/aheadCount.js +1 -1
  112. package/dist/workspace/types.d.ts +2 -7
  113. package/package.json +1 -1
  114. package/skills/using-dreamteamer/SKILL.md +9 -10
  115. package/skills/using-dreamteamer/references/before-you-build.md +2 -2
  116. package/skills/using-dreamteamer/references/changes.md +6 -7
  117. package/skills/using-dreamteamer/references/collections.md +22 -91
  118. package/skills/using-dreamteamer/references/records.md +1 -2
  119. package/skills/using-dreamteamer/references/writing-a-module.md +2 -2
  120. package/dist/changes/layerOf.d.ts +0 -6
  121. package/dist/changes/layerOf.js +0 -12
  122. package/dist/install/buildClone.d.ts +0 -5
  123. package/dist/install/buildClone.js +0 -22
  124. package/dist/install/commitOf.d.ts +0 -1
  125. package/dist/install/commitOf.js +0 -2
  126. package/dist/install/install.d.ts +0 -8
  127. package/dist/install/install.js +0 -177
  128. package/dist/install/installClone.d.ts +0 -6
  129. package/dist/install/installClone.js +0 -32
  130. package/dist/install/isLink.d.ts +0 -1
  131. package/dist/install/isLink.js +0 -9
  132. package/dist/install/offRef.d.ts +0 -7
  133. package/dist/install/offRef.js +0 -19
  134. package/dist/record/ownersReadIn.d.ts +0 -9
  135. package/dist/record/ownersReadIn.js +0 -11
  136. package/dist/update/update.d.ts +0 -7
  137. package/dist/update/update.js +0 -57
  138. package/dist/workspace/declaredGitModules.d.ts +0 -51
  139. package/dist/workspace/declaredGitModules.js +0 -89
  140. package/dist/workspace/layerEntries.d.ts +0 -16
  141. package/dist/workspace/layerEntries.js +0 -36
@@ -5,7 +5,7 @@ import fs from "node:fs";
5
5
  import { isStale } from "./isStale.js";
6
6
  import { symlinkedChildRoots } from "./symlinkedChildRoots.js";
7
7
  import { collectRefFields } from "../record/collectRefFields.js";
8
- import { bodyFieldOf, fieldsOf, idsOf, jsonSchemaOf, recordTitleOf, unresolvedPeersOf } from "../record/descriptor.js";
8
+ import { bodyFieldOf, fieldsOf, idsOf, jsonSchemaOf, unresolvedPeersOf } from "../record/descriptor.js";
9
9
  import { expectedMirrors } from "../record/expectedMirrors.js";
10
10
  import { sees } from "../record/sees.js";
11
11
  import { valuesAt } from "../record/valuesAt.js";
@@ -14,7 +14,6 @@ import { exportsContext } from "../record/exportsContext.js";
14
14
  import { idFromRecordPath } from "../record/idFromRecordPath.js";
15
15
  import { outsideRefs } from "../record/outsideRefs.js";
16
16
  import { ownerIdOf } from "../record/ownerIdOf.js";
17
- import { ownersReadIn } from "../record/ownersReadIn.js";
18
17
  import { parseRef } from "../record/parseRef.js";
19
18
  import { placedRecords } from "../record/placedRecords.js";
20
19
  import { placementOf } from "../record/placement.js";
@@ -61,34 +60,29 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
61
60
  // finding (an unreachable data root, below) before a single record is read.
62
61
  const violations = [];
63
62
  const dirOf = (d) => path.resolve(storageOf(d).runtime ? RUNTIME : root, storageOf(d).path); // resolve: an env-pointed root is absolute
64
- // per indexed file: the repo that holds it (mirrors are expected per repo) and the record layer it
65
- // came from, if any (its findings are reported under the layer, not as this workspace's data)
63
+ // per indexed file: the repo that holds it (mirrors are expected per repo)
66
64
  const fileRepo = new Map();
67
- const fileLayer = new Map();
68
- const layerNotes = new Map(); // layer name -> note, printed once
65
+ const notes = new Map(); // key -> note, printed once
69
66
  for (const [name, d] of descriptors) {
70
67
  const ids = new Map();
71
68
  index.set(name, ids);
72
- const claim = (id, f, repo, layer) => {
69
+ const claim = (id, f, repo) => {
73
70
  if (ids.has(id)) {
74
71
  violations.push({
75
72
  file: rel(f),
76
- layer,
77
73
  msg: `collection "${name}" holds the id "${id}" twice — ${rel(ids.get(id))} and ${rel(f)}. Remove one.`,
78
74
  });
79
75
  return false;
80
76
  }
81
77
  ids.set(id, f);
82
78
  fileRepo.set(f, repo);
83
- if (layer)
84
- fileLayer.set(f, layer);
85
79
  return true;
86
80
  };
87
81
  // An env-pointed root this machine cannot render is the normal state of a per-machine
88
- // collection elsewhere — said once, like an absent layer, and not read: a literal `${env:…}`
82
+ // collection elsewhere — said once, and not read: a literal `${env:…}`
89
83
  // folder is never looked at, and a reference into the collection is not a finding here.
90
84
  if (storageOf(d).unavailable) {
91
- layerNotes.set(`collection:${name}`, `⚠ collection ${name}: ${storageOf(d).unavailable} — its records are not read on this machine, and references into it are not checked`);
85
+ notes.set(`collection:${name}`, `⚠ collection ${name}: ${storageOf(d).unavailable} — its records are not read on this machine, and references into it are not checked`);
92
86
  continue;
93
87
  }
94
88
  // runtime-based (knowhow/meta) collections are read from the COMPILED runtime —
@@ -136,79 +130,67 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
136
130
  }
137
131
  continue;
138
132
  }
139
- // every root: the write root, then each record layer. Claimants are GATHERED first, in root order:
140
- // the first answers, exactly as the store indexes, and every other is the duplicate reported above.
141
- const offers = new Map(); // id -> [{ f, repo, layer }], root order
142
- const offer = (id, f, repo, layer) => {
133
+ // Claimants are GATHERED first: the first answers, exactly as the store indexes, and every other is
134
+ // the duplicate reported above.
135
+ const offers = new Map(); // id -> files, walk order
136
+ const offer = (id, f) => {
143
137
  const o = offers.get(id);
144
138
  if (o)
145
- o.push({ f, repo, layer });
139
+ o.push(f);
146
140
  else
147
- offers.set(id, [{ f, repo, layer }]);
141
+ offers.set(id, [f]);
148
142
  };
149
- for (const r of storageOf(d).roots) {
150
- const rootDir = r.layer ? path.join(root, r.path) : dir;
151
- if (!fs.existsSync(rootDir)) {
152
- // a layer whose CLONE is absent is a fresh checkout before `dreamteamer install` — its records
153
- // are unread, and that is said once rather than passed off as an empty layer
154
- if (r.layer && !fs.existsSync(path.join(root, r.repo)))
155
- layerNotes.set(r.layer, `⚠ layer ${r.layer} (${r.repo}) is not installed — its records are not read; run dreamteamer install`);
156
- continue;
157
- }
158
- const shape = storageOf(d).shape ?? "file";
159
- if (shape === "folder") {
160
- // a FILE record at the root of a folder-shape collection is the state a collection is in
161
- // right after its shape changed — named as such, with the verb that finishes the change
162
- const asFile = { ...d, storage: { ...d.storage, shape: "file" } };
163
- for (const entry of fs.readdirSync(rootDir).sort()) {
164
- if (entry.startsWith("."))
165
- continue;
166
- const p = path.join(rootDir, entry);
167
- if (!fs.statSync(p).isDirectory()) {
168
- const legacy = idFromRecordPath(asFile, entry) !== null;
169
- strays.push({
170
- collection: name,
171
- file: rel(p),
172
- note: legacy
173
- ? `a file-shape record in a folder-shape collection — dreamteamer relocate ${name} moves it to ${entry.split(".")[0]}/${storageOf(d).entry}`
174
- : undefined,
175
- });
176
- continue;
177
- }
178
- const main = path.join(p, storageOf(d).entry ?? "SKILL.md");
179
- if (fs.existsSync(main))
180
- offer(entry, main, r.repo, r.layer);
181
- else
182
- strays.push({ collection: name, file: rel(p), note: `missing entry file ${storageOf(d).entry}` });
143
+ const shape = storageOf(d).shape ?? "file";
144
+ if (fs.existsSync(dir) && shape === "folder") {
145
+ // a FILE record at the root of a folder-shape collection is the state a collection is in
146
+ // right after its shape changed — named as such, with the verb that finishes the change
147
+ const asFile = { ...d, storage: { ...d.storage, shape: "file" } };
148
+ for (const entry of fs.readdirSync(dir).sort()) {
149
+ if (entry.startsWith("."))
150
+ continue;
151
+ const p = path.join(dir, entry);
152
+ if (!fs.statSync(p).isDirectory()) {
153
+ const legacy = idFromRecordPath(asFile, entry) !== null;
154
+ strays.push({
155
+ collection: name,
156
+ file: rel(p),
157
+ note: legacy
158
+ ? `a file-shape record in a folder-shape collection — dreamteamer relocate ${name} moves it to ${entry.split(".")[0]}/${storageOf(d).entry}`
159
+ : undefined,
160
+ });
161
+ continue;
183
162
  }
184
- continue;
163
+ const main = path.join(p, storageOf(d).entry ?? "SKILL.md");
164
+ if (fs.existsSync(main))
165
+ offer(entry, main);
166
+ else
167
+ strays.push({ collection: name, file: rel(p), note: `missing entry file ${storageOf(d).entry}` });
185
168
  }
186
- for (const f of walk(rootDir)) {
187
- const id = idFromRecordPath(d, path.relative(rootDir, f));
169
+ }
170
+ else if (fs.existsSync(dir)) {
171
+ for (const f of walk(dir)) {
172
+ const id = idFromRecordPath(d, path.relative(dir, f));
188
173
  if (id === null) {
189
174
  strays.push({ collection: name, file: rel(f) });
190
175
  continue;
191
176
  }
192
- // One id is one file. Under a fixed-extension format this cannot happen within one root;
193
- // under `binary` it can, and across roots it is a layer and this workspace disagreeing.
194
- offer(id, f, r.repo, r.layer);
177
+ // One id is one file. Under a fixed-extension format this cannot happen; under `binary` it can.
178
+ offer(id, f);
195
179
  }
196
180
  }
197
181
  const opaque = storageOf(d).format === "binary";
198
182
  const allowed = storageOf(d).accept; // undefined = any
199
183
  const max = storageOf(d).max_bytes ?? MAX_RECORD_BYTES;
200
184
  for (const [id, list] of offers) {
201
- const [winner] = list;
185
+ const [f] = list;
202
186
  for (const c of list)
203
- claim(id, c.f, c.repo, c.layer); // the second and later are reported as duplicates
187
+ claim(id, c, storageOf(d).repo); // the second and later are reported as duplicates
204
188
  if (!opaque)
205
189
  continue;
206
- const f = winner.f;
207
190
  const ext = path.extname(f).slice(1).toLowerCase();
208
191
  if (allowed && !allowed.includes(ext)) {
209
192
  violations.push({
210
193
  file: rel(f),
211
- layer: winner.layer,
212
194
  msg: `collection "${name}" does not accept .${ext} — its declared extensions are ${allowed.join(", ")}`,
213
195
  });
214
196
  }
@@ -216,48 +198,34 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
216
198
  if (size > max) {
217
199
  violations.push({
218
200
  file: rel(f),
219
- layer: winner.layer,
220
201
  msg: `is ${size} bytes, over collection "${name}"'s max_bytes of ${max} — a record is a small file; a big one belongs outside the vault`,
221
202
  });
222
203
  }
223
204
  }
224
205
  }
225
206
  const flag = (file, msg) => {
226
- violations.push({ file: rel(file), layer: fileLayer.get(file), msg });
207
+ violations.push({ file: rel(file), msg });
227
208
  };
228
209
  // parsed fields, kept for the relations pass below (parse each record exactly once)
229
210
  const parsed = new Map();
230
- // cr-dt-003: what a reader of this workspace (without its layers) would see break — a target only a
231
- // layer answers
232
- const layerOnly = new Map(); // target -> { layer, binary, refs: [{ file, field, value, referrer }] }
233
211
  const softRefs = new Map(); // absent-but-declared peer collection -> how many refs point at it
234
- // cr-dt-004: each repo's exports manifest (the write root is `null`), and the references it vouches for
212
+ // cr-dt-004: this workspace's exports manifest, and the references it vouches for
235
213
  const facts = exportsFacts(root);
236
- const ctx = exportsContext({ root, descriptors, own: facts.own, layers: facts.layers, dataPath: facts.data });
237
- const manifests = new Map();
238
- for (const repo of [null, ...(facts.layers ?? []).map(l => l.name)]) {
239
- try {
240
- const m = readExports(ctx.rootOf(repo));
241
- if (m)
242
- manifests.set(repo, m);
243
- }
244
- catch (e) {
245
- violations.push({
246
- file: rel(path.join(ctx.rootOf(repo), EXPORTS_FILE)),
247
- layer: repo ?? undefined,
248
- msg: e.message,
249
- });
250
- }
214
+ const ctx = exportsContext({ root, descriptors, own: facts.own, dataPath: facts.data });
215
+ let manifest = null;
216
+ try {
217
+ manifest = readExports(root);
251
218
  }
252
- const external = new Map(); // repo -> { refs, targets: Set }
219
+ catch (e) {
220
+ violations.push({ file: rel(path.join(root, EXPORTS_FILE)), msg: e.message });
221
+ }
222
+ const external = { refs: 0, targets: new Set() };
253
223
  for (const [name, d] of descriptors) {
254
224
  const validate = ajv.compile(jsonSchemaOf(d));
255
225
  const refFields = collectRefFields(fieldsOf(d));
256
226
  const softTargets = unresolvedPeersOf(d).length ? new Set(unresolvedPeersOf(d)) : null;
257
227
  const bodyField = bodyFieldOf(d);
258
228
  parsed.set(name, new Map());
259
- // only a referrer a reader can read counts: its collection can be layered at all (D11)
260
- const exportable = d.compiled?.layerable === true;
261
229
  for (const [id, file] of index.get(name)) {
262
230
  if (idsOf(d).pattern && !patternRe(idsOf(d).pattern).test(id)) {
263
231
  flag(file, `id "${id}" does not match pattern ${idsOf(d).pattern}`);
@@ -278,20 +246,8 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
278
246
  flag(file, `unknown field "${k}" (not in the ${name} schema)`);
279
247
  }
280
248
  for (const [fieldPath, target, soft] of refFields) {
281
- // a layer's MIRROR whose owners this workspace does not read from that layer names
282
- // records of the layer's repo — not dangling, only out of sight (see ownersReadIn)
283
- if (fileLayer.has(file) &&
284
- fieldPath.length === 1 &&
285
- fieldsOf(d)[fieldPath[0]]?.mirror_of !== undefined &&
286
- Array.isArray(target) &&
287
- descriptors.has(target[0]) &&
288
- !ownersReadIn(descriptors.get(target[0]), fileRepo.get(file)))
289
- continue;
290
- const counted = exportable &&
291
- !fileLayer.has(file) &&
292
- !(fieldPath.length === 1 && fieldsOf(d)[fieldPath[0]]?.mirror_of !== undefined);
293
249
  for (const value of valuesAt(fields, fieldPath)) {
294
- checkRef(file, fieldPath, value, target, softTargets, soft, counted ? `${name}/${id}` : null);
250
+ checkRef(file, fieldPath, value, target, softTargets, soft);
295
251
  }
296
252
  }
297
253
  // placement: the FIELD is the intended owner, the FOLDER is observed placement
@@ -347,8 +303,7 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
347
303
  repo: fileRepo.get(index.get(relation.owner).get(id)),
348
304
  }));
349
305
  // PER REPO: a mirror is kept only between records of one repo (store.js applyMirrorEdits), so
350
- // the expectation on a target is computed from the owners in ITS repo — an owner in this
351
- // workspace naming a target a layer holds is not a link the layer's own check could see.
306
+ // the expectation on a target is computed from the owners in ITS repo.
352
307
  const byRepo = new Map();
353
308
  for (const o of owners) {
354
309
  if (!byRepo.has(o.repo))
@@ -373,17 +328,13 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
373
328
  seen.set(v, id);
374
329
  }
375
330
  }
376
- const ownerD = descriptors.get(relation.owner);
377
331
  for (const [id, fields] of parsed.get(relation.target) ?? []) {
378
- const tfile = index.get(relation.target).get(id);
379
- if (fileLayer.has(tfile) && !ownersReadIn(ownerD, fileRepo.get(tfile)))
380
- continue; // the layer's own check judges it
381
332
  const expected = expByRepo.get(fileRepo.get(index.get(relation.target).get(id)))?.get(id);
382
333
  if (!sameMirror(relation, fields?.[relation.mirror], expected))
383
334
  flag(index.get(relation.target).get(id), `${relation.mirror}: stale — run: dreamteamer relations rebuild ${relation.target}`);
384
335
  }
385
336
  }
386
- function checkRef(file, fieldPath, value, targets, softTargets, soft = false, referrer = null) {
337
+ function checkRef(file, fieldPath, value, targets, softTargets, soft = false) {
387
338
  if (typeof value !== "string")
388
339
  return;
389
340
  if (value.startsWith("@"))
@@ -417,28 +368,15 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
417
368
  return; // resolve if present, ignore if absent
418
369
  if (storageOf(descriptors.get(coll)).unavailable)
419
370
  return; // the collection is unread here, not empty
420
- // listed by the referring record's OWN repo, its holder not read here: external (cr-dt-004)
421
- const repo = fileLayer.get(file) ?? null;
422
- const e = manifests.get(repo)?.[coll]?.[id];
371
+ // listed by this workspace's exports manifest, its holder not read here: external (cr-dt-004)
372
+ const e = manifest?.[coll]?.[id];
423
373
  if (e && !sees(e, coll, ctx)) {
424
- const x = external.get(repo) ?? external.set(repo, { refs: 0, targets: new Set() }).get(repo);
425
- x.refs++;
426
- x.targets.add(`${coll}/${id}`);
374
+ external.refs++;
375
+ external.targets.add(`${coll}/${id}`);
427
376
  return;
428
377
  }
429
378
  return flag(file, `${fieldPath.join(".")}: dangling reference "${value}" — no such record${e ? ` (its holder ${e.from} is read here and does not have it)` : ""}`);
430
379
  }
431
- const at = index.get(coll).get(id);
432
- if (!referrer || soft || !fileLayer.has(at) || manifests.get(null)?.[coll]?.[id])
433
- return;
434
- const key = `${coll}/${id}`;
435
- if (!layerOnly.has(key))
436
- layerOnly.set(key, {
437
- layer: fileLayer.get(at),
438
- binary: storageOf(descriptors.get(coll)).format === "binary",
439
- refs: [],
440
- });
441
- layerOnly.get(key).refs.push({ file, field: fieldPath.join("."), value, referrer });
442
380
  }
443
381
  // an extension's warning is printed and never counted: a disagreement worth seeing that must not turn
444
382
  // the workspace red (src/api.ts contributedViolations carries the mark)
@@ -446,51 +384,25 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
446
384
  for (const s of strays) {
447
385
  console.log(`⚠ ${s.file} — unrecognized file in ${s.collection} folder${s.note ? ` (${s.note})` : ""}`);
448
386
  }
449
- for (const note of layerNotes.values())
387
+ for (const note of notes.values())
450
388
  console.log(note);
451
389
  const upTo3 = (xs) => (xs.length > 3 ? [...xs.slice(0, 3), `+${xs.length - 3} more`] : xs).join(", ");
452
- for (const [repo, { refs, targets }] of external) {
453
- console.log(`ℹ ${repo ? `layer ${repo}: ` : ""}${refs} reference${refs === 1 ? "" : "s"} to ${targets.size} record${targets.size === 1 ? "" : "s"} outside ${repo ? "it" : "this workspace"}, vouched for by its exports manifest (${upTo3([...targets].sort())})`);
454
- }
390
+ if (external.refs)
391
+ console.log(`ℹ ${external.refs} reference${external.refs === 1 ? "" : "s"} to ${external.targets.size} record${external.targets.size === 1 ? "" : "s"} outside this workspace, vouched for by its exports manifest (${upTo3([...external.targets].sort())})`);
455
392
  // a manifest is stale exactly when `dt exports` here would change or drop one of its entries
456
- for (const [repo, current] of manifests) {
457
- const repoOf = (c, id) => {
458
- const f = index.get(c)?.get(id);
459
- return f ? (fileLayer.get(f) ?? null) : undefined;
460
- };
461
- const records = [...parsed].flatMap(([c, m]) => [...m]
462
- .filter(([id]) => repoOf(c, id) === repo)
463
- .map(([id, fields]) => ({ collection: c, id, fields, descriptor: descriptors.get(c) })));
464
- const resolve = (c, id) => {
465
- if (repoOf(c, id) === undefined)
466
- return null;
467
- const t = /\{\{\s*([A-Za-z_][\w]*)/.exec(recordTitleOf(descriptors.get(c)))?.[1];
468
- return { label: String(parsed.get(c)?.get(id)?.[t] ?? id), from: ctx.packageOf(repoOf(c, id)) };
469
- };
470
- const outside = outsideRefs({ records, held: (c, id) => repoOf(c, id) === repo, resolve, namespaces });
471
- const { changes } = regenerate({ current, outside, ctx, repo, held: (c, id) => repoOf(c, id) === repo });
472
- if (!isStale(changes))
473
- continue;
474
- const stale = changes.filter(x => x.kind !== "add");
475
- const msg = `stale — ${upTo3(stale.map(x => `${x.ref} (${x.kind}: ${x.why})`))}. dt exports${repo ? ` --layer ${repo}` : ""}`;
476
- if (strictExport && !repo)
477
- violations.push({ file: rel(path.join(root, EXPORTS_FILE)), msg });
478
- else
479
- console.log(`⚠ ${rel(path.join(ctx.rootOf(repo), EXPORTS_FILE))} is ${msg}`);
480
- }
481
- for (const [target, { layer, refs }] of [...layerOnly].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
482
- const fix = () => "a workspace reading this one sees it dangle. dt exports";
483
- if (strictExport) {
484
- for (const r of refs)
485
- violations.push({
486
- file: rel(r.file),
487
- msg: `${r.field}: "${r.value}" resolves only through layer ${layer} — ${fix()}`,
488
- });
489
- continue;
393
+ if (manifest) {
394
+ const held = (c, id) => !!index.get(c)?.has(id);
395
+ const records = [...parsed].flatMap(([c, m]) => [...m].map(([id, fields]) => ({ collection: c, id, fields, descriptor: descriptors.get(c) })));
396
+ const outside = outsideRefs({ records, held, resolve: () => null, namespaces });
397
+ const { changes } = regenerate({ current: manifest, outside, ctx, held });
398
+ if (isStale(changes)) {
399
+ const stale = changes.filter(x => x.kind !== "add");
400
+ const msg = `stale — ${upTo3(stale.map(x => `${x.ref} (${x.kind}: ${x.why})`))}. dt exports`;
401
+ if (strictExport)
402
+ violations.push({ file: rel(path.join(root, EXPORTS_FILE)), msg });
403
+ else
404
+ console.log(`⚠ ${rel(path.join(root, EXPORTS_FILE))} is ${msg}`);
490
405
  }
491
- const who = [...new Set(refs.map(r => r.referrer))];
492
- const named = `${who.length} record${who.length === 1 ? "" : "s"} here (${upTo3(who)})`;
493
- console.log(`⚠ ${target} resolves only through layer ${layer} — named by ${named}; ${fix()}`);
494
406
  }
495
407
  // Warned, never silent: the references are real and currently resolve to nothing. This is the
496
408
  // expected reading when a module is opened without the workspace that provides the concept.
@@ -516,30 +428,12 @@ export function check({ root }, { extra = [], strictExport = false, } = {}) {
516
428
  console.log(`✔ 0 violations (${[...index.values()].reduce((n, m) => n + m.size, 0)} records across ${descriptors.size} collections)`);
517
429
  return 0;
518
430
  }
519
- // this workspace's own findings first, then each record layer's under its own heading: a layer's
520
- // record is validated against THIS workspace's shape, and a value its own overlay allows is a
521
- // finding about the two having drifted, not a defect in our data
522
- const own = violations.filter(v => !v.layer);
523
- const layers = new Map();
524
- for (const v of violations)
525
- if (v.layer) {
526
- if (!layers.has(v.layer))
527
- layers.set(v.layer, []);
528
- layers.get(v.layer).push(v);
529
- }
530
- const print = (list) => {
531
- let last = null;
532
- for (const v of list) {
533
- if (v.file !== last)
534
- console.log(`✖ ${v.file}`);
535
- console.log(` ${v.msg}`);
536
- last = v.file;
537
- }
538
- };
539
- print(own);
540
- for (const [layer, list] of layers) {
541
- console.log(`✖ layer ${layer}: ${list.length} violation${list.length === 1 ? "" : "s"} against this workspace's shape`);
542
- print(list);
431
+ let last = null;
432
+ for (const v of violations) {
433
+ if (v.file !== last)
434
+ console.log(`✖ ${v.file}`);
435
+ console.log(` ${v.msg}`);
436
+ last = v.file;
543
437
  }
544
438
  console.log(`${violations.length} violation${violations.length === 1 ? "" : "s"}. files were NOT modified.`);
545
439
  return 1;
@@ -1,8 +1,7 @@
1
1
  // Record files under the workspace's own data/ that no compiled collection reads (cr-dt-008 test stage).
2
2
  //
3
3
  // A collection that leaves a module — notebooks and wikis composed out of rnd — leaves its records on disk
4
- // with nothing reading them, and `dt check` said "0 violations". Compile has warned about the same thing for
5
- // a record layer's clone since cr-dt-004 ("no collection here reads it"); this is the workspace's own data/,
4
+ // with nothing reading them, and `dt check` said "0 violations". This warns about the workspace's own data/,
6
5
  // read at check time against the compiled descriptors. A warning, never a violation: the files are not
7
6
  // wrong, they are unread — and the remedy is usually one install.
8
7
  import fs from "node:fs";
package/dist/cli.js CHANGED
@@ -38,7 +38,6 @@ export const WORKSPACE_FLAGS = {
38
38
  ],
39
39
  update: ["engine", "allow", "from", "no-commit"],
40
40
  install: [
41
- "clone",
42
41
  "dry-run",
43
42
  "json",
44
43
  "link-env",
@@ -53,7 +52,7 @@ export const WORKSPACE_FLAGS = {
53
52
  ],
54
53
  compile: ["watch"],
55
54
  check: ["strict-export", "alone", "keep"],
56
- exports: ["layer", "dry-run", "json"],
55
+ exports: ["dry-run", "json"],
57
56
  status: ["json"],
58
57
  doctor: ["strict", "json"],
59
58
  setup: ["input", "allow", "authorize", "verify", "skip", "no-input", "json"],
@@ -155,11 +155,6 @@ export function renameCollection(ws, store, oldName, newName) {
155
155
  const newSuffix = suffixWasDerived ? singular(newBase) : oldSuffix;
156
156
  // Every id BEFORE anything moves — the store's index is keyed on the old collection.
157
157
  const ids = [...store.ids(oldName).keys()];
158
- for (const [id, f] of store.ids(oldName)) {
159
- const layer = store.layerOfFile(d, f);
160
- if (layer)
161
- throw new Error(`${oldName}/${id} is held by layer ${layer.layer} (${layer.path}) — a collection with records in a record layer is renamed in that workspace first; nothing was renamed`);
162
- }
163
158
  const oldDir = store.dir(d);
164
159
  const newDir = path.join(ws.root, newPath);
165
160
  if (newDir !== oldDir && fs.existsSync(newDir)) {
@@ -8,7 +8,7 @@ export async function compileCommand(args) {
8
8
  const code = compile(ws);
9
9
  if (!args.includes("--watch"))
10
10
  return code;
11
- console.log("… watching sources (modules/*, git_modules/*, and the workspace root) — ctrl-c to stop");
11
+ console.log("… watching sources (modules/* and the workspace root) — ctrl-c to stop");
12
12
  watchAndRecompile(ws);
13
13
  }
14
14
  function watchAndRecompile(ws) {
@@ -28,7 +28,7 @@ function watchAndRecompile(ws) {
28
28
  };
29
29
  // 'system' plus the flat kinds: the classic layout can put sources at the workspace root under
30
30
  // either spelling, and a watcher that misses one makes --watch quietly stop recompiling.
31
- for (const dir of ["system", ...kindsOf(ws), "modules", "git_modules"].map(d => path.join(ws.root, d))) {
31
+ for (const dir of ["system", ...kindsOf(ws), "modules"].map(d => path.join(ws.root, d))) {
32
32
  if (fs.existsSync(dir))
33
33
  fs.watch(dir, { recursive: true }, trigger);
34
34
  }
@@ -3,8 +3,5 @@ import { openWorkspace } from "../openWorkspace.js";
3
3
  import { Store } from "../store/Store.js";
4
4
  export async function exportsCommand(args) {
5
5
  const ws = await openWorkspace();
6
- const layers = args
7
- .flatMap((a, i) => (a === "--layer" ? [args[i + 1]] : a.startsWith("--layer=") ? [a.slice(8)] : []))
8
- .filter(Boolean);
9
- return runExports(new Store(ws), { layers, dryRun: args.includes("--dry-run"), json: args.includes("--json") });
6
+ return runExports(new Store(ws), { dryRun: args.includes("--dry-run"), json: args.includes("--json") });
10
7
  }
@@ -18,9 +18,8 @@ export async function fmtCommand(rest) {
18
18
  const out = formatDescriptors(ws, { collection, dryRun });
19
19
  for (const f of out.changed)
20
20
  console.log(`${dryRun ? "→" : "✔"} ${f}`);
21
- const under = (dir) => out.skipped.filter(f => f.startsWith(`${dir}/`)).length;
22
21
  if (out.skipped.length)
23
- console.log(`— skipped ${under("git_modules")} source(s) under git_modules/ and ${under("node_modules")} under node_modules/ — format those in their own repo`);
22
+ console.log(`— skipped ${out.skipped.length} source(s) under node_modules/ — format those in their own repo`);
24
23
  console.log(`${out.changed.length} source(s) ${dryRun ? "would change (dry run — nothing was written)" : "formatted"}, ${out.unchanged} already canonical`);
25
24
  reportCommits(out.commits);
26
25
  return 0;
@@ -38,7 +38,7 @@ export function unknownVerb(cmd) {
38
38
  }
39
39
  if (cmd === "ensure") {
40
40
  console.error('✖ unknown verb "ensure" — gone since 0.22.0 (decision 309: install is the one verb that makes a thing present and ready):');
41
- console.error(" dt install this checkout — engine, .env, local assets, git modules, compile, postinstall");
41
+ console.error(" dt install this checkout — engine, .env, local assets, compile, postinstall");
42
42
  console.error(" dt install repos/<id> materialize one attached repo · dt install repos --all");
43
43
  return 2;
44
44
  }
@@ -7,7 +7,6 @@ import { bodyField } from "../record/bodyField.js";
7
7
  import { fieldsOf } from "../record/descriptor.js";
8
8
  import { emit } from "../lib/emit.js";
9
9
  import { expectedMirrors } from "../record/expectedMirrors.js";
10
- import { ownersReadIn } from "../record/ownersReadIn.js";
11
10
  import { parseRecord } from "../record/records.js";
12
11
  import { serialize } from "../record/serialize.js";
13
12
  import { storageOf } from "../record/storageOf.js";
@@ -87,8 +86,8 @@ function relationsRebuild(store, flags, pos) {
87
86
  // store's own `applyMirrorEdits` re-walks the owners per write, which is right for one edit and
88
87
  // quadratic for a whole collection — so rebuild does not build on it.
89
88
  const unreadableOwners = [];
90
- // PER REPO, like check.js and the store: an owner in another repo (a record layer, or this
91
- // workspace against a module-owned target) implies no mirror on a target it cannot be committed with
89
+ // PER REPO, like check.js and the store: an owner in another repo (this workspace against a
90
+ // module-owned target) implies no mirror on a target it cannot be committed with
92
91
  const perRepo = (r) => {
93
92
  const groups = new Map();
94
93
  for (const o of parseEach(store, r.owner, f => unreadableOwners.push(rel(store.root, f)))) {
@@ -117,10 +116,6 @@ function relationsRebuild(store, flags, pos) {
117
116
  let changed = false;
118
117
  const repo = store.repoOfFile(d, file);
119
118
  for (const { r, exp } of expected) {
120
- // a layer's mirror justified by owners this workspace does not read from that layer is
121
- // left exactly as the layer wrote it — rebuilding it from here deleted it (ownersReadIn)
122
- if (store.layerOfFile(d, file) && !ownersReadIn(store.descriptor(r.owner), repo))
123
- continue;
124
119
  const want = exp.get(repo)?.get(id);
125
120
  const have = fields[r.mirror];
126
121
  // ⚠ COERCE THE WAY AJV DOES. `check` validates with `coerceTypes: 'array'`, which mutates
@@ -1,18 +1,10 @@
1
- import { declaredGitModules } from "../workspace/declaredGitModules.js";
2
1
  import { parseUpdateArgs } from "../update/parseUpdateArgs.js";
3
- import { update } from "../update/update.js";
4
2
  import { updateModules } from "../update/updateModules.js";
5
- import { compile } from "../compile/compile.js";
6
3
  import { openWorkspace } from "../openWorkspace.js";
7
4
  export async function updateCommand(rest) {
8
5
  const ws = await openWorkspace();
9
- // an npm module or the engine moves through src/update.js; a git module (or no target) keeps
10
- // the fast-forward path below
11
6
  const u = parseUpdateArgs(rest);
12
- const gitMods = Object.fromEntries(declaredGitModules(ws.pkg, ws.root).map);
13
- if (u.engine || (u.name && !gitMods[u.name]))
14
- return await updateModules(ws, u, { open: openWorkspace });
15
- const code = update(ws, u.name);
16
- compile(ws); // pulled modules may carry new sources — prints its own summary
17
- return code;
7
+ if (!u.engine && !u.name)
8
+ throw new Error("dt update needs a target — <name>[@<version>] moves one module's pin, --engine the engine's");
9
+ return await updateModules(ws, u, { open: openWorkspace });
18
10
  }