@marktiderman/genesis-cli 1.17.3 → 1.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.
Files changed (33) hide show
  1. package/README.md +162 -17
  2. package/dist/cli.js +2099 -747
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-1jP8eCZy.d.ts → config-Dj_f9T7J.d.ts} +14 -1
  5. package/dist/doctor.d.ts +3 -3
  6. package/dist/doctor.js +944 -361
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +2 -2
  9. package/dist/expo.js +18 -0
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +29 -16
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +944 -361
  14. package/dist/index.js.map +1 -1
  15. package/dist/starter/README.md +9 -0
  16. package/dist/starter/__tests__/components/gestures.test.tsx +64 -0
  17. package/dist/starter/__tests__/components/resolver.js +14 -2
  18. package/dist/starter/__tests__/components/setup.ts +5 -0
  19. package/dist/starter/__tests__/starter.test.ts +56 -22
  20. package/dist/starter/genesis.config.json +10 -0
  21. package/dist/starter/jest.config.js +3 -0
  22. package/dist/starter/package.json +2 -0
  23. package/dist/starter/src/lib/link-hosts.ts +12 -0
  24. package/dist/starter/src/lib/links.ts +2 -1
  25. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +7 -2
  26. package/dist/starter/supabase/migrations/20261024000700_genesis_support_findings.sql +339 -0
  27. package/dist/starter/supabase/tests/database/genesis_notifications.test.sql +5 -3
  28. package/dist/starter/supabase/tests/database/genesis_support.test.sql +1 -1
  29. package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +219 -0
  30. package/dist/templates/ci/genesis-upgrade.yml +1 -0
  31. package/dist/vite.js +945 -362
  32. package/dist/vite.js.map +1 -1
  33. package/package.json +3 -3
package/dist/vite.js CHANGED
@@ -1,12 +1,13 @@
1
- import * as path19 from 'path';
1
+ import * as path20 from 'path';
2
2
  import { spawnSync } from 'child_process';
3
3
  import { existsSync, readFileSync, statSync, realpathSync, readdirSync, lstatSync } from 'fs';
4
4
  import { builtinModules, createRequire } from 'module';
5
- import 'crypto';
5
+ import { createHash } from 'crypto';
6
6
  import { FEATURE_PLATFORMS, defineBlock, BlockError } from '@marktiderman/genesis-features/blocks';
7
- import { pathToFileURL } from 'url';
7
+ import { pathToFileURL, fileURLToPath } from 'url';
8
8
  import { overlayUpstream, readOverlayMarker } from '@marktiderman/genesis-features';
9
- import 'jiti';
9
+ import { createJiti } from 'jiti';
10
+ import 'os';
10
11
 
11
12
  var __defProp = Object.defineProperty;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -454,14 +455,14 @@ function inherit(own, source) {
454
455
  }
455
456
  function resolveViews(relations) {
456
457
  const done = /* @__PURE__ */ new Set();
457
- const resolve16 = (relation, depth) => {
458
+ const resolve17 = (relation, depth) => {
458
459
  if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
459
460
  done.add(relation.oid);
460
461
  const sources = new Set([...relation.origins.values()].map((o) => o.relation));
461
462
  if (sources.size !== 1) return;
462
463
  const source = relations.get([...sources][0]);
463
464
  if (!source) return;
464
- resolve16(source, depth + 1);
465
+ resolve17(source, depth + 1);
465
466
  const viewAttnumOf = /* @__PURE__ */ new Map();
466
467
  for (const [attnum, origin] of relation.origins) {
467
468
  const own = relation.columns.get(attnum);
@@ -484,7 +485,7 @@ function resolveViews(relations) {
484
485
  };
485
486
  if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
486
487
  };
487
- for (const relation of relations.values()) resolve16(relation, 0);
488
+ for (const relation of relations.values()) resolve17(relation, 0);
488
489
  }
489
490
  async function introspectPostgres(sql, schemas, options = {}) {
490
491
  const relations = /* @__PURE__ */ new Map();
@@ -720,19 +721,19 @@ var init_introspect = __esm({
720
721
  var BUILD_GUARD_ENV = "GENESIS_DOCTOR_BUILDING";
721
722
  function buildCommands(root, config) {
722
723
  if (config.build) return config.build;
723
- const pkgFile = path19.join(root, "package.json");
724
+ const pkgFile = path20.join(root, "package.json");
724
725
  const scripts = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, "utf8")).scripts ?? {} : {};
725
726
  const pm = packageManager(root);
726
727
  return ["typecheck", "build"].filter((s) => scripts[s]).map((s) => `${pm} run ${s}`);
727
728
  }
728
729
  function packageManager(root) {
729
- let dir = path19.resolve(root);
730
+ let dir = path20.resolve(root);
730
731
  for (; ; ) {
731
- if (existsSync(path19.join(dir, "pnpm-lock.yaml"))) return "pnpm";
732
- if (existsSync(path19.join(dir, "bun.lock")) || existsSync(path19.join(dir, "bun.lockb"))) return "bun";
733
- if (existsSync(path19.join(dir, "yarn.lock"))) return "yarn";
734
- if (existsSync(path19.join(dir, "package-lock.json"))) return "npm";
735
- const parent = path19.dirname(dir);
732
+ if (existsSync(path20.join(dir, "pnpm-lock.yaml"))) return "pnpm";
733
+ if (existsSync(path20.join(dir, "bun.lock")) || existsSync(path20.join(dir, "bun.lockb"))) return "bun";
734
+ if (existsSync(path20.join(dir, "yarn.lock"))) return "yarn";
735
+ if (existsSync(path20.join(dir, "package-lock.json"))) return "npm";
736
+ const parent = path20.dirname(dir);
736
737
  if (parent === dir) return "npm";
737
738
  dir = parent;
738
739
  }
@@ -847,25 +848,25 @@ var PACK_KEYS = {
847
848
  };
848
849
  function appPath(v, where2, fail) {
849
850
  if (typeof v !== "string" || !v.trim()) return fail(`${where2} must be a non-empty path`);
850
- if (path19.isAbsolute(v) || /^[A-Za-z]:[\\/]/.test(v)) fail(`${where2} must be relative to the app, not absolute ("${v}")`);
851
- const norm = path19.posix.normalize(v.replace(/\\/g, "/")).replace(/\/+$/, "");
851
+ if (path20.isAbsolute(v) || /^[A-Za-z]:[\\/]/.test(v)) fail(`${where2} must be relative to the app, not absolute ("${v}")`);
852
+ const norm = path20.posix.normalize(v.replace(/\\/g, "/")).replace(/\/+$/, "");
852
853
  if (norm === "." || norm === ".." || norm.startsWith("../")) fail(`${where2} must be a folder inside the app ("${v}")`);
853
854
  return norm;
854
855
  }
855
856
  function loadConfig(root, configPath) {
856
857
  if (configPath) {
857
- const file = path19.resolve(root, configPath);
858
+ const file = path20.resolve(root, configPath);
858
859
  if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);
859
860
  const json = readJson(file);
860
- const block = path19.basename(file) === "package.json" ? json?.genesis?.doctor : json?.doctor ?? json;
861
- return { config: validateConfig(block ?? {}, file), file, dir: path19.dirname(file) };
861
+ const block = path20.basename(file) === "package.json" ? json?.genesis?.doctor : json?.doctor ?? json;
862
+ return { config: validateConfig(block ?? {}, file), file, dir: path20.dirname(file) };
862
863
  }
863
- const own = path19.join(root, "genesis.config.json");
864
+ const own = path20.join(root, "genesis.config.json");
864
865
  if (existsSync(own)) {
865
866
  const block = readGenesisConfig(root)?.raw.doctor;
866
867
  return { config: validateConfig(block ?? {}, own), file: own, dir: root };
867
868
  }
868
- const pkg = path19.join(root, "package.json");
869
+ const pkg = path20.join(root, "package.json");
869
870
  if (existsSync(pkg)) {
870
871
  const block = readJson(pkg)?.genesis?.doctor;
871
872
  if (block !== void 0 && !isPackageDeclaration(block)) return { config: validateConfig(block, pkg), file: pkg, dir: root };
@@ -874,7 +875,7 @@ function loadConfig(root, configPath) {
874
875
  }
875
876
  function doctorBlock(json, file, explicit) {
876
877
  const j = json;
877
- if (path19.basename(file) === "package.json") return j?.genesis?.doctor;
878
+ if (path20.basename(file) === "package.json") return j?.genesis?.doctor;
878
879
  return explicit ? j?.doctor ?? j : j?.doctor;
879
880
  }
880
881
  function isPackageDeclaration(block) {
@@ -891,15 +892,33 @@ function readJson(file) {
891
892
  }
892
893
  }
893
894
  function readGenesisConfig(root) {
894
- const file = path19.join(root, "genesis.config.json");
895
+ const file = path20.join(root, "genesis.config.json");
895
896
  if (!existsSync(file)) return null;
896
897
  const raw = readJson(file);
897
898
  if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
898
899
  const out = { raw };
899
900
  if (raw.links !== void 0) out.links = validateLinks(raw.links, file);
900
901
  if (raw.privacy !== void 0) out.privacy = validatePrivacy(raw.privacy, file);
902
+ if (raw.supabase !== void 0) {
903
+ const supabase = validateSupabase(raw.supabase, file);
904
+ if (supabase !== true) out.supabase = supabase;
905
+ }
901
906
  return out;
902
907
  }
908
+ function validateSupabase(raw, source = "config") {
909
+ const fail = (msg) => {
910
+ throw new GenesisConfigError(`${source}: ${msg}`);
911
+ };
912
+ if (typeof raw === "boolean") return raw ? true : false;
913
+ if (!isObject(raw)) return fail(`"supabase" must be false or { "app": "<the folder of the app that holds supabase/>" }`);
914
+ for (const key2 of Object.keys(raw)) if (key2 !== "app" && key2 !== "$comment") fail(`supabase: unknown setting "${key2}" (known: app)`);
915
+ const app = raw.app;
916
+ if (typeof app !== "string" || !app.trim()) return fail(`supabase.app must be the folder of the app that holds supabase/, relative to this one (e.g. "../app")`);
917
+ if (path20.isAbsolute(app) || /^[A-Za-z]:[\\/]/.test(app) || app.includes("\\")) fail(`supabase.app must be relative to this app, with forward slashes ("${app}")`);
918
+ const norm = path20.posix.normalize(app).replace(/\/+$/, "");
919
+ if (norm === "." || norm === "") fail(`supabase.app names this app itself; leave "supabase" out instead`);
920
+ return { app: norm };
921
+ }
903
922
  var PRIVACY_KEYS = /* @__PURE__ */ new Set(["blocks", "collects", "tracking"]);
904
923
  var DATA_USE_KEYS = /* @__PURE__ */ new Set(["type", "purposes", "linked", "tracking"]);
905
924
  function validatePrivacy(raw, source = "config") {
@@ -1056,7 +1075,7 @@ function validateConfig(raw, source = "config") {
1056
1075
  if (!(c.packs ?? []).includes("supabase")) fail(`"contracts" is set but the supabase pack is not in "packs"`);
1057
1076
  if (contracts.out !== void 0) {
1058
1077
  if (typeof contracts.out !== "string" || !contracts.out.trim()) fail(`contracts.out must be a file path`);
1059
- if (path19.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1078
+ if (path20.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1060
1079
  }
1061
1080
  if (contracts.schemas !== void 0 && !isStringList(contracts.schemas)) fail(`contracts.schemas must be a list of schema names`);
1062
1081
  if (contracts.databaseEnv !== void 0 && (typeof contracts.databaseEnv !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(contracts.databaseEnv))) {
@@ -1124,7 +1143,7 @@ function globToRegExp(glob) {
1124
1143
  }
1125
1144
  function globMatcher(globs) {
1126
1145
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
1127
- return (path31) => res.some((re) => re.test(path31));
1146
+ return (path40) => res.some((re) => re.test(path40));
1128
1147
  }
1129
1148
  var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
1130
1149
  var NATIVE_UI_PACKAGE = "@marktiderman/genesis-ui-native";
@@ -1164,11 +1183,11 @@ var TAILWIND_PALETTE = [
1164
1183
  "olive"
1165
1184
  ];
1166
1185
  function findPackageDir(from, name) {
1167
- let dir = path19.resolve(from);
1186
+ let dir = path20.resolve(from);
1168
1187
  for (; ; ) {
1169
- const candidate = path19.join(dir, "node_modules", name);
1170
- if (existsSync(path19.join(candidate, "package.json"))) return candidate;
1171
- const parent = path19.dirname(dir);
1188
+ const candidate = path20.join(dir, "node_modules", name);
1189
+ if (existsSync(path20.join(candidate, "package.json"))) return candidate;
1190
+ const parent = path20.dirname(dir);
1172
1191
  if (parent === dir) return null;
1173
1192
  dir = parent;
1174
1193
  }
@@ -1220,7 +1239,7 @@ function loadCompanions(root, config, uiPackage) {
1220
1239
  function readPackageExports(root, uiPackage) {
1221
1240
  const uiDir = findPackageDir(root, uiPackage);
1222
1241
  if (!uiDir) return null;
1223
- const uiPkg = JSON.parse(readFileSync(path19.join(uiDir, "package.json"), "utf8"));
1242
+ const uiPkg = JSON.parse(readFileSync(path20.join(uiDir, "package.json"), "utf8"));
1224
1243
  const subpaths = Object.values(uiPkg.exports ?? {});
1225
1244
  const declared = uiPkg.types ?? uiPkg.typings ?? exportTypes(uiPkg.exports?.["."] ?? uiPkg.exports);
1226
1245
  const fromSource = typeof declared !== "string" && !subpaths.some((t) => typeof exportTypes(t) === "string");
@@ -1247,23 +1266,23 @@ function readPackageExports(root, uiPackage) {
1247
1266
  }
1248
1267
  if (fromSource) {
1249
1268
  for (const m of code.matchAll(/export\s+\*\s+from\s*["'](\.[^"']*)["']/g)) {
1250
- const next = resolveSource(path19.dirname(file), m[1]);
1269
+ const next = resolveSource(path20.dirname(file), m[1]);
1251
1270
  if (next) readEntry(next);
1252
1271
  }
1253
1272
  }
1254
1273
  };
1255
- for (const entry of typeEntries) readEntry(path19.join(uiDir, entry));
1274
+ for (const entry of typeEntries) readEntry(path20.join(uiDir, entry));
1256
1275
  if (!readAny) {
1257
1276
  const what = fromSource ? "type declarations or TypeScript source" : "type declarations";
1258
1277
  throw new DoctorConfigError(`${uiPackage} has no ${what} to read (is it built?). Looked for: ${[...typeEntries].join(", ") || "none"}`);
1259
1278
  }
1260
1279
  const valueDecls = /* @__PURE__ */ new Set();
1261
1280
  const typeDecls = /* @__PURE__ */ new Set();
1262
- const declRoot = typeof mainTypes === "string" ? path19.dirname(path19.join(uiDir, mainTypes)) : uiDir;
1281
+ const declRoot = typeof mainTypes === "string" ? path20.dirname(path20.join(uiDir, mainTypes)) : uiDir;
1263
1282
  const declFiles = fromSource ? walkSource(declRoot) : walkDts(declRoot);
1264
1283
  for (const pkg of reexportedPackages) {
1265
1284
  const dir = findPackageDir(uiDir, pkg);
1266
- if (dir) walkDts(path19.join(dir, "dist"), declFiles);
1285
+ if (dir) walkDts(path20.join(dir, "dist"), declFiles);
1267
1286
  }
1268
1287
  for (const file of declFiles) {
1269
1288
  const text = readFileSync(file, "utf8");
@@ -1313,13 +1332,13 @@ function exportSource(target) {
1313
1332
  return void 0;
1314
1333
  }
1315
1334
  function resolveSource(dir, spec) {
1316
- const base = path19.resolve(dir, spec.replace(/\.js$/, ""));
1317
- const candidates = [base, ...[".ts", ".tsx", ".mts", ".cts"].map((e) => base + e), ...["index.ts", "index.tsx"].map((i) => path19.join(base, i))];
1335
+ const base = path20.resolve(dir, spec.replace(/\.js$/, ""));
1336
+ const candidates = [base, ...[".ts", ".tsx", ".mts", ".cts"].map((e) => base + e), ...["index.ts", "index.tsx"].map((i) => path20.join(base, i))];
1318
1337
  return candidates.find((f) => TS_SOURCE.test(f) && existsSync(f) && statSync(f).isFile()) ?? null;
1319
1338
  }
1320
1339
  function insidePackage(dir, file) {
1321
- const rel = path19.relative(path19.resolve(dir), path19.resolve(file));
1322
- return rel === "" || !rel.startsWith("..") && !path19.isAbsolute(rel);
1340
+ const rel = path20.relative(path20.resolve(dir), path20.resolve(file));
1341
+ return rel === "" || !rel.startsWith("..") && !path20.isAbsolute(rel);
1323
1342
  }
1324
1343
  function stripComments(code) {
1325
1344
  let out = "";
@@ -1355,7 +1374,7 @@ function walkSource(dir, out = []) {
1355
1374
  if (!existsSync(dir)) return out;
1356
1375
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1357
1376
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
1358
- const p = path19.join(dir, entry.name);
1377
+ const p = path20.join(dir, entry.name);
1359
1378
  if (entry.isDirectory()) walkSource(p, out);
1360
1379
  else if (isTsSource(entry.name) || /\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1361
1380
  }
@@ -1375,7 +1394,7 @@ function walkDts(dir, out = []) {
1375
1394
  if (!existsSync(dir)) return out;
1376
1395
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1377
1396
  if (entry.name === "node_modules") continue;
1378
- const p = path19.join(dir, entry.name);
1397
+ const p = path20.join(dir, entry.name);
1379
1398
  if (entry.isDirectory()) walkDts(p, out);
1380
1399
  else if (/\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1381
1400
  }
@@ -1392,27 +1411,27 @@ function resolveThemeFiles(root, config, uiDir) {
1392
1411
  }
1393
1412
  const files = [];
1394
1413
  const ds = findPackageDir(root, DESIGN_SYSTEM_PACKAGE);
1395
- const themes = ds && path19.join(ds, "dist", "themes");
1414
+ const themes = ds && path20.join(ds, "dist", "themes");
1396
1415
  if (themes && existsSync(themes)) {
1397
- for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path19.join(themes, name));
1416
+ for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path20.join(themes, name));
1398
1417
  }
1399
1418
  if (files.length === 0) {
1400
1419
  throw new DoctorConfigError(
1401
1420
  `No Genesis theme stylesheet found (${DESIGN_SYSTEM_PACKAGE}/dist/themes/*.css). Install the design system, or set doctor.themeCss.`
1402
1421
  );
1403
1422
  }
1404
- const uiStyles = path19.join(uiDir, "dist", "styles.css");
1423
+ const uiStyles = path20.join(uiDir, "dist", "styles.css");
1405
1424
  if (existsSync(uiStyles)) files.push(uiStyles);
1406
1425
  return files;
1407
1426
  }
1408
1427
  function resolveSpec(root, spec) {
1409
- const local = path19.resolve(root, spec);
1410
- if (spec.startsWith(".") || path19.isAbsolute(spec)) return existsSync(local) ? local : null;
1428
+ const local = path20.resolve(root, spec);
1429
+ if (spec.startsWith(".") || path20.isAbsolute(spec)) return existsSync(local) ? local : null;
1411
1430
  const parts = spec.split("/");
1412
1431
  const nameLength = spec.startsWith("@") ? 2 : 1;
1413
1432
  const dir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
1414
1433
  if (dir) {
1415
- const file = path19.join(dir, ...parts.slice(nameLength));
1434
+ const file = path20.join(dir, ...parts.slice(nameLength));
1416
1435
  if (existsSync(file) && statSync(file).isFile()) return file;
1417
1436
  }
1418
1437
  return existsSync(local) ? local : null;
@@ -1420,7 +1439,7 @@ function resolveSpec(root, spec) {
1420
1439
  function loadPalette(root) {
1421
1440
  const names = new Set(TAILWIND_PALETTE);
1422
1441
  try {
1423
- const req = createRequire(path19.join(root, "package.json"));
1442
+ const req = createRequire(path20.join(root, "package.json"));
1424
1443
  const colors = req("tailwindcss/colors");
1425
1444
  for (const key2 of Object.keys(colors?.default ?? colors ?? {})) {
1426
1445
  if (/^[a-z]+$/.test(key2) && !["inherit", "current", "transparent"].includes(key2)) names.add(key2);
@@ -1510,6 +1529,26 @@ function parseManifest(home, id, raw, version, options = {}) {
1510
1529
  const file = pathOf(m["file"], `${where2}.file`);
1511
1530
  if (file && !MIGRATION_FILE.test(file.split("/").pop())) problems.push(`${where2}.file: "${file}" must be named NNNN_name.sql (lowercase letters, digits, _)`);
1512
1531
  const out = { package: pkgOf(m["package"], where2), file };
1532
+ if (m["provides"] !== void 0) {
1533
+ if (!Array.isArray(m["provides"])) problems.push(`${where2}.provides: must be a list of { package, file }`);
1534
+ else {
1535
+ out.provides = m["provides"].map((p, j) => {
1536
+ const at2 = `${where2}.provides[${j}]`;
1537
+ if (!isObject2(p)) {
1538
+ problems.push(`${at2}: must be an object`);
1539
+ return { package: home, file: "" };
1540
+ }
1541
+ const provided = { package: pkgOf(p["package"], at2), file: pathOf(p["file"], `${at2}.file`) };
1542
+ if (p["functions"] !== void 0) {
1543
+ if (!Array.isArray(p["functions"])) problems.push(`${at2}.functions: must be a list of function folders`);
1544
+ else provided.functions = p["functions"].map((f, k) => pathOf(f, `${at2}.functions[${k}]`));
1545
+ }
1546
+ if (provided.file && !MIGRATION_FILE.test(provided.file.split("/").pop())) problems.push(`${at2}.file: "${provided.file}" must be named NNNN_name.sql`);
1547
+ if (provided.package === out.package && provided.file === file) problems.push(`${at2}: a migration can't provide itself`);
1548
+ return provided;
1549
+ });
1550
+ }
1551
+ }
1513
1552
  if (m["test"] !== void 0) {
1514
1553
  out.test = pathOf(m["test"], `${where2}.test`);
1515
1554
  if (out.test && !/^[a-z0-9_]+\.test\.sql$/.test(out.test.split("/").pop().replace(/^\d{4}_/, ""))) problems.push(`${where2}.test: "${out.test}" must be named [NNNN_]name.test.sql`);
@@ -1606,11 +1645,52 @@ function rawBlocksOf(packageJson) {
1606
1645
  const blocks = packageJson["genesis"]["blocks"];
1607
1646
  return isObject2(blocks) ? blocks : {};
1608
1647
  }
1648
+ function declarationFields(block) {
1649
+ const c = block.contributes ?? {};
1650
+ return {
1651
+ ...block.requires ? { requires: [...block.requires] } : {},
1652
+ ...block.platforms ? { platforms: [...block.platforms] } : {},
1653
+ ...c.migrations ? { migrations: c.migrations.map((m) => ({ ...m })) } : {},
1654
+ ...c.routes ? { routes: c.routes.map((r) => ({ ...r })) } : {},
1655
+ ...c.skills ? { skills: [...c.skills] } : {},
1656
+ ...c.privacy ? { privacy: c.privacy } : {}
1657
+ };
1658
+ }
1659
+ function isBlockDef(value) {
1660
+ return isObject2(value) && typeof value["id"] === "string" && BLOCK_ID.test(value["id"]) && (value["contributes"] === void 0 || isObject2(value["contributes"])) && (isObject2(value["contributes"]) || Array.isArray(value["requires"]));
1661
+ }
1609
1662
 
1610
1663
  // src/blocks/files.ts
1664
+ var sha256 = (text) => createHash("sha256").update(text).digest("hex");
1611
1665
  function inside(parent, child) {
1612
- const rel = path19.relative(parent, child);
1613
- return rel === "" || !rel.startsWith("..") && !path19.isAbsolute(rel);
1666
+ const rel = path20.relative(parent, child);
1667
+ return rel === "" || !rel.startsWith("..") && !path20.isAbsolute(rel);
1668
+ }
1669
+ function appPath2(root, rel) {
1670
+ const safe = safeRelative(rel.replace(/^\.\//, ""));
1671
+ if (!safe) throw new Error(`"${rel}" is not a plain path inside the app`);
1672
+ if (safe.split("/").some((s) => s.toLowerCase() === ".git")) throw new Error(`"${rel}" is inside .git; refused`);
1673
+ const realRoot = realpathSync(root);
1674
+ const target = path20.join(realRoot, ...safe.split("/"));
1675
+ const there = (p) => {
1676
+ try {
1677
+ lstatSync(p);
1678
+ return true;
1679
+ } catch {
1680
+ return false;
1681
+ }
1682
+ };
1683
+ let probe = path20.dirname(target);
1684
+ while (!there(probe)) probe = path20.dirname(probe);
1685
+ let real2;
1686
+ try {
1687
+ real2 = realpathSync(probe);
1688
+ } catch {
1689
+ throw new Error(`${rel} goes through a broken symlink (${path20.relative(realRoot, probe)}); refused`);
1690
+ }
1691
+ if (!inside(realRoot, real2)) throw new Error(`${rel} is outside the app (a symlinked folder?)`);
1692
+ if (there(target) && lstatSync(target).isSymbolicLink()) throw new Error(`${rel} is a symlink; left alone`);
1693
+ return target;
1614
1694
  }
1615
1695
 
1616
1696
  // src/blocks/local.ts
@@ -1623,8 +1703,8 @@ function validateLocalPackages(raw, source = "genesis.config.json") {
1623
1703
  return raw.map((entry, i) => {
1624
1704
  const where2 = `${source}: ${LOCAL_PACKAGES_KEY}[${i}]`;
1625
1705
  if (typeof entry !== "string" || !entry.trim()) throw new LocalPackagesError(`${where2} must be a non-empty folder`);
1626
- if (path19.isAbsolute(entry) || /^[A-Za-z]:[\\/]/.test(entry)) throw new LocalPackagesError(`${where2} must be relative to the app ("${entry}")`);
1627
- const norm = path19.posix.normalize(entry.replace(/\\/g, "/")).replace(/\/+$/, "");
1706
+ if (path20.isAbsolute(entry) || /^[A-Za-z]:[\\/]/.test(entry)) throw new LocalPackagesError(`${where2} must be relative to the app ("${entry}")`);
1707
+ const norm = path20.posix.normalize(entry.replace(/\\/g, "/")).replace(/\/+$/, "");
1628
1708
  if (norm === "." || /^(\.\.\/)*\.\.$/.test(norm)) throw new LocalPackagesError(`${where2} must name a package folder, not the app or a parent of it ("${entry}")`);
1629
1709
  const parts = norm.split("/");
1630
1710
  if (parts.some((p, k) => p.includes("*") && (p !== "*" || k !== parts.length - 1))) {
@@ -1635,7 +1715,7 @@ function validateLocalPackages(raw, source = "genesis.config.json") {
1635
1715
  });
1636
1716
  }
1637
1717
  function localPackageGlobs(root) {
1638
- const file = path19.join(root, "genesis.config.json");
1718
+ const file = path20.join(root, "genesis.config.json");
1639
1719
  if (!existsSync(file)) return [];
1640
1720
  let raw;
1641
1721
  try {
@@ -1649,14 +1729,14 @@ function localPackageGlobs(root) {
1649
1729
  var cache = /* @__PURE__ */ new Map();
1650
1730
  function repositoryRoot(appRoot) {
1651
1731
  for (let dir = appRoot; ; ) {
1652
- if (existsSync(path19.join(dir, ".git"))) return dir;
1653
- const parent = path19.dirname(dir);
1732
+ if (existsSync(path20.join(dir, ".git"))) return dir;
1733
+ const parent = path20.dirname(dir);
1654
1734
  if (parent === dir) return appRoot;
1655
1735
  dir = parent;
1656
1736
  }
1657
1737
  }
1658
1738
  function localPackages(root) {
1659
- const appRoot = path19.resolve(root);
1739
+ const appRoot = path20.resolve(root);
1660
1740
  const globs = localPackageGlobs(appRoot);
1661
1741
  const key2 = `${appRoot}
1662
1742
  ${globs.join("\n")}`;
@@ -1665,24 +1745,24 @@ ${globs.join("\n")}`;
1665
1745
  const dirs = /* @__PURE__ */ new Set();
1666
1746
  for (const glob of globs) {
1667
1747
  if (glob.endsWith("/*") || glob === "*") {
1668
- const parent = path19.join(appRoot, glob === "*" ? "" : glob.slice(0, -2));
1748
+ const parent = path20.join(appRoot, glob === "*" ? "" : glob.slice(0, -2));
1669
1749
  if (!existsSync(parent) || !statSync(parent).isDirectory()) continue;
1670
1750
  for (const entry of readdirSync(parent).sort()) {
1671
1751
  if (entry.startsWith(".") || entry === "node_modules") continue;
1672
- dirs.add(path19.join(parent, entry));
1752
+ dirs.add(path20.join(parent, entry));
1673
1753
  }
1674
1754
  } else {
1675
- dirs.add(path19.join(appRoot, glob));
1755
+ dirs.add(path20.join(appRoot, glob));
1676
1756
  }
1677
1757
  }
1678
1758
  const real2 = realpathSync(repositoryRoot(appRoot));
1679
1759
  const out = [];
1680
1760
  const byName = /* @__PURE__ */ new Map();
1681
1761
  for (const dir of [...dirs].sort()) {
1682
- const manifest = path19.join(dir, "package.json");
1762
+ const manifest = path20.join(dir, "package.json");
1683
1763
  if (!existsSync(manifest)) continue;
1684
1764
  if (!inside(real2, realpathSync(dir))) {
1685
- throw new LocalPackagesError(`${path19.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
1765
+ throw new LocalPackagesError(`${path20.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
1686
1766
  }
1687
1767
  let pkg;
1688
1768
  try {
@@ -1691,7 +1771,7 @@ ${globs.join("\n")}`;
1691
1771
  continue;
1692
1772
  }
1693
1773
  if (typeof pkg.name !== "string" || !pkg.name) continue;
1694
- const rel = path19.relative(appRoot, dir).split(path19.sep).join("/");
1774
+ const rel = path20.relative(appRoot, dir).split(path20.sep).join("/");
1695
1775
  const other = byName.get(pkg.name);
1696
1776
  if (other) throw new LocalPackagesError(`${other} and ${rel} are both named ${pkg.name}`);
1697
1777
  byName.set(pkg.name, rel);
@@ -1700,6 +1780,9 @@ ${globs.join("\n")}`;
1700
1780
  cache.set(key2, out);
1701
1781
  return out;
1702
1782
  }
1783
+ function localPackageNames(root) {
1784
+ return new Set(localPackages(root).map((p) => p.name));
1785
+ }
1703
1786
 
1704
1787
  // ../../scripts/lib/color-literals.mjs
1705
1788
  var LINE_COMMENT_EXTS = /* @__PURE__ */ new Set([".ts", ".tsx", ".jsx", ".js", ".mjs", ".cjs", ".scss", ".less"]);
@@ -1876,35 +1959,35 @@ var DEFAULT_IGNORE = [
1876
1959
  ];
1877
1960
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", "coverage"]);
1878
1961
  var MAX_FILE_BYTES = 2 * 1024 * 1024;
1879
- var toPosix = (p) => p.split(path19.sep).join("/");
1962
+ var toPosix = (p) => p.split(path20.sep).join("/");
1880
1963
  function scanFiles(root, config) {
1881
1964
  const extensions = new Set(config.extensions ?? DEFAULT_EXTENSIONS);
1882
1965
  const ignored = globMatcher([...DEFAULT_IGNORE, ...config.ignore ?? []]);
1883
1966
  const files = [];
1884
1967
  const seen = /* @__PURE__ */ new Set();
1885
1968
  const visit = (abs) => {
1886
- const rel = toPosix(path19.relative(root, abs));
1969
+ const rel = toPosix(path20.relative(root, abs));
1887
1970
  if (seen.has(rel) || ignored(rel)) return;
1888
- const ext = path19.extname(abs);
1971
+ const ext = path20.extname(abs);
1889
1972
  if (!extensions.has(ext)) return;
1890
1973
  if (statSync(abs).size > MAX_FILE_BYTES) return;
1891
1974
  seen.add(rel);
1892
1975
  const text = readFileSync(abs, "utf8");
1893
1976
  files.push({ path: rel, absolutePath: abs, ext, text, code: stripBlockComments(text, LINE_COMMENT_EXTS.has(ext)) });
1894
1977
  };
1895
- const walk = (dir) => {
1978
+ const walk2 = (dir) => {
1896
1979
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
1897
1980
  if (entry.isDirectory()) {
1898
- if (!SKIP_DIRS.has(entry.name)) walk(path19.join(dir, entry.name));
1981
+ if (!SKIP_DIRS.has(entry.name)) walk2(path20.join(dir, entry.name));
1899
1982
  } else if (entry.isFile()) {
1900
- visit(path19.join(dir, entry.name));
1983
+ visit(path20.join(dir, entry.name));
1901
1984
  }
1902
1985
  }
1903
1986
  };
1904
1987
  for (const src of config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)) {
1905
- const abs = path19.resolve(root, src);
1988
+ const abs = path20.resolve(root, src);
1906
1989
  if (!existsSync(abs)) continue;
1907
- if (statSync(abs).isDirectory()) walk(abs);
1990
+ if (statSync(abs).isDirectory()) walk2(abs);
1908
1991
  else visit(abs);
1909
1992
  }
1910
1993
  let local = [];
@@ -1913,7 +1996,7 @@ function scanFiles(root, config) {
1913
1996
  } catch {
1914
1997
  local = [];
1915
1998
  }
1916
- for (const pkg of local) walk(pkg.dir);
1999
+ for (const pkg of local) walk2(pkg.dir);
1917
2000
  return files;
1918
2001
  }
1919
2002
  function lineAt(text, index) {
@@ -1990,7 +2073,7 @@ function loadPatternRules(root, patterns, rulesDoc) {
1990
2073
  const compiled = compilePatternRules(patterns ?? [], "doctor.patterns");
1991
2074
  let all = compiled;
1992
2075
  if (rulesDoc) {
1993
- const file = path19.resolve(root, rulesDoc);
2076
+ const file = path20.resolve(root, rulesDoc);
1994
2077
  if (!existsSync(file)) throw new DoctorConfigError(`doctor.rulesDoc: ${rulesDoc} not found`);
1995
2078
  const fromDoc = compilePatternRules(parseRulesMarkdown(readFileSync(file, "utf8")), rulesDoc);
1996
2079
  const clash = fromDoc.find((d) => compiled.some((c) => c.rule.id === d.rule.id));
@@ -2048,15 +2131,177 @@ async function loadPlugins(specs, configDir) {
2048
2131
  }
2049
2132
  function resolvePlugin(id, configDir) {
2050
2133
  try {
2051
- if (id.startsWith(".") || path19.isAbsolute(id)) return resolveFrom(path19.resolve(configDir, id), configDir);
2134
+ if (id.startsWith(".") || path20.isAbsolute(id)) return resolveFrom(path20.resolve(configDir, id), configDir);
2052
2135
  return resolveFrom(id, configDir);
2053
2136
  } catch {
2054
2137
  throw new DoctorConfigError(`doctor.plugins: cannot find ${id} (relative paths resolve from ${configDir})`);
2055
2138
  }
2056
2139
  }
2057
2140
  function resolveFrom(id, from) {
2058
- return createRequire(path19.join(from, "noop.js")).resolve(id);
2141
+ return createRequire(path20.join(from, "noop.js")).resolve(id);
2142
+ }
2143
+
2144
+ // src/doctor/semver.ts
2145
+ var VERSION = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
2146
+ function parseVersion(v) {
2147
+ const m = VERSION.exec(v.trim());
2148
+ return m ? { major: +m[1], minor: +m[2], patch: +m[3], pre: m[4] ? m[4].split(".") : [] } : null;
2149
+ }
2150
+ function compareVersions(a, b) {
2151
+ for (const k of ["major", "minor", "patch"]) if (a[k] !== b[k]) return a[k] < b[k] ? -1 : 1;
2152
+ if (!a.pre.length || !b.pre.length) return a.pre.length ? -1 : b.pre.length ? 1 : 0;
2153
+ for (let i = 0; i < Math.max(a.pre.length, b.pre.length); i++) {
2154
+ const x = a.pre[i];
2155
+ const y = b.pre[i];
2156
+ if (x === void 0) return -1;
2157
+ if (y === void 0) return 1;
2158
+ if (x === y) continue;
2159
+ const nx = /^\d+$/.test(x);
2160
+ const ny = /^\d+$/.test(y);
2161
+ if (nx && ny) return +x < +y ? -1 : 1;
2162
+ if (nx !== ny) return nx ? -1 : 1;
2163
+ return x < y ? -1 : 1;
2164
+ }
2165
+ return 0;
2059
2166
  }
2167
+ function partial(s) {
2168
+ const m = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(s);
2169
+ if (!m) return null;
2170
+ const nums = [];
2171
+ let wild = false;
2172
+ for (const part of [m[1], m[2], m[3]]) {
2173
+ if (wild || part === void 0 || /^[xX*]$/.test(part)) {
2174
+ wild = true;
2175
+ nums.push(null);
2176
+ } else nums.push(+part);
2177
+ }
2178
+ return { nums, pre: m[4] && !wild ? m[4].split(".") : [] };
2179
+ }
2180
+ var ver = (major, minor, patch, pre = []) => ({ major, minor, patch, pre });
2181
+ function comparators(token) {
2182
+ const m = /^(\^|~>?|>=|<=|>|<|=)?\s*(.+)$/.exec(token);
2183
+ if (!m) return null;
2184
+ const op = m[1] ?? "";
2185
+ const p = partial(m[2]);
2186
+ if (!p) return null;
2187
+ const [major, mi, pa] = p.nums;
2188
+ if (major === null) return op === "<" || op === ">" ? [{ op: "<", v: ver(0, 0, 0, ["0"]) }] : [];
2189
+ const M = major;
2190
+ const lo = ver(M, mi ?? 0, pa ?? 0, p.pre);
2191
+ const next = (kind) => kind === "major" ? ver(M + 1, 0, 0, ["0"]) : kind === "minor" ? ver(M, (mi ?? 0) + 1, 0, ["0"]) : ver(M, mi ?? 0, (pa ?? 0) + 1, ["0"]);
2192
+ const upper = mi === null ? next("major") : pa === null ? next("minor") : null;
2193
+ const out = switchOp();
2194
+ if (p.pre.length) {
2195
+ for (const c of out) if (c.v === lo) c.pre = true;
2196
+ }
2197
+ return out;
2198
+ function switchOp() {
2199
+ switch (op) {
2200
+ case "^": {
2201
+ const bound = M > 0 || mi === null ? next("major") : (mi ?? 0) > 0 || pa === null ? next("minor") : next("patch");
2202
+ return [
2203
+ { op: ">=", v: lo },
2204
+ { op: "<", v: bound }
2205
+ ];
2206
+ }
2207
+ case "~":
2208
+ case "~>":
2209
+ return [
2210
+ { op: ">=", v: lo },
2211
+ { op: "<", v: mi === null ? next("major") : next("minor") }
2212
+ ];
2213
+ case ">":
2214
+ return upper ? [{ op: ">=", v: upper }] : [{ op: ">", v: lo }];
2215
+ case ">=":
2216
+ return [{ op: ">=", v: lo }];
2217
+ case "<":
2218
+ return [{ op: "<", v: lo.pre.length ? lo : ver(M, mi ?? 0, pa ?? 0, ["0"]) }];
2219
+ case "<=":
2220
+ return upper ? [{ op: "<", v: upper }] : [{ op: "<=", v: lo }];
2221
+ default:
2222
+ return upper ? [
2223
+ { op: ">=", v: lo },
2224
+ { op: "<", v: upper }
2225
+ ] : [{ op: "=", v: lo }];
2226
+ }
2227
+ }
2228
+ }
2229
+ function test(c, v) {
2230
+ const d = compareVersions(v, c.v);
2231
+ return c.op === ">=" ? d >= 0 : c.op === "<=" ? d <= 0 : c.op === ">" ? d > 0 : c.op === "<" ? d < 0 : d === 0;
2232
+ }
2233
+ function parseRange(range) {
2234
+ const alts = [];
2235
+ for (const raw of range.trim().split("||")) {
2236
+ const alt = raw.trim();
2237
+ const hyphen = /^(\S+)\s+-\s+(\S+)$/.exec(alt);
2238
+ if (hyphen) {
2239
+ const from = comparators(`>=${hyphen[1]}`);
2240
+ const to = comparators(`<=${hyphen[2]}`);
2241
+ if (!from || !to) return null;
2242
+ alts.push([...from, ...to]);
2243
+ continue;
2244
+ }
2245
+ const set = [];
2246
+ for (const token of alt.replace(/(\^|~>?|>=|<=|>|<|=)\s+/g, "$1").split(/\s+/).filter(Boolean)) {
2247
+ const cs = comparators(token);
2248
+ if (!cs) return null;
2249
+ set.push(...cs);
2250
+ }
2251
+ alts.push(set);
2252
+ }
2253
+ return alts;
2254
+ }
2255
+ function satisfies(version, range) {
2256
+ const v = parseVersion(version);
2257
+ const alts = parseRange(range);
2258
+ if (!v || !alts) return null;
2259
+ return alts.some(
2260
+ (set) => set.every((c) => test(c, v)) && (!v.pre.length || set.some((c) => c.pre && c.v.major === v.major && c.v.minor === v.minor && c.v.patch === v.patch))
2261
+ );
2262
+ }
2263
+ var UMBRELLA_PACKAGE = "@marktiderman/genesis";
2264
+ function readReleaseManifest(root) {
2265
+ const dir = findPackageDir(root, UMBRELLA_PACKAGE);
2266
+ const file = dir && path20.join(dir, "dist", "versions.json");
2267
+ if (!file || !existsSync(file)) return null;
2268
+ return JSON.parse(readFileSync(file, "utf8"));
2269
+ }
2270
+ function checkVersionSkew(ctx) {
2271
+ const manifest = readReleaseManifest(ctx.root);
2272
+ if (!manifest) return;
2273
+ const overlays = markedOverlays(ctx);
2274
+ for (const [name, want] of Object.entries(manifest.packages)) {
2275
+ const overlay = overlays.get(name);
2276
+ if (overlay) {
2277
+ const from = overlay.marker.upstream.slice(overlay.marker.upstream.lastIndexOf("@") + 1);
2278
+ const behind = parseVersion(from) && parseVersion(want) && compareVersions(parseVersion(from), parseVersion(want)) < 0;
2279
+ if (from !== want && !behind) {
2280
+ ctx.report({
2281
+ rule: "version-skew",
2282
+ level: "warn",
2283
+ file: "package.json",
2284
+ subject: name,
2285
+ message: `the app's overlay of ${name} was copied from ${from}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Bring the overlay onto ${want} (or promote it and adopt the release).`
2286
+ });
2287
+ }
2288
+ continue;
2289
+ }
2290
+ const dir = findPackageDir(ctx.root, name);
2291
+ if (!dir) continue;
2292
+ const have = JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8")).version;
2293
+ if (have === want) continue;
2294
+ ctx.report({
2295
+ rule: "version-skew",
2296
+ level: "warn",
2297
+ file: "package.json",
2298
+ subject: name,
2299
+ message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`
2300
+ });
2301
+ }
2302
+ }
2303
+
2304
+ // src/doctor/overlays.ts
2060
2305
  var GENESIS_PACKAGE_NAME = /^@marktiderman\/genesis(?:-[a-z0-9-]+)?$/;
2061
2306
  var OVERLAY_NOTICE_DAYS = 14;
2062
2307
  var OVERLAY_WARN_DAYS = 30;
@@ -2070,7 +2315,7 @@ function overlayState(name, json) {
2070
2315
  function overlaySetupProblems(root, config, dir, name, json) {
2071
2316
  const problems = [];
2072
2317
  if (json.private !== true) problems.push(`${name}: an overlay is the app's own copy and never publishes; set "private": true`);
2073
- const rel = path19.relative(path19.resolve(root), path19.resolve(dir)).split(path19.sep).join("/");
2318
+ const rel = path20.relative(path20.resolve(root), path20.resolve(dir)).split(path20.sep).join("/");
2074
2319
  const sources = (config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)).map((s) => s.replace(/^\.\//, "").replace(/\/+$/, ""));
2075
2320
  const holds = sources.find((s) => rel === "" || s === rel || s.startsWith(`${rel}/`));
2076
2321
  if (holds !== void 0) problems.push(`${name}: an overlay lives in a package folder of its own, not in ${rel || "the app root"}, which holds the app's source (${holds})`);
@@ -2095,6 +2340,31 @@ function overlayAgeDays(since, now = /* @__PURE__ */ new Date()) {
2095
2340
  return Math.floor((today - Date.UTC(y, m - 1, d)) / 864e5);
2096
2341
  }
2097
2342
  var LOCAL_VERSION = /^(\d+\.\d+\.\d+(?:-(?!local\.)[0-9A-Za-z.-]+?)?)(?:[+-]local\.(?:0|[1-9]\d*))?$/;
2343
+ function pinnedVersion(root, name, manifests = ["package.json"]) {
2344
+ let manifest = null;
2345
+ try {
2346
+ manifest = readReleaseManifest(root);
2347
+ } catch {
2348
+ }
2349
+ const released = manifest?.packages[name];
2350
+ if (released && parseVersion(released)) return released;
2351
+ let best = null;
2352
+ for (const file of manifests) {
2353
+ let json;
2354
+ try {
2355
+ json = JSON.parse(readFileSync(path20.join(root, file), "utf8"));
2356
+ } catch {
2357
+ continue;
2358
+ }
2359
+ for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
2360
+ const spec = json[section]?.[name];
2361
+ const v = typeof spec === "string" ? /^[\^~=]?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/.exec(spec)?.[1] : void 0;
2362
+ const parsed = v && parseVersion(v);
2363
+ if (parsed && (!best || compareVersions(parsed, parseVersion(best)) > 0)) best = v;
2364
+ }
2365
+ }
2366
+ return best;
2367
+ }
2098
2368
  function checkOverlays(ctx, now = /* @__PURE__ */ new Date()) {
2099
2369
  let packages;
2100
2370
  try {
@@ -2107,7 +2377,7 @@ function checkOverlays(ctx, now = /* @__PURE__ */ new Date()) {
2107
2377
  const file = `${pkg.rel}/package.json`;
2108
2378
  let json;
2109
2379
  try {
2110
- json = JSON.parse(readFileSync(path19.join(pkg.dir, "package.json"), "utf8"));
2380
+ json = JSON.parse(readFileSync(path20.join(pkg.dir, "package.json"), "utf8"));
2111
2381
  } catch {
2112
2382
  continue;
2113
2383
  }
@@ -2150,6 +2420,18 @@ function checkOverlays(ctx, now = /* @__PURE__ */ new Date()) {
2150
2420
  message: `the overlay of ${marker.upstream} is version ${version || "(none)"}; use ${upstream}+local.N (or ${upstream} itself) so it reads as a local build of ${upstream} and still satisfies peer ranges`
2151
2421
  });
2152
2422
  }
2423
+ const pinned = pinnedVersion(ctx.root, pkg.name);
2424
+ const from = parseVersion(upstream);
2425
+ const to = pinned ? parseVersion(pinned) : null;
2426
+ if (from && to && compareVersions(from, to) < 0) {
2427
+ ctx.report({
2428
+ rule: "overlay-behind",
2429
+ level: "warn",
2430
+ file,
2431
+ subject: pkg.name,
2432
+ message: `the overlay of ${marker.upstream} is behind ${pkg.name}@${pinned}, the version the app now pins; run genesis upgrade, which rebases the overlay onto it (dropping what Genesis now ships) and moves the marker's upstream, or rebase it by hand`
2433
+ });
2434
+ }
2153
2435
  }
2154
2436
  }
2155
2437
 
@@ -2213,6 +2495,7 @@ var BUILTIN_RULES = [
2213
2495
  "overlay-invalid",
2214
2496
  "overlay-age",
2215
2497
  "overlay-version",
2498
+ "overlay-behind",
2216
2499
  // package rules (package-rules.ts): the rules themselves are namespaced, e.g. ui/lists-use-resource-view
2217
2500
  "package-rules-invalid",
2218
2501
  "package-rule-override",
@@ -2223,7 +2506,11 @@ var BUILTIN_RULES = [
2223
2506
  // agent guide (primitives.ts)
2224
2507
  "agent-guide-stale",
2225
2508
  // supabase pack: contracts (contracts.ts)
2226
- "contracts-stale"
2509
+ "contracts-stale",
2510
+ // genesis.lock.json against the files (lock-files.ts)
2511
+ "lock-files",
2512
+ // an app whose database files live in another app (database.ts)
2513
+ "database-elsewhere"
2227
2514
  ];
2228
2515
  var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
2229
2516
  var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
@@ -2241,7 +2528,7 @@ function importSpecifiers(file) {
2241
2528
  }
2242
2529
  function checkProjectLayout(ctx) {
2243
2530
  for (const dir of ctx.config.localPrimitiveDirs ?? DEFAULT_LOCAL_PRIMITIVE_DIRS) {
2244
- if (existsSync(path19.join(ctx.root, dir))) {
2531
+ if (existsSync(path20.join(ctx.root, dir))) {
2245
2532
  ctx.report({
2246
2533
  rule: "local-primitives",
2247
2534
  file: dir,
@@ -2251,7 +2538,7 @@ function checkProjectLayout(ctx) {
2251
2538
  }
2252
2539
  }
2253
2540
  for (const file of STARTER_LEFTOVERS) {
2254
- if (existsSync(path19.join(ctx.root, file))) {
2541
+ if (existsSync(path20.join(ctx.root, file))) {
2255
2542
  ctx.report({
2256
2543
  rule: "starter-leftover",
2257
2544
  level: "warn",
@@ -2341,7 +2628,7 @@ function checkTokens(ctx) {
2341
2628
  }
2342
2629
  for (const pattern of ctx.config.tokenFiles ?? []) {
2343
2630
  if (/[*?]/.test(pattern)) continue;
2344
- const abs = path19.join(ctx.root, pattern);
2631
+ const abs = path20.join(ctx.root, pattern);
2345
2632
  if (!ctx.files.some((f) => f.absolutePath === abs) && existsSync(abs)) {
2346
2633
  for (const t of declaredTokens(readFileSync(abs, "utf8"))) defined.add(t);
2347
2634
  }
@@ -2441,14 +2728,33 @@ var appFunctionality = (type, ...more) => ({
2441
2728
  function privacyApisFor(dependencies2) {
2442
2729
  return Object.keys(PRIVACY_APIS).filter((pkg) => pkg in dependencies2).flatMap((pkg) => PRIVACY_APIS[pkg]);
2443
2730
  }
2731
+
2732
+ // src/eas-placeholders.ts
2733
+ var EAS_PLACEHOLDERS = {
2734
+ REPLACE_WITH_APP_STORE_CONNECT_APP_ID: "the app's Apple ID from App Store Connect (create the app there, then App Information \u2192 General Information \u2192 Apple ID, a number)",
2735
+ REPLACE_WITH_APPLE_TEAM_ID: "your Apple Developer Team ID (developer.apple.com \u2192 Account \u2192 Membership details, 10 characters)",
2736
+ REPLACE_WITH_PATH_TO_GOOGLE_SERVICE_ACCOUNT_JSON: "the Google Play service account key uploaded to EAS, not a local path (deploy-production.yml submits on EAS, where a local file isn't there): create a Google Cloud service account and its JSON key, invite it in Play Console \u2192 Users and permissions, upload the key with `eas credentials` (Android \u2192 Google Service Account), then remove only this serviceAccountKeyPath line (https://docs.expo.dev/submit/android/). Until you ship to Google Play, remove the submit_android job from deploy-production.yml instead, and keep submit.production.android as it is (the internal track, as a draft)",
2737
+ REPLACE_WITH_APP_FOLDER: "the app's code folder (src, or apps/<name> in a monorepo)"
2738
+ };
2739
+ function placeholderKey(line, placeholder) {
2740
+ return new RegExp(`"([A-Za-z0-9_]+)"\\s*:\\s*"${placeholder}"`).exec(line)?.[1] ?? null;
2741
+ }
2742
+ function findPlaceholders(file, text) {
2743
+ const out = [];
2744
+ text.split("\n").forEach((line, i) => {
2745
+ if (!file.endsWith(".json") && /^\s*#/.test(line)) return;
2746
+ for (const m of line.matchAll(/\bREPLACE_WITH_[A-Z0-9_]+/g)) out.push({ line: i + 1, text: line, placeholder: m[0] });
2747
+ });
2748
+ return out;
2749
+ }
2444
2750
  var SCRIPT_EXTS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
2445
2751
  var JSX_EXTS2 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
2446
2752
  var RESOLVE_EXTS = [".tsx", ".ts", ".jsx", ".js"];
2447
2753
  function resolveLocal(root, fromFile, spec) {
2448
- const bases = spec.startsWith(".") ? [path19.resolve(path19.dirname(fromFile), spec)] : [path19.join(root, spec.slice(2)), path19.join(root, "src", spec.slice(2))];
2754
+ const bases = spec.startsWith(".") ? [path20.resolve(path20.dirname(fromFile), spec)] : [path20.join(root, spec.slice(2)), path20.join(root, "src", spec.slice(2))];
2449
2755
  for (const base of bases) {
2450
- const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path19.join(base, `index${e}`))].find(
2451
- (p) => SCRIPT_EXTS2.has(path19.extname(p)) && existsSync(p)
2756
+ const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path20.join(base, `index${e}`))].find(
2757
+ (p) => SCRIPT_EXTS2.has(path20.extname(p)) && existsSync(p)
2452
2758
  );
2453
2759
  if (hit) return hit;
2454
2760
  }
@@ -2567,29 +2873,26 @@ function checkNativePack(ctx) {
2567
2873
  checkStoreReadiness(ctx);
2568
2874
  checkEasPlaceholders(ctx);
2569
2875
  }
2570
- var EAS_PLACEHOLDER = /\bREPLACE_WITH_[A-Z0-9_]+/g;
2571
2876
  function checkEasPlaceholders(ctx) {
2572
2877
  const files = [];
2573
- if (existsSync(path19.join(ctx.root, "eas.json"))) files.push("eas.json");
2574
- const workflows = path19.join(ctx.root, ".eas", "workflows");
2878
+ if (existsSync(path20.join(ctx.root, "eas.json"))) files.push("eas.json");
2879
+ const workflows = path20.join(ctx.root, ".eas", "workflows");
2575
2880
  if (existsSync(workflows)) {
2576
2881
  for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
2577
2882
  }
2578
2883
  for (const file of files) {
2579
- const lines = readFileSync(path19.join(ctx.root, file), "utf8").split("\n");
2580
- lines.forEach((text, i) => {
2581
- if (!file.endsWith(".json") && /^\s*#/.test(text)) return;
2582
- for (const m of text.matchAll(EAS_PLACEHOLDER)) {
2583
- ctx.report({
2584
- rule: "eas-placeholder",
2585
- level: "warn",
2586
- file,
2587
- line: i + 1,
2588
- subject: m[0],
2589
- message: m[0] === "REPLACE_WITH_APP_FOLDER" ? "still names REPLACE_WITH_APP_FOLDER, so only config changes start a preview; replace it with the app's code folder (src, or apps/<name> in a monorepo)" : `still has the template placeholder ${m[0]}; replace it before the job that reads it runs (see docs/NATIVE-RELEASE.md in the Genesis repository)`
2590
- });
2591
- }
2592
- });
2884
+ for (const hit of findPlaceholders(file, readFileSync(path20.join(ctx.root, file), "utf8"))) {
2885
+ const key2 = placeholderKey(hit.text, hit.placeholder);
2886
+ const what = EAS_PLACEHOLDERS[hit.placeholder];
2887
+ ctx.report({
2888
+ rule: "eas-placeholder",
2889
+ level: "warn",
2890
+ file,
2891
+ line: hit.line,
2892
+ subject: hit.placeholder,
2893
+ message: hit.placeholder === "REPLACE_WITH_APP_FOLDER" ? `still names REPLACE_WITH_APP_FOLDER, so only config changes start a preview; replace it with ${what}` : `${key2 ? `${key2} is` : "still has"} the template placeholder ${hit.placeholder}; replace it with ${what ?? "its value (see docs/NATIVE-RELEASE.md in the Genesis repository)"} before the job that reads it runs`
2894
+ });
2895
+ }
2593
2896
  }
2594
2897
  }
2595
2898
  var RN = String.raw`["']react-native["']`;
@@ -2657,7 +2960,7 @@ function checkCustomHeaders(ctx, pkg) {
2657
2960
  if (!JSX_EXTS3.has(file.ext)) continue;
2658
2961
  const code = file.code;
2659
2962
  const hidden = HIDES_HEADER.exec(code);
2660
- if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path19.posix.dirname(file.path), file.path);
2963
+ if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path20.posix.dirname(file.path), file.path);
2661
2964
  const own = hidden ? ownHeader(code, pkg) : null;
2662
2965
  if (hidden && own) {
2663
2966
  reported.add(file.path);
@@ -2685,7 +2988,7 @@ function checkCustomHeaders(ctx, pkg) {
2685
2988
  }
2686
2989
  for (const file of ctx.files) {
2687
2990
  if (!JSX_EXTS3.has(file.ext) || reported.has(file.path) || !file.path.startsWith(`${rootDir}/`) || NON_SCREEN_ROUTE.test(file.path)) continue;
2688
- const layout = hidingLayouts.get(path19.posix.dirname(file.path));
2991
+ const layout = hidingLayouts.get(path20.posix.dirname(file.path));
2689
2992
  const own = layout ? ownHeader(file.code, pkg) : null;
2690
2993
  if (!layout || !own) continue;
2691
2994
  ctx.report({
@@ -2707,13 +3010,13 @@ function isLoadingOnlyRoute(code) {
2707
3010
  }
2708
3011
  function routerRoot(ctx) {
2709
3012
  if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\/+$/, "");
2710
- return existsSync(path19.join(ctx.root, "src", "app")) ? "src/app" : "app";
3013
+ return existsSync(path20.join(ctx.root, "src", "app")) ? "src/app" : "app";
2711
3014
  }
2712
3015
  function checkScreenLayouts(ctx, pkg) {
2713
3016
  const layouts = nativeLayouts(pkg);
2714
3017
  if (layouts.length === 0) return;
2715
3018
  const rootDir = routerRoot(ctx);
2716
- if (!existsSync(path19.join(ctx.root, rootDir))) {
3019
+ if (!existsSync(path20.join(ctx.root, rootDir))) {
2717
3020
  ctx.report({ rule: "native-screen-layout", level: "warn", file: rootDir, message: `no Expo Router root at ${rootDir}; set doctor.native.routerRoot` });
2718
3021
  return;
2719
3022
  }
@@ -2769,7 +3072,7 @@ var GENESIS_PLUGIN_IMPORT = /\bfrom\s*["']@marktiderman\/genesis-cli[^"']*["']|\
2769
3072
  function readExpoConfigs(root) {
2770
3073
  const out = [];
2771
3074
  for (const name of EXPO_CONFIGS) {
2772
- const abs = path19.join(root, name);
3075
+ const abs = path20.join(root, name);
2773
3076
  if (!existsSync(abs)) continue;
2774
3077
  const text = readFileSync(abs, "utf8");
2775
3078
  let json = null;
@@ -2803,13 +3106,13 @@ function pluginOptions(json, module) {
2803
3106
  return null;
2804
3107
  }
2805
3108
  function dependencies(root) {
2806
- const file = path19.join(root, "package.json");
3109
+ const file = path20.join(root, "package.json");
2807
3110
  if (!existsSync(file)) return /* @__PURE__ */ new Set();
2808
3111
  const pkg = JSON.parse(readFileSync(file, "utf8"));
2809
3112
  return /* @__PURE__ */ new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);
2810
3113
  }
2811
3114
  function runtimeDependencies(root) {
2812
- const file = path19.join(root, "package.json");
3115
+ const file = path20.join(root, "package.json");
2813
3116
  if (!existsSync(file)) return {};
2814
3117
  return JSON.parse(readFileSync(file, "utf8")).dependencies ?? {};
2815
3118
  }
@@ -2890,126 +3193,6 @@ function checkStoreReadiness(ctx) {
2890
3193
  });
2891
3194
  }
2892
3195
  }
2893
-
2894
- // src/doctor/semver.ts
2895
- var VERSION = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
2896
- function parseVersion(v) {
2897
- const m = VERSION.exec(v.trim());
2898
- return m ? { major: +m[1], minor: +m[2], patch: +m[3], pre: m[4] ? m[4].split(".") : [] } : null;
2899
- }
2900
- function compareVersions(a, b) {
2901
- for (const k of ["major", "minor", "patch"]) if (a[k] !== b[k]) return a[k] < b[k] ? -1 : 1;
2902
- if (!a.pre.length || !b.pre.length) return a.pre.length ? -1 : b.pre.length ? 1 : 0;
2903
- for (let i = 0; i < Math.max(a.pre.length, b.pre.length); i++) {
2904
- const x = a.pre[i];
2905
- const y = b.pre[i];
2906
- if (x === void 0) return -1;
2907
- if (y === void 0) return 1;
2908
- if (x === y) continue;
2909
- const nx = /^\d+$/.test(x);
2910
- const ny = /^\d+$/.test(y);
2911
- if (nx && ny) return +x < +y ? -1 : 1;
2912
- if (nx !== ny) return nx ? -1 : 1;
2913
- return x < y ? -1 : 1;
2914
- }
2915
- return 0;
2916
- }
2917
- function partial(s) {
2918
- const m = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(s);
2919
- if (!m) return null;
2920
- const nums = [];
2921
- let wild = false;
2922
- for (const part of [m[1], m[2], m[3]]) {
2923
- if (wild || part === void 0 || /^[xX*]$/.test(part)) {
2924
- wild = true;
2925
- nums.push(null);
2926
- } else nums.push(+part);
2927
- }
2928
- return { nums, pre: m[4] && !wild ? m[4].split(".") : [] };
2929
- }
2930
- var ver = (major, minor, patch, pre = []) => ({ major, minor, patch, pre });
2931
- function comparators(token) {
2932
- const m = /^(\^|~>?|>=|<=|>|<|=)?\s*(.+)$/.exec(token);
2933
- if (!m) return null;
2934
- const op = m[1] ?? "";
2935
- const p = partial(m[2]);
2936
- if (!p) return null;
2937
- const [major, mi, pa] = p.nums;
2938
- if (major === null) return op === "<" || op === ">" ? [{ op: "<", v: ver(0, 0, 0, ["0"]) }] : [];
2939
- const M = major;
2940
- const lo = ver(M, mi ?? 0, pa ?? 0, p.pre);
2941
- const next = (kind) => kind === "major" ? ver(M + 1, 0, 0, ["0"]) : kind === "minor" ? ver(M, (mi ?? 0) + 1, 0, ["0"]) : ver(M, mi ?? 0, (pa ?? 0) + 1, ["0"]);
2942
- const upper = mi === null ? next("major") : pa === null ? next("minor") : null;
2943
- const out = switchOp();
2944
- if (p.pre.length) {
2945
- for (const c of out) if (c.v === lo) c.pre = true;
2946
- }
2947
- return out;
2948
- function switchOp() {
2949
- switch (op) {
2950
- case "^": {
2951
- const bound = M > 0 || mi === null ? next("major") : (mi ?? 0) > 0 || pa === null ? next("minor") : next("patch");
2952
- return [
2953
- { op: ">=", v: lo },
2954
- { op: "<", v: bound }
2955
- ];
2956
- }
2957
- case "~":
2958
- case "~>":
2959
- return [
2960
- { op: ">=", v: lo },
2961
- { op: "<", v: mi === null ? next("major") : next("minor") }
2962
- ];
2963
- case ">":
2964
- return upper ? [{ op: ">=", v: upper }] : [{ op: ">", v: lo }];
2965
- case ">=":
2966
- return [{ op: ">=", v: lo }];
2967
- case "<":
2968
- return [{ op: "<", v: lo.pre.length ? lo : ver(M, mi ?? 0, pa ?? 0, ["0"]) }];
2969
- case "<=":
2970
- return upper ? [{ op: "<", v: upper }] : [{ op: "<=", v: lo }];
2971
- default:
2972
- return upper ? [
2973
- { op: ">=", v: lo },
2974
- { op: "<", v: upper }
2975
- ] : [{ op: "=", v: lo }];
2976
- }
2977
- }
2978
- }
2979
- function test(c, v) {
2980
- const d = compareVersions(v, c.v);
2981
- return c.op === ">=" ? d >= 0 : c.op === "<=" ? d <= 0 : c.op === ">" ? d > 0 : c.op === "<" ? d < 0 : d === 0;
2982
- }
2983
- function parseRange(range) {
2984
- const alts = [];
2985
- for (const raw of range.trim().split("||")) {
2986
- const alt = raw.trim();
2987
- const hyphen = /^(\S+)\s+-\s+(\S+)$/.exec(alt);
2988
- if (hyphen) {
2989
- const from = comparators(`>=${hyphen[1]}`);
2990
- const to = comparators(`<=${hyphen[2]}`);
2991
- if (!from || !to) return null;
2992
- alts.push([...from, ...to]);
2993
- continue;
2994
- }
2995
- const set = [];
2996
- for (const token of alt.replace(/(\^|~>?|>=|<=|>|<|=)\s+/g, "$1").split(/\s+/).filter(Boolean)) {
2997
- const cs = comparators(token);
2998
- if (!cs) return null;
2999
- set.push(...cs);
3000
- }
3001
- alts.push(set);
3002
- }
3003
- return alts;
3004
- }
3005
- function satisfies(version, range) {
3006
- const v = parseVersion(version);
3007
- const alts = parseRange(range);
3008
- if (!v || !alts) return null;
3009
- return alts.some(
3010
- (set) => set.every((c) => test(c, v)) && (!v.pre.length || set.some((c) => c.pre && c.v.major === v.major && c.v.minor === v.minor && c.v.patch === v.patch))
3011
- );
3012
- }
3013
3196
  var TRAIL_DEPTH = 6;
3014
3197
  var RESOLVE_EXTS2 = [".tsx", ".ts", ".jsx", ".js", ".mts", ".mjs"];
3015
3198
  var IMPORT_FROM = /^[ \t]*import\s+(type\s+)?([^;"'`]*?)\s*from\s*["']([^"']+)["']/gm;
@@ -3183,14 +3366,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
3183
3366
  seen.add(file);
3184
3367
  const json = readJsonc(file);
3185
3368
  if (!json) return {};
3186
- const dir = path19.dirname(file);
3369
+ const dir = path20.dirname(file);
3187
3370
  let merged = {};
3188
3371
  const parents = typeof json.extends === "string" ? [json.extends] : Array.isArray(json.extends) ? json.extends : [];
3189
3372
  for (const ext of parents) {
3190
3373
  if (typeof ext !== "string") continue;
3191
3374
  let target = null;
3192
- if (ext.startsWith(".") || path19.isAbsolute(ext)) {
3193
- const abs = path19.resolve(dir, ext);
3375
+ if (ext.startsWith(".") || path20.isAbsolute(ext)) {
3376
+ const abs = path20.resolve(dir, ext);
3194
3377
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
3195
3378
  } else {
3196
3379
  const parts = ext.split("/");
@@ -3198,14 +3381,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
3198
3381
  const pkgDir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
3199
3382
  if (pkgDir) {
3200
3383
  const sub = parts.slice(nameLength).join("/");
3201
- const abs = path19.join(pkgDir, sub || "tsconfig.json");
3384
+ const abs = path20.join(pkgDir, sub || "tsconfig.json");
3202
3385
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
3203
3386
  }
3204
3387
  }
3205
3388
  if (target) merged = { ...merged, ...readTsconfig(root, target, seen) };
3206
3389
  }
3207
3390
  const opts = json.compilerOptions ?? {};
3208
- if (typeof opts.baseUrl === "string") merged.baseUrl = path19.resolve(dir, opts.baseUrl);
3391
+ if (typeof opts.baseUrl === "string") merged.baseUrl = path20.resolve(dir, opts.baseUrl);
3209
3392
  if (opts.paths && typeof opts.paths === "object") {
3210
3393
  merged.paths = opts.paths;
3211
3394
  merged.pathsDir = dir;
@@ -3216,7 +3399,7 @@ function aliases(root) {
3216
3399
  const table = [];
3217
3400
  let baseUrl = null;
3218
3401
  for (const name of ["tsconfig.json", "tsconfig.app.json", "jsconfig.json"]) {
3219
- const file = path19.join(root, name);
3402
+ const file = path20.join(root, name);
3220
3403
  if (!existsSync(file)) continue;
3221
3404
  const config = readTsconfig(root, file);
3222
3405
  baseUrl ??= config.baseUrl ?? null;
@@ -3224,22 +3407,22 @@ function aliases(root) {
3224
3407
  for (const [pattern, targets] of Object.entries(config.paths ?? {})) {
3225
3408
  if (!Array.isArray(targets)) continue;
3226
3409
  const exact = !pattern.endsWith("*");
3227
- table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path19.join(base, String(t).replace(/\*$/, ""))) });
3410
+ table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path20.join(base, String(t).replace(/\*$/, ""))) });
3228
3411
  }
3229
3412
  }
3230
- const pkg = readJsonc(path19.join(root, "package.json"));
3413
+ const pkg = readJsonc(path20.join(root, "package.json"));
3231
3414
  for (const [pattern, target] of Object.entries(pkg?.imports ?? {})) {
3232
3415
  if (typeof target !== "string") continue;
3233
- table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path19.join(root, target.replace(/\*.*$/, ""))] });
3416
+ table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path20.join(root, target.replace(/\*.*$/, ""))] });
3234
3417
  }
3235
- for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path19.join(root, "src") + path19.sep, root + path19.sep] });
3418
+ for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path20.join(root, "src") + path20.sep, root + path20.sep] });
3236
3419
  return { table, baseUrl };
3237
3420
  }
3238
3421
  function resolveFile(base) {
3239
- const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path19.join(base, `index${e}`))];
3422
+ const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path20.join(base, `index${e}`))];
3240
3423
  if (/\.[mc]?js$/.test(base)) tries.push(...[".ts", ".tsx"].map((e) => base.replace(/\.[mc]?js$/, e)));
3241
3424
  for (const p of tries) {
3242
- if (SCRIPT_EXTS2.has(path19.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
3425
+ if (SCRIPT_EXTS2.has(path20.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
3243
3426
  }
3244
3427
  return null;
3245
3428
  }
@@ -3253,7 +3436,7 @@ function createTrail(ctx) {
3253
3436
  const { table, baseUrl } = aliases(ctx.root);
3254
3437
  let declared = null;
3255
3438
  try {
3256
- const pkg = JSON.parse(readFileSync(path19.join(ctx.root, "package.json"), "utf8"));
3439
+ const pkg = JSON.parse(readFileSync(path20.join(ctx.root, "package.json"), "utf8"));
3257
3440
  declared = new Set(["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"].flatMap((k) => Object.keys(pkg[k] ?? {})));
3258
3441
  } catch {
3259
3442
  declared = null;
@@ -3284,17 +3467,17 @@ function createTrail(ctx) {
3284
3467
  if (/^(?:node:|https?:|data:|virtual:)/.test(spec) || /\.(?:css|scss|sass|less|svg|png|jpe?g|gif|webp|json|md|mdx)(?:\?.*)?$/.test(spec)) continue;
3285
3468
  let resolved = null;
3286
3469
  if (spec.startsWith(".")) {
3287
- resolved = resolveFile(path19.resolve(path19.dirname(file.absolutePath), spec));
3470
+ resolved = resolveFile(path20.resolve(path20.dirname(file.absolutePath), spec));
3288
3471
  if (!resolved) lost = true;
3289
3472
  } else {
3290
3473
  const alias = table.find((a) => a.exact ? spec === a.prefix : spec.startsWith(a.prefix));
3291
3474
  if (alias) {
3292
3475
  for (const t of alias.targets) {
3293
- resolved = resolveFile(alias.exact ? t : path19.join(t, spec.slice(alias.prefix.length)));
3476
+ resolved = resolveFile(alias.exact ? t : path20.join(t, spec.slice(alias.prefix.length)));
3294
3477
  if (resolved) break;
3295
3478
  }
3296
3479
  }
3297
- if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path19.join(baseUrl, spec));
3480
+ if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path20.join(baseUrl, spec));
3298
3481
  if (!resolved) {
3299
3482
  const pkg = spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
3300
3483
  if (spec.startsWith("#") || declared && !declared.has(pkg) && !findPackageDir(ctx.root, pkg)) lost = true;
@@ -3365,27 +3548,159 @@ function createTrail(ctx) {
3365
3548
  };
3366
3549
  return { reach: (file, test2, depth = TRAIL_DEPTH) => reach(file, test2, depth, /* @__PURE__ */ new Set())[0] };
3367
3550
  }
3551
+ function buildCatalog(packagesDir) {
3552
+ const packages = {};
3553
+ for (const dir of readdirSync(packagesDir).sort()) {
3554
+ const file = path20.join(packagesDir, dir, "package.json");
3555
+ if (!existsSync(file)) continue;
3556
+ const pkg = JSON.parse(readFileSync(file, "utf8"));
3557
+ if (!pkg.name || !pkg.version || pkg.private || !pkg.name.startsWith("@marktiderman/genesis")) continue;
3558
+ packages[pkg.name] = { version: pkg.version, ...pkg.genesis?.blocks ? { blocks: pkg.genesis.blocks } : {} };
3559
+ }
3560
+ return { packages };
3561
+ }
3368
3562
 
3369
3563
  // src/blocks/discover.ts
3564
+ var CLI_PACKAGE = "@marktiderman/genesis-cli";
3565
+ function cliPackageDir() {
3566
+ let dir = path20.dirname(fileURLToPath(import.meta.url));
3567
+ for (; ; ) {
3568
+ const file = path20.join(dir, "package.json");
3569
+ if (existsSync(file) && JSON.parse(readFileSync(file, "utf8")).name === CLI_PACKAGE) return dir;
3570
+ const parent = path20.dirname(dir);
3571
+ if (parent === dir) throw new Error("Can't find the genesis-cli package folder.");
3572
+ dir = parent;
3573
+ }
3574
+ }
3575
+ function workspacePackagesDir() {
3576
+ const dir = path20.resolve(cliPackageDir(), "..");
3577
+ return existsSync(path20.join(dir, "features", "package.json")) && existsSync(path20.join(dir, "..", "pnpm-workspace.yaml")) ? dir : null;
3578
+ }
3579
+ var catalogCache;
3580
+ function readCatalog() {
3581
+ if (catalogCache) return catalogCache;
3582
+ const workspace = workspacePackagesDir();
3583
+ if (workspace) return catalogCache = buildCatalog(workspace);
3584
+ const file = path20.join(cliPackageDir(), "dist", "genesis-catalog.json");
3585
+ catalogCache = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { packages: {} };
3586
+ return catalogCache;
3587
+ }
3370
3588
  var INSTALL_ROOT_MARKERS = [".git", "pnpm-lock.yaml", "pnpm-workspace.yaml", "bun.lock", "bun.lockb", "yarn.lock", "package-lock.json"];
3371
3589
  function installedGenesis(root) {
3372
3590
  const found = /* @__PURE__ */ new Map();
3373
- let dir = path19.resolve(root);
3591
+ let dir = path20.resolve(root);
3374
3592
  for (; ; ) {
3375
- const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path19.join(dir, m)));
3376
- const scope = path19.join(dir, "node_modules", "@marktiderman");
3593
+ const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path20.join(dir, m)));
3594
+ const scope = path20.join(dir, "node_modules", "@marktiderman");
3377
3595
  if (existsSync(scope)) {
3378
3596
  for (const entry of readdirSync(scope)) {
3379
3597
  const name = `@marktiderman/${entry}`;
3380
3598
  if (!GENESIS_PACKAGE.test(name) || found.has(name)) continue;
3381
- if (existsSync(path19.join(scope, entry, "package.json"))) found.set(name, path19.join(scope, entry));
3599
+ if (existsSync(path20.join(scope, entry, "package.json"))) found.set(name, path20.join(scope, entry));
3382
3600
  }
3383
3601
  }
3384
- const parent = path19.dirname(dir);
3602
+ const parent = path20.dirname(dir);
3385
3603
  if (atInstallRoot || parent === dir) return found;
3386
3604
  dir = parent;
3387
3605
  }
3388
3606
  }
3607
+ var declarationCache = /* @__PURE__ */ new Map();
3608
+ function declarationsOf(dir, warnings) {
3609
+ const pkg = JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8"));
3610
+ const key2 = `${realpathSync(dir)}@${pkg.version ?? ""}`;
3611
+ let cached = declarationCache.get(key2);
3612
+ if (!cached) {
3613
+ cached = loadDeclarations(dir, warnings);
3614
+ declarationCache.set(key2, cached);
3615
+ }
3616
+ return cached;
3617
+ }
3618
+ async function loadDeclarations(dir, warnings) {
3619
+ const pkg = JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8"));
3620
+ const entry = pkg.exports?.["./blocks"];
3621
+ const target = typeof entry === "string" ? entry : entry && typeof entry === "object" ? entry["import"] ?? entry["default"] : void 0;
3622
+ if (typeof target !== "string") return {};
3623
+ const rel = safeRelative(target.replace(/^\.\//, ""));
3624
+ const file = rel && path20.join(dir, ...rel.split("/"));
3625
+ if (!file || !inside(dir, file) || !existsSync(file)) return {};
3626
+ try {
3627
+ const jiti = createJiti(path20.join(dir, "package.json"), { moduleCache: false });
3628
+ const mod = await jiti.import(file);
3629
+ const out = {};
3630
+ for (const value of Object.values(mod)) if (isBlockDef(value)) out[value.id] = declarationFields(value);
3631
+ return out;
3632
+ } catch (err) {
3633
+ warnings.push(`${pkg.name}/blocks didn't load in Node (${err instanceof Error ? err.message.split("\n")[0] : String(err)}); using its package.json manifest only.`);
3634
+ return {};
3635
+ }
3636
+ }
3637
+ async function blocksOfInstalled(dir, warnings = [], options = {}) {
3638
+ const pkg = JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8"));
3639
+ const raw = rawBlocksOf(pkg);
3640
+ const declared = await declarationsOf(dir, warnings);
3641
+ const ids = /* @__PURE__ */ new Set([...Object.keys(raw), ...Object.keys(declared)]);
3642
+ const out = [];
3643
+ for (const id of [...ids].sort()) {
3644
+ const fromJson = raw[id] ?? {};
3645
+ const merged = { ...fromJson, ...declared[id] };
3646
+ if (declared[id]?.["migrations"] && Array.isArray(fromJson["migrations"])) merged["migrations"] = withProvides(declared[id]["migrations"], fromJson["migrations"]);
3647
+ const manifest = tryParse(() => parseManifest(pkg.name, id, merged, pkg.version, options), warnings);
3648
+ if (manifest) out.push(manifest);
3649
+ }
3650
+ return out;
3651
+ }
3652
+ function withProvides(declared, json) {
3653
+ if (!Array.isArray(declared)) return declared;
3654
+ const fileOf = (m) => m && typeof m === "object" ? m["file"] : void 0;
3655
+ return declared.map((m) => {
3656
+ const same = json.find((j) => fileOf(j) === fileOf(m));
3657
+ return same?.["provides"] !== void 0 && m && typeof m === "object" && !("provides" in m) ? { ...m, provides: same["provides"] } : m;
3658
+ });
3659
+ }
3660
+ async function allBlocks(root, warnings = []) {
3661
+ const out = [];
3662
+ for (const local of localPackages(root)) {
3663
+ for (const manifest of await blocksOfInstalled(local.dir, warnings, { local: true })) out.push({ manifest, from: "local" });
3664
+ }
3665
+ const installed = installedGenesis(root);
3666
+ for (const [, dir] of installed) for (const manifest of await blocksOfInstalled(dir, warnings)) out.push({ manifest, from: "installed" });
3667
+ for (const [name, entry] of Object.entries(readCatalog().packages)) {
3668
+ if (installed.has(name)) continue;
3669
+ for (const [id, raw] of Object.entries(entry.blocks ?? {})) {
3670
+ const manifest = tryParse(() => parseManifest(name, id, raw, entry.version), warnings);
3671
+ if (manifest) out.push({ manifest, from: "catalog" });
3672
+ }
3673
+ }
3674
+ return out;
3675
+ }
3676
+ function tryParse(parse2, warnings) {
3677
+ try {
3678
+ return parse2();
3679
+ } catch (err) {
3680
+ if (!(err instanceof ManifestError)) throw err;
3681
+ warnings.push(err.message);
3682
+ return null;
3683
+ }
3684
+ }
3685
+ function catalogBlocks(warnings = []) {
3686
+ const out = [];
3687
+ for (const [name, entry] of Object.entries(readCatalog().packages)) {
3688
+ for (const [id, raw] of Object.entries(entry.blocks ?? {})) {
3689
+ const manifest = tryParse(() => parseManifest(name, id, raw, entry.version), warnings);
3690
+ if (manifest) out.push(manifest);
3691
+ }
3692
+ }
3693
+ return out;
3694
+ }
3695
+ async function findBlock(root, id, options = {}) {
3696
+ const all = (await allBlocks(root, options.warnings)).filter((b) => b.manifest.id === id && (!options.package || b.manifest.package === options.package));
3697
+ if (all.length === 0) {
3698
+ const known = [...new Set((await allBlocks(root)).map((b) => b.manifest.id))].sort();
3699
+ throw new Error(`No Genesis or local package declares a block "${id}"${options.package ? ` in ${options.package}` : ""}. Known blocks: ${known.join(", ") || "none"}.`);
3700
+ }
3701
+ if (all.length > 1) throw new Error(`"${id}" is declared by ${all.map((b) => b.manifest.package).join(" and ")}; pass --package to pick one.`);
3702
+ return all[0];
3703
+ }
3389
3704
  var ROUTES_DIR_CANDIDATES = ["src/routes", "src/app", "app", "src/pages", "pages"];
3390
3705
  var STEMS = {
3391
3706
  tanstack: { layout: /* @__PURE__ */ new Set(["route", "__root"]), index: /* @__PURE__ */ new Set(["index"]), skip: /^$/ },
@@ -3403,7 +3718,7 @@ var RENDERS_OUTLET = (code) => /<Outlet(?=[\s>/])/.test(code);
3403
3718
  var OWN_CONTENT = /(?<![=-])>\s*[A-Za-z][^<>{}]*</.source + "|" + /(?<![\w$.])<(?:h[1-6]|ul|ol|table|dl|H[1-6]|[A-Z]\w*(?:Heading|Title|Table|List|Grid))(?=[\s>/])/.source;
3404
3719
  function routesDir(ctx) {
3405
3720
  if (ctx.config.routesDir) return ctx.config.routesDir;
3406
- return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path19.join(ctx.root, d))) ?? null;
3721
+ return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path20.join(ctx.root, d))) ?? null;
3407
3722
  }
3408
3723
  var key = (segments) => segments.map((s) => s.replace(/_$/, "")).join("/");
3409
3724
  function flavorOf(dir, rels) {
@@ -3538,7 +3853,7 @@ function validateDeclaration(raw, packageName3, packageDir, ignored) {
3538
3853
  });
3539
3854
  if (typeof raw === "string") {
3540
3855
  if (!packageDir) fail(`points at ${raw}, but the package folder is unknown`);
3541
- const file = path19.resolve(packageDir, raw);
3856
+ const file = path20.resolve(packageDir, raw);
3542
3857
  if (!inside(packageDir, file)) fail(`points outside the package (${raw})`);
3543
3858
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
3544
3859
  let parsed;
@@ -3587,7 +3902,7 @@ function validateDeclaration(raw, packageName3, packageDir, ignored) {
3587
3902
  if (typeof c.plugin === "string") {
3588
3903
  if (!packageDir) plugin = c.plugin;
3589
3904
  else {
3590
- plugin = path19.resolve(packageDir, c.plugin);
3905
+ plugin = path20.resolve(packageDir, c.plugin);
3591
3906
  if (!inside(packageDir, plugin)) fail(`plugin points outside the package (${c.plugin})`);
3592
3907
  }
3593
3908
  }
@@ -3637,7 +3952,7 @@ function checkPattern(v, where2, fail) {
3637
3952
  }
3638
3953
  var discoveryCache = /* @__PURE__ */ new Map();
3639
3954
  function readDeclaringPackage(dir, local) {
3640
- const file = path19.join(dir, "package.json");
3955
+ const file = path20.join(dir, "package.json");
3641
3956
  let stamp;
3642
3957
  let real2;
3643
3958
  try {
@@ -3660,7 +3975,7 @@ ${local}`;
3660
3975
  const pkg = {
3661
3976
  name: json.name,
3662
3977
  version: typeof json.version === "string" ? json.version : "0.0.0",
3663
- dir: path19.resolve(dir),
3978
+ dir: path20.resolve(dir),
3664
3979
  namespace: ruleNamespace(json.name),
3665
3980
  local,
3666
3981
  private: json.private === true,
@@ -3674,7 +3989,7 @@ ${local}`;
3674
3989
  if (raw !== void 0) {
3675
3990
  const ignored = [];
3676
3991
  try {
3677
- pkg.declaration = validateDeclaration(raw, json.name, path19.resolve(dir), ignored);
3992
+ pkg.declaration = validateDeclaration(raw, json.name, path20.resolve(dir), ignored);
3678
3993
  if (ignored.length) pkg.ignored = ignored;
3679
3994
  } catch (err) {
3680
3995
  pkg.error = err.message;
@@ -3693,14 +4008,14 @@ function discoverPackages(root) {
3693
4008
  for (const dir of installed) {
3694
4009
  let scope;
3695
4010
  try {
3696
- scope = path19.dirname(realpathSync(dir));
4011
+ scope = path20.dirname(realpathSync(dir));
3697
4012
  } catch {
3698
4013
  continue;
3699
4014
  }
3700
- if (path19.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
4015
+ if (path20.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
3701
4016
  for (const entry of readdirSync(scope)) {
3702
4017
  if (byName.has(`@marktiderman/${entry}`) || !GENESIS.test(`@marktiderman/${entry}`)) continue;
3703
- const pkg = readDeclaringPackage(path19.join(scope, entry), false);
4018
+ const pkg = readDeclaringPackage(path20.join(scope, entry), false);
3704
4019
  if (pkg) byName.set(pkg.name, pkg);
3705
4020
  }
3706
4021
  }
@@ -3884,10 +4199,10 @@ var IMPORT = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["']([
3884
4199
  var TYPE_ONLY = /\b(?:import|export)\s+type\s+(?:\{[^}]*\}|\*\s+as\s+[\w$]+|\*|[\w$]+)\s*from\s*["'][^"']+["']/g;
3885
4200
  function sourceFiles(dir, rel = "") {
3886
4201
  const out = [];
3887
- for (const entry of readdirSync(path19.join(dir, rel)).sort()) {
4202
+ for (const entry of readdirSync(path20.join(dir, rel)).sort()) {
3888
4203
  if (entry.startsWith(".") || SKIP_DIRS2.has(entry)) continue;
3889
4204
  const child = rel ? `${rel}/${entry}` : entry;
3890
- const stat = lstatSync(path19.join(dir, child));
4205
+ const stat = lstatSync(path20.join(dir, child));
3891
4206
  if (stat.isSymbolicLink()) continue;
3892
4207
  if (stat.isDirectory()) out.push(...sourceFiles(dir, child));
3893
4208
  else if (SOURCE.test(entry) && !entry.endsWith(".d.ts")) out.push(child);
@@ -3910,13 +4225,13 @@ function matchPattern(pattern, spec) {
3910
4225
  return spec.startsWith(head) && spec.endsWith(tail) && spec.length >= head.length + tail.length ? spec.slice(head.length, spec.length - tail.length) : null;
3911
4226
  }
3912
4227
  function tsconfigPaths(dir) {
3913
- const file = path19.join(dir, "tsconfig.json");
4228
+ const file = path20.join(dir, "tsconfig.json");
3914
4229
  if (!existsSync(file)) return [];
3915
4230
  try {
3916
4231
  const text = readFileSync(file, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[\s{,[])\/\/[^\n]*/g, "$1").replace(/,(\s*[}\]])/g, "$1");
3917
4232
  const options = JSON.parse(text).compilerOptions ?? {};
3918
- const base = path19.resolve(dir, options.baseUrl ?? ".");
3919
- return Object.entries(options.paths ?? {}).map(([pattern, targets]) => ({ pattern, targets: targets.map((t) => path19.resolve(base, t)) }));
4233
+ const base = path20.resolve(dir, options.baseUrl ?? ".");
4234
+ return Object.entries(options.paths ?? {}).map(([pattern, targets]) => ({ pattern, targets: targets.map((t) => path20.resolve(base, t)) }));
3920
4235
  } catch {
3921
4236
  return [];
3922
4237
  }
@@ -3930,8 +4245,8 @@ function checkImports2(ctx, pkg, json) {
3930
4245
  const hit = matchPattern(pattern, spec);
3931
4246
  if (hit === null) continue;
3932
4247
  return targets.some((t) => {
3933
- const rel = path19.relative(pkg.dir, t.replace("*", hit));
3934
- return !rel.startsWith("..") && !path19.isAbsolute(rel);
4248
+ const rel = path20.relative(pkg.dir, t.replace("*", hit));
4249
+ return !rel.startsWith("..") && !path20.isAbsolute(rel);
3935
4250
  });
3936
4251
  }
3937
4252
  return null;
@@ -3944,7 +4259,7 @@ function checkImports2(ctx, pkg, json) {
3944
4259
  ...Object.keys(json.optionalDependencies ?? {})
3945
4260
  ]);
3946
4261
  for (const file of sourceFiles(pkg.dir)) {
3947
- const code = stripForImports(readFileSync(path19.join(pkg.dir, file), "utf8"));
4262
+ const code = stripForImports(readFileSync(path20.join(pkg.dir, file), "utf8"));
3948
4263
  if (code === null) continue;
3949
4264
  const at = `${pkg.rel}/${file}`;
3950
4265
  const typeOnly = [...code.matchAll(TYPE_ONLY)].map((m) => [m.index, m.index + m[0].length]);
@@ -3969,9 +4284,9 @@ function checkImports2(ctx, pkg, json) {
3969
4284
  continue;
3970
4285
  }
3971
4286
  if (spec.startsWith(".")) {
3972
- const target = path19.resolve(pkg.dir, path19.dirname(file), spec);
3973
- const rel = path19.relative(pkg.dir, target);
3974
- if (rel.startsWith("..") || path19.isAbsolute(rel)) {
4287
+ const target = path20.resolve(pkg.dir, path20.dirname(file), spec);
4288
+ const rel = path20.relative(pkg.dir, target);
4289
+ if (rel.startsWith("..") || path20.isAbsolute(rel)) {
3975
4290
  ctx.report({ rule: "package-app-import", file: at, line, subject: spec, message: `${pkg.name} reaches outside its folder (${spec}); move what it needs into the package or a dependency` });
3976
4291
  }
3977
4292
  continue;
@@ -4008,12 +4323,12 @@ function checkMigrations(ctx, pkg, json, locals) {
4008
4323
  const from = own ? "" : ` (in ${m.package})`;
4009
4324
  if (typeof m.file === "string" && typeof m.test !== "string") {
4010
4325
  ctx.report({ rule: "package-migration-test", file: `${pkg.rel}/package.json`, subject: m.file, message: `${pkg.name} block ${id}: ${m.file}${from} has no pgTAP test; declare one as "test" beside it` });
4011
- } else if (typeof m.test === "string" && !existsSync(path19.join(home, m.test))) {
4326
+ } else if (typeof m.test === "string" && !existsSync(path20.join(home, m.test))) {
4012
4327
  ctx.report({ rule: "package-migration-test", file: `${pkg.rel}/package.json`, subject: m.test, message: `${pkg.name} block ${id}: its test ${m.test}${from} doesn't exist` });
4013
4328
  }
4014
4329
  }
4015
4330
  }
4016
- const dir = path19.join(pkg.dir, "migrations");
4331
+ const dir = path20.join(pkg.dir, "migrations");
4017
4332
  if (!existsSync(dir)) return;
4018
4333
  const seen = /* @__PURE__ */ new Map();
4019
4334
  for (const name of readdirSync(dir).sort()) {
@@ -4022,21 +4337,21 @@ function checkMigrations(ctx, pkg, json, locals) {
4022
4337
  const other = seen.get(m[1]);
4023
4338
  if (other) ctx.report({ rule: "package-migration-number", file: `${pkg.rel}/migrations/${name}`, subject: m[1], message: `${pkg.name}: ${name} and ${other} share the number ${m[1]}; give each migration its own` });
4024
4339
  else seen.set(m[1], name);
4025
- if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path19.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
4340
+ if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path20.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
4026
4341
  ctx.report({ rule: "package-migration-test", file: `${pkg.rel}/migrations/${name}`, subject: name, message: `${pkg.name}: ${name} has no pgTAP test (migrations/tests/${name.replace(/\.sql$/, ".test.sql")})` });
4027
4342
  }
4028
4343
  }
4029
4344
  }
4030
4345
  function checkExports(ctx, pkg, json) {
4031
4346
  const targets = [];
4032
- const walk = (v) => {
4347
+ const walk2 = (v) => {
4033
4348
  if (typeof v === "string") targets.push(v);
4034
- else if (v && typeof v === "object") for (const x of Object.values(v)) walk(x);
4349
+ else if (v && typeof v === "object") for (const x of Object.values(v)) walk2(x);
4035
4350
  };
4036
- walk(json.exports);
4351
+ walk2(json.exports);
4037
4352
  for (const t of targets) {
4038
4353
  if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
4039
- if (!existsSync(path19.join(pkg.dir, t))) {
4354
+ if (!existsSync(path20.join(pkg.dir, t))) {
4040
4355
  ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
4041
4356
  }
4042
4357
  }
@@ -4054,11 +4369,11 @@ function checkBlocks(ctx, pkg, json) {
4054
4369
  function checkTaggedTests(ctx, pkg) {
4055
4370
  const tests = sourceFiles(pkg.dir).filter((f) => /\.(test|spec)\.[cm]?[jt]sx?$/.test(f));
4056
4371
  if (!tests.length) return;
4057
- const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path19.join(pkg.dir, f), "utf8")));
4372
+ const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path20.join(pkg.dir, f), "utf8")));
4058
4373
  if (!tagged) ctx.report({ rule: "package-untagged-tests", level: "warn", file: pkg.rel, message: `${pkg.name}'s tests name no feature; tag them with // @feat:<feature id>` });
4059
4374
  }
4060
4375
  function checkRegistered(ctx, pkg) {
4061
- const file = path19.join(ctx.root, "features.json");
4376
+ const file = path20.join(ctx.root, "features.json");
4062
4377
  if (!existsSync(file)) return;
4063
4378
  let doc;
4064
4379
  try {
@@ -4068,7 +4383,7 @@ function checkRegistered(ctx, pkg) {
4068
4383
  }
4069
4384
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
4070
4385
  const forms = /* @__PURE__ */ new Set([pkg.rel]);
4071
- if (top) forms.add(path19.relative(top, realpathSync(pkg.dir)).split(path19.sep).join("/"));
4386
+ if (top) forms.add(path20.relative(top, realpathSync(pkg.dir)).split(path20.sep).join("/"));
4072
4387
  const covered = (doc.features ?? []).some(
4073
4388
  (f) => (f.links?.code ?? []).some((c) => {
4074
4389
  const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
@@ -4098,8 +4413,8 @@ function mergeBaseOf(root, base) {
4098
4413
  function checkChanges(ctx, pkg, json, base, mergeBase) {
4099
4414
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
4100
4415
  if (!top) return;
4101
- const appRelative = (fromTop) => path19.relative(realpathSync(ctx.root), path19.join(top, fromTop)).split(path19.sep).join("/");
4102
- const inRepo = path19.relative(top, realpathSync(pkg.dir)).split(path19.sep).join("/");
4416
+ const appRelative = (fromTop) => path20.relative(realpathSync(ctx.root), path20.join(top, fromTop)).split(path20.sep).join("/");
4417
+ const inRepo = path20.relative(top, realpathSync(pkg.dir)).split(path20.sep).join("/");
4103
4418
  const diff = (git(top, ["diff", "--name-status", "-M", mergeBase, "--", inRepo]) ?? "").split("\n").filter(Boolean).map((row) => row.split(" ").map((cell2, i) => i === 0 ? cell2 : appRelative(cell2)).join(" ")).join("\n");
4104
4419
  const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
4105
4420
  const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
@@ -4122,11 +4437,11 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
4122
4437
  const now = typeof json.version === "string" ? parseVersion(json.version) : null;
4123
4438
  const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
4124
4439
  const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
4125
- const changesets = top ? (git(top, ["diff", "--name-only", "--diff-filter=A", mergeBase, "--", ".changeset"]) ?? "").split("\n").concat((git(top, ["ls-files", "--others", "--exclude-standard", "--", ".changeset"]) ?? "").split("\n")).filter((f) => f.endsWith(".md")).map((f) => path19.join(top, f)) : [];
4440
+ const changesets = top ? (git(top, ["diff", "--name-only", "--diff-filter=A", mergeBase, "--", ".changeset"]) ?? "").split("\n").concat((git(top, ["ls-files", "--others", "--exclude-standard", "--", ".changeset"]) ?? "").split("\n")).filter((f) => f.endsWith(".md")).map((f) => path20.join(top, f)) : [];
4126
4441
  const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
4127
4442
  const named = naming.length > 0;
4128
4443
  if (named && !naming.some((p) => /^Features:\s*\S/m.test(readFileSync(p, "utf8")))) {
4129
- ctx.report({ rule: "package-unversioned-change", level: "warn", file: path19.relative(realpathSync(ctx.root), naming[0]), message: `the changeset for ${pkg.name} has no "Features:" line; name the features it changes` });
4444
+ ctx.report({ rule: "package-unversioned-change", level: "warn", file: path20.relative(realpathSync(ctx.root), naming[0]), message: `the changeset for ${pkg.name} has no "Features:" line; name the features it changes` });
4130
4445
  }
4131
4446
  let jsonBefore = null;
4132
4447
  try {
@@ -4136,7 +4451,7 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
4136
4451
  }
4137
4452
  const raw = json;
4138
4453
  if (jsonBefore && (JSON.stringify(jsonBefore.genesis) !== JSON.stringify(raw.genesis) || JSON.stringify(jsonBefore.exports) !== JSON.stringify(raw.exports))) {
4139
- const appInRepo = path19.relative(top, realpathSync(ctx.root)).split(path19.sep).join("/");
4454
+ const appInRepo = path20.relative(top, realpathSync(ctx.root)).split(path20.sep).join("/");
4140
4455
  const candidates = [.../* @__PURE__ */ new Set(["features.ts", "src/features.ts", ...appInRepo ? [`${appInRepo}/features.ts`, `${appInRepo}/src/features.ts`] : []])];
4141
4456
  const registry = (git(top, ["diff", "--name-only", mergeBase, "--", ...candidates]) ?? "").trim();
4142
4457
  if (!registry) ctx.report({ rule: "package-unversioned-change", level: "warn", file: `${pkg.rel}/package.json`, message: `${pkg.name}'s blocks or exports changed but features.ts didn't; update the features they belong to` });
@@ -4188,7 +4503,7 @@ function checkPackagesPack(ctx) {
4188
4503
  ctx.report({ rule: "package-unversioned-change", level: base ? "warn" : "info", file: "genesis.config.json", message: `change gate skipped: ${merge.reason}` });
4189
4504
  }
4190
4505
  for (const pkg of packages) {
4191
- const json = JSON.parse(readFileSync(path19.join(pkg.dir, "package.json"), "utf8"));
4506
+ const json = JSON.parse(readFileSync(path20.join(pkg.dir, "package.json"), "utf8"));
4192
4507
  checkImports2(ctx, pkg, json);
4193
4508
  checkExports(ctx, pkg, json);
4194
4509
  checkBlocks(ctx, pkg, json);
@@ -4200,6 +4515,45 @@ function checkPackagesPack(ctx) {
4200
4515
  if (base && "sha" in merge && !overlay) checkChanges(ctx, pkg, json, base, merge.sha);
4201
4516
  }
4202
4517
  }
4518
+ var LOCK_FILE = "genesis.lock.json";
4519
+ function emptyLock() {
4520
+ return { version: 1, blocks: {}, files: {} };
4521
+ }
4522
+ function readLock(root) {
4523
+ const file = path20.join(root, LOCK_FILE);
4524
+ if (!existsSync(file)) return emptyLock();
4525
+ const raw = JSON.parse(readFileSync(file, "utf8"));
4526
+ if (raw.version !== 1) throw new Error(`${LOCK_FILE} has version ${String(raw.version)}; this CLI reads version 1.`);
4527
+ return {
4528
+ version: 1,
4529
+ ...raw.substitutions ? { substitutions: raw.substitutions } : {},
4530
+ blocks: raw.blocks ?? {},
4531
+ files: raw.files ?? {},
4532
+ ...raw.migrations ? { migrations: raw.migrations } : {}
4533
+ };
4534
+ }
4535
+ function parseSource(source) {
4536
+ const at = source.indexOf(":");
4537
+ if (at < 1) throw new Error(`${LOCK_FILE}: "${source}" is not <package>:<path>`);
4538
+ return { package: source.slice(0, at), path: source.slice(at + 1) };
4539
+ }
4540
+
4541
+ // src/blocks/database.ts
4542
+ function databaseElsewhere(root) {
4543
+ const setting = readGenesisConfig(root)?.supabase;
4544
+ if (setting === void 0) return null;
4545
+ if (setting === false) return { app: null, dir: null, hasSupabase: false };
4546
+ const resolved = path20.resolve(root, setting.app);
4547
+ const real2 = (p) => existsSync(p) ? realpathSync(p) : p;
4548
+ const dir = real2(resolved);
4549
+ if (dir === real2(path20.resolve(root))) throw new GenesisConfigError(`${path20.join(root, "genesis.config.json")}: supabase.app "${setting.app}" is this app itself; leave "supabase" out instead`);
4550
+ return { app: setting.app, dir, hasSupabase: existsSync(path20.join(dir, "supabase")) };
4551
+ }
4552
+ function isSupabasePath(rel) {
4553
+ return rel === "supabase" || rel.startsWith("supabase/");
4554
+ }
4555
+
4556
+ // src/doctor/supabase.ts
4203
4557
  var DEFAULT_MIGRATIONS = "supabase/migrations";
4204
4558
  var DEFAULT_BASE = "origin/main";
4205
4559
  var DEFAULT_EXPOSED = ["public"];
@@ -4380,11 +4734,12 @@ function gitView(root, dir, base) {
4380
4734
  return { touched: touched2, edited };
4381
4735
  }
4382
4736
  function checkSupabasePack(ctx) {
4737
+ if (databaseElsewhere(ctx.root)) return;
4383
4738
  const settings = ctx.config.supabase ?? {};
4384
4739
  const dir = settings.migrations ?? DEFAULT_MIGRATIONS;
4385
- const abs = path19.join(ctx.root, dir);
4740
+ const abs = path20.join(ctx.root, dir);
4386
4741
  if (!existsSync(abs)) throw new DoctorConfigError(`the supabase pack reads ${dir}, which doesn't exist; set doctor.supabase.migrations`);
4387
- const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path19.join(abs, n), "utf8")) }));
4742
+ const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path20.join(abs, n), "utf8")) }));
4388
4743
  const exposed = new Set((settings.exposedSchemas ?? DEFAULT_EXPOSED).map((s) => s.toLowerCase()));
4389
4744
  const base = settings.base ?? DEFAULT_BASE;
4390
4745
  const view = gitView(ctx.root, dir, base);
@@ -4401,7 +4756,7 @@ function checkSupabasePack(ctx) {
4401
4756
  }
4402
4757
  }
4403
4758
  const since = settings.since;
4404
- const afterSince = (file) => since === void 0 || path19.posix.basename(file) >= since;
4759
+ const afterSince = (file) => since === void 0 || path20.posix.basename(file) >= since;
4405
4760
  if ("reason" in view && since === void 0) {
4406
4761
  ctx.report({
4407
4762
  rule: "migration-grants",
@@ -4679,51 +5034,12 @@ function checkDefinerSearchPath(ctx, migrations) {
4679
5034
  });
4680
5035
  }
4681
5036
  }
4682
- var UMBRELLA_PACKAGE = "@marktiderman/genesis";
4683
- function readReleaseManifest(root) {
4684
- const dir = findPackageDir(root, UMBRELLA_PACKAGE);
4685
- const file = dir && path19.join(dir, "dist", "versions.json");
4686
- if (!file || !existsSync(file)) return null;
4687
- return JSON.parse(readFileSync(file, "utf8"));
4688
- }
4689
- function checkVersionSkew(ctx) {
4690
- const manifest = readReleaseManifest(ctx.root);
4691
- if (!manifest) return;
4692
- const overlays = markedOverlays(ctx);
4693
- for (const [name, want] of Object.entries(manifest.packages)) {
4694
- const overlay = overlays.get(name);
4695
- if (overlay) {
4696
- const from = overlay.marker.upstream.slice(overlay.marker.upstream.lastIndexOf("@") + 1);
4697
- if (from !== want) {
4698
- ctx.report({
4699
- rule: "version-skew",
4700
- level: "warn",
4701
- file: "package.json",
4702
- subject: name,
4703
- message: `the app's overlay of ${name} was copied from ${from}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Bring the overlay onto ${want} (or promote it and adopt the release).`
4704
- });
4705
- }
4706
- continue;
4707
- }
4708
- const dir = findPackageDir(ctx.root, name);
4709
- if (!dir) continue;
4710
- const have = JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8")).version;
4711
- if (have === want) continue;
4712
- ctx.report({
4713
- rule: "version-skew",
4714
- level: "warn",
4715
- file: "package.json",
4716
- subject: name,
4717
- message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`
4718
- });
4719
- }
4720
- }
4721
5037
  var GENESIS2 = /^@marktiderman\/genesis(?:-[\w.-]+)?$/;
4722
5038
  var DEV_TOOLS = /* @__PURE__ */ new Set(["@marktiderman/genesis-cli"]);
4723
5039
  var NON_SHIPPING = /^(?:@marktiderman\/genesis-cli|vitest|@vitest\/.+|jest|jest-.+|@jest\/.+|ts-jest|babel-jest|mocha|ava|c8|nyc|@playwright\/test|playwright|cypress|@testing-library\/.+|happy-dom|jsdom|msw|@types\/.+|typescript|tsx|ts-node|eslint|eslint-.+|@eslint\/.+|@typescript-eslint\/.+|typescript-eslint|prettier|prettier-.+|@biomejs\/.+|oxlint|vite|@vitejs\/.+|vite-plugin-.+|webpack|webpack-.+|rollup|@rollup\/.+|esbuild|tsup|turbo|@storybook\/.+|storybook|@changesets\/.+|husky|lint-staged|wrangler|knip|concurrently|npm-run-all2?|rimraf|cross-env|dotenv-cli)$/;
4724
5040
  var readManifest = (dir) => {
4725
5041
  try {
4726
- return JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8"));
5042
+ return JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8"));
4727
5043
  } catch {
4728
5044
  return null;
4729
5045
  }
@@ -4737,18 +5053,18 @@ var real = (p) => {
4737
5053
  };
4738
5054
  var LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"];
4739
5055
  function nodeModulesOf(dir) {
4740
- const parent = path19.dirname(dir);
4741
- return path19.basename(parent).startsWith("@") ? path19.dirname(parent) : parent;
5056
+ const parent = path20.dirname(dir);
5057
+ return path20.basename(parent).startsWith("@") ? path20.dirname(parent) : parent;
4742
5058
  }
4743
5059
  function packagesIn(nodeModules) {
4744
5060
  if (!existsSync(nodeModules)) return [];
4745
5061
  const out = [];
4746
5062
  for (const entry of readdirSync(nodeModules)) {
4747
5063
  if (entry.startsWith(".")) continue;
4748
- const p = path19.join(nodeModules, entry);
5064
+ const p = path20.join(nodeModules, entry);
4749
5065
  if (entry.startsWith("@")) {
4750
5066
  try {
4751
- for (const sub of readdirSync(p)) out.push(path19.join(p, sub));
5067
+ for (const sub of readdirSync(p)) out.push(path20.join(p, sub));
4752
5068
  } catch {
4753
5069
  }
4754
5070
  } else {
@@ -4760,7 +5076,7 @@ function packagesIn(nodeModules) {
4760
5076
  function genesisInstalls(root) {
4761
5077
  const copies = /* @__PURE__ */ new Map();
4762
5078
  const realRoot = real(root);
4763
- const rel = (abs) => path19.relative(realRoot, abs).split(path19.sep).join("/") || ".";
5079
+ const rel = (abs) => path20.relative(realRoot, abs).split(path20.sep).join("/") || ".";
4764
5080
  const via = /* @__PURE__ */ new Map();
4765
5081
  const record = (real2, manifest, by, range, root2) => {
4766
5082
  let copy = copies.get(real2);
@@ -4772,7 +5088,7 @@ function genesisInstalls(root) {
4772
5088
  via.get(real2).add(root2);
4773
5089
  if (!copy.requiredBy.some((r) => r.by === by)) copy.requiredBy.push({ by, ...range ? { range } : {} });
4774
5090
  };
4775
- const walk = (kind, roots) => {
5091
+ const walk2 = (kind, roots) => {
4776
5092
  const expanded = /* @__PURE__ */ new Set();
4777
5093
  const queue = [];
4778
5094
  const visit = (dir, by, range) => {
@@ -4805,7 +5121,7 @@ function genesisInstalls(root) {
4805
5121
  if (!dir) return null;
4806
5122
  if (!ownInstall || name in declared) return dir;
4807
5123
  const realDir = real(dir);
4808
- if (realDir.startsWith(realRoot + path19.sep)) return dir;
5124
+ if (realDir.startsWith(realRoot + path20.sep)) return dir;
4809
5125
  return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
4810
5126
  };
4811
5127
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
@@ -4813,7 +5129,7 @@ function genesisInstalls(root) {
4813
5129
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
4814
5130
  });
4815
5131
  const app = readManifest(root);
4816
- const ownInstall = LOCKFILES.some((f) => existsSync(path19.join(root, f)));
5132
+ const ownInstall = LOCKFILES.some((f) => existsSync(path20.join(root, f)));
4817
5133
  const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
4818
5134
  const declaredDev = Object.entries(app?.devDependencies ?? {});
4819
5135
  const runtimeDeps = {
@@ -4823,18 +5139,18 @@ function genesisInstalls(root) {
4823
5139
  ...app?.dependencies
4824
5140
  };
4825
5141
  const devDeps = Object.fromEntries(declaredDev.filter(([n]) => NON_SHIPPING.test(n) && !(n in runtimeDeps)));
4826
- walk("runtime", rootsOf(runtimeDeps, "the app"));
4827
- const top = path19.join(root, "node_modules");
4828
- walk(
5142
+ walk2("runtime", rootsOf(runtimeDeps, "the app"));
5143
+ const top = path20.join(root, "node_modules");
5144
+ walk2(
4829
5145
  "hoisted",
4830
5146
  packagesIn(top).filter((dir) => {
4831
- const name = path19.relative(top, dir).split(path19.sep).join("/");
5147
+ const name = path20.relative(top, dir).split(path20.sep).join("/");
4832
5148
  return !(name in runtimeDeps) && !(name in devDeps);
4833
5149
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
4834
5150
  );
4835
5151
  const devRoots = { ...devDeps };
4836
5152
  for (const tool of DEV_TOOLS) if (!(tool in devRoots) && tool in runtimeDeps) devRoots[tool] = runtimeDeps[tool];
4837
- walk("dev", rootsOf(devRoots, "the app (dev)"));
5153
+ walk2("dev", rootsOf(devRoots, "the app (dev)"));
4838
5154
  for (const [key2, copy] of copies) {
4839
5155
  const kinds = via.get(key2);
4840
5156
  copy.runtime = kinds.has("runtime");
@@ -4870,7 +5186,7 @@ function checkDuplicatePackages(ctx) {
4870
5186
  }
4871
5187
  }
4872
5188
  function checkPeerRanges(ctx) {
4873
- const rel = (abs) => path19.relative(ctx.root, abs).split(path19.sep).join("/");
5189
+ const rel = (abs) => path20.relative(ctx.root, abs).split(path20.sep).join("/");
4874
5190
  for (const copies of genesisInstalls(ctx.root).values()) {
4875
5191
  for (const copy of copies) {
4876
5192
  const dir = copy.absolutePath;
@@ -5252,17 +5568,17 @@ var SCRIPT2 = /\.(?:[cm]?[jt]sx?)$/;
5252
5568
  var MAX_BYTES = 2 * 1024 * 1024;
5253
5569
  function appScripts(root) {
5254
5570
  const out = [];
5255
- const walk = (dir) => {
5571
+ const walk2 = (dir) => {
5256
5572
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
5257
- const abs = path19.join(dir, entry.name);
5573
+ const abs = path20.join(dir, entry.name);
5258
5574
  if (entry.isDirectory()) {
5259
- if (!SKIP_DIRS3.has(entry.name)) walk(abs);
5575
+ if (!SKIP_DIRS3.has(entry.name)) walk2(abs);
5260
5576
  } else if (entry.isFile() && SCRIPT2.test(entry.name) && statSync(abs).size <= MAX_BYTES) {
5261
- out.push(path19.relative(root, abs).split(path19.sep).join("/"));
5577
+ out.push(path20.relative(root, abs).split(path20.sep).join("/"));
5262
5578
  }
5263
5579
  }
5264
5580
  };
5265
- walk(root);
5581
+ walk2(root);
5266
5582
  return out;
5267
5583
  }
5268
5584
 
@@ -5346,7 +5662,7 @@ var ROOT_REQUIRE = /\brequire\s*\(\s*["']@marktiderman\/genesis-studio-server["'
5346
5662
  function moduleFiles(ctx) {
5347
5663
  const scanned = new Set(ctx.files.map((f) => f.path));
5348
5664
  const ignored = globMatcher([...DEFAULT_IGNORE, ...ctx.config.ignore ?? []]);
5349
- const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path19.join(ctx.root, rel), "utf8"), true) }));
5665
+ const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path20.join(ctx.root, rel), "utf8"), true) }));
5350
5666
  return [...ctx.files.filter((f) => SCRIPT_EXTS5.has(f.ext)), ...extra];
5351
5667
  }
5352
5668
  function checkStudioServerImports(ctx) {
@@ -5382,7 +5698,7 @@ var REMOVED_WORDS = {
5382
5698
  };
5383
5699
  function checkRemovedScopeNames(ctx) {
5384
5700
  let augmentedMemo;
5385
- const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path19.join(ctx.root, rel), "utf8")));
5701
+ const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path20.join(ctx.root, rel), "utf8")));
5386
5702
  for (const file of ctx.files) {
5387
5703
  if (!SCRIPT_EXTS5.has(file.ext)) continue;
5388
5704
  for (const hit of findRemovedScopeNames(file.code)) {
@@ -5454,16 +5770,16 @@ function genesisNamedImports(source) {
5454
5770
  }
5455
5771
  function declarationFiles(dir, out = []) {
5456
5772
  for (const name of readdirSync(dir)) {
5457
- const full = path19.join(dir, name);
5773
+ const full = path20.join(dir, name);
5458
5774
  if (statSync(full).isDirectory()) declarationFiles(full, out);
5459
5775
  else if (/\.d\.[cm]?ts$/.test(name)) out.push(full);
5460
5776
  }
5461
5777
  return out;
5462
5778
  }
5463
5779
  function readPackageTags(dir) {
5464
- const pkg = JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8"));
5780
+ const pkg = JSON.parse(readFileSync(path20.join(dir, "package.json"), "utf8"));
5465
5781
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
5466
- const dist = path19.join(dir, "dist");
5782
+ const dist = path20.join(dir, "dist");
5467
5783
  if (!existsSync(dist)) return tags;
5468
5784
  for (const file of declarationFiles(dist)) {
5469
5785
  const text = readFileSync(file, "utf8");
@@ -5481,7 +5797,7 @@ function entryFile(tags, pkg, specifier) {
5481
5797
  const subpath = `.${specifier.slice(pkg.length)}` || ".";
5482
5798
  const target = tags.exports[subpath === "." ? "." : subpath];
5483
5799
  const types = typeof target === "object" && target ? target.types : null;
5484
- return typeof types === "string" ? path19.join(tags.dir, types) : null;
5800
+ return typeof types === "string" ? path20.join(tags.dir, types) : null;
5485
5801
  }
5486
5802
  function tagFor(tags, entry, name) {
5487
5803
  if (entry && tags.declaredIn.get(name)?.includes(entry)) return tags.byFile.get(entry)?.get(name);
@@ -5536,7 +5852,7 @@ function showAt(dir, rev, file) {
5536
5852
  function configAtBase(root, base, explicitFile) {
5537
5853
  const mergeBase = git3(root, ["merge-base", base, "HEAD"])?.trim();
5538
5854
  if (!mergeBase) return null;
5539
- const candidates = explicitFile ? [{ dir: path19.dirname(explicitFile), file: path19.basename(explicitFile), explicit: true }] : [
5855
+ const candidates = explicitFile ? [{ dir: path20.dirname(explicitFile), file: path20.basename(explicitFile), explicit: true }] : [
5540
5856
  { dir: root, file: "genesis.config.json", explicit: false },
5541
5857
  { dir: root, file: "package.json", explicit: false }
5542
5858
  ];
@@ -5648,7 +5964,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
5648
5964
  const env = settings.databaseEnv ?? DEFAULT_DATABASE_ENV;
5649
5965
  let current = null;
5650
5966
  try {
5651
- current = lf(readFileSync(path19.join(ctx.root, out), "utf8"));
5967
+ current = lf(readFileSync(path20.join(ctx.root, out), "utf8"));
5652
5968
  } catch {
5653
5969
  current = null;
5654
5970
  }
@@ -5672,7 +5988,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
5672
5988
  ctx.report({ rule: "contracts-stale", level: generation ? "error" : "warn", file: out, message: generation ? `couldn't be generated: ${message}` : `couldn't read the database through ${env}: ${message}` });
5673
5989
  return;
5674
5990
  }
5675
- const target = path19.relative(process.cwd(), path19.join(ctx.root, out)) || out;
5991
+ const target = path20.relative(process.cwd(), path20.join(ctx.root, out)) || out;
5676
5992
  const command = `genesis introspect -o ${shellArg(target)} -s ${shellArg(schemas.join(","))}${env === DEFAULT_DATABASE_ENV ? "" : ` --database-env ${shellArg(env)}`}`;
5677
5993
  if (current !== expected) {
5678
5994
  ctx.report({
@@ -5815,8 +6131,8 @@ function currentAgentsBlock(agents) {
5815
6131
  var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
5816
6132
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
5817
6133
  const rows = primitivesCatalog(packages);
5818
- const skill = read(path19.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
5819
- const block = currentAgentsBlock(read(path19.join(root, agentsFile)));
6134
+ const skill = read(path20.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
6135
+ const block = currentAgentsBlock(read(path20.join(root, agentsFile)));
5820
6136
  return {
5821
6137
  skill: skill === null ? "missing" : skill === renderSkill(rows) ? "ok" : "stale",
5822
6138
  agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows) ? "ok" : "stale"
@@ -5838,9 +6154,274 @@ function checkAgentGuide(ctx) {
5838
6154
  ctx.report({ rule: "agent-guide-stale", level: "warn", file: "AGENTS.md", message });
5839
6155
  }
5840
6156
  }
6157
+ var CLI = "@marktiderman/genesis-cli";
6158
+ function ownedKeyProblem(key2, source, localNames = /* @__PURE__ */ new Set()) {
6159
+ let parsed;
6160
+ try {
6161
+ parsed = parseSource(source);
6162
+ } catch (err) {
6163
+ return err instanceof Error ? err.message : String(err);
6164
+ }
6165
+ const { package: pkg, path: rel } = parsed;
6166
+ if (!GENESIS_PACKAGE.test(pkg) && !localNames.has(pkg)) return `${key2}'s source ${pkg} isn't a Genesis or local package`;
6167
+ if (!safeRelative(rel) || !safeRelative(key2)) return `${key2} or its source isn't a plain path`;
6168
+ if (key2.startsWith("supabase/migrations/")) return `${key2} is a migration; migrations are never refreshed`;
6169
+ const base = rel.split("/").pop();
6170
+ if (pkg === CLI && rel.startsWith("templates/")) {
6171
+ return /^(eas\.json|\.eas\/[\w./-]+|\.maestro\/[\w./-]+|\.github\/workflows\/[\w.-]+\.ya?ml)$/.test(key2) ? null : `${key2} isn't where a template goes`;
6172
+ }
6173
+ const fn = /^functions\/([a-z0-9][a-z0-9_-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*)$/.exec(rel);
6174
+ if (fn) return key2 === `supabase/functions/${fn[1]}/${fn[2]}` ? null : `${key2} isn't where ${rel} goes`;
6175
+ if (/\.test\.sql$/.test(base)) return key2 === `supabase/tests/database/${base.replace(/^\d{4}_/, "")}` ? null : `${key2} isn't where ${rel} goes`;
6176
+ if (/^\.claude\/skills\/[a-z0-9][a-z0-9_-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/.test(key2) && key2.endsWith(`/${base}`)) return null;
6177
+ return `${key2} doesn't match its source ${source}`;
6178
+ }
6179
+
6180
+ // src/blocks/templates.ts
6181
+ function starterDir() {
6182
+ const workspace = workspacePackagesDir();
6183
+ const live = workspace && path20.join(workspace, "..", "apps", "genesis-rn-starter");
6184
+ if (live && existsSync(path20.join(live, "package.json"))) return live;
6185
+ const packaged = path20.join(cliPackageDir(), "dist", "starter");
6186
+ if (existsSync(path20.join(packaged, "package.json"))) return packaged;
6187
+ throw new Error("This genesis-cli has no starter (dist/starter is missing): reinstall @marktiderman/genesis-cli.");
6188
+ }
6189
+
6190
+ // src/blocks/starter-features.ts
6191
+ var STARTER_CONFIG = "starter.config.ts";
6192
+ var GENESIS_CONFIG = "genesis.config.json";
6193
+ var SWITCH = /^[a-zA-Z][a-zA-Z0-9]*$/;
6194
+ var BLOCK_ID2 = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
6195
+ function featuresBody(text) {
6196
+ const m = /\bfeatures:\s*\{/.exec(text);
6197
+ if (!m) return null;
6198
+ const start = m.index + m[0].length;
6199
+ let depth = 1;
6200
+ for (let i = start; i < text.length; i++) {
6201
+ const c = text[i];
6202
+ if (c === "/" && text[i + 1] === "/") {
6203
+ const nl = text.indexOf("\n", i);
6204
+ if (nl < 0) return null;
6205
+ i = nl;
6206
+ } else if (c === "/" && text[i + 1] === "*") {
6207
+ const close = text.indexOf("*/", i + 2);
6208
+ if (close < 0) return null;
6209
+ i = close + 1;
6210
+ } else if (c === '"' || c === "'" || c === "`") {
6211
+ let j = i + 1;
6212
+ while (j < text.length && text[j] !== c) j += text[j] === "\\" ? 2 : 1;
6213
+ i = j;
6214
+ } else if (c === "{") depth++;
6215
+ else if (c === "}" && --depth === 0) return { start, body: text.slice(start, i) };
6216
+ }
6217
+ return null;
6218
+ }
6219
+ function parseStarterFeatures(text) {
6220
+ const found = featuresBody(text);
6221
+ if (!found) return null;
6222
+ const out = {};
6223
+ for (const line of found.body.split("\n")) {
6224
+ const m = /^\s*([a-zA-Z][a-zA-Z0-9]*)\s*:\s*(true|false)\s*,?\s*(?:\/\/.*)?$/.exec(line);
6225
+ if (m) out[m[1]] = m[2] === "true";
6226
+ }
6227
+ return out;
6228
+ }
6229
+ function parseStarterBlocks(json, source = GENESIS_CONFIG) {
6230
+ let raw;
6231
+ try {
6232
+ raw = JSON.parse(json);
6233
+ } catch (err) {
6234
+ throw new Error(`${source} is not valid JSON: ${err.message}`);
6235
+ }
6236
+ const starter = raw?.starter;
6237
+ if (starter === void 0) return null;
6238
+ const blocks = starter?.blocks;
6239
+ if (blocks === void 0 && typeof starter === "object" && starter !== null && !Array.isArray(starter)) return null;
6240
+ if (typeof blocks !== "object" || blocks === null || Array.isArray(blocks)) throw new Error(`${source}: starter.blocks must map each feature switch to a list of block ids`);
6241
+ const out = {};
6242
+ for (const [name, ids] of Object.entries(blocks)) {
6243
+ if (name === "$comment") continue;
6244
+ if (!SWITCH.test(name) || !Array.isArray(ids) || !ids.every((id) => typeof id === "string" && BLOCK_ID2.test(id))) {
6245
+ throw new Error(`${source}: starter.blocks.${name} must be a list of block ids`);
6246
+ }
6247
+ out[name] = ids;
6248
+ }
6249
+ return out;
6250
+ }
6251
+ function readText(file) {
6252
+ try {
6253
+ return readFileSync(file, "utf8");
6254
+ } catch {
6255
+ return null;
6256
+ }
6257
+ }
6258
+ function starterBlockMap(root) {
6259
+ if (root) {
6260
+ const file = path20.join(root, GENESIS_CONFIG);
6261
+ const text2 = readText(file);
6262
+ const own = text2 === null ? null : parseStarterBlocks(text2, file);
6263
+ if (own) return own;
6264
+ }
6265
+ let dir;
6266
+ try {
6267
+ dir = starterDir();
6268
+ } catch {
6269
+ return {};
6270
+ }
6271
+ const text = readText(path20.join(dir, GENESIS_CONFIG));
6272
+ return (text === null ? null : parseStarterBlocks(text)) ?? {};
6273
+ }
6274
+ function blocksSwitchedOff(switches, map, manifests, present) {
6275
+ const ids = new Set(present);
6276
+ const off = /* @__PURE__ */ new Map();
6277
+ for (const [name, carried] of Object.entries(map)) if (switches[name] === false) {
6278
+ for (const id of carried) if (ids.has(id)) off.set(id, name);
6279
+ }
6280
+ const requires = new Map(manifests.map((m) => [m.id, m.requires]));
6281
+ const keep = [...ids].filter((id) => !off.has(id));
6282
+ for (let i = 0; i < keep.length; i++) {
6283
+ for (const r of requires.get(keep[i]) ?? []) {
6284
+ off.delete(r);
6285
+ if (!keep.includes(r)) keep.push(r);
6286
+ }
6287
+ }
6288
+ return off;
6289
+ }
6290
+ function appBlocksSwitchedOff(root, manifests, present) {
6291
+ const text = readText(path20.join(root, STARTER_CONFIG));
6292
+ const switches = text === null ? null : parseStarterFeatures(text);
6293
+ if (!switches) return /* @__PURE__ */ new Map();
6294
+ return blocksSwitchedOff(switches, starterBlockMap(existsSync(path20.join(root, GENESIS_CONFIG)) ? root : void 0), manifests, present);
6295
+ }
6296
+ function blockOfSource(source, manifests) {
6297
+ const at = source.indexOf(":");
6298
+ if (at < 1) return null;
6299
+ const pkg = source.slice(0, at);
6300
+ const rel = source.slice(at + 1);
6301
+ for (const m of manifests) {
6302
+ if (m.functions.some((fn) => fn.package === pkg && rel.startsWith(`${fn.dir}/`))) return m.id;
6303
+ if (m.migrations.some((mig) => mig.package === pkg && mig.test === rel)) return m.id;
6304
+ }
6305
+ return null;
6306
+ }
6307
+
6308
+ // src/doctor/lock-files.ts
6309
+ async function checkLockFiles(ctx) {
6310
+ if (!existsSync(path20.join(ctx.root, LOCK_FILE))) return;
6311
+ let lock;
6312
+ try {
6313
+ lock = readLock(ctx.root);
6314
+ } catch (err) {
6315
+ ctx.report({ rule: "lock-files", level: "warn", file: LOCK_FILE, message: `can't be read (${err instanceof Error ? err.message : String(err)}); genesis upgrade and migrate can't either` });
6316
+ return;
6317
+ }
6318
+ const catalog = catalogBlocks();
6319
+ const off = appBlocksSwitchedOff(ctx.root, catalog, Object.keys(lock.blocks));
6320
+ const offManifests = [];
6321
+ for (const [id, entry] of Object.entries(lock.blocks)) {
6322
+ const feature = off.get(id);
6323
+ if (!feature) continue;
6324
+ try {
6325
+ offManifests.push((await findBlock(ctx.root, id, { package: entry.package })).manifest);
6326
+ } catch {
6327
+ offManifests.push(...catalog.filter((m) => m.id === id));
6328
+ }
6329
+ ctx.report({
6330
+ rule: "lock-files",
6331
+ level: "info",
6332
+ file: LOCK_FILE,
6333
+ subject: id,
6334
+ message: `lists the ${id} block, but features.${feature} is off in ${STARTER_CONFIG}: genesis upgrade and migrate leave it out (delete its entry if it's gone for good)`
6335
+ });
6336
+ }
6337
+ const local = localPackageNames(ctx.root);
6338
+ let home = null;
6339
+ try {
6340
+ home = databaseElsewhere(ctx.root);
6341
+ } catch {
6342
+ }
6343
+ const elsewhere = home ? Object.keys(lock.files).filter(isSupabasePath) : [];
6344
+ if (home && elsewhere.length) {
6345
+ ctx.report({
6346
+ rule: "lock-files",
6347
+ level: "info",
6348
+ file: LOCK_FILE,
6349
+ subject: "supabase/",
6350
+ message: `lists ${elsewhere.length} file${elsewhere.length === 1 ? "" : "s"} under supabase/, but this app's database files live ${home.app ? `in ${home.app}` : "nowhere"} (genesis.config.json supabase): genesis upgrade leaves them alone, so delete those entries`
6351
+ });
6352
+ }
6353
+ for (const [rel, entry] of Object.entries(lock.files)) {
6354
+ if (home && isSupabasePath(rel)) continue;
6355
+ if (ownedKeyProblem(rel, entry.source, local)) continue;
6356
+ if (offManifests.length && blockOfSource(entry.source, offManifests)) continue;
6357
+ let file;
6358
+ try {
6359
+ file = appPath2(ctx.root, rel);
6360
+ } catch {
6361
+ continue;
6362
+ }
6363
+ let text;
6364
+ try {
6365
+ text = existsSync(file) ? readFileSync(file, "utf8") : null;
6366
+ } catch (err) {
6367
+ ctx.report({
6368
+ rule: "lock-files",
6369
+ level: "warn",
6370
+ file: rel,
6371
+ subject: rel,
6372
+ message: `is in ${LOCK_FILE} (from ${entry.source}) but can't be read (${err instanceof Error ? err.message : String(err)}), so genesis upgrade can't refresh it. Make it a file again, or remove its entry from ${LOCK_FILE}`
6373
+ });
6374
+ continue;
6375
+ }
6376
+ if (text === null) {
6377
+ if (entry.deleted) continue;
6378
+ ctx.report({
6379
+ rule: "lock-files",
6380
+ level: "warn",
6381
+ file: rel,
6382
+ subject: rel,
6383
+ message: `is in ${LOCK_FILE} (from ${entry.source}) but not on disk, and genesis upgrade won't bring it back. Deleted on purpose: add "deleted": true to its entry in ${LOCK_FILE}. Otherwise restore it (git checkout, or copy it from ${entry.source})`
6384
+ });
6385
+ continue;
6386
+ }
6387
+ if (entry.deleted) {
6388
+ ctx.report({ rule: "lock-files", level: "info", file: rel, subject: rel, message: `is marked "deleted": true in ${LOCK_FILE} but is on disk; remove the marker` });
6389
+ }
6390
+ if (sha256(text) === entry.sha256) continue;
6391
+ ctx.report({
6392
+ rule: "lock-files",
6393
+ level: "info",
6394
+ file: rel,
6395
+ subject: rel,
6396
+ message: entry.pending ? `differs from ${LOCK_FILE}: the last upgrade's version is waiting in ${rel}.genesis-next; resolve it into this file and delete it` : `differs from ${LOCK_FILE} (edited in the app); genesis upgrade three-way merges the next version into your edits`
6397
+ });
6398
+ }
6399
+ }
6400
+ function checkDatabaseHome(ctx) {
6401
+ const home = databaseElsewhere(ctx.root);
6402
+ if (!home) return;
6403
+ if (home.app && !home.hasSupabase) {
6404
+ ctx.report({
6405
+ rule: "database-elsewhere",
6406
+ level: "warn",
6407
+ file: "genesis.config.json",
6408
+ subject: home.app,
6409
+ message: `supabase.app is ${home.app}, which has no supabase folder; name the app that holds this app's database (its migrations, tests and Edge Functions)`
6410
+ });
6411
+ }
6412
+ if (existsSync(path20.join(ctx.root, "supabase"))) {
6413
+ ctx.report({
6414
+ rule: "database-elsewhere",
6415
+ level: "warn",
6416
+ file: "supabase",
6417
+ subject: "supabase/",
6418
+ message: `is here, but genesis.config.json says this app's database files live ${home.app ? `in ${home.app}/supabase` : "nowhere"}: genesis add, migrate and upgrade never plan it, so it is a second, unused copy. Delete it`
6419
+ });
6420
+ }
6421
+ }
5841
6422
  var RATCHETED_BY_DEFAULT = ["deprecated-import"];
5842
6423
  async function runDoctor(options = {}) {
5843
- const root = path19.resolve(options.root ?? process.cwd());
6424
+ const root = path20.resolve(options.root ?? process.cwd());
5844
6425
  const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);
5845
6426
  const config = loaded.config;
5846
6427
  const genesis = options.genesis ?? loadGenesis(root, config);
@@ -5894,7 +6475,7 @@ async function runDoctor(options = {}) {
5894
6475
  }
5895
6476
  let findings = applyConfig(raw, config, packageRuleIds(packages));
5896
6477
  if (options.base && changed) {
5897
- findings = applyRatchet(findings, { config, newOnly, changed, base: options.base, isAppPath: (f) => existsSync(path19.join(root, f)) });
6478
+ findings = applyRatchet(findings, { config, newOnly, changed, base: options.base, isAppPath: (f) => existsSync(path20.join(root, f)) });
5898
6479
  }
5899
6480
  const errors = findings.filter((f) => f.level === "error").length;
5900
6481
  const warnings = findings.filter((f) => f.level === "warn").length;
@@ -5939,6 +6520,8 @@ function builtinChecks(config, options = {}) {
5939
6520
  { name: "stability-imports", check: checkStabilityImports },
5940
6521
  { name: "agent-guide", check: checkAgentGuide },
5941
6522
  { name: "overlays", check: (ctx) => checkOverlays(ctx) },
6523
+ { name: "lock-files", check: checkLockFiles },
6524
+ { name: "database-elsewhere", check: checkDatabaseHome },
5942
6525
  ...(config.packs ?? []).map((p) => packs[p]),
5943
6526
  ...config.packs?.includes("supabase") && config.contracts && options.contracts !== false ? [{ name: "contracts", check: (ctx) => checkContracts(ctx) }] : []
5944
6527
  ];
@@ -6072,15 +6655,15 @@ ${formatProblems(result)}`);
6072
6655
  }
6073
6656
  }
6074
6657
  };
6075
- const explicit = /* @__PURE__ */ new Set([path19.join(root, "genesis.config.json"), ...options.configPath ? [path19.resolve(root, options.configPath)] : []]);
6658
+ const explicit = /* @__PURE__ */ new Set([path20.join(root, "genesis.config.json"), ...options.configPath ? [path20.resolve(root, options.configPath)] : []]);
6076
6659
  try {
6077
6660
  const { config } = loadConfig(root, options.configPath);
6078
- if (config.rulesDoc) explicit.add(path19.resolve(root, config.rulesDoc));
6661
+ if (config.rulesDoc) explicit.add(path20.resolve(root, config.rulesDoc));
6079
6662
  } catch {
6080
6663
  }
6081
6664
  const schedule = (file) => {
6082
- if (!explicit.has(path19.resolve(file))) {
6083
- const rel = path19.relative(root, file).split(path19.sep).join("/");
6665
+ if (!explicit.has(path20.resolve(file))) {
6666
+ const rel = path20.relative(root, file).split(path20.sep).join("/");
6084
6667
  if (rel.startsWith("..") || rel.includes("node_modules/")) return;
6085
6668
  }
6086
6669
  clearTimeout(timer);