@jeffreyjyz/opencode-command-code 0.3.13 → 0.3.14

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
@@ -4063,7 +4063,7 @@ var commandCodeV2 = {
4063
4063
  // package.json
4064
4064
  var package_default = {
4065
4065
  name: "@jeffreyjyz/opencode-command-code",
4066
- version: "0.3.13",
4066
+ version: "0.3.14",
4067
4067
  description: "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
4068
4068
  type: "module",
4069
4069
  main: "dist/index.js",
@@ -9,9 +9,10 @@ export declare const WEEKLY_SECS: number;
9
9
  */
10
10
  export declare function elapsedPct(resetAtMs: number | undefined, durSecs: number, nowSecs: number): number | undefined;
11
11
  /**
12
- * `elapsedPct` as text: a seven-day window forty minutes in is 0.4%, and "0%"
13
- * reads as "not started". Non-zero fractions below a percent render "<1%".
14
- * Exact zero stays "0%".
12
+ * `elapsedPct` as text, one decimal: a seven-day window forty minutes in is
13
+ * "0.4%". Only a fraction too small to show at one decimal (<0.05%) reads
14
+ * "<0.1%", so a just-started window is not mistaken for an unstarted one.
15
+ * Exact zero stays "0.0%".
15
16
  */
16
17
  export declare function elapsedLabel(resetAtMs: number | undefined, durSecs: number, nowSecs: number): string | undefined;
17
18
  /**
package/dist/tui.js CHANGED
@@ -458,15 +458,15 @@ function elapsedPct(resetAtMs, durSecs, nowSecs) {
458
458
  if (nowSecs < start)
459
459
  return;
460
460
  const pct = (nowSecs - start) / durSecs * 100;
461
- return Math.round(Math.min(100, Math.max(0, pct)));
461
+ return Math.round(Math.min(100, Math.max(0, pct)) * 10) / 10;
462
462
  }
463
463
  function elapsedLabel(resetAtMs, durSecs, nowSecs) {
464
464
  const pct = elapsedPct(resetAtMs, durSecs, nowSecs);
465
465
  if (pct === undefined)
466
466
  return;
467
467
  if (pct === 0 && nowSecs > Math.floor(resetAtMs / 1000) - durSecs)
468
- return "<1%";
469
- return `${pct}%`;
468
+ return "<0.1%";
469
+ return `${pct.toFixed(1)}%`;
470
470
  }
471
471
  function paceEtaSecs(resetAtMs, durSecs, used, cap, nowSecs) {
472
472
  if (typeof resetAtMs !== "number" || !Number.isFinite(resetAtMs))
@@ -551,14 +551,14 @@ function windowRows(label, w, now, durSecs) {
551
551
  if (!w || typeof w.cap !== "number" || w.cap <= 0)
552
552
  return [];
553
553
  const used = typeof w.used === "number" ? w.used : 0;
554
- const pct = Math.round(used / w.cap * 100);
554
+ const pct = used / w.cap * 100;
555
555
  const nowSecs = Math.floor(now / 1000);
556
556
  const elapsed = elapsedLabel(w.resetAt, durSecs, nowSecs);
557
557
  const eta = paceEtaSecs(w.resetAt, durSecs, used, w.cap, nowSecs);
558
558
  const reset = until(w.resetAt, now);
559
559
  const lead = w.exceeded ? "LIMIT EXCEEDED" : eta === undefined ? elapsed === undefined ? "" : `${elapsed} elapsed` : `cap in ${until(now + eta * 1000, now)}`;
560
560
  const detail = [lead, reset ? `resets ${reset}` : ""].filter(Boolean).join(" \xB7 ");
561
- return [[label, `${money(used)}/${money(w.cap)} (${pct}%)`, w.exceeded ? "crit" : pctTone(pct)], ...detail ? [["", detail, "muted"]] : []];
561
+ return [[label, `${money(used)}/${money(w.cap)} (${pct.toFixed(1)}%)`, w.exceeded ? "crit" : pctTone(pct)], ...detail ? [["", detail, "muted"]] : []];
562
562
  }
563
563
  function monthlyDetail(usage, now) {
564
564
  const {
@@ -585,8 +585,8 @@ function usageRows(usage, now = Date.now()) {
585
585
  }
586
586
  if (typeof usage.monthlyCap === "number" && typeof usage.monthlyCredits === "number") {
587
587
  const used = Math.min(usage.monthlyCap, Math.max(0, usage.monthlyCap - usage.monthlyCredits));
588
- const pct = usage.monthlyCap > 0 ? Math.round(used / usage.monthlyCap * 100) : 0;
589
- rows.push(["Monthly", `${money(used)} / ${money(usage.monthlyCap)} (${pct}%)`, pctTone(pct)]);
588
+ const pct = usage.monthlyCap > 0 ? used / usage.monthlyCap * 100 : 0;
589
+ rows.push(["Monthly", `${money(used)} / ${money(usage.monthlyCap)} (${pct.toFixed(1)}%)`, pctTone(pct)]);
590
590
  const detail = monthlyDetail(usage, now);
591
591
  if (detail)
592
592
  rows.push(["", detail, "muted"]);
@@ -1913,8 +1913,8 @@ function windowRows2(label, spent, limit, share) {
1913
1913
  return [[label, `${money(spent.cost)} \xB7 ${count(spent.requests)} req`, "base"]];
1914
1914
  }
1915
1915
  const cap = limit * share;
1916
- const pct = cap > 0 ? Math.round(spent.cost / cap * 100) : 0;
1917
- const rows = [[label, `${money(spent.cost)}/${money(cap)} (${pct}%)`, pctTone(pct)]];
1916
+ const pct = cap > 0 ? spent.cost / cap * 100 : 0;
1917
+ const rows = [[label, `${money(spent.cost)}/${money(cap)} (${pct.toFixed(1)}%)`, pctTone(pct)]];
1918
1918
  if (spent.requests > 0)
1919
1919
  rows.push(["", `${count(spent.requests)} req`, "muted"]);
1920
1920
  return rows;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffreyjyz/opencode-command-code",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",