pi-opencode-go-usage 1.0.2 → 1.0.3
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/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/extensions/opencode-go-usage.ts +12 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Track OpenCode Go usage limits — **rolling 5-hour, weekly, and monthly** — in-session
|
|
8
8
|
with a live status bar and a `/opencode-go` report widget.
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
```
|
|
12
12
|
Status bar: Go 5h 62% · wk 31% · mo 44%
|
|
@@ -78,6 +78,7 @@ or use the slash command (persists to `~/.omp/agent/opencode-go-usage.json`, mod
|
|
|
78
78
|
| `/opencode-go --cookie <value>` | Save cookie only |
|
|
79
79
|
| `/opencode-go --disconnect` | Forget both |
|
|
80
80
|
| `/opencode-go --refresh` | Fetch again now |
|
|
81
|
+
| `/opencode-go --compact [on\|off]` | Toggle compact status bar (`Go: 5h 0% · wk 2% · mo 2%`) |
|
|
81
82
|
| `/opencode-go --json` | Export report to `~/.omp/agent/opencode-go-usage-report.json` |
|
|
82
83
|
|
|
83
84
|
Usage refreshes automatically every 5 minutes.
|
package/README.zh-CN.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
在会话中实时追踪 OpenCode Go 的用量限额 —— **滚动 5 小时、每周、每月**,
|
|
4
4
|
通过实时状态栏和 `/opencode-go` 报告组件展示。
|
|
5
5
|
|
|
6
|
-

|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
状态栏: Go 5h 62% · wk 31% · mo 44%
|
|
@@ -72,6 +72,7 @@ export OPENCODE_GO_AUTH_COOKIE='…'
|
|
|
72
72
|
| `/opencode-go --cookie <value>` | 仅保存 cookie |
|
|
73
73
|
| `/opencode-go --disconnect` | 清除两者 |
|
|
74
74
|
| `/opencode-go --refresh` | 立即重新抓取 |
|
|
75
|
+
| `/opencode-go --compact [on\|off]` | 切换精简状态栏(`Go: 5h 0% · wk 2% · mo 2%`) |
|
|
75
76
|
| `/opencode-go --json` | 导出报告到 `~/.omp/agent/opencode-go-usage-report.json` |
|
|
76
77
|
|
|
77
78
|
用量每 5 分钟自动刷新一次。
|
|
@@ -36,6 +36,7 @@ interface UsageMeter {
|
|
|
36
36
|
interface Config {
|
|
37
37
|
workspaceId?: string;
|
|
38
38
|
authCookie?: string;
|
|
39
|
+
compact?: boolean;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
type FetchFailure =
|
|
@@ -298,11 +299,12 @@ export default function opencodeGoUsage(pi: ExtensionAPI): void {
|
|
|
298
299
|
return;
|
|
299
300
|
}
|
|
300
301
|
const parts = meters.map((m) => {
|
|
302
|
+
if (config.compact) return `${METER_SHORT[m.kind]} ${m.percent}%`;
|
|
301
303
|
const cd = countdown(m.resetsAt);
|
|
302
304
|
return `${METER_SHORT[m.kind]} ${m.percent}%${cd ? ` (${cd})` : ""}`;
|
|
303
305
|
});
|
|
304
306
|
let text = `OpenCode Go: ${parts.join(" · ")}`;
|
|
305
|
-
if (lastFetchedAt) text += ` · ${fmtUpdate(lastFetchedAt)}`;
|
|
307
|
+
if (!config.compact && lastFetchedAt) text += ` · ${fmtUpdate(lastFetchedAt)}`;
|
|
306
308
|
ctx.ui.setStatus("opencode-go", text);
|
|
307
309
|
};
|
|
308
310
|
|
|
@@ -376,7 +378,7 @@ export default function opencodeGoUsage(pi: ExtensionAPI): void {
|
|
|
376
378
|
|
|
377
379
|
pi.registerCommand("opencode-go", {
|
|
378
380
|
description:
|
|
379
|
-
"Show OpenCode Go usage. Subcommands: --connect <wrk> <cookie> | --workspace <id> | --cookie <v> | --disconnect | --refresh | --json",
|
|
381
|
+
"Show OpenCode Go usage. Subcommands: --connect <wrk> <cookie> | --workspace <id> | --cookie <v> | --disconnect | --refresh | --compact [on|off] | --json",
|
|
380
382
|
handler: async (args, ctx) => {
|
|
381
383
|
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
382
384
|
const sub = tokens[0];
|
|
@@ -430,6 +432,14 @@ export default function opencodeGoUsage(pi: ExtensionAPI): void {
|
|
|
430
432
|
renderStatus(ctx);
|
|
431
433
|
ctx.ui.setWidget("opencode-go", undefined);
|
|
432
434
|
ctx.ui.notify("Disconnected", "info");
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (sub === "--compact") {
|
|
438
|
+
const arg = rest[0];
|
|
439
|
+
config.compact = arg ? arg !== "off" && arg !== "false" : !config.compact;
|
|
440
|
+
await saveConfig(config);
|
|
441
|
+
renderStatus(ctx);
|
|
442
|
+
ctx.ui.notify(`Compact mode ${config.compact ? "on" : "off"}`, "info");
|
|
433
443
|
return;
|
|
434
444
|
}
|
|
435
445
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-opencode-go-usage",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Track OpenCode Go usage limits (rolling 5h / weekly / monthly) in Pi — status bar + /opencode-go report via HTML scrape.",
|
|
5
5
|
"author": "Dakai",
|
|
6
6
|
"keywords": [
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"extensions": [
|
|
41
41
|
"./extensions/opencode-go-usage.ts"
|
|
42
42
|
],
|
|
43
|
-
"image": "https://raw.githubusercontent.com/Dakai/pi-opencode-go-usage/main/
|
|
43
|
+
"image": "https://raw.githubusercontent.com/Dakai/pi-opencode-go-usage/main/assets/pi-opencode-go-usage.png"
|
|
44
44
|
}
|
|
45
45
|
}
|