opencode-context-indicator 1.1.0 → 1.1.1
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/package.json +7 -1
- package/tui.tsx +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-context-indicator",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Real-time OpenCode context-window usage indicator: per-category token breakdown written to a log file, plus an optional TUI sidebar. Dual V1 + V2 plugin entry.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,5 +53,11 @@
|
|
|
53
53
|
"solid-js": {
|
|
54
54
|
"optional": true
|
|
55
55
|
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@opencode/plugin": "^2.0.19",
|
|
59
|
+
"@opentui/core": "^0.5.12",
|
|
60
|
+
"@opentui/solid": "^0.5.12",
|
|
61
|
+
"solid-js": "^1.9.12"
|
|
56
62
|
}
|
|
57
63
|
}
|
package/tui.tsx
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
1
2
|
/**
|
|
2
3
|
* tui.tsx — optional OpenCode TUI sidebar for `opencode-context-indicator`.
|
|
3
4
|
*
|
|
5
|
+
* The import-source pragma on the first line above is REQUIRED: without it the
|
|
6
|
+
* opencode TUI loader (Bun) transforms JSX against the React runtime and emits
|
|
7
|
+
* `import ... from "react/jsx-runtime"`, which the TUI runtime does not provide,
|
|
8
|
+
* so loading the plugin from the npm cache throws `Cannot find package 'react'`
|
|
9
|
+
* (react only ever resolved from a developer's local node_modules). The pragma
|
|
10
|
+
* must stay the very first line, before any import, and no other pragma-like
|
|
11
|
+
* token may appear in this file. See the OpenTUI Solid integration guide.
|
|
12
|
+
*
|
|
4
13
|
* Exposed as the `./tui` package entry ("beside the main plugin for automatic
|
|
5
14
|
* loading"). OpenCode loads it only in the terminal TUI; it is NOT loaded in
|
|
6
15
|
* the Desktop app (Desktop exposes no TUI slot API). It renders the
|
|
@@ -19,6 +28,7 @@
|
|
|
19
28
|
*/
|
|
20
29
|
import {Plugin, usePlugin} from "@opencode/plugin/tui"
|
|
21
30
|
import {createSignal, Show} from "solid-js"
|
|
31
|
+
import type {ColorInput} from "@opentui/core"
|
|
22
32
|
import {readFileSync} from "node:fs"
|
|
23
33
|
import {tmpdir} from "node:os"
|
|
24
34
|
import {join} from "node:path"
|
|
@@ -62,8 +72,10 @@ function num(v: unknown): number {
|
|
|
62
72
|
// Theme tokens are OpenTUI RGBA values (see ResolvedTheme.text.base/.muted);
|
|
63
73
|
// pass them straight to the renderer. Fall back to a named color when a token
|
|
64
74
|
// is absent so an unexpected theme shape can never blank the sidebar.
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
// `fg` on <text> is typed as OpenTUI's ColorInput (= string | RGBA); using the
|
|
76
|
+
// same alias keeps the JSX assignment type-correct instead of a loose `object`.
|
|
77
|
+
type Fg = ColorInput
|
|
78
|
+
function token(v: unknown, fallback: Fg): Fg {
|
|
67
79
|
return v && typeof v === "object" ? (v as Fg) : fallback
|
|
68
80
|
}
|
|
69
81
|
|