opencode-top 3.3.0 → 3.3.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +36 -18
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -21256,9 +21256,13 @@ var import_react27 = __toESM(require_react(), 1);
21256
21256
  var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
21257
21257
  function buildLines(session, contentWidth, expandedIds) {
21258
21258
  const lines = [];
21259
+ let cumTokens = 0;
21259
21260
  for (const interaction of session.interactions) {
21260
21261
  if (interaction.role !== "assistant") continue;
21262
+ cumTokens += interaction.tokens.input + interaction.tokens.cacheRead + interaction.tokens.output;
21261
21263
  const dur = interaction.time.completed && interaction.time.created ? formatDuration2(interaction.time.completed - interaction.time.created) : "";
21264
+ const tokensIn = interaction.tokens.input + interaction.tokens.cacheRead;
21265
+ const tokensOut = interaction.tokens.output;
21262
21266
  lines.push({
21263
21267
  id: `h-${interaction.id}`,
21264
21268
  kind: "header",
@@ -21266,8 +21270,9 @@ function buildLines(session, contentWidth, expandedIds) {
21266
21270
  agent: interaction.agent ?? null,
21267
21271
  duration: dur,
21268
21272
  time: formatTime(interaction.time.created),
21269
- tokensIn: interaction.tokens.input + interaction.tokens.cacheRead,
21270
- tokensOut: interaction.tokens.output
21273
+ tokensIn,
21274
+ tokensOut,
21275
+ cumTokens
21271
21276
  });
21272
21277
  for (const part of interaction.parts) {
21273
21278
  if (part.type === "tool") {
@@ -21286,24 +21291,25 @@ function buildLines(session, contentWidth, expandedIds) {
21286
21291
  name: truncate4(p.toolName, 18),
21287
21292
  title: p.title ? truncate4(p.title, 28) : "",
21288
21293
  right: exitStr + dur2,
21289
- expanded
21294
+ expanded,
21295
+ cumTokens
21290
21296
  });
21291
21297
  if (expanded) {
21292
21298
  const inputKeys = Object.keys(p.input);
21293
21299
  if (inputKeys.length > 0) {
21294
- lines.push({ id: `td-${p.callId}-in`, kind: "tool-detail", label: "input", value: "", isSection: true });
21300
+ lines.push({ id: `td-${p.callId}-in`, kind: "tool-detail", label: "input", value: "", isSection: true, cumTokens });
21295
21301
  for (const key of inputKeys) {
21296
21302
  const val = formatParamValue(p.input[key], contentWidth - key.length - 6);
21297
- lines.push({ id: `td-${p.callId}-in-${key}`, kind: "tool-detail", label: key, value: val, isSection: false });
21303
+ lines.push({ id: `td-${p.callId}-in-${key}`, kind: "tool-detail", label: key, value: val, isSection: false, cumTokens });
21298
21304
  }
21299
21305
  }
21300
21306
  if (p.output?.trim()) {
21301
- lines.push({ id: `td-${p.callId}-out`, kind: "tool-detail", label: "output", value: "", isSection: true });
21307
+ lines.push({ id: `td-${p.callId}-out`, kind: "tool-detail", label: "output", value: "", isSection: true, cumTokens });
21302
21308
  const outLines = p.output.trim().split("\n").slice(0, 40);
21303
21309
  let outIdx = 0;
21304
21310
  for (const ol of outLines) {
21305
21311
  for (const wrapped of wrapText2(ol === "" ? " " : ol, contentWidth - 5)) {
21306
- lines.push({ id: `td-${p.callId}-out-${outIdx++}`, kind: "tool-detail", label: "", value: wrapped, isSection: false });
21312
+ lines.push({ id: `td-${p.callId}-out-${outIdx++}`, kind: "tool-detail", label: "", value: wrapped, isSection: false, cumTokens });
21307
21313
  }
21308
21314
  }
21309
21315
  }
@@ -21311,12 +21317,12 @@ function buildLines(session, contentWidth, expandedIds) {
21311
21317
  } else if (part.type === "text" && part.text.trim()) {
21312
21318
  let txtIdx = 0;
21313
21319
  for (const row of wrapText2(part.text.trim(), contentWidth - 3)) {
21314
- lines.push({ id: `tx-${interaction.id}-${txtIdx++}`, kind: "text", text: row });
21320
+ lines.push({ id: `tx-${interaction.id}-${txtIdx++}`, kind: "text", text: row, cumTokens });
21315
21321
  }
21316
21322
  } else if (part.type === "reasoning" && part.text.trim()) {
21317
21323
  let rIdx = 0;
21318
21324
  for (const row of wrapText2(part.text.trim(), contentWidth - 5)) {
21319
- lines.push({ id: `r-${interaction.id}-${rIdx++}`, kind: "reasoning", text: row });
21325
+ lines.push({ id: `r-${interaction.id}-${rIdx++}`, kind: "reasoning", text: row, cumTokens });
21320
21326
  }
21321
21327
  }
21322
21328
  }
@@ -21448,6 +21454,9 @@ function MessagesPanelInner({ session, maxHeight, isActive }) {
21448
21454
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { height: maxHeight, paddingX: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.textDim, children: "No messages" }) });
21449
21455
  }
21450
21456
  const visibleLines = allLines.slice(clampedOffset, clampedOffset + viewHeight);
21457
+ const cursorLine = allLines[clampedCursor];
21458
+ const cursorCumTokens = cursorLine?.cumTokens ?? 0;
21459
+ const totalTokens = allLines[allLines.length - 1]?.cumTokens ?? 0;
21451
21460
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", height: maxHeight, paddingX: 1, children: [
21452
21461
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "row", height: 1, children: [
21453
21462
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
@@ -21457,6 +21466,15 @@ function MessagesPanelInner({ session, maxHeight, isActive }) {
21457
21466
  "/",
21458
21467
  allLines.length
21459
21468
  ] }),
21469
+ totalTokens > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
21470
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.textDim, children: " \xB7 " }),
21471
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.info, children: formatTokens4(cursorCumTokens) }),
21472
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
21473
+ "/",
21474
+ formatTokens4(totalTokens),
21475
+ " tok"
21476
+ ] })
21477
+ ] }),
21460
21478
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { flexGrow: 1 }),
21461
21479
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
21462
21480
  session.interactions.filter((i) => i.role === "assistant").length,
@@ -21480,17 +21498,17 @@ function MessagesPanelInner({ session, maxHeight, isActive }) {
21480
21498
  "]"
21481
21499
  ] }),
21482
21500
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { flexGrow: 1 }),
21483
- line.tokensIn > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
21484
- "\u2193",
21485
- formatTokens4(line.tokensIn),
21486
- " "
21501
+ line.tokensIn > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
21502
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.textDim, children: "\u2193" }),
21503
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.warning, children: formatTokens4(line.tokensIn) }),
21504
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { children: " " })
21487
21505
  ] }),
21488
- line.tokensOut > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
21489
- "\u2191",
21490
- formatTokens4(line.tokensOut),
21491
- " "
21506
+ line.tokensOut > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
21507
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.textDim, children: "\u2191" }),
21508
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: colors.success, children: formatTokens4(line.tokensOut) }),
21509
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { children: " " })
21492
21510
  ] }),
21493
- line.duration && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.textDim, children: [
21511
+ line.duration && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: colors.cyan, children: [
21494
21512
  line.duration,
21495
21513
  " "
21496
21514
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-top",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Monitor OpenCode AI coding sessions - Token usage, costs, and agent analytics",
5
5
  "type": "module",
6
6
  "bin": {