opencode-tokenwatch 0.3.0 → 0.3.1

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/commands.jsx CHANGED
@@ -3,6 +3,7 @@ import { formatUsageReport } from "./formatter.js";
3
3
  import { generateUsageHtml } from "./generate-usage-html.js";
4
4
  import { t, setLanguage } from "./i18n.js";
5
5
  import { readLogs } from "./perf-tracker.js";
6
+ import { readPersistedStats } from "./stats-store.js";
6
7
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
7
8
  import { join } from "node:path";
8
9
  import { homedir } from "node:os";
@@ -144,7 +145,11 @@ function aggregatePerfStats(logs) {
144
145
  }
145
146
  async function buildCombinedData(api, filters = {}) {
146
147
  const report = await getUsageReport(filters);
147
- const logs = readLogs(1000);
148
+ // perfLogs: 仅用于 JSON 导出参考,保持适当窗口即可
149
+ const logs = readLogs(200);
150
+ // perfSummary: 使用持久化聚合统计,包含自插件安装以来的全量历史数据
151
+ // 不再受 readLogs 窗口限制,即使 JSONL 被轮转,历史指标也不会丢失
152
+ const perfSummary = readPersistedStats();
148
153
  const now = new Date();
149
154
  const pad = (n) => String(n).padStart(2, '0');
150
155
  const meta = {
@@ -157,7 +162,7 @@ async function buildCombinedData(api, filters = {}) {
157
162
  return {
158
163
  ...report,
159
164
  perfLogs: logs,
160
- perfSummary: aggregatePerfStats(logs),
165
+ perfSummary,
161
166
  meta,
162
167
  };
163
168
  }
@@ -208,6 +213,10 @@ function showHtmlReportRangeMenu(api, dialog) {
208
213
  ]} flat={true}/>));
209
214
  }
210
215
  function showUsageMenu(api, dialog) {
216
+ try {
217
+ setLanguage(loadConfigFromStore(api).language);
218
+ }
219
+ catch { }
211
220
  dialog.replace(() => (<api.ui.DialogSelect title={t("panelTitle")} placeholder="Select an action..." options={[
212
221
  {
213
222
  title: `${t("cmdTitleHtml")} ▸`,