@ordewell/cli 0.10.8 → 0.10.10

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/main.js +17 -42
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -2574,7 +2574,7 @@ function runnerCommandLines(block2, cols, detailAll) {
2574
2574
  return [head, ...underHeader(shown.map(style.grey))];
2575
2575
  }
2576
2576
  function compactionLine(block2, cols) {
2577
- const sizes = block2.preTokens !== void 0 && block2.postTokens !== void 0 ? ` \xB7 ${compactCount(block2.preTokens)} \u2192 ${compactCount(block2.postTokens)} tokens` : "";
2577
+ const sizes = block2.preTokens !== void 0 && block2.postTokens !== void 0 ? ` \xB7 ${(0, import_core14.formatTokenCount)(block2.preTokens)} \u2192 ${(0, import_core14.formatTokenCount)(block2.postTokens)} tokens` : "";
2578
2578
  const text = block2.trigger === "auto" && !sizes ? "\u2261 Context compacted by the runner on its own" : `\u2261 Context compacted${sizes}`;
2579
2579
  return style.grey(truncate(text, cols));
2580
2580
  }
@@ -2650,37 +2650,10 @@ function conversationLines(blocks2, cols, detailAll, answering) {
2650
2650
  }
2651
2651
  return lines;
2652
2652
  }
2653
- function compactCount(n) {
2654
- if (n < 1e3) return String(n);
2655
- const [value, unit] = n < 999950 ? [n / 1e3, "k"] : [n / 1e6, "M"];
2656
- return `${value.toFixed(1).replace(/\.0$/, "")}${unit}`;
2657
- }
2658
- function formatCost(currency, amount) {
2659
- const [whole, frac = ""] = amount.toFixed(4).replace(/0+$/, "").split(".");
2660
- const value = `${whole}.${frac.padEnd(2, "0")}`;
2661
- return currency.toLowerCase() === "usd" ? `$${value}` : `${value} ${currency.toUpperCase()}`;
2662
- }
2663
2653
  function tokenLine(blocks2, cols) {
2664
2654
  const usage = blocks2[blocks2.length - 1];
2665
- if (usage?.type !== "usage") return null;
2666
- const parts = usageMeasures(usage.totals);
2667
- if (usage.model && !usage.contextFill) parts.push("ctx unknown");
2668
- if (usage.contextFill) parts.splice(2, 0, `${Math.round(usage.contextFill.usedTokens / usage.contextFill.windowTokens * 100)}% ctx`);
2669
- return parts.length > 0 ? style.grey(truncate(parts.join(" \xB7 "), cols)) : null;
2670
- }
2671
- function usageMeasures(totals) {
2672
- return [
2673
- ...totals.inputTokens !== void 0 ? [`${compactCount(totals.inputTokens)} in`] : [],
2674
- ...totals.outputTokens !== void 0 ? [`${compactCount(totals.outputTokens)} out`] : [],
2675
- ...totals.cachedInputTokens !== void 0 ? [`${compactCount(totals.cachedInputTokens)} cached`] : [],
2676
- ...Object.entries(totals.reportedCost ?? {}).map(([currency, amount]) => formatCost(currency, amount))
2677
- ];
2678
- }
2679
- function taskUsageText(usage) {
2680
- return [
2681
- ...usageMeasures(usage.totals),
2682
- ...usage.attempt !== void 0 ? [usage.contextFill ? `ctx ${Math.round(usage.contextFill.usedTokens / usage.contextFill.windowTokens * 100)}%` : "ctx unknown"] : []
2683
- ].join(" \xB7 ");
2655
+ const text = usage?.type === "usage" ? (0, import_core14.usageText)(usage) : null;
2656
+ return text ? style.grey(truncate(text, cols)) : null;
2684
2657
  }
2685
2658
  function assignmentFlagText(row) {
2686
2659
  return `${row.assignmentFlag} \u2014 ${row.assignmentConsequence}`;
@@ -2767,8 +2740,8 @@ function printOneSession(sessionId, meta, plan, runnerScope) {
2767
2740
  if (isolation) console.log(`Base: ${handoffBase(isolation.handoff, 8)}`);
2768
2741
  console.log(`Tasks: ${everyTask.length} total | ${count("completed")} done | ${count("failed")} failed | ${count("in_progress")} running | ${count("blocked")} blocked | ${count("skipped")} skipped
2769
2742
  `);
2770
- const usage = (0, import_core15.planUsage)(allTasks);
2771
- if (usage.attempts) console.log(`Tasks total: ${taskUsageText(usage)}`);
2743
+ const total = (0, import_core15.tasksTotalText)(allTasks);
2744
+ if (total) console.log(total);
2772
2745
  const record = servedApprovalRecord(plan);
2773
2746
  const approval = (row, ref) => row.waitsForApproval ? `${row.waitsForApproval}: \`ordewell force-start ${ref}\` approves it, \`ordewell run\` approves all` : null;
2774
2747
  for (const t of allTasks) {
@@ -2782,7 +2755,8 @@ function printOneSession(sessionId, meta, plan, runnerScope) {
2782
2755
  if (row.assignmentFlag) console.log(` \u26A0 ${assignmentFlagText(row)}`);
2783
2756
  if (row.blockedBy) console.log(` ${(0, import_core15.blockedByLabel)(row.blockedBy)}`);
2784
2757
  if (row.status === "skipped") console.log(` ${(0, import_core15.skippedLabel)(row.skipReason)}`);
2785
- if (row.usage) console.log(` ${taskUsageText(row.usage)}`);
2758
+ const usage = row.usage && (0, import_core15.usageText)(row.usage);
2759
+ if (usage) console.log(` ${usage}`);
2786
2760
  for (const sub of t.subtasks || []) {
2787
2761
  const subIcon = iconFor(blocked.has(sub.id) ? "blocked" : sub.status);
2788
2762
  const subModel = sub.assignedModel ? ` (${sub.assignedModel.modelLabel})` : "";
@@ -2794,7 +2768,8 @@ function printOneSession(sessionId, meta, plan, runnerScope) {
2794
2768
  if (subRow.assignmentFlag) console.log(` \u26A0 ${assignmentFlagText(subRow)}`);
2795
2769
  if (subRow.blockedBy) console.log(` ${(0, import_core15.blockedByLabel)(subRow.blockedBy)}`);
2796
2770
  if (subRow.status === "skipped") console.log(` ${(0, import_core15.skippedLabel)(subRow.skipReason)}`);
2797
- if (subRow.usage) console.log(` ${taskUsageText(subRow.usage)}`);
2771
+ const subUsage = subRow.usage && (0, import_core15.usageText)(subRow.usage);
2772
+ if (subUsage) console.log(` ${subUsage}`);
2798
2773
  }
2799
2774
  }
2800
2775
  }
@@ -5373,11 +5348,11 @@ function taskUsageFooter(state, tv, blocks2, cols) {
5373
5348
  const reported = task?.attemptUsage ?? [];
5374
5349
  if (!task || reported.length === 0) return tokenRow(blocks2, cols);
5375
5350
  const onScreen = tv.attempt > 0 ? reported.find((a) => a.attempt === tv.attempt) : reported.at(-1);
5376
- const spend = (0, import_core34.taskUsageSummary)(task);
5377
- const total = taskUsageText({ ...spend, attempt: reported.at(-1)?.attempt ?? 0 });
5378
- if (onScreen === reported.at(-1)) return [style.grey(truncate(total, cols))];
5379
- const own = onScreen ? [style.grey(truncate(`attempt ${onScreen.attempt}: ${taskUsageText({ totals: onScreen.totals, contextFill: (0, import_core34.plannerContextFill)(onScreen), attempt: onScreen.attempt })}`, cols))] : tokenRow(blocks2, cols);
5380
- return [...own, style.grey(truncate(`task total: ${total}`, cols))];
5351
+ const total = (0, import_core34.usageText)((0, import_core34.taskUsageSummary)(task));
5352
+ const totalRow = total ? [style.grey(truncate(onScreen === reported.at(-1) ? total : `task total: ${total}`, cols))] : [];
5353
+ if (onScreen === reported.at(-1)) return totalRow;
5354
+ const own = onScreen ? (0, import_core34.usageText)({ totals: onScreen.totals, contextFill: (0, import_core34.plannerContextFill)(onScreen) }) : null;
5355
+ return [...onScreen ? own ? [style.grey(truncate(`attempt ${onScreen.attempt}: ${own}`, cols))] : [] : tokenRow(blocks2, cols), ...totalRow];
5381
5356
  }
5382
5357
  function chatScrollMax(state) {
5383
5358
  return chatLayout(state, bodyRows(state), chatPaneWidth(state)).maxScroll;
@@ -5533,18 +5508,18 @@ var STATUS_ICON = {
5533
5508
  var inRow = (label) => label.charAt(0).toLowerCase() + label.slice(1);
5534
5509
  function planLayout(state, rows, cols) {
5535
5510
  const done = state.tasks.filter((t) => t.status === "completed").length;
5536
- const totalUsage = (0, import_core34.planUsage)(state.tasks);
5511
+ const totalUsage = (0, import_core34.tasksTotalText)(state.tasks);
5537
5512
  const unmerged = state.runMerge?.handoff.landed.length ?? 0;
5538
5513
  const count = `${done}/${state.tasks.length}`;
5539
5514
  const hints = runHints(state);
5540
5515
  const hint = hints.find((h) => width(`Plan ${count} \xB7 ${h}`) <= cols) ?? hints.at(-1);
5541
5516
  const lines = [
5542
5517
  truncate(`${style.bold(style.brand("Plan"))} ${style.grey(`${count}${hint ? ` \xB7 ${hint}` : ""}`)}`, cols),
5543
- totalUsage.attempts ? style.grey(truncate(`Tasks total: ${taskUsageText(totalUsage)}`, cols)) : ""
5518
+ totalUsage ? style.grey(truncate(totalUsage, cols)) : ""
5544
5519
  ];
5545
5520
  if (unmerged > 0) {
5546
5521
  const landed = style.dim(truncate(`${unmerged} landed task${unmerged === 1 ? "" : "s"} not merged: /handoff merge`, cols));
5547
- if (totalUsage.attempts) lines.push(landed);
5522
+ if (totalUsage) lines.push(landed);
5548
5523
  else lines[1] = landed;
5549
5524
  }
5550
5525
  const firstRowLine = lines.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordewell/cli",
3
- "version": "0.10.8",
3
+ "version": "0.10.10",
4
4
  "description": "Ordewell CLI and TUI — plan, run and verify coding-agent tasks from the terminal.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Alessandro Costanzo Ciano",
@@ -51,8 +51,8 @@
51
51
  "typecheck": "tsc --noEmit"
52
52
  },
53
53
  "dependencies": {
54
- "@ordewell/core": "^0.10.8",
55
- "@ordewell/web": "^0.10.8",
54
+ "@ordewell/core": "^0.10.10",
55
+ "@ordewell/web": "^0.10.10",
56
56
  "string-width": "^7.2.0",
57
57
  "ws": "^8.18.0"
58
58
  },