blun-king-cli 2.5.1 → 2.5.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/bin/blun.js +21 -0
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -2228,6 +2228,24 @@ async function main() {
2228
2228
  }
2229
2229
  }
2230
2230
 
2231
+ // Restore last workdir if still in home/default dir
2232
+ var lastWdFile = path.join(CONFIG_DIR, "last-workdir.json");
2233
+ if (!dirIdx || dirIdx === -1) {
2234
+ try {
2235
+ if (fs.existsSync(lastWdFile)) {
2236
+ var lastWd = JSON.parse(fs.readFileSync(lastWdFile, "utf8"));
2237
+ if (lastWd.dir && fs.existsSync(lastWd.dir) && config.workdir === process.cwd()) {
2238
+ // Only auto-restore if user didn't explicitly cd somewhere
2239
+ var homeDir = require("os").homedir();
2240
+ if (config.workdir === homeDir || config.workdir === homeDir.replace(/\\/g, "/")) {
2241
+ config.workdir = lastWd.dir;
2242
+ process.chdir(config.workdir);
2243
+ }
2244
+ }
2245
+ }
2246
+ } catch(e) {}
2247
+ }
2248
+
2231
2249
  if (!process.argv.includes("--no-workdir-prompt") && !process.argv.includes("--trust")) {
2232
2250
  var trustedDirs = [];
2233
2251
  var trustFile = path.join(CONFIG_DIR, "trusted.json");
@@ -2264,6 +2282,7 @@ async function main() {
2264
2282
  rlDir.close();
2265
2283
  if (newDir.trim() && fs.existsSync(newDir.trim())) {
2266
2284
  config.workdir = newDir.trim();
2285
+ try { fs.writeFileSync(path.join(CONFIG_DIR, "last-workdir.json"), JSON.stringify({ dir: config.workdir, ts: new Date().toISOString() })); } catch(e) {}
2267
2286
  } else {
2268
2287
  printError("Invalid path, using current directory.");
2269
2288
  }
@@ -2568,6 +2587,8 @@ async function main() {
2568
2587
  if (key === "\x03" || key === "\x04") {
2569
2588
  session.history = chatHistory.slice(-50);
2570
2589
  saveSessionHistory(session);
2590
+ // Save last workdir for next session
2591
+ try { fs.writeFileSync(path.join(CONFIG_DIR, "last-workdir.json"), JSON.stringify({ dir: config.workdir, ts: new Date().toISOString() })); } catch(e) {}
2571
2592
  eraseUI();
2572
2593
  console.log(C.dim + "\nBye." + C.reset);
2573
2594
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"