oc-usage-limits-plugin 1.0.0 → 1.0.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/README.md CHANGED
@@ -22,10 +22,25 @@ Add the TUI plugin to `~/.config/opencode/tui.json`:
22
22
  }
23
23
  ```
24
24
 
25
+ Or install via the CLI, which writes the config for you:
26
+
27
+ ```powershell
28
+ oc plugin oc-usage-limits-plugin -g
29
+ ```
30
+
31
+ - `-g` / `--global` installs to `~/.config/opencode/tui.json`.
32
+ - Without `-g`, installs locally to `<project>/.opencode/tui.json` (requires a git worktree).
33
+ - `--force` replaces an existing pinned version.
34
+
25
35
  OpenCode TUI plugins are configured in `tui.json`, not `opencode.jsonc`.
26
36
 
27
37
  Restart OpenCode after changing TUI plugin config.
28
38
 
39
+ ### Troubleshooting
40
+
41
+ - **Peer dependency warnings during install** are expected — `@opencode-ai/plugin`, `@opentui/solid`, and `solid-js` are provided by the OpenCode TUI runtime at load time.
42
+ - **`No versions available`** right after a release means a supply-chain cooldown policy (e.g. `min-release-age`) is blocking the fresh version. Wait for the cooldown window to pass, or install a previously vetted version instead.
43
+
29
44
  ## Usage Config
30
45
 
31
46
  Create `~/.config/opencode/usage-limits.jsonc`:
package/dist/index.mjs CHANGED
@@ -549,9 +549,8 @@ const readZaiAuthPathKey = async (authPath) => {
549
549
  /**
550
550
  * Converts one raw ZAI limit entry into a normalized usage window.
551
551
  *
552
- * Token limits become the primary `tokens` quota window. Time limits become an
553
- * `MCP` count-based window and also expose the total prompt quota used to infer
554
- * the user's ZAI tier.
552
+ * Token limits become the primary `5h` quota window. Time limits are not shown
553
+ * but still expose the total prompt quota used to infer the user's ZAI tier.
555
554
  *
556
555
  * @param limit - Raw limit object from the ZAI quota API.
557
556
  * @returns The normalized window plus any prompt total discovered on the entry.
@@ -559,12 +558,11 @@ const readZaiAuthPathKey = async (authPath) => {
559
558
  const zaiWindowFromLimit = (limit) => {
560
559
  const usedPercent = typeof limit.percentage === "number" ? clampPercent(limit.percentage) : null;
561
560
  const resetsAt = typeof limit.nextResetTime === "number" ? new Date(limit.nextResetTime) : null;
562
- const current = typeof limit.currentValue === "number" ? limit.currentValue : void 0;
563
561
  const total = typeof limit.usage === "number" ? limit.usage : void 0;
564
562
  if (limit.type === "TOKENS_LIMIT") return {
565
563
  promptTotal: null,
566
564
  window: {
567
- label: "tokens",
565
+ label: "5h",
568
566
  remainingPercent: usedPercent === null ? null : 100 - usedPercent,
569
567
  resetAfterSeconds: resetsAt ? Math.max(0, Math.ceil((resetsAt.getTime() - Date.now()) / 1e3)) : null,
570
568
  resetsAt,
@@ -573,15 +571,7 @@ const zaiWindowFromLimit = (limit) => {
573
571
  };
574
572
  if (limit.type === "TIME_LIMIT") return {
575
573
  promptTotal: total ?? null,
576
- window: {
577
- current,
578
- label: "MCP",
579
- remainingPercent: usedPercent === null ? null : 100 - usedPercent,
580
- resetAfterSeconds: null,
581
- resetsAt: null,
582
- total,
583
- usedPercent
584
- }
574
+ window: null
585
575
  };
586
576
  return {
587
577
  promptTotal: null,
@@ -715,7 +705,7 @@ const usageForProvider = (states, providerID) => {
715
705
  if (state?.status === "ready") ({data} = state);
716
706
  if (state?.status === "error") data = state.previous;
717
707
  if (!data) return null;
718
- if (usageID === "zai") return data.windows.find((window) => window.label === "tokens") ?? data.windows[0] ?? null;
708
+ if (usageID === "zai") return data.windows.find((window) => window.label === "5h") ?? data.windows[0] ?? null;
719
709
  return data.windows.find((window) => window.label === "5h") ?? data.windows[0] ?? null;
720
710
  };
721
711
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-usage-limits-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "OpenCode TUI plugin that shows Codex and ZAI usage limits in the sidebar and prompt footer.",
5
5
  "keywords": [
6
6
  "codex",
@@ -62,13 +62,13 @@
62
62
  "lefthook": "^2.1.9",
63
63
  "oxfmt": "^0.56.0",
64
64
  "oxlint": "^1.71.0",
65
- "solid-js": "1.9.13",
65
+ "solid-js": "1.9.12",
66
66
  "tsdown": "^0.22.3",
67
67
  "ultracite": "7.8.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@opencode-ai/plugin": ">=1.17.9",
71
71
  "@opentui/solid": ">=0.4.1",
72
- "solid-js": ">=1.9.13"
72
+ "solid-js": ">=1.9.12"
73
73
  }
74
74
  }