opencode-statboard 2.10.8 → 2.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.
- package/package.json +1 -1
- package/public/index.html +86 -40
- package/tui-dashboard.js +42 -20
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -237,12 +237,24 @@
|
|
|
237
237
|
<div class="legend">
|
|
238
238
|
<span><i class="sw" style="background:var(--in)"></i><span data-i18n="inputDay">Input / Day</span></span>
|
|
239
239
|
<span><i class="sw" style="background:var(--out)"></i><span data-i18n="outputDay">Output / Day</span></span>
|
|
240
|
+
<span id="trendStatus" style="color:var(--cache);font-size:11px"></span>
|
|
241
|
+
</div>
|
|
242
|
+
<div class="chart" id="trendInputChart"><div class="bars" id="trend-input"></div></div>
|
|
243
|
+
<div class="trend-x" id="trend-input-x"></div>
|
|
244
|
+
</div>
|
|
245
|
+
<div>
|
|
246
|
+
<div class="legend">
|
|
240
247
|
<span><i class="sw" style="background:var(--tool)"></i><span data-i18n="reasoningDay">Reasoning / Day</span></span>
|
|
248
|
+
</div>
|
|
249
|
+
<div class="chart" id="trendReasoningChart"><div class="bars" id="trend-reasoning"></div></div>
|
|
250
|
+
<div class="trend-x" id="trend-reasoning-x"></div>
|
|
251
|
+
</div>
|
|
252
|
+
<div>
|
|
253
|
+
<div class="legend">
|
|
241
254
|
<span><i class="sw" style="background:var(--cache)"></i><span data-i18n="cacheReadDay">Cache Read / Day</span></span>
|
|
242
|
-
<span id="trendStatus" style="color:var(--cache);font-size:11px"></span>
|
|
243
255
|
</div>
|
|
244
|
-
<div class="chart" id="
|
|
245
|
-
<div class="trend-x" id="trend-
|
|
256
|
+
<div class="chart" id="trendCacheChart"><div class="bars" id="trend-cache"></div></div>
|
|
257
|
+
<div class="trend-x" id="trend-cache-x"></div>
|
|
246
258
|
</div>
|
|
247
259
|
<div id="costSection">
|
|
248
260
|
<div class="legend"><span><i class="sw" style="background:var(--cost)"></i><span data-i18n="costDay">Cost / Day</span></span></div>
|
|
@@ -727,10 +739,14 @@ function renderPricing(rep) {
|
|
|
727
739
|
// ---- trend (buckets follow scope; newest day leftmost) -----------------
|
|
728
740
|
function renderTrend(data) {
|
|
729
741
|
if (!data || !data.labels || !data.labels.length) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
742
|
+
['trend-input', 'trend-output', 'trend-reasoning', 'trend-cache', 'trend-cost'].forEach(id => {
|
|
743
|
+
const el = $(id);
|
|
744
|
+
if (el) el.innerHTML = '';
|
|
745
|
+
});
|
|
746
|
+
['trend-input-x', 'trend-output-x', 'trend-reasoning-x', 'trend-cache-x', 'trend-cost-x'].forEach(id => {
|
|
747
|
+
const el = $(id);
|
|
748
|
+
if (el) el.innerHTML = '';
|
|
749
|
+
});
|
|
734
750
|
$('costZeroNote').style.display = 'none';
|
|
735
751
|
$('trendCostChart').style.display = '';
|
|
736
752
|
$('trend-cost-x').style.display = '';
|
|
@@ -749,55 +765,85 @@ function renderTrend(data) {
|
|
|
749
765
|
const sessions = data.sessions || [];
|
|
750
766
|
const n = labels.length;
|
|
751
767
|
|
|
752
|
-
const maxAll = Math.max(1, ...input, ...output, ...reasoning, ...cache);
|
|
753
768
|
const genTime = ts ? new Date(ts).toLocaleTimeString(lang === 'zh-TW' ? 'zh-TW' : 'en', { hour12: false }) : '?';
|
|
754
769
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
+ '
|
|
770
|
-
|
|
770
|
+
// Each series uses its own max for independent scaling
|
|
771
|
+
const maxIn = Math.max(1, ...input);
|
|
772
|
+
const maxOut = Math.max(1, ...output);
|
|
773
|
+
const maxReasoning = Math.max(1, ...reasoning);
|
|
774
|
+
const maxCache = Math.max(1, ...cache);
|
|
775
|
+
const maxCost = Math.max(1, ...cost);
|
|
776
|
+
|
|
777
|
+
const chartHeight = 140;
|
|
778
|
+
|
|
779
|
+
function renderSeriesChart(containerId, xAxisId, data, maxVal, color, label) {
|
|
780
|
+
const el = $(containerId);
|
|
781
|
+
if (!el) return;
|
|
782
|
+
el.innerHTML = labels.map((l, i) => {
|
|
783
|
+
const h = maxVal > 0 ? (data[i] / maxVal) * 100 : 0;
|
|
784
|
+
const tip = [l, t('sessionsLabel') + ' ' + day(sessions[i]),
|
|
785
|
+
t('tIn') + ' ' + fmt(input[i]), t('tOut') + ' ' + fmt(output[i]),
|
|
786
|
+
t('tReasoning') + ' ' + fmt(reasoning[i]), t('tCache') + ' ' + fmt(cache[i]),
|
|
787
|
+
t('totalCost') + ' ' + fmtCost(cost[i])].join(' · ') + ' · ' + genTime;
|
|
788
|
+
return `<div class="col" title="${esc(tip)}">`
|
|
789
|
+
+ `<div style="display:flex;align-items:flex-end;width:100%;height:${chartHeight}px;justify-content:center">`
|
|
790
|
+
+ `<div style="width:50%;height:${Math.max(h, 1)}%;background:${color};border-radius:2px 2px 0 0"></div>`
|
|
791
|
+
+ '</div></div>';
|
|
792
|
+
}).join('');
|
|
793
|
+
const xEl = $(xAxisId);
|
|
794
|
+
if (xEl) {
|
|
795
|
+
const labelStep = Math.max(1, Math.ceil(n / 14));
|
|
796
|
+
xEl.innerHTML = labels.map((l, i) =>
|
|
797
|
+
`<span style="${i % labelStep === 0 ? '' : 'visibility:hidden'}">${esc(l)}</span>`).join('');
|
|
798
|
+
}
|
|
799
|
+
}
|
|
771
800
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
801
|
+
// Input + Output (share chart)
|
|
802
|
+
const maxInOut = Math.max(maxIn, maxOut);
|
|
803
|
+
const inputEl = $('trend-input');
|
|
804
|
+
if (inputEl) {
|
|
805
|
+
inputEl.innerHTML = labels.map((l, i) => {
|
|
806
|
+
const hi = maxInOut > 0 ? (input[i] / maxInOut) * 100 : 0;
|
|
807
|
+
const ho = maxInOut > 0 ? (output[i] / maxInOut) * 100 : 0;
|
|
808
|
+
const tip = [l, t('sessionsLabel') + ' ' + day(sessions[i]),
|
|
809
|
+
t('tIn') + ' ' + fmt(input[i]), t('tOut') + ' ' + fmt(output[i]),
|
|
810
|
+
t('tReasoning') + ' ' + fmt(reasoning[i]), t('tCache') + ' ' + fmt(cache[i]),
|
|
811
|
+
t('totalCost') + ' ' + fmtCost(cost[i])].join(' · ') + ' · ' + genTime;
|
|
812
|
+
return `<div class="col" title="${esc(tip)}">`
|
|
813
|
+
+ '<div style="display:flex;gap:2px;align-items:flex-end;width:100%;height:140px;justify-content:center">'
|
|
814
|
+
+ '<div style="position:relative;width:100%;height:100%">'
|
|
815
|
+
+ `<div class="trend-bar trend-bar-input" style="height:${Math.max(hi, 1)}%;background:var(--in)"></div>`
|
|
816
|
+
+ `<div class="trend-bar trend-bar-output" style="height:${Math.max(ho, 1)}%;background:var(--out)"></div>`
|
|
817
|
+
+ '</div></div></div>';
|
|
818
|
+
}).join('');
|
|
819
|
+
const labelStep = Math.max(1, Math.ceil(n / 14));
|
|
820
|
+
const xEl = $('trend-input-x');
|
|
821
|
+
if (xEl) xEl.innerHTML = labels.map((l, i) =>
|
|
822
|
+
`<span style="${i % labelStep === 0 ? '' : 'visibility:hidden'}">${esc(l)}</span>`).join('');
|
|
823
|
+
}
|
|
775
824
|
|
|
776
|
-
|
|
825
|
+
// Reasoning
|
|
826
|
+
renderSeriesChart('trend-reasoning', 'trend-reasoning-x', reasoning, maxReasoning, 'var(--tool)', t('tReasoning'));
|
|
827
|
+
// Cache
|
|
828
|
+
renderSeriesChart('trend-cache', 'trend-cache-x', cache, maxCache, 'var(--cache)', t('tCache'));
|
|
829
|
+
// Cost
|
|
777
830
|
const anyCost = cost.some((v) => v > 0);
|
|
778
831
|
const costLegend = $('costSection').querySelector('.legend');
|
|
779
832
|
if (!anyCost) {
|
|
780
833
|
$('trendCostChart').style.display = 'none';
|
|
781
834
|
$('trend-cost-x').style.display = 'none';
|
|
782
|
-
costLegend.style.display = 'none';
|
|
835
|
+
if (costLegend) costLegend.style.display = 'none';
|
|
783
836
|
$('costZeroNote').style.display = '';
|
|
784
837
|
$('costZeroNote').textContent = t('allFree');
|
|
785
838
|
return;
|
|
786
839
|
}
|
|
787
|
-
costLegend.style.display = '';
|
|
840
|
+
if (costLegend) costLegend.style.display = '';
|
|
788
841
|
$('trendCostChart').style.display = '';
|
|
789
842
|
$('trend-cost-x').style.display = '';
|
|
790
843
|
$('costZeroNote').style.display = 'none';
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return `<div class="col" title="${esc(l + ' · ' + fmtCost(cost[i]) + ' · ' + genTime)}">`
|
|
795
|
-
+ '<div style="display:flex;align-items:flex-end;width:100%;height:170px;justify-content:center">'
|
|
796
|
-
+ `<div style="width:50%;height:${Math.max(h, 1)}%;background:var(--cost);border-radius:2px 2px 0 0"></div>`
|
|
797
|
-
+ '</div></div>';
|
|
798
|
-
}).join('');
|
|
799
|
-
$('trend-cost-x').innerHTML = labels.map((l, i) =>
|
|
800
|
-
`<span style="${i % labelStep === 0 ? '' : 'visibility:hidden'}">${esc(l)}</span>`).join('');
|
|
844
|
+
renderSeriesChart('trend-cost', 'trend-cost-x', cost, maxCost, 'var(--cost)', t('totalCost'));
|
|
845
|
+
|
|
846
|
+
$('trendStatus').textContent = data.stale ? ' ⟳ ' + t('updating') : '';
|
|
801
847
|
}
|
|
802
848
|
|
|
803
849
|
// ---- heatmap (daily token intensity, last 90 days) ---------------------
|
package/tui-dashboard.js
CHANGED
|
@@ -441,6 +441,15 @@ class TUIServer {
|
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
fillScreen(lines) {
|
|
445
|
+
const height = this.getContentHeight();
|
|
446
|
+
const width = this.getContentWidth();
|
|
447
|
+
const contentWidth = width - 2; // account for borders
|
|
448
|
+
const contentHeight = height - 2;
|
|
449
|
+
while (lines.length < contentHeight) lines.push('');
|
|
450
|
+
return lines.map(l => l.padEnd(contentWidth)).join('\n');
|
|
451
|
+
}
|
|
452
|
+
|
|
444
453
|
renderOverview() {
|
|
445
454
|
const ov = this.data;
|
|
446
455
|
const t = this.t.bind(this);
|
|
@@ -472,7 +481,7 @@ class TUIServer {
|
|
|
472
481
|
'{bold}' + t('avgCostDay') + ':{/bold} ' + this.formatCost(cost.avgCostPerDay || 0),
|
|
473
482
|
'{bold}' + t('avgTokensDay') + ':{/bold} ' + this.formatNumber(cost.avgTokensPerDay || 0)
|
|
474
483
|
];
|
|
475
|
-
return
|
|
484
|
+
return this.fillScreen(lines);
|
|
476
485
|
}
|
|
477
486
|
|
|
478
487
|
renderProjects() {
|
|
@@ -501,7 +510,7 @@ class TUIServer {
|
|
|
501
510
|
lines.push('{gray}... ' + t('noData') + ' ' + (projects.length - 50) + ' ' + t('projects') + '{/gray}');
|
|
502
511
|
}
|
|
503
512
|
|
|
504
|
-
return
|
|
513
|
+
return this.fillScreen(lines);
|
|
505
514
|
}
|
|
506
515
|
|
|
507
516
|
renderModels() {
|
|
@@ -527,7 +536,7 @@ class TUIServer {
|
|
|
527
536
|
lines.push(namePad + ' ' + provPad + ' ' + tokPad + ' ' + costPad + ' ' + speedPad);
|
|
528
537
|
}
|
|
529
538
|
|
|
530
|
-
return
|
|
539
|
+
return this.fillScreen(lines);
|
|
531
540
|
}
|
|
532
541
|
|
|
533
542
|
renderTrend() {
|
|
@@ -540,29 +549,42 @@ class TUIServer {
|
|
|
540
549
|
const labels = trend.labels;
|
|
541
550
|
const input = trend.input || [];
|
|
542
551
|
const output = trend.output || [];
|
|
552
|
+
const reasoning = trend.reasoning || [];
|
|
553
|
+
const cache = trend.cacheRead || [];
|
|
543
554
|
const cost = trend.cost || [];
|
|
544
555
|
|
|
545
|
-
const maxVal = Math.max(...input, ...output, 1);
|
|
546
556
|
const height = this.getContentHeight() - 4;
|
|
547
557
|
const width = this.getContentWidth();
|
|
558
|
+
const chartHeight = Math.max(1, Math.floor(height / 3) - 2); // 3 charts, each ~1/3 height
|
|
559
|
+
|
|
560
|
+
// Helper: render one chart with its own max
|
|
561
|
+
const renderChart = (data, label, color, maxVal) => {
|
|
562
|
+
if (maxVal <= 0) return '{gray}(no data){/gray}\n';
|
|
563
|
+
let lines = [];
|
|
564
|
+
lines.push('{bold}' + label + ':{/bold}');
|
|
565
|
+
for (let row = chartHeight - 1; row >= 0; row--) {
|
|
566
|
+
let line = '';
|
|
567
|
+
const threshold = (row / chartHeight) * maxVal;
|
|
568
|
+
for (let i = 0; i < width; i++) {
|
|
569
|
+
const idx = Math.floor(i * labels.length / width);
|
|
570
|
+
const val = data[idx] || 0;
|
|
571
|
+
if (val >= threshold) line += '{' + color + '-fg}\u2588{/}';
|
|
572
|
+
else line += ' ';
|
|
573
|
+
}
|
|
574
|
+
lines.push(line);
|
|
575
|
+
}
|
|
576
|
+
return lines.join('\n');
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
const maxIn = Math.max(...input, 1);
|
|
580
|
+
const maxOut = Math.max(...output, 1);
|
|
581
|
+
const maxCost = Math.max(...cost, 1);
|
|
548
582
|
|
|
549
583
|
let out = '{center}{bold}\u2501\u2501\u2501 ' + t('trend') + ' \u2501\u2501\u2501{/bold}{/center}\n\n';
|
|
550
|
-
out += '{bold}Input (cyan) / Output (green) / Cost (yellow){/bold}\n\n';
|
|
551
584
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
for (let i = 0; i < width; i++) {
|
|
556
|
-
const idx = Math.floor(i * labels.length / width);
|
|
557
|
-
const inVal = input[idx] || 0;
|
|
558
|
-
const outVal = output[idx] || 0;
|
|
559
|
-
if (inVal >= threshold && outVal >= threshold) line += '{magenta-fg}\u2588{/magenta-fg}';
|
|
560
|
-
else if (inVal >= threshold) line += '{cyan-fg}\u2588{/cyan-fg}';
|
|
561
|
-
else if (outVal >= threshold) line += '{green-fg}\u2588{/green-fg}';
|
|
562
|
-
else line += ' ';
|
|
563
|
-
}
|
|
564
|
-
out += line + '\n';
|
|
565
|
-
}
|
|
585
|
+
out += renderChart(input, t('input') + ' (cyan)', 'cyan', maxIn) + '\n';
|
|
586
|
+
out += renderChart(output, t('output') + ' (green)', 'green', maxOut) + '\n';
|
|
587
|
+
out += renderChart(cost, t('cost') + ' (yellow)', 'yellow', maxCost) + '\n';
|
|
566
588
|
|
|
567
589
|
let xAxis = '';
|
|
568
590
|
const labelStep = Math.max(1, Math.ceil(width / 20));
|
|
@@ -574,7 +596,7 @@ class TUIServer {
|
|
|
574
596
|
xAxis += ' ';
|
|
575
597
|
}
|
|
576
598
|
}
|
|
577
|
-
out += '
|
|
599
|
+
out += '{gray}' + xAxis + '{/gray}\n';
|
|
578
600
|
|
|
579
601
|
const lastIdx = labels.length - 1;
|
|
580
602
|
out += '\n{bold}' + t('today') + ':{/bold} Input: ' + this.formatNumber(input[lastIdx] || 0) + ' | Output: ' + this.formatNumber(output[lastIdx] || 0) + ' | Cost: ' + this.formatCost(cost[lastIdx] || 0);
|