opencode-statboard 2.8.0 → 2.8.2
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/AGENTS.md +1 -0
- package/package.json +1 -1
- package/public/index.html +7 -6
- package/server.js +5 -5
package/AGENTS.md
CHANGED
|
@@ -32,6 +32,7 @@ The message table is ~1GB of JSON; scanning it with `json_extract` costs **43s**
|
|
|
32
32
|
Rules that keep it fast:
|
|
33
33
|
|
|
34
34
|
- **Nothing on the request path may run a full scan.** `toolCountsFor()` returns the worker/cached counts while a worker round is in flight; only if the worker is unavailable does it fall back to an inline scan.
|
|
35
|
+
- **The bundle cache is keyed on the DB PATH only.** Keying it on size/mtime looked safer but the live DB grows on every message, so the fingerprint changed constantly and the "instant" cold start silently degraded back to a 6–7s rebuild on a busy machine.
|
|
35
36
|
- **Reports refuse to build without a bundle** (`refreshReport` returns `ready:false`), otherwise an all-zero report sits in the 10-minute cache and blanks the dashboard.
|
|
36
37
|
- The bundle is persisted with its tool counts, so a cold start paints complete numbers before the first worker round lands. `settleBundle` repaints and prewarms the default scope report.
|
|
37
38
|
- The frontend `warmOtherScopes()` fetches the scopes the user is NOT looking at, on idle, so a scope click is an in-memory swap.
|
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -308,7 +308,7 @@ const STRINGS = {
|
|
|
308
308
|
headline: 'HEADLINE', trend: 'TREND', breakdown: 'BREAKDOWN', toolUsage: 'TOOLS',
|
|
309
309
|
pricingBasis: 'PRICING BASIS', rawText: 'RAW TEXT',
|
|
310
310
|
rawHint: 'Plain-text statement, same numbers as the tables above.',
|
|
311
|
-
tokens: 'Tokens', tIn: 'in', tOut: 'out', tReasoning: 'reasoning', tCache: 'cache re-reads',
|
|
311
|
+
tokens: 'Tokens', tIn: 'in', tOut: 'out', tReasoning: 'reasoning', tCache: 'cache re-reads', tokensExclCache: 'new tokens (excl. cache re-reads): {v}',
|
|
312
312
|
totalCost: 'Total Cost', marketValue: 'Market Value', saved: 'Saved',
|
|
313
313
|
costShare: 'actual paid', atCatalog: 'same usage at catalog list prices',
|
|
314
314
|
savedOf: '{pct} of market value',
|
|
@@ -354,7 +354,7 @@ const STRINGS = {
|
|
|
354
354
|
headline: '重點指標', trend: '趨勢', breakdown: '明細', toolUsage: '工具',
|
|
355
355
|
pricingBasis: '定價依據', rawText: '原始文字',
|
|
356
356
|
rawHint: '純文字報表,數字與上方表格一致。',
|
|
357
|
-
tokens: 'Tokens', tIn: '輸入', tOut: '輸出', tReasoning: '推理', tCache: '快取重讀',
|
|
357
|
+
tokens: 'Tokens', tIn: '輸入', tOut: '輸出', tReasoning: '推理', tCache: '快取重讀', tokensExclCache: '新 token(不含快取重讀):{v}',
|
|
358
358
|
totalCost: '總費用', marketValue: '市價', saved: '已節省',
|
|
359
359
|
costShare: '實際付費', atCatalog: '同等用量依牌價換算',
|
|
360
360
|
savedOf: '占市價 {pct}',
|
|
@@ -532,11 +532,12 @@ function renderReport(rep) {
|
|
|
532
532
|
const o = (rep.stats && rep.stats.overview) || {};
|
|
533
533
|
const cacheAll = (c.cacheRead || 0) + (c.cacheWrite || 0);
|
|
534
534
|
|
|
535
|
-
//
|
|
536
|
-
//
|
|
535
|
+
// Headline = every token the models processed, cache re-reads included (the
|
|
536
|
+
// big number). The new-token subtotal sits below it, because cache reads
|
|
537
|
+
// re-count the same context on every turn and would otherwise be invisible.
|
|
537
538
|
const coreTok = (c.input || 0) + (c.output || 0) + (c.reasoning || 0);
|
|
538
|
-
$('hl-tokens').textContent = fmt(coreTok);
|
|
539
|
-
$('hl-tokens-incl').textContent = fmtLang('
|
|
539
|
+
$('hl-tokens').textContent = fmt(coreTok + cacheAll);
|
|
540
|
+
$('hl-tokens-incl').textContent = fmtLang('tokensExclCache', { v: fmt(coreTok) });
|
|
540
541
|
$('hl-in').textContent = fmt(c.input);
|
|
541
542
|
$('hl-out').textContent = fmt(c.output);
|
|
542
543
|
$('hl-reasoning').textContent = fmt(c.reasoning);
|
package/server.js
CHANGED
|
@@ -585,13 +585,13 @@ async function buildAttrBundle(now) {
|
|
|
585
585
|
// serves every request while a fresh one is rebuilt in the background.
|
|
586
586
|
const BUNDLE_FILE = path.join(__dirname, '.attr-bundle.json');
|
|
587
587
|
const BUNDLE_SAVE_MS = 60000; // don't hammer the disk while chatting
|
|
588
|
-
// Cache is bound to the
|
|
588
|
+
// Cache is bound to the DATABASE PATH it was computed from, so pointing
|
|
589
589
|
// OPENCODE_DATA at another DB (tests, a restored copy) never reuses it.
|
|
590
|
+
// Deliberately NOT keyed on size/mtime: the live DB grows on every message,
|
|
591
|
+
// so a stat-based fingerprint invalidated the cache on every restart and
|
|
592
|
+
// silently turned the instant cold start back into a full 6-7s rebuild.
|
|
590
593
|
function dbFingerprint() {
|
|
591
|
-
|
|
592
|
-
const st = fs.statSync(BACKUP_SRC);
|
|
593
|
-
return `${BACKUP_SRC}|${st.size}|${Math.round(st.mtimeMs)}`;
|
|
594
|
-
} catch (_) { return BACKUP_SRC; }
|
|
594
|
+
return BACKUP_SRC;
|
|
595
595
|
}
|
|
596
596
|
function serializeBundle(a, tools) {
|
|
597
597
|
// MUST NOT mutate: the caller serializes the LIVE bundle, and swapping a
|