@antelopejs/tooling-configs 0.5.6 → 0.5.8

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 (34) hide show
  1. package/dist/bin/api-diff.mjs +9 -7
  2. package/dist/bin/body-check.mjs +3 -3
  3. package/dist/bin/capture.mjs +12 -4
  4. package/dist/bin/check-size.mjs +6 -4
  5. package/dist/bin/checks.mjs +2 -2
  6. package/dist/bin/comment-proof.mjs +3 -3
  7. package/dist/bin/garden.mjs +151 -15
  8. package/dist/bin/lease.mjs +142 -20
  9. package/dist/bin/ratchet.mjs +5 -5
  10. package/dist/bin/readme-strip.mjs +1 -1
  11. package/dist/bin/suppressions.mjs +9 -10
  12. package/dist/bin/sync.mjs +96 -29
  13. package/dist/bin/verify.mjs +65 -39
  14. package/dist/{checks-DqTjyKCC.mjs → checks-BC-F8bsv.mjs} +4 -537
  15. package/dist/docs-compat-Ft1r2sf0.mjs +476 -0
  16. package/dist/{files-DJ0TeaTU.mjs → files-C-JJhExM.mjs} +1 -1
  17. package/dist/launch-D5cylwvb.mjs +76 -0
  18. package/dist/{map-DRyYz_Fw.mjs → map-BYkmnvNw.mjs} +42 -10
  19. package/dist/oxc/fmt.mjs +1 -1
  20. package/dist/oxc/guardrails/index.mjs +1 -1
  21. package/dist/oxc/lint.mjs +1 -1
  22. package/dist/{oxlint-BbpTFFmf.mjs → oxlint-CCOJqj3d.mjs} +6 -2
  23. package/dist/{proof-stamp-Kg-tkM6G.mjs → proof-stamp-lyD84zmj.mjs} +4 -4
  24. package/dist/{ratchet-1O8k4Dxu.mjs → ratchet-SQ7vTR0i.mjs} +4 -4
  25. package/dist/run-command-BlFRPORx.mjs +95 -0
  26. package/dist/{shared-igPpEDpS.mjs → shared-BCFFyp3l.mjs} +9 -2
  27. package/dist/{size-DBatLT-F.mjs → size-CCGLY4Ke.mjs} +1 -1
  28. package/dist/slash-BEgSnfYw.mjs +12 -0
  29. package/dist/{suppression-base-DZgUDXiI.mjs → suppression-base-whhvw-IJ.mjs} +3 -3
  30. package/dist/{suppression-budget-DgYdu6JK.mjs → suppression-budget-CtIYSoDO.mjs} +2 -2
  31. package/dist/{suppressions-CQTcKCi1.mjs → suppressions-C79kRvYI.mjs} +1 -1
  32. package/dist/{typescript-DhavwHb7.mjs → typescript--_8og8AM.mjs} +20 -7
  33. package/dist/verify/index.d.mts +2 -0
  34. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
3
3
  import { a as closeServer, c as LOCK_PORT, d as isRole, f as leaseHome, i as claimPort, l as PORT_ROLES, m as parseRecord, n as bindable, o as listenerPids, p as leaseId, r as chooseBlock, s as listensOn, t as accepting, u as isLeaseId } from "../ports-DGP6bPJy.mjs";
4
4
  import { a as isServerRole, l as unmarked, o as leaseEnv, s as leaseMarker } from "../env-DT0UJNeL.mjs";
5
5
  import { accessSync, closeSync, constants, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
6
- import { delimiter, join } from "node:path";
6
+ import { delimiter, join, win32 } from "node:path";
7
7
  import { execFileSync, spawn } from "node:child_process";
8
8
  import { homedir } from "node:os";
9
9
  import { parseArgs } from "node:util";
@@ -94,22 +94,109 @@ function locate(name, env) {
94
94
  }
95
95
  return refused ?? NOT_FOUND;
96
96
  }
97
+ const DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
98
+ const WINDOWS_PROGRAMS = /* @__PURE__ */ new Set([".com", ".exe"]);
99
+ const WINDOWS_SCRIPTS = /* @__PURE__ */ new Set([".bat", ".cmd"]);
100
+ const WINDOWS_PATH_SEPARATOR = ";";
101
+ const WINDOWS_DRIVE_OR_DIRECTORY = /^[A-Za-z]:|[\\/]/u;
102
+ const UNQUOTABLE_FOR_CMD = /["%\r\n]/u;
103
+ const WINDOWS_STARTABLE = "a .exe, .com, .bat or .cmd file";
104
+ const CONSOLE_SIGNALS = [
105
+ "SIGINT",
106
+ "SIGBREAK",
107
+ "SIGHUP"
108
+ ];
109
+ function isStartable(extension) {
110
+ return WINDOWS_PROGRAMS.has(extension) || WINDOWS_SCRIPTS.has(extension);
111
+ }
112
+ /** The value of the variable `name` however `env` spells its case, as Windows reads it. */
113
+ function windowsVariable(env, name) {
114
+ const key = Object.keys(env).find((each) => each.toUpperCase() === name);
115
+ return key === void 0 ? void 0 : env[key];
116
+ }
117
+ function isRegularFile(path) {
118
+ try {
119
+ return statSync(path).isFile();
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
124
+ /** The files `base` may name: itself when it ends in a startable extension, else it plus each `PATHEXT` one. */
125
+ function withExtensions(base, extensions) {
126
+ return isStartable(win32.extname(base).toLowerCase()) ? [base] : extensions.map((extension) => base + extension);
127
+ }
97
128
  /**
98
- * Replaces this process with `command` under exactly `env`. The command keeps this pid and is the
99
- * only process, so a signal from a terminal, a process-group kill or `kill <pid>` reaches it once,
100
- * and its exit status, 128 plus the signal included, is the caller's. Node ignores SIGPIPE and
101
- * SIGXFSZ, and an ignored signal stays ignored across `execve`, so both get a handler first, which
102
- * `execve` resets to the default. Returns only when the command cannot start: after printing why,
103
- * with 127 when it is not found and 126 when it is found but cannot run, as a shell exits.
129
+ * The program `name` names on Windows, found the way `cmd.exe` finds it: as a path when it holds a
130
+ * drive or a directory, else in each directory of `Path` in `env` in turn, trying each `PATHEXT`
131
+ * extension a name without one needs. Only `.exe`, `.com`, `.bat` and `.cmd` start; any other
132
+ * extension in `PATHEXT` is ignored, and a file with one is refused with 126.
104
133
  */
105
- function launch(command, env) {
134
+ function locateWindows(name, env, isFile = isRegularFile) {
135
+ if (name === "") return NOT_FOUND;
136
+ const extensions = (windowsVariable(env, "PATHEXT") ?? DEFAULT_PATHEXT).split(WINDOWS_PATH_SEPARATOR).map((extension) => extension.trim().toLowerCase()).filter(isStartable);
137
+ const bases = WINDOWS_DRIVE_OR_DIRECTORY.test(name) ? [name] : (windowsVariable(env, "PATH") ?? "").split(WINDOWS_PATH_SEPARATOR).map((directory) => directory.trim().replaceAll("\"", "")).filter(Boolean).map((directory) => win32.join(directory, name));
138
+ for (const base of bases) for (const file of withExtensions(base, extensions)) if (isFile(file)) return {
139
+ kind: "start",
140
+ file,
141
+ script: WINDOWS_SCRIPTS.has(win32.extname(file).toLowerCase())
142
+ };
143
+ const plain = bases.find(isFile);
144
+ return plain === void 0 ? NOT_FOUND : refusal(126, `${plain} is not ${WINDOWS_STARTABLE}`);
145
+ }
146
+ function quoteForCmd(word) {
147
+ return `"${word.replace(/(\\+)$/u, "$1$1")}"`;
148
+ }
149
+ /** The `cmd.exe` command line that runs the script `file` with `args`, or why none can carry them unchanged. */
150
+ function cmdLine(file, args) {
151
+ const words = [file, ...args];
152
+ return words.some((word) => UNQUOTABLE_FOR_CMD.test(word)) ? refusal(126, `${file} runs under cmd.exe, which cannot pass a double quote, a percent sign or a line break in a path or argument unchanged`) : {
153
+ kind: "line",
154
+ line: `"${words.map(quoteForCmd).join(" ")}"`
155
+ };
156
+ }
157
+ function waitFor(name, file, args, env, verbatim) {
158
+ for (const signal of CONSOLE_SIGNALS) process.on(signal, () => void 0);
159
+ return new Promise((resolve) => {
160
+ const started = spawn(file, args, {
161
+ env,
162
+ stdio: "inherit",
163
+ windowsVerbatimArguments: verbatim
164
+ });
165
+ started.once("error", (error) => {
166
+ process.stderr.write(`antelopejs-lease: cannot run ${name}: ${error.message}\n`);
167
+ resolve(error.code === "ENOENT" ? 127 : 126);
168
+ });
169
+ started.once("exit", (code) => resolve(code ?? 1));
170
+ });
171
+ }
172
+ /**
173
+ * Runs `command` as a child on Windows, which has no `execve`, and answers its exit code. The
174
+ * child shares this console, so Ctrl+C and Ctrl+Break reach it directly; this process ignores
175
+ * them and outlives it by only the time to pass its code on.
176
+ */
177
+ async function launchWindows(command, env) {
178
+ const [name = "", ...args] = command;
179
+ const verdict = locateWindows(name, env);
180
+ if (verdict.kind === "refuse") return report$1(name, verdict);
181
+ if (!verdict.script) return waitFor(name, verdict.file, args, env, false);
182
+ const built = cmdLine(verdict.file, args);
183
+ if (built.kind === "refuse") return report$1(name, built);
184
+ return waitFor(name, windowsVariable(env, "COMSPEC") ?? "cmd.exe", [
185
+ "/d",
186
+ "/s",
187
+ "/c",
188
+ built.line
189
+ ], env, true);
190
+ }
191
+ function report$1(name, verdict) {
192
+ process.stderr.write(`antelopejs-lease: cannot run ${name}: ${verdict.reason}\n`);
193
+ return verdict.code;
194
+ }
195
+ function replaceWith(command, env) {
106
196
  if (process.execve === void 0) throw new Error("antelopejs-lease: run needs process.execve, from Node 22.15 on Linux or macOS");
107
197
  const [name = "", ...args] = command;
108
198
  const verdict = locate(name, env);
109
- if (verdict.kind === "refuse") {
110
- process.stderr.write(`antelopejs-lease: cannot run ${name}: ${verdict.reason}\n`);
111
- return verdict.code;
112
- }
199
+ if (verdict.kind === "refuse") return report$1(name, verdict);
113
200
  for (const signal of IGNORED_BY_NODE) process.on(signal, () => void 0);
114
201
  return verdict.viaShell ? process.execve(SHELL, [
115
202
  SHELL,
@@ -117,6 +204,20 @@ function launch(command, env) {
117
204
  ...args
118
205
  ], env) : process.execve(verdict.file, [name, ...args], env);
119
206
  }
207
+ /**
208
+ * Runs `command` under exactly `env` and answers its exit code. On Linux and macOS it replaces
209
+ * this process: the command keeps this pid and is the only process, so a signal from a terminal, a
210
+ * process-group kill or `kill <pid>` reaches it once, and its exit status, 128 plus the signal
211
+ * included, is the caller's. Node ignores SIGPIPE and SIGXFSZ, and an ignored signal stays ignored
212
+ * across `execve`, so both get a handler first, which `execve` resets to the default. That path
213
+ * returns only when the command cannot start. On Windows, which has no `execve`, the command runs
214
+ * as a child of this process, found through `Path` and `PATHEXT`. Either way a command that
215
+ * cannot start prints why and answers 127 when it is not found and 126 when it is found but cannot
216
+ * run, as a shell exits.
217
+ */
218
+ function launch(command, env) {
219
+ return process.platform === "win32" ? launchWindows(command, env) : Promise.resolve(replaceWith(command, env));
220
+ }
120
221
  //#endregion
121
222
  //#region src/lease/procs.ts
122
223
  const STAT_AFTER_COMM = 2;
@@ -378,6 +479,7 @@ async function ready(port, paths, exited) {
378
479
  * worktree's lease, so only `down` of its own lease stops it.
379
480
  */
380
481
  async function ensureMongod(port, paths, env) {
482
+ if (process.platform === "win32") throw new Error("antelopejs-lease: a lease's own mongod is not supported on Windows, where mongod has no --fork and holds its mongod.lock exclusively; set DMS_MONGO_URL to a server you run");
381
483
  if (mongodPid(paths.dbpath) !== void 0) return ready(port, paths, () => true);
382
484
  const binary = findMongod(env);
383
485
  if (binary === void 0) throw new Error("antelopejs-lease: no mongod on PATH or in ~/.cache/mongodb-binaries; install MongoDB, or set DMS_MONGO_URL to a server you run");
@@ -410,6 +512,12 @@ async function ensureMongod(port, paths, env) {
410
512
  const LOCK_WAIT_MS = 15e3;
411
513
  const RECORD_FILE = "lease.json";
412
514
  const RUNS_DIR = "runs";
515
+ const NODE_FS = {
516
+ readdir: (path) => {
517
+ readdirSync(path);
518
+ },
519
+ stat: (path) => statSync(path, { throwIfNoEntry: false })
520
+ };
413
521
  function staleReason(record, git) {
414
522
  if (git === void 0) return "missing";
415
523
  if (git.inode !== record.gitInode) return "recreated";
@@ -431,9 +539,11 @@ function leaseState(parsed, facts) {
431
539
  reason
432
540
  };
433
541
  }
434
- function probeGit(worktree) {
542
+ /** Lists `worktree`, then stats its `.git`, and reports what the two reads found. */
543
+ function probeGit(worktree, fs = NODE_FS) {
435
544
  try {
436
- const stat = statSync(join(worktree, ".git"), { throwIfNoEntry: false });
545
+ fs.readdir(worktree);
546
+ const stat = fs.stat(join(worktree, ".git"));
437
547
  if (stat === void 0) return { kind: "gone" };
438
548
  return {
439
549
  kind: "present",
@@ -443,13 +553,19 @@ function probeGit(worktree) {
443
553
  }
444
554
  };
445
555
  } catch (error) {
556
+ const code = error instanceof Error && "code" in error ? String(error.code) : "";
557
+ if (code === "ENOENT" || code === "ENOTDIR") return { kind: "gone" };
446
558
  return {
447
559
  kind: "unreadable",
448
- code: (error instanceof Error && "code" in error ? String(error.code) : "") || "unknown"
560
+ code: code || "unknown"
449
561
  };
450
562
  }
451
563
  }
452
- /** The worktree containing `cwd`, by the real path of `git rev-parse --show-toplevel`. */
564
+ /**
565
+ * The worktree containing `cwd`, by the real path of `git rev-parse --show-toplevel`. The native
566
+ * real path expands a Windows 8.3 short name such as `RUNNER~1`, so the id does not depend on how
567
+ * the caller spelled the directory.
568
+ */
453
569
  function locateWorktree(cwd) {
454
570
  let top;
455
571
  try {
@@ -465,7 +581,7 @@ function locateWorktree(cwd) {
465
581
  } catch {
466
582
  throw new Error(`antelopejs-lease: ${cwd} is not inside a git worktree`);
467
583
  }
468
- const path = realpathSync(top);
584
+ const path = realpathSync.native(top);
469
585
  const git = probeGit(path);
470
586
  if (git.kind !== "present") throw new Error(`antelopejs-lease: ${path} has no .git entry`);
471
587
  return {
@@ -745,6 +861,10 @@ async function terminate(found, report) {
745
861
  for (const target of found) if (!survivors.includes(target)) report(`stopped pid ${target.pid} (${target.command})`);
746
862
  if (survivors.length > 0) throw new Error(`antelopejs-lease: pid ${survivors.map((target) => target.pid).join(", ")} still running ${KILL_WAIT_MS / 1e3} s after SIGKILL`);
747
863
  }
864
+ /** Throws unless this platform is Linux, the only one where a process's environment can be read to find a lease's processes. */
865
+ function assertStopSupported() {
866
+ if (process.platform !== "linux") throw new Error("antelopejs-lease: down --stop reads /proc and runs on Linux only; stop your servers with their own stop command, then run down");
867
+ }
748
868
  /**
749
869
  * Stops every process of this user whose environment holds `ANTELOPEJS_LEASE=<id>`, which `run`
750
870
  * exports and every descendant inherits, except this process and its ancestors. Signals each pid
@@ -754,7 +874,7 @@ async function terminate(found, report) {
754
874
  * throws when one outlives the kill or new ones keep appearing. Linux only: it reads `/proc`.
755
875
  */
756
876
  async function stopOwn(id, report) {
757
- if (process.platform !== "linux") throw new Error("antelopejs-lease: down --stop reads /proc and runs on Linux only; stop your servers with their own stop command, then run down");
877
+ assertStopSupported();
758
878
  const marker = leaseMarker(id);
759
879
  const shield = ancestry();
760
880
  for (let round = 0; round < ROUNDS; round += 1) {
@@ -772,8 +892,9 @@ const DAY_MS = 864e5;
772
892
  const ROLES = Object.keys(PORT_ROLES).filter(isRole);
773
893
  /**
774
894
  * Opens this worktree's lease, makes sure its mongod runs unless `DMS_MONGO_URL` names another
775
- * server, and replaces this process with `command` under the lease's environment. Answers 127 or
776
- * 126, as a shell does, only when the command is not found or cannot run.
895
+ * server, and runs `command` under the lease's environment: as this process on Linux and macOS, as
896
+ * a child of it on Windows. Answers 127 or 126, as a shell does, when the command is not found or
897
+ * cannot run, and the command's own exit code on Windows.
777
898
  */
778
899
  async function run(command, as, env) {
779
900
  const worktree = locateWorktree(process.cwd());
@@ -865,6 +986,7 @@ async function down(env, options) {
865
986
  const worktree = locateWorktree(process.cwd());
866
987
  const entry = readEntries(leaseHome(env)).find((candidate) => candidate.id === worktree.id);
867
988
  if (entry === void 0) return;
989
+ if (options.stop !== void 0) assertStopSupported();
868
990
  if (entry.parsed?.kind === "foreign") throw foreignRecord(entry.dir);
869
991
  const record = entry.parsed?.kind === "current" ? entry.parsed.record : void 0;
870
992
  if (record !== void 0 && options.stop !== void 0) await stopOwn(record.id, options.stop);
@@ -2,11 +2,11 @@
2
2
  import { c as parseCeilings, l as readCeilings, t as CEILINGS_FILE } from "../ceilings-B7KayYIG.mjs";
3
3
  import { n as renamedPaths } from "../renames-L2owF5GD.mjs";
4
4
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
5
- import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-DJ0TeaTU.mjs";
6
- import { n as ratchet, r as withPreviousTree } from "../ratchet-1O8k4Dxu.mjs";
7
- import { t as lintDiagnostics } from "../oxlint-BbpTFFmf.mjs";
8
- import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-DgYdu6JK.mjs";
9
- import { n as suppressionBase } from "../suppression-base-DZgUDXiI.mjs";
5
+ import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-C-JJhExM.mjs";
6
+ import { n as ratchet, r as withPreviousTree } from "../ratchet-SQ7vTR0i.mjs";
7
+ import { t as lintDiagnostics } from "../oxlint-CCOJqj3d.mjs";
8
+ import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-CtIYSoDO.mjs";
9
+ import { n as suppressionBase } from "../suppression-base-whhvw-IJ.mjs";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import { execFileSync, spawnSync } from "node:child_process";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { d as toolingRoot } from "../package-DnxZ2CXZ.mjs";
3
3
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
- import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
+ import { c as repositoryRoot } from "../files-C-JJhExM.mjs";
5
5
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { parseArgs } from "node:util";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
- import { c as repositoryRoot, r as changedFiles } from "../files-DJ0TeaTU.mjs";
4
- import { n as unusedDirectives } from "../oxlint-BbpTFFmf.mjs";
5
- import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-DgYdu6JK.mjs";
6
- import { c as suppressionsIn, i as inWorktree } from "../suppressions-CQTcKCi1.mjs";
7
- import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-DZgUDXiI.mjs";
3
+ import { c as repositoryRoot, r as changedFiles } from "../files-C-JJhExM.mjs";
4
+ import { n as unusedDirectives } from "../oxlint-CCOJqj3d.mjs";
5
+ import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-CtIYSoDO.mjs";
6
+ import { c as suppressionsIn, i as inWorktree } from "../suppressions-C79kRvYI.mjs";
7
+ import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-whhvw-IJ.mjs";
8
8
  import { readdirSync } from "node:fs";
9
- import { dirname, join } from "node:path";
9
+ import { join, posix } from "node:path";
10
10
  import { execFileSync, spawnSync } from "node:child_process";
11
11
  import { parseArgs } from "node:util";
12
12
  //#region src/guardrails/dead-directives.ts
@@ -38,11 +38,10 @@ function written(directive, rules = directive.rules) {
38
38
  }
39
39
  /** Whether an ESLint config sits in the file's directory or above it, so ESLint may run the rules an `eslint-` directive names. */
40
40
  function lintedByEslint(root, file) {
41
- for (let directory = dirname(join(root, file)); directory.startsWith(root); directory = dirname(directory)) {
42
- if (readdirSync(directory).some((name) => ESLINT_CONFIG.test(name))) return true;
43
- if (directory === root) break;
41
+ for (let directory = posix.dirname(file);; directory = posix.dirname(directory)) {
42
+ if (readdirSync(join(root, directory)).some((name) => ESLINT_CONFIG.test(name))) return true;
43
+ if (directory === ".") return false;
44
44
  }
45
- return false;
46
45
  }
47
46
  /** The directive oxlint's report is about: on its line, else the nearest earlier block disable it ends at an `-enable` on that line, naming the dead rule when oxlint names one. */
48
47
  function reported(directives, unused) {
package/dist/bin/sync.mjs CHANGED
@@ -3,16 +3,18 @@ import { a as formatCeilings, l as readCeilings, s as isRetired, t as CEILINGS_F
3
3
  import { a as managedPackage, c as repositoryTools, f as toolingVersions, l as serializeManifest, m as usesNuxt, n as bootstrapDependencies, o as packageManager, p as usesCaptures, r as bootstrappedManifest, s as parseManifest, t as addedDevDependencies, u as templatePackage } from "../package-DnxZ2CXZ.mjs";
4
4
  import { t as admits } from "../semver-BDxeEcP_.mjs";
5
5
  import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-Dg188oRC.mjs";
6
- import { a as VERIFY_KINDS, c as isVerifyKind, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-igPpEDpS.mjs";
6
+ import { a as VERIFY_KINDS, c as isVerifyKind, d as linkPointsAt, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-BCFFyp3l.mjs";
7
7
  import { r as localVersions, t as checkInterfaceRanges } from "../interface-ranges-CcVSr59f.mjs";
8
8
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
9
9
  import { c as CI_CONTEXT, f as ciWorkflow, i as hasChecksWorkflow, n as ciNodeCallers, p as placeholderTestScript, r as ciRenovateSyncCallers, s as renovateArtifacts, t as MISSING_CHECKS_WORKFLOW, u as CI_PATH } from "../workflow-CPcNc8KL.mjs";
10
- import { a as gitFiles, c as repositoryRoot, u as trackedManifests } from "../files-DJ0TeaTU.mjs";
11
- import { a as stepsOf, c as workspacePatterns, i as matchingScripts, n as droppedChecksSteps, o as planDocs, s as workspaceDirectories } from "../checks-DqTjyKCC.mjs";
12
- import { i as recordedRelease, t as measureBaseline } from "../ratchet-1O8k4Dxu.mjs";
13
- import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-DgYdu6JK.mjs";
14
- import { u as typescript } from "../suppressions-CQTcKCi1.mjs";
15
- import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
10
+ import { a as gitFiles, c as repositoryRoot, u as trackedManifests } from "../files-C-JJhExM.mjs";
11
+ import { n as workspaceDirectories, r as workspacePatterns, t as planDocs } from "../docs-compat-Ft1r2sf0.mjs";
12
+ import { n as shimInvocation } from "../run-command-BlFRPORx.mjs";
13
+ import { i as recordedRelease, t as measureBaseline } from "../ratchet-SQ7vTR0i.mjs";
14
+ import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps } from "../checks-BC-F8bsv.mjs";
15
+ import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-CtIYSoDO.mjs";
16
+ import { u as typescript } from "../suppressions-C79kRvYI.mjs";
17
+ import { t as DEFAULT_SHARED } from "../map-BYkmnvNw.mjs";
16
18
  import { createRequire } from "node:module";
17
19
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
18
20
  import { basename, dirname, join, posix, resolve } from "node:path";
@@ -92,9 +94,11 @@ function untypedDocsFiles(root) {
92
94
  /** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
93
95
  function runPnpm(root, args) {
94
96
  const command = ["pnpm", ...args].join(" ");
95
- const result = spawnSync("pnpm", args, {
97
+ const pnpm = shimInvocation("pnpm", args);
98
+ const result = spawnSync(pnpm.command, pnpm.args, {
96
99
  cwd: root,
97
- encoding: "utf8"
100
+ encoding: "utf8",
101
+ shell: pnpm.shell
98
102
  });
99
103
  if (result.error) return `${command} failed: ${result.error.message}`;
100
104
  if (result.status === 0) return void 0;
@@ -270,12 +274,57 @@ function agentsBlock(context) {
270
274
  ].join("\n");
271
275
  }
272
276
  //#endregion
277
+ //#region src/guardrails/exec-bit.ts
278
+ function git(root, args) {
279
+ const result = spawnSync("git", args, {
280
+ cwd: root,
281
+ encoding: "utf8"
282
+ });
283
+ return result.status === 0 ? result.stdout : void 0;
284
+ }
285
+ /** Whether git ignores the filesystem's exec bit in the checkout at `root`, as Git for Windows does by setting `core.fileMode` to false. */
286
+ function ignoresFileMode(root) {
287
+ return git(root, [
288
+ "config",
289
+ "--bool",
290
+ "core.fileMode"
291
+ ])?.trim() === "false";
292
+ }
293
+ /** Whether `file` under `root` is executable: its filesystem exec bit, or, where git ignores that bit, the `100755` mode git's index records for it. */
294
+ function isExecutable(root, file) {
295
+ if ((statSync(join(root, file)).mode & 73) !== 0) return true;
296
+ return ignoresFileMode(root) && git(root, [
297
+ "ls-files",
298
+ "--stage",
299
+ "--",
300
+ file
301
+ ])?.startsWith("100755 ") === true;
302
+ }
303
+ /** Sets `file`'s mode; where the filesystem drops the exec bit, as on Windows, and git ignores it, also stages the file with mode `100755`, the only place such a checkout keeps that bit. */
304
+ function makeExecutable(root, file, mode) {
305
+ const path = join(root, file);
306
+ chmodSync(path, mode);
307
+ if ((statSync(path).mode & 73) === 0 && ignoresFileMode(root)) execFileSync("git", [
308
+ "update-index",
309
+ "--add",
310
+ "--chmod=+x",
311
+ "--",
312
+ file
313
+ ], { cwd: root });
314
+ }
315
+ //#endregion
273
316
  //#region src/guardrails/pnpm-workspace.ts
274
317
  const PATH = "pnpm-workspace.yaml";
275
- /** Whether the pinned pnpm reads settings from a `pnpm-workspace.yaml` without `packages`, which pnpm before 10.5 rejects. An unpinned pnpm counts as current. */
276
- function readsSettings(manifest) {
318
+ /** The first pnpm that keeps `pnpm --dir <nested> install` in the nested project when the root `pnpm-workspace.yaml` has no `packages`. Earlier pnpm installs the root instead. */
319
+ const SCOPED_NESTED_INSTALLS = "11.27.1";
320
+ /**
321
+ * What sync does for a repository without a `pnpm-workspace.yaml`, by its pinned pnpm. An unpinned pnpm counts as current.
322
+ * pnpm 10 and earlier only warn about an undecided build, so they get no file. pnpm 11 fails the install without one, and before 11.27.1 misroutes nested installs with one, so its pin must rise.
323
+ */
324
+ function creation(manifest) {
277
325
  const pinned = manifest.packageManager?.split("@")[1];
278
- return pinned === void 0 || admits(">=10.5.0", pinned);
326
+ if (pinned === void 0 || admits(`>=${SCOPED_NESTED_INSTALLS}`, pinned)) return "write";
327
+ return admits(">=11.0.0", pinned) ? "raise" : "skip";
279
328
  }
280
329
  /**
281
330
  * The dependency builds sync declares and pnpm 11 must be told to skip.
@@ -284,6 +333,14 @@ function readsSettings(manifest) {
284
333
  function skippedBuilds(captures) {
285
334
  return captures ? ["lefthook", "mongodb-memory-server"] : ["lefthook"];
286
335
  }
336
+ /** Whether `current` holds nothing but builds sync turns off, so pnpm reads it only to make the repository root a workspace. */
337
+ function onlyDecidedBuilds(current) {
338
+ const document = parseDocument(current);
339
+ const builds = document.get("allowBuilds");
340
+ if (document.errors.length || !isMap(document.contents) || document.contents.items.length !== 1 || !isMap(builds) || !builds.items.length) return false;
341
+ const synced = skippedBuilds(true);
342
+ return builds.items.every(({ key, value }) => isScalar(key) && synced.includes(String(key.value)) && isScalar(value) && value.value === false);
343
+ }
287
344
  /**
288
345
  * `current` with `allowBuilds.<name>` set to `false` for each of `names` the repository does not already decide.
289
346
  * pnpm 11 fails an install on a dependency build it was not told about.
@@ -315,10 +372,18 @@ function pnpmWorkspaceArtifacts(root, manifest, managed) {
315
372
  if (!managed || packageManager(manifest) !== "pnpm") return [];
316
373
  const file = join(root, PATH);
317
374
  const current = existsSync(file) ? readFileSync(file, "utf8") : void 0;
318
- if (current === void 0 && !readsSettings(manifest)) return [];
319
375
  const names = skippedBuilds(usesCaptures(root));
320
376
  try {
321
377
  const content = withBuildsDecided(names, current);
378
+ const action = creation(manifest);
379
+ if (action !== "write" && onlyDecidedBuilds(content)) {
380
+ if (action === "skip" && current === void 0) return [];
381
+ return [{
382
+ kind: "error",
383
+ path: PATH,
384
+ message: action === "skip" ? `${PATH} holds nothing but the allowBuilds that antelopejs-sync writes. pnpm before 11 does not need it, and it makes a nested \`pnpm install\` install the repository root. Delete ${PATH}, then rerun antelopejs-sync.` : `pnpm 11 needs a ${PATH} to install ${names.join(" and ")}, and before ${SCOPED_NESTED_INSTALLS} that file makes a nested \`pnpm install\` install the repository root. Set \`packageManager\` to \`pnpm@${SCOPED_NESTED_INSTALLS}\` or later, then rerun antelopejs-sync.`
385
+ }];
386
+ }
322
387
  return [content === current ? {
323
388
  kind: "unchanged",
324
389
  path: PATH
@@ -489,7 +554,7 @@ function backendBoundaryArtifacts(root) {
489
554
  cwd: root,
490
555
  encoding: "utf8"
491
556
  }).split("\0").filter((path) => path && dirname(dirname(path)) !== ".").map((path) => {
492
- const manifest = join(dirname(dirname(dirname(path))), "package.json");
557
+ const manifest = posix.join(posix.dirname(posix.dirname(posix.dirname(path))), "package.json");
493
558
  const name = existsSync(join(root, manifest)) ? parseManifest(readFileSync(join(root, manifest), "utf8")).name : void 0;
494
559
  if (!name) return {
495
560
  kind: "error",
@@ -895,7 +960,7 @@ const KIND_TEXT = {
895
960
  - a plain function runs the \`interface.calls\` hook of \`verify.config.ts\` and must return its \`expect\`; one only providers call is listed in \`interface.providerSide\` with why.
896
961
  A declared function with none of these fails the journey.
897
962
  - \`minor-bump\`: reads the declared functions of the packed head and of the published version (\`npm pack <name>@<latest>\`). An added, changed or removed function needs a release of at least the next minor. The release is the head version when it is already bumped, otherwise what changelogen makes of the change title (\`new --title\`) or the commit subjects since the base.`,
898
- layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\`.
963
+ layer: `- \`services\`: image, port, optional \`args\`, readiness command and a \`reset\` command run before every journey, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\`.
899
964
  - \`interface.provide(api, services)\` runs in the stub provider after the generic stubs attach, for example to hand a client pointed at \`services\` to \`internal.SetClient\`.
900
965
  - \`interface.calls["<entry>:<path>"]\` calls a plain exported function from the consumer and states the value it must return.
901
966
  - \`interface.providerSide["<entry>:<path>"]\` names a function only providers call, with the reason.`,
@@ -908,7 +973,7 @@ const KIND_TEXT = {
908
973
  user: "The user of a module is an app developer: they add it to `antelope.config.ts`, configure it, and other modules call the interfaces it implements.",
909
974
  launch: "`new` runs the setup (`pnpm run build` by default), then starts every `services` entry of `verify.config.ts` in its own Docker container on a free loopback port, named `<prefix>-<repo>-<service>-<run>` (`VERIFY_CONTAINER_PREFIX`, default `verify`), and waits for each readiness command. A provider with sandbox keys in `saas.env` records the missing ones.",
910
975
  builtins: "- `module-dev`: a fixture project installs the module as `local` with `moduleConfig(services)` as its config, plus the `companions(services)` modules and a consumer module. `ajs project dev` must answer, the consumer must load every implemented interface, Ctrl+C must exit 130 and the port must refuse afterwards.",
911
- layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, so each starts from a clean state.
976
+ layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, so each starts from a clean state. Optional \`args\` follow the image in \`docker run\` in place of its default command, such as \`["--performance-schema=ON", "--log-bin"]\` for MariaDB's server.
912
977
  - \`moduleConfig(services)\`: the module's configuration, pointing at the run's containers.
913
978
  - \`companions(services)\`: other modules the fixture project loads, keyed by name, each a \`source\` and an optional \`config\` as in \`antelope.config.ts\`. Add the provider of every interface the module imports that it does not implement, such as \`@antelopejs/api\` for \`@antelopejs/interface-api\`, or the module never finishes starting.
914
979
  - \`saas: { env, sandbox }\`: a SaaS module runs against the provider's sandbox with keys from these environment variables. Without every key, each journey is NOT VERIFIED and so is the verdict, never PASS or PASS+NOTES.
@@ -929,7 +994,7 @@ Both take their project from \`context.prepared("scaffolded", ...)\`, so the run
929
994
  layer: `- \`template.name\`: the listing name users pass to \`--template\`.
930
995
  - \`template.project\`: list it under \`projectTemplates\`.
931
996
  - \`template.module\`: a module template, listed under \`templates\` and created with \`ajs module init\`; it excludes \`template.project\`.
932
- - \`services\`: image, port, readiness command and \`reset\`, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\` and passes their endpoints to the project it starts through the \`env\` of \`context.dev\`.
997
+ - \`services\`: image, port, optional \`args\`, readiness command and \`reset\`, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\` and passes their endpoints to the project it starts through the \`env\` of \`context.dev\`.
933
998
  - \`context.dev(name, project, { command })\`: a template that is not an \`ajs\` project starts with its own command, such as \`["node", "ace", "serve"]\`, in place of \`ajs project dev\`. The harness records its PID, so \`context.stop\` and \`clean\` stop it, and \`template.probe\` decides when it is ready. Leave \`scaffold-dev\` and \`scaffold-checks\` out of its features: both run \`ajs\`.
934
999
  - \`template.probe\`: \`path\`, \`status\` and \`body\` for an HTTP welcome page or endpoint, or \`log\` and \`settleMs\` for a template that serves nothing.`,
935
1000
  smoke: "`scaffold-dev` and `scaffold-checks`, or, for a template that is not an `ajs` project, its own journeys that start it with `context.dev(name, project, { command })`",
@@ -1204,7 +1269,7 @@ function planLink(root, link, target) {
1204
1269
  actions: [],
1205
1270
  errors: [`${link} is not a symlink. Move it away, then rerun antelopejs-sync.`]
1206
1271
  };
1207
- if (readlinkSync(join(root, link)) !== target) return {
1272
+ if (!linkPointsAt(root, link, target)) return {
1208
1273
  actions: [{
1209
1274
  kind: "link",
1210
1275
  path: link,
@@ -1398,7 +1463,7 @@ const MANAGED_ARTIFACTS = [
1398
1463
  })
1399
1464
  }
1400
1465
  ];
1401
- function planSync(current, modes, context) {
1466
+ function planSync(current, executables, context) {
1402
1467
  const plan = [];
1403
1468
  for (const preset of PRESET_CONFIGS) for (const file of preset.legacy) if (current.has(file)) plan.push({
1404
1469
  kind: "error",
@@ -1411,7 +1476,7 @@ function planSync(current, modes, context) {
1411
1476
  if (artifact.path === ".github/workflows/ci.yml" && !context.managesCi) continue;
1412
1477
  try {
1413
1478
  const { content, notes } = artifact.desired(current.get(artifact.path), context);
1414
- const changed = current.get(artifact.path) !== content || artifact.mode !== void 0 && (artifact.mode & 73) !== 0 && ((modes.get(artifact.path) ?? 0) & 73) === 0;
1479
+ const changed = current.get(artifact.path) !== content || artifact.mode !== void 0 && (artifact.mode & 73) !== 0 && !executables.has(artifact.path);
1415
1480
  if (notes.length) plan.push({
1416
1481
  kind: "migrated",
1417
1482
  path: artifact.path,
@@ -1458,17 +1523,17 @@ function plannedDocs(docs) {
1458
1523
  }
1459
1524
  function repositorySnapshot(root) {
1460
1525
  const current = /* @__PURE__ */ new Map();
1461
- const modes = /* @__PURE__ */ new Map();
1526
+ const executables = /* @__PURE__ */ new Set();
1462
1527
  for (const file of [...MANAGED_ARTIFACTS.map(({ path }) => path), ...PRESET_CONFIGS.flatMap(({ legacy }) => legacy)]) {
1463
1528
  const path = join(root, file);
1464
1529
  if (existsSync(path)) {
1465
1530
  current.set(file, readFileSync(path, "utf8"));
1466
- modes.set(file, statSync(path).mode & 511);
1531
+ if (isExecutable(root, file)) executables.add(file);
1467
1532
  }
1468
1533
  }
1469
1534
  return {
1470
1535
  current,
1471
- modes
1536
+ executables
1472
1537
  };
1473
1538
  }
1474
1539
  function linksTo(root, link, target) {
@@ -1511,7 +1576,7 @@ function writeArtifacts(root, artifacts) {
1511
1576
  mkdirSync(dirname(path), { recursive: true });
1512
1577
  if (lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink()) unlinkSync(path);
1513
1578
  writeFileSync(path, artifact.content);
1514
- if (artifact.mode !== void 0) chmodSync(path, artifact.mode);
1579
+ if (artifact.mode !== void 0) makeExecutable(root, artifact.path, artifact.mode);
1515
1580
  }
1516
1581
  }
1517
1582
  function repositoryNotices(root, context) {
@@ -1528,7 +1593,7 @@ function repositoryNotices(root, context) {
1528
1593
  */
1529
1594
  function syncRepository(root, options = {}) {
1530
1595
  const profile = options.profile ?? "full";
1531
- const { current, modes } = repositorySnapshot(root);
1596
+ const { current, executables } = repositorySnapshot(root);
1532
1597
  const manifest = parseManifest(current.get("package.json") ?? "{}");
1533
1598
  const verify = planVerify(root, {
1534
1599
  flag: options.verify,
@@ -1543,7 +1608,7 @@ function syncRepository(root, options = {}) {
1543
1608
  ...renovateArtifacts(root, manifest, profile === "full" || verify.kind === "template"),
1544
1609
  ...pnpmWorkspaceArtifacts(root, manifest, profile === "full")
1545
1610
  ];
1546
- let plan = [...planSync(current, modes, context), ...standalone];
1611
+ let plan = [...planSync(current, executables, context), ...standalone];
1547
1612
  const errors = plan.filter((artifact) => artifact.kind === "error").map(({ message }) => message);
1548
1613
  const entryOnly = checkEntryOnlyConfiguration(root);
1549
1614
  const coverage = checkTypecheckCoverage(root, Boolean(options.check));
@@ -1560,7 +1625,7 @@ function syncRepository(root, options = {}) {
1560
1625
  ...baseline,
1561
1626
  pack: recordedRelease(void 0)
1562
1627
  });
1563
- plan = [...planSync(current, modes, context), ...standalone];
1628
+ plan = [...planSync(current, executables, context), ...standalone];
1564
1629
  }
1565
1630
  const writes = plan.filter((artifact) => artifact.kind === "write" || artifact.kind === "migrated");
1566
1631
  if (!options.check && !errors.length) {
@@ -1908,9 +1973,11 @@ function failureText(result) {
1908
1973
  return result.stderr.trim().split("\n")[0] || `gh exited with ${result.status ?? result.signal}`;
1909
1974
  }
1910
1975
  function gh(root, args) {
1911
- return spawnSync("gh", args, {
1976
+ const invocation = shimInvocation("gh", args);
1977
+ return spawnSync(invocation.command, invocation.args, {
1912
1978
  cwd: root,
1913
- encoding: "utf8"
1979
+ encoding: "utf8",
1980
+ shell: invocation.shell
1914
1981
  });
1915
1982
  }
1916
1983
  /** Turns `delete_branch_on_merge` on through `gh`, reading it first so a repository that has it on is never written. */