opencode-swarm 6.33.7 → 6.33.9

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.
Files changed (3) hide show
  1. package/dist/cli/index.js +306 -305
  2. package/dist/index.js +526 -520
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15413,7 +15413,8 @@ var init_utils2 = __esm(() => {
15413
15413
  });
15414
15414
 
15415
15415
  // src/evidence/manager.ts
15416
- import { mkdirSync, readdirSync, renameSync, rmSync, statSync as statSync2 } from "fs";
15416
+ import { mkdirSync, readdirSync, rmSync, statSync as statSync2 } from "fs";
15417
+ import * as fs4 from "fs/promises";
15417
15418
  import * as path4 from "path";
15418
15419
  function isValidEvidenceType(type) {
15419
15420
  return VALID_EVIDENCE_TYPES.includes(type);
@@ -15492,7 +15493,7 @@ async function saveEvidence(directory, taskId, evidence) {
15492
15493
  const tempPath = path4.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
15493
15494
  try {
15494
15495
  await Bun.write(tempPath, bundleJson);
15495
- renameSync(tempPath, evidencePath);
15496
+ await fs4.rename(tempPath, evidencePath);
15496
15497
  } catch (error49) {
15497
15498
  try {
15498
15499
  rmSync(tempPath, { force: true });
@@ -15548,7 +15549,7 @@ async function loadEvidence(directory, taskId) {
15548
15549
  const tempPath = path4.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
15549
15550
  try {
15550
15551
  await Bun.write(tempPath, bundleJson);
15551
- renameSync(tempPath, evidencePath);
15552
+ await fs4.rename(tempPath, evidencePath);
15552
15553
  } catch (writeError) {
15553
15554
  try {
15554
15555
  rmSync(tempPath, { force: true });
@@ -15687,7 +15688,7 @@ var init_manager = __esm(() => {
15687
15688
  });
15688
15689
 
15689
15690
  // src/plan/manager.ts
15690
- import { renameSync as renameSync2, unlinkSync } from "fs";
15691
+ import { renameSync, unlinkSync } from "fs";
15691
15692
  import * as path5 from "path";
15692
15693
  async function loadPlanJsonOnly(directory) {
15693
15694
  const planJsonContent = await readSwarmFileAsync(directory, "plan.json");
@@ -15779,7 +15780,7 @@ ${markdown}`;
15779
15780
  const mdTempPath = path5.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
15780
15781
  try {
15781
15782
  await Bun.write(mdTempPath, markdownWithHash);
15782
- renameSync2(mdTempPath, mdPath);
15783
+ renameSync(mdTempPath, mdPath);
15783
15784
  } finally {
15784
15785
  try {
15785
15786
  unlinkSync(mdTempPath);
@@ -15868,7 +15869,7 @@ async function savePlan(directory, plan, options) {
15868
15869
  const tempPath = path5.join(swarmDir, `plan.json.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
15869
15870
  try {
15870
15871
  await Bun.write(tempPath, JSON.stringify(validated, null, 2));
15871
- renameSync2(tempPath, planPath);
15872
+ renameSync(tempPath, planPath);
15872
15873
  } finally {
15873
15874
  try {
15874
15875
  unlinkSync(tempPath);
@@ -15882,7 +15883,7 @@ ${markdown}`;
15882
15883
  const mdTempPath = path5.join(swarmDir, `plan.md.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
15883
15884
  try {
15884
15885
  await Bun.write(mdTempPath, markdownWithHash);
15885
- renameSync2(mdTempPath, mdPath);
15886
+ renameSync(mdTempPath, mdPath);
15886
15887
  } finally {
15887
15888
  try {
15888
15889
  unlinkSync(mdTempPath);
@@ -16768,7 +16769,7 @@ var exports_status_artifact = {};
16768
16769
  __export(exports_status_artifact, {
16769
16770
  AutomationStatusArtifact: () => AutomationStatusArtifact
16770
16771
  });
16771
- import * as fs5 from "fs";
16772
+ import * as fs6 from "fs";
16772
16773
  import * as path8 from "path";
16773
16774
  function createEmptySnapshot(mode, capabilities) {
16774
16775
  return {
@@ -16833,8 +16834,8 @@ class AutomationStatusArtifact {
16833
16834
  load() {
16834
16835
  const filePath = this.getFilePath();
16835
16836
  try {
16836
- if (fs5.existsSync(filePath)) {
16837
- const content = fs5.readFileSync(filePath, "utf-8");
16837
+ if (fs6.existsSync(filePath)) {
16838
+ const content = fs6.readFileSync(filePath, "utf-8");
16838
16839
  return JSON.parse(content);
16839
16840
  }
16840
16841
  } catch {}
@@ -16842,10 +16843,10 @@ class AutomationStatusArtifact {
16842
16843
  }
16843
16844
  write() {
16844
16845
  const filePath = this.getFilePath();
16845
- if (!fs5.existsSync(this.swarmDir)) {
16846
- fs5.mkdirSync(this.swarmDir, { recursive: true });
16846
+ if (!fs6.existsSync(this.swarmDir)) {
16847
+ fs6.mkdirSync(this.swarmDir, { recursive: true });
16847
16848
  }
16848
- fs5.writeFileSync(filePath, JSON.stringify(this.currentSnapshot, null, 2), "utf-8");
16849
+ fs6.writeFileSync(filePath, JSON.stringify(this.currentSnapshot, null, 2), "utf-8");
16849
16850
  }
16850
16851
  getSnapshot() {
16851
16852
  return { ...this.currentSnapshot };
@@ -29902,7 +29903,7 @@ var init_create_tool = __esm(() => {
29902
29903
 
29903
29904
  // src/tools/checkpoint.ts
29904
29905
  import { spawnSync } from "child_process";
29905
- import * as fs6 from "fs";
29906
+ import * as fs7 from "fs";
29906
29907
  import * as path9 from "path";
29907
29908
  function containsNonAsciiChars(label) {
29908
29909
  for (let i2 = 0;i2 < label.length; i2++) {
@@ -29952,8 +29953,8 @@ function getCheckpointLogPath(directory) {
29952
29953
  function readCheckpointLog(directory) {
29953
29954
  const logPath = getCheckpointLogPath(directory);
29954
29955
  try {
29955
- if (fs6.existsSync(logPath)) {
29956
- const content = fs6.readFileSync(logPath, "utf-8");
29956
+ if (fs7.existsSync(logPath)) {
29957
+ const content = fs7.readFileSync(logPath, "utf-8");
29957
29958
  const parsed = JSON.parse(content);
29958
29959
  if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
29959
29960
  return { version: 1, checkpoints: [] };
@@ -29966,12 +29967,12 @@ function readCheckpointLog(directory) {
29966
29967
  function writeCheckpointLog(log2, directory) {
29967
29968
  const logPath = getCheckpointLogPath(directory);
29968
29969
  const dir = path9.dirname(logPath);
29969
- if (!fs6.existsSync(dir)) {
29970
- fs6.mkdirSync(dir, { recursive: true });
29970
+ if (!fs7.existsSync(dir)) {
29971
+ fs7.mkdirSync(dir, { recursive: true });
29971
29972
  }
29972
29973
  const tempPath = `${logPath}.tmp`;
29973
- fs6.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
29974
- fs6.renameSync(tempPath, logPath);
29974
+ fs7.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
29975
+ fs7.renameSync(tempPath, logPath);
29975
29976
  }
29976
29977
  function gitExec(args2) {
29977
29978
  const result = spawnSync("git", args2, {
@@ -30204,54 +30205,54 @@ var require_polyfills = __commonJS((exports, module2) => {
30204
30205
  }
30205
30206
  var chdir;
30206
30207
  module2.exports = patch;
30207
- function patch(fs7) {
30208
+ function patch(fs8) {
30208
30209
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
30209
- patchLchmod(fs7);
30210
- }
30211
- if (!fs7.lutimes) {
30212
- patchLutimes(fs7);
30213
- }
30214
- fs7.chown = chownFix(fs7.chown);
30215
- fs7.fchown = chownFix(fs7.fchown);
30216
- fs7.lchown = chownFix(fs7.lchown);
30217
- fs7.chmod = chmodFix(fs7.chmod);
30218
- fs7.fchmod = chmodFix(fs7.fchmod);
30219
- fs7.lchmod = chmodFix(fs7.lchmod);
30220
- fs7.chownSync = chownFixSync(fs7.chownSync);
30221
- fs7.fchownSync = chownFixSync(fs7.fchownSync);
30222
- fs7.lchownSync = chownFixSync(fs7.lchownSync);
30223
- fs7.chmodSync = chmodFixSync(fs7.chmodSync);
30224
- fs7.fchmodSync = chmodFixSync(fs7.fchmodSync);
30225
- fs7.lchmodSync = chmodFixSync(fs7.lchmodSync);
30226
- fs7.stat = statFix(fs7.stat);
30227
- fs7.fstat = statFix(fs7.fstat);
30228
- fs7.lstat = statFix(fs7.lstat);
30229
- fs7.statSync = statFixSync(fs7.statSync);
30230
- fs7.fstatSync = statFixSync(fs7.fstatSync);
30231
- fs7.lstatSync = statFixSync(fs7.lstatSync);
30232
- if (fs7.chmod && !fs7.lchmod) {
30233
- fs7.lchmod = function(path11, mode, cb) {
30210
+ patchLchmod(fs8);
30211
+ }
30212
+ if (!fs8.lutimes) {
30213
+ patchLutimes(fs8);
30214
+ }
30215
+ fs8.chown = chownFix(fs8.chown);
30216
+ fs8.fchown = chownFix(fs8.fchown);
30217
+ fs8.lchown = chownFix(fs8.lchown);
30218
+ fs8.chmod = chmodFix(fs8.chmod);
30219
+ fs8.fchmod = chmodFix(fs8.fchmod);
30220
+ fs8.lchmod = chmodFix(fs8.lchmod);
30221
+ fs8.chownSync = chownFixSync(fs8.chownSync);
30222
+ fs8.fchownSync = chownFixSync(fs8.fchownSync);
30223
+ fs8.lchownSync = chownFixSync(fs8.lchownSync);
30224
+ fs8.chmodSync = chmodFixSync(fs8.chmodSync);
30225
+ fs8.fchmodSync = chmodFixSync(fs8.fchmodSync);
30226
+ fs8.lchmodSync = chmodFixSync(fs8.lchmodSync);
30227
+ fs8.stat = statFix(fs8.stat);
30228
+ fs8.fstat = statFix(fs8.fstat);
30229
+ fs8.lstat = statFix(fs8.lstat);
30230
+ fs8.statSync = statFixSync(fs8.statSync);
30231
+ fs8.fstatSync = statFixSync(fs8.fstatSync);
30232
+ fs8.lstatSync = statFixSync(fs8.lstatSync);
30233
+ if (fs8.chmod && !fs8.lchmod) {
30234
+ fs8.lchmod = function(path11, mode, cb) {
30234
30235
  if (cb)
30235
30236
  process.nextTick(cb);
30236
30237
  };
30237
- fs7.lchmodSync = function() {};
30238
+ fs8.lchmodSync = function() {};
30238
30239
  }
30239
- if (fs7.chown && !fs7.lchown) {
30240
- fs7.lchown = function(path11, uid, gid, cb) {
30240
+ if (fs8.chown && !fs8.lchown) {
30241
+ fs8.lchown = function(path11, uid, gid, cb) {
30241
30242
  if (cb)
30242
30243
  process.nextTick(cb);
30243
30244
  };
30244
- fs7.lchownSync = function() {};
30245
+ fs8.lchownSync = function() {};
30245
30246
  }
30246
30247
  if (platform === "win32") {
30247
- fs7.rename = typeof fs7.rename !== "function" ? fs7.rename : function(fs$rename) {
30248
- function rename(from, to, cb) {
30248
+ fs8.rename = typeof fs8.rename !== "function" ? fs8.rename : function(fs$rename) {
30249
+ function rename2(from, to, cb) {
30249
30250
  var start2 = Date.now();
30250
30251
  var backoff = 0;
30251
30252
  fs$rename(from, to, function CB(er) {
30252
30253
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 60000) {
30253
30254
  setTimeout(function() {
30254
- fs7.stat(to, function(stater, st) {
30255
+ fs8.stat(to, function(stater, st) {
30255
30256
  if (stater && stater.code === "ENOENT")
30256
30257
  fs$rename(from, to, CB);
30257
30258
  else
@@ -30267,11 +30268,11 @@ var require_polyfills = __commonJS((exports, module2) => {
30267
30268
  });
30268
30269
  }
30269
30270
  if (Object.setPrototypeOf)
30270
- Object.setPrototypeOf(rename, fs$rename);
30271
- return rename;
30272
- }(fs7.rename);
30271
+ Object.setPrototypeOf(rename2, fs$rename);
30272
+ return rename2;
30273
+ }(fs8.rename);
30273
30274
  }
30274
- fs7.read = typeof fs7.read !== "function" ? fs7.read : function(fs$read) {
30275
+ fs8.read = typeof fs8.read !== "function" ? fs8.read : function(fs$read) {
30275
30276
  function read(fd, buffer, offset, length, position, callback_) {
30276
30277
  var callback;
30277
30278
  if (callback_ && typeof callback_ === "function") {
@@ -30279,23 +30280,23 @@ var require_polyfills = __commonJS((exports, module2) => {
30279
30280
  callback = function(er, _, __) {
30280
30281
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
30281
30282
  eagCounter++;
30282
- return fs$read.call(fs7, fd, buffer, offset, length, position, callback);
30283
+ return fs$read.call(fs8, fd, buffer, offset, length, position, callback);
30283
30284
  }
30284
30285
  callback_.apply(this, arguments);
30285
30286
  };
30286
30287
  }
30287
- return fs$read.call(fs7, fd, buffer, offset, length, position, callback);
30288
+ return fs$read.call(fs8, fd, buffer, offset, length, position, callback);
30288
30289
  }
30289
30290
  if (Object.setPrototypeOf)
30290
30291
  Object.setPrototypeOf(read, fs$read);
30291
30292
  return read;
30292
- }(fs7.read);
30293
- fs7.readSync = typeof fs7.readSync !== "function" ? fs7.readSync : function(fs$readSync) {
30293
+ }(fs8.read);
30294
+ fs8.readSync = typeof fs8.readSync !== "function" ? fs8.readSync : function(fs$readSync) {
30294
30295
  return function(fd, buffer, offset, length, position) {
30295
30296
  var eagCounter = 0;
30296
30297
  while (true) {
30297
30298
  try {
30298
- return fs$readSync.call(fs7, fd, buffer, offset, length, position);
30299
+ return fs$readSync.call(fs8, fd, buffer, offset, length, position);
30299
30300
  } catch (er) {
30300
30301
  if (er.code === "EAGAIN" && eagCounter < 10) {
30301
30302
  eagCounter++;
@@ -30305,90 +30306,90 @@ var require_polyfills = __commonJS((exports, module2) => {
30305
30306
  }
30306
30307
  }
30307
30308
  };
30308
- }(fs7.readSync);
30309
- function patchLchmod(fs8) {
30310
- fs8.lchmod = function(path11, mode, callback) {
30311
- fs8.open(path11, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err2, fd) {
30309
+ }(fs8.readSync);
30310
+ function patchLchmod(fs9) {
30311
+ fs9.lchmod = function(path11, mode, callback) {
30312
+ fs9.open(path11, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err2, fd) {
30312
30313
  if (err2) {
30313
30314
  if (callback)
30314
30315
  callback(err2);
30315
30316
  return;
30316
30317
  }
30317
- fs8.fchmod(fd, mode, function(err3) {
30318
- fs8.close(fd, function(err22) {
30318
+ fs9.fchmod(fd, mode, function(err3) {
30319
+ fs9.close(fd, function(err22) {
30319
30320
  if (callback)
30320
30321
  callback(err3 || err22);
30321
30322
  });
30322
30323
  });
30323
30324
  });
30324
30325
  };
30325
- fs8.lchmodSync = function(path11, mode) {
30326
- var fd = fs8.openSync(path11, constants.O_WRONLY | constants.O_SYMLINK, mode);
30326
+ fs9.lchmodSync = function(path11, mode) {
30327
+ var fd = fs9.openSync(path11, constants.O_WRONLY | constants.O_SYMLINK, mode);
30327
30328
  var threw = true;
30328
30329
  var ret;
30329
30330
  try {
30330
- ret = fs8.fchmodSync(fd, mode);
30331
+ ret = fs9.fchmodSync(fd, mode);
30331
30332
  threw = false;
30332
30333
  } finally {
30333
30334
  if (threw) {
30334
30335
  try {
30335
- fs8.closeSync(fd);
30336
+ fs9.closeSync(fd);
30336
30337
  } catch (er) {}
30337
30338
  } else {
30338
- fs8.closeSync(fd);
30339
+ fs9.closeSync(fd);
30339
30340
  }
30340
30341
  }
30341
30342
  return ret;
30342
30343
  };
30343
30344
  }
30344
- function patchLutimes(fs8) {
30345
- if (constants.hasOwnProperty("O_SYMLINK") && fs8.futimes) {
30346
- fs8.lutimes = function(path11, at, mt, cb) {
30347
- fs8.open(path11, constants.O_SYMLINK, function(er, fd) {
30345
+ function patchLutimes(fs9) {
30346
+ if (constants.hasOwnProperty("O_SYMLINK") && fs9.futimes) {
30347
+ fs9.lutimes = function(path11, at, mt, cb) {
30348
+ fs9.open(path11, constants.O_SYMLINK, function(er, fd) {
30348
30349
  if (er) {
30349
30350
  if (cb)
30350
30351
  cb(er);
30351
30352
  return;
30352
30353
  }
30353
- fs8.futimes(fd, at, mt, function(er2) {
30354
- fs8.close(fd, function(er22) {
30354
+ fs9.futimes(fd, at, mt, function(er2) {
30355
+ fs9.close(fd, function(er22) {
30355
30356
  if (cb)
30356
30357
  cb(er2 || er22);
30357
30358
  });
30358
30359
  });
30359
30360
  });
30360
30361
  };
30361
- fs8.lutimesSync = function(path11, at, mt) {
30362
- var fd = fs8.openSync(path11, constants.O_SYMLINK);
30362
+ fs9.lutimesSync = function(path11, at, mt) {
30363
+ var fd = fs9.openSync(path11, constants.O_SYMLINK);
30363
30364
  var ret;
30364
30365
  var threw = true;
30365
30366
  try {
30366
- ret = fs8.futimesSync(fd, at, mt);
30367
+ ret = fs9.futimesSync(fd, at, mt);
30367
30368
  threw = false;
30368
30369
  } finally {
30369
30370
  if (threw) {
30370
30371
  try {
30371
- fs8.closeSync(fd);
30372
+ fs9.closeSync(fd);
30372
30373
  } catch (er) {}
30373
30374
  } else {
30374
- fs8.closeSync(fd);
30375
+ fs9.closeSync(fd);
30375
30376
  }
30376
30377
  }
30377
30378
  return ret;
30378
30379
  };
30379
- } else if (fs8.futimes) {
30380
- fs8.lutimes = function(_a2, _b, _c, cb) {
30380
+ } else if (fs9.futimes) {
30381
+ fs9.lutimes = function(_a2, _b, _c, cb) {
30381
30382
  if (cb)
30382
30383
  process.nextTick(cb);
30383
30384
  };
30384
- fs8.lutimesSync = function() {};
30385
+ fs9.lutimesSync = function() {};
30385
30386
  }
30386
30387
  }
30387
30388
  function chmodFix(orig) {
30388
30389
  if (!orig)
30389
30390
  return orig;
30390
30391
  return function(target, mode, cb) {
30391
- return orig.call(fs7, target, mode, function(er) {
30392
+ return orig.call(fs8, target, mode, function(er) {
30392
30393
  if (chownErOk(er))
30393
30394
  er = null;
30394
30395
  if (cb)
@@ -30401,7 +30402,7 @@ var require_polyfills = __commonJS((exports, module2) => {
30401
30402
  return orig;
30402
30403
  return function(target, mode) {
30403
30404
  try {
30404
- return orig.call(fs7, target, mode);
30405
+ return orig.call(fs8, target, mode);
30405
30406
  } catch (er) {
30406
30407
  if (!chownErOk(er))
30407
30408
  throw er;
@@ -30412,7 +30413,7 @@ var require_polyfills = __commonJS((exports, module2) => {
30412
30413
  if (!orig)
30413
30414
  return orig;
30414
30415
  return function(target, uid, gid, cb) {
30415
- return orig.call(fs7, target, uid, gid, function(er) {
30416
+ return orig.call(fs8, target, uid, gid, function(er) {
30416
30417
  if (chownErOk(er))
30417
30418
  er = null;
30418
30419
  if (cb)
@@ -30425,7 +30426,7 @@ var require_polyfills = __commonJS((exports, module2) => {
30425
30426
  return orig;
30426
30427
  return function(target, uid, gid) {
30427
30428
  try {
30428
- return orig.call(fs7, target, uid, gid);
30429
+ return orig.call(fs8, target, uid, gid);
30429
30430
  } catch (er) {
30430
30431
  if (!chownErOk(er))
30431
30432
  throw er;
@@ -30450,14 +30451,14 @@ var require_polyfills = __commonJS((exports, module2) => {
30450
30451
  if (cb)
30451
30452
  cb.apply(this, arguments);
30452
30453
  }
30453
- return options ? orig.call(fs7, target, options, callback) : orig.call(fs7, target, callback);
30454
+ return options ? orig.call(fs8, target, options, callback) : orig.call(fs8, target, callback);
30454
30455
  };
30455
30456
  }
30456
30457
  function statFixSync(orig) {
30457
30458
  if (!orig)
30458
30459
  return orig;
30459
30460
  return function(target, options) {
30460
- var stats = options ? orig.call(fs7, target, options) : orig.call(fs7, target);
30461
+ var stats = options ? orig.call(fs8, target, options) : orig.call(fs8, target);
30461
30462
  if (stats) {
30462
30463
  if (stats.uid < 0)
30463
30464
  stats.uid += 4294967296;
@@ -30486,7 +30487,7 @@ var require_polyfills = __commonJS((exports, module2) => {
30486
30487
  var require_legacy_streams = __commonJS((exports, module2) => {
30487
30488
  var Stream = __require("stream").Stream;
30488
30489
  module2.exports = legacy;
30489
- function legacy(fs7) {
30490
+ function legacy(fs8) {
30490
30491
  return {
30491
30492
  ReadStream,
30492
30493
  WriteStream
@@ -30531,7 +30532,7 @@ var require_legacy_streams = __commonJS((exports, module2) => {
30531
30532
  });
30532
30533
  return;
30533
30534
  }
30534
- fs7.open(this.path, this.flags, this.mode, function(err2, fd) {
30535
+ fs8.open(this.path, this.flags, this.mode, function(err2, fd) {
30535
30536
  if (err2) {
30536
30537
  self2.emit("error", err2);
30537
30538
  self2.readable = false;
@@ -30571,7 +30572,7 @@ var require_legacy_streams = __commonJS((exports, module2) => {
30571
30572
  this.busy = false;
30572
30573
  this._queue = [];
30573
30574
  if (this.fd === null) {
30574
- this._open = fs7.open;
30575
+ this._open = fs8.open;
30575
30576
  this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
30576
30577
  this.flush();
30577
30578
  }
@@ -30601,7 +30602,7 @@ var require_clone = __commonJS((exports, module2) => {
30601
30602
 
30602
30603
  // node_modules/graceful-fs/graceful-fs.js
30603
30604
  var require_graceful_fs = __commonJS((exports, module2) => {
30604
- var fs7 = __require("fs");
30605
+ var fs8 = __require("fs");
30605
30606
  var polyfills = require_polyfills();
30606
30607
  var legacy = require_legacy_streams();
30607
30608
  var clone3 = require_clone();
@@ -30633,12 +30634,12 @@ var require_graceful_fs = __commonJS((exports, module2) => {
30633
30634
  GFS4: `);
30634
30635
  console.error(m);
30635
30636
  };
30636
- if (!fs7[gracefulQueue]) {
30637
+ if (!fs8[gracefulQueue]) {
30637
30638
  queue = global[gracefulQueue] || [];
30638
- publishQueue(fs7, queue);
30639
- fs7.close = function(fs$close) {
30639
+ publishQueue(fs8, queue);
30640
+ fs8.close = function(fs$close) {
30640
30641
  function close(fd, cb) {
30641
- return fs$close.call(fs7, fd, function(err2) {
30642
+ return fs$close.call(fs8, fd, function(err2) {
30642
30643
  if (!err2) {
30643
30644
  resetQueue();
30644
30645
  }
@@ -30650,40 +30651,40 @@ GFS4: `);
30650
30651
  value: fs$close
30651
30652
  });
30652
30653
  return close;
30653
- }(fs7.close);
30654
- fs7.closeSync = function(fs$closeSync) {
30654
+ }(fs8.close);
30655
+ fs8.closeSync = function(fs$closeSync) {
30655
30656
  function closeSync(fd) {
30656
- fs$closeSync.apply(fs7, arguments);
30657
+ fs$closeSync.apply(fs8, arguments);
30657
30658
  resetQueue();
30658
30659
  }
30659
30660
  Object.defineProperty(closeSync, previousSymbol, {
30660
30661
  value: fs$closeSync
30661
30662
  });
30662
30663
  return closeSync;
30663
- }(fs7.closeSync);
30664
+ }(fs8.closeSync);
30664
30665
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
30665
30666
  process.on("exit", function() {
30666
- debug(fs7[gracefulQueue]);
30667
- __require("assert").equal(fs7[gracefulQueue].length, 0);
30667
+ debug(fs8[gracefulQueue]);
30668
+ __require("assert").equal(fs8[gracefulQueue].length, 0);
30668
30669
  });
30669
30670
  }
30670
30671
  }
30671
30672
  var queue;
30672
30673
  if (!global[gracefulQueue]) {
30673
- publishQueue(global, fs7[gracefulQueue]);
30674
- }
30675
- module2.exports = patch(clone3(fs7));
30676
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs7.__patched) {
30677
- module2.exports = patch(fs7);
30678
- fs7.__patched = true;
30679
- }
30680
- function patch(fs8) {
30681
- polyfills(fs8);
30682
- fs8.gracefulify = patch;
30683
- fs8.createReadStream = createReadStream;
30684
- fs8.createWriteStream = createWriteStream;
30685
- var fs$readFile = fs8.readFile;
30686
- fs8.readFile = readFile2;
30674
+ publishQueue(global, fs8[gracefulQueue]);
30675
+ }
30676
+ module2.exports = patch(clone3(fs8));
30677
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs8.__patched) {
30678
+ module2.exports = patch(fs8);
30679
+ fs8.__patched = true;
30680
+ }
30681
+ function patch(fs9) {
30682
+ polyfills(fs9);
30683
+ fs9.gracefulify = patch;
30684
+ fs9.createReadStream = createReadStream;
30685
+ fs9.createWriteStream = createWriteStream;
30686
+ var fs$readFile = fs9.readFile;
30687
+ fs9.readFile = readFile2;
30687
30688
  function readFile2(path11, options, cb) {
30688
30689
  if (typeof options === "function")
30689
30690
  cb = options, options = null;
@@ -30699,8 +30700,8 @@ GFS4: `);
30699
30700
  });
30700
30701
  }
30701
30702
  }
30702
- var fs$writeFile = fs8.writeFile;
30703
- fs8.writeFile = writeFile;
30703
+ var fs$writeFile = fs9.writeFile;
30704
+ fs9.writeFile = writeFile;
30704
30705
  function writeFile(path11, data, options, cb) {
30705
30706
  if (typeof options === "function")
30706
30707
  cb = options, options = null;
@@ -30716,9 +30717,9 @@ GFS4: `);
30716
30717
  });
30717
30718
  }
30718
30719
  }
30719
- var fs$appendFile = fs8.appendFile;
30720
+ var fs$appendFile = fs9.appendFile;
30720
30721
  if (fs$appendFile)
30721
- fs8.appendFile = appendFile;
30722
+ fs9.appendFile = appendFile;
30722
30723
  function appendFile(path11, data, options, cb) {
30723
30724
  if (typeof options === "function")
30724
30725
  cb = options, options = null;
@@ -30734,9 +30735,9 @@ GFS4: `);
30734
30735
  });
30735
30736
  }
30736
30737
  }
30737
- var fs$copyFile = fs8.copyFile;
30738
+ var fs$copyFile = fs9.copyFile;
30738
30739
  if (fs$copyFile)
30739
- fs8.copyFile = copyFile;
30740
+ fs9.copyFile = copyFile;
30740
30741
  function copyFile(src, dest, flags2, cb) {
30741
30742
  if (typeof flags2 === "function") {
30742
30743
  cb = flags2;
@@ -30754,8 +30755,8 @@ GFS4: `);
30754
30755
  });
30755
30756
  }
30756
30757
  }
30757
- var fs$readdir = fs8.readdir;
30758
- fs8.readdir = readdir2;
30758
+ var fs$readdir = fs9.readdir;
30759
+ fs9.readdir = readdir2;
30759
30760
  var noReaddirOptionVersions = /^v[0-5]\./;
30760
30761
  function readdir2(path11, options, cb) {
30761
30762
  if (typeof options === "function")
@@ -30786,21 +30787,21 @@ GFS4: `);
30786
30787
  }
30787
30788
  }
30788
30789
  if (process.version.substr(0, 4) === "v0.8") {
30789
- var legStreams = legacy(fs8);
30790
+ var legStreams = legacy(fs9);
30790
30791
  ReadStream = legStreams.ReadStream;
30791
30792
  WriteStream = legStreams.WriteStream;
30792
30793
  }
30793
- var fs$ReadStream = fs8.ReadStream;
30794
+ var fs$ReadStream = fs9.ReadStream;
30794
30795
  if (fs$ReadStream) {
30795
30796
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
30796
30797
  ReadStream.prototype.open = ReadStream$open;
30797
30798
  }
30798
- var fs$WriteStream = fs8.WriteStream;
30799
+ var fs$WriteStream = fs9.WriteStream;
30799
30800
  if (fs$WriteStream) {
30800
30801
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
30801
30802
  WriteStream.prototype.open = WriteStream$open;
30802
30803
  }
30803
- Object.defineProperty(fs8, "ReadStream", {
30804
+ Object.defineProperty(fs9, "ReadStream", {
30804
30805
  get: function() {
30805
30806
  return ReadStream;
30806
30807
  },
@@ -30810,7 +30811,7 @@ GFS4: `);
30810
30811
  enumerable: true,
30811
30812
  configurable: true
30812
30813
  });
30813
- Object.defineProperty(fs8, "WriteStream", {
30814
+ Object.defineProperty(fs9, "WriteStream", {
30814
30815
  get: function() {
30815
30816
  return WriteStream;
30816
30817
  },
@@ -30821,7 +30822,7 @@ GFS4: `);
30821
30822
  configurable: true
30822
30823
  });
30823
30824
  var FileReadStream = ReadStream;
30824
- Object.defineProperty(fs8, "FileReadStream", {
30825
+ Object.defineProperty(fs9, "FileReadStream", {
30825
30826
  get: function() {
30826
30827
  return FileReadStream;
30827
30828
  },
@@ -30832,7 +30833,7 @@ GFS4: `);
30832
30833
  configurable: true
30833
30834
  });
30834
30835
  var FileWriteStream = WriteStream;
30835
- Object.defineProperty(fs8, "FileWriteStream", {
30836
+ Object.defineProperty(fs9, "FileWriteStream", {
30836
30837
  get: function() {
30837
30838
  return FileWriteStream;
30838
30839
  },
@@ -30881,13 +30882,13 @@ GFS4: `);
30881
30882
  });
30882
30883
  }
30883
30884
  function createReadStream(path11, options) {
30884
- return new fs8.ReadStream(path11, options);
30885
+ return new fs9.ReadStream(path11, options);
30885
30886
  }
30886
30887
  function createWriteStream(path11, options) {
30887
- return new fs8.WriteStream(path11, options);
30888
+ return new fs9.WriteStream(path11, options);
30888
30889
  }
30889
- var fs$open = fs8.open;
30890
- fs8.open = open;
30890
+ var fs$open = fs9.open;
30891
+ fs9.open = open;
30891
30892
  function open(path11, flags2, mode, cb) {
30892
30893
  if (typeof mode === "function")
30893
30894
  cb = mode, mode = null;
@@ -30903,20 +30904,20 @@ GFS4: `);
30903
30904
  });
30904
30905
  }
30905
30906
  }
30906
- return fs8;
30907
+ return fs9;
30907
30908
  }
30908
30909
  function enqueue(elem) {
30909
30910
  debug("ENQUEUE", elem[0].name, elem[1]);
30910
- fs7[gracefulQueue].push(elem);
30911
+ fs8[gracefulQueue].push(elem);
30911
30912
  retry();
30912
30913
  }
30913
30914
  var retryTimer;
30914
30915
  function resetQueue() {
30915
30916
  var now = Date.now();
30916
- for (var i2 = 0;i2 < fs7[gracefulQueue].length; ++i2) {
30917
- if (fs7[gracefulQueue][i2].length > 2) {
30918
- fs7[gracefulQueue][i2][3] = now;
30919
- fs7[gracefulQueue][i2][4] = now;
30917
+ for (var i2 = 0;i2 < fs8[gracefulQueue].length; ++i2) {
30918
+ if (fs8[gracefulQueue][i2].length > 2) {
30919
+ fs8[gracefulQueue][i2][3] = now;
30920
+ fs8[gracefulQueue][i2][4] = now;
30920
30921
  }
30921
30922
  }
30922
30923
  retry();
@@ -30924,9 +30925,9 @@ GFS4: `);
30924
30925
  function retry() {
30925
30926
  clearTimeout(retryTimer);
30926
30927
  retryTimer = undefined;
30927
- if (fs7[gracefulQueue].length === 0)
30928
+ if (fs8[gracefulQueue].length === 0)
30928
30929
  return;
30929
- var elem = fs7[gracefulQueue].shift();
30930
+ var elem = fs8[gracefulQueue].shift();
30930
30931
  var fn = elem[0];
30931
30932
  var args2 = elem[1];
30932
30933
  var err2 = elem[2];
@@ -30948,7 +30949,7 @@ GFS4: `);
30948
30949
  debug("RETRY", fn.name, args2);
30949
30950
  fn.apply(null, args2.concat([startTime]));
30950
30951
  } else {
30951
- fs7[gracefulQueue].push(elem);
30952
+ fs8[gracefulQueue].push(elem);
30952
30953
  }
30953
30954
  }
30954
30955
  if (retryTimer === undefined) {
@@ -31343,10 +31344,10 @@ var require_signal_exit = __commonJS((exports, module2) => {
31343
31344
  // node_modules/proper-lockfile/lib/mtime-precision.js
31344
31345
  var require_mtime_precision = __commonJS((exports, module2) => {
31345
31346
  var cacheSymbol = Symbol();
31346
- function probe(file3, fs7, callback) {
31347
- const cachedPrecision = fs7[cacheSymbol];
31347
+ function probe(file3, fs8, callback) {
31348
+ const cachedPrecision = fs8[cacheSymbol];
31348
31349
  if (cachedPrecision) {
31349
- return fs7.stat(file3, (err2, stat) => {
31350
+ return fs8.stat(file3, (err2, stat) => {
31350
31351
  if (err2) {
31351
31352
  return callback(err2);
31352
31353
  }
@@ -31354,16 +31355,16 @@ var require_mtime_precision = __commonJS((exports, module2) => {
31354
31355
  });
31355
31356
  }
31356
31357
  const mtime = new Date(Math.ceil(Date.now() / 1000) * 1000 + 5);
31357
- fs7.utimes(file3, mtime, mtime, (err2) => {
31358
+ fs8.utimes(file3, mtime, mtime, (err2) => {
31358
31359
  if (err2) {
31359
31360
  return callback(err2);
31360
31361
  }
31361
- fs7.stat(file3, (err3, stat) => {
31362
+ fs8.stat(file3, (err3, stat) => {
31362
31363
  if (err3) {
31363
31364
  return callback(err3);
31364
31365
  }
31365
31366
  const precision = stat.mtime.getTime() % 1000 === 0 ? "s" : "ms";
31366
- Object.defineProperty(fs7, cacheSymbol, { value: precision });
31367
+ Object.defineProperty(fs8, cacheSymbol, { value: precision });
31367
31368
  callback(null, stat.mtime, precision);
31368
31369
  });
31369
31370
  });
@@ -31382,7 +31383,7 @@ var require_mtime_precision = __commonJS((exports, module2) => {
31382
31383
  // node_modules/proper-lockfile/lib/lockfile.js
31383
31384
  var require_lockfile = __commonJS((exports, module2) => {
31384
31385
  var path11 = __require("path");
31385
- var fs7 = require_graceful_fs();
31386
+ var fs8 = require_graceful_fs();
31386
31387
  var retry = require_retry();
31387
31388
  var onExit = require_signal_exit();
31388
31389
  var mtimePrecision = require_mtime_precision();
@@ -31505,7 +31506,7 @@ var require_lockfile = __commonJS((exports, module2) => {
31505
31506
  update: null,
31506
31507
  realpath: true,
31507
31508
  retries: 0,
31508
- fs: fs7,
31509
+ fs: fs8,
31509
31510
  onCompromised: (err2) => {
31510
31511
  throw err2;
31511
31512
  },
@@ -31549,7 +31550,7 @@ var require_lockfile = __commonJS((exports, module2) => {
31549
31550
  }
31550
31551
  function unlock(file3, options, callback) {
31551
31552
  options = {
31552
- fs: fs7,
31553
+ fs: fs8,
31553
31554
  realpath: true,
31554
31555
  ...options
31555
31556
  };
@@ -31571,7 +31572,7 @@ var require_lockfile = __commonJS((exports, module2) => {
31571
31572
  options = {
31572
31573
  stale: 1e4,
31573
31574
  realpath: true,
31574
- fs: fs7,
31575
+ fs: fs8,
31575
31576
  ...options
31576
31577
  };
31577
31578
  options.stale = Math.max(options.stale || 0, 2000);
@@ -31606,16 +31607,16 @@ var require_lockfile = __commonJS((exports, module2) => {
31606
31607
 
31607
31608
  // node_modules/proper-lockfile/lib/adapter.js
31608
31609
  var require_adapter = __commonJS((exports, module2) => {
31609
- var fs7 = require_graceful_fs();
31610
- function createSyncFs(fs8) {
31610
+ var fs8 = require_graceful_fs();
31611
+ function createSyncFs(fs9) {
31611
31612
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
31612
- const newFs = { ...fs8 };
31613
+ const newFs = { ...fs9 };
31613
31614
  methods.forEach((method) => {
31614
31615
  newFs[method] = (...args2) => {
31615
31616
  const callback = args2.pop();
31616
31617
  let ret;
31617
31618
  try {
31618
- ret = fs8[`${method}Sync`](...args2);
31619
+ ret = fs9[`${method}Sync`](...args2);
31619
31620
  } catch (err2) {
31620
31621
  return callback(err2);
31621
31622
  }
@@ -31653,7 +31654,7 @@ var require_adapter = __commonJS((exports, module2) => {
31653
31654
  }
31654
31655
  function toSyncOptions(options) {
31655
31656
  options = { ...options };
31656
- options.fs = createSyncFs(options.fs || fs7);
31657
+ options.fs = createSyncFs(options.fs || fs8);
31657
31658
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
31658
31659
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
31659
31660
  }
@@ -31713,7 +31714,7 @@ __export(exports_config_doctor, {
31713
31714
  applySafeAutoFixes: () => applySafeAutoFixes
31714
31715
  });
31715
31716
  import * as crypto2 from "crypto";
31716
- import * as fs8 from "fs";
31717
+ import * as fs9 from "fs";
31717
31718
  import * as os4 from "os";
31718
31719
  import * as path18 from "path";
31719
31720
  function getUserConfigDir3() {
@@ -31758,15 +31759,15 @@ function createConfigBackup(directory) {
31758
31759
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
31759
31760
  let configPath = projectConfigPath;
31760
31761
  let content = null;
31761
- if (fs8.existsSync(projectConfigPath)) {
31762
+ if (fs9.existsSync(projectConfigPath)) {
31762
31763
  try {
31763
- content = fs8.readFileSync(projectConfigPath, "utf-8");
31764
+ content = fs9.readFileSync(projectConfigPath, "utf-8");
31764
31765
  } catch {}
31765
31766
  }
31766
- if (content === null && fs8.existsSync(userConfigPath)) {
31767
+ if (content === null && fs9.existsSync(userConfigPath)) {
31767
31768
  configPath = userConfigPath;
31768
31769
  try {
31769
- content = fs8.readFileSync(userConfigPath, "utf-8");
31770
+ content = fs9.readFileSync(userConfigPath, "utf-8");
31770
31771
  } catch {}
31771
31772
  }
31772
31773
  if (content === null) {
@@ -31781,8 +31782,8 @@ function createConfigBackup(directory) {
31781
31782
  }
31782
31783
  function writeBackupArtifact(directory, backup) {
31783
31784
  const swarmDir = path18.join(directory, ".swarm");
31784
- if (!fs8.existsSync(swarmDir)) {
31785
- fs8.mkdirSync(swarmDir, { recursive: true });
31785
+ if (!fs9.existsSync(swarmDir)) {
31786
+ fs9.mkdirSync(swarmDir, { recursive: true });
31786
31787
  }
31787
31788
  const backupFilename = `config-backup-${backup.createdAt}.json`;
31788
31789
  const backupPath = path18.join(swarmDir, backupFilename);
@@ -31793,15 +31794,15 @@ function writeBackupArtifact(directory, backup) {
31793
31794
  content: backup.content,
31794
31795
  preview: backup.content.substring(0, 500) + (backup.content.length > 500 ? "..." : "")
31795
31796
  };
31796
- fs8.writeFileSync(backupPath, JSON.stringify(artifact, null, 2), "utf-8");
31797
+ fs9.writeFileSync(backupPath, JSON.stringify(artifact, null, 2), "utf-8");
31797
31798
  return backupPath;
31798
31799
  }
31799
31800
  function restoreFromBackup(backupPath, directory) {
31800
- if (!fs8.existsSync(backupPath)) {
31801
+ if (!fs9.existsSync(backupPath)) {
31801
31802
  return null;
31802
31803
  }
31803
31804
  try {
31804
- const artifact = JSON.parse(fs8.readFileSync(backupPath, "utf-8"));
31805
+ const artifact = JSON.parse(fs9.readFileSync(backupPath, "utf-8"));
31805
31806
  if (!artifact.content || !artifact.configPath || !artifact.contentHash) {
31806
31807
  return null;
31807
31808
  }
@@ -31816,10 +31817,10 @@ function restoreFromBackup(backupPath, directory) {
31816
31817
  }
31817
31818
  const targetPath = artifact.configPath;
31818
31819
  const targetDir = path18.dirname(targetPath);
31819
- if (!fs8.existsSync(targetDir)) {
31820
- fs8.mkdirSync(targetDir, { recursive: true });
31820
+ if (!fs9.existsSync(targetDir)) {
31821
+ fs9.mkdirSync(targetDir, { recursive: true });
31821
31822
  }
31822
- fs8.writeFileSync(targetPath, artifact.content, "utf-8");
31823
+ fs9.writeFileSync(targetPath, artifact.content, "utf-8");
31823
31824
  return targetPath;
31824
31825
  } catch {
31825
31826
  return null;
@@ -31829,12 +31830,12 @@ function readConfigFromFile(directory) {
31829
31830
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
31830
31831
  let configPath = projectConfigPath;
31831
31832
  let configContent = null;
31832
- if (fs8.existsSync(projectConfigPath)) {
31833
+ if (fs9.existsSync(projectConfigPath)) {
31833
31834
  configPath = projectConfigPath;
31834
- configContent = fs8.readFileSync(projectConfigPath, "utf-8");
31835
- } else if (fs8.existsSync(userConfigPath)) {
31835
+ configContent = fs9.readFileSync(projectConfigPath, "utf-8");
31836
+ } else if (fs9.existsSync(userConfigPath)) {
31836
31837
  configPath = userConfigPath;
31837
- configContent = fs8.readFileSync(userConfigPath, "utf-8");
31838
+ configContent = fs9.readFileSync(userConfigPath, "utf-8");
31838
31839
  }
31839
31840
  if (configContent === null) {
31840
31841
  return null;
@@ -32130,9 +32131,9 @@ function runConfigDoctor(config3, directory) {
32130
32131
  const hasAutoFixableIssues = findings.some((f) => f.autoFixable && f.proposedFix?.risk === "low");
32131
32132
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
32132
32133
  let configSource = "defaults";
32133
- if (fs8.existsSync(projectConfigPath)) {
32134
+ if (fs9.existsSync(projectConfigPath)) {
32134
32135
  configSource = projectConfigPath;
32135
- } else if (fs8.existsSync(userConfigPath)) {
32136
+ } else if (fs9.existsSync(userConfigPath)) {
32136
32137
  configSource = userConfigPath;
32137
32138
  }
32138
32139
  return {
@@ -32161,12 +32162,12 @@ function applySafeAutoFixes(directory, result) {
32161
32162
  const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
32162
32163
  let configPath = projectConfigPath;
32163
32164
  let configContent;
32164
- if (fs8.existsSync(projectConfigPath)) {
32165
+ if (fs9.existsSync(projectConfigPath)) {
32165
32166
  configPath = projectConfigPath;
32166
- configContent = fs8.readFileSync(projectConfigPath, "utf-8");
32167
- } else if (fs8.existsSync(userConfigPath)) {
32167
+ configContent = fs9.readFileSync(projectConfigPath, "utf-8");
32168
+ } else if (fs9.existsSync(userConfigPath)) {
32168
32169
  configPath = userConfigPath;
32169
- configContent = fs8.readFileSync(userConfigPath, "utf-8");
32170
+ configContent = fs9.readFileSync(userConfigPath, "utf-8");
32170
32171
  } else {
32171
32172
  return { appliedFixes, updatedConfigPath: null };
32172
32173
  }
@@ -32236,18 +32237,18 @@ function applySafeAutoFixes(directory, result) {
32236
32237
  }
32237
32238
  if (appliedFixes.length > 0) {
32238
32239
  const configDir = path18.dirname(configPath);
32239
- if (!fs8.existsSync(configDir)) {
32240
- fs8.mkdirSync(configDir, { recursive: true });
32240
+ if (!fs9.existsSync(configDir)) {
32241
+ fs9.mkdirSync(configDir, { recursive: true });
32241
32242
  }
32242
- fs8.writeFileSync(configPath, JSON.stringify(config3, null, 2), "utf-8");
32243
+ fs9.writeFileSync(configPath, JSON.stringify(config3, null, 2), "utf-8");
32243
32244
  updatedConfigPath = configPath;
32244
32245
  }
32245
32246
  return { appliedFixes, updatedConfigPath };
32246
32247
  }
32247
32248
  function writeDoctorArtifact(directory, result) {
32248
32249
  const swarmDir = path18.join(directory, ".swarm");
32249
- if (!fs8.existsSync(swarmDir)) {
32250
- fs8.mkdirSync(swarmDir, { recursive: true });
32250
+ if (!fs9.existsSync(swarmDir)) {
32251
+ fs9.mkdirSync(swarmDir, { recursive: true });
32251
32252
  }
32252
32253
  const artifactFilename = "config-doctor.json";
32253
32254
  const artifactPath = path18.join(swarmDir, artifactFilename);
@@ -32271,7 +32272,7 @@ function writeDoctorArtifact(directory, result) {
32271
32272
  } : null
32272
32273
  }))
32273
32274
  };
32274
- fs8.writeFileSync(artifactPath, JSON.stringify(guiOutput, null, 2), "utf-8");
32275
+ fs9.writeFileSync(artifactPath, JSON.stringify(guiOutput, null, 2), "utf-8");
32275
32276
  return artifactPath;
32276
32277
  }
32277
32278
  function shouldRunOnStartup(automationConfig) {
@@ -33249,7 +33250,7 @@ var init_detector = __esm(() => {
33249
33250
  });
33250
33251
 
33251
33252
  // src/build/discovery.ts
33252
- import * as fs9 from "fs";
33253
+ import * as fs10 from "fs";
33253
33254
  import * as path21 from "path";
33254
33255
  function isCommandAvailable(command) {
33255
33256
  if (toolchainCache.has(command)) {
@@ -33279,7 +33280,7 @@ function findBuildFiles(workingDir, patterns) {
33279
33280
  if (pattern.includes("*")) {
33280
33281
  const dir = workingDir;
33281
33282
  try {
33282
- const files = fs9.readdirSync(dir);
33283
+ const files = fs10.readdirSync(dir);
33283
33284
  const regex = simpleGlobToRegex(pattern);
33284
33285
  const matches = files.filter((f) => regex.test(f));
33285
33286
  if (matches.length > 0) {
@@ -33288,7 +33289,7 @@ function findBuildFiles(workingDir, patterns) {
33288
33289
  } catch {}
33289
33290
  } else {
33290
33291
  const filePath = path21.join(workingDir, pattern);
33291
- if (fs9.existsSync(filePath)) {
33292
+ if (fs10.existsSync(filePath)) {
33292
33293
  return filePath;
33293
33294
  }
33294
33295
  }
@@ -33297,11 +33298,11 @@ function findBuildFiles(workingDir, patterns) {
33297
33298
  }
33298
33299
  function getRepoDefinedScripts(workingDir, scripts) {
33299
33300
  const packageJsonPath = path21.join(workingDir, "package.json");
33300
- if (!fs9.existsSync(packageJsonPath)) {
33301
+ if (!fs10.existsSync(packageJsonPath)) {
33301
33302
  return [];
33302
33303
  }
33303
33304
  try {
33304
- const content = fs9.readFileSync(packageJsonPath, "utf-8");
33305
+ const content = fs10.readFileSync(packageJsonPath, "utf-8");
33305
33306
  const pkg = JSON.parse(content);
33306
33307
  if (!pkg.scripts || typeof pkg.scripts !== "object") {
33307
33308
  return [];
@@ -33338,7 +33339,7 @@ function findAllBuildFiles(workingDir) {
33338
33339
  findFilesRecursive(workingDir, regex, allBuildFiles);
33339
33340
  } else {
33340
33341
  const filePath = path21.join(workingDir, pattern);
33341
- if (fs9.existsSync(filePath)) {
33342
+ if (fs10.existsSync(filePath)) {
33342
33343
  allBuildFiles.add(filePath);
33343
33344
  }
33344
33345
  }
@@ -33348,7 +33349,7 @@ function findAllBuildFiles(workingDir) {
33348
33349
  }
33349
33350
  function findFilesRecursive(dir, regex, results) {
33350
33351
  try {
33351
- const entries = fs9.readdirSync(dir, { withFileTypes: true });
33352
+ const entries = fs10.readdirSync(dir, { withFileTypes: true });
33352
33353
  for (const entry of entries) {
33353
33354
  const fullPath = path21.join(dir, entry.name);
33354
33355
  if (entry.isDirectory() && !["node_modules", ".git", "dist", "build", "target"].includes(entry.name)) {
@@ -33374,7 +33375,7 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
33374
33375
  for (const cmd of sortedCommands) {
33375
33376
  if (cmd.detectFile) {
33376
33377
  const detectFilePath = path21.join(workingDir, cmd.detectFile);
33377
- if (!fs9.existsSync(detectFilePath)) {
33378
+ if (!fs10.existsSync(detectFilePath)) {
33378
33379
  continue;
33379
33380
  }
33380
33381
  }
@@ -33582,7 +33583,7 @@ var init_discovery = __esm(() => {
33582
33583
  });
33583
33584
 
33584
33585
  // src/tools/lint.ts
33585
- import * as fs10 from "fs";
33586
+ import * as fs11 from "fs";
33586
33587
  import * as path22 from "path";
33587
33588
  function validateArgs(args2) {
33588
33589
  if (typeof args2 !== "object" || args2 === null)
@@ -33612,7 +33613,7 @@ function getLinterCommand(linter, mode, projectDir) {
33612
33613
  }
33613
33614
  function getAdditionalLinterCommand(linter, mode, cwd) {
33614
33615
  const gradlewName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
33615
- const gradlew = fs10.existsSync(path22.join(cwd, gradlewName)) ? path22.join(cwd, gradlewName) : null;
33616
+ const gradlew = fs11.existsSync(path22.join(cwd, gradlewName)) ? path22.join(cwd, gradlewName) : null;
33616
33617
  switch (linter) {
33617
33618
  case "ruff":
33618
33619
  return mode === "fix" ? ["ruff", "check", "--fix", "."] : ["ruff", "check", "."];
@@ -33646,12 +33647,12 @@ function getAdditionalLinterCommand(linter, mode, cwd) {
33646
33647
  }
33647
33648
  }
33648
33649
  function detectRuff(cwd) {
33649
- if (fs10.existsSync(path22.join(cwd, "ruff.toml")))
33650
+ if (fs11.existsSync(path22.join(cwd, "ruff.toml")))
33650
33651
  return isCommandAvailable("ruff");
33651
33652
  try {
33652
33653
  const pyproject = path22.join(cwd, "pyproject.toml");
33653
- if (fs10.existsSync(pyproject)) {
33654
- const content = fs10.readFileSync(pyproject, "utf-8");
33654
+ if (fs11.existsSync(pyproject)) {
33655
+ const content = fs11.readFileSync(pyproject, "utf-8");
33655
33656
  if (content.includes("[tool.ruff]"))
33656
33657
  return isCommandAvailable("ruff");
33657
33658
  }
@@ -33659,21 +33660,21 @@ function detectRuff(cwd) {
33659
33660
  return false;
33660
33661
  }
33661
33662
  function detectClippy(cwd) {
33662
- return fs10.existsSync(path22.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
33663
+ return fs11.existsSync(path22.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
33663
33664
  }
33664
33665
  function detectGolangciLint(cwd) {
33665
- return fs10.existsSync(path22.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
33666
+ return fs11.existsSync(path22.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
33666
33667
  }
33667
33668
  function detectCheckstyle(cwd) {
33668
- const hasMaven = fs10.existsSync(path22.join(cwd, "pom.xml"));
33669
- const hasGradle = fs10.existsSync(path22.join(cwd, "build.gradle")) || fs10.existsSync(path22.join(cwd, "build.gradle.kts"));
33670
- const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs10.existsSync(path22.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
33669
+ const hasMaven = fs11.existsSync(path22.join(cwd, "pom.xml"));
33670
+ const hasGradle = fs11.existsSync(path22.join(cwd, "build.gradle")) || fs11.existsSync(path22.join(cwd, "build.gradle.kts"));
33671
+ const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs11.existsSync(path22.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
33671
33672
  return (hasMaven || hasGradle) && hasBinary;
33672
33673
  }
33673
33674
  function detectKtlint(cwd) {
33674
- const hasKotlin = fs10.existsSync(path22.join(cwd, "build.gradle.kts")) || fs10.existsSync(path22.join(cwd, "build.gradle")) || (() => {
33675
+ const hasKotlin = fs11.existsSync(path22.join(cwd, "build.gradle.kts")) || fs11.existsSync(path22.join(cwd, "build.gradle")) || (() => {
33675
33676
  try {
33676
- return fs10.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
33677
+ return fs11.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
33677
33678
  } catch {
33678
33679
  return false;
33679
33680
  }
@@ -33682,7 +33683,7 @@ function detectKtlint(cwd) {
33682
33683
  }
33683
33684
  function detectDotnetFormat(cwd) {
33684
33685
  try {
33685
- const files = fs10.readdirSync(cwd);
33686
+ const files = fs11.readdirSync(cwd);
33686
33687
  const hasCsproj = files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"));
33687
33688
  return hasCsproj && isCommandAvailable("dotnet");
33688
33689
  } catch {
@@ -33690,14 +33691,14 @@ function detectDotnetFormat(cwd) {
33690
33691
  }
33691
33692
  }
33692
33693
  function detectCppcheck(cwd) {
33693
- if (fs10.existsSync(path22.join(cwd, "CMakeLists.txt"))) {
33694
+ if (fs11.existsSync(path22.join(cwd, "CMakeLists.txt"))) {
33694
33695
  return isCommandAvailable("cppcheck");
33695
33696
  }
33696
33697
  try {
33697
33698
  const dirsToCheck = [cwd, path22.join(cwd, "src")];
33698
33699
  const hasCpp = dirsToCheck.some((dir) => {
33699
33700
  try {
33700
- return fs10.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
33701
+ return fs11.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
33701
33702
  } catch {
33702
33703
  return false;
33703
33704
  }
@@ -33708,13 +33709,13 @@ function detectCppcheck(cwd) {
33708
33709
  }
33709
33710
  }
33710
33711
  function detectSwiftlint(cwd) {
33711
- return fs10.existsSync(path22.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
33712
+ return fs11.existsSync(path22.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
33712
33713
  }
33713
33714
  function detectDartAnalyze(cwd) {
33714
- return fs10.existsSync(path22.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
33715
+ return fs11.existsSync(path22.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
33715
33716
  }
33716
33717
  function detectRubocop(cwd) {
33717
- return (fs10.existsSync(path22.join(cwd, "Gemfile")) || fs10.existsSync(path22.join(cwd, "gems.rb")) || fs10.existsSync(path22.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
33718
+ return (fs11.existsSync(path22.join(cwd, "Gemfile")) || fs11.existsSync(path22.join(cwd, "gems.rb")) || fs11.existsSync(path22.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
33718
33719
  }
33719
33720
  function detectAdditionalLinter(cwd) {
33720
33721
  if (detectRuff(cwd))
@@ -33759,7 +33760,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
33759
33760
  const result = await Promise.race([biomeExit, timeout]);
33760
33761
  if (result === "timeout") {
33761
33762
  biomeProc.kill();
33762
- } else if (biomeProc.exitCode === 0 && fs10.existsSync(biomeBin)) {
33763
+ } else if (biomeProc.exitCode === 0 && fs11.existsSync(biomeBin)) {
33763
33764
  return "biome";
33764
33765
  }
33765
33766
  } catch {}
@@ -33773,7 +33774,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
33773
33774
  const result = await Promise.race([eslintExit, timeout]);
33774
33775
  if (result === "timeout") {
33775
33776
  eslintProc.kill();
33776
- } else if (eslintProc.exitCode === 0 && fs10.existsSync(eslintBin)) {
33777
+ } else if (eslintProc.exitCode === 0 && fs11.existsSync(eslintBin)) {
33777
33778
  return "eslint";
33778
33779
  }
33779
33780
  } catch {}
@@ -33950,7 +33951,7 @@ For Rust: rustup component add clippy`
33950
33951
  });
33951
33952
 
33952
33953
  // src/tools/secretscan.ts
33953
- import * as fs11 from "fs";
33954
+ import * as fs12 from "fs";
33954
33955
  import * as path23 from "path";
33955
33956
  function calculateShannonEntropy(str) {
33956
33957
  if (str.length === 0)
@@ -34014,9 +34015,9 @@ function isGlobOrPathPattern(pattern) {
34014
34015
  function loadSecretScanIgnore(scanDir) {
34015
34016
  const ignorePath = path23.join(scanDir, ".secretscanignore");
34016
34017
  try {
34017
- if (!fs11.existsSync(ignorePath))
34018
+ if (!fs12.existsSync(ignorePath))
34018
34019
  return [];
34019
- const content = fs11.readFileSync(ignorePath, "utf8");
34020
+ const content = fs12.readFileSync(ignorePath, "utf8");
34020
34021
  const patterns = [];
34021
34022
  for (const rawLine of content.split(/\r?\n/)) {
34022
34023
  const line = rawLine.trim();
@@ -34137,7 +34138,7 @@ function createRedactedContext(line, findings) {
34137
34138
  function scanFileForSecrets(filePath) {
34138
34139
  const findings = [];
34139
34140
  try {
34140
- const lstat = fs11.lstatSync(filePath);
34141
+ const lstat = fs12.lstatSync(filePath);
34141
34142
  if (lstat.isSymbolicLink()) {
34142
34143
  return findings;
34143
34144
  }
@@ -34146,14 +34147,14 @@ function scanFileForSecrets(filePath) {
34146
34147
  }
34147
34148
  let buffer;
34148
34149
  if (O_NOFOLLOW !== undefined) {
34149
- const fd = fs11.openSync(filePath, "r", O_NOFOLLOW);
34150
+ const fd = fs12.openSync(filePath, "r", O_NOFOLLOW);
34150
34151
  try {
34151
- buffer = fs11.readFileSync(fd);
34152
+ buffer = fs12.readFileSync(fd);
34152
34153
  } finally {
34153
- fs11.closeSync(fd);
34154
+ fs12.closeSync(fd);
34154
34155
  }
34155
34156
  } else {
34156
- buffer = fs11.readFileSync(filePath);
34157
+ buffer = fs12.readFileSync(filePath);
34157
34158
  }
34158
34159
  if (isBinaryFile(filePath, buffer)) {
34159
34160
  return findings;
@@ -34208,7 +34209,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
34208
34209
  const files = [];
34209
34210
  let entries;
34210
34211
  try {
34211
- entries = fs11.readdirSync(dir);
34212
+ entries = fs12.readdirSync(dir);
34212
34213
  } catch {
34213
34214
  stats.fileErrors++;
34214
34215
  return files;
@@ -34231,7 +34232,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
34231
34232
  }
34232
34233
  let lstat;
34233
34234
  try {
34234
- lstat = fs11.lstatSync(fullPath);
34235
+ lstat = fs12.lstatSync(fullPath);
34235
34236
  } catch {
34236
34237
  stats.fileErrors++;
34237
34238
  continue;
@@ -34243,7 +34244,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
34243
34244
  if (lstat.isDirectory()) {
34244
34245
  let realPath;
34245
34246
  try {
34246
- realPath = fs11.realpathSync(fullPath);
34247
+ realPath = fs12.realpathSync(fullPath);
34247
34248
  } catch {
34248
34249
  stats.fileErrors++;
34249
34250
  continue;
@@ -34460,7 +34461,7 @@ var init_secretscan = __esm(() => {
34460
34461
  redactTemplate: () => "SK[REDACTED]"
34461
34462
  }
34462
34463
  ];
34463
- O_NOFOLLOW = process.platform !== "win32" ? fs11.constants.O_NOFOLLOW : undefined;
34464
+ O_NOFOLLOW = process.platform !== "win32" ? fs12.constants.O_NOFOLLOW : undefined;
34464
34465
  secretscan = createSwarmTool({
34465
34466
  description: "Scan directory for potential secrets (API keys, tokens, passwords) using regex patterns and entropy heuristics. Returns metadata-only findings with redacted previews - NEVER returns raw secrets. Excludes common directories (node_modules, .git, dist, etc.) by default. Supports glob patterns (e.g. **/.svelte-kit/**, **/*.test.ts) and reads .secretscanignore at the scan root.",
34466
34467
  args: {
@@ -34518,7 +34519,7 @@ var init_secretscan = __esm(() => {
34518
34519
  }
34519
34520
  try {
34520
34521
  const scanDir = path23.resolve(directory);
34521
- if (!fs11.existsSync(scanDir)) {
34522
+ if (!fs12.existsSync(scanDir)) {
34522
34523
  const errorResult = {
34523
34524
  error: "directory not found",
34524
34525
  scan_dir: directory,
@@ -34529,7 +34530,7 @@ var init_secretscan = __esm(() => {
34529
34530
  };
34530
34531
  return JSON.stringify(errorResult, null, 2);
34531
34532
  }
34532
- const dirStat = fs11.statSync(scanDir);
34533
+ const dirStat = fs12.statSync(scanDir);
34533
34534
  if (!dirStat.isDirectory()) {
34534
34535
  const errorResult = {
34535
34536
  error: "target must be a directory, not a file",
@@ -34580,7 +34581,7 @@ var init_secretscan = __esm(() => {
34580
34581
  break;
34581
34582
  const fileFindings = scanFileForSecrets(filePath);
34582
34583
  try {
34583
- const stat2 = fs11.statSync(filePath);
34584
+ const stat2 = fs12.statSync(filePath);
34584
34585
  if (stat2.size > MAX_FILE_SIZE_BYTES) {
34585
34586
  skippedFiles++;
34586
34587
  continue;
@@ -34652,7 +34653,7 @@ var init_secretscan = __esm(() => {
34652
34653
  });
34653
34654
 
34654
34655
  // src/tools/test-runner.ts
34655
- import * as fs12 from "fs";
34656
+ import * as fs13 from "fs";
34656
34657
  import * as path24 from "path";
34657
34658
  function containsPathTraversal2(str) {
34658
34659
  if (/\.\.[/\\]/.test(str))
@@ -34746,19 +34747,19 @@ function hasDevDependency(devDeps, ...patterns) {
34746
34747
  return hasPackageJsonDependency(devDeps, ...patterns);
34747
34748
  }
34748
34749
  function detectGoTest(cwd) {
34749
- return fs12.existsSync(path24.join(cwd, "go.mod")) && isCommandAvailable("go");
34750
+ return fs13.existsSync(path24.join(cwd, "go.mod")) && isCommandAvailable("go");
34750
34751
  }
34751
34752
  function detectJavaMaven(cwd) {
34752
- return fs12.existsSync(path24.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
34753
+ return fs13.existsSync(path24.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
34753
34754
  }
34754
34755
  function detectGradle(cwd) {
34755
- const hasBuildFile = fs12.existsSync(path24.join(cwd, "build.gradle")) || fs12.existsSync(path24.join(cwd, "build.gradle.kts"));
34756
- const hasGradlew = fs12.existsSync(path24.join(cwd, "gradlew")) || fs12.existsSync(path24.join(cwd, "gradlew.bat"));
34756
+ const hasBuildFile = fs13.existsSync(path24.join(cwd, "build.gradle")) || fs13.existsSync(path24.join(cwd, "build.gradle.kts"));
34757
+ const hasGradlew = fs13.existsSync(path24.join(cwd, "gradlew")) || fs13.existsSync(path24.join(cwd, "gradlew.bat"));
34757
34758
  return hasBuildFile && (hasGradlew || isCommandAvailable("gradle"));
34758
34759
  }
34759
34760
  function detectDotnetTest(cwd) {
34760
34761
  try {
34761
- const files = fs12.readdirSync(cwd);
34762
+ const files = fs13.readdirSync(cwd);
34762
34763
  const hasCsproj = files.some((f) => f.endsWith(".csproj"));
34763
34764
  return hasCsproj && isCommandAvailable("dotnet");
34764
34765
  } catch {
@@ -34766,32 +34767,32 @@ function detectDotnetTest(cwd) {
34766
34767
  }
34767
34768
  }
34768
34769
  function detectCTest(cwd) {
34769
- const hasSource = fs12.existsSync(path24.join(cwd, "CMakeLists.txt"));
34770
- const hasBuildCache = fs12.existsSync(path24.join(cwd, "CMakeCache.txt")) || fs12.existsSync(path24.join(cwd, "build", "CMakeCache.txt"));
34770
+ const hasSource = fs13.existsSync(path24.join(cwd, "CMakeLists.txt"));
34771
+ const hasBuildCache = fs13.existsSync(path24.join(cwd, "CMakeCache.txt")) || fs13.existsSync(path24.join(cwd, "build", "CMakeCache.txt"));
34771
34772
  return (hasSource || hasBuildCache) && isCommandAvailable("ctest");
34772
34773
  }
34773
34774
  function detectSwiftTest(cwd) {
34774
- return fs12.existsSync(path24.join(cwd, "Package.swift")) && isCommandAvailable("swift");
34775
+ return fs13.existsSync(path24.join(cwd, "Package.swift")) && isCommandAvailable("swift");
34775
34776
  }
34776
34777
  function detectDartTest(cwd) {
34777
- return fs12.existsSync(path24.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
34778
+ return fs13.existsSync(path24.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
34778
34779
  }
34779
34780
  function detectRSpec(cwd) {
34780
- const hasRSpecFile = fs12.existsSync(path24.join(cwd, ".rspec"));
34781
- const hasGemfile = fs12.existsSync(path24.join(cwd, "Gemfile"));
34782
- const hasSpecDir = fs12.existsSync(path24.join(cwd, "spec"));
34781
+ const hasRSpecFile = fs13.existsSync(path24.join(cwd, ".rspec"));
34782
+ const hasGemfile = fs13.existsSync(path24.join(cwd, "Gemfile"));
34783
+ const hasSpecDir = fs13.existsSync(path24.join(cwd, "spec"));
34783
34784
  const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
34784
34785
  return hasRSpec && (isCommandAvailable("bundle") || isCommandAvailable("rspec"));
34785
34786
  }
34786
34787
  function detectMinitest(cwd) {
34787
- return fs12.existsSync(path24.join(cwd, "test")) && (fs12.existsSync(path24.join(cwd, "Gemfile")) || fs12.existsSync(path24.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
34788
+ return fs13.existsSync(path24.join(cwd, "test")) && (fs13.existsSync(path24.join(cwd, "Gemfile")) || fs13.existsSync(path24.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
34788
34789
  }
34789
34790
  async function detectTestFramework(cwd) {
34790
34791
  const baseDir = cwd;
34791
34792
  try {
34792
34793
  const packageJsonPath = path24.join(baseDir, "package.json");
34793
- if (fs12.existsSync(packageJsonPath)) {
34794
- const content = fs12.readFileSync(packageJsonPath, "utf-8");
34794
+ if (fs13.existsSync(packageJsonPath)) {
34795
+ const content = fs13.readFileSync(packageJsonPath, "utf-8");
34795
34796
  const pkg = JSON.parse(content);
34796
34797
  const _deps = pkg.dependencies || {};
34797
34798
  const devDeps = pkg.devDependencies || {};
@@ -34810,7 +34811,7 @@ async function detectTestFramework(cwd) {
34810
34811
  return "jest";
34811
34812
  if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
34812
34813
  return "mocha";
34813
- if (fs12.existsSync(path24.join(baseDir, "bun.lockb")) || fs12.existsSync(path24.join(baseDir, "bun.lock"))) {
34814
+ if (fs13.existsSync(path24.join(baseDir, "bun.lockb")) || fs13.existsSync(path24.join(baseDir, "bun.lock"))) {
34814
34815
  if (scripts.test?.includes("bun"))
34815
34816
  return "bun";
34816
34817
  }
@@ -34820,28 +34821,28 @@ async function detectTestFramework(cwd) {
34820
34821
  const pyprojectTomlPath = path24.join(baseDir, "pyproject.toml");
34821
34822
  const setupCfgPath = path24.join(baseDir, "setup.cfg");
34822
34823
  const requirementsTxtPath = path24.join(baseDir, "requirements.txt");
34823
- if (fs12.existsSync(pyprojectTomlPath)) {
34824
- const content = fs12.readFileSync(pyprojectTomlPath, "utf-8");
34824
+ if (fs13.existsSync(pyprojectTomlPath)) {
34825
+ const content = fs13.readFileSync(pyprojectTomlPath, "utf-8");
34825
34826
  if (content.includes("[tool.pytest"))
34826
34827
  return "pytest";
34827
34828
  if (content.includes("pytest"))
34828
34829
  return "pytest";
34829
34830
  }
34830
- if (fs12.existsSync(setupCfgPath)) {
34831
- const content = fs12.readFileSync(setupCfgPath, "utf-8");
34831
+ if (fs13.existsSync(setupCfgPath)) {
34832
+ const content = fs13.readFileSync(setupCfgPath, "utf-8");
34832
34833
  if (content.includes("[pytest]"))
34833
34834
  return "pytest";
34834
34835
  }
34835
- if (fs12.existsSync(requirementsTxtPath)) {
34836
- const content = fs12.readFileSync(requirementsTxtPath, "utf-8");
34836
+ if (fs13.existsSync(requirementsTxtPath)) {
34837
+ const content = fs13.readFileSync(requirementsTxtPath, "utf-8");
34837
34838
  if (content.includes("pytest"))
34838
34839
  return "pytest";
34839
34840
  }
34840
34841
  } catch {}
34841
34842
  try {
34842
34843
  const cargoTomlPath = path24.join(baseDir, "Cargo.toml");
34843
- if (fs12.existsSync(cargoTomlPath)) {
34844
- const content = fs12.readFileSync(cargoTomlPath, "utf-8");
34844
+ if (fs13.existsSync(cargoTomlPath)) {
34845
+ const content = fs13.readFileSync(cargoTomlPath, "utf-8");
34845
34846
  if (content.includes("[dev-dependencies]")) {
34846
34847
  if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
34847
34848
  return "cargo";
@@ -34853,7 +34854,7 @@ async function detectTestFramework(cwd) {
34853
34854
  const pesterConfigPath = path24.join(baseDir, "pester.config.ps1");
34854
34855
  const pesterConfigJsonPath = path24.join(baseDir, "pester.config.ps1.json");
34855
34856
  const pesterPs1Path = path24.join(baseDir, "tests.ps1");
34856
- if (fs12.existsSync(pesterConfigPath) || fs12.existsSync(pesterConfigJsonPath) || fs12.existsSync(pesterPs1Path)) {
34857
+ if (fs13.existsSync(pesterConfigPath) || fs13.existsSync(pesterConfigJsonPath) || fs13.existsSync(pesterPs1Path)) {
34857
34858
  return "pester";
34858
34859
  }
34859
34860
  } catch {}
@@ -34904,7 +34905,7 @@ function getTestFilesFromConvention(sourceFiles) {
34904
34905
  path24.join(dirname10, "test", `${nameWithoutExt}${ext}`)
34905
34906
  ];
34906
34907
  for (const testFile of possibleTestFiles) {
34907
- if (fs12.existsSync(testFile) && !testFiles.includes(testFile)) {
34908
+ if (fs13.existsSync(testFile) && !testFiles.includes(testFile)) {
34908
34909
  testFiles.push(testFile);
34909
34910
  }
34910
34911
  }
@@ -34920,7 +34921,7 @@ async function getTestFilesFromGraph(sourceFiles) {
34920
34921
  }
34921
34922
  for (const testFile of candidateTestFiles) {
34922
34923
  try {
34923
- const content = fs12.readFileSync(testFile, "utf-8");
34924
+ const content = fs13.readFileSync(testFile, "utf-8");
34924
34925
  const testDir = path24.dirname(testFile);
34925
34926
  const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
34926
34927
  let match;
@@ -34941,7 +34942,7 @@ async function getTestFilesFromGraph(sourceFiles) {
34941
34942
  ".cjs"
34942
34943
  ]) {
34943
34944
  const withExt = resolvedImport + extToTry;
34944
- if (sourceFiles.includes(withExt) || fs12.existsSync(withExt)) {
34945
+ if (sourceFiles.includes(withExt) || fs13.existsSync(withExt)) {
34945
34946
  resolvedImport = withExt;
34946
34947
  break;
34947
34948
  }
@@ -34982,7 +34983,7 @@ async function getTestFilesFromGraph(sourceFiles) {
34982
34983
  ".cjs"
34983
34984
  ]) {
34984
34985
  const withExt = resolvedImport + extToTry;
34985
- if (sourceFiles.includes(withExt) || fs12.existsSync(withExt)) {
34986
+ if (sourceFiles.includes(withExt) || fs13.existsSync(withExt)) {
34986
34987
  resolvedImport = withExt;
34987
34988
  break;
34988
34989
  }
@@ -35078,8 +35079,8 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
35078
35079
  return ["mvn", "test"];
35079
35080
  case "gradle": {
35080
35081
  const isWindows = process.platform === "win32";
35081
- const hasGradlewBat = fs12.existsSync(path24.join(baseDir, "gradlew.bat"));
35082
- const hasGradlew = fs12.existsSync(path24.join(baseDir, "gradlew"));
35082
+ const hasGradlewBat = fs13.existsSync(path24.join(baseDir, "gradlew.bat"));
35083
+ const hasGradlew = fs13.existsSync(path24.join(baseDir, "gradlew"));
35083
35084
  if (hasGradlewBat && isWindows)
35084
35085
  return ["gradlew.bat", "test"];
35085
35086
  if (hasGradlew)
@@ -35096,7 +35097,7 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
35096
35097
  "cmake-build-release",
35097
35098
  "out"
35098
35099
  ];
35099
- const actualBuildDir = buildDirCandidates.find((d) => fs12.existsSync(path24.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
35100
+ const actualBuildDir = buildDirCandidates.find((d) => fs13.existsSync(path24.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
35100
35101
  return ["ctest", "--test-dir", actualBuildDir];
35101
35102
  }
35102
35103
  case "swift-test":
@@ -35689,7 +35690,7 @@ var init_test_runner = __esm(() => {
35689
35690
  });
35690
35691
 
35691
35692
  // src/services/preflight-service.ts
35692
- import * as fs13 from "fs";
35693
+ import * as fs14 from "fs";
35693
35694
  import * as path25 from "path";
35694
35695
  function validateDirectoryPath(dir) {
35695
35696
  if (!dir || typeof dir !== "string") {
@@ -35723,8 +35724,8 @@ function validateTimeout(timeoutMs, defaultValue) {
35723
35724
  function getPackageVersion(dir) {
35724
35725
  try {
35725
35726
  const packagePath = path25.join(dir, "package.json");
35726
- if (fs13.existsSync(packagePath)) {
35727
- const content = fs13.readFileSync(packagePath, "utf-8");
35727
+ if (fs14.existsSync(packagePath)) {
35728
+ const content = fs14.readFileSync(packagePath, "utf-8");
35728
35729
  const pkg = JSON.parse(content);
35729
35730
  return pkg.version ?? null;
35730
35731
  }
@@ -35734,8 +35735,8 @@ function getPackageVersion(dir) {
35734
35735
  function getChangelogVersion(dir) {
35735
35736
  try {
35736
35737
  const changelogPath = path25.join(dir, "CHANGELOG.md");
35737
- if (fs13.existsSync(changelogPath)) {
35738
- const content = fs13.readFileSync(changelogPath, "utf-8");
35738
+ if (fs14.existsSync(changelogPath)) {
35739
+ const content = fs14.readFileSync(changelogPath, "utf-8");
35739
35740
  const match = content.match(/^##\s*\[?(\d+\.\d+\.\d+)\]?/m);
35740
35741
  if (match) {
35741
35742
  return match[1];
@@ -35748,9 +35749,9 @@ function getVersionFileVersion(dir) {
35748
35749
  const possibleFiles = ["VERSION.txt", "version.txt", "VERSION", "version"];
35749
35750
  for (const file3 of possibleFiles) {
35750
35751
  const filePath = path25.join(dir, file3);
35751
- if (fs13.existsSync(filePath)) {
35752
+ if (fs14.existsSync(filePath)) {
35752
35753
  try {
35753
- const content = fs13.readFileSync(filePath, "utf-8").trim();
35754
+ const content = fs14.readFileSync(filePath, "utf-8").trim();
35754
35755
  const match = content.match(/(\d+\.\d+\.\d+)/);
35755
35756
  if (match) {
35756
35757
  return match[1];
@@ -36272,7 +36273,7 @@ __export(exports_gate_evidence, {
36272
36273
  deriveRequiredGates: () => deriveRequiredGates,
36273
36274
  DEFAULT_REQUIRED_GATES: () => DEFAULT_REQUIRED_GATES
36274
36275
  });
36275
- import { mkdirSync as mkdirSync9, readFileSync as readFileSync14, renameSync as renameSync9, unlinkSync as unlinkSync5 } from "fs";
36276
+ import { mkdirSync as mkdirSync9, readFileSync as readFileSync14, renameSync as renameSync8, unlinkSync as unlinkSync5 } from "fs";
36276
36277
  import * as path30 from "path";
36277
36278
  function isValidTaskId2(taskId) {
36278
36279
  if (!taskId)
@@ -36337,7 +36338,7 @@ async function atomicWrite(targetPath, content) {
36337
36338
  const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
36338
36339
  try {
36339
36340
  await Bun.write(tempPath, content);
36340
- renameSync9(tempPath, targetPath);
36341
+ renameSync8(tempPath, targetPath);
36341
36342
  } finally {
36342
36343
  try {
36343
36344
  unlinkSync5(tempPath);
@@ -43107,7 +43108,7 @@ function resetAutomationManager() {
43107
43108
  // src/background/plan-sync-worker.ts
43108
43109
  init_manager2();
43109
43110
  init_utils();
43110
- import * as fs4 from "fs";
43111
+ import * as fs5 from "fs";
43111
43112
  import * as path7 from "path";
43112
43113
 
43113
43114
  class PlanSyncWorker {
@@ -43191,7 +43192,7 @@ class PlanSyncWorker {
43191
43192
  }
43192
43193
  initializeStat() {
43193
43194
  try {
43194
- const stats = fs4.statSync(this.getPlanJsonPath());
43195
+ const stats = fs5.statSync(this.getPlanJsonPath());
43195
43196
  this.lastStat = { mtimeMs: stats.mtimeMs, size: stats.size };
43196
43197
  } catch {
43197
43198
  this.lastStat = null;
@@ -43200,11 +43201,11 @@ class PlanSyncWorker {
43200
43201
  setupNativeWatcher() {
43201
43202
  const swarmDir = this.getSwarmDir();
43202
43203
  try {
43203
- if (!fs4.existsSync(swarmDir)) {
43204
+ if (!fs5.existsSync(swarmDir)) {
43204
43205
  log("[PlanSyncWorker] Swarm directory does not exist yet");
43205
43206
  return false;
43206
43207
  }
43207
- this.watcher = fs4.watch(swarmDir, { persistent: false }, (_eventType, filename) => {
43208
+ this.watcher = fs5.watch(swarmDir, { persistent: false }, (_eventType, filename) => {
43208
43209
  if (this.disposed || this.status !== "running") {
43209
43210
  return;
43210
43211
  }
@@ -43251,14 +43252,14 @@ class PlanSyncWorker {
43251
43252
  pollCheck() {
43252
43253
  try {
43253
43254
  const planPath = this.getPlanJsonPath();
43254
- if (!fs4.existsSync(planPath)) {
43255
+ if (!fs5.existsSync(planPath)) {
43255
43256
  if (this.lastStat !== null) {
43256
43257
  this.lastStat = null;
43257
43258
  log("[PlanSyncWorker] plan.json deleted");
43258
43259
  }
43259
43260
  return;
43260
43261
  }
43261
- const stats = fs4.statSync(planPath);
43262
+ const stats = fs5.statSync(planPath);
43262
43263
  const currentStat = { mtimeMs: stats.mtimeMs, size: stats.size };
43263
43264
  if (this.lastStat === null || currentStat.mtimeMs !== this.lastStat.mtimeMs || currentStat.size !== this.lastStat.size) {
43264
43265
  this.lastStat = currentStat;
@@ -43350,9 +43351,9 @@ class PlanSyncWorker {
43350
43351
  const swarmDir = this.getSwarmDir();
43351
43352
  const planJsonPath = path7.join(swarmDir, "plan.json");
43352
43353
  const markerPath = path7.join(swarmDir, ".plan-write-marker");
43353
- const planStats = fs4.statSync(planJsonPath);
43354
+ const planStats = fs5.statSync(planJsonPath);
43354
43355
  const planMtimeMs = planStats.mtimeMs;
43355
- const markerContent = fs4.readFileSync(markerPath, "utf8");
43356
+ const markerContent = fs5.readFileSync(markerPath, "utf8");
43356
43357
  const marker = JSON.parse(markerContent);
43357
43358
  const markerTimestampMs = new Date(marker.timestamp).getTime();
43358
43359
  if (planMtimeMs > markerTimestampMs + 5000) {
@@ -43978,7 +43979,7 @@ import path14 from "path";
43978
43979
 
43979
43980
  // src/hooks/curator.ts
43980
43981
  init_event_bus();
43981
- import * as fs7 from "fs";
43982
+ import * as fs8 from "fs";
43982
43983
  import * as path12 from "path";
43983
43984
 
43984
43985
  // src/hooks/knowledge-store.ts
@@ -44158,10 +44159,10 @@ async function readCuratorSummary(directory) {
44158
44159
  }
44159
44160
  async function writeCuratorSummary(directory, summary) {
44160
44161
  const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
44161
- fs7.mkdirSync(path12.dirname(resolvedPath), { recursive: true });
44162
+ fs8.mkdirSync(path12.dirname(resolvedPath), { recursive: true });
44162
44163
  const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
44163
44164
  await Bun.write(tempPath, JSON.stringify(summary, null, 2));
44164
- fs7.renameSync(tempPath, resolvedPath);
44165
+ fs8.renameSync(tempPath, resolvedPath);
44165
44166
  }
44166
44167
  function normalizeAgentName(name2) {
44167
44168
  return name2.toLowerCase().replace(/^(mega|paid|local|lowtier|modelrelay)_/, "");
@@ -46517,7 +46518,7 @@ async function handleExportCommand(directory, _args) {
46517
46518
  // src/commands/handoff.ts
46518
46519
  init_utils2();
46519
46520
  import crypto3 from "crypto";
46520
- import { renameSync as renameSync6 } from "fs";
46521
+ import { renameSync as renameSync5 } from "fs";
46521
46522
 
46522
46523
  // src/services/handoff-service.ts
46523
46524
  init_utils2();
@@ -46818,7 +46819,7 @@ function formatHandoffMarkdown(data) {
46818
46819
 
46819
46820
  // src/session/snapshot-writer.ts
46820
46821
  init_utils2();
46821
- import { mkdirSync as mkdirSync7, renameSync as renameSync5 } from "fs";
46822
+ import { mkdirSync as mkdirSync7, renameSync as renameSync4 } from "fs";
46822
46823
  import * as path19 from "path";
46823
46824
  var pendingWrite = null;
46824
46825
  var lastWritePromise = Promise.resolve();
@@ -46909,7 +46910,7 @@ async function writeSnapshot(directory, state) {
46909
46910
  mkdirSync7(dir, { recursive: true });
46910
46911
  const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
46911
46912
  await Bun.write(tempPath, content);
46912
- renameSync5(tempPath, resolvedPath);
46913
+ renameSync4(tempPath, resolvedPath);
46913
46914
  } catch (error93) {
46914
46915
  if (process.env.DEBUG_SWARM) {
46915
46916
  console.warn("[snapshot-writer] write failed:", error93 instanceof Error ? error93.message : String(error93));
@@ -46943,7 +46944,7 @@ async function handleHandoffCommand(directory, _args) {
46943
46944
  const resolvedPath = validateSwarmPath(directory, "handoff.md");
46944
46945
  const tempPath = `${resolvedPath}.tmp.${crypto3.randomUUID()}`;
46945
46946
  await Bun.write(tempPath, markdown);
46946
- renameSync6(tempPath, resolvedPath);
46947
+ renameSync5(tempPath, resolvedPath);
46947
46948
  await writeSnapshot(directory, swarmState);
46948
46949
  await flushPendingSnapshot(directory);
46949
46950
  return `## Handoff Brief Written
@@ -47597,7 +47598,7 @@ async function handlePromoteCommand(directory, args2) {
47597
47598
  }
47598
47599
 
47599
47600
  // src/commands/reset.ts
47600
- import * as fs14 from "fs";
47601
+ import * as fs15 from "fs";
47601
47602
  init_utils2();
47602
47603
  async function handleResetCommand(directory, args2) {
47603
47604
  const hasConfirm = args2.includes("--confirm");
@@ -47618,8 +47619,8 @@ async function handleResetCommand(directory, args2) {
47618
47619
  for (const filename of filesToReset) {
47619
47620
  try {
47620
47621
  const resolvedPath = validateSwarmPath(directory, filename);
47621
- if (fs14.existsSync(resolvedPath)) {
47622
- fs14.unlinkSync(resolvedPath);
47622
+ if (fs15.existsSync(resolvedPath)) {
47623
+ fs15.unlinkSync(resolvedPath);
47623
47624
  results.push(`- \u2705 Deleted ${filename}`);
47624
47625
  } else {
47625
47626
  results.push(`- \u23ED\uFE0F ${filename} not found (skipped)`);
@@ -47636,8 +47637,8 @@ async function handleResetCommand(directory, args2) {
47636
47637
  }
47637
47638
  try {
47638
47639
  const summariesPath = validateSwarmPath(directory, "summaries");
47639
- if (fs14.existsSync(summariesPath)) {
47640
- fs14.rmSync(summariesPath, { recursive: true, force: true });
47640
+ if (fs15.existsSync(summariesPath)) {
47641
+ fs15.rmSync(summariesPath, { recursive: true, force: true });
47641
47642
  results.push("- \u2705 Deleted summaries/ directory");
47642
47643
  } else {
47643
47644
  results.push("- \u23ED\uFE0F summaries/ not found (skipped)");
@@ -47657,13 +47658,13 @@ async function handleResetCommand(directory, args2) {
47657
47658
 
47658
47659
  // src/commands/reset-session.ts
47659
47660
  init_utils2();
47660
- import * as fs15 from "fs";
47661
+ import * as fs16 from "fs";
47661
47662
  async function handleResetSessionCommand(directory, _args) {
47662
47663
  const results = [];
47663
47664
  try {
47664
47665
  const statePath = validateSwarmPath(directory, "session/state.json");
47665
- if (fs15.existsSync(statePath)) {
47666
- fs15.unlinkSync(statePath);
47666
+ if (fs16.existsSync(statePath)) {
47667
+ fs16.unlinkSync(statePath);
47667
47668
  results.push("\u2705 Deleted .swarm/session/state.json");
47668
47669
  } else {
47669
47670
  results.push("\u23ED\uFE0F state.json not found (already clean)");
@@ -47689,7 +47690,7 @@ async function handleResetSessionCommand(directory, _args) {
47689
47690
  // src/summaries/manager.ts
47690
47691
  init_utils2();
47691
47692
  init_utils();
47692
- import { mkdirSync as mkdirSync8, readdirSync as readdirSync7, renameSync as renameSync7, rmSync as rmSync3, statSync as statSync7 } from "fs";
47693
+ import { mkdirSync as mkdirSync8, readdirSync as readdirSync7, renameSync as renameSync6, rmSync as rmSync3, statSync as statSync7 } from "fs";
47693
47694
  import * as path26 from "path";
47694
47695
  var SUMMARY_ID_REGEX = /^S\d+$/;
47695
47696
  function sanitizeSummaryId(id) {
@@ -47733,7 +47734,7 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
47733
47734
  const tempPath = path26.join(summaryDir, `${sanitizedId}.json.tmp.${Date.now()}.${process.pid}`);
47734
47735
  try {
47735
47736
  await Bun.write(tempPath, entryJson);
47736
- renameSync7(tempPath, summaryPath);
47737
+ renameSync6(tempPath, summaryPath);
47737
47738
  } catch (error93) {
47738
47739
  try {
47739
47740
  rmSync3(tempPath, { force: true });
@@ -47796,18 +47797,18 @@ ${error93 instanceof Error ? error93.message : String(error93)}`;
47796
47797
 
47797
47798
  // src/commands/rollback.ts
47798
47799
  init_utils2();
47799
- import * as fs16 from "fs";
47800
+ import * as fs17 from "fs";
47800
47801
  import * as path27 from "path";
47801
47802
  async function handleRollbackCommand(directory, args2) {
47802
47803
  const phaseArg = args2[0];
47803
47804
  if (!phaseArg) {
47804
47805
  const manifestPath2 = validateSwarmPath(directory, "checkpoints/manifest.json");
47805
- if (!fs16.existsSync(manifestPath2)) {
47806
+ if (!fs17.existsSync(manifestPath2)) {
47806
47807
  return "No checkpoints found. Use `/swarm checkpoint` to create checkpoints.";
47807
47808
  }
47808
47809
  let manifest2;
47809
47810
  try {
47810
- manifest2 = JSON.parse(fs16.readFileSync(manifestPath2, "utf-8"));
47811
+ manifest2 = JSON.parse(fs17.readFileSync(manifestPath2, "utf-8"));
47811
47812
  } catch {
47812
47813
  return "Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.";
47813
47814
  }
@@ -47829,12 +47830,12 @@ async function handleRollbackCommand(directory, args2) {
47829
47830
  return "Error: Phase number must be a positive integer.";
47830
47831
  }
47831
47832
  const manifestPath = validateSwarmPath(directory, "checkpoints/manifest.json");
47832
- if (!fs16.existsSync(manifestPath)) {
47833
+ if (!fs17.existsSync(manifestPath)) {
47833
47834
  return `Error: No checkpoints found. Cannot rollback to phase ${targetPhase}.`;
47834
47835
  }
47835
47836
  let manifest;
47836
47837
  try {
47837
- manifest = JSON.parse(fs16.readFileSync(manifestPath, "utf-8"));
47838
+ manifest = JSON.parse(fs17.readFileSync(manifestPath, "utf-8"));
47838
47839
  } catch {
47839
47840
  return `Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.`;
47840
47841
  }
@@ -47844,10 +47845,10 @@ async function handleRollbackCommand(directory, args2) {
47844
47845
  return `Error: Checkpoint for phase ${targetPhase} not found. Available phases: ${available}`;
47845
47846
  }
47846
47847
  const checkpointDir = validateSwarmPath(directory, `checkpoints/phase-${targetPhase}`);
47847
- if (!fs16.existsSync(checkpointDir)) {
47848
+ if (!fs17.existsSync(checkpointDir)) {
47848
47849
  return `Error: Checkpoint directory for phase ${targetPhase} does not exist.`;
47849
47850
  }
47850
- const checkpointFiles = fs16.readdirSync(checkpointDir);
47851
+ const checkpointFiles = fs17.readdirSync(checkpointDir);
47851
47852
  if (checkpointFiles.length === 0) {
47852
47853
  return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
47853
47854
  }
@@ -47858,7 +47859,7 @@ async function handleRollbackCommand(directory, args2) {
47858
47859
  const src = path27.join(checkpointDir, file3);
47859
47860
  const dest = path27.join(swarmDir, file3);
47860
47861
  try {
47861
- fs16.cpSync(src, dest, { recursive: true, force: true });
47862
+ fs17.cpSync(src, dest, { recursive: true, force: true });
47862
47863
  successes.push(file3);
47863
47864
  } catch (error93) {
47864
47865
  failures.push({ file: file3, error: error93.message });
@@ -47875,7 +47876,7 @@ async function handleRollbackCommand(directory, args2) {
47875
47876
  timestamp: new Date().toISOString()
47876
47877
  };
47877
47878
  try {
47878
- fs16.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
47879
+ fs17.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
47879
47880
  `);
47880
47881
  } catch (error93) {
47881
47882
  console.error("Failed to write rollback event:", error93);
@@ -47918,11 +47919,11 @@ async function handleSimulateCommand(directory, args2) {
47918
47919
  ];
47919
47920
  const report = reportLines.filter(Boolean).join(`
47920
47921
  `);
47921
- const fs17 = await import("fs/promises");
47922
+ const fs18 = await import("fs/promises");
47922
47923
  const path28 = await import("path");
47923
47924
  const reportPath = path28.join(directory, ".swarm", "simulate-report.md");
47924
- await fs17.mkdir(path28.dirname(reportPath), { recursive: true });
47925
- await fs17.writeFile(reportPath, report, "utf-8");
47925
+ await fs18.mkdir(path28.dirname(reportPath), { recursive: true });
47926
+ await fs18.writeFile(reportPath, report, "utf-8");
47926
47927
  return `${darkMatterPairs.length} hidden coupling pairs detected`;
47927
47928
  }
47928
47929
 
@@ -48279,7 +48280,7 @@ init_utils2();
48279
48280
  init_manager2();
48280
48281
 
48281
48282
  // src/services/compaction-service.ts
48282
- import * as fs17 from "fs";
48283
+ import * as fs18 from "fs";
48283
48284
  import * as path28 from "path";
48284
48285
  function makeInitialState() {
48285
48286
  return {
@@ -48301,7 +48302,7 @@ function appendSnapshot(directory, tier, budgetPct, message) {
48301
48302
  ## [${tier.toUpperCase()}] ${timestamp} \u2014 ${budgetPct.toFixed(1)}% used
48302
48303
  ${message}
48303
48304
  `;
48304
- fs17.appendFileSync(snapshotPath, entry, "utf-8");
48305
+ fs18.appendFileSync(snapshotPath, entry, "utf-8");
48305
48306
  } catch {}
48306
48307
  }
48307
48308
  function buildObservationMessage(budgetPct) {
@@ -49275,7 +49276,7 @@ init_constants();
49275
49276
  init_schema();
49276
49277
 
49277
49278
  // src/hooks/agent-activity.ts
49278
- import { renameSync as renameSync8, unlinkSync as unlinkSync4 } from "fs";
49279
+ import { renameSync as renameSync7, unlinkSync as unlinkSync4 } from "fs";
49279
49280
  init_utils();
49280
49281
  init_utils2();
49281
49282
  function createAgentActivityHooks(config3, directory) {
@@ -49349,7 +49350,7 @@ async function doFlush(directory) {
49349
49350
  const tempPath = `${path29}.tmp`;
49350
49351
  try {
49351
49352
  await Bun.write(tempPath, updated);
49352
- renameSync8(tempPath, path29);
49353
+ renameSync7(tempPath, path29);
49353
49354
  } catch (writeError) {
49354
49355
  try {
49355
49356
  unlinkSync4(tempPath);
@@ -49398,7 +49399,7 @@ ${content.substring(endIndex + 1)}`;
49398
49399
  }
49399
49400
  // src/hooks/compaction-customizer.ts
49400
49401
  init_manager2();
49401
- import * as fs18 from "fs";
49402
+ import * as fs19 from "fs";
49402
49403
  import { join as join25 } from "path";
49403
49404
  init_utils2();
49404
49405
  function createCompactionCustomizerHook(config3, directory) {
@@ -49446,7 +49447,7 @@ function createCompactionCustomizerHook(config3, directory) {
49446
49447
  }
49447
49448
  try {
49448
49449
  const summariesDir = join25(directory, ".swarm", "summaries");
49449
- const files = await fs18.promises.readdir(summariesDir);
49450
+ const files = await fs19.promises.readdir(summariesDir);
49450
49451
  if (files.length > 0) {
49451
49452
  const count = files.length;
49452
49453
  output.context.push(`[CONTEXT OPTIMIZATION] Tool outputs from earlier in this session have been stored to disk. When compacting, replace any large tool output blocks (bash, test_runner, lint, diff results) with a one-line reference: "[Output stored \u2014 use /swarm retrieve to access full content]". Preserve the tool name, exit status, and any error messages. Discard raw output lines.`);
@@ -49931,7 +49932,7 @@ function maskToolOutput(msg, _threshold) {
49931
49932
  }
49932
49933
  // src/hooks/delegation-gate.ts
49933
49934
  init_schema();
49934
- import * as fs19 from "fs";
49935
+ import * as fs20 from "fs";
49935
49936
  import * as path31 from "path";
49936
49937
 
49937
49938
  // src/hooks/guardrails.ts
@@ -50876,7 +50877,7 @@ async function getEvidenceTaskId(session, directory) {
50876
50877
  if (!resolvedPlanPath.startsWith(resolvedDirectory + path31.sep) && resolvedPlanPath !== resolvedDirectory) {
50877
50878
  return null;
50878
50879
  }
50879
- const planContent = await fs19.promises.readFile(resolvedPlanPath, "utf-8");
50880
+ const planContent = await fs20.promises.readFile(resolvedPlanPath, "utf-8");
50880
50881
  const plan = JSON.parse(planContent);
50881
50882
  if (!plan || !Array.isArray(plan.phases)) {
50882
50883
  return null;
@@ -51349,7 +51350,7 @@ ${warningLines.join(`
51349
51350
  }
51350
51351
  // src/hooks/delegation-sanitizer.ts
51351
51352
  init_utils2();
51352
- import * as fs20 from "fs";
51353
+ import * as fs21 from "fs";
51353
51354
  var SANITIZATION_PATTERNS = [
51354
51355
  /\b\d+(st|nd|rd|th)\s+(attempt|try|time)\b/gi,
51355
51356
  /\b(5th|fifth|final|last)\s+attempt\b/gi,
@@ -51420,7 +51421,7 @@ function createDelegationSanitizerHook(directory) {
51420
51421
  stripped_patterns: result.stripped,
51421
51422
  timestamp: new Date().toISOString()
51422
51423
  };
51423
- fs20.appendFileSync(eventsPath, `${JSON.stringify(event)}
51424
+ fs21.appendFileSync(eventsPath, `${JSON.stringify(event)}
51424
51425
  `, "utf-8");
51425
51426
  } catch {}
51426
51427
  }
@@ -51677,12 +51678,12 @@ init_schema();
51677
51678
  init_manager();
51678
51679
  init_detector();
51679
51680
  init_manager2();
51680
- import * as fs22 from "fs";
51681
+ import * as fs23 from "fs";
51681
51682
 
51682
51683
  // src/services/decision-drift-analyzer.ts
51683
51684
  init_utils2();
51684
51685
  init_manager2();
51685
- import * as fs21 from "fs";
51686
+ import * as fs22 from "fs";
51686
51687
  import * as path33 from "path";
51687
51688
  var DEFAULT_DRIFT_CONFIG = {
51688
51689
  staleThresholdPhases: 1,
@@ -51840,8 +51841,8 @@ async function analyzeDecisionDrift(directory, config3 = {}) {
51840
51841
  const contextPath = path33.join(directory, ".swarm", "context.md");
51841
51842
  let contextContent = "";
51842
51843
  try {
51843
- if (fs21.existsSync(contextPath)) {
51844
- contextContent = fs21.readFileSync(contextPath, "utf-8");
51844
+ if (fs22.existsSync(contextPath)) {
51845
+ contextContent = fs22.readFileSync(contextPath, "utf-8");
51845
51846
  }
51846
51847
  } catch {
51847
51848
  return {
@@ -52335,11 +52336,11 @@ function createSystemEnhancerHook(config3, directory) {
52335
52336
  if (handoffContent) {
52336
52337
  const handoffPath = validateSwarmPath(directory, "handoff.md");
52337
52338
  const consumedPath = validateSwarmPath(directory, "handoff-consumed.md");
52338
- if (fs22.existsSync(consumedPath)) {
52339
+ if (fs23.existsSync(consumedPath)) {
52339
52340
  warn("Duplicate handoff detected: handoff-consumed.md already exists");
52340
- fs22.unlinkSync(consumedPath);
52341
+ fs23.unlinkSync(consumedPath);
52341
52342
  }
52342
- fs22.renameSync(handoffPath, consumedPath);
52343
+ fs23.renameSync(handoffPath, consumedPath);
52343
52344
  const handoffBlock = `## HANDOFF \u2014 Resuming from model switch
52344
52345
  The previous model's session ended. Here is your starting context:
52345
52346
 
@@ -52619,11 +52620,11 @@ ${budgetWarning}`);
52619
52620
  if (handoffContent) {
52620
52621
  const handoffPath = validateSwarmPath(directory, "handoff.md");
52621
52622
  const consumedPath = validateSwarmPath(directory, "handoff-consumed.md");
52622
- if (fs22.existsSync(consumedPath)) {
52623
+ if (fs23.existsSync(consumedPath)) {
52623
52624
  warn("Duplicate handoff detected: handoff-consumed.md already exists");
52624
- fs22.unlinkSync(consumedPath);
52625
+ fs23.unlinkSync(consumedPath);
52625
52626
  }
52626
- fs22.renameSync(handoffPath, consumedPath);
52627
+ fs23.renameSync(handoffPath, consumedPath);
52627
52628
  const handoffBlock = `## HANDOFF \u2014 Resuming from model switch
52628
52629
  The previous model's session ended. Here is your starting context:
52629
52630
 
@@ -53392,7 +53393,7 @@ function isReadTool(toolName) {
53392
53393
  }
53393
53394
 
53394
53395
  // src/hooks/incremental-verify.ts
53395
- import * as fs23 from "fs";
53396
+ import * as fs24 from "fs";
53396
53397
  import * as path34 from "path";
53397
53398
 
53398
53399
  // src/hooks/spawn-helper.ts
@@ -53468,21 +53469,21 @@ function spawnAsync(command, cwd, timeoutMs) {
53468
53469
  // src/hooks/incremental-verify.ts
53469
53470
  var emittedSkipAdvisories = new Set;
53470
53471
  function detectPackageManager(projectDir) {
53471
- if (fs23.existsSync(path34.join(projectDir, "bun.lockb")))
53472
+ if (fs24.existsSync(path34.join(projectDir, "bun.lockb")))
53472
53473
  return "bun";
53473
- if (fs23.existsSync(path34.join(projectDir, "pnpm-lock.yaml")))
53474
+ if (fs24.existsSync(path34.join(projectDir, "pnpm-lock.yaml")))
53474
53475
  return "pnpm";
53475
- if (fs23.existsSync(path34.join(projectDir, "yarn.lock")))
53476
+ if (fs24.existsSync(path34.join(projectDir, "yarn.lock")))
53476
53477
  return "yarn";
53477
- if (fs23.existsSync(path34.join(projectDir, "package-lock.json")))
53478
+ if (fs24.existsSync(path34.join(projectDir, "package-lock.json")))
53478
53479
  return "npm";
53479
53480
  return "bun";
53480
53481
  }
53481
53482
  function detectTypecheckCommand(projectDir) {
53482
53483
  const pkgPath = path34.join(projectDir, "package.json");
53483
- if (fs23.existsSync(pkgPath)) {
53484
+ if (fs24.existsSync(pkgPath)) {
53484
53485
  try {
53485
- const pkg = JSON.parse(fs23.readFileSync(pkgPath, "utf8"));
53486
+ const pkg = JSON.parse(fs24.readFileSync(pkgPath, "utf8"));
53486
53487
  const scripts = pkg.scripts;
53487
53488
  if (scripts?.typecheck) {
53488
53489
  const pm = detectPackageManager(projectDir);
@@ -53496,8 +53497,8 @@ function detectTypecheckCommand(projectDir) {
53496
53497
  ...pkg.dependencies,
53497
53498
  ...pkg.devDependencies
53498
53499
  };
53499
- if (!deps?.typescript && !fs23.existsSync(path34.join(projectDir, "tsconfig.json"))) {}
53500
- const hasTSMarkers = deps?.typescript || fs23.existsSync(path34.join(projectDir, "tsconfig.json"));
53500
+ if (!deps?.typescript && !fs24.existsSync(path34.join(projectDir, "tsconfig.json"))) {}
53501
+ const hasTSMarkers = deps?.typescript || fs24.existsSync(path34.join(projectDir, "tsconfig.json"));
53501
53502
  if (hasTSMarkers) {
53502
53503
  return { command: ["npx", "tsc", "--noEmit"], language: "typescript" };
53503
53504
  }
@@ -53505,17 +53506,17 @@ function detectTypecheckCommand(projectDir) {
53505
53506
  return null;
53506
53507
  }
53507
53508
  }
53508
- if (fs23.existsSync(path34.join(projectDir, "go.mod"))) {
53509
+ if (fs24.existsSync(path34.join(projectDir, "go.mod"))) {
53509
53510
  return { command: ["go", "vet", "./..."], language: "go" };
53510
53511
  }
53511
- if (fs23.existsSync(path34.join(projectDir, "Cargo.toml"))) {
53512
+ if (fs24.existsSync(path34.join(projectDir, "Cargo.toml"))) {
53512
53513
  return { command: ["cargo", "check"], language: "rust" };
53513
53514
  }
53514
- if (fs23.existsSync(path34.join(projectDir, "pyproject.toml")) || fs23.existsSync(path34.join(projectDir, "requirements.txt")) || fs23.existsSync(path34.join(projectDir, "setup.py"))) {
53515
+ if (fs24.existsSync(path34.join(projectDir, "pyproject.toml")) || fs24.existsSync(path34.join(projectDir, "requirements.txt")) || fs24.existsSync(path34.join(projectDir, "setup.py"))) {
53515
53516
  return { command: null, language: "python" };
53516
53517
  }
53517
53518
  try {
53518
- const entries = fs23.readdirSync(projectDir);
53519
+ const entries = fs24.readdirSync(projectDir);
53519
53520
  if (entries.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
53520
53521
  return {
53521
53522
  command: ["dotnet", "build", "--no-restore"],
@@ -54209,12 +54210,12 @@ Use this data to avoid repeating known failure patterns.`;
54209
54210
  // src/hooks/curator-drift.ts
54210
54211
  init_event_bus();
54211
54212
  init_utils2();
54212
- import * as fs24 from "fs";
54213
+ import * as fs25 from "fs";
54213
54214
  import * as path36 from "path";
54214
54215
  var DRIFT_REPORT_PREFIX = "drift-report-phase-";
54215
54216
  async function readPriorDriftReports(directory) {
54216
54217
  const swarmDir = path36.join(directory, ".swarm");
54217
- const entries = await fs24.promises.readdir(swarmDir).catch(() => null);
54218
+ const entries = await fs25.promises.readdir(swarmDir).catch(() => null);
54218
54219
  if (entries === null)
54219
54220
  return [];
54220
54221
  const reportFiles = entries.filter((name2) => name2.startsWith(DRIFT_REPORT_PREFIX) && name2.endsWith(".json")).sort();
@@ -54241,9 +54242,9 @@ async function writeDriftReport(directory, report) {
54241
54242
  const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
54242
54243
  const filePath = validateSwarmPath(directory, filename);
54243
54244
  const swarmDir = path36.dirname(filePath);
54244
- await fs24.promises.mkdir(swarmDir, { recursive: true });
54245
+ await fs25.promises.mkdir(swarmDir, { recursive: true });
54245
54246
  try {
54246
- await fs24.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
54247
+ await fs25.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
54247
54248
  } catch (err2) {
54248
54249
  throw new Error(`[curator-drift] Failed to write drift report to ${filePath}: ${String(err2)}`);
54249
54250
  }
@@ -54634,7 +54635,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
54634
54635
  }
54635
54636
 
54636
54637
  // src/hooks/slop-detector.ts
54637
- import * as fs25 from "fs";
54638
+ import * as fs26 from "fs";
54638
54639
  import * as path38 from "path";
54639
54640
  var WRITE_EDIT_TOOLS = new Set([
54640
54641
  "write",
@@ -54680,7 +54681,7 @@ function checkBoilerplateExplosion(content, taskDescription, threshold) {
54680
54681
  function walkFiles(dir, exts, deadline) {
54681
54682
  const results = [];
54682
54683
  try {
54683
- for (const entry of fs25.readdirSync(dir, { withFileTypes: true })) {
54684
+ for (const entry of fs26.readdirSync(dir, { withFileTypes: true })) {
54684
54685
  if (deadline !== undefined && Date.now() > deadline)
54685
54686
  break;
54686
54687
  if (entry.isSymbolicLink())
@@ -54700,7 +54701,7 @@ function walkFiles(dir, exts, deadline) {
54700
54701
  return results;
54701
54702
  }
54702
54703
  function checkDeadExports(content, projectDir, startTime) {
54703
- const hasPackageJson = fs25.existsSync(path38.join(projectDir, "package.json"));
54704
+ const hasPackageJson = fs26.existsSync(path38.join(projectDir, "package.json"));
54704
54705
  if (!hasPackageJson)
54705
54706
  return null;
54706
54707
  const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
@@ -54723,7 +54724,7 @@ function checkDeadExports(content, projectDir, startTime) {
54723
54724
  if (found || Date.now() - startTime > 480)
54724
54725
  break;
54725
54726
  try {
54726
- const text = fs25.readFileSync(file3, "utf-8");
54727
+ const text = fs26.readFileSync(file3, "utf-8");
54727
54728
  if (importPattern.test(text))
54728
54729
  found = true;
54729
54730
  importPattern.lastIndex = 0;
@@ -54856,7 +54857,7 @@ Review before proceeding.`;
54856
54857
 
54857
54858
  // src/hooks/steering-consumed.ts
54858
54859
  init_utils2();
54859
- import * as fs26 from "fs";
54860
+ import * as fs27 from "fs";
54860
54861
  function recordSteeringConsumed(directory, directiveId) {
54861
54862
  try {
54862
54863
  const eventsPath = validateSwarmPath(directory, "events.jsonl");
@@ -54865,7 +54866,7 @@ function recordSteeringConsumed(directory, directiveId) {
54865
54866
  directiveId,
54866
54867
  timestamp: new Date().toISOString()
54867
54868
  };
54868
- fs26.appendFileSync(eventsPath, `${JSON.stringify(event)}
54869
+ fs27.appendFileSync(eventsPath, `${JSON.stringify(event)}
54869
54870
  `, "utf-8");
54870
54871
  } catch {}
54871
54872
  }
@@ -55259,7 +55260,7 @@ var build_check = createSwarmTool({
55259
55260
  init_dist();
55260
55261
  init_manager();
55261
55262
  init_create_tool();
55262
- import * as fs27 from "fs";
55263
+ import * as fs28 from "fs";
55263
55264
  import * as path39 from "path";
55264
55265
  var EVIDENCE_DIR = ".swarm/evidence";
55265
55266
  var TASK_ID_PATTERN2 = /^\d+\.\d+(\.\d+)*$/;
@@ -55283,12 +55284,12 @@ function isPathWithinSwarm(filePath, workspaceRoot) {
55283
55284
  return normalizedPath.startsWith(swarmPath);
55284
55285
  }
55285
55286
  function readEvidenceFile(evidencePath) {
55286
- if (!fs27.existsSync(evidencePath)) {
55287
+ if (!fs28.existsSync(evidencePath)) {
55287
55288
  return null;
55288
55289
  }
55289
55290
  let content;
55290
55291
  try {
55291
- content = fs27.readFileSync(evidencePath, "utf-8");
55292
+ content = fs28.readFileSync(evidencePath, "utf-8");
55292
55293
  } catch {
55293
55294
  return null;
55294
55295
  }
@@ -55434,7 +55435,7 @@ init_checkpoint();
55434
55435
  // src/tools/complexity-hotspots.ts
55435
55436
  init_dist();
55436
55437
  init_create_tool();
55437
- import * as fs28 from "fs";
55438
+ import * as fs29 from "fs";
55438
55439
  import * as path40 from "path";
55439
55440
  var MAX_FILE_SIZE_BYTES2 = 256 * 1024;
55440
55441
  var DEFAULT_DAYS = 90;
@@ -55564,11 +55565,11 @@ function estimateComplexity(content) {
55564
55565
  }
55565
55566
  function getComplexityForFile(filePath) {
55566
55567
  try {
55567
- const stat2 = fs28.statSync(filePath);
55568
+ const stat2 = fs29.statSync(filePath);
55568
55569
  if (stat2.size > MAX_FILE_SIZE_BYTES2) {
55569
55570
  return null;
55570
55571
  }
55571
- const content = fs28.readFileSync(filePath, "utf-8");
55572
+ const content = fs29.readFileSync(filePath, "utf-8");
55572
55573
  return estimateComplexity(content);
55573
55574
  } catch {
55574
55575
  return null;
@@ -55589,7 +55590,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
55589
55590
  let analyzedFiles = 0;
55590
55591
  for (const [file3, churnCount] of filteredChurn) {
55591
55592
  let fullPath = file3;
55592
- if (!fs28.existsSync(fullPath)) {
55593
+ if (!fs29.existsSync(fullPath)) {
55593
55594
  fullPath = path40.join(cwd, file3);
55594
55595
  }
55595
55596
  const complexity = getComplexityForFile(fullPath);
@@ -55798,7 +55799,7 @@ var curator_analyze = createSwarmTool({
55798
55799
  });
55799
55800
  // src/tools/declare-scope.ts
55800
55801
  init_tool();
55801
- import * as fs29 from "fs";
55802
+ import * as fs30 from "fs";
55802
55803
  import * as path41 from "path";
55803
55804
  init_create_tool();
55804
55805
  function validateTaskIdFormat(taskId) {
@@ -55891,9 +55892,9 @@ async function executeDeclareScope(args2, fallbackDir) {
55891
55892
  }
55892
55893
  const resolvedDir = path41.resolve(normalizedDir);
55893
55894
  try {
55894
- const realPath = fs29.realpathSync(resolvedDir);
55895
+ const realPath = fs30.realpathSync(resolvedDir);
55895
55896
  const planPath2 = path41.join(realPath, ".swarm", "plan.json");
55896
- if (!fs29.existsSync(planPath2)) {
55897
+ if (!fs30.existsSync(planPath2)) {
55897
55898
  return {
55898
55899
  success: false,
55899
55900
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -55917,7 +55918,7 @@ async function executeDeclareScope(args2, fallbackDir) {
55917
55918
  }
55918
55919
  const directory = normalizedDir || fallbackDir;
55919
55920
  const planPath = path41.resolve(directory, ".swarm", "plan.json");
55920
- if (!fs29.existsSync(planPath)) {
55921
+ if (!fs30.existsSync(planPath)) {
55921
55922
  return {
55922
55923
  success: false,
55923
55924
  message: "No plan found",
@@ -55926,7 +55927,7 @@ async function executeDeclareScope(args2, fallbackDir) {
55926
55927
  }
55927
55928
  let planContent;
55928
55929
  try {
55929
- planContent = JSON.parse(fs29.readFileSync(planPath, "utf-8"));
55930
+ planContent = JSON.parse(fs30.readFileSync(planPath, "utf-8"));
55930
55931
  } catch {
55931
55932
  return {
55932
55933
  success: false,
@@ -56152,7 +56153,7 @@ var diff = createSwarmTool({
56152
56153
  init_dist();
56153
56154
  init_schema();
56154
56155
  import * as crypto4 from "crypto";
56155
- import * as fs30 from "fs";
56156
+ import * as fs31 from "fs";
56156
56157
  import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
56157
56158
  import * as path42 from "path";
56158
56159
  init_create_tool();
@@ -56253,7 +56254,7 @@ async function scanDocIndex(directory) {
56253
56254
  for (const file3 of existingManifest.files) {
56254
56255
  try {
56255
56256
  const fullPath = path42.join(directory, file3.path);
56256
- const stat2 = fs30.statSync(fullPath);
56257
+ const stat2 = fs31.statSync(fullPath);
56257
56258
  if (stat2.mtimeMs > new Date(existingManifest.scanned_at).getTime()) {
56258
56259
  cacheValid = false;
56259
56260
  break;
@@ -56271,7 +56272,7 @@ async function scanDocIndex(directory) {
56271
56272
  const discoveredFiles = [];
56272
56273
  let rawEntries;
56273
56274
  try {
56274
- rawEntries = fs30.readdirSync(directory, { recursive: true });
56275
+ rawEntries = fs31.readdirSync(directory, { recursive: true });
56275
56276
  } catch {
56276
56277
  const manifest2 = {
56277
56278
  schema_version: 1,
@@ -56285,7 +56286,7 @@ async function scanDocIndex(directory) {
56285
56286
  const fullPath = path42.join(directory, entry);
56286
56287
  let stat2;
56287
56288
  try {
56288
- stat2 = fs30.statSync(fullPath);
56289
+ stat2 = fs31.statSync(fullPath);
56289
56290
  } catch {
56290
56291
  continue;
56291
56292
  }
@@ -56314,7 +56315,7 @@ async function scanDocIndex(directory) {
56314
56315
  }
56315
56316
  let content;
56316
56317
  try {
56317
- content = fs30.readFileSync(fullPath, "utf-8");
56318
+ content = fs31.readFileSync(fullPath, "utf-8");
56318
56319
  } catch {
56319
56320
  continue;
56320
56321
  }
@@ -56491,7 +56492,7 @@ var doc_scan = createSwarmTool({
56491
56492
  if (force) {
56492
56493
  const manifestPath = path42.join(directory, ".swarm", "doc-manifest.json");
56493
56494
  try {
56494
- fs30.unlinkSync(manifestPath);
56495
+ fs31.unlinkSync(manifestPath);
56495
56496
  } catch {}
56496
56497
  }
56497
56498
  const { manifest, cached: cached3 } = await scanDocIndex(directory);
@@ -56716,7 +56717,7 @@ Use these as DOMAIN values when delegating to @sme.`;
56716
56717
  // src/tools/evidence-check.ts
56717
56718
  init_dist();
56718
56719
  init_create_tool();
56719
- import * as fs31 from "fs";
56720
+ import * as fs32 from "fs";
56720
56721
  import * as path43 from "path";
56721
56722
  var MAX_FILE_SIZE_BYTES3 = 1024 * 1024;
56722
56723
  var MAX_EVIDENCE_FILES = 1000;
@@ -56765,12 +56766,12 @@ function parseCompletedTasks(planContent) {
56765
56766
  }
56766
56767
  function readEvidenceFiles(evidenceDir, _cwd) {
56767
56768
  const evidence = [];
56768
- if (!fs31.existsSync(evidenceDir) || !fs31.statSync(evidenceDir).isDirectory()) {
56769
+ if (!fs32.existsSync(evidenceDir) || !fs32.statSync(evidenceDir).isDirectory()) {
56769
56770
  return evidence;
56770
56771
  }
56771
56772
  let files;
56772
56773
  try {
56773
- files = fs31.readdirSync(evidenceDir);
56774
+ files = fs32.readdirSync(evidenceDir);
56774
56775
  } catch {
56775
56776
  return evidence;
56776
56777
  }
@@ -56786,7 +56787,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
56786
56787
  if (!resolvedPath.startsWith(evidenceDirResolved)) {
56787
56788
  continue;
56788
56789
  }
56789
- const stat2 = fs31.lstatSync(filePath);
56790
+ const stat2 = fs32.lstatSync(filePath);
56790
56791
  if (!stat2.isFile()) {
56791
56792
  continue;
56792
56793
  }
@@ -56795,7 +56796,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
56795
56796
  }
56796
56797
  let fileStat;
56797
56798
  try {
56798
- fileStat = fs31.statSync(filePath);
56799
+ fileStat = fs32.statSync(filePath);
56799
56800
  if (fileStat.size > MAX_FILE_SIZE_BYTES3) {
56800
56801
  continue;
56801
56802
  }
@@ -56804,7 +56805,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
56804
56805
  }
56805
56806
  let content;
56806
56807
  try {
56807
- content = fs31.readFileSync(filePath, "utf-8");
56808
+ content = fs32.readFileSync(filePath, "utf-8");
56808
56809
  } catch {
56809
56810
  continue;
56810
56811
  }
@@ -56914,7 +56915,7 @@ var evidence_check = createSwarmTool({
56914
56915
  }
56915
56916
  let planContent;
56916
56917
  try {
56917
- planContent = fs31.readFileSync(planPath, "utf-8");
56918
+ planContent = fs32.readFileSync(planPath, "utf-8");
56918
56919
  } catch {
56919
56920
  const result2 = {
56920
56921
  message: "No completed tasks found in plan.",
@@ -56949,7 +56950,7 @@ var evidence_check = createSwarmTool({
56949
56950
  // src/tools/file-extractor.ts
56950
56951
  init_tool();
56951
56952
  init_create_tool();
56952
- import * as fs32 from "fs";
56953
+ import * as fs33 from "fs";
56953
56954
  import * as path44 from "path";
56954
56955
  var EXT_MAP = {
56955
56956
  python: ".py",
@@ -57012,8 +57013,8 @@ var extract_code_blocks = createSwarmTool({
57012
57013
  execute: async (args2, directory) => {
57013
57014
  const { content, output_dir, prefix } = args2;
57014
57015
  const targetDir = output_dir || directory;
57015
- if (!fs32.existsSync(targetDir)) {
57016
- fs32.mkdirSync(targetDir, { recursive: true });
57016
+ if (!fs33.existsSync(targetDir)) {
57017
+ fs33.mkdirSync(targetDir, { recursive: true });
57017
57018
  }
57018
57019
  if (!content) {
57019
57020
  return "Error: content is required";
@@ -57035,12 +57036,12 @@ var extract_code_blocks = createSwarmTool({
57035
57036
  const base = path44.basename(filepath, path44.extname(filepath));
57036
57037
  const ext = path44.extname(filepath);
57037
57038
  let counter = 1;
57038
- while (fs32.existsSync(filepath)) {
57039
+ while (fs33.existsSync(filepath)) {
57039
57040
  filepath = path44.join(targetDir, `${base}_${counter}${ext}`);
57040
57041
  counter++;
57041
57042
  }
57042
57043
  try {
57043
- fs32.writeFileSync(filepath, code.trim(), "utf-8");
57044
+ fs33.writeFileSync(filepath, code.trim(), "utf-8");
57044
57045
  savedFiles.push(filepath);
57045
57046
  } catch (error93) {
57046
57047
  errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
@@ -57156,7 +57157,7 @@ var gitingest = createSwarmTool({
57156
57157
  // src/tools/imports.ts
57157
57158
  init_dist();
57158
57159
  init_create_tool();
57159
- import * as fs33 from "fs";
57160
+ import * as fs34 from "fs";
57160
57161
  import * as path45 from "path";
57161
57162
  var MAX_FILE_PATH_LENGTH2 = 500;
57162
57163
  var MAX_SYMBOL_LENGTH = 256;
@@ -57325,7 +57326,7 @@ var SKIP_DIRECTORIES3 = new Set([
57325
57326
  function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
57326
57327
  let entries;
57327
57328
  try {
57328
- entries = fs33.readdirSync(dir);
57329
+ entries = fs34.readdirSync(dir);
57329
57330
  } catch (e) {
57330
57331
  stats.fileErrors.push({
57331
57332
  path: dir,
@@ -57342,7 +57343,7 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
57342
57343
  const fullPath = path45.join(dir, entry);
57343
57344
  let stat2;
57344
57345
  try {
57345
- stat2 = fs33.statSync(fullPath);
57346
+ stat2 = fs34.statSync(fullPath);
57346
57347
  } catch (e) {
57347
57348
  stats.fileErrors.push({
57348
57349
  path: fullPath,
@@ -57411,7 +57412,7 @@ var imports = createSwarmTool({
57411
57412
  }
57412
57413
  try {
57413
57414
  const targetFile = path45.resolve(file3);
57414
- if (!fs33.existsSync(targetFile)) {
57415
+ if (!fs34.existsSync(targetFile)) {
57415
57416
  const errorResult = {
57416
57417
  error: `target file not found: ${file3}`,
57417
57418
  target: file3,
@@ -57421,7 +57422,7 @@ var imports = createSwarmTool({
57421
57422
  };
57422
57423
  return JSON.stringify(errorResult, null, 2);
57423
57424
  }
57424
- const targetStat = fs33.statSync(targetFile);
57425
+ const targetStat = fs34.statSync(targetFile);
57425
57426
  if (!targetStat.isFile()) {
57426
57427
  const errorResult = {
57427
57428
  error: "target must be a file, not a directory",
@@ -57447,12 +57448,12 @@ var imports = createSwarmTool({
57447
57448
  if (consumers.length >= MAX_CONSUMERS)
57448
57449
  break;
57449
57450
  try {
57450
- const stat2 = fs33.statSync(filePath);
57451
+ const stat2 = fs34.statSync(filePath);
57451
57452
  if (stat2.size > MAX_FILE_SIZE_BYTES4) {
57452
57453
  skippedFileCount++;
57453
57454
  continue;
57454
57455
  }
57455
- const buffer = fs33.readFileSync(filePath);
57456
+ const buffer = fs34.readFileSync(filePath);
57456
57457
  if (isBinaryFile2(filePath, buffer)) {
57457
57458
  skippedFileCount++;
57458
57459
  continue;
@@ -58001,7 +58002,7 @@ init_dist();
58001
58002
  init_config();
58002
58003
  init_schema();
58003
58004
  init_manager();
58004
- import * as fs34 from "fs";
58005
+ import * as fs35 from "fs";
58005
58006
  import * as path46 from "path";
58006
58007
  init_utils2();
58007
58008
  init_create_tool();
@@ -58261,7 +58262,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
58261
58262
  if (agentsMissing.length > 0) {
58262
58263
  try {
58263
58264
  const planPath = validateSwarmPath(dir, "plan.json");
58264
- const planRaw = fs34.readFileSync(planPath, "utf-8");
58265
+ const planRaw = fs35.readFileSync(planPath, "utf-8");
58265
58266
  const plan = JSON.parse(planRaw);
58266
58267
  const targetPhase = plan.phases.find((p) => p.id === phase);
58267
58268
  if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
@@ -58292,7 +58293,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
58292
58293
  if (phaseCompleteConfig.regression_sweep?.enforce) {
58293
58294
  try {
58294
58295
  const planPath = validateSwarmPath(dir, "plan.json");
58295
- const planRaw = fs34.readFileSync(planPath, "utf-8");
58296
+ const planRaw = fs35.readFileSync(planPath, "utf-8");
58296
58297
  const plan = JSON.parse(planRaw);
58297
58298
  const targetPhase = plan.phases.find((p) => p.id === phase);
58298
58299
  if (targetPhase) {
@@ -58330,7 +58331,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
58330
58331
  };
58331
58332
  try {
58332
58333
  const eventsPath = validateSwarmPath(dir, "events.jsonl");
58333
- fs34.appendFileSync(eventsPath, `${JSON.stringify(event)}
58334
+ fs35.appendFileSync(eventsPath, `${JSON.stringify(event)}
58334
58335
  `, "utf-8");
58335
58336
  } catch (writeError) {
58336
58337
  warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
@@ -58349,12 +58350,12 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
58349
58350
  }
58350
58351
  try {
58351
58352
  const planPath = validateSwarmPath(dir, "plan.json");
58352
- const planJson = fs34.readFileSync(planPath, "utf-8");
58353
+ const planJson = fs35.readFileSync(planPath, "utf-8");
58353
58354
  const plan = JSON.parse(planJson);
58354
58355
  const phaseObj = plan.phases.find((p) => p.id === phase);
58355
58356
  if (phaseObj) {
58356
58357
  phaseObj.status = "completed";
58357
- fs34.writeFileSync(planPath, `${JSON.stringify(plan, null, 2)}
58358
+ fs35.writeFileSync(planPath, `${JSON.stringify(plan, null, 2)}
58358
58359
  `, "utf-8");
58359
58360
  }
58360
58361
  } catch (error93) {
@@ -58408,7 +58409,7 @@ init_dist();
58408
58409
  init_discovery();
58409
58410
  init_utils();
58410
58411
  init_create_tool();
58411
- import * as fs35 from "fs";
58412
+ import * as fs36 from "fs";
58412
58413
  import * as path47 from "path";
58413
58414
  var MAX_OUTPUT_BYTES5 = 52428800;
58414
58415
  var AUDIT_TIMEOUT_MS = 120000;
@@ -58427,28 +58428,28 @@ function validateArgs3(args2) {
58427
58428
  function detectEcosystems(directory) {
58428
58429
  const ecosystems = [];
58429
58430
  const cwd = directory;
58430
- if (fs35.existsSync(path47.join(cwd, "package.json"))) {
58431
+ if (fs36.existsSync(path47.join(cwd, "package.json"))) {
58431
58432
  ecosystems.push("npm");
58432
58433
  }
58433
- if (fs35.existsSync(path47.join(cwd, "pyproject.toml")) || fs35.existsSync(path47.join(cwd, "requirements.txt"))) {
58434
+ if (fs36.existsSync(path47.join(cwd, "pyproject.toml")) || fs36.existsSync(path47.join(cwd, "requirements.txt"))) {
58434
58435
  ecosystems.push("pip");
58435
58436
  }
58436
- if (fs35.existsSync(path47.join(cwd, "Cargo.toml"))) {
58437
+ if (fs36.existsSync(path47.join(cwd, "Cargo.toml"))) {
58437
58438
  ecosystems.push("cargo");
58438
58439
  }
58439
- if (fs35.existsSync(path47.join(cwd, "go.mod"))) {
58440
+ if (fs36.existsSync(path47.join(cwd, "go.mod"))) {
58440
58441
  ecosystems.push("go");
58441
58442
  }
58442
58443
  try {
58443
- const files = fs35.readdirSync(cwd);
58444
+ const files = fs36.readdirSync(cwd);
58444
58445
  if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
58445
58446
  ecosystems.push("dotnet");
58446
58447
  }
58447
58448
  } catch {}
58448
- if (fs35.existsSync(path47.join(cwd, "Gemfile")) || fs35.existsSync(path47.join(cwd, "Gemfile.lock"))) {
58449
+ if (fs36.existsSync(path47.join(cwd, "Gemfile")) || fs36.existsSync(path47.join(cwd, "Gemfile.lock"))) {
58449
58450
  ecosystems.push("ruby");
58450
58451
  }
58451
- if (fs35.existsSync(path47.join(cwd, "pubspec.yaml"))) {
58452
+ if (fs36.existsSync(path47.join(cwd, "pubspec.yaml"))) {
58452
58453
  ecosystems.push("dart");
58453
58454
  }
58454
58455
  return ecosystems;
@@ -59510,7 +59511,7 @@ var SUPPORTED_PARSER_EXTENSIONS = new Set([
59510
59511
  ]);
59511
59512
  // src/tools/pre-check-batch.ts
59512
59513
  init_dist();
59513
- import * as fs38 from "fs";
59514
+ import * as fs39 from "fs";
59514
59515
  import * as path50 from "path";
59515
59516
 
59516
59517
  // node_modules/yocto-queue/index.js
@@ -59679,7 +59680,7 @@ init_lint();
59679
59680
  init_manager();
59680
59681
 
59681
59682
  // src/quality/metrics.ts
59682
- import * as fs36 from "fs";
59683
+ import * as fs37 from "fs";
59683
59684
  import * as path48 from "path";
59684
59685
  var MAX_FILE_SIZE_BYTES5 = 256 * 1024;
59685
59686
  var MIN_DUPLICATION_LINES = 10;
@@ -59718,11 +59719,11 @@ function estimateCyclomaticComplexity(content) {
59718
59719
  }
59719
59720
  function getComplexityForFile2(filePath) {
59720
59721
  try {
59721
- const stat2 = fs36.statSync(filePath);
59722
+ const stat2 = fs37.statSync(filePath);
59722
59723
  if (stat2.size > MAX_FILE_SIZE_BYTES5) {
59723
59724
  return null;
59724
59725
  }
59725
- const content = fs36.readFileSync(filePath, "utf-8");
59726
+ const content = fs37.readFileSync(filePath, "utf-8");
59726
59727
  return estimateCyclomaticComplexity(content);
59727
59728
  } catch {
59728
59729
  return null;
@@ -59733,7 +59734,7 @@ async function computeComplexityDelta(files, workingDir) {
59733
59734
  const analyzedFiles = [];
59734
59735
  for (const file3 of files) {
59735
59736
  const fullPath = path48.isAbsolute(file3) ? file3 : path48.join(workingDir, file3);
59736
- if (!fs36.existsSync(fullPath)) {
59737
+ if (!fs37.existsSync(fullPath)) {
59737
59738
  continue;
59738
59739
  }
59739
59740
  const complexity = getComplexityForFile2(fullPath);
@@ -59854,7 +59855,7 @@ function countGoExports(content) {
59854
59855
  }
59855
59856
  function getExportCountForFile(filePath) {
59856
59857
  try {
59857
- const content = fs36.readFileSync(filePath, "utf-8");
59858
+ const content = fs37.readFileSync(filePath, "utf-8");
59858
59859
  const ext = path48.extname(filePath).toLowerCase();
59859
59860
  switch (ext) {
59860
59861
  case ".ts":
@@ -59882,7 +59883,7 @@ async function computePublicApiDelta(files, workingDir) {
59882
59883
  const analyzedFiles = [];
59883
59884
  for (const file3 of files) {
59884
59885
  const fullPath = path48.isAbsolute(file3) ? file3 : path48.join(workingDir, file3);
59885
- if (!fs36.existsSync(fullPath)) {
59886
+ if (!fs37.existsSync(fullPath)) {
59886
59887
  continue;
59887
59888
  }
59888
59889
  const exports = getExportCountForFile(fullPath);
@@ -59916,15 +59917,15 @@ async function computeDuplicationRatio(files, workingDir) {
59916
59917
  const analyzedFiles = [];
59917
59918
  for (const file3 of files) {
59918
59919
  const fullPath = path48.isAbsolute(file3) ? file3 : path48.join(workingDir, file3);
59919
- if (!fs36.existsSync(fullPath)) {
59920
+ if (!fs37.existsSync(fullPath)) {
59920
59921
  continue;
59921
59922
  }
59922
59923
  try {
59923
- const stat2 = fs36.statSync(fullPath);
59924
+ const stat2 = fs37.statSync(fullPath);
59924
59925
  if (stat2.size > MAX_FILE_SIZE_BYTES5) {
59925
59926
  continue;
59926
59927
  }
59927
- const content = fs36.readFileSync(fullPath, "utf-8");
59928
+ const content = fs37.readFileSync(fullPath, "utf-8");
59928
59929
  const lines = content.split(`
59929
59930
  `).filter((line) => line.trim().length > 0);
59930
59931
  if (lines.length < MIN_DUPLICATION_LINES) {
@@ -60100,7 +60101,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
60100
60101
  let testLines = 0;
60101
60102
  let codeLines = 0;
60102
60103
  const srcDir = path48.join(workingDir, "src");
60103
- if (fs36.existsSync(srcDir)) {
60104
+ if (fs37.existsSync(srcDir)) {
60104
60105
  await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
60105
60106
  codeLines += lines;
60106
60107
  });
@@ -60108,14 +60109,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
60108
60109
  const possibleSrcDirs = ["lib", "app", "source", "core"];
60109
60110
  for (const dir of possibleSrcDirs) {
60110
60111
  const dirPath = path48.join(workingDir, dir);
60111
- if (fs36.existsSync(dirPath)) {
60112
+ if (fs37.existsSync(dirPath)) {
60112
60113
  await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
60113
60114
  codeLines += lines;
60114
60115
  });
60115
60116
  }
60116
60117
  }
60117
60118
  const testsDir = path48.join(workingDir, "tests");
60118
- if (fs36.existsSync(testsDir)) {
60119
+ if (fs37.existsSync(testsDir)) {
60119
60120
  await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
60120
60121
  testLines += lines;
60121
60122
  });
@@ -60123,7 +60124,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
60123
60124
  const possibleTestDirs = ["test", "__tests__", "specs"];
60124
60125
  for (const dir of possibleTestDirs) {
60125
60126
  const dirPath = path48.join(workingDir, dir);
60126
- if (fs36.existsSync(dirPath) && dirPath !== testsDir) {
60127
+ if (fs37.existsSync(dirPath) && dirPath !== testsDir) {
60127
60128
  await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
60128
60129
  testLines += lines;
60129
60130
  });
@@ -60135,7 +60136,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
60135
60136
  }
60136
60137
  async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
60137
60138
  try {
60138
- const entries = fs36.readdirSync(dirPath, { withFileTypes: true });
60139
+ const entries = fs37.readdirSync(dirPath, { withFileTypes: true });
60139
60140
  for (const entry of entries) {
60140
60141
  const fullPath = path48.join(dirPath, entry.name);
60141
60142
  if (entry.isDirectory()) {
@@ -60181,7 +60182,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
60181
60182
  continue;
60182
60183
  }
60183
60184
  try {
60184
- const content = fs36.readFileSync(fullPath, "utf-8");
60185
+ const content = fs37.readFileSync(fullPath, "utf-8");
60185
60186
  const lines = countCodeLines(content);
60186
60187
  callback(lines);
60187
60188
  } catch {}
@@ -60395,7 +60396,7 @@ async function qualityBudget(input, directory) {
60395
60396
  init_dist();
60396
60397
  init_manager();
60397
60398
  init_detector();
60398
- import * as fs37 from "fs";
60399
+ import * as fs38 from "fs";
60399
60400
  import * as path49 from "path";
60400
60401
  import { extname as extname9 } from "path";
60401
60402
 
@@ -61263,17 +61264,17 @@ var SEVERITY_ORDER = {
61263
61264
  };
61264
61265
  function shouldSkipFile(filePath) {
61265
61266
  try {
61266
- const stats = fs37.statSync(filePath);
61267
+ const stats = fs38.statSync(filePath);
61267
61268
  if (stats.size > MAX_FILE_SIZE_BYTES6) {
61268
61269
  return { skip: true, reason: "file too large" };
61269
61270
  }
61270
61271
  if (stats.size === 0) {
61271
61272
  return { skip: true, reason: "empty file" };
61272
61273
  }
61273
- const fd = fs37.openSync(filePath, "r");
61274
+ const fd = fs38.openSync(filePath, "r");
61274
61275
  const buffer = Buffer.alloc(8192);
61275
- const bytesRead = fs37.readSync(fd, buffer, 0, 8192, 0);
61276
- fs37.closeSync(fd);
61276
+ const bytesRead = fs38.readSync(fd, buffer, 0, 8192, 0);
61277
+ fs38.closeSync(fd);
61277
61278
  if (bytesRead > 0) {
61278
61279
  let nullCount = 0;
61279
61280
  for (let i2 = 0;i2 < bytesRead; i2++) {
@@ -61312,7 +61313,7 @@ function countBySeverity(findings) {
61312
61313
  }
61313
61314
  function scanFileWithTierA(filePath, language) {
61314
61315
  try {
61315
- const content = fs37.readFileSync(filePath, "utf-8");
61316
+ const content = fs38.readFileSync(filePath, "utf-8");
61316
61317
  const findings = executeRulesSync(filePath, content, language);
61317
61318
  return findings.map((f) => ({
61318
61319
  rule_id: f.rule_id,
@@ -61360,7 +61361,7 @@ async function sastScan(input, directory, config3) {
61360
61361
  continue;
61361
61362
  }
61362
61363
  const resolvedPath = path49.isAbsolute(filePath) ? filePath : path49.resolve(directory, filePath);
61363
- if (!fs37.existsSync(resolvedPath)) {
61364
+ if (!fs38.existsSync(resolvedPath)) {
61364
61365
  _filesSkipped++;
61365
61366
  continue;
61366
61367
  }
@@ -61819,7 +61820,7 @@ async function runSecretscanWithFiles(files, directory) {
61819
61820
  }
61820
61821
  let stat2;
61821
61822
  try {
61822
- stat2 = fs38.statSync(file3);
61823
+ stat2 = fs39.statSync(file3);
61823
61824
  } catch {
61824
61825
  skippedFiles++;
61825
61826
  continue;
@@ -61830,7 +61831,7 @@ async function runSecretscanWithFiles(files, directory) {
61830
61831
  }
61831
61832
  let content;
61832
61833
  try {
61833
- const buffer = fs38.readFileSync(file3);
61834
+ const buffer = fs39.readFileSync(file3);
61834
61835
  if (buffer.includes(0)) {
61835
61836
  skippedFiles++;
61836
61837
  continue;
@@ -62250,7 +62251,7 @@ ${paginatedContent}`;
62250
62251
  init_tool();
62251
62252
  init_manager2();
62252
62253
  init_create_tool();
62253
- import * as fs39 from "fs";
62254
+ import * as fs40 from "fs";
62254
62255
  import * as path51 from "path";
62255
62256
  function detectPlaceholderContent(args2) {
62256
62257
  const issues = [];
@@ -62362,7 +62363,7 @@ async function executeSavePlan(args2, fallbackDir) {
62362
62363
  phases_count: plan.phases.length,
62363
62364
  tasks_count: tasksCount
62364
62365
  });
62365
- await fs39.promises.writeFile(markerPath, marker, "utf8");
62366
+ await fs40.promises.writeFile(markerPath, marker, "utf8");
62366
62367
  } catch {}
62367
62368
  return {
62368
62369
  success: true,
@@ -62405,7 +62406,7 @@ var save_plan = createSwarmTool({
62405
62406
  // src/tools/sbom-generate.ts
62406
62407
  init_dist();
62407
62408
  init_manager();
62408
- import * as fs40 from "fs";
62409
+ import * as fs41 from "fs";
62409
62410
  import * as path52 from "path";
62410
62411
 
62411
62412
  // src/sbom/detectors/index.ts
@@ -63252,7 +63253,7 @@ function findManifestFiles(rootDir) {
63252
63253
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
63253
63254
  function searchDir(dir) {
63254
63255
  try {
63255
- const entries = fs40.readdirSync(dir, { withFileTypes: true });
63256
+ const entries = fs41.readdirSync(dir, { withFileTypes: true });
63256
63257
  for (const entry of entries) {
63257
63258
  const fullPath = path52.join(dir, entry.name);
63258
63259
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
@@ -63279,7 +63280,7 @@ function findManifestFilesInDirs(directories, workingDir) {
63279
63280
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
63280
63281
  for (const dir of directories) {
63281
63282
  try {
63282
- const entries = fs40.readdirSync(dir, { withFileTypes: true });
63283
+ const entries = fs41.readdirSync(dir, { withFileTypes: true });
63283
63284
  for (const entry of entries) {
63284
63285
  const fullPath = path52.join(dir, entry.name);
63285
63286
  if (entry.isFile()) {
@@ -63316,7 +63317,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
63316
63317
  }
63317
63318
  function ensureOutputDir(outputDir) {
63318
63319
  try {
63319
- fs40.mkdirSync(outputDir, { recursive: true });
63320
+ fs41.mkdirSync(outputDir, { recursive: true });
63320
63321
  } catch (error93) {
63321
63322
  if (!error93 || error93.code !== "EEXIST") {
63322
63323
  throw error93;
@@ -63410,10 +63411,10 @@ var sbom_generate = createSwarmTool({
63410
63411
  for (const manifestFile of manifestFiles) {
63411
63412
  try {
63412
63413
  const fullPath = path52.isAbsolute(manifestFile) ? manifestFile : path52.join(workingDir, manifestFile);
63413
- if (!fs40.existsSync(fullPath)) {
63414
+ if (!fs41.existsSync(fullPath)) {
63414
63415
  continue;
63415
63416
  }
63416
- const content = fs40.readFileSync(fullPath, "utf-8");
63417
+ const content = fs41.readFileSync(fullPath, "utf-8");
63417
63418
  const components = detectComponents(manifestFile, content);
63418
63419
  processedFiles.push(manifestFile);
63419
63420
  if (components.length > 0) {
@@ -63427,7 +63428,7 @@ var sbom_generate = createSwarmTool({
63427
63428
  const bomJson = serializeCycloneDX(bom);
63428
63429
  const filename = generateSbomFilename();
63429
63430
  const outputPath = path52.join(outputDir, filename);
63430
- fs40.writeFileSync(outputPath, bomJson, "utf-8");
63431
+ fs41.writeFileSync(outputPath, bomJson, "utf-8");
63431
63432
  const verdict = processedFiles.length > 0 ? "pass" : "pass";
63432
63433
  try {
63433
63434
  const timestamp = new Date().toISOString();
@@ -63469,7 +63470,7 @@ var sbom_generate = createSwarmTool({
63469
63470
  // src/tools/schema-drift.ts
63470
63471
  init_dist();
63471
63472
  init_create_tool();
63472
- import * as fs41 from "fs";
63473
+ import * as fs42 from "fs";
63473
63474
  import * as path53 from "path";
63474
63475
  var SPEC_CANDIDATES = [
63475
63476
  "openapi.json",
@@ -63511,19 +63512,19 @@ function discoverSpecFile(cwd, specFileArg) {
63511
63512
  if (!ALLOWED_EXTENSIONS.includes(ext)) {
63512
63513
  throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
63513
63514
  }
63514
- const stats = fs41.statSync(resolvedPath);
63515
+ const stats = fs42.statSync(resolvedPath);
63515
63516
  if (stats.size > MAX_SPEC_SIZE) {
63516
63517
  throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
63517
63518
  }
63518
- if (!fs41.existsSync(resolvedPath)) {
63519
+ if (!fs42.existsSync(resolvedPath)) {
63519
63520
  throw new Error(`Spec file not found: ${resolvedPath}`);
63520
63521
  }
63521
63522
  return resolvedPath;
63522
63523
  }
63523
63524
  for (const candidate of SPEC_CANDIDATES) {
63524
63525
  const candidatePath = path53.resolve(cwd, candidate);
63525
- if (fs41.existsSync(candidatePath)) {
63526
- const stats = fs41.statSync(candidatePath);
63526
+ if (fs42.existsSync(candidatePath)) {
63527
+ const stats = fs42.statSync(candidatePath);
63527
63528
  if (stats.size <= MAX_SPEC_SIZE) {
63528
63529
  return candidatePath;
63529
63530
  }
@@ -63532,7 +63533,7 @@ function discoverSpecFile(cwd, specFileArg) {
63532
63533
  return null;
63533
63534
  }
63534
63535
  function parseSpec(specFile) {
63535
- const content = fs41.readFileSync(specFile, "utf-8");
63536
+ const content = fs42.readFileSync(specFile, "utf-8");
63536
63537
  const ext = path53.extname(specFile).toLowerCase();
63537
63538
  if (ext === ".json") {
63538
63539
  return parseJsonSpec(content);
@@ -63604,7 +63605,7 @@ function extractRoutes(cwd) {
63604
63605
  function walkDir(dir) {
63605
63606
  let entries;
63606
63607
  try {
63607
- entries = fs41.readdirSync(dir, { withFileTypes: true });
63608
+ entries = fs42.readdirSync(dir, { withFileTypes: true });
63608
63609
  } catch {
63609
63610
  return;
63610
63611
  }
@@ -63637,7 +63638,7 @@ function extractRoutes(cwd) {
63637
63638
  }
63638
63639
  function extractRoutesFromFile(filePath) {
63639
63640
  const routes = [];
63640
- const content = fs41.readFileSync(filePath, "utf-8");
63641
+ const content = fs42.readFileSync(filePath, "utf-8");
63641
63642
  const lines = content.split(/\r?\n/);
63642
63643
  const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
63643
63644
  const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
@@ -63788,7 +63789,7 @@ init_secretscan();
63788
63789
  // src/tools/symbols.ts
63789
63790
  init_tool();
63790
63791
  init_create_tool();
63791
- import * as fs42 from "fs";
63792
+ import * as fs43 from "fs";
63792
63793
  import * as path54 from "path";
63793
63794
  var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
63794
63795
  var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
@@ -63819,8 +63820,8 @@ function containsWindowsAttacks(str) {
63819
63820
  function isPathInWorkspace(filePath, workspace) {
63820
63821
  try {
63821
63822
  const resolvedPath = path54.resolve(workspace, filePath);
63822
- const realWorkspace = fs42.realpathSync(workspace);
63823
- const realResolvedPath = fs42.realpathSync(resolvedPath);
63823
+ const realWorkspace = fs43.realpathSync(workspace);
63824
+ const realResolvedPath = fs43.realpathSync(resolvedPath);
63824
63825
  const relativePath = path54.relative(realWorkspace, realResolvedPath);
63825
63826
  if (relativePath.startsWith("..") || path54.isAbsolute(relativePath)) {
63826
63827
  return false;
@@ -63840,11 +63841,11 @@ function extractTSSymbols(filePath, cwd) {
63840
63841
  }
63841
63842
  let content;
63842
63843
  try {
63843
- const stats = fs42.statSync(fullPath);
63844
+ const stats = fs43.statSync(fullPath);
63844
63845
  if (stats.size > MAX_FILE_SIZE_BYTES7) {
63845
63846
  throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES7})`);
63846
63847
  }
63847
- content = fs42.readFileSync(fullPath, "utf-8");
63848
+ content = fs43.readFileSync(fullPath, "utf-8");
63848
63849
  } catch {
63849
63850
  return [];
63850
63851
  }
@@ -63992,11 +63993,11 @@ function extractPythonSymbols(filePath, cwd) {
63992
63993
  }
63993
63994
  let content;
63994
63995
  try {
63995
- const stats = fs42.statSync(fullPath);
63996
+ const stats = fs43.statSync(fullPath);
63996
63997
  if (stats.size > MAX_FILE_SIZE_BYTES7) {
63997
63998
  throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES7})`);
63998
63999
  }
63999
- content = fs42.readFileSync(fullPath, "utf-8");
64000
+ content = fs43.readFileSync(fullPath, "utf-8");
64000
64001
  } catch {
64001
64002
  return [];
64002
64003
  }
@@ -64140,7 +64141,7 @@ init_test_runner();
64140
64141
  init_dist();
64141
64142
  init_utils();
64142
64143
  init_create_tool();
64143
- import * as fs43 from "fs";
64144
+ import * as fs44 from "fs";
64144
64145
  import * as path55 from "path";
64145
64146
  var MAX_TEXT_LENGTH = 200;
64146
64147
  var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
@@ -64236,7 +64237,7 @@ function isSupportedExtension(filePath) {
64236
64237
  function findSourceFiles2(dir, files = []) {
64237
64238
  let entries;
64238
64239
  try {
64239
- entries = fs43.readdirSync(dir);
64240
+ entries = fs44.readdirSync(dir);
64240
64241
  } catch {
64241
64242
  return files;
64242
64243
  }
@@ -64248,7 +64249,7 @@ function findSourceFiles2(dir, files = []) {
64248
64249
  const fullPath = path55.join(dir, entry);
64249
64250
  let stat2;
64250
64251
  try {
64251
- stat2 = fs43.statSync(fullPath);
64252
+ stat2 = fs44.statSync(fullPath);
64252
64253
  } catch {
64253
64254
  continue;
64254
64255
  }
@@ -64341,7 +64342,7 @@ var todo_extract = createSwarmTool({
64341
64342
  return JSON.stringify(errorResult, null, 2);
64342
64343
  }
64343
64344
  const scanPath = resolvedPath;
64344
- if (!fs43.existsSync(scanPath)) {
64345
+ if (!fs44.existsSync(scanPath)) {
64345
64346
  const errorResult = {
64346
64347
  error: `path not found: ${pathsInput}`,
64347
64348
  total: 0,
@@ -64351,7 +64352,7 @@ var todo_extract = createSwarmTool({
64351
64352
  return JSON.stringify(errorResult, null, 2);
64352
64353
  }
64353
64354
  const filesToScan = [];
64354
- const stat2 = fs43.statSync(scanPath);
64355
+ const stat2 = fs44.statSync(scanPath);
64355
64356
  if (stat2.isFile()) {
64356
64357
  if (isSupportedExtension(scanPath)) {
64357
64358
  filesToScan.push(scanPath);
@@ -64370,11 +64371,11 @@ var todo_extract = createSwarmTool({
64370
64371
  const allEntries = [];
64371
64372
  for (const filePath of filesToScan) {
64372
64373
  try {
64373
- const fileStat = fs43.statSync(filePath);
64374
+ const fileStat = fs44.statSync(filePath);
64374
64375
  if (fileStat.size > MAX_FILE_SIZE_BYTES8) {
64375
64376
  continue;
64376
64377
  }
64377
- const content = fs43.readFileSync(filePath, "utf-8");
64378
+ const content = fs44.readFileSync(filePath, "utf-8");
64378
64379
  const entries = parseTodoComments(content, filePath, tagsSet);
64379
64380
  allEntries.push(...entries);
64380
64381
  } catch {}
@@ -64402,18 +64403,18 @@ var todo_extract = createSwarmTool({
64402
64403
  // src/tools/update-task-status.ts
64403
64404
  init_tool();
64404
64405
  init_schema();
64405
- import * as fs45 from "fs";
64406
+ import * as fs46 from "fs";
64406
64407
  import * as path57 from "path";
64407
64408
 
64408
64409
  // src/hooks/diff-scope.ts
64409
- import * as fs44 from "fs";
64410
+ import * as fs45 from "fs";
64410
64411
  import * as path56 from "path";
64411
64412
  function getDeclaredScope(taskId, directory) {
64412
64413
  try {
64413
64414
  const planPath = path56.join(directory, ".swarm", "plan.json");
64414
- if (!fs44.existsSync(planPath))
64415
+ if (!fs45.existsSync(planPath))
64415
64416
  return null;
64416
- const raw = fs44.readFileSync(planPath, "utf-8");
64417
+ const raw = fs45.readFileSync(planPath, "utf-8");
64417
64418
  const plan = JSON.parse(raw);
64418
64419
  for (const phase of plan.phases ?? []) {
64419
64420
  for (const task of phase.tasks ?? []) {
@@ -64548,7 +64549,7 @@ function checkReviewerGate(taskId, workingDirectory) {
64548
64549
  const resolvedDir2 = workingDirectory;
64549
64550
  try {
64550
64551
  const planPath = path57.join(resolvedDir2, ".swarm", "plan.json");
64551
- const planRaw = fs45.readFileSync(planPath, "utf-8");
64552
+ const planRaw = fs46.readFileSync(planPath, "utf-8");
64552
64553
  const plan = JSON.parse(planRaw);
64553
64554
  for (const planPhase of plan.phases ?? []) {
64554
64555
  for (const task of planPhase.tasks ?? []) {
@@ -64568,7 +64569,7 @@ function checkReviewerGate(taskId, workingDirectory) {
64568
64569
  const resolvedDir = workingDirectory;
64569
64570
  try {
64570
64571
  const evidencePath = path57.join(resolvedDir, ".swarm", "evidence", `${taskId}.json`);
64571
- const raw = fs45.readFileSync(evidencePath, "utf-8");
64572
+ const raw = fs46.readFileSync(evidencePath, "utf-8");
64572
64573
  const evidence = JSON.parse(raw);
64573
64574
  if (evidence?.required_gates && Array.isArray(evidence.required_gates) && evidence?.gates) {
64574
64575
  const allGatesMet = evidence.required_gates.every((gate) => evidence.gates[gate] != null);
@@ -64609,7 +64610,7 @@ function checkReviewerGate(taskId, workingDirectory) {
64609
64610
  try {
64610
64611
  const resolvedDir2 = workingDirectory;
64611
64612
  const planPath = path57.join(resolvedDir2, ".swarm", "plan.json");
64612
- const planRaw = fs45.readFileSync(planPath, "utf-8");
64613
+ const planRaw = fs46.readFileSync(planPath, "utf-8");
64613
64614
  const plan = JSON.parse(planRaw);
64614
64615
  for (const planPhase of plan.phases ?? []) {
64615
64616
  for (const task of planPhase.tasks ?? []) {
@@ -64803,9 +64804,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
64803
64804
  }
64804
64805
  const resolvedDir = path57.resolve(normalizedDir);
64805
64806
  try {
64806
- const realPath = fs45.realpathSync(resolvedDir);
64807
+ const realPath = fs46.realpathSync(resolvedDir);
64807
64808
  const planPath = path57.join(realPath, ".swarm", "plan.json");
64808
- if (!fs45.existsSync(planPath)) {
64809
+ if (!fs46.existsSync(planPath)) {
64809
64810
  return {
64810
64811
  success: false,
64811
64812
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -65258,7 +65259,8 @@ var OpenCodeSwarm = async (ctx) => {
65258
65259
  },
65259
65260
  "experimental.chat.messages.transform": composeHandlers(...[
65260
65261
  (input, _output) => {
65261
- console.error(`[DIAG] messagesTransform START`);
65262
+ if (process.env.DEBUG_SWARM)
65263
+ console.error(`[DIAG] messagesTransform START`);
65262
65264
  const p = input;
65263
65265
  if (p.sessionID) {
65264
65266
  const archAgent = swarmState.activeAgent.get(p.sessionID);
@@ -65282,24 +65284,28 @@ var OpenCodeSwarm = async (ctx) => {
65282
65284
  if (output.messages) {
65283
65285
  output.messages = consolidateSystemMessages(output.messages);
65284
65286
  }
65285
- console.error(`[DIAG] messagesTransform DONE`);
65287
+ if (process.env.DEBUG_SWARM)
65288
+ console.error(`[DIAG] messagesTransform DONE`);
65286
65289
  return Promise.resolve();
65287
65290
  }
65288
65291
  ].filter((fn) => Boolean(fn))),
65289
65292
  "experimental.chat.system.transform": composeHandlers(...[
65290
65293
  async (input, output) => {
65291
- console.error(`[DIAG] systemTransform START`);
65294
+ if (process.env.DEBUG_SWARM)
65295
+ console.error(`[DIAG] systemTransform START`);
65292
65296
  },
65293
65297
  systemEnhancerHook["experimental.chat.system.transform"],
65294
65298
  async (_input, _output) => {
65295
- console.error(`[DIAG] systemTransform enhancer DONE`);
65299
+ if (process.env.DEBUG_SWARM)
65300
+ console.error(`[DIAG] systemTransform enhancer DONE`);
65296
65301
  },
65297
65302
  automationConfig.capabilities?.phase_preflight === true && preflightTriggerManager ? createPhaseMonitorHook(ctx.directory, preflightTriggerManager) : knowledgeConfig.enabled ? createPhaseMonitorHook(ctx.directory) : undefined
65298
65303
  ].filter(Boolean)),
65299
65304
  "experimental.session.compacting": compactionHook["experimental.session.compacting"],
65300
65305
  "command.execute.before": safeHook(commandHandler),
65301
65306
  "tool.execute.before": async (input, output) => {
65302
- console.error(`[DIAG] toolBefore tool=${input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool} session=${input.sessionID}`);
65307
+ if (process.env.DEBUG_SWARM)
65308
+ console.error(`[DIAG] toolBefore tool=${input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool} session=${input.sessionID}`);
65303
65309
  if (!swarmState.activeAgent.has(input.sessionID)) {
65304
65310
  swarmState.activeAgent.set(input.sessionID, ORCHESTRATOR_NAME);
65305
65311
  }
@@ -65328,47 +65334,43 @@ var OpenCodeSwarm = async (ctx) => {
65328
65334
  await safeHook(activityHooks.toolBefore)(input, output);
65329
65335
  },
65330
65336
  "tool.execute.after": async (input, output) => {
65337
+ const _dbg = !!process.env.DEBUG_SWARM;
65331
65338
  const _toolName = input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool;
65332
- console.error(`[DIAG] toolAfter START tool=${_toolName} session=${input.sessionID}`);
65339
+ if (_dbg)
65340
+ console.error(`[DIAG] toolAfter START tool=${_toolName} session=${input.sessionID}`);
65333
65341
  const normalizedTool = input.tool.replace(/^[^:]+[:.]/, "");
65334
65342
  const isTaskTool = normalizedTool === "Task" || normalizedTool === "task";
65335
- if (isTaskTool) {
65336
- const sessionId = input.sessionID;
65337
- swarmState.activeAgent.set(sessionId, ORCHESTRATOR_NAME);
65338
- ensureAgentSession(sessionId, ORCHESTRATOR_NAME);
65339
- const taskSession = swarmState.agentSessions.get(sessionId);
65340
- if (taskSession) {
65341
- taskSession.delegationActive = false;
65342
- taskSession.lastAgentEventTime = Date.now();
65343
- }
65344
- console.error(`[DIAG] Task handoff DONE (early) session=${sessionId} activeAgent=${swarmState.activeAgent.get(sessionId)}`);
65345
- }
65346
- const HOOK_CHAIN_TIMEOUT_MS = 30000;
65347
- const hookChainStart = Date.now();
65348
- let hookChainTimedOut = false;
65349
65343
  const hookChain = async () => {
65350
65344
  await activityHooks.toolAfter(input, output);
65351
- console.error(`[DIAG] toolAfter activity done tool=${_toolName}`);
65345
+ if (_dbg)
65346
+ console.error(`[DIAG] toolAfter activity done tool=${_toolName}`);
65352
65347
  await guardrailsHooks.toolAfter(input, output);
65353
- console.error(`[DIAG] toolAfter guardrails done tool=${_toolName}`);
65348
+ if (_dbg)
65349
+ console.error(`[DIAG] toolAfter guardrails done tool=${_toolName}`);
65354
65350
  await safeHook(delegationLedgerHook.toolAfter)(input, output);
65355
- console.error(`[DIAG] toolAfter ledger done tool=${_toolName}`);
65351
+ if (_dbg)
65352
+ console.error(`[DIAG] toolAfter ledger done tool=${_toolName}`);
65356
65353
  await safeHook(selfReviewHook.toolAfter)(input, output);
65357
- console.error(`[DIAG] toolAfter selfReview done tool=${_toolName}`);
65354
+ if (_dbg)
65355
+ console.error(`[DIAG] toolAfter selfReview done tool=${_toolName}`);
65358
65356
  await safeHook(delegationGateHooks.toolAfter)(input, output);
65359
- console.error(`[DIAG] toolAfter delegationGate done tool=${_toolName}`);
65357
+ if (_dbg)
65358
+ console.error(`[DIAG] toolAfter delegationGate done tool=${_toolName}`);
65360
65359
  if (knowledgeCuratorHook)
65361
65360
  await safeHook(knowledgeCuratorHook)(input, output);
65362
65361
  if (hivePromoterHook)
65363
65362
  await safeHook(hivePromoterHook)(input, output);
65364
- console.error(`[DIAG] toolAfter knowledge done tool=${_toolName}`);
65363
+ if (_dbg)
65364
+ console.error(`[DIAG] toolAfter knowledge done tool=${_toolName}`);
65365
65365
  await safeHook(steeringConsumedHook)(input, output);
65366
65366
  await safeHook(coChangeSuggesterHook)(input, output);
65367
65367
  await safeHook(darkMatterDetectorHook)(input, output);
65368
- console.error(`[DIAG] toolAfter intelligence done tool=${_toolName}`);
65368
+ if (_dbg)
65369
+ console.error(`[DIAG] toolAfter intelligence done tool=${_toolName}`);
65369
65370
  await snapshotWriterHook(input, output);
65370
65371
  await toolSummarizerHook?.(input, output);
65371
- console.error(`[DIAG] toolAfter snapshot+summarizer done tool=${_toolName}`);
65372
+ if (_dbg)
65373
+ console.error(`[DIAG] toolAfter snapshot+summarizer done tool=${_toolName}`);
65372
65374
  const execMode = config3.execution_mode ?? "balanced";
65373
65375
  if (execMode === "strict") {
65374
65376
  if (slopDetectorHook)
@@ -65401,29 +65403,33 @@ var OpenCodeSwarm = async (ctx) => {
65401
65403
  }
65402
65404
  }
65403
65405
  };
65404
- const timeout = new Promise((resolve23) => {
65405
- setTimeout(() => {
65406
- hookChainTimedOut = true;
65407
- resolve23();
65408
- }, HOOK_CHAIN_TIMEOUT_MS);
65409
- });
65410
- await Promise.race([
65411
- hookChain().catch((err2) => {
65412
- console.error(`[DIAG] toolAfter hook chain error tool=${_toolName}: ${err2 instanceof Error ? err2.message : String(err2)}`);
65413
- }),
65414
- timeout
65415
- ]);
65416
- if (hookChainTimedOut) {
65417
- const elapsed = Date.now() - hookChainStart;
65418
- console.error(`[DIAG] toolAfter TIMEOUT after ${elapsed}ms tool=${_toolName} session=${input.sessionID} \u2014 hooks abandoned to prevent session freeze`);
65406
+ try {
65407
+ await hookChain();
65408
+ } catch (err2) {
65409
+ console.warn(`[swarm] toolAfter hook chain error tool=${_toolName}: ${err2 instanceof Error ? err2.message : String(err2)}`);
65410
+ }
65411
+ if (isTaskTool) {
65412
+ const sessionId = input.sessionID;
65413
+ swarmState.activeAgent.set(sessionId, ORCHESTRATOR_NAME);
65414
+ ensureAgentSession(sessionId, ORCHESTRATOR_NAME);
65415
+ const taskSession = swarmState.agentSessions.get(sessionId);
65416
+ if (taskSession) {
65417
+ taskSession.delegationActive = false;
65418
+ taskSession.lastAgentEventTime = Date.now();
65419
+ }
65420
+ if (_dbg)
65421
+ console.error(`[DIAG] Task handoff DONE session=${sessionId} activeAgent=${swarmState.activeAgent.get(sessionId)}`);
65419
65422
  }
65420
65423
  deleteStoredInputArgs(input.callID);
65421
- console.error(`[DIAG] toolAfter COMPLETE tool=${_toolName}`);
65424
+ if (_dbg)
65425
+ console.error(`[DIAG] toolAfter COMPLETE tool=${_toolName}`);
65422
65426
  },
65423
65427
  "chat.message": safeHook(async (input, output) => {
65424
- console.error(`[DIAG] chat.message agent=${input.agent ?? "none"} session=${input.sessionID}`);
65428
+ if (process.env.DEBUG_SWARM)
65429
+ console.error(`[DIAG] chat.message agent=${input.agent ?? "none"} session=${input.sessionID}`);
65425
65430
  await delegationHandler(input, output);
65426
- console.error(`[DIAG] chat.message DONE agent=${input.agent ?? "none"}`);
65431
+ if (process.env.DEBUG_SWARM)
65432
+ console.error(`[DIAG] chat.message DONE agent=${input.agent ?? "none"}`);
65427
65433
  }),
65428
65434
  automation: automationManager
65429
65435
  };