@khalilgharbaoui/opencode-claude-code-plugin 0.4.12 → 0.4.14

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
@@ -321,11 +321,28 @@ Set `permissionMode: "plan"` to forward `--permission-mode plan` to Claude. The
321
321
 
322
322
  ## Debug logging
323
323
 
324
+ Two independent knobs:
325
+
324
326
  ```bash
327
+ # Verbose logging to stderr (opencode surfaces stderr as UI warnings):
325
328
  DEBUG=opencode-claude-code opencode
329
+
330
+ # Persistent file log (default: OFF — file is not created at all):
331
+ OPENCODE_CLAUDE_CODE_LOG_FILE=1 opencode
332
+
333
+ # Both:
334
+ DEBUG=opencode-claude-code OPENCODE_CLAUDE_CODE_LOG_FILE=1 opencode
326
335
  ```
327
336
 
328
- Goes to stderr.
337
+ When `OPENCODE_CLAUDE_CODE_LOG_FILE` is set to any truthy value (`1`,
338
+ `true`, `yes`, `on`), the plugin writes NOTICE/WARN/ERROR (plus INFO and
339
+ DEBUG when `DEBUG=opencode-claude-code` is also set) to
340
+ `~/.local/share/opencode-claude-code/plugin.log` with 5MB rotation. Override
341
+ the directory with `OPENCODE_CLAUDE_CODE_LOG_DIR=/custom/path`.
342
+
343
+ Default is off so the plugin doesn't accrete a log file on every user's
344
+ disk. Opt in when you need to inspect auto-continue decisions, broker
345
+ state, or other plugin internals.
329
346
 
330
347
  ## Known limitations
331
348
 
package/dist/index.js CHANGED
@@ -9,6 +9,13 @@ var DEBUG = process.env.DEBUG?.includes("opencode-claude-code") ?? false;
9
9
  var LOG_DIR = process.env.OPENCODE_CLAUDE_CODE_LOG_DIR ?? join(homedir(), ".local", "share", "opencode-claude-code");
10
10
  var LOG_FILE = join(LOG_DIR, "plugin.log");
11
11
  var MAX_LOG_BYTES = 5 * 1024 * 1024;
12
+ function isTruthyEnv(v) {
13
+ if (v == null) return false;
14
+ const s = v.toLowerCase().trim();
15
+ if (s === "") return false;
16
+ return s !== "0" && s !== "false" && s !== "no" && s !== "off";
17
+ }
18
+ var LOG_FILE_ENABLED = isTruthyEnv(process.env.OPENCODE_CLAUDE_CODE_LOG_FILE);
12
19
  var fileLoggingDisabled = false;
13
20
  function rotateIfNeeded() {
14
21
  try {
@@ -20,6 +27,7 @@ function rotateIfNeeded() {
20
27
  }
21
28
  }
22
29
  function writeToFile(line) {
30
+ if (!LOG_FILE_ENABLED) return;
23
31
  if (fileLoggingDisabled) return;
24
32
  try {
25
33
  mkdirSync(dirname(LOG_FILE), { recursive: true });
@@ -1211,7 +1219,7 @@ async function createProxyMcpServer(tools = DEFAULT_PROXY_TOOLS) {
1211
1219
  timer = setTimeout(() => {
1212
1220
  if (!pending.has(callId)) return;
1213
1221
  pending.delete(callId);
1214
- log.warn("proxy-mcp tool call timed out", {
1222
+ log.notice("proxy-mcp tool call timed out", {
1215
1223
  callId,
1216
1224
  toolName,
1217
1225
  timeoutMs: PROXY_CALL_TIMEOUT_MS
@@ -1255,8 +1263,11 @@ async function createProxyMcpServer(tools = DEFAULT_PROXY_TOOLS) {
1255
1263
  error: { code: -32601, message: `Unknown method: ${request.method}` }
1256
1264
  });
1257
1265
  } catch (error) {
1258
- log.warn("proxy-mcp error handling request", {
1259
- error: error instanceof Error ? error.message : String(error)
1266
+ const errorMessage = error instanceof Error ? error.message : String(error);
1267
+ const isTimeout = errorMessage.includes("timed out after") && errorMessage.includes("waiting for opencode to resolve");
1268
+ const logFn = isTimeout ? log.notice : log.warn;
1269
+ logFn("proxy-mcp error handling request", {
1270
+ error: errorMessage
1260
1271
  });
1261
1272
  try {
1262
1273
  writeJson(res, {
@@ -1428,7 +1439,7 @@ function queuePendingProxyCall(sessionKey2, call) {
1428
1439
  `Proxy tool call '${call.toolName}' timed out after ${PENDING_PROXY_CALL_TIMEOUT_MS}ms waiting for opencode to resolve the call`
1429
1440
  )
1430
1441
  );
1431
- log.warn("timed out pending proxy call", {
1442
+ log.notice("timed out pending proxy call", {
1432
1443
  sessionKey: current.sessionKey,
1433
1444
  toolCallId: call.id,
1434
1445
  toolName: call.toolName,