@bolt-cli/cli 0.14.0 → 0.15.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/lib/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  const fs = require("fs");
5
5
  const os = require("os");
6
6
  const path = require("path");
7
- const { spawn } = require("node:child_process");
7
+ const { spawn, execFileSync } = require("node:child_process");
8
8
  const config = require("./config");
9
9
  const api = require("./api");
10
10
  const browser = require("./browser");
@@ -278,7 +278,7 @@ async function cmdSession(rest) {
278
278
  const s = id ? session.load(id) : null;
279
279
  if (!s) throw new Error("Usage: bolt session show <id>");
280
280
  for (const [i, t] of s.turns.entries()) {
281
- console.log(`\n--- turn ${i + 1} [${t.mode}] ${t.at} ---\nQ: ${t.prompt}\nA: ${t.response.slice(0, 2000)}`);
281
+ console.log(`\n--- turn ${i + 1} [${t.mode}] ${t.at} ---\n${ui.userTurn(t.prompt)}\nA: ${t.response.slice(0, 2000)}`);
282
282
  if (t.tools && t.tools.length) {
283
283
  console.log(`tools: ${t.tools.map((tool) => `${tool.tool}${tool.ok === false ? " (failed)" : ""}`).join(", ")}`);
284
284
  }
@@ -921,10 +921,10 @@ function handleToolEvent(event) {
921
921
  } else {
922
922
  toolStarted.set(toolTimingKey(event.call), Date.now());
923
923
  const elevated = event.call && event.call.tool === "bash" ? permissions.isElevatedCommand(event.call.command) : false;
924
- // reference terminals render tool traffic as dim text under the answer, not a
925
- // branded announcement; the elevated warning keeps its colour so the
926
- // one thing that must be seen, is.
927
- ui.status(`${ui.c.muted(`${ui.GLYPH.caret} ${tools.describeCall(event.call)}`)}${elevated ? ` ${ui.c.warning("[elevated]")}` : ""}`);
924
+ // Transcript-style tool row: a quiet mark plus the call, the way a
925
+ // full-screen agent renders activity. The elevated warning keeps its
926
+ // colour so the one thing that must be seen, is.
927
+ ui.status(`${ui.toolLine(tools.describeCall(event.call))}${elevated ? ` ${ui.c.warning("[elevated]")}` : ""}`);
928
928
  }
929
929
  return;
930
930
  }
@@ -934,9 +934,9 @@ function handleToolEvent(event) {
934
934
  if (event.call.tool === "(parse error)") {
935
935
  ui.warn(`tool request ignored: ${r.summary || "bad block"}`);
936
936
  } else {
937
- // Result rows stay dim like the call row; failure keeps a warning tone
938
- // so a scan down the transcript still catches it.
939
- ui.status(` ${r.ok ? ui.c.muted("ok") : ui.c.warning("FAILED")} ${ui.c.muted(r.summary || "")}${took}`);
937
+ // Result rows mirror the call row; failure keeps an error tone so a scan
938
+ // down the transcript still catches it.
939
+ ui.status(ui.toolLine(r.ok ? "ok" : "FAILED", r.summary || "", { ok: r.ok, duration: took || undefined }));
940
940
  }
941
941
  }
942
942
  }
@@ -966,8 +966,7 @@ function takeToolElapsed(call) {
966
966
  if (!key || !toolStarted.has(key)) return "";
967
967
  const ms = Date.now() - toolStarted.get(key);
968
968
  toolStarted.delete(key);
969
- const text = formatElapsed(ms);
970
- return text ? ` ${ui.c.muted(`· ${text}`)}` : "";
969
+ return formatElapsed(ms);
971
970
  }
972
971
 
973
972
  function copyToClipboard(text) {
@@ -1395,31 +1394,88 @@ async function cmdDoctor() {
1395
1394
  }
1396
1395
 
1397
1396
  // ── update ────────────────────────────────────────────────────────────────
1398
- // `bolt update` shells npm to upgrade the globally installed package. npm's
1399
- // launcher is a .cmd on Windows, so the child runs through a shell; stdio is
1400
- // inherited so the npm progress bars show as they are.
1397
+ // `bolt update` runs npm to upgrade the globally installed package. On Windows
1398
+ // npm is a .cmd: newer Node refuses to spawn it directly (EINVAL), while
1399
+ // `shell: true` triggers DEP0190 and concatenates the arguments unescaped.
1400
+ // cmd.exe with one fixed command line avoids both. No argument here is
1401
+ // user-controlled; stdio is inherited so npm's progress shows as-is.
1402
+ function npmInvocation(args) {
1403
+ return process.platform === "win32"
1404
+ ? { command: "cmd.exe", args: ["/d", "/s", "/c", ["npm", ...args].join(" ")] }
1405
+ : { command: "npm", args };
1406
+ }
1407
+
1408
+ // What is actually on disk in the global prefix? A zero npm exit does not
1409
+ // guarantee the package was replaced — Windows can keep the running CLI's
1410
+ // files locked — so the install is verified before claiming success. "" means
1411
+ // the prefix could not be read and no claim is made.
1412
+ function installedCliVersion() {
1413
+ try {
1414
+ const inv = npmInvocation(["root", "-g"]);
1415
+ const root = execFileSync(inv.command, inv.args, { encoding: "utf8", windowsHide: true }).trim();
1416
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "@bolt-cli", "cli", "package.json"), "utf8"));
1417
+ return String(pkg.version || "");
1418
+ } catch {
1419
+ return "";
1420
+ }
1421
+ }
1422
+
1423
+ // Latest published version, used only to explain an "unchanged" install:
1424
+ // already-current is fine, but being behind means npm failed to replace us.
1425
+ function registryLatest() {
1426
+ try {
1427
+ const inv = npmInvocation(["view", "@bolt-cli/cli", "version"]);
1428
+ return execFileSync(inv.command, inv.args, { encoding: "utf8", timeout: 8000, windowsHide: true }).trim();
1429
+ } catch {
1430
+ return "";
1431
+ }
1432
+ }
1433
+
1434
+ // Pure outcome classifier for the self-update. "unchanged" is the important
1435
+ // case: npm exited zero but the old version is still installed. Tested.
1436
+ function updateOutcome(installed, current) {
1437
+ if (!installed) return "unknown";
1438
+ return String(installed) === String(current) ? "unchanged" : "upgraded";
1439
+ }
1440
+
1401
1441
  function cmdUpdate() {
1402
1442
  console.log(`running: npm install -g @bolt-cli/cli (current: v${VERSION})`);
1403
- const child = spawn("npm", ["install", "-g", "@bolt-cli/cli"], { stdio: "inherit", shell: process.platform === "win32" });
1443
+ const inv = npmInvocation(["install", "-g", "@bolt-cli/cli"]);
1444
+ const child = spawn(inv.command, inv.args, { stdio: "inherit", windowsHide: true });
1404
1445
  return new Promise((resolve) => {
1405
1446
  child.on("error", (error) => {
1406
1447
  ui.err(`update failed: ${error.message} - try: npm install -g @bolt-cli/cli`);
1407
1448
  resolve();
1408
1449
  });
1409
1450
  child.on("close", (code) => {
1410
- if (code === 0) {
1411
- // Restart into the new version before the next check: clear the
1412
- // cached check so the fresh install re-verifies against the registry
1413
- // instead of greeting itself with a stale notice.
1451
+ if (code !== 0) {
1452
+ ui.err(`update failed (exit ${code}) - try: npm install -g @bolt-cli/cli`);
1453
+ resolve();
1454
+ return;
1455
+ }
1456
+ const installed = installedCliVersion();
1457
+ const outcome = updateOutcome(installed, VERSION);
1458
+ if (outcome === "upgraded") {
1459
+ // Clear the cached check only after a verified upgrade, so the next
1460
+ // session re-verifies instead of greeting itself with stale news.
1414
1461
  try {
1415
1462
  const cfg = config.load();
1416
1463
  config.save({ ...cfg, updateCheckedAt: 0, updateLatest: "" });
1417
1464
  } catch {
1418
- // Cache hygiene is best-effort; the update itself already succeeded.
1465
+ // Cache hygiene is best-effort; the install itself succeeded.
1466
+ }
1467
+ ui.ok(`update complete - v${installed} installed; restart bolt to run it`);
1468
+ } else if (outcome === "unchanged") {
1469
+ const latest = registryLatest();
1470
+ if (latest && String(latest) === String(installed)) {
1471
+ ui.ok(`already on the latest version (v${installed})`);
1472
+ } else {
1473
+ // Still behind, so the notice stays true. Say what to do rather than
1474
+ // reporting a success that did not take.
1475
+ ui.warn(`npm finished but v${installed} is still installed - run: npm install -g @bolt-cli/cli from a new terminal`);
1419
1476
  }
1420
- ui.ok("update complete - restart bolt to run the new version");
1421
1477
  } else {
1422
- ui.err(`update failed (exit ${code}) - try: npm install -g @bolt-cli/cli`);
1478
+ ui.ok("update finished - check with: bolt --version");
1423
1479
  }
1424
1480
  resolve();
1425
1481
  });
@@ -1619,19 +1675,22 @@ function pickTip(n) {
1619
1675
  return TIPS[((Number(n) || 0) % TIPS.length + TIPS.length) % TIPS.length];
1620
1676
  }
1621
1677
 
1622
- // Welcome lines for the REPL: quiet, polished. One identity line
1623
- // (name, version, backend, working directory), one state line (session, the
1624
- // single verb that matters), one muted mechanics line. No logo wall, no box,
1625
- // no rotating tip. Pure (ui.c degrades to identity), tested.
1678
+ // REPL home surface: half-block wordmark, identity/session chrome, and one
1679
+ // mechanics line. The wordmark is the only decoration; everything else stays
1680
+ // muted so the prompt below remains the focus. Pure (ui.c degrades on a pipe),
1681
+ // tested for the hint phrases the docs promise.
1626
1682
  function replWelcomeLines({ sid, version, host, cwd, update }) {
1627
1683
  const identity = [version ? `v${version}` : "", host, cwd].filter(Boolean);
1628
1684
  const lines = [
1629
- `${ui.c.primary(ui.c.bold("bolt"))}${identity.length ? ` ${ui.c.muted(identity.join(` ${ui.GLYPH.dot} `))}` : ""}`,
1630
- ui.c.muted(`session ${sid.slice(0, 8)} ${ui.GLYPH.dot} type a task and press enter`),
1631
- ` ${ui.c.muted(`/ opens the command dropdown ${ui.GLYPH.dot} type to filter, up/down to pick, Tab fills and keeps your place ${ui.GLYPH.dot} @path attaches a file`)}`,
1685
+ ...ui.wordmark(" "),
1686
+ "",
1687
+ ` ${ui.c.muted(identity.join(` ${ui.GLYPH.dot} `))}`,
1688
+ ` ${ui.c.muted(`session ${sid.slice(0, 8)} ${ui.GLYPH.dot} type a task and press enter`)}`,
1689
+ "",
1690
+ ` ${ui.c.primary("/")} ${ui.c.muted("opens the command dropdown")} ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.primary("Tab fills")} ${ui.c.muted("and keeps your place")} ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.primary("@path")} ${ui.c.muted("attaches a file")}`,
1632
1691
  ];
1633
1692
  if (update) {
1634
- lines.push("", `${ui.c.warning("update")} ${update}`);
1693
+ lines.push("", ` ${ui.c.warning("update")} ${update}`);
1635
1694
  }
1636
1695
  return lines;
1637
1696
  }
@@ -2620,4 +2679,4 @@ async function run(argv) {
2620
2679
  throw new Error(`Unknown command "${cmd}".\n${help()}`);
2621
2680
  }
2622
2681
 
2623
- module.exports = { run, resolveUrl, isLoopbackUrl, backendReachable, completer, completeFileFrag, completeWithDescriptions, filterPaletteItems, isPaletteRunnable, COMMANDS, AGENTS, NO_ARG_COMMANDS, makeAsker, makeAskQuestion, handleToolEvent, estimateTokens, buildDryRunReport, printDryRun, dryRunTools, argvSecretWarning, cmdDoctor, cmdCompletion, cmdTemplates, cmdExport, cmdUndo, reportRunError, warnTruncated, stripBoltPrefix, printPaletteNumbered, resolvePalettePick, replWelcomeLines, printHelpBox, printSessionTable, printKeysBox, pickTip, TIPS, formatElapsed, backendHost };
2682
+ module.exports = { run, resolveUrl, isLoopbackUrl, backendReachable, completer, completeFileFrag, completeWithDescriptions, filterPaletteItems, isPaletteRunnable, COMMANDS, AGENTS, NO_ARG_COMMANDS, makeAsker, makeAskQuestion, handleToolEvent, estimateTokens, buildDryRunReport, printDryRun, dryRunTools, argvSecretWarning, cmdDoctor, cmdCompletion, cmdTemplates, cmdExport, cmdUndo, reportRunError, warnTruncated, stripBoltPrefix, printPaletteNumbered, resolvePalettePick, replWelcomeLines, printHelpBox, printSessionTable, printKeysBox, pickTip, TIPS, formatElapsed, backendHost, updateOutcome };
package/lib/present.js CHANGED
@@ -79,7 +79,7 @@ function promptLine({ mode, target, agent, files, balance, tools }) {
79
79
  if (files) bits.push(ui.c.muted(`${files} file${files === 1 ? "" : "s"}`));
80
80
  if (tools !== undefined) bits.push(ui.c.muted(tools ? "tools" : "no-tools"));
81
81
  if (balance !== undefined && balance !== null) bits.push(ui.c.muted(`${balance} tok`));
82
- return `${ui.c.primary(ui.GLYPH.caret)} ${bits.join(ui.c.muted(` ${ui.GLYPH.dot} `))} ${ui.c.primary(ui.GLYPH.caret)} `;
82
+ return `${ui.c.primary(">")} ${bits.join(ui.c.muted(` ${ui.GLYPH.dot} `))} `;
83
83
  }
84
84
 
85
85
  // Palette rows for `select()`; label is what gets typed back into the prompt.
package/lib/ui.js CHANGED
@@ -168,21 +168,34 @@ function width() {
168
168
  return typeof columns === "number" && columns > 20 ? Math.min(columns, 100) : 78;
169
169
  }
170
170
 
171
- // Heavy block-letter wordmark: solid blocks where
172
- // the terminal proves modern, the plain word everywhere else so raster fonts
173
- // never show tofu. Rows pad to one width in code (no trailing whitespace in
174
- // the literals for linters to flag); every glyph is one cell, so length math
175
- // holds. Pure, tested.
171
+ // Half-block wordmark in the register used by full-screen agent terminals:
172
+ // solid upper blocks, a dim baseline, `_` holes and a `~` shadow. One cell per
173
+ // glyph so visible-length maths holds; `_` is a blank cell, never a literal
174
+ // underscore. Colour degrades to identity on a pipe. Pure, width-tested.
176
175
  const LOGO_RAW = [
177
- "██████╗ ██████╗ ██╗ █████████",
178
- "██╔══██╗ ██╔══██╗ ██║ █████████",
179
- "██████╔╝ ██║ ██║ ██║ █",
180
- "██╔══██╗ ██║ ██║ ██║ █",
181
- "██████╔╝ ██║ ██║ ██║ █",
182
- "╚═════╝ ╚════╝ ██║▄▄▄▄",
176
+ " ",
177
+ "█▀▀▄ █▀▀█ █___ █▀▀▀",
178
+ "█▄▄▀ █__█ █___ _█__",
179
+ "▀~~▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀",
183
180
  ];
184
- const LOGO_WIDTH = Math.max(...LOGO_RAW.map((row) => row.length));
185
- const LOGO = U ? LOGO_RAW.map((row) => row + " ".repeat(LOGO_WIDTH - row.length)) : ["bolt"];
181
+ function wordmark(pad = "") {
182
+ if (!U) return [`${pad}bolt`];
183
+ return LOGO_RAW.map((line, i) => {
184
+ const baseline = i === LOGO_RAW.length - 1;
185
+ return (
186
+ pad +
187
+ [...line]
188
+ .map((ch) => {
189
+ if (ch === "_" || ch === " ") return " ";
190
+ if (ch === "~") return c.border("▀");
191
+ if (ch === "▀" && baseline) return c.muted(ch);
192
+ return c.primary(ch);
193
+ })
194
+ .join("")
195
+ );
196
+ });
197
+ }
198
+ const LOGO = wordmark();
186
199
 
187
200
  // Relative timestamps for pickers and dashboards ("5m ago"). Pure, tested:
188
201
  // `now` injects the clock, unparseable input yields "".
@@ -270,6 +283,26 @@ function bullets(rows, { marker = GLYPH.dot } = {}) {
270
283
  return rows.map((r) => ` ${c.muted(marker)} ${r}`).join("\n");
271
284
  }
272
285
 
286
+ // Transcript shapes shared by the REPL and the tool-event renderer. A user
287
+ // turn gets a bright `>` marker and default-foreground text; tool activity gets
288
+ // a compact indented row with a semantic mark. Both are pure strings, so a
289
+ // piped log keeps the same readable shape without ANSI.
290
+ function userTurn(text) {
291
+ return String(text ?? "")
292
+ .split("\n")
293
+ .map((line, i) => (i === 0 ? `${c.primary(">")} ${c.bold(line)}` : ` ${line}`))
294
+ .join("\n");
295
+ }
296
+
297
+ function toolLine(name, detail, { ok: state, duration } = {}) {
298
+ const mark = state === undefined ? c.info(GLYPH.dot) : state ? c.success(GLYPH.tick) : c.error(GLYPH.cross);
299
+ const label = state === undefined ? c.primary(name) : state ? c.success(name) : c.error(name);
300
+ const bits = [label];
301
+ if (detail) bits.push(c.muted(String(detail)));
302
+ if (duration) bits.push(c.border(String(duration)));
303
+ return ` ${mark} ${bits.join(` ${c.muted(GLYPH.dot)} `)}`;
304
+ }
305
+
273
306
  // ---------------------------------------------------------------- status
274
307
 
275
308
  // Quiet progress line for tool activity: reference terminals render tool traffic as
@@ -748,6 +781,9 @@ module.exports = {
748
781
  ESC,
749
782
  GLYPH,
750
783
  LOGO,
784
+ wordmark,
785
+ userTurn,
786
+ toolLine,
751
787
  PALETTE,
752
788
  c,
753
789
  enabled: c.enabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolt-cli/cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "Bolt terminal CLI — authorized testing and tool-building from your terminal or VS Code.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",