oc-flight-deck 0.24.0 → 0.25.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/CHANGELOG.md +11 -0
- package/README.md +42 -24
- package/dist/tui/index.js +229 -103
- package/docs/GUIDE.md +10 -7
- package/flight-deck.example.jsonc +43 -27
- package/flight-deck.schema.json +27 -10
- package/package.json +6 -6
- package/src/tui/config.ts +115 -6
- package/src/tui/go-panel.ts +5 -3
- package/src/tui/index.tsx +38 -3
- package/src/tui/lifetime-totals.ts +92 -0
- package/src/tui/presentation.ts +11 -5
- package/src/tui/rows.ts +73 -71
- package/src/tui/stat-fields.ts +55 -22
package/docs/GUIDE.md
CHANGED
|
@@ -89,13 +89,14 @@ One global file: `~/.config/opencode/flight-deck.jsonc`. The `.json` name is als
|
|
|
89
89
|
|
|
90
90
|
| Key | Default | Effect |
|
|
91
91
|
| --- | --- | --- |
|
|
92
|
+
| **`lifetimeTotalsPath`** | `~/.local/share/opencode/flight-deck/totals.json` | Optional file for the lifetime total's high-water mark. A non-empty string overrides it; malformed values fall back and are reported. |
|
|
92
93
|
| **`sidebar.enabled`** | `true` | `false` leaves the plugin loaded but invisible. |
|
|
93
|
-
| **`sidebar.rows`** | `["status","agent","model","
|
|
94
|
+
| **`sidebar.rows`** | `["status","agent","model","spend","project","tokens","cache","context","perms","elapsed","tps"]` | Live rows, top to bottom, any subset in any order. Max 24 names; unknown names are ignored with a one-time warning. `cost`, `total` and `session` stay accepted as aliases of `spend`, `lifetime` and `ses`. |
|
|
94
95
|
| **`sidebar.lines`** | `[]` | Fixed lines above the rows. Max 24. These plus rows share the rail cap (`maxLines`); fixed lines render at full brightness while live rows are dimmed. |
|
|
95
96
|
| **`sidebar.footer.lines`** | `[]` | Fixed lines in the host footer slot, outside the rail cap; max 24. |
|
|
96
97
|
| **`sidebar.footer.go`** | `false` | `true` or an object draws the live Go usage panel. Object keys: `header` (`false`), `barWidth` (`10`, 1–40), `labelWidth` (`6`, 5–24, auto-widens), `percent` (`true`), `reset` (`true`), `align` (`"right"`, left, right, or center), `sweep` (`false`), `labels` (`{rolling,weekly,monthly}`, each 1–24 chars), `blink` (`true`), `blinkMs` (`700`, 200–5000). |
|
|
97
|
-
| **`sidebar.persist`** | `true` | Every named row renders, drawing
|
|
98
|
-
| **`sidebar.placeholder`** | `"
|
|
98
|
+
| **`sidebar.persist`** | `true` | Every named row renders, drawing an honest zero until data arrives; `false` omits rows with no data. |
|
|
99
|
+
| **`sidebar.placeholder`** | `"0"` | Non-empty string; only for a data-less row with no zero of its own. Numeric rows never use it. `caution` stays silent, and `updated` draws it until the host records an action. |
|
|
99
100
|
| **`sidebar.maxLines`** | `24` | Whole rail, fixed lines plus rows, 1–24. |
|
|
100
101
|
| **`sidebar.tps.scope`** | `"family"` | `"family"` paces the open session plus subagents; `"session"` paces the open session alone. |
|
|
101
102
|
| **`sidebar.tps.display`** | `"rt"` | `"rt"` estimated realtime throughput plus observed TTFT, `"avg"` settled-turn average, `"both"` both figures plus TTFT. |
|
|
@@ -175,8 +176,10 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
175
176
|
| `agent` | Active agent name. | yes |
|
|
176
177
|
| `model` | Model id, plus ` · variant` when one is present. | yes |
|
|
177
178
|
| `branch` | Current git branch. Costs a VCS call. | opt-in |
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
179
|
+
| `spend` | The current model's spend for this session only. When the rail already shows `lifetime`, this row shows the session's own figure; otherwise it merges the subagent total into itself. Merged shape `$1.84 · 3 subagents`; childless shows `$1.84`. | yes |
|
|
180
|
+
| `lifetime` | Family total plus subagent count, all models, `$1.84 · 0 subagents` when childless. A durable high-water mark: the highest figure seen for the family root is kept in `~/.local/share/opencode/flight-deck/totals.json`, so a restart or host pruning cannot lower the row. | opt-in |
|
|
181
|
+
| `cost` | Alias for `spend`; accepted in `sidebar.rows` and folded to it. Old configs keep the `cost` label. | yes |
|
|
182
|
+
| `total` | Alias for `lifetime`; accepted in `sidebar.rows` and folded to it. Old configs keep the `total` label. | opt-in |
|
|
180
183
|
| `project` | Every session in the project: `$12.40 · 21 sessions` when more than one, else just the figure. | yes |
|
|
181
184
|
| `tokens` | `1.2M in · 84k out`, same family scope as `cost`. | yes |
|
|
182
185
|
| `cache` | `92% hit · 1.1M read`, family scope. The hit-rate denominator is cache read plus input; cache write is excluded because a write is not a lookup. A zero read is drawn (`0 read`, or `0% hit · 0 read` when input exists), never hidden. | yes |
|
|
@@ -184,7 +187,7 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
184
187
|
| `perms` | Pending approvals. One names the action plus an 18-cell clipped resource (`bash · src/tui…`); several lead with the count (`3 waiting · bash`). | yes |
|
|
185
188
|
| `elapsed` | Active generation time, recomputed from the assistant-turn spans the host recorded for this session and its subagents. Survives a restart, never steps backwards while the host reports those turns, and is not wall-clock since the session began. | yes |
|
|
186
189
|
| `updated` | Absolute timestamp of the newest action the host recorded: the latest message's `completed`, else `streamed`, else `created` stamp. The host locale and time zone apply by default; `format.timestamp` sets the locale, date and time styles, the 12/24-hour clock, and an IANA zone or UTC offset. A Windows zone id is rejected and the host zone is used. | opt-in |
|
|
187
|
-
| `tps` | Session speed. Default `rt`: estimated realtime throughput from streaming delta bytes and observed mean TTFT after steps settle; TTFT
|
|
190
|
+
| `tps` | Session speed. Default `rt`: estimated realtime throughput from streaming delta bytes and observed mean TTFT after steps settle; TTFT rides only while a rate stands. `avg` selects the settled-turn average; `both` shows both rates. Scope `family` includes subagents; `session` covers the open session. With no rate the row draws `0 <sidebar.tps.label>` (`0 tok/s` shipped), never a placeholder or a ttft-only fallback. | yes |
|
|
188
191
|
| `spark` | Recent turn sizes as a sparkline; the newest samples are kept. | opt-in |
|
|
189
192
|
| `reasoning` | Reasoning tokens, family scope. | opt-in |
|
|
190
193
|
| `turns` | Prompts sent this session. | opt-in |
|
|
@@ -194,7 +197,7 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
194
197
|
| `ses` | Clipped 18-cell preview of the session id (less when the label column is narrow, floored at 8), labelled `session`. Click copies the full id. A verified copy is silent: the host write reports `written`, or an exact clipboard read-back confirms an OSC52 dispatch. An unconfirmed dispatch is an advisory warning (paste to verify). Gate the failure toast with `notifications.copy`. | opt-in |
|
|
195
198
|
| `session` | Alias for `ses`; accepted in `sidebar.rows` and folded to it. | opt-in |
|
|
196
199
|
|
|
197
|
-
With `sidebar.persist` (the default) named rows render even without data.
|
|
200
|
+
With `sidebar.persist` (the default) named rows render even without data. Numeric rows draw an honest zero: `$0.000` money rows, `0 in · 0 out`, `0 read`, `~0 used`, `0s`, `0` reasoning and turns, `0 tok/s` tps, plus the zero forms of the gauge and spark. `caution` stays silent; `updated` draws `sidebar.placeholder` (`0` by default) because there is no honest zero timestamp. Set `persist: false` to omit rows with no data instead.
|
|
198
201
|
|
|
199
202
|
### Recipes
|
|
200
203
|
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
// host's renderer, so a smaller value spends work without adding motion.
|
|
54
54
|
"refresh": 100,
|
|
55
55
|
|
|
56
|
+
// Optional: where the durable high-water lifetime total is kept. Omit it to
|
|
57
|
+
// use `~/.local/share/opencode/flight-deck/totals.json`. A non-empty string
|
|
58
|
+
// is used as given; malformed values are reported and the default is used.
|
|
59
|
+
// ,"lifetimeTotalsPath": "/tmp/flight-deck-totals.json",
|
|
60
|
+
|
|
56
61
|
// ── Sidebar ──────────────────────────────────────────────────────────────
|
|
57
62
|
"sidebar": {
|
|
58
63
|
// false hides the whole panel.
|
|
@@ -117,25 +122,23 @@
|
|
|
117
122
|
// agent which agent is running (orchestrator, build, plan, ...)
|
|
118
123
|
// model model id, plus the variant when there is one
|
|
119
124
|
// branch current git branch. Off by default — costs a VCS call
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// the session's own cost with `0 subagents` when it spawned
|
|
132
|
-
// none, never a blank row
|
|
125
|
+
// spend the current model's spend for this session only. `cost` is
|
|
126
|
+
// an accepted alias and renders the same row. It cannot see
|
|
127
|
+
// spend from an independently spawned top-level session: the
|
|
128
|
+
// rollup follows the host's parentID link only (family()),
|
|
129
|
+
// and a session spawned as an independent top-level session
|
|
130
|
+
// carries no parentID. `project` covers every session in the
|
|
131
|
+
// project, spawned included
|
|
132
|
+
// lifetime the durable family total and subagent count on a row of its
|
|
133
|
+
// own — all models, this session plus its subagents, kept as
|
|
134
|
+
// a high-water mark across restarts. `total` is an accepted
|
|
135
|
+
// alias. `0 subagents` when it spawned none, never a blank
|
|
133
136
|
// project every session in this project, not just the one on screen
|
|
134
|
-
// tokens input and output, in the same family scope as `
|
|
137
|
+
// tokens input and output, in the same family scope as `spend`: this
|
|
135
138
|
// conversation plus its subagent sessions when any exist,
|
|
136
139
|
// the session alone when there are none
|
|
137
140
|
// cache cache hit rate, then cache reads, in the same family scope
|
|
138
|
-
// as `
|
|
141
|
+
// as `spend`
|
|
139
142
|
// context a gauge of how full the context window is
|
|
140
143
|
// perms what is waiting for approval, not just how many
|
|
141
144
|
// elapsed active time recomputed from the assistant-turn spans the host
|
|
@@ -159,7 +162,7 @@
|
|
|
159
162
|
// `both` draws both on one line
|
|
160
163
|
// spark recent turn sizes as a sparkline
|
|
161
164
|
// reasoning reasoning tokens, when the model emits them, in the same
|
|
162
|
-
// family scope as `
|
|
165
|
+
// family scope as `spend`
|
|
163
166
|
// turns how many prompts you have sent this session
|
|
164
167
|
// guard harness status from oc-harness-guard: breaches, orphans,
|
|
165
168
|
// findings, or ok. Available, off by default.
|
|
@@ -180,16 +183,16 @@
|
|
|
180
183
|
// the rename at every `layout.labelWidth`. Off by default; needs the host's mouse.
|
|
181
184
|
//
|
|
182
185
|
// Every named row renders persistently, so the rail keeps a stable shape:
|
|
183
|
-
// a row with no data yet draws
|
|
184
|
-
// rows
|
|
185
|
-
// `updated`
|
|
186
|
-
// The fixed lines and live rows share the maxLines
|
|
187
|
-
// anything past it is dropped.
|
|
186
|
+
// a numeric row with no data yet draws an honest zero — `$0.000` for
|
|
187
|
+
// money rows, `0 in · 0 out` for tokens, `0 tok/s` for tps. `caution`
|
|
188
|
+
// stays silent; `updated` draws `sidebar.placeholder` because there is no
|
|
189
|
+
// honest zero timestamp. The fixed lines and live rows share the maxLines
|
|
190
|
+
// budget below, and anything past it is dropped.
|
|
188
191
|
"rows": [
|
|
189
192
|
"status",
|
|
190
193
|
"agent",
|
|
191
194
|
"model",
|
|
192
|
-
"
|
|
195
|
+
"spend",
|
|
193
196
|
"project",
|
|
194
197
|
"tokens",
|
|
195
198
|
"cache",
|
|
@@ -231,7 +234,19 @@
|
|
|
231
234
|
// so a restart forgets them. `rt` also shows TTFT when available.
|
|
232
235
|
// An unknown value falls back to `"rt"` and
|
|
233
236
|
// is reported.
|
|
234
|
-
|
|
237
|
+
//
|
|
238
|
+
// `"label"` is the suffix on the single-figure rows: `"rt"` draws
|
|
239
|
+
// `N <label>` and `"avg"` draws the same. The shipped `"tok/s"` keeps
|
|
240
|
+
// today's output; set it to `"rt"` to name the realtime figure after its
|
|
241
|
+
// half. `"both"` already names its two halves `rt` and `avg`, so it
|
|
242
|
+
// ignores this key. The value is trimmed; blank, non-string and overlong
|
|
243
|
+
// values fall back to `"tok/s"` and are reported.
|
|
244
|
+
//
|
|
245
|
+
// `"ttft"` controls the mean time to first token (`1.2s ttft`). On (the
|
|
246
|
+
// default) it rides along beside the figures, and is the whole fallback
|
|
247
|
+
// row when no rate can be drawn. Set it to false to hide that segment in
|
|
248
|
+
// every display mode: with no rate, the row hides instead.
|
|
249
|
+
"tps": { "scope": "family", "display": "rt", "label": "tok/s", "ttft": true },
|
|
235
250
|
|
|
236
251
|
// Every named row renders persistently: with no data yet it draws its
|
|
237
252
|
// zero skeleton or placeholder, in the
|
|
@@ -239,10 +254,11 @@
|
|
|
239
254
|
// instead.
|
|
240
255
|
"persist": true,
|
|
241
256
|
|
|
242
|
-
// Fallback for a persistent row with no
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
|
|
257
|
+
// Fallback for a persistent row with no zero of its own. Any non-empty
|
|
258
|
+
// string; `0` by default. Numeric rows never use it — they draw a real
|
|
259
|
+
// zero. `caution` stays silent (its silence is the design), and `updated`
|
|
260
|
+
// draws it until data is available.
|
|
261
|
+
"placeholder": "0",
|
|
246
262
|
|
|
247
263
|
// Maximum total height, including fixed lines and live rows. Defaults to 24.
|
|
248
264
|
"maxLines": 24
|
package/flight-deck.schema.json
CHANGED
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
"description": "Milliseconds between ticks. Cost and tokens arrive with host events; anything derived from the clock — `elapsed`, the status spinner, and the caution thresholds — needs this timer. 100 turns the spinner once a second. 0 turns the ticker off entirely, which also freezes the annunciator (it works, but only updates on host events). Practical range 16–1000; 1–15 are treated as 16, while 0 is the deliberate off switch and is never clamped."
|
|
20
20
|
},
|
|
21
21
|
|
|
22
|
+
"lifetimeTotalsPath": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1,
|
|
25
|
+
"description": "Optional path to the durable high-water ledger for the `total` row. Leave it out to use `~/.local/share/opencode/flight-deck/totals.json`. A non-empty string is used as given; a malformed value is reported and the default path is used. Entries in this file are never deleted or expired."
|
|
26
|
+
},
|
|
27
|
+
|
|
22
28
|
"sidebar": {
|
|
23
29
|
"type": "object",
|
|
24
30
|
"additionalProperties": false,
|
|
@@ -145,16 +151,16 @@
|
|
|
145
151
|
},
|
|
146
152
|
"rows": {
|
|
147
153
|
"type": "array",
|
|
148
|
-
"items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "dex", "ses", "session"] },
|
|
149
|
-
"default": ["status", "agent", "model", "
|
|
154
|
+
"items": { "enum": ["caution", "status", "agent", "model", "branch", "spend", "lifetime", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "dex", "ses", "session"] },
|
|
155
|
+
"default": ["status", "agent", "model", "spend", "project", "tokens", "cache", "context", "perms", "elapsed", "tps"],
|
|
150
156
|
"maxItems": 24,
|
|
151
|
-
"description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data (the opt-in `updated` row has no skeleton and draws `sidebar.placeholder` instead, because there is no honest zero timestamp); with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row copies the full id to the OS clipboard: a host write reporting `written` or an exact clipboard read-back after the OSC52 dispatch verifies it, only a verified copy counts as success, a verified copy stays silent, and an unverified or failed outcome surfaces a toast gated by `notifications.copy`. `session` is accepted as an alias for `ses` and
|
|
157
|
+
"description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data (the opt-in `updated` row has no skeleton and draws `sidebar.placeholder` instead, because there is no honest zero timestamp); with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row copies the full id to the OS clipboard: a host write reporting `written` or an exact clipboard read-back after the OSC52 dispatch verifies it, only a verified copy counts as success, a verified copy stays silent, and an unverified or failed outcome surfaces a toast gated by `notifications.copy`. `session` is accepted as an alias for `ses`, `cost` for `spend`, and `total` for `lifetime`. Aliases keep working forever; naming both an alias and its key renders the row once and reports the duplicate."
|
|
152
158
|
},
|
|
153
159
|
"tps": {
|
|
154
160
|
"type": "object",
|
|
155
161
|
"additionalProperties": false,
|
|
156
|
-
"default": { "scope": "family", "display": "rt" },
|
|
157
|
-
"description": "The `tps` row: which sessions it paces (`scope`)
|
|
162
|
+
"default": { "scope": "family", "display": "rt", "label": "tok/s", "ttft": true },
|
|
163
|
+
"description": "The `tps` row: which sessions it paces (`scope`), which figure it draws (`display`), what suffix the single-figure rows print (`label`), and whether the observed time to first token may show (`ttft`). When selected it shows the settled-turn average over the whole family: on hosts that record turn timestamps, generation tokens (output plus reasoning) over assistant turns that recorded `streamed`, divided by the union of their `streamed − created` spans — in-flight turns excluded, idle gaps never billed; on hosts without turn timestamps, generation tokens over the borrowed active clock instead. `display: \"rt\"` draws the realtime figure from the host's streaming events instead — an estimate from delta bytes while a turn streams, reading zero while nothing generates; `\"both\"` draws both figures on one line, plus the mean time to first token over settled steps (`1.2s ttft`) — per step, the earliest delta's event time minus the step's `started` dispatch stamp, pushed into the scope's ring when the step ends and kept in memory for the plugin's lifetime. `ttft: false` suppresses that segment in every display mode.",
|
|
158
164
|
"properties": {
|
|
159
165
|
"scope": {
|
|
160
166
|
"type": "string",
|
|
@@ -167,19 +173,30 @@
|
|
|
167
173
|
"enum": ["avg", "rt", "both"],
|
|
168
174
|
"default": "rt",
|
|
169
175
|
"description": "Which figure the `tps` row draws. `avg` is the settled-turn average: on hosts that record turn timestamps, generation tokens over assistant turns with `streamed` recorded, divided by the union of their `streamed - created` spans, in the row's scope; on hosts without them, generation tokens over the borrowed active clock. `rt` is the realtime figure from the host's streaming events — an estimate from delta bytes while a turn streams, reading zero while nothing generates. `both` draws `rt` and `avg` on one line (`106 rt · 41 avg`), plus the mean time to first token over settled steps (`83 rt · 38 avg · 1.2s ttft`): per step, the earliest text/reasoning delta's event time minus the step's `started` dispatch stamp (request dispatch time, before waiting for provider output), pushed into the scope's ring when the step ends — the mean covers the most recent finalized steps observed while the plugin ran (in-memory; a restart forgets them). An unknown value falls back to `rt` and is reported."
|
|
176
|
+
},
|
|
177
|
+
"label": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"maxLength": 16,
|
|
180
|
+
"default": "tok/s",
|
|
181
|
+
"description": "Short suffix printed after the number on the single-figure `tps` rows: `display: \"rt\"` draws `N <label>` and `display: \"avg\"` draws the same. The shipped `tok/s` keeps a new user's output unchanged; set it to `rt` to name the realtime figure after its half. `display: \"both\"` ignores this key because it already names its two halves `rt` and `avg`. The value is trimmed; a blank, non-string or overlong value falls back to `tok/s` and is reported."
|
|
182
|
+
},
|
|
183
|
+
"ttft": {
|
|
184
|
+
"type": "boolean",
|
|
185
|
+
"default": true,
|
|
186
|
+
"description": "Whether the `tps` row may draw the observed mean time to first token over settled steps (`1.2s ttft`). On, the default, the segment rides along beside the figures — including `display: \"rt\"`'s fallback row, shown when no rate can be drawn. Off, it is suppressed in every display mode, and with no rate there is no row at all. A non-boolean value falls back to `true` and is reported."
|
|
170
187
|
}
|
|
171
188
|
}
|
|
172
189
|
},
|
|
173
190
|
"persist": {
|
|
174
191
|
"type": "boolean",
|
|
175
192
|
"default": true,
|
|
176
|
-
"description": "Render named fields persistently.
|
|
193
|
+
"description": "Render named fields persistently. Numeric rows now draw a sane zero before data arrives; only `updated` (no honest zero timestamp) and a few text rows with no zero use `sidebar.placeholder`, while `caution` stays silent. False omits fields without data."
|
|
177
194
|
},
|
|
178
195
|
"placeholder": {
|
|
179
196
|
"type": "string",
|
|
180
197
|
"minLength": 1,
|
|
181
|
-
"default": "
|
|
182
|
-
"description": "Fallback value for a persistent row with no
|
|
198
|
+
"default": "0",
|
|
199
|
+
"description": "Fallback value for a persistent row with no zero of its own. Used only when `sidebar.persist` is true. Must be a non-empty string; anything else falls back to the default `0`. Numeric rows never use it: they draw a real zero instead. `caution` stays silent, and `updated` uses it until the host records an action because there is no honest zero timestamp."
|
|
183
200
|
},
|
|
184
201
|
"maxLines": {
|
|
185
202
|
"type": "integer",
|
|
@@ -450,10 +467,10 @@
|
|
|
450
467
|
}
|
|
451
468
|
},
|
|
452
469
|
"propertyNames": {
|
|
453
|
-
"enum": ["*", "caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "dex", "ses", "session"]
|
|
470
|
+
"enum": ["*", "caution", "status", "agent", "model", "branch", "spend", "lifetime", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "dex", "ses", "session"]
|
|
454
471
|
},
|
|
455
472
|
"default": { "*": { "color": "subdued", "attributes": [] } },
|
|
456
|
-
"description": "Style all live rows under `*`, then optionally override any known row name such as `cost`. A row can change one field and inherit the other from `*`; unknown row names are reported and ignored. `session` is accepted as an alias for `ses` and
|
|
473
|
+
"description": "Style all live rows under `*`, then optionally override any known row name such as `cost`. A row can change one field and inherit the other from `*`; unknown row names are reported and ignored. `session` is accepted as an alias for `ses`, `cost` for `spend`, and `total` for `lifetime`. Aliases keep working forever; naming both an alias and its key renders the row once and reports the duplicate."
|
|
457
474
|
}
|
|
458
475
|
}
|
|
459
476
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-flight-deck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Live OpenCode V2 session telemetry — agent, model, branch, cost, tokens, cache hit rate and context usage in your sidebar.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@opencode/plugin": "^2.
|
|
63
|
+
"@opencode/plugin": "^2.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@opencode/plugin": "2.
|
|
67
|
-
"@opentui/core": "^0.
|
|
68
|
-
"@opentui/solid": "^0.
|
|
66
|
+
"@opencode/plugin": "2.3.0",
|
|
67
|
+
"@opentui/core": "^0.9.0",
|
|
68
|
+
"@opentui/solid": "^0.9.0",
|
|
69
69
|
"@types/bun": "^1.4.4",
|
|
70
|
-
"solid-js": "1.9.
|
|
70
|
+
"solid-js": "1.9.19",
|
|
71
71
|
"string-width": "7.2.0",
|
|
72
72
|
"typescript": "^7.0.2"
|
|
73
73
|
},
|
package/src/tui/config.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// defaults below, so the rail always renders and a typo can never break the TUI.
|
|
10
10
|
|
|
11
11
|
import { DEFAULT_PLACEHOLDER, canonicalField, isStatField, STAT_FIELDS } from "./stats.js";
|
|
12
|
+
import { defaultLifetimeTotalsPath } from "./lifetime-totals.js";
|
|
12
13
|
import type { CautionThresholds } from "./caution.js";
|
|
13
14
|
import type { DurationStyle, TimestampDateStyle, TimestampTimeStyle } from "./format.js";
|
|
14
15
|
import {
|
|
@@ -33,7 +34,7 @@ interface SidebarConfig {
|
|
|
33
34
|
readonly footer: SidebarFooterConfig;
|
|
34
35
|
/** Live session fields to render, top to bottom. Default `DEFAULT_SIDEBAR_ROWS`. */
|
|
35
36
|
readonly rows: readonly string[];
|
|
36
|
-
/** Which sessions the `tps` row paces,
|
|
37
|
+
/** Which sessions the `tps` row paces, which figure it draws, its single-figure suffix, and whether TTFT may show. Default `{ scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY, label: DEFAULT_TPS_LABEL, ttft: DEFAULT_TPS_TTFT }`. */
|
|
37
38
|
readonly tps: TpsConfig;
|
|
38
39
|
/**
|
|
39
40
|
* Render every named row even when the host has no data for it, using
|
|
@@ -157,11 +158,28 @@ export const DEFAULT_TPS_SCOPE: TpsScope = "family";
|
|
|
157
158
|
*/
|
|
158
159
|
export const DEFAULT_TPS_DISPLAY: TpsDisplay = "rt";
|
|
159
160
|
|
|
161
|
+
/**
|
|
162
|
+
* The shipped `tps` TTFT switch: `true`, so the observed time to first token
|
|
163
|
+
* keeps its place beside the figures until the owner turns it off.
|
|
164
|
+
*/
|
|
165
|
+
export const DEFAULT_TPS_TTFT = true;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The shipped `tps` single-figure suffix: `"tok/s"`, so a new user sees the
|
|
169
|
+
* same line as before. `display: "both"` names its halves itself and ignores
|
|
170
|
+
* this key.
|
|
171
|
+
*/
|
|
172
|
+
export const DEFAULT_TPS_LABEL = "tok/s";
|
|
173
|
+
|
|
160
174
|
interface TpsConfig {
|
|
161
175
|
/** Which sessions the `tps` row paces. Default `DEFAULT_TPS_SCOPE`. */
|
|
162
176
|
readonly scope: TpsScope;
|
|
163
177
|
/** Which figure the `tps` row draws. Default `DEFAULT_TPS_DISPLAY`. */
|
|
164
178
|
readonly display: TpsDisplay;
|
|
179
|
+
/** Suffix on the single-figure rows (`rt`, `avg`). Default `DEFAULT_TPS_LABEL`. */
|
|
180
|
+
readonly label: string;
|
|
181
|
+
/** Whether the observed time to first token may render. Default `DEFAULT_TPS_TTFT`. */
|
|
182
|
+
readonly ttft: boolean;
|
|
165
183
|
}
|
|
166
184
|
|
|
167
185
|
interface SidebarFooterConfig {
|
|
@@ -272,6 +290,12 @@ export interface FlightDeckConfig {
|
|
|
272
290
|
* it needs a tick. `0` turns the ticker off, leaving every row event-driven.
|
|
273
291
|
*/
|
|
274
292
|
readonly refresh: number;
|
|
293
|
+
/**
|
|
294
|
+
* Path to the durable lifetime-totals ledger. Ships as
|
|
295
|
+
* `~/.local/share/opencode/flight-deck/totals.json`; a host config can point
|
|
296
|
+
* it at another file, which is also the test seam.
|
|
297
|
+
*/
|
|
298
|
+
readonly lifetimeTotalsPath: string;
|
|
275
299
|
}
|
|
276
300
|
|
|
277
301
|
/** The millisecond view the rules in ./caution.ts operate on. */
|
|
@@ -464,7 +488,7 @@ export const DEFAULT_SIDEBAR_ROWS: readonly string[] = [
|
|
|
464
488
|
"status",
|
|
465
489
|
"agent",
|
|
466
490
|
"model",
|
|
467
|
-
"
|
|
491
|
+
"spend",
|
|
468
492
|
"project",
|
|
469
493
|
"tokens",
|
|
470
494
|
"cache",
|
|
@@ -510,7 +534,12 @@ export const DEFAULT_CONFIG: FlightDeckConfig = {
|
|
|
510
534
|
lines: DEFAULT_SIDEBAR_LINES,
|
|
511
535
|
footer: { lines: DEFAULT_SIDEBAR_FOOTER_LINES, go: false },
|
|
512
536
|
rows: DEFAULT_SIDEBAR_ROWS,
|
|
513
|
-
tps: {
|
|
537
|
+
tps: {
|
|
538
|
+
scope: DEFAULT_TPS_SCOPE,
|
|
539
|
+
display: DEFAULT_TPS_DISPLAY,
|
|
540
|
+
label: DEFAULT_TPS_LABEL,
|
|
541
|
+
ttft: DEFAULT_TPS_TTFT,
|
|
542
|
+
},
|
|
514
543
|
persist: true,
|
|
515
544
|
placeholder: DEFAULT_PLACEHOLDER,
|
|
516
545
|
maxLines: MAX_LINES,
|
|
@@ -523,6 +552,7 @@ export const DEFAULT_CONFIG: FlightDeckConfig = {
|
|
|
523
552
|
glyphs: DEFAULT_GLYPHS,
|
|
524
553
|
style: DEFAULT_STYLE,
|
|
525
554
|
refresh: DEFAULT_REFRESH_MS,
|
|
555
|
+
lifetimeTotalsPath: defaultLifetimeTotalsPath(),
|
|
526
556
|
};
|
|
527
557
|
|
|
528
558
|
/** Layout guards: keep a hand-edited config from producing an unusable rail. */
|
|
@@ -780,7 +810,20 @@ function readRows(value: unknown, issues: string[], maxLines: number): readonly
|
|
|
780
810
|
issues.push(`${path} is not a known field (${STAT_FIELDS.join(", ")}); skipping it`);
|
|
781
811
|
return;
|
|
782
812
|
}
|
|
783
|
-
|
|
813
|
+
// An alias and its key name one row. Keep the first spelling (so an old
|
|
814
|
+
// config keeps its old label) and report the second rather than drawing
|
|
815
|
+
// the same figure twice.
|
|
816
|
+
const canonical = canonicalField(name);
|
|
817
|
+
const duplicateOf = rows.find((entry) => canonicalField(entry) === canonical);
|
|
818
|
+
if (duplicateOf !== undefined) {
|
|
819
|
+
issues.push(`${path} duplicates ${duplicateOf}; rendering the row once`);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
// `session` keeps folding to `ses`; `cost` and `total` keep their spelling
|
|
823
|
+
// so old configs render byte-for-byte as they did before the rename.
|
|
824
|
+
// The guard above narrows to the canonical union, but the original string
|
|
825
|
+
// may still be an accepted alias; read it as a plain string here.
|
|
826
|
+
rows.push((name as string) === "session" ? "ses" : name);
|
|
784
827
|
});
|
|
785
828
|
|
|
786
829
|
if (rows.length === 0) {
|
|
@@ -818,6 +861,45 @@ function readTpsDisplay(value: unknown, issues: string[]): TpsDisplay {
|
|
|
818
861
|
return DEFAULT_TPS_DISPLAY;
|
|
819
862
|
}
|
|
820
863
|
|
|
864
|
+
/**
|
|
865
|
+
* Whether the `tps` row may draw the observed time to first token.
|
|
866
|
+
*
|
|
867
|
+
* A boolean knob: `false` suppresses the TTFT segment in every display mode,
|
|
868
|
+
* including the realtime fallback row that otherwise appears when no rate can
|
|
869
|
+
* be drawn. A non-boolean falls back to the shipped default and is reported.
|
|
870
|
+
*/
|
|
871
|
+
function readTpsTtft(value: unknown, issues: string[]): boolean {
|
|
872
|
+
return readBoolean(value, DEFAULT_TPS_TTFT, "sidebar.tps.ttft", issues);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/** Longest suffix the single-figure `tps` rows accept before the rail gets silly. */
|
|
876
|
+
const TPS_LABEL_MAX_LENGTH = 16;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* The suffix the single-figure `tps` rows print after the number.
|
|
880
|
+
*
|
|
881
|
+
* A short string, trimmed like the other text values. Blank means no label to
|
|
882
|
+
* draw, so the default comes back and the key is named; a non-string and an
|
|
883
|
+
* overlong value fall back the same way. `display: "both"` ignores it.
|
|
884
|
+
*/
|
|
885
|
+
function readTpsLabel(value: unknown, issues: string[]): string {
|
|
886
|
+
if (value === undefined) return DEFAULT_TPS_LABEL;
|
|
887
|
+
if (typeof value !== "string") {
|
|
888
|
+
issues.push("sidebar.tps.label must be a string; using the default");
|
|
889
|
+
return DEFAULT_TPS_LABEL;
|
|
890
|
+
}
|
|
891
|
+
const text = normalizeText(value, "sidebar.tps.label", issues);
|
|
892
|
+
if (text.length === 0) {
|
|
893
|
+
issues.push("sidebar.tps.label must not be empty; using the default");
|
|
894
|
+
return DEFAULT_TPS_LABEL;
|
|
895
|
+
}
|
|
896
|
+
if (text.length > TPS_LABEL_MAX_LENGTH) {
|
|
897
|
+
issues.push(`sidebar.tps.label was longer than ${TPS_LABEL_MAX_LENGTH} characters; using the default`);
|
|
898
|
+
return DEFAULT_TPS_LABEL;
|
|
899
|
+
}
|
|
900
|
+
return text;
|
|
901
|
+
}
|
|
902
|
+
|
|
821
903
|
/**
|
|
822
904
|
* Which sessions the `tps` row paces.
|
|
823
905
|
*
|
|
@@ -829,10 +911,20 @@ function readTps(section: Record<string, unknown>, issues: string[]): TpsConfig
|
|
|
829
911
|
const raw = section["tps"];
|
|
830
912
|
if (raw !== undefined && !isRecord(raw)) {
|
|
831
913
|
issues.push("sidebar.tps must be an object; using defaults");
|
|
832
|
-
return {
|
|
914
|
+
return {
|
|
915
|
+
scope: DEFAULT_TPS_SCOPE,
|
|
916
|
+
display: DEFAULT_TPS_DISPLAY,
|
|
917
|
+
label: DEFAULT_TPS_LABEL,
|
|
918
|
+
ttft: DEFAULT_TPS_TTFT,
|
|
919
|
+
};
|
|
833
920
|
}
|
|
834
921
|
const tps = isRecord(raw) ? raw : {};
|
|
835
|
-
return {
|
|
922
|
+
return {
|
|
923
|
+
scope: readTpsScope(tps["scope"], issues),
|
|
924
|
+
display: readTpsDisplay(tps["display"], issues),
|
|
925
|
+
label: readTpsLabel(tps["label"], issues),
|
|
926
|
+
ttft: readTpsTtft(tps["ttft"], issues),
|
|
927
|
+
};
|
|
836
928
|
}
|
|
837
929
|
|
|
838
930
|
/**
|
|
@@ -853,6 +945,22 @@ function sectionOf(options: Record<string, unknown>, key: SectionKey): Record<st
|
|
|
853
945
|
return isRecord(value) ? value : {};
|
|
854
946
|
}
|
|
855
947
|
|
|
948
|
+
/**
|
|
949
|
+
* Optional override for the durable lifetime-totals file.
|
|
950
|
+
*
|
|
951
|
+
* A non-empty string is used as given; an absent key leaves the module's
|
|
952
|
+
* shipped path alone. A malformed key is reported and ignored, like every
|
|
953
|
+
* other option.
|
|
954
|
+
*/
|
|
955
|
+
function readLifetimeTotalsPath(value: unknown, issues: string[]): string {
|
|
956
|
+
if (value === undefined) return DEFAULT_CONFIG.lifetimeTotalsPath;
|
|
957
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
958
|
+
issues.push("lifetimeTotalsPath must be a non-empty string; using the default path");
|
|
959
|
+
return DEFAULT_CONFIG.lifetimeTotalsPath;
|
|
960
|
+
}
|
|
961
|
+
return value.trim();
|
|
962
|
+
}
|
|
963
|
+
|
|
856
964
|
/**
|
|
857
965
|
* Read the ticker cadence.
|
|
858
966
|
*
|
|
@@ -1523,6 +1631,7 @@ export function resolveConfig(options: unknown): ConfigResolution {
|
|
|
1523
1631
|
glyphs: readGlyphs(glyphs, issues),
|
|
1524
1632
|
style: readStyle(style, issues),
|
|
1525
1633
|
refresh: readRefresh(options.refresh, issues),
|
|
1634
|
+
lifetimeTotalsPath: readLifetimeTotalsPath(options.lifetimeTotalsPath, issues),
|
|
1526
1635
|
},
|
|
1527
1636
|
issues,
|
|
1528
1637
|
};
|
package/src/tui/go-panel.ts
CHANGED
|
@@ -30,7 +30,9 @@ import { formatRemaining as formatCompactRemaining, goTone, type GoUsage, type G
|
|
|
30
30
|
export { formatRemaining as formatCompactRemaining } from "./go-usage.js";
|
|
31
31
|
import type { RailLine } from "./presentation.js";
|
|
32
32
|
import type { StatSegment } from "./rows.js";
|
|
33
|
-
|
|
33
|
+
// The panel's "no reading" mark is its own, not the sidebar row placeholder:
|
|
34
|
+
// changing `sidebar.placeholder` must never rewrite the Go dials.
|
|
35
|
+
const NO_READING = "\u2014";
|
|
34
36
|
import type { StyleColor } from "./style.js";
|
|
35
37
|
|
|
36
38
|
/** The panel's three windows, in canonical 5h -> 1w -> 1m order. Labels live in the look. */
|
|
@@ -482,7 +484,7 @@ function restingLine(
|
|
|
482
484
|
}
|
|
483
485
|
const tail =
|
|
484
486
|
CELL.repeat(trackCells) +
|
|
485
|
-
(look.showPercent ? ` ${alignCell(
|
|
487
|
+
(look.showPercent ? ` ${alignCell(NO_READING, PANEL_PERCENT_WIDTH, look.align)}` : "");
|
|
486
488
|
segments.push({ text: tail, tone: "subdued" });
|
|
487
489
|
return { field: "go", text: segments.map((segment) => segment.text).join(""), segments };
|
|
488
490
|
}
|
|
@@ -535,7 +537,7 @@ function valueLine(
|
|
|
535
537
|
appendRun(runs, CELL, "subdued");
|
|
536
538
|
}
|
|
537
539
|
if (look.showPercent) {
|
|
538
|
-
const percent = ratio === undefined ?
|
|
540
|
+
const percent = ratio === undefined ? NO_READING : `${Math.round(ratio * 100)}%`;
|
|
539
541
|
// The percent joins the meter's trailing run so a uniform meter stays one
|
|
540
542
|
// span; the countdown is its own dim run (relief, not severity).
|
|
541
543
|
appendRun(runs, ` ${alignCell(percent, PANEL_PERCENT_WIDTH, look.align)}`, tone);
|
package/src/tui/index.tsx
CHANGED
|
@@ -15,13 +15,14 @@ import { loadConfigFile } from "./file-config.js";
|
|
|
15
15
|
import { createGoLookReader } from "./go-look.js";
|
|
16
16
|
import { footerLine, railLineSpans, railLines, railLineStyle, type RailLine } from "./presentation.js";
|
|
17
17
|
import { goPanelLines } from "./go-panel.js";
|
|
18
|
-
import { ANIMATED_FIELDS, type StatSource } from "./stats.js";
|
|
18
|
+
import { ANIMATED_FIELDS, canonicalField, type StatSource } from "./stats.js";
|
|
19
19
|
import { attributeMask, themeColor } from "./style.js";
|
|
20
20
|
import { startGuardBridge } from "./guard.js";
|
|
21
21
|
import { startGoBridge } from "./go.js";
|
|
22
22
|
import { startCodexQuota } from "./codex-quota.js";
|
|
23
23
|
import { startTicker } from "./ticker.js";
|
|
24
24
|
import { asCount, asRecord, type SessionLike } from "./coerce.js";
|
|
25
|
+
import { createLifetimeTotals } from "./lifetime-totals.js";
|
|
25
26
|
import { createProjectTotals } from "./project-totals.js";
|
|
26
27
|
import { createRealtimeTps } from "./realtime-tps.js";
|
|
27
28
|
import { createSessionReads, locationOf } from "./session-reads.js";
|
|
@@ -54,7 +55,12 @@ export default Plugin.define({
|
|
|
54
55
|
// Only the rows actually on the rail are worth deriving: the rail re-runs on
|
|
55
56
|
// every tick, and a figure nobody asked to see should not cost a walk of the
|
|
56
57
|
// session database or the model catalog.
|
|
57
|
-
|
|
58
|
+
// Canonical keys for the "is this row on screen" checks: `cost` and
|
|
59
|
+
// `total` are accepted aliases of `spend` and `lifetime`, and every one of
|
|
60
|
+
// them must ask for the same underlying read.
|
|
61
|
+
const rows = config.sidebar.enabled
|
|
62
|
+
? new Set(config.sidebar.rows.map(canonicalField))
|
|
63
|
+
: new Set<string>();
|
|
58
64
|
const wants = (name: string): boolean => rows.has(name);
|
|
59
65
|
|
|
60
66
|
if (file.issue !== undefined && file.source !== undefined) {
|
|
@@ -175,6 +181,10 @@ export default Plugin.define({
|
|
|
175
181
|
|
|
176
182
|
const { projectTotals } = createProjectTotals(context);
|
|
177
183
|
|
|
184
|
+
// The lifetime figure is a high-water mark, not just the host's current
|
|
185
|
+
// family roll-up. This ledger is the only durable state the rail keeps.
|
|
186
|
+
const lifetimeTotals = createLifetimeTotals({ path: config.lifetimeTotalsPath });
|
|
187
|
+
|
|
178
188
|
const cautionThreshold = cautionThresholds(config.caution);
|
|
179
189
|
|
|
180
190
|
const cautionsOf = (sessionID: string, now: number): Caution[] =>
|
|
@@ -311,10 +321,34 @@ export default Plugin.define({
|
|
|
311
321
|
// roll-up. Neither reads the other's source, so no hand-off can make the
|
|
312
322
|
// lifetime figure inherit a per-model one.
|
|
313
323
|
const wantsUsage =
|
|
314
|
-
wants("
|
|
324
|
+
wants("spend") || wants("lifetime") || wants("tokens") || wants("cache") || wants("reasoning");
|
|
315
325
|
const ownCost = wantsUsage ? sessionCost(sessionID, session as SessionLike | undefined) : undefined;
|
|
316
326
|
const tree = wantsUsage ? treeTotals(sessionID) : undefined;
|
|
317
327
|
|
|
328
|
+
// The lifetime figure is a high-water mark. Resolve the family root the
|
|
329
|
+
// same way treeTotals does, read what earlier ticks recorded, and raise
|
|
330
|
+
// the stored figure when the host currently reports more. Only `lifetime`
|
|
331
|
+
// carries the raised number: `tree` stays the live roll-up so the cost
|
|
332
|
+
// row keeps naming the current model's spend alone.
|
|
333
|
+
let lifetime: { cost: number; count: number; kind: string } | undefined;
|
|
334
|
+
if (wantsUsage) {
|
|
335
|
+
let root = sessionID;
|
|
336
|
+
try {
|
|
337
|
+
root = context.data.session.root(sessionID) ?? sessionID;
|
|
338
|
+
} catch {
|
|
339
|
+
root = sessionID;
|
|
340
|
+
}
|
|
341
|
+
const stored = lifetimeTotals.read(root);
|
|
342
|
+
const live = tree?.cost;
|
|
343
|
+
if (live !== undefined && (stored === undefined || live > stored)) {
|
|
344
|
+
lifetimeTotals.record(root, live);
|
|
345
|
+
}
|
|
346
|
+
const high = Math.max(live ?? 0, stored ?? 0);
|
|
347
|
+
if (live !== undefined || stored !== undefined) {
|
|
348
|
+
lifetime = { cost: high, count: tree?.count ?? 0, kind: tree?.kind ?? "bounded" };
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
318
352
|
return {
|
|
319
353
|
...session,
|
|
320
354
|
cost: ownCost?.cost,
|
|
@@ -323,6 +357,7 @@ export default Plugin.define({
|
|
|
323
357
|
caution: wants("caution") ? announce(sessionID) : undefined,
|
|
324
358
|
branch: wants("branch") ? branchOf(location) : undefined,
|
|
325
359
|
tree,
|
|
360
|
+
lifetime,
|
|
326
361
|
context: wants("context") ? contextUsage(sessionID, session?.model) : undefined,
|
|
327
362
|
project: wants("project") ? projectTotals(sessionID) : undefined,
|
|
328
363
|
status: wants("status") ? statusOf(sessionID) : undefined,
|