opencode-statboard 2.10.9 → 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 +30 -17
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
|
@@ -549,29 +549,42 @@ class TUIServer {
|
|
|
549
549
|
const labels = trend.labels;
|
|
550
550
|
const input = trend.input || [];
|
|
551
551
|
const output = trend.output || [];
|
|
552
|
+
const reasoning = trend.reasoning || [];
|
|
553
|
+
const cache = trend.cacheRead || [];
|
|
552
554
|
const cost = trend.cost || [];
|
|
553
555
|
|
|
554
|
-
const maxVal = Math.max(...input, ...output, 1);
|
|
555
556
|
const height = this.getContentHeight() - 4;
|
|
556
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);
|
|
557
582
|
|
|
558
583
|
let out = '{center}{bold}\u2501\u2501\u2501 ' + t('trend') + ' \u2501\u2501\u2501{/bold}{/center}\n\n';
|
|
559
|
-
out += '{bold}Input (cyan) / Output (green) / Cost (yellow){/bold}\n\n';
|
|
560
584
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
for (let i = 0; i < width; i++) {
|
|
565
|
-
const idx = Math.floor(i * labels.length / width);
|
|
566
|
-
const inVal = input[idx] || 0;
|
|
567
|
-
const outVal = output[idx] || 0;
|
|
568
|
-
if (inVal >= threshold && outVal >= threshold) line += '{magenta-fg}\u2588{/magenta-fg}';
|
|
569
|
-
else if (inVal >= threshold) line += '{cyan-fg}\u2588{/cyan-fg}';
|
|
570
|
-
else if (outVal >= threshold) line += '{green-fg}\u2588{/green-fg}';
|
|
571
|
-
else line += ' ';
|
|
572
|
-
}
|
|
573
|
-
out += line + '\n';
|
|
574
|
-
}
|
|
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';
|
|
575
588
|
|
|
576
589
|
let xAxis = '';
|
|
577
590
|
const labelStep = Math.max(1, Math.ceil(width / 20));
|
|
@@ -583,7 +596,7 @@ class TUIServer {
|
|
|
583
596
|
xAxis += ' ';
|
|
584
597
|
}
|
|
585
598
|
}
|
|
586
|
-
out += '
|
|
599
|
+
out += '{gray}' + xAxis + '{/gray}\n';
|
|
587
600
|
|
|
588
601
|
const lastIdx = labels.length - 1;
|
|
589
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);
|