blun-king-cli 2.3.2 → 2.4.1
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 +48 -11
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -106,16 +106,25 @@ var chatHistory = [];
|
|
|
106
106
|
// ── Print Helpers ──
|
|
107
107
|
function printHeader() {
|
|
108
108
|
var w = Math.min(process.stdout.columns || 60, 60);
|
|
109
|
-
var
|
|
109
|
+
var inner = w - 4; // inner width between │ and │
|
|
110
|
+
var line = BOX.h.repeat(inner);
|
|
111
|
+
// Helper: pad text to exact inner width
|
|
112
|
+
function row(text, visLen) { return C.brightBlue + " " + BOX.v + C.reset + text + " ".repeat(Math.max(0, inner - visLen)) + C.brightBlue + BOX.v + C.reset; }
|
|
113
|
+
var modelStr = typeof config.model === "string" ? config.model : (config.model && config.model.name ? config.model.name : "default");
|
|
114
|
+
var wdShort = config.workdir.length > inner - 10 ? "..." + config.workdir.slice(-(inner - 13)) : config.workdir;
|
|
115
|
+
var titleText = " " + BOX.bot + " BLUN KING CLI v" + PKG_VERSION;
|
|
116
|
+
var subText = " Premium KI \u2014 Local First \u2014 Autonom";
|
|
110
117
|
console.log("");
|
|
111
118
|
console.log(C.brightBlue + " " + BOX.tl + line + BOX.tr + C.reset);
|
|
112
|
-
console.log(C.
|
|
113
|
-
console.log(C.
|
|
119
|
+
console.log(row(C.bold + C.brightWhite + titleText + C.reset, titleText.length));
|
|
120
|
+
console.log(row(C.gray + subText + C.reset, subText.length));
|
|
114
121
|
console.log(C.brightBlue + " " + BOX.v + line + BOX.v + C.reset);
|
|
115
|
-
|
|
116
|
-
console.log(C.
|
|
117
|
-
var
|
|
118
|
-
console.log(C.
|
|
122
|
+
var apiText = " API " + config.api.base_url;
|
|
123
|
+
console.log(row(C.gray + " API " + C.brightCyan + config.api.base_url + C.reset, apiText.length));
|
|
124
|
+
var modelText = " Model " + modelStr;
|
|
125
|
+
console.log(row(C.gray + " Model " + C.brightCyan + modelStr + C.reset, modelText.length));
|
|
126
|
+
var dirText = " Dir " + wdShort;
|
|
127
|
+
console.log(row(C.gray + " Dir " + C.brightCyan + wdShort + C.reset, dirText.length));
|
|
119
128
|
console.log(C.brightBlue + " " + BOX.bl + line + BOX.br + C.reset);
|
|
120
129
|
console.log("");
|
|
121
130
|
console.log(C.gray + " /help " + C.dim + "for commands " + C.gray + BOX.dot + " just type to chat" + C.reset);
|
|
@@ -2267,6 +2276,31 @@ async function main() {
|
|
|
2267
2276
|
printHeader();
|
|
2268
2277
|
checkForUpdates();
|
|
2269
2278
|
|
|
2279
|
+
// API Key check — prompt if missing
|
|
2280
|
+
if (!config.api.key && !process.argv.includes("--api-key")) {
|
|
2281
|
+
console.log("");
|
|
2282
|
+
console.log(C.yellow + " " + BOX.bot + " No API key configured." + C.reset);
|
|
2283
|
+
console.log(C.gray + " Enter your BLUN King API key (or press Enter to skip):" + C.reset);
|
|
2284
|
+
var apiKeyAnswer = await new Promise(function(resolve) {
|
|
2285
|
+
var rlKey = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2286
|
+
rlKey.question(C.brightBlue + " API Key: " + C.reset, function(answer) {
|
|
2287
|
+
rlKey.close();
|
|
2288
|
+
resolve(answer.trim());
|
|
2289
|
+
});
|
|
2290
|
+
});
|
|
2291
|
+
if (apiKeyAnswer) {
|
|
2292
|
+
config.api.key = apiKeyAnswer;
|
|
2293
|
+
// Save to config file
|
|
2294
|
+
var cfgFile = path.join(CONFIG_DIR, "config.json");
|
|
2295
|
+
var cfgData = {};
|
|
2296
|
+
if (fs.existsSync(cfgFile)) { try { cfgData = JSON.parse(fs.readFileSync(cfgFile, "utf8")); } catch(e) {} }
|
|
2297
|
+
if (!cfgData.api) cfgData.api = {};
|
|
2298
|
+
cfgData.api.key = apiKeyAnswer;
|
|
2299
|
+
fs.writeFileSync(cfgFile, JSON.stringify(cfgData, null, 2));
|
|
2300
|
+
printSuccess("API key saved.");
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2270
2304
|
// Load session history for this workdir
|
|
2271
2305
|
var session = loadSessionHistory();
|
|
2272
2306
|
chatHistory = session.history.slice(-20);
|
|
@@ -2329,7 +2363,7 @@ async function main() {
|
|
|
2329
2363
|
var w = Math.min(getTermWidth() - 4, 76);
|
|
2330
2364
|
var displayText = inputBuffer;
|
|
2331
2365
|
if (displayText.length > w - 4) displayText = displayText.slice(-(w - 4));
|
|
2332
|
-
var pad = Math.max(0, w -
|
|
2366
|
+
var pad = Math.max(0, w - 3 - displayText.length);
|
|
2333
2367
|
var lines = 0;
|
|
2334
2368
|
|
|
2335
2369
|
// Box top
|
|
@@ -2342,11 +2376,14 @@ async function main() {
|
|
|
2342
2376
|
// Status bar (permission mode + model + workdir)
|
|
2343
2377
|
var rawPerm = getSetting("permissions.defaultMode");
|
|
2344
2378
|
var permMode = typeof rawPerm === "string" ? rawPerm : "ask";
|
|
2345
|
-
|
|
2346
|
-
var
|
|
2379
|
+
// Check if --dangerously-skip-permissions or godmode
|
|
2380
|
+
var isDangerous = process.argv.includes("--dangerously-skip-permissions") || permMode === "allow";
|
|
2381
|
+
var permLabel = isDangerous ? "GOD MODE" : permMode === "deny" ? "LOCKED" : "ask permission";
|
|
2382
|
+
var permIcon = isDangerous ? "\u26A1" : permMode === "deny" ? "\u2718" : "\u2753";
|
|
2383
|
+
var permColor = isDangerous ? C.red + C.bold : permMode === "deny" ? C.red : C.yellow;
|
|
2347
2384
|
var modelName = typeof config.model === "string" ? config.model : (config.model && config.model.name ? config.model.name : "default");
|
|
2348
2385
|
var wdShort = config.workdir ? path.basename(config.workdir) : "~";
|
|
2349
|
-
var statusLine = permColor + " " + permIcon + " " +
|
|
2386
|
+
var statusLine = permColor + " " + permIcon + " " + permLabel + C.reset + C.dim + " \u2502 " + C.reset +
|
|
2350
2387
|
C.cyan + modelName + C.reset + C.dim + " \u2502 " + C.reset +
|
|
2351
2388
|
C.dim + wdShort + C.reset;
|
|
2352
2389
|
process.stdout.write("\x1b[2K" + statusLine + "\n"); lines++;
|