@antelopejs/dms 0.18.0 → 0.18.2

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 (61) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +3 -3
  3. package/bin/control/backend-records.test.mjs +276 -0
  4. package/bin/control/backend.mjs +212 -0
  5. package/bin/control/backend.test.mjs +325 -0
  6. package/bin/control/base.mjs +3 -7
  7. package/bin/control/browser-client.mjs +6 -4
  8. package/bin/control/browser.mjs +173 -36
  9. package/bin/control/build-cache.mjs +394 -0
  10. package/bin/control/build-cache.test.mjs +270 -0
  11. package/bin/control/build-inputs.mjs +172 -0
  12. package/bin/control/build-key-refusals.test.mjs +138 -0
  13. package/bin/control/build-key.mjs +479 -0
  14. package/bin/control/build-key.test.mjs +392 -0
  15. package/bin/control/build-layout.test.mjs +314 -0
  16. package/bin/control/commands-stack.mjs +46 -6
  17. package/bin/control/commands-verify.mjs +14 -25
  18. package/bin/control/doctor.mjs +87 -16
  19. package/bin/control/forwarder.mjs +86 -0
  20. package/bin/control/forwarder.test.mjs +141 -0
  21. package/bin/control/frontend-check.mjs +54 -0
  22. package/bin/control/frontend-workspace.mjs +150 -0
  23. package/bin/control/frontend-workspace.test.mjs +133 -0
  24. package/bin/control/helpers/env.mjs +21 -0
  25. package/bin/control/helpers/evidence.mjs +13 -0
  26. package/bin/control/helpers/fake-run.mjs +290 -0
  27. package/bin/control/helpers/key-fixture.mjs +82 -0
  28. package/bin/control/helpers/pids.mjs +27 -0
  29. package/bin/control/helpers/repo.mjs +13 -0
  30. package/bin/control/helpers/tree.mjs +40 -0
  31. package/bin/control/identity.mjs +238 -0
  32. package/bin/control/identity.test.mjs +166 -0
  33. package/bin/control/journey.mjs +64 -16
  34. package/bin/control/journey.test.mjs +60 -2
  35. package/bin/control/namespaces.test.mjs +211 -0
  36. package/bin/control/options.mjs +2 -0
  37. package/bin/control/pid-guard.test.mjs +202 -0
  38. package/bin/control/prepared-workspace.mjs +20 -0
  39. package/bin/control/processes.mjs +122 -33
  40. package/bin/control/processes.test.mjs +255 -0
  41. package/bin/control/renderer.test.mjs +2 -1
  42. package/bin/control/run-copy.mjs +77 -0
  43. package/bin/control/run-state.mjs +142 -16
  44. package/bin/control/stack.mjs +259 -210
  45. package/bin/control/tab.mjs +13 -6
  46. package/bin/control/tab.test.mjs +444 -0
  47. package/bin/control/timing.mjs +244 -0
  48. package/bin/control/timing.test.mjs +197 -0
  49. package/bin/control/verify/decode.mjs +34 -36
  50. package/bin/control/verify/decode.test.mjs +40 -14
  51. package/bin/control/verify/doors.test.mjs +2 -0
  52. package/bin/control/verify/map.mjs +57 -7
  53. package/bin/control/verify/map.test.mjs +264 -0
  54. package/bin/control/verify/skill.mjs +12 -3
  55. package/bin/control/verify/types.mjs +2 -2
  56. package/bin/control/verify/verdict.mjs +34 -37
  57. package/bin/dms-control.mjs +13 -6
  58. package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
  59. package/package.json +1 -1
  60. package/skills/dms-project/SKILL.md +6 -3
  61. package/bin/control/verify/publish.mjs +0 -186
@@ -0,0 +1,392 @@
1
+ import assert from "node:assert/strict";
2
+ import { rmSync, symlinkSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import test from "node:test";
5
+ import { setEnv } from "./helpers/env.mjs";
6
+ import { fixture, keyOf } from "./helpers/key-fixture.mjs";
7
+ import { write } from "./helpers/repo.mjs";
8
+
9
+ await test("two runs that set up the same sources share a key, whatever their folders and web URLs", (t) => {
10
+ const { frontend, prepare } = fixture(t);
11
+ assert.equal(
12
+ keyOf(frontend, prepare("run-b", 2002)),
13
+ keyOf(frontend, prepare("run-a", 1001)),
14
+ "a key holding the run's folder or URL never hits",
15
+ );
16
+ });
17
+
18
+ await test("a .env or .env.local of the project changes the key", (t) => {
19
+ const { frontend, prepare } = fixture(t);
20
+ const side = prepare("run", 1001);
21
+ const clean = keyOf(frontend, side);
22
+ write(join(side.project, ".env"), "NODE_ENV=development\n");
23
+ const env = keyOf(frontend, side);
24
+ assert.notEqual(
25
+ env,
26
+ clean,
27
+ "a key on git's view of the checkout skips the ignored .env the build loads",
28
+ );
29
+ write(join(side.project, ".env.local"), "VITE_FLAG=on\n");
30
+ assert.notEqual(keyOf(frontend, side), env, "the build loads .env.local too");
31
+ });
32
+
33
+ await test("the versions the install resolved change the key", (t) => {
34
+ const { frontend, prepare } = fixture(t);
35
+ const side = prepare("run", 1001);
36
+ const resolved = keyOf(frontend, side);
37
+ write(join(side.workspace, "pnpm-lock.yaml"), "vue: 3.5.1\n");
38
+ assert.notEqual(
39
+ keyOf(frontend, side),
40
+ resolved,
41
+ "a key on the declared ranges serves a build of the last release in range",
42
+ );
43
+ });
44
+
45
+ await test("an edited copy, generated file or dms-frontend changes the key; the installed modules and later entries do not", (t) => {
46
+ const { frontend, prepare } = fixture(t);
47
+ const side = prepare("run", 1001);
48
+ const keys = new Set([keyOf(frontend, side)]);
49
+ write(join(side.workspace, "node_modules", "vue", "index.js"), "other();\n");
50
+ write(
51
+ join(side.workspace, "frontend-modules", "layer", "node_modules", "x"),
52
+ "linked\n",
53
+ );
54
+ write(join(side.workspace, "dist", "client", "index.html"), "<html>\n");
55
+ assert.ok(
56
+ keys.has(keyOf(frontend, side)),
57
+ "a key on the installed modules or the build's own output never hits",
58
+ );
59
+ /** @param {string} change */
60
+ const changed = (change) => {
61
+ const key = keyOf(frontend, side);
62
+ assert.ok(!keys.has(key), change);
63
+ keys.add(key);
64
+ };
65
+ write(
66
+ join(side.workspace, "frontend-modules", "layer", "page.vue"),
67
+ "<template>two</template>\n",
68
+ );
69
+ changed("a key read off the checkout misses what the setup copied");
70
+ write(join(side.workspace, "generated-frontend-modules.json"), "{}");
71
+ changed("the setup generates the registry from the configuration");
72
+ write(join(frontend, "dist", "index.js"), "other();\n");
73
+ changed("another dms-frontend builds another dashboard");
74
+ write(join(frontend, "templates", "vue", "main.ts"), "other();\n");
75
+ changed("a renderer checkout keyed by its version serves its last build");
76
+ });
77
+
78
+ await test("the environment, an --env pair or a VITE_ variable changes the key", (t) => {
79
+ const { frontend, prepare } = fixture(t);
80
+ const side = prepare("run", 1001);
81
+ const keys = new Set([keyOf(frontend, side)]);
82
+ /** @param {string} change */
83
+ const changed = (change) => {
84
+ const key = keyOf(frontend, side);
85
+ assert.ok(!keys.has(key), change);
86
+ keys.add(key);
87
+ };
88
+ side.run.environment = "production";
89
+ changed("the environment picks the project's configuration");
90
+ side.run.extraEnv = { DMS_FEATURE: "on" };
91
+ changed("the --env pairs reach the build");
92
+ side.run.bakedEnv = { VITE_PROBE: "on" };
93
+ changed("Vite bakes VITE_ variables into the bundle");
94
+ });
95
+
96
+ await test("the key reads the VITE_ and NODE_ENV variables the run recorded, not those of the shell keying it again", (t) => {
97
+ const { frontend, prepare } = fixture(t);
98
+ const side = prepare("run", 1001);
99
+ side.run.bakedEnv = { NODE_ENV: "production" };
100
+ const recorded = keyOf(frontend, side);
101
+ setEnv(t, { NODE_ENV: "development", VITE_PROBE: "on" });
102
+ assert.equal(
103
+ keyOf(frontend, side),
104
+ recorded,
105
+ "a key on the variables of the shell that keys it reports identical sources as stale from any other shell",
106
+ );
107
+ });
108
+
109
+ await test("a source holding a URL or a placeholder is keyed as written; only the setup's registries leave the run's values out", (t) => {
110
+ const { frontend, prepare } = fixture(t);
111
+ let runs = 0;
112
+ /**
113
+ * @param {number} port
114
+ * @param {(workspace: string) => Record<string, string>} files
115
+ */
116
+ const keyed = (port, files) => {
117
+ runs += 1;
118
+ const side = prepare(`run-${runs}`, port);
119
+ for (const [name, text] of Object.entries(files(side.workspace))) {
120
+ write(join(side.workspace, name), text);
121
+ }
122
+ return keyOf(frontend, side);
123
+ };
124
+ const api = join("frontend-modules", "layer", "api.ts");
125
+ for (const path of ["", "/v1"]) {
126
+ assert.notEqual(
127
+ keyed(1001, () => ({
128
+ [api]: `export const API = "http://127.0.0.1:1001${path}";`,
129
+ })),
130
+ keyed(1002, () => ({
131
+ [api]: `export const API = "http://127.0.0.1:1002${path}";`,
132
+ })),
133
+ "a key replacing the run's URL in every source serves a build pinned to another run's URL",
134
+ );
135
+ }
136
+ const registry = "generated-frontend-modules.json";
137
+ /** @param {string} url */
138
+ const options = (url) => JSON.stringify({ dms: { baseURL: url } });
139
+ const own = keyed(1001, () => ({
140
+ [registry]: options("http://127.0.0.1:1001"),
141
+ }));
142
+ assert.equal(
143
+ keyed(1002, () => ({ [registry]: options("http://127.0.0.1:1002") })),
144
+ own,
145
+ "a registry naming each run's own URL never hits",
146
+ );
147
+ for (const placeholder of ["<web>", "%W", '%W"']) {
148
+ assert.notEqual(
149
+ keyed(1009, () => ({ [registry]: options(placeholder) })),
150
+ own,
151
+ `a registry holding ${placeholder} reads as one holding the run's URL`,
152
+ );
153
+ }
154
+ assert.notEqual(
155
+ keyed(1001, () => ({ [registry]: options("http://127.0.0.1:10012") })),
156
+ keyed(1002, () => ({ [registry]: options("http://127.0.0.1:10022") })),
157
+ "a URL that extends the run's reads as the run's with a suffix",
158
+ );
159
+ /** @param {string} workspace */
160
+ const sibling = (workspace) => JSON.stringify({ root: `${workspace}-old` });
161
+ assert.notEqual(
162
+ keyed(1001, (workspace) => ({ [registry]: sibling(workspace) })),
163
+ keyed(1001, (workspace) => ({ [registry]: sibling(workspace) })),
164
+ "a folder whose name extends the workspace's reads as a path under it",
165
+ );
166
+ });
167
+
168
+ await test("the installs above the workspace that a bare import resolves from change the key; their caches and pnpm's per-install bookkeeping do not", (t) => {
169
+ const { dir, frontend, checkout, modules, prepare } = fixture(t);
170
+ const side = prepare("run", 1001);
171
+ const keys = new Set([keyOf(frontend, side)]);
172
+ write(
173
+ join(checkout, "node_modules", ".modules.yaml"),
174
+ "hoistedDependencies: {}\npendingBuilds:\n - .\n - .\nprunedAt: Sun, 08 Nov 2026 01:24:21 GMT\nlayoutVersion: 5\n",
175
+ );
176
+ write(join(modules, ".cache", "jiti", "entry.json"), "{}");
177
+ assert.ok(
178
+ keys.has(keyOf(frontend, side)),
179
+ "a key on pnpm's install bookkeeping or a tool's cache misses after every install that skips scripts",
180
+ );
181
+ /** @param {string} change */
182
+ const changed = (change) => {
183
+ const key = keyOf(frontend, side);
184
+ assert.ok(!keys.has(key), change);
185
+ keys.add(key);
186
+ };
187
+ write(join(checkout, "pnpm-lock.yaml"), "zod: 3.25.0\n");
188
+ changed("a key without the playground's lockfile misses an upgrade");
189
+ write(join(checkout, "node_modules", ".pnpm", "lock.yaml"), "zod: 3.25.0\n");
190
+ changed("pnpm records what it installed apart from the lockfile");
191
+ write(
192
+ join(checkout, "node_modules", ".modules.yaml"),
193
+ "hoistedDependencies:\n zod: public\npendingBuilds:\n - .\nlayoutVersion: 5\n",
194
+ );
195
+ changed("what pnpm hoisted changes what resolves");
196
+ rmSync(join(modules, "zod"));
197
+ symlinkSync(
198
+ "../../node_modules/.pnpm/zod@3.25.0/node_modules/zod",
199
+ join(modules, "zod"),
200
+ );
201
+ changed("a relinked package resolves to another version");
202
+ write(join(modules, "rv-dep", "index.js"), "export const v = 1;\n");
203
+ changed("a package copied into node_modules is resolved too");
204
+ write(join(modules, "rv-dep", "index.js"), "export const v = 2;\n");
205
+ changed("a key on a copied package's name serves its old files");
206
+ write(join(dir, "node_modules", "hoisted", "index.js"), "export {};\n");
207
+ changed("a key reading only the nearest node_modules misses one further up");
208
+ });
209
+
210
+ await test("a no-op install, with scripts or without, keeps the key; a change to what pnpm linked where changes it", (t) => {
211
+ const { frontend, checkout, prepare } = fixture(t);
212
+ const side = prepare("run", 1001);
213
+ const layout = {
214
+ hoistPattern: "\n - '*'",
215
+ hoistedDependencies: "\n zod@3.24.4:\n zod: public",
216
+ hoistedLocations: " {}",
217
+ included:
218
+ "\n dependencies: true\n devDependencies: true\n optionalDependencies: true",
219
+ injectedDeps: " {}",
220
+ layoutVersion: " 5",
221
+ nodeLinker: " isolated",
222
+ publicHoistPattern: "\n - '*'",
223
+ skipped: "\n - '@esbuild/aix-ppc64@0.25.12'",
224
+ virtualStoreDir: " .pnpm",
225
+ virtualStoreDirMaxLength: " 120",
226
+ };
227
+ const bookkeeping = {
228
+ packageManager: " pnpm@10.2.0",
229
+ pendingBuilds: " []",
230
+ prunedAt: " Sat, 07 Nov 2026 01:24:21 GMT",
231
+ registries: "\n default: https://registry.npmjs.org/",
232
+ storeDir: " /home/a/.local/share/pnpm/store/v10",
233
+ };
234
+ /** @param {Record<string, string>} fields */
235
+ const installed = (fields) => {
236
+ const lines = Object.entries(fields).map(
237
+ ([name, value]) => `${name}:${value}`,
238
+ );
239
+ write(
240
+ join(checkout, "node_modules", ".modules.yaml"),
241
+ `${lines.join("\n")}\n`,
242
+ );
243
+ return keyOf(frontend, side);
244
+ };
245
+ const plain = installed({ ...layout, ...bookkeeping, ignoredBuilds: " []" });
246
+ assert.equal(
247
+ installed({
248
+ ...layout,
249
+ ...bookkeeping,
250
+ pendingBuilds: "\n - .\n - esbuild@0.25.12",
251
+ }),
252
+ plain,
253
+ "a key on the record without only pendingBuilds and prunedAt misses after an install that skips scripts, which drops ignoredBuilds",
254
+ );
255
+ assert.equal(
256
+ installed({
257
+ ...layout,
258
+ packageManager: " pnpm@10.3.0",
259
+ prunedAt: " Sun, 08 Nov 2026 01:24:21 GMT",
260
+ registries: "\n default: https://registry.example.test/",
261
+ storeDir: " /var/cache/pnpm/store/v10",
262
+ }),
263
+ plain,
264
+ "a key on the pnpm version, its store or registries misses on an install that links the same packages",
265
+ );
266
+ /** @type {Record<string, string>} */
267
+ const relaid = {
268
+ hoistPattern: "\n - '@types/*'",
269
+ hoistedDependencies: "\n zod@3.24.4:\n zod: private",
270
+ hoistedLocations: "\n zod@3.24.4:\n - node_modules/zod",
271
+ included:
272
+ "\n dependencies: true\n devDependencies: false\n optionalDependencies: true",
273
+ injectedDeps:
274
+ "\n shared-ui:\n - node_modules/.pnpm/shared-ui@file+shared-ui",
275
+ layoutVersion: " 6",
276
+ nodeLinker: " hoisted",
277
+ publicHoistPattern: " []",
278
+ skipped: " []",
279
+ virtualStoreDir: " ../.store",
280
+ virtualStoreDirMaxLength: " 60",
281
+ };
282
+ const keys = new Set([plain]);
283
+ for (const [field, value] of Object.entries(relaid)) {
284
+ const key = installed({ ...layout, ...bookkeeping, [field]: value });
285
+ assert.ok(
286
+ !keys.has(key),
287
+ `a key without ${field} misses that pnpm linked other packages or linked them elsewhere`,
288
+ );
289
+ keys.add(key);
290
+ }
291
+ });
292
+
293
+ await test("a linked workspace package is keyed by its files, without its installs or its runs' outputs; a package of pnpm's virtual store by its link", (t) => {
294
+ const { frontend, checkout, modules, prepare } = fixture(t);
295
+ const side = prepare("run", 1001);
296
+ const shared = join(checkout, "packages", "shared-ui");
297
+ write(join(shared, "index.js"), 'export const label = "SHARED-V1";\n');
298
+ write(join(modules, "@acme", ".keep"), "");
299
+ symlinkSync(
300
+ "../../../packages/shared-ui",
301
+ join(modules, "@acme", "shared-ui"),
302
+ );
303
+ const store = join(
304
+ checkout,
305
+ "node_modules",
306
+ ".pnpm",
307
+ "vue@3.5.0",
308
+ "node_modules",
309
+ "vue",
310
+ );
311
+ write(join(store, "index.js"), "vue();\n");
312
+ symlinkSync(
313
+ "../../node_modules/.pnpm/vue@3.5.0/node_modules/vue",
314
+ join(modules, "vue"),
315
+ );
316
+ write(join(shared, "node_modules", ".bin", "vue"), "vue\n");
317
+ symlinkSync(
318
+ "../../../node_modules/.pnpm/vue@3.5.0/node_modules/vue",
319
+ join(shared, "node_modules", "vue"),
320
+ );
321
+ const linked = keyOf(frontend, side);
322
+ for (const path of [
323
+ join("node_modules", ".bin", "vue"),
324
+ join(".git", "HEAD"),
325
+ join(".antelope", "build", "build.json"),
326
+ join(".dms-frontend", "dist", "index.html"),
327
+ ]) {
328
+ write(join(shared, path), "changed\n");
329
+ }
330
+ assert.equal(
331
+ keyOf(frontend, side),
332
+ linked,
333
+ "a key on a linked package's installs, history or run outputs misses on every install and while a dev server runs there",
334
+ );
335
+ write(join(store, "index.js"), "patched();\n");
336
+ assert.equal(
337
+ keyOf(frontend, side),
338
+ linked,
339
+ "a key reading each package of the virtual store file by file reads every installed package on every up",
340
+ );
341
+ write(join(shared, "index.js"), 'export const label = "SHARED-V2";\n');
342
+ assert.notEqual(
343
+ keyOf(frontend, side),
344
+ linked,
345
+ "a key on a linked package's target path serves a build of its old files",
346
+ );
347
+ });
348
+
349
+ await test("a package copied into node_modules is keyed with its own node_modules", (t) => {
350
+ const { frontend, modules, prepare } = fixture(t);
351
+ const side = prepare("run", 1001);
352
+ write(
353
+ join(modules, "ui-kit", "index.js"),
354
+ 'import color from "color-lib";\n',
355
+ );
356
+ const nested = join(
357
+ modules,
358
+ "ui-kit",
359
+ "node_modules",
360
+ "color-lib",
361
+ "index.js",
362
+ );
363
+ write(nested, 'export default "COLOR-V1";\n');
364
+ const copied = keyOf(frontend, side);
365
+ write(nested, 'export default "COLOR-V2";\n');
366
+ assert.notEqual(
367
+ keyOf(frontend, side),
368
+ copied,
369
+ "a key that skips a copied package's node_modules serves a build of its old dependencies",
370
+ );
371
+ });
372
+
373
+ await test("links of one name and one link text in two node_modules are keyed by the folder each resolves to", (t) => {
374
+ const { dir, frontend, modules, prepare } = fixture(t);
375
+ const side = prepare("run", 1001);
376
+ const near = join(modules, "..", "packages", "shared-ui");
377
+ const far = join(dir, "packages", "shared-ui");
378
+ for (const target of [near, far]) {
379
+ write(join(target, "index.js"), 'export const label = "SHARED-V1";\n');
380
+ }
381
+ write(join(dir, "node_modules", ".keep"), "");
382
+ for (const folder of [modules, join(dir, "node_modules")]) {
383
+ symlinkSync("../packages/shared-ui", join(folder, "shared-ui"));
384
+ }
385
+ const linked = keyOf(frontend, side);
386
+ write(join(far, "index.js"), 'export const label = "SHARED-V2";\n');
387
+ assert.notEqual(
388
+ keyOf(frontend, side),
389
+ linked,
390
+ "a key that reuses a linked package's hash by its name or link text serves the nearer package's hash for the farther one",
391
+ );
392
+ });