@glaicer/supercode-token-usage-panel 1.0.1 → 1.2.0
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/README.md +18 -2
- package/dist/index.js +17 -0
- package/index.ts +10 -0
- package/package.json +6 -2
- package/tui.js +3 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Requires OpenCode v2 (`>=2.0.0`). On OpenCode v1 stay on `@glaicer/supercode-tok
|
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
|
-
Install with the OpenCode CLI — it installs the package and registers the plugin in the global
|
|
16
|
+
Install with the OpenCode CLI — it installs the package and registers the plugin in the global server configuration (`~/.config/opencode/opencode.jsonc`):
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
opencode plugin add @glaicer/supercode-token-usage-panel
|
|
@@ -24,7 +24,7 @@ Restart OpenCode after installing.
|
|
|
24
24
|
> [!IMPORTANT]
|
|
25
25
|
> **The first OpenCode load after installing this plugin may be slow.** That's OpenCode downloading the plugin's packages and managed tools into its cache — it happens once. Every subsequent start is fast.
|
|
26
26
|
|
|
27
|
-
Manual install also works: add the package to the `plugins` array in `~/.config/opencode/
|
|
27
|
+
Manual install also works: add the package to the `plugins` array in `~/.config/opencode/opencode.jsonc`:
|
|
28
28
|
|
|
29
29
|
```jsonc
|
|
30
30
|
{
|
|
@@ -32,6 +32,22 @@ Manual install also works: add the package to the `plugins` array in `~/.config/
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
### Sidebar order
|
|
36
|
+
|
|
37
|
+
The panel claims `after: "sidebar.content"`, and so do other plugins that extend the sidebar, so their relative order is the order in which they were registered. Entries in `opencode.jsonc` are always ordered before entries in `cli.json`, so register the panel here to place it relative to another sidebar plugin — for example, between `context-progress-bar` and `session-recap`:
|
|
38
|
+
|
|
39
|
+
```jsonc
|
|
40
|
+
{
|
|
41
|
+
"plugins": [
|
|
42
|
+
"@glaicer/supercode-context-progress-bar",
|
|
43
|
+
"@glaicer/supercode-token-usage-panel",
|
|
44
|
+
"@glaicer/supercode-session-recap"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The package ships a no-op server entry purely to make this possible: a `./tui`-only package can only be registered in `cli.json`, which always sorts last.
|
|
50
|
+
|
|
35
51
|
## Development
|
|
36
52
|
|
|
37
53
|
```bash
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server entrypoint (required so the plugin loads at all).
|
|
3
|
+
*
|
|
4
|
+
* The panel itself is TUI-only; all behaviour lives in `src/usage-panel.tsx`.
|
|
5
|
+
* This no-op server half exists for two host requirements: the server resolves
|
|
6
|
+
* a package through its main/server entry and only then reports `features.tui`,
|
|
7
|
+
* and sidebar claims from different plugins share one slot, so their relative
|
|
8
|
+
* order is the order of the `plugins` array that loaded them. Registering in
|
|
9
|
+
* `opencode.jsonc` is therefore the only way to place this panel relative to
|
|
10
|
+
* another `sidebar.content` claim such as session-recap — a `cli.json`-only
|
|
11
|
+
* entry is always ordered last.
|
|
12
|
+
*/
|
|
13
|
+
import { Plugin } from "@opencode/plugin";
|
|
14
|
+
export default Plugin.define({
|
|
15
|
+
id: "supercode.token-usage",
|
|
16
|
+
setup() {}
|
|
17
|
+
});
|
package/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root server entry for local-directory loading.
|
|
3
|
+
*
|
|
4
|
+
* When this package is referenced by directory path in `opencode.json(c)`
|
|
5
|
+
* `plugins`, the host loads `<dir>/index.{ts,js}` directly and does not consult
|
|
6
|
+
* `package.json` `exports`. The npm route keeps using `exports["."]` →
|
|
7
|
+
* `./dist/index.js`. Both entries define the same plugin; the host loads
|
|
8
|
+
* exactly one per package.
|
|
9
|
+
*/
|
|
10
|
+
export { default } from "./dist/index.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@glaicer/supercode-token-usage-panel",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "OpenCode TUI sidebar section: cumulative token usage and cost of the current session family.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
"generation-speed"
|
|
22
22
|
],
|
|
23
23
|
"exports": {
|
|
24
|
+
".": "./dist/index.js",
|
|
25
|
+
"./server": "./dist/index.js",
|
|
24
26
|
"./tui": "./dist/usage-panel.js"
|
|
25
27
|
},
|
|
26
28
|
"files": [
|
|
27
|
-
"dist"
|
|
29
|
+
"dist",
|
|
30
|
+
"index.ts",
|
|
31
|
+
"tui.js"
|
|
28
32
|
],
|
|
29
33
|
"publishConfig": {
|
|
30
34
|
"access": "public"
|
package/tui.js
ADDED