@antelopejs/tooling-configs 0.3.3 → 0.3.5
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/dist/bin/api-diff.mjs +2 -2
- package/dist/bin/checks.mjs +15 -13
- package/dist/bin/comment-proof.mjs +1 -1
- package/dist/bin/garden.mjs +67 -8
- package/dist/bin/lease.mjs +202 -57
- package/dist/bin/ratchet.mjs +1 -1
- package/dist/bin/sync.mjs +11 -9
- package/dist/bin/verify.mjs +868 -381
- package/dist/{ci-workflow-CXcAZj6g.mjs → ci-workflow-C4mQ8QSp.mjs} +84 -4
- package/dist/env-DT0UJNeL.mjs +79 -0
- package/dist/formal/index.d.mts +12 -0
- package/dist/formal/index.mjs +171 -56
- package/dist/map-s_jKqBQv.mjs +397 -0
- package/dist/oxc/fmt.d.mts +4 -0
- package/dist/oxc/lint.mjs +1 -1
- package/dist/{package-BRTjkzt5.mjs → package-CqqBgE8Y.mjs} +27 -2
- package/dist/{ratchet-BAcLRYuM.mjs → ratchet-Q-JXuZIX.mjs} +1 -1
- package/dist/{templates-CypDm-j9.mjs → templates-BKZv-BRw.mjs} +1 -1
- package/dist/{typescript-CM0LrVP7.mjs → typescript-DAgQIAAR.mjs} +1 -1
- package/dist/verify/index.d.mts +37 -2
- package/package.json +7 -5
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { l as skillFolder } from "./shared-igPpEDpS.mjs";
|
|
2
|
+
import { f as parseJson, i as isObject } from "./json-CG2L7YFl.mjs";
|
|
3
|
+
import { c as leaseTmpDir, i as PARENT_TMPDIR, n as LEASE_DIR, r as LEASE_MARKER, t as DEV_STACK_VARIABLES } from "./env-DT0UJNeL.mjs";
|
|
4
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { basename, dirname, join, matchesGlob, relative, resolve } from "node:path";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { randomBytes } from "node:crypto";
|
|
9
|
+
import { homedir, tmpdir } from "node:os";
|
|
10
|
+
//#region src/verify/workspace.ts
|
|
11
|
+
/**
|
|
12
|
+
* Caches shared by every run: the warm pnpm store, the npm cache and the
|
|
13
|
+
* published packages. Nothing a journey asserts on lives here.
|
|
14
|
+
*/
|
|
15
|
+
const CACHE_DIR = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "antelopejs-verify");
|
|
16
|
+
/**
|
|
17
|
+
* The temp folder the operator would have outside a lease: the `TMPDIR` of
|
|
18
|
+
* `operatorEnv()`, else the platform default, so a lease's own tmp never
|
|
19
|
+
* holds a run.
|
|
20
|
+
*/
|
|
21
|
+
function operatorTmpdir() {
|
|
22
|
+
const { TMPDIR: tmp, TMP, TEMP } = operatorEnv();
|
|
23
|
+
if (tmp) return tmp;
|
|
24
|
+
if (process.platform === "win32") return tmpdir();
|
|
25
|
+
return TMP || TEMP || "/tmp";
|
|
26
|
+
}
|
|
27
|
+
/** The folder that holds every run, one subfolder per repository. */
|
|
28
|
+
const RUNS_DIR = join(operatorTmpdir(), "antelopejs-verify");
|
|
29
|
+
function makeWritable(folder) {
|
|
30
|
+
chmodSync(folder, lstatSync(folder).mode | 448);
|
|
31
|
+
for (const entry of readdirSync(folder, { withFileTypes: true })) if (entry.isDirectory()) makeWritable(join(folder, entry.name));
|
|
32
|
+
}
|
|
33
|
+
/** Deletes a folder this run wrote, including folders an install left read-only. */
|
|
34
|
+
function removeTree(folder) {
|
|
35
|
+
try {
|
|
36
|
+
rmSync(folder, {
|
|
37
|
+
recursive: true,
|
|
38
|
+
force: true
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
makeWritable(folder);
|
|
42
|
+
rmSync(folder, {
|
|
43
|
+
recursive: true,
|
|
44
|
+
force: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Runs git in `cwd` and returns its trimmed output. */
|
|
49
|
+
function git(cwd, args) {
|
|
50
|
+
return execFileSync("git", args, {
|
|
51
|
+
cwd,
|
|
52
|
+
encoding: "utf8",
|
|
53
|
+
stdio: [
|
|
54
|
+
"ignore",
|
|
55
|
+
"pipe",
|
|
56
|
+
"pipe"
|
|
57
|
+
]
|
|
58
|
+
}).trim();
|
|
59
|
+
}
|
|
60
|
+
function readManifest(root) {
|
|
61
|
+
const file = join(root, "package.json");
|
|
62
|
+
const value = existsSync(file) ? parseJson(readFileSync(file, "utf8")) : {};
|
|
63
|
+
return isObject(value) ? value : {};
|
|
64
|
+
}
|
|
65
|
+
/** Opens the repository at `root` for `kind`, loading the repo-owned verify.config.ts. */
|
|
66
|
+
async function openWorkspace(root, kind) {
|
|
67
|
+
const skill = join(root, skillFolder(kind));
|
|
68
|
+
const file = join(skill, "verify.config.ts");
|
|
69
|
+
if (!existsSync(file)) throw new Error(`${file} is missing. Write the repo-owned layer (verify.config.ts and features/) described in ${skillFolder(kind)}/SKILL.md.`);
|
|
70
|
+
const config = (await import(pathToFileURL(file).href)).default;
|
|
71
|
+
if (config?.doors === void 0) throw new Error(`${file} must export default a VerifyConfig with a doors block.`);
|
|
72
|
+
const manifest = readManifest(root);
|
|
73
|
+
return {
|
|
74
|
+
root,
|
|
75
|
+
kind,
|
|
76
|
+
skill,
|
|
77
|
+
config,
|
|
78
|
+
manifest,
|
|
79
|
+
name: String(manifest.name ?? basename(root)).replace(/^@[^/]+\//, "").replace(/[^a-z0-9-]+/gi, "-")
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function stateFile(dir) {
|
|
83
|
+
return join(dir, "run.json");
|
|
84
|
+
}
|
|
85
|
+
/** Reads a run created by `new`, failing with the reason when it is missing, and marks it active by touching run.json. */
|
|
86
|
+
function loadRun(dir) {
|
|
87
|
+
const file = stateFile(resolve(dir));
|
|
88
|
+
if (!existsSync(file)) throw new Error(`No run at ${dir}: run.json is missing. Create one with \`new\`.`);
|
|
89
|
+
const now = /* @__PURE__ */ new Date();
|
|
90
|
+
utimesSync(file, now, now);
|
|
91
|
+
const stored = JSON.parse(readFileSync(file, "utf8"));
|
|
92
|
+
return {
|
|
93
|
+
...stored,
|
|
94
|
+
timings: stored.timings ?? [],
|
|
95
|
+
all: stored.all === true
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Persists the run state. */
|
|
99
|
+
function saveRun(state) {
|
|
100
|
+
writeFileSync(stateFile(state.dir), `${JSON.stringify(state, null, 2)}\n`);
|
|
101
|
+
}
|
|
102
|
+
/** Allocates the folders of a new run under the system temp folder. */
|
|
103
|
+
function allocateRun(workspace, baseRef, title, all) {
|
|
104
|
+
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").slice(0, 15)}-${randomBytes(3).toString("hex")}`;
|
|
105
|
+
const dir = join(RUNS_DIR, workspace.name, id);
|
|
106
|
+
const evidence = join(dir, "evidence");
|
|
107
|
+
mkdirSync(evidence, { recursive: true });
|
|
108
|
+
return {
|
|
109
|
+
id,
|
|
110
|
+
kind: workspace.kind,
|
|
111
|
+
repo: workspace.root,
|
|
112
|
+
dir,
|
|
113
|
+
evidence,
|
|
114
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
115
|
+
headSha: git(workspace.root, ["rev-parse", "HEAD"]),
|
|
116
|
+
baseRef,
|
|
117
|
+
title,
|
|
118
|
+
all,
|
|
119
|
+
processes: [],
|
|
120
|
+
containers: [],
|
|
121
|
+
pack: "",
|
|
122
|
+
manifestUrl: "",
|
|
123
|
+
templateName: "",
|
|
124
|
+
missingKeys: (workspace.config.saas?.env ?? []).filter((key) => !process.env[key]),
|
|
125
|
+
timings: []
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const INHERITED_PREFIXES = [
|
|
129
|
+
"ANTELOPEJS_",
|
|
130
|
+
"npm_",
|
|
131
|
+
"PNPM_",
|
|
132
|
+
"XDG_"
|
|
133
|
+
];
|
|
134
|
+
/** The real path of `path`, resolved through its nearest existing ancestor when the path itself is gone. */
|
|
135
|
+
function canonical(path) {
|
|
136
|
+
const full = resolve(path);
|
|
137
|
+
try {
|
|
138
|
+
return realpathSync(full);
|
|
139
|
+
} catch {
|
|
140
|
+
const parent = dirname(full);
|
|
141
|
+
return parent === full ? full : join(canonical(parent), basename(full));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function isLeaseTmp(tmp, leaseDir) {
|
|
145
|
+
return !!tmp && canonical(tmp) === canonical(leaseTmpDir(leaseDir));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The environment the operator would have outside `antelopejs-lease run`. A
|
|
149
|
+
* lease is active only when `ANTELOPEJS_LEASE` and `ANTELOPEJS_LEASE_DIR` are
|
|
150
|
+
* both non-empty. Under one, the lease's dev-stack variables and its own
|
|
151
|
+
* `ANTELOPEJS_LEASE*` variables are dropped. `TMPDIR` is replaced only when
|
|
152
|
+
* it is the lease's own tmp: by the value the lease recorded, or removed when
|
|
153
|
+
* the operator had none, and kept as it is when the lease recorded nothing
|
|
154
|
+
* (an older pack). A `TMPDIR` set for the command is honoured. Outside a
|
|
155
|
+
* lease it is `process.env` unchanged, so the operator's own `PORT` or
|
|
156
|
+
* `MONGO_URL` still counts.
|
|
157
|
+
*/
|
|
158
|
+
function operatorEnv() {
|
|
159
|
+
const leaseDir = process.env[LEASE_DIR];
|
|
160
|
+
if (!process.env["ANTELOPEJS_LEASE"] || !leaseDir) return process.env;
|
|
161
|
+
const dropped = /* @__PURE__ */ new Set([
|
|
162
|
+
...DEV_STACK_VARIABLES.filter((name) => name !== "TMPDIR"),
|
|
163
|
+
LEASE_MARKER,
|
|
164
|
+
LEASE_DIR,
|
|
165
|
+
PARENT_TMPDIR
|
|
166
|
+
]);
|
|
167
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !dropped.has(key)));
|
|
168
|
+
const recorded = process.env[PARENT_TMPDIR];
|
|
169
|
+
if (recorded !== void 0 && isLeaseTmp(env.TMPDIR, leaseDir)) {
|
|
170
|
+
if (recorded) env.TMPDIR = recorded;
|
|
171
|
+
else delete env.TMPDIR;
|
|
172
|
+
}
|
|
173
|
+
return env;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The environment every driven command gets: the journey's HOME, CI=1, no
|
|
177
|
+
* update check, no colors and the shared caches. Variables that could leak
|
|
178
|
+
* the operator's own settings or the lease's dev stack into the run are
|
|
179
|
+
* dropped; npm and pnpm settings in any case, since both also read their upper and lowercase spellings. `NPM_TOKEN` and other uppercase variables a `.npmrc` interpolates are kept. The config `env` can set any of them back on purpose.
|
|
180
|
+
*/
|
|
181
|
+
function isolatedEnv(workspace, home, extra = {}) {
|
|
182
|
+
const kept = Object.entries(operatorEnv()).filter(([key]) => !INHERITED_PREFIXES.some((prefix) => key.startsWith(prefix)) && !/^p?npm_config_/i.test(key));
|
|
183
|
+
return {
|
|
184
|
+
...Object.fromEntries(kept),
|
|
185
|
+
HOME: home,
|
|
186
|
+
USERPROFILE: home,
|
|
187
|
+
CI: "1",
|
|
188
|
+
AJS_NO_UPDATE_CHECK: "1",
|
|
189
|
+
NO_COLOR: "1",
|
|
190
|
+
COREPACK_HOME: process.env.COREPACK_HOME ?? join(homedir(), ".cache", "node", "corepack"),
|
|
191
|
+
COREPACK_ENABLE_DOWNLOAD_PROMPT: "0",
|
|
192
|
+
XDG_DATA_HOME: join(CACHE_DIR, "xdg-data"),
|
|
193
|
+
XDG_CACHE_HOME: join(home, ".cache"),
|
|
194
|
+
XDG_CONFIG_HOME: join(home, ".config"),
|
|
195
|
+
npm_config_cache: join(CACHE_DIR, "npm"),
|
|
196
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
197
|
+
...workspace.config.env,
|
|
198
|
+
...extra
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/verify/map.ts
|
|
203
|
+
/** The feature that always runs, whatever the diff touches. */
|
|
204
|
+
const SMOKE_FEATURE = "smoke";
|
|
205
|
+
const DEFAULT_USER_FACING = {
|
|
206
|
+
interface: ["src/**"],
|
|
207
|
+
module: ["src/**"],
|
|
208
|
+
template: ["**"]
|
|
209
|
+
};
|
|
210
|
+
const VERIFICATION_LAYER = [
|
|
211
|
+
".agents/**",
|
|
212
|
+
".claude/**",
|
|
213
|
+
".github/**"
|
|
214
|
+
];
|
|
215
|
+
/** Tests are user-facing in a template, since `ajs` copies its whole tree except `.agents/` and `.claude/skills/`. */
|
|
216
|
+
const NOT_USER_FACING = {
|
|
217
|
+
interface: [
|
|
218
|
+
"**/*.test.ts",
|
|
219
|
+
"**/test/**",
|
|
220
|
+
"**/tests/**",
|
|
221
|
+
...VERIFICATION_LAYER
|
|
222
|
+
],
|
|
223
|
+
module: [
|
|
224
|
+
"**/*.test.ts",
|
|
225
|
+
"**/test/**",
|
|
226
|
+
"**/tests/**",
|
|
227
|
+
...VERIFICATION_LAYER
|
|
228
|
+
],
|
|
229
|
+
template: VERIFICATION_LAYER
|
|
230
|
+
};
|
|
231
|
+
const SHARED_BY_ALL = [
|
|
232
|
+
"package.json",
|
|
233
|
+
"pnpm-lock.yaml",
|
|
234
|
+
"pnpm-workspace.yaml",
|
|
235
|
+
"tsconfig.json",
|
|
236
|
+
"tsconfig.*.json",
|
|
237
|
+
"antelope-lock/**"
|
|
238
|
+
];
|
|
239
|
+
/** The files whose change can break any feature, so a diff touching one runs them all. */
|
|
240
|
+
const DEFAULT_SHARED = {
|
|
241
|
+
interface: SHARED_BY_ALL,
|
|
242
|
+
module: [...SHARED_BY_ALL, "src/interfaces/**"],
|
|
243
|
+
template: [
|
|
244
|
+
...SHARED_BY_ALL,
|
|
245
|
+
"antelope.config.*",
|
|
246
|
+
"antelope.json"
|
|
247
|
+
]
|
|
248
|
+
};
|
|
249
|
+
function frontmatterLists(text) {
|
|
250
|
+
const lists = /* @__PURE__ */ new Map();
|
|
251
|
+
const match = /^---\n([\s\S]*?)\n---\n/.exec(text);
|
|
252
|
+
let current;
|
|
253
|
+
for (const line of (match?.[1] ?? "").split("\n")) {
|
|
254
|
+
const key = /^(\w+):\s*$/.exec(line);
|
|
255
|
+
const item = /^\s+-\s+(.+)$/.exec(line);
|
|
256
|
+
if (key) {
|
|
257
|
+
current = [];
|
|
258
|
+
lists.set(key[1], current);
|
|
259
|
+
} else if (item && current) current.push(item[1].replace(/^"|"$/g, ""));
|
|
260
|
+
}
|
|
261
|
+
return lists;
|
|
262
|
+
}
|
|
263
|
+
/** Reads every feature file under features/, README.md excluded. */
|
|
264
|
+
function readFeatures(workspace) {
|
|
265
|
+
const folder = join(workspace.skill, "features");
|
|
266
|
+
if (!existsSync(folder)) return [];
|
|
267
|
+
return readdirSync(folder).filter((file) => file.endsWith(".md") && file !== "README.md").sort().map((file) => {
|
|
268
|
+
const body = readFileSync(join(folder, file), "utf8");
|
|
269
|
+
const lists = frontmatterLists(body);
|
|
270
|
+
return {
|
|
271
|
+
name: file.replace(/\.md$/, ""),
|
|
272
|
+
file: relative(workspace.root, join(folder, file)),
|
|
273
|
+
covers: lists.get("covers") ?? [],
|
|
274
|
+
docs: lists.get("docs") ?? [],
|
|
275
|
+
journeys: lists.get("journeys") ?? [],
|
|
276
|
+
body
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function matches(file, globs) {
|
|
281
|
+
return globs.some((glob) => matchesGlob(file, glob));
|
|
282
|
+
}
|
|
283
|
+
/** Whether a user can observe a change to `file`. */
|
|
284
|
+
function userFacing(workspace, file) {
|
|
285
|
+
return matches(file, workspace.config.userFacing ?? DEFAULT_USER_FACING[workspace.kind]) && !matches(file, NOT_USER_FACING[workspace.kind]);
|
|
286
|
+
}
|
|
287
|
+
/** The changed files that run every feature; the verification layer never counts. */
|
|
288
|
+
function sharedFiles(workspace, changed) {
|
|
289
|
+
const globs = workspace.config.shared ?? DEFAULT_SHARED[workspace.kind];
|
|
290
|
+
return changed.filter((file) => matches(file, globs) && !matches(file, VERIFICATION_LAYER));
|
|
291
|
+
}
|
|
292
|
+
function trackedFiles(workspace) {
|
|
293
|
+
return git(workspace.root, ["ls-files"]).split("\n").filter(Boolean);
|
|
294
|
+
}
|
|
295
|
+
/** The features whose globs cover `file`. */
|
|
296
|
+
function featuresOf(file, features) {
|
|
297
|
+
return features.filter((feature) => matches(file, feature.covers)).map((feature) => feature.name);
|
|
298
|
+
}
|
|
299
|
+
function featureProblems(workspace, feature, known, tracked) {
|
|
300
|
+
const problems = [];
|
|
301
|
+
if (feature.journeys.length === 0) problems.push(`${feature.file}: lists no journeys`);
|
|
302
|
+
for (const journey of feature.journeys) {
|
|
303
|
+
if (!known.has(journey)) problems.push(`${feature.file}: journey ${journey} is neither built in nor in verify.config.ts journeys`);
|
|
304
|
+
if (!feature.body.includes(`\`${journey}\``)) problems.push(`${feature.file}: journey \`${journey}\` is not described`);
|
|
305
|
+
}
|
|
306
|
+
if (feature.name !== "smoke" && feature.covers.length === 0) problems.push(`${feature.file}: lists no covers globs`);
|
|
307
|
+
for (const glob of feature.covers) if (!tracked.some((file) => matchesGlob(file, glob))) problems.push(`${feature.file}: glob ${glob} matches no tracked file`);
|
|
308
|
+
if (feature.docs.length === 0) problems.push(`${feature.file}: lists no docs pages`);
|
|
309
|
+
for (const doc of feature.docs) if (!existsSync(join(workspace.root, doc))) problems.push(`${feature.file}: docs path ${doc} does not exist`);
|
|
310
|
+
return problems;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Checks the repo-owned layer against the repository: a smoke feature
|
|
314
|
+
* exists, every user-facing file is covered, every feature names known
|
|
315
|
+
* journeys and docs pages that exist, and every config journey is used. One
|
|
316
|
+
* line per problem.
|
|
317
|
+
*/
|
|
318
|
+
function checkMap(workspace, builtins) {
|
|
319
|
+
const features = readFeatures(workspace);
|
|
320
|
+
const tracked = trackedFiles(workspace);
|
|
321
|
+
const configJourneys = Object.keys(workspace.config.journeys ?? {});
|
|
322
|
+
const known = /* @__PURE__ */ new Set([...builtins, ...configJourneys]);
|
|
323
|
+
const problems = [];
|
|
324
|
+
if (!features.some((feature) => feature.name === "smoke")) problems.push(`${skillFolder(workspace.kind)}/features/${SMOKE_FEATURE}.md is missing: every verdict runs the smoke feature`);
|
|
325
|
+
for (const file of tracked.filter((path) => userFacing(workspace, path))) if (featuresOf(file, features).length === 0) problems.push(`unmapped: ${file} matches no feature glob`);
|
|
326
|
+
for (const feature of features) problems.push(...featureProblems(workspace, feature, known, tracked));
|
|
327
|
+
for (const journey of configJourneys) if (!features.some((feature) => feature.journeys.includes(journey))) problems.push(`verify.config.ts journey ${journey} is in no feature file`);
|
|
328
|
+
return problems;
|
|
329
|
+
}
|
|
330
|
+
/** The files a change touches: committed since the merge base, staged, unstaged and untracked. */
|
|
331
|
+
function changedFiles(workspace, baseSha) {
|
|
332
|
+
const committed = git(workspace.root, [
|
|
333
|
+
"diff",
|
|
334
|
+
"--name-only",
|
|
335
|
+
"--no-renames",
|
|
336
|
+
baseSha
|
|
337
|
+
]).split("\n");
|
|
338
|
+
const untracked = git(workspace.root, [
|
|
339
|
+
"ls-files",
|
|
340
|
+
"--others",
|
|
341
|
+
"--exclude-standard"
|
|
342
|
+
]).split("\n");
|
|
343
|
+
return [...new Set([...committed, ...untracked].filter(Boolean))].sort();
|
|
344
|
+
}
|
|
345
|
+
/** The reason a plan runs every feature, `all` taking precedence over a shared file. */
|
|
346
|
+
function fullReason(workspace, changed, all) {
|
|
347
|
+
if (all) return { reason: "all" };
|
|
348
|
+
const files = sharedFiles(workspace, changed);
|
|
349
|
+
return files.length > 0 ? {
|
|
350
|
+
reason: "shared",
|
|
351
|
+
files
|
|
352
|
+
} : null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Maps the change from the merge base of `baseRef` onto features: every
|
|
356
|
+
* touched feature plus the smoke feature runs, every feature runs when a
|
|
357
|
+
* shared file changed or `all` is set, and a user-facing file outside every
|
|
358
|
+
* glob is an unmapped surface.
|
|
359
|
+
*/
|
|
360
|
+
function planFor(workspace, baseRef, all = false) {
|
|
361
|
+
const features = readFeatures(workspace);
|
|
362
|
+
const baseSha = git(workspace.root, [
|
|
363
|
+
"merge-base",
|
|
364
|
+
baseRef,
|
|
365
|
+
"HEAD"
|
|
366
|
+
]);
|
|
367
|
+
const changed = changedFiles(workspace, baseSha);
|
|
368
|
+
const touched = features.map((feature) => ({
|
|
369
|
+
feature: feature.name,
|
|
370
|
+
files: changed.filter((file) => matches(file, feature.covers))
|
|
371
|
+
})).filter((entry) => entry.files.length > 0);
|
|
372
|
+
const unmapped = changed.filter((file) => userFacing(workspace, file) && featuresOf(file, features).length === 0);
|
|
373
|
+
const touchedNames = new Set(touched.map((entry) => entry.feature));
|
|
374
|
+
const full = fullReason(workspace, changed, all);
|
|
375
|
+
const planned = full ? features.map((feature) => feature.name) : [...touchedNames];
|
|
376
|
+
const docs = [...new Set(features.filter((feature) => planned.includes(feature.name)).flatMap((feature) => feature.docs))];
|
|
377
|
+
const run = [SMOKE_FEATURE, ...planned.filter((name) => name !== SMOKE_FEATURE)];
|
|
378
|
+
const dirty = git(workspace.root, [
|
|
379
|
+
"status",
|
|
380
|
+
"--porcelain",
|
|
381
|
+
"--untracked-files=no"
|
|
382
|
+
]).split("\n").filter(Boolean);
|
|
383
|
+
return {
|
|
384
|
+
baseRef,
|
|
385
|
+
baseSha,
|
|
386
|
+
headSha: git(workspace.root, ["rev-parse", "HEAD"]),
|
|
387
|
+
changed,
|
|
388
|
+
touched,
|
|
389
|
+
unmapped,
|
|
390
|
+
docs,
|
|
391
|
+
full,
|
|
392
|
+
run,
|
|
393
|
+
dirty
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
export { readFeatures as a, allocateRun as c, loadRun as d, openWorkspace as f, saveRun as g, removeTree as h, planFor as i, git as l, operatorTmpdir as m, SMOKE_FEATURE as n, CACHE_DIR as o, operatorEnv as p, checkMap as r, RUNS_DIR as s, DEFAULT_SHARED as t, isolatedEnv as u };
|
package/dist/oxc/fmt.d.mts
CHANGED
|
@@ -47,6 +47,8 @@ interface AntelopeFmtOptions extends Partial<OxfmtOptions> {
|
|
|
47
47
|
declare function antelopeFmtPreset(options?: AntelopeFmtOptions): {
|
|
48
48
|
ignorePatterns: string[];
|
|
49
49
|
arrowParens?: import("oxfmt").ArrowParensConfig | undefined;
|
|
50
|
+
associations?: import("oxfmt").OxfmtAssociationConfig[] | undefined;
|
|
51
|
+
astro?: import("oxfmt").AstroUserConfig | undefined;
|
|
50
52
|
bracketSameLine?: boolean | undefined;
|
|
51
53
|
bracketSpacing?: boolean | undefined;
|
|
52
54
|
embeddedLanguageFormatting?: import("oxfmt").EmbeddedLanguageFormattingConfig | undefined;
|
|
@@ -75,6 +77,8 @@ declare function antelopeFmtPreset(options?: AntelopeFmtOptions): {
|
|
|
75
77
|
} | {
|
|
76
78
|
ignorePatterns: string[];
|
|
77
79
|
arrowParens?: import("oxfmt").ArrowParensConfig | undefined;
|
|
80
|
+
associations?: import("oxfmt").OxfmtAssociationConfig[] | undefined;
|
|
81
|
+
astro?: import("oxfmt").AstroUserConfig | undefined;
|
|
78
82
|
bracketSameLine?: boolean | undefined;
|
|
79
83
|
bracketSpacing?: boolean | undefined;
|
|
80
84
|
embeddedLanguageFormatting?: import("oxfmt").EmbeddedLanguageFormattingConfig | undefined;
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
|
|
3
|
-
import { t as PRESET_CONFIGS } from "../templates-
|
|
3
|
+
import { t as PRESET_CONFIGS } from "../templates-BKZv-BRw.mjs";
|
|
4
4
|
import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
|
|
5
5
|
import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-igPpEDpS.mjs";
|
|
6
6
|
import { defineConfig } from "oxlint";
|
|
@@ -80,7 +80,14 @@ function repositoryTools(manifest) {
|
|
|
80
80
|
}
|
|
81
81
|
}[manifest.name === "@antelopejs/tooling-configs" ? "source" : "installed"];
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
/** Installs hooks only in a folder whose own `.git` is a working repository, the top of a checkout, worktree or submodule. `GIT_DIR` and `GIT_WORK_TREE` are pinned to that folder, since a git hook or CI wrapper can point them at an outer repository, and a `.git` that does not resolve skips silently. */
|
|
84
|
+
const PREPARE_INSTALL = "if [ -e .git ] && command -v git >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1 && GIT_DIR=.git GIT_WORK_TREE=. git rev-parse --git-dir >/dev/null 2>&1; then GIT_DIR=.git GIT_WORK_TREE=. lefthook install; fi";
|
|
85
|
+
/** Every earlier install in one pass, so text a replacement inserts is never scanned again. */
|
|
86
|
+
const PREVIOUS_INSTALL = new RegExp([
|
|
87
|
+
"if [ -e .git ] && command -v git >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1; then lefthook install; fi",
|
|
88
|
+
"if git rev-parse --is-inside-work-tree >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1; then lefthook install; fi",
|
|
89
|
+
"if [ \"$(git rev-parse --is-inside-work-tree --show-prefix 2>/dev/null)\" = true ] && command -v lefthook >/dev/null 2>&1; then lefthook install; fi"
|
|
90
|
+
].map((script) => script.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "g");
|
|
84
91
|
const DEFAULT_SCRIPTS = {
|
|
85
92
|
typecheck: "tsc --noEmit",
|
|
86
93
|
lint: "oxlint",
|
|
@@ -88,8 +95,26 @@ const DEFAULT_SCRIPTS = {
|
|
|
88
95
|
"format:check": "oxfmt --check .",
|
|
89
96
|
knip: "knip"
|
|
90
97
|
};
|
|
98
|
+
/** Stands in for the current install while the script is split on its separators, since the install holds `&&` itself. */
|
|
99
|
+
const INSTALL_TOKEN = "\0prepare-install\0";
|
|
100
|
+
/** Rewrites every earlier synced install to the current one in one pass and keeps a single install, whatever separator joined the copies. */
|
|
101
|
+
function migratePrepare(current) {
|
|
102
|
+
const tokenized = current.split(PREPARE_INSTALL).map((part) => part.replace(PREVIOUS_INSTALL, () => INSTALL_TOKEN)).join(INSTALL_TOKEN);
|
|
103
|
+
let seen = false;
|
|
104
|
+
return tokenized.split(/(\s*(?:&&|\|\||;)\s*)/).reduce((kept, piece, index, pieces) => {
|
|
105
|
+
if (index % 2 === 1) return kept;
|
|
106
|
+
if (piece === INSTALL_TOKEN && seen) return kept;
|
|
107
|
+
seen ||= piece === INSTALL_TOKEN;
|
|
108
|
+
return kept.length === 0 ? [piece] : [
|
|
109
|
+
...kept,
|
|
110
|
+
pieces[index - 1],
|
|
111
|
+
piece
|
|
112
|
+
];
|
|
113
|
+
}, []).join("").replaceAll(INSTALL_TOKEN, () => PREPARE_INSTALL);
|
|
114
|
+
}
|
|
91
115
|
function prepareScript(current = "") {
|
|
92
|
-
|
|
116
|
+
const migrated = migratePrepare(current);
|
|
117
|
+
if (migrated.includes("if [ -e .git ] && command -v git >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1 && GIT_DIR=.git GIT_WORK_TREE=. git rev-parse --git-dir >/dev/null 2>&1; then GIT_DIR=.git GIT_WORK_TREE=. lefthook install; fi")) return migrated;
|
|
93
118
|
const legacy = /(^|&&\s*|;\s*)(?:(?:pnpm exec|npm exec --|yarn exec|bun x --no-install)\s+)?lefthook\s+install(?=\s*(?:$|&&|;))/;
|
|
94
119
|
if (legacy.test(current)) return current.replace(legacy, `$1${PREPARE_INSTALL}`);
|
|
95
120
|
return current ? `${current} && ${PREPARE_INSTALL}` : PREPARE_INSTALL;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPackRelease, s as isRetired, t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
|
|
3
|
-
import { s as toolingVersions } from "./package-
|
|
3
|
+
import { s as toolingVersions } from "./package-CqqBgE8Y.mjs";
|
|
4
4
|
import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-DJ0TeaTU.mjs";
|
|
5
5
|
import { t as lintDiagnostics } from "./oxlint-DIV-lLSS.mjs";
|
|
6
6
|
import "./suppression-budget-C0SkPO5R.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as parseManifest } from "./package-
|
|
1
|
+
import { i as parseManifest } from "./package-CqqBgE8Y.mjs";
|
|
2
2
|
import { u as trackedManifests } from "./files-DJ0TeaTU.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
package/dist/verify/index.d.mts
CHANGED
|
@@ -174,7 +174,10 @@ interface JourneyContext {
|
|
|
174
174
|
service(name: string): ServiceEndpoint;
|
|
175
175
|
/** Runs a command inside a service's container: the read-back through the native client. */
|
|
176
176
|
native(name: string, service: string, args: string[]): Promise<CommandResult>;
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Writes the fixture project of the interface or module kind and returns its folder. Each call writes a fresh project, so a journey can hold several.
|
|
179
|
+
* The project's `.antelope/cache` starts as a copy of a cache of registry modules an earlier passing journey of the run left exactly as a fresh `ajs` install leaves it, none installed from a lock record, so `ajs` installs a registry module once per run.
|
|
180
|
+
*/
|
|
178
181
|
fixture(options?: {
|
|
179
182
|
moduleConfig?: JsonObject;
|
|
180
183
|
}): string;
|
|
@@ -183,8 +186,38 @@ interface JourneyContext {
|
|
|
183
186
|
call(name: string, app: App, request: CallRequest): Promise<CallResult>;
|
|
184
187
|
/** Stops an app with SIGINT by recorded PID. */
|
|
185
188
|
stop(name: string, app: App): Promise<StopResult>;
|
|
186
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Creates a project from the template under verification with `ajs project init`.
|
|
191
|
+
* Once init succeeds, the project's `.antelope/cache` starts as a copy of a cache of registry modules an earlier passing journey of the run left exactly as a fresh `ajs` install leaves it, none installed from a lock record.
|
|
192
|
+
*/
|
|
187
193
|
scaffold(name: string, project: string, flags?: string[]): Promise<CommandResult>;
|
|
194
|
+
/**
|
|
195
|
+
* Builds a folder once per run and gives every journey its own copy, for
|
|
196
|
+
* the preparation many journeys repeat, such as a scaffolded and installed
|
|
197
|
+
* project. Returns `<work>/<key>`. The first journey of the run that asks
|
|
198
|
+
* for `key` runs `build` on that empty folder with its usual recorded
|
|
199
|
+
* steps, after a step `prepared <key>` that marks them as the build and says
|
|
200
|
+
* whether the run kept it. The run keeps a copy of the folder and of the
|
|
201
|
+
* build's step evidence only when `build` returns, recorded at least one
|
|
202
|
+
* check, passed every check, and left nothing in the folder but files,
|
|
203
|
+
* directories and symlinks. A later journey of the run, in this `journey`
|
|
204
|
+
* command or a later one, gets a fresh copy of the kept folder and one
|
|
205
|
+
* step, `prepared <key>`, that names the journey that built it and holds
|
|
206
|
+
* that build's evidence under `build/`. A build that is not kept is built
|
|
207
|
+
* again by the next journey. Rerunning the journey that built builds again.
|
|
208
|
+
* In a copy, an absolute symlink into the built folder points to the same
|
|
209
|
+
* path in the copy; every other symlink keeps its target. `build` writes
|
|
210
|
+
* only inside the folder it is given: what it writes elsewhere, such as a
|
|
211
|
+
* sibling in the journey's work folder or the repository, stays with the
|
|
212
|
+
* journey that built. Two journeys that ask for the same key at once, in
|
|
213
|
+
* concurrent `journey` commands, both build, and the first to finish is
|
|
214
|
+
* kept. The commands `build` runs get a HOME of their own, deleted when
|
|
215
|
+
* `build` ends, so what they write there (`ajs config set git`, caches) is
|
|
216
|
+
* never kept and every journey continues with its own HOME. Every journey
|
|
217
|
+
* passes the same `build` for a key. `key` is lowercase letters and digits
|
|
218
|
+
* joined by dashes. `clean` deletes what the run kept.
|
|
219
|
+
*/
|
|
220
|
+
prepared(key: string, build: (folder: string) => Promise<void>): Promise<string>;
|
|
188
221
|
}
|
|
189
222
|
/** A repo-owned journey of `verify.config.ts`, named by id in a feature file. */
|
|
190
223
|
interface Journey {
|
|
@@ -228,6 +261,8 @@ interface VerifyConfig<Api = never> {
|
|
|
228
261
|
formal?: FormalCheck[];
|
|
229
262
|
/** Files whose change a user can observe; replaces the kind's default. */
|
|
230
263
|
userFacing?: string[];
|
|
264
|
+
/** Files whose change runs every feature, not only the touched ones; replaces the kind's default. */
|
|
265
|
+
shared?: string[];
|
|
231
266
|
services?: {
|
|
232
267
|
[name: string]: ServiceDefinition;
|
|
233
268
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -67,13 +67,15 @@
|
|
|
67
67
|
"checks": "node src/bin/checks.ts",
|
|
68
68
|
"format:check": "oxfmt --check .",
|
|
69
69
|
"size": "node src/bin/check-size.ts",
|
|
70
|
-
"prepare": "if
|
|
70
|
+
"prepare": "if [ -e .git ] && command -v git >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1 && GIT_DIR=.git GIT_WORK_TREE=. git rev-parse --git-dir >/dev/null 2>&1; then GIT_DIR=.git GIT_WORK_TREE=. lefthook install; fi",
|
|
71
71
|
"sync": "node src/bin/sync.ts",
|
|
72
72
|
"sync:check": "node src/bin/sync.ts --check",
|
|
73
73
|
"knip": "knip",
|
|
74
74
|
"suppressions": "node src/bin/suppressions.ts",
|
|
75
75
|
"suppressions:update": "node src/bin/suppressions.ts --update",
|
|
76
|
-
"docs:generate": "node src/docs/generate.ts"
|
|
76
|
+
"docs:generate": "node src/docs/generate.ts",
|
|
77
|
+
"ci:shard": "node src/ci/shard.ts",
|
|
78
|
+
"ci:weights": "node src/ci/refresh-weights.ts"
|
|
77
79
|
},
|
|
78
80
|
"dependencies": {
|
|
79
81
|
"@oxlint/plugins": "1.81.0",
|
|
@@ -88,7 +90,7 @@
|
|
|
88
90
|
"knip": "^6.34.0",
|
|
89
91
|
"lefthook": "^2.2.2",
|
|
90
92
|
"mongodb-memory-server": "^11.3.0",
|
|
91
|
-
"oxfmt": "^0.
|
|
93
|
+
"oxfmt": "^0.77.0",
|
|
92
94
|
"oxlint": "1.81.0",
|
|
93
95
|
"oxlint-tsgolint": "^7.0.2001",
|
|
94
96
|
"pixelmatch": "^8.0.0",
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
"eslint-plugin-perfectionist": ">=5.0.0",
|
|
105
107
|
"knip": ">=6.0.0",
|
|
106
108
|
"mongodb-memory-server": ">=10.0.0",
|
|
107
|
-
"oxfmt": "^0.66.0",
|
|
109
|
+
"oxfmt": "^0.66.0 || ^0.77.0",
|
|
108
110
|
"oxlint": "1.81.0",
|
|
109
111
|
"pixelmatch": ">=7.0.0",
|
|
110
112
|
"playwright-core": ">=1.56.0",
|