oc-flight-deck 0.3.0 → 0.5.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 CHANGED
@@ -59,6 +59,7 @@ learn. The panel appears beside an open session and starts reading.
59
59
  | `reasoning` | Reasoning tokens, when the model emits them. Available, off by default. |
60
60
  | `turns` | How many prompts you have sent this session. Available, off by default. |
61
61
  | `total` | The family total and subagent count on a row of its own. Adding it makes `cost` show the session figure alone. Available, off by default. |
62
+ | `guard` | Harness status from oc-harness-guard. Available, off by default. |
62
63
 
63
64
  `project` matches on the host's **project id**, not on a directory, so a worktree
64
65
  counts as part of the same project. A host that reports no project id leaves
@@ -143,14 +144,41 @@ growing rows as the session produces data.
143
144
  Set `"persist": false` to restore omission: rows with no data are then left out
144
145
  entirely, which is also how a narrow rail stays shortest.
145
146
 
147
+ ### guard pairs with oc-harness-guard
148
+
149
+ The guard row is opt-in: add it to sidebar.rows and the panel polls harness
150
+ status about every ten seconds, plus right away when the rendered session
151
+ changes. It shows the worst signal first, then falls back to ok when every
152
+ source reports available and quiet. A source that reports unavailable reads as
153
+ unknown, and no data renders the placeholder like any other row.
154
+
155
+ It only appears when oc-harness-guard is installed and answering. Without it
156
+ the row stays on the placeholder, and the panel never installs or requires the
157
+ other plugin. Each side works alone.
158
+
146
159
  ## Configuration
147
160
 
148
161
  **You don't need any.** Install it and the panel works. But every knob is
149
162
  available in a commented JSONC file.
150
163
 
151
164
  Copy [`flight-deck.example.jsonc`](./flight-deck.example.jsonc) to
152
- `flight-deck.jsonc` at your project root, or to `.opencode/flight-deck.jsonc`,
153
- then edit. Comments and trailing commas are fine.
165
+ `~/.config/opencode/flight-deck.jsonc`, then edit. Comments and trailing commas
166
+ are fine.
167
+
168
+ There is **one** config file, global to your user, so the same values apply to
169
+ every project. Flight Deck does not read a `flight-deck.jsonc` from a project
170
+ root or from a project's `.opencode/` directory — a copy left there configures
171
+ nothing. If `$XDG_CONFIG_HOME` is set, the path is
172
+ `$XDG_CONFIG_HOME/opencode/flight-deck.jsonc` instead. A `.json` name works too;
173
+ the `.jsonc` name is tried first.
174
+
175
+ The file is optional, and a missing file is normal and silent: with no file at
176
+ all you get exactly the defaults written out below.
177
+
178
+ > **Upgrading from 0.4.0 — the config file moved.** The per-project search is
179
+ > gone. A `flight-deck.jsonc` in a project root or in `.opencode/` is no longer
180
+ > read; move it to `~/.config/opencode/flight-deck.jsonc` (or the
181
+ > `$XDG_CONFIG_HOME` path above) to keep your settings.
154
182
 
155
183
  ```jsonc
156
184
  {
@@ -198,15 +226,17 @@ toast naming the key to fix.
198
226
 
199
227
  Flight Deck shows what OpenCode already knows.
200
228
 
201
- - **No network calls.** Nothing is fetched, nothing is sent.
229
+ - **No network calls while the opt-in `guard` row stays off.** Nothing is fetched, nothing is sent. When the `guard` row is enabled, the panel polls the local guard RPC (same machine, no telemetry) about every ten seconds, plus right away on session change.
202
230
  - **No telemetry.** Nothing is collected or phoned home.
203
231
  - **Nothing on disk.** The one thing it writes is an animation counter in the
204
232
  host's in-memory plugin state, so the spinner and `elapsed` keep moving
205
233
  between turns. It is scoped to this plugin and dies with the TUI; it is never
206
234
  persisted, and `"refresh": 0` removes even that.
207
- - **No polling of your session** — cost, tokens, and permissions update from the
235
+ - **No polling of your session while the opt-in `guard` row stays off** — cost, tokens, and permissions update from the
208
236
  host's own events. The timer only re-reads state the host already holds in
209
- memory, and only so the clock-derived rows keep moving.
237
+ memory, and only so the clock-derived rows keep moving. When the `guard` row
238
+ is enabled, the panel additionally polls the local guard RPC on its own
239
+ ten-second cadence.
210
240
  - **Theme-native.** Every line uses your active theme's text tokens, so it blends
211
241
  with whatever look you already run.
212
242
 
@@ -215,7 +245,7 @@ Delete the plugin and the stock sidebar is back, exactly as it was.
215
245
  ## Uninstall
216
246
 
217
247
  Remove the entry from `opencode.jsonc`, restart, done. Delete your
218
- `flight-deck.jsonc` too if you made one.
248
+ `~/.config/opencode/flight-deck.jsonc` too if you made one.
219
249
 
220
250
  ## Development
221
251
 
@@ -9,12 +9,22 @@
9
9
  // you can see exactly what there is to change. Delete any key and its
10
10
  // default comes straight back.
11
11
  //
12
- // TO USE IT: copy this file to `flight-deck.jsonc` at your project root, or
13
- // to `.opencode/flight-deck.jsonc`. Comments and trailing commas are fine.
12
+ // TO USE IT: copy this file to `~/.config/opencode/flight-deck.jsonc` (or
13
+ // `flight-deck.json` — the `.jsonc` name is tried first), then edit. Comments
14
+ // and trailing commas are fine.
14
15
  //
15
- // Flight Deck looks in this order and uses the first file it finds:
16
- // .opencode/flight-deck.jsonc .opencode/flight-deck.json
17
- // flight-deck.jsonc flight-deck.json
16
+ // There is ONE config file, global to your user, so the same values apply to
17
+ // every project. Flight Deck does NOT look in a project root or in a
18
+ // project's `.opencode/` directory: a copy left there configures nothing.
19
+ //
20
+ // If `$XDG_CONFIG_HOME` is set, the path is
21
+ // `$XDG_CONFIG_HOME/opencode/flight-deck.jsonc` instead.
22
+ //
23
+ // The file is optional. Having none is the normal case, and it is silent —
24
+ // the defaults below are what you get.
25
+ //
26
+ // Upgrading from 0.4.0? A `flight-deck.jsonc` in a project root or in
27
+ // `.opencode/` is no longer read; move it to the global path above.
18
28
  //
19
29
  // The same values can also be passed as plugin options in opencode.jsonc /
20
30
  // cli.json, which take precedence on hosts that forward them.
@@ -72,6 +82,8 @@
72
82
  // spark recent turn sizes as a sparkline
73
83
  // reasoning reasoning tokens, when the model emits them
74
84
  // turns how many prompts you have sent this session
85
+ // guard harness status from oc-harness-guard: breaches, orphans,
86
+ // findings, or ok. Available, off by default.
75
87
  //
76
88
  // Every named row renders persistently, so the rail keeps a stable shape:
77
89
  // a row with no data yet shows the placeholder below, in the same label
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://github.com/nathwn12/oc-flight-deck/flight-deck.schema.json",
4
4
  "title": "Flight Deck configuration",
5
- "description": "Configuration for the oc-flight-deck TUI plugin. Every key is optional: install the plugin and it works with no config file at all. Copy flight-deck.example.jsonc to flight-deck.jsonc (or .opencode/flight-deck.jsonc) and edit. Comments and trailing commas are allowed. An invalid value is ignored, its default is restored, and a one-time toast names the key to fix — a typo can never break the TUI.",
5
+ "description": "Configuration for the oc-flight-deck TUI plugin. Every key is optional: install the plugin and it works with no config file at all — a missing file is normal and silent. Copy flight-deck.example.jsonc to the one global path, ~/.config/opencode/flight-deck.jsonc ($XDG_CONFIG_HOME/opencode/flight-deck.jsonc when XDG_CONFIG_HOME is set), and edit; that single file applies to every project. There is no per-project lookup: a flight-deck.jsonc in a project root or in .opencode/ is not read. Comments and trailing commas are allowed. An invalid value is ignored, its default is restored, and a one-time toast names the key to fix — a typo can never break the TUI.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "properties": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "rows": {
40
40
  "type": "array",
41
- "items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns"] },
41
+ "items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard"] },
42
42
  "default": ["caution", "status", "agent", "model", "branch", "cost", "project", "tokens", "cache", "context", "perms", "elapsed", "tps"],
43
43
  "maxItems": 24,
44
44
  "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, using `sidebar.placeholder` until the host has data; with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail."
package/package.json CHANGED
@@ -1,70 +1,70 @@
1
- {
2
- "name": "oc-flight-deck",
3
- "version": "0.3.0",
4
- "description": "Live OpenCode V2 session telemetry — agent, model, branch, cost, tokens, cache hit rate and context usage in your sidebar.",
5
- "keywords": [
6
- "opencode",
7
- "opencode-plugin",
8
- "opencode-tui",
9
- "tui",
10
- "cli",
11
- "sidebar",
12
- "telemetry",
13
- "cost"
14
- ],
15
- "license": "MIT",
16
- "author": "nathwn12",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/nathwn12/oc-flight-deck.git"
20
- },
21
- "homepage": "https://github.com/nathwn12/oc-flight-deck#readme",
22
- "bugs": {
23
- "url": "https://github.com/nathwn12/oc-flight-deck/issues"
24
- },
25
- "type": "module",
26
- "exports": {
27
- ".": {
28
- "types": "./src/index.ts",
29
- "import": "./src/index.ts"
30
- },
31
- "./tui": {
32
- "types": "./src/tui/index.tsx",
33
- "import": "./src/tui/index.tsx"
34
- }
35
- },
36
- "files": [
37
- "src",
38
- "flight-deck.example.jsonc",
39
- "flight-deck.schema.json",
40
- "README.md",
41
- "LICENSE"
42
- ],
43
- "engines": {
44
- "node": ">=22",
45
- "bun": ">=1.4.0"
46
- },
47
- "scripts": {
48
- "typecheck": "tsc --noEmit",
49
- "test": "bun test",
50
- "check": "bun run typecheck && bun test"
51
- },
52
- "publishConfig": {
53
- "access": "public"
54
- },
55
- "dependencies": {
56
- "@opencode/plugin": "2.0.2"
57
- },
58
- "devDependencies": {
59
- "@opentui/core": "0.5.10",
60
- "@opentui/solid": "0.5.10",
61
- "@types/bun": "^1.4.2",
62
- "solid-js": "1.9.12",
63
- "typescript": "^5.9.0"
64
- },
65
- "peerDependencies": {
66
- "@opentui/core": ">=0.5.10",
67
- "@opentui/solid": ">=0.5.10",
68
- "solid-js": ">=1.9.0"
69
- }
70
- }
1
+ {
2
+ "name": "oc-flight-deck",
3
+ "version": "0.5.0",
4
+ "description": "Live OpenCode V2 session telemetry — agent, model, branch, cost, tokens, cache hit rate and context usage in your sidebar.",
5
+ "keywords": [
6
+ "opencode",
7
+ "opencode-plugin",
8
+ "opencode-tui",
9
+ "tui",
10
+ "cli",
11
+ "sidebar",
12
+ "telemetry",
13
+ "cost"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "nathwn12",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/nathwn12/oc-flight-deck.git"
20
+ },
21
+ "homepage": "https://github.com/nathwn12/oc-flight-deck#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/nathwn12/oc-flight-deck/issues"
24
+ },
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./src/index.ts",
29
+ "import": "./src/index.ts"
30
+ },
31
+ "./tui": {
32
+ "types": "./src/tui/index.tsx",
33
+ "import": "./src/tui/index.tsx"
34
+ }
35
+ },
36
+ "files": [
37
+ "src",
38
+ "flight-deck.example.jsonc",
39
+ "flight-deck.schema.json",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "engines": {
44
+ "node": ">=22",
45
+ "bun": ">=1.4.0"
46
+ },
47
+ "scripts": {
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "bun test",
50
+ "check": "bun run typecheck && bun test"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "dependencies": {
56
+ "@opencode/plugin": "2.0.2"
57
+ },
58
+ "devDependencies": {
59
+ "@opentui/core": "0.5.10",
60
+ "@opentui/solid": "0.5.10",
61
+ "@types/bun": "^1.4.2",
62
+ "solid-js": "1.9.12",
63
+ "typescript": "^5.9.0"
64
+ },
65
+ "peerDependencies": {
66
+ "@opentui/core": ">=0.5.10",
67
+ "@opentui/solid": ">=0.5.10",
68
+ "solid-js": ">=1.9.0"
69
+ }
70
+ }
@@ -2,19 +2,35 @@
2
2
  //
3
3
  // The host's `context.options` is the official configuration channel, but not
4
4
  // every host build forwards it (and `cli.json` may not allow comments). So the
5
- // plugin also reads a small JSONC file from the project, which guarantees
6
- // inline comments work everywhere. `context.options` still wins when present.
5
+ // plugin also reads a small global JSONC file, which guarantees inline comments
6
+ // work everywhere. `context.options` still wins when present.
7
+ //
8
+ // There is exactly one config file, in the user's config directory. There is no
9
+ // per-project channel: what the rail shows cannot change with the directory the
10
+ // host happens to open.
7
11
 
8
12
  import { existsSync, readFileSync, statSync } from "node:fs";
9
- import { join } from "node:path";
13
+ import { homedir } from "node:os";
14
+ import { isAbsolute, join } from "node:path";
10
15
 
11
- /** Searched in order, relative to the project directory; first hit wins. */
12
- export const CONFIG_FILE_CANDIDATES: readonly string[] = [
13
- join(".opencode", "flight-deck.jsonc"),
14
- join(".opencode", "flight-deck.json"),
15
- "flight-deck.jsonc",
16
- "flight-deck.json",
17
- ];
16
+ /**
17
+ * Searched in order inside `globalConfigDirectory()`; first hit wins. Both
18
+ * candidates live in the same directory — one file configures every session.
19
+ */
20
+ export const CONFIG_FILE_CANDIDATES: readonly string[] = ["flight-deck.jsonc", "flight-deck.json"];
21
+
22
+ /**
23
+ * The one directory Flight Deck reads its config from: `$XDG_CONFIG_HOME/opencode`
24
+ * when that variable holds an absolute path, else `~/.config/opencode`. A
25
+ * relative value is ignored, as the XDG base directory spec requires — otherwise
26
+ * the lookup would resolve against the host's working directory.
27
+ */
28
+ export function globalConfigDirectory(): string {
29
+ const xdg = process.env["XDG_CONFIG_HOME"]?.trim();
30
+ return xdg !== undefined && xdg.length > 0 && isAbsolute(xdg)
31
+ ? join(xdg, "opencode")
32
+ : join(homedir(), ".config", "opencode");
33
+ }
18
34
 
19
35
  /** Refuse to pull an unreasonable file into the TUI at startup. */
20
36
  const MAX_CONFIG_BYTES = 64 * 1024;
@@ -28,7 +44,11 @@ export interface FileConfig {
28
44
  readonly issue?: string;
29
45
  }
30
46
 
31
- export function findConfigFile(directory: string): string | undefined {
47
+ /**
48
+ * Find the first config file that exists in `directory`, which defaults to the
49
+ * global config directory. A missing directory simply has no candidates.
50
+ */
51
+ export function findConfigFile(directory: string = globalConfigDirectory()): string | undefined {
32
52
  for (const candidate of CONFIG_FILE_CANDIDATES) {
33
53
  const path = join(directory, candidate);
34
54
  if (existsSync(path)) return path;
@@ -45,13 +65,15 @@ export function parseJsonc(text: string): unknown {
45
65
  }
46
66
 
47
67
  /**
48
- * Load the first config file that exists under `directory`.
68
+ * Load the first config file that exists in `directory`, which defaults to the
69
+ * global config directory (`$XDG_CONFIG_HOME/opencode`, else `~/.config/opencode`).
70
+ * There is no per-project lookup.
49
71
  *
50
72
  * A missing file is normal and silent. A present-but-broken file is reported in
51
73
  * `issue` so the caller can warn once, and then behaves as if it were absent.
52
74
  * Only regular files under the size cap are read.
53
75
  */
54
- export function loadConfigFile(directory: string): FileConfig {
76
+ export function loadConfigFile(directory: string = globalConfigDirectory()): FileConfig {
55
77
  const source = findConfigFile(directory);
56
78
  if (source === undefined) return { options: undefined };
57
79