@mtreeai/msapling-cli 2.3.6-beta.1 → 2.3.6-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +366 -321
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3479,7 +3479,7 @@ async function copyDir(src, dst) {
|
|
|
3479
3479
|
}
|
|
3480
3480
|
async function backupFile(absPath) {
|
|
3481
3481
|
try {
|
|
3482
|
-
const { readFile: readFile23, writeFile: writeFile12, mkdir:
|
|
3482
|
+
const { readFile: readFile23, writeFile: writeFile12, mkdir: mkdir9 } = await import("fs/promises");
|
|
3483
3483
|
const { homedir: homedir15 } = await import("os");
|
|
3484
3484
|
const { join: join27 } = await import("path");
|
|
3485
3485
|
const filename = absPath.split(/[\\/]/).pop() ?? "file";
|
|
@@ -3489,7 +3489,7 @@ async function backupFile(absPath) {
|
|
|
3489
3489
|
"backups",
|
|
3490
3490
|
`${filename}.${Date.now()}.bak`
|
|
3491
3491
|
);
|
|
3492
|
-
await
|
|
3492
|
+
await mkdir9(join27(homedir15(), ".msapling", "backups"), { recursive: true });
|
|
3493
3493
|
const content = await readFile23(absPath, "utf8");
|
|
3494
3494
|
await writeFile12(backupPath, content, "utf8");
|
|
3495
3495
|
return backupPath;
|
|
@@ -3715,12 +3715,12 @@ var init_DeleteFileTool = __esm({
|
|
|
3715
3715
|
let backedUpTo = null;
|
|
3716
3716
|
if (isFile) {
|
|
3717
3717
|
try {
|
|
3718
|
-
const { readFile: readFile23, writeFile: writeFile12, mkdir:
|
|
3718
|
+
const { readFile: readFile23, writeFile: writeFile12, mkdir: mkdir9 } = await import("fs/promises");
|
|
3719
3719
|
const { homedir: homedir15 } = await import("os");
|
|
3720
3720
|
const existingContent = await readFile23(abs, "utf8");
|
|
3721
3721
|
const filename = abs.split(/[\\/]/).pop() ?? "file";
|
|
3722
3722
|
const backupPath = join10(homedir15(), ".msapling", "backups", `${filename}.${Date.now()}.bak`);
|
|
3723
|
-
await
|
|
3723
|
+
await mkdir9(join10(homedir15(), ".msapling", "backups"), { recursive: true });
|
|
3724
3724
|
await writeFile12(backupPath, existingContent, "utf8");
|
|
3725
3725
|
backedUpTo = backupPath;
|
|
3726
3726
|
} catch {
|
|
@@ -5132,54 +5132,54 @@ var require_polyfills = __commonJS({
|
|
|
5132
5132
|
}
|
|
5133
5133
|
var chdir;
|
|
5134
5134
|
module.exports = patch;
|
|
5135
|
-
function patch(
|
|
5135
|
+
function patch(fs2) {
|
|
5136
5136
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
5137
|
-
patchLchmod(
|
|
5138
|
-
}
|
|
5139
|
-
if (!
|
|
5140
|
-
patchLutimes(
|
|
5141
|
-
}
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
if (
|
|
5161
|
-
|
|
5137
|
+
patchLchmod(fs2);
|
|
5138
|
+
}
|
|
5139
|
+
if (!fs2.lutimes) {
|
|
5140
|
+
patchLutimes(fs2);
|
|
5141
|
+
}
|
|
5142
|
+
fs2.chown = chownFix(fs2.chown);
|
|
5143
|
+
fs2.fchown = chownFix(fs2.fchown);
|
|
5144
|
+
fs2.lchown = chownFix(fs2.lchown);
|
|
5145
|
+
fs2.chmod = chmodFix(fs2.chmod);
|
|
5146
|
+
fs2.fchmod = chmodFix(fs2.fchmod);
|
|
5147
|
+
fs2.lchmod = chmodFix(fs2.lchmod);
|
|
5148
|
+
fs2.chownSync = chownFixSync(fs2.chownSync);
|
|
5149
|
+
fs2.fchownSync = chownFixSync(fs2.fchownSync);
|
|
5150
|
+
fs2.lchownSync = chownFixSync(fs2.lchownSync);
|
|
5151
|
+
fs2.chmodSync = chmodFixSync(fs2.chmodSync);
|
|
5152
|
+
fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
|
|
5153
|
+
fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
|
|
5154
|
+
fs2.stat = statFix(fs2.stat);
|
|
5155
|
+
fs2.fstat = statFix(fs2.fstat);
|
|
5156
|
+
fs2.lstat = statFix(fs2.lstat);
|
|
5157
|
+
fs2.statSync = statFixSync(fs2.statSync);
|
|
5158
|
+
fs2.fstatSync = statFixSync(fs2.fstatSync);
|
|
5159
|
+
fs2.lstatSync = statFixSync(fs2.lstatSync);
|
|
5160
|
+
if (fs2.chmod && !fs2.lchmod) {
|
|
5161
|
+
fs2.lchmod = function(path2, mode, cb) {
|
|
5162
5162
|
if (cb) process.nextTick(cb);
|
|
5163
5163
|
};
|
|
5164
|
-
|
|
5164
|
+
fs2.lchmodSync = function() {
|
|
5165
5165
|
};
|
|
5166
5166
|
}
|
|
5167
|
-
if (
|
|
5168
|
-
|
|
5167
|
+
if (fs2.chown && !fs2.lchown) {
|
|
5168
|
+
fs2.lchown = function(path2, uid, gid, cb) {
|
|
5169
5169
|
if (cb) process.nextTick(cb);
|
|
5170
5170
|
};
|
|
5171
|
-
|
|
5171
|
+
fs2.lchownSync = function() {
|
|
5172
5172
|
};
|
|
5173
5173
|
}
|
|
5174
5174
|
if (platform2 === "win32") {
|
|
5175
|
-
|
|
5175
|
+
fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : (function(fs$rename) {
|
|
5176
5176
|
function rename2(from, to, cb) {
|
|
5177
5177
|
var start = Date.now();
|
|
5178
5178
|
var backoff = 0;
|
|
5179
5179
|
fs$rename(from, to, function CB(er) {
|
|
5180
5180
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
5181
5181
|
setTimeout(function() {
|
|
5182
|
-
|
|
5182
|
+
fs2.stat(to, function(stater, st) {
|
|
5183
5183
|
if (stater && stater.code === "ENOENT")
|
|
5184
5184
|
fs$rename(from, to, CB);
|
|
5185
5185
|
else
|
|
@@ -5195,9 +5195,9 @@ var require_polyfills = __commonJS({
|
|
|
5195
5195
|
}
|
|
5196
5196
|
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
5197
5197
|
return rename2;
|
|
5198
|
-
})(
|
|
5198
|
+
})(fs2.rename);
|
|
5199
5199
|
}
|
|
5200
|
-
|
|
5200
|
+
fs2.read = typeof fs2.read !== "function" ? fs2.read : (function(fs$read) {
|
|
5201
5201
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
5202
5202
|
var callback;
|
|
5203
5203
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -5205,22 +5205,22 @@ var require_polyfills = __commonJS({
|
|
|
5205
5205
|
callback = function(er, _, __) {
|
|
5206
5206
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
5207
5207
|
eagCounter++;
|
|
5208
|
-
return fs$read.call(
|
|
5208
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
5209
5209
|
}
|
|
5210
5210
|
callback_.apply(this, arguments);
|
|
5211
5211
|
};
|
|
5212
5212
|
}
|
|
5213
|
-
return fs$read.call(
|
|
5213
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
5214
5214
|
}
|
|
5215
5215
|
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
5216
5216
|
return read;
|
|
5217
|
-
})(
|
|
5218
|
-
|
|
5217
|
+
})(fs2.read);
|
|
5218
|
+
fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
5219
5219
|
return function(fd, buffer, offset, length, position) {
|
|
5220
5220
|
var eagCounter = 0;
|
|
5221
5221
|
while (true) {
|
|
5222
5222
|
try {
|
|
5223
|
-
return fs$readSync.call(
|
|
5223
|
+
return fs$readSync.call(fs2, fd, buffer, offset, length, position);
|
|
5224
5224
|
} catch (er) {
|
|
5225
5225
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
5226
5226
|
eagCounter++;
|
|
@@ -5230,10 +5230,10 @@ var require_polyfills = __commonJS({
|
|
|
5230
5230
|
}
|
|
5231
5231
|
}
|
|
5232
5232
|
};
|
|
5233
|
-
})(
|
|
5234
|
-
function patchLchmod(
|
|
5235
|
-
|
|
5236
|
-
|
|
5233
|
+
})(fs2.readSync);
|
|
5234
|
+
function patchLchmod(fs3) {
|
|
5235
|
+
fs3.lchmod = function(path2, mode, callback) {
|
|
5236
|
+
fs3.open(
|
|
5237
5237
|
path2,
|
|
5238
5238
|
constants.O_WRONLY | constants.O_SYMLINK,
|
|
5239
5239
|
mode,
|
|
@@ -5242,80 +5242,80 @@ var require_polyfills = __commonJS({
|
|
|
5242
5242
|
if (callback) callback(err);
|
|
5243
5243
|
return;
|
|
5244
5244
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5245
|
+
fs3.fchmod(fd, mode, function(err2) {
|
|
5246
|
+
fs3.close(fd, function(err22) {
|
|
5247
5247
|
if (callback) callback(err2 || err22);
|
|
5248
5248
|
});
|
|
5249
5249
|
});
|
|
5250
5250
|
}
|
|
5251
5251
|
);
|
|
5252
5252
|
};
|
|
5253
|
-
|
|
5254
|
-
var fd =
|
|
5253
|
+
fs3.lchmodSync = function(path2, mode) {
|
|
5254
|
+
var fd = fs3.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
5255
5255
|
var threw = true;
|
|
5256
5256
|
var ret;
|
|
5257
5257
|
try {
|
|
5258
|
-
ret =
|
|
5258
|
+
ret = fs3.fchmodSync(fd, mode);
|
|
5259
5259
|
threw = false;
|
|
5260
5260
|
} finally {
|
|
5261
5261
|
if (threw) {
|
|
5262
5262
|
try {
|
|
5263
|
-
|
|
5263
|
+
fs3.closeSync(fd);
|
|
5264
5264
|
} catch (er) {
|
|
5265
5265
|
}
|
|
5266
5266
|
} else {
|
|
5267
|
-
|
|
5267
|
+
fs3.closeSync(fd);
|
|
5268
5268
|
}
|
|
5269
5269
|
}
|
|
5270
5270
|
return ret;
|
|
5271
5271
|
};
|
|
5272
5272
|
}
|
|
5273
|
-
function patchLutimes(
|
|
5274
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
5275
|
-
|
|
5276
|
-
|
|
5273
|
+
function patchLutimes(fs3) {
|
|
5274
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
|
|
5275
|
+
fs3.lutimes = function(path2, at, mt, cb) {
|
|
5276
|
+
fs3.open(path2, constants.O_SYMLINK, function(er, fd) {
|
|
5277
5277
|
if (er) {
|
|
5278
5278
|
if (cb) cb(er);
|
|
5279
5279
|
return;
|
|
5280
5280
|
}
|
|
5281
|
-
|
|
5282
|
-
|
|
5281
|
+
fs3.futimes(fd, at, mt, function(er2) {
|
|
5282
|
+
fs3.close(fd, function(er22) {
|
|
5283
5283
|
if (cb) cb(er2 || er22);
|
|
5284
5284
|
});
|
|
5285
5285
|
});
|
|
5286
5286
|
});
|
|
5287
5287
|
};
|
|
5288
|
-
|
|
5289
|
-
var fd =
|
|
5288
|
+
fs3.lutimesSync = function(path2, at, mt) {
|
|
5289
|
+
var fd = fs3.openSync(path2, constants.O_SYMLINK);
|
|
5290
5290
|
var ret;
|
|
5291
5291
|
var threw = true;
|
|
5292
5292
|
try {
|
|
5293
|
-
ret =
|
|
5293
|
+
ret = fs3.futimesSync(fd, at, mt);
|
|
5294
5294
|
threw = false;
|
|
5295
5295
|
} finally {
|
|
5296
5296
|
if (threw) {
|
|
5297
5297
|
try {
|
|
5298
|
-
|
|
5298
|
+
fs3.closeSync(fd);
|
|
5299
5299
|
} catch (er) {
|
|
5300
5300
|
}
|
|
5301
5301
|
} else {
|
|
5302
|
-
|
|
5302
|
+
fs3.closeSync(fd);
|
|
5303
5303
|
}
|
|
5304
5304
|
}
|
|
5305
5305
|
return ret;
|
|
5306
5306
|
};
|
|
5307
|
-
} else if (
|
|
5308
|
-
|
|
5307
|
+
} else if (fs3.futimes) {
|
|
5308
|
+
fs3.lutimes = function(_a, _b, _c, cb) {
|
|
5309
5309
|
if (cb) process.nextTick(cb);
|
|
5310
5310
|
};
|
|
5311
|
-
|
|
5311
|
+
fs3.lutimesSync = function() {
|
|
5312
5312
|
};
|
|
5313
5313
|
}
|
|
5314
5314
|
}
|
|
5315
5315
|
function chmodFix(orig) {
|
|
5316
5316
|
if (!orig) return orig;
|
|
5317
5317
|
return function(target, mode, cb) {
|
|
5318
|
-
return orig.call(
|
|
5318
|
+
return orig.call(fs2, target, mode, function(er) {
|
|
5319
5319
|
if (chownErOk(er)) er = null;
|
|
5320
5320
|
if (cb) cb.apply(this, arguments);
|
|
5321
5321
|
});
|
|
@@ -5325,7 +5325,7 @@ var require_polyfills = __commonJS({
|
|
|
5325
5325
|
if (!orig) return orig;
|
|
5326
5326
|
return function(target, mode) {
|
|
5327
5327
|
try {
|
|
5328
|
-
return orig.call(
|
|
5328
|
+
return orig.call(fs2, target, mode);
|
|
5329
5329
|
} catch (er) {
|
|
5330
5330
|
if (!chownErOk(er)) throw er;
|
|
5331
5331
|
}
|
|
@@ -5334,7 +5334,7 @@ var require_polyfills = __commonJS({
|
|
|
5334
5334
|
function chownFix(orig) {
|
|
5335
5335
|
if (!orig) return orig;
|
|
5336
5336
|
return function(target, uid, gid, cb) {
|
|
5337
|
-
return orig.call(
|
|
5337
|
+
return orig.call(fs2, target, uid, gid, function(er) {
|
|
5338
5338
|
if (chownErOk(er)) er = null;
|
|
5339
5339
|
if (cb) cb.apply(this, arguments);
|
|
5340
5340
|
});
|
|
@@ -5344,7 +5344,7 @@ var require_polyfills = __commonJS({
|
|
|
5344
5344
|
if (!orig) return orig;
|
|
5345
5345
|
return function(target, uid, gid) {
|
|
5346
5346
|
try {
|
|
5347
|
-
return orig.call(
|
|
5347
|
+
return orig.call(fs2, target, uid, gid);
|
|
5348
5348
|
} catch (er) {
|
|
5349
5349
|
if (!chownErOk(er)) throw er;
|
|
5350
5350
|
}
|
|
@@ -5364,13 +5364,13 @@ var require_polyfills = __commonJS({
|
|
|
5364
5364
|
}
|
|
5365
5365
|
if (cb) cb.apply(this, arguments);
|
|
5366
5366
|
}
|
|
5367
|
-
return options ? orig.call(
|
|
5367
|
+
return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
|
|
5368
5368
|
};
|
|
5369
5369
|
}
|
|
5370
5370
|
function statFixSync(orig) {
|
|
5371
5371
|
if (!orig) return orig;
|
|
5372
5372
|
return function(target, options) {
|
|
5373
|
-
var stats = options ? orig.call(
|
|
5373
|
+
var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
|
|
5374
5374
|
if (stats) {
|
|
5375
5375
|
if (stats.uid < 0) stats.uid += 4294967296;
|
|
5376
5376
|
if (stats.gid < 0) stats.gid += 4294967296;
|
|
@@ -5401,7 +5401,7 @@ var require_legacy_streams = __commonJS({
|
|
|
5401
5401
|
init_esm_shims();
|
|
5402
5402
|
var Stream = __require("stream").Stream;
|
|
5403
5403
|
module.exports = legacy;
|
|
5404
|
-
function legacy(
|
|
5404
|
+
function legacy(fs2) {
|
|
5405
5405
|
return {
|
|
5406
5406
|
ReadStream,
|
|
5407
5407
|
WriteStream
|
|
@@ -5444,7 +5444,7 @@ var require_legacy_streams = __commonJS({
|
|
|
5444
5444
|
});
|
|
5445
5445
|
return;
|
|
5446
5446
|
}
|
|
5447
|
-
|
|
5447
|
+
fs2.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
5448
5448
|
if (err) {
|
|
5449
5449
|
self.emit("error", err);
|
|
5450
5450
|
self.readable = false;
|
|
@@ -5483,7 +5483,7 @@ var require_legacy_streams = __commonJS({
|
|
|
5483
5483
|
this.busy = false;
|
|
5484
5484
|
this._queue = [];
|
|
5485
5485
|
if (this.fd === null) {
|
|
5486
|
-
this._open =
|
|
5486
|
+
this._open = fs2.open;
|
|
5487
5487
|
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
5488
5488
|
this.flush();
|
|
5489
5489
|
}
|
|
@@ -5521,7 +5521,7 @@ var require_graceful_fs = __commonJS({
|
|
|
5521
5521
|
"../../node_modules/.bun/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
5522
5522
|
"use strict";
|
|
5523
5523
|
init_esm_shims();
|
|
5524
|
-
var
|
|
5524
|
+
var fs2 = __require("fs");
|
|
5525
5525
|
var polyfills = require_polyfills();
|
|
5526
5526
|
var legacy = require_legacy_streams();
|
|
5527
5527
|
var clone = require_clone();
|
|
@@ -5553,12 +5553,12 @@ var require_graceful_fs = __commonJS({
|
|
|
5553
5553
|
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
5554
5554
|
console.error(m);
|
|
5555
5555
|
};
|
|
5556
|
-
if (!
|
|
5556
|
+
if (!fs2[gracefulQueue]) {
|
|
5557
5557
|
queue = global[gracefulQueue] || [];
|
|
5558
|
-
publishQueue(
|
|
5559
|
-
|
|
5558
|
+
publishQueue(fs2, queue);
|
|
5559
|
+
fs2.close = (function(fs$close) {
|
|
5560
5560
|
function close(fd, cb) {
|
|
5561
|
-
return fs$close.call(
|
|
5561
|
+
return fs$close.call(fs2, fd, function(err) {
|
|
5562
5562
|
if (!err) {
|
|
5563
5563
|
resetQueue();
|
|
5564
5564
|
}
|
|
@@ -5570,40 +5570,40 @@ var require_graceful_fs = __commonJS({
|
|
|
5570
5570
|
value: fs$close
|
|
5571
5571
|
});
|
|
5572
5572
|
return close;
|
|
5573
|
-
})(
|
|
5574
|
-
|
|
5573
|
+
})(fs2.close);
|
|
5574
|
+
fs2.closeSync = (function(fs$closeSync) {
|
|
5575
5575
|
function closeSync(fd) {
|
|
5576
|
-
fs$closeSync.apply(
|
|
5576
|
+
fs$closeSync.apply(fs2, arguments);
|
|
5577
5577
|
resetQueue();
|
|
5578
5578
|
}
|
|
5579
5579
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
5580
5580
|
value: fs$closeSync
|
|
5581
5581
|
});
|
|
5582
5582
|
return closeSync;
|
|
5583
|
-
})(
|
|
5583
|
+
})(fs2.closeSync);
|
|
5584
5584
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
5585
5585
|
process.on("exit", function() {
|
|
5586
|
-
debug(
|
|
5587
|
-
__require("assert").equal(
|
|
5586
|
+
debug(fs2[gracefulQueue]);
|
|
5587
|
+
__require("assert").equal(fs2[gracefulQueue].length, 0);
|
|
5588
5588
|
});
|
|
5589
5589
|
}
|
|
5590
5590
|
}
|
|
5591
5591
|
var queue;
|
|
5592
5592
|
if (!global[gracefulQueue]) {
|
|
5593
|
-
publishQueue(global,
|
|
5594
|
-
}
|
|
5595
|
-
module.exports = patch(clone(
|
|
5596
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
5597
|
-
module.exports = patch(
|
|
5598
|
-
|
|
5599
|
-
}
|
|
5600
|
-
function patch(
|
|
5601
|
-
polyfills(
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
var fs$readFile =
|
|
5606
|
-
|
|
5593
|
+
publishQueue(global, fs2[gracefulQueue]);
|
|
5594
|
+
}
|
|
5595
|
+
module.exports = patch(clone(fs2));
|
|
5596
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
|
|
5597
|
+
module.exports = patch(fs2);
|
|
5598
|
+
fs2.__patched = true;
|
|
5599
|
+
}
|
|
5600
|
+
function patch(fs3) {
|
|
5601
|
+
polyfills(fs3);
|
|
5602
|
+
fs3.gracefulify = patch;
|
|
5603
|
+
fs3.createReadStream = createReadStream;
|
|
5604
|
+
fs3.createWriteStream = createWriteStream;
|
|
5605
|
+
var fs$readFile = fs3.readFile;
|
|
5606
|
+
fs3.readFile = readFile23;
|
|
5607
5607
|
function readFile23(path2, options, cb) {
|
|
5608
5608
|
if (typeof options === "function")
|
|
5609
5609
|
cb = options, options = null;
|
|
@@ -5619,8 +5619,8 @@ var require_graceful_fs = __commonJS({
|
|
|
5619
5619
|
});
|
|
5620
5620
|
}
|
|
5621
5621
|
}
|
|
5622
|
-
var fs$writeFile =
|
|
5623
|
-
|
|
5622
|
+
var fs$writeFile = fs3.writeFile;
|
|
5623
|
+
fs3.writeFile = writeFile12;
|
|
5624
5624
|
function writeFile12(path2, data, options, cb) {
|
|
5625
5625
|
if (typeof options === "function")
|
|
5626
5626
|
cb = options, options = null;
|
|
@@ -5636,9 +5636,9 @@ var require_graceful_fs = __commonJS({
|
|
|
5636
5636
|
});
|
|
5637
5637
|
}
|
|
5638
5638
|
}
|
|
5639
|
-
var fs$appendFile =
|
|
5639
|
+
var fs$appendFile = fs3.appendFile;
|
|
5640
5640
|
if (fs$appendFile)
|
|
5641
|
-
|
|
5641
|
+
fs3.appendFile = appendFile;
|
|
5642
5642
|
function appendFile(path2, data, options, cb) {
|
|
5643
5643
|
if (typeof options === "function")
|
|
5644
5644
|
cb = options, options = null;
|
|
@@ -5654,9 +5654,9 @@ var require_graceful_fs = __commonJS({
|
|
|
5654
5654
|
});
|
|
5655
5655
|
}
|
|
5656
5656
|
}
|
|
5657
|
-
var fs$copyFile =
|
|
5657
|
+
var fs$copyFile = fs3.copyFile;
|
|
5658
5658
|
if (fs$copyFile)
|
|
5659
|
-
|
|
5659
|
+
fs3.copyFile = copyFile2;
|
|
5660
5660
|
function copyFile2(src, dest, flags, cb) {
|
|
5661
5661
|
if (typeof flags === "function") {
|
|
5662
5662
|
cb = flags;
|
|
@@ -5674,8 +5674,8 @@ var require_graceful_fs = __commonJS({
|
|
|
5674
5674
|
});
|
|
5675
5675
|
}
|
|
5676
5676
|
}
|
|
5677
|
-
var fs$readdir =
|
|
5678
|
-
|
|
5677
|
+
var fs$readdir = fs3.readdir;
|
|
5678
|
+
fs3.readdir = readdir4;
|
|
5679
5679
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
5680
5680
|
function readdir4(path2, options, cb) {
|
|
5681
5681
|
if (typeof options === "function")
|
|
@@ -5716,21 +5716,21 @@ var require_graceful_fs = __commonJS({
|
|
|
5716
5716
|
}
|
|
5717
5717
|
}
|
|
5718
5718
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
5719
|
-
var legStreams = legacy(
|
|
5719
|
+
var legStreams = legacy(fs3);
|
|
5720
5720
|
ReadStream = legStreams.ReadStream;
|
|
5721
5721
|
WriteStream = legStreams.WriteStream;
|
|
5722
5722
|
}
|
|
5723
|
-
var fs$ReadStream =
|
|
5723
|
+
var fs$ReadStream = fs3.ReadStream;
|
|
5724
5724
|
if (fs$ReadStream) {
|
|
5725
5725
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
5726
5726
|
ReadStream.prototype.open = ReadStream$open;
|
|
5727
5727
|
}
|
|
5728
|
-
var fs$WriteStream =
|
|
5728
|
+
var fs$WriteStream = fs3.WriteStream;
|
|
5729
5729
|
if (fs$WriteStream) {
|
|
5730
5730
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
5731
5731
|
WriteStream.prototype.open = WriteStream$open;
|
|
5732
5732
|
}
|
|
5733
|
-
Object.defineProperty(
|
|
5733
|
+
Object.defineProperty(fs3, "ReadStream", {
|
|
5734
5734
|
get: function() {
|
|
5735
5735
|
return ReadStream;
|
|
5736
5736
|
},
|
|
@@ -5740,7 +5740,7 @@ var require_graceful_fs = __commonJS({
|
|
|
5740
5740
|
enumerable: true,
|
|
5741
5741
|
configurable: true
|
|
5742
5742
|
});
|
|
5743
|
-
Object.defineProperty(
|
|
5743
|
+
Object.defineProperty(fs3, "WriteStream", {
|
|
5744
5744
|
get: function() {
|
|
5745
5745
|
return WriteStream;
|
|
5746
5746
|
},
|
|
@@ -5751,7 +5751,7 @@ var require_graceful_fs = __commonJS({
|
|
|
5751
5751
|
configurable: true
|
|
5752
5752
|
});
|
|
5753
5753
|
var FileReadStream = ReadStream;
|
|
5754
|
-
Object.defineProperty(
|
|
5754
|
+
Object.defineProperty(fs3, "FileReadStream", {
|
|
5755
5755
|
get: function() {
|
|
5756
5756
|
return FileReadStream;
|
|
5757
5757
|
},
|
|
@@ -5762,7 +5762,7 @@ var require_graceful_fs = __commonJS({
|
|
|
5762
5762
|
configurable: true
|
|
5763
5763
|
});
|
|
5764
5764
|
var FileWriteStream = WriteStream;
|
|
5765
|
-
Object.defineProperty(
|
|
5765
|
+
Object.defineProperty(fs3, "FileWriteStream", {
|
|
5766
5766
|
get: function() {
|
|
5767
5767
|
return FileWriteStream;
|
|
5768
5768
|
},
|
|
@@ -5811,13 +5811,13 @@ var require_graceful_fs = __commonJS({
|
|
|
5811
5811
|
});
|
|
5812
5812
|
}
|
|
5813
5813
|
function createReadStream(path2, options) {
|
|
5814
|
-
return new
|
|
5814
|
+
return new fs3.ReadStream(path2, options);
|
|
5815
5815
|
}
|
|
5816
5816
|
function createWriteStream(path2, options) {
|
|
5817
|
-
return new
|
|
5817
|
+
return new fs3.WriteStream(path2, options);
|
|
5818
5818
|
}
|
|
5819
|
-
var fs$open =
|
|
5820
|
-
|
|
5819
|
+
var fs$open = fs3.open;
|
|
5820
|
+
fs3.open = open;
|
|
5821
5821
|
function open(path2, flags, mode, cb) {
|
|
5822
5822
|
if (typeof mode === "function")
|
|
5823
5823
|
cb = mode, mode = null;
|
|
@@ -5833,20 +5833,20 @@ var require_graceful_fs = __commonJS({
|
|
|
5833
5833
|
});
|
|
5834
5834
|
}
|
|
5835
5835
|
}
|
|
5836
|
-
return
|
|
5836
|
+
return fs3;
|
|
5837
5837
|
}
|
|
5838
5838
|
function enqueue(elem) {
|
|
5839
5839
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
5840
|
-
|
|
5840
|
+
fs2[gracefulQueue].push(elem);
|
|
5841
5841
|
retry();
|
|
5842
5842
|
}
|
|
5843
5843
|
var retryTimer;
|
|
5844
5844
|
function resetQueue() {
|
|
5845
5845
|
var now = Date.now();
|
|
5846
|
-
for (var i = 0; i <
|
|
5847
|
-
if (
|
|
5848
|
-
|
|
5849
|
-
|
|
5846
|
+
for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
|
|
5847
|
+
if (fs2[gracefulQueue][i].length > 2) {
|
|
5848
|
+
fs2[gracefulQueue][i][3] = now;
|
|
5849
|
+
fs2[gracefulQueue][i][4] = now;
|
|
5850
5850
|
}
|
|
5851
5851
|
}
|
|
5852
5852
|
retry();
|
|
@@ -5854,9 +5854,9 @@ var require_graceful_fs = __commonJS({
|
|
|
5854
5854
|
function retry() {
|
|
5855
5855
|
clearTimeout(retryTimer);
|
|
5856
5856
|
retryTimer = void 0;
|
|
5857
|
-
if (
|
|
5857
|
+
if (fs2[gracefulQueue].length === 0)
|
|
5858
5858
|
return;
|
|
5859
|
-
var elem =
|
|
5859
|
+
var elem = fs2[gracefulQueue].shift();
|
|
5860
5860
|
var fn = elem[0];
|
|
5861
5861
|
var args2 = elem[1];
|
|
5862
5862
|
var err = elem[2];
|
|
@@ -5878,7 +5878,7 @@ var require_graceful_fs = __commonJS({
|
|
|
5878
5878
|
debug("RETRY", fn.name, args2);
|
|
5879
5879
|
fn.apply(null, args2.concat([startTime]));
|
|
5880
5880
|
} else {
|
|
5881
|
-
|
|
5881
|
+
fs2[gracefulQueue].push(elem);
|
|
5882
5882
|
}
|
|
5883
5883
|
}
|
|
5884
5884
|
if (retryTimer === void 0) {
|
|
@@ -6324,10 +6324,10 @@ var require_mtime_precision = __commonJS({
|
|
|
6324
6324
|
"use strict";
|
|
6325
6325
|
init_esm_shims();
|
|
6326
6326
|
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
6327
|
-
function probe(file,
|
|
6328
|
-
const cachedPrecision =
|
|
6327
|
+
function probe(file, fs2, callback) {
|
|
6328
|
+
const cachedPrecision = fs2[cacheSymbol];
|
|
6329
6329
|
if (cachedPrecision) {
|
|
6330
|
-
return
|
|
6330
|
+
return fs2.stat(file, (err, stat5) => {
|
|
6331
6331
|
if (err) {
|
|
6332
6332
|
return callback(err);
|
|
6333
6333
|
}
|
|
@@ -6335,16 +6335,16 @@ var require_mtime_precision = __commonJS({
|
|
|
6335
6335
|
});
|
|
6336
6336
|
}
|
|
6337
6337
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
6338
|
-
|
|
6338
|
+
fs2.utimes(file, mtime, mtime, (err) => {
|
|
6339
6339
|
if (err) {
|
|
6340
6340
|
return callback(err);
|
|
6341
6341
|
}
|
|
6342
|
-
|
|
6342
|
+
fs2.stat(file, (err2, stat5) => {
|
|
6343
6343
|
if (err2) {
|
|
6344
6344
|
return callback(err2);
|
|
6345
6345
|
}
|
|
6346
6346
|
const precision = stat5.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
6347
|
-
Object.defineProperty(
|
|
6347
|
+
Object.defineProperty(fs2, cacheSymbol, { value: precision });
|
|
6348
6348
|
callback(null, stat5.mtime, precision);
|
|
6349
6349
|
});
|
|
6350
6350
|
});
|
|
@@ -6367,7 +6367,7 @@ var require_lockfile = __commonJS({
|
|
|
6367
6367
|
"use strict";
|
|
6368
6368
|
init_esm_shims();
|
|
6369
6369
|
var path2 = __require("path");
|
|
6370
|
-
var
|
|
6370
|
+
var fs2 = require_graceful_fs();
|
|
6371
6371
|
var retry = require_retry2();
|
|
6372
6372
|
var onExit = require_signal_exit();
|
|
6373
6373
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -6498,7 +6498,7 @@ var require_lockfile = __commonJS({
|
|
|
6498
6498
|
update: null,
|
|
6499
6499
|
realpath: true,
|
|
6500
6500
|
retries: 0,
|
|
6501
|
-
fs,
|
|
6501
|
+
fs: fs2,
|
|
6502
6502
|
onCompromised: (err) => {
|
|
6503
6503
|
throw err;
|
|
6504
6504
|
},
|
|
@@ -6542,7 +6542,7 @@ var require_lockfile = __commonJS({
|
|
|
6542
6542
|
}
|
|
6543
6543
|
function unlock2(file, options, callback) {
|
|
6544
6544
|
options = {
|
|
6545
|
-
fs,
|
|
6545
|
+
fs: fs2,
|
|
6546
6546
|
realpath: true,
|
|
6547
6547
|
...options
|
|
6548
6548
|
};
|
|
@@ -6564,7 +6564,7 @@ var require_lockfile = __commonJS({
|
|
|
6564
6564
|
options = {
|
|
6565
6565
|
stale: 1e4,
|
|
6566
6566
|
realpath: true,
|
|
6567
|
-
fs,
|
|
6567
|
+
fs: fs2,
|
|
6568
6568
|
...options
|
|
6569
6569
|
};
|
|
6570
6570
|
options.stale = Math.max(options.stale || 0, 2e3);
|
|
@@ -6604,16 +6604,16 @@ var require_adapter = __commonJS({
|
|
|
6604
6604
|
"../../node_modules/.bun/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
6605
6605
|
"use strict";
|
|
6606
6606
|
init_esm_shims();
|
|
6607
|
-
var
|
|
6608
|
-
function createSyncFs(
|
|
6607
|
+
var fs2 = require_graceful_fs();
|
|
6608
|
+
function createSyncFs(fs3) {
|
|
6609
6609
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
6610
|
-
const newFs = { ...
|
|
6610
|
+
const newFs = { ...fs3 };
|
|
6611
6611
|
methods.forEach((method) => {
|
|
6612
6612
|
newFs[method] = (...args2) => {
|
|
6613
6613
|
const callback = args2.pop();
|
|
6614
6614
|
let ret;
|
|
6615
6615
|
try {
|
|
6616
|
-
ret =
|
|
6616
|
+
ret = fs3[`${method}Sync`](...args2);
|
|
6617
6617
|
} catch (err) {
|
|
6618
6618
|
return callback(err);
|
|
6619
6619
|
}
|
|
@@ -6651,7 +6651,7 @@ var require_adapter = __commonJS({
|
|
|
6651
6651
|
}
|
|
6652
6652
|
function toSyncOptions(options) {
|
|
6653
6653
|
options = { ...options };
|
|
6654
|
-
options.fs = createSyncFs(options.fs ||
|
|
6654
|
+
options.fs = createSyncFs(options.fs || fs2);
|
|
6655
6655
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
6656
6656
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
6657
6657
|
}
|
|
@@ -6763,11 +6763,142 @@ var require_keytar2 = __commonJS({
|
|
|
6763
6763
|
}
|
|
6764
6764
|
});
|
|
6765
6765
|
|
|
6766
|
-
// ../core/src/
|
|
6767
|
-
import { join as join13 } from "path";
|
|
6766
|
+
// ../core/src/Settings.ts
|
|
6768
6767
|
import { homedir as homedir7 } from "os";
|
|
6769
|
-
import {
|
|
6770
|
-
import {
|
|
6768
|
+
import { join as join13 } from "path";
|
|
6769
|
+
import { existsSync as existsSync12 } from "fs";
|
|
6770
|
+
import * as fs from "fs";
|
|
6771
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
6772
|
+
function ensureConfigDir(p) {
|
|
6773
|
+
try {
|
|
6774
|
+
fs.mkdirSync(p, { recursive: true, mode: 448 });
|
|
6775
|
+
} catch (e) {
|
|
6776
|
+
if (e.code === "EEXIST" || e.code === "ENOTDIR") {
|
|
6777
|
+
const stat5 = fs.statSync(p);
|
|
6778
|
+
if (!stat5.isDirectory()) {
|
|
6779
|
+
fs.renameSync(p, `${p}.broken-${Date.now()}`);
|
|
6780
|
+
fs.mkdirSync(p, { recursive: true, mode: 448 });
|
|
6781
|
+
}
|
|
6782
|
+
} else {
|
|
6783
|
+
throw e;
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
}
|
|
6787
|
+
async function readJson(path2) {
|
|
6788
|
+
try {
|
|
6789
|
+
if (!existsSync12(path2)) return null;
|
|
6790
|
+
const text = await readFile11(path2, "utf8");
|
|
6791
|
+
if (!text.trim()) return null;
|
|
6792
|
+
return JSON.parse(text);
|
|
6793
|
+
} catch {
|
|
6794
|
+
return null;
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
function fromEnv(env) {
|
|
6798
|
+
const out = {};
|
|
6799
|
+
for (const [envKey, settingKey] of Object.entries(ENV_MAP)) {
|
|
6800
|
+
const raw = env[envKey];
|
|
6801
|
+
if (raw === void 0) continue;
|
|
6802
|
+
if (settingKey === "maxTokens") {
|
|
6803
|
+
const n = Number.parseInt(raw, 10);
|
|
6804
|
+
if (Number.isFinite(n)) out.maxTokens = n;
|
|
6805
|
+
} else if (settingKey === "temperature") {
|
|
6806
|
+
const n = Number.parseFloat(raw);
|
|
6807
|
+
if (Number.isFinite(n)) out.temperature = n;
|
|
6808
|
+
} else if (settingKey === "ollamaEnabled" || settingKey === "telemetryEnabled") {
|
|
6809
|
+
out[settingKey] = raw === "true" || raw === "1";
|
|
6810
|
+
} else if (settingKey === "defaultMode") {
|
|
6811
|
+
const v = raw;
|
|
6812
|
+
if (["default", "plan", "acceptEdits", "bypassPermissions"].includes(v)) {
|
|
6813
|
+
out.defaultMode = v;
|
|
6814
|
+
}
|
|
6815
|
+
} else {
|
|
6816
|
+
out[settingKey] = raw;
|
|
6817
|
+
}
|
|
6818
|
+
}
|
|
6819
|
+
return out;
|
|
6820
|
+
}
|
|
6821
|
+
function mergeSettings(base, override) {
|
|
6822
|
+
const out = { ...base, ...override };
|
|
6823
|
+
if (override.mcpServers) {
|
|
6824
|
+
out.mcpServers = { ...base.mcpServers, ...override.mcpServers };
|
|
6825
|
+
}
|
|
6826
|
+
if (override.hooks) {
|
|
6827
|
+
out.hooks = { ...base.hooks, ...override.hooks };
|
|
6828
|
+
}
|
|
6829
|
+
if (override.trustedCommands) {
|
|
6830
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6831
|
+
const merged = [];
|
|
6832
|
+
for (const c of [...base.trustedCommands, ...override.trustedCommands]) {
|
|
6833
|
+
if (!seen.has(c)) {
|
|
6834
|
+
seen.add(c);
|
|
6835
|
+
merged.push(c);
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
6838
|
+
out.trustedCommands = merged;
|
|
6839
|
+
}
|
|
6840
|
+
return out;
|
|
6841
|
+
}
|
|
6842
|
+
async function loadSettings(cwd = process.cwd(), env = process.env, warn) {
|
|
6843
|
+
const sources = [];
|
|
6844
|
+
const userPath = join13(homedir7() || ".", ".msapling", "settings.json");
|
|
6845
|
+
const projectPath = join13(cwd, ".msapling", "settings.json");
|
|
6846
|
+
const [user, project] = await Promise.all([readJson(userPath), readJson(projectPath)]);
|
|
6847
|
+
if (user) sources.push(userPath);
|
|
6848
|
+
if (project) sources.push(projectPath);
|
|
6849
|
+
let settings = DEFAULT_SETTINGS;
|
|
6850
|
+
if (user) settings = mergeSettings(settings, user);
|
|
6851
|
+
if (project) settings = mergeSettings(settings, project);
|
|
6852
|
+
settings = mergeSettings(settings, fromEnv(env));
|
|
6853
|
+
if (settings.temperature < 0 || settings.temperature > 2) {
|
|
6854
|
+
warn?.(`Settings: temperature out of range (${settings.temperature}); clamping to 0.7`);
|
|
6855
|
+
settings = { ...settings, temperature: 0.7 };
|
|
6856
|
+
}
|
|
6857
|
+
if (settings.maxTokens <= 0) {
|
|
6858
|
+
warn?.(`Settings: maxTokens must be positive; resetting to ${DEFAULT_SETTINGS.maxTokens}`);
|
|
6859
|
+
settings = { ...settings, maxTokens: DEFAULT_SETTINGS.maxTokens };
|
|
6860
|
+
}
|
|
6861
|
+
return { settings, sources };
|
|
6862
|
+
}
|
|
6863
|
+
var DEFAULT_SETTINGS, ENV_MAP;
|
|
6864
|
+
var init_Settings = __esm({
|
|
6865
|
+
"../core/src/Settings.ts"() {
|
|
6866
|
+
"use strict";
|
|
6867
|
+
init_esm_shims();
|
|
6868
|
+
DEFAULT_SETTINGS = {
|
|
6869
|
+
apiUrl: "https://api.msapling.com",
|
|
6870
|
+
defaultModel: "google/gemini-2.0-flash-001",
|
|
6871
|
+
defaultMode: "default",
|
|
6872
|
+
theme: "diamond",
|
|
6873
|
+
maxTokens: 4096,
|
|
6874
|
+
temperature: 0.7,
|
|
6875
|
+
ollamaEnabled: true,
|
|
6876
|
+
ollamaBaseUrl: "http://127.0.0.1:11434",
|
|
6877
|
+
telemetryEnabled: true,
|
|
6878
|
+
mcpServers: {},
|
|
6879
|
+
hooks: {},
|
|
6880
|
+
trustedCommands: [],
|
|
6881
|
+
shellEscapeEnabled: true
|
|
6882
|
+
};
|
|
6883
|
+
ENV_MAP = {
|
|
6884
|
+
MSAPLING_API_URL: "apiUrl",
|
|
6885
|
+
MSAPLING_DEFAULT_MODEL: "defaultModel",
|
|
6886
|
+
MSAPLING_DEFAULT_MODE: "defaultMode",
|
|
6887
|
+
MSAPLING_THEME: "theme",
|
|
6888
|
+
MSAPLING_MAX_TOKENS: "maxTokens",
|
|
6889
|
+
MSAPLING_TEMPERATURE: "temperature",
|
|
6890
|
+
MSAPLING_OLLAMA_ENABLED: "ollamaEnabled",
|
|
6891
|
+
MSAPLING_OLLAMA_BASE_URL: "ollamaBaseUrl",
|
|
6892
|
+
MSAPLING_TELEMETRY_ENABLED: "telemetryEnabled"
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6895
|
+
});
|
|
6896
|
+
|
|
6897
|
+
// ../core/src/Storage.ts
|
|
6898
|
+
import { join as join14 } from "path";
|
|
6899
|
+
import { homedir as homedir8 } from "os";
|
|
6900
|
+
import { chmodSync, existsSync as existsSync13, renameSync as renameSync2, unlinkSync } from "fs";
|
|
6901
|
+
import { writeFile as writeFile6, readFile as readFile12 } from "fs/promises";
|
|
6771
6902
|
var lockfile, keytar, StorageManager;
|
|
6772
6903
|
var init_Storage = __esm({
|
|
6773
6904
|
"../core/src/Storage.ts"() {
|
|
@@ -6776,6 +6907,7 @@ var init_Storage = __esm({
|
|
|
6776
6907
|
init_Mutex();
|
|
6777
6908
|
lockfile = __toESM(require_proper_lockfile(), 1);
|
|
6778
6909
|
keytar = __toESM(require_keytar2(), 1);
|
|
6910
|
+
init_Settings();
|
|
6779
6911
|
StorageManager = class {
|
|
6780
6912
|
baseDir;
|
|
6781
6913
|
/**
|
|
@@ -6794,16 +6926,16 @@ var init_Storage = __esm({
|
|
|
6794
6926
|
*/
|
|
6795
6927
|
_ready;
|
|
6796
6928
|
constructor() {
|
|
6797
|
-
this.baseDir =
|
|
6929
|
+
this.baseDir = join14(homedir8(), ".msapling");
|
|
6798
6930
|
this._ready = this.ensureDirs();
|
|
6799
6931
|
}
|
|
6800
6932
|
async ensureDirs() {
|
|
6801
6933
|
try {
|
|
6802
|
-
|
|
6803
|
-
const subdirs = ["history", "backups", "cache", "vault"];
|
|
6934
|
+
ensureConfigDir(this.baseDir);
|
|
6935
|
+
const subdirs = ["history", "backups", "cache", "vault", "mcp"];
|
|
6804
6936
|
for (const sub of subdirs) {
|
|
6805
|
-
const path2 =
|
|
6806
|
-
|
|
6937
|
+
const path2 = join14(this.baseDir, sub);
|
|
6938
|
+
ensureConfigDir(path2);
|
|
6807
6939
|
}
|
|
6808
6940
|
if (process.platform !== "win32") {
|
|
6809
6941
|
chmodSync(this.baseDir, 448);
|
|
@@ -6820,11 +6952,11 @@ var init_Storage = __esm({
|
|
|
6820
6952
|
await this._ready;
|
|
6821
6953
|
const KEYCHAIN_SERVICE = "msapling-cli";
|
|
6822
6954
|
const KEYCHAIN_ACCOUNT = "auth_token";
|
|
6823
|
-
const filePath =
|
|
6955
|
+
const filePath = join14(this.baseDir, "vault", "token");
|
|
6824
6956
|
try {
|
|
6825
6957
|
await keytar.setPassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT, token);
|
|
6826
6958
|
try {
|
|
6827
|
-
if (
|
|
6959
|
+
if (existsSync13(filePath)) {
|
|
6828
6960
|
unlinkSync(filePath);
|
|
6829
6961
|
}
|
|
6830
6962
|
} catch {
|
|
@@ -6840,7 +6972,7 @@ var init_Storage = __esm({
|
|
|
6840
6972
|
async loadToken() {
|
|
6841
6973
|
const KEYCHAIN_SERVICE = "msapling-cli";
|
|
6842
6974
|
const KEYCHAIN_ACCOUNT = "auth_token";
|
|
6843
|
-
const filePath =
|
|
6975
|
+
const filePath = join14(this.baseDir, "vault", "token");
|
|
6844
6976
|
try {
|
|
6845
6977
|
const keychainToken = await keytar.getPassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT);
|
|
6846
6978
|
if (keychainToken) {
|
|
@@ -6849,8 +6981,8 @@ var init_Storage = __esm({
|
|
|
6849
6981
|
} catch (e) {
|
|
6850
6982
|
console.debug(`Keychain unavailable (${e instanceof Error ? e.message : String(e)}), falling back to file storage`);
|
|
6851
6983
|
}
|
|
6852
|
-
if (
|
|
6853
|
-
const text = await
|
|
6984
|
+
if (existsSync13(filePath)) {
|
|
6985
|
+
const text = await readFile12(filePath, "utf8");
|
|
6854
6986
|
return text.trim();
|
|
6855
6987
|
}
|
|
6856
6988
|
return null;
|
|
@@ -6861,16 +6993,16 @@ var init_Storage = __esm({
|
|
|
6861
6993
|
async clearToken() {
|
|
6862
6994
|
const KEYCHAIN_SERVICE = "msapling-cli";
|
|
6863
6995
|
const KEYCHAIN_ACCOUNT = "auth_token";
|
|
6864
|
-
const filePath =
|
|
6996
|
+
const filePath = join14(this.baseDir, "vault", "token");
|
|
6865
6997
|
try {
|
|
6866
6998
|
await keytar.deletePassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT);
|
|
6867
6999
|
} catch (e) {
|
|
6868
7000
|
console.debug(`Keychain unavailable for deletion (${e instanceof Error ? e.message : String(e)})`);
|
|
6869
7001
|
}
|
|
6870
7002
|
try {
|
|
6871
|
-
if (
|
|
6872
|
-
const
|
|
6873
|
-
await
|
|
7003
|
+
if (existsSync13(filePath)) {
|
|
7004
|
+
const fs2 = await import("fs/promises");
|
|
7005
|
+
await fs2.unlink(filePath);
|
|
6874
7006
|
}
|
|
6875
7007
|
} catch (e) {
|
|
6876
7008
|
console.warn(`Failed to delete token file: ${e}`);
|
|
@@ -6884,23 +7016,26 @@ var init_Storage = __esm({
|
|
|
6884
7016
|
* This ensures:
|
|
6885
7017
|
* 1. Only one process writes at a time (file lock)
|
|
6886
7018
|
* 2. Partial writes don't corrupt the JSON (atomic rename)
|
|
7019
|
+
*
|
|
7020
|
+
* CLI-LSTAT-HISTORY-01: Pass realpath:false so lockfile never calls lstat on a
|
|
7021
|
+
* path that may not exist yet (first run before any history has been written).
|
|
6887
7022
|
*/
|
|
6888
7023
|
async saveHistory(history) {
|
|
6889
|
-
const path2 =
|
|
7024
|
+
const path2 = join14(this.baseDir, "history", "shell_history.json");
|
|
6890
7025
|
let release2;
|
|
6891
7026
|
try {
|
|
6892
|
-
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
|
|
7027
|
+
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50, realpath: false });
|
|
6893
7028
|
await this.historyMutex.run(async () => {
|
|
6894
7029
|
const tmpPath = `${path2}.tmp`;
|
|
6895
7030
|
const content = JSON.stringify(history, null, 2);
|
|
6896
7031
|
await writeFile6(tmpPath, content, "utf8");
|
|
6897
7032
|
try {
|
|
6898
|
-
|
|
7033
|
+
renameSync2(tmpPath, path2);
|
|
6899
7034
|
} catch (e) {
|
|
6900
7035
|
try {
|
|
6901
|
-
if (
|
|
6902
|
-
const
|
|
6903
|
-
await
|
|
7036
|
+
if (existsSync13(tmpPath)) {
|
|
7037
|
+
const fs2 = await import("fs/promises");
|
|
7038
|
+
await fs2.unlink(tmpPath);
|
|
6904
7039
|
}
|
|
6905
7040
|
} catch {
|
|
6906
7041
|
}
|
|
@@ -6910,7 +7045,7 @@ var init_Storage = __esm({
|
|
|
6910
7045
|
} finally {
|
|
6911
7046
|
if (release2) {
|
|
6912
7047
|
try {
|
|
6913
|
-
await lockfile.unlock(path2, { skipStale: true });
|
|
7048
|
+
await lockfile.unlock(path2, { skipStale: true, realpath: false });
|
|
6914
7049
|
} catch (e) {
|
|
6915
7050
|
console.warn(`Failed to unlock history file: ${e}`);
|
|
6916
7051
|
}
|
|
@@ -6921,23 +7056,41 @@ var init_Storage = __esm({
|
|
|
6921
7056
|
* SYNC-01: Serialised history read with file-based locking.
|
|
6922
7057
|
* Reads are gated behind the file lock so a read that overlaps with an
|
|
6923
7058
|
* in-progress write from another process always sees a complete, valid JSON.
|
|
7059
|
+
*
|
|
7060
|
+
* CLI-LSTAT-HISTORY-01: Short-circuit before locking when the file is absent
|
|
7061
|
+
* so lockfile never calls lstat/realpath on a nonexistent path (ENOENT crash
|
|
7062
|
+
* on fresh install). Corrupt JSON is caught, backed up, and treated as empty
|
|
7063
|
+
* rather than propagating a parse error.
|
|
6924
7064
|
*/
|
|
6925
7065
|
async loadHistory() {
|
|
6926
|
-
const path2 =
|
|
7066
|
+
const path2 = join14(this.baseDir, "history", "shell_history.json");
|
|
7067
|
+
if (!existsSync13(path2)) {
|
|
7068
|
+
return [];
|
|
7069
|
+
}
|
|
6927
7070
|
let release2;
|
|
6928
7071
|
try {
|
|
6929
|
-
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
|
|
6930
|
-
return this.historyMutex.run(async () => {
|
|
6931
|
-
if (
|
|
6932
|
-
|
|
7072
|
+
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50, realpath: false });
|
|
7073
|
+
return await this.historyMutex.run(async () => {
|
|
7074
|
+
if (!existsSync13(path2)) {
|
|
7075
|
+
return [];
|
|
7076
|
+
}
|
|
7077
|
+
const text = await readFile12(path2, "utf8");
|
|
7078
|
+
try {
|
|
6933
7079
|
return JSON.parse(text);
|
|
7080
|
+
} catch {
|
|
7081
|
+
console.warn("[msapling] shell_history.json is corrupt; resetting to empty history.");
|
|
7082
|
+
const backupPath = `${path2}.corrupt.${Date.now()}.bak`;
|
|
7083
|
+
try {
|
|
7084
|
+
renameSync2(path2, backupPath);
|
|
7085
|
+
} catch {
|
|
7086
|
+
}
|
|
7087
|
+
return [];
|
|
6934
7088
|
}
|
|
6935
|
-
return [];
|
|
6936
7089
|
});
|
|
6937
7090
|
} finally {
|
|
6938
7091
|
if (release2) {
|
|
6939
7092
|
try {
|
|
6940
|
-
await lockfile.unlock(path2, { skipStale: true });
|
|
7093
|
+
await lockfile.unlock(path2, { skipStale: true, realpath: false });
|
|
6941
7094
|
} catch (e) {
|
|
6942
7095
|
console.warn(`Failed to unlock history file: ${e}`);
|
|
6943
7096
|
}
|
|
@@ -6946,23 +7099,24 @@ var init_Storage = __esm({
|
|
|
6946
7099
|
}
|
|
6947
7100
|
/**
|
|
6948
7101
|
* SYNC-01: Serialised permissions write with file-based locking.
|
|
7102
|
+
* CLI-LSTAT-HISTORY-01: realpath:false prevents ENOENT lstat on first run.
|
|
6949
7103
|
*/
|
|
6950
7104
|
async savePermissions(permissions) {
|
|
6951
|
-
const path2 =
|
|
7105
|
+
const path2 = join14(this.baseDir, "vault", "permissions.json");
|
|
6952
7106
|
let release2;
|
|
6953
7107
|
try {
|
|
6954
|
-
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
|
|
7108
|
+
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50, realpath: false });
|
|
6955
7109
|
await this.permissionsMutex.run(async () => {
|
|
6956
7110
|
const tmpPath = `${path2}.tmp`;
|
|
6957
7111
|
const content = JSON.stringify(permissions, null, 2);
|
|
6958
7112
|
await writeFile6(tmpPath, content, "utf8");
|
|
6959
7113
|
try {
|
|
6960
|
-
|
|
7114
|
+
renameSync2(tmpPath, path2);
|
|
6961
7115
|
} catch (e) {
|
|
6962
7116
|
try {
|
|
6963
|
-
if (
|
|
6964
|
-
const
|
|
6965
|
-
await
|
|
7117
|
+
if (existsSync13(tmpPath)) {
|
|
7118
|
+
const fs2 = await import("fs/promises");
|
|
7119
|
+
await fs2.unlink(tmpPath);
|
|
6966
7120
|
}
|
|
6967
7121
|
} catch {
|
|
6968
7122
|
}
|
|
@@ -6972,7 +7126,7 @@ var init_Storage = __esm({
|
|
|
6972
7126
|
} finally {
|
|
6973
7127
|
if (release2) {
|
|
6974
7128
|
try {
|
|
6975
|
-
await lockfile.unlock(path2, { skipStale: true });
|
|
7129
|
+
await lockfile.unlock(path2, { skipStale: true, realpath: false });
|
|
6976
7130
|
} catch (e) {
|
|
6977
7131
|
console.warn(`Failed to unlock permissions file: ${e}`);
|
|
6978
7132
|
}
|
|
@@ -6981,23 +7135,28 @@ var init_Storage = __esm({
|
|
|
6981
7135
|
}
|
|
6982
7136
|
/**
|
|
6983
7137
|
* SYNC-01: Serialised permissions read with file-based locking.
|
|
7138
|
+
* CLI-LSTAT-HISTORY-01: Short-circuit on missing file; realpath:false avoids
|
|
7139
|
+
* lstat on a path that may not exist yet on a fresh install.
|
|
6984
7140
|
*/
|
|
6985
7141
|
async loadPermissions() {
|
|
6986
|
-
const path2 =
|
|
7142
|
+
const path2 = join14(this.baseDir, "vault", "permissions.json");
|
|
7143
|
+
if (!existsSync13(path2)) {
|
|
7144
|
+
return { trustedCommands: [], trustedPaths: [] };
|
|
7145
|
+
}
|
|
6987
7146
|
let release2;
|
|
6988
7147
|
try {
|
|
6989
|
-
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
|
|
6990
|
-
return this.permissionsMutex.run(async () => {
|
|
6991
|
-
if (
|
|
6992
|
-
|
|
6993
|
-
return JSON.parse(text);
|
|
7148
|
+
release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50, realpath: false });
|
|
7149
|
+
return await this.permissionsMutex.run(async () => {
|
|
7150
|
+
if (!existsSync13(path2)) {
|
|
7151
|
+
return { trustedCommands: [], trustedPaths: [] };
|
|
6994
7152
|
}
|
|
6995
|
-
|
|
7153
|
+
const text = await readFile12(path2, "utf8");
|
|
7154
|
+
return JSON.parse(text);
|
|
6996
7155
|
});
|
|
6997
7156
|
} finally {
|
|
6998
7157
|
if (release2) {
|
|
6999
7158
|
try {
|
|
7000
|
-
await lockfile.unlock(path2, { skipStale: true });
|
|
7159
|
+
await lockfile.unlock(path2, { skipStale: true, realpath: false });
|
|
7001
7160
|
} catch (e) {
|
|
7002
7161
|
console.warn(`Failed to unlock permissions file: ${e}`);
|
|
7003
7162
|
}
|
|
@@ -7012,7 +7171,7 @@ var init_Storage = __esm({
|
|
|
7012
7171
|
async backup(filePath, content) {
|
|
7013
7172
|
const filename = filePath.split("/").pop() || "file";
|
|
7014
7173
|
const timestamp = Date.now();
|
|
7015
|
-
const backupPath =
|
|
7174
|
+
const backupPath = join14(this.baseDir, "backups", `${filename}.${timestamp}.bak`);
|
|
7016
7175
|
await writeFile6(backupPath, content, "utf8");
|
|
7017
7176
|
if (process.platform !== "win32") {
|
|
7018
7177
|
chmodSync(backupPath, 384);
|
|
@@ -7023,121 +7182,6 @@ var init_Storage = __esm({
|
|
|
7023
7182
|
}
|
|
7024
7183
|
});
|
|
7025
7184
|
|
|
7026
|
-
// ../core/src/Settings.ts
|
|
7027
|
-
import { homedir as homedir8 } from "os";
|
|
7028
|
-
import { join as join14 } from "path";
|
|
7029
|
-
import { existsSync as existsSync13 } from "fs";
|
|
7030
|
-
import { readFile as readFile12 } from "fs/promises";
|
|
7031
|
-
async function readJson(path2) {
|
|
7032
|
-
try {
|
|
7033
|
-
if (!existsSync13(path2)) return null;
|
|
7034
|
-
const text = await readFile12(path2, "utf8");
|
|
7035
|
-
if (!text.trim()) return null;
|
|
7036
|
-
return JSON.parse(text);
|
|
7037
|
-
} catch {
|
|
7038
|
-
return null;
|
|
7039
|
-
}
|
|
7040
|
-
}
|
|
7041
|
-
function fromEnv(env) {
|
|
7042
|
-
const out = {};
|
|
7043
|
-
for (const [envKey, settingKey] of Object.entries(ENV_MAP)) {
|
|
7044
|
-
const raw = env[envKey];
|
|
7045
|
-
if (raw === void 0) continue;
|
|
7046
|
-
if (settingKey === "maxTokens") {
|
|
7047
|
-
const n = Number.parseInt(raw, 10);
|
|
7048
|
-
if (Number.isFinite(n)) out.maxTokens = n;
|
|
7049
|
-
} else if (settingKey === "temperature") {
|
|
7050
|
-
const n = Number.parseFloat(raw);
|
|
7051
|
-
if (Number.isFinite(n)) out.temperature = n;
|
|
7052
|
-
} else if (settingKey === "ollamaEnabled" || settingKey === "telemetryEnabled") {
|
|
7053
|
-
out[settingKey] = raw === "true" || raw === "1";
|
|
7054
|
-
} else if (settingKey === "defaultMode") {
|
|
7055
|
-
const v = raw;
|
|
7056
|
-
if (["default", "plan", "acceptEdits", "bypassPermissions"].includes(v)) {
|
|
7057
|
-
out.defaultMode = v;
|
|
7058
|
-
}
|
|
7059
|
-
} else {
|
|
7060
|
-
out[settingKey] = raw;
|
|
7061
|
-
}
|
|
7062
|
-
}
|
|
7063
|
-
return out;
|
|
7064
|
-
}
|
|
7065
|
-
function mergeSettings(base, override) {
|
|
7066
|
-
const out = { ...base, ...override };
|
|
7067
|
-
if (override.mcpServers) {
|
|
7068
|
-
out.mcpServers = { ...base.mcpServers, ...override.mcpServers };
|
|
7069
|
-
}
|
|
7070
|
-
if (override.hooks) {
|
|
7071
|
-
out.hooks = { ...base.hooks, ...override.hooks };
|
|
7072
|
-
}
|
|
7073
|
-
if (override.trustedCommands) {
|
|
7074
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7075
|
-
const merged = [];
|
|
7076
|
-
for (const c of [...base.trustedCommands, ...override.trustedCommands]) {
|
|
7077
|
-
if (!seen.has(c)) {
|
|
7078
|
-
seen.add(c);
|
|
7079
|
-
merged.push(c);
|
|
7080
|
-
}
|
|
7081
|
-
}
|
|
7082
|
-
out.trustedCommands = merged;
|
|
7083
|
-
}
|
|
7084
|
-
return out;
|
|
7085
|
-
}
|
|
7086
|
-
async function loadSettings(cwd = process.cwd(), env = process.env, warn) {
|
|
7087
|
-
const sources = [];
|
|
7088
|
-
const userPath = join14(homedir8() || ".", ".msapling", "settings.json");
|
|
7089
|
-
const projectPath = join14(cwd, ".msapling", "settings.json");
|
|
7090
|
-
const [user, project] = await Promise.all([readJson(userPath), readJson(projectPath)]);
|
|
7091
|
-
if (user) sources.push(userPath);
|
|
7092
|
-
if (project) sources.push(projectPath);
|
|
7093
|
-
let settings = DEFAULT_SETTINGS;
|
|
7094
|
-
if (user) settings = mergeSettings(settings, user);
|
|
7095
|
-
if (project) settings = mergeSettings(settings, project);
|
|
7096
|
-
settings = mergeSettings(settings, fromEnv(env));
|
|
7097
|
-
if (settings.temperature < 0 || settings.temperature > 2) {
|
|
7098
|
-
warn?.(`Settings: temperature out of range (${settings.temperature}); clamping to 0.7`);
|
|
7099
|
-
settings = { ...settings, temperature: 0.7 };
|
|
7100
|
-
}
|
|
7101
|
-
if (settings.maxTokens <= 0) {
|
|
7102
|
-
warn?.(`Settings: maxTokens must be positive; resetting to ${DEFAULT_SETTINGS.maxTokens}`);
|
|
7103
|
-
settings = { ...settings, maxTokens: DEFAULT_SETTINGS.maxTokens };
|
|
7104
|
-
}
|
|
7105
|
-
return { settings, sources };
|
|
7106
|
-
}
|
|
7107
|
-
var DEFAULT_SETTINGS, ENV_MAP;
|
|
7108
|
-
var init_Settings = __esm({
|
|
7109
|
-
"../core/src/Settings.ts"() {
|
|
7110
|
-
"use strict";
|
|
7111
|
-
init_esm_shims();
|
|
7112
|
-
DEFAULT_SETTINGS = {
|
|
7113
|
-
apiUrl: "https://api.msapling.com",
|
|
7114
|
-
defaultModel: "google/gemini-2.0-flash-001",
|
|
7115
|
-
defaultMode: "default",
|
|
7116
|
-
theme: "diamond",
|
|
7117
|
-
maxTokens: 4096,
|
|
7118
|
-
temperature: 0.7,
|
|
7119
|
-
ollamaEnabled: true,
|
|
7120
|
-
ollamaBaseUrl: "http://127.0.0.1:11434",
|
|
7121
|
-
telemetryEnabled: true,
|
|
7122
|
-
mcpServers: {},
|
|
7123
|
-
hooks: {},
|
|
7124
|
-
trustedCommands: [],
|
|
7125
|
-
shellEscapeEnabled: true
|
|
7126
|
-
};
|
|
7127
|
-
ENV_MAP = {
|
|
7128
|
-
MSAPLING_API_URL: "apiUrl",
|
|
7129
|
-
MSAPLING_DEFAULT_MODEL: "defaultModel",
|
|
7130
|
-
MSAPLING_DEFAULT_MODE: "defaultMode",
|
|
7131
|
-
MSAPLING_THEME: "theme",
|
|
7132
|
-
MSAPLING_MAX_TOKENS: "maxTokens",
|
|
7133
|
-
MSAPLING_TEMPERATURE: "temperature",
|
|
7134
|
-
MSAPLING_OLLAMA_ENABLED: "ollamaEnabled",
|
|
7135
|
-
MSAPLING_OLLAMA_BASE_URL: "ollamaBaseUrl",
|
|
7136
|
-
MSAPLING_TELEMETRY_ENABLED: "telemetryEnabled"
|
|
7137
|
-
};
|
|
7138
|
-
}
|
|
7139
|
-
});
|
|
7140
|
-
|
|
7141
7185
|
// ../core/src/mcp/client.ts
|
|
7142
7186
|
import { spawn as spawn8 } from "child_process";
|
|
7143
7187
|
var PROTOCOL_VERSION, CLIENT_INFO, MCPClientError, MCPClient, MCPRegistry;
|
|
@@ -8592,13 +8636,13 @@ ${rendered}` : rendered;
|
|
|
8592
8636
|
});
|
|
8593
8637
|
|
|
8594
8638
|
// src/commands/skill.ts
|
|
8595
|
-
import { existsSync as existsSync19, readdirSync as readdirSync2, statSync as
|
|
8639
|
+
import { existsSync as existsSync19, readdirSync as readdirSync2, statSync as statSync5 } from "fs";
|
|
8596
8640
|
import { readFile as readFile17 } from "fs/promises";
|
|
8597
8641
|
import { join as join19, resolve as resolve14 } from "path";
|
|
8598
8642
|
function findSkillsRoot(cwd) {
|
|
8599
8643
|
for (const candidate of SKILLS_DIRS) {
|
|
8600
8644
|
const full = resolve14(cwd, candidate);
|
|
8601
|
-
if (existsSync19(full) &&
|
|
8645
|
+
if (existsSync19(full) && statSync5(full).isDirectory()) return full;
|
|
8602
8646
|
}
|
|
8603
8647
|
return null;
|
|
8604
8648
|
}
|
|
@@ -8614,7 +8658,7 @@ function listAllSkills(root) {
|
|
|
8614
8658
|
const dir = join19(root, domain);
|
|
8615
8659
|
let s;
|
|
8616
8660
|
try {
|
|
8617
|
-
s =
|
|
8661
|
+
s = statSync5(dir);
|
|
8618
8662
|
} catch {
|
|
8619
8663
|
continue;
|
|
8620
8664
|
}
|
|
@@ -8718,7 +8762,7 @@ ${prompt}`;
|
|
|
8718
8762
|
// src/commands/benchmark.ts
|
|
8719
8763
|
import { homedir as homedir11 } from "os";
|
|
8720
8764
|
import { join as join20 } from "path";
|
|
8721
|
-
import { mkdirSync as
|
|
8765
|
+
import { mkdirSync as mkdirSync4, writeFileSync } from "fs";
|
|
8722
8766
|
function parseArgs(args2) {
|
|
8723
8767
|
let models = null;
|
|
8724
8768
|
let rounds = 1;
|
|
@@ -8834,7 +8878,7 @@ HW at start: ${hw.cores}-core ${hw.platform} | CPU ${hw.cpuPct}% | RAM ${hw.ramP
|
|
|
8834
8878
|
);
|
|
8835
8879
|
try {
|
|
8836
8880
|
const dir = join20(homedir11(), ".msapling", "benchmarks");
|
|
8837
|
-
|
|
8881
|
+
mkdirSync4(dir, { recursive: true });
|
|
8838
8882
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 16);
|
|
8839
8883
|
const file = join20(dir, `${ts}.json`);
|
|
8840
8884
|
const run = {
|
|
@@ -9085,7 +9129,7 @@ var init_theme = __esm({
|
|
|
9085
9129
|
import { join as join21 } from "path";
|
|
9086
9130
|
import { homedir as homedir12 } from "os";
|
|
9087
9131
|
import { existsSync as existsSync20 } from "fs";
|
|
9088
|
-
import { readFile as readFile18, writeFile as writeFile9
|
|
9132
|
+
import { readFile as readFile18, writeFile as writeFile9 } from "fs/promises";
|
|
9089
9133
|
async function persistTheme(storage, themeName) {
|
|
9090
9134
|
const settingsPath = join21(homedir12(), ".msapling", "settings.json");
|
|
9091
9135
|
let existing = {};
|
|
@@ -9097,7 +9141,7 @@ async function persistTheme(storage, themeName) {
|
|
|
9097
9141
|
} catch {
|
|
9098
9142
|
}
|
|
9099
9143
|
existing["theme"] = themeName;
|
|
9100
|
-
|
|
9144
|
+
ensureConfigDir(join21(homedir12(), ".msapling"));
|
|
9101
9145
|
await writeFile9(settingsPath, JSON.stringify(existing, null, 2), "utf8");
|
|
9102
9146
|
}
|
|
9103
9147
|
var VALID_THEMES, themeCommand;
|
|
@@ -9106,6 +9150,7 @@ var init_theme2 = __esm({
|
|
|
9106
9150
|
"use strict";
|
|
9107
9151
|
init_esm_shims();
|
|
9108
9152
|
init_theme();
|
|
9153
|
+
init_src3();
|
|
9109
9154
|
VALID_THEMES = ["diamond", "onyx", "mono"];
|
|
9110
9155
|
themeCommand = {
|
|
9111
9156
|
name: "theme",
|
|
@@ -9258,7 +9303,7 @@ var init_feedback = __esm({
|
|
|
9258
9303
|
// src/commands/export.ts
|
|
9259
9304
|
import { homedir as homedir13 } from "os";
|
|
9260
9305
|
import { join as join24 } from "path";
|
|
9261
|
-
import { writeFile as writeFile10, mkdir as
|
|
9306
|
+
import { writeFile as writeFile10, mkdir as mkdir8 } from "fs/promises";
|
|
9262
9307
|
function formatTimestamp(date) {
|
|
9263
9308
|
return date.toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
|
|
9264
9309
|
}
|
|
@@ -9323,7 +9368,7 @@ var init_export = __esm({
|
|
|
9323
9368
|
}
|
|
9324
9369
|
try {
|
|
9325
9370
|
const dir = join24(outputPath, "..");
|
|
9326
|
-
await
|
|
9371
|
+
await mkdir8(dir, { recursive: true });
|
|
9327
9372
|
await writeFile10(outputPath, content, "utf8");
|
|
9328
9373
|
context.addMessage("system", `Exported to: ${outputPath}`);
|
|
9329
9374
|
} catch (e) {
|
|
@@ -9519,7 +9564,7 @@ var init_plan = __esm({
|
|
|
9519
9564
|
// src/commands/note.ts
|
|
9520
9565
|
import { homedir as homedir14 } from "os";
|
|
9521
9566
|
import { join as join25 } from "path";
|
|
9522
|
-
import {
|
|
9567
|
+
import { existsSync as existsSync23 } from "fs";
|
|
9523
9568
|
import { readFile as readFile21, writeFile as writeFile11 } from "fs/promises";
|
|
9524
9569
|
function getNotesFilePath() {
|
|
9525
9570
|
return join25(homedir14(), ".msapling", "notes.json");
|
|
@@ -9537,7 +9582,7 @@ async function readNotes(filePath = getNotesFilePath()) {
|
|
|
9537
9582
|
}
|
|
9538
9583
|
async function writeNotes(notes, filePath = getNotesFilePath()) {
|
|
9539
9584
|
const dir = join25(homedir14(), ".msapling");
|
|
9540
|
-
|
|
9585
|
+
ensureConfigDir(dir);
|
|
9541
9586
|
await writeFile11(filePath, JSON.stringify(notes, null, 2), "utf8");
|
|
9542
9587
|
}
|
|
9543
9588
|
function formatTimestamp2(iso) {
|
|
@@ -11288,7 +11333,7 @@ __export(server_exports, {
|
|
|
11288
11333
|
runStdio: () => runStdio,
|
|
11289
11334
|
runStdioWithRegistry: () => runStdioWithRegistry
|
|
11290
11335
|
});
|
|
11291
|
-
import { readdirSync as readdirSync3, readFileSync, statSync as
|
|
11336
|
+
import { readdirSync as readdirSync3, readFileSync, statSync as statSync6 } from "fs";
|
|
11292
11337
|
import { join as join26, relative as relative14, resolve as resolve16 } from "path";
|
|
11293
11338
|
function asResult2(text, isError = false) {
|
|
11294
11339
|
return { content: [{ type: "text", text }], ...isError ? { isError: true } : {} };
|
|
@@ -11312,7 +11357,7 @@ function buildFileTree(root, maxFiles) {
|
|
|
11312
11357
|
const full = join26(dir, name);
|
|
11313
11358
|
let s;
|
|
11314
11359
|
try {
|
|
11315
|
-
s =
|
|
11360
|
+
s = statSync6(full);
|
|
11316
11361
|
} catch {
|
|
11317
11362
|
continue;
|
|
11318
11363
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtreeai/msapling-cli",
|
|
3
|
-
"version": "2.3.6-beta.
|
|
3
|
+
"version": "2.3.6-beta.3",
|
|
4
4
|
"description": "MSapling CLI — React/Ink terminal client for the MSapling backend (chat, projects, MDrive, agent tools). Proprietary, see LICENSE.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "MSapling Team",
|