agenttop 0.11.1 → 0.11.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.
package/dist/index.js CHANGED
@@ -648,7 +648,7 @@ var checkForUpdate = () => new Promise((resolve) => {
648
648
  var installUpdate = () => {
649
649
  const npm = getNpmPath();
650
650
  return new Promise((resolve, reject) => {
651
- execFile(npm, ["install", "-g", "agenttop@latest"], { timeout: 6e4 }, (err, stdout) => {
651
+ execFile(npm, ["install", "-g", "--force", "agenttop@latest"], { timeout: 6e4 }, (err, stdout) => {
652
652
  if (err) {
653
653
  reject(err);
654
654
  } else {
@@ -1382,6 +1382,71 @@ var FooterBar = React7.memo(
1382
1382
  import React8, { useState as useState3 } from "react";
1383
1383
  import { Box as Box8, Text as Text8, useInput as useInput2 } from "ink";
1384
1384
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1385
+ var highlightJsonLine = (line) => {
1386
+ const segments = [];
1387
+ let i = 0;
1388
+ const len = line.length;
1389
+ while (i < len) {
1390
+ const ch = line[i];
1391
+ if (ch === " " || ch === " ") {
1392
+ let end = i;
1393
+ while (end < len && (line[end] === " " || line[end] === " ")) end++;
1394
+ segments.push({ text: line.slice(i, end), color: colors.text });
1395
+ i = end;
1396
+ continue;
1397
+ }
1398
+ if (ch === "{" || ch === "}" || ch === "[" || ch === "]" || ch === "," || ch === ":") {
1399
+ segments.push({ text: ch, color: colors.muted });
1400
+ i++;
1401
+ continue;
1402
+ }
1403
+ if (ch === '"') {
1404
+ let end = i + 1;
1405
+ while (end < len && line[end] !== '"') {
1406
+ if (line[end] === "\\") end++;
1407
+ end++;
1408
+ }
1409
+ end++;
1410
+ const str = line.slice(i, end);
1411
+ let peek = end;
1412
+ while (peek < len && line[peek] === " ") peek++;
1413
+ const isKey = peek < len && line[peek] === ":";
1414
+ segments.push({ text: str, color: isKey ? colors.primary : colors.secondary });
1415
+ i = end;
1416
+ continue;
1417
+ }
1418
+ if (ch >= "0" && ch <= "9" || ch === "-") {
1419
+ let end = i + 1;
1420
+ while (end < len && (line[end] >= "0" && line[end] <= "9" || line[end] === "." || line[end] === "e" || line[end] === "E" || line[end] === "+" || line[end] === "-"))
1421
+ end++;
1422
+ segments.push({ text: line.slice(i, end), color: colors.warning });
1423
+ i = end;
1424
+ continue;
1425
+ }
1426
+ if (line.startsWith("true", i)) {
1427
+ segments.push({ text: "true", color: colors.accent });
1428
+ i += 4;
1429
+ continue;
1430
+ }
1431
+ if (line.startsWith("false", i)) {
1432
+ segments.push({ text: "false", color: colors.accent });
1433
+ i += 5;
1434
+ continue;
1435
+ }
1436
+ if (line.startsWith("null", i)) {
1437
+ segments.push({ text: "null", color: colors.error });
1438
+ i += 4;
1439
+ continue;
1440
+ }
1441
+ segments.push({ text: ch, color: colors.text });
1442
+ i++;
1443
+ }
1444
+ return segments;
1445
+ };
1446
+ var isJsonLine = (line) => {
1447
+ const trimmed = line.trimStart();
1448
+ return trimmed.startsWith("{") || trimmed.startsWith("}") || trimmed.startsWith("[") || trimmed.startsWith("]") || trimmed.startsWith('"') || /^\d/.test(trimmed) || trimmed === "true" || trimmed === "true," || trimmed === "false" || trimmed === "false," || trimmed === "null" || trimmed === "null,";
1449
+ };
1385
1450
  var renderBash = (event) => {
1386
1451
  const lines = [];
1387
1452
  const cmd = String(event.call.toolInput.command || "");
@@ -1492,7 +1557,7 @@ var renderWebSearch = (event) => {
1492
1557
  var renderDefault = (event) => {
1493
1558
  const lines = [];
1494
1559
  lines.push("--- input ---");
1495
- lines.push(JSON.stringify(event.call.toolInput, null, 2));
1560
+ lines.push(...JSON.stringify(event.call.toolInput, null, 2).split("\n"));
1496
1561
  if (event.result) {
1497
1562
  lines.push("");
1498
1563
  lines.push("--- result ---");
@@ -1566,13 +1631,26 @@ var ToolCallDetail = React8.memo(({ event, focused, height }) => {
1566
1631
  /* @__PURE__ */ jsx8(Text8, { color: colors.muted, children: "Esc:back j/k:scroll" })
1567
1632
  ] }),
1568
1633
  /* @__PURE__ */ jsx8(Box8, { flexDirection: "column", paddingX: 1, children: visible.map((line, i) => {
1569
- let lineColor = colors.text;
1570
- if (line.startsWith("- ") && event.call.toolName === "Edit") lineColor = colors.error;
1571
- else if (line.startsWith("+ ") && event.call.toolName === "Edit") lineColor = colors.secondary;
1572
- else if (line.startsWith("$ ")) lineColor = colors.bright;
1573
- else if (line.startsWith("---")) lineColor = colors.muted;
1574
- else if (event.result?.isError) lineColor = colors.error;
1575
- return /* @__PURE__ */ jsx8(Text8, { color: lineColor, wrap: "truncate", children: line }, `${start + i}`);
1634
+ if (line.startsWith("- ") && event.call.toolName === "Edit") {
1635
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.error, wrap: "truncate", children: line }, `${start + i}`);
1636
+ }
1637
+ if (line.startsWith("+ ") && event.call.toolName === "Edit") {
1638
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.secondary, wrap: "truncate", children: line }, `${start + i}`);
1639
+ }
1640
+ if (line.startsWith("$ ")) {
1641
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.bright, wrap: "truncate", children: line }, `${start + i}`);
1642
+ }
1643
+ if (line.startsWith("---")) {
1644
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.muted, wrap: "truncate", children: line }, `${start + i}`);
1645
+ }
1646
+ if (event.result?.isError) {
1647
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.error, wrap: "truncate", children: line }, `${start + i}`);
1648
+ }
1649
+ if (isJsonLine(line)) {
1650
+ const segments = highlightJsonLine(line);
1651
+ return /* @__PURE__ */ jsx8(Text8, { wrap: "truncate", children: segments.map((seg, si) => /* @__PURE__ */ jsx8(Text8, { color: seg.color, children: seg.text }, si)) }, `${start + i}`);
1652
+ }
1653
+ return /* @__PURE__ */ jsx8(Text8, { color: colors.text, wrap: "truncate", children: line }, `${start + i}`);
1576
1654
  }) }),
1577
1655
  contentLines.length > viewportRows && /* @__PURE__ */ jsx8(Box8, { paddingX: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsxs8(Text8, { color: colors.muted, children: [
1578
1656
  "[",