@marktiderman/genesis-cli 1.26.0 → 1.27.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
@@ -2867,9 +2867,9 @@ function initNative(options) {
2867
2867
  }
2868
2868
  const shared = beside?.shared === true;
2869
2869
  const source = starterDir();
2870
- const read2 = (rel) => readFileSync(path30.join(source, rel), "utf8");
2871
- const was = starterIdentity(read2(STARTER_CONFIG));
2872
- const switches = parseStarterFeatures(read2(STARTER_CONFIG)) ?? {};
2870
+ const read3 = (rel) => readFileSync(path30.join(source, rel), "utf8");
2871
+ const was = starterIdentity(read3(STARTER_CONFIG));
2872
+ const switches = parseStarterFeatures(read3(STARTER_CONFIG)) ?? {};
2873
2873
  const without = [...new Set(options.without ?? [])];
2874
2874
  const unknown = without.filter((w) => !(w in switches));
2875
2875
  if (unknown.length) throw new Error(`--without: ${unknown.join(", ")} ${unknown.length > 1 ? "aren't" : "isn't"} a feature switch in ${STARTER_CONFIG} (${Object.keys(switches).join(", ")}).`);
@@ -2885,7 +2885,7 @@ function initNative(options) {
2885
2885
  const files = /* @__PURE__ */ new Map();
2886
2886
  for (const rel of walk(source, STARTER_EXCLUDE)) {
2887
2887
  const to = rel.replace(new RegExp(`(^|/)${PACKED_GITIGNORE}$`), "$1.gitignore");
2888
- files.set(to, /^supabase\/(migrations|tests)\//.test(rel) ? read2(rel) : substitute(read2(rel), substitutions));
2888
+ files.set(to, /^supabase\/(migrations|tests)\//.test(rel) ? read3(rel) : substitute(read3(rel), substitutions));
2889
2889
  }
2890
2890
  const versionFor = options.versionFor ?? ((name) => pinnedVersion2(target, name)?.version ?? null);
2891
2891
  const pkg = JSON.parse(files.get("package.json"));
@@ -2915,7 +2915,7 @@ function initNative(options) {
2915
2915
  files.set("README.md", readme(display, slug, shared ? beside.app : void 0));
2916
2916
  if (without.length) files.set(STARTER_CONFIG, setStarterFeatures(files.get(STARTER_CONFIG), Object.fromEntries(without.map((w) => [w, false]))));
2917
2917
  const carried = options.blocks.filter((b) => carriedBy(files, b)).map((b) => b.id);
2918
- const switchedOff = blocksSwitchedOff(features2, parseStarterBlocks(read2("genesis.config.json")) ?? {}, options.blocks, carried);
2918
+ const switchedOff = blocksSwitchedOff(features2, parseStarterBlocks(read3("genesis.config.json")) ?? {}, options.blocks, carried);
2919
2919
  const leftOut = options.blocks.filter((b) => switchedOff.has(b.id)).map((b) => b.id);
2920
2920
  if (leftOut.length) leaveOut(files, options.blocks.filter((b) => switchedOff.has(b.id)));
2921
2921
  if (shared) {
@@ -3362,8 +3362,11 @@ var init_model = __esm({
3362
3362
  });
3363
3363
 
3364
3364
  // src/introspect/postgres.ts
3365
- function where(sql, scope) {
3366
- return "schemas" in scope ? sql`n.nspname = any(${scope.schemas})` : sql`c.oid = any(${scope.oids}::oid[])`;
3365
+ function where(scope) {
3366
+ return "schemas" in scope ? { condition: "n.nspname = any(array(select jsonb_array_elements_text($1::text::jsonb)))", param: JSON.stringify(scope.schemas) } : { condition: "c.oid = any(array(select jsonb_array_elements_text($1::text::jsonb)::oid))", param: JSON.stringify(scope.oids) };
3367
+ }
3368
+ async function read(sql, text, param) {
3369
+ return [...await sql.unsafe(text, [param])];
3367
3370
  }
3368
3371
  function linkOf(columns, refColumns, refUnique = []) {
3369
3372
  if (columns.length === 1) return 0;
@@ -3372,7 +3375,8 @@ function linkOf(columns, refColumns, refUnique = []) {
3372
3375
  return own.length === 1 && refUnique[own[0]] === true ? own[0] : -1;
3373
3376
  }
3374
3377
  async function readRelations(sql, scope, into) {
3375
- const columns = await sql`
3378
+ const { condition, param } = where(scope);
3379
+ const columns = await read(sql, `
3376
3380
  select c.oid::text as oid, c.relkind::text as relkind, n.nspname as schema, c.relname as table,
3377
3381
  obj_description(c.oid, 'pg_class') as table_comment,
3378
3382
  a.attnum::int as attnum,
@@ -3391,17 +3395,17 @@ async function readRelations(sql, scope, into) {
3391
3395
  join pg_attribute a on a.attrelid = c.oid and a.attnum > 0 and not a.attisdropped
3392
3396
  join pg_type t on t.oid = a.atttypid
3393
3397
  where c.relkind in ('r', 'p', 'v', 'm', 'f')
3394
- and ${where(sql, scope)}
3395
- order by n.nspname, c.relname, a.attnum`;
3396
- const keys = await sql`
3398
+ and ${condition}
3399
+ order by n.nspname, c.relname, a.attnum`, param);
3400
+ const keys = await read(sql, `
3397
3401
  select c.oid::text as oid, array_agg(k.attnum::int order by k.ord) as columns
3398
3402
  from pg_constraint con
3399
3403
  join pg_class c on c.oid = con.conrelid
3400
3404
  join pg_namespace n on n.oid = c.relnamespace
3401
3405
  cross join lateral unnest(con.conkey) with ordinality as k(attnum, ord)
3402
- where con.contype = 'p' and ${where(sql, scope)}
3403
- group by c.oid`;
3404
- const links = await sql`
3406
+ where con.contype = 'p' and ${condition}
3407
+ group by c.oid`, param);
3408
+ const links = await read(sql, `
3405
3409
  select c.oid::text as oid, con.conkey::int[] as attnums,
3406
3410
  array(select a.attname::text from unnest(con.conkey) with ordinality k(attnum, ord)
3407
3411
  join pg_attribute a on a.attrelid = c.oid and a.attnum = k.attnum order by k.ord) as columns,
@@ -3418,9 +3422,9 @@ async function readRelations(sql, scope, into) {
3418
3422
  join pg_class rc on rc.oid = con.confrelid
3419
3423
  join pg_namespace rn on rn.oid = rc.relnamespace
3420
3424
  where con.contype = 'f'
3421
- and ${where(sql, scope)}
3422
- order by con.conname`;
3423
- const checks = await sql`
3425
+ and ${condition}
3426
+ order by con.conname`, param);
3427
+ const checks = await read(sql, `
3424
3428
  select c.oid::text as oid, con.conkey[1]::int as attnum, a.attname as column,
3425
3429
  pg_get_constraintdef(con.oid) as definition
3426
3430
  from pg_constraint con
@@ -3428,9 +3432,9 @@ async function readRelations(sql, scope, into) {
3428
3432
  join pg_namespace n on n.oid = c.relnamespace
3429
3433
  join pg_attribute a on a.attrelid = c.oid and a.attnum = con.conkey[1]
3430
3434
  where con.contype = 'c' and array_length(con.conkey, 1) = 1
3431
- and ${where(sql, scope)}
3432
- order by con.conname`;
3433
- const views = await sql`
3435
+ and ${condition}
3436
+ order by con.conname`, param);
3437
+ const views = await read(sql, `
3434
3438
  select c.oid::text as oid, r.ev_action::text as ev_action
3435
3439
  from pg_class c
3436
3440
  join pg_namespace n on n.oid = c.relnamespace
@@ -3438,7 +3442,7 @@ async function readRelations(sql, scope, into) {
3438
3442
  where c.relkind = 'v'
3439
3443
  and (pg_relation_is_updatable(c.oid, false) & 20) = 20
3440
3444
  and not exists (select 1 from pg_rewrite o where o.ev_class = c.oid and o.rulename <> '_RETURN')
3441
- and ${where(sql, scope)}`;
3445
+ and ${condition}`, param);
3442
3446
  const added = [];
3443
3447
  for (const row of columns) {
3444
3448
  let relation = into.get(row.oid);
@@ -3834,7 +3838,7 @@ function sourceSchemas(source) {
3834
3838
  const schemas = m?.[1].split(",").map((s) => s.trim()).filter(Boolean);
3835
3839
  return schemas?.length ? schemas : null;
3836
3840
  }
3837
- async function checkContracts(ctx, read2 = postgresContract) {
3841
+ async function checkContracts(ctx, read3 = postgresContract) {
3838
3842
  const settings2 = ctx.config.contracts;
3839
3843
  if (!settings2) return;
3840
3844
  const out = settings2.out ?? DEFAULT_CONTRACT_OUT;
@@ -3858,7 +3862,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
3858
3862
  }
3859
3863
  let expected;
3860
3864
  try {
3861
- expected = lf((await read2(url, schemas)).content);
3865
+ expected = lf((await read3(url, schemas)).content);
3862
3866
  } catch (err) {
3863
3867
  const generation = err.name === "EmitError";
3864
3868
  const message = err.message.split("\n")[0];
@@ -5165,7 +5169,7 @@ function createTrail(ctx) {
5165
5169
  declared = null;
5166
5170
  }
5167
5171
  const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
5168
- const read2 = (abs) => byPath.get(abs) ?? readSource(abs);
5172
+ const read3 = (abs) => byPath.get(abs) ?? readSource(abs);
5169
5173
  const importsCache = /* @__PURE__ */ new Map();
5170
5174
  const importsOf = (file) => {
5171
5175
  const hit = importsCache.get(file.absolutePath);
@@ -5242,7 +5246,7 @@ function createTrail(ctx) {
5242
5246
  cut.add(abs);
5243
5247
  continue;
5244
5248
  }
5245
- const target = read2(abs);
5249
+ const target = read3(abs);
5246
5250
  if (!target) {
5247
5251
  unknown = true;
5248
5252
  continue;
@@ -8695,7 +8699,7 @@ function packageGuides(root, packages) {
8695
8699
  const guides = [];
8696
8700
  for (const p of packages) {
8697
8701
  const stable = p.local ? path30.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
8698
- const text = stable === null ? null : read(stable);
8702
+ const text = stable === null ? null : read2(stable);
8699
8703
  if (stable === null || text === null) continue;
8700
8704
  const description = skillDescription(text);
8701
8705
  const at = description.indexOf("Load before");
@@ -8787,11 +8791,11 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
8787
8791
  const guides = packageGuides(root, packages);
8788
8792
  const changed = [];
8789
8793
  const agents = path30.join(root, agentsFile);
8790
- const before = read(agents);
8794
+ const before = read2(agents);
8791
8795
  const after = mergeAgentsBlock(before, renderAgentsBlock(rows, guides));
8792
8796
  const skill = path30.join(root, SKILL_PATH);
8793
8797
  const skillText = renderSkill(rows, guides);
8794
- if (read(skill)?.replace(/\r\n/g, "\n") !== skillText) {
8798
+ if (read2(skill)?.replace(/\r\n/g, "\n") !== skillText) {
8795
8799
  mkdirSync(path30.dirname(skill), { recursive: true });
8796
8800
  writeFileSync(skill, skillText);
8797
8801
  changed.push(SKILL_PATH);
@@ -8831,8 +8835,8 @@ function claudeState(root) {
8831
8835
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
8832
8836
  const rows = primitivesCatalog(packages);
8833
8837
  const guides = packageGuides(root, packages);
8834
- const skill = read(path30.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
8835
- const block = currentAgentsBlock(read(path30.join(root, agentsFile)));
8838
+ const skill = read2(path30.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
8839
+ const block = currentAgentsBlock(read2(path30.join(root, agentsFile)));
8836
8840
  return {
8837
8841
  skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
8838
8842
  agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
@@ -8869,12 +8873,12 @@ function checkAgentGuide(ctx) {
8869
8873
  ctx.report({ rule: "agent-guide-stale", level: "info", file: "AGENTS.md", message: `leaves out the guide of ${unlisted.join(", ")}: it's only inside pnpm's store, under a path that changes with unrelated bumps. Add the package as a direct dependency to list its guide.` });
8870
8874
  }
8871
8875
  }
8872
- var GENESIS_DOCS, read, CLAUDE_IMPORT, CORE, cell, importCell, SKILL_PATH, AGENTS_START, AGENTS_END, RULES, GUIDE_SEARCH_LEVELS, BLOCKED_FIX;
8876
+ var GENESIS_DOCS, read2, CLAUDE_IMPORT, CORE, cell, importCell, SKILL_PATH, AGENTS_START, AGENTS_END, RULES, GUIDE_SEARCH_LEVELS, BLOCKED_FIX;
8873
8877
  var init_primitives = __esm({
8874
8878
  "src/doctor/primitives.ts"() {
8875
8879
  init_package_rules();
8876
8880
  GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
8877
- read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
8881
+ read2 = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
8878
8882
  CLAUDE_IMPORT = "@AGENTS.md\n";
8879
8883
  CORE = [
8880
8884
  {
@@ -10574,7 +10578,7 @@ async function runFeaturesCheck(options) {
10574
10578
  }
10575
10579
  function readFeaturePackages(root) {
10576
10580
  const found = [];
10577
- const read2 = (dir, inRepo) => {
10581
+ const read3 = (dir, inRepo) => {
10578
10582
  const file = path30.join(dir, "package.json");
10579
10583
  if (!existsSync(file)) return;
10580
10584
  try {
@@ -10591,7 +10595,7 @@ function readFeaturePackages(root) {
10591
10595
  [path30.join(root, "node_modules", "@marktiderman"), false]
10592
10596
  ]) {
10593
10597
  if (!existsSync(base)) continue;
10594
- for (const name of readdirSync(base)) read2(path30.join(base, name), inRepo);
10598
+ for (const name of readdirSync(base)) read3(path30.join(base, name), inRepo);
10595
10599
  }
10596
10600
  return found;
10597
10601
  }
@@ -11132,7 +11136,7 @@ var init_init = __esm({
11132
11136
  "@tanstack/react-virtual@^3.14",
11133
11137
  "react-hook-form@^7",
11134
11138
  "zod@^4",
11135
- "@hookform/resolvers@>=5.1.0 <7"
11139
+ "@hookform/resolvers@>=5.1.0 <8"
11136
11140
  ];
11137
11141
  ROLE = /^[a-z_][a-z0-9_]{0,62}$/;
11138
11142
  LOVABLE_CLIENT = "src/integrations/supabase/client.ts";
@@ -11346,7 +11350,7 @@ function appDependencies(root) {
11346
11350
  }
11347
11351
  }
11348
11352
  function registryFile(root) {
11349
- const read2 = (file, key2) => {
11353
+ const read3 = (file, key2) => {
11350
11354
  try {
11351
11355
  const v = JSON.parse(readFileSync(path30.join(root, file), "utf8"))[key2]?.registry;
11352
11356
  return typeof v === "string" ? v : void 0;
@@ -11354,7 +11358,7 @@ function registryFile(root) {
11354
11358
  return void 0;
11355
11359
  }
11356
11360
  };
11357
- const named = read2("genesis.config.json", "features") ?? read2("package.json", "genesisFeatures");
11361
+ const named = read3("genesis.config.json", "features") ?? read3("package.json", "genesisFeatures");
11358
11362
  for (const candidate of named ? [named] : ["src/features.ts", "features.ts"]) if (existsSync(path30.join(root, candidate))) return candidate;
11359
11363
  return null;
11360
11364
  }