@xtruder/opencode-claude-max-plugin 0.2.0 → 0.2.3

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/src/tui.tsx CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /** @jsxImportSource @opentui/solid */
3
2
  import type {
4
3
  TuiPlugin,
@@ -6,15 +5,15 @@ import type {
6
5
  TuiPluginModule,
7
6
  TuiThemeCurrent,
8
7
  } from "@opencode-ai/plugin/tui"
9
- import { createMemo, createSignal, Show } from "solid-js"
8
+ import { type Accessor, Show, createMemo, createSignal } from "solid-js"
10
9
  import {
10
+ type UsageData,
11
+ bestUsageFromCache,
11
12
  fetchUsage,
12
13
  formatReset,
13
14
  readUsageCache,
14
- writeUsageCache,
15
- bestUsageFromCache,
16
15
  shouldFetchApi,
17
- type UsageData,
16
+ writeUsageCache,
18
17
  } from "./usage.ts"
19
18
 
20
19
  const id = "anthropic-sdk-usage"
@@ -178,15 +177,6 @@ function UsageSidebar(props: {
178
177
  }
179
178
  })
180
179
 
181
- const sevenDaySonnet = createMemo(() => {
182
- const d = props.usage()
183
- if (!d?.seven_day_sonnet) return null
184
- return {
185
- ratio: clamp01(d.seven_day_sonnet.utilization / 100),
186
- reset: d.seven_day_sonnet.resets_at,
187
- }
188
- })
189
-
190
180
  const hasData = createMemo(() => fiveHour() !== null || sevenDay() !== null)
191
181
 
192
182
  return (
@@ -196,7 +186,6 @@ function UsageSidebar(props: {
196
186
  const next = Math.max(1, this.width)
197
187
  setBarWidth((prev) => (prev === next ? prev : next))
198
188
  }}
199
- paddingTop={1}
200
189
  width="100%"
201
190
  flexDirection="column"
202
191
  >
@@ -204,7 +193,7 @@ function UsageSidebar(props: {
204
193
  <b>Claude Usage</b>
205
194
  </text>
206
195
  <Show when={fiveHour()}>
207
- {(data) => {
196
+ {(data: Accessor<{ ratio: number; reset: string | null }>) => {
208
197
  const label = "5H "
209
198
  const suffix = createMemo(() => ` ${pct(data().ratio)}`)
210
199
  return (
@@ -224,7 +213,7 @@ function UsageSidebar(props: {
224
213
  }}
225
214
  </Show>
226
215
  <Show when={sevenDay()}>
227
- {(data) => {
216
+ {(data: Accessor<{ ratio: number; reset: string | null }>) => {
228
217
  const label = "7D "
229
218
  const suffix = createMemo(() => ` ${pct(data().ratio)}`)
230
219
  return (
@@ -243,26 +232,6 @@ function UsageSidebar(props: {
243
232
  )
244
233
  }}
245
234
  </Show>
246
- <Show when={sevenDaySonnet()}>
247
- {(data) => {
248
- const label = "7D Sonnet "
249
- const suffix = createMemo(() => ` ${pct(data().ratio)}`)
250
- return (
251
- <>
252
- <text>
253
- <span style={{ fg: props.theme.textMuted }}>{label}</span>
254
- <span style={{ fg: barColor(data().ratio, props.theme) }}>
255
- [{bar(data().ratio, fillWidth(barWidth(), label, suffix()))}]
256
- </span>
257
- <span style={{ fg: props.theme.text }}>{suffix()}</span>
258
- </text>
259
- <Show when={data().reset}>
260
- <text fg={props.theme.textMuted}>{formatReset(data().reset)}</text>
261
- </Show>
262
- </>
263
- )
264
- }}
265
- </Show>
266
235
  </box>
267
236
  </Show>
268
237
  )
@@ -360,7 +329,7 @@ function UsageDialog(props: {
360
329
  ))
361
330
  })()}
362
331
  <Show when={extra()}>
363
- {(ex) => (
332
+ {(ex: Accessor<{ enabled: boolean; text: string }>) => (
364
333
  <box paddingTop={1}>
365
334
  <text fg={ex().enabled ? theme().warning : theme().textMuted}>{ex().text}</text>
366
335
  </box>
package/src/usage.ts CHANGED
@@ -9,17 +9,17 @@
9
9
  * so the TUI plugin (main process) can read data written by the server plugin (worker process).
10
10
  */
11
11
  import {
12
- readFileSync,
13
- writeFileSync,
12
+ closeSync,
13
+ constants as fsConstants,
14
14
  mkdirSync,
15
- unlinkSync,
16
15
  openSync,
17
- closeSync,
16
+ readFileSync,
18
17
  renameSync,
19
- constants as fsConstants,
18
+ unlinkSync,
19
+ writeFileSync,
20
20
  } from "node:fs"
21
- import { join } from "node:path"
22
21
  import { homedir } from "node:os"
22
+ import { join } from "node:path"
23
23
  import { readClaudeCredentials } from "./credentials.ts"
24
24
 
25
25
  // ─── Types ───────────────────────────────────────────────────────────