@marktiderman/genesis-cli 1.27.0 → 1.28.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 path30 from 'path';
3
+ import * as path62 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 = path30.join(packagesDir, dir, "package.json");
34
+ const file = path62.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 = path30.relative(parent, child);
298
- return rel === "" || !rel.startsWith("..") && !path30.isAbsolute(rel);
297
+ const rel = path62.relative(parent, child);
298
+ return rel === "" || !rel.startsWith("..") && !path62.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 = path30.join(root, ...safe.split("/"));
304
+ const file = path62.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 = path30.join(root, ...safe.split("/"));
315
+ const dir = path62.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 = path30.join(realRoot, ...safe.split("/"));
335
+ const target = path62.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 = path30.dirname(target);
345
- while (!there(probe)) probe = path30.dirname(probe);
344
+ let probe = path62.dirname(target);
345
+ while (!there(probe)) probe = path62.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 (${path30.relative(realRoot, probe)}); refused`);
350
+ throw new Error(`${rel} goes through a broken symlink (${path62.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(path30.dirname(file), { recursive: true });
362
+ mkdirSync(path62.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(path30.dirname(file), { recursive: true });
367
+ mkdirSync(path62.dirname(file), { recursive: true });
368
368
  writeFileSync(file, content, "utf8");
369
369
  }
370
370
  function listApp(root, rel, options = {}) {
371
- const dir = path30.join(root, rel);
371
+ const dir = path62.join(root, rel);
372
372
  if (!existsSync(dir)) return [];
373
373
  const out = [];
374
374
  const walk4 = (r) => {
375
- for (const entry of readdirSync(path30.join(root, r), { withFileTypes: true })) {
375
+ for (const entry of readdirSync(path62.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 (path30.isAbsolute(entry) || /^[A-Za-z]:[\\/]/.test(entry)) throw new LocalPackagesError(`${where2} must be relative to the app ("${entry}")`);
397
- const norm = path30.posix.normalize(entry.replace(/\\/g, "/")).replace(/\/+$/, "");
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(/\/+$/, "");
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 = path30.join(root, "genesis.config.json");
408
+ const file = path62.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(path30.join(dir, ".git"))) return dir;
422
- const parent = path30.dirname(dir);
421
+ if (existsSync(path62.join(dir, ".git"))) return dir;
422
+ const parent = path62.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 = path30.resolve(root);
428
+ const appRoot = path62.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 = path30.join(appRoot, glob === "*" ? "" : glob.slice(0, -2));
437
+ const parent = path62.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(path30.join(parent, entry));
441
+ dirs.add(path62.join(parent, entry));
442
442
  }
443
443
  } else {
444
- dirs.add(path30.join(appRoot, glob));
444
+ dirs.add(path62.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 = path30.join(dir, "package.json");
451
+ const manifest = path62.join(dir, "package.json");
452
452
  if (!existsSync(manifest)) continue;
453
453
  if (!inside(real2, realpathSync(dir))) {
454
- throw new LocalPackagesError(`${path30.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
454
+ throw new LocalPackagesError(`${path62.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 = path30.relative(appRoot, dir).split(path30.sep).join("/");
463
+ const rel = path62.relative(appRoot, dir).split(path62.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 = path30.dirname(fileURLToPath(import.meta.url));
506
+ let dir = path62.dirname(fileURLToPath(import.meta.url));
507
507
  for (; ; ) {
508
- const file = path30.join(dir, "package.json");
508
+ const file = path62.join(dir, "package.json");
509
509
  if (existsSync(file) && JSON.parse(readFileSync(file, "utf8")).name === CLI_PACKAGE) return dir;
510
- const parent = path30.dirname(dir);
510
+ const parent = path62.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 = path30.resolve(cliPackageDir(), "..");
517
- return existsSync(path30.join(dir, "features", "package.json")) && existsSync(path30.join(dir, "..", "pnpm-workspace.yaml")) ? dir : null;
516
+ const dir = path62.resolve(cliPackageDir(), "..");
517
+ return existsSync(path62.join(dir, "features", "package.json")) && existsSync(path62.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 = path30.join(cliPackageDir(), "dist", "genesis-catalog.json");
523
+ const file = path62.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 = path30.resolve(root);
529
+ let dir = path62.resolve(root);
530
530
  for (; ; ) {
531
- const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path30.join(dir, m)));
532
- const scope = path30.join(dir, "node_modules", "@marktiderman");
531
+ const atInstallRoot = INSTALL_ROOT_MARKERS.some((m) => existsSync(path62.join(dir, m)));
532
+ const scope = path62.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(path30.join(scope, entry, "package.json"))) found.set(name, path30.join(scope, entry));
537
+ if (existsSync(path62.join(scope, entry, "package.json"))) found.set(name, path62.join(scope, entry));
538
538
  }
539
539
  }
540
- const parent = path30.dirname(dir);
540
+ const parent = path62.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(path30.join(dir, "package.json"), "utf8")).version;
554
+ return JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8")).version;
555
555
  }
556
556
  function declarationsOf(dir, warnings) {
557
- const pkg = JSON.parse(readFileSync(path30.join(dir, "package.json"), "utf8"));
557
+ const pkg = JSON.parse(readFileSync(path62.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(path30.join(dir, "package.json"), "utf8"));
567
+ const pkg = JSON.parse(readFileSync(path62.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 && path30.join(dir, ...rel.split("/"));
572
+ const file = rel && path62.join(dir, ...rel.split("/"));
573
573
  if (!file || !inside(dir, file) || !existsSync(file)) return {};
574
574
  try {
575
- const jiti = createJiti(path30.join(dir, "package.json"), { moduleCache: false });
575
+ const jiti = createJiti(path62.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(path30.join(dir, "package.json"), "utf8"));
586
+ const pkg = JSON.parse(readFileSync(path62.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 = path30.join(root, LOCK_FILE);
680
+ const file = path62.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(path30.posix.basename(file))?.[2] ?? null;
757
+ return MIGRATION_FILE.exec(path62.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 = path30.posix.basename(p);
767
+ const name = path62.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 ${path30.posix.basename(src.file)}; the applied copy is never rewritten`;
938
+ detail = `${src.package} now ships a different ${path62.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}/${path30.posix.basename(src.test).replace(/^\d{4}_/, "")}`;
960
+ const test2 = `${TESTS_DIR}/${path62.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;
@@ -1042,6 +1042,7 @@ __export(config_exports, {
1042
1042
  privacyDataType: () => privacyDataType,
1043
1043
  readGenesisConfig: () => readGenesisConfig,
1044
1044
  validateAppFolder: () => validateAppFolder,
1045
+ validateClient: () => validateClient,
1045
1046
  validateConfig: () => validateConfig,
1046
1047
  validateEnvironments: () => validateEnvironments,
1047
1048
  validateLinks: () => validateLinks,
@@ -1071,25 +1072,25 @@ function validateEnvironments(raw, source = "config") {
1071
1072
  }
1072
1073
  function appPath2(v, where2, fail) {
1073
1074
  if (typeof v !== "string" || !v.trim()) return fail(`${where2} must be a non-empty path`);
1074
- if (path30.isAbsolute(v) || /^[A-Za-z]:[\\/]/.test(v)) fail(`${where2} must be relative to the app, not absolute ("${v}")`);
1075
- const norm = path30.posix.normalize(v.replace(/\\/g, "/")).replace(/\/+$/, "");
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(/\/+$/, "");
1076
1077
  if (norm === "." || norm === ".." || norm.startsWith("../")) fail(`${where2} must be a folder inside the app ("${v}")`);
1077
1078
  return norm;
1078
1079
  }
1079
1080
  function loadConfig(root, configPath) {
1080
1081
  if (configPath) {
1081
- const file = path30.resolve(root, configPath);
1082
+ const file = path62.resolve(root, configPath);
1082
1083
  if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);
1083
1084
  const json = readJson(file);
1084
- const block = path30.basename(file) === "package.json" ? json?.genesis?.doctor : json?.doctor ?? json;
1085
- return { config: validateConfig(block ?? {}, file), file, dir: path30.dirname(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) };
1086
1087
  }
1087
- const own = path30.join(root, "genesis.config.json");
1088
+ const own = path62.join(root, "genesis.config.json");
1088
1089
  if (existsSync(own)) {
1089
1090
  const block = readGenesisConfig(root)?.raw.doctor;
1090
1091
  return { config: validateConfig(block ?? {}, own), file: own, dir: root };
1091
1092
  }
1092
- const pkg = path30.join(root, "package.json");
1093
+ const pkg = path62.join(root, "package.json");
1093
1094
  if (existsSync(pkg)) {
1094
1095
  const block = readJson(pkg)?.genesis?.doctor;
1095
1096
  if (block !== void 0 && !isPackageDeclaration(block)) return { config: validateConfig(block, pkg), file: pkg, dir: root };
@@ -1098,7 +1099,7 @@ function loadConfig(root, configPath) {
1098
1099
  }
1099
1100
  function doctorBlock(json, file, explicit) {
1100
1101
  const j = json;
1101
- if (path30.basename(file) === "package.json") return j?.genesis?.doctor;
1102
+ if (path62.basename(file) === "package.json") return j?.genesis?.doctor;
1102
1103
  return explicit ? j?.doctor ?? j : j?.doctor;
1103
1104
  }
1104
1105
  function isPackageDeclaration(block) {
@@ -1115,7 +1116,7 @@ function readJson(file) {
1115
1116
  }
1116
1117
  }
1117
1118
  function readGenesisConfig(root) {
1118
- const file = path30.join(root, "genesis.config.json");
1119
+ const file = path62.join(root, "genesis.config.json");
1119
1120
  if (!existsSync(file)) return null;
1120
1121
  const raw = readJson(file);
1121
1122
  if (!isObject2(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
@@ -1128,6 +1129,7 @@ function readGenesisConfig(root) {
1128
1129
  }
1129
1130
  if (raw.appFolder !== void 0) out.appFolder = validateAppFolder(raw.appFolder, file);
1130
1131
  if (raw.environments !== void 0) out.environments = validateEnvironments(raw.environments, file);
1132
+ if (raw.client !== void 0) out.client = validateClient(raw.client, file);
1131
1133
  return out;
1132
1134
  }
1133
1135
  function isPlainFolder(value) {
@@ -1138,6 +1140,16 @@ function validateAppFolder(raw, source = "config") {
1138
1140
  if (!isPlainFolder(norm)) throw new GenesisConfigError(`${source}: "appFolder" must be the app's folder from the repository root, such as "mobile" or "apps/phone" (got ${JSON.stringify(raw)})`);
1139
1141
  return norm;
1140
1142
  }
1143
+ function validateClient(raw, source = "config") {
1144
+ const fail = (msg) => {
1145
+ throw new GenesisConfigError(`${source}: ${msg}`);
1146
+ };
1147
+ if (!isObject2(raw)) return fail(`"client" must be { "dir": "<the client layer's folder, e.g. src/client>" }`);
1148
+ for (const key2 of Object.keys(raw)) if (key2 !== "dir" && key2 !== "$comment") fail(`client: unknown setting "${key2}" (known: dir)`);
1149
+ const dir = typeof raw.dir === "string" ? raw.dir.replace(/^\.\//, "").replace(/\/+$/, "") : "";
1150
+ if (!isPlainFolder(dir)) return fail(`client.dir must be a folder inside the app, such as "src/client" (got ${JSON.stringify(raw.dir)})`);
1151
+ return { dir };
1152
+ }
1141
1153
  function validateSupabase(raw, source = "config") {
1142
1154
  const fail = (msg) => {
1143
1155
  throw new GenesisConfigError(`${source}: ${msg}`);
@@ -1147,8 +1159,8 @@ function validateSupabase(raw, source = "config") {
1147
1159
  for (const key2 of Object.keys(raw)) if (key2 !== "app" && key2 !== "$comment") fail(`supabase: unknown setting "${key2}" (known: app)`);
1148
1160
  const app = raw.app;
1149
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")`);
1150
- if (path30.isAbsolute(app) || /^[A-Za-z]:[\\/]/.test(app) || app.includes("\\")) fail(`supabase.app must be relative to this app, with forward slashes ("${app}")`);
1151
- const norm = path30.posix.normalize(app).replace(/\/+$/, "");
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(/\/+$/, "");
1152
1164
  if (norm === "." || norm === "") fail(`supabase.app names this app itself; leave "supabase" out instead`);
1153
1165
  return { app: norm };
1154
1166
  }
@@ -1328,7 +1340,7 @@ function validateConfig(raw, source = "config") {
1328
1340
  if (!(c.packs ?? []).includes("supabase")) fail(`"contracts" is set but the supabase pack is not in "packs"`);
1329
1341
  if (contracts.out !== void 0) {
1330
1342
  if (typeof contracts.out !== "string" || !contracts.out.trim()) fail(`contracts.out must be a file path`);
1331
- if (path30.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1343
+ if (path62.isAbsolute(contracts.out) || contracts.out.replace(/\\/g, "/").split("/").includes("..")) fail(`contracts.out must be a file inside the app`);
1332
1344
  }
1333
1345
  if (contracts.schemas !== void 0 && !isStringList(contracts.schemas)) fail(`contracts.schemas must be a list of schema names`);
1334
1346
  if (contracts.databaseEnv !== void 0 && (typeof contracts.databaseEnv !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(contracts.databaseEnv))) {
@@ -1475,11 +1487,11 @@ function databaseElsewhere(root) {
1475
1487
  const setting = readGenesisConfig(root)?.supabase;
1476
1488
  if (setting === void 0) return null;
1477
1489
  if (setting === false) return { app: null, dir: null, hasSupabase: false };
1478
- const resolved = path30.resolve(root, setting.app);
1490
+ const resolved = path62.resolve(root, setting.app);
1479
1491
  const real2 = (p) => existsSync(p) ? realpathSync(p) : p;
1480
1492
  const dir = real2(resolved);
1481
- if (dir === real2(path30.resolve(root))) throw new GenesisConfigError(`${path30.join(root, "genesis.config.json")}: supabase.app "${setting.app}" is this app itself; leave "supabase" out instead`);
1482
- return { app: setting.app, dir, hasSupabase: existsSync(path30.join(dir, "supabase")) };
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")) };
1483
1495
  }
1484
1496
  function isSupabasePath(rel) {
1485
1497
  return rel === "supabase" || rel.startsWith("supabase/");
@@ -1525,7 +1537,7 @@ function migrationsMissingThere(home, ids, manifests) {
1525
1537
  }
1526
1538
  for (const fn of m.functions) {
1527
1539
  if (superseded.has(`${fn.package}:${fn.dir}`)) continue;
1528
- if (!existsSync(path30.join(home.dir, "supabase", "functions", fn.dir.split("/").pop()))) out.push({ block: id, what: `${fn.package} ${fn.dir}`, kind: "function" });
1540
+ if (!existsSync(path62.join(home.dir, "supabase", "functions", fn.dir.split("/").pop()))) out.push({ block: id, what: `${fn.package} ${fn.dir}`, kind: "function" });
1529
1541
  }
1530
1542
  }
1531
1543
  return out;
@@ -1564,11 +1576,11 @@ var init_database = __esm({
1564
1576
  }
1565
1577
  });
1566
1578
  function findPackageDir(from, name) {
1567
- let dir = path30.resolve(from);
1579
+ let dir = path62.resolve(from);
1568
1580
  for (; ; ) {
1569
- const candidate = path30.join(dir, "node_modules", name);
1570
- if (existsSync(path30.join(candidate, "package.json"))) return candidate;
1571
- const parent = path30.dirname(dir);
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);
1572
1584
  if (parent === dir) return null;
1573
1585
  dir = parent;
1574
1586
  }
@@ -1611,7 +1623,7 @@ function loadGenesis(root, config) {
1611
1623
  function notInstalled(root, uiPackage) {
1612
1624
  let declared = false;
1613
1625
  try {
1614
- const pkg = JSON.parse(readFileSync(path30.join(root, "package.json"), "utf8"));
1626
+ const pkg = JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
1615
1627
  declared = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"].some((s) => pkg[s]?.[uiPackage] !== void 0);
1616
1628
  } catch {
1617
1629
  }
@@ -1634,7 +1646,7 @@ function loadCompanions(root, config, uiPackage) {
1634
1646
  function readPackageExports(root, uiPackage) {
1635
1647
  const uiDir = findPackageDir(root, uiPackage);
1636
1648
  if (!uiDir) return null;
1637
- const uiPkg = JSON.parse(readFileSync(path30.join(uiDir, "package.json"), "utf8"));
1649
+ const uiPkg = JSON.parse(readFileSync(path62.join(uiDir, "package.json"), "utf8"));
1638
1650
  const subpaths = Object.values(uiPkg.exports ?? {});
1639
1651
  const declared = uiPkg.types ?? uiPkg.typings ?? exportTypes(uiPkg.exports?.["."] ?? uiPkg.exports);
1640
1652
  const fromSource = typeof declared !== "string" && !subpaths.some((t) => typeof exportTypes(t) === "string");
@@ -1661,23 +1673,23 @@ function readPackageExports(root, uiPackage) {
1661
1673
  }
1662
1674
  if (fromSource) {
1663
1675
  for (const m of code.matchAll(/export\s+\*\s+from\s*["'](\.[^"']*)["']/g)) {
1664
- const next = resolveSource(path30.dirname(file), m[1]);
1676
+ const next = resolveSource(path62.dirname(file), m[1]);
1665
1677
  if (next) readEntry(next);
1666
1678
  }
1667
1679
  }
1668
1680
  };
1669
- for (const entry of typeEntries) readEntry(path30.join(uiDir, entry));
1681
+ for (const entry of typeEntries) readEntry(path62.join(uiDir, entry));
1670
1682
  if (!readAny) {
1671
1683
  const what = fromSource ? "type declarations or TypeScript source" : "type declarations";
1672
1684
  throw new DoctorConfigError(`${uiPackage} has no ${what} to read (is it built?). Looked for: ${[...typeEntries].join(", ") || "none"}`);
1673
1685
  }
1674
1686
  const valueDecls = /* @__PURE__ */ new Set();
1675
1687
  const typeDecls = /* @__PURE__ */ new Set();
1676
- const declRoot = typeof mainTypes === "string" ? path30.dirname(path30.join(uiDir, mainTypes)) : uiDir;
1688
+ const declRoot = typeof mainTypes === "string" ? path62.dirname(path62.join(uiDir, mainTypes)) : uiDir;
1677
1689
  const declFiles = fromSource ? walkSource(declRoot) : walkDts(declRoot);
1678
1690
  for (const pkg of reexportedPackages) {
1679
1691
  const dir = findPackageDir(uiDir, pkg);
1680
- if (dir) walkDts(path30.join(dir, "dist"), declFiles);
1692
+ if (dir) walkDts(path62.join(dir, "dist"), declFiles);
1681
1693
  }
1682
1694
  for (const file of declFiles) {
1683
1695
  const text = readFileSync(file, "utf8");
@@ -1726,11 +1738,11 @@ function themeParts(root) {
1726
1738
  if (!ds) return null;
1727
1739
  if (partsCache.has(ds)) return partsCache.get(ds);
1728
1740
  let found = null;
1729
- const dist = path30.join(ds, "dist");
1741
+ const dist = path62.join(ds, "dist");
1730
1742
  try {
1731
1743
  for (const name of existsSync(dist) ? readdirSync(dist) : []) {
1732
1744
  if (!name.endsWith(".js")) continue;
1733
- const code = readFileSync(path30.join(dist, name), "utf8");
1745
+ const code = readFileSync(path62.join(dist, name), "utf8");
1734
1746
  const at = code.indexOf("THEME_PARTS = Object.freeze([");
1735
1747
  if (at === -1) continue;
1736
1748
  const body = code.slice(at, code.indexOf("]);", at));
@@ -1766,13 +1778,13 @@ function exportSource(target) {
1766
1778
  return void 0;
1767
1779
  }
1768
1780
  function resolveSource(dir, spec) {
1769
- const base = path30.resolve(dir, spec.replace(/\.js$/, ""));
1770
- const candidates = [base, ...[".ts", ".tsx", ".mts", ".cts"].map((e) => base + e), ...["index.ts", "index.tsx"].map((i) => path30.join(base, i))];
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))];
1771
1783
  return candidates.find((f) => TS_SOURCE.test(f) && existsSync(f) && statSync(f).isFile()) ?? null;
1772
1784
  }
1773
1785
  function insidePackage(dir, file) {
1774
- const rel = path30.relative(path30.resolve(dir), path30.resolve(file));
1775
- return rel === "" || !rel.startsWith("..") && !path30.isAbsolute(rel);
1786
+ const rel = path62.relative(path62.resolve(dir), path62.resolve(file));
1787
+ return rel === "" || !rel.startsWith("..") && !path62.isAbsolute(rel);
1776
1788
  }
1777
1789
  function stripComments(code) {
1778
1790
  let out = "";
@@ -1808,7 +1820,7 @@ function walkSource(dir, out = []) {
1808
1820
  if (!existsSync(dir)) return out;
1809
1821
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1810
1822
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
1811
- const p = path30.join(dir, entry.name);
1823
+ const p = path62.join(dir, entry.name);
1812
1824
  if (entry.isDirectory()) walkSource(p, out);
1813
1825
  else if (isTsSource(entry.name) || /\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1814
1826
  }
@@ -1828,7 +1840,7 @@ function walkDts(dir, out = []) {
1828
1840
  if (!existsSync(dir)) return out;
1829
1841
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
1830
1842
  if (entry.name === "node_modules") continue;
1831
- const p = path30.join(dir, entry.name);
1843
+ const p = path62.join(dir, entry.name);
1832
1844
  if (entry.isDirectory()) walkDts(p, out);
1833
1845
  else if (/\.d\.[cm]?ts$/.test(entry.name)) out.push(p);
1834
1846
  }
@@ -1845,27 +1857,27 @@ function resolveThemeFiles(root, config, uiDir) {
1845
1857
  }
1846
1858
  const files = [];
1847
1859
  const ds = findPackageDir(root, DESIGN_SYSTEM_PACKAGE);
1848
- const themes = ds && path30.join(ds, "dist", "themes");
1860
+ const themes = ds && path62.join(ds, "dist", "themes");
1849
1861
  if (themes && existsSync(themes)) {
1850
- for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path30.join(themes, name));
1862
+ for (const name of readdirSync(themes).sort()) if (name.endsWith(".css")) files.push(path62.join(themes, name));
1851
1863
  }
1852
1864
  if (files.length === 0) {
1853
1865
  throw new DoctorConfigError(
1854
1866
  `No Genesis theme stylesheet found (${DESIGN_SYSTEM_PACKAGE}/dist/themes/*.css). Install the design system, or set doctor.themeCss.`
1855
1867
  );
1856
1868
  }
1857
- const uiStyles = path30.join(uiDir, "dist", "styles.css");
1869
+ const uiStyles = path62.join(uiDir, "dist", "styles.css");
1858
1870
  if (existsSync(uiStyles)) files.push(uiStyles);
1859
1871
  return files;
1860
1872
  }
1861
1873
  function resolveSpec(root, spec) {
1862
- const local = path30.resolve(root, spec);
1863
- if (spec.startsWith(".") || path30.isAbsolute(spec)) return existsSync(local) ? local : null;
1874
+ const local = path62.resolve(root, spec);
1875
+ if (spec.startsWith(".") || path62.isAbsolute(spec)) return existsSync(local) ? local : null;
1864
1876
  const parts = spec.split("/");
1865
1877
  const nameLength = spec.startsWith("@") ? 2 : 1;
1866
1878
  const dir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
1867
1879
  if (dir) {
1868
- const file = path30.join(dir, ...parts.slice(nameLength));
1880
+ const file = path62.join(dir, ...parts.slice(nameLength));
1869
1881
  if (existsSync(file) && statSync(file).isFile()) return file;
1870
1882
  }
1871
1883
  return existsSync(local) ? local : null;
@@ -1873,7 +1885,7 @@ function resolveSpec(root, spec) {
1873
1885
  function loadPalette(root) {
1874
1886
  const names = new Set(TAILWIND_PALETTE);
1875
1887
  try {
1876
- const req = createRequire(path30.join(root, "package.json"));
1888
+ const req = createRequire(path62.join(root, "package.json"));
1877
1889
  const colors = req("tailwindcss/colors");
1878
1890
  for (const key2 of Object.keys(colors?.default ?? colors ?? {})) {
1879
1891
  if (/^[a-z]+$/.test(key2) && !["inherit", "current", "transparent"].includes(key2)) names.add(key2);
@@ -2121,7 +2133,7 @@ function globToRegExp(glob) {
2121
2133
  }
2122
2134
  function globMatcher(globs) {
2123
2135
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
2124
- return (path62) => res.some((re) => re.test(path62));
2136
+ return (path63) => res.some((re) => re.test(path63));
2125
2137
  }
2126
2138
  var init_glob = __esm({
2127
2139
  "src/doctor/glob.ts"() {
@@ -2133,9 +2145,9 @@ function scanFiles(root, config) {
2133
2145
  const files = [];
2134
2146
  const seen = /* @__PURE__ */ new Set();
2135
2147
  const visit = (abs) => {
2136
- const rel = toPosix(path30.relative(root, abs));
2148
+ const rel = toPosix(path62.relative(root, abs));
2137
2149
  if (seen.has(rel) || ignored(rel)) return;
2138
- const ext = path30.extname(abs);
2150
+ const ext = path62.extname(abs);
2139
2151
  if (!extensions.has(ext)) return;
2140
2152
  if (statSync(abs).size > MAX_FILE_BYTES) return;
2141
2153
  seen.add(rel);
@@ -2145,14 +2157,14 @@ function scanFiles(root, config) {
2145
2157
  const walk4 = (dir) => {
2146
2158
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
2147
2159
  if (entry.isDirectory()) {
2148
- if (!SKIP_DIRS.has(entry.name)) walk4(path30.join(dir, entry.name));
2160
+ if (!SKIP_DIRS.has(entry.name)) walk4(path62.join(dir, entry.name));
2149
2161
  } else if (entry.isFile()) {
2150
- visit(path30.join(dir, entry.name));
2162
+ visit(path62.join(dir, entry.name));
2151
2163
  }
2152
2164
  }
2153
2165
  };
2154
2166
  for (const src of config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)) {
2155
- const abs = path30.resolve(root, src);
2167
+ const abs = path62.resolve(root, src);
2156
2168
  if (!existsSync(abs)) continue;
2157
2169
  if (statSync(abs).isDirectory()) walk4(abs);
2158
2170
  else visit(abs);
@@ -2194,7 +2206,7 @@ var init_scan = __esm({
2194
2206
  ];
2195
2207
  SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", "coverage"]);
2196
2208
  MAX_FILE_BYTES = 2 * 1024 * 1024;
2197
- toPosix = (p) => p.split(path30.sep).join("/");
2209
+ toPosix = (p) => p.split(path62.sep).join("/");
2198
2210
  }
2199
2211
  });
2200
2212
 
@@ -2332,7 +2344,7 @@ function overlayState(name, json) {
2332
2344
  function overlaySetupProblems(root, config, dir, name, json) {
2333
2345
  const problems = [];
2334
2346
  if (json.private !== true) problems.push(`${name}: an overlay is the app's own copy and never publishes; set "private": true`);
2335
- const rel = path30.relative(path30.resolve(root), path30.resolve(dir)).split(path30.sep).join("/");
2347
+ const rel = path62.relative(path62.resolve(root), path62.resolve(dir)).split(path62.sep).join("/");
2336
2348
  const sources = (config.src ?? (config.packs?.includes("native") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)).map((s) => s.replace(/^\.\//, "").replace(/\/+$/, ""));
2337
2349
  const holds = sources.find((s) => rel === "" || s === rel || s.startsWith(`${rel}/`));
2338
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})`);
@@ -2368,7 +2380,7 @@ function pinnedVersion(root, name, manifests = ["package.json"]) {
2368
2380
  for (const file of manifests) {
2369
2381
  let json;
2370
2382
  try {
2371
- json = JSON.parse(readFileSync(path30.join(root, file), "utf8"));
2383
+ json = JSON.parse(readFileSync(path62.join(root, file), "utf8"));
2372
2384
  } catch {
2373
2385
  continue;
2374
2386
  }
@@ -2393,7 +2405,7 @@ function checkOverlays(ctx, now = /* @__PURE__ */ new Date()) {
2393
2405
  const file = `${pkg.rel}/package.json`;
2394
2406
  let json;
2395
2407
  try {
2396
- json = JSON.parse(readFileSync(path30.join(pkg.dir, "package.json"), "utf8"));
2408
+ json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
2397
2409
  } catch {
2398
2410
  continue;
2399
2411
  }
@@ -2466,7 +2478,7 @@ var init_overlays = __esm({
2466
2478
  });
2467
2479
  function readReleaseManifest(root) {
2468
2480
  const dir = findPackageDir(root, UMBRELLA_PACKAGE);
2469
- const file = dir && path30.join(dir, "dist", "versions.json");
2481
+ const file = dir && path62.join(dir, "dist", "versions.json");
2470
2482
  if (!file || !existsSync(file)) return null;
2471
2483
  return JSON.parse(readFileSync(file, "utf8"));
2472
2484
  }
@@ -2492,7 +2504,7 @@ function checkVersionSkew(ctx) {
2492
2504
  }
2493
2505
  const dir = findPackageDir(ctx.root, name);
2494
2506
  if (!dir) continue;
2495
- const have = JSON.parse(readFileSync(path30.join(dir, "package.json"), "utf8")).version;
2507
+ const have = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8")).version;
2496
2508
  if (have === want) continue;
2497
2509
  ctx.report({
2498
2510
  rule: "version-skew",
@@ -2513,13 +2525,13 @@ var init_versions = __esm({
2513
2525
  }
2514
2526
  });
2515
2527
  function findLockfile(root) {
2516
- let dir = path30.resolve(root);
2528
+ let dir = path62.resolve(root);
2517
2529
  for (; ; ) {
2518
- if (existsSync(path30.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
2519
- if (existsSync(path30.join(dir, "bun.lock")) || existsSync(path30.join(dir, "bun.lockb"))) return { pm: "bun", dir };
2520
- if (existsSync(path30.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
2521
- if (existsSync(path30.join(dir, "package-lock.json"))) return { pm: "npm", dir };
2522
- const parent = path30.dirname(dir);
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);
2523
2535
  if (parent === dir) return null;
2524
2536
  dir = parent;
2525
2537
  }
@@ -2563,10 +2575,10 @@ var init_pm = __esm({
2563
2575
  function walk(dir, exclude = []) {
2564
2576
  const out = [];
2565
2577
  const visit = (rel) => {
2566
- for (const name of readdirSync(path30.join(dir, rel)).sort()) {
2578
+ for (const name of readdirSync(path62.join(dir, rel)).sort()) {
2567
2579
  const child = rel ? `${rel}/${name}` : name;
2568
2580
  if (exclude.some((r) => r.test(child))) continue;
2569
- const stat = statSync(path30.join(dir, child));
2581
+ const stat = statSync(path62.join(dir, child));
2570
2582
  if (stat.isDirectory()) visit(child);
2571
2583
  else if (stat.isFile()) out.push(child);
2572
2584
  }
@@ -2595,17 +2607,17 @@ var init_walk = __esm({
2595
2607
  });
2596
2608
  function starterDir() {
2597
2609
  const workspace = workspacePackagesDir();
2598
- const live = workspace && path30.join(workspace, "..", "apps", "genesis-rn-starter");
2599
- if (live && existsSync(path30.join(live, "package.json"))) return live;
2600
- const packaged = path30.join(cliPackageDir(), "dist", "starter");
2601
- if (existsSync(path30.join(packaged, "package.json"))) return packaged;
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;
2602
2614
  throw new Error("This genesis-cli has no starter (dist/starter is missing): reinstall @marktiderman/genesis-cli.");
2603
2615
  }
2604
2616
  function templatesDir(cliDir = cliPackageDir()) {
2605
2617
  const workspace = workspacePackagesDir();
2606
- const live = workspace && cliDir === cliPackageDir() ? path30.join(workspace, "..", "templates") : null;
2607
- if (live && existsSync(path30.join(live, "eas"))) return live;
2608
- const packaged = path30.join(cliDir, "dist", "templates");
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");
2609
2621
  if (existsSync(packaged)) return packaged;
2610
2622
  throw new Error(`${cliDir} has no templates (dist/templates is missing).`);
2611
2623
  }
@@ -2702,7 +2714,7 @@ function readText(file) {
2702
2714
  }
2703
2715
  function starterBlockMap(root) {
2704
2716
  if (root) {
2705
- const file = path30.join(root, GENESIS_CONFIG);
2717
+ const file = path62.join(root, GENESIS_CONFIG);
2706
2718
  const text2 = readText(file);
2707
2719
  const own = text2 === null ? null : parseStarterBlocks(text2, file);
2708
2720
  if (own) return own;
@@ -2713,7 +2725,7 @@ function starterBlockMap(root) {
2713
2725
  } catch {
2714
2726
  return {};
2715
2727
  }
2716
- const text = readText(path30.join(dir, GENESIS_CONFIG));
2728
+ const text = readText(path62.join(dir, GENESIS_CONFIG));
2717
2729
  return (text === null ? null : parseStarterBlocks(text)) ?? {};
2718
2730
  }
2719
2731
  function blocksSwitchedOff(switches, map, manifests, present) {
@@ -2733,10 +2745,10 @@ function blocksSwitchedOff(switches, map, manifests, present) {
2733
2745
  return off;
2734
2746
  }
2735
2747
  function appBlocksSwitchedOff(root, manifests, present) {
2736
- const text = readText(path30.join(root, STARTER_CONFIG));
2748
+ const text = readText(path62.join(root, STARTER_CONFIG));
2737
2749
  const switches = text === null ? null : parseStarterFeatures(text);
2738
2750
  if (!switches) return /* @__PURE__ */ new Map();
2739
- return blocksSwitchedOff(switches, starterBlockMap(existsSync(path30.join(root, GENESIS_CONFIG)) ? root : void 0), manifests, present);
2751
+ return blocksSwitchedOff(switches, starterBlockMap(existsSync(path62.join(root, GENESIS_CONFIG)) ? root : void 0), manifests, present);
2740
2752
  }
2741
2753
  function switchedOffNote(id, feature) {
2742
2754
  return `${id}: features.${feature} is off in ${STARTER_CONFIG}, so it's left out (turn it on to have it again)`;
@@ -2856,18 +2868,18 @@ function initNative(options) {
2856
2868
  if (!BUNDLE.test(bundleId)) throw new Error(`"${bundleId}" isn't a bundle id like com.example.app.`);
2857
2869
  if (!SCHEME.test(scheme)) throw new Error(`"${scheme}" isn't a URL scheme.`);
2858
2870
  if (/["\\\n]/.test(display)) throw new Error("The display name can't contain quotes, backslashes or new lines.");
2859
- const target = path30.resolve(options.target);
2871
+ const target = path62.resolve(options.target);
2860
2872
  if (existsSync(target) && readdirSync(target).length) throw new Error(`${target} isn't empty; init writes into a new folder and never overwrites.`);
2861
2873
  let beside;
2862
2874
  if (options.beside !== void 0) {
2863
- const dir = path30.resolve(options.beside);
2875
+ const dir = path62.resolve(options.beside);
2864
2876
  if (!existsSync(dir)) throw new Error(`--beside: ${options.beside} doesn't exist; name the web app's folder.`);
2865
2877
  if (dir === target) throw new Error("--beside names the new app's own folder; name the web app's folder.");
2866
- beside = { dir, app: path30.relative(target, dir).split(path30.sep).join("/"), shared: existsSync(path30.join(dir, "supabase")) };
2878
+ beside = { dir, app: path62.relative(target, dir).split(path62.sep).join("/"), shared: existsSync(path62.join(dir, "supabase")) };
2867
2879
  }
2868
2880
  const shared = beside?.shared === true;
2869
2881
  const source = starterDir();
2870
- const read3 = (rel) => readFileSync(path30.join(source, rel), "utf8");
2882
+ const read3 = (rel) => readFileSync(path62.join(source, rel), "utf8");
2871
2883
  const was = starterIdentity(read3(STARTER_CONFIG));
2872
2884
  const switches = parseStarterFeatures(read3(STARTER_CONFIG)) ?? {};
2873
2885
  const without = [...new Set(options.without ?? [])];
@@ -2910,7 +2922,7 @@ function initNative(options) {
2910
2922
  files.set("package.json", `${JSON.stringify(pkg, null, 2)}
2911
2923
  `);
2912
2924
  files.set("metro.config.js", METRO);
2913
- const pnpmSettings = [path30.join(source, "pnpm-workspace.yaml"), path30.join(source, "..", "..", "pnpm-workspace.yaml")].find((f) => existsSync(f));
2925
+ const pnpmSettings = [path62.join(source, "pnpm-workspace.yaml"), path62.join(source, "..", "..", "pnpm-workspace.yaml")].find((f) => existsSync(f));
2914
2926
  if (pnpmSettings) files.set("pnpm-workspace.yaml", appPnpmSettings(readFileSync(pnpmSettings, "utf8")));
2915
2927
  files.set("README.md", readme(display, slug, shared ? beside.app : void 0));
2916
2928
  if (without.length) files.set(STARTER_CONFIG, setStarterFeatures(files.get(STARTER_CONFIG), Object.fromEntries(without.map((w) => [w, false]))));
@@ -2931,7 +2943,7 @@ function initNative(options) {
2931
2943
  const templates = templatesDir();
2932
2944
  for (const rel of walk(templates)) {
2933
2945
  if (shared && DATABASE_TEMPLATES.has(rel)) continue;
2934
- const text = substitute(readFileSync(path30.join(templates, rel), "utf8"), substitutions);
2946
+ const text = substitute(readFileSync(path62.join(templates, rel), "utf8"), substitutions);
2935
2947
  const to = templateTarget(rel, text);
2936
2948
  files.set(to, text);
2937
2949
  lock.files[to] = { source: `${CLI_PACKAGE}:templates/${rel}`, sha256: sha256(text), ...cliVersion2 ? { version: cliVersion2 } : {} };
@@ -2950,14 +2962,14 @@ function initNative(options) {
2950
2962
  continue;
2951
2963
  }
2952
2964
  const stems = block.migrations.map((m) => stemOf(m.file));
2953
- const copies = stems.map((s) => migrations.find((f) => path30.posix.basename(f).replace(/^\d+_/, "") === `${s}.sql`));
2965
+ const copies = stems.map((s) => migrations.find((f) => path62.posix.basename(f).replace(/^\d+_/, "") === `${s}.sql`));
2954
2966
  if (!stems.length || copies.some((c) => !c)) continue;
2955
2967
  blocks.push(block.id);
2956
2968
  lock.blocks[block.id] = { package: block.package, ...block.version ? { version: block.version } : {} };
2957
2969
  block.migrations.forEach((m, i) => {
2958
2970
  lock.migrations = { ...lock.migrations, [migrationKey(m.package, m.file)]: copies[i] };
2959
2971
  if (m.test) {
2960
- const test2 = `${TESTS_DIR}/${path30.posix.basename(m.test).replace(/^\d{4}_/, "")}`;
2972
+ const test2 = `${TESTS_DIR}/${path62.posix.basename(m.test).replace(/^\d{4}_/, "")}`;
2961
2973
  if (files.has(test2)) lock.files[test2] = { source: `${m.package}:${m.test}`, sha256: sha256(files.get(test2)) };
2962
2974
  }
2963
2975
  });
@@ -2970,8 +2982,8 @@ function initNative(options) {
2970
2982
  }
2971
2983
  mkdirSync(target, { recursive: true });
2972
2984
  for (const [rel, content] of [...files].sort(([a], [b]) => a.localeCompare(b))) {
2973
- const file = path30.join(target, ...rel.split("/"));
2974
- mkdirSync(path30.dirname(file), { recursive: true });
2985
+ const file = path62.join(target, ...rel.split("/"));
2986
+ mkdirSync(path62.dirname(file), { recursive: true });
2975
2987
  writeFileSync(file, content, { encoding: "utf8", flag: "wx" });
2976
2988
  }
2977
2989
  writeLock(target, lock);
@@ -3008,11 +3020,11 @@ function besideConfig(text, app) {
3008
3020
  `;
3009
3021
  }
3010
3022
  function carriedBy(files, block) {
3011
- const names = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => path30.posix.basename(f).replace(/^\d+_/, ""));
3023
+ const names = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => path62.posix.basename(f).replace(/^\d+_/, ""));
3012
3024
  return block.migrations.length > 0 && block.migrations.every((m) => names.includes(`${stemOf(m.file)}.sql`));
3013
3025
  }
3014
3026
  function sinceAfter(files) {
3015
- const versions = [...files.keys()].filter((f) => f.startsWith(`${MIGRATIONS_DIR}/`) && f.endsWith(".sql")).map((f) => /^(\d{14})_/.exec(path30.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(path62.posix.basename(f))?.[1]).filter((v) => Boolean(v)).sort();
3016
3028
  const last = versions.at(-1);
3017
3029
  return last ? nextStamp(last) : null;
3018
3030
  }
@@ -3027,12 +3039,12 @@ function leaveOut(files, blocks) {
3027
3039
  for (const block of blocks) {
3028
3040
  for (const m of block.migrations) {
3029
3041
  const stem = stemOf(m.file);
3030
- for (const copy of migrations.filter((f) => path30.posix.basename(f).replace(/^\d+_/, "") === `${stem}.sql`)) {
3042
+ for (const copy of migrations.filter((f) => path62.posix.basename(f).replace(/^\d+_/, "") === `${stem}.sql`)) {
3031
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());
3032
3044
  files.delete(copy);
3033
3045
  }
3034
3046
  files.delete(`${TESTS_DIR}/${stem}.test.sql`);
3035
- if (m.test) files.delete(`${TESTS_DIR}/${path30.posix.basename(m.test).replace(/^\d{4}_/, "")}`);
3047
+ if (m.test) files.delete(`${TESTS_DIR}/${path62.posix.basename(m.test).replace(/^\d{4}_/, "")}`);
3036
3048
  }
3037
3049
  for (const fn of block.functions) {
3038
3050
  const name = fn.dir.split("/").pop();
@@ -3102,6 +3114,15 @@ module.exports = withNativeWind(getDefaultConfig(__dirname), { input: "./global.
3102
3114
  }
3103
3115
  });
3104
3116
 
3117
+ // src/regexp.ts
3118
+ function escapeRegExp(s) {
3119
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3120
+ }
3121
+ var init_regexp = __esm({
3122
+ "src/regexp.ts"() {
3123
+ }
3124
+ });
3125
+
3105
3126
  // src/introspect/catalog-text.ts
3106
3127
  function tokenize(tree) {
3107
3128
  const tokens = [];
@@ -3231,9 +3252,6 @@ function splitTopLevel(expr, separator) {
3231
3252
  parts.push(expr.slice(from));
3232
3253
  return parts;
3233
3254
  }
3234
- function escapeRegExp(s) {
3235
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3236
- }
3237
3255
  function checkEnumValues(definition, column) {
3238
3256
  const outer = /^CHECK \((.*)\)(?: NOT VALID)?$/s.exec(definition.trim());
3239
3257
  if (!outer) return void 0;
@@ -3268,6 +3286,7 @@ function checkEnumValues(definition, column) {
3268
3286
  var CAST, LITERAL;
3269
3287
  var init_catalog_text = __esm({
3270
3288
  "src/introspect/catalog-text.ts"() {
3289
+ init_regexp();
3271
3290
  CAST = String.raw`::[a-z][a-z ]*(?:\(\d+(?:,\d+)?\))?`;
3272
3291
  LITERAL = String.raw`'((?:[^']|'')*)'${CAST}`;
3273
3292
  }
@@ -3845,7 +3864,7 @@ async function checkContracts(ctx, read3 = postgresContract) {
3845
3864
  const env = settings2.databaseEnv ?? DEFAULT_DATABASE_ENV;
3846
3865
  let current = null;
3847
3866
  try {
3848
- current = lf(readFileSync(path30.join(ctx.root, out), "utf8"));
3867
+ current = lf(readFileSync(path62.join(ctx.root, out), "utf8"));
3849
3868
  } catch {
3850
3869
  current = null;
3851
3870
  }
@@ -3869,7 +3888,7 @@ async function checkContracts(ctx, read3 = postgresContract) {
3869
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}` });
3870
3889
  return;
3871
3890
  }
3872
- const target = path30.relative(process.cwd(), path30.join(ctx.root, out)) || out;
3891
+ const target = path62.relative(process.cwd(), path62.join(ctx.root, out)) || out;
3873
3892
  const command = `genesis introspect -o ${shellArg(target)} -s ${shellArg(schemas.join(","))}${env === DEFAULT_DATABASE_ENV ? "" : ` --database-env ${shellArg(env)}`}`;
3874
3893
  if (current !== expected) {
3875
3894
  ctx.report({
@@ -3897,7 +3916,7 @@ __export(settings_exports, {
3897
3916
  });
3898
3917
  function introspectSettings(flags, root, contracts, readCurrent = () => null) {
3899
3918
  const out = flags.out ?? contracts?.out ?? DEFAULT_CONTRACT_OUT;
3900
- const target = path30.resolve(root, out);
3919
+ const target = path62.resolve(root, out);
3901
3920
  return { target, label: out, schemas: schemasFor(flags, target, contracts, readCurrent), databaseEnv: flags.databaseEnv ?? contracts?.databaseEnv ?? DEFAULT_DATABASE_ENV };
3902
3921
  }
3903
3922
  function schemasFor(flags, target, contracts, readCurrent) {
@@ -3913,19 +3932,19 @@ var init_settings = __esm({
3913
3932
  });
3914
3933
  function buildCommands(root, config) {
3915
3934
  if (config.build) return config.build;
3916
- const pkgFile = path30.join(root, "package.json");
3935
+ const pkgFile = path62.join(root, "package.json");
3917
3936
  const scripts = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, "utf8")).scripts ?? {} : {};
3918
3937
  const pm = packageManager(root);
3919
3938
  return ["typecheck", "build"].filter((s) => scripts[s]).map((s) => `${pm} run ${s}`);
3920
3939
  }
3921
3940
  function packageManager(root) {
3922
- let dir = path30.resolve(root);
3941
+ let dir = path62.resolve(root);
3923
3942
  for (; ; ) {
3924
- if (existsSync(path30.join(dir, "pnpm-lock.yaml"))) return "pnpm";
3925
- if (existsSync(path30.join(dir, "bun.lock")) || existsSync(path30.join(dir, "bun.lockb"))) return "bun";
3926
- if (existsSync(path30.join(dir, "yarn.lock"))) return "yarn";
3927
- if (existsSync(path30.join(dir, "package-lock.json"))) return "npm";
3928
- const parent = path30.dirname(dir);
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);
3929
3948
  if (parent === dir) return "npm";
3930
3949
  dir = parent;
3931
3950
  }
@@ -4023,7 +4042,7 @@ function loadPatternRules(root, patterns, rulesDoc) {
4023
4042
  const compiled = compilePatternRules(patterns ?? [], "doctor.patterns");
4024
4043
  let all = compiled;
4025
4044
  if (rulesDoc) {
4026
- const file = path30.resolve(root, rulesDoc);
4045
+ const file = path62.resolve(root, rulesDoc);
4027
4046
  if (!existsSync(file)) throw new DoctorConfigError(`doctor.rulesDoc: ${rulesDoc} not found`);
4028
4047
  const fromDoc = compilePatternRules(parseRulesMarkdown(readFileSync(file, "utf8")), rulesDoc);
4029
4048
  const clash = fromDoc.find((d) => compiled.some((c) => c.rule.id === d.rule.id));
@@ -4091,20 +4110,336 @@ async function loadPlugins(specs, configDir) {
4091
4110
  }
4092
4111
  function resolvePlugin(id, configDir) {
4093
4112
  try {
4094
- if (id.startsWith(".") || path30.isAbsolute(id)) return resolveFrom(path30.resolve(configDir, id), configDir);
4113
+ if (id.startsWith(".") || path62.isAbsolute(id)) return resolveFrom(path62.resolve(configDir, id), configDir);
4095
4114
  return resolveFrom(id, configDir);
4096
4115
  } catch {
4097
4116
  throw new DoctorConfigError(`doctor.plugins: cannot find ${id} (relative paths resolve from ${configDir})`);
4098
4117
  }
4099
4118
  }
4100
4119
  function resolveFrom(id, from) {
4101
- return createRequire(path30.join(from, "noop.js")).resolve(id);
4120
+ return createRequire(path62.join(from, "noop.js")).resolve(id);
4102
4121
  }
4103
4122
  var init_plugins = __esm({
4104
4123
  "src/doctor/plugins.ts"() {
4105
4124
  init_config();
4106
4125
  }
4107
4126
  });
4127
+
4128
+ // src/doctor/js-scan.ts
4129
+ function scanCode(code, options = {}) {
4130
+ const jsx = options.jsx ?? true;
4131
+ const tokens = [];
4132
+ const push = (kind, value) => tokens.push({ kind, value, index: tokens.length });
4133
+ const expressionNext = (start) => {
4134
+ if (tokens.length <= start) return true;
4135
+ const t = tokens[tokens.length - 1];
4136
+ if (!t) return true;
4137
+ if (t.kind === "ident") return EXPRESSION_KEYWORDS.has(t.value);
4138
+ if (t.kind === "jsxTag" || t.kind === "literal") return false;
4139
+ return !(t.value === ")" || t.value === "]" || t.value === "}" || t.value === "<>");
4140
+ };
4141
+ const skipString2 = (i2, quote2) => {
4142
+ let j = i2 + 1;
4143
+ while (j < code.length && code[j] !== quote2) {
4144
+ if (code[j] === "\\") j++;
4145
+ else if (code[j] === "\n") return j;
4146
+ j++;
4147
+ }
4148
+ return j + 1;
4149
+ };
4150
+ const skipAttribute = (i2, quote2) => {
4151
+ const end = code.indexOf(quote2, i2 + 1);
4152
+ return end < 0 ? code.length : end + 1;
4153
+ };
4154
+ const skipRegex = (i2) => {
4155
+ let j = i2 + 1;
4156
+ let inClass = false;
4157
+ while (j < code.length && code[j] !== "\n") {
4158
+ const c = code[j];
4159
+ if (c === "\\") j++;
4160
+ else if (c === "[") inClass = true;
4161
+ else if (c === "]") inClass = false;
4162
+ else if (c === "/" && !inClass) {
4163
+ j++;
4164
+ while (j < code.length && IDENT.test(code[j])) j++;
4165
+ return j;
4166
+ }
4167
+ j++;
4168
+ }
4169
+ return j;
4170
+ };
4171
+ const skipTrivia = (i2) => {
4172
+ let j = i2;
4173
+ for (; ; ) {
4174
+ while (j < code.length && /\s/.test(code[j])) j++;
4175
+ if (code.startsWith("//", j)) {
4176
+ const end = code.indexOf("\n", j);
4177
+ j = end < 0 ? code.length : end;
4178
+ } else if (code.startsWith("/*", j)) {
4179
+ const end = code.indexOf("*/", j + 2);
4180
+ j = end < 0 ? code.length : end + 2;
4181
+ } else return j;
4182
+ }
4183
+ };
4184
+ const stack = [{ k: "code", depth: 0, stop: false, start: 0 }];
4185
+ const openCode = () => stack.push({ k: "code", depth: 0, stop: true, start: tokens.length });
4186
+ const openElement = (i2) => {
4187
+ if (code[i2 + 1] === ">") {
4188
+ stack.push({ k: "children" });
4189
+ return i2 + 2;
4190
+ }
4191
+ let j = i2 + 1;
4192
+ while (j < code.length && /[\w$.:-]/.test(code[j])) j++;
4193
+ const name = code.slice(i2 + 1, j);
4194
+ if (name) push("jsxTag", name.split(/[.:]/)[0]);
4195
+ stack.push({ k: "tag" });
4196
+ return j;
4197
+ };
4198
+ const closeElement = () => {
4199
+ stack.pop();
4200
+ push("punct", "<>");
4201
+ };
4202
+ let i = 0;
4203
+ while (i < code.length) {
4204
+ const top = stack[stack.length - 1];
4205
+ if (top.k === "code") {
4206
+ i = skipTrivia(i);
4207
+ if (i >= code.length) break;
4208
+ const c = code[i];
4209
+ if (c === '"' || c === "'") {
4210
+ i = skipString2(i, c);
4211
+ push("literal", "''");
4212
+ } else if (c === "`") {
4213
+ stack.push({ k: "template" });
4214
+ i++;
4215
+ } else if (IDENT_START.test(c)) {
4216
+ let j = i + 1;
4217
+ while (j < code.length && IDENT.test(code[j])) j++;
4218
+ push("ident", code.slice(i, j));
4219
+ i = j;
4220
+ } else if (/\d/.test(c) || c === "." && /\d/.test(code[i + 1] ?? "")) {
4221
+ let j = i + 1;
4222
+ while (j < code.length && /[\w.]/.test(code[j])) j++;
4223
+ push("literal", "0");
4224
+ i = j;
4225
+ } else if (c === "/" && expressionNext(top.start)) {
4226
+ i = skipRegex(i);
4227
+ push("literal", "//");
4228
+ } else if (c === "<" && jsx && expressionNext(top.start) && /[A-Za-z_$>]/.test(code[i + 1] ?? "") && !TYPE_PARAMETERS.test(code.slice(i, i + 200))) {
4229
+ i = openElement(i);
4230
+ } else if (c === "{") {
4231
+ top.depth++;
4232
+ push("punct", "{");
4233
+ i++;
4234
+ } else if (c === "}") {
4235
+ i++;
4236
+ if (top.depth === 0 && top.stop) stack.pop();
4237
+ else {
4238
+ top.depth = Math.max(0, top.depth - 1);
4239
+ push("punct", "}");
4240
+ }
4241
+ } else {
4242
+ const three = code.slice(i, i + 3);
4243
+ const two = code.slice(i, i + 2);
4244
+ const p = PUNCT3.includes(three) ? three : PUNCT2.includes(two) ? two : c;
4245
+ push("punct", p);
4246
+ i += p.length;
4247
+ }
4248
+ } else if (top.k === "template") {
4249
+ const c = code[i];
4250
+ if (c === "\\") i += 2;
4251
+ else if (c === "`") {
4252
+ stack.pop();
4253
+ push("literal", "``");
4254
+ i++;
4255
+ } else if (c === "$" && code[i + 1] === "{") {
4256
+ openCode();
4257
+ i += 2;
4258
+ } else i++;
4259
+ } else if (top.k === "tag") {
4260
+ i = skipTrivia(i);
4261
+ const c = code[i];
4262
+ if (c === void 0) break;
4263
+ if (c === "/" && code[i + 1] === ">") {
4264
+ closeElement();
4265
+ i += 2;
4266
+ } else if (c === ">") {
4267
+ stack[stack.length - 1] = { k: "children" };
4268
+ i++;
4269
+ } else if (c === "{") {
4270
+ openCode();
4271
+ i++;
4272
+ } else if (c === '"' || c === "'") i = skipAttribute(i, c);
4273
+ else if (c === "<") i = openElement(i);
4274
+ else i++;
4275
+ } else {
4276
+ const c = code[i];
4277
+ if (c === "<" && code[i + 1] === "/") {
4278
+ const end = code.indexOf(">", i);
4279
+ i = end < 0 ? code.length : end + 1;
4280
+ closeElement();
4281
+ } else if (c === "<" && /[A-Za-z_$>]/.test(code[i + 1] ?? "")) i = openElement(i);
4282
+ else if (c === "{") {
4283
+ openCode();
4284
+ i++;
4285
+ } else i++;
4286
+ }
4287
+ }
4288
+ return tokens;
4289
+ }
4290
+ function usesAsCode(code, name, options = {}) {
4291
+ const tokens = scanCode(code, options);
4292
+ return tokens.some((t, i) => {
4293
+ if (t.value !== name) return false;
4294
+ if (t.kind === "jsxTag") return true;
4295
+ if (t.kind !== "ident") return false;
4296
+ const before = tokens[i - 1];
4297
+ const after = tokens[i + 1];
4298
+ if (before?.value === "." || before?.value === "?." || before?.value === "as" || before?.value === "import") return false;
4299
+ if (after?.value === ":" && (before?.value === "{" || before?.value === ",")) return false;
4300
+ return true;
4301
+ });
4302
+ }
4303
+ function boundNames(list) {
4304
+ const out = [];
4305
+ const params = [[]];
4306
+ let depth = 0;
4307
+ let angles = 0;
4308
+ let inType = false;
4309
+ for (const t of list) {
4310
+ if (OPENS.has(t.value)) depth++;
4311
+ else if (CLOSES.has(t.value)) depth--;
4312
+ else if (depth === 0 && t.value === ":") inType = true;
4313
+ else if (depth === 0 && t.value === "=") inType = false;
4314
+ else if (inType && t.value === "<") angles++;
4315
+ else if (inType && (t.value === ">" || t.value === ">>")) angles = Math.max(0, angles - t.value.length);
4316
+ if (depth === 0 && angles === 0 && t.value === ",") {
4317
+ params.push([]);
4318
+ inType = false;
4319
+ } else params[params.length - 1].push(t);
4320
+ }
4321
+ for (const param of params) {
4322
+ let d = 0;
4323
+ let end = param.length;
4324
+ for (let k = 0; k < param.length; k++) {
4325
+ const v = param[k].value;
4326
+ if (OPENS.has(v)) d++;
4327
+ else if (CLOSES.has(v)) d--;
4328
+ else if (d === 0 && (v === "=" || v === ":" || v === "?")) {
4329
+ end = k;
4330
+ break;
4331
+ }
4332
+ }
4333
+ const pattern = param.slice(0, end);
4334
+ let skipping = -1;
4335
+ d = 0;
4336
+ for (let k = 0; k < pattern.length; k++) {
4337
+ const t = pattern[k];
4338
+ if (t.value === "[" && skipping < 0) {
4339
+ let depth2 = 0;
4340
+ let close = k;
4341
+ for (; close < pattern.length; close++) {
4342
+ const v = pattern[close].value;
4343
+ if (OPENS.has(v)) depth2++;
4344
+ else if (CLOSES.has(v) && --depth2 === 0) break;
4345
+ }
4346
+ if (pattern[close + 1]?.value === ":") {
4347
+ k = close;
4348
+ continue;
4349
+ }
4350
+ }
4351
+ if (OPENS.has(t.value)) d++;
4352
+ else if (CLOSES.has(t.value)) {
4353
+ d--;
4354
+ if (skipping > d) skipping = -1;
4355
+ }
4356
+ if (skipping >= 0) {
4357
+ if (t.value === "," && d === skipping) skipping = -1;
4358
+ continue;
4359
+ }
4360
+ if (t.value === "=") {
4361
+ skipping = d;
4362
+ continue;
4363
+ }
4364
+ if (t.kind === "ident" && pattern[k + 1]?.value !== ":") out.push(t.value);
4365
+ }
4366
+ }
4367
+ return out;
4368
+ }
4369
+ function boundAsParameter(code, name, options = {}) {
4370
+ const tokens = scanCode(code, options);
4371
+ const match = new Int32Array(tokens.length).fill(-1);
4372
+ const open = [];
4373
+ tokens.forEach((t, k) => {
4374
+ if (t.value === "(") open.push(k);
4375
+ else if (t.value === ")" && open.length) match[open.pop()] = k;
4376
+ });
4377
+ const arrowAfter = (end) => {
4378
+ const next = tokens[end + 1];
4379
+ if (next?.value === "=>") return true;
4380
+ if (next?.value !== ":") return false;
4381
+ let depth = 0;
4382
+ for (let k = end + 2; k < Math.min(tokens.length, end + 200); k++) {
4383
+ const v = tokens[k].value;
4384
+ if (v === "(" || v === "{" || v === "[" || v === "<") depth++;
4385
+ else if (v === ")" || v === "}" || v === "]" || v === ">") depth--;
4386
+ if (depth < 0) return false;
4387
+ if (depth === 0 && v === "=>") return true;
4388
+ if (depth === 0 && (v === ";" || v === "," || v === "=")) return false;
4389
+ }
4390
+ return false;
4391
+ };
4392
+ const beforeTypeParameters = (paren) => {
4393
+ let k = paren - 1;
4394
+ if (tokens[k]?.value !== ">" && tokens[k]?.value !== ">>") return k;
4395
+ let depth = 0;
4396
+ for (const stop = Math.max(0, k - TYPE_PARAMETERS_REACH); k >= stop; k--) {
4397
+ const v = tokens[k].value;
4398
+ if (v === ">") depth++;
4399
+ else if (v === ">>") depth += 2;
4400
+ else if (v === "<" && --depth === 0) return k - 1;
4401
+ }
4402
+ return -1;
4403
+ };
4404
+ const isFunction = (paren) => {
4405
+ let k = beforeTypeParameters(paren);
4406
+ if (k < 0) return false;
4407
+ if (tokens[k]?.kind === "ident" && tokens[k].value !== "function") k--;
4408
+ if (tokens[k]?.value === "*") k--;
4409
+ return tokens[k]?.value === "function";
4410
+ };
4411
+ for (let i = 0; i < tokens.length; i++) {
4412
+ const t = tokens[i];
4413
+ if (t.value === "=>" && tokens[i - 1]?.kind === "ident" && tokens[i - 1].value === name && tokens[i - 2]?.value !== ".") return true;
4414
+ if (t.value !== "(") continue;
4415
+ const end = match[i];
4416
+ if (end < 0) continue;
4417
+ const before = tokens[i - 1];
4418
+ const catchClause = before?.value === "catch";
4419
+ const nameAt = beforeTypeParameters(i);
4420
+ const methodName = nameAt >= 0 ? tokens[nameAt] : void 0;
4421
+ const typed = tokens[end + 1]?.value === ":" && !arrowAfter(end);
4422
+ const method = !catchClause && methodName?.kind === "ident" && !NOT_METHODS.has(methodName.value) && (tokens[end + 1]?.value === "{" || typed && (nameAt === 0 || BEFORE_METHOD.has(tokens[nameAt - 1].value)));
4423
+ if ((catchClause || isFunction(i) || method || arrowAfter(end)) && boundNames(tokens.slice(i + 1, end)).includes(name)) return true;
4424
+ }
4425
+ return false;
4426
+ }
4427
+ var IDENT_START, IDENT, PUNCT3, PUNCT2, EXPRESSION_KEYWORDS, TYPE_PARAMETERS, NOT_METHODS, BEFORE_METHOD, TYPE_PARAMETERS_REACH, OPENS, CLOSES;
4428
+ var init_js_scan = __esm({
4429
+ "src/doctor/js-scan.ts"() {
4430
+ IDENT_START = /[A-Za-z_$]/;
4431
+ IDENT = /[\w$]/;
4432
+ PUNCT3 = ["...", "===", "!==", "**=", "<<=", ">>=", "??=", "&&=", "||="];
4433
+ PUNCT2 = ["=>", "==", "!=", "<=", ">=", "&&", "||", "??", "?.", "++", "--", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "**", "<<", ">>"];
4434
+ EXPRESSION_KEYWORDS = /* @__PURE__ */ new Set(["return", "typeof", "case", "do", "else", "in", "new", "delete", "void", "throw", "yield", "await", "instanceof"]);
4435
+ TYPE_PARAMETERS = /^<\s*[A-Za-z_$][\w$]*\s*(?:,|extends\b)/;
4436
+ NOT_METHODS = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "with", "function", "return", "typeof", "await", "new"]);
4437
+ BEFORE_METHOD = /* @__PURE__ */ new Set(["{", "}", ";", ",", "*", "async", "get", "set", "static", "public", "private", "protected", "readonly", "override", "abstract", "declare", "accessor"]);
4438
+ TYPE_PARAMETERS_REACH = 200;
4439
+ OPENS = /* @__PURE__ */ new Set(["(", "[", "{"]);
4440
+ CLOSES = /* @__PURE__ */ new Set([")", "]", "}"]);
4441
+ }
4442
+ });
4108
4443
  function importSpecifiers(file) {
4109
4444
  const out = [];
4110
4445
  const lines = file.code.split("\n");
@@ -4116,7 +4451,7 @@ function importSpecifiers(file) {
4116
4451
  }
4117
4452
  function checkProjectLayout(ctx) {
4118
4453
  for (const dir of ctx.config.localPrimitiveDirs ?? DEFAULT_LOCAL_PRIMITIVE_DIRS) {
4119
- if (existsSync(path30.join(ctx.root, dir))) {
4454
+ if (existsSync(path62.join(ctx.root, dir))) {
4120
4455
  ctx.report({
4121
4456
  rule: "local-primitives",
4122
4457
  file: dir,
@@ -4126,7 +4461,7 @@ function checkProjectLayout(ctx) {
4126
4461
  }
4127
4462
  }
4128
4463
  for (const file of STARTER_LEFTOVERS) {
4129
- if (existsSync(path30.join(ctx.root, file))) {
4464
+ if (existsSync(path62.join(ctx.root, file))) {
4130
4465
  ctx.report({
4131
4466
  rule: "starter-leftover",
4132
4467
  level: "warn",
@@ -4214,7 +4549,7 @@ function checkTokens(ctx) {
4214
4549
  }
4215
4550
  for (const pattern of ctx.config.tokenFiles ?? []) {
4216
4551
  if (/[*?]/.test(pattern)) continue;
4217
- const abs = path30.join(ctx.root, pattern);
4552
+ const abs = path62.join(ctx.root, pattern);
4218
4553
  if (!ctx.files.some((f) => f.absolutePath === abs) && existsSync(abs)) {
4219
4554
  for (const t of declaredTokens(readFileSync(abs, "utf8"))) defined.add(t);
4220
4555
  }
@@ -4235,14 +4570,32 @@ function checkShadowedExports(ctx) {
4235
4570
  const re = /\bexport\s+(?:default\s+)?(?:declare\s+)?(?:async\s+)?(?:function\*?|const|let|var|class)\s+([A-Z][\w$]*)/g;
4236
4571
  for (const file of ctx.files) {
4237
4572
  if (!SCRIPT_EXTS.has(file.ext) || insideOverlayOf(overlays, file, ctx.genesis.uiPackage)) continue;
4573
+ const wrapped = wrappedGenesisNames(file.code, ctx.genesis.uiPackage, { jsx: file.ext !== ".ts" && file.ext !== ".mts" });
4238
4574
  file.code.split("\n").forEach((text, i) => {
4239
4575
  for (const m of text.matchAll(re)) {
4240
4576
  if (!ctx.genesis.values.has(m[1])) continue;
4577
+ if (wrapped.has(m[1])) continue;
4241
4578
  ctx.report({ rule: "shadowed-export", file: file.path, line: i + 1, subject: m[1], message: `shadows the Genesis export '${m[1]}'; reuse or extend ${m[1]} from ${ctx.genesis.uiPackage} (or rename yours if it's a different thing)` });
4242
4579
  }
4243
4580
  });
4244
4581
  }
4245
4582
  }
4583
+ function wrappedGenesisNames(code, uiPackage, options = {}) {
4584
+ const out = /* @__PURE__ */ new Set();
4585
+ const pkg = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
4586
+ const re = new RegExp(`\\bimport\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${pkg}(?:/[^"']*)?["']`, "g");
4587
+ for (const m of code.matchAll(re)) {
4588
+ if (/^import\s+type\b/.test(m[0])) continue;
4589
+ for (const part of m[1].split(",")) {
4590
+ const spec = part.trim();
4591
+ if (!spec || spec.startsWith("type ")) continue;
4592
+ const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
4593
+ if (!imported || !local || local === imported) continue;
4594
+ if (usesAsCode(code, local, options)) out.add(imported);
4595
+ }
4596
+ }
4597
+ return out;
4598
+ }
4246
4599
  function unusedComponents(ctx) {
4247
4600
  const used = /* @__PURE__ */ new Set();
4248
4601
  const pkg = ctx.genesis.uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
@@ -4263,7 +4616,9 @@ var init_rules = __esm({
4263
4616
  init_color_literals();
4264
4617
  init_glob();
4265
4618
  init_genesis();
4619
+ init_js_scan();
4266
4620
  init_overlays();
4621
+ init_js_scan();
4267
4622
  BUILTIN_RULES = [
4268
4623
  "local-primitives",
4269
4624
  // figma (figma/routes.ts; runs when genesis.config.json has a figma block)
@@ -4351,7 +4706,10 @@ var init_rules = __esm({
4351
4706
  // custom views and app parts (custom-views.ts)
4352
4707
  "app-part-colors",
4353
4708
  "app-part-name",
4354
- "custom-view-states"
4709
+ "custom-view-states",
4710
+ // the app's client layer (client-layer.ts)
4711
+ "client/layer",
4712
+ "client/one-view-per-resource"
4355
4713
  ];
4356
4714
  DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
4357
4715
  STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
@@ -4436,10 +4794,10 @@ var init_expo = __esm({
4436
4794
  }
4437
4795
  });
4438
4796
  function resolveLocal(root, fromFile, spec) {
4439
- const bases = spec.startsWith(".") ? [path30.resolve(path30.dirname(fromFile), spec)] : [path30.join(root, spec.slice(2)), path30.join(root, "src", spec.slice(2))];
4797
+ const bases = spec.startsWith(".") ? [path62.resolve(path62.dirname(fromFile), spec)] : [path62.join(root, spec.slice(2)), path62.join(root, "src", spec.slice(2))];
4440
4798
  for (const base of bases) {
4441
- const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path30.join(base, `index${e}`))].find(
4442
- (p) => SCRIPT_EXTS2.has(path30.extname(p)) && existsSync(p)
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)
4443
4801
  );
4444
4802
  if (hit) return hit;
4445
4803
  }
@@ -4589,13 +4947,13 @@ function checkNativePack(ctx) {
4589
4947
  }
4590
4948
  function checkEasPlaceholders(ctx) {
4591
4949
  const files = [];
4592
- if (existsSync(path30.join(ctx.root, "eas.json"))) files.push("eas.json");
4593
- const workflows = path30.join(ctx.root, ".eas", "workflows");
4950
+ if (existsSync(path62.join(ctx.root, "eas.json"))) files.push("eas.json");
4951
+ const workflows = path62.join(ctx.root, ".eas", "workflows");
4594
4952
  if (existsSync(workflows)) {
4595
4953
  for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
4596
4954
  }
4597
4955
  for (const file of files) {
4598
- for (const hit of findPlaceholders(file, readFileSync(path30.join(ctx.root, file), "utf8"))) {
4956
+ for (const hit of findPlaceholders(file, readFileSync(path62.join(ctx.root, file), "utf8"))) {
4599
4957
  const key2 = placeholderKey(hit.text, hit.placeholder);
4600
4958
  const what = EAS_PLACEHOLDERS[hit.placeholder];
4601
4959
  ctx.report({
@@ -4673,7 +5031,7 @@ function checkCustomHeaders(ctx, pkg) {
4673
5031
  if (!JSX_EXTS3.has(file.ext)) continue;
4674
5032
  const code = file.code;
4675
5033
  const hidden = HIDES_HEADER.exec(code);
4676
- if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path30.posix.dirname(file.path), file.path);
5034
+ if (hidden && /(?:^|\/)_layout\.[jt]sx$/.test(file.path)) hidingLayouts.set(path62.posix.dirname(file.path), file.path);
4677
5035
  const own = hidden ? ownHeader(code, pkg) : null;
4678
5036
  if (hidden && own) {
4679
5037
  reported.add(file.path);
@@ -4701,7 +5059,7 @@ function checkCustomHeaders(ctx, pkg) {
4701
5059
  }
4702
5060
  for (const file of ctx.files) {
4703
5061
  if (!JSX_EXTS3.has(file.ext) || reported.has(file.path) || !file.path.startsWith(`${rootDir}/`) || NON_SCREEN_ROUTE.test(file.path)) continue;
4704
- const layout = hidingLayouts.get(path30.posix.dirname(file.path));
5062
+ const layout = hidingLayouts.get(path62.posix.dirname(file.path));
4705
5063
  const own = layout ? ownHeader(file.code, pkg) : null;
4706
5064
  if (!layout || !own) continue;
4707
5065
  ctx.report({
@@ -4722,13 +5080,13 @@ function isLoadingOnlyRoute(code) {
4722
5080
  }
4723
5081
  function routerRoot(ctx) {
4724
5082
  if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\/+$/, "");
4725
- return existsSync(path30.join(ctx.root, "src", "app")) ? "src/app" : "app";
5083
+ return existsSync(path62.join(ctx.root, "src", "app")) ? "src/app" : "app";
4726
5084
  }
4727
5085
  function checkScreenLayouts(ctx, pkg) {
4728
5086
  const layouts = nativeLayouts(pkg);
4729
5087
  if (layouts.length === 0) return;
4730
5088
  const rootDir = routerRoot(ctx);
4731
- if (!existsSync(path30.join(ctx.root, rootDir))) {
5089
+ if (!existsSync(path62.join(ctx.root, rootDir))) {
4732
5090
  ctx.report({ rule: "native-screen-layout", level: "warn", file: rootDir, message: `no Expo Router root at ${rootDir}; set doctor.native.routerRoot` });
4733
5091
  return;
4734
5092
  }
@@ -4765,7 +5123,7 @@ function checkScreenLayouts(ctx, pkg) {
4765
5123
  function readExpoConfigs(root) {
4766
5124
  const out = [];
4767
5125
  for (const name of EXPO_CONFIGS) {
4768
- const abs = path30.join(root, name);
5126
+ const abs = path62.join(root, name);
4769
5127
  if (!existsSync(abs)) continue;
4770
5128
  const text = readFileSync(abs, "utf8");
4771
5129
  let json = null;
@@ -4799,13 +5157,13 @@ function pluginOptions(json, module) {
4799
5157
  return null;
4800
5158
  }
4801
5159
  function dependencies(root) {
4802
- const file = path30.join(root, "package.json");
5160
+ const file = path62.join(root, "package.json");
4803
5161
  if (!existsSync(file)) return /* @__PURE__ */ new Set();
4804
5162
  const pkg = JSON.parse(readFileSync(file, "utf8"));
4805
5163
  return /* @__PURE__ */ new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);
4806
5164
  }
4807
5165
  function runtimeDependencies(root) {
4808
- const file = path30.join(root, "package.json");
5166
+ const file = path62.join(root, "package.json");
4809
5167
  if (!existsSync(file)) return {};
4810
5168
  return JSON.parse(readFileSync(file, "utf8")).dependencies ?? {};
4811
5169
  }
@@ -5094,14 +5452,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
5094
5452
  seen.add(file);
5095
5453
  const json = readJsonc(file);
5096
5454
  if (!json) return {};
5097
- const dir = path30.dirname(file);
5455
+ const dir = path62.dirname(file);
5098
5456
  let merged = {};
5099
5457
  const parents = typeof json.extends === "string" ? [json.extends] : Array.isArray(json.extends) ? json.extends : [];
5100
5458
  for (const ext of parents) {
5101
5459
  if (typeof ext !== "string") continue;
5102
5460
  let target = null;
5103
- if (ext.startsWith(".") || path30.isAbsolute(ext)) {
5104
- const abs = path30.resolve(dir, ext);
5461
+ if (ext.startsWith(".") || path62.isAbsolute(ext)) {
5462
+ const abs = path62.resolve(dir, ext);
5105
5463
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
5106
5464
  } else {
5107
5465
  const parts = ext.split("/");
@@ -5109,14 +5467,14 @@ function readTsconfig(root, file, seen = /* @__PURE__ */ new Set()) {
5109
5467
  const pkgDir = findPackageDir(root, parts.slice(0, nameLength).join("/"));
5110
5468
  if (pkgDir) {
5111
5469
  const sub = parts.slice(nameLength).join("/");
5112
- const abs = path30.join(pkgDir, sub || "tsconfig.json");
5470
+ const abs = path62.join(pkgDir, sub || "tsconfig.json");
5113
5471
  target = existsSync(abs) && statSync(abs).isFile() ? abs : existsSync(`${abs}.json`) ? `${abs}.json` : null;
5114
5472
  }
5115
5473
  }
5116
5474
  if (target) merged = { ...merged, ...readTsconfig(root, target, seen) };
5117
5475
  }
5118
5476
  const opts = json.compilerOptions ?? {};
5119
- if (typeof opts.baseUrl === "string") merged.baseUrl = path30.resolve(dir, opts.baseUrl);
5477
+ if (typeof opts.baseUrl === "string") merged.baseUrl = path62.resolve(dir, opts.baseUrl);
5120
5478
  if (opts.paths && typeof opts.paths === "object") {
5121
5479
  merged.paths = opts.paths;
5122
5480
  merged.pathsDir = dir;
@@ -5127,7 +5485,7 @@ function aliases(root) {
5127
5485
  const table = [];
5128
5486
  let baseUrl = null;
5129
5487
  for (const name of ["tsconfig.json", "tsconfig.app.json", "jsconfig.json"]) {
5130
- const file = path30.join(root, name);
5488
+ const file = path62.join(root, name);
5131
5489
  if (!existsSync(file)) continue;
5132
5490
  const config = readTsconfig(root, file);
5133
5491
  baseUrl ??= config.baseUrl ?? null;
@@ -5135,22 +5493,22 @@ function aliases(root) {
5135
5493
  for (const [pattern, targets] of Object.entries(config.paths ?? {})) {
5136
5494
  if (!Array.isArray(targets)) continue;
5137
5495
  const exact = !pattern.endsWith("*");
5138
- table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path30.join(base, String(t).replace(/\*$/, ""))) });
5496
+ table.push({ prefix: pattern.replace(/\*$/, ""), exact, targets: targets.map((t) => path62.join(base, String(t).replace(/\*$/, ""))) });
5139
5497
  }
5140
5498
  }
5141
- const pkg = readJsonc(path30.join(root, "package.json"));
5499
+ const pkg = readJsonc(path62.join(root, "package.json"));
5142
5500
  for (const [pattern, target] of Object.entries(pkg?.imports ?? {})) {
5143
5501
  if (typeof target !== "string") continue;
5144
- table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path30.join(root, target.replace(/\*.*$/, ""))] });
5502
+ table.push({ prefix: pattern.replace(/\*.*$/, ""), exact: !pattern.includes("*"), targets: [path62.join(root, target.replace(/\*.*$/, ""))] });
5145
5503
  }
5146
- for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path30.join(root, "src") + path30.sep, root + path30.sep] });
5504
+ for (const prefix of ["@/", "~/", "#/"]) table.push({ prefix, exact: false, targets: [path62.join(root, "src") + path62.sep, root + path62.sep] });
5147
5505
  return { table, baseUrl };
5148
5506
  }
5149
5507
  function resolveFile(base) {
5150
- const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path30.join(base, `index${e}`))];
5508
+ const tries = [base, ...RESOLVE_EXTS2.map((e) => base + e), ...RESOLVE_EXTS2.map((e) => path62.join(base, `index${e}`))];
5151
5509
  if (/\.[mc]?js$/.test(base)) tries.push(...[".ts", ".tsx"].map((e) => base.replace(/\.[mc]?js$/, e)));
5152
5510
  for (const p of tries) {
5153
- if (SCRIPT_EXTS2.has(path30.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
5511
+ if (SCRIPT_EXTS2.has(path62.extname(p)) && existsSync(p) && statSync(p).isFile()) return p;
5154
5512
  }
5155
5513
  return null;
5156
5514
  }
@@ -5163,7 +5521,7 @@ function createTrail(ctx) {
5163
5521
  const { table, baseUrl } = aliases(ctx.root);
5164
5522
  let declared = null;
5165
5523
  try {
5166
- const pkg = JSON.parse(readFileSync(path30.join(ctx.root, "package.json"), "utf8"));
5524
+ const pkg = JSON.parse(readFileSync(path62.join(ctx.root, "package.json"), "utf8"));
5167
5525
  declared = new Set(["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"].flatMap((k) => Object.keys(pkg[k] ?? {})));
5168
5526
  } catch {
5169
5527
  declared = null;
@@ -5194,17 +5552,17 @@ function createTrail(ctx) {
5194
5552
  if (/^(?:node:|https?:|data:|virtual:)/.test(spec) || /\.(?:css|scss|sass|less|svg|png|jpe?g|gif|webp|json|md|mdx)(?:\?.*)?$/.test(spec)) continue;
5195
5553
  let resolved = null;
5196
5554
  if (spec.startsWith(".")) {
5197
- resolved = resolveFile(path30.resolve(path30.dirname(file.absolutePath), spec));
5555
+ resolved = resolveFile(path62.resolve(path62.dirname(file.absolutePath), spec));
5198
5556
  if (!resolved) lost = true;
5199
5557
  } else {
5200
5558
  const alias = table.find((a) => a.exact ? spec === a.prefix : spec.startsWith(a.prefix));
5201
5559
  if (alias) {
5202
5560
  for (const t of alias.targets) {
5203
- resolved = resolveFile(alias.exact ? t : path30.join(t, spec.slice(alias.prefix.length)));
5561
+ resolved = resolveFile(alias.exact ? t : path62.join(t, spec.slice(alias.prefix.length)));
5204
5562
  if (resolved) break;
5205
5563
  }
5206
5564
  }
5207
- if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path30.join(baseUrl, spec));
5565
+ if (!resolved && baseUrl && !spec.startsWith("#")) resolved = resolveFile(path62.join(baseUrl, spec));
5208
5566
  if (!resolved) {
5209
5567
  const pkg = spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
5210
5568
  if (spec.startsWith("#") || declared && !declared.has(pkg) && !findPackageDir(ctx.root, pkg)) lost = true;
@@ -5290,7 +5648,7 @@ var init_trail = __esm({
5290
5648
  });
5291
5649
  function routesDir(ctx) {
5292
5650
  if (ctx.config.routesDir) return ctx.config.routesDir;
5293
- return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path30.join(ctx.root, d))) ?? null;
5651
+ return ROUTES_DIR_CANDIDATES.find((d) => existsSync(path62.join(ctx.root, d))) ?? null;
5294
5652
  }
5295
5653
  function flavorOf(dir, rels) {
5296
5654
  const stems = rels.map((r) => r.split("/").pop());
@@ -5431,7 +5789,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
5431
5789
  });
5432
5790
  if (typeof raw === "string") {
5433
5791
  if (!packageDir2) fail(`points at ${raw}, but the package folder is unknown`);
5434
- const file = path30.resolve(packageDir2, raw);
5792
+ const file = path62.resolve(packageDir2, raw);
5435
5793
  if (!inside(packageDir2, file)) fail(`points outside the package (${raw})`);
5436
5794
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
5437
5795
  let parsed;
@@ -5480,7 +5838,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
5480
5838
  if (typeof c.plugin === "string") {
5481
5839
  if (!packageDir2) plugin = c.plugin;
5482
5840
  else {
5483
- plugin = path30.resolve(packageDir2, c.plugin);
5841
+ plugin = path62.resolve(packageDir2, c.plugin);
5484
5842
  if (!inside(packageDir2, plugin)) fail(`plugin points outside the package (${c.plugin})`);
5485
5843
  }
5486
5844
  }
@@ -5533,7 +5891,7 @@ function checkPattern(v, where2, fail) {
5533
5891
  }
5534
5892
  }
5535
5893
  function readDeclaringPackage(dir, local) {
5536
- const file = path30.join(dir, "package.json");
5894
+ const file = path62.join(dir, "package.json");
5537
5895
  let stamp;
5538
5896
  let real2;
5539
5897
  try {
@@ -5556,7 +5914,7 @@ ${local}`;
5556
5914
  const pkg = {
5557
5915
  name: json.name,
5558
5916
  version: typeof json.version === "string" ? json.version : "0.0.0",
5559
- dir: path30.resolve(dir),
5917
+ dir: path62.resolve(dir),
5560
5918
  namespace: ruleNamespace(json.name),
5561
5919
  local,
5562
5920
  private: json.private === true,
@@ -5570,7 +5928,7 @@ ${local}`;
5570
5928
  if (raw !== void 0) {
5571
5929
  const ignored = [];
5572
5930
  try {
5573
- pkg.declaration = validateDeclaration(raw, json.name, path30.resolve(dir), ignored);
5931
+ pkg.declaration = validateDeclaration(raw, json.name, path62.resolve(dir), ignored);
5574
5932
  if (ignored.length) pkg.ignored = ignored;
5575
5933
  } catch (err) {
5576
5934
  pkg.error = err.message;
@@ -5589,14 +5947,14 @@ function discoverPackages(root) {
5589
5947
  for (const dir of installed) {
5590
5948
  let scope;
5591
5949
  try {
5592
- scope = path30.dirname(realpathSync(dir));
5950
+ scope = path62.dirname(realpathSync(dir));
5593
5951
  } catch {
5594
5952
  continue;
5595
5953
  }
5596
- if (path30.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
5954
+ if (path62.basename(scope) !== "@marktiderman" || !existsSync(scope)) continue;
5597
5955
  for (const entry of readdirSync(scope)) {
5598
5956
  if (byName.has(`@marktiderman/${entry}`) || !GENESIS.test(`@marktiderman/${entry}`)) continue;
5599
- const pkg = readDeclaringPackage(path30.join(scope, entry), false);
5957
+ const pkg = readDeclaringPackage(path62.join(scope, entry), false);
5600
5958
  if (pkg) byName.set(pkg.name, pkg);
5601
5959
  }
5602
5960
  }
@@ -5837,10 +6195,10 @@ var init_package_rules = __esm({
5837
6195
  });
5838
6196
  function sourceFiles(dir, rel = "") {
5839
6197
  const out = [];
5840
- for (const entry of readdirSync(path30.join(dir, rel)).sort()) {
6198
+ for (const entry of readdirSync(path62.join(dir, rel)).sort()) {
5841
6199
  if (entry.startsWith(".") || SKIP_DIRS2.has(entry)) continue;
5842
6200
  const child = rel ? `${rel}/${entry}` : entry;
5843
- const stat = lstatSync(path30.join(dir, child));
6201
+ const stat = lstatSync(path62.join(dir, child));
5844
6202
  if (stat.isSymbolicLink()) continue;
5845
6203
  if (stat.isDirectory()) out.push(...sourceFiles(dir, child));
5846
6204
  else if (SOURCE.test(entry) && !entry.endsWith(".d.ts")) out.push(child);
@@ -5863,13 +6221,13 @@ function matchPattern(pattern, spec) {
5863
6221
  return spec.startsWith(head) && spec.endsWith(tail) && spec.length >= head.length + tail.length ? spec.slice(head.length, spec.length - tail.length) : null;
5864
6222
  }
5865
6223
  function tsconfigPaths(dir) {
5866
- const file = path30.join(dir, "tsconfig.json");
6224
+ const file = path62.join(dir, "tsconfig.json");
5867
6225
  if (!existsSync(file)) return [];
5868
6226
  try {
5869
6227
  const text = readFileSync(file, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[\s{,[])\/\/[^\n]*/g, "$1").replace(/,(\s*[}\]])/g, "$1");
5870
6228
  const options = JSON.parse(text).compilerOptions ?? {};
5871
- const base = path30.resolve(dir, options.baseUrl ?? ".");
5872
- return Object.entries(options.paths ?? {}).map(([pattern, targets]) => ({ pattern, targets: targets.map((t) => path30.resolve(base, t)) }));
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)) }));
5873
6231
  } catch {
5874
6232
  return [];
5875
6233
  }
@@ -5883,8 +6241,8 @@ function checkImports2(ctx, pkg, json) {
5883
6241
  const hit = matchPattern(pattern, spec);
5884
6242
  if (hit === null) continue;
5885
6243
  return targets.some((t) => {
5886
- const rel = path30.relative(pkg.dir, t.replace("*", hit));
5887
- return !rel.startsWith("..") && !path30.isAbsolute(rel);
6244
+ const rel = path62.relative(pkg.dir, t.replace("*", hit));
6245
+ return !rel.startsWith("..") && !path62.isAbsolute(rel);
5888
6246
  });
5889
6247
  }
5890
6248
  return null;
@@ -5897,7 +6255,7 @@ function checkImports2(ctx, pkg, json) {
5897
6255
  ...Object.keys(json.optionalDependencies ?? {})
5898
6256
  ]);
5899
6257
  for (const file of sourceFiles(pkg.dir)) {
5900
- const code = stripForImports(readFileSync(path30.join(pkg.dir, file), "utf8"));
6258
+ const code = stripForImports(readFileSync(path62.join(pkg.dir, file), "utf8"));
5901
6259
  if (code === null) continue;
5902
6260
  const at = `${pkg.rel}/${file}`;
5903
6261
  const typeOnly = [...code.matchAll(TYPE_ONLY)].map((m) => [m.index, m.index + m[0].length]);
@@ -5922,9 +6280,9 @@ function checkImports2(ctx, pkg, json) {
5922
6280
  continue;
5923
6281
  }
5924
6282
  if (spec.startsWith(".")) {
5925
- const target = path30.resolve(pkg.dir, path30.dirname(file), spec);
5926
- const rel = path30.relative(pkg.dir, target);
5927
- if (rel.startsWith("..") || path30.isAbsolute(rel)) {
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)) {
5928
6286
  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` });
5929
6287
  }
5930
6288
  continue;
@@ -5960,12 +6318,12 @@ function checkMigrations(ctx, pkg, json, locals) {
5960
6318
  const from = own ? "" : ` (in ${m.package})`;
5961
6319
  if (typeof m.file === "string" && typeof m.test !== "string") {
5962
6320
  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` });
5963
- } else if (typeof m.test === "string" && !existsSync(path30.join(home, m.test))) {
6321
+ } else if (typeof m.test === "string" && !existsSync(path62.join(home, m.test))) {
5964
6322
  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` });
5965
6323
  }
5966
6324
  }
5967
6325
  }
5968
- const dir = path30.join(pkg.dir, "migrations");
6326
+ const dir = path62.join(pkg.dir, "migrations");
5969
6327
  if (!existsSync(dir)) return;
5970
6328
  const seen = /* @__PURE__ */ new Map();
5971
6329
  for (const name of readdirSync(dir).sort()) {
@@ -5974,7 +6332,7 @@ function checkMigrations(ctx, pkg, json, locals) {
5974
6332
  const other = seen.get(m[1]);
5975
6333
  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` });
5976
6334
  else seen.set(m[1], name);
5977
- if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path30.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
6335
+ if (!declaredFiles.has(`migrations/${name}`) && !existsSync(path62.join(dir, "tests", name.replace(/\.sql$/, ".test.sql")))) {
5978
6336
  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")})` });
5979
6337
  }
5980
6338
  }
@@ -5988,7 +6346,7 @@ function checkExports(ctx, pkg, json) {
5988
6346
  walk4(json.exports);
5989
6347
  for (const t of targets) {
5990
6348
  if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
5991
- if (!existsSync(path30.join(pkg.dir, t))) {
6349
+ if (!existsSync(path62.join(pkg.dir, t))) {
5992
6350
  ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
5993
6351
  }
5994
6352
  }
@@ -6006,11 +6364,11 @@ function checkBlocks(ctx, pkg, json) {
6006
6364
  function checkTaggedTests(ctx, pkg) {
6007
6365
  const tests = sourceFiles(pkg.dir).filter((f) => /\.(test|spec)\.[cm]?[jt]sx?$/.test(f));
6008
6366
  if (!tests.length) return;
6009
- const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path30.join(pkg.dir, f), "utf8")));
6367
+ const tagged = tests.some((f) => /@feat:[a-z]/.test(readFileSync(path62.join(pkg.dir, f), "utf8")));
6010
6368
  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>` });
6011
6369
  }
6012
6370
  function checkRegistered(ctx, pkg) {
6013
- const file = path30.join(ctx.root, "features.json");
6371
+ const file = path62.join(ctx.root, "features.json");
6014
6372
  if (!existsSync(file)) return;
6015
6373
  let doc;
6016
6374
  try {
@@ -6020,7 +6378,7 @@ function checkRegistered(ctx, pkg) {
6020
6378
  }
6021
6379
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
6022
6380
  const forms = /* @__PURE__ */ new Set([pkg.rel]);
6023
- if (top) forms.add(path30.relative(top, realpathSync(pkg.dir)).split(path30.sep).join("/"));
6381
+ if (top) forms.add(path62.relative(top, realpathSync(pkg.dir)).split(path62.sep).join("/"));
6024
6382
  const covered = (doc.features ?? []).some(
6025
6383
  (f) => (f.links?.code ?? []).some((c) => {
6026
6384
  const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
@@ -6050,8 +6408,8 @@ function mergeBaseOf(root, base) {
6050
6408
  function checkChanges(ctx, pkg, json, base, mergeBase) {
6051
6409
  const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
6052
6410
  if (!top) return;
6053
- const appRelative = (fromTop) => path30.relative(realpathSync(ctx.root), path30.join(top, fromTop)).split(path30.sep).join("/");
6054
- const inRepo = path30.relative(top, realpathSync(pkg.dir)).split(path30.sep).join("/");
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("/");
6055
6413
  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");
6056
6414
  const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
6057
6415
  const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
@@ -6074,11 +6432,11 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
6074
6432
  const now = typeof json.version === "string" ? parseVersion(json.version) : null;
6075
6433
  const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
6076
6434
  const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
6077
- 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) => path30.join(top, f)) : [];
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)) : [];
6078
6436
  const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
6079
6437
  const named = naming.length > 0;
6080
6438
  if (named && !naming.some((p) => /^Features:\s*\S/m.test(readFileSync(p, "utf8")))) {
6081
- ctx.report({ rule: "package-unversioned-change", level: "warn", file: path30.relative(realpathSync(ctx.root), naming[0]), message: `the changeset for ${pkg.name} has no "Features:" line; name the features it changes` });
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` });
6082
6440
  }
6083
6441
  let jsonBefore = null;
6084
6442
  try {
@@ -6088,7 +6446,7 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
6088
6446
  }
6089
6447
  const raw = json;
6090
6448
  if (jsonBefore && (JSON.stringify(jsonBefore.genesis) !== JSON.stringify(raw.genesis) || JSON.stringify(jsonBefore.exports) !== JSON.stringify(raw.exports))) {
6091
- const appInRepo = path30.relative(top, realpathSync(ctx.root)).split(path30.sep).join("/");
6449
+ const appInRepo = path62.relative(top, realpathSync(ctx.root)).split(path62.sep).join("/");
6092
6450
  const candidates = [.../* @__PURE__ */ new Set(["features.ts", "src/features.ts", ...appInRepo ? [`${appInRepo}/features.ts`, `${appInRepo}/src/features.ts`] : []])];
6093
6451
  const registry = (git(top, ["diff", "--name-only", mergeBase, "--", ...candidates]) ?? "").trim();
6094
6452
  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` });
@@ -6139,7 +6497,7 @@ function checkPackagesPack(ctx) {
6139
6497
  ctx.report({ rule: "package-unversioned-change", level: base ? "warn" : "info", file: "genesis.config.json", message: `change gate skipped: ${merge.reason}` });
6140
6498
  }
6141
6499
  for (const pkg of packages) {
6142
- const json = JSON.parse(readFileSync(path30.join(pkg.dir, "package.json"), "utf8"));
6500
+ const json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
6143
6501
  checkImports2(ctx, pkg, json);
6144
6502
  checkExports(ctx, pkg, json);
6145
6503
  checkBlocks(ctx, pkg, json);
@@ -6338,9 +6696,9 @@ function checkSupabasePack(ctx) {
6338
6696
  if (databaseElsewhere(ctx.root)) return;
6339
6697
  const settings2 = ctx.config.supabase ?? {};
6340
6698
  const dir = settings2.migrations ?? DEFAULT_MIGRATIONS;
6341
- const abs = path30.join(ctx.root, dir);
6699
+ const abs = path62.join(ctx.root, dir);
6342
6700
  if (!existsSync(abs)) throw new DoctorConfigError(`the supabase pack reads ${dir}, which doesn't exist; set doctor.supabase.migrations`);
6343
- const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path30.join(abs, n), "utf8")) }));
6701
+ const migrations = readdirSync(abs).filter((n) => n.endsWith(".sql")).sort().map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path62.join(abs, n), "utf8")) }));
6344
6702
  const exposed = new Set((settings2.exposedSchemas ?? DEFAULT_EXPOSED).map((s) => s.toLowerCase()));
6345
6703
  const base = settings2.base ?? DEFAULT_BASE;
6346
6704
  const view = gitView(ctx.root, dir, base);
@@ -6357,7 +6715,7 @@ function checkSupabasePack(ctx) {
6357
6715
  }
6358
6716
  }
6359
6717
  const since = settings2.since;
6360
- const afterSince = (file) => since === void 0 || path30.posix.basename(file) >= since;
6718
+ const afterSince = (file) => since === void 0 || path62.posix.basename(file) >= since;
6361
6719
  if ("reason" in view && since === void 0) {
6362
6720
  ctx.report({
6363
6721
  rule: "migration-grants",
@@ -6411,8 +6769,8 @@ function checkExposedSchemasCreatedLater(ctx, dir, migrations, configured, branc
6411
6769
  if (m && m[1] !== "authorization" && !created.has(m[1])) created.set(m[1], { file, line });
6412
6770
  }
6413
6771
  }
6414
- const tomlFile = path30.posix.join(path30.posix.dirname(dir), "config.toml");
6415
- const tomlText = existsSync(path30.join(ctx.root, tomlFile)) ? readFileSync(path30.join(ctx.root, tomlFile), "utf8") : null;
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;
6416
6774
  const api2 = tomlText === null ? null : apiSchemas(tomlText);
6417
6775
  const sources = [];
6418
6776
  if (api2?.enabled) for (const schema of api2.schemas) sources.push({ schema, file: tomlFile, line: api2.line, where: `${tomlFile} [api] schemas` });
@@ -6719,18 +7077,18 @@ var init_supabase = __esm({
6719
7077
  }
6720
7078
  });
6721
7079
  function nodeModulesOf(dir) {
6722
- const parent = path30.dirname(dir);
6723
- return path30.basename(parent).startsWith("@") ? path30.dirname(parent) : parent;
7080
+ const parent = path62.dirname(dir);
7081
+ return path62.basename(parent).startsWith("@") ? path62.dirname(parent) : parent;
6724
7082
  }
6725
7083
  function packagesIn(nodeModules) {
6726
7084
  if (!existsSync(nodeModules)) return [];
6727
7085
  const out = [];
6728
7086
  for (const entry of readdirSync(nodeModules)) {
6729
7087
  if (entry.startsWith(".")) continue;
6730
- const p = path30.join(nodeModules, entry);
7088
+ const p = path62.join(nodeModules, entry);
6731
7089
  if (entry.startsWith("@")) {
6732
7090
  try {
6733
- for (const sub of readdirSync(p)) out.push(path30.join(p, sub));
7091
+ for (const sub of readdirSync(p)) out.push(path62.join(p, sub));
6734
7092
  } catch {
6735
7093
  }
6736
7094
  } else {
@@ -6742,7 +7100,7 @@ function packagesIn(nodeModules) {
6742
7100
  function genesisInstalls(root) {
6743
7101
  const copies = /* @__PURE__ */ new Map();
6744
7102
  const realRoot = real(root);
6745
- const rel = (abs) => path30.relative(realRoot, abs).split(path30.sep).join("/") || ".";
7103
+ const rel = (abs) => path62.relative(realRoot, abs).split(path62.sep).join("/") || ".";
6746
7104
  const via = /* @__PURE__ */ new Map();
6747
7105
  const record = (real2, manifest, by, range, root2) => {
6748
7106
  let copy = copies.get(real2);
@@ -6787,7 +7145,7 @@ function genesisInstalls(root) {
6787
7145
  if (!dir) return null;
6788
7146
  if (!ownInstall || name in declared) return dir;
6789
7147
  const realDir = real(dir);
6790
- if (realDir.startsWith(realRoot + path30.sep)) return dir;
7148
+ if (realDir.startsWith(realRoot + path62.sep)) return dir;
6791
7149
  return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
6792
7150
  };
6793
7151
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
@@ -6795,7 +7153,7 @@ function genesisInstalls(root) {
6795
7153
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
6796
7154
  });
6797
7155
  const app = readManifest(root);
6798
- const ownInstall = LOCKFILES.some((f) => existsSync(path30.join(root, f)));
7156
+ const ownInstall = LOCKFILES.some((f) => existsSync(path62.join(root, f)));
6799
7157
  const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
6800
7158
  const declaredDev = Object.entries(app?.devDependencies ?? {});
6801
7159
  const runtimeDeps = {
@@ -6806,11 +7164,11 @@ function genesisInstalls(root) {
6806
7164
  };
6807
7165
  const devDeps = Object.fromEntries(declaredDev.filter(([n]) => NON_SHIPPING.test(n) && !(n in runtimeDeps)));
6808
7166
  walk4("runtime", rootsOf(runtimeDeps, "the app"));
6809
- const top = path30.join(root, "node_modules");
7167
+ const top = path62.join(root, "node_modules");
6810
7168
  walk4(
6811
7169
  "hoisted",
6812
7170
  packagesIn(top).filter((dir) => {
6813
- const name = path30.relative(top, dir).split(path30.sep).join("/");
7171
+ const name = path62.relative(top, dir).split(path62.sep).join("/");
6814
7172
  return !(name in runtimeDeps) && !(name in devDeps);
6815
7173
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
6816
7174
  );
@@ -6852,7 +7210,7 @@ function checkDuplicatePackages(ctx) {
6852
7210
  }
6853
7211
  }
6854
7212
  function checkPeerRanges(ctx) {
6855
- const rel = (abs) => path30.relative(ctx.root, abs).split(path30.sep).join("/");
7213
+ const rel = (abs) => path62.relative(ctx.root, abs).split(path62.sep).join("/");
6856
7214
  for (const copies of genesisInstalls(ctx.root).values()) {
6857
7215
  for (const copy of copies) {
6858
7216
  const dir = copy.absolutePath;
@@ -6885,7 +7243,7 @@ var init_installs = __esm({
6885
7243
  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)$/;
6886
7244
  readManifest = (dir) => {
6887
7245
  try {
6888
- return JSON.parse(readFileSync(path30.join(dir, "package.json"), "utf8"));
7246
+ return JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
6889
7247
  } catch {
6890
7248
  return null;
6891
7249
  }
@@ -7084,11 +7442,11 @@ function appScripts(root) {
7084
7442
  const out = [];
7085
7443
  const walk4 = (dir) => {
7086
7444
  for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
7087
- const abs = path30.join(dir, entry.name);
7445
+ const abs = path62.join(dir, entry.name);
7088
7446
  if (entry.isDirectory()) {
7089
7447
  if (!SKIP_DIRS3.has(entry.name)) walk4(abs);
7090
7448
  } else if (entry.isFile() && SCRIPT2.test(entry.name) && statSync(abs).size <= MAX_BYTES) {
7091
- out.push(path30.relative(root, abs).split(path30.sep).join("/"));
7449
+ out.push(path62.relative(root, abs).split(path62.sep).join("/"));
7092
7450
  }
7093
7451
  }
7094
7452
  };
@@ -7401,7 +7759,7 @@ var init_doctor_rule_codemods = __esm({
7401
7759
  run({ root, dryRun, log }) {
7402
7760
  const changed = [];
7403
7761
  for (const rel of appScripts(root).filter((f) => /\.[jt]sx$/.test(f))) {
7404
- const abs = path30.join(root, rel);
7762
+ const abs = path62.join(root, rel);
7405
7763
  const text = readFileSync(abs, "utf8");
7406
7764
  const next = rewriteOverlayHeights(text);
7407
7765
  if (next === text) continue;
@@ -7428,7 +7786,7 @@ var init_doctor_rule_codemods = __esm({
7428
7786
  const changed = [];
7429
7787
  for (const rel of appScripts(root)) {
7430
7788
  if (/(?:^|\/)__tests__\/|\.test\.[jt]sx?$/.test(rel)) continue;
7431
- const abs = path30.join(root, rel);
7789
+ const abs = path62.join(root, rel);
7432
7790
  const text = readFileSync(abs, "utf8");
7433
7791
  if (!text.includes("expo-haptics")) continue;
7434
7792
  const result = rewriteHaptics(text);
@@ -7644,11 +8002,11 @@ var init_scope_names = __esm({
7644
8002
  }
7645
8003
  });
7646
8004
  function findEslintConfig(root) {
7647
- return FLAT_CONFIG_FILES.find((name) => existsSync(path30.join(root, name))) ?? null;
8005
+ return FLAT_CONFIG_FILES.find((name) => existsSync(path62.join(root, name))) ?? null;
7648
8006
  }
7649
8007
  function readPackageJson(root) {
7650
8008
  try {
7651
- return JSON.parse(readFileSync(path30.join(root, "package.json"), "utf8"));
8009
+ return JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
7652
8010
  } catch {
7653
8011
  return null;
7654
8012
  }
@@ -7705,7 +8063,7 @@ function spreadLine(platform, local = "genesis") {
7705
8063
  }
7706
8064
  function addGenesisLint(text, platform, file = "eslint.config.js") {
7707
8065
  const code = maskCode(text);
7708
- const ext = path30.extname(file);
8066
+ const ext = path62.extname(file);
7709
8067
  const exportsCjs = [...code.matchAll(/(?:^|[\n;])\s*module\.exports\s*=\s*/g)];
7710
8068
  const exportsEsm = [...code.matchAll(/(?:^|[\n;])\s*export\s+default\s+/g)];
7711
8069
  const kind = ext === ".cjs" || ext === ".cts" ? "cjs" : ext === ".mjs" || ext === ".mts" ? "esm" : exportsCjs.length && !exportsEsm.length ? "cjs" : "esm";
@@ -7877,7 +8235,7 @@ var init_codemods = __esm({
7877
8235
  let readsId = false;
7878
8236
  let augmented = false;
7879
8237
  for (const rel of appScripts(root)) {
7880
- const abs = path30.join(root, rel);
8238
+ const abs = path62.join(root, rel);
7881
8239
  const text = readFileSync(abs, "utf8");
7882
8240
  if (augmentsResourceScope(text)) augmented = true;
7883
8241
  if (!IMPORTS_GENESIS.test(text)) continue;
@@ -7905,7 +8263,7 @@ var init_codemods = __esm({
7905
8263
  const changed = [];
7906
8264
  const pkg = readPackageJson(root);
7907
8265
  const platform = appPlatform(pkg);
7908
- const abs = path30.join(root, file);
8266
+ const abs = path62.join(root, file);
7909
8267
  const text = readFileSync(abs, "utf8");
7910
8268
  if (!usesGenesisLint(text)) {
7911
8269
  const result = addGenesisLint(text, platform, file);
@@ -7921,7 +8279,7 @@ ${manualLines(result.kind, platform).map((l) => ` ${l}`).join("\n")}`);
7921
8279
  }
7922
8280
  }
7923
8281
  if (platform === "native" && pkg && !hasTestingLibrary(pkg)) {
7924
- const pkgFile = path30.join(root, "package.json");
8282
+ const pkgFile = path62.join(root, "package.json");
7925
8283
  const raw = readFileSync(pkgFile, "utf8");
7926
8284
  const indent = /^[ \t]+(?=")/m.exec(raw)?.[0] ?? " ";
7927
8285
  const json = JSON.parse(raw);
@@ -7944,7 +8302,7 @@ ${manualLines(result.kind, platform).map((l) => ` ${l}`).join("\n")}`);
7944
8302
  run({ root, dryRun }) {
7945
8303
  const changed = [];
7946
8304
  for (const rel of appScripts(root)) {
7947
- const abs = path30.join(root, rel);
8305
+ const abs = path62.join(root, rel);
7948
8306
  const text = readFileSync(abs, "utf8");
7949
8307
  if (!text.includes("NativeComposerBar")) continue;
7950
8308
  const next = rewriteComposerBarEmpty(text);
@@ -8034,7 +8392,7 @@ function checkTreeViews(ctx) {
8034
8392
  function moduleFiles(ctx) {
8035
8393
  const scanned = new Set(ctx.files.map((f) => f.path));
8036
8394
  const ignored = globMatcher([...DEFAULT_IGNORE, ...ctx.config.ignore ?? []]);
8037
- const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path30.join(ctx.root, rel), "utf8"), true) }));
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) }));
8038
8396
  return [...ctx.files.filter((f) => SCRIPT_EXTS5.has(f.ext)), ...extra];
8039
8397
  }
8040
8398
  function checkStudioServerImports(ctx) {
@@ -8064,7 +8422,7 @@ function checkStudioServerImports(ctx) {
8064
8422
  }
8065
8423
  function checkRemovedScopeNames(ctx) {
8066
8424
  let augmentedMemo;
8067
- const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path30.join(ctx.root, rel), "utf8")));
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")));
8068
8426
  for (const file of ctx.files) {
8069
8427
  if (!SCRIPT_EXTS5.has(file.ext)) continue;
8070
8428
  for (const hit of findRemovedScopeNames(file.code)) {
@@ -8185,6 +8543,116 @@ var init_custom_views = __esm({
8185
8543
  VARIABLE = /var\(\s*(--[A-Za-z0-9_-]+)/g;
8186
8544
  }
8187
8545
  });
8546
+ function clientLayer(root, files) {
8547
+ let dir = DEFAULT_CLIENT_DIR;
8548
+ try {
8549
+ dir = readGenesisConfig(root)?.client?.dir ?? DEFAULT_CLIENT_DIR;
8550
+ } catch {
8551
+ }
8552
+ 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"));
8555
+ return { dir, present, recordWrapper };
8556
+ }
8557
+ function genesisImports(code, uiPackage) {
8558
+ const out = /* @__PURE__ */ new Map();
8559
+ const escaped = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
8560
+ const re = new RegExp(`import\\s*(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${escaped}(?:/data)?["']`, "g");
8561
+ for (const m of code.matchAll(re)) {
8562
+ if (/^\s*type\s/.test(m[0].slice(6))) continue;
8563
+ for (const part of m[1].split(",")) {
8564
+ const spec = part.trim().replace(/^type\s+/, "");
8565
+ if (!spec || part.trim().startsWith("type ")) continue;
8566
+ const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
8567
+ if (imported === "ResourceView" || imported === "RecordView") out.set(local ?? imported, imported);
8568
+ }
8569
+ }
8570
+ return out;
8571
+ }
8572
+ function checkClientLayer(ctx) {
8573
+ const layer = clientLayer(ctx.root, ctx.files);
8574
+ const inside3 = `${layer.dir}/`;
8575
+ if (layer.present) {
8576
+ for (const file of ctx.files) {
8577
+ if (!JSX_EXTS5.has(file.ext) || file.path.startsWith(inside3)) continue;
8578
+ const imported = genesisImports(file.code, ctx.genesis.uiPackage);
8579
+ for (const [local, name] of imported) {
8580
+ if (name === "RecordView" && !layer.recordWrapper) continue;
8581
+ const at = file.code.search(new RegExp(`<${local}\\b`));
8582
+ if (at < 0) continue;
8583
+ ctx.report({
8584
+ rule: "client/layer",
8585
+ level: "warn",
8586
+ file: file.path,
8587
+ line: lineAt(file.code, at),
8588
+ subject: name,
8589
+ message: `renders Genesis's <${name}> directly; the app has a client layer (${layer.dir}), so render its ${name === "ResourceView" ? "ResourceView from resource-view.tsx" : "RecordView from record-view.tsx"}, and its defaults reach this screen too (docs/adr/0020-client-layer.md)`
8590
+ });
8591
+ }
8592
+ }
8593
+ }
8594
+ if (!layer.present) return;
8595
+ const seen = /* @__PURE__ */ new Map();
8596
+ for (const file of ctx.files) {
8597
+ if (!SCRIPT_EXTS6.has(file.ext) || SHOWN_OR_TRIED.test(file.path)) continue;
8598
+ const imports = importedNames(file.path, file.code);
8599
+ for (const m of file.code.matchAll(/\bdefineView\s*(?:<[^>]*>)?\s*\(\s*([A-Za-z_$][\w$]*)((?:\s*(?:\.\s*[A-Za-z_$][\w$]*|\[\s*["'`][^"'`]+["'`]\s*\]))*)\s*[,)]/g)) {
8600
+ const base = m[1];
8601
+ const access2 = m[2].replace(/\s+/g, "").replace(/'|`/g, '"');
8602
+ const imported = imports.get(base);
8603
+ if (!imported && !declaredAtTop(file.code, base)) continue;
8604
+ if (boundAsParameter(file.code, base, { jsx: file.ext !== ".ts" && file.ext !== ".mts" })) continue;
8605
+ const identity = `${imported ?? `${file.path}#${base}`}${access2}`;
8606
+ const shown = `${base}${access2}`;
8607
+ const line = lineAt(file.code, m.index ?? 0);
8608
+ const first = seen.get(identity);
8609
+ if (!first) {
8610
+ seen.set(identity, { file: file.path, line });
8611
+ continue;
8612
+ }
8613
+ ctx.report({
8614
+ rule: "client/one-view-per-resource",
8615
+ level: "warn",
8616
+ file: file.path,
8617
+ line,
8618
+ subject: shown,
8619
+ message: `defines a second view over ${shown} (the first is in ${first.file}:${first.line}); keep one view per resource and narrow it on the screen (preset, filter, columns), so its rules can't drift (docs/adr/0020-client-layer.md)`
8620
+ });
8621
+ }
8622
+ }
8623
+ }
8624
+ function declaredAtTop(code, name) {
8625
+ const escaped = escapeRegExp(name);
8626
+ return new RegExp(`^(?:export\\s+)?(?:const|let|var)\\s+${escaped}\\b`, "m").test(code);
8627
+ }
8628
+ function importedNames(filePath, code) {
8629
+ 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;
8632
+ for (const m of code.matchAll(/import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
8633
+ for (const part of m[1].split(",")) {
8634
+ const spec = part.trim().replace(/^type\s+/, "");
8635
+ if (!spec) continue;
8636
+ const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
8637
+ out.set(local ?? imported, `${where2(m[2])}#${imported}`);
8638
+ }
8639
+ }
8640
+ for (const m of code.matchAll(/import\s+(?:\*\s+as\s+)?([A-Za-z_$][\w$]*)\s+from\s*["']([^"']+)["']/g)) out.set(m[1], `${where2(m[2])}#*`);
8641
+ return out;
8642
+ }
8643
+ var JSX_EXTS5, SCRIPT_EXTS6, DEFAULT_CLIENT_DIR, SHOWN_OR_TRIED;
8644
+ var init_client_layer = __esm({
8645
+ "src/doctor/client-layer.ts"() {
8646
+ init_config();
8647
+ init_scan();
8648
+ init_js_scan();
8649
+ init_regexp();
8650
+ JSX_EXTS5 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
8651
+ SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts"]);
8652
+ DEFAULT_CLIENT_DIR = "src/client";
8653
+ SHOWN_OR_TRIED = /(\.stories\.|\.test\.|\.spec\.|(^|\/)__tests__\/)/;
8654
+ }
8655
+ });
8188
8656
  function specifierParts(spec) {
8189
8657
  return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
8190
8658
  }
@@ -8227,16 +8695,16 @@ function genesisNamedImports(source) {
8227
8695
  }
8228
8696
  function declarationFiles(dir, out = []) {
8229
8697
  for (const name of readdirSync(dir)) {
8230
- const full = path30.join(dir, name);
8698
+ const full = path62.join(dir, name);
8231
8699
  if (statSync(full).isDirectory()) declarationFiles(full, out);
8232
8700
  else if (/\.d\.[cm]?ts$/.test(name)) out.push(full);
8233
8701
  }
8234
8702
  return out;
8235
8703
  }
8236
8704
  function readPackageTags(dir) {
8237
- const pkg = JSON.parse(readFileSync(path30.join(dir, "package.json"), "utf8"));
8705
+ const pkg = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
8238
8706
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
8239
- const dist = path30.join(dir, "dist");
8707
+ const dist = path62.join(dir, "dist");
8240
8708
  if (!existsSync(dist)) return tags;
8241
8709
  for (const file of declarationFiles(dist)) {
8242
8710
  const text = readFileSync(file, "utf8");
@@ -8254,7 +8722,7 @@ function entryFile(tags, pkg, specifier) {
8254
8722
  const subpath = `.${specifier.slice(pkg.length)}` || ".";
8255
8723
  const target = tags.exports[subpath === "." ? "." : subpath];
8256
8724
  const types = typeof target === "object" && target ? target.types : null;
8257
- return typeof types === "string" ? path30.join(tags.dir, types) : null;
8725
+ return typeof types === "string" ? path62.join(tags.dir, types) : null;
8258
8726
  }
8259
8727
  function tagFor(tags, entry, name) {
8260
8728
  if (entry && tags.declaredIn.get(name)?.includes(entry)) return tags.byFile.get(entry)?.get(name);
@@ -8272,7 +8740,7 @@ function checkStabilityImports(ctx) {
8272
8740
  return cache2.get(pkg);
8273
8741
  };
8274
8742
  for (const file of ctx.files) {
8275
- if (!SCRIPT_EXTS6.has(file.ext)) continue;
8743
+ if (!SCRIPT_EXTS7.has(file.ext)) continue;
8276
8744
  for (const { pkg, specifier, names, line } of genesisNamedImports(file.code)) {
8277
8745
  const tags = tagsOf(pkg);
8278
8746
  if (!tags) continue;
@@ -8288,12 +8756,12 @@ function checkStabilityImports(ctx) {
8288
8756
  }
8289
8757
  }
8290
8758
  }
8291
- var SCRIPT_EXTS6, DECLARATION, REEXPORT;
8759
+ var SCRIPT_EXTS7, DECLARATION, REEXPORT;
8292
8760
  var init_stability = __esm({
8293
8761
  "src/doctor/stability.ts"() {
8294
8762
  init_genesis();
8295
8763
  init_trail();
8296
- SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
8764
+ SCRIPT_EXTS7 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
8297
8765
  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;
8298
8766
  REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
8299
8767
  }
@@ -8339,7 +8807,7 @@ function showAt(dir, rev, file) {
8339
8807
  function configAtBase(root, base, explicitFile) {
8340
8808
  const mergeBase = mergeBaseOf2(root, base);
8341
8809
  if (!mergeBase) return null;
8342
- const candidates = explicitFile ? [{ dir: path30.dirname(explicitFile), file: path30.basename(explicitFile), explicit: true }] : [
8810
+ const candidates = explicitFile ? [{ dir: path62.dirname(explicitFile), file: path62.basename(explicitFile), explicit: true }] : [
8343
8811
  { dir: root, file: "genesis.config.json", explicit: false },
8344
8812
  { dir: root, file: "package.json", explicit: false }
8345
8813
  ];
@@ -8453,7 +8921,7 @@ function snapshotAtBase(root, base, files, changed, originOf = (f) => f) {
8453
8921
  seen.add(origin);
8454
8922
  const text = showAt(root, mergeBase, origin);
8455
8923
  if (text === null) return null;
8456
- if (text !== void 0) out.push(withText({ ...f, path: origin, absolutePath: path30.join(root, origin) }, text));
8924
+ if (text !== void 0) out.push(withText({ ...f, path: origin, absolutePath: path62.join(root, origin) }, text));
8457
8925
  }
8458
8926
  const cache2 = /* @__PURE__ */ new Map();
8459
8927
  return {
@@ -8611,7 +9079,7 @@ function pathTaken(file) {
8611
9079
  return true;
8612
9080
  } catch {
8613
9081
  try {
8614
- return readdirSync(path30.dirname(file)).some((n) => n.toLowerCase() === path30.basename(file).toLowerCase());
9082
+ return readdirSync(path62.dirname(file)).some((n) => n.toLowerCase() === path62.basename(file).toLowerCase());
8615
9083
  } catch {
8616
9084
  return false;
8617
9085
  }
@@ -8683,13 +9151,13 @@ function stableGuidePath(root, p) {
8683
9151
  };
8684
9152
  const want = real2(p.dir);
8685
9153
  for (let dir = root, level = 0; level <= GUIDE_SEARCH_LEVELS; level++) {
8686
- const found = path30.join(dir, "node_modules", p.name);
9154
+ const found = path62.join(dir, "node_modules", p.name);
8687
9155
  if (existsSync(found)) {
8688
- const file = path30.join(found, "SKILL.md");
9156
+ const file = path62.join(found, "SKILL.md");
8689
9157
  return want !== null && real2(found) === want && existsSync(file) ? file : null;
8690
9158
  }
8691
- if (existsSync(path30.join(dir, ".git")) || existsSync(path30.join(dir, "pnpm-workspace.yaml"))) return null;
8692
- const up = path30.dirname(dir);
9159
+ if (existsSync(path62.join(dir, ".git")) || existsSync(path62.join(dir, "pnpm-workspace.yaml"))) return null;
9160
+ const up = path62.dirname(dir);
8693
9161
  if (up === dir) return null;
8694
9162
  dir = up;
8695
9163
  }
@@ -8698,18 +9166,18 @@ function stableGuidePath(root, p) {
8698
9166
  function packageGuides(root, packages) {
8699
9167
  const guides = [];
8700
9168
  for (const p of packages) {
8701
- const stable = p.local ? path30.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
9169
+ const stable = p.local ? path62.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
8702
9170
  const text = stable === null ? null : read2(stable);
8703
9171
  if (stable === null || text === null) continue;
8704
9172
  const description = skillDescription(text);
8705
9173
  const at = description.indexOf("Load before");
8706
- guides.push({ package: p.name, path: path30.relative(root, stable).split(path30.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
9174
+ guides.push({ package: p.name, path: path62.relative(root, stable).split(path62.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
8707
9175
  }
8708
9176
  return guides.sort((a, b) => a.package.localeCompare(b.package));
8709
9177
  }
8710
9178
  function unlistedGuides(root, packages) {
8711
9179
  const listed = new Set(packageGuides(root, packages).map((g) => g.package));
8712
- return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path30.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
9180
+ return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path62.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
8713
9181
  }
8714
9182
  function guidesSection(guides) {
8715
9183
  if (!guides.length) return [];
@@ -8790,13 +9258,13 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
8790
9258
  const rows = primitivesCatalog(packages);
8791
9259
  const guides = packageGuides(root, packages);
8792
9260
  const changed = [];
8793
- const agents = path30.join(root, agentsFile);
9261
+ const agents = path62.join(root, agentsFile);
8794
9262
  const before = read2(agents);
8795
9263
  const after = mergeAgentsBlock(before, renderAgentsBlock(rows, guides));
8796
- const skill = path30.join(root, SKILL_PATH);
9264
+ const skill = path62.join(root, SKILL_PATH);
8797
9265
  const skillText = renderSkill(rows, guides);
8798
9266
  if (read2(skill)?.replace(/\r\n/g, "\n") !== skillText) {
8799
- mkdirSync(path30.dirname(skill), { recursive: true });
9267
+ mkdirSync(path62.dirname(skill), { recursive: true });
8800
9268
  writeFileSync(skill, skillText);
8801
9269
  changed.push(SKILL_PATH);
8802
9270
  }
@@ -8804,7 +9272,7 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
8804
9272
  writeFileSync(agents, after);
8805
9273
  changed.push(agentsFile);
8806
9274
  }
8807
- const claude = path30.join(root, "CLAUDE.md");
9275
+ const claude = path62.join(root, "CLAUDE.md");
8808
9276
  if (agentsFile === "AGENTS.md" && !pathTaken(claude)) {
8809
9277
  writeFileSync(claude, CLAUDE_IMPORT);
8810
9278
  changed.push("CLAUDE.md");
@@ -8812,7 +9280,7 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
8812
9280
  return changed;
8813
9281
  }
8814
9282
  function claudeState(root) {
8815
- const file = path30.join(root, "CLAUDE.md");
9283
+ const file = path62.join(root, "CLAUDE.md");
8816
9284
  let names = [];
8817
9285
  try {
8818
9286
  names = readdirSync(root);
@@ -8827,7 +9295,7 @@ function claudeState(root) {
8827
9295
  }
8828
9296
  if (/^@AGENTS\.md\b/m.test(text)) return "ok";
8829
9297
  try {
8830
- if (realpathSync(file) === realpathSync(path30.join(root, "AGENTS.md"))) return "ok";
9298
+ if (realpathSync(file) === realpathSync(path62.join(root, "AGENTS.md"))) return "ok";
8831
9299
  } catch {
8832
9300
  }
8833
9301
  return "no-import";
@@ -8835,8 +9303,8 @@ function claudeState(root) {
8835
9303
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
8836
9304
  const rows = primitivesCatalog(packages);
8837
9305
  const guides = packageGuides(root, packages);
8838
- const skill = read2(path30.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
8839
- const block = currentAgentsBlock(read2(path30.join(root, agentsFile)));
9306
+ const skill = read2(path62.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
9307
+ const block = currentAgentsBlock(read2(path62.join(root, agentsFile)));
8840
9308
  return {
8841
9309
  skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
8842
9310
  agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
@@ -8983,7 +9451,7 @@ function mergeAgentHooks(settings2) {
8983
9451
  return out;
8984
9452
  }
8985
9453
  function writeAgentHooks(root) {
8986
- const file = path30.join(root, SETTINGS_PATH);
9454
+ const file = path62.join(root, SETTINGS_PATH);
8987
9455
  const before = existsSync(file) ? readFileSync(file, "utf8") : null;
8988
9456
  let current = {};
8989
9457
  if (before !== null) {
@@ -8997,14 +9465,14 @@ function writeAgentHooks(root) {
8997
9465
  const after = `${JSON.stringify(mergeAgentHooks(current), null, 2)}
8998
9466
  `;
8999
9467
  if (before !== null && JSON.stringify(JSON.parse(before)) === JSON.stringify(JSON.parse(after))) return [];
9000
- mkdirSync(path30.dirname(file), { recursive: true });
9468
+ mkdirSync(path62.dirname(file), { recursive: true });
9001
9469
  writeFileSync(file, after);
9002
9470
  return [SETTINGS_PATH];
9003
9471
  }
9004
9472
  function agentHooksState(root) {
9005
9473
  let settings2;
9006
9474
  try {
9007
- settings2 = JSON.parse(readFileSync(path30.join(root, SETTINGS_PATH), "utf8"));
9475
+ settings2 = JSON.parse(readFileSync(path62.join(root, SETTINGS_PATH), "utf8"));
9008
9476
  } catch {
9009
9477
  return "none";
9010
9478
  }
@@ -9047,7 +9515,7 @@ function unprefixedTemplatePaths(root, rel, mine, template, folder) {
9047
9515
  const lines = new Set(mine.split("\n"));
9048
9516
  const lockfileElsewhere = (line) => {
9049
9517
  const name = PATH_ITEM.exec(line)?.[3];
9050
- return name !== void 0 && LOCKFILES2.has(name) && !existsSync(path30.join(root, name));
9518
+ return name !== void 0 && LOCKFILES2.has(name) && !existsSync(path62.join(root, name));
9051
9519
  };
9052
9520
  return template.split("\n").filter((line, i) => line !== rendered[i] && !/^\s*#/.test(line) && lines.has(line) && !lockfileElsewhere(line)).map((line) => line.trim());
9053
9521
  }
@@ -9120,9 +9588,9 @@ function ownedKeyProblem(key2, source, localNames = /* @__PURE__ */ new Set()) {
9120
9588
  return `${key2} doesn't match its source ${source}`;
9121
9589
  }
9122
9590
  function mergeThreeWay(mine, base, theirs) {
9123
- const dir = mkdtempSync(path30.join(tmpdir(), "genesis-merge-"));
9591
+ const dir = mkdtempSync(path62.join(tmpdir(), "genesis-merge-"));
9124
9592
  try {
9125
- const [m, b, t] = ["mine", "base", "theirs"].map((n) => path30.join(dir, n));
9593
+ const [m, b, t] = ["mine", "base", "theirs"].map((n) => path62.join(dir, n));
9126
9594
  writeFileSync(m, mine);
9127
9595
  writeFileSync(b, base);
9128
9596
  writeFileSync(t, theirs);
@@ -9386,7 +9854,7 @@ function removeBunLockEntries(text, remove) {
9386
9854
  return out + text.slice(at);
9387
9855
  }
9388
9856
  function readBunLock(dir) {
9389
- const file = path30.join(dir, BUN_LOCK);
9857
+ const file = path62.join(dir, BUN_LOCK);
9390
9858
  return existsSync(file) ? readFileSync(file, "utf8") : null;
9391
9859
  }
9392
9860
  var BUN_LOCK, GENESIS_TAIL, PLAIN_VERSION;
@@ -9403,7 +9871,7 @@ function checkBunLock(ctx) {
9403
9871
  if (found?.pm !== "bun") return;
9404
9872
  const text = readBunLock(found.dir);
9405
9873
  if (text === null) return;
9406
- const file = path30.relative(ctx.root, path30.join(found.dir, BUN_LOCK)).split(path30.sep).join("/");
9874
+ const file = path62.relative(ctx.root, path62.join(found.dir, BUN_LOCK)).split(path62.sep).join("/");
9407
9875
  let stale;
9408
9876
  try {
9409
9877
  stale = staleNestedEntries(text);
@@ -9422,7 +9890,7 @@ function checkBunLock(ctx) {
9422
9890
  }
9423
9891
  async function checkLockFiles(ctx) {
9424
9892
  checkBunLock(ctx);
9425
- if (!existsSync(path30.join(ctx.root, LOCK_FILE))) return;
9893
+ if (!existsSync(path62.join(ctx.root, LOCK_FILE))) return;
9426
9894
  let lock;
9427
9895
  try {
9428
9896
  lock = readLock(ctx.root);
@@ -9544,7 +10012,7 @@ function checkDatabaseHome(ctx) {
9544
10012
  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)`
9545
10013
  });
9546
10014
  }
9547
- if (existsSync(path30.join(ctx.root, "supabase"))) {
10015
+ if (existsSync(path62.join(ctx.root, "supabase"))) {
9548
10016
  ctx.report({
9549
10017
  rule: "database-elsewhere",
9550
10018
  level: "warn",
@@ -9567,7 +10035,7 @@ function checkEslintConfig(ctx) {
9567
10035
  if (!file) return;
9568
10036
  let text;
9569
10037
  try {
9570
- text = readFileSync(path30.join(ctx.root, file), "utf8");
10038
+ text = readFileSync(path62.join(ctx.root, file), "utf8");
9571
10039
  } catch {
9572
10040
  return;
9573
10041
  }
@@ -9645,7 +10113,7 @@ function validateFigmaConfig(raw, source = "genesis.config.json") {
9645
10113
  return { file: obj.file, pages: out, proposalsPage: obj.proposalsPage ?? "Proposals" };
9646
10114
  }
9647
10115
  function readFigmaConfig(root) {
9648
- const file = path30.join(root, "genesis.config.json");
10116
+ const file = path62.join(root, "genesis.config.json");
9649
10117
  if (!existsSync(file)) return null;
9650
10118
  let raw;
9651
10119
  try {
@@ -9659,7 +10127,7 @@ function walk2(dir, out = []) {
9659
10127
  if (!existsSync(dir)) return out;
9660
10128
  for (const name of readdirSync(dir).sort()) {
9661
10129
  if (name === "node_modules" || name.startsWith(".")) continue;
9662
- const full = path30.join(dir, name);
10130
+ const full = path62.join(dir, name);
9663
10131
  if (statSync(full).isDirectory()) walk2(full, out);
9664
10132
  else if (CODE.test(name) && !/\.(?:test|spec|d)\.[jt]sx?$/.test(name)) out.push(full);
9665
10133
  }
@@ -9688,27 +10156,27 @@ function tanstackSegments(stem) {
9688
10156
  return out;
9689
10157
  }
9690
10158
  function expoRoot(root) {
9691
- for (const dir of ["src/app", "app"]) if (existsSync(path30.join(root, dir))) return dir;
10159
+ for (const dir of ["src/app", "app"]) if (existsSync(path62.join(root, dir))) return dir;
9692
10160
  return null;
9693
10161
  }
9694
10162
  function appRoutes(root) {
9695
10163
  const out = [];
9696
- const rel = (f) => path30.relative(root, f).split(path30.sep).join("/");
10164
+ const rel = (f) => path62.relative(root, f).split(path62.sep).join("/");
9697
10165
  const expo = expoRoot(root);
9698
10166
  if (expo) {
9699
- for (const f of walk2(path30.join(root, expo))) {
9700
- const parts = path30.relative(path30.join(root, expo), f).split(path30.sep);
10167
+ for (const f of walk2(path62.join(root, expo))) {
10168
+ const parts = path62.relative(path62.join(root, expo), f).split(path62.sep);
9701
10169
  const stem = parts.pop().replace(CODE, "");
9702
10170
  if (stem === "_layout" || stem.startsWith("+")) continue;
9703
10171
  if (stem !== "index") parts.push(stem);
9704
10172
  out.push(withId({ route: parts.join("/") || "index", platform: "native", file: rel(f) }, f));
9705
10173
  }
9706
10174
  }
9707
- const tanstack = path30.join(root, "src/routes");
10175
+ const tanstack = path62.join(root, "src/routes");
9708
10176
  if (existsSync(tanstack)) {
9709
10177
  const seen = /* @__PURE__ */ new Set();
9710
10178
  for (const f of walk2(tanstack)) {
9711
- const parts = path30.relative(tanstack, f).split(path30.sep);
10179
+ const parts = path62.relative(tanstack, f).split(path62.sep);
9712
10180
  const stem = parts.pop().replace(CODE, "").replace(/\.lazy$/, "");
9713
10181
  if (stem === "__root" || stem === "route" || stem.startsWith("-") || parts.some((p) => p.startsWith("-"))) continue;
9714
10182
  const segs = [...parts.flatMap(tanstackSegments), ...tanstackSegments(stem)];
@@ -9773,12 +10241,12 @@ function navTargets(code, file) {
9773
10241
  return out.sort((a, b) => a.line - b.line);
9774
10242
  }
9775
10243
  function appNavTargets(root) {
9776
- const files = [.../* @__PURE__ */ new Set([...walk2(path30.join(root, "src")), ...walk2(path30.join(root, "app"))])];
9777
- return files.flatMap((f) => navTargets(readFileSync(f, "utf8"), path30.relative(root, f).split(path30.sep).join("/")));
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("/")));
9778
10246
  }
9779
10247
  function appDynamicNavTargets(root) {
9780
- const files = [.../* @__PURE__ */ new Set([...walk2(path30.join(root, "src")), ...walk2(path30.join(root, "app"))])];
9781
- return files.flatMap((f) => dynamicNavTargets(readFileSync(f, "utf8"), path30.relative(root, f).split(path30.sep).join("/")));
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("/")));
9782
10250
  }
9783
10251
  function splitName(name) {
9784
10252
  const i = name.indexOf(" \xB7 ");
@@ -9901,7 +10369,7 @@ function compare(config, routes, targets, figma, dynamicTargets = []) {
9901
10369
  }
9902
10370
  async function checkFigmaRoutes(options) {
9903
10371
  const config = options.config ?? readFigmaConfig(options.root);
9904
- if (!config) throw new FigmaConfigError(`no "figma" block in ${path30.join(options.root, "genesis.config.json")}`);
10372
+ if (!config) throw new FigmaConfigError(`no "figma" block in ${path62.join(options.root, "genesis.config.json")}`);
9905
10373
  const token = options.token ?? process.env.FIGMA_ACCESS_TOKEN;
9906
10374
  if (!token) throw new FigmaConfigError("FIGMA_ACCESS_TOKEN isn't set");
9907
10375
  const figma = await readFigma(config, token, options.fetch);
@@ -10058,7 +10526,7 @@ __export(doctor_exports, {
10058
10526
  writeAgentHooks: () => writeAgentHooks
10059
10527
  });
10060
10528
  async function runDoctor(options = {}) {
10061
- const root = path30.resolve(options.root ?? process.cwd());
10529
+ const root = path62.resolve(options.root ?? process.cwd());
10062
10530
  const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);
10063
10531
  const config = loaded.config;
10064
10532
  const genesis = options.genesis ?? loadGenesis(root, config);
@@ -10113,7 +10581,7 @@ async function runDoctor(options = {}) {
10113
10581
  const configured = applyConfig(raw, config, packageIds);
10114
10582
  let findings = applyExtensions(configured, extensionCtx);
10115
10583
  if (options.base && changed) {
10116
- const isAppPath = (f) => existsSync(path30.join(root, f));
10584
+ const isAppPath = (f) => existsSync(path62.join(root, f));
10117
10585
  const origins = options.changedFiles ? /* @__PURE__ */ new Map() : originsSince(root, options.base);
10118
10586
  const originOf = (f) => origins.get(f) ?? f;
10119
10587
  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));
@@ -10191,6 +10659,7 @@ function builtinChecks(config, options = {}) {
10191
10659
  { name: "studio-server-imports", check: checkStudioServerImports },
10192
10660
  { name: "removed-scope-names", check: checkRemovedScopeNames },
10193
10661
  { name: "app-parts", check: checkAppParts },
10662
+ { name: "client-layer", check: checkClientLayer },
10194
10663
  { name: "stability-imports", check: checkStabilityImports },
10195
10664
  { name: "agent-guide", check: (ctx) => {
10196
10665
  checkAgentGuide(ctx);
@@ -10315,6 +10784,7 @@ var init_doctor = __esm({
10315
10784
  init_dates();
10316
10785
  init_api_usage();
10317
10786
  init_custom_views();
10787
+ init_client_layer();
10318
10788
  init_stability();
10319
10789
  init_package_rules();
10320
10790
  init_ratchet();
@@ -10358,12 +10828,12 @@ __export(agent_rules_exports, {
10358
10828
  runsOnPullRequestsInto: () => runsOnPullRequestsInto
10359
10829
  });
10360
10830
  function changesetBumps(root) {
10361
- const dir = path30.join(root, ".changeset");
10831
+ const dir = path62.join(root, ".changeset");
10362
10832
  const bumps = /* @__PURE__ */ new Map();
10363
10833
  if (!existsSync(dir)) return bumps;
10364
10834
  for (const name of readdirSync(dir)) {
10365
10835
  if (!name.endsWith(".md") || name === "README.md") continue;
10366
- const text = readFileSync(path30.join(dir, name), "utf8");
10836
+ const text = readFileSync(path62.join(dir, name), "utf8");
10367
10837
  const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
10368
10838
  for (const line of front.split(/\r?\n/)) {
10369
10839
  const m = /^\s*["']?([^"':]+)["']?\s*:\s*(major|minor|patch)\s*$/.exec(line);
@@ -10376,13 +10846,13 @@ function changesetBumps(root) {
10376
10846
  return bumps;
10377
10847
  }
10378
10848
  function firstVersionProblems(root) {
10379
- const packagesDir = path30.join(root, "packages");
10849
+ const packagesDir = path62.join(root, "packages");
10380
10850
  if (!existsSync(packagesDir)) return [];
10381
10851
  const bumps = changesetBumps(root);
10382
10852
  const problems = [];
10383
10853
  for (const dir of readdirSync(packagesDir)) {
10384
- const file = path30.join(packagesDir, dir, "package.json");
10385
- if (!existsSync(file) || existsSync(path30.join(packagesDir, dir, "CHANGELOG.md"))) continue;
10854
+ const file = path62.join(packagesDir, dir, "package.json");
10855
+ if (!existsSync(file) || existsSync(path62.join(packagesDir, dir, "CHANGELOG.md"))) continue;
10386
10856
  const pkg = JSON.parse(readFileSync(file, "utf8"));
10387
10857
  if (pkg.private || !pkg.name) continue;
10388
10858
  if (pkg.version !== FIRST_VERSION) {
@@ -10453,12 +10923,12 @@ function runsOnPullRequestsInto(workflow, branch) {
10453
10923
  return ignore ? !ignore.some((p) => globMatches(p, branch)) : void 0;
10454
10924
  }
10455
10925
  function batchCiProblems(root, batch) {
10456
- const dir = path30.join(root, ".github", "workflows");
10926
+ const dir = path62.join(root, ".github", "workflows");
10457
10927
  if (!existsSync(dir)) return [];
10458
10928
  const problems = [];
10459
10929
  for (const name of readdirSync(dir)) {
10460
10930
  if (!/\.ya?ml$/.test(name)) continue;
10461
- const workflow = readFileSync(path30.join(dir, name), "utf8");
10931
+ const workflow = readFileSync(path62.join(dir, name), "utf8");
10462
10932
  const main = runsOnPullRequestsInto(workflow, "main");
10463
10933
  if (main && !runsOnPullRequestsInto(workflow, sampleBranch(batch))) {
10464
10934
  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` });
@@ -10503,20 +10973,20 @@ function readObject(file, key2) {
10503
10973
  }
10504
10974
  }
10505
10975
  function settings(root, options) {
10506
- const fromPackage = readObject(path30.join(root, "package.json"), "genesisFeatures");
10507
- const fromConfig = readObject(path30.join(root, "genesis.config.json"), "features");
10976
+ const fromPackage = readObject(path62.join(root, "package.json"), "genesisFeatures");
10977
+ const fromConfig = readObject(path62.join(root, "genesis.config.json"), "features");
10508
10978
  const given = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== void 0));
10509
10979
  return { ...fromPackage, ...fromConfig, ...given };
10510
10980
  }
10511
10981
  async function loadRegistry(input) {
10512
- const root = path30.resolve(input.dir);
10982
+ const root = path62.resolve(input.dir);
10513
10983
  const options = settings(root, input);
10514
- const registry = options.registry ?? DEFAULT_REGISTRIES.find((p) => existsSync(path30.join(root, p)));
10515
- if (!registry || !existsSync(path30.join(root, registry))) {
10984
+ const registry = options.registry ?? DEFAULT_REGISTRIES.find((p) => existsSync(path62.join(root, p)));
10985
+ if (!registry || !existsSync(path62.join(root, registry))) {
10516
10986
  throw new Error(`No feature registry found. Looked for ${options.registry ?? DEFAULT_REGISTRIES.join(" and ")}; pass --registry.`);
10517
10987
  }
10518
- const jiti = createJiti(path30.join(root, "package.json"), { moduleCache: false });
10519
- const load = async (file) => await jiti.import(path30.join(root, file));
10988
+ const jiti = createJiti(path62.join(root, "package.json"), { moduleCache: false });
10989
+ const load = async (file) => await jiti.import(path62.join(root, file));
10520
10990
  const mod = await load(registry);
10521
10991
  const features2 = mod.features ?? mod.default;
10522
10992
  if (!isObject5(features2)) throw new Error(`${registry} must export \`features\` (from defineFeatures).`);
@@ -10528,7 +10998,7 @@ async function loadRegistry(input) {
10528
10998
  const project = {
10529
10999
  ...rest,
10530
11000
  root,
10531
- source: options.source ?? registry.split(path30.sep).join("/"),
11001
+ source: options.source ?? registry.split(path62.sep).join("/"),
10532
11002
  features: features2,
10533
11003
  flags
10534
11004
  };
@@ -10579,23 +11049,23 @@ async function runFeaturesCheck(options) {
10579
11049
  function readFeaturePackages(root) {
10580
11050
  const found = [];
10581
11051
  const read3 = (dir, inRepo) => {
10582
- const file = path30.join(dir, "package.json");
11052
+ const file = path62.join(dir, "package.json");
10583
11053
  if (!existsSync(file)) return;
10584
11054
  try {
10585
11055
  const pkg = JSON.parse(readFileSync(file, "utf8"));
10586
11056
  const layer = pkg.genesis?.layer;
10587
11057
  if (typeof pkg.name !== "string" || !PACKAGE_LAYERS.includes(layer)) return;
10588
11058
  if (found.some((p) => p.name === pkg.name)) return;
10589
- found.push({ name: pkg.name, layer, ...inRepo ? { dir: path30.relative(root, dir).split(path30.sep).join("/") } : {} });
11059
+ found.push({ name: pkg.name, layer, ...inRepo ? { dir: path62.relative(root, dir).split(path62.sep).join("/") } : {} });
10590
11060
  } catch {
10591
11061
  }
10592
11062
  };
10593
11063
  for (const [base, inRepo] of [
10594
- [path30.join(root, "packages"), true],
10595
- [path30.join(root, "node_modules", "@marktiderman"), false]
11064
+ [path62.join(root, "packages"), true],
11065
+ [path62.join(root, "node_modules", "@marktiderman"), false]
10596
11066
  ]) {
10597
11067
  if (!existsSync(base)) continue;
10598
- for (const name of readdirSync(base)) read3(path30.join(base, name), inRepo);
11068
+ for (const name of readdirSync(base)) read3(path62.join(base, name), inRepo);
10599
11069
  }
10600
11070
  return found;
10601
11071
  }
@@ -10712,7 +11182,7 @@ function readRegister(markdown) {
10712
11182
  const need = at(row, "need");
10713
11183
  if (!need || need === "-") problems.push(`${where2}: say the need in one line`);
10714
11184
  const local = at(row, "local");
10715
- if (local && local !== "-" && localPaths(local).some((p) => path30.isAbsolute(p) || /^[A-Za-z]:[\\/]/.test(p) || p.split(/[\\/]/).includes(".."))) {
11185
+ if (local && local !== "-" && localPaths(local).some((p) => path62.isAbsolute(p) || /^[A-Za-z]:[\\/]/.test(p) || p.split(/[\\/]/).includes(".."))) {
10716
11186
  problems.push(`${where2}: local must be paths inside the app, relative to its root`);
10717
11187
  }
10718
11188
  const opt = (c) => at(row, c) && at(row, c) !== "-" ? at(row, c) : void 0;
@@ -10724,13 +11194,13 @@ function localPaths(local) {
10724
11194
  return (local ?? "").split(/,\s+|<br\s*\/?>/i).map((p) => p.trim()).filter((p) => p && p !== "-");
10725
11195
  }
10726
11196
  function checkUpstream(root) {
10727
- const found = REGISTER_PATHS.find((p) => existsSync(path30.join(root, p)));
11197
+ const found = REGISTER_PATHS.find((p) => existsSync(path62.join(root, p)));
10728
11198
  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 };
10729
- const { entries, problems } = readRegister(readFileSync(path30.join(root, found), "utf8"));
11199
+ const { entries, problems } = readRegister(readFileSync(path62.join(root, found), "utf8"));
10730
11200
  const warnings = [];
10731
11201
  for (const e of entries) {
10732
11202
  const paths = localPaths(e.local);
10733
- const absent = paths.filter((p) => !existsSync(path30.join(root, p)));
11203
+ const absent = paths.filter((p) => !existsSync(path62.join(root, p)));
10734
11204
  const present = paths.filter((p) => !absent.includes(p));
10735
11205
  if (absent.length && e.status !== "promoted" && e.status !== "declined") problems.push(`${e.id}: local ${absent.join(", ")} doesn't exist`);
10736
11206
  if (present.length && e.status === "promoted") {
@@ -10759,6 +11229,177 @@ var init_upstream = __esm({
10759
11229
  }
10760
11230
  });
10761
11231
 
11232
+ // src/client/init.ts
11233
+ var init_exports = {};
11234
+ __export(init_exports, {
11235
+ DEFAULT_CLIENT_DIR: () => DEFAULT_CLIENT_DIR2,
11236
+ clientConfigChange: () => clientConfigChange,
11237
+ normalizeClientDir: () => normalizeClientDir,
11238
+ planClientInit: () => planClientInit
11239
+ });
11240
+ function normalizeClientDir(raw) {
11241
+ const dir = raw.trim().replace(/^(\.\/)+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/, "");
11242
+ if (raw.includes("\\") || !isPlainFolder(dir) || dir.split("/").includes(".")) {
11243
+ throw new Error(`client init: "${raw}" isn't a plain folder inside the app; give one like src/client (letters, digits, dashes, dots and underscores, separated by /)`);
11244
+ }
11245
+ return dir;
11246
+ }
11247
+ function layerFile() {
11248
+ return `// The app's client layer (ADR 0020): one provider for what every list and record page in the
11249
+ // app shares. Mount <ClientLayer> once, near the root, inside GenesisProvider.
11250
+ import type { ReactNode } from "react";
11251
+ import { createLocalSavedViewStore, type SavedViewStore } from "@marktiderman/genesis-core/resource-view";
11252
+ import { useBrowserSearchParams } from "@marktiderman/genesis-ui";
11253
+ import { ResourceViewDefaultsProvider } from "@marktiderman/genesis-ui/data";
11254
+
11255
+ /**
11256
+ * Where saved views live. The device store keeps them in this browser; swap in a store over the
11257
+ * app's own table (list, save, remove, under row-level security) to share them across devices
11258
+ * and with a team.
11259
+ */
11260
+ export const savedViews: SavedViewStore = createLocalSavedViewStore();
11261
+
11262
+ export function ClientLayer({ children }: { children: ReactNode }) {
11263
+ // The router's search-params adapter: a TanStack or React Router app passes its own hook's.
11264
+ const urlState = useBrowserSearchParams();
11265
+ return (
11266
+ <ResourceViewDefaultsProvider sizeColumns clipCells pagerJumps savedViews={savedViews} urlState={urlState} rowActions>
11267
+ {children}
11268
+ </ResourceViewDefaultsProvider>
11269
+ );
11270
+ }
11271
+ `;
11272
+ }
11273
+ function resourceViewFile() {
11274
+ return `// The app's ResourceView (ADR 0020): Genesis's, with the app's defaults. Screens render this one,
11275
+ // never Genesis's directly, so a default the app changes reaches every list at once.
11276
+ import { ResourceView as GenesisResourceView, type ResourceViewProps } from "@marktiderman/genesis-ui/data";
11277
+
11278
+ type Row = Record<string, unknown>;
11279
+
11280
+ export function ResourceView<T extends Row = Row>(props: ResourceViewProps<T>) {
11281
+ return <GenesisResourceView<T> createdToast {...props} />;
11282
+ }
11283
+
11284
+ export type { ResourceViewProps };
11285
+ `;
11286
+ }
11287
+ function recordViewFile() {
11288
+ return `// The app's RecordView (ADR 0020): Genesis's record page, with the app's defaults. Screens render
11289
+ // this one, never Genesis's directly, so a default the app changes reaches every record page at once.
11290
+ import { RecordView as GenesisRecordView, type RecordViewProps } from "@marktiderman/genesis-ui/data";
11291
+
11292
+ type Row = Record<string, unknown>;
11293
+
11294
+ export function RecordView<T extends Row = Row>(props: RecordViewProps<T>) {
11295
+ return <GenesisRecordView<T> {...props} />;
11296
+ }
11297
+
11298
+ export type { RecordViewProps };
11299
+ `;
11300
+ }
11301
+ function contractFile(type) {
11302
+ const name = camel(type);
11303
+ const table = type.replace(/-/g, "_");
11304
+ const Row = `${name[0].toUpperCase()}${name.slice(1)}Row`;
11305
+ return `// The ${type} contract: its fields and identity. A starting example so the view works today; once
11306
+ // the app generates its contracts, export the generated one instead:
11307
+ // export { contracts["public.${table}"] as ${name}Contract } \u2026 from "../../lib/resources.genesis";
11308
+ import { defineResource } from "@marktiderman/genesis-core";
11309
+
11310
+ export interface ${Row} {
11311
+ id: string;
11312
+ name: string;
11313
+ status: string;
11314
+ updated_at: string;
11315
+ [field: string]: unknown;
11316
+ }
11317
+
11318
+ export const ${name}Contract = defineResource<${Row}>()({
11319
+ name: "public.${table}",
11320
+ key: "id",
11321
+ labelField: "name",
11322
+ noun: "${type.replace(/-/g, " ")}",
11323
+ fields: [
11324
+ { name: "id", type: "string", readOnly: true },
11325
+ { name: "name", type: "string", label: "Name" },
11326
+ { name: "status", type: "string", label: "Status" },
11327
+ { name: "updated_at", type: "datetime", label: "Updated", readOnly: true },
11328
+ ],
11329
+ });
11330
+ `;
11331
+ }
11332
+ function viewFile(type) {
11333
+ const name = camel(type);
11334
+ return `// The ${type} view (ADR 0020): what a ${type} record means to people. One view per resource; every
11335
+ // screen of ${type} renders this one, narrowed by its own props.
11336
+ import { defineView } from "@marktiderman/genesis-core/resource-view";
11337
+ import { ${name}Contract } from "./contract";
11338
+
11339
+ export const ${name}View = defineView(${name}Contract, {
11340
+ columns: { default: ["name", "status", "updated_at"] },
11341
+ segments: [{ id: "all", label: "All" }],
11342
+ filters: [{ field: "status" }],
11343
+ export: true,
11344
+ // fields: { status: { tones: { active: "success" } } },
11345
+ // actions: [{ name: "archive", label: "Archive", bulk: true }],
11346
+ });
11347
+ `;
11348
+ }
11349
+ function appearanceFile(type) {
11350
+ const name = camel(type);
11351
+ return `// How a ${type} record looks (ADR 0020): its own cells, its card and its record page. Keep the
11352
+ // rules in view.ts; this file draws.
11353
+ import type { ReactNode } from "react";
11354
+
11355
+ type ${name[0].toUpperCase()}${name.slice(1)}Row = Record<string, unknown>;
11356
+
11357
+ /** Cells this type draws its own way, by column key (ResourceView's \`cells\`). */
11358
+ export const ${name}Cells: Partial<Record<string, (row: ${name[0].toUpperCase()}${name.slice(1)}Row) => ReactNode>> = {};
11359
+ `;
11360
+ }
11361
+ function planClientInit(options = {}) {
11362
+ const dir = normalizeClientDir(options.dir ?? DEFAULT_CLIENT_DIR2);
11363
+ if (options.type !== void 0 && !TYPE.test(options.type)) throw new Error(`client init: the type "${options.type}" is lowercase words of letters and digits joined by single dashes, like tasks or client-notes`);
11364
+ const files = [
11365
+ { path: `${dir}/client-layer.tsx`, content: layerFile() },
11366
+ { path: `${dir}/resource-view.tsx`, content: resourceViewFile() },
11367
+ { path: `${dir}/record-view.tsx`, content: recordViewFile() },
11368
+ { path: `${dir}/cells/index.ts`, content: "// Cells the app draws its own way, shared by its types (ADR 0020).\nexport {};\n" },
11369
+ { path: `${dir}/components/index.ts`, content: "// The app's own parts (ADR 0020): name each element's data-slot app-<name>.\nexport {};\n" },
11370
+ {
11371
+ path: `${dir}/view-types/index.ts`,
11372
+ content: "// View types the app registers (ADR 0021): defineViewType, then registerViewType once at start-up.\nexport {};\n"
11373
+ }
11374
+ ];
11375
+ if (options.type) {
11376
+ files.push({ path: `${dir}/${options.type}/contract.ts`, content: contractFile(options.type) });
11377
+ files.push({ path: `${dir}/${options.type}/view.ts`, content: viewFile(options.type) });
11378
+ files.push({ path: `${dir}/${options.type}/appearance.tsx`, content: appearanceFile(options.type) });
11379
+ }
11380
+ const steps = [
11381
+ `Mount <ClientLayer> from ${dir}/client-layer.tsx once, inside GenesisProvider.`,
11382
+ `Render ResourceView and RecordView from ${dir}/resource-view.tsx and ${dir}/record-view.tsx in screens; genesis doctor warns (client/layer) where a screen renders Genesis's directly.`,
11383
+ ...dir !== DEFAULT_CLIENT_DIR2 ? [`genesis.config.json now names the folder: { "client": { "dir": "${dir}" } }.`] : []
11384
+ ];
11385
+ return { dir, files, steps };
11386
+ }
11387
+ function clientConfigChange(planned, configured, force = false) {
11388
+ if (configured === void 0) return planned === DEFAULT_CLIENT_DIR2 ? "none" : "write";
11389
+ if (configured === planned) return "none";
11390
+ if (!force) throw new Error(`client init: genesis.config.json names the client layer's folder "${configured}"; pass --force to move it to "${planned}"`);
11391
+ return "write";
11392
+ }
11393
+ var DEFAULT_CLIENT_DIR2, TYPE, camel;
11394
+ var init_init = __esm({
11395
+ "src/client/init.ts"() {
11396
+ init_config();
11397
+ DEFAULT_CLIENT_DIR2 = "src/client";
11398
+ TYPE = /^(?=.{1,40}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
11399
+ camel = (name) => name.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
11400
+ }
11401
+ });
11402
+
10762
11403
  // src/studio/wire-route.ts
10763
11404
  function routeTags(source) {
10764
11405
  const tags = [];
@@ -10850,8 +11491,8 @@ var init_wire_route = __esm({
10850
11491
  });
10851
11492
 
10852
11493
  // src/studio/init.ts
10853
- var init_exports = {};
10854
- __export(init_exports, {
11494
+ var init_exports2 = {};
11495
+ __export(init_exports2, {
10855
11496
  detectHost: () => detectHost,
10856
11497
  planStudioInit: () => planStudioInit
10857
11498
  });
@@ -11121,7 +11762,7 @@ ${line}
11121
11762
  );
11122
11763
  }
11123
11764
  var SERVER_VERSION, PACKAGES, ROLE, LOVABLE_CLIENT;
11124
- var init_init = __esm({
11765
+ var init_init2 = __esm({
11125
11766
  "src/studio/init.ts"() {
11126
11767
  init_wire_route();
11127
11768
  SERVER_VERSION = createRequire(import.meta.url)("@marktiderman/genesis-studio-server/package.json").version;
@@ -11180,7 +11821,7 @@ function literal(value, indent) {
11180
11821
  if (Array.isArray(value)) return `[${value.map((v) => literal(v, indent)).join(", ")}]`;
11181
11822
  if (value && typeof value === "object") {
11182
11823
  const inner = `${indent} `;
11183
- const lines = Object.entries(value).map(([k, v]) => `${inner}${IDENT.test(k) ? k : JSON.stringify(k)}: ${literal(v, inner)},`);
11824
+ const lines = Object.entries(value).map(([k, v]) => `${inner}${IDENT2.test(k) ? k : JSON.stringify(k)}: ${literal(v, inner)},`);
11184
11825
  return `{
11185
11826
  ${lines.join("\n")}
11186
11827
  ${indent}}`;
@@ -11188,8 +11829,8 @@ ${indent}}`;
11188
11829
  return JSON.stringify(value);
11189
11830
  }
11190
11831
  function featureKindField(root) {
11191
- for (let dir = path30.resolve(root); ; dir = path30.dirname(dir)) {
11192
- for (const file of [path30.join(dir, "node_modules/@marktiderman/genesis-features/package.json"), path30.join(dir, "packages/features/package.json")]) {
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")]) {
11193
11834
  try {
11194
11835
  const pkg = JSON.parse(readFileSync(file, "utf8"));
11195
11836
  if (pkg.name !== "@marktiderman/genesis-features" || !pkg.version) continue;
@@ -11198,7 +11839,7 @@ function featureKindField(root) {
11198
11839
  } catch {
11199
11840
  }
11200
11841
  }
11201
- if (path30.dirname(dir) === dir) return "layer";
11842
+ if (path62.dirname(dir) === dir) return "layer";
11202
11843
  }
11203
11844
  }
11204
11845
  function featureSnippet(manifest, owner, kindField = "kind") {
@@ -11268,20 +11909,20 @@ function addFeatureEntry(text, snippet) {
11268
11909
  return `${head.replace(/\s*$/, "")}
11269
11910
  ${snippet}${text.slice(scan.close)}`;
11270
11911
  }
11271
- var IDENT;
11912
+ var IDENT2;
11272
11913
  var init_registry_edit = __esm({
11273
11914
  "src/blocks/registry-edit.ts"() {
11274
- IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
11915
+ IDENT2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
11275
11916
  }
11276
11917
  });
11277
11918
  function routerRoot2(root) {
11278
11919
  try {
11279
- const config = JSON.parse(readFileSync(path30.join(root, "genesis.config.json"), "utf8"));
11920
+ const config = JSON.parse(readFileSync(path62.join(root, "genesis.config.json"), "utf8"));
11280
11921
  const configured = config.doctor?.native?.routerRoot;
11281
- if (configured && existsSync(path30.join(root, configured, "_layout.tsx"))) return configured.replace(/\/+$/, "");
11922
+ if (configured && existsSync(path62.join(root, configured, "_layout.tsx"))) return configured.replace(/\/+$/, "");
11282
11923
  } catch {
11283
11924
  }
11284
- for (const dir of ["src/app", "app"]) if (existsSync(path30.join(root, dir, "_layout.tsx"))) return dir;
11925
+ for (const dir of ["src/app", "app"]) if (existsSync(path62.join(root, dir, "_layout.tsx"))) return dir;
11285
11926
  return null;
11286
11927
  }
11287
11928
  function routeOf(file) {
@@ -11343,7 +11984,7 @@ __export(add_exports, {
11343
11984
  });
11344
11985
  function appDependencies(root) {
11345
11986
  try {
11346
- const pkg = JSON.parse(readFileSync(path30.join(root, "package.json"), "utf8"));
11987
+ const pkg = JSON.parse(readFileSync(path62.join(root, "package.json"), "utf8"));
11347
11988
  return { ...pkg["dependencies"], ...pkg["devDependencies"], ...pkg["optionalDependencies"] };
11348
11989
  } catch {
11349
11990
  return {};
@@ -11352,14 +11993,14 @@ function appDependencies(root) {
11352
11993
  function registryFile(root) {
11353
11994
  const read3 = (file, key2) => {
11354
11995
  try {
11355
- const v = JSON.parse(readFileSync(path30.join(root, file), "utf8"))[key2]?.registry;
11996
+ const v = JSON.parse(readFileSync(path62.join(root, file), "utf8"))[key2]?.registry;
11356
11997
  return typeof v === "string" ? v : void 0;
11357
11998
  } catch {
11358
11999
  return void 0;
11359
12000
  }
11360
12001
  };
11361
12002
  const named = read3("genesis.config.json", "features") ?? read3("package.json", "genesisFeatures");
11362
- for (const candidate of named ? [named] : ["src/features.ts", "features.ts"]) if (existsSync(path30.join(root, candidate))) return candidate;
12003
+ for (const candidate of named ? [named] : ["src/features.ts", "features.ts"]) if (existsSync(path62.join(root, candidate))) return candidate;
11363
12004
  return null;
11364
12005
  }
11365
12006
  async function registryIds(root, file) {
@@ -11447,7 +12088,7 @@ verify_jwt = false
11447
12088
  return { content: `${config.replace(/\s*$/, "\n")}${add}`, names };
11448
12089
  }
11449
12090
  async function runAdd(options) {
11450
- const root = path30.resolve(options.root);
12091
+ const root = path62.resolve(options.root);
11451
12092
  const log = options.log ?? SILENT;
11452
12093
  const now = options.now ?? /* @__PURE__ */ new Date();
11453
12094
  const warnings = [];
@@ -11686,7 +12327,7 @@ function notificationTypesSql(rows, registryFile2) {
11686
12327
  }
11687
12328
  function configuredRegistry(root) {
11688
12329
  try {
11689
- const raw = JSON.parse(readFileSync(path30.join(root, "genesis.config.json"), "utf8"));
12330
+ const raw = JSON.parse(readFileSync(path62.join(root, "genesis.config.json"), "utf8"));
11690
12331
  return typeof raw.notifications?.registry === "string" ? raw.notifications.registry : void 0;
11691
12332
  } catch {
11692
12333
  return void 0;
@@ -11705,14 +12346,14 @@ async function planNotificationTypes(root, options) {
11705
12346
  warnings.push(`Notification types: not checked on a dry run (loading ${file} runs app code).`);
11706
12347
  return { registry: file, warnings };
11707
12348
  }
11708
- const absolute = path30.resolve(root, file);
12349
+ const absolute = path62.resolve(root, file);
11709
12350
  if (!existsSync(absolute)) {
11710
12351
  warnings.push(`Notification types: ${file} doesn't exist (a relative path is resolved against the app's root, ${root}).`);
11711
12352
  return { registry: file, warnings };
11712
12353
  }
11713
12354
  let mod;
11714
12355
  try {
11715
- const jiti = createJiti(path30.join(root, "package.json"), { moduleCache: false });
12356
+ const jiti = createJiti(path62.join(root, "package.json"), { moduleCache: false });
11716
12357
  mod = await jiti.import(absolute);
11717
12358
  } catch (err) {
11718
12359
  warnings.push(`Notification types: couldn't load ${file} (${err instanceof Error ? err.message : String(err)}).`);
@@ -11723,8 +12364,8 @@ async function planNotificationTypes(root, options) {
11723
12364
  warnings.push(`Notification types: ${file} exports no defineNotifications registry (export it as \`notifications\`).`);
11724
12365
  return { registry: file, warnings };
11725
12366
  }
11726
- const shown = path30.isAbsolute(file) ? path30.relative(root, absolute) : file;
11727
- const content = notificationTypesSql(found.toTypeRows(), shown.split(path30.sep).join("/"));
12367
+ const shown = path62.isAbsolute(file) ? path62.relative(root, absolute) : file;
12368
+ const content = notificationTypesSql(found.toTypeRows(), shown.split(path62.sep).join("/"));
11728
12369
  const app = readAppMigrations(root);
11729
12370
  const latest = app.filter((m) => m.name.endsWith(`_${TYPES_STEM}.sql`)).sort((a, b) => a.name < b.name ? -1 : 1).pop();
11730
12371
  if (latest && payloadOf(latest.content) === payloadOf(content)) return { registry: file, warnings };
@@ -11756,7 +12397,7 @@ __export(migrate_exports, {
11756
12397
  runMigrate: () => runMigrate
11757
12398
  });
11758
12399
  async function runMigrate(options) {
11759
- const root = path30.resolve(options.root);
12400
+ const root = path62.resolve(options.root);
11760
12401
  const lock = readLock(root);
11761
12402
  const warnings = [];
11762
12403
  const home = databaseElsewhere(root);
@@ -11873,7 +12514,7 @@ function repositoryDirectory(root, name) {
11873
12514
  const dir = packageDir(root, name);
11874
12515
  if (!dir) return null;
11875
12516
  try {
11876
- const { repository } = JSON.parse(readFileSync(path30.join(dir, "package.json"), "utf8"));
12517
+ const { repository } = JSON.parse(readFileSync(path62.join(dir, "package.json"), "utf8"));
11877
12518
  return typeof repository?.directory === "string" ? repository.directory : null;
11878
12519
  } catch {
11879
12520
  return null;
@@ -11952,11 +12593,11 @@ var init_new_exports = __esm({
11952
12593
  }
11953
12594
  });
11954
12595
  function walk3(dir, rel = "", out = /* @__PURE__ */ new Map()) {
11955
- for (const entry of readdirSync(path30.join(dir, rel), { withFileTypes: true })) {
12596
+ for (const entry of readdirSync(path62.join(dir, rel), { withFileTypes: true })) {
11956
12597
  if (SKIP.has(entry.name)) continue;
11957
12598
  const child = rel ? `${rel}/${entry.name}` : entry.name;
11958
12599
  if (entry.isDirectory()) walk3(dir, child, out);
11959
- else if (entry.isFile()) out.set(child, readFileSync(path30.join(dir, child)));
12600
+ else if (entry.isFile()) out.set(child, readFileSync(path62.join(dir, child)));
11960
12601
  }
11961
12602
  return out;
11962
12603
  }
@@ -11979,7 +12620,7 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
11979
12620
  const tag = `${name}@${version}`;
11980
12621
  try {
11981
12622
  if (!clone) {
11982
- clone = mkdtempSync(path30.join(tmpdir(), "genesis-upstream-"));
12623
+ clone = mkdtempSync(path62.join(tmpdir(), "genesis-upstream-"));
11983
12624
  git4(["init", "-q"]);
11984
12625
  }
11985
12626
  git4(["fetch", "-q", "--no-tags", "--depth", "1", repository, `+refs/tags/${tag}:refs/tags/${tag}`]);
@@ -11996,7 +12637,7 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
11996
12637
  }
11997
12638
  });
11998
12639
  if (!manifest) return { error: `the tag ${tag} has no package named ${name}` };
11999
- const dir = path30.posix.dirname(manifest);
12640
+ const dir = path62.posix.dirname(manifest);
12000
12641
  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)));
12001
12642
  const files = /* @__PURE__ */ new Map();
12002
12643
  if (entries.length) {
@@ -12022,10 +12663,10 @@ function gitUpstream(repository = GENESIS_REPOSITORY) {
12022
12663
  }
12023
12664
  function diffHunks(before, after) {
12024
12665
  if (before === after) return [];
12025
- const dir = mkdtempSync(path30.join(tmpdir(), "genesis-diff-"));
12666
+ const dir = mkdtempSync(path62.join(tmpdir(), "genesis-diff-"));
12026
12667
  try {
12027
- writeFileSync(path30.join(dir, "a"), before);
12028
- writeFileSync(path30.join(dir, "b"), after);
12668
+ writeFileSync(path62.join(dir, "a"), before);
12669
+ writeFileSync(path62.join(dir, "b"), after);
12029
12670
  let out = "";
12030
12671
  try {
12031
12672
  out = execFileSync("git", ["diff", "--no-index", "--no-color", "-U0", "a", "b"], { cwd: dir, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
@@ -12053,9 +12694,9 @@ function shippedBy(upstreamHunks) {
12053
12694
  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]));
12054
12695
  }
12055
12696
  function promotions(root, name) {
12056
- const file = REGISTER_PATHS.find((p) => existsSync(path30.join(root, p)));
12697
+ const file = REGISTER_PATHS.find((p) => existsSync(path62.join(root, p)));
12057
12698
  if (!file) return [];
12058
- const text = readFileSync(path30.join(root, file), "utf8");
12699
+ const text = readFileSync(path62.join(root, file), "utf8");
12059
12700
  const rows = text.split("\n");
12060
12701
  return readRegister(text).entries.filter((e) => e.status === "promoted" && e.package === name).map((e) => {
12061
12702
  const row = rows.find((r) => r.split("|").map((c) => c.trim())[1] === e.id) ?? "";
@@ -12113,7 +12754,7 @@ function planOverlays(root, wanted, upstream2, manifests = ["package.json"]) {
12113
12754
  if (!GENESIS_PACKAGE_NAME.test(pkg.name)) continue;
12114
12755
  let json;
12115
12756
  try {
12116
- json = JSON.parse(readFileSync(path30.join(pkg.dir, "package.json"), "utf8"));
12757
+ json = JSON.parse(readFileSync(path62.join(pkg.dir, "package.json"), "utf8"));
12117
12758
  } catch {
12118
12759
  continue;
12119
12760
  }
@@ -12239,7 +12880,7 @@ function folderReferences(root, plan) {
12239
12880
  for (const file of candidates.sort()) {
12240
12881
  let text;
12241
12882
  try {
12242
- text = readFileSync(path30.join(root, file), "utf8");
12883
+ text = readFileSync(path62.join(root, file), "utf8");
12243
12884
  } catch {
12244
12885
  continue;
12245
12886
  }
@@ -12251,7 +12892,7 @@ function folderReferences(root, plan) {
12251
12892
  function planPins(root, plan, manifests) {
12252
12893
  const pins = /* @__PURE__ */ new Map();
12253
12894
  for (const file of manifests) {
12254
- const abs = path30.join(root, file);
12895
+ const abs = path62.join(root, file);
12255
12896
  if (!existsSync(abs)) continue;
12256
12897
  const text = readFileSync(abs, "utf8");
12257
12898
  const pinned = pinManifest(root, plan, file, text);
@@ -12269,9 +12910,9 @@ function pinManifest(root, plan, file, text) {
12269
12910
  } catch {
12270
12911
  return void 0;
12271
12912
  }
12272
- const overlay = path30.resolve(root, plan.rel);
12273
- const here = path30.dirname(path30.join(root, file));
12274
- const local = (spec) => typeof spec === "string" && (spec.startsWith("workspace:") || /^(file|link):/.test(spec) && path30.resolve(here, spec.slice(5)) === overlay);
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);
12275
12916
  let touched2 = false;
12276
12917
  for (const section2 of ["dependencies", "devDependencies", "optionalDependencies"]) {
12277
12918
  const deps = json[section2];
@@ -12286,7 +12927,7 @@ function pinManifest(root, plan, file, text) {
12286
12927
  touched2 = true;
12287
12928
  }
12288
12929
  }
12289
- const names = (entry) => typeof entry === "string" && path30.resolve(here, entry) === overlay;
12930
+ const names = (entry) => typeof entry === "string" && path62.resolve(here, entry) === overlay;
12290
12931
  const ws = json.workspaces;
12291
12932
  const list = Array.isArray(ws) ? ws : isObject6(ws) && Array.isArray(ws.packages) ? ws.packages : null;
12292
12933
  if (list?.some(names)) {
@@ -12304,10 +12945,10 @@ function applyOverlayPlans(root, plans, lockEdits = []) {
12304
12945
  const removedFolders = [];
12305
12946
  for (const plan of plans) {
12306
12947
  if (plan.skipped || plan.conflicts.length) continue;
12307
- const dir = path30.join(root, plan.rel);
12948
+ const dir = path62.join(root, plan.rel);
12308
12949
  if (plan.remove) {
12309
12950
  for (const file of plan.pins.keys()) {
12310
- const abs = path30.join(root, file);
12951
+ const abs = path62.join(root, file);
12311
12952
  const now = existsSync(abs) ? readFileSync(abs, "utf8") : null;
12312
12953
  const text = now === null ? plan.pins.get(file) : pinManifest(root, plan, file, now);
12313
12954
  if (typeof text !== "string") continue;
@@ -12320,10 +12961,10 @@ function applyOverlayPlans(root, plans, lockEdits = []) {
12320
12961
  continue;
12321
12962
  }
12322
12963
  for (const [file, bytes] of plan.writes) {
12323
- const target = path30.join(dir, file);
12964
+ const target = path62.join(dir, file);
12324
12965
  if (bytes === null) rmSync(target, { force: true });
12325
12966
  else {
12326
- mkdirSync(path30.dirname(target), { recursive: true });
12967
+ mkdirSync(path62.dirname(target), { recursive: true });
12327
12968
  writeFileSync(target, bytes);
12328
12969
  }
12329
12970
  changed.push(`${plan.rel}/${file}`);
@@ -12345,7 +12986,7 @@ function dropRemovedWorkspaces(root, folders) {
12345
12986
  const packages = [];
12346
12987
  try {
12347
12988
  for (const folder of folders) {
12348
- const entries = workspaceEntries(text, path30.relative(found.dir, folder).split(path30.sep).join("/"));
12989
+ const entries = workspaceEntries(text, path62.relative(found.dir, folder).split(path62.sep).join("/"));
12349
12990
  workspaces.push(...entries.workspaces);
12350
12991
  packages.push(...entries.packages);
12351
12992
  }
@@ -12353,8 +12994,8 @@ function dropRemovedWorkspaces(root, folders) {
12353
12994
  return null;
12354
12995
  }
12355
12996
  if (!workspaces.length && !packages.length) return null;
12356
- writeFileSync(path30.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { workspaces, packages }));
12357
- return { file: path30.relative(root, path30.join(found.dir, BUN_LOCK)).split(path30.sep).join("/"), workspaces };
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 };
12358
12999
  }
12359
13000
  function overlayChecklist(plans) {
12360
13001
  if (!plans.length) return [];
@@ -12419,8 +13060,8 @@ function pruneBunLock(root, want, dryRun) {
12419
13060
  return null;
12420
13061
  }
12421
13062
  if (!pruned.length) return null;
12422
- if (!dryRun) writeFileSync(path30.join(found.dir, BUN_LOCK), removeBunLockEntries(text, { packages: pruned.map((p) => p.key) }));
12423
- return { file: path30.relative(root, path30.join(found.dir, BUN_LOCK)).split(path30.sep).join("/"), pruned };
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 };
12424
13065
  }
12425
13066
  function npm(args, cwd) {
12426
13067
  return execFileSync("npm", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
@@ -12432,11 +13073,11 @@ function npmLookup(cwd) {
12432
13073
  if (!EXACT_OR_TAG.test(target)) throw new Error(`--version must be an exact version or a dist-tag, not "${target}"`);
12433
13074
  const version = JSON.parse(npm(["view", `${UMBRELLA}@${target}`, "version", "--json"], cwd) || "null");
12434
13075
  if (typeof version !== "string") throw new Error(`${UMBRELLA}@${target} is not one published version`);
12435
- const tmp = mkdtempSync(path30.join(tmpdir(), "genesis-umbrella-"));
13076
+ const tmp = mkdtempSync(path62.join(tmpdir(), "genesis-umbrella-"));
12436
13077
  try {
12437
13078
  const [packed] = JSON.parse(npm(["pack", `${UMBRELLA}@${version}`, "--pack-destination", tmp, "--json"], cwd));
12438
- execFileSync("tar", ["-xzf", path30.join(tmp, packed.filename), "-C", tmp, "package/dist/versions.json"]);
12439
- const manifest = JSON.parse(readFileSync(path30.join(tmp, "package/dist/versions.json"), "utf8"));
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"));
12440
13081
  if (manifest.version !== version) throw new Error(`${UMBRELLA}@${version} ships a versions.json for ${manifest.version}`);
12441
13082
  return manifest;
12442
13083
  } finally {
@@ -12482,8 +13123,8 @@ function readText2(file) {
12482
13123
  function tidyReleaseAgeExcludes(file) {
12483
13124
  const before = readText2(file);
12484
13125
  if (before === null) return false;
12485
- const dir = path30.dirname(file);
12486
- const after = normaliseReleaseAgeExcludes(before, tidyLocked(before, readText2(path30.join(dir, "pnpm-lock.yaml")), readText2(path30.join(dir, ".npmrc"))));
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"))));
12487
13128
  if (after === before) return false;
12488
13129
  writeFileSync(file, after);
12489
13130
  return true;
@@ -12499,14 +13140,14 @@ function gitTopLevel(root) {
12499
13140
  function folderBelowTopLevel(root) {
12500
13141
  const real2 = realpathSync(root);
12501
13142
  const top = gitTopLevel(real2);
12502
- return top === null ? null : path30.relative(top, real2).split(path30.sep).join("/");
13143
+ return top === null ? null : path62.relative(top, real2).split(path62.sep).join("/");
12503
13144
  }
12504
13145
  function pnpmWorkspaceFileFor(root) {
12505
13146
  const real2 = realpathSync(root);
12506
13147
  const top = gitTopLevel(real2);
12507
13148
  const lockDir = findLockfile(real2)?.dir;
12508
13149
  const fallback = lockDir && (!top || inside2(top, lockDir)) ? lockDir : real2;
12509
- return pnpmWorkspaceFile(real2, fallback, { exists: existsSync, join: path30.join, dirname: path30.dirname }, top ?? void 0);
13150
+ return pnpmWorkspaceFile(real2, fallback, { exists: existsSync, join: path62.join, dirname: path62.dirname }, top ?? void 0);
12510
13151
  }
12511
13152
  function pnpmVersionIn(root) {
12512
13153
  try {
@@ -12556,7 +13197,7 @@ function packageJsons(root) {
12556
13197
  if (files.length) return files;
12557
13198
  } catch {
12558
13199
  }
12559
- return existsSync(path30.join(root, "package.json")) ? ["package.json"] : [];
13200
+ return existsSync(path62.join(root, "package.json")) ? ["package.json"] : [];
12560
13201
  }
12561
13202
  function sourceText(root, source, substitutions) {
12562
13203
  const { package: pkg, path: rel } = parseSource(source);
@@ -12576,12 +13217,12 @@ function sourceText(root, source, substitutions) {
12576
13217
  }
12577
13218
  }
12578
13219
  async function runUpgrade(options) {
12579
- const root = path30.resolve(options.root);
13220
+ const root = path62.resolve(options.root);
12580
13221
  const log = options.log ?? (() => {
12581
13222
  });
12582
13223
  checkInstalled(root, options);
12583
13224
  const lookup = options.lookup ?? npmLookup(root);
12584
- const release = options.manifest ? JSON.parse(readFileSync(path30.resolve(options.manifest), "utf8")) : lookup.release(options.version ?? "latest");
13225
+ const release = options.manifest ? JSON.parse(readFileSync(path62.resolve(options.manifest), "utf8")) : lookup.release(options.version ?? "latest");
12585
13226
  const pinned = { [UMBRELLA]: release.version, ...release.packages };
12586
13227
  const wanted = (name) => pinned[name] ?? lookup.latest(name);
12587
13228
  const prBase = options.pr && !options.dryRun ? checkPullRequest(root, release.version) : void 0;
@@ -12679,7 +13320,7 @@ async function runUpgrade(options) {
12679
13320
  const excludeWarnings = [];
12680
13321
  if (!options.dryRun && options.install !== false && (bumped.size || bunLock)) {
12681
13322
  const workspaceFile = pm === "pnpm" ? pnpmWorkspaceFileFor(root) : null;
12682
- const relWorkspace = workspaceFile ? path30.relative(realpathSync(root), workspaceFile) : null;
13323
+ const relWorkspace = workspaceFile ? path62.relative(realpathSync(root), workspaceFile) : null;
12683
13324
  const workspaceBefore = workspaceFile ? readText2(workspaceFile) : null;
12684
13325
  const tidy = () => {
12685
13326
  if (!workspaceFile || !tidyReleaseAgeExcludes(workspaceFile)) return;
@@ -12912,7 +13553,7 @@ function checkSubstitutions(substitutions) {
12912
13553
  if (!substitutions || !Object.keys(substitutions).length) return;
12913
13554
  let names;
12914
13555
  try {
12915
- const was = starterIdentity(readFileSync(path30.join(starterDir(), "starter.config.ts"), "utf8"));
13556
+ const was = starterIdentity(readFileSync(path62.join(starterDir(), "starter.config.ts"), "utf8"));
12916
13557
  names = [was.name, was.slug, was.scheme, was.bundleId];
12917
13558
  } catch {
12918
13559
  names = [];
@@ -12928,9 +13569,9 @@ function checkSubstitutions(substitutions) {
12928
13569
  function lockfilesFor(root) {
12929
13570
  const top = gitTopLevel(root);
12930
13571
  const lockfiles = [];
12931
- for (let dir = realpathSync(root); ; dir = path30.dirname(dir)) {
12932
- for (const f of ["pnpm-lock.yaml", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock"]) if (existsSync(path30.join(dir, f))) lockfiles.push(path30.relative(realpathSync(root), path30.join(dir, f)));
12933
- if (lockfiles.length || dir === top || path30.dirname(dir) === dir) break;
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;
12934
13575
  }
12935
13576
  return lockfiles;
12936
13577
  }
@@ -12961,13 +13602,13 @@ function openPullRequest(root, version, report, base) {
12961
13602
  git4("switch", "-c", branch);
12962
13603
  const lockfiles = lockfilesFor(root);
12963
13604
  const ignoredLocks = gitIgnored(root, lockfiles);
12964
- const paths = [...report.files.filter((f) => existsSync(path30.join(root, f))), ...lockfiles.filter((f) => !ignoredLocks.includes(f))];
13605
+ const paths = [...report.files.filter((f) => existsSync(path62.join(root, f))), ...lockfiles.filter((f) => !ignoredLocks.includes(f))];
12965
13606
  git4("add", "--", ...paths);
12966
13607
  const overlayDirs = report.overlays.filter((o) => !o.skipped && !o.conflicts.length && (o.remove || [...o.writes.values()].includes(null))).map((o) => o.rel);
12967
13608
  if (overlayDirs.length) git4("add", "-A", "--", ...overlayDirs);
12968
13609
  git4("commit", "-q", "-m", `chore(deps): upgrade Genesis to ${version}`);
12969
13610
  git4("push", "-u", "origin", branch);
12970
- const body = path30.join(mkdtempSync(path30.join(tmpdir(), "genesis-pr-")), "body.md");
13611
+ const body = path62.join(mkdtempSync(path62.join(tmpdir(), "genesis-pr-")), "body.md");
12971
13612
  writeFileSync(body, `${report.summary}
12972
13613
 
12973
13614
  Opened by \`genesis upgrade --pr\`.
@@ -13002,8 +13643,8 @@ var init_upgrade = __esm({
13002
13643
  init_bun_lock();
13003
13644
  EXACT_OR_TAG = /^[0-9A-Za-z][0-9A-Za-z.+-]*$/;
13004
13645
  inside2 = (dir, file) => {
13005
- const rel = path30.relative(dir, file);
13006
- return rel === "" || rel.split(path30.sep)[0] !== ".." && !path30.isAbsolute(rel);
13646
+ const rel = path62.relative(dir, file);
13647
+ return rel === "" || rel.split(path62.sep)[0] !== ".." && !path62.isAbsolute(rel);
13007
13648
  };
13008
13649
  NOT_MATURE = "ERR_PNPM_NO_MATURE_MATCHING_VERSION";
13009
13650
  SUBSTITUTION_VALUE = /^[A-Za-z0-9][A-Za-z0-9 .+-]{0,59}$/;
@@ -13106,9 +13747,9 @@ async function runScaffold(opts, fs2) {
13106
13747
  function joinPath(...parts) {
13107
13748
  return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
13108
13749
  }
13109
- function dirname(path62) {
13110
- const idx = path62.lastIndexOf("/");
13111
- return idx === -1 ? "." : path62.slice(0, idx);
13750
+ function dirname(path63) {
13751
+ const idx = path63.lastIndexOf("/");
13752
+ return idx === -1 ? "." : path63.slice(0, idx);
13112
13753
  }
13113
13754
  function brandPackageJson(consumer, genesisVersion) {
13114
13755
  return JSON.stringify(
@@ -13347,7 +13988,7 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
13347
13988
  const { runInitNative: runInitNative2 } = await Promise.resolve().then(() => (init_init_native(), init_native_exports));
13348
13989
  const result2 = await runInitNative2({
13349
13990
  name: consumer,
13350
- target: path30.resolve(opts.target ?? consumer),
13991
+ target: path62.resolve(opts.target ?? consumer),
13351
13992
  ...opts.displayName ? { displayName: opts.displayName } : {},
13352
13993
  ...opts.bundleId ? { bundleId: opts.bundleId } : {},
13353
13994
  ...opts.scheme ? { scheme: opts.scheme } : {},
@@ -13361,7 +14002,7 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
13361
14002
  console.log(` Genesis packages: ${Object.entries(result2.dependencies).map(([n, v]) => `${n}@${v}`).join(", ")}`);
13362
14003
  console.log("");
13363
14004
  console.log("Next steps:");
13364
- [`cd ${path30.relative(process.cwd(), result2.target) || "."} && pnpm install (or your package manager)`, ...result2.steps].forEach((s, i) => console.log(` ${i + 1}. ${s}`));
14005
+ [`cd ${path62.relative(process.cwd(), result2.target) || "."} && pnpm install (or your package manager)`, ...result2.steps].forEach((s, i) => console.log(` ${i + 1}. ${s}`));
13365
14006
  return;
13366
14007
  }
13367
14008
  opts.target ??= process.cwd();
@@ -13446,7 +14087,7 @@ program.command("introspect").description("Write a checked-in contract (resource
13446
14087
  });
13447
14088
  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) => {
13448
14089
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
13449
- const root = path30.resolve(opts.dir);
14090
+ const root = path62.resolve(opts.dir);
13450
14091
  try {
13451
14092
  if (opts.printGenesis) {
13452
14093
  const { config } = doctor.loadConfig(root, opts.config);
@@ -13465,7 +14106,7 @@ program.command("doctor").description("Check this app against the installed Gene
13465
14106
  });
13466
14107
  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) => {
13467
14108
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
13468
- const packages = doctor.discoverPackages(path30.resolve(opts.dir));
14109
+ const packages = doctor.discoverPackages(path62.resolve(opts.dir));
13469
14110
  const rows = doctor.primitivesCatalog(packages);
13470
14111
  const broken = packages.filter((p) => p.error);
13471
14112
  if (opts.json) {
@@ -13480,7 +14121,7 @@ program.command("catalog").description("Print the Genesis catalog: for each need
13480
14121
  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) => {
13481
14122
  console.error("! `genesis primitives` is now `genesis catalog`; the old name works until the next major.");
13482
14123
  const doctor = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
13483
- const packages = doctor.discoverPackages(path30.resolve(opts.dir));
14124
+ const packages = doctor.discoverPackages(path62.resolve(opts.dir));
13484
14125
  const rows = doctor.primitivesCatalog(packages);
13485
14126
  const broken = packages.filter((p) => p.error);
13486
14127
  if (opts.json) {
@@ -13493,7 +14134,7 @@ program.command("primitives").description("Deprecated name of `genesis catalog`
13493
14134
  if (broken.length) process.exitCode = 1;
13494
14135
  });
13495
14136
  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) => {
13496
- const root = path30.resolve(opts.dir);
14137
+ const root = path62.resolve(opts.dir);
13497
14138
  if (opts.hook) {
13498
14139
  try {
13499
14140
  if (opts.hook === "subagent-start") {
@@ -13506,7 +14147,7 @@ program.command("agents").description(`Write the agent guide from the installed
13506
14147
  }
13507
14148
  if (opts.rules && opts.check) return program.error("--rules checks the repo, --check the agent guide: run them one at a time");
13508
14149
  if (opts.rules) {
13509
- if (!existsSync(path30.join(root, "packages")) && !existsSync(path30.join(root, ".github", "workflows"))) {
14150
+ if (!existsSync(path62.join(root, "packages")) && !existsSync(path62.join(root, ".github", "workflows"))) {
13510
14151
  return program.error(`--rules checks a repository: ${root} has no packages/ or .github/workflows/. Run it from the repo root or pass --dir.`);
13511
14152
  }
13512
14153
  const { checkAgentRules: checkAgentRules2 } = await Promise.resolve().then(() => (init_agent_rules(), agent_rules_exports));
@@ -13591,7 +14232,7 @@ featureOptions(
13591
14232
  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) => {
13592
14233
  const figma = await Promise.resolve().then(() => (init_routes2(), routes_exports));
13593
14234
  try {
13594
- const report = await figma.checkFigmaRoutes({ root: path30.resolve(opts.dir) });
14235
+ const report = await figma.checkFigmaRoutes({ root: path62.resolve(opts.dir) });
13595
14236
  console.log(opts.json ? JSON.stringify(report, null, 2) : figma.formatCoverage(report));
13596
14237
  process.exitCode = opts.strict && report.summary.missing > 0 ? 1 : 0;
13597
14238
  } catch (err) {
@@ -13603,7 +14244,7 @@ program.command("figma:routes").description("Report drift between this app's rou
13603
14244
  var upstream = program.command("upstream").description("The app's register of what it needed from Genesis (docs/genesis-upstream.md)");
13604
14245
  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) => {
13605
14246
  const { checkUpstream: checkUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
13606
- const result = checkUpstream2(path30.resolve(opts.dir));
14247
+ const result = checkUpstream2(path62.resolve(opts.dir));
13607
14248
  for (const w of result.warnings) console.warn(`! ${w}`);
13608
14249
  for (const p of result.problems) console.error(`\u2717 ${p}`);
13609
14250
  if (result.problems.length) process.exitCode = 1;
@@ -13611,7 +14252,7 @@ upstream.command("check").description("Check docs/genesis-upstream.md: kinds, st
13611
14252
  });
13612
14253
  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) => {
13613
14254
  const { checkUpstream: checkUpstream2, exportIssueUrl: exportIssueUrl2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
13614
- const register = checkUpstream2(path30.resolve(opts.dir));
14255
+ const register = checkUpstream2(path62.resolve(opts.dir));
13615
14256
  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).");
13616
14257
  const entry = register.entries.find((e) => e.id === id);
13617
14258
  if (!entry) return program.error(`No register entry "${id}" in ${register.file}.`);
@@ -13621,12 +14262,46 @@ ${own.map((p) => ` ${p}`).join("\n")}`);
13621
14262
  console.log(`Open this to file it (check it names no app or customer; Genesis is public), then set its status to proposed:
13622
14263
  ${exportIssueUrl2(entry)}`);
13623
14264
  });
14265
+ var client = program.command("client").description("The app's client layer: its own layer over Genesis (ADR 0020)");
14266
+ 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
+ const { planClientInit: planClientInit2, clientConfigChange: clientConfigChange2 } = await Promise.resolve().then(() => (init_init(), init_exports));
14268
+ const { readGenesisConfig: readGenesisConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
14269
+ const root = path62.resolve(opts.dir);
14270
+ const configured = readGenesisConfig2(root);
14271
+ const folder = opts.folder ?? configured?.client?.dir;
14272
+ let plan;
14273
+ let change;
14274
+ try {
14275
+ plan = planClientInit2({ ...folder ? { dir: folder } : {}, ...opts.type ? { type: opts.type } : {} });
14276
+ change = clientConfigChange2(plan.dir, configured?.client?.dir, opts.force);
14277
+ } catch (err) {
14278
+ return program.error(err.message);
14279
+ }
14280
+ for (const file of plan.files) {
14281
+ const target = path62.join(root, file.path);
14282
+ if (existsSync(target) && !opts.force) {
14283
+ console.log(`\xB7 ${file.path} (kept)`);
14284
+ continue;
14285
+ }
14286
+ await fs.mkdir(path62.dirname(target), { recursive: true });
14287
+ await fs.writeFile(target, file.content);
14288
+ console.log(`\u2714 ${file.path}`);
14289
+ }
14290
+ if (change === "write") {
14291
+ const configPath = path62.join(root, "genesis.config.json");
14292
+ const raw = configured?.raw ?? {};
14293
+ await fs.writeFile(configPath, `${JSON.stringify({ ...raw, client: { dir: plan.dir } }, null, 2)}
14294
+ `);
14295
+ console.log("\u2714 genesis.config.json (client.dir)");
14296
+ }
14297
+ for (const step of plan.steps) console.log(`\u2192 ${step}`);
14298
+ });
13624
14299
  var studio = program.command("studio").description("The Genesis Data Studio");
13625
14300
  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) => {
13626
- const { planStudioInit: planStudioInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
13627
- const root = path30.resolve(opts.dir);
13628
- const packageJson = JSON.parse(await fs.readFile(path30.join(root, "package.json"), "utf-8").catch(() => "{}"));
13629
- const existsSync46 = (await import('fs')).existsSync;
14301
+ 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(() => "{}"));
14304
+ const existsSync47 = (await import('fs')).existsSync;
13630
14305
  const readSync = (await import('fs')).readFileSync;
13631
14306
  const readdirSync21 = (await import('fs')).readdirSync;
13632
14307
  if (opts.host && !["next", "tanstack-start", "supabase-function"].includes(opts.host)) {
@@ -13635,13 +14310,13 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
13635
14310
  const plan = planStudioInit2(
13636
14311
  {
13637
14312
  packageJson,
13638
- exists: (p) => existsSync46(path30.join(root, p)),
13639
- read: (p) => existsSync46(path30.join(root, p)) ? readSync(path30.join(root, p), "utf-8") : null,
14313
+ exists: (p) => existsSync47(path62.join(root, p)),
14314
+ read: (p) => existsSync47(path62.join(root, p)) ? readSync(path62.join(root, p), "utf-8") : null,
13640
14315
  timestamp: (/* @__PURE__ */ new Date()).toISOString().replace(/\D/g, "").slice(0, 14),
13641
14316
  listDeep: (p) => {
13642
14317
  const out = [];
13643
14318
  const walk4 = (rel) => {
13644
- for (const entry of readdirSync21(path30.join(root, rel), { withFileTypes: true })) {
14319
+ for (const entry of readdirSync21(path62.join(root, rel), { withFileTypes: true })) {
13645
14320
  const child = `${rel}/${entry.name}`;
13646
14321
  if (entry.isDirectory()) walk4(child);
13647
14322
  else out.push(child);
@@ -13655,7 +14330,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
13655
14330
  },
13656
14331
  list: (p) => {
13657
14332
  try {
13658
- return readdirSync21(path30.join(root, p));
14333
+ return readdirSync21(path62.join(root, p));
13659
14334
  } catch {
13660
14335
  return [];
13661
14336
  }
@@ -13664,8 +14339,8 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
13664
14339
  { host: opts.host, route: opts.route, loginRole: opts.loginRole }
13665
14340
  );
13666
14341
  for (const file of plan.files) {
13667
- const target = path30.join(root, file.path);
13668
- await fs.mkdir(path30.dirname(target), { recursive: true });
14342
+ const target = path62.join(root, file.path);
14343
+ await fs.mkdir(path62.dirname(target), { recursive: true });
13669
14344
  if (file.edit) {
13670
14345
  await fs.writeFile(target, file.content, "utf-8");
13671
14346
  console.log(`~ ${file.path} (${file.edit})`);
@@ -13676,14 +14351,14 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
13676
14351
  console.log(`+ ${file.path} (appended)`);
13677
14352
  continue;
13678
14353
  }
13679
- if (existsSync46(target) && !opts.force) {
14354
+ if (existsSync47(target) && !opts.force) {
13680
14355
  console.log(`= ${file.path} exists; left as it is (--force to replace)`);
13681
14356
  continue;
13682
14357
  }
13683
14358
  await fs.writeFile(target, file.content, "utf-8");
13684
14359
  console.log(`+ ${file.path}`);
13685
14360
  }
13686
- const pm = existsSync46(path30.join(root, "pnpm-lock.yaml")) ? "pnpm add" : existsSync46(path30.join(root, "yarn.lock")) ? "yarn add" : existsSync46(path30.join(root, "bun.lock")) || existsSync46(path30.join(root, "bun.lockb")) ? "bun add" : "npm install";
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";
13687
14362
  console.log("");
13688
14363
  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:`);
13689
14364
  console.log(` 1. ${pm} ${plan.install.map((p) => /[\s<>|]/.test(p) ? `"${p}"` : p).join(" ")}`);
@@ -13701,7 +14376,7 @@ async function confirm(question) {
13701
14376
  }
13702
14377
  var logger = { info: (m) => console.log(m), warn: (m) => console.warn(`! ${m}`) };
13703
14378
  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) => {
13704
- const root = path30.resolve(opts.dir);
14379
+ const root = path62.resolve(opts.dir);
13705
14380
  if (opts.list || !block) {
13706
14381
  const { allBlocks: allBlocks2 } = await Promise.resolve().then(() => (init_discover(), discover_exports));
13707
14382
  const { readLock: readLock2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
@@ -13731,7 +14406,7 @@ program.command("migrate").description("Copy new package migrations of the app's
13731
14406
  const { runMigrate: runMigrate2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
13732
14407
  const { formatMigrationRows: formatMigrationRows2 } = await Promise.resolve().then(() => (init_migrations(), migrations_exports));
13733
14408
  const report = await runMigrate2({
13734
- root: path30.resolve(opts.dir),
14409
+ root: path62.resolve(opts.dir),
13735
14410
  ...opts.block ? { blocks: opts.block } : {},
13736
14411
  ...opts.notifications ? { notifications: opts.notifications } : {},
13737
14412
  dryRun: opts.dryRun,
@@ -13757,7 +14432,7 @@ program.command("migrate").description("Copy new package migrations of the app's
13757
14432
  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) => {
13758
14433
  const { runUpgrade: runUpgrade2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
13759
14434
  const report = await runUpgrade2({
13760
- root: path30.resolve(opts.dir),
14435
+ root: path62.resolve(opts.dir),
13761
14436
  version: opts.version,
13762
14437
  ...opts.manifest ? { manifest: opts.manifest } : {},
13763
14438
  dryRun: opts.dryRun,
@@ -13786,10 +14461,10 @@ program.command("codemod [id]").description("Run one of Genesis's codemods by ha
13786
14461
  }
13787
14462
  const mod = codemodById2(id);
13788
14463
  if (!mod) throw new Error(`No codemod "${id}". Run genesis codemod to list them.`);
13789
- const changed = await mod.run({ root: path30.resolve(opts.dir), dryRun: opts.dryRun, log: (m) => console.log(m) });
14464
+ const changed = await mod.run({ root: path62.resolve(opts.dir), dryRun: opts.dryRun, log: (m) => console.log(m) });
13790
14465
  console.log(changed.length ? `${opts.dryRun ? "Would change" : "\u2714 Changed"} ${changed.length} file${changed.length === 1 ? "" : "s"}:
13791
14466
  ${changed.map((f) => ` ${f}`).join("\n")}` : "Nothing to change.");
13792
- const note = codemodInstallNote2(path30.resolve(opts.dir), changed, opts.dryRun);
14467
+ const note = codemodInstallNote2(path62.resolve(opts.dir), changed, opts.dryRun);
13793
14468
  if (note) console.log(`! ${note}`);
13794
14469
  });
13795
14470
  program.parseAsync(process.argv).catch((err) => {
@@ -13839,7 +14514,7 @@ function redactUrl(location) {
13839
14514
  const url = new URL(location);
13840
14515
  return `${url.origin}${url.pathname}`;
13841
14516
  } catch {
13842
- return path30.basename(location);
14517
+ return path62.basename(location);
13843
14518
  }
13844
14519
  }
13845
14520
  //# sourceMappingURL=cli.js.map