blun-king-cli 5.1.4 → 5.1.6

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/blun-cli.js +28 -8
  2. package/package.json +1 -1
package/blun-cli.js CHANGED
@@ -17,7 +17,7 @@ const MEMORY_DIR = path.join(CONFIG_DIR, "memory");
17
17
  const SKILLS_DIR = path.join(CONFIG_DIR, "skills");
18
18
  const HISTORY_FILE = path.join(CONFIG_DIR, "history.json");
19
19
  const LOG_FILE = path.join(CONFIG_DIR, "cli.log");
20
- const PKG_VERSION = (() => { try { return require(path.join(__dirname, "..", "package.json")).version; } catch(e) { return "1.7.0"; } })();
20
+ const PKG_VERSION = (() => { try { return require(path.join(__dirname, "package.json")).version; } catch(e) { try { return require(path.join(__dirname, "..", "package.json")).version; } catch(e2) { return "5.1.6"; } } })();
21
21
 
22
22
  if (!fs.existsSync(CONFIG_DIR)) fs.mkdirSync(CONFIG_DIR, { recursive: true });
23
23
  if (!fs.existsSync(MEMORY_DIR)) fs.mkdirSync(MEMORY_DIR, { recursive: true });
@@ -2679,25 +2679,45 @@ async function main() {
2679
2679
  printHeader();
2680
2680
  checkForUpdates();
2681
2681
 
2682
- // API Key check — prompt if missing
2683
- if (!config.api.key && !process.argv.includes("--api-key")) {
2682
+ // API Key check — prompt if missing (uses raw stdin since readline may not work after setRawMode)
2683
+ if (!config.api.key && !config.auth.api_key && !process.argv.includes("--api-key")) {
2684
2684
  console.log("");
2685
2685
  console.log(C.yellow + " " + BOX.bot + " No API key configured." + C.reset);
2686
2686
  console.log(C.gray + " Enter your BLUN King API key (or press Enter to skip):" + C.reset);
2687
+ process.stdout.write(C.brightBlue + " API Key: " + C.reset);
2687
2688
  var apiKeyAnswer = await new Promise(function(resolve) {
2688
- var rlKey = readline.createInterface({ input: process.stdin, output: process.stdout });
2689
- rlKey.question(C.brightBlue + " API Key: " + C.reset, function(answer) {
2690
- rlKey.close();
2691
- resolve(answer.trim());
2692
- });
2689
+ var buf = "";
2690
+ process.stdin.setRawMode(true);
2691
+ process.stdin.resume();
2692
+ process.stdin.setEncoding("utf8");
2693
+ function onKeyApi(key) {
2694
+ if (key === "\x03") { process.exit(0); }
2695
+ if (key === "\r" || key === "\n") {
2696
+ process.stdin.removeListener("data", onKeyApi);
2697
+ process.stdin.setRawMode(false);
2698
+ process.stdout.write("\n");
2699
+ resolve(buf.trim());
2700
+ return;
2701
+ }
2702
+ if (key === "\x7f" || key === "\b") {
2703
+ if (buf.length > 0) { buf = buf.slice(0, -1); process.stdout.write("\b \b"); }
2704
+ return;
2705
+ }
2706
+ buf += key;
2707
+ process.stdout.write("*");
2708
+ }
2709
+ process.stdin.on("data", onKeyApi);
2693
2710
  });
2694
2711
  if (apiKeyAnswer) {
2695
2712
  config.api.key = apiKeyAnswer;
2713
+ config.auth.api_key = apiKeyAnswer;
2696
2714
  var cfgFile = path.join(CONFIG_DIR, "config.json");
2697
2715
  var cfgData = {};
2698
2716
  if (fs.existsSync(cfgFile)) { try { cfgData = JSON.parse(fs.readFileSync(cfgFile, "utf8")); } catch(e) {} }
2699
2717
  if (!cfgData.api) cfgData.api = {};
2718
+ if (!cfgData.auth) cfgData.auth = {};
2700
2719
  cfgData.api.key = apiKeyAnswer;
2720
+ cfgData.auth.api_key = apiKeyAnswer;
2701
2721
  fs.writeFileSync(cfgFile, JSON.stringify(cfgData, null, 2));
2702
2722
  printSuccess("API key saved.");
2703
2723
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
4
4
  "description": "BLUN King CLI — Your local AI assistant powered by Gemma4",
5
5
  "type": "commonjs",
6
6
  "bin": {