@nexusbloom/cli 0.2.1 → 0.2.3

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/package.json +4 -3
  2. package/src/index.js +18 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusbloom/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "NexusBloom CLI — run tools and workflows from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,8 +18,9 @@
18
18
  "node": ">=18"
19
19
  },
20
20
  "dependencies": {
21
- "commander": "^12.0.0",
22
21
  "chalk": "^5.3.0",
23
- "ora": "^8.0.0"
22
+ "commander": "^12.0.0",
23
+ "ora": "^8.0.0",
24
+ "qrcode": "^1.5.4"
24
25
  }
25
26
  }
package/src/index.js CHANGED
@@ -10,7 +10,6 @@
10
10
  * nxb run <slug> --input '{}' — Execute with inline JSON input
11
11
  * nxb run <slug> --file input.json — Execute with file input
12
12
  * nxb run <slug> --local — Execute coreLogic locally (cached)
13
- * nxb chat <message> — Natural language routing
14
13
  * nxb info <slug> — Show tool schema
15
14
  * nxb transform <slug> — Pipe stdin through a tool
16
15
  * nxb config set <key> [value] — Set config (interactive if value omitted)
@@ -25,6 +24,7 @@ import fs from "fs";
25
24
  import path from "path";
26
25
  import { fileURLToPath } from "url";
27
26
  import readline from "readline";
27
+ import QRCode from "qrcode";
28
28
 
29
29
  const require = createRequire(import.meta.url);
30
30
  const { version } = require("../package.json");
@@ -265,6 +265,10 @@ program
265
265
  if (data.success) {
266
266
  if (jsonMode) return console.log(JSON.stringify({ success: true, data: data.data }, null, 2));
267
267
  console.log(chalk.green("\n Result:"));
268
+ // Try to render QR code if the output is SVG-based
269
+ if (data.data && typeof data.data === "object" && data.data.svg) {
270
+ await renderQRCode(body.data || body.text || JSON.stringify(body), slug);
271
+ }
268
272
  console.log(` ${JSON.stringify(data.data, null, 2)}`);
269
273
  } else {
270
274
  if (jsonMode) return console.log(JSON.stringify({ success: false, error: data.error || "Unknown error" }, null, 2));
@@ -432,44 +436,6 @@ async function executeLocal(slug, input, jsonMode) {
432
436
  }
433
437
  }
434
438
 
435
- // ─── `nxb chat <message>` — describe what you want ───────────────────────────
436
- program
437
- .command("chat")
438
- .description("Describe what you want and let NexusBloom route to the right tools")
439
- .argument("<message>", "What you want to do")
440
- .action(async (message, opts, cmd) => {
441
- const jsonMode = (cmd?.parent?.opts().json) || false;
442
- try {
443
- if (!jsonMode) console.log(chalk.dim(" Routing your request..."));
444
- const res = await fetch(`${API_BASE}/api/v1/route`, {
445
- method: "POST",
446
- headers: { "Content-Type": "application/json" },
447
- body: JSON.stringify({ task: message }),
448
- });
449
- const data = await res.json();
450
- if (jsonMode) return console.log(JSON.stringify(data, null, 2));
451
- if (data.matched_tools?.length > 0) {
452
- console.log(chalk.bold(`\n Matched ${data.matched_tools.length} tool${data.matched_tools.length > 1 ? "s" : ""}:\n`));
453
- data.matched_tools.forEach((t) => {
454
- console.log(` ${chalk.cyan(t.slug.padEnd(30))} ${chalk.dim(`${Math.round(t.confidence * 100)}% match`)}`);
455
- });
456
- console.log();
457
- if (data.results) {
458
- console.log(chalk.bold(" Results:\n"));
459
- data.results.forEach((r) => {
460
- console.log(` ${chalk.cyan(r.tool)}:`);
461
- console.log(` ${JSON.stringify(r.data, null, 4)}`);
462
- });
463
- }
464
- } else {
465
- console.log(chalk.yellow(" No matching tools found."));
466
- }
467
- } catch (err) {
468
- if (jsonMode) return console.log(JSON.stringify({ error: err.message }));
469
- console.error(chalk.red("Chat failed:"), err.message);
470
- }
471
- });
472
-
473
439
  // ─── `nxb info <slug>` — show tool schema ────────────────────────────────────
474
440
  program
475
441
  .command("info")
@@ -874,4 +840,17 @@ function readStdin() {
874
840
  });
875
841
  }
876
842
 
843
+ // ─── QR Code Terminal Renderer ────────────────────────────────────────────
844
+
845
+ async function renderQRCode(data, slug) {
846
+ try {
847
+ const qr = await QRCode.toString(data, { type: "terminal", small: true });
848
+ console.log(chalk.cyan("\n QR Code:"));
849
+ console.log(qr);
850
+ console.log(chalk.dim(` Data: ${data.slice(0, 80)}${data.length > 80 ? "..." : ""}`));
851
+ } catch {
852
+ // Silently skip if QR rendering fails
853
+ }
854
+ }
855
+
877
856
  program.parse(process.argv);