@biffo/cli 0.328.0 → 0.330.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +317 -206
- package/package.json +1 -1
- package/scripts/pg-test-db.sh +28 -2
package/dist/index.js
CHANGED
|
@@ -7172,8 +7172,12 @@ async function startLocalAwsSink(parameters = /* @__PURE__ */ new Map()) {
|
|
|
7172
7172
|
}
|
|
7173
7173
|
|
|
7174
7174
|
// src/lib/plugin-compose/raise-postgres.ts
|
|
7175
|
-
function raisePostgres(runner, script, cwd) {
|
|
7176
|
-
const { status, stdout } = runner.run(script, [], {
|
|
7175
|
+
function raisePostgres(runner, script, cwd, env) {
|
|
7176
|
+
const { status, stdout } = runner.run(script, [], {
|
|
7177
|
+
cwd,
|
|
7178
|
+
captureStdout: true,
|
|
7179
|
+
...env ? { env } : {}
|
|
7180
|
+
});
|
|
7177
7181
|
if (status !== 0) {
|
|
7178
7182
|
return { dsn: null, status: status ?? 2 };
|
|
7179
7183
|
}
|
|
@@ -12604,6 +12608,97 @@ function runChecksOnce(runner, cwd, dsn) {
|
|
|
12604
12608
|
return status ?? 2;
|
|
12605
12609
|
}
|
|
12606
12610
|
|
|
12611
|
+
// src/lib/plugin-verify/manifest-schema.ts
|
|
12612
|
+
import {
|
|
12613
|
+
existsSync as existsSync43,
|
|
12614
|
+
mkdirSync as mkdirSync14,
|
|
12615
|
+
mkdtempSync as mkdtempSync6,
|
|
12616
|
+
readdirSync as readdirSync15,
|
|
12617
|
+
readFileSync as readFileSync31,
|
|
12618
|
+
writeFileSync as writeFileSync15
|
|
12619
|
+
} from "fs";
|
|
12620
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
12621
|
+
import { join as join45 } from "path";
|
|
12622
|
+
var MANIFEST = "biffo.plugin.json";
|
|
12623
|
+
function hasNativeSchema(cwd) {
|
|
12624
|
+
if (existsSync43(join45(cwd, "alembic.ini")) || existsSync43(join45(cwd, "services", "api", "alembic.ini"))) {
|
|
12625
|
+
return true;
|
|
12626
|
+
}
|
|
12627
|
+
const imports = join45(cwd, "db", "imports");
|
|
12628
|
+
if (!existsSync43(imports)) return false;
|
|
12629
|
+
return readdirSync15(imports, { withFileTypes: true }).some(
|
|
12630
|
+
(d) => d.isDirectory() && readdirSync15(join45(imports, d.name)).some((f) => f.endsWith(".sql"))
|
|
12631
|
+
);
|
|
12632
|
+
}
|
|
12633
|
+
function buildManifestSchema(runner, pluginRoot, coreRoot) {
|
|
12634
|
+
const manifestPath = join45(pluginRoot, MANIFEST);
|
|
12635
|
+
if (!existsSync43(manifestPath)) return null;
|
|
12636
|
+
const manifest = JSON.parse(readFileSync31(manifestPath, "utf8"));
|
|
12637
|
+
if (!manifest.name || !Array.isArray(manifest.tables) || manifest.tables.length === 0) return null;
|
|
12638
|
+
const scratch = mkdtempSync6(join45(tmpdir6(), "biffo-plugin-verify-alembic-"));
|
|
12639
|
+
const versions = join45(scratch, "migrations", "versions");
|
|
12640
|
+
const serviceDir = join45(scratch, "services", manifest.name);
|
|
12641
|
+
mkdirSync14(versions, { recursive: true });
|
|
12642
|
+
mkdirSync14(serviceDir, { recursive: true });
|
|
12643
|
+
writeFileSync15(join45(serviceDir, MANIFEST), readFileSync31(manifestPath), { mode: 384 });
|
|
12644
|
+
writeFileSync15(join45(scratch, "alembic.ini"), "[alembic]\nscript_location = migrations\n", {
|
|
12645
|
+
mode: 384
|
|
12646
|
+
});
|
|
12647
|
+
writeFileSync15(join45(scratch, "migrations", "env.py"), ENV_PY, { mode: 384 });
|
|
12648
|
+
const coreApi = join45(coreRoot, "services", "api");
|
|
12649
|
+
const generator = join45(coreApi, "scripts", "generate_plugin_migrations.py");
|
|
12650
|
+
if (!existsSync43(generator)) {
|
|
12651
|
+
throw new Error(`Core at ${coreRoot} has no ${generator} to build the plugin schema with`);
|
|
12652
|
+
}
|
|
12653
|
+
const { status } = runner.run(
|
|
12654
|
+
"uv",
|
|
12655
|
+
[
|
|
12656
|
+
"run",
|
|
12657
|
+
"--project",
|
|
12658
|
+
coreApi,
|
|
12659
|
+
"python",
|
|
12660
|
+
generator,
|
|
12661
|
+
"--services-root",
|
|
12662
|
+
join45(scratch, "services"),
|
|
12663
|
+
"--versions-dir",
|
|
12664
|
+
versions,
|
|
12665
|
+
"--plugin",
|
|
12666
|
+
manifest.name
|
|
12667
|
+
],
|
|
12668
|
+
{ cwd: coreApi, captureStdout: false }
|
|
12669
|
+
);
|
|
12670
|
+
if (status !== 0) {
|
|
12671
|
+
throw new Error(`the plugin migration generator exited ${status}`);
|
|
12672
|
+
}
|
|
12673
|
+
if (!readdirSync15(versions).some((f) => f.endsWith(".py"))) {
|
|
12674
|
+
throw new Error("the plugin migration generator produced no migration for the declared tables");
|
|
12675
|
+
}
|
|
12676
|
+
const env = {};
|
|
12677
|
+
for (const [k, v] of Object.entries(process.env)) if (v !== void 0) env[k] = v;
|
|
12678
|
+
env.BIFFO_REPO_ROOT = pluginRoot;
|
|
12679
|
+
env.BIFFO_PG_ALEMBIC_DIR = scratch;
|
|
12680
|
+
env.BIFFO_PG_ALEMBIC_PROJECT = coreApi;
|
|
12681
|
+
return { env };
|
|
12682
|
+
}
|
|
12683
|
+
var ENV_PY = `import asyncio
|
|
12684
|
+
import os
|
|
12685
|
+
|
|
12686
|
+
from alembic import context
|
|
12687
|
+
from sqlalchemy.ext.asyncio import create_async_engine
|
|
12688
|
+
|
|
12689
|
+
|
|
12690
|
+
async def run() -> None:
|
|
12691
|
+
engine = create_async_engine(os.environ["BIFFO_DATABASE_URL"])
|
|
12692
|
+
async with engine.connect() as connection:
|
|
12693
|
+
await connection.run_sync(lambda c: context.configure(connection=c, target_metadata=None))
|
|
12694
|
+
async with connection.begin():
|
|
12695
|
+
await connection.run_sync(lambda _: context.run_migrations())
|
|
12696
|
+
await engine.dispose()
|
|
12697
|
+
|
|
12698
|
+
|
|
12699
|
+
asyncio.run(run())
|
|
12700
|
+
`;
|
|
12701
|
+
|
|
12607
12702
|
// src/lib/plugin-verify/run-plugin-verify.ts
|
|
12608
12703
|
var REAL_CORE_LABEL = "plugin verify (real_core)";
|
|
12609
12704
|
var PG_TEST_DB_SCRIPT2 = "scripts/pg-test-db.sh";
|
|
@@ -12624,7 +12719,22 @@ async function runPluginVerify(options, deps) {
|
|
|
12624
12719
|
log.error(packagedScriptMissing(PG_TEST_DB_SCRIPT2));
|
|
12625
12720
|
return 2;
|
|
12626
12721
|
}
|
|
12627
|
-
|
|
12722
|
+
let schemaEnv;
|
|
12723
|
+
if (!hasNativeSchema(options.cwd)) {
|
|
12724
|
+
const resolveCore = deps.schemaCoreRoot ?? deps.realCore?.coreRoot;
|
|
12725
|
+
try {
|
|
12726
|
+
if (resolveCore) {
|
|
12727
|
+
const built = buildManifestSchema(deps.runner, options.cwd, resolveCore());
|
|
12728
|
+
if (built) schemaEnv = built.env;
|
|
12729
|
+
}
|
|
12730
|
+
} catch (err) {
|
|
12731
|
+
log.error(
|
|
12732
|
+
`plugin verify: could not build the test schema from biffo.plugin.json's tables: ${err.message}`
|
|
12733
|
+
);
|
|
12734
|
+
return 1;
|
|
12735
|
+
}
|
|
12736
|
+
}
|
|
12737
|
+
const raised = raisePostgres(deps.runner, script, options.cwd, schemaEnv);
|
|
12628
12738
|
if (!raised.dsn) {
|
|
12629
12739
|
log.error(
|
|
12630
12740
|
`plugin verify: could not provision the local Postgres test database (${PG_TEST_DB_SCRIPT2} exited ${raised.status})`
|
|
@@ -12706,6 +12816,7 @@ var pluginVerifyCommand = new Command22("verify").description(
|
|
|
12706
12816
|
{
|
|
12707
12817
|
runner,
|
|
12708
12818
|
findScript,
|
|
12819
|
+
schemaCoreRoot: () => resolveCoreRootForCli(options.coreRoot, runner),
|
|
12709
12820
|
realCore: {
|
|
12710
12821
|
coreRoot: () => resolveCoreRootForCli(options.coreRoot, runner),
|
|
12711
12822
|
compose: realComposeDeps(runner, findScript, (l) => log.info(l))
|
|
@@ -12733,7 +12844,7 @@ pluginCommand.addCommand(pluginVerifyCommand);
|
|
|
12733
12844
|
import { Command as Command25 } from "commander";
|
|
12734
12845
|
|
|
12735
12846
|
// src/commands/sibling-check-identity.ts
|
|
12736
|
-
import { existsSync as
|
|
12847
|
+
import { existsSync as existsSync44, readFileSync as readFileSync32 } from "fs";
|
|
12737
12848
|
import { resolve as resolve22 } from "path";
|
|
12738
12849
|
import chalk20 from "chalk";
|
|
12739
12850
|
import { Command as Command24 } from "commander";
|
|
@@ -12927,7 +13038,7 @@ async function fetchPublishedIdentity(portalUrl) {
|
|
|
12927
13038
|
}
|
|
12928
13039
|
async function resolveConfig4(options) {
|
|
12929
13040
|
if (options.config) {
|
|
12930
|
-
const raw = JSON.parse(
|
|
13041
|
+
const raw = JSON.parse(readFileSync32(resolve22(options.config), "utf8"));
|
|
12931
13042
|
const result = BiffoConfigSchema.safeParse(raw);
|
|
12932
13043
|
if (!result.success) {
|
|
12933
13044
|
log.error(`Invalid config at ${options.config}:`);
|
|
@@ -12947,8 +13058,8 @@ async function resolveConfig4(options) {
|
|
|
12947
13058
|
return cfg;
|
|
12948
13059
|
}
|
|
12949
13060
|
const localConfigPath = resolve22(process.cwd(), "biffo.config.json");
|
|
12950
|
-
if (
|
|
12951
|
-
const raw = JSON.parse(
|
|
13061
|
+
if (existsSync44(localConfigPath)) {
|
|
13062
|
+
const raw = JSON.parse(readFileSync32(localConfigPath, "utf8"));
|
|
12952
13063
|
const result = BiffoConfigSchema.safeParse(raw);
|
|
12953
13064
|
if (result.success) return result.data;
|
|
12954
13065
|
if (isTemplatePlaceholderConfig(raw)) {
|
|
@@ -12994,20 +13105,20 @@ siblingCommand.addCommand(siblingCheckIdentityCommand);
|
|
|
12994
13105
|
import { Command as Command26 } from "commander";
|
|
12995
13106
|
|
|
12996
13107
|
// src/scripts/check-adr-numbering.ts
|
|
12997
|
-
import { existsSync as
|
|
12998
|
-
import { join as
|
|
13108
|
+
import { existsSync as existsSync46 } from "fs";
|
|
13109
|
+
import { join as join47 } from "path";
|
|
12999
13110
|
|
|
13000
13111
|
// src/lib/adr-numbering-guard.ts
|
|
13001
|
-
import { existsSync as
|
|
13002
|
-
import { join as
|
|
13112
|
+
import { existsSync as existsSync45, readdirSync as readdirSync16, readFileSync as readFileSync33 } from "fs";
|
|
13113
|
+
import { join as join46 } from "path";
|
|
13003
13114
|
var ADR_FILENAME = /^(\d{4})-.+\.md$/;
|
|
13004
13115
|
var ALLOWLIST_FILENAME = ".numbering-allowlist";
|
|
13005
13116
|
var TEMPLATE_ADR_RESERVED_UPTO = "0099";
|
|
13006
13117
|
function readAdrNumberingAllowlist(adrDir) {
|
|
13007
|
-
const path =
|
|
13008
|
-
if (!
|
|
13118
|
+
const path = join46(adrDir, ALLOWLIST_FILENAME);
|
|
13119
|
+
if (!existsSync45(path)) return /* @__PURE__ */ new Set();
|
|
13009
13120
|
const numbers = /* @__PURE__ */ new Set();
|
|
13010
|
-
for (const rawLine of
|
|
13121
|
+
for (const rawLine of readFileSync33(path, "utf8").split("\n")) {
|
|
13011
13122
|
const line = rawLine.split("#")[0].trim();
|
|
13012
13123
|
if (line) numbers.add(line);
|
|
13013
13124
|
}
|
|
@@ -13015,8 +13126,8 @@ function readAdrNumberingAllowlist(adrDir) {
|
|
|
13015
13126
|
}
|
|
13016
13127
|
function adrNumbersIn(adrDir) {
|
|
13017
13128
|
const claims = /* @__PURE__ */ new Map();
|
|
13018
|
-
if (!
|
|
13019
|
-
for (const entry of
|
|
13129
|
+
if (!existsSync45(adrDir)) return claims;
|
|
13130
|
+
for (const entry of readdirSync16(adrDir).sort()) {
|
|
13020
13131
|
const match = ADR_FILENAME.exec(entry);
|
|
13021
13132
|
if (!match) continue;
|
|
13022
13133
|
const number = match[1];
|
|
@@ -13070,8 +13181,8 @@ function formatAdrReservedRangeViolations(violations, reservedUpTo = TEMPLATE_AD
|
|
|
13070
13181
|
// src/scripts/check-adr-numbering.ts
|
|
13071
13182
|
async function runAdrNumberingCheck() {
|
|
13072
13183
|
const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
13073
|
-
const adrDir =
|
|
13074
|
-
if (!
|
|
13184
|
+
const adrDir = join47(root, "docs", "ADR");
|
|
13185
|
+
if (!existsSync46(adrDir)) {
|
|
13075
13186
|
console.log("\u2713 ADR numbering guard: no docs/ADR/ directory \u2014 nothing to compare");
|
|
13076
13187
|
return;
|
|
13077
13188
|
}
|
|
@@ -13109,8 +13220,8 @@ Already accepted? List it in docs/ADR/${ALLOWLIST_FILENAME} instead of leaving t
|
|
|
13109
13220
|
}
|
|
13110
13221
|
|
|
13111
13222
|
// src/lib/api-gateway-integration-guard.ts
|
|
13112
|
-
import { readFileSync as
|
|
13113
|
-
import { join as
|
|
13223
|
+
import { readFileSync as readFileSync34, readdirSync as readdirSync17, statSync as statSync10 } from "fs";
|
|
13224
|
+
import { join as join48 } from "path";
|
|
13114
13225
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
|
|
13115
13226
|
var MODULE_TYPE = "module";
|
|
13116
13227
|
var INTEGRATION_TYPE = "aws_apigatewayv2_integration";
|
|
@@ -13187,12 +13298,12 @@ function walkTerraformFiles(root) {
|
|
|
13187
13298
|
const walk2 = (dir) => {
|
|
13188
13299
|
let entries;
|
|
13189
13300
|
try {
|
|
13190
|
-
entries =
|
|
13301
|
+
entries = readdirSync17(dir);
|
|
13191
13302
|
} catch {
|
|
13192
13303
|
return;
|
|
13193
13304
|
}
|
|
13194
13305
|
for (const entry of entries) {
|
|
13195
|
-
const p =
|
|
13306
|
+
const p = join48(dir, entry);
|
|
13196
13307
|
let st;
|
|
13197
13308
|
try {
|
|
13198
13309
|
st = statSync10(p);
|
|
@@ -13236,7 +13347,7 @@ function auditApiGatewayIntegrations(root) {
|
|
|
13236
13347
|
let rawModuleCount = 0;
|
|
13237
13348
|
let rawIntegrationCount = 0;
|
|
13238
13349
|
for (const file of files) {
|
|
13239
|
-
const text =
|
|
13350
|
+
const text = readFileSync34(file, "utf8");
|
|
13240
13351
|
rawModuleCount += countRawResourceDeclarations(text, MODULE_TYPE);
|
|
13241
13352
|
rawIntegrationCount += countRawResourceDeclarations(text, INTEGRATION_TYPE);
|
|
13242
13353
|
moduleBlocks.push(...findModuleBlocks(text, file));
|
|
@@ -13608,18 +13719,18 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
|
|
|
13608
13719
|
}
|
|
13609
13720
|
|
|
13610
13721
|
// src/lib/claim-invocation-parity.ts
|
|
13611
|
-
import { existsSync as
|
|
13612
|
-
import { join as
|
|
13722
|
+
import { existsSync as existsSync47, readFileSync as readFileSync35, readdirSync as readdirSync18 } from "fs";
|
|
13723
|
+
import { join as join49 } from "path";
|
|
13613
13724
|
function distributedAgentsDocs(root) {
|
|
13614
13725
|
const docs = [];
|
|
13615
|
-
const own =
|
|
13616
|
-
if (
|
|
13617
|
-
const skeletons =
|
|
13618
|
-
if (
|
|
13619
|
-
for (const name of
|
|
13620
|
-
const abs =
|
|
13621
|
-
if (!
|
|
13622
|
-
docs.push({ path: `_skeletons/${name}/AGENTS.md`, text:
|
|
13726
|
+
const own = join49(root, "AGENTS.md");
|
|
13727
|
+
if (existsSync47(own)) docs.push({ path: "AGENTS.md", text: readFileSync35(own, "utf8") });
|
|
13728
|
+
const skeletons = join49(root, "_skeletons");
|
|
13729
|
+
if (existsSync47(skeletons)) {
|
|
13730
|
+
for (const name of readdirSync18(skeletons).sort()) {
|
|
13731
|
+
const abs = join49(skeletons, name, "AGENTS.md");
|
|
13732
|
+
if (!existsSync47(abs)) continue;
|
|
13733
|
+
docs.push({ path: `_skeletons/${name}/AGENTS.md`, text: readFileSync35(abs, "utf8") });
|
|
13623
13734
|
}
|
|
13624
13735
|
}
|
|
13625
13736
|
return docs;
|
|
@@ -13751,12 +13862,12 @@ async function runClaimInvocationCheck() {
|
|
|
13751
13862
|
}
|
|
13752
13863
|
|
|
13753
13864
|
// src/scripts/check-codeql-suppression.ts
|
|
13754
|
-
import { existsSync as
|
|
13755
|
-
import { join as
|
|
13865
|
+
import { existsSync as existsSync48 } from "fs";
|
|
13866
|
+
import { join as join51, relative as relative8 } from "path";
|
|
13756
13867
|
|
|
13757
13868
|
// src/lib/codeql-suppression-guard.ts
|
|
13758
|
-
import { readdirSync as
|
|
13759
|
-
import { join as
|
|
13869
|
+
import { readdirSync as readdirSync19, readFileSync as readFileSync36, statSync as statSync11 } from "fs";
|
|
13870
|
+
import { join as join50 } from "path";
|
|
13760
13871
|
var SKIP_DIRS2 = /* @__PURE__ */ new Set([
|
|
13761
13872
|
".git",
|
|
13762
13873
|
".worktrees",
|
|
@@ -13782,12 +13893,12 @@ function walkSourceFiles(root) {
|
|
|
13782
13893
|
const walk2 = (dir) => {
|
|
13783
13894
|
let entries;
|
|
13784
13895
|
try {
|
|
13785
|
-
entries =
|
|
13896
|
+
entries = readdirSync19(dir);
|
|
13786
13897
|
} catch {
|
|
13787
13898
|
return;
|
|
13788
13899
|
}
|
|
13789
13900
|
for (const entry of entries) {
|
|
13790
|
-
const p =
|
|
13901
|
+
const p = join50(dir, entry);
|
|
13791
13902
|
let st;
|
|
13792
13903
|
try {
|
|
13793
13904
|
st = statSync11(p);
|
|
@@ -13813,7 +13924,7 @@ function countSourceFiles(root) {
|
|
|
13813
13924
|
function sweepCodeqlSuppressionComments(root) {
|
|
13814
13925
|
const hits = [];
|
|
13815
13926
|
for (const path of walkSourceFiles(root)) {
|
|
13816
|
-
const text =
|
|
13927
|
+
const text = readFileSync36(path, "utf8");
|
|
13817
13928
|
for (const line of findCodeqlSuppressionComments(text)) {
|
|
13818
13929
|
hits.push({ path, line, text: text.split("\n")[line - 1] ?? "" });
|
|
13819
13930
|
}
|
|
@@ -13824,8 +13935,8 @@ function sweepCodeqlSuppressionComments(root) {
|
|
|
13824
13935
|
// src/scripts/check-codeql-suppression.ts
|
|
13825
13936
|
async function runCodeqlSuppressionCheck() {
|
|
13826
13937
|
const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
13827
|
-
const scanRoot =
|
|
13828
|
-
if (!
|
|
13938
|
+
const scanRoot = join51(root, "cli", "src");
|
|
13939
|
+
if (!existsSync48(scanRoot)) {
|
|
13829
13940
|
console.log(
|
|
13830
13941
|
"\u2014 codeql-suppression guard: skipped \u2014 no cli/src in this repo, so there is no CLI source to scan."
|
|
13831
13942
|
);
|
|
@@ -13849,12 +13960,12 @@ async function runCodeqlSuppressionCheck() {
|
|
|
13849
13960
|
}
|
|
13850
13961
|
|
|
13851
13962
|
// src/scripts/check-cognito-invite-template.ts
|
|
13852
|
-
import { existsSync as
|
|
13853
|
-
import { join as
|
|
13963
|
+
import { existsSync as existsSync49 } from "fs";
|
|
13964
|
+
import { join as join53 } from "path";
|
|
13854
13965
|
|
|
13855
13966
|
// src/lib/cognito-invite-template-guard.ts
|
|
13856
|
-
import { readdirSync as
|
|
13857
|
-
import { join as
|
|
13967
|
+
import { readdirSync as readdirSync20, readFileSync as readFileSync37, statSync as statSync12 } from "fs";
|
|
13968
|
+
import { join as join52 } from "path";
|
|
13858
13969
|
var REQUIRED_INVITE_MEMBERS = ["email_subject", "email_message", "sms_message"];
|
|
13859
13970
|
var REQUIRED_INVITE_PLACEHOLDERS = ["{username}", "{####}"];
|
|
13860
13971
|
var PLACEHOLDER_MEMBERS = ["email_message", "sms_message"];
|
|
@@ -13931,14 +14042,14 @@ function findModuleTerraformFiles(repoRoot) {
|
|
|
13931
14042
|
const walk2 = (dir, relative11) => {
|
|
13932
14043
|
let entries;
|
|
13933
14044
|
try {
|
|
13934
|
-
entries =
|
|
14045
|
+
entries = readdirSync20(dir);
|
|
13935
14046
|
} catch {
|
|
13936
14047
|
return;
|
|
13937
14048
|
}
|
|
13938
14049
|
for (const entry of entries) {
|
|
13939
14050
|
if (entry === "node_modules" || entry === ".git" || entry === ".worktrees" || entry === ".venv")
|
|
13940
14051
|
continue;
|
|
13941
|
-
const full =
|
|
14052
|
+
const full = join52(dir, entry);
|
|
13942
14053
|
const rel = `${relative11}/${entry}`;
|
|
13943
14054
|
let isDir;
|
|
13944
14055
|
try {
|
|
@@ -13953,12 +14064,12 @@ function findModuleTerraformFiles(repoRoot) {
|
|
|
13953
14064
|
}
|
|
13954
14065
|
}
|
|
13955
14066
|
};
|
|
13956
|
-
walk2(
|
|
14067
|
+
walk2(join52(repoRoot, "modules"), "modules");
|
|
13957
14068
|
return found.sort();
|
|
13958
14069
|
}
|
|
13959
14070
|
function checkCognitoInviteTemplates(repoRoot) {
|
|
13960
14071
|
return findModuleTerraformFiles(repoRoot).flatMap(
|
|
13961
|
-
(file) => checkInviteTemplateSource(file,
|
|
14072
|
+
(file) => checkInviteTemplateSource(file, readFileSync37(join52(repoRoot, file), "utf8"))
|
|
13962
14073
|
);
|
|
13963
14074
|
}
|
|
13964
14075
|
|
|
@@ -13968,7 +14079,7 @@ async function runCognitoInviteTemplateCheck() {
|
|
|
13968
14079
|
const files = findModuleTerraformFiles(root);
|
|
13969
14080
|
console.log(`audited ${files.length} .tf file(s) under modules/ under ${root}`);
|
|
13970
14081
|
if (files.length === 0) {
|
|
13971
|
-
if (!
|
|
14082
|
+
if (!existsSync49(join53(root, "modules"))) {
|
|
13972
14083
|
console.log(
|
|
13973
14084
|
`\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.`
|
|
13974
14085
|
);
|
|
@@ -13992,11 +14103,11 @@ async function runCognitoInviteTemplateCheck() {
|
|
|
13992
14103
|
}
|
|
13993
14104
|
|
|
13994
14105
|
// src/scripts/check-core-direct-paths.ts
|
|
13995
|
-
import { join as
|
|
14106
|
+
import { join as join55 } from "path";
|
|
13996
14107
|
|
|
13997
14108
|
// src/lib/core-direct-paths-audit.ts
|
|
13998
|
-
import { existsSync as
|
|
13999
|
-
import { join as
|
|
14109
|
+
import { existsSync as existsSync50, readFileSync as readFileSync38, readdirSync as readdirSync21, statSync as statSync13 } from "fs";
|
|
14110
|
+
import { join as join54 } from "path";
|
|
14000
14111
|
var EXTERNAL_BASE_IDENTIFIERS = ["CORE_API_URL"];
|
|
14001
14112
|
var API_ROUTE_PREFIX = "/api/v1";
|
|
14002
14113
|
var TEST_FILE_SUFFIXES = [".test.ts", ".test.tsx", ".spec.ts", ".spec.tsx"];
|
|
@@ -14155,12 +14266,12 @@ function walkFiles(root, accept, skipDir) {
|
|
|
14155
14266
|
const walk2 = (dir) => {
|
|
14156
14267
|
let entries;
|
|
14157
14268
|
try {
|
|
14158
|
-
entries =
|
|
14269
|
+
entries = readdirSync21(dir);
|
|
14159
14270
|
} catch {
|
|
14160
14271
|
return;
|
|
14161
14272
|
}
|
|
14162
14273
|
for (const entry of entries) {
|
|
14163
|
-
const p =
|
|
14274
|
+
const p = join54(dir, entry);
|
|
14164
14275
|
let st;
|
|
14165
14276
|
try {
|
|
14166
14277
|
st = statSync13(p);
|
|
@@ -14190,7 +14301,7 @@ function auditFrontendExtraction(frontendSrcDir, externalBases = EXTERNAL_BASE_I
|
|
|
14190
14301
|
const extracted = [];
|
|
14191
14302
|
let rawTotal = 0;
|
|
14192
14303
|
for (const file of files) {
|
|
14193
|
-
const text =
|
|
14304
|
+
const text = readFileSync38(file, "utf8");
|
|
14194
14305
|
rawTotal += countRawExternalOccurrences(text, externalBases);
|
|
14195
14306
|
extracted.push(...extractCoreDirectPaths(text, file, externalBases));
|
|
14196
14307
|
}
|
|
@@ -14239,7 +14350,7 @@ function auditCoreRouteExtraction(apiSrcDir) {
|
|
|
14239
14350
|
const prefixSet = /* @__PURE__ */ new Set();
|
|
14240
14351
|
let rawApiRouterCount = 0;
|
|
14241
14352
|
for (const file of files) {
|
|
14242
|
-
const text =
|
|
14353
|
+
const text = readFileSync38(file, "utf8");
|
|
14243
14354
|
const extraction = extractCoreRoutePrefixes(text);
|
|
14244
14355
|
rawApiRouterCount += extraction.rawApiRouterCount;
|
|
14245
14356
|
for (const p of extraction.prefixes) prefixSet.add(normalizePrefix(p));
|
|
@@ -14255,10 +14366,10 @@ function pathMatchesAnyCorePrefix(normalized, corePrefixes, apiRoutePrefix = API
|
|
|
14255
14366
|
}
|
|
14256
14367
|
function resolveSiblingCoreSrc(params) {
|
|
14257
14368
|
const { estateDir, sibling } = params;
|
|
14258
|
-
const configPath =
|
|
14369
|
+
const configPath = join54(estateDir, sibling, "biffo.sibling.json");
|
|
14259
14370
|
let raw;
|
|
14260
14371
|
try {
|
|
14261
|
-
raw =
|
|
14372
|
+
raw = readFileSync38(configPath, "utf8");
|
|
14262
14373
|
} catch (err) {
|
|
14263
14374
|
throw new Error(
|
|
14264
14375
|
`cannot resolve ${sibling}'s core: ${configPath} does not exist or is unreadable (${err.message}) -- refusing to guess which core serves this sibling.`
|
|
@@ -14278,8 +14389,8 @@ function resolveSiblingCoreSrc(params) {
|
|
|
14278
14389
|
`cannot resolve ${sibling}'s core: ${configPath} has no non-empty "core_project" field.`
|
|
14279
14390
|
);
|
|
14280
14391
|
}
|
|
14281
|
-
const coreApiSrcDir =
|
|
14282
|
-
if (!
|
|
14392
|
+
const coreApiSrcDir = join54(estateDir, coreProject, "services", "api", "src");
|
|
14393
|
+
if (!existsSync50(coreApiSrcDir)) {
|
|
14283
14394
|
throw new Error(
|
|
14284
14395
|
`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.`
|
|
14285
14396
|
);
|
|
@@ -14332,7 +14443,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
|
|
|
14332
14443
|
}
|
|
14333
14444
|
}
|
|
14334
14445
|
const sibling = opts.sibling ?? "sibling-template (self-check)";
|
|
14335
|
-
const frontendSrcDir = opts.frontendSrc ??
|
|
14446
|
+
const frontendSrcDir = opts.frontendSrc ?? join55(root, "_skeletons", "sibling-template", "apps", "frontend", "src");
|
|
14336
14447
|
let coreApiSrcDir;
|
|
14337
14448
|
let coreProject = null;
|
|
14338
14449
|
if (opts.coreSrc) {
|
|
@@ -14348,7 +14459,7 @@ async function runCoreDirectPathsCheck(opts = {}) {
|
|
|
14348
14459
|
coreApiSrcDir = resolution.coreApiSrcDir;
|
|
14349
14460
|
coreProject = resolution.coreProject;
|
|
14350
14461
|
} else {
|
|
14351
|
-
coreApiSrcDir =
|
|
14462
|
+
coreApiSrcDir = join55(root, "services", "api", "src");
|
|
14352
14463
|
}
|
|
14353
14464
|
const report = auditSiblingCoreDirectPaths({ sibling, frontendSrcDir, coreApiSrcDir });
|
|
14354
14465
|
console.log(
|
|
@@ -14475,8 +14586,8 @@ async function runOwnershipCheck(argv) {
|
|
|
14475
14586
|
const { stdout } = await execa("git", ["diff", "--cached", "--name-status"], { cwd: root });
|
|
14476
14587
|
({ changed: changedFiles, deleted: deletedFiles } = parseNameStatus(stdout));
|
|
14477
14588
|
if (messageFile) {
|
|
14478
|
-
const { readFileSync:
|
|
14479
|
-
if (
|
|
14589
|
+
const { readFileSync: readFileSync52, existsSync: existsSync64 } = await import("fs");
|
|
14590
|
+
if (existsSync64(messageFile)) commitMessage = readFileSync52(messageFile, "utf8");
|
|
14480
14591
|
}
|
|
14481
14592
|
} else {
|
|
14482
14593
|
const base = process.env["GITHUB_BASE_REF"] ?? args[0];
|
|
@@ -14599,21 +14710,21 @@ ${BOLD}If the divergence is deliberate${OFF}
|
|
|
14599
14710
|
}
|
|
14600
14711
|
|
|
14601
14712
|
// src/scripts/check-distribution-inventory.ts
|
|
14602
|
-
import { existsSync as
|
|
14603
|
-
import { join as
|
|
14713
|
+
import { existsSync as existsSync52 } from "fs";
|
|
14714
|
+
import { join as join57 } from "path";
|
|
14604
14715
|
|
|
14605
14716
|
// src/lib/distribution-inventory.ts
|
|
14606
|
-
import { existsSync as
|
|
14607
|
-
import { join as
|
|
14717
|
+
import { existsSync as existsSync51, readFileSync as readFileSync39 } from "fs";
|
|
14718
|
+
import { join as join56 } from "path";
|
|
14608
14719
|
var INVENTORY_FILENAME = "distribution-inventory.json";
|
|
14609
14720
|
function loadDistributionInventory(root) {
|
|
14610
|
-
const path =
|
|
14611
|
-
if (!
|
|
14721
|
+
const path = join56(root, INVENTORY_FILENAME);
|
|
14722
|
+
if (!existsSync51(path)) {
|
|
14612
14723
|
throw new Error(
|
|
14613
14724
|
`${INVENTORY_FILENAME} not found at ${root} -- expected it beside core-manifest.json`
|
|
14614
14725
|
);
|
|
14615
14726
|
}
|
|
14616
|
-
return JSON.parse(
|
|
14727
|
+
return JSON.parse(readFileSync39(path, "utf8"));
|
|
14617
14728
|
}
|
|
14618
14729
|
function validateInventory(inventory) {
|
|
14619
14730
|
const violations = [];
|
|
@@ -14773,7 +14884,7 @@ async function runDistributionInventoryCheck(root) {
|
|
|
14773
14884
|
);
|
|
14774
14885
|
return;
|
|
14775
14886
|
}
|
|
14776
|
-
if (!
|
|
14887
|
+
if (!existsSync52(join57(repoRoot, INVENTORY_FILENAME))) {
|
|
14777
14888
|
console.log(
|
|
14778
14889
|
`\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.`
|
|
14779
14890
|
);
|
|
@@ -14799,7 +14910,7 @@ async function runDistributionInventoryCheck(root) {
|
|
|
14799
14910
|
}
|
|
14800
14911
|
|
|
14801
14912
|
// src/scripts/check-distribution-remote-state.ts
|
|
14802
|
-
import { join as
|
|
14913
|
+
import { join as join58 } from "path";
|
|
14803
14914
|
async function ghExecCommand(file, args) {
|
|
14804
14915
|
const result = await execa(file, args, { reject: false });
|
|
14805
14916
|
return { stdout: String(result.stdout ?? ""), exitCode: result.exitCode ?? null };
|
|
@@ -14814,7 +14925,7 @@ async function runDistributionRemoteStateCheck(root) {
|
|
|
14814
14925
|
}
|
|
14815
14926
|
}
|
|
14816
14927
|
console.log(
|
|
14817
|
-
`distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${
|
|
14928
|
+
`distribution-remote-state: examined ${assertions.length} remote content assertion(s) declared across ${inventory.entries.length} inventory entries (${join58(repoRoot, "distribution-inventory.json")})`
|
|
14818
14929
|
);
|
|
14819
14930
|
if (assertions.length === 0) {
|
|
14820
14931
|
console.log("\u2713 distribution-remote-state: nothing declared to check");
|
|
@@ -14859,8 +14970,8 @@ ${assertion.ref}`;
|
|
|
14859
14970
|
}
|
|
14860
14971
|
|
|
14861
14972
|
// src/lib/eventbridge-log-permission-guard.ts
|
|
14862
|
-
import { readFileSync as
|
|
14863
|
-
import { join as
|
|
14973
|
+
import { readFileSync as readFileSync40, readdirSync as readdirSync22, statSync as statSync14 } from "fs";
|
|
14974
|
+
import { join as join59 } from "path";
|
|
14864
14975
|
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".terraform", ".worktrees", "dist"]);
|
|
14865
14976
|
var EVENT_TARGET_TYPE = "aws_cloudwatch_event_target";
|
|
14866
14977
|
var LOG_RESOURCE_POLICY_TYPE = "aws_cloudwatch_log_resource_policy";
|
|
@@ -14932,12 +15043,12 @@ function walkTerraformFiles2(root) {
|
|
|
14932
15043
|
const walk2 = (dir) => {
|
|
14933
15044
|
let entries;
|
|
14934
15045
|
try {
|
|
14935
|
-
entries =
|
|
15046
|
+
entries = readdirSync22(dir);
|
|
14936
15047
|
} catch {
|
|
14937
15048
|
return;
|
|
14938
15049
|
}
|
|
14939
15050
|
for (const entry of entries) {
|
|
14940
|
-
const p =
|
|
15051
|
+
const p = join59(dir, entry);
|
|
14941
15052
|
let st;
|
|
14942
15053
|
try {
|
|
14943
15054
|
st = statSync14(p);
|
|
@@ -14980,7 +15091,7 @@ function auditEventBridgeLogPermissions(root) {
|
|
|
14980
15091
|
let rawEventTargetCount = 0;
|
|
14981
15092
|
let rawLogPolicyCount = 0;
|
|
14982
15093
|
for (const file of files) {
|
|
14983
|
-
const text =
|
|
15094
|
+
const text = readFileSync40(file, "utf8");
|
|
14984
15095
|
rawEventTargetCount += countRawResourceDeclarations2(text, EVENT_TARGET_TYPE);
|
|
14985
15096
|
rawLogPolicyCount += countRawResourceDeclarations2(text, LOG_RESOURCE_POLICY_TYPE);
|
|
14986
15097
|
eventTargetBlocks.push(...findResourceBlocks2(text, file, EVENT_TARGET_TYPE));
|
|
@@ -15077,8 +15188,8 @@ async function runEventBridgeLogPermissionCheck() {
|
|
|
15077
15188
|
}
|
|
15078
15189
|
|
|
15079
15190
|
// src/scripts/check-instance-adoption.ts
|
|
15080
|
-
import { existsSync as
|
|
15081
|
-
import { join as
|
|
15191
|
+
import { existsSync as existsSync53 } from "fs";
|
|
15192
|
+
import { join as join60 } from "path";
|
|
15082
15193
|
async function runInstanceAdoptionCheck(opts = {}) {
|
|
15083
15194
|
if (!opts.instanceDir) {
|
|
15084
15195
|
console.error(
|
|
@@ -15086,7 +15197,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
|
|
|
15086
15197
|
);
|
|
15087
15198
|
process.exit(2);
|
|
15088
15199
|
}
|
|
15089
|
-
if (!
|
|
15200
|
+
if (!existsSync53(opts.instanceDir)) {
|
|
15090
15201
|
console.error(
|
|
15091
15202
|
`\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.`
|
|
15092
15203
|
);
|
|
@@ -15094,7 +15205,7 @@ async function runInstanceAdoptionCheck(opts = {}) {
|
|
|
15094
15205
|
}
|
|
15095
15206
|
const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
15096
15207
|
const theirsDir = opts.theirsDir ?? root;
|
|
15097
|
-
const instanceLabel = opts.instance ??
|
|
15208
|
+
const instanceLabel = opts.instance ?? join60(opts.instanceDir).split("/").filter(Boolean).pop();
|
|
15098
15209
|
const report = checkInstanceAdoption(theirsDir, opts.instanceDir);
|
|
15099
15210
|
console.log(
|
|
15100
15211
|
`examined ${report.examinedInstances} instance (${instanceLabel}) against ${report.registeredPairs} registered pair(s), ${report.applicablePairs} applicable to this instance, against template tree ${theirsDir}`
|
|
@@ -15116,12 +15227,12 @@ async function runInstanceAdoptionCheck(opts = {}) {
|
|
|
15116
15227
|
}
|
|
15117
15228
|
|
|
15118
15229
|
// src/lib/lambda-output-guard.ts
|
|
15119
|
-
import { readFileSync as
|
|
15120
|
-
import { join as
|
|
15230
|
+
import { readFileSync as readFileSync42 } from "fs";
|
|
15231
|
+
import { join as join62 } from "path";
|
|
15121
15232
|
|
|
15122
15233
|
// src/lib/terraform-input-guard.ts
|
|
15123
|
-
import { existsSync as
|
|
15124
|
-
import { join as
|
|
15234
|
+
import { existsSync as existsSync54, readdirSync as readdirSync23, readFileSync as readFileSync41, statSync as statSync15 } from "fs";
|
|
15235
|
+
import { join as join61 } from "path";
|
|
15125
15236
|
var GUARDED_SUBCOMMANDS = [
|
|
15126
15237
|
"init",
|
|
15127
15238
|
"plan",
|
|
@@ -15135,18 +15246,18 @@ function stripComments2(source) {
|
|
|
15135
15246
|
return source.split("\n").map((line) => line.replace(/(^|\s)#.*$/, "$1")).join("\n");
|
|
15136
15247
|
}
|
|
15137
15248
|
function vendoredPluginServiceDirs(repoRoot) {
|
|
15138
|
-
const servicesDir =
|
|
15249
|
+
const servicesDir = join61(repoRoot, "services");
|
|
15139
15250
|
const result = /* @__PURE__ */ new Set();
|
|
15140
15251
|
let entries;
|
|
15141
15252
|
try {
|
|
15142
|
-
entries =
|
|
15253
|
+
entries = readdirSync23(servicesDir);
|
|
15143
15254
|
} catch {
|
|
15144
15255
|
return result;
|
|
15145
15256
|
}
|
|
15146
15257
|
for (const entry of entries) {
|
|
15147
|
-
const full =
|
|
15148
|
-
if (!
|
|
15149
|
-
if (
|
|
15258
|
+
const full = join61(servicesDir, entry);
|
|
15259
|
+
if (!existsSync54(full) || !statSync15(full).isDirectory()) continue;
|
|
15260
|
+
if (existsSync54(join61(full, "biffo.plugin.json"))) {
|
|
15150
15261
|
result.add(entry);
|
|
15151
15262
|
}
|
|
15152
15263
|
}
|
|
@@ -15158,7 +15269,7 @@ function findWorkflowFiles(repoRoot) {
|
|
|
15158
15269
|
const walk2 = (dir, relative11) => {
|
|
15159
15270
|
let entries;
|
|
15160
15271
|
try {
|
|
15161
|
-
entries =
|
|
15272
|
+
entries = readdirSync23(dir);
|
|
15162
15273
|
} catch {
|
|
15163
15274
|
return;
|
|
15164
15275
|
}
|
|
@@ -15168,7 +15279,7 @@ function findWorkflowFiles(repoRoot) {
|
|
|
15168
15279
|
if (entry === ".github" && relative11.startsWith("services/") && vendoredPluginDirs.has(relative11.slice("services/".length))) {
|
|
15169
15280
|
continue;
|
|
15170
15281
|
}
|
|
15171
|
-
const full =
|
|
15282
|
+
const full = join61(dir, entry);
|
|
15172
15283
|
const rel = relative11 ? `${relative11}/${entry}` : entry;
|
|
15173
15284
|
let isDir;
|
|
15174
15285
|
try {
|
|
@@ -15218,7 +15329,7 @@ function checkWorkflowSource(file, rawSource) {
|
|
|
15218
15329
|
}
|
|
15219
15330
|
function checkTerraformInput(repoRoot) {
|
|
15220
15331
|
return findWorkflowFiles(repoRoot).flatMap(
|
|
15221
|
-
(file) => checkWorkflowSource(file,
|
|
15332
|
+
(file) => checkWorkflowSource(file, readFileSync41(join61(repoRoot, file), "utf8"))
|
|
15222
15333
|
);
|
|
15223
15334
|
}
|
|
15224
15335
|
|
|
@@ -15276,7 +15387,7 @@ function checkWorkflowSource2(file, rawSource) {
|
|
|
15276
15387
|
}
|
|
15277
15388
|
function checkLambdaOutput(repoRoot) {
|
|
15278
15389
|
return findWorkflowFiles(repoRoot).flatMap(
|
|
15279
|
-
(file) => checkWorkflowSource2(file,
|
|
15390
|
+
(file) => checkWorkflowSource2(file, readFileSync42(join62(repoRoot, file), "utf8"))
|
|
15280
15391
|
);
|
|
15281
15392
|
}
|
|
15282
15393
|
|
|
@@ -15304,8 +15415,8 @@ async function runLambdaOutputCheck() {
|
|
|
15304
15415
|
}
|
|
15305
15416
|
|
|
15306
15417
|
// src/scripts/check-migration-body-change.ts
|
|
15307
|
-
import { existsSync as
|
|
15308
|
-
import { join as
|
|
15418
|
+
import { existsSync as existsSync55 } from "fs";
|
|
15419
|
+
import { join as join63 } from "path";
|
|
15309
15420
|
|
|
15310
15421
|
// src/lib/migration-body-change-guard.ts
|
|
15311
15422
|
function checkMigrationBodyChangeMarkers(diffs) {
|
|
@@ -15387,7 +15498,7 @@ async function runMigrationBodyChangeCheck(argv) {
|
|
|
15387
15498
|
);
|
|
15388
15499
|
return;
|
|
15389
15500
|
}
|
|
15390
|
-
if (!
|
|
15501
|
+
if (!existsSync55(join63(root, MIGRATIONS_VERSIONS_DIR))) {
|
|
15391
15502
|
console.log(`\u2713 migration body-change guard: no ${MIGRATIONS_VERSIONS_DIR} in this repo.`);
|
|
15392
15503
|
return;
|
|
15393
15504
|
}
|
|
@@ -15493,8 +15604,8 @@ ${BOLD2}What to do${OFF2}
|
|
|
15493
15604
|
}
|
|
15494
15605
|
|
|
15495
15606
|
// src/scripts/check-orphan-ratchet.ts
|
|
15496
|
-
import { existsSync as
|
|
15497
|
-
import { basename as basename3, join as
|
|
15607
|
+
import { existsSync as existsSync56 } from "fs";
|
|
15608
|
+
import { basename as basename3, join as join64 } from "path";
|
|
15498
15609
|
function reportOrphan(entry, manifest) {
|
|
15499
15610
|
console.error(` ${entry.path}`);
|
|
15500
15611
|
const { templateOwnedMatch, nearestUserOwnedEntries } = explainOwnership(entry.path, manifest);
|
|
@@ -15516,7 +15627,7 @@ function reportOrphan(entry, manifest) {
|
|
|
15516
15627
|
}
|
|
15517
15628
|
}
|
|
15518
15629
|
async function runOrphanRatchetCheck(opts = {}) {
|
|
15519
|
-
if (opts.instanceDir !== void 0 && !
|
|
15630
|
+
if (opts.instanceDir !== void 0 && !existsSync56(opts.instanceDir)) {
|
|
15520
15631
|
console.error(
|
|
15521
15632
|
`\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.`
|
|
15522
15633
|
);
|
|
@@ -15533,7 +15644,7 @@ async function runOrphanRatchetCheck(opts = {}) {
|
|
|
15533
15644
|
"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."
|
|
15534
15645
|
);
|
|
15535
15646
|
}
|
|
15536
|
-
if (!
|
|
15647
|
+
if (!existsSync56(join64(theirsDir, CORE_MANIFEST_FILE))) {
|
|
15537
15648
|
console.log(
|
|
15538
15649
|
`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.`
|
|
15539
15650
|
);
|
|
@@ -15564,8 +15675,8 @@ baseline was ${String(ratchet.baseline)}, now ${String(ratchet.count)}. See biff
|
|
|
15564
15675
|
}
|
|
15565
15676
|
|
|
15566
15677
|
// src/lib/ownership-header-claim-guard.ts
|
|
15567
|
-
import { readFileSync as
|
|
15568
|
-
import { join as
|
|
15678
|
+
import { readFileSync as readFileSync43 } from "fs";
|
|
15679
|
+
import { join as join65 } from "path";
|
|
15569
15680
|
var OWNERSHIP_HEADER_SWEEP_DIRS = [
|
|
15570
15681
|
"scripts",
|
|
15571
15682
|
".githooks",
|
|
@@ -15774,7 +15885,7 @@ function sweepOwnershipHeaderClaims(root, options = {}) {
|
|
|
15774
15885
|
for (const rel of files) {
|
|
15775
15886
|
let content;
|
|
15776
15887
|
try {
|
|
15777
|
-
content =
|
|
15888
|
+
content = readFileSync43(join65(root, rel), "utf8");
|
|
15778
15889
|
} catch {
|
|
15779
15890
|
continue;
|
|
15780
15891
|
}
|
|
@@ -15849,8 +15960,8 @@ async function runOwnershipHeaderClaimCheck() {
|
|
|
15849
15960
|
}
|
|
15850
15961
|
|
|
15851
15962
|
// src/scripts/check-pipe-trap.ts
|
|
15852
|
-
import { readFileSync as
|
|
15853
|
-
import { join as
|
|
15963
|
+
import { readFileSync as readFileSync44, readdirSync as readdirSync24 } from "fs";
|
|
15964
|
+
import { join as join66, relative as relative9 } from "path";
|
|
15854
15965
|
|
|
15855
15966
|
// src/lib/pipe-trap-guard.ts
|
|
15856
15967
|
var STATUS_BEARING = [
|
|
@@ -15946,17 +16057,17 @@ function findPipeTraps(source) {
|
|
|
15946
16057
|
function shellFiles(root) {
|
|
15947
16058
|
const out = [];
|
|
15948
16059
|
for (const dir of ["scripts", ".githooks"]) {
|
|
15949
|
-
const full =
|
|
16060
|
+
const full = join66(root, dir);
|
|
15950
16061
|
let entries;
|
|
15951
16062
|
try {
|
|
15952
|
-
entries =
|
|
16063
|
+
entries = readdirSync24(full, { withFileTypes: true });
|
|
15953
16064
|
} catch {
|
|
15954
16065
|
continue;
|
|
15955
16066
|
}
|
|
15956
16067
|
for (const entry of entries) {
|
|
15957
16068
|
if (!entry.isFile()) continue;
|
|
15958
16069
|
if (dir === "scripts" && !entry.name.endsWith(".sh")) continue;
|
|
15959
|
-
out.push(
|
|
16070
|
+
out.push(join66(full, entry.name));
|
|
15960
16071
|
}
|
|
15961
16072
|
}
|
|
15962
16073
|
return out;
|
|
@@ -15972,7 +16083,7 @@ async function runPipeTrapCheck() {
|
|
|
15972
16083
|
process.exit(1);
|
|
15973
16084
|
}
|
|
15974
16085
|
const findings = files.flatMap(
|
|
15975
|
-
(file) => findPipeTraps(
|
|
16086
|
+
(file) => findPipeTraps(readFileSync44(file, "utf8")).map(
|
|
15976
16087
|
(t) => `${relative9(root, file)}:${t.line} ${t.text}
|
|
15977
16088
|
${t.reason}`
|
|
15978
16089
|
)
|
|
@@ -15989,8 +16100,8 @@ async function runPipeTrapCheck() {
|
|
|
15989
16100
|
}
|
|
15990
16101
|
|
|
15991
16102
|
// src/lib/plugin-allowlist-convention.ts
|
|
15992
|
-
import { readFileSync as
|
|
15993
|
-
import { join as
|
|
16103
|
+
import { readFileSync as readFileSync45 } from "fs";
|
|
16104
|
+
import { join as join67 } from "path";
|
|
15994
16105
|
var COMPUTE_MAIN_TF = "modules/cloud/aws/compute/main.tf";
|
|
15995
16106
|
var PLUGIN_TEMPLATE_MAIN_TF = "modules/plugins/_template/main.tf";
|
|
15996
16107
|
var ALLOWLIST_MAIN_TF = "modules/cloud/aws/plugin-allowlist/main.tf";
|
|
@@ -16001,7 +16112,7 @@ var PLUGIN = "<plugin>";
|
|
|
16001
16112
|
var ACCOUNT = "<account>";
|
|
16002
16113
|
function read(repoRoot, relative11) {
|
|
16003
16114
|
try {
|
|
16004
|
-
return
|
|
16115
|
+
return readFileSync45(join67(repoRoot, relative11), "utf8");
|
|
16005
16116
|
} catch {
|
|
16006
16117
|
throw new Error(`plugin-allowlist drift guard: cannot read ${relative11}`);
|
|
16007
16118
|
}
|
|
@@ -16129,33 +16240,33 @@ async function runPluginAllowlistConventionCheck() {
|
|
|
16129
16240
|
}
|
|
16130
16241
|
|
|
16131
16242
|
// src/scripts/check-plugin-collisions.ts
|
|
16132
|
-
import { existsSync as
|
|
16133
|
-
import { join as
|
|
16243
|
+
import { existsSync as existsSync58 } from "fs";
|
|
16244
|
+
import { join as join69 } from "path";
|
|
16134
16245
|
|
|
16135
16246
|
// src/lib/plugin-collision-guard.ts
|
|
16136
|
-
import { existsSync as
|
|
16137
|
-
import { join as
|
|
16247
|
+
import { existsSync as existsSync57, readdirSync as readdirSync25, statSync as statSync16 } from "fs";
|
|
16248
|
+
import { join as join68 } from "path";
|
|
16138
16249
|
var PYTEST_SPECIAL = /* @__PURE__ */ new Set(["conftest.py"]);
|
|
16139
16250
|
var IGNORED_DIRS = /* @__PURE__ */ new Set([".venv", "node_modules", "__pycache__", ".git", "dist", "build"]);
|
|
16140
16251
|
function subdirectories(dir) {
|
|
16141
|
-
if (!
|
|
16142
|
-
return
|
|
16252
|
+
if (!existsSync57(dir)) return [];
|
|
16253
|
+
return readdirSync25(dir).filter((entry) => {
|
|
16143
16254
|
if (IGNORED_DIRS.has(entry) || entry.startsWith(".")) return false;
|
|
16144
16255
|
try {
|
|
16145
|
-
return statSync16(
|
|
16256
|
+
return statSync16(join68(dir, entry)).isDirectory();
|
|
16146
16257
|
} catch {
|
|
16147
16258
|
return false;
|
|
16148
16259
|
}
|
|
16149
16260
|
});
|
|
16150
16261
|
}
|
|
16151
16262
|
function regularPackagesOf(pluginDir2) {
|
|
16152
|
-
return subdirectories(pluginDir2).filter((name) =>
|
|
16263
|
+
return subdirectories(pluginDir2).filter((name) => existsSync57(join68(pluginDir2, name, "__init__.py"))).sort();
|
|
16153
16264
|
}
|
|
16154
16265
|
function bareTestModulesOf(pluginDir2) {
|
|
16155
|
-
const testsDir =
|
|
16156
|
-
if (!
|
|
16157
|
-
if (
|
|
16158
|
-
return
|
|
16266
|
+
const testsDir = join68(pluginDir2, "tests");
|
|
16267
|
+
if (!existsSync57(testsDir)) return [];
|
|
16268
|
+
if (existsSync57(join68(testsDir, "__init__.py"))) return [];
|
|
16269
|
+
return readdirSync25(testsDir).filter((f) => f.endsWith(".py") && !PYTEST_SPECIAL.has(f)).sort();
|
|
16159
16270
|
}
|
|
16160
16271
|
function findCollisions(servicesDir, pluginDirs) {
|
|
16161
16272
|
const plugins = (pluginDirs ?? subdirectories(servicesDir)).filter((name) => !name.startsWith("_")).filter((name) => name !== "api").sort();
|
|
@@ -16163,7 +16274,7 @@ function findCollisions(servicesDir, pluginDirs) {
|
|
|
16163
16274
|
const gather = (kind, namesOf) => {
|
|
16164
16275
|
const claims = /* @__PURE__ */ new Map();
|
|
16165
16276
|
for (const plugin of plugins) {
|
|
16166
|
-
for (const name of namesOf(
|
|
16277
|
+
for (const name of namesOf(join68(servicesDir, plugin))) {
|
|
16167
16278
|
claims.set(name, [...claims.get(name) ?? [], plugin]);
|
|
16168
16279
|
}
|
|
16169
16280
|
}
|
|
@@ -16201,8 +16312,8 @@ function formatCollisions(collisions) {
|
|
|
16201
16312
|
// src/scripts/check-plugin-collisions.ts
|
|
16202
16313
|
async function runPluginCollisionCheck() {
|
|
16203
16314
|
const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
16204
|
-
const servicesDir =
|
|
16205
|
-
if (!
|
|
16315
|
+
const servicesDir = join69(root, "services");
|
|
16316
|
+
if (!existsSync58(servicesDir)) {
|
|
16206
16317
|
console.log("\u2713 plugin collision guard: no services/ directory \u2014 nothing to compare");
|
|
16207
16318
|
return;
|
|
16208
16319
|
}
|
|
@@ -16219,8 +16330,8 @@ async function runPluginCollisionCheck() {
|
|
|
16219
16330
|
}
|
|
16220
16331
|
|
|
16221
16332
|
// src/lib/plugin-terraform-guard.ts
|
|
16222
|
-
import { existsSync as
|
|
16223
|
-
import { dirname as dirname13, join as
|
|
16333
|
+
import { existsSync as existsSync59, readFileSync as readFileSync46, readdirSync as readdirSync26 } from "fs";
|
|
16334
|
+
import { dirname as dirname13, join as join70, relative as relative10, sep as sep4 } from "path";
|
|
16224
16335
|
var SKIP_DIRS4 = /* @__PURE__ */ new Set(["node_modules", ".git", ".worktrees", "dist", ".venv", "__pycache__"]);
|
|
16225
16336
|
var PLUGIN_MANIFEST_FILE2 = "biffo.plugin.json";
|
|
16226
16337
|
function findPluginManifests(root) {
|
|
@@ -16228,16 +16339,16 @@ function findPluginManifests(root) {
|
|
|
16228
16339
|
const walk2 = (dir) => {
|
|
16229
16340
|
let entries;
|
|
16230
16341
|
try {
|
|
16231
|
-
entries =
|
|
16342
|
+
entries = readdirSync26(dir, { withFileTypes: true });
|
|
16232
16343
|
} catch {
|
|
16233
16344
|
return;
|
|
16234
16345
|
}
|
|
16235
16346
|
for (const entry of entries) {
|
|
16236
16347
|
if (entry.isDirectory()) {
|
|
16237
16348
|
if (SKIP_DIRS4.has(entry.name)) continue;
|
|
16238
|
-
walk2(
|
|
16349
|
+
walk2(join70(dir, entry.name));
|
|
16239
16350
|
} else if (entry.isFile() && entry.name === PLUGIN_MANIFEST_FILE2) {
|
|
16240
|
-
found.push(relative10(root,
|
|
16351
|
+
found.push(relative10(root, join70(dir, entry.name)).split(sep4).join("/"));
|
|
16241
16352
|
}
|
|
16242
16353
|
}
|
|
16243
16354
|
};
|
|
@@ -16247,7 +16358,7 @@ function findPluginManifests(root) {
|
|
|
16247
16358
|
function readSubscriptions(absManifestPath) {
|
|
16248
16359
|
let parsed;
|
|
16249
16360
|
try {
|
|
16250
|
-
parsed = JSON.parse(
|
|
16361
|
+
parsed = JSON.parse(readFileSync46(absManifestPath, "utf8"));
|
|
16251
16362
|
} catch {
|
|
16252
16363
|
return null;
|
|
16253
16364
|
}
|
|
@@ -16262,14 +16373,14 @@ function readSubscriptions(absManifestPath) {
|
|
|
16262
16373
|
}
|
|
16263
16374
|
function checkPluginTerraform(root) {
|
|
16264
16375
|
const violations = [];
|
|
16265
|
-
const coreManifest =
|
|
16376
|
+
const coreManifest = existsSync59(join70(root, CORE_MANIFEST_FILE)) ? readCoreManifest(root) : null;
|
|
16266
16377
|
for (const manifest of findPluginManifests(root)) {
|
|
16267
16378
|
if (coreManifest && !isTemplateOwned(manifest, coreManifest)) continue;
|
|
16268
|
-
const absManifest =
|
|
16379
|
+
const absManifest = join70(root, manifest);
|
|
16269
16380
|
const subscriptions = readSubscriptions(absManifest);
|
|
16270
16381
|
if (subscriptions === null) continue;
|
|
16271
16382
|
const pluginDir2 = dirname13(absManifest);
|
|
16272
|
-
if (
|
|
16383
|
+
if (existsSync59(join70(pluginDir2, "terraform"))) continue;
|
|
16273
16384
|
const relPluginDir = relative10(root, pluginDir2).split(sep4).join("/");
|
|
16274
16385
|
violations.push({
|
|
16275
16386
|
manifest,
|
|
@@ -16300,12 +16411,12 @@ async function runPluginTerraformCheck() {
|
|
|
16300
16411
|
}
|
|
16301
16412
|
|
|
16302
16413
|
// src/scripts/check-plugin-tool-supply.ts
|
|
16303
|
-
import { existsSync as
|
|
16304
|
-
import { join as
|
|
16414
|
+
import { existsSync as existsSync61 } from "fs";
|
|
16415
|
+
import { join as join72 } from "path";
|
|
16305
16416
|
|
|
16306
16417
|
// src/lib/plugin-tool-supply-audit.ts
|
|
16307
|
-
import { existsSync as
|
|
16308
|
-
import { join as
|
|
16418
|
+
import { existsSync as existsSync60, readFileSync as readFileSync47, readdirSync as readdirSync27, statSync as statSync17 } from "fs";
|
|
16419
|
+
import { join as join71 } from "path";
|
|
16309
16420
|
|
|
16310
16421
|
// src/lib/openrouter-model-snapshot.ts
|
|
16311
16422
|
var OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT = "2026-09-25T20:12:57Z";
|
|
@@ -16774,13 +16885,13 @@ var OPENROUTER_MODEL_IDS = [
|
|
|
16774
16885
|
function listDirs(root) {
|
|
16775
16886
|
let entries;
|
|
16776
16887
|
try {
|
|
16777
|
-
entries =
|
|
16888
|
+
entries = readdirSync27(root);
|
|
16778
16889
|
} catch {
|
|
16779
16890
|
return [];
|
|
16780
16891
|
}
|
|
16781
16892
|
return entries.filter((e) => {
|
|
16782
16893
|
try {
|
|
16783
|
-
return statSync17(
|
|
16894
|
+
return statSync17(join71(root, e)).isDirectory();
|
|
16784
16895
|
} catch {
|
|
16785
16896
|
return false;
|
|
16786
16897
|
}
|
|
@@ -16791,12 +16902,12 @@ function walkFiles2(root, accept, skipDir) {
|
|
|
16791
16902
|
const walk2 = (dir) => {
|
|
16792
16903
|
let entries;
|
|
16793
16904
|
try {
|
|
16794
|
-
entries =
|
|
16905
|
+
entries = readdirSync27(dir);
|
|
16795
16906
|
} catch {
|
|
16796
16907
|
return;
|
|
16797
16908
|
}
|
|
16798
16909
|
for (const entry of entries) {
|
|
16799
|
-
const p =
|
|
16910
|
+
const p = join71(dir, entry);
|
|
16800
16911
|
let st;
|
|
16801
16912
|
try {
|
|
16802
16913
|
st = statSync17(p);
|
|
@@ -16822,14 +16933,14 @@ function pluginPythonFiles(pluginDir2) {
|
|
|
16822
16933
|
);
|
|
16823
16934
|
}
|
|
16824
16935
|
function pluginTerraformFiles(pluginDir2) {
|
|
16825
|
-
const tfDir =
|
|
16936
|
+
const tfDir = join71(pluginDir2, "terraform");
|
|
16826
16937
|
let entries;
|
|
16827
16938
|
try {
|
|
16828
|
-
entries =
|
|
16939
|
+
entries = readdirSync27(tfDir);
|
|
16829
16940
|
} catch {
|
|
16830
16941
|
return [];
|
|
16831
16942
|
}
|
|
16832
|
-
return entries.filter((e) => e.endsWith(".tf")).map((e) =>
|
|
16943
|
+
return entries.filter((e) => e.endsWith(".tf")).map((e) => join71(tfDir, e)).sort();
|
|
16833
16944
|
}
|
|
16834
16945
|
function extractManifestTools(manifestText) {
|
|
16835
16946
|
let parsed;
|
|
@@ -17081,8 +17192,8 @@ function isSnapshotStale(fetchedAt, now) {
|
|
|
17081
17192
|
function normalizeModelId(id) {
|
|
17082
17193
|
return id.endsWith(":online") ? id.slice(0, -":online".length) : id;
|
|
17083
17194
|
}
|
|
17084
|
-
var CONFIG_PY_PATH =
|
|
17085
|
-
var ORCHESTRATION_SCHEMA_PATH =
|
|
17195
|
+
var CONFIG_PY_PATH = join71("services", "api", "src", "api", "config.py");
|
|
17196
|
+
var ORCHESTRATION_SCHEMA_PATH = join71(
|
|
17086
17197
|
"services",
|
|
17087
17198
|
"api",
|
|
17088
17199
|
"src",
|
|
@@ -17095,10 +17206,10 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
|
|
|
17095
17206
|
const snapshotFetchedAt = options.snapshotFetchedAt ?? OPENROUTER_MODEL_SNAPSHOT_FETCHED_AT;
|
|
17096
17207
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
17097
17208
|
const snapshotAgeEnforced = options.enforceSnapshotAge ?? true;
|
|
17098
|
-
const configPath =
|
|
17099
|
-
const orchestrationPath =
|
|
17100
|
-
const configMissing = !
|
|
17101
|
-
const orchestrationSchemaMissing = !
|
|
17209
|
+
const configPath = join71(repoRoot, CONFIG_PY_PATH);
|
|
17210
|
+
const orchestrationPath = join71(repoRoot, ORCHESTRATION_SCHEMA_PATH);
|
|
17211
|
+
const configMissing = !existsSync60(configPath);
|
|
17212
|
+
const orchestrationSchemaMissing = !existsSync60(orchestrationPath);
|
|
17102
17213
|
const knownSet = new Set(knownModelIds);
|
|
17103
17214
|
const snapshotEmpty = knownModelIds.length === 0;
|
|
17104
17215
|
const snapshotStale = isSnapshotStale(snapshotFetchedAt, now);
|
|
@@ -17116,13 +17227,13 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
|
|
|
17116
17227
|
};
|
|
17117
17228
|
let settingsBlind = false;
|
|
17118
17229
|
if (!configMissing) {
|
|
17119
|
-
const settingsFields = extractSettingsModelFields(
|
|
17230
|
+
const settingsFields = extractSettingsModelFields(readFileSync47(configPath, "utf8"));
|
|
17120
17231
|
if (settingsFields.length === 0) settingsBlind = true;
|
|
17121
17232
|
for (const { field, value } of settingsFields) record(`${CONFIG_PY_PATH}#${field}`, value);
|
|
17122
17233
|
}
|
|
17123
17234
|
let curatedFieldsBlind = false;
|
|
17124
17235
|
if (!orchestrationSchemaMissing) {
|
|
17125
|
-
const curated = extractCuratedModelFields(
|
|
17236
|
+
const curated = extractCuratedModelFields(readFileSync47(orchestrationPath, "utf8"));
|
|
17126
17237
|
if (curated.rawFieldCount > 0 && curated.fields.every((f) => f.defaultValue === null && f.optionValues.length === 0)) {
|
|
17127
17238
|
curatedFieldsBlind = true;
|
|
17128
17239
|
}
|
|
@@ -17170,7 +17281,7 @@ function auditDeclaredModelIds(repoRoot, options = {}) {
|
|
|
17170
17281
|
function discoverPluginDirs(pluginsRoot) {
|
|
17171
17282
|
return listDirs(pluginsRoot).filter((name) => {
|
|
17172
17283
|
try {
|
|
17173
|
-
return statSync17(
|
|
17284
|
+
return statSync17(join71(pluginsRoot, name, "biffo.plugin.json")).isFile();
|
|
17174
17285
|
} catch {
|
|
17175
17286
|
return false;
|
|
17176
17287
|
}
|
|
@@ -17183,8 +17294,8 @@ function auditPluginToolSupply(pluginsRoot) {
|
|
|
17183
17294
|
let terraformBlind = false;
|
|
17184
17295
|
let totalDeclaredTools = 0;
|
|
17185
17296
|
for (const name of pluginNames) {
|
|
17186
|
-
const pluginDir2 =
|
|
17187
|
-
const manifestText =
|
|
17297
|
+
const pluginDir2 = join71(pluginsRoot, name);
|
|
17298
|
+
const manifestText = readFileSync47(join71(pluginDir2, "biffo.plugin.json"), "utf8");
|
|
17188
17299
|
const manifest = extractManifestTools(manifestText);
|
|
17189
17300
|
if (manifest.parseError) {
|
|
17190
17301
|
findings.push({
|
|
@@ -17202,13 +17313,13 @@ function auditPluginToolSupply(pluginsRoot) {
|
|
|
17202
17313
|
totalDeclaredTools += manifest.tools.length;
|
|
17203
17314
|
const pySources = pluginPythonFiles(pluginDir2).map((f) => ({
|
|
17204
17315
|
file: f,
|
|
17205
|
-
text:
|
|
17316
|
+
text: readFileSync47(f, "utf8")
|
|
17206
17317
|
}));
|
|
17207
17318
|
const resolver = buildSymbolResolver(pySources);
|
|
17208
17319
|
const registry = extractToolRegistryEntries(pySources, resolver);
|
|
17209
17320
|
if (registry.rawToolDefinitionCount > 0 && registry.entries.length === 0) registryBlind = true;
|
|
17210
17321
|
const tfFiles = pluginTerraformFiles(pluginDir2);
|
|
17211
|
-
const tfText = tfFiles.map((f) =>
|
|
17322
|
+
const tfText = tfFiles.map((f) => readFileSync47(f, "utf8")).join("\n");
|
|
17212
17323
|
const terraform = extractTerraformEnvKeys(tfText);
|
|
17213
17324
|
if (terraform.rawMarkerCount > 0 && terraform.resolvedBlockCount === 0) terraformBlind = true;
|
|
17214
17325
|
for (const toolName of manifest.tools) {
|
|
@@ -17282,7 +17393,7 @@ function auditPluginToolSupply(pluginsRoot) {
|
|
|
17282
17393
|
requiredEnvVars: envResult.envVars,
|
|
17283
17394
|
missingEnvVars: anyWired ? [] : envResult.envVars,
|
|
17284
17395
|
status: anyWired ? "ok" : "missing-env",
|
|
17285
|
-
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 ${
|
|
17396
|
+
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 ${join71(pluginDir2, "terraform")}, so this deployment can never supply it`
|
|
17286
17397
|
});
|
|
17287
17398
|
}
|
|
17288
17399
|
}
|
|
@@ -17322,8 +17433,8 @@ async function runPluginToolSupplyCheck() {
|
|
|
17322
17433
|
return;
|
|
17323
17434
|
}
|
|
17324
17435
|
let allOk = true;
|
|
17325
|
-
const pluginsRoot =
|
|
17326
|
-
if (!
|
|
17436
|
+
const pluginsRoot = join72(root, "services", "_plugins");
|
|
17437
|
+
if (!existsSync61(pluginsRoot)) {
|
|
17327
17438
|
console.log("\u2713 plugin tool-supply guard: no services/_plugins/ \u2014 nothing to audit");
|
|
17328
17439
|
} else {
|
|
17329
17440
|
const report = auditPluginToolSupply(pluginsRoot);
|
|
@@ -17353,8 +17464,8 @@ async function runPluginToolSupplyCheck() {
|
|
|
17353
17464
|
console.log(`\u2713 plugin tool-supply guard: ${report.summary}`);
|
|
17354
17465
|
}
|
|
17355
17466
|
}
|
|
17356
|
-
const servicesApiRoot =
|
|
17357
|
-
if (!
|
|
17467
|
+
const servicesApiRoot = join72(root, "services", "api");
|
|
17468
|
+
if (!existsSync61(servicesApiRoot)) {
|
|
17358
17469
|
console.log("\u2713 plugin model-id guard: no services/api/ \u2014 nothing to audit");
|
|
17359
17470
|
} else {
|
|
17360
17471
|
const modelReport = auditDeclaredModelIds(root, {
|
|
@@ -17535,10 +17646,10 @@ async function runReleaseSubjectCheck(argv) {
|
|
|
17535
17646
|
}
|
|
17536
17647
|
|
|
17537
17648
|
// src/scripts/check-shared-file-reduction.ts
|
|
17538
|
-
import { readFileSync as
|
|
17649
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
17539
17650
|
|
|
17540
17651
|
// src/lib/shared-file-reduction-guard.ts
|
|
17541
|
-
import { readFileSync as
|
|
17652
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
17542
17653
|
var LEAF_TEST_CALLS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
17543
17654
|
var SUITE_CALLS = /* @__PURE__ */ new Set(["describe", "suite"]);
|
|
17544
17655
|
var TEST_FILE_PATTERN = /\.(test|spec)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/;
|
|
@@ -17665,7 +17776,7 @@ function formatReductionReport(report) {
|
|
|
17665
17776
|
// src/scripts/check-shared-file-reduction.ts
|
|
17666
17777
|
function readStdin() {
|
|
17667
17778
|
try {
|
|
17668
|
-
return
|
|
17779
|
+
return readFileSync49(0, "utf8");
|
|
17669
17780
|
} catch {
|
|
17670
17781
|
return "";
|
|
17671
17782
|
}
|
|
@@ -17682,15 +17793,15 @@ function pairsFromTsv(tsv) {
|
|
|
17682
17793
|
const [target, existingPath, incomingPath] = fields;
|
|
17683
17794
|
pairs.push({
|
|
17684
17795
|
target,
|
|
17685
|
-
existing:
|
|
17686
|
-
incoming:
|
|
17796
|
+
existing: readFileSync49(existingPath, "utf8"),
|
|
17797
|
+
incoming: readFileSync49(incomingPath, "utf8")
|
|
17687
17798
|
});
|
|
17688
17799
|
}
|
|
17689
17800
|
return pairs;
|
|
17690
17801
|
}
|
|
17691
17802
|
function loadAccepted(manifestPath) {
|
|
17692
17803
|
if (!manifestPath) return {};
|
|
17693
|
-
const parsed = JSON.parse(
|
|
17804
|
+
const parsed = JSON.parse(readFileSync49(manifestPath, "utf8"));
|
|
17694
17805
|
return parsed.acceptedReductions ?? {};
|
|
17695
17806
|
}
|
|
17696
17807
|
async function runSharedFileReductionCheck(args) {
|
|
@@ -17698,13 +17809,13 @@ async function runSharedFileReductionCheck(args) {
|
|
|
17698
17809
|
let accepted;
|
|
17699
17810
|
try {
|
|
17700
17811
|
if (args.pairs) {
|
|
17701
|
-
pairs = pairsFromTsv(args.pairs === "-" ? readStdin() :
|
|
17812
|
+
pairs = pairsFromTsv(args.pairs === "-" ? readStdin() : readFileSync49(args.pairs, "utf8"));
|
|
17702
17813
|
} else if (args.target && args.existing && args.incoming) {
|
|
17703
17814
|
pairs = [
|
|
17704
17815
|
{
|
|
17705
17816
|
target: args.target,
|
|
17706
|
-
existing:
|
|
17707
|
-
incoming:
|
|
17817
|
+
existing: readFileSync49(args.existing, "utf8"),
|
|
17818
|
+
incoming: readFileSync49(args.incoming, "utf8")
|
|
17708
17819
|
}
|
|
17709
17820
|
];
|
|
17710
17821
|
} else {
|
|
@@ -17738,12 +17849,12 @@ async function runSharedFileReductionCheck(args) {
|
|
|
17738
17849
|
}
|
|
17739
17850
|
|
|
17740
17851
|
// src/scripts/check-skeleton-drift.ts
|
|
17741
|
-
import { existsSync as
|
|
17742
|
-
import { join as
|
|
17852
|
+
import { existsSync as existsSync62, readdirSync as readdirSync29 } from "fs";
|
|
17853
|
+
import { join as join74 } from "path";
|
|
17743
17854
|
|
|
17744
17855
|
// src/lib/skeleton-drift-guard.ts
|
|
17745
|
-
import { readFileSync as
|
|
17746
|
-
import { join as
|
|
17856
|
+
import { readFileSync as readFileSync50, readdirSync as readdirSync28, statSync as statSync18 } from "fs";
|
|
17857
|
+
import { join as join73 } from "path";
|
|
17747
17858
|
var isWorkflow = (rel) => rel.startsWith(".github/workflows/") && (rel.endsWith(".yml") || rel.endsWith(".yaml"));
|
|
17748
17859
|
var isRootLayout = (rel) => rel.endsWith("src/app/layout.tsx");
|
|
17749
17860
|
var uncommented = (contents) => contents.split("\n").filter((line) => !/^\s*(\/\/|\/\*|\*)/.test(line)).join("\n");
|
|
@@ -17801,13 +17912,13 @@ function walk(dir, base = dir) {
|
|
|
17801
17912
|
const out = [];
|
|
17802
17913
|
let entries;
|
|
17803
17914
|
try {
|
|
17804
|
-
entries =
|
|
17915
|
+
entries = readdirSync28(dir);
|
|
17805
17916
|
} catch {
|
|
17806
17917
|
return out;
|
|
17807
17918
|
}
|
|
17808
17919
|
for (const entry of entries) {
|
|
17809
17920
|
if (entry === ".venv" || entry === "node_modules" || entry === ".git") continue;
|
|
17810
|
-
const abs =
|
|
17921
|
+
const abs = join73(dir, entry);
|
|
17811
17922
|
let isDir;
|
|
17812
17923
|
try {
|
|
17813
17924
|
isDir = statSync18(abs).isDirectory();
|
|
@@ -17829,7 +17940,7 @@ function auditSkeleton(skeletonRoot, name, rules = SKELETON_RULES) {
|
|
|
17829
17940
|
if (!rule.appliesTo(rel)) continue;
|
|
17830
17941
|
let contents;
|
|
17831
17942
|
try {
|
|
17832
|
-
contents =
|
|
17943
|
+
contents = readFileSync50(join73(skeletonRoot, rel), "utf8");
|
|
17833
17944
|
} catch {
|
|
17834
17945
|
continue;
|
|
17835
17946
|
}
|
|
@@ -17858,23 +17969,23 @@ function formatViolations2(violations) {
|
|
|
17858
17969
|
|
|
17859
17970
|
// src/scripts/check-skeleton-drift.ts
|
|
17860
17971
|
function discoverSkeletons(root) {
|
|
17861
|
-
const skeletonsDir =
|
|
17972
|
+
const skeletonsDir = join74(root, "_skeletons");
|
|
17862
17973
|
let entries;
|
|
17863
17974
|
try {
|
|
17864
|
-
entries =
|
|
17975
|
+
entries = readdirSync29(skeletonsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
17865
17976
|
} catch {
|
|
17866
17977
|
return [];
|
|
17867
17978
|
}
|
|
17868
|
-
return entries.filter((name) =>
|
|
17979
|
+
return entries.filter((name) => existsSync62(join74(skeletonsDir, name, ".github", "workflows", "ci.yml"))).sort();
|
|
17869
17980
|
}
|
|
17870
17981
|
async function runSkeletonDriftCheck() {
|
|
17871
17982
|
const root = (await execa("git", ["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
17872
17983
|
const skeletons = discoverSkeletons(root);
|
|
17873
17984
|
let filesConsidered = 0;
|
|
17874
17985
|
for (const name of skeletons) {
|
|
17875
|
-
const skeletonRoot =
|
|
17986
|
+
const skeletonRoot = join74(root, "_skeletons", name);
|
|
17876
17987
|
filesConsidered += findWorkflowFiles(skeletonRoot).length;
|
|
17877
|
-
if (
|
|
17988
|
+
if (existsSync62(join74(skeletonRoot, "apps", "frontend", "src", "app", "layout.tsx"))) {
|
|
17878
17989
|
filesConsidered += 1;
|
|
17879
17990
|
}
|
|
17880
17991
|
}
|
|
@@ -17882,7 +17993,7 @@ async function runSkeletonDriftCheck() {
|
|
|
17882
17993
|
`audited ${skeletons.length} skeleton(s) (${skeletons.join(", ") || "none"}), ${filesConsidered} file(s) considered, under ${root}/_skeletons`
|
|
17883
17994
|
);
|
|
17884
17995
|
if (skeletons.length === 0) {
|
|
17885
|
-
if (!
|
|
17996
|
+
if (!existsSync62(join74(root, "_skeletons"))) {
|
|
17886
17997
|
console.log(
|
|
17887
17998
|
`\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.`
|
|
17888
17999
|
);
|
|
@@ -17894,7 +18005,7 @@ async function runSkeletonDriftCheck() {
|
|
|
17894
18005
|
process.exit(1);
|
|
17895
18006
|
}
|
|
17896
18007
|
const violations = skeletons.flatMap(
|
|
17897
|
-
(name) => auditSkeleton(
|
|
18008
|
+
(name) => auditSkeleton(join74(root, "_skeletons", name), name)
|
|
17898
18009
|
);
|
|
17899
18010
|
if (violations.length > 0) {
|
|
17900
18011
|
console.error("\u2717 Skeleton-drift guard: drift found between this repo and its scaffolding\n");
|
|
@@ -18095,8 +18206,8 @@ function rawArgsAfter(subcommand) {
|
|
|
18095
18206
|
}
|
|
18096
18207
|
|
|
18097
18208
|
// src/commands/doctor.ts
|
|
18098
|
-
import { existsSync as
|
|
18099
|
-
import { join as
|
|
18209
|
+
import { existsSync as existsSync63, readFileSync as readFileSync51 } from "fs";
|
|
18210
|
+
import { join as join76, resolve as resolve24 } from "path";
|
|
18100
18211
|
import chalk21 from "chalk";
|
|
18101
18212
|
import { Command as Command27 } from "commander";
|
|
18102
18213
|
|
|
@@ -18436,12 +18547,12 @@ async function reapAllBareBranches(cwd, branches, worktrees, currentBranch, deps
|
|
|
18436
18547
|
}
|
|
18437
18548
|
|
|
18438
18549
|
// src/lib/scratch-clone-scan.ts
|
|
18439
|
-
import { readdirSync as
|
|
18440
|
-
import { join as
|
|
18550
|
+
import { readdirSync as readdirSync30, statSync as statSync19 } from "fs";
|
|
18551
|
+
import { join as join75 } from "path";
|
|
18441
18552
|
var INTEGRATION_BRANCH = "dev";
|
|
18442
18553
|
function isPlainCloneDir(path) {
|
|
18443
18554
|
try {
|
|
18444
|
-
return statSync19(
|
|
18555
|
+
return statSync19(join75(path, ".git")).isDirectory();
|
|
18445
18556
|
} catch {
|
|
18446
18557
|
return false;
|
|
18447
18558
|
}
|
|
@@ -18453,10 +18564,10 @@ function repoNameFromRemoteUrl(url) {
|
|
|
18453
18564
|
return match?.[1] && match[1] !== "" ? match[1] : null;
|
|
18454
18565
|
}
|
|
18455
18566
|
async function findScratchCloneCandidates(estateRoot, deps) {
|
|
18456
|
-
const names =
|
|
18567
|
+
const names = readdirSync30(estateRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
18457
18568
|
const candidates = [];
|
|
18458
18569
|
for (const name of names) {
|
|
18459
|
-
const path =
|
|
18570
|
+
const path = join75(estateRoot, name);
|
|
18460
18571
|
if (!isPlainCloneDir(path)) continue;
|
|
18461
18572
|
let branch;
|
|
18462
18573
|
try {
|
|
@@ -18636,10 +18747,10 @@ function printScratchCloneReports(estateRoot, reports) {
|
|
|
18636
18747
|
);
|
|
18637
18748
|
}
|
|
18638
18749
|
function readLocalCoreVersion(cwd) {
|
|
18639
|
-
const path =
|
|
18640
|
-
if (!
|
|
18750
|
+
const path = join76(cwd, INSTANCE_CORE_FILE);
|
|
18751
|
+
if (!existsSync63(path)) return null;
|
|
18641
18752
|
try {
|
|
18642
|
-
return extractVersionField(
|
|
18753
|
+
return extractVersionField(readFileSync51(path, "utf8"));
|
|
18643
18754
|
} catch {
|
|
18644
18755
|
return null;
|
|
18645
18756
|
}
|
|
@@ -18659,10 +18770,10 @@ function extractVersionField(contents) {
|
|
|
18659
18770
|
return match?.[1] ?? null;
|
|
18660
18771
|
}
|
|
18661
18772
|
function readFossil(cwd) {
|
|
18662
|
-
const path =
|
|
18663
|
-
if (!
|
|
18773
|
+
const path = join76(cwd, CORE_VERSION_FILE);
|
|
18774
|
+
if (!existsSync63(path)) return null;
|
|
18664
18775
|
try {
|
|
18665
|
-
const value =
|
|
18776
|
+
const value = readFileSync51(path, "utf8").trim();
|
|
18666
18777
|
return value === "" ? null : value;
|
|
18667
18778
|
} catch {
|
|
18668
18779
|
return null;
|