Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(codex-memory-plugin): stop PostToolUse usage hook from injecting additionalContext (#5738)

t0saki961fb4639505
diff --git a/docs/en/configuration/02-client.md b/docs/en/configuration/02-client.md
index cce6135d9..05b6013b9 100644
--- a/docs/en/configuration/02-client.md
+++ b/docs/en/configuration/02-client.md
@@ -211,6 +211,7 @@ No command writes the registry file. Create it by hand at the path `ov-memory-do
| `capture.enabled` | boolean | Whether the session is captured |
| `capture.commit_token_threshold` | integer, `1000`–`1000000` | Tokens accumulated before a capture commits |
| `bypass.session_patterns` | list of globs | A session whose id or working directory matches skips recall and capture |
+| `usage.view` / `usage.output` | string | Codex OV-Usage footer: `summary` / `expanded` / `off`, and `auto` / `terminal` / `desktop` |
| `labels` | object | Free-form metadata for humans; not read by the plugins |
An out-of-range number is clamped to the nearest bound and reported; an unrecognized enum value is ignored. The table lists common fields; `config-schema.mjs` defines the full shared schema. Unrecognized keys do not take effect.
diff --git a/docs/zh/configuration/02-client.md b/docs/zh/configuration/02-client.md
index 21fde7de2..bfe06c2f0 100644
--- a/docs/zh/configuration/02-client.md
+++ b/docs/zh/configuration/02-client.md
@@ -208,6 +208,7 @@ export OPENVIKING_CLI_CONFIG_FILE=/path/to/ovcli.conf
| `capture.enabled` | boolean | 是否启用 Capture |
| `capture.commit_token_threshold` | integer,`1000`–`1000000` | 累计多少 token 后提交一次 Capture |
| `bypass.session_patterns` | glob 列表 | 会话 id 或工作目录命中时跳过 Recall 与 Capture |
+| `usage.view` / `usage.output` | string | Codex OV-Usage 来源摘要:`summary` / `expanded` / `off`,以及 `auto` / `terminal` / `desktop` |
| `labels` | object | 给人看的自由元数据,插件不读取 |
超出范围的数值会被夹到最近的边界并给出提示;无法识别的枚举值会被忽略。表格列出常用字段;完整字段由共享 `config-schema.mjs` 定义,未识别的键不会生效。
diff --git a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
index 4e6778787..8dcbd7eb1 100644
--- a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.12",
+ "version": "0.5.13",
"clients": [
"cursor"
],
diff --git a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
index 01ba46a9e..8b39fc914 100644
--- a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
+++ b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.5.12",
+ "version": "0.5.13",
"description": "Long-term semantic memory for Kimi Code CLI, powered by OpenViking.",
"author": {
"name": "OpenViking",
diff --git a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
index 01b7e0377..138e6884a 100644
--- a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.12",
+ "version": "0.5.13",
"clients": [
"kimicode"
],
diff --git a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
index 546dcf0d7..64c50950d 100644
--- a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.12",
+ "version": "0.5.13",
"clients": [
"trae",
"trae-cn"
diff --git a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
index 06ed4632f..e3d1ec57c 100644
--- a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.12",
+ "version": "0.5.13",
"clients": [
"zcode"
],
diff --git a/examples/agent-hook-plugin/plugin.json b/examples/agent-hook-plugin/plugin.json
index bf1951268..46cea3e2b 100644
--- a/examples/agent-hook-plugin/plugin.json
+++ b/examples/agent-hook-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agent-hook-plugin",
- "version": "0.5.12",
+ "version": "0.5.13",
"description": "Long-term semantic memory for Cursor, TRAE, TRAE CN, ZCode and Kimi Code — powered by OpenViking. Auto-recall relevant memories and capture the conversation as it happens.",
"author": {
"name": "OpenViking",
diff --git a/examples/claude-code-memory-plugin/.claude-plugin/plugin.json b/examples/claude-code-memory-plugin/.claude-plugin/plugin.json
index 5d2077ca9..ec2325ea5 100644
--- a/examples/claude-code-memory-plugin/.claude-plugin/plugin.json
+++ b/examples/claude-code-memory-plugin/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.7.4",
+ "version": "0.7.5",
"description": "Long-term semantic memory for Claude Code, powered by OpenViking. Auto-recall relevant memories at session start and capture important information during conversations.",
"author": {
"name": "OpenViking",
diff --git a/examples/claude-code-memory-plugin/package.json b/examples/claude-code-memory-plugin/package.json
index 68052abdd..0dde69d87 100644
--- a/examples/claude-code-memory-plugin/package.json
+++ b/examples/claude-code-memory-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-code-openviking-memory",
- "version": "0.7.4",
+ "version": "0.7.5",
"description": "OpenViking memory plugin for Claude Code — semantic long-term memory",
"type": "module",
"scripts": {
diff --git a/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs b/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs
index cc5e88854..c79d4f11e 100644
--- a/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs
+++ b/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs
@@ -203,6 +203,11 @@ export const KNOBS = [
capability: "session",
},
+ // Codex's OV-Usage footer. Strings rather than enums: the reader matches
+ // several spellings case-insensitively (off/false/0/disabled, expanded/full/details).
+ { name: "usageView", type: "string", default: "summary", env: "OPENVIKING_USAGE_VIEW", workspace: "usage.view", capability: "session" },
+ { name: "usageOutput", type: "string", default: "auto", env: "OPENVIKING_USAGE_OUTPUT", workspace: "usage.output", capability: "session" },
+
// ── debug ─────────────────────────────────────────────────────────────
{ name: "debug", type: "bool", default: false, env: "OPENVIKING_DEBUG", capability: "debug" },
// The default path is per-harness and built from a log directory the loader
diff --git a/examples/codex-memory-plugin/.codex-plugin/plugin.json b/examples/codex-memory-plugin/.codex-plugin/plugin.json
index 51862a5ba..425e21f69 100644
--- a/examples/codex-memory-plugin/.codex-plugin/plugin.json
+++ b/examples/codex-memory-plugin/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.11.3",
+ "version": "0.11.4",
"description": "Long-term semantic memory for Codex, powered by OpenViking. Recall on UserPromptSubmit, incremental add_message on Stop (per turn), commit on SessionEnd (Codex >= 0.145) and on PreCompact, with an idle/ended sweep on SessionStart as the fallback for signals, crashes and older Codex builds. Includes a local stdio MCP proxy that reads OpenViking credentials from env/ovcli.conf.",
"author": {
"name": "OpenViking",
diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.md
index 5decbe771..c65b43d22 100644
--- a/examples/codex-memory-plugin/README.md
+++ b/examples/codex-memory-plugin/README.md
@@ -221,7 +221,7 @@ A repository can carry its own plugin settings in `<repo-root>/.openviking/confi
}
```
-`version: 1` is required; a file declaring another version is skipped with a warning. Schema v1 is `peer.source`, `peer.id`, `recall.enabled`, `recall.peer_scope`, `recall.dedup_turns`, `recall.max_items`, `recall.score_threshold`, `capture.enabled`, `capture.commit_token_threshold`, `bypass.session_patterns`, and `labels`. Lists union across layers, and a leading `"!reset"` drops what was inherited. Unknown keys are kept and ignored.
+`version: 1` is required; a file declaring another version is skipped with a warning. Schema v1 is `peer.source`, `peer.id`, `recall.enabled`, `recall.peer_scope`, `recall.dedup_turns`, `recall.max_items`, `recall.score_threshold`, `capture.enabled`, `capture.commit_token_threshold`, `bypass.session_patterns`, `usage.view`, `usage.output`, and `labels`. Lists union across layers, and a leading `"!reset"` drops what was inherited. Unknown keys are kept and ignored.
These files are trusted without a prompt, because a hook is non-interactive and an approval gate would mean one command per workspace. What is refused is structural: connection and credential keys (`url`, `api_key`, `account`, `user`, `extra_headers`, …) are stripped with a warning and `${VAR}` is never expanded in them. What a committed file switches off is announced by `$ov-memory-doctor` rather than blocked.
@@ -550,9 +550,9 @@ uses the deterministic fallback for that turn; later turns use the server.
## OV-Usage source summaries
-OV-Usage is built into the memory plugin; no separate plugin is needed. Independent
-`PostToolUse` and `Stop` hooks summarize automatic recall and explicit OpenViking
-lookups; the recall hook also supplies a footer for turns with recall alone.
+OV-Usage is built into the memory plugin; no separate plugin is needed. A
+`PostToolUse` hook records explicit OpenViking lookups, and the `Stop` hook
+summarizes them together with automatic recall.
A typical summary is:
```text
@@ -566,7 +566,7 @@ excluded from source counts.
### Configure the output
-Set `OPENVIKING_USAGE_VIEW` before launching Codex:
+Set `OPENVIKING_USAGE_VIEW` before launching Codex, or `usageView` in `ovcli.conf`'s `plugin` / `plugin.codex` section (also `usage.view` in a workspace config file, or `codex.usageView` in `ov.conf`). The environment variable wins over the files:
| Value | Behavior |
| --- | --- |
@@ -578,14 +578,20 @@ Set `OPENVIKING_USAGE_VIEW` before launching Codex:
OPENVIKING_USAGE_VIEW=expanded codex
```
-Usage uses one display channel per client. In terminal mode, the Stop hook emits
-an informational `systemMessage`; recall and lookup hooks do not request an answer
-footer. In desktop mode, recall and lookup hooks supply `additionalContext` for a
-model-rendered answer footer, and Stop does not emit a second message. Later
-lookups replace earlier snapshots. Higher-priority formatting requirements can
-suppress the footer. Interactive expand/collapse controls are not implemented.
+```json
+{ "plugin": { "codex": { "usageView": "off" } } }
+```
-Set `OPENVIKING_USAGE_OUTPUT=terminal` or `desktop` to select the channel explicitly.
+Usage uses one display channel per client. In terminal mode, the Stop hook emits
+an informational `systemMessage`; the recall hook does not request an answer
+footer. In desktop mode, the recall hook supplies `additionalContext` for a
+model-rendered answer footer covering automatic recall, and Stop does not emit a
+second message. The lookup hook never returns `additionalContext`: Codex would
+insert it between the outputs of parallel tool calls, which strict model
+providers reject. Higher-priority formatting requirements can suppress the footer.
+Interactive expand/collapse controls are not implemented.
+
+Set `OPENVIKING_USAGE_OUTPUT=terminal` or `desktop` (file key `usageOutput`, workspace `usage.output`) to select the channel explicitly.
The default `auto` selects terminal when `TERM_PROGRAM` or a non-`dumb` `TERM` is
present, and desktop otherwise. This is a heuristic, not a guaranteed client ID;
use the explicit setting if your client inherits a terminal environment. This
@@ -602,7 +608,7 @@ Turns with no recall or lookups produce no summary.
summary; with `expanded`, check that its URI matches the document.
Working MCP tools alone do not establish that hooks are enabled. If a summary is
-missing, check hook trust and `OPENVIKING_USAGE_VIEW`, then restart Codex after
+missing, check hook trust and `OPENVIKING_USAGE_VIEW` / `usageView`, then restart Codex after
changing environment variables. With `OPENVIKING_DEBUG=1`, reporting failures
write a generic notice to the existing Codex debug log. Exception text and hook
input are never logged; reporting and logging failures leave memory hooks intact.
diff --git a/examples/codex-memory-plugin/scripts/auto-recall.mjs b/examples/codex-memory-plugin/scripts/auto-recall.mjs
index 94e5cb67a..77af5e1b0 100644
--- a/examples/codex-memory-plugin/scripts/auto-recall.mjs
+++ b/examples/codex-memory-plugin/scripts/auto-recall.mjs
@@ -63,7 +63,7 @@ function emit(additionalContext) {
hookEventName: "UserPromptSubmit",
additionalContext: [wrappedContext, usageTurnId ? answerContext({
recalled: parseRecall(wrappedContext), lookups: [],
- }, usageTurnId) : ""].filter(Boolean).join("\n"),
+ }, usageTurnId, cfg) : ""].filter(Boolean).join("\n"),
},
});
}
diff --git a/examples/codex-memory-plugin/scripts/config.test.mjs b/examples/codex-memory-plugin/scripts/config.test.mjs
index e368304cc..998cb1f5a 100644
--- a/examples/codex-memory-plugin/scripts/config.test.mjs
+++ b/examples/codex-memory-plugin/scripts/config.test.mjs
@@ -5,6 +5,7 @@ import { join } from "node:path";
import test from "node:test";
import { loadConfig } from "./config.mjs";
import { isBypassed } from "./shared/session-model.mjs";
+import { usageEnabled, usageOutput, usageView } from "./usage/settings.mjs";
// The layers, the knobs and the peer are the shared loader's, and
// memory-plugin-shared/plugin-config.test.mjs holds this harness to them. What
@@ -34,6 +35,8 @@ const OVERRIDES = [
"OPENVIKING_CREDENTIALS_SOURCE",
"OPENVIKING_RECALL_QUERY_FILTERS",
"OPENVIKING_CAPTURE_FILTERS",
+ "OPENVIKING_USAGE_VIEW",
+ "OPENVIKING_USAGE_OUTPUT",
];
/**
@@ -227,3 +230,32 @@ test("slash-form directory patterns match a Windows working directory", () => {
"a backslash pattern still matches the raw path",
);
});
+
+test("OV-Usage settings come from the config files, and env overrides them", () => {
+ withConfigs({
+ cli: { url: "http://127.0.0.1:1933", api_key: "sk-cli", plugin: { codex: { usageView: "OFF", usageOutput: "terminal" } } },
+ }, ({ otherDir }) => {
+ const cfg = loadConfig(otherDir);
+ assert.equal(usageEnabled(cfg), false);
+ assert.equal(usageOutput(cfg), "terminal");
+ });
+
+ withConfigs({
+ cli: { url: "http://127.0.0.1:1933", api_key: "sk-cli", plugin: { usageView: false } },
+ workspace: { version: 1, usage: { output: "desktop" } },
+ }, ({ workspaceDir }) => {
+ const cfg = loadConfig(workspaceDir);
+ assert.equal(usageEnabled(cfg), false);
+ assert.equal(usageOutput(cfg), "desktop");
+ });
+
+ withConfigs({
+ cli: { url: "http://127.0.0.1:1933", api_key: "sk-cli", plugin: { usageView: "off", usageOutput: "terminal" } },
+ env: { OPENVIKING_USAGE_VIEW: "expanded", OPENVIKING_USAGE_OUTPUT: "desktop" },
+ }, ({ otherDir }) => {
+ const cfg = loadConfig(otherDir);
+ assert.equal(usageEnabled(cfg), true);
+ assert.equal(usageView(cfg), "expanded");
+ assert.equal(usageOutput(cfg), "desktop");
+ });
+});
diff --git a/examples/codex-memory-plugin/scripts/marketplace.test.mjs b/examples/codex-memory-plugin/scripts/marketplace.test.mjs
index 182dd5c4d..9d8f88d6f 100644
--- a/examples/codex-memory-plugin/scripts/marketplace.test.mjs
+++ b/examples/codex-memory-plugin/scripts/marketplace.test.mjs
@@ -32,28 +32,42 @@ const packagedExperienceSkillPath = join(pluginDir, "skills", "ov-experience-mem
const PLUGIN_NAME = "openviking-memory";
const LEGACY_TOOL_NAMES = ["openviking_recall", "openviking_store", "openviking_forget", "openviking_health"];
-test("usage hook delivers current-turn footer context without restarting the answer", () => {
+function usageReporter(dir, view) {
+ const env = { ...process.env, OPENVIKING_CODEX_STATE_DIR: dir, OPENVIKING_USAGE_VIEW: view, OPENVIKING_USAGE_OUTPUT: "desktop" };
+ const hook = (file, input) => JSON.parse(execFileSync(process.execPath, [join(scriptsDir, "usage", file)], {
+ input: JSON.stringify(input), env, encoding: "utf8",
+ }));
+ return (input) => {
+ assert.deepEqual(hook("track-lookup.mjs", input), {});
+ return JSON.parse(execFileSync(process.execPath, [join(scriptsDir, "usage", "report.mjs")], {
+ input: JSON.stringify({ session_id: input.session_id, turn_id: input.turn_id }),
+ env: { ...env, OPENVIKING_USAGE_OUTPUT: "terminal" }, encoding: "utf8",
+ })).systemMessage || "";
+ };
+}
+
+test("usage lookup hook records lookups without returning additionalContext", () => {
const dir = mkdtempSync(join(tmpdir(), "ov-usage-display-"));
const hook = join(scriptsDir, "usage", "track-lookup.mjs");
const env = { ...process.env, OPENVIKING_CODEX_STATE_DIR: dir, OPENVIKING_USAGE_VIEW: "summary", OPENVIKING_USAGE_OUTPUT: "desktop" };
- const run = (turn, uri, extra = {}, overrides = {}) => JSON.parse(execFileSync(process.execPath, [hook], {
- input: JSON.stringify({ session_id: "display-contract", turn_id: turn,
- tool_use_id: uri, tool_name: "mcp__openviking_memory__read",
- tool_input: { uris: [uri] }, tool_response: { content: [] }, ...extra }),
- env: { ...env, ...overrides }, encoding: "utf8",
+ const report = usageReporter(dir, "summary");
+ const input = (turn, uri, extra = {}) => ({ session_id: "display-contract", turn_id: turn,
+ tool_use_id: uri, tool_name: "mcp__openviking_memory__read",
+ tool_input: { uris: [uri] }, tool_response: { content: [] }, ...extra });
+ const run = (value, overrides = {}) => JSON.parse(execFileSync(process.execPath, [hook], {
+ input: JSON.stringify(value), env: { ...env, ...overrides }, encoding: "utf8",
}));
try {
- const first = run("one", "viking://resources/team/a.md");
- assert.equal(first.hookSpecificOutput.hookEventName, "PostToolUse");
- assert.match(first.hookSpecificOutput.additionalContext, /OpenViking · 1 source · 1 team doc · 1 read/);
- assert.equal(first.decision, undefined);
- const second = run("one", "viking://resources/team/b.md");
- assert.match(second.hookSpecificOutput.additionalContext, /OpenViking · 2 sources · 2 team docs · 2 read/);
- const failed = run("two", "viking://resources/team/c.md", { tool_response: { isError: true } });
- assert.match(failed.hookSpecificOutput.additionalContext, /OpenViking · 0 sources/);
- assert.doesNotMatch(failed.hookSpecificOutput.additionalContext, /1 read/);
- assert.deepEqual(run("off", "viking://resources/team/a.md", {}, { OPENVIKING_USAGE_VIEW: "off" }), {});
- assert.deepEqual(run("other", "ignored", { tool_name: "unrelated" }), {});
+ assert.match(report(input("one", "viking://resources/team/a.md")), /OpenViking · 1 source · 1 team doc · 1 read/);
+ assert.match(report(input("one", "viking://resources/team/b.md")), /OpenViking · 2 sources · 2 team docs · 2 read/);
+ const failed = report(input("two", "viking://resources/team/c.md", { tool_response: { isError: true } }));
+ assert.match(failed, /OpenViking · 0 sources/);
+ assert.doesNotMatch(failed, /1 read/);
+ for (const channel of ["desktop", "terminal"]) {
+ assert.deepEqual(run(input("three", "viking://resources/team/d.md"), { OPENVIKING_USAGE_OUTPUT: channel }), {});
+ }
+ assert.deepEqual(run(input("off", "viking://resources/team/a.md"), { OPENVIKING_USAGE_VIEW: "off" }), {});
+ assert.deepEqual(run(input("other", "ignored", { tool_name: "unrelated" })), {});
} finally { rmSync(dir, { recursive: true, force: true }); }
});
@@ -79,14 +93,9 @@ test("usage wrapper credits successful output without inferring executed reads",
const dir = mkdtempSync(join(tmpdir(), "ov-usage-wrapper-"));
const uri = "viking://resources/team/checklist.md";
const failedUri = "viking://resources/team/failed.md";
- const hook = join(scriptsDir, "usage", "track-lookup.mjs");
- const run = (code, content) => JSON.parse(execFileSync(process.execPath, [hook], {
- input: JSON.stringify({ session_id: "wrapper", turn_id: "turn", tool_use_id: "lookup",
- tool_name: "functions.exec", tool_input: { code }, tool_response: { content } }),
- env: { ...process.env, OPENVIKING_CODEX_STATE_DIR: dir,
- OPENVIKING_USAGE_VIEW: "expanded", OPENVIKING_USAGE_OUTPUT: "desktop" },
- encoding: "utf8",
- })).hookSpecificOutput?.additionalContext || "";
+ const report = usageReporter(dir, "expanded");
+ const run = (code, content) => report({ session_id: "wrapper", turn_id: "turn", tool_use_id: "lookup",
+ tool_name: "functions.exec", tool_input: { code }, tool_response: { content } });
const text = (value) => ({ type: "text", text: typeof value === "string" ? value : JSON.stringify(value) });
try {
for (const code of [
@@ -122,13 +131,9 @@ test("usage wrapper credits successful output without inferring executed reads",
test("usage attributes Experience through the registered generic search and read tools", () => {
const dir = mkdtempSync(join(tmpdir(), "ov-usage-experience-"));
const uri = "viking://user/test/memories/experiences/hook-review.md";
- const run = (method, input, response) => JSON.parse(execFileSync(process.execPath,
- [join(scriptsDir, "usage", "track-lookup.mjs")], {
- input: JSON.stringify({ session_id: "experience", turn_id: "turn", tool_use_id: method,
- tool_name: `mcp__openviking_memory__${method}`, tool_input: input, tool_response: response }),
- env: { ...process.env, OPENVIKING_CODEX_STATE_DIR: dir,
- OPENVIKING_USAGE_VIEW: "summary", OPENVIKING_USAGE_OUTPUT: "desktop" }, encoding: "utf8",
- })).hookSpecificOutput.additionalContext;
+ const report = usageReporter(dir, "summary");
+ const run = (method, input, response) => report({ session_id: "experience", turn_id: "turn",
+ tool_use_id: method, tool_name: `mcp__openviking_memory__${method}`, tool_input: input, tool_response: response });
try {
assert.match(run("find", { query: "hook review", target_uri: "viking://~/memories/experiences" },
{ content: [{ type: "text", text: uri }] }), /OpenViking · 1 source · 1 work memory/);
@@ -402,7 +407,7 @@ test("terminal and desktop use exactly one usage output channel", () => {
}));
const lookup = run("track-lookup.mjs");
const stop = run("report.mjs");
- assert.equal(Boolean(lookup.hookSpecificOutput?.additionalContext), channel === "desktop");
+ assert.deepEqual(lookup, {});
assert.equal(Boolean(stop.systemMessage), channel === "terminal");
}
} finally {
diff --git a/examples/codex-memory-plugin/scripts/shared/config-schema.mjs b/examples/codex-memory-plugin/scripts/shared/config-schema.mjs
index cc5e88854..c79d4f11e 100644
--- a/examples/codex-memory-plugin/scripts/shared/config-schema.mjs
+++ b/examples/codex-memory-plugin/scripts/shared/config-schema.mjs
@@ -203,6 +203,11 @@ export const KNOBS = [
capability: "session",
},
+ // Codex's OV-Usage footer. Strings rather than enums: the reader matches
+ // several spellings case-insensitively (off/false/0/disabled, expanded/full/details).
+ { name: "usageView", type: "string", default: "summary", env: "OPENVIKING_USAGE_VIEW", workspace: "usage.view", capability: "session" },
+ { name: "usageOutput", type: "string", default: "auto", env: "OPENVIKING_USAGE_OUTPUT", workspace: "usage.output", capability: "session" },
+
// ── debug ─────────────────────────────────────────────────────────────
{ name: "debug", type: "bool", default: false, env: "OPENVIKING_DEBUG", capability: "debug" },
// The default path is per-harness and built from a log directory the loader
diff --git a/examples/codex-memory-plugin/scripts/usage/display.mjs b/examples/codex-memory-plugin/scripts/usage/display.mjs
index 79e45d3cf..bc347972d 100644
--- a/examples/codex-memory-plugin/scripts/usage/display.mjs
+++ b/examples/codex-memory-plugin/scripts/usage/display.mjs
@@ -1,18 +1,17 @@
+import { loadConfig } from "../config.mjs";
import { consulted, expandedLines, summaryLine } from "./sources.mjs";
-import { usageEnabled, usageOutput } from "./settings.mjs";
+import { usageEnabled, usageOutput, usageView } from "./settings.mjs";
-export function formatReport(turn) {
+export function formatReport(turn, cfg = loadConfig()) {
const result = consulted(turn);
if (!result.rows.length && !turn.lookups?.length) return "";
- const expanded = ["expanded", "full", "details"].includes(
- String(process.env.OPENVIKING_USAGE_VIEW || "summary").trim().toLowerCase(),
- );
+ const expanded = ["expanded", "full", "details"].includes(usageView(cfg));
return expanded ? expandedLines(turn, result).join("\n") : summaryLine(result);
}
-export function answerContext(turn, turnId) {
- if (!usageEnabled() || usageOutput() === "terminal") return "";
- const report = formatReport(turn);
+export function answerContext(turn, turnId, cfg = loadConfig()) {
+ if (!usageEnabled(cfg) || usageOutput(cfg) === "terminal") return "";
+ const report = formatReport(turn, cfg);
if (!report) return "";
// Keep source titles and query strings as data, never hook instructions.
const data = JSON.stringify({ turnId, report }).replace(/</g, "\\u003c");
diff --git a/examples/codex-memory-plugin/scripts/usage/report.mjs b/examples/codex-memory-plugin/scripts/usage/report.mjs
index c5c4fbdf5..c7da226b1 100644
--- a/examples/codex-memory-plugin/scripts/usage/report.mjs
+++ b/examples/codex-memory-plugin/scripts/usage/report.mjs
@@ -1,5 +1,6 @@
#!/usr/bin/env node
+import { loadConfig } from "../config.mjs";
import { usageEnabled, usageOutput } from "./settings.mjs";
import { runHook } from "./hook-io.mjs";
import { formatReport } from "./display.mjs";
@@ -7,7 +8,8 @@ import { pruneSessions, pruneTurns, readTurn, writeRecall } from "./state.mjs";
import { readTranscriptRecall } from "./transcript.mjs";
await runHook(async (input) => {
- if (!usageEnabled()) return {};
+ const cfg = loadConfig(input.cwd || undefined);
+ if (!usageEnabled(cfg)) return {};
const sessionId = input.session_id;
const turnId = input.turn_id;
if (!sessionId || !turnId) return {};
@@ -18,10 +20,10 @@ await runHook(async (input) => {
turn.recalled = recalled;
await writeRecall(sessionId, turnId, recalled);
}
- const message = formatReport(turn);
+ const message = formatReport(turn, cfg);
if (!message) return {};
await pruneTurns(sessionId, turnId);
await pruneSessions(sessionId);
- return usageOutput() === "terminal" ? { systemMessage: message } : {};
+ return usageOutput(cfg) === "terminal" ? { systemMessage: message } : {};
}, "report");
diff --git a/examples/codex-memory-plugin/scripts/usage/settings.mjs b/examples/codex-memory-plugin/scripts/usage/settings.mjs
index 7845d3aa8..027e1fd19 100644
--- a/examples/codex-memory-plugin/scripts/usage/settings.mjs
+++ b/examples/codex-memory-plugin/scripts/usage/settings.mjs
@@ -1,11 +1,21 @@
-export function usageEnabled() {
- return !["off", "false", "0", "disabled"].includes(String(process.env.OPENVIKING_USAGE_VIEW || "summary").trim().toLowerCase());
+import { loadConfig } from "../config.mjs";
+
+function setting(value, fallback) {
+ return String(value ?? fallback).trim().toLowerCase();
+}
+
+export function usageView(cfg = loadConfig()) {
+ return setting(cfg.usageView, "summary");
+}
+
+export function usageEnabled(cfg = loadConfig()) {
+ return !["off", "false", "0", "disabled"].includes(usageView(cfg));
}
// Clients do not expose a universal desktop/terminal identifier to hooks.
// An explicit choice takes precedence; terminal environments use native output.
-export function usageOutput() {
- const value = String(process.env.OPENVIKING_USAGE_OUTPUT || "auto").trim().toLowerCase();
+export function usageOutput(cfg = loadConfig()) {
+ const value = setting(cfg.usageOutput, "auto");
if (["terminal", "desktop"].includes(value)) return value;
const term = String(process.env.TERM || "").trim();
return process.env.TERM_PROGRAM || (term && term !== "dumb") ? "terminal" : "desktop";
diff --git a/examples/codex-memory-plugin/scripts/usage/track-lookup.mjs b/examples/codex-memory-plugin/scripts/usage/track-lookup.mjs
index f299f9db7..b244dfcd0 100644
--- a/examples/codex-memory-plugin/scripts/usage/track-lookup.mjs
+++ b/examples/codex-memory-plugin/scripts/usage/track-lookup.mjs
@@ -1,5 +1,6 @@
#!/usr/bin/env node
+import { loadConfig } from "../config.mjs";
import { usageEnabled } from "./settings.mjs";
import { runHook } from "./hook-io.mjs";
import {
@@ -8,12 +9,10 @@ import {
successfulResponseText,
urisIn,
} from "./sources.mjs";
-import { readTurn, writeLookup, writeRecall } from "./state.mjs";
-import { readTranscriptRecall } from "./transcript.mjs";
-import { answerContext } from "./display.mjs";
+import { writeLookup } from "./state.mjs";
await runHook(async (input) => {
- if (!usageEnabled()) return {};
+ if (!usageEnabled(loadConfig(input.cwd || undefined))) return {};
const sessionId = input.session_id;
const turnId = input.turn_id;
if (!sessionId || !turnId) return {};
@@ -33,10 +32,7 @@ await runHook(async (input) => {
isError: toolResponseFailed(input.tool_response) && (!wrapped || !responseText),
};
await writeLookup(sessionId, turnId, input.tool_use_id, lookup);
- const recalled = await readTranscriptRecall(input.transcript_path, turnId);
- await writeRecall(sessionId, turnId, recalled);
- const additionalContext = answerContext(await readTurn(sessionId, turnId), turnId);
- return additionalContext ? {
- hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext },
- } : {};
+ // Codex injects PostToolUse additionalContext as a developer message right after
+ // this tool's output, which splits parallel function_call_outputs; record only.
+ return {};
}, "track-lookup");
diff --git a/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md b/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
index d5e30e632..63b6a73c8 100644
--- a/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
+++ b/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
@@ -12,7 +12,7 @@ and `CODEX_CONFIG_FILE` relocate individual pieces.
| `~/.openviking/ovcli.conf` | Client connection: `url`, `api_key`, `account`, `user`, optional `plugin.codex.*` tuning. Mode 0600. |
| `~/.openviking/ov.conf` | Server config. The plugin reads only `server.url/host/port`, `server.root_api_key` (last-resort key) and the legacy `codex` block. |
| `~/.openviking/ovcli.conf.<name>` | Saved CLI profiles (`ov config switch` copies one over `ovcli.conf`). `ovcli.conf.bak.<epoch>` are installer backups. |
-| `<repo root>/.openviking/config.json` / `config.local.json` | Workspace config layers, `version: 1` required: `peer.source`, `peer.id`, `recall.*`, `capture.*`, `bypass.session_patterns`, `labels`. `config.json` is committed and shared; `config.local.json` is private and gitignored. Trusted without a prompt, but connection and credential keys (`url`, `api_key`, `account`, `user`, `extra_headers`, …) are stripped with a warning and `${VAR}` is never expanded. A blanket `.openviking/` rule in `.gitignore` stops `config.json` from ever being committed — narrow it to `.openviking/media/` and `.openviking/downloads/`. |
+| `<repo root>/.openviking/config.json` / `config.local.json` | Workspace config layers, `version: 1` required: `peer.source`, `peer.id`, `recall.*`, `capture.*`, `bypass.session_patterns`, `usage.*`, `labels`. `config.json` is committed and shared; `config.local.json` is private and gitignored. Trusted without a prompt, but connection and credential keys (`url`, `api_key`, `account`, `user`, `extra_headers`, …) are stripped with a warning and `${VAR}` is never expanded. A blanket `.openviking/` rule in `.gitignore` stops `config.json` from ever being committed — narrow it to `.openviking/media/` and `.openviking/downloads/`. |
| `~/.openviking/workspaces/<slot>.json` | Per-machine workspace registry, one file per workspace (`<dir name>-<hash>.json`, mode 0600). Outranks both workspace files, and nothing writes it — a user creates the file by hand. An entry recorded for a different repository is ignored, not inherited. |
| `~/.codex/config.toml` | `[features] hooks` (or legacy `plugin_hooks`), `[plugins."openviking-memory@openviking"] enabled`, `[marketplaces.openviking]` (source, ref), `[hooks.state."openviking-memory@openviking:hooks/hooks.json:<event>:0:0"] trusted_hash` for `session_start`, `user_prompt_submit`, `pre_tool_use`, `stop`, `session_end`, `pre_compact`. |
| `~/.codex/plugins/cache/openviking/openviking-memory/<version>/` | The copy Codex runs hooks from. Keyed by `plugin.json` version. |
diff --git a/examples/memory-plugin-shared/README.md b/examples/memory-plugin-shared/README.md
index a891464b4..7b5526fe0 100644
--- a/examples/memory-plugin-shared/README.md
+++ b/examples/memory-plugin-shared/README.md
@@ -115,7 +115,7 @@ Every harness resolves every knob through that order: claude-code, codex, cursor
The knobs themselves are declared once in `lib/config-schema.mjs`, with each one's type, default, range, `OPENVIKING_*` variable and older spellings. An older spelling keeps working: `syncTurns` sets `autoCapture`, `bypassPatterns` sets `bypassSessionPatterns`, `recallRewrite` sets `recallCompress`, `requestTimeoutMs` sets `timeoutMs`, `recallBudget` sets `recallTokenBudget`, `recallScoreThreshold` sets `scoreThreshold`, `recallMinQueryLength` sets `minQueryLength`, `profileBudget` sets `profileTokenBudget`, `recallCompressReasoningEffort` sets `recallCompressThinking`, `auth_mode` sets `authMode`, and `peer_id` sets `peerId`.
-Every file declares `version: 1`; one declaring another version is skipped with a warning. Schema v1 is `peer.source`, `peer.id`, `recall.enabled`, `recall.peer_scope`, `recall.dedup_turns`, `recall.max_items`, `recall.score_threshold`, `capture.enabled`, `capture.commit_token_threshold`, `bypass.session_patterns`, and `labels`. Lists union across layers, and a leading `"!reset"` clears what was inherited. Unknown keys are kept and ignored.
+Every file declares `version: 1`; one declaring another version is skipped with a warning. Schema v1 is `peer.source`, `peer.id`, `recall.enabled`, `recall.peer_scope`, `recall.dedup_turns`, `recall.max_items`, `recall.score_threshold`, `capture.enabled`, `capture.commit_token_threshold`, `bypass.session_patterns`, `usage.view`, `usage.output`, and `labels`. Lists union across layers, and a leading `"!reset"` clears what was inherited. Unknown keys are kept and ignored.
Workspace files are trusted without a prompt: a hook is non-interactive, and an approval gate would degrade into one command per workspace. What is refused instead is structural — connection and credential keys (`url`, `api_key`, `account`, `user`, `extra_headers`, …) are stripped with a warning and `${VAR}` is never expanded in these files. What a committed file switches off is announced in `ov-memory-doctor` rather than blocked.
diff --git a/examples/memory-plugin-shared/lib/config-schema.mjs b/examples/memory-plugin-shared/lib/config-schema.mjs
index 3a08ed02b..c49188a4b 100644
--- a/examples/memory-plugin-shared/lib/config-schema.mjs
+++ b/examples/memory-plugin-shared/lib/config-schema.mjs
@@ -202,6 +202,11 @@ export const KNOBS = [
capability: "session",
},
+ // Codex's OV-Usage footer. Strings rather than enums: the reader matches
+ // several spellings case-insensitively (off/false/0/disabled, expanded/full/details).
+ { name: "usageView", type: "string", default: "summary", env: "OPENVIKING_USAGE_VIEW", workspace: "usage.view", capability: "session" },
+ { name: "usageOutput", type: "string", default: "auto", env: "OPENVIKING_USAGE_OUTPUT", workspace: "usage.output", capability: "session" },
+
// ── debug ─────────────────────────────────────────────────────────────
{ name: "debug", type: "bool", default: false, env: "OPENVIKING_DEBUG", capability: "debug" },
// The default path is per-harness and built from a log directory the loader
diff --git a/examples/opencode-plugin/package.json b/examples/opencode-plugin/package.json
index cb0bfae49..3888ac0fc 100644
--- a/examples/opencode-plugin/package.json
+++ b/examples/opencode-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@openviking/opencode-plugin",
- "version": "0.5.6",
+ "version": "0.5.7",
"author": "@openviking",
"description": "Unified OpenCode plugin for OpenViking repository retrieval and long-term memory",
"type": "module",
diff --git a/examples/pi-coding-agent-extension/package-lock.json b/examples/pi-coding-agent-extension/package-lock.json
index cc275a72b..544cda338 100644
--- a/examples/pi-coding-agent-extension/package-lock.json
+++ b/examples/pi-coding-agent-extension/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "openviking-pi-extension",
- "version": "0.4.11",
+ "version": "0.4.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openviking-pi-extension",
- "version": "0.4.11",
+ "version": "0.4.12",
"dependencies": {
"@modelcontextprotocol/client": "2.0.0"
},
diff --git a/examples/pi-coding-agent-extension/package.json b/examples/pi-coding-agent-extension/package.json
index c20eeb9c1..727bfb234 100644
--- a/examples/pi-coding-agent-extension/package.json
+++ b/examples/pi-coding-agent-extension/package.json
@@ -1,6 +1,6 @@
{
"name": "openviking-pi-extension",
- "version": "0.4.11",
+ "version": "0.4.12",
"description": "OpenViking memory and context extension for the pi coding agent",
"private": true,
"type": "module",
diff --git a/examples/schemas/workspace-config-v1.json b/examples/schemas/workspace-config-v1.json
index f1e7df8c3..fd3dc22de 100644
--- a/examples/schemas/workspace-config-v1.json
+++ b/examples/schemas/workspace-config-v1.json
@@ -84,6 +84,15 @@
}
}
},
+ "usage": {
+ "type": "object",
+ "additionalProperties": true,
+ "description": "Codex OV-Usage footer.",
+ "properties": {
+ "view": { "type": "string", "examples": ["summary", "expanded", "off"] },
+ "output": { "type": "string", "examples": ["auto", "terminal", "desktop"] }
+ }
+ },
"labels": {
"type": "object",
"description": "Free-form metadata for humans and for the plugins' doctor output. Its keys are the user's own vocabulary and are never interpreted as settings.",