@marktiderman/genesis-cli 1.6.0 → 1.7.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.
Files changed (139) hide show
  1. package/README.md +156 -1
  2. package/dist/cli.js +2769 -567
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-CUdwT-nY.d.ts → config-CrZbM3jD.d.ts} +45 -2
  5. package/dist/doctor.d.ts +2 -2
  6. package/dist/doctor.js +133 -5
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +91 -8
  9. package/dist/expo.js +207 -14
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +502 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +140 -9
  14. package/dist/index.js.map +1 -1
  15. package/dist/scaffolder.d.ts +1 -1
  16. package/dist/scaffolder.js +7 -4
  17. package/dist/scaffolder.js.map +1 -1
  18. package/dist/starter/.eas/scripts/rollout-health.mjs +85 -0
  19. package/dist/starter/.eas/workflows/deploy-production.yml +149 -0
  20. package/dist/starter/.eas/workflows/e2e.yml +77 -0
  21. package/dist/starter/.eas/workflows/pr-preview.yml +117 -0
  22. package/dist/starter/.eas/workflows/rollout.yml +120 -0
  23. package/dist/starter/.env.example +11 -0
  24. package/dist/starter/.fingerprintignore +7 -0
  25. package/dist/starter/.maestro/README.md +38 -0
  26. package/dist/starter/.maestro/config.yaml +5 -0
  27. package/dist/starter/.maestro/flows/deep-link.yaml +22 -0
  28. package/dist/starter/.maestro/flows/launch.yaml +17 -0
  29. package/dist/starter/.maestro/flows/settings-version.yaml +28 -0
  30. package/dist/starter/.maestro/flows/sign-in-screen.yaml +17 -0
  31. package/dist/starter/.maestro/subflows/sign-in.yaml +20 -0
  32. package/dist/starter/README.md +314 -0
  33. package/dist/starter/__tests__/app-config.test.ts +51 -0
  34. package/dist/starter/__tests__/check-in-photos.test.ts +57 -0
  35. package/dist/starter/__tests__/components/css-stub.js +2 -0
  36. package/dist/starter/__tests__/components/fake-supabase.ts +136 -0
  37. package/dist/starter/__tests__/components/links.test.ts +25 -0
  38. package/dist/starter/__tests__/components/render-app.ts +22 -0
  39. package/dist/starter/__tests__/components/reports.ts +10 -0
  40. package/dist/starter/__tests__/components/resolver.js +12 -0
  41. package/dist/starter/__tests__/components/root-layout.test.tsx +55 -0
  42. package/dist/starter/__tests__/components/session-storage.test.tsx +81 -0
  43. package/dist/starter/__tests__/components/settings.test.tsx +134 -0
  44. package/dist/starter/__tests__/components/setup.ts +69 -0
  45. package/dist/starter/__tests__/components/sign-in.test.tsx +90 -0
  46. package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +19 -0
  47. package/dist/starter/__tests__/components/tabs.test.tsx +43 -0
  48. package/dist/starter/__tests__/components/tabs.ts +12 -0
  49. package/dist/starter/__tests__/entry.test.ts +28 -0
  50. package/dist/starter/__tests__/inline-copy.ts +59 -0
  51. package/dist/starter/__tests__/starter.test.ts +319 -0
  52. package/dist/starter/_gitignore +13 -0
  53. package/dist/starter/app.config.ts +44 -0
  54. package/dist/starter/babel.config.js +9 -0
  55. package/dist/starter/eas.json +47 -0
  56. package/dist/starter/eslint.config.js +5 -0
  57. package/dist/starter/genesis.config.json +12 -0
  58. package/dist/starter/global.css +3 -0
  59. package/dist/starter/index.ts +14 -0
  60. package/dist/starter/jest.config.js +36 -0
  61. package/dist/starter/metro.config.js +38 -0
  62. package/dist/starter/package.json +93 -0
  63. package/dist/starter/pnpm-workspace.yaml +73 -0
  64. package/dist/starter/src/app/(app)/(home)/_layout.tsx +6 -0
  65. package/dist/starter/src/app/(app)/(home)/check-in.tsx +41 -0
  66. package/dist/starter/src/app/(app)/(home)/index.tsx +34 -0
  67. package/dist/starter/src/app/(app)/_layout.tsx +27 -0
  68. package/dist/starter/src/app/(app)/notifications/_layout.tsx +6 -0
  69. package/dist/starter/src/app/(app)/notifications/index.tsx +36 -0
  70. package/dist/starter/src/app/(app)/settings/_layout.tsx +6 -0
  71. package/dist/starter/src/app/(app)/settings/index.tsx +96 -0
  72. package/dist/starter/src/app/(app)/settings/notifications.tsx +16 -0
  73. package/dist/starter/src/app/(app)/settings/support/[id].tsx +23 -0
  74. package/dist/starter/src/app/(app)/settings/support/ideas.tsx +20 -0
  75. package/dist/starter/src/app/(app)/settings/support/index.tsx +20 -0
  76. package/dist/starter/src/app/(app)/settings/support/new.tsx +35 -0
  77. package/dist/starter/src/app/(app)/settings/support/shipped.tsx +20 -0
  78. package/dist/starter/src/app/+native-intent.ts +11 -0
  79. package/dist/starter/src/app/_layout.tsx +20 -0
  80. package/dist/starter/src/app/sign-in.tsx +69 -0
  81. package/dist/starter/src/copy.ts +118 -0
  82. package/dist/starter/src/forms/check-in.json +121 -0
  83. package/dist/starter/src/lib/account.ts +42 -0
  84. package/dist/starter/src/lib/app.ts +52 -0
  85. package/dist/starter/src/lib/auth.ts +80 -0
  86. package/dist/starter/src/lib/check-in-photos.ts +66 -0
  87. package/dist/starter/src/lib/check-in.ts +85 -0
  88. package/dist/starter/src/lib/define-starter.ts +148 -0
  89. package/dist/starter/src/lib/devtools-overlay.ts +34 -0
  90. package/dist/starter/src/lib/devtools.ts +23 -0
  91. package/dist/starter/src/lib/env.ts +33 -0
  92. package/dist/starter/src/lib/google-signin.ts +23 -0
  93. package/dist/starter/src/lib/links.ts +40 -0
  94. package/dist/starter/src/lib/native-modules.ts +27 -0
  95. package/dist/starter/src/lib/notifications.ts +15 -0
  96. package/dist/starter/src/lib/observability.ts +45 -0
  97. package/dist/starter/src/lib/push.ts +49 -0
  98. package/dist/starter/src/lib/supabase.ts +65 -0
  99. package/dist/starter/src/lib/support.ts +44 -0
  100. package/dist/starter/src/lib/updates.ts +61 -0
  101. package/dist/starter/starter.config.ts +37 -0
  102. package/dist/starter/supabase/config.toml +26 -0
  103. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +237 -0
  104. package/dist/starter/supabase/functions/genesis-apple-revoke/handler.ts +227 -0
  105. package/dist/starter/supabase/functions/genesis-apple-revoke/index.ts +55 -0
  106. package/dist/starter/supabase/functions/genesis-push-send/expo.ts +117 -0
  107. package/dist/starter/supabase/functions/genesis-push-send/handler.ts +462 -0
  108. package/dist/starter/supabase/functions/genesis-push-send/index.ts +54 -0
  109. package/dist/starter/supabase/migrations/20261024000000_genesis_account_deletion.sql +133 -0
  110. package/dist/starter/supabase/migrations/20261024000100_genesis_app_release_policy.sql +82 -0
  111. package/dist/starter/supabase/migrations/20261024000200_genesis_apple_token_revocation.sql +205 -0
  112. package/dist/starter/supabase/migrations/20261024000400_genesis_push.sql +524 -0
  113. package/dist/starter/supabase/migrations/20261024000600_genesis_support.sql +846 -0
  114. package/dist/starter/supabase/tests/database/genesis_account_deletion.test.sql +138 -0
  115. package/dist/starter/supabase/tests/database/genesis_app_release_policy.test.sql +148 -0
  116. package/dist/starter/supabase/tests/database/genesis_apple_token_revocation.test.sql +230 -0
  117. package/dist/starter/supabase/tests/database/genesis_push.test.sql +407 -0
  118. package/dist/starter/supabase/tests/database/genesis_support.test.sql +552 -0
  119. package/dist/starter/tailwind.config.mjs +15 -0
  120. package/dist/starter/tsconfig.json +14 -0
  121. package/dist/starter/vitest.config.mts +7 -0
  122. package/dist/templates/ci/app-ci.yml +17 -0
  123. package/dist/templates/ci/genesis-upgrade.yml +21 -0
  124. package/dist/templates/ci/supabase-ci.yml +20 -0
  125. package/dist/templates/eas/eas.json +47 -0
  126. package/dist/templates/eas/scripts/rollout-health.mjs +85 -0
  127. package/dist/templates/eas/workflows/deploy-production.yml +149 -0
  128. package/dist/templates/eas/workflows/e2e.yml +77 -0
  129. package/dist/templates/eas/workflows/pr-preview.yml +117 -0
  130. package/dist/templates/eas/workflows/rollout.yml +120 -0
  131. package/dist/templates/maestro/config.yaml +5 -0
  132. package/dist/templates/maestro/flows/deep-link.yaml +22 -0
  133. package/dist/templates/maestro/flows/launch.yaml +17 -0
  134. package/dist/templates/maestro/flows/settings-version.yaml +28 -0
  135. package/dist/templates/maestro/flows/sign-in-screen.yaml +17 -0
  136. package/dist/templates/maestro/subflows/sign-in.yaml +20 -0
  137. package/dist/vite.js +133 -5
  138. package/dist/vite.js.map +1 -1
  139. package/package.json +4 -4
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/doctor/build.ts","../src/doctor/config.ts","../src/doctor/glob.ts","../src/doctor/genesis.ts","../../../scripts/lib/color-literals.mjs","../src/doctor/scan.ts","../src/doctor/patterns.ts","../src/doctor/plugins.ts","../src/doctor/rules.ts","../../../scripts/lib/native-primitives.mjs","../src/expo.ts","../src/doctor/native.ts","../src/doctor/supabase.ts","../src/doctor/versions.ts","../src/doctor/index.ts","../src/vite.ts"],"names":["path","path2","existsSync","readFileSync","path4","statSync","readdirSync","path5","path6","createRequire","path7","dependencies","SCRIPT_EXTS","JSX_EXTS","path9","spawnSync","path10","path11","path12","path13"],"mappings":";;;;;;;AASO,IAAM,eAAA,GAAkB,yBAAA;AAGxB,SAAS,aAAA,CAAc,MAAc,MAAA,EAAgC;AAC1E,EAAA,IAAI,MAAA,CAAO,KAAA,EAAO,OAAO,MAAA,CAAO,KAAA;AAChC,EAAA,MAAM,OAAA,GAAeA,KAAA,CAAA,IAAA,CAAK,IAAA,EAAM,cAAc,CAAA;AAC9C,EAAA,MAAM,OAAA,GAAkC,UAAA,CAAW,OAAO,CAAA,GAAI,KAAK,KAAA,CAAM,YAAA,CAAa,OAAA,EAAS,MAAM,CAAC,CAAA,CAAE,OAAA,IAAW,KAAK,EAAC;AACzH,EAAA,MAAM,EAAA,GAAK,eAAe,IAAI,CAAA;AAC9B,EAAA,OAAO,CAAC,WAAA,EAAa,OAAO,EAAE,MAAA,CAAO,CAAC,MAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA,KAAM,GAAG,EAAE,CAAA,KAAA,EAAQ,CAAC,CAAA,CAAE,CAAA;AACrF;AAEO,SAAS,eAAe,IAAA,EAAsB;AACnD,EAAA,IAAI,GAAA,GAAWA,c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AAe,CAAA,EAAG;AAAA,UAC7D;AACA,UAAA,YAAA,CAAa,KAAK,CAAA;AAClB,UAAA,KAAA,GAAQ,WAAW,MAAM,KAAK,OAAM,EAAG,OAAA,CAAQ,cAAc,GAAG,CAAA;AAAA,QAClE,CAAA;AACA,QAAA,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;AAChC,QAAA,MAAA,CAAO,OAAA,CAAQ,EAAA,CAAG,QAAA,EAAU,QAAQ,CAAA;AACpC,QAAA,MAAA,CAAO,OAAA,CAAQ,EAAA,CAAG,KAAA,EAAO,QAAQ,CAAA;AACjC,QAAA,MAAA,CAAO,OAAA,CAAQ,EAAA,CAAG,QAAA,EAAU,QAAQ,CAAA;AACpC,QAAA,MAAA,CAAO,EAAA,CAAG,EAAA,CAAG,YAAA,EAAc,MAAM;AAC/B,UAAA,IAAI,WAAW,MAAA,CAAO,EAAA,CAAG,IAAA,CAAK,EAAE,MAAM,OAAA,EAAS,GAAA,EAAK,EAAE,OAAA,EAAS,WAAW,KAAA,EAAO,EAAA,EAAI,MAAA,EAAQ,gBAAA,IAAoB,CAAA;AAAA,QACnH,CAAC,CAAA;AACD,QAAA,MAAA,CAAO,YAAY,IAAA,CAAK,WAAA,EAAa,MAAM,KAAK,OAAO,CAAA;AACvD,QAAA,IAAI,CAAC,MAAA,CAAO,UAAA,EAAY,KAAK,KAAA,EAAM;AAAA,MACrC;AAAA;AACF,GACF;AACF","file":"vite.js","sourcesContent":["/**\n * `genesis doctor --build`: run the app's typecheck and build after the checks.\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { DoctorConfig, FindingInput } from \"./types.js\";\n\n/** Set for build children, so a build that itself runs `genesis doctor --build` doesn't recurse. */\nexport const BUILD_GUARD_ENV = \"GENESIS_DOCTOR_BUILDING\";\n\n/** The commands `--build` runs: config `build`, else the app's `typecheck` and `build` scripts. */\nexport function buildCommands(root: string, config: DoctorConfig): string[] {\n if (config.build) return config.build;\n const pkgFile = path.join(root, \"package.json\");\n const scripts: Record<string, string> = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, \"utf8\")).scripts ?? {} : {};\n const pm = packageManager(root);\n return [\"typecheck\", \"build\"].filter((s) => scripts[s]).map((s) => `${pm} run ${s}`);\n}\n\nexport function packageManager(root: string): string {\n let dir = path.resolve(root);\n for (;;) {\n if (existsSync(path.join(dir, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(path.join(dir, \"bun.lock\")) || existsSync(path.join(dir, \"bun.lockb\"))) return \"bun\";\n if (existsSync(path.join(dir, \"yarn.lock\"))) return \"yarn\";\n if (existsSync(path.join(dir, \"package-lock.json\"))) return \"npm\";\n const parent = path.dirname(dir);\n if (parent === dir) return \"npm\";\n dir = parent;\n }\n}\n\n/** Run each command in order; stop at the first failure and return it as a finding. */\nexport function runBuild(root: string, commands: string[], quiet: boolean): FindingInput | null {\n if (process.env[BUILD_GUARD_ENV]) return null;\n if (commands.length === 0) {\n return { rule: \"build\", level: \"warn\", file: \"package.json\", message: \"--build found nothing to run: add typecheck/build scripts or doctor.build\" };\n }\n for (const command of commands) {\n // Commands come from the app's own config or package.json, so a shell is fine.\n const r = spawnSync(command, {\n cwd: root,\n shell: true,\n stdio: quiet ? \"pipe\" : \"inherit\",\n env: { ...process.env, [BUILD_GUARD_ENV]: \"1\" },\n });\n if (r.status !== 0) {\n const tail = quiet ? `\\n${String(r.stderr ?? \"\").trim().split(\"\\n\").slice(-20).join(\"\\n\")}` : \"\";\n return { rule: \"build\", file: command, message: `\\`${command}\\` failed (exit ${r.status ?? r.signal})${tail}` };\n }\n }\n return null;\n}\n","/**\n * Finds and validates the app's genesis.config.json.\n *\n * The doctor's lookup order: `--config <path>`, then `genesis.config.json`\n * in the app root, then the `genesis` key of package.json. Either file holds\n * the settings under `doctor`, beside other blocks: `features` (read by\n * `genesis features`) and `links` (validated here, read by the Expo config\n * plugin).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { DoctorConfig } from \"./types.js\";\n\n/** A genesis.config.json that can't be read or has a block of the wrong shape. */\nexport class GenesisConfigError extends Error {\n override name = \"GenesisConfigError\";\n}\n\nexport class DoctorConfigError extends GenesisConfigError {\n override name = \"DoctorConfigError\";\n}\n\n/** The `links` block: the web hosts (and optional path prefixes) the app opens as universal / app links. */\nexport interface GenesisLinks {\n /** Bare host names, such as `example.com` or `app.example.com`: no scheme, path or port. */\n hosts: string[];\n /** Path prefixes the app handles, each starting with `/`. Default: every path. */\n paths?: string[];\n /** Also add `webcredentials:` domains (password autofill). Default true. */\n webcredentials?: boolean;\n}\n\n/** genesis.config.json, parsed, with its shared blocks validated. */\nexport interface GenesisConfigFile {\n /** The whole parsed file, for blocks other readers own (`doctor`, `features`). */\n raw: Record<string, unknown>;\n links?: GenesisLinks;\n}\n\nexport interface LoadedConfig {\n config: DoctorConfig;\n /** The file it came from, or null when no config exists (defaults apply). */\n file: string | null;\n /** Folder that relative plugin paths resolve against. */\n dir: string;\n}\n\nconst STRING_LISTS = [\"src\", \"extensions\", \"ignore\", \"tokenFiles\", \"ignoreTokenPrefixes\", \"localPrimitiveDirs\", \"build\"] as const;\nconst STRINGS = [\"uiPackage\", \"rulesDoc\"] as const;\nconst KNOWN = new Set<string>([\n ...STRING_LISTS,\n ...STRINGS,\n \"themeCss\",\n \"rawTags\",\n \"forbiddenImports\",\n \"rules\",\n \"allow\",\n \"patterns\",\n \"plugins\",\n \"packs\",\n \"native\",\n \"supabase\",\n \"$schema\",\n \"$comment\",\n]);\nconst LEVELS = new Set([\"error\", \"warn\", \"off\"]);\nconst PATTERN_KEYS = new Set([\"id\", \"level\", \"files\", \"exclude\", \"forbid\", \"require\", \"path\", \"message\"]);\nconst PACKS = new Set([\"native\", \"supabase\"]);\n/** Each pack's settings: key → \"string\", \"path\" (app-relative folder, normalized) or \"list\". */\nconst PACK_KEYS: Record<string, Record<string, \"string\" | \"path\" | \"list\">> = {\n native: { routerRoot: \"path\" },\n supabase: { migrations: \"path\", base: \"string\", exposedSchemas: \"list\", since: \"string\" },\n};\n\n/** An app-relative folder in POSIX form (`./app/` → `app`); absolute paths and paths leaving the app are rejected. */\nfunction appPath(v: unknown, where: string, fail: (msg: string) => never): string {\n if (typeof v !== \"string\" || !v.trim()) return fail(`${where} must be a non-empty path`);\n if (path.isAbsolute(v) || /^[A-Za-z]:[\\\\/]/.test(v)) fail(`${where} must be relative to the app, not absolute (\"${v}\")`);\n const norm = path.posix.normalize(v.replace(/\\\\/g, \"/\")).replace(/\\/+$/, \"\");\n if (norm === \".\" || norm === \"..\" || norm.startsWith(\"../\")) fail(`${where} must be a folder inside the app (\"${v}\")`);\n return norm;\n}\n\nexport function loadConfig(root: string, configPath?: string): LoadedConfig {\n if (configPath) {\n const file = path.resolve(root, configPath);\n if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);\n const json = readJson(file);\n // An explicit file may hold the block at the top level or under `doctor`\n // (or, for a package.json, under `genesis.doctor`).\n const block = path.basename(file) === \"package.json\" ? json?.genesis?.doctor : json?.doctor ?? json;\n return { config: validateConfig(block ?? {}, file), file, dir: path.dirname(file) };\n }\n const own = path.join(root, \"genesis.config.json\");\n if (existsSync(own)) {\n const block = readGenesisConfig(root)?.raw.doctor;\n return { config: validateConfig(block ?? {}, own), file: own, dir: root };\n }\n const pkg = path.join(root, \"package.json\");\n if (existsSync(pkg)) {\n const block = readJson(pkg)?.genesis?.doctor;\n if (block !== undefined) return { config: validateConfig(block, pkg), file: pkg, dir: root };\n }\n return { config: {}, file: null, dir: root };\n}\n\nfunction readJson(file: string) {\n try {\n return JSON.parse(readFileSync(file, \"utf8\"));\n } catch (err) {\n throw new DoctorConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\n/**\n * Reads `<root>/genesis.config.json` and validates its shared blocks (today:\n * `links`). Returns null when the file doesn't exist; throws a\n * GenesisConfigError naming the file when it isn't valid.\n */\nexport function readGenesisConfig(root: string): GenesisConfigFile | null {\n const file = path.join(root, \"genesis.config.json\");\n if (!existsSync(file)) return null;\n const raw: unknown = readJson(file);\n if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);\n const links = raw.links === undefined ? undefined : validateLinks(raw.links, file);\n return links ? { raw, links } : { raw };\n}\n\nconst LINK_KEYS = new Set([\"hosts\", \"paths\", \"webcredentials\"]);\nconst HOST = /^(?=.{1,253}$)(\\*\\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/;\n\n/** Check the `links` block, so a typo'd host fails the build instead of shipping links that never open. */\nexport function validateLinks(raw: unknown, source = \"config\"): GenesisLinks {\n const fail = (msg: string): never => {\n throw new GenesisConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(`\"links\" must be an object`);\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting \"${key}\"`);\n if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);\n for (const host of c.hosts as string[]) {\n if (!HOST.test(host)) {\n fail(`links.hosts: \"${host}\" is not a bare lower-case host name (no scheme, path or port), e.g. \"example.com\"`);\n }\n }\n if (c.paths !== undefined) {\n if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);\n for (const p of c.paths as string[]) {\n if (!p.startsWith(\"/\") || /[\\s?#*]/.test(p)) {\n fail(`links.paths: \"${p}\" must start with \"/\" and hold no spaces, \"?\", \"#\" or \"*\"`);\n }\n }\n }\n if (c.webcredentials !== undefined && typeof c.webcredentials !== \"boolean\") fail(`links.webcredentials must be true or false`);\n const links: GenesisLinks = { hosts: [...new Set(c.hosts as string[])] };\n if (c.paths !== undefined) links.paths = [...new Set(c.paths as string[])];\n if (c.webcredentials !== undefined) links.webcredentials = c.webcredentials as boolean;\n return links;\n}\n\n/** Check the shape, so a typo fails loudly instead of silently disabling a check. */\nexport function validateConfig(raw: unknown, source = \"config\"): DoctorConfig {\n const fail = (msg: string): never => {\n throw new DoctorConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(\"the doctor settings must be an object\");\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!KNOWN.has(key)) fail(`unknown setting \"${key}\"`);\n // themeCss takes one stylesheet or several; normalize to a list.\n if (typeof c.themeCss === \"string\") c.themeCss = [c.themeCss];\n if (c.themeCss !== undefined && !isStringList(c.themeCss)) fail(`\"themeCss\" must be a path or a list of paths`);\n for (const key of STRING_LISTS) {\n if (c[key] !== undefined && !isStringList(c[key])) fail(`\"${key}\" must be a list of strings`);\n }\n for (const key of STRINGS) {\n if (c[key] !== undefined && typeof c[key] !== \"string\") fail(`\"${key}\" must be a string`);\n }\n if (c.rawTags !== undefined) {\n if (!isObject(c.rawTags)) fail(`\"rawTags\" must be an object`);\n for (const [tag, v] of Object.entries(c.rawTags as object)) {\n if (!/^[a-z][a-z0-9-]*$/.test(tag)) fail(`rawTags: \"${tag}\" is not an HTML tag name`);\n if (v !== false && typeof v !== \"string\") fail(`rawTags.${tag} must be a component name or false`);\n }\n }\n if (c.forbiddenImports !== undefined) {\n if (!isObject(c.forbiddenImports)) fail(`\"forbiddenImports\" must be an object of pattern → message`);\n for (const [re, msg] of Object.entries(c.forbiddenImports as object)) {\n if (typeof msg !== \"string\") fail(`forbiddenImports[\"${re}\"] must be a message string`);\n checkRegExp(re, `forbiddenImports[\"${re}\"]`, fail);\n }\n }\n if (c.rules !== undefined) {\n if (!isObject(c.rules)) fail(`\"rules\" must be an object of rule → level`);\n for (const [rule, level] of Object.entries(c.rules as object)) {\n if (!LEVELS.has(level as string)) fail(`rules.${rule} must be \"error\", \"warn\" or \"off\"`);\n }\n }\n if (c.allow !== undefined) {\n if (!Array.isArray(c.allow)) fail(`\"allow\" must be a list`);\n (c.allow as unknown[]).forEach((e, i) => {\n if (!isObject(e)) return fail(`allow[${i}] must be an object`);\n const entry = e as Record<string, unknown>;\n if (typeof entry.rule !== \"string\" || !entry.rule) fail(`allow[${i}] needs a \"rule\"`);\n if (typeof entry.reason !== \"string\" || !entry.reason.trim()) fail(`allow[${i}] (${entry.rule}) needs a \"reason\"`);\n for (const k of [\"file\", \"match\"]) {\n if (entry[k] !== undefined && typeof entry[k] !== \"string\") fail(`allow[${i}].${k} must be a string`);\n }\n });\n }\n if (c.patterns !== undefined) {\n if (!Array.isArray(c.patterns)) fail(`\"patterns\" must be a list`);\n (c.patterns as unknown[]).forEach((p, i) => {\n if (!isObject(p)) return fail(`patterns[${i}] must be an object`);\n const rule = p as Record<string, unknown>;\n for (const k of Object.keys(rule)) if (!PATTERN_KEYS.has(k)) fail(`patterns[${i}]: unknown key \"${k}\"`);\n if (typeof rule.id !== \"string\" || !rule.id) fail(`patterns[${i}] needs an \"id\"`);\n for (const k of [\"files\", \"exclude\"]) {\n if (rule[k] !== undefined && !isStringList(rule[k])) fail(`patterns[${i}].${k} must be a list of globs`);\n }\n });\n }\n if (c.packs !== undefined) {\n if (!isStringList(c.packs)) fail(`\"packs\" must be a list, e.g. [\"native\", \"supabase\"]`);\n for (const p of c.packs as string[]) if (!PACKS.has(p)) fail(`packs: unknown pack \"${p}\" (known: ${[...PACKS].join(\", \")})`);\n if (new Set(c.packs as string[]).size !== (c.packs as string[]).length) fail(`packs: lists a pack twice`);\n }\n for (const [pack, keys] of Object.entries(PACK_KEYS)) {\n const block = c[pack];\n if (block === undefined) continue;\n if (!isObject(block)) fail(`\"${pack}\" must be an object`);\n if (!((c.packs as string[] | undefined) ?? []).includes(pack)) fail(`\"${pack}\" settings are set but the ${pack} pack is not in \"packs\"`);\n for (const [k, v] of Object.entries(block as object)) {\n const want = keys[k];\n if (!want) fail(`${pack}: unknown setting \"${k}\"`);\n if (want === \"string\" && typeof v !== \"string\") fail(`${pack}.${k} must be a string`);\n if (want === \"list\" && !isStringList(v)) fail(`${pack}.${k} must be a list of strings`);\n if (want === \"string\" && !(v as string).trim()) fail(`${pack}.${k} must not be empty`);\n if (want === \"path\") (block as Record<string, unknown>)[k] = appPath(v, `${pack}.${k}`, fail);\n }\n }\n // Schema names compare lowercased, like the SQL they're matched against.\n const supa = c.supabase as Record<string, unknown> | undefined;\n if (Array.isArray(supa?.exposedSchemas)) supa.exposedSchemas = (supa.exposedSchemas as string[]).map((s) => s.toLowerCase());\n if (c.plugins !== undefined) {\n const ok =\n Array.isArray(c.plugins) &&\n c.plugins.every((p) => typeof p === \"string\" || (Array.isArray(p) && p.length === 2 && typeof p[0] === \"string\"));\n if (!ok) fail(`\"plugins\" must be a list of module paths or [path, options] pairs`);\n }\n return c as DoctorConfig;\n}\n\nexport function checkRegExp(source: string, where: string, fail: (msg: string) => never): void {\n try {\n new RegExp(source);\n } catch (err) {\n fail(`${where} is not a valid regular expression: ${(err as Error).message}`);\n }\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction isStringList(v: unknown): v is string[] {\n return Array.isArray(v) && v.every((x) => typeof x === \"string\");\n}\n","/**\n * Minimal globs for config: `*` matches within a folder, `**` across folders,\n * `?` one character, and a trailing `/` means \"everything under this folder\".\n */\nexport function globToRegExp(glob: string): RegExp {\n let g = glob.trim().replace(/^\\.\\//, \"\");\n if (g.endsWith(\"/\")) g += \"**\";\n let out = \"\";\n for (let i = 0; i < g.length; i++) {\n const ch = g[i];\n if (ch === \"*\") {\n if (g[i + 1] === \"*\") {\n const slash = g[i + 2] === \"/\";\n out += slash ? \"(?:.*/)?\" : \".*\";\n i += slash ? 2 : 1;\n } else {\n out += \"[^/]*\";\n }\n } else if (ch === \"?\") {\n out += \"[^/]\";\n } else {\n out += ch.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n }\n }\n return new RegExp(`^${out}$`);\n}\n\n/** A matcher for a list of globs; an empty list matches nothing. */\nexport function globMatcher(globs: readonly string[] | undefined): (path: string) => boolean {\n const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);\n return (path) => res.some((re) => re.test(path));\n}\n","/**\n * Reads the rules' ground truth from the installed Genesis packages: the\n * component package's type declarations (what it exports, which exports are\n * components), the design system's theme stylesheets (which tokens exist) and\n * Tailwind's palette (which literal colors to flag). No component or token is\n * listed here, so the doctor follows whatever Genesis version the app has.\n */\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorConfig, GenesisFacts } from \"./types.js\";\n\nexport const DEFAULT_UI_PACKAGE = \"@marktiderman/genesis-ui\";\nexport const NATIVE_UI_PACKAGE = \"@marktiderman/genesis-ui-native\";\nexport const DESIGN_SYSTEM_PACKAGE = \"@marktiderman/genesis-design-system\";\n\n/**\n * Raw tags checked when Genesis ships a same-named component. `form` is left\n * out on purpose: a shadcn-style `Form` is a react-hook-form provider that\n * still wraps a real `<form>`.\n */\nconst TAGS = [\"button\", \"input\", \"textarea\", \"select\", \"label\", \"table\", \"dialog\", \"progress\", \"details\", \"summary\"];\n/** Tags whose Genesis replacement has a different name. Applied only when that component exists. */\nconst TAG_ALIASES: Record<string, string> = { hr: \"Separator\" };\n\n/** Names that look like components but are types or helpers. */\nconst NON_COMPONENT_SUFFIX = /(Props|Variant|Variants|Type|Types|Config|Context|Options|Status)$/;\n\n/** Tailwind's default palette names; merged with the app's installed `tailwindcss/colors` when present. */\nconst TAILWIND_PALETTE = [\n \"black\", \"white\", \"slate\", \"gray\", \"zinc\", \"neutral\", \"stone\", \"red\", \"orange\", \"amber\", \"yellow\", \"lime\",\n \"green\", \"emerald\", \"teal\", \"cyan\", \"sky\", \"blue\", \"indigo\", \"violet\", \"purple\", \"fuchsia\", \"pink\", \"rose\",\n \"taupe\", \"mauve\", \"mist\", \"olive\",\n];\n\n/** The installed folder of `name`, looking in node_modules from `from` upward (works with hoisting and pnpm). */\nexport function findPackageDir(from: string, name: string): string | null {\n let dir = path.resolve(from);\n for (;;) {\n const candidate = path.join(dir, \"node_modules\", name);\n if (existsSync(path.join(candidate, \"package.json\"))) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n/** What one installed component package exports, read from its type declarations. */\nexport interface PackageExports {\n dir: string;\n version: string;\n /** Every exported name (all subpaths). */\n exports: Set<string>;\n /** Exported values (not types). */\n values: Set<string>;\n /** Exported components, sorted. */\n components: string[];\n}\n\n/** The component package the core rules read: `uiPackage`, else the native one when the native pack is on. */\nexport function uiPackageFor(config: DoctorConfig): string {\n return config.uiPackage ?? (config.packs?.includes(\"native\") ? NATIVE_UI_PACKAGE : DEFAULT_UI_PACKAGE);\n}\n\nexport function loadGenesis(root: string, config: DoctorConfig): GenesisFacts {\n const uiPackage = uiPackageFor(config);\n const pkg = readPackageExports(root, uiPackage);\n if (!pkg) throw new DoctorConfigError(`${uiPackage} is not installed here. Install it, or set doctor.uiPackage.`);\n const { dir: uiDir, exports: exportNames, values, components } = pkg;\n\n // ---- Tokens, from the theme stylesheets ----\n const tokens = new Set<string>();\n const themeFiles = resolveThemeFiles(root, config, uiDir);\n for (const file of themeFiles) for (const t of declaredTokens(readFileSync(file, \"utf8\"))) tokens.add(t);\n\n // ---- Raw tags ----\n const byLower = new Map(components.map((c) => [c.toLowerCase(), c]));\n const rawTags = new Map<string, string>();\n for (const tag of TAGS) if (byLower.has(tag)) rawTags.set(tag, byLower.get(tag)!);\n for (const [tag, comp] of Object.entries(TAG_ALIASES)) if (values.has(comp)) rawTags.set(tag, comp);\n for (const [tag, comp] of Object.entries(config.rawTags ?? {})) {\n if (comp === false) rawTags.delete(tag);\n else rawTags.set(tag, comp);\n }\n\n return {\n uiPackage,\n uiVersion: pkg.version,\n exports: exportNames,\n values,\n components,\n tokens,\n rawTags,\n palette: loadPalette(root),\n };\n}\n\n/** An installed package's exports, from its declarations (every subpath), or null when it isn't installed. */\nexport function readPackageExports(root: string, uiPackage: string): PackageExports | null {\n const uiDir = findPackageDir(root, uiPackage);\n if (!uiDir) return null;\n const uiPkg = JSON.parse(readFileSync(path.join(uiDir, \"package.json\"), \"utf8\"));\n\n // ---- Exports, from every subpath's declarations ----\n const typeEntries = new Set<string>();\n const mainTypes = uiPkg.types ?? uiPkg.typings ?? exportTypes(uiPkg.exports?.[\".\"] ?? uiPkg.exports);\n if (typeof mainTypes === \"string\") typeEntries.add(mainTypes);\n for (const target of Object.values(uiPkg.exports ?? {})) {\n const t = exportTypes(target);\n if (typeof t === \"string\" && !t.includes(\"*\")) typeEntries.add(t);\n }\n const exportNames = new Set<string>();\n const reexportedPackages = new Set<string>();\n let readAny = false;\n for (const entry of typeEntries) {\n const file = path.join(uiDir, entry);\n if (!existsSync(file)) continue;\n readAny = true;\n const dts = readFileSync(file, \"utf8\");\n for (const name of parseExportNames(dts)) exportNames.add(name);\n for (const m of dts.matchAll(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*)\\s*from\\s*[\"']([^\"'.][^\"']*)[\"']/g)) {\n reexportedPackages.add(packageName(m[1]));\n }\n }\n if (!readAny) {\n throw new DoctorConfigError(`${uiPackage} has no type declarations to read (is it built?). Looked for: ${[...typeEntries].join(\", \") || \"none\"}`);\n }\n\n // ---- Which exports are types only, from every declaration file it ships ----\n const valueDecls = new Set<string>();\n const typeDecls = new Set<string>();\n const declRoot = typeof mainTypes === \"string\" ? path.dirname(path.join(uiDir, mainTypes)) : uiDir;\n // Names re-exported from other packages (e.g. genesis-core's types) are declared there.\n const declFiles = walkDts(declRoot);\n for (const pkg of reexportedPackages) {\n const dir = findPackageDir(uiDir, pkg);\n if (dir) walkDts(path.join(dir, \"dist\"), declFiles);\n }\n for (const file of declFiles) {\n const text = readFileSync(file, \"utf8\");\n for (const m of text.matchAll(/\\b(?:declare\\s+)?(?:const|let|var|function|class|enum)\\s+([A-Za-z_$][\\w$]*)/g)) valueDecls.add(m[1]);\n for (const m of text.matchAll(/\\b(?:interface|type)\\s+([A-Za-z_$][\\w$]*)/g)) typeDecls.add(m[1]);\n }\n const isTypeOnly = (n: string) => typeDecls.has(n) && !valueDecls.has(n);\n const values = new Set([...exportNames].filter((n) => !isTypeOnly(n)));\n const components = [...values]\n // PascalCase (H1 and P included), but not SCREAMING_CASE constants.\n .filter((n) => /^[A-Z][A-Za-z0-9]*$/.test(n) && !(n.length > 2 && n === n.toUpperCase()) && !NON_COMPONENT_SUFFIX.test(n))\n .sort();\n return { dir: uiDir, version: String(uiPkg.version ?? \"unknown\"), exports: exportNames, values, components };\n}\n\n/** Names exported by a declaration file: `export { a, b as c }` blocks and `export declare …` statements. */\nexport function parseExportNames(dts: string): string[] {\n const names: string[] = [];\n for (const m of dts.matchAll(/export\\s+(?:type\\s+)?\\{([^}]*)\\}/g)) {\n for (const part of m[1].split(\",\")) {\n const name = part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/).pop()?.trim();\n if (name && name !== \"default\") names.push(name);\n }\n }\n for (const m of dts.matchAll(/export\\s+(?:declare\\s+)?(?:const|let|function|class|enum|interface|type)\\s+([A-Za-z_$][\\w$]*)/g)) {\n names.push(m[1]);\n }\n return names;\n}\n\n/** Custom properties a stylesheet declares (`--name:`). */\nexport function declaredTokens(css: string): string[] {\n return [...css.matchAll(/(--[A-Za-z0-9_-]+)\\s*:/g)].map((m) => m[1]);\n}\n\nfunction packageName(specifier: string): string {\n const parts = specifier.split(\"/\");\n return parts.slice(0, specifier.startsWith(\"@\") ? 2 : 1).join(\"/\");\n}\n\nfunction exportTypes(target: unknown): string | undefined {\n if (!target || typeof target !== \"object\") return undefined;\n const t = target as Record<string, unknown>;\n if (typeof t.types === \"string\") return t.types;\n for (const key of [\"import\", \"default\", \"require\"]) {\n const nested = exportTypes(t[key]);\n if (nested) return nested;\n }\n return undefined;\n}\n\nfunction walkDts(dir: string, out: string[] = []): string[] {\n if (!existsSync(dir)) return out;\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === \"node_modules\") continue;\n const p = path.join(dir, entry.name);\n if (entry.isDirectory()) walkDts(p, out);\n else if (/\\.d\\.[cm]?ts$/.test(entry.name)) out.push(p);\n }\n return out;\n}\n\nfunction resolveThemeFiles(root: string, config: DoctorConfig, uiDir: string): string[] {\n if (config.themeCss) {\n const specs = typeof config.themeCss === \"string\" ? [config.themeCss] : config.themeCss;\n return specs.map((spec) => {\n const file = resolveSpec(root, spec);\n if (!file) throw new DoctorConfigError(`doctor.themeCss: cannot find ${spec}`);\n return file;\n });\n }\n const files: string[] = [];\n const ds = findPackageDir(root, DESIGN_SYSTEM_PACKAGE);\n const themes = ds && path.join(ds, \"dist\", \"themes\");\n if (themes && existsSync(themes)) {\n for (const name of readdirSync(themes).sort()) if (name.endsWith(\".css\")) files.push(path.join(themes, name));\n }\n if (files.length === 0) {\n throw new DoctorConfigError(\n `No Genesis theme stylesheet found (${DESIGN_SYSTEM_PACKAGE}/dist/themes/*.css). Install the design system, or set doctor.themeCss.`,\n );\n }\n const uiStyles = path.join(uiDir, \"dist\", \"styles.css\");\n if (existsSync(uiStyles)) files.push(uiStyles);\n return files;\n}\n\n/** An app-relative path, or `package/sub/path` resolved inside that installed package. */\nfunction resolveSpec(root: string, spec: string): string | null {\n const local = path.resolve(root, spec);\n if (spec.startsWith(\".\") || path.isAbsolute(spec)) return existsSync(local) ? local : null;\n const parts = spec.split(\"/\");\n const nameLength = spec.startsWith(\"@\") ? 2 : 1;\n const dir = findPackageDir(root, parts.slice(0, nameLength).join(\"/\"));\n if (dir) {\n const file = path.join(dir, ...parts.slice(nameLength));\n if (existsSync(file) && statSync(file).isFile()) return file;\n }\n return existsSync(local) ? local : null;\n}\n\nfunction loadPalette(root: string): string[] {\n const names = new Set(TAILWIND_PALETTE);\n try {\n const req = createRequire(path.join(root, \"package.json\"));\n const colors = req(\"tailwindcss/colors\");\n for (const key of Object.keys(colors?.default ?? colors ?? {})) {\n if (/^[a-z]+$/.test(key) && ![\"inherit\", \"current\", \"transparent\"].includes(key)) names.add(key);\n }\n } catch {\n // No Tailwind installed (or it is ESM-only): the built-in list stands.\n }\n return [...names].sort();\n}\n","/**\n * color-literals.mjs — the raw-color lexer shared by scripts/check-token-usage.mjs\n * and `genesis doctor` (packages/genesis-cli, which bundles this file at build\n * time). One implementation, so a bypass fixed here is fixed in both gates.\n *\n * Pure functions only: no filesystem, no process state.\n */\n\n// Extensions where `//` opens a genuine line comment (C-style langs, plus the\n// CSS supersets SCSS/LESS which DO have `//`). Plain `.css` is deliberately\n// absent: CSS has NO `//` line comment, and an unquoted `url(https://cdn/x.svg)`\n// contains `//`. Treating that `//` as a comment blanks the rest of the line, so\n// a real hex after it (`... color: #ff0000;`) never gets scanned and the gate is\n// bypassed. Only files with this extension run the `//` branch in\n// stripBlockComments(); `/* ... */` block comments are stripped for ALL types.\nexport const LINE_COMMENT_EXTS = new Set(['.ts', '.tsx', '.jsx', '.js', '.mjs', '.cjs', '.scss', '.less']);\n\n// Numeric HTML entities (`&#1234;`) are not colors.\nconst HTML_ENTITY_RE = /&#\\d+;/g;\n\n// Blank out `/* ... */` block comments (JS/TS JSDoc AND CSS comments) while\n// preserving line numbers, so hex inside a comment is ignored without skipping\n// any `*`-prefixed CSS selector line. Uses escape-aware lexical scanning to\n// avoid removing comment-like sequences inside string and template literals.\n//\n// `hasLineComments` gates the `//` line-comment branch: pass `true` only for\n// file types where `//` is a real line comment (see LINE_COMMENT_EXTS). For\n// plain CSS it must be `false`, otherwise `url(https://…)` gets blanked from the\n// `//` onward and any hex after it slips past the gate. String/template/`/* */`\n// handling is unaffected by this flag and runs for ALL file types.\n/** Blank out C-style block comments (and `//` line comments when enabled) while preserving line numbers and skipping string/template literals. */\nexport function stripBlockComments(content, hasLineComments = true) {\n let result = '';\n let i = 0;\n const len = content.length;\n\n while (i < len) {\n const ch = content[i];\n const next = i + 1 < len ? content[i + 1] : '';\n const prevIsColon = i > 0 && content[i - 1] === ':';\n const prevIsBackslash = i > 0 && content[i - 1] === '\\\\';\n\n // Handle string literals: \"...\" with escape support\n if (ch === '\"') {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === '\"') {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle string literals: '...' with escape support\n if (ch === \"'\") {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === \"'\") {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle template literals: `...` with escape support\n if (ch === '`') {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === '`') {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle CSS/SCSS/LESS `url(...)` tokens. The contents of `url(...)` are\n // NEVER a comment regardless of scheme, so consume the whole token verbatim\n // through to the matching `)` and do NOT let the `//` inside it open a line\n // comment. This structurally closes the entire `url()`-`//` bypass class in\n // one place — `url(//cdn/x)` (protocol-relative), `url(https://…)` and\n // `url(http://…)` all stay scannable, so a trailing `color: #ff0000;` on the\n // same line is still caught (CMT-250-004 + Codex protocol-relative P2).\n // Detect an `url` identifier (case-insensitive) directly followed by `(`,\n // where `u` starts the identifier (previous char is not an identifier char,\n // so `blurUrl(` / `baseurl(` don't match). Quotes inside are respected via\n // the same escape rules as string state, so a `)` inside `url(\"a)b\")` does\n // not end the token early; `/* */` is left intact (never appears in url()).\n if (\n (ch === 'u' || ch === 'U') &&\n content.slice(i, i + 4).toLowerCase() === 'url(' &&\n !/[\\w$]/.test(content[i - 1] ?? '')\n ) {\n result += content.slice(i, i + 4); // 'url('\n i += 4;\n while (i < len && content[i] !== ')') {\n const c = content[i];\n if (c === '\"' || c === \"'\") {\n // Consume a quoted segment (escape-aware) so a `)` inside it is not\n // mistaken for the url() close.\n result += c;\n i++;\n while (i < len) {\n const q = content[i];\n result += q;\n if (q === '\\\\' && i + 1 < len) {\n result += content[i + 1];\n i += 2;\n } else if (q === c) {\n i++;\n break;\n } else {\n i++;\n }\n }\n } else {\n result += c;\n i++;\n }\n }\n if (i < len && content[i] === ')') {\n result += ')';\n i++;\n }\n continue;\n }\n\n // Handle line comments: // ... to end of line\n // A `//` at top level must NOT open string/template/block state: an\n // apostrophe in a contraction (\"don't\") inside a line comment would\n // otherwise enter string-mode and consume across the newline, corrupting\n // the stripping of a following real block comment (CMT-250-001).\n // Gated on `hasLineComments`: plain CSS has no `//` comment (an unquoted\n // `url(https://…)` contains `//`), so this branch is skipped there and the\n // `//` is treated as ordinary content, keeping any following hex scannable.\n // The `url(...)` branch above already neutralizes `//` inside url() for ALL\n // file types; the guards below are defense-in-depth for `//` sequences that\n // arise OUTSIDE url(). Skip when the `//` is immediately preceded by `:` — a\n // URL scheme separator (`http://`, `https://`), not a comment (CMT-250-004).\n // AND skip when the `//` is immediately preceded by `\\` — strings/templates\n // are already lexed above, so a backslash in code state means we are inside\n // a regex literal (e.g. `/https?:\\/\\//`), where the escaped `\\/` + closing\n // `/` read as `//`. Without this the rest of the line (and any hex on it)\n // would be blanked and slip past the gate (Codex P2, same bypass class).\n if (hasLineComments && ch === '/' && next === '/' && !prevIsColon && !prevIsBackslash) {\n let j = i + 2;\n while (j < len && content[j] !== '\\n') {\n j++;\n }\n const commentLen = j - i;\n // Blank comment chars to spaces; the trailing `\\n` (if any) is left for\n // the next iteration so line numbers are preserved.\n const commentText = content.slice(i, i + commentLen);\n result += commentText.replace(/[^\\n]/g, ' ');\n i += commentLen;\n continue;\n }\n\n // Handle block comments: /* ... */\n if (ch === '/' && next === '*') {\n let commentLen = 2;\n let j = i + 2;\n while (j < len) {\n if (content[j] === '*' && j + 1 < len && content[j + 1] === '/') {\n commentLen = j + 2 - i;\n break;\n }\n j++;\n }\n // Replace non-newline chars with spaces to preserve line numbers\n const commentText = content.slice(i, i + commentLen);\n result += commentText.replace(/[^\\n]/g, ' ');\n i += commentLen;\n continue;\n }\n\n // Regular character\n result += ch;\n i++;\n }\n\n return result;\n}\n\n// Hex color literal: `#` + 3, 4, 6, or 8 hex digits, NOT inside an HTML\n// entity (which is `&#1234;` — pure decimal). The match is intentionally\n// generous (any hex run in {3,4,6,8}); the all-digits-in-3/4 case is\n// filtered out post-match because pure-decimal `#163` / `#1284`\n// overwhelmingly appears in natural language as issue / order refs\n// (\"Merged PR #163\", \"Order #1284\") rather than as colors. CSS\n// developers writing literal short-hand colors almost always include a\n// letter (`#fff`, `#a1b`, `#0af`). For 6- and 8-digit forms we accept\n// all-digit hex (`#000000` is a real color). False-negative tradeoff:\n// `#123` written as a short-hand for `#112233` will pass — but the\n// long-form is the dominant style, and the alternative (false-positive\n// every issue reference) is worse.\nconst HEX_RE = /(^|[^\\w&])#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\\b/g;\nconst HEX_LETTER_RE = /[a-fA-F]/;\n\n// Color-function literal: rgb()/rgba()/hsl()/hsla() whose first argument is a\n// number or percentage — e.g. `rgba(0,0,0,0.08)`, `rgb(0 0 0 / 0.1)`,\n// `hsl(160 84% 39%)`. Raw color-function literals sneak past the hex check\n// (finding #4: `rgba(0,0,0,0.08)` borders), so they're flagged the same way.\n// Requiring a digit/`.` right after `(` deliberately spares token-backed forms\n// like `hsl(var(--primary))` — those reference a CSS variable, not a raw\n// literal — and non-color CSS functions (translate(), scale(), matrix()) never\n// match the rgb/rgba/hsl/hsla names. The match is captured up to the first\n// closing paren for the reported literal.\nconst COLOR_FN_RE = /\\b(rgba?|hsla?)\\(\\s*[\\d.][^)\\n]*\\)?/gi;\n\n/** Strip numeric HTML entities (`&#1234;`) from a line so they are not mistaken for hex color literals. */\nfunction stripHtmlEntities(line) {\n return line.replace(HTML_ENTITY_RE, '');\n}\n\n/** Find raw hex color literals in a line, filtering out decimal-only 3/4-digit matches (likely issue/order refs). */\nexport function findHexLiterals(line) {\n const cleaned = stripHtmlEntities(line);\n const matches = [];\n let m;\n HEX_RE.lastIndex = 0;\n while ((m = HEX_RE.exec(cleaned)) !== null) {\n const digits = m[2];\n // Filter pure-decimal 3/4-digit matches as likely issue refs (#163,\n // #1284). 6/8-digit forms are accepted unconditionally.\n if (digits.length <= 4 && !HEX_LETTER_RE.test(digits)) continue;\n const literal = `#${digits}`;\n const idx = m.index + m[1].length;\n matches.push({ literal, column: idx + 1 });\n }\n return matches;\n}\n\n/** Find raw rgb()/rgba()/hsl()/hsla() literals with numeric arguments in a line (token-backed `hsl(var(--x))` is spared). */\nexport function findColorFunctions(line) {\n const cleaned = stripHtmlEntities(line);\n const matches = [];\n let m;\n COLOR_FN_RE.lastIndex = 0;\n while ((m = COLOR_FN_RE.exec(cleaned)) !== null) {\n matches.push({ literal: m[0], column: m.index + 1 });\n }\n return matches;\n}\n","/**\n * Collects the app files the doctor checks.\n */\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { LINE_COMMENT_EXTS, stripBlockComments } from \"../../../../scripts/lib/color-literals.mjs\";\nimport { globMatcher } from \"./glob.js\";\nimport type { DoctorConfig, SourceFile } from \"./types.js\";\n\nexport const DEFAULT_SRC = [\"src\"];\n/** Expo apps keep routes in `app/` and shared UI in `components/` at the root. */\nexport const DEFAULT_NATIVE_SRC = [\"app\", \"src\", \"components\"];\nexport const DEFAULT_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".css\"];\n/** Always skipped: tests, fixtures, declarations and generated files are not shipped UI. */\nexport const DEFAULT_IGNORE = [\n \"**/*.d.ts\",\n \"**/*.gen.*\",\n \"**/*.test.*\",\n \"**/*.spec.*\",\n \"**/__tests__/**\",\n \"**/__fixtures__/**\",\n \"**/__mocks__/**\",\n];\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \".next\", \".output\", \".turbo\", \"coverage\"]);\nconst MAX_FILE_BYTES = 2 * 1024 * 1024;\n\nconst toPosix = (p: string) => p.split(path.sep).join(\"/\");\n\nexport function scanFiles(root: string, config: DoctorConfig): SourceFile[] {\n const extensions = new Set(config.extensions ?? DEFAULT_EXTENSIONS);\n const ignored = globMatcher([...DEFAULT_IGNORE, ...(config.ignore ?? [])]);\n const files: SourceFile[] = [];\n const seen = new Set<string>();\n const visit = (abs: string) => {\n const rel = toPosix(path.relative(root, abs));\n if (seen.has(rel) || ignored(rel)) return;\n const ext = path.extname(abs);\n if (!extensions.has(ext)) return;\n if (statSync(abs).size > MAX_FILE_BYTES) return;\n seen.add(rel);\n const text = readFileSync(abs, \"utf8\");\n files.push({ path: rel, absolutePath: abs, ext, text, code: stripBlockComments(text, LINE_COMMENT_EXTS.has(ext)) });\n };\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n if (entry.isDirectory()) {\n if (!SKIP_DIRS.has(entry.name)) walk(path.join(dir, entry.name));\n } else if (entry.isFile()) {\n visit(path.join(dir, entry.name));\n }\n }\n };\n for (const src of config.src ?? (config.packs?.includes(\"native\") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)) {\n const abs = path.resolve(root, src);\n if (!existsSync(abs)) continue;\n if (statSync(abs).isDirectory()) walk(abs);\n else visit(abs);\n }\n return files;\n}\n\n/** 1-based line of a character offset. */\nexport function lineAt(text: string, index: number): number {\n let line = 1;\n for (let i = 0; i < index && i < text.length; i++) if (text.charCodeAt(i) === 10) line++;\n return line;\n}\n","/**\n * Declarative app rules: from config `patterns`, or from a markdown rules\n * document so the rules can live next to the prose that explains them.\n *\n * The markdown format: a `### rule-id` heading starts a rule; the `- key: value`\n * lines under it (level, files, exclude, forbid, require, path, message) set\n * it; any `#` or `##` heading ends it. `files`/`exclude` are comma-separated.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport { globMatcher } from \"./glob.js\";\nimport { lineAt } from \"./scan.js\";\nimport type { DoctorContext, DoctorPlugin, PatternRule } from \"./types.js\";\n\nexport function parseRulesMarkdown(markdown: string): PatternRule[] {\n const rules: PatternRule[] = [];\n let current: PatternRule | null = null;\n for (const line of markdown.split(\"\\n\")) {\n const heading = line.match(/^###\\s+([A-Za-z0-9_-]+)\\s*$/);\n if (heading) {\n current = { id: heading[1] };\n rules.push(current);\n continue;\n }\n if (/^#{1,2}\\s/.test(line)) {\n current = null;\n continue;\n }\n const kv = current && line.match(/^-\\s+(level|files|exclude|forbid|require|path|message):\\s*(.*)$/);\n if (!current || !kv) continue;\n const [, key, raw] = kv;\n const value = raw.trim();\n if (key === \"files\" || key === \"exclude\") current[key] = value.split(\",\").map((s) => s.trim()).filter(Boolean);\n else if (key === \"level\") current.level = value as PatternRule[\"level\"];\n else current[key as \"forbid\" | \"require\" | \"path\" | \"message\"] = value;\n }\n return rules;\n}\n\n/** `(?i)` at the start means case-insensitive, as in the markdown format. */\nfunction toRegExp(source: string, flags = \"\"): RegExp {\n if (source.startsWith(\"(?i)\")) return new RegExp(source.slice(4), flags + \"i\");\n return new RegExp(source, flags);\n}\n\ninterface CompiledRule {\n rule: PatternRule;\n level: \"error\" | \"warn\";\n includes: (p: string) => boolean;\n excludes: (p: string) => boolean;\n forbid?: RegExp;\n require?: RegExp;\n path?: RegExp;\n}\n\n/** Validate and compile rules up front, so a broken pattern fails the run with its rule id. */\nexport function compilePatternRules(rules: PatternRule[], source: string): CompiledRule[] {\n const ids = new Set<string>();\n const out: CompiledRule[] = [];\n for (const rule of rules) {\n if (ids.has(rule.id)) throw new DoctorConfigError(`${source}: rule \"${rule.id}\" is defined twice`);\n ids.add(rule.id);\n const level = rule.level ?? \"error\";\n if (![\"error\", \"warn\", \"guide\"].includes(level)) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" has level \"${level}\" (use error, warn or guide)`);\n }\n if (level === \"guide\") continue;\n if (!rule.files?.length) throw new DoctorConfigError(`${source}: rule \"${rule.id}\" needs \"files\" (or level: guide)`);\n if (!rule.forbid && !rule.require && !rule.path) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" needs forbid, require or path (or level: guide)`);\n }\n try {\n out.push({\n rule,\n level,\n includes: globMatcher(rule.files),\n excludes: globMatcher(rule.exclude),\n forbid: rule.forbid ? toRegExp(rule.forbid, \"m\") : undefined,\n require: rule.require ? toRegExp(rule.require, \"m\") : undefined,\n path: rule.path ? toRegExp(rule.path) : undefined,\n });\n } catch (err) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" has an invalid pattern: ${(err as Error).message}`);\n }\n }\n return out;\n}\n\n/** Pattern rules from config and the rules doc, as one plugin. Returns null when there are none. */\nexport function loadPatternRules(root: string, patterns: PatternRule[] | undefined, rulesDoc: string | undefined): { plugin: DoctorPlugin; count: number } | null {\n const compiled = compilePatternRules(patterns ?? [], \"doctor.patterns\");\n let all = compiled;\n if (rulesDoc) {\n const file = path.resolve(root, rulesDoc);\n if (!existsSync(file)) throw new DoctorConfigError(`doctor.rulesDoc: ${rulesDoc} not found`);\n const fromDoc = compilePatternRules(parseRulesMarkdown(readFileSync(file, \"utf8\")), rulesDoc);\n const clash = fromDoc.find((d) => compiled.some((c) => c.rule.id === d.rule.id));\n if (clash) throw new DoctorConfigError(`rule \"${clash.rule.id}\" is defined in both doctor.patterns and ${rulesDoc}`);\n all = [...compiled, ...fromDoc];\n }\n if (all.length === 0) return null;\n return {\n count: all.length,\n plugin: {\n name: \"patterns\",\n check(ctx: DoctorContext) {\n for (const r of all) {\n const message = r.rule.message ?? \"breaks a design rule\";\n for (const file of ctx.files) {\n if (!r.includes(file.path) || r.excludes(file.path)) continue;\n const report = (line: number) => ctx.report({ rule: r.rule.id, level: r.level, file: file.path, line, message });\n if (r.path && !r.path.test(file.path)) report(0);\n if (r.require && !r.require.test(file.code)) report(0);\n if (r.forbid) {\n const m = r.forbid.exec(file.code);\n if (m) report(lineAt(file.code, m.index));\n }\n }\n }\n },\n },\n };\n}\n","/**\n * Loads app rule modules listed in config `plugins`.\n *\n * A module default-exports a plugin, an array of plugins, or a function that\n * takes the options from `[\"./path.mjs\", options]` and returns either.\n */\nimport { statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorPlugin, PluginSpec } from \"./types.js\";\n\n/** Identity helper that types a plugin. */\nexport function defineDoctorPlugin(plugin: DoctorPlugin): DoctorPlugin {\n return plugin;\n}\n\nexport async function loadPlugins(specs: PluginSpec[] | undefined, configDir: string): Promise<DoctorPlugin[]> {\n const plugins: DoctorPlugin[] = [];\n for (const spec of specs ?? []) {\n const [id, options] = typeof spec === \"string\" ? [spec, undefined] : spec;\n const file = resolvePlugin(id, configDir);\n // The mtime query re-imports an edited module in a long-lived dev server.\n const url = `${pathToFileURL(file).href}?mtime=${statSync(file).mtimeMs}`;\n let mod: { default?: unknown };\n try {\n mod = await import(url);\n } catch (err) {\n throw new DoctorConfigError(`doctor.plugins: could not load ${id}: ${(err as Error).message}`);\n }\n let value = mod.default;\n if (typeof value === \"function\") value = await (value as (o: unknown) => unknown)(options);\n const list = Array.isArray(value) ? value : [value];\n for (const p of list) {\n if (!p || typeof p !== \"object\" || typeof (p as DoctorPlugin).check !== \"function\" || typeof (p as DoctorPlugin).name !== \"string\") {\n throw new DoctorConfigError(`doctor.plugins: ${id} must default-export { name, check(context) } (or an array, or a factory returning one)`);\n }\n plugins.push(p as DoctorPlugin);\n }\n }\n return plugins;\n}\n\nfunction resolvePlugin(id: string, configDir: string): string {\n try {\n if (id.startsWith(\".\") || path.isAbsolute(id)) return resolveFrom(path.resolve(configDir, id), configDir);\n return resolveFrom(id, configDir);\n } catch {\n throw new DoctorConfigError(`doctor.plugins: cannot find ${id} (relative paths resolve from ${configDir})`);\n }\n}\n\nfunction resolveFrom(id: string, from: string): string {\n return createRequire(path.join(from, \"noop.js\")).resolve(id);\n}\n","/**\n * The built-in, app-agnostic checks. Each is driven by facts read from the\n * installed Genesis packages, never by a hardcoded component or token list.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { findColorFunctions, findHexLiterals } from \"../../../../scripts/lib/color-literals.mjs\";\nimport { globMatcher } from \"./glob.js\";\nimport { declaredTokens } from \"./genesis.js\";\nimport type { DoctorContext, SourceFile } from \"./types.js\";\n\n/** Ids of the built-in rules, for `rules` overrides and `allow` entries. */\nexport const BUILTIN_RULES = [\n \"local-primitives\",\n \"starter-leftover\",\n \"forbidden-import\",\n \"raw-tag\",\n \"palette-color\",\n \"arbitrary-color\",\n \"raw-color\",\n \"undefined-token\",\n \"shadowed-export\",\n \"version-skew\",\n // native pack\n \"native-raw-primitive\",\n \"native-literal-color\",\n \"native-custom-header\",\n \"native-screen-layout\",\n \"store-readiness\",\n // supabase pack\n \"migration-grants\",\n \"migration-rls\",\n \"migration-definer-search-path\",\n \"migration-edited\",\n] as const;\n\nexport const DEFAULT_LOCAL_PRIMITIVE_DIRS = [\"src/components/ui\"];\nconst STARTER_LEFTOVERS = [\"components.json\", \"src/lib/utils.ts\"];\nconst DEFAULT_IGNORE_TOKEN_PREFIXES = [\"--tw-\", \"--radix-\"];\n\nconst JSX_EXTS = new Set([\".tsx\", \".jsx\"]);\nconst SCRIPT_EXTS = new Set([\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".mjs\", \".cjs\"]);\n\n/** Every module specifier a file imports or re-exports, with its 1-based line. */\nexport function importSpecifiers(file: SourceFile): Array<{ specifier: string; line: number }> {\n const out: Array<{ specifier: string; line: number }> = [];\n const lines = file.code.split(\"\\n\");\n const re = /(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*|@import\\s+)[\"']([^\"']+)[\"']/g;\n lines.forEach((text, i) => {\n for (const m of text.matchAll(re)) out.push({ specifier: m[1], line: i + 1 });\n });\n return out;\n}\n\nexport function checkProjectLayout(ctx: DoctorContext): void {\n for (const dir of ctx.config.localPrimitiveDirs ?? DEFAULT_LOCAL_PRIMITIVE_DIRS) {\n if (existsSync(path.join(ctx.root, dir))) {\n ctx.report({\n rule: \"local-primitives\",\n file: dir,\n subject: dir,\n message: `is a local design-system primitive folder; use ${ctx.genesis.uiPackage} (or extend it upstream)`,\n });\n }\n }\n for (const file of STARTER_LEFTOVERS) {\n if (existsSync(path.join(ctx.root, file))) {\n ctx.report({\n rule: \"starter-leftover\",\n level: \"warn\",\n file,\n subject: file,\n message: `is a starter leftover; Genesis ships cn and owns the components`,\n });\n }\n }\n}\n\nexport function checkImports(ctx: DoctorContext): void {\n const ui = ctx.genesis.uiPackage;\n const forbidden: Array<[RegExp, string]> = [\n [/^@radix-ui\\//, `imports Radix directly; use the Genesis wrapper from ${ui}`],\n [/^(?:[@~#]\\/|\\.{1,2}\\/)(?:.*\\/)?components\\/ui(?:\\/|$)/, `imports a local UI primitive; use ${ui}`],\n [/^[@~#]\\/lib\\/utils$/, `imports the starter's utils; use cn from ${ui}`],\n ...Object.entries(ctx.config.forbiddenImports ?? {}).map(([re, msg]) => [new RegExp(re), msg] as [RegExp, string]),\n ];\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n for (const { specifier, line } of importSpecifiers(file)) {\n const hit = forbidden.find(([re]) => re.test(specifier));\n if (hit) ctx.report({ rule: \"forbidden-import\", file: file.path, line, subject: specifier, message: `${hit[1]} ('${specifier}')` });\n }\n }\n}\n\nexport function checkRawTags(ctx: DoctorContext): void {\n const tags = [...ctx.genesis.rawTags].map(([tag, component]) => [tag, component, new RegExp(`<${tag}(?=[\\\\s>/]|$)`)] as const);\n if (tags.length === 0) return;\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext)) continue;\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const [tag, component, re] of tags) {\n if (re.test(text)) {\n ctx.report({ rule: \"raw-tag\", file: file.path, line: i + 1, subject: tag, message: `renders a raw <${tag}>; use Genesis ${component}` });\n }\n }\n });\n }\n}\n\n/** Tailwind utilities that take a color. */\nconst COLOR_UTILITIES = \"bg|text|border(?:-[xytrbls])?|ring|ring-offset|fill|stroke|from|to|via|outline|divide|decoration|shadow|accent|caret|placeholder\";\nconst ARBITRARY_COLOR_RE = /(?<![\\w-])[a-z][a-z-]*-\\[(?:#|(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\\()[^\\]]*\\]/g;\n\nexport function checkColors(ctx: DoctorContext): void {\n const palette = new RegExp(\n `(?<![\\\\w-])(?:${COLOR_UTILITIES})-(?:${ctx.genesis.palette.join(\"|\")})(?:-\\\\d{2,3})?(?:\\\\/\\\\d{1,3})?(?![\\\\w-])`,\n \"g\",\n );\n // With the native pack, literals in code are style values: report them as native-literal-color with the native fix.\n const native = ctx.config.packs?.includes(\"native\") ?? false;\n const themeRoles = ctx.genesis.values.has(\"useThemeRoles\") ? \"a theme role (useThemeRoles())\" : \"a theme role\";\n for (const file of ctx.files) {\n const nativeCode = native && SCRIPT_EXTS.has(file.ext);\n file.code.split(\"\\n\").forEach((text, i) => {\n const line = i + 1;\n for (const m of text.matchAll(palette)) {\n ctx.report({ rule: \"palette-color\", file: file.path, line, subject: m[0], message: `uses the literal palette color '${m[0]}'; use a semantic token (bg-primary, text-muted-foreground, …)` });\n }\n // Arbitrary values are reported once, as arbitrary-color, not again as raw-color.\n const arbitrary: Array<[number, number]> = [];\n for (const m of text.matchAll(ARBITRARY_COLOR_RE)) {\n arbitrary.push([m.index!, m.index! + m[0].length]);\n ctx.report({ rule: \"arbitrary-color\", file: file.path, line, subject: m[0], message: `uses the arbitrary color '${m[0]}'; define it as a brand token first` });\n }\n for (const hit of [...findHexLiterals(text), ...findColorFunctions(text)]) {\n const at = hit.column - 1;\n if (arbitrary.some(([a, b]) => at >= a && at < b)) continue;\n if (nativeCode) {\n ctx.report({\n rule: \"native-literal-color\",\n file: file.path,\n line,\n subject: hit.literal,\n message: `hardcodes the color ${hit.literal}; use ${themeRoles}, a token className (bg-primary, text-muted-foreground) or PlatformColor(...)`,\n });\n continue;\n }\n ctx.report({ rule: \"raw-color\", file: file.path, line, subject: hit.literal, message: `hardcodes the color ${hit.literal}; color values come from Genesis tokens` });\n }\n });\n }\n}\n\nexport function checkTokens(ctx: DoctorContext): void {\n const defined = new Set(ctx.genesis.tokens);\n const isTokenFile = ctx.config.tokenFiles ? globMatcher(ctx.config.tokenFiles) : (p: string) => p.endsWith(\".css\");\n for (const file of ctx.files) {\n if (isTokenFile(file.path)) for (const t of declaredTokens(file.code)) defined.add(t);\n // A custom property set inline (style={{ \"--progress\": \"40%\" }}) is a runtime variable, not a token.\n for (const m of file.code.matchAll(/[\"'](--[A-Za-z0-9_-]+)[\"']\\s*:/g)) defined.add(m[1]);\n }\n // Token files outside the scanned folders (e.g. a brand package).\n for (const pattern of ctx.config.tokenFiles ?? []) {\n if (/[*?]/.test(pattern)) continue;\n const abs = path.join(ctx.root, pattern);\n if (!ctx.files.some((f) => f.absolutePath === abs) && existsSync(abs)) {\n for (const t of declaredTokens(readFileSync(abs, \"utf8\"))) defined.add(t);\n }\n }\n const ignorePrefixes = ctx.config.ignoreTokenPrefixes ?? DEFAULT_IGNORE_TOKEN_PREFIXES;\n for (const file of ctx.files) {\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const m of text.matchAll(/var\\(\\s*(--[A-Za-z0-9_-]+)/g)) {\n const token = m[1];\n if (defined.has(token) || ignorePrefixes.some((p) => token.startsWith(p))) continue;\n ctx.report({ rule: \"undefined-token\", file: file.path, line: i + 1, subject: token, message: `references the undefined token ${token}; define it in Genesis or the brand` });\n }\n });\n }\n}\n\nexport function checkShadowedExports(ctx: DoctorContext): void {\n const re = /\\bexport\\s+(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?(?:function\\*?|const|let|var|class)\\s+([A-Z][\\w$]*)/g;\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const m of text.matchAll(re)) {\n if (!ctx.genesis.values.has(m[1])) continue;\n ctx.report({ rule: \"shadowed-export\", file: file.path, line: i + 1, subject: m[1], message: `shadows the Genesis export '${m[1]}'; reuse or extend Genesis ${m[1]}` });\n }\n });\n }\n}\n\n/** Genesis components that no scanned file imports (named imports or re-exports from the package or its subpaths). */\nexport function unusedComponents(ctx: Pick<DoctorContext, \"files\" | \"genesis\">): string[] {\n const used = new Set<string>();\n const pkg = ctx.genesis.uiPackage.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n const re = new RegExp(`\\\\b(?:import|export)\\\\s+(?:type\\\\s+)?(?:[\\\\w$]+\\\\s*,\\\\s*)?\\\\{([^}]*)\\\\}\\\\s*from\\\\s*[\"']${pkg}(?:/[^\"']*)?[\"']`, \"g\");\n for (const file of ctx.files) {\n for (const m of file.code.matchAll(re)) {\n for (const part of m[1].split(\",\")) {\n const name = part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim();\n if (name) used.add(name);\n }\n }\n }\n return ctx.genesis.components.filter((c) => !used.has(c));\n}\n\n","/**\n * native-primitives.mjs — the React Native primitives Genesis wraps, shared by\n * scripts/check-forbidden-imports.mjs and `genesis doctor`'s native pack\n * (packages/genesis-cli, which bundles this file at build time). One list, so\n * the repo gate and the doctor can't drift.\n *\n * Importing the raw primitive skips Genesis theming and a11y defaults. Keep the\n * list small and intentional: `View`, `Text`, `Pressable`, `ScrollView`,\n * `StyleSheet` stay free imports because layout and performance code needs\n * them. Expanding it is a design-system decision, not a CI tweak.\n *\n * Pure data and functions only: no filesystem, no process state.\n */\n\n/** Primitive → the Genesis components that replace it (the doctor names the ones the installed package exports). */\nexport const NATIVE_WRAPPED_PRIMITIVES = Object.freeze({\n Modal: Object.freeze(['NativeDialog', 'NativeSheet', 'NativeDrawer']),\n ActivityIndicator: Object.freeze(['NativeSkeleton', 'NativeProgress']),\n});\n\n/**\n * The wrapped primitives named in one import (or export-from) clause's `{ ... }` list,\n * aliases resolved to the imported name. Type-only entries (`type Modal`) are skipped:\n * they never render anything.\n */\nexport function wrappedPrimitivesIn(namedImports) {\n return namedImports\n .split(',')\n .map((n) => n.trim())\n .filter((n) => n && !/^type\\s/.test(n))\n .map((n) => n.split(/\\s+as\\s+/)[0].trim())\n .filter((n) => n && Object.hasOwn(NATIVE_WRAPPED_PRIMITIVES, n));\n}\n","/**\n * `withGenesis()` — the Genesis Expo config plugin.\n *\n * Keeps an app's `app.config.ts` to a name, ids and plugins. It sets:\n *\n * 1. App variants: `APP_VARIANT` (`development` | `preview` | `production`,\n * default `production`) suffixes the bundle id, Android package and name,\n * so the three builds install side by side.\n * 2. Universal / app links from genesis.config.json `links`:\n * `ios.associatedDomains` (`applinks:` and `webcredentials:`) and one\n * Android `intentFilters` entry with `autoVerify`.\n * 3. The iOS privacy manifest's required-reason APIs for the packages the\n * app's package.json lists, merged into what the app declares.\n * 4. Export compliance: `ios.config.usesNonExemptEncryption = false`.\n * 5. `runtimeVersion: { policy: \"fingerprint\" }`.\n *\n * Anything the app already sets wins: the plugin fills gaps and appends to\n * lists, never overwrites or removes a value, and running it twice changes\n * nothing.\n *\n * Determinism: the plugin reads two committed files in the project root,\n * genesis.config.json and package.json, and one environment variable,\n * APP_VARIANT. No network, no clock, no other environment. The same commit\n * and variant always give the same config; the EAS fingerprint is stable only\n * if APP_VARIANT is set the same way for builds, `eas update` and fingerprint\n * checks (an EAS environment variable, not a build profile's `env`).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ConfigPlugin } from \"@expo/config-plugins\";\nimport type { ExpoConfig } from \"@expo/config-types\";\nimport { GenesisConfigError, readGenesisConfig, type GenesisLinks } from \"./doctor/config.js\";\n\nexport { GenesisConfigError, validateLinks, readGenesisConfig, type GenesisLinks } from \"./doctor/config.js\";\n\nexport const APP_VARIANTS = [\"development\", \"preview\", \"production\"] as const;\nexport type AppVariant = (typeof APP_VARIANTS)[number];\n\nexport interface VariantSuffix {\n /** Appended to `ios.bundleIdentifier` and `android.package`, e.g. `.dev`. */\n id: string;\n /** Appended to `name`, e.g. ` (Dev)`. */\n name: string;\n}\n\n/** A required-reason API category and the reasons for it, as in PrivacyInfo.xcprivacy. */\nexport interface PrivacyApi {\n NSPrivacyAccessedAPIType: string;\n NSPrivacyAccessedAPITypeReasons: string[];\n}\n\nexport interface WithGenesisOptions {\n /**\n * The variant, overriding `APP_VARIANT`. Tests and scripts pass it; an app\n * leaves it out and sets `APP_VARIANT` per build profile in eas.json.\n */\n variant?: AppVariant;\n /** Suffixes per non-production variant. Default `.dev` / ` (Dev)` and `.preview` / ` (Preview)`. */\n variants?: Partial<Record<Exclude<AppVariant, \"production\">, Partial<VariantSuffix>>>;\n /** Where genesis.config.json and package.json live. Default: the Expo project root. */\n projectRoot?: string;\n /** Turn single steps off. Every step is on by default. */\n links?: boolean;\n privacyManifest?: boolean;\n exportCompliance?: boolean;\n fingerprint?: boolean;\n}\n\nexport const DEFAULT_VARIANT_SUFFIXES: Record<Exclude<AppVariant, \"production\">, VariantSuffix> = {\n development: { id: \".dev\", name: \" (Dev)\" },\n preview: { id: \".preview\", name: \" (Preview)\" },\n};\n\n/**\n * The required-reason APIs each package needs the app to declare, copied from\n * the package's own PrivacyInfo.xcprivacy. A package is matched when the\n * app's package.json lists it in `dependencies`.\n *\n * - async-storage (2.2.0 `ios/PrivacyInfo.xcprivacy`): FileTimestamp, C617.1.\n *\n * expo-secure-store is not listed: the Keychain is not a required-reason API.\n */\nexport const PRIVACY_APIS: Record<string, PrivacyApi[]> = {\n \"@react-native-async-storage/async-storage\": [\n { NSPrivacyAccessedAPIType: \"NSPrivacyAccessedAPICategoryFileTimestamp\", NSPrivacyAccessedAPITypeReasons: [\"C617.1\"] },\n ],\n};\n\n/** The variant from options, else `APP_VARIANT`, else production. An unknown value throws. */\nexport function resolveVariant(given?: string): AppVariant {\n const value = given ?? process.env.APP_VARIANT ?? \"production\";\n if (!(APP_VARIANTS as readonly string[]).includes(value)) {\n throw new GenesisConfigError(`APP_VARIANT is \"${value}\"; expected one of ${APP_VARIANTS.join(\", \")}`);\n }\n return value as AppVariant;\n}\n\nexport function applyVariant(config: ExpoConfig, variant: AppVariant, options: WithGenesisOptions[\"variants\"] = {}): ExpoConfig {\n if (variant === \"production\") return config;\n const suffix = { ...DEFAULT_VARIANT_SUFFIXES[variant], ...options[variant] };\n // A value that already ends in the suffix was suffixed by an earlier run: leave it.\n const add = (value: string, end: string) => (end && value.endsWith(end) ? value : value + end);\n const next: ExpoConfig = { ...config, name: add(config.name, suffix.name) };\n if (config.ios?.bundleIdentifier) next.ios = { ...config.ios, bundleIdentifier: add(config.ios.bundleIdentifier, suffix.id) };\n if (config.android?.package) next.android = { ...config.android, package: add(config.android.package, suffix.id) };\n return next;\n}\n\nexport function applyLinks(config: ExpoConfig, links: GenesisLinks | undefined): ExpoConfig {\n if (!links) return config;\n const services = links.webcredentials === false ? [\"applinks\"] : [\"applinks\", \"webcredentials\"];\n const domains = links.hosts.flatMap((host) => services.map((service) => `${service}:${host}`));\n const associatedDomains = union(config.ios?.associatedDomains ?? [], domains);\n\n const data = links.hosts.flatMap((host) =>\n links.paths?.length ? links.paths.map((pathPrefix) => ({ scheme: \"https\", host, pathPrefix })) : [{ scheme: \"https\", host }],\n );\n const filter = { action: \"VIEW\", autoVerify: true, data, category: [\"BROWSABLE\", \"DEFAULT\"] };\n const existing = config.android?.intentFilters ?? [];\n const intentFilters = existing.some((f) => JSON.stringify(f) === JSON.stringify(filter)) ? existing : [...existing, filter];\n\n return {\n ...config,\n ios: { ...config.ios, associatedDomains },\n android: { ...config.android, intentFilters },\n };\n}\n\n/** The required-reason APIs for the packages listed in package.json `dependencies`. */\nexport function privacyApisFor(dependencies: Record<string, unknown>): PrivacyApi[] {\n return Object.keys(PRIVACY_APIS)\n .filter((pkg) => pkg in dependencies)\n .flatMap((pkg) => PRIVACY_APIS[pkg]!);\n}\n\n/** Merge required-reason APIs into `ios.privacyManifests`, keeping every entry and reason the app declares. */\nexport function applyPrivacyApis(config: ExpoConfig, apis: PrivacyApi[]): ExpoConfig {\n if (apis.length === 0) return config;\n const manifests = config.ios?.privacyManifests ?? {};\n const types = (manifests.NSPrivacyAccessedAPITypes ?? []).map((t) => ({ ...t, NSPrivacyAccessedAPITypeReasons: [...t.NSPrivacyAccessedAPITypeReasons] }));\n for (const api of apis) {\n const found = types.find((t) => t.NSPrivacyAccessedAPIType === api.NSPrivacyAccessedAPIType);\n if (found) found.NSPrivacyAccessedAPITypeReasons = union(found.NSPrivacyAccessedAPITypeReasons, api.NSPrivacyAccessedAPITypeReasons);\n else types.push({ ...api, NSPrivacyAccessedAPITypeReasons: [...api.NSPrivacyAccessedAPITypeReasons] });\n }\n return { ...config, ios: { ...config.ios, privacyManifests: { ...manifests, NSPrivacyAccessedAPITypes: types } } };\n}\n\nexport function applyExportCompliance(config: ExpoConfig): ExpoConfig {\n if (config.ios?.config?.usesNonExemptEncryption !== undefined) return config;\n return { ...config, ios: { ...config.ios, config: { ...config.ios?.config, usesNonExemptEncryption: false } } };\n}\n\nexport function applyFingerprint(config: ExpoConfig): ExpoConfig {\n if (config.runtimeVersion !== undefined || config.ios?.runtimeVersion !== undefined || config.android?.runtimeVersion !== undefined) {\n return config;\n }\n return { ...config, runtimeVersion: { policy: \"fingerprint\" } };\n}\n\n/** The Genesis config plugin. Use it in `plugins` or call it directly in app.config.ts. */\nexport const withGenesis: ConfigPlugin<WithGenesisOptions | void> = (config, props) => {\n const options = props ?? {};\n const root = options.projectRoot ?? (config as { _internal?: { projectRoot?: string } })._internal?.projectRoot ?? process.cwd();\n let next = applyVariant(config, resolveVariant(options.variant), options.variants);\n if (options.links !== false) next = applyLinks(next, readGenesisConfig(root)?.links);\n if (options.privacyManifest !== false) next = applyPrivacyApis(next, privacyApisFor(readDependencies(root)));\n if (options.exportCompliance !== false) next = applyExportCompliance(next);\n if (options.fingerprint !== false) next = applyFingerprint(next);\n return next;\n};\n\nexport default withGenesis;\n\nfunction readDependencies(root: string): Record<string, unknown> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return {};\n try {\n const deps = JSON.parse(readFileSync(file, \"utf8\"))?.dependencies;\n return deps && typeof deps === \"object\" ? deps : {};\n } catch (err) {\n throw new GenesisConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\nfunction union(a: string[], b: string[]): string[] {\n return [...new Set([...a, ...b])];\n}\n","/**\n * The `native` pack: rules for Expo / React Native apps on\n * `@marktiderman/genesis-ui-native`. Turned on with `doctor.packs: [\"native\"]`.\n *\n * The screen layouts and replacements are read from the installed native\n * package's declarations, like the core rules read the web package; the\n * wrapped-primitive list is shared with the repo's check-forbidden-imports\n * gate. Literal colors in native code are reported by rules.ts checkColors\n * as `native-literal-color`.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { NATIVE_WRAPPED_PRIMITIVES, wrappedPrimitivesIn } from \"../../../../scripts/lib/native-primitives.mjs\";\nimport { privacyApisFor } from \"../expo.js\";\nimport { DoctorConfigError } from \"./config.js\";\nimport { NATIVE_UI_PACKAGE, readPackageExports, type PackageExports } from \"./genesis.js\";\nimport { lineAt } from \"./scan.js\";\nimport type { DoctorContext, SourceFile } from \"./types.js\";\n\nconst SCRIPT_EXTS = new Set([\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".mjs\", \".cjs\"]);\nconst JSX_EXTS = new Set([\".tsx\", \".jsx\"]);\nconst RESOLVE_EXTS = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n\n/** A Genesis screen layout: an exported component named `…Page`, `…Screen` or `ScreenContainer`. */\nconst LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$/;\n/** Route files Expo Router treats as non-screens. */\nconst NON_SCREEN_ROUTE = /(?:^|\\/)(?:_layout|\\+html|\\+native-intent|\\+middleware)\\.[jt]sx?$|\\+api\\.[jt]sx?$/;\n/** Header-named components that head a section of a screen, not the screen. */\nconst PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;\nconst HIDES_HEADER = /\\bheaderShown\\s*(?::|=\\s*\\{)\\s*false\\b/;\n\n/** The installed native package (also when `uiPackage` points the core rules at the web one). */\nfunction nativePackage(ctx: DoctorContext): PackageExports {\n const pkg = readPackageExports(ctx.root, NATIVE_UI_PACKAGE);\n if (!pkg) throw new DoctorConfigError(`the native pack needs ${NATIVE_UI_PACKAGE}; install it, or remove \"native\" from doctor.packs`);\n return pkg;\n}\n\n/** Genesis screen layouts the installed native package exports, sorted. */\nexport function nativeLayouts(pkg: Pick<PackageExports, \"components\">): string[] {\n return pkg.components.filter((n) => LAYOUT_NAME.test(n));\n}\n\nexport function checkNativePack(ctx: DoctorContext): void {\n const pkg = nativePackage(ctx);\n checkRawPrimitives(ctx, pkg);\n checkCustomHeaders(ctx, pkg);\n checkScreenLayouts(ctx, pkg);\n checkStoreReadiness(ctx);\n}\n\nconst RN = String.raw`[\"']react-native[\"']`;\n\n/** `native-raw-primitive`: a React Native primitive Genesis wraps, taken from react-native at runtime. */\nfunction checkRawPrimitives(ctx: DoctorContext, pkg: PackageExports): void {\n const wrapped = Object.keys(NATIVE_WRAPPED_PRIMITIVES);\n const named = [\n // import { Modal } / import RN, { Modal }; `import type { … }` doesn't match.\n new RegExp(String.raw`\\bimport\\s+(?:[\\w$]+\\s*,\\s*)?\\{([^}]*)\\}\\s*from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\bexport\\s+\\{([^}]*)\\}\\s*from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\b(?:const|let|var)\\s*\\{([^}]*)\\}\\s*=\\s*require\\(\\s*${RN}\\s*\\)`, \"g\"),\n ];\n const namespaces = [\n new RegExp(String.raw`\\bimport\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\b(?:const|let|var)\\s+([\\w$]+)\\s*=\\s*require\\(\\s*${RN}\\s*\\)`, \"g\"),\n ];\n const member = new RegExp(String.raw`\\brequire\\(\\s*${RN}\\s*\\)\\.(${wrapped.join(\"|\")})\\b`, \"g\");\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n const code = file.code;\n const report = (name: string, at: number) => {\n const use = NATIVE_WRAPPED_PRIMITIVES[name].filter((c) => pkg.values.has(c));\n ctx.report({\n rule: \"native-raw-primitive\",\n file: file.path,\n line: lineAt(code, at),\n subject: name,\n message: `uses ${name} from react-native, which Genesis wraps; use ${use.length ? use.join(\" or \") : \"the Genesis wrapper\"} from ${NATIVE_UI_PACKAGE}`,\n });\n };\n for (const re of named) {\n for (const m of code.matchAll(re)) {\n for (const name of wrappedPrimitivesIn(m[1].replace(/:/g, \" as \"))) report(name, m.index! + m[0].indexOf(name));\n }\n }\n for (const re of namespaces) {\n for (const m of code.matchAll(re)) {\n for (const use of code.matchAll(new RegExp(String.raw`\\b${m[1].replace(/\\$/g, \"\\\\$\")}\\.(${wrapped.join(\"|\")})\\b`, \"g\"))) report(use[1], use.index!);\n }\n }\n for (const m of code.matchAll(member)) report(m[1], m.index!);\n }\n}\n\n/** A JSX element matching `re` that Genesis doesn't export and that isn't a section header: the app's own header or bar. */\nfunction customElement(code: string, re: RegExp, pkg: PackageExports): { name: string; index: number } | null {\n for (const m of code.matchAll(re)) {\n const name = m[1];\n if (!pkg.values.has(name.split(\".\")[0]) && !PART_HEADER.test(name)) return { name, index: m.index! };\n }\n return null;\n}\n\n/** The screen's own header: a `<…Header>` of the app's own, or `style={styles.header}`. */\nfunction ownHeader(code: string, pkg: PackageExports): { name: string; index: number } | null {\n const el = customElement(code, /<([A-Z][\\w$]*Header)\\b/g, pkg);\n if (el) return el;\n const style = /\\bstyle=\\{\\s*styles\\.header\\s*\\}/.exec(code);\n return style ? { name: \"styles.header\", index: style.index } : null;\n}\n\n/** `native-custom-header`: the navigator header turned off and a hand-drawn one rendered, or a hand-built tab bar. */\nfunction checkCustomHeaders(ctx: DoctorContext, pkg: PackageExports): void {\n const layouts = nativeLayouts(pkg);\n if (layouts.length === 0) return;\n const headerWay = pkg.values.has(\"ScreenContainer\")\n ? `ScreenContainer's header props${pkg.values.has(\"composeHeaderOptions\") ? \" (composeHeaderOptions)\" : \"\"}`\n : `a Genesis layout's header (${layouts.join(\", \")})`;\n const rootDir = routerRoot(ctx);\n const reported = new Set<string>();\n /** Folders whose _layout hides the header for the screens beside it. */\n const hidingLayouts = new Map<string, string>();\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext)) continue;\n const code = file.code;\n const hidden = HIDES_HEADER.exec(code);\n if (hidden && /(?:^|\\/)_layout\\.[jt]sx$/.test(file.path)) hidingLayouts.set(path.posix.dirname(file.path), file.path);\n const own = hidden ? ownHeader(code, pkg) : null;\n if (hidden && own) {\n reported.add(file.path);\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(code, hidden.index),\n subject: own.name,\n message: `hides the navigator header and draws its own (${own.name}); use ${headerWay} so the title, back button and large-title behavior stay native`,\n });\n }\n const tabBarProp = /<Tabs\\b/.test(code) ? /\\btabBar\\s*=\\s*\\{/.exec(code) : null;\n const tabBar = tabBarProp ? { name: \"tabBar prop\", index: tabBarProp.index } : customElement(code, /<([A-Z][\\w$]*TabBar)\\b/g, pkg);\n if (tabBar) {\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(code, tabBar.index),\n subject: tabBar.name,\n message: `builds a tab bar by hand (${tabBar.name}); use the router's native <Tabs> bar, themed through Genesis screenOptions`,\n });\n }\n }\n // A layout that hides the header for its stack, and a screen in it that draws one.\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext) || reported.has(file.path) || !file.path.startsWith(`${rootDir}/`) || NON_SCREEN_ROUTE.test(file.path)) continue;\n const layout = hidingLayouts.get(path.posix.dirname(file.path));\n const own = layout ? ownHeader(file.code, pkg) : null;\n if (!layout || !own) continue;\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(file.code, own.index),\n subject: own.name,\n message: `draws its own header (${own.name}) while ${layout} hides the navigator's; use ${headerWay} so the title, back button and large-title behavior stay native`,\n });\n }\n}\n\n/** The Expo Router root: `native.routerRoot`, else `src/app`, else `app`. */\nexport function routerRoot(ctx: Pick<DoctorContext, \"root\" | \"config\">): string {\n if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\\/+$/, \"\");\n return existsSync(path.join(ctx.root, \"src\", \"app\")) ? \"src/app\" : \"app\";\n}\n\n/** `native-screen-layout`: a route screen that doesn't render a Genesis screen layout (directly or through one local import). */\nfunction checkScreenLayouts(ctx: DoctorContext, pkg: PackageExports): void {\n const layouts = nativeLayouts(pkg);\n if (layouts.length === 0) return;\n const rootDir = routerRoot(ctx);\n if (!existsSync(path.join(ctx.root, rootDir))) {\n ctx.report({ rule: \"native-screen-layout\", level: \"warn\", file: rootDir, message: `no Expo Router root at ${rootDir}; set doctor.native.routerRoot` });\n return;\n }\n const routes = ctx.files.filter((f) => f.path.startsWith(`${rootDir}/`));\n if (routes.length === 0) {\n ctx.report({\n rule: \"native-screen-layout\",\n level: \"warn\",\n file: rootDir,\n message: `no scanned file is under the router root ${rootDir}, so no screen was checked; add it to doctor.src`,\n });\n return;\n }\n const renders = new RegExp(`<(?:${layouts.join(\"|\")}|Redirect)\\\\b`);\n const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));\n for (const file of routes) {\n if (!JSX_EXTS.has(file.ext) || NON_SCREEN_ROUTE.test(file.path)) continue;\n // A route that only re-exports a screen, or renders no JSX, is judged where the screen lives.\n if (!/\\bexport\\s+default\\b/.test(file.code) || !/<[A-Za-z]/.test(file.code)) continue;\n if (renders.test(file.code)) continue;\n const viaImport = localImports(ctx.root, file).some((abs) => {\n const target = byPath.get(abs) ?? readSource(abs);\n return target !== null && renders.test(target.code);\n });\n if (viaImport) continue;\n ctx.report({\n rule: \"native-screen-layout\",\n level: \"warn\",\n file: file.path,\n message: `doesn't render a Genesis screen layout (${layouts.join(\", \")}); wrap the screen in one so the header, safe area and scrolling match every other screen`,\n });\n }\n}\n\n/** Files a source imports by relative path or the `@/` / `~/` root aliases, resolved to absolute paths that exist. */\nfunction localImports(root: string, file: SourceFile): string[] {\n const out: string[] = [];\n for (const m of file.code.matchAll(/\\bfrom\\s*[\"']((?:\\.{1,2}|[@~])\\/[^\"']+)[\"']/g)) {\n const spec = m[1];\n const bases = spec.startsWith(\".\")\n ? [path.resolve(path.dirname(file.absolutePath), spec)]\n : [path.join(root, spec.slice(2)), path.join(root, \"src\", spec.slice(2))];\n for (const base of bases) {\n const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path.join(base, `index${e}`))].find(\n (p) => SCRIPT_EXTS.has(path.extname(p)) && existsSync(p),\n );\n if (hit) {\n out.push(hit);\n break;\n }\n }\n }\n return out;\n}\n\nfunction readSource(abs: string): Pick<SourceFile, \"code\"> | null {\n try {\n return { code: readFileSync(abs, \"utf8\") };\n } catch {\n return null;\n }\n}\n\n// ---- store-readiness ----\n\n/**\n * Modules that need an iOS usage string: the Info.plist key, and the config-plugin\n * option that sets it (`false` opts out). `maybe`: the module works without that\n * permission (playback only, picking from the library), so the string may not be needed.\n */\nconst PERMISSIONS: ReadonlyArray<{ module: string; key: string; option: string; maybe?: string }> = [\n { module: \"expo-camera\", key: \"NSCameraUsageDescription\", option: \"cameraPermission\" },\n { module: \"expo-image-picker\", key: \"NSPhotoLibraryUsageDescription\", option: \"photosPermission\" },\n { module: \"expo-image-picker\", key: \"NSCameraUsageDescription\", option: \"cameraPermission\", maybe: \"takes photos with the camera\" },\n { module: \"expo-media-library\", key: \"NSPhotoLibraryUsageDescription\", option: \"photosPermission\" },\n { module: \"expo-location\", key: \"NSLocationWhenInUseUsageDescription\", option: \"locationWhenInUsePermission\" },\n { module: \"expo-av\", key: \"NSMicrophoneUsageDescription\", option: \"microphonePermission\", maybe: \"records audio\" },\n { module: \"expo-audio\", key: \"NSMicrophoneUsageDescription\", option: \"microphonePermission\", maybe: \"records audio\" },\n { module: \"expo-contacts\", key: \"NSContactsUsageDescription\", option: \"contactsPermission\" },\n { module: \"expo-local-authentication\", key: \"NSFaceIDUsageDescription\", option: \"faceIDPermission\" },\n];\n/** Packages that are a third-party sign-in (App Store guideline 4.8). */\nconst SOCIAL_SIGN_IN = [\"@react-native-google-signin/google-signin\", \"react-native-fbsdk-next\"];\n/** Used for sign-in and for other OAuth flows alike: mentioned, never enough on its own. */\nconst WEAK_SOCIAL_SIGN_IN = [\"expo-auth-session\"];\nconst APPLE_SIGN_IN = [\"expo-apple-authentication\", \"@invertase/react-native-apple-authentication\"];\nconst EXPO_CONFIGS = [\"app.json\", \"app.config.json\", \"app.config.ts\", \"app.config.js\", \"app.config.mjs\", \"app.config.cjs\"];\nconst SUPABASE_SIGN_IN = /\\bsignInWith(?:OAuth|IdToken)\\s*\\(\\s*\\{\\s*provider\\s*:\\s*[\"']([\\w-]+)[\"']/g;\n/** This package's Expo config plugin, as `plugins` lists it. */\nconst GENESIS_PLUGIN = \"@marktiderman/genesis-cli\";\nconst GENESIS_PLUGIN_TEXT = /[\"']@marktiderman\\/genesis-cli(?:\\/expo)?[\"']|\\bwithGenesis\\s*\\(/;\n/** `from \"…genesis-cli…\"`, `require(\"…\")` and `import(\"…\")` of the package: naming it there isn't listing the plugin. */\nconst GENESIS_PLUGIN_IMPORT = /\\bfrom\\s*[\"']@marktiderman\\/genesis-cli[^\"']*[\"']|\\b(?:require|import)\\s*\\(\\s*[\"']@marktiderman\\/genesis-cli[^\"']*[\"']\\s*\\)/g;\n\n/** The app's Expo config as data (JSON files) plus text (dynamic configs, scanned best-effort). */\ninterface ExpoConfig {\n file: string;\n json: Record<string, unknown> | null;\n text: string;\n}\n\nfunction readExpoConfigs(root: string): ExpoConfig[] {\n const out: ExpoConfig[] = [];\n for (const name of EXPO_CONFIGS) {\n const abs = path.join(root, name);\n if (!existsSync(abs)) continue;\n const text = readFileSync(abs, \"utf8\");\n let json: Record<string, unknown> | null = null;\n if (name.endsWith(\".json\")) {\n try {\n const raw = JSON.parse(text) as Record<string, unknown>;\n json = (raw.expo as Record<string, unknown> | undefined) ?? raw;\n } catch (err) {\n throw new DoctorConfigError(`${name} is not valid JSON: ${(err as Error).message}`);\n }\n }\n out.push({ file: name, json, text });\n }\n return out;\n}\n\nfunction get(obj: unknown, keys: string[]): unknown {\n let cur = obj;\n for (const k of keys) {\n if (!cur || typeof cur !== \"object\") return undefined;\n cur = (cur as Record<string, unknown>)[k];\n }\n return cur;\n}\n\n/** A config plugin's entry in `plugins`: its options (`{}` when listed without any), or null when it isn't listed. */\nfunction pluginOptions(json: Record<string, unknown> | null, module: string): Record<string, unknown> | null {\n const plugins = json?.plugins;\n if (!Array.isArray(plugins)) return null;\n for (const p of plugins) {\n if (p === module) return {};\n if (Array.isArray(p) && p[0] === module) return p[1] && typeof p[1] === \"object\" ? (p[1] as Record<string, unknown>) : {};\n }\n return null;\n}\n\nfunction dependencies(root: string): Set<string> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return new Set();\n const pkg = JSON.parse(readFileSync(file, \"utf8\")) as Record<string, Record<string, string> | undefined>;\n return new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);\n}\n\n/** `dependencies` only, as the config plugin reads them (dev tools ship nothing). */\nfunction runtimeDependencies(root: string): Record<string, unknown> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return {};\n return (JSON.parse(readFileSync(file, \"utf8\")) as { dependencies?: Record<string, unknown> }).dependencies ?? {};\n}\n\n/** `store-readiness`: static App Store checks against app.json / app.config.*. */\nexport function checkStoreReadiness(ctx: DoctorContext): void {\n const configs = readExpoConfigs(ctx.root);\n if (configs.length === 0) {\n ctx.report({ rule: \"store-readiness\", level: \"warn\", file: \"app.json\", message: \"no app.json or app.config.* found; the store checks read the Expo config\" });\n return;\n }\n const file = configs[0].file;\n const deps = dependencies(ctx.root);\n /** A setting is present in any config: the JSON path is set, or a dynamic config's text names it. */\n const has = (keys: string[], word: string) =>\n configs.some((c) => (c.json ? get(c.json, keys) !== undefined : new RegExp(`\\\\b${word}\\\\b`).test(c.text)));\n /**\n * This package's own config plugin (`withGenesis()`) is listed and its `option` isn't `false`, so\n * it sets that step when the config is evaluated. A dynamic config is read as text: the plugin's\n * name or `withGenesis(`, and no `option: false`.\n */\n const genesisPluginDoes = (option: string) =>\n configs.some((c) => {\n if (c.json) {\n const options = pluginOptions(c.json, GENESIS_PLUGIN) ?? pluginOptions(c.json, `${GENESIS_PLUGIN}/expo`);\n return options !== null && options[option] !== false;\n }\n // An import of the package (`import { withGenesis } from \"@marktiderman/genesis-cli/expo\"`)\n // doesn't list the plugin; calling `withGenesis(` or naming it in `plugins` does.\n const listed = c.text.replace(GENESIS_PLUGIN_IMPORT, \"\");\n return GENESIS_PLUGIN_TEXT.test(listed) && !new RegExp(`\\\\b${option}\\\\s*:\\\\s*false\\\\b`).test(c.text);\n });\n\n const exportCompliance =\n has([\"ios\", \"config\", \"usesNonExemptEncryption\"], \"usesNonExemptEncryption\") ||\n has([\"ios\", \"infoPlist\", \"ITSAppUsesNonExemptEncryption\"], \"ITSAppUsesNonExemptEncryption\") ||\n genesisPluginDoes(\"exportCompliance\");\n if (!exportCompliance) {\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: \"usesNonExemptEncryption\",\n message: \"sets neither ios.config.usesNonExemptEncryption nor ios.infoPlist.ITSAppUsesNonExemptEncryption; set it (false for HTTPS-only apps) so App Store Connect doesn't hold every build for the export-compliance question\",\n });\n }\n\n // Sign in with Apple, or an equivalent privacy-focused login, beside third-party sign-in (guideline 4.8).\n const social = SOCIAL_SIGN_IN.filter((d) => deps.has(d));\n let apple = APPLE_SIGN_IN.some((d) => deps.has(d));\n for (const f of ctx.files) {\n for (const m of f.code.matchAll(SUPABASE_SIGN_IN)) {\n if (m[1] === \"apple\") apple = true;\n else if (!social.includes(`Supabase ${m[1]} sign-in`)) social.push(`Supabase ${m[1]} sign-in`);\n }\n }\n if (social.length > 0 && !apple) {\n const weak = WEAK_SOCIAL_SIGN_IN.filter((d) => deps.has(d));\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file: \"package.json\",\n subject: \"sign-in-with-apple\",\n message:\n `offers third-party sign-in (${[...social, ...weak].join(\", \")}) and no Sign in with Apple. App Store guideline 4.8 asks for an equivalent login ` +\n \"that limits data collection to name and email, lets people keep their email private and doesn't track them; Sign in with Apple \" +\n \"(expo-apple-authentication, or Supabase's apple provider) is the usual one. If another option qualifies, allow this with the reason.\",\n });\n }\n\n const generic = new Map<string, string[]>();\n for (const p of PERMISSIONS) {\n if (!deps.has(p.module)) continue;\n const set = configs.some((c) => {\n if (!c.json) return new RegExp(`\\\\b(?:${p.key}|${p.option})\\\\b`).test(c.text);\n const plist = get(c.json, [\"ios\", \"infoPlist\", p.key]);\n const option = pluginOptions(c.json, p.module)?.[p.option];\n // A sentence, or `false`: Expo's documented opt-out for a permission the app doesn't use.\n return (typeof plist === \"string\" && plist.trim() !== \"\") || (typeof option === \"string\" && option.trim() !== \"\") || option === false;\n });\n if (!set) generic.set(p.key, [...(generic.get(p.key) ?? []), `${p.module}${p.maybe ? `, if the app ${p.maybe}` : \"\"}`]);\n }\n for (const [key, modules] of generic) {\n const opt = PERMISSIONS.find((p) => p.key === key)!.option;\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: key,\n message: `leaves ${key} to Expo's generic default string (${modules.join(\"; \")}), and App Review rejects generic purpose strings; set the plugin's ${opt} (or ios.infoPlist.${key}) to a sentence saying why the app needs it, or ${opt}: false if it doesn't`,\n });\n }\n\n // The plugin writes a manifest only for packages it knows need one (`privacyApisFor`).\n const pluginManifest = genesisPluginDoes(\"privacyManifest\") && privacyApisFor(runtimeDependencies(ctx.root)).length > 0;\n if (!has([\"ios\", \"privacyManifests\"], \"privacyManifests\") && !pluginManifest) {\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: \"privacyManifests\",\n message: \"has no ios.privacyManifests; declare the required-reason APIs the app uses (NSPrivacyAccessedAPITypes) so uploads aren't rejected for a missing privacy manifest\",\n });\n }\n}\n","/**\n * The `supabase` pack: rules for `supabase/migrations`. Turned on with\n * `doctor.packs: [\"supabase\"]`.\n *\n * - migration-grants: blanket function grants and grants of unexposed\n * functions or schemas to anon/public, in new or changed migrations.\n * - migration-rls: a table in an exposed schema whose row level security is off\n * after every migration has run.\n * - migration-definer-search-path: a security definer function without a pinned search_path.\n * - migration-edited: a migration that already exists on the base ref was changed.\n *\n * The SQL is read statement by statement with comments removed and string and\n * dollar-quoted bodies blanked, so text inside a function body never matches\n * (dollar-quoted bodies are kept aside for the one rule that looks inside them).\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorContext, Level } from \"./types.js\";\n\nexport const DEFAULT_MIGRATIONS = \"supabase/migrations\";\nexport const DEFAULT_BASE = \"origin/main\";\nconst DEFAULT_EXPOSED = [\"public\"];\n\nexport interface SqlStatement {\n /** The statement, lowercased, comments removed, literals blanked, whitespace collapsed. */\n sql: string;\n /** 1-based line where it starts. */\n line: number;\n /** The lowercased text of each dollar-quoted body in the statement (`do $$ … $$`, function bodies). */\n bodies: string[];\n}\n\n/** Split SQL into statements, dropping comments and blanking quoted literals and dollar-quoted bodies. */\nexport function sqlStatements(text: string): SqlStatement[] {\n const out: SqlStatement[] = [];\n let buf = \"\";\n let bodies: string[] = [];\n let line = 1;\n let start = 0;\n const flush = () => {\n const sql = buf.replace(/\\s+/g, \" \").trim().toLowerCase();\n if (sql) out.push({ sql, line: start, bodies });\n buf = \"\";\n bodies = [];\n start = 0;\n };\n const put = (s: string) => {\n if (!start && /\\S/.test(s)) start = line;\n buf += s;\n };\n let i = 0;\n while (i < text.length) {\n const ch = text[i];\n const two = text.slice(i, i + 2);\n if (ch === \"\\n\") {\n buf += \" \";\n line++;\n i++;\n } else if (two === \"--\") {\n while (i < text.length && text[i] !== \"\\n\") i++;\n } else if (two === \"/*\") {\n let depth = 0;\n while (i < text.length) {\n if (text.startsWith(\"/*\", i)) {\n depth++;\n i += 2;\n } else if (text.startsWith(\"*/\", i)) {\n depth--;\n i += 2;\n if (depth === 0) break;\n } else {\n if (text[i] === \"\\n\") line++;\n i++;\n }\n }\n buf += \" \";\n } else if (ch === \"'\") {\n // E'…' strings take backslash escapes; standard strings only double the quote.\n const escapes = /[eE]/.test(text[i - 1] ?? \"\") && !/[\\w$]/.test(text[i - 2] ?? \"\");\n put(\"'\");\n i++;\n while (i < text.length) {\n if (escapes && text[i] === \"\\\\\") i += 2;\n else if (text[i] === \"'\" && text[i + 1] === \"'\") i += 2;\n else if (text[i] === \"'\") break;\n else {\n if (text[i] === \"\\n\") line++;\n i++;\n }\n }\n put(\"'\");\n i++;\n } else if (ch === '\"') {\n // Quoted identifiers keep their name, minus the quotes.\n i++;\n while (i < text.length && text[i] !== '\"') put(text[i++]);\n i++;\n } else if (ch === \"$\" && !/[\\w$]/.test(text[i - 1] ?? \"\") && /^\\$(?:[A-Za-z_]\\w*)?\\$/.test(text.slice(i))) {\n const tag = /^\\$(?:[A-Za-z_]\\w*)?\\$/.exec(text.slice(i))![0];\n const end = text.indexOf(tag, i + tag.length);\n const stop = end === -1 ? text.length : end + tag.length;\n bodies.push(text.slice(i + tag.length, end === -1 ? text.length : end).toLowerCase());\n for (let k = i; k < stop; k++) if (text[k] === \"\\n\") line++;\n put(`${tag} ${tag}`);\n i = stop;\n } else if (ch === \";\") {\n flush();\n i++;\n } else {\n put(ch);\n i++;\n }\n }\n flush();\n return out;\n}\n\n/** `schema.name`, lowercased, defaulting the schema to public. */\nfunction qualify(name: string): string {\n const n = name.trim().toLowerCase();\n return n.includes(\".\") ? n : `public.${n}`;\n}\n\nconst schemaOf = (name: string) => name.split(\".\")[0];\n\n/** The text inside the parentheses that open at `open` (balanced), and the index after the close. */\nfunction parenthesized(sql: string, open: number): { inner: string; end: number } {\n let depth = 0;\n for (let k = open; k < sql.length; k++) {\n if (sql[k] === \"(\") depth++;\n else if (sql[k] === \")\" && --depth === 0) return { inner: sql.slice(open + 1, k), end: k + 1 };\n }\n return { inner: sql.slice(open + 1), end: sql.length };\n}\n\n/** Remove every parenthesized group (argument lists, typmods). */\nfunction stripParens(s: string): string {\n let out = \"\";\n let depth = 0;\n for (const c of s) {\n if (c === \"(\") depth++;\n else if (c === \")\") depth = Math.max(0, depth - 1);\n else if (depth === 0) out += c;\n }\n return out;\n}\n\n/** Split on commas outside parentheses. */\nfunction splitTop(s: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let cur = \"\";\n for (const c of s) {\n if (c === \"(\") depth++;\n if (c === \")\") depth--;\n if (c === \",\" && depth === 0) {\n parts.push(cur);\n cur = \"\";\n } else cur += c;\n }\n if (cur.trim()) parts.push(cur);\n return parts.map((p) => p.trim()).filter(Boolean);\n}\n\nconst TYPE_ALIASES: Record<string, string> = {\n int: \"integer\",\n int4: \"integer\",\n int8: \"bigint\",\n int2: \"smallint\",\n bool: \"boolean\",\n varchar: \"character varying\",\n timestamptz: \"timestamp with time zone\",\n float8: \"double precision\",\n};\nconst MULTIWORD_TYPE = /^(?:double precision|character varying|character|bit varying|timestamp|time|interval)\\b/;\n\n/** A function's identity: its argument types (names, defaults, OUT args and typmods dropped). */\nexport function argTypes(args: string): string[] {\n const types: string[] = [];\n for (const raw of splitTop(args)) {\n let tokens = stripParens(raw.replace(/\\s+(?:default\\b|=).*$/, \"\")).trim().split(/\\s+/).filter(Boolean);\n const mode = tokens[0];\n if (mode === \"out\") continue;\n if (mode === \"in\" || mode === \"inout\" || mode === \"variadic\") tokens = tokens.slice(1);\n const joined = tokens.join(\" \");\n const type = tokens.length > 1 && !MULTIWORD_TYPE.test(joined) ? tokens.slice(1).join(\" \") : joined;\n types.push(TYPE_ALIASES[type] ?? type);\n }\n return types;\n}\n\ninterface Migration {\n /** Path relative to the app root, POSIX. */\n file: string;\n statements: SqlStatement[];\n}\n\n/** What git says about the migrations folder against the base ref. */\ninterface GitView {\n /** Paths (app-relative) that are new or changed since the merge base, including untracked files. */\n touched: Set<string>;\n /** Migrations that existed at the merge base and were modified, deleted or renamed. */\n edited: Array<{ file: string; status: \"modified\" | \"deleted\" | \"renamed\" }>;\n}\n\nfunction git(root: string, args: string[]): string | null {\n const r = spawnSync(\"git\", args, { cwd: root, encoding: \"utf8\" });\n return r.status === 0 ? r.stdout : null;\n}\n\n/** A GitView, or the reason git can't compare (null reason: not a git repo). */\nfunction gitView(root: string, dir: string, base: string): GitView | { reason: string; repo: boolean } {\n if (git(root, [\"rev-parse\", \"--is-inside-work-tree\"])?.trim() !== \"true\") return { reason: \"not a git repository\", repo: false };\n if (git(root, [\"rev-parse\", \"--verify\", \"--quiet\", `${base}^{commit}`]) === null) {\n return { reason: `the git ref ${base} isn't available (fetch it, or set doctor.supabase.base)`, repo: true };\n }\n const mergeBase = git(root, [\"merge-base\", \"HEAD\", base])?.trim();\n if (!mergeBase) return { reason: `HEAD has no merge base with ${base} (a shallow clone? fetch with depth 0)`, repo: true };\n const diff = git(root, [\"diff\", \"--relative\", \"--name-status\", \"-M\", mergeBase, \"--\", dir]);\n const untracked = git(root, [\"ls-files\", \"--others\", \"--exclude-standard\", \"--\", dir]);\n if (diff === null || untracked === null) return { reason: `git diff against ${base} failed`, repo: true };\n const sql = (p: string | undefined) => p !== undefined && p.endsWith(\".sql\");\n const touched = new Set<string>(untracked.split(\"\\n\").filter(sql));\n const edited: GitView[\"edited\"] = [];\n for (const row of diff.split(\"\\n\").filter(Boolean)) {\n const [status, a, b] = row.split(\"\\t\");\n if (status.startsWith(\"R\")) {\n if (sql(b)) touched.add(b);\n if (sql(a)) edited.push({ file: a, status: \"renamed\" });\n continue;\n }\n if (!sql(a)) continue;\n if (status.startsWith(\"A\")) touched.add(a);\n else if (status.startsWith(\"M\") || status.startsWith(\"T\")) {\n touched.add(a);\n edited.push({ file: a, status: \"modified\" });\n } else if (status.startsWith(\"D\")) edited.push({ file: a, status: \"deleted\" });\n }\n return { touched, edited };\n}\n\nexport function checkSupabasePack(ctx: DoctorContext): void {\n const settings = ctx.config.supabase ?? {};\n const dir = settings.migrations ?? DEFAULT_MIGRATIONS;\n const abs = path.join(ctx.root, dir);\n if (!existsSync(abs)) throw new DoctorConfigError(`the supabase pack reads ${dir}, which doesn't exist; set doctor.supabase.migrations`);\n const migrations: Migration[] = readdirSync(abs)\n .filter((n) => n.endsWith(\".sql\"))\n .sort()\n .map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path.join(abs, n), \"utf8\")) }));\n const exposed = new Set((settings.exposedSchemas ?? DEFAULT_EXPOSED).map((s) => s.toLowerCase()));\n\n const base = settings.base ?? DEFAULT_BASE;\n const view = gitView(ctx.root, dir, base);\n if (\"reason\" in view) {\n if (view.repo) ctx.report({ rule: \"migration-edited\", level: \"warn\", file: dir, message: `can't check for edited migrations: ${view.reason}` });\n } else {\n for (const e of view.edited) {\n ctx.report({\n rule: \"migration-edited\",\n file: e.file,\n subject: e.file,\n message: `${e.status === \"modified\" ? \"edits\" : e.status === \"deleted\" ? \"deletes\" : \"renames\"} a migration that already exists on ${base}, so it has been applied; put the change in a new migration instead`,\n });\n }\n }\n\n // Which migrations are new: changed since the base (when git can tell) and not before `since`.\n const since = settings.since;\n const afterSince = (file: string) => since === undefined || path.posix.basename(file) >= since;\n if (\"reason\" in view && since === undefined) {\n ctx.report({\n rule: \"migration-grants\",\n level: \"warn\",\n file: dir,\n message: `skipped: can't tell new migrations from applied ones (${view.reason}); fetch the base ref (CI: fetch-depth 0) or set doctor.supabase.since`,\n });\n } else {\n const isNew = (file: string) => afterSince(file) && (\"reason\" in view || view.touched.has(file));\n checkGrants(ctx, migrations.filter((m) => isNew(m.file)), exposed);\n }\n checkRls(ctx, migrations, exposed);\n checkDefinerSearchPath(ctx, migrations);\n}\n\n/** Grantee list of a grant: `to a, b [with grant option] [granted by x]`. */\nfunction granteesOf(s: string): string[] {\n return s\n .replace(/\\s+granted by .*$/, \"\")\n .replace(/\\s+with grant option$/, \"\")\n .split(/\\s*,\\s*/)\n .map((r) => r.replace(/^group\\s+/, \"\").trim())\n .filter(Boolean);\n}\n\n/** `migration-grants`: grant function privileges by name, and never expose an unexposed schema to anon/public. */\nfunction checkGrants(ctx: DoctorContext, migrations: Migration[], exposed: Set<string>): void {\n const fix = \"grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives\";\n const open = (roles: string[]) => roles.filter((r) => r === \"anon\" || r === \"public\");\n /** error for anon/public, warn for authenticated, nothing for other roles (service_role, postgres, …). */\n const blanket = (roles: string[]): { level: Level; who: string } | null => {\n const o = open(roles);\n if (o.length) return { level: \"error\", who: o.join(\" and \") };\n if (roles.includes(\"authenticated\")) return { level: \"warn\", who: \"authenticated\" };\n return null;\n };\n for (const { file, statements } of migrations) {\n for (const { sql, line } of statements) {\n const all = /^grant\\b.*\\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);\n if (all) {\n const hit = blanket(granteesOf(all[1]));\n if (hit) {\n ctx.report({ rule: \"migration-grants\", level: hit.level, file, line, subject: \"on all functions\", message: `grants every function in a schema to ${hit.who}, which re-grants functions an earlier migration revoked; ${fix}` });\n }\n continue;\n }\n const defaults = /^alter default privileges\\b.*?\\bgrant\\b.*\\bon (?:functions|routines) to (.+)$/.exec(sql);\n if (defaults) {\n const hit = blanket(granteesOf(defaults[1]));\n if (hit) {\n ctx.report({ rule: \"migration-grants\", level: hit.level, file, line, subject: \"alter default privileges\", message: `grants default privileges on functions to ${hit.who}, so every future function is callable by them; ${fix}` });\n }\n continue;\n }\n const fn = /^grant\\b.*?\\bon (?:function|procedure|routine)s? (.+?) to (.+)$/.exec(sql);\n if (fn) {\n const roles = open(granteesOf(fn[2]));\n if (!roles.length) continue;\n for (const name of splitTop(fn[1]).map((n) => qualify(stripParens(n)))) {\n if (exposed.has(schemaOf(name))) continue;\n ctx.report({\n rule: \"migration-grants\",\n file,\n line,\n subject: name,\n message: `grants ${name} to ${roles.join(\" and \")}; a function outside the exposed schemas is never callable by anon or public (grant it to authenticated, or expose a wrapper)`,\n });\n }\n continue;\n }\n const schema = /^grant\\b.*?\\bon schema (.+?) to (.+)$/.exec(sql);\n if (schema) {\n const roles = open(granteesOf(schema[2]));\n if (!roles.length) continue;\n for (const s of schema[1].split(/\\s*,\\s*/).map((x) => x.trim())) {\n if (exposed.has(s)) continue;\n ctx.report({\n rule: \"migration-grants\",\n file,\n line,\n subject: `schema ${s}`,\n message: `grants schema ${s} to ${roles.join(\" and \")}; a schema outside the exposed ones stays closed to anon and public`,\n });\n }\n }\n }\n }\n}\n\n/** `migration-rls`: after every migration, each table in an exposed schema has row level security on. */\nfunction checkRls(ctx: DoctorContext, migrations: Migration[], exposed: Set<string>): void {\n const tables = new Map<string, { rls: boolean; file: string; line: number; disabled: boolean }>();\n const name = String.raw`([\\w$.]+)`;\n const target = String.raw`^alter table (?:if exists )?(?:only )?${name}`;\n for (const { file, statements } of migrations) {\n for (const { sql, line, bodies } of statements) {\n // RLS turned on by dynamic SQL (a do-block loop over tables) can't be traced: trust it for every table so far.\n if (bodies.some((b) => /\\benable row level security\\b/.test(b))) for (const t of tables.values()) t.rls = true;\n const create = new RegExp(String.raw`^create (?:(?:global |local )?(?:temp|temporary) |unlogged )?table (?:if not exists )?${name}`).exec(sql);\n if (create) {\n if (!/^create (?:global |local )?(?:temp|temporary) /.test(sql)) tables.set(qualify(create[1]), { rls: false, file, line, disabled: false });\n continue;\n }\n const rename = new RegExp(`${target} rename to ([\\\\w$]+)$`).exec(sql);\n const move = new RegExp(`${target} set schema ([\\\\w$]+)$`).exec(sql);\n if (rename || move) {\n const from = qualify((rename ?? move)![1]);\n const to = rename ? `${schemaOf(from)}.${rename[2]}` : `${move![2]}.${from.split(\".\")[1]}`;\n const state = tables.get(from);\n if (state) {\n tables.delete(from);\n tables.set(to, state);\n }\n continue;\n }\n const alter = new RegExp(target).exec(sql);\n if (alter && /\\b(?:enable|disable) row level security\\b/.test(sql)) {\n const t = qualify(alter[1]);\n if (/\\bdisable row level security\\b/.test(sql)) tables.set(t, { rls: false, file, line, disabled: true });\n else {\n const state = tables.get(t);\n if (state) state.rls = true;\n }\n continue;\n }\n const drop = /^drop table (?:if exists )?(.+?)(?: cascade| restrict)?$/.exec(sql);\n if (drop) for (const n of drop[1].split(\",\")) tables.delete(qualify(n));\n }\n }\n for (const [t, at] of tables) {\n if (at.rls || !exposed.has(schemaOf(t))) continue;\n ctx.report({\n rule: \"migration-rls\",\n file: at.file,\n line: at.line,\n subject: t,\n message: at.disabled\n ? `disables row level security on ${t}, and no later migration turns it back on; anyone with the API key can read and write it`\n : `creates ${t} without enabling row level security in any migration; add \"alter table ${t} enable row level security;\" and its policies`,\n });\n }\n}\n\n/** `migration-definer-search-path`: a security definer function pins its search_path. Functions are keyed by name and argument types. */\nfunction checkDefinerSearchPath(ctx: DoctorContext, migrations: Migration[]): void {\n const fns = new Map<string, { definer: boolean; searchPath: boolean; file: string; line: number }>();\n /** Keys a statement names: one overload with an argument list, every overload without one. */\n const keysFor = (sql: string, nameEnd: number, fnName: string): string[] => {\n const rest = sql.slice(nameEnd).trimStart();\n if (rest.startsWith(\"(\")) {\n const { inner } = parenthesized(rest, 0);\n return [`${fnName}(${argTypes(inner).join(\",\")})`];\n }\n return [...fns.keys()].filter((k) => k.startsWith(`${fnName}(`));\n };\n for (const { file, statements } of migrations) {\n for (const { sql, line } of statements) {\n const create = /^create (?:or replace )?(?:function|procedure) ([\\w$.]+)\\s*/.exec(sql);\n if (create) {\n const [key] = keysFor(sql, create[0].length, qualify(create[1]));\n fns.set(key, { definer: /\\bsecurity definer\\b/.test(sql), searchPath: /\\bset search_path\\b/.test(sql), file, line });\n continue;\n }\n const alter = /^alter (?:function|procedure|routine) ([\\w$.]+)\\s*/.exec(sql);\n if (alter) {\n const fnName = qualify(alter[1]);\n const keys = keysFor(sql, alter[0].length, fnName);\n const rename = / rename to ([\\w$]+)$/.exec(sql);\n const move = / set schema ([\\w$]+)$/.exec(sql);\n for (const key of keys) {\n const state = fns.get(key);\n if (rename || move) {\n if (!state) continue;\n fns.delete(key);\n const newName = rename ? `${schemaOf(fnName)}.${rename[1]}` : `${move![1]}.${fnName.split(\".\")[1]}`;\n fns.set(newName + key.slice(fnName.length), state);\n continue;\n }\n // A function created outside the migrations: only what this alter says is known.\n const next = state ?? { definer: false, searchPath: false, file, line };\n if (/\\bsecurity definer\\b/.test(sql)) Object.assign(next, { definer: true, file, line });\n if (/\\bsecurity invoker\\b/.test(sql)) next.definer = false;\n if (/\\bset search_path\\b/.test(sql)) next.searchPath = true;\n if (/\\breset (?:search_path|all)\\b/.test(sql)) Object.assign(next, { searchPath: false, file, line });\n fns.set(key, next);\n }\n continue;\n }\n const drop = /^drop (?:function|procedure|routine) (?:if exists )?(.+?)(?: cascade| restrict)?$/.exec(sql);\n if (drop) {\n for (const part of splitTop(drop[1])) {\n const m = /^([\\w$.]+)\\s*/.exec(part);\n if (m) for (const key of keysFor(part, m[0].length, qualify(m[1]))) fns.delete(key);\n }\n }\n }\n }\n for (const [key, at] of fns) {\n if (!at.definer || at.searchPath) continue;\n ctx.report({\n rule: \"migration-definer-search-path\",\n file: at.file,\n line: at.line,\n subject: key,\n message: `${key} is security definer without \"set search_path\"; add set search_path = '' and schema-qualify the names in its body, so a caller's objects can't stand in for yours`,\n });\n }\n}\n","/**\n * The release train: `@marktiderman/genesis` ships `dist/versions.json`, the\n * exact version of every Genesis package it was released with. When an app\n * has the umbrella installed, every other Genesis package it has installed\n * should be that version, so the app runs a set that was tested together.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { findPackageDir } from \"./genesis.js\";\nimport type { DoctorContext } from \"./types.js\";\n\nexport const UMBRELLA_PACKAGE = \"@marktiderman/genesis\";\n\n/** The shape of the umbrella's `dist/versions.json`. */\nexport interface ReleaseManifest {\n version: string;\n packages: Record<string, string>;\n}\n\n/** The installed umbrella's manifest, or null when there's no umbrella or no manifest. */\nexport function readReleaseManifest(root: string): ReleaseManifest | null {\n const dir = findPackageDir(root, UMBRELLA_PACKAGE);\n const file = dir && path.join(dir, \"dist\", \"versions.json\");\n if (!file || !existsSync(file)) return null;\n return JSON.parse(readFileSync(file, \"utf8\")) as ReleaseManifest;\n}\n\n/** `version-skew`: an installed Genesis package isn't the version the installed umbrella was released with. */\nexport function checkVersionSkew(ctx: DoctorContext): void {\n const manifest = readReleaseManifest(ctx.root);\n if (!manifest) return;\n for (const [name, want] of Object.entries(manifest.packages)) {\n const dir = findPackageDir(ctx.root, name);\n if (!dir) continue;\n const have = (JSON.parse(readFileSync(path.join(dir, \"package.json\"), \"utf8\")) as { version: string }).version;\n if (have === want) continue;\n ctx.report({\n rule: \"version-skew\",\n level: \"warn\",\n file: \"package.json\",\n subject: name,\n message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`,\n });\n }\n}\n","/**\n * `genesis doctor`: checks an app against the installed Genesis — local\n * primitives, forbidden imports, raw tags Genesis has components for,\n * literal colors, undefined tokens, shadowed exports — plus the app's own\n * pattern rules and rule plugins. The CLI and the Vite plugin both call\n * `runDoctor`.\n */\nimport * as path from \"node:path\";\nimport { buildCommands, runBuild } from \"./build.js\";\nimport { DoctorConfigError, loadConfig } from \"./config.js\";\nimport { globToRegExp } from \"./glob.js\";\nimport { loadGenesis } from \"./genesis.js\";\nimport { loadPatternRules } from \"./patterns.js\";\nimport { loadPlugins } from \"./plugins.js\";\nimport {\n BUILTIN_RULES,\n checkColors,\n checkImports,\n checkProjectLayout,\n checkRawTags,\n checkShadowedExports,\n checkTokens,\n unusedComponents,\n} from \"./rules.js\";\nimport { checkNativePack } from \"./native.js\";\nimport { scanFiles } from \"./scan.js\";\nimport { checkSupabasePack } from \"./supabase.js\";\nimport { checkVersionSkew } from \"./versions.js\";\nimport type { DoctorConfig, DoctorContext, DoctorPlugin, DoctorResult, Finding, FindingInput, GenesisFacts } from \"./types.js\";\n\nexport type * from \"./types.js\";\nexport {\n DoctorConfigError,\n GenesisConfigError,\n loadConfig,\n readGenesisConfig,\n validateConfig,\n validateLinks,\n type GenesisConfigFile,\n type GenesisLinks,\n} from \"./config.js\";\nexport { loadGenesis, findPackageDir, parseExportNames, readPackageExports } from \"./genesis.js\";\nexport { parseRulesMarkdown } from \"./patterns.js\";\nexport { defineDoctorPlugin } from \"./plugins.js\";\nexport { BUILTIN_RULES } from \"./rules.js\";\nexport { globToRegExp } from \"./glob.js\";\nexport { nativeLayouts } from \"./native.js\";\nexport { sqlStatements } from \"./supabase.js\";\nexport { readReleaseManifest, type ReleaseManifest } from \"./versions.js\";\n\nexport interface RunDoctorOptions {\n /** The app root. Default `process.cwd()`. */\n root?: string;\n /** Explicit config file (otherwise genesis.config.json, then package.json `genesis`). */\n configPath?: string;\n /** Use this config instead of reading one. Relative plugin paths resolve from `root`. */\n config?: DoctorConfig;\n /** Treat warnings as failures. */\n strict?: boolean;\n /** Run the app's typecheck and build after the checks. */\n build?: boolean;\n /** Pipe build output instead of inheriting the terminal (for --json). */\n quietBuild?: boolean;\n /** Reuse facts read earlier (the Vite dev server caches them). */\n genesis?: GenesisFacts;\n}\n\nexport async function runDoctor(options: RunDoctorOptions = {}): Promise<DoctorResult> {\n const root = path.resolve(options.root ?? process.cwd());\n const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);\n const config = loaded.config;\n const genesis = options.genesis ?? loadGenesis(root, config);\n const files = scanFiles(root, config);\n\n const patterns = loadPatternRules(root, config.patterns, config.rulesDoc);\n const plugins = await loadPlugins(config.plugins, loaded.dir);\n const builtinIds = new Set<string>(BUILTIN_RULES);\n for (const p of config.patterns ?? []) {\n if (builtinIds.has(p.id)) throw new DoctorConfigError(`doctor.patterns: \"${p.id}\" is a built-in rule id; pick another`);\n }\n\n const raw: FindingInput[] = [];\n const ctx: DoctorContext = { root, files, genesis, config, report: (f) => raw.push(f) };\n const builtins: DoctorPlugin[] = [\n { name: \"layout\", check: checkProjectLayout },\n { name: \"imports\", check: checkImports },\n { name: \"raw-tags\", check: checkRawTags },\n { name: \"colors\", check: checkColors },\n { name: \"tokens\", check: checkTokens },\n { name: \"shadowed-exports\", check: checkShadowedExports },\n { name: \"version-skew\", check: checkVersionSkew },\n ...(config.packs?.includes(\"native\") ? [{ name: \"native\", check: checkNativePack }] : []),\n ...(config.packs?.includes(\"supabase\") ? [{ name: \"supabase\", check: checkSupabasePack }] : []),\n ];\n for (const plugin of [...builtins, ...(patterns ? [patterns.plugin] : []), ...plugins]) {\n try {\n await plugin.check(ctx);\n } catch (err) {\n if (err instanceof DoctorConfigError) throw err;\n raw.push({ rule: \"plugin-error\", file: plugin.name, message: `rule plugin \"${plugin.name}\" threw: ${(err as Error).message}` });\n }\n }\n\n if (options.build) {\n const failure = runBuild(root, buildCommands(root, config), options.quietBuild ?? false);\n if (failure) raw.push(failure);\n }\n\n const findings = applyConfig(raw, config);\n const errors = findings.filter((f) => f.level === \"error\").length;\n const warnings = findings.length - errors;\n return {\n ok: errors === 0 && !(options.strict && warnings > 0),\n root,\n genesis,\n findings,\n unused: unusedComponents(ctx),\n ruleCount: (patterns?.count ?? 0) + plugins.length,\n errors,\n warnings,\n };\n}\n\n/** Apply `rules` level overrides and `allow` exceptions; flag exceptions that no longer match anything. */\nfunction applyConfig(raw: FindingInput[], config: DoctorConfig): Finding[] {\n const allow = (config.allow ?? []).map((entry) => ({ entry, file: entry.file ? globToRegExp(entry.file) : null, used: false }));\n const out: Finding[] = [];\n for (const input of raw) {\n const setting = config.rules?.[input.rule];\n if (setting === \"off\") continue;\n const finding: Finding = {\n rule: input.rule,\n level: setting ?? input.level ?? \"error\",\n file: input.file,\n line: input.line ?? 0,\n message: input.message,\n ...(input.subject !== undefined ? { subject: input.subject } : {}),\n };\n const exception = allow.find(\n (a) => a.entry.rule === finding.rule && (!a.file || a.file.test(finding.file)) && (a.entry.match === undefined || a.entry.match === finding.subject),\n );\n if (exception) {\n exception.used = true;\n continue;\n }\n out.push(finding);\n }\n // stale-exception is a rule like any other: `rules` can turn it off or change its level.\n const staleLevel = config.rules?.[\"stale-exception\"];\n for (const a of allow) {\n if (staleLevel === \"off\" || a.used || config.rules?.[a.entry.rule] === \"off\") continue;\n out.push({\n rule: \"stale-exception\",\n level: staleLevel ?? \"warn\",\n file: a.entry.file ?? \"genesis config\",\n line: 0,\n subject: a.entry.rule,\n message: `the allow entry for ${a.entry.rule}${a.entry.match ? ` (${a.entry.match})` : \"\"} no longer matches anything; remove it`,\n });\n }\n return out.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line || x.rule.localeCompare(y.rule));\n}\n\n/** The human-readable report. */\nexport function formatReport(result: DoctorResult): string {\n const g = result.genesis;\n const lines = [\n `Genesis doctor: ${g.uiPackage}@${g.uiVersion}, ${g.components.length} components, ${g.tokens.size} tokens, ` +\n `${result.ruleCount} app rules; raw tags checked: ${[...g.rawTags.keys()].join(\", \") || \"none\"}`,\n ];\n for (const f of result.findings) {\n lines.push(`${f.level.toUpperCase().padEnd(5)} ${f.file}${f.line ? `:${f.line}` : \"\"} [${f.rule}] ${f.message}`);\n }\n lines.push(`Available but unused (${result.unused.length}): ${result.unused.join(\", \") || \"none\"}`);\n lines.push(result.ok ? `PASS (${result.warnings} warnings)` : `FAIL (${result.errors} errors, ${result.warnings} warnings)`);\n return lines.join(\"\\n\");\n}\n\n/** The `--json` report: plain data, sets turned into sorted lists. */\nexport function toJson(result: DoctorResult) {\n return {\n ok: result.ok,\n genesis: `${result.genesis.uiPackage}@${result.genesis.uiVersion}`,\n errors: result.errors,\n warnings: result.warnings,\n findings: result.findings,\n unused: result.unused,\n };\n}\n\n/** What `--print-genesis` shows: the facts every rule is derived from. */\nexport function genesisSummary(g: GenesisFacts) {\n return {\n package: `${g.uiPackage}@${g.uiVersion}`,\n components: g.components,\n tokens: [...g.tokens].sort(),\n rawTags: Object.fromEntries(g.rawTags),\n palette: g.palette,\n };\n}\n","/**\n * `genesisDoctor()` for Vite: runs the same checks as `genesis doctor`.\n *\n * - `vite build`: fails the build when the doctor finds errors.\n * - `vite dev`: logs problems and shows Vite's error overlay, re-checking\n * (debounced) whenever a scanned file, the config or the rules doc changes.\n *\n * import { genesisDoctor } from \"@marktiderman/genesis-cli/vite\";\n * export default defineConfig({ plugins: [genesisDoctor()] });\n */\nimport * as path from \"node:path\";\nimport type { Plugin, ViteDevServer } from \"vite\";\nimport { formatReport, loadConfig, loadGenesis, runDoctor, type DoctorResult, type GenesisFacts } from \"./doctor/index.js\";\n\nexport interface GenesisDoctorOptions {\n /** The app root. Default: Vite's `root`. */\n root?: string;\n /** Explicit config file. */\n configPath?: string;\n /** Fail builds on warnings too. */\n strict?: boolean;\n /** Re-check delay after a change, in ms. Default 300. */\n debounceMs?: number;\n}\n\nconst formatProblems = (result: DoctorResult, withWarnings = false) =>\n result.findings\n .filter((f) => f.level === \"error\" || withWarnings)\n .map((f) => `${f.file}${f.line ? `:${f.line}` : \"\"} [${f.rule}] ${f.message}`)\n .join(\"\\n\");\n\nexport function genesisDoctor(options: GenesisDoctorOptions = {}): Plugin[] {\n let root = options.root ?? process.cwd();\n return [\n {\n name: \"genesis-doctor:build\",\n apply: \"build\",\n configResolved(config) {\n root = options.root ?? config.root;\n },\n async buildStart() {\n const result = await runDoctor({ root, configPath: options.configPath, strict: options.strict });\n if (!result.ok) this.error(`Genesis doctor found problems:\\n${formatProblems(result, options.strict)}`);\n if (result.warnings > 0) this.warn(formatReport(result));\n },\n },\n {\n name: \"genesis-doctor:serve\",\n apply: \"serve\",\n configResolved(config) {\n root = options.root ?? config.root;\n },\n configureServer(server: ViteDevServer) {\n let genesis: GenesisFacts | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let failing = false;\n // The last overlay message, re-sent to browsers that connect after the check ran.\n let lastError: string | null = null;\n const showError = (message: string) => {\n lastError = message;\n failing = true;\n server.config.logger.error(message, { timestamp: true });\n server.ws.send({ type: \"error\", err: { message, stack: \"\", plugin: \"genesis-doctor\" } });\n };\n let running = false;\n let again = false;\n\n const check = async () => {\n if (running) {\n again = true;\n return;\n }\n running = true;\n try {\n // Genesis facts only change on reinstall; read them once per server.\n genesis ??= loadGenesis(root, loadConfig(root, options.configPath).config);\n const result = await runDoctor({ root, configPath: options.configPath, genesis });\n if (result.errors > 0) {\n showError(`Genesis doctor found problems:\\n${formatProblems(result)}`);\n } else if (failing) {\n // Clear the overlay once the problems are fixed.\n failing = false;\n lastError = null;\n server.config.logger.info(\"Genesis doctor: all clear\", { timestamp: true });\n server.ws.send({ type: \"full-reload\" });\n }\n } catch (err) {\n showError(`Genesis doctor could not run: ${(err as Error).message}`);\n } finally {\n running = false;\n if (again) {\n again = false;\n void check();\n }\n }\n };\n\n // The config and rules doc live outside src/ (and may live outside root),\n // so watch them explicitly and always re-check when they change.\n const explicit = new Set([path.join(root, \"genesis.config.json\"), ...(options.configPath ? [path.resolve(root, options.configPath)] : [])]);\n try {\n const { config } = loadConfig(root, options.configPath);\n if (config.rulesDoc) explicit.add(path.resolve(root, config.rulesDoc));\n } catch {\n // A broken config is reported by the first check.\n }\n const schedule = (file: string) => {\n if (!explicit.has(path.resolve(file))) {\n const rel = path.relative(root, file).split(path.sep).join(\"/\");\n if (rel.startsWith(\"..\") || rel.includes(\"node_modules/\")) return;\n }\n clearTimeout(timer);\n timer = setTimeout(() => void check(), options.debounceMs ?? 300);\n };\n server.watcher.add([...explicit]);\n server.watcher.on(\"change\", schedule);\n server.watcher.on(\"add\", schedule);\n server.watcher.on(\"unlink\", schedule);\n server.ws.on(\"connection\", () => {\n if (lastError) server.ws.send({ type: \"error\", err: { message: lastError, stack: \"\", plugin: \"genesis-doctor\" } });\n });\n server.httpServer?.once(\"listening\", () => void check());\n if (!server.httpServer) void check();\n },\n },\n ];\n}\n"]}
1
+ {"version":3,"sources":["../src/doctor/build.ts","../src/doctor/config.ts","../src/doctor/glob.ts","../src/doctor/genesis.ts","../../../scripts/lib/color-literals.mjs","../src/doctor/scan.ts","../src/doctor/patterns.ts","../src/doctor/plugins.ts","../src/doctor/rules.ts","../../../scripts/lib/native-primitives.mjs","../src/expo.ts","../src/doctor/native.ts","../src/doctor/supabase.ts","../src/doctor/versions.ts","../src/doctor/index.ts","../src/vite.ts"],"names":["path","path2","existsSync","readFileSync","path4","statSync","readdirSync","path5","path6","createRequire","path7","dependencies","SCRIPT_EXTS","JSX_EXTS","path9","spawnSync","path10","path11","path12","path13"],"mappings":";;;;;;;AASO,IAAM,eAAA,GAAkB,yBAAA;AAGxB,SAAS,aAAA,CAAc,MAAc,MAAA,EAAgC;AAC1E,EAAA,IAAI,MAAA,CAAO,KAAA,EAAO,OAAO,MAAA,CAAO,KAAA;AAChC,EAAA,MAAM,OAAA,GAAeA,KAAA,CAAA,IAAA,CAAK,IAAA,EAAM,cAAc,CAAA;AAC9C,EAAA,MAAM,OAAA,GAAkC,UAAA,CAAW,OAAO,CAAA,GAAI,KAAK,KAAA,CAAM,YAAA,CAAa,OAAA,EAAS,MAAM,CAAC,CAAA,CAAE,OAAA,IAAW,KAAK,EAAC;AACzH,EAAA,MAAM,EAAA,GAAK,eAAe,IAAI,CAAA;AAC9B,EAAA,OAAO,CAAC,WAAA,EAAa,OAAO,EAAE,MAAA,CAAO,CAAC,MAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA,KAAM,GAAG,EAAE,CAAA,KAAA,EAAQ,CAAC,CAAA,CAAE,CAAA;AACrF;AAEO,SAAS,eAAe,IAAA,EAAsB;AACnD,EAAA,IAAI,GAAA,GAAWA,cAAQ,IAAI,CAAA;AAC3B,EAAA,WAAS;AACP,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AAA,MACrC;AAAA;AACF,GACF;AACF","file":"vite.js","sourcesContent":["/**\n * `genesis doctor --build`: run the app's typecheck and build after the checks.\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { DoctorConfig, FindingInput } from \"./types.js\";\n\n/** Set for build children, so a build that itself runs `genesis doctor --build` doesn't recurse. */\nexport const BUILD_GUARD_ENV = \"GENESIS_DOCTOR_BUILDING\";\n\n/** The commands `--build` runs: config `build`, else the app's `typecheck` and `build` scripts. */\nexport function buildCommands(root: string, config: DoctorConfig): string[] {\n if (config.build) return config.build;\n const pkgFile = path.join(root, \"package.json\");\n const scripts: Record<string, string> = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, \"utf8\")).scripts ?? {} : {};\n const pm = packageManager(root);\n return [\"typecheck\", \"build\"].filter((s) => scripts[s]).map((s) => `${pm} run ${s}`);\n}\n\nexport function packageManager(root: string): string {\n let dir = path.resolve(root);\n for (;;) {\n if (existsSync(path.join(dir, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(path.join(dir, \"bun.lock\")) || existsSync(path.join(dir, \"bun.lockb\"))) return \"bun\";\n if (existsSync(path.join(dir, \"yarn.lock\"))) return \"yarn\";\n if (existsSync(path.join(dir, \"package-lock.json\"))) return \"npm\";\n const parent = path.dirname(dir);\n if (parent === dir) return \"npm\";\n dir = parent;\n }\n}\n\n/** Run each command in order; stop at the first failure and return it as a finding. */\nexport function runBuild(root: string, commands: string[], quiet: boolean): FindingInput | null {\n if (process.env[BUILD_GUARD_ENV]) return null;\n if (commands.length === 0) {\n return { rule: \"build\", level: \"warn\", file: \"package.json\", message: \"--build found nothing to run: add typecheck/build scripts or doctor.build\" };\n }\n for (const command of commands) {\n // Commands come from the app's own config or package.json, so a shell is fine.\n const r = spawnSync(command, {\n cwd: root,\n shell: true,\n stdio: quiet ? \"pipe\" : \"inherit\",\n env: { ...process.env, [BUILD_GUARD_ENV]: \"1\" },\n });\n if (r.status !== 0) {\n const tail = quiet ? `\\n${String(r.stderr ?? \"\").trim().split(\"\\n\").slice(-20).join(\"\\n\")}` : \"\";\n return { rule: \"build\", file: command, message: `\\`${command}\\` failed (exit ${r.status ?? r.signal})${tail}` };\n }\n }\n return null;\n}\n","/**\n * Finds and validates the app's genesis.config.json.\n *\n * The doctor's lookup order: `--config <path>`, then `genesis.config.json`\n * in the app root, then the `genesis` key of package.json. Either file holds\n * the settings under `doctor`, beside other blocks: `features` (read by\n * `genesis features`) and `links` (validated here, read by the Expo config\n * plugin).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { DoctorConfig } from \"./types.js\";\n\n/** A genesis.config.json that can't be read or has a block of the wrong shape. */\nexport class GenesisConfigError extends Error {\n override name = \"GenesisConfigError\";\n}\n\nexport class DoctorConfigError extends GenesisConfigError {\n override name = \"DoctorConfigError\";\n}\n\n/** The `links` block: the web hosts (and optional path prefixes) the app opens as universal / app links. */\nexport interface GenesisLinks {\n /** Bare host names, such as `example.com` or `app.example.com`: no scheme, path or port. */\n hosts: string[];\n /** Path prefixes the app handles, each starting with `/`. Default: every path. */\n paths?: string[];\n /** Also add `webcredentials:` domains (password autofill). Default true. */\n webcredentials?: boolean;\n}\n\n/**\n * Apple's collected data types (`NSPrivacyCollectedDataType`), every one in\n * Apple's reference, keyed by the stores' own words, lower case, as Genesis\n * blocks name them in `privacy.collects`. Look one up with\n * {@link privacyDataType}, which ignores case (blocks write `\"device ID\"`,\n * `\"user ID\"`). The values are Apple's exact strings, `PhotosorVideos`\n * included.\n */\nexport const PRIVACY_DATA_TYPES: Readonly<Record<string, string>> = {\n name: \"NSPrivacyCollectedDataTypeName\",\n \"email address\": \"NSPrivacyCollectedDataTypeEmailAddress\",\n \"phone number\": \"NSPrivacyCollectedDataTypePhoneNumber\",\n \"physical address\": \"NSPrivacyCollectedDataTypePhysicalAddress\",\n \"other user contact info\": \"NSPrivacyCollectedDataTypeOtherUserContactInfo\",\n health: \"NSPrivacyCollectedDataTypeHealth\",\n fitness: \"NSPrivacyCollectedDataTypeFitness\",\n \"payment info\": \"NSPrivacyCollectedDataTypePaymentInfo\",\n \"credit info\": \"NSPrivacyCollectedDataTypeCreditInfo\",\n \"other financial info\": \"NSPrivacyCollectedDataTypeOtherFinancialInfo\",\n \"precise location\": \"NSPrivacyCollectedDataTypePreciseLocation\",\n \"coarse location\": \"NSPrivacyCollectedDataTypeCoarseLocation\",\n \"sensitive info\": \"NSPrivacyCollectedDataTypeSensitiveInfo\",\n contacts: \"NSPrivacyCollectedDataTypeContacts\",\n \"emails or text messages\": \"NSPrivacyCollectedDataTypeEmailsOrTextMessages\",\n \"photos or videos\": \"NSPrivacyCollectedDataTypePhotosorVideos\",\n \"audio data\": \"NSPrivacyCollectedDataTypeAudioData\",\n \"gameplay content\": \"NSPrivacyCollectedDataTypeGameplayContent\",\n \"customer support\": \"NSPrivacyCollectedDataTypeCustomerSupport\",\n \"other user content\": \"NSPrivacyCollectedDataTypeOtherUserContent\",\n \"browsing history\": \"NSPrivacyCollectedDataTypeBrowsingHistory\",\n \"search history\": \"NSPrivacyCollectedDataTypeSearchHistory\",\n \"user id\": \"NSPrivacyCollectedDataTypeUserID\",\n \"device id\": \"NSPrivacyCollectedDataTypeDeviceID\",\n \"purchase history\": \"NSPrivacyCollectedDataTypePurchaseHistory\",\n \"product interaction\": \"NSPrivacyCollectedDataTypeProductInteraction\",\n \"advertising data\": \"NSPrivacyCollectedDataTypeAdvertisingData\",\n \"other usage data\": \"NSPrivacyCollectedDataTypeOtherUsageData\",\n \"crash data\": \"NSPrivacyCollectedDataTypeCrashData\",\n \"performance data\": \"NSPrivacyCollectedDataTypePerformanceData\",\n \"other diagnostic data\": \"NSPrivacyCollectedDataTypeOtherDiagnosticData\",\n \"environment scanning\": \"NSPrivacyCollectedDataTypeEnvironmentScanning\",\n hands: \"NSPrivacyCollectedDataTypeHands\",\n head: \"NSPrivacyCollectedDataTypeHead\",\n \"other data types\": \"NSPrivacyCollectedDataTypeOtherDataTypes\",\n};\n\n/** Apple's string for a data type in the stores' words, whatever its case, or undefined. */\nexport function privacyDataType(type: string): string | undefined {\n return PRIVACY_DATA_TYPES[type.toLowerCase()];\n}\n\n/** Apple's collection purposes (`NSPrivacyCollectedDataTypePurposes`), by the stores' words. */\nexport const PRIVACY_PURPOSES: Readonly<Record<string, string>> = {\n \"app functionality\": \"NSPrivacyCollectedDataTypePurposeAppFunctionality\",\n analytics: \"NSPrivacyCollectedDataTypePurposeAnalytics\",\n \"product personalization\": \"NSPrivacyCollectedDataTypePurposeProductPersonalization\",\n \"developer advertising\": \"NSPrivacyCollectedDataTypePurposeDeveloperAdvertising\",\n \"third-party advertising\": \"NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising\",\n other: \"NSPrivacyCollectedDataTypePurposeOther\",\n};\n\n/** One kind of data the app collects, as a Genesis block's `privacy.collects` entry says it. */\nexport interface GenesisDataUse {\n /** A key of {@link PRIVACY_DATA_TYPES}: `\"email address\"`, `\"user id\"`, `\"crash data\"`… */\n type: string;\n /** Keys of {@link PRIVACY_PURPOSES}: `\"app functionality\"`, `\"analytics\"`… */\n purposes: string[];\n /** Tied to the person's identity. */\n linked: boolean;\n /** Used to track the person across other companies' apps and websites. */\n tracking: boolean;\n}\n\n/**\n * The `privacy` block: what goes in the iOS privacy manifest's collected data\n * types. Left out, the Genesis blocks the app's packages carry decide.\n */\nexport interface GenesisPrivacy {\n /** The Genesis blocks whose data the app sends anywhere (`account`, `observability`, `push`). Default: found from package.json. */\n blocks?: string[];\n /** Every kind of data the app collects. Replaces what the blocks give, so list everything. */\n collects?: GenesisDataUse[];\n /** `NSPrivacyTracking`. Default false; true needs `NSPrivacyTrackingDomains` in app.config. */\n tracking?: boolean;\n}\n\n/** genesis.config.json, parsed, with its shared blocks validated. */\nexport interface GenesisConfigFile {\n /** The whole parsed file, for blocks other readers own (`doctor`, `features`). */\n raw: Record<string, unknown>;\n links?: GenesisLinks;\n privacy?: GenesisPrivacy;\n}\n\nexport interface LoadedConfig {\n config: DoctorConfig;\n /** The file it came from, or null when no config exists (defaults apply). */\n file: string | null;\n /** Folder that relative plugin paths resolve against. */\n dir: string;\n}\n\nconst STRING_LISTS = [\"src\", \"extensions\", \"ignore\", \"tokenFiles\", \"ignoreTokenPrefixes\", \"localPrimitiveDirs\", \"build\"] as const;\nconst STRINGS = [\"uiPackage\", \"rulesDoc\"] as const;\nconst KNOWN = new Set<string>([\n ...STRING_LISTS,\n ...STRINGS,\n \"themeCss\",\n \"rawTags\",\n \"forbiddenImports\",\n \"rules\",\n \"allow\",\n \"patterns\",\n \"plugins\",\n \"packs\",\n \"native\",\n \"supabase\",\n \"$schema\",\n \"$comment\",\n]);\nconst LEVELS = new Set([\"error\", \"warn\", \"off\"]);\nconst PATTERN_KEYS = new Set([\"id\", \"level\", \"files\", \"exclude\", \"forbid\", \"require\", \"path\", \"message\"]);\nconst PACKS = new Set([\"native\", \"supabase\"]);\n/** Each pack's settings: key → \"string\", \"path\" (app-relative folder, normalized) or \"list\". */\nconst PACK_KEYS: Record<string, Record<string, \"string\" | \"path\" | \"list\">> = {\n native: { routerRoot: \"path\" },\n supabase: { migrations: \"path\", base: \"string\", exposedSchemas: \"list\", since: \"string\" },\n};\n\n/** An app-relative folder in POSIX form (`./app/` → `app`); absolute paths and paths leaving the app are rejected. */\nfunction appPath(v: unknown, where: string, fail: (msg: string) => never): string {\n if (typeof v !== \"string\" || !v.trim()) return fail(`${where} must be a non-empty path`);\n if (path.isAbsolute(v) || /^[A-Za-z]:[\\\\/]/.test(v)) fail(`${where} must be relative to the app, not absolute (\"${v}\")`);\n const norm = path.posix.normalize(v.replace(/\\\\/g, \"/\")).replace(/\\/+$/, \"\");\n if (norm === \".\" || norm === \"..\" || norm.startsWith(\"../\")) fail(`${where} must be a folder inside the app (\"${v}\")`);\n return norm;\n}\n\nexport function loadConfig(root: string, configPath?: string): LoadedConfig {\n if (configPath) {\n const file = path.resolve(root, configPath);\n if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);\n const json = readJson(file);\n // An explicit file may hold the block at the top level or under `doctor`\n // (or, for a package.json, under `genesis.doctor`).\n const block = path.basename(file) === \"package.json\" ? json?.genesis?.doctor : json?.doctor ?? json;\n return { config: validateConfig(block ?? {}, file), file, dir: path.dirname(file) };\n }\n const own = path.join(root, \"genesis.config.json\");\n if (existsSync(own)) {\n const block = readGenesisConfig(root)?.raw.doctor;\n return { config: validateConfig(block ?? {}, own), file: own, dir: root };\n }\n const pkg = path.join(root, \"package.json\");\n if (existsSync(pkg)) {\n const block = readJson(pkg)?.genesis?.doctor;\n if (block !== undefined) return { config: validateConfig(block, pkg), file: pkg, dir: root };\n }\n return { config: {}, file: null, dir: root };\n}\n\nfunction readJson(file: string) {\n try {\n return JSON.parse(readFileSync(file, \"utf8\"));\n } catch (err) {\n throw new DoctorConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\n/**\n * Reads `<root>/genesis.config.json` and validates its shared blocks (today:\n * `links` and `privacy`). Returns null when the file doesn't exist; throws a\n * GenesisConfigError naming the file when it isn't valid.\n */\nexport function readGenesisConfig(root: string): GenesisConfigFile | null {\n const file = path.join(root, \"genesis.config.json\");\n if (!existsSync(file)) return null;\n const raw: unknown = readJson(file);\n if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);\n const out: GenesisConfigFile = { raw };\n if (raw.links !== undefined) out.links = validateLinks(raw.links, file);\n if (raw.privacy !== undefined) out.privacy = validatePrivacy(raw.privacy, file);\n return out;\n}\n\nconst PRIVACY_KEYS = new Set([\"blocks\", \"collects\", \"tracking\"]);\nconst DATA_USE_KEYS = new Set([\"type\", \"purposes\", \"linked\", \"tracking\"]);\n\n/**\n * Check a `privacy` block (genesis.config.json's, or the plugin's `privacy`\n * option): a misspelt data type or purpose fails the build, since Xcode's\n * privacy report ignores values it doesn't know.\n */\nexport function validatePrivacy(raw: unknown, source = \"config\"): GenesisPrivacy {\n const fail = (msg: string): never => {\n throw new GenesisConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(`\"privacy\" must be an object`);\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!PRIVACY_KEYS.has(key)) fail(`privacy: unknown setting \"${key}\"`);\n const out: GenesisPrivacy = {};\n if (c.blocks !== undefined) {\n if (!isStringList(c.blocks)) fail(`privacy.blocks must be a list of block ids`);\n out.blocks = [...new Set(c.blocks as string[])];\n }\n if (c.tracking !== undefined) {\n if (typeof c.tracking !== \"boolean\") fail(`privacy.tracking must be true or false`);\n out.tracking = c.tracking as boolean;\n }\n if (c.collects !== undefined) {\n if (!Array.isArray(c.collects)) fail(`privacy.collects must be a list`);\n out.collects = (c.collects as unknown[]).map((entry, i) => {\n const where = `privacy.collects[${i}]`;\n if (!isObject(entry)) return fail(`${where} must be an object`);\n for (const key of Object.keys(entry)) if (!DATA_USE_KEYS.has(key)) fail(`${where}: unknown setting \"${key}\"`);\n if (typeof entry.type !== \"string\" || !privacyDataType(entry.type)) {\n fail(`${where}.type \"${String(entry.type)}\" is not one of ${Object.keys(PRIVACY_DATA_TYPES).join(\", \")}`);\n }\n if (!isStringList(entry.purposes) || entry.purposes.length === 0) fail(`${where}.purposes must be a non-empty list`);\n for (const p of entry.purposes as string[]) {\n if (!(p in PRIVACY_PURPOSES)) fail(`${where}.purposes: \"${p}\" is not one of ${Object.keys(PRIVACY_PURPOSES).join(\", \")}`);\n }\n if (typeof entry.linked !== \"boolean\") fail(`${where}.linked must be true or false`);\n if (typeof entry.tracking !== \"boolean\") fail(`${where}.tracking must be true or false`);\n return { type: entry.type as string, purposes: [...new Set(entry.purposes as string[])], linked: entry.linked as boolean, tracking: entry.tracking as boolean };\n });\n }\n return out;\n}\n\nconst LINK_KEYS = new Set([\"hosts\", \"paths\", \"webcredentials\"]);\nconst HOST = /^(?=.{1,253}$)(\\*\\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/;\n\n/** Check the `links` block, so a typo'd host fails the build instead of shipping links that never open. */\nexport function validateLinks(raw: unknown, source = \"config\"): GenesisLinks {\n const fail = (msg: string): never => {\n throw new GenesisConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(`\"links\" must be an object`);\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting \"${key}\"`);\n if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);\n for (const host of c.hosts as string[]) {\n if (!HOST.test(host)) {\n fail(`links.hosts: \"${host}\" is not a bare lower-case host name (no scheme, path or port), e.g. \"example.com\"`);\n }\n }\n if (c.paths !== undefined) {\n if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);\n for (const p of c.paths as string[]) {\n if (!p.startsWith(\"/\") || /[\\s?#*]/.test(p)) {\n fail(`links.paths: \"${p}\" must start with \"/\" and hold no spaces, \"?\", \"#\" or \"*\"`);\n }\n }\n }\n if (c.webcredentials !== undefined && typeof c.webcredentials !== \"boolean\") fail(`links.webcredentials must be true or false`);\n const links: GenesisLinks = { hosts: [...new Set(c.hosts as string[])] };\n if (c.paths !== undefined) links.paths = [...new Set(c.paths as string[])];\n if (c.webcredentials !== undefined) links.webcredentials = c.webcredentials as boolean;\n return links;\n}\n\n/** Check the shape, so a typo fails loudly instead of silently disabling a check. */\nexport function validateConfig(raw: unknown, source = \"config\"): DoctorConfig {\n const fail = (msg: string): never => {\n throw new DoctorConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(\"the doctor settings must be an object\");\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!KNOWN.has(key)) fail(`unknown setting \"${key}\"`);\n // themeCss takes one stylesheet or several; normalize to a list.\n if (typeof c.themeCss === \"string\") c.themeCss = [c.themeCss];\n if (c.themeCss !== undefined && !isStringList(c.themeCss)) fail(`\"themeCss\" must be a path or a list of paths`);\n for (const key of STRING_LISTS) {\n if (c[key] !== undefined && !isStringList(c[key])) fail(`\"${key}\" must be a list of strings`);\n }\n for (const key of STRINGS) {\n if (c[key] !== undefined && typeof c[key] !== \"string\") fail(`\"${key}\" must be a string`);\n }\n if (c.rawTags !== undefined) {\n if (!isObject(c.rawTags)) fail(`\"rawTags\" must be an object`);\n for (const [tag, v] of Object.entries(c.rawTags as object)) {\n if (!/^[a-z][a-z0-9-]*$/.test(tag)) fail(`rawTags: \"${tag}\" is not an HTML tag name`);\n if (v !== false && typeof v !== \"string\") fail(`rawTags.${tag} must be a component name or false`);\n }\n }\n if (c.forbiddenImports !== undefined) {\n if (!isObject(c.forbiddenImports)) fail(`\"forbiddenImports\" must be an object of pattern → message`);\n for (const [re, msg] of Object.entries(c.forbiddenImports as object)) {\n if (typeof msg !== \"string\") fail(`forbiddenImports[\"${re}\"] must be a message string`);\n checkRegExp(re, `forbiddenImports[\"${re}\"]`, fail);\n }\n }\n if (c.rules !== undefined) {\n if (!isObject(c.rules)) fail(`\"rules\" must be an object of rule → level`);\n for (const [rule, level] of Object.entries(c.rules as object)) {\n if (!LEVELS.has(level as string)) fail(`rules.${rule} must be \"error\", \"warn\" or \"off\"`);\n }\n }\n if (c.allow !== undefined) {\n if (!Array.isArray(c.allow)) fail(`\"allow\" must be a list`);\n (c.allow as unknown[]).forEach((e, i) => {\n if (!isObject(e)) return fail(`allow[${i}] must be an object`);\n const entry = e as Record<string, unknown>;\n if (typeof entry.rule !== \"string\" || !entry.rule) fail(`allow[${i}] needs a \"rule\"`);\n if (typeof entry.reason !== \"string\" || !entry.reason.trim()) fail(`allow[${i}] (${entry.rule}) needs a \"reason\"`);\n for (const k of [\"file\", \"match\"]) {\n if (entry[k] !== undefined && typeof entry[k] !== \"string\") fail(`allow[${i}].${k} must be a string`);\n }\n });\n }\n if (c.patterns !== undefined) {\n if (!Array.isArray(c.patterns)) fail(`\"patterns\" must be a list`);\n (c.patterns as unknown[]).forEach((p, i) => {\n if (!isObject(p)) return fail(`patterns[${i}] must be an object`);\n const rule = p as Record<string, unknown>;\n for (const k of Object.keys(rule)) if (!PATTERN_KEYS.has(k)) fail(`patterns[${i}]: unknown key \"${k}\"`);\n if (typeof rule.id !== \"string\" || !rule.id) fail(`patterns[${i}] needs an \"id\"`);\n for (const k of [\"files\", \"exclude\"]) {\n if (rule[k] !== undefined && !isStringList(rule[k])) fail(`patterns[${i}].${k} must be a list of globs`);\n }\n });\n }\n if (c.packs !== undefined) {\n if (!isStringList(c.packs)) fail(`\"packs\" must be a list, e.g. [\"native\", \"supabase\"]`);\n for (const p of c.packs as string[]) if (!PACKS.has(p)) fail(`packs: unknown pack \"${p}\" (known: ${[...PACKS].join(\", \")})`);\n if (new Set(c.packs as string[]).size !== (c.packs as string[]).length) fail(`packs: lists a pack twice`);\n }\n for (const [pack, keys] of Object.entries(PACK_KEYS)) {\n const block = c[pack];\n if (block === undefined) continue;\n if (!isObject(block)) fail(`\"${pack}\" must be an object`);\n if (!((c.packs as string[] | undefined) ?? []).includes(pack)) fail(`\"${pack}\" settings are set but the ${pack} pack is not in \"packs\"`);\n for (const [k, v] of Object.entries(block as object)) {\n const want = keys[k];\n if (!want) fail(`${pack}: unknown setting \"${k}\"`);\n if (want === \"string\" && typeof v !== \"string\") fail(`${pack}.${k} must be a string`);\n if (want === \"list\" && !isStringList(v)) fail(`${pack}.${k} must be a list of strings`);\n if (want === \"string\" && !(v as string).trim()) fail(`${pack}.${k} must not be empty`);\n if (want === \"path\") (block as Record<string, unknown>)[k] = appPath(v, `${pack}.${k}`, fail);\n }\n }\n // Schema names compare lowercased, like the SQL they're matched against.\n const supa = c.supabase as Record<string, unknown> | undefined;\n if (Array.isArray(supa?.exposedSchemas)) supa.exposedSchemas = (supa.exposedSchemas as string[]).map((s) => s.toLowerCase());\n if (c.plugins !== undefined) {\n const ok =\n Array.isArray(c.plugins) &&\n c.plugins.every((p) => typeof p === \"string\" || (Array.isArray(p) && p.length === 2 && typeof p[0] === \"string\"));\n if (!ok) fail(`\"plugins\" must be a list of module paths or [path, options] pairs`);\n }\n return c as DoctorConfig;\n}\n\nexport function checkRegExp(source: string, where: string, fail: (msg: string) => never): void {\n try {\n new RegExp(source);\n } catch (err) {\n fail(`${where} is not a valid regular expression: ${(err as Error).message}`);\n }\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction isStringList(v: unknown): v is string[] {\n return Array.isArray(v) && v.every((x) => typeof x === \"string\");\n}\n","/**\n * Minimal globs for config: `*` matches within a folder, `**` across folders,\n * `?` one character, and a trailing `/` means \"everything under this folder\".\n */\nexport function globToRegExp(glob: string): RegExp {\n let g = glob.trim().replace(/^\\.\\//, \"\");\n if (g.endsWith(\"/\")) g += \"**\";\n let out = \"\";\n for (let i = 0; i < g.length; i++) {\n const ch = g[i];\n if (ch === \"*\") {\n if (g[i + 1] === \"*\") {\n const slash = g[i + 2] === \"/\";\n out += slash ? \"(?:.*/)?\" : \".*\";\n i += slash ? 2 : 1;\n } else {\n out += \"[^/]*\";\n }\n } else if (ch === \"?\") {\n out += \"[^/]\";\n } else {\n out += ch.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n }\n }\n return new RegExp(`^${out}$`);\n}\n\n/** A matcher for a list of globs; an empty list matches nothing. */\nexport function globMatcher(globs: readonly string[] | undefined): (path: string) => boolean {\n const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);\n return (path) => res.some((re) => re.test(path));\n}\n","/**\n * Reads the rules' ground truth from the installed Genesis packages: the\n * component package's type declarations (what it exports, which exports are\n * components), the design system's theme stylesheets (which tokens exist) and\n * Tailwind's palette (which literal colors to flag). No component or token is\n * listed here, so the doctor follows whatever Genesis version the app has.\n */\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorConfig, GenesisFacts } from \"./types.js\";\n\nexport const DEFAULT_UI_PACKAGE = \"@marktiderman/genesis-ui\";\nexport const NATIVE_UI_PACKAGE = \"@marktiderman/genesis-ui-native\";\nexport const DESIGN_SYSTEM_PACKAGE = \"@marktiderman/genesis-design-system\";\n\n/**\n * Raw tags checked when Genesis ships a same-named component. `form` is left\n * out on purpose: a shadcn-style `Form` is a react-hook-form provider that\n * still wraps a real `<form>`.\n */\nconst TAGS = [\"button\", \"input\", \"textarea\", \"select\", \"label\", \"table\", \"dialog\", \"progress\", \"details\", \"summary\"];\n/** Tags whose Genesis replacement has a different name. Applied only when that component exists. */\nconst TAG_ALIASES: Record<string, string> = { hr: \"Separator\" };\n\n/** Names that look like components but are types or helpers. */\nconst NON_COMPONENT_SUFFIX = /(Props|Variant|Variants|Type|Types|Config|Context|Options|Status)$/;\n\n/** Tailwind's default palette names; merged with the app's installed `tailwindcss/colors` when present. */\nconst TAILWIND_PALETTE = [\n \"black\", \"white\", \"slate\", \"gray\", \"zinc\", \"neutral\", \"stone\", \"red\", \"orange\", \"amber\", \"yellow\", \"lime\",\n \"green\", \"emerald\", \"teal\", \"cyan\", \"sky\", \"blue\", \"indigo\", \"violet\", \"purple\", \"fuchsia\", \"pink\", \"rose\",\n \"taupe\", \"mauve\", \"mist\", \"olive\",\n];\n\n/** The installed folder of `name`, looking in node_modules from `from` upward (works with hoisting and pnpm). */\nexport function findPackageDir(from: string, name: string): string | null {\n let dir = path.resolve(from);\n for (;;) {\n const candidate = path.join(dir, \"node_modules\", name);\n if (existsSync(path.join(candidate, \"package.json\"))) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n/** What one installed component package exports, read from its type declarations. */\nexport interface PackageExports {\n dir: string;\n version: string;\n /** Every exported name (all subpaths). */\n exports: Set<string>;\n /** Exported values (not types). */\n values: Set<string>;\n /** Exported components, sorted. */\n components: string[];\n}\n\n/** The component package the core rules read: `uiPackage`, else the native one when the native pack is on. */\nexport function uiPackageFor(config: DoctorConfig): string {\n return config.uiPackage ?? (config.packs?.includes(\"native\") ? NATIVE_UI_PACKAGE : DEFAULT_UI_PACKAGE);\n}\n\nexport function loadGenesis(root: string, config: DoctorConfig): GenesisFacts {\n const uiPackage = uiPackageFor(config);\n const pkg = readPackageExports(root, uiPackage);\n if (!pkg) throw new DoctorConfigError(`${uiPackage} is not installed here. Install it, or set doctor.uiPackage.`);\n const { dir: uiDir, exports: exportNames, values, components } = pkg;\n\n // ---- Tokens, from the theme stylesheets ----\n const tokens = new Set<string>();\n const themeFiles = resolveThemeFiles(root, config, uiDir);\n for (const file of themeFiles) for (const t of declaredTokens(readFileSync(file, \"utf8\"))) tokens.add(t);\n\n // ---- Raw tags ----\n const byLower = new Map(components.map((c) => [c.toLowerCase(), c]));\n const rawTags = new Map<string, string>();\n for (const tag of TAGS) if (byLower.has(tag)) rawTags.set(tag, byLower.get(tag)!);\n for (const [tag, comp] of Object.entries(TAG_ALIASES)) if (values.has(comp)) rawTags.set(tag, comp);\n for (const [tag, comp] of Object.entries(config.rawTags ?? {})) {\n if (comp === false) rawTags.delete(tag);\n else rawTags.set(tag, comp);\n }\n\n return {\n uiPackage,\n uiVersion: pkg.version,\n exports: exportNames,\n values,\n components,\n tokens,\n rawTags,\n palette: loadPalette(root),\n };\n}\n\n/** An installed package's exports, from its declarations (every subpath), or null when it isn't installed. */\nexport function readPackageExports(root: string, uiPackage: string): PackageExports | null {\n const uiDir = findPackageDir(root, uiPackage);\n if (!uiDir) return null;\n const uiPkg = JSON.parse(readFileSync(path.join(uiDir, \"package.json\"), \"utf8\"));\n\n // ---- Exports, from every subpath's declarations ----\n const typeEntries = new Set<string>();\n const mainTypes = uiPkg.types ?? uiPkg.typings ?? exportTypes(uiPkg.exports?.[\".\"] ?? uiPkg.exports);\n if (typeof mainTypes === \"string\") typeEntries.add(mainTypes);\n for (const target of Object.values(uiPkg.exports ?? {})) {\n const t = exportTypes(target);\n if (typeof t === \"string\" && !t.includes(\"*\")) typeEntries.add(t);\n }\n const exportNames = new Set<string>();\n const reexportedPackages = new Set<string>();\n let readAny = false;\n for (const entry of typeEntries) {\n const file = path.join(uiDir, entry);\n if (!existsSync(file)) continue;\n readAny = true;\n const dts = readFileSync(file, \"utf8\");\n for (const name of parseExportNames(dts)) exportNames.add(name);\n for (const m of dts.matchAll(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*)\\s*from\\s*[\"']([^\"'.][^\"']*)[\"']/g)) {\n reexportedPackages.add(packageName(m[1]));\n }\n }\n if (!readAny) {\n throw new DoctorConfigError(`${uiPackage} has no type declarations to read (is it built?). Looked for: ${[...typeEntries].join(\", \") || \"none\"}`);\n }\n\n // ---- Which exports are types only, from every declaration file it ships ----\n const valueDecls = new Set<string>();\n const typeDecls = new Set<string>();\n const declRoot = typeof mainTypes === \"string\" ? path.dirname(path.join(uiDir, mainTypes)) : uiDir;\n // Names re-exported from other packages (e.g. genesis-core's types) are declared there.\n const declFiles = walkDts(declRoot);\n for (const pkg of reexportedPackages) {\n const dir = findPackageDir(uiDir, pkg);\n if (dir) walkDts(path.join(dir, \"dist\"), declFiles);\n }\n for (const file of declFiles) {\n const text = readFileSync(file, \"utf8\");\n for (const m of text.matchAll(/\\b(?:declare\\s+)?(?:const|let|var|function|class|enum)\\s+([A-Za-z_$][\\w$]*)/g)) valueDecls.add(m[1]);\n for (const m of text.matchAll(/\\b(?:interface|type)\\s+([A-Za-z_$][\\w$]*)/g)) typeDecls.add(m[1]);\n }\n const isTypeOnly = (n: string) => typeDecls.has(n) && !valueDecls.has(n);\n const values = new Set([...exportNames].filter((n) => !isTypeOnly(n)));\n const components = [...values]\n // PascalCase (H1 and P included), but not SCREAMING_CASE constants.\n .filter((n) => /^[A-Z][A-Za-z0-9]*$/.test(n) && !(n.length > 2 && n === n.toUpperCase()) && !NON_COMPONENT_SUFFIX.test(n))\n .sort();\n return { dir: uiDir, version: String(uiPkg.version ?? \"unknown\"), exports: exportNames, values, components };\n}\n\n/** Names exported by a declaration file: `export { a, b as c }` blocks and `export declare …` statements. */\nexport function parseExportNames(dts: string): string[] {\n const names: string[] = [];\n for (const m of dts.matchAll(/export\\s+(?:type\\s+)?\\{([^}]*)\\}/g)) {\n for (const part of m[1].split(\",\")) {\n const name = part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/).pop()?.trim();\n if (name && name !== \"default\") names.push(name);\n }\n }\n for (const m of dts.matchAll(/export\\s+(?:declare\\s+)?(?:const|let|function|class|enum|interface|type)\\s+([A-Za-z_$][\\w$]*)/g)) {\n names.push(m[1]);\n }\n return names;\n}\n\n/** Custom properties a stylesheet declares (`--name:`). */\nexport function declaredTokens(css: string): string[] {\n return [...css.matchAll(/(--[A-Za-z0-9_-]+)\\s*:/g)].map((m) => m[1]);\n}\n\nfunction packageName(specifier: string): string {\n const parts = specifier.split(\"/\");\n return parts.slice(0, specifier.startsWith(\"@\") ? 2 : 1).join(\"/\");\n}\n\nfunction exportTypes(target: unknown): string | undefined {\n if (!target || typeof target !== \"object\") return undefined;\n const t = target as Record<string, unknown>;\n if (typeof t.types === \"string\") return t.types;\n for (const key of [\"import\", \"default\", \"require\"]) {\n const nested = exportTypes(t[key]);\n if (nested) return nested;\n }\n return undefined;\n}\n\nfunction walkDts(dir: string, out: string[] = []): string[] {\n if (!existsSync(dir)) return out;\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === \"node_modules\") continue;\n const p = path.join(dir, entry.name);\n if (entry.isDirectory()) walkDts(p, out);\n else if (/\\.d\\.[cm]?ts$/.test(entry.name)) out.push(p);\n }\n return out;\n}\n\nfunction resolveThemeFiles(root: string, config: DoctorConfig, uiDir: string): string[] {\n if (config.themeCss) {\n const specs = typeof config.themeCss === \"string\" ? [config.themeCss] : config.themeCss;\n return specs.map((spec) => {\n const file = resolveSpec(root, spec);\n if (!file) throw new DoctorConfigError(`doctor.themeCss: cannot find ${spec}`);\n return file;\n });\n }\n const files: string[] = [];\n const ds = findPackageDir(root, DESIGN_SYSTEM_PACKAGE);\n const themes = ds && path.join(ds, \"dist\", \"themes\");\n if (themes && existsSync(themes)) {\n for (const name of readdirSync(themes).sort()) if (name.endsWith(\".css\")) files.push(path.join(themes, name));\n }\n if (files.length === 0) {\n throw new DoctorConfigError(\n `No Genesis theme stylesheet found (${DESIGN_SYSTEM_PACKAGE}/dist/themes/*.css). Install the design system, or set doctor.themeCss.`,\n );\n }\n const uiStyles = path.join(uiDir, \"dist\", \"styles.css\");\n if (existsSync(uiStyles)) files.push(uiStyles);\n return files;\n}\n\n/** An app-relative path, or `package/sub/path` resolved inside that installed package. */\nfunction resolveSpec(root: string, spec: string): string | null {\n const local = path.resolve(root, spec);\n if (spec.startsWith(\".\") || path.isAbsolute(spec)) return existsSync(local) ? local : null;\n const parts = spec.split(\"/\");\n const nameLength = spec.startsWith(\"@\") ? 2 : 1;\n const dir = findPackageDir(root, parts.slice(0, nameLength).join(\"/\"));\n if (dir) {\n const file = path.join(dir, ...parts.slice(nameLength));\n if (existsSync(file) && statSync(file).isFile()) return file;\n }\n return existsSync(local) ? local : null;\n}\n\nfunction loadPalette(root: string): string[] {\n const names = new Set(TAILWIND_PALETTE);\n try {\n const req = createRequire(path.join(root, \"package.json\"));\n const colors = req(\"tailwindcss/colors\");\n for (const key of Object.keys(colors?.default ?? colors ?? {})) {\n if (/^[a-z]+$/.test(key) && ![\"inherit\", \"current\", \"transparent\"].includes(key)) names.add(key);\n }\n } catch {\n // No Tailwind installed (or it is ESM-only): the built-in list stands.\n }\n return [...names].sort();\n}\n","/**\n * color-literals.mjs — the raw-color lexer shared by scripts/check-token-usage.mjs\n * and `genesis doctor` (packages/genesis-cli, which bundles this file at build\n * time). One implementation, so a bypass fixed here is fixed in both gates.\n *\n * Pure functions only: no filesystem, no process state.\n */\n\n// Extensions where `//` opens a genuine line comment (C-style langs, plus the\n// CSS supersets SCSS/LESS which DO have `//`). Plain `.css` is deliberately\n// absent: CSS has NO `//` line comment, and an unquoted `url(https://cdn/x.svg)`\n// contains `//`. Treating that `//` as a comment blanks the rest of the line, so\n// a real hex after it (`... color: #ff0000;`) never gets scanned and the gate is\n// bypassed. Only files with this extension run the `//` branch in\n// stripBlockComments(); `/* ... */` block comments are stripped for ALL types.\nexport const LINE_COMMENT_EXTS = new Set(['.ts', '.tsx', '.jsx', '.js', '.mjs', '.cjs', '.scss', '.less']);\n\n// Numeric HTML entities (`&#1234;`) are not colors.\nconst HTML_ENTITY_RE = /&#\\d+;/g;\n\n// Blank out `/* ... */` block comments (JS/TS JSDoc AND CSS comments) while\n// preserving line numbers, so hex inside a comment is ignored without skipping\n// any `*`-prefixed CSS selector line. Uses escape-aware lexical scanning to\n// avoid removing comment-like sequences inside string and template literals.\n//\n// `hasLineComments` gates the `//` line-comment branch: pass `true` only for\n// file types where `//` is a real line comment (see LINE_COMMENT_EXTS). For\n// plain CSS it must be `false`, otherwise `url(https://…)` gets blanked from the\n// `//` onward and any hex after it slips past the gate. String/template/`/* */`\n// handling is unaffected by this flag and runs for ALL file types.\n/** Blank out C-style block comments (and `//` line comments when enabled) while preserving line numbers and skipping string/template literals. */\nexport function stripBlockComments(content, hasLineComments = true) {\n let result = '';\n let i = 0;\n const len = content.length;\n\n while (i < len) {\n const ch = content[i];\n const next = i + 1 < len ? content[i + 1] : '';\n const prevIsColon = i > 0 && content[i - 1] === ':';\n const prevIsBackslash = i > 0 && content[i - 1] === '\\\\';\n\n // Handle string literals: \"...\" with escape support\n if (ch === '\"') {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === '\"') {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle string literals: '...' with escape support\n if (ch === \"'\") {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === \"'\") {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle template literals: `...` with escape support\n if (ch === '`') {\n result += ch;\n i++;\n while (i < len) {\n const c = content[i];\n result += c;\n if (c === '\\\\' && i + 1 < len) {\n result += content[i + 1]; // escaped character\n i += 2;\n } else if (c === '`') {\n i++;\n break;\n } else {\n i++;\n }\n }\n continue;\n }\n\n // Handle CSS/SCSS/LESS `url(...)` tokens. The contents of `url(...)` are\n // NEVER a comment regardless of scheme, so consume the whole token verbatim\n // through to the matching `)` and do NOT let the `//` inside it open a line\n // comment. This structurally closes the entire `url()`-`//` bypass class in\n // one place — `url(//cdn/x)` (protocol-relative), `url(https://…)` and\n // `url(http://…)` all stay scannable, so a trailing `color: #ff0000;` on the\n // same line is still caught (CMT-250-004 + Codex protocol-relative P2).\n // Detect an `url` identifier (case-insensitive) directly followed by `(`,\n // where `u` starts the identifier (previous char is not an identifier char,\n // so `blurUrl(` / `baseurl(` don't match). Quotes inside are respected via\n // the same escape rules as string state, so a `)` inside `url(\"a)b\")` does\n // not end the token early; `/* */` is left intact (never appears in url()).\n if (\n (ch === 'u' || ch === 'U') &&\n content.slice(i, i + 4).toLowerCase() === 'url(' &&\n !/[\\w$]/.test(content[i - 1] ?? '')\n ) {\n result += content.slice(i, i + 4); // 'url('\n i += 4;\n while (i < len && content[i] !== ')') {\n const c = content[i];\n if (c === '\"' || c === \"'\") {\n // Consume a quoted segment (escape-aware) so a `)` inside it is not\n // mistaken for the url() close.\n result += c;\n i++;\n while (i < len) {\n const q = content[i];\n result += q;\n if (q === '\\\\' && i + 1 < len) {\n result += content[i + 1];\n i += 2;\n } else if (q === c) {\n i++;\n break;\n } else {\n i++;\n }\n }\n } else {\n result += c;\n i++;\n }\n }\n if (i < len && content[i] === ')') {\n result += ')';\n i++;\n }\n continue;\n }\n\n // Handle line comments: // ... to end of line\n // A `//` at top level must NOT open string/template/block state: an\n // apostrophe in a contraction (\"don't\") inside a line comment would\n // otherwise enter string-mode and consume across the newline, corrupting\n // the stripping of a following real block comment (CMT-250-001).\n // Gated on `hasLineComments`: plain CSS has no `//` comment (an unquoted\n // `url(https://…)` contains `//`), so this branch is skipped there and the\n // `//` is treated as ordinary content, keeping any following hex scannable.\n // The `url(...)` branch above already neutralizes `//` inside url() for ALL\n // file types; the guards below are defense-in-depth for `//` sequences that\n // arise OUTSIDE url(). Skip when the `//` is immediately preceded by `:` — a\n // URL scheme separator (`http://`, `https://`), not a comment (CMT-250-004).\n // AND skip when the `//` is immediately preceded by `\\` — strings/templates\n // are already lexed above, so a backslash in code state means we are inside\n // a regex literal (e.g. `/https?:\\/\\//`), where the escaped `\\/` + closing\n // `/` read as `//`. Without this the rest of the line (and any hex on it)\n // would be blanked and slip past the gate (Codex P2, same bypass class).\n if (hasLineComments && ch === '/' && next === '/' && !prevIsColon && !prevIsBackslash) {\n let j = i + 2;\n while (j < len && content[j] !== '\\n') {\n j++;\n }\n const commentLen = j - i;\n // Blank comment chars to spaces; the trailing `\\n` (if any) is left for\n // the next iteration so line numbers are preserved.\n const commentText = content.slice(i, i + commentLen);\n result += commentText.replace(/[^\\n]/g, ' ');\n i += commentLen;\n continue;\n }\n\n // Handle block comments: /* ... */\n if (ch === '/' && next === '*') {\n let commentLen = 2;\n let j = i + 2;\n while (j < len) {\n if (content[j] === '*' && j + 1 < len && content[j + 1] === '/') {\n commentLen = j + 2 - i;\n break;\n }\n j++;\n }\n // Replace non-newline chars with spaces to preserve line numbers\n const commentText = content.slice(i, i + commentLen);\n result += commentText.replace(/[^\\n]/g, ' ');\n i += commentLen;\n continue;\n }\n\n // Regular character\n result += ch;\n i++;\n }\n\n return result;\n}\n\n// Hex color literal: `#` + 3, 4, 6, or 8 hex digits, NOT inside an HTML\n// entity (which is `&#1234;` — pure decimal). The match is intentionally\n// generous (any hex run in {3,4,6,8}); the all-digits-in-3/4 case is\n// filtered out post-match because pure-decimal `#163` / `#1284`\n// overwhelmingly appears in natural language as issue / order refs\n// (\"Merged PR #163\", \"Order #1284\") rather than as colors. CSS\n// developers writing literal short-hand colors almost always include a\n// letter (`#fff`, `#a1b`, `#0af`). For 6- and 8-digit forms we accept\n// all-digit hex (`#000000` is a real color). False-negative tradeoff:\n// `#123` written as a short-hand for `#112233` will pass — but the\n// long-form is the dominant style, and the alternative (false-positive\n// every issue reference) is worse.\nconst HEX_RE = /(^|[^\\w&])#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\\b/g;\nconst HEX_LETTER_RE = /[a-fA-F]/;\n\n// Color-function literal: rgb()/rgba()/hsl()/hsla() whose first argument is a\n// number or percentage — e.g. `rgba(0,0,0,0.08)`, `rgb(0 0 0 / 0.1)`,\n// `hsl(160 84% 39%)`. Raw color-function literals sneak past the hex check\n// (finding #4: `rgba(0,0,0,0.08)` borders), so they're flagged the same way.\n// Requiring a digit/`.` right after `(` deliberately spares token-backed forms\n// like `hsl(var(--primary))` — those reference a CSS variable, not a raw\n// literal — and non-color CSS functions (translate(), scale(), matrix()) never\n// match the rgb/rgba/hsl/hsla names. The match is captured up to the first\n// closing paren for the reported literal.\nconst COLOR_FN_RE = /\\b(rgba?|hsla?)\\(\\s*[\\d.][^)\\n]*\\)?/gi;\n\n/** Strip numeric HTML entities (`&#1234;`) from a line so they are not mistaken for hex color literals. */\nfunction stripHtmlEntities(line) {\n return line.replace(HTML_ENTITY_RE, '');\n}\n\n/** Find raw hex color literals in a line, filtering out decimal-only 3/4-digit matches (likely issue/order refs). */\nexport function findHexLiterals(line) {\n const cleaned = stripHtmlEntities(line);\n const matches = [];\n let m;\n HEX_RE.lastIndex = 0;\n while ((m = HEX_RE.exec(cleaned)) !== null) {\n const digits = m[2];\n // Filter pure-decimal 3/4-digit matches as likely issue refs (#163,\n // #1284). 6/8-digit forms are accepted unconditionally.\n if (digits.length <= 4 && !HEX_LETTER_RE.test(digits)) continue;\n const literal = `#${digits}`;\n const idx = m.index + m[1].length;\n matches.push({ literal, column: idx + 1 });\n }\n return matches;\n}\n\n/** Find raw rgb()/rgba()/hsl()/hsla() literals with numeric arguments in a line (token-backed `hsl(var(--x))` is spared). */\nexport function findColorFunctions(line) {\n const cleaned = stripHtmlEntities(line);\n const matches = [];\n let m;\n COLOR_FN_RE.lastIndex = 0;\n while ((m = COLOR_FN_RE.exec(cleaned)) !== null) {\n matches.push({ literal: m[0], column: m.index + 1 });\n }\n return matches;\n}\n","/**\n * Collects the app files the doctor checks.\n */\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { LINE_COMMENT_EXTS, stripBlockComments } from \"../../../../scripts/lib/color-literals.mjs\";\nimport { globMatcher } from \"./glob.js\";\nimport type { DoctorConfig, SourceFile } from \"./types.js\";\n\nexport const DEFAULT_SRC = [\"src\"];\n/** Expo apps keep routes in `app/` and shared UI in `components/` at the root. */\nexport const DEFAULT_NATIVE_SRC = [\"app\", \"src\", \"components\"];\nexport const DEFAULT_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".css\"];\n/** Always skipped: tests, fixtures, declarations and generated files are not shipped UI. */\nexport const DEFAULT_IGNORE = [\n \"**/*.d.ts\",\n \"**/*.gen.*\",\n \"**/*.test.*\",\n \"**/*.spec.*\",\n \"**/__tests__/**\",\n \"**/__fixtures__/**\",\n \"**/__mocks__/**\",\n];\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \".next\", \".output\", \".turbo\", \"coverage\"]);\nconst MAX_FILE_BYTES = 2 * 1024 * 1024;\n\nconst toPosix = (p: string) => p.split(path.sep).join(\"/\");\n\nexport function scanFiles(root: string, config: DoctorConfig): SourceFile[] {\n const extensions = new Set(config.extensions ?? DEFAULT_EXTENSIONS);\n const ignored = globMatcher([...DEFAULT_IGNORE, ...(config.ignore ?? [])]);\n const files: SourceFile[] = [];\n const seen = new Set<string>();\n const visit = (abs: string) => {\n const rel = toPosix(path.relative(root, abs));\n if (seen.has(rel) || ignored(rel)) return;\n const ext = path.extname(abs);\n if (!extensions.has(ext)) return;\n if (statSync(abs).size > MAX_FILE_BYTES) return;\n seen.add(rel);\n const text = readFileSync(abs, \"utf8\");\n files.push({ path: rel, absolutePath: abs, ext, text, code: stripBlockComments(text, LINE_COMMENT_EXTS.has(ext)) });\n };\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n if (entry.isDirectory()) {\n if (!SKIP_DIRS.has(entry.name)) walk(path.join(dir, entry.name));\n } else if (entry.isFile()) {\n visit(path.join(dir, entry.name));\n }\n }\n };\n for (const src of config.src ?? (config.packs?.includes(\"native\") ? DEFAULT_NATIVE_SRC : DEFAULT_SRC)) {\n const abs = path.resolve(root, src);\n if (!existsSync(abs)) continue;\n if (statSync(abs).isDirectory()) walk(abs);\n else visit(abs);\n }\n return files;\n}\n\n/** 1-based line of a character offset. */\nexport function lineAt(text: string, index: number): number {\n let line = 1;\n for (let i = 0; i < index && i < text.length; i++) if (text.charCodeAt(i) === 10) line++;\n return line;\n}\n","/**\n * Declarative app rules: from config `patterns`, or from a markdown rules\n * document so the rules can live next to the prose that explains them.\n *\n * The markdown format: a `### rule-id` heading starts a rule; the `- key: value`\n * lines under it (level, files, exclude, forbid, require, path, message) set\n * it; any `#` or `##` heading ends it. `files`/`exclude` are comma-separated.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport { globMatcher } from \"./glob.js\";\nimport { lineAt } from \"./scan.js\";\nimport type { DoctorContext, DoctorPlugin, PatternRule } from \"./types.js\";\n\nexport function parseRulesMarkdown(markdown: string): PatternRule[] {\n const rules: PatternRule[] = [];\n let current: PatternRule | null = null;\n for (const line of markdown.split(\"\\n\")) {\n const heading = line.match(/^###\\s+([A-Za-z0-9_-]+)\\s*$/);\n if (heading) {\n current = { id: heading[1] };\n rules.push(current);\n continue;\n }\n if (/^#{1,2}\\s/.test(line)) {\n current = null;\n continue;\n }\n const kv = current && line.match(/^-\\s+(level|files|exclude|forbid|require|path|message):\\s*(.*)$/);\n if (!current || !kv) continue;\n const [, key, raw] = kv;\n const value = raw.trim();\n if (key === \"files\" || key === \"exclude\") current[key] = value.split(\",\").map((s) => s.trim()).filter(Boolean);\n else if (key === \"level\") current.level = value as PatternRule[\"level\"];\n else current[key as \"forbid\" | \"require\" | \"path\" | \"message\"] = value;\n }\n return rules;\n}\n\n/** `(?i)` at the start means case-insensitive, as in the markdown format. */\nfunction toRegExp(source: string, flags = \"\"): RegExp {\n if (source.startsWith(\"(?i)\")) return new RegExp(source.slice(4), flags + \"i\");\n return new RegExp(source, flags);\n}\n\ninterface CompiledRule {\n rule: PatternRule;\n level: \"error\" | \"warn\";\n includes: (p: string) => boolean;\n excludes: (p: string) => boolean;\n forbid?: RegExp;\n require?: RegExp;\n path?: RegExp;\n}\n\n/** Validate and compile rules up front, so a broken pattern fails the run with its rule id. */\nexport function compilePatternRules(rules: PatternRule[], source: string): CompiledRule[] {\n const ids = new Set<string>();\n const out: CompiledRule[] = [];\n for (const rule of rules) {\n if (ids.has(rule.id)) throw new DoctorConfigError(`${source}: rule \"${rule.id}\" is defined twice`);\n ids.add(rule.id);\n const level = rule.level ?? \"error\";\n if (![\"error\", \"warn\", \"guide\"].includes(level)) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" has level \"${level}\" (use error, warn or guide)`);\n }\n if (level === \"guide\") continue;\n if (!rule.files?.length) throw new DoctorConfigError(`${source}: rule \"${rule.id}\" needs \"files\" (or level: guide)`);\n if (!rule.forbid && !rule.require && !rule.path) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" needs forbid, require or path (or level: guide)`);\n }\n try {\n out.push({\n rule,\n level,\n includes: globMatcher(rule.files),\n excludes: globMatcher(rule.exclude),\n forbid: rule.forbid ? toRegExp(rule.forbid, \"m\") : undefined,\n require: rule.require ? toRegExp(rule.require, \"m\") : undefined,\n path: rule.path ? toRegExp(rule.path) : undefined,\n });\n } catch (err) {\n throw new DoctorConfigError(`${source}: rule \"${rule.id}\" has an invalid pattern: ${(err as Error).message}`);\n }\n }\n return out;\n}\n\n/** Pattern rules from config and the rules doc, as one plugin. Returns null when there are none. */\nexport function loadPatternRules(root: string, patterns: PatternRule[] | undefined, rulesDoc: string | undefined): { plugin: DoctorPlugin; count: number } | null {\n const compiled = compilePatternRules(patterns ?? [], \"doctor.patterns\");\n let all = compiled;\n if (rulesDoc) {\n const file = path.resolve(root, rulesDoc);\n if (!existsSync(file)) throw new DoctorConfigError(`doctor.rulesDoc: ${rulesDoc} not found`);\n const fromDoc = compilePatternRules(parseRulesMarkdown(readFileSync(file, \"utf8\")), rulesDoc);\n const clash = fromDoc.find((d) => compiled.some((c) => c.rule.id === d.rule.id));\n if (clash) throw new DoctorConfigError(`rule \"${clash.rule.id}\" is defined in both doctor.patterns and ${rulesDoc}`);\n all = [...compiled, ...fromDoc];\n }\n if (all.length === 0) return null;\n return {\n count: all.length,\n plugin: {\n name: \"patterns\",\n check(ctx: DoctorContext) {\n for (const r of all) {\n const message = r.rule.message ?? \"breaks a design rule\";\n for (const file of ctx.files) {\n if (!r.includes(file.path) || r.excludes(file.path)) continue;\n const report = (line: number) => ctx.report({ rule: r.rule.id, level: r.level, file: file.path, line, message });\n if (r.path && !r.path.test(file.path)) report(0);\n if (r.require && !r.require.test(file.code)) report(0);\n if (r.forbid) {\n const m = r.forbid.exec(file.code);\n if (m) report(lineAt(file.code, m.index));\n }\n }\n }\n },\n },\n };\n}\n","/**\n * Loads app rule modules listed in config `plugins`.\n *\n * A module default-exports a plugin, an array of plugins, or a function that\n * takes the options from `[\"./path.mjs\", options]` and returns either.\n */\nimport { statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorPlugin, PluginSpec } from \"./types.js\";\n\n/** Identity helper that types a plugin. */\nexport function defineDoctorPlugin(plugin: DoctorPlugin): DoctorPlugin {\n return plugin;\n}\n\nexport async function loadPlugins(specs: PluginSpec[] | undefined, configDir: string): Promise<DoctorPlugin[]> {\n const plugins: DoctorPlugin[] = [];\n for (const spec of specs ?? []) {\n const [id, options] = typeof spec === \"string\" ? [spec, undefined] : spec;\n const file = resolvePlugin(id, configDir);\n // The mtime query re-imports an edited module in a long-lived dev server.\n const url = `${pathToFileURL(file).href}?mtime=${statSync(file).mtimeMs}`;\n let mod: { default?: unknown };\n try {\n mod = await import(url);\n } catch (err) {\n throw new DoctorConfigError(`doctor.plugins: could not load ${id}: ${(err as Error).message}`);\n }\n let value = mod.default;\n if (typeof value === \"function\") value = await (value as (o: unknown) => unknown)(options);\n const list = Array.isArray(value) ? value : [value];\n for (const p of list) {\n if (!p || typeof p !== \"object\" || typeof (p as DoctorPlugin).check !== \"function\" || typeof (p as DoctorPlugin).name !== \"string\") {\n throw new DoctorConfigError(`doctor.plugins: ${id} must default-export { name, check(context) } (or an array, or a factory returning one)`);\n }\n plugins.push(p as DoctorPlugin);\n }\n }\n return plugins;\n}\n\nfunction resolvePlugin(id: string, configDir: string): string {\n try {\n if (id.startsWith(\".\") || path.isAbsolute(id)) return resolveFrom(path.resolve(configDir, id), configDir);\n return resolveFrom(id, configDir);\n } catch {\n throw new DoctorConfigError(`doctor.plugins: cannot find ${id} (relative paths resolve from ${configDir})`);\n }\n}\n\nfunction resolveFrom(id: string, from: string): string {\n return createRequire(path.join(from, \"noop.js\")).resolve(id);\n}\n","/**\n * The built-in, app-agnostic checks. Each is driven by facts read from the\n * installed Genesis packages, never by a hardcoded component or token list.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { findColorFunctions, findHexLiterals } from \"../../../../scripts/lib/color-literals.mjs\";\nimport { globMatcher } from \"./glob.js\";\nimport { declaredTokens } from \"./genesis.js\";\nimport type { DoctorContext, SourceFile } from \"./types.js\";\n\n/** Ids of the built-in rules, for `rules` overrides and `allow` entries. */\nexport const BUILTIN_RULES = [\n \"local-primitives\",\n \"starter-leftover\",\n \"forbidden-import\",\n \"raw-tag\",\n \"palette-color\",\n \"arbitrary-color\",\n \"raw-color\",\n \"undefined-token\",\n \"shadowed-export\",\n \"version-skew\",\n // native pack\n \"native-raw-primitive\",\n \"native-literal-color\",\n \"native-custom-header\",\n \"native-screen-layout\",\n \"store-readiness\",\n // supabase pack\n \"migration-grants\",\n \"migration-rls\",\n \"migration-definer-search-path\",\n \"migration-edited\",\n] as const;\n\nexport const DEFAULT_LOCAL_PRIMITIVE_DIRS = [\"src/components/ui\"];\nconst STARTER_LEFTOVERS = [\"components.json\", \"src/lib/utils.ts\"];\nconst DEFAULT_IGNORE_TOKEN_PREFIXES = [\"--tw-\", \"--radix-\"];\n\nconst JSX_EXTS = new Set([\".tsx\", \".jsx\"]);\nconst SCRIPT_EXTS = new Set([\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".mjs\", \".cjs\"]);\n\n/** Every module specifier a file imports or re-exports, with its 1-based line. */\nexport function importSpecifiers(file: SourceFile): Array<{ specifier: string; line: number }> {\n const out: Array<{ specifier: string; line: number }> = [];\n const lines = file.code.split(\"\\n\");\n const re = /(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*|@import\\s+)[\"']([^\"']+)[\"']/g;\n lines.forEach((text, i) => {\n for (const m of text.matchAll(re)) out.push({ specifier: m[1], line: i + 1 });\n });\n return out;\n}\n\nexport function checkProjectLayout(ctx: DoctorContext): void {\n for (const dir of ctx.config.localPrimitiveDirs ?? DEFAULT_LOCAL_PRIMITIVE_DIRS) {\n if (existsSync(path.join(ctx.root, dir))) {\n ctx.report({\n rule: \"local-primitives\",\n file: dir,\n subject: dir,\n message: `is a local design-system primitive folder; use ${ctx.genesis.uiPackage} (or extend it upstream)`,\n });\n }\n }\n for (const file of STARTER_LEFTOVERS) {\n if (existsSync(path.join(ctx.root, file))) {\n ctx.report({\n rule: \"starter-leftover\",\n level: \"warn\",\n file,\n subject: file,\n message: `is a starter leftover; Genesis ships cn and owns the components`,\n });\n }\n }\n}\n\nexport function checkImports(ctx: DoctorContext): void {\n const ui = ctx.genesis.uiPackage;\n const forbidden: Array<[RegExp, string]> = [\n [/^@radix-ui\\//, `imports Radix directly; use the Genesis wrapper from ${ui}`],\n [/^(?:[@~#]\\/|\\.{1,2}\\/)(?:.*\\/)?components\\/ui(?:\\/|$)/, `imports a local UI primitive; use ${ui}`],\n [/^[@~#]\\/lib\\/utils$/, `imports the starter's utils; use cn from ${ui}`],\n ...Object.entries(ctx.config.forbiddenImports ?? {}).map(([re, msg]) => [new RegExp(re), msg] as [RegExp, string]),\n ];\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n for (const { specifier, line } of importSpecifiers(file)) {\n const hit = forbidden.find(([re]) => re.test(specifier));\n if (hit) ctx.report({ rule: \"forbidden-import\", file: file.path, line, subject: specifier, message: `${hit[1]} ('${specifier}')` });\n }\n }\n}\n\nexport function checkRawTags(ctx: DoctorContext): void {\n const tags = [...ctx.genesis.rawTags].map(([tag, component]) => [tag, component, new RegExp(`<${tag}(?=[\\\\s>/]|$)`)] as const);\n if (tags.length === 0) return;\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext)) continue;\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const [tag, component, re] of tags) {\n if (re.test(text)) {\n ctx.report({ rule: \"raw-tag\", file: file.path, line: i + 1, subject: tag, message: `renders a raw <${tag}>; use Genesis ${component}` });\n }\n }\n });\n }\n}\n\n/** Tailwind utilities that take a color. */\nconst COLOR_UTILITIES = \"bg|text|border(?:-[xytrbls])?|ring|ring-offset|fill|stroke|from|to|via|outline|divide|decoration|shadow|accent|caret|placeholder\";\nconst ARBITRARY_COLOR_RE = /(?<![\\w-])[a-z][a-z-]*-\\[(?:#|(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\\()[^\\]]*\\]/g;\n\nexport function checkColors(ctx: DoctorContext): void {\n const palette = new RegExp(\n `(?<![\\\\w-])(?:${COLOR_UTILITIES})-(?:${ctx.genesis.palette.join(\"|\")})(?:-\\\\d{2,3})?(?:\\\\/\\\\d{1,3})?(?![\\\\w-])`,\n \"g\",\n );\n // With the native pack, literals in code are style values: report them as native-literal-color with the native fix.\n const native = ctx.config.packs?.includes(\"native\") ?? false;\n const themeRoles = ctx.genesis.values.has(\"useThemeRoles\") ? \"a theme role (useThemeRoles())\" : \"a theme role\";\n for (const file of ctx.files) {\n const nativeCode = native && SCRIPT_EXTS.has(file.ext);\n file.code.split(\"\\n\").forEach((text, i) => {\n const line = i + 1;\n for (const m of text.matchAll(palette)) {\n ctx.report({ rule: \"palette-color\", file: file.path, line, subject: m[0], message: `uses the literal palette color '${m[0]}'; use a semantic token (bg-primary, text-muted-foreground, …)` });\n }\n // Arbitrary values are reported once, as arbitrary-color, not again as raw-color.\n const arbitrary: Array<[number, number]> = [];\n for (const m of text.matchAll(ARBITRARY_COLOR_RE)) {\n arbitrary.push([m.index!, m.index! + m[0].length]);\n ctx.report({ rule: \"arbitrary-color\", file: file.path, line, subject: m[0], message: `uses the arbitrary color '${m[0]}'; define it as a brand token first` });\n }\n for (const hit of [...findHexLiterals(text), ...findColorFunctions(text)]) {\n const at = hit.column - 1;\n if (arbitrary.some(([a, b]) => at >= a && at < b)) continue;\n if (nativeCode) {\n ctx.report({\n rule: \"native-literal-color\",\n file: file.path,\n line,\n subject: hit.literal,\n message: `hardcodes the color ${hit.literal}; use ${themeRoles}, a token className (bg-primary, text-muted-foreground) or PlatformColor(...)`,\n });\n continue;\n }\n ctx.report({ rule: \"raw-color\", file: file.path, line, subject: hit.literal, message: `hardcodes the color ${hit.literal}; color values come from Genesis tokens` });\n }\n });\n }\n}\n\nexport function checkTokens(ctx: DoctorContext): void {\n const defined = new Set(ctx.genesis.tokens);\n const isTokenFile = ctx.config.tokenFiles ? globMatcher(ctx.config.tokenFiles) : (p: string) => p.endsWith(\".css\");\n for (const file of ctx.files) {\n if (isTokenFile(file.path)) for (const t of declaredTokens(file.code)) defined.add(t);\n // A custom property set inline (style={{ \"--progress\": \"40%\" }}) is a runtime variable, not a token.\n for (const m of file.code.matchAll(/[\"'](--[A-Za-z0-9_-]+)[\"']\\s*:/g)) defined.add(m[1]);\n }\n // Token files outside the scanned folders (e.g. a brand package).\n for (const pattern of ctx.config.tokenFiles ?? []) {\n if (/[*?]/.test(pattern)) continue;\n const abs = path.join(ctx.root, pattern);\n if (!ctx.files.some((f) => f.absolutePath === abs) && existsSync(abs)) {\n for (const t of declaredTokens(readFileSync(abs, \"utf8\"))) defined.add(t);\n }\n }\n const ignorePrefixes = ctx.config.ignoreTokenPrefixes ?? DEFAULT_IGNORE_TOKEN_PREFIXES;\n for (const file of ctx.files) {\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const m of text.matchAll(/var\\(\\s*(--[A-Za-z0-9_-]+)/g)) {\n const token = m[1];\n if (defined.has(token) || ignorePrefixes.some((p) => token.startsWith(p))) continue;\n ctx.report({ rule: \"undefined-token\", file: file.path, line: i + 1, subject: token, message: `references the undefined token ${token}; define it in Genesis or the brand` });\n }\n });\n }\n}\n\nexport function checkShadowedExports(ctx: DoctorContext): void {\n const re = /\\bexport\\s+(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?(?:function\\*?|const|let|var|class)\\s+([A-Z][\\w$]*)/g;\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n file.code.split(\"\\n\").forEach((text, i) => {\n for (const m of text.matchAll(re)) {\n if (!ctx.genesis.values.has(m[1])) continue;\n ctx.report({ rule: \"shadowed-export\", file: file.path, line: i + 1, subject: m[1], message: `shadows the Genesis export '${m[1]}'; reuse or extend Genesis ${m[1]}` });\n }\n });\n }\n}\n\n/** Genesis components that no scanned file imports (named imports or re-exports from the package or its subpaths). */\nexport function unusedComponents(ctx: Pick<DoctorContext, \"files\" | \"genesis\">): string[] {\n const used = new Set<string>();\n const pkg = ctx.genesis.uiPackage.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n const re = new RegExp(`\\\\b(?:import|export)\\\\s+(?:type\\\\s+)?(?:[\\\\w$]+\\\\s*,\\\\s*)?\\\\{([^}]*)\\\\}\\\\s*from\\\\s*[\"']${pkg}(?:/[^\"']*)?[\"']`, \"g\");\n for (const file of ctx.files) {\n for (const m of file.code.matchAll(re)) {\n for (const part of m[1].split(\",\")) {\n const name = part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim();\n if (name) used.add(name);\n }\n }\n }\n return ctx.genesis.components.filter((c) => !used.has(c));\n}\n\n","/**\n * native-primitives.mjs — the React Native primitives Genesis wraps, shared by\n * scripts/check-forbidden-imports.mjs and `genesis doctor`'s native pack\n * (packages/genesis-cli, which bundles this file at build time). One list, so\n * the repo gate and the doctor can't drift.\n *\n * Importing the raw primitive skips Genesis theming and a11y defaults. Keep the\n * list small and intentional: `View`, `Text`, `Pressable`, `ScrollView`,\n * `StyleSheet` stay free imports because layout and performance code needs\n * them. Expanding it is a design-system decision, not a CI tweak.\n *\n * Pure data and functions only: no filesystem, no process state.\n */\n\n/** Primitive → the Genesis components that replace it (the doctor names the ones the installed package exports). */\nexport const NATIVE_WRAPPED_PRIMITIVES = Object.freeze({\n Modal: Object.freeze(['NativeDialog', 'NativeSheet', 'NativeDrawer']),\n ActivityIndicator: Object.freeze(['NativeSkeleton', 'NativeProgress']),\n});\n\n/**\n * The wrapped primitives named in one import (or export-from) clause's `{ ... }` list,\n * aliases resolved to the imported name. Type-only entries (`type Modal`) are skipped:\n * they never render anything.\n */\nexport function wrappedPrimitivesIn(namedImports) {\n return namedImports\n .split(',')\n .map((n) => n.trim())\n .filter((n) => n && !/^type\\s/.test(n))\n .map((n) => n.split(/\\s+as\\s+/)[0].trim())\n .filter((n) => n && Object.hasOwn(NATIVE_WRAPPED_PRIMITIVES, n));\n}\n","/**\n * `withGenesis()` — the Genesis Expo config plugin.\n *\n * Keeps an app's `app.config.ts` to a name, ids and plugins. It sets:\n *\n * 1. App variants: `APP_VARIANT` (`development` | `preview` | `production`,\n * default `production`) suffixes the bundle id, Android package, name and\n * URL scheme, so the three builds install side by side and a\n * `scheme://` link opens the build it names, not whichever one iOS or\n * Android picks among apps that registered the same scheme.\n * 2. Universal / app links from genesis.config.json `links`:\n * `ios.associatedDomains` (`applinks:` and `webcredentials:`) and one\n * Android `intentFilters` entry with `autoVerify`.\n * 3. The iOS privacy manifest, merged into what the app declares: the\n * required-reason APIs of React Native, Expo and the packages the app's\n * package.json lists; `NSPrivacyTracking: false`; and the collected data\n * types, the union of what each Genesis block the app uses collects\n * (`account`, `observability`, `push`), or the app's own list from\n * genesis.config.json `privacy` or the plugin's `privacy` option.\n * 4. Export compliance: `ios.config.usesNonExemptEncryption = false`.\n * 5. `runtimeVersion: { policy: \"fingerprint\" }`.\n *\n * Anything the app already sets wins: the plugin fills gaps and appends to\n * lists, never overwrites or removes a value, and running it twice changes\n * nothing.\n *\n * Determinism: the plugin reads two committed files in the project root,\n * genesis.config.json and package.json, and one environment variable,\n * APP_VARIANT. No network, no clock, no other environment. The same commit\n * and variant always give the same config; the EAS fingerprint is stable only\n * if APP_VARIANT is set the same way for builds, `eas update` and fingerprint\n * checks (an EAS environment variable, not a build profile's `env`).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ConfigPlugin } from \"@expo/config-plugins\";\nimport type { ExpoConfig } from \"@expo/config-types\";\nimport {\n GenesisConfigError,\n PRIVACY_PURPOSES,\n privacyDataType,\n readGenesisConfig,\n validatePrivacy,\n type GenesisDataUse,\n type GenesisLinks,\n type GenesisPrivacy,\n} from \"./doctor/config.js\";\n\nexport {\n GenesisConfigError,\n PRIVACY_DATA_TYPES,\n PRIVACY_PURPOSES,\n privacyDataType,\n validateLinks,\n validatePrivacy,\n readGenesisConfig,\n type GenesisDataUse,\n type GenesisLinks,\n type GenesisPrivacy,\n} from \"./doctor/config.js\";\n\nexport const APP_VARIANTS = [\"development\", \"preview\", \"production\"] as const;\nexport type AppVariant = (typeof APP_VARIANTS)[number];\n\nexport interface VariantSuffix {\n /** Appended to `ios.bundleIdentifier` and `android.package`, e.g. `.dev`. */\n id: string;\n /** Appended to `name`, e.g. ` (Dev)`. */\n name: string;\n /** Appended to each `scheme`, e.g. `-dev` (`myapp-dev://`). */\n scheme: string;\n}\n\n/** A required-reason API category and the reasons for it, as in PrivacyInfo.xcprivacy. */\nexport interface PrivacyApi {\n NSPrivacyAccessedAPIType: string;\n NSPrivacyAccessedAPITypeReasons: string[];\n}\n\nexport interface WithGenesisOptions {\n /**\n * The variant, overriding `APP_VARIANT`. Tests and scripts pass it; an app\n * leaves it out and sets `APP_VARIANT` per build profile in eas.json.\n */\n variant?: AppVariant;\n /** Suffixes per non-production variant. Default `.dev` / ` (Dev)` / `-dev` and `.preview` / ` (Preview)` / `-preview`. */\n variants?: Partial<Record<Exclude<AppVariant, \"production\">, Partial<VariantSuffix>>>;\n /** Where genesis.config.json and package.json live. Default: the Expo project root. */\n projectRoot?: string;\n /**\n * The manifest's collected data types, overriding genesis.config.json\n * `privacy` key by key (`blocks` here replaces the file's `blocks`; a\n * `collects` list, from either place, replaces every block's list). An app\n * passes `blocks` from its own feature switches, so a block turned off\n * declares nothing. Without `privacy` in either place, the blocks are found\n * from package.json and a warning says the app's own data isn't in the list.\n */\n privacy?: GenesisPrivacy;\n /** Turn single steps off. Every step is on by default. */\n links?: boolean;\n privacyManifest?: boolean;\n exportCompliance?: boolean;\n fingerprint?: boolean;\n}\n\nexport const DEFAULT_VARIANT_SUFFIXES: Record<Exclude<AppVariant, \"production\">, VariantSuffix> = {\n development: { id: \".dev\", name: \" (Dev)\", scheme: \"-dev\" },\n preview: { id: \".preview\", name: \" (Preview)\", scheme: \"-preview\" },\n};\n\nconst api = (category: string, ...reasons: string[]): PrivacyApi => ({\n NSPrivacyAccessedAPIType: `NSPrivacyAccessedAPICategory${category}`,\n NSPrivacyAccessedAPITypeReasons: reasons,\n});\n\n/**\n * The required-reason APIs each package needs the app to declare, copied from\n * the package's own PrivacyInfo.xcprivacy (read from the SDK 58 versions the\n * starter installs). A package is matched when the app's package.json lists\n * it in `dependencies`. CocoaPods also merges these manifests into the app's\n * at `pod install` (React Native's privacy manifest aggregation); declaring\n * them here keeps the app's manifest whole when that is off, or for a pod\n * that doesn't ship one.\n *\n * - react-native 0.88 (`React/Resources`, `ReactCommon/cxxreact`,\n * `ReactCommon/react/timing` and the boost, glog and RCT-Folly podspecs):\n * FileTimestamp C617.1, UserDefaults CA92.1, SystemBootTime 35F9.1.\n * - expo 58, for what it always installs: expo-file-system (FileTimestamp\n * 0A2A.1 and 3B52.1, DiskSpace E174.1 and 85F4.1) and expo-constants\n * (UserDefaults CA92.1).\n * - expo-updates, through expo-eas-client: UserDefaults CA92.1.\n * - expo-application: FileTimestamp C617.1.\n * - expo-notifications: UserDefaults CA92.1.\n * - async-storage 2.2.0: FileTimestamp C617.1.\n *\n * - @sentry/react-native: UserDefaults CA92.1, SystemBootTime 35F9.1,\n * FileTimestamp C617.1, as Sentry's \"Apple Privacy Manifest\" guide for\n * React Native lists (sentry-cocoa ships in a pod, not in node_modules).\n *\n * Not listed, because their packages ship no required-reason API: expo-secure-store\n * (the Keychain is not one), expo-crypto, expo-haptics, expo-linking,\n * expo-apple-authentication, expo-router, netinfo, reanimated and the other\n * starter dependencies with no PrivacyInfo.xcprivacy.\n */\nexport const PRIVACY_APIS: Record<string, PrivacyApi[]> = {\n \"react-native\": [api(\"FileTimestamp\", \"C617.1\"), api(\"UserDefaults\", \"CA92.1\"), api(\"SystemBootTime\", \"35F9.1\")],\n expo: [api(\"FileTimestamp\", \"0A2A.1\", \"3B52.1\"), api(\"DiskSpace\", \"E174.1\", \"85F4.1\"), api(\"UserDefaults\", \"CA92.1\")],\n \"expo-updates\": [api(\"UserDefaults\", \"CA92.1\")],\n \"expo-application\": [api(\"FileTimestamp\", \"C617.1\")],\n \"expo-notifications\": [api(\"UserDefaults\", \"CA92.1\")],\n \"@react-native-async-storage/async-storage\": [api(\"FileTimestamp\", \"C617.1\")],\n \"@sentry/react-native\": [api(\"UserDefaults\", \"CA92.1\"), api(\"SystemBootTime\", \"35F9.1\"), api(\"FileTimestamp\", \"C617.1\")],\n};\n\n/** A Genesis block's collected data, and the packages that mean the app uses it. */\nexport interface PrivacyBlock {\n /** The block is on when the app's `dependencies` list every one of these. */\n packages: string[];\n collects: GenesisDataUse[];\n}\n\nconst appFunctionality = (type: string, ...more: string[]): GenesisDataUse => ({\n type,\n purposes: [\"app functionality\", ...more],\n linked: true,\n tracking: false,\n});\n\n/**\n * What each Genesis block collects, mirroring its `defineBlock`\n * `privacy.collects` (the blocks themselves are React Native code, which a\n * config plugin can't load). \"Collected\" is Apple's sense: sent off the\n * phone, to the app's own backend or a vendor. Purposes follow Apple's\n * definitions: crash and performance data that keep the app working are app\n * functionality (\"minimize app crashes, improve scalability and\n * performance\"); analytics is the typed product events.\n *\n * - `account` (`@marktiderman/genesis-supabase` `accountBlock`): the\n * sign-in email, the account id, and the name (Sign in with Apple's, or\n * one typed in).\n * - `observability` (`@marktiderman/genesis-native` `createObservability`\n * with `events`, reporting through Sentry): crash and performance data,\n * and the other diagnostic data Sentry sends with them (device and OS\n * details, breadcrumbs, sessions), the three Sentry's own privacy-manifest\n * guide lists; the user id; and the typed analytics events (product\n * interaction), all linked because the sink sets the user id. Found by\n * `@sentry/react-native`; an app that never sets a DSN sends nothing and\n * should leave this block out.\n * - `push` (`@marktiderman/genesis-native` `createPush`): the device's push\n * token against the person (a device-level id).\n * - `support` (`@marktiderman/genesis-support` `supportContributions`):\n * feedback and support requests the person sends, with their text, an\n * optional screenshot, the account id and basic device facts.\n *\n * Tests keep each entry equal to its block's own list.\n */\nexport const PRIVACY_BLOCKS: Record<string, PrivacyBlock> = {\n account: {\n packages: [\"@marktiderman/genesis-supabase\"],\n collects: [appFunctionality(\"email address\"), appFunctionality(\"user id\"), appFunctionality(\"name\")],\n },\n observability: {\n packages: [\"@marktiderman/genesis-native\", \"@sentry/react-native\"],\n collects: [\n appFunctionality(\"crash data\"),\n appFunctionality(\"performance data\"),\n appFunctionality(\"other diagnostic data\"),\n appFunctionality(\"user id\", \"analytics\"),\n { type: \"product interaction\", purposes: [\"analytics\"], linked: true, tracking: false },\n ],\n },\n push: {\n packages: [\"@marktiderman/genesis-native\", \"expo-notifications\"],\n collects: [appFunctionality(\"device ID\")],\n },\n support: {\n packages: [\"@marktiderman/genesis-support\"],\n collects: [\n appFunctionality(\"user id\"),\n appFunctionality(\"customer support\"),\n appFunctionality(\"other user content\"),\n appFunctionality(\"photos or videos\"),\n appFunctionality(\"other diagnostic data\"),\n ],\n },\n};\n\n/** The variant from options, else `APP_VARIANT`, else production. An unknown value throws. */\nexport function resolveVariant(given?: string): AppVariant {\n const value = given ?? process.env.APP_VARIANT ?? \"production\";\n if (!(APP_VARIANTS as readonly string[]).includes(value)) {\n throw new GenesisConfigError(`APP_VARIANT is \"${value}\"; expected one of ${APP_VARIANTS.join(\", \")}`);\n }\n return value as AppVariant;\n}\n\nexport function applyVariant(config: ExpoConfig, variant: AppVariant, options: WithGenesisOptions[\"variants\"] = {}): ExpoConfig {\n if (variant === \"production\") return config;\n const suffix = { ...DEFAULT_VARIANT_SUFFIXES[variant], ...options[variant] };\n // A value that already ends in the suffix was suffixed by an earlier run: leave it.\n const add = (value: string, end: string) => (end && value.endsWith(end) ? value : value + end);\n const next: ExpoConfig = { ...config, name: add(config.name, suffix.name) };\n if (config.ios?.bundleIdentifier) next.ios = { ...config.ios, bundleIdentifier: add(config.ios.bundleIdentifier, suffix.id) };\n if (config.android?.package) next.android = { ...config.android, package: add(config.android.package, suffix.id) };\n // Every build registering the same scheme would let a link open the wrong one. Production keeps the base.\n if (typeof config.scheme === \"string\") next.scheme = add(config.scheme, suffix.scheme);\n else if (Array.isArray(config.scheme)) next.scheme = config.scheme.map((scheme) => add(scheme, suffix.scheme));\n return next;\n}\n\nexport function applyLinks(config: ExpoConfig, links: GenesisLinks | undefined): ExpoConfig {\n if (!links) return config;\n const services = links.webcredentials === false ? [\"applinks\"] : [\"applinks\", \"webcredentials\"];\n const domains = links.hosts.flatMap((host) => services.map((service) => `${service}:${host}`));\n const associatedDomains = union(config.ios?.associatedDomains ?? [], domains);\n\n const data = links.hosts.flatMap((host) =>\n links.paths?.length ? links.paths.map((pathPrefix) => ({ scheme: \"https\", host, pathPrefix })) : [{ scheme: \"https\", host }],\n );\n const filter = { action: \"VIEW\", autoVerify: true, data, category: [\"BROWSABLE\", \"DEFAULT\"] };\n const existing = config.android?.intentFilters ?? [];\n const intentFilters = existing.some((f) => JSON.stringify(f) === JSON.stringify(filter)) ? existing : [...existing, filter];\n\n return {\n ...config,\n ios: { ...config.ios, associatedDomains },\n android: { ...config.android, intentFilters },\n };\n}\n\n/** The required-reason APIs for the packages listed in package.json `dependencies`. */\nexport function privacyApisFor(dependencies: Record<string, unknown>): PrivacyApi[] {\n return Object.keys(PRIVACY_APIS)\n .filter((pkg) => pkg in dependencies)\n .flatMap((pkg) => PRIVACY_APIS[pkg]!);\n}\n\n/** Merge required-reason APIs into `ios.privacyManifests`, keeping every entry and reason the app declares. */\nexport function applyPrivacyApis(config: ExpoConfig, apis: PrivacyApi[]): ExpoConfig {\n if (apis.length === 0) return config;\n const manifests = config.ios?.privacyManifests ?? {};\n const types = (manifests.NSPrivacyAccessedAPITypes ?? []).map((t) => ({ ...t, NSPrivacyAccessedAPITypeReasons: [...t.NSPrivacyAccessedAPITypeReasons] }));\n for (const api of apis) {\n const found = types.find((t) => t.NSPrivacyAccessedAPIType === api.NSPrivacyAccessedAPIType);\n if (found) found.NSPrivacyAccessedAPITypeReasons = union(found.NSPrivacyAccessedAPITypeReasons, api.NSPrivacyAccessedAPITypeReasons);\n else types.push({ ...api, NSPrivacyAccessedAPITypeReasons: [...api.NSPrivacyAccessedAPITypeReasons] });\n }\n return { ...config, ios: { ...config.ios, privacyManifests: { ...manifests, NSPrivacyAccessedAPITypes: types } } };\n}\n\n/** The Genesis blocks whose packages are all in `dependencies`. */\nexport function privacyBlocksFor(dependencies: Record<string, unknown>): string[] {\n return Object.keys(PRIVACY_BLOCKS).filter((id) => PRIVACY_BLOCKS[id]!.packages.every((pkg) => pkg in dependencies));\n}\n\n/**\n * The data the app collects: `privacy.collects` when given, else the union of\n * the blocks' (`privacy.blocks`, else those found in `dependencies`). A type\n * two blocks collect appears once, with every purpose either gives, linked or\n * tracking if either says so. An unknown block id throws.\n */\nexport function collectedDataFor(privacy: GenesisPrivacy, dependencies: Record<string, unknown>): GenesisDataUse[] {\n if (privacy.collects) return mergeDataUses(privacy.collects);\n const blocks = privacy.blocks ?? privacyBlocksFor(dependencies);\n const unknown = blocks.filter((id) => !(id in PRIVACY_BLOCKS));\n if (unknown.length) {\n throw new GenesisConfigError(`privacy.blocks: ${unknown.map((id) => `\"${id}\"`).join(\", \")} not one of ${Object.keys(PRIVACY_BLOCKS).join(\", \")}; list other data in privacy.collects`);\n }\n return mergeDataUses(blocks.flatMap((id) => PRIVACY_BLOCKS[id]!.collects));\n}\n\nfunction mergeDataUses(uses: readonly GenesisDataUse[]): GenesisDataUse[] {\n const byType = new Map<string, GenesisDataUse>();\n for (const use of uses) {\n // By Apple's type, so \"user ID\" and \"user id\" are one entry.\n const key = privacyDataType(use.type) ?? use.type;\n const seen = byType.get(key);\n byType.set(\n key,\n seen\n ? { type: use.type, purposes: union(seen.purposes, use.purposes), linked: seen.linked || use.linked, tracking: seen.tracking || use.tracking }\n : { ...use, purposes: [...use.purposes] },\n );\n }\n return [...byType.values()];\n}\n\n/**\n * Write the collected data types and `NSPrivacyTracking` into\n * `ios.privacyManifests`. The app's own entries win: a type it already lists\n * is left as it wrote it, and an `NSPrivacyTracking` it set stays. Tracking\n * defaults to whether any entry tracks; an entry that tracks with tracking\n * set false throws, since the manifest would contradict itself.\n */\nexport function applyPrivacyData(config: ExpoConfig, uses: GenesisDataUse[], tracking?: boolean): ExpoConfig {\n const manifests = config.ios?.privacyManifests ?? {};\n if (tracking !== undefined && manifests.NSPrivacyTracking !== undefined && tracking !== manifests.NSPrivacyTracking) {\n throw new GenesisConfigError(`privacy.tracking is ${tracking} but app.config sets ios.privacyManifests.NSPrivacyTracking to ${manifests.NSPrivacyTracking}; set it in one place`);\n }\n const tracks = uses.some((u) => u.tracking);\n const NSPrivacyTracking = manifests.NSPrivacyTracking ?? tracking ?? tracks;\n if (tracks && NSPrivacyTracking === false) {\n const which = uses.filter((u) => u.tracking).map((u) => u.type);\n throw new GenesisConfigError(`privacy: ${which.join(\", \")} is used for tracking but NSPrivacyTracking is false; set privacy.tracking to true and list NSPrivacyTrackingDomains`);\n }\n const existing = (manifests.NSPrivacyCollectedDataTypes ?? []).map((t) => ({ ...t, NSPrivacyCollectedDataTypePurposes: [...t.NSPrivacyCollectedDataTypePurposes] }));\n const listed = new Set(existing.map((t) => t.NSPrivacyCollectedDataType));\n const added = uses\n .map((u) => ({\n NSPrivacyCollectedDataType: privacyDataType(u.type)!,\n NSPrivacyCollectedDataTypeLinked: u.linked,\n NSPrivacyCollectedDataTypeTracking: u.tracking,\n NSPrivacyCollectedDataTypePurposes: u.purposes.map((p) => PRIVACY_PURPOSES[p]!),\n }))\n .filter((t) => !listed.has(t.NSPrivacyCollectedDataType));\n return {\n ...config,\n ios: { ...config.ios, privacyManifests: { ...manifests, NSPrivacyTracking, NSPrivacyCollectedDataTypes: [...existing, ...added] } },\n };\n}\n\nexport function applyExportCompliance(config: ExpoConfig): ExpoConfig {\n if (config.ios?.config?.usesNonExemptEncryption !== undefined) return config;\n return { ...config, ios: { ...config.ios, config: { ...config.ios?.config, usesNonExemptEncryption: false } } };\n}\n\nexport function applyFingerprint(config: ExpoConfig): ExpoConfig {\n if (config.runtimeVersion !== undefined || config.ios?.runtimeVersion !== undefined || config.android?.runtimeVersion !== undefined) {\n return config;\n }\n return { ...config, runtimeVersion: { policy: \"fingerprint\" } };\n}\n\n/** The Genesis config plugin. Use it in `plugins` or call it directly in app.config.ts. */\nexport const withGenesis: ConfigPlugin<WithGenesisOptions | void> = (config, props) => {\n const options = props ?? {};\n const root = options.projectRoot ?? (config as { _internal?: { projectRoot?: string } })._internal?.projectRoot ?? process.cwd();\n let next = applyVariant(config, resolveVariant(options.variant), options.variants);\n const file = options.links !== false || options.privacyManifest !== false ? readGenesisConfig(root) : null;\n if (options.links !== false) next = applyLinks(next, file?.links);\n if (options.privacyManifest !== false) {\n const dependencies = readDependencies(root);\n const privacy = { ...file?.privacy, ...(options.privacy ? validatePrivacy(options.privacy, \"withGenesis({ privacy })\") : {}) };\n next = applyPrivacyApis(next, privacyApisFor(dependencies));\n if (!privacy.blocks && !privacy.collects && !config.ios?.privacyManifests?.NSPrivacyCollectedDataTypes) {\n // Not a throw: the default is right for an app that is only Genesis blocks. Loud, because\n // anything else the app sends is missing from it.\n console.warn(\n `[genesis] privacy manifest: collected data types are only those of the Genesis blocks found in package.json (${privacyBlocksFor(dependencies).join(\", \") || \"none\"}). If the app sends anything else, list everything it collects in genesis.config.json privacy.collects; to keep this list, set privacy.blocks.`,\n );\n }\n next = applyPrivacyData(next, collectedDataFor(privacy, dependencies), privacy.tracking);\n }\n if (options.exportCompliance !== false) next = applyExportCompliance(next);\n if (options.fingerprint !== false) next = applyFingerprint(next);\n return next;\n};\n\nexport default withGenesis;\n\nfunction readDependencies(root: string): Record<string, unknown> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return {};\n try {\n const deps = JSON.parse(readFileSync(file, \"utf8\"))?.dependencies;\n return deps && typeof deps === \"object\" ? deps : {};\n } catch (err) {\n throw new GenesisConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\nfunction union(a: string[], b: string[]): string[] {\n return [...new Set([...a, ...b])];\n}\n","/**\n * The `native` pack: rules for Expo / React Native apps on\n * `@marktiderman/genesis-ui-native`. Turned on with `doctor.packs: [\"native\"]`.\n *\n * The screen layouts and replacements are read from the installed native\n * package's declarations, like the core rules read the web package; the\n * wrapped-primitive list is shared with the repo's check-forbidden-imports\n * gate. Literal colors in native code are reported by rules.ts checkColors\n * as `native-literal-color`.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { NATIVE_WRAPPED_PRIMITIVES, wrappedPrimitivesIn } from \"../../../../scripts/lib/native-primitives.mjs\";\nimport { privacyApisFor } from \"../expo.js\";\nimport { DoctorConfigError } from \"./config.js\";\nimport { NATIVE_UI_PACKAGE, readPackageExports, type PackageExports } from \"./genesis.js\";\nimport { lineAt } from \"./scan.js\";\nimport type { DoctorContext, SourceFile } from \"./types.js\";\n\nconst SCRIPT_EXTS = new Set([\".ts\", \".tsx\", \".js\", \".jsx\", \".mts\", \".cts\", \".mjs\", \".cjs\"]);\nconst JSX_EXTS = new Set([\".tsx\", \".jsx\"]);\nconst RESOLVE_EXTS = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n\n/** A Genesis screen layout: an exported component named `…Page`, `…Screen` or `ScreenContainer`. */\nconst LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$/;\n/** Route files Expo Router treats as non-screens. */\nconst NON_SCREEN_ROUTE = /(?:^|\\/)(?:_layout|\\+html|\\+native-intent|\\+middleware)\\.[jt]sx?$|\\+api\\.[jt]sx?$/;\n/** Header-named components that head a section of a screen, not the screen. */\nconst PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;\nconst HIDES_HEADER = /\\bheaderShown\\s*(?::|=\\s*\\{)\\s*false\\b/;\n\n/** The installed native package (also when `uiPackage` points the core rules at the web one). */\nfunction nativePackage(ctx: DoctorContext): PackageExports {\n const pkg = readPackageExports(ctx.root, NATIVE_UI_PACKAGE);\n if (!pkg) throw new DoctorConfigError(`the native pack needs ${NATIVE_UI_PACKAGE}; install it, or remove \"native\" from doctor.packs`);\n return pkg;\n}\n\n/** Genesis screen layouts the installed native package exports, sorted. */\nexport function nativeLayouts(pkg: Pick<PackageExports, \"components\">): string[] {\n return pkg.components.filter((n) => LAYOUT_NAME.test(n));\n}\n\nexport function checkNativePack(ctx: DoctorContext): void {\n const pkg = nativePackage(ctx);\n checkRawPrimitives(ctx, pkg);\n checkCustomHeaders(ctx, pkg);\n checkScreenLayouts(ctx, pkg);\n checkStoreReadiness(ctx);\n}\n\nconst RN = String.raw`[\"']react-native[\"']`;\n\n/** `native-raw-primitive`: a React Native primitive Genesis wraps, taken from react-native at runtime. */\nfunction checkRawPrimitives(ctx: DoctorContext, pkg: PackageExports): void {\n const wrapped = Object.keys(NATIVE_WRAPPED_PRIMITIVES);\n const named = [\n // import { Modal } / import RN, { Modal }; `import type { … }` doesn't match.\n new RegExp(String.raw`\\bimport\\s+(?:[\\w$]+\\s*,\\s*)?\\{([^}]*)\\}\\s*from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\bexport\\s+\\{([^}]*)\\}\\s*from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\b(?:const|let|var)\\s*\\{([^}]*)\\}\\s*=\\s*require\\(\\s*${RN}\\s*\\)`, \"g\"),\n ];\n const namespaces = [\n new RegExp(String.raw`\\bimport\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s*${RN}`, \"g\"),\n new RegExp(String.raw`\\b(?:const|let|var)\\s+([\\w$]+)\\s*=\\s*require\\(\\s*${RN}\\s*\\)`, \"g\"),\n ];\n const member = new RegExp(String.raw`\\brequire\\(\\s*${RN}\\s*\\)\\.(${wrapped.join(\"|\")})\\b`, \"g\");\n for (const file of ctx.files) {\n if (!SCRIPT_EXTS.has(file.ext)) continue;\n const code = file.code;\n const report = (name: string, at: number) => {\n const use = NATIVE_WRAPPED_PRIMITIVES[name].filter((c) => pkg.values.has(c));\n ctx.report({\n rule: \"native-raw-primitive\",\n file: file.path,\n line: lineAt(code, at),\n subject: name,\n message: `uses ${name} from react-native, which Genesis wraps; use ${use.length ? use.join(\" or \") : \"the Genesis wrapper\"} from ${NATIVE_UI_PACKAGE}`,\n });\n };\n for (const re of named) {\n for (const m of code.matchAll(re)) {\n for (const name of wrappedPrimitivesIn(m[1].replace(/:/g, \" as \"))) report(name, m.index! + m[0].indexOf(name));\n }\n }\n for (const re of namespaces) {\n for (const m of code.matchAll(re)) {\n for (const use of code.matchAll(new RegExp(String.raw`\\b${m[1].replace(/\\$/g, \"\\\\$\")}\\.(${wrapped.join(\"|\")})\\b`, \"g\"))) report(use[1], use.index!);\n }\n }\n for (const m of code.matchAll(member)) report(m[1], m.index!);\n }\n}\n\n/** A JSX element matching `re` that Genesis doesn't export and that isn't a section header: the app's own header or bar. */\nfunction customElement(code: string, re: RegExp, pkg: PackageExports): { name: string; index: number } | null {\n for (const m of code.matchAll(re)) {\n const name = m[1];\n if (!pkg.values.has(name.split(\".\")[0]) && !PART_HEADER.test(name)) return { name, index: m.index! };\n }\n return null;\n}\n\n/** The screen's own header: a `<…Header>` of the app's own, or `style={styles.header}`. */\nfunction ownHeader(code: string, pkg: PackageExports): { name: string; index: number } | null {\n const el = customElement(code, /<([A-Z][\\w$]*Header)\\b/g, pkg);\n if (el) return el;\n const style = /\\bstyle=\\{\\s*styles\\.header\\s*\\}/.exec(code);\n return style ? { name: \"styles.header\", index: style.index } : null;\n}\n\n/** `native-custom-header`: the navigator header turned off and a hand-drawn one rendered, or a hand-built tab bar. */\nfunction checkCustomHeaders(ctx: DoctorContext, pkg: PackageExports): void {\n const layouts = nativeLayouts(pkg);\n if (layouts.length === 0) return;\n const headerWay = pkg.values.has(\"ScreenContainer\")\n ? `ScreenContainer's header props${pkg.values.has(\"composeHeaderOptions\") ? \" (composeHeaderOptions)\" : \"\"}`\n : `a Genesis layout's header (${layouts.join(\", \")})`;\n const rootDir = routerRoot(ctx);\n const reported = new Set<string>();\n /** Folders whose _layout hides the header for the screens beside it. */\n const hidingLayouts = new Map<string, string>();\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext)) continue;\n const code = file.code;\n const hidden = HIDES_HEADER.exec(code);\n if (hidden && /(?:^|\\/)_layout\\.[jt]sx$/.test(file.path)) hidingLayouts.set(path.posix.dirname(file.path), file.path);\n const own = hidden ? ownHeader(code, pkg) : null;\n if (hidden && own) {\n reported.add(file.path);\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(code, hidden.index),\n subject: own.name,\n message: `hides the navigator header and draws its own (${own.name}); use ${headerWay} so the title, back button and large-title behavior stay native`,\n });\n }\n const tabBarProp = /<Tabs\\b/.test(code) ? /\\btabBar\\s*=\\s*\\{/.exec(code) : null;\n const tabBar = tabBarProp ? { name: \"tabBar prop\", index: tabBarProp.index } : customElement(code, /<([A-Z][\\w$]*TabBar)\\b/g, pkg);\n if (tabBar) {\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(code, tabBar.index),\n subject: tabBar.name,\n message: `builds a tab bar by hand (${tabBar.name}); use the router's native <Tabs> bar, themed through Genesis screenOptions`,\n });\n }\n }\n // A layout that hides the header for its stack, and a screen in it that draws one.\n for (const file of ctx.files) {\n if (!JSX_EXTS.has(file.ext) || reported.has(file.path) || !file.path.startsWith(`${rootDir}/`) || NON_SCREEN_ROUTE.test(file.path)) continue;\n const layout = hidingLayouts.get(path.posix.dirname(file.path));\n const own = layout ? ownHeader(file.code, pkg) : null;\n if (!layout || !own) continue;\n ctx.report({\n rule: \"native-custom-header\",\n level: \"warn\",\n file: file.path,\n line: lineAt(file.code, own.index),\n subject: own.name,\n message: `draws its own header (${own.name}) while ${layout} hides the navigator's; use ${headerWay} so the title, back button and large-title behavior stay native`,\n });\n }\n}\n\n/** The Expo Router root: `native.routerRoot`, else `src/app`, else `app`. */\nexport function routerRoot(ctx: Pick<DoctorContext, \"root\" | \"config\">): string {\n if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\\/+$/, \"\");\n return existsSync(path.join(ctx.root, \"src\", \"app\")) ? \"src/app\" : \"app\";\n}\n\n/** `native-screen-layout`: a route screen that doesn't render a Genesis screen layout (directly or through one local import). */\nfunction checkScreenLayouts(ctx: DoctorContext, pkg: PackageExports): void {\n const layouts = nativeLayouts(pkg);\n if (layouts.length === 0) return;\n const rootDir = routerRoot(ctx);\n if (!existsSync(path.join(ctx.root, rootDir))) {\n ctx.report({ rule: \"native-screen-layout\", level: \"warn\", file: rootDir, message: `no Expo Router root at ${rootDir}; set doctor.native.routerRoot` });\n return;\n }\n const routes = ctx.files.filter((f) => f.path.startsWith(`${rootDir}/`));\n if (routes.length === 0) {\n ctx.report({\n rule: \"native-screen-layout\",\n level: \"warn\",\n file: rootDir,\n message: `no scanned file is under the router root ${rootDir}, so no screen was checked; add it to doctor.src`,\n });\n return;\n }\n const renders = new RegExp(`<(?:${layouts.join(\"|\")}|Redirect)\\\\b`);\n const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));\n for (const file of routes) {\n if (!JSX_EXTS.has(file.ext) || NON_SCREEN_ROUTE.test(file.path)) continue;\n // A route that only re-exports a screen, or renders no JSX, is judged where the screen lives.\n if (!/\\bexport\\s+default\\b/.test(file.code) || !/<[A-Za-z]/.test(file.code)) continue;\n if (renders.test(file.code)) continue;\n const viaImport = localImports(ctx.root, file).some((abs) => {\n const target = byPath.get(abs) ?? readSource(abs);\n return target !== null && renders.test(target.code);\n });\n if (viaImport) continue;\n ctx.report({\n rule: \"native-screen-layout\",\n level: \"warn\",\n file: file.path,\n message: `doesn't render a Genesis screen layout (${layouts.join(\", \")}); wrap the screen in one so the header, safe area and scrolling match every other screen`,\n });\n }\n}\n\n/** Files a source imports by relative path or the `@/` / `~/` root aliases, resolved to absolute paths that exist. */\nfunction localImports(root: string, file: SourceFile): string[] {\n const out: string[] = [];\n for (const m of file.code.matchAll(/\\bfrom\\s*[\"']((?:\\.{1,2}|[@~])\\/[^\"']+)[\"']/g)) {\n const spec = m[1];\n const bases = spec.startsWith(\".\")\n ? [path.resolve(path.dirname(file.absolutePath), spec)]\n : [path.join(root, spec.slice(2)), path.join(root, \"src\", spec.slice(2))];\n for (const base of bases) {\n const hit = [base, ...RESOLVE_EXTS.map((e) => base + e), ...RESOLVE_EXTS.map((e) => path.join(base, `index${e}`))].find(\n (p) => SCRIPT_EXTS.has(path.extname(p)) && existsSync(p),\n );\n if (hit) {\n out.push(hit);\n break;\n }\n }\n }\n return out;\n}\n\nfunction readSource(abs: string): Pick<SourceFile, \"code\"> | null {\n try {\n return { code: readFileSync(abs, \"utf8\") };\n } catch {\n return null;\n }\n}\n\n// ---- store-readiness ----\n\n/**\n * Modules that need an iOS usage string: the Info.plist key, and the config-plugin\n * option that sets it (`false` opts out). `maybe`: the module works without that\n * permission (playback only, picking from the library), so the string may not be needed.\n */\nconst PERMISSIONS: ReadonlyArray<{ module: string; key: string; option: string; maybe?: string }> = [\n { module: \"expo-camera\", key: \"NSCameraUsageDescription\", option: \"cameraPermission\" },\n { module: \"expo-image-picker\", key: \"NSPhotoLibraryUsageDescription\", option: \"photosPermission\" },\n { module: \"expo-image-picker\", key: \"NSCameraUsageDescription\", option: \"cameraPermission\", maybe: \"takes photos with the camera\" },\n { module: \"expo-media-library\", key: \"NSPhotoLibraryUsageDescription\", option: \"photosPermission\" },\n { module: \"expo-location\", key: \"NSLocationWhenInUseUsageDescription\", option: \"locationWhenInUsePermission\" },\n { module: \"expo-av\", key: \"NSMicrophoneUsageDescription\", option: \"microphonePermission\", maybe: \"records audio\" },\n { module: \"expo-audio\", key: \"NSMicrophoneUsageDescription\", option: \"microphonePermission\", maybe: \"records audio\" },\n { module: \"expo-contacts\", key: \"NSContactsUsageDescription\", option: \"contactsPermission\" },\n { module: \"expo-local-authentication\", key: \"NSFaceIDUsageDescription\", option: \"faceIDPermission\" },\n];\n/** Packages that are a third-party sign-in (App Store guideline 4.8). */\nconst SOCIAL_SIGN_IN = [\"@react-native-google-signin/google-signin\", \"react-native-fbsdk-next\"];\n/** Used for sign-in and for other OAuth flows alike: mentioned, never enough on its own. */\nconst WEAK_SOCIAL_SIGN_IN = [\"expo-auth-session\"];\nconst APPLE_SIGN_IN = [\"expo-apple-authentication\", \"@invertase/react-native-apple-authentication\"];\nconst EXPO_CONFIGS = [\"app.json\", \"app.config.json\", \"app.config.ts\", \"app.config.js\", \"app.config.mjs\", \"app.config.cjs\"];\nconst SUPABASE_SIGN_IN = /\\bsignInWith(?:OAuth|IdToken)\\s*\\(\\s*\\{\\s*provider\\s*:\\s*[\"']([\\w-]+)[\"']/g;\n/** This package's Expo config plugin, as `plugins` lists it. */\nconst GENESIS_PLUGIN = \"@marktiderman/genesis-cli\";\nconst GENESIS_PLUGIN_TEXT = /[\"']@marktiderman\\/genesis-cli(?:\\/expo)?[\"']|\\bwithGenesis\\s*\\(/;\n/** `from \"…genesis-cli…\"`, `require(\"…\")` and `import(\"…\")` of the package: naming it there isn't listing the plugin. */\nconst GENESIS_PLUGIN_IMPORT = /\\bfrom\\s*[\"']@marktiderman\\/genesis-cli[^\"']*[\"']|\\b(?:require|import)\\s*\\(\\s*[\"']@marktiderman\\/genesis-cli[^\"']*[\"']\\s*\\)/g;\n\n/** The app's Expo config as data (JSON files) plus text (dynamic configs, scanned best-effort). */\ninterface ExpoConfig {\n file: string;\n json: Record<string, unknown> | null;\n text: string;\n}\n\nfunction readExpoConfigs(root: string): ExpoConfig[] {\n const out: ExpoConfig[] = [];\n for (const name of EXPO_CONFIGS) {\n const abs = path.join(root, name);\n if (!existsSync(abs)) continue;\n const text = readFileSync(abs, \"utf8\");\n let json: Record<string, unknown> | null = null;\n if (name.endsWith(\".json\")) {\n try {\n const raw = JSON.parse(text) as Record<string, unknown>;\n json = (raw.expo as Record<string, unknown> | undefined) ?? raw;\n } catch (err) {\n throw new DoctorConfigError(`${name} is not valid JSON: ${(err as Error).message}`);\n }\n }\n out.push({ file: name, json, text });\n }\n return out;\n}\n\nfunction get(obj: unknown, keys: string[]): unknown {\n let cur = obj;\n for (const k of keys) {\n if (!cur || typeof cur !== \"object\") return undefined;\n cur = (cur as Record<string, unknown>)[k];\n }\n return cur;\n}\n\n/** A config plugin's entry in `plugins`: its options (`{}` when listed without any), or null when it isn't listed. */\nfunction pluginOptions(json: Record<string, unknown> | null, module: string): Record<string, unknown> | null {\n const plugins = json?.plugins;\n if (!Array.isArray(plugins)) return null;\n for (const p of plugins) {\n if (p === module) return {};\n if (Array.isArray(p) && p[0] === module) return p[1] && typeof p[1] === \"object\" ? (p[1] as Record<string, unknown>) : {};\n }\n return null;\n}\n\nfunction dependencies(root: string): Set<string> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return new Set();\n const pkg = JSON.parse(readFileSync(file, \"utf8\")) as Record<string, Record<string, string> | undefined>;\n return new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);\n}\n\n/** `dependencies` only, as the config plugin reads them (dev tools ship nothing). */\nfunction runtimeDependencies(root: string): Record<string, unknown> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return {};\n return (JSON.parse(readFileSync(file, \"utf8\")) as { dependencies?: Record<string, unknown> }).dependencies ?? {};\n}\n\n/** `store-readiness`: static App Store checks against app.json / app.config.*. */\nexport function checkStoreReadiness(ctx: DoctorContext): void {\n const configs = readExpoConfigs(ctx.root);\n if (configs.length === 0) {\n ctx.report({ rule: \"store-readiness\", level: \"warn\", file: \"app.json\", message: \"no app.json or app.config.* found; the store checks read the Expo config\" });\n return;\n }\n const file = configs[0].file;\n const deps = dependencies(ctx.root);\n /** A setting is present in any config: the JSON path is set, or a dynamic config's text names it. */\n const has = (keys: string[], word: string) =>\n configs.some((c) => (c.json ? get(c.json, keys) !== undefined : new RegExp(`\\\\b${word}\\\\b`).test(c.text)));\n /**\n * This package's own config plugin (`withGenesis()`) is listed and its `option` isn't `false`, so\n * it sets that step when the config is evaluated. A dynamic config is read as text: the plugin's\n * name or `withGenesis(`, and no `option: false`.\n */\n const genesisPluginDoes = (option: string) =>\n configs.some((c) => {\n if (c.json) {\n const options = pluginOptions(c.json, GENESIS_PLUGIN) ?? pluginOptions(c.json, `${GENESIS_PLUGIN}/expo`);\n return options !== null && options[option] !== false;\n }\n // An import of the package (`import { withGenesis } from \"@marktiderman/genesis-cli/expo\"`)\n // doesn't list the plugin; calling `withGenesis(` or naming it in `plugins` does.\n const listed = c.text.replace(GENESIS_PLUGIN_IMPORT, \"\");\n return GENESIS_PLUGIN_TEXT.test(listed) && !new RegExp(`\\\\b${option}\\\\s*:\\\\s*false\\\\b`).test(c.text);\n });\n\n const exportCompliance =\n has([\"ios\", \"config\", \"usesNonExemptEncryption\"], \"usesNonExemptEncryption\") ||\n has([\"ios\", \"infoPlist\", \"ITSAppUsesNonExemptEncryption\"], \"ITSAppUsesNonExemptEncryption\") ||\n genesisPluginDoes(\"exportCompliance\");\n if (!exportCompliance) {\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: \"usesNonExemptEncryption\",\n message: \"sets neither ios.config.usesNonExemptEncryption nor ios.infoPlist.ITSAppUsesNonExemptEncryption; set it (false for HTTPS-only apps) so App Store Connect doesn't hold every build for the export-compliance question\",\n });\n }\n\n // Sign in with Apple, or an equivalent privacy-focused login, beside third-party sign-in (guideline 4.8).\n const social = SOCIAL_SIGN_IN.filter((d) => deps.has(d));\n let apple = APPLE_SIGN_IN.some((d) => deps.has(d));\n for (const f of ctx.files) {\n for (const m of f.code.matchAll(SUPABASE_SIGN_IN)) {\n if (m[1] === \"apple\") apple = true;\n else if (!social.includes(`Supabase ${m[1]} sign-in`)) social.push(`Supabase ${m[1]} sign-in`);\n }\n }\n if (social.length > 0 && !apple) {\n const weak = WEAK_SOCIAL_SIGN_IN.filter((d) => deps.has(d));\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file: \"package.json\",\n subject: \"sign-in-with-apple\",\n message:\n `offers third-party sign-in (${[...social, ...weak].join(\", \")}) and no Sign in with Apple. App Store guideline 4.8 asks for an equivalent login ` +\n \"that limits data collection to name and email, lets people keep their email private and doesn't track them; Sign in with Apple \" +\n \"(expo-apple-authentication, or Supabase's apple provider) is the usual one. If another option qualifies, allow this with the reason.\",\n });\n }\n\n const generic = new Map<string, string[]>();\n for (const p of PERMISSIONS) {\n if (!deps.has(p.module)) continue;\n const set = configs.some((c) => {\n if (!c.json) return new RegExp(`\\\\b(?:${p.key}|${p.option})\\\\b`).test(c.text);\n const plist = get(c.json, [\"ios\", \"infoPlist\", p.key]);\n const option = pluginOptions(c.json, p.module)?.[p.option];\n // A sentence, or `false`: Expo's documented opt-out for a permission the app doesn't use.\n return (typeof plist === \"string\" && plist.trim() !== \"\") || (typeof option === \"string\" && option.trim() !== \"\") || option === false;\n });\n if (!set) generic.set(p.key, [...(generic.get(p.key) ?? []), `${p.module}${p.maybe ? `, if the app ${p.maybe}` : \"\"}`]);\n }\n for (const [key, modules] of generic) {\n const opt = PERMISSIONS.find((p) => p.key === key)!.option;\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: key,\n message: `leaves ${key} to Expo's generic default string (${modules.join(\"; \")}), and App Review rejects generic purpose strings; set the plugin's ${opt} (or ios.infoPlist.${key}) to a sentence saying why the app needs it, or ${opt}: false if it doesn't`,\n });\n }\n\n // The plugin writes a manifest only for packages it knows need one (`privacyApisFor`).\n const pluginManifest = genesisPluginDoes(\"privacyManifest\") && privacyApisFor(runtimeDependencies(ctx.root)).length > 0;\n if (!has([\"ios\", \"privacyManifests\"], \"privacyManifests\") && !pluginManifest) {\n ctx.report({\n rule: \"store-readiness\",\n level: \"warn\",\n file,\n subject: \"privacyManifests\",\n message: \"has no ios.privacyManifests; declare the required-reason APIs the app uses (NSPrivacyAccessedAPITypes) so uploads aren't rejected for a missing privacy manifest\",\n });\n }\n}\n","/**\n * The `supabase` pack: rules for `supabase/migrations`. Turned on with\n * `doctor.packs: [\"supabase\"]`.\n *\n * - migration-grants: blanket function grants and grants of unexposed\n * functions or schemas to anon/public, in new or changed migrations.\n * - migration-rls: a table in an exposed schema whose row level security is off\n * after every migration has run.\n * - migration-definer-search-path: a security definer function without a pinned search_path.\n * - migration-edited: a migration that already exists on the base ref was changed.\n *\n * The SQL is read statement by statement with comments removed and string and\n * dollar-quoted bodies blanked, so text inside a function body never matches\n * (dollar-quoted bodies are kept aside for the one rule that looks inside them).\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { DoctorConfigError } from \"./config.js\";\nimport type { DoctorContext, Level } from \"./types.js\";\n\nexport const DEFAULT_MIGRATIONS = \"supabase/migrations\";\nexport const DEFAULT_BASE = \"origin/main\";\nconst DEFAULT_EXPOSED = [\"public\"];\n\nexport interface SqlStatement {\n /** The statement, lowercased, comments removed, literals blanked, whitespace collapsed. */\n sql: string;\n /** 1-based line where it starts. */\n line: number;\n /** The lowercased text of each dollar-quoted body in the statement (`do $$ … $$`, function bodies). */\n bodies: string[];\n}\n\n/** Split SQL into statements, dropping comments and blanking quoted literals and dollar-quoted bodies. */\nexport function sqlStatements(text: string): SqlStatement[] {\n const out: SqlStatement[] = [];\n let buf = \"\";\n let bodies: string[] = [];\n let line = 1;\n let start = 0;\n const flush = () => {\n const sql = buf.replace(/\\s+/g, \" \").trim().toLowerCase();\n if (sql) out.push({ sql, line: start, bodies });\n buf = \"\";\n bodies = [];\n start = 0;\n };\n const put = (s: string) => {\n if (!start && /\\S/.test(s)) start = line;\n buf += s;\n };\n let i = 0;\n while (i < text.length) {\n const ch = text[i];\n const two = text.slice(i, i + 2);\n if (ch === \"\\n\") {\n buf += \" \";\n line++;\n i++;\n } else if (two === \"--\") {\n while (i < text.length && text[i] !== \"\\n\") i++;\n } else if (two === \"/*\") {\n let depth = 0;\n while (i < text.length) {\n if (text.startsWith(\"/*\", i)) {\n depth++;\n i += 2;\n } else if (text.startsWith(\"*/\", i)) {\n depth--;\n i += 2;\n if (depth === 0) break;\n } else {\n if (text[i] === \"\\n\") line++;\n i++;\n }\n }\n buf += \" \";\n } else if (ch === \"'\") {\n // E'…' strings take backslash escapes; standard strings only double the quote.\n const escapes = /[eE]/.test(text[i - 1] ?? \"\") && !/[\\w$]/.test(text[i - 2] ?? \"\");\n put(\"'\");\n i++;\n while (i < text.length) {\n if (escapes && text[i] === \"\\\\\") i += 2;\n else if (text[i] === \"'\" && text[i + 1] === \"'\") i += 2;\n else if (text[i] === \"'\") break;\n else {\n if (text[i] === \"\\n\") line++;\n i++;\n }\n }\n put(\"'\");\n i++;\n } else if (ch === '\"') {\n // Quoted identifiers keep their name, minus the quotes.\n i++;\n while (i < text.length && text[i] !== '\"') put(text[i++]);\n i++;\n } else if (ch === \"$\" && !/[\\w$]/.test(text[i - 1] ?? \"\") && /^\\$(?:[A-Za-z_]\\w*)?\\$/.test(text.slice(i))) {\n const tag = /^\\$(?:[A-Za-z_]\\w*)?\\$/.exec(text.slice(i))![0];\n const end = text.indexOf(tag, i + tag.length);\n const stop = end === -1 ? text.length : end + tag.length;\n bodies.push(text.slice(i + tag.length, end === -1 ? text.length : end).toLowerCase());\n for (let k = i; k < stop; k++) if (text[k] === \"\\n\") line++;\n put(`${tag} ${tag}`);\n i = stop;\n } else if (ch === \";\") {\n flush();\n i++;\n } else {\n put(ch);\n i++;\n }\n }\n flush();\n return out;\n}\n\n/** `schema.name`, lowercased, defaulting the schema to public. */\nfunction qualify(name: string): string {\n const n = name.trim().toLowerCase();\n return n.includes(\".\") ? n : `public.${n}`;\n}\n\nconst schemaOf = (name: string) => name.split(\".\")[0];\n\n/** The text inside the parentheses that open at `open` (balanced), and the index after the close. */\nfunction parenthesized(sql: string, open: number): { inner: string; end: number } {\n let depth = 0;\n for (let k = open; k < sql.length; k++) {\n if (sql[k] === \"(\") depth++;\n else if (sql[k] === \")\" && --depth === 0) return { inner: sql.slice(open + 1, k), end: k + 1 };\n }\n return { inner: sql.slice(open + 1), end: sql.length };\n}\n\n/** Remove every parenthesized group (argument lists, typmods). */\nfunction stripParens(s: string): string {\n let out = \"\";\n let depth = 0;\n for (const c of s) {\n if (c === \"(\") depth++;\n else if (c === \")\") depth = Math.max(0, depth - 1);\n else if (depth === 0) out += c;\n }\n return out;\n}\n\n/** Split on commas outside parentheses. */\nfunction splitTop(s: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let cur = \"\";\n for (const c of s) {\n if (c === \"(\") depth++;\n if (c === \")\") depth--;\n if (c === \",\" && depth === 0) {\n parts.push(cur);\n cur = \"\";\n } else cur += c;\n }\n if (cur.trim()) parts.push(cur);\n return parts.map((p) => p.trim()).filter(Boolean);\n}\n\nconst TYPE_ALIASES: Record<string, string> = {\n int: \"integer\",\n int4: \"integer\",\n int8: \"bigint\",\n int2: \"smallint\",\n bool: \"boolean\",\n varchar: \"character varying\",\n timestamptz: \"timestamp with time zone\",\n float8: \"double precision\",\n};\nconst MULTIWORD_TYPE = /^(?:double precision|character varying|character|bit varying|timestamp|time|interval)\\b/;\n\n/** A function's identity: its argument types (names, defaults, OUT args and typmods dropped). */\nexport function argTypes(args: string): string[] {\n const types: string[] = [];\n for (const raw of splitTop(args)) {\n let tokens = stripParens(raw.replace(/\\s+(?:default\\b|=).*$/, \"\")).trim().split(/\\s+/).filter(Boolean);\n const mode = tokens[0];\n if (mode === \"out\") continue;\n if (mode === \"in\" || mode === \"inout\" || mode === \"variadic\") tokens = tokens.slice(1);\n const joined = tokens.join(\" \");\n const type = tokens.length > 1 && !MULTIWORD_TYPE.test(joined) ? tokens.slice(1).join(\" \") : joined;\n types.push(TYPE_ALIASES[type] ?? type);\n }\n return types;\n}\n\ninterface Migration {\n /** Path relative to the app root, POSIX. */\n file: string;\n statements: SqlStatement[];\n}\n\n/** What git says about the migrations folder against the base ref. */\ninterface GitView {\n /** Paths (app-relative) that are new or changed since the merge base, including untracked files. */\n touched: Set<string>;\n /** Migrations that existed at the merge base and were modified, deleted or renamed. */\n edited: Array<{ file: string; status: \"modified\" | \"deleted\" | \"renamed\" }>;\n}\n\nfunction git(root: string, args: string[]): string | null {\n const r = spawnSync(\"git\", args, { cwd: root, encoding: \"utf8\" });\n return r.status === 0 ? r.stdout : null;\n}\n\n/** A GitView, or the reason git can't compare (null reason: not a git repo). */\nfunction gitView(root: string, dir: string, base: string): GitView | { reason: string; repo: boolean } {\n if (git(root, [\"rev-parse\", \"--is-inside-work-tree\"])?.trim() !== \"true\") return { reason: \"not a git repository\", repo: false };\n if (git(root, [\"rev-parse\", \"--verify\", \"--quiet\", `${base}^{commit}`]) === null) {\n return { reason: `the git ref ${base} isn't available (fetch it, or set doctor.supabase.base)`, repo: true };\n }\n const mergeBase = git(root, [\"merge-base\", \"HEAD\", base])?.trim();\n if (!mergeBase) return { reason: `HEAD has no merge base with ${base} (a shallow clone? fetch with depth 0)`, repo: true };\n const diff = git(root, [\"diff\", \"--relative\", \"--name-status\", \"-M\", mergeBase, \"--\", dir]);\n const untracked = git(root, [\"ls-files\", \"--others\", \"--exclude-standard\", \"--\", dir]);\n if (diff === null || untracked === null) return { reason: `git diff against ${base} failed`, repo: true };\n const sql = (p: string | undefined) => p !== undefined && p.endsWith(\".sql\");\n const touched = new Set<string>(untracked.split(\"\\n\").filter(sql));\n const edited: GitView[\"edited\"] = [];\n for (const row of diff.split(\"\\n\").filter(Boolean)) {\n const [status, a, b] = row.split(\"\\t\");\n if (status.startsWith(\"R\")) {\n if (sql(b)) touched.add(b);\n if (sql(a)) edited.push({ file: a, status: \"renamed\" });\n continue;\n }\n if (!sql(a)) continue;\n if (status.startsWith(\"A\")) touched.add(a);\n else if (status.startsWith(\"M\") || status.startsWith(\"T\")) {\n touched.add(a);\n edited.push({ file: a, status: \"modified\" });\n } else if (status.startsWith(\"D\")) edited.push({ file: a, status: \"deleted\" });\n }\n return { touched, edited };\n}\n\nexport function checkSupabasePack(ctx: DoctorContext): void {\n const settings = ctx.config.supabase ?? {};\n const dir = settings.migrations ?? DEFAULT_MIGRATIONS;\n const abs = path.join(ctx.root, dir);\n if (!existsSync(abs)) throw new DoctorConfigError(`the supabase pack reads ${dir}, which doesn't exist; set doctor.supabase.migrations`);\n const migrations: Migration[] = readdirSync(abs)\n .filter((n) => n.endsWith(\".sql\"))\n .sort()\n .map((n) => ({ file: `${dir}/${n}`, statements: sqlStatements(readFileSync(path.join(abs, n), \"utf8\")) }));\n const exposed = new Set((settings.exposedSchemas ?? DEFAULT_EXPOSED).map((s) => s.toLowerCase()));\n\n const base = settings.base ?? DEFAULT_BASE;\n const view = gitView(ctx.root, dir, base);\n if (\"reason\" in view) {\n if (view.repo) ctx.report({ rule: \"migration-edited\", level: \"warn\", file: dir, message: `can't check for edited migrations: ${view.reason}` });\n } else {\n for (const e of view.edited) {\n ctx.report({\n rule: \"migration-edited\",\n file: e.file,\n subject: e.file,\n message: `${e.status === \"modified\" ? \"edits\" : e.status === \"deleted\" ? \"deletes\" : \"renames\"} a migration that already exists on ${base}, so it has been applied; put the change in a new migration instead`,\n });\n }\n }\n\n // Which migrations are new: changed since the base (when git can tell) and not before `since`.\n const since = settings.since;\n const afterSince = (file: string) => since === undefined || path.posix.basename(file) >= since;\n if (\"reason\" in view && since === undefined) {\n ctx.report({\n rule: \"migration-grants\",\n level: \"warn\",\n file: dir,\n message: `skipped: can't tell new migrations from applied ones (${view.reason}); fetch the base ref (CI: fetch-depth 0) or set doctor.supabase.since`,\n });\n } else {\n const isNew = (file: string) => afterSince(file) && (\"reason\" in view || view.touched.has(file));\n checkGrants(ctx, migrations.filter((m) => isNew(m.file)), exposed);\n }\n checkRls(ctx, migrations, exposed);\n checkDefinerSearchPath(ctx, migrations);\n}\n\n/** Grantee list of a grant: `to a, b [with grant option] [granted by x]`. */\nfunction granteesOf(s: string): string[] {\n return s\n .replace(/\\s+granted by .*$/, \"\")\n .replace(/\\s+with grant option$/, \"\")\n .split(/\\s*,\\s*/)\n .map((r) => r.replace(/^group\\s+/, \"\").trim())\n .filter(Boolean);\n}\n\n/** `migration-grants`: grant function privileges by name, and never expose an unexposed schema to anon/public. */\nfunction checkGrants(ctx: DoctorContext, migrations: Migration[], exposed: Set<string>): void {\n const fix = \"grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives\";\n const open = (roles: string[]) => roles.filter((r) => r === \"anon\" || r === \"public\");\n /** error for anon/public, warn for authenticated, nothing for other roles (service_role, postgres, …). */\n const blanket = (roles: string[]): { level: Level; who: string } | null => {\n const o = open(roles);\n if (o.length) return { level: \"error\", who: o.join(\" and \") };\n if (roles.includes(\"authenticated\")) return { level: \"warn\", who: \"authenticated\" };\n return null;\n };\n for (const { file, statements } of migrations) {\n for (const { sql, line } of statements) {\n const all = /^grant\\b.*\\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);\n if (all) {\n const hit = blanket(granteesOf(all[1]));\n if (hit) {\n ctx.report({ rule: \"migration-grants\", level: hit.level, file, line, subject: \"on all functions\", message: `grants every function in a schema to ${hit.who}, which re-grants functions an earlier migration revoked; ${fix}` });\n }\n continue;\n }\n const defaults = /^alter default privileges\\b.*?\\bgrant\\b.*\\bon (?:functions|routines) to (.+)$/.exec(sql);\n if (defaults) {\n const hit = blanket(granteesOf(defaults[1]));\n if (hit) {\n ctx.report({ rule: \"migration-grants\", level: hit.level, file, line, subject: \"alter default privileges\", message: `grants default privileges on functions to ${hit.who}, so every future function is callable by them; ${fix}` });\n }\n continue;\n }\n const fn = /^grant\\b.*?\\bon (?:function|procedure|routine)s? (.+?) to (.+)$/.exec(sql);\n if (fn) {\n const roles = open(granteesOf(fn[2]));\n if (!roles.length) continue;\n for (const name of splitTop(fn[1]).map((n) => qualify(stripParens(n)))) {\n if (exposed.has(schemaOf(name))) continue;\n ctx.report({\n rule: \"migration-grants\",\n file,\n line,\n subject: name,\n message: `grants ${name} to ${roles.join(\" and \")}; a function outside the exposed schemas is never callable by anon or public (grant it to authenticated, or expose a wrapper)`,\n });\n }\n continue;\n }\n const schema = /^grant\\b.*?\\bon schema (.+?) to (.+)$/.exec(sql);\n if (schema) {\n const roles = open(granteesOf(schema[2]));\n if (!roles.length) continue;\n for (const s of schema[1].split(/\\s*,\\s*/).map((x) => x.trim())) {\n if (exposed.has(s)) continue;\n ctx.report({\n rule: \"migration-grants\",\n file,\n line,\n subject: `schema ${s}`,\n message: `grants schema ${s} to ${roles.join(\" and \")}; a schema outside the exposed ones stays closed to anon and public`,\n });\n }\n }\n }\n }\n}\n\n/** `migration-rls`: after every migration, each table in an exposed schema has row level security on. */\nfunction checkRls(ctx: DoctorContext, migrations: Migration[], exposed: Set<string>): void {\n const tables = new Map<string, { rls: boolean; file: string; line: number; disabled: boolean }>();\n const name = String.raw`([\\w$.]+)`;\n const target = String.raw`^alter table (?:if exists )?(?:only )?${name}`;\n for (const { file, statements } of migrations) {\n for (const { sql, line, bodies } of statements) {\n // RLS turned on by dynamic SQL (a do-block loop over tables) can't be traced: trust it for every table so far.\n if (bodies.some((b) => /\\benable row level security\\b/.test(b))) for (const t of tables.values()) t.rls = true;\n const create = new RegExp(String.raw`^create (?:(?:global |local )?(?:temp|temporary) |unlogged )?table (?:if not exists )?${name}`).exec(sql);\n if (create) {\n if (!/^create (?:global |local )?(?:temp|temporary) /.test(sql)) tables.set(qualify(create[1]), { rls: false, file, line, disabled: false });\n continue;\n }\n const rename = new RegExp(`${target} rename to ([\\\\w$]+)$`).exec(sql);\n const move = new RegExp(`${target} set schema ([\\\\w$]+)$`).exec(sql);\n if (rename || move) {\n const from = qualify((rename ?? move)![1]);\n const to = rename ? `${schemaOf(from)}.${rename[2]}` : `${move![2]}.${from.split(\".\")[1]}`;\n const state = tables.get(from);\n if (state) {\n tables.delete(from);\n tables.set(to, state);\n }\n continue;\n }\n const alter = new RegExp(target).exec(sql);\n if (alter && /\\b(?:enable|disable) row level security\\b/.test(sql)) {\n const t = qualify(alter[1]);\n if (/\\bdisable row level security\\b/.test(sql)) tables.set(t, { rls: false, file, line, disabled: true });\n else {\n const state = tables.get(t);\n if (state) state.rls = true;\n }\n continue;\n }\n const drop = /^drop table (?:if exists )?(.+?)(?: cascade| restrict)?$/.exec(sql);\n if (drop) for (const n of drop[1].split(\",\")) tables.delete(qualify(n));\n }\n }\n for (const [t, at] of tables) {\n if (at.rls || !exposed.has(schemaOf(t))) continue;\n ctx.report({\n rule: \"migration-rls\",\n file: at.file,\n line: at.line,\n subject: t,\n message: at.disabled\n ? `disables row level security on ${t}, and no later migration turns it back on; anyone with the API key can read and write it`\n : `creates ${t} without enabling row level security in any migration; add \"alter table ${t} enable row level security;\" and its policies`,\n });\n }\n}\n\n/** `migration-definer-search-path`: a security definer function pins its search_path. Functions are keyed by name and argument types. */\nfunction checkDefinerSearchPath(ctx: DoctorContext, migrations: Migration[]): void {\n const fns = new Map<string, { definer: boolean; searchPath: boolean; file: string; line: number }>();\n /** Keys a statement names: one overload with an argument list, every overload without one. */\n const keysFor = (sql: string, nameEnd: number, fnName: string): string[] => {\n const rest = sql.slice(nameEnd).trimStart();\n if (rest.startsWith(\"(\")) {\n const { inner } = parenthesized(rest, 0);\n return [`${fnName}(${argTypes(inner).join(\",\")})`];\n }\n return [...fns.keys()].filter((k) => k.startsWith(`${fnName}(`));\n };\n for (const { file, statements } of migrations) {\n for (const { sql, line } of statements) {\n const create = /^create (?:or replace )?(?:function|procedure) ([\\w$.]+)\\s*/.exec(sql);\n if (create) {\n const [key] = keysFor(sql, create[0].length, qualify(create[1]));\n fns.set(key, { definer: /\\bsecurity definer\\b/.test(sql), searchPath: /\\bset search_path\\b/.test(sql), file, line });\n continue;\n }\n const alter = /^alter (?:function|procedure|routine) ([\\w$.]+)\\s*/.exec(sql);\n if (alter) {\n const fnName = qualify(alter[1]);\n const keys = keysFor(sql, alter[0].length, fnName);\n const rename = / rename to ([\\w$]+)$/.exec(sql);\n const move = / set schema ([\\w$]+)$/.exec(sql);\n for (const key of keys) {\n const state = fns.get(key);\n if (rename || move) {\n if (!state) continue;\n fns.delete(key);\n const newName = rename ? `${schemaOf(fnName)}.${rename[1]}` : `${move![1]}.${fnName.split(\".\")[1]}`;\n fns.set(newName + key.slice(fnName.length), state);\n continue;\n }\n // A function created outside the migrations: only what this alter says is known.\n const next = state ?? { definer: false, searchPath: false, file, line };\n if (/\\bsecurity definer\\b/.test(sql)) Object.assign(next, { definer: true, file, line });\n if (/\\bsecurity invoker\\b/.test(sql)) next.definer = false;\n if (/\\bset search_path\\b/.test(sql)) next.searchPath = true;\n if (/\\breset (?:search_path|all)\\b/.test(sql)) Object.assign(next, { searchPath: false, file, line });\n fns.set(key, next);\n }\n continue;\n }\n const drop = /^drop (?:function|procedure|routine) (?:if exists )?(.+?)(?: cascade| restrict)?$/.exec(sql);\n if (drop) {\n for (const part of splitTop(drop[1])) {\n const m = /^([\\w$.]+)\\s*/.exec(part);\n if (m) for (const key of keysFor(part, m[0].length, qualify(m[1]))) fns.delete(key);\n }\n }\n }\n }\n for (const [key, at] of fns) {\n if (!at.definer || at.searchPath) continue;\n ctx.report({\n rule: \"migration-definer-search-path\",\n file: at.file,\n line: at.line,\n subject: key,\n message: `${key} is security definer without \"set search_path\"; add set search_path = '' and schema-qualify the names in its body, so a caller's objects can't stand in for yours`,\n });\n }\n}\n","/**\n * The release train: `@marktiderman/genesis` ships `dist/versions.json`, the\n * exact version of every Genesis package it was released with. When an app\n * has the umbrella installed, every other Genesis package it has installed\n * should be that version, so the app runs a set that was tested together.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { findPackageDir } from \"./genesis.js\";\nimport type { DoctorContext } from \"./types.js\";\n\nexport const UMBRELLA_PACKAGE = \"@marktiderman/genesis\";\n\n/** The shape of the umbrella's `dist/versions.json`. */\nexport interface ReleaseManifest {\n version: string;\n packages: Record<string, string>;\n}\n\n/** The installed umbrella's manifest, or null when there's no umbrella or no manifest. */\nexport function readReleaseManifest(root: string): ReleaseManifest | null {\n const dir = findPackageDir(root, UMBRELLA_PACKAGE);\n const file = dir && path.join(dir, \"dist\", \"versions.json\");\n if (!file || !existsSync(file)) return null;\n return JSON.parse(readFileSync(file, \"utf8\")) as ReleaseManifest;\n}\n\n/** `version-skew`: an installed Genesis package isn't the version the installed umbrella was released with. */\nexport function checkVersionSkew(ctx: DoctorContext): void {\n const manifest = readReleaseManifest(ctx.root);\n if (!manifest) return;\n for (const [name, want] of Object.entries(manifest.packages)) {\n const dir = findPackageDir(ctx.root, name);\n if (!dir) continue;\n const have = (JSON.parse(readFileSync(path.join(dir, \"package.json\"), \"utf8\")) as { version: string }).version;\n if (have === want) continue;\n ctx.report({\n rule: \"version-skew\",\n level: \"warn\",\n file: \"package.json\",\n subject: name,\n message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`,\n });\n }\n}\n","/**\n * `genesis doctor`: checks an app against the installed Genesis — local\n * primitives, forbidden imports, raw tags Genesis has components for,\n * literal colors, undefined tokens, shadowed exports — plus the app's own\n * pattern rules and rule plugins. The CLI and the Vite plugin both call\n * `runDoctor`.\n */\nimport * as path from \"node:path\";\nimport { buildCommands, runBuild } from \"./build.js\";\nimport { DoctorConfigError, loadConfig } from \"./config.js\";\nimport { globToRegExp } from \"./glob.js\";\nimport { loadGenesis } from \"./genesis.js\";\nimport { loadPatternRules } from \"./patterns.js\";\nimport { loadPlugins } from \"./plugins.js\";\nimport {\n BUILTIN_RULES,\n checkColors,\n checkImports,\n checkProjectLayout,\n checkRawTags,\n checkShadowedExports,\n checkTokens,\n unusedComponents,\n} from \"./rules.js\";\nimport { checkNativePack } from \"./native.js\";\nimport { scanFiles } from \"./scan.js\";\nimport { checkSupabasePack } from \"./supabase.js\";\nimport { checkVersionSkew } from \"./versions.js\";\nimport type { DoctorConfig, DoctorContext, DoctorPlugin, DoctorResult, Finding, FindingInput, GenesisFacts } from \"./types.js\";\n\nexport type * from \"./types.js\";\nexport {\n DoctorConfigError,\n GenesisConfigError,\n loadConfig,\n readGenesisConfig,\n validateConfig,\n validateLinks,\n type GenesisConfigFile,\n type GenesisLinks,\n} from \"./config.js\";\nexport { loadGenesis, findPackageDir, parseExportNames, readPackageExports } from \"./genesis.js\";\nexport { parseRulesMarkdown } from \"./patterns.js\";\nexport { defineDoctorPlugin } from \"./plugins.js\";\nexport { BUILTIN_RULES } from \"./rules.js\";\nexport { globToRegExp } from \"./glob.js\";\nexport { nativeLayouts } from \"./native.js\";\nexport { sqlStatements } from \"./supabase.js\";\nexport { readReleaseManifest, type ReleaseManifest } from \"./versions.js\";\n\nexport interface RunDoctorOptions {\n /** The app root. Default `process.cwd()`. */\n root?: string;\n /** Explicit config file (otherwise genesis.config.json, then package.json `genesis`). */\n configPath?: string;\n /** Use this config instead of reading one. Relative plugin paths resolve from `root`. */\n config?: DoctorConfig;\n /** Treat warnings as failures. */\n strict?: boolean;\n /** Run the app's typecheck and build after the checks. */\n build?: boolean;\n /** Pipe build output instead of inheriting the terminal (for --json). */\n quietBuild?: boolean;\n /** Reuse facts read earlier (the Vite dev server caches them). */\n genesis?: GenesisFacts;\n}\n\nexport async function runDoctor(options: RunDoctorOptions = {}): Promise<DoctorResult> {\n const root = path.resolve(options.root ?? process.cwd());\n const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);\n const config = loaded.config;\n const genesis = options.genesis ?? loadGenesis(root, config);\n const files = scanFiles(root, config);\n\n const patterns = loadPatternRules(root, config.patterns, config.rulesDoc);\n const plugins = await loadPlugins(config.plugins, loaded.dir);\n const builtinIds = new Set<string>(BUILTIN_RULES);\n for (const p of config.patterns ?? []) {\n if (builtinIds.has(p.id)) throw new DoctorConfigError(`doctor.patterns: \"${p.id}\" is a built-in rule id; pick another`);\n }\n\n const raw: FindingInput[] = [];\n const ctx: DoctorContext = { root, files, genesis, config, report: (f) => raw.push(f) };\n const builtins: DoctorPlugin[] = [\n { name: \"layout\", check: checkProjectLayout },\n { name: \"imports\", check: checkImports },\n { name: \"raw-tags\", check: checkRawTags },\n { name: \"colors\", check: checkColors },\n { name: \"tokens\", check: checkTokens },\n { name: \"shadowed-exports\", check: checkShadowedExports },\n { name: \"version-skew\", check: checkVersionSkew },\n ...(config.packs?.includes(\"native\") ? [{ name: \"native\", check: checkNativePack }] : []),\n ...(config.packs?.includes(\"supabase\") ? [{ name: \"supabase\", check: checkSupabasePack }] : []),\n ];\n for (const plugin of [...builtins, ...(patterns ? [patterns.plugin] : []), ...plugins]) {\n try {\n await plugin.check(ctx);\n } catch (err) {\n if (err instanceof DoctorConfigError) throw err;\n raw.push({ rule: \"plugin-error\", file: plugin.name, message: `rule plugin \"${plugin.name}\" threw: ${(err as Error).message}` });\n }\n }\n\n if (options.build) {\n const failure = runBuild(root, buildCommands(root, config), options.quietBuild ?? false);\n if (failure) raw.push(failure);\n }\n\n const findings = applyConfig(raw, config);\n const errors = findings.filter((f) => f.level === \"error\").length;\n const warnings = findings.length - errors;\n return {\n ok: errors === 0 && !(options.strict && warnings > 0),\n root,\n genesis,\n findings,\n unused: unusedComponents(ctx),\n ruleCount: (patterns?.count ?? 0) + plugins.length,\n errors,\n warnings,\n };\n}\n\n/** Apply `rules` level overrides and `allow` exceptions; flag exceptions that no longer match anything. */\nfunction applyConfig(raw: FindingInput[], config: DoctorConfig): Finding[] {\n const allow = (config.allow ?? []).map((entry) => ({ entry, file: entry.file ? globToRegExp(entry.file) : null, used: false }));\n const out: Finding[] = [];\n for (const input of raw) {\n const setting = config.rules?.[input.rule];\n if (setting === \"off\") continue;\n const finding: Finding = {\n rule: input.rule,\n level: setting ?? input.level ?? \"error\",\n file: input.file,\n line: input.line ?? 0,\n message: input.message,\n ...(input.subject !== undefined ? { subject: input.subject } : {}),\n };\n const exception = allow.find(\n (a) => a.entry.rule === finding.rule && (!a.file || a.file.test(finding.file)) && (a.entry.match === undefined || a.entry.match === finding.subject),\n );\n if (exception) {\n exception.used = true;\n continue;\n }\n out.push(finding);\n }\n // stale-exception is a rule like any other: `rules` can turn it off or change its level.\n const staleLevel = config.rules?.[\"stale-exception\"];\n for (const a of allow) {\n if (staleLevel === \"off\" || a.used || config.rules?.[a.entry.rule] === \"off\") continue;\n out.push({\n rule: \"stale-exception\",\n level: staleLevel ?? \"warn\",\n file: a.entry.file ?? \"genesis config\",\n line: 0,\n subject: a.entry.rule,\n message: `the allow entry for ${a.entry.rule}${a.entry.match ? ` (${a.entry.match})` : \"\"} no longer matches anything; remove it`,\n });\n }\n return out.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line || x.rule.localeCompare(y.rule));\n}\n\n/** The human-readable report. */\nexport function formatReport(result: DoctorResult): string {\n const g = result.genesis;\n const lines = [\n `Genesis doctor: ${g.uiPackage}@${g.uiVersion}, ${g.components.length} components, ${g.tokens.size} tokens, ` +\n `${result.ruleCount} app rules; raw tags checked: ${[...g.rawTags.keys()].join(\", \") || \"none\"}`,\n ];\n for (const f of result.findings) {\n lines.push(`${f.level.toUpperCase().padEnd(5)} ${f.file}${f.line ? `:${f.line}` : \"\"} [${f.rule}] ${f.message}`);\n }\n lines.push(`Available but unused (${result.unused.length}): ${result.unused.join(\", \") || \"none\"}`);\n lines.push(result.ok ? `PASS (${result.warnings} warnings)` : `FAIL (${result.errors} errors, ${result.warnings} warnings)`);\n return lines.join(\"\\n\");\n}\n\n/** The `--json` report: plain data, sets turned into sorted lists. */\nexport function toJson(result: DoctorResult) {\n return {\n ok: result.ok,\n genesis: `${result.genesis.uiPackage}@${result.genesis.uiVersion}`,\n errors: result.errors,\n warnings: result.warnings,\n findings: result.findings,\n unused: result.unused,\n };\n}\n\n/** What `--print-genesis` shows: the facts every rule is derived from. */\nexport function genesisSummary(g: GenesisFacts) {\n return {\n package: `${g.uiPackage}@${g.uiVersion}`,\n components: g.components,\n tokens: [...g.tokens].sort(),\n rawTags: Object.fromEntries(g.rawTags),\n palette: g.palette,\n };\n}\n","/**\n * `genesisDoctor()` for Vite: runs the same checks as `genesis doctor`.\n *\n * - `vite build`: fails the build when the doctor finds errors.\n * - `vite dev`: logs problems and shows Vite's error overlay, re-checking\n * (debounced) whenever a scanned file, the config or the rules doc changes.\n *\n * import { genesisDoctor } from \"@marktiderman/genesis-cli/vite\";\n * export default defineConfig({ plugins: [genesisDoctor()] });\n */\nimport * as path from \"node:path\";\nimport type { Plugin, ViteDevServer } from \"vite\";\nimport { formatReport, loadConfig, loadGenesis, runDoctor, type DoctorResult, type GenesisFacts } from \"./doctor/index.js\";\n\nexport interface GenesisDoctorOptions {\n /** The app root. Default: Vite's `root`. */\n root?: string;\n /** Explicit config file. */\n configPath?: string;\n /** Fail builds on warnings too. */\n strict?: boolean;\n /** Re-check delay after a change, in ms. Default 300. */\n debounceMs?: number;\n}\n\nconst formatProblems = (result: DoctorResult, withWarnings = false) =>\n result.findings\n .filter((f) => f.level === \"error\" || withWarnings)\n .map((f) => `${f.file}${f.line ? `:${f.line}` : \"\"} [${f.rule}] ${f.message}`)\n .join(\"\\n\");\n\nexport function genesisDoctor(options: GenesisDoctorOptions = {}): Plugin[] {\n let root = options.root ?? process.cwd();\n return [\n {\n name: \"genesis-doctor:build\",\n apply: \"build\",\n configResolved(config) {\n root = options.root ?? config.root;\n },\n async buildStart() {\n const result = await runDoctor({ root, configPath: options.configPath, strict: options.strict });\n if (!result.ok) this.error(`Genesis doctor found problems:\\n${formatProblems(result, options.strict)}`);\n if (result.warnings > 0) this.warn(formatReport(result));\n },\n },\n {\n name: \"genesis-doctor:serve\",\n apply: \"serve\",\n configResolved(config) {\n root = options.root ?? config.root;\n },\n configureServer(server: ViteDevServer) {\n let genesis: GenesisFacts | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let failing = false;\n // The last overlay message, re-sent to browsers that connect after the check ran.\n let lastError: string | null = null;\n const showError = (message: string) => {\n lastError = message;\n failing = true;\n server.config.logger.error(message, { timestamp: true });\n server.ws.send({ type: \"error\", err: { message, stack: \"\", plugin: \"genesis-doctor\" } });\n };\n let running = false;\n let again = false;\n\n const check = async () => {\n if (running) {\n again = true;\n return;\n }\n running = true;\n try {\n // Genesis facts only change on reinstall; read them once per server.\n genesis ??= loadGenesis(root, loadConfig(root, options.configPath).config);\n const result = await runDoctor({ root, configPath: options.configPath, genesis });\n if (result.errors > 0) {\n showError(`Genesis doctor found problems:\\n${formatProblems(result)}`);\n } else if (failing) {\n // Clear the overlay once the problems are fixed.\n failing = false;\n lastError = null;\n server.config.logger.info(\"Genesis doctor: all clear\", { timestamp: true });\n server.ws.send({ type: \"full-reload\" });\n }\n } catch (err) {\n showError(`Genesis doctor could not run: ${(err as Error).message}`);\n } finally {\n running = false;\n if (again) {\n again = false;\n void check();\n }\n }\n };\n\n // The config and rules doc live outside src/ (and may live outside root),\n // so watch them explicitly and always re-check when they change.\n const explicit = new Set([path.join(root, \"genesis.config.json\"), ...(options.configPath ? [path.resolve(root, options.configPath)] : [])]);\n try {\n const { config } = loadConfig(root, options.configPath);\n if (config.rulesDoc) explicit.add(path.resolve(root, config.rulesDoc));\n } catch {\n // A broken config is reported by the first check.\n }\n const schedule = (file: string) => {\n if (!explicit.has(path.resolve(file))) {\n const rel = path.relative(root, file).split(path.sep).join(\"/\");\n if (rel.startsWith(\"..\") || rel.includes(\"node_modules/\")) return;\n }\n clearTimeout(timer);\n timer = setTimeout(() => void check(), options.debounceMs ?? 300);\n };\n server.watcher.add([...explicit]);\n server.watcher.on(\"change\", schedule);\n server.watcher.on(\"add\", schedule);\n server.watcher.on(\"unlink\", schedule);\n server.ws.on(\"connection\", () => {\n if (lastError) server.ws.send({ type: \"error\", err: { message: lastError, stack: \"\", plugin: \"genesis-doctor\" } });\n });\n server.httpServer?.once(\"listening\", () => void check());\n if (!server.httpServer) void check();\n },\n },\n ];\n}\n"]}