opencode-codex-usage-tui 1.3.3 → 1.4.0
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 -2
- package/dist/tui.js +14 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Add the published package to OpenCode's TUI configuration:
|
|
|
23
23
|
```json
|
|
24
24
|
{
|
|
25
25
|
"$schema": "https://opencode.ai/tui.json",
|
|
26
|
-
"plugin": ["opencode-codex-usage-tui@1.
|
|
26
|
+
"plugin": ["opencode-codex-usage-tui@1.4.0"]
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -44,7 +44,7 @@ For example, a local file URL can be used when supported:
|
|
|
44
44
|
```json
|
|
45
45
|
{
|
|
46
46
|
"$schema": "https://opencode.ai/tui.json",
|
|
47
|
-
"plugin": ["file:///absolute/path/to/opencode-codex-usage-tui-1.
|
|
47
|
+
"plugin": ["file:///absolute/path/to/opencode-codex-usage-tui-1.4.0.tgz"]
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
package/dist/tui.js
CHANGED
|
@@ -65,7 +65,11 @@ function fmtReset(resetSec) {
|
|
|
65
65
|
return `${mins}m`;
|
|
66
66
|
}
|
|
67
67
|
function fmtPct(pct) {
|
|
68
|
-
return `${
|
|
68
|
+
return `${Math.round(pct)}%`;
|
|
69
|
+
}
|
|
70
|
+
function fmtCredits(balance) {
|
|
71
|
+
const amount = Number(balance);
|
|
72
|
+
return Number.isFinite(amount) ? amount.toFixed(2) : balance;
|
|
69
73
|
}
|
|
70
74
|
function liveResetSeconds(usage) {
|
|
71
75
|
if (!state.lastFetch) return usage.resetInSec;
|
|
@@ -116,9 +120,8 @@ const tui = async (api) => {
|
|
|
116
120
|
slots: {
|
|
117
121
|
sidebar_content() {
|
|
118
122
|
const theme = api.theme.current;
|
|
119
|
-
const muted = theme.textMuted;
|
|
120
123
|
const normal = theme.text;
|
|
121
|
-
const valStyle = { fg:
|
|
124
|
+
const valStyle = { fg: normal };
|
|
122
125
|
const headerTitle = valNode({ attributes: TextAttributes.BOLD, fg: normal });
|
|
123
126
|
const headerSummary = valNode(valStyle);
|
|
124
127
|
const planVal = valNode(valStyle);
|
|
@@ -126,14 +129,10 @@ const tui = async (api) => {
|
|
|
126
129
|
const resetsVal = valNode(valStyle);
|
|
127
130
|
const statusVal = valNode(valStyle);
|
|
128
131
|
function usageBlock() {
|
|
129
|
-
const label = valNode({ fg:
|
|
132
|
+
const label = valNode({ fg: normal });
|
|
130
133
|
const pct = valNode(valStyle);
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [label, pct]),
|
|
134
|
-
box({ flexDirection: "row", width: "100%", justifyContent: "flex-end" }, [reset])
|
|
135
|
-
]);
|
|
136
|
-
return { block, label, pct, reset };
|
|
134
|
+
const block = box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [label, pct]);
|
|
135
|
+
return { block, label, pct };
|
|
137
136
|
}
|
|
138
137
|
const primary = usageBlock();
|
|
139
138
|
const secondary = usageBlock();
|
|
@@ -144,13 +143,11 @@ const tui = async (api) => {
|
|
|
144
143
|
if (!usage) {
|
|
145
144
|
setNodeText(view.label, "");
|
|
146
145
|
setNodeText(view.pct, "");
|
|
147
|
-
setNodeText(view.reset, "");
|
|
148
146
|
return;
|
|
149
147
|
}
|
|
150
148
|
const reset = fmtReset(liveResetSeconds(usage));
|
|
151
149
|
setNodeText(view.label, usage.label);
|
|
152
|
-
setNodeText(view.pct, `${fmtPct(remainingPercent(usage.usedPercent))}
|
|
153
|
-
setNodeText(view.reset, reset ? `reset ${reset}` : "");
|
|
150
|
+
setNodeText(view.pct, `${fmtPct(remainingPercent(usage.usedPercent))}${reset ? ` (${reset})` : ""}${usage.limitReached ? " exhausted" : ""}`);
|
|
154
151
|
}
|
|
155
152
|
function clearWindows() {
|
|
156
153
|
setUsageWindow(primary, void 0);
|
|
@@ -173,7 +170,7 @@ const tui = async (api) => {
|
|
|
173
170
|
setUsageWindow(extraTwo, windows[3]);
|
|
174
171
|
setNodeText(
|
|
175
172
|
creditsVal,
|
|
176
|
-
state.credits ? state.credits.hasCredits ? state.credits.unlimited ? "unlimited" : state.credits.balance : "none" : ""
|
|
173
|
+
state.credits ? state.credits.hasCredits ? state.credits.unlimited ? "unlimited" : fmtCredits(state.credits.balance) : "none" : ""
|
|
177
174
|
);
|
|
178
175
|
setNodeText(resetsVal, state.resetCredits === void 0 ? "" : `${state.resetCredits} available`);
|
|
179
176
|
setNodeText(statusVal, "");
|
|
@@ -213,13 +210,13 @@ ${DASHBOARD_URL}`);
|
|
|
213
210
|
}
|
|
214
211
|
const header = box({ flexDirection: "row", width: "100%", onMouseUp: () => toggle() }, [headerTitle, headerSummary]);
|
|
215
212
|
const body = box({ flexDirection: "column", width: "100%", visible: !collapsed }, [
|
|
216
|
-
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg:
|
|
213
|
+
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg: normal }, ["Plan"]), planVal]),
|
|
217
214
|
primary.block,
|
|
218
215
|
secondary.block,
|
|
219
216
|
extraOne.block,
|
|
220
217
|
extraTwo.block,
|
|
221
|
-
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg:
|
|
222
|
-
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg:
|
|
218
|
+
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg: normal }, ["Credits"]), creditsVal]),
|
|
219
|
+
box({ flexDirection: "row", width: "100%", justifyContent: "space-between" }, [txt({ fg: normal }, ["Resets"]), resetsVal]),
|
|
223
220
|
statusVal
|
|
224
221
|
]);
|
|
225
222
|
const root = box({ flexDirection: "column", width: "100%" }, [header, body]);
|