@biffo/cli 0.324.5 → 0.324.7

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 (2) hide show
  1. package/dist/index.js +375 -396
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9615,12 +9615,83 @@ async function promptForConfig(awsAccountId, awsRegion, awsProfile) {
9615
9615
  import { Command as Command23 } from "commander";
9616
9616
 
9617
9617
  // src/commands/plugin-create.ts
9618
- import { existsSync as existsSync32, readFileSync as readFileSync23, writeFileSync as writeFileSync11 } from "fs";
9619
- import { dirname as dirname10, join as join32, resolve as resolve13 } from "path";
9618
+ import { existsSync as existsSync33, readFileSync as readFileSync23, writeFileSync as writeFileSync11 } from "fs";
9619
+ import { dirname as dirname10, join as join34, resolve as resolve13 } from "path";
9620
9620
  import { fileURLToPath as fileURLToPath6 } from "url";
9621
9621
  import chalk13 from "chalk";
9622
9622
  import { Command as Command14 } from "commander";
9623
9623
 
9624
+ // src/lib/plugin-commit.ts
9625
+ import { existsSync as existsSync29 } from "fs";
9626
+ import { join as join30 } from "path";
9627
+
9628
+ // src/adapters/plugin-migrations/index.ts
9629
+ import { join as join29 } from "path";
9630
+ var PluginMigrationsAdapter = class {
9631
+ /**
9632
+ * Generates migration file(s) for `pluginNames` (every discovered
9633
+ * installed plugin if omitted), returning the absolute path of each newly
9634
+ * generated file — empty if every named plugin already had a migration,
9635
+ * or declared no tables.
9636
+ */
9637
+ async generate(cwd, pluginNames) {
9638
+ const scriptPath = join29(cwd, "services", "api", "scripts", "generate_plugin_migrations.py");
9639
+ const args = [
9640
+ "run",
9641
+ "python",
9642
+ scriptPath,
9643
+ "--services-root",
9644
+ join29(cwd, "services"),
9645
+ "--versions-dir",
9646
+ join29(cwd, "services", "api", "migrations", "versions")
9647
+ ];
9648
+ for (const name of pluginNames ?? []) {
9649
+ args.push("--plugin", name);
9650
+ }
9651
+ const result = await runUv(args, join29(cwd, "services", "api"), {
9652
+ missing: "biffo plugin install/upgrade/sync-migrations needs `uv` (Python) on PATH to generate a real migration file \u2014 see https://docs.astral.sh/uv/ to install it. Once installed, re-run this command (or `biffo plugin sync-migrations <name>` if services/<name>/ is already copied in).",
9653
+ failed: "Failed to generate plugin migration"
9654
+ });
9655
+ return result.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
9656
+ }
9657
+ /**
9658
+ * Brings the instance's root `uv.lock` in step with its workspace (`uv lock`).
9659
+ *
9660
+ * `plugin install` adds a member to the uv workspace, so the committed lock is stale the moment the plugin lands — whether or
9661
+ * not the plugin has tables (only a table-bearing plugin runs `uv run` for a migration, which is a side effect that happens to
9662
+ * re-lock). Locking explicitly, then staging the result, is what makes `uv lock --check` pass on the install commit
9663
+ * (biffo-template#2106); leaving it to whichever `uv run` came last is how the no-tables install shipped a stale lock.
9664
+ */
9665
+ async refreshLock(cwd) {
9666
+ await runUv(["lock"], cwd, {
9667
+ missing: "biffo plugin install needs `uv` (Python) on PATH to refresh uv.lock for the workspace member it adds \u2014 see https://docs.astral.sh/uv/ to install it, then run `uv lock` and commit uv.lock yourself.",
9668
+ failed: "Failed to refresh uv.lock (`uv lock`)"
9669
+ });
9670
+ }
9671
+ };
9672
+ async function runUv(args, cwd, messages) {
9673
+ try {
9674
+ return await execa("uv", args, { cwd });
9675
+ } catch (err) {
9676
+ const cause = err;
9677
+ if (cause.code === "ENOENT") throw new Error(messages.missing);
9678
+ throw new Error(`${messages.failed}: ${cause.stderr?.trim() || err.message}`);
9679
+ }
9680
+ }
9681
+
9682
+ // src/lib/plugin-commit.ts
9683
+ async function withRefreshedLock(deps, cwd, stagePaths) {
9684
+ if (!existsSync29(join30(cwd, "uv.lock"))) return stagePaths;
9685
+ await (deps.migrations ?? new PluginMigrationsAdapter()).refreshLock(cwd);
9686
+ return stagePaths.includes("uv.lock") ? stagePaths : [...stagePaths, "uv.lock"];
9687
+ }
9688
+ async function commitPluginChange(deps, cwd, stagePaths, message) {
9689
+ const paths = await withRefreshedLock(deps, cwd, stagePaths);
9690
+ await deps.git.add(cwd, paths);
9691
+ await deps.git.commit(cwd, message, paths);
9692
+ return paths;
9693
+ }
9694
+
9624
9695
  // src/lib/registry-sources.ts
9625
9696
  function manifestUrlFor(repoUrl, branch = "dev") {
9626
9697
  const slug = repoUrl.replace(/^https:\/\/github\.com\//, "").replace(/\.git$/, "");
@@ -9680,21 +9751,21 @@ function workflowCheckContexts(workflow) {
9680
9751
  }
9681
9752
 
9682
9753
  // src/lib/plugin-locations.ts
9683
- import { existsSync as existsSync29, readdirSync as readdirSync10 } from "fs";
9684
- import { join as join29 } from "path";
9754
+ import { existsSync as existsSync30, readdirSync as readdirSync10 } from "fs";
9755
+ import { join as join31 } from "path";
9685
9756
  var FIRST_PARTY_PLUGINS_DIR = "_plugins";
9686
9757
  var PLUGIN_MANIFEST_FILE = "biffo.plugin.json";
9687
9758
  function pluginDir(name, channel) {
9688
9759
  return channel === "first-party" ? `services/${FIRST_PARTY_PLUGINS_DIR}/${name}` : `services/${name}`;
9689
9760
  }
9690
9761
  function scanDir(absDir, relDir, channel) {
9691
- if (!existsSync29(absDir)) return [];
9762
+ if (!existsSync30(absDir)) return [];
9692
9763
  const found = [];
9693
9764
  for (const entry of readdirSync10(absDir, { withFileTypes: true })) {
9694
9765
  if (!entry.isDirectory()) continue;
9695
9766
  if (channel === "third-party" && entry.name === FIRST_PARTY_PLUGINS_DIR) continue;
9696
- const manifestPath = join29(absDir, entry.name, PLUGIN_MANIFEST_FILE);
9697
- if (!existsSync29(manifestPath)) continue;
9767
+ const manifestPath = join31(absDir, entry.name, PLUGIN_MANIFEST_FILE);
9768
+ if (!existsSync30(manifestPath)) continue;
9698
9769
  found.push({
9699
9770
  dirName: entry.name,
9700
9771
  relDir: `${relDir}/${entry.name}`,
@@ -9705,11 +9776,11 @@ function scanDir(absDir, relDir, channel) {
9705
9776
  return found;
9706
9777
  }
9707
9778
  function findInstalledPlugins(cwd) {
9708
- const servicesDir = join29(cwd, "services");
9779
+ const servicesDir = join31(cwd, "services");
9709
9780
  return [
9710
9781
  ...scanDir(servicesDir, "services", "third-party"),
9711
9782
  ...scanDir(
9712
- join29(servicesDir, FIRST_PARTY_PLUGINS_DIR),
9783
+ join31(servicesDir, FIRST_PARTY_PLUGINS_DIR),
9713
9784
  `services/${FIRST_PARTY_PLUGINS_DIR}`,
9714
9785
  "first-party"
9715
9786
  )
@@ -9717,33 +9788,9 @@ function findInstalledPlugins(cwd) {
9717
9788
  }
9718
9789
 
9719
9790
  // src/lib/plugin-workspace-sources.ts
9720
- import { existsSync as existsSync30, readdirSync as readdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
9721
- import { join as join30 } from "path";
9791
+ import { existsSync as existsSync31, readdirSync as readdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
9792
+ import { join as join32 } from "path";
9722
9793
  import { parse as parseToml } from "smol-toml";
9723
- function readTomlStringArray(text, key) {
9724
- const open = new RegExp(`^${key}\\s*=\\s*\\[`, "m").exec(text);
9725
- if (!open) return [];
9726
- const strings = [];
9727
- let depth = 1;
9728
- let i = open.index + open[0].length;
9729
- while (i < text.length && depth > 0) {
9730
- const c = text[i];
9731
- if (c === "#") {
9732
- const nl = text.indexOf("\n", i);
9733
- i = nl === -1 ? text.length : nl;
9734
- } else if (c === '"' || c === "'") {
9735
- const close = text.indexOf(c, i + 1);
9736
- if (close === -1) break;
9737
- if (depth === 1) strings.push(text.slice(i + 1, close));
9738
- i = close + 1;
9739
- } else {
9740
- if (c === "[") depth++;
9741
- else if (c === "]") depth--;
9742
- i++;
9743
- }
9744
- }
9745
- return depth === 0 ? strings : [];
9746
- }
9747
9794
  function normaliseName(name) {
9748
9795
  return name.replace(/[-_.]+/g, "-").toLowerCase();
9749
9796
  }
@@ -9771,15 +9818,17 @@ function requirementsIn(groups) {
9771
9818
  return Object.values(groups).filter(Array.isArray).flat().filter((entry) => typeof entry === "string");
9772
9819
  }
9773
9820
  function readDeclaredDependencyNames(doc) {
9821
+ return readDeclaredRequirements(doc).map(requirementName).filter((name) => name !== null);
9822
+ }
9823
+ function readDeclaredRequirements(doc) {
9774
9824
  const project = isTable(doc.project) ? doc.project : {};
9775
- const requirements = [
9825
+ return [
9776
9826
  ...(Array.isArray(project.dependencies) ? project.dependencies : []).filter(
9777
9827
  (dep) => typeof dep === "string"
9778
9828
  ),
9779
9829
  ...requirementsIn(project["optional-dependencies"]),
9780
9830
  ...requirementsIn(doc["dependency-groups"])
9781
9831
  ];
9782
- return requirements.map(requirementName).filter((name) => name !== null);
9783
9832
  }
9784
9833
  function existingSourceNames(doc) {
9785
9834
  const tool = isTable(doc.tool) ? doc.tool : {};
@@ -9852,8 +9901,8 @@ function isSourcesHeader(header) {
9852
9901
  return isTable(node) && Object.keys(node).length === 0;
9853
9902
  }
9854
9903
  function workspaceMemberNames(instanceRoot) {
9855
- const rootPyproject = join30(instanceRoot, "pyproject.toml");
9856
- if (!existsSync30(rootPyproject)) return /* @__PURE__ */ new Set();
9904
+ const rootPyproject = join32(instanceRoot, "pyproject.toml");
9905
+ if (!existsSync31(rootPyproject)) return /* @__PURE__ */ new Set();
9857
9906
  const doc = parsePyproject(readFileSync21(rootPyproject, "utf8"), rootPyproject);
9858
9907
  const tool = isTable(doc.tool) ? doc.tool : {};
9859
9908
  const uv = isTable(tool.uv) ? tool.uv : {};
@@ -9866,7 +9915,7 @@ function workspaceMemberNames(instanceRoot) {
9866
9915
  const base = member.slice(0, -2);
9867
9916
  let entries;
9868
9917
  try {
9869
- entries = readdirSync11(join30(instanceRoot, base), { withFileTypes: true });
9918
+ entries = readdirSync11(join32(instanceRoot, base), { withFileTypes: true });
9870
9919
  } catch {
9871
9920
  continue;
9872
9921
  }
@@ -9880,15 +9929,15 @@ function workspaceMemberNames(instanceRoot) {
9880
9929
  }
9881
9930
  const names = /* @__PURE__ */ new Set();
9882
9931
  for (const dir of dirs) {
9883
- const pp = join30(instanceRoot, dir, "pyproject.toml");
9884
- if (!existsSync30(pp)) continue;
9932
+ const pp = join32(instanceRoot, dir, "pyproject.toml");
9933
+ if (!existsSync31(pp)) continue;
9885
9934
  const name = readProjectName(readFileSync21(pp, "utf8"));
9886
9935
  if (name) names.add(normaliseName(name));
9887
9936
  }
9888
9937
  return names;
9889
9938
  }
9890
9939
  function ensureWorkspaceSources(pluginPyprojectPath, memberNames) {
9891
- if (!existsSync30(pluginPyprojectPath) || memberNames.size === 0) return [];
9940
+ if (!existsSync31(pluginPyprojectPath) || memberNames.size === 0) return [];
9892
9941
  const text = readFileSync21(pluginPyprojectPath, "utf8");
9893
9942
  const doc = parsePyproject(text, pluginPyprojectPath);
9894
9943
  const members = new Set([...memberNames].map(normaliseName));
@@ -9944,8 +9993,8 @@ function parsePyproject(text, path) {
9944
9993
  }
9945
9994
  }
9946
9995
  function applyWorkspaceSources(targetDir, cwd, relTargetDir) {
9947
- const pluginPyproject = join30(targetDir, "pyproject.toml");
9948
- if (!existsSync30(pluginPyproject)) return [];
9996
+ const pluginPyproject = join32(targetDir, "pyproject.toml");
9997
+ if (!existsSync31(pluginPyproject)) return [];
9949
9998
  const sourced = ensureWorkspaceSources(pluginPyproject, workspaceMemberNames(cwd));
9950
9999
  if (sourced.length > 0) {
9951
10000
  log.info(
@@ -9959,14 +10008,14 @@ function applyWorkspaceSources(targetDir, cwd, relTargetDir) {
9959
10008
  import {
9960
10009
  chmodSync as chmodSync2,
9961
10010
  copyFileSync,
9962
- existsSync as existsSync31,
10011
+ existsSync as existsSync32,
9963
10012
  mkdirSync as mkdirSync9,
9964
10013
  readFileSync as readFileSync22,
9965
10014
  readdirSync as readdirSync12,
9966
10015
  statSync as statSync7,
9967
10016
  writeFileSync as writeFileSync10
9968
10017
  } from "fs";
9969
- import { dirname as dirname9, join as join31 } from "path";
10018
+ import { dirname as dirname9, join as join33 } from "path";
9970
10019
  var STANDALONE_ONLY_ENTRIES = {
9971
10020
  ".github": "standalone-repo CI/release workflows \u2014 the host monorepo already runs lint/type/test/security over services/",
9972
10021
  "registry-schema.json": "the plugin-registry publishing schema, used when submitting a *published* plugin to the registry repo, not by an in-tree plugin",
@@ -10020,10 +10069,10 @@ function applySubstitutions(text, names) {
10020
10069
  var BINARY_EXTENSIONS = /\.(png|jpe?g|gif|ico|woff2?|ttf|zip|gz)$/i;
10021
10070
  function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10022
10071
  const layout = options.layout ?? "in-tree";
10023
- if (!existsSync31(skeletonRoot)) {
10072
+ if (!existsSync32(skeletonRoot)) {
10024
10073
  throw new Error(`Plugin skeleton not found at ${skeletonRoot}`);
10025
10074
  }
10026
- if (!existsSync31(join31(skeletonRoot, "terraform"))) {
10075
+ if (!existsSync32(join33(skeletonRoot, "terraform"))) {
10027
10076
  throw new Error(
10028
10077
  `Plugin skeleton at ${skeletonRoot} has no terraform/ directory. Refusing to scaffold a plugin that cannot receive events (issue #194) \u2014 the skeleton is broken.`
10029
10078
  );
@@ -10031,7 +10080,7 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10031
10080
  const skipped = [];
10032
10081
  const files = [];
10033
10082
  const walk2 = (relDir) => {
10034
- const absDir = join31(skeletonRoot, relDir);
10083
+ const absDir = join33(skeletonRoot, relDir);
10035
10084
  for (const entry of readdirSync12(absDir, { withFileTypes: true }).sort(
10036
10085
  (a, b) => a.name.localeCompare(b.name)
10037
10086
  )) {
@@ -10046,9 +10095,9 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10046
10095
  continue;
10047
10096
  }
10048
10097
  const destRel = applySubstitutions(relPath, names);
10049
- const destPath = join31(destDir, destRel);
10098
+ const destPath = join33(destDir, destRel);
10050
10099
  mkdirSync9(dirname9(destPath), { recursive: true });
10051
- const srcPath = join31(skeletonRoot, relPath);
10100
+ const srcPath = join33(skeletonRoot, relPath);
10052
10101
  if (BINARY_EXTENSIONS.test(entry.name)) {
10053
10102
  copyFileSync(srcPath, destPath);
10054
10103
  } else {
@@ -10069,8 +10118,8 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10069
10118
  function findSkeletonRoot(startDir, skeleton) {
10070
10119
  let dir = startDir;
10071
10120
  for (; ; ) {
10072
- const candidate = join31(dir, "_skeletons", skeleton);
10073
- if (existsSync31(candidate)) return candidate;
10121
+ const candidate = join33(dir, "_skeletons", skeleton);
10122
+ if (existsSync32(candidate)) return candidate;
10074
10123
  const parent = dirname9(dir);
10075
10124
  if (parent === dir) return null;
10076
10125
  dir = parent;
@@ -10138,7 +10187,7 @@ async function runPluginCreate(name, options, deps) {
10138
10187
  reportBranchProtectionSummary();
10139
10188
  return;
10140
10189
  }
10141
- const isInstance = existsSync32(join32(options.cwd, INSTANCE_CORE_FILE));
10190
+ const isInstance = existsSync33(join34(options.cwd, INSTANCE_CORE_FILE));
10142
10191
  if (options.firstParty && isInstance) {
10143
10192
  throw new Error(
10144
10193
  `--first-party scaffolds into services/_plugins/, which is template-owned: \`biffo core upgrade\` three-way-merges it against the template on every upgrade, and the template has no '${names.slug}'. This checkout is a Biffo instance (${INSTANCE_CORE_FILE} is present), so your plugin belongs in the user-owned ${pluginDir(names.slug, "third-party")}/ \u2014 re-run without --first-party.`
@@ -10146,19 +10195,19 @@ async function runPluginCreate(name, options, deps) {
10146
10195
  }
10147
10196
  const channel = options.firstParty ? "first-party" : "third-party";
10148
10197
  const relDir = pluginDir(names.slug, channel);
10149
- const destDir = join32(options.cwd, relDir);
10150
- const servicesDir = join32(options.cwd, "services");
10151
- if (!existsSync32(servicesDir)) {
10198
+ const destDir = join34(options.cwd, relDir);
10199
+ const servicesDir = join34(options.cwd, "services");
10200
+ if (!existsSync33(servicesDir)) {
10152
10201
  throw new Error(
10153
10202
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
10154
10203
  );
10155
10204
  }
10156
- if (existsSync32(destDir)) {
10205
+ if (existsSync33(destDir)) {
10157
10206
  throw new Error(`${relDir}/ already exists. Choose a different name, or remove it first.`);
10158
10207
  }
10159
10208
  const here = dirname10(fileURLToPath6(import.meta.url));
10160
- const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join32(options.cwd, "_skeletons", "plugin-template");
10161
- if (!existsSync32(skeletonRoot)) {
10209
+ const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join34(options.cwd, "_skeletons", "plugin-template");
10210
+ if (!existsSync33(skeletonRoot)) {
10162
10211
  throw new Error(
10163
10212
  `Could not find the plugin skeleton (_skeletons/plugin-template/). Pass --skeleton <path> to point at it explicitly.`
10164
10213
  );
@@ -10173,7 +10222,7 @@ async function runPluginCreate(name, options, deps) {
10173
10222
  for (const { entry, reason } of skipped) {
10174
10223
  log.info(`Skipped ${entry} \u2014 ${reason}`);
10175
10224
  }
10176
- const manifestPath = join32(destDir, "biffo.plugin.json");
10225
+ const manifestPath = join34(destDir, "biffo.plugin.json");
10177
10226
  const manifest = validateManifest(JSON.parse(readFileSync23(manifestPath, "utf8")));
10178
10227
  if (manifest.name !== names.slug) {
10179
10228
  throw new Error(
@@ -10191,15 +10240,14 @@ async function runPluginCreate(name, options, deps) {
10191
10240
  );
10192
10241
  }
10193
10242
  const commitMessage = `feat(plugins): scaffold ${names.slug} plugin`;
10194
- await deps.git.add(options.cwd, [relDir]);
10195
- await deps.git.commit(options.cwd, commitMessage, [relDir]);
10243
+ await commitPluginChange(deps, options.cwd, [relDir], commitMessage);
10196
10244
  log.success(`Committed: ${commitMessage}`);
10197
10245
  }
10198
10246
  printNextSteps(names, relDir, channel);
10199
10247
  }
10200
10248
  async function runStandaloneCreate(names, options, deps) {
10201
- const destDir = join32(options.cwd, names.dist);
10202
- if (existsSync32(destDir)) {
10249
+ const destDir = join34(options.cwd, names.dist);
10250
+ if (existsSync33(destDir)) {
10203
10251
  throw new Error(`${names.dist}/ already exists. Choose a different name, or remove it first.`);
10204
10252
  }
10205
10253
  const skeletonRoot = resolveSkeletonRoot(options);
@@ -10217,7 +10265,7 @@ async function runStandaloneCreate(names, options, deps) {
10217
10265
  restorePackagedDotfiles(destDir);
10218
10266
  log.success(`Scaffolded ${String(files.length)} file(s) into ${names.dist}/`);
10219
10267
  const manifest = validateManifest(
10220
- JSON.parse(readFileSync23(join32(destDir, "biffo.plugin.json"), "utf8"))
10268
+ JSON.parse(readFileSync23(join34(destDir, "biffo.plugin.json"), "utf8"))
10221
10269
  );
10222
10270
  if (manifest.name !== names.slug) {
10223
10271
  throw new Error(
@@ -10228,12 +10276,12 @@ async function runStandaloneCreate(names, options, deps) {
10228
10276
  `Manifest valid \u2014 ${String(manifest.tables.length)} table(s), ${String(manifest.api_routes.length)} route(s)`
10229
10277
  );
10230
10278
  writeFileSync11(
10231
- join32(destDir, ".biffo-shared-version"),
10279
+ join34(destDir, ".biffo-shared-version"),
10232
10280
  `core-v${getLatestCoreVersion().replace(/^core-v/, "")}
10233
10281
  `
10234
10282
  );
10235
10283
  if (options.commit) {
10236
- if (!existsSync32(join32(destDir, "uv.lock"))) {
10284
+ if (!existsSync33(join34(destDir, "uv.lock"))) {
10237
10285
  throw new Error(
10238
10286
  `Scaffolded plugin at ${destDir} has no uv.lock. The standalone layout must carry a substituted uv.lock (see plugin-scaffold.ts STANDALONE_ONLY_ENTRIES) so the first commit's CI run can satisfy 'uv sync --locked'. Refusing to commit a repo that would ship red on its very first push (issue #1769) \u2014 run 'uv lock' in ${destDir} first.`
10239
10287
  );
@@ -10266,8 +10314,8 @@ async function createAndPushStandaloneRepo(org, names, destDir, options, deps) {
10266
10314
  await deps.git.push(destDir, "dev", { token });
10267
10315
  log.success(`Pushed dev to ${org}/${names.dist}`);
10268
10316
  await github.setDefaultBranch(org, names.dist, "dev");
10269
- const ciPath = join32(destDir, ".github", "workflows", "ci.yml");
10270
- const contexts = existsSync32(ciPath) ? workflowCheckContexts(readFileSync23(ciPath, "utf8")) : [];
10317
+ const ciPath = join34(destDir, ".github", "workflows", "ci.yml");
10318
+ const contexts = existsSync33(ciPath) ? workflowCheckContexts(readFileSync23(ciPath, "utf8")) : [];
10271
10319
  if (contexts.length === 0) {
10272
10320
  log.warn(
10273
10321
  `Could not determine required status checks from ${ciPath} \u2014 skipping branch protection. Configure it manually on dev once you know the CI job names.`
@@ -10296,7 +10344,7 @@ async function registerInRegistrySources(names, cloneUrl, token, deps) {
10296
10344
  let dir;
10297
10345
  try {
10298
10346
  dir = await deps.git.cloneForEditing(REGISTRY_REPO, "biffo-registry", token);
10299
- const path = join32(dir, "sources.json");
10347
+ const path = join34(dir, "sources.json");
10300
10348
  const file = JSON.parse(readFileSync23(path, "utf8"));
10301
10349
  const next = addSource(file, {
10302
10350
  name: names.slug,
@@ -10407,8 +10455,8 @@ function printStandaloneNextSteps(names, minor) {
10407
10455
  }
10408
10456
  function resolveSkeletonRoot(options) {
10409
10457
  const here = dirname10(fileURLToPath6(import.meta.url));
10410
- const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join32(options.cwd, "_skeletons", "plugin-template");
10411
- if (!existsSync32(skeletonRoot)) {
10458
+ const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join34(options.cwd, "_skeletons", "plugin-template");
10459
+ if (!existsSync33(skeletonRoot)) {
10412
10460
  throw new Error(
10413
10461
  `Could not find the plugin skeleton (_skeletons/plugin-template/). Pass --skeleton <path> to point at it explicitly.`
10414
10462
  );
@@ -10638,68 +10686,14 @@ function printScopeSeamEntitlement(name) {
10638
10686
  }
10639
10687
 
10640
10688
  // src/commands/plugin-install.ts
10641
- import { cpSync as cpSync5, existsSync as existsSync36, mkdirSync as mkdirSync12, readFileSync as readFileSync26, statSync as statSync8, writeFileSync as writeFileSync14 } from "fs";
10642
- import { join as join38, relative as relative4, resolve as resolve14 } from "path";
10689
+ import { cpSync as cpSync5, existsSync as existsSync37, mkdirSync as mkdirSync12, readFileSync as readFileSync26, statSync as statSync8, writeFileSync as writeFileSync14 } from "fs";
10690
+ import { join as join39, relative as relative4, resolve as resolve14 } from "path";
10643
10691
  import chalk15 from "chalk";
10644
10692
  import { Command as Command16 } from "commander";
10645
10693
 
10646
- // src/adapters/plugin-migrations/index.ts
10647
- import { join as join33 } from "path";
10648
- var PluginMigrationsAdapter = class {
10649
- /**
10650
- * Generates migration file(s) for `pluginNames` (every discovered
10651
- * installed plugin if omitted), returning the absolute path of each newly
10652
- * generated file — empty if every named plugin already had a migration,
10653
- * or declared no tables.
10654
- */
10655
- async generate(cwd, pluginNames) {
10656
- const scriptPath = join33(cwd, "services", "api", "scripts", "generate_plugin_migrations.py");
10657
- const args = [
10658
- "run",
10659
- "python",
10660
- scriptPath,
10661
- "--services-root",
10662
- join33(cwd, "services"),
10663
- "--versions-dir",
10664
- join33(cwd, "services", "api", "migrations", "versions")
10665
- ];
10666
- for (const name of pluginNames ?? []) {
10667
- args.push("--plugin", name);
10668
- }
10669
- const result = await runUv(args, join33(cwd, "services", "api"), {
10670
- missing: "biffo plugin install/upgrade/sync-migrations needs `uv` (Python) on PATH to generate a real migration file \u2014 see https://docs.astral.sh/uv/ to install it. Once installed, re-run this command (or `biffo plugin sync-migrations <name>` if services/<name>/ is already copied in).",
10671
- failed: "Failed to generate plugin migration"
10672
- });
10673
- return result.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
10674
- }
10675
- /**
10676
- * Brings the instance's root `uv.lock` in step with its workspace (`uv lock`).
10677
- *
10678
- * `plugin install` adds a member to the uv workspace, so the committed lock is stale the moment the plugin lands — whether or
10679
- * not the plugin has tables (only a table-bearing plugin runs `uv run` for a migration, which is a side effect that happens to
10680
- * re-lock). Locking explicitly, then staging the result, is what makes `uv lock --check` pass on the install commit
10681
- * (biffo-template#2106); leaving it to whichever `uv run` came last is how the no-tables install shipped a stale lock.
10682
- */
10683
- async refreshLock(cwd) {
10684
- await runUv(["lock"], cwd, {
10685
- missing: "biffo plugin install needs `uv` (Python) on PATH to refresh uv.lock for the workspace member it adds \u2014 see https://docs.astral.sh/uv/ to install it, then run `uv lock` and commit uv.lock yourself.",
10686
- failed: "Failed to refresh uv.lock (`uv lock`)"
10687
- });
10688
- }
10689
- };
10690
- async function runUv(args, cwd, messages) {
10691
- try {
10692
- return await execa("uv", args, { cwd });
10693
- } catch (err) {
10694
- const cause = err;
10695
- if (cause.code === "ENOENT") throw new Error(messages.missing);
10696
- throw new Error(`${messages.failed}: ${cause.stderr?.trim() || err.message}`);
10697
- }
10698
- }
10699
-
10700
10694
  // src/lib/plugin-frontend-registry.ts
10701
- import { existsSync as existsSync33, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
10702
- import { join as join34 } from "path";
10695
+ import { existsSync as existsSync34, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
10696
+ import { join as join35 } from "path";
10703
10697
  var PLUGIN_REGISTRY_RELATIVE_PATH = "apps/frontend/src/lib/plugins.ts";
10704
10698
  var REGISTRY_START_MARKER = "// BIFFO-PLUGIN-REGISTRY:START \u2014 managed by `biffo plugin install`/`uninstall`. Do not hand-edit.";
10705
10699
  var REGISTRY_END_MARKER = "// BIFFO-PLUGIN-REGISTRY:END";
@@ -10710,7 +10704,7 @@ function frontendUrlForSlug(slug) {
10710
10704
  return `/api/v1/plugins/${slug}/ui`;
10711
10705
  }
10712
10706
  function registryPath2(cwd) {
10713
- return join34(cwd, PLUGIN_REGISTRY_RELATIVE_PATH);
10707
+ return join35(cwd, PLUGIN_REGISTRY_RELATIVE_PATH);
10714
10708
  }
10715
10709
  function missingRegistryError(cwd, pluginSlug) {
10716
10710
  return new Error(
@@ -10787,7 +10781,7 @@ function assertPluginRegistryReady(cwd, pluginSlug) {
10787
10781
  }
10788
10782
  function readManagedEntries(cwd, pluginSlug) {
10789
10783
  const path = registryPath2(cwd);
10790
- if (!existsSync33(path)) throw missingRegistryError(cwd, pluginSlug);
10784
+ if (!existsSync34(path)) throw missingRegistryError(cwd, pluginSlug);
10791
10785
  const source = readFileSync24(path, "utf8");
10792
10786
  const found = findManagedRegion(source);
10793
10787
  if (!found) throw malformedRegistryError(cwd, pluginSlug);
@@ -10811,8 +10805,8 @@ function removePluginRegistryEntry(cwd, pluginSlug) {
10811
10805
  }
10812
10806
 
10813
10807
  // src/lib/plugin-provenance.ts
10814
- import { existsSync as existsSync34, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
10815
- import { join as join35 } from "path";
10808
+ import { existsSync as existsSync35, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
10809
+ import { join as join36 } from "path";
10816
10810
  var PLUGIN_PROVENANCE_FILENAME = ".biffo-plugin-provenance.json";
10817
10811
  function isPluginProvenance(value) {
10818
10812
  if (typeof value !== "object" || value === null) return false;
@@ -10820,8 +10814,8 @@ function isPluginProvenance(value) {
10820
10814
  return typeof v["origin"] === "string" && (typeof v["ref"] === "string" || v["ref"] === null) && (typeof v["sha"] === "string" || v["sha"] === null) && typeof v["recordedAt"] === "string" && typeof v["inTree"] === "boolean";
10821
10815
  }
10822
10816
  function readProvenance(pluginDir2) {
10823
- const path = join35(pluginDir2, PLUGIN_PROVENANCE_FILENAME);
10824
- if (!existsSync34(path)) return { status: "absent" };
10817
+ const path = join36(pluginDir2, PLUGIN_PROVENANCE_FILENAME);
10818
+ if (!existsSync35(path)) return { status: "absent" };
10825
10819
  let parsed;
10826
10820
  try {
10827
10821
  parsed = JSON.parse(readFileSync25(path, "utf8"));
@@ -10840,7 +10834,7 @@ function readProvenance(pluginDir2) {
10840
10834
  return { status: "present", record: parsed };
10841
10835
  }
10842
10836
  function writePluginProvenance(pluginDir2, record) {
10843
- writeFileSync13(join35(pluginDir2, PLUGIN_PROVENANCE_FILENAME), `${JSON.stringify(record, null, 2)}
10837
+ writeFileSync13(join36(pluginDir2, PLUGIN_PROVENANCE_FILENAME), `${JSON.stringify(record, null, 2)}
10844
10838
  `);
10845
10839
  }
10846
10840
  function reconcileProvenance(previous, next) {
@@ -10890,8 +10884,8 @@ async function tryGit(cwd, args) {
10890
10884
  }
10891
10885
 
10892
10886
  // src/lib/plugin-seed-vendor.ts
10893
- import { cpSync as cpSync3, existsSync as existsSync35, mkdirSync as mkdirSync10, readdirSync as readdirSync13, rmSync as rmSync9 } from "fs";
10894
- import { join as join36 } from "path";
10887
+ import { cpSync as cpSync3, existsSync as existsSync36, mkdirSync as mkdirSync10, readdirSync as readdirSync13, rmSync as rmSync9 } from "fs";
10888
+ import { join as join37 } from "path";
10895
10889
  var VENDOR_PREFIX = "_plugin-";
10896
10890
  function pluginSeedImportDir(pluginName) {
10897
10891
  return `db/imports/${VENDOR_PREFIX}${pluginName}`;
@@ -10900,8 +10894,8 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10900
10894
  if (!manifest.seed) {
10901
10895
  return { vendored: false };
10902
10896
  }
10903
- const sourceSeedDir = join36(pluginSourceDir, manifest.seed.dir);
10904
- if (!existsSync35(sourceSeedDir)) {
10897
+ const sourceSeedDir = join37(pluginSourceDir, manifest.seed.dir);
10898
+ if (!existsSync36(sourceSeedDir)) {
10905
10899
  throw new Error(
10906
10900
  `${manifest.name}'s manifest declares seed.dir '${manifest.seed.dir}', but ${sourceSeedDir} does not exist in the plugin's source.`
10907
10901
  );
@@ -10913,11 +10907,11 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10913
10907
  );
10914
10908
  }
10915
10909
  const relTargetDir = pluginSeedImportDir(manifest.name);
10916
- const targetDir = join36(cwd, relTargetDir);
10910
+ const targetDir = join37(cwd, relTargetDir);
10917
10911
  rmSync9(targetDir, { recursive: true, force: true });
10918
10912
  mkdirSync10(targetDir, { recursive: true });
10919
10913
  for (const file of sqlFiles) {
10920
- cpSync3(join36(sourceSeedDir, file), join36(targetDir, file));
10914
+ cpSync3(join37(sourceSeedDir, file), join37(targetDir, file));
10921
10915
  }
10922
10916
  log.success(
10923
10917
  `Vendored ${sqlFiles.length} seed file(s) to ${relTargetDir}/ (baseline_tables: ${manifest.seed.baseline_tables.join(", ") || "none declared"})`
@@ -10930,7 +10924,7 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10930
10924
 
10931
10925
  // src/lib/plugin-source-copy.ts
10932
10926
  import { copyFileSync as copyFileSync2, cpSync as cpSync4, mkdirSync as mkdirSync11 } from "fs";
10933
- import { basename as basename2, dirname as dirname11, join as join37 } from "path";
10927
+ import { basename as basename2, dirname as dirname11, join as join38 } from "path";
10934
10928
  var LOCAL_COPY_EXCLUDES = /* @__PURE__ */ new Set([
10935
10929
  ".git",
10936
10930
  ".venv",
@@ -10946,9 +10940,9 @@ async function copyPluginSource(sourceDir, targetDir) {
10946
10940
  if (await isGitWorkingTree2(sourceDir)) {
10947
10941
  const files = await listGitFiles(sourceDir);
10948
10942
  for (const relPath of files) {
10949
- const destPath = join37(targetDir, relPath);
10943
+ const destPath = join38(targetDir, relPath);
10950
10944
  mkdirSync11(dirname11(destPath), { recursive: true });
10951
- copyFileSync2(join37(sourceDir, relPath), destPath);
10945
+ copyFileSync2(join38(sourceDir, relPath), destPath);
10952
10946
  }
10953
10947
  return { usedGitIgnoreRules: true };
10954
10948
  }
@@ -11020,14 +11014,14 @@ var pluginInstallCommand = new Command16("install").description(
11020
11014
  }
11021
11015
  );
11022
11016
  function resolveLocalPlugin(localPath) {
11023
- if (!existsSync36(localPath)) {
11017
+ if (!existsSync37(localPath)) {
11024
11018
  throw new Error(`--local path does not exist: ${localPath}`);
11025
11019
  }
11026
11020
  if (!statSync8(localPath).isDirectory()) {
11027
11021
  throw new Error(`--local path is not a directory: ${localPath}`);
11028
11022
  }
11029
- const manifestPath = join38(localPath, "biffo.plugin.json");
11030
- if (!existsSync36(manifestPath)) {
11023
+ const manifestPath = join39(localPath, "biffo.plugin.json");
11024
+ if (!existsSync37(manifestPath)) {
11031
11025
  throw new Error(
11032
11026
  `${localPath} does not contain a biffo.plugin.json manifest at its root \u2014 is it a plugin directory? (Scaffold one with \`biffo plugin create <name>\`.)`
11033
11027
  );
@@ -11053,8 +11047,8 @@ function parsePluginTarget(target) {
11053
11047
  async function cloneAndValidatePlugin(entry, git) {
11054
11048
  const tmpDir = await git.cloneToTemp(entry.repo, `biffo-plugin-${entry.name}`);
11055
11049
  try {
11056
- const manifestPath = join38(tmpDir, "biffo.plugin.json");
11057
- if (!existsSync36(manifestPath)) {
11050
+ const manifestPath = join39(tmpDir, "biffo.plugin.json");
11051
+ if (!existsSync37(manifestPath)) {
11058
11052
  throw new Error(
11059
11053
  `Plugin repo ${entry.repo} does not contain a biffo.plugin.json manifest at its root.`
11060
11054
  );
@@ -11082,8 +11076,8 @@ async function runPluginInstall(target, options, deps) {
11082
11076
  `Nothing to install. Pass a registry target (e.g. \`biffo plugin install acme-crm@1.0\`) or a local plugin directory (\`biffo plugin install --local services/acme-crm\`).`
11083
11077
  );
11084
11078
  }
11085
- const servicesDir = join38(options.cwd, "services");
11086
- if (!existsSync36(servicesDir)) {
11079
+ const servicesDir = join39(options.cwd, "services");
11080
+ if (!existsSync37(servicesDir)) {
11087
11081
  throw new Error(
11088
11082
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11089
11083
  );
@@ -11101,11 +11095,11 @@ async function runPluginInstall(target, options, deps) {
11101
11095
  }
11102
11096
  const pluginName = entry ? entry.name : source.name;
11103
11097
  const relTargetDir = pluginDir(pluginName, "third-party");
11104
- const targetDir = join38(options.cwd, relTargetDir);
11105
- const modulesDir = join38(options.cwd, "modules", "plugins", pluginName);
11098
+ const targetDir = join39(options.cwd, relTargetDir);
11099
+ const modulesDir = join39(options.cwd, "modules", "plugins", pluginName);
11106
11100
  const registryCwd = options.frontendCwd ?? options.cwd;
11107
11101
  const inTreeSource = options.local !== void 0 && resolve14(options.local) === resolve14(targetDir);
11108
- if (existsSync36(targetDir) && !inTreeSource) {
11102
+ if (existsSync37(targetDir) && !inTreeSource) {
11109
11103
  throw new Error(
11110
11104
  `Plugin '${pluginName}' is already installed at ${relTargetDir}/. Remove it first, or wait for a future 'biffo plugin upgrade' command.`
11111
11105
  );
@@ -11145,7 +11139,7 @@ async function runPluginInstall(target, options, deps) {
11145
11139
  log.success(
11146
11140
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
11147
11141
  );
11148
- const retiredShapeReasons = findRetiredFrontendShape(join38(source.sourceDir, "terraform"));
11142
+ const retiredShapeReasons = findRetiredFrontendShape(join39(source.sourceDir, "terraform"));
11149
11143
  if (retiredShapeReasons.length > 0) {
11150
11144
  throw new Error(retiredFrontendShapeError(pluginName, retiredShapeReasons));
11151
11145
  }
@@ -11182,13 +11176,13 @@ async function runPluginInstall(target, options, deps) {
11182
11176
  writePluginProvenance(targetDir, reconcileProvenance(previousProvenance, nextProvenance));
11183
11177
  const sourced = applyWorkspaceSources(targetDir, options.cwd, relTargetDir);
11184
11178
  if (inTreeSource && sourced.length > 0) left.core.written.push(`${relTargetDir}/pyproject.toml`);
11185
- const stagePaths = [relTargetDir];
11179
+ let stagePaths = [relTargetDir];
11186
11180
  const track = (...paths) => {
11187
11181
  stagePaths.push(...paths);
11188
11182
  left.core.written.push(...paths);
11189
11183
  };
11190
- const tfSourceDir = join38(targetDir, "terraform");
11191
- if (existsSync36(tfSourceDir)) {
11184
+ const tfSourceDir = join39(targetDir, "terraform");
11185
+ if (existsSync37(tfSourceDir)) {
11192
11186
  mkdirSync12(modulesDir, { recursive: true });
11193
11187
  cpSync5(tfSourceDir, modulesDir, { recursive: true });
11194
11188
  track(`modules/plugins/${pluginName}`);
@@ -11236,7 +11230,7 @@ async function runPluginInstall(target, options, deps) {
11236
11230
  track(seedResult.stagedPath);
11237
11231
  }
11238
11232
  if (manifest.config.length > 0) {
11239
- const configFilePath = join38(targetDir, "biffo.plugin-config.json");
11233
+ const configFilePath = join39(targetDir, "biffo.plugin-config.json");
11240
11234
  writeFileSync14(
11241
11235
  configFilePath,
11242
11236
  JSON.stringify(
@@ -11260,10 +11254,7 @@ async function runPluginInstall(target, options, deps) {
11260
11254
  `Recorded ${configSupply.resolved.length}/${manifest.config.length} declared config value(s) at ${relative4(options.cwd, configFilePath)}`
11261
11255
  );
11262
11256
  }
11263
- if (existsSync36(join38(options.cwd, "uv.lock"))) {
11264
- await deps.migrations.refreshLock(options.cwd);
11265
- stagePaths.push("uv.lock");
11266
- }
11257
+ stagePaths = await withRefreshedLock(deps, options.cwd, stagePaths);
11267
11258
  if (manifest.user_frontend) {
11268
11259
  upsertPluginRegistryEntry(registryCwd, {
11269
11260
  slug: pluginName,
@@ -11435,8 +11426,8 @@ function printDryRun4(entry, source, relTargetDir, inTreeSource, suppliedConfig
11435
11426
  }
11436
11427
 
11437
11428
  // src/commands/plugin-list.ts
11438
- import { existsSync as existsSync37, readFileSync as readFileSync27 } from "fs";
11439
- import { join as join39, resolve as resolve15 } from "path";
11429
+ import { existsSync as existsSync38, readFileSync as readFileSync27 } from "fs";
11430
+ import { join as join40, resolve as resolve15 } from "path";
11440
11431
  import chalk16 from "chalk";
11441
11432
  import { Command as Command17 } from "commander";
11442
11433
  var pluginListCommand = new Command17("list").description("List plugins installed in this project checkout").option("--cwd <path>", "Project root to scan (defaults to the current directory)").action(async (options) => {
@@ -11449,8 +11440,8 @@ var pluginListCommand = new Command17("list").description("List plugins installe
11449
11440
  }
11450
11441
  });
11451
11442
  async function runPluginList(options) {
11452
- const servicesDir = join39(options.cwd, "services");
11453
- if (!existsSync37(servicesDir)) {
11443
+ const servicesDir = join40(options.cwd, "services");
11444
+ if (!existsSync38(servicesDir)) {
11454
11445
  throw new Error(
11455
11446
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11456
11447
  );
@@ -11499,14 +11490,14 @@ import { resolve as resolve16 } from "path";
11499
11490
  import { Command as Command18 } from "commander";
11500
11491
 
11501
11492
  // src/lib/plugin-staleness.ts
11502
- import { existsSync as existsSync38, readFileSync as readFileSync28, readdirSync as readdirSync14, statSync as statSync9 } from "fs";
11503
- import { join as join40, relative as relative5 } from "path";
11493
+ import { existsSync as existsSync39, readFileSync as readFileSync28, readdirSync as readdirSync14, statSync as statSync9 } from "fs";
11494
+ import { join as join41, relative as relative5 } from "path";
11504
11495
  function discoverVendoredPlugins(servicesDir) {
11505
- if (!existsSync38(servicesDir)) return [];
11506
- return readdirSync14(servicesDir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith("_") && e.name !== "api").map((e) => e.name).filter((name) => existsSync38(join40(servicesDir, name, "biffo.plugin.json"))).sort();
11496
+ if (!existsSync39(servicesDir)) return [];
11497
+ return readdirSync14(servicesDir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith("_") && e.name !== "api").map((e) => e.name).filter((name) => existsSync39(join41(servicesDir, name, "biffo.plugin.json"))).sort();
11507
11498
  }
11508
11499
  async function checkPluginStaleness(cwd, deps) {
11509
- const servicesDir = join40(cwd, "services");
11500
+ const servicesDir = join41(cwd, "services");
11510
11501
  const names = discoverVendoredPlugins(servicesDir);
11511
11502
  let registryRepoByName = null;
11512
11503
  let registryFetchFailure = null;
@@ -11527,7 +11518,7 @@ async function checkPluginStaleness(cwd, deps) {
11527
11518
  };
11528
11519
  const results = [];
11529
11520
  for (const name of names) {
11530
- results.push(await checkOnePlugin(join40(servicesDir, name), name, resolveRegistryRepo, deps.git));
11521
+ results.push(await checkOnePlugin(join41(servicesDir, name), name, resolveRegistryRepo, deps.git));
11531
11522
  }
11532
11523
  return results;
11533
11524
  }
@@ -11553,7 +11544,7 @@ async function checkOnePlugin(pluginDir2, name, resolveRegistryRepo, git) {
11553
11544
  if (record?.sha && isFetchableUrl(record.origin)) {
11554
11545
  return checkViaProvenance(name, record, record.origin, git);
11555
11546
  }
11556
- const localOrigin = record && !isFetchableUrl(record.origin) && existsSync38(record.origin) ? record.origin : null;
11547
+ const localOrigin = record && !isFetchableUrl(record.origin) && existsSync39(record.origin) ? record.origin : null;
11557
11548
  if (localOrigin) {
11558
11549
  return checkViaContentDiff(name, pluginDir2, localOrigin, { isLocalDir: true }, git);
11559
11550
  }
@@ -11705,8 +11696,8 @@ async function countDifferingFiles(sourceDir, pluginDir2) {
11705
11696
  differing++;
11706
11697
  continue;
11707
11698
  }
11708
- const a = readFileSync28(join40(sourceDir, relPath));
11709
- const b = readFileSync28(join40(pluginDir2, relPath));
11699
+ const a = readFileSync28(join41(sourceDir, relPath));
11700
+ const b = readFileSync28(join41(pluginDir2, relPath));
11710
11701
  if (!a.equals(b)) differing++;
11711
11702
  }
11712
11703
  return differing;
@@ -11721,11 +11712,11 @@ function vendorFileList(dir) {
11721
11712
  return new Set(walkExcluding(dir, dir, LOCAL_COPY_EXCLUDES));
11722
11713
  }
11723
11714
  function walkExcluding(root, dir, excludes) {
11724
- if (!existsSync38(dir)) return [];
11715
+ if (!existsSync39(dir)) return [];
11725
11716
  const out = [];
11726
11717
  for (const entry of readdirSync14(dir)) {
11727
11718
  if (excludes.has(entry) || entry === ".git") continue;
11728
- const full = join40(dir, entry);
11719
+ const full = join41(dir, entry);
11729
11720
  let stat;
11730
11721
  try {
11731
11722
  stat = statSync9(full);
@@ -11782,8 +11773,8 @@ var pluginStalenessCommand = new Command18("staleness").description(
11782
11773
  });
11783
11774
 
11784
11775
  // src/commands/plugin-sync-migrations.ts
11785
- import { existsSync as existsSync39 } from "fs";
11786
- import { join as join41, relative as relative6, resolve as resolve17 } from "path";
11776
+ import { existsSync as existsSync40 } from "fs";
11777
+ import { join as join42, relative as relative6, resolve as resolve17 } from "path";
11787
11778
  import chalk17 from "chalk";
11788
11779
  import { Command as Command19 } from "commander";
11789
11780
  var pluginSyncMigrationsCommand = new Command19("sync-migrations").description(
@@ -11804,11 +11795,11 @@ var pluginSyncMigrationsCommand = new Command19("sync-migrations").description(
11804
11795
  }
11805
11796
  );
11806
11797
  async function runPluginSyncMigrations(name, options, deps) {
11807
- const servicesDir = join41(options.cwd, "services");
11808
- if (!existsSync39(servicesDir)) {
11798
+ const servicesDir = join42(options.cwd, "services");
11799
+ if (!existsSync40(servicesDir)) {
11809
11800
  throw new Error(`${servicesDir} does not exist \u2014 is ${options.cwd} a Biffo project checkout?`);
11810
11801
  }
11811
- if (name && !existsSync39(join41(servicesDir, name, "biffo.plugin.json"))) {
11802
+ if (name && !existsSync40(join42(servicesDir, name, "biffo.plugin.json"))) {
11812
11803
  throw new Error(`Plugin '${name}' is not installed at services/${name}/.`);
11813
11804
  }
11814
11805
  if (options.dryRun) {
@@ -11833,10 +11824,9 @@ async function runPluginSyncMigrations(name, options, deps) {
11833
11824
  if (!isRepo) {
11834
11825
  throw new Error(`${options.cwd} is not a git repository \u2014 cannot commit.`);
11835
11826
  }
11836
- await deps.git.add(options.cwd, relativePaths);
11837
11827
  const label = name ?? `${String(generated.length)} plugin(s)`;
11838
11828
  const commitMessage = `chore(plugins): sync migration(s) for ${label}`;
11839
- await deps.git.commit(options.cwd, commitMessage, relativePaths);
11829
+ await commitPluginChange(deps, options.cwd, relativePaths, commitMessage);
11840
11830
  log.success(`Committed: ${commitMessage}`);
11841
11831
  } else {
11842
11832
  log.warn("--no-commit: generated file(s) are on disk but not staged/committed.");
@@ -11844,8 +11834,8 @@ async function runPluginSyncMigrations(name, options, deps) {
11844
11834
  }
11845
11835
 
11846
11836
  // src/commands/plugin-uninstall.ts
11847
- import { existsSync as existsSync40, readFileSync as readFileSync29, rmSync as rmSync10 } from "fs";
11848
- import { join as join42, resolve as resolve18 } from "path";
11837
+ import { existsSync as existsSync41, readFileSync as readFileSync29, rmSync as rmSync10 } from "fs";
11838
+ import { join as join43, resolve as resolve18 } from "path";
11849
11839
  import chalk18 from "chalk";
11850
11840
  import { Command as Command20 } from "commander";
11851
11841
  import inquirer6 from "inquirer";
@@ -11877,16 +11867,16 @@ async function runPluginUninstall(name, options, deps) {
11877
11867
  if (!NAME_PATTERN2.test(name)) {
11878
11868
  throw new Error(`Invalid plugin name '${name}'. Expected a lowercase kebab-case slug.`);
11879
11869
  }
11880
- const servicesDir = join42(options.cwd, "services");
11881
- if (!existsSync40(servicesDir)) {
11870
+ const servicesDir = join43(options.cwd, "services");
11871
+ if (!existsSync41(servicesDir)) {
11882
11872
  throw new Error(
11883
11873
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11884
11874
  );
11885
11875
  }
11886
- const targetDir = join42(servicesDir, name);
11887
- if (!existsSync40(targetDir)) {
11888
- const firstParty = join42(servicesDir, FIRST_PARTY_PLUGINS_DIR, name);
11889
- if (existsSync40(firstParty)) {
11876
+ const targetDir = join43(servicesDir, name);
11877
+ if (!existsSync41(targetDir)) {
11878
+ const firstParty = join43(servicesDir, FIRST_PARTY_PLUGINS_DIR, name);
11879
+ if (existsSync41(firstParty)) {
11890
11880
  throw new Error(
11891
11881
  `Plugin '${name}' is a first-party plugin at ${pluginDir(name, "first-party")}/, which is template-owned \u2014 \`biffo core upgrade\` would restore it on the next upgrade. Disable it instead by removing '${name}' from \`enabled_plugins\` in infra/environments/<env>/main.tf and re-applying.`
11892
11882
  );
@@ -11895,9 +11885,9 @@ async function runPluginUninstall(name, options, deps) {
11895
11885
  }
11896
11886
  const installedManifest = readInstalledManifest(targetDir);
11897
11887
  const version = installedManifest?.version;
11898
- const modulesDir = join42(options.cwd, "modules", "plugins", name);
11888
+ const modulesDir = join43(options.cwd, "modules", "plugins", name);
11899
11889
  const stagePaths = [`services/${name}`];
11900
- if (existsSync40(modulesDir)) {
11890
+ if (existsSync41(modulesDir)) {
11901
11891
  stagePaths.push(`modules/plugins/${name}`);
11902
11892
  }
11903
11893
  const hasUserFrontend = installedManifest?.user_frontend !== void 0;
@@ -11924,7 +11914,7 @@ async function runPluginUninstall(name, options, deps) {
11924
11914
  if (hasUserFrontend) {
11925
11915
  assertPluginRegistryReady(options.cwd, name);
11926
11916
  }
11927
- if (existsSync40(modulesDir)) {
11917
+ if (existsSync41(modulesDir)) {
11928
11918
  const refs = findPluginModuleReferences(options.cwd, name).filter(
11929
11919
  (r) => !r.file.endsWith(`/${GENERATED_TF_FILE}`) && r.file !== GENERATED_TF_FILE
11930
11920
  );
@@ -11939,7 +11929,7 @@ Remove the reference(s) above first, then re-run uninstall.`
11939
11929
  }
11940
11930
  rmSync10(targetDir, { recursive: true, force: true });
11941
11931
  log.success(`Removed services/${name}/`);
11942
- if (existsSync40(modulesDir)) {
11932
+ if (existsSync41(modulesDir)) {
11943
11933
  rmSync10(modulesDir, { recursive: true, force: true });
11944
11934
  log.success(`Removed modules/plugins/${name}/`);
11945
11935
  const wiring = syncPluginTerraform(options.cwd);
@@ -11956,8 +11946,7 @@ Remove the reference(s) above first, then re-run uninstall.`
11956
11946
  }
11957
11947
  const label = version ? `${name}@${version}` : name;
11958
11948
  const commitMessage = `chore(plugins): uninstall ${label}`;
11959
- await deps.git.add(options.cwd, stagePaths);
11960
- await deps.git.commit(options.cwd, commitMessage, stagePaths);
11949
+ await commitPluginChange(deps, options.cwd, stagePaths, commitMessage);
11961
11950
  log.success(`Committed: ${commitMessage}`);
11962
11951
  console.log(chalk18.bold("\n Plugin uninstalled!\n"));
11963
11952
  console.log(` services/${name}/ has been removed and committed.`);
@@ -11978,15 +11967,15 @@ Remove the reference(s) above first, then re-run uninstall.`
11978
11967
  "Any tables this plugin created remain in the database, and its migration file at services/api/migrations/versions/ is NOT removed (it is a permanent historical record \u2014 see notes). Dropping tables, if desired, requires a manual Alembic migration written against the Core API."
11979
11968
  );
11980
11969
  }
11981
- if (existsSync40(join42(options.cwd, pluginSeedImportDir(name)))) {
11970
+ if (existsSync41(join43(options.cwd, pluginSeedImportDir(name)))) {
11982
11971
  log.warn(
11983
11972
  `${pluginSeedImportDir(name)}/ (this plugin's vendored baseline-row seed, biffo-template#1554) was NOT removed either, for the same reason \u2014 see notes. Delete it by hand if you are certain the rows it applied should go too, but note nothing drops rows already applied to the database; that still needs a manual migration.`
11984
11973
  );
11985
11974
  }
11986
11975
  }
11987
11976
  function readInstalledManifest(targetDir) {
11988
- const manifestPath = join42(targetDir, "biffo.plugin.json");
11989
- if (!existsSync40(manifestPath)) return void 0;
11977
+ const manifestPath = join43(targetDir, "biffo.plugin.json");
11978
+ if (!existsSync41(manifestPath)) return void 0;
11990
11979
  try {
11991
11980
  return validateManifest(JSON.parse(readFileSync29(manifestPath, "utf8")));
11992
11981
  } catch {
@@ -12021,11 +12010,12 @@ function printDryRun5(name, version, stagePaths, keepData) {
12021
12010
  }
12022
12011
 
12023
12012
  // src/commands/plugin-upgrade.ts
12024
- import { cpSync as cpSync6, existsSync as existsSync41, mkdirSync as mkdirSync13, readFileSync as readFileSync30, rmSync as rmSync11 } from "fs";
12025
- import { join as join43, relative as relative7, resolve as resolve19 } from "path";
12013
+ import { cpSync as cpSync6, existsSync as existsSync42, mkdirSync as mkdirSync13, readFileSync as readFileSync30, rmSync as rmSync11 } from "fs";
12014
+ import { join as join44, relative as relative7, resolve as resolve19 } from "path";
12026
12015
  import chalk19 from "chalk";
12027
12016
  import { Command as Command21 } from "commander";
12028
12017
  import inquirer7 from "inquirer";
12018
+ import { parse as parseToml2 } from "smol-toml";
12029
12019
  var pluginUpgradeCommand = new Command21("upgrade").description(
12030
12020
  "Upgrade an installed plugin to a new minor version (biffo plugin upgrade <name>@<new-minor>) or refresh it in place from a local, unpublished checkout (biffo plugin upgrade --local <path>)"
12031
12021
  ).argument(
@@ -12069,8 +12059,8 @@ async function runPluginUpgrade(target, options, deps) {
12069
12059
  `Nothing to upgrade. Pass a registry target (e.g. \`biffo plugin upgrade acme-crm@1.1\`) or a local checkout to refresh from (\`biffo plugin upgrade --local ../acme-crm\`).`
12070
12060
  );
12071
12061
  }
12072
- const servicesDir = join43(options.cwd, "services");
12073
- if (!existsSync41(servicesDir)) {
12062
+ const servicesDir = join44(options.cwd, "services");
12063
+ if (!existsSync42(servicesDir)) {
12074
12064
  throw new Error(
12075
12065
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
12076
12066
  );
@@ -12079,8 +12069,8 @@ async function runPluginUpgrade(target, options, deps) {
12079
12069
  return runLocalPluginRefresh(options.local, options, deps);
12080
12070
  }
12081
12071
  const { name, minor } = parsePluginTarget(target);
12082
- const targetDir = join43(servicesDir, name);
12083
- if (!existsSync41(targetDir)) {
12072
+ const targetDir = join44(servicesDir, name);
12073
+ if (!existsSync42(targetDir)) {
12084
12074
  throw new Error(
12085
12075
  `Plugin '${name}' is not installed at services/${name}/. Use 'biffo plugin install ${name}@${minor}' instead.`
12086
12076
  );
@@ -12094,7 +12084,7 @@ async function runPluginUpgrade(target, options, deps) {
12094
12084
  `Plugin declares required_core_version '${entry.required_core_version}'. The CLI cannot verify this against your deployment \u2014 the Core API exposes no version endpoint and services/api/pyproject.toml's version is a static placeholder, not a real release marker. Confirm compatibility yourself before deploying.`
12095
12085
  );
12096
12086
  }
12097
- const modulesDir = join43(options.cwd, "modules", "plugins", entry.name);
12087
+ const modulesDir = join44(options.cwd, "modules", "plugins", entry.name);
12098
12088
  if (options.dryRun) {
12099
12089
  printDryRun6(entry, currentVersion);
12100
12090
  return;
@@ -12122,11 +12112,11 @@ async function runPluginUpgrade(target, options, deps) {
12122
12112
  log.success(
12123
12113
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
12124
12114
  );
12125
- const retiredShapeReasons = findRetiredFrontendShape(join43(tmpDir, "terraform"));
12115
+ const retiredShapeReasons = findRetiredFrontendShape(join44(tmpDir, "terraform"));
12126
12116
  if (retiredShapeReasons.length > 0) {
12127
12117
  throw new Error(retiredFrontendShapeError(entry.name, retiredShapeReasons));
12128
12118
  }
12129
- if (!existsSync41(join43(tmpDir, "terraform"))) {
12119
+ if (!existsSync42(join44(tmpDir, "terraform"))) {
12130
12120
  refuseIfModuleStillReferenced(options.cwd, modulesDir, entry.name);
12131
12121
  }
12132
12122
  const previousProvenance = readProvenance(targetDir);
@@ -12143,11 +12133,11 @@ async function runPluginUpgrade(target, options, deps) {
12143
12133
  applyWorkspaceSources(targetDir, options.cwd, `services/${entry.name}`);
12144
12134
  const newPyproject = readPyprojectIfPresent(targetDir);
12145
12135
  const stagePaths = [`services/${entry.name}`];
12146
- if (existsSync41(modulesDir)) {
12136
+ if (existsSync42(modulesDir)) {
12147
12137
  rmSync11(modulesDir, { recursive: true, force: true });
12148
12138
  }
12149
- const tfSourceDir = join43(targetDir, "terraform");
12150
- if (existsSync41(tfSourceDir)) {
12139
+ const tfSourceDir = join44(targetDir, "terraform");
12140
+ if (existsSync42(tfSourceDir)) {
12151
12141
  mkdirSync13(modulesDir, { recursive: true });
12152
12142
  cpSync6(tfSourceDir, modulesDir, { recursive: true });
12153
12143
  stagePaths.push(`modules/plugins/${entry.name}`);
@@ -12208,16 +12198,16 @@ async function runPluginUpgrade(target, options, deps) {
12208
12198
  async function runLocalPluginRefresh(localPath, options, deps) {
12209
12199
  const source = resolveLocalPlugin(localPath);
12210
12200
  log.success(`Resolved ${source.name}@${source.version} from ${source.origin}`);
12211
- const servicesDir = join43(options.cwd, "services");
12212
- const targetDir = join43(servicesDir, source.name);
12213
- if (!existsSync41(targetDir)) {
12201
+ const servicesDir = join44(options.cwd, "services");
12202
+ const targetDir = join44(servicesDir, source.name);
12203
+ if (!existsSync42(targetDir)) {
12214
12204
  throw new Error(
12215
12205
  `Plugin '${source.name}' is not installed at services/${source.name}/. Use 'biffo plugin install --local ${localPath}' instead.`
12216
12206
  );
12217
12207
  }
12218
12208
  const inTreeSource = resolve19(source.sourceDir) === resolve19(targetDir);
12219
12209
  const currentVersion = readInstalledVersion(targetDir);
12220
- const modulesDir = join43(options.cwd, "modules", "plugins", source.name);
12210
+ const modulesDir = join44(options.cwd, "modules", "plugins", source.name);
12221
12211
  if (options.dryRun) {
12222
12212
  printLocalDryRun(source, currentVersion, inTreeSource);
12223
12213
  return;
@@ -12240,11 +12230,11 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12240
12230
  log.success(
12241
12231
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
12242
12232
  );
12243
- const retiredShapeReasons = findRetiredFrontendShape(join43(source.sourceDir, "terraform"));
12233
+ const retiredShapeReasons = findRetiredFrontendShape(join44(source.sourceDir, "terraform"));
12244
12234
  if (retiredShapeReasons.length > 0) {
12245
12235
  throw new Error(retiredFrontendShapeError(source.name, retiredShapeReasons));
12246
12236
  }
12247
- if (!existsSync41(join43(source.sourceDir, "terraform"))) {
12237
+ if (!existsSync42(join44(source.sourceDir, "terraform"))) {
12248
12238
  refuseIfModuleStillReferenced(options.cwd, modulesDir, source.name);
12249
12239
  }
12250
12240
  const previousProvenance = readProvenance(targetDir);
@@ -12264,11 +12254,11 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12264
12254
  applyWorkspaceSources(targetDir, options.cwd, `services/${source.name}`);
12265
12255
  const newPyproject = readPyprojectIfPresent(targetDir);
12266
12256
  const stagePaths = [`services/${source.name}`];
12267
- if (existsSync41(modulesDir)) {
12257
+ if (existsSync42(modulesDir)) {
12268
12258
  rmSync11(modulesDir, { recursive: true, force: true });
12269
12259
  }
12270
- const tfSourceDir = join43(targetDir, "terraform");
12271
- if (existsSync41(tfSourceDir)) {
12260
+ const tfSourceDir = join44(targetDir, "terraform");
12261
+ if (existsSync42(tfSourceDir)) {
12272
12262
  mkdirSync13(modulesDir, { recursive: true });
12273
12263
  cpSync6(tfSourceDir, modulesDir, { recursive: true });
12274
12264
  stagePaths.push(`modules/plugins/${source.name}`);
@@ -12332,7 +12322,7 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12332
12322
  }
12333
12323
  }
12334
12324
  function refuseIfModuleStillReferenced(cwd, modulesDir, name) {
12335
- if (!existsSync41(modulesDir)) return;
12325
+ if (!existsSync42(modulesDir)) return;
12336
12326
  const refs = findPluginModuleReferences(cwd, name);
12337
12327
  if (refs.length === 0) return;
12338
12328
  const refList = refs.map((r) => ` ${r.file}:${r.line} ${r.text}`).join("\n");
@@ -12393,37 +12383,26 @@ var defaultRunCommand2 = async (command, cwd) => {
12393
12383
  }
12394
12384
  };
12395
12385
  function readPyprojectIfPresent(targetDir) {
12396
- const path = join43(targetDir, "pyproject.toml");
12397
- return existsSync41(path) ? readFileSync30(path, "utf8") : null;
12386
+ const path = join44(targetDir, "pyproject.toml");
12387
+ return existsSync42(path) ? readFileSync30(path, "utf8") : null;
12398
12388
  }
12399
12389
  function dependenciesChanged(before, after) {
12400
12390
  if (before === after) return false;
12401
- const beforeItems = before ? dependencySurface(before) : [];
12402
- const afterItems = after ? dependencySurface(after) : [];
12391
+ const beforeItems = before === null ? [] : dependencySurface(before);
12392
+ const afterItems = after === null ? [] : dependencySurface(after);
12393
+ if (beforeItems === null || afterItems === null) return true;
12403
12394
  return JSON.stringify(beforeItems) !== JSON.stringify(afterItems);
12404
12395
  }
12405
12396
  function dependencySurface(text) {
12406
- const items = [...readTomlStringArray(text, "dependencies")];
12407
- for (const header of ["dependency-groups", "project.optional-dependencies"]) {
12408
- const body = tomlTableBody(text, header);
12409
- if (!body) continue;
12410
- for (const m of body.matchAll(/^([A-Za-z0-9_.-]+)\s*=\s*\[/gm)) {
12411
- items.push(...readTomlStringArray(body, m[1]));
12412
- }
12397
+ try {
12398
+ return readDeclaredRequirements(parseToml2(text)).sort();
12399
+ } catch {
12400
+ return null;
12413
12401
  }
12414
- return items.sort();
12415
- }
12416
- function tomlTableBody(text, header) {
12417
- const escaped = header.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
12418
- const headerMatch = new RegExp(`^\\[${escaped}\\]\\s*$`, "m").exec(text);
12419
- if (!headerMatch) return null;
12420
- const rest = text.slice(headerMatch.index + headerMatch[0].length);
12421
- const nextHeader = /^\[/m.exec(rest);
12422
- return nextHeader ? rest.slice(0, nextHeader.index) : rest;
12423
12402
  }
12424
12403
  function readInstalledVersion(targetDir) {
12425
- const manifestPath = join43(targetDir, "biffo.plugin.json");
12426
- if (!existsSync41(manifestPath)) return void 0;
12404
+ const manifestPath = join44(targetDir, "biffo.plugin.json");
12405
+ if (!existsSync42(manifestPath)) return void 0;
12427
12406
  try {
12428
12407
  return validateManifest(JSON.parse(readFileSync30(manifestPath, "utf8"))).version;
12429
12408
  } catch {
@@ -12645,7 +12624,7 @@ pluginCommand.addCommand(pluginVerifyCommand);
12645
12624
  import { Command as Command25 } from "commander";
12646
12625
 
12647
12626
  // src/commands/sibling-check-identity.ts
12648
- import { existsSync as existsSync42, readFileSync as readFileSync31 } from "fs";
12627
+ import { existsSync as existsSync43, readFileSync as readFileSync31 } from "fs";
12649
12628
  import { resolve as resolve21 } from "path";
12650
12629
  import chalk20 from "chalk";
12651
12630
  import { Command as Command24 } from "commander";
@@ -12859,7 +12838,7 @@ async function resolveConfig4(options) {
12859
12838
  return cfg;
12860
12839
  }
12861
12840
  const localConfigPath = resolve21(process.cwd(), "biffo.config.json");
12862
- if (existsSync42(localConfigPath)) {
12841
+ if (existsSync43(localConfigPath)) {
12863
12842
  const raw = JSON.parse(readFileSync31(localConfigPath, "utf8"));
12864
12843
  const result = BiffoConfigSchema.safeParse(raw);
12865
12844
  if (result.success) return result.data;
@@ -12906,18 +12885,18 @@ siblingCommand.addCommand(siblingCheckIdentityCommand);
12906
12885
  import { Command as Command26 } from "commander";
12907
12886
 
12908
12887
  // src/scripts/check-adr-numbering.ts
12909
- import { existsSync as existsSync44 } from "fs";
12910
- import { join as join45 } from "path";
12888
+ import { existsSync as existsSync45 } from "fs";
12889
+ import { join as join46 } from "path";
12911
12890
 
12912
12891
  // src/lib/adr-numbering-guard.ts
12913
- import { existsSync as existsSync43, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "fs";
12914
- import { join as join44 } from "path";
12892
+ import { existsSync as existsSync44, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "fs";
12893
+ import { join as join45 } from "path";
12915
12894
  var ADR_FILENAME = /^(\d{4})-.+\.md$/;
12916
12895
  var ALLOWLIST_FILENAME = ".numbering-allowlist";
12917
12896
  var TEMPLATE_ADR_RESERVED_UPTO = "0099";
12918
12897
  function readAdrNumberingAllowlist(adrDir) {
12919
- const path = join44(adrDir, ALLOWLIST_FILENAME);
12920
- if (!existsSync43(path)) return /* @__PURE__ */ new Set();
12898
+ const path = join45(adrDir, ALLOWLIST_FILENAME);
12899
+ if (!existsSync44(path)) return /* @__PURE__ */ new Set();
12921
12900
  const numbers = /* @__PURE__ */ new Set();
12922
12901
  for (const rawLine of readFileSync32(path, "utf8").split("\n")) {
12923
12902
  const line = rawLine.split("#")[0].trim();
@@ -12927,7 +12906,7 @@ function readAdrNumberingAllowlist(adrDir) {
12927
12906
  }
12928
12907
  function adrNumbersIn(adrDir) {
12929
12908
  const claims = /* @__PURE__ */ new Map();
12930
- if (!existsSync43(adrDir)) return claims;
12909
+ if (!existsSync44(adrDir)) return claims;
12931
12910
  for (const entry of readdirSync15(adrDir).sort()) {
12932
12911
  const match = ADR_FILENAME.exec(entry);
12933
12912
  if (!match) continue;
@@ -12982,8 +12961,8 @@ function formatAdrReservedRangeViolations(violations, reservedUpTo = TEMPLATE_AD
12982
12961
  // src/scripts/check-adr-numbering.ts
12983
12962
  async function runAdrNumberingCheck() {
12984
12963
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
12985
- const adrDir = join45(root, "docs", "ADR");
12986
- if (!existsSync44(adrDir)) {
12964
+ const adrDir = join46(root, "docs", "ADR");
12965
+ if (!existsSync45(adrDir)) {
12987
12966
  console.log("\u2713 ADR numbering guard: no docs/ADR/ directory \u2014 nothing to compare");
12988
12967
  return;
12989
12968
  }
@@ -13022,7 +13001,7 @@ Already accepted? List it in docs/ADR/${ALLOWLIST_FILENAME} instead of leaving t
13022
13001
 
13023
13002
  // src/lib/api-gateway-integration-guard.ts
13024
13003
  import { readFileSync as readFileSync33, readdirSync as readdirSync16, statSync as statSync10 } from "fs";
13025
- import { join as join46 } from "path";
13004
+ import { join as join47 } from "path";
13026
13005
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
13027
13006
  var MODULE_TYPE = "module";
13028
13007
  var INTEGRATION_TYPE = "aws_apigatewayv2_integration";
@@ -13104,7 +13083,7 @@ function walkTerraformFiles(root) {
13104
13083
  return;
13105
13084
  }
13106
13085
  for (const entry of entries) {
13107
- const p = join46(dir, entry);
13086
+ const p = join47(dir, entry);
13108
13087
  let st;
13109
13088
  try {
13110
13089
  st = statSync10(p);
@@ -13520,17 +13499,17 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
13520
13499
  }
13521
13500
 
13522
13501
  // src/lib/claim-invocation-parity.ts
13523
- import { existsSync as existsSync45, readFileSync as readFileSync34, readdirSync as readdirSync17 } from "fs";
13524
- import { join as join47 } from "path";
13502
+ import { existsSync as existsSync46, readFileSync as readFileSync34, readdirSync as readdirSync17 } from "fs";
13503
+ import { join as join48 } from "path";
13525
13504
  function distributedAgentsDocs(root) {
13526
13505
  const docs = [];
13527
- const own = join47(root, "AGENTS.md");
13528
- if (existsSync45(own)) docs.push({ path: "AGENTS.md", text: readFileSync34(own, "utf8") });
13529
- const skeletons = join47(root, "_skeletons");
13530
- if (existsSync45(skeletons)) {
13506
+ const own = join48(root, "AGENTS.md");
13507
+ if (existsSync46(own)) docs.push({ path: "AGENTS.md", text: readFileSync34(own, "utf8") });
13508
+ const skeletons = join48(root, "_skeletons");
13509
+ if (existsSync46(skeletons)) {
13531
13510
  for (const name of readdirSync17(skeletons).sort()) {
13532
- const abs = join47(skeletons, name, "AGENTS.md");
13533
- if (!existsSync45(abs)) continue;
13511
+ const abs = join48(skeletons, name, "AGENTS.md");
13512
+ if (!existsSync46(abs)) continue;
13534
13513
  docs.push({ path: `_skeletons/${name}/AGENTS.md`, text: readFileSync34(abs, "utf8") });
13535
13514
  }
13536
13515
  }
@@ -13663,12 +13642,12 @@ async function runClaimInvocationCheck() {
13663
13642
  }
13664
13643
 
13665
13644
  // src/scripts/check-codeql-suppression.ts
13666
- import { existsSync as existsSync46 } from "fs";
13667
- import { join as join49, relative as relative8 } from "path";
13645
+ import { existsSync as existsSync47 } from "fs";
13646
+ import { join as join50, relative as relative8 } from "path";
13668
13647
 
13669
13648
  // src/lib/codeql-suppression-guard.ts
13670
13649
  import { readdirSync as readdirSync18, readFileSync as readFileSync35, statSync as statSync11 } from "fs";
13671
- import { join as join48 } from "path";
13650
+ import { join as join49 } from "path";
13672
13651
  var SKIP_DIRS2 = /* @__PURE__ */ new Set([
13673
13652
  ".git",
13674
13653
  ".worktrees",
@@ -13699,7 +13678,7 @@ function walkSourceFiles(root) {
13699
13678
  return;
13700
13679
  }
13701
13680
  for (const entry of entries) {
13702
- const p = join48(dir, entry);
13681
+ const p = join49(dir, entry);
13703
13682
  let st;
13704
13683
  try {
13705
13684
  st = statSync11(p);
@@ -13736,8 +13715,8 @@ function sweepCodeqlSuppressionComments(root) {
13736
13715
  // src/scripts/check-codeql-suppression.ts
13737
13716
  async function runCodeqlSuppressionCheck() {
13738
13717
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
13739
- const scanRoot = join49(root, "cli", "src");
13740
- if (!existsSync46(scanRoot)) {
13718
+ const scanRoot = join50(root, "cli", "src");
13719
+ if (!existsSync47(scanRoot)) {
13741
13720
  console.log(
13742
13721
  "\u2014 codeql-suppression guard: skipped \u2014 no cli/src in this repo, so there is no CLI source to scan."
13743
13722
  );
@@ -13761,12 +13740,12 @@ async function runCodeqlSuppressionCheck() {
13761
13740
  }
13762
13741
 
13763
13742
  // src/scripts/check-cognito-invite-template.ts
13764
- import { existsSync as existsSync47 } from "fs";
13765
- import { join as join51 } from "path";
13743
+ import { existsSync as existsSync48 } from "fs";
13744
+ import { join as join52 } from "path";
13766
13745
 
13767
13746
  // src/lib/cognito-invite-template-guard.ts
13768
13747
  import { readdirSync as readdirSync19, readFileSync as readFileSync36, statSync as statSync12 } from "fs";
13769
- import { join as join50 } from "path";
13748
+ import { join as join51 } from "path";
13770
13749
  var REQUIRED_INVITE_MEMBERS = ["email_subject", "email_message", "sms_message"];
13771
13750
  var REQUIRED_INVITE_PLACEHOLDERS = ["{username}", "{####}"];
13772
13751
  var PLACEHOLDER_MEMBERS = ["email_message", "sms_message"];
@@ -13850,7 +13829,7 @@ function findModuleTerraformFiles(repoRoot) {
13850
13829
  for (const entry of entries) {
13851
13830
  if (entry === "node_modules" || entry === ".git" || entry === ".worktrees" || entry === ".venv")
13852
13831
  continue;
13853
- const full = join50(dir, entry);
13832
+ const full = join51(dir, entry);
13854
13833
  const rel = `${relative11}/${entry}`;
13855
13834
  let isDir;
13856
13835
  try {
@@ -13865,12 +13844,12 @@ function findModuleTerraformFiles(repoRoot) {
13865
13844
  }
13866
13845
  }
13867
13846
  };
13868
- walk2(join50(repoRoot, "modules"), "modules");
13847
+ walk2(join51(repoRoot, "modules"), "modules");
13869
13848
  return found.sort();
13870
13849
  }
13871
13850
  function checkCognitoInviteTemplates(repoRoot) {
13872
13851
  return findModuleTerraformFiles(repoRoot).flatMap(
13873
- (file) => checkInviteTemplateSource(file, readFileSync36(join50(repoRoot, file), "utf8"))
13852
+ (file) => checkInviteTemplateSource(file, readFileSync36(join51(repoRoot, file), "utf8"))
13874
13853
  );
13875
13854
  }
13876
13855
 
@@ -13880,7 +13859,7 @@ async function runCognitoInviteTemplateCheck() {
13880
13859
  const files = findModuleTerraformFiles(root);
13881
13860
  console.log(`audited ${files.length} .tf file(s) under modules/ under ${root}`);
13882
13861
  if (files.length === 0) {
13883
- if (!existsSync47(join51(root, "modules"))) {
13862
+ if (!existsSync48(join52(root, "modules"))) {
13884
13863
  console.log(
13885
13864
  `\xB7 Cognito invite template guard: not applicable \u2014 no modules/ directory under ${root} \u2014 this is not a template/instance tree (a satellite repo never carries the template-owned Terraform modules). Skipping.`
13886
13865
  );
@@ -13904,11 +13883,11 @@ async function runCognitoInviteTemplateCheck() {
13904
13883
  }
13905
13884
 
13906
13885
  // src/scripts/check-core-direct-paths.ts
13907
- import { join as join53 } from "path";
13886
+ import { join as join54 } from "path";
13908
13887
 
13909
13888
  // src/lib/core-direct-paths-audit.ts
13910
- import { existsSync as existsSync48, readFileSync as readFileSync37, readdirSync as readdirSync20, statSync as statSync13 } from "fs";
13911
- import { join as join52 } from "path";
13889
+ import { existsSync as existsSync49, readFileSync as readFileSync37, readdirSync as readdirSync20, statSync as statSync13 } from "fs";
13890
+ import { join as join53 } from "path";
13912
13891
  var EXTERNAL_BASE_IDENTIFIERS = ["CORE_API_URL"];
13913
13892
  var API_ROUTE_PREFIX = "/api/v1";
13914
13893
  var TEST_FILE_SUFFIXES = [".test.ts", ".test.tsx", ".spec.ts", ".spec.tsx"];
@@ -14072,7 +14051,7 @@ function walkFiles(root, accept, skipDir) {
14072
14051
  return;
14073
14052
  }
14074
14053
  for (const entry of entries) {
14075
- const p = join52(dir, entry);
14054
+ const p = join53(dir, entry);
14076
14055
  let st;
14077
14056
  try {
14078
14057
  st = statSync13(p);
@@ -14167,7 +14146,7 @@ function pathMatchesAnyCorePrefix(normalized, corePrefixes, apiRoutePrefix = API
14167
14146
  }
14168
14147
  function resolveSiblingCoreSrc(params) {
14169
14148
  const { estateDir, sibling } = params;
14170
- const configPath = join52(estateDir, sibling, "biffo.sibling.json");
14149
+ const configPath = join53(estateDir, sibling, "biffo.sibling.json");
14171
14150
  let raw;
14172
14151
  try {
14173
14152
  raw = readFileSync37(configPath, "utf8");
@@ -14190,8 +14169,8 @@ function resolveSiblingCoreSrc(params) {
14190
14169
  `cannot resolve ${sibling}'s core: ${configPath} has no non-empty "core_project" field.`
14191
14170
  );
14192
14171
  }
14193
- const coreApiSrcDir = join52(estateDir, coreProject, "services", "api", "src");
14194
- if (!existsSync48(coreApiSrcDir)) {
14172
+ const coreApiSrcDir = join53(estateDir, coreProject, "services", "api", "src");
14173
+ if (!existsSync49(coreApiSrcDir)) {
14195
14174
  throw new Error(
14196
14175
  `cannot resolve ${sibling}'s core: biffo.sibling.json names core_project "${coreProject}", but ${coreApiSrcDir} does not exist -- the instance is missing from this estate checkout, not merely unmatched. Refusing to silently skip ${sibling} and shrink the audit's denominator.`
14197
14176
  );
@@ -14244,7 +14223,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
14244
14223
  }
14245
14224
  }
14246
14225
  const sibling = opts.sibling ?? "sibling-template (self-check)";
14247
- const frontendSrcDir = opts.frontendSrc ?? join53(root, "_skeletons", "sibling-template", "apps", "frontend", "src");
14226
+ const frontendSrcDir = opts.frontendSrc ?? join54(root, "_skeletons", "sibling-template", "apps", "frontend", "src");
14248
14227
  let coreApiSrcDir;
14249
14228
  let coreProject = null;
14250
14229
  if (opts.coreSrc) {
@@ -14260,7 +14239,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
14260
14239
  coreApiSrcDir = resolution.coreApiSrcDir;
14261
14240
  coreProject = resolution.coreProject;
14262
14241
  } else {
14263
- coreApiSrcDir = join53(root, "services", "api", "src");
14242
+ coreApiSrcDir = join54(root, "services", "api", "src");
14264
14243
  }
14265
14244
  const report = auditSiblingCoreDirectPaths({ sibling, frontendSrcDir, coreApiSrcDir });
14266
14245
  console.log(
@@ -14387,8 +14366,8 @@ async function runOwnershipCheck(argv) {
14387
14366
  const { stdout } = await execa("git", ["diff", "--cached", "--name-status"], { cwd: root });
14388
14367
  ({ changed: changedFiles, deleted: deletedFiles } = parseNameStatus(stdout));
14389
14368
  if (messageFile) {
14390
- const { readFileSync: readFileSync51, existsSync: existsSync62 } = await import("fs");
14391
- if (existsSync62(messageFile)) commitMessage = readFileSync51(messageFile, "utf8");
14369
+ const { readFileSync: readFileSync51, existsSync: existsSync63 } = await import("fs");
14370
+ if (existsSync63(messageFile)) commitMessage = readFileSync51(messageFile, "utf8");
14392
14371
  }
14393
14372
  } else {
14394
14373
  const base = process.env["GITHUB_BASE_REF"] ?? args[0];
@@ -14511,16 +14490,16 @@ ${BOLD}If the divergence is deliberate${OFF}
14511
14490
  }
14512
14491
 
14513
14492
  // src/scripts/check-distribution-inventory.ts
14514
- import { existsSync as existsSync50 } from "fs";
14515
- import { join as join55 } from "path";
14493
+ import { existsSync as existsSync51 } from "fs";
14494
+ import { join as join56 } from "path";
14516
14495
 
14517
14496
  // src/lib/distribution-inventory.ts
14518
- import { existsSync as existsSync49, readFileSync as readFileSync38 } from "fs";
14519
- import { join as join54 } from "path";
14497
+ import { existsSync as existsSync50, readFileSync as readFileSync38 } from "fs";
14498
+ import { join as join55 } from "path";
14520
14499
  var INVENTORY_FILENAME = "distribution-inventory.json";
14521
14500
  function loadDistributionInventory(root) {
14522
- const path = join54(root, INVENTORY_FILENAME);
14523
- if (!existsSync49(path)) {
14501
+ const path = join55(root, INVENTORY_FILENAME);
14502
+ if (!existsSync50(path)) {
14524
14503
  throw new Error(
14525
14504
  `${INVENTORY_FILENAME} not found at ${root} -- expected it beside core-manifest.json`
14526
14505
  );
@@ -14685,7 +14664,7 @@ async function runDistributionInventoryCheck(root) {
14685
14664
  );
14686
14665
  return;
14687
14666
  }
14688
- if (!existsSync50(join55(repoRoot, INVENTORY_FILENAME))) {
14667
+ if (!existsSync51(join56(repoRoot, INVENTORY_FILENAME))) {
14689
14668
  console.log(
14690
14669
  `\u2713 distribution-inventory: skipped \u2014 no ${INVENTORY_FILENAME} at ${repoRoot}. This is a template-only registry; a checkout that legitimately has none has nothing for this guard to check.`
14691
14670
  );
@@ -14711,7 +14690,7 @@ async function runDistributionInventoryCheck(root) {
14711
14690
  }
14712
14691
 
14713
14692
  // src/scripts/check-distribution-remote-state.ts
14714
- import { join as join56 } from "path";
14693
+ import { join as join57 } from "path";
14715
14694
  async function ghExecCommand(file, args) {
14716
14695
  const result = await execa(file, args, { reject: false });
14717
14696
  return { stdout: String(result.stdout ?? ""), exitCode: result.exitCode ?? null };
@@ -14726,7 +14705,7 @@ async function runDistributionRemoteStateCheck(root) {
14726
14705
  }
14727
14706
  }
14728
14707
  console.log(
14729
- `distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${join56(repoRoot, "distribution-inventory.json")})`
14708
+ `distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${join57(repoRoot, "distribution-inventory.json")})`
14730
14709
  );
14731
14710
  if (assertions.length === 0) {
14732
14711
  console.log("\u2713 distribution-remote-state: nothing declared to check");
@@ -14772,7 +14751,7 @@ ${assertion.ref}`;
14772
14751
 
14773
14752
  // src/lib/eventbridge-log-permission-guard.ts
14774
14753
  import { readFileSync as readFileSync39, readdirSync as readdirSync21, statSync as statSync14 } from "fs";
14775
- import { join as join57 } from "path";
14754
+ import { join as join58 } from "path";
14776
14755
  var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
14777
14756
  var EVENT_TARGET_TYPE = "aws_cloudwatch_event_target";
14778
14757
  var LOG_RESOURCE_POLICY_TYPE = "aws_cloudwatch_log_resource_policy";
@@ -14849,7 +14828,7 @@ function walkTerraformFiles2(root) {
14849
14828
  return;
14850
14829
  }
14851
14830
  for (const entry of entries) {
14852
- const p = join57(dir, entry);
14831
+ const p = join58(dir, entry);
14853
14832
  let st;
14854
14833
  try {
14855
14834
  st = statSync14(p);
@@ -14989,8 +14968,8 @@ async function runEventBridgeLogPermissionCheck() {
14989
14968
  }
14990
14969
 
14991
14970
  // src/scripts/check-instance-adoption.ts
14992
- import { existsSync as existsSync51 } from "fs";
14993
- import { join as join58 } from "path";
14971
+ import { existsSync as existsSync52 } from "fs";
14972
+ import { join as join59 } from "path";
14994
14973
  async function runInstanceAdoptionCheck(opts = {}) {
14995
14974
  if (!opts.instanceDir) {
14996
14975
  console.error(
@@ -14998,7 +14977,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
14998
14977
  );
14999
14978
  process.exit(2);
15000
14979
  }
15001
- if (!existsSync51(opts.instanceDir)) {
14980
+ if (!existsSync52(opts.instanceDir)) {
15002
14981
  console.error(
15003
14982
  `\u2717 instance-adoption guard: --instance-dir ${opts.instanceDir} does not exist \u2014 cannot tell whether it is adopted, and that is not the same as a clean pass.`
15004
14983
  );
@@ -15006,7 +14985,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
15006
14985
  }
15007
14986
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
15008
14987
  const theirsDir = opts.theirsDir ?? root;
15009
- const instanceLabel = opts.instance ?? join58(opts.instanceDir).split("/").filter(Boolean).pop();
14988
+ const instanceLabel = opts.instance ?? join59(opts.instanceDir).split("/").filter(Boolean).pop();
15010
14989
  const report = checkInstanceAdoption(theirsDir, opts.instanceDir);
15011
14990
  console.log(
15012
14991
  `examined ${report.examinedInstances} instance (${instanceLabel}) against ${report.registeredPairs} registered pair(s), ${report.applicablePairs} applicable to this instance, against template tree ${theirsDir}`
@@ -15029,11 +15008,11 @@ async function runInstanceAdoptionCheck(opts = {}) {
15029
15008
 
15030
15009
  // src/lib/lambda-output-guard.ts
15031
15010
  import { readFileSync as readFileSync41 } from "fs";
15032
- import { join as join60 } from "path";
15011
+ import { join as join61 } from "path";
15033
15012
 
15034
15013
  // src/lib/terraform-input-guard.ts
15035
- import { existsSync as existsSync52, readdirSync as readdirSync22, readFileSync as readFileSync40, statSync as statSync15 } from "fs";
15036
- import { join as join59 } from "path";
15014
+ import { existsSync as existsSync53, readdirSync as readdirSync22, readFileSync as readFileSync40, statSync as statSync15 } from "fs";
15015
+ import { join as join60 } from "path";
15037
15016
  var GUARDED_SUBCOMMANDS = [
15038
15017
  "init",
15039
15018
  "plan",
@@ -15047,7 +15026,7 @@ function stripComments2(source) {
15047
15026
  return source.split("\n").map((line) => line.replace(/(^|\s)#.*$/, "$1")).join("\n");
15048
15027
  }
15049
15028
  function vendoredPluginServiceDirs(repoRoot) {
15050
- const servicesDir = join59(repoRoot, "services");
15029
+ const servicesDir = join60(repoRoot, "services");
15051
15030
  const result = /* @__PURE__ */ new Set();
15052
15031
  let entries;
15053
15032
  try {
@@ -15056,9 +15035,9 @@ function vendoredPluginServiceDirs(repoRoot) {
15056
15035
  return result;
15057
15036
  }
15058
15037
  for (const entry of entries) {
15059
- const full = join59(servicesDir, entry);
15060
- if (!existsSync52(full) || !statSync15(full).isDirectory()) continue;
15061
- if (existsSync52(join59(full, "biffo.plugin.json"))) {
15038
+ const full = join60(servicesDir, entry);
15039
+ if (!existsSync53(full) || !statSync15(full).isDirectory()) continue;
15040
+ if (existsSync53(join60(full, "biffo.plugin.json"))) {
15062
15041
  result.add(entry);
15063
15042
  }
15064
15043
  }
@@ -15080,7 +15059,7 @@ function findWorkflowFiles(repoRoot) {
15080
15059
  if (entry === ".github" && relative11.startsWith("services/") && vendoredPluginDirs.has(relative11.slice("services/".length))) {
15081
15060
  continue;
15082
15061
  }
15083
- const full = join59(dir, entry);
15062
+ const full = join60(dir, entry);
15084
15063
  const rel = relative11 ? `${relative11}/${entry}` : entry;
15085
15064
  let isDir;
15086
15065
  try {
@@ -15130,7 +15109,7 @@ function checkWorkflowSource(file, rawSource) {
15130
15109
  }
15131
15110
  function checkTerraformInput(repoRoot) {
15132
15111
  return findWorkflowFiles(repoRoot).flatMap(
15133
- (file) => checkWorkflowSource(file, readFileSync40(join59(repoRoot, file), "utf8"))
15112
+ (file) => checkWorkflowSource(file, readFileSync40(join60(repoRoot, file), "utf8"))
15134
15113
  );
15135
15114
  }
15136
15115
 
@@ -15188,7 +15167,7 @@ function checkWorkflowSource2(file, rawSource) {
15188
15167
  }
15189
15168
  function checkLambdaOutput(repoRoot) {
15190
15169
  return findWorkflowFiles(repoRoot).flatMap(
15191
- (file) => checkWorkflowSource2(file, readFileSync41(join60(repoRoot, file), "utf8"))
15170
+ (file) => checkWorkflowSource2(file, readFileSync41(join61(repoRoot, file), "utf8"))
15192
15171
  );
15193
15172
  }
15194
15173
 
@@ -15216,8 +15195,8 @@ async function runLambdaOutputCheck() {
15216
15195
  }
15217
15196
 
15218
15197
  // src/scripts/check-migration-body-change.ts
15219
- import { existsSync as existsSync53 } from "fs";
15220
- import { join as join61 } from "path";
15198
+ import { existsSync as existsSync54 } from "fs";
15199
+ import { join as join62 } from "path";
15221
15200
 
15222
15201
  // src/lib/migration-body-change-guard.ts
15223
15202
  function checkMigrationBodyChangeMarkers(diffs) {
@@ -15299,7 +15278,7 @@ async function runMigrationBodyChangeCheck(argv) {
15299
15278
  );
15300
15279
  return;
15301
15280
  }
15302
- if (!existsSync53(join61(root, MIGRATIONS_VERSIONS_DIR))) {
15281
+ if (!existsSync54(join62(root, MIGRATIONS_VERSIONS_DIR))) {
15303
15282
  console.log(`\u2713 migration body-change guard: no ${MIGRATIONS_VERSIONS_DIR} in this repo.`);
15304
15283
  return;
15305
15284
  }
@@ -15405,8 +15384,8 @@ ${BOLD2}What to do${OFF2}
15405
15384
  }
15406
15385
 
15407
15386
  // src/scripts/check-orphan-ratchet.ts
15408
- import { existsSync as existsSync54 } from "fs";
15409
- import { basename as basename3, join as join62 } from "path";
15387
+ import { existsSync as existsSync55 } from "fs";
15388
+ import { basename as basename3, join as join63 } from "path";
15410
15389
  function reportOrphan(entry, manifest) {
15411
15390
  console.error(` ${entry.path}`);
15412
15391
  const { templateOwnedMatch, nearestUserOwnedEntries } = explainOwnership(entry.path, manifest);
@@ -15428,7 +15407,7 @@ function reportOrphan(entry, manifest) {
15428
15407
  }
15429
15408
  }
15430
15409
  async function runOrphanRatchetCheck(opts = {}) {
15431
- if (opts.instanceDir !== void 0 && !existsSync54(opts.instanceDir)) {
15410
+ if (opts.instanceDir !== void 0 && !existsSync55(opts.instanceDir)) {
15432
15411
  console.error(
15433
15412
  `\u2717 orphan-ratchet guard: --instance-dir ${opts.instanceDir} does not exist \u2014 cannot tell whether it carries unsanctioned files, and that is not the same as a clean pass.`
15434
15413
  );
@@ -15445,7 +15424,7 @@ async function runOrphanRatchetCheck(opts = {}) {
15445
15424
  "self-check mode: --instance-dir was not given, so it defaulted to --theirs-dir (this repo's own root) alongside --base-dir \u2014 all three trees are the same, so this run can only ever find zero orphans by construction. See this script's doc comment. Pass a real instance tree with --instance-dir for a check that can actually find something. biffo-template#1714."
15446
15425
  );
15447
15426
  }
15448
- if (!existsSync54(join62(theirsDir, CORE_MANIFEST_FILE))) {
15427
+ if (!existsSync55(join63(theirsDir, CORE_MANIFEST_FILE))) {
15449
15428
  console.log(
15450
15429
  `orphan-ratchet guard (${label}): no ${CORE_MANIFEST_FILE} in ${theirsDir} \u2014 this is not a Biffo template/instance tree (a satellite repo never carries one), so there is no ownership manifest to classify paths against. Not applicable; skipping.`
15451
15430
  );
@@ -15477,7 +15456,7 @@ baseline was ${String(ratchet.baseline)}, now ${String(ratchet.count)}. See biff
15477
15456
 
15478
15457
  // src/lib/ownership-header-claim-guard.ts
15479
15458
  import { readFileSync as readFileSync42 } from "fs";
15480
- import { join as join63 } from "path";
15459
+ import { join as join64 } from "path";
15481
15460
  var OWNERSHIP_HEADER_SWEEP_DIRS = [
15482
15461
  "scripts",
15483
15462
  ".githooks",
@@ -15686,7 +15665,7 @@ function sweepOwnershipHeaderClaims(root, options = {}) {
15686
15665
  for (const rel of files) {
15687
15666
  let content;
15688
15667
  try {
15689
- content = readFileSync42(join63(root, rel), "utf8");
15668
+ content = readFileSync42(join64(root, rel), "utf8");
15690
15669
  } catch {
15691
15670
  continue;
15692
15671
  }
@@ -15762,7 +15741,7 @@ async function runOwnershipHeaderClaimCheck() {
15762
15741
 
15763
15742
  // src/scripts/check-pipe-trap.ts
15764
15743
  import { readFileSync as readFileSync43, readdirSync as readdirSync23 } from "fs";
15765
- import { join as join64, relative as relative9 } from "path";
15744
+ import { join as join65, relative as relative9 } from "path";
15766
15745
 
15767
15746
  // src/lib/pipe-trap-guard.ts
15768
15747
  var STATUS_BEARING = [
@@ -15858,7 +15837,7 @@ function findPipeTraps(source) {
15858
15837
  function shellFiles(root) {
15859
15838
  const out = [];
15860
15839
  for (const dir of ["scripts", ".githooks"]) {
15861
- const full = join64(root, dir);
15840
+ const full = join65(root, dir);
15862
15841
  let entries;
15863
15842
  try {
15864
15843
  entries = readdirSync23(full, { withFileTypes: true });
@@ -15868,7 +15847,7 @@ function shellFiles(root) {
15868
15847
  for (const entry of entries) {
15869
15848
  if (!entry.isFile()) continue;
15870
15849
  if (dir === "scripts" && !entry.name.endsWith(".sh")) continue;
15871
- out.push(join64(full, entry.name));
15850
+ out.push(join65(full, entry.name));
15872
15851
  }
15873
15852
  }
15874
15853
  return out;
@@ -15902,7 +15881,7 @@ async function runPipeTrapCheck() {
15902
15881
 
15903
15882
  // src/lib/plugin-allowlist-convention.ts
15904
15883
  import { readFileSync as readFileSync44 } from "fs";
15905
- import { join as join65 } from "path";
15884
+ import { join as join66 } from "path";
15906
15885
  var COMPUTE_MAIN_TF = "modules/cloud/aws/compute/main.tf";
15907
15886
  var PLUGIN_TEMPLATE_MAIN_TF = "modules/plugins/_template/main.tf";
15908
15887
  var ALLOWLIST_MAIN_TF = "modules/cloud/aws/plugin-allowlist/main.tf";
@@ -15913,7 +15892,7 @@ var PLUGIN = "<plugin>";
15913
15892
  var ACCOUNT = "<account>";
15914
15893
  function read(repoRoot, relative11) {
15915
15894
  try {
15916
- return readFileSync44(join65(repoRoot, relative11), "utf8");
15895
+ return readFileSync44(join66(repoRoot, relative11), "utf8");
15917
15896
  } catch {
15918
15897
  throw new Error(`plugin-allowlist drift guard: cannot read ${relative11}`);
15919
15898
  }
@@ -16041,32 +16020,32 @@ async function runPluginAllowlistConventionCheck() {
16041
16020
  }
16042
16021
 
16043
16022
  // src/scripts/check-plugin-collisions.ts
16044
- import { existsSync as existsSync56 } from "fs";
16045
- import { join as join67 } from "path";
16023
+ import { existsSync as existsSync57 } from "fs";
16024
+ import { join as join68 } from "path";
16046
16025
 
16047
16026
  // src/lib/plugin-collision-guard.ts
16048
- import { existsSync as existsSync55, readdirSync as readdirSync24, statSync as statSync16 } from "fs";
16049
- import { join as join66 } from "path";
16027
+ import { existsSync as existsSync56, readdirSync as readdirSync24, statSync as statSync16 } from "fs";
16028
+ import { join as join67 } from "path";
16050
16029
  var PYTEST_SPECIAL = /* @__PURE__ */ new Set(["conftest.py"]);
16051
16030
  var IGNORED_DIRS = /* @__PURE__ */ new Set([".venv", "node_modules", "__pycache__", ".git", "dist", "build"]);
16052
16031
  function subdirectories(dir) {
16053
- if (!existsSync55(dir)) return [];
16032
+ if (!existsSync56(dir)) return [];
16054
16033
  return readdirSync24(dir).filter((entry) => {
16055
16034
  if (IGNORED_DIRS.has(entry) || entry.startsWith(".")) return false;
16056
16035
  try {
16057
- return statSync16(join66(dir, entry)).isDirectory();
16036
+ return statSync16(join67(dir, entry)).isDirectory();
16058
16037
  } catch {
16059
16038
  return false;
16060
16039
  }
16061
16040
  });
16062
16041
  }
16063
16042
  function regularPackagesOf(pluginDir2) {
16064
- return subdirectories(pluginDir2).filter((name) => existsSync55(join66(pluginDir2, name, "__init__.py"))).sort();
16043
+ return subdirectories(pluginDir2).filter((name) => existsSync56(join67(pluginDir2, name, "__init__.py"))).sort();
16065
16044
  }
16066
16045
  function bareTestModulesOf(pluginDir2) {
16067
- const testsDir = join66(pluginDir2, "tests");
16068
- if (!existsSync55(testsDir)) return [];
16069
- if (existsSync55(join66(testsDir, "__init__.py"))) return [];
16046
+ const testsDir = join67(pluginDir2, "tests");
16047
+ if (!existsSync56(testsDir)) return [];
16048
+ if (existsSync56(join67(testsDir, "__init__.py"))) return [];
16070
16049
  return readdirSync24(testsDir).filter((f) => f.endsWith(".py") && !PYTEST_SPECIAL.has(f)).sort();
16071
16050
  }
16072
16051
  function findCollisions(servicesDir, pluginDirs) {
@@ -16075,7 +16054,7 @@ function findCollisions(servicesDir, pluginDirs) {
16075
16054
  const gather = (kind, namesOf) => {
16076
16055
  const claims = /* @__PURE__ */ new Map();
16077
16056
  for (const plugin of plugins) {
16078
- for (const name of namesOf(join66(servicesDir, plugin))) {
16057
+ for (const name of namesOf(join67(servicesDir, plugin))) {
16079
16058
  claims.set(name, [...claims.get(name) ?? [], plugin]);
16080
16059
  }
16081
16060
  }
@@ -16113,8 +16092,8 @@ function formatCollisions(collisions) {
16113
16092
  // src/scripts/check-plugin-collisions.ts
16114
16093
  async function runPluginCollisionCheck() {
16115
16094
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
16116
- const servicesDir = join67(root, "services");
16117
- if (!existsSync56(servicesDir)) {
16095
+ const servicesDir = join68(root, "services");
16096
+ if (!existsSync57(servicesDir)) {
16118
16097
  console.log("\u2713 plugin collision guard: no services/ directory \u2014 nothing to compare");
16119
16098
  return;
16120
16099
  }
@@ -16131,8 +16110,8 @@ async function runPluginCollisionCheck() {
16131
16110
  }
16132
16111
 
16133
16112
  // src/lib/plugin-terraform-guard.ts
16134
- import { existsSync as existsSync57, readFileSync as readFileSync45, readdirSync as readdirSync25 } from "fs";
16135
- import { dirname as dirname13, join as join68, relative as relative10, sep as sep4 } from "path";
16113
+ import { existsSync as existsSync58, readFileSync as readFileSync45, readdirSync as readdirSync25 } from "fs";
16114
+ import { dirname as dirname13, join as join69, relative as relative10, sep as sep4 } from "path";
16136
16115
  var SKIP_DIRS4 = /* @__PURE__ */ new Set(["node_modules", ".git", ".worktrees", "dist", ".venv", "__pycache__"]);
16137
16116
  var PLUGIN_MANIFEST_FILE2 = "biffo.plugin.json";
16138
16117
  function findPluginManifests(root) {
@@ -16147,9 +16126,9 @@ function findPluginManifests(root) {
16147
16126
  for (const entry of entries) {
16148
16127
  if (entry.isDirectory()) {
16149
16128
  if (SKIP_DIRS4.has(entry.name)) continue;
16150
- walk2(join68(dir, entry.name));
16129
+ walk2(join69(dir, entry.name));
16151
16130
  } else if (entry.isFile() && entry.name === PLUGIN_MANIFEST_FILE2) {
16152
- found.push(relative10(root, join68(dir, entry.name)).split(sep4).join("/"));
16131
+ found.push(relative10(root, join69(dir, entry.name)).split(sep4).join("/"));
16153
16132
  }
16154
16133
  }
16155
16134
  };
@@ -16174,14 +16153,14 @@ function readSubscriptions(absManifestPath) {
16174
16153
  }
16175
16154
  function checkPluginTerraform(root) {
16176
16155
  const violations = [];
16177
- const coreManifest = existsSync57(join68(root, CORE_MANIFEST_FILE)) ? readCoreManifest(root) : null;
16156
+ const coreManifest = existsSync58(join69(root, CORE_MANIFEST_FILE)) ? readCoreManifest(root) : null;
16178
16157
  for (const manifest of findPluginManifests(root)) {
16179
16158
  if (coreManifest && !isTemplateOwned(manifest, coreManifest)) continue;
16180
- const absManifest = join68(root, manifest);
16159
+ const absManifest = join69(root, manifest);
16181
16160
  const subscriptions = readSubscriptions(absManifest);
16182
16161
  if (subscriptions === null) continue;
16183
16162
  const pluginDir2 = dirname13(absManifest);
16184
- if (existsSync57(join68(pluginDir2, "terraform"))) continue;
16163
+ if (existsSync58(join69(pluginDir2, "terraform"))) continue;
16185
16164
  const relPluginDir = relative10(root, pluginDir2).split(sep4).join("/");
16186
16165
  violations.push({
16187
16166
  manifest,
@@ -16212,12 +16191,12 @@ async function runPluginTerraformCheck() {
16212
16191
  }
16213
16192
 
16214
16193
  // src/scripts/check-plugin-tool-supply.ts
16215
- import { existsSync as existsSync59 } from "fs";
16216
- import { join as join70 } from "path";
16194
+ import { existsSync as existsSync60 } from "fs";
16195
+ import { join as join71 } from "path";
16217
16196
 
16218
16197
  // src/lib/plugin-tool-supply-audit.ts
16219
- import { existsSync as existsSync58, readFileSync as readFileSync46, readdirSync as readdirSync26, statSync as statSync17 } from "fs";
16220
- import { join as join69 } from "path";
16198
+ import { existsSync as existsSync59, readFileSync as readFileSync46, readdirSync as readdirSync26, statSync as statSync17 } from "fs";
16199
+ import { join as join70 } from "path";
16221
16200
 
16222
16201
  // src/lib/openrouter-model-snapshot.ts
16223
16202
  var OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT = "2026-09-25T20:12:57Z";
@@ -16692,7 +16671,7 @@ function listDirs(root) {
16692
16671
  }
16693
16672
  return entries.filter((e) => {
16694
16673
  try {
16695
- return statSync17(join69(root, e)).isDirectory();
16674
+ return statSync17(join70(root, e)).isDirectory();
16696
16675
  } catch {
16697
16676
  return false;
16698
16677
  }
@@ -16708,7 +16687,7 @@ function walkFiles2(root, accept, skipDir) {
16708
16687
  return;
16709
16688
  }
16710
16689
  for (const entry of entries) {
16711
- const p = join69(dir, entry);
16690
+ const p = join70(dir, entry);
16712
16691
  let st;
16713
16692
  try {
16714
16693
  st = statSync17(p);
@@ -16734,14 +16713,14 @@ function pluginPythonFiles(pluginDir2) {
16734
16713
  );
16735
16714
  }
16736
16715
  function pluginTerraformFiles(pluginDir2) {
16737
- const tfDir = join69(pluginDir2, "terraform");
16716
+ const tfDir = join70(pluginDir2, "terraform");
16738
16717
  let entries;
16739
16718
  try {
16740
16719
  entries = readdirSync26(tfDir);
16741
16720
  } catch {
16742
16721
  return [];
16743
16722
  }
16744
- return entries.filter((e) => e.endsWith(".tf")).map((e) => join69(tfDir, e)).sort();
16723
+ return entries.filter((e) => e.endsWith(".tf")).map((e) => join70(tfDir, e)).sort();
16745
16724
  }
16746
16725
  function extractManifestTools(manifestText) {
16747
16726
  let parsed;
@@ -16993,8 +16972,8 @@ function isSnapshotStale(fetchedAt, now) {
16993
16972
  function normalizeModelId(id) {
16994
16973
  return id.endsWith(":online") ? id.slice(0, -":online".length) : id;
16995
16974
  }
16996
- var CONFIG_PY_PATH = join69("services", "api", "src", "api", "config.py");
16997
- var ORCHESTRATION_SCHEMA_PATH = join69(
16975
+ var CONFIG_PY_PATH = join70("services", "api", "src", "api", "config.py");
16976
+ var ORCHESTRATION_SCHEMA_PATH = join70(
16998
16977
  "services",
16999
16978
  "api",
17000
16979
  "src",
@@ -17007,10 +16986,10 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
17007
16986
  const snapshotFetchedAt = options.snapshotFetchedAt ?? OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT;
17008
16987
  const now = options.now ?? /* @__PURE__ */ new Date();
17009
16988
  const snapshotAgeEnforced = options.enforceSnapshotAge ?? true;
17010
- const configPath = join69(repoRoot, CONFIG_PY_PATH);
17011
- const orchestrationPath = join69(repoRoot, ORCHESTRATION_SCHEMA_PATH);
17012
- const configMissing = !existsSync58(configPath);
17013
- const orchestrationSchemaMissing = !existsSync58(orchestrationPath);
16989
+ const configPath = join70(repoRoot, CONFIG_PY_PATH);
16990
+ const orchestrationPath = join70(repoRoot, ORCHESTRATION_SCHEMA_PATH);
16991
+ const configMissing = !existsSync59(configPath);
16992
+ const orchestrationSchemaMissing = !existsSync59(orchestrationPath);
17014
16993
  const knownSet = new Set(knownModelIds);
17015
16994
  const snapshotEmpty = knownModelIds.length === 0;
17016
16995
  const snapshotStale = isSnapshotStale(snapshotFetchedAt, now);
@@ -17082,7 +17061,7 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
17082
17061
  function discoverPluginDirs(pluginsRoot) {
17083
17062
  return listDirs(pluginsRoot).filter((name) => {
17084
17063
  try {
17085
- return statSync17(join69(pluginsRoot, name, "biffo.plugin.json")).isFile();
17064
+ return statSync17(join70(pluginsRoot, name, "biffo.plugin.json")).isFile();
17086
17065
  } catch {
17087
17066
  return false;
17088
17067
  }
@@ -17095,8 +17074,8 @@ function auditPluginToolSupply(pluginsRoot) {
17095
17074
  let terraformBlind = false;
17096
17075
  let totalDeclaredTools = 0;
17097
17076
  for (const name of pluginNames) {
17098
- const pluginDir2 = join69(pluginsRoot, name);
17099
- const manifestText = readFileSync46(join69(pluginDir2, "biffo.plugin.json"), "utf8");
17077
+ const pluginDir2 = join70(pluginsRoot, name);
17078
+ const manifestText = readFileSync46(join70(pluginDir2, "biffo.plugin.json"), "utf8");
17100
17079
  const manifest = extractManifestTools(manifestText);
17101
17080
  if (manifest.parseError) {
17102
17081
  findings.push({
@@ -17194,7 +17173,7 @@ function auditPluginToolSupply(pluginsRoot) {
17194
17173
  requiredEnvVars: envResult.envVars,
17195
17174
  missingEnvVars: anyWired ? [] : envResult.envVars,
17196
17175
  status: anyWired ? "ok" : "missing-env",
17197
- detail: anyWired ? `${entry.predicate}() is satisfiable: at least one of ${JSON.stringify(envResult.envVars)} is wired in Terraform` : `${entry.predicate}() reads ${JSON.stringify(envResult.envVars)} \u2014 NONE of these are wired by any environment_variables block under ${join69(pluginDir2, "terraform")}, so this deployment can never supply it`
17176
+ detail: anyWired ? `${entry.predicate}() is satisfiable: at least one of ${JSON.stringify(envResult.envVars)} is wired in Terraform` : `${entry.predicate}() reads ${JSON.stringify(envResult.envVars)} \u2014 NONE of these are wired by any environment_variables block under ${join70(pluginDir2, "terraform")}, so this deployment can never supply it`
17198
17177
  });
17199
17178
  }
17200
17179
  }
@@ -17234,8 +17213,8 @@ async function runPluginToolSupplyCheck() {
17234
17213
  return;
17235
17214
  }
17236
17215
  let allOk = true;
17237
- const pluginsRoot = join70(root, "services", "_plugins");
17238
- if (!existsSync59(pluginsRoot)) {
17216
+ const pluginsRoot = join71(root, "services", "_plugins");
17217
+ if (!existsSync60(pluginsRoot)) {
17239
17218
  console.log("\u2713 plugin tool-supply guard: no services/_plugins/ \u2014 nothing to audit");
17240
17219
  } else {
17241
17220
  const report = auditPluginToolSupply(pluginsRoot);
@@ -17265,8 +17244,8 @@ async function runPluginToolSupplyCheck() {
17265
17244
  console.log(`\u2713 plugin tool-supply guard: ${report.summary}`);
17266
17245
  }
17267
17246
  }
17268
- const servicesApiRoot = join70(root, "services", "api");
17269
- if (!existsSync59(servicesApiRoot)) {
17247
+ const servicesApiRoot = join71(root, "services", "api");
17248
+ if (!existsSync60(servicesApiRoot)) {
17270
17249
  console.log("\u2713 plugin model-id guard: no services/api/ \u2014 nothing to audit");
17271
17250
  } else {
17272
17251
  const modelReport = auditDeclaredModelIds(root, {
@@ -17650,12 +17629,12 @@ async function runSharedFileReductionCheck(args) {
17650
17629
  }
17651
17630
 
17652
17631
  // src/scripts/check-skeleton-drift.ts
17653
- import { existsSync as existsSync60, readdirSync as readdirSync28 } from "fs";
17654
- import { join as join72 } from "path";
17632
+ import { existsSync as existsSync61, readdirSync as readdirSync28 } from "fs";
17633
+ import { join as join73 } from "path";
17655
17634
 
17656
17635
  // src/lib/skeleton-drift-guard.ts
17657
17636
  import { readFileSync as readFileSync49, readdirSync as readdirSync27, statSync as statSync18 } from "fs";
17658
- import { join as join71 } from "path";
17637
+ import { join as join72 } from "path";
17659
17638
  var isWorkflow = (rel) => rel.startsWith(".github/workflows/") && (rel.endsWith(".yml") || rel.endsWith(".yaml"));
17660
17639
  var isRootLayout = (rel) => rel.endsWith("src/app/layout.tsx");
17661
17640
  var uncommented = (contents) => contents.split("\n").filter((line) => !/^\s*(\/\/|\/\*|\*)/.test(line)).join("\n");
@@ -17719,7 +17698,7 @@ function walk(dir, base = dir) {
17719
17698
  }
17720
17699
  for (const entry of entries) {
17721
17700
  if (entry === ".venv" || entry === "node_modules" || entry === ".git") continue;
17722
- const abs = join71(dir, entry);
17701
+ const abs = join72(dir, entry);
17723
17702
  let isDir;
17724
17703
  try {
17725
17704
  isDir = statSync18(abs).isDirectory();
@@ -17741,7 +17720,7 @@ function auditSkeleton(skeletonRoot, name, rules = SKELETON_RULES) {
17741
17720
  if (!rule.appliesTo(rel)) continue;
17742
17721
  let contents;
17743
17722
  try {
17744
- contents = readFileSync49(join71(skeletonRoot, rel), "utf8");
17723
+ contents = readFileSync49(join72(skeletonRoot, rel), "utf8");
17745
17724
  } catch {
17746
17725
  continue;
17747
17726
  }
@@ -17770,23 +17749,23 @@ function formatViolations2(violations) {
17770
17749
 
17771
17750
  // src/scripts/check-skeleton-drift.ts
17772
17751
  function discoverSkeletons(root) {
17773
- const skeletonsDir = join72(root, "_skeletons");
17752
+ const skeletonsDir = join73(root, "_skeletons");
17774
17753
  let entries;
17775
17754
  try {
17776
17755
  entries = readdirSync28(skeletonsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
17777
17756
  } catch {
17778
17757
  return [];
17779
17758
  }
17780
- return entries.filter((name) => existsSync60(join72(skeletonsDir, name, ".github", "workflows", "ci.yml"))).sort();
17759
+ return entries.filter((name) => existsSync61(join73(skeletonsDir, name, ".github", "workflows", "ci.yml"))).sort();
17781
17760
  }
17782
17761
  async function runSkeletonDriftCheck() {
17783
17762
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
17784
17763
  const skeletons = discoverSkeletons(root);
17785
17764
  let filesConsidered = 0;
17786
17765
  for (const name of skeletons) {
17787
- const skeletonRoot = join72(root, "_skeletons", name);
17766
+ const skeletonRoot = join73(root, "_skeletons", name);
17788
17767
  filesConsidered += findWorkflowFiles(skeletonRoot).length;
17789
- if (existsSync60(join72(skeletonRoot, "apps", "frontend", "src", "app", "layout.tsx"))) {
17768
+ if (existsSync61(join73(skeletonRoot, "apps", "frontend", "src", "app", "layout.tsx"))) {
17790
17769
  filesConsidered += 1;
17791
17770
  }
17792
17771
  }
@@ -17794,7 +17773,7 @@ async function runSkeletonDriftCheck() {
17794
17773
  `audited ${skeletons.length} skeleton(s) (${skeletons.join(", ") || "none"}), ${filesConsidered} file(s) considered, under ${root}/_skeletons`
17795
17774
  );
17796
17775
  if (skeletons.length === 0) {
17797
- if (!existsSync60(join72(root, "_skeletons"))) {
17776
+ if (!existsSync61(join73(root, "_skeletons"))) {
17798
17777
  console.log(
17799
17778
  `\xB7 Skeleton-drift guard: no _skeletons/ directory under ${root} \u2014 this is not a repo that ships scaffolding (a satellite repo never carries one). Not applicable; skipping.`
17800
17779
  );
@@ -17806,7 +17785,7 @@ async function runSkeletonDriftCheck() {
17806
17785
  process.exit(1);
17807
17786
  }
17808
17787
  const violations = skeletons.flatMap(
17809
- (name) => auditSkeleton(join72(root, "_skeletons", name), name)
17788
+ (name) => auditSkeleton(join73(root, "_skeletons", name), name)
17810
17789
  );
17811
17790
  if (violations.length > 0) {
17812
17791
  console.error("\u2717 Skeleton-drift guard: drift found between this repo and its scaffolding\n");
@@ -18007,8 +17986,8 @@ function rawArgsAfter(subcommand) {
18007
17986
  }
18008
17987
 
18009
17988
  // src/commands/doctor.ts
18010
- import { existsSync as existsSync61, readFileSync as readFileSync50 } from "fs";
18011
- import { join as join74, resolve as resolve23 } from "path";
17989
+ import { existsSync as existsSync62, readFileSync as readFileSync50 } from "fs";
17990
+ import { join as join75, resolve as resolve23 } from "path";
18012
17991
  import chalk21 from "chalk";
18013
17992
  import { Command as Command27 } from "commander";
18014
17993
 
@@ -18349,11 +18328,11 @@ async function reapAllBareBranches(cwd, branches, worktrees, currentBranch, deps
18349
18328
 
18350
18329
  // src/lib/scratch-clone-scan.ts
18351
18330
  import { readdirSync as readdirSync29, statSync as statSync19 } from "fs";
18352
- import { join as join73 } from "path";
18331
+ import { join as join74 } from "path";
18353
18332
  var INTEGRATION_BRANCH = "dev";
18354
18333
  function isPlainCloneDir(path) {
18355
18334
  try {
18356
- return statSync19(join73(path, ".git")).isDirectory();
18335
+ return statSync19(join74(path, ".git")).isDirectory();
18357
18336
  } catch {
18358
18337
  return false;
18359
18338
  }
@@ -18368,7 +18347,7 @@ async function findScratchCloneCandidates(estateRoot, deps) {
18368
18347
  const names = readdirSync29(estateRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
18369
18348
  const candidates = [];
18370
18349
  for (const name of names) {
18371
- const path = join73(estateRoot, name);
18350
+ const path = join74(estateRoot, name);
18372
18351
  if (!isPlainCloneDir(path)) continue;
18373
18352
  let branch;
18374
18353
  try {
@@ -18548,8 +18527,8 @@ function printScratchCloneReports(estateRoot, reports) {
18548
18527
  );
18549
18528
  }
18550
18529
  function readLocalCoreVersion(cwd) {
18551
- const path = join74(cwd, INSTANCE_CORE_FILE);
18552
- if (!existsSync61(path)) return null;
18530
+ const path = join75(cwd, INSTANCE_CORE_FILE);
18531
+ if (!existsSync62(path)) return null;
18553
18532
  try {
18554
18533
  return extractVersionField(readFileSync50(path, "utf8"));
18555
18534
  } catch {
@@ -18571,8 +18550,8 @@ function extractVersionField(contents) {
18571
18550
  return match?.[1] ?? null;
18572
18551
  }
18573
18552
  function readFossil(cwd) {
18574
- const path = join74(cwd, CORE_VERSION_FILE);
18575
- if (!existsSync61(path)) return null;
18553
+ const path = join75(cwd, CORE_VERSION_FILE);
18554
+ if (!existsSync62(path)) return null;
18576
18555
  try {
18577
18556
  const value = readFileSync50(path, "utf8").trim();
18578
18557
  return value === "" ? null : value;