import fs from "fs" import os from "os" import path from "path" let LOG_DIR = "/tmp/opencode-matrix-plugin" let LOG_FILE = path.join(LOG_DIR, "plugin.log") export function setLogDir(dir: string): void { LOG_DIR = dir LOG_FILE = path.join(dir, "plugin.log") } export function log(message: string): void { try { const timestamp = new Date().toISOString() const line = `[${timestamp}] ${message}\n` fs.mkdirSync(LOG_DIR, { recursive: true }) fs.appendFileSync(LOG_FILE, line) } catch (e) { try { const timestamp = new Date().toISOString() fs.appendFileSync("/tmp/opencode-matrix-fallback.log", `[${timestamp}] ${message}\n`) } catch { // silent fallback } } }