opencode-tokscope 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/tui.js +1427 -0
- package/package.json +33 -4
- package/tui.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mihael Lenic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-tokscope
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An OpenCode v2 TUI plugin answering: **which models and providers are fastest in my actual usage?** and **is a model/provider getting faster or slower over time?**
|
|
4
|
+
|
|
5
|
+
Opens a full-screen `/tokscope` page with a median tok/s comparison table (one row per model + provider) and a per-model daily median trend, and adds a compact summary to the session sidebar.
|
|
6
|
+
|
|
7
|
+
## Sidebar
|
|
8
|
+
|
|
9
|
+
The bottom of the session sidebar shows the three fastest model/provider pairs from a rolling 24-hour window across **all projects** on the connected instance (not just the current session or project). A pair needs at least three measured requests inside the window to appear; one or two qualifying pairs show one or two rows, and none shows `No models with 3+ calls in 24h.`
|
|
10
|
+
|
|
11
|
+
Rows show the full model name and as much of the provider name as fits, followed by the integer median tok/s. Speeds are right-aligned under the `tok/s` heading; per-entry call counts and repeated units are omitted. The scope and window are fixed — the sidebar does not follow the full page's filters.
|
|
12
|
+
|
|
13
|
+
Click anywhere in the widget to open the full page. The widget refreshes when a model step completes and once a minute while visible; after a read failure the last successful rows stay on screen marked `(stale)`. The sidebar has no shortcut of its own — `/tokscope` and the command palette remain the keyboard entry points.
|
|
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.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Requires an OpenCode V2 TUI. The packaged plugin is built against the OpenCode 2.1.2 API and development pins; the actual npm artifact was runtime-validated on OpenCode 2.1.4, while 2.1.2 was historically tested. Other 2.x versions are untested, and V1 is not supported.
|
|
35
|
+
|
|
36
|
+
The one-command install:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
opencode plugin add opencode-tokscope
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`plugin add` classifies the package as a TUI plugin (verified against the released OpenCode 2.1.4 CLI) and records it in `~/.config/opencode/cli.json` for you. Older 2.x CLIs whose `plugin add` predates TUI-class packages do not support this form.
|
|
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.
|
|
54
|
+
|
|
55
|
+
OpenCode loads installed plugins automatically. Run `/tokscope`, or open the palette (`ctrl+p`) and pick "Tokscope". If the command does not appear, run `/reload`; restart OpenCode only when you changed dependencies that it does not watch for reloads.
|
|
56
|
+
|
|
57
|
+
## Local development (Bun)
|
|
58
|
+
|
|
59
|
+
Consumers install the published package; they do not need Bun or a build step. The npm artifact ships prebuilt JavaScript. The following setup is only for working on this repository.
|
|
60
|
+
|
|
61
|
+
Requires Bun.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun install
|
|
65
|
+
bun run build
|
|
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`.
|
|
69
|
+
|
|
70
|
+
Development pins match the tested host (`opencode v2.1.2`): `@opencode/plugin@2.1.2`, `@opencode/client@2.1.2`, `@opentui/*@0.6.6`, `solid-js@1.9.15`.
|
|
71
|
+
|
|
72
|
+
For local discovery, symlink the checkout into OpenCode's plugin directory:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mkdir -p ~/.config/opencode/plugins
|
|
76
|
+
ln -sfn /path/to/opencode-tokscope ~/.config/opencode/plugins/opencode-tokscope
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
OpenCode picks up the link automatically where it can; if it does not, run `/reload`. A full restart is only needed when development dependencies outside OpenCode's watch set change. Rebuild and reload after source edits.
|
|
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
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
| Key | Action |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `↑` / `↓` (or `k` / `j`) | Move row selection |
|
|
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`).
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT. See [LICENSE](LICENSE).
|