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,6 @@ import { fieldsOf, targetsOf } from "../record/descriptor.js";
5
5
  import { displayOf } from "../record/displayOf.js";
6
6
  import { ensureEditorRecommendation } from "./ensureEditorRecommendation.js";
7
7
  import { ensureEnvExample } from "./lib/ensureEnvExample.js";
8
- import { layerEntries } from "../workspace/layerEntries.js";
9
8
  import { namespaceProblems } from "./lib/namespaceProblems.js";
10
9
  import { normalizeNamespaces } from "../record/normalizeNamespaces.js";
11
10
  import { parseEnvValues } from "../workspace/parseEnvValues.js";
@@ -165,23 +164,21 @@ export const locationOf = (source, wsRoot) => path.resolve(source.root) === path
165
164
  // workspace's data/. The descriptor still says `data/<collection>`; compile is what turns
166
165
  // that into a path, so the module never names its host.
167
166
  /**
168
- * Why a module's clone could NOT hold records, or null when it can. Decided from the CHANNEL, never
167
+ * Why a module could NOT hold records, or null when it can. Decided from the CHANNEL, never
169
168
  * by asking git — compile shells out to git nowhere and must keep working in a freshly-`init`ed
170
169
  * directory that is not a repo yet. Asked by the module flag and by a descriptor's `storage.owner`
171
170
  * alike, so an npm module shipping an owned collection fails the same way.
172
171
  */
173
- function unownableBecause(source, rel) {
172
+ function unownableBecause(source) {
174
173
  if (source.channel === "npm")
175
- return `module "${source.name}" is installed under node_modules/ — that path is never committed, so its records could not be saved. Vendor it into modules/ or install it as a git module.`;
176
- if (source.channel === "git" && !fs.existsSync(path.join(source.root, ".git")))
177
- return `${rel(source.root)} is not a git clone — git_modules/ is gitignored by the workspace, so its records could never be committed.`;
174
+ return `module "${source.name}" is installed under node_modules/ — that path is never committed, so its records could not be saved. Vendor it into modules/.`;
178
175
  return null;
179
176
  }
180
177
  /**
181
178
  * modules whose collections default to `storage.owner: module` (`owns_data: true`), by module
182
179
  * name → {root, channel}. Records that could never be committed are a compile ERROR, not a silent zero.
183
180
  */
184
- function dataOwningModules(sources, fail, rel) {
181
+ function dataOwningModules(sources, fail) {
185
182
  const owners = new Map();
186
183
  for (const s of sources) {
187
184
  let mpkg;
@@ -196,38 +193,16 @@ function dataOwningModules(sources, fail, rel) {
196
193
  continue;
197
194
  if (flag !== true)
198
195
  fail(`module "${s.name}": "owns_data" must be true or false (got ${JSON.stringify(flag)})`);
199
- const why = unownableBecause(s, rel);
196
+ const why = unownableBecause(s);
200
197
  if (why)
201
198
  fail(`module "${s.name}" sets owns_data, but ${why}`);
202
199
  owners.set(s.name, { root: s.root, channel: s.channel });
203
200
  }
204
201
  return owners;
205
202
  }
206
- /**
207
- * A layer's data folder, from the clone's own manifest (its `data_path`), default `data`. The clone
208
- * may be absent — a fresh checkout before `dreamteamer install` — and then the default stands.
209
- */
210
- function layerDataPath(root, name) {
211
- try {
212
- return (JSON.parse(fs.readFileSync(path.join(root, "git_modules", name, "package.json"), "utf8")).dreamteamer
213
- ?.data_path ?? "data");
214
- }
215
- catch {
216
- return "data";
217
- }
218
- }
219
203
  function shadowWarning({ name, winner, loser }) {
220
204
  return `⚠ module ${name}: ${CHANNEL_LABEL[winner]} copy shadows ${CHANNEL_LABEL[loser]} copy`;
221
205
  }
222
- /** The `name` in a folder's package.json, or null — an absent clone or an unreadable file is unknown. */
223
- function pkgNameAt(dir) {
224
- try {
225
- return JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")).name ?? null;
226
- }
227
- catch {
228
- return null;
229
- }
230
- }
231
206
  export function compile(ws) {
232
207
  const { root, pkg } = ws;
233
208
  const extensions = ws.extensions ?? [];
@@ -270,9 +245,7 @@ export function compile(ws) {
270
245
  }
271
246
  };
272
247
  // discover sources: channel modules then the workspace's own
273
- const { modules: discovered, shadows, disabledModules, layerRefusals } = discoverModules(root, pkg);
274
- for (const r of layerRefusals)
275
- fail(r);
248
+ const { modules: discovered, shadows, disabledModules } = discoverModules(root, pkg);
276
249
  for (const s of shadows)
277
250
  console.warn(shadowWarning(s));
278
251
  const sources = [...discovered];
@@ -321,17 +294,6 @@ export function compile(ws) {
321
294
  // what every message in this engine already calls it. Defined HERE, above the namespace pass,
322
295
  // because a namespace error has to name the module by the id the fix is typed with.
323
296
  const moduleId = moduleIdOf;
324
- // A layer's workspace module (`module: true`) must answer to an id of its own: `default` is the ROLE
325
- // every workspace's own module carries, and an id another module holds would merge two modules' records.
326
- for (const s of sources.filter(x => x.layer)) {
327
- const at = `git_modules.${s.layer}.module`;
328
- const id = moduleId(s.name);
329
- if (id === "default")
330
- fail(`${at}: the clone's workspace module is "default" — the role name every workspace's own module carries, so it cannot be told apart from this one's. Name the project's module after the project (its workspace_module, and the folder under modules/).`);
331
- const other = sources.find(o => o !== s && moduleId(o.name) === id);
332
- if (other)
333
- fail(`${at}: the clone's workspace module "${id}" collides with module "${other.name}" at ${rel(other.root) || "."} — a module id names one module. Rename one of them.`);
334
- }
335
297
  const channelOf = new Map(sources.map(s => [s.name, s.channel]));
336
298
  const declaredEnv = new Map(); // env key -> [module names]
337
299
  const requestedVars = new Map(); // var a module READS through ${env:…} -> [module names]
@@ -347,7 +309,14 @@ export function compile(ws) {
347
309
  // the package.json `dreamteamer` block is a closed set of snake_case keys, the workspace's and
348
310
  // every module's alike — a key outside it is a typo or a spelling this engine does not read
349
311
  const refuseUnknownKeys = (block, where) => {
350
- const bad = Object.keys(block ?? {}).filter(k => !MANIFEST_KEYS.includes(k));
312
+ // git modules were removed: an empty map (what `init` used to seed) is only a stale key, a populated
313
+ // one is a workspace whose modules would silently stop compiling
314
+ if (block?.git_modules !== undefined) {
315
+ if (Object.keys(block.git_modules ?? {}).length)
316
+ fail(`${where}: dreamteamer.git_modules is no longer read — git modules were removed from the engine. Vendor each module into modules/<id> or install it from npm, then delete the key.`);
317
+ console.warn(`⚠ ${where}: dreamteamer.git_modules is no longer read — delete the empty key`);
318
+ }
319
+ const bad = Object.keys(block ?? {}).filter(k => k !== "git_modules" && !MANIFEST_KEYS.includes(k));
351
320
  // a kebab-case spelling of a key this engine reads is the v1 manifest: the converter rewrites it
352
321
  const v1 = v1ManifestRefusal(block, where);
353
322
  if (v1)
@@ -577,8 +546,7 @@ export function compile(ws) {
577
546
  ? [e.name]
578
547
  : []),
579
548
  ];
580
- const complete = !Object.keys(config.git_modules ?? {}).some(n => !fs.existsSync(path.join(root, "git_modules", n))) &&
581
- !Object.keys(pkg.dependencies ?? {}).some(n => !fs.existsSync(path.join(root, "node_modules", n, "package.json")));
549
+ const complete = !Object.keys(pkg.dependencies ?? {}).some(n => !fs.existsSync(path.join(root, "node_modules", n, "package.json")));
582
550
  const env = ensureEnvExample(root, [...byKey.values()], "# secrets for skills and modules go here (copy to .env; .env is never committed).\n# modules declare the env keys they require in their package.json dreamteamer.env list.\n", { keep, complete });
583
551
  if (env.added.length)
584
552
  console.log(`✔ .env.example now names ${env.added.join(", ")}`);
@@ -656,7 +624,7 @@ export function compile(ws) {
656
624
  }
657
625
  }
658
626
  // npm's `peerDependencies` naming ANOTHER discovered module is a VERSION FLOOR: npm refuses the install
659
- // below it, and this refuses the channels npm never saw — a git_modules clone, an inline copy, an
627
+ // below it, and this refuses the channels npm never saw — an inline copy, an
660
628
  // install that went around the peer check. An absent sibling is `dependencies`' business, not this one's.
661
629
  {
662
630
  const byName = new Map(sources.map(s => [s.name, s]));
@@ -693,21 +661,7 @@ export function compile(ws) {
693
661
  for (const mod of moduleDeps.keys())
694
662
  visit(mod, []);
695
663
  }
696
- const dataOwners = dataOwningModules(sources, fail, rel);
697
- let layers;
698
- try {
699
- layers = layerEntries(pkg, root).map(l => ({
700
- ...l,
701
- root: path.posix.join("git_modules", l.name),
702
- dataPath: layerDataPath(root, l.name),
703
- }));
704
- }
705
- catch (e) {
706
- fail(e.message);
707
- }
708
- for (const l of layers)
709
- if (!fs.existsSync(path.join(root, l.root)))
710
- console.warn(`⚠ layer ${l.name} (${l.root}) is not installed — its records are not read; run dreamteamer install`);
664
+ const dataOwners = dataOwningModules(sources, fail);
711
665
  const disabled = new Set(config.disable ?? []);
712
666
  const disabledHits = new Set(disabledModules); // bare entries were applied at discovery
713
667
  /** entries: runtime-relative path -> { sources: [workspace-relative], bytes } */
@@ -1028,13 +982,7 @@ export function compile(ws) {
1028
982
  const engineName = engineId().replace(/@[^@]*$/, "");
1029
983
  const wsDir = config.workspace_module;
1030
984
  const wsModuleName = wsDir ? sources.find(s => rel(s.root) === path.posix.join("modules", wsDir))?.name : pkg.name;
1031
- // a declared git module whose clone is absent is an UNINSTALLED workspace (a fresh clone), so a
1032
- // collection error there is named with the install, not left reading as a broken reference
1033
- const uninstalled = Object.keys(config.git_modules ?? {}).filter(n => !fs.existsSync(path.join(root, "git_modules", n)));
1034
- const collectionsFail = (msg) => fail(uninstalled.length
1035
- ? `${msg}\n run \`dreamteamer install\` first — dreamteamer.git_modules declares ${uninstalled.join(", ")}, and no clone of ${uninstalled.length === 1 ? "it" : "them"} is on disk yet`
1036
- : msg);
1037
- const { compiled: compiledColls, inert: inertSources, moduleColls, layerReads, } = compileCollections({
985
+ const { compiled: compiledColls, inert: inertSources, moduleColls, } = compileCollections({
1038
986
  groups: descriptorGroups,
1039
987
  mixins: mixinDocs,
1040
988
  namespaces,
@@ -1050,14 +998,12 @@ export function compile(ws) {
1050
998
  dataOwners,
1051
999
  moduleSources: new Map(sources.map(s => [s.name, s])),
1052
1000
  unownableBecause,
1053
- layers,
1054
1001
  repoOf: moduleRoot => repoRootOf(moduleRoot, root),
1055
1002
  rel,
1056
- root,
1057
1003
  dataPath: config.data_path ?? "data",
1058
1004
  vars: storageVars,
1059
1005
  moduleId,
1060
- fail: collectionsFail,
1006
+ fail,
1061
1007
  warn: m => console.warn(m),
1062
1008
  });
1063
1009
  refusePlacementTransitions(root, compiledColls);
@@ -1126,8 +1072,7 @@ export function compile(ws) {
1126
1072
  // §8: the namespaces THIS module declares — projected from its package.json, so
1127
1073
  // `dt list modules` answers "who owns hr?" without reading seven package.json files.
1128
1074
  ...(normalizeNamespaces(mpkg.namespaces).length ? { namespaces: normalizeNamespaces(mpkg.namespaces) } : {}),
1129
- // §10: the folder name, not an internal channel word. `dt status` then reads
1130
- // `hr git_modules @ 3f2a1c (dirty)` and needs no legend.
1075
+ // §10: the folder name, not an internal channel word, so `dt status` needs no legend.
1131
1076
  location: locationOf(source, root),
1132
1077
  path: rel(source.root) || ".",
1133
1078
  // The module's RUNNABLE entry points — `bin/<file>`, the folder NON_SOURCE_DIRS waves through.
@@ -1413,19 +1358,9 @@ export function compile(ws) {
1413
1358
  // `storage.base` is a field instead of a path test. An older runtime has no key here, which
1414
1359
  // reads as "no namespaces", which is exactly right for a workspace that never declared any.
1415
1360
  namespaces,
1416
- // What the record layer needs to judge an exports manifest (cr-dt-004) without reading package.json:
1417
- // this workspace's package name, and per layer its package name, data folder, the folders read from
1418
- // it and whether `records:` narrows it — completeness itself is judged at run time, on the disk.
1361
+ // What the record layer needs to judge an exports manifest (cr-dt-004) without reading package.json.
1419
1362
  package: pkg.name ?? null,
1420
1363
  data_path: config.data_path ?? "data",
1421
- layers: layers.map(l => ({
1422
- name: l.name,
1423
- root: l.root,
1424
- data: path.posix.join(l.root, l.dataPath),
1425
- package: pkgNameAt(path.join(root, l.root)),
1426
- reads: layerReads.get(l.name) ?? [],
1427
- narrowed: !!l.records || !!l.skipsSome,
1428
- })),
1429
1364
  // The extensions this runtime was compiled WITH, and the source kinds they staged — so the next
1430
1365
  // compile can prune a kind whose extension is gone, and `staleness` can walk a contributed kind
1431
1366
  // without loading any extension code.
@@ -11,7 +11,6 @@ export const MANIFEST_KEYS = [
11
11
  "env",
12
12
  "auto_commit",
13
13
  "harnesses",
14
- "git_modules",
15
14
  "disable",
16
15
  "local_assets",
17
16
  "postinstall",
@@ -84,7 +83,7 @@ export const V2_KEYS = [
84
83
  * `location` field's vocabulary — see collections/modules.collection.yaml. Keeping the export name
85
84
  * on purpose: renaming a symbol under src/ is a cross-repo change, and this one buys nothing.)
86
85
  */
87
- export const CHANNEL_LABEL = { inline: "modules", git: "git_modules", npm: "node_modules" };
86
+ export const CHANNEL_LABEL = { inline: "modules", npm: "node_modules" };
88
87
  // ⚠ A MANAGED MARKER INSIDE `dreamteamer.md` IS A REFUSAL, not something to escape around.
89
88
  // The file is rendered VERBATIM into a managed block, and `writeBlock` finds that block by the FIRST
90
89
  // occurrence of its begin marker anywhere in the file — so a marker quoted inside the rendered text
@@ -1,5 +1,5 @@
1
1
  import type { AuthoredDescriptor } from "../../types.js";
2
- import type { CompileLayer, CompiledCollection, DescriptorSource } from "../types.js";
2
+ import type { CompiledCollection, DescriptorSource } from "../types.js";
3
3
  import type { ModuleSource } from "../../workspace/types.js";
4
4
  import type { SourceRef } from "../types.js";
5
5
  interface CollectionsContext {
@@ -23,11 +23,9 @@ interface CollectionsContext {
23
23
  channel: string;
24
24
  }>;
25
25
  moduleSources: Map<string, ModuleSource>;
26
- unownableBecause: (source: ModuleSource, rel: (p: string) => string) => string | null;
27
- layers?: CompileLayer[];
26
+ unownableBecause: (source: ModuleSource) => string | null;
28
27
  repoOf: (moduleRoot: string) => string;
29
28
  rel: (p: string) => string;
30
- root?: string;
31
29
  dataPath: string;
32
30
  vars: {
33
31
  env: Map<string, string>;
@@ -49,13 +47,12 @@ interface CollectionsContext {
49
47
  * @param {Map<string,string[]>} ctx.moduleDeps
50
48
  * @param {Map<string,Record<string,string>>} [ctx.modulePresets] module preset name -> { member: exact version }; a dependency on a preset reaches its members
51
49
  * @param {Map<string,string[]>} ctx.modulePeers
52
- * @param {Map<string,string>} ctx.channelOf module name -> inline | git | npm
50
+ * @param {Map<string,string>} ctx.channelOf module name -> inline | npm
53
51
  * @param {string} ctx.wsModuleName
54
52
  * @param {string} ctx.engineName
55
53
  * @param {Map<string,{root}>} ctx.dataOwners owns-data modules — every collection defaults to `storage.owner: module`
56
54
  * @param {Map<string,{name,root,channel}>} ctx.moduleSources every module source, for a descriptor that names `storage.owner: module`
57
- * @param {(source: object, rel: Function) => string|null} ctx.unownableBecause why a module's clone cannot hold records, or null
58
- * @param {{name,root,dataPath,records:string[]|null}[]} ctx.layers record layers — clones whose data is read here; `records` narrows, null reads every collection both have
55
+ * @param {(source: object) => string|null} ctx.unownableBecause why a module cannot hold records, or null
59
56
  * @param {(moduleRoot: string) => string} ctx.repoOf workspace-relative git repo of a module root
60
57
  * @param {(p: string) => string} ctx.rel
61
58
  * @param {string} ctx.dataPath
@@ -69,6 +66,5 @@ export declare function compileCollections(ctx: CollectionsContext): {
69
66
  compiled: Map<string, CompiledCollection>;
70
67
  inert: SourceRef[];
71
68
  moduleColls: Map<string, Set<string>>;
72
- layerReads: Map<string, string[]>;
73
69
  };
74
70
  export {};
@@ -1,7 +1,6 @@
1
1
  import Ajv from "ajv";
2
2
  import addFormats from "ajv-formats";
3
3
  import path from "node:path";
4
- import fs from "node:fs";
5
4
  import { targetsOf } from "../../record/descriptor.js";
6
5
  import { baseNameOf, defaultStoragePath, inflects, namespaceOf } from "../../record/namespace.js";
7
6
  import { patternRe } from "../../record/records.js";
@@ -11,7 +10,6 @@ import { singular } from "../../lib/singular.js";
11
10
  import { storageOverlaps } from "./storageOverlaps.js";
12
11
  import { subpathProblem } from "./subpathProblem.js";
13
12
  import { toJsonSchema } from "./toJsonSchema.js";
14
- import { walk } from "../../lib/walk.js";
15
13
  import { isV2 } from "../isV2.js";
16
14
  import { mergeMixins } from "./mergeMixins.js";
17
15
  import { mergeOverlays } from "./mergeOverlays.js";
@@ -88,13 +86,12 @@ const titleCase = (id) => String(id)
88
86
  * @param {Map<string,string[]>} ctx.moduleDeps
89
87
  * @param {Map<string,Record<string,string>>} [ctx.modulePresets] module preset name -> { member: exact version }; a dependency on a preset reaches its members
90
88
  * @param {Map<string,string[]>} ctx.modulePeers
91
- * @param {Map<string,string>} ctx.channelOf module name -> inline | git | npm
89
+ * @param {Map<string,string>} ctx.channelOf module name -> inline | npm
92
90
  * @param {string} ctx.wsModuleName
93
91
  * @param {string} ctx.engineName
94
92
  * @param {Map<string,{root}>} ctx.dataOwners owns-data modules — every collection defaults to `storage.owner: module`
95
93
  * @param {Map<string,{name,root,channel}>} ctx.moduleSources every module source, for a descriptor that names `storage.owner: module`
96
- * @param {(source: object, rel: Function) => string|null} ctx.unownableBecause why a module's clone cannot hold records, or null
97
- * @param {{name,root,dataPath,records:string[]|null}[]} ctx.layers record layers — clones whose data is read here; `records` narrows, null reads every collection both have
94
+ * @param {(source: object) => string|null} ctx.unownableBecause why a module cannot hold records, or null
98
95
  * @param {(moduleRoot: string) => string} ctx.repoOf workspace-relative git repo of a module root
99
96
  * @param {(p: string) => string} ctx.rel
100
97
  * @param {string} ctx.dataPath
@@ -105,7 +102,7 @@ const titleCase = (id) => String(id)
105
102
  * @returns {{ compiled: Map<string, {doc, sources}>, inert: {path, hash}[], moduleColls: Map<string, Set<string>> }}
106
103
  */
107
104
  export function compileCollections(ctx) {
108
- const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePresets = new Map(), modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, layers = [], repoOf, dataPath, vars, moduleId, fail, warn, root = vars?.workspaceFolder ?? ".", } = ctx;
105
+ const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePresets = new Map(), modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, repoOf, dataPath, vars, moduleId, fail, warn, } = ctx;
109
106
  // What a module may reach: its dependencies and, for a dependency that is a MODULE PRESET (CR-dt-008),
110
107
  // the preset's members, flattened through nested presets (a seen-set stops a ring).
111
108
  const reachCache = new Map();
@@ -137,8 +134,6 @@ export function compileCollections(ctx) {
137
134
  const typeNames = new Set([...groups.keys(), ...core]);
138
135
  const allPeers = new Set([...modulePeers.values()].flat());
139
136
  const out = new Map();
140
- const layerClaims = new Map(); // layer name -> clone folders some collection here accounts for
141
- const layerReads = new Map(); // layer name -> clone folders some collection here READS (cr-dt-004); compiled sources never sit in a layer's data
142
137
  const inert = [];
143
138
  const moduleColls = new Map();
144
139
  const owners = new Map(); // collection -> owning module name
@@ -204,7 +199,7 @@ export function compileCollections(ctx) {
204
199
  let repo = ".";
205
200
  if (owner === "module" && !runtime) {
206
201
  const source = moduleSources.get(base.moduleName);
207
- const why = unownableBecause(source, ctx.rel);
202
+ const why = unownableBecause(source);
208
203
  if (why)
209
204
  fail(`collection "${name}" sets storage.owner: module, but ${why} (${where})`);
210
205
  const modRel = ctx.rel(source.root);
@@ -279,39 +274,6 @@ export function compileCollections(ctx) {
279
274
  if (format === "binary" && (a.shape ?? "file") === "folder")
280
275
  fail(`collection "${name}" is \`format: binary\` — one file per record, not a folder; drop \`shape: folder\` (${where})`);
281
276
  storageEntries.push({ name, path: storagePath, base: runtime ? "runtime" : "workspace" });
282
- // record layers: the listed clones' data folders, read BELOW the write root
283
- const collLayers = [];
284
- for (const l of layers) {
285
- // where this collection's records would sit in the clone — claimed, so the unread-folder
286
- // pass below never names a folder some collection here accounts for
287
- const at = `${l.root}/${a.path && !pointed && !runtime ? a.path : defaultStoragePath(name, namespaces, l.dataPath)}`;
288
- (layerClaims.get(l.name) ?? layerClaims.set(l.name, new Set()).get(l.name)).add(at);
289
- if (l.records && !l.records.includes(name))
290
- continue;
291
- const why = runtime
292
- ? "is a compiled source"
293
- : owner === "module"
294
- ? `is \`storage.owner: module\` — one shared list read from the module's clone, which a layer would duplicate`
295
- : a.under
296
- ? "is stored under another collection (storage.under) — a placed collection is not layered"
297
- : pointed
298
- ? "is env-pointed (its storage.path is a template) — its records are per machine, not a clone's"
299
- : null;
300
- if (why && l.records)
301
- fail(`git_modules.${l.name}.records names "${name}", which ${why}`);
302
- if (why) {
303
- if (!runtime)
304
- l.skipsSome = true; // a reader that skips one of the layer's collections never reads it completely (cr-dt-004); compiled sources never sit in a layer's data
305
- // an INHERENT layer reads every collection both have, so one that cannot layer is skipped —
306
- // said only when the clone actually holds records there, so a quiet compile stays quiet
307
- const n = fileCount(path.join(root, at));
308
- if (n)
309
- warn(`ℹ layer ${l.name}: ${name} is not read from the layer — it ${why} (${n} file${n === 1 ? "" : "s"} in ${at}/ unread)`);
310
- continue;
311
- }
312
- collLayers.push({ name: l.name, path: at, repo: l.root });
313
- (layerReads.get(l.name) ?? layerReads.set(l.name, []).get(l.name)).push(at);
314
- }
315
277
  // an opaque record's fields are the ones derived from the file itself
316
278
  const fields = { ...(authored.fields ?? {}) };
317
279
  if (format === "binary") {
@@ -326,8 +288,6 @@ export function compileCollections(ctx) {
326
288
  fields.bytes ??= { type: "integer", virtual: true, description: "The file's size in bytes. Read from the file." };
327
289
  }
328
290
  const { fields: resolved, errors, warnings, defaults: fieldDefaults, } = resolveFields(fields, { name, collections: typeNames, peers: allPeers, runtime });
329
- // a collection a reader can read from a layer: what `check` counts a referrer by (cr-dt-004); compiled sources never sit in a layer's data
330
- const layerable = !runtime && owner !== "module" && !a.under && !pointed;
331
291
  if (errors.length)
332
292
  fail(`collection "${name}" (${where}):\n ${errors.join("\n ")}`);
333
293
  for (const w of warnings)
@@ -449,8 +409,6 @@ export function compileCollections(ctx) {
449
409
  unresolved_peers: unresolved,
450
410
  fields: resolved,
451
411
  json_schema: jsonSchema,
452
- ...(collLayers.length ? { layers: collLayers } : {}),
453
- ...(layerable ? { layerable: true } : {}),
454
412
  ...(external ? { external: true } : {}),
455
413
  ...(unavailable ? { unavailable } : {}),
456
414
  },
@@ -459,18 +417,6 @@ export function compileCollections(ctx) {
459
417
  }
460
418
  for (const p of storageOverlaps(storageEntries))
461
419
  fail(p);
462
- for (const l of layers) {
463
- for (const c of l.records ?? [])
464
- if (!staged.has(c))
465
- fail(`git_modules.${l.name}.records names "${c}", which is not a collection here (have: ${[...staged.keys()].sort().join(", ")})`);
466
- }
467
- // A layer folder no collection here accounts for — the project's own domain collections, read by a
468
- // workspace that does not install their module — is WARNED, never failed: reading a project without
469
- // its domain module is legitimate, but its records silently not appearing is not.
470
- for (const l of layers)
471
- for (const [folder, n] of unreadFolders(root, `${l.root}/${l.dataPath}`, layerClaims.get(l.name) ?? new Set())) {
472
- warn(`⚠ layer ${l.name}: ${folder}/ holds ${n} file${n === 1 ? "" : "s"} and no collection here reads it — install the module that defines it to read them${l.records ? "" : ", or list the collections to read in git_modules." + l.name + ".records"}`);
473
- }
474
420
  {
475
421
  const words = new Map();
476
422
  for (const { name } of wordEntries)
@@ -488,7 +434,7 @@ export function compileCollections(ctx) {
488
434
  placement(out, fail);
489
435
  for (const [, c] of out)
490
436
  c.doc = { ...c.doc, compiled: c.compiled };
491
- return { compiled: out, inert, moduleColls, layerReads };
437
+ return { compiled: out, inert, moduleColls };
492
438
  }
493
439
  function relations(out, fail) {
494
440
  for (const [tName, t] of out) {
@@ -574,41 +520,3 @@ function placement(out, fail) {
574
520
  c.compiled.under_collection = parentName;
575
521
  }
576
522
  }
577
- /** How many files sit under a folder, recursively — 0 when it is absent. */
578
- function fileCount(dir) {
579
- if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory())
580
- return 0;
581
- let n = 0;
582
- for (const _ of walk(dir))
583
- n++;
584
- return n;
585
- }
586
- /**
587
- * `[folder, fileCount]` for each folder under a layer's data path that no claimed path accounts for:
588
- * a claimed folder is skipped, one that is a PREFIX of a claimed path (a namespace folder) is
589
- * descended into, anything else is unread. Paths are workspace-relative, `/`-joined.
590
- */
591
- function unreadFolders(root, dataDir, claimed) {
592
- const out = [];
593
- const visit = (rel) => {
594
- const abs = path.join(root, rel);
595
- if (!fs.existsSync(abs))
596
- return;
597
- for (const e of fs.readdirSync(abs, { withFileTypes: true }).sort((x, y) => x.name.localeCompare(y.name))) {
598
- if (!e.isDirectory() || e.name.startsWith("."))
599
- continue;
600
- const p = `${rel}/${e.name}`;
601
- if (claimed.has(p))
602
- continue;
603
- if ([...claimed].some(c => c.startsWith(`${p}/`))) {
604
- visit(p);
605
- continue;
606
- }
607
- const n = fileCount(path.join(root, p));
608
- if (n)
609
- out.push([p, n]);
610
- }
611
- };
612
- visit(dataDir);
613
- return out;
614
- }
@@ -5,15 +5,6 @@ export interface DescriptorSource {
5
5
  doc: AuthoredDescriptor;
6
6
  moduleName: string;
7
7
  }
8
- /** A record layer as compile reads it: the clone, its data folder, and the collections it narrows to (null: all). */
9
- export interface CompileLayer {
10
- name: string;
11
- root: string;
12
- dataPath: string;
13
- records: string[] | null;
14
- /** set by compile: some collection here skips one of the layer's, so it is never read completely */
15
- skipsSome?: boolean;
16
- }
17
8
  /** One collection compile resolved: the doc it writes, its resolved fields, its sources and storage facts. */
18
9
  export interface CompiledCollection {
19
10
  doc: AuthoredDescriptor & {
@@ -1,7 +1,7 @@
1
1
  import type { Store } from "../store/Store.js";
2
2
  import type { ExportChange } from "../record/types.js";
3
- /** The manifest `dt exports` would write for `repo` (null: this workspace) and what changes. */
4
- export declare function planExports(store: Store, repo: string | null): {
3
+ /** The manifest `dt exports` would write for this workspace, and what changes. */
4
+ export declare function planExports(store: Store): {
5
5
  dir: string;
6
6
  file: string;
7
7
  text: string | null;
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { serializeExports } from "./serializeExports.js";
3
- import { bodyFieldOf, recordTitleOf } from "../record/descriptor.js";
3
+ import { bodyFieldOf } from "../record/descriptor.js";
4
4
  import { EXPORTS_FILE } from "../record/consts.js";
5
5
  import { exportsContext } from "../record/exportsContext.js";
6
6
  import { outsideRefs } from "../record/outsideRefs.js";
@@ -9,20 +9,19 @@ import { parseRecord } from "../record/records.js";
9
9
  import { regenerate } from "../record/regenerate.js";
10
10
  import { storageOf } from "../record/storageOf.js";
11
11
  import { exportsFacts } from "../runtime/exportsFacts.js";
12
- /** The manifest `dt exports` would write for `repo` (null: this workspace) and what changes. */
13
- export function planExports(store, repo) {
12
+ /** The manifest `dt exports` would write for this workspace, and what changes. */
13
+ export function planExports(store) {
14
14
  const facts = exportsFacts(store.root);
15
15
  const ctx = exportsContext({
16
16
  root: store.root,
17
17
  descriptors: store.descriptors,
18
18
  own: facts.own,
19
- layers: facts.layers,
20
19
  dataPath: facts.data,
21
20
  });
22
21
  const readableD = (d) => d && !storageOf(d).runtime && !storageOf(d).unavailable;
23
22
  const readable = [...store.descriptors.values()].filter(readableD);
24
23
  // an unparseable record (a conflict mid-merge) is check's to report — skipped here, never fatal; while
25
- // one is unread, nothing it might name is dropped as unreferenced (the repo is not read completely)
24
+ // one is unread, nothing it might name is dropped as unreferenced (the workspace is not read completely)
26
25
  let unparsed = false;
27
26
  const fieldsAt = (d, file) => {
28
27
  try {
@@ -33,33 +32,19 @@ export function planExports(store, repo) {
33
32
  return null;
34
33
  }
35
34
  };
36
- const repoOf = (c, id) => {
37
- const d = store.descriptors.get(c);
38
- const f = readableD(d) ? store.ids(c).get(id) : undefined;
39
- return f ? (store.layerOfFile(d, f)?.layer ?? null) : undefined;
40
- };
41
- const titled = (d, id, file) => {
42
- if (storageOf(d).format === "binary")
43
- return id;
44
- const t = /\{\{\s*([A-Za-z_][\w]*)/.exec(recordTitleOf(d))?.[1];
45
- return String(fieldsAt(d, file)?.[t] ?? id);
46
- };
35
+ const held = (c, id) => readableD(store.descriptors.get(c)) && store.ids(c).has(id);
47
36
  const records = readable.flatMap(d => [...store.ids(d.name)]
48
- .filter(([id]) => repoOf(d.name, id) === repo && storageOf(d).format !== "binary")
37
+ .filter(() => storageOf(d).format !== "binary")
49
38
  .map(([id, file]) => ({ collection: d.name, id, descriptor: d, fields: fieldsAt(d, file) }))
50
39
  .filter(r => r.fields));
51
- const resolve = (c, id) => repoOf(c, id) === undefined
52
- ? null
53
- : { label: titled(store.descriptors.get(c), id, store.ids(c).get(id)), from: ctx.packageOf(repoOf(c, id)) };
54
- const held = (c, id) => repoOf(c, id) === repo;
55
- const dir = ctx.rootOf(repo);
40
+ const dir = store.root;
56
41
  const current = readExports(dir); // throws on an unparseable file, naming it — never overwritten
57
- const outside = outsideRefs({ records, held, resolve, namespaces: store.namespaces });
42
+ // an outside reference is one no record here holds, so nothing here resolves it
43
+ const outside = outsideRefs({ records, held, resolve: () => null, namespaces: store.namespaces });
58
44
  const { next, changes } = regenerate({
59
45
  current: current ?? {},
60
46
  outside,
61
47
  ctx: unparsed ? { ...ctx, complete: () => false } : ctx,
62
- repo,
63
48
  held,
64
49
  });
65
50
  return {
@@ -1,7 +1,6 @@
1
1
  import type { Store } from "../store/Store.js";
2
- /** Write (and commit) each named repo's manifest; returns the exit code. */
3
- export declare function runExports(store: Store, { layers, dryRun, json }?: {
4
- layers?: string[];
2
+ /** Write (and commit) this workspace's manifest; returns the exit code. */
3
+ export declare function runExports(store: Store, { dryRun, json }?: {
5
4
  dryRun?: boolean;
6
5
  json?: boolean;
7
6
  }): number;