@marktiderman/genesis-cli 1.23.0 → 1.24.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/index.js CHANGED
@@ -821,9 +821,9 @@ async function runScaffold(opts, fs) {
821
821
  function joinPath(...parts) {
822
822
  return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
823
823
  }
824
- function dirname(path48) {
825
- const idx = path48.lastIndexOf("/");
826
- return idx === -1 ? "." : path48.slice(0, idx);
824
+ function dirname(path49) {
825
+ const idx = path49.lastIndexOf("/");
826
+ return idx === -1 ? "." : path49.slice(0, idx);
827
827
  }
828
828
  function brandPackageJson(consumer, genesisVersion) {
829
829
  return JSON.stringify(
@@ -1081,8 +1081,8 @@ function routeTags(source) {
1081
1081
  var GUARD = /<((?:[A-Z]\w*)?(?:Admin|Staff)\w*(?:Guard|Route|Only)|RequireAdmin|RequireStaff)>/;
1082
1082
  function wireStudioRoute(source, route, pageImportPath) {
1083
1083
  const tags = routeTags(source);
1084
- const relative13 = route.replace(/^\//, "");
1085
- const existing = tags.find((t) => new RegExp(`path=["'](/?${relative13.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
1084
+ const relative14 = route.replace(/^\//, "");
1085
+ const existing = tags.find((t) => new RegExp(`path=["'](/?${relative14.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
1086
1086
  if (existing) {
1087
1087
  return { skipped: `Your router already has a page at ${route}. Replace its element with <DataStudioPage /> to use the studio there.` };
1088
1088
  }
@@ -1090,17 +1090,17 @@ function wireStudioRoute(source, route, pageImportPath) {
1090
1090
  const roots = layouts.length ? layouts : tags.filter((t) => !t.selfClosing && t.close !== void 0 && /path=["']\/["']/.test(t.text));
1091
1091
  if (roots.length !== 1) {
1092
1092
  return {
1093
- skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative13}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
1093
+ skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative14}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
1094
1094
  };
1095
1095
  }
1096
1096
  const layout = roots[0];
1097
1097
  const base = (/\bpath=["']([^"']*)["']/.exec(layout.text)?.[1] ?? "").replace(/^\/+|\/+$/g, "");
1098
- if (base && !relative13.startsWith(`${base}/`)) {
1098
+ if (base && !relative14.startsWith(`${base}/`)) {
1099
1099
  return {
1100
1100
  skipped: `Your layout route lives at /${base}, outside ${route}. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.`
1101
1101
  };
1102
1102
  }
1103
- const childPath = base ? relative13.slice(base.length + 1) : relative13;
1103
+ const childPath = base ? relative14.slice(base.length + 1) : relative14;
1104
1104
  const guard = GUARD.exec(source)?.[1];
1105
1105
  const element = guard ? `<${guard}><DataStudioPage /></${guard}>` : "<DataStudioPage />";
1106
1106
  const before = source.slice(0, layout.close);
@@ -1505,6 +1505,25 @@ var PRIVACY_PURPOSES = {
1505
1505
  "third-party advertising": "NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising",
1506
1506
  other: "NSPrivacyCollectedDataTypePurposeOther"
1507
1507
  };
1508
+ var ENVIRONMENT_KEYS = /* @__PURE__ */ new Set(["previews", "label", "branchPrefix", "$comment"]);
1509
+ function validateEnvironments(raw, source = "config") {
1510
+ const fail = (msg) => {
1511
+ throw new GenesisConfigError(`${source}: ${msg}`);
1512
+ };
1513
+ if (!isObject(raw)) return fail(`"environments" must be an object`);
1514
+ for (const key2 of Object.keys(raw)) if (!ENVIRONMENT_KEYS.has(key2)) fail(`environments: unknown setting "${key2}" (known: previews, label, branchPrefix)`);
1515
+ const out = {};
1516
+ if (raw.previews !== void 0) {
1517
+ if (raw.previews !== "on-demand" && raw.previews !== "every-pr" && raw.previews !== "off") fail(`environments.previews must be "on-demand", "every-pr" or "off" (got ${JSON.stringify(raw.previews)})`);
1518
+ out.previews = raw.previews;
1519
+ }
1520
+ for (const key2 of ["label", "branchPrefix"]) {
1521
+ if (raw[key2] === void 0) continue;
1522
+ if (typeof raw[key2] !== "string") fail(`environments.${key2} must be a string ("" turns that check off)`);
1523
+ out[key2] = raw[key2];
1524
+ }
1525
+ return out;
1526
+ }
1508
1527
  var STRING_LISTS = ["src", "extensions", "ignore", "tokenFiles", "ignoreTokenPrefixes", "localPrimitiveDirs", "build", "componentPackages"];
1509
1528
  var STRINGS = ["uiPackage", "rulesDoc"];
1510
1529
  var KNOWN = /* @__PURE__ */ new Set([
@@ -1536,7 +1555,7 @@ var CONTRACT_KEYS = /* @__PURE__ */ new Set(["out", "schemas", "databaseEnv"]);
1536
1555
  var PACKS = /* @__PURE__ */ new Set(["native", "supabase", "packages"]);
1537
1556
  var PACK_KEYS = {
1538
1557
  native: { routerRoot: "path" },
1539
- supabase: { migrations: "path", base: "string", exposedSchemas: "list", since: "string" },
1558
+ supabase: { migrations: "path", base: "string", exposedSchemas: "list", since: "string", automaticBranching: "boolean" },
1540
1559
  packages: { base: "string" }
1541
1560
  };
1542
1561
  function appPath(v, where2, fail) {
@@ -1597,6 +1616,7 @@ function readGenesisConfig(root) {
1597
1616
  if (supabase !== true) out.supabase = supabase;
1598
1617
  }
1599
1618
  if (raw.appFolder !== void 0) out.appFolder = validateAppFolder(raw.appFolder, file);
1619
+ if (raw.environments !== void 0) out.environments = validateEnvironments(raw.environments, file);
1600
1620
  return out;
1601
1621
  }
1602
1622
  var PLAIN_FOLDER = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,59}(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,59}){0,7}$/;
@@ -1795,6 +1815,7 @@ function validateConfig(raw, source = "config") {
1795
1815
  if (!want) fail(`${pack}: unknown setting "${k}"`);
1796
1816
  if (want === "string" && typeof v !== "string") fail(`${pack}.${k} must be a string`);
1797
1817
  if (want === "list" && !isStringList(v)) fail(`${pack}.${k} must be a list of strings`);
1818
+ if (want === "boolean" && typeof v !== "boolean") fail(`${pack}.${k} must be true or false`);
1798
1819
  if (want === "string" && !v.trim()) fail(`${pack}.${k} must not be empty`);
1799
1820
  if (want === "path") block[k] = appPath(v, `${pack}.${k}`, fail);
1800
1821
  }
@@ -1846,7 +1867,7 @@ function globToRegExp(glob) {
1846
1867
  }
1847
1868
  function globMatcher(globs) {
1848
1869
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
1849
- return (path48) => res.some((re) => re.test(path48));
1870
+ return (path49) => res.some((re) => re.test(path49));
1850
1871
  }
1851
1872
  var GENESIS_PACKAGE = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
1852
1873
  var BLOCK_ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
@@ -3402,6 +3423,7 @@ var BUILTIN_RULES = [
3402
3423
  "migration-edited",
3403
3424
  "migration-testing-kit",
3404
3425
  "migration-view-rls",
3426
+ "exposed-schema-created-later",
3405
3427
  // packages pack
3406
3428
  "package-app-import",
3407
3429
  "package-undeclared-dependency",
@@ -5545,6 +5567,67 @@ function checkSupabasePack(ctx) {
5545
5567
  checkViewInvoker(ctx, migrations, exposed);
5546
5568
  checkDefinerSearchPath(ctx, migrations);
5547
5569
  checkTestingKit(ctx, migrations);
5570
+ checkExposedSchemasCreatedLater(ctx, dir, migrations, settings.exposedSchemas, settings.automaticBranching !== false);
5571
+ }
5572
+ var PLATFORM_SCHEMAS = /* @__PURE__ */ new Set(["public", "graphql_public", "graphql", "extensions", "storage", "auth", "realtime", "vault"]);
5573
+ function apiSchemas(toml) {
5574
+ const lines = toml.split("\n");
5575
+ const start = lines.findIndex((l) => /^\s*\[api\]\s*(?:#.*)?$/.test(l));
5576
+ if (start < 0) return null;
5577
+ let end = lines.findIndex((l, i) => i > start && /^\s*\[/.test(l));
5578
+ if (end < 0) end = lines.length;
5579
+ const bare = (l) => {
5580
+ let quoted = false;
5581
+ for (let i = 0; i < l.length; i++) {
5582
+ if (l[i] === '"' && l[i - 1] !== "\\") quoted = !quoted;
5583
+ else if (l[i] === "#" && !quoted) return l.slice(0, i);
5584
+ }
5585
+ return l;
5586
+ };
5587
+ const body = lines.slice(start + 1, end).map(bare);
5588
+ const enabled = !body.some((l) => /^\s*enabled\s*=\s*false\b/.test(l));
5589
+ const at = body.findIndex((l) => /^\s*schemas\s*=/.test(l));
5590
+ if (at < 0) return { enabled, schemas: [], line: start + 1 };
5591
+ let list = "";
5592
+ for (let i = at; i < body.length; i++) {
5593
+ list += `${body[i]}
5594
+ `;
5595
+ if (body[i].includes("]")) break;
5596
+ }
5597
+ const inner = /\[([\s\S]*?)\]/.exec(list)?.[1] ?? "";
5598
+ const schemas = [...inner.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)].map((m) => (m[1] ?? m[2]).trim().toLowerCase()).filter(Boolean);
5599
+ return { enabled, schemas, line: start + at + 2 };
5600
+ }
5601
+ function checkExposedSchemasCreatedLater(ctx, dir, migrations, configured, branching) {
5602
+ const created = /* @__PURE__ */ new Map();
5603
+ for (const { file, statements } of migrations) {
5604
+ for (const { sql, line } of statements) {
5605
+ const m = /^create schema (?:if not exists )?"?([\w$]+)"?/.exec(sql);
5606
+ if (m && m[1] !== "authorization" && !created.has(m[1])) created.set(m[1], { file, line });
5607
+ }
5608
+ }
5609
+ const tomlFile = path21.posix.join(path21.posix.dirname(dir), "config.toml");
5610
+ const tomlText = existsSync(path21.join(ctx.root, tomlFile)) ? readFileSync(path21.join(ctx.root, tomlFile), "utf8") : null;
5611
+ const api2 = tomlText === null ? null : apiSchemas(tomlText);
5612
+ const sources = [];
5613
+ if (api2?.enabled) for (const schema of api2.schemas) sources.push({ schema, file: tomlFile, line: api2.line, where: `${tomlFile} [api] schemas` });
5614
+ for (const schema of api2?.enabled === false ? [] : configured ?? []) {
5615
+ const s = schema.toLowerCase();
5616
+ if (!sources.some((x) => x.schema === s)) sources.push({ schema: s, file: "genesis.config.json", where: "doctor.supabase.exposedSchemas" });
5617
+ }
5618
+ for (const { schema, file, line, where: where2 } of sources) {
5619
+ if (PLATFORM_SCHEMAS.has(schema)) continue;
5620
+ const by = created.get(schema);
5621
+ if (by && !branching) continue;
5622
+ ctx.report({
5623
+ rule: "exposed-schema-created-later",
5624
+ level: "warn",
5625
+ file,
5626
+ ...line ? { line } : {},
5627
+ subject: schema,
5628
+ message: by ? `${where2} exposes ${schema}, which only a migration creates (${by.file}:${by.line}); a Supabase branch points its Data API at ${schema} before it runs migrations, so a fresh preview branch fails its health check. Turn off Supabase's automatic branching (Genesis docs/APP-CI.md, "Previews"), then set doctor.supabase.automaticBranching to false` : `${where2} exposes ${schema}, which no migration creates, so a database built from the migrations can't serve it (a Supabase branch fails its health check); create it in a migration or stop exposing it`
5629
+ });
5630
+ }
5548
5631
  }
5549
5632
  function checkTestingKit(ctx, migrations) {
5550
5633
  for (const { file, statements } of migrations) {
@@ -6795,6 +6878,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
6795
6878
  }
6796
6879
  }
6797
6880
  var GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
6881
+ var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
6798
6882
  var CORE = [
6799
6883
  {
6800
6884
  need: "anything, before building it",
@@ -6867,14 +6951,79 @@ var SKILL_PATH = ".claude/skills/genesis/SKILL.md";
6867
6951
  var AGENTS_START = "<!-- genesis-primitives:start -->";
6868
6952
  var AGENTS_END = "<!-- genesis-primitives:end -->";
6869
6953
  var RULES = [
6870
- "Use the Genesis primitive for the need first: reuse, then extend, then invent (docs/FRAMEWORK.md, G1 to G6).",
6954
+ `Use the Genesis primitive for the need first: reuse, then extend, then invent (G1 to G6 in ${GENESIS_DOCS}/FRAMEWORK.md).`,
6871
6955
  "Never copy an older screen as a template. Old screens predate the primitives; the doctor flags what they did.",
6872
6956
  "A list screen is a view (`defineView`) rendered by `ResourceView`; a record view is `RecordView`; on the phone, `NativeResourceView`.",
6873
6957
  "Screens never call the database client (`supabase.from`, `.rpc`) directly: reads go through a view or a named data function, writes through the resource's provider rules.",
6874
6958
  "When no primitive fits, write the gap up for Genesis before inventing, then invent in the app on Genesis primitives.",
6875
6959
  "Run `genesis doctor` before you finish; it enforces these rules."
6876
6960
  ];
6877
- function renderSkill(rows) {
6961
+ function skillDescription(text) {
6962
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1];
6963
+ if (!fm) return "";
6964
+ const lines = fm.split(/\r?\n/);
6965
+ const i = lines.findIndex((l) => /^description:/.test(l));
6966
+ if (i < 0) return "";
6967
+ const first = lines[i].replace(/^description:\s*/, "").trim();
6968
+ if (first && !/^[>|][+-]?$/.test(first)) return first.replace(/^["']|["']$/g, "");
6969
+ const more = [];
6970
+ for (const l of lines.slice(i + 1)) {
6971
+ if (!/^\s+\S/.test(l)) break;
6972
+ more.push(l.trim());
6973
+ }
6974
+ return more.join(" ");
6975
+ }
6976
+ var GUIDE_SEARCH_LEVELS = 4;
6977
+ function stableGuidePath(root, p) {
6978
+ const real2 = (f) => {
6979
+ try {
6980
+ return realpathSync(f);
6981
+ } catch {
6982
+ return null;
6983
+ }
6984
+ };
6985
+ const want = real2(p.dir);
6986
+ for (let dir = root, level = 0; level <= GUIDE_SEARCH_LEVELS; level++) {
6987
+ const found = path21.join(dir, "node_modules", p.name);
6988
+ if (existsSync(found)) {
6989
+ const file = path21.join(found, "SKILL.md");
6990
+ return want !== null && real2(found) === want && existsSync(file) ? file : null;
6991
+ }
6992
+ if (existsSync(path21.join(dir, ".git")) || existsSync(path21.join(dir, "pnpm-workspace.yaml"))) return null;
6993
+ const up = path21.dirname(dir);
6994
+ if (up === dir) return null;
6995
+ dir = up;
6996
+ }
6997
+ return null;
6998
+ }
6999
+ function packageGuides(root, packages) {
7000
+ const guides = [];
7001
+ for (const p of packages) {
7002
+ const stable = p.local ? path21.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
7003
+ const text = stable === null ? null : read(stable);
7004
+ if (stable === null || text === null) continue;
7005
+ const description = skillDescription(text);
7006
+ const at = description.indexOf("Load before");
7007
+ guides.push({ package: p.name, path: path21.relative(root, stable).split(path21.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
7008
+ }
7009
+ return guides.sort((a, b) => a.package.localeCompare(b.package));
7010
+ }
7011
+ function unlistedGuides(root, packages) {
7012
+ const listed = new Set(packageGuides(root, packages).map((g) => g.package));
7013
+ return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path21.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
7014
+ }
7015
+ function guidesSection(guides) {
7016
+ if (!guides.length) return [];
7017
+ return [
7018
+ "### Package guides (they match the installed versions)",
7019
+ "",
7020
+ "Before using a package's primitives, read its guide:",
7021
+ "",
7022
+ ...guides.map((g) => `- \`${g.path}\` (${g.package}): ${g.when}`),
7023
+ ""
7024
+ ];
7025
+ }
7026
+ function renderSkill(rows, guides = []) {
6878
7027
  return [
6879
7028
  "---",
6880
7029
  "name: genesis",
@@ -6887,6 +7036,7 @@ function renderSkill(rows) {
6887
7036
  "",
6888
7037
  ...RULES.map((r) => `- ${r}`),
6889
7038
  "",
7039
+ ...guidesSection(guides),
6890
7040
  "## What to use for each need",
6891
7041
  "",
6892
7042
  catalogTable(rows, { docs: true }),
@@ -6895,7 +7045,7 @@ function renderSkill(rows) {
6895
7045
  ""
6896
7046
  ].join("\n");
6897
7047
  }
6898
- function renderAgentsBlock(rows) {
7048
+ function renderAgentsBlock(rows, guides = []) {
6899
7049
  return [
6900
7050
  AGENTS_START,
6901
7051
  "## Building with Genesis",
@@ -6906,6 +7056,7 @@ function renderAgentsBlock(rows) {
6906
7056
  "",
6907
7057
  ...RULES.map((r) => `- ${r}`),
6908
7058
  "",
7059
+ ...guidesSection(guides),
6909
7060
  catalogTable(rows),
6910
7061
  AGENTS_END
6911
7062
  ].join("\n");
@@ -6924,14 +7075,37 @@ function currentAgentsBlock(agents) {
6924
7075
  if (span === "broken") return "broken";
6925
7076
  return agents.slice(span.start, span.end).replace(/\r\n/g, "\n");
6926
7077
  }
6927
- var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
7078
+ function claudeState(root) {
7079
+ const file = path21.join(root, "CLAUDE.md");
7080
+ let names = [];
7081
+ try {
7082
+ names = readdirSync(root);
7083
+ } catch {
7084
+ }
7085
+ if (!names.includes("CLAUDE.md")) return names.some((n) => n.toLowerCase() === "claude.md") ? "blocked" : "missing";
7086
+ let text;
7087
+ try {
7088
+ text = readFileSync(file, "utf8");
7089
+ } catch {
7090
+ return "blocked";
7091
+ }
7092
+ if (/^@AGENTS\.md\b/m.test(text)) return "ok";
7093
+ try {
7094
+ if (realpathSync(file) === realpathSync(path21.join(root, "AGENTS.md"))) return "ok";
7095
+ } catch {
7096
+ }
7097
+ return "no-import";
7098
+ }
6928
7099
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
6929
7100
  const rows = primitivesCatalog(packages);
7101
+ const guides = packageGuides(root, packages);
6930
7102
  const skill = read(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
6931
7103
  const block = currentAgentsBlock(read(path21.join(root, agentsFile)));
6932
7104
  return {
6933
- skill: skill === null ? "missing" : skill === renderSkill(rows) ? "ok" : "stale",
6934
- agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows) ? "ok" : "stale"
7105
+ skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
7106
+ agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
7107
+ // Only the default AGENTS.md gets a CLAUDE.md written for it, so only then is a missing one reported.
7108
+ claude: agentsFile !== "AGENTS.md" ? "ok" : claudeState(root)
6935
7109
  };
6936
7110
  }
6937
7111
  function checkAgentGuide(ctx) {
@@ -6949,6 +7123,41 @@ function checkAgentGuide(ctx) {
6949
7123
  }[state.agents];
6950
7124
  ctx.report({ rule: "agent-guide-stale", level: "warn", file: "AGENTS.md", message });
6951
7125
  }
7126
+ if (state.claude === "no-import") {
7127
+ ctx.report({ rule: "agent-guide-stale", level: "info", file: "CLAUDE.md", message: "doesn't import AGENTS.md (`@AGENTS.md`), so reviewers and cloud project threads that read only CLAUDE.md don't see the Genesis guide" });
7128
+ }
7129
+ if (state.claude === "missing") {
7130
+ ctx.report({ rule: "agent-guide-stale", level: "warn", file: "CLAUDE.md", message: `is missing, so reviewers and cloud project threads that read only CLAUDE.md never see AGENTS.md; ${fix} (it writes \`@AGENTS.md\`)` });
7131
+ }
7132
+ if (state.claude === "blocked") {
7133
+ ctx.report({ rule: "agent-guide-stale", level: "warn", file: "CLAUDE.md", message: `can't be read: something else is in its place (another case of the name such as claude.md, a dangling link, a folder or an unreadable file), and genesis agents won't write over it; ${BLOCKED_FIX}` });
7134
+ }
7135
+ const unlisted = unlistedGuides(ctx.root, ctx.packages);
7136
+ if (unlisted.length) {
7137
+ 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.` });
7138
+ }
7139
+ }
7140
+ var BLOCKED_FIX = "rename or replace it with a CLAUDE.md file (or remove the dangling link), then run genesis agents";
7141
+ var SETTINGS_PATH = ".claude/settings.json";
7142
+ var SUBAGENT_HOOK_COMMAND = '"$CLAUDE_PROJECT_DIR"/node_modules/.bin/genesis agents --hook subagent-start --dir "$CLAUDE_PROJECT_DIR" 2>/dev/null || true';
7143
+ var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
7144
+ var isGenesisHook = (h) => typeof h.command === "string" && h.command.includes("genesis agents --hook");
7145
+ function agentHooksState(root) {
7146
+ let settings;
7147
+ try {
7148
+ settings = JSON.parse(readFileSync(path21.join(root, SETTINGS_PATH), "utf8"));
7149
+ } catch {
7150
+ return "none";
7151
+ }
7152
+ const start = isObject4(settings) && isObject4(settings.hooks) ? settings.hooks["SubagentStart"] : void 0;
7153
+ const commands = (Array.isArray(start) ? start : []).flatMap((e) => isObject4(e) && Array.isArray(e.hooks) ? e.hooks : []).filter((h) => isObject4(h) && isGenesisHook(h)).map((h) => h.command);
7154
+ if (!commands.length) return "none";
7155
+ return commands.every((c) => c === SUBAGENT_HOOK_COMMAND) ? "ok" : "stale";
7156
+ }
7157
+ function checkAgentHooks(ctx) {
7158
+ if (agentHooksState(ctx.root) === "stale") {
7159
+ ctx.report({ rule: "agent-guide-stale", level: "warn", file: SETTINGS_PATH, message: "has an older Genesis SubagentStart hook command; run genesis agents --hooks and commit the result" });
7160
+ }
6952
7161
  }
6953
7162
 
6954
7163
  // src/blocks/templates.ts
@@ -7875,7 +8084,10 @@ function builtinChecks(config, options = {}) {
7875
8084
  { name: "studio-server-imports", check: checkStudioServerImports },
7876
8085
  { name: "removed-scope-names", check: checkRemovedScopeNames },
7877
8086
  { name: "stability-imports", check: checkStabilityImports },
7878
- { name: "agent-guide", check: checkAgentGuide },
8087
+ { name: "agent-guide", check: (ctx) => {
8088
+ checkAgentGuide(ctx);
8089
+ checkAgentHooks(ctx);
8090
+ } },
7879
8091
  { name: "overlays", check: (ctx) => checkOverlays(ctx) },
7880
8092
  { name: "lock-files", check: checkLockFiles },
7881
8093
  { name: "database-elsewhere", check: checkDatabaseHome },