@cesarus777/opencode-cgp 0.3.0 → 0.3.1

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 — 2026-10-29
4
+
5
+ - Install the standalone dashboard's pinned OpenTUI renderer automatically with CGP, including its native platform library. Keep renderer loading lazy so server and offline commands still work on Bun >=1.1.34; the dashboard requires Bun >=1.3.0.
6
+ - Clarify CLI launch instructions and add command-specific help with examples.
7
+
3
8
  ## 0.3.0 — 2026-10-28
4
9
 
5
10
  Changes since 0.2.5:
package/README.md CHANGED
@@ -41,10 +41,10 @@ Global configuration is `~/.config/opencode/opencode.jsonc` (or the OpenCode con
41
41
 
42
42
  Restart/reload OpenCode and look for `context-guard: observe; diagnostics ...`. Observe mode records policy decisions and never requests compaction; OpenCode's own automatic compaction remains active. Inspect diagnostics first, then set `mode` to `enforce` to admit native compaction at runtime step boundaries. The complete [example](examples/opencode.jsonc) includes model, role, and agent policies. **Last matching rule wins**; selectors within a rule are ANDed.
43
43
 
44
- Pin the exact published version in the existing entry's `package` field or use the manager. Version `0.3.0` adds a standalone terminal dashboard, offline model analytics across retained sessions, and context charts that preserve bar height and reuse the latest column during pauses. See the [changelog](CHANGELOG.md).
44
+ Pin the exact published version in the existing entry's `package` field or use the manager. Version `0.3.1` installs the standalone dashboard renderer automatically and adds clearer command help. Version `0.3.0` introduced the standalone dashboard, offline model analytics and paused context chart fixes. See the [changelog](CHANGELOG.md).
45
45
 
46
46
  ```sh
47
- opencode plugin add @cesarus777/opencode-cgp@0.3.0
47
+ opencode plugin add @cesarus777/opencode-cgp@0.3.1
48
48
  ```
49
49
 
50
50
  Manage the configured target with the [official V2 CLI](https://dev.opencode.ai/v2/docs/plugins):
@@ -82,9 +82,32 @@ Use `{"plugins":[{"package":"/absolute/path/to/opencode-cgp","options":{"mode":"
82
82
 
83
83
  If loading fails, run `opencode plugin list` and `opencode plugin check`, confirm V2 2.0.29 and the correct configuration scope, and inspect OpenCode's startup logs. A missing `@opencode/plugin` or client module indicates an incomplete package installation: remove/re-add the configured package using the manager. TUI-only missing `solid-js`/OpenTUI modules usually indicate an unsupported host or loading the TUI outside its host runtime. These optional peers are supplied by the native TUI and must share its runtime instances; do not bundle private renderer copies. Standalone renderer tests need the pinned peers and public runtime preload described in [testing](docs/testing.md). Never reset persisted safety state merely to fix loading. For remote clients, check both client installation and server registration in the session's owning location.
84
84
 
85
+ ## Run after installation
86
+
87
+ From your project directory, start OpenCode:
88
+
89
+ ```sh
90
+ opencode
91
+ ```
92
+
93
+ Inside OpenCode, enter `/context-guard` to open the Context Guard panel. The plugin loads automatically with OpenCode after registration; there is no separate plugin process to start. Observe mode is the default. Press **c** in the panel for history charts, or **q** to close it.
94
+
95
+ The installed diagnostic command is **`context-guard`** (Bun required):
96
+
97
+ ```sh
98
+ context-guard --help
99
+ context-guard dashboard tui --help
100
+ context-guard models --help
101
+ context-guard metrics --help
102
+ context-guard charts --help
103
+ context-guard help journal
104
+ ```
105
+
106
+ Each command's help explains its inputs and shows an example. In a source checkout, use `bun run inspect` in place of `context-guard`, for example `bun run inspect charts --help`. OpenCode's plugin manager installs the plugin for the host; if `context-guard` is absent from your shell's PATH, you can still use the native panel. To expose the CLI separately, install the same package with your package manager, for example `npm install -g @cesarus777/opencode-cgp@0.3.1`.
107
+
85
108
  ## Standalone terminal dashboard
86
109
 
87
- Run the dashboard with OpenCode's native TUI closed. The server must already be running, with Context Guard registered in the owning location. The standalone command requires **Bun >=1.3.0** and the optional **`@opentui/core@0.5.17`** peer; server imports and existing diagnostic commands retain Bun >=1.1.34 support. Solid and the native TUI plugin are unnecessary for this command.
110
+ Run the dashboard with OpenCode's native TUI closed. The server must already be running, with Context Guard registered in the owning location. The standalone command requires **Bun >=1.3.0**. The package automatically installs **`@opentui/core@0.5.17`** and its platform renderer; no separate OpenTUI install is needed. Keep optional dependencies enabled so OpenTUI's native platform library is installed. Server imports and existing diagnostic commands retain Bun >=1.1.34 support. Solid and the native TUI plugin are unnecessary for this command.
88
111
 
89
112
  For an unreleased checkout:
90
113
 
@@ -95,10 +118,10 @@ bun dist/cli.js dashboard tui
95
118
  bun dist/cli.js dashboard tui --server https://server.example --directory /server/project
96
119
  ```
97
120
 
98
- For a packed artifact, install the tarball and renderer together into a separate client directory, then launch with Bun >=1.3.0:
121
+ For a packed artifact, install the tarball into a separate client directory, then launch with Bun >=1.3.0:
99
122
 
100
123
  ```sh
101
- npm install /absolute/path/cesarus777-opencode-cgp-0.3.0.tgz @opentui/core@0.5.17
124
+ npm install /absolute/path/cesarus777-opencode-cgp-0.3.1.tgz
102
125
  bun node_modules/.bin/context-guard dashboard tui
103
126
  ```
104
127
 
package/dist/cli.js CHANGED
@@ -663,19 +663,40 @@ async function loadTerminalRenderer() {
663
663
  try {
664
664
  return await import("@opentui/core");
665
665
  } catch {
666
- throw new Error("Terminal renderer unavailable; install @opentui/core@0.5.17 beside @cesarus777/opencode-cgp using Bun >=1.3.0");
667
- }
668
- }
669
- var dashboardHelp = `Usage: context-guard dashboard tui [--server URL] [--directory PATH]
670
- Read-only standalone terminal dashboard; never starts an OpenCode server.
671
- Requires an interactive terminal, Bun >=1.3.0 and @opentui/core@0.5.17.
672
- Install the renderer beside this package: npm install @opentui/core@0.5.17
673
- Local discovery defaults to the current directory.
674
- An explicit server requires --directory with an owning absolute server path.
675
- Remote authentication: CONTEXT_GUARD_PASSWORD and optional CONTEXT_GUARD_USERNAME
676
- (default opencode). Credentials must never be supplied in the URL.
677
- Keys: 1 overview, 2 detail, 3 history, arrows/j/k move, / search, f filters,
678
- l location, w history window, r refresh, ? help, Escape back, q/Ctrl+C quit.`;
666
+ throw new Error("Terminal renderer unavailable; reinstall @cesarus777/opencode-cgp with optional dependencies enabled for its platform renderer, using Bun >=1.3.0");
667
+ }
668
+ }
669
+ var dashboardHelp = `Usage: context-guard dashboard tui [options]
670
+ Open a read-only live terminal dashboard for an existing OpenCode server.
671
+
672
+ Start here
673
+ 1. Keep an OpenCode server running with Context Guard registered.
674
+ 2. Close OpenCode's native TUI before opening the standalone dashboard.
675
+ 3. In the owning project directory, run: context-guard dashboard tui
676
+
677
+ Options
678
+ --directory PATH Owning project directory (local default: current directory)
679
+ --server URL Connect to an explicit server; requires --directory with
680
+ an absolute server-side project path. Use HTTPS except
681
+ on loopback. Credentials in URLs are rejected.
682
+ -h, --help Show this help
683
+
684
+ Examples
685
+ context-guard dashboard tui
686
+ context-guard dashboard tui --directory /absolute/project
687
+ context-guard dashboard tui --server https://server.example --directory /server/project
688
+
689
+ Requirements
690
+ Interactive terminal and Bun >=1.3.0. The OpenTUI renderer is installed
691
+ automatically with CGP. This command never starts a server.
692
+
693
+ Authentication (explicit servers)
694
+ CONTEXT_GUARD_PASSWORD Server password
695
+ CONTEXT_GUARD_USERNAME Server username (default: opencode)
696
+
697
+ Keys
698
+ 1/2/3 overview/detail/history; arrows or j/k move; / search; f filters;
699
+ l location; w history window; r refresh; ? help; q or Ctrl+C quit.`;
679
700
  var init_command = () => {
680
701
  };
681
702
 
@@ -2793,7 +2814,7 @@ import { isAbsolute as isAbsolute4, resolve as resolve2 } from "path";
2793
2814
  async function inspectModels(args) {
2794
2815
  const directory = args[0];
2795
2816
  if (!directory || !isAbsolute4(directory))
2796
- throw new Error("Usage: inspect models /absolute/history-directory [--model ID] [--agent NAME] [--from ISO-or-ms] [--to ISO-or-ms] [--csv | --json]");
2817
+ throw new Error("Use context-guard models --help for usage and examples; the history directory must be an absolute path");
2797
2818
  const values = new Map;
2798
2819
  let csv = false, json = false;
2799
2820
  for (let i = 1;i < args.length; i++) {
@@ -3592,9 +3613,124 @@ async function readJournal(path, maxBytes = 16 * 1024 * 1024) {
3592
3613
  return records;
3593
3614
  }
3594
3615
 
3616
+ // src/clihelp.ts
3617
+ var mainHelp = `Context Guard \u2014 context monitoring for OpenCode V2
3618
+
3619
+ Start here
3620
+ In your project, run: opencode
3621
+ Inside OpenCode, enter: /context-guard
3622
+ The plugin loads with OpenCode; observe mode is the default.
3623
+
3624
+ Usage: context-guard <command> [options]
3625
+ context-guard <journal.jsonl> [--history | --json]
3626
+
3627
+ Commands
3628
+ dashboard tui Open the standalone live terminal dashboard
3629
+ models Compare models across retained history
3630
+ metrics Export retained performance records as JSON or CSV
3631
+ charts Generate an interactive HTML report
3632
+ <journal.jsonl> Inspect diagnostic session records
3633
+
3634
+ Examples
3635
+ context-guard dashboard tui
3636
+ context-guard models /absolute/history-directory
3637
+ context-guard charts /absolute/history-directory --output report.html
3638
+ context-guard /absolute/events.jsonl --history
3639
+
3640
+ Help
3641
+ context-guard <command> --help Show options and examples
3642
+ context-guard help journal Explain diagnostic inspection
3643
+ -h, --help Show help
3644
+
3645
+ Requires Bun >=1.1.34; the standalone dashboard requires Bun >=1.3.0.
3646
+ From a source checkout, replace context-guard with bun run inspect.`;
3647
+ var filterOptions = ` --agent NAME Filter by exact agent name
3648
+ --model PROVIDER/MODEL
3649
+ Filter by exact model ID
3650
+ --from ISO-or-ms Start time: ISO timestamp or Unix milliseconds
3651
+ --to ISO-or-ms End time: ISO timestamp or Unix milliseconds`;
3652
+ var historyOptions = ` --session ID Filter by session
3653
+ ${filterOptions}`;
3654
+ var historyPath = `Use the owning location's history.path directory, not its diagnostic JSONL
3655
+ file. By default it is a location-hashed directory under
3656
+ \$XDG_STATE_HOME/opencode-context-guard (or ~/.local/state/opencode-context-guard).
3657
+ A custom telemetry.path does not change the history directory.`;
3658
+ var commandHelp = {
3659
+ models: `Usage: context-guard models <history-directory> [options]
3660
+ Compare model throughput and time to first token across retained sessions.
3661
+ The history directory must be an absolute path. Output defaults to JSON.
3662
+
3663
+ Options
3664
+ ${filterOptions}
3665
+ --csv Export CSV; coverage metadata goes to stderr
3666
+ --json Export JSON (default); cannot combine with --csv
3667
+ -h, --help Show this help
3668
+
3669
+ Example
3670
+ context-guard models /absolute/history-directory --agent build --csv
3671
+
3672
+ ${historyPath}`,
3673
+ metrics: `Usage: context-guard metrics <history-directory> [options]
3674
+ Read retained performance records. Output defaults to JSON.
3675
+
3676
+ Options
3677
+ ${historyOptions}
3678
+ --csv Export CSV; coverage metadata goes to stderr
3679
+ --chart FILE.html Generate an HTML report instead (see charts --help)
3680
+ -h, --help Show this help
3681
+
3682
+ Example
3683
+ context-guard metrics /absolute/history-directory --csv > metrics.csv
3684
+
3685
+ ${historyPath}`,
3686
+ charts: `Usage: context-guard charts <history-directory> [options]
3687
+ Generate a self-contained interactive HTML report, then open it in a browser.
3688
+
3689
+ Options
3690
+ ${historyOptions}
3691
+ --output FILE.html Write the report (default: context-guard-charts.html)
3692
+ --max-points N Points per series: 16\u20135000 (default: 1000)
3693
+ --max-sessions N Session instances: 1\u20131024 (default: 128)
3694
+ --force Overwrite an existing report
3695
+ -h, --help Show this help
3696
+
3697
+ Example
3698
+ context-guard charts /absolute/history-directory --output report.html
3699
+
3700
+ ${historyPath}`,
3701
+ journal: `Usage: context-guard <journal.jsonl> [options]
3702
+ Inspect the diagnostic journal reported in OpenCode's Context Guard startup log.
3703
+ By default, print the latest retained record for each session, one JSON per line.
3704
+
3705
+ Options
3706
+ --json Print latest session records as a JSON array
3707
+ --history Print all retained journal records as a JSON array
3708
+ -h, --help Show this help
3709
+
3710
+ Example
3711
+ context-guard /absolute/path/from/startup.jsonl --history
3712
+
3713
+ This reads a diagnostic file, not a performance history directory.`
3714
+ };
3715
+
3595
3716
  // src/cli.ts
3596
3717
  var args = process.argv.slice(2);
3597
- if (args[0] === "dashboard") {
3718
+ var helpRequested = args.some((arg) => arg === "--help" || arg === "-h");
3719
+ var helpTopic = args[0] === "help" ? args[1] : args[0];
3720
+ if (!args[0] || args[0] === "help" || helpRequested || args.length === 1 && (args[0] === "dashboard" || Object.hasOwn(commandHelp, args[0]))) {
3721
+ if (helpTopic === "dashboard") {
3722
+ const { dashboardHelp: dashboardHelp2 } = await Promise.resolve().then(() => (init_command(), exports_command));
3723
+ console.log(dashboardHelp2);
3724
+ } else if (helpTopic && Object.hasOwn(commandHelp, helpTopic)) {
3725
+ console.log(commandHelp[helpTopic]);
3726
+ } else if (args[0] === "help" && helpTopic) {
3727
+ console.error(`Unknown help topic. Use context-guard --help for commands.`);
3728
+ process.exitCode = 1;
3729
+ } else if (helpRequested && helpTopic && !helpTopic.startsWith("-")) {
3730
+ console.log(commandHelp.journal);
3731
+ } else
3732
+ console.log(mainHelp);
3733
+ } else if (args[0] === "dashboard") {
3598
3734
  const { parseDashboardArgs: parseDashboardArgs2, dashboardHelp: dashboardHelp2, checkTerminalRuntime: checkTerminalRuntime2 } = await Promise.resolve().then(() => (init_command(), exports_command));
3599
3735
  try {
3600
3736
  const options = parseDashboardArgs2(args.slice(1), process.cwd(), process.env);
@@ -3611,15 +3747,13 @@ if (args[0] === "dashboard") {
3611
3747
  console.error(safe ? message : "Dashboard startup failed; check server, owning directory, authentication and renderer installation");
3612
3748
  process.exitCode = 1;
3613
3749
  }
3614
- } else if (!args[0] || args.includes("--help")) {
3615
- console.log("Usage: bun run inspect /absolute/path/to/journal.jsonl [--history] [--json]\nThe ready log reports the location-specific journal path.\nMetrics: inspect metrics /absolute/history-directory [--session ID] [--from ISO-or-ms] [--to ISO-or-ms] [--csv]\nModels: inspect models /absolute/history-directory [--model provider/model] [--agent NAME] [--from ISO-or-ms] [--to ISO-or-ms] [--csv | --json]\nCharts: inspect charts /absolute/history-directory --output report.html [--session ID] [--agent NAME] [--model provider/model] [--from ISO-or-ms] [--to ISO-or-ms] [--max-points 1000] [--force]");
3616
3750
  } else if (args[0] === "models") {
3617
3751
  const { inspectModels: inspectModels2 } = await Promise.resolve().then(() => (init_modelcli(), exports_modelcli));
3618
3752
  await inspectModels2(args.slice(1));
3619
3753
  } else if (args[0] === "metrics" || args[0] === "charts") {
3620
3754
  const directory = args[1];
3621
3755
  if (!directory || directory.startsWith("--"))
3622
- throw new Error("Usage: inspect metrics /absolute/history-directory [--session ID] [--from ISO-or-ms] [--to ISO-or-ms] [--csv]");
3756
+ throw new Error(`Use context-guard ${args[0]} --help for usage and examples`);
3623
3757
  const option = (name) => {
3624
3758
  const index = args.indexOf(name);
3625
3759
  if (index < 0)
@@ -0,0 +1,2 @@
1
+ export declare const mainHelp = "Context Guard \u2014 context monitoring for OpenCode V2\n\nStart here\n In your project, run: opencode\n Inside OpenCode, enter: /context-guard\n The plugin loads with OpenCode; observe mode is the default.\n\nUsage: context-guard <command> [options]\n context-guard <journal.jsonl> [--history | --json]\n\nCommands\n dashboard tui Open the standalone live terminal dashboard\n models Compare models across retained history\n metrics Export retained performance records as JSON or CSV\n charts Generate an interactive HTML report\n <journal.jsonl> Inspect diagnostic session records\n\nExamples\n context-guard dashboard tui\n context-guard models /absolute/history-directory\n context-guard charts /absolute/history-directory --output report.html\n context-guard /absolute/events.jsonl --history\n\nHelp\n context-guard <command> --help Show options and examples\n context-guard help journal Explain diagnostic inspection\n -h, --help Show help\n\nRequires Bun >=1.1.34; the standalone dashboard requires Bun >=1.3.0.\nFrom a source checkout, replace context-guard with bun run inspect.";
2
+ export declare const commandHelp: Readonly<Record<string, string>>;
@@ -1,5 +1,5 @@
1
1
  import type { DashboardConnectionOptions } from "./connection.js";
2
- export declare const dashboardHelp = "Usage: context-guard dashboard tui [--server URL] [--directory PATH]\nRead-only standalone terminal dashboard; never starts an OpenCode server.\nRequires an interactive terminal, Bun >=1.3.0 and @opentui/core@0.5.17.\nInstall the renderer beside this package: npm install @opentui/core@0.5.17\nLocal discovery defaults to the current directory.\nAn explicit server requires --directory with an owning absolute server path.\nRemote authentication: CONTEXT_GUARD_PASSWORD and optional CONTEXT_GUARD_USERNAME\n(default opencode). Credentials must never be supplied in the URL.\nKeys: 1 overview, 2 detail, 3 history, arrows/j/k move, / search, f filters,\nl location, w history window, r refresh, ? help, Escape back, q/Ctrl+C quit.";
2
+ export declare const dashboardHelp = "Usage: context-guard dashboard tui [options]\nOpen a read-only live terminal dashboard for an existing OpenCode server.\n\nStart here\n 1. Keep an OpenCode server running with Context Guard registered.\n 2. Close OpenCode's native TUI before opening the standalone dashboard.\n 3. In the owning project directory, run: context-guard dashboard tui\n\nOptions\n --directory PATH Owning project directory (local default: current directory)\n --server URL Connect to an explicit server; requires --directory with\n an absolute server-side project path. Use HTTPS except\n on loopback. Credentials in URLs are rejected.\n -h, --help Show this help\n\nExamples\n context-guard dashboard tui\n context-guard dashboard tui --directory /absolute/project\n context-guard dashboard tui --server https://server.example --directory /server/project\n\nRequirements\n Interactive terminal and Bun >=1.3.0. The OpenTUI renderer is installed\n automatically with CGP. This command never starts a server.\n\nAuthentication (explicit servers)\n CONTEXT_GUARD_PASSWORD Server password\n CONTEXT_GUARD_USERNAME Server username (default: opencode)\n\nKeys\n 1/2/3 overview/detail/history; arrows or j/k move; / search; f filters;\n l location; w history window; r refresh; ? help; q or Ctrl+C quit.";
3
3
  export declare function parseDashboardArgs(args: readonly string[], cwd: string, env: Readonly<Record<string, string | undefined>>): DashboardConnectionOptions | "help";
4
4
  export declare function checkTerminalRuntime(version: string, interactive: boolean): void;
5
5
  export declare function loadTerminalRenderer(): Promise<typeof import("@opentui/core")>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesarus777/opencode-cgp",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -50,6 +50,7 @@
50
50
  "test:dashboard-terminal": "bun scripts/dashboard-terminal-live.ts"
51
51
  },
52
52
  "dependencies": {
53
+ "@opentui/core": "0.5.17",
53
54
  "@opencode/plugin": "2.0.29",
54
55
  "@opencode/client": "2.0.29"
55
56
  },
@@ -58,7 +59,6 @@
58
59
  "typescript": "5.9.3",
59
60
  "prettier": "3.6.2",
60
61
  "solid-js": "1.9.15",
61
- "@opentui/core": "0.5.17",
62
62
  "@opentui/solid": "0.5.17",
63
63
  "@opencode/theme": "2.0.29"
64
64
  },
@@ -67,16 +67,12 @@
67
67
  },
68
68
  "peerDependencies": {
69
69
  "solid-js": ">=1.9.0",
70
- "@opentui/core": ">=0.5.17",
71
70
  "@opentui/solid": ">=0.5.17"
72
71
  },
73
72
  "peerDependenciesMeta": {
74
73
  "solid-js": {
75
74
  "optional": true
76
75
  },
77
- "@opentui/core": {
78
- "optional": true
79
- },
80
76
  "@opentui/solid": {
81
77
  "optional": true
82
78
  }