@agentv/core 4.33.0-next.1 → 4.34.1-next.1

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 CHANGED
@@ -1014,7 +1014,8 @@ async function inspectResultsRepoGit(repoDir) {
1014
1014
  cwd: repoDir,
1015
1015
  check: false
1016
1016
  });
1017
- const { dirtyPaths, conflictedPaths } = parseGitPorcelainPaths(porcelain);
1017
+ const { dirtyPaths: allDirtyPaths, conflictedPaths } = parseGitPorcelainPaths(porcelain);
1018
+ const dirtyPaths = allDirtyPaths.filter(isSafeResultsRepoPath);
1018
1019
  const { ahead = 0, behind = 0 } = await getAheadBehind(repoDir, upstream);
1019
1020
  const inProgressConflict = await hasInProgressGitConflict(repoDir);
1020
1021
  let syncStatus = "clean";
@@ -1067,9 +1068,6 @@ function lastErrorForGitInspection(status, inspection) {
1067
1068
  if (status.auto_push === false) {
1068
1069
  return "Results repo has uncommitted changes and auto_push is disabled";
1069
1070
  }
1070
- if (!areSafeResultsRepoPaths(inspection.dirtyPaths)) {
1071
- return "Results repo has non-results working tree changes";
1072
- }
1073
1071
  }
1074
1072
  return void 0;
1075
1073
  }
@@ -1092,10 +1090,11 @@ function withActionFlags(status, flags) {
1092
1090
  commit_created: flags.commitCreated
1093
1091
  };
1094
1092
  }
1093
+ function isSafeResultsRepoPath(p) {
1094
+ return p === RESULTS_REPO_RESULTS_DIR || p.startsWith(`${RESULTS_REPO_RESULTS_DIR}/`);
1095
+ }
1095
1096
  function areSafeResultsRepoPaths(paths) {
1096
- return paths.length > 0 && paths.every(
1097
- (p) => p === RESULTS_REPO_RESULTS_DIR || p.startsWith(`${RESULTS_REPO_RESULTS_DIR}/`)
1098
- );
1097
+ return paths.length > 0 && paths.every(isSafeResultsRepoPath);
1099
1098
  }
1100
1099
  async function getAheadPaths(repoDir, upstream) {
1101
1100
  if (!upstream) {
@@ -1207,33 +1206,51 @@ async function syncResultsRepoForProject(config) {
1207
1206
  }
1208
1207
  );
1209
1208
  }
1210
- if (!areSafeResultsRepoPaths(inspection.dirtyPaths)) {
1211
- const status = withGitInspection(getResultsRepoStatus(normalized), inspection);
1212
- updateStatusFile(normalized, {
1213
- last_error: "Results repo has non-results working tree changes"
1214
- });
1215
- return withBlockedStatus(status, "Results repo has non-results working tree changes", {
1216
- pullPerformed,
1217
- pushPerformed,
1218
- commitCreated
1219
- });
1220
- }
1221
1209
  if ((inspection.behind ?? 0) > 0) {
1222
- const status = withGitInspection(getResultsRepoStatus(normalized), inspection);
1223
- const reason = "Results repo has uncommitted result changes and remote changes";
1224
- updateStatusFile(normalized, { last_error: reason });
1225
- return withBlockedStatus(status, reason, {
1226
- pullPerformed,
1227
- pushPerformed,
1228
- commitCreated
1229
- });
1210
+ if (!inspection.upstream) {
1211
+ const status = withGitInspection(getResultsRepoStatus(normalized), inspection);
1212
+ updateStatusFile(normalized, {
1213
+ last_error: "Results repo has no upstream branch to pull from"
1214
+ });
1215
+ return withBlockedStatus(status, "Results repo has no upstream branch to pull from", {
1216
+ pullPerformed,
1217
+ pushPerformed,
1218
+ commitCreated
1219
+ });
1220
+ }
1221
+ try {
1222
+ await runGit(["merge", "--ff-only", inspection.upstream], { cwd: repoDir });
1223
+ pullPerformed = true;
1224
+ inspection = await inspectResultsRepoGit(repoDir);
1225
+ } catch (error) {
1226
+ inspection = await inspectResultsRepoGit(repoDir);
1227
+ const status = withGitInspection(getResultsRepoStatus(normalized), inspection);
1228
+ const reason = `Results repo could not be fast-forwarded: ${getStatusMessage(error)}`;
1229
+ updateStatusFile(normalized, { last_error: reason });
1230
+ return withBlockedStatus(status, reason, {
1231
+ pullPerformed,
1232
+ pushPerformed,
1233
+ commitCreated
1234
+ });
1235
+ }
1236
+ }
1237
+ if (inspection.syncStatus === "dirty") {
1238
+ await runGit(["add", "--all", "--", RESULTS_REPO_RESULTS_DIR], { cwd: repoDir });
1239
+ await runGit(
1240
+ [
1241
+ "commit",
1242
+ "-m",
1243
+ "chore(results): sync local result metadata",
1244
+ "--",
1245
+ RESULTS_REPO_RESULTS_DIR
1246
+ ],
1247
+ {
1248
+ cwd: repoDir
1249
+ }
1250
+ );
1251
+ commitCreated = true;
1252
+ inspection = await inspectResultsRepoGit(repoDir);
1230
1253
  }
1231
- await runGit(["add", "--all", "--", RESULTS_REPO_RESULTS_DIR], { cwd: repoDir });
1232
- await runGit(["commit", "-m", "chore(results): sync local result metadata"], {
1233
- cwd: repoDir
1234
- });
1235
- commitCreated = true;
1236
- inspection = await inspectResultsRepoGit(repoDir);
1237
1254
  }
1238
1255
  if (inspection.syncStatus === "diverged") {
1239
1256
  const status = withGitInspection(getResultsRepoStatus(normalized), inspection);