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