@uzysjung/agent-harness 26.136.0 → 26.139.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 CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  residentCost,
28
28
  resolveScope,
29
29
  summarizeContextCost
30
- } from "./chunk-WCH7E3G6.js";
30
+ } from "./chunk-4VDIAMSM.js";
31
31
 
32
32
  // node_modules/sisteransi/src/index.js
33
33
  var require_src = __commonJS({
@@ -712,7 +712,7 @@ var cac = (name = "") => new CAC(name);
712
712
  // package.json
713
713
  var package_default = {
714
714
  name: "@uzysjung/agent-harness",
715
- version: "26.136.0",
715
+ version: "26.139.0",
716
716
  description: "Curate vetted AI-coding skills & plugins by your tech stack \u2014 install only what you need, across Claude Code, Codex, OpenCode & Antigravity",
717
717
  type: "module",
718
718
  publishConfig: {
@@ -926,10 +926,13 @@ import {
926
926
  copyFileSync,
927
927
  cpSync,
928
928
  existsSync,
929
+ constants as fsConstants,
929
930
  mkdirSync,
930
931
  readdirSync,
931
932
  readFileSync,
932
- renameSync
933
+ realpathSync,
934
+ renameSync,
935
+ rmdirSync
933
936
  } from "fs";
934
937
  import { dirname, join } from "path";
935
938
  function ensureDir(path) {
@@ -949,11 +952,25 @@ function copyDir(source, target) {
949
952
  mkdirSync(target, { recursive: true });
950
953
  cpSync(source, target, { recursive: true, force: true });
951
954
  }
955
+ var MAX_BACKUP_CLAIMS = 100;
956
+ function claimBackupPath(base, claim) {
957
+ for (let n = 1; n <= MAX_BACKUP_CLAIMS; n++) {
958
+ const candidate = n === 1 ? base : `${base}-${n}`;
959
+ try {
960
+ claim(candidate);
961
+ return candidate;
962
+ } catch (err) {
963
+ if (err.code !== "EEXIST") throw err;
964
+ }
965
+ }
966
+ throw new Error(`Cannot allocate a backup path for ${base} (${MAX_BACKUP_CLAIMS} taken)`);
967
+ }
952
968
  function backupDir(target, now = /* @__PURE__ */ new Date()) {
953
969
  if (!existsSync(target)) {
954
970
  return null;
955
971
  }
956
- const backup = `${target}.backup-${formatStamp(now)}`;
972
+ const backup = claimBackupPath(`${target}.backup-${formatStamp(now)}`, (c3) => mkdirSync(c3));
973
+ rmdirSync(backup);
957
974
  renameSync(target, backup);
958
975
  return backup;
959
976
  }
@@ -961,8 +978,8 @@ function copyBackupDir(target, now = /* @__PURE__ */ new Date()) {
961
978
  if (!existsSync(target)) {
962
979
  return null;
963
980
  }
964
- const backup = `${target}.backup-${formatStamp(now)}`;
965
- cpSync(target, backup, { recursive: true });
981
+ const backup = claimBackupPath(`${target}.backup-${formatStamp(now)}`, (c3) => mkdirSync(c3));
982
+ cpSync(realpathSync(target), backup, { recursive: true });
966
983
  return backup;
967
984
  }
968
985
  function backupFileIfChanged(target, newContent, now = /* @__PURE__ */ new Date()) {
@@ -975,9 +992,10 @@ function backupFileIfChanged(target, newContent, now = /* @__PURE__ */ new Date(
975
992
  return backupFile(target, now);
976
993
  }
977
994
  function backupFile(target, now = /* @__PURE__ */ new Date()) {
978
- const backup = `${target}.backup-${formatStamp(now)}`;
979
- copyFileSync(target, backup);
980
- return backup;
995
+ return claimBackupPath(
996
+ `${target}.backup-${formatStamp(now)}`,
997
+ (c3) => copyFileSync(target, c3, fsConstants.COPYFILE_EXCL)
998
+ );
981
999
  }
982
1000
  function listFilesRecursive(dir, prefix = "") {
983
1001
  if (!existsSync(dir)) return [];