@bitfab/sdk 0.65.8 → 0.65.10

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.
@@ -1,5 +1,5 @@
1
1
  const require_bamlPeer = require("./bamlPeer-BUoZgNxZ.cjs");
2
- const require_http = require("./http-Cy8I9KDT.cjs");
2
+ const require_http = require("./http-CbiIR-Z6.cjs");
3
3
  const require_autoTrace = require("./autoTrace-CQw0qMBt.cjs");
4
4
  let superjson = require("superjson");
5
5
  superjson = require_bamlPeer.__toESM(superjson, 1);
@@ -2060,6 +2060,7 @@ var OrganizationMembersClient = class {
2060
2060
  const MAX_FILES = 60;
2061
2061
  const MAX_FILE_BYTES = 5e5;
2062
2062
  const MAX_TOTAL_BYTES = 2e6;
2063
+ const MAX_BRANCH_WALK = 1e3;
2063
2064
  const NUL = String.fromCharCode(0);
2064
2065
  async function resolveAutoCodeChange(label) {
2065
2066
  if (typeof process === "undefined") return null;
@@ -2101,8 +2102,17 @@ async function captureCodeChangeFromGit(cwd, label) {
2101
2102
  try {
2102
2103
  const root = (await git(cwd, ["rev-parse", "--show-toplevel"]))?.trim();
2103
2104
  if (!root) return null;
2104
- const resolved = await resolveBase(git, root);
2105
+ let resolved = await resolveBase(git, root);
2105
2106
  if (!resolved) return null;
2107
+ let entries = await listChanges(git, root, resolved.base);
2108
+ if (entries.length === 0 && resolved.base === "HEAD") {
2109
+ const branchPoint = await resolveBranchPoint(git, root);
2110
+ if (branchPoint) {
2111
+ resolved = branchPoint;
2112
+ entries = await listChanges(git, root, branchPoint.base);
2113
+ }
2114
+ }
2115
+ if (entries.length === 0) return null;
2106
2116
  const { base, against } = resolved;
2107
2117
  const blobBytes = async (ref, path) => {
2108
2118
  const out = await git(root, [
@@ -2122,29 +2132,6 @@ async function captureCodeChangeFromGit(cwd, label) {
2122
2132
  return 0;
2123
2133
  }
2124
2134
  };
2125
- const tracked = await git(root, [
2126
- "diff",
2127
- "--name-status",
2128
- "--find-renames",
2129
- "-z",
2130
- base,
2131
- "--",
2132
- ":!.bitfab"
2133
- ]);
2134
- const untracked = await git(root, [
2135
- "ls-files",
2136
- "--others",
2137
- "--exclude-standard",
2138
- "-z",
2139
- "--",
2140
- ":!.bitfab"
2141
- ]);
2142
- const entries = [...parseNameStatusZ(tracked ?? ""), ...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({
2143
- status: "A",
2144
- beforePath: path,
2145
- path
2146
- }))];
2147
- if (entries.length === 0) return null;
2148
2135
  const files = [];
2149
2136
  let totalBytes = 0;
2150
2137
  for (const { status, beforePath, path } of entries) {
@@ -2180,6 +2167,129 @@ async function captureCodeChangeFromGit(cwd, label) {
2180
2167
  return null;
2181
2168
  }
2182
2169
  }
2170
+ async function listChanges(git, root, base) {
2171
+ const tracked = await git(root, [
2172
+ "diff",
2173
+ "--name-status",
2174
+ "--find-renames",
2175
+ "-z",
2176
+ base,
2177
+ "--",
2178
+ ":!.bitfab"
2179
+ ]);
2180
+ const untracked = await git(root, [
2181
+ "ls-files",
2182
+ "--others",
2183
+ "--exclude-standard",
2184
+ "-z",
2185
+ "--",
2186
+ ":!.bitfab"
2187
+ ]);
2188
+ return [...parseNameStatusZ(tracked ?? ""), ...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({
2189
+ status: "A",
2190
+ beforePath: path,
2191
+ path
2192
+ }))];
2193
+ }
2194
+ async function defaultBranchCandidates(git, root) {
2195
+ const originHead = (await git(root, [
2196
+ "rev-parse",
2197
+ "--abbrev-ref",
2198
+ "origin/HEAD"
2199
+ ]))?.trim();
2200
+ const candidates = [
2201
+ originHead && originHead !== "origin/HEAD" ? originHead : null,
2202
+ "origin/main",
2203
+ "origin/master",
2204
+ "main",
2205
+ "master"
2206
+ ].filter((ref) => !!ref);
2207
+ return [...new Set(candidates)];
2208
+ }
2209
+ async function resolveDefaultBranch(git, root) {
2210
+ for (const ref of await defaultBranchCandidates(git, root)) if (await refExists(git, root, ref)) return ref;
2211
+ return null;
2212
+ }
2213
+ async function currentBranchRefs(git, root) {
2214
+ const branch = (await git(root, [
2215
+ "symbolic-ref",
2216
+ "--short",
2217
+ "-q",
2218
+ "HEAD"
2219
+ ]))?.trim();
2220
+ const refs = /* @__PURE__ */ new Set();
2221
+ if (branch) {
2222
+ refs.add(`refs/heads/${branch}`);
2223
+ const remotes = (await git(root, ["remote"]))?.split(/\s+/) ?? [];
2224
+ for (const remote of remotes.filter((r) => r.length > 0)) refs.add(`refs/remotes/${remote}/${branch}`);
2225
+ }
2226
+ return refs;
2227
+ }
2228
+ async function ownBranchRefs(git, root) {
2229
+ const upstream = (await git(root, [
2230
+ "rev-parse",
2231
+ "--symbolic-full-name",
2232
+ "@{upstream}"
2233
+ ]))?.trim();
2234
+ const own = await currentBranchRefs(git, root);
2235
+ if (upstream) own.add(upstream);
2236
+ return own;
2237
+ }
2238
+ async function isOnDefaultBranch(git, root, defaultBranch) {
2239
+ const fullName = (await git(root, [
2240
+ "rev-parse",
2241
+ "--symbolic-full-name",
2242
+ defaultBranch
2243
+ ]))?.trim();
2244
+ return !!fullName && (await currentBranchRefs(git, root)).has(fullName);
2245
+ }
2246
+ async function branchTips(git, root) {
2247
+ const own = await ownBranchRefs(git, root);
2248
+ const listing = await git(root, [
2249
+ "for-each-ref",
2250
+ "--format=%(objectname) %(refname)",
2251
+ "refs/heads",
2252
+ "refs/remotes"
2253
+ ]);
2254
+ const tips = /* @__PURE__ */ new Map();
2255
+ for (const line of (listing ?? "").split("\n")) {
2256
+ const [sha, ref] = line.trim().split(" ");
2257
+ if (!ref || own.has(ref) || ref.endsWith("/HEAD") || tips.has(sha)) continue;
2258
+ tips.set(sha, ref.replace(/^refs\/(heads|remotes)\//, ""));
2259
+ }
2260
+ return tips;
2261
+ }
2262
+ async function resolveBranchPoint(git, root) {
2263
+ const head = (await git(root, ["rev-parse", "HEAD"]))?.trim();
2264
+ if (!head) return null;
2265
+ const defaultBranch = await resolveDefaultBranch(git, root);
2266
+ if (defaultBranch && await isOnDefaultBranch(git, root, defaultBranch)) return null;
2267
+ const defaultBase = defaultBranch ? (await git(root, [
2268
+ "merge-base",
2269
+ "HEAD",
2270
+ defaultBranch
2271
+ ]))?.trim() : void 0;
2272
+ const walk = [
2273
+ "rev-list",
2274
+ "--first-parent",
2275
+ `--max-count=${MAX_BRANCH_WALK}`,
2276
+ "HEAD",
2277
+ ...defaultBase ? [`^${defaultBase}`] : []
2278
+ ];
2279
+ const tips = await branchTips(git, root);
2280
+ const history = (await git(root, walk) ?? "").split(/\s+/).filter(Boolean);
2281
+ for (const sha of history.slice(1)) {
2282
+ const name = tips.get(sha);
2283
+ if (name) return {
2284
+ base: sha,
2285
+ against: `vs ${name}`
2286
+ };
2287
+ }
2288
+ return defaultBase && defaultBase !== head ? {
2289
+ base: defaultBase,
2290
+ against: `vs ${defaultBranch}`
2291
+ } : null;
2292
+ }
2183
2293
  async function resolveBase(git, root) {
2184
2294
  const forced = process.env?.BITFAB_CODE_CHANGE_BASE;
2185
2295
  if (forced && await refExists(git, root, forced)) {
@@ -3952,7 +4062,8 @@ var TracesClient = class {
3952
4062
  traceId: params.traceId,
3953
4063
  assertions: params.assertions
3954
4064
  }],
3955
- source: params.source
4065
+ source: params.source,
4066
+ skipGuidedRewrite: params.skipGuidedRewrite
3956
4067
  });
3957
4068
  }
3958
4069
  async saveAssertionsAll(params) {
@@ -3962,7 +4073,8 @@ var TracesClient = class {
3962
4073
  ...update,
3963
4074
  assertions: update.assertions.map(toWireAssertion)
3964
4075
  })),
3965
- source: params.source ?? "agent"
4076
+ source: params.source ?? "agent",
4077
+ guidedRewrite: params.skipGuidedRewrite !== true
3966
4078
  })).assertions);
3967
4079
  }
3968
4080
  async generateAssertions(traceId, options = {}) {
@@ -5798,7 +5910,7 @@ var Bitfab = class {
5798
5910
  await runWithSeedContext({ traceId }, async () => target(...args));
5799
5911
  } finally {
5800
5912
  try {
5801
- const { flushTraces } = await Promise.resolve().then(() => require("./http-Cy8I9KDT.cjs")).then((n) => n.http_exports);
5913
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-CbiIR-Z6.cjs")).then((n) => n.http_exports);
5802
5914
  await flushTraces(3e4);
5803
5915
  } finally {
5804
5916
  unrecorded = activeTraceStates.delete(traceId);
@@ -5986,7 +6098,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
5986
6098
  metadata: seedCase.metadata,
5987
6099
  sessionId: seedCase.sessionId
5988
6100
  }));
5989
- const { flushTraces } = await Promise.resolve().then(() => require("./http-Cy8I9KDT.cjs")).then((n) => n.http_exports);
6101
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-CbiIR-Z6.cjs")).then((n) => n.http_exports);
5990
6102
  await flushTraces(3e4);
5991
6103
  return {
5992
6104
  pipeline,
@@ -6224,4 +6336,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
6224
6336
  }
6225
6337
  });
6226
6338
 
6227
- //# sourceMappingURL=src-gxbiiKid.cjs.map
6339
+ //# sourceMappingURL=src-Cgw_Bw4p.cjs.map