@marktiderman/genesis-cli 1.3.0 → 1.4.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/README.md CHANGED
@@ -59,6 +59,101 @@ Writes the marked feature block in `AGENTS.md` (and a JSON copy with `--json <fi
59
59
  repo's `src/features.ts`; `check` exits 1 when that output is stale or a feature's `links.code`
60
60
  path doesn't exist. See [genesis-features](../features/README.md) for the registry and the options.
61
61
 
62
+ ## Expo config plugin
63
+
64
+ `withGenesis()` keeps an Expo app's `app.config.ts` to a name, ids and plugins:
65
+
66
+ ```ts
67
+ // app.config.ts
68
+ import type { ExpoConfig } from "expo/config";
69
+
70
+ export default (): ExpoConfig => ({
71
+ name: "My App",
72
+ slug: "my-app",
73
+ scheme: "myapp",
74
+ ios: { bundleIdentifier: "com.example.myapp" },
75
+ android: { package: "com.example.myapp" },
76
+ plugins: ["expo-router", "@marktiderman/genesis-cli"],
77
+ });
78
+ ```
79
+
80
+ Install the CLI in the app (`pnpm add -D @marktiderman/genesis-cli`); Expo finds the plugin
81
+ through the package's `app.plugin.js`. To pass options, use `["@marktiderman/genesis-cli", { … }]`,
82
+ or call it yourself: `import { withGenesis } from "@marktiderman/genesis-cli/expo"`.
83
+
84
+ | Step | What it sets | Option to turn it off |
85
+ | --- | --- | --- |
86
+ | App variants | `APP_VARIANT` = `development` / `preview` / `production` (default) suffixes `ios.bundleIdentifier` and `android.package` with `.dev` / `.preview` and `name` with ` (Dev)` / ` (Preview)`, so the three install side by side. Any other value fails. A value that already ends in the suffix is left alone. Change the suffixes with `variants: { development: { id: ".debug", name: " (Debug)" } }`. | pass `variant: "production"` |
87
+ | Links | `ios.associatedDomains` (`applinks:` and, unless `links.webcredentials` is `false`, `webcredentials:` per host) and one Android `intentFilters` entry with `autoVerify`, from the `links` block of `genesis.config.json`. | `links: false` |
88
+ | Privacy manifest | `ios.privacyManifests.NSPrivacyAccessedAPITypes` for the packages in `dependencies`: `@react-native-async-storage/async-storage` needs FileTimestamp, reason `C617.1` (what its own `PrivacyInfo.xcprivacy` declares). | `privacyManifest: false` |
89
+ | Export compliance | `ios.config.usesNonExemptEncryption = false`. | `exportCompliance: false` |
90
+ | Runtime version | `runtimeVersion: { policy: "fingerprint" }`. | `fingerprint: false` |
91
+
92
+ The app's own values always win: the plugin fills gaps and appends to lists, merges privacy
93
+ reasons into an entry the app already declares, never overwrites or removes anything, and
94
+ running it twice changes nothing.
95
+
96
+ ### Setting APP_VARIANT
97
+
98
+ `APP_VARIANT` has to be the same wherever the config is evaluated for a build, not only in
99
+ `eas build`. `eas update` and EAS fingerprint checks evaluate the config too, and they don't read
100
+ the `env` of a build profile in `eas.json`. If an update is published without the variant, it is
101
+ built for the production ids and runtime, and preview and development builds never receive it.
102
+
103
+ Set it per EAS environment instead, so builds, updates and fingerprints all see it:
104
+
105
+ ```bash
106
+ eas env:create --environment preview --name APP_VARIANT --value preview --visibility plaintext
107
+ eas env:create --environment development --name APP_VARIANT --value development --visibility plaintext
108
+ ```
109
+
110
+ Point each build profile at its environment (`"preview": { "environment": "preview" }`), and
111
+ publish with `eas update --environment preview` (SDK 55 requires `--environment`). On SDK 54 or
112
+ earlier without EAS environments, set it on the command line every time:
113
+ `APP_VARIANT=preview eas update --branch preview`.
114
+
115
+ ### Links
116
+
117
+ The `links` block in `genesis.config.json` is validated by the same loader the doctor uses, so a
118
+ bad block fails `genesis doctor` too:
119
+
120
+ ```json
121
+ {
122
+ "links": { "hosts": ["example.com", "app.example.com"], "paths": ["/invite", "/c"], "webcredentials": true }
123
+ }
124
+ ```
125
+
126
+ `hosts` are bare lower-case host names (`*.example.com` allowed; no scheme, path or port);
127
+ `paths` are optional prefixes, each starting with `/`; `webcredentials` (default `true`) adds the
128
+ `webcredentials:` domains for password autofill. Set it to `false` if the site doesn't share
129
+ credentials with the app.
130
+
131
+ The web side has to list every variant you want links to open, because each variant is a
132
+ different app to Apple and Google:
133
+
134
+ - `/.well-known/apple-app-site-association`: one app id per variant, `TEAMID.com.example.myapp`,
135
+ `TEAMID.com.example.myapp.dev` and `TEAMID.com.example.myapp.preview`, under `applinks` (in
136
+ `details[].appIDs`) and, when `webcredentials` is on, under `webcredentials.apps`.
137
+ - `/.well-known/assetlinks.json`: one entry per package (`com.example.myapp`,
138
+ `com.example.myapp.dev`, `com.example.myapp.preview`), each with that build's own signing
139
+ certificate SHA-256 fingerprint (`eas credentials` shows it).
140
+
141
+ A variant the web files leave out installs fine, but its links open in the browser.
142
+
143
+ ### Determinism
144
+
145
+ The plugin reads exactly two committed files in the project root, `genesis.config.json` and
146
+ `package.json`, and one environment variable, `APP_VARIANT`. It makes no network calls and reads
147
+ no clock or other environment, so for a given commit and `APP_VARIANT` it always gives the same
148
+ config. That makes the EAS fingerprint (`runtimeVersion` policy `fingerprint`) stable only when
149
+ `APP_VARIANT` is set the same way in every place the config is evaluated: builds, `eas update` and
150
+ fingerprint checks (see [Setting APP_VARIANT](#setting-app_variant)). Keep the rest of the config
151
+ in committed files too.
152
+
153
+ `@expo/config-plugins` and `@expo/config-types` are optional peer dependencies used for types
154
+ only; the plugin bundles neither and has no runtime dependency on them. Node 20.19 or 22.12+ is
155
+ needed (Expo `require()`s `app.plugin.js`, which is an ES module).
156
+
62
157
  ## Settings in comments
63
158
 
64
159
  Put labels and widgets next to the schema, in table and column comments:
package/app.plugin.js ADDED
@@ -0,0 +1,4 @@
1
+ // The Expo config plugin: `plugins: ["@marktiderman/genesis-cli"]` in app.config.ts.
2
+ // Expo require()s this file; Node's require(esm) (Node 20.19+, 22.12+) loads it
3
+ // and Expo calls its default export. See README "Expo config plugin".
4
+ export { default } from "./dist/expo.js";
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { execFileSync, spawnSync } from 'child_process';
3
- import { existsSync, readFileSync, statSync, readdirSync } from 'fs';
3
+ import { readFileSync, existsSync, statSync, readdirSync } from 'fs';
4
4
  import * as path3 from 'path';
5
5
  import { createRequire } from 'module';
6
6
  import { pathToFileURL } from 'url';
@@ -390,7 +390,8 @@ function loadConfig(root, configPath) {
390
390
  }
391
391
  const own = path3.join(root, "genesis.config.json");
392
392
  if (existsSync(own)) {
393
- return { config: validateConfig(readJson(own)?.doctor ?? {}, own), file: own, dir: root };
393
+ const block = readGenesisConfig(root)?.raw.doctor;
394
+ return { config: validateConfig(block ?? {}, own), file: own, dir: root };
394
395
  }
395
396
  const pkg = path3.join(root, "package.json");
396
397
  if (existsSync(pkg)) {
@@ -406,6 +407,41 @@ function readJson(file) {
406
407
  throw new DoctorConfigError(`${file} is not valid JSON: ${err.message}`);
407
408
  }
408
409
  }
410
+ function readGenesisConfig(root) {
411
+ const file = path3.join(root, "genesis.config.json");
412
+ if (!existsSync(file)) return null;
413
+ const raw = readJson(file);
414
+ if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
415
+ const links = raw.links === void 0 ? void 0 : validateLinks(raw.links, file);
416
+ return links ? { raw, links } : { raw };
417
+ }
418
+ function validateLinks(raw, source = "config") {
419
+ const fail = (msg) => {
420
+ throw new GenesisConfigError(`${source}: ${msg}`);
421
+ };
422
+ if (!isObject(raw)) fail(`"links" must be an object`);
423
+ const c = raw;
424
+ for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting "${key}"`);
425
+ if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);
426
+ for (const host of c.hosts) {
427
+ if (!HOST.test(host)) {
428
+ fail(`links.hosts: "${host}" is not a bare lower-case host name (no scheme, path or port), e.g. "example.com"`);
429
+ }
430
+ }
431
+ if (c.paths !== void 0) {
432
+ if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);
433
+ for (const p of c.paths) {
434
+ if (!p.startsWith("/") || /[\s?#*]/.test(p)) {
435
+ fail(`links.paths: "${p}" must start with "/" and hold no spaces, "?", "#" or "*"`);
436
+ }
437
+ }
438
+ }
439
+ if (c.webcredentials !== void 0 && typeof c.webcredentials !== "boolean") fail(`links.webcredentials must be true or false`);
440
+ const links = { hosts: [...new Set(c.hosts)] };
441
+ if (c.paths !== void 0) links.paths = [...new Set(c.paths)];
442
+ if (c.webcredentials !== void 0) links.webcredentials = c.webcredentials;
443
+ return links;
444
+ }
409
445
  function validateConfig(raw, source = "config") {
410
446
  const fail = (msg) => {
411
447
  throw new DoctorConfigError(`${source}: ${msg}`);
@@ -484,10 +520,13 @@ function isObject(v) {
484
520
  function isStringList(v) {
485
521
  return Array.isArray(v) && v.every((x) => typeof x === "string");
486
522
  }
487
- var DoctorConfigError, STRING_LISTS, STRINGS, KNOWN, LEVELS, PATTERN_KEYS;
523
+ var GenesisConfigError, DoctorConfigError, STRING_LISTS, STRINGS, KNOWN, LEVELS, PATTERN_KEYS, LINK_KEYS, HOST;
488
524
  var init_config = __esm({
489
525
  "src/doctor/config.ts"() {
490
- DoctorConfigError = class extends Error {
526
+ GenesisConfigError = class extends Error {
527
+ name = "GenesisConfigError";
528
+ };
529
+ DoctorConfigError = class extends GenesisConfigError {
491
530
  name = "DoctorConfigError";
492
531
  };
493
532
  STRING_LISTS = ["src", "extensions", "ignore", "tokenFiles", "ignoreTokenPrefixes", "localPrimitiveDirs", "build"];
@@ -507,6 +546,8 @@ var init_config = __esm({
507
546
  ]);
508
547
  LEVELS = /* @__PURE__ */ new Set(["error", "warn", "off"]);
509
548
  PATTERN_KEYS = /* @__PURE__ */ new Set(["id", "level", "files", "exclude", "forbid", "require", "path", "message"]);
549
+ LINK_KEYS = /* @__PURE__ */ new Set(["hosts", "paths", "webcredentials"]);
550
+ HOST = /^(?=.{1,253}$)(\*\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
510
551
  }
511
552
  });
512
553
 
@@ -535,7 +576,7 @@ function globToRegExp(glob) {
535
576
  }
536
577
  function globMatcher(globs) {
537
578
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
538
- return (path11) => res.some((re) => re.test(path11));
579
+ return (path12) => res.some((re) => re.test(path12));
539
580
  }
540
581
  var init_glob = __esm({
541
582
  "src/doctor/glob.ts"() {
@@ -1264,7 +1305,8 @@ var init_rules = __esm({
1264
1305
  "arbitrary-color",
1265
1306
  "raw-color",
1266
1307
  "undefined-token",
1267
- "shadowed-export"
1308
+ "shadowed-export",
1309
+ "version-skew"
1268
1310
  ];
1269
1311
  DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
1270
1312
  STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
@@ -1275,12 +1317,43 @@ var init_rules = __esm({
1275
1317
  ARBITRARY_COLOR_RE = /(?<![\w-])[a-z][a-z-]*-\[(?:#|(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\()[^\]]*\]/g;
1276
1318
  }
1277
1319
  });
1320
+ function readReleaseManifest(root) {
1321
+ const dir = findPackageDir(root, UMBRELLA_PACKAGE);
1322
+ const file = dir && path3.join(dir, "dist", "versions.json");
1323
+ if (!file || !existsSync(file)) return null;
1324
+ return JSON.parse(readFileSync(file, "utf8"));
1325
+ }
1326
+ function checkVersionSkew(ctx) {
1327
+ const manifest = readReleaseManifest(ctx.root);
1328
+ if (!manifest) return;
1329
+ for (const [name, want] of Object.entries(manifest.packages)) {
1330
+ const dir = findPackageDir(ctx.root, name);
1331
+ if (!dir) continue;
1332
+ const have = JSON.parse(readFileSync(path3.join(dir, "package.json"), "utf8")).version;
1333
+ if (have === want) continue;
1334
+ ctx.report({
1335
+ rule: "version-skew",
1336
+ level: "warn",
1337
+ file: "package.json",
1338
+ subject: name,
1339
+ message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`
1340
+ });
1341
+ }
1342
+ }
1343
+ var UMBRELLA_PACKAGE;
1344
+ var init_versions = __esm({
1345
+ "src/doctor/versions.ts"() {
1346
+ init_genesis();
1347
+ UMBRELLA_PACKAGE = "@marktiderman/genesis";
1348
+ }
1349
+ });
1278
1350
 
1279
1351
  // src/doctor/index.ts
1280
1352
  var doctor_exports = {};
1281
1353
  __export(doctor_exports, {
1282
1354
  BUILTIN_RULES: () => BUILTIN_RULES,
1283
1355
  DoctorConfigError: () => DoctorConfigError,
1356
+ GenesisConfigError: () => GenesisConfigError,
1284
1357
  defineDoctorPlugin: () => defineDoctorPlugin,
1285
1358
  findPackageDir: () => findPackageDir,
1286
1359
  formatReport: () => formatReport,
@@ -1290,9 +1363,12 @@ __export(doctor_exports, {
1290
1363
  loadGenesis: () => loadGenesis,
1291
1364
  parseExportNames: () => parseExportNames,
1292
1365
  parseRulesMarkdown: () => parseRulesMarkdown,
1366
+ readGenesisConfig: () => readGenesisConfig,
1367
+ readReleaseManifest: () => readReleaseManifest,
1293
1368
  runDoctor: () => runDoctor,
1294
1369
  toJson: () => toJson,
1295
- validateConfig: () => validateConfig
1370
+ validateConfig: () => validateConfig,
1371
+ validateLinks: () => validateLinks
1296
1372
  });
1297
1373
  async function runDoctor(options = {}) {
1298
1374
  const root = path3.resolve(options.root ?? process.cwd());
@@ -1314,7 +1390,8 @@ async function runDoctor(options = {}) {
1314
1390
  { name: "raw-tags", check: checkRawTags },
1315
1391
  { name: "colors", check: checkColors },
1316
1392
  { name: "tokens", check: checkTokens },
1317
- { name: "shadowed-exports", check: checkShadowedExports }
1393
+ { name: "shadowed-exports", check: checkShadowedExports },
1394
+ { name: "version-skew", check: checkVersionSkew }
1318
1395
  ];
1319
1396
  for (const plugin of [...builtins, ...patterns ? [patterns.plugin] : [], ...plugins]) {
1320
1397
  try {
@@ -1420,12 +1497,14 @@ var init_doctor = __esm({
1420
1497
  init_plugins();
1421
1498
  init_rules();
1422
1499
  init_scan();
1500
+ init_versions();
1423
1501
  init_config();
1424
1502
  init_genesis();
1425
1503
  init_patterns();
1426
1504
  init_plugins();
1427
1505
  init_rules();
1428
1506
  init_glob();
1507
+ init_versions();
1429
1508
  }
1430
1509
  });
1431
1510
 
@@ -1442,15 +1521,19 @@ __export(features_exports, {
1442
1521
  function isObject2(value) {
1443
1522
  return typeof value === "object" && value !== null && !Array.isArray(value);
1444
1523
  }
1445
- function settings(root, options) {
1446
- let fromPackage = {};
1524
+ function readObject(file, key) {
1447
1525
  try {
1448
- const pkg = JSON.parse(readFileSync(path3.join(root, "package.json"), "utf-8"));
1449
- if (isObject2(pkg.genesisFeatures)) fromPackage = pkg.genesisFeatures;
1526
+ const json = JSON.parse(readFileSync(file, "utf-8"));
1527
+ return isObject2(json[key]) ? json[key] : {};
1450
1528
  } catch {
1529
+ return {};
1451
1530
  }
1531
+ }
1532
+ function settings(root, options) {
1533
+ const fromPackage = readObject(path3.join(root, "package.json"), "genesisFeatures");
1534
+ const fromConfig = readObject(path3.join(root, "genesis.config.json"), "features");
1452
1535
  const given = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== void 0));
1453
- return { ...fromPackage, ...given };
1536
+ return { ...fromPackage, ...fromConfig, ...given };
1454
1537
  }
1455
1538
  async function loadRegistry(input) {
1456
1539
  const root = path3.resolve(input.dir);
@@ -1520,12 +1603,18 @@ async function runFeaturesCheck(options) {
1520
1603
  }
1521
1604
  return { ...result, summary };
1522
1605
  }
1523
- async function runFeaturesFind(options, term) {
1606
+ async function runFeaturesFind(options, term, filters = {}) {
1524
1607
  const project = await loadRegistry(options);
1525
- return findFeatures(project.features, term, project.flags);
1608
+ return findFeatures(project.features, term, project.flags, filters);
1526
1609
  }
1527
1610
  function formatFeature(r) {
1528
- const lines = [`${r.id} \u2014 ${r.name} [${r.status}${r.horizon ? `, ${r.horizon}` : ""}] (${r.owner})`, ` ${r.summary}`];
1611
+ const kind = r.layer ? ` ${r.layer}` : "";
1612
+ const lines = [`${r.id} \u2014 ${r.name} [${r.status}${r.horizon ? `, ${r.horizon}` : ""}]${kind} (${r.owner})`, ` ${r.summary}`];
1613
+ if (r.platforms) lines.push(` platforms: ${Object.entries(r.platforms).map(([p, s]) => `${p} ${s}`).join(", ")}`);
1614
+ if (r.entry) lines.push(` import: ${Object.entries(r.entry).map(([p, e]) => `${e} (${p})`).join(", ")}`);
1615
+ if (r.extends) lines.push(` variant of: ${r.extends}`);
1616
+ if (r.slots?.length) lines.push(` slots: ${r.slots.join(", ")}`);
1617
+ if (r.requires?.length) lines.push(` requires: ${r.requires.join(", ")}`);
1529
1618
  if (r.links?.code?.length) lines.push(` code: ${r.links.code.join(", ")}`);
1530
1619
  if (r.flags.length) lines.push(` flags: ${r.flags.join(", ")}`);
1531
1620
  if (r.claimedBy) lines.push(` being built by ${r.claimedBy}`);
@@ -1965,16 +2054,12 @@ export type { Brand } from "./brand";
1965
2054
  },
1966
2055
  {
1967
2056
  path: `tailwind.config.ts`,
1968
- content: tailwindConfig(consumer)
2057
+ content: tailwindConfig(consumer, opts.native ?? false)
1969
2058
  },
1970
2059
  {
1971
2060
  path: `app/global.css`,
1972
2061
  content: globalCss()
1973
2062
  },
1974
- {
1975
- path: `.genesis/cli.yml`,
1976
- content: genesisConfig(consumer)
1977
- },
1978
2063
  {
1979
2064
  path: `CLAUDE.md`,
1980
2065
  content: claudeMd(consumer)
@@ -2024,9 +2109,9 @@ async function runScaffold(opts, fs2) {
2024
2109
  function joinPath(...parts) {
2025
2110
  return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
2026
2111
  }
2027
- function dirname(path11) {
2028
- const idx = path11.lastIndexOf("/");
2029
- return idx === -1 ? "." : path11.slice(0, idx);
2112
+ function dirname(path12) {
2113
+ const idx = path12.lastIndexOf("/");
2114
+ return idx === -1 ? "." : path12.slice(0, idx);
2030
2115
  }
2031
2116
  function brandPackageJson(consumer, genesisVersion) {
2032
2117
  return JSON.stringify(
@@ -2156,8 +2241,11 @@ export const brand: Brand = {
2156
2241
  };
2157
2242
  `;
2158
2243
  }
2159
- function tailwindConfig(consumer) {
2244
+ function tailwindConfig(consumer, native) {
2160
2245
  return `import type { Config } from "tailwindcss";
2246
+ import { genesisPreset } from "@marktiderman/genesis-design-system/presets/tailwind";${native ? `
2247
+ // NativeWind v4 needs its preset; Genesis's goes after it.
2248
+ import nativewindPreset from "nativewind/preset";` : ""}
2161
2249
  import { brand } from "@${consumer}/brand";
2162
2250
 
2163
2251
  /**
@@ -2173,9 +2261,9 @@ const config: Config = {
2173
2261
  content: [
2174
2262
  "./app/**/*.{ts,tsx}",
2175
2263
  "./components/**/*.{ts,tsx}",
2176
- "./node_modules/@marktiderman/genesis-ui-native/**/*.{js,ts,tsx}",
2177
- ],
2178
- presets: [require("@marktiderman/genesis-design-system/tailwind-preset")],
2264
+ ${native ? ` "./node_modules/@marktiderman/genesis-ui-native/**/*.{js,ts,tsx}",
2265
+ ` : ""} ],
2266
+ presets: [${native ? "nativewindPreset, " : ""}genesisPreset],
2179
2267
  theme: {
2180
2268
  extend: {
2181
2269
  colors: {
@@ -2197,47 +2285,16 @@ export default config;
2197
2285
  }
2198
2286
  function globalCss() {
2199
2287
  return `/**
2200
- * Genesis global stylesheet entry. Imports the canonical token sheet
2201
- * + the consumer's tailwind layers. The token sheet wires CSS variables
2202
- * (--color-primary, --color-foreground, etc.) used by every Genesis
2203
- * primitive's tailwind classes.
2288
+ * Genesis global stylesheet entry. Imports the Genesis theme (the CSS
2289
+ * variables every Genesis primitive's classes read: --background,
2290
+ * --foreground, --primary, \u2026) and the consumer's tailwind layers.
2204
2291
  */
2205
- @import "@marktiderman/genesis-design-system/tokens.css";
2292
+ @import "@marktiderman/genesis-design-system/themes/genesis.css";
2206
2293
  @tailwind base;
2207
2294
  @tailwind components;
2208
2295
  @tailwind utilities;
2209
2296
  `;
2210
2297
  }
2211
- function genesisConfig(consumer) {
2212
- return `# Genesis DESIGN-SYSTEM consumer pin \u2014 read by the genesis CLI + .claude/hooks/*
2213
- # NOT the harness config: the schema-validated harness/root config lives at
2214
- # genesis.config.yml (see genesis.config.example.yml). This file only pins the
2215
- # @marktiderman/genesis-* version + design-system rules for this consumer.
2216
- #
2217
- # version pin: which @marktiderman/genesis-* major are we on. The genesis CLI
2218
- # uses this to validate that an upgrade hasn't drifted past breaking-change
2219
- # boundaries.
2220
- version: "1"
2221
- consumer: "${consumer}"
2222
-
2223
- rules:
2224
- # Block raw hex in consumer code \u2014 must use brand tokens.
2225
- no-raw-hex: error
2226
- # Block StyleSheet.create() in NativeWind-first projects.
2227
- no-stylesheet-create: error
2228
- # Block fork-and-modify of Genesis primitives.
2229
- no-genesis-fork: error
2230
- # Layouts must compose Genesis primitives, not rebuild them.
2231
- prefer-genesis-layout: warn
2232
-
2233
- # Path map \u2014 where consumer composites + brand live. Default values match
2234
- # the scaffolder's output; adjust if your layout differs.
2235
- paths:
2236
- brand: "packages/${consumer}-brand"
2237
- composites: "components"
2238
- app: "app"
2239
- `;
2240
- }
2241
2298
  function claudeMd(consumer) {
2242
2299
  return `# CLAUDE.md \u2014 ${consumer}
2243
2300
 
@@ -2245,8 +2302,9 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
2245
2302
 
2246
2303
  ## Workflow
2247
2304
 
2248
- - **Reuse before extend, extend before create.** See the Genesis usage
2249
- doctrine: \`docs/prds/PRD-07-genesis-consumption-architecture/standards/usage-doctrine.md\`
2305
+ - **Reuse before extend, extend before create.** Before building anything,
2306
+ run \`npx @marktiderman/genesis-cli features find <term>\` and read
2307
+ https://github.com/marktiderman/genesis/blob/main/docs/FRAMEWORK.md
2250
2308
  - **Brand changes live in \`packages/${consumer}-brand\`.** Don't fork Genesis
2251
2309
  primitives \u2014 edit your brand schema instead (Layer 1).
2252
2310
  - **Layout customization has 4 layers.** Default \u2192 named props \u2192
@@ -2254,9 +2312,9 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
2254
2312
 
2255
2313
  ## Critical rules
2256
2314
 
2257
- - \`.genesis/cli.yml\` design-system rules are enforced via Claude Code hooks. Don't
2258
- bypass with \`StyleSheet.create()\` or raw hex; use brand tokens.
2259
- - Run \`pnpm test\` before every commit.
2315
+ - \`genesis doctor\` enforces the design-system rules. Don't bypass them with
2316
+ \`StyleSheet.create()\` or raw hex; use brand tokens and theme roles.
2317
+ - Run your test script before every commit.
2260
2318
  - Open RFCs in the genesis repo for missing primitives \u2014 don't fork
2261
2319
  locally and forget.
2262
2320
 
@@ -2267,12 +2325,19 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
2267
2325
  - \`app/global.css\` \u2014 Genesis token sheet + tailwind layers
2268
2326
  `;
2269
2327
  }
2328
+ function cliVersion() {
2329
+ try {
2330
+ return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
2331
+ } catch {
2332
+ return "unknown";
2333
+ }
2334
+ }
2270
2335
  var program = new Command();
2271
- program.name("genesis").description("Genesis CLI \u2014 scaffolders + workspace tooling").version("0.1.0");
2336
+ program.name("genesis").description("Genesis CLI \u2014 scaffolders + workspace tooling").version(cliVersion());
2272
2337
  program.command("init").description("Scaffold a new Genesis consumer (brand package + tailwind + tokens)").argument("<consumer>", "Consumer slug (lowercase, e.g., 'acme')").option("-t, --target <dir>", "Target directory (default: cwd)", process.cwd()).option(
2273
2338
  "--genesis-version <v>",
2274
2339
  "Pin @marktiderman/genesis-* version (default: 'workspace:^' for monorepo)"
2275
- ).option(
2340
+ ).option("--native", "An Expo app: add NativeWind's preset and scan genesis-ui-native", false).option(
2276
2341
  "--emit-conflicts",
2277
2342
  "Emit `.genesis-next` siblings for files that already exist (so you can diff)",
2278
2343
  false
@@ -2284,6 +2349,7 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
2284
2349
  targetDir: opts.target,
2285
2350
  genesisVersion: opts.genesisVersion,
2286
2351
  emitConflicts: opts.emitConflicts ?? false,
2352
+ native: opts.native ?? false,
2287
2353
  logger: {
2288
2354
  info: (msg) => console.log(msg),
2289
2355
  warn: (msg) => console.warn(msg),
@@ -2305,8 +2371,8 @@ program.command("init").description("Scaffold a new Genesis consumer (brand pack
2305
2371
  console.log("");
2306
2372
  console.log("Next steps:");
2307
2373
  console.log(` 1. Edit packages/${consumer}-brand/src/brand.ts with your colors`);
2308
- console.log(` 2. pnpm install`);
2309
- console.log(` 3. Read docs/prds/PRD-07-genesis-consumption-architecture/standards/usage-doctrine.md`);
2374
+ console.log(` 2. Install dependencies with your package manager`);
2375
+ console.log(` 3. Run genesis doctor, and read https://github.com/marktiderman/genesis/blob/main/docs/FRAMEWORK.md`);
2310
2376
  });
2311
2377
  program.command("introspect").description("Write a checked-in contract (resources.genesis.ts) from the Postgres catalog or a PostgREST/Supabase OpenAPI spec").option("--database-env <name>", "Environment variable holding the Postgres URL", "DATABASE_URL").option("--openapi <file-or-url>", "Read a PostgREST OpenAPI document (a Supabase project's /rest/v1/) instead of Postgres").option("--header <header...>", "HTTP header for --openapi URLs, for values that aren't secret (repeatable)").option("--apikey-env <name>", "Environment variable holding the API key for --openapi URLs (sent as apikey and Bearer)").option("-s, --schema <schemas>", "Comma-separated schemas", "public").option("-o, --out <file>", "Where to write the contract", "resources.genesis.ts").option("--check", "Write nothing; exit 1 if the contract on disk is out of date (for CI)", false).action(async (opts) => {
2312
2378
  const schemas = opts.schema.split(",").map((s) => s.trim()).filter(Boolean);
@@ -2364,13 +2430,13 @@ program.command("doctor").description("Check this app against the installed Gene
2364
2430
  console.log(opts.json ? JSON.stringify(doctor.toJson(result), null, 2) : doctor.formatReport(result));
2365
2431
  process.exitCode = result.ok ? 0 : 1;
2366
2432
  } catch (err) {
2367
- if (!(err instanceof doctor.DoctorConfigError)) throw err;
2433
+ if (!(err instanceof doctor.GenesisConfigError)) throw err;
2368
2434
  if (opts.json) console.log(JSON.stringify({ ok: false, error: err.message }, null, 2));
2369
2435
  else console.error(`\u2717 ${err.message}`);
2370
2436
  process.exitCode = 2;
2371
2437
  }
2372
2438
  });
2373
- var features = program.command("features").description('The feature registry: one typed features.ts, everything else generated from it. Settings: package.json "genesisFeatures"');
2439
+ var features = program.command("features").description('The feature registry: one typed features.ts, everything else generated from it. Settings: genesis.config.json "features" (or package.json "genesisFeatures")');
2374
2440
  function featureOptions(command) {
2375
2441
  return command.option("-d, --dir <dir>", "The repo root", process.cwd()).option("-r, --registry <file>", "The registry (default: src/features.ts, then features.ts)").option("--flags-file <file>", "A flags file exporting `flags` (default: the registry's own `flags` export)").option("--agents <file>", "The AGENTS.md that holds the pointer block (default AGENTS.md)").option("--json <file>", "The JSON copy, also the record of every id (default features.json)").option("--command <text>", "How people run this CLI here, named in generated files (default `genesis features`)");
2376
2442
  }
@@ -2394,19 +2460,33 @@ featureOptions(features.command("check").description("Errors fail (stale output,
2394
2460
  if (result.ok) console.log(`\u2714 The feature registry and the repo agree${result.warnings.length ? ` (${result.warnings.length} warning${result.warnings.length === 1 ? "" : "s"})` : ""}.`);
2395
2461
  process.exitCode = result.ok ? 0 : 1;
2396
2462
  });
2397
- featureOptions(features.command("find").description("Search features by id, alias, name, summary, flag or code path").argument("<term>", "What to look for")).action(
2398
- async (term, opts) => {
2399
- const { runFeaturesFind: runFeaturesFind2, formatFeature: formatFeature2 } = await Promise.resolve().then(() => (init_features(), features_exports));
2400
- const hits = await runFeaturesFind2(opts, term);
2401
- console.log(hits.length ? hits.map(formatFeature2).join("\n\n") : `No feature matches "${term}". If this is new work, add it to the registry first.`);
2402
- }
2403
- );
2463
+ featureOptions(
2464
+ features.command("find").description("Search features before building: reuse one, extend one, or add an idea first").argument("[term]", "What to look for (id, alias, name, keyword, summary, import, slot or code path)", "").option("--platform <platform>", "Only features on web, native, server or cli").option("--layer <layer>", "Only token, primitive, pattern, layout, hook, provider, block, service or tool").option("--status <status>", "Only idea, planned, building, beta, live, deprecated or retired")
2465
+ ).action(async (term, opts) => {
2466
+ const { FEATURE_LAYERS, FEATURE_PLATFORMS, FEATURE_STATUSES } = await import('@marktiderman/genesis-features');
2467
+ const { runFeaturesFind: runFeaturesFind2, formatFeature: formatFeature2 } = await Promise.resolve().then(() => (init_features(), features_exports));
2468
+ const pick = (name, value, allowed) => {
2469
+ if (value === void 0) return void 0;
2470
+ if (allowed.includes(value)) return value;
2471
+ return program.error(`--${name} must be one of ${allowed.join(", ")}`);
2472
+ };
2473
+ const { platform, layer, status, ...rest } = opts;
2474
+ const filters = {
2475
+ platform: pick("platform", platform, FEATURE_PLATFORMS),
2476
+ layer: pick("layer", layer, FEATURE_LAYERS),
2477
+ status: pick("status", status, FEATURE_STATUSES)
2478
+ };
2479
+ if (!term && !filters.platform && !filters.layer && !filters.status) program.error("Give a term, or --platform, --layer or --status");
2480
+ const hits = await runFeaturesFind2(rest, term, filters);
2481
+ const what = term ? `"${term}"` : "those filters";
2482
+ console.log(hits.length ? hits.map(formatFeature2).join("\n\n") : `No feature matches ${what}. If this is new work, add it to the registry first (an idea is enough).`);
2483
+ });
2404
2484
  var studio = program.command("studio").description("The Genesis Data Studio");
2405
2485
  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) => {
2406
2486
  const { planStudioInit: planStudioInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
2407
2487
  const root = path3.resolve(opts.dir);
2408
2488
  const packageJson = JSON.parse(await fs.readFile(path3.join(root, "package.json"), "utf-8").catch(() => "{}"));
2409
- const existsSync8 = (await import('fs')).existsSync;
2489
+ const existsSync9 = (await import('fs')).existsSync;
2410
2490
  const readSync = (await import('fs')).readFileSync;
2411
2491
  const readdirSync3 = (await import('fs')).readdirSync;
2412
2492
  if (opts.host && !["next", "tanstack-start", "supabase-function"].includes(opts.host)) {
@@ -2415,8 +2495,8 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
2415
2495
  const plan = planStudioInit2(
2416
2496
  {
2417
2497
  packageJson,
2418
- exists: (p) => existsSync8(path3.join(root, p)),
2419
- read: (p) => existsSync8(path3.join(root, p)) ? readSync(path3.join(root, p), "utf-8") : null,
2498
+ exists: (p) => existsSync9(path3.join(root, p)),
2499
+ read: (p) => existsSync9(path3.join(root, p)) ? readSync(path3.join(root, p), "utf-8") : null,
2420
2500
  timestamp: (/* @__PURE__ */ new Date()).toISOString().replace(/\D/g, "").slice(0, 14),
2421
2501
  listDeep: (p) => {
2422
2502
  const out = [];
@@ -2456,14 +2536,14 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
2456
2536
  console.log(`+ ${file.path} (appended)`);
2457
2537
  continue;
2458
2538
  }
2459
- if (existsSync8(target) && !opts.force) {
2539
+ if (existsSync9(target) && !opts.force) {
2460
2540
  console.log(`= ${file.path} exists; left as it is (--force to replace)`);
2461
2541
  continue;
2462
2542
  }
2463
2543
  await fs.writeFile(target, file.content, "utf-8");
2464
2544
  console.log(`+ ${file.path}`);
2465
2545
  }
2466
- const pm = existsSync8(path3.join(root, "pnpm-lock.yaml")) ? "pnpm add" : existsSync8(path3.join(root, "yarn.lock")) ? "yarn add" : existsSync8(path3.join(root, "bun.lock")) || existsSync8(path3.join(root, "bun.lockb")) ? "bun add" : "npm install";
2546
+ const pm = existsSync9(path3.join(root, "pnpm-lock.yaml")) ? "pnpm add" : existsSync9(path3.join(root, "yarn.lock")) ? "yarn add" : existsSync9(path3.join(root, "bun.lock")) || existsSync9(path3.join(root, "bun.lockb")) ? "bun add" : "npm install";
2467
2547
  console.log("");
2468
2548
  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:`);
2469
2549
  console.log(` 1. ${pm} ${plan.install.join(" ")}`);