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/LICENSE +21 -21
- package/README.en.md +104 -97
- package/README.md +104 -97
- package/dist/commands.js +208 -0
- package/dist/commands.jsx +11 -2
- package/dist/generate-usage-html.js +719 -707
- package/dist/i18n.js +2 -0
- package/dist/perf-tracker.d.ts +1 -0
- package/dist/perf-tracker.js +37 -0
- package/dist/queries.js +101 -101
- package/dist/sidebar.d.ts +2 -2
- package/dist/sidebar.jsx +333 -137
- package/dist/stats-store.d.ts +23 -0
- package/dist/stats-store.js +258 -0
- package/dist/tui.jsx +80 -26
- package/package.json +63 -63
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
|
-
|
|
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
|
|
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")} ▸`,
|