opencode-swarm 6.71.0 → 6.71.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/cli/index.js CHANGED
@@ -15899,54 +15899,54 @@ var require_polyfills = __commonJS((exports, module) => {
15899
15899
  }
15900
15900
  var chdir;
15901
15901
  module.exports = patch;
15902
- function patch(fs5) {
15902
+ function patch(fs4) {
15903
15903
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
15904
- patchLchmod(fs5);
15905
- }
15906
- if (!fs5.lutimes) {
15907
- patchLutimes(fs5);
15908
- }
15909
- fs5.chown = chownFix(fs5.chown);
15910
- fs5.fchown = chownFix(fs5.fchown);
15911
- fs5.lchown = chownFix(fs5.lchown);
15912
- fs5.chmod = chmodFix(fs5.chmod);
15913
- fs5.fchmod = chmodFix(fs5.fchmod);
15914
- fs5.lchmod = chmodFix(fs5.lchmod);
15915
- fs5.chownSync = chownFixSync(fs5.chownSync);
15916
- fs5.fchownSync = chownFixSync(fs5.fchownSync);
15917
- fs5.lchownSync = chownFixSync(fs5.lchownSync);
15918
- fs5.chmodSync = chmodFixSync(fs5.chmodSync);
15919
- fs5.fchmodSync = chmodFixSync(fs5.fchmodSync);
15920
- fs5.lchmodSync = chmodFixSync(fs5.lchmodSync);
15921
- fs5.stat = statFix(fs5.stat);
15922
- fs5.fstat = statFix(fs5.fstat);
15923
- fs5.lstat = statFix(fs5.lstat);
15924
- fs5.statSync = statFixSync(fs5.statSync);
15925
- fs5.fstatSync = statFixSync(fs5.fstatSync);
15926
- fs5.lstatSync = statFixSync(fs5.lstatSync);
15927
- if (fs5.chmod && !fs5.lchmod) {
15928
- fs5.lchmod = function(path7, mode, cb) {
15904
+ patchLchmod(fs4);
15905
+ }
15906
+ if (!fs4.lutimes) {
15907
+ patchLutimes(fs4);
15908
+ }
15909
+ fs4.chown = chownFix(fs4.chown);
15910
+ fs4.fchown = chownFix(fs4.fchown);
15911
+ fs4.lchown = chownFix(fs4.lchown);
15912
+ fs4.chmod = chmodFix(fs4.chmod);
15913
+ fs4.fchmod = chmodFix(fs4.fchmod);
15914
+ fs4.lchmod = chmodFix(fs4.lchmod);
15915
+ fs4.chownSync = chownFixSync(fs4.chownSync);
15916
+ fs4.fchownSync = chownFixSync(fs4.fchownSync);
15917
+ fs4.lchownSync = chownFixSync(fs4.lchownSync);
15918
+ fs4.chmodSync = chmodFixSync(fs4.chmodSync);
15919
+ fs4.fchmodSync = chmodFixSync(fs4.fchmodSync);
15920
+ fs4.lchmodSync = chmodFixSync(fs4.lchmodSync);
15921
+ fs4.stat = statFix(fs4.stat);
15922
+ fs4.fstat = statFix(fs4.fstat);
15923
+ fs4.lstat = statFix(fs4.lstat);
15924
+ fs4.statSync = statFixSync(fs4.statSync);
15925
+ fs4.fstatSync = statFixSync(fs4.fstatSync);
15926
+ fs4.lstatSync = statFixSync(fs4.lstatSync);
15927
+ if (fs4.chmod && !fs4.lchmod) {
15928
+ fs4.lchmod = function(path6, mode, cb) {
15929
15929
  if (cb)
15930
15930
  process.nextTick(cb);
15931
15931
  };
15932
- fs5.lchmodSync = function() {};
15932
+ fs4.lchmodSync = function() {};
15933
15933
  }
15934
- if (fs5.chown && !fs5.lchown) {
15935
- fs5.lchown = function(path7, uid, gid, cb) {
15934
+ if (fs4.chown && !fs4.lchown) {
15935
+ fs4.lchown = function(path6, uid, gid, cb) {
15936
15936
  if (cb)
15937
15937
  process.nextTick(cb);
15938
15938
  };
15939
- fs5.lchownSync = function() {};
15939
+ fs4.lchownSync = function() {};
15940
15940
  }
15941
15941
  if (platform === "win32") {
15942
- fs5.rename = typeof fs5.rename !== "function" ? fs5.rename : function(fs$rename) {
15942
+ fs4.rename = typeof fs4.rename !== "function" ? fs4.rename : function(fs$rename) {
15943
15943
  function rename2(from, to, cb) {
15944
15944
  var start = Date.now();
15945
15945
  var backoff = 0;
15946
15946
  fs$rename(from, to, function CB(er) {
15947
15947
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
15948
15948
  setTimeout(function() {
15949
- fs5.stat(to, function(stater, st) {
15949
+ fs4.stat(to, function(stater, st) {
15950
15950
  if (stater && stater.code === "ENOENT")
15951
15951
  fs$rename(from, to, CB);
15952
15952
  else
@@ -15964,9 +15964,9 @@ var require_polyfills = __commonJS((exports, module) => {
15964
15964
  if (Object.setPrototypeOf)
15965
15965
  Object.setPrototypeOf(rename2, fs$rename);
15966
15966
  return rename2;
15967
- }(fs5.rename);
15967
+ }(fs4.rename);
15968
15968
  }
15969
- fs5.read = typeof fs5.read !== "function" ? fs5.read : function(fs$read) {
15969
+ fs4.read = typeof fs4.read !== "function" ? fs4.read : function(fs$read) {
15970
15970
  function read(fd, buffer, offset, length, position, callback_) {
15971
15971
  var callback;
15972
15972
  if (callback_ && typeof callback_ === "function") {
@@ -15974,23 +15974,23 @@ var require_polyfills = __commonJS((exports, module) => {
15974
15974
  callback = function(er, _, __) {
15975
15975
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
15976
15976
  eagCounter++;
15977
- return fs$read.call(fs5, fd, buffer, offset, length, position, callback);
15977
+ return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
15978
15978
  }
15979
15979
  callback_.apply(this, arguments);
15980
15980
  };
15981
15981
  }
15982
- return fs$read.call(fs5, fd, buffer, offset, length, position, callback);
15982
+ return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
15983
15983
  }
15984
15984
  if (Object.setPrototypeOf)
15985
15985
  Object.setPrototypeOf(read, fs$read);
15986
15986
  return read;
15987
- }(fs5.read);
15988
- fs5.readSync = typeof fs5.readSync !== "function" ? fs5.readSync : function(fs$readSync) {
15987
+ }(fs4.read);
15988
+ fs4.readSync = typeof fs4.readSync !== "function" ? fs4.readSync : function(fs$readSync) {
15989
15989
  return function(fd, buffer, offset, length, position) {
15990
15990
  var eagCounter = 0;
15991
15991
  while (true) {
15992
15992
  try {
15993
- return fs$readSync.call(fs5, fd, buffer, offset, length, position);
15993
+ return fs$readSync.call(fs4, fd, buffer, offset, length, position);
15994
15994
  } catch (er) {
15995
15995
  if (er.code === "EAGAIN" && eagCounter < 10) {
15996
15996
  eagCounter++;
@@ -16000,90 +16000,90 @@ var require_polyfills = __commonJS((exports, module) => {
16000
16000
  }
16001
16001
  }
16002
16002
  };
16003
- }(fs5.readSync);
16004
- function patchLchmod(fs6) {
16005
- fs6.lchmod = function(path7, mode, callback) {
16006
- fs6.open(path7, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
16003
+ }(fs4.readSync);
16004
+ function patchLchmod(fs5) {
16005
+ fs5.lchmod = function(path6, mode, callback) {
16006
+ fs5.open(path6, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
16007
16007
  if (err) {
16008
16008
  if (callback)
16009
16009
  callback(err);
16010
16010
  return;
16011
16011
  }
16012
- fs6.fchmod(fd, mode, function(err2) {
16013
- fs6.close(fd, function(err22) {
16012
+ fs5.fchmod(fd, mode, function(err2) {
16013
+ fs5.close(fd, function(err22) {
16014
16014
  if (callback)
16015
16015
  callback(err2 || err22);
16016
16016
  });
16017
16017
  });
16018
16018
  });
16019
16019
  };
16020
- fs6.lchmodSync = function(path7, mode) {
16021
- var fd = fs6.openSync(path7, constants.O_WRONLY | constants.O_SYMLINK, mode);
16020
+ fs5.lchmodSync = function(path6, mode) {
16021
+ var fd = fs5.openSync(path6, constants.O_WRONLY | constants.O_SYMLINK, mode);
16022
16022
  var threw = true;
16023
16023
  var ret;
16024
16024
  try {
16025
- ret = fs6.fchmodSync(fd, mode);
16025
+ ret = fs5.fchmodSync(fd, mode);
16026
16026
  threw = false;
16027
16027
  } finally {
16028
16028
  if (threw) {
16029
16029
  try {
16030
- fs6.closeSync(fd);
16030
+ fs5.closeSync(fd);
16031
16031
  } catch (er) {}
16032
16032
  } else {
16033
- fs6.closeSync(fd);
16033
+ fs5.closeSync(fd);
16034
16034
  }
16035
16035
  }
16036
16036
  return ret;
16037
16037
  };
16038
16038
  }
16039
- function patchLutimes(fs6) {
16040
- if (constants.hasOwnProperty("O_SYMLINK") && fs6.futimes) {
16041
- fs6.lutimes = function(path7, at, mt, cb) {
16042
- fs6.open(path7, constants.O_SYMLINK, function(er, fd) {
16039
+ function patchLutimes(fs5) {
16040
+ if (constants.hasOwnProperty("O_SYMLINK") && fs5.futimes) {
16041
+ fs5.lutimes = function(path6, at, mt, cb) {
16042
+ fs5.open(path6, constants.O_SYMLINK, function(er, fd) {
16043
16043
  if (er) {
16044
16044
  if (cb)
16045
16045
  cb(er);
16046
16046
  return;
16047
16047
  }
16048
- fs6.futimes(fd, at, mt, function(er2) {
16049
- fs6.close(fd, function(er22) {
16048
+ fs5.futimes(fd, at, mt, function(er2) {
16049
+ fs5.close(fd, function(er22) {
16050
16050
  if (cb)
16051
16051
  cb(er2 || er22);
16052
16052
  });
16053
16053
  });
16054
16054
  });
16055
16055
  };
16056
- fs6.lutimesSync = function(path7, at, mt) {
16057
- var fd = fs6.openSync(path7, constants.O_SYMLINK);
16056
+ fs5.lutimesSync = function(path6, at, mt) {
16057
+ var fd = fs5.openSync(path6, constants.O_SYMLINK);
16058
16058
  var ret;
16059
16059
  var threw = true;
16060
16060
  try {
16061
- ret = fs6.futimesSync(fd, at, mt);
16061
+ ret = fs5.futimesSync(fd, at, mt);
16062
16062
  threw = false;
16063
16063
  } finally {
16064
16064
  if (threw) {
16065
16065
  try {
16066
- fs6.closeSync(fd);
16066
+ fs5.closeSync(fd);
16067
16067
  } catch (er) {}
16068
16068
  } else {
16069
- fs6.closeSync(fd);
16069
+ fs5.closeSync(fd);
16070
16070
  }
16071
16071
  }
16072
16072
  return ret;
16073
16073
  };
16074
- } else if (fs6.futimes) {
16075
- fs6.lutimes = function(_a2, _b, _c, cb) {
16074
+ } else if (fs5.futimes) {
16075
+ fs5.lutimes = function(_a2, _b, _c, cb) {
16076
16076
  if (cb)
16077
16077
  process.nextTick(cb);
16078
16078
  };
16079
- fs6.lutimesSync = function() {};
16079
+ fs5.lutimesSync = function() {};
16080
16080
  }
16081
16081
  }
16082
16082
  function chmodFix(orig) {
16083
16083
  if (!orig)
16084
16084
  return orig;
16085
16085
  return function(target, mode, cb) {
16086
- return orig.call(fs5, target, mode, function(er) {
16086
+ return orig.call(fs4, target, mode, function(er) {
16087
16087
  if (chownErOk(er))
16088
16088
  er = null;
16089
16089
  if (cb)
@@ -16096,7 +16096,7 @@ var require_polyfills = __commonJS((exports, module) => {
16096
16096
  return orig;
16097
16097
  return function(target, mode) {
16098
16098
  try {
16099
- return orig.call(fs5, target, mode);
16099
+ return orig.call(fs4, target, mode);
16100
16100
  } catch (er) {
16101
16101
  if (!chownErOk(er))
16102
16102
  throw er;
@@ -16107,7 +16107,7 @@ var require_polyfills = __commonJS((exports, module) => {
16107
16107
  if (!orig)
16108
16108
  return orig;
16109
16109
  return function(target, uid, gid, cb) {
16110
- return orig.call(fs5, target, uid, gid, function(er) {
16110
+ return orig.call(fs4, target, uid, gid, function(er) {
16111
16111
  if (chownErOk(er))
16112
16112
  er = null;
16113
16113
  if (cb)
@@ -16120,7 +16120,7 @@ var require_polyfills = __commonJS((exports, module) => {
16120
16120
  return orig;
16121
16121
  return function(target, uid, gid) {
16122
16122
  try {
16123
- return orig.call(fs5, target, uid, gid);
16123
+ return orig.call(fs4, target, uid, gid);
16124
16124
  } catch (er) {
16125
16125
  if (!chownErOk(er))
16126
16126
  throw er;
@@ -16145,14 +16145,14 @@ var require_polyfills = __commonJS((exports, module) => {
16145
16145
  if (cb)
16146
16146
  cb.apply(this, arguments);
16147
16147
  }
16148
- return options ? orig.call(fs5, target, options, callback) : orig.call(fs5, target, callback);
16148
+ return options ? orig.call(fs4, target, options, callback) : orig.call(fs4, target, callback);
16149
16149
  };
16150
16150
  }
16151
16151
  function statFixSync(orig) {
16152
16152
  if (!orig)
16153
16153
  return orig;
16154
16154
  return function(target, options) {
16155
- var stats = options ? orig.call(fs5, target, options) : orig.call(fs5, target);
16155
+ var stats = options ? orig.call(fs4, target, options) : orig.call(fs4, target);
16156
16156
  if (stats) {
16157
16157
  if (stats.uid < 0)
16158
16158
  stats.uid += 4294967296;
@@ -16181,17 +16181,17 @@ var require_polyfills = __commonJS((exports, module) => {
16181
16181
  var require_legacy_streams = __commonJS((exports, module) => {
16182
16182
  var Stream = __require("stream").Stream;
16183
16183
  module.exports = legacy;
16184
- function legacy(fs5) {
16184
+ function legacy(fs4) {
16185
16185
  return {
16186
16186
  ReadStream,
16187
16187
  WriteStream
16188
16188
  };
16189
- function ReadStream(path7, options) {
16189
+ function ReadStream(path6, options) {
16190
16190
  if (!(this instanceof ReadStream))
16191
- return new ReadStream(path7, options);
16191
+ return new ReadStream(path6, options);
16192
16192
  Stream.call(this);
16193
16193
  var self = this;
16194
- this.path = path7;
16194
+ this.path = path6;
16195
16195
  this.fd = null;
16196
16196
  this.readable = true;
16197
16197
  this.paused = false;
@@ -16226,7 +16226,7 @@ var require_legacy_streams = __commonJS((exports, module) => {
16226
16226
  });
16227
16227
  return;
16228
16228
  }
16229
- fs5.open(this.path, this.flags, this.mode, function(err, fd) {
16229
+ fs4.open(this.path, this.flags, this.mode, function(err, fd) {
16230
16230
  if (err) {
16231
16231
  self.emit("error", err);
16232
16232
  self.readable = false;
@@ -16237,11 +16237,11 @@ var require_legacy_streams = __commonJS((exports, module) => {
16237
16237
  self._read();
16238
16238
  });
16239
16239
  }
16240
- function WriteStream(path7, options) {
16240
+ function WriteStream(path6, options) {
16241
16241
  if (!(this instanceof WriteStream))
16242
- return new WriteStream(path7, options);
16242
+ return new WriteStream(path6, options);
16243
16243
  Stream.call(this);
16244
- this.path = path7;
16244
+ this.path = path6;
16245
16245
  this.fd = null;
16246
16246
  this.writable = true;
16247
16247
  this.flags = "w";
@@ -16266,7 +16266,7 @@ var require_legacy_streams = __commonJS((exports, module) => {
16266
16266
  this.busy = false;
16267
16267
  this._queue = [];
16268
16268
  if (this.fd === null) {
16269
- this._open = fs5.open;
16269
+ this._open = fs4.open;
16270
16270
  this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
16271
16271
  this.flush();
16272
16272
  }
@@ -16276,11 +16276,11 @@ var require_legacy_streams = __commonJS((exports, module) => {
16276
16276
 
16277
16277
  // node_modules/graceful-fs/clone.js
16278
16278
  var require_clone = __commonJS((exports, module) => {
16279
- module.exports = clone3;
16279
+ module.exports = clone2;
16280
16280
  var getPrototypeOf = Object.getPrototypeOf || function(obj) {
16281
16281
  return obj.__proto__;
16282
16282
  };
16283
- function clone3(obj) {
16283
+ function clone2(obj) {
16284
16284
  if (obj === null || typeof obj !== "object")
16285
16285
  return obj;
16286
16286
  if (obj instanceof Object)
@@ -16296,10 +16296,10 @@ var require_clone = __commonJS((exports, module) => {
16296
16296
 
16297
16297
  // node_modules/graceful-fs/graceful-fs.js
16298
16298
  var require_graceful_fs = __commonJS((exports, module) => {
16299
- var fs5 = __require("fs");
16299
+ var fs4 = __require("fs");
16300
16300
  var polyfills = require_polyfills();
16301
16301
  var legacy = require_legacy_streams();
16302
- var clone3 = require_clone();
16302
+ var clone2 = require_clone();
16303
16303
  var util = __require("util");
16304
16304
  var gracefulQueue;
16305
16305
  var previousSymbol;
@@ -16328,12 +16328,12 @@ var require_graceful_fs = __commonJS((exports, module) => {
16328
16328
  GFS4: `);
16329
16329
  console.error(m);
16330
16330
  };
16331
- if (!fs5[gracefulQueue]) {
16331
+ if (!fs4[gracefulQueue]) {
16332
16332
  queue = global[gracefulQueue] || [];
16333
- publishQueue(fs5, queue);
16334
- fs5.close = function(fs$close) {
16333
+ publishQueue(fs4, queue);
16334
+ fs4.close = function(fs$close) {
16335
16335
  function close(fd, cb) {
16336
- return fs$close.call(fs5, fd, function(err) {
16336
+ return fs$close.call(fs4, fd, function(err) {
16337
16337
  if (!err) {
16338
16338
  resetQueue();
16339
16339
  }
@@ -16345,48 +16345,48 @@ GFS4: `);
16345
16345
  value: fs$close
16346
16346
  });
16347
16347
  return close;
16348
- }(fs5.close);
16349
- fs5.closeSync = function(fs$closeSync) {
16348
+ }(fs4.close);
16349
+ fs4.closeSync = function(fs$closeSync) {
16350
16350
  function closeSync(fd) {
16351
- fs$closeSync.apply(fs5, arguments);
16351
+ fs$closeSync.apply(fs4, arguments);
16352
16352
  resetQueue();
16353
16353
  }
16354
16354
  Object.defineProperty(closeSync, previousSymbol, {
16355
16355
  value: fs$closeSync
16356
16356
  });
16357
16357
  return closeSync;
16358
- }(fs5.closeSync);
16358
+ }(fs4.closeSync);
16359
16359
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
16360
16360
  process.on("exit", function() {
16361
- debug(fs5[gracefulQueue]);
16362
- __require("assert").equal(fs5[gracefulQueue].length, 0);
16361
+ debug(fs4[gracefulQueue]);
16362
+ __require("assert").equal(fs4[gracefulQueue].length, 0);
16363
16363
  });
16364
16364
  }
16365
16365
  }
16366
16366
  var queue;
16367
16367
  if (!global[gracefulQueue]) {
16368
- publishQueue(global, fs5[gracefulQueue]);
16369
- }
16370
- module.exports = patch(clone3(fs5));
16371
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs5.__patched) {
16372
- module.exports = patch(fs5);
16373
- fs5.__patched = true;
16374
- }
16375
- function patch(fs6) {
16376
- polyfills(fs6);
16377
- fs6.gracefulify = patch;
16378
- fs6.createReadStream = createReadStream;
16379
- fs6.createWriteStream = createWriteStream;
16380
- var fs$readFile = fs6.readFile;
16381
- fs6.readFile = readFile2;
16382
- function readFile2(path7, options, cb) {
16368
+ publishQueue(global, fs4[gracefulQueue]);
16369
+ }
16370
+ module.exports = patch(clone2(fs4));
16371
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs4.__patched) {
16372
+ module.exports = patch(fs4);
16373
+ fs4.__patched = true;
16374
+ }
16375
+ function patch(fs5) {
16376
+ polyfills(fs5);
16377
+ fs5.gracefulify = patch;
16378
+ fs5.createReadStream = createReadStream;
16379
+ fs5.createWriteStream = createWriteStream;
16380
+ var fs$readFile = fs5.readFile;
16381
+ fs5.readFile = readFile2;
16382
+ function readFile2(path6, options, cb) {
16383
16383
  if (typeof options === "function")
16384
16384
  cb = options, options = null;
16385
- return go$readFile(path7, options, cb);
16386
- function go$readFile(path8, options2, cb2, startTime) {
16387
- return fs$readFile(path8, options2, function(err) {
16385
+ return go$readFile(path6, options, cb);
16386
+ function go$readFile(path7, options2, cb2, startTime) {
16387
+ return fs$readFile(path7, options2, function(err) {
16388
16388
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16389
- enqueue([go$readFile, [path8, options2, cb2], err, startTime || Date.now(), Date.now()]);
16389
+ enqueue([go$readFile, [path7, options2, cb2], err, startTime || Date.now(), Date.now()]);
16390
16390
  else {
16391
16391
  if (typeof cb2 === "function")
16392
16392
  cb2.apply(this, arguments);
@@ -16394,16 +16394,16 @@ GFS4: `);
16394
16394
  });
16395
16395
  }
16396
16396
  }
16397
- var fs$writeFile = fs6.writeFile;
16398
- fs6.writeFile = writeFile2;
16399
- function writeFile2(path7, data, options, cb) {
16397
+ var fs$writeFile = fs5.writeFile;
16398
+ fs5.writeFile = writeFile2;
16399
+ function writeFile2(path6, data, options, cb) {
16400
16400
  if (typeof options === "function")
16401
16401
  cb = options, options = null;
16402
- return go$writeFile(path7, data, options, cb);
16403
- function go$writeFile(path8, data2, options2, cb2, startTime) {
16404
- return fs$writeFile(path8, data2, options2, function(err) {
16402
+ return go$writeFile(path6, data, options, cb);
16403
+ function go$writeFile(path7, data2, options2, cb2, startTime) {
16404
+ return fs$writeFile(path7, data2, options2, function(err) {
16405
16405
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16406
- enqueue([go$writeFile, [path8, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
16406
+ enqueue([go$writeFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
16407
16407
  else {
16408
16408
  if (typeof cb2 === "function")
16409
16409
  cb2.apply(this, arguments);
@@ -16411,17 +16411,17 @@ GFS4: `);
16411
16411
  });
16412
16412
  }
16413
16413
  }
16414
- var fs$appendFile = fs6.appendFile;
16414
+ var fs$appendFile = fs5.appendFile;
16415
16415
  if (fs$appendFile)
16416
- fs6.appendFile = appendFile2;
16417
- function appendFile2(path7, data, options, cb) {
16416
+ fs5.appendFile = appendFile2;
16417
+ function appendFile2(path6, data, options, cb) {
16418
16418
  if (typeof options === "function")
16419
16419
  cb = options, options = null;
16420
- return go$appendFile(path7, data, options, cb);
16421
- function go$appendFile(path8, data2, options2, cb2, startTime) {
16422
- return fs$appendFile(path8, data2, options2, function(err) {
16420
+ return go$appendFile(path6, data, options, cb);
16421
+ function go$appendFile(path7, data2, options2, cb2, startTime) {
16422
+ return fs$appendFile(path7, data2, options2, function(err) {
16423
16423
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16424
- enqueue([go$appendFile, [path8, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
16424
+ enqueue([go$appendFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
16425
16425
  else {
16426
16426
  if (typeof cb2 === "function")
16427
16427
  cb2.apply(this, arguments);
@@ -16429,9 +16429,9 @@ GFS4: `);
16429
16429
  });
16430
16430
  }
16431
16431
  }
16432
- var fs$copyFile = fs6.copyFile;
16432
+ var fs$copyFile = fs5.copyFile;
16433
16433
  if (fs$copyFile)
16434
- fs6.copyFile = copyFile;
16434
+ fs5.copyFile = copyFile;
16435
16435
  function copyFile(src, dest, flags, cb) {
16436
16436
  if (typeof flags === "function") {
16437
16437
  cb = flags;
@@ -16449,24 +16449,24 @@ GFS4: `);
16449
16449
  });
16450
16450
  }
16451
16451
  }
16452
- var fs$readdir = fs6.readdir;
16453
- fs6.readdir = readdir;
16452
+ var fs$readdir = fs5.readdir;
16453
+ fs5.readdir = readdir;
16454
16454
  var noReaddirOptionVersions = /^v[0-5]\./;
16455
- function readdir(path7, options, cb) {
16455
+ function readdir(path6, options, cb) {
16456
16456
  if (typeof options === "function")
16457
16457
  cb = options, options = null;
16458
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path8, options2, cb2, startTime) {
16459
- return fs$readdir(path8, fs$readdirCallback(path8, options2, cb2, startTime));
16460
- } : function go$readdir2(path8, options2, cb2, startTime) {
16461
- return fs$readdir(path8, options2, fs$readdirCallback(path8, options2, cb2, startTime));
16458
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path7, options2, cb2, startTime) {
16459
+ return fs$readdir(path7, fs$readdirCallback(path7, options2, cb2, startTime));
16460
+ } : function go$readdir2(path7, options2, cb2, startTime) {
16461
+ return fs$readdir(path7, options2, fs$readdirCallback(path7, options2, cb2, startTime));
16462
16462
  };
16463
- return go$readdir(path7, options, cb);
16464
- function fs$readdirCallback(path8, options2, cb2, startTime) {
16463
+ return go$readdir(path6, options, cb);
16464
+ function fs$readdirCallback(path7, options2, cb2, startTime) {
16465
16465
  return function(err, files) {
16466
16466
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16467
16467
  enqueue([
16468
16468
  go$readdir,
16469
- [path8, options2, cb2],
16469
+ [path7, options2, cb2],
16470
16470
  err,
16471
16471
  startTime || Date.now(),
16472
16472
  Date.now()
@@ -16481,21 +16481,21 @@ GFS4: `);
16481
16481
  }
16482
16482
  }
16483
16483
  if (process.version.substr(0, 4) === "v0.8") {
16484
- var legStreams = legacy(fs6);
16484
+ var legStreams = legacy(fs5);
16485
16485
  ReadStream = legStreams.ReadStream;
16486
16486
  WriteStream = legStreams.WriteStream;
16487
16487
  }
16488
- var fs$ReadStream = fs6.ReadStream;
16488
+ var fs$ReadStream = fs5.ReadStream;
16489
16489
  if (fs$ReadStream) {
16490
16490
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
16491
16491
  ReadStream.prototype.open = ReadStream$open;
16492
16492
  }
16493
- var fs$WriteStream = fs6.WriteStream;
16493
+ var fs$WriteStream = fs5.WriteStream;
16494
16494
  if (fs$WriteStream) {
16495
16495
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
16496
16496
  WriteStream.prototype.open = WriteStream$open;
16497
16497
  }
16498
- Object.defineProperty(fs6, "ReadStream", {
16498
+ Object.defineProperty(fs5, "ReadStream", {
16499
16499
  get: function() {
16500
16500
  return ReadStream;
16501
16501
  },
@@ -16505,7 +16505,7 @@ GFS4: `);
16505
16505
  enumerable: true,
16506
16506
  configurable: true
16507
16507
  });
16508
- Object.defineProperty(fs6, "WriteStream", {
16508
+ Object.defineProperty(fs5, "WriteStream", {
16509
16509
  get: function() {
16510
16510
  return WriteStream;
16511
16511
  },
@@ -16516,7 +16516,7 @@ GFS4: `);
16516
16516
  configurable: true
16517
16517
  });
16518
16518
  var FileReadStream = ReadStream;
16519
- Object.defineProperty(fs6, "FileReadStream", {
16519
+ Object.defineProperty(fs5, "FileReadStream", {
16520
16520
  get: function() {
16521
16521
  return FileReadStream;
16522
16522
  },
@@ -16527,7 +16527,7 @@ GFS4: `);
16527
16527
  configurable: true
16528
16528
  });
16529
16529
  var FileWriteStream = WriteStream;
16530
- Object.defineProperty(fs6, "FileWriteStream", {
16530
+ Object.defineProperty(fs5, "FileWriteStream", {
16531
16531
  get: function() {
16532
16532
  return FileWriteStream;
16533
16533
  },
@@ -16537,7 +16537,7 @@ GFS4: `);
16537
16537
  enumerable: true,
16538
16538
  configurable: true
16539
16539
  });
16540
- function ReadStream(path7, options) {
16540
+ function ReadStream(path6, options) {
16541
16541
  if (this instanceof ReadStream)
16542
16542
  return fs$ReadStream.apply(this, arguments), this;
16543
16543
  else
@@ -16557,7 +16557,7 @@ GFS4: `);
16557
16557
  }
16558
16558
  });
16559
16559
  }
16560
- function WriteStream(path7, options) {
16560
+ function WriteStream(path6, options) {
16561
16561
  if (this instanceof WriteStream)
16562
16562
  return fs$WriteStream.apply(this, arguments), this;
16563
16563
  else
@@ -16575,22 +16575,22 @@ GFS4: `);
16575
16575
  }
16576
16576
  });
16577
16577
  }
16578
- function createReadStream(path7, options) {
16579
- return new fs6.ReadStream(path7, options);
16578
+ function createReadStream(path6, options) {
16579
+ return new fs5.ReadStream(path6, options);
16580
16580
  }
16581
- function createWriteStream(path7, options) {
16582
- return new fs6.WriteStream(path7, options);
16581
+ function createWriteStream(path6, options) {
16582
+ return new fs5.WriteStream(path6, options);
16583
16583
  }
16584
- var fs$open = fs6.open;
16585
- fs6.open = open;
16586
- function open(path7, flags, mode, cb) {
16584
+ var fs$open = fs5.open;
16585
+ fs5.open = open;
16586
+ function open(path6, flags, mode, cb) {
16587
16587
  if (typeof mode === "function")
16588
16588
  cb = mode, mode = null;
16589
- return go$open(path7, flags, mode, cb);
16590
- function go$open(path8, flags2, mode2, cb2, startTime) {
16591
- return fs$open(path8, flags2, mode2, function(err, fd) {
16589
+ return go$open(path6, flags, mode, cb);
16590
+ function go$open(path7, flags2, mode2, cb2, startTime) {
16591
+ return fs$open(path7, flags2, mode2, function(err, fd) {
16592
16592
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16593
- enqueue([go$open, [path8, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
16593
+ enqueue([go$open, [path7, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
16594
16594
  else {
16595
16595
  if (typeof cb2 === "function")
16596
16596
  cb2.apply(this, arguments);
@@ -16598,20 +16598,20 @@ GFS4: `);
16598
16598
  });
16599
16599
  }
16600
16600
  }
16601
- return fs6;
16601
+ return fs5;
16602
16602
  }
16603
16603
  function enqueue(elem) {
16604
16604
  debug("ENQUEUE", elem[0].name, elem[1]);
16605
- fs5[gracefulQueue].push(elem);
16605
+ fs4[gracefulQueue].push(elem);
16606
16606
  retry();
16607
16607
  }
16608
16608
  var retryTimer;
16609
16609
  function resetQueue() {
16610
16610
  var now = Date.now();
16611
- for (var i = 0;i < fs5[gracefulQueue].length; ++i) {
16612
- if (fs5[gracefulQueue][i].length > 2) {
16613
- fs5[gracefulQueue][i][3] = now;
16614
- fs5[gracefulQueue][i][4] = now;
16611
+ for (var i = 0;i < fs4[gracefulQueue].length; ++i) {
16612
+ if (fs4[gracefulQueue][i].length > 2) {
16613
+ fs4[gracefulQueue][i][3] = now;
16614
+ fs4[gracefulQueue][i][4] = now;
16615
16615
  }
16616
16616
  }
16617
16617
  retry();
@@ -16619,9 +16619,9 @@ GFS4: `);
16619
16619
  function retry() {
16620
16620
  clearTimeout(retryTimer);
16621
16621
  retryTimer = undefined;
16622
- if (fs5[gracefulQueue].length === 0)
16622
+ if (fs4[gracefulQueue].length === 0)
16623
16623
  return;
16624
- var elem = fs5[gracefulQueue].shift();
16624
+ var elem = fs4[gracefulQueue].shift();
16625
16625
  var fn = elem[0];
16626
16626
  var args = elem[1];
16627
16627
  var err = elem[2];
@@ -16643,7 +16643,7 @@ GFS4: `);
16643
16643
  debug("RETRY", fn.name, args);
16644
16644
  fn.apply(null, args.concat([startTime]));
16645
16645
  } else {
16646
- fs5[gracefulQueue].push(elem);
16646
+ fs4[gracefulQueue].push(elem);
16647
16647
  }
16648
16648
  }
16649
16649
  if (retryTimer === undefined) {
@@ -16768,12 +16768,12 @@ var require_retry_operation = __commonJS((exports, module) => {
16768
16768
  var mainError = null;
16769
16769
  var mainErrorCount = 0;
16770
16770
  for (var i = 0;i < this._errors.length; i++) {
16771
- var error93 = this._errors[i];
16772
- var message = error93.message;
16771
+ var error49 = this._errors[i];
16772
+ var message = error49.message;
16773
16773
  var count = (counts[message] || 0) + 1;
16774
16774
  counts[message] = count;
16775
16775
  if (count >= mainErrorCount) {
16776
- mainError = error93;
16776
+ mainError = error49;
16777
16777
  mainErrorCount = count;
16778
16778
  }
16779
16779
  }
@@ -16893,7 +16893,7 @@ var require_signal_exit = __commonJS((exports, module) => {
16893
16893
  return function() {};
16894
16894
  };
16895
16895
  } else {
16896
- assert3 = __require("assert");
16896
+ assert2 = __require("assert");
16897
16897
  signals = require_signals();
16898
16898
  isWin = /^win/i.test(process3.platform);
16899
16899
  EE = __require("events");
@@ -16915,7 +16915,7 @@ var require_signal_exit = __commonJS((exports, module) => {
16915
16915
  if (!processOk(global.process)) {
16916
16916
  return function() {};
16917
16917
  }
16918
- assert3.equal(typeof cb, "function", "a callback must be provided for exit handler");
16918
+ assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
16919
16919
  if (loaded === false) {
16920
16920
  load();
16921
16921
  }
@@ -16947,7 +16947,7 @@ var require_signal_exit = __commonJS((exports, module) => {
16947
16947
  emitter.count -= 1;
16948
16948
  };
16949
16949
  module.exports.unload = unload;
16950
- emit2 = function emit3(event, code, signal) {
16950
+ emit = function emit2(event, code, signal) {
16951
16951
  if (emitter.emitted[event]) {
16952
16952
  return;
16953
16953
  }
@@ -16963,8 +16963,8 @@ var require_signal_exit = __commonJS((exports, module) => {
16963
16963
  var listeners = process3.listeners(sig);
16964
16964
  if (listeners.length === emitter.count) {
16965
16965
  unload();
16966
- emit2("exit", null, sig);
16967
- emit2("afterexit", null, sig);
16966
+ emit("exit", null, sig);
16967
+ emit("afterexit", null, sig);
16968
16968
  if (isWin && sig === "SIGHUP") {
16969
16969
  sig = "SIGINT";
16970
16970
  }
@@ -17000,8 +17000,8 @@ var require_signal_exit = __commonJS((exports, module) => {
17000
17000
  return;
17001
17001
  }
17002
17002
  process3.exitCode = code || 0;
17003
- emit2("exit", process3.exitCode, null);
17004
- emit2("afterexit", process3.exitCode, null);
17003
+ emit("exit", process3.exitCode, null);
17004
+ emit("afterexit", process3.exitCode, null);
17005
17005
  originalProcessReallyExit.call(process3, process3.exitCode);
17006
17006
  };
17007
17007
  originalProcessEmit = process3.emit;
@@ -17011,21 +17011,21 @@ var require_signal_exit = __commonJS((exports, module) => {
17011
17011
  process3.exitCode = arg;
17012
17012
  }
17013
17013
  var ret = originalProcessEmit.apply(this, arguments);
17014
- emit2("exit", process3.exitCode, null);
17015
- emit2("afterexit", process3.exitCode, null);
17014
+ emit("exit", process3.exitCode, null);
17015
+ emit("afterexit", process3.exitCode, null);
17016
17016
  return ret;
17017
17017
  } else {
17018
17018
  return originalProcessEmit.apply(this, arguments);
17019
17019
  }
17020
17020
  };
17021
17021
  }
17022
- var assert3;
17022
+ var assert2;
17023
17023
  var signals;
17024
17024
  var isWin;
17025
17025
  var EE;
17026
17026
  var emitter;
17027
17027
  var unload;
17028
- var emit2;
17028
+ var emit;
17029
17029
  var sigListeners;
17030
17030
  var loaded;
17031
17031
  var load;
@@ -17038,10 +17038,10 @@ var require_signal_exit = __commonJS((exports, module) => {
17038
17038
  // node_modules/proper-lockfile/lib/mtime-precision.js
17039
17039
  var require_mtime_precision = __commonJS((exports, module) => {
17040
17040
  var cacheSymbol = Symbol();
17041
- function probe(file3, fs5, callback) {
17042
- const cachedPrecision = fs5[cacheSymbol];
17041
+ function probe(file2, fs4, callback) {
17042
+ const cachedPrecision = fs4[cacheSymbol];
17043
17043
  if (cachedPrecision) {
17044
- return fs5.stat(file3, (err, stat) => {
17044
+ return fs4.stat(file2, (err, stat) => {
17045
17045
  if (err) {
17046
17046
  return callback(err);
17047
17047
  }
@@ -17049,16 +17049,16 @@ var require_mtime_precision = __commonJS((exports, module) => {
17049
17049
  });
17050
17050
  }
17051
17051
  const mtime = new Date(Math.ceil(Date.now() / 1000) * 1000 + 5);
17052
- fs5.utimes(file3, mtime, mtime, (err) => {
17052
+ fs4.utimes(file2, mtime, mtime, (err) => {
17053
17053
  if (err) {
17054
17054
  return callback(err);
17055
17055
  }
17056
- fs5.stat(file3, (err2, stat) => {
17056
+ fs4.stat(file2, (err2, stat) => {
17057
17057
  if (err2) {
17058
17058
  return callback(err2);
17059
17059
  }
17060
17060
  const precision = stat.mtime.getTime() % 1000 === 0 ? "s" : "ms";
17061
- Object.defineProperty(fs5, cacheSymbol, { value: precision });
17061
+ Object.defineProperty(fs4, cacheSymbol, { value: precision });
17062
17062
  callback(null, stat.mtime, precision);
17063
17063
  });
17064
17064
  });
@@ -17076,23 +17076,23 @@ var require_mtime_precision = __commonJS((exports, module) => {
17076
17076
 
17077
17077
  // node_modules/proper-lockfile/lib/lockfile.js
17078
17078
  var require_lockfile = __commonJS((exports, module) => {
17079
- var path7 = __require("path");
17080
- var fs5 = require_graceful_fs();
17079
+ var path6 = __require("path");
17080
+ var fs4 = require_graceful_fs();
17081
17081
  var retry = require_retry();
17082
17082
  var onExit = require_signal_exit();
17083
17083
  var mtimePrecision = require_mtime_precision();
17084
17084
  var locks = {};
17085
- function getLockFile(file3, options) {
17086
- return options.lockfilePath || `${file3}.lock`;
17085
+ function getLockFile(file2, options) {
17086
+ return options.lockfilePath || `${file2}.lock`;
17087
17087
  }
17088
- function resolveCanonicalPath(file3, options, callback) {
17088
+ function resolveCanonicalPath(file2, options, callback) {
17089
17089
  if (!options.realpath) {
17090
- return callback(null, path7.resolve(file3));
17090
+ return callback(null, path6.resolve(file2));
17091
17091
  }
17092
- options.fs.realpath(file3, callback);
17092
+ options.fs.realpath(file2, callback);
17093
17093
  }
17094
- function acquireLock(file3, options, callback) {
17095
- const lockfilePath = getLockFile(file3, options);
17094
+ function acquireLock(file2, options, callback) {
17095
+ const lockfilePath = getLockFile(file2, options);
17096
17096
  options.fs.mkdir(lockfilePath, (err) => {
17097
17097
  if (!err) {
17098
17098
  return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
@@ -17107,23 +17107,23 @@ var require_lockfile = __commonJS((exports, module) => {
17107
17107
  return callback(err);
17108
17108
  }
17109
17109
  if (options.stale <= 0) {
17110
- return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file3 }));
17110
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
17111
17111
  }
17112
17112
  options.fs.stat(lockfilePath, (err2, stat) => {
17113
17113
  if (err2) {
17114
17114
  if (err2.code === "ENOENT") {
17115
- return acquireLock(file3, { ...options, stale: 0 }, callback);
17115
+ return acquireLock(file2, { ...options, stale: 0 }, callback);
17116
17116
  }
17117
17117
  return callback(err2);
17118
17118
  }
17119
17119
  if (!isLockStale(stat, options)) {
17120
- return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file3 }));
17120
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
17121
17121
  }
17122
- removeLock(file3, options, (err3) => {
17122
+ removeLock(file2, options, (err3) => {
17123
17123
  if (err3) {
17124
17124
  return callback(err3);
17125
17125
  }
17126
- acquireLock(file3, { ...options, stale: 0 }, callback);
17126
+ acquireLock(file2, { ...options, stale: 0 }, callback);
17127
17127
  });
17128
17128
  });
17129
17129
  });
@@ -17131,16 +17131,16 @@ var require_lockfile = __commonJS((exports, module) => {
17131
17131
  function isLockStale(stat, options) {
17132
17132
  return stat.mtime.getTime() < Date.now() - options.stale;
17133
17133
  }
17134
- function removeLock(file3, options, callback) {
17135
- options.fs.rmdir(getLockFile(file3, options), (err) => {
17134
+ function removeLock(file2, options, callback) {
17135
+ options.fs.rmdir(getLockFile(file2, options), (err) => {
17136
17136
  if (err && err.code !== "ENOENT") {
17137
17137
  return callback(err);
17138
17138
  }
17139
17139
  callback();
17140
17140
  });
17141
17141
  }
17142
- function updateLock(file3, options) {
17143
- const lock2 = locks[file3];
17142
+ function updateLock(file2, options) {
17143
+ const lock2 = locks[file2];
17144
17144
  if (lock2.updateTimeout) {
17145
17145
  return;
17146
17146
  }
@@ -17151,14 +17151,14 @@ var require_lockfile = __commonJS((exports, module) => {
17151
17151
  const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
17152
17152
  if (err) {
17153
17153
  if (err.code === "ENOENT" || isOverThreshold) {
17154
- return setLockAsCompromised(file3, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
17154
+ return setLockAsCompromised(file2, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
17155
17155
  }
17156
17156
  lock2.updateDelay = 1000;
17157
- return updateLock(file3, options);
17157
+ return updateLock(file2, options);
17158
17158
  }
17159
17159
  const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
17160
17160
  if (!isMtimeOurs) {
17161
- return setLockAsCompromised(file3, lock2, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
17161
+ return setLockAsCompromised(file2, lock2, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
17162
17162
  }
17163
17163
  const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
17164
17164
  options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
@@ -17168,15 +17168,15 @@ var require_lockfile = __commonJS((exports, module) => {
17168
17168
  }
17169
17169
  if (err2) {
17170
17170
  if (err2.code === "ENOENT" || isOverThreshold2) {
17171
- return setLockAsCompromised(file3, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
17171
+ return setLockAsCompromised(file2, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
17172
17172
  }
17173
17173
  lock2.updateDelay = 1000;
17174
- return updateLock(file3, options);
17174
+ return updateLock(file2, options);
17175
17175
  }
17176
17176
  lock2.mtime = mtime;
17177
17177
  lock2.lastUpdate = Date.now();
17178
17178
  lock2.updateDelay = null;
17179
- updateLock(file3, options);
17179
+ updateLock(file2, options);
17180
17180
  });
17181
17181
  });
17182
17182
  }, lock2.updateDelay);
@@ -17184,23 +17184,23 @@ var require_lockfile = __commonJS((exports, module) => {
17184
17184
  lock2.updateTimeout.unref();
17185
17185
  }
17186
17186
  }
17187
- function setLockAsCompromised(file3, lock2, err) {
17187
+ function setLockAsCompromised(file2, lock2, err) {
17188
17188
  lock2.released = true;
17189
17189
  if (lock2.updateTimeout) {
17190
17190
  clearTimeout(lock2.updateTimeout);
17191
17191
  }
17192
- if (locks[file3] === lock2) {
17193
- delete locks[file3];
17192
+ if (locks[file2] === lock2) {
17193
+ delete locks[file2];
17194
17194
  }
17195
17195
  lock2.options.onCompromised(err);
17196
17196
  }
17197
- function lock(file3, options, callback) {
17197
+ function lock(file2, options, callback) {
17198
17198
  options = {
17199
17199
  stale: 1e4,
17200
17200
  update: null,
17201
17201
  realpath: true,
17202
17202
  retries: 0,
17203
- fs: fs5,
17203
+ fs: fs4,
17204
17204
  onCompromised: (err) => {
17205
17205
  throw err;
17206
17206
  },
@@ -17211,70 +17211,70 @@ var require_lockfile = __commonJS((exports, module) => {
17211
17211
  options.stale = Math.max(options.stale || 0, 2000);
17212
17212
  options.update = options.update == null ? options.stale / 2 : options.update || 0;
17213
17213
  options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);
17214
- resolveCanonicalPath(file3, options, (err, file4) => {
17214
+ resolveCanonicalPath(file2, options, (err, file3) => {
17215
17215
  if (err) {
17216
17216
  return callback(err);
17217
17217
  }
17218
17218
  const operation = retry.operation(options.retries);
17219
17219
  operation.attempt(() => {
17220
- acquireLock(file4, options, (err2, mtime, mtimePrecision2) => {
17220
+ acquireLock(file3, options, (err2, mtime, mtimePrecision2) => {
17221
17221
  if (operation.retry(err2)) {
17222
17222
  return;
17223
17223
  }
17224
17224
  if (err2) {
17225
17225
  return callback(operation.mainError());
17226
17226
  }
17227
- const lock2 = locks[file4] = {
17228
- lockfilePath: getLockFile(file4, options),
17227
+ const lock2 = locks[file3] = {
17228
+ lockfilePath: getLockFile(file3, options),
17229
17229
  mtime,
17230
17230
  mtimePrecision: mtimePrecision2,
17231
17231
  options,
17232
17232
  lastUpdate: Date.now()
17233
17233
  };
17234
- updateLock(file4, options);
17234
+ updateLock(file3, options);
17235
17235
  callback(null, (releasedCallback) => {
17236
17236
  if (lock2.released) {
17237
17237
  return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
17238
17238
  }
17239
- unlock(file4, { ...options, realpath: false }, releasedCallback);
17239
+ unlock(file3, { ...options, realpath: false }, releasedCallback);
17240
17240
  });
17241
17241
  });
17242
17242
  });
17243
17243
  });
17244
17244
  }
17245
- function unlock(file3, options, callback) {
17245
+ function unlock(file2, options, callback) {
17246
17246
  options = {
17247
- fs: fs5,
17247
+ fs: fs4,
17248
17248
  realpath: true,
17249
17249
  ...options
17250
17250
  };
17251
- resolveCanonicalPath(file3, options, (err, file4) => {
17251
+ resolveCanonicalPath(file2, options, (err, file3) => {
17252
17252
  if (err) {
17253
17253
  return callback(err);
17254
17254
  }
17255
- const lock2 = locks[file4];
17255
+ const lock2 = locks[file3];
17256
17256
  if (!lock2) {
17257
17257
  return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
17258
17258
  }
17259
17259
  lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
17260
17260
  lock2.released = true;
17261
- delete locks[file4];
17262
- removeLock(file4, options, callback);
17261
+ delete locks[file3];
17262
+ removeLock(file3, options, callback);
17263
17263
  });
17264
17264
  }
17265
- function check3(file3, options, callback) {
17265
+ function check2(file2, options, callback) {
17266
17266
  options = {
17267
17267
  stale: 1e4,
17268
17268
  realpath: true,
17269
- fs: fs5,
17269
+ fs: fs4,
17270
17270
  ...options
17271
17271
  };
17272
17272
  options.stale = Math.max(options.stale || 0, 2000);
17273
- resolveCanonicalPath(file3, options, (err, file4) => {
17273
+ resolveCanonicalPath(file2, options, (err, file3) => {
17274
17274
  if (err) {
17275
17275
  return callback(err);
17276
17276
  }
17277
- options.fs.stat(getLockFile(file4, options), (err2, stat) => {
17277
+ options.fs.stat(getLockFile(file3, options), (err2, stat) => {
17278
17278
  if (err2) {
17279
17279
  return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
17280
17280
  }
@@ -17286,31 +17286,31 @@ var require_lockfile = __commonJS((exports, module) => {
17286
17286
  return locks;
17287
17287
  }
17288
17288
  onExit(() => {
17289
- for (const file3 in locks) {
17290
- const options = locks[file3].options;
17289
+ for (const file2 in locks) {
17290
+ const options = locks[file2].options;
17291
17291
  try {
17292
- options.fs.rmdirSync(getLockFile(file3, options));
17292
+ options.fs.rmdirSync(getLockFile(file2, options));
17293
17293
  } catch (e) {}
17294
17294
  }
17295
17295
  });
17296
17296
  exports.lock = lock;
17297
17297
  exports.unlock = unlock;
17298
- exports.check = check3;
17298
+ exports.check = check2;
17299
17299
  exports.getLocks = getLocks;
17300
17300
  });
17301
17301
 
17302
17302
  // node_modules/proper-lockfile/lib/adapter.js
17303
17303
  var require_adapter = __commonJS((exports, module) => {
17304
- var fs5 = require_graceful_fs();
17305
- function createSyncFs(fs6) {
17304
+ var fs4 = require_graceful_fs();
17305
+ function createSyncFs(fs5) {
17306
17306
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
17307
- const newFs = { ...fs6 };
17307
+ const newFs = { ...fs5 };
17308
17308
  methods.forEach((method) => {
17309
17309
  newFs[method] = (...args) => {
17310
17310
  const callback = args.pop();
17311
17311
  let ret;
17312
17312
  try {
17313
- ret = fs6[`${method}Sync`](...args);
17313
+ ret = fs5[`${method}Sync`](...args);
17314
17314
  } catch (err) {
17315
17315
  return callback(err);
17316
17316
  }
@@ -17348,7 +17348,7 @@ var require_adapter = __commonJS((exports, module) => {
17348
17348
  }
17349
17349
  function toSyncOptions(options) {
17350
17350
  options = { ...options };
17351
- options.fs = createSyncFs(options.fs || fs5);
17351
+ options.fs = createSyncFs(options.fs || fs4);
17352
17352
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
17353
17353
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
17354
17354
  }
@@ -17365,32 +17365,32 @@ var require_adapter = __commonJS((exports, module) => {
17365
17365
  var require_proper_lockfile = __commonJS((exports, module) => {
17366
17366
  var lockfile = require_lockfile();
17367
17367
  var { toPromise, toSync, toSyncOptions } = require_adapter();
17368
- async function lock(file3, options) {
17369
- const release = await toPromise(lockfile.lock)(file3, options);
17368
+ async function lock(file2, options) {
17369
+ const release = await toPromise(lockfile.lock)(file2, options);
17370
17370
  return toPromise(release);
17371
17371
  }
17372
- function lockSync(file3, options) {
17373
- const release = toSync(lockfile.lock)(file3, toSyncOptions(options));
17372
+ function lockSync(file2, options) {
17373
+ const release = toSync(lockfile.lock)(file2, toSyncOptions(options));
17374
17374
  return toSync(release);
17375
17375
  }
17376
- function unlock(file3, options) {
17377
- return toPromise(lockfile.unlock)(file3, options);
17376
+ function unlock(file2, options) {
17377
+ return toPromise(lockfile.unlock)(file2, options);
17378
17378
  }
17379
- function unlockSync(file3, options) {
17380
- return toSync(lockfile.unlock)(file3, toSyncOptions(options));
17379
+ function unlockSync(file2, options) {
17380
+ return toSync(lockfile.unlock)(file2, toSyncOptions(options));
17381
17381
  }
17382
- function check3(file3, options) {
17383
- return toPromise(lockfile.check)(file3, options);
17382
+ function check2(file2, options) {
17383
+ return toPromise(lockfile.check)(file2, options);
17384
17384
  }
17385
- function checkSync(file3, options) {
17386
- return toSync(lockfile.check)(file3, toSyncOptions(options));
17385
+ function checkSync(file2, options) {
17386
+ return toSync(lockfile.check)(file2, toSyncOptions(options));
17387
17387
  }
17388
17388
  module.exports = lock;
17389
17389
  module.exports.lock = lock;
17390
17390
  module.exports.unlock = unlock;
17391
17391
  module.exports.lockSync = lockSync;
17392
17392
  module.exports.unlockSync = unlockSync;
17393
- module.exports.check = check3;
17393
+ module.exports.check = check2;
17394
17394
  module.exports.checkSync = checkSync;
17395
17395
  });
17396
17396
 
@@ -17408,15 +17408,15 @@ __export(exports_config_doctor, {
17408
17408
  applySafeAutoFixes: () => applySafeAutoFixes
17409
17409
  });
17410
17410
  import * as crypto3 from "crypto";
17411
- import * as fs7 from "fs";
17411
+ import * as fs8 from "fs";
17412
17412
  import * as os4 from "os";
17413
- import * as path16 from "path";
17413
+ import * as path17 from "path";
17414
17414
  function getUserConfigDir3() {
17415
- return process.env.XDG_CONFIG_HOME || path16.join(os4.homedir(), ".config");
17415
+ return process.env.XDG_CONFIG_HOME || path17.join(os4.homedir(), ".config");
17416
17416
  }
17417
17417
  function getConfigPaths(directory) {
17418
- const userConfigPath = path16.join(getUserConfigDir3(), "opencode", "opencode-swarm.json");
17419
- const projectConfigPath = path16.join(directory, ".opencode", "opencode-swarm.json");
17418
+ const userConfigPath = path17.join(getUserConfigDir3(), "opencode", "opencode-swarm.json");
17419
+ const projectConfigPath = path17.join(directory, ".opencode", "opencode-swarm.json");
17420
17420
  return { userConfigPath, projectConfigPath };
17421
17421
  }
17422
17422
  function computeHash(content) {
@@ -17441,9 +17441,9 @@ function isValidConfigPath(configPath, directory) {
17441
17441
  const normalizedUser = userConfigPath.replace(/\\/g, "/");
17442
17442
  const normalizedProject = projectConfigPath.replace(/\\/g, "/");
17443
17443
  try {
17444
- const resolvedConfig = path16.resolve(configPath);
17445
- const resolvedUser = path16.resolve(normalizedUser);
17446
- const resolvedProject = path16.resolve(normalizedProject);
17444
+ const resolvedConfig = path17.resolve(configPath);
17445
+ const resolvedUser = path17.resolve(normalizedUser);
17446
+ const resolvedProject = path17.resolve(normalizedProject);
17447
17447
  return resolvedConfig === resolvedUser || resolvedConfig === resolvedProject;
17448
17448
  } catch {
17449
17449
  return false;
@@ -17453,19 +17453,19 @@ function createConfigBackup(directory) {
17453
17453
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
17454
17454
  let configPath = projectConfigPath;
17455
17455
  let content = null;
17456
- if (fs7.existsSync(projectConfigPath)) {
17456
+ if (fs8.existsSync(projectConfigPath)) {
17457
17457
  try {
17458
- content = fs7.readFileSync(projectConfigPath, "utf-8");
17458
+ content = fs8.readFileSync(projectConfigPath, "utf-8");
17459
17459
  } catch (error93) {
17460
17460
  log("[ConfigDoctor] project config read failed", {
17461
17461
  error: error93 instanceof Error ? error93.message : String(error93)
17462
17462
  });
17463
17463
  }
17464
17464
  }
17465
- if (content === null && fs7.existsSync(userConfigPath)) {
17465
+ if (content === null && fs8.existsSync(userConfigPath)) {
17466
17466
  configPath = userConfigPath;
17467
17467
  try {
17468
- content = fs7.readFileSync(userConfigPath, "utf-8");
17468
+ content = fs8.readFileSync(userConfigPath, "utf-8");
17469
17469
  } catch (error93) {
17470
17470
  log("[ConfigDoctor] user config read failed", {
17471
17471
  error: error93 instanceof Error ? error93.message : String(error93)
@@ -17483,12 +17483,12 @@ function createConfigBackup(directory) {
17483
17483
  };
17484
17484
  }
17485
17485
  function writeBackupArtifact(directory, backup) {
17486
- const swarmDir = path16.join(directory, ".swarm");
17487
- if (!fs7.existsSync(swarmDir)) {
17488
- fs7.mkdirSync(swarmDir, { recursive: true });
17486
+ const swarmDir = path17.join(directory, ".swarm");
17487
+ if (!fs8.existsSync(swarmDir)) {
17488
+ fs8.mkdirSync(swarmDir, { recursive: true });
17489
17489
  }
17490
17490
  const backupFilename = `config-backup-${backup.createdAt}.json`;
17491
- const backupPath = path16.join(swarmDir, backupFilename);
17491
+ const backupPath = path17.join(swarmDir, backupFilename);
17492
17492
  const artifact = {
17493
17493
  createdAt: backup.createdAt,
17494
17494
  configPath: backup.configPath,
@@ -17496,15 +17496,15 @@ function writeBackupArtifact(directory, backup) {
17496
17496
  content: backup.content,
17497
17497
  preview: backup.content.substring(0, 500) + (backup.content.length > 500 ? "..." : "")
17498
17498
  };
17499
- fs7.writeFileSync(backupPath, JSON.stringify(artifact, null, 2), "utf-8");
17499
+ fs8.writeFileSync(backupPath, JSON.stringify(artifact, null, 2), "utf-8");
17500
17500
  return backupPath;
17501
17501
  }
17502
17502
  function restoreFromBackup(backupPath, directory) {
17503
- if (!fs7.existsSync(backupPath)) {
17503
+ if (!fs8.existsSync(backupPath)) {
17504
17504
  return null;
17505
17505
  }
17506
17506
  try {
17507
- const artifact = JSON.parse(fs7.readFileSync(backupPath, "utf-8"));
17507
+ const artifact = JSON.parse(fs8.readFileSync(backupPath, "utf-8"));
17508
17508
  if (!artifact.content || !artifact.configPath || !artifact.contentHash) {
17509
17509
  return null;
17510
17510
  }
@@ -17518,11 +17518,11 @@ function restoreFromBackup(backupPath, directory) {
17518
17518
  return null;
17519
17519
  }
17520
17520
  const targetPath = artifact.configPath;
17521
- const targetDir = path16.dirname(targetPath);
17522
- if (!fs7.existsSync(targetDir)) {
17523
- fs7.mkdirSync(targetDir, { recursive: true });
17521
+ const targetDir = path17.dirname(targetPath);
17522
+ if (!fs8.existsSync(targetDir)) {
17523
+ fs8.mkdirSync(targetDir, { recursive: true });
17524
17524
  }
17525
- fs7.writeFileSync(targetPath, artifact.content, "utf-8");
17525
+ fs8.writeFileSync(targetPath, artifact.content, "utf-8");
17526
17526
  return targetPath;
17527
17527
  } catch {
17528
17528
  return null;
@@ -17532,12 +17532,12 @@ function readConfigFromFile(directory) {
17532
17532
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
17533
17533
  let configPath = projectConfigPath;
17534
17534
  let configContent = null;
17535
- if (fs7.existsSync(projectConfigPath)) {
17535
+ if (fs8.existsSync(projectConfigPath)) {
17536
17536
  configPath = projectConfigPath;
17537
- configContent = fs7.readFileSync(projectConfigPath, "utf-8");
17538
- } else if (fs7.existsSync(userConfigPath)) {
17537
+ configContent = fs8.readFileSync(projectConfigPath, "utf-8");
17538
+ } else if (fs8.existsSync(userConfigPath)) {
17539
17539
  configPath = userConfigPath;
17540
- configContent = fs7.readFileSync(userConfigPath, "utf-8");
17540
+ configContent = fs8.readFileSync(userConfigPath, "utf-8");
17541
17541
  }
17542
17542
  if (configContent === null) {
17543
17543
  return null;
@@ -17549,9 +17549,9 @@ function readConfigFromFile(directory) {
17549
17549
  return null;
17550
17550
  }
17551
17551
  }
17552
- function validateConfigKey(path17, value, _config) {
17552
+ function validateConfigKey(path18, value, _config) {
17553
17553
  const findings = [];
17554
- switch (path17) {
17554
+ switch (path18) {
17555
17555
  case "agents": {
17556
17556
  if (value !== undefined) {
17557
17557
  findings.push({
@@ -17798,27 +17798,27 @@ function validateConfigKey(path17, value, _config) {
17798
17798
  }
17799
17799
  return findings;
17800
17800
  }
17801
- function walkConfigAndValidate(obj, path17, config3, findings) {
17801
+ function walkConfigAndValidate(obj, path18, config3, findings) {
17802
17802
  if (obj === null || obj === undefined) {
17803
17803
  return;
17804
17804
  }
17805
- if (path17 && typeof obj === "object" && !Array.isArray(obj)) {
17806
- const keyFindings = validateConfigKey(path17, obj, config3);
17805
+ if (path18 && typeof obj === "object" && !Array.isArray(obj)) {
17806
+ const keyFindings = validateConfigKey(path18, obj, config3);
17807
17807
  findings.push(...keyFindings);
17808
17808
  }
17809
17809
  if (typeof obj !== "object") {
17810
- const keyFindings = validateConfigKey(path17, obj, config3);
17810
+ const keyFindings = validateConfigKey(path18, obj, config3);
17811
17811
  findings.push(...keyFindings);
17812
17812
  return;
17813
17813
  }
17814
17814
  if (Array.isArray(obj)) {
17815
17815
  obj.forEach((item, index) => {
17816
- walkConfigAndValidate(item, `${path17}[${index}]`, config3, findings);
17816
+ walkConfigAndValidate(item, `${path18}[${index}]`, config3, findings);
17817
17817
  });
17818
17818
  return;
17819
17819
  }
17820
17820
  for (const [key, value] of Object.entries(obj)) {
17821
- const newPath = path17 ? `${path17}.${key}` : key;
17821
+ const newPath = path18 ? `${path18}.${key}` : key;
17822
17822
  walkConfigAndValidate(value, newPath, config3, findings);
17823
17823
  }
17824
17824
  }
@@ -17833,9 +17833,9 @@ function runConfigDoctor(config3, directory) {
17833
17833
  const hasAutoFixableIssues = findings.some((f) => f.autoFixable && f.proposedFix?.risk === "low");
17834
17834
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
17835
17835
  let configSource = "defaults";
17836
- if (fs7.existsSync(projectConfigPath)) {
17836
+ if (fs8.existsSync(projectConfigPath)) {
17837
17837
  configSource = projectConfigPath;
17838
- } else if (fs7.existsSync(userConfigPath)) {
17838
+ } else if (fs8.existsSync(userConfigPath)) {
17839
17839
  configSource = userConfigPath;
17840
17840
  }
17841
17841
  return {
@@ -17864,12 +17864,12 @@ function applySafeAutoFixes(directory, result) {
17864
17864
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
17865
17865
  let configPath = projectConfigPath;
17866
17866
  let configContent;
17867
- if (fs7.existsSync(projectConfigPath)) {
17867
+ if (fs8.existsSync(projectConfigPath)) {
17868
17868
  configPath = projectConfigPath;
17869
- configContent = fs7.readFileSync(projectConfigPath, "utf-8");
17870
- } else if (fs7.existsSync(userConfigPath)) {
17869
+ configContent = fs8.readFileSync(projectConfigPath, "utf-8");
17870
+ } else if (fs8.existsSync(userConfigPath)) {
17871
17871
  configPath = userConfigPath;
17872
- configContent = fs7.readFileSync(userConfigPath, "utf-8");
17872
+ configContent = fs8.readFileSync(userConfigPath, "utf-8");
17873
17873
  } else {
17874
17874
  return { appliedFixes, updatedConfigPath: null };
17875
17875
  }
@@ -17938,22 +17938,22 @@ function applySafeAutoFixes(directory, result) {
17938
17938
  }
17939
17939
  }
17940
17940
  if (appliedFixes.length > 0) {
17941
- const configDir = path16.dirname(configPath);
17942
- if (!fs7.existsSync(configDir)) {
17943
- fs7.mkdirSync(configDir, { recursive: true });
17941
+ const configDir = path17.dirname(configPath);
17942
+ if (!fs8.existsSync(configDir)) {
17943
+ fs8.mkdirSync(configDir, { recursive: true });
17944
17944
  }
17945
- fs7.writeFileSync(configPath, JSON.stringify(config3, null, 2), "utf-8");
17945
+ fs8.writeFileSync(configPath, JSON.stringify(config3, null, 2), "utf-8");
17946
17946
  updatedConfigPath = configPath;
17947
17947
  }
17948
17948
  return { appliedFixes, updatedConfigPath };
17949
17949
  }
17950
17950
  function writeDoctorArtifact(directory, result) {
17951
- const swarmDir = path16.join(directory, ".swarm");
17952
- if (!fs7.existsSync(swarmDir)) {
17953
- fs7.mkdirSync(swarmDir, { recursive: true });
17951
+ const swarmDir = path17.join(directory, ".swarm");
17952
+ if (!fs8.existsSync(swarmDir)) {
17953
+ fs8.mkdirSync(swarmDir, { recursive: true });
17954
17954
  }
17955
17955
  const artifactFilename = "config-doctor.json";
17956
- const artifactPath = path16.join(swarmDir, artifactFilename);
17956
+ const artifactPath = path17.join(swarmDir, artifactFilename);
17957
17957
  const guiOutput = {
17958
17958
  timestamp: result.timestamp,
17959
17959
  summary: result.summary,
@@ -17974,7 +17974,7 @@ function writeDoctorArtifact(directory, result) {
17974
17974
  } : null
17975
17975
  }))
17976
17976
  };
17977
- fs7.writeFileSync(artifactPath, JSON.stringify(guiOutput, null, 2), "utf-8");
17977
+ fs8.writeFileSync(artifactPath, JSON.stringify(guiOutput, null, 2), "utf-8");
17978
17978
  return artifactPath;
17979
17979
  }
17980
17980
  function shouldRunOnStartup(automationConfig) {
@@ -18314,9 +18314,9 @@ var init_evidence_summary_service = __esm(() => {
18314
18314
  });
18315
18315
 
18316
18316
  // src/cli/index.ts
18317
- import * as fs21 from "fs";
18317
+ import * as fs22 from "fs";
18318
18318
  import * as os6 from "os";
18319
- import * as path31 from "path";
18319
+ import * as path32 from "path";
18320
18320
 
18321
18321
  // src/commands/acknowledge-spec-drift.ts
18322
18322
  init_utils2();
@@ -19784,6 +19784,50 @@ var warnedAgents = new Set;
19784
19784
 
19785
19785
  // src/hooks/guardrails.ts
19786
19786
  init_manager();
19787
+
19788
+ // src/scope/scope-persistence.ts
19789
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
19790
+ import * as fs4 from "fs";
19791
+ import * as path6 from "path";
19792
+ var DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
19793
+ var LOCK_STALE_MS = 30 * 1000;
19794
+ var SCOPES_DIR = ".swarm/scopes";
19795
+ var MAX_PLAN_BYTES = 10 * 1024 * 1024;
19796
+ var MAX_SCOPE_BYTES = 2 * 1024 * 1024;
19797
+ var WINDOWS_RESERVED = new Set([
19798
+ "CON",
19799
+ "PRN",
19800
+ "AUX",
19801
+ "NUL",
19802
+ "COM1",
19803
+ "COM2",
19804
+ "COM3",
19805
+ "COM4",
19806
+ "COM5",
19807
+ "COM6",
19808
+ "COM7",
19809
+ "COM8",
19810
+ "COM9",
19811
+ "LPT1",
19812
+ "LPT2",
19813
+ "LPT3",
19814
+ "LPT4",
19815
+ "LPT5",
19816
+ "LPT6",
19817
+ "LPT7",
19818
+ "LPT8",
19819
+ "LPT9"
19820
+ ]);
19821
+ function getScopesDir(directory) {
19822
+ return path6.join(directory, SCOPES_DIR);
19823
+ }
19824
+ function clearAllScopes(directory) {
19825
+ try {
19826
+ fs4.rmSync(getScopesDir(directory), { recursive: true, force: true });
19827
+ } catch {}
19828
+ }
19829
+
19830
+ // src/hooks/guardrails.ts
19787
19831
  init_telemetry();
19788
19832
  init_utils();
19789
19833
 
@@ -20269,8 +20313,8 @@ init_zod();
20269
20313
 
20270
20314
  // src/tools/checkpoint.ts
20271
20315
  import * as child_process from "child_process";
20272
- import * as fs4 from "fs";
20273
- import * as path6 from "path";
20316
+ import * as fs5 from "fs";
20317
+ import * as path7 from "path";
20274
20318
 
20275
20319
  // node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
20276
20320
  var exports_external2 = {};
@@ -21001,10 +21045,10 @@ function mergeDefs2(...defs) {
21001
21045
  function cloneDef2(schema) {
21002
21046
  return mergeDefs2(schema._zod.def);
21003
21047
  }
21004
- function getElementAtPath2(obj, path6) {
21005
- if (!path6)
21048
+ function getElementAtPath2(obj, path7) {
21049
+ if (!path7)
21006
21050
  return obj;
21007
- return path6.reduce((acc, key) => acc?.[key], obj);
21051
+ return path7.reduce((acc, key) => acc?.[key], obj);
21008
21052
  }
21009
21053
  function promiseAllObject2(promisesObj) {
21010
21054
  const keys = Object.keys(promisesObj);
@@ -21363,11 +21407,11 @@ function aborted2(x, startIndex = 0) {
21363
21407
  }
21364
21408
  return false;
21365
21409
  }
21366
- function prefixIssues2(path6, issues) {
21410
+ function prefixIssues2(path7, issues) {
21367
21411
  return issues.map((iss) => {
21368
21412
  var _a2;
21369
21413
  (_a2 = iss).path ?? (_a2.path = []);
21370
- iss.path.unshift(path6);
21414
+ iss.path.unshift(path7);
21371
21415
  return iss;
21372
21416
  });
21373
21417
  }
@@ -21535,7 +21579,7 @@ function treeifyError2(error49, _mapper) {
21535
21579
  return issue3.message;
21536
21580
  };
21537
21581
  const result = { errors: [] };
21538
- const processError = (error50, path6 = []) => {
21582
+ const processError = (error50, path7 = []) => {
21539
21583
  var _a2, _b;
21540
21584
  for (const issue3 of error50.issues) {
21541
21585
  if (issue3.code === "invalid_union" && issue3.errors.length) {
@@ -21545,7 +21589,7 @@ function treeifyError2(error49, _mapper) {
21545
21589
  } else if (issue3.code === "invalid_element") {
21546
21590
  processError({ issues: issue3.issues }, issue3.path);
21547
21591
  } else {
21548
- const fullpath = [...path6, ...issue3.path];
21592
+ const fullpath = [...path7, ...issue3.path];
21549
21593
  if (fullpath.length === 0) {
21550
21594
  result.errors.push(mapper(issue3));
21551
21595
  continue;
@@ -21577,8 +21621,8 @@ function treeifyError2(error49, _mapper) {
21577
21621
  }
21578
21622
  function toDotPath2(_path) {
21579
21623
  const segs = [];
21580
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
21581
- for (const seg of path6) {
21624
+ const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
21625
+ for (const seg of path7) {
21582
21626
  if (typeof seg === "number")
21583
21627
  segs.push(`[${seg}]`);
21584
21628
  else if (typeof seg === "symbol")
@@ -32675,13 +32719,13 @@ function validateLabel(label) {
32675
32719
  return null;
32676
32720
  }
32677
32721
  function getCheckpointLogPath(directory) {
32678
- return path6.join(directory, CHECKPOINT_LOG_PATH);
32722
+ return path7.join(directory, CHECKPOINT_LOG_PATH);
32679
32723
  }
32680
32724
  function readCheckpointLog(directory) {
32681
32725
  const logPath = getCheckpointLogPath(directory);
32682
32726
  try {
32683
- if (fs4.existsSync(logPath)) {
32684
- const content = fs4.readFileSync(logPath, "utf-8");
32727
+ if (fs5.existsSync(logPath)) {
32728
+ const content = fs5.readFileSync(logPath, "utf-8");
32685
32729
  const parsed = JSON.parse(content);
32686
32730
  if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
32687
32731
  return { version: 1, checkpoints: [] };
@@ -32693,13 +32737,13 @@ function readCheckpointLog(directory) {
32693
32737
  }
32694
32738
  function writeCheckpointLog(log2, directory) {
32695
32739
  const logPath = getCheckpointLogPath(directory);
32696
- const dir = path6.dirname(logPath);
32697
- if (!fs4.existsSync(dir)) {
32698
- fs4.mkdirSync(dir, { recursive: true });
32740
+ const dir = path7.dirname(logPath);
32741
+ if (!fs5.existsSync(dir)) {
32742
+ fs5.mkdirSync(dir, { recursive: true });
32699
32743
  }
32700
32744
  const tempPath = `${logPath}.tmp`;
32701
- fs4.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
32702
- fs4.renameSync(tempPath, logPath);
32745
+ fs5.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
32746
+ fs5.renameSync(tempPath, logPath);
32703
32747
  }
32704
32748
  function gitExec(args) {
32705
32749
  const result = child_process.spawnSync("git", args, {
@@ -33033,8 +33077,8 @@ async function handleClarifyCommand(_directory, args) {
33033
33077
 
33034
33078
  // src/commands/close.ts
33035
33079
  import { execFileSync } from "child_process";
33036
- import { promises as fs6 } from "fs";
33037
- import path11 from "path";
33080
+ import { promises as fs7 } from "fs";
33081
+ import path12 from "path";
33038
33082
  init_manager2();
33039
33083
 
33040
33084
  // src/git/branch.ts
@@ -33084,33 +33128,33 @@ function hasUncommittedChanges(cwd) {
33084
33128
  }
33085
33129
 
33086
33130
  // src/hooks/knowledge-store.ts
33087
- var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
33131
+ var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
33088
33132
  import { existsSync as existsSync5 } from "fs";
33089
33133
  import { appendFile as appendFile2, mkdir, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
33090
33134
  import * as os2 from "os";
33091
- import * as path7 from "path";
33135
+ import * as path8 from "path";
33092
33136
  function resolveSwarmKnowledgePath(directory) {
33093
- return path7.join(directory, ".swarm", "knowledge.jsonl");
33137
+ return path8.join(directory, ".swarm", "knowledge.jsonl");
33094
33138
  }
33095
33139
  function resolveSwarmRejectedPath(directory) {
33096
- return path7.join(directory, ".swarm", "knowledge-rejected.jsonl");
33140
+ return path8.join(directory, ".swarm", "knowledge-rejected.jsonl");
33097
33141
  }
33098
33142
  function resolveHiveKnowledgePath() {
33099
33143
  const platform = process.platform;
33100
33144
  const home = os2.homedir();
33101
33145
  let dataDir;
33102
33146
  if (platform === "win32") {
33103
- dataDir = path7.join(process.env.LOCALAPPDATA || path7.join(home, "AppData", "Local"), "opencode-swarm", "Data");
33147
+ dataDir = path8.join(process.env.LOCALAPPDATA || path8.join(home, "AppData", "Local"), "opencode-swarm", "Data");
33104
33148
  } else if (platform === "darwin") {
33105
- dataDir = path7.join(home, "Library", "Application Support", "opencode-swarm");
33149
+ dataDir = path8.join(home, "Library", "Application Support", "opencode-swarm");
33106
33150
  } else {
33107
- dataDir = path7.join(process.env.XDG_DATA_HOME || path7.join(home, ".local", "share"), "opencode-swarm");
33151
+ dataDir = path8.join(process.env.XDG_DATA_HOME || path8.join(home, ".local", "share"), "opencode-swarm");
33108
33152
  }
33109
- return path7.join(dataDir, "shared-learnings.jsonl");
33153
+ return path8.join(dataDir, "shared-learnings.jsonl");
33110
33154
  }
33111
33155
  function resolveHiveRejectedPath() {
33112
33156
  const hivePath = resolveHiveKnowledgePath();
33113
- return path7.join(path7.dirname(hivePath), "shared-learnings-rejected.jsonl");
33157
+ return path8.join(path8.dirname(hivePath), "shared-learnings-rejected.jsonl");
33114
33158
  }
33115
33159
  async function readKnowledge(filePath) {
33116
33160
  if (!existsSync5(filePath))
@@ -33134,16 +33178,16 @@ async function readRejectedLessons(directory) {
33134
33178
  return readKnowledge(resolveSwarmRejectedPath(directory));
33135
33179
  }
33136
33180
  async function appendKnowledge(filePath, entry) {
33137
- await mkdir(path7.dirname(filePath), { recursive: true });
33181
+ await mkdir(path8.dirname(filePath), { recursive: true });
33138
33182
  await appendFile2(filePath, `${JSON.stringify(entry)}
33139
33183
  `, "utf-8");
33140
33184
  }
33141
33185
  async function rewriteKnowledge(filePath, entries) {
33142
- const dir = path7.dirname(filePath);
33186
+ const dir = path8.dirname(filePath);
33143
33187
  await mkdir(dir, { recursive: true });
33144
33188
  let release = null;
33145
33189
  try {
33146
- release = await import_proper_lockfile.default.lock(dir, {
33190
+ release = await import_proper_lockfile2.default.lock(dir, {
33147
33191
  retries: { retries: 3, minTimeout: 100 }
33148
33192
  });
33149
33193
  const content = entries.map((e) => JSON.stringify(e)).join(`
@@ -33245,9 +33289,9 @@ function inferTags(lesson) {
33245
33289
  }
33246
33290
 
33247
33291
  // src/hooks/knowledge-validator.ts
33248
- var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
33292
+ var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
33249
33293
  import { appendFile as appendFile3, mkdir as mkdir2, writeFile as writeFile3 } from "fs/promises";
33250
- import * as path8 from "path";
33294
+ import * as path9 from "path";
33251
33295
  var DANGEROUS_COMMAND_PATTERNS = [
33252
33296
  /\brm\s+-rf\b/,
33253
33297
  /\bsudo\s+rm\b/,
@@ -33501,14 +33545,14 @@ async function quarantineEntry(directory, entryId, reason, reportedBy) {
33501
33545
  return;
33502
33546
  }
33503
33547
  const sanitizedReason = reason.slice(0, 500).replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\x0d]/g, "");
33504
- const knowledgePath = path8.join(directory, ".swarm", "knowledge.jsonl");
33505
- const quarantinePath = path8.join(directory, ".swarm", "knowledge-quarantined.jsonl");
33506
- const rejectedPath = path8.join(directory, ".swarm", "knowledge-rejected.jsonl");
33507
- const swarmDir = path8.join(directory, ".swarm");
33548
+ const knowledgePath = path9.join(directory, ".swarm", "knowledge.jsonl");
33549
+ const quarantinePath = path9.join(directory, ".swarm", "knowledge-quarantined.jsonl");
33550
+ const rejectedPath = path9.join(directory, ".swarm", "knowledge-rejected.jsonl");
33551
+ const swarmDir = path9.join(directory, ".swarm");
33508
33552
  await mkdir2(swarmDir, { recursive: true });
33509
33553
  let release;
33510
33554
  try {
33511
- release = await import_proper_lockfile2.default.lock(swarmDir, {
33555
+ release = await import_proper_lockfile3.default.lock(swarmDir, {
33512
33556
  retries: { retries: 3, minTimeout: 100 }
33513
33557
  });
33514
33558
  const entries = await readKnowledge(knowledgePath);
@@ -33561,14 +33605,14 @@ async function restoreEntry(directory, entryId) {
33561
33605
  console.warn("[knowledge-validator] restoreEntry: invalid entryId rejected");
33562
33606
  return;
33563
33607
  }
33564
- const knowledgePath = path8.join(directory, ".swarm", "knowledge.jsonl");
33565
- const quarantinePath = path8.join(directory, ".swarm", "knowledge-quarantined.jsonl");
33566
- const rejectedPath = path8.join(directory, ".swarm", "knowledge-rejected.jsonl");
33567
- const swarmDir = path8.join(directory, ".swarm");
33608
+ const knowledgePath = path9.join(directory, ".swarm", "knowledge.jsonl");
33609
+ const quarantinePath = path9.join(directory, ".swarm", "knowledge-quarantined.jsonl");
33610
+ const rejectedPath = path9.join(directory, ".swarm", "knowledge-rejected.jsonl");
33611
+ const swarmDir = path9.join(directory, ".swarm");
33568
33612
  await mkdir2(swarmDir, { recursive: true });
33569
33613
  let release;
33570
33614
  try {
33571
- release = await import_proper_lockfile2.default.lock(swarmDir, {
33615
+ release = await import_proper_lockfile3.default.lock(swarmDir, {
33572
33616
  retries: { retries: 3, minTimeout: 100 }
33573
33617
  });
33574
33618
  const quarantinedEntries = await readKnowledge(quarantinePath);
@@ -33722,18 +33766,18 @@ init_utils2();
33722
33766
  init_plan_schema();
33723
33767
  init_ledger();
33724
33768
  init_manager();
33725
- import * as fs5 from "fs";
33726
- import * as path9 from "path";
33769
+ import * as fs6 from "fs";
33770
+ import * as path10 from "path";
33727
33771
  async function writeCheckpoint(directory) {
33728
33772
  try {
33729
33773
  const plan = await loadPlan(directory);
33730
33774
  if (!plan)
33731
33775
  return;
33732
- const jsonPath = path9.join(directory, "SWARM_PLAN.json");
33733
- const mdPath = path9.join(directory, "SWARM_PLAN.md");
33734
- fs5.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
33776
+ const jsonPath = path10.join(directory, "SWARM_PLAN.json");
33777
+ const mdPath = path10.join(directory, "SWARM_PLAN.md");
33778
+ fs6.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
33735
33779
  const md = derivePlanMarkdown(plan);
33736
- fs5.writeFileSync(mdPath, md, "utf8");
33780
+ fs6.writeFileSync(mdPath, md, "utf8");
33737
33781
  } catch (error93) {
33738
33782
  console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
33739
33783
  }
@@ -33741,8 +33785,8 @@ async function writeCheckpoint(directory) {
33741
33785
 
33742
33786
  // src/session/snapshot-writer.ts
33743
33787
  init_utils2();
33744
- import { mkdirSync as mkdirSync4, renameSync as renameSync4 } from "fs";
33745
- import * as path10 from "path";
33788
+ import { mkdirSync as mkdirSync5, renameSync as renameSync5 } from "fs";
33789
+ import * as path11 from "path";
33746
33790
  init_utils();
33747
33791
  var _writeInFlight = Promise.resolve();
33748
33792
  function serializeAgentSession(s) {
@@ -33833,11 +33877,11 @@ async function writeSnapshot(directory, state) {
33833
33877
  }
33834
33878
  const content = JSON.stringify(snapshot, null, 2);
33835
33879
  const resolvedPath = validateSwarmPath(directory, "session/state.json");
33836
- const dir = path10.dirname(resolvedPath);
33837
- mkdirSync4(dir, { recursive: true });
33880
+ const dir = path11.dirname(resolvedPath);
33881
+ mkdirSync5(dir, { recursive: true });
33838
33882
  const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
33839
33883
  await Bun.write(tempPath, content);
33840
- renameSync4(tempPath, resolvedPath);
33884
+ renameSync5(tempPath, resolvedPath);
33841
33885
  } catch (error93) {
33842
33886
  log("[snapshot-writer] write failed", {
33843
33887
  error: error93 instanceof Error ? error93.message : String(error93)
@@ -34225,21 +34269,21 @@ var ACTIVE_STATE_TO_CLEAN = [
34225
34269
  ];
34226
34270
  async function handleCloseCommand(directory, args) {
34227
34271
  const planPath = validateSwarmPath(directory, "plan.json");
34228
- const swarmDir = path11.join(directory, ".swarm");
34272
+ const swarmDir = path12.join(directory, ".swarm");
34229
34273
  let planExists = false;
34230
34274
  let planData = {
34231
- title: path11.basename(directory) || "Ad-hoc session",
34275
+ title: path12.basename(directory) || "Ad-hoc session",
34232
34276
  phases: []
34233
34277
  };
34234
34278
  try {
34235
- const content = await fs6.readFile(planPath, "utf-8");
34279
+ const content = await fs7.readFile(planPath, "utf-8");
34236
34280
  planData = JSON.parse(content);
34237
34281
  planExists = true;
34238
34282
  } catch (error93) {
34239
34283
  if (error93?.code !== "ENOENT") {
34240
34284
  return `\u274C Failed to read plan.json: ${error93 instanceof Error ? error93.message : String(error93)}`;
34241
34285
  }
34242
- const swarmDirExists = await fs6.access(swarmDir).then(() => true).catch(() => false);
34286
+ const swarmDirExists = await fs7.access(swarmDir).then(() => true).catch(() => false);
34243
34287
  if (!swarmDirExists) {
34244
34288
  return `\u274C No .swarm/ directory found in ${directory}. Run /swarm close from the project root, or run /swarm plan first.`;
34245
34289
  }
@@ -34333,10 +34377,10 @@ async function handleCloseCommand(directory, args) {
34333
34377
  warnings.push(`Session retrospective write threw: ${retroError instanceof Error ? retroError.message : String(retroError)}`);
34334
34378
  }
34335
34379
  }
34336
- const lessonsFilePath = path11.join(swarmDir, "close-lessons.md");
34380
+ const lessonsFilePath = path12.join(swarmDir, "close-lessons.md");
34337
34381
  let explicitLessons = [];
34338
34382
  try {
34339
- const lessonsText = await fs6.readFile(lessonsFilePath, "utf-8");
34383
+ const lessonsText = await fs7.readFile(lessonsFilePath, "utf-8");
34340
34384
  explicitLessons = lessonsText.split(`
34341
34385
  `).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
34342
34386
  } catch {}
@@ -34350,7 +34394,7 @@ async function handleCloseCommand(directory, args) {
34350
34394
  console.warn("[close-command] curateAndStoreSwarm error:", error93);
34351
34395
  }
34352
34396
  if (curationSucceeded && explicitLessons.length > 0) {
34353
- await fs6.unlink(lessonsFilePath).catch(() => {});
34397
+ await fs7.unlink(lessonsFilePath).catch(() => {});
34354
34398
  }
34355
34399
  if (planExists && !planAlreadyDone) {
34356
34400
  for (const phase of phases) {
@@ -34370,7 +34414,7 @@ async function handleCloseCommand(directory, args) {
34370
34414
  }
34371
34415
  }
34372
34416
  try {
34373
- await fs6.writeFile(planPath, JSON.stringify(planData, null, 2), "utf-8");
34417
+ await fs7.writeFile(planPath, JSON.stringify(planData, null, 2), "utf-8");
34374
34418
  } catch (error93) {
34375
34419
  const msg = error93 instanceof Error ? error93.message : String(error93);
34376
34420
  warnings.push(`Failed to persist terminal plan.json state: ${msg}`);
@@ -34379,53 +34423,53 @@ async function handleCloseCommand(directory, args) {
34379
34423
  }
34380
34424
  const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
34381
34425
  const suffix = Math.random().toString(36).slice(2, 8);
34382
- const archiveDir = path11.join(swarmDir, "archive", `swarm-${timestamp}-${suffix}`);
34426
+ const archiveDir = path12.join(swarmDir, "archive", `swarm-${timestamp}-${suffix}`);
34383
34427
  let archiveResult = "";
34384
34428
  let archivedFileCount = 0;
34385
34429
  const archivedActiveStateFiles = new Set;
34386
34430
  try {
34387
- await fs6.mkdir(archiveDir, { recursive: true });
34431
+ await fs7.mkdir(archiveDir, { recursive: true });
34388
34432
  for (const artifact of ARCHIVE_ARTIFACTS) {
34389
- const srcPath = path11.join(swarmDir, artifact);
34390
- const destPath = path11.join(archiveDir, artifact);
34433
+ const srcPath = path12.join(swarmDir, artifact);
34434
+ const destPath = path12.join(archiveDir, artifact);
34391
34435
  try {
34392
- await fs6.copyFile(srcPath, destPath);
34436
+ await fs7.copyFile(srcPath, destPath);
34393
34437
  archivedFileCount++;
34394
34438
  if (ACTIVE_STATE_TO_CLEAN.includes(artifact)) {
34395
34439
  archivedActiveStateFiles.add(artifact);
34396
34440
  }
34397
34441
  } catch {}
34398
34442
  }
34399
- const evidenceDir = path11.join(swarmDir, "evidence");
34400
- const archiveEvidenceDir = path11.join(archiveDir, "evidence");
34443
+ const evidenceDir = path12.join(swarmDir, "evidence");
34444
+ const archiveEvidenceDir = path12.join(archiveDir, "evidence");
34401
34445
  try {
34402
- const evidenceEntries = await fs6.readdir(evidenceDir);
34446
+ const evidenceEntries = await fs7.readdir(evidenceDir);
34403
34447
  if (evidenceEntries.length > 0) {
34404
- await fs6.mkdir(archiveEvidenceDir, { recursive: true });
34448
+ await fs7.mkdir(archiveEvidenceDir, { recursive: true });
34405
34449
  for (const entry of evidenceEntries) {
34406
- const srcEntry = path11.join(evidenceDir, entry);
34407
- const destEntry = path11.join(archiveEvidenceDir, entry);
34450
+ const srcEntry = path12.join(evidenceDir, entry);
34451
+ const destEntry = path12.join(archiveEvidenceDir, entry);
34408
34452
  try {
34409
- const stat = await fs6.stat(srcEntry);
34453
+ const stat = await fs7.stat(srcEntry);
34410
34454
  if (stat.isDirectory()) {
34411
- await fs6.mkdir(destEntry, { recursive: true });
34412
- const subEntries = await fs6.readdir(srcEntry);
34455
+ await fs7.mkdir(destEntry, { recursive: true });
34456
+ const subEntries = await fs7.readdir(srcEntry);
34413
34457
  for (const sub of subEntries) {
34414
- await fs6.copyFile(path11.join(srcEntry, sub), path11.join(destEntry, sub)).catch(() => {});
34458
+ await fs7.copyFile(path12.join(srcEntry, sub), path12.join(destEntry, sub)).catch(() => {});
34415
34459
  }
34416
34460
  } else {
34417
- await fs6.copyFile(srcEntry, destEntry);
34461
+ await fs7.copyFile(srcEntry, destEntry);
34418
34462
  }
34419
34463
  archivedFileCount++;
34420
34464
  } catch {}
34421
34465
  }
34422
34466
  }
34423
34467
  } catch {}
34424
- const sessionStatePath = path11.join(swarmDir, "session", "state.json");
34468
+ const sessionStatePath = path12.join(swarmDir, "session", "state.json");
34425
34469
  try {
34426
- const archiveSessionDir = path11.join(archiveDir, "session");
34427
- await fs6.mkdir(archiveSessionDir, { recursive: true });
34428
- await fs6.copyFile(sessionStatePath, path11.join(archiveSessionDir, "state.json"));
34470
+ const archiveSessionDir = path12.join(archiveDir, "session");
34471
+ await fs7.mkdir(archiveSessionDir, { recursive: true });
34472
+ await fs7.copyFile(sessionStatePath, path12.join(archiveSessionDir, "state.json"));
34429
34473
  archivedFileCount++;
34430
34474
  } catch {}
34431
34475
  archiveResult = `Archived ${archivedFileCount} artifact(s) to .swarm/archive/swarm-${timestamp}/`;
@@ -34448,9 +34492,9 @@ async function handleCloseCommand(directory, args) {
34448
34492
  warnings.push(`Preserved ${artifact} because it was not successfully archived.`);
34449
34493
  continue;
34450
34494
  }
34451
- const filePath = path11.join(swarmDir, artifact);
34495
+ const filePath = path12.join(swarmDir, artifact);
34452
34496
  try {
34453
- await fs6.unlink(filePath);
34497
+ await fs7.unlink(filePath);
34454
34498
  cleanedFiles.push(artifact);
34455
34499
  } catch {}
34456
34500
  }
@@ -34458,22 +34502,23 @@ async function handleCloseCommand(directory, args) {
34458
34502
  warnings.push("Skipped active-state cleanup because no active-state files were archived. Files preserved to prevent data loss.");
34459
34503
  }
34460
34504
  try {
34461
- const swarmFiles = await fs6.readdir(swarmDir);
34505
+ const swarmFiles = await fs7.readdir(swarmDir);
34462
34506
  const configBackups = swarmFiles.filter((f) => f.startsWith("config-backup-") && f.endsWith(".json"));
34463
34507
  for (const backup of configBackups) {
34464
34508
  try {
34465
- await fs6.unlink(path11.join(swarmDir, backup));
34509
+ await fs7.unlink(path12.join(swarmDir, backup));
34466
34510
  configBackupsRemoved++;
34467
34511
  } catch {}
34468
34512
  }
34469
34513
  const ledgerSiblings = swarmFiles.filter((f) => (f.startsWith("plan-ledger.archived-") || f.startsWith("plan-ledger.backup-")) && f.endsWith(".jsonl"));
34470
34514
  for (const sibling of ledgerSiblings) {
34471
34515
  try {
34472
- await fs6.unlink(path11.join(swarmDir, sibling));
34516
+ await fs7.unlink(path12.join(swarmDir, sibling));
34473
34517
  } catch {}
34474
34518
  }
34475
34519
  } catch {}
34476
- const contextPath = path11.join(swarmDir, "context.md");
34520
+ clearAllScopes(directory);
34521
+ const contextPath = path12.join(swarmDir, "context.md");
34477
34522
  const contextContent = [
34478
34523
  "# Context",
34479
34524
  "",
@@ -34486,7 +34531,7 @@ async function handleCloseCommand(directory, args) {
34486
34531
  ].join(`
34487
34532
  `);
34488
34533
  try {
34489
- await fs6.writeFile(contextPath, contextContent, "utf-8");
34534
+ await fs7.writeFile(contextPath, contextContent, "utf-8");
34490
34535
  } catch (error93) {
34491
34536
  const msg = error93 instanceof Error ? error93.message : String(error93);
34492
34537
  warnings.push(`Failed to reset context.md: ${msg}`);
@@ -34617,7 +34662,7 @@ async function handleCloseCommand(directory, args) {
34617
34662
  ].join(`
34618
34663
  `);
34619
34664
  try {
34620
- await fs6.writeFile(closeSummaryPath, summaryContent, "utf-8");
34665
+ await fs7.writeFile(closeSummaryPath, summaryContent, "utf-8");
34621
34666
  } catch (error93) {
34622
34667
  const msg = error93 instanceof Error ? error93.message : String(error93);
34623
34668
  warnings.push(`Failed to write close-summary.md: ${msg}`);
@@ -34674,14 +34719,14 @@ ${otherWarnings.map((w) => `- ${w}`).join(`
34674
34719
 
34675
34720
  // src/commands/config.ts
34676
34721
  import * as os3 from "os";
34677
- import * as path12 from "path";
34722
+ import * as path13 from "path";
34678
34723
  function getUserConfigDir2() {
34679
- return process.env.XDG_CONFIG_HOME || path12.join(os3.homedir(), ".config");
34724
+ return process.env.XDG_CONFIG_HOME || path13.join(os3.homedir(), ".config");
34680
34725
  }
34681
34726
  async function handleConfigCommand(directory, _args) {
34682
34727
  const config3 = loadPluginConfig(directory);
34683
- const userConfigPath = path12.join(getUserConfigDir2(), "opencode", "opencode-swarm.json");
34684
- const projectConfigPath = path12.join(directory, ".opencode", "opencode-swarm.json");
34728
+ const userConfigPath = path13.join(getUserConfigDir2(), "opencode", "opencode-swarm.json");
34729
+ const projectConfigPath = path13.join(directory, ".opencode", "opencode-swarm.json");
34685
34730
  const lines = [
34686
34731
  "## Swarm Configuration",
34687
34732
  "",
@@ -34949,13 +34994,13 @@ function formatCurationSummary(summary) {
34949
34994
  }
34950
34995
 
34951
34996
  // src/commands/dark-matter.ts
34952
- import path14 from "path";
34997
+ import path15 from "path";
34953
34998
 
34954
34999
  // src/tools/co-change-analyzer.ts
34955
35000
  import * as child_process3 from "child_process";
34956
35001
  import { randomUUID } from "crypto";
34957
35002
  import { readdir, readFile as readFile3, stat } from "fs/promises";
34958
- import * as path13 from "path";
35003
+ import * as path14 from "path";
34959
35004
  import { promisify } from "util";
34960
35005
  function getExecFileAsync() {
34961
35006
  return promisify(child_process3.execFile);
@@ -35057,7 +35102,7 @@ async function scanSourceFiles(dir) {
35057
35102
  try {
35058
35103
  const entries = await readdir(dir, { withFileTypes: true });
35059
35104
  for (const entry of entries) {
35060
- const fullPath = path13.join(dir, entry.name);
35105
+ const fullPath = path14.join(dir, entry.name);
35061
35106
  if (entry.isDirectory()) {
35062
35107
  if (skipDirs.has(entry.name)) {
35063
35108
  continue;
@@ -35065,7 +35110,7 @@ async function scanSourceFiles(dir) {
35065
35110
  const subFiles = await scanSourceFiles(fullPath);
35066
35111
  results.push(...subFiles);
35067
35112
  } else if (entry.isFile()) {
35068
- const ext = path13.extname(entry.name);
35113
+ const ext = path14.extname(entry.name);
35069
35114
  if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext)) {
35070
35115
  results.push(fullPath);
35071
35116
  }
@@ -35087,8 +35132,8 @@ async function getStaticEdges(directory) {
35087
35132
  continue;
35088
35133
  }
35089
35134
  try {
35090
- const sourceDir = path13.dirname(sourceFile);
35091
- const resolvedPath = path13.resolve(sourceDir, importPath);
35135
+ const sourceDir = path14.dirname(sourceFile);
35136
+ const resolvedPath = path14.resolve(sourceDir, importPath);
35092
35137
  const extensions = [
35093
35138
  "",
35094
35139
  ".ts",
@@ -35113,8 +35158,8 @@ async function getStaticEdges(directory) {
35113
35158
  if (!targetFile) {
35114
35159
  continue;
35115
35160
  }
35116
- const relSource = path13.relative(directory, sourceFile).replace(/\\/g, "/");
35117
- const relTarget = path13.relative(directory, targetFile).replace(/\\/g, "/");
35161
+ const relSource = path14.relative(directory, sourceFile).replace(/\\/g, "/");
35162
+ const relTarget = path14.relative(directory, targetFile).replace(/\\/g, "/");
35118
35163
  const [key] = relSource < relTarget ? [`${relSource}::${relTarget}`, relSource, relTarget] : [`${relTarget}::${relSource}`, relTarget, relSource];
35119
35164
  edges.add(key);
35120
35165
  } catch {}
@@ -35126,7 +35171,7 @@ async function getStaticEdges(directory) {
35126
35171
  function isTestImplementationPair(fileA, fileB) {
35127
35172
  const testPatterns = [".test.ts", ".test.js", ".spec.ts", ".spec.js"];
35128
35173
  const getBaseName = (filePath) => {
35129
- const base = path13.basename(filePath);
35174
+ const base = path14.basename(filePath);
35130
35175
  for (const pattern of testPatterns) {
35131
35176
  if (base.endsWith(pattern)) {
35132
35177
  return base.slice(0, -pattern.length);
@@ -35136,16 +35181,16 @@ function isTestImplementationPair(fileA, fileB) {
35136
35181
  };
35137
35182
  const baseA = getBaseName(fileA);
35138
35183
  const baseB = getBaseName(fileB);
35139
- return baseA === baseB && baseA !== path13.basename(fileA) && baseA !== path13.basename(fileB);
35184
+ return baseA === baseB && baseA !== path14.basename(fileA) && baseA !== path14.basename(fileB);
35140
35185
  }
35141
35186
  function hasSharedPrefix(fileA, fileB) {
35142
- const dirA = path13.dirname(fileA);
35143
- const dirB = path13.dirname(fileB);
35187
+ const dirA = path14.dirname(fileA);
35188
+ const dirB = path14.dirname(fileB);
35144
35189
  if (dirA !== dirB) {
35145
35190
  return false;
35146
35191
  }
35147
- const baseA = path13.basename(fileA).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
35148
- const baseB = path13.basename(fileB).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
35192
+ const baseA = path14.basename(fileA).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
35193
+ const baseB = path14.basename(fileB).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
35149
35194
  if (baseA.startsWith(baseB) || baseB.startsWith(baseA)) {
35150
35195
  return true;
35151
35196
  }
@@ -35199,8 +35244,8 @@ function darkMatterToKnowledgeEntries(pairs, projectName) {
35199
35244
  const entries = [];
35200
35245
  const now = new Date().toISOString();
35201
35246
  for (const pair of pairs.slice(0, 10)) {
35202
- const baseA = path13.basename(pair.fileA);
35203
- const baseB = path13.basename(pair.fileB);
35247
+ const baseA = path14.basename(pair.fileA);
35248
+ const baseB = path14.basename(pair.fileB);
35204
35249
  let lesson = `Files ${pair.fileA} and ${pair.fileB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern \u2014 changes to one likely require changes to the other.`;
35205
35250
  if (lesson.length > 280) {
35206
35251
  lesson = `Files ${baseA} and ${baseB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern \u2014 changes to one likely require changes to the other.`;
@@ -35310,7 +35355,7 @@ async function handleDarkMatterCommand(directory, args) {
35310
35355
  const output = formatDarkMatterOutput(pairs);
35311
35356
  if (pairs.length > 0) {
35312
35357
  try {
35313
- const projectName = path14.basename(path14.resolve(directory));
35358
+ const projectName = path15.basename(path15.resolve(directory));
35314
35359
  const entries = darkMatterToKnowledgeEntries(pairs, projectName);
35315
35360
  if (entries.length > 0) {
35316
35361
  const knowledgePath = resolveSwarmKnowledgePath(directory);
@@ -35331,8 +35376,8 @@ async function handleDarkMatterCommand(directory, args) {
35331
35376
 
35332
35377
  // src/services/diagnose-service.ts
35333
35378
  import * as child_process4 from "child_process";
35334
- import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
35335
- import path15 from "path";
35379
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
35380
+ import path16 from "path";
35336
35381
  import { fileURLToPath } from "url";
35337
35382
  init_manager2();
35338
35383
  init_utils2();
@@ -35568,7 +35613,7 @@ async function checkConfigBackups(directory) {
35568
35613
  }
35569
35614
  async function checkGitRepository(directory) {
35570
35615
  try {
35571
- if (!existsSync6(directory) || !statSync3(directory).isDirectory()) {
35616
+ if (!existsSync6(directory) || !statSync4(directory).isDirectory()) {
35572
35617
  return {
35573
35618
  name: "Git Repository",
35574
35619
  status: "\u274C",
@@ -35632,7 +35677,7 @@ async function checkSpecStaleness(directory, plan) {
35632
35677
  };
35633
35678
  }
35634
35679
  async function checkConfigParseability(directory) {
35635
- const configPath = path15.join(directory, ".opencode/opencode-swarm.json");
35680
+ const configPath = path16.join(directory, ".opencode/opencode-swarm.json");
35636
35681
  if (!existsSync6(configPath)) {
35637
35682
  return {
35638
35683
  name: "Config Parseability",
@@ -35641,7 +35686,7 @@ async function checkConfigParseability(directory) {
35641
35686
  };
35642
35687
  }
35643
35688
  try {
35644
- const content = readFileSync5(configPath, "utf-8");
35689
+ const content = readFileSync6(configPath, "utf-8");
35645
35690
  JSON.parse(content);
35646
35691
  return {
35647
35692
  name: "Config Parseability",
@@ -35679,15 +35724,15 @@ async function checkGrammarWasmFiles() {
35679
35724
  "tree-sitter-ini.wasm",
35680
35725
  "tree-sitter-regex.wasm"
35681
35726
  ];
35682
- const thisDir = path15.dirname(fileURLToPath(import.meta.url));
35727
+ const thisDir = path16.dirname(fileURLToPath(import.meta.url));
35683
35728
  const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
35684
- const grammarDir = isSource ? path15.join(thisDir, "..", "lang", "grammars") : path15.join(thisDir, "lang", "grammars");
35729
+ const grammarDir = isSource ? path16.join(thisDir, "..", "lang", "grammars") : path16.join(thisDir, "lang", "grammars");
35685
35730
  const missing = [];
35686
- if (!existsSync6(path15.join(grammarDir, "tree-sitter.wasm"))) {
35731
+ if (!existsSync6(path16.join(grammarDir, "tree-sitter.wasm"))) {
35687
35732
  missing.push("tree-sitter.wasm (core runtime)");
35688
35733
  }
35689
35734
  for (const file3 of grammarFiles) {
35690
- if (!existsSync6(path15.join(grammarDir, file3))) {
35735
+ if (!existsSync6(path16.join(grammarDir, file3))) {
35691
35736
  missing.push(file3);
35692
35737
  }
35693
35738
  }
@@ -35705,7 +35750,7 @@ async function checkGrammarWasmFiles() {
35705
35750
  };
35706
35751
  }
35707
35752
  async function checkCheckpointManifest(directory) {
35708
- const manifestPath = path15.join(directory, ".swarm/checkpoints.json");
35753
+ const manifestPath = path16.join(directory, ".swarm/checkpoints.json");
35709
35754
  if (!existsSync6(manifestPath)) {
35710
35755
  return {
35711
35756
  name: "Checkpoint Manifest",
@@ -35714,7 +35759,7 @@ async function checkCheckpointManifest(directory) {
35714
35759
  };
35715
35760
  }
35716
35761
  try {
35717
- const content = readFileSync5(manifestPath, "utf-8");
35762
+ const content = readFileSync6(manifestPath, "utf-8");
35718
35763
  const parsed = JSON.parse(content);
35719
35764
  if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
35720
35765
  return {
@@ -35757,7 +35802,7 @@ async function checkCheckpointManifest(directory) {
35757
35802
  }
35758
35803
  }
35759
35804
  async function checkEventStreamIntegrity(directory) {
35760
- const eventsPath = path15.join(directory, ".swarm/events.jsonl");
35805
+ const eventsPath = path16.join(directory, ".swarm/events.jsonl");
35761
35806
  if (!existsSync6(eventsPath)) {
35762
35807
  return {
35763
35808
  name: "Event Stream",
@@ -35766,7 +35811,7 @@ async function checkEventStreamIntegrity(directory) {
35766
35811
  };
35767
35812
  }
35768
35813
  try {
35769
- const content = readFileSync5(eventsPath, "utf-8");
35814
+ const content = readFileSync6(eventsPath, "utf-8");
35770
35815
  const lines = content.split(`
35771
35816
  `).filter((line) => line.trim() !== "");
35772
35817
  let malformedCount = 0;
@@ -35798,7 +35843,7 @@ async function checkEventStreamIntegrity(directory) {
35798
35843
  }
35799
35844
  }
35800
35845
  async function checkSteeringDirectives(directory) {
35801
- const eventsPath = path15.join(directory, ".swarm/events.jsonl");
35846
+ const eventsPath = path16.join(directory, ".swarm/events.jsonl");
35802
35847
  if (!existsSync6(eventsPath)) {
35803
35848
  return {
35804
35849
  name: "Steering Directives",
@@ -35807,7 +35852,7 @@ async function checkSteeringDirectives(directory) {
35807
35852
  };
35808
35853
  }
35809
35854
  try {
35810
- const content = readFileSync5(eventsPath, "utf-8");
35855
+ const content = readFileSync6(eventsPath, "utf-8");
35811
35856
  const lines = content.split(`
35812
35857
  `).filter((line) => line.trim() !== "");
35813
35858
  const directivesIssued = [];
@@ -35854,7 +35899,7 @@ async function checkCurator(directory) {
35854
35899
  detail: "Disabled (enable via curator.enabled)"
35855
35900
  };
35856
35901
  }
35857
- const summaryPath = path15.join(directory, ".swarm/curator-summary.json");
35902
+ const summaryPath = path16.join(directory, ".swarm/curator-summary.json");
35858
35903
  if (!existsSync6(summaryPath)) {
35859
35904
  return {
35860
35905
  name: "Curator",
@@ -35863,7 +35908,7 @@ async function checkCurator(directory) {
35863
35908
  };
35864
35909
  }
35865
35910
  try {
35866
- const content = readFileSync5(summaryPath, "utf-8");
35911
+ const content = readFileSync6(summaryPath, "utf-8");
35867
35912
  const parsed = JSON.parse(content);
35868
35913
  if (typeof parsed.schema_version !== "number" || parsed.schema_version !== 1) {
35869
35914
  return {
@@ -36002,7 +36047,7 @@ async function getDiagnoseData(directory) {
36002
36047
  checks5.push(await checkSteeringDirectives(directory));
36003
36048
  checks5.push(await checkCurator(directory));
36004
36049
  try {
36005
- const evidenceDir = path15.join(directory, ".swarm", "evidence");
36050
+ const evidenceDir = path16.join(directory, ".swarm", "evidence");
36006
36051
  const snapshotFiles = existsSync6(evidenceDir) ? readdirSync3(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
36007
36052
  if (snapshotFiles.length > 0) {
36008
36053
  const latest = snapshotFiles.sort().pop();
@@ -36054,16 +36099,16 @@ async function handleDiagnoseCommand(directory, _args) {
36054
36099
  init_config_doctor();
36055
36100
 
36056
36101
  // src/services/tool-doctor.ts
36057
- import * as fs9 from "fs";
36058
- import * as path18 from "path";
36102
+ import * as fs10 from "fs";
36103
+ import * as path19 from "path";
36059
36104
 
36060
36105
  // src/build/discovery.ts
36061
- import * as fs8 from "fs";
36062
- import * as path17 from "path";
36106
+ import * as fs9 from "fs";
36107
+ import * as path18 from "path";
36063
36108
 
36064
36109
  // src/lang/detector.ts
36065
36110
  import { access as access2, readdir as readdir2 } from "fs/promises";
36066
- import { extname as extname2, join as join13 } from "path";
36111
+ import { extname as extname2, join as join14 } from "path";
36067
36112
 
36068
36113
  // src/lang/profiles.ts
36069
36114
  class LanguageRegistry {
@@ -37043,7 +37088,7 @@ async function detectProjectLanguages(projectDir) {
37043
37088
  if (detectFile.includes("*") || detectFile.includes("?"))
37044
37089
  continue;
37045
37090
  try {
37046
- await access2(join13(dir, detectFile));
37091
+ await access2(join14(dir, detectFile));
37047
37092
  detected.add(profile.id);
37048
37093
  break;
37049
37094
  } catch {}
@@ -37064,7 +37109,7 @@ async function detectProjectLanguages(projectDir) {
37064
37109
  const topEntries = await readdir2(projectDir, { withFileTypes: true });
37065
37110
  for (const entry of topEntries) {
37066
37111
  if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
37067
- await scanDir(join13(projectDir, entry.name));
37112
+ await scanDir(join14(projectDir, entry.name));
37068
37113
  }
37069
37114
  }
37070
37115
  } catch {}
@@ -37219,16 +37264,16 @@ function findBuildFiles(workingDir, patterns) {
37219
37264
  if (pattern.includes("*")) {
37220
37265
  const dir = workingDir;
37221
37266
  try {
37222
- const files = fs8.readdirSync(dir);
37267
+ const files = fs9.readdirSync(dir);
37223
37268
  const regex = simpleGlobToRegex(pattern);
37224
37269
  const matches = files.filter((f) => regex.test(f));
37225
37270
  if (matches.length > 0) {
37226
- return path17.join(dir, matches[0]);
37271
+ return path18.join(dir, matches[0]);
37227
37272
  }
37228
37273
  } catch {}
37229
37274
  } else {
37230
- const filePath = path17.join(workingDir, pattern);
37231
- if (fs8.existsSync(filePath)) {
37275
+ const filePath = path18.join(workingDir, pattern);
37276
+ if (fs9.existsSync(filePath)) {
37232
37277
  return filePath;
37233
37278
  }
37234
37279
  }
@@ -37236,12 +37281,12 @@ function findBuildFiles(workingDir, patterns) {
37236
37281
  return null;
37237
37282
  }
37238
37283
  function getRepoDefinedScripts(workingDir, scripts) {
37239
- const packageJsonPath = path17.join(workingDir, "package.json");
37240
- if (!fs8.existsSync(packageJsonPath)) {
37284
+ const packageJsonPath = path18.join(workingDir, "package.json");
37285
+ if (!fs9.existsSync(packageJsonPath)) {
37241
37286
  return [];
37242
37287
  }
37243
37288
  try {
37244
- const content = fs8.readFileSync(packageJsonPath, "utf-8");
37289
+ const content = fs9.readFileSync(packageJsonPath, "utf-8");
37245
37290
  const pkg = JSON.parse(content);
37246
37291
  if (!pkg.scripts || typeof pkg.scripts !== "object") {
37247
37292
  return [];
@@ -37277,8 +37322,8 @@ function findAllBuildFiles(workingDir) {
37277
37322
  const regex = simpleGlobToRegex(pattern);
37278
37323
  findFilesRecursive(workingDir, regex, allBuildFiles);
37279
37324
  } else {
37280
- const filePath = path17.join(workingDir, pattern);
37281
- if (fs8.existsSync(filePath)) {
37325
+ const filePath = path18.join(workingDir, pattern);
37326
+ if (fs9.existsSync(filePath)) {
37282
37327
  allBuildFiles.add(filePath);
37283
37328
  }
37284
37329
  }
@@ -37288,9 +37333,9 @@ function findAllBuildFiles(workingDir) {
37288
37333
  }
37289
37334
  function findFilesRecursive(dir, regex, results) {
37290
37335
  try {
37291
- const entries = fs8.readdirSync(dir, { withFileTypes: true });
37336
+ const entries = fs9.readdirSync(dir, { withFileTypes: true });
37292
37337
  for (const entry of entries) {
37293
- const fullPath = path17.join(dir, entry.name);
37338
+ const fullPath = path18.join(dir, entry.name);
37294
37339
  if (entry.isDirectory() && !["node_modules", ".git", "dist", "build", "target"].includes(entry.name)) {
37295
37340
  findFilesRecursive(fullPath, regex, results);
37296
37341
  } else if (entry.isFile() && regex.test(entry.name)) {
@@ -37313,8 +37358,8 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
37313
37358
  let foundCommand = false;
37314
37359
  for (const cmd of sortedCommands) {
37315
37360
  if (cmd.detectFile) {
37316
- const detectFilePath = path17.join(workingDir, cmd.detectFile);
37317
- if (!fs8.existsSync(detectFilePath)) {
37361
+ const detectFilePath = path18.join(workingDir, cmd.detectFile);
37362
+ if (!fs9.existsSync(detectFilePath)) {
37318
37363
  continue;
37319
37364
  }
37320
37365
  }
@@ -37437,7 +37482,7 @@ var BINARY_CHECKLIST = [
37437
37482
  function extractRegisteredToolKeys(indexPath) {
37438
37483
  const registeredKeys = new Set;
37439
37484
  try {
37440
- const content = fs9.readFileSync(indexPath, "utf-8");
37485
+ const content = fs10.readFileSync(indexPath, "utf-8");
37441
37486
  const toolBlockMatch = content.match(/tool:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s);
37442
37487
  if (!toolBlockMatch) {
37443
37488
  return registeredKeys;
@@ -37488,9 +37533,9 @@ function checkBinaryReadiness() {
37488
37533
  }
37489
37534
  function runToolDoctor(_directory, pluginRoot) {
37490
37535
  const findings = [];
37491
- const resolvedPluginRoot = pluginRoot ?? path18.resolve(import.meta.dir, "..", "..");
37492
- const indexPath = path18.join(resolvedPluginRoot, "src", "index.ts");
37493
- if (!fs9.existsSync(indexPath)) {
37536
+ const resolvedPluginRoot = pluginRoot ?? path19.resolve(import.meta.dir, "..", "..");
37537
+ const indexPath = path19.join(resolvedPluginRoot, "src", "index.ts");
37538
+ if (!fs10.existsSync(indexPath)) {
37494
37539
  return {
37495
37540
  findings: [
37496
37541
  {
@@ -37877,7 +37922,7 @@ async function handleFullAutoCommand(_directory, args, sessionID) {
37877
37922
  // src/commands/handoff.ts
37878
37923
  init_utils2();
37879
37924
  import crypto4 from "crypto";
37880
- import { renameSync as renameSync5 } from "fs";
37925
+ import { renameSync as renameSync6 } from "fs";
37881
37926
 
37882
37927
  // src/services/handoff-service.ts
37883
37928
  init_utils2();
@@ -38245,12 +38290,12 @@ async function handleHandoffCommand(directory, _args) {
38245
38290
  const resolvedPath = validateSwarmPath(directory, "handoff.md");
38246
38291
  const tempPath = `${resolvedPath}.tmp.${crypto4.randomUUID()}`;
38247
38292
  await Bun.write(tempPath, markdown);
38248
- renameSync5(tempPath, resolvedPath);
38293
+ renameSync6(tempPath, resolvedPath);
38249
38294
  const continuationPrompt = formatContinuationPrompt(handoffData);
38250
38295
  const promptPath = validateSwarmPath(directory, "handoff-prompt.md");
38251
38296
  const promptTempPath = `${promptPath}.tmp.${crypto4.randomUUID()}`;
38252
38297
  await Bun.write(promptTempPath, continuationPrompt);
38253
- renameSync5(promptTempPath, promptPath);
38298
+ renameSync6(promptTempPath, promptPath);
38254
38299
  await writeSnapshot(directory, swarmState);
38255
38300
  await flushPendingSnapshot(directory);
38256
38301
  return `## Handoff Brief Written
@@ -38400,12 +38445,12 @@ async function handleHistoryCommand(directory, _args) {
38400
38445
  }
38401
38446
  // src/hooks/knowledge-migrator.ts
38402
38447
  import { randomUUID as randomUUID2 } from "crypto";
38403
- import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
38448
+ import { existsSync as existsSync10, readFileSync as readFileSync10 } from "fs";
38404
38449
  import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
38405
- import * as path19 from "path";
38450
+ import * as path20 from "path";
38406
38451
  async function migrateContextToKnowledge(directory, config3) {
38407
- const sentinelPath = path19.join(directory, ".swarm", ".knowledge-migrated");
38408
- const contextPath = path19.join(directory, ".swarm", "context.md");
38452
+ const sentinelPath = path20.join(directory, ".swarm", ".knowledge-migrated");
38453
+ const contextPath = path20.join(directory, ".swarm", "context.md");
38409
38454
  const knowledgePath = resolveSwarmKnowledgePath(directory);
38410
38455
  if (existsSync10(sentinelPath)) {
38411
38456
  return {
@@ -38601,16 +38646,16 @@ function truncateLesson(text) {
38601
38646
  return `${text.slice(0, 277)}...`;
38602
38647
  }
38603
38648
  function inferProjectName(directory) {
38604
- const packageJsonPath = path19.join(directory, "package.json");
38649
+ const packageJsonPath = path20.join(directory, "package.json");
38605
38650
  if (existsSync10(packageJsonPath)) {
38606
38651
  try {
38607
- const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
38652
+ const pkg = JSON.parse(readFileSync10(packageJsonPath, "utf-8"));
38608
38653
  if (pkg.name && typeof pkg.name === "string") {
38609
38654
  return pkg.name;
38610
38655
  }
38611
38656
  } catch {}
38612
38657
  }
38613
- return path19.basename(directory);
38658
+ return path20.basename(directory);
38614
38659
  }
38615
38660
  async function writeSentinel(sentinelPath, migrated, dropped) {
38616
38661
  const sentinel = {
@@ -38622,7 +38667,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
38622
38667
  schema_version: 1,
38623
38668
  migration_tool: "knowledge-migrator.ts"
38624
38669
  };
38625
- await mkdir3(path19.dirname(sentinelPath), { recursive: true });
38670
+ await mkdir3(path20.dirname(sentinelPath), { recursive: true });
38626
38671
  await writeFile4(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
38627
38672
  }
38628
38673
 
@@ -38858,12 +38903,12 @@ async function handlePlanCommand(directory, args) {
38858
38903
  // src/services/preflight-service.ts
38859
38904
  init_manager2();
38860
38905
  init_manager();
38861
- import * as fs16 from "fs";
38862
- import * as path26 from "path";
38906
+ import * as fs17 from "fs";
38907
+ import * as path27 from "path";
38863
38908
 
38864
38909
  // src/tools/lint.ts
38865
- import * as fs10 from "fs";
38866
- import * as path20 from "path";
38910
+ import * as fs11 from "fs";
38911
+ import * as path21 from "path";
38867
38912
  init_utils();
38868
38913
 
38869
38914
  // src/utils/path-security.ts
@@ -38909,9 +38954,9 @@ function validateArgs(args) {
38909
38954
  }
38910
38955
  function getLinterCommand(linter, mode, projectDir) {
38911
38956
  const isWindows = process.platform === "win32";
38912
- const binDir = path20.join(projectDir, "node_modules", ".bin");
38913
- const biomeBin = isWindows ? path20.join(binDir, "biome.EXE") : path20.join(binDir, "biome");
38914
- const eslintBin = isWindows ? path20.join(binDir, "eslint.cmd") : path20.join(binDir, "eslint");
38957
+ const binDir = path21.join(projectDir, "node_modules", ".bin");
38958
+ const biomeBin = isWindows ? path21.join(binDir, "biome.EXE") : path21.join(binDir, "biome");
38959
+ const eslintBin = isWindows ? path21.join(binDir, "eslint.cmd") : path21.join(binDir, "eslint");
38915
38960
  switch (linter) {
38916
38961
  case "biome":
38917
38962
  if (mode === "fix") {
@@ -38927,7 +38972,7 @@ function getLinterCommand(linter, mode, projectDir) {
38927
38972
  }
38928
38973
  function getAdditionalLinterCommand(linter, mode, cwd) {
38929
38974
  const gradlewName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
38930
- const gradlew = fs10.existsSync(path20.join(cwd, gradlewName)) ? path20.join(cwd, gradlewName) : null;
38975
+ const gradlew = fs11.existsSync(path21.join(cwd, gradlewName)) ? path21.join(cwd, gradlewName) : null;
38931
38976
  switch (linter) {
38932
38977
  case "ruff":
38933
38978
  return mode === "fix" ? ["ruff", "check", "--fix", "."] : ["ruff", "check", "."];
@@ -38961,12 +39006,12 @@ function getAdditionalLinterCommand(linter, mode, cwd) {
38961
39006
  }
38962
39007
  }
38963
39008
  function detectRuff(cwd) {
38964
- if (fs10.existsSync(path20.join(cwd, "ruff.toml")))
39009
+ if (fs11.existsSync(path21.join(cwd, "ruff.toml")))
38965
39010
  return isCommandAvailable("ruff");
38966
39011
  try {
38967
- const pyproject = path20.join(cwd, "pyproject.toml");
38968
- if (fs10.existsSync(pyproject)) {
38969
- const content = fs10.readFileSync(pyproject, "utf-8");
39012
+ const pyproject = path21.join(cwd, "pyproject.toml");
39013
+ if (fs11.existsSync(pyproject)) {
39014
+ const content = fs11.readFileSync(pyproject, "utf-8");
38970
39015
  if (content.includes("[tool.ruff]"))
38971
39016
  return isCommandAvailable("ruff");
38972
39017
  }
@@ -38974,21 +39019,21 @@ function detectRuff(cwd) {
38974
39019
  return false;
38975
39020
  }
38976
39021
  function detectClippy(cwd) {
38977
- return fs10.existsSync(path20.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
39022
+ return fs11.existsSync(path21.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
38978
39023
  }
38979
39024
  function detectGolangciLint(cwd) {
38980
- return fs10.existsSync(path20.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
39025
+ return fs11.existsSync(path21.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
38981
39026
  }
38982
39027
  function detectCheckstyle(cwd) {
38983
- const hasMaven = fs10.existsSync(path20.join(cwd, "pom.xml"));
38984
- const hasGradle = fs10.existsSync(path20.join(cwd, "build.gradle")) || fs10.existsSync(path20.join(cwd, "build.gradle.kts"));
38985
- const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs10.existsSync(path20.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
39028
+ const hasMaven = fs11.existsSync(path21.join(cwd, "pom.xml"));
39029
+ const hasGradle = fs11.existsSync(path21.join(cwd, "build.gradle")) || fs11.existsSync(path21.join(cwd, "build.gradle.kts"));
39030
+ const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs11.existsSync(path21.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
38986
39031
  return (hasMaven || hasGradle) && hasBinary;
38987
39032
  }
38988
39033
  function detectKtlint(cwd) {
38989
- const hasKotlin = fs10.existsSync(path20.join(cwd, "build.gradle.kts")) || fs10.existsSync(path20.join(cwd, "build.gradle")) || (() => {
39034
+ const hasKotlin = fs11.existsSync(path21.join(cwd, "build.gradle.kts")) || fs11.existsSync(path21.join(cwd, "build.gradle")) || (() => {
38990
39035
  try {
38991
- return fs10.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
39036
+ return fs11.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
38992
39037
  } catch {
38993
39038
  return false;
38994
39039
  }
@@ -38997,7 +39042,7 @@ function detectKtlint(cwd) {
38997
39042
  }
38998
39043
  function detectDotnetFormat(cwd) {
38999
39044
  try {
39000
- const files = fs10.readdirSync(cwd);
39045
+ const files = fs11.readdirSync(cwd);
39001
39046
  const hasCsproj = files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"));
39002
39047
  return hasCsproj && isCommandAvailable("dotnet");
39003
39048
  } catch {
@@ -39005,14 +39050,14 @@ function detectDotnetFormat(cwd) {
39005
39050
  }
39006
39051
  }
39007
39052
  function detectCppcheck(cwd) {
39008
- if (fs10.existsSync(path20.join(cwd, "CMakeLists.txt"))) {
39053
+ if (fs11.existsSync(path21.join(cwd, "CMakeLists.txt"))) {
39009
39054
  return isCommandAvailable("cppcheck");
39010
39055
  }
39011
39056
  try {
39012
- const dirsToCheck = [cwd, path20.join(cwd, "src")];
39057
+ const dirsToCheck = [cwd, path21.join(cwd, "src")];
39013
39058
  const hasCpp = dirsToCheck.some((dir) => {
39014
39059
  try {
39015
- return fs10.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
39060
+ return fs11.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
39016
39061
  } catch {
39017
39062
  return false;
39018
39063
  }
@@ -39023,13 +39068,13 @@ function detectCppcheck(cwd) {
39023
39068
  }
39024
39069
  }
39025
39070
  function detectSwiftlint(cwd) {
39026
- return fs10.existsSync(path20.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
39071
+ return fs11.existsSync(path21.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
39027
39072
  }
39028
39073
  function detectDartAnalyze(cwd) {
39029
- return fs10.existsSync(path20.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
39074
+ return fs11.existsSync(path21.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
39030
39075
  }
39031
39076
  function detectRubocop(cwd) {
39032
- return (fs10.existsSync(path20.join(cwd, "Gemfile")) || fs10.existsSync(path20.join(cwd, "gems.rb")) || fs10.existsSync(path20.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
39077
+ return (fs11.existsSync(path21.join(cwd, "Gemfile")) || fs11.existsSync(path21.join(cwd, "gems.rb")) || fs11.existsSync(path21.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
39033
39078
  }
39034
39079
  function detectAdditionalLinter(cwd) {
39035
39080
  if (detectRuff(cwd))
@@ -39057,10 +39102,10 @@ function detectAdditionalLinter(cwd) {
39057
39102
  function findBinInAncestors(startDir, binName) {
39058
39103
  let dir = startDir;
39059
39104
  while (true) {
39060
- const candidate = path20.join(dir, "node_modules", ".bin", binName);
39061
- if (fs10.existsSync(candidate))
39105
+ const candidate = path21.join(dir, "node_modules", ".bin", binName);
39106
+ if (fs11.existsSync(candidate))
39062
39107
  return candidate;
39063
- const parent = path20.dirname(dir);
39108
+ const parent = path21.dirname(dir);
39064
39109
  if (parent === dir)
39065
39110
  break;
39066
39111
  dir = parent;
@@ -39069,11 +39114,11 @@ function findBinInAncestors(startDir, binName) {
39069
39114
  }
39070
39115
  function findBinInEnvPath(binName) {
39071
39116
  const searchPath = process.env.PATH ?? "";
39072
- for (const dir of searchPath.split(path20.delimiter)) {
39117
+ for (const dir of searchPath.split(path21.delimiter)) {
39073
39118
  if (!dir)
39074
39119
  continue;
39075
- const candidate = path20.join(dir, binName);
39076
- if (fs10.existsSync(candidate))
39120
+ const candidate = path21.join(dir, binName);
39121
+ if (fs11.existsSync(candidate))
39077
39122
  return candidate;
39078
39123
  }
39079
39124
  return null;
@@ -39081,17 +39126,17 @@ function findBinInEnvPath(binName) {
39081
39126
  async function detectAvailableLinter(directory) {
39082
39127
  if (!directory)
39083
39128
  return null;
39084
- if (!fs10.existsSync(directory))
39129
+ if (!fs11.existsSync(directory))
39085
39130
  return null;
39086
39131
  const projectDir = directory;
39087
39132
  const isWindows = process.platform === "win32";
39088
- const biomeBin = isWindows ? path20.join(projectDir, "node_modules", ".bin", "biome.EXE") : path20.join(projectDir, "node_modules", ".bin", "biome");
39089
- const eslintBin = isWindows ? path20.join(projectDir, "node_modules", ".bin", "eslint.cmd") : path20.join(projectDir, "node_modules", ".bin", "eslint");
39133
+ const biomeBin = isWindows ? path21.join(projectDir, "node_modules", ".bin", "biome.EXE") : path21.join(projectDir, "node_modules", ".bin", "biome");
39134
+ const eslintBin = isWindows ? path21.join(projectDir, "node_modules", ".bin", "eslint.cmd") : path21.join(projectDir, "node_modules", ".bin", "eslint");
39090
39135
  const localResult = await _detectAvailableLinter(projectDir, biomeBin, eslintBin);
39091
39136
  if (localResult)
39092
39137
  return localResult;
39093
- const biomeAncestor = findBinInAncestors(path20.dirname(projectDir), isWindows ? "biome.EXE" : "biome");
39094
- const eslintAncestor = findBinInAncestors(path20.dirname(projectDir), isWindows ? "eslint.cmd" : "eslint");
39138
+ const biomeAncestor = findBinInAncestors(path21.dirname(projectDir), isWindows ? "biome.EXE" : "biome");
39139
+ const eslintAncestor = findBinInAncestors(path21.dirname(projectDir), isWindows ? "eslint.cmd" : "eslint");
39095
39140
  if (biomeAncestor || eslintAncestor) {
39096
39141
  return _detectAvailableLinter(projectDir, biomeAncestor ?? biomeBin, eslintAncestor ?? eslintBin);
39097
39142
  }
@@ -39114,7 +39159,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
39114
39159
  const result = await Promise.race([biomeExit, timeout]);
39115
39160
  if (result === "timeout") {
39116
39161
  biomeProc.kill();
39117
- } else if (biomeProc.exitCode === 0 && fs10.existsSync(biomeBin)) {
39162
+ } else if (biomeProc.exitCode === 0 && fs11.existsSync(biomeBin)) {
39118
39163
  return "biome";
39119
39164
  }
39120
39165
  } catch {}
@@ -39128,7 +39173,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
39128
39173
  const result = await Promise.race([eslintExit, timeout]);
39129
39174
  if (result === "timeout") {
39130
39175
  eslintProc.kill();
39131
- } else if (eslintProc.exitCode === 0 && fs10.existsSync(eslintBin)) {
39176
+ } else if (eslintProc.exitCode === 0 && fs11.existsSync(eslintBin)) {
39132
39177
  return "eslint";
39133
39178
  }
39134
39179
  } catch {}
@@ -39298,8 +39343,8 @@ For Rust: rustup component add clippy`
39298
39343
  });
39299
39344
 
39300
39345
  // src/tools/secretscan.ts
39301
- import * as fs11 from "fs";
39302
- import * as path21 from "path";
39346
+ import * as fs12 from "fs";
39347
+ import * as path22 from "path";
39303
39348
  var MAX_FILE_PATH_LENGTH = 500;
39304
39349
  var MAX_FILE_SIZE_BYTES = 512 * 1024;
39305
39350
  var MAX_FILES_SCANNED = 1000;
@@ -39526,11 +39571,11 @@ function isGlobOrPathPattern(pattern) {
39526
39571
  return pattern.includes("/") || pattern.includes("\\") || /[*?[\]{}]/.test(pattern);
39527
39572
  }
39528
39573
  function loadSecretScanIgnore(scanDir) {
39529
- const ignorePath = path21.join(scanDir, ".secretscanignore");
39574
+ const ignorePath = path22.join(scanDir, ".secretscanignore");
39530
39575
  try {
39531
- if (!fs11.existsSync(ignorePath))
39576
+ if (!fs12.existsSync(ignorePath))
39532
39577
  return [];
39533
- const content = fs11.readFileSync(ignorePath, "utf8");
39578
+ const content = fs12.readFileSync(ignorePath, "utf8");
39534
39579
  const patterns = [];
39535
39580
  for (const rawLine of content.split(/\r?\n/)) {
39536
39581
  const line = rawLine.trim();
@@ -39549,7 +39594,7 @@ function isExcluded(entry, relPath, exactNames, globPatterns) {
39549
39594
  if (exactNames.has(entry))
39550
39595
  return true;
39551
39596
  for (const pattern of globPatterns) {
39552
- if (path21.matchesGlob(relPath, pattern))
39597
+ if (path22.matchesGlob(relPath, pattern))
39553
39598
  return true;
39554
39599
  }
39555
39600
  return false;
@@ -39570,7 +39615,7 @@ function validateDirectoryInput(dir) {
39570
39615
  return null;
39571
39616
  }
39572
39617
  function isBinaryFile(filePath, buffer) {
39573
- const ext = path21.extname(filePath).toLowerCase();
39618
+ const ext = path22.extname(filePath).toLowerCase();
39574
39619
  if (DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
39575
39620
  return true;
39576
39621
  }
@@ -39645,11 +39690,11 @@ function createRedactedContext(line, findings) {
39645
39690
  result += line.slice(lastEnd);
39646
39691
  return result;
39647
39692
  }
39648
- var O_NOFOLLOW = process.platform !== "win32" ? fs11.constants.O_NOFOLLOW : undefined;
39693
+ var O_NOFOLLOW = process.platform !== "win32" ? fs12.constants.O_NOFOLLOW : undefined;
39649
39694
  function scanFileForSecrets(filePath) {
39650
39695
  const findings = [];
39651
39696
  try {
39652
- const lstat = fs11.lstatSync(filePath);
39697
+ const lstat = fs12.lstatSync(filePath);
39653
39698
  if (lstat.isSymbolicLink()) {
39654
39699
  return findings;
39655
39700
  }
@@ -39658,14 +39703,14 @@ function scanFileForSecrets(filePath) {
39658
39703
  }
39659
39704
  let buffer;
39660
39705
  if (O_NOFOLLOW !== undefined) {
39661
- const fd = fs11.openSync(filePath, "r", O_NOFOLLOW);
39706
+ const fd = fs12.openSync(filePath, "r", O_NOFOLLOW);
39662
39707
  try {
39663
- buffer = fs11.readFileSync(fd);
39708
+ buffer = fs12.readFileSync(fd);
39664
39709
  } finally {
39665
- fs11.closeSync(fd);
39710
+ fs12.closeSync(fd);
39666
39711
  }
39667
39712
  } else {
39668
- buffer = fs11.readFileSync(filePath);
39713
+ buffer = fs12.readFileSync(filePath);
39669
39714
  }
39670
39715
  if (isBinaryFile(filePath, buffer)) {
39671
39716
  return findings;
@@ -39707,9 +39752,9 @@ function isSymlinkLoop(realPath, visited) {
39707
39752
  return false;
39708
39753
  }
39709
39754
  function isPathWithinScope(realPath, scanDir) {
39710
- const resolvedScanDir = path21.resolve(scanDir);
39711
- const resolvedRealPath = path21.resolve(realPath);
39712
- return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir + path21.sep) || resolvedRealPath.startsWith(`${resolvedScanDir}/`) || resolvedRealPath.startsWith(`${resolvedScanDir}\\`);
39755
+ const resolvedScanDir = path22.resolve(scanDir);
39756
+ const resolvedRealPath = path22.resolve(realPath);
39757
+ return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir + path22.sep) || resolvedRealPath.startsWith(`${resolvedScanDir}/`) || resolvedRealPath.startsWith(`${resolvedScanDir}\\`);
39713
39758
  }
39714
39759
  function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, stats = {
39715
39760
  skippedDirs: 0,
@@ -39720,7 +39765,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
39720
39765
  const files = [];
39721
39766
  let entries;
39722
39767
  try {
39723
- entries = fs11.readdirSync(dir);
39768
+ entries = fs12.readdirSync(dir);
39724
39769
  } catch {
39725
39770
  stats.fileErrors++;
39726
39771
  return files;
@@ -39735,15 +39780,15 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
39735
39780
  return a.localeCompare(b);
39736
39781
  });
39737
39782
  for (const entry of entries) {
39738
- const fullPath = path21.join(dir, entry);
39739
- const relPath = path21.relative(scanDir, fullPath).replace(/\\/g, "/");
39783
+ const fullPath = path22.join(dir, entry);
39784
+ const relPath = path22.relative(scanDir, fullPath).replace(/\\/g, "/");
39740
39785
  if (isExcluded(entry, relPath, excludeExact, excludeGlobs)) {
39741
39786
  stats.skippedDirs++;
39742
39787
  continue;
39743
39788
  }
39744
39789
  let lstat;
39745
39790
  try {
39746
- lstat = fs11.lstatSync(fullPath);
39791
+ lstat = fs12.lstatSync(fullPath);
39747
39792
  } catch {
39748
39793
  stats.fileErrors++;
39749
39794
  continue;
@@ -39755,7 +39800,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
39755
39800
  if (lstat.isDirectory()) {
39756
39801
  let realPath;
39757
39802
  try {
39758
- realPath = fs11.realpathSync(fullPath);
39803
+ realPath = fs12.realpathSync(fullPath);
39759
39804
  } catch {
39760
39805
  stats.fileErrors++;
39761
39806
  continue;
@@ -39771,7 +39816,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
39771
39816
  const subFiles = findScannableFiles(fullPath, excludeExact, excludeGlobs, scanDir, visited, stats);
39772
39817
  files.push(...subFiles);
39773
39818
  } else if (lstat.isFile()) {
39774
- const ext = path21.extname(fullPath).toLowerCase();
39819
+ const ext = path22.extname(fullPath).toLowerCase();
39775
39820
  if (!DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
39776
39821
  files.push(fullPath);
39777
39822
  } else {
@@ -39837,15 +39882,15 @@ var secretscan = createSwarmTool({
39837
39882
  }
39838
39883
  }
39839
39884
  try {
39840
- const _scanDirRaw = path21.resolve(directory);
39885
+ const _scanDirRaw = path22.resolve(directory);
39841
39886
  const scanDir = (() => {
39842
39887
  try {
39843
- return fs11.realpathSync(_scanDirRaw);
39888
+ return fs12.realpathSync(_scanDirRaw);
39844
39889
  } catch {
39845
39890
  return _scanDirRaw;
39846
39891
  }
39847
39892
  })();
39848
- if (!fs11.existsSync(scanDir)) {
39893
+ if (!fs12.existsSync(scanDir)) {
39849
39894
  const errorResult = {
39850
39895
  error: "directory not found",
39851
39896
  scan_dir: directory,
@@ -39856,7 +39901,7 @@ var secretscan = createSwarmTool({
39856
39901
  };
39857
39902
  return JSON.stringify(errorResult, null, 2);
39858
39903
  }
39859
- const dirStat = fs11.statSync(scanDir);
39904
+ const dirStat = fs12.statSync(scanDir);
39860
39905
  if (!dirStat.isDirectory()) {
39861
39906
  const errorResult = {
39862
39907
  error: "target must be a directory, not a file",
@@ -39907,7 +39952,7 @@ var secretscan = createSwarmTool({
39907
39952
  break;
39908
39953
  const fileFindings = scanFileForSecrets(filePath);
39909
39954
  try {
39910
- const stat2 = fs11.statSync(filePath);
39955
+ const stat2 = fs12.statSync(filePath);
39911
39956
  if (stat2.size > MAX_FILE_SIZE_BYTES) {
39912
39957
  skippedFiles++;
39913
39958
  continue;
@@ -39994,12 +40039,12 @@ async function runSecretscan(directory) {
39994
40039
  }
39995
40040
 
39996
40041
  // src/tools/test-runner.ts
39997
- import * as fs15 from "fs";
39998
- import * as path25 from "path";
40042
+ import * as fs16 from "fs";
40043
+ import * as path26 from "path";
39999
40044
 
40000
40045
  // src/test-impact/analyzer.ts
40001
- import fs12 from "fs";
40002
- import path22 from "path";
40046
+ import fs13 from "fs";
40047
+ import path23 from "path";
40003
40048
  var IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
40004
40049
  var IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
40005
40050
  var IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
@@ -40010,7 +40055,7 @@ function normalizePath(p) {
40010
40055
  function isCacheStale(impactMap, generatedAtMs) {
40011
40056
  for (const sourcePath of Object.keys(impactMap)) {
40012
40057
  try {
40013
- const stat2 = fs12.statSync(sourcePath);
40058
+ const stat2 = fs13.statSync(sourcePath);
40014
40059
  if (stat2.mtimeMs > generatedAtMs) {
40015
40060
  return true;
40016
40061
  }
@@ -40024,15 +40069,15 @@ function resolveRelativeImport(fromDir, importPath) {
40024
40069
  if (!importPath.startsWith(".")) {
40025
40070
  return null;
40026
40071
  }
40027
- const resolved = path22.resolve(fromDir, importPath);
40028
- if (path22.extname(resolved)) {
40029
- if (fs12.existsSync(resolved) && fs12.statSync(resolved).isFile()) {
40072
+ const resolved = path23.resolve(fromDir, importPath);
40073
+ if (path23.extname(resolved)) {
40074
+ if (fs13.existsSync(resolved) && fs13.statSync(resolved).isFile()) {
40030
40075
  return normalizePath(resolved);
40031
40076
  }
40032
40077
  } else {
40033
40078
  for (const ext of EXTENSIONS_TO_TRY) {
40034
40079
  const withExt = resolved + ext;
40035
- if (fs12.existsSync(withExt) && fs12.statSync(withExt).isFile()) {
40080
+ if (fs13.existsSync(withExt) && fs13.statSync(withExt).isFile()) {
40036
40081
  return normalizePath(withExt);
40037
40082
  }
40038
40083
  }
@@ -40051,13 +40096,13 @@ function findTestFilesSync(cwd) {
40051
40096
  function walk(dir, visitedInodes) {
40052
40097
  let entries;
40053
40098
  try {
40054
- entries = fs12.readdirSync(dir, { withFileTypes: true });
40099
+ entries = fs13.readdirSync(dir, { withFileTypes: true });
40055
40100
  } catch {
40056
40101
  return;
40057
40102
  }
40058
40103
  let dirInode;
40059
40104
  try {
40060
- dirInode = fs12.statSync(dir).ino;
40105
+ dirInode = fs13.statSync(dir).ino;
40061
40106
  } catch {
40062
40107
  return;
40063
40108
  }
@@ -40070,12 +40115,12 @@ function findTestFilesSync(cwd) {
40070
40115
  for (const entry of entries) {
40071
40116
  if (entry.isDirectory()) {
40072
40117
  if (!skipDirs.has(entry.name)) {
40073
- walk(path22.join(dir, entry.name), visitedInodes);
40118
+ walk(path23.join(dir, entry.name), visitedInodes);
40074
40119
  }
40075
40120
  } else if (entry.isFile()) {
40076
40121
  const name = entry.name;
40077
40122
  if (/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(name) || dir.includes("__tests__") && /\.(ts|tsx|js|jsx)$/.test(name)) {
40078
- testFiles.push(normalizePath(path22.join(dir, entry.name)));
40123
+ testFiles.push(normalizePath(path23.join(dir, entry.name)));
40079
40124
  }
40080
40125
  }
40081
40126
  }
@@ -40105,7 +40150,7 @@ async function buildImpactMapInternal(cwd) {
40105
40150
  for (const testFile of testFiles) {
40106
40151
  let content;
40107
40152
  try {
40108
- content = fs12.readFileSync(testFile, "utf-8");
40153
+ content = fs13.readFileSync(testFile, "utf-8");
40109
40154
  } catch {
40110
40155
  continue;
40111
40156
  }
@@ -40113,7 +40158,7 @@ async function buildImpactMapInternal(cwd) {
40113
40158
  continue;
40114
40159
  }
40115
40160
  const imports = extractImports(content);
40116
- const testDir = path22.dirname(testFile);
40161
+ const testDir = path23.dirname(testFile);
40117
40162
  for (const importPath of imports) {
40118
40163
  const resolvedSource = resolveRelativeImport(testDir, importPath);
40119
40164
  if (resolvedSource === null) {
@@ -40135,10 +40180,10 @@ async function buildImpactMap(cwd) {
40135
40180
  return impactMap;
40136
40181
  }
40137
40182
  async function loadImpactMap(cwd) {
40138
- const cachePath = path22.join(cwd, ".swarm", "cache", "impact-map.json");
40139
- if (fs12.existsSync(cachePath)) {
40183
+ const cachePath = path23.join(cwd, ".swarm", "cache", "impact-map.json");
40184
+ if (fs13.existsSync(cachePath)) {
40140
40185
  try {
40141
- const content = fs12.readFileSync(cachePath, "utf-8");
40186
+ const content = fs13.readFileSync(cachePath, "utf-8");
40142
40187
  const data = JSON.parse(content);
40143
40188
  const map3 = data.map;
40144
40189
  const generatedAt = new Date(data.generatedAt).getTime();
@@ -40150,17 +40195,17 @@ async function loadImpactMap(cwd) {
40150
40195
  return buildImpactMap(cwd);
40151
40196
  }
40152
40197
  async function saveImpactMap(cwd, impactMap) {
40153
- const cacheDir = path22.join(cwd, ".swarm", "cache");
40154
- const cachePath = path22.join(cacheDir, "impact-map.json");
40155
- if (!fs12.existsSync(cacheDir)) {
40156
- fs12.mkdirSync(cacheDir, { recursive: true });
40198
+ const cacheDir = path23.join(cwd, ".swarm", "cache");
40199
+ const cachePath = path23.join(cacheDir, "impact-map.json");
40200
+ if (!fs13.existsSync(cacheDir)) {
40201
+ fs13.mkdirSync(cacheDir, { recursive: true });
40157
40202
  }
40158
40203
  const data = {
40159
40204
  generatedAt: new Date().toISOString(),
40160
40205
  fileCount: Object.keys(impactMap).length,
40161
40206
  map: impactMap
40162
40207
  };
40163
- fs12.writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
40208
+ fs13.writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
40164
40209
  }
40165
40210
  async function analyzeImpact(changedFiles, cwd) {
40166
40211
  if (!Array.isArray(changedFiles)) {
@@ -40177,7 +40222,7 @@ async function analyzeImpact(changedFiles, cwd) {
40177
40222
  const impactedTestsSet = new Set;
40178
40223
  const untestedFiles = [];
40179
40224
  for (const changedFile of validFiles) {
40180
- const normalizedChanged = normalizePath(path22.resolve(changedFile));
40225
+ const normalizedChanged = normalizePath(path23.resolve(changedFile));
40181
40226
  const tests = impactMap[normalizedChanged];
40182
40227
  if (tests && tests.length > 0) {
40183
40228
  for (const test of tests) {
@@ -40423,14 +40468,14 @@ function detectFlakyTests(allHistory) {
40423
40468
  }
40424
40469
 
40425
40470
  // src/test-impact/history-store.ts
40426
- import fs13 from "fs";
40427
- import path23 from "path";
40471
+ import fs14 from "fs";
40472
+ import path24 from "path";
40428
40473
  var MAX_HISTORY_PER_TEST = 20;
40429
40474
  var MAX_ERROR_LENGTH = 500;
40430
40475
  var MAX_STACK_LENGTH = 200;
40431
40476
  var MAX_CHANGED_FILES = 50;
40432
40477
  function getHistoryPath(workingDir) {
40433
- return path23.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
40478
+ return path24.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
40434
40479
  }
40435
40480
  function sanitizeErrorMessage(errorMessage) {
40436
40481
  if (errorMessage === undefined) {
@@ -40490,9 +40535,9 @@ function appendTestRun(record3, workingDir) {
40490
40535
  changedFiles: sanitizeChangedFiles(record3.changedFiles || [])
40491
40536
  };
40492
40537
  const historyPath = getHistoryPath(workingDir);
40493
- const historyDir = path23.dirname(historyPath);
40494
- if (!fs13.existsSync(historyDir)) {
40495
- fs13.mkdirSync(historyDir, { recursive: true });
40538
+ const historyDir = path24.dirname(historyPath);
40539
+ if (!fs14.existsSync(historyDir)) {
40540
+ fs14.mkdirSync(historyDir, { recursive: true });
40496
40541
  }
40497
40542
  const existingRecords = readAllRecords(historyPath);
40498
40543
  existingRecords.push(sanitizedRecord);
@@ -40517,24 +40562,24 @@ function appendTestRun(record3, workingDir) {
40517
40562
  `) + `
40518
40563
  `;
40519
40564
  const tempPath = historyPath + ".tmp";
40520
- fs13.writeFileSync(tempPath, content, "utf-8");
40521
- fs13.renameSync(tempPath, historyPath);
40565
+ fs14.writeFileSync(tempPath, content, "utf-8");
40566
+ fs14.renameSync(tempPath, historyPath);
40522
40567
  } catch (err) {
40523
40568
  try {
40524
40569
  const tempPath = historyPath + ".tmp";
40525
- if (fs13.existsSync(tempPath)) {
40526
- fs13.unlinkSync(tempPath);
40570
+ if (fs14.existsSync(tempPath)) {
40571
+ fs14.unlinkSync(tempPath);
40527
40572
  }
40528
40573
  } catch {}
40529
40574
  throw new Error(`Failed to write test history: ${err instanceof Error ? err.message : String(err)}`);
40530
40575
  }
40531
40576
  }
40532
40577
  function readAllRecords(historyPath) {
40533
- if (!fs13.existsSync(historyPath)) {
40578
+ if (!fs14.existsSync(historyPath)) {
40534
40579
  return [];
40535
40580
  }
40536
40581
  try {
40537
- const content = fs13.readFileSync(historyPath, "utf-8");
40582
+ const content = fs14.readFileSync(historyPath, "utf-8");
40538
40583
  const lines = content.split(`
40539
40584
  `);
40540
40585
  const records = [];
@@ -40563,8 +40608,8 @@ function getAllHistory(workingDir) {
40563
40608
  }
40564
40609
 
40565
40610
  // src/tools/resolve-working-directory.ts
40566
- import * as fs14 from "fs";
40567
- import * as path24 from "path";
40611
+ import * as fs15 from "fs";
40612
+ import * as path25 from "path";
40568
40613
  function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
40569
40614
  if (workingDirectory == null || workingDirectory === "") {
40570
40615
  return { success: true, directory: fallbackDirectory };
@@ -40584,17 +40629,17 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
40584
40629
  };
40585
40630
  }
40586
40631
  }
40587
- const normalizedDir = path24.normalize(workingDirectory);
40588
- const pathParts = normalizedDir.split(path24.sep);
40632
+ const normalizedDir = path25.normalize(workingDirectory);
40633
+ const pathParts = normalizedDir.split(path25.sep);
40589
40634
  if (pathParts.includes("..")) {
40590
40635
  return {
40591
40636
  success: false,
40592
40637
  message: "Invalid working_directory: path traversal sequences (..) are not allowed"
40593
40638
  };
40594
40639
  }
40595
- const resolvedDir = path24.resolve(normalizedDir);
40640
+ const resolvedDir = path25.resolve(normalizedDir);
40596
40641
  try {
40597
- const realPath = fs14.realpathSync(resolvedDir);
40642
+ const realPath = fs15.realpathSync(resolvedDir);
40598
40643
  return { success: true, directory: realPath };
40599
40644
  } catch {
40600
40645
  return {
@@ -40675,19 +40720,19 @@ function hasDevDependency(devDeps, ...patterns) {
40675
40720
  return hasPackageJsonDependency(devDeps, ...patterns);
40676
40721
  }
40677
40722
  function detectGoTest(cwd) {
40678
- return fs15.existsSync(path25.join(cwd, "go.mod")) && isCommandAvailable("go");
40723
+ return fs16.existsSync(path26.join(cwd, "go.mod")) && isCommandAvailable("go");
40679
40724
  }
40680
40725
  function detectJavaMaven(cwd) {
40681
- return fs15.existsSync(path25.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
40726
+ return fs16.existsSync(path26.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
40682
40727
  }
40683
40728
  function detectGradle(cwd) {
40684
- const hasBuildFile = fs15.existsSync(path25.join(cwd, "build.gradle")) || fs15.existsSync(path25.join(cwd, "build.gradle.kts"));
40685
- const hasGradlew = fs15.existsSync(path25.join(cwd, "gradlew")) || fs15.existsSync(path25.join(cwd, "gradlew.bat"));
40729
+ const hasBuildFile = fs16.existsSync(path26.join(cwd, "build.gradle")) || fs16.existsSync(path26.join(cwd, "build.gradle.kts"));
40730
+ const hasGradlew = fs16.existsSync(path26.join(cwd, "gradlew")) || fs16.existsSync(path26.join(cwd, "gradlew.bat"));
40686
40731
  return hasBuildFile && (hasGradlew || isCommandAvailable("gradle"));
40687
40732
  }
40688
40733
  function detectDotnetTest(cwd) {
40689
40734
  try {
40690
- const files = fs15.readdirSync(cwd);
40735
+ const files = fs16.readdirSync(cwd);
40691
40736
  const hasCsproj = files.some((f) => f.endsWith(".csproj"));
40692
40737
  return hasCsproj && isCommandAvailable("dotnet");
40693
40738
  } catch {
@@ -40695,32 +40740,32 @@ function detectDotnetTest(cwd) {
40695
40740
  }
40696
40741
  }
40697
40742
  function detectCTest(cwd) {
40698
- const hasSource = fs15.existsSync(path25.join(cwd, "CMakeLists.txt"));
40699
- const hasBuildCache = fs15.existsSync(path25.join(cwd, "CMakeCache.txt")) || fs15.existsSync(path25.join(cwd, "build", "CMakeCache.txt"));
40743
+ const hasSource = fs16.existsSync(path26.join(cwd, "CMakeLists.txt"));
40744
+ const hasBuildCache = fs16.existsSync(path26.join(cwd, "CMakeCache.txt")) || fs16.existsSync(path26.join(cwd, "build", "CMakeCache.txt"));
40700
40745
  return (hasSource || hasBuildCache) && isCommandAvailable("ctest");
40701
40746
  }
40702
40747
  function detectSwiftTest(cwd) {
40703
- return fs15.existsSync(path25.join(cwd, "Package.swift")) && isCommandAvailable("swift");
40748
+ return fs16.existsSync(path26.join(cwd, "Package.swift")) && isCommandAvailable("swift");
40704
40749
  }
40705
40750
  function detectDartTest(cwd) {
40706
- return fs15.existsSync(path25.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
40751
+ return fs16.existsSync(path26.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
40707
40752
  }
40708
40753
  function detectRSpec(cwd) {
40709
- const hasRSpecFile = fs15.existsSync(path25.join(cwd, ".rspec"));
40710
- const hasGemfile = fs15.existsSync(path25.join(cwd, "Gemfile"));
40711
- const hasSpecDir = fs15.existsSync(path25.join(cwd, "spec"));
40754
+ const hasRSpecFile = fs16.existsSync(path26.join(cwd, ".rspec"));
40755
+ const hasGemfile = fs16.existsSync(path26.join(cwd, "Gemfile"));
40756
+ const hasSpecDir = fs16.existsSync(path26.join(cwd, "spec"));
40712
40757
  const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
40713
40758
  return hasRSpec && (isCommandAvailable("bundle") || isCommandAvailable("rspec"));
40714
40759
  }
40715
40760
  function detectMinitest(cwd) {
40716
- return fs15.existsSync(path25.join(cwd, "test")) && (fs15.existsSync(path25.join(cwd, "Gemfile")) || fs15.existsSync(path25.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
40761
+ return fs16.existsSync(path26.join(cwd, "test")) && (fs16.existsSync(path26.join(cwd, "Gemfile")) || fs16.existsSync(path26.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
40717
40762
  }
40718
40763
  async function detectTestFramework(cwd) {
40719
40764
  const baseDir = cwd;
40720
40765
  try {
40721
- const packageJsonPath = path25.join(baseDir, "package.json");
40722
- if (fs15.existsSync(packageJsonPath)) {
40723
- const content = fs15.readFileSync(packageJsonPath, "utf-8");
40766
+ const packageJsonPath = path26.join(baseDir, "package.json");
40767
+ if (fs16.existsSync(packageJsonPath)) {
40768
+ const content = fs16.readFileSync(packageJsonPath, "utf-8");
40724
40769
  const pkg = JSON.parse(content);
40725
40770
  const _deps = pkg.dependencies || {};
40726
40771
  const devDeps = pkg.devDependencies || {};
@@ -40739,38 +40784,38 @@ async function detectTestFramework(cwd) {
40739
40784
  return "jest";
40740
40785
  if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
40741
40786
  return "mocha";
40742
- if (fs15.existsSync(path25.join(baseDir, "bun.lockb")) || fs15.existsSync(path25.join(baseDir, "bun.lock"))) {
40787
+ if (fs16.existsSync(path26.join(baseDir, "bun.lockb")) || fs16.existsSync(path26.join(baseDir, "bun.lock"))) {
40743
40788
  if (scripts.test?.includes("bun"))
40744
40789
  return "bun";
40745
40790
  }
40746
40791
  }
40747
40792
  } catch {}
40748
40793
  try {
40749
- const pyprojectTomlPath = path25.join(baseDir, "pyproject.toml");
40750
- const setupCfgPath = path25.join(baseDir, "setup.cfg");
40751
- const requirementsTxtPath = path25.join(baseDir, "requirements.txt");
40752
- if (fs15.existsSync(pyprojectTomlPath)) {
40753
- const content = fs15.readFileSync(pyprojectTomlPath, "utf-8");
40794
+ const pyprojectTomlPath = path26.join(baseDir, "pyproject.toml");
40795
+ const setupCfgPath = path26.join(baseDir, "setup.cfg");
40796
+ const requirementsTxtPath = path26.join(baseDir, "requirements.txt");
40797
+ if (fs16.existsSync(pyprojectTomlPath)) {
40798
+ const content = fs16.readFileSync(pyprojectTomlPath, "utf-8");
40754
40799
  if (content.includes("[tool.pytest"))
40755
40800
  return "pytest";
40756
40801
  if (content.includes("pytest"))
40757
40802
  return "pytest";
40758
40803
  }
40759
- if (fs15.existsSync(setupCfgPath)) {
40760
- const content = fs15.readFileSync(setupCfgPath, "utf-8");
40804
+ if (fs16.existsSync(setupCfgPath)) {
40805
+ const content = fs16.readFileSync(setupCfgPath, "utf-8");
40761
40806
  if (content.includes("[pytest]"))
40762
40807
  return "pytest";
40763
40808
  }
40764
- if (fs15.existsSync(requirementsTxtPath)) {
40765
- const content = fs15.readFileSync(requirementsTxtPath, "utf-8");
40809
+ if (fs16.existsSync(requirementsTxtPath)) {
40810
+ const content = fs16.readFileSync(requirementsTxtPath, "utf-8");
40766
40811
  if (content.includes("pytest"))
40767
40812
  return "pytest";
40768
40813
  }
40769
40814
  } catch {}
40770
40815
  try {
40771
- const cargoTomlPath = path25.join(baseDir, "Cargo.toml");
40772
- if (fs15.existsSync(cargoTomlPath)) {
40773
- const content = fs15.readFileSync(cargoTomlPath, "utf-8");
40816
+ const cargoTomlPath = path26.join(baseDir, "Cargo.toml");
40817
+ if (fs16.existsSync(cargoTomlPath)) {
40818
+ const content = fs16.readFileSync(cargoTomlPath, "utf-8");
40774
40819
  if (content.includes("[dev-dependencies]")) {
40775
40820
  if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
40776
40821
  return "cargo";
@@ -40779,10 +40824,10 @@ async function detectTestFramework(cwd) {
40779
40824
  }
40780
40825
  } catch {}
40781
40826
  try {
40782
- const pesterConfigPath = path25.join(baseDir, "pester.config.ps1");
40783
- const pesterConfigJsonPath = path25.join(baseDir, "pester.config.ps1.json");
40784
- const pesterPs1Path = path25.join(baseDir, "tests.ps1");
40785
- if (fs15.existsSync(pesterConfigPath) || fs15.existsSync(pesterConfigJsonPath) || fs15.existsSync(pesterPs1Path)) {
40827
+ const pesterConfigPath = path26.join(baseDir, "pester.config.ps1");
40828
+ const pesterConfigJsonPath = path26.join(baseDir, "pester.config.ps1.json");
40829
+ const pesterPs1Path = path26.join(baseDir, "tests.ps1");
40830
+ if (fs16.existsSync(pesterConfigPath) || fs16.existsSync(pesterConfigJsonPath) || fs16.existsSync(pesterPs1Path)) {
40786
40831
  return "pester";
40787
40832
  }
40788
40833
  } catch {}
@@ -40833,8 +40878,8 @@ function getTestFilesFromConvention(sourceFiles) {
40833
40878
  const testFiles = [];
40834
40879
  for (const file3 of sourceFiles) {
40835
40880
  const normalizedPath = file3.replace(/\\/g, "/");
40836
- const basename4 = path25.basename(file3);
40837
- const dirname10 = path25.dirname(file3);
40881
+ const basename4 = path26.basename(file3);
40882
+ const dirname10 = path26.dirname(file3);
40838
40883
  if (hasCompoundTestExtension(basename4) || basename4.includes(".spec.") || basename4.includes(".test.") || normalizedPath.includes("/__tests__/") || normalizedPath.includes("/tests/") || normalizedPath.includes("/test/")) {
40839
40884
  if (!testFiles.includes(file3)) {
40840
40885
  testFiles.push(file3);
@@ -40843,16 +40888,16 @@ function getTestFilesFromConvention(sourceFiles) {
40843
40888
  }
40844
40889
  for (const _pattern of TEST_PATTERNS) {
40845
40890
  const nameWithoutExt = basename4.replace(/\.[^.]+$/, "");
40846
- const ext = path25.extname(basename4);
40891
+ const ext = path26.extname(basename4);
40847
40892
  const possibleTestFiles = [
40848
- path25.join(dirname10, `${nameWithoutExt}.spec${ext}`),
40849
- path25.join(dirname10, `${nameWithoutExt}.test${ext}`),
40850
- path25.join(dirname10, "__tests__", `${nameWithoutExt}${ext}`),
40851
- path25.join(dirname10, "tests", `${nameWithoutExt}${ext}`),
40852
- path25.join(dirname10, "test", `${nameWithoutExt}${ext}`)
40893
+ path26.join(dirname10, `${nameWithoutExt}.spec${ext}`),
40894
+ path26.join(dirname10, `${nameWithoutExt}.test${ext}`),
40895
+ path26.join(dirname10, "__tests__", `${nameWithoutExt}${ext}`),
40896
+ path26.join(dirname10, "tests", `${nameWithoutExt}${ext}`),
40897
+ path26.join(dirname10, "test", `${nameWithoutExt}${ext}`)
40853
40898
  ];
40854
40899
  for (const testFile of possibleTestFiles) {
40855
- if (fs15.existsSync(testFile) && !testFiles.includes(testFile)) {
40900
+ if (fs16.existsSync(testFile) && !testFiles.includes(testFile)) {
40856
40901
  testFiles.push(testFile);
40857
40902
  }
40858
40903
  }
@@ -40868,8 +40913,8 @@ async function getTestFilesFromGraph(sourceFiles) {
40868
40913
  }
40869
40914
  for (const testFile of candidateTestFiles) {
40870
40915
  try {
40871
- const content = fs15.readFileSync(testFile, "utf-8");
40872
- const testDir = path25.dirname(testFile);
40916
+ const content = fs16.readFileSync(testFile, "utf-8");
40917
+ const testDir = path26.dirname(testFile);
40873
40918
  const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
40874
40919
  let match;
40875
40920
  match = importRegex.exec(content);
@@ -40877,8 +40922,8 @@ async function getTestFilesFromGraph(sourceFiles) {
40877
40922
  const importPath = match[1];
40878
40923
  let resolvedImport;
40879
40924
  if (importPath.startsWith(".")) {
40880
- resolvedImport = path25.resolve(testDir, importPath);
40881
- const existingExt = path25.extname(resolvedImport);
40925
+ resolvedImport = path26.resolve(testDir, importPath);
40926
+ const existingExt = path26.extname(resolvedImport);
40882
40927
  if (!existingExt) {
40883
40928
  for (const extToTry of [
40884
40929
  ".ts",
@@ -40889,7 +40934,7 @@ async function getTestFilesFromGraph(sourceFiles) {
40889
40934
  ".cjs"
40890
40935
  ]) {
40891
40936
  const withExt = resolvedImport + extToTry;
40892
- if (sourceFiles.includes(withExt) || fs15.existsSync(withExt)) {
40937
+ if (sourceFiles.includes(withExt) || fs16.existsSync(withExt)) {
40893
40938
  resolvedImport = withExt;
40894
40939
  break;
40895
40940
  }
@@ -40898,12 +40943,12 @@ async function getTestFilesFromGraph(sourceFiles) {
40898
40943
  } else {
40899
40944
  continue;
40900
40945
  }
40901
- const importBasename = path25.basename(resolvedImport, path25.extname(resolvedImport));
40902
- const importDir = path25.dirname(resolvedImport);
40946
+ const importBasename = path26.basename(resolvedImport, path26.extname(resolvedImport));
40947
+ const importDir = path26.dirname(resolvedImport);
40903
40948
  for (const sourceFile of sourceFiles) {
40904
- const sourceDir = path25.dirname(sourceFile);
40905
- const sourceBasename = path25.basename(sourceFile, path25.extname(sourceFile));
40906
- const isRelatedDir = importDir === sourceDir || importDir === path25.join(sourceDir, "__tests__") || importDir === path25.join(sourceDir, "tests") || importDir === path25.join(sourceDir, "test");
40949
+ const sourceDir = path26.dirname(sourceFile);
40950
+ const sourceBasename = path26.basename(sourceFile, path26.extname(sourceFile));
40951
+ const isRelatedDir = importDir === sourceDir || importDir === path26.join(sourceDir, "__tests__") || importDir === path26.join(sourceDir, "tests") || importDir === path26.join(sourceDir, "test");
40907
40952
  if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
40908
40953
  if (!testFiles.includes(testFile)) {
40909
40954
  testFiles.push(testFile);
@@ -40918,8 +40963,8 @@ async function getTestFilesFromGraph(sourceFiles) {
40918
40963
  while (match !== null) {
40919
40964
  const importPath = match[1];
40920
40965
  if (importPath.startsWith(".")) {
40921
- let resolvedImport = path25.resolve(testDir, importPath);
40922
- const existingExt = path25.extname(resolvedImport);
40966
+ let resolvedImport = path26.resolve(testDir, importPath);
40967
+ const existingExt = path26.extname(resolvedImport);
40923
40968
  if (!existingExt) {
40924
40969
  for (const extToTry of [
40925
40970
  ".ts",
@@ -40930,18 +40975,18 @@ async function getTestFilesFromGraph(sourceFiles) {
40930
40975
  ".cjs"
40931
40976
  ]) {
40932
40977
  const withExt = resolvedImport + extToTry;
40933
- if (sourceFiles.includes(withExt) || fs15.existsSync(withExt)) {
40978
+ if (sourceFiles.includes(withExt) || fs16.existsSync(withExt)) {
40934
40979
  resolvedImport = withExt;
40935
40980
  break;
40936
40981
  }
40937
40982
  }
40938
40983
  }
40939
- const importDir = path25.dirname(resolvedImport);
40940
- const importBasename = path25.basename(resolvedImport, path25.extname(resolvedImport));
40984
+ const importDir = path26.dirname(resolvedImport);
40985
+ const importBasename = path26.basename(resolvedImport, path26.extname(resolvedImport));
40941
40986
  for (const sourceFile of sourceFiles) {
40942
- const sourceDir = path25.dirname(sourceFile);
40943
- const sourceBasename = path25.basename(sourceFile, path25.extname(sourceFile));
40944
- const isRelatedDir = importDir === sourceDir || importDir === path25.join(sourceDir, "__tests__") || importDir === path25.join(sourceDir, "tests") || importDir === path25.join(sourceDir, "test");
40987
+ const sourceDir = path26.dirname(sourceFile);
40988
+ const sourceBasename = path26.basename(sourceFile, path26.extname(sourceFile));
40989
+ const isRelatedDir = importDir === sourceDir || importDir === path26.join(sourceDir, "__tests__") || importDir === path26.join(sourceDir, "tests") || importDir === path26.join(sourceDir, "test");
40945
40990
  if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
40946
40991
  if (!testFiles.includes(testFile)) {
40947
40992
  testFiles.push(testFile);
@@ -41026,8 +41071,8 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
41026
41071
  return ["mvn", "test"];
41027
41072
  case "gradle": {
41028
41073
  const isWindows = process.platform === "win32";
41029
- const hasGradlewBat = fs15.existsSync(path25.join(baseDir, "gradlew.bat"));
41030
- const hasGradlew = fs15.existsSync(path25.join(baseDir, "gradlew"));
41074
+ const hasGradlewBat = fs16.existsSync(path26.join(baseDir, "gradlew.bat"));
41075
+ const hasGradlew = fs16.existsSync(path26.join(baseDir, "gradlew"));
41031
41076
  if (hasGradlewBat && isWindows)
41032
41077
  return ["gradlew.bat", "test"];
41033
41078
  if (hasGradlew)
@@ -41044,7 +41089,7 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
41044
41089
  "cmake-build-release",
41045
41090
  "out"
41046
41091
  ];
41047
- const actualBuildDir = buildDirCandidates.find((d) => fs15.existsSync(path25.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
41092
+ const actualBuildDir = buildDirCandidates.find((d) => fs16.existsSync(path26.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
41048
41093
  return ["ctest", "--test-dir", actualBuildDir];
41049
41094
  }
41050
41095
  case "swift-test":
@@ -41647,7 +41692,7 @@ var test_runner = createSwarmTool({
41647
41692
  let effectiveScope = scope;
41648
41693
  if (scope === "all") {} else if (scope === "convention") {
41649
41694
  const sourceFiles = args.files.filter((f) => {
41650
- const ext = path25.extname(f).toLowerCase();
41695
+ const ext = path26.extname(f).toLowerCase();
41651
41696
  return SOURCE_EXTENSIONS.has(ext);
41652
41697
  });
41653
41698
  if (sourceFiles.length === 0) {
@@ -41664,7 +41709,7 @@ var test_runner = createSwarmTool({
41664
41709
  testFiles = getTestFilesFromConvention(sourceFiles);
41665
41710
  } else if (scope === "graph") {
41666
41711
  const sourceFiles = args.files.filter((f) => {
41667
- const ext = path25.extname(f).toLowerCase();
41712
+ const ext = path26.extname(f).toLowerCase();
41668
41713
  return SOURCE_EXTENSIONS.has(ext);
41669
41714
  });
41670
41715
  if (sourceFiles.length === 0) {
@@ -41688,7 +41733,7 @@ var test_runner = createSwarmTool({
41688
41733
  }
41689
41734
  } else if (scope === "impact") {
41690
41735
  const sourceFiles = args.files.filter((f) => {
41691
- const ext = path25.extname(f).toLowerCase();
41736
+ const ext = path26.extname(f).toLowerCase();
41692
41737
  return SOURCE_EXTENSIONS.has(ext);
41693
41738
  });
41694
41739
  if (sourceFiles.length === 0) {
@@ -41706,8 +41751,8 @@ var test_runner = createSwarmTool({
41706
41751
  const impactResult = await analyzeImpact(sourceFiles, workingDir);
41707
41752
  if (impactResult.impactedTests.length > 0) {
41708
41753
  testFiles = impactResult.impactedTests.map((absPath) => {
41709
- const relativePath = path25.relative(workingDir, absPath);
41710
- return path25.isAbsolute(relativePath) ? absPath : relativePath;
41754
+ const relativePath = path26.relative(workingDir, absPath);
41755
+ return path26.isAbsolute(relativePath) ? absPath : relativePath;
41711
41756
  });
41712
41757
  } else {
41713
41758
  graphFallbackReason = "no impacted tests found via impact analysis, falling back to graph";
@@ -41800,8 +41845,8 @@ function validateDirectoryPath(dir) {
41800
41845
  if (dir.includes("..")) {
41801
41846
  throw new Error("Directory path must not contain path traversal sequences");
41802
41847
  }
41803
- const normalized = path26.normalize(dir);
41804
- const absolutePath = path26.isAbsolute(normalized) ? normalized : path26.resolve(normalized);
41848
+ const normalized = path27.normalize(dir);
41849
+ const absolutePath = path27.isAbsolute(normalized) ? normalized : path27.resolve(normalized);
41805
41850
  return absolutePath;
41806
41851
  }
41807
41852
  function validateTimeout(timeoutMs, defaultValue) {
@@ -41824,9 +41869,9 @@ function validateTimeout(timeoutMs, defaultValue) {
41824
41869
  }
41825
41870
  function getPackageVersion(dir) {
41826
41871
  try {
41827
- const packagePath = path26.join(dir, "package.json");
41828
- if (fs16.existsSync(packagePath)) {
41829
- const content = fs16.readFileSync(packagePath, "utf-8");
41872
+ const packagePath = path27.join(dir, "package.json");
41873
+ if (fs17.existsSync(packagePath)) {
41874
+ const content = fs17.readFileSync(packagePath, "utf-8");
41830
41875
  const pkg = JSON.parse(content);
41831
41876
  return pkg.version ?? null;
41832
41877
  }
@@ -41835,9 +41880,9 @@ function getPackageVersion(dir) {
41835
41880
  }
41836
41881
  function getChangelogVersion(dir) {
41837
41882
  try {
41838
- const changelogPath = path26.join(dir, "CHANGELOG.md");
41839
- if (fs16.existsSync(changelogPath)) {
41840
- const content = fs16.readFileSync(changelogPath, "utf-8");
41883
+ const changelogPath = path27.join(dir, "CHANGELOG.md");
41884
+ if (fs17.existsSync(changelogPath)) {
41885
+ const content = fs17.readFileSync(changelogPath, "utf-8");
41841
41886
  const match = content.match(/^##\s*\[?(\d+\.\d+\.\d+)\]?/m);
41842
41887
  if (match) {
41843
41888
  return match[1];
@@ -41849,10 +41894,10 @@ function getChangelogVersion(dir) {
41849
41894
  function getVersionFileVersion(dir) {
41850
41895
  const possibleFiles = ["VERSION.txt", "version.txt", "VERSION", "version"];
41851
41896
  for (const file3 of possibleFiles) {
41852
- const filePath = path26.join(dir, file3);
41853
- if (fs16.existsSync(filePath)) {
41897
+ const filePath = path27.join(dir, file3);
41898
+ if (fs17.existsSync(filePath)) {
41854
41899
  try {
41855
- const content = fs16.readFileSync(filePath, "utf-8").trim();
41900
+ const content = fs17.readFileSync(filePath, "utf-8").trim();
41856
41901
  const match = content.match(/(\d+\.\d+\.\d+)/);
41857
41902
  if (match) {
41858
41903
  return match[1];
@@ -42176,8 +42221,8 @@ async function runEvidenceCheck(dir) {
42176
42221
  async function runRequirementCoverageCheck(dir, currentPhase) {
42177
42222
  const startTime = Date.now();
42178
42223
  try {
42179
- const specPath = path26.join(dir, ".swarm", "spec.md");
42180
- if (!fs16.existsSync(specPath)) {
42224
+ const specPath = path27.join(dir, ".swarm", "spec.md");
42225
+ if (!fs17.existsSync(specPath)) {
42181
42226
  return {
42182
42227
  type: "req_coverage",
42183
42228
  status: "skip",
@@ -42390,9 +42435,9 @@ async function handlePreflightCommand(directory, _args) {
42390
42435
  return formatPreflightMarkdown(report);
42391
42436
  }
42392
42437
  // src/knowledge/hive-promoter.ts
42393
- import * as fs17 from "fs";
42438
+ import * as fs18 from "fs";
42394
42439
  import * as os5 from "os";
42395
- import * as path27 from "path";
42440
+ import * as path28 from "path";
42396
42441
  var DANGEROUS_PATTERNS = [
42397
42442
  [/rm\s+-rf/, "rm\\s+-rf"],
42398
42443
  [/:\s*!\s*\|/, ":\\s*!\\s*\\|"],
@@ -42438,13 +42483,13 @@ function getHiveFilePath() {
42438
42483
  const home = os5.homedir();
42439
42484
  let dataDir;
42440
42485
  if (platform === "win32") {
42441
- dataDir = path27.join(process.env.LOCALAPPDATA || path27.join(home, "AppData", "Local"), "opencode-swarm", "Data");
42486
+ dataDir = path28.join(process.env.LOCALAPPDATA || path28.join(home, "AppData", "Local"), "opencode-swarm", "Data");
42442
42487
  } else if (platform === "darwin") {
42443
- dataDir = path27.join(home, "Library", "Application Support", "opencode-swarm");
42488
+ dataDir = path28.join(home, "Library", "Application Support", "opencode-swarm");
42444
42489
  } else {
42445
- dataDir = path27.join(process.env.XDG_DATA_HOME || path27.join(home, ".local", "share"), "opencode-swarm");
42490
+ dataDir = path28.join(process.env.XDG_DATA_HOME || path28.join(home, ".local", "share"), "opencode-swarm");
42446
42491
  }
42447
- return path27.join(dataDir, "hive-knowledge.jsonl");
42492
+ return path28.join(dataDir, "hive-knowledge.jsonl");
42448
42493
  }
42449
42494
  async function promoteToHive(_directory, lesson, category) {
42450
42495
  const trimmed = (lesson ?? "").trim();
@@ -42456,9 +42501,9 @@ async function promoteToHive(_directory, lesson, category) {
42456
42501
  throw new Error(`Lesson rejected by validator: ${validation.reason}`);
42457
42502
  }
42458
42503
  const hivePath = getHiveFilePath();
42459
- const hiveDir = path27.dirname(hivePath);
42460
- if (!fs17.existsSync(hiveDir)) {
42461
- fs17.mkdirSync(hiveDir, { recursive: true });
42504
+ const hiveDir = path28.dirname(hivePath);
42505
+ if (!fs18.existsSync(hiveDir)) {
42506
+ fs18.mkdirSync(hiveDir, { recursive: true });
42462
42507
  }
42463
42508
  const now = new Date;
42464
42509
  const entry = {
@@ -42472,16 +42517,16 @@ async function promoteToHive(_directory, lesson, category) {
42472
42517
  promotedAt: now.toISOString(),
42473
42518
  retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
42474
42519
  };
42475
- fs17.appendFileSync(hivePath, `${JSON.stringify(entry)}
42520
+ fs18.appendFileSync(hivePath, `${JSON.stringify(entry)}
42476
42521
  `, "utf-8");
42477
42522
  const preview = `${trimmed.slice(0, 50)}${trimmed.length > 50 ? "..." : ""}`;
42478
42523
  return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
42479
42524
  }
42480
42525
  async function promoteFromSwarm(directory, lessonId) {
42481
- const knowledgePath = path27.join(directory, ".swarm", "knowledge.jsonl");
42526
+ const knowledgePath = path28.join(directory, ".swarm", "knowledge.jsonl");
42482
42527
  const entries = [];
42483
- if (fs17.existsSync(knowledgePath)) {
42484
- const content = fs17.readFileSync(knowledgePath, "utf-8");
42528
+ if (fs18.existsSync(knowledgePath)) {
42529
+ const content = fs18.readFileSync(knowledgePath, "utf-8");
42485
42530
  for (const line of content.split(`
42486
42531
  `)) {
42487
42532
  const t = line.trim();
@@ -42505,9 +42550,9 @@ async function promoteFromSwarm(directory, lessonId) {
42505
42550
  throw new Error(`Lesson rejected by validator: ${validation.reason}`);
42506
42551
  }
42507
42552
  const hivePath = getHiveFilePath();
42508
- const hiveDir = path27.dirname(hivePath);
42509
- if (!fs17.existsSync(hiveDir)) {
42510
- fs17.mkdirSync(hiveDir, { recursive: true });
42553
+ const hiveDir = path28.dirname(hivePath);
42554
+ if (!fs18.existsSync(hiveDir)) {
42555
+ fs18.mkdirSync(hiveDir, { recursive: true });
42511
42556
  }
42512
42557
  const now = new Date;
42513
42558
  const hiveEntry = {
@@ -42521,7 +42566,7 @@ async function promoteFromSwarm(directory, lessonId) {
42521
42566
  promotedAt: now.toISOString(),
42522
42567
  retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
42523
42568
  };
42524
- fs17.appendFileSync(hivePath, `${JSON.stringify(hiveEntry)}
42569
+ fs18.appendFileSync(hivePath, `${JSON.stringify(hiveEntry)}
42525
42570
  `, "utf-8");
42526
42571
  const preview = `${lessonText.slice(0, 50)}${lessonText.length > 50 ? "..." : ""}`;
42527
42572
  return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
@@ -42579,8 +42624,8 @@ import { createHash as createHash4 } from "crypto";
42579
42624
 
42580
42625
  // src/db/project-db.ts
42581
42626
  import { Database } from "bun:sqlite";
42582
- import { existsSync as existsSync16, mkdirSync as mkdirSync7 } from "fs";
42583
- import { join as join22, resolve as resolve11 } from "path";
42627
+ import { existsSync as existsSync16, mkdirSync as mkdirSync8 } from "fs";
42628
+ import { join as join23, resolve as resolve11 } from "path";
42584
42629
  var MIGRATIONS = [
42585
42630
  {
42586
42631
  version: 1,
@@ -42639,7 +42684,7 @@ function runProjectMigrations(db) {
42639
42684
  }
42640
42685
  }
42641
42686
  function projectDbPath(directory) {
42642
- return join22(resolve11(directory), ".swarm", "swarm.db");
42687
+ return join23(resolve11(directory), ".swarm", "swarm.db");
42643
42688
  }
42644
42689
  function projectDbExists(directory) {
42645
42690
  return existsSync16(projectDbPath(directory));
@@ -42649,9 +42694,9 @@ function getProjectDb(directory) {
42649
42694
  const existing = _projectDbs.get(key);
42650
42695
  if (existing)
42651
42696
  return existing;
42652
- const swarmDir = join22(key, ".swarm");
42653
- mkdirSync7(swarmDir, { recursive: true });
42654
- const db = new Database(join22(swarmDir, "swarm.db"));
42697
+ const swarmDir = join23(key, ".swarm");
42698
+ mkdirSync8(swarmDir, { recursive: true });
42699
+ const db = new Database(join23(swarmDir, "swarm.db"));
42655
42700
  db.run("PRAGMA journal_mode = WAL;");
42656
42701
  db.run("PRAGMA synchronous = NORMAL;");
42657
42702
  db.run("PRAGMA busy_timeout = 5000;");
@@ -42893,7 +42938,7 @@ async function handleQaGatesCommand(directory, args, sessionID) {
42893
42938
  }
42894
42939
 
42895
42940
  // src/commands/reset.ts
42896
- import * as fs18 from "fs";
42941
+ import * as fs19 from "fs";
42897
42942
 
42898
42943
  // src/background/manager.ts
42899
42944
  init_utils();
@@ -43594,8 +43639,8 @@ async function handleResetCommand(directory, args) {
43594
43639
  for (const filename of filesToReset) {
43595
43640
  try {
43596
43641
  const resolvedPath = validateSwarmPath(directory, filename);
43597
- if (fs18.existsSync(resolvedPath)) {
43598
- fs18.unlinkSync(resolvedPath);
43642
+ if (fs19.existsSync(resolvedPath)) {
43643
+ fs19.unlinkSync(resolvedPath);
43599
43644
  results.push(`- \u2705 Deleted ${filename}`);
43600
43645
  } else {
43601
43646
  results.push(`- \u23ED\uFE0F ${filename} not found (skipped)`);
@@ -43612,8 +43657,8 @@ async function handleResetCommand(directory, args) {
43612
43657
  }
43613
43658
  try {
43614
43659
  const summariesPath = validateSwarmPath(directory, "summaries");
43615
- if (fs18.existsSync(summariesPath)) {
43616
- fs18.rmSync(summariesPath, { recursive: true, force: true });
43660
+ if (fs19.existsSync(summariesPath)) {
43661
+ fs19.rmSync(summariesPath, { recursive: true, force: true });
43617
43662
  results.push("- \u2705 Deleted summaries/ directory");
43618
43663
  } else {
43619
43664
  results.push("- \u23ED\uFE0F summaries/ not found (skipped)");
@@ -43633,14 +43678,14 @@ async function handleResetCommand(directory, args) {
43633
43678
 
43634
43679
  // src/commands/reset-session.ts
43635
43680
  init_utils2();
43636
- import * as fs19 from "fs";
43637
- import * as path28 from "path";
43681
+ import * as fs20 from "fs";
43682
+ import * as path29 from "path";
43638
43683
  async function handleResetSessionCommand(directory, _args) {
43639
43684
  const results = [];
43640
43685
  try {
43641
43686
  const statePath = validateSwarmPath(directory, "session/state.json");
43642
- if (fs19.existsSync(statePath)) {
43643
- fs19.unlinkSync(statePath);
43687
+ if (fs20.existsSync(statePath)) {
43688
+ fs20.unlinkSync(statePath);
43644
43689
  results.push("\u2705 Deleted .swarm/session/state.json");
43645
43690
  } else {
43646
43691
  results.push("\u23ED\uFE0F state.json not found (already clean)");
@@ -43649,15 +43694,15 @@ async function handleResetSessionCommand(directory, _args) {
43649
43694
  results.push("\u274C Failed to delete state.json");
43650
43695
  }
43651
43696
  try {
43652
- const sessionDir = path28.dirname(validateSwarmPath(directory, "session/state.json"));
43653
- if (fs19.existsSync(sessionDir)) {
43654
- const files = fs19.readdirSync(sessionDir);
43697
+ const sessionDir = path29.dirname(validateSwarmPath(directory, "session/state.json"));
43698
+ if (fs20.existsSync(sessionDir)) {
43699
+ const files = fs20.readdirSync(sessionDir);
43655
43700
  const otherFiles = files.filter((f) => f !== "state.json");
43656
43701
  let deletedCount = 0;
43657
43702
  for (const file3 of otherFiles) {
43658
- const filePath = path28.join(sessionDir, file3);
43659
- if (fs19.lstatSync(filePath).isFile()) {
43660
- fs19.unlinkSync(filePath);
43703
+ const filePath = path29.join(sessionDir, file3);
43704
+ if (fs20.lstatSync(filePath).isFile()) {
43705
+ fs20.unlinkSync(filePath);
43661
43706
  deletedCount++;
43662
43707
  }
43663
43708
  }
@@ -43685,7 +43730,7 @@ async function handleResetSessionCommand(directory, _args) {
43685
43730
  // src/summaries/manager.ts
43686
43731
  init_utils2();
43687
43732
  init_utils();
43688
- import * as path29 from "path";
43733
+ import * as path30 from "path";
43689
43734
  var SUMMARY_ID_REGEX = /^S\d+$/;
43690
43735
  function sanitizeSummaryId(id) {
43691
43736
  if (!id || id.length === 0) {
@@ -43709,7 +43754,7 @@ function sanitizeSummaryId(id) {
43709
43754
  }
43710
43755
  async function loadFullOutput(directory, id) {
43711
43756
  const sanitizedId = sanitizeSummaryId(id);
43712
- const relativePath = path29.join("summaries", `${sanitizedId}.json`);
43757
+ const relativePath = path30.join("summaries", `${sanitizedId}.json`);
43713
43758
  validateSwarmPath(directory, relativePath);
43714
43759
  const content = await readSwarmFileAsync(directory, relativePath);
43715
43760
  if (content === null) {
@@ -43762,18 +43807,18 @@ ${error93 instanceof Error ? error93.message : String(error93)}`;
43762
43807
 
43763
43808
  // src/commands/rollback.ts
43764
43809
  init_utils2();
43765
- import * as fs20 from "fs";
43766
- import * as path30 from "path";
43810
+ import * as fs21 from "fs";
43811
+ import * as path31 from "path";
43767
43812
  async function handleRollbackCommand(directory, args) {
43768
43813
  const phaseArg = args[0];
43769
43814
  if (!phaseArg) {
43770
43815
  const manifestPath2 = validateSwarmPath(directory, "checkpoints/manifest.json");
43771
- if (!fs20.existsSync(manifestPath2)) {
43816
+ if (!fs21.existsSync(manifestPath2)) {
43772
43817
  return "No checkpoints found. Use `/swarm checkpoint` to create checkpoints.";
43773
43818
  }
43774
43819
  let manifest2;
43775
43820
  try {
43776
- manifest2 = JSON.parse(fs20.readFileSync(manifestPath2, "utf-8"));
43821
+ manifest2 = JSON.parse(fs21.readFileSync(manifestPath2, "utf-8"));
43777
43822
  } catch {
43778
43823
  return "Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.";
43779
43824
  }
@@ -43795,12 +43840,12 @@ async function handleRollbackCommand(directory, args) {
43795
43840
  return "Error: Phase number must be a positive integer.";
43796
43841
  }
43797
43842
  const manifestPath = validateSwarmPath(directory, "checkpoints/manifest.json");
43798
- if (!fs20.existsSync(manifestPath)) {
43843
+ if (!fs21.existsSync(manifestPath)) {
43799
43844
  return `Error: No checkpoints found. Cannot rollback to phase ${targetPhase}.`;
43800
43845
  }
43801
43846
  let manifest;
43802
43847
  try {
43803
- manifest = JSON.parse(fs20.readFileSync(manifestPath, "utf-8"));
43848
+ manifest = JSON.parse(fs21.readFileSync(manifestPath, "utf-8"));
43804
43849
  } catch {
43805
43850
  return `Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.`;
43806
43851
  }
@@ -43810,10 +43855,10 @@ async function handleRollbackCommand(directory, args) {
43810
43855
  return `Error: Checkpoint for phase ${targetPhase} not found. Available phases: ${available}`;
43811
43856
  }
43812
43857
  const checkpointDir = validateSwarmPath(directory, `checkpoints/phase-${targetPhase}`);
43813
- if (!fs20.existsSync(checkpointDir)) {
43858
+ if (!fs21.existsSync(checkpointDir)) {
43814
43859
  return `Error: Checkpoint directory for phase ${targetPhase} does not exist.`;
43815
43860
  }
43816
- const checkpointFiles = fs20.readdirSync(checkpointDir);
43861
+ const checkpointFiles = fs21.readdirSync(checkpointDir);
43817
43862
  if (checkpointFiles.length === 0) {
43818
43863
  return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
43819
43864
  }
@@ -43821,10 +43866,10 @@ async function handleRollbackCommand(directory, args) {
43821
43866
  const successes = [];
43822
43867
  const failures = [];
43823
43868
  for (const file3 of checkpointFiles) {
43824
- const src = path30.join(checkpointDir, file3);
43825
- const dest = path30.join(swarmDir, file3);
43869
+ const src = path31.join(checkpointDir, file3);
43870
+ const dest = path31.join(swarmDir, file3);
43826
43871
  try {
43827
- fs20.cpSync(src, dest, { recursive: true, force: true });
43872
+ fs21.cpSync(src, dest, { recursive: true, force: true });
43828
43873
  successes.push(file3);
43829
43874
  } catch (error93) {
43830
43875
  failures.push({ file: file3, error: error93.message });
@@ -43841,7 +43886,7 @@ async function handleRollbackCommand(directory, args) {
43841
43886
  timestamp: new Date().toISOString()
43842
43887
  };
43843
43888
  try {
43844
- fs20.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
43889
+ fs21.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
43845
43890
  `);
43846
43891
  } catch (error93) {
43847
43892
  console.error("Failed to write rollback event:", error93 instanceof Error ? error93.message : String(error93));
@@ -43884,11 +43929,11 @@ async function handleSimulateCommand(directory, args) {
43884
43929
  ];
43885
43930
  const report = reportLines.filter(Boolean).join(`
43886
43931
  `);
43887
- const fs21 = await import("fs/promises");
43888
- const path31 = await import("path");
43889
- const reportPath = path31.join(directory, ".swarm", "simulate-report.md");
43890
- await fs21.mkdir(path31.dirname(reportPath), { recursive: true });
43891
- await fs21.writeFile(reportPath, report, "utf-8");
43932
+ const fs22 = await import("fs/promises");
43933
+ const path32 = await import("path");
43934
+ const reportPath = path32.join(directory, ".swarm", "simulate-report.md");
43935
+ await fs22.mkdir(path32.dirname(reportPath), { recursive: true });
43936
+ await fs22.writeFile(reportPath, report, "utf-8");
43892
43937
  return `${darkMatterPairs.length} hidden coupling pairs detected`;
43893
43938
  }
43894
43939
 
@@ -44411,18 +44456,18 @@ function resolveCommand(tokens) {
44411
44456
  }
44412
44457
 
44413
44458
  // src/cli/index.ts
44414
- var CONFIG_DIR = path31.join(process.env.XDG_CONFIG_HOME || path31.join(os6.homedir(), ".config"), "opencode");
44415
- var OPENCODE_CONFIG_PATH = path31.join(CONFIG_DIR, "opencode.json");
44416
- var PLUGIN_CONFIG_PATH = path31.join(CONFIG_DIR, "opencode-swarm.json");
44417
- var PROMPTS_DIR = path31.join(CONFIG_DIR, "opencode-swarm");
44459
+ var CONFIG_DIR = path32.join(process.env.XDG_CONFIG_HOME || path32.join(os6.homedir(), ".config"), "opencode");
44460
+ var OPENCODE_CONFIG_PATH = path32.join(CONFIG_DIR, "opencode.json");
44461
+ var PLUGIN_CONFIG_PATH = path32.join(CONFIG_DIR, "opencode-swarm.json");
44462
+ var PROMPTS_DIR = path32.join(CONFIG_DIR, "opencode-swarm");
44418
44463
  function ensureDir(dir) {
44419
- if (!fs21.existsSync(dir)) {
44420
- fs21.mkdirSync(dir, { recursive: true });
44464
+ if (!fs22.existsSync(dir)) {
44465
+ fs22.mkdirSync(dir, { recursive: true });
44421
44466
  }
44422
44467
  }
44423
44468
  function loadJson(filepath) {
44424
44469
  try {
44425
- const content = fs21.readFileSync(filepath, "utf-8");
44470
+ const content = fs22.readFileSync(filepath, "utf-8");
44426
44471
  const stripped = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, comment) => comment ? "" : match).replace(/,(\s*[}\]])/g, "$1");
44427
44472
  return JSON.parse(stripped);
44428
44473
  } catch {
@@ -44430,7 +44475,7 @@ function loadJson(filepath) {
44430
44475
  }
44431
44476
  }
44432
44477
  function saveJson(filepath, data) {
44433
- fs21.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
44478
+ fs22.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
44434
44479
  `, "utf-8");
44435
44480
  }
44436
44481
  async function install() {
@@ -44438,7 +44483,7 @@ async function install() {
44438
44483
  `);
44439
44484
  ensureDir(CONFIG_DIR);
44440
44485
  ensureDir(PROMPTS_DIR);
44441
- const LEGACY_CONFIG_PATH = path31.join(CONFIG_DIR, "config.json");
44486
+ const LEGACY_CONFIG_PATH = path32.join(CONFIG_DIR, "config.json");
44442
44487
  let opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
44443
44488
  if (!opencodeConfig) {
44444
44489
  const legacyConfig = loadJson(LEGACY_CONFIG_PATH);
@@ -44463,7 +44508,7 @@ async function install() {
44463
44508
  saveJson(OPENCODE_CONFIG_PATH, opencodeConfig);
44464
44509
  console.log("\u2713 Added opencode-swarm to OpenCode plugins");
44465
44510
  console.log("\u2713 Disabled default OpenCode agents (explore, general)");
44466
- if (!fs21.existsSync(PLUGIN_CONFIG_PATH)) {
44511
+ if (!fs22.existsSync(PLUGIN_CONFIG_PATH)) {
44467
44512
  const defaultConfig = {
44468
44513
  agents: {
44469
44514
  coder: { model: "opencode/minimax-m2.5-free" },
@@ -44506,7 +44551,7 @@ async function uninstall() {
44506
44551
  `);
44507
44552
  const opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
44508
44553
  if (!opencodeConfig) {
44509
- if (fs21.existsSync(OPENCODE_CONFIG_PATH)) {
44554
+ if (fs22.existsSync(OPENCODE_CONFIG_PATH)) {
44510
44555
  console.log(`\u2717 Could not parse opencode config at: ${OPENCODE_CONFIG_PATH}`);
44511
44556
  return 1;
44512
44557
  } else {
@@ -44538,13 +44583,13 @@ async function uninstall() {
44538
44583
  console.log("\u2713 Re-enabled default OpenCode agents (explore, general)");
44539
44584
  if (process.argv.includes("--clean")) {
44540
44585
  let cleaned = false;
44541
- if (fs21.existsSync(PLUGIN_CONFIG_PATH)) {
44542
- fs21.unlinkSync(PLUGIN_CONFIG_PATH);
44586
+ if (fs22.existsSync(PLUGIN_CONFIG_PATH)) {
44587
+ fs22.unlinkSync(PLUGIN_CONFIG_PATH);
44543
44588
  console.log(`\u2713 Removed plugin config: ${PLUGIN_CONFIG_PATH}`);
44544
44589
  cleaned = true;
44545
44590
  }
44546
- if (fs21.existsSync(PROMPTS_DIR)) {
44547
- fs21.rmSync(PROMPTS_DIR, { recursive: true });
44591
+ if (fs22.existsSync(PROMPTS_DIR)) {
44592
+ fs22.rmSync(PROMPTS_DIR, { recursive: true });
44548
44593
  console.log(`\u2713 Removed custom prompts: ${PROMPTS_DIR}`);
44549
44594
  cleaned = true;
44550
44595
  }