oc-metricboard 0.1.4 → 0.1.6

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JasonJason-oy
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,137 +1,137 @@
1
- # oc-metricboard
2
-
3
- OpenCode TUI sidebar plugin for real-time LLM metrics (TPS / TTFT / token usage) with **sub-agent aggregation** and **per-model breakdown**.
4
-
5
- Based on [opencode-metrics](https://github.com/nxxxsooo/opencode-metrics) with a streamlined display, sub-agent × model grouping, and production-hardening fixes.
6
-
7
- ## Features
8
-
9
- - **Real-time TPS** — live rolling-window rate while streaming, frozen average on completion (sanity-gated against absurd values)
10
- - **TTFT** — time to first token, anchored to the user message (not the lazy `step.started` event)
11
- - **Token usage** — exact input/output counts from provider (estimated fallback)
12
- - **Sub-agent aggregation** (`scope: "tree"`) — merges all descendant sub-agent sessions
13
- - **Per-model breakdown** — one row per distinct model with `×N` session count
14
- - **Collapsed quick-view** — keeps a compact TPS + Session summary while collapsed
15
- - **Compact layout** — no vertical gaps, no value truncation in narrow sidebars
16
-
17
- ### Display
18
-
19
- ```
20
- ▼ MetricBoard
21
- TPS ⚡ 116.9 t/s
22
- Elapsed ▹ 1m5s
23
- TTFT ⏱ 57.8s
24
- Tokens ↓ 603.1K in ↑ 3.9K out
25
- Session ◷ 1m49s
26
-
27
- deepseek-v4-flash
28
- ⚡116.9 ⏱7.8s ↓595.9K ↑902
29
- mimo-v2.5-free ×4
30
- ⚡67.3 ⏱2.1s ↓78.3K ↑5.0K
31
- ```
32
-
33
- ## Installation
34
-
35
- ### From npm (after publishing)
36
-
37
- ```bash
38
- opencode plugin oc-metricboard --global
39
- ```
40
-
41
- or add to your config:
42
-
43
- ```json
44
- {
45
- "plugin": ["oc-metricboard"]
46
- }
47
- ```
48
-
49
- ### Local development (tarball)
50
-
51
- ```json
52
- {
53
- "plugin": ["file:///absolute/path/to/oc-metricboard-0.1.4.tgz"]
54
- }
55
- ```
56
-
57
- Restart OpenCode TUI afterwards. Plugins load at TUI startup and are not hot-reloaded.
58
-
59
- ## Configuration
60
-
61
- Preferences live in `~/.config/opencode/tui-preferences.jsonc` under the `oc-metricboard` key:
62
-
63
- ```jsonc
64
- {
65
- "oc-metricboard": {
66
- "scope": "tree", // "current" | "tree" — tree enables sub-agent aggregation
67
- "section": {
68
- "enabled": true,
69
- "collapsed": false,
70
- "rememberCollapsed": true,
71
- "label": "MetricBoard"
72
- },
73
- "rows": {
74
- "tps": true, // TPS row (renamed from "speed")
75
- "ttft": true, // Time to first token
76
- "input": true, // Input tokens
77
- "output": true, // Output tokens
78
- "cache": false, // Cache read tokens (off by default)
79
- "elapsed": true, // Request elapsed time
80
- "session": true, // Session cumulative time
81
- "modelBreakdown": true // Per-model rows in tree scope
82
- }
83
- }
84
- }
85
- ```
86
-
87
- Runtime behavior (`refreshIntervalMs`, `holdDurationMs`, `estimationRatio`, `enableLogging`) is read from `~/.config/opencode/opencode-bar.json`:
88
-
89
- ```jsonc
90
- {
91
- "refreshIntervalMs": 200,
92
- "holdDurationMs": 0,
93
- "estimationRatio": 4.0,
94
- "enableLogging": false
95
- }
96
- ```
97
-
98
- ## How it works
99
-
100
- The plugin subscribes to OpenCode events:
101
-
102
- - `session.created/updated/status` — builds the session tree
103
- - `message.part.delta`, `session.next.text.delta` — live token estimation and TPS window
104
- - `session.next.step.started/ended` — exact token counts from provider
105
- - `message.updated` — model attribution and exact counts
106
- - `session.idle` — request completion
107
-
108
- For **tree scope** it additionally:
109
-
110
- 1. Queries `session.children` (SDK client) to build the sub-agent hierarchy
111
- 2. Hydrates descendant sessions via the async SDK client (`session.messages` / `session.status`)
112
- 3. Groups requests by `(modelID, providerID)`, summing tokens and pooling sessions into a `×N` count
113
- 4. Renders one compact two-line entry per model group
114
-
115
- ### Design notes
116
-
117
- - **Aggregate cache** (150 ms TTL): multiple sidebar rows share one aggregation pass per render tick to avoid redundant O(tree) work and UI jank.
118
- - **TTFT anchor**: uses the preceding user message's created time — opencode 1.18.x stamps `step.started` lazily at the first token, which would otherwise collapse TTFT to ~0.
119
- - **Timing sanity**: negative timestamps (from hydrating messages older than the TUI process) and implausible spans are reported as `--`, not garbage numbers.
120
- - **Hydration bounds**: at most 5 attempts per session; a session with no token history is not retried forever.
121
-
122
- ## Development
123
-
124
- ```bash
125
- npm install
126
- npm run build # tsup bundle check
127
- npm test # bun test (requires bun)
128
- npm pack --dry-run # verify publish contents
129
- ```
130
-
131
- ## Credits
132
-
133
- Forked from [opencode-metrics](https://github.com/nxxxsooo/opencode-metrics) by nxxxsooo, itself a rewrite of [Icicno/opencodeBar](https://github.com/Icicno/opencodeBar).
134
-
135
- ## License
136
-
137
- MIT
1
+ # oc-metricboard
2
+
3
+ OpenCode TUI sidebar plugin for real-time LLM metrics (TPS / TTFT / token usage) with **sub-agent aggregation** and **per-model breakdown**.
4
+
5
+ Based on [opencode-metrics](https://github.com/nxxxsooo/opencode-metrics) with a streamlined display, sub-agent × model grouping, and production-hardening fixes.
6
+
7
+ ## Features
8
+
9
+ - **Real-time TPS** — live rolling-window rate while streaming, frozen average on completion (sanity-gated against absurd values)
10
+ - **TTFT** — time to first token, anchored to the user message (not the lazy `step.started` event)
11
+ - **Token usage** — exact input/output counts from provider (estimated fallback)
12
+ - **Sub-agent aggregation** (`scope: "tree"`) — merges all descendant sub-agent sessions
13
+ - **Per-model breakdown** — one row per distinct model with `×N` session count
14
+ - **Collapsed quick-view** — keeps a compact TPS + Session summary while collapsed
15
+ - **Compact layout** — no vertical gaps, no value truncation in narrow sidebars
16
+
17
+ ### Display
18
+
19
+ ```
20
+ ▼ MetricBoard
21
+ TPS ⚡ 116.9 t/s
22
+ Elapsed ▹ 1m5s
23
+ TTFT ⏱ 57.8s
24
+ Tokens ↓ 603.1K in ↑ 3.9K out
25
+ Session ◷ 1m49s
26
+
27
+ deepseek-v4-flash
28
+ ⚡116.9 ⏱7.8s ↓595.9K ↑902
29
+ mimo-v2.5-free ×4
30
+ ⚡67.3 ⏱2.1s ↓78.3K ↑5.0K
31
+ ```
32
+
33
+ ## Installation
34
+
35
+ ### From npm (after publishing)
36
+
37
+ ```bash
38
+ opencode plugin oc-metricboard --global
39
+ ```
40
+
41
+ or add to your config:
42
+
43
+ ```json
44
+ {
45
+ "plugin": ["oc-metricboard"]
46
+ }
47
+ ```
48
+
49
+ ### Local development (tarball)
50
+
51
+ ```json
52
+ {
53
+ "plugin": ["file:///absolute/path/to/oc-metricboard-0.1.4.tgz"]
54
+ }
55
+ ```
56
+
57
+ Restart OpenCode TUI afterwards. Plugins load at TUI startup and are not hot-reloaded.
58
+
59
+ ## Configuration
60
+
61
+ Preferences live in `~/.config/opencode/tui-preferences.jsonc` under the `oc-metricboard` key:
62
+
63
+ ```jsonc
64
+ {
65
+ "oc-metricboard": {
66
+ "scope": "tree", // "current" | "tree" — tree enables sub-agent aggregation
67
+ "section": {
68
+ "enabled": true,
69
+ "collapsed": false,
70
+ "rememberCollapsed": true,
71
+ "label": "MetricBoard"
72
+ },
73
+ "rows": {
74
+ "tps": true, // TPS row (renamed from "speed")
75
+ "ttft": true, // Time to first token
76
+ "input": true, // Input tokens
77
+ "output": true, // Output tokens
78
+ "cache": false, // Cache read tokens (off by default)
79
+ "elapsed": true, // Request elapsed time
80
+ "session": true, // Session cumulative time
81
+ "modelBreakdown": true // Per-model rows in tree scope
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ Runtime behavior (`refreshIntervalMs`, `holdDurationMs`, `estimationRatio`, `enableLogging`) is read from `~/.config/opencode/opencode-bar.json`:
88
+
89
+ ```jsonc
90
+ {
91
+ "refreshIntervalMs": 200,
92
+ "holdDurationMs": 0,
93
+ "estimationRatio": 4.0,
94
+ "enableLogging": false
95
+ }
96
+ ```
97
+
98
+ ## How it works
99
+
100
+ The plugin subscribes to OpenCode events:
101
+
102
+ - `session.created/updated/status` — builds the session tree
103
+ - `message.part.delta`, `session.next.text.delta` — live token estimation and TPS window
104
+ - `session.next.step.started/ended` — exact token counts from provider
105
+ - `message.updated` — model attribution and exact counts
106
+ - `session.idle` — request completion
107
+
108
+ For **tree scope** it additionally:
109
+
110
+ 1. Queries `session.children` (SDK client) to build the sub-agent hierarchy
111
+ 2. Hydrates descendant sessions via the async SDK client (`session.messages` / `session.status`)
112
+ 3. Groups requests by `(modelID, providerID)`, summing tokens and pooling sessions into a `×N` count
113
+ 4. Renders one compact two-line entry per model group
114
+
115
+ ### Design notes
116
+
117
+ - **Aggregate cache** (150 ms TTL): multiple sidebar rows share one aggregation pass per render tick to avoid redundant O(tree) work and UI jank.
118
+ - **TTFT anchor**: uses the preceding user message's created time — opencode 1.18.x stamps `step.started` lazily at the first token, which would otherwise collapse TTFT to ~0.
119
+ - **Timing sanity**: negative timestamps (from hydrating messages older than the TUI process) and implausible spans are reported as `--`, not garbage numbers.
120
+ - **Hydration bounds**: at most 5 attempts per session; a session with no token history is not retried forever.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ npm install
126
+ npm run build # tsup bundle check
127
+ npm test # bun test (requires bun)
128
+ npm pack --dry-run # verify publish contents
129
+ ```
130
+
131
+ ## Credits
132
+
133
+ Forked from [opencode-metrics](https://github.com/nxxxsooo/opencode-metrics) by nxxxsooo, itself a rewrite of [Icicno/opencodeBar](https://github.com/Icicno/opencodeBar).
134
+
135
+ ## License
136
+
137
+ MIT
package/package.json CHANGED
@@ -1,92 +1,92 @@
1
- {
2
- "name": "oc-metricboard",
3
- "version": "0.1.4",
4
- "description": "OpenCode TUI sidebar plugin showing real-time LLM metrics (TPS, TTFT, tokens) with sub-agent × model breakdown",
5
- "keywords": [
6
- "opencode",
7
- "opencode-plugin",
8
- "tui",
9
- "metrics",
10
- "tps",
11
- "ttft",
12
- "tokens",
13
- "monitoring",
14
- "sub-agent",
15
- "llm"
16
- ],
17
- "license": "MIT",
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/JasonJason-oy/oc-metricboard.git"
21
- },
22
- "bugs": {
23
- "url": "https://github.com/JasonJason-oy/oc-metricboard/issues"
24
- },
25
- "homepage": "https://github.com/JasonJason-oy/oc-metricboard#readme",
26
- "engines": {
27
- "opencode": ">=1.14.22",
28
- "node": ">=20.11"
29
- },
30
- "type": "module",
31
- "main": "./src/tui.tsx",
32
- "exports": {
33
- ".": {
34
- "import": "./src/tui.tsx"
35
- },
36
- "./tui": {
37
- "import": "./src/tui.tsx"
38
- }
39
- },
40
- "oc-plugin": [
41
- "tui"
42
- ],
43
- "files": [
44
- "src/tui.tsx",
45
- "src/tui-preferences.ts",
46
- "src/tui-prefs-io.ts",
47
- "src/badge-contrast.ts",
48
- "src/assistant-progress.ts",
49
- "src/collector.ts",
50
- "src/collector-state.ts",
51
- "src/config.ts",
52
- "src/event-bus.ts",
53
- "src/event-handlers.ts",
54
- "src/logger.ts",
55
- "src/metrics.ts",
56
- "src/live-speed.ts",
57
- "src/turn-state.ts",
58
- "src/request-state.ts",
59
- "src/request-updates.ts",
60
- "src/session-hydration.ts",
61
- "src/session-timing.ts",
62
- "src/session-tree.ts",
63
- "src/types.ts",
64
- "src/event-shapes.ts",
65
- "src/components/SidebarMetrics.tsx",
66
- "src/components/StatRow.tsx",
67
- "src/scripts/init-tui-preferences.ts",
68
- "README.md"
69
- ],
70
- "scripts": {
71
- "test": "bun test",
72
- "init:prefs": "OPENCODE_TUI_PREFERENCES_FILE=${OPENCODE_TUI_PREFERENCES_FILE:-$HOME/.config/opencode/tui-preferences.jsonc} bun run src/scripts/init-tui-preferences.ts",
73
- "prepublishOnly": "npm pack --dry-run"
74
- },
75
- "devDependencies": {
76
- "@opencode-ai/plugin": "1.18.4",
77
- "@opencode-ai/sdk": "1.18.4",
78
- "@types/bun": "latest",
79
- "tsup": "^8.0.0",
80
- "typescript": "^5.0.0"
81
- },
82
- "dependencies": {
83
- "@opentui/core": "0.4.5",
84
- "@opentui/solid": "0.4.5",
85
- "comment-json": "^5.0.0",
86
- "solid-js": "^1.9.12"
87
- },
88
- "peerDependencies": {
89
- "@opencode-ai/plugin": "*",
90
- "@opencode-ai/sdk": "*"
91
- }
92
- }
1
+ {
2
+ "name": "oc-metricboard",
3
+ "version": "0.1.6",
4
+ "description": "OpenCode TUI sidebar plugin showing real-time LLM metrics (TPS, TTFT, tokens) with sub-agent × model breakdown",
5
+ "keywords": [
6
+ "opencode",
7
+ "opencode-plugin",
8
+ "tui",
9
+ "metrics",
10
+ "tps",
11
+ "ttft",
12
+ "tokens",
13
+ "monitoring",
14
+ "sub-agent",
15
+ "llm"
16
+ ],
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/JasonJason-oy/oc-metricboard.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/JasonJason-oy/oc-metricboard/issues"
24
+ },
25
+ "homepage": "https://github.com/JasonJason-oy/oc-metricboard#readme",
26
+ "engines": {
27
+ "opencode": ">=1.14.22",
28
+ "node": ">=20.11"
29
+ },
30
+ "type": "module",
31
+ "main": "./src/tui.tsx",
32
+ "exports": {
33
+ ".": {
34
+ "import": "./src/tui.tsx"
35
+ },
36
+ "./tui": {
37
+ "import": "./src/tui.tsx"
38
+ }
39
+ },
40
+ "oc-plugin": [
41
+ "tui"
42
+ ],
43
+ "files": [
44
+ "src/tui.tsx",
45
+ "src/tui-preferences.ts",
46
+ "src/tui-prefs-io.ts",
47
+ "src/badge-contrast.ts",
48
+ "src/assistant-progress.ts",
49
+ "src/collector.ts",
50
+ "src/collector-state.ts",
51
+ "src/config.ts",
52
+ "src/event-bus.ts",
53
+ "src/event-handlers.ts",
54
+ "src/logger.ts",
55
+ "src/metrics.ts",
56
+ "src/live-speed.ts",
57
+ "src/turn-state.ts",
58
+ "src/request-state.ts",
59
+ "src/request-updates.ts",
60
+ "src/session-hydration.ts",
61
+ "src/session-timing.ts",
62
+ "src/session-tree.ts",
63
+ "src/types.ts",
64
+ "src/event-shapes.ts",
65
+ "src/components/SidebarMetrics.tsx",
66
+ "src/components/StatRow.tsx",
67
+ "src/scripts/init-tui-preferences.ts",
68
+ "README.md"
69
+ ],
70
+ "scripts": {
71
+ "test": "bun test",
72
+ "init:prefs": "OPENCODE_TUI_PREFERENCES_FILE=${OPENCODE_TUI_PREFERENCES_FILE:-$HOME/.config/opencode/tui-preferences.jsonc} bun run src/scripts/init-tui-preferences.ts",
73
+ "prepublishOnly": "npm pack --dry-run"
74
+ },
75
+ "devDependencies": {
76
+ "@opencode-ai/plugin": "1.18.4",
77
+ "@opencode-ai/sdk": "1.18.4",
78
+ "@types/bun": "latest",
79
+ "tsup": "^8.0.0",
80
+ "typescript": "^5.0.0"
81
+ },
82
+ "dependencies": {
83
+ "@opentui/core": "0.4.5",
84
+ "@opentui/solid": "0.4.5",
85
+ "comment-json": "^5.0.0",
86
+ "solid-js": "^1.9.12"
87
+ },
88
+ "peerDependencies": {
89
+ "@opencode-ai/plugin": "*",
90
+ "@opencode-ai/sdk": "*"
91
+ }
92
+ }