@openviking/opencode-plugin 0.2.4 → 2026.9.9

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.
@@ -1,90 +0,0 @@
1
- // GENERATED FROM examples/memory-plugin-shared/lib. DO NOT EDIT.
2
- /**
3
- * Per-harness plugin settings from ovcli.conf.
4
- *
5
- * ovcli.conf carried connection fields only, so every harness had to keep its
6
- * tuning knobs in ov.conf's harness section — a server-side file that a
7
- * client-side plugin has no business editing. The `plugin` section fixes that:
8
- * shared keys apply to every harness that reads them, and a per-harness object
9
- * overrides them.
10
- *
11
- * {
12
- * "url": "...", "api_key": "...",
13
- * "plugin": {
14
- * "recallQueryExpansion": "off",
15
- * "recallCompress": "auto"
16
- * }
17
- * }
18
- *
19
- * Resolution stays env → ovcli.conf plugin.<harness> → ovcli.conf plugin →
20
- * ov.conf harness section (legacy) → defaults.
21
- *
22
- * Consumers: Claude Code and Codex only. The other harnesses ship this module
23
- * through `sync.mjs` but still read their knobs from the environment, so a
24
- * `plugin` entry named after them is inert. `HARNESS_KEYS` lists what a harness
25
- * loader actually consumes today — add a key here as its loader starts calling
26
- * `loadPluginSettings`, not before, so the section never promises a knob that
27
- * silently does nothing.
28
- */
29
-
30
- import { readFileSync } from "node:fs";
31
- import { homedir } from "node:os";
32
- import { join, resolve as resolvePath } from "node:path";
33
-
34
- const DEFAULT_OVCLI_CONF_PATH = join(homedir(), ".openviking", "ovcli.conf");
35
-
36
- export const HARNESS_KEYS = {
37
- claudeCode: "claude_code",
38
- codex: "codex",
39
- };
40
-
41
- function tryLoadJson(path) {
42
- try {
43
- return JSON.parse(readFileSync(path, "utf-8"));
44
- } catch {
45
- return null;
46
- }
47
- }
48
-
49
- /**
50
- * Merge the shared plugin section with the harness-specific override.
51
- * Returns a flat settings object; unknown keys pass through untouched so a
52
- * harness can add its own knobs without touching this module.
53
- */
54
- export function loadPluginSettings(harness, env = process.env) {
55
- const path = resolvePath(
56
- (env.OPENVIKING_CLI_CONFIG_FILE || DEFAULT_OVCLI_CONF_PATH).replace(/^~/, homedir()),
57
- );
58
- const file = tryLoadJson(path);
59
- const plugin = file && typeof file.plugin === "object" && file.plugin ? file.plugin : {};
60
-
61
- const shared = {};
62
- for (const [key, value] of Object.entries(plugin)) {
63
- if (value && typeof value === "object" && !Array.isArray(value)) continue;
64
- shared[key] = value;
65
- }
66
- const scoped = harness && plugin[harness] && typeof plugin[harness] === "object"
67
- ? plugin[harness]
68
- : {};
69
-
70
- return { ...shared, ...scoped };
71
- }
72
-
73
- const REWRITE_MODES = new Set(["off", "client", "server", "auto"]);
74
-
75
- /**
76
- * Normalize the tri-state rewrite knob.
77
- *
78
- * off — never compress
79
- * client — always compress locally through the host CLI
80
- * server — always ask the server for a digest
81
- * auto — prefer local (cost lands on the user's own subscription), fall back
82
- * to the server when no healthy host CLI is available
83
- */
84
- export function normalizeRewriteMode(value, fallback = "off") {
85
- const raw = String(value ?? "").trim().toLowerCase();
86
- if (REWRITE_MODES.has(raw)) return raw;
87
- if (raw === "1" || raw === "true" || raw === "yes") return "auto";
88
- if (raw === "0" || raw === "false" || raw === "no") return "off";
89
- return fallback;
90
- }