@biffo/cli 0.324.4 → 0.324.6

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 +389 -375
  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,8 +9788,8 @@ 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
9794
  function readTomlStringArray(text, key) {
9724
9795
  const open = new RegExp(`^${key}\\s*=\\s*\\[`, "m").exec(text);
@@ -9744,24 +9815,25 @@ function readTomlStringArray(text, key) {
9744
9815
  }
9745
9816
  return depth === 0 ? strings : [];
9746
9817
  }
9818
+ function normaliseName(name) {
9819
+ return name.replace(/[-_.]+/g, "-").toLowerCase();
9820
+ }
9747
9821
  function readProjectName(text) {
9748
- let inProject = false;
9749
- for (const line of text.split("\n")) {
9750
- const trimmed = line.trim();
9751
- if (trimmed.startsWith("[")) {
9752
- inProject = trimmed === "[project]";
9753
- continue;
9754
- }
9755
- if (inProject) {
9756
- const m = /^name\s*=\s*["']([^"']+)["']/.exec(trimmed);
9757
- if (m) return m[1];
9758
- }
9822
+ let doc;
9823
+ try {
9824
+ doc = parseToml(text);
9825
+ } catch {
9826
+ return null;
9759
9827
  }
9760
- return null;
9828
+ const name = isTable(doc.project) ? doc.project.name : void 0;
9829
+ return typeof name === "string" && name !== "" ? name : null;
9761
9830
  }
9762
9831
  function requirementName(requirement) {
9763
9832
  return /^\s*([A-Za-z0-9._-]+)/.exec(requirement)?.[1] ?? null;
9764
9833
  }
9834
+ function stringsIn(value) {
9835
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
9836
+ }
9765
9837
  function isTable(value) {
9766
9838
  return typeof value === "object" && value !== null && !Array.isArray(value);
9767
9839
  }
@@ -9851,18 +9923,21 @@ function isSourcesHeader(header) {
9851
9923
  return isTable(node) && Object.keys(node).length === 0;
9852
9924
  }
9853
9925
  function workspaceMemberNames(instanceRoot) {
9854
- const rootPyproject = join30(instanceRoot, "pyproject.toml");
9855
- if (!existsSync30(rootPyproject)) return /* @__PURE__ */ new Set();
9856
- const text = readFileSync21(rootPyproject, "utf8");
9857
- const members = readTomlStringArray(text, "members");
9858
- const excluded = new Set(readTomlStringArray(text, "exclude"));
9926
+ const rootPyproject = join32(instanceRoot, "pyproject.toml");
9927
+ if (!existsSync31(rootPyproject)) return /* @__PURE__ */ new Set();
9928
+ const doc = parsePyproject(readFileSync21(rootPyproject, "utf8"), rootPyproject);
9929
+ const tool = isTable(doc.tool) ? doc.tool : {};
9930
+ const uv = isTable(tool.uv) ? tool.uv : {};
9931
+ const workspace = isTable(uv.workspace) ? uv.workspace : {};
9932
+ const members = stringsIn(workspace.members);
9933
+ const excluded = new Set(stringsIn(workspace.exclude));
9859
9934
  const dirs = [];
9860
9935
  for (const member of members) {
9861
9936
  if (member.endsWith("/*")) {
9862
9937
  const base = member.slice(0, -2);
9863
9938
  let entries;
9864
9939
  try {
9865
- entries = readdirSync11(join30(instanceRoot, base), { withFileTypes: true });
9940
+ entries = readdirSync11(join32(instanceRoot, base), { withFileTypes: true });
9866
9941
  } catch {
9867
9942
  continue;
9868
9943
  }
@@ -9876,24 +9951,23 @@ function workspaceMemberNames(instanceRoot) {
9876
9951
  }
9877
9952
  const names = /* @__PURE__ */ new Set();
9878
9953
  for (const dir of dirs) {
9879
- const pp = join30(instanceRoot, dir, "pyproject.toml");
9880
- if (!existsSync30(pp)) continue;
9954
+ const pp = join32(instanceRoot, dir, "pyproject.toml");
9955
+ if (!existsSync31(pp)) continue;
9881
9956
  const name = readProjectName(readFileSync21(pp, "utf8"));
9882
- if (name) names.add(name);
9957
+ if (name) names.add(normaliseName(name));
9883
9958
  }
9884
9959
  return names;
9885
9960
  }
9886
9961
  function ensureWorkspaceSources(pluginPyprojectPath, memberNames) {
9887
- if (!existsSync30(pluginPyprojectPath) || memberNames.size === 0) return [];
9962
+ if (!existsSync31(pluginPyprojectPath) || memberNames.size === 0) return [];
9888
9963
  const text = readFileSync21(pluginPyprojectPath, "utf8");
9889
9964
  const doc = parsePyproject(text, pluginPyprojectPath);
9890
- const already = existingSourceNames(doc);
9891
- const declared = new Set(readDeclaredDependencyNames(doc));
9892
- const toAdd = [...declared].filter((n) => memberNames.has(n) && !already.has(n));
9965
+ const members = new Set([...memberNames].map(normaliseName));
9966
+ const already = new Set([...existingSourceNames(doc)].map(normaliseName));
9967
+ const declared = new Set(readDeclaredDependencyNames(doc).map(normaliseName));
9968
+ const toAdd = [...declared].filter((n) => members.has(n) && !already.has(n));
9893
9969
  if (toAdd.length === 0) return [];
9894
- const lines = toAdd.map(
9895
- (n) => `${/^[A-Za-z0-9_-]+$/.test(n) ? n : JSON.stringify(n)} = { workspace = true }`
9896
- );
9970
+ const lines = toAdd.map((n) => `${n} = { workspace = true }`);
9897
9971
  let updated;
9898
9972
  if (hasSourcesTable(doc)) {
9899
9973
  const insertAt = sourcesHeaderLineEnd(text);
@@ -9916,7 +9990,7 @@ ${lines.join("\n")}
9916
9990
  }
9917
9991
  let written = /* @__PURE__ */ new Set();
9918
9992
  try {
9919
- written = existingSourceNames(parseToml(updated));
9993
+ written = new Set([...existingSourceNames(parseToml(updated))].map(normaliseName));
9920
9994
  } catch {
9921
9995
  }
9922
9996
  const missing = toAdd.filter((n) => !written.has(n));
@@ -9941,8 +10015,8 @@ function parsePyproject(text, path) {
9941
10015
  }
9942
10016
  }
9943
10017
  function applyWorkspaceSources(targetDir, cwd, relTargetDir) {
9944
- const pluginPyproject = join30(targetDir, "pyproject.toml");
9945
- if (!existsSync30(pluginPyproject)) return [];
10018
+ const pluginPyproject = join32(targetDir, "pyproject.toml");
10019
+ if (!existsSync31(pluginPyproject)) return [];
9946
10020
  const sourced = ensureWorkspaceSources(pluginPyproject, workspaceMemberNames(cwd));
9947
10021
  if (sourced.length > 0) {
9948
10022
  log.info(
@@ -9956,14 +10030,14 @@ function applyWorkspaceSources(targetDir, cwd, relTargetDir) {
9956
10030
  import {
9957
10031
  chmodSync as chmodSync2,
9958
10032
  copyFileSync,
9959
- existsSync as existsSync31,
10033
+ existsSync as existsSync32,
9960
10034
  mkdirSync as mkdirSync9,
9961
10035
  readFileSync as readFileSync22,
9962
10036
  readdirSync as readdirSync12,
9963
10037
  statSync as statSync7,
9964
10038
  writeFileSync as writeFileSync10
9965
10039
  } from "fs";
9966
- import { dirname as dirname9, join as join31 } from "path";
10040
+ import { dirname as dirname9, join as join33 } from "path";
9967
10041
  var STANDALONE_ONLY_ENTRIES = {
9968
10042
  ".github": "standalone-repo CI/release workflows \u2014 the host monorepo already runs lint/type/test/security over services/",
9969
10043
  "registry-schema.json": "the plugin-registry publishing schema, used when submitting a *published* plugin to the registry repo, not by an in-tree plugin",
@@ -10017,10 +10091,10 @@ function applySubstitutions(text, names) {
10017
10091
  var BINARY_EXTENSIONS = /\.(png|jpe?g|gif|ico|woff2?|ttf|zip|gz)$/i;
10018
10092
  function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10019
10093
  const layout = options.layout ?? "in-tree";
10020
- if (!existsSync31(skeletonRoot)) {
10094
+ if (!existsSync32(skeletonRoot)) {
10021
10095
  throw new Error(`Plugin skeleton not found at ${skeletonRoot}`);
10022
10096
  }
10023
- if (!existsSync31(join31(skeletonRoot, "terraform"))) {
10097
+ if (!existsSync32(join33(skeletonRoot, "terraform"))) {
10024
10098
  throw new Error(
10025
10099
  `Plugin skeleton at ${skeletonRoot} has no terraform/ directory. Refusing to scaffold a plugin that cannot receive events (issue #194) \u2014 the skeleton is broken.`
10026
10100
  );
@@ -10028,7 +10102,7 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10028
10102
  const skipped = [];
10029
10103
  const files = [];
10030
10104
  const walk2 = (relDir) => {
10031
- const absDir = join31(skeletonRoot, relDir);
10105
+ const absDir = join33(skeletonRoot, relDir);
10032
10106
  for (const entry of readdirSync12(absDir, { withFileTypes: true }).sort(
10033
10107
  (a, b) => a.name.localeCompare(b.name)
10034
10108
  )) {
@@ -10043,9 +10117,9 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10043
10117
  continue;
10044
10118
  }
10045
10119
  const destRel = applySubstitutions(relPath, names);
10046
- const destPath = join31(destDir, destRel);
10120
+ const destPath = join33(destDir, destRel);
10047
10121
  mkdirSync9(dirname9(destPath), { recursive: true });
10048
- const srcPath = join31(skeletonRoot, relPath);
10122
+ const srcPath = join33(skeletonRoot, relPath);
10049
10123
  if (BINARY_EXTENSIONS.test(entry.name)) {
10050
10124
  copyFileSync(srcPath, destPath);
10051
10125
  } else {
@@ -10066,8 +10140,8 @@ function scaffoldPlugin(skeletonRoot, destDir, names, options = {}) {
10066
10140
  function findSkeletonRoot(startDir, skeleton) {
10067
10141
  let dir = startDir;
10068
10142
  for (; ; ) {
10069
- const candidate = join31(dir, "_skeletons", skeleton);
10070
- if (existsSync31(candidate)) return candidate;
10143
+ const candidate = join33(dir, "_skeletons", skeleton);
10144
+ if (existsSync32(candidate)) return candidate;
10071
10145
  const parent = dirname9(dir);
10072
10146
  if (parent === dir) return null;
10073
10147
  dir = parent;
@@ -10135,7 +10209,7 @@ async function runPluginCreate(name, options, deps) {
10135
10209
  reportBranchProtectionSummary();
10136
10210
  return;
10137
10211
  }
10138
- const isInstance = existsSync32(join32(options.cwd, INSTANCE_CORE_FILE));
10212
+ const isInstance = existsSync33(join34(options.cwd, INSTANCE_CORE_FILE));
10139
10213
  if (options.firstParty && isInstance) {
10140
10214
  throw new Error(
10141
10215
  `--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.`
@@ -10143,19 +10217,19 @@ async function runPluginCreate(name, options, deps) {
10143
10217
  }
10144
10218
  const channel = options.firstParty ? "first-party" : "third-party";
10145
10219
  const relDir = pluginDir(names.slug, channel);
10146
- const destDir = join32(options.cwd, relDir);
10147
- const servicesDir = join32(options.cwd, "services");
10148
- if (!existsSync32(servicesDir)) {
10220
+ const destDir = join34(options.cwd, relDir);
10221
+ const servicesDir = join34(options.cwd, "services");
10222
+ if (!existsSync33(servicesDir)) {
10149
10223
  throw new Error(
10150
10224
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
10151
10225
  );
10152
10226
  }
10153
- if (existsSync32(destDir)) {
10227
+ if (existsSync33(destDir)) {
10154
10228
  throw new Error(`${relDir}/ already exists. Choose a different name, or remove it first.`);
10155
10229
  }
10156
10230
  const here = dirname10(fileURLToPath6(import.meta.url));
10157
- const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join32(options.cwd, "_skeletons", "plugin-template");
10158
- if (!existsSync32(skeletonRoot)) {
10231
+ const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join34(options.cwd, "_skeletons", "plugin-template");
10232
+ if (!existsSync33(skeletonRoot)) {
10159
10233
  throw new Error(
10160
10234
  `Could not find the plugin skeleton (_skeletons/plugin-template/). Pass --skeleton <path> to point at it explicitly.`
10161
10235
  );
@@ -10170,7 +10244,7 @@ async function runPluginCreate(name, options, deps) {
10170
10244
  for (const { entry, reason } of skipped) {
10171
10245
  log.info(`Skipped ${entry} \u2014 ${reason}`);
10172
10246
  }
10173
- const manifestPath = join32(destDir, "biffo.plugin.json");
10247
+ const manifestPath = join34(destDir, "biffo.plugin.json");
10174
10248
  const manifest = validateManifest(JSON.parse(readFileSync23(manifestPath, "utf8")));
10175
10249
  if (manifest.name !== names.slug) {
10176
10250
  throw new Error(
@@ -10188,15 +10262,14 @@ async function runPluginCreate(name, options, deps) {
10188
10262
  );
10189
10263
  }
10190
10264
  const commitMessage = `feat(plugins): scaffold ${names.slug} plugin`;
10191
- await deps.git.add(options.cwd, [relDir]);
10192
- await deps.git.commit(options.cwd, commitMessage, [relDir]);
10265
+ await commitPluginChange(deps, options.cwd, [relDir], commitMessage);
10193
10266
  log.success(`Committed: ${commitMessage}`);
10194
10267
  }
10195
10268
  printNextSteps(names, relDir, channel);
10196
10269
  }
10197
10270
  async function runStandaloneCreate(names, options, deps) {
10198
- const destDir = join32(options.cwd, names.dist);
10199
- if (existsSync32(destDir)) {
10271
+ const destDir = join34(options.cwd, names.dist);
10272
+ if (existsSync33(destDir)) {
10200
10273
  throw new Error(`${names.dist}/ already exists. Choose a different name, or remove it first.`);
10201
10274
  }
10202
10275
  const skeletonRoot = resolveSkeletonRoot(options);
@@ -10214,7 +10287,7 @@ async function runStandaloneCreate(names, options, deps) {
10214
10287
  restorePackagedDotfiles(destDir);
10215
10288
  log.success(`Scaffolded ${String(files.length)} file(s) into ${names.dist}/`);
10216
10289
  const manifest = validateManifest(
10217
- JSON.parse(readFileSync23(join32(destDir, "biffo.plugin.json"), "utf8"))
10290
+ JSON.parse(readFileSync23(join34(destDir, "biffo.plugin.json"), "utf8"))
10218
10291
  );
10219
10292
  if (manifest.name !== names.slug) {
10220
10293
  throw new Error(
@@ -10225,12 +10298,12 @@ async function runStandaloneCreate(names, options, deps) {
10225
10298
  `Manifest valid \u2014 ${String(manifest.tables.length)} table(s), ${String(manifest.api_routes.length)} route(s)`
10226
10299
  );
10227
10300
  writeFileSync11(
10228
- join32(destDir, ".biffo-shared-version"),
10301
+ join34(destDir, ".biffo-shared-version"),
10229
10302
  `core-v${getLatestCoreVersion().replace(/^core-v/, "")}
10230
10303
  `
10231
10304
  );
10232
10305
  if (options.commit) {
10233
- if (!existsSync32(join32(destDir, "uv.lock"))) {
10306
+ if (!existsSync33(join34(destDir, "uv.lock"))) {
10234
10307
  throw new Error(
10235
10308
  `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.`
10236
10309
  );
@@ -10263,8 +10336,8 @@ async function createAndPushStandaloneRepo(org, names, destDir, options, deps) {
10263
10336
  await deps.git.push(destDir, "dev", { token });
10264
10337
  log.success(`Pushed dev to ${org}/${names.dist}`);
10265
10338
  await github.setDefaultBranch(org, names.dist, "dev");
10266
- const ciPath = join32(destDir, ".github", "workflows", "ci.yml");
10267
- const contexts = existsSync32(ciPath) ? workflowCheckContexts(readFileSync23(ciPath, "utf8")) : [];
10339
+ const ciPath = join34(destDir, ".github", "workflows", "ci.yml");
10340
+ const contexts = existsSync33(ciPath) ? workflowCheckContexts(readFileSync23(ciPath, "utf8")) : [];
10268
10341
  if (contexts.length === 0) {
10269
10342
  log.warn(
10270
10343
  `Could not determine required status checks from ${ciPath} \u2014 skipping branch protection. Configure it manually on dev once you know the CI job names.`
@@ -10293,7 +10366,7 @@ async function registerInRegistrySources(names, cloneUrl, token, deps) {
10293
10366
  let dir;
10294
10367
  try {
10295
10368
  dir = await deps.git.cloneForEditing(REGISTRY_REPO, "biffo-registry", token);
10296
- const path = join32(dir, "sources.json");
10369
+ const path = join34(dir, "sources.json");
10297
10370
  const file = JSON.parse(readFileSync23(path, "utf8"));
10298
10371
  const next = addSource(file, {
10299
10372
  name: names.slug,
@@ -10404,8 +10477,8 @@ function printStandaloneNextSteps(names, minor) {
10404
10477
  }
10405
10478
  function resolveSkeletonRoot(options) {
10406
10479
  const here = dirname10(fileURLToPath6(import.meta.url));
10407
- const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join32(options.cwd, "_skeletons", "plugin-template");
10408
- if (!existsSync32(skeletonRoot)) {
10480
+ const skeletonRoot = options.skeletonRoot ?? findSkeletonRoot(here, "plugin-template") ?? join34(options.cwd, "_skeletons", "plugin-template");
10481
+ if (!existsSync33(skeletonRoot)) {
10409
10482
  throw new Error(
10410
10483
  `Could not find the plugin skeleton (_skeletons/plugin-template/). Pass --skeleton <path> to point at it explicitly.`
10411
10484
  );
@@ -10635,68 +10708,14 @@ function printScopeSeamEntitlement(name) {
10635
10708
  }
10636
10709
 
10637
10710
  // src/commands/plugin-install.ts
10638
- import { cpSync as cpSync5, existsSync as existsSync36, mkdirSync as mkdirSync12, readFileSync as readFileSync26, statSync as statSync8, writeFileSync as writeFileSync14 } from "fs";
10639
- import { join as join38, relative as relative4, resolve as resolve14 } from "path";
10711
+ import { cpSync as cpSync5, existsSync as existsSync37, mkdirSync as mkdirSync12, readFileSync as readFileSync26, statSync as statSync8, writeFileSync as writeFileSync14 } from "fs";
10712
+ import { join as join39, relative as relative4, resolve as resolve14 } from "path";
10640
10713
  import chalk15 from "chalk";
10641
10714
  import { Command as Command16 } from "commander";
10642
10715
 
10643
- // src/adapters/plugin-migrations/index.ts
10644
- import { join as join33 } from "path";
10645
- var PluginMigrationsAdapter = class {
10646
- /**
10647
- * Generates migration file(s) for `pluginNames` (every discovered
10648
- * installed plugin if omitted), returning the absolute path of each newly
10649
- * generated file — empty if every named plugin already had a migration,
10650
- * or declared no tables.
10651
- */
10652
- async generate(cwd, pluginNames) {
10653
- const scriptPath = join33(cwd, "services", "api", "scripts", "generate_plugin_migrations.py");
10654
- const args = [
10655
- "run",
10656
- "python",
10657
- scriptPath,
10658
- "--services-root",
10659
- join33(cwd, "services"),
10660
- "--versions-dir",
10661
- join33(cwd, "services", "api", "migrations", "versions")
10662
- ];
10663
- for (const name of pluginNames ?? []) {
10664
- args.push("--plugin", name);
10665
- }
10666
- const result = await runUv(args, join33(cwd, "services", "api"), {
10667
- 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).",
10668
- failed: "Failed to generate plugin migration"
10669
- });
10670
- return result.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
10671
- }
10672
- /**
10673
- * Brings the instance's root `uv.lock` in step with its workspace (`uv lock`).
10674
- *
10675
- * `plugin install` adds a member to the uv workspace, so the committed lock is stale the moment the plugin lands — whether or
10676
- * not the plugin has tables (only a table-bearing plugin runs `uv run` for a migration, which is a side effect that happens to
10677
- * re-lock). Locking explicitly, then staging the result, is what makes `uv lock --check` pass on the install commit
10678
- * (biffo-template#2106); leaving it to whichever `uv run` came last is how the no-tables install shipped a stale lock.
10679
- */
10680
- async refreshLock(cwd) {
10681
- await runUv(["lock"], cwd, {
10682
- 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.",
10683
- failed: "Failed to refresh uv.lock (`uv lock`)"
10684
- });
10685
- }
10686
- };
10687
- async function runUv(args, cwd, messages) {
10688
- try {
10689
- return await execa("uv", args, { cwd });
10690
- } catch (err) {
10691
- const cause = err;
10692
- if (cause.code === "ENOENT") throw new Error(messages.missing);
10693
- throw new Error(`${messages.failed}: ${cause.stderr?.trim() || err.message}`);
10694
- }
10695
- }
10696
-
10697
10716
  // src/lib/plugin-frontend-registry.ts
10698
- import { existsSync as existsSync33, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
10699
- import { join as join34 } from "path";
10717
+ import { existsSync as existsSync34, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
10718
+ import { join as join35 } from "path";
10700
10719
  var PLUGIN_REGISTRY_RELATIVE_PATH = "apps/frontend/src/lib/plugins.ts";
10701
10720
  var REGISTRY_START_MARKER = "// BIFFO-PLUGIN-REGISTRY:START \u2014 managed by `biffo plugin install`/`uninstall`. Do not hand-edit.";
10702
10721
  var REGISTRY_END_MARKER = "// BIFFO-PLUGIN-REGISTRY:END";
@@ -10707,7 +10726,7 @@ function frontendUrlForSlug(slug) {
10707
10726
  return `/api/v1/plugins/${slug}/ui`;
10708
10727
  }
10709
10728
  function registryPath2(cwd) {
10710
- return join34(cwd, PLUGIN_REGISTRY_RELATIVE_PATH);
10729
+ return join35(cwd, PLUGIN_REGISTRY_RELATIVE_PATH);
10711
10730
  }
10712
10731
  function missingRegistryError(cwd, pluginSlug) {
10713
10732
  return new Error(
@@ -10784,7 +10803,7 @@ function assertPluginRegistryReady(cwd, pluginSlug) {
10784
10803
  }
10785
10804
  function readManagedEntries(cwd, pluginSlug) {
10786
10805
  const path = registryPath2(cwd);
10787
- if (!existsSync33(path)) throw missingRegistryError(cwd, pluginSlug);
10806
+ if (!existsSync34(path)) throw missingRegistryError(cwd, pluginSlug);
10788
10807
  const source = readFileSync24(path, "utf8");
10789
10808
  const found = findManagedRegion(source);
10790
10809
  if (!found) throw malformedRegistryError(cwd, pluginSlug);
@@ -10808,8 +10827,8 @@ function removePluginRegistryEntry(cwd, pluginSlug) {
10808
10827
  }
10809
10828
 
10810
10829
  // src/lib/plugin-provenance.ts
10811
- import { existsSync as existsSync34, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
10812
- import { join as join35 } from "path";
10830
+ import { existsSync as existsSync35, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
10831
+ import { join as join36 } from "path";
10813
10832
  var PLUGIN_PROVENANCE_FILENAME = ".biffo-plugin-provenance.json";
10814
10833
  function isPluginProvenance(value) {
10815
10834
  if (typeof value !== "object" || value === null) return false;
@@ -10817,8 +10836,8 @@ function isPluginProvenance(value) {
10817
10836
  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";
10818
10837
  }
10819
10838
  function readProvenance(pluginDir2) {
10820
- const path = join35(pluginDir2, PLUGIN_PROVENANCE_FILENAME);
10821
- if (!existsSync34(path)) return { status: "absent" };
10839
+ const path = join36(pluginDir2, PLUGIN_PROVENANCE_FILENAME);
10840
+ if (!existsSync35(path)) return { status: "absent" };
10822
10841
  let parsed;
10823
10842
  try {
10824
10843
  parsed = JSON.parse(readFileSync25(path, "utf8"));
@@ -10837,7 +10856,7 @@ function readProvenance(pluginDir2) {
10837
10856
  return { status: "present", record: parsed };
10838
10857
  }
10839
10858
  function writePluginProvenance(pluginDir2, record) {
10840
- writeFileSync13(join35(pluginDir2, PLUGIN_PROVENANCE_FILENAME), `${JSON.stringify(record, null, 2)}
10859
+ writeFileSync13(join36(pluginDir2, PLUGIN_PROVENANCE_FILENAME), `${JSON.stringify(record, null, 2)}
10841
10860
  `);
10842
10861
  }
10843
10862
  function reconcileProvenance(previous, next) {
@@ -10887,8 +10906,8 @@ async function tryGit(cwd, args) {
10887
10906
  }
10888
10907
 
10889
10908
  // src/lib/plugin-seed-vendor.ts
10890
- import { cpSync as cpSync3, existsSync as existsSync35, mkdirSync as mkdirSync10, readdirSync as readdirSync13, rmSync as rmSync9 } from "fs";
10891
- import { join as join36 } from "path";
10909
+ import { cpSync as cpSync3, existsSync as existsSync36, mkdirSync as mkdirSync10, readdirSync as readdirSync13, rmSync as rmSync9 } from "fs";
10910
+ import { join as join37 } from "path";
10892
10911
  var VENDOR_PREFIX = "_plugin-";
10893
10912
  function pluginSeedImportDir(pluginName) {
10894
10913
  return `db/imports/${VENDOR_PREFIX}${pluginName}`;
@@ -10897,8 +10916,8 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10897
10916
  if (!manifest.seed) {
10898
10917
  return { vendored: false };
10899
10918
  }
10900
- const sourceSeedDir = join36(pluginSourceDir, manifest.seed.dir);
10901
- if (!existsSync35(sourceSeedDir)) {
10919
+ const sourceSeedDir = join37(pluginSourceDir, manifest.seed.dir);
10920
+ if (!existsSync36(sourceSeedDir)) {
10902
10921
  throw new Error(
10903
10922
  `${manifest.name}'s manifest declares seed.dir '${manifest.seed.dir}', but ${sourceSeedDir} does not exist in the plugin's source.`
10904
10923
  );
@@ -10910,11 +10929,11 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10910
10929
  );
10911
10930
  }
10912
10931
  const relTargetDir = pluginSeedImportDir(manifest.name);
10913
- const targetDir = join36(cwd, relTargetDir);
10932
+ const targetDir = join37(cwd, relTargetDir);
10914
10933
  rmSync9(targetDir, { recursive: true, force: true });
10915
10934
  mkdirSync10(targetDir, { recursive: true });
10916
10935
  for (const file of sqlFiles) {
10917
- cpSync3(join36(sourceSeedDir, file), join36(targetDir, file));
10936
+ cpSync3(join37(sourceSeedDir, file), join37(targetDir, file));
10918
10937
  }
10919
10938
  log.success(
10920
10939
  `Vendored ${sqlFiles.length} seed file(s) to ${relTargetDir}/ (baseline_tables: ${manifest.seed.baseline_tables.join(", ") || "none declared"})`
@@ -10927,7 +10946,7 @@ function vendorPluginSeed(pluginSourceDir, manifest, cwd) {
10927
10946
 
10928
10947
  // src/lib/plugin-source-copy.ts
10929
10948
  import { copyFileSync as copyFileSync2, cpSync as cpSync4, mkdirSync as mkdirSync11 } from "fs";
10930
- import { basename as basename2, dirname as dirname11, join as join37 } from "path";
10949
+ import { basename as basename2, dirname as dirname11, join as join38 } from "path";
10931
10950
  var LOCAL_COPY_EXCLUDES = /* @__PURE__ */ new Set([
10932
10951
  ".git",
10933
10952
  ".venv",
@@ -10943,9 +10962,9 @@ async function copyPluginSource(sourceDir, targetDir) {
10943
10962
  if (await isGitWorkingTree2(sourceDir)) {
10944
10963
  const files = await listGitFiles(sourceDir);
10945
10964
  for (const relPath of files) {
10946
- const destPath = join37(targetDir, relPath);
10965
+ const destPath = join38(targetDir, relPath);
10947
10966
  mkdirSync11(dirname11(destPath), { recursive: true });
10948
- copyFileSync2(join37(sourceDir, relPath), destPath);
10967
+ copyFileSync2(join38(sourceDir, relPath), destPath);
10949
10968
  }
10950
10969
  return { usedGitIgnoreRules: true };
10951
10970
  }
@@ -11017,14 +11036,14 @@ var pluginInstallCommand = new Command16("install").description(
11017
11036
  }
11018
11037
  );
11019
11038
  function resolveLocalPlugin(localPath) {
11020
- if (!existsSync36(localPath)) {
11039
+ if (!existsSync37(localPath)) {
11021
11040
  throw new Error(`--local path does not exist: ${localPath}`);
11022
11041
  }
11023
11042
  if (!statSync8(localPath).isDirectory()) {
11024
11043
  throw new Error(`--local path is not a directory: ${localPath}`);
11025
11044
  }
11026
- const manifestPath = join38(localPath, "biffo.plugin.json");
11027
- if (!existsSync36(manifestPath)) {
11045
+ const manifestPath = join39(localPath, "biffo.plugin.json");
11046
+ if (!existsSync37(manifestPath)) {
11028
11047
  throw new Error(
11029
11048
  `${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>\`.)`
11030
11049
  );
@@ -11050,8 +11069,8 @@ function parsePluginTarget(target) {
11050
11069
  async function cloneAndValidatePlugin(entry, git) {
11051
11070
  const tmpDir = await git.cloneToTemp(entry.repo, `biffo-plugin-${entry.name}`);
11052
11071
  try {
11053
- const manifestPath = join38(tmpDir, "biffo.plugin.json");
11054
- if (!existsSync36(manifestPath)) {
11072
+ const manifestPath = join39(tmpDir, "biffo.plugin.json");
11073
+ if (!existsSync37(manifestPath)) {
11055
11074
  throw new Error(
11056
11075
  `Plugin repo ${entry.repo} does not contain a biffo.plugin.json manifest at its root.`
11057
11076
  );
@@ -11079,8 +11098,8 @@ async function runPluginInstall(target, options, deps) {
11079
11098
  `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\`).`
11080
11099
  );
11081
11100
  }
11082
- const servicesDir = join38(options.cwd, "services");
11083
- if (!existsSync36(servicesDir)) {
11101
+ const servicesDir = join39(options.cwd, "services");
11102
+ if (!existsSync37(servicesDir)) {
11084
11103
  throw new Error(
11085
11104
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11086
11105
  );
@@ -11098,11 +11117,11 @@ async function runPluginInstall(target, options, deps) {
11098
11117
  }
11099
11118
  const pluginName = entry ? entry.name : source.name;
11100
11119
  const relTargetDir = pluginDir(pluginName, "third-party");
11101
- const targetDir = join38(options.cwd, relTargetDir);
11102
- const modulesDir = join38(options.cwd, "modules", "plugins", pluginName);
11120
+ const targetDir = join39(options.cwd, relTargetDir);
11121
+ const modulesDir = join39(options.cwd, "modules", "plugins", pluginName);
11103
11122
  const registryCwd = options.frontendCwd ?? options.cwd;
11104
11123
  const inTreeSource = options.local !== void 0 && resolve14(options.local) === resolve14(targetDir);
11105
- if (existsSync36(targetDir) && !inTreeSource) {
11124
+ if (existsSync37(targetDir) && !inTreeSource) {
11106
11125
  throw new Error(
11107
11126
  `Plugin '${pluginName}' is already installed at ${relTargetDir}/. Remove it first, or wait for a future 'biffo plugin upgrade' command.`
11108
11127
  );
@@ -11142,7 +11161,7 @@ async function runPluginInstall(target, options, deps) {
11142
11161
  log.success(
11143
11162
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
11144
11163
  );
11145
- const retiredShapeReasons = findRetiredFrontendShape(join38(source.sourceDir, "terraform"));
11164
+ const retiredShapeReasons = findRetiredFrontendShape(join39(source.sourceDir, "terraform"));
11146
11165
  if (retiredShapeReasons.length > 0) {
11147
11166
  throw new Error(retiredFrontendShapeError(pluginName, retiredShapeReasons));
11148
11167
  }
@@ -11179,13 +11198,13 @@ async function runPluginInstall(target, options, deps) {
11179
11198
  writePluginProvenance(targetDir, reconcileProvenance(previousProvenance, nextProvenance));
11180
11199
  const sourced = applyWorkspaceSources(targetDir, options.cwd, relTargetDir);
11181
11200
  if (inTreeSource && sourced.length > 0) left.core.written.push(`${relTargetDir}/pyproject.toml`);
11182
- const stagePaths = [relTargetDir];
11201
+ let stagePaths = [relTargetDir];
11183
11202
  const track = (...paths) => {
11184
11203
  stagePaths.push(...paths);
11185
11204
  left.core.written.push(...paths);
11186
11205
  };
11187
- const tfSourceDir = join38(targetDir, "terraform");
11188
- if (existsSync36(tfSourceDir)) {
11206
+ const tfSourceDir = join39(targetDir, "terraform");
11207
+ if (existsSync37(tfSourceDir)) {
11189
11208
  mkdirSync12(modulesDir, { recursive: true });
11190
11209
  cpSync5(tfSourceDir, modulesDir, { recursive: true });
11191
11210
  track(`modules/plugins/${pluginName}`);
@@ -11233,7 +11252,7 @@ async function runPluginInstall(target, options, deps) {
11233
11252
  track(seedResult.stagedPath);
11234
11253
  }
11235
11254
  if (manifest.config.length > 0) {
11236
- const configFilePath = join38(targetDir, "biffo.plugin-config.json");
11255
+ const configFilePath = join39(targetDir, "biffo.plugin-config.json");
11237
11256
  writeFileSync14(
11238
11257
  configFilePath,
11239
11258
  JSON.stringify(
@@ -11257,10 +11276,7 @@ async function runPluginInstall(target, options, deps) {
11257
11276
  `Recorded ${configSupply.resolved.length}/${manifest.config.length} declared config value(s) at ${relative4(options.cwd, configFilePath)}`
11258
11277
  );
11259
11278
  }
11260
- if (existsSync36(join38(options.cwd, "uv.lock"))) {
11261
- await deps.migrations.refreshLock(options.cwd);
11262
- stagePaths.push("uv.lock");
11263
- }
11279
+ stagePaths = await withRefreshedLock(deps, options.cwd, stagePaths);
11264
11280
  if (manifest.user_frontend) {
11265
11281
  upsertPluginRegistryEntry(registryCwd, {
11266
11282
  slug: pluginName,
@@ -11432,8 +11448,8 @@ function printDryRun4(entry, source, relTargetDir, inTreeSource, suppliedConfig
11432
11448
  }
11433
11449
 
11434
11450
  // src/commands/plugin-list.ts
11435
- import { existsSync as existsSync37, readFileSync as readFileSync27 } from "fs";
11436
- import { join as join39, resolve as resolve15 } from "path";
11451
+ import { existsSync as existsSync38, readFileSync as readFileSync27 } from "fs";
11452
+ import { join as join40, resolve as resolve15 } from "path";
11437
11453
  import chalk16 from "chalk";
11438
11454
  import { Command as Command17 } from "commander";
11439
11455
  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) => {
@@ -11446,8 +11462,8 @@ var pluginListCommand = new Command17("list").description("List plugins installe
11446
11462
  }
11447
11463
  });
11448
11464
  async function runPluginList(options) {
11449
- const servicesDir = join39(options.cwd, "services");
11450
- if (!existsSync37(servicesDir)) {
11465
+ const servicesDir = join40(options.cwd, "services");
11466
+ if (!existsSync38(servicesDir)) {
11451
11467
  throw new Error(
11452
11468
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11453
11469
  );
@@ -11496,14 +11512,14 @@ import { resolve as resolve16 } from "path";
11496
11512
  import { Command as Command18 } from "commander";
11497
11513
 
11498
11514
  // src/lib/plugin-staleness.ts
11499
- import { existsSync as existsSync38, readFileSync as readFileSync28, readdirSync as readdirSync14, statSync as statSync9 } from "fs";
11500
- import { join as join40, relative as relative5 } from "path";
11515
+ import { existsSync as existsSync39, readFileSync as readFileSync28, readdirSync as readdirSync14, statSync as statSync9 } from "fs";
11516
+ import { join as join41, relative as relative5 } from "path";
11501
11517
  function discoverVendoredPlugins(servicesDir) {
11502
- if (!existsSync38(servicesDir)) return [];
11503
- 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();
11518
+ if (!existsSync39(servicesDir)) return [];
11519
+ 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();
11504
11520
  }
11505
11521
  async function checkPluginStaleness(cwd, deps) {
11506
- const servicesDir = join40(cwd, "services");
11522
+ const servicesDir = join41(cwd, "services");
11507
11523
  const names = discoverVendoredPlugins(servicesDir);
11508
11524
  let registryRepoByName = null;
11509
11525
  let registryFetchFailure = null;
@@ -11524,7 +11540,7 @@ async function checkPluginStaleness(cwd, deps) {
11524
11540
  };
11525
11541
  const results = [];
11526
11542
  for (const name of names) {
11527
- results.push(await checkOnePlugin(join40(servicesDir, name), name, resolveRegistryRepo, deps.git));
11543
+ results.push(await checkOnePlugin(join41(servicesDir, name), name, resolveRegistryRepo, deps.git));
11528
11544
  }
11529
11545
  return results;
11530
11546
  }
@@ -11550,7 +11566,7 @@ async function checkOnePlugin(pluginDir2, name, resolveRegistryRepo, git) {
11550
11566
  if (record?.sha && isFetchableUrl(record.origin)) {
11551
11567
  return checkViaProvenance(name, record, record.origin, git);
11552
11568
  }
11553
- const localOrigin = record && !isFetchableUrl(record.origin) && existsSync38(record.origin) ? record.origin : null;
11569
+ const localOrigin = record && !isFetchableUrl(record.origin) && existsSync39(record.origin) ? record.origin : null;
11554
11570
  if (localOrigin) {
11555
11571
  return checkViaContentDiff(name, pluginDir2, localOrigin, { isLocalDir: true }, git);
11556
11572
  }
@@ -11702,8 +11718,8 @@ async function countDifferingFiles(sourceDir, pluginDir2) {
11702
11718
  differing++;
11703
11719
  continue;
11704
11720
  }
11705
- const a = readFileSync28(join40(sourceDir, relPath));
11706
- const b = readFileSync28(join40(pluginDir2, relPath));
11721
+ const a = readFileSync28(join41(sourceDir, relPath));
11722
+ const b = readFileSync28(join41(pluginDir2, relPath));
11707
11723
  if (!a.equals(b)) differing++;
11708
11724
  }
11709
11725
  return differing;
@@ -11718,11 +11734,11 @@ function vendorFileList(dir) {
11718
11734
  return new Set(walkExcluding(dir, dir, LOCAL_COPY_EXCLUDES));
11719
11735
  }
11720
11736
  function walkExcluding(root, dir, excludes) {
11721
- if (!existsSync38(dir)) return [];
11737
+ if (!existsSync39(dir)) return [];
11722
11738
  const out = [];
11723
11739
  for (const entry of readdirSync14(dir)) {
11724
11740
  if (excludes.has(entry) || entry === ".git") continue;
11725
- const full = join40(dir, entry);
11741
+ const full = join41(dir, entry);
11726
11742
  let stat;
11727
11743
  try {
11728
11744
  stat = statSync9(full);
@@ -11779,8 +11795,8 @@ var pluginStalenessCommand = new Command18("staleness").description(
11779
11795
  });
11780
11796
 
11781
11797
  // src/commands/plugin-sync-migrations.ts
11782
- import { existsSync as existsSync39 } from "fs";
11783
- import { join as join41, relative as relative6, resolve as resolve17 } from "path";
11798
+ import { existsSync as existsSync40 } from "fs";
11799
+ import { join as join42, relative as relative6, resolve as resolve17 } from "path";
11784
11800
  import chalk17 from "chalk";
11785
11801
  import { Command as Command19 } from "commander";
11786
11802
  var pluginSyncMigrationsCommand = new Command19("sync-migrations").description(
@@ -11801,11 +11817,11 @@ var pluginSyncMigrationsCommand = new Command19("sync-migrations").description(
11801
11817
  }
11802
11818
  );
11803
11819
  async function runPluginSyncMigrations(name, options, deps) {
11804
- const servicesDir = join41(options.cwd, "services");
11805
- if (!existsSync39(servicesDir)) {
11820
+ const servicesDir = join42(options.cwd, "services");
11821
+ if (!existsSync40(servicesDir)) {
11806
11822
  throw new Error(`${servicesDir} does not exist \u2014 is ${options.cwd} a Biffo project checkout?`);
11807
11823
  }
11808
- if (name && !existsSync39(join41(servicesDir, name, "biffo.plugin.json"))) {
11824
+ if (name && !existsSync40(join42(servicesDir, name, "biffo.plugin.json"))) {
11809
11825
  throw new Error(`Plugin '${name}' is not installed at services/${name}/.`);
11810
11826
  }
11811
11827
  if (options.dryRun) {
@@ -11830,10 +11846,9 @@ async function runPluginSyncMigrations(name, options, deps) {
11830
11846
  if (!isRepo) {
11831
11847
  throw new Error(`${options.cwd} is not a git repository \u2014 cannot commit.`);
11832
11848
  }
11833
- await deps.git.add(options.cwd, relativePaths);
11834
11849
  const label = name ?? `${String(generated.length)} plugin(s)`;
11835
11850
  const commitMessage = `chore(plugins): sync migration(s) for ${label}`;
11836
- await deps.git.commit(options.cwd, commitMessage, relativePaths);
11851
+ await commitPluginChange(deps, options.cwd, relativePaths, commitMessage);
11837
11852
  log.success(`Committed: ${commitMessage}`);
11838
11853
  } else {
11839
11854
  log.warn("--no-commit: generated file(s) are on disk but not staged/committed.");
@@ -11841,8 +11856,8 @@ async function runPluginSyncMigrations(name, options, deps) {
11841
11856
  }
11842
11857
 
11843
11858
  // src/commands/plugin-uninstall.ts
11844
- import { existsSync as existsSync40, readFileSync as readFileSync29, rmSync as rmSync10 } from "fs";
11845
- import { join as join42, resolve as resolve18 } from "path";
11859
+ import { existsSync as existsSync41, readFileSync as readFileSync29, rmSync as rmSync10 } from "fs";
11860
+ import { join as join43, resolve as resolve18 } from "path";
11846
11861
  import chalk18 from "chalk";
11847
11862
  import { Command as Command20 } from "commander";
11848
11863
  import inquirer6 from "inquirer";
@@ -11874,16 +11889,16 @@ async function runPluginUninstall(name, options, deps) {
11874
11889
  if (!NAME_PATTERN2.test(name)) {
11875
11890
  throw new Error(`Invalid plugin name '${name}'. Expected a lowercase kebab-case slug.`);
11876
11891
  }
11877
- const servicesDir = join42(options.cwd, "services");
11878
- if (!existsSync40(servicesDir)) {
11892
+ const servicesDir = join43(options.cwd, "services");
11893
+ if (!existsSync41(servicesDir)) {
11879
11894
  throw new Error(
11880
11895
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
11881
11896
  );
11882
11897
  }
11883
- const targetDir = join42(servicesDir, name);
11884
- if (!existsSync40(targetDir)) {
11885
- const firstParty = join42(servicesDir, FIRST_PARTY_PLUGINS_DIR, name);
11886
- if (existsSync40(firstParty)) {
11898
+ const targetDir = join43(servicesDir, name);
11899
+ if (!existsSync41(targetDir)) {
11900
+ const firstParty = join43(servicesDir, FIRST_PARTY_PLUGINS_DIR, name);
11901
+ if (existsSync41(firstParty)) {
11887
11902
  throw new Error(
11888
11903
  `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.`
11889
11904
  );
@@ -11892,9 +11907,9 @@ async function runPluginUninstall(name, options, deps) {
11892
11907
  }
11893
11908
  const installedManifest = readInstalledManifest(targetDir);
11894
11909
  const version = installedManifest?.version;
11895
- const modulesDir = join42(options.cwd, "modules", "plugins", name);
11910
+ const modulesDir = join43(options.cwd, "modules", "plugins", name);
11896
11911
  const stagePaths = [`services/${name}`];
11897
- if (existsSync40(modulesDir)) {
11912
+ if (existsSync41(modulesDir)) {
11898
11913
  stagePaths.push(`modules/plugins/${name}`);
11899
11914
  }
11900
11915
  const hasUserFrontend = installedManifest?.user_frontend !== void 0;
@@ -11921,7 +11936,7 @@ async function runPluginUninstall(name, options, deps) {
11921
11936
  if (hasUserFrontend) {
11922
11937
  assertPluginRegistryReady(options.cwd, name);
11923
11938
  }
11924
- if (existsSync40(modulesDir)) {
11939
+ if (existsSync41(modulesDir)) {
11925
11940
  const refs = findPluginModuleReferences(options.cwd, name).filter(
11926
11941
  (r) => !r.file.endsWith(`/${GENERATED_TF_FILE}`) && r.file !== GENERATED_TF_FILE
11927
11942
  );
@@ -11936,7 +11951,7 @@ Remove the reference(s) above first, then re-run uninstall.`
11936
11951
  }
11937
11952
  rmSync10(targetDir, { recursive: true, force: true });
11938
11953
  log.success(`Removed services/${name}/`);
11939
- if (existsSync40(modulesDir)) {
11954
+ if (existsSync41(modulesDir)) {
11940
11955
  rmSync10(modulesDir, { recursive: true, force: true });
11941
11956
  log.success(`Removed modules/plugins/${name}/`);
11942
11957
  const wiring = syncPluginTerraform(options.cwd);
@@ -11953,8 +11968,7 @@ Remove the reference(s) above first, then re-run uninstall.`
11953
11968
  }
11954
11969
  const label = version ? `${name}@${version}` : name;
11955
11970
  const commitMessage = `chore(plugins): uninstall ${label}`;
11956
- await deps.git.add(options.cwd, stagePaths);
11957
- await deps.git.commit(options.cwd, commitMessage, stagePaths);
11971
+ await commitPluginChange(deps, options.cwd, stagePaths, commitMessage);
11958
11972
  log.success(`Committed: ${commitMessage}`);
11959
11973
  console.log(chalk18.bold("\n Plugin uninstalled!\n"));
11960
11974
  console.log(` services/${name}/ has been removed and committed.`);
@@ -11975,15 +11989,15 @@ Remove the reference(s) above first, then re-run uninstall.`
11975
11989
  "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."
11976
11990
  );
11977
11991
  }
11978
- if (existsSync40(join42(options.cwd, pluginSeedImportDir(name)))) {
11992
+ if (existsSync41(join43(options.cwd, pluginSeedImportDir(name)))) {
11979
11993
  log.warn(
11980
11994
  `${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.`
11981
11995
  );
11982
11996
  }
11983
11997
  }
11984
11998
  function readInstalledManifest(targetDir) {
11985
- const manifestPath = join42(targetDir, "biffo.plugin.json");
11986
- if (!existsSync40(manifestPath)) return void 0;
11999
+ const manifestPath = join43(targetDir, "biffo.plugin.json");
12000
+ if (!existsSync41(manifestPath)) return void 0;
11987
12001
  try {
11988
12002
  return validateManifest(JSON.parse(readFileSync29(manifestPath, "utf8")));
11989
12003
  } catch {
@@ -12018,8 +12032,8 @@ function printDryRun5(name, version, stagePaths, keepData) {
12018
12032
  }
12019
12033
 
12020
12034
  // src/commands/plugin-upgrade.ts
12021
- import { cpSync as cpSync6, existsSync as existsSync41, mkdirSync as mkdirSync13, readFileSync as readFileSync30, rmSync as rmSync11 } from "fs";
12022
- import { join as join43, relative as relative7, resolve as resolve19 } from "path";
12035
+ import { cpSync as cpSync6, existsSync as existsSync42, mkdirSync as mkdirSync13, readFileSync as readFileSync30, rmSync as rmSync11 } from "fs";
12036
+ import { join as join44, relative as relative7, resolve as resolve19 } from "path";
12023
12037
  import chalk19 from "chalk";
12024
12038
  import { Command as Command21 } from "commander";
12025
12039
  import inquirer7 from "inquirer";
@@ -12066,8 +12080,8 @@ async function runPluginUpgrade(target, options, deps) {
12066
12080
  `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\`).`
12067
12081
  );
12068
12082
  }
12069
- const servicesDir = join43(options.cwd, "services");
12070
- if (!existsSync41(servicesDir)) {
12083
+ const servicesDir = join44(options.cwd, "services");
12084
+ if (!existsSync42(servicesDir)) {
12071
12085
  throw new Error(
12072
12086
  `${servicesDir} does not exist \u2014 is ${options.cwd} the root of a Biffo project checkout?`
12073
12087
  );
@@ -12076,8 +12090,8 @@ async function runPluginUpgrade(target, options, deps) {
12076
12090
  return runLocalPluginRefresh(options.local, options, deps);
12077
12091
  }
12078
12092
  const { name, minor } = parsePluginTarget(target);
12079
- const targetDir = join43(servicesDir, name);
12080
- if (!existsSync41(targetDir)) {
12093
+ const targetDir = join44(servicesDir, name);
12094
+ if (!existsSync42(targetDir)) {
12081
12095
  throw new Error(
12082
12096
  `Plugin '${name}' is not installed at services/${name}/. Use 'biffo plugin install ${name}@${minor}' instead.`
12083
12097
  );
@@ -12091,7 +12105,7 @@ async function runPluginUpgrade(target, options, deps) {
12091
12105
  `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.`
12092
12106
  );
12093
12107
  }
12094
- const modulesDir = join43(options.cwd, "modules", "plugins", entry.name);
12108
+ const modulesDir = join44(options.cwd, "modules", "plugins", entry.name);
12095
12109
  if (options.dryRun) {
12096
12110
  printDryRun6(entry, currentVersion);
12097
12111
  return;
@@ -12119,11 +12133,11 @@ async function runPluginUpgrade(target, options, deps) {
12119
12133
  log.success(
12120
12134
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
12121
12135
  );
12122
- const retiredShapeReasons = findRetiredFrontendShape(join43(tmpDir, "terraform"));
12136
+ const retiredShapeReasons = findRetiredFrontendShape(join44(tmpDir, "terraform"));
12123
12137
  if (retiredShapeReasons.length > 0) {
12124
12138
  throw new Error(retiredFrontendShapeError(entry.name, retiredShapeReasons));
12125
12139
  }
12126
- if (!existsSync41(join43(tmpDir, "terraform"))) {
12140
+ if (!existsSync42(join44(tmpDir, "terraform"))) {
12127
12141
  refuseIfModuleStillReferenced(options.cwd, modulesDir, entry.name);
12128
12142
  }
12129
12143
  const previousProvenance = readProvenance(targetDir);
@@ -12140,11 +12154,11 @@ async function runPluginUpgrade(target, options, deps) {
12140
12154
  applyWorkspaceSources(targetDir, options.cwd, `services/${entry.name}`);
12141
12155
  const newPyproject = readPyprojectIfPresent(targetDir);
12142
12156
  const stagePaths = [`services/${entry.name}`];
12143
- if (existsSync41(modulesDir)) {
12157
+ if (existsSync42(modulesDir)) {
12144
12158
  rmSync11(modulesDir, { recursive: true, force: true });
12145
12159
  }
12146
- const tfSourceDir = join43(targetDir, "terraform");
12147
- if (existsSync41(tfSourceDir)) {
12160
+ const tfSourceDir = join44(targetDir, "terraform");
12161
+ if (existsSync42(tfSourceDir)) {
12148
12162
  mkdirSync13(modulesDir, { recursive: true });
12149
12163
  cpSync6(tfSourceDir, modulesDir, { recursive: true });
12150
12164
  stagePaths.push(`modules/plugins/${entry.name}`);
@@ -12205,16 +12219,16 @@ async function runPluginUpgrade(target, options, deps) {
12205
12219
  async function runLocalPluginRefresh(localPath, options, deps) {
12206
12220
  const source = resolveLocalPlugin(localPath);
12207
12221
  log.success(`Resolved ${source.name}@${source.version} from ${source.origin}`);
12208
- const servicesDir = join43(options.cwd, "services");
12209
- const targetDir = join43(servicesDir, source.name);
12210
- if (!existsSync41(targetDir)) {
12222
+ const servicesDir = join44(options.cwd, "services");
12223
+ const targetDir = join44(servicesDir, source.name);
12224
+ if (!existsSync42(targetDir)) {
12211
12225
  throw new Error(
12212
12226
  `Plugin '${source.name}' is not installed at services/${source.name}/. Use 'biffo plugin install --local ${localPath}' instead.`
12213
12227
  );
12214
12228
  }
12215
12229
  const inTreeSource = resolve19(source.sourceDir) === resolve19(targetDir);
12216
12230
  const currentVersion = readInstalledVersion(targetDir);
12217
- const modulesDir = join43(options.cwd, "modules", "plugins", source.name);
12231
+ const modulesDir = join44(options.cwd, "modules", "plugins", source.name);
12218
12232
  if (options.dryRun) {
12219
12233
  printLocalDryRun(source, currentVersion, inTreeSource);
12220
12234
  return;
@@ -12237,11 +12251,11 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12237
12251
  log.success(
12238
12252
  `Manifest valid \u2014 ${manifest.tables.length} table(s), ${manifest.api_routes.length} route(s)`
12239
12253
  );
12240
- const retiredShapeReasons = findRetiredFrontendShape(join43(source.sourceDir, "terraform"));
12254
+ const retiredShapeReasons = findRetiredFrontendShape(join44(source.sourceDir, "terraform"));
12241
12255
  if (retiredShapeReasons.length > 0) {
12242
12256
  throw new Error(retiredFrontendShapeError(source.name, retiredShapeReasons));
12243
12257
  }
12244
- if (!existsSync41(join43(source.sourceDir, "terraform"))) {
12258
+ if (!existsSync42(join44(source.sourceDir, "terraform"))) {
12245
12259
  refuseIfModuleStillReferenced(options.cwd, modulesDir, source.name);
12246
12260
  }
12247
12261
  const previousProvenance = readProvenance(targetDir);
@@ -12261,11 +12275,11 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12261
12275
  applyWorkspaceSources(targetDir, options.cwd, `services/${source.name}`);
12262
12276
  const newPyproject = readPyprojectIfPresent(targetDir);
12263
12277
  const stagePaths = [`services/${source.name}`];
12264
- if (existsSync41(modulesDir)) {
12278
+ if (existsSync42(modulesDir)) {
12265
12279
  rmSync11(modulesDir, { recursive: true, force: true });
12266
12280
  }
12267
- const tfSourceDir = join43(targetDir, "terraform");
12268
- if (existsSync41(tfSourceDir)) {
12281
+ const tfSourceDir = join44(targetDir, "terraform");
12282
+ if (existsSync42(tfSourceDir)) {
12269
12283
  mkdirSync13(modulesDir, { recursive: true });
12270
12284
  cpSync6(tfSourceDir, modulesDir, { recursive: true });
12271
12285
  stagePaths.push(`modules/plugins/${source.name}`);
@@ -12329,7 +12343,7 @@ async function runLocalPluginRefresh(localPath, options, deps) {
12329
12343
  }
12330
12344
  }
12331
12345
  function refuseIfModuleStillReferenced(cwd, modulesDir, name) {
12332
- if (!existsSync41(modulesDir)) return;
12346
+ if (!existsSync42(modulesDir)) return;
12333
12347
  const refs = findPluginModuleReferences(cwd, name);
12334
12348
  if (refs.length === 0) return;
12335
12349
  const refList = refs.map((r) => ` ${r.file}:${r.line} ${r.text}`).join("\n");
@@ -12390,8 +12404,8 @@ var defaultRunCommand2 = async (command, cwd) => {
12390
12404
  }
12391
12405
  };
12392
12406
  function readPyprojectIfPresent(targetDir) {
12393
- const path = join43(targetDir, "pyproject.toml");
12394
- return existsSync41(path) ? readFileSync30(path, "utf8") : null;
12407
+ const path = join44(targetDir, "pyproject.toml");
12408
+ return existsSync42(path) ? readFileSync30(path, "utf8") : null;
12395
12409
  }
12396
12410
  function dependenciesChanged(before, after) {
12397
12411
  if (before === after) return false;
@@ -12419,8 +12433,8 @@ function tomlTableBody(text, header) {
12419
12433
  return nextHeader ? rest.slice(0, nextHeader.index) : rest;
12420
12434
  }
12421
12435
  function readInstalledVersion(targetDir) {
12422
- const manifestPath = join43(targetDir, "biffo.plugin.json");
12423
- if (!existsSync41(manifestPath)) return void 0;
12436
+ const manifestPath = join44(targetDir, "biffo.plugin.json");
12437
+ if (!existsSync42(manifestPath)) return void 0;
12424
12438
  try {
12425
12439
  return validateManifest(JSON.parse(readFileSync30(manifestPath, "utf8"))).version;
12426
12440
  } catch {
@@ -12642,7 +12656,7 @@ pluginCommand.addCommand(pluginVerifyCommand);
12642
12656
  import { Command as Command25 } from "commander";
12643
12657
 
12644
12658
  // src/commands/sibling-check-identity.ts
12645
- import { existsSync as existsSync42, readFileSync as readFileSync31 } from "fs";
12659
+ import { existsSync as existsSync43, readFileSync as readFileSync31 } from "fs";
12646
12660
  import { resolve as resolve21 } from "path";
12647
12661
  import chalk20 from "chalk";
12648
12662
  import { Command as Command24 } from "commander";
@@ -12856,7 +12870,7 @@ async function resolveConfig4(options) {
12856
12870
  return cfg;
12857
12871
  }
12858
12872
  const localConfigPath = resolve21(process.cwd(), "biffo.config.json");
12859
- if (existsSync42(localConfigPath)) {
12873
+ if (existsSync43(localConfigPath)) {
12860
12874
  const raw = JSON.parse(readFileSync31(localConfigPath, "utf8"));
12861
12875
  const result = BiffoConfigSchema.safeParse(raw);
12862
12876
  if (result.success) return result.data;
@@ -12903,18 +12917,18 @@ siblingCommand.addCommand(siblingCheckIdentityCommand);
12903
12917
  import { Command as Command26 } from "commander";
12904
12918
 
12905
12919
  // src/scripts/check-adr-numbering.ts
12906
- import { existsSync as existsSync44 } from "fs";
12907
- import { join as join45 } from "path";
12920
+ import { existsSync as existsSync45 } from "fs";
12921
+ import { join as join46 } from "path";
12908
12922
 
12909
12923
  // src/lib/adr-numbering-guard.ts
12910
- import { existsSync as existsSync43, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "fs";
12911
- import { join as join44 } from "path";
12924
+ import { existsSync as existsSync44, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "fs";
12925
+ import { join as join45 } from "path";
12912
12926
  var ADR_FILENAME = /^(\d{4})-.+\.md$/;
12913
12927
  var ALLOWLIST_FILENAME = ".numbering-allowlist";
12914
12928
  var TEMPLATE_ADR_RESERVED_UPTO = "0099";
12915
12929
  function readAdrNumberingAllowlist(adrDir) {
12916
- const path = join44(adrDir, ALLOWLIST_FILENAME);
12917
- if (!existsSync43(path)) return /* @__PURE__ */ new Set();
12930
+ const path = join45(adrDir, ALLOWLIST_FILENAME);
12931
+ if (!existsSync44(path)) return /* @__PURE__ */ new Set();
12918
12932
  const numbers = /* @__PURE__ */ new Set();
12919
12933
  for (const rawLine of readFileSync32(path, "utf8").split("\n")) {
12920
12934
  const line = rawLine.split("#")[0].trim();
@@ -12924,7 +12938,7 @@ function readAdrNumberingAllowlist(adrDir) {
12924
12938
  }
12925
12939
  function adrNumbersIn(adrDir) {
12926
12940
  const claims = /* @__PURE__ */ new Map();
12927
- if (!existsSync43(adrDir)) return claims;
12941
+ if (!existsSync44(adrDir)) return claims;
12928
12942
  for (const entry of readdirSync15(adrDir).sort()) {
12929
12943
  const match = ADR_FILENAME.exec(entry);
12930
12944
  if (!match) continue;
@@ -12979,8 +12993,8 @@ function formatAdrReservedRangeViolations(violations, reservedUpTo = TEMPLATE_AD
12979
12993
  // src/scripts/check-adr-numbering.ts
12980
12994
  async function runAdrNumberingCheck() {
12981
12995
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
12982
- const adrDir = join45(root, "docs", "ADR");
12983
- if (!existsSync44(adrDir)) {
12996
+ const adrDir = join46(root, "docs", "ADR");
12997
+ if (!existsSync45(adrDir)) {
12984
12998
  console.log("\u2713 ADR numbering guard: no docs/ADR/ directory \u2014 nothing to compare");
12985
12999
  return;
12986
13000
  }
@@ -13019,7 +13033,7 @@ Already accepted? List it in docs/ADR/${ALLOWLIST_FILENAME} instead of leaving t
13019
13033
 
13020
13034
  // src/lib/api-gateway-integration-guard.ts
13021
13035
  import { readFileSync as readFileSync33, readdirSync as readdirSync16, statSync as statSync10 } from "fs";
13022
- import { join as join46 } from "path";
13036
+ import { join as join47 } from "path";
13023
13037
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
13024
13038
  var MODULE_TYPE = "module";
13025
13039
  var INTEGRATION_TYPE = "aws_apigatewayv2_integration";
@@ -13101,7 +13115,7 @@ function walkTerraformFiles(root) {
13101
13115
  return;
13102
13116
  }
13103
13117
  for (const entry of entries) {
13104
- const p = join46(dir, entry);
13118
+ const p = join47(dir, entry);
13105
13119
  let st;
13106
13120
  try {
13107
13121
  st = statSync10(p);
@@ -13517,17 +13531,17 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
13517
13531
  }
13518
13532
 
13519
13533
  // src/lib/claim-invocation-parity.ts
13520
- import { existsSync as existsSync45, readFileSync as readFileSync34, readdirSync as readdirSync17 } from "fs";
13521
- import { join as join47 } from "path";
13534
+ import { existsSync as existsSync46, readFileSync as readFileSync34, readdirSync as readdirSync17 } from "fs";
13535
+ import { join as join48 } from "path";
13522
13536
  function distributedAgentsDocs(root) {
13523
13537
  const docs = [];
13524
- const own = join47(root, "AGENTS.md");
13525
- if (existsSync45(own)) docs.push({ path: "AGENTS.md", text: readFileSync34(own, "utf8") });
13526
- const skeletons = join47(root, "_skeletons");
13527
- if (existsSync45(skeletons)) {
13538
+ const own = join48(root, "AGENTS.md");
13539
+ if (existsSync46(own)) docs.push({ path: "AGENTS.md", text: readFileSync34(own, "utf8") });
13540
+ const skeletons = join48(root, "_skeletons");
13541
+ if (existsSync46(skeletons)) {
13528
13542
  for (const name of readdirSync17(skeletons).sort()) {
13529
- const abs = join47(skeletons, name, "AGENTS.md");
13530
- if (!existsSync45(abs)) continue;
13543
+ const abs = join48(skeletons, name, "AGENTS.md");
13544
+ if (!existsSync46(abs)) continue;
13531
13545
  docs.push({ path: `_skeletons/${name}/AGENTS.md`, text: readFileSync34(abs, "utf8") });
13532
13546
  }
13533
13547
  }
@@ -13660,12 +13674,12 @@ async function runClaimInvocationCheck() {
13660
13674
  }
13661
13675
 
13662
13676
  // src/scripts/check-codeql-suppression.ts
13663
- import { existsSync as existsSync46 } from "fs";
13664
- import { join as join49, relative as relative8 } from "path";
13677
+ import { existsSync as existsSync47 } from "fs";
13678
+ import { join as join50, relative as relative8 } from "path";
13665
13679
 
13666
13680
  // src/lib/codeql-suppression-guard.ts
13667
13681
  import { readdirSync as readdirSync18, readFileSync as readFileSync35, statSync as statSync11 } from "fs";
13668
- import { join as join48 } from "path";
13682
+ import { join as join49 } from "path";
13669
13683
  var SKIP_DIRS2 = /* @__PURE__ */ new Set([
13670
13684
  ".git",
13671
13685
  ".worktrees",
@@ -13696,7 +13710,7 @@ function walkSourceFiles(root) {
13696
13710
  return;
13697
13711
  }
13698
13712
  for (const entry of entries) {
13699
- const p = join48(dir, entry);
13713
+ const p = join49(dir, entry);
13700
13714
  let st;
13701
13715
  try {
13702
13716
  st = statSync11(p);
@@ -13733,8 +13747,8 @@ function sweepCodeqlSuppressionComments(root) {
13733
13747
  // src/scripts/check-codeql-suppression.ts
13734
13748
  async function runCodeqlSuppressionCheck() {
13735
13749
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
13736
- const scanRoot = join49(root, "cli", "src");
13737
- if (!existsSync46(scanRoot)) {
13750
+ const scanRoot = join50(root, "cli", "src");
13751
+ if (!existsSync47(scanRoot)) {
13738
13752
  console.log(
13739
13753
  "\u2014 codeql-suppression guard: skipped \u2014 no cli/src in this repo, so there is no CLI source to scan."
13740
13754
  );
@@ -13758,12 +13772,12 @@ async function runCodeqlSuppressionCheck() {
13758
13772
  }
13759
13773
 
13760
13774
  // src/scripts/check-cognito-invite-template.ts
13761
- import { existsSync as existsSync47 } from "fs";
13762
- import { join as join51 } from "path";
13775
+ import { existsSync as existsSync48 } from "fs";
13776
+ import { join as join52 } from "path";
13763
13777
 
13764
13778
  // src/lib/cognito-invite-template-guard.ts
13765
13779
  import { readdirSync as readdirSync19, readFileSync as readFileSync36, statSync as statSync12 } from "fs";
13766
- import { join as join50 } from "path";
13780
+ import { join as join51 } from "path";
13767
13781
  var REQUIRED_INVITE_MEMBERS = ["email_subject", "email_message", "sms_message"];
13768
13782
  var REQUIRED_INVITE_PLACEHOLDERS = ["{username}", "{####}"];
13769
13783
  var PLACEHOLDER_MEMBERS = ["email_message", "sms_message"];
@@ -13847,7 +13861,7 @@ function findModuleTerraformFiles(repoRoot) {
13847
13861
  for (const entry of entries) {
13848
13862
  if (entry === "node_modules" || entry === ".git" || entry === ".worktrees" || entry === ".venv")
13849
13863
  continue;
13850
- const full = join50(dir, entry);
13864
+ const full = join51(dir, entry);
13851
13865
  const rel = `${relative11}/${entry}`;
13852
13866
  let isDir;
13853
13867
  try {
@@ -13862,12 +13876,12 @@ function findModuleTerraformFiles(repoRoot) {
13862
13876
  }
13863
13877
  }
13864
13878
  };
13865
- walk2(join50(repoRoot, "modules"), "modules");
13879
+ walk2(join51(repoRoot, "modules"), "modules");
13866
13880
  return found.sort();
13867
13881
  }
13868
13882
  function checkCognitoInviteTemplates(repoRoot) {
13869
13883
  return findModuleTerraformFiles(repoRoot).flatMap(
13870
- (file) => checkInviteTemplateSource(file, readFileSync36(join50(repoRoot, file), "utf8"))
13884
+ (file) => checkInviteTemplateSource(file, readFileSync36(join51(repoRoot, file), "utf8"))
13871
13885
  );
13872
13886
  }
13873
13887
 
@@ -13877,7 +13891,7 @@ async function runCognitoInviteTemplateCheck() {
13877
13891
  const files = findModuleTerraformFiles(root);
13878
13892
  console.log(`audited ${files.length} .tf file(s) under modules/ under ${root}`);
13879
13893
  if (files.length === 0) {
13880
- if (!existsSync47(join51(root, "modules"))) {
13894
+ if (!existsSync48(join52(root, "modules"))) {
13881
13895
  console.log(
13882
13896
  `\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.`
13883
13897
  );
@@ -13901,11 +13915,11 @@ async function runCognitoInviteTemplateCheck() {
13901
13915
  }
13902
13916
 
13903
13917
  // src/scripts/check-core-direct-paths.ts
13904
- import { join as join53 } from "path";
13918
+ import { join as join54 } from "path";
13905
13919
 
13906
13920
  // src/lib/core-direct-paths-audit.ts
13907
- import { existsSync as existsSync48, readFileSync as readFileSync37, readdirSync as readdirSync20, statSync as statSync13 } from "fs";
13908
- import { join as join52 } from "path";
13921
+ import { existsSync as existsSync49, readFileSync as readFileSync37, readdirSync as readdirSync20, statSync as statSync13 } from "fs";
13922
+ import { join as join53 } from "path";
13909
13923
  var EXTERNAL_BASE_IDENTIFIERS = ["CORE_API_URL"];
13910
13924
  var API_ROUTE_PREFIX = "/api/v1";
13911
13925
  var TEST_FILE_SUFFIXES = [".test.ts", ".test.tsx", ".spec.ts", ".spec.tsx"];
@@ -14069,7 +14083,7 @@ function walkFiles(root, accept, skipDir) {
14069
14083
  return;
14070
14084
  }
14071
14085
  for (const entry of entries) {
14072
- const p = join52(dir, entry);
14086
+ const p = join53(dir, entry);
14073
14087
  let st;
14074
14088
  try {
14075
14089
  st = statSync13(p);
@@ -14164,7 +14178,7 @@ function pathMatchesAnyCorePrefix(normalized, corePrefixes, apiRoutePrefix = API
14164
14178
  }
14165
14179
  function resolveSiblingCoreSrc(params) {
14166
14180
  const { estateDir, sibling } = params;
14167
- const configPath = join52(estateDir, sibling, "biffo.sibling.json");
14181
+ const configPath = join53(estateDir, sibling, "biffo.sibling.json");
14168
14182
  let raw;
14169
14183
  try {
14170
14184
  raw = readFileSync37(configPath, "utf8");
@@ -14187,8 +14201,8 @@ function resolveSiblingCoreSrc(params) {
14187
14201
  `cannot resolve ${sibling}'s core: ${configPath} has no non-empty "core_project" field.`
14188
14202
  );
14189
14203
  }
14190
- const coreApiSrcDir = join52(estateDir, coreProject, "services", "api", "src");
14191
- if (!existsSync48(coreApiSrcDir)) {
14204
+ const coreApiSrcDir = join53(estateDir, coreProject, "services", "api", "src");
14205
+ if (!existsSync49(coreApiSrcDir)) {
14192
14206
  throw new Error(
14193
14207
  `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.`
14194
14208
  );
@@ -14241,7 +14255,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
14241
14255
  }
14242
14256
  }
14243
14257
  const sibling = opts.sibling ?? "sibling-template (self-check)";
14244
- const frontendSrcDir = opts.frontendSrc ?? join53(root, "_skeletons", "sibling-template", "apps", "frontend", "src");
14258
+ const frontendSrcDir = opts.frontendSrc ?? join54(root, "_skeletons", "sibling-template", "apps", "frontend", "src");
14245
14259
  let coreApiSrcDir;
14246
14260
  let coreProject = null;
14247
14261
  if (opts.coreSrc) {
@@ -14257,7 +14271,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
14257
14271
  coreApiSrcDir = resolution.coreApiSrcDir;
14258
14272
  coreProject = resolution.coreProject;
14259
14273
  } else {
14260
- coreApiSrcDir = join53(root, "services", "api", "src");
14274
+ coreApiSrcDir = join54(root, "services", "api", "src");
14261
14275
  }
14262
14276
  const report = auditSiblingCoreDirectPaths({ sibling, frontendSrcDir, coreApiSrcDir });
14263
14277
  console.log(
@@ -14384,8 +14398,8 @@ async function runOwnershipCheck(argv) {
14384
14398
  const { stdout } = await execa("git", ["diff", "--cached", "--name-status"], { cwd: root });
14385
14399
  ({ changed: changedFiles, deleted: deletedFiles } = parseNameStatus(stdout));
14386
14400
  if (messageFile) {
14387
- const { readFileSync: readFileSync51, existsSync: existsSync62 } = await import("fs");
14388
- if (existsSync62(messageFile)) commitMessage = readFileSync51(messageFile, "utf8");
14401
+ const { readFileSync: readFileSync51, existsSync: existsSync63 } = await import("fs");
14402
+ if (existsSync63(messageFile)) commitMessage = readFileSync51(messageFile, "utf8");
14389
14403
  }
14390
14404
  } else {
14391
14405
  const base = process.env["GITHUB_BASE_REF"] ?? args[0];
@@ -14508,16 +14522,16 @@ ${BOLD}If the divergence is deliberate${OFF}
14508
14522
  }
14509
14523
 
14510
14524
  // src/scripts/check-distribution-inventory.ts
14511
- import { existsSync as existsSync50 } from "fs";
14512
- import { join as join55 } from "path";
14525
+ import { existsSync as existsSync51 } from "fs";
14526
+ import { join as join56 } from "path";
14513
14527
 
14514
14528
  // src/lib/distribution-inventory.ts
14515
- import { existsSync as existsSync49, readFileSync as readFileSync38 } from "fs";
14516
- import { join as join54 } from "path";
14529
+ import { existsSync as existsSync50, readFileSync as readFileSync38 } from "fs";
14530
+ import { join as join55 } from "path";
14517
14531
  var INVENTORY_FILENAME = "distribution-inventory.json";
14518
14532
  function loadDistributionInventory(root) {
14519
- const path = join54(root, INVENTORY_FILENAME);
14520
- if (!existsSync49(path)) {
14533
+ const path = join55(root, INVENTORY_FILENAME);
14534
+ if (!existsSync50(path)) {
14521
14535
  throw new Error(
14522
14536
  `${INVENTORY_FILENAME} not found at ${root} -- expected it beside core-manifest.json`
14523
14537
  );
@@ -14682,7 +14696,7 @@ async function runDistributionInventoryCheck(root) {
14682
14696
  );
14683
14697
  return;
14684
14698
  }
14685
- if (!existsSync50(join55(repoRoot, INVENTORY_FILENAME))) {
14699
+ if (!existsSync51(join56(repoRoot, INVENTORY_FILENAME))) {
14686
14700
  console.log(
14687
14701
  `\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.`
14688
14702
  );
@@ -14708,7 +14722,7 @@ async function runDistributionInventoryCheck(root) {
14708
14722
  }
14709
14723
 
14710
14724
  // src/scripts/check-distribution-remote-state.ts
14711
- import { join as join56 } from "path";
14725
+ import { join as join57 } from "path";
14712
14726
  async function ghExecCommand(file, args) {
14713
14727
  const result = await execa(file, args, { reject: false });
14714
14728
  return { stdout: String(result.stdout ?? ""), exitCode: result.exitCode ?? null };
@@ -14723,7 +14737,7 @@ async function runDistributionRemoteStateCheck(root) {
14723
14737
  }
14724
14738
  }
14725
14739
  console.log(
14726
- `distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${join56(repoRoot, "distribution-inventory.json")})`
14740
+ `distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${join57(repoRoot, "distribution-inventory.json")})`
14727
14741
  );
14728
14742
  if (assertions.length === 0) {
14729
14743
  console.log("\u2713 distribution-remote-state: nothing declared to check");
@@ -14769,7 +14783,7 @@ ${assertion.ref}`;
14769
14783
 
14770
14784
  // src/lib/eventbridge-log-permission-guard.ts
14771
14785
  import { readFileSync as readFileSync39, readdirSync as readdirSync21, statSync as statSync14 } from "fs";
14772
- import { join as join57 } from "path";
14786
+ import { join as join58 } from "path";
14773
14787
  var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
14774
14788
  var EVENT_TARGET_TYPE = "aws_cloudwatch_event_target";
14775
14789
  var LOG_RESOURCE_POLICY_TYPE = "aws_cloudwatch_log_resource_policy";
@@ -14846,7 +14860,7 @@ function walkTerraformFiles2(root) {
14846
14860
  return;
14847
14861
  }
14848
14862
  for (const entry of entries) {
14849
- const p = join57(dir, entry);
14863
+ const p = join58(dir, entry);
14850
14864
  let st;
14851
14865
  try {
14852
14866
  st = statSync14(p);
@@ -14986,8 +15000,8 @@ async function runEventBridgeLogPermissionCheck() {
14986
15000
  }
14987
15001
 
14988
15002
  // src/scripts/check-instance-adoption.ts
14989
- import { existsSync as existsSync51 } from "fs";
14990
- import { join as join58 } from "path";
15003
+ import { existsSync as existsSync52 } from "fs";
15004
+ import { join as join59 } from "path";
14991
15005
  async function runInstanceAdoptionCheck(opts = {}) {
14992
15006
  if (!opts.instanceDir) {
14993
15007
  console.error(
@@ -14995,7 +15009,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
14995
15009
  );
14996
15010
  process.exit(2);
14997
15011
  }
14998
- if (!existsSync51(opts.instanceDir)) {
15012
+ if (!existsSync52(opts.instanceDir)) {
14999
15013
  console.error(
15000
15014
  `\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.`
15001
15015
  );
@@ -15003,7 +15017,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
15003
15017
  }
15004
15018
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
15005
15019
  const theirsDir = opts.theirsDir ?? root;
15006
- const instanceLabel = opts.instance ?? join58(opts.instanceDir).split("/").filter(Boolean).pop();
15020
+ const instanceLabel = opts.instance ?? join59(opts.instanceDir).split("/").filter(Boolean).pop();
15007
15021
  const report = checkInstanceAdoption(theirsDir, opts.instanceDir);
15008
15022
  console.log(
15009
15023
  `examined ${report.examinedInstances} instance (${instanceLabel}) against ${report.registeredPairs} registered pair(s), ${report.applicablePairs} applicable to this instance, against template tree ${theirsDir}`
@@ -15026,11 +15040,11 @@ async function runInstanceAdoptionCheck(opts = {}) {
15026
15040
 
15027
15041
  // src/lib/lambda-output-guard.ts
15028
15042
  import { readFileSync as readFileSync41 } from "fs";
15029
- import { join as join60 } from "path";
15043
+ import { join as join61 } from "path";
15030
15044
 
15031
15045
  // src/lib/terraform-input-guard.ts
15032
- import { existsSync as existsSync52, readdirSync as readdirSync22, readFileSync as readFileSync40, statSync as statSync15 } from "fs";
15033
- import { join as join59 } from "path";
15046
+ import { existsSync as existsSync53, readdirSync as readdirSync22, readFileSync as readFileSync40, statSync as statSync15 } from "fs";
15047
+ import { join as join60 } from "path";
15034
15048
  var GUARDED_SUBCOMMANDS = [
15035
15049
  "init",
15036
15050
  "plan",
@@ -15044,7 +15058,7 @@ function stripComments2(source) {
15044
15058
  return source.split("\n").map((line) => line.replace(/(^|\s)#.*$/, "$1")).join("\n");
15045
15059
  }
15046
15060
  function vendoredPluginServiceDirs(repoRoot) {
15047
- const servicesDir = join59(repoRoot, "services");
15061
+ const servicesDir = join60(repoRoot, "services");
15048
15062
  const result = /* @__PURE__ */ new Set();
15049
15063
  let entries;
15050
15064
  try {
@@ -15053,9 +15067,9 @@ function vendoredPluginServiceDirs(repoRoot) {
15053
15067
  return result;
15054
15068
  }
15055
15069
  for (const entry of entries) {
15056
- const full = join59(servicesDir, entry);
15057
- if (!existsSync52(full) || !statSync15(full).isDirectory()) continue;
15058
- if (existsSync52(join59(full, "biffo.plugin.json"))) {
15070
+ const full = join60(servicesDir, entry);
15071
+ if (!existsSync53(full) || !statSync15(full).isDirectory()) continue;
15072
+ if (existsSync53(join60(full, "biffo.plugin.json"))) {
15059
15073
  result.add(entry);
15060
15074
  }
15061
15075
  }
@@ -15077,7 +15091,7 @@ function findWorkflowFiles(repoRoot) {
15077
15091
  if (entry === ".github" && relative11.startsWith("services/") && vendoredPluginDirs.has(relative11.slice("services/".length))) {
15078
15092
  continue;
15079
15093
  }
15080
- const full = join59(dir, entry);
15094
+ const full = join60(dir, entry);
15081
15095
  const rel = relative11 ? `${relative11}/${entry}` : entry;
15082
15096
  let isDir;
15083
15097
  try {
@@ -15127,7 +15141,7 @@ function checkWorkflowSource(file, rawSource) {
15127
15141
  }
15128
15142
  function checkTerraformInput(repoRoot) {
15129
15143
  return findWorkflowFiles(repoRoot).flatMap(
15130
- (file) => checkWorkflowSource(file, readFileSync40(join59(repoRoot, file), "utf8"))
15144
+ (file) => checkWorkflowSource(file, readFileSync40(join60(repoRoot, file), "utf8"))
15131
15145
  );
15132
15146
  }
15133
15147
 
@@ -15185,7 +15199,7 @@ function checkWorkflowSource2(file, rawSource) {
15185
15199
  }
15186
15200
  function checkLambdaOutput(repoRoot) {
15187
15201
  return findWorkflowFiles(repoRoot).flatMap(
15188
- (file) => checkWorkflowSource2(file, readFileSync41(join60(repoRoot, file), "utf8"))
15202
+ (file) => checkWorkflowSource2(file, readFileSync41(join61(repoRoot, file), "utf8"))
15189
15203
  );
15190
15204
  }
15191
15205
 
@@ -15213,8 +15227,8 @@ async function runLambdaOutputCheck() {
15213
15227
  }
15214
15228
 
15215
15229
  // src/scripts/check-migration-body-change.ts
15216
- import { existsSync as existsSync53 } from "fs";
15217
- import { join as join61 } from "path";
15230
+ import { existsSync as existsSync54 } from "fs";
15231
+ import { join as join62 } from "path";
15218
15232
 
15219
15233
  // src/lib/migration-body-change-guard.ts
15220
15234
  function checkMigrationBodyChangeMarkers(diffs) {
@@ -15296,7 +15310,7 @@ async function runMigrationBodyChangeCheck(argv) {
15296
15310
  );
15297
15311
  return;
15298
15312
  }
15299
- if (!existsSync53(join61(root, MIGRATIONS_VERSIONS_DIR))) {
15313
+ if (!existsSync54(join62(root, MIGRATIONS_VERSIONS_DIR))) {
15300
15314
  console.log(`\u2713 migration body-change guard: no ${MIGRATIONS_VERSIONS_DIR} in this repo.`);
15301
15315
  return;
15302
15316
  }
@@ -15402,8 +15416,8 @@ ${BOLD2}What to do${OFF2}
15402
15416
  }
15403
15417
 
15404
15418
  // src/scripts/check-orphan-ratchet.ts
15405
- import { existsSync as existsSync54 } from "fs";
15406
- import { basename as basename3, join as join62 } from "path";
15419
+ import { existsSync as existsSync55 } from "fs";
15420
+ import { basename as basename3, join as join63 } from "path";
15407
15421
  function reportOrphan(entry, manifest) {
15408
15422
  console.error(` ${entry.path}`);
15409
15423
  const { templateOwnedMatch, nearestUserOwnedEntries } = explainOwnership(entry.path, manifest);
@@ -15425,7 +15439,7 @@ function reportOrphan(entry, manifest) {
15425
15439
  }
15426
15440
  }
15427
15441
  async function runOrphanRatchetCheck(opts = {}) {
15428
- if (opts.instanceDir !== void 0 && !existsSync54(opts.instanceDir)) {
15442
+ if (opts.instanceDir !== void 0 && !existsSync55(opts.instanceDir)) {
15429
15443
  console.error(
15430
15444
  `\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.`
15431
15445
  );
@@ -15442,7 +15456,7 @@ async function runOrphanRatchetCheck(opts = {}) {
15442
15456
  "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."
15443
15457
  );
15444
15458
  }
15445
- if (!existsSync54(join62(theirsDir, CORE_MANIFEST_FILE))) {
15459
+ if (!existsSync55(join63(theirsDir, CORE_MANIFEST_FILE))) {
15446
15460
  console.log(
15447
15461
  `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.`
15448
15462
  );
@@ -15474,7 +15488,7 @@ baseline was ${String(ratchet.baseline)}, now ${String(ratchet.count)}. See biff
15474
15488
 
15475
15489
  // src/lib/ownership-header-claim-guard.ts
15476
15490
  import { readFileSync as readFileSync42 } from "fs";
15477
- import { join as join63 } from "path";
15491
+ import { join as join64 } from "path";
15478
15492
  var OWNERSHIP_HEADER_SWEEP_DIRS = [
15479
15493
  "scripts",
15480
15494
  ".githooks",
@@ -15683,7 +15697,7 @@ function sweepOwnershipHeaderClaims(root, options = {}) {
15683
15697
  for (const rel of files) {
15684
15698
  let content;
15685
15699
  try {
15686
- content = readFileSync42(join63(root, rel), "utf8");
15700
+ content = readFileSync42(join64(root, rel), "utf8");
15687
15701
  } catch {
15688
15702
  continue;
15689
15703
  }
@@ -15759,7 +15773,7 @@ async function runOwnershipHeaderClaimCheck() {
15759
15773
 
15760
15774
  // src/scripts/check-pipe-trap.ts
15761
15775
  import { readFileSync as readFileSync43, readdirSync as readdirSync23 } from "fs";
15762
- import { join as join64, relative as relative9 } from "path";
15776
+ import { join as join65, relative as relative9 } from "path";
15763
15777
 
15764
15778
  // src/lib/pipe-trap-guard.ts
15765
15779
  var STATUS_BEARING = [
@@ -15855,7 +15869,7 @@ function findPipeTraps(source) {
15855
15869
  function shellFiles(root) {
15856
15870
  const out = [];
15857
15871
  for (const dir of ["scripts", ".githooks"]) {
15858
- const full = join64(root, dir);
15872
+ const full = join65(root, dir);
15859
15873
  let entries;
15860
15874
  try {
15861
15875
  entries = readdirSync23(full, { withFileTypes: true });
@@ -15865,7 +15879,7 @@ function shellFiles(root) {
15865
15879
  for (const entry of entries) {
15866
15880
  if (!entry.isFile()) continue;
15867
15881
  if (dir === "scripts" && !entry.name.endsWith(".sh")) continue;
15868
- out.push(join64(full, entry.name));
15882
+ out.push(join65(full, entry.name));
15869
15883
  }
15870
15884
  }
15871
15885
  return out;
@@ -15899,7 +15913,7 @@ async function runPipeTrapCheck() {
15899
15913
 
15900
15914
  // src/lib/plugin-allowlist-convention.ts
15901
15915
  import { readFileSync as readFileSync44 } from "fs";
15902
- import { join as join65 } from "path";
15916
+ import { join as join66 } from "path";
15903
15917
  var COMPUTE_MAIN_TF = "modules/cloud/aws/compute/main.tf";
15904
15918
  var PLUGIN_TEMPLATE_MAIN_TF = "modules/plugins/_template/main.tf";
15905
15919
  var ALLOWLIST_MAIN_TF = "modules/cloud/aws/plugin-allowlist/main.tf";
@@ -15910,7 +15924,7 @@ var PLUGIN = "<plugin>";
15910
15924
  var ACCOUNT = "<account>";
15911
15925
  function read(repoRoot, relative11) {
15912
15926
  try {
15913
- return readFileSync44(join65(repoRoot, relative11), "utf8");
15927
+ return readFileSync44(join66(repoRoot, relative11), "utf8");
15914
15928
  } catch {
15915
15929
  throw new Error(`plugin-allowlist drift guard: cannot read ${relative11}`);
15916
15930
  }
@@ -16038,32 +16052,32 @@ async function runPluginAllowlistConventionCheck() {
16038
16052
  }
16039
16053
 
16040
16054
  // src/scripts/check-plugin-collisions.ts
16041
- import { existsSync as existsSync56 } from "fs";
16042
- import { join as join67 } from "path";
16055
+ import { existsSync as existsSync57 } from "fs";
16056
+ import { join as join68 } from "path";
16043
16057
 
16044
16058
  // src/lib/plugin-collision-guard.ts
16045
- import { existsSync as existsSync55, readdirSync as readdirSync24, statSync as statSync16 } from "fs";
16046
- import { join as join66 } from "path";
16059
+ import { existsSync as existsSync56, readdirSync as readdirSync24, statSync as statSync16 } from "fs";
16060
+ import { join as join67 } from "path";
16047
16061
  var PYTEST_SPECIAL = /* @__PURE__ */ new Set(["conftest.py"]);
16048
16062
  var IGNORED_DIRS = /* @__PURE__ */ new Set([".venv", "node_modules", "__pycache__", ".git", "dist", "build"]);
16049
16063
  function subdirectories(dir) {
16050
- if (!existsSync55(dir)) return [];
16064
+ if (!existsSync56(dir)) return [];
16051
16065
  return readdirSync24(dir).filter((entry) => {
16052
16066
  if (IGNORED_DIRS.has(entry) || entry.startsWith(".")) return false;
16053
16067
  try {
16054
- return statSync16(join66(dir, entry)).isDirectory();
16068
+ return statSync16(join67(dir, entry)).isDirectory();
16055
16069
  } catch {
16056
16070
  return false;
16057
16071
  }
16058
16072
  });
16059
16073
  }
16060
16074
  function regularPackagesOf(pluginDir2) {
16061
- return subdirectories(pluginDir2).filter((name) => existsSync55(join66(pluginDir2, name, "__init__.py"))).sort();
16075
+ return subdirectories(pluginDir2).filter((name) => existsSync56(join67(pluginDir2, name, "__init__.py"))).sort();
16062
16076
  }
16063
16077
  function bareTestModulesOf(pluginDir2) {
16064
- const testsDir = join66(pluginDir2, "tests");
16065
- if (!existsSync55(testsDir)) return [];
16066
- if (existsSync55(join66(testsDir, "__init__.py"))) return [];
16078
+ const testsDir = join67(pluginDir2, "tests");
16079
+ if (!existsSync56(testsDir)) return [];
16080
+ if (existsSync56(join67(testsDir, "__init__.py"))) return [];
16067
16081
  return readdirSync24(testsDir).filter((f) => f.endsWith(".py") && !PYTEST_SPECIAL.has(f)).sort();
16068
16082
  }
16069
16083
  function findCollisions(servicesDir, pluginDirs) {
@@ -16072,7 +16086,7 @@ function findCollisions(servicesDir, pluginDirs) {
16072
16086
  const gather = (kind, namesOf) => {
16073
16087
  const claims = /* @__PURE__ */ new Map();
16074
16088
  for (const plugin of plugins) {
16075
- for (const name of namesOf(join66(servicesDir, plugin))) {
16089
+ for (const name of namesOf(join67(servicesDir, plugin))) {
16076
16090
  claims.set(name, [...claims.get(name) ?? [], plugin]);
16077
16091
  }
16078
16092
  }
@@ -16110,8 +16124,8 @@ function formatCollisions(collisions) {
16110
16124
  // src/scripts/check-plugin-collisions.ts
16111
16125
  async function runPluginCollisionCheck() {
16112
16126
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
16113
- const servicesDir = join67(root, "services");
16114
- if (!existsSync56(servicesDir)) {
16127
+ const servicesDir = join68(root, "services");
16128
+ if (!existsSync57(servicesDir)) {
16115
16129
  console.log("\u2713 plugin collision guard: no services/ directory \u2014 nothing to compare");
16116
16130
  return;
16117
16131
  }
@@ -16128,8 +16142,8 @@ async function runPluginCollisionCheck() {
16128
16142
  }
16129
16143
 
16130
16144
  // src/lib/plugin-terraform-guard.ts
16131
- import { existsSync as existsSync57, readFileSync as readFileSync45, readdirSync as readdirSync25 } from "fs";
16132
- import { dirname as dirname13, join as join68, relative as relative10, sep as sep4 } from "path";
16145
+ import { existsSync as existsSync58, readFileSync as readFileSync45, readdirSync as readdirSync25 } from "fs";
16146
+ import { dirname as dirname13, join as join69, relative as relative10, sep as sep4 } from "path";
16133
16147
  var SKIP_DIRS4 = /* @__PURE__ */ new Set(["node_modules", ".git", ".worktrees", "dist", ".venv", "__pycache__"]);
16134
16148
  var PLUGIN_MANIFEST_FILE2 = "biffo.plugin.json";
16135
16149
  function findPluginManifests(root) {
@@ -16144,9 +16158,9 @@ function findPluginManifests(root) {
16144
16158
  for (const entry of entries) {
16145
16159
  if (entry.isDirectory()) {
16146
16160
  if (SKIP_DIRS4.has(entry.name)) continue;
16147
- walk2(join68(dir, entry.name));
16161
+ walk2(join69(dir, entry.name));
16148
16162
  } else if (entry.isFile() && entry.name === PLUGIN_MANIFEST_FILE2) {
16149
- found.push(relative10(root, join68(dir, entry.name)).split(sep4).join("/"));
16163
+ found.push(relative10(root, join69(dir, entry.name)).split(sep4).join("/"));
16150
16164
  }
16151
16165
  }
16152
16166
  };
@@ -16171,14 +16185,14 @@ function readSubscriptions(absManifestPath) {
16171
16185
  }
16172
16186
  function checkPluginTerraform(root) {
16173
16187
  const violations = [];
16174
- const coreManifest = existsSync57(join68(root, CORE_MANIFEST_FILE)) ? readCoreManifest(root) : null;
16188
+ const coreManifest = existsSync58(join69(root, CORE_MANIFEST_FILE)) ? readCoreManifest(root) : null;
16175
16189
  for (const manifest of findPluginManifests(root)) {
16176
16190
  if (coreManifest && !isTemplateOwned(manifest, coreManifest)) continue;
16177
- const absManifest = join68(root, manifest);
16191
+ const absManifest = join69(root, manifest);
16178
16192
  const subscriptions = readSubscriptions(absManifest);
16179
16193
  if (subscriptions === null) continue;
16180
16194
  const pluginDir2 = dirname13(absManifest);
16181
- if (existsSync57(join68(pluginDir2, "terraform"))) continue;
16195
+ if (existsSync58(join69(pluginDir2, "terraform"))) continue;
16182
16196
  const relPluginDir = relative10(root, pluginDir2).split(sep4).join("/");
16183
16197
  violations.push({
16184
16198
  manifest,
@@ -16209,12 +16223,12 @@ async function runPluginTerraformCheck() {
16209
16223
  }
16210
16224
 
16211
16225
  // src/scripts/check-plugin-tool-supply.ts
16212
- import { existsSync as existsSync59 } from "fs";
16213
- import { join as join70 } from "path";
16226
+ import { existsSync as existsSync60 } from "fs";
16227
+ import { join as join71 } from "path";
16214
16228
 
16215
16229
  // src/lib/plugin-tool-supply-audit.ts
16216
- import { existsSync as existsSync58, readFileSync as readFileSync46, readdirSync as readdirSync26, statSync as statSync17 } from "fs";
16217
- import { join as join69 } from "path";
16230
+ import { existsSync as existsSync59, readFileSync as readFileSync46, readdirSync as readdirSync26, statSync as statSync17 } from "fs";
16231
+ import { join as join70 } from "path";
16218
16232
 
16219
16233
  // src/lib/openrouter-model-snapshot.ts
16220
16234
  var OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT = "2026-09-25T20:12:57Z";
@@ -16689,7 +16703,7 @@ function listDirs(root) {
16689
16703
  }
16690
16704
  return entries.filter((e) => {
16691
16705
  try {
16692
- return statSync17(join69(root, e)).isDirectory();
16706
+ return statSync17(join70(root, e)).isDirectory();
16693
16707
  } catch {
16694
16708
  return false;
16695
16709
  }
@@ -16705,7 +16719,7 @@ function walkFiles2(root, accept, skipDir) {
16705
16719
  return;
16706
16720
  }
16707
16721
  for (const entry of entries) {
16708
- const p = join69(dir, entry);
16722
+ const p = join70(dir, entry);
16709
16723
  let st;
16710
16724
  try {
16711
16725
  st = statSync17(p);
@@ -16731,14 +16745,14 @@ function pluginPythonFiles(pluginDir2) {
16731
16745
  );
16732
16746
  }
16733
16747
  function pluginTerraformFiles(pluginDir2) {
16734
- const tfDir = join69(pluginDir2, "terraform");
16748
+ const tfDir = join70(pluginDir2, "terraform");
16735
16749
  let entries;
16736
16750
  try {
16737
16751
  entries = readdirSync26(tfDir);
16738
16752
  } catch {
16739
16753
  return [];
16740
16754
  }
16741
- return entries.filter((e) => e.endsWith(".tf")).map((e) => join69(tfDir, e)).sort();
16755
+ return entries.filter((e) => e.endsWith(".tf")).map((e) => join70(tfDir, e)).sort();
16742
16756
  }
16743
16757
  function extractManifestTools(manifestText) {
16744
16758
  let parsed;
@@ -16990,8 +17004,8 @@ function isSnapshotStale(fetchedAt, now) {
16990
17004
  function normalizeModelId(id) {
16991
17005
  return id.endsWith(":online") ? id.slice(0, -":online".length) : id;
16992
17006
  }
16993
- var CONFIG_PY_PATH = join69("services", "api", "src", "api", "config.py");
16994
- var ORCHESTRATION_SCHEMA_PATH = join69(
17007
+ var CONFIG_PY_PATH = join70("services", "api", "src", "api", "config.py");
17008
+ var ORCHESTRATION_SCHEMA_PATH = join70(
16995
17009
  "services",
16996
17010
  "api",
16997
17011
  "src",
@@ -17004,10 +17018,10 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
17004
17018
  const snapshotFetchedAt = options.snapshotFetchedAt ?? OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT;
17005
17019
  const now = options.now ?? /* @__PURE__ */ new Date();
17006
17020
  const snapshotAgeEnforced = options.enforceSnapshotAge ?? true;
17007
- const configPath = join69(repoRoot, CONFIG_PY_PATH);
17008
- const orchestrationPath = join69(repoRoot, ORCHESTRATION_SCHEMA_PATH);
17009
- const configMissing = !existsSync58(configPath);
17010
- const orchestrationSchemaMissing = !existsSync58(orchestrationPath);
17021
+ const configPath = join70(repoRoot, CONFIG_PY_PATH);
17022
+ const orchestrationPath = join70(repoRoot, ORCHESTRATION_SCHEMA_PATH);
17023
+ const configMissing = !existsSync59(configPath);
17024
+ const orchestrationSchemaMissing = !existsSync59(orchestrationPath);
17011
17025
  const knownSet = new Set(knownModelIds);
17012
17026
  const snapshotEmpty = knownModelIds.length === 0;
17013
17027
  const snapshotStale = isSnapshotStale(snapshotFetchedAt, now);
@@ -17079,7 +17093,7 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
17079
17093
  function discoverPluginDirs(pluginsRoot) {
17080
17094
  return listDirs(pluginsRoot).filter((name) => {
17081
17095
  try {
17082
- return statSync17(join69(pluginsRoot, name, "biffo.plugin.json")).isFile();
17096
+ return statSync17(join70(pluginsRoot, name, "biffo.plugin.json")).isFile();
17083
17097
  } catch {
17084
17098
  return false;
17085
17099
  }
@@ -17092,8 +17106,8 @@ function auditPluginToolSupply(pluginsRoot) {
17092
17106
  let terraformBlind = false;
17093
17107
  let totalDeclaredTools = 0;
17094
17108
  for (const name of pluginNames) {
17095
- const pluginDir2 = join69(pluginsRoot, name);
17096
- const manifestText = readFileSync46(join69(pluginDir2, "biffo.plugin.json"), "utf8");
17109
+ const pluginDir2 = join70(pluginsRoot, name);
17110
+ const manifestText = readFileSync46(join70(pluginDir2, "biffo.plugin.json"), "utf8");
17097
17111
  const manifest = extractManifestTools(manifestText);
17098
17112
  if (manifest.parseError) {
17099
17113
  findings.push({
@@ -17191,7 +17205,7 @@ function auditPluginToolSupply(pluginsRoot) {
17191
17205
  requiredEnvVars: envResult.envVars,
17192
17206
  missingEnvVars: anyWired ? [] : envResult.envVars,
17193
17207
  status: anyWired ? "ok" : "missing-env",
17194
- 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`
17208
+ 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`
17195
17209
  });
17196
17210
  }
17197
17211
  }
@@ -17231,8 +17245,8 @@ async function runPluginToolSupplyCheck() {
17231
17245
  return;
17232
17246
  }
17233
17247
  let allOk = true;
17234
- const pluginsRoot = join70(root, "services", "_plugins");
17235
- if (!existsSync59(pluginsRoot)) {
17248
+ const pluginsRoot = join71(root, "services", "_plugins");
17249
+ if (!existsSync60(pluginsRoot)) {
17236
17250
  console.log("\u2713 plugin tool-supply guard: no services/_plugins/ \u2014 nothing to audit");
17237
17251
  } else {
17238
17252
  const report = auditPluginToolSupply(pluginsRoot);
@@ -17262,8 +17276,8 @@ async function runPluginToolSupplyCheck() {
17262
17276
  console.log(`\u2713 plugin tool-supply guard: ${report.summary}`);
17263
17277
  }
17264
17278
  }
17265
- const servicesApiRoot = join70(root, "services", "api");
17266
- if (!existsSync59(servicesApiRoot)) {
17279
+ const servicesApiRoot = join71(root, "services", "api");
17280
+ if (!existsSync60(servicesApiRoot)) {
17267
17281
  console.log("\u2713 plugin model-id guard: no services/api/ \u2014 nothing to audit");
17268
17282
  } else {
17269
17283
  const modelReport = auditDeclaredModelIds(root, {
@@ -17647,12 +17661,12 @@ async function runSharedFileReductionCheck(args) {
17647
17661
  }
17648
17662
 
17649
17663
  // src/scripts/check-skeleton-drift.ts
17650
- import { existsSync as existsSync60, readdirSync as readdirSync28 } from "fs";
17651
- import { join as join72 } from "path";
17664
+ import { existsSync as existsSync61, readdirSync as readdirSync28 } from "fs";
17665
+ import { join as join73 } from "path";
17652
17666
 
17653
17667
  // src/lib/skeleton-drift-guard.ts
17654
17668
  import { readFileSync as readFileSync49, readdirSync as readdirSync27, statSync as statSync18 } from "fs";
17655
- import { join as join71 } from "path";
17669
+ import { join as join72 } from "path";
17656
17670
  var isWorkflow = (rel) => rel.startsWith(".github/workflows/") && (rel.endsWith(".yml") || rel.endsWith(".yaml"));
17657
17671
  var isRootLayout = (rel) => rel.endsWith("src/app/layout.tsx");
17658
17672
  var uncommented = (contents) => contents.split("\n").filter((line) => !/^\s*(\/\/|\/\*|\*)/.test(line)).join("\n");
@@ -17716,7 +17730,7 @@ function walk(dir, base = dir) {
17716
17730
  }
17717
17731
  for (const entry of entries) {
17718
17732
  if (entry === ".venv" || entry === "node_modules" || entry === ".git") continue;
17719
- const abs = join71(dir, entry);
17733
+ const abs = join72(dir, entry);
17720
17734
  let isDir;
17721
17735
  try {
17722
17736
  isDir = statSync18(abs).isDirectory();
@@ -17738,7 +17752,7 @@ function auditSkeleton(skeletonRoot, name, rules = SKELETON_RULES) {
17738
17752
  if (!rule.appliesTo(rel)) continue;
17739
17753
  let contents;
17740
17754
  try {
17741
- contents = readFileSync49(join71(skeletonRoot, rel), "utf8");
17755
+ contents = readFileSync49(join72(skeletonRoot, rel), "utf8");
17742
17756
  } catch {
17743
17757
  continue;
17744
17758
  }
@@ -17767,23 +17781,23 @@ function formatViolations2(violations) {
17767
17781
 
17768
17782
  // src/scripts/check-skeleton-drift.ts
17769
17783
  function discoverSkeletons(root) {
17770
- const skeletonsDir = join72(root, "_skeletons");
17784
+ const skeletonsDir = join73(root, "_skeletons");
17771
17785
  let entries;
17772
17786
  try {
17773
17787
  entries = readdirSync28(skeletonsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
17774
17788
  } catch {
17775
17789
  return [];
17776
17790
  }
17777
- return entries.filter((name) => existsSync60(join72(skeletonsDir, name, ".github", "workflows", "ci.yml"))).sort();
17791
+ return entries.filter((name) => existsSync61(join73(skeletonsDir, name, ".github", "workflows", "ci.yml"))).sort();
17778
17792
  }
17779
17793
  async function runSkeletonDriftCheck() {
17780
17794
  const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
17781
17795
  const skeletons = discoverSkeletons(root);
17782
17796
  let filesConsidered = 0;
17783
17797
  for (const name of skeletons) {
17784
- const skeletonRoot = join72(root, "_skeletons", name);
17798
+ const skeletonRoot = join73(root, "_skeletons", name);
17785
17799
  filesConsidered += findWorkflowFiles(skeletonRoot).length;
17786
- if (existsSync60(join72(skeletonRoot, "apps", "frontend", "src", "app", "layout.tsx"))) {
17800
+ if (existsSync61(join73(skeletonRoot, "apps", "frontend", "src", "app", "layout.tsx"))) {
17787
17801
  filesConsidered += 1;
17788
17802
  }
17789
17803
  }
@@ -17791,7 +17805,7 @@ async function runSkeletonDriftCheck() {
17791
17805
  `audited ${skeletons.length} skeleton(s) (${skeletons.join(", ") || "none"}), ${filesConsidered} file(s) considered, under ${root}/_skeletons`
17792
17806
  );
17793
17807
  if (skeletons.length === 0) {
17794
- if (!existsSync60(join72(root, "_skeletons"))) {
17808
+ if (!existsSync61(join73(root, "_skeletons"))) {
17795
17809
  console.log(
17796
17810
  `\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.`
17797
17811
  );
@@ -17803,7 +17817,7 @@ async function runSkeletonDriftCheck() {
17803
17817
  process.exit(1);
17804
17818
  }
17805
17819
  const violations = skeletons.flatMap(
17806
- (name) => auditSkeleton(join72(root, "_skeletons", name), name)
17820
+ (name) => auditSkeleton(join73(root, "_skeletons", name), name)
17807
17821
  );
17808
17822
  if (violations.length > 0) {
17809
17823
  console.error("\u2717 Skeleton-drift guard: drift found between this repo and its scaffolding\n");
@@ -18004,8 +18018,8 @@ function rawArgsAfter(subcommand) {
18004
18018
  }
18005
18019
 
18006
18020
  // src/commands/doctor.ts
18007
- import { existsSync as existsSync61, readFileSync as readFileSync50 } from "fs";
18008
- import { join as join74, resolve as resolve23 } from "path";
18021
+ import { existsSync as existsSync62, readFileSync as readFileSync50 } from "fs";
18022
+ import { join as join75, resolve as resolve23 } from "path";
18009
18023
  import chalk21 from "chalk";
18010
18024
  import { Command as Command27 } from "commander";
18011
18025
 
@@ -18346,11 +18360,11 @@ async function reapAllBareBranches(cwd, branches, worktrees, currentBranch, deps
18346
18360
 
18347
18361
  // src/lib/scratch-clone-scan.ts
18348
18362
  import { readdirSync as readdirSync29, statSync as statSync19 } from "fs";
18349
- import { join as join73 } from "path";
18363
+ import { join as join74 } from "path";
18350
18364
  var INTEGRATION_BRANCH = "dev";
18351
18365
  function isPlainCloneDir(path) {
18352
18366
  try {
18353
- return statSync19(join73(path, ".git")).isDirectory();
18367
+ return statSync19(join74(path, ".git")).isDirectory();
18354
18368
  } catch {
18355
18369
  return false;
18356
18370
  }
@@ -18365,7 +18379,7 @@ async function findScratchCloneCandidates(estateRoot, deps) {
18365
18379
  const names = readdirSync29(estateRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
18366
18380
  const candidates = [];
18367
18381
  for (const name of names) {
18368
- const path = join73(estateRoot, name);
18382
+ const path = join74(estateRoot, name);
18369
18383
  if (!isPlainCloneDir(path)) continue;
18370
18384
  let branch;
18371
18385
  try {
@@ -18545,8 +18559,8 @@ function printScratchCloneReports(estateRoot, reports) {
18545
18559
  );
18546
18560
  }
18547
18561
  function readLocalCoreVersion(cwd) {
18548
- const path = join74(cwd, INSTANCE_CORE_FILE);
18549
- if (!existsSync61(path)) return null;
18562
+ const path = join75(cwd, INSTANCE_CORE_FILE);
18563
+ if (!existsSync62(path)) return null;
18550
18564
  try {
18551
18565
  return extractVersionField(readFileSync50(path, "utf8"));
18552
18566
  } catch {
@@ -18568,8 +18582,8 @@ function extractVersionField(contents) {
18568
18582
  return match?.[1] ?? null;
18569
18583
  }
18570
18584
  function readFossil(cwd) {
18571
- const path = join74(cwd, CORE_VERSION_FILE);
18572
- if (!existsSync61(path)) return null;
18585
+ const path = join75(cwd, CORE_VERSION_FILE);
18586
+ if (!existsSync62(path)) return null;
18573
18587
  try {
18574
18588
  const value = readFileSync50(path, "utf8").trim();
18575
18589
  return value === "" ? null : value;