blun-king-cli 5.2.0 → 5.2.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/blun-cli.js +41 -53
- package/package.json +1 -1
package/blun-cli.js
CHANGED
|
@@ -2595,14 +2595,8 @@ async function main() {
|
|
|
2595
2595
|
}
|
|
2596
2596
|
|
|
2597
2597
|
if (!process.argv.includes("--no-workdir-prompt") && !process.argv.includes("--trust")) {
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
if (fs.existsSync(trustFile)) {
|
|
2601
|
-
try { trustedDirs = JSON.parse(fs.readFileSync(trustFile, "utf8")); } catch(e) {}
|
|
2602
|
-
}
|
|
2603
|
-
var isTrusted = trustedDirs.includes(process.cwd());
|
|
2604
|
-
|
|
2605
|
-
if (!isTrusted) {
|
|
2598
|
+
// Always ask — like Claude Code (every session)
|
|
2599
|
+
{
|
|
2606
2600
|
console.log("");
|
|
2607
2601
|
console.log(C.yellow + C.bold + " Quick safety check:" + C.reset);
|
|
2608
2602
|
console.log(C.gray + " Is " + C.brightWhite + process.cwd() + C.gray + " a project you trust?" + C.reset);
|
|
@@ -2652,56 +2646,50 @@ async function main() {
|
|
|
2652
2646
|
}
|
|
2653
2647
|
}
|
|
2654
2648
|
|
|
2655
|
-
// API Key
|
|
2656
|
-
// Test if key actually works by hitting /health
|
|
2657
|
-
var hasKey = false;
|
|
2649
|
+
// API Key — ALWAYS prompt (like Claude Code login)
|
|
2658
2650
|
var existingKey = config.api.key || config.auth.api_key || "";
|
|
2651
|
+
console.log("");
|
|
2652
|
+
console.log(C.yellow + C.bold + " API Key" + C.reset);
|
|
2659
2653
|
if (existingKey.length > 3) {
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
} catch(e) { hasKey = false; }
|
|
2664
|
-
}
|
|
2665
|
-
if (!hasKey) {
|
|
2666
|
-
console.log("");
|
|
2667
|
-
console.log(C.yellow + C.bold + " API Key required" + C.reset);
|
|
2668
|
-
if (existingKey.length > 3) {
|
|
2669
|
-
console.log(C.red + " Saved key didn't work — please re-enter." + C.reset);
|
|
2670
|
-
}
|
|
2654
|
+
console.log(C.gray + " Current: " + C.green + existingKey.slice(0, 8) + "..." + C.reset);
|
|
2655
|
+
console.log(C.gray + " Press Enter to keep, or type a new key:" + C.reset);
|
|
2656
|
+
} else {
|
|
2671
2657
|
console.log(C.gray + " Enter your BLUN King API key:" + C.reset);
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
if (key === "\x7f" || key === "\b") {
|
|
2689
|
-
if (buf.length > 0) { buf = buf.slice(0, -1); process.stdout.write("\b \b"); }
|
|
2690
|
-
return;
|
|
2691
|
-
}
|
|
2692
|
-
buf += key;
|
|
2693
|
-
process.stdout.write("*");
|
|
2658
|
+
}
|
|
2659
|
+
process.stdout.write(C.brightBlue + " API Key: " + C.reset);
|
|
2660
|
+
var apiKeyAnswer = await new Promise(function(resolve) {
|
|
2661
|
+
var buf = "";
|
|
2662
|
+
process.stdin.setRawMode(true);
|
|
2663
|
+
process.stdin.resume();
|
|
2664
|
+
process.stdin.setEncoding("utf8");
|
|
2665
|
+
function onKeyApi(key) {
|
|
2666
|
+
if (key === "\x03") { process.exit(0); }
|
|
2667
|
+
if (key === "\r" || key === "\n") {
|
|
2668
|
+
process.stdin.removeListener("data", onKeyApi);
|
|
2669
|
+
process.stdin.setRawMode(false);
|
|
2670
|
+
process.stdin.pause();
|
|
2671
|
+
process.stdout.write("\n");
|
|
2672
|
+
resolve(buf.trim());
|
|
2673
|
+
return;
|
|
2694
2674
|
}
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
printSuccess("API key saved.");
|
|
2702
|
-
} else {
|
|
2703
|
-
printError("No API key — some features won't work.");
|
|
2675
|
+
if (key === "\x7f" || key === "\b") {
|
|
2676
|
+
if (buf.length > 0) { buf = buf.slice(0, -1); process.stdout.write("\b \b"); }
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
buf += key;
|
|
2680
|
+
process.stdout.write("*");
|
|
2704
2681
|
}
|
|
2682
|
+
process.stdin.on("data", onKeyApi);
|
|
2683
|
+
});
|
|
2684
|
+
if (apiKeyAnswer) {
|
|
2685
|
+
config.api.key = apiKeyAnswer;
|
|
2686
|
+
config.auth.api_key = apiKeyAnswer;
|
|
2687
|
+
saveConfig(config);
|
|
2688
|
+
printSuccess("API key saved.");
|
|
2689
|
+
} else if (existingKey.length > 3) {
|
|
2690
|
+
printSuccess("Using saved key.");
|
|
2691
|
+
} else {
|
|
2692
|
+
printError("No API key — some features won't work.");
|
|
2705
2693
|
}
|
|
2706
2694
|
|
|
2707
2695
|
printHeader();
|