blun-king-cli 2.7.0 → 2.8.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 +47 -10
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -158,6 +158,33 @@ function checkForUpdates() {
158
158
  } catch(e) { /* silent */ }
159
159
  }
160
160
 
161
+ // Inline markdown: **bold**, `code`, *italic*
162
+ function renderInline(text) {
163
+ return text
164
+ .replace(/\*\*(.+?)\*\*/g, C.bold + C.brightWhite + "$1" + C.reset)
165
+ .replace(/`(.+?)`/g, C.cyan + "$1" + C.reset)
166
+ .replace(/\*(.+?)\*/g, C.italic + "$1" + C.reset);
167
+ }
168
+
169
+ // Word-wrap text to terminal width
170
+ function wordWrap(text, indent) {
171
+ var maxW = (process.stdout.columns || 80) - indent - 2;
172
+ if (text.length <= maxW) return [text];
173
+ var words = text.split(" ");
174
+ var lines = [];
175
+ var current = "";
176
+ for (var i = 0; i < words.length; i++) {
177
+ if (current.length + words[i].length + 1 > maxW && current.length > 0) {
178
+ lines.push(current);
179
+ current = words[i];
180
+ } else {
181
+ current = current ? current + " " + words[i] : words[i];
182
+ }
183
+ }
184
+ if (current) lines.push(current);
185
+ return lines;
186
+ }
187
+
161
188
  function printAnswer(answer, meta) {
162
189
  console.log("");
163
190
  console.log(C.green + C.bold + " " + BOX.bot + " BLUN King" + C.reset + (meta ? C.gray + " " + BOX.dot + " " + meta + C.reset : ""));
@@ -178,19 +205,29 @@ function printAnswer(answer, meta) {
178
205
  } else if (inCode) {
179
206
  console.log(C.cyan + " " + BOX.v + " " + line + C.reset);
180
207
  } else if (line.startsWith("# ")) {
181
- console.log(C.bold + C.yellow + " " + line + C.reset);
208
+ console.log("");
209
+ console.log(C.bold + C.yellow + " \u2588 " + line.slice(2) + C.reset);
210
+ console.log("");
182
211
  } else if (line.startsWith("## ")) {
183
- console.log(C.bold + C.magenta + " " + line + C.reset);
212
+ console.log("");
213
+ console.log(C.bold + C.magenta + " \u25B6 " + line.slice(3) + C.reset);
184
214
  } else if (line.startsWith("### ")) {
185
- console.log(C.bold + " " + line + C.reset);
186
- } else if (line.startsWith("- ") || line.startsWith("* ")) {
187
- console.log(C.white + " " + line + C.reset);
188
- } else if (line.match(/^\d+\./)) {
189
- console.log(C.white + " " + line + C.reset);
190
- } else if (line.startsWith("**") && line.endsWith("**")) {
191
- console.log(C.bold + C.brightWhite + " " + line + C.reset);
215
+ console.log(C.bold + C.brightWhite + " \u25AA " + line.slice(4) + C.reset);
216
+ } else if (line.match(/^\s*[-*] /)) {
217
+ var bulletText = line.replace(/^\s*[-*] /, "");
218
+ var wrapped = wordWrap(bulletText, 8);
219
+ console.log(" " + C.green + "\u2022 " + C.reset + renderInline(wrapped[0]));
220
+ for (var w = 1; w < wrapped.length; w++) console.log(" " + renderInline(wrapped[w]));
221
+ } else if (line.match(/^\s*\d+\.\s/)) {
222
+ var numMatch = line.match(/^(\s*\d+\.)\s(.*)/);
223
+ var wrapped = wordWrap(numMatch[2], 8);
224
+ console.log(" " + C.yellow + numMatch[1] + C.reset + " " + renderInline(wrapped[0]));
225
+ for (var w = 1; w < wrapped.length; w++) console.log(" " + renderInline(wrapped[w]));
226
+ } else if (line.trim() === "") {
227
+ console.log("");
192
228
  } else {
193
- console.log(" " + line);
229
+ var wrapped = wordWrap(line, 2);
230
+ for (var w = 0; w < wrapped.length; w++) console.log(" " + renderInline(wrapped[w]));
194
231
  }
195
232
  }
196
233
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"