opencode-tokscope 0.1.0 → 0.3.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 +36 -78
- package/dist/tui.js +2005 -471
- package/package.json +23 -5
package/README.md
CHANGED
|
@@ -1,103 +1,61 @@
|
|
|
1
1
|
# opencode-tokscope
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/opencode-tokscope)
|
|
4
|
+
[](https://github.com/mihaellenic/opencode-tokscope/blob/main/LICENSE)
|
|
5
|
+
[](https://opencode.ai/docs/plugins/)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**Which models and providers are fastest in your actual OpenCode usage? And are they getting faster or slower?**
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Tokscope is an OpenCode V2 terminal UI plugin with:
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
- A full-screen `/tokscope` page comparing median tokens per second for each model/provider pair.
|
|
12
|
+
- A daily median trend for the selected pair, with project, time-range, and reasoning-setting filters.
|
|
13
|
+
- A clickable sidebar summary of the fastest pairs over the last 24 hours.
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+

|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Metric
|
|
16
|
-
|
|
17
|
-
One sample = one completed model request (an assistant step), including main-agent, subagent, and background activity.
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
tok/s = (tokens.output + tokens.reasoning) / ((time.streamed - time.created) / 1000)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
- Matches OpenCode's native TUI throughput semantics: `time.streamed` is when the provider response body ended, so tool settlement time is excluded.
|
|
24
|
-
- Input and cache tokens never count toward generated-token throughput.
|
|
25
|
-
- Headline per model/provider is the **median of individual request rates** — not total tokens ÷ total duration, and not an average.
|
|
26
|
-
- Measured: completed, no error, `time.streamed` present, positive duration, and `output + reasoning > 0`.
|
|
27
|
-
- Unavailable: completed requests missing that data (older history). They appear as `unavailable` with `0` calls after measured rows, and are counted in the coverage line — never shown as `0.0 tok/s`.
|
|
28
|
-
- Failed, cancelled, and in-progress requests are excluded entirely.
|
|
29
|
-
|
|
30
|
-
Historical sessions are read through the running OpenCode server, so requests made before installing the plugin are included wherever the recorded data supports the metric. Daily trends bucket by local calendar day using the day the request completed; days without measurements are gaps, never zeros.
|
|
17
|
+

|
|
31
18
|
|
|
32
19
|
## Install
|
|
33
20
|
|
|
34
|
-
Requires
|
|
35
|
-
|
|
36
|
-
The one-command install:
|
|
21
|
+
Requires **OpenCode V2 TUI**.
|
|
37
22
|
|
|
38
|
-
```
|
|
23
|
+
```sh
|
|
39
24
|
opencode plugin add opencode-tokscope
|
|
40
25
|
```
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Only if `opencode plugin add` does not work for some reason, add the plugin manually to the `plugins` array in `~/.config/opencode/cli.json`. Add or extend only that key; keep every unrelated setting already in the file. A minimal file looks like this:
|
|
45
|
-
|
|
46
|
-
```json
|
|
47
|
-
{
|
|
48
|
-
"$schema": "https://opencode.ai/v2/cli.json",
|
|
49
|
-
"plugins": ["opencode-tokscope"]
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
To pin the first release instead of following the latest published version, use `opencode plugin add opencode-tokscope@0.1.0`, or put `"opencode-tokscope@0.1.0"` in the manual array entry.
|
|
27
|
+
## Use
|
|
54
28
|
|
|
55
|
-
|
|
29
|
+
Run `/tokscope`, or press `Ctrl+P` and select **Tokscope**.
|
|
56
30
|
|
|
57
|
-
|
|
31
|
+
The page opens with **all projects · last 30 days · all reasoning settings**. Active filters and measured/unavailable coverage remain visible.
|
|
58
32
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`Bun.build` with the Solid transform from `@opentui/solid/bun-plugin` produces `dist/tui.js`. Host-provided modules stay **external** so OpenCode's runtime-plugin transform binds them to the TUI's own instances: `effect`, `@opencode/plugin` (and subpaths), `solid-js`, `@opentui/core`, `@opentui/solid`, `@opentui/keymap` (and subpaths). Bundling those produces a second Solid/OpenTUI runtime and the page fails with `No renderer found`.
|
|
33
|
+
| Key | Action |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `↑` / `↓` or `k` / `j` | Select a model/provider pair |
|
|
36
|
+
| `←` / `→` | Select a day in its trend |
|
|
37
|
+
| `s` | Choose current project or all projects |
|
|
38
|
+
| `t` | Choose last 7 / 30 / 90 days or all history |
|
|
39
|
+
| `r` | Choose all / a recorded reasoning setting / unknown |
|
|
40
|
+
| `Esc` | Return to the previous screen |
|
|
69
41
|
|
|
70
|
-
|
|
42
|
+
**Sidebar:** shows up to three fastest pairs across **all projects on the connected instance**, each requiring at least **three measured calls in the rolling 24-hour window**. Click anywhere in the widget to open the page. It refreshes after a model step completes and once a minute while visible. Read failures retain the last successful rows; no qualifying pairs shows `No models with 3+ calls in 24h.`
|
|
71
43
|
|
|
72
|
-
|
|
44
|
+
## What tok/s means
|
|
73
45
|
|
|
74
|
-
|
|
75
|
-
mkdir -p ~/.config/opencode/plugins
|
|
76
|
-
ln -sfn /path/to/opencode-tokscope ~/.config/opencode/plugins/opencode-tokscope
|
|
77
|
-
```
|
|
46
|
+
One sample is one completed model request (assistant step), including main-agent, subagent, and background activity:
|
|
78
47
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
bun test # unit tests (metric, harvest, aggregation, chart, state)
|
|
83
|
-
bun run typecheck # tsc --noEmit (Bun.build strips types, so this is the type gate)
|
|
84
|
-
bun run build # rebuild dist/tui.js, then reload OpenCode
|
|
48
|
+
```text
|
|
49
|
+
tok/s = (tokens.output + tokens.reasoning) / ((time.streamed - time.created) / 1000)
|
|
85
50
|
```
|
|
86
51
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
| `←` / `→` | Move day selection in the trend |
|
|
93
|
-
| `s` | Scope: current project / all projects |
|
|
94
|
-
| `t` | Time range: last 7 / 30 / 90 days, all history |
|
|
95
|
-
| `r` | Reasoning setting: all / a recorded setting / unknown |
|
|
96
|
-
| `esc` | Return to the previous screen |
|
|
97
|
-
| `enter` | Retry after a read error |
|
|
98
|
-
|
|
99
|
-
Defaults on open: all projects, last 30 days, all reasoning settings combined. Current project remains selectable. Header and footer always show the active filters and coverage (`N measured calls; M unavailable`).
|
|
52
|
+
- Comparisons use the **median of individual request rates**, not an average or total tokens divided by total duration.
|
|
53
|
+
- The interval ends when the provider response body ends, excluding tool settlement time. Input and cache tokens do not count.
|
|
54
|
+
- Measurements require completion without error, a recorded stream end, positive duration, and positive generated tokens. Failed, cancelled, and in-progress requests are excluded.
|
|
55
|
+
- Completed requests without usable data count as **unavailable**, never zero throughput. Pairs with only unavailable data appear after measured rows with `0` measured calls.
|
|
56
|
+
- Existing history is read through the connected OpenCode server, including requests made before installation when the recorded data supports measurement. Daily trends use the local calendar day of completion; missing days are gaps, not zeros.
|
|
100
57
|
|
|
101
|
-
##
|
|
58
|
+
## Project links
|
|
102
59
|
|
|
103
|
-
|
|
60
|
+
- [Contributing and local development](https://github.com/mihaellenic/opencode-tokscope/blob/main/CONTRIBUTING.md)
|
|
61
|
+
- [MIT license](https://github.com/mihaellenic/opencode-tokscope/blob/main/LICENSE)
|