opencode-mask-j0k3r-dev-rgl 2.0.17 → 2.0.19

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 +18 -13
  2. package/package.json +1 -1
package/components.tsx CHANGED
@@ -112,21 +112,26 @@ 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 = input máximo entre todos los mensajes asistente
117
+ // (el input crece conforme el contexto se acumula; el mayor = el más reciente sustancial)
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 contextTokens = assistantMsgs.reduce((max, m) => Math.max(max, m.tokens?.input ?? 0), 0)
119
121
  const totalCost = assistantMsgs.reduce((s, m) => s + (m.cost ?? 0), 0)
120
122
 
121
- // Context window: OpenCode muestra "% used" basado en el modelo.
122
- // Usamos 200_000 como referencia (Claude 3.5 Sonnet / GPT-4o max).
123
- const CONTEXT_LIMIT = 200_000
124
- const contextPct = Math.min(100, Math.round((totalTokens / CONTEXT_LIMIT) * 100))
123
+ // % used: OpenCode lo calcula internamente con el context window del modelo.
124
+ // Inferimos el límite desde los datos disponibles: si tenemos tokens y %,
125
+ // podemos intentar inferirlo. Sin esa info, usamos 1M (Claude 3.5/Gemini 1.5).
126
+ const CONTEXT_LIMIT = 1_000_000
127
+ const contextPct = Math.min(100, Math.round((contextTokens / CONTEXT_LIMIT) * 100))
128
+ // El % de costo: escalamos $1.00 = 100%
129
+ const costPct = Math.min(100, Math.round(totalCost * 100))
125
130
 
126
131
  const fmtTokens = (n: number) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`
127
132
  const fmtCost = (n: number) => `$${n.toFixed(2)}`
128
133
 
129
- // Color del context bar: verde → amarillo → rojo según el %
134
+ // Color: verde → amarillo → rojo según el %
130
135
  const ctxColor = contextPct < 50 ? "#00e5a0" : contextPct < 80 ? "#ffd166" : "#ff2d78"
131
136
 
132
137
  return (
@@ -151,30 +156,30 @@ export const SidebarArch = (props: {
151
156
  )}
152
157
 
153
158
  {/* ── Context (tokens + % used + cost) ── */}
154
- {totalTokens > 0 && (
155
- <box flexDirection="column" marginTop={1}>
159
+ {contextTokens > 0 && (
160
+ <box flexDirection="column" alignItems="center" marginTop={1}>
156
161
  <text fg={t.textMuted} bold={true}>Context</text>
157
162
 
158
163
  {/* tokens */}
159
164
  <box flexDirection="row" gap={1}>
160
- <text fg={t.text}>{fmtTokens(totalTokens)}</text>
165
+ <text fg={t.text}>{fmtTokens(contextTokens)}</text>
161
166
  <text fg={t.textMuted}>tokens</text>
162
167
  </box>
163
- <ProgressBar value={contextPct} width={12} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
168
+ <ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
164
169
 
165
170
  {/* % used */}
166
171
  <box flexDirection="row" gap={1}>
167
172
  <text fg={ctxColor}>{contextPct}%</text>
168
173
  <text fg={t.textMuted}>used</text>
169
174
  </box>
170
- <ProgressBar value={contextPct} width={12} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
175
+ <ProgressBar value={contextPct} width={18} fillColor={ctxColor} emptyColor="#3a3a3a" theme={t} />
171
176
 
172
177
  {/* $ spent */}
173
178
  <box flexDirection="row" gap={1}>
174
179
  <text fg="#ffd166">{fmtCost(totalCost)}</text>
175
180
  <text fg={t.textMuted}>spent</text>
176
181
  </box>
177
- <ProgressBar value={Math.min(100, totalCost * 100)} width={12} fillColor="#ffd166" emptyColor="#3a3a3a" theme={t} />
182
+ <ProgressBar value={costPct} width={18} fillColor="#ffd166" emptyColor="#3a3a3a" theme={t} />
178
183
  </box>
179
184
  )}
180
185
 
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.19",
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": {