@antelopejs/dms 0.18.2 → 0.19.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/CHANGELOG.md +60 -0
- package/README.md +1 -1
- package/bin/control/backend.mjs +1 -1
- package/bin/control/base.mjs +24 -9
- package/bin/control/base.test.mjs +88 -0
- package/bin/control/browser-client.mjs +1 -1
- package/bin/control/commands-stack.mjs +3 -1
- package/bin/control/consumer-install.test.mjs +73 -0
- package/bin/control/database.mjs +66 -0
- package/bin/control/doctor.mjs +7 -0
- package/bin/control/frontend-check.mjs +2 -1
- package/bin/control/frontend-mode.test.mjs +24 -0
- package/bin/control/identity.mjs +45 -16
- package/bin/control/journey.mjs +31 -3
- package/bin/control/journey.test.mjs +207 -2
- package/bin/control/launch.mjs +123 -0
- package/bin/control/module-root.mjs +40 -0
- package/bin/control/module-root.test.mjs +67 -0
- package/bin/control/mongo-server.test.mjs +91 -0
- package/bin/control/mongo.mjs +125 -12
- package/bin/control/options.mjs +1 -0
- package/bin/control/pid-reuse.test.mjs +278 -0
- package/bin/control/processes.mjs +91 -29
- package/bin/control/renderer.test.mjs +1 -1
- package/bin/control/run-copy.mjs +6 -1
- package/bin/control/run-state.mjs +4 -1
- package/bin/control/stack.mjs +78 -165
- package/bin/control/verify/behaviour.test.mjs +36 -23
- package/bin/control/verify/decode.mjs +1 -0
- package/bin/control/verify/emit.mjs +11 -11
- package/bin/control/verify/formal.mjs +28 -14
- package/bin/control/verify/formal.test.mjs +15 -0
- package/bin/control/verify/types.mjs +1 -1
- package/bin/dms-control.mjs +4 -2
- package/dist/db/models/userNotifications.model.js +14 -8
- package/dist/db/models/userNotifications.model.js.map +1 -1
- package/dist/pages/public/auth/not-a-member.d.ts +9 -0
- package/dist/pages/public/auth/not-a-member.js +27 -0
- package/dist/pages/public/auth/not-a-member.js.map +1 -0
- package/dist/pages/public/index.d.ts +1 -0
- package/dist/pages/public/index.js +1 -0
- package/dist/pages/public/index.js.map +1 -1
- package/dist/routes/auth/oauth/identity-resolution.js +10 -0
- package/dist/routes/auth/oauth/identity-resolution.js.map +1 -1
- package/dist/routes/onboarding.js +1 -5
- package/dist/routes/onboarding.js.map +1 -1
- package/dist/utils/ensure-default-tenant.js +23 -3
- package/dist/utils/ensure-default-tenant.js.map +1 -1
- package/frontend-vue/layers/dms-auth/app/build/utils/noWorkspaceRoute.ts +19 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/login.vue +4 -6
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/not-a-member.vue +21 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/oauth-complete.vue +2 -4
- package/frontend-vue/layers/dms-auth/i18n/locales/auth-en-GB.json +6 -0
- package/frontend-vue/layers/dms-auth/i18n/locales/auth-fr-FR.json +6 -0
- package/frontend-vue/layers/dms-core/app/types/live.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +9 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/live/currentPageLive.ts +7 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/live/pageLiveController.ts +23 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/live/usePageDataRefresh.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewRealtime.ts +21 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableLiveHold.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/accessibilityPreferences.ts +1 -21
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +8 -4
- package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +35 -7
- package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +51 -8
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/utils/reducedMotion.ts +22 -0
- package/package.json +4 -4
- package/skills/dms-pages/REFERENCE.md +1 -1
|
@@ -16,7 +16,7 @@ import { git } from "./git.mjs";
|
|
|
16
16
|
import { resolveRenderer } from "./renderer.mjs";
|
|
17
17
|
import { decodeSkillConfig } from "./verify/decode.mjs";
|
|
18
18
|
import { layOutCopy } from "./run-copy.mjs";
|
|
19
|
-
import { cliPaths } from "./
|
|
19
|
+
import { cliPaths } from "./launch.mjs";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {import("node:test").TestContext} t The test
|
package/bin/control/run-copy.mjs
CHANGED
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
import { basename, join, relative, sep } from "node:path";
|
|
9
9
|
import { WORKSPACE_FOLDER } from "./build-key.mjs";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** The playground entries a copy leaves out: installed modules and builds. */
|
|
12
|
+
export const COPY_SKIPPED = new Set([
|
|
13
|
+
"node_modules",
|
|
14
|
+
".antelope",
|
|
15
|
+
WORKSPACE_FOLDER,
|
|
16
|
+
]);
|
|
12
17
|
const SHADOW_SKIPPED = new Set([".antelope", WORKSPACE_FOLDER, ".git"]);
|
|
13
18
|
|
|
14
19
|
/**
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
isString,
|
|
22
22
|
nullable,
|
|
23
23
|
objectOf,
|
|
24
|
+
oneOf,
|
|
24
25
|
recordOf,
|
|
25
26
|
} from "./json.mjs";
|
|
26
27
|
|
|
@@ -33,7 +34,8 @@ const TIMESTAMP_LENGTH = 15;
|
|
|
33
34
|
* @typedef {ProcessRecord & { port: number }} ServerRecord
|
|
34
35
|
* @typedef {ServerRecord & { database: string }} BackendRecord A backend the run started, with the database it serves
|
|
35
36
|
* @typedef {{ email: string, password: string, userId?: string | null }} Account
|
|
36
|
-
* @typedef {{ dir: string, root: string, home: string, logs: string, mongo: string, browser?: ServerRecord, evidence: string, cache: string, id: string, createdAt: string, environment: string, playground: string, moduleRoot: string, repo: string | null, headSha: string | null, renderer?: string, baseRef: string, skill: string | null, apiPort: number, webPort: number, smtpPort: number, mail: string, apiUrl: string, webUrl: string, databasePrefix: string, database: string, mongoUrl: string, ownsMongo: boolean, secrets: Record<string, string>, adminPassword: string, extraEnv: Record<string, string>, processes: ProcessRecord[], namespaces?: import("./identity.mjs").Namespaces, noStandby?: boolean, buildRoots?: string[], accounts: Record<string, Account>, tokens: Record<string, string>, ready: boolean, error?: string, runPlayground?: string, baseRoot?: string, resetCount?: number, journeyCount?: number, frontendBuild?: FrontendBuild, bakedEnv?: Record<string, string> }} RunState
|
|
37
|
+
* @typedef {{ dir: string, root: string, home: string, logs: string, mongo: string, browser?: ServerRecord, evidence: string, cache: string, id: string, createdAt: string, environment: string, playground: string, moduleRoot: string, repo: string | null, headSha: string | null, renderer?: string, baseRef: string, skill: string | null, apiPort: number, webPort: number, smtpPort: number, mail: string, apiUrl: string, webUrl: string, databasePrefix: string, database: string, mongoUrl: string, ownsMongo: boolean, secrets: Record<string, string>, adminPassword: string, extraEnv: Record<string, string>, processes: ProcessRecord[], namespaces?: import("./identity.mjs").Namespaces, noStandby?: boolean, frontendMode?: FrontendMode, buildRoots?: string[], accounts: Record<string, Account>, tokens: Record<string, string>, ready: boolean, error?: string, runPlayground?: string, baseRoot?: string, resetCount?: number, journeyCount?: number, frontendBuild?: FrontendBuild, bakedEnv?: Record<string, string> }} RunState
|
|
38
|
+
* @typedef {"build" | "dev"} FrontendMode How the run serves its dashboard: `build` runs `ajs dms build` then `ajs dms start`, `dev` runs `ajs dms dev` on the sources. A run without one serves a build.
|
|
37
39
|
* @typedef {{ key: string | null, cached: boolean, reason?: string }} FrontendBuild The key of the inputs of the run's frontend build (null when it was not keyed), whether the build came from the build cache, and why the cache was not used or not filled when it should have been
|
|
38
40
|
*/
|
|
39
41
|
|
|
@@ -186,6 +188,7 @@ const isStoredRun = objectOf(
|
|
|
186
188
|
browser: either(isString, isServerRecord),
|
|
187
189
|
namespaces: objectOf({}, { pid: isString, time: isString }),
|
|
188
190
|
noStandby: isBoolean,
|
|
191
|
+
frontendMode: oneOf(["build", "dev"]),
|
|
189
192
|
buildRoots: arrayOf(isString),
|
|
190
193
|
error: isString,
|
|
191
194
|
renderer: isString,
|
package/bin/control/stack.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { existsSync, rmSync } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
6
4
|
import { layOutFrontendBuild } from "./build-cache.mjs";
|
|
7
5
|
import { existingBuildRoots } from "./build-inputs.mjs";
|
|
8
6
|
import { describeFailure } from "./failure.mjs";
|
|
@@ -29,14 +27,23 @@ import {
|
|
|
29
27
|
runsRoot,
|
|
30
28
|
saveRun,
|
|
31
29
|
} from "./run-state.mjs";
|
|
32
|
-
import {
|
|
30
|
+
import { resolveRenderer } from "./renderer.mjs";
|
|
31
|
+
import { moduleRootOf } from "./module-root.mjs";
|
|
32
|
+
import {
|
|
33
|
+
cliPaths,
|
|
34
|
+
CONTROL_BIN,
|
|
35
|
+
ENVIRONMENT,
|
|
36
|
+
frontendPackage,
|
|
37
|
+
resolutionFolders,
|
|
38
|
+
spec,
|
|
39
|
+
} from "./launch.mjs";
|
|
33
40
|
import { layOutCopy } from "./run-copy.mjs";
|
|
34
41
|
import { newPassword } from "./session.mjs";
|
|
35
42
|
import { appendTiming, recordTiming, stopwatch, timed } from "./timing.mjs";
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
45
|
* @typedef {import("./run-state.mjs").RunState} RunState
|
|
39
|
-
* @typedef {{ playground: string, renderer?: string, runs?: string, mongoUrl?: string, env?: string[], base?: string, skill?: string, prepared?: import("./timing.mjs").TimingEntry[], noStandby?: boolean, buildCache?: boolean }} UpOptions Where the playground and the runs are, the `prepare` entries to record once the run exists, whether fresh databases start their backend on the spot,
|
|
46
|
+
* @typedef {{ playground: string, renderer?: string, runs?: string, mongoUrl?: string, env?: string[], base?: string, skill?: string, prepared?: import("./timing.mjs").TimingEntry[], noStandby?: boolean, buildCache?: boolean, frontendMode?: import("./run-state.mjs").FrontendMode }} UpOptions Where the playground and the runs are, the `prepare` entries to record once the run exists, whether fresh databases start their backend on the spot, whether the frontend build may come from the build cache (it may unless `buildCache` is false), and how the dashboard is served (a build unless `frontendMode` is `dev`)
|
|
40
47
|
*/
|
|
41
48
|
|
|
42
49
|
const READY_TIMEOUT_MS = 180_000;
|
|
@@ -52,103 +59,6 @@ const SECRET_NAMES = [
|
|
|
52
59
|
"DMS_SESSION_SECRET",
|
|
53
60
|
"DMS_SETUP_TOKEN",
|
|
54
61
|
];
|
|
55
|
-
const DROPPED_PREFIXES = ["ANTELOPEJS_", "npm_", "PNPM_", "DMS_", "MONGO_"];
|
|
56
|
-
|
|
57
|
-
/** This package's root, which resolves dms-control's own dependencies. */
|
|
58
|
-
export const PACKAGE_ROOT = resolve(import.meta.dirname, "..", "..");
|
|
59
|
-
|
|
60
|
-
/** The dms-control entry, which also serves the mail sink and the browser. */
|
|
61
|
-
export const CONTROL_BIN = join(PACKAGE_ROOT, "bin", "dms-control.mjs");
|
|
62
|
-
|
|
63
|
-
/** The AntelopeJS environment every run builds and starts. */
|
|
64
|
-
export const ENVIRONMENT = "docs";
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The folders the project's dependencies resolve from: the playground, the
|
|
68
|
-
* module it belongs to, then this package.
|
|
69
|
-
*
|
|
70
|
-
* @param {{ playground: string, moduleRoot: string }} state The run
|
|
71
|
-
* @returns {string[]} The folders, in order
|
|
72
|
-
*/
|
|
73
|
-
export function resolutionFolders(state) {
|
|
74
|
-
return [state.playground, state.moduleRoot, PACKAGE_ROOT];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The `ajs` and `ajs dms` entry points the playground installs, `ajs dms`
|
|
79
|
-
* being the renderer checkout's when the run serves one.
|
|
80
|
-
*
|
|
81
|
-
* @param {string} playground The playground folder
|
|
82
|
-
* @param {string} [renderer] The renderer checkout the run serves
|
|
83
|
-
* @returns {{ ajs: string, dms: string }} Their scripts
|
|
84
|
-
*/
|
|
85
|
-
export function cliPaths(playground, renderer) {
|
|
86
|
-
const require = createRequire(join(playground, "package.json"));
|
|
87
|
-
const core = dirname(require.resolve("@antelopejs/core/package.json"));
|
|
88
|
-
return {
|
|
89
|
-
ajs: join(core, "dist", "core", "cli", "index.js"),
|
|
90
|
-
dms: join(frontendPackage(playground, renderer), RENDERER_CLI),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The `@antelopejs/dms-frontend` that builds and serves the run's dashboard:
|
|
96
|
-
* the renderer checkout, else the one the playground installs.
|
|
97
|
-
*
|
|
98
|
-
* @param {string} playground The playground folder
|
|
99
|
-
* @param {string} [renderer] The renderer checkout the run serves
|
|
100
|
-
* @returns {string} Its folder
|
|
101
|
-
*/
|
|
102
|
-
export function frontendPackage(playground, renderer) {
|
|
103
|
-
const require = createRequire(join(playground, "package.json"));
|
|
104
|
-
return (
|
|
105
|
-
renderer ??
|
|
106
|
-
dirname(require.resolve("@antelopejs/dms-frontend/package.json"))
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function inheritedEnv() {
|
|
111
|
-
return Object.fromEntries(
|
|
112
|
-
Object.entries(process.env).filter(
|
|
113
|
-
([key]) => !DROPPED_PREFIXES.some((prefix) => key.startsWith(prefix)),
|
|
114
|
-
),
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The environment of every process a run starts: its own HOME, ports,
|
|
120
|
-
* database, origin and secrets, an npm cache and a pnpm store shared by
|
|
121
|
-
* every run, no update checks and no colors. Extra `KEY=VALUE` pairs from `--env` come last.
|
|
122
|
-
*
|
|
123
|
-
* @param {import("./run-state.mjs").RunState} state The run
|
|
124
|
-
* @returns {NodeJS.ProcessEnv} The environment
|
|
125
|
-
*/
|
|
126
|
-
export function runEnv(state) {
|
|
127
|
-
const cacheHome = process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache");
|
|
128
|
-
return {
|
|
129
|
-
...inheritedEnv(),
|
|
130
|
-
HOME: state.home,
|
|
131
|
-
USERPROFILE: state.home,
|
|
132
|
-
CI: "1",
|
|
133
|
-
NO_COLOR: "1",
|
|
134
|
-
AJS_NO_UPDATE_CHECK: "1",
|
|
135
|
-
NO_UPDATE_NOTIFIER: "1",
|
|
136
|
-
COREPACK_HOME:
|
|
137
|
-
process.env.COREPACK_HOME ?? join(cacheHome, "node", "corepack"),
|
|
138
|
-
npm_config_cache: join(cacheHome, "dms-control", "npm"),
|
|
139
|
-
npm_config_store_dir: join(cacheHome, "dms-control", "pnpm-store"),
|
|
140
|
-
PORT: String(state.apiPort),
|
|
141
|
-
DMS_CLIENT_BASE_URL: state.webUrl,
|
|
142
|
-
DMS_API_BASE_URL: state.apiUrl,
|
|
143
|
-
DMS_PREBUILT: "1",
|
|
144
|
-
DMS_SMTP_PORT: String(state.smtpPort),
|
|
145
|
-
MONGO_URL: state.mongoUrl,
|
|
146
|
-
MONGO_DATABASE: state.database,
|
|
147
|
-
...state.secrets,
|
|
148
|
-
...state.extraEnv,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
62
|
/**
|
|
153
63
|
* @param {string[]} pairs
|
|
154
64
|
* @returns {Record<string, string>}
|
|
@@ -186,7 +96,7 @@ async function initialState(options) {
|
|
|
186
96
|
createdAt: new Date().toISOString(),
|
|
187
97
|
environment: ENVIRONMENT,
|
|
188
98
|
playground,
|
|
189
|
-
moduleRoot:
|
|
99
|
+
moduleRoot: moduleRootOf(playground),
|
|
190
100
|
repo: checkout.root,
|
|
191
101
|
headSha: verified.head,
|
|
192
102
|
baseRef: options.base ?? "origin/main",
|
|
@@ -217,31 +127,10 @@ async function initialState(options) {
|
|
|
217
127
|
};
|
|
218
128
|
if (renderer) state.renderer = renderer;
|
|
219
129
|
if (options.noStandby) state.noStandby = true;
|
|
130
|
+
if (options.frontendMode === "dev") state.frontendMode = "dev";
|
|
220
131
|
return state;
|
|
221
132
|
}
|
|
222
133
|
|
|
223
|
-
/**
|
|
224
|
-
* How to run one of the playground's CLIs for the run: its own log, the
|
|
225
|
-
* run's environment, from the run's playground copy or `cwd`.
|
|
226
|
-
*
|
|
227
|
-
* @param {import("./run-state.mjs").RunState} state The run
|
|
228
|
-
* @param {string} name The log name
|
|
229
|
-
* @param {string} script The CLI script
|
|
230
|
-
* @param {string[]} args Its arguments
|
|
231
|
-
* @param {string} [cwd] Where to run it
|
|
232
|
-
* @returns {{ name: string, program: string, args: string[], cwd: string, env: NodeJS.ProcessEnv, logs: string }} The process spec
|
|
233
|
-
*/
|
|
234
|
-
export function spec(state, name, script, args, cwd = state.runPlayground) {
|
|
235
|
-
return {
|
|
236
|
-
name,
|
|
237
|
-
program: process.execPath,
|
|
238
|
-
args: [script, ...args],
|
|
239
|
-
cwd,
|
|
240
|
-
env: runEnv(state),
|
|
241
|
-
logs: state.logs,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
134
|
/**
|
|
246
135
|
* Records a process of the run, in place of the one of the same name.
|
|
247
136
|
*
|
|
@@ -421,13 +310,71 @@ export function workspaceSetup(state, name, project, install) {
|
|
|
421
310
|
);
|
|
422
311
|
}
|
|
423
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Builds the run's dashboard as `ajs dms build` does, in a prepared
|
|
315
|
+
* workspace, or lays out the build of the same inputs from the build cache.
|
|
316
|
+
*
|
|
317
|
+
* @param {RunState} state The run, after its project build
|
|
318
|
+
* @param {boolean} useCache Whether the build may come from the build cache
|
|
319
|
+
* @returns {Promise<void>} Resolves once the build is in the run's workspace
|
|
320
|
+
*/
|
|
321
|
+
function buildFrontend(state, useCache) {
|
|
322
|
+
const { dms } = cliPaths(state.playground, state.renderer);
|
|
323
|
+
return layOutFrontendBuild(
|
|
324
|
+
state,
|
|
325
|
+
frontendPackage(state.playground, state.renderer),
|
|
326
|
+
{
|
|
327
|
+
prepare: (workspace) =>
|
|
328
|
+
timed(state, "frontend-prepare", () =>
|
|
329
|
+
workspaceSetup(
|
|
330
|
+
state,
|
|
331
|
+
"frontend-prepare",
|
|
332
|
+
state.runPlayground ?? "",
|
|
333
|
+
true,
|
|
334
|
+
)(workspace),
|
|
335
|
+
),
|
|
336
|
+
build: (prepared) => {
|
|
337
|
+
const build = spec(state, "frontend-build", dms, [
|
|
338
|
+
"build",
|
|
339
|
+
"-e",
|
|
340
|
+
ENVIRONMENT,
|
|
341
|
+
]);
|
|
342
|
+
if (prepared) build.args.unshift("--import", PREPARED_WORKSPACE);
|
|
343
|
+
return runToEnd(build);
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
useCache,
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* How the run serves its dashboard on its web port against its API:
|
|
352
|
+
* `ajs dms start` on the build `up` made, or `ajs dms dev` on the sources
|
|
353
|
+
* when the run's `frontendMode` is `dev`.
|
|
354
|
+
*
|
|
355
|
+
* @param {RunState} state The run
|
|
356
|
+
* @returns {ReturnType<typeof spec>} The frontend's process spec
|
|
357
|
+
*/
|
|
358
|
+
export function frontendSpec(state) {
|
|
359
|
+
const { dms } = cliPaths(state.playground, state.renderer);
|
|
360
|
+
return spec(state, "frontend", dms, [
|
|
361
|
+
state.frontendMode === "dev" ? "dev" : "start",
|
|
362
|
+
"-e",
|
|
363
|
+
ENVIRONMENT,
|
|
364
|
+
"-b",
|
|
365
|
+
state.apiUrl,
|
|
366
|
+
"-p",
|
|
367
|
+
String(state.webPort),
|
|
368
|
+
]);
|
|
369
|
+
}
|
|
370
|
+
|
|
424
371
|
/**
|
|
425
372
|
* @param {RunState} state
|
|
426
373
|
* @param {boolean} useCache
|
|
427
374
|
* @returns {Promise<void>}
|
|
428
375
|
*/
|
|
429
376
|
async function buildAndStart(state, useCache) {
|
|
430
|
-
const
|
|
377
|
+
const { ajs } = cliPaths(state.playground, state.renderer);
|
|
431
378
|
state.runPlayground = await timed(state, "layout", () =>
|
|
432
379
|
layOutCopy(
|
|
433
380
|
state.playground,
|
|
@@ -446,7 +393,7 @@ async function buildAndStart(state, useCache) {
|
|
|
446
393
|
await timed(state, "mail", () => startFirstMail(state));
|
|
447
394
|
await timed(state, "project-build", () =>
|
|
448
395
|
runToEnd(
|
|
449
|
-
spec(state, "project-build",
|
|
396
|
+
spec(state, "project-build", ajs, [
|
|
450
397
|
"project",
|
|
451
398
|
"build",
|
|
452
399
|
"-e",
|
|
@@ -454,48 +401,14 @@ async function buildAndStart(state, useCache) {
|
|
|
454
401
|
]),
|
|
455
402
|
),
|
|
456
403
|
);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
frontendPackage(state.playground, state.renderer),
|
|
461
|
-
{
|
|
462
|
-
prepare: (workspace) =>
|
|
463
|
-
timed(state, "frontend-prepare", () =>
|
|
464
|
-
workspaceSetup(
|
|
465
|
-
state,
|
|
466
|
-
"frontend-prepare",
|
|
467
|
-
state.runPlayground ?? "",
|
|
468
|
-
true,
|
|
469
|
-
)(workspace),
|
|
470
|
-
),
|
|
471
|
-
build: (prepared) => {
|
|
472
|
-
const build = spec(state, "frontend-build", clis.dms, [
|
|
473
|
-
"build",
|
|
474
|
-
"-e",
|
|
475
|
-
ENVIRONMENT,
|
|
476
|
-
]);
|
|
477
|
-
if (prepared) build.args.unshift("--import", PREPARED_WORKSPACE);
|
|
478
|
-
return runToEnd(build);
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
useCache,
|
|
482
|
-
),
|
|
483
|
-
);
|
|
404
|
+
if (state.frontendMode !== "dev") {
|
|
405
|
+
await timed(state, "frontend-build", () => buildFrontend(state, useCache));
|
|
406
|
+
}
|
|
484
407
|
state.buildRoots = existingBuildRoots(state);
|
|
485
408
|
saveRun(state);
|
|
486
409
|
await timed(state, "backend-start", () => startBackend(state));
|
|
487
410
|
await timed(state, "frontend-start", async () => {
|
|
488
|
-
const frontend = startDetached(
|
|
489
|
-
spec(state, "frontend", clis.dms, [
|
|
490
|
-
"start",
|
|
491
|
-
"-e",
|
|
492
|
-
ENVIRONMENT,
|
|
493
|
-
"-b",
|
|
494
|
-
state.apiUrl,
|
|
495
|
-
"-p",
|
|
496
|
-
String(state.webPort),
|
|
497
|
-
]),
|
|
498
|
-
);
|
|
411
|
+
const frontend = startDetached(frontendSpec(state));
|
|
499
412
|
record(state, { ...frontend, port: state.webPort });
|
|
500
413
|
await waitForOk(`${state.webUrl}/dms-preview`, frontend, READY_TIMEOUT_MS);
|
|
501
414
|
});
|
|
@@ -384,6 +384,12 @@ const NON_LITERAL_SPECIFIERS = [
|
|
|
384
384
|
"export { a } from foo;\n",
|
|
385
385
|
"export { a } from bar;\n",
|
|
386
386
|
],
|
|
387
|
+
["a call", "import x from a();\nx();\n", "import x from b();\nx();\n"],
|
|
388
|
+
[
|
|
389
|
+
"a template with substitutions",
|
|
390
|
+
"import x from `./${a}`;\nx();\n",
|
|
391
|
+
"import x from `./${b}`;\nx();\n",
|
|
392
|
+
],
|
|
387
393
|
];
|
|
388
394
|
|
|
389
395
|
for (const [kind, base, head] of NON_LITERAL_SPECIFIERS) {
|
|
@@ -427,33 +433,40 @@ const SAME_TEXT_SPECIFIERS = [
|
|
|
427
433
|
];
|
|
428
434
|
|
|
429
435
|
for (const [kind, base, head] of SAME_TEXT_SPECIFIERS) {
|
|
430
|
-
await test(`${kind} is
|
|
431
|
-
assert.equal(changed(t, { "src/a.ts": base }, { "src/a.ts": head }),
|
|
436
|
+
await test(`${kind} is changed`, (t) => {
|
|
437
|
+
assert.equal(changed(t, { "src/a.ts": base }, { "src/a.ts": head }), true);
|
|
432
438
|
});
|
|
433
439
|
}
|
|
434
440
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
name
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
441
|
+
const EXPRESSION_SPECIFIERS = [
|
|
442
|
+
["a call expression", "import x from a();\nx();\n"],
|
|
443
|
+
[
|
|
444
|
+
"a template literal with substitutions",
|
|
445
|
+
"import x from `./${name}`;\nx();\n",
|
|
446
|
+
],
|
|
447
|
+
];
|
|
448
|
+
|
|
449
|
+
for (const [kind, expression] of EXPRESSION_SPECIFIERS) {
|
|
450
|
+
await test(`a module specifier that is ${kind} is changed against a string on either commit`, (t) => {
|
|
451
|
+
const valid = 'import x from "./a";\nx();\n';
|
|
452
|
+
assert.equal(
|
|
453
|
+
changed(t, { "src/a.ts": valid }, { "src/a.ts": expression }),
|
|
454
|
+
true,
|
|
455
|
+
);
|
|
456
|
+
assert.equal(
|
|
457
|
+
changed(t, { "src/a.ts": expression }, { "src/a.ts": valid }),
|
|
458
|
+
true,
|
|
459
|
+
);
|
|
445
460
|
});
|
|
446
|
-
}
|
|
461
|
+
}
|
|
447
462
|
|
|
448
|
-
await test("a module specifier that is
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
() => changed(t, { "src/a.ts": template }, { "src/a.ts": valid }),
|
|
457
|
-
{ name: "TypeError", message: /found TemplateExpression/ },
|
|
463
|
+
await test("reformatting a module specifier that is an expression is unchanged", (t) => {
|
|
464
|
+
assert.equal(
|
|
465
|
+
changed(
|
|
466
|
+
t,
|
|
467
|
+
{ "src/a.ts": "import x from a('1');\nx();\n" },
|
|
468
|
+
{ "src/a.ts": 'import x from (a( "1" ));\nx();\n' },
|
|
469
|
+
),
|
|
470
|
+
false,
|
|
458
471
|
);
|
|
459
472
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, extname, join, posix } from "node:path";
|
|
4
|
-
import { PACKAGE_ROOT } from "../
|
|
4
|
+
import { PACKAGE_ROOT } from "../launch.mjs";
|
|
5
5
|
|
|
6
6
|
/** @typedef {typeof import("typescript")} TypeScript */
|
|
7
7
|
/** @typedef {import("typescript").Node} Node */
|
|
@@ -83,20 +83,20 @@ function leafOf(ts, node, bindings) {
|
|
|
83
83
|
const MODULE_EXTENSION = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The
|
|
87
|
-
*
|
|
86
|
+
* The module a specifier names. Only a string literal names a module; any
|
|
87
|
+
* other expression, which only a file that does not parse as a module can
|
|
88
|
+
* hold, is keyed by its structure, so it never reads as the module its text
|
|
89
|
+
* spells.
|
|
88
90
|
*
|
|
89
91
|
* @param {TypeScript} ts
|
|
92
|
+
* @param {string} path The file that holds the specifier
|
|
90
93
|
* @param {import("typescript").Expression} specifier
|
|
91
94
|
* @returns {string}
|
|
92
|
-
* @throws {TypeError} For any other expression, such as a call
|
|
93
95
|
*/
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`a module specifier must be a name, found ${ts.SyntaxKind[specifier.kind]}`,
|
|
99
|
-
);
|
|
96
|
+
function moduleOf(ts, path, specifier) {
|
|
97
|
+
return ts.isStringLiteral(specifier)
|
|
98
|
+
? moduleKey(path, specifier.text)
|
|
99
|
+
: `expression ${structureOf(ts, specifier, new Map())}`;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -269,7 +269,7 @@ function originsOf(ts, path, covered, file, locals) {
|
|
|
269
269
|
if (specifier === undefined && ts.isExportDeclaration(statement))
|
|
270
270
|
exports.push(statement);
|
|
271
271
|
if (specifier === undefined) continue;
|
|
272
|
-
const module =
|
|
272
|
+
const module = moduleOf(ts, path, specifier);
|
|
273
273
|
if (ts.isImportDeclaration(statement)) {
|
|
274
274
|
if (statement.importClause === undefined) {
|
|
275
275
|
ordered.push(`import ${module}`);
|
|
@@ -125,22 +125,31 @@ function baseRules(skill, check, baseSha, folder) {
|
|
|
125
125
|
* @param {{ baseSha: string, headSha: string, changed: string[] }} diff The diff
|
|
126
126
|
* @param {string} folder The evidence folder
|
|
127
127
|
* @param {import("./types.mjs").Rules} head The rules at HEAD
|
|
128
|
-
* @returns {Pick<import("./types.mjs").FormalResult, "behaviour" | "checkChanged" | "base" | "fixed" | "missing">} The gate fields
|
|
128
|
+
* @returns {Pick<import("./types.mjs").FormalResult, "behaviour" | "checkChanged" | "base" | "fixed" | "dropped" | "missing">} The gate fields
|
|
129
129
|
*/
|
|
130
130
|
function gateFields(skill, check, diff, folder, head) {
|
|
131
131
|
const behaviour = behaviourChange(skill, check, diff);
|
|
132
132
|
const checkChanged = changesCheckFiles(check, diff.changed);
|
|
133
133
|
if (!behaviour.changed && !checkChanged)
|
|
134
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
behaviour,
|
|
136
|
+
checkChanged,
|
|
137
|
+
base: null,
|
|
138
|
+
fixed: [],
|
|
139
|
+
dropped: [],
|
|
140
|
+
missing: [],
|
|
141
|
+
};
|
|
135
142
|
const base = baseRules(skill, check, diff.baseSha, folder);
|
|
136
143
|
const atHead = new Set([...head.violated, ...head.passing]);
|
|
144
|
+
const passingNow = base.violated.filter(
|
|
145
|
+
(rule) => head.passing.includes(rule) && !head.violated.includes(rule),
|
|
146
|
+
);
|
|
137
147
|
return {
|
|
138
148
|
behaviour,
|
|
139
149
|
checkChanged,
|
|
140
150
|
base,
|
|
141
|
-
fixed:
|
|
142
|
-
|
|
143
|
-
),
|
|
151
|
+
fixed: behaviour.changed ? passingNow : [],
|
|
152
|
+
dropped: behaviour.changed ? [] : passingNow,
|
|
144
153
|
missing: base.violated.filter((rule) => !atHead.has(rule)),
|
|
145
154
|
};
|
|
146
155
|
}
|
|
@@ -151,8 +160,10 @@ function gateFields(skill, check, diff, folder, head) {
|
|
|
151
160
|
* When the diff touches the check (`diff` given), it also records whether
|
|
152
161
|
* the diff changed the behaviour of the covered code. When it did, or when
|
|
153
162
|
* the diff changed the check's own `files`, it runs the check on the base:
|
|
154
|
-
* `fixed` lists the rules the base broke that HEAD reports passing
|
|
155
|
-
* `
|
|
163
|
+
* `fixed` lists the rules the base broke that HEAD reports passing when the
|
|
164
|
+
* covered behaviour changed, `dropped` the same rules when it did not (only
|
|
165
|
+
* the edit to the check removed them), and `missing` the rules the base
|
|
166
|
+
* broke that HEAD reports neither failing nor passing.
|
|
156
167
|
*
|
|
157
168
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
158
169
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
@@ -193,7 +204,9 @@ export function runFormalCheck(skill, state, check, diff) {
|
|
|
193
204
|
* non-zero exit (a tool error, or a check that no longer matches its
|
|
194
205
|
* record) fails; recorded findings fail only when the diff changed the
|
|
195
206
|
* covered code's behaviour; a rule the base reported and HEAD no longer
|
|
196
|
-
* reports fails;
|
|
207
|
+
* reports fails; a rule the base broke that HEAD reports passing though the
|
|
208
|
+
* covered behaviour is unchanged fails; rules the base broke that HEAD
|
|
209
|
+
* reports passing after a behaviour change are fixed.
|
|
197
210
|
*
|
|
198
211
|
* @param {import("./types.mjs").FormalResult} result The recorded result
|
|
199
212
|
* @returns {{ fails: boolean, outcome: string }} The weight and its wording
|
|
@@ -206,12 +219,13 @@ export function formalGate(result) {
|
|
|
206
219
|
: "tool error";
|
|
207
220
|
return { fails: true, outcome: `${what}, exit ${result.exitCode}` };
|
|
208
221
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
222
|
+
const gone = [
|
|
223
|
+
result.missing?.length > 0 &&
|
|
224
|
+
`rules the base broke are absent at HEAD: ${result.missing.join(", ")}`,
|
|
225
|
+
result.dropped?.length > 0 &&
|
|
226
|
+
`findings the base broke are gone at HEAD, though the covered behaviour is unchanged (${result.behaviour?.method}): ${result.dropped.join(", ")}`,
|
|
227
|
+
].filter(Boolean);
|
|
228
|
+
if (gone.length > 0) return { fails: true, outcome: gone.join("; ") };
|
|
215
229
|
const fixed =
|
|
216
230
|
result.fixed?.length > 0 ? `; fixed: ${result.fixed.join(", ")}` : "";
|
|
217
231
|
if (!result.behaviour) {
|
|
@@ -130,6 +130,21 @@ await test("a diff that touches only a check's own files runs the check and gate
|
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
+
await test("a finding that only an edit to the check turns passing is dropped, not fixed, and fails the gate", (t) => {
|
|
134
|
+
const result = gated(
|
|
135
|
+
formalRepo(t, {
|
|
136
|
+
".agents/skills/formal-add/check.mjs": CHECK_FIXED,
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
assert.deepEqual(result.fixed, []);
|
|
140
|
+
assert.deepEqual(result.dropped, ["NegativeZero"]);
|
|
141
|
+
assert.deepEqual(formalGate(result), {
|
|
142
|
+
fails: true,
|
|
143
|
+
outcome:
|
|
144
|
+
"findings the base broke are gone at HEAD, though the covered behaviour is unchanged (emit): NegativeZero",
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
133
148
|
await test("a diff that touches neither the covered files nor the check's files does not touch the check", (t) => {
|
|
134
149
|
const { skill, diff } = formalRepo(t, { "README.md": "# Demo\n" });
|
|
135
150
|
assert.deepEqual(touchedFormalChecks(skill, diff.changed), []);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @typedef {{ baseSha: string, headSha: string }} Commits
|
|
9
9
|
* @typedef {{ method: string, changed: boolean, removed: string[], added: string[] }} BehaviourChange
|
|
10
10
|
* @typedef {{ exitCode: number | null, violated: string[], passing: string[] }} Rules
|
|
11
|
-
* @typedef {{ name: string, exitCode: number | null, violated: string[], passing: string[], folder: string, commits?: Commits, behaviour?: BehaviourChange, checkChanged?: boolean, base?: Rules | null, fixed?: string[], missing?: string[] }} FormalResult
|
|
11
|
+
* @typedef {{ name: string, exitCode: number | null, violated: string[], passing: string[], folder: string, commits?: Commits, behaviour?: BehaviourChange, checkChanged?: boolean, base?: Rules | null, fixed?: string[], dropped?: string[], missing?: string[] }} FormalResult
|
|
12
12
|
* @typedef {{ feature: string, files: string[] }} TouchedFeature
|
|
13
13
|
* @typedef {{ baseRef: string, baseSha: string, headSha: string, changed: string[], touched: TouchedFeature[], shared: string[], unmapped: string[], docs: string[], run: string[] }} Plan
|
|
14
14
|
* @typedef {{ kind?: string, location?: string, irreversible?: string, containment?: string }} RawDoorRow
|
package/bin/dms-control.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { runVerifyCommand } from "./control/commands-verify.mjs";
|
|
|
7
7
|
const USAGE = `Usage: dms-control <command>
|
|
8
8
|
|
|
9
9
|
Drive an isolated DMS (run from the repository, or pass --playground):
|
|
10
|
-
up [--prepare] [--playground <dir>] [--renderer <dir>] [--runs <dir>] [--mongo-url <url>] [--env KEY=VALUE]... [--base <ref>] [--skill <dir>] [--no-standby] [--no-build-cache]
|
|
10
|
+
up [--prepare] [--playground <dir>] [--renderer <dir>] [--runs <dir>] [--mongo-url <url>] [--env KEY=VALUE]... [--base <ref>] [--skill <dir>] [--no-standby] [--no-build-cache] [--dev-frontend]
|
|
11
11
|
build and start a playground copy on free ports; print the run folder
|
|
12
12
|
(--prepare first runs the skill's install and build commands;
|
|
13
13
|
--renderer serves that built @antelopejs/dms-frontend checkout;
|
|
@@ -15,7 +15,9 @@ Drive an isolated DMS (run from the repository, or pass --playground):
|
|
|
15
15
|
backend when it is needed instead of one ahead: about 160 MB less while
|
|
16
16
|
journeys run, about 5 s more per journey;
|
|
17
17
|
the frontend build of the same inputs comes from $XDG_CACHE_HOME/dms-control/frontend,
|
|
18
|
-
--no-build-cache runs ajs dms build as it is
|
|
18
|
+
--no-build-cache runs ajs dms build as it is;
|
|
19
|
+
--dev-frontend serves the sources with ajs dms dev instead of a build,
|
|
20
|
+
which shows the module UI a production frontend leaves out)
|
|
19
21
|
doctor <run> [--verbose] check the run is worth driving; print the failing checks
|
|
20
22
|
onboard <run> [--platform-name <name>]
|
|
21
23
|
create the run's administrator through POST /api/onboarding/register
|