@codemem/opencode-plugin 0.26.0 → 0.26.2

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.
@@ -15,7 +15,7 @@ import {
15
15
 
16
16
  const TRUTHY_VALUES = ["1", "true", "yes"];
17
17
  const DISABLED_VALUES = ["0", "false", "off"];
18
- const PINNED_BACKEND_VERSION = "0.26.0";
18
+ const PINNED_BACKEND_VERSION = "0.26.2";
19
19
  const COMPAT_CHECK_DELAY_MS = 1500;
20
20
  const COMPAT_CHECK_CACHE_TTL_MS = 5 * 60 * 1000;
21
21
 
@@ -703,6 +703,8 @@ export const OpencodeMemPlugin = async ({
703
703
  );
704
704
  const viewerHost = process.env.CODEMEM_VIEWER_HOST || "127.0.0.1";
705
705
  const viewerPort = process.env.CODEMEM_VIEWER_PORT || "38888";
706
+ const viewerDbPath = process.env.CODEMEM_DB || "";
707
+ const viewerConfigPath = process.env.CODEMEM_CONFIG || "";
706
708
  const commandTimeout = Number.parseInt(
707
709
  process.env.CODEMEM_PLUGIN_CMD_TIMEOUT || "20000",
708
710
  10
@@ -798,6 +800,17 @@ export const OpencodeMemPlugin = async ({
798
800
  return true;
799
801
  };
800
802
 
803
+ const buildViewerCliArgs = (action) => {
804
+ const args = ["serve", action, "--host", viewerHost, "--port", viewerPort];
805
+ if (String(viewerDbPath || "").trim()) {
806
+ args.push("--db-path", viewerDbPath);
807
+ }
808
+ if (String(viewerConfigPath || "").trim()) {
809
+ args.push("--config", viewerConfigPath);
810
+ }
811
+ return args;
812
+ };
813
+
801
814
  const emitRawEvent = async ({ sessionID, type, payload }) => {
802
815
  if (!rawEventsEnabled) {
803
816
  return true;
@@ -1212,7 +1225,8 @@ export const OpencodeMemPlugin = async ({
1212
1225
  return;
1213
1226
  }
1214
1227
  viewerStarted = true;
1215
- const cmd = [runner, ...runnerArgs, "serve", "start"];
1228
+ const viewerArgs = buildViewerCliArgs("start");
1229
+ const cmd = [runner, ...runnerArgs, ...viewerArgs];
1216
1230
  logLine(`auto-starting viewer: ${cmd.join(" ")}`).catch(() => {});
1217
1231
  try {
1218
1232
  const child = nodeSpawn(cmd[0], cmd.slice(1), {
@@ -1304,7 +1318,7 @@ export const OpencodeMemPlugin = async ({
1304
1318
  if (!viewerEnabled || !viewerAutoStart || !viewerStarted) {
1305
1319
  return { attempted: false, ok: false };
1306
1320
  }
1307
- const restartResult = await runCli(["serve", "restart"]);
1321
+ const restartResult = await runCli(buildViewerCliArgs("restart"));
1308
1322
  if (restartResult?.exitCode === 0) {
1309
1323
  await logLine("compat.auto_update_viewer_restart ok");
1310
1324
  return { attempted: true, ok: true };
@@ -1550,7 +1564,7 @@ export const OpencodeMemPlugin = async ({
1550
1564
  viewerStarted = false;
1551
1565
  stopHealthCheck();
1552
1566
  await logLine("viewer stop requested");
1553
- await runCli(["serve", "stop"]);
1567
+ await runCli(buildViewerCliArgs("stop"));
1554
1568
  };
1555
1569
 
1556
1570
  const checkViewerHealth = async () => {
@@ -1581,7 +1595,7 @@ export const OpencodeMemPlugin = async ({
1581
1595
  healthLastRestartAttempt = Date.now();
1582
1596
  await logLine(`viewer.health restarting viewer after ${healthConsecutiveFailures} consecutive failures`);
1583
1597
  try {
1584
- const result = await runCli(["serve", "restart"]);
1598
+ const result = await runCli(buildViewerCliArgs("restart"));
1585
1599
  const ok = result?.exitCode === 0;
1586
1600
  await logLine(`viewer.health restart ${ok ? "succeeded" : "failed"} (exit=${result?.exitCode ?? "unknown"})`);
1587
1601
  if (ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemem/opencode-plugin",
3
- "version": "0.26.0",
3
+ "version": "0.26.2",
4
4
  "description": "CodeMem plugin for OpenCode",
5
5
  "type": "module",
6
6
  "main": "./index.js",