@khalilgharbaoui/opencode-claude-code-plugin 0.4.13 → 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 });