@antelopejs/tooling-configs 0.5.0 → 0.5.1

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/sync.mjs CHANGED
@@ -5,7 +5,7 @@ import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIG
5
5
  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
6
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
7
7
  import { a as gitFiles, c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
8
- import { i as recordedRelease, t as measureBaseline } from "../ratchet-BTiPMqam.mjs";
8
+ import { i as recordedRelease, t as measureBaseline } from "../ratchet-ClfblHNJ.mjs";
9
9
  import { a as ciWorkflow, c as ciNodeCallers, l as ciRenovateSyncCallers, o as placeholderTestScript, p as renovateArtifacts, r as CI_PATH, s as MISSING_CHECKS_WORKFLOW, u as hasChecksWorkflow } from "../ci-workflow-COJUT12b.mjs";
10
10
  import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-Dvb_IqBo.mjs";
11
11
  import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
@@ -67,6 +67,7 @@ const SHARED_RULES = [
67
67
  ["String-keyed object tables are read through own keys only", "`antelopejs/no-inherited-key-lookup`"],
68
68
  ["A type guard checks each member it narrows to; keys with `Object.hasOwn`", "`antelopejs/no-presence-only-type-guard`"],
69
69
  ["A type guard checks the nested elements and values it claims", "review; no tool"],
70
+ ["A startup read does not decide an insert another replica can race", "`antelopejs/no-read-then-insert`"],
70
71
  ["`Object.assign` writes no `unknown`, `any` or mistyped value over a field", "`antelopejs/no-unsafe-object-assign`"],
71
72
  ["Every file type-aware lint reads is listed by a tsconfig", "`antelopejs/require-tsconfig-include`"],
72
73
  ["Params ≤ 5, function ≤ 120 lines, file ≤ 500 lines, depth ≤ 4, complexity ≤ 20", "`eslint/max-*`, `eslint/complexity`"],
@@ -96,9 +97,9 @@ const FULL_RULES = [
96
97
  ["A CI gate reads `needs.<id>` only of jobs in its `needs`", "`antelopejs-sync --check`"],
97
98
  ["Entry-only rules exempt no tracked outsider", "`antelopejs-sync --check`"],
98
99
  ["A DMS layer's `build/backend-boundary.ts` is the pack's plugin", "`antelopejs-sync --check`"],
99
- ["No `skipLibCheck` in the root tsconfig or one `typecheck` or `build` uses", "Reported by `antelopejs-sync` (note only)"],
100
- ["`build` skips the lib check only over what `typecheck` checks", "Reported by `antelopejs-sync` (note only)"],
101
- ["`release` runs `typecheck`", "Reported by `antelopejs-sync` (note only)"],
100
+ ["No `skipLibCheck` in the root tsconfig or one `typecheck` or `build` uses", "`antelopejs-sync --check`"],
101
+ ["`build` skips the lib check only over what `typecheck` checks", "`antelopejs-sync --check`"],
102
+ ["`release` runs `typecheck`", "`antelopejs-sync --check`"],
102
103
  ["A test names the wrong implementation it catches", "review; no tool"]
103
104
  ];
104
105
  /** Pads each column the way oxfmt does, so formatting AGENTS.md never reports sync drift. */
@@ -425,6 +426,91 @@ function checkEntryOnlyConfiguration(root) {
425
426
  };
426
427
  }
427
428
  //#endregion
429
+ //#region src/guardrails/markdown-table.ts
430
+ /** The lines of a Markdown table whose first row is the header, columns padded as oxfmt leaves them. */
431
+ function tableLines(table) {
432
+ const widths = table[0].map((_, column) => Math.max(3, ...table.map((row) => row[column].length)));
433
+ const line = (cells) => `| ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" | ")} |`;
434
+ return [
435
+ line(table[0]),
436
+ line(widths.map((width) => "-".repeat(width))),
437
+ ...table.slice(1).map(line)
438
+ ];
439
+ }
440
+ //#endregion
441
+ //#region src/guardrails/docs-modules.ts
442
+ const DMS_MODULES_START = "<!-- antelopejs-dms-modules:start -->";
443
+ const DMS_MODULES_END = "<!-- antelopejs-dms-modules:end -->";
444
+ const ORGANIZATION = "https://github.com/AntelopeJS";
445
+ /** The AntelopeJS DMS modules in display order. Every README holding the markers lists exactly these. */
446
+ const DMS_MODULES = [
447
+ {
448
+ repo: "dms-builder",
449
+ row: "Edit pages, tables and data sources by clicking, as TypeScript that compiles"
450
+ },
451
+ {
452
+ repo: "dms-ai",
453
+ row: "An assistant chat in the dashboard, on your own Claude Code or Codex"
454
+ },
455
+ {
456
+ repo: "dms-database",
457
+ row: "Schemas, relation diagrams, a data browser and a query console"
458
+ },
459
+ {
460
+ repo: "dms-api",
461
+ row: "API health, request logs, per-route statistics and a request tester"
462
+ },
463
+ {
464
+ repo: "dms-automation",
465
+ row: "Node-graph automations on schedules, webhooks and DMS events, with a trace for every run"
466
+ },
467
+ {
468
+ repo: "dms-mailing",
469
+ row: "E-mail templates in a block editor, versions, a send log and delivery metrics"
470
+ },
471
+ {
472
+ repo: "dms-lang",
473
+ row: "Translation coverage, a translation matrix and a translation queue"
474
+ },
475
+ {
476
+ repo: "dms-media",
477
+ row: "A media library with folders, per-folder permissions, image sizes and light editing"
478
+ },
479
+ {
480
+ repo: "dms-saas",
481
+ row: "Self-service sign-up, plans that gate features, and Stripe billing"
482
+ },
483
+ {
484
+ repo: "dms-marketing",
485
+ row: "Traffic, conversion funnels with A/B splits and click heatmaps, without cookies"
486
+ },
487
+ {
488
+ repo: "dms-frontend",
489
+ row: "The `ajs dms` CLI, the Vue renderer and the SDK every frontend module builds on"
490
+ }
491
+ ];
492
+ /** The generated block, formatted as oxfmt leaves it. */
493
+ function modulesBlock() {
494
+ return [
495
+ DMS_MODULES_START,
496
+ "",
497
+ ...tableLines([["Module", "What it adds"], ...DMS_MODULES.map(({ repo, row }) => [`[\`${repo}\`](${ORGANIZATION}/${repo})`, row])]),
498
+ "",
499
+ DMS_MODULES_END,
500
+ ""
501
+ ].join("\n");
502
+ }
503
+ /** The README with the block between its markers rewritten. A README without markers comes back as it is. */
504
+ function placeModulesBlock(current) {
505
+ const start = current.indexOf(DMS_MODULES_START);
506
+ const end = current.indexOf(DMS_MODULES_END);
507
+ const starts = current.split(DMS_MODULES_START).length - 1;
508
+ const ends = current.split(DMS_MODULES_END).length - 1;
509
+ if (starts === 0 && ends === 0) return current;
510
+ if (starts !== 1 || ends !== 1 || end < start) throw new Error("invalid antelopejs-dms-modules markers: a README holds exactly one start marker followed by one end marker. Repair or delete them, then rerun antelopejs-sync.");
511
+ return `${current.slice(0, start)}${modulesBlock()}${current.slice(end + 35).replace(/^\r?\n/, "")}`;
512
+ }
513
+ //#endregion
428
514
  //#region src/guardrails/docs-compat.ts
429
515
  const DOCS_COMPAT_START = "<!-- antelopejs-docs-compat:start -->";
430
516
  const DOCS_COMPAT_END = "<!-- antelopejs-docs-compat:end -->";
@@ -443,27 +529,19 @@ const RESOLVED_SECTIONS = [
443
529
  ];
444
530
  /** The generated block, rows sorted by package name, formatted as oxfmt leaves it. */
445
531
  function compatBlock(rows) {
446
- const table = [[
447
- "Package",
448
- "Supported",
449
- "Tested with"
450
- ], ...[...rows].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map(({ name, supported, tested }) => [
451
- `\`${name}\``,
452
- `\`${supported.replaceAll("|", "\\|")}\``,
453
- tested === void 0 ? UNRESOLVED : `\`${tested}\``
454
- ])];
455
- const widths = [
456
- 0,
457
- 1,
458
- 2
459
- ].map((column) => Math.max(3, ...table.map((row) => row[column].length)));
460
- const line = (cells) => `| ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" | ")} |`;
532
+ const sorted = [...rows].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
461
533
  return [
462
534
  DOCS_COMPAT_START,
463
535
  "",
464
- line(table[0]),
465
- line(widths.map((width) => "-".repeat(width))),
466
- ...table.slice(1).map(line),
536
+ ...tableLines([[
537
+ "Package",
538
+ "Supported",
539
+ "Tested with"
540
+ ], ...sorted.map(({ name, supported, tested }) => [
541
+ `\`${name}\``,
542
+ `\`${supported.replaceAll("|", "\\|")}\``,
543
+ tested === void 0 ? UNRESOLVED : `\`${tested}\``
544
+ ])]),
467
545
  "",
468
546
  DOCS_COMPAT_END,
469
547
  ""
@@ -633,12 +711,14 @@ function sharesLockfile(root) {
633
711
  function lockPath(shared, directory) {
634
712
  return shared ? LOCKFILE : relative$1(directory, LOCKFILE);
635
713
  }
636
- function readLock(root, shared, directory) {
714
+ function readLock(root, shared, directory, documents) {
637
715
  const path = join(root, lockPath(shared, directory));
638
- return existsSync(path) ? {
639
- document: parseDocument(readFileSync(path, "utf8")),
716
+ if (!documents.has(path) && existsSync(path)) documents.set(path, parseDocument(readFileSync(path, "utf8")));
717
+ const document = documents.get(path);
718
+ return document && {
719
+ document,
640
720
  importer: shared ? directory || "." : "."
641
- } : void 0;
721
+ };
642
722
  }
643
723
  /** Adds one package's `docs-files` lines and, when it needs one, its README with the generated blocks. */
644
724
  function planPackage(root, plan, lock, standard, { directory, ranges, published, node }) {
@@ -649,7 +729,7 @@ function planPackage(root, plan, lock, standard, { directory, ranges, published,
649
729
  if (isDirectory(root, docs)) plan.docsFiles.push(docs);
650
730
  const current = existsSync(join(root, readme)) ? readFileSync(join(root, readme), "utf8") : void 0;
651
731
  const nodeRange = standard && current !== void 0 ? node : void 0;
652
- if (ranges.size === 0 && nodeRange === void 0) return;
732
+ if (ranges.size === 0 && current === void 0) return;
653
733
  const rows = [...ranges].map(([name, supported]) => ({
654
734
  name,
655
735
  supported,
@@ -660,7 +740,7 @@ function planPackage(root, plan, lock, standard, { directory, ranges, published,
660
740
  plan.readmes.push({
661
741
  path: readme,
662
742
  current,
663
- content: rows.length > 0 ? placeCompatBlock(withRequirements, compatBlock(rows)) : withRequirements ?? ""
743
+ content: placeModulesBlock(rows.length > 0 ? placeCompatBlock(withRequirements, compatBlock(rows)) : withRequirements ?? "")
664
744
  });
665
745
  } catch (error) {
666
746
  plan.errors.push(`${readme}: ${error instanceof Error ? error.message : String(error)}`);
@@ -691,7 +771,8 @@ function planDocs(root, manager) {
691
771
  exists: (path) => existsSync(join(root, path))
692
772
  };
693
773
  const shared = sharesLockfile(root);
694
- const locks = new Map(packages.map(({ directory }) => [directory, manager === "pnpm" ? readLock(root, shared, directory) : void 0]));
774
+ const documents = /* @__PURE__ */ new Map();
775
+ const locks = new Map(qualifying.map(({ directory }) => [directory, manager === "pnpm" ? readLock(root, shared, directory, documents) : void 0]));
695
776
  const missing = manager === "pnpm" ? qualifying.filter(({ directory }) => !locks.get(directory)) : [];
696
777
  if (missing.length) {
697
778
  for (const path of new Set(missing.map(({ directory }) => lockPath(shared, directory)))) plan.errors.push(`${path} is missing, and the docs-compat block reads Tested with from it: run pnpm install, then rerun antelopejs-sync.`);
@@ -1165,17 +1246,20 @@ function scriptsOf(files) {
1165
1246
  return;
1166
1247
  }
1167
1248
  }
1168
- /** The package.json and tsconfig facts that keep `typecheck` the lib check no other script skips: `build` skips the lib check only over a program `typecheck` checks in full, no tsconfig a script uses or the root one sets `skipLibCheck: true`, and `release` runs `typecheck`. A file that cannot be read yields a note and never an error. */
1169
- function checkTypecheckCoverage(root) {
1249
+ /** The package.json and tsconfig facts that keep `typecheck` the lib check no other script skips: `build` skips the lib check only over a program `typecheck` checks in full, no tsconfig a script uses or the root one sets `skipLibCheck: true`, and `release` runs `typecheck`. Under `check` a broken fact is an error; otherwise it is a `Note:` advisory. A file that cannot be read yields a `Note:` advisory and never an error. */
1250
+ function checkTypecheckCoverage(root, check) {
1170
1251
  const files = coverageFiles(root);
1171
1252
  const scripts = scriptsOf(files);
1172
- if (scripts === void 0) return unreadableNotes(files);
1173
- return [
1253
+ const findings = scripts === void 0 ? [] : [
1174
1254
  ...skipCoverageErrors(scripts),
1175
1255
  ...skipLibCheckErrors(files, scripts),
1176
- ...releaseErrors(files, scripts),
1177
- ...unreadableNotes(files)
1256
+ ...releaseErrors(files, scripts)
1178
1257
  ];
1258
+ const notes = check ? unreadableNotes(files) : [...findings, ...unreadableNotes(files)];
1259
+ return {
1260
+ errors: check ? findings : [],
1261
+ advisories: notes.map((note) => `Note: ${note}`)
1262
+ };
1179
1263
  }
1180
1264
  /** The kind-specific text of each shared skill. */
1181
1265
  const KIND_TEXT = {
@@ -1337,7 +1421,7 @@ ${BIN} map
1337
1421
  6. **One-way doors.** The section comes right after the result line and is mandatory. \`${BIN} doors\` prints the \`One-way-door:\` line of the diff. Every file the path rules flag needs a door row or a false positive with its reason.
1338
1422
  7. **Result.** FAIL if any rule fails. NOT VERIFIED when any journey of a required feature is NOT VERIFIED, for example a SaaS module run without its sandbox keys, however many other journeys passed. PASS+NOTES when everything required ran and passed but the judgement lists something no journey reached or something the owner should look at. PASS otherwise.
1339
1423
 
1340
- Write your judgement to \`<run>/evidence/judgement.json\`:
1424
+ Write your judgement to a JSON file:
1341
1425
 
1342
1426
  \`\`\`json
1343
1427
  {
@@ -1353,13 +1437,13 @@ Write your judgement to \`<run>/evidence/judgement.json\`:
1353
1437
  }
1354
1438
  \`\`\`
1355
1439
 
1356
- A door row is \`{ "kind", "location", "irreversible", "containment" }\`, where \`containment\` says what limits the damage. Then render the verdict:
1440
+ A door row is \`{ "kind", "location", "irreversible", "containment" }\`, where \`containment\` says what limits the damage. Pass it to \`verdict\` in the same step:
1357
1441
 
1358
1442
  \`\`\`bash
1359
- ${BIN} verdict <run> --pr <n>
1443
+ ${BIN} verdict <run> --pr <n> --judgement <file>
1360
1444
  \`\`\`
1361
1445
 
1362
- \`verdict\` writes \`evidence/verdict.md\` and exits 1 unless the result is PASS or PASS+NOTES. Report the verdict and what you saw in your own reply, from a thread that did not write the change.
1446
+ \`verdict\` stores it as \`evidence/judgement.json\`, writes \`evidence/verdict.md\` and exits 1 when an input is missing or the result is not PASS or PASS+NOTES. Read \`verdict.md\` only after it exits. Report the verdict and what you saw in your own reply, from a thread that did not write the change.
1363
1447
 
1364
1448
  ## Trust
1365
1449
 
@@ -1835,7 +1919,9 @@ function syncRepository(root, options = {}) {
1835
1919
  let plan = [...planSync(current, modes, context), ...standalone];
1836
1920
  const errors = plan.filter((artifact) => artifact.kind === "error").map(({ message }) => message);
1837
1921
  const entryOnly = checkEntryOnlyConfiguration(root);
1922
+ const coverage = checkTypecheckCoverage(root, Boolean(options.check));
1838
1923
  errors.push(...entryOnly.errors, ...verify.errors, ...writing.errors);
1924
+ errors.push(...coverage.errors);
1839
1925
  const notes = plan.flatMap((artifact) => artifact.kind === "migrated" ? artifact.notes : []);
1840
1926
  (options.check ? errors : notes).push(...repositoryNotices(root, context));
1841
1927
  if (!errors.length && profile === "full" && !options.check && !current.has("guardrails.ratchet.json") && manifest.scripts?.["sync:check"] === void 0) {
@@ -1864,7 +1950,7 @@ function syncRepository(root, options = {}) {
1864
1950
  errors,
1865
1951
  notes,
1866
1952
  verifyNotes: options.check || errors.length ? [] : verify.notes,
1867
- advisories: [...entryOnly.advisories, ...checkTypecheckCoverage(root).map((finding) => `Note: ${finding}`)],
1953
+ advisories: [...entryOnly.advisories, ...coverage.advisories],
1868
1954
  dependenciesAdded
1869
1955
  };
1870
1956
  }