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
@@ -1,19 +1,19 @@
1
1
  import { sees } from "./sees.js";
2
2
  /**
3
- * The manifest `dt exports` would write for `repo` in this context, and why — design §3's rules:
3
+ * The manifest `dt exports` would write in this context, and why — design §3's rules:
4
4
  * add an outside reference that resolves here; refresh a label only where the entry's holder is seen
5
5
  * and still has the id (its `from` never changes); fill a holder-less entry whose id resolves here;
6
- * drop an entry for an id the repo now holds, one whose seen holder lost the id, and — only where this
7
- * context reads every record of the repo — one nothing references; keep everything else as written.
6
+ * drop an entry for an id the workspace now holds, one whose seen holder lost the id, and — only where this
7
+ * context reads every record of the workspace — one nothing references; keep everything else as written.
8
8
  */
9
- export function regenerate({ current, outside, ctx, repo, held, }) {
9
+ export function regenerate({ current, outside, ctx, held, }) {
10
10
  const next = {};
11
11
  const changes = [];
12
12
  const put = (c, id, e) => {
13
13
  ;
14
14
  (next[c] ??= {})[id] = e;
15
15
  };
16
- const complete = ctx.complete(repo);
16
+ const complete = ctx.complete();
17
17
  for (const [c, ids] of Object.entries(current ?? {})) {
18
18
  for (const [id, e] of Object.entries(ids)) {
19
19
  const ref = `${c}/${id}`;
@@ -1,6 +1,6 @@
1
1
  import type { ExportEntry, ExportsContext } from "./types.js";
2
2
  /**
3
- * Does this context read the entry's holder for its collection — a root of that collection, on disk,
4
- * whose package is the entry's `from`? An entry with no holder is seen by no context.
3
+ * Does this context read the entry's holder for its collection — is the holder this workspace, and does
4
+ * it have the collection? An entry with no holder is seen by no context.
5
5
  */
6
6
  export declare function sees(entry: ExportEntry | null | undefined, coll: string, ctx: ExportsContext): boolean;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Does this context read the entry's holder for its collection — a root of that collection, on disk,
3
- * whose package is the entry's `from`? An entry with no holder is seen by no context.
2
+ * Does this context read the entry's holder for its collection — is the holder this workspace, and does
3
+ * it have the collection? An entry with no holder is seen by no context.
4
4
  */
5
5
  export function sees(entry, coll, ctx) {
6
- return !!entry?.from && ctx.rootsOf(coll).some(r => r.present && r.package === entry.from);
6
+ return !!entry?.from && entry.from === ctx.own && ctx.reads(coll);
7
7
  }
@@ -16,13 +16,7 @@ export function storageOf(d) {
16
16
  // then still the template, and a reader refuses or skips rather than touching a literal folder.
17
17
  external: block(d).external === true,
18
18
  unavailable: block(d).unavailable ?? null,
19
- }; // layers/roots are set just below
20
- // write root first, then each record layer (a clone whose listed collections are read here)
21
- out.layers = (block(d).layers ?? []).map(l => ({ name: l.name, path: l.path, repo: l.repo }));
22
- out.roots = [
23
- { path: out.path, repo: out.repo },
24
- ...out.layers.map(l => ({ path: l.path, repo: l.repo, layer: l.name })),
25
- ];
19
+ };
26
20
  if (a.entry !== undefined)
27
21
  out.entry = a.entry;
28
22
  if (a.max_bytes !== undefined)
@@ -3,18 +3,15 @@ export interface ExportEntry {
3
3
  label: string;
4
4
  from?: string;
5
5
  }
6
- /** A collection root as one context sees it: its layer (null: the write root), its package, whether it is on disk. */
7
- export interface ContextRoot {
8
- layer: string | null;
9
- package: string | null;
10
- present: boolean;
11
- }
12
6
  export interface ExportsContext {
7
+ /** this workspace's package name */
13
8
  own: string | null;
14
- rootsOf: (coll: string) => ContextRoot[];
15
- complete: (layer: string | null) => boolean;
16
- packageOf: (layer: string | null) => string | null;
17
- rootOf: (layer: string | null) => string;
9
+ /** this workspace's root — where its exports manifest sits */
10
+ root: string;
11
+ /** does this workspace have the collection */
12
+ reads: (coll: string) => boolean;
13
+ /** is every record under the data folder read by some collection here */
14
+ complete: () => boolean;
18
15
  }
19
16
  export interface OutsideRef {
20
17
  collection: string;
@@ -9,7 +9,7 @@ export declare function assertInRepo(descriptor: Descriptor, collection: string,
9
9
  * `git log` for a record, newest first. `--follow` (so a rename keeps its past) only applies to a
10
10
  * single pathspec — git rejects it outright with several — so a layered record trades it away.
11
11
  */
12
- /** The repo a record's file is committed in: a module-owned or layer record's past is in that clone. */
12
+ /** The repo a record's file is committed in: a module-owned record's past is in that module's repo. */
13
13
  export declare const repoOf: (store: Store, descriptor: Descriptor, file: string) => string;
14
14
  export declare function history(store: Store, collection: string, id: string): {
15
15
  hash: string;
@@ -15,7 +15,7 @@ const FORMAT = "%H%x00%an%x00%aI%x00%s";
15
15
  * `git log` for a record, newest first. `--follow` (so a rename keeps its past) only applies to a
16
16
  * single pathspec — git rejects it outright with several — so a layered record trades it away.
17
17
  */
18
- /** The repo a record's file is committed in: a module-owned or layer record's past is in that clone. */
18
+ /** The repo a record's file is committed in: a module-owned record's past is in that module's repo. */
19
19
  export const repoOf = (store, descriptor, file) => path.resolve(store.root, store.repoOfFile(descriptor, file));
20
20
  export function history(store, collection, id) {
21
21
  const { file } = store.read(collection, id), descriptor = store.descriptor(collection);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * What a write on an EXISTING record adds to its `✔` line: nothing in the workspace's own repo; the
3
- * repo when it is another clone (a layer, a module's list); and that it is never committed when the
3
+ * repo when it is another one (a module's list); and that it is never committed when the
4
4
  * root is outside every repo here. The workspace name alone used to be printed wherever it landed.
5
5
  */
6
6
  export declare function landedIn(where: {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * What a write on an EXISTING record adds to its `✔` line: nothing in the workspace's own repo; the
3
- * repo when it is another clone (a layer, a module's list); and that it is never committed when the
3
+ * repo when it is another one (a module's list); and that it is never committed when the
4
4
  * root is outside every repo here. The workspace name alone used to be printed wherever it landed.
5
5
  */
6
6
  export function landedIn(where) {
@@ -62,8 +62,8 @@ export function recordsCommand(ws, store, collection, verb, flags, pos) {
62
62
  }
63
63
  case "get": {
64
64
  const id = need(pos, 0, "id");
65
- // an id no root holds that an exports manifest vouches for (cr-dt-004): named, and still exit 1
66
- const ext = store.external(collection, id, { referrer: flags.referrer });
65
+ // an id no record holds that the exports manifest vouches for (cr-dt-004): named, and still exit 1
66
+ const ext = store.external(collection, id);
67
67
  if (ext) {
68
68
  if (flags.json)
69
69
  emit(JSON.stringify({ $external: { collection, id, ...ext } }, null, 2));
@@ -1,6 +1,5 @@
1
1
  import path from "node:path";
2
- // A `repos` record declares a related git repo and NOTHING about the schema — the other half of
3
- // what git_modules fuses together. Modules stay in package.json because compile can't read records
4
- // until they're restored (no .dreamteamer → no schemas → no readable records); attached repos have
5
- // no such constraint, so they get to be data.
2
+ // A `repos` record declares a related git repo and NOTHING about the schema. Modules stay in
3
+ // package.json because compile can't read records until they're installed (no .dreamteamer → no
4
+ // schemas → no readable records); attached repos have no such constraint, so they get to be data.
6
5
  export const relPath = (root, p) => path.relative(root, p) || ".";
@@ -20,7 +20,7 @@ export function materializeRepo(ws, id, fields) {
20
20
  fs.mkdirSync(path.dirname(dest), { recursive: true });
21
21
  console.log(`… cloning ${fields.url} → ${rp} (${ref})`);
22
22
  execFileSync("git", ["clone", "--branch", ref, fields.url, dest], { stdio: "inherit" });
23
- // NO buildClone() here, unlike install(): a prototype or app repo is not an npm module and
23
+ // NO npm install here: a prototype or app repo is not an npm module and
24
24
  // must never have `npm install` run in it as a side effect of being materialized.
25
25
  return { id, path: rp, present: true, cloned: true, ref };
26
26
  }
@@ -1,17 +1,5 @@
1
- /**
2
- * What compile recorded for the exports manifest (cr-dt-004): this workspace's package name and data
3
- * folder, and per layer `{ name, root, data, package, reads, narrowed }` — `layers: null` from a runtime
4
- * older than them, which a caller reads as "nothing is known".
5
- */
1
+ /** What compile recorded for the exports manifest (cr-dt-004): this workspace's package name and data folder. */
6
2
  export declare function exportsFacts(root: string): {
7
3
  own: string | null;
8
4
  data: string;
9
- layers: {
10
- name: string;
11
- root: string;
12
- data: string;
13
- package: string | null;
14
- reads: string[];
15
- narrowed: boolean;
16
- }[] | null;
17
5
  };
@@ -1,10 +1,6 @@
1
1
  import { readManifest } from "./runtime.js";
2
- /**
3
- * What compile recorded for the exports manifest (cr-dt-004): this workspace's package name and data
4
- * folder, and per layer `{ name, root, data, package, reads, narrowed }` — `layers: null` from a runtime
5
- * older than them, which a caller reads as "nothing is known".
6
- */
2
+ /** What compile recorded for the exports manifest (cr-dt-004): this workspace's package name and data folder. */
7
3
  export function exportsFacts(root) {
8
4
  const m = readManifest(root);
9
- return { own: m?.package ?? null, data: m?.data_path ?? "data", layers: m?.layers ?? null };
5
+ return { own: m?.package ?? null, data: m?.data_path ?? "data" };
10
6
  }
@@ -11,14 +11,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
11
11
  // exports manifest, `dreamteamer-exports.json`, and delete the stub (cr-dt-004). Run it once per workspace
12
12
  // that holds or reads stubs, on engine 0.45.0, right after `dt compile`:
13
13
  //
14
- // node node_modules/dreamteamer/dist/scripts/migrate-stubs.js --root <workspace> [--layers] [--dry-run]
14
+ // node node_modules/dreamteamer/dist/scripts/migrate-stubs.js --root <workspace> [--dry-run]
15
15
  //
16
- // --layers also migrates every installed record layer's stubs, from this workspace's view — so an entry
17
- // gets the live label and holder of a record this workspace reads. Per stub: an entry when a record of its
18
- // repo names the id, or when this workspace does not read that repo completely (it cannot know, so it never
19
- // deletes without an entry); label and holder from a non-stub claimant of the id in any root read here,
20
- // else the stub's own title and no holder; then the repo's manifest is regenerated exactly as `dt exports`
21
- // would, and ONE commit per repo holds the manifest and the deleted stubs. --dry-run writes nothing.
16
+ // Per stub: an entry when a record of the workspace names the id, or when this workspace does not read its
17
+ // data completely (it cannot know, so it never deletes without an entry); the label is the stub's own title,
18
+ // with no holder; then the manifest is regenerated exactly as `dt exports` would, and ONE commit holds the
19
+ // manifest and the deleted stubs. --dry-run writes nothing.
22
20
  import { execFileSync } from "node:child_process";
23
21
  import fs from "node:fs";
24
22
  import path from "node:path";
@@ -42,25 +40,24 @@ const { outsideRefs } = await engine("record/outsideRefs");
42
40
  const { planExports } = await engine("exports/planExports");
43
41
  const isStubText = (text) => /^stub:\s*true\s*$/m.test(/^---\n([\s\S]*?)\n---(?:\n|$)/.exec(text)?.[1] ?? "");
44
42
  const title = (d, fields, id) => String(fields[/\{\{\s*([A-Za-z_][\w]*)/.exec(recordTitleOf(d))?.[1]] ?? id);
45
- /** Every record file of `repo` (null: the workspace), per collection: `[{ d, id, file, stub }]`. */
46
- function filesOf(store, repo) {
43
+ /** Every record file of the workspace, per collection: `[{ d, id, file, stub }]`. */
44
+ function filesOf(store) {
47
45
  const out = [];
48
46
  for (const d of store.descriptors.values()) {
49
47
  if (storageOf(d).runtime || storageOf(d).unavailable || storageOf(d).format === "binary")
50
48
  continue;
51
- for (const r of store.rootsOf(d)) {
52
- if ((r.layer ?? null) !== repo || !fs.existsSync(r.abs))
53
- continue;
54
- for (const file of walk(r.abs)) {
55
- const id = idFromRecordPath(d, path.relative(r.abs, file).split(path.sep).join("/"));
56
- if (id !== null)
57
- out.push({ d, id, file, stub: isStubText(fs.readFileSync(file, "utf8")) });
58
- }
49
+ const dir = store.dir(d);
50
+ if (!fs.existsSync(dir))
51
+ continue;
52
+ for (const file of walk(dir)) {
53
+ const id = idFromRecordPath(d, path.relative(dir, file).split(path.sep).join("/"));
54
+ if (id !== null)
55
+ out.push({ d, id, file, stub: isStubText(fs.readFileSync(file, "utf8")) });
59
56
  }
60
57
  }
61
58
  return out;
62
59
  }
63
- export function migrate(root, { layers = false, dryRun = false, log = console.log, } = {}) {
60
+ export function migrate(root, { dryRun = false, log = console.log } = {}) {
64
61
  const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
65
62
  const store = new Store({ root, pkg });
66
63
  const facts = exportsFacts(root);
@@ -68,20 +65,12 @@ export function migrate(root, { layers = false, dryRun = false, log = console.lo
68
65
  root,
69
66
  descriptors: store.descriptors,
70
67
  own: facts.own,
71
- layers: facts.layers,
72
68
  dataPath: facts.data,
73
69
  });
74
- const repos = [
75
- null,
76
- ...(layers ? (facts.layers ?? []).filter(l => fs.existsSync(path.join(root, l.root))).map(l => l.name) : []),
77
- ];
78
- const all = new Map(repos.map(repo => [repo, filesOf(store, repo)]));
79
70
  const report = [];
80
- for (const repo of repos) {
81
- const files = all.get(repo);
82
- const stubs = files.filter(f => f.stub);
83
- if (!stubs.length)
84
- continue;
71
+ const files = filesOf(store);
72
+ const stubs = files.filter(f => f.stub);
73
+ if (stubs.length) {
85
74
  const own = files
86
75
  .filter(f => !f.stub)
87
76
  .map(f => ({
@@ -91,8 +80,8 @@ export function migrate(root, { layers = false, dryRun = false, log = console.lo
91
80
  fields: parseRecord(f.file, f.d, bodyFieldOf(f.d)),
92
81
  }));
93
82
  const named = outsideRefs({ records: own, held: () => false, resolve: () => null, namespaces: store.namespaces });
94
- const complete = ctx.complete(repo);
95
- const entries = readExports(ctx.rootOf(repo)) ?? {};
83
+ const complete = ctx.complete();
84
+ const entries = readExports(root) ?? {};
96
85
  const rows = [];
97
86
  for (const s of stubs) {
98
87
  const ref = `${s.d.name}/${s.id}`;
@@ -101,54 +90,48 @@ export function migrate(root, { layers = false, dryRun = false, log = console.lo
101
90
  rows.push({ ref, fate: "deleted — nothing in its repo references it" });
102
91
  continue;
103
92
  }
104
- const real = [...all.values()].flat().find(f => !f.stub && f.d.name === s.d.name && f.id === s.id);
105
- const e = real
106
- ? {
107
- label: title(real.d, parseRecord(real.file, real.d, bodyFieldOf(real.d)), s.id),
108
- from: ctx.packageOf(store.layerOfFile(real.d, real.file)?.layer ?? null),
109
- }
110
- : { label: title(s.d, parseRecord(s.file, s.d, bodyFieldOf(s.d)), s.id) };
93
+ const e = { label: title(s.d, parseRecord(s.file, s.d, bodyFieldOf(s.d)), s.id) };
111
94
  (entries[s.d.name] ??= {})[s.id] = entries[s.d.name][s.id] ?? e;
112
95
  rows.push({
113
96
  ref,
114
97
  fate: `entry ${JSON.stringify(e)}${referrers.length ? ` — named by ${referrers.slice(0, 3).join(", ")}${referrers.length > 3 ? ` +${referrers.length - 3}` : ""}` : " — kept: this workspace does not read the repo completely"}`,
115
98
  });
116
99
  }
117
- const dir = ctx.rootOf(repo);
118
- log(`${repo ?? "this workspace"} · ${stubs.length} stub${stubs.length === 1 ? "" : "s"}${dryRun ? " (dry run — nothing written)" : ""}`);
100
+ const dir = root;
101
+ log(`this workspace · ${stubs.length} stub${stubs.length === 1 ? "" : "s"}${dryRun ? " (dry run — nothing written)" : ""}`);
119
102
  for (const r of rows)
120
103
  log(` ${r.ref} — ${r.fate}`);
121
- report.push({ repo, rows });
122
- if (dryRun)
123
- continue;
124
- for (const s of stubs)
125
- fs.rmSync(s.file);
126
- fs.writeFileSync(path.join(dir, EXPORTS_FILE), serializeExports(entries) ?? "{}\n");
127
- const plan = planExports(new Store({ root, pkg }), repo); // as dt exports would, on the migrated tree
128
- if (plan.text === null)
129
- fs.rmSync(plan.file, { force: true });
130
- else
131
- fs.writeFileSync(plan.file, plan.text);
132
- const git = (args) => execFileSync("git", args, { cwd: dir, stdio: ["ignore", "pipe", "pipe"] })
133
- .toString()
134
- .trim();
135
- // the manifest only when there is one or git tracks one: all-unreferenced stubs leave none to add
136
- const tracked = git(["ls-files", "--", EXPORTS_FILE]) !== "";
137
- const paths = [
138
- ...(tracked || fs.existsSync(path.join(dir, EXPORTS_FILE)) ? [EXPORTS_FILE] : []),
139
- ...stubs.map(s => path.relative(dir, s.file)),
140
- ];
141
- git(["add", "-A", "--", ...paths]);
142
- git([
143
- "commit",
144
- "--only",
145
- "-q",
146
- "-m",
147
- `dreamteamer: migrate ${stubs.length} stub record(s) to ${EXPORTS_FILE}`,
148
- "--",
149
- ...paths,
150
- ]);
151
- log(` ✔ committed ${git(["rev-parse", "--short", "HEAD"])}`);
104
+ report.push({ repo: null, rows });
105
+ if (!dryRun) {
106
+ for (const s of stubs)
107
+ fs.rmSync(s.file);
108
+ fs.writeFileSync(path.join(dir, EXPORTS_FILE), serializeExports(entries) ?? "{}\n");
109
+ const plan = planExports(new Store({ root, pkg })); // as dt exports would, on the migrated tree
110
+ if (plan.text === null)
111
+ fs.rmSync(plan.file, { force: true });
112
+ else
113
+ fs.writeFileSync(plan.file, plan.text);
114
+ const git = (args) => execFileSync("git", args, { cwd: dir, stdio: ["ignore", "pipe", "pipe"] })
115
+ .toString()
116
+ .trim();
117
+ // the manifest only when there is one or git tracks one: all-unreferenced stubs leave none to add
118
+ const tracked = git(["ls-files", "--", EXPORTS_FILE]) !== "";
119
+ const paths = [
120
+ ...(tracked || fs.existsSync(path.join(dir, EXPORTS_FILE)) ? [EXPORTS_FILE] : []),
121
+ ...stubs.map(s => path.relative(dir, s.file)),
122
+ ];
123
+ git(["add", "-A", "--", ...paths]);
124
+ git([
125
+ "commit",
126
+ "--only",
127
+ "-q",
128
+ "-m",
129
+ `dreamteamer: migrate ${stubs.length} stub record(s) to ${EXPORTS_FILE}`,
130
+ "--",
131
+ ...paths,
132
+ ]);
133
+ log(` ✔ committed ${git(["rev-parse", "--short", "HEAD"])}`);
134
+ }
152
135
  }
153
136
  if (!report.length)
154
137
  log("no stub records found");
@@ -159,7 +142,6 @@ if (import.meta.url === `file://${process.argv[1]}`) {
159
142
  const at = argv.indexOf("--root");
160
143
  try {
161
144
  migrate(path.resolve(at >= 0 ? argv[at + 1] : "."), {
162
- layers: argv.includes("--layers"),
163
145
  dryRun: argv.includes("--dry-run"),
164
146
  });
165
147
  }
@@ -1,15 +1,12 @@
1
1
  import path from "node:path";
2
2
  import fs from "node:fs";
3
- import { execFileSync } from "node:child_process";
4
3
  import { Store } from "./store/Store.js";
5
4
  import { commitPending } from "./changes/commitPending.js";
6
- import { declaredGitModules } from "./workspace/declaredGitModules.js";
7
5
  import { emit } from "./lib/emit.js";
8
- import { layerEntries } from "./workspace/layerEntries.js";
9
6
  import { storageOf } from "./record/storageOf.js";
10
7
  import { renderStatusLines } from "./setup/renderStatusLines.js";
11
8
  import { statusLines } from "./setup/statusLines.js";
12
- import { locationOf, moduleIdOf } from "./compile/compile.js";
9
+ import { locationOf } from "./compile/compile.js";
13
10
  import { CHANNEL_LABEL } from "./compile/consts.js";
14
11
  import { describeCheckout } from "./lib/git/describeCheckout.js";
15
12
  import { discoverModules } from "./workspace/discoverModules.js";
@@ -61,8 +58,7 @@ export function statusCommand(ws, rest) {
61
58
  const presets = presetMembers(ws);
62
59
  console.log("modules:");
63
60
  for (const m of modules) {
64
- // §10: the folder name IS the label. `hr git_modules @ 3f2a1c (dirty)` needs no
65
- // legend, and `[inline]` needed one every single time.
61
+ // §10: the folder name IS the label — `[inline]` needed a legend every single time.
66
62
  let line = ` ${m.name.padEnd(20)} ${locationOf(m, ws.root)}`;
67
63
  // a development link (a folder spec): never pinned, skipped by update
68
64
  try {
@@ -74,15 +70,6 @@ export function statusCommand(ws, rest) {
74
70
  catch {
75
71
  /* not under node_modules */
76
72
  }
77
- if (m.channel === "git") {
78
- const ref = tryGit(m.root, ["rev-parse", "--short", "HEAD"]);
79
- const dirty = tryGit(m.root, ["status", "--porcelain"]);
80
- // ⚠ A SCHEMA WRITE NOW COMMITS HERE (§9), so a clone can be ahead of its remote
81
- // with work the operator does not know they are holding. `status` is the command
82
- // they run when something feels wrong, so it is where the count belongs.
83
- const ahead = tryGit(m.root, ["rev-list", "--count", "HEAD", "--not", "--remotes"]);
84
- line += ` @ ${ref ?? "?"}${dirty ? " (dirty)" : ""}${Number(ahead) > 0 ? ` — ahead ${ahead}, push when ready` : ""}`;
85
- }
86
73
  const sh = shadowed.get(m.name);
87
74
  if (sh)
88
75
  line += ` — shadows ${CHANNEL_LABEL[sh.loser]} copy`;
@@ -100,52 +87,6 @@ export function statusCommand(ws, rest) {
100
87
  console.log(` ${x.name} ${x.installed} (preset ${p.id} names ${x.pinned})`);
101
88
  }
102
89
  }
103
- // record layers: other workspaces cloned here for their records. The collections listed are
104
- // the ones FOUND — compiled with this layer as a root and holding a folder in the clone —
105
- // never the declared `records:`, which narrows and may name a folder that does not exist.
106
- const layers = layerEntries(ws.pkg, ws.root);
107
- if (layers.length) {
108
- console.log("layers:");
109
- let descriptors = [];
110
- try {
111
- descriptors = [...new Store(ws).descriptors.values()];
112
- }
113
- catch {
114
- /* no runtime yet */
115
- }
116
- // a layer a clone needed says so (`via`); one this workspace's declaration overrides says whom; a
117
- // copy nested under a clone, or a clone of its own where a link would be, is drawn under its clone
118
- const declared = declaredGitModules(ws.pkg, ws.root);
119
- const under = (by) => [
120
- ...declared.nested
121
- .filter(c => c.by === by)
122
- .map(c => {
123
- const d = path.join(ws.root, by, "git_modules", c.name);
124
- return ` ↳ ${c.name} nested @ ${tryGit(d, ["rev-parse", "--short", "HEAD"]) ?? "?"} — ${c.url} (${c.ref}); git_modules/${c.name} is ${c.top.url} (${c.top.ref})`;
125
- }),
126
- ...[...declared.map]
127
- .filter(([n, m]) => m.declarers.includes(by) && isOwnClone(path.join(ws.root, by, "git_modules", n)))
128
- .map(([n]) => ` ↳ ${n} its own clone @ ${tryGit(path.join(ws.root, by, "git_modules", n), ["rev-parse", "--short", "HEAD"]) ?? "?"}, not a link to git_modules/${n}`),
129
- ];
130
- for (const l of layers) {
131
- const over = declared.mismatches.filter(m => m.name === l.name);
132
- const asked = over.length
133
- ? ` · overrides ${over.map(m => `${m.by} (${m.what} ${m.theirs})`).join(", ")}`
134
- : l.via.length
135
- ? ` · via ${l.via.join(", ")}`
136
- : "";
137
- const dir = path.join(ws.root, "git_modules", l.name);
138
- const ref = fs.existsSync(dir) ? tryGit(dir, ["rev-parse", "--short", "HEAD"]) : null;
139
- const mod = l.module ? modules.find(m => m.layer === l.name) : null;
140
- const found = descriptors
141
- .filter(d => storageOf(d).roots.some(r => r.layer === l.name && fs.existsSync(path.join(ws.root, r.path))))
142
- .map(d => d.name)
143
- .sort();
144
- console.log(` ${l.name.padEnd(20)} ${ref ? `git_modules @ ${ref}${tryGit(dir, ["status", "--porcelain"]) ? " (dirty)" : ""}` : "not installed — dreamteamer install"} · records: ${found.join(", ") || "(none found)"}${l.module ? ` · module ${mod ? moduleIdOf(mod.name) : "-"}` : ""}${asked}`);
145
- for (const line of under(`git_modules/${l.name}`))
146
- console.log(line);
147
- }
148
- }
149
90
  // env-pointed roots (`storage.path: ${env:NAME}/…`), rendered per machine by compile: the
150
91
  // folder a record of each lands in on THIS machine, or why it cannot. Wrapped like the
151
92
  // blocks below — status is the command run when things are already wrong.
@@ -225,25 +166,3 @@ export function statusCommand(ws, rest) {
225
166
  console.log("✔ .dreamteamer is fresh");
226
167
  return 0;
227
168
  }
228
- /**
229
- * git calls whose failure we CATCH must not print git's own error: execFileSync forwards the
230
- * child's stderr to ours unless told otherwise, so a handled "not a git repository" still
231
- * reached the user's terminal. stdout stays piped because we read it.
232
- */
233
- const QUIET = ["ignore", "pipe", "ignore"];
234
- function tryGit(cwd, args) {
235
- try {
236
- return execFileSync("git", args, { cwd, stdio: QUIET }).toString().trim() || null;
237
- }
238
- catch {
239
- return null;
240
- }
241
- }
242
- const isOwnClone = (p) => {
243
- try {
244
- return !fs.lstatSync(p).isSymbolicLink() && fs.existsSync(path.join(p, ".git"));
245
- }
246
- catch {
247
- return false;
248
- }
249
- };
@@ -2,7 +2,7 @@ import Ajv from "ajv";
2
2
  import { relationsOf } from "../record/relationsOf.js";
3
3
  import type { Under } from "../record/types.js";
4
4
  import type { Descriptor, Descriptors, Fields } from "../types.js";
5
- import type { ResolvedRoot, RewriteResult, RelocatePlan, Undo } from "./types.js";
5
+ import type { RewriteResult, RelocatePlan, Undo } from "./types.js";
6
6
  export declare class Store {
7
7
  root: string;
8
8
  runtime: string;
@@ -105,30 +105,18 @@ export declare class Store {
105
105
  * it is stored under one. What `commit` scopes `git status` to and what a surface asks git about.
106
106
  */
107
107
  recordDirs(d: Descriptor): string[];
108
- /**
109
- * Every root a record of `d` can be READ from, write root first, then each record layer — another
110
- * workspace cloned under git_modules/ whose manifest entry lists this collection.
111
- */
112
- rootsOf(d: Descriptor): ResolvedRoot[];
113
- /** Does a record layer contribute to `d`? Such a collection is indexed across every root. */
114
- layered(d: Descriptor): boolean;
115
108
  /**
116
109
  * The file an owner in `ownerRepo` keeps the mirror of `collection/id` in: the record that answers
117
110
  * the id when it sits in that repo, else null (the id is another repo's, and mirrors stay per repo). The one place the choice is made — the mirror
118
111
  * pass writes it and rm's guard credits it, so the two cannot disagree.
119
112
  */
120
113
  mirrorFileFor(collection: string, id: string, ownerRepo: string): string | null;
121
- /**
122
- * The layer an existing file of `d` was read from — `{ layer, path, repo, abs }` — or null for a
123
- * file in the write root. What decides which repo an edit of it commits to.
124
- */
125
- layerOfFile(d: Descriptor, file: string): ResolvedRoot | null;
126
- /** The git repo that owns a file of `d`, workspace-relative: a layer's when a layer holds it. */
127
- repoOfFile(d: Descriptor, file: string): string;
114
+ /** The git repo that owns a file of `d`, workspace-relative. */
115
+ repoOfFile(d: Descriptor, _file: string): string;
128
116
  /**
129
117
  * WHERE a record is read from, and which repo commits it — what `dt get --json` and `dt list
130
118
  * --json` say as `$file` and `$repo`. `file` is workspace-relative, `repo` the workspace-relative
131
- * repo root (`.`, `git_modules/<clone>`); a collection kept outside every repo here (an
119
+ * repo root (`.`, or a module's own clone); a collection kept outside every repo here (an
132
120
  * env-pointed root) answers its absolute file and `repo: null` — it is never committed.
133
121
  */
134
122
  locate(collection: string, id: string): {
@@ -257,23 +245,20 @@ export declare class Store {
257
245
  */
258
246
  _pruneAround(d: Descriptor, file: string): void;
259
247
  /**
260
- * An id no root here holds that an exports manifest vouches for (cr-dt-004): `{ label, from?, manifest }`,
261
- * or null. The manifest is the referring record's repo's — `referrer` (`<collection>/<id>`), else this
262
- * workspace's — and it answers only where its holder is not read here: exactly where `check` says
263
- * external. A referrer this workspace does not read is refused, naming it.
248
+ * An id no record here holds that this workspace's exports manifest vouches for (cr-dt-004):
249
+ * `{ label, from?, manifest }`, or null. It answers only where its holder is not read here: exactly
250
+ * where `check` says external.
264
251
  */
265
- external(collection: string, id: string, opts?: {
266
- referrer?: string;
267
- }): {
252
+ external(collection: string, id: string): {
268
253
  label: string;
269
254
  from?: string;
270
255
  manifest: string;
271
256
  } | null;
272
257
  /**
273
- * The entry the exports manifest of `repo` (a layer name; null: the write root) holds for an id, with
274
- * `seen` when its holder is read here — or null. The one reading `external` and `checkRefs` share.
258
+ * The entry this workspace's exports manifest holds for an id, with `seen` when its holder is read
259
+ * here — or null. The one reading `external` and `checkRefs` share.
275
260
  */
276
- vouched(collection: string, id: string, repo?: string | null): {
261
+ vouched(collection: string, id: string): {
277
262
  label: string;
278
263
  from?: string;
279
264
  manifest: string;
@@ -355,7 +340,6 @@ export declare class Store {
355
340
  };
356
341
  validate(d: Descriptor, fields: Fields, opts?: {
357
342
  skipRefs?: boolean;
358
- repo?: string | null;
359
343
  }): Fields;
360
344
  /**
361
345
  * Bare ids are accepted on INPUT for a field whose target set has exactly one member, and
@@ -373,8 +357,7 @@ export declare class Store {
373
357
  * misread collection.
374
358
  */
375
359
  qualifyBareRefs(d: Descriptor, fields: Fields): void;
376
- /** `repo` is the referring record's: the layer that holds it, null for the write root. */
377
- checkRefs(d: Descriptor, fields: Fields, repo?: string | null): void;
360
+ checkRefs(d: Descriptor, fields: Fields): void;
378
361
  add(collection: string, fields: Fields, opts?: {
379
362
  id?: string;
380
363
  }): {
@@ -478,8 +461,7 @@ export declare class Store {
478
461
  */
479
462
  recordFiles(): Generator<string, void, unknown>;
480
463
  /**
481
- * every compiled module (review finding 10: this layer never learned decision 24 — rename
482
- * silently skipped git_modules sources), read off the manifest rather than by re-discovering
464
+ * every compiled module, read off the manifest rather than by re-discovering
483
465
  * modules, which is what used to make the store import the compiler. See runtime.js.
484
466
  */
485
467
  sourceRoots(): string[];