opencode-swarm 6.71.0 → 6.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +789 -736
- package/dist/config/schema.d.ts +6 -0
- package/dist/hooks/knowledge-store.d.ts +10 -1
- package/dist/hooks/knowledge-types.d.ts +9 -1
- package/dist/index.js +16313 -15899
- 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();
|
|
@@ -19162,7 +19162,10 @@ var KnowledgeConfigSchema = exports_external.object({
|
|
|
19162
19162
|
min_encounter_score: exports_external.number().min(0).max(1).default(0.1),
|
|
19163
19163
|
initial_encounter_score: exports_external.number().min(0).max(5).default(1),
|
|
19164
19164
|
encounter_increment: exports_external.number().min(0).max(1).default(0.1),
|
|
19165
|
-
max_encounter_score: exports_external.number().min(1).max(20).default(10)
|
|
19165
|
+
max_encounter_score: exports_external.number().min(1).max(20).default(10),
|
|
19166
|
+
default_max_phases: exports_external.number().int().positive().default(10),
|
|
19167
|
+
todo_max_phases: exports_external.number().int().positive().default(3),
|
|
19168
|
+
sweep_enabled: exports_external.boolean().default(true)
|
|
19166
19169
|
});
|
|
19167
19170
|
var CuratorConfigSchema = exports_external.object({
|
|
19168
19171
|
enabled: exports_external.boolean().default(true),
|
|
@@ -19784,6 +19787,50 @@ var warnedAgents = new Set;
|
|
|
19784
19787
|
|
|
19785
19788
|
// src/hooks/guardrails.ts
|
|
19786
19789
|
init_manager();
|
|
19790
|
+
|
|
19791
|
+
// src/scope/scope-persistence.ts
|
|
19792
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
19793
|
+
import * as fs4 from "fs";
|
|
19794
|
+
import * as path6 from "path";
|
|
19795
|
+
var DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19796
|
+
var LOCK_STALE_MS = 30 * 1000;
|
|
19797
|
+
var SCOPES_DIR = ".swarm/scopes";
|
|
19798
|
+
var MAX_PLAN_BYTES = 10 * 1024 * 1024;
|
|
19799
|
+
var MAX_SCOPE_BYTES = 2 * 1024 * 1024;
|
|
19800
|
+
var WINDOWS_RESERVED = new Set([
|
|
19801
|
+
"CON",
|
|
19802
|
+
"PRN",
|
|
19803
|
+
"AUX",
|
|
19804
|
+
"NUL",
|
|
19805
|
+
"COM1",
|
|
19806
|
+
"COM2",
|
|
19807
|
+
"COM3",
|
|
19808
|
+
"COM4",
|
|
19809
|
+
"COM5",
|
|
19810
|
+
"COM6",
|
|
19811
|
+
"COM7",
|
|
19812
|
+
"COM8",
|
|
19813
|
+
"COM9",
|
|
19814
|
+
"LPT1",
|
|
19815
|
+
"LPT2",
|
|
19816
|
+
"LPT3",
|
|
19817
|
+
"LPT4",
|
|
19818
|
+
"LPT5",
|
|
19819
|
+
"LPT6",
|
|
19820
|
+
"LPT7",
|
|
19821
|
+
"LPT8",
|
|
19822
|
+
"LPT9"
|
|
19823
|
+
]);
|
|
19824
|
+
function getScopesDir(directory) {
|
|
19825
|
+
return path6.join(directory, SCOPES_DIR);
|
|
19826
|
+
}
|
|
19827
|
+
function clearAllScopes(directory) {
|
|
19828
|
+
try {
|
|
19829
|
+
fs4.rmSync(getScopesDir(directory), { recursive: true, force: true });
|
|
19830
|
+
} catch {}
|
|
19831
|
+
}
|
|
19832
|
+
|
|
19833
|
+
// src/hooks/guardrails.ts
|
|
19787
19834
|
init_telemetry();
|
|
19788
19835
|
init_utils();
|
|
19789
19836
|
|
|
@@ -20269,8 +20316,8 @@ init_zod();
|
|
|
20269
20316
|
|
|
20270
20317
|
// src/tools/checkpoint.ts
|
|
20271
20318
|
import * as child_process from "child_process";
|
|
20272
|
-
import * as
|
|
20273
|
-
import * as
|
|
20319
|
+
import * as fs5 from "fs";
|
|
20320
|
+
import * as path7 from "path";
|
|
20274
20321
|
|
|
20275
20322
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
|
|
20276
20323
|
var exports_external2 = {};
|
|
@@ -21001,10 +21048,10 @@ function mergeDefs2(...defs) {
|
|
|
21001
21048
|
function cloneDef2(schema) {
|
|
21002
21049
|
return mergeDefs2(schema._zod.def);
|
|
21003
21050
|
}
|
|
21004
|
-
function getElementAtPath2(obj,
|
|
21005
|
-
if (!
|
|
21051
|
+
function getElementAtPath2(obj, path7) {
|
|
21052
|
+
if (!path7)
|
|
21006
21053
|
return obj;
|
|
21007
|
-
return
|
|
21054
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
21008
21055
|
}
|
|
21009
21056
|
function promiseAllObject2(promisesObj) {
|
|
21010
21057
|
const keys = Object.keys(promisesObj);
|
|
@@ -21363,11 +21410,11 @@ function aborted2(x, startIndex = 0) {
|
|
|
21363
21410
|
}
|
|
21364
21411
|
return false;
|
|
21365
21412
|
}
|
|
21366
|
-
function prefixIssues2(
|
|
21413
|
+
function prefixIssues2(path7, issues) {
|
|
21367
21414
|
return issues.map((iss) => {
|
|
21368
21415
|
var _a2;
|
|
21369
21416
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
21370
|
-
iss.path.unshift(
|
|
21417
|
+
iss.path.unshift(path7);
|
|
21371
21418
|
return iss;
|
|
21372
21419
|
});
|
|
21373
21420
|
}
|
|
@@ -21535,7 +21582,7 @@ function treeifyError2(error49, _mapper) {
|
|
|
21535
21582
|
return issue3.message;
|
|
21536
21583
|
};
|
|
21537
21584
|
const result = { errors: [] };
|
|
21538
|
-
const processError = (error50,
|
|
21585
|
+
const processError = (error50, path7 = []) => {
|
|
21539
21586
|
var _a2, _b;
|
|
21540
21587
|
for (const issue3 of error50.issues) {
|
|
21541
21588
|
if (issue3.code === "invalid_union" && issue3.errors.length) {
|
|
@@ -21545,7 +21592,7 @@ function treeifyError2(error49, _mapper) {
|
|
|
21545
21592
|
} else if (issue3.code === "invalid_element") {
|
|
21546
21593
|
processError({ issues: issue3.issues }, issue3.path);
|
|
21547
21594
|
} else {
|
|
21548
|
-
const fullpath = [...
|
|
21595
|
+
const fullpath = [...path7, ...issue3.path];
|
|
21549
21596
|
if (fullpath.length === 0) {
|
|
21550
21597
|
result.errors.push(mapper(issue3));
|
|
21551
21598
|
continue;
|
|
@@ -21577,8 +21624,8 @@ function treeifyError2(error49, _mapper) {
|
|
|
21577
21624
|
}
|
|
21578
21625
|
function toDotPath2(_path) {
|
|
21579
21626
|
const segs = [];
|
|
21580
|
-
const
|
|
21581
|
-
for (const seg of
|
|
21627
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21628
|
+
for (const seg of path7) {
|
|
21582
21629
|
if (typeof seg === "number")
|
|
21583
21630
|
segs.push(`[${seg}]`);
|
|
21584
21631
|
else if (typeof seg === "symbol")
|
|
@@ -32675,13 +32722,13 @@ function validateLabel(label) {
|
|
|
32675
32722
|
return null;
|
|
32676
32723
|
}
|
|
32677
32724
|
function getCheckpointLogPath(directory) {
|
|
32678
|
-
return
|
|
32725
|
+
return path7.join(directory, CHECKPOINT_LOG_PATH);
|
|
32679
32726
|
}
|
|
32680
32727
|
function readCheckpointLog(directory) {
|
|
32681
32728
|
const logPath = getCheckpointLogPath(directory);
|
|
32682
32729
|
try {
|
|
32683
|
-
if (
|
|
32684
|
-
const content =
|
|
32730
|
+
if (fs5.existsSync(logPath)) {
|
|
32731
|
+
const content = fs5.readFileSync(logPath, "utf-8");
|
|
32685
32732
|
const parsed = JSON.parse(content);
|
|
32686
32733
|
if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
|
|
32687
32734
|
return { version: 1, checkpoints: [] };
|
|
@@ -32693,13 +32740,13 @@ function readCheckpointLog(directory) {
|
|
|
32693
32740
|
}
|
|
32694
32741
|
function writeCheckpointLog(log2, directory) {
|
|
32695
32742
|
const logPath = getCheckpointLogPath(directory);
|
|
32696
|
-
const dir =
|
|
32697
|
-
if (!
|
|
32698
|
-
|
|
32743
|
+
const dir = path7.dirname(logPath);
|
|
32744
|
+
if (!fs5.existsSync(dir)) {
|
|
32745
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
32699
32746
|
}
|
|
32700
32747
|
const tempPath = `${logPath}.tmp`;
|
|
32701
|
-
|
|
32702
|
-
|
|
32748
|
+
fs5.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
|
|
32749
|
+
fs5.renameSync(tempPath, logPath);
|
|
32703
32750
|
}
|
|
32704
32751
|
function gitExec(args) {
|
|
32705
32752
|
const result = child_process.spawnSync("git", args, {
|
|
@@ -33033,8 +33080,8 @@ async function handleClarifyCommand(_directory, args) {
|
|
|
33033
33080
|
|
|
33034
33081
|
// src/commands/close.ts
|
|
33035
33082
|
import { execFileSync } from "child_process";
|
|
33036
|
-
import { promises as
|
|
33037
|
-
import
|
|
33083
|
+
import { promises as fs7 } from "fs";
|
|
33084
|
+
import path12 from "path";
|
|
33038
33085
|
init_manager2();
|
|
33039
33086
|
|
|
33040
33087
|
// src/git/branch.ts
|
|
@@ -33084,33 +33131,33 @@ function hasUncommittedChanges(cwd) {
|
|
|
33084
33131
|
}
|
|
33085
33132
|
|
|
33086
33133
|
// src/hooks/knowledge-store.ts
|
|
33087
|
-
var
|
|
33134
|
+
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
33088
33135
|
import { existsSync as existsSync5 } from "fs";
|
|
33089
33136
|
import { appendFile as appendFile2, mkdir, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
33090
33137
|
import * as os2 from "os";
|
|
33091
|
-
import * as
|
|
33138
|
+
import * as path8 from "path";
|
|
33092
33139
|
function resolveSwarmKnowledgePath(directory) {
|
|
33093
|
-
return
|
|
33140
|
+
return path8.join(directory, ".swarm", "knowledge.jsonl");
|
|
33094
33141
|
}
|
|
33095
33142
|
function resolveSwarmRejectedPath(directory) {
|
|
33096
|
-
return
|
|
33143
|
+
return path8.join(directory, ".swarm", "knowledge-rejected.jsonl");
|
|
33097
33144
|
}
|
|
33098
33145
|
function resolveHiveKnowledgePath() {
|
|
33099
33146
|
const platform = process.platform;
|
|
33100
33147
|
const home = os2.homedir();
|
|
33101
33148
|
let dataDir;
|
|
33102
33149
|
if (platform === "win32") {
|
|
33103
|
-
dataDir =
|
|
33150
|
+
dataDir = path8.join(process.env.LOCALAPPDATA || path8.join(home, "AppData", "Local"), "opencode-swarm", "Data");
|
|
33104
33151
|
} else if (platform === "darwin") {
|
|
33105
|
-
dataDir =
|
|
33152
|
+
dataDir = path8.join(home, "Library", "Application Support", "opencode-swarm");
|
|
33106
33153
|
} else {
|
|
33107
|
-
dataDir =
|
|
33154
|
+
dataDir = path8.join(process.env.XDG_DATA_HOME || path8.join(home, ".local", "share"), "opencode-swarm");
|
|
33108
33155
|
}
|
|
33109
|
-
return
|
|
33156
|
+
return path8.join(dataDir, "shared-learnings.jsonl");
|
|
33110
33157
|
}
|
|
33111
33158
|
function resolveHiveRejectedPath() {
|
|
33112
33159
|
const hivePath = resolveHiveKnowledgePath();
|
|
33113
|
-
return
|
|
33160
|
+
return path8.join(path8.dirname(hivePath), "shared-learnings-rejected.jsonl");
|
|
33114
33161
|
}
|
|
33115
33162
|
async function readKnowledge(filePath) {
|
|
33116
33163
|
if (!existsSync5(filePath))
|
|
@@ -33134,17 +33181,18 @@ async function readRejectedLessons(directory) {
|
|
|
33134
33181
|
return readKnowledge(resolveSwarmRejectedPath(directory));
|
|
33135
33182
|
}
|
|
33136
33183
|
async function appendKnowledge(filePath, entry) {
|
|
33137
|
-
await mkdir(
|
|
33184
|
+
await mkdir(path8.dirname(filePath), { recursive: true });
|
|
33138
33185
|
await appendFile2(filePath, `${JSON.stringify(entry)}
|
|
33139
33186
|
`, "utf-8");
|
|
33140
33187
|
}
|
|
33141
33188
|
async function rewriteKnowledge(filePath, entries) {
|
|
33142
|
-
const dir =
|
|
33189
|
+
const dir = path8.dirname(filePath);
|
|
33143
33190
|
await mkdir(dir, { recursive: true });
|
|
33144
33191
|
let release = null;
|
|
33145
33192
|
try {
|
|
33146
|
-
release = await
|
|
33147
|
-
retries: { retries:
|
|
33193
|
+
release = await import_proper_lockfile2.default.lock(dir, {
|
|
33194
|
+
retries: { retries: 5, minTimeout: 100, maxTimeout: 500 },
|
|
33195
|
+
stale: 5000
|
|
33148
33196
|
});
|
|
33149
33197
|
const content = entries.map((e) => JSON.stringify(e)).join(`
|
|
33150
33198
|
`) + (entries.length > 0 ? `
|
|
@@ -33213,6 +33261,8 @@ function computeConfidence(confirmedByCount, autoGenerated) {
|
|
|
33213
33261
|
function inferTags(lesson) {
|
|
33214
33262
|
const lower = lesson.toLowerCase();
|
|
33215
33263
|
const tags = [];
|
|
33264
|
+
if (/(^|\s)(?:todo|remember|don't?(?:\s+)?forget)(?:\s|:|,|$)/i.test(lesson))
|
|
33265
|
+
tags.push("todo");
|
|
33216
33266
|
if (/\b(?:typescript|ts)\b/.test(lower))
|
|
33217
33267
|
tags.push("typescript");
|
|
33218
33268
|
if (/\b(?:javascript|js)\b/.test(lower))
|
|
@@ -33245,9 +33295,9 @@ function inferTags(lesson) {
|
|
|
33245
33295
|
}
|
|
33246
33296
|
|
|
33247
33297
|
// src/hooks/knowledge-validator.ts
|
|
33248
|
-
var
|
|
33298
|
+
var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
33249
33299
|
import { appendFile as appendFile3, mkdir as mkdir2, writeFile as writeFile3 } from "fs/promises";
|
|
33250
|
-
import * as
|
|
33300
|
+
import * as path9 from "path";
|
|
33251
33301
|
var DANGEROUS_COMMAND_PATTERNS = [
|
|
33252
33302
|
/\brm\s+-rf\b/,
|
|
33253
33303
|
/\bsudo\s+rm\b/,
|
|
@@ -33297,6 +33347,7 @@ var VALID_CATEGORIES = new Set([
|
|
|
33297
33347
|
"debugging",
|
|
33298
33348
|
"performance",
|
|
33299
33349
|
"integration",
|
|
33350
|
+
"todo",
|
|
33300
33351
|
"other"
|
|
33301
33352
|
]);
|
|
33302
33353
|
var TECH_REFERENCE_WORDS = new Set([
|
|
@@ -33501,14 +33552,14 @@ async function quarantineEntry(directory, entryId, reason, reportedBy) {
|
|
|
33501
33552
|
return;
|
|
33502
33553
|
}
|
|
33503
33554
|
const sanitizedReason = reason.slice(0, 500).replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\x0d]/g, "");
|
|
33504
|
-
const knowledgePath =
|
|
33505
|
-
const quarantinePath =
|
|
33506
|
-
const rejectedPath =
|
|
33507
|
-
const swarmDir =
|
|
33555
|
+
const knowledgePath = path9.join(directory, ".swarm", "knowledge.jsonl");
|
|
33556
|
+
const quarantinePath = path9.join(directory, ".swarm", "knowledge-quarantined.jsonl");
|
|
33557
|
+
const rejectedPath = path9.join(directory, ".swarm", "knowledge-rejected.jsonl");
|
|
33558
|
+
const swarmDir = path9.join(directory, ".swarm");
|
|
33508
33559
|
await mkdir2(swarmDir, { recursive: true });
|
|
33509
33560
|
let release;
|
|
33510
33561
|
try {
|
|
33511
|
-
release = await
|
|
33562
|
+
release = await import_proper_lockfile3.default.lock(swarmDir, {
|
|
33512
33563
|
retries: { retries: 3, minTimeout: 100 }
|
|
33513
33564
|
});
|
|
33514
33565
|
const entries = await readKnowledge(knowledgePath);
|
|
@@ -33561,14 +33612,14 @@ async function restoreEntry(directory, entryId) {
|
|
|
33561
33612
|
console.warn("[knowledge-validator] restoreEntry: invalid entryId rejected");
|
|
33562
33613
|
return;
|
|
33563
33614
|
}
|
|
33564
|
-
const knowledgePath =
|
|
33565
|
-
const quarantinePath =
|
|
33566
|
-
const rejectedPath =
|
|
33567
|
-
const swarmDir =
|
|
33615
|
+
const knowledgePath = path9.join(directory, ".swarm", "knowledge.jsonl");
|
|
33616
|
+
const quarantinePath = path9.join(directory, ".swarm", "knowledge-quarantined.jsonl");
|
|
33617
|
+
const rejectedPath = path9.join(directory, ".swarm", "knowledge-rejected.jsonl");
|
|
33618
|
+
const swarmDir = path9.join(directory, ".swarm");
|
|
33568
33619
|
await mkdir2(swarmDir, { recursive: true });
|
|
33569
33620
|
let release;
|
|
33570
33621
|
try {
|
|
33571
|
-
release = await
|
|
33622
|
+
release = await import_proper_lockfile3.default.lock(swarmDir, {
|
|
33572
33623
|
retries: { retries: 3, minTimeout: 100 }
|
|
33573
33624
|
});
|
|
33574
33625
|
const quarantinedEntries = await readKnowledge(quarantinePath);
|
|
@@ -33615,7 +33666,8 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
33615
33666
|
["debugging", "debugging"],
|
|
33616
33667
|
["performance", "performance"],
|
|
33617
33668
|
["integration", "integration"],
|
|
33618
|
-
["other", "other"]
|
|
33669
|
+
["other", "other"],
|
|
33670
|
+
["todo", "todo"]
|
|
33619
33671
|
]);
|
|
33620
33672
|
for (const lesson of lessons) {
|
|
33621
33673
|
const tags = inferTags(lesson);
|
|
@@ -33722,18 +33774,18 @@ init_utils2();
|
|
|
33722
33774
|
init_plan_schema();
|
|
33723
33775
|
init_ledger();
|
|
33724
33776
|
init_manager();
|
|
33725
|
-
import * as
|
|
33726
|
-
import * as
|
|
33777
|
+
import * as fs6 from "fs";
|
|
33778
|
+
import * as path10 from "path";
|
|
33727
33779
|
async function writeCheckpoint(directory) {
|
|
33728
33780
|
try {
|
|
33729
33781
|
const plan = await loadPlan(directory);
|
|
33730
33782
|
if (!plan)
|
|
33731
33783
|
return;
|
|
33732
|
-
const jsonPath =
|
|
33733
|
-
const mdPath =
|
|
33734
|
-
|
|
33784
|
+
const jsonPath = path10.join(directory, "SWARM_PLAN.json");
|
|
33785
|
+
const mdPath = path10.join(directory, "SWARM_PLAN.md");
|
|
33786
|
+
fs6.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
33735
33787
|
const md = derivePlanMarkdown(plan);
|
|
33736
|
-
|
|
33788
|
+
fs6.writeFileSync(mdPath, md, "utf8");
|
|
33737
33789
|
} catch (error93) {
|
|
33738
33790
|
console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
33739
33791
|
}
|
|
@@ -33741,8 +33793,8 @@ async function writeCheckpoint(directory) {
|
|
|
33741
33793
|
|
|
33742
33794
|
// src/session/snapshot-writer.ts
|
|
33743
33795
|
init_utils2();
|
|
33744
|
-
import { mkdirSync as
|
|
33745
|
-
import * as
|
|
33796
|
+
import { mkdirSync as mkdirSync5, renameSync as renameSync5 } from "fs";
|
|
33797
|
+
import * as path11 from "path";
|
|
33746
33798
|
init_utils();
|
|
33747
33799
|
var _writeInFlight = Promise.resolve();
|
|
33748
33800
|
function serializeAgentSession(s) {
|
|
@@ -33833,11 +33885,11 @@ async function writeSnapshot(directory, state) {
|
|
|
33833
33885
|
}
|
|
33834
33886
|
const content = JSON.stringify(snapshot, null, 2);
|
|
33835
33887
|
const resolvedPath = validateSwarmPath(directory, "session/state.json");
|
|
33836
|
-
const dir =
|
|
33837
|
-
|
|
33888
|
+
const dir = path11.dirname(resolvedPath);
|
|
33889
|
+
mkdirSync5(dir, { recursive: true });
|
|
33838
33890
|
const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
33839
33891
|
await Bun.write(tempPath, content);
|
|
33840
|
-
|
|
33892
|
+
renameSync5(tempPath, resolvedPath);
|
|
33841
33893
|
} catch (error93) {
|
|
33842
33894
|
log("[snapshot-writer] write failed", {
|
|
33843
33895
|
error: error93 instanceof Error ? error93.message : String(error93)
|
|
@@ -34225,21 +34277,21 @@ var ACTIVE_STATE_TO_CLEAN = [
|
|
|
34225
34277
|
];
|
|
34226
34278
|
async function handleCloseCommand(directory, args) {
|
|
34227
34279
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
34228
|
-
const swarmDir =
|
|
34280
|
+
const swarmDir = path12.join(directory, ".swarm");
|
|
34229
34281
|
let planExists = false;
|
|
34230
34282
|
let planData = {
|
|
34231
|
-
title:
|
|
34283
|
+
title: path12.basename(directory) || "Ad-hoc session",
|
|
34232
34284
|
phases: []
|
|
34233
34285
|
};
|
|
34234
34286
|
try {
|
|
34235
|
-
const content = await
|
|
34287
|
+
const content = await fs7.readFile(planPath, "utf-8");
|
|
34236
34288
|
planData = JSON.parse(content);
|
|
34237
34289
|
planExists = true;
|
|
34238
34290
|
} catch (error93) {
|
|
34239
34291
|
if (error93?.code !== "ENOENT") {
|
|
34240
34292
|
return `\u274C Failed to read plan.json: ${error93 instanceof Error ? error93.message : String(error93)}`;
|
|
34241
34293
|
}
|
|
34242
|
-
const swarmDirExists = await
|
|
34294
|
+
const swarmDirExists = await fs7.access(swarmDir).then(() => true).catch(() => false);
|
|
34243
34295
|
if (!swarmDirExists) {
|
|
34244
34296
|
return `\u274C No .swarm/ directory found in ${directory}. Run /swarm close from the project root, or run /swarm plan first.`;
|
|
34245
34297
|
}
|
|
@@ -34333,10 +34385,10 @@ async function handleCloseCommand(directory, args) {
|
|
|
34333
34385
|
warnings.push(`Session retrospective write threw: ${retroError instanceof Error ? retroError.message : String(retroError)}`);
|
|
34334
34386
|
}
|
|
34335
34387
|
}
|
|
34336
|
-
const lessonsFilePath =
|
|
34388
|
+
const lessonsFilePath = path12.join(swarmDir, "close-lessons.md");
|
|
34337
34389
|
let explicitLessons = [];
|
|
34338
34390
|
try {
|
|
34339
|
-
const lessonsText = await
|
|
34391
|
+
const lessonsText = await fs7.readFile(lessonsFilePath, "utf-8");
|
|
34340
34392
|
explicitLessons = lessonsText.split(`
|
|
34341
34393
|
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
34342
34394
|
} catch {}
|
|
@@ -34350,7 +34402,7 @@ async function handleCloseCommand(directory, args) {
|
|
|
34350
34402
|
console.warn("[close-command] curateAndStoreSwarm error:", error93);
|
|
34351
34403
|
}
|
|
34352
34404
|
if (curationSucceeded && explicitLessons.length > 0) {
|
|
34353
|
-
await
|
|
34405
|
+
await fs7.unlink(lessonsFilePath).catch(() => {});
|
|
34354
34406
|
}
|
|
34355
34407
|
if (planExists && !planAlreadyDone) {
|
|
34356
34408
|
for (const phase of phases) {
|
|
@@ -34370,7 +34422,7 @@ async function handleCloseCommand(directory, args) {
|
|
|
34370
34422
|
}
|
|
34371
34423
|
}
|
|
34372
34424
|
try {
|
|
34373
|
-
await
|
|
34425
|
+
await fs7.writeFile(planPath, JSON.stringify(planData, null, 2), "utf-8");
|
|
34374
34426
|
} catch (error93) {
|
|
34375
34427
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
34376
34428
|
warnings.push(`Failed to persist terminal plan.json state: ${msg}`);
|
|
@@ -34379,53 +34431,53 @@ async function handleCloseCommand(directory, args) {
|
|
|
34379
34431
|
}
|
|
34380
34432
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
34381
34433
|
const suffix = Math.random().toString(36).slice(2, 8);
|
|
34382
|
-
const archiveDir =
|
|
34434
|
+
const archiveDir = path12.join(swarmDir, "archive", `swarm-${timestamp}-${suffix}`);
|
|
34383
34435
|
let archiveResult = "";
|
|
34384
34436
|
let archivedFileCount = 0;
|
|
34385
34437
|
const archivedActiveStateFiles = new Set;
|
|
34386
34438
|
try {
|
|
34387
|
-
await
|
|
34439
|
+
await fs7.mkdir(archiveDir, { recursive: true });
|
|
34388
34440
|
for (const artifact of ARCHIVE_ARTIFACTS) {
|
|
34389
|
-
const srcPath =
|
|
34390
|
-
const destPath =
|
|
34441
|
+
const srcPath = path12.join(swarmDir, artifact);
|
|
34442
|
+
const destPath = path12.join(archiveDir, artifact);
|
|
34391
34443
|
try {
|
|
34392
|
-
await
|
|
34444
|
+
await fs7.copyFile(srcPath, destPath);
|
|
34393
34445
|
archivedFileCount++;
|
|
34394
34446
|
if (ACTIVE_STATE_TO_CLEAN.includes(artifact)) {
|
|
34395
34447
|
archivedActiveStateFiles.add(artifact);
|
|
34396
34448
|
}
|
|
34397
34449
|
} catch {}
|
|
34398
34450
|
}
|
|
34399
|
-
const evidenceDir =
|
|
34400
|
-
const archiveEvidenceDir =
|
|
34451
|
+
const evidenceDir = path12.join(swarmDir, "evidence");
|
|
34452
|
+
const archiveEvidenceDir = path12.join(archiveDir, "evidence");
|
|
34401
34453
|
try {
|
|
34402
|
-
const evidenceEntries = await
|
|
34454
|
+
const evidenceEntries = await fs7.readdir(evidenceDir);
|
|
34403
34455
|
if (evidenceEntries.length > 0) {
|
|
34404
|
-
await
|
|
34456
|
+
await fs7.mkdir(archiveEvidenceDir, { recursive: true });
|
|
34405
34457
|
for (const entry of evidenceEntries) {
|
|
34406
|
-
const srcEntry =
|
|
34407
|
-
const destEntry =
|
|
34458
|
+
const srcEntry = path12.join(evidenceDir, entry);
|
|
34459
|
+
const destEntry = path12.join(archiveEvidenceDir, entry);
|
|
34408
34460
|
try {
|
|
34409
|
-
const stat = await
|
|
34461
|
+
const stat = await fs7.stat(srcEntry);
|
|
34410
34462
|
if (stat.isDirectory()) {
|
|
34411
|
-
await
|
|
34412
|
-
const subEntries = await
|
|
34463
|
+
await fs7.mkdir(destEntry, { recursive: true });
|
|
34464
|
+
const subEntries = await fs7.readdir(srcEntry);
|
|
34413
34465
|
for (const sub of subEntries) {
|
|
34414
|
-
await
|
|
34466
|
+
await fs7.copyFile(path12.join(srcEntry, sub), path12.join(destEntry, sub)).catch(() => {});
|
|
34415
34467
|
}
|
|
34416
34468
|
} else {
|
|
34417
|
-
await
|
|
34469
|
+
await fs7.copyFile(srcEntry, destEntry);
|
|
34418
34470
|
}
|
|
34419
34471
|
archivedFileCount++;
|
|
34420
34472
|
} catch {}
|
|
34421
34473
|
}
|
|
34422
34474
|
}
|
|
34423
34475
|
} catch {}
|
|
34424
|
-
const sessionStatePath =
|
|
34476
|
+
const sessionStatePath = path12.join(swarmDir, "session", "state.json");
|
|
34425
34477
|
try {
|
|
34426
|
-
const archiveSessionDir =
|
|
34427
|
-
await
|
|
34428
|
-
await
|
|
34478
|
+
const archiveSessionDir = path12.join(archiveDir, "session");
|
|
34479
|
+
await fs7.mkdir(archiveSessionDir, { recursive: true });
|
|
34480
|
+
await fs7.copyFile(sessionStatePath, path12.join(archiveSessionDir, "state.json"));
|
|
34429
34481
|
archivedFileCount++;
|
|
34430
34482
|
} catch {}
|
|
34431
34483
|
archiveResult = `Archived ${archivedFileCount} artifact(s) to .swarm/archive/swarm-${timestamp}/`;
|
|
@@ -34448,9 +34500,9 @@ async function handleCloseCommand(directory, args) {
|
|
|
34448
34500
|
warnings.push(`Preserved ${artifact} because it was not successfully archived.`);
|
|
34449
34501
|
continue;
|
|
34450
34502
|
}
|
|
34451
|
-
const filePath =
|
|
34503
|
+
const filePath = path12.join(swarmDir, artifact);
|
|
34452
34504
|
try {
|
|
34453
|
-
await
|
|
34505
|
+
await fs7.unlink(filePath);
|
|
34454
34506
|
cleanedFiles.push(artifact);
|
|
34455
34507
|
} catch {}
|
|
34456
34508
|
}
|
|
@@ -34458,22 +34510,23 @@ async function handleCloseCommand(directory, args) {
|
|
|
34458
34510
|
warnings.push("Skipped active-state cleanup because no active-state files were archived. Files preserved to prevent data loss.");
|
|
34459
34511
|
}
|
|
34460
34512
|
try {
|
|
34461
|
-
const swarmFiles = await
|
|
34513
|
+
const swarmFiles = await fs7.readdir(swarmDir);
|
|
34462
34514
|
const configBackups = swarmFiles.filter((f) => f.startsWith("config-backup-") && f.endsWith(".json"));
|
|
34463
34515
|
for (const backup of configBackups) {
|
|
34464
34516
|
try {
|
|
34465
|
-
await
|
|
34517
|
+
await fs7.unlink(path12.join(swarmDir, backup));
|
|
34466
34518
|
configBackupsRemoved++;
|
|
34467
34519
|
} catch {}
|
|
34468
34520
|
}
|
|
34469
34521
|
const ledgerSiblings = swarmFiles.filter((f) => (f.startsWith("plan-ledger.archived-") || f.startsWith("plan-ledger.backup-")) && f.endsWith(".jsonl"));
|
|
34470
34522
|
for (const sibling of ledgerSiblings) {
|
|
34471
34523
|
try {
|
|
34472
|
-
await
|
|
34524
|
+
await fs7.unlink(path12.join(swarmDir, sibling));
|
|
34473
34525
|
} catch {}
|
|
34474
34526
|
}
|
|
34475
34527
|
} catch {}
|
|
34476
|
-
|
|
34528
|
+
clearAllScopes(directory);
|
|
34529
|
+
const contextPath = path12.join(swarmDir, "context.md");
|
|
34477
34530
|
const contextContent = [
|
|
34478
34531
|
"# Context",
|
|
34479
34532
|
"",
|
|
@@ -34486,7 +34539,7 @@ async function handleCloseCommand(directory, args) {
|
|
|
34486
34539
|
].join(`
|
|
34487
34540
|
`);
|
|
34488
34541
|
try {
|
|
34489
|
-
await
|
|
34542
|
+
await fs7.writeFile(contextPath, contextContent, "utf-8");
|
|
34490
34543
|
} catch (error93) {
|
|
34491
34544
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
34492
34545
|
warnings.push(`Failed to reset context.md: ${msg}`);
|
|
@@ -34617,7 +34670,7 @@ async function handleCloseCommand(directory, args) {
|
|
|
34617
34670
|
].join(`
|
|
34618
34671
|
`);
|
|
34619
34672
|
try {
|
|
34620
|
-
await
|
|
34673
|
+
await fs7.writeFile(closeSummaryPath, summaryContent, "utf-8");
|
|
34621
34674
|
} catch (error93) {
|
|
34622
34675
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
34623
34676
|
warnings.push(`Failed to write close-summary.md: ${msg}`);
|
|
@@ -34674,14 +34727,14 @@ ${otherWarnings.map((w) => `- ${w}`).join(`
|
|
|
34674
34727
|
|
|
34675
34728
|
// src/commands/config.ts
|
|
34676
34729
|
import * as os3 from "os";
|
|
34677
|
-
import * as
|
|
34730
|
+
import * as path13 from "path";
|
|
34678
34731
|
function getUserConfigDir2() {
|
|
34679
|
-
return process.env.XDG_CONFIG_HOME ||
|
|
34732
|
+
return process.env.XDG_CONFIG_HOME || path13.join(os3.homedir(), ".config");
|
|
34680
34733
|
}
|
|
34681
34734
|
async function handleConfigCommand(directory, _args) {
|
|
34682
34735
|
const config3 = loadPluginConfig(directory);
|
|
34683
|
-
const userConfigPath =
|
|
34684
|
-
const projectConfigPath =
|
|
34736
|
+
const userConfigPath = path13.join(getUserConfigDir2(), "opencode", "opencode-swarm.json");
|
|
34737
|
+
const projectConfigPath = path13.join(directory, ".opencode", "opencode-swarm.json");
|
|
34685
34738
|
const lines = [
|
|
34686
34739
|
"## Swarm Configuration",
|
|
34687
34740
|
"",
|
|
@@ -34949,13 +35002,13 @@ function formatCurationSummary(summary) {
|
|
|
34949
35002
|
}
|
|
34950
35003
|
|
|
34951
35004
|
// src/commands/dark-matter.ts
|
|
34952
|
-
import
|
|
35005
|
+
import path15 from "path";
|
|
34953
35006
|
|
|
34954
35007
|
// src/tools/co-change-analyzer.ts
|
|
34955
35008
|
import * as child_process3 from "child_process";
|
|
34956
35009
|
import { randomUUID } from "crypto";
|
|
34957
35010
|
import { readdir, readFile as readFile3, stat } from "fs/promises";
|
|
34958
|
-
import * as
|
|
35011
|
+
import * as path14 from "path";
|
|
34959
35012
|
import { promisify } from "util";
|
|
34960
35013
|
function getExecFileAsync() {
|
|
34961
35014
|
return promisify(child_process3.execFile);
|
|
@@ -35057,7 +35110,7 @@ async function scanSourceFiles(dir) {
|
|
|
35057
35110
|
try {
|
|
35058
35111
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
35059
35112
|
for (const entry of entries) {
|
|
35060
|
-
const fullPath =
|
|
35113
|
+
const fullPath = path14.join(dir, entry.name);
|
|
35061
35114
|
if (entry.isDirectory()) {
|
|
35062
35115
|
if (skipDirs.has(entry.name)) {
|
|
35063
35116
|
continue;
|
|
@@ -35065,7 +35118,7 @@ async function scanSourceFiles(dir) {
|
|
|
35065
35118
|
const subFiles = await scanSourceFiles(fullPath);
|
|
35066
35119
|
results.push(...subFiles);
|
|
35067
35120
|
} else if (entry.isFile()) {
|
|
35068
|
-
const ext =
|
|
35121
|
+
const ext = path14.extname(entry.name);
|
|
35069
35122
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext)) {
|
|
35070
35123
|
results.push(fullPath);
|
|
35071
35124
|
}
|
|
@@ -35087,8 +35140,8 @@ async function getStaticEdges(directory) {
|
|
|
35087
35140
|
continue;
|
|
35088
35141
|
}
|
|
35089
35142
|
try {
|
|
35090
|
-
const sourceDir =
|
|
35091
|
-
const resolvedPath =
|
|
35143
|
+
const sourceDir = path14.dirname(sourceFile);
|
|
35144
|
+
const resolvedPath = path14.resolve(sourceDir, importPath);
|
|
35092
35145
|
const extensions = [
|
|
35093
35146
|
"",
|
|
35094
35147
|
".ts",
|
|
@@ -35113,8 +35166,8 @@ async function getStaticEdges(directory) {
|
|
|
35113
35166
|
if (!targetFile) {
|
|
35114
35167
|
continue;
|
|
35115
35168
|
}
|
|
35116
|
-
const relSource =
|
|
35117
|
-
const relTarget =
|
|
35169
|
+
const relSource = path14.relative(directory, sourceFile).replace(/\\/g, "/");
|
|
35170
|
+
const relTarget = path14.relative(directory, targetFile).replace(/\\/g, "/");
|
|
35118
35171
|
const [key] = relSource < relTarget ? [`${relSource}::${relTarget}`, relSource, relTarget] : [`${relTarget}::${relSource}`, relTarget, relSource];
|
|
35119
35172
|
edges.add(key);
|
|
35120
35173
|
} catch {}
|
|
@@ -35126,7 +35179,7 @@ async function getStaticEdges(directory) {
|
|
|
35126
35179
|
function isTestImplementationPair(fileA, fileB) {
|
|
35127
35180
|
const testPatterns = [".test.ts", ".test.js", ".spec.ts", ".spec.js"];
|
|
35128
35181
|
const getBaseName = (filePath) => {
|
|
35129
|
-
const base =
|
|
35182
|
+
const base = path14.basename(filePath);
|
|
35130
35183
|
for (const pattern of testPatterns) {
|
|
35131
35184
|
if (base.endsWith(pattern)) {
|
|
35132
35185
|
return base.slice(0, -pattern.length);
|
|
@@ -35136,16 +35189,16 @@ function isTestImplementationPair(fileA, fileB) {
|
|
|
35136
35189
|
};
|
|
35137
35190
|
const baseA = getBaseName(fileA);
|
|
35138
35191
|
const baseB = getBaseName(fileB);
|
|
35139
|
-
return baseA === baseB && baseA !==
|
|
35192
|
+
return baseA === baseB && baseA !== path14.basename(fileA) && baseA !== path14.basename(fileB);
|
|
35140
35193
|
}
|
|
35141
35194
|
function hasSharedPrefix(fileA, fileB) {
|
|
35142
|
-
const dirA =
|
|
35143
|
-
const dirB =
|
|
35195
|
+
const dirA = path14.dirname(fileA);
|
|
35196
|
+
const dirB = path14.dirname(fileB);
|
|
35144
35197
|
if (dirA !== dirB) {
|
|
35145
35198
|
return false;
|
|
35146
35199
|
}
|
|
35147
|
-
const baseA =
|
|
35148
|
-
const baseB =
|
|
35200
|
+
const baseA = path14.basename(fileA).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
|
|
35201
|
+
const baseB = path14.basename(fileB).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
|
|
35149
35202
|
if (baseA.startsWith(baseB) || baseB.startsWith(baseA)) {
|
|
35150
35203
|
return true;
|
|
35151
35204
|
}
|
|
@@ -35199,8 +35252,8 @@ function darkMatterToKnowledgeEntries(pairs, projectName) {
|
|
|
35199
35252
|
const entries = [];
|
|
35200
35253
|
const now = new Date().toISOString();
|
|
35201
35254
|
for (const pair of pairs.slice(0, 10)) {
|
|
35202
|
-
const baseA =
|
|
35203
|
-
const baseB =
|
|
35255
|
+
const baseA = path14.basename(pair.fileA);
|
|
35256
|
+
const baseB = path14.basename(pair.fileB);
|
|
35204
35257
|
let lesson = `Files ${pair.fileA} and ${pair.fileB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern \u2014 changes to one likely require changes to the other.`;
|
|
35205
35258
|
if (lesson.length > 280) {
|
|
35206
35259
|
lesson = `Files ${baseA} and ${baseB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern \u2014 changes to one likely require changes to the other.`;
|
|
@@ -35310,7 +35363,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
35310
35363
|
const output = formatDarkMatterOutput(pairs);
|
|
35311
35364
|
if (pairs.length > 0) {
|
|
35312
35365
|
try {
|
|
35313
|
-
const projectName =
|
|
35366
|
+
const projectName = path15.basename(path15.resolve(directory));
|
|
35314
35367
|
const entries = darkMatterToKnowledgeEntries(pairs, projectName);
|
|
35315
35368
|
if (entries.length > 0) {
|
|
35316
35369
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
@@ -35331,8 +35384,8 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
35331
35384
|
|
|
35332
35385
|
// src/services/diagnose-service.ts
|
|
35333
35386
|
import * as child_process4 from "child_process";
|
|
35334
|
-
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as
|
|
35335
|
-
import
|
|
35387
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
|
|
35388
|
+
import path16 from "path";
|
|
35336
35389
|
import { fileURLToPath } from "url";
|
|
35337
35390
|
init_manager2();
|
|
35338
35391
|
init_utils2();
|
|
@@ -35568,7 +35621,7 @@ async function checkConfigBackups(directory) {
|
|
|
35568
35621
|
}
|
|
35569
35622
|
async function checkGitRepository(directory) {
|
|
35570
35623
|
try {
|
|
35571
|
-
if (!existsSync6(directory) || !
|
|
35624
|
+
if (!existsSync6(directory) || !statSync4(directory).isDirectory()) {
|
|
35572
35625
|
return {
|
|
35573
35626
|
name: "Git Repository",
|
|
35574
35627
|
status: "\u274C",
|
|
@@ -35632,7 +35685,7 @@ async function checkSpecStaleness(directory, plan) {
|
|
|
35632
35685
|
};
|
|
35633
35686
|
}
|
|
35634
35687
|
async function checkConfigParseability(directory) {
|
|
35635
|
-
const configPath =
|
|
35688
|
+
const configPath = path16.join(directory, ".opencode/opencode-swarm.json");
|
|
35636
35689
|
if (!existsSync6(configPath)) {
|
|
35637
35690
|
return {
|
|
35638
35691
|
name: "Config Parseability",
|
|
@@ -35641,7 +35694,7 @@ async function checkConfigParseability(directory) {
|
|
|
35641
35694
|
};
|
|
35642
35695
|
}
|
|
35643
35696
|
try {
|
|
35644
|
-
const content =
|
|
35697
|
+
const content = readFileSync6(configPath, "utf-8");
|
|
35645
35698
|
JSON.parse(content);
|
|
35646
35699
|
return {
|
|
35647
35700
|
name: "Config Parseability",
|
|
@@ -35679,15 +35732,15 @@ async function checkGrammarWasmFiles() {
|
|
|
35679
35732
|
"tree-sitter-ini.wasm",
|
|
35680
35733
|
"tree-sitter-regex.wasm"
|
|
35681
35734
|
];
|
|
35682
|
-
const thisDir =
|
|
35735
|
+
const thisDir = path16.dirname(fileURLToPath(import.meta.url));
|
|
35683
35736
|
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
|
|
35684
|
-
const grammarDir = isSource ?
|
|
35737
|
+
const grammarDir = isSource ? path16.join(thisDir, "..", "lang", "grammars") : path16.join(thisDir, "lang", "grammars");
|
|
35685
35738
|
const missing = [];
|
|
35686
|
-
if (!existsSync6(
|
|
35739
|
+
if (!existsSync6(path16.join(grammarDir, "tree-sitter.wasm"))) {
|
|
35687
35740
|
missing.push("tree-sitter.wasm (core runtime)");
|
|
35688
35741
|
}
|
|
35689
35742
|
for (const file3 of grammarFiles) {
|
|
35690
|
-
if (!existsSync6(
|
|
35743
|
+
if (!existsSync6(path16.join(grammarDir, file3))) {
|
|
35691
35744
|
missing.push(file3);
|
|
35692
35745
|
}
|
|
35693
35746
|
}
|
|
@@ -35705,7 +35758,7 @@ async function checkGrammarWasmFiles() {
|
|
|
35705
35758
|
};
|
|
35706
35759
|
}
|
|
35707
35760
|
async function checkCheckpointManifest(directory) {
|
|
35708
|
-
const manifestPath =
|
|
35761
|
+
const manifestPath = path16.join(directory, ".swarm/checkpoints.json");
|
|
35709
35762
|
if (!existsSync6(manifestPath)) {
|
|
35710
35763
|
return {
|
|
35711
35764
|
name: "Checkpoint Manifest",
|
|
@@ -35714,7 +35767,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
35714
35767
|
};
|
|
35715
35768
|
}
|
|
35716
35769
|
try {
|
|
35717
|
-
const content =
|
|
35770
|
+
const content = readFileSync6(manifestPath, "utf-8");
|
|
35718
35771
|
const parsed = JSON.parse(content);
|
|
35719
35772
|
if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
|
|
35720
35773
|
return {
|
|
@@ -35757,7 +35810,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
35757
35810
|
}
|
|
35758
35811
|
}
|
|
35759
35812
|
async function checkEventStreamIntegrity(directory) {
|
|
35760
|
-
const eventsPath =
|
|
35813
|
+
const eventsPath = path16.join(directory, ".swarm/events.jsonl");
|
|
35761
35814
|
if (!existsSync6(eventsPath)) {
|
|
35762
35815
|
return {
|
|
35763
35816
|
name: "Event Stream",
|
|
@@ -35766,7 +35819,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
35766
35819
|
};
|
|
35767
35820
|
}
|
|
35768
35821
|
try {
|
|
35769
|
-
const content =
|
|
35822
|
+
const content = readFileSync6(eventsPath, "utf-8");
|
|
35770
35823
|
const lines = content.split(`
|
|
35771
35824
|
`).filter((line) => line.trim() !== "");
|
|
35772
35825
|
let malformedCount = 0;
|
|
@@ -35798,7 +35851,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
35798
35851
|
}
|
|
35799
35852
|
}
|
|
35800
35853
|
async function checkSteeringDirectives(directory) {
|
|
35801
|
-
const eventsPath =
|
|
35854
|
+
const eventsPath = path16.join(directory, ".swarm/events.jsonl");
|
|
35802
35855
|
if (!existsSync6(eventsPath)) {
|
|
35803
35856
|
return {
|
|
35804
35857
|
name: "Steering Directives",
|
|
@@ -35807,7 +35860,7 @@ async function checkSteeringDirectives(directory) {
|
|
|
35807
35860
|
};
|
|
35808
35861
|
}
|
|
35809
35862
|
try {
|
|
35810
|
-
const content =
|
|
35863
|
+
const content = readFileSync6(eventsPath, "utf-8");
|
|
35811
35864
|
const lines = content.split(`
|
|
35812
35865
|
`).filter((line) => line.trim() !== "");
|
|
35813
35866
|
const directivesIssued = [];
|
|
@@ -35854,7 +35907,7 @@ async function checkCurator(directory) {
|
|
|
35854
35907
|
detail: "Disabled (enable via curator.enabled)"
|
|
35855
35908
|
};
|
|
35856
35909
|
}
|
|
35857
|
-
const summaryPath =
|
|
35910
|
+
const summaryPath = path16.join(directory, ".swarm/curator-summary.json");
|
|
35858
35911
|
if (!existsSync6(summaryPath)) {
|
|
35859
35912
|
return {
|
|
35860
35913
|
name: "Curator",
|
|
@@ -35863,7 +35916,7 @@ async function checkCurator(directory) {
|
|
|
35863
35916
|
};
|
|
35864
35917
|
}
|
|
35865
35918
|
try {
|
|
35866
|
-
const content =
|
|
35919
|
+
const content = readFileSync6(summaryPath, "utf-8");
|
|
35867
35920
|
const parsed = JSON.parse(content);
|
|
35868
35921
|
if (typeof parsed.schema_version !== "number" || parsed.schema_version !== 1) {
|
|
35869
35922
|
return {
|
|
@@ -36002,7 +36055,7 @@ async function getDiagnoseData(directory) {
|
|
|
36002
36055
|
checks5.push(await checkSteeringDirectives(directory));
|
|
36003
36056
|
checks5.push(await checkCurator(directory));
|
|
36004
36057
|
try {
|
|
36005
|
-
const evidenceDir =
|
|
36058
|
+
const evidenceDir = path16.join(directory, ".swarm", "evidence");
|
|
36006
36059
|
const snapshotFiles = existsSync6(evidenceDir) ? readdirSync3(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
|
|
36007
36060
|
if (snapshotFiles.length > 0) {
|
|
36008
36061
|
const latest = snapshotFiles.sort().pop();
|
|
@@ -36054,16 +36107,16 @@ async function handleDiagnoseCommand(directory, _args) {
|
|
|
36054
36107
|
init_config_doctor();
|
|
36055
36108
|
|
|
36056
36109
|
// src/services/tool-doctor.ts
|
|
36057
|
-
import * as
|
|
36058
|
-
import * as
|
|
36110
|
+
import * as fs10 from "fs";
|
|
36111
|
+
import * as path19 from "path";
|
|
36059
36112
|
|
|
36060
36113
|
// src/build/discovery.ts
|
|
36061
|
-
import * as
|
|
36062
|
-
import * as
|
|
36114
|
+
import * as fs9 from "fs";
|
|
36115
|
+
import * as path18 from "path";
|
|
36063
36116
|
|
|
36064
36117
|
// src/lang/detector.ts
|
|
36065
36118
|
import { access as access2, readdir as readdir2 } from "fs/promises";
|
|
36066
|
-
import { extname as extname2, join as
|
|
36119
|
+
import { extname as extname2, join as join14 } from "path";
|
|
36067
36120
|
|
|
36068
36121
|
// src/lang/profiles.ts
|
|
36069
36122
|
class LanguageRegistry {
|
|
@@ -37043,7 +37096,7 @@ async function detectProjectLanguages(projectDir) {
|
|
|
37043
37096
|
if (detectFile.includes("*") || detectFile.includes("?"))
|
|
37044
37097
|
continue;
|
|
37045
37098
|
try {
|
|
37046
|
-
await access2(
|
|
37099
|
+
await access2(join14(dir, detectFile));
|
|
37047
37100
|
detected.add(profile.id);
|
|
37048
37101
|
break;
|
|
37049
37102
|
} catch {}
|
|
@@ -37064,7 +37117,7 @@ async function detectProjectLanguages(projectDir) {
|
|
|
37064
37117
|
const topEntries = await readdir2(projectDir, { withFileTypes: true });
|
|
37065
37118
|
for (const entry of topEntries) {
|
|
37066
37119
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
37067
|
-
await scanDir(
|
|
37120
|
+
await scanDir(join14(projectDir, entry.name));
|
|
37068
37121
|
}
|
|
37069
37122
|
}
|
|
37070
37123
|
} catch {}
|
|
@@ -37219,16 +37272,16 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
37219
37272
|
if (pattern.includes("*")) {
|
|
37220
37273
|
const dir = workingDir;
|
|
37221
37274
|
try {
|
|
37222
|
-
const files =
|
|
37275
|
+
const files = fs9.readdirSync(dir);
|
|
37223
37276
|
const regex = simpleGlobToRegex(pattern);
|
|
37224
37277
|
const matches = files.filter((f) => regex.test(f));
|
|
37225
37278
|
if (matches.length > 0) {
|
|
37226
|
-
return
|
|
37279
|
+
return path18.join(dir, matches[0]);
|
|
37227
37280
|
}
|
|
37228
37281
|
} catch {}
|
|
37229
37282
|
} else {
|
|
37230
|
-
const filePath =
|
|
37231
|
-
if (
|
|
37283
|
+
const filePath = path18.join(workingDir, pattern);
|
|
37284
|
+
if (fs9.existsSync(filePath)) {
|
|
37232
37285
|
return filePath;
|
|
37233
37286
|
}
|
|
37234
37287
|
}
|
|
@@ -37236,12 +37289,12 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
37236
37289
|
return null;
|
|
37237
37290
|
}
|
|
37238
37291
|
function getRepoDefinedScripts(workingDir, scripts) {
|
|
37239
|
-
const packageJsonPath =
|
|
37240
|
-
if (!
|
|
37292
|
+
const packageJsonPath = path18.join(workingDir, "package.json");
|
|
37293
|
+
if (!fs9.existsSync(packageJsonPath)) {
|
|
37241
37294
|
return [];
|
|
37242
37295
|
}
|
|
37243
37296
|
try {
|
|
37244
|
-
const content =
|
|
37297
|
+
const content = fs9.readFileSync(packageJsonPath, "utf-8");
|
|
37245
37298
|
const pkg = JSON.parse(content);
|
|
37246
37299
|
if (!pkg.scripts || typeof pkg.scripts !== "object") {
|
|
37247
37300
|
return [];
|
|
@@ -37277,8 +37330,8 @@ function findAllBuildFiles(workingDir) {
|
|
|
37277
37330
|
const regex = simpleGlobToRegex(pattern);
|
|
37278
37331
|
findFilesRecursive(workingDir, regex, allBuildFiles);
|
|
37279
37332
|
} else {
|
|
37280
|
-
const filePath =
|
|
37281
|
-
if (
|
|
37333
|
+
const filePath = path18.join(workingDir, pattern);
|
|
37334
|
+
if (fs9.existsSync(filePath)) {
|
|
37282
37335
|
allBuildFiles.add(filePath);
|
|
37283
37336
|
}
|
|
37284
37337
|
}
|
|
@@ -37288,9 +37341,9 @@ function findAllBuildFiles(workingDir) {
|
|
|
37288
37341
|
}
|
|
37289
37342
|
function findFilesRecursive(dir, regex, results) {
|
|
37290
37343
|
try {
|
|
37291
|
-
const entries =
|
|
37344
|
+
const entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
37292
37345
|
for (const entry of entries) {
|
|
37293
|
-
const fullPath =
|
|
37346
|
+
const fullPath = path18.join(dir, entry.name);
|
|
37294
37347
|
if (entry.isDirectory() && !["node_modules", ".git", "dist", "build", "target"].includes(entry.name)) {
|
|
37295
37348
|
findFilesRecursive(fullPath, regex, results);
|
|
37296
37349
|
} else if (entry.isFile() && regex.test(entry.name)) {
|
|
@@ -37313,8 +37366,8 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
|
|
|
37313
37366
|
let foundCommand = false;
|
|
37314
37367
|
for (const cmd of sortedCommands) {
|
|
37315
37368
|
if (cmd.detectFile) {
|
|
37316
|
-
const detectFilePath =
|
|
37317
|
-
if (!
|
|
37369
|
+
const detectFilePath = path18.join(workingDir, cmd.detectFile);
|
|
37370
|
+
if (!fs9.existsSync(detectFilePath)) {
|
|
37318
37371
|
continue;
|
|
37319
37372
|
}
|
|
37320
37373
|
}
|
|
@@ -37437,7 +37490,7 @@ var BINARY_CHECKLIST = [
|
|
|
37437
37490
|
function extractRegisteredToolKeys(indexPath) {
|
|
37438
37491
|
const registeredKeys = new Set;
|
|
37439
37492
|
try {
|
|
37440
|
-
const content =
|
|
37493
|
+
const content = fs10.readFileSync(indexPath, "utf-8");
|
|
37441
37494
|
const toolBlockMatch = content.match(/tool:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s);
|
|
37442
37495
|
if (!toolBlockMatch) {
|
|
37443
37496
|
return registeredKeys;
|
|
@@ -37488,9 +37541,9 @@ function checkBinaryReadiness() {
|
|
|
37488
37541
|
}
|
|
37489
37542
|
function runToolDoctor(_directory, pluginRoot) {
|
|
37490
37543
|
const findings = [];
|
|
37491
|
-
const resolvedPluginRoot = pluginRoot ??
|
|
37492
|
-
const indexPath =
|
|
37493
|
-
if (!
|
|
37544
|
+
const resolvedPluginRoot = pluginRoot ?? path19.resolve(import.meta.dir, "..", "..");
|
|
37545
|
+
const indexPath = path19.join(resolvedPluginRoot, "src", "index.ts");
|
|
37546
|
+
if (!fs10.existsSync(indexPath)) {
|
|
37494
37547
|
return {
|
|
37495
37548
|
findings: [
|
|
37496
37549
|
{
|
|
@@ -37877,7 +37930,7 @@ async function handleFullAutoCommand(_directory, args, sessionID) {
|
|
|
37877
37930
|
// src/commands/handoff.ts
|
|
37878
37931
|
init_utils2();
|
|
37879
37932
|
import crypto4 from "crypto";
|
|
37880
|
-
import { renameSync as
|
|
37933
|
+
import { renameSync as renameSync6 } from "fs";
|
|
37881
37934
|
|
|
37882
37935
|
// src/services/handoff-service.ts
|
|
37883
37936
|
init_utils2();
|
|
@@ -38245,12 +38298,12 @@ async function handleHandoffCommand(directory, _args) {
|
|
|
38245
38298
|
const resolvedPath = validateSwarmPath(directory, "handoff.md");
|
|
38246
38299
|
const tempPath = `${resolvedPath}.tmp.${crypto4.randomUUID()}`;
|
|
38247
38300
|
await Bun.write(tempPath, markdown);
|
|
38248
|
-
|
|
38301
|
+
renameSync6(tempPath, resolvedPath);
|
|
38249
38302
|
const continuationPrompt = formatContinuationPrompt(handoffData);
|
|
38250
38303
|
const promptPath = validateSwarmPath(directory, "handoff-prompt.md");
|
|
38251
38304
|
const promptTempPath = `${promptPath}.tmp.${crypto4.randomUUID()}`;
|
|
38252
38305
|
await Bun.write(promptTempPath, continuationPrompt);
|
|
38253
|
-
|
|
38306
|
+
renameSync6(promptTempPath, promptPath);
|
|
38254
38307
|
await writeSnapshot(directory, swarmState);
|
|
38255
38308
|
await flushPendingSnapshot(directory);
|
|
38256
38309
|
return `## Handoff Brief Written
|
|
@@ -38400,12 +38453,12 @@ async function handleHistoryCommand(directory, _args) {
|
|
|
38400
38453
|
}
|
|
38401
38454
|
// src/hooks/knowledge-migrator.ts
|
|
38402
38455
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
38403
|
-
import { existsSync as existsSync10, readFileSync as
|
|
38456
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "fs";
|
|
38404
38457
|
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
38405
|
-
import * as
|
|
38458
|
+
import * as path20 from "path";
|
|
38406
38459
|
async function migrateContextToKnowledge(directory, config3) {
|
|
38407
|
-
const sentinelPath =
|
|
38408
|
-
const contextPath =
|
|
38460
|
+
const sentinelPath = path20.join(directory, ".swarm", ".knowledge-migrated");
|
|
38461
|
+
const contextPath = path20.join(directory, ".swarm", "context.md");
|
|
38409
38462
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
38410
38463
|
if (existsSync10(sentinelPath)) {
|
|
38411
38464
|
return {
|
|
@@ -38601,16 +38654,16 @@ function truncateLesson(text) {
|
|
|
38601
38654
|
return `${text.slice(0, 277)}...`;
|
|
38602
38655
|
}
|
|
38603
38656
|
function inferProjectName(directory) {
|
|
38604
|
-
const packageJsonPath =
|
|
38657
|
+
const packageJsonPath = path20.join(directory, "package.json");
|
|
38605
38658
|
if (existsSync10(packageJsonPath)) {
|
|
38606
38659
|
try {
|
|
38607
|
-
const pkg = JSON.parse(
|
|
38660
|
+
const pkg = JSON.parse(readFileSync10(packageJsonPath, "utf-8"));
|
|
38608
38661
|
if (pkg.name && typeof pkg.name === "string") {
|
|
38609
38662
|
return pkg.name;
|
|
38610
38663
|
}
|
|
38611
38664
|
} catch {}
|
|
38612
38665
|
}
|
|
38613
|
-
return
|
|
38666
|
+
return path20.basename(directory);
|
|
38614
38667
|
}
|
|
38615
38668
|
async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
38616
38669
|
const sentinel = {
|
|
@@ -38622,7 +38675,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
38622
38675
|
schema_version: 1,
|
|
38623
38676
|
migration_tool: "knowledge-migrator.ts"
|
|
38624
38677
|
};
|
|
38625
|
-
await mkdir3(
|
|
38678
|
+
await mkdir3(path20.dirname(sentinelPath), { recursive: true });
|
|
38626
38679
|
await writeFile4(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
38627
38680
|
}
|
|
38628
38681
|
|
|
@@ -38858,12 +38911,12 @@ async function handlePlanCommand(directory, args) {
|
|
|
38858
38911
|
// src/services/preflight-service.ts
|
|
38859
38912
|
init_manager2();
|
|
38860
38913
|
init_manager();
|
|
38861
|
-
import * as
|
|
38862
|
-
import * as
|
|
38914
|
+
import * as fs17 from "fs";
|
|
38915
|
+
import * as path27 from "path";
|
|
38863
38916
|
|
|
38864
38917
|
// src/tools/lint.ts
|
|
38865
|
-
import * as
|
|
38866
|
-
import * as
|
|
38918
|
+
import * as fs11 from "fs";
|
|
38919
|
+
import * as path21 from "path";
|
|
38867
38920
|
init_utils();
|
|
38868
38921
|
|
|
38869
38922
|
// src/utils/path-security.ts
|
|
@@ -38909,9 +38962,9 @@ function validateArgs(args) {
|
|
|
38909
38962
|
}
|
|
38910
38963
|
function getLinterCommand(linter, mode, projectDir) {
|
|
38911
38964
|
const isWindows = process.platform === "win32";
|
|
38912
|
-
const binDir =
|
|
38913
|
-
const biomeBin = isWindows ?
|
|
38914
|
-
const eslintBin = isWindows ?
|
|
38965
|
+
const binDir = path21.join(projectDir, "node_modules", ".bin");
|
|
38966
|
+
const biomeBin = isWindows ? path21.join(binDir, "biome.EXE") : path21.join(binDir, "biome");
|
|
38967
|
+
const eslintBin = isWindows ? path21.join(binDir, "eslint.cmd") : path21.join(binDir, "eslint");
|
|
38915
38968
|
switch (linter) {
|
|
38916
38969
|
case "biome":
|
|
38917
38970
|
if (mode === "fix") {
|
|
@@ -38927,7 +38980,7 @@ function getLinterCommand(linter, mode, projectDir) {
|
|
|
38927
38980
|
}
|
|
38928
38981
|
function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
38929
38982
|
const gradlewName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
|
|
38930
|
-
const gradlew =
|
|
38983
|
+
const gradlew = fs11.existsSync(path21.join(cwd, gradlewName)) ? path21.join(cwd, gradlewName) : null;
|
|
38931
38984
|
switch (linter) {
|
|
38932
38985
|
case "ruff":
|
|
38933
38986
|
return mode === "fix" ? ["ruff", "check", "--fix", "."] : ["ruff", "check", "."];
|
|
@@ -38961,12 +39014,12 @@ function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
|
38961
39014
|
}
|
|
38962
39015
|
}
|
|
38963
39016
|
function detectRuff(cwd) {
|
|
38964
|
-
if (
|
|
39017
|
+
if (fs11.existsSync(path21.join(cwd, "ruff.toml")))
|
|
38965
39018
|
return isCommandAvailable("ruff");
|
|
38966
39019
|
try {
|
|
38967
|
-
const pyproject =
|
|
38968
|
-
if (
|
|
38969
|
-
const content =
|
|
39020
|
+
const pyproject = path21.join(cwd, "pyproject.toml");
|
|
39021
|
+
if (fs11.existsSync(pyproject)) {
|
|
39022
|
+
const content = fs11.readFileSync(pyproject, "utf-8");
|
|
38970
39023
|
if (content.includes("[tool.ruff]"))
|
|
38971
39024
|
return isCommandAvailable("ruff");
|
|
38972
39025
|
}
|
|
@@ -38974,21 +39027,21 @@ function detectRuff(cwd) {
|
|
|
38974
39027
|
return false;
|
|
38975
39028
|
}
|
|
38976
39029
|
function detectClippy(cwd) {
|
|
38977
|
-
return
|
|
39030
|
+
return fs11.existsSync(path21.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
|
|
38978
39031
|
}
|
|
38979
39032
|
function detectGolangciLint(cwd) {
|
|
38980
|
-
return
|
|
39033
|
+
return fs11.existsSync(path21.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
|
|
38981
39034
|
}
|
|
38982
39035
|
function detectCheckstyle(cwd) {
|
|
38983
|
-
const hasMaven =
|
|
38984
|
-
const hasGradle =
|
|
38985
|
-
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (
|
|
39036
|
+
const hasMaven = fs11.existsSync(path21.join(cwd, "pom.xml"));
|
|
39037
|
+
const hasGradle = fs11.existsSync(path21.join(cwd, "build.gradle")) || fs11.existsSync(path21.join(cwd, "build.gradle.kts"));
|
|
39038
|
+
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs11.existsSync(path21.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
|
|
38986
39039
|
return (hasMaven || hasGradle) && hasBinary;
|
|
38987
39040
|
}
|
|
38988
39041
|
function detectKtlint(cwd) {
|
|
38989
|
-
const hasKotlin =
|
|
39042
|
+
const hasKotlin = fs11.existsSync(path21.join(cwd, "build.gradle.kts")) || fs11.existsSync(path21.join(cwd, "build.gradle")) || (() => {
|
|
38990
39043
|
try {
|
|
38991
|
-
return
|
|
39044
|
+
return fs11.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
|
|
38992
39045
|
} catch {
|
|
38993
39046
|
return false;
|
|
38994
39047
|
}
|
|
@@ -38997,7 +39050,7 @@ function detectKtlint(cwd) {
|
|
|
38997
39050
|
}
|
|
38998
39051
|
function detectDotnetFormat(cwd) {
|
|
38999
39052
|
try {
|
|
39000
|
-
const files =
|
|
39053
|
+
const files = fs11.readdirSync(cwd);
|
|
39001
39054
|
const hasCsproj = files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"));
|
|
39002
39055
|
return hasCsproj && isCommandAvailable("dotnet");
|
|
39003
39056
|
} catch {
|
|
@@ -39005,14 +39058,14 @@ function detectDotnetFormat(cwd) {
|
|
|
39005
39058
|
}
|
|
39006
39059
|
}
|
|
39007
39060
|
function detectCppcheck(cwd) {
|
|
39008
|
-
if (
|
|
39061
|
+
if (fs11.existsSync(path21.join(cwd, "CMakeLists.txt"))) {
|
|
39009
39062
|
return isCommandAvailable("cppcheck");
|
|
39010
39063
|
}
|
|
39011
39064
|
try {
|
|
39012
|
-
const dirsToCheck = [cwd,
|
|
39065
|
+
const dirsToCheck = [cwd, path21.join(cwd, "src")];
|
|
39013
39066
|
const hasCpp = dirsToCheck.some((dir) => {
|
|
39014
39067
|
try {
|
|
39015
|
-
return
|
|
39068
|
+
return fs11.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
|
|
39016
39069
|
} catch {
|
|
39017
39070
|
return false;
|
|
39018
39071
|
}
|
|
@@ -39023,13 +39076,13 @@ function detectCppcheck(cwd) {
|
|
|
39023
39076
|
}
|
|
39024
39077
|
}
|
|
39025
39078
|
function detectSwiftlint(cwd) {
|
|
39026
|
-
return
|
|
39079
|
+
return fs11.existsSync(path21.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
|
|
39027
39080
|
}
|
|
39028
39081
|
function detectDartAnalyze(cwd) {
|
|
39029
|
-
return
|
|
39082
|
+
return fs11.existsSync(path21.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
39030
39083
|
}
|
|
39031
39084
|
function detectRubocop(cwd) {
|
|
39032
|
-
return (
|
|
39085
|
+
return (fs11.existsSync(path21.join(cwd, "Gemfile")) || fs11.existsSync(path21.join(cwd, "gems.rb")) || fs11.existsSync(path21.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
|
|
39033
39086
|
}
|
|
39034
39087
|
function detectAdditionalLinter(cwd) {
|
|
39035
39088
|
if (detectRuff(cwd))
|
|
@@ -39057,10 +39110,10 @@ function detectAdditionalLinter(cwd) {
|
|
|
39057
39110
|
function findBinInAncestors(startDir, binName) {
|
|
39058
39111
|
let dir = startDir;
|
|
39059
39112
|
while (true) {
|
|
39060
|
-
const candidate =
|
|
39061
|
-
if (
|
|
39113
|
+
const candidate = path21.join(dir, "node_modules", ".bin", binName);
|
|
39114
|
+
if (fs11.existsSync(candidate))
|
|
39062
39115
|
return candidate;
|
|
39063
|
-
const parent =
|
|
39116
|
+
const parent = path21.dirname(dir);
|
|
39064
39117
|
if (parent === dir)
|
|
39065
39118
|
break;
|
|
39066
39119
|
dir = parent;
|
|
@@ -39069,11 +39122,11 @@ function findBinInAncestors(startDir, binName) {
|
|
|
39069
39122
|
}
|
|
39070
39123
|
function findBinInEnvPath(binName) {
|
|
39071
39124
|
const searchPath = process.env.PATH ?? "";
|
|
39072
|
-
for (const dir of searchPath.split(
|
|
39125
|
+
for (const dir of searchPath.split(path21.delimiter)) {
|
|
39073
39126
|
if (!dir)
|
|
39074
39127
|
continue;
|
|
39075
|
-
const candidate =
|
|
39076
|
-
if (
|
|
39128
|
+
const candidate = path21.join(dir, binName);
|
|
39129
|
+
if (fs11.existsSync(candidate))
|
|
39077
39130
|
return candidate;
|
|
39078
39131
|
}
|
|
39079
39132
|
return null;
|
|
@@ -39081,17 +39134,17 @@ function findBinInEnvPath(binName) {
|
|
|
39081
39134
|
async function detectAvailableLinter(directory) {
|
|
39082
39135
|
if (!directory)
|
|
39083
39136
|
return null;
|
|
39084
|
-
if (!
|
|
39137
|
+
if (!fs11.existsSync(directory))
|
|
39085
39138
|
return null;
|
|
39086
39139
|
const projectDir = directory;
|
|
39087
39140
|
const isWindows = process.platform === "win32";
|
|
39088
|
-
const biomeBin = isWindows ?
|
|
39089
|
-
const eslintBin = isWindows ?
|
|
39141
|
+
const biomeBin = isWindows ? path21.join(projectDir, "node_modules", ".bin", "biome.EXE") : path21.join(projectDir, "node_modules", ".bin", "biome");
|
|
39142
|
+
const eslintBin = isWindows ? path21.join(projectDir, "node_modules", ".bin", "eslint.cmd") : path21.join(projectDir, "node_modules", ".bin", "eslint");
|
|
39090
39143
|
const localResult = await _detectAvailableLinter(projectDir, biomeBin, eslintBin);
|
|
39091
39144
|
if (localResult)
|
|
39092
39145
|
return localResult;
|
|
39093
|
-
const biomeAncestor = findBinInAncestors(
|
|
39094
|
-
const eslintAncestor = findBinInAncestors(
|
|
39146
|
+
const biomeAncestor = findBinInAncestors(path21.dirname(projectDir), isWindows ? "biome.EXE" : "biome");
|
|
39147
|
+
const eslintAncestor = findBinInAncestors(path21.dirname(projectDir), isWindows ? "eslint.cmd" : "eslint");
|
|
39095
39148
|
if (biomeAncestor || eslintAncestor) {
|
|
39096
39149
|
return _detectAvailableLinter(projectDir, biomeAncestor ?? biomeBin, eslintAncestor ?? eslintBin);
|
|
39097
39150
|
}
|
|
@@ -39114,7 +39167,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
|
|
|
39114
39167
|
const result = await Promise.race([biomeExit, timeout]);
|
|
39115
39168
|
if (result === "timeout") {
|
|
39116
39169
|
biomeProc.kill();
|
|
39117
|
-
} else if (biomeProc.exitCode === 0 &&
|
|
39170
|
+
} else if (biomeProc.exitCode === 0 && fs11.existsSync(biomeBin)) {
|
|
39118
39171
|
return "biome";
|
|
39119
39172
|
}
|
|
39120
39173
|
} catch {}
|
|
@@ -39128,7 +39181,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
|
|
|
39128
39181
|
const result = await Promise.race([eslintExit, timeout]);
|
|
39129
39182
|
if (result === "timeout") {
|
|
39130
39183
|
eslintProc.kill();
|
|
39131
|
-
} else if (eslintProc.exitCode === 0 &&
|
|
39184
|
+
} else if (eslintProc.exitCode === 0 && fs11.existsSync(eslintBin)) {
|
|
39132
39185
|
return "eslint";
|
|
39133
39186
|
}
|
|
39134
39187
|
} catch {}
|
|
@@ -39298,8 +39351,8 @@ For Rust: rustup component add clippy`
|
|
|
39298
39351
|
});
|
|
39299
39352
|
|
|
39300
39353
|
// src/tools/secretscan.ts
|
|
39301
|
-
import * as
|
|
39302
|
-
import * as
|
|
39354
|
+
import * as fs12 from "fs";
|
|
39355
|
+
import * as path22 from "path";
|
|
39303
39356
|
var MAX_FILE_PATH_LENGTH = 500;
|
|
39304
39357
|
var MAX_FILE_SIZE_BYTES = 512 * 1024;
|
|
39305
39358
|
var MAX_FILES_SCANNED = 1000;
|
|
@@ -39526,11 +39579,11 @@ function isGlobOrPathPattern(pattern) {
|
|
|
39526
39579
|
return pattern.includes("/") || pattern.includes("\\") || /[*?[\]{}]/.test(pattern);
|
|
39527
39580
|
}
|
|
39528
39581
|
function loadSecretScanIgnore(scanDir) {
|
|
39529
|
-
const ignorePath =
|
|
39582
|
+
const ignorePath = path22.join(scanDir, ".secretscanignore");
|
|
39530
39583
|
try {
|
|
39531
|
-
if (!
|
|
39584
|
+
if (!fs12.existsSync(ignorePath))
|
|
39532
39585
|
return [];
|
|
39533
|
-
const content =
|
|
39586
|
+
const content = fs12.readFileSync(ignorePath, "utf8");
|
|
39534
39587
|
const patterns = [];
|
|
39535
39588
|
for (const rawLine of content.split(/\r?\n/)) {
|
|
39536
39589
|
const line = rawLine.trim();
|
|
@@ -39549,7 +39602,7 @@ function isExcluded(entry, relPath, exactNames, globPatterns) {
|
|
|
39549
39602
|
if (exactNames.has(entry))
|
|
39550
39603
|
return true;
|
|
39551
39604
|
for (const pattern of globPatterns) {
|
|
39552
|
-
if (
|
|
39605
|
+
if (path22.matchesGlob(relPath, pattern))
|
|
39553
39606
|
return true;
|
|
39554
39607
|
}
|
|
39555
39608
|
return false;
|
|
@@ -39570,7 +39623,7 @@ function validateDirectoryInput(dir) {
|
|
|
39570
39623
|
return null;
|
|
39571
39624
|
}
|
|
39572
39625
|
function isBinaryFile(filePath, buffer) {
|
|
39573
|
-
const ext =
|
|
39626
|
+
const ext = path22.extname(filePath).toLowerCase();
|
|
39574
39627
|
if (DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
|
|
39575
39628
|
return true;
|
|
39576
39629
|
}
|
|
@@ -39645,11 +39698,11 @@ function createRedactedContext(line, findings) {
|
|
|
39645
39698
|
result += line.slice(lastEnd);
|
|
39646
39699
|
return result;
|
|
39647
39700
|
}
|
|
39648
|
-
var O_NOFOLLOW = process.platform !== "win32" ?
|
|
39701
|
+
var O_NOFOLLOW = process.platform !== "win32" ? fs12.constants.O_NOFOLLOW : undefined;
|
|
39649
39702
|
function scanFileForSecrets(filePath) {
|
|
39650
39703
|
const findings = [];
|
|
39651
39704
|
try {
|
|
39652
|
-
const lstat =
|
|
39705
|
+
const lstat = fs12.lstatSync(filePath);
|
|
39653
39706
|
if (lstat.isSymbolicLink()) {
|
|
39654
39707
|
return findings;
|
|
39655
39708
|
}
|
|
@@ -39658,14 +39711,14 @@ function scanFileForSecrets(filePath) {
|
|
|
39658
39711
|
}
|
|
39659
39712
|
let buffer;
|
|
39660
39713
|
if (O_NOFOLLOW !== undefined) {
|
|
39661
|
-
const fd =
|
|
39714
|
+
const fd = fs12.openSync(filePath, "r", O_NOFOLLOW);
|
|
39662
39715
|
try {
|
|
39663
|
-
buffer =
|
|
39716
|
+
buffer = fs12.readFileSync(fd);
|
|
39664
39717
|
} finally {
|
|
39665
|
-
|
|
39718
|
+
fs12.closeSync(fd);
|
|
39666
39719
|
}
|
|
39667
39720
|
} else {
|
|
39668
|
-
buffer =
|
|
39721
|
+
buffer = fs12.readFileSync(filePath);
|
|
39669
39722
|
}
|
|
39670
39723
|
if (isBinaryFile(filePath, buffer)) {
|
|
39671
39724
|
return findings;
|
|
@@ -39707,9 +39760,9 @@ function isSymlinkLoop(realPath, visited) {
|
|
|
39707
39760
|
return false;
|
|
39708
39761
|
}
|
|
39709
39762
|
function isPathWithinScope(realPath, scanDir) {
|
|
39710
|
-
const resolvedScanDir =
|
|
39711
|
-
const resolvedRealPath =
|
|
39712
|
-
return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir +
|
|
39763
|
+
const resolvedScanDir = path22.resolve(scanDir);
|
|
39764
|
+
const resolvedRealPath = path22.resolve(realPath);
|
|
39765
|
+
return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir + path22.sep) || resolvedRealPath.startsWith(`${resolvedScanDir}/`) || resolvedRealPath.startsWith(`${resolvedScanDir}\\`);
|
|
39713
39766
|
}
|
|
39714
39767
|
function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, stats = {
|
|
39715
39768
|
skippedDirs: 0,
|
|
@@ -39720,7 +39773,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
39720
39773
|
const files = [];
|
|
39721
39774
|
let entries;
|
|
39722
39775
|
try {
|
|
39723
|
-
entries =
|
|
39776
|
+
entries = fs12.readdirSync(dir);
|
|
39724
39777
|
} catch {
|
|
39725
39778
|
stats.fileErrors++;
|
|
39726
39779
|
return files;
|
|
@@ -39735,15 +39788,15 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
39735
39788
|
return a.localeCompare(b);
|
|
39736
39789
|
});
|
|
39737
39790
|
for (const entry of entries) {
|
|
39738
|
-
const fullPath =
|
|
39739
|
-
const relPath =
|
|
39791
|
+
const fullPath = path22.join(dir, entry);
|
|
39792
|
+
const relPath = path22.relative(scanDir, fullPath).replace(/\\/g, "/");
|
|
39740
39793
|
if (isExcluded(entry, relPath, excludeExact, excludeGlobs)) {
|
|
39741
39794
|
stats.skippedDirs++;
|
|
39742
39795
|
continue;
|
|
39743
39796
|
}
|
|
39744
39797
|
let lstat;
|
|
39745
39798
|
try {
|
|
39746
|
-
lstat =
|
|
39799
|
+
lstat = fs12.lstatSync(fullPath);
|
|
39747
39800
|
} catch {
|
|
39748
39801
|
stats.fileErrors++;
|
|
39749
39802
|
continue;
|
|
@@ -39755,7 +39808,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
39755
39808
|
if (lstat.isDirectory()) {
|
|
39756
39809
|
let realPath;
|
|
39757
39810
|
try {
|
|
39758
|
-
realPath =
|
|
39811
|
+
realPath = fs12.realpathSync(fullPath);
|
|
39759
39812
|
} catch {
|
|
39760
39813
|
stats.fileErrors++;
|
|
39761
39814
|
continue;
|
|
@@ -39771,7 +39824,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
39771
39824
|
const subFiles = findScannableFiles(fullPath, excludeExact, excludeGlobs, scanDir, visited, stats);
|
|
39772
39825
|
files.push(...subFiles);
|
|
39773
39826
|
} else if (lstat.isFile()) {
|
|
39774
|
-
const ext =
|
|
39827
|
+
const ext = path22.extname(fullPath).toLowerCase();
|
|
39775
39828
|
if (!DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
|
|
39776
39829
|
files.push(fullPath);
|
|
39777
39830
|
} else {
|
|
@@ -39837,15 +39890,15 @@ var secretscan = createSwarmTool({
|
|
|
39837
39890
|
}
|
|
39838
39891
|
}
|
|
39839
39892
|
try {
|
|
39840
|
-
const _scanDirRaw =
|
|
39893
|
+
const _scanDirRaw = path22.resolve(directory);
|
|
39841
39894
|
const scanDir = (() => {
|
|
39842
39895
|
try {
|
|
39843
|
-
return
|
|
39896
|
+
return fs12.realpathSync(_scanDirRaw);
|
|
39844
39897
|
} catch {
|
|
39845
39898
|
return _scanDirRaw;
|
|
39846
39899
|
}
|
|
39847
39900
|
})();
|
|
39848
|
-
if (!
|
|
39901
|
+
if (!fs12.existsSync(scanDir)) {
|
|
39849
39902
|
const errorResult = {
|
|
39850
39903
|
error: "directory not found",
|
|
39851
39904
|
scan_dir: directory,
|
|
@@ -39856,7 +39909,7 @@ var secretscan = createSwarmTool({
|
|
|
39856
39909
|
};
|
|
39857
39910
|
return JSON.stringify(errorResult, null, 2);
|
|
39858
39911
|
}
|
|
39859
|
-
const dirStat =
|
|
39912
|
+
const dirStat = fs12.statSync(scanDir);
|
|
39860
39913
|
if (!dirStat.isDirectory()) {
|
|
39861
39914
|
const errorResult = {
|
|
39862
39915
|
error: "target must be a directory, not a file",
|
|
@@ -39907,7 +39960,7 @@ var secretscan = createSwarmTool({
|
|
|
39907
39960
|
break;
|
|
39908
39961
|
const fileFindings = scanFileForSecrets(filePath);
|
|
39909
39962
|
try {
|
|
39910
|
-
const stat2 =
|
|
39963
|
+
const stat2 = fs12.statSync(filePath);
|
|
39911
39964
|
if (stat2.size > MAX_FILE_SIZE_BYTES) {
|
|
39912
39965
|
skippedFiles++;
|
|
39913
39966
|
continue;
|
|
@@ -39994,12 +40047,12 @@ async function runSecretscan(directory) {
|
|
|
39994
40047
|
}
|
|
39995
40048
|
|
|
39996
40049
|
// src/tools/test-runner.ts
|
|
39997
|
-
import * as
|
|
39998
|
-
import * as
|
|
40050
|
+
import * as fs16 from "fs";
|
|
40051
|
+
import * as path26 from "path";
|
|
39999
40052
|
|
|
40000
40053
|
// src/test-impact/analyzer.ts
|
|
40001
|
-
import
|
|
40002
|
-
import
|
|
40054
|
+
import fs13 from "fs";
|
|
40055
|
+
import path23 from "path";
|
|
40003
40056
|
var IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
40004
40057
|
var IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
40005
40058
|
var IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
@@ -40010,7 +40063,7 @@ function normalizePath(p) {
|
|
|
40010
40063
|
function isCacheStale(impactMap, generatedAtMs) {
|
|
40011
40064
|
for (const sourcePath of Object.keys(impactMap)) {
|
|
40012
40065
|
try {
|
|
40013
|
-
const stat2 =
|
|
40066
|
+
const stat2 = fs13.statSync(sourcePath);
|
|
40014
40067
|
if (stat2.mtimeMs > generatedAtMs) {
|
|
40015
40068
|
return true;
|
|
40016
40069
|
}
|
|
@@ -40024,15 +40077,15 @@ function resolveRelativeImport(fromDir, importPath) {
|
|
|
40024
40077
|
if (!importPath.startsWith(".")) {
|
|
40025
40078
|
return null;
|
|
40026
40079
|
}
|
|
40027
|
-
const resolved =
|
|
40028
|
-
if (
|
|
40029
|
-
if (
|
|
40080
|
+
const resolved = path23.resolve(fromDir, importPath);
|
|
40081
|
+
if (path23.extname(resolved)) {
|
|
40082
|
+
if (fs13.existsSync(resolved) && fs13.statSync(resolved).isFile()) {
|
|
40030
40083
|
return normalizePath(resolved);
|
|
40031
40084
|
}
|
|
40032
40085
|
} else {
|
|
40033
40086
|
for (const ext of EXTENSIONS_TO_TRY) {
|
|
40034
40087
|
const withExt = resolved + ext;
|
|
40035
|
-
if (
|
|
40088
|
+
if (fs13.existsSync(withExt) && fs13.statSync(withExt).isFile()) {
|
|
40036
40089
|
return normalizePath(withExt);
|
|
40037
40090
|
}
|
|
40038
40091
|
}
|
|
@@ -40051,13 +40104,13 @@ function findTestFilesSync(cwd) {
|
|
|
40051
40104
|
function walk(dir, visitedInodes) {
|
|
40052
40105
|
let entries;
|
|
40053
40106
|
try {
|
|
40054
|
-
entries =
|
|
40107
|
+
entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
40055
40108
|
} catch {
|
|
40056
40109
|
return;
|
|
40057
40110
|
}
|
|
40058
40111
|
let dirInode;
|
|
40059
40112
|
try {
|
|
40060
|
-
dirInode =
|
|
40113
|
+
dirInode = fs13.statSync(dir).ino;
|
|
40061
40114
|
} catch {
|
|
40062
40115
|
return;
|
|
40063
40116
|
}
|
|
@@ -40070,12 +40123,12 @@ function findTestFilesSync(cwd) {
|
|
|
40070
40123
|
for (const entry of entries) {
|
|
40071
40124
|
if (entry.isDirectory()) {
|
|
40072
40125
|
if (!skipDirs.has(entry.name)) {
|
|
40073
|
-
walk(
|
|
40126
|
+
walk(path23.join(dir, entry.name), visitedInodes);
|
|
40074
40127
|
}
|
|
40075
40128
|
} else if (entry.isFile()) {
|
|
40076
40129
|
const name = entry.name;
|
|
40077
40130
|
if (/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(name) || dir.includes("__tests__") && /\.(ts|tsx|js|jsx)$/.test(name)) {
|
|
40078
|
-
testFiles.push(normalizePath(
|
|
40131
|
+
testFiles.push(normalizePath(path23.join(dir, entry.name)));
|
|
40079
40132
|
}
|
|
40080
40133
|
}
|
|
40081
40134
|
}
|
|
@@ -40105,7 +40158,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
40105
40158
|
for (const testFile of testFiles) {
|
|
40106
40159
|
let content;
|
|
40107
40160
|
try {
|
|
40108
|
-
content =
|
|
40161
|
+
content = fs13.readFileSync(testFile, "utf-8");
|
|
40109
40162
|
} catch {
|
|
40110
40163
|
continue;
|
|
40111
40164
|
}
|
|
@@ -40113,7 +40166,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
40113
40166
|
continue;
|
|
40114
40167
|
}
|
|
40115
40168
|
const imports = extractImports(content);
|
|
40116
|
-
const testDir =
|
|
40169
|
+
const testDir = path23.dirname(testFile);
|
|
40117
40170
|
for (const importPath of imports) {
|
|
40118
40171
|
const resolvedSource = resolveRelativeImport(testDir, importPath);
|
|
40119
40172
|
if (resolvedSource === null) {
|
|
@@ -40135,10 +40188,10 @@ async function buildImpactMap(cwd) {
|
|
|
40135
40188
|
return impactMap;
|
|
40136
40189
|
}
|
|
40137
40190
|
async function loadImpactMap(cwd) {
|
|
40138
|
-
const cachePath =
|
|
40139
|
-
if (
|
|
40191
|
+
const cachePath = path23.join(cwd, ".swarm", "cache", "impact-map.json");
|
|
40192
|
+
if (fs13.existsSync(cachePath)) {
|
|
40140
40193
|
try {
|
|
40141
|
-
const content =
|
|
40194
|
+
const content = fs13.readFileSync(cachePath, "utf-8");
|
|
40142
40195
|
const data = JSON.parse(content);
|
|
40143
40196
|
const map3 = data.map;
|
|
40144
40197
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
@@ -40150,17 +40203,17 @@ async function loadImpactMap(cwd) {
|
|
|
40150
40203
|
return buildImpactMap(cwd);
|
|
40151
40204
|
}
|
|
40152
40205
|
async function saveImpactMap(cwd, impactMap) {
|
|
40153
|
-
const cacheDir =
|
|
40154
|
-
const cachePath =
|
|
40155
|
-
if (!
|
|
40156
|
-
|
|
40206
|
+
const cacheDir = path23.join(cwd, ".swarm", "cache");
|
|
40207
|
+
const cachePath = path23.join(cacheDir, "impact-map.json");
|
|
40208
|
+
if (!fs13.existsSync(cacheDir)) {
|
|
40209
|
+
fs13.mkdirSync(cacheDir, { recursive: true });
|
|
40157
40210
|
}
|
|
40158
40211
|
const data = {
|
|
40159
40212
|
generatedAt: new Date().toISOString(),
|
|
40160
40213
|
fileCount: Object.keys(impactMap).length,
|
|
40161
40214
|
map: impactMap
|
|
40162
40215
|
};
|
|
40163
|
-
|
|
40216
|
+
fs13.writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
|
|
40164
40217
|
}
|
|
40165
40218
|
async function analyzeImpact(changedFiles, cwd) {
|
|
40166
40219
|
if (!Array.isArray(changedFiles)) {
|
|
@@ -40177,7 +40230,7 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
40177
40230
|
const impactedTestsSet = new Set;
|
|
40178
40231
|
const untestedFiles = [];
|
|
40179
40232
|
for (const changedFile of validFiles) {
|
|
40180
|
-
const normalizedChanged = normalizePath(
|
|
40233
|
+
const normalizedChanged = normalizePath(path23.resolve(changedFile));
|
|
40181
40234
|
const tests = impactMap[normalizedChanged];
|
|
40182
40235
|
if (tests && tests.length > 0) {
|
|
40183
40236
|
for (const test of tests) {
|
|
@@ -40423,14 +40476,14 @@ function detectFlakyTests(allHistory) {
|
|
|
40423
40476
|
}
|
|
40424
40477
|
|
|
40425
40478
|
// src/test-impact/history-store.ts
|
|
40426
|
-
import
|
|
40427
|
-
import
|
|
40479
|
+
import fs14 from "fs";
|
|
40480
|
+
import path24 from "path";
|
|
40428
40481
|
var MAX_HISTORY_PER_TEST = 20;
|
|
40429
40482
|
var MAX_ERROR_LENGTH = 500;
|
|
40430
40483
|
var MAX_STACK_LENGTH = 200;
|
|
40431
40484
|
var MAX_CHANGED_FILES = 50;
|
|
40432
40485
|
function getHistoryPath(workingDir) {
|
|
40433
|
-
return
|
|
40486
|
+
return path24.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
|
|
40434
40487
|
}
|
|
40435
40488
|
function sanitizeErrorMessage(errorMessage) {
|
|
40436
40489
|
if (errorMessage === undefined) {
|
|
@@ -40490,9 +40543,9 @@ function appendTestRun(record3, workingDir) {
|
|
|
40490
40543
|
changedFiles: sanitizeChangedFiles(record3.changedFiles || [])
|
|
40491
40544
|
};
|
|
40492
40545
|
const historyPath = getHistoryPath(workingDir);
|
|
40493
|
-
const historyDir =
|
|
40494
|
-
if (!
|
|
40495
|
-
|
|
40546
|
+
const historyDir = path24.dirname(historyPath);
|
|
40547
|
+
if (!fs14.existsSync(historyDir)) {
|
|
40548
|
+
fs14.mkdirSync(historyDir, { recursive: true });
|
|
40496
40549
|
}
|
|
40497
40550
|
const existingRecords = readAllRecords(historyPath);
|
|
40498
40551
|
existingRecords.push(sanitizedRecord);
|
|
@@ -40517,24 +40570,24 @@ function appendTestRun(record3, workingDir) {
|
|
|
40517
40570
|
`) + `
|
|
40518
40571
|
`;
|
|
40519
40572
|
const tempPath = historyPath + ".tmp";
|
|
40520
|
-
|
|
40521
|
-
|
|
40573
|
+
fs14.writeFileSync(tempPath, content, "utf-8");
|
|
40574
|
+
fs14.renameSync(tempPath, historyPath);
|
|
40522
40575
|
} catch (err) {
|
|
40523
40576
|
try {
|
|
40524
40577
|
const tempPath = historyPath + ".tmp";
|
|
40525
|
-
if (
|
|
40526
|
-
|
|
40578
|
+
if (fs14.existsSync(tempPath)) {
|
|
40579
|
+
fs14.unlinkSync(tempPath);
|
|
40527
40580
|
}
|
|
40528
40581
|
} catch {}
|
|
40529
40582
|
throw new Error(`Failed to write test history: ${err instanceof Error ? err.message : String(err)}`);
|
|
40530
40583
|
}
|
|
40531
40584
|
}
|
|
40532
40585
|
function readAllRecords(historyPath) {
|
|
40533
|
-
if (!
|
|
40586
|
+
if (!fs14.existsSync(historyPath)) {
|
|
40534
40587
|
return [];
|
|
40535
40588
|
}
|
|
40536
40589
|
try {
|
|
40537
|
-
const content =
|
|
40590
|
+
const content = fs14.readFileSync(historyPath, "utf-8");
|
|
40538
40591
|
const lines = content.split(`
|
|
40539
40592
|
`);
|
|
40540
40593
|
const records = [];
|
|
@@ -40563,8 +40616,8 @@ function getAllHistory(workingDir) {
|
|
|
40563
40616
|
}
|
|
40564
40617
|
|
|
40565
40618
|
// src/tools/resolve-working-directory.ts
|
|
40566
|
-
import * as
|
|
40567
|
-
import * as
|
|
40619
|
+
import * as fs15 from "fs";
|
|
40620
|
+
import * as path25 from "path";
|
|
40568
40621
|
function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
40569
40622
|
if (workingDirectory == null || workingDirectory === "") {
|
|
40570
40623
|
return { success: true, directory: fallbackDirectory };
|
|
@@ -40584,17 +40637,17 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
40584
40637
|
};
|
|
40585
40638
|
}
|
|
40586
40639
|
}
|
|
40587
|
-
const normalizedDir =
|
|
40588
|
-
const pathParts = normalizedDir.split(
|
|
40640
|
+
const normalizedDir = path25.normalize(workingDirectory);
|
|
40641
|
+
const pathParts = normalizedDir.split(path25.sep);
|
|
40589
40642
|
if (pathParts.includes("..")) {
|
|
40590
40643
|
return {
|
|
40591
40644
|
success: false,
|
|
40592
40645
|
message: "Invalid working_directory: path traversal sequences (..) are not allowed"
|
|
40593
40646
|
};
|
|
40594
40647
|
}
|
|
40595
|
-
const resolvedDir =
|
|
40648
|
+
const resolvedDir = path25.resolve(normalizedDir);
|
|
40596
40649
|
try {
|
|
40597
|
-
const realPath =
|
|
40650
|
+
const realPath = fs15.realpathSync(resolvedDir);
|
|
40598
40651
|
return { success: true, directory: realPath };
|
|
40599
40652
|
} catch {
|
|
40600
40653
|
return {
|
|
@@ -40675,19 +40728,19 @@ function hasDevDependency(devDeps, ...patterns) {
|
|
|
40675
40728
|
return hasPackageJsonDependency(devDeps, ...patterns);
|
|
40676
40729
|
}
|
|
40677
40730
|
function detectGoTest(cwd) {
|
|
40678
|
-
return
|
|
40731
|
+
return fs16.existsSync(path26.join(cwd, "go.mod")) && isCommandAvailable("go");
|
|
40679
40732
|
}
|
|
40680
40733
|
function detectJavaMaven(cwd) {
|
|
40681
|
-
return
|
|
40734
|
+
return fs16.existsSync(path26.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
|
|
40682
40735
|
}
|
|
40683
40736
|
function detectGradle(cwd) {
|
|
40684
|
-
const hasBuildFile =
|
|
40685
|
-
const hasGradlew =
|
|
40737
|
+
const hasBuildFile = fs16.existsSync(path26.join(cwd, "build.gradle")) || fs16.existsSync(path26.join(cwd, "build.gradle.kts"));
|
|
40738
|
+
const hasGradlew = fs16.existsSync(path26.join(cwd, "gradlew")) || fs16.existsSync(path26.join(cwd, "gradlew.bat"));
|
|
40686
40739
|
return hasBuildFile && (hasGradlew || isCommandAvailable("gradle"));
|
|
40687
40740
|
}
|
|
40688
40741
|
function detectDotnetTest(cwd) {
|
|
40689
40742
|
try {
|
|
40690
|
-
const files =
|
|
40743
|
+
const files = fs16.readdirSync(cwd);
|
|
40691
40744
|
const hasCsproj = files.some((f) => f.endsWith(".csproj"));
|
|
40692
40745
|
return hasCsproj && isCommandAvailable("dotnet");
|
|
40693
40746
|
} catch {
|
|
@@ -40695,32 +40748,32 @@ function detectDotnetTest(cwd) {
|
|
|
40695
40748
|
}
|
|
40696
40749
|
}
|
|
40697
40750
|
function detectCTest(cwd) {
|
|
40698
|
-
const hasSource =
|
|
40699
|
-
const hasBuildCache =
|
|
40751
|
+
const hasSource = fs16.existsSync(path26.join(cwd, "CMakeLists.txt"));
|
|
40752
|
+
const hasBuildCache = fs16.existsSync(path26.join(cwd, "CMakeCache.txt")) || fs16.existsSync(path26.join(cwd, "build", "CMakeCache.txt"));
|
|
40700
40753
|
return (hasSource || hasBuildCache) && isCommandAvailable("ctest");
|
|
40701
40754
|
}
|
|
40702
40755
|
function detectSwiftTest(cwd) {
|
|
40703
|
-
return
|
|
40756
|
+
return fs16.existsSync(path26.join(cwd, "Package.swift")) && isCommandAvailable("swift");
|
|
40704
40757
|
}
|
|
40705
40758
|
function detectDartTest(cwd) {
|
|
40706
|
-
return
|
|
40759
|
+
return fs16.existsSync(path26.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
40707
40760
|
}
|
|
40708
40761
|
function detectRSpec(cwd) {
|
|
40709
|
-
const hasRSpecFile =
|
|
40710
|
-
const hasGemfile =
|
|
40711
|
-
const hasSpecDir =
|
|
40762
|
+
const hasRSpecFile = fs16.existsSync(path26.join(cwd, ".rspec"));
|
|
40763
|
+
const hasGemfile = fs16.existsSync(path26.join(cwd, "Gemfile"));
|
|
40764
|
+
const hasSpecDir = fs16.existsSync(path26.join(cwd, "spec"));
|
|
40712
40765
|
const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
|
|
40713
40766
|
return hasRSpec && (isCommandAvailable("bundle") || isCommandAvailable("rspec"));
|
|
40714
40767
|
}
|
|
40715
40768
|
function detectMinitest(cwd) {
|
|
40716
|
-
return
|
|
40769
|
+
return fs16.existsSync(path26.join(cwd, "test")) && (fs16.existsSync(path26.join(cwd, "Gemfile")) || fs16.existsSync(path26.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
|
|
40717
40770
|
}
|
|
40718
40771
|
async function detectTestFramework(cwd) {
|
|
40719
40772
|
const baseDir = cwd;
|
|
40720
40773
|
try {
|
|
40721
|
-
const packageJsonPath =
|
|
40722
|
-
if (
|
|
40723
|
-
const content =
|
|
40774
|
+
const packageJsonPath = path26.join(baseDir, "package.json");
|
|
40775
|
+
if (fs16.existsSync(packageJsonPath)) {
|
|
40776
|
+
const content = fs16.readFileSync(packageJsonPath, "utf-8");
|
|
40724
40777
|
const pkg = JSON.parse(content);
|
|
40725
40778
|
const _deps = pkg.dependencies || {};
|
|
40726
40779
|
const devDeps = pkg.devDependencies || {};
|
|
@@ -40739,38 +40792,38 @@ async function detectTestFramework(cwd) {
|
|
|
40739
40792
|
return "jest";
|
|
40740
40793
|
if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
|
|
40741
40794
|
return "mocha";
|
|
40742
|
-
if (
|
|
40795
|
+
if (fs16.existsSync(path26.join(baseDir, "bun.lockb")) || fs16.existsSync(path26.join(baseDir, "bun.lock"))) {
|
|
40743
40796
|
if (scripts.test?.includes("bun"))
|
|
40744
40797
|
return "bun";
|
|
40745
40798
|
}
|
|
40746
40799
|
}
|
|
40747
40800
|
} catch {}
|
|
40748
40801
|
try {
|
|
40749
|
-
const pyprojectTomlPath =
|
|
40750
|
-
const setupCfgPath =
|
|
40751
|
-
const requirementsTxtPath =
|
|
40752
|
-
if (
|
|
40753
|
-
const content =
|
|
40802
|
+
const pyprojectTomlPath = path26.join(baseDir, "pyproject.toml");
|
|
40803
|
+
const setupCfgPath = path26.join(baseDir, "setup.cfg");
|
|
40804
|
+
const requirementsTxtPath = path26.join(baseDir, "requirements.txt");
|
|
40805
|
+
if (fs16.existsSync(pyprojectTomlPath)) {
|
|
40806
|
+
const content = fs16.readFileSync(pyprojectTomlPath, "utf-8");
|
|
40754
40807
|
if (content.includes("[tool.pytest"))
|
|
40755
40808
|
return "pytest";
|
|
40756
40809
|
if (content.includes("pytest"))
|
|
40757
40810
|
return "pytest";
|
|
40758
40811
|
}
|
|
40759
|
-
if (
|
|
40760
|
-
const content =
|
|
40812
|
+
if (fs16.existsSync(setupCfgPath)) {
|
|
40813
|
+
const content = fs16.readFileSync(setupCfgPath, "utf-8");
|
|
40761
40814
|
if (content.includes("[pytest]"))
|
|
40762
40815
|
return "pytest";
|
|
40763
40816
|
}
|
|
40764
|
-
if (
|
|
40765
|
-
const content =
|
|
40817
|
+
if (fs16.existsSync(requirementsTxtPath)) {
|
|
40818
|
+
const content = fs16.readFileSync(requirementsTxtPath, "utf-8");
|
|
40766
40819
|
if (content.includes("pytest"))
|
|
40767
40820
|
return "pytest";
|
|
40768
40821
|
}
|
|
40769
40822
|
} catch {}
|
|
40770
40823
|
try {
|
|
40771
|
-
const cargoTomlPath =
|
|
40772
|
-
if (
|
|
40773
|
-
const content =
|
|
40824
|
+
const cargoTomlPath = path26.join(baseDir, "Cargo.toml");
|
|
40825
|
+
if (fs16.existsSync(cargoTomlPath)) {
|
|
40826
|
+
const content = fs16.readFileSync(cargoTomlPath, "utf-8");
|
|
40774
40827
|
if (content.includes("[dev-dependencies]")) {
|
|
40775
40828
|
if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
|
|
40776
40829
|
return "cargo";
|
|
@@ -40779,10 +40832,10 @@ async function detectTestFramework(cwd) {
|
|
|
40779
40832
|
}
|
|
40780
40833
|
} catch {}
|
|
40781
40834
|
try {
|
|
40782
|
-
const pesterConfigPath =
|
|
40783
|
-
const pesterConfigJsonPath =
|
|
40784
|
-
const pesterPs1Path =
|
|
40785
|
-
if (
|
|
40835
|
+
const pesterConfigPath = path26.join(baseDir, "pester.config.ps1");
|
|
40836
|
+
const pesterConfigJsonPath = path26.join(baseDir, "pester.config.ps1.json");
|
|
40837
|
+
const pesterPs1Path = path26.join(baseDir, "tests.ps1");
|
|
40838
|
+
if (fs16.existsSync(pesterConfigPath) || fs16.existsSync(pesterConfigJsonPath) || fs16.existsSync(pesterPs1Path)) {
|
|
40786
40839
|
return "pester";
|
|
40787
40840
|
}
|
|
40788
40841
|
} catch {}
|
|
@@ -40833,8 +40886,8 @@ function getTestFilesFromConvention(sourceFiles) {
|
|
|
40833
40886
|
const testFiles = [];
|
|
40834
40887
|
for (const file3 of sourceFiles) {
|
|
40835
40888
|
const normalizedPath = file3.replace(/\\/g, "/");
|
|
40836
|
-
const basename4 =
|
|
40837
|
-
const dirname10 =
|
|
40889
|
+
const basename4 = path26.basename(file3);
|
|
40890
|
+
const dirname10 = path26.dirname(file3);
|
|
40838
40891
|
if (hasCompoundTestExtension(basename4) || basename4.includes(".spec.") || basename4.includes(".test.") || normalizedPath.includes("/__tests__/") || normalizedPath.includes("/tests/") || normalizedPath.includes("/test/")) {
|
|
40839
40892
|
if (!testFiles.includes(file3)) {
|
|
40840
40893
|
testFiles.push(file3);
|
|
@@ -40843,16 +40896,16 @@ function getTestFilesFromConvention(sourceFiles) {
|
|
|
40843
40896
|
}
|
|
40844
40897
|
for (const _pattern of TEST_PATTERNS) {
|
|
40845
40898
|
const nameWithoutExt = basename4.replace(/\.[^.]+$/, "");
|
|
40846
|
-
const ext =
|
|
40899
|
+
const ext = path26.extname(basename4);
|
|
40847
40900
|
const possibleTestFiles = [
|
|
40848
|
-
|
|
40849
|
-
|
|
40850
|
-
|
|
40851
|
-
|
|
40852
|
-
|
|
40901
|
+
path26.join(dirname10, `${nameWithoutExt}.spec${ext}`),
|
|
40902
|
+
path26.join(dirname10, `${nameWithoutExt}.test${ext}`),
|
|
40903
|
+
path26.join(dirname10, "__tests__", `${nameWithoutExt}${ext}`),
|
|
40904
|
+
path26.join(dirname10, "tests", `${nameWithoutExt}${ext}`),
|
|
40905
|
+
path26.join(dirname10, "test", `${nameWithoutExt}${ext}`)
|
|
40853
40906
|
];
|
|
40854
40907
|
for (const testFile of possibleTestFiles) {
|
|
40855
|
-
if (
|
|
40908
|
+
if (fs16.existsSync(testFile) && !testFiles.includes(testFile)) {
|
|
40856
40909
|
testFiles.push(testFile);
|
|
40857
40910
|
}
|
|
40858
40911
|
}
|
|
@@ -40868,8 +40921,8 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40868
40921
|
}
|
|
40869
40922
|
for (const testFile of candidateTestFiles) {
|
|
40870
40923
|
try {
|
|
40871
|
-
const content =
|
|
40872
|
-
const testDir =
|
|
40924
|
+
const content = fs16.readFileSync(testFile, "utf-8");
|
|
40925
|
+
const testDir = path26.dirname(testFile);
|
|
40873
40926
|
const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
40874
40927
|
let match;
|
|
40875
40928
|
match = importRegex.exec(content);
|
|
@@ -40877,8 +40930,8 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40877
40930
|
const importPath = match[1];
|
|
40878
40931
|
let resolvedImport;
|
|
40879
40932
|
if (importPath.startsWith(".")) {
|
|
40880
|
-
resolvedImport =
|
|
40881
|
-
const existingExt =
|
|
40933
|
+
resolvedImport = path26.resolve(testDir, importPath);
|
|
40934
|
+
const existingExt = path26.extname(resolvedImport);
|
|
40882
40935
|
if (!existingExt) {
|
|
40883
40936
|
for (const extToTry of [
|
|
40884
40937
|
".ts",
|
|
@@ -40889,7 +40942,7 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40889
40942
|
".cjs"
|
|
40890
40943
|
]) {
|
|
40891
40944
|
const withExt = resolvedImport + extToTry;
|
|
40892
|
-
if (sourceFiles.includes(withExt) ||
|
|
40945
|
+
if (sourceFiles.includes(withExt) || fs16.existsSync(withExt)) {
|
|
40893
40946
|
resolvedImport = withExt;
|
|
40894
40947
|
break;
|
|
40895
40948
|
}
|
|
@@ -40898,12 +40951,12 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40898
40951
|
} else {
|
|
40899
40952
|
continue;
|
|
40900
40953
|
}
|
|
40901
|
-
const importBasename =
|
|
40902
|
-
const importDir =
|
|
40954
|
+
const importBasename = path26.basename(resolvedImport, path26.extname(resolvedImport));
|
|
40955
|
+
const importDir = path26.dirname(resolvedImport);
|
|
40903
40956
|
for (const sourceFile of sourceFiles) {
|
|
40904
|
-
const sourceDir =
|
|
40905
|
-
const sourceBasename =
|
|
40906
|
-
const isRelatedDir = importDir === sourceDir || importDir ===
|
|
40957
|
+
const sourceDir = path26.dirname(sourceFile);
|
|
40958
|
+
const sourceBasename = path26.basename(sourceFile, path26.extname(sourceFile));
|
|
40959
|
+
const isRelatedDir = importDir === sourceDir || importDir === path26.join(sourceDir, "__tests__") || importDir === path26.join(sourceDir, "tests") || importDir === path26.join(sourceDir, "test");
|
|
40907
40960
|
if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
|
|
40908
40961
|
if (!testFiles.includes(testFile)) {
|
|
40909
40962
|
testFiles.push(testFile);
|
|
@@ -40918,8 +40971,8 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40918
40971
|
while (match !== null) {
|
|
40919
40972
|
const importPath = match[1];
|
|
40920
40973
|
if (importPath.startsWith(".")) {
|
|
40921
|
-
let resolvedImport =
|
|
40922
|
-
const existingExt =
|
|
40974
|
+
let resolvedImport = path26.resolve(testDir, importPath);
|
|
40975
|
+
const existingExt = path26.extname(resolvedImport);
|
|
40923
40976
|
if (!existingExt) {
|
|
40924
40977
|
for (const extToTry of [
|
|
40925
40978
|
".ts",
|
|
@@ -40930,18 +40983,18 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
40930
40983
|
".cjs"
|
|
40931
40984
|
]) {
|
|
40932
40985
|
const withExt = resolvedImport + extToTry;
|
|
40933
|
-
if (sourceFiles.includes(withExt) ||
|
|
40986
|
+
if (sourceFiles.includes(withExt) || fs16.existsSync(withExt)) {
|
|
40934
40987
|
resolvedImport = withExt;
|
|
40935
40988
|
break;
|
|
40936
40989
|
}
|
|
40937
40990
|
}
|
|
40938
40991
|
}
|
|
40939
|
-
const importDir =
|
|
40940
|
-
const importBasename =
|
|
40992
|
+
const importDir = path26.dirname(resolvedImport);
|
|
40993
|
+
const importBasename = path26.basename(resolvedImport, path26.extname(resolvedImport));
|
|
40941
40994
|
for (const sourceFile of sourceFiles) {
|
|
40942
|
-
const sourceDir =
|
|
40943
|
-
const sourceBasename =
|
|
40944
|
-
const isRelatedDir = importDir === sourceDir || importDir ===
|
|
40995
|
+
const sourceDir = path26.dirname(sourceFile);
|
|
40996
|
+
const sourceBasename = path26.basename(sourceFile, path26.extname(sourceFile));
|
|
40997
|
+
const isRelatedDir = importDir === sourceDir || importDir === path26.join(sourceDir, "__tests__") || importDir === path26.join(sourceDir, "tests") || importDir === path26.join(sourceDir, "test");
|
|
40945
40998
|
if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
|
|
40946
40999
|
if (!testFiles.includes(testFile)) {
|
|
40947
41000
|
testFiles.push(testFile);
|
|
@@ -41026,8 +41079,8 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
41026
41079
|
return ["mvn", "test"];
|
|
41027
41080
|
case "gradle": {
|
|
41028
41081
|
const isWindows = process.platform === "win32";
|
|
41029
|
-
const hasGradlewBat =
|
|
41030
|
-
const hasGradlew =
|
|
41082
|
+
const hasGradlewBat = fs16.existsSync(path26.join(baseDir, "gradlew.bat"));
|
|
41083
|
+
const hasGradlew = fs16.existsSync(path26.join(baseDir, "gradlew"));
|
|
41031
41084
|
if (hasGradlewBat && isWindows)
|
|
41032
41085
|
return ["gradlew.bat", "test"];
|
|
41033
41086
|
if (hasGradlew)
|
|
@@ -41044,7 +41097,7 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
41044
41097
|
"cmake-build-release",
|
|
41045
41098
|
"out"
|
|
41046
41099
|
];
|
|
41047
|
-
const actualBuildDir = buildDirCandidates.find((d) =>
|
|
41100
|
+
const actualBuildDir = buildDirCandidates.find((d) => fs16.existsSync(path26.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
|
|
41048
41101
|
return ["ctest", "--test-dir", actualBuildDir];
|
|
41049
41102
|
}
|
|
41050
41103
|
case "swift-test":
|
|
@@ -41647,7 +41700,7 @@ var test_runner = createSwarmTool({
|
|
|
41647
41700
|
let effectiveScope = scope;
|
|
41648
41701
|
if (scope === "all") {} else if (scope === "convention") {
|
|
41649
41702
|
const sourceFiles = args.files.filter((f) => {
|
|
41650
|
-
const ext =
|
|
41703
|
+
const ext = path26.extname(f).toLowerCase();
|
|
41651
41704
|
return SOURCE_EXTENSIONS.has(ext);
|
|
41652
41705
|
});
|
|
41653
41706
|
if (sourceFiles.length === 0) {
|
|
@@ -41664,7 +41717,7 @@ var test_runner = createSwarmTool({
|
|
|
41664
41717
|
testFiles = getTestFilesFromConvention(sourceFiles);
|
|
41665
41718
|
} else if (scope === "graph") {
|
|
41666
41719
|
const sourceFiles = args.files.filter((f) => {
|
|
41667
|
-
const ext =
|
|
41720
|
+
const ext = path26.extname(f).toLowerCase();
|
|
41668
41721
|
return SOURCE_EXTENSIONS.has(ext);
|
|
41669
41722
|
});
|
|
41670
41723
|
if (sourceFiles.length === 0) {
|
|
@@ -41688,7 +41741,7 @@ var test_runner = createSwarmTool({
|
|
|
41688
41741
|
}
|
|
41689
41742
|
} else if (scope === "impact") {
|
|
41690
41743
|
const sourceFiles = args.files.filter((f) => {
|
|
41691
|
-
const ext =
|
|
41744
|
+
const ext = path26.extname(f).toLowerCase();
|
|
41692
41745
|
return SOURCE_EXTENSIONS.has(ext);
|
|
41693
41746
|
});
|
|
41694
41747
|
if (sourceFiles.length === 0) {
|
|
@@ -41706,8 +41759,8 @@ var test_runner = createSwarmTool({
|
|
|
41706
41759
|
const impactResult = await analyzeImpact(sourceFiles, workingDir);
|
|
41707
41760
|
if (impactResult.impactedTests.length > 0) {
|
|
41708
41761
|
testFiles = impactResult.impactedTests.map((absPath) => {
|
|
41709
|
-
const relativePath =
|
|
41710
|
-
return
|
|
41762
|
+
const relativePath = path26.relative(workingDir, absPath);
|
|
41763
|
+
return path26.isAbsolute(relativePath) ? absPath : relativePath;
|
|
41711
41764
|
});
|
|
41712
41765
|
} else {
|
|
41713
41766
|
graphFallbackReason = "no impacted tests found via impact analysis, falling back to graph";
|
|
@@ -41800,8 +41853,8 @@ function validateDirectoryPath(dir) {
|
|
|
41800
41853
|
if (dir.includes("..")) {
|
|
41801
41854
|
throw new Error("Directory path must not contain path traversal sequences");
|
|
41802
41855
|
}
|
|
41803
|
-
const normalized =
|
|
41804
|
-
const absolutePath =
|
|
41856
|
+
const normalized = path27.normalize(dir);
|
|
41857
|
+
const absolutePath = path27.isAbsolute(normalized) ? normalized : path27.resolve(normalized);
|
|
41805
41858
|
return absolutePath;
|
|
41806
41859
|
}
|
|
41807
41860
|
function validateTimeout(timeoutMs, defaultValue) {
|
|
@@ -41824,9 +41877,9 @@ function validateTimeout(timeoutMs, defaultValue) {
|
|
|
41824
41877
|
}
|
|
41825
41878
|
function getPackageVersion(dir) {
|
|
41826
41879
|
try {
|
|
41827
|
-
const packagePath =
|
|
41828
|
-
if (
|
|
41829
|
-
const content =
|
|
41880
|
+
const packagePath = path27.join(dir, "package.json");
|
|
41881
|
+
if (fs17.existsSync(packagePath)) {
|
|
41882
|
+
const content = fs17.readFileSync(packagePath, "utf-8");
|
|
41830
41883
|
const pkg = JSON.parse(content);
|
|
41831
41884
|
return pkg.version ?? null;
|
|
41832
41885
|
}
|
|
@@ -41835,9 +41888,9 @@ function getPackageVersion(dir) {
|
|
|
41835
41888
|
}
|
|
41836
41889
|
function getChangelogVersion(dir) {
|
|
41837
41890
|
try {
|
|
41838
|
-
const changelogPath =
|
|
41839
|
-
if (
|
|
41840
|
-
const content =
|
|
41891
|
+
const changelogPath = path27.join(dir, "CHANGELOG.md");
|
|
41892
|
+
if (fs17.existsSync(changelogPath)) {
|
|
41893
|
+
const content = fs17.readFileSync(changelogPath, "utf-8");
|
|
41841
41894
|
const match = content.match(/^##\s*\[?(\d+\.\d+\.\d+)\]?/m);
|
|
41842
41895
|
if (match) {
|
|
41843
41896
|
return match[1];
|
|
@@ -41849,10 +41902,10 @@ function getChangelogVersion(dir) {
|
|
|
41849
41902
|
function getVersionFileVersion(dir) {
|
|
41850
41903
|
const possibleFiles = ["VERSION.txt", "version.txt", "VERSION", "version"];
|
|
41851
41904
|
for (const file3 of possibleFiles) {
|
|
41852
|
-
const filePath =
|
|
41853
|
-
if (
|
|
41905
|
+
const filePath = path27.join(dir, file3);
|
|
41906
|
+
if (fs17.existsSync(filePath)) {
|
|
41854
41907
|
try {
|
|
41855
|
-
const content =
|
|
41908
|
+
const content = fs17.readFileSync(filePath, "utf-8").trim();
|
|
41856
41909
|
const match = content.match(/(\d+\.\d+\.\d+)/);
|
|
41857
41910
|
if (match) {
|
|
41858
41911
|
return match[1];
|
|
@@ -42176,8 +42229,8 @@ async function runEvidenceCheck(dir) {
|
|
|
42176
42229
|
async function runRequirementCoverageCheck(dir, currentPhase) {
|
|
42177
42230
|
const startTime = Date.now();
|
|
42178
42231
|
try {
|
|
42179
|
-
const specPath =
|
|
42180
|
-
if (!
|
|
42232
|
+
const specPath = path27.join(dir, ".swarm", "spec.md");
|
|
42233
|
+
if (!fs17.existsSync(specPath)) {
|
|
42181
42234
|
return {
|
|
42182
42235
|
type: "req_coverage",
|
|
42183
42236
|
status: "skip",
|
|
@@ -42390,9 +42443,9 @@ async function handlePreflightCommand(directory, _args) {
|
|
|
42390
42443
|
return formatPreflightMarkdown(report);
|
|
42391
42444
|
}
|
|
42392
42445
|
// src/knowledge/hive-promoter.ts
|
|
42393
|
-
import * as
|
|
42446
|
+
import * as fs18 from "fs";
|
|
42394
42447
|
import * as os5 from "os";
|
|
42395
|
-
import * as
|
|
42448
|
+
import * as path28 from "path";
|
|
42396
42449
|
var DANGEROUS_PATTERNS = [
|
|
42397
42450
|
[/rm\s+-rf/, "rm\\s+-rf"],
|
|
42398
42451
|
[/:\s*!\s*\|/, ":\\s*!\\s*\\|"],
|
|
@@ -42438,13 +42491,13 @@ function getHiveFilePath() {
|
|
|
42438
42491
|
const home = os5.homedir();
|
|
42439
42492
|
let dataDir;
|
|
42440
42493
|
if (platform === "win32") {
|
|
42441
|
-
dataDir =
|
|
42494
|
+
dataDir = path28.join(process.env.LOCALAPPDATA || path28.join(home, "AppData", "Local"), "opencode-swarm", "Data");
|
|
42442
42495
|
} else if (platform === "darwin") {
|
|
42443
|
-
dataDir =
|
|
42496
|
+
dataDir = path28.join(home, "Library", "Application Support", "opencode-swarm");
|
|
42444
42497
|
} else {
|
|
42445
|
-
dataDir =
|
|
42498
|
+
dataDir = path28.join(process.env.XDG_DATA_HOME || path28.join(home, ".local", "share"), "opencode-swarm");
|
|
42446
42499
|
}
|
|
42447
|
-
return
|
|
42500
|
+
return path28.join(dataDir, "hive-knowledge.jsonl");
|
|
42448
42501
|
}
|
|
42449
42502
|
async function promoteToHive(_directory, lesson, category) {
|
|
42450
42503
|
const trimmed = (lesson ?? "").trim();
|
|
@@ -42456,9 +42509,9 @@ async function promoteToHive(_directory, lesson, category) {
|
|
|
42456
42509
|
throw new Error(`Lesson rejected by validator: ${validation.reason}`);
|
|
42457
42510
|
}
|
|
42458
42511
|
const hivePath = getHiveFilePath();
|
|
42459
|
-
const hiveDir =
|
|
42460
|
-
if (!
|
|
42461
|
-
|
|
42512
|
+
const hiveDir = path28.dirname(hivePath);
|
|
42513
|
+
if (!fs18.existsSync(hiveDir)) {
|
|
42514
|
+
fs18.mkdirSync(hiveDir, { recursive: true });
|
|
42462
42515
|
}
|
|
42463
42516
|
const now = new Date;
|
|
42464
42517
|
const entry = {
|
|
@@ -42472,16 +42525,16 @@ async function promoteToHive(_directory, lesson, category) {
|
|
|
42472
42525
|
promotedAt: now.toISOString(),
|
|
42473
42526
|
retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
|
|
42474
42527
|
};
|
|
42475
|
-
|
|
42528
|
+
fs18.appendFileSync(hivePath, `${JSON.stringify(entry)}
|
|
42476
42529
|
`, "utf-8");
|
|
42477
42530
|
const preview = `${trimmed.slice(0, 50)}${trimmed.length > 50 ? "..." : ""}`;
|
|
42478
42531
|
return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
|
|
42479
42532
|
}
|
|
42480
42533
|
async function promoteFromSwarm(directory, lessonId) {
|
|
42481
|
-
const knowledgePath =
|
|
42534
|
+
const knowledgePath = path28.join(directory, ".swarm", "knowledge.jsonl");
|
|
42482
42535
|
const entries = [];
|
|
42483
|
-
if (
|
|
42484
|
-
const content =
|
|
42536
|
+
if (fs18.existsSync(knowledgePath)) {
|
|
42537
|
+
const content = fs18.readFileSync(knowledgePath, "utf-8");
|
|
42485
42538
|
for (const line of content.split(`
|
|
42486
42539
|
`)) {
|
|
42487
42540
|
const t = line.trim();
|
|
@@ -42505,9 +42558,9 @@ async function promoteFromSwarm(directory, lessonId) {
|
|
|
42505
42558
|
throw new Error(`Lesson rejected by validator: ${validation.reason}`);
|
|
42506
42559
|
}
|
|
42507
42560
|
const hivePath = getHiveFilePath();
|
|
42508
|
-
const hiveDir =
|
|
42509
|
-
if (!
|
|
42510
|
-
|
|
42561
|
+
const hiveDir = path28.dirname(hivePath);
|
|
42562
|
+
if (!fs18.existsSync(hiveDir)) {
|
|
42563
|
+
fs18.mkdirSync(hiveDir, { recursive: true });
|
|
42511
42564
|
}
|
|
42512
42565
|
const now = new Date;
|
|
42513
42566
|
const hiveEntry = {
|
|
@@ -42521,7 +42574,7 @@ async function promoteFromSwarm(directory, lessonId) {
|
|
|
42521
42574
|
promotedAt: now.toISOString(),
|
|
42522
42575
|
retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
|
|
42523
42576
|
};
|
|
42524
|
-
|
|
42577
|
+
fs18.appendFileSync(hivePath, `${JSON.stringify(hiveEntry)}
|
|
42525
42578
|
`, "utf-8");
|
|
42526
42579
|
const preview = `${lessonText.slice(0, 50)}${lessonText.length > 50 ? "..." : ""}`;
|
|
42527
42580
|
return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
|
|
@@ -42579,8 +42632,8 @@ import { createHash as createHash4 } from "crypto";
|
|
|
42579
42632
|
|
|
42580
42633
|
// src/db/project-db.ts
|
|
42581
42634
|
import { Database } from "bun:sqlite";
|
|
42582
|
-
import { existsSync as existsSync16, mkdirSync as
|
|
42583
|
-
import { join as
|
|
42635
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync8 } from "fs";
|
|
42636
|
+
import { join as join23, resolve as resolve11 } from "path";
|
|
42584
42637
|
var MIGRATIONS = [
|
|
42585
42638
|
{
|
|
42586
42639
|
version: 1,
|
|
@@ -42639,7 +42692,7 @@ function runProjectMigrations(db) {
|
|
|
42639
42692
|
}
|
|
42640
42693
|
}
|
|
42641
42694
|
function projectDbPath(directory) {
|
|
42642
|
-
return
|
|
42695
|
+
return join23(resolve11(directory), ".swarm", "swarm.db");
|
|
42643
42696
|
}
|
|
42644
42697
|
function projectDbExists(directory) {
|
|
42645
42698
|
return existsSync16(projectDbPath(directory));
|
|
@@ -42649,9 +42702,9 @@ function getProjectDb(directory) {
|
|
|
42649
42702
|
const existing = _projectDbs.get(key);
|
|
42650
42703
|
if (existing)
|
|
42651
42704
|
return existing;
|
|
42652
|
-
const swarmDir =
|
|
42653
|
-
|
|
42654
|
-
const db = new Database(
|
|
42705
|
+
const swarmDir = join23(key, ".swarm");
|
|
42706
|
+
mkdirSync8(swarmDir, { recursive: true });
|
|
42707
|
+
const db = new Database(join23(swarmDir, "swarm.db"));
|
|
42655
42708
|
db.run("PRAGMA journal_mode = WAL;");
|
|
42656
42709
|
db.run("PRAGMA synchronous = NORMAL;");
|
|
42657
42710
|
db.run("PRAGMA busy_timeout = 5000;");
|
|
@@ -42893,7 +42946,7 @@ async function handleQaGatesCommand(directory, args, sessionID) {
|
|
|
42893
42946
|
}
|
|
42894
42947
|
|
|
42895
42948
|
// src/commands/reset.ts
|
|
42896
|
-
import * as
|
|
42949
|
+
import * as fs19 from "fs";
|
|
42897
42950
|
|
|
42898
42951
|
// src/background/manager.ts
|
|
42899
42952
|
init_utils();
|
|
@@ -43594,8 +43647,8 @@ async function handleResetCommand(directory, args) {
|
|
|
43594
43647
|
for (const filename of filesToReset) {
|
|
43595
43648
|
try {
|
|
43596
43649
|
const resolvedPath = validateSwarmPath(directory, filename);
|
|
43597
|
-
if (
|
|
43598
|
-
|
|
43650
|
+
if (fs19.existsSync(resolvedPath)) {
|
|
43651
|
+
fs19.unlinkSync(resolvedPath);
|
|
43599
43652
|
results.push(`- \u2705 Deleted ${filename}`);
|
|
43600
43653
|
} else {
|
|
43601
43654
|
results.push(`- \u23ED\uFE0F ${filename} not found (skipped)`);
|
|
@@ -43612,8 +43665,8 @@ async function handleResetCommand(directory, args) {
|
|
|
43612
43665
|
}
|
|
43613
43666
|
try {
|
|
43614
43667
|
const summariesPath = validateSwarmPath(directory, "summaries");
|
|
43615
|
-
if (
|
|
43616
|
-
|
|
43668
|
+
if (fs19.existsSync(summariesPath)) {
|
|
43669
|
+
fs19.rmSync(summariesPath, { recursive: true, force: true });
|
|
43617
43670
|
results.push("- \u2705 Deleted summaries/ directory");
|
|
43618
43671
|
} else {
|
|
43619
43672
|
results.push("- \u23ED\uFE0F summaries/ not found (skipped)");
|
|
@@ -43633,14 +43686,14 @@ async function handleResetCommand(directory, args) {
|
|
|
43633
43686
|
|
|
43634
43687
|
// src/commands/reset-session.ts
|
|
43635
43688
|
init_utils2();
|
|
43636
|
-
import * as
|
|
43637
|
-
import * as
|
|
43689
|
+
import * as fs20 from "fs";
|
|
43690
|
+
import * as path29 from "path";
|
|
43638
43691
|
async function handleResetSessionCommand(directory, _args) {
|
|
43639
43692
|
const results = [];
|
|
43640
43693
|
try {
|
|
43641
43694
|
const statePath = validateSwarmPath(directory, "session/state.json");
|
|
43642
|
-
if (
|
|
43643
|
-
|
|
43695
|
+
if (fs20.existsSync(statePath)) {
|
|
43696
|
+
fs20.unlinkSync(statePath);
|
|
43644
43697
|
results.push("\u2705 Deleted .swarm/session/state.json");
|
|
43645
43698
|
} else {
|
|
43646
43699
|
results.push("\u23ED\uFE0F state.json not found (already clean)");
|
|
@@ -43649,15 +43702,15 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
43649
43702
|
results.push("\u274C Failed to delete state.json");
|
|
43650
43703
|
}
|
|
43651
43704
|
try {
|
|
43652
|
-
const sessionDir =
|
|
43653
|
-
if (
|
|
43654
|
-
const files =
|
|
43705
|
+
const sessionDir = path29.dirname(validateSwarmPath(directory, "session/state.json"));
|
|
43706
|
+
if (fs20.existsSync(sessionDir)) {
|
|
43707
|
+
const files = fs20.readdirSync(sessionDir);
|
|
43655
43708
|
const otherFiles = files.filter((f) => f !== "state.json");
|
|
43656
43709
|
let deletedCount = 0;
|
|
43657
43710
|
for (const file3 of otherFiles) {
|
|
43658
|
-
const filePath =
|
|
43659
|
-
if (
|
|
43660
|
-
|
|
43711
|
+
const filePath = path29.join(sessionDir, file3);
|
|
43712
|
+
if (fs20.lstatSync(filePath).isFile()) {
|
|
43713
|
+
fs20.unlinkSync(filePath);
|
|
43661
43714
|
deletedCount++;
|
|
43662
43715
|
}
|
|
43663
43716
|
}
|
|
@@ -43685,7 +43738,7 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
43685
43738
|
// src/summaries/manager.ts
|
|
43686
43739
|
init_utils2();
|
|
43687
43740
|
init_utils();
|
|
43688
|
-
import * as
|
|
43741
|
+
import * as path30 from "path";
|
|
43689
43742
|
var SUMMARY_ID_REGEX = /^S\d+$/;
|
|
43690
43743
|
function sanitizeSummaryId(id) {
|
|
43691
43744
|
if (!id || id.length === 0) {
|
|
@@ -43709,7 +43762,7 @@ function sanitizeSummaryId(id) {
|
|
|
43709
43762
|
}
|
|
43710
43763
|
async function loadFullOutput(directory, id) {
|
|
43711
43764
|
const sanitizedId = sanitizeSummaryId(id);
|
|
43712
|
-
const relativePath =
|
|
43765
|
+
const relativePath = path30.join("summaries", `${sanitizedId}.json`);
|
|
43713
43766
|
validateSwarmPath(directory, relativePath);
|
|
43714
43767
|
const content = await readSwarmFileAsync(directory, relativePath);
|
|
43715
43768
|
if (content === null) {
|
|
@@ -43762,18 +43815,18 @@ ${error93 instanceof Error ? error93.message : String(error93)}`;
|
|
|
43762
43815
|
|
|
43763
43816
|
// src/commands/rollback.ts
|
|
43764
43817
|
init_utils2();
|
|
43765
|
-
import * as
|
|
43766
|
-
import * as
|
|
43818
|
+
import * as fs21 from "fs";
|
|
43819
|
+
import * as path31 from "path";
|
|
43767
43820
|
async function handleRollbackCommand(directory, args) {
|
|
43768
43821
|
const phaseArg = args[0];
|
|
43769
43822
|
if (!phaseArg) {
|
|
43770
43823
|
const manifestPath2 = validateSwarmPath(directory, "checkpoints/manifest.json");
|
|
43771
|
-
if (!
|
|
43824
|
+
if (!fs21.existsSync(manifestPath2)) {
|
|
43772
43825
|
return "No checkpoints found. Use `/swarm checkpoint` to create checkpoints.";
|
|
43773
43826
|
}
|
|
43774
43827
|
let manifest2;
|
|
43775
43828
|
try {
|
|
43776
|
-
manifest2 = JSON.parse(
|
|
43829
|
+
manifest2 = JSON.parse(fs21.readFileSync(manifestPath2, "utf-8"));
|
|
43777
43830
|
} catch {
|
|
43778
43831
|
return "Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.";
|
|
43779
43832
|
}
|
|
@@ -43795,12 +43848,12 @@ async function handleRollbackCommand(directory, args) {
|
|
|
43795
43848
|
return "Error: Phase number must be a positive integer.";
|
|
43796
43849
|
}
|
|
43797
43850
|
const manifestPath = validateSwarmPath(directory, "checkpoints/manifest.json");
|
|
43798
|
-
if (!
|
|
43851
|
+
if (!fs21.existsSync(manifestPath)) {
|
|
43799
43852
|
return `Error: No checkpoints found. Cannot rollback to phase ${targetPhase}.`;
|
|
43800
43853
|
}
|
|
43801
43854
|
let manifest;
|
|
43802
43855
|
try {
|
|
43803
|
-
manifest = JSON.parse(
|
|
43856
|
+
manifest = JSON.parse(fs21.readFileSync(manifestPath, "utf-8"));
|
|
43804
43857
|
} catch {
|
|
43805
43858
|
return `Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.`;
|
|
43806
43859
|
}
|
|
@@ -43810,10 +43863,10 @@ async function handleRollbackCommand(directory, args) {
|
|
|
43810
43863
|
return `Error: Checkpoint for phase ${targetPhase} not found. Available phases: ${available}`;
|
|
43811
43864
|
}
|
|
43812
43865
|
const checkpointDir = validateSwarmPath(directory, `checkpoints/phase-${targetPhase}`);
|
|
43813
|
-
if (!
|
|
43866
|
+
if (!fs21.existsSync(checkpointDir)) {
|
|
43814
43867
|
return `Error: Checkpoint directory for phase ${targetPhase} does not exist.`;
|
|
43815
43868
|
}
|
|
43816
|
-
const checkpointFiles =
|
|
43869
|
+
const checkpointFiles = fs21.readdirSync(checkpointDir);
|
|
43817
43870
|
if (checkpointFiles.length === 0) {
|
|
43818
43871
|
return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
|
|
43819
43872
|
}
|
|
@@ -43821,10 +43874,10 @@ async function handleRollbackCommand(directory, args) {
|
|
|
43821
43874
|
const successes = [];
|
|
43822
43875
|
const failures = [];
|
|
43823
43876
|
for (const file3 of checkpointFiles) {
|
|
43824
|
-
const src =
|
|
43825
|
-
const dest =
|
|
43877
|
+
const src = path31.join(checkpointDir, file3);
|
|
43878
|
+
const dest = path31.join(swarmDir, file3);
|
|
43826
43879
|
try {
|
|
43827
|
-
|
|
43880
|
+
fs21.cpSync(src, dest, { recursive: true, force: true });
|
|
43828
43881
|
successes.push(file3);
|
|
43829
43882
|
} catch (error93) {
|
|
43830
43883
|
failures.push({ file: file3, error: error93.message });
|
|
@@ -43841,7 +43894,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
43841
43894
|
timestamp: new Date().toISOString()
|
|
43842
43895
|
};
|
|
43843
43896
|
try {
|
|
43844
|
-
|
|
43897
|
+
fs21.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
|
|
43845
43898
|
`);
|
|
43846
43899
|
} catch (error93) {
|
|
43847
43900
|
console.error("Failed to write rollback event:", error93 instanceof Error ? error93.message : String(error93));
|
|
@@ -43884,11 +43937,11 @@ async function handleSimulateCommand(directory, args) {
|
|
|
43884
43937
|
];
|
|
43885
43938
|
const report = reportLines.filter(Boolean).join(`
|
|
43886
43939
|
`);
|
|
43887
|
-
const
|
|
43888
|
-
const
|
|
43889
|
-
const reportPath =
|
|
43890
|
-
await
|
|
43891
|
-
await
|
|
43940
|
+
const fs22 = await import("fs/promises");
|
|
43941
|
+
const path32 = await import("path");
|
|
43942
|
+
const reportPath = path32.join(directory, ".swarm", "simulate-report.md");
|
|
43943
|
+
await fs22.mkdir(path32.dirname(reportPath), { recursive: true });
|
|
43944
|
+
await fs22.writeFile(reportPath, report, "utf-8");
|
|
43892
43945
|
return `${darkMatterPairs.length} hidden coupling pairs detected`;
|
|
43893
43946
|
}
|
|
43894
43947
|
|
|
@@ -44411,18 +44464,18 @@ function resolveCommand(tokens) {
|
|
|
44411
44464
|
}
|
|
44412
44465
|
|
|
44413
44466
|
// src/cli/index.ts
|
|
44414
|
-
var CONFIG_DIR =
|
|
44415
|
-
var OPENCODE_CONFIG_PATH =
|
|
44416
|
-
var PLUGIN_CONFIG_PATH =
|
|
44417
|
-
var PROMPTS_DIR =
|
|
44467
|
+
var CONFIG_DIR = path32.join(process.env.XDG_CONFIG_HOME || path32.join(os6.homedir(), ".config"), "opencode");
|
|
44468
|
+
var OPENCODE_CONFIG_PATH = path32.join(CONFIG_DIR, "opencode.json");
|
|
44469
|
+
var PLUGIN_CONFIG_PATH = path32.join(CONFIG_DIR, "opencode-swarm.json");
|
|
44470
|
+
var PROMPTS_DIR = path32.join(CONFIG_DIR, "opencode-swarm");
|
|
44418
44471
|
function ensureDir(dir) {
|
|
44419
|
-
if (!
|
|
44420
|
-
|
|
44472
|
+
if (!fs22.existsSync(dir)) {
|
|
44473
|
+
fs22.mkdirSync(dir, { recursive: true });
|
|
44421
44474
|
}
|
|
44422
44475
|
}
|
|
44423
44476
|
function loadJson(filepath) {
|
|
44424
44477
|
try {
|
|
44425
|
-
const content =
|
|
44478
|
+
const content = fs22.readFileSync(filepath, "utf-8");
|
|
44426
44479
|
const stripped = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, comment) => comment ? "" : match).replace(/,(\s*[}\]])/g, "$1");
|
|
44427
44480
|
return JSON.parse(stripped);
|
|
44428
44481
|
} catch {
|
|
@@ -44430,7 +44483,7 @@ function loadJson(filepath) {
|
|
|
44430
44483
|
}
|
|
44431
44484
|
}
|
|
44432
44485
|
function saveJson(filepath, data) {
|
|
44433
|
-
|
|
44486
|
+
fs22.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
|
|
44434
44487
|
`, "utf-8");
|
|
44435
44488
|
}
|
|
44436
44489
|
async function install() {
|
|
@@ -44438,7 +44491,7 @@ async function install() {
|
|
|
44438
44491
|
`);
|
|
44439
44492
|
ensureDir(CONFIG_DIR);
|
|
44440
44493
|
ensureDir(PROMPTS_DIR);
|
|
44441
|
-
const LEGACY_CONFIG_PATH =
|
|
44494
|
+
const LEGACY_CONFIG_PATH = path32.join(CONFIG_DIR, "config.json");
|
|
44442
44495
|
let opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
44443
44496
|
if (!opencodeConfig) {
|
|
44444
44497
|
const legacyConfig = loadJson(LEGACY_CONFIG_PATH);
|
|
@@ -44463,7 +44516,7 @@ async function install() {
|
|
|
44463
44516
|
saveJson(OPENCODE_CONFIG_PATH, opencodeConfig);
|
|
44464
44517
|
console.log("\u2713 Added opencode-swarm to OpenCode plugins");
|
|
44465
44518
|
console.log("\u2713 Disabled default OpenCode agents (explore, general)");
|
|
44466
|
-
if (!
|
|
44519
|
+
if (!fs22.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
44467
44520
|
const defaultConfig = {
|
|
44468
44521
|
agents: {
|
|
44469
44522
|
coder: { model: "opencode/minimax-m2.5-free" },
|
|
@@ -44506,7 +44559,7 @@ async function uninstall() {
|
|
|
44506
44559
|
`);
|
|
44507
44560
|
const opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
44508
44561
|
if (!opencodeConfig) {
|
|
44509
|
-
if (
|
|
44562
|
+
if (fs22.existsSync(OPENCODE_CONFIG_PATH)) {
|
|
44510
44563
|
console.log(`\u2717 Could not parse opencode config at: ${OPENCODE_CONFIG_PATH}`);
|
|
44511
44564
|
return 1;
|
|
44512
44565
|
} else {
|
|
@@ -44538,13 +44591,13 @@ async function uninstall() {
|
|
|
44538
44591
|
console.log("\u2713 Re-enabled default OpenCode agents (explore, general)");
|
|
44539
44592
|
if (process.argv.includes("--clean")) {
|
|
44540
44593
|
let cleaned = false;
|
|
44541
|
-
if (
|
|
44542
|
-
|
|
44594
|
+
if (fs22.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
44595
|
+
fs22.unlinkSync(PLUGIN_CONFIG_PATH);
|
|
44543
44596
|
console.log(`\u2713 Removed plugin config: ${PLUGIN_CONFIG_PATH}`);
|
|
44544
44597
|
cleaned = true;
|
|
44545
44598
|
}
|
|
44546
|
-
if (
|
|
44547
|
-
|
|
44599
|
+
if (fs22.existsSync(PROMPTS_DIR)) {
|
|
44600
|
+
fs22.rmSync(PROMPTS_DIR, { recursive: true });
|
|
44548
44601
|
console.log(`\u2713 Removed custom prompts: ${PROMPTS_DIR}`);
|
|
44549
44602
|
cleaned = true;
|
|
44550
44603
|
}
|