@marktiderman/genesis-cli 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync, mkdtempSync, rmSync, realpathSync, statSync, lstatSync } from 'fs';
3
- import * as path62 from 'path';
3
+ import * as path63 from 'path';
4
4
  import { FEATURE_PLATFORMS, defineBlock, BlockError } from '@marktiderman/genesis-features/blocks';
5
5
  import { createHash } from 'crypto';
6
6
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -31,7 +31,7 @@ var __export = (target, all) => {
31
31
  function buildCatalog(packagesDir) {
32
32
  const packages = {};
33
33
  for (const dir of readdirSync(packagesDir).sort()) {
34
- const file = path62.join(packagesDir, dir, "package.json");
34
+ const file = path63.join(packagesDir, dir, "package.json");
35
35
  if (!existsSync(file)) continue;
36
36
  const pkg = JSON.parse(readFileSync(file, "utf8"));
37
37
  if (!pkg.name || !pkg.version || pkg.private || !pkg.name.startsWith("@marktiderman/genesis")) continue;
@@ -294,14 +294,14 @@ ${problems.map((p) => ` - ${p}`).join("\n")}`);
294
294
  }
295
295
  });
296
296
  function inside(parent, child) {
297
- const rel = path62.relative(parent, child);
298
- return rel === "" || !rel.startsWith("..") && !path62.isAbsolute(rel);
297
+ const rel = path63.relative(parent, child);
298
+ return rel === "" || !rel.startsWith("..") && !path63.isAbsolute(rel);
299
299
  }
300
300
  function readPackageFile(packageDir2, rel) {
301
301
  const safe = safeRelative(rel);
302
302
  if (!safe) throw new Error(`"${rel}" is not a plain path inside the package`);
303
303
  const root = realpathSync(packageDir2);
304
- const file = path62.join(root, ...safe.split("/"));
304
+ const file = path63.join(root, ...safe.split("/"));
305
305
  if (!existsSync(file)) return null;
306
306
  const real2 = realpathSync(file);
307
307
  if (!inside(root, real2)) throw new Error(`${rel} in ${packageDir2} points outside the package`);
@@ -312,7 +312,7 @@ function readPackageDir(packageDir2, rel, skipped = []) {
312
312
  const safe = safeRelative(rel);
313
313
  if (!safe) throw new Error(`"${rel}" is not a plain path inside the package`);
314
314
  const root = realpathSync(packageDir2);
315
- const dir = path62.join(root, ...safe.split("/"));
315
+ const dir = path63.join(root, ...safe.split("/"));
316
316
  if (!existsSync(dir)) return null;
317
317
  const real2 = realpathSync(dir);
318
318
  if (!inside(root, real2) || !statSync(real2).isDirectory()) throw new Error(`${rel} in ${packageDir2} is not a folder inside the package`);
@@ -332,7 +332,7 @@ function appPath(root, rel) {
332
332
  if (!safe) throw new Error(`"${rel}" is not a plain path inside the app`);
333
333
  if (safe.split("/").some((s) => s.toLowerCase() === ".git")) throw new Error(`"${rel}" is inside .git; refused`);
334
334
  const realRoot = realpathSync(root);
335
- const target = path62.join(realRoot, ...safe.split("/"));
335
+ const target = path63.join(realRoot, ...safe.split("/"));
336
336
  const there = (p) => {
337
337
  try {
338
338
  lstatSync(p);
@@ -341,13 +341,13 @@ function appPath(root, rel) {
341
341
  return false;
342
342
  }
343
343
  };
344
- let probe = path62.dirname(target);
345
- while (!there(probe)) probe = path62.dirname(probe);
344
+ let probe = path63.dirname(target);
345
+ while (!there(probe)) probe = path63.dirname(probe);
346
346
  let real2;
347
347
  try {
348
348
  real2 = realpathSync(probe);
349
349
  } catch {
350
- throw new Error(`${rel} goes through a broken symlink (${path62.relative(realRoot, probe)}); refused`);
350
+ throw new Error(`${rel} goes through a broken symlink (${path63.relative(realRoot, probe)}); refused`);
351
351
  }
352
352
  if (!inside(realRoot, real2)) throw new Error(`${rel} is outside the app (a symlinked folder?)`);
353
353
  if (there(target) && lstatSync(target).isSymbolicLink()) throw new Error(`${rel} is a symlink; left alone`);
@@ -359,20 +359,20 @@ function readApp(root, rel) {
359
359
  }
360
360
  function createApp(root, rel, content) {
361
361
  const file = appPath(root, rel);
362
- mkdirSync(path62.dirname(file), { recursive: true });
362
+ mkdirSync(path63.dirname(file), { recursive: true });
363
363
  writeFileSync(file, content, { encoding: "utf8", flag: "wx" });
364
364
  }
365
365
  function replaceApp(root, rel, content) {
366
366
  const file = appPath(root, rel);
367
- mkdirSync(path62.dirname(file), { recursive: true });
367
+ mkdirSync(path63.dirname(file), { recursive: true });
368
368
  writeFileSync(file, content, "utf8");
369
369
  }
370
370
  function listApp(root, rel, options = {}) {
371
- const dir = path62.join(root, rel);
371
+ const dir = path63.join(root, rel);
372
372
  if (!existsSync(dir)) return [];
373
373
  const out = [];
374
374
  const walk4 = (r) => {
375
- for (const entry of readdirSync(path62.join(root, r), { withFileTypes: true })) {
375
+ for (const entry of readdirSync(path63.join(root, r), { withFileTypes: true })) {
376
376
  const child = `${r}/${entry.name}`;
377
377
  if (entry.isDirectory()) walk4(child);
378
378
  else if (entry.isFile() || options.symlinks && entry.isSymbolicLink()) out.push(child);
@@ -393,8 +393,8 @@ function validateLocalPackages(raw, source = "genesis.config.json") {
393
393
  return raw.map((entry, i) => {
394
394
  const where2 = `${source}: ${LOCAL_PACKAGES_KEY}[${i}]`;
395
395
  if (typeof entry !== "string" || !entry.trim()) throw new LocalPackagesError(`${where2} must be a non-empty folder`);
396
- if (path62.isAbsolute(entry) || /^[A-Za-z]:[\\/]/.test(entry)) throw new LocalPackagesError(`${where2} must be relative to the app ("${entry}")`);
397
- const norm = path62.posix.normalize(entry.replace(/\\/g, "/")).replace(/\/+$/, "");
396
+ if (path63.isAbsolute(entry) || /^[A-Za-z]:[\\/]/.test(entry)) throw new LocalPackagesError(`${where2} must be relative to the app ("${entry}")`);
397
+ const norm = path63.posix.normalize(entry.replace(/\\/g, "/")).replace(/\/+$/, "");
398
398
  if (norm === "." || /^(\.\.\/)*\.\.$/.test(norm)) throw new LocalPackagesError(`${where2} must name a package folder, not the app or a parent of it ("${entry}")`);
399
399
  const parts = norm.split("/");
400
400
  if (parts.some((p, k) => p.includes("*") && (p !== "*" || k !== parts.length - 1))) {
@@ -405,7 +405,7 @@ function validateLocalPackages(raw, source = "genesis.config.json") {
405
405
  });
406
406
  }
407
407
  function localPackageGlobs(root) {
408
- const file = path62.join(root, "genesis.config.json");
408
+ const file = path63.join(root, "genesis.config.json");
409
409
  if (!existsSync(file)) return [];
410
410
  let raw;
411
411
  try {
@@ -418,14 +418,14 @@ function localPackageGlobs(root) {
418
418
  }
419
419
  function repositoryRoot(appRoot) {
420
420
  for (let dir = appRoot; ; ) {
421
- if (existsSync(path62.join(dir, ".git"))) return dir;
422
- const parent = path62.dirname(dir);
421
+ if (existsSync(path63.join(dir, ".git"))) return dir;
422
+ const parent = path63.dirname(dir);
423
423
  if (parent === dir) return appRoot;
424
424
  dir = parent;
425
425
  }
426
426
  }
427
427
  function localPackages(root) {
428
- const appRoot = path62.resolve(root);
428
+ const appRoot = path63.resolve(root);
429
429
  const globs = localPackageGlobs(appRoot);
430
430
  const key2 = `${appRoot}
431
431
  ${globs.join("\n")}`;
@@ -434,24 +434,24 @@ ${globs.join("\n")}`;
434
434
  const dirs = /* @__PURE__ */ new Set();
435
435
  for (const glob of globs) {
436
436
  if (glob.endsWith("/*") || glob === "*") {
437
- const parent = path62.join(appRoot, glob === "*" ? "" : glob.slice(0, -2));
437
+ const parent = path63.join(appRoot, glob === "*" ? "" : glob.slice(0, -2));
438
438
  if (!existsSync(parent) || !statSync(parent).isDirectory()) continue;
439
439
  for (const entry of readdirSync(parent).sort()) {
440
440
  if (entry.startsWith(".") || entry === "node_modules") continue;
441
- dirs.add(path62.join(parent, entry));
441
+ dirs.add(path63.join(parent, entry));
442
442
  }
443
443
  } else {
444
- dirs.add(path62.join(appRoot, glob));
444
+ dirs.add(path63.join(appRoot, glob));
445
445
  }
446
446
  }
447
447
  const real2 = realpathSync(repositoryRoot(appRoot));
448
448
  const out = [];
449
449
  const byName = /* @__PURE__ */ new Map();
450
450
  for (const dir of [...dirs].sort()) {
451
- const manifest = path62.join(dir, "package.json");
451
+ const manifest = path63.join(dir, "package.json");
452
452
  if (!existsSync(manifest)) continue;
453
453
  if (!inside(real2, realpathSync(dir))) {
454
- throw new LocalPackagesError(`${path62.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
454
+ throw new LocalPackagesError(`${path63.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
455
455
  }
456
456
  let pkg;
457
457
  try {
@@ -460,7 +460,7 @@ ${globs.join("\n")}`;
460
460
  continue;
461
461
  }
462
462
  if (typeof pkg.name !== "string" || !pkg.name) continue;
463
- const rel = path62.relative(appRoot, dir).split(path62.sep).join("/");
463
+ const rel = path63.relative(appRoot, dir).split(path63.sep).join("/");
464
464
  const other = byName.get(pkg.name);
465
465
  if (other) throw new LocalPackagesError(`${other} and ${rel} are both named ${pkg.name}`);
466
466
  byName.set(pkg.name, rel);
@@ -503,41 +503,41 @@ __export(discover_exports, {
503
503
  workspacePackagesDir: () => workspacePackagesDir
504
504
  });
505
505
  function cliPackageDir() {
506
- let dir = path62.dirname(fileURLToPath(import.meta.url));
506
+ let dir = path63.dirname(fileURLToPath(import.meta.url));
507
507
  for (; ; ) {
508
- const file = path62.join(dir, "package.json");
508
+ const file = path63.join(dir, "package.json");
509
509
  if (existsSync(file) && JSON.parse(readFileSync(file, "utf8")).name === CLI_PACKAGE) return dir;
510
- const parent = path62.dirname(dir);
510
+ const parent = path63.dirname(dir);
511
511
  if (parent === dir) throw new Error("Can't find the genesis-cli package folder.");
512
512
  dir = parent;
513
513
  }
514
514
  }
515
515
  function workspacePackagesDir() {
516
- const dir = path62.resolve(cliPackageDir(), "..");
517
- return existsSync(path62.join(dir, "features", "package.json")) && existsSync(path62.join(dir, "..", "pnpm-workspace.yaml")) ? dir : null;
516
+ const dir = path63.resolve(cliPackageDir(), "..");
517
+ return existsSync(path63.join(dir, "features", "package.json")) && existsSync(path63.join(dir, "..", "pnpm-workspace.yaml")) ? dir : null;
518
518
  }
519
519
  function readCatalog() {
520
520
  if (catalogCache) return catalogCache;
521
521
  const workspace = workspacePackagesDir();
522
522
  if (workspace) return catalogCache = buildCatalog(workspace);
523
- const file = path62.join(cliPackageDir(), "dist", "genesis-catalog.json");
523
+ const file = path63.join(cliPackageDir(), "dist", "genesis-catalog.json");
524
524
  catalogCache = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { packages: {} };
525
525
  return catalogCache;
526
526
  }
527
527
  function installedGenesis(root) {
528
528
  const found = /* @__PURE__ */ new Map();
529
- let dir = path62.resolve(root);
529
+ let dir = path63.resolve(root);
530
530
  for (; ; ) {
531
- const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path62.join(dir, m)));
532
- const scope = path62.join(dir, "node_modules", "@marktiderman");
531
+ const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path63.join(dir, m)));
532
+ const scope = path63.join(dir, "node_modules", "@marktiderman");
533
533
  if (existsSync(scope)) {
534
534
  for (const entry of readdirSync(scope)) {
535
535
  const name = `@marktiderman/${entry}`;
536
536
  if (!GENESIS_PACKAGE.test(name) || found.has(name)) continue;
537
- if (existsSync(path62.join(scope, entry, "package.json"))) found.set(name, path62.join(scope, entry));
537
+ if (existsSync(path63.join(scope, entry, "package.json"))) found.set(name, path63.join(scope, entry));
538
538
  }
539
539
  }
540
- const parent = path62.dirname(dir);
540
+ const parent = path63.dirname(dir);
541
541
  if (atInstallRoot || parent === dir) return found;
542
542
  dir = parent;
543
543
  }
@@ -551,10 +551,10 @@ function packageDir(root, name) {
551
551
  return null;
552
552
  }
553
553
  function packageVersion(dir) {
554
- return JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8")).version;
554
+ return JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8")).version;
555
555
  }
556
556
  function declarationsOf(dir, warnings) {
557
- const pkg = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
557
+ const pkg = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
558
558
  const key2 = `${realpathSync(dir)}@${pkg.version ?? ""}`;
559
559
  let cached = declarationCache.get(key2);
560
560
  if (!cached) {
@@ -564,15 +564,15 @@ function declarationsOf(dir, warnings) {
564
564
  return cached;
565
565
  }
566
566
  async function loadDeclarations(dir, warnings) {
567
- const pkg = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
567
+ const pkg = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
568
568
  const entry = pkg.exports?.["./blocks"];
569
569
  const target = typeof entry === "string" ? entry : entry && typeof entry === "object" ? entry["import"] ?? entry["default"] : void 0;
570
570
  if (typeof target !== "string") return {};
571
571
  const rel = safeRelative(target.replace(/^\.\//, ""));
572
- const file = rel && path62.join(dir, ...rel.split("/"));
572
+ const file = rel && path63.join(dir, ...rel.split("/"));
573
573
  if (!file || !inside(dir, file) || !existsSync(file)) return {};
574
574
  try {
575
- const jiti = createJiti(path62.join(dir, "package.json"), { moduleCache: false });
575
+ const jiti = createJiti(path63.join(dir, "package.json"), { moduleCache: false });
576
576
  const mod = await jiti.import(file);
577
577
  const out = {};
578
578
  for (const value of Object.values(mod)) if (isBlockDef(value)) out[value.id] = declarationFields(value);
@@ -583,7 +583,7 @@ async function loadDeclarations(dir, warnings) {
583
583
  }
584
584
  }
585
585
  async function blocksOfInstalled(dir, warnings = [], options = {}) {
586
- const pkg = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
586
+ const pkg = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
587
587
  const raw = rawBlocksOf(pkg);
588
588
  const declared = await declarationsOf(dir, warnings);
589
589
  const ids = /* @__PURE__ */ new Set([...Object.keys(raw), ...Object.keys(declared)]);
@@ -677,7 +677,7 @@ function emptyLock() {
677
677
  return { version: 1, blocks: {}, files: {} };
678
678
  }
679
679
  function readLock(root) {
680
- const file = path62.join(root, LOCK_FILE);
680
+ const file = path63.join(root, LOCK_FILE);
681
681
  if (!existsSync(file)) return emptyLock();
682
682
  const raw = JSON.parse(readFileSync(file, "utf8"));
683
683
  if (raw.version !== 1) throw new Error(`${LOCK_FILE} has version ${String(raw.version)}; this CLI reads version 1.`);
@@ -754,7 +754,7 @@ function migrationHeader(pkg, file, source) {
754
754
  `;
755
755
  }
756
756
  function stemOrNull(file) {
757
- return MIGRATION_FILE.exec(path62.posix.basename(file))?.[2] ?? null;
757
+ return MIGRATION_FILE.exec(path63.posix.basename(file))?.[2] ?? null;
758
758
  }
759
759
  function stemOf(file) {
760
760
  const stem = stemOrNull(file);
@@ -764,7 +764,7 @@ function stemOf(file) {
764
764
  function readAppMigrations(root, dir = MIGRATIONS_DIR) {
765
765
  return listApp(root, dir, { symlinks: true }).filter((p) => p.endsWith(".sql")).map((p) => {
766
766
  const content = readApp(root, p) ?? "";
767
- const name = path62.posix.basename(p);
767
+ const name = path63.posix.basename(p);
768
768
  const m = HEADER.exec(content);
769
769
  if (m) return { path: p, name, content, tracked: { package: m[1], file: m[2], sha256: m[3], body: content.slice(m[0].length) } };
770
770
  const f = FORWARD.exec(content);
@@ -935,7 +935,7 @@ function planMigrations(root, sources, options = { now: /* @__PURE__ */ new Date
935
935
  detail = copy.tracked ? renamed.trim() : "copied before headers; matches the package";
936
936
  } else if (copy.tracked) {
937
937
  state = "changed-upstream";
938
- detail = `${src.package} now ships a different ${path62.posix.basename(src.file)}; the applied copy is never rewritten`;
938
+ detail = `${src.package} now ships a different ${path63.posix.basename(src.file)}; the applied copy is never rewritten`;
939
939
  } else {
940
940
  state = "differs";
941
941
  detail = "has the package migration's name but other text and no header; treated as the app's own";
@@ -957,7 +957,7 @@ function planMigrations(root, sources, options = { now: /* @__PURE__ */ new Date
957
957
  row.target = target2;
958
958
  creates.push({ path: target2, content: migrationHeader(src.package, src.file, src.source) + src.source, kind, source: { package: src.package, file: src.file } });
959
959
  if (options.tests !== false && src.test && src.testSource != null) {
960
- const test2 = `${TESTS_DIR}/${path62.posix.basename(src.test).replace(/^\d{4}_/, "")}`;
960
+ const test2 = `${TESTS_DIR}/${path63.posix.basename(src.test).replace(/^\d{4}_/, "")}`;
961
961
  if (readApp(root, test2) === null && !creates.some((c) => c.path === test2)) creates.push({ path: test2, content: src.testSource, kind: "test", source: { package: src.package, file: src.test } });
962
962
  }
963
963
  return;
@@ -1072,25 +1072,25 @@ function validateEnvironments(raw, source = "config") {
1072
1072
  }
1073
1073
  function appPath2(v, where2, fail) {
1074
1074
  if (typeof v !== "string" || !v.trim()) return fail(`${where2} must be a non-empty path`);
1075
- if (path62.isAbsolute(v) || /^[A-Za-z]:[\\/]/.test(v)) fail(`${where2} must be relative to the app, not absolute ("${v}")`);
1076
- const norm = path62.posix.normalize(v.replace(/\\/g, "/")).replace(/\/+$/, "");
1075
+ if (path63.isAbsolute(v) || /^[A-Za-z]:[\\/]/.test(v)) fail(`${where2} must be relative to the app, not absolute ("${v}")`);
1076
+ const norm = path63.posix.normalize(v.replace(/\\/g, "/")).replace(/\/+$/, "");
1077
1077
  if (norm === "." || norm === ".." || norm.startsWith("../")) fail(`${where2} must be a folder inside the app ("${v}")`);
1078
1078
  return norm;
1079
1079
  }
1080
1080
  function loadConfig(root, configPath) {
1081
1081
  if (configPath) {
1082
- const file = path62.resolve(root, configPath);
1082
+ const file = path63.resolve(root, configPath);
1083
1083
  if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);
1084
1084
  const json = readJson(file);
1085
- const block = path62.basename(file) === "package.json" ? json?.genesis?.doctor : json?.doctor ?? json;
1086
- return { config: validateConfig(block ?? {}, file), file, dir: path62.dirname(file) };
1085
+ const block = path63.basename(file) === "package.json" ? json?.genesis?.doctor : json?.doctor ?? json;
1086
+ return { config: validateConfig(block ?? {}, file), file, dir: path63.dirname(file) };
1087
1087
  }
1088
- const own = path62.join(root, "genesis.config.json");
1088
+ const own = path63.join(root, "genesis.config.json");
1089
1089
  if (existsSync(own)) {
1090
1090
  const block = readGenesisConfig(root)?.raw.doctor;
1091
1091
  return { config: validateConfig(block ?? {}, own), file: own, dir: root };
1092
1092
  }
1093
- const pkg = path62.join(root, "package.json");
1093
+ const pkg = path63.join(root, "package.json");
1094
1094
  if (existsSync(pkg)) {
1095
1095
  const block = readJson(pkg)?.genesis?.doctor;
1096
1096
  if (block !== void 0 && !isPackageDeclaration(block)) return { config: validateConfig(block, pkg), file: pkg, dir: root };
@@ -1099,7 +1099,7 @@ function loadConfig(root, configPath) {
1099
1099
  }
1100
1100
  function doctorBlock(json, file, explicit) {
1101
1101
  const j = json;
1102
- if (path62.basename(file) === "package.json") return j?.genesis?.doctor;
1102
+ if (path63.basename(file) === "package.json") return j?.genesis?.doctor;
1103
1103
  return explicit ? j?.doctor ?? j : j?.doctor;
1104
1104
  }
1105
1105
  function isPackageDeclaration(block) {
@@ -1116,7 +1116,7 @@ function readJson(file) {
1116
1116
  }
1117
1117
  }
1118
1118
  function readGenesisConfig(root) {
1119
- const file = path62.join(root, "genesis.config.json");
1119
+ const file = path63.join(root, "genesis.config.json");
1120
1120
  if (!existsSync(file)) return null;
1121
1121
  const raw = readJson(file);
1122
1122
  if (!isObject2(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
@@ -1159,8 +1159,8 @@ function validateSupabase(raw, source = "config") {
1159
1159
  for (const key2 of Object.keys(raw)) if (key2 !== "app" && key2 !== "$comment") fail(`supabase: unknown setting "${key2}" (known: app)`);
1160
1160
  const app = raw.app;
1161
1161
  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")`);
1162
- if (path62.isAbsolute(app) || /^[A-Za-z]:[\\/]/.test(app) || app.includes("\\")) fail(`supabase.app must be relative to this app, with forward slashes ("${app}")`);
1163
- const norm = path62.posix.normalize(app).replace(/\/+$/, "");
1162
+ if (path63.isAbsolute(app) || /^[A-Za-z]:[\\/]/.test(app) || app.includes("\\")) fail(`supabase.app must be relative to this app, with forward slashes ("${app}")`);
1163
+ const norm = path63.posix.normalize(app).replace(/\/+$/, "");
1164
1164
  if (norm === "." || norm === "") fail(`supabase.app names this app itself; leave "supabase" out instead`);
1165
1165
  return { app: norm };
1166
1166
  }
@@ -1340,7 +1340,7 @@ function validateConfig(raw, source = "config") {
1340
1340
  if (!(c.packs ?? []).includes("supabase")) fail(`"contracts" is set but the supabase pack is not in "packs"`);
1341
1341
  if (contracts.out !== void 0) {
1342
1342
  if (typeof contracts.out !== "string" || !contracts.out.trim()) fail(`contracts.out must be a file path`);
1343
- if (path62.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1343
+ if (path63.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1344
1344
  }
1345
1345
  if (contracts.schemas !== void 0 && !isStringList(contracts.schemas)) fail(`contracts.schemas must be a list of schema names`);
1346
1346
  if (contracts.databaseEnv !== void 0 && (typeof contracts.databaseEnv !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(contracts.databaseEnv))) {
@@ -1487,11 +1487,11 @@ function databaseElsewhere(root) {
1487
1487
  const setting = readGenesisConfig(root)?.supabase;
1488
1488
  if (setting === void 0) return null;
1489
1489
  if (setting === false) return { app: null, dir: null, hasSupabase: false };
1490
- const resolved = path62.resolve(root, setting.app);
1490
+ const resolved = path63.resolve(root, setting.app);
1491
1491
  const real2 = (p) => existsSync(p) ? realpathSync(p) : p;
1492
1492
  const dir = real2(resolved);
1493
- if (dir === real2(path62.resolve(root))) throw new GenesisConfigError(`${path62.join(root, "genesis.config.json")}: supabase.app "${setting.app}" is this app itself; leave "supabase" out instead`);
1494
- return { app: setting.app, dir, hasSupabase: existsSync(path62.join(dir, "supabase")) };
1493
+ if (dir === real2(path63.resolve(root))) throw new GenesisConfigError(`${path63.join(root, "genesis.config.json")}: supabase.app "${setting.app}" is this app itself; leave "supabase" out instead`);
1494
+ return { app: setting.app, dir, hasSupabase: existsSync(path63.join(dir, "supabase")) };
1495
1495
  }
1496
1496
  function isSupabasePath(rel) {
1497
1497
  return rel === "supabase" || rel.startsWith("supabase/");
@@ -1537,7 +1537,7 @@ function migrationsMissingThere(home, ids, manifests) {
1537
1537
  }
1538
1538
  for (const fn of m.functions) {
1539
1539
  if (superseded.has(`${fn.package}:${fn.dir}`)) continue;
1540
- if (!existsSync(path62.join(home.dir, "supabase", "functions", fn.dir.split("/").pop()))) out.push({ block: id, what: `${fn.package} ${fn.dir}`, kind: "function" });
1540
+ if (!existsSync(path63.join(home.dir, "supabase", "functions", fn.dir.split("/").pop()))) out.push({ block: id, what: `${fn.package} ${fn.dir}`, kind: "function" });
1541
1541
  }
1542
1542
  }
1543
1543
  return out;
@@ -1576,11 +1576,11 @@ var init_database = __esm({
1576
1576
  }
1577
1577
  });
1578
1578
  function findPackageDir(from, name) {
1579
- let dir = path62.resolve(from);
1579
+ let dir = path63.resolve(from);
1580
1580
  for (; ; ) {
1581
- const candidate = path62.join(dir, "node_modules", name);
1582
- if (existsSync(path62.join(candidate, "package.json"))) return candidate;
1583
- const parent = path62.dirname(dir);
1581
+ const candidate = path63.join(dir, "node_modules", name);
1582
+ if (existsSync(path63.join(candidate, "package.json"))) return candidate;
1583
+ const parent = path63.dirname(dir);
1584
1584
  if (parent === dir) return null;
1585
1585
  dir = parent;
1586
1586
  }
@@ -1623,7 +1623,7 @@ function loadGenesis(root, config) {
1623
1623
  function notInstalled(root, uiPackage) {
1624
1624
  let declared = false;
1625
1625
  try {
1626
- const pkg = JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
1626
+ const pkg = JSON.parse(readFileSync(path63.join(root, "package.json"), "utf8"));
1627
1627
  declared = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"].some((s) => pkg[s]?.[uiPackage] !== void 0);
1628
1628
  } catch {
1629
1629
  }
@@ -1646,7 +1646,7 @@ function loadCompanions(root, config, uiPackage) {
1646
1646
  function readPackageExports(root, uiPackage) {
1647
1647
  const uiDir = findPackageDir(root, uiPackage);
1648
1648
  if (!uiDir) return null;
1649
- const uiPkg = JSON.parse(readFileSync(path62.join(uiDir, "package.json"), "utf8"));
1649
+ const uiPkg = JSON.parse(readFileSync(path63.join(uiDir, "package.json"), "utf8"));
1650
1650
  const subpaths = Object.values(uiPkg.exports ?? {});
1651
1651
  const declared = uiPkg.types ?? uiPkg.typings ?? exportTypes(uiPkg.exports?.["."] ?? uiPkg.exports);
1652
1652
  const fromSource = typeof declared !== "string" && !subpaths.some((t) => typeof exportTypes(t) === "string");
@@ -1673,23 +1673,23 @@ function readPackageExports(root, uiPackage) {
1673
1673
  }
1674
1674
  if (fromSource) {
1675
1675
  for (const m of code.matchAll(/export\s+\*\s+from\s*["'](\.[^"']*)["']/g)) {
1676
- const next = resolveSource(path62.dirname(file), m[1]);
1676
+ const next = resolveSource(path63.dirname(file), m[1]);
1677
1677
  if (next) readEntry(next);
1678
1678
  }
1679
1679
  }
1680
1680
  };
1681
- for (const entry of typeEntries) readEntry(path62.join(uiDir, entry));
1681
+ for (const entry of typeEntries) readEntry(path63.join(uiDir, entry));
1682
1682
  if (!readAny) {
1683
1683
  const what = fromSource ? "type declarations or TypeScript source" : "type declarations";
1684
1684
  throw new DoctorConfigError(`${uiPackage} has no ${what} to read (is it built?). Looked for: ${[...typeEntries].join(", ") || "none"}`);
1685
1685
  }
1686
1686
  const valueDecls = /* @__PURE__ */ new Set();
1687
1687
  const typeDecls = /* @__PURE__ */ new Set();
1688
- const declRoot = typeof mainTypes === "string" ? path62.dirname(path62.join(uiDir, mainTypes)) : uiDir;
1688
+ const declRoot = typeof mainTypes === "string" ? path63.dirname(path63.join(uiDir, mainTypes)) : uiDir;
1689
1689
  const declFiles = fromSource ? walkSource(declRoot) : walkDts(declRoot);
1690
1690
  for (const pkg of reexportedPackages) {
1691
1691
  const dir = findPackageDir(uiDir, pkg);
1692
- if (dir) walkDts(path62.join(dir, "dist"), declFiles);
1692
+ if (dir) walkDts(path63.join(dir, "dist"), declFiles);
1693
1693
  }
1694
1694
  for (const file of declFiles) {
1695
1695
  const text = readFileSync(file, "utf8");
@@ -1738,11 +1738,11 @@ function themeParts(root) {
1738
1738
  if (!ds) return null;
1739
1739
  if (partsCache.has(ds)) return partsCache.get(ds);
1740
1740
  let found = null;
1741
- const dist = path62.join(ds, "dist");
1741
+ const dist = path63.join(ds, "dist");
1742
1742
  try {
1743
1743
  for (const name of existsSync(dist) ? readdirSync(dist) : []) {
1744
1744
  if (!name.endsWith(".js")) continue;
1745
- const code = readFileSync(path62.join(dist, name), "utf8");
1745
+ const code = readFileSync(path63.join(dist, name), "utf8");
1746
1746
  const at = code.indexOf("THEME_PARTS = Object.freeze([");
1747
1747
  if (at === -1) continue;
1748
1748
  const body = code.slice(at, code.indexOf("]);", at));
@@ -1778,13 +1778,13 @@ function exportSource(target) {
1778
1778
  return void 0;
1779
1779
  }
1780
1780
  function resolveSource(dir, spec) {
1781
- const base = path62.resolve(dir, spec.replace(/\.js$/, ""));
1782
- const candidates = [base, ...[".ts", ".tsx", ".mts", ".cts"].map((e) => base + e), ...["index.ts", "index.tsx"].map((i) => path62.join(base, i))];
1781
+ const base = path63.resolve(dir, spec.replace(/\.js$/, ""));
1782
+ const candidates = [base, ...[".ts", ".tsx", ".mts", ".cts"].map((e) => base + e), ...["index.ts", "index.tsx"].map((i) => path63.join(base, i))];
1783
1783
  return candidates.find((f) => TS_SOURCE.test(f) && existsSync(f) && statSync(f).isFile()) ?? null;
1784
1784
  }
1785
1785
  function insidePackage(dir, file) {
1786
- const rel = path62.relative(path62.resolve(dir), path62.resolve(file));
1787
- return rel === "" || !rel.startsWith("..") && !path62.isAbsolute(rel);
1786
+ const rel = path63.relative(path63.resolve(dir), path63.resolve(file));
1787
+ return rel === "" || !rel.startsWith("..") && !path63.isAbsolute(rel);
1788
1788
  }
1789
1789
  function stripComments(code) {
1790
1790
  let out = "";
@@ -1820,7 +1820,7 @@ function walkSource(dir, out = []) {
1820
1820
  if (!existsSync(dir)) return out;
1821
1821
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1822
1822
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
1823
- const p = path62.join(dir, entry.name);
1823
+ const p = path63.join(dir, entry.name);
1824
1824
  if (entry.isDirectory()) walkSource(p, out);
1825
1825
  else if (isTsSource(entry.name) || /\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1826
1826
  }
@@ -1840,7 +1840,7 @@ function walkDts(dir, out = []) {
1840
1840
  if (!existsSync(dir)) return out;
1841
1841
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1842
1842
  if (entry.name === "node_modules") continue;
1843
- const p = path62.join(dir, entry.name);
1843
+ const p = path63.join(dir, entry.name);
1844
1844
  if (entry.isDirectory()) walkDts(p, out);
1845
1845
  else if (/\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1846
1846
  }
@@ -1857,27 +1857,27 @@ function resolveThemeFiles(root, config, uiDir) {
1857
1857
  }
1858
1858
  const files = [];
1859
1859
  const ds = findPackageDir(root, DESIGN_SYSTEM_PACKAGE);
1860
- const themes = ds && path62.join(ds, "dist", "themes");
1860
+ const themes = ds && path63.join(ds, "dist", "themes");
1861
1861
  if (themes && existsSync(themes)) {
1862
- for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path62.join(themes, name));
1862
+ for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path63.join(themes, name));
1863
1863
  }
1864
1864
  if (files.length === 0) {
1865
1865
  throw new DoctorConfigError(
1866
1866
  `No Genesis theme stylesheet found (${DESIGN_SYSTEM_PACKAGE}/dist/themes/*.css). Install the design system, or set doctor.themeCss.`
1867
1867
  );
1868
1868
  }
1869
- const uiStyles = path62.join(uiDir, "dist", "styles.css");
1869
+ const uiStyles = path63.join(uiDir, "dist", "styles.css");
1870
1870
  if (existsSync(uiStyles)) files.push(uiStyles);
1871
1871
  return files;
1872
1872
  }
1873
1873
  function resolveSpec(root, spec) {
1874
- const local = path62.resolve(root, spec);
1875
- if (spec.startsWith(".") || path62.isAbsolute(spec)) return existsSync(local) ? local : null;
1874
+ const local = path63.resolve(root, spec);
1875
+ if (spec.startsWith(".") || path63.isAbsolute(spec)) return existsSync(local) ? local : null;
1876
1876
  const parts = spec.split("/");
1877
1877
  const nameLength = spec.startsWith("@") ? 2 : 1;
1878
1878
  const dir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
1879
1879
  if (dir) {
1880
- const file = path62.join(dir, ...parts.slice(nameLength));
1880
+ const file = path63.join(dir, ...parts.slice(nameLength));
1881
1881
  if (existsSync(file) && statSync(file).isFile()) return file;
1882
1882
  }
1883
1883
  return existsSync(local) ? local : null;
@@ -1885,7 +1885,7 @@ function resolveSpec(root, spec) {
1885
1885
  function loadPalette(root) {
1886
1886
  const names = new Set(TAILWIND_PALETTE);
1887
1887
  try {
1888
- const req = createRequire(path62.join(root, "package.json"));
1888
+ const req = createRequire(path63.join(root, "package.json"));
1889
1889
  const colors = req("tailwindcss/colors");
1890
1890
  for (const key2 of Object.keys(colors?.default ?? colors ?? {})) {
1891
1891
  if (/^[a-z]+$/.test(key2) && !["inherit", "current", "transparent"].includes(key2)) names.add(key2);
@@ -2133,7 +2133,7 @@ function globToRegExp(glob) {
2133
2133
  }
2134
2134
  function globMatcher(globs) {
2135
2135
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
2136
- return (path63) => res.some((re) => re.test(path63));
2136
+ return (path64) => res.some((re) => re.test(path64));
2137
2137
  }
2138
2138
  var init_glob = __esm({
2139
2139
  "src/doctor/glob.ts"() {
@@ -2145,9 +2145,9 @@ function scanFiles(root, config) {
2145
2145
  const files = [];
2146
2146
  const seen = /* @__PURE__ */ new Set();
2147
2147
  const visit = (abs) => {
2148
- const rel = toPosix(path62.relative(root, abs));
2148
+ const rel = toPosix(path63.relative(root, abs));
2149
2149
  if (seen.has(rel) || ignored(rel)) return;
2150
- const ext = path62.extname(abs);
2150
+ const ext = path63.extname(abs);
2151
2151
  if (!extensions.has(ext)) return;
2152
2152
  if (statSync(abs).size > MAX_FILE_BYTES) return;
2153
2153
  seen.add(rel);
@@ -2157,14 +2157,14 @@ function scanFiles(root, config) {
2157
2157
  const walk4 = (dir) => {
2158
2158
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
2159
2159
  if (entry.isDirectory()) {
2160
- if (!SKIP_DIRS.has(entry.name)) walk4(path62.join(dir, entry.name));
2160
+ if (!SKIP_DIRS.has(entry.name)) walk4(path63.join(dir, entry.name));
2161
2161
  } else if (entry.isFile()) {
2162
- visit(path62.join(dir, entry.name));
2162
+ visit(path63.join(dir, entry.name));
2163
2163
  }
2164
2164
  }
2165
2165
  };
2166
2166
  for (const src of config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)) {
2167
- const abs = path62.resolve(root, src);
2167
+ const abs = path63.resolve(root, src);
2168
2168
  if (!existsSync(abs)) continue;
2169
2169
  if (statSync(abs).isDirectory()) walk4(abs);
2170
2170
  else visit(abs);
@@ -2206,7 +2206,7 @@ var init_scan = __esm({
2206
2206
  ];
2207
2207
  SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", "coverage"]);
2208
2208
  MAX_FILE_BYTES = 2 * 1024 * 1024;
2209
- toPosix = (p) => p.split(path62.sep).join("/");
2209
+ toPosix = (p) => p.split(path63.sep).join("/");
2210
2210
  }
2211
2211
  });
2212
2212
 
@@ -2344,7 +2344,7 @@ function overlayState(name, json) {
2344
2344
  function overlaySetupProblems(root, config, dir, name, json) {
2345
2345
  const problems = [];
2346
2346
  if (json.private !== true) problems.push(`${name}: an overlay is the app's own copy and never publishes; set "private": true`);
2347
- const rel = path62.relative(path62.resolve(root), path62.resolve(dir)).split(path62.sep).join("/");
2347
+ const rel = path63.relative(path63.resolve(root), path63.resolve(dir)).split(path63.sep).join("/");
2348
2348
  const sources = (config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)).map((s) => s.replace(/^\.\//, "").replace(/\/+$/, ""));
2349
2349
  const holds = sources.find((s) => rel === "" || s === rel || s.startsWith(`${rel}/`));
2350
2350
  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})`);
@@ -2380,7 +2380,7 @@ function pinnedVersion(root, name, manifests = ["package.json"]) {
2380
2380
  for (const file of manifests) {
2381
2381
  let json;
2382
2382
  try {
2383
- json = JSON.parse(readFileSync(path62.join(root, file), "utf8"));
2383
+ json = JSON.parse(readFileSync(path63.join(root, file), "utf8"));
2384
2384
  } catch {
2385
2385
  continue;
2386
2386
  }
@@ -2405,7 +2405,7 @@ function checkOverlays(ctx, now = /* @__PURE__ */ new Date()) {
2405
2405
  const file = `${pkg.rel}/package.json`;
2406
2406
  let json;
2407
2407
  try {
2408
- json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
2408
+ json = JSON.parse(readFileSync(path63.join(pkg.dir, "package.json"), "utf8"));
2409
2409
  } catch {
2410
2410
  continue;
2411
2411
  }
@@ -2478,7 +2478,7 @@ var init_overlays = __esm({
2478
2478
  });
2479
2479
  function readReleaseManifest(root) {
2480
2480
  const dir = findPackageDir(root, UMBRELLA_PACKAGE);
2481
- const file = dir && path62.join(dir, "dist", "versions.json");
2481
+ const file = dir && path63.join(dir, "dist", "versions.json");
2482
2482
  if (!file || !existsSync(file)) return null;
2483
2483
  return JSON.parse(readFileSync(file, "utf8"));
2484
2484
  }
@@ -2504,7 +2504,7 @@ function checkVersionSkew(ctx) {
2504
2504
  }
2505
2505
  const dir = findPackageDir(ctx.root, name);
2506
2506
  if (!dir) continue;
2507
- const have = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8")).version;
2507
+ const have = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8")).version;
2508
2508
  if (have === want) continue;
2509
2509
  ctx.report({
2510
2510
  rule: "version-skew",
@@ -2525,13 +2525,13 @@ var init_versions = __esm({
2525
2525
  }
2526
2526
  });
2527
2527
  function findLockfile(root) {
2528
- let dir = path62.resolve(root);
2528
+ let dir = path63.resolve(root);
2529
2529
  for (; ; ) {
2530
- if (existsSync(path62.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
2531
- if (existsSync(path62.join(dir, "bun.lock")) || existsSync(path62.join(dir, "bun.lockb"))) return { pm: "bun", dir };
2532
- if (existsSync(path62.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
2533
- if (existsSync(path62.join(dir, "package-lock.json"))) return { pm: "npm", dir };
2534
- const parent = path62.dirname(dir);
2530
+ if (existsSync(path63.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
2531
+ if (existsSync(path63.join(dir, "bun.lock")) || existsSync(path63.join(dir, "bun.lockb"))) return { pm: "bun", dir };
2532
+ if (existsSync(path63.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
2533
+ if (existsSync(path63.join(dir, "package-lock.json"))) return { pm: "npm", dir };
2534
+ const parent = path63.dirname(dir);
2535
2535
  if (parent === dir) return null;
2536
2536
  dir = parent;
2537
2537
  }
@@ -2575,10 +2575,10 @@ var init_pm = __esm({
2575
2575
  function walk(dir, exclude = []) {
2576
2576
  const out = [];
2577
2577
  const visit = (rel) => {
2578
- for (const name of readdirSync(path62.join(dir, rel)).sort()) {
2578
+ for (const name of readdirSync(path63.join(dir, rel)).sort()) {
2579
2579
  const child = rel ? `${rel}/${name}` : name;
2580
2580
  if (exclude.some((r) => r.test(child))) continue;
2581
- const stat = statSync(path62.join(dir, child));
2581
+ const stat = statSync(path63.join(dir, child));
2582
2582
  if (stat.isDirectory()) visit(child);
2583
2583
  else if (stat.isFile()) out.push(child);
2584
2584
  }
@@ -2607,17 +2607,17 @@ var init_walk = __esm({
2607
2607
  });
2608
2608
  function starterDir() {
2609
2609
  const workspace = workspacePackagesDir();
2610
- const live = workspace && path62.join(workspace, "..", "apps", "genesis-rn-starter");
2611
- if (live && existsSync(path62.join(live, "package.json"))) return live;
2612
- const packaged = path62.join(cliPackageDir(), "dist", "starter");
2613
- if (existsSync(path62.join(packaged, "package.json"))) return packaged;
2610
+ const live = workspace && path63.join(workspace, "..", "apps", "genesis-rn-starter");
2611
+ if (live && existsSync(path63.join(live, "package.json"))) return live;
2612
+ const packaged = path63.join(cliPackageDir(), "dist", "starter");
2613
+ if (existsSync(path63.join(packaged, "package.json"))) return packaged;
2614
2614
  throw new Error("This genesis-cli has no starter (dist/starter is missing): reinstall @marktiderman/genesis-cli.");
2615
2615
  }
2616
2616
  function templatesDir(cliDir = cliPackageDir()) {
2617
2617
  const workspace = workspacePackagesDir();
2618
- const live = workspace && cliDir === cliPackageDir() ? path62.join(workspace, "..", "templates") : null;
2619
- if (live && existsSync(path62.join(live, "eas"))) return live;
2620
- const packaged = path62.join(cliDir, "dist", "templates");
2618
+ const live = workspace && cliDir === cliPackageDir() ? path63.join(workspace, "..", "templates") : null;
2619
+ if (live && existsSync(path63.join(live, "eas"))) return live;
2620
+ const packaged = path63.join(cliDir, "dist", "templates");
2621
2621
  if (existsSync(packaged)) return packaged;
2622
2622
  throw new Error(`${cliDir} has no templates (dist/templates is missing).`);
2623
2623
  }
@@ -2714,7 +2714,7 @@ function readText(file) {
2714
2714
  }
2715
2715
  function starterBlockMap(root) {
2716
2716
  if (root) {
2717
- const file = path62.join(root, GENESIS_CONFIG);
2717
+ const file = path63.join(root, GENESIS_CONFIG);
2718
2718
  const text2 = readText(file);
2719
2719
  const own = text2 === null ? null : parseStarterBlocks(text2, file);
2720
2720
  if (own) return own;
@@ -2725,7 +2725,7 @@ function starterBlockMap(root) {
2725
2725
  } catch {
2726
2726
  return {};
2727
2727
  }
2728
- const text = readText(path62.join(dir, GENESIS_CONFIG));
2728
+ const text = readText(path63.join(dir, GENESIS_CONFIG));
2729
2729
  return (text === null ? null : parseStarterBlocks(text)) ?? {};
2730
2730
  }
2731
2731
  function blocksSwitchedOff(switches, map, manifests, present) {
@@ -2745,10 +2745,10 @@ function blocksSwitchedOff(switches, map, manifests, present) {
2745
2745
  return off;
2746
2746
  }
2747
2747
  function appBlocksSwitchedOff(root, manifests, present) {
2748
- const text = readText(path62.join(root, STARTER_CONFIG));
2748
+ const text = readText(path63.join(root, STARTER_CONFIG));
2749
2749
  const switches = text === null ? null : parseStarterFeatures(text);
2750
2750
  if (!switches) return /* @__PURE__ */ new Map();
2751
- return blocksSwitchedOff(switches, starterBlockMap(existsSync(path62.join(root, GENESIS_CONFIG)) ? root : void 0), manifests, present);
2751
+ return blocksSwitchedOff(switches, starterBlockMap(existsSync(path63.join(root, GENESIS_CONFIG)) ? root : void 0), manifests, present);
2752
2752
  }
2753
2753
  function switchedOffNote(id, feature) {
2754
2754
  return `${id}: features.${feature} is off in ${STARTER_CONFIG}, so it's left out (turn it on to have it again)`;
@@ -2868,18 +2868,18 @@ function initNative(options) {
2868
2868
  if (!BUNDLE.test(bundleId)) throw new Error(`"${bundleId}" isn't a bundle id like com.example.app.`);
2869
2869
  if (!SCHEME.test(scheme)) throw new Error(`"${scheme}" isn't a URL scheme.`);
2870
2870
  if (/["\\\n]/.test(display)) throw new Error("The display name can't contain quotes, backslashes or new lines.");
2871
- const target = path62.resolve(options.target);
2871
+ const target = path63.resolve(options.target);
2872
2872
  if (existsSync(target) && readdirSync(target).length) throw new Error(`${target} isn't empty; init writes into a new folder and never overwrites.`);
2873
2873
  let beside;
2874
2874
  if (options.beside !== void 0) {
2875
- const dir = path62.resolve(options.beside);
2875
+ const dir = path63.resolve(options.beside);
2876
2876
  if (!existsSync(dir)) throw new Error(`--beside: ${options.beside} doesn't exist; name the web app's folder.`);
2877
2877
  if (dir === target) throw new Error("--beside names the new app's own folder; name the web app's folder.");
2878
- beside = { dir, app: path62.relative(target, dir).split(path62.sep).join("/"), shared: existsSync(path62.join(dir, "supabase")) };
2878
+ beside = { dir, app: path63.relative(target, dir).split(path63.sep).join("/"), shared: existsSync(path63.join(dir, "supabase")) };
2879
2879
  }
2880
2880
  const shared = beside?.shared === true;
2881
2881
  const source = starterDir();
2882
- const read3 = (rel) => readFileSync(path62.join(source, rel), "utf8");
2882
+ const read3 = (rel) => readFileSync(path63.join(source, rel), "utf8");
2883
2883
  const was = starterIdentity(read3(STARTER_CONFIG));
2884
2884
  const switches = parseStarterFeatures(read3(STARTER_CONFIG)) ?? {};
2885
2885
  const without = [...new Set(options.without ?? [])];
@@ -2922,7 +2922,7 @@ function initNative(options) {
2922
2922
  files.set("package.json", `${JSON.stringify(pkg, null, 2)}
2923
2923
  `);
2924
2924
  files.set("metro.config.js", METRO);
2925
- const pnpmSettings = [path62.join(source, "pnpm-workspace.yaml"), path62.join(source, "..", "..", "pnpm-workspace.yaml")].find((f) => existsSync(f));
2925
+ const pnpmSettings = [path63.join(source, "pnpm-workspace.yaml"), path63.join(source, "..", "..", "pnpm-workspace.yaml")].find((f) => existsSync(f));
2926
2926
  if (pnpmSettings) files.set("pnpm-workspace.yaml", appPnpmSettings(readFileSync(pnpmSettings, "utf8")));
2927
2927
  files.set("README.md", readme(display, slug, shared ? beside.app : void 0));
2928
2928
  if (without.length) files.set(STARTER_CONFIG, setStarterFeatures(files.get(STARTER_CONFIG), Object.fromEntries(without.map((w) => [w, false]))));
@@ -2943,7 +2943,7 @@ function initNative(options) {
2943
2943
  const templates = templatesDir();
2944
2944
  for (const rel of walk(templates)) {
2945
2945
  if (shared && DATABASE_TEMPLATES.has(rel)) continue;
2946
- const text = substitute(readFileSync(path62.join(templates, rel), "utf8"), substitutions);
2946
+ const text = substitute(readFileSync(path63.join(templates, rel), "utf8"), substitutions);
2947
2947
  const to = templateTarget(rel, text);
2948
2948
  files.set(to, text);
2949
2949
  lock.files[to] = { source: `${CLI_PACKAGE}:templates/${rel}`, sha256: sha256(text), ...cliVersion2 ? { version: cliVersion2 } : {} };
@@ -2962,14 +2962,14 @@ function initNative(options) {
2962
2962
  continue;
2963
2963
  }
2964
2964
  const stems = block.migrations.map((m) => stemOf(m.file));
2965
- const copies = stems.map((s) => migrations.find((f) => path62.posix.basename(f).replace(/^\d+_/, "") === `${s}.sql`));
2965
+ const copies = stems.map((s) => migrations.find((f) => path63.posix.basename(f).replace(/^\d+_/, "") === `${s}.sql`));
2966
2966
  if (!stems.length || copies.some((c) => !c)) continue;
2967
2967
  blocks.push(block.id);
2968
2968
  lock.blocks[block.id] = { package: block.package, ...block.version ? { version: block.version } : {} };
2969
2969
  block.migrations.forEach((m, i) => {
2970
2970
  lock.migrations = { ...lock.migrations, [migrationKey(m.package, m.file)]: copies[i] };
2971
2971
  if (m.test) {
2972
- const test2 = `${TESTS_DIR}/${path62.posix.basename(m.test).replace(/^\d{4}_/, "")}`;
2972
+ const test2 = `${TESTS_DIR}/${path63.posix.basename(m.test).replace(/^\d{4}_/, "")}`;
2973
2973
  if (files.has(test2)) lock.files[test2] = { source: `${m.package}:${m.test}`, sha256: sha256(files.get(test2)) };
2974
2974
  }
2975
2975
  });
@@ -2982,8 +2982,8 @@ function initNative(options) {
2982
2982
  }
2983
2983
  mkdirSync(target, { recursive: true });
2984
2984
  for (const [rel, content] of [...files].sort(([a], [b]) => a.localeCompare(b))) {
2985
- const file = path62.join(target, ...rel.split("/"));
2986
- mkdirSync(path62.dirname(file), { recursive: true });
2985
+ const file = path63.join(target, ...rel.split("/"));
2986
+ mkdirSync(path63.dirname(file), { recursive: true });
2987
2987
  writeFileSync(file, content, { encoding: "utf8", flag: "wx" });
2988
2988
  }
2989
2989
  writeLock(target, lock);
@@ -3020,11 +3020,11 @@ function besideConfig(text, app) {
3020
3020
  `;
3021
3021
  }
3022
3022
  function carriedBy(files, block) {
3023
- const names = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => path62.posix.basename(f).replace(/^\d+_/, ""));
3023
+ const names = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => path63.posix.basename(f).replace(/^\d+_/, ""));
3024
3024
  return block.migrations.length > 0 && block.migrations.every((m) => names.includes(`${stemOf(m.file)}.sql`));
3025
3025
  }
3026
3026
  function sinceAfter(files) {
3027
- const versions = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => /^(\d{14})_/.exec(path62.posix.basename(f))?.[1]).filter((v) => Boolean(v)).sort();
3027
+ const versions = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => /^(\d{14})_/.exec(path63.posix.basename(f))?.[1]).filter((v) => Boolean(v)).sort();
3028
3028
  const last = versions.at(-1);
3029
3029
  return last ? nextStamp(last) : null;
3030
3030
  }
@@ -3039,12 +3039,12 @@ function leaveOut(files, blocks) {
3039
3039
  for (const block of blocks) {
3040
3040
  for (const m of block.migrations) {
3041
3041
  const stem = stemOf(m.file);
3042
- for (const copy of migrations.filter((f) => path62.posix.basename(f).replace(/^\d+_/, "") === `${stem}.sql`)) {
3042
+ for (const copy of migrations.filter((f) => path63.posix.basename(f).replace(/^\d+_/, "") === `${stem}.sql`)) {
3043
3043
  for (const s of files.get(copy).matchAll(/\bcreate\s+schema\s+(?:if\s+not\s+exists\s+)?"?([a-z_][a-z0-9_]*)"?/gi)) schemas.add(s[1].toLowerCase());
3044
3044
  files.delete(copy);
3045
3045
  }
3046
3046
  files.delete(`${TESTS_DIR}/${stem}.test.sql`);
3047
- if (m.test) files.delete(`${TESTS_DIR}/${path62.posix.basename(m.test).replace(/^\d{4}_/, "")}`);
3047
+ if (m.test) files.delete(`${TESTS_DIR}/${path63.posix.basename(m.test).replace(/^\d{4}_/, "")}`);
3048
3048
  }
3049
3049
  for (const fn of block.functions) {
3050
3050
  const name = fn.dir.split("/").pop();
@@ -3864,7 +3864,7 @@ async function checkContracts(ctx, read3 = postgresContract) {
3864
3864
  const env = settings2.databaseEnv ?? DEFAULT_DATABASE_ENV;
3865
3865
  let current = null;
3866
3866
  try {
3867
- current = lf(readFileSync(path62.join(ctx.root, out), "utf8"));
3867
+ current = lf(readFileSync(path63.join(ctx.root, out), "utf8"));
3868
3868
  } catch {
3869
3869
  current = null;
3870
3870
  }
@@ -3888,7 +3888,7 @@ async function checkContracts(ctx, read3 = postgresContract) {
3888
3888
  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}` });
3889
3889
  return;
3890
3890
  }
3891
- const target = path62.relative(process.cwd(), path62.join(ctx.root, out)) || out;
3891
+ const target = path63.relative(process.cwd(), path63.join(ctx.root, out)) || out;
3892
3892
  const command = `genesis introspect -o ${shellArg(target)} -s ${shellArg(schemas.join(","))}${env === DEFAULT_DATABASE_ENV ? "" : ` --database-env ${shellArg(env)}`}`;
3893
3893
  if (current !== expected) {
3894
3894
  ctx.report({
@@ -3916,7 +3916,7 @@ __export(settings_exports, {
3916
3916
  });
3917
3917
  function introspectSettings(flags, root, contracts, readCurrent = () => null) {
3918
3918
  const out = flags.out ?? contracts?.out ?? DEFAULT_CONTRACT_OUT;
3919
- const target = path62.resolve(root, out);
3919
+ const target = path63.resolve(root, out);
3920
3920
  return { target, label: out, schemas: schemasFor(flags, target, contracts, readCurrent), databaseEnv: flags.databaseEnv ?? contracts?.databaseEnv ?? DEFAULT_DATABASE_ENV };
3921
3921
  }
3922
3922
  function schemasFor(flags, target, contracts, readCurrent) {
@@ -3932,19 +3932,19 @@ var init_settings = __esm({
3932
3932
  });
3933
3933
  function buildCommands(root, config) {
3934
3934
  if (config.build) return config.build;
3935
- const pkgFile = path62.join(root, "package.json");
3935
+ const pkgFile = path63.join(root, "package.json");
3936
3936
  const scripts = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, "utf8")).scripts ?? {} : {};
3937
3937
  const pm = packageManager(root);
3938
3938
  return ["typecheck", "build"].filter((s) => scripts[s]).map((s) => `${pm} run ${s}`);
3939
3939
  }
3940
3940
  function packageManager(root) {
3941
- let dir = path62.resolve(root);
3941
+ let dir = path63.resolve(root);
3942
3942
  for (; ; ) {
3943
- if (existsSync(path62.join(dir, "pnpm-lock.yaml"))) return "pnpm";
3944
- if (existsSync(path62.join(dir, "bun.lock")) || existsSync(path62.join(dir, "bun.lockb"))) return "bun";
3945
- if (existsSync(path62.join(dir, "yarn.lock"))) return "yarn";
3946
- if (existsSync(path62.join(dir, "package-lock.json"))) return "npm";
3947
- const parent = path62.dirname(dir);
3943
+ if (existsSync(path63.join(dir, "pnpm-lock.yaml"))) return "pnpm";
3944
+ if (existsSync(path63.join(dir, "bun.lock")) || existsSync(path63.join(dir, "bun.lockb"))) return "bun";
3945
+ if (existsSync(path63.join(dir, "yarn.lock"))) return "yarn";
3946
+ if (existsSync(path63.join(dir, "package-lock.json"))) return "npm";
3947
+ const parent = path63.dirname(dir);
3948
3948
  if (parent === dir) return "npm";
3949
3949
  dir = parent;
3950
3950
  }
@@ -4042,7 +4042,7 @@ function loadPatternRules(root, patterns, rulesDoc) {
4042
4042
  const compiled = compilePatternRules(patterns ?? [], "doctor.patterns");
4043
4043
  let all = compiled;
4044
4044
  if (rulesDoc) {
4045
- const file = path62.resolve(root, rulesDoc);
4045
+ const file = path63.resolve(root, rulesDoc);
4046
4046
  if (!existsSync(file)) throw new DoctorConfigError(`doctor.rulesDoc: ${rulesDoc} not found`);
4047
4047
  const fromDoc = compilePatternRules(parseRulesMarkdown(readFileSync(file, "utf8")), rulesDoc);
4048
4048
  const clash = fromDoc.find((d) => compiled.some((c) => c.rule.id === d.rule.id));
@@ -4110,14 +4110,14 @@ async function loadPlugins(specs, configDir) {
4110
4110
  }
4111
4111
  function resolvePlugin(id, configDir) {
4112
4112
  try {
4113
- if (id.startsWith(".") || path62.isAbsolute(id)) return resolveFrom(path62.resolve(configDir, id), configDir);
4113
+ if (id.startsWith(".") || path63.isAbsolute(id)) return resolveFrom(path63.resolve(configDir, id), configDir);
4114
4114
  return resolveFrom(id, configDir);
4115
4115
  } catch {
4116
4116
  throw new DoctorConfigError(`doctor.plugins: cannot find ${id} (relative paths resolve from ${configDir})`);
4117
4117
  }
4118
4118
  }
4119
4119
  function resolveFrom(id, from) {
4120
- return createRequire(path62.join(from, "noop.js")).resolve(id);
4120
+ return createRequire(path63.join(from, "noop.js")).resolve(id);
4121
4121
  }
4122
4122
  var init_plugins = __esm({
4123
4123
  "src/doctor/plugins.ts"() {
@@ -4451,7 +4451,7 @@ function importSpecifiers(file) {
4451
4451
  }
4452
4452
  function checkProjectLayout(ctx) {
4453
4453
  for (const dir of ctx.config.localPrimitiveDirs ?? DEFAULT_LOCAL_PRIMITIVE_DIRS) {
4454
- if (existsSync(path62.join(ctx.root, dir))) {
4454
+ if (existsSync(path63.join(ctx.root, dir))) {
4455
4455
  ctx.report({
4456
4456
  rule: "local-primitives",
4457
4457
  file: dir,
@@ -4461,7 +4461,7 @@ function checkProjectLayout(ctx) {
4461
4461
  }
4462
4462
  }
4463
4463
  for (const file of STARTER_LEFTOVERS) {
4464
- if (existsSync(path62.join(ctx.root, file))) {
4464
+ if (existsSync(path63.join(ctx.root, file))) {
4465
4465
  ctx.report({
4466
4466
  rule: "starter-leftover",
4467
4467
  level: "warn",
@@ -4549,7 +4549,7 @@ function checkTokens(ctx) {
4549
4549
  }
4550
4550
  for (const pattern of ctx.config.tokenFiles ?? []) {
4551
4551
  if (/[*?]/.test(pattern)) continue;
4552
- const abs = path62.join(ctx.root, pattern);
4552
+ const abs = path63.join(ctx.root, pattern);
4553
4553
  if (!ctx.files.some((f) => f.absolutePath === abs) && existsSync(abs)) {
4554
4554
  for (const t of declaredTokens(readFileSync(abs, "utf8"))) defined.add(t);
4555
4555
  }
@@ -4709,7 +4709,10 @@ var init_rules = __esm({
4709
4709
  "custom-view-states",
4710
4710
  // the app's client layer (client-layer.ts)
4711
4711
  "client/layer",
4712
- "client/one-view-per-resource"
4712
+ "client/one-view-per-resource",
4713
+ // how the app reaches its database (data-access.ts)
4714
+ "data/declared-access",
4715
+ "data/access-rule-tests"
4713
4716
  ];
4714
4717
  DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
4715
4718
  STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
@@ -4794,10 +4797,10 @@ var init_expo = __esm({
4794
4797
  }
4795
4798
  });
4796
4799
  function resolveLocal(root, fromFile, spec) {
4797
- const bases = spec.startsWith(".") ? [path62.resolve(path62.dirname(fromFile), spec)] : [path62.join(root, spec.slice(2)), path62.join(root, "src", spec.slice(2))];
4800
+ const bases = spec.startsWith(".") ? [path63.resolve(path63.dirname(fromFile), spec)] : [path63.join(root, spec.slice(2)), path63.join(root, "src", spec.slice(2))];
4798
4801
  for (const base of bases) {
4799
- const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path62.join(base, `index${e}`))].find(
4800
- (p) => SCRIPT_EXTS2.has(path62.extname(p)) && existsSync(p)
4802
+ const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path63.join(base, `index${e}`))].find(
4803
+ (p) => SCRIPT_EXTS2.has(path63.extname(p)) && existsSync(p)
4801
4804
  );
4802
4805
  if (hit) return hit;
4803
4806
  }
@@ -4947,13 +4950,13 @@ function checkNativePack(ctx) {
4947
4950
  }
4948
4951
  function checkEasPlaceholders(ctx) {
4949
4952
  const files = [];
4950
- if (existsSync(path62.join(ctx.root, "eas.json"))) files.push("eas.json");
4951
- const workflows = path62.join(ctx.root, ".eas", "workflows");
4953
+ if (existsSync(path63.join(ctx.root, "eas.json"))) files.push("eas.json");
4954
+ const workflows = path63.join(ctx.root, ".eas", "workflows");
4952
4955
  if (existsSync(workflows)) {
4953
4956
  for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
4954
4957
  }
4955
4958
  for (const file of files) {
4956
- for (const hit of findPlaceholders(file, readFileSync(path62.join(ctx.root, file), "utf8"))) {
4959
+ for (const hit of findPlaceholders(file, readFileSync(path63.join(ctx.root, file), "utf8"))) {
4957
4960
  const key2 = placeholderKey(hit.text, hit.placeholder);
4958
4961
  const what = EAS_PLACEHOLDERS[hit.placeholder];
4959
4962
  ctx.report({
@@ -5031,7 +5034,7 @@ function checkCustomHeaders(ctx, pkg) {
5031
5034
  if (!JSX_EXTS3.has(file.ext)) continue;
5032
5035
  const code = file.code;
5033
5036
  const hidden = HIDES_HEADER.exec(code);
5034
- if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path62.posix.dirname(file.path), file.path);
5037
+ if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path63.posix.dirname(file.path), file.path);
5035
5038
  const own = hidden ? ownHeader(code, pkg) : null;
5036
5039
  if (hidden && own) {
5037
5040
  reported.add(file.path);
@@ -5059,7 +5062,7 @@ function checkCustomHeaders(ctx, pkg) {
5059
5062
  }
5060
5063
  for (const file of ctx.files) {
5061
5064
  if (!JSX_EXTS3.has(file.ext) || reported.has(file.path) || !file.path.startsWith(`${rootDir}/`) || NON_SCREEN_ROUTE.test(file.path)) continue;
5062
- const layout = hidingLayouts.get(path62.posix.dirname(file.path));
5065
+ const layout = hidingLayouts.get(path63.posix.dirname(file.path));
5063
5066
  const own = layout ? ownHeader(file.code, pkg) : null;
5064
5067
  if (!layout || !own) continue;
5065
5068
  ctx.report({
@@ -5080,13 +5083,13 @@ function isLoadingOnlyRoute(code) {
5080
5083
  }
5081
5084
  function routerRoot(ctx) {
5082
5085
  if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\/+$/, "");
5083
- return existsSync(path62.join(ctx.root, "src", "app")) ? "src/app" : "app";
5086
+ return existsSync(path63.join(ctx.root, "src", "app")) ? "src/app" : "app";
5084
5087
  }
5085
5088
  function checkScreenLayouts(ctx, pkg) {
5086
5089
  const layouts = nativeLayouts(pkg);
5087
5090
  if (layouts.length === 0) return;
5088
5091
  const rootDir = routerRoot(ctx);
5089
- if (!existsSync(path62.join(ctx.root, rootDir))) {
5092
+ if (!existsSync(path63.join(ctx.root, rootDir))) {
5090
5093
  ctx.report({ rule: "native-screen-layout", level: "warn", file: rootDir, message: `no Expo Router root at ${rootDir}; set doctor.native.routerRoot` });
5091
5094
  return;
5092
5095
  }
@@ -5123,7 +5126,7 @@ function checkScreenLayouts(ctx, pkg) {
5123
5126
  function readExpoConfigs(root) {
5124
5127
  const out = [];
5125
5128
  for (const name of EXPO_CONFIGS) {
5126
- const abs = path62.join(root, name);
5129
+ const abs = path63.join(root, name);
5127
5130
  if (!existsSync(abs)) continue;
5128
5131
  const text = readFileSync(abs, "utf8");
5129
5132
  let json = null;
@@ -5157,13 +5160,13 @@ function pluginOptions(json, module) {
5157
5160
  return null;
5158
5161
  }
5159
5162
  function dependencies(root) {
5160
- const file = path62.join(root, "package.json");
5163
+ const file = path63.join(root, "package.json");
5161
5164
  if (!existsSync(file)) return /* @__PURE__ */ new Set();
5162
5165
  const pkg = JSON.parse(readFileSync(file, "utf8"));
5163
5166
  return /* @__PURE__ */ new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);
5164
5167
  }
5165
5168
  function runtimeDependencies(root) {
5166
- const file = path62.join(root, "package.json");
5169
+ const file = path63.join(root, "package.json");
5167
5170
  if (!existsSync(file)) return {};
5168
5171
  return JSON.parse(readFileSync(file, "utf8")).dependencies ?? {};
5169
5172
  }
@@ -5452,14 +5455,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
5452
5455
  seen.add(file);
5453
5456
  const json = readJsonc(file);
5454
5457
  if (!json) return {};
5455
- const dir = path62.dirname(file);
5458
+ const dir = path63.dirname(file);
5456
5459
  let merged = {};
5457
5460
  const parents = typeof json.extends === "string" ? [json.extends] : Array.isArray(json.extends) ? json.extends : [];
5458
5461
  for (const ext of parents) {
5459
5462
  if (typeof ext !== "string") continue;
5460
5463
  let target = null;
5461
- if (ext.startsWith(".") || path62.isAbsolute(ext)) {
5462
- const abs = path62.resolve(dir, ext);
5464
+ if (ext.startsWith(".") || path63.isAbsolute(ext)) {
5465
+ const abs = path63.resolve(dir, ext);
5463
5466
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
5464
5467
  } else {
5465
5468
  const parts = ext.split("/");
@@ -5467,14 +5470,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
5467
5470
  const pkgDir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
5468
5471
  if (pkgDir) {
5469
5472
  const sub = parts.slice(nameLength).join("/");
5470
- const abs = path62.join(pkgDir, sub || "tsconfig.json");
5473
+ const abs = path63.join(pkgDir, sub || "tsconfig.json");
5471
5474
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
5472
5475
  }
5473
5476
  }
5474
5477
  if (target) merged = { ...merged, ...readTsconfig(root, target, seen) };
5475
5478
  }
5476
5479
  const opts = json.compilerOptions ?? {};
5477
- if (typeof opts.baseUrl === "string") merged.baseUrl = path62.resolve(dir, opts.baseUrl);
5480
+ if (typeof opts.baseUrl === "string") merged.baseUrl = path63.resolve(dir, opts.baseUrl);
5478
5481
  if (opts.paths && typeof opts.paths === "object") {
5479
5482
  merged.paths = opts.paths;
5480
5483
  merged.pathsDir = dir;
@@ -5485,7 +5488,7 @@ function aliases(root) {
5485
5488
  const table = [];
5486
5489
  let baseUrl = null;
5487
5490
  for (const name of ["tsconfig.json", "tsconfig.app.json", "jsconfig.json"]) {
5488
- const file = path62.join(root, name);
5491
+ const file = path63.join(root, name);
5489
5492
  if (!existsSync(file)) continue;
5490
5493
  const config = readTsconfig(root, file);
5491
5494
  baseUrl ??= config.baseUrl ?? null;
@@ -5493,22 +5496,22 @@ function aliases(root) {
5493
5496
  for (const [pattern, targets] of Object.entries(config.paths ?? {})) {
5494
5497
  if (!Array.isArray(targets)) continue;
5495
5498
  const exact = !pattern.endsWith("*");
5496
- table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path62.join(base, String(t).replace(/\*$/, ""))) });
5499
+ table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path63.join(base, String(t).replace(/\*$/, ""))) });
5497
5500
  }
5498
5501
  }
5499
- const pkg = readJsonc(path62.join(root, "package.json"));
5502
+ const pkg = readJsonc(path63.join(root, "package.json"));
5500
5503
  for (const [pattern, target] of Object.entries(pkg?.imports ?? {})) {
5501
5504
  if (typeof target !== "string") continue;
5502
- table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path62.join(root, target.replace(/\*.*$/, ""))] });
5505
+ table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path63.join(root, target.replace(/\*.*$/, ""))] });
5503
5506
  }
5504
- for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path62.join(root, "src") + path62.sep, root + path62.sep] });
5507
+ for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path63.join(root, "src") + path63.sep, root + path63.sep] });
5505
5508
  return { table, baseUrl };
5506
5509
  }
5507
5510
  function resolveFile(base) {
5508
- const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path62.join(base, `index${e}`))];
5511
+ const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path63.join(base, `index${e}`))];
5509
5512
  if (/\.[mc]?js$/.test(base)) tries.push(...[".ts", ".tsx"].map((e) => base.replace(/\.[mc]?js$/, e)));
5510
5513
  for (const p of tries) {
5511
- if (SCRIPT_EXTS2.has(path62.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
5514
+ if (SCRIPT_EXTS2.has(path63.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
5512
5515
  }
5513
5516
  return null;
5514
5517
  }
@@ -5521,7 +5524,7 @@ function createTrail(ctx) {
5521
5524
  const { table, baseUrl } = aliases(ctx.root);
5522
5525
  let declared = null;
5523
5526
  try {
5524
- const pkg = JSON.parse(readFileSync(path62.join(ctx.root, "package.json"), "utf8"));
5527
+ const pkg = JSON.parse(readFileSync(path63.join(ctx.root, "package.json"), "utf8"));
5525
5528
  declared = new Set(["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"].flatMap((k) => Object.keys(pkg[k] ?? {})));
5526
5529
  } catch {
5527
5530
  declared = null;
@@ -5552,17 +5555,17 @@ function createTrail(ctx) {
5552
5555
  if (/^(?:node:|https?:|data:|virtual:)/.test(spec) || /\.(?:css|scss|sass|less|svg|png|jpe?g|gif|webp|json|md|mdx)(?:\?.*)?$/.test(spec)) continue;
5553
5556
  let resolved = null;
5554
5557
  if (spec.startsWith(".")) {
5555
- resolved = resolveFile(path62.resolve(path62.dirname(file.absolutePath), spec));
5558
+ resolved = resolveFile(path63.resolve(path63.dirname(file.absolutePath), spec));
5556
5559
  if (!resolved) lost = true;
5557
5560
  } else {
5558
5561
  const alias = table.find((a) => a.exact ? spec === a.prefix : spec.startsWith(a.prefix));
5559
5562
  if (alias) {
5560
5563
  for (const t of alias.targets) {
5561
- resolved = resolveFile(alias.exact ? t : path62.join(t, spec.slice(alias.prefix.length)));
5564
+ resolved = resolveFile(alias.exact ? t : path63.join(t, spec.slice(alias.prefix.length)));
5562
5565
  if (resolved) break;
5563
5566
  }
5564
5567
  }
5565
- if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path62.join(baseUrl, spec));
5568
+ if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path63.join(baseUrl, spec));
5566
5569
  if (!resolved) {
5567
5570
  const pkg = spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
5568
5571
  if (spec.startsWith("#") || declared && !declared.has(pkg) && !findPackageDir(ctx.root, pkg)) lost = true;
@@ -5648,7 +5651,7 @@ var init_trail = __esm({
5648
5651
  });
5649
5652
  function routesDir(ctx) {
5650
5653
  if (ctx.config.routesDir) return ctx.config.routesDir;
5651
- return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path62.join(ctx.root, d))) ?? null;
5654
+ return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path63.join(ctx.root, d))) ?? null;
5652
5655
  }
5653
5656
  function flavorOf(dir, rels) {
5654
5657
  const stems = rels.map((r) => r.split("/").pop());
@@ -5789,7 +5792,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
5789
5792
  });
5790
5793
  if (typeof raw === "string") {
5791
5794
  if (!packageDir2) fail(`points at ${raw}, but the package folder is unknown`);
5792
- const file = path62.resolve(packageDir2, raw);
5795
+ const file = path63.resolve(packageDir2, raw);
5793
5796
  if (!inside(packageDir2, file)) fail(`points outside the package (${raw})`);
5794
5797
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
5795
5798
  let parsed;
@@ -5838,7 +5841,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
5838
5841
  if (typeof c.plugin === "string") {
5839
5842
  if (!packageDir2) plugin = c.plugin;
5840
5843
  else {
5841
- plugin = path62.resolve(packageDir2, c.plugin);
5844
+ plugin = path63.resolve(packageDir2, c.plugin);
5842
5845
  if (!inside(packageDir2, plugin)) fail(`plugin points outside the package (${c.plugin})`);
5843
5846
  }
5844
5847
  }
@@ -5891,7 +5894,7 @@ function checkPattern(v, where2, fail) {
5891
5894
  }
5892
5895
  }
5893
5896
  function readDeclaringPackage(dir, local) {
5894
- const file = path62.join(dir, "package.json");
5897
+ const file = path63.join(dir, "package.json");
5895
5898
  let stamp;
5896
5899
  let real2;
5897
5900
  try {
@@ -5914,7 +5917,7 @@ ${local}`;
5914
5917
  const pkg = {
5915
5918
  name: json.name,
5916
5919
  version: typeof json.version === "string" ? json.version : "0.0.0",
5917
- dir: path62.resolve(dir),
5920
+ dir: path63.resolve(dir),
5918
5921
  namespace: ruleNamespace(json.name),
5919
5922
  local,
5920
5923
  private: json.private === true,
@@ -5928,7 +5931,7 @@ ${local}`;
5928
5931
  if (raw !== void 0) {
5929
5932
  const ignored = [];
5930
5933
  try {
5931
- pkg.declaration = validateDeclaration(raw, json.name, path62.resolve(dir), ignored);
5934
+ pkg.declaration = validateDeclaration(raw, json.name, path63.resolve(dir), ignored);
5932
5935
  if (ignored.length) pkg.ignored = ignored;
5933
5936
  } catch (err) {
5934
5937
  pkg.error = err.message;
@@ -5947,14 +5950,14 @@ function discoverPackages(root) {
5947
5950
  for (const dir of installed) {
5948
5951
  let scope;
5949
5952
  try {
5950
- scope = path62.dirname(realpathSync(dir));
5953
+ scope = path63.dirname(realpathSync(dir));
5951
5954
  } catch {
5952
5955
  continue;
5953
5956
  }
5954
- if (path62.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
5957
+ if (path63.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
5955
5958
  for (const entry of readdirSync(scope)) {
5956
5959
  if (byName.has(`@marktiderman/${entry}`) || !GENESIS.test(`@marktiderman/${entry}`)) continue;
5957
- const pkg = readDeclaringPackage(path62.join(scope, entry), false);
5960
+ const pkg = readDeclaringPackage(path63.join(scope, entry), false);
5958
5961
  if (pkg) byName.set(pkg.name, pkg);
5959
5962
  }
5960
5963
  }
@@ -6195,10 +6198,10 @@ var init_package_rules = __esm({
6195
6198
  });
6196
6199
  function sourceFiles(dir, rel = "") {
6197
6200
  const out = [];
6198
- for (const entry of readdirSync(path62.join(dir, rel)).sort()) {
6201
+ for (const entry of readdirSync(path63.join(dir, rel)).sort()) {
6199
6202
  if (entry.startsWith(".") || SKIP_DIRS2.has(entry)) continue;
6200
6203
  const child = rel ? `${rel}/${entry}` : entry;
6201
- const stat = lstatSync(path62.join(dir, child));
6204
+ const stat = lstatSync(path63.join(dir, child));
6202
6205
  if (stat.isSymbolicLink()) continue;
6203
6206
  if (stat.isDirectory()) out.push(...sourceFiles(dir, child));
6204
6207
  else if (SOURCE.test(entry) && !entry.endsWith(".d.ts")) out.push(child);
@@ -6221,13 +6224,13 @@ function matchPattern(pattern, spec) {
6221
6224
  return spec.startsWith(head) && spec.endsWith(tail) && spec.length >= head.length + tail.length ? spec.slice(head.length, spec.length - tail.length) : null;
6222
6225
  }
6223
6226
  function tsconfigPaths(dir) {
6224
- const file = path62.join(dir, "tsconfig.json");
6227
+ const file = path63.join(dir, "tsconfig.json");
6225
6228
  if (!existsSync(file)) return [];
6226
6229
  try {
6227
6230
  const text = readFileSync(file, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[\s{,[])\/\/[^\n]*/g, "$1").replace(/,(\s*[}\]])/g, "$1");
6228
6231
  const options = JSON.parse(text).compilerOptions ?? {};
6229
- const base = path62.resolve(dir, options.baseUrl ?? ".");
6230
- return Object.entries(options.paths ?? {}).map(([pattern, targets]) => ({ pattern, targets: targets.map((t) => path62.resolve(base, t)) }));
6232
+ const base = path63.resolve(dir, options.baseUrl ?? ".");
6233
+ return Object.entries(options.paths ?? {}).map(([pattern, targets]) => ({ pattern, targets: targets.map((t) => path63.resolve(base, t)) }));
6231
6234
  } catch {
6232
6235
  return [];
6233
6236
  }
@@ -6241,8 +6244,8 @@ function checkImports2(ctx, pkg, json) {
6241
6244
  const hit = matchPattern(pattern, spec);
6242
6245
  if (hit === null) continue;
6243
6246
  return targets.some((t) => {
6244
- const rel = path62.relative(pkg.dir, t.replace("*", hit));
6245
- return !rel.startsWith("..") && !path62.isAbsolute(rel);
6247
+ const rel = path63.relative(pkg.dir, t.replace("*", hit));
6248
+ return !rel.startsWith("..") && !path63.isAbsolute(rel);
6246
6249
  });
6247
6250
  }
6248
6251
  return null;
@@ -6255,7 +6258,7 @@ function checkImports2(ctx, pkg, json) {
6255
6258
  ...Object.keys(json.optionalDependencies ?? {})
6256
6259
  ]);
6257
6260
  for (const file of sourceFiles(pkg.dir)) {
6258
- const code = stripForImports(readFileSync(path62.join(pkg.dir, file), "utf8"));
6261
+ const code = stripForImports(readFileSync(path63.join(pkg.dir, file), "utf8"));
6259
6262
  if (code === null) continue;
6260
6263
  const at = `${pkg.rel}/${file}`;
6261
6264
  const typeOnly = [...code.matchAll(TYPE_ONLY)].map((m) => [m.index, m.index + m[0].length]);
@@ -6280,9 +6283,9 @@ function checkImports2(ctx, pkg, json) {
6280
6283
  continue;
6281
6284
  }
6282
6285
  if (spec.startsWith(".")) {
6283
- const target = path62.resolve(pkg.dir, path62.dirname(file), spec);
6284
- const rel = path62.relative(pkg.dir, target);
6285
- if (rel.startsWith("..") || path62.isAbsolute(rel)) {
6286
+ const target = path63.resolve(pkg.dir, path63.dirname(file), spec);
6287
+ const rel = path63.relative(pkg.dir, target);
6288
+ if (rel.startsWith("..") || path63.isAbsolute(rel)) {
6286
6289
  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` });
6287
6290
  }
6288
6291
  continue;
@@ -6318,12 +6321,12 @@ function checkMigrations(ctx, pkg, json, locals) {
6318
6321
  const from = own ? "" : ` (in ${m.package})`;
6319
6322
  if (typeof m.file === "string" && typeof m.test !== "string") {
6320
6323
  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` });
6321
- } else if (typeof m.test === "string" && !existsSync(path62.join(home, m.test))) {
6324
+ } else if (typeof m.test === "string" && !existsSync(path63.join(home, m.test))) {
6322
6325
  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` });
6323
6326
  }
6324
6327
  }
6325
6328
  }
6326
- const dir = path62.join(pkg.dir, "migrations");
6329
+ const dir = path63.join(pkg.dir, "migrations");
6327
6330
  if (!existsSync(dir)) return;
6328
6331
  const seen = /* @__PURE__ */ new Map();
6329
6332
  for (const name of readdirSync(dir).sort()) {
@@ -6332,7 +6335,7 @@ function checkMigrations(ctx, pkg, json, locals) {
6332
6335
  const other = seen.get(m[1]);
6333
6336
  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` });
6334
6337
  else seen.set(m[1], name);
6335
- if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path62.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
6338
+ if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path63.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
6336
6339
  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")})` });
6337
6340
  }
6338
6341
  }
@@ -6346,7 +6349,7 @@ function checkExports(ctx, pkg, json) {
6346
6349
  walk4(json.exports);
6347
6350
  for (const t of targets) {
6348
6351
  if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
6349
- if (!existsSync(path62.join(pkg.dir, t))) {
6352
+ if (!existsSync(path63.join(pkg.dir, t))) {
6350
6353
  ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
6351
6354
  }
6352
6355
  }
@@ -6364,11 +6367,11 @@ function checkBlocks(ctx, pkg, json) {
6364
6367
  function checkTaggedTests(ctx, pkg) {
6365
6368
  const tests = sourceFiles(pkg.dir).filter((f) => /\.(test|spec)\.[cm]?[jt]sx?$/.test(f));
6366
6369
  if (!tests.length) return;
6367
- const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path62.join(pkg.dir, f), "utf8")));
6370
+ const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path63.join(pkg.dir, f), "utf8")));
6368
6371
  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>` });
6369
6372
  }
6370
6373
  function checkRegistered(ctx, pkg) {
6371
- const file = path62.join(ctx.root, "features.json");
6374
+ const file = path63.join(ctx.root, "features.json");
6372
6375
  if (!existsSync(file)) return;
6373
6376
  let doc;
6374
6377
  try {
@@ -6378,7 +6381,7 @@ function checkRegistered(ctx, pkg) {
6378
6381
  }
6379
6382
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
6380
6383
  const forms = /* @__PURE__ */ new Set([pkg.rel]);
6381
- if (top) forms.add(path62.relative(top, realpathSync(pkg.dir)).split(path62.sep).join("/"));
6384
+ if (top) forms.add(path63.relative(top, realpathSync(pkg.dir)).split(path63.sep).join("/"));
6382
6385
  const covered = (doc.features ?? []).some(
6383
6386
  (f) => (f.links?.code ?? []).some((c) => {
6384
6387
  const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
@@ -6408,8 +6411,8 @@ function mergeBaseOf(root, base) {
6408
6411
  function checkChanges(ctx, pkg, json, base, mergeBase) {
6409
6412
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
6410
6413
  if (!top) return;
6411
- const appRelative = (fromTop) => path62.relative(realpathSync(ctx.root), path62.join(top, fromTop)).split(path62.sep).join("/");
6412
- const inRepo = path62.relative(top, realpathSync(pkg.dir)).split(path62.sep).join("/");
6414
+ const appRelative = (fromTop) => path63.relative(realpathSync(ctx.root), path63.join(top, fromTop)).split(path63.sep).join("/");
6415
+ const inRepo = path63.relative(top, realpathSync(pkg.dir)).split(path63.sep).join("/");
6413
6416
  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");
6414
6417
  const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
6415
6418
  const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
@@ -6432,11 +6435,11 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
6432
6435
  const now = typeof json.version === "string" ? parseVersion(json.version) : null;
6433
6436
  const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
6434
6437
  const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
6435
- 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) => path62.join(top, f)) : [];
6438
+ 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) => path63.join(top, f)) : [];
6436
6439
  const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
6437
6440
  const named = naming.length > 0;
6438
6441
  if (named && !naming.some((p) => /^Features:\s*\S/m.test(readFileSync(p, "utf8")))) {
6439
- ctx.report({ rule: "package-unversioned-change", level: "warn", file: path62.relative(realpathSync(ctx.root), naming[0]), message: `the changeset for ${pkg.name} has no "Features:" line; name the features it changes` });
6442
+ ctx.report({ rule: "package-unversioned-change", level: "warn", file: path63.relative(realpathSync(ctx.root), naming[0]), message: `the changeset for ${pkg.name} has no "Features:" line; name the features it changes` });
6440
6443
  }
6441
6444
  let jsonBefore = null;
6442
6445
  try {
@@ -6446,7 +6449,7 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
6446
6449
  }
6447
6450
  const raw = json;
6448
6451
  if (jsonBefore && (JSON.stringify(jsonBefore.genesis) !== JSON.stringify(raw.genesis) || JSON.stringify(jsonBefore.exports) !== JSON.stringify(raw.exports))) {
6449
- const appInRepo = path62.relative(top, realpathSync(ctx.root)).split(path62.sep).join("/");
6452
+ const appInRepo = path63.relative(top, realpathSync(ctx.root)).split(path63.sep).join("/");
6450
6453
  const candidates = [.../* @__PURE__ */ new Set(["features.ts", "src/features.ts", ...appInRepo ? [`${appInRepo}/features.ts`, `${appInRepo}/src/features.ts`] : []])];
6451
6454
  const registry = (git(top, ["diff", "--name-only", mergeBase, "--", ...candidates]) ?? "").trim();
6452
6455
  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` });
@@ -6497,7 +6500,7 @@ function checkPackagesPack(ctx) {
6497
6500
  ctx.report({ rule: "package-unversioned-change", level: base ? "warn" : "info", file: "genesis.config.json", message: `change gate skipped: ${merge.reason}` });
6498
6501
  }
6499
6502
  for (const pkg of packages) {
6500
- const json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
6503
+ const json = JSON.parse(readFileSync(path63.join(pkg.dir, "package.json"), "utf8"));
6501
6504
  checkImports2(ctx, pkg, json);
6502
6505
  checkExports(ctx, pkg, json);
6503
6506
  checkBlocks(ctx, pkg, json);
@@ -6696,9 +6699,9 @@ function checkSupabasePack(ctx) {
6696
6699
  if (databaseElsewhere(ctx.root)) return;
6697
6700
  const settings2 = ctx.config.supabase ?? {};
6698
6701
  const dir = settings2.migrations ?? DEFAULT_MIGRATIONS;
6699
- const abs = path62.join(ctx.root, dir);
6702
+ const abs = path63.join(ctx.root, dir);
6700
6703
  if (!existsSync(abs)) throw new DoctorConfigError(`the supabase pack reads ${dir}, which doesn't exist; set doctor.supabase.migrations`);
6701
- const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path62.join(abs, n), "utf8")) }));
6704
+ const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path63.join(abs, n), "utf8")) }));
6702
6705
  const exposed = new Set((settings2.exposedSchemas ?? DEFAULT_EXPOSED).map((s) => s.toLowerCase()));
6703
6706
  const base = settings2.base ?? DEFAULT_BASE;
6704
6707
  const view = gitView(ctx.root, dir, base);
@@ -6715,7 +6718,7 @@ function checkSupabasePack(ctx) {
6715
6718
  }
6716
6719
  }
6717
6720
  const since = settings2.since;
6718
- const afterSince = (file) => since === void 0 || path62.posix.basename(file) >= since;
6721
+ const afterSince = (file) => since === void 0 || path63.posix.basename(file) >= since;
6719
6722
  if ("reason" in view && since === void 0) {
6720
6723
  ctx.report({
6721
6724
  rule: "migration-grants",
@@ -6769,8 +6772,8 @@ function checkExposedSchemasCreatedLater(ctx, dir, migrations, configured, branc
6769
6772
  if (m && m[1] !== "authorization" && !created.has(m[1])) created.set(m[1], { file, line });
6770
6773
  }
6771
6774
  }
6772
- const tomlFile = path62.posix.join(path62.posix.dirname(dir), "config.toml");
6773
- const tomlText = existsSync(path62.join(ctx.root, tomlFile)) ? readFileSync(path62.join(ctx.root, tomlFile), "utf8") : null;
6775
+ const tomlFile = path63.posix.join(path63.posix.dirname(dir), "config.toml");
6776
+ const tomlText = existsSync(path63.join(ctx.root, tomlFile)) ? readFileSync(path63.join(ctx.root, tomlFile), "utf8") : null;
6774
6777
  const api2 = tomlText === null ? null : apiSchemas(tomlText);
6775
6778
  const sources = [];
6776
6779
  if (api2?.enabled) for (const schema of api2.schemas) sources.push({ schema, file: tomlFile, line: api2.line, where: `${tomlFile} [api] schemas` });
@@ -7077,18 +7080,18 @@ var init_supabase = __esm({
7077
7080
  }
7078
7081
  });
7079
7082
  function nodeModulesOf(dir) {
7080
- const parent = path62.dirname(dir);
7081
- return path62.basename(parent).startsWith("@") ? path62.dirname(parent) : parent;
7083
+ const parent = path63.dirname(dir);
7084
+ return path63.basename(parent).startsWith("@") ? path63.dirname(parent) : parent;
7082
7085
  }
7083
7086
  function packagesIn(nodeModules) {
7084
7087
  if (!existsSync(nodeModules)) return [];
7085
7088
  const out = [];
7086
7089
  for (const entry of readdirSync(nodeModules)) {
7087
7090
  if (entry.startsWith(".")) continue;
7088
- const p = path62.join(nodeModules, entry);
7091
+ const p = path63.join(nodeModules, entry);
7089
7092
  if (entry.startsWith("@")) {
7090
7093
  try {
7091
- for (const sub of readdirSync(p)) out.push(path62.join(p, sub));
7094
+ for (const sub of readdirSync(p)) out.push(path63.join(p, sub));
7092
7095
  } catch {
7093
7096
  }
7094
7097
  } else {
@@ -7100,7 +7103,7 @@ function packagesIn(nodeModules) {
7100
7103
  function genesisInstalls(root) {
7101
7104
  const copies = /* @__PURE__ */ new Map();
7102
7105
  const realRoot = real(root);
7103
- const rel = (abs) => path62.relative(realRoot, abs).split(path62.sep).join("/") || ".";
7106
+ const rel = (abs) => path63.relative(realRoot, abs).split(path63.sep).join("/") || ".";
7104
7107
  const via = /* @__PURE__ */ new Map();
7105
7108
  const record = (real2, manifest, by, range, root2) => {
7106
7109
  let copy = copies.get(real2);
@@ -7145,7 +7148,7 @@ function genesisInstalls(root) {
7145
7148
  if (!dir) return null;
7146
7149
  if (!ownInstall || name in declared) return dir;
7147
7150
  const realDir = real(dir);
7148
- if (realDir.startsWith(realRoot + path62.sep)) return dir;
7151
+ if (realDir.startsWith(realRoot + path63.sep)) return dir;
7149
7152
  return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
7150
7153
  };
7151
7154
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
@@ -7153,7 +7156,7 @@ function genesisInstalls(root) {
7153
7156
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
7154
7157
  });
7155
7158
  const app = readManifest(root);
7156
- const ownInstall = LOCKFILES.some((f) => existsSync(path62.join(root, f)));
7159
+ const ownInstall = LOCKFILES.some((f) => existsSync(path63.join(root, f)));
7157
7160
  const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
7158
7161
  const declaredDev = Object.entries(app?.devDependencies ?? {});
7159
7162
  const runtimeDeps = {
@@ -7164,11 +7167,11 @@ function genesisInstalls(root) {
7164
7167
  };
7165
7168
  const devDeps = Object.fromEntries(declaredDev.filter(([n]) => NON_SHIPPING.test(n) && !(n in runtimeDeps)));
7166
7169
  walk4("runtime", rootsOf(runtimeDeps, "the app"));
7167
- const top = path62.join(root, "node_modules");
7170
+ const top = path63.join(root, "node_modules");
7168
7171
  walk4(
7169
7172
  "hoisted",
7170
7173
  packagesIn(top).filter((dir) => {
7171
- const name = path62.relative(top, dir).split(path62.sep).join("/");
7174
+ const name = path63.relative(top, dir).split(path63.sep).join("/");
7172
7175
  return !(name in runtimeDeps) && !(name in devDeps);
7173
7176
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
7174
7177
  );
@@ -7210,7 +7213,7 @@ function checkDuplicatePackages(ctx) {
7210
7213
  }
7211
7214
  }
7212
7215
  function checkPeerRanges(ctx) {
7213
- const rel = (abs) => path62.relative(ctx.root, abs).split(path62.sep).join("/");
7216
+ const rel = (abs) => path63.relative(ctx.root, abs).split(path63.sep).join("/");
7214
7217
  for (const copies of genesisInstalls(ctx.root).values()) {
7215
7218
  for (const copy of copies) {
7216
7219
  const dir = copy.absolutePath;
@@ -7243,7 +7246,7 @@ var init_installs = __esm({
7243
7246
  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)$/;
7244
7247
  readManifest = (dir) => {
7245
7248
  try {
7246
- return JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
7249
+ return JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
7247
7250
  } catch {
7248
7251
  return null;
7249
7252
  }
@@ -7442,11 +7445,11 @@ function appScripts(root) {
7442
7445
  const out = [];
7443
7446
  const walk4 = (dir) => {
7444
7447
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
7445
- const abs = path62.join(dir, entry.name);
7448
+ const abs = path63.join(dir, entry.name);
7446
7449
  if (entry.isDirectory()) {
7447
7450
  if (!SKIP_DIRS3.has(entry.name)) walk4(abs);
7448
7451
  } else if (entry.isFile() && SCRIPT2.test(entry.name) && statSync(abs).size <= MAX_BYTES) {
7449
- out.push(path62.relative(root, abs).split(path62.sep).join("/"));
7452
+ out.push(path63.relative(root, abs).split(path63.sep).join("/"));
7450
7453
  }
7451
7454
  }
7452
7455
  };
@@ -7759,7 +7762,7 @@ var init_doctor_rule_codemods = __esm({
7759
7762
  run({ root, dryRun, log }) {
7760
7763
  const changed = [];
7761
7764
  for (const rel of appScripts(root).filter((f) => /\.[jt]sx$/.test(f))) {
7762
- const abs = path62.join(root, rel);
7765
+ const abs = path63.join(root, rel);
7763
7766
  const text = readFileSync(abs, "utf8");
7764
7767
  const next = rewriteOverlayHeights(text);
7765
7768
  if (next === text) continue;
@@ -7786,7 +7789,7 @@ var init_doctor_rule_codemods = __esm({
7786
7789
  const changed = [];
7787
7790
  for (const rel of appScripts(root)) {
7788
7791
  if (/(?:^|\/)__tests__\/|\.test\.[jt]sx?$/.test(rel)) continue;
7789
- const abs = path62.join(root, rel);
7792
+ const abs = path63.join(root, rel);
7790
7793
  const text = readFileSync(abs, "utf8");
7791
7794
  if (!text.includes("expo-haptics")) continue;
7792
7795
  const result = rewriteHaptics(text);
@@ -8002,11 +8005,11 @@ var init_scope_names = __esm({
8002
8005
  }
8003
8006
  });
8004
8007
  function findEslintConfig(root) {
8005
- return FLAT_CONFIG_FILES.find((name) => existsSync(path62.join(root, name))) ?? null;
8008
+ return FLAT_CONFIG_FILES.find((name) => existsSync(path63.join(root, name))) ?? null;
8006
8009
  }
8007
8010
  function readPackageJson(root) {
8008
8011
  try {
8009
- return JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
8012
+ return JSON.parse(readFileSync(path63.join(root, "package.json"), "utf8"));
8010
8013
  } catch {
8011
8014
  return null;
8012
8015
  }
@@ -8063,7 +8066,7 @@ function spreadLine(platform, local = "genesis") {
8063
8066
  }
8064
8067
  function addGenesisLint(text, platform, file = "eslint.config.js") {
8065
8068
  const code = maskCode(text);
8066
- const ext = path62.extname(file);
8069
+ const ext = path63.extname(file);
8067
8070
  const exportsCjs = [...code.matchAll(/(?:^|[\n;])\s*module\.exports\s*=\s*/g)];
8068
8071
  const exportsEsm = [...code.matchAll(/(?:^|[\n;])\s*export\s+default\s+/g)];
8069
8072
  const kind = ext === ".cjs" || ext === ".cts" ? "cjs" : ext === ".mjs" || ext === ".mts" ? "esm" : exportsCjs.length && !exportsEsm.length ? "cjs" : "esm";
@@ -8235,7 +8238,7 @@ var init_codemods = __esm({
8235
8238
  let readsId = false;
8236
8239
  let augmented = false;
8237
8240
  for (const rel of appScripts(root)) {
8238
- const abs = path62.join(root, rel);
8241
+ const abs = path63.join(root, rel);
8239
8242
  const text = readFileSync(abs, "utf8");
8240
8243
  if (augmentsResourceScope(text)) augmented = true;
8241
8244
  if (!IMPORTS_GENESIS.test(text)) continue;
@@ -8263,7 +8266,7 @@ var init_codemods = __esm({
8263
8266
  const changed = [];
8264
8267
  const pkg = readPackageJson(root);
8265
8268
  const platform = appPlatform(pkg);
8266
- const abs = path62.join(root, file);
8269
+ const abs = path63.join(root, file);
8267
8270
  const text = readFileSync(abs, "utf8");
8268
8271
  if (!usesGenesisLint(text)) {
8269
8272
  const result = addGenesisLint(text, platform, file);
@@ -8279,7 +8282,7 @@ ${manualLines(result.kind, platform).map((l) => ` ${l}`).join("\n")}`);
8279
8282
  }
8280
8283
  }
8281
8284
  if (platform === "native" && pkg && !hasTestingLibrary(pkg)) {
8282
- const pkgFile = path62.join(root, "package.json");
8285
+ const pkgFile = path63.join(root, "package.json");
8283
8286
  const raw = readFileSync(pkgFile, "utf8");
8284
8287
  const indent = /^[ \t]+(?=")/m.exec(raw)?.[0] ?? " ";
8285
8288
  const json = JSON.parse(raw);
@@ -8302,7 +8305,7 @@ ${manualLines(result.kind, platform).map((l) => ` ${l}`).join("\n")}`);
8302
8305
  run({ root, dryRun }) {
8303
8306
  const changed = [];
8304
8307
  for (const rel of appScripts(root)) {
8305
- const abs = path62.join(root, rel);
8308
+ const abs = path63.join(root, rel);
8306
8309
  const text = readFileSync(abs, "utf8");
8307
8310
  if (!text.includes("NativeComposerBar")) continue;
8308
8311
  const next = rewriteComposerBarEmpty(text);
@@ -8392,7 +8395,7 @@ function checkTreeViews(ctx) {
8392
8395
  function moduleFiles(ctx) {
8393
8396
  const scanned = new Set(ctx.files.map((f) => f.path));
8394
8397
  const ignored = globMatcher([...DEFAULT_IGNORE, ...ctx.config.ignore ?? []]);
8395
- const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path62.join(ctx.root, rel), "utf8"), true) }));
8398
+ const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path63.join(ctx.root, rel), "utf8"), true) }));
8396
8399
  return [...ctx.files.filter((f) => SCRIPT_EXTS5.has(f.ext)), ...extra];
8397
8400
  }
8398
8401
  function checkStudioServerImports(ctx) {
@@ -8422,7 +8425,7 @@ function checkStudioServerImports(ctx) {
8422
8425
  }
8423
8426
  function checkRemovedScopeNames(ctx) {
8424
8427
  let augmentedMemo;
8425
- const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path62.join(ctx.root, rel), "utf8")));
8428
+ const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path63.join(ctx.root, rel), "utf8")));
8426
8429
  for (const file of ctx.files) {
8427
8430
  if (!SCRIPT_EXTS5.has(file.ext)) continue;
8428
8431
  for (const hit of findRemovedScopeNames(file.code)) {
@@ -8550,8 +8553,8 @@ function clientLayer(root, files) {
8550
8553
  } catch {
8551
8554
  }
8552
8555
  const inside3 = `${dir}/`;
8553
- const present = files.some((f) => f.path.startsWith(inside3) && /(^|\/)resource-view\.(t|j)sx?$/.test(f.path)) || existsSync(path62.join(root, dir, "resource-view.tsx"));
8554
- const recordWrapper = files.some((f) => f.path.startsWith(inside3) && /(^|\/)record-view\.(t|j)sx?$/.test(f.path)) || existsSync(path62.join(root, dir, "record-view.tsx"));
8556
+ const present = files.some((f) => f.path.startsWith(inside3) && /(^|\/)resource-view\.(t|j)sx?$/.test(f.path)) || existsSync(path63.join(root, dir, "resource-view.tsx"));
8557
+ const recordWrapper = files.some((f) => f.path.startsWith(inside3) && /(^|\/)record-view\.(t|j)sx?$/.test(f.path)) || existsSync(path63.join(root, dir, "record-view.tsx"));
8555
8558
  return { dir, present, recordWrapper };
8556
8559
  }
8557
8560
  function genesisImports(code, uiPackage) {
@@ -8627,8 +8630,8 @@ function declaredAtTop(code, name) {
8627
8630
  }
8628
8631
  function importedNames(filePath, code) {
8629
8632
  const out = /* @__PURE__ */ new Map();
8630
- const dir = path62.posix.dirname(filePath);
8631
- const where2 = (spec) => spec.startsWith(".") ? path62.posix.normalize(path62.posix.join(dir, spec)).replace(/\.(t|j)sx?$/, "").replace(/\/index$/, "") : spec;
8633
+ const dir = path63.posix.dirname(filePath);
8634
+ const where2 = (spec) => spec.startsWith(".") ? path63.posix.normalize(path63.posix.join(dir, spec)).replace(/\.(t|j)sx?$/, "").replace(/\/index$/, "") : spec;
8632
8635
  for (const m of code.matchAll(/import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
8633
8636
  for (const part of m[1].split(",")) {
8634
8637
  const spec = part.trim().replace(/^type\s+/, "");
@@ -8653,6 +8656,175 @@ var init_client_layer = __esm({
8653
8656
  SHOWN_OR_TRIED = /(\.stories\.|\.test\.|\.spec\.|(^|\/)__tests__\/)/;
8654
8657
  }
8655
8658
  });
8659
+ function balanced(code, start) {
8660
+ const open = code[start];
8661
+ const close = open === "{" ? "}" : open === "(" ? ")" : open === "[" ? "]" : "";
8662
+ if (!close) return "";
8663
+ const blank = blankStrings(code);
8664
+ let depth = 0;
8665
+ for (let i = start; i < blank.length; i++) {
8666
+ const ch = blank[i];
8667
+ if (ch === "{" || ch === "(" || ch === "[") depth++;
8668
+ else if (ch === "}" || ch === ")" || ch === "]") {
8669
+ depth--;
8670
+ if (depth === 0) return ch === close ? code.slice(start, i + 1) : "";
8671
+ }
8672
+ }
8673
+ return "";
8674
+ }
8675
+ function testFiles(root) {
8676
+ const out = [];
8677
+ const walk4 = (dir) => {
8678
+ let entries;
8679
+ try {
8680
+ entries = readdirSync(dir, { withFileTypes: true });
8681
+ } catch {
8682
+ return;
8683
+ }
8684
+ for (const entry of entries) {
8685
+ if (entry.isDirectory()) {
8686
+ if (!SKIP_DIRS4.has(entry.name) && !entry.name.startsWith(".")) walk4(path63.join(dir, entry.name));
8687
+ continue;
8688
+ }
8689
+ const abs = path63.join(dir, entry.name);
8690
+ const rel = path63.relative(root, abs).split(path63.sep).join("/");
8691
+ if (SCRIPT_EXTS7.has(path63.extname(entry.name)) && TEST_FILE.test(rel)) out.push(abs);
8692
+ }
8693
+ };
8694
+ walk4(root);
8695
+ return out;
8696
+ }
8697
+ function initializer(code, blank, name) {
8698
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8699
+ const decl = new RegExp(`\\b(const|let|var)\\s+${escaped}(?![\\w$])[^=;]*=\\s*\\{`).exec(blank);
8700
+ if (!decl) return null;
8701
+ const text = balanced(code, decl.index + decl[0].length - 1);
8702
+ return text ? { text, keyword: decl[1], at: decl.index } : null;
8703
+ }
8704
+ function objectDeclares(object) {
8705
+ const blank = blankStrings(object);
8706
+ let depth = 0;
8707
+ let declaredAt = -1;
8708
+ let lastAccess = -1;
8709
+ let lastSpread = -1;
8710
+ for (let i = 0; i < blank.length; i++) {
8711
+ const ch = blank[i];
8712
+ if (ch === "{" || ch === "(" || ch === "[") depth++;
8713
+ else if (ch === "}" || ch === ")" || ch === "]") depth--;
8714
+ else if (depth === 1 && blank.startsWith("...", i)) lastSpread = i;
8715
+ else if (depth === 1 && blank[i] === object[i] && /[\s{,]/.test(blank[i - 1] ?? " ") && /^(["'`]?)access\1\s*:/.test(object.slice(i))) {
8716
+ lastAccess = i;
8717
+ const value = /^(["'`]?)access\1\s*:\s*(["'`])([^"'`]*)\2/.exec(object.slice(i));
8718
+ declaredAt = value?.[3] === "declared" ? i : -1;
8719
+ }
8720
+ }
8721
+ return declaredAt !== -1 && declaredAt === lastAccess && lastSpread < declaredAt;
8722
+ }
8723
+ function inlineDeclares(call) {
8724
+ const blank = blankStrings(call);
8725
+ let depth = 0;
8726
+ for (let i = 0; i < blank.length; i++) {
8727
+ const ch = blank[i];
8728
+ if (ch === "{" && depth === 1 && objectDeclares(balanced(call, i))) return true;
8729
+ if (ch === "{" || ch === "(" || ch === "[") depth++;
8730
+ else if (ch === "}" || ch === ")" || ch === "]") depth--;
8731
+ }
8732
+ return false;
8733
+ }
8734
+ function optionsConstDeclares(code, blank, call) {
8735
+ const args = blankStrings(call).slice(1, -1);
8736
+ for (const [, name] of args.matchAll(/(?:^|,)\s*([A-Za-z_$][\w$]*)\s*(?=,|$)/g)) {
8737
+ const found = initializer(code, blank, name);
8738
+ if (!found || !objectDeclares(found.text)) continue;
8739
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8740
+ const reassigned = found.keyword !== "const" && new RegExp(`(?<![\\w$.])${escaped}\\s*=(?!=)`, "g").test(blank.slice(found.at + found.keyword.length + 1 + name.length));
8741
+ const changed = new RegExp(
8742
+ `(?<![\\w$.])${escaped}\\s*(?:\\.\\s*access|\\[[^\\]]*\\])\\s*=(?!=)|\\bdelete\\s+${escaped}\\s*(?:\\.\\s*access|\\[)|Object\\.assign\\(\\s*${escaped}(?![\\w$])`
8743
+ ).test(blank);
8744
+ if (!reassigned && !changed) return true;
8745
+ }
8746
+ return false;
8747
+ }
8748
+ function coverageTested(root) {
8749
+ for (const abs of testFiles(root)) {
8750
+ let code;
8751
+ try {
8752
+ code = stripBlockComments(readFileSync(abs, "utf8"), true);
8753
+ } catch {
8754
+ continue;
8755
+ }
8756
+ if (!code.includes("expectAccessRulesCover")) continue;
8757
+ if (/\bexpectAccessRulesCover\s*\(/.test(blankStrings(code))) return true;
8758
+ }
8759
+ return false;
8760
+ }
8761
+ function checkDataAccess(ctx) {
8762
+ for (const file of ctx.files) {
8763
+ if (!SCRIPT_EXTS7.has(file.ext)) continue;
8764
+ const blank = blankStrings(file.code);
8765
+ for (const m of blank.matchAll(/\bcreateSupabaseProvider\s*\(/g)) {
8766
+ const call = balanced(file.code, (m.index ?? 0) + m[0].length - 1);
8767
+ if (inlineDeclares(call) || optionsConstDeclares(file.code, blank, call)) continue;
8768
+ ctx.report({
8769
+ rule: "data/declared-access",
8770
+ level: "warn",
8771
+ file: file.path,
8772
+ line: lineAt(file.code, m.index ?? 0),
8773
+ subject: "createSupabaseProvider",
8774
+ message: `leaves its resources free to read and write their tables undeclared. Pass access: "declared", give each resource its read (source: a view or a function) and its writes (writes: named database functions), and opt a table in only with table: { \u2026, why } (${DOCS})`
8775
+ });
8776
+ }
8777
+ if (file.path.startsWith("supabase/") || file.path.includes("/supabase/functions/")) continue;
8778
+ for (const m of file.code.matchAll(TABLE_WRITE)) {
8779
+ const at = m.index ?? 0;
8780
+ if (blank[at] !== ".") continue;
8781
+ if (STORAGE_BEFORE.test(blank.slice(Math.max(0, at - 40), at))) continue;
8782
+ ctx.report({
8783
+ rule: "data/declared-access",
8784
+ level: "warn",
8785
+ file: file.path,
8786
+ line: lineAt(file.code, at),
8787
+ subject: `${m[2]}.${m[3]}`,
8788
+ message: `writes the ${m[2]} table directly (${m[3]}). Write through a named database function (the resource's writes, or a call to it), which holds the access rule; a write that must stay on the table is an allow entry for data/declared-access with its reason (${DOCS})`
8789
+ });
8790
+ }
8791
+ }
8792
+ const providers = providerCalls(ctx.files);
8793
+ if (providers.length === 0 || coverageTested(ctx.root)) return;
8794
+ const first = providers[0];
8795
+ ctx.report({
8796
+ rule: "data/access-rule-tests",
8797
+ level: "warn",
8798
+ file: first.file,
8799
+ line: first.line,
8800
+ subject: "expectAccessRulesCover",
8801
+ message: `no test checks that every database function the provider declares has an access-rule test. Add expectAccessRulesCover(providerOptions, [/* each accessRules spec */]) (@marktiderman/genesis-core/testing) to a test file: it fails for each declared function without one (${DOCS})`
8802
+ });
8803
+ }
8804
+ function providerCalls(files) {
8805
+ const out = [];
8806
+ for (const file of files) {
8807
+ if (!SCRIPT_EXTS7.has(file.ext)) continue;
8808
+ for (const m of blankStrings(file.code).matchAll(/\bcreateSupabaseProvider\s*\(/g)) {
8809
+ out.push({ file: file.path, line: lineAt(file.code, m.index ?? 0) });
8810
+ }
8811
+ }
8812
+ return out;
8813
+ }
8814
+ var SCRIPT_EXTS7, SKIP_DIRS4, TEST_FILE, DOCS, TABLE_WRITE, STORAGE_BEFORE;
8815
+ var init_data_access = __esm({
8816
+ "src/doctor/data-access.ts"() {
8817
+ init_color_literals();
8818
+ init_scan();
8819
+ init_source();
8820
+ SCRIPT_EXTS7 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
8821
+ SKIP_DIRS4 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", "coverage", ".expo"]);
8822
+ TEST_FILE = /(^|\/)(__tests__\/|[^/]+\.(test|spec)\.[cm]?[jt]sx?$)/;
8823
+ DOCS = "docs/DATA-ACCESS.md";
8824
+ TABLE_WRITE = /\.from\(\s*(["'`])([\w.]+)\1\s*\)\s*\.\s*(insert|update|upsert|delete)\s*\(/g;
8825
+ STORAGE_BEFORE = /\bstorage\s*\??\.?\s*$/;
8826
+ }
8827
+ });
8656
8828
  function specifierParts(spec) {
8657
8829
  return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
8658
8830
  }
@@ -8695,16 +8867,16 @@ function genesisNamedImports(source) {
8695
8867
  }
8696
8868
  function declarationFiles(dir, out = []) {
8697
8869
  for (const name of readdirSync(dir)) {
8698
- const full = path62.join(dir, name);
8870
+ const full = path63.join(dir, name);
8699
8871
  if (statSync(full).isDirectory()) declarationFiles(full, out);
8700
8872
  else if (/\.d\.[cm]?ts$/.test(name)) out.push(full);
8701
8873
  }
8702
8874
  return out;
8703
8875
  }
8704
8876
  function readPackageTags(dir) {
8705
- const pkg = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
8877
+ const pkg = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
8706
8878
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
8707
- const dist = path62.join(dir, "dist");
8879
+ const dist = path63.join(dir, "dist");
8708
8880
  if (!existsSync(dist)) return tags;
8709
8881
  for (const file of declarationFiles(dist)) {
8710
8882
  const text = readFileSync(file, "utf8");
@@ -8722,7 +8894,7 @@ function entryFile(tags, pkg, specifier) {
8722
8894
  const subpath = `.${specifier.slice(pkg.length)}` || ".";
8723
8895
  const target = tags.exports[subpath === "." ? "." : subpath];
8724
8896
  const types = typeof target === "object" && target ? target.types : null;
8725
- return typeof types === "string" ? path62.join(tags.dir, types) : null;
8897
+ return typeof types === "string" ? path63.join(tags.dir, types) : null;
8726
8898
  }
8727
8899
  function tagFor(tags, entry, name) {
8728
8900
  if (entry && tags.declaredIn.get(name)?.includes(entry)) return tags.byFile.get(entry)?.get(name);
@@ -8740,7 +8912,7 @@ function checkStabilityImports(ctx) {
8740
8912
  return cache2.get(pkg);
8741
8913
  };
8742
8914
  for (const file of ctx.files) {
8743
- if (!SCRIPT_EXTS7.has(file.ext)) continue;
8915
+ if (!SCRIPT_EXTS8.has(file.ext)) continue;
8744
8916
  for (const { pkg, specifier, names, line } of genesisNamedImports(file.code)) {
8745
8917
  const tags = tagsOf(pkg);
8746
8918
  if (!tags) continue;
@@ -8756,12 +8928,12 @@ function checkStabilityImports(ctx) {
8756
8928
  }
8757
8929
  }
8758
8930
  }
8759
- var SCRIPT_EXTS7, DECLARATION, REEXPORT;
8931
+ var SCRIPT_EXTS8, DECLARATION, REEXPORT;
8760
8932
  var init_stability = __esm({
8761
8933
  "src/doctor/stability.ts"() {
8762
8934
  init_genesis();
8763
8935
  init_trail();
8764
- SCRIPT_EXTS7 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
8936
+ SCRIPT_EXTS8 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
8765
8937
  DECLARATION = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\n(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/g;
8766
8938
  REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
8767
8939
  }
@@ -8807,7 +8979,7 @@ function showAt(dir, rev, file) {
8807
8979
  function configAtBase(root, base, explicitFile) {
8808
8980
  const mergeBase = mergeBaseOf2(root, base);
8809
8981
  if (!mergeBase) return null;
8810
- const candidates = explicitFile ? [{ dir: path62.dirname(explicitFile), file: path62.basename(explicitFile), explicit: true }] : [
8982
+ const candidates = explicitFile ? [{ dir: path63.dirname(explicitFile), file: path63.basename(explicitFile), explicit: true }] : [
8811
8983
  { dir: root, file: "genesis.config.json", explicit: false },
8812
8984
  { dir: root, file: "package.json", explicit: false }
8813
8985
  ];
@@ -8921,7 +9093,7 @@ function snapshotAtBase(root, base, files, changed, originOf = (f) => f) {
8921
9093
  seen.add(origin);
8922
9094
  const text = showAt(root, mergeBase, origin);
8923
9095
  if (text === null) return null;
8924
- if (text !== void 0) out.push(withText({ ...f, path: origin, absolutePath: path62.join(root, origin) }, text));
9096
+ if (text !== void 0) out.push(withText({ ...f, path: origin, absolutePath: path63.join(root, origin) }, text));
8925
9097
  }
8926
9098
  const cache2 = /* @__PURE__ */ new Map();
8927
9099
  return {
@@ -9079,7 +9251,7 @@ function pathTaken(file) {
9079
9251
  return true;
9080
9252
  } catch {
9081
9253
  try {
9082
- return readdirSync(path62.dirname(file)).some((n) => n.toLowerCase() === path62.basename(file).toLowerCase());
9254
+ return readdirSync(path63.dirname(file)).some((n) => n.toLowerCase() === path63.basename(file).toLowerCase());
9083
9255
  } catch {
9084
9256
  return false;
9085
9257
  }
@@ -9151,13 +9323,13 @@ function stableGuidePath(root, p) {
9151
9323
  };
9152
9324
  const want = real2(p.dir);
9153
9325
  for (let dir = root, level = 0; level <= GUIDE_SEARCH_LEVELS; level++) {
9154
- const found = path62.join(dir, "node_modules", p.name);
9326
+ const found = path63.join(dir, "node_modules", p.name);
9155
9327
  if (existsSync(found)) {
9156
- const file = path62.join(found, "SKILL.md");
9328
+ const file = path63.join(found, "SKILL.md");
9157
9329
  return want !== null && real2(found) === want && existsSync(file) ? file : null;
9158
9330
  }
9159
- if (existsSync(path62.join(dir, ".git")) || existsSync(path62.join(dir, "pnpm-workspace.yaml"))) return null;
9160
- const up = path62.dirname(dir);
9331
+ if (existsSync(path63.join(dir, ".git")) || existsSync(path63.join(dir, "pnpm-workspace.yaml"))) return null;
9332
+ const up = path63.dirname(dir);
9161
9333
  if (up === dir) return null;
9162
9334
  dir = up;
9163
9335
  }
@@ -9166,18 +9338,18 @@ function stableGuidePath(root, p) {
9166
9338
  function packageGuides(root, packages) {
9167
9339
  const guides = [];
9168
9340
  for (const p of packages) {
9169
- const stable = p.local ? path62.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
9341
+ const stable = p.local ? path63.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
9170
9342
  const text = stable === null ? null : read2(stable);
9171
9343
  if (stable === null || text === null) continue;
9172
9344
  const description = skillDescription(text);
9173
9345
  const at = description.indexOf("Load before");
9174
- guides.push({ package: p.name, path: path62.relative(root, stable).split(path62.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
9346
+ guides.push({ package: p.name, path: path63.relative(root, stable).split(path63.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
9175
9347
  }
9176
9348
  return guides.sort((a, b) => a.package.localeCompare(b.package));
9177
9349
  }
9178
9350
  function unlistedGuides(root, packages) {
9179
9351
  const listed = new Set(packageGuides(root, packages).map((g) => g.package));
9180
- return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path62.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
9352
+ return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path63.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
9181
9353
  }
9182
9354
  function guidesSection(guides) {
9183
9355
  if (!guides.length) return [];
@@ -9258,13 +9430,13 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
9258
9430
  const rows = primitivesCatalog(packages);
9259
9431
  const guides = packageGuides(root, packages);
9260
9432
  const changed = [];
9261
- const agents = path62.join(root, agentsFile);
9433
+ const agents = path63.join(root, agentsFile);
9262
9434
  const before = read2(agents);
9263
9435
  const after = mergeAgentsBlock(before, renderAgentsBlock(rows, guides));
9264
- const skill = path62.join(root, SKILL_PATH);
9436
+ const skill = path63.join(root, SKILL_PATH);
9265
9437
  const skillText = renderSkill(rows, guides);
9266
9438
  if (read2(skill)?.replace(/\r\n/g, "\n") !== skillText) {
9267
- mkdirSync(path62.dirname(skill), { recursive: true });
9439
+ mkdirSync(path63.dirname(skill), { recursive: true });
9268
9440
  writeFileSync(skill, skillText);
9269
9441
  changed.push(SKILL_PATH);
9270
9442
  }
@@ -9272,7 +9444,7 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
9272
9444
  writeFileSync(agents, after);
9273
9445
  changed.push(agentsFile);
9274
9446
  }
9275
- const claude = path62.join(root, "CLAUDE.md");
9447
+ const claude = path63.join(root, "CLAUDE.md");
9276
9448
  if (agentsFile === "AGENTS.md" && !pathTaken(claude)) {
9277
9449
  writeFileSync(claude, CLAUDE_IMPORT);
9278
9450
  changed.push("CLAUDE.md");
@@ -9280,7 +9452,7 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
9280
9452
  return changed;
9281
9453
  }
9282
9454
  function claudeState(root) {
9283
- const file = path62.join(root, "CLAUDE.md");
9455
+ const file = path63.join(root, "CLAUDE.md");
9284
9456
  let names = [];
9285
9457
  try {
9286
9458
  names = readdirSync(root);
@@ -9295,7 +9467,7 @@ function claudeState(root) {
9295
9467
  }
9296
9468
  if (/^@AGENTS\.md\b/m.test(text)) return "ok";
9297
9469
  try {
9298
- if (realpathSync(file) === realpathSync(path62.join(root, "AGENTS.md"))) return "ok";
9470
+ if (realpathSync(file) === realpathSync(path63.join(root, "AGENTS.md"))) return "ok";
9299
9471
  } catch {
9300
9472
  }
9301
9473
  return "no-import";
@@ -9303,8 +9475,8 @@ function claudeState(root) {
9303
9475
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
9304
9476
  const rows = primitivesCatalog(packages);
9305
9477
  const guides = packageGuides(root, packages);
9306
- const skill = read2(path62.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
9307
- const block = currentAgentsBlock(read2(path62.join(root, agentsFile)));
9478
+ const skill = read2(path63.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
9479
+ const block = currentAgentsBlock(read2(path63.join(root, agentsFile)));
9308
9480
  return {
9309
9481
  skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
9310
9482
  agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
@@ -9400,6 +9572,7 @@ var init_primitives = __esm({
9400
9572
  "Never copy an older screen as a template. Old screens predate the primitives; the doctor flags what they did.",
9401
9573
  "A list screen is a view (`defineView`) rendered by `ResourceView`; a record view is `RecordView`; on the phone, `NativeResourceView`.",
9402
9574
  "Screens never call the database client (`supabase.from`, `.rpc`) directly: reads go through a view or a named data function, writes through the resource's provider rules.",
9575
+ `Data access is declared: the Supabase provider runs with \`access: "declared"\`; each resource reads through a view or a function (\`source\`) and writes through named database functions (\`writes\`, \`actions\`) that hold the access rule; a table is touched only with \`table: { \u2026, why }\`. Every declared function gets an access-rule test (\`accessRules\`), and one test (\`expectAccessRulesCover\`) fails for any declared function whose name no spec carries: it compares names only, so give it the same specs the cases are registered from. See ${GENESIS_DOCS}/DATA-ACCESS.md.`,
9403
9576
  "When a Genesis piece is close and does the same job, extend it: a prop, a variant, a slot, or your own component that wraps it. Never build a parallel copy beside it.",
9404
9577
  "When no Genesis piece does the job, invent it in the app: your own screens and components, on Genesis tokens and primitives. Genesis asks for no write-up or approval first (your app's own design review still applies); you may add it to `docs/genesis-upstream.md` if you think Genesis should have it.",
9405
9578
  "Run `genesis doctor` before you finish; it enforces these rules."
@@ -9451,7 +9624,7 @@ function mergeAgentHooks(settings2) {
9451
9624
  return out;
9452
9625
  }
9453
9626
  function writeAgentHooks(root) {
9454
- const file = path62.join(root, SETTINGS_PATH);
9627
+ const file = path63.join(root, SETTINGS_PATH);
9455
9628
  const before = existsSync(file) ? readFileSync(file, "utf8") : null;
9456
9629
  let current = {};
9457
9630
  if (before !== null) {
@@ -9465,14 +9638,14 @@ function writeAgentHooks(root) {
9465
9638
  const after = `${JSON.stringify(mergeAgentHooks(current), null, 2)}
9466
9639
  `;
9467
9640
  if (before !== null && JSON.stringify(JSON.parse(before)) === JSON.stringify(JSON.parse(after))) return [];
9468
- mkdirSync(path62.dirname(file), { recursive: true });
9641
+ mkdirSync(path63.dirname(file), { recursive: true });
9469
9642
  writeFileSync(file, after);
9470
9643
  return [SETTINGS_PATH];
9471
9644
  }
9472
9645
  function agentHooksState(root) {
9473
9646
  let settings2;
9474
9647
  try {
9475
- settings2 = JSON.parse(readFileSync(path62.join(root, SETTINGS_PATH), "utf8"));
9648
+ settings2 = JSON.parse(readFileSync(path63.join(root, SETTINGS_PATH), "utf8"));
9476
9649
  } catch {
9477
9650
  return "none";
9478
9651
  }
@@ -9515,7 +9688,7 @@ function unprefixedTemplatePaths(root, rel, mine, template, folder) {
9515
9688
  const lines = new Set(mine.split("\n"));
9516
9689
  const lockfileElsewhere = (line) => {
9517
9690
  const name = PATH_ITEM.exec(line)?.[3];
9518
- return name !== void 0 && LOCKFILES2.has(name) && !existsSync(path62.join(root, name));
9691
+ return name !== void 0 && LOCKFILES2.has(name) && !existsSync(path63.join(root, name));
9519
9692
  };
9520
9693
  return template.split("\n").filter((line, i) => line !== rendered[i] && !/^\s*#/.test(line) && lines.has(line) && !lockfileElsewhere(line)).map((line) => line.trim());
9521
9694
  }
@@ -9588,9 +9761,9 @@ function ownedKeyProblem(key2, source, localNames = /* @__PURE__ */ new Set()) {
9588
9761
  return `${key2} doesn't match its source ${source}`;
9589
9762
  }
9590
9763
  function mergeThreeWay(mine, base, theirs) {
9591
- const dir = mkdtempSync(path62.join(tmpdir(), "genesis-merge-"));
9764
+ const dir = mkdtempSync(path63.join(tmpdir(), "genesis-merge-"));
9592
9765
  try {
9593
- const [m, b, t] = ["mine", "base", "theirs"].map((n) => path62.join(dir, n));
9766
+ const [m, b, t] = ["mine", "base", "theirs"].map((n) => path63.join(dir, n));
9594
9767
  writeFileSync(m, mine);
9595
9768
  writeFileSync(b, base);
9596
9769
  writeFileSync(t, theirs);
@@ -9854,7 +10027,7 @@ function removeBunLockEntries(text, remove) {
9854
10027
  return out + text.slice(at);
9855
10028
  }
9856
10029
  function readBunLock(dir) {
9857
- const file = path62.join(dir, BUN_LOCK);
10030
+ const file = path63.join(dir, BUN_LOCK);
9858
10031
  return existsSync(file) ? readFileSync(file, "utf8") : null;
9859
10032
  }
9860
10033
  var BUN_LOCK, GENESIS_TAIL, PLAIN_VERSION;
@@ -9871,7 +10044,7 @@ function checkBunLock(ctx) {
9871
10044
  if (found?.pm !== "bun") return;
9872
10045
  const text = readBunLock(found.dir);
9873
10046
  if (text === null) return;
9874
- const file = path62.relative(ctx.root, path62.join(found.dir, BUN_LOCK)).split(path62.sep).join("/");
10047
+ const file = path63.relative(ctx.root, path63.join(found.dir, BUN_LOCK)).split(path63.sep).join("/");
9875
10048
  let stale;
9876
10049
  try {
9877
10050
  stale = staleNestedEntries(text);
@@ -9890,7 +10063,7 @@ function checkBunLock(ctx) {
9890
10063
  }
9891
10064
  async function checkLockFiles(ctx) {
9892
10065
  checkBunLock(ctx);
9893
- if (!existsSync(path62.join(ctx.root, LOCK_FILE))) return;
10066
+ if (!existsSync(path63.join(ctx.root, LOCK_FILE))) return;
9894
10067
  let lock;
9895
10068
  try {
9896
10069
  lock = readLock(ctx.root);
@@ -10012,7 +10185,7 @@ function checkDatabaseHome(ctx) {
10012
10185
  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)`
10013
10186
  });
10014
10187
  }
10015
- if (existsSync(path62.join(ctx.root, "supabase"))) {
10188
+ if (existsSync(path63.join(ctx.root, "supabase"))) {
10016
10189
  ctx.report({
10017
10190
  rule: "database-elsewhere",
10018
10191
  level: "warn",
@@ -10035,7 +10208,7 @@ function checkEslintConfig(ctx) {
10035
10208
  if (!file) return;
10036
10209
  let text;
10037
10210
  try {
10038
- text = readFileSync(path62.join(ctx.root, file), "utf8");
10211
+ text = readFileSync(path63.join(ctx.root, file), "utf8");
10039
10212
  } catch {
10040
10213
  return;
10041
10214
  }
@@ -10113,7 +10286,7 @@ function validateFigmaConfig(raw, source = "genesis.config.json") {
10113
10286
  return { file: obj.file, pages: out, proposalsPage: obj.proposalsPage ?? "Proposals" };
10114
10287
  }
10115
10288
  function readFigmaConfig(root) {
10116
- const file = path62.join(root, "genesis.config.json");
10289
+ const file = path63.join(root, "genesis.config.json");
10117
10290
  if (!existsSync(file)) return null;
10118
10291
  let raw;
10119
10292
  try {
@@ -10127,7 +10300,7 @@ function walk2(dir, out = []) {
10127
10300
  if (!existsSync(dir)) return out;
10128
10301
  for (const name of readdirSync(dir).sort()) {
10129
10302
  if (name === "node_modules" || name.startsWith(".")) continue;
10130
- const full = path62.join(dir, name);
10303
+ const full = path63.join(dir, name);
10131
10304
  if (statSync(full).isDirectory()) walk2(full, out);
10132
10305
  else if (CODE.test(name) && !/\.(?:test|spec|d)\.[jt]sx?$/.test(name)) out.push(full);
10133
10306
  }
@@ -10156,27 +10329,27 @@ function tanstackSegments(stem) {
10156
10329
  return out;
10157
10330
  }
10158
10331
  function expoRoot(root) {
10159
- for (const dir of ["src/app", "app"]) if (existsSync(path62.join(root, dir))) return dir;
10332
+ for (const dir of ["src/app", "app"]) if (existsSync(path63.join(root, dir))) return dir;
10160
10333
  return null;
10161
10334
  }
10162
10335
  function appRoutes(root) {
10163
10336
  const out = [];
10164
- const rel = (f) => path62.relative(root, f).split(path62.sep).join("/");
10337
+ const rel = (f) => path63.relative(root, f).split(path63.sep).join("/");
10165
10338
  const expo = expoRoot(root);
10166
10339
  if (expo) {
10167
- for (const f of walk2(path62.join(root, expo))) {
10168
- const parts = path62.relative(path62.join(root, expo), f).split(path62.sep);
10340
+ for (const f of walk2(path63.join(root, expo))) {
10341
+ const parts = path63.relative(path63.join(root, expo), f).split(path63.sep);
10169
10342
  const stem = parts.pop().replace(CODE, "");
10170
10343
  if (stem === "_layout" || stem.startsWith("+")) continue;
10171
10344
  if (stem !== "index") parts.push(stem);
10172
10345
  out.push(withId({ route: parts.join("/") || "index", platform: "native", file: rel(f) }, f));
10173
10346
  }
10174
10347
  }
10175
- const tanstack = path62.join(root, "src/routes");
10348
+ const tanstack = path63.join(root, "src/routes");
10176
10349
  if (existsSync(tanstack)) {
10177
10350
  const seen = /* @__PURE__ */ new Set();
10178
10351
  for (const f of walk2(tanstack)) {
10179
- const parts = path62.relative(tanstack, f).split(path62.sep);
10352
+ const parts = path63.relative(tanstack, f).split(path63.sep);
10180
10353
  const stem = parts.pop().replace(CODE, "").replace(/\.lazy$/, "");
10181
10354
  if (stem === "__root" || stem === "route" || stem.startsWith("-") || parts.some((p) => p.startsWith("-"))) continue;
10182
10355
  const segs = [...parts.flatMap(tanstackSegments), ...tanstackSegments(stem)];
@@ -10241,12 +10414,12 @@ function navTargets(code, file) {
10241
10414
  return out.sort((a, b) => a.line - b.line);
10242
10415
  }
10243
10416
  function appNavTargets(root) {
10244
- const files = [.../* @__PURE__ */ new Set([...walk2(path62.join(root, "src")), ...walk2(path62.join(root, "app"))])];
10245
- return files.flatMap((f) => navTargets(readFileSync(f, "utf8"), path62.relative(root, f).split(path62.sep).join("/")));
10417
+ const files = [.../* @__PURE__ */ new Set([...walk2(path63.join(root, "src")), ...walk2(path63.join(root, "app"))])];
10418
+ return files.flatMap((f) => navTargets(readFileSync(f, "utf8"), path63.relative(root, f).split(path63.sep).join("/")));
10246
10419
  }
10247
10420
  function appDynamicNavTargets(root) {
10248
- const files = [.../* @__PURE__ */ new Set([...walk2(path62.join(root, "src")), ...walk2(path62.join(root, "app"))])];
10249
- return files.flatMap((f) => dynamicNavTargets(readFileSync(f, "utf8"), path62.relative(root, f).split(path62.sep).join("/")));
10421
+ const files = [.../* @__PURE__ */ new Set([...walk2(path63.join(root, "src")), ...walk2(path63.join(root, "app"))])];
10422
+ return files.flatMap((f) => dynamicNavTargets(readFileSync(f, "utf8"), path63.relative(root, f).split(path63.sep).join("/")));
10250
10423
  }
10251
10424
  function splitName(name) {
10252
10425
  const i = name.indexOf(" \xB7 ");
@@ -10369,7 +10542,7 @@ function compare(config, routes, targets, figma, dynamicTargets = []) {
10369
10542
  }
10370
10543
  async function checkFigmaRoutes(options) {
10371
10544
  const config = options.config ?? readFigmaConfig(options.root);
10372
- if (!config) throw new FigmaConfigError(`no "figma" block in ${path62.join(options.root, "genesis.config.json")}`);
10545
+ if (!config) throw new FigmaConfigError(`no "figma" block in ${path63.join(options.root, "genesis.config.json")}`);
10373
10546
  const token = options.token ?? process.env.FIGMA_ACCESS_TOKEN;
10374
10547
  if (!token) throw new FigmaConfigError("FIGMA_ACCESS_TOKEN isn't set");
10375
10548
  const figma = await readFigma(config, token, options.fetch);
@@ -10526,7 +10699,7 @@ __export(doctor_exports, {
10526
10699
  writeAgentHooks: () => writeAgentHooks
10527
10700
  });
10528
10701
  async function runDoctor(options = {}) {
10529
- const root = path62.resolve(options.root ?? process.cwd());
10702
+ const root = path63.resolve(options.root ?? process.cwd());
10530
10703
  const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);
10531
10704
  const config = loaded.config;
10532
10705
  const genesis = options.genesis ?? loadGenesis(root, config);
@@ -10581,7 +10754,7 @@ async function runDoctor(options = {}) {
10581
10754
  const configured = applyConfig(raw, config, packageIds);
10582
10755
  let findings = applyExtensions(configured, extensionCtx);
10583
10756
  if (options.base && changed) {
10584
- const isAppPath = (f) => existsSync(path62.join(root, f));
10757
+ const isAppPath = (f) => existsSync(path63.join(root, f));
10585
10758
  const origins = options.changedFiles ? /* @__PURE__ */ new Map() : originsSince(root, options.base);
10586
10759
  const originOf = (f) => origins.get(f) ?? f;
10587
10760
  const dueRules = new Set(findings.filter((f) => f.level !== "info" && isRatcheted(f.rule, config, newOnly) && isAppPath(f.file) && touched(f.file, changed)).map((f) => f.rule));
@@ -10660,6 +10833,7 @@ function builtinChecks(config, options = {}) {
10660
10833
  { name: "removed-scope-names", check: checkRemovedScopeNames },
10661
10834
  { name: "app-parts", check: checkAppParts },
10662
10835
  { name: "client-layer", check: checkClientLayer },
10836
+ { name: "data-access", check: checkDataAccess },
10663
10837
  { name: "stability-imports", check: checkStabilityImports },
10664
10838
  { name: "agent-guide", check: (ctx) => {
10665
10839
  checkAgentGuide(ctx);
@@ -10785,6 +10959,7 @@ var init_doctor = __esm({
10785
10959
  init_api_usage();
10786
10960
  init_custom_views();
10787
10961
  init_client_layer();
10962
+ init_data_access();
10788
10963
  init_stability();
10789
10964
  init_package_rules();
10790
10965
  init_ratchet();
@@ -10828,12 +11003,12 @@ __export(agent_rules_exports, {
10828
11003
  runsOnPullRequestsInto: () => runsOnPullRequestsInto
10829
11004
  });
10830
11005
  function changesetBumps(root) {
10831
- const dir = path62.join(root, ".changeset");
11006
+ const dir = path63.join(root, ".changeset");
10832
11007
  const bumps = /* @__PURE__ */ new Map();
10833
11008
  if (!existsSync(dir)) return bumps;
10834
11009
  for (const name of readdirSync(dir)) {
10835
11010
  if (!name.endsWith(".md") || name === "README.md") continue;
10836
- const text = readFileSync(path62.join(dir, name), "utf8");
11011
+ const text = readFileSync(path63.join(dir, name), "utf8");
10837
11012
  const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
10838
11013
  for (const line of front.split(/\r?\n/)) {
10839
11014
  const m = /^\s*["']?([^"':]+)["']?\s*:\s*(major|minor|patch)\s*$/.exec(line);
@@ -10846,13 +11021,13 @@ function changesetBumps(root) {
10846
11021
  return bumps;
10847
11022
  }
10848
11023
  function firstVersionProblems(root) {
10849
- const packagesDir = path62.join(root, "packages");
11024
+ const packagesDir = path63.join(root, "packages");
10850
11025
  if (!existsSync(packagesDir)) return [];
10851
11026
  const bumps = changesetBumps(root);
10852
11027
  const problems = [];
10853
11028
  for (const dir of readdirSync(packagesDir)) {
10854
- const file = path62.join(packagesDir, dir, "package.json");
10855
- if (!existsSync(file) || existsSync(path62.join(packagesDir, dir, "CHANGELOG.md"))) continue;
11029
+ const file = path63.join(packagesDir, dir, "package.json");
11030
+ if (!existsSync(file) || existsSync(path63.join(packagesDir, dir, "CHANGELOG.md"))) continue;
10856
11031
  const pkg = JSON.parse(readFileSync(file, "utf8"));
10857
11032
  if (pkg.private || !pkg.name) continue;
10858
11033
  if (pkg.version !== FIRST_VERSION) {
@@ -10923,12 +11098,12 @@ function runsOnPullRequestsInto(workflow, branch) {
10923
11098
  return ignore ? !ignore.some((p) => globMatches(p, branch)) : void 0;
10924
11099
  }
10925
11100
  function batchCiProblems(root, batch) {
10926
- const dir = path62.join(root, ".github", "workflows");
11101
+ const dir = path63.join(root, ".github", "workflows");
10927
11102
  if (!existsSync(dir)) return [];
10928
11103
  const problems = [];
10929
11104
  for (const name of readdirSync(dir)) {
10930
11105
  if (!/\.ya?ml$/.test(name)) continue;
10931
- const workflow = readFileSync(path62.join(dir, name), "utf8");
11106
+ const workflow = readFileSync(path63.join(dir, name), "utf8");
10932
11107
  const main = runsOnPullRequestsInto(workflow, "main");
10933
11108
  if (main && !runsOnPullRequestsInto(workflow, sampleBranch(batch))) {
10934
11109
  problems.push({ rule: "batch-ci", message: `.github/workflows/${name}: runs on pull requests into main but not into ${batch}; let pull_request's branch filter include it` });
@@ -10973,20 +11148,20 @@ function readObject(file, key2) {
10973
11148
  }
10974
11149
  }
10975
11150
  function settings(root, options) {
10976
- const fromPackage = readObject(path62.join(root, "package.json"), "genesisFeatures");
10977
- const fromConfig = readObject(path62.join(root, "genesis.config.json"), "features");
11151
+ const fromPackage = readObject(path63.join(root, "package.json"), "genesisFeatures");
11152
+ const fromConfig = readObject(path63.join(root, "genesis.config.json"), "features");
10978
11153
  const given = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== void 0));
10979
11154
  return { ...fromPackage, ...fromConfig, ...given };
10980
11155
  }
10981
11156
  async function loadRegistry(input) {
10982
- const root = path62.resolve(input.dir);
11157
+ const root = path63.resolve(input.dir);
10983
11158
  const options = settings(root, input);
10984
- const registry = options.registry ?? DEFAULT_REGISTRIES.find((p) => existsSync(path62.join(root, p)));
10985
- if (!registry || !existsSync(path62.join(root, registry))) {
11159
+ const registry = options.registry ?? DEFAULT_REGISTRIES.find((p) => existsSync(path63.join(root, p)));
11160
+ if (!registry || !existsSync(path63.join(root, registry))) {
10986
11161
  throw new Error(`No feature registry found. Looked for ${options.registry ?? DEFAULT_REGISTRIES.join(" and ")}; pass --registry.`);
10987
11162
  }
10988
- const jiti = createJiti(path62.join(root, "package.json"), { moduleCache: false });
10989
- const load = async (file) => await jiti.import(path62.join(root, file));
11163
+ const jiti = createJiti(path63.join(root, "package.json"), { moduleCache: false });
11164
+ const load = async (file) => await jiti.import(path63.join(root, file));
10990
11165
  const mod = await load(registry);
10991
11166
  const features2 = mod.features ?? mod.default;
10992
11167
  if (!isObject5(features2)) throw new Error(`${registry} must export \`features\` (from defineFeatures).`);
@@ -10998,7 +11173,7 @@ async function loadRegistry(input) {
10998
11173
  const project = {
10999
11174
  ...rest,
11000
11175
  root,
11001
- source: options.source ?? registry.split(path62.sep).join("/"),
11176
+ source: options.source ?? registry.split(path63.sep).join("/"),
11002
11177
  features: features2,
11003
11178
  flags
11004
11179
  };
@@ -11049,23 +11224,23 @@ async function runFeaturesCheck(options) {
11049
11224
  function readFeaturePackages(root) {
11050
11225
  const found = [];
11051
11226
  const read3 = (dir, inRepo) => {
11052
- const file = path62.join(dir, "package.json");
11227
+ const file = path63.join(dir, "package.json");
11053
11228
  if (!existsSync(file)) return;
11054
11229
  try {
11055
11230
  const pkg = JSON.parse(readFileSync(file, "utf8"));
11056
11231
  const layer = pkg.genesis?.layer;
11057
11232
  if (typeof pkg.name !== "string" || !PACKAGE_LAYERS.includes(layer)) return;
11058
11233
  if (found.some((p) => p.name === pkg.name)) return;
11059
- found.push({ name: pkg.name, layer, ...inRepo ? { dir: path62.relative(root, dir).split(path62.sep).join("/") } : {} });
11234
+ found.push({ name: pkg.name, layer, ...inRepo ? { dir: path63.relative(root, dir).split(path63.sep).join("/") } : {} });
11060
11235
  } catch {
11061
11236
  }
11062
11237
  };
11063
11238
  for (const [base, inRepo] of [
11064
- [path62.join(root, "packages"), true],
11065
- [path62.join(root, "node_modules", "@marktiderman"), false]
11239
+ [path63.join(root, "packages"), true],
11240
+ [path63.join(root, "node_modules", "@marktiderman"), false]
11066
11241
  ]) {
11067
11242
  if (!existsSync(base)) continue;
11068
- for (const name of readdirSync(base)) read3(path62.join(base, name), inRepo);
11243
+ for (const name of readdirSync(base)) read3(path63.join(base, name), inRepo);
11069
11244
  }
11070
11245
  return found;
11071
11246
  }
@@ -11182,7 +11357,7 @@ function readRegister(markdown) {
11182
11357
  const need = at(row, "need");
11183
11358
  if (!need || need === "-") problems.push(`${where2}: say the need in one line`);
11184
11359
  const local = at(row, "local");
11185
- if (local && local !== "-" && localPaths(local).some((p) => path62.isAbsolute(p) || /^[A-Za-z]:[\\/]/.test(p) || p.split(/[\\/]/).includes(".."))) {
11360
+ if (local && local !== "-" && localPaths(local).some((p) => path63.isAbsolute(p) || /^[A-Za-z]:[\\/]/.test(p) || p.split(/[\\/]/).includes(".."))) {
11186
11361
  problems.push(`${where2}: local must be paths inside the app, relative to its root`);
11187
11362
  }
11188
11363
  const opt = (c) => at(row, c) && at(row, c) !== "-" ? at(row, c) : void 0;
@@ -11194,13 +11369,13 @@ function localPaths(local) {
11194
11369
  return (local ?? "").split(/,\s+|<br\s*\/?>/i).map((p) => p.trim()).filter((p) => p && p !== "-");
11195
11370
  }
11196
11371
  function checkUpstream(root) {
11197
- const found = REGISTER_PATHS.find((p) => existsSync(path62.join(root, p)));
11372
+ const found = REGISTER_PATHS.find((p) => existsSync(path63.join(root, p)));
11198
11373
  if (!found) return { entries: [], problems: [], warnings: [`no ${REGISTER_PATHS.join(" or ")}: nothing to check (add one when the app first needs something Genesis lacks)`], missing: true };
11199
- const { entries, problems } = readRegister(readFileSync(path62.join(root, found), "utf8"));
11374
+ const { entries, problems } = readRegister(readFileSync(path63.join(root, found), "utf8"));
11200
11375
  const warnings = [];
11201
11376
  for (const e of entries) {
11202
11377
  const paths = localPaths(e.local);
11203
- const absent = paths.filter((p) => !existsSync(path62.join(root, p)));
11378
+ const absent = paths.filter((p) => !existsSync(path63.join(root, p)));
11204
11379
  const present = paths.filter((p) => !absent.includes(p));
11205
11380
  if (absent.length && e.status !== "promoted" && e.status !== "declined") problems.push(`${e.id}: local ${absent.join(", ")} doesn't exist`);
11206
11381
  if (present.length && e.status === "promoted") {
@@ -11436,8 +11611,8 @@ function routeTags(source) {
11436
11611
  }
11437
11612
  function wireStudioRoute(source, route, pageImportPath) {
11438
11613
  const tags = routeTags(source);
11439
- const relative19 = route.replace(/^\//, "");
11440
- const existing = tags.find((t) => new RegExp(`path=["'](/?${relative19.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
11614
+ const relative20 = route.replace(/^\//, "");
11615
+ const existing = tags.find((t) => new RegExp(`path=["'](/?${relative20.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
11441
11616
  if (existing) {
11442
11617
  return { skipped: `Your router already has a page at ${route}. Replace its element with <DataStudioPage /> to use the studio there.` };
11443
11618
  }
@@ -11445,17 +11620,17 @@ function wireStudioRoute(source, route, pageImportPath) {
11445
11620
  const roots = layouts.length ? layouts : tags.filter((t) => !t.selfClosing && t.close !== void 0 && /path=["']\/["']/.test(t.text));
11446
11621
  if (roots.length !== 1) {
11447
11622
  return {
11448
- skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative19}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
11623
+ skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative20}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
11449
11624
  };
11450
11625
  }
11451
11626
  const layout = roots[0];
11452
11627
  const base = (/\bpath=["']([^"']*)["']/.exec(layout.text)?.[1] ?? "").replace(/^\/+|\/+$/g, "");
11453
- if (base && !relative19.startsWith(`${base}/`)) {
11628
+ if (base && !relative20.startsWith(`${base}/`)) {
11454
11629
  return {
11455
11630
  skipped: `Your layout route lives at /${base}, outside ${route}. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.`
11456
11631
  };
11457
11632
  }
11458
- const childPath = base ? relative19.slice(base.length + 1) : relative19;
11633
+ const childPath = base ? relative20.slice(base.length + 1) : relative20;
11459
11634
  const guard = GUARD.exec(source)?.[1];
11460
11635
  const element = guard ? `<${guard}><DataStudioPage /></${guard}>` : "<DataStudioPage />";
11461
11636
  const before = source.slice(0, layout.close);
@@ -11829,8 +12004,8 @@ ${indent}}`;
11829
12004
  return JSON.stringify(value);
11830
12005
  }
11831
12006
  function featureKindField(root) {
11832
- for (let dir = path62.resolve(root); ; dir = path62.dirname(dir)) {
11833
- for (const file of [path62.join(dir, "node_modules/@marktiderman/genesis-features/package.json"), path62.join(dir, "packages/features/package.json")]) {
12007
+ for (let dir = path63.resolve(root); ; dir = path63.dirname(dir)) {
12008
+ for (const file of [path63.join(dir, "node_modules/@marktiderman/genesis-features/package.json"), path63.join(dir, "packages/features/package.json")]) {
11834
12009
  try {
11835
12010
  const pkg = JSON.parse(readFileSync(file, "utf8"));
11836
12011
  if (pkg.name !== "@marktiderman/genesis-features" || !pkg.version) continue;
@@ -11839,7 +12014,7 @@ function featureKindField(root) {
11839
12014
  } catch {
11840
12015
  }
11841
12016
  }
11842
- if (path62.dirname(dir) === dir) return "layer";
12017
+ if (path63.dirname(dir) === dir) return "layer";
11843
12018
  }
11844
12019
  }
11845
12020
  function featureSnippet(manifest, owner, kindField = "kind") {
@@ -11917,12 +12092,12 @@ var init_registry_edit = __esm({
11917
12092
  });
11918
12093
  function routerRoot2(root) {
11919
12094
  try {
11920
- const config = JSON.parse(readFileSync(path62.join(root, "genesis.config.json"), "utf8"));
12095
+ const config = JSON.parse(readFileSync(path63.join(root, "genesis.config.json"), "utf8"));
11921
12096
  const configured = config.doctor?.native?.routerRoot;
11922
- if (configured && existsSync(path62.join(root, configured, "_layout.tsx"))) return configured.replace(/\/+$/, "");
12097
+ if (configured && existsSync(path63.join(root, configured, "_layout.tsx"))) return configured.replace(/\/+$/, "");
11923
12098
  } catch {
11924
12099
  }
11925
- for (const dir of ["src/app", "app"]) if (existsSync(path62.join(root, dir, "_layout.tsx"))) return dir;
12100
+ for (const dir of ["src/app", "app"]) if (existsSync(path63.join(root, dir, "_layout.tsx"))) return dir;
11926
12101
  return null;
11927
12102
  }
11928
12103
  function routeOf(file) {
@@ -11984,7 +12159,7 @@ __export(add_exports, {
11984
12159
  });
11985
12160
  function appDependencies(root) {
11986
12161
  try {
11987
- const pkg = JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
12162
+ const pkg = JSON.parse(readFileSync(path63.join(root, "package.json"), "utf8"));
11988
12163
  return { ...pkg["dependencies"], ...pkg["devDependencies"], ...pkg["optionalDependencies"] };
11989
12164
  } catch {
11990
12165
  return {};
@@ -11993,14 +12168,14 @@ function appDependencies(root) {
11993
12168
  function registryFile(root) {
11994
12169
  const read3 = (file, key2) => {
11995
12170
  try {
11996
- const v = JSON.parse(readFileSync(path62.join(root, file), "utf8"))[key2]?.registry;
12171
+ const v = JSON.parse(readFileSync(path63.join(root, file), "utf8"))[key2]?.registry;
11997
12172
  return typeof v === "string" ? v : void 0;
11998
12173
  } catch {
11999
12174
  return void 0;
12000
12175
  }
12001
12176
  };
12002
12177
  const named = read3("genesis.config.json", "features") ?? read3("package.json", "genesisFeatures");
12003
- for (const candidate of named ? [named] : ["src/features.ts", "features.ts"]) if (existsSync(path62.join(root, candidate))) return candidate;
12178
+ for (const candidate of named ? [named] : ["src/features.ts", "features.ts"]) if (existsSync(path63.join(root, candidate))) return candidate;
12004
12179
  return null;
12005
12180
  }
12006
12181
  async function registryIds(root, file) {
@@ -12088,7 +12263,7 @@ verify_jwt = false
12088
12263
  return { content: `${config.replace(/\s*$/, "\n")}${add}`, names };
12089
12264
  }
12090
12265
  async function runAdd(options) {
12091
- const root = path62.resolve(options.root);
12266
+ const root = path63.resolve(options.root);
12092
12267
  const log = options.log ?? SILENT;
12093
12268
  const now = options.now ?? /* @__PURE__ */ new Date();
12094
12269
  const warnings = [];
@@ -12327,7 +12502,7 @@ function notificationTypesSql(rows, registryFile2) {
12327
12502
  }
12328
12503
  function configuredRegistry(root) {
12329
12504
  try {
12330
- const raw = JSON.parse(readFileSync(path62.join(root, "genesis.config.json"), "utf8"));
12505
+ const raw = JSON.parse(readFileSync(path63.join(root, "genesis.config.json"), "utf8"));
12331
12506
  return typeof raw.notifications?.registry === "string" ? raw.notifications.registry : void 0;
12332
12507
  } catch {
12333
12508
  return void 0;
@@ -12346,14 +12521,14 @@ async function planNotificationTypes(root, options) {
12346
12521
  warnings.push(`Notification types: not checked on a dry run (loading ${file} runs app code).`);
12347
12522
  return { registry: file, warnings };
12348
12523
  }
12349
- const absolute = path62.resolve(root, file);
12524
+ const absolute = path63.resolve(root, file);
12350
12525
  if (!existsSync(absolute)) {
12351
12526
  warnings.push(`Notification types: ${file} doesn't exist (a relative path is resolved against the app's root, ${root}).`);
12352
12527
  return { registry: file, warnings };
12353
12528
  }
12354
12529
  let mod;
12355
12530
  try {
12356
- const jiti = createJiti(path62.join(root, "package.json"), { moduleCache: false });
12531
+ const jiti = createJiti(path63.join(root, "package.json"), { moduleCache: false });
12357
12532
  mod = await jiti.import(absolute);
12358
12533
  } catch (err) {
12359
12534
  warnings.push(`Notification types: couldn't load ${file} (${err instanceof Error ? err.message : String(err)}).`);
@@ -12364,8 +12539,8 @@ async function planNotificationTypes(root, options) {
12364
12539
  warnings.push(`Notification types: ${file} exports no defineNotifications registry (export it as \`notifications\`).`);
12365
12540
  return { registry: file, warnings };
12366
12541
  }
12367
- const shown = path62.isAbsolute(file) ? path62.relative(root, absolute) : file;
12368
- const content = notificationTypesSql(found.toTypeRows(), shown.split(path62.sep).join("/"));
12542
+ const shown = path63.isAbsolute(file) ? path63.relative(root, absolute) : file;
12543
+ const content = notificationTypesSql(found.toTypeRows(), shown.split(path63.sep).join("/"));
12369
12544
  const app = readAppMigrations(root);
12370
12545
  const latest = app.filter((m) => m.name.endsWith(`_${TYPES_STEM}.sql`)).sort((a, b) => a.name < b.name ? -1 : 1).pop();
12371
12546
  if (latest && payloadOf(latest.content) === payloadOf(content)) return { registry: file, warnings };
@@ -12397,7 +12572,7 @@ __export(migrate_exports, {
12397
12572
  runMigrate: () => runMigrate
12398
12573
  });
12399
12574
  async function runMigrate(options) {
12400
- const root = path62.resolve(options.root);
12575
+ const root = path63.resolve(options.root);
12401
12576
  const lock = readLock(root);
12402
12577
  const warnings = [];
12403
12578
  const home = databaseElsewhere(root);
@@ -12514,7 +12689,7 @@ function repositoryDirectory(root, name) {
12514
12689
  const dir = packageDir(root, name);
12515
12690
  if (!dir) return null;
12516
12691
  try {
12517
- const { repository } = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
12692
+ const { repository } = JSON.parse(readFileSync(path63.join(dir, "package.json"), "utf8"));
12518
12693
  return typeof repository?.directory === "string" ? repository.directory : null;
12519
12694
  } catch {
12520
12695
  return null;
@@ -12593,11 +12768,11 @@ var init_new_exports = __esm({
12593
12768
  }
12594
12769
  });
12595
12770
  function walk3(dir, rel = "", out = /* @__PURE__ */ new Map()) {
12596
- for (const entry of readdirSync(path62.join(dir, rel), { withFileTypes: true })) {
12771
+ for (const entry of readdirSync(path63.join(dir, rel), { withFileTypes: true })) {
12597
12772
  if (SKIP.has(entry.name)) continue;
12598
12773
  const child = rel ? `${rel}/${entry.name}` : entry.name;
12599
12774
  if (entry.isDirectory()) walk3(dir, child, out);
12600
- else if (entry.isFile()) out.set(child, readFileSync(path62.join(dir, child)));
12775
+ else if (entry.isFile()) out.set(child, readFileSync(path63.join(dir, child)));
12601
12776
  }
12602
12777
  return out;
12603
12778
  }
@@ -12620,7 +12795,7 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
12620
12795
  const tag = `${name}@${version}`;
12621
12796
  try {
12622
12797
  if (!clone) {
12623
- clone = mkdtempSync(path62.join(tmpdir(), "genesis-upstream-"));
12798
+ clone = mkdtempSync(path63.join(tmpdir(), "genesis-upstream-"));
12624
12799
  git4(["init", "-q"]);
12625
12800
  }
12626
12801
  git4(["fetch", "-q", "--no-tags", "--depth", "1", repository, `+refs/tags/${tag}:refs/tags/${tag}`]);
@@ -12637,7 +12812,7 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
12637
12812
  }
12638
12813
  });
12639
12814
  if (!manifest) return { error: `the tag ${tag} has no package named ${name}` };
12640
- const dir = path62.posix.dirname(manifest);
12815
+ const dir = path63.posix.dirname(manifest);
12641
12816
  const entries = git4(["ls-tree", "-r", "-z", tag, "--", `${dir}/`]).toString("utf8").split("\0").filter(Boolean).map((line) => /^\d+ blob ([0-9a-f]+)\t(.*)$/s.exec(line)).filter((m) => m !== null).map((m) => ({ sha: m[1], file: m[2].slice(dir.length + 1) })).filter((e) => !e.file.split("/").some((part) => SKIP.has(part)));
12642
12817
  const files = /* @__PURE__ */ new Map();
12643
12818
  if (entries.length) {
@@ -12663,10 +12838,10 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
12663
12838
  }
12664
12839
  function diffHunks(before, after) {
12665
12840
  if (before === after) return [];
12666
- const dir = mkdtempSync(path62.join(tmpdir(), "genesis-diff-"));
12841
+ const dir = mkdtempSync(path63.join(tmpdir(), "genesis-diff-"));
12667
12842
  try {
12668
- writeFileSync(path62.join(dir, "a"), before);
12669
- writeFileSync(path62.join(dir, "b"), after);
12843
+ writeFileSync(path63.join(dir, "a"), before);
12844
+ writeFileSync(path63.join(dir, "b"), after);
12670
12845
  let out = "";
12671
12846
  try {
12672
12847
  out = execFileSync("git", ["diff", "--no-index", "--no-color", "-U0", "a", "b"], { cwd: dir, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
@@ -12694,9 +12869,9 @@ function shippedBy(upstreamHunks) {
12694
12869
  return (h) => upstreamHunks.some((u) => u.start === h.start && u.count === h.count && u.added.length === h.added.length && u.added.every((l, i) => l === h.added[i]));
12695
12870
  }
12696
12871
  function promotions(root, name) {
12697
- const file = REGISTER_PATHS.find((p) => existsSync(path62.join(root, p)));
12872
+ const file = REGISTER_PATHS.find((p) => existsSync(path63.join(root, p)));
12698
12873
  if (!file) return [];
12699
- const text = readFileSync(path62.join(root, file), "utf8");
12874
+ const text = readFileSync(path63.join(root, file), "utf8");
12700
12875
  const rows = text.split("\n");
12701
12876
  return readRegister(text).entries.filter((e) => e.status === "promoted" && e.package === name).map((e) => {
12702
12877
  const row = rows.find((r) => r.split("|").map((c) => c.trim())[1] === e.id) ?? "";
@@ -12754,7 +12929,7 @@ function planOverlays(root, wanted, upstream2, manifests = ["package.json"]) {
12754
12929
  if (!GENESIS_PACKAGE_NAME.test(pkg.name)) continue;
12755
12930
  let json;
12756
12931
  try {
12757
- json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
12932
+ json = JSON.parse(readFileSync(path63.join(pkg.dir, "package.json"), "utf8"));
12758
12933
  } catch {
12759
12934
  continue;
12760
12935
  }
@@ -12880,7 +13055,7 @@ function folderReferences(root, plan) {
12880
13055
  for (const file of candidates.sort()) {
12881
13056
  let text;
12882
13057
  try {
12883
- text = readFileSync(path62.join(root, file), "utf8");
13058
+ text = readFileSync(path63.join(root, file), "utf8");
12884
13059
  } catch {
12885
13060
  continue;
12886
13061
  }
@@ -12892,7 +13067,7 @@ function folderReferences(root, plan) {
12892
13067
  function planPins(root, plan, manifests) {
12893
13068
  const pins = /* @__PURE__ */ new Map();
12894
13069
  for (const file of manifests) {
12895
- const abs = path62.join(root, file);
13070
+ const abs = path63.join(root, file);
12896
13071
  if (!existsSync(abs)) continue;
12897
13072
  const text = readFileSync(abs, "utf8");
12898
13073
  const pinned = pinManifest(root, plan, file, text);
@@ -12910,9 +13085,9 @@ function pinManifest(root, plan, file, text) {
12910
13085
  } catch {
12911
13086
  return void 0;
12912
13087
  }
12913
- const overlay = path62.resolve(root, plan.rel);
12914
- const here = path62.dirname(path62.join(root, file));
12915
- const local = (spec) => typeof spec === "string" && (spec.startsWith("workspace:") || /^(file|link):/.test(spec) && path62.resolve(here, spec.slice(5)) === overlay);
13088
+ const overlay = path63.resolve(root, plan.rel);
13089
+ const here = path63.dirname(path63.join(root, file));
13090
+ const local = (spec) => typeof spec === "string" && (spec.startsWith("workspace:") || /^(file|link):/.test(spec) && path63.resolve(here, spec.slice(5)) === overlay);
12916
13091
  let touched2 = false;
12917
13092
  for (const section2 of ["dependencies", "devDependencies", "optionalDependencies"]) {
12918
13093
  const deps = json[section2];
@@ -12927,7 +13102,7 @@ function pinManifest(root, plan, file, text) {
12927
13102
  touched2 = true;
12928
13103
  }
12929
13104
  }
12930
- const names = (entry) => typeof entry === "string" && path62.resolve(here, entry) === overlay;
13105
+ const names = (entry) => typeof entry === "string" && path63.resolve(here, entry) === overlay;
12931
13106
  const ws = json.workspaces;
12932
13107
  const list = Array.isArray(ws) ? ws : isObject6(ws) && Array.isArray(ws.packages) ? ws.packages : null;
12933
13108
  if (list?.some(names)) {
@@ -12945,10 +13120,10 @@ function applyOverlayPlans(root, plans, lockEdits = []) {
12945
13120
  const removedFolders = [];
12946
13121
  for (const plan of plans) {
12947
13122
  if (plan.skipped || plan.conflicts.length) continue;
12948
- const dir = path62.join(root, plan.rel);
13123
+ const dir = path63.join(root, plan.rel);
12949
13124
  if (plan.remove) {
12950
13125
  for (const file of plan.pins.keys()) {
12951
- const abs = path62.join(root, file);
13126
+ const abs = path63.join(root, file);
12952
13127
  const now = existsSync(abs) ? readFileSync(abs, "utf8") : null;
12953
13128
  const text = now === null ? plan.pins.get(file) : pinManifest(root, plan, file, now);
12954
13129
  if (typeof text !== "string") continue;
@@ -12961,10 +13136,10 @@ function applyOverlayPlans(root, plans, lockEdits = []) {
12961
13136
  continue;
12962
13137
  }
12963
13138
  for (const [file, bytes] of plan.writes) {
12964
- const target = path62.join(dir, file);
13139
+ const target = path63.join(dir, file);
12965
13140
  if (bytes === null) rmSync(target, { force: true });
12966
13141
  else {
12967
- mkdirSync(path62.dirname(target), { recursive: true });
13142
+ mkdirSync(path63.dirname(target), { recursive: true });
12968
13143
  writeFileSync(target, bytes);
12969
13144
  }
12970
13145
  changed.push(`${plan.rel}/${file}`);
@@ -12986,7 +13161,7 @@ function dropRemovedWorkspaces(root, folders) {
12986
13161
  const packages = [];
12987
13162
  try {
12988
13163
  for (const folder of folders) {
12989
- const entries = workspaceEntries(text, path62.relative(found.dir, folder).split(path62.sep).join("/"));
13164
+ const entries = workspaceEntries(text, path63.relative(found.dir, folder).split(path63.sep).join("/"));
12990
13165
  workspaces.push(...entries.workspaces);
12991
13166
  packages.push(...entries.packages);
12992
13167
  }
@@ -12994,8 +13169,8 @@ function dropRemovedWorkspaces(root, folders) {
12994
13169
  return null;
12995
13170
  }
12996
13171
  if (!workspaces.length && !packages.length) return null;
12997
- writeFileSync(path62.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { workspaces, packages }));
12998
- return { file: path62.relative(root, path62.join(found.dir, BUN_LOCK)).split(path62.sep).join("/"), workspaces };
13172
+ writeFileSync(path63.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { workspaces, packages }));
13173
+ return { file: path63.relative(root, path63.join(found.dir, BUN_LOCK)).split(path63.sep).join("/"), workspaces };
12999
13174
  }
13000
13175
  function overlayChecklist(plans) {
13001
13176
  if (!plans.length) return [];
@@ -13060,8 +13235,8 @@ function pruneBunLock(root, want, dryRun) {
13060
13235
  return null;
13061
13236
  }
13062
13237
  if (!pruned.length) return null;
13063
- if (!dryRun) writeFileSync(path62.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { packages: pruned.map((p) => p.key) }));
13064
- return { file: path62.relative(root, path62.join(found.dir, BUN_LOCK)).split(path62.sep).join("/"), pruned };
13238
+ if (!dryRun) writeFileSync(path63.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { packages: pruned.map((p) => p.key) }));
13239
+ return { file: path63.relative(root, path63.join(found.dir, BUN_LOCK)).split(path63.sep).join("/"), pruned };
13065
13240
  }
13066
13241
  function npm(args, cwd) {
13067
13242
  return execFileSync("npm", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
@@ -13073,11 +13248,11 @@ function npmLookup(cwd) {
13073
13248
  if (!EXACT_OR_TAG.test(target)) throw new Error(`--version must be an exact version or a dist-tag, not "${target}"`);
13074
13249
  const version = JSON.parse(npm(["view", `${UMBRELLA}@${target}`, "version", "--json"], cwd) || "null");
13075
13250
  if (typeof version !== "string") throw new Error(`${UMBRELLA}@${target} is not one published version`);
13076
- const tmp = mkdtempSync(path62.join(tmpdir(), "genesis-umbrella-"));
13251
+ const tmp = mkdtempSync(path63.join(tmpdir(), "genesis-umbrella-"));
13077
13252
  try {
13078
13253
  const [packed] = JSON.parse(npm(["pack", `${UMBRELLA}@${version}`, "--pack-destination", tmp, "--json"], cwd));
13079
- execFileSync("tar", ["-xzf", path62.join(tmp, packed.filename), "-C", tmp, "package/dist/versions.json"]);
13080
- const manifest = JSON.parse(readFileSync(path62.join(tmp, "package/dist/versions.json"), "utf8"));
13254
+ execFileSync("tar", ["-xzf", path63.join(tmp, packed.filename), "-C", tmp, "package/dist/versions.json"]);
13255
+ const manifest = JSON.parse(readFileSync(path63.join(tmp, "package/dist/versions.json"), "utf8"));
13081
13256
  if (manifest.version !== version) throw new Error(`${UMBRELLA}@${version} ships a versions.json for ${manifest.version}`);
13082
13257
  return manifest;
13083
13258
  } finally {
@@ -13123,8 +13298,8 @@ function readText2(file) {
13123
13298
  function tidyReleaseAgeExcludes(file) {
13124
13299
  const before = readText2(file);
13125
13300
  if (before === null) return false;
13126
- const dir = path62.dirname(file);
13127
- const after = normaliseReleaseAgeExcludes(before, tidyLocked(before, readText2(path62.join(dir, "pnpm-lock.yaml")), readText2(path62.join(dir, ".npmrc"))));
13301
+ const dir = path63.dirname(file);
13302
+ const after = normaliseReleaseAgeExcludes(before, tidyLocked(before, readText2(path63.join(dir, "pnpm-lock.yaml")), readText2(path63.join(dir, ".npmrc"))));
13128
13303
  if (after === before) return false;
13129
13304
  writeFileSync(file, after);
13130
13305
  return true;
@@ -13140,14 +13315,14 @@ function gitTopLevel(root) {
13140
13315
  function folderBelowTopLevel(root) {
13141
13316
  const real2 = realpathSync(root);
13142
13317
  const top = gitTopLevel(real2);
13143
- return top === null ? null : path62.relative(top, real2).split(path62.sep).join("/");
13318
+ return top === null ? null : path63.relative(top, real2).split(path63.sep).join("/");
13144
13319
  }
13145
13320
  function pnpmWorkspaceFileFor(root) {
13146
13321
  const real2 = realpathSync(root);
13147
13322
  const top = gitTopLevel(real2);
13148
13323
  const lockDir = findLockfile(real2)?.dir;
13149
13324
  const fallback = lockDir && (!top || inside2(top, lockDir)) ? lockDir : real2;
13150
- return pnpmWorkspaceFile(real2, fallback, { exists: existsSync, join: path62.join, dirname: path62.dirname }, top ?? void 0);
13325
+ return pnpmWorkspaceFile(real2, fallback, { exists: existsSync, join: path63.join, dirname: path63.dirname }, top ?? void 0);
13151
13326
  }
13152
13327
  function pnpmVersionIn(root) {
13153
13328
  try {
@@ -13197,7 +13372,7 @@ function packageJsons(root) {
13197
13372
  if (files.length) return files;
13198
13373
  } catch {
13199
13374
  }
13200
- return existsSync(path62.join(root, "package.json")) ? ["package.json"] : [];
13375
+ return existsSync(path63.join(root, "package.json")) ? ["package.json"] : [];
13201
13376
  }
13202
13377
  function sourceText(root, source, substitutions) {
13203
13378
  const { package: pkg, path: rel } = parseSource(source);
@@ -13217,12 +13392,12 @@ function sourceText(root, source, substitutions) {
13217
13392
  }
13218
13393
  }
13219
13394
  async function runUpgrade(options) {
13220
- const root = path62.resolve(options.root);
13395
+ const root = path63.resolve(options.root);
13221
13396
  const log = options.log ?? (() => {
13222
13397
  });
13223
13398
  checkInstalled(root, options);
13224
13399
  const lookup = options.lookup ?? npmLookup(root);
13225
- const release = options.manifest ? JSON.parse(readFileSync(path62.resolve(options.manifest), "utf8")) : lookup.release(options.version ?? "latest");
13400
+ const release = options.manifest ? JSON.parse(readFileSync(path63.resolve(options.manifest), "utf8")) : lookup.release(options.version ?? "latest");
13226
13401
  const pinned = { [UMBRELLA]: release.version, ...release.packages };
13227
13402
  const wanted = (name) => pinned[name] ?? lookup.latest(name);
13228
13403
  const prBase = options.pr && !options.dryRun ? checkPullRequest(root, release.version) : void 0;
@@ -13320,7 +13495,7 @@ async function runUpgrade(options) {
13320
13495
  const excludeWarnings = [];
13321
13496
  if (!options.dryRun && options.install !== false && (bumped.size || bunLock)) {
13322
13497
  const workspaceFile = pm === "pnpm" ? pnpmWorkspaceFileFor(root) : null;
13323
- const relWorkspace = workspaceFile ? path62.relative(realpathSync(root), workspaceFile) : null;
13498
+ const relWorkspace = workspaceFile ? path63.relative(realpathSync(root), workspaceFile) : null;
13324
13499
  const workspaceBefore = workspaceFile ? readText2(workspaceFile) : null;
13325
13500
  const tidy = () => {
13326
13501
  if (!workspaceFile || !tidyReleaseAgeExcludes(workspaceFile)) return;
@@ -13553,7 +13728,7 @@ function checkSubstitutions(substitutions) {
13553
13728
  if (!substitutions || !Object.keys(substitutions).length) return;
13554
13729
  let names;
13555
13730
  try {
13556
- const was = starterIdentity(readFileSync(path62.join(starterDir(), "starter.config.ts"), "utf8"));
13731
+ const was = starterIdentity(readFileSync(path63.join(starterDir(), "starter.config.ts"), "utf8"));
13557
13732
  names = [was.name, was.slug, was.scheme, was.bundleId];
13558
13733
  } catch {
13559
13734
  names = [];
@@ -13569,9 +13744,9 @@ function checkSubstitutions(substitutions) {
13569
13744
  function lockfilesFor(root) {
13570
13745
  const top = gitTopLevel(root);
13571
13746
  const lockfiles = [];
13572
- for (let dir = realpathSync(root); ; dir = path62.dirname(dir)) {
13573
- for (const f of ["pnpm-lock.yaml", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock"]) if (existsSync(path62.join(dir, f))) lockfiles.push(path62.relative(realpathSync(root), path62.join(dir, f)));
13574
- if (lockfiles.length || dir === top || path62.dirname(dir) === dir) break;
13747
+ for (let dir = realpathSync(root); ; dir = path63.dirname(dir)) {
13748
+ for (const f of ["pnpm-lock.yaml", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock"]) if (existsSync(path63.join(dir, f))) lockfiles.push(path63.relative(realpathSync(root), path63.join(dir, f)));
13749
+ if (lockfiles.length || dir === top || path63.dirname(dir) === dir) break;
13575
13750
  }
13576
13751
  return lockfiles;
13577
13752
  }
@@ -13602,13 +13777,13 @@ function openPullRequest(root, version, report, base) {
13602
13777
  git4("switch", "-c", branch);
13603
13778
  const lockfiles = lockfilesFor(root);
13604
13779
  const ignoredLocks = gitIgnored(root, lockfiles);
13605
- const paths = [...report.files.filter((f) => existsSync(path62.join(root, f))), ...lockfiles.filter((f) => !ignoredLocks.includes(f))];
13780
+ const paths = [...report.files.filter((f) => existsSync(path63.join(root, f))), ...lockfiles.filter((f) => !ignoredLocks.includes(f))];
13606
13781
  git4("add", "--", ...paths);
13607
13782
  const overlayDirs = report.overlays.filter((o) => !o.skipped && !o.conflicts.length && (o.remove || [...o.writes.values()].includes(null))).map((o) => o.rel);
13608
13783
  if (overlayDirs.length) git4("add", "-A", "--", ...overlayDirs);
13609
13784
  git4("commit", "-q", "-m", `chore(deps): upgrade Genesis to ${version}`);
13610
13785
  git4("push", "-u", "origin", branch);
13611
- const body = path62.join(mkdtempSync(path62.join(tmpdir(), "genesis-pr-")), "body.md");
13786
+ const body = path63.join(mkdtempSync(path63.join(tmpdir(), "genesis-pr-")), "body.md");
13612
13787
  writeFileSync(body, `${report.summary}
13613
13788
 
13614
13789
  Opened by \`genesis upgrade --pr\`.
@@ -13643,8 +13818,8 @@ var init_upgrade = __esm({
13643
13818
  init_bun_lock();
13644
13819
  EXACT_OR_TAG = /^[0-9A-Za-z][0-9A-Za-z.+-]*$/;
13645
13820
  inside2 = (dir, file) => {
13646
- const rel = path62.relative(dir, file);
13647
- return rel === "" || rel.split(path62.sep)[0] !== ".." && !path62.isAbsolute(rel);
13821
+ const rel = path63.relative(dir, file);
13822
+ return rel === "" || rel.split(path63.sep)[0] !== ".." && !path63.isAbsolute(rel);
13648
13823
  };
13649
13824
  NOT_MATURE = "ERR_PNPM_NO_MATURE_MATCHING_VERSION";
13650
13825
  SUBSTITUTION_VALUE = /^[A-Za-z0-9][A-Za-z0-9 .+-]{0,59}$/;
@@ -13747,9 +13922,9 @@ async function runScaffold(opts, fs2) {
13747
13922
  function joinPath(...parts) {
13748
13923
  return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
13749
13924
  }
13750
- function dirname(path63) {
13751
- const idx = path63.lastIndexOf("/");
13752
- return idx === -1 ? "." : path63.slice(0, idx);
13925
+ function dirname(path64) {
13926
+ const idx = path64.lastIndexOf("/");
13927
+ return idx === -1 ? "." : path64.slice(0, idx);
13753
13928
  }
13754
13929
  function brandPackageJson(consumer, genesisVersion) {
13755
13930
  return JSON.stringify(
@@ -13988,7 +14163,7 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
13988
14163
  const { runInitNative: runInitNative2 } = await Promise.resolve().then(() => (init_init_native(), init_native_exports));
13989
14164
  const result2 = await runInitNative2({
13990
14165
  name: consumer,
13991
- target: path62.resolve(opts.target ?? consumer),
14166
+ target: path63.resolve(opts.target ?? consumer),
13992
14167
  ...opts.displayName ? { displayName: opts.displayName } : {},
13993
14168
  ...opts.bundleId ? { bundleId: opts.bundleId } : {},
13994
14169
  ...opts.scheme ? { scheme: opts.scheme } : {},
@@ -14002,7 +14177,7 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
14002
14177
  console.log(` Genesis packages: ${Object.entries(result2.dependencies).map(([n, v]) => `${n}@${v}`).join(", ")}`);
14003
14178
  console.log("");
14004
14179
  console.log("Next steps:");
14005
- [`cd ${path62.relative(process.cwd(), result2.target) || "."} && pnpm install (or your package manager)`, ...result2.steps].forEach((s, i) => console.log(` ${i + 1}. ${s}`));
14180
+ [`cd ${path63.relative(process.cwd(), result2.target) || "."} && pnpm install (or your package manager)`, ...result2.steps].forEach((s, i) => console.log(` ${i + 1}. ${s}`));
14006
14181
  return;
14007
14182
  }
14008
14183
  opts.target ??= process.cwd();
@@ -14087,7 +14262,7 @@ program.command("introspect").description("Write a checked-in contract (resource
14087
14262
  });
14088
14263
  program.command("doctor").description("Check this app against the installed Genesis: components, tokens, imports, colors, plus the app's own rules").option("--strict", "Fail on warnings too", false).option("--json", "Print the report as JSON", false).option("--verbose", "List the Genesis components no file imports (otherwise only their count)", false).option("--build", "Also run the app's typecheck and build (doctor.build, or its typecheck/build scripts)", false).option("-c, --config <path>", 'Config file (default: genesis.config.json, then package.json "genesis")').option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--print-genesis", "Print the components, tokens and raw tags read from Genesis, and exit", false).option("--base <ref>", "The git ref change checks compare against (the packages pack's change gate, and the ratchet: newOnly rules report unchanged files as info), e.g. origin/main").action(async (opts) => {
14089
14264
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
14090
- const root = path62.resolve(opts.dir);
14265
+ const root = path63.resolve(opts.dir);
14091
14266
  try {
14092
14267
  if (opts.printGenesis) {
14093
14268
  const { config } = doctor.loadConfig(root, opts.config);
@@ -14106,7 +14281,7 @@ program.command("doctor").description("Check this app against the installed Gene
14106
14281
  });
14107
14282
  program.command("catalog").description("Print the Genesis catalog: for each need, what to use, its import and docs, from every installed Genesis package's declarations").option("--json", "Print the catalog as JSON", false).option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (opts) => {
14108
14283
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
14109
- const packages = doctor.discoverPackages(path62.resolve(opts.dir));
14284
+ const packages = doctor.discoverPackages(path63.resolve(opts.dir));
14110
14285
  const rows = doctor.primitivesCatalog(packages);
14111
14286
  const broken = packages.filter((p) => p.error);
14112
14287
  if (opts.json) {
@@ -14121,7 +14296,7 @@ program.command("catalog").description("Print the Genesis catalog: for each need
14121
14296
  program.command("primitives").description("Deprecated name of `genesis catalog` (same output; JSON keeps the `primitives` key until the next major)").option("--json", "Print the catalog as JSON", false).option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (opts) => {
14122
14297
  console.error("! `genesis primitives` is now `genesis catalog`; the old name works until the next major.");
14123
14298
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
14124
- const packages = doctor.discoverPackages(path62.resolve(opts.dir));
14299
+ const packages = doctor.discoverPackages(path63.resolve(opts.dir));
14125
14300
  const rows = doctor.primitivesCatalog(packages);
14126
14301
  const broken = packages.filter((p) => p.error);
14127
14302
  if (opts.json) {
@@ -14134,7 +14309,7 @@ program.command("primitives").description("Deprecated name of `genesis catalog`
14134
14309
  if (broken.length) process.exitCode = 1;
14135
14310
  });
14136
14311
  program.command("agents").description(`Write the agent guide from the installed Genesis packages: .claude/skills/genesis/SKILL.md and a marked block in AGENTS.md`).option("--check", "Write nothing; exit 1 if either is missing or out of date (for CI)", false).option("--rules", "Check the repo against the agent rules of engagement a script can check (docs/agents/RULES.md); exit 1 on a break", false).option("--batch <pattern>", "With --rules: the branch pattern staging batches use in workflow filters", "staging/**").option("--hooks", "Also write the agent hooks into .claude/settings.json: the Genesis rules for Explore and Plan subagents, and deny rules for secret files", false).option("--hook <name>", "Run as a Claude Code hook and print its output (subagent-start); never fails").option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (opts) => {
14137
- const root = path62.resolve(opts.dir);
14312
+ const root = path63.resolve(opts.dir);
14138
14313
  if (opts.hook) {
14139
14314
  try {
14140
14315
  if (opts.hook === "subagent-start") {
@@ -14147,7 +14322,7 @@ program.command("agents").description(`Write the agent guide from the installed
14147
14322
  }
14148
14323
  if (opts.rules && opts.check) return program.error("--rules checks the repo, --check the agent guide: run them one at a time");
14149
14324
  if (opts.rules) {
14150
- if (!existsSync(path62.join(root, "packages")) && !existsSync(path62.join(root, ".github", "workflows"))) {
14325
+ if (!existsSync(path63.join(root, "packages")) && !existsSync(path63.join(root, ".github", "workflows"))) {
14151
14326
  return program.error(`--rules checks a repository: ${root} has no packages/ or .github/workflows/. Run it from the repo root or pass --dir.`);
14152
14327
  }
14153
14328
  const { checkAgentRules: checkAgentRules2 } = await Promise.resolve().then(() => (init_agent_rules(), agent_rules_exports));
@@ -14232,7 +14407,7 @@ featureOptions(
14232
14407
  program.command("figma:routes").description("Report drift between this app's routes and its Figma app file (read-only; genesis.config.json figma block, FIGMA_ACCESS_TOKEN)").option("--json", "Print the report as JSON", false).option("--strict", "Exit 1 when a route, hotspot or figma: id is missing", false).option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (opts) => {
14233
14408
  const figma = await Promise.resolve().then(() => (init_routes2(), routes_exports));
14234
14409
  try {
14235
- const report = await figma.checkFigmaRoutes({ root: path62.resolve(opts.dir) });
14410
+ const report = await figma.checkFigmaRoutes({ root: path63.resolve(opts.dir) });
14236
14411
  console.log(opts.json ? JSON.stringify(report, null, 2) : figma.formatCoverage(report));
14237
14412
  process.exitCode = opts.strict && report.summary.missing > 0 ? 1 : 0;
14238
14413
  } catch (err) {
@@ -14244,7 +14419,7 @@ program.command("figma:routes").description("Report drift between this app's rou
14244
14419
  var upstream = program.command("upstream").description("The app's register of what it needed from Genesis (docs/genesis-upstream.md)");
14245
14420
  upstream.command("check").description("Check docs/genesis-upstream.md: kinds, statuses, local paths, and promoted entries whose local copy is still there").option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (opts) => {
14246
14421
  const { checkUpstream: checkUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
14247
- const result = checkUpstream2(path62.resolve(opts.dir));
14422
+ const result = checkUpstream2(path63.resolve(opts.dir));
14248
14423
  for (const w of result.warnings) console.warn(`! ${w}`);
14249
14424
  for (const p of result.problems) console.error(`\u2717 ${p}`);
14250
14425
  if (result.problems.length) process.exitCode = 1;
@@ -14252,7 +14427,7 @@ upstream.command("check").description("Check docs/genesis-upstream.md: kinds, st
14252
14427
  });
14253
14428
  upstream.command("export").description("Print the link that files a register entry with Genesis through the gap form (sends nothing)").argument("<id>", "The entry's id").option("-d, --dir <dir>", "The app's folder", process.cwd()).action(async (id, opts) => {
14254
14429
  const { checkUpstream: checkUpstream2, exportIssueUrl: exportIssueUrl2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
14255
- const register = checkUpstream2(path62.resolve(opts.dir));
14430
+ const register = checkUpstream2(path63.resolve(opts.dir));
14256
14431
  if (register.missing) return program.error("There is no docs/genesis-upstream.md or genesis-upstream.md here; add the register first (see genesis upstream check).");
14257
14432
  const entry = register.entries.find((e) => e.id === id);
14258
14433
  if (!entry) return program.error(`No register entry "${id}" in ${register.file}.`);
@@ -14266,7 +14441,7 @@ var client = program.command("client").description("The app's client layer: its
14266
14441
  client.command("init").description("Start the app's client layer: the provider and defaults, its ResourceView wrapper, and a folder per record type").option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--folder <folder>", "The layer's folder (default: genesis.config.json's client.dir, else src/client)").option("--type <name>", "A record type to start: <folder>/<type>/view.ts and appearance.tsx").option("--force", "Overwrite files that already exist", false).action(async (opts) => {
14267
14442
  const { planClientInit: planClientInit2, clientConfigChange: clientConfigChange2 } = await Promise.resolve().then(() => (init_init(), init_exports));
14268
14443
  const { readGenesisConfig: readGenesisConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
14269
- const root = path62.resolve(opts.dir);
14444
+ const root = path63.resolve(opts.dir);
14270
14445
  const configured = readGenesisConfig2(root);
14271
14446
  const folder = opts.folder ?? configured?.client?.dir;
14272
14447
  let plan;
@@ -14278,17 +14453,17 @@ client.command("init").description("Start the app's client layer: the provider a
14278
14453
  return program.error(err.message);
14279
14454
  }
14280
14455
  for (const file of plan.files) {
14281
- const target = path62.join(root, file.path);
14456
+ const target = path63.join(root, file.path);
14282
14457
  if (existsSync(target) && !opts.force) {
14283
14458
  console.log(`\xB7 ${file.path} (kept)`);
14284
14459
  continue;
14285
14460
  }
14286
- await fs.mkdir(path62.dirname(target), { recursive: true });
14461
+ await fs.mkdir(path63.dirname(target), { recursive: true });
14287
14462
  await fs.writeFile(target, file.content);
14288
14463
  console.log(`\u2714 ${file.path}`);
14289
14464
  }
14290
14465
  if (change === "write") {
14291
- const configPath = path62.join(root, "genesis.config.json");
14466
+ const configPath = path63.join(root, "genesis.config.json");
14292
14467
  const raw = configured?.raw ?? {};
14293
14468
  await fs.writeFile(configPath, `${JSON.stringify({ ...raw, client: { dir: plan.dir } }, null, 2)}
14294
14469
  `);
@@ -14299,24 +14474,24 @@ client.command("init").description("Start the app's client layer: the provider a
14299
14474
  var studio = program.command("studio").description("The Genesis Data Studio");
14300
14475
  studio.command("init").description("Turn the Data Studio on in this app: a server for every table, a page, and one migration to review").option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--host <host>", "next, tanstack-start or supabase-function (default: detected)").option("--route <path>", "Where the page lives", "/admin/data").option("--login-role <name>", "The studio's database login", "genesis_studio_login").option("--force", "Overwrite files that already exist", false).action(async (opts) => {
14301
14476
  const { planStudioInit: planStudioInit2 } = await Promise.resolve().then(() => (init_init2(), init_exports2));
14302
- const root = path62.resolve(opts.dir);
14303
- const packageJson = JSON.parse(await fs.readFile(path62.join(root, "package.json"), "utf-8").catch(() => "{}"));
14477
+ const root = path63.resolve(opts.dir);
14478
+ const packageJson = JSON.parse(await fs.readFile(path63.join(root, "package.json"), "utf-8").catch(() => "{}"));
14304
14479
  const existsSync47 = (await import('fs')).existsSync;
14305
14480
  const readSync = (await import('fs')).readFileSync;
14306
- const readdirSync21 = (await import('fs')).readdirSync;
14481
+ const readdirSync22 = (await import('fs')).readdirSync;
14307
14482
  if (opts.host && !["next", "tanstack-start", "supabase-function"].includes(opts.host)) {
14308
14483
  throw new Error("--host must be next, tanstack-start or supabase-function.");
14309
14484
  }
14310
14485
  const plan = planStudioInit2(
14311
14486
  {
14312
14487
  packageJson,
14313
- exists: (p) => existsSync47(path62.join(root, p)),
14314
- read: (p) => existsSync47(path62.join(root, p)) ? readSync(path62.join(root, p), "utf-8") : null,
14488
+ exists: (p) => existsSync47(path63.join(root, p)),
14489
+ read: (p) => existsSync47(path63.join(root, p)) ? readSync(path63.join(root, p), "utf-8") : null,
14315
14490
  timestamp: (/* @__PURE__ */ new Date()).toISOString().replace(/\D/g, "").slice(0, 14),
14316
14491
  listDeep: (p) => {
14317
14492
  const out = [];
14318
14493
  const walk4 = (rel) => {
14319
- for (const entry of readdirSync21(path62.join(root, rel), { withFileTypes: true })) {
14494
+ for (const entry of readdirSync22(path63.join(root, rel), { withFileTypes: true })) {
14320
14495
  const child = `${rel}/${entry.name}`;
14321
14496
  if (entry.isDirectory()) walk4(child);
14322
14497
  else out.push(child);
@@ -14330,7 +14505,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
14330
14505
  },
14331
14506
  list: (p) => {
14332
14507
  try {
14333
- return readdirSync21(path62.join(root, p));
14508
+ return readdirSync22(path63.join(root, p));
14334
14509
  } catch {
14335
14510
  return [];
14336
14511
  }
@@ -14339,8 +14514,8 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
14339
14514
  { host: opts.host, route: opts.route, loginRole: opts.loginRole }
14340
14515
  );
14341
14516
  for (const file of plan.files) {
14342
- const target = path62.join(root, file.path);
14343
- await fs.mkdir(path62.dirname(target), { recursive: true });
14517
+ const target = path63.join(root, file.path);
14518
+ await fs.mkdir(path63.dirname(target), { recursive: true });
14344
14519
  if (file.edit) {
14345
14520
  await fs.writeFile(target, file.content, "utf-8");
14346
14521
  console.log(`~ ${file.path} (${file.edit})`);
@@ -14358,7 +14533,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
14358
14533
  await fs.writeFile(target, file.content, "utf-8");
14359
14534
  console.log(`+ ${file.path}`);
14360
14535
  }
14361
- const pm = existsSync47(path62.join(root, "pnpm-lock.yaml")) ? "pnpm add" : existsSync47(path62.join(root, "yarn.lock")) ? "yarn add" : existsSync47(path62.join(root, "bun.lock")) || existsSync47(path62.join(root, "bun.lockb")) ? "bun add" : "npm install";
14536
+ const pm = existsSync47(path63.join(root, "pnpm-lock.yaml")) ? "pnpm add" : existsSync47(path63.join(root, "yarn.lock")) ? "yarn add" : existsSync47(path63.join(root, "bun.lock")) || existsSync47(path63.join(root, "bun.lockb")) ? "bun add" : "npm install";
14362
14537
  console.log("");
14363
14538
  console.log(`\u2714 The Data Studio is set up for ${{ next: "Next.js", "tanstack-start": "TanStack Start", "supabase-function": "a Supabase Edge Function" }[plan.host]}. To finish:`);
14364
14539
  console.log(` 1. ${pm} ${plan.install.map((p) => /[\s<>|]/.test(p) ? `"${p}"` : p).join(" ")}`);
@@ -14376,7 +14551,7 @@ async function confirm(question) {
14376
14551
  }
14377
14552
  var logger = { info: (m) => console.log(m), warn: (m) => console.warn(`! ${m}`) };
14378
14553
  program.command("add").description("Add a block (a feature an app adds whole) from the Genesis package that declares it: install, migrations, functions, skills, routes, registry entry").argument("[block]", "The block's id, e.g. tenant-features").option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--package <name>", "The package that declares it, when two do").option("--list", "List the blocks this app can add, and exit", false).option("--dry-run", "Print the plan; write and install nothing", false).option("-y, --yes", "Don't ask before writing", false).option("--no-install", "Don't install packages (print the command instead)").option("--no-features-build", "Don't run features build after").option("--database-only", "Only the block's migrations, pgTAP tests, Edge Functions and config.toml sections: in the app that holds another app's database", false).action(async (block, opts) => {
14379
- const root = path62.resolve(opts.dir);
14554
+ const root = path63.resolve(opts.dir);
14380
14555
  if (opts.list || !block) {
14381
14556
  const { allBlocks: allBlocks2 } = await Promise.resolve().then(() => (init_discover(), discover_exports));
14382
14557
  const { readLock: readLock2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
@@ -14406,7 +14581,7 @@ program.command("migrate").description("Copy new package migrations of the app's
14406
14581
  const { runMigrate: runMigrate2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
14407
14582
  const { formatMigrationRows: formatMigrationRows2 } = await Promise.resolve().then(() => (init_migrations(), migrations_exports));
14408
14583
  const report = await runMigrate2({
14409
- root: path62.resolve(opts.dir),
14584
+ root: path63.resolve(opts.dir),
14410
14585
  ...opts.block ? { blocks: opts.block } : {},
14411
14586
  ...opts.notifications ? { notifications: opts.notifications } : {},
14412
14587
  dryRun: opts.dryRun,
@@ -14432,7 +14607,7 @@ program.command("migrate").description("Copy new package migrations of the app's
14432
14607
  program.command("upgrade").description("Move every @marktiderman/genesis* dependency to one Genesis release, refresh the files Genesis owns and what's generated, run codemods and the doctor").option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--version <v>", "The @marktiderman/genesis release: an exact version or a dist-tag", "latest").option("--manifest <file>", "Read the release from this versions.json instead of npm").option("--dry-run", "Report the bump, and owned files compared with the packages installed now; change nothing", false).option("--no-install", "Don't reinstall after the bump").option("--no-doctor", "Don't run genesis doctor after").option("--no-agents", "Don't regenerate the agent guide (genesis agents) after").option("--no-features-build", "Don't run features build after").option("--keep-mine", "Never merge an owned file you changed; write the new text to .genesis-next", false).option("--pr", "Commit to a genesis-upgrade/<version> branch, push it and open a pull request", false).option("--genesis-repo <url>", "The Genesis git repository whose <package>@<version> tags overlays are rebased from (default: the public one)").action(async (opts) => {
14433
14608
  const { runUpgrade: runUpgrade2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
14434
14609
  const report = await runUpgrade2({
14435
- root: path62.resolve(opts.dir),
14610
+ root: path63.resolve(opts.dir),
14436
14611
  version: opts.version,
14437
14612
  ...opts.manifest ? { manifest: opts.manifest } : {},
14438
14613
  dryRun: opts.dryRun,
@@ -14461,10 +14636,10 @@ program.command("codemod [id]").description("Run one of Genesis's codemods by ha
14461
14636
  }
14462
14637
  const mod = codemodById2(id);
14463
14638
  if (!mod) throw new Error(`No codemod "${id}". Run genesis codemod to list them.`);
14464
- const changed = await mod.run({ root: path62.resolve(opts.dir), dryRun: opts.dryRun, log: (m) => console.log(m) });
14639
+ const changed = await mod.run({ root: path63.resolve(opts.dir), dryRun: opts.dryRun, log: (m) => console.log(m) });
14465
14640
  console.log(changed.length ? `${opts.dryRun ? "Would change" : "\u2714 Changed"} ${changed.length} file${changed.length === 1 ? "" : "s"}:
14466
14641
  ${changed.map((f) => ` ${f}`).join("\n")}` : "Nothing to change.");
14467
- const note = codemodInstallNote2(path62.resolve(opts.dir), changed, opts.dryRun);
14642
+ const note = codemodInstallNote2(path63.resolve(opts.dir), changed, opts.dryRun);
14468
14643
  if (note) console.log(`! ${note}`);
14469
14644
  });
14470
14645
  program.parseAsync(process.argv).catch((err) => {
@@ -14514,7 +14689,7 @@ function redactUrl(location) {
14514
14689
  const url = new URL(location);
14515
14690
  return `${url.origin}${url.pathname}`;
14516
14691
  } catch {
14517
- return path62.basename(location);
14692
+ return path63.basename(location);
14518
14693
  }
14519
14694
  }
14520
14695
  //# sourceMappingURL=cli.js.map