oc-flight-deck 0.4.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 +18 -3
- package/flight-deck.example.jsonc +15 -5
- package/flight-deck.schema.json +1 -1
- package/package.json +70 -70
- package/src/tui/file-config.ts +35 -13
- package/src/tui/index.tsx +515 -515
- package/src/tui/presentation.ts +34 -34
package/README.md
CHANGED
|
@@ -162,8 +162,23 @@ other plugin. Each side works alone.
|
|
|
162
162
|
available in a commented JSONC file.
|
|
163
163
|
|
|
164
164
|
Copy [`flight-deck.example.jsonc`](./flight-deck.example.jsonc) to
|
|
165
|
-
|
|
166
|
-
|
|
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.
|
|
167
182
|
|
|
168
183
|
```jsonc
|
|
169
184
|
{
|
|
@@ -230,7 +245,7 @@ Delete the plugin and the stock sidebar is back, exactly as it was.
|
|
|
230
245
|
## Uninstall
|
|
231
246
|
|
|
232
247
|
Remove the entry from `opencode.jsonc`, restart, done. Delete your
|
|
233
|
-
|
|
248
|
+
`~/.config/opencode/flight-deck.jsonc` too if you made one.
|
|
234
249
|
|
|
235
250
|
## Development
|
|
236
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
|
|
13
|
-
//
|
|
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
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
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.
|
package/flight-deck.schema.json
CHANGED
|
@@ -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 (
|
|
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": {
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "oc-flight-deck",
|
|
3
|
-
"version": "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
|
+
}
|
package/src/tui/file-config.ts
CHANGED
|
@@ -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
|
|
6
|
-
//
|
|
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 {
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { isAbsolute, join } from "node:path";
|
|
10
15
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|