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