opencode-mask-j0k3r-dev-rgl 2.0.18 → 2.0.20
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 +5 -21
- package/package.json +1 -1
- package/tui.tsx +13 -0
package/components.tsx
CHANGED
|
@@ -84,17 +84,12 @@ export const SidebarArch = (props: {
|
|
|
84
84
|
lspItems?: ReadonlyArray<TuiSidebarLspItem>
|
|
85
85
|
todos?: ReadonlyArray<TuiSidebarTodoItem>
|
|
86
86
|
messages?: ReadonlyArray<Message>
|
|
87
|
+
contextLimit?: number
|
|
87
88
|
}) => {
|
|
88
89
|
if (!props.config.show_sidebar) return null
|
|
89
90
|
|
|
90
91
|
const t = props.theme
|
|
91
92
|
|
|
92
|
-
// ── Files ─────────────────────────────────────────────────────────────────
|
|
93
|
-
const files = props.files ?? []
|
|
94
|
-
const totalAdditions = files.reduce((s, f) => s + f.additions, 0)
|
|
95
|
-
const totalDeletions = files.reduce((s, f) => s + f.deletions, 0)
|
|
96
|
-
const totalChanges = totalAdditions + totalDeletions
|
|
97
|
-
|
|
98
93
|
// ── Todos ─────────────────────────────────────────────────────────────────
|
|
99
94
|
const todos = props.todos ?? []
|
|
100
95
|
const doneTodos = todos.filter(t => t.status === "completed").length
|
|
@@ -113,25 +108,14 @@ export const SidebarArch = (props: {
|
|
|
113
108
|
const lspTotal = lspItems.length
|
|
114
109
|
|
|
115
110
|
// ── 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
|
|
118
111
|
const messages = props.messages ?? []
|
|
119
112
|
const assistantMsgs = messages.filter(m => m.role === "assistant")
|
|
120
|
-
const
|
|
121
|
-
const contextTokens = lastMsg?.tokens?.input ?? 0
|
|
113
|
+
const contextTokens = assistantMsgs.reduce((max, m) => Math.max(max, m.tokens?.input ?? 0), 0)
|
|
122
114
|
const totalCost = assistantMsgs.reduce((s, m) => s + (m.cost ?? 0), 0)
|
|
123
115
|
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
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.
|
|
132
|
-
const CONTEXT_LIMIT = 200_000
|
|
133
|
-
const contextPct = Math.min(100, Math.round((contextTokens / CONTEXT_LIMIT) * 100))
|
|
134
|
-
// El % de costo: escalamos $1.00 = 100%
|
|
116
|
+
// context window real del modelo via api.state.provider → model.limit.context
|
|
117
|
+
const contextLimit = props.contextLimit ?? 1_000_000
|
|
118
|
+
const contextPct = Math.min(100, Math.round((contextTokens / contextLimit) * 100))
|
|
135
119
|
const costPct = Math.min(100, Math.round(totalCost * 100))
|
|
136
120
|
|
|
137
121
|
const fmtTokens = (n: number) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`
|
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.20",
|
|
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": {
|
package/tui.tsx
CHANGED
|
@@ -48,6 +48,18 @@ const tui: TuiPlugin = async (api, options) => {
|
|
|
48
48
|
const mcpItems = api.state.mcp()
|
|
49
49
|
const lspItems = api.state.lsp()
|
|
50
50
|
|
|
51
|
+
// Resolver el context window real del modelo activo
|
|
52
|
+
// api.state.config.model = "providerID/modelID"
|
|
53
|
+
// api.state.provider = ReadonlyArray<Provider> donde Provider.models[modelID].limit.context
|
|
54
|
+
let contextLimit: number | undefined
|
|
55
|
+
try {
|
|
56
|
+
const modelStr = api.state.config?.model ?? ""
|
|
57
|
+
const [providerID, modelID] = modelStr.split("/")
|
|
58
|
+
const provider = api.state.provider.find(p => p.id === providerID)
|
|
59
|
+
const model = provider?.models?.[modelID]
|
|
60
|
+
if (model?.limit?.context) contextLimit = model.limit.context
|
|
61
|
+
} catch (_) {}
|
|
62
|
+
|
|
51
63
|
return (
|
|
52
64
|
<SidebarArch
|
|
53
65
|
theme={ctx.theme.current}
|
|
@@ -59,6 +71,7 @@ const tui: TuiPlugin = async (api, options) => {
|
|
|
59
71
|
messages={messages}
|
|
60
72
|
mcpItems={mcpItems}
|
|
61
73
|
lspItems={lspItems}
|
|
74
|
+
contextLimit={contextLimit}
|
|
62
75
|
/>
|
|
63
76
|
)
|
|
64
77
|
},
|