quotacap 0.0.16 → 0.0.18

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.
@@ -18,25 +18,39 @@ export function renderQuotasTable(quotas, advisories = []) {
18
18
  const daysLeft = a?.daysLeft != null ? a.daysLeft.toFixed(1) : "—";
19
19
  const ideal = a?.idealRate != null ? `${Math.round(a.idealRate)}%/day` : "—";
20
20
  const burn = (() => {
21
- if (a?.burnMeasured)
22
- return `${a.burnRate.toFixed(1)}%/day`;
23
- if (q.periodStart) {
24
- const elapsed = (Date.now() - new Date(q.periodStart).getTime()) / 86400000;
25
- if (elapsed > 0.1)
26
- return `${((q.usedPct ?? 0) / elapsed).toFixed(1)}%/day avg`;
21
+ const rate = a?.burnMeasured ? `${a.burnRate.toFixed(1)}%/day`
22
+ : q.periodStart ? (() => {
23
+ const elapsed = (Date.now() - new Date(q.periodStart).getTime()) / 86400000;
24
+ if (elapsed > 0.1)
25
+ return `${((q.usedPct ?? 0) / elapsed).toFixed(1)}%/day avg`;
26
+ return null;
27
+ })()
28
+ : null;
29
+ if (!rate)
30
+ return "—";
31
+ // Verdict against the ideal rate: outside the +-20% band the cell says
32
+ // (fast)/(slow); inside it a single-width check mark.
33
+ const value = a?.burnMeasured ? a.burnRate : q.periodStart ? (q.usedPct ?? 0) / Math.max(0.1, (Date.now() - new Date(q.periodStart).getTime()) / 86400000) : null;
34
+ const ideal = a?.idealRate;
35
+ if (ideal != null && value != null) {
36
+ if (value > ideal * 1.2)
37
+ return `${rate} (fast)`;
38
+ if (value < ideal * 0.8)
39
+ return `${rate} (slow)`;
40
+ return `${rate} ✔`;
27
41
  }
28
- return "—";
42
+ return rate;
29
43
  })();
30
44
  // Renderers that count emoji as one cell but paint two (Kimi, Claude
31
45
  // Code) shift the pipes after a wide glyph by +1; the status glyphs
32
46
  // live in the last column so the shift touches only the right border.
33
47
  const icon = a?.status === "at risk" ? "⚠️" : a != null ? "✅" : "—";
34
48
  const waste = a?.wastePct != null ? `${Math.round(a.wastePct)}%` : "—";
35
- return `| ${q.provider} | ${used}% | ${100 - used}% | ${resets} | ${daysLeft} | ${ideal} | ${burn} | ${waste} | ${icon} |`;
49
+ return `| ${q.provider} | ${used}% | ${100 - used}% | ${resets} | ${daysLeft} | ${ideal} | ${burn} | ${waste} |`;
36
50
  });
37
51
  return [
38
- "| Provider | Used | Remaining | Resets | Days left | Ideal daily burn | Burn rate | Waste if unused | Status |",
39
- "|---|---|---|---|---|---|---|---|---|",
52
+ "| Provider | Used | Left | Resets | Days left | Ideal daily burn | Burn rate | Waste if unused |",
53
+ "|---|---|---|---|---|---|---|---|",
40
54
  ...rows,
41
55
  ].join("\n");
42
56
  }
@@ -18,25 +18,39 @@ export function renderQuotasTable(quotas, advisories = []) {
18
18
  const daysLeft = a?.daysLeft != null ? a.daysLeft.toFixed(1) : "—";
19
19
  const ideal = a?.idealRate != null ? `${Math.round(a.idealRate)}%/day` : "—";
20
20
  const burn = (() => {
21
- if (a?.burnMeasured)
22
- return `${a.burnRate.toFixed(1)}%/day`;
23
- if (q.periodStart) {
24
- const elapsed = (Date.now() - new Date(q.periodStart).getTime()) / 86400000;
25
- if (elapsed > 0.1)
26
- return `${((q.usedPct ?? 0) / elapsed).toFixed(1)}%/day avg`;
21
+ const rate = a?.burnMeasured ? `${a.burnRate.toFixed(1)}%/day`
22
+ : q.periodStart ? (() => {
23
+ const elapsed = (Date.now() - new Date(q.periodStart).getTime()) / 86400000;
24
+ if (elapsed > 0.1)
25
+ return `${((q.usedPct ?? 0) / elapsed).toFixed(1)}%/day avg`;
26
+ return null;
27
+ })()
28
+ : null;
29
+ if (!rate)
30
+ return "—";
31
+ // Verdict against the ideal rate: outside the +-20% band the cell says
32
+ // (fast)/(slow); inside it a single-width check mark.
33
+ const value = a?.burnMeasured ? a.burnRate : q.periodStart ? (q.usedPct ?? 0) / Math.max(0.1, (Date.now() - new Date(q.periodStart).getTime()) / 86400000) : null;
34
+ const ideal = a?.idealRate;
35
+ if (ideal != null && value != null) {
36
+ if (value > ideal * 1.2)
37
+ return `${rate} (fast)`;
38
+ if (value < ideal * 0.8)
39
+ return `${rate} (slow)`;
40
+ return `${rate} ✔`;
27
41
  }
28
- return "—";
42
+ return rate;
29
43
  })();
30
44
  // Renderers that count emoji as one cell but paint two (Kimi, Claude
31
45
  // Code) shift the pipes after a wide glyph by +1; the status glyphs
32
46
  // live in the last column so the shift touches only the right border.
33
47
  const icon = a?.status === "at risk" ? "⚠️" : a != null ? "✅" : "—";
34
48
  const waste = a?.wastePct != null ? `${Math.round(a.wastePct)}%` : "—";
35
- return `| ${q.provider} | ${used}% | ${100 - used}% | ${resets} | ${daysLeft} | ${ideal} | ${burn} | ${waste} | ${icon} |`;
49
+ return `| ${q.provider} | ${used}% | ${100 - used}% | ${resets} | ${daysLeft} | ${ideal} | ${burn} | ${waste} |`;
36
50
  });
37
51
  return [
38
- "| Provider | Used | Remaining | Resets | Days left | Ideal daily burn | Burn rate | Waste if unused | Status |",
39
- "|---|---|---|---|---|---|---|---|---|",
52
+ "| Provider | Used | Left | Resets | Days left | Ideal daily burn | Burn rate | Waste if unused |",
53
+ "|---|---|---|---|---|---|---|---|",
40
54
  ...rows,
41
55
  ].join("\n");
42
56
  }
@@ -1,2 +1,2 @@
1
1
  // generated by scripts/build-embed.mjs — do not edit
2
- export const VERSION = "0.0.16";
2
+ export const VERSION = "0.0.18";