@howaboua/opencode-usage-plugin 0.0.3 → 0.0.4

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
@@ -9,6 +9,8 @@ Track AI provider rate limits and quotas in real-time.
9
9
  - **Inline status** – Results appear directly in your chat, no context switching
10
10
  - **Zero setup** – Auto-detects providers from your existing config
11
11
 
12
+ <img width="1300" height="900" alt="image" src="https://github.com/user-attachments/assets/cd49e450-f4b6-4314-b236-b3a92bffdb88" />
13
+
12
14
  ## Installation
13
15
 
14
16
  Add to your `opencode.json`:
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/providers/proxy/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,SAAS,CAAA;AAsGxE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAkC7D"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/providers/proxy/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,SAAS,CAAA;AAwHxE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAoC7D"}
@@ -4,10 +4,29 @@
4
4
  const GROUP_MAPPING = {
5
5
  "claude": "claude",
6
6
  "g3-pro": "g3-pro",
7
- "g3-flash": "g3-fla",
7
+ "g3-flash": "g3-flash",
8
+ "g25-flash": "25-flash",
9
+ "g25-lite": "25-lite",
8
10
  "pro": "g3-pro",
9
- "3-flash": "g3-fla"
11
+ "3-flash": "g3-flash",
12
+ "25-flash": "25-flash",
13
+ "25-lite": "25-lite"
10
14
  };
15
+ // Display name ordering priority
16
+ const GROUP_ORDER = ["claude", "g3-pro", "g3-flash", "25-flash", "25-lite"];
17
+ function sortGroupNames(groups) {
18
+ return Array.from(groups.keys()).sort((a, b) => {
19
+ const aIndex = GROUP_ORDER.indexOf(a);
20
+ const bIndex = GROUP_ORDER.indexOf(b);
21
+ if (aIndex !== -1 && bIndex !== -1)
22
+ return aIndex - bIndex;
23
+ if (aIndex !== -1)
24
+ return -1;
25
+ if (bIndex !== -1)
26
+ return 1;
27
+ return a.localeCompare(b);
28
+ });
29
+ }
11
30
  function formatBar(remainingPercent) {
12
31
  const clamped = Math.max(0, Math.min(100, remainingPercent));
13
32
  const size = 20;
@@ -109,7 +128,9 @@ export function formatProxyLimits(data) {
109
128
  continue;
110
129
  const tierLabel = tierName === "paid" ? "Paid" : "Free";
111
130
  lines.push(` ${tierLabel}:`);
112
- for (const [groupName, quota] of quotas) {
131
+ const sortedNames = sortGroupNames(quotas);
132
+ for (const groupName of sortedNames) {
133
+ const quota = quotas.get(groupName);
113
134
  const remainingPct = quota.max > 0 ? (quota.remaining / quota.max) * 100 : 0;
114
135
  const resetSuffix = quota.remaining === 0 ? formatResetTime(quota.resetTime) : "";
115
136
  lines.push(` ${groupName}: ${formatBar(remainingPct)} ${quota.remaining}/${quota.max}${resetSuffix}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/proxy/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AA+I5C,eAAO,MAAM,aAAa,EAAE,aAwB3B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/proxy/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAiK5C,eAAO,MAAM,aAAa,EAAE,aAwB3B,CAAA"}
@@ -10,14 +10,33 @@ export { formatProxyLimits } from "./format";
10
10
  const GROUP_MAPPING = {
11
11
  "claude": "claude",
12
12
  "g3-pro": "g3-pro",
13
- "g3-flash": "g3-fla",
13
+ "g3-flash": "g3-flash",
14
14
  "g25-flash": "25-flash",
15
15
  "g25-lite": "25-lite",
16
16
  "pro": "g3-pro",
17
- "3-flash": "g3-fla",
17
+ "3-flash": "g3-flash",
18
18
  "25-flash": "25-flash",
19
19
  "25-lite": "25-lite"
20
20
  };
21
+ // Display name ordering priority
22
+ const GROUP_ORDER = ["claude", "g3-pro", "g3-flash", "25-flash", "25-lite"];
23
+ function sortQuotaGroups(groups) {
24
+ return groups.sort((a, b) => {
25
+ const aIndex = GROUP_ORDER.indexOf(a.name);
26
+ const bIndex = GROUP_ORDER.indexOf(b.name);
27
+ // Both in priority list: sort by index
28
+ if (aIndex !== -1 && bIndex !== -1)
29
+ return aIndex - bIndex;
30
+ // Only a in priority list: a comes first
31
+ if (aIndex !== -1)
32
+ return -1;
33
+ // Only b in priority list: b comes first
34
+ if (bIndex !== -1)
35
+ return 1;
36
+ // Neither in priority list: alphabetical
37
+ return a.name.localeCompare(b.name);
38
+ });
39
+ }
21
40
  function normalizeTier(tier) {
22
41
  if (!tier)
23
42
  return "free";
@@ -105,10 +124,10 @@ function aggregateByTier(credentials) {
105
124
  }
106
125
  const result = [];
107
126
  if (tiers.paid.size > 0) {
108
- result.push({ tier: "paid", quotaGroups: Array.from(tiers.paid.values()) });
127
+ result.push({ tier: "paid", quotaGroups: sortQuotaGroups(Array.from(tiers.paid.values())) });
109
128
  }
110
129
  if (tiers.free.size > 0) {
111
- result.push({ tier: "free", quotaGroups: Array.from(tiers.free.values()) });
130
+ result.push({ tier: "free", quotaGroups: sortQuotaGroups(Array.from(tiers.free.values())) });
112
131
  }
113
132
  return result;
114
133
  }
package/package.json CHANGED
@@ -1,12 +1,23 @@
1
1
  {
2
2
  "name": "@howaboua/opencode-usage-plugin",
3
- "version": "0.0.3",
4
- "description": "OpenCode plugin for tracking AI provider usage, rate limits, and quotas",
3
+ "version": "0.0.4",
4
+ "description": "opencode plugin for tracking AI provider usage, rate limits, and quotas",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
- "files": ["dist", "README.md", "LICENSE"],
9
- "keywords": ["opencode", "opencode-plugin", "plugin", "usage", "tracking", "rate-limit"],
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "keywords": [
14
+ "opencode",
15
+ "opencode-plugin",
16
+ "plugin",
17
+ "usage",
18
+ "tracking",
19
+ "rate-limit"
20
+ ],
10
21
  "license": "MIT",
11
22
  "peerDependencies": {
12
23
  "@opencode-ai/plugin": "^1.0.0"