blun-king-cli 1.1.0 → 1.2.0

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 +79 -34
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -47,10 +47,16 @@ var config = loadConfig();
47
47
 
48
48
  // ── Colors ──
49
49
  const C = {
50
- reset: "\x1b[0m", bold: "\x1b[1m", dim: "\x1b[2m",
50
+ reset: "\x1b[0m", bold: "\x1b[1m", dim: "\x1b[2m", italic: "\x1b[3m",
51
51
  red: "\x1b[31m", green: "\x1b[32m", yellow: "\x1b[33m",
52
52
  blue: "\x1b[34m", magenta: "\x1b[35m", cyan: "\x1b[36m", white: "\x1b[37m",
53
- bg_blue: "\x1b[44m", bg_green: "\x1b[42m"
53
+ gray: "\x1b[90m", brightBlue: "\x1b[94m", brightCyan: "\x1b[96m", brightWhite: "\x1b[97m",
54
+ bg_blue: "\x1b[44m", bg_green: "\x1b[42m", bg_gray: "\x1b[100m", bg_darkBlue: "\x1b[48;5;17m"
55
+ };
56
+ // Box drawing helpers
57
+ const BOX = {
58
+ tl: "╭", tr: "╮", bl: "╰", br: "╯", h: "─", v: "│",
59
+ sep: "├", sepR: "┤", dot: "●", arrow: "❯", chat: "💬", bot: "🤖", user: "👤"
54
60
  };
55
61
 
56
62
  function log(msg) { if (config.verbose) fs.appendFileSync(LOG_FILE, new Date().toISOString() + " " + msg + "\n"); }
@@ -98,51 +104,68 @@ var chatHistory = [];
98
104
 
99
105
  // ── Print Helpers ──
100
106
  function printHeader() {
107
+ var w = Math.min(process.stdout.columns || 60, 60);
108
+ var line = BOX.h.repeat(w - 4);
101
109
  console.log("");
102
- console.log(C.bold + C.blue + " ╔══════════════════════════════════════╗" + C.reset);
103
- console.log(C.bold + C.blue + " BLUN KING CLI v1.0 ║" + C.reset);
104
- console.log(C.bold + C.blue + " Premium KI — Local First" + C.reset);
105
- console.log(C.bold + C.blue + " ╚══════════════════════════════════════╝" + C.reset);
106
- console.log("");
107
- console.log(C.dim + " API: " + config.api.base_url + C.reset);
108
- console.log(C.dim + " Auth: " + config.auth.type + (config.auth.api_key ? " (key set)" : " (no key)") + C.reset);
109
- console.log(C.dim + " Model: " + config.model + C.reset);
110
- console.log(C.dim + " Workdir: " + config.workdir + C.reset);
110
+ console.log(C.brightBlue + " " + BOX.tl + line + BOX.tr + C.reset);
111
+ console.log(C.brightBlue + " " + BOX.v + C.reset + C.bold + C.brightWhite + " " + BOX.bot + " BLUN KING CLI" + C.reset + C.dim + " v1.1" + C.reset + " ".repeat(Math.max(0, w - 24)) + C.brightBlue + BOX.v + C.reset);
112
+ console.log(C.brightBlue + " " + BOX.v + C.reset + C.gray + " Premium KI — Local First — Autonom" + C.reset + " ".repeat(Math.max(0, w - 41)) + C.brightBlue + BOX.v + C.reset);
113
+ console.log(C.brightBlue + " " + BOX.v + line + BOX.v + C.reset);
114
+ console.log(C.brightBlue + " " + BOX.v + C.reset + C.gray + " API " + C.brightCyan + config.api.base_url + C.reset + " ".repeat(Math.max(0, w - 14 - config.api.base_url.length)) + C.brightBlue + BOX.v + C.reset);
115
+ console.log(C.brightBlue + " " + BOX.v + C.reset + C.gray + " Model " + C.brightCyan + config.model + C.reset + " ".repeat(Math.max(0, w - 14 - config.model.length)) + C.brightBlue + BOX.v + C.reset);
116
+ var wdShort = config.workdir.length > w - 16 ? "..." + config.workdir.slice(-(w - 19)) : config.workdir;
117
+ console.log(C.brightBlue + " " + BOX.v + C.reset + C.gray + " Dir " + C.brightCyan + wdShort + C.reset + " ".repeat(Math.max(0, w - 14 - wdShort.length)) + C.brightBlue + BOX.v + C.reset);
118
+ console.log(C.brightBlue + " " + BOX.bl + line + BOX.br + C.reset);
111
119
  console.log("");
112
- console.log(C.dim + " Type /help for commands, or just chat." + C.reset);
120
+ console.log(C.gray + " /help " + C.dim + "for commands " + C.gray + BOX.dot + " just type to chat" + C.reset);
113
121
  console.log("");
114
122
  }
115
123
 
116
- function printAnswer(answer) {
124
+ function printAnswer(answer, meta) {
117
125
  console.log("");
118
- console.log(C.green + C.bold + "BLUN King:" + C.reset);
119
- // Simple markdown rendering
126
+ console.log(C.green + C.bold + " " + BOX.bot + " BLUN King" + C.reset + (meta ? C.gray + " " + BOX.dot + " " + meta + C.reset : ""));
127
+ console.log(C.green + " " + BOX.h.repeat(40) + C.reset);
128
+ // Markdown rendering
120
129
  var lines = answer.split("\n");
121
130
  var inCode = false;
122
131
  for (var i = 0; i < lines.length; i++) {
123
132
  var line = lines[i];
124
133
  if (line.startsWith("```")) {
125
134
  inCode = !inCode;
126
- console.log(C.dim + line + C.reset);
135
+ if (inCode) {
136
+ var lang = line.slice(3).trim();
137
+ console.log(C.dim + " " + BOX.tl + BOX.h.repeat(38) + (lang ? " " + lang + " " : "") + C.reset);
138
+ } else {
139
+ console.log(C.dim + " " + BOX.bl + BOX.h.repeat(38) + C.reset);
140
+ }
127
141
  } else if (inCode) {
128
- console.log(C.cyan + line + C.reset);
142
+ console.log(C.cyan + " " + BOX.v + " " + line + C.reset);
129
143
  } else if (line.startsWith("# ")) {
130
- console.log(C.bold + C.yellow + line + C.reset);
144
+ console.log(C.bold + C.yellow + " " + line + C.reset);
131
145
  } else if (line.startsWith("## ")) {
132
- console.log(C.bold + C.magenta + line + C.reset);
146
+ console.log(C.bold + C.magenta + " " + line + C.reset);
133
147
  } else if (line.startsWith("### ")) {
134
- console.log(C.bold + line + C.reset);
148
+ console.log(C.bold + " " + line + C.reset);
135
149
  } else if (line.startsWith("- ") || line.startsWith("* ")) {
136
- console.log(C.white + " " + line + C.reset);
150
+ console.log(C.white + " " + line + C.reset);
137
151
  } else if (line.match(/^\d+\./)) {
138
- console.log(C.white + " " + line + C.reset);
152
+ console.log(C.white + " " + line + C.reset);
153
+ } else if (line.startsWith("**") && line.endsWith("**")) {
154
+ console.log(C.bold + C.brightWhite + " " + line + C.reset);
139
155
  } else {
140
- console.log(line);
156
+ console.log(" " + line);
141
157
  }
142
158
  }
143
159
  console.log("");
144
160
  }
145
161
 
162
+ function printUserMessage(msg) {
163
+ console.log("");
164
+ console.log(C.brightBlue + C.bold + " " + BOX.user + " Du" + C.reset);
165
+ console.log(C.brightBlue + " " + BOX.h.repeat(40) + C.reset);
166
+ console.log(C.brightWhite + " " + msg + C.reset);
167
+ }
168
+
146
169
  function printError(msg) { console.log(C.red + "ERROR: " + msg + C.reset); }
147
170
  function printInfo(msg) { console.log(C.cyan + msg + C.reset); }
148
171
  function printSuccess(msg) { console.log(C.green + "✓ " + msg + C.reset); }
@@ -324,12 +347,22 @@ async function handleCommand(input) {
324
347
  // ── Chat ──
325
348
  async function sendChat(message) {
326
349
  try {
327
- process.stdout.write(C.dim + "⏳ thinking..." + C.reset);
350
+ printUserMessage(message);
351
+ // Animated thinking
352
+ var dots = 0;
353
+ var thinkFrames = ["thinking", "thinking.", "thinking..", "thinking..."];
354
+ var thinkTimer = setInterval(function() {
355
+ process.stdout.write("\r" + C.dim + " " + BOX.bot + " " + thinkFrames[dots % 4] + " " + C.reset);
356
+ dots++;
357
+ }, 300);
358
+
328
359
  var resp = await apiCall("POST", "/chat", {
329
360
  message: message,
330
361
  history: chatHistory.slice(-10)
331
362
  });
332
- process.stdout.write("\r" + " ".repeat(30) + "\r");
363
+
364
+ clearInterval(thinkTimer);
365
+ process.stdout.write("\r" + " ".repeat(40) + "\r");
333
366
 
334
367
  if (resp.status !== 200) {
335
368
  printError(resp.data.error || "API Error " + resp.status);
@@ -339,17 +372,14 @@ async function sendChat(message) {
339
372
  chatHistory.push({ role: "user", content: message });
340
373
  chatHistory.push({ role: "assistant", content: resp.data.answer });
341
374
 
342
- printAnswer(resp.data.answer);
343
-
344
- // Status line
345
375
  var q = resp.data.quality || {};
346
- console.log(C.dim + " [" + resp.data.task_type + "/" + resp.data.role + " | score: " + (q.score || "?") +
347
- (q.retried ? " | retried" : "") +
348
- (q.flags && q.flags.length > 0 ? " | flags: " + q.flags.join(", ") : "") + "]" + C.reset);
349
- console.log("");
376
+ var meta = resp.data.task_type + "/" + resp.data.role + " " + BOX.dot + " score: " + (q.score || "?") +
377
+ (q.retried ? " " + BOX.dot + " retried" : "");
378
+ printAnswer(resp.data.answer, meta);
350
379
 
351
380
  } catch(e) {
352
- process.stdout.write("\r" + " ".repeat(30) + "\r");
381
+ if (typeof thinkTimer !== "undefined") clearInterval(thinkTimer);
382
+ process.stdout.write("\r" + " ".repeat(40) + "\r");
353
383
  printError("Connection failed: " + e.message);
354
384
  }
355
385
  }
@@ -1092,10 +1122,25 @@ async function main() {
1092
1122
  printInfo("Run: blun setup — to configure");
1093
1123
  }
1094
1124
 
1125
+ var ALL_COMMANDS = [
1126
+ "/help", "/clear", "/skills", "/skill", "/search", "/learn", "/learn-url",
1127
+ "/generate", "/analyze", "/score", "/eval", "/settings", "/set",
1128
+ "/status", "/versions", "/health", "/watchdog", "/memory", "/files",
1129
+ "/sh", "/git", "/ssh", "/deploy", "/read", "/write", "/init",
1130
+ "/screenshot", "/render", "/agent", "/exit"
1131
+ ];
1132
+
1095
1133
  var rl = readline.createInterface({
1096
1134
  input: process.stdin,
1097
1135
  output: process.stdout,
1098
- prompt: C.blue + C.bold + "blun > " + C.reset
1136
+ prompt: "\n" + C.brightBlue + C.bold + " " + BOX.arrow + " " + C.reset,
1137
+ completer: function(line) {
1138
+ if (line.startsWith("/")) {
1139
+ var hits = ALL_COMMANDS.filter(function(c) { return c.startsWith(line); });
1140
+ return [hits.length ? hits : ALL_COMMANDS, line];
1141
+ }
1142
+ return [[], line];
1143
+ }
1099
1144
  });
1100
1145
 
1101
1146
  rl.prompt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"