@mtreeai/msapling-cli 2.3.6-beta.1 → 2.3.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +326 -308
  2. 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: mkdir10 } = await import("fs/promises");
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 mkdir10(join27(homedir15(), ".msapling", "backups"), { recursive: true });
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: mkdir10 } = await import("fs/promises");
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 mkdir10(join10(homedir15(), ".msapling", "backups"), { recursive: true });
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(fs) {
5135
+ function patch(fs2) {
5136
5136
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
5137
- patchLchmod(fs);
5138
- }
5139
- if (!fs.lutimes) {
5140
- patchLutimes(fs);
5141
- }
5142
- fs.chown = chownFix(fs.chown);
5143
- fs.fchown = chownFix(fs.fchown);
5144
- fs.lchown = chownFix(fs.lchown);
5145
- fs.chmod = chmodFix(fs.chmod);
5146
- fs.fchmod = chmodFix(fs.fchmod);
5147
- fs.lchmod = chmodFix(fs.lchmod);
5148
- fs.chownSync = chownFixSync(fs.chownSync);
5149
- fs.fchownSync = chownFixSync(fs.fchownSync);
5150
- fs.lchownSync = chownFixSync(fs.lchownSync);
5151
- fs.chmodSync = chmodFixSync(fs.chmodSync);
5152
- fs.fchmodSync = chmodFixSync(fs.fchmodSync);
5153
- fs.lchmodSync = chmodFixSync(fs.lchmodSync);
5154
- fs.stat = statFix(fs.stat);
5155
- fs.fstat = statFix(fs.fstat);
5156
- fs.lstat = statFix(fs.lstat);
5157
- fs.statSync = statFixSync(fs.statSync);
5158
- fs.fstatSync = statFixSync(fs.fstatSync);
5159
- fs.lstatSync = statFixSync(fs.lstatSync);
5160
- if (fs.chmod && !fs.lchmod) {
5161
- fs.lchmod = function(path2, mode, cb) {
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
- fs.lchmodSync = function() {
5164
+ fs2.lchmodSync = function() {
5165
5165
  };
5166
5166
  }
5167
- if (fs.chown && !fs.lchown) {
5168
- fs.lchown = function(path2, uid, gid, cb) {
5167
+ if (fs2.chown && !fs2.lchown) {
5168
+ fs2.lchown = function(path2, uid, gid, cb) {
5169
5169
  if (cb) process.nextTick(cb);
5170
5170
  };
5171
- fs.lchownSync = function() {
5171
+ fs2.lchownSync = function() {
5172
5172
  };
5173
5173
  }
5174
5174
  if (platform2 === "win32") {
5175
- fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
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
- fs.stat(to, function(stater, st) {
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
- })(fs.rename);
5198
+ })(fs2.rename);
5199
5199
  }
5200
- fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
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(fs, fd, buffer, offset, length, position, callback);
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(fs, fd, buffer, offset, length, position, callback);
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
- })(fs.read);
5218
- fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
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(fs, fd, buffer, offset, length, position);
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
- })(fs.readSync);
5234
- function patchLchmod(fs2) {
5235
- fs2.lchmod = function(path2, mode, callback) {
5236
- fs2.open(
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
- fs2.fchmod(fd, mode, function(err2) {
5246
- fs2.close(fd, function(err22) {
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
- fs2.lchmodSync = function(path2, mode) {
5254
- var fd = fs2.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
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 = fs2.fchmodSync(fd, mode);
5258
+ ret = fs3.fchmodSync(fd, mode);
5259
5259
  threw = false;
5260
5260
  } finally {
5261
5261
  if (threw) {
5262
5262
  try {
5263
- fs2.closeSync(fd);
5263
+ fs3.closeSync(fd);
5264
5264
  } catch (er) {
5265
5265
  }
5266
5266
  } else {
5267
- fs2.closeSync(fd);
5267
+ fs3.closeSync(fd);
5268
5268
  }
5269
5269
  }
5270
5270
  return ret;
5271
5271
  };
5272
5272
  }
5273
- function patchLutimes(fs2) {
5274
- if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
5275
- fs2.lutimes = function(path2, at, mt, cb) {
5276
- fs2.open(path2, constants.O_SYMLINK, function(er, fd) {
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
- fs2.futimes(fd, at, mt, function(er2) {
5282
- fs2.close(fd, function(er22) {
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
- fs2.lutimesSync = function(path2, at, mt) {
5289
- var fd = fs2.openSync(path2, constants.O_SYMLINK);
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 = fs2.futimesSync(fd, at, mt);
5293
+ ret = fs3.futimesSync(fd, at, mt);
5294
5294
  threw = false;
5295
5295
  } finally {
5296
5296
  if (threw) {
5297
5297
  try {
5298
- fs2.closeSync(fd);
5298
+ fs3.closeSync(fd);
5299
5299
  } catch (er) {
5300
5300
  }
5301
5301
  } else {
5302
- fs2.closeSync(fd);
5302
+ fs3.closeSync(fd);
5303
5303
  }
5304
5304
  }
5305
5305
  return ret;
5306
5306
  };
5307
- } else if (fs2.futimes) {
5308
- fs2.lutimes = function(_a, _b, _c, cb) {
5307
+ } else if (fs3.futimes) {
5308
+ fs3.lutimes = function(_a, _b, _c, cb) {
5309
5309
  if (cb) process.nextTick(cb);
5310
5310
  };
5311
- fs2.lutimesSync = function() {
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(fs, target, mode, function(er) {
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(fs, target, mode);
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(fs, target, uid, gid, function(er) {
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(fs, target, uid, gid);
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(fs, target, options, callback) : orig.call(fs, target, callback);
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(fs, target, options) : orig.call(fs, target);
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(fs) {
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
- fs.open(this.path, this.flags, this.mode, function(err, fd) {
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 = fs.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 fs = __require("fs");
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 (!fs[gracefulQueue]) {
5556
+ if (!fs2[gracefulQueue]) {
5557
5557
  queue = global[gracefulQueue] || [];
5558
- publishQueue(fs, queue);
5559
- fs.close = (function(fs$close) {
5558
+ publishQueue(fs2, queue);
5559
+ fs2.close = (function(fs$close) {
5560
5560
  function close(fd, cb) {
5561
- return fs$close.call(fs, fd, function(err) {
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
- })(fs.close);
5574
- fs.closeSync = (function(fs$closeSync) {
5573
+ })(fs2.close);
5574
+ fs2.closeSync = (function(fs$closeSync) {
5575
5575
  function closeSync(fd) {
5576
- fs$closeSync.apply(fs, arguments);
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
- })(fs.closeSync);
5583
+ })(fs2.closeSync);
5584
5584
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
5585
5585
  process.on("exit", function() {
5586
- debug(fs[gracefulQueue]);
5587
- __require("assert").equal(fs[gracefulQueue].length, 0);
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, fs[gracefulQueue]);
5594
- }
5595
- module.exports = patch(clone(fs));
5596
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
5597
- module.exports = patch(fs);
5598
- fs.__patched = true;
5599
- }
5600
- function patch(fs2) {
5601
- polyfills(fs2);
5602
- fs2.gracefulify = patch;
5603
- fs2.createReadStream = createReadStream;
5604
- fs2.createWriteStream = createWriteStream;
5605
- var fs$readFile = fs2.readFile;
5606
- fs2.readFile = readFile23;
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 = fs2.writeFile;
5623
- fs2.writeFile = writeFile12;
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 = fs2.appendFile;
5639
+ var fs$appendFile = fs3.appendFile;
5640
5640
  if (fs$appendFile)
5641
- fs2.appendFile = appendFile;
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 = fs2.copyFile;
5657
+ var fs$copyFile = fs3.copyFile;
5658
5658
  if (fs$copyFile)
5659
- fs2.copyFile = copyFile2;
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 = fs2.readdir;
5678
- fs2.readdir = readdir4;
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(fs2);
5719
+ var legStreams = legacy(fs3);
5720
5720
  ReadStream = legStreams.ReadStream;
5721
5721
  WriteStream = legStreams.WriteStream;
5722
5722
  }
5723
- var fs$ReadStream = fs2.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 = fs2.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(fs2, "ReadStream", {
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(fs2, "WriteStream", {
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(fs2, "FileReadStream", {
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(fs2, "FileWriteStream", {
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 fs2.ReadStream(path2, options);
5814
+ return new fs3.ReadStream(path2, options);
5815
5815
  }
5816
5816
  function createWriteStream(path2, options) {
5817
- return new fs2.WriteStream(path2, options);
5817
+ return new fs3.WriteStream(path2, options);
5818
5818
  }
5819
- var fs$open = fs2.open;
5820
- fs2.open = open;
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 fs2;
5836
+ return fs3;
5837
5837
  }
5838
5838
  function enqueue(elem) {
5839
5839
  debug("ENQUEUE", elem[0].name, elem[1]);
5840
- fs[gracefulQueue].push(elem);
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 < fs[gracefulQueue].length; ++i) {
5847
- if (fs[gracefulQueue][i].length > 2) {
5848
- fs[gracefulQueue][i][3] = now;
5849
- fs[gracefulQueue][i][4] = now;
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 (fs[gracefulQueue].length === 0)
5857
+ if (fs2[gracefulQueue].length === 0)
5858
5858
  return;
5859
- var elem = fs[gracefulQueue].shift();
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
- fs[gracefulQueue].push(elem);
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, fs, callback) {
6328
- const cachedPrecision = fs[cacheSymbol];
6327
+ function probe(file, fs2, callback) {
6328
+ const cachedPrecision = fs2[cacheSymbol];
6329
6329
  if (cachedPrecision) {
6330
- return fs.stat(file, (err, stat5) => {
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
- fs.utimes(file, mtime, mtime, (err) => {
6338
+ fs2.utimes(file, mtime, mtime, (err) => {
6339
6339
  if (err) {
6340
6340
  return callback(err);
6341
6341
  }
6342
- fs.stat(file, (err2, stat5) => {
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(fs, cacheSymbol, { value: precision });
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 fs = require_graceful_fs();
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 fs = require_graceful_fs();
6608
- function createSyncFs(fs2) {
6607
+ var fs2 = require_graceful_fs();
6608
+ function createSyncFs(fs3) {
6609
6609
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
6610
- const newFs = { ...fs2 };
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 = fs2[`${method}Sync`](...args2);
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 || 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/Storage.ts
6767
- import { join as join13 } from "path";
6766
+ // ../core/src/Settings.ts
6768
6767
  import { homedir as homedir7 } from "os";
6769
- import { chmodSync, existsSync as existsSync12, renameSync, unlinkSync } from "fs";
6770
- import { mkdir as mkdir6, writeFile as writeFile6, readFile as readFile11 } from "fs/promises";
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 = join13(homedir7(), ".msapling");
6929
+ this.baseDir = join14(homedir8(), ".msapling");
6798
6930
  this._ready = this.ensureDirs();
6799
6931
  }
6800
6932
  async ensureDirs() {
6801
6933
  try {
6802
- await mkdir6(this.baseDir, { recursive: true });
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 = join13(this.baseDir, sub);
6806
- await mkdir6(path2, { recursive: true });
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 = join13(this.baseDir, "vault", "token");
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 (existsSync12(filePath)) {
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 = join13(this.baseDir, "vault", "token");
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 (existsSync12(filePath)) {
6853
- const text = await readFile11(filePath, "utf8");
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 = join13(this.baseDir, "vault", "token");
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 (existsSync12(filePath)) {
6872
- const fs = await import("fs/promises");
6873
- await fs.unlink(filePath);
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}`);
@@ -6886,7 +7018,7 @@ var init_Storage = __esm({
6886
7018
  * 2. Partial writes don't corrupt the JSON (atomic rename)
6887
7019
  */
6888
7020
  async saveHistory(history) {
6889
- const path2 = join13(this.baseDir, "history", "shell_history.json");
7021
+ const path2 = join14(this.baseDir, "history", "shell_history.json");
6890
7022
  let release2;
6891
7023
  try {
6892
7024
  release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
@@ -6895,12 +7027,12 @@ var init_Storage = __esm({
6895
7027
  const content = JSON.stringify(history, null, 2);
6896
7028
  await writeFile6(tmpPath, content, "utf8");
6897
7029
  try {
6898
- renameSync(tmpPath, path2);
7030
+ renameSync2(tmpPath, path2);
6899
7031
  } catch (e) {
6900
7032
  try {
6901
- if (existsSync12(tmpPath)) {
6902
- const fs = await import("fs/promises");
6903
- await fs.unlink(tmpPath);
7033
+ if (existsSync13(tmpPath)) {
7034
+ const fs2 = await import("fs/promises");
7035
+ await fs2.unlink(tmpPath);
6904
7036
  }
6905
7037
  } catch {
6906
7038
  }
@@ -6923,13 +7055,13 @@ var init_Storage = __esm({
6923
7055
  * in-progress write from another process always sees a complete, valid JSON.
6924
7056
  */
6925
7057
  async loadHistory() {
6926
- const path2 = join13(this.baseDir, "history", "shell_history.json");
7058
+ const path2 = join14(this.baseDir, "history", "shell_history.json");
6927
7059
  let release2;
6928
7060
  try {
6929
7061
  release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
6930
7062
  return this.historyMutex.run(async () => {
6931
- if (existsSync12(path2)) {
6932
- const text = await readFile11(path2, "utf8");
7063
+ if (existsSync13(path2)) {
7064
+ const text = await readFile12(path2, "utf8");
6933
7065
  return JSON.parse(text);
6934
7066
  }
6935
7067
  return [];
@@ -6948,7 +7080,7 @@ var init_Storage = __esm({
6948
7080
  * SYNC-01: Serialised permissions write with file-based locking.
6949
7081
  */
6950
7082
  async savePermissions(permissions) {
6951
- const path2 = join13(this.baseDir, "vault", "permissions.json");
7083
+ const path2 = join14(this.baseDir, "vault", "permissions.json");
6952
7084
  let release2;
6953
7085
  try {
6954
7086
  release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
@@ -6957,12 +7089,12 @@ var init_Storage = __esm({
6957
7089
  const content = JSON.stringify(permissions, null, 2);
6958
7090
  await writeFile6(tmpPath, content, "utf8");
6959
7091
  try {
6960
- renameSync(tmpPath, path2);
7092
+ renameSync2(tmpPath, path2);
6961
7093
  } catch (e) {
6962
7094
  try {
6963
- if (existsSync12(tmpPath)) {
6964
- const fs = await import("fs/promises");
6965
- await fs.unlink(tmpPath);
7095
+ if (existsSync13(tmpPath)) {
7096
+ const fs2 = await import("fs/promises");
7097
+ await fs2.unlink(tmpPath);
6966
7098
  }
6967
7099
  } catch {
6968
7100
  }
@@ -6983,13 +7115,13 @@ var init_Storage = __esm({
6983
7115
  * SYNC-01: Serialised permissions read with file-based locking.
6984
7116
  */
6985
7117
  async loadPermissions() {
6986
- const path2 = join13(this.baseDir, "vault", "permissions.json");
7118
+ const path2 = join14(this.baseDir, "vault", "permissions.json");
6987
7119
  let release2;
6988
7120
  try {
6989
7121
  release2 = await lockfile.lock(path2, { retries: 5, retryWait: 50 });
6990
7122
  return this.permissionsMutex.run(async () => {
6991
- if (existsSync12(path2)) {
6992
- const text = await readFile11(path2, "utf8");
7123
+ if (existsSync13(path2)) {
7124
+ const text = await readFile12(path2, "utf8");
6993
7125
  return JSON.parse(text);
6994
7126
  }
6995
7127
  return { trustedCommands: [], trustedPaths: [] };
@@ -7012,7 +7144,7 @@ var init_Storage = __esm({
7012
7144
  async backup(filePath, content) {
7013
7145
  const filename = filePath.split("/").pop() || "file";
7014
7146
  const timestamp = Date.now();
7015
- const backupPath = join13(this.baseDir, "backups", `${filename}.${timestamp}.bak`);
7147
+ const backupPath = join14(this.baseDir, "backups", `${filename}.${timestamp}.bak`);
7016
7148
  await writeFile6(backupPath, content, "utf8");
7017
7149
  if (process.platform !== "win32") {
7018
7150
  chmodSync(backupPath, 384);
@@ -7023,121 +7155,6 @@ var init_Storage = __esm({
7023
7155
  }
7024
7156
  });
7025
7157
 
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
7158
  // ../core/src/mcp/client.ts
7142
7159
  import { spawn as spawn8 } from "child_process";
7143
7160
  var PROTOCOL_VERSION, CLIENT_INFO, MCPClientError, MCPClient, MCPRegistry;
@@ -8592,13 +8609,13 @@ ${rendered}` : rendered;
8592
8609
  });
8593
8610
 
8594
8611
  // src/commands/skill.ts
8595
- import { existsSync as existsSync19, readdirSync as readdirSync2, statSync as statSync4 } from "fs";
8612
+ import { existsSync as existsSync19, readdirSync as readdirSync2, statSync as statSync5 } from "fs";
8596
8613
  import { readFile as readFile17 } from "fs/promises";
8597
8614
  import { join as join19, resolve as resolve14 } from "path";
8598
8615
  function findSkillsRoot(cwd) {
8599
8616
  for (const candidate of SKILLS_DIRS) {
8600
8617
  const full = resolve14(cwd, candidate);
8601
- if (existsSync19(full) && statSync4(full).isDirectory()) return full;
8618
+ if (existsSync19(full) && statSync5(full).isDirectory()) return full;
8602
8619
  }
8603
8620
  return null;
8604
8621
  }
@@ -8614,7 +8631,7 @@ function listAllSkills(root) {
8614
8631
  const dir = join19(root, domain);
8615
8632
  let s;
8616
8633
  try {
8617
- s = statSync4(dir);
8634
+ s = statSync5(dir);
8618
8635
  } catch {
8619
8636
  continue;
8620
8637
  }
@@ -8718,7 +8735,7 @@ ${prompt}`;
8718
8735
  // src/commands/benchmark.ts
8719
8736
  import { homedir as homedir11 } from "os";
8720
8737
  import { join as join20 } from "path";
8721
- import { mkdirSync as mkdirSync3, writeFileSync } from "fs";
8738
+ import { mkdirSync as mkdirSync4, writeFileSync } from "fs";
8722
8739
  function parseArgs(args2) {
8723
8740
  let models = null;
8724
8741
  let rounds = 1;
@@ -8834,7 +8851,7 @@ HW at start: ${hw.cores}-core ${hw.platform} | CPU ${hw.cpuPct}% | RAM ${hw.ramP
8834
8851
  );
8835
8852
  try {
8836
8853
  const dir = join20(homedir11(), ".msapling", "benchmarks");
8837
- mkdirSync3(dir, { recursive: true });
8854
+ mkdirSync4(dir, { recursive: true });
8838
8855
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 16);
8839
8856
  const file = join20(dir, `${ts}.json`);
8840
8857
  const run = {
@@ -9085,7 +9102,7 @@ var init_theme = __esm({
9085
9102
  import { join as join21 } from "path";
9086
9103
  import { homedir as homedir12 } from "os";
9087
9104
  import { existsSync as existsSync20 } from "fs";
9088
- import { readFile as readFile18, writeFile as writeFile9, mkdir as mkdir8 } from "fs/promises";
9105
+ import { readFile as readFile18, writeFile as writeFile9 } from "fs/promises";
9089
9106
  async function persistTheme(storage, themeName) {
9090
9107
  const settingsPath = join21(homedir12(), ".msapling", "settings.json");
9091
9108
  let existing = {};
@@ -9097,7 +9114,7 @@ async function persistTheme(storage, themeName) {
9097
9114
  } catch {
9098
9115
  }
9099
9116
  existing["theme"] = themeName;
9100
- await mkdir8(join21(homedir12(), ".msapling"), { recursive: true });
9117
+ ensureConfigDir(join21(homedir12(), ".msapling"));
9101
9118
  await writeFile9(settingsPath, JSON.stringify(existing, null, 2), "utf8");
9102
9119
  }
9103
9120
  var VALID_THEMES, themeCommand;
@@ -9106,6 +9123,7 @@ var init_theme2 = __esm({
9106
9123
  "use strict";
9107
9124
  init_esm_shims();
9108
9125
  init_theme();
9126
+ init_src3();
9109
9127
  VALID_THEMES = ["diamond", "onyx", "mono"];
9110
9128
  themeCommand = {
9111
9129
  name: "theme",
@@ -9258,7 +9276,7 @@ var init_feedback = __esm({
9258
9276
  // src/commands/export.ts
9259
9277
  import { homedir as homedir13 } from "os";
9260
9278
  import { join as join24 } from "path";
9261
- import { writeFile as writeFile10, mkdir as mkdir9 } from "fs/promises";
9279
+ import { writeFile as writeFile10, mkdir as mkdir8 } from "fs/promises";
9262
9280
  function formatTimestamp(date) {
9263
9281
  return date.toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
9264
9282
  }
@@ -9323,7 +9341,7 @@ var init_export = __esm({
9323
9341
  }
9324
9342
  try {
9325
9343
  const dir = join24(outputPath, "..");
9326
- await mkdir9(dir, { recursive: true });
9344
+ await mkdir8(dir, { recursive: true });
9327
9345
  await writeFile10(outputPath, content, "utf8");
9328
9346
  context.addMessage("system", `Exported to: ${outputPath}`);
9329
9347
  } catch (e) {
@@ -9519,7 +9537,7 @@ var init_plan = __esm({
9519
9537
  // src/commands/note.ts
9520
9538
  import { homedir as homedir14 } from "os";
9521
9539
  import { join as join25 } from "path";
9522
- import { mkdirSync as mkdirSync4, existsSync as existsSync23 } from "fs";
9540
+ import { existsSync as existsSync23 } from "fs";
9523
9541
  import { readFile as readFile21, writeFile as writeFile11 } from "fs/promises";
9524
9542
  function getNotesFilePath() {
9525
9543
  return join25(homedir14(), ".msapling", "notes.json");
@@ -9537,7 +9555,7 @@ async function readNotes(filePath = getNotesFilePath()) {
9537
9555
  }
9538
9556
  async function writeNotes(notes, filePath = getNotesFilePath()) {
9539
9557
  const dir = join25(homedir14(), ".msapling");
9540
- mkdirSync4(dir, { recursive: true });
9558
+ ensureConfigDir(dir);
9541
9559
  await writeFile11(filePath, JSON.stringify(notes, null, 2), "utf8");
9542
9560
  }
9543
9561
  function formatTimestamp2(iso) {
@@ -11288,7 +11306,7 @@ __export(server_exports, {
11288
11306
  runStdio: () => runStdio,
11289
11307
  runStdioWithRegistry: () => runStdioWithRegistry
11290
11308
  });
11291
- import { readdirSync as readdirSync3, readFileSync, statSync as statSync5 } from "fs";
11309
+ import { readdirSync as readdirSync3, readFileSync, statSync as statSync6 } from "fs";
11292
11310
  import { join as join26, relative as relative14, resolve as resolve16 } from "path";
11293
11311
  function asResult2(text, isError = false) {
11294
11312
  return { content: [{ type: "text", text }], ...isError ? { isError: true } : {} };
@@ -11312,7 +11330,7 @@ function buildFileTree(root, maxFiles) {
11312
11330
  const full = join26(dir, name);
11313
11331
  let s;
11314
11332
  try {
11315
- s = statSync5(full);
11333
+ s = statSync6(full);
11316
11334
  } catch {
11317
11335
  continue;
11318
11336
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtreeai/msapling-cli",
3
- "version": "2.3.6-beta.1",
3
+ "version": "2.3.6-beta.2",
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",