dreamteamer 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreamteamer",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "A workspace compiler for coding agents — schema-validated records as plain files over git, compiled into every harness",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Gilad Khen <giladkhen@gmail.com>",
@@ -266,7 +266,7 @@ Keys are snake_case and closed: compile refuses an unknown one, naming the list.
266
266
  | `vars` | the `.env` keys records may reference as `${env:KEY}` (`records.md`) |
267
267
  | `auto_commit` | whether a record write also commits (default off) |
268
268
  | `harnesses` | which coding-agent adapters compile writes |
269
- | `git_modules` | the lockfile map `dt install` restores into `git_modules/` — `{ url, ref }` per clone; a clone whose own package.json names `workspace_module` is a RECORD LAYER (below), not a bundle, and `records: [<collection>…]` narrows it (or makes any clone a layer) — `module: true` adds its one workspace module |
269
+ | `git_modules` | the lockfile map `dt install` restores into `git_modules/` — `{ url, ref }` per clone; a clone whose own package.json names `workspace_module` is a RECORD LAYER (below), not a bundle, and `records: [<collection>…]` narrows it (or makes any clone a layer) — `module: true` adds its one workspace module; what a clone NEEDS (the holders its `dreamteamer-exports.json` names) is installed here too, once at the top and linked under the clone (0.46.0) |
270
270
  | `disable` | what to drop from the compile: `modules/<id>` (a whole module, its code included) or `<kind>/<id>` (one entity) |
271
271
  | `local_assets` · `postinstall` · `repos_path` · `gitignore_runtime_folder` | links a worktree gets · a script `dt install` runs · where `repos` records materialise · whether `.dreamteamer/` is gitignored |
272
272
 
@@ -444,7 +444,13 @@ HQ reads the projects' records by cloning each project under `git_modules/`:
444
444
  count, never a failure.
445
445
  - **A layer is never a bundle.** Its own `modules/` is not unpacked and it
446
446
  is not an extension; the shapes are the modules both workspaces install. Its nested
447
- `git_modules/` are never read.
447
+ `git_modules/` contribute no sources either — but what it NEEDS is installed here (0.46.0), the
448
+ npm way: the entries of its `git_modules` that provide a package its committed
449
+ `dreamteamer-exports.json` names as a holder, and only those. `dt install` clones each once at this
450
+ workspace's `git_modules/<name>` and links `<clone>/git_modules/<name>` to it; their records are read
451
+ here with the union of every declarer's `records` list, and `dt status` says `· via git_modules/<clone>`.
452
+ Your own declaration overrides a clone's (said in status); two clones that disagree get the second
453
+ copy nested under its declarer; nothing is refused.
448
454
  - **`module: true` also compiles the clone's WORKSPACE module** — `modules/<workspace_module>`, as
449
455
  the clone's own package.json names it — as a module source here, the way a bundle's module
450
456
  compiles: its agents, skills, commands, command-bindings, ui-views, mixins and collections, with a
package/src/checkout.js CHANGED
@@ -6,6 +6,7 @@ import { execFileSync, spawnSync } from 'node:child_process';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { staleness, compile, discoverModules } from './compile.js';
8
8
  import { install as restoreGitModules, offRef } from './init.js';
9
+ import { declaredGitModules } from './workspace.js';
9
10
 
10
11
  export const defaultGit = (args, cwd) => {
11
12
  try {
@@ -138,8 +139,13 @@ export function observeState(ws) {
138
139
  // ⚠ THE MISSING clones and the ones off their declared ref, not every declared one. A settled
139
140
  // worktree would otherwise print `▶ git modules: …` for ever, and this is the step whose result
140
141
  // nobody looks at — so the narrowing here is what makes the empty case mean "nothing to do".
141
- gitModules: Object.entries(ws.pkg.dreamteamer?.git_modules ?? {})
142
- .filter(([n, m]) => !resolves(here(path.join('git_modules', n))) || offRef(here(path.join('git_modules', n)), m?.ref ?? 'main')).map(([n]) => n),
142
+ // … and the ones a clone on disk NEEDS (`declaredGitModules`): missing, off their ref, nothing yet under
143
+ // a declarer (a clone of its own there is satisfied), or a nested copy missing or off its ref. Before
144
+ // the first install only this workspace's own are visible.
145
+ gitModules: [...new Set([
146
+ ...[...declaredGitModules(ws.pkg, ws.root).map].filter(([n, m]) => !resolves(here(path.join('git_modules', n))) || offRef(here(path.join('git_modules', n)), m.ref) || m.declarers.some((by) => by && !resolves(here(path.join(by, 'git_modules', n))))).map(([n]) => n),
147
+ ...declaredGitModules(ws.pkg, ws.root).nested.filter((c) => !resolves(here(path.join(c.by, 'git_modules', c.name))) || offRef(here(path.join(c.by, 'git_modules', c.name)), c.ref)).map((c) => c.name),
148
+ ])],
143
149
  stale: !s.compiled || s.stale.length > 0,
144
150
  postinstall: ws.pkg.dreamteamer?.postinstall ?? null,
145
151
  };
package/src/cli.js CHANGED
@@ -21,6 +21,8 @@ import { collectionCommand, emit, relationsCommand, reportCommits } from './coll
21
21
  import { formatDescriptors } from './schema-ops.js';
22
22
  import { init, installClone, update, listRepos } from './init.js';
23
23
  import { installCommand, describeCheckout } from './checkout.js';
24
+ import { declaredGitModules } from './workspace.js';
25
+ const isOwnClone = (p) => { try { return !fs.lstatSync(p).isSymbolicLink() && fs.existsSync(path.join(p, '.git')); } catch { return false; } };
24
26
  import { foldChanges, groupChanges, reportLine } from './events.js';
25
27
  import { commitPending, recordChanges, rowChanges } from './commit.js';
26
28
  import { Store } from './store.js';
@@ -568,12 +570,22 @@ export async function run(argv) {
568
570
  console.log('layers:');
569
571
  let descriptors = [];
570
572
  try { descriptors = [...new Store(ws).descriptors.values()]; } catch { /* no runtime yet */ }
573
+ // a layer a clone needed says so (`via`); one this workspace's declaration overrides says whom; a
574
+ // copy nested under a clone, or a clone of its own where a link would be, is drawn under its clone
575
+ const declared = declaredGitModules(ws.pkg, ws.root);
576
+ const under = (by) => [
577
+ ...declared.nested.filter((c) => c.by === by).map((c) => { const d = path.join(ws.root, by, 'git_modules', c.name); 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})`; }),
578
+ ...[...declared.map].filter(([n, m]) => m.declarers.includes(by) && isOwnClone(path.join(ws.root, by, 'git_modules', n))).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}`),
579
+ ];
571
580
  for (const l of layers) {
581
+ const over = declared.mismatches.filter((m) => m.name === l.name);
582
+ const asked = over.length ? ` · overrides ${over.map((m) => `${m.by} (${m.what} ${m.theirs})`).join(', ')}` : l.via.length ? ` · via ${l.via.join(', ')}` : '';
572
583
  const dir = path.join(ws.root, 'git_modules', l.name);
573
584
  const ref = fs.existsSync(dir) ? tryGit(dir, ['rev-parse', '--short', 'HEAD']) : null;
574
585
  const mod = l.module ? modules.find((m) => m.layer === l.name) : null;
575
586
  const found = descriptors.filter((d) => storageOf(d).roots.some((r) => r.layer === l.name && fs.existsSync(path.join(ws.root, r.path)))).map((d) => d.name).sort();
576
- 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) : '-'}` : ''}`);
587
+ 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}`);
588
+ for (const line of under(`git_modules/${l.name}`)) console.log(line);
577
589
  }
578
590
  }
579
591
  // env-pointed roots (`storage.path: ${env:NAME}/…`), rendered per machine by compile: the
package/src/init.js CHANGED
@@ -8,7 +8,7 @@ import { discoverModules, KINDS } from './compile.js';
8
8
  import { KNOWN_HARNESSES } from './harnesses.js';
9
9
  import { Store } from './store.js';
10
10
  import { envContext, renderTemplate } from './env-vars.js';
11
- import { ensureEditorRecommendation } from './workspace.js';
11
+ import { declaredGitModules, ensureEditorRecommendation } from './workspace.js';
12
12
 
13
13
  // git calls whose failure we CATCH must not print git's own error: execFileSync forwards the
14
14
  // child's stderr to ours unless told otherwise, so a handled "not a git repository" still
@@ -169,21 +169,15 @@ export function init({ flags = {} } = {}) {
169
169
  return 0;
170
170
  }
171
171
 
172
- // dreamteamer install — restore git_modules/ working clones from the committed lockfile map
172
+ // dreamteamer install — restore git_modules/ working clones from the committed lockfile map, and what each
173
+ // restored clone NEEDS in turn (`declaredGitModules`, the npm model): a layer a clone's manifest names is
174
+ // cloned ONCE at the top level and linked under the clone — or, where it disagrees with what the top holds,
175
+ // cloned under the clone itself — to a fixpoint, since a clone just restored may need more. Never refuses.
173
176
  export function install({ root, pkg }) {
174
- const map = pkg.dreamteamer?.git_modules ?? {};
175
- const names = Object.keys(map);
176
- if (!names.length) { console.log('✔ no git_modules declared — nothing to restore'); return 0; }
177
- fs.mkdirSync(path.join(root, 'git_modules'), { recursive: true });
178
- const unreachable = [];
179
- for (const name of names) {
180
- const { url, ref = 'main' } = map[name];
181
- const dest = path.join(root, 'git_modules', name);
182
- if (fs.existsSync(dest)) {
183
- if (!repoint(dest, name, ref)) unreachable.push(name);
184
- continue;
185
- }
186
- console.log(`… cloning ${url} → git_modules/${name} (${ref})`);
177
+ const unreachable = [], done = new Set();
178
+ let declared;
179
+ const clone = (url, ref, dest, name, note) => {
180
+ console.log(`… cloning ${url} → ${path.relative(root, dest)} (${ref})${note}`);
187
181
  try {
188
182
  execFileSync('git', ['clone', '--branch', ref, url, dest], { stdio: 'inherit' });
189
183
  } catch {
@@ -193,27 +187,71 @@ export function install({ root, pkg }) {
193
187
  // half-restored workspace and named only the first failure.
194
188
  fs.rmSync(dest, { recursive: true, force: true }); // git leaves the partial dir behind
195
189
  unreachable.push(name);
196
- console.warn(`⚠ git_modules/${name}: clone failed — skipped (${url})`);
197
- continue;
190
+ console.warn(`⚠ ${path.relative(root, dest)}: clone failed — skipped (${url})`);
191
+ return;
198
192
  }
199
193
  buildClone(dest, name);
194
+ };
195
+ for (;;) {
196
+ declared = declaredGitModules(pkg, root);
197
+ const top = [...declared.map].filter(([n]) => !done.has(n)).map(([name, e]) => ({ ...e, name, dest: path.join(root, 'git_modules', name), note: e.declarers.some(Boolean) ? ` — for ${e.declarers.filter(Boolean).join(', ')}` : '' }));
198
+ const under = declared.nested.filter((n) => !done.has(`${n.by}/${n.name}`)).map((n) => ({ ...n, dest: path.join(root, n.by, 'git_modules', n.name), note: ` — nested: git_modules/${n.name} is ${n.top.url} (${n.top.ref})` }));
199
+ if (!top.length && !under.length) break;
200
+ for (const t of [...top, ...under]) {
201
+ done.add(t.by ? `${t.by}/${t.name}` : t.name);
202
+ fs.mkdirSync(path.dirname(t.dest), { recursive: true });
203
+ if (fs.existsSync(t.dest)) { if (!repoint(t.dest, path.relative(path.join(root, 'git_modules'), t.dest), t.ref)) unreachable.push(t.name); continue; }
204
+ clone(t.url, t.ref, t.dest, t.name, t.note);
205
+ if (t.by) excludeIn(path.join(root, t.by), `git_modules/${t.name}`);
206
+ }
207
+ }
208
+ if (!done.size) { console.log('✔ no git_modules declared — nothing to restore'); return 0; }
209
+ for (const [name, { declarers }] of declared.map) for (const by of declarers) if (by && !unreachable.includes(name)) linkLayer(root, by, name);
210
+ for (const [name, list] of declared.mismatches.reduce((g, m) => g.set(m.name, [...(g.get(m.name) ?? []), m]), new Map())) { // Map.groupBy is Node 21+
211
+ console.warn(`⚠ git_modules/${name}: this workspace's declaration overrides ${list.map((m) => `${m.by} (${m.what} ${m.theirs})`).join(', ')}`);
200
212
  }
213
+ for (const u of declared.unmet) console.warn(`⚠ ${u.by}: dreamteamer-exports.json names ${u.holder}, which no git_modules entry of the clone provides`);
201
214
  // non-zero, because the workspace is NOT what the lockfile describes: modules are missing or off
202
215
  // their ref, and `check` will report references into them as unknown collections.
203
216
  if (unreachable.length) console.error(`✖ ${unreachable.length} module(s) are not what the lockfile declares: ${unreachable.join(', ')}`);
204
217
  return unreachable.length ? 1 : 0;
205
218
  }
206
219
 
220
+ /** The link a declarer finds its layer through — `<by>/git_modules/<name> -> ../../<name>`, the pnpm shape:
221
+ * explicit on disk, resolved by a tool that knows nothing of dreamteamer. A clone of its own standing there
222
+ * may hold work: left as it is, and said — `dt status` draws it too. */
223
+ function linkLayer(root, by, name) {
224
+ const at = path.join(root, by, 'git_modules', name), want = path.join('..', '..', name);
225
+ let st = null;
226
+ try { st = fs.lstatSync(at); } catch { /* nothing there */ }
227
+ if (st && !st.isSymbolicLink()) { console.log(`… ${by}/git_modules/${name} is a clone of its own — left as it is`); return; }
228
+ if (st && fs.readlinkSync(at) === want) return;
229
+ if (st) fs.unlinkSync(at);
230
+ fs.mkdirSync(path.dirname(at), { recursive: true });
231
+ fs.symlinkSync(want, at);
232
+ excludeIn(path.join(root, by), `git_modules/${name}`);
233
+ console.log(`✔ ${by}/git_modules/${name} → git_modules/${name}`);
234
+ }
235
+
236
+ /** Ignore `rel` in a clone's own `.git/info/exclude` when its .gitignore does not already cover it — never
237
+ * in a tracked file, which would dirty the clone. */
238
+ function excludeIn(clone, rel) {
239
+ if (ran(clone, ['check-ignore', '-q', rel])) return;
240
+ const exclude = path.resolve(clone, tryGit(clone, ['rev-parse', '--git-path', 'info/exclude']) ?? path.join('.git', 'info', 'exclude'));
241
+ fs.mkdirSync(path.dirname(exclude), { recursive: true });
242
+ appendMissing(exclude, rel);
243
+ }
244
+
207
245
  // dreamteamer update [<name>] — pull each lockfile-declared git_modules clone forward
208
246
  // (ff-only on its recorded ref) and rebuild it. dirty clones are skipped, never touched.
209
247
  // the caller (cli) runs compile afterwards — a pulled module may change sources.
210
248
  export function update({ root, pkg }, only) {
211
- const map = pkg.dreamteamer?.git_modules ?? {};
249
+ const map = Object.fromEntries(declaredGitModules(pkg, root).map); // a hoisted layer is pulled forward too
212
250
  if (only && !map[only]) throw new Error(`"${only}" is not in dreamteamer.git_modules (known: ${Object.keys(map).join(', ') || 'none'})`);
213
251
  const names = only ? [only] : Object.keys(map);
214
252
  if (!names.length) { console.log('✔ no git_modules declared — nothing to update'); return 0; }
215
253
  for (const name of names) {
216
- const { ref = 'main' } = map[name];
254
+ const { ref } = map[name];
217
255
  const dest = path.join(root, 'git_modules', name);
218
256
  if (!fs.existsSync(dest)) { console.warn(`⚠ git_modules/${name} missing — run \`dreamteamer install\` first; skipped`); continue; }
219
257
  if (tryGit(dest, ['status', '--porcelain'])) { console.warn(`⚠ git_modules/${name} is dirty — skipped (commit or stash there, then re-run)`); continue; }
package/src/workspace.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // real workspace and now resolves as one.
11
11
  import fs from 'node:fs';
12
12
  import path from 'node:path';
13
+ import { readExports } from './exports.js';
13
14
 
14
15
  // path segments that mean "the thing below me is a module of the thing above me", never a workspace
15
16
  const MODULE_SEGMENTS = new Set(['node_modules', 'git_modules', 'modules']);
@@ -46,28 +47,84 @@ export function findWorkspace(start = process.cwd()) {
46
47
  return found;
47
48
  }
48
49
 
49
- /** The declared record layers, validated: `{ name, records, module }` per entry. WHAT THE CLONE IS
50
- * decides it, not the reader's key (0.41.0): a clone whose own manifest names `workspace_module` is a
51
- * workspace, so its data is a layer for every collection both have (`records: null`); a clone that
52
- * names none is a bundle and is not listed here; a clone not on disk is listed (not installed). `records:` still makes an entry a layer and NARROWS
53
- * it to the listed collections; `module: true` declares one too (and is refused downstream when the
54
- * clone has no workspace module to contribute). `root` absent reads only the declarations. */
55
- export function layerEntries(pkg, root = null) {
56
- const out = [];
57
- for (const [name, entry] of Object.entries(pkg?.dreamteamer?.git_modules ?? {})) {
58
- if (entry?.module !== undefined && typeof entry.module !== 'boolean') throw new Error(`git_modules.${name}.module must be true or false (got ${JSON.stringify(entry.module)})`);
50
+ /** Every git module this workspace installs, by name — THE NPM MODEL. Its own declarations first, all of
51
+ * them (a root installs its devDependencies too). Then, with `root`, what each clone on disk NEEDS: the
52
+ * entries of the clone's own `git_modules` that provide a package its committed `dreamteamer-exports.json`
53
+ * names as holding ids its records reference. A clone with no manifest needs nothing — the rest of its list
54
+ * is its devDependencies, never installed here, which is what keeps a transitive install from dragging in
55
+ * everything a nested workspace happens to read. A need is matched to an entry by package name, scoped or
56
+ * not (`@northwind/org` → `org`); one no entry provides is returned in `unmet`.
57
+ *
58
+ * Resolution, as npm's: a need the root declares is the root's (`overrides` — a differing ref or url is
59
+ * returned in `mismatches`, never acted on); a need another clone already hoisted at the same url and ref
60
+ * is shared; a need nobody has is hoisted to the top-level `git_modules/<name>`, once; a need that disagrees
61
+ * with what the top holds is `nested` — a second clone under its declarer, as npm nests a second version.
62
+ * `install` lays a symlink under each declarer of a top-level clone. Nothing here refuses; every
63
+ * disagreement is returned to be said. `records` is the union of the lists, `open` when some declarer
64
+ * named none; a nested `module: true` is not hoisted. */
65
+ export function declaredGitModules(pkg, root = null) {
66
+ const map = new Map(), nested = [], mismatches = [], unmet = [];
67
+ const validate = (at, entry) => {
68
+ if (entry?.module !== undefined && typeof entry.module !== 'boolean') throw new Error(`${at}.module must be true or false (got ${JSON.stringify(entry.module)})`);
59
69
  const r = entry?.records;
60
70
  if (r !== undefined && (!Array.isArray(r) || !r.length || r.some((c) => typeof c !== 'string' || !c.trim()))) {
61
- throw new Error(`git_modules.${name}.records must be a non-empty list of collection names (got ${JSON.stringify(r)})`);
71
+ throw new Error(`${at}.records must be a non-empty list of collection names (got ${JSON.stringify(r)})`);
72
+ }
73
+ const { url, ref = 'main' } = entry ?? {};
74
+ return { url, ref, records: r, open: r === undefined };
75
+ };
76
+ for (const [name, entry] of Object.entries(pkg?.dreamteamer?.git_modules ?? {})) {
77
+ map.set(name, { ...validate(`git_modules.${name}`, entry), module: entry?.module === true, declarers: [null] });
78
+ }
79
+ if (!root) return { map, nested, mismatches, unmet };
80
+ const widen = (have, e) => { if (e.open) have.open = true; else have.records = [...new Set([...(have.records ?? []), ...e.records])]; };
81
+ // clones to read, by workspace-relative path; a Map visits entries appended while it is walked
82
+ const clones = new Map([...map.keys()].map((n) => [`git_modules/${n}`, n]));
83
+ for (const [by, name] of clones) {
84
+ const dir = path.join(root, by);
85
+ let own, holders;
86
+ try { own = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).dreamteamer?.git_modules ?? {}; } catch { continue; }
87
+ holders = new Set(Object.values(readExports(dir) ?? {}).flatMap((ids) => Object.values(ids).map((e) => e.from)).filter(Boolean));
88
+ for (const holder of holders) {
89
+ const found = Object.entries(own).find(([n]) => n === holder || n === holder.split('/').pop());
90
+ if (!found) { unmet.push({ by, holder }); continue; }
91
+ const [need, entry] = found;
92
+ const e = validate(`${by}: git_modules.${need}`, entry);
93
+ const have = map.get(need);
94
+ if (!have) { map.set(need, { ...e, module: false, declarers: [by] }); clones.set(`git_modules/${need}`, need); continue; }
95
+ if (have.declarers[0] === null) { // the root's — it overrides
96
+ if (have.url !== e.url) mismatches.push({ name: need, by, what: 'url', theirs: e.url });
97
+ else if (have.ref !== e.ref) mismatches.push({ name: need, by, what: 'ref', theirs: e.ref });
98
+ } else if (have.url !== e.url || have.ref !== e.ref) {
99
+ nested.push({ by, name: need, ...e, top: { url: have.url, ref: have.ref } });
100
+ clones.set(`${by}/git_modules/${need}`, need);
101
+ continue;
102
+ }
103
+ have.declarers.push(by);
104
+ widen(have, e);
62
105
  }
63
- // a clone ON DISK that names no workspace module is a bundle. One NOT on disk cannot say what it is,
64
- // and is read as a layer that is not installed — announced by compile, check and status — rather
65
- // than vanishing: reading a project is the default since 0.41.0, and silence is how an absent
66
- // layer passed for an empty one.
106
+ }
107
+ return { map, nested, mismatches, unmet };
108
+ }
109
+
110
+ /** The declared record layers, validated: `{ name, records, module, via }` per entry — `via` the nested
111
+ * declarers a hoisted layer was asked for by (`declaredGitModules`). WHAT THE CLONE IS decides it, not the
112
+ * reader's key (0.41.0): a clone whose own manifest names `workspace_module` is a workspace, so its data is
113
+ * a layer for every collection both have (`records: null`); a clone that names none is a bundle and is not
114
+ * listed here; a clone not on disk is listed (not installed). `records:` still makes an entry a layer and
115
+ * NARROWS it to the listed collections; `module: true` declares one too (and is refused downstream when the
116
+ * clone has no workspace module to contribute). `root` absent reads only the declarations. */
117
+ export function layerEntries(pkg, root = null) {
118
+ const out = [];
119
+ for (const [name, e] of declaredGitModules(pkg, root).map) {
67
120
  const clone = root ? path.join(root, 'git_modules', name) : null;
68
- if (r === undefined && entry?.module !== true && clone && fs.existsSync(clone) && !cloneWorkspaceModule(clone)) continue;
69
- if (r === undefined && entry?.module !== true && !clone) continue;
70
- out.push({ name, records: r ?? null, module: entry?.module === true });
121
+ // a declaration naming no records reads every shared collection of a WORKSPACE clone — or of one not on
122
+ // disk, which cannot say what it is, and is read as a layer that is not installed (announced by compile,
123
+ // check and status) rather than vanishing: silence is how an absent layer passed for an empty one. Of a
124
+ // bundle it reads nothing, so another declarer's list stands
125
+ const wide = e.open && (clone ? !fs.existsSync(clone) || !!cloneWorkspaceModule(clone) : e.module);
126
+ if (!wide && !e.records && !(clone && e.module)) continue;
127
+ out.push({ name, records: wide ? null : e.records ?? null, module: e.module, via: e.declarers.filter(Boolean) });
71
128
  }
72
129
  return out;
73
130
  }