blun-king-cli 2.5.0 → 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.
- package/bin/blun.js +24 -3
- 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
|
}
|
|
@@ -2369,9 +2388,9 @@ async function main() {
|
|
|
2369
2388
|
lines.push(C.brightBlue + " \u2570" + "\u2500".repeat(inner) + "\u256F" + C.reset);
|
|
2370
2389
|
|
|
2371
2390
|
// Status bar
|
|
2372
|
-
var
|
|
2373
|
-
var permMode =
|
|
2374
|
-
var isDangerous = process.argv.includes("--dangerously-skip-permissions") || permMode === "allow";
|
|
2391
|
+
var permData = loadPermissions();
|
|
2392
|
+
var permMode = permData.mode || "ask";
|
|
2393
|
+
var isDangerous = process.argv.includes("--dangerously-skip-permissions") || permMode === "allow" || permMode === "allow-all";
|
|
2375
2394
|
var permLabel = isDangerous ? "GOD MODE" : permMode === "deny" ? "LOCKED" : "ask permission";
|
|
2376
2395
|
var permIcon = isDangerous ? "\u26A1" : permMode === "deny" ? "\u2718" : "\u2753";
|
|
2377
2396
|
var permColor = isDangerous ? C.red + C.bold : permMode === "deny" ? C.red : C.yellow;
|
|
@@ -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);
|