agentv 4.28.0 → 4.29.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.
@@ -27,7 +27,16 @@ import { cp, mkdtemp, readdir, rm, stat } from "node:fs/promises";
27
27
  import os from "node:os";
28
28
  import path4 from "node:path";
29
29
  import { promisify } from "node:util";
30
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
30
+ import {
31
+ existsSync as existsSync2,
32
+ mkdirSync as mkdirSync2,
33
+ readFileSync as readFileSync3,
34
+ readdirSync,
35
+ renameSync,
36
+ statSync,
37
+ unlinkSync,
38
+ writeFileSync as writeFileSync2
39
+ } from "node:fs";
31
40
  import path5 from "node:path";
32
41
  import { stringify as stringifyYaml } from "yaml";
33
42
  import * as childProcess from "node:child_process";
@@ -890,9 +899,56 @@ async function directPushResults(params) {
890
899
  }
891
900
  return false;
892
901
  }
893
- function getBenchmarksRegistryPath() {
902
+ function getProjectsRegistryPath() {
903
+ return path5.join(getAgentvConfigDir(), "projects.yaml");
904
+ }
905
+ function getLegacyBenchmarksRegistryPath() {
894
906
  return path5.join(getAgentvConfigDir(), "benchmarks.yaml");
895
907
  }
908
+ function migrateLegacyBenchmarksFile() {
909
+ const newPath = getProjectsRegistryPath();
910
+ const oldPath = getLegacyBenchmarksRegistryPath();
911
+ const newExists = existsSync2(newPath);
912
+ const oldExists = existsSync2(oldPath);
913
+ if (!oldExists) return;
914
+ if (newExists) {
915
+ console.warn(
916
+ `[agentv] Both ${oldPath} and ${newPath} exist. Using ${path5.basename(newPath)}; delete ${path5.basename(oldPath)} when you've confirmed the new file is correct.`
917
+ );
918
+ return;
919
+ }
920
+ let parsed = null;
921
+ try {
922
+ const raw = readFileSync3(oldPath, "utf-8");
923
+ parsed = parseYamlValue(raw);
924
+ } catch (err) {
925
+ console.warn(
926
+ `[agentv] Failed to read legacy ${path5.basename(oldPath)} for migration: ${err.message}. Leaving the file in place; you may need to migrate it manually.`
927
+ );
928
+ return;
929
+ }
930
+ const entries = parsed && typeof parsed === "object" && Array.isArray(parsed.benchmarks) ? parsed.benchmarks : [];
931
+ const newContent = stringifyYaml({ projects: entries });
932
+ const tempPath = `${newPath}.migrating`;
933
+ try {
934
+ mkdirSync2(path5.dirname(newPath), { recursive: true });
935
+ writeFileSync2(tempPath, newContent, "utf-8");
936
+ renameSync(tempPath, newPath);
937
+ unlinkSync(oldPath);
938
+ } catch (err) {
939
+ try {
940
+ if (existsSync2(tempPath)) unlinkSync(tempPath);
941
+ } catch {
942
+ }
943
+ console.warn(
944
+ `[agentv] Failed to migrate ${path5.basename(oldPath)} \u2192 ${path5.basename(newPath)}: ${err.message}. Legacy file left in place.`
945
+ );
946
+ return;
947
+ }
948
+ console.log(
949
+ `[agentv] Migrated registry: ${path5.basename(oldPath)} \u2192 ${path5.basename(newPath)} (${entries.length} entr${entries.length === 1 ? "y" : "ies"})`
950
+ );
951
+ }
896
952
  function fromYaml(raw) {
897
953
  if (!raw || typeof raw !== "object") return null;
898
954
  const e = raw;
@@ -927,36 +983,37 @@ function toYaml(entry) {
927
983
  }
928
984
  return yaml;
929
985
  }
930
- function loadBenchmarkRegistry() {
931
- const registryPath = getBenchmarksRegistryPath();
986
+ function loadProjectRegistry() {
987
+ migrateLegacyBenchmarksFile();
988
+ const registryPath = getProjectsRegistryPath();
932
989
  if (!existsSync2(registryPath)) {
933
- return { benchmarks: [] };
990
+ return { projects: [] };
934
991
  }
935
992
  try {
936
993
  const raw = readFileSync3(registryPath, "utf-8");
937
994
  const parsed = parseYamlValue(raw);
938
995
  if (!parsed || typeof parsed !== "object") {
939
- return { benchmarks: [] };
996
+ return { projects: [] };
940
997
  }
941
998
  const env = process.env;
942
- const benchmarks = Array.isArray(parsed.benchmarks) ? parsed.benchmarks.map((e) => fromYaml(interpolateEnv(e, env))).filter((e) => e !== null) : [];
943
- return { benchmarks };
999
+ const projects = Array.isArray(parsed.projects) ? parsed.projects.map((e) => fromYaml(interpolateEnv(e, env))).filter((e) => e !== null) : [];
1000
+ return { projects };
944
1001
  } catch {
945
- return { benchmarks: [] };
1002
+ return { projects: [] };
946
1003
  }
947
1004
  }
948
- function saveBenchmarkRegistry(registry) {
949
- const registryPath = getBenchmarksRegistryPath();
1005
+ function saveProjectRegistry(registry) {
1006
+ const registryPath = getProjectsRegistryPath();
950
1007
  const dir = path5.dirname(registryPath);
951
1008
  if (!existsSync2(dir)) {
952
1009
  mkdirSync2(dir, { recursive: true });
953
1010
  }
954
- const payload = { benchmarks: registry.benchmarks.map(toYaml) };
1011
+ const payload = { projects: registry.projects.map(toYaml) };
955
1012
  writeFileSync2(registryPath, stringifyYaml(payload), "utf-8");
956
1013
  }
957
- function deriveBenchmarkId(dirPath, existingIds) {
1014
+ function deriveProjectId(dirPath, existingIds) {
958
1015
  const base = path5.basename(dirPath).toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
959
- let candidate = base || "benchmark";
1016
+ let candidate = base || "project";
960
1017
  let suffix = 2;
961
1018
  while (existingIds.includes(candidate)) {
962
1019
  candidate = `${base}-${suffix}`;
@@ -964,54 +1021,54 @@ function deriveBenchmarkId(dirPath, existingIds) {
964
1021
  }
965
1022
  return candidate;
966
1023
  }
967
- function addBenchmark(benchmarkPath) {
968
- const absPath = path5.resolve(benchmarkPath);
1024
+ function addProject(projectPath) {
1025
+ const absPath = path5.resolve(projectPath);
969
1026
  if (!existsSync2(absPath)) {
970
1027
  throw new Error(`Directory not found: ${absPath}`);
971
1028
  }
972
1029
  if (!existsSync2(path5.join(absPath, ".agentv"))) {
973
1030
  throw new Error(`No .agentv/ directory found in ${absPath}. Run an evaluation first.`);
974
1031
  }
975
- const registry = loadBenchmarkRegistry();
976
- const existing = registry.benchmarks.find((p) => p.path === absPath);
1032
+ const registry = loadProjectRegistry();
1033
+ const existing = registry.projects.find((p) => p.path === absPath);
977
1034
  if (existing) {
978
1035
  return existing;
979
1036
  }
980
1037
  const now = (/* @__PURE__ */ new Date()).toISOString();
981
1038
  const entry = {
982
- id: deriveBenchmarkId(
1039
+ id: deriveProjectId(
983
1040
  absPath,
984
- registry.benchmarks.map((p) => p.id)
1041
+ registry.projects.map((p) => p.id)
985
1042
  ),
986
1043
  name: path5.basename(absPath),
987
1044
  path: absPath,
988
1045
  addedAt: now,
989
1046
  lastOpenedAt: now
990
1047
  };
991
- registry.benchmarks.push(entry);
992
- saveBenchmarkRegistry(registry);
1048
+ registry.projects.push(entry);
1049
+ saveProjectRegistry(registry);
993
1050
  return entry;
994
1051
  }
995
- function removeBenchmark(benchmarkId) {
996
- const registry = loadBenchmarkRegistry();
997
- const idx = registry.benchmarks.findIndex((p) => p.id === benchmarkId);
1052
+ function removeProject(projectId) {
1053
+ const registry = loadProjectRegistry();
1054
+ const idx = registry.projects.findIndex((p) => p.id === projectId);
998
1055
  if (idx < 0) return false;
999
- registry.benchmarks.splice(idx, 1);
1000
- saveBenchmarkRegistry(registry);
1056
+ registry.projects.splice(idx, 1);
1057
+ saveProjectRegistry(registry);
1001
1058
  return true;
1002
1059
  }
1003
- function getBenchmark(benchmarkId) {
1004
- return loadBenchmarkRegistry().benchmarks.find((p) => p.id === benchmarkId);
1060
+ function getProject(projectId) {
1061
+ return loadProjectRegistry().projects.find((p) => p.id === projectId);
1005
1062
  }
1006
- function touchBenchmark(benchmarkId) {
1007
- const registry = loadBenchmarkRegistry();
1008
- const entry = registry.benchmarks.find((p) => p.id === benchmarkId);
1063
+ function touchProject(projectId) {
1064
+ const registry = loadProjectRegistry();
1065
+ const entry = registry.projects.find((p) => p.id === projectId);
1009
1066
  if (entry) {
1010
1067
  entry.lastOpenedAt = (/* @__PURE__ */ new Date()).toISOString();
1011
- saveBenchmarkRegistry(registry);
1068
+ saveProjectRegistry(registry);
1012
1069
  }
1013
1070
  }
1014
- function discoverBenchmarks(rootDir, maxDepth = 2) {
1071
+ function discoverProjects(rootDir, maxDepth = 2) {
1015
1072
  const absRoot = path5.resolve(rootDir);
1016
1073
  if (!existsSync2(absRoot) || !statSync(absRoot).isDirectory()) {
1017
1074
  return [];
@@ -1037,9 +1094,9 @@ function discoverBenchmarks(rootDir, maxDepth = 2) {
1037
1094
  scan(absRoot, 0);
1038
1095
  return results.sort();
1039
1096
  }
1040
- async function syncBenchmark(entry) {
1097
+ async function syncProject(entry) {
1041
1098
  if (!entry.source) {
1042
- throw new Error(`Benchmark '${entry.id}' has no source defined`);
1099
+ throw new Error(`Project '${entry.id}' has no source defined`);
1043
1100
  }
1044
1101
  const { url, ref } = entry.source;
1045
1102
  const dest = entry.path;
@@ -1053,12 +1110,12 @@ async function syncBenchmark(entry) {
1053
1110
  );
1054
1111
  }
1055
1112
  }
1056
- async function syncBenchmarks(entries) {
1113
+ async function syncProjects(entries) {
1057
1114
  for (const entry of entries) {
1058
1115
  if (!entry.source) continue;
1059
- console.log(`Syncing benchmark '${entry.id}' from ${entry.source.url}...`);
1060
- await syncBenchmark(entry);
1061
- console.log(`Benchmark '${entry.id}' synced.`);
1116
+ console.log(`Syncing project '${entry.id}' from ${entry.source.url}...`);
1117
+ await syncProject(entry);
1118
+ console.log(`Project '${entry.id}' synced.`);
1062
1119
  }
1063
1120
  }
1064
1121
  var STRIPPED_TOP_LEVEL_FIELDS = /* @__PURE__ */ new Set([
@@ -2313,17 +2370,17 @@ export {
2313
2370
  pushResultsRepoBranch,
2314
2371
  createDraftResultsPr,
2315
2372
  directPushResults,
2316
- getBenchmarksRegistryPath,
2317
- loadBenchmarkRegistry,
2318
- saveBenchmarkRegistry,
2319
- deriveBenchmarkId,
2320
- addBenchmark,
2321
- removeBenchmark,
2322
- getBenchmark,
2323
- touchBenchmark,
2324
- discoverBenchmarks,
2325
- syncBenchmark,
2326
- syncBenchmarks,
2373
+ getProjectsRegistryPath,
2374
+ loadProjectRegistry,
2375
+ saveProjectRegistry,
2376
+ deriveProjectId,
2377
+ addProject,
2378
+ removeProject,
2379
+ getProject,
2380
+ touchProject,
2381
+ discoverProjects,
2382
+ syncProject,
2383
+ syncProjects,
2327
2384
  trimBaselineResult,
2328
2385
  DEFAULT_CATEGORY,
2329
2386
  deriveCategory,
@@ -2344,4 +2401,4 @@ export {
2344
2401
  TranscriptProvider,
2345
2402
  createAgentKernel
2346
2403
  };
2347
- //# sourceMappingURL=chunk-WZVOY2W2.js.map
2404
+ //# sourceMappingURL=chunk-VZMGBDJD.js.map