opencode-mask-j0k3r-dev-rgl 2.0.17 → 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.
Files changed (2) hide show
  1. package/components.tsx +23 -12
  2. 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 — sumados de los AssistantMessages ─────────────────────
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 totalTokens = assistantMsgs.reduce((s, m) => s + (m.tokens?.total ?? (m.tokens?.input ?? 0) + (m.tokens?.output ?? 0)), 0)
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
- // Context window: OpenCode muestra "% used" basado en el modelo.
122
- // Usamos 200_000 como referencia (Claude 3.5 Sonnet / GPT-4o max).
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((totalTokens / CONTEXT_LIMIT) * 100))
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 del context bar: verde → amarillo → rojo según el %
140
+ // Color: verde → amarillo → rojo según el %
130
141
  const ctxColor = contextPct < 50 ? "#00e5a0" : contextPct < 80 ? "#ffd166" : "#ff2d78"
131
142
 
132
143
  return (
@@ -151,30 +162,30 @@ export const SidebarArch = (props: {
151
162
  )}
152
163
 
153
164
  {/* ── Context (tokens + % used + cost) ── */}
154
- {totalTokens > 0 && (
155
- <box flexDirection="column" marginTop={1}>
165
+ {contextTokens > 0 && (
166
+ <box flexDirection="column" alignItems="center" marginTop={1}>
156
167
  <text fg={t.textMuted} bold={true}>Context</text>
157
168
 
158
169
  {/* tokens */}
159
170
  <box flexDirection="row" gap={1}>
160
- <text fg={t.text}>{fmtTokens(totalTokens)}</text>
171
+ <text fg={t.text}>{fmtTokens(contextTokens)}</text>
161
172
  <text fg={t.textMuted}>tokens</text>
162
173
  </box>
163
- <ProgressBar value={contextPct} width={12} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
174
+ <ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
164
175
 
165
176
  {/* % used */}
166
177
  <box flexDirection="row" gap={1}>
167
178
  <text fg={ctxColor}>{contextPct}%</text>
168
179
  <text fg={t.textMuted}>used</text>
169
180
  </box>
170
- <ProgressBar value={contextPct} width={12} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
181
+ <ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
171
182
 
172
183
  {/* $ spent */}
173
184
  <box flexDirection="row" gap={1}>
174
185
  <text fg="#ffd166">{fmtCost(totalCost)}</text>
175
186
  <text fg={t.textMuted}>spent</text>
176
187
  </box>
177
- <ProgressBar value={Math.min(100, totalCost * 100)} width={12} fillColor="#ffd166" emptyColor="#3a3a3a" theme={t} />
188
+ <ProgressBar value={costPct} width={18} fillColor="#ffd166" emptyColor="#3a3a3a" theme={t} />
178
189
  </box>
179
190
  )}
180
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.17",
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": {