@bitfab/sdk 0.69.0 → 0.71.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/cloudReplay.py +49 -27
- package/dist/{http-C9icRaA3.cjs → http-D2Rgpq7_.cjs} +4 -3
- package/dist/http-D2Rgpq7_.cjs.map +1 -0
- package/dist/{http-CzKW7TgN.js → http-Dh6NfOpj.js} +4 -3
- package/dist/http-Dh6NfOpj.js.map +1 -0
- package/dist/{index-D7y_bwZC.d.cts → index-CEhjDPxK.d.cts} +36 -17
- package/dist/{index-D7y_bwZC.d.ts → index-CEhjDPxK.d.ts} +36 -17
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/{registryCommand-CWxt6kPp.js → registryCommand-jPTSRgL9.js} +39 -16
- package/dist/registryCommand-jPTSRgL9.js.map +1 -0
- package/dist/replayCli.js +2 -2
- package/dist/replayCli.js.map +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-4VpSvoAt.cjs → src-C2OX1CHX.cjs} +70 -44
- package/dist/src-C2OX1CHX.cjs.map +1 -0
- package/dist/{src-Cn--d1sW.js → src-gqUT-PNr.js} +70 -44
- package/dist/src-gqUT-PNr.js.map +1 -0
- package/package.json +1 -1
- package/dist/http-C9icRaA3.cjs.map +0 -1
- package/dist/http-CzKW7TgN.js.map +0 -1
- package/dist/registryCommand-CWxt6kPp.js.map +0 -1
- package/dist/src-4VpSvoAt.cjs.map +0 -1
- package/dist/src-Cn--d1sW.js.map +0 -1
package/dist/replayCli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-
|
|
2
|
+
import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-jPTSRgL9.js";
|
|
3
3
|
//#region src/cloudReplayCli.ts
|
|
4
4
|
const CLOUD_REPLAY_HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.";
|
|
5
5
|
function isCloudReplayCommand(argv) {
|
|
@@ -38,7 +38,7 @@ async function runCloudReplayCommand(argv, helper) {
|
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/replayCli.ts
|
|
40
40
|
const CHECK_ARGUMENTS_FLAG = "--check-arguments";
|
|
41
|
-
const USAGE = `Usage: bitfab-replay --registry <path> <pipeline> [options]\n bitfab-replay --registry <path> <pipeline> --resume <experimentId>\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\nRun bitfab-replay --registry <path> --help to list replay options.\n${CLOUD_REPLAY_HINT}`;
|
|
41
|
+
const USAGE = `Usage: bitfab-replay --registry <path> <pipeline> --code-change <type> [options]\n bitfab-replay --registry <path> <pipeline> --code-change <type> --resume <experimentId>\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\nRun bitfab-replay --registry <path> --help to list replay options.\n${CLOUD_REPLAY_HINT}`;
|
|
42
42
|
async function runReplayCommand(argv, io = {}, importer = importRegistry) {
|
|
43
43
|
const { registryPath, commandArgs } = await parseRegistryCommandArgs(argv, USAGE);
|
|
44
44
|
const registry = resolveRegistry(await importer(registryPath), registryPath);
|
package/dist/replayCli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayCli.js","names":[],"sources":["../src/cloudReplayCli.ts","../src/replayCli.ts"],"sourcesContent":["export const CLOUD_REPLAY_HINT =\n \"Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.\"\n\nexport function isCloudReplayCommand(argv: readonly string[]): boolean {\n return argv.some((arg) => arg === \"--cloud\" || arg.startsWith(\"--cloud-\"))\n}\n\nexport async function runCloudReplayCommand(\n argv: readonly string[],\n helper?: string,\n): Promise<number> {\n const [{ spawn }, { fileURLToPath }] = await Promise.all([\n import(\"node:child_process\"),\n import(\"node:url\"),\n ])\n const script =\n helper ?? fileURLToPath(new URL(\"../cloudReplay.py\", import.meta.url))\n const replayCommand = [\n process.execPath,\n ...process.execArgv.filter((flag) => !/^--(inspect|debug)/.test(flag)),\n fileURLToPath(new URL(\"./replayCli.js\", import.meta.url)),\n ]\n const keepWaiting = () => {}\n process.on(\"SIGINT\", keepWaiting)\n try {\n return await new Promise<number>((resolve) => {\n const child = spawn(\"python3\", [script, ...argv], {\n stdio: \"inherit\",\n env: {\n ...process.env,\n BITFAB_REPLAY_COMMAND: JSON.stringify(replayCommand),\n BITFAB_SDK_LANGUAGE: \"typescript\",\n },\n })\n child.on(\"error\", () => {\n process.stderr.write(\n \"Cloud replay needs Python 3.10+ on PATH as python3\\n\",\n )\n resolve(1)\n })\n child.on(\"close\", (code, signal) =>\n resolve(code ?? (signal === \"SIGINT\" ? 130 : 1)),\n )\n })\n } finally {\n process.off(\"SIGINT\", keepWaiting)\n }\n}\n","#!/usr/bin/env node\n\nimport {\n CLOUD_REPLAY_HINT,\n isCloudReplayCommand,\n runCloudReplayCommand,\n} from \"./cloudReplayCli.js\"\nimport {\n importRegistry,\n parseRegistryCommandArgs,\n type RegistryImporter,\n resolveRegistry,\n runIfEntrypoint,\n runRegistryMain,\n} from \"./registryCommand.js\"\nimport type { ReplayResult } from \"./replay.js\"\nimport {\n checkReplayCliArgs,\n type ReplayCliIo,\n type ReseedRegistryResult,\n runReplayCli,\n runSeedCli,\n type SeedResult,\n} from \"./replayRegistry.js\"\n\nconst CHECK_ARGUMENTS_FLAG = \"--check-arguments\"\n\nconst USAGE = `Usage: bitfab-replay --registry <path> <pipeline> [options]\\n bitfab-replay --registry <path> <pipeline> --resume <experimentId>\\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\\nRun bitfab-replay --registry <path> --help to list replay options.\\n${CLOUD_REPLAY_HINT}`\n\nexport async function runReplayCommand(\n argv: readonly string[],\n io: ReplayCliIo = {},\n importer: RegistryImporter = importRegistry,\n): Promise<ReplayResult<unknown> | SeedResult | ReseedRegistryResult | null> {\n const { registryPath, commandArgs } = await parseRegistryCommandArgs(\n argv,\n USAGE,\n )\n const registry = resolveRegistry(await importer(registryPath), registryPath)\n if (commandArgs.includes(\"--seed\")) {\n return runSeedCli(registry, commandArgs, io)\n }\n return runReplayCli(registry, commandArgs, io, registryPath)\n}\n\nexport async function runReplayMain(\n argv: readonly string[],\n io: ReplayCliIo = {},\n): Promise<number> {\n if (argv[0] === CHECK_ARGUMENTS_FLAG) {\n return runRegistryMain(async () => {\n const { commandArgs } = await parseRegistryCommandArgs(\n argv.slice(1),\n USAGE,\n )\n checkReplayCliArgs(commandArgs)\n }, io)\n }\n if (isCloudReplayCommand(argv)) {\n return runCloudReplayCommand(argv)\n }\n return runRegistryMain(() => runReplayCommand(argv, io), io)\n}\n\nrunIfEntrypoint(import.meta.url, () => runReplayMain(process.argv.slice(2)))\n"],"mappings":";;;AAAA,MAAa,oBACX;AAEF,SAAgB,qBAAqB,MAAkC;CACrE,OAAO,KAAK,MAAM,QAAQ,QAAQ,aAAa,IAAI,WAAW,UAAU,CAAC;AAC3E;AAEA,eAAsB,sBACpB,MACA,QACiB;CACjB,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,MAAM,QAAQ,IAAI,CACvD,OAAO,kBACP,OAAO,MACT,CAAC;CACD,MAAM,SACJ,UAAU,cAAc,IAAI,IAAI,qBAAqB,YAAY,GAAG,CAAC;CACvE,MAAM,gBAAgB;EACpB,QAAQ;EACR,GAAG,QAAQ,SAAS,QAAQ,SAAS,CAAC,qBAAqB,KAAK,IAAI,CAAC;EACrE,cAAc,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC;CAC1D;CACA,MAAM,oBAAoB,CAAC;CAC3B,QAAQ,GAAG,UAAU,WAAW;CAChC,IAAI;EACF,OAAO,MAAM,IAAI,SAAiB,YAAY;GAC5C,MAAM,QAAQ,MAAM,WAAW,CAAC,QAAQ,GAAG,IAAI,GAAG;IAChD,OAAO;IACP,KAAK;KACH,GAAG,QAAQ;KACX,uBAAuB,KAAK,UAAU,aAAa;KACnD,qBAAqB;IACvB;GACF,CAAC;GACD,MAAM,GAAG,eAAe;IACtB,QAAQ,OAAO,MACb,sDACF;IACA,QAAQ,CAAC;GACX,CAAC;GACD,MAAM,GAAG,UAAU,MAAM,WACvB,QAAQ,SAAS,WAAW,WAAW,MAAM,EAAE,CACjD;EACF,CAAC;CACH,UAAU;EACR,QAAQ,IAAI,UAAU,WAAW;CACnC;AACF;;;ACtBA,MAAM,uBAAuB;AAE7B,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"replayCli.js","names":[],"sources":["../src/cloudReplayCli.ts","../src/replayCli.ts"],"sourcesContent":["export const CLOUD_REPLAY_HINT =\n \"Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.\"\n\nexport function isCloudReplayCommand(argv: readonly string[]): boolean {\n return argv.some((arg) => arg === \"--cloud\" || arg.startsWith(\"--cloud-\"))\n}\n\nexport async function runCloudReplayCommand(\n argv: readonly string[],\n helper?: string,\n): Promise<number> {\n const [{ spawn }, { fileURLToPath }] = await Promise.all([\n import(\"node:child_process\"),\n import(\"node:url\"),\n ])\n const script =\n helper ?? fileURLToPath(new URL(\"../cloudReplay.py\", import.meta.url))\n const replayCommand = [\n process.execPath,\n ...process.execArgv.filter((flag) => !/^--(inspect|debug)/.test(flag)),\n fileURLToPath(new URL(\"./replayCli.js\", import.meta.url)),\n ]\n const keepWaiting = () => {}\n process.on(\"SIGINT\", keepWaiting)\n try {\n return await new Promise<number>((resolve) => {\n const child = spawn(\"python3\", [script, ...argv], {\n stdio: \"inherit\",\n env: {\n ...process.env,\n BITFAB_REPLAY_COMMAND: JSON.stringify(replayCommand),\n BITFAB_SDK_LANGUAGE: \"typescript\",\n },\n })\n child.on(\"error\", () => {\n process.stderr.write(\n \"Cloud replay needs Python 3.10+ on PATH as python3\\n\",\n )\n resolve(1)\n })\n child.on(\"close\", (code, signal) =>\n resolve(code ?? (signal === \"SIGINT\" ? 130 : 1)),\n )\n })\n } finally {\n process.off(\"SIGINT\", keepWaiting)\n }\n}\n","#!/usr/bin/env node\n\nimport {\n CLOUD_REPLAY_HINT,\n isCloudReplayCommand,\n runCloudReplayCommand,\n} from \"./cloudReplayCli.js\"\nimport {\n importRegistry,\n parseRegistryCommandArgs,\n type RegistryImporter,\n resolveRegistry,\n runIfEntrypoint,\n runRegistryMain,\n} from \"./registryCommand.js\"\nimport type { ReplayResult } from \"./replay.js\"\nimport {\n checkReplayCliArgs,\n type ReplayCliIo,\n type ReseedRegistryResult,\n runReplayCli,\n runSeedCli,\n type SeedResult,\n} from \"./replayRegistry.js\"\n\nconst CHECK_ARGUMENTS_FLAG = \"--check-arguments\"\n\nconst USAGE = `Usage: bitfab-replay --registry <path> <pipeline> --code-change <type> [options]\\n bitfab-replay --registry <path> <pipeline> --code-change <type> --resume <experimentId>\\n bitfab-replay --registry <path> <pipeline> --seed <cases.jsonl> [--run]\\nRun bitfab-replay --registry <path> --help to list replay options.\\n${CLOUD_REPLAY_HINT}`\n\nexport async function runReplayCommand(\n argv: readonly string[],\n io: ReplayCliIo = {},\n importer: RegistryImporter = importRegistry,\n): Promise<ReplayResult<unknown> | SeedResult | ReseedRegistryResult | null> {\n const { registryPath, commandArgs } = await parseRegistryCommandArgs(\n argv,\n USAGE,\n )\n const registry = resolveRegistry(await importer(registryPath), registryPath)\n if (commandArgs.includes(\"--seed\")) {\n return runSeedCli(registry, commandArgs, io)\n }\n return runReplayCli(registry, commandArgs, io, registryPath)\n}\n\nexport async function runReplayMain(\n argv: readonly string[],\n io: ReplayCliIo = {},\n): Promise<number> {\n if (argv[0] === CHECK_ARGUMENTS_FLAG) {\n return runRegistryMain(async () => {\n const { commandArgs } = await parseRegistryCommandArgs(\n argv.slice(1),\n USAGE,\n )\n checkReplayCliArgs(commandArgs)\n }, io)\n }\n if (isCloudReplayCommand(argv)) {\n return runCloudReplayCommand(argv)\n }\n return runRegistryMain(() => runReplayCommand(argv, io), io)\n}\n\nrunIfEntrypoint(import.meta.url, () => runReplayMain(process.argv.slice(2)))\n"],"mappings":";;;AAAA,MAAa,oBACX;AAEF,SAAgB,qBAAqB,MAAkC;CACrE,OAAO,KAAK,MAAM,QAAQ,QAAQ,aAAa,IAAI,WAAW,UAAU,CAAC;AAC3E;AAEA,eAAsB,sBACpB,MACA,QACiB;CACjB,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,MAAM,QAAQ,IAAI,CACvD,OAAO,kBACP,OAAO,MACT,CAAC;CACD,MAAM,SACJ,UAAU,cAAc,IAAI,IAAI,qBAAqB,YAAY,GAAG,CAAC;CACvE,MAAM,gBAAgB;EACpB,QAAQ;EACR,GAAG,QAAQ,SAAS,QAAQ,SAAS,CAAC,qBAAqB,KAAK,IAAI,CAAC;EACrE,cAAc,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC;CAC1D;CACA,MAAM,oBAAoB,CAAC;CAC3B,QAAQ,GAAG,UAAU,WAAW;CAChC,IAAI;EACF,OAAO,MAAM,IAAI,SAAiB,YAAY;GAC5C,MAAM,QAAQ,MAAM,WAAW,CAAC,QAAQ,GAAG,IAAI,GAAG;IAChD,OAAO;IACP,KAAK;KACH,GAAG,QAAQ;KACX,uBAAuB,KAAK,UAAU,aAAa;KACnD,qBAAqB;IACvB;GACF,CAAC;GACD,MAAM,GAAG,eAAe;IACtB,QAAQ,OAAO,MACb,sDACF;IACA,QAAQ,CAAC;GACX,CAAC;GACD,MAAM,GAAG,UAAU,MAAM,WACvB,QAAQ,SAAS,WAAW,WAAW,MAAM,EAAE,CACjD;EACF,CAAC;CACH,UAAU;EACR,QAAQ,IAAI,UAAU,WAAW;CACnC;AACF;;;ACtBA,MAAM,uBAAuB;AAE7B,MAAM,QAAQ,yUAAyU;AAEvV,eAAsB,iBACpB,MACA,KAAkB,CAAC,GACnB,WAA6B,gBAC8C;CAC3E,MAAM,EAAE,cAAc,gBAAgB,MAAM,yBAC1C,MACA,KACF;CACA,MAAM,WAAW,gBAAgB,MAAM,SAAS,YAAY,GAAG,YAAY;CAC3E,IAAI,YAAY,SAAS,QAAQ,GAC/B,OAAO,WAAW,UAAU,aAAa,EAAE;CAE7C,OAAO,aAAa,UAAU,aAAa,IAAI,YAAY;AAC7D;AAEA,eAAsB,cACpB,MACA,KAAkB,CAAC,GACF;CACjB,IAAI,KAAK,OAAO,sBACd,OAAO,gBAAgB,YAAY;EACjC,MAAM,EAAE,gBAAgB,MAAM,yBAC5B,KAAK,MAAM,CAAC,GACZ,KACF;EACA,mBAAmB,WAAW;CAChC,GAAG,EAAE;CAEP,IAAI,qBAAqB,IAAI,GAC3B,OAAO,sBAAsB,IAAI;CAEnC,OAAO,sBAAsB,iBAAiB,MAAM,EAAE,GAAG,EAAE;AAC7D;AAEA,gBAAgB,YAAY,WAAW,cAAc,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
|
package/dist/seedCli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-
|
|
2
|
+
import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-jPTSRgL9.js";
|
|
3
3
|
//#region src/seedCli.ts
|
|
4
4
|
const USAGE = "Usage: bitfab-seed --registry <path> <pipeline> --from-trace <id>[,<id>...]\n bitfab-seed --registry <path> <pipeline> --cases <cases.jsonl> [--run]\nRun bitfab-seed --registry <path> <pipeline> --help for details.";
|
|
5
5
|
async function runSeedCommand(argv, io = {}, importer = importRegistry) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-D2Rgpq7_.cjs");
|
|
3
3
|
const require_autoTrace = require("./autoTrace-DPWV1Xzr.cjs");
|
|
4
4
|
const require_optionalPeer = require("./optionalPeer-CUH756lt.cjs");
|
|
5
5
|
let superjson = require("superjson");
|
|
@@ -3006,17 +3006,57 @@ var BitfabPiIntegration = class {
|
|
|
3006
3006
|
};
|
|
3007
3007
|
//#endregion
|
|
3008
3008
|
//#region src/codeChange.ts
|
|
3009
|
+
const CODE_CHANGE_TYPES = [
|
|
3010
|
+
"working-tree",
|
|
3011
|
+
"last-branch",
|
|
3012
|
+
"default-branch",
|
|
3013
|
+
"skip",
|
|
3014
|
+
"manual"
|
|
3015
|
+
];
|
|
3016
|
+
const CODE_CHANGE_CHOICES = "\"working-tree\" (uncommitted changes vs HEAD), \"last-branch\" (the diff against the branch this one was cut from), \"default-branch\" (the diff against the default branch), \"skip\" (no code change), or \"manual\" (pass the files yourself)";
|
|
3017
|
+
function isCodeChangeType(value) {
|
|
3018
|
+
return CODE_CHANGE_TYPES.includes(value);
|
|
3019
|
+
}
|
|
3020
|
+
function validateCodeChange(request) {
|
|
3021
|
+
const { codeChange, codeChangeDescription, codeChangeFiles } = request;
|
|
3022
|
+
if (codeChange === void 0 || codeChange === null) throw new require_http.BitfabError(`replay needs a codeChange naming the code this run tests: ${CODE_CHANGE_CHOICES}.`);
|
|
3023
|
+
if (!isCodeChangeType(codeChange)) throw new require_http.BitfabError(`Unknown codeChange ${JSON.stringify(codeChange)}. Pass ${CODE_CHANGE_CHOICES}.`);
|
|
3024
|
+
const hasFiles = codeChangeFiles !== void 0 && codeChangeFiles !== null;
|
|
3025
|
+
if (codeChange === "manual" && !hasFiles) throw new require_http.BitfabError("codeChange \"manual\" needs codeChangeFiles: the path and before/after contents of each edited file.");
|
|
3026
|
+
if (codeChange !== "manual" && hasFiles) throw new require_http.BitfabError(`codeChangeFiles only applies with codeChange "manual" (got "${codeChange}").`);
|
|
3027
|
+
if (codeChange === "skip" && codeChangeDescription !== void 0 && codeChangeDescription !== null) throw new require_http.BitfabError("codeChange \"skip\" attaches no code change, so it cannot take a codeChangeDescription.");
|
|
3028
|
+
return codeChange;
|
|
3029
|
+
}
|
|
3030
|
+
async function resolveCodeChange(request, label) {
|
|
3031
|
+
const codeChange = validateCodeChange(request);
|
|
3032
|
+
const description = request.codeChangeDescription ?? void 0;
|
|
3033
|
+
if (codeChange === "skip") return {};
|
|
3034
|
+
if (codeChange === "manual") return {
|
|
3035
|
+
description,
|
|
3036
|
+
files: request.codeChangeFiles ?? []
|
|
3037
|
+
};
|
|
3038
|
+
const captured = await captureCodeChange(codeChange, label);
|
|
3039
|
+
if (captured?.files === void 0 || captured.files.length === 0) {
|
|
3040
|
+
try {
|
|
3041
|
+
console.warn(`Bitfab: codeChange "${codeChange}" found no changed files, so this replay has no code change attached.`);
|
|
3042
|
+
} catch {}
|
|
3043
|
+
return { description };
|
|
3044
|
+
}
|
|
3045
|
+
return {
|
|
3046
|
+
description: description ?? captured.description,
|
|
3047
|
+
files: captured.files
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3009
3050
|
const MAX_FILES = 60;
|
|
3010
3051
|
const MAX_FILE_BYTES = 5e5;
|
|
3011
3052
|
const MAX_TOTAL_BYTES = 2e6;
|
|
3012
3053
|
const MAX_BRANCH_WALK = 1e3;
|
|
3013
3054
|
const NUL = String.fromCharCode(0);
|
|
3014
|
-
async function
|
|
3055
|
+
async function captureCodeChange(type, label) {
|
|
3015
3056
|
if (typeof process === "undefined") return null;
|
|
3016
|
-
if (process.env?.BITFAB_DISABLE_CODE_CHANGE_CAPTURE) return null;
|
|
3017
3057
|
const fromEnv = await readCodeChangeFile();
|
|
3018
3058
|
if (fromEnv) return fromEnv;
|
|
3019
|
-
return captureCodeChangeFromGit(process.cwd?.() ?? ".", label);
|
|
3059
|
+
return captureCodeChangeFromGit(process.cwd?.() ?? ".", type, label);
|
|
3020
3060
|
}
|
|
3021
3061
|
async function readCodeChangeFile() {
|
|
3022
3062
|
const path = process.env?.BITFAB_CODE_CHANGE_PATH;
|
|
@@ -3035,7 +3075,7 @@ async function readCodeChangeFile() {
|
|
|
3035
3075
|
return null;
|
|
3036
3076
|
}
|
|
3037
3077
|
}
|
|
3038
|
-
async function captureCodeChangeFromGit(cwd, label) {
|
|
3078
|
+
async function captureCodeChangeFromGit(cwd, type, label) {
|
|
3039
3079
|
let readFile;
|
|
3040
3080
|
try {
|
|
3041
3081
|
({readFile} = await import("fs/promises"));
|
|
@@ -3051,16 +3091,9 @@ async function captureCodeChangeFromGit(cwd, label) {
|
|
|
3051
3091
|
try {
|
|
3052
3092
|
const root = (await git(cwd, ["rev-parse", "--show-toplevel"]))?.trim();
|
|
3053
3093
|
if (!root) return null;
|
|
3054
|
-
|
|
3094
|
+
const resolved = await resolveBase(git, root, type);
|
|
3055
3095
|
if (!resolved) return null;
|
|
3056
|
-
|
|
3057
|
-
if (entries.length === 0 && resolved.base === "HEAD") {
|
|
3058
|
-
const branchPoint = await resolveBranchPoint(git, root);
|
|
3059
|
-
if (branchPoint) {
|
|
3060
|
-
resolved = branchPoint;
|
|
3061
|
-
entries = await listChanges(git, root, branchPoint.base);
|
|
3062
|
-
}
|
|
3063
|
-
}
|
|
3096
|
+
const entries = await listChanges(git, root, resolved.base);
|
|
3064
3097
|
if (entries.length === 0) return null;
|
|
3065
3098
|
const { base, against } = resolved;
|
|
3066
3099
|
const blobBytes = async (ref, path) => {
|
|
@@ -3239,23 +3272,22 @@ async function resolveBranchPoint(git, root) {
|
|
|
3239
3272
|
against: `vs ${defaultBranch}`
|
|
3240
3273
|
} : null;
|
|
3241
3274
|
}
|
|
3242
|
-
async function
|
|
3243
|
-
const
|
|
3244
|
-
if (
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
}
|
|
3275
|
+
async function resolveDefaultBranchPoint(git, root) {
|
|
3276
|
+
const defaultBranch = await resolveDefaultBranch(git, root);
|
|
3277
|
+
if (!defaultBranch) return null;
|
|
3278
|
+
const base = (await git(root, [
|
|
3279
|
+
"merge-base",
|
|
3280
|
+
"HEAD",
|
|
3281
|
+
defaultBranch
|
|
3282
|
+
]))?.trim();
|
|
3283
|
+
return base ? {
|
|
3284
|
+
base,
|
|
3285
|
+
against: `vs ${defaultBranch}`
|
|
3286
|
+
} : null;
|
|
3287
|
+
}
|
|
3288
|
+
async function resolveBase(git, root, type) {
|
|
3289
|
+
if (type === "last-branch") return resolveBranchPoint(git, root);
|
|
3290
|
+
if (type === "default-branch") return resolveDefaultBranchPoint(git, root);
|
|
3259
3291
|
return await refExists(git, root, "HEAD") ? {
|
|
3260
3292
|
base: "HEAD",
|
|
3261
3293
|
against: "uncommitted (vs HEAD)"
|
|
@@ -3777,6 +3809,7 @@ const REPLAY_OPTION_NAMES = [
|
|
|
3777
3809
|
"notes",
|
|
3778
3810
|
"metadata",
|
|
3779
3811
|
"maxConcurrency",
|
|
3812
|
+
"codeChange",
|
|
3780
3813
|
"codeChangeDescription",
|
|
3781
3814
|
"codeChangeFiles",
|
|
3782
3815
|
"mock",
|
|
@@ -4144,6 +4177,7 @@ function warnJudgeAssertionsDeprecated(write = console.warn) {
|
|
|
4144
4177
|
require_autoTrace.writeOnce("judgeAssertions-deprecated", JUDGE_ASSERTIONS_DEPRECATION_WARNING, write);
|
|
4145
4178
|
}
|
|
4146
4179
|
async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, registeredOverrides = []) {
|
|
4180
|
+
const codeChangeType = validateCodeChange(options ?? {});
|
|
4147
4181
|
if (options?.judgeAssertions !== void 0) warnJudgeAssertionsDeprecated();
|
|
4148
4182
|
if (options?.resume !== void 0) validateResume(options.resume, options);
|
|
4149
4183
|
else if (options?.force === true) throw new require_http.BitfabError("force only applies when resuming an experiment. Pass it together with resume.");
|
|
@@ -4164,19 +4198,11 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4164
4198
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
4165
4199
|
if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) throw new require_http.BitfabError(`maxConcurrency must be a positive integer (got ${maxConcurrency}).`);
|
|
4166
4200
|
await require_http.replayContextReady;
|
|
4167
|
-
|
|
4168
|
-
let codeChangeFiles = options?.codeChangeFiles;
|
|
4169
|
-
if (codeChangeFiles === void 0) {
|
|
4170
|
-
const captured = await resolveAutoCodeChange(options?.name);
|
|
4171
|
-
if (captured) {
|
|
4172
|
-
codeChangeFiles = captured.files;
|
|
4173
|
-
if (codeChangeDescription === void 0) codeChangeDescription = captured.description;
|
|
4174
|
-
}
|
|
4175
|
-
}
|
|
4201
|
+
const { description: codeChangeDescription, files: codeChangeFiles } = await resolveCodeChange(options, options.name);
|
|
4176
4202
|
const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
|
|
4177
4203
|
let session;
|
|
4178
4204
|
if (options?.resume === void 0) {
|
|
4179
|
-
const started = await httpClient.startReplay(traceFunctionKey, options?.traceIds ? void 0 : options?.limit ?? 5, options?.traceIds, options?.name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, options?.experimentGroupId, datasetIds, options?.graderIds, resolveDbBranchSettings(options?.dbBranch), requestedAttempts, options?.adaptInputs !== void 0, options?.onlyWithAssertions, options?.skipAssertionJudging === true || options?.judgeAssertions === false, options?.experimentalSelectiveReplay, options?.notes, options?.metadata, options?.dryRun === true, options?.experimentGroupName, safeReplayInvocation(() => buildReplayInvocation(Object.entries(cliFlags(options) ?? explicitReplayOptions(options)))));
|
|
4205
|
+
const started = await httpClient.startReplay(traceFunctionKey, options?.traceIds ? void 0 : options?.limit ?? 5, options?.traceIds, options?.name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, options?.experimentGroupId, datasetIds, options?.graderIds, resolveDbBranchSettings(options?.dbBranch), requestedAttempts, options?.adaptInputs !== void 0, options?.onlyWithAssertions, options?.skipAssertionJudging === true || options?.judgeAssertions === false, options?.experimentalSelectiveReplay, options?.notes, options?.metadata, options?.dryRun === true, options?.experimentGroupName, safeReplayInvocation(() => buildReplayInvocation(Object.entries(cliFlags(options) ?? explicitReplayOptions(options)))), codeChangeType);
|
|
4180
4206
|
if (started.items.length === 0) try {
|
|
4181
4207
|
console.warn(`Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`);
|
|
4182
4208
|
} catch {}
|
|
@@ -7012,7 +7038,7 @@ var Bitfab = class {
|
|
|
7012
7038
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
7013
7039
|
} finally {
|
|
7014
7040
|
try {
|
|
7015
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
7041
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-D2Rgpq7_.cjs")).then((n) => n.http_exports);
|
|
7016
7042
|
await flushTraces(3e4);
|
|
7017
7043
|
} finally {
|
|
7018
7044
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -7218,7 +7244,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
7218
7244
|
metadata: seedCase.metadata,
|
|
7219
7245
|
sessionId: seedCase.sessionId
|
|
7220
7246
|
}));
|
|
7221
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
7247
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-D2Rgpq7_.cjs")).then((n) => n.http_exports);
|
|
7222
7248
|
await flushTraces(3e4);
|
|
7223
7249
|
return {
|
|
7224
7250
|
pipeline,
|
|
@@ -7468,4 +7494,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
|
|
|
7468
7494
|
}
|
|
7469
7495
|
});
|
|
7470
7496
|
|
|
7471
|
-
//# sourceMappingURL=src-
|
|
7497
|
+
//# sourceMappingURL=src-C2OX1CHX.cjs.map
|