opencode-mask-j0k3r-dev-rgl 2.0.16 → 2.0.18
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/components.tsx +30 -32
- package/package.json +1 -1
package/components.tsx
CHANGED
|
@@ -112,21 +112,32 @@ export const SidebarArch = (props: {
|
|
|
112
112
|
const lspActive = lspItems.filter(l => l.status === "idle" || l.status === "running").length
|
|
113
113
|
const lspTotal = lspItems.length
|
|
114
114
|
|
|
115
|
-
// ── Tokens & Cost
|
|
115
|
+
// ── Tokens & Cost ─────────────────────────────────────────────────────────
|
|
116
|
+
// El contexto actual = tokens del ÚLTIMO mensaje asistente (input acumulado)
|
|
117
|
+
// El costo = suma de todos los mensajes de la sesión
|
|
116
118
|
const messages = props.messages ?? []
|
|
117
119
|
const assistantMsgs = messages.filter(m => m.role === "assistant")
|
|
118
|
-
const
|
|
120
|
+
const lastMsg = assistantMsgs[assistantMsgs.length - 1]
|
|
121
|
+
const contextTokens = lastMsg?.tokens?.input ?? 0
|
|
119
122
|
const totalCost = assistantMsgs.reduce((s, m) => s + (m.cost ?? 0), 0)
|
|
120
123
|
|
|
121
|
-
//
|
|
122
|
-
//
|
|
124
|
+
// % used: inferido del input del último mensaje vs su límite de contexto
|
|
125
|
+
// OpenCode lo calcula internamente; usamos input/(input+output) del último msg
|
|
126
|
+
// como aproximación del % relativo al context window del modelo
|
|
127
|
+
const lastInput = lastMsg?.tokens?.input ?? 0
|
|
128
|
+
const lastOutput = lastMsg?.tokens?.output ?? 0
|
|
129
|
+
const lastTotal = lastInput + lastOutput
|
|
130
|
+
// Estimamos el limit del modelo: si el input representa el contexto acumulado,
|
|
131
|
+
// el % es proporcional. Usamos 200k como referencia estándar.
|
|
123
132
|
const CONTEXT_LIMIT = 200_000
|
|
124
|
-
const contextPct = Math.min(100, Math.round((
|
|
133
|
+
const contextPct = Math.min(100, Math.round((contextTokens / CONTEXT_LIMIT) * 100))
|
|
134
|
+
// El % de costo: escalamos $1.00 = 100%
|
|
135
|
+
const costPct = Math.min(100, Math.round(totalCost * 100))
|
|
125
136
|
|
|
126
137
|
const fmtTokens = (n: number) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`
|
|
127
138
|
const fmtCost = (n: number) => `$${n.toFixed(2)}`
|
|
128
139
|
|
|
129
|
-
// Color
|
|
140
|
+
// Color: verde → amarillo → rojo según el %
|
|
130
141
|
const ctxColor = contextPct < 50 ? "#00e5a0" : contextPct < 80 ? "#ffd166" : "#ff2d78"
|
|
131
142
|
|
|
132
143
|
return (
|
|
@@ -150,44 +161,31 @@ export const SidebarArch = (props: {
|
|
|
150
161
|
</box>
|
|
151
162
|
)}
|
|
152
163
|
|
|
153
|
-
{/* ── Context (tokens + cost) ── */}
|
|
154
|
-
{
|
|
155
|
-
<box flexDirection="column" marginTop={1}>
|
|
164
|
+
{/* ── Context (tokens + % used + cost) ── */}
|
|
165
|
+
{contextTokens > 0 && (
|
|
166
|
+
<box flexDirection="column" alignItems="center" marginTop={1}>
|
|
156
167
|
<text fg={t.textMuted} bold={true}>Context</text>
|
|
168
|
+
|
|
169
|
+
{/* tokens */}
|
|
157
170
|
<box flexDirection="row" gap={1}>
|
|
158
|
-
<text fg={t.text}>{fmtTokens(
|
|
171
|
+
<text fg={t.text}>{fmtTokens(contextTokens)}</text>
|
|
159
172
|
<text fg={t.textMuted}>tokens</text>
|
|
160
173
|
</box>
|
|
161
|
-
<ProgressBar value={contextPct} width={
|
|
174
|
+
<ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
|
|
175
|
+
|
|
176
|
+
{/* % used */}
|
|
162
177
|
<box flexDirection="row" gap={1}>
|
|
163
178
|
<text fg={ctxColor}>{contextPct}%</text>
|
|
164
179
|
<text fg={t.textMuted}>used</text>
|
|
165
180
|
</box>
|
|
181
|
+
<ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
|
|
182
|
+
|
|
183
|
+
{/* $ spent */}
|
|
166
184
|
<box flexDirection="row" gap={1}>
|
|
167
185
|
<text fg="#ffd166">{fmtCost(totalCost)}</text>
|
|
168
186
|
<text fg={t.textMuted}>spent</text>
|
|
169
187
|
</box>
|
|
170
|
-
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
{/* ── Files changed ── */}
|
|
174
|
-
{totalChanges > 0 && (
|
|
175
|
-
<box flexDirection="column" marginTop={1}>
|
|
176
|
-
<box flexDirection="row" gap={1}>
|
|
177
|
-
<text fg={t.textMuted}>files</text>
|
|
178
|
-
<text fg={t.text}>{files.length}</text>
|
|
179
|
-
</box>
|
|
180
|
-
<box flexDirection="row" gap={0}>
|
|
181
|
-
<text fg="#00e5a0">+{totalAdditions} </text>
|
|
182
|
-
<text fg="#ff2d78">-{totalDeletions}</text>
|
|
183
|
-
</box>
|
|
184
|
-
<ProgressBar
|
|
185
|
-
value={totalChanges > 0 ? Math.min(100, (totalAdditions / totalChanges) * 100) : 0}
|
|
186
|
-
width={12}
|
|
187
|
-
fillColor="#00e5a0"
|
|
188
|
-
emptyColor="#ff2d78"
|
|
189
|
-
theme={t}
|
|
190
|
-
/>
|
|
188
|
+
<ProgressBar value={costPct} width={18} fillColor="#ffd166" emptyColor="#3a3a3a" theme={t} />
|
|
191
189
|
</box>
|
|
192
190
|
)}
|
|
193
191
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "opencode-mask-j0k3r-dev-rgl",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.18",
|
|
5
5
|
"description": "Arch Linux TUI mask for OpenCode — hot pink theme with prominent ASCII logo and j0k3r-dev-rgl@latest legend",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|