Files
OpenViking/examples/opencode-plugin/lib/shared/debug-log.mjs
T
t0saki b511d91ee5 feat(plugins): retrofit OpenCode and pi memory integrations (hybrid MCP, shared lib, 4-harness installer) (#3079)
* feat(plugins): align opencode and pi memory integrations

* fix(installer): tolerate missing optional harness CLIs

* fix(installer): install opencode file wrapper

* fix(opencode): import path for logger initialization

* fix(installer): register pi extension after copy

* feat(plugins): use MCP for opencode integration

* docs: move OpenCode and pi integrations to dedicated pages

Promote the OpenCode plugin and pi extension out of the community-plugins
page into their own numbered agent-integrations pages (10-opencode, 11-pi,
en + zh), update the overview routing table, and refresh the OpenCode image
cards to the hybrid MCP architecture (unified installer, openviking_* MCP
tools, ovcli.conf credentials).

* docs: bare TOS installer commands and reference more examples

Drop --harness from TOS-mirror install commands (image cards use the bare
installer URL, matching the claude-code/codex cards); add Open WebUI tool
server and an examples/ pointer to the community-plugins page (en + zh).

* docs: bare TOS installer commands across agent-integration pages

TOS-mirror install commands carry no flags anywhere; the installer wizard
asks for source, harnesses, language, and credentials.
2026-07-08 15:54:37 +08:00

59 lines
1.6 KiB
JavaScript

// GENERATED FROM examples/memory-plugin-shared/lib. DO NOT EDIT.
/**
* Shared structured debug logger for OpenViking memory plugin hook scripts.
*
* Harness-specific wrappers load config and pass {debug, debugLogPath}. This
* module stays path-agnostic so it can be vendored into each plugin snapshot.
*/
import { appendFileSync, mkdirSync } from "node:fs";
import { dirname } from "node:path";
function ensureDir(filePath) {
try {
mkdirSync(dirname(filePath), { recursive: true });
} catch { /* best effort */ }
}
function writeLine(filePath, obj) {
try {
appendFileSync(filePath, JSON.stringify(obj) + "\n");
} catch { /* best effort */ }
}
function localISO() {
const d = new Date();
const off = d.getTimezoneOffset();
const sign = off <= 0 ? "+" : "-";
const abs = Math.abs(off);
const local = new Date(d.getTime() - off * 60000);
return local.toISOString().replace(
"Z",
`${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`,
);
}
const noop = () => {};
export function createLogger(hookName, overrideCfg) {
const c = overrideCfg || {};
if (!c.debug) return { log: noop, logError: noop };
const logPath = c.debugLogPath;
if (!logPath) return { log: noop, logError: noop };
ensureDir(logPath);
function log(stage, data) {
writeLine(logPath, { ts: localISO(), hook: hookName, stage, data });
}
function logError(stage, err) {
const error = err instanceof Error
? { message: err.message, stack: err.stack }
: String(err);
writeLine(logPath, { ts: localISO(), hook: hookName, stage, error });
}
return { log, logError };
}