Skip to content

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

fix(plugins): skip shell aliases when wrapping extra launch commands (#2471)

t0saki7237ac611cfb
diff --git a/docs/en/agent-integrations/02-claude-code.md b/docs/en/agent-integrations/02-claude-code.md
index 0332fb9b1..d0349e65b 100644
--- a/docs/en/agent-integrations/02-claude-code.md
+++ b/docs/en/agent-integrations/02-claude-code.md
@@ -18,6 +18,8 @@ After installation, activate the `claude` wrapper in your current terminal (or s
source ~/.openviking/openviking-repo/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
```
+> Launch Claude Code through a custom command? A wrapper script like `cc-custom`, or a multi-word launcher (a base command plus a sub-command) — list it at the installer's "Extra launch commands" step (or pass `OPENVIKING_CC_WRAP_EXTRA='cc-custom'`) to inject credentials there too.
+
After using it for a while, try starting a new conversation and asking about something you mentioned earlier—it will remember.
<details>
@@ -110,6 +112,8 @@ The plugin renders an OpenViking status indicator beneath your Claude Code input
| Plugin is not activating | Missing `ov.conf` or `ovcli.conf` | Run the [installer](#install), or set `OPENVIKING_MEMORY_ENABLED=1` along with the URL/API_KEY environment variables |
| Hooks fire but recall is empty | Server is not running or the URL is incorrect | Check server health: `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` |
| MCP tools hit `127.0.0.1` instead of the remote server | Missing function wrapper | Ensure `type claude` outputs "shell function"; see [Manual setup](#install) |
+| `type claude` shows a path instead of a shell function (wrapper inactive) | The rc wasn't `source`d after install, or you launched from a terminal that didn't load it | Run `source ~/.zshrc` (or `~/.bashrc` on bash), or open a new terminal |
+| Launching via an alias (e.g. `cc`) injects no credentials | The alias *name* was listed in `OPENVIKING_CC_WRAP_EXTRA` (alias names are skipped), or the alias's target command isn't wrapped | Wrap the command the alias points to, not the alias: `alias cc=claude` needs nothing; for `alias cc=claude-custom`, add `claude-custom` |
| Remote auth 401 / 403 | Incorrect API key or missing tenant headers | Verify `OPENVIKING_API_KEY`; for multi-tenant setups, also check `OPENVIKING_ACCOUNT` and `OPENVIKING_USER` |
## See also
diff --git a/docs/en/agent-integrations/04-codex.md b/docs/en/agent-integrations/04-codex.md
index dc3905439..996f04fc8 100644
--- a/docs/en/agent-integrations/04-codex.md
+++ b/docs/en/agent-integrations/04-codex.md
@@ -19,6 +19,8 @@ source ~/.openviking/openviking-repo/examples/codex-memory-plugin/setup-helper/w
codex # First run: approve hooks once when prompted via /hooks
```
+> Launch Codex through a custom command? A wrapper script like `codex-custom`, or a multi-word launcher (a base command plus a sub-command) — list it at the installer's "Extra launch commands" step (or pass `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'`) to inject credentials there too.
+
<details>
<summary><b>Manual setup</b></summary>
@@ -70,6 +72,8 @@ Additional tuning options (e.g., `OPENVIKING_RECALL_LIMIT`, `OPENVIKING_CAPTURE_
| Symptom | Cause | Fix |
|---------|-------|-----|
| `MCP server is not logged in` | `OPENVIKING_API_KEY` not in env at launch | Ensure the `codex()` shell function is sourced and `ovcli.conf` contains a valid `api_key`. |
+| `type codex` shows a path instead of a shell function (wrapper inactive) | The rc wasn't `source`d after install, or you launched from a terminal that didn't load it | Run `source ~/.zshrc` (or `~/.bashrc` on bash), or open a new terminal |
+| Launching via an alias (e.g. `cx`) injects no credentials | The alias *name* was listed in `OPENVIKING_CODEX_WRAP_EXTRA` (alias names are skipped), or the alias's target command isn't wrapped | Wrap the command the alias points to, not the alias: `alias cx=codex` needs nothing; for `alias cx=codex-custom`, add `codex-custom` |
| `4 hooks need review` | Security review on first launch | Run `/hooks` within Codex and approve the hooks. |
| `hook (failed) exited with code 1` | Stale placeholders in the plugin cache | Re-run the one-line installer. |
| Recall returns nothing | Server is unreachable or the URL is incorrect | Check the endpoint: `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` |
diff --git a/docs/images/agents/en/claude-code.md b/docs/images/agents/en/claude-code.md
index cbd74f507..b299cb413 100644
--- a/docs/images/agents/en/claude-code.md
+++ b/docs/images/agents/en/claude-code.md
@@ -16,6 +16,8 @@ After installation, activate the `claude` wrapper in your current terminal, or s
source ~/.openviking/openviking-repo/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
```
+> Launch Claude Code through a custom command? A wrapper script like `cc-custom`, or a multi-word launcher (a base command plus a sub-command) — list it at the installer's "Extra launch commands" step (or pass `OPENVIKING_CC_WRAP_EXTRA='cc-custom'`) to inject credentials there too.
+
After using it for a while, start a new conversation and ask about something you mentioned earlier. It should remember.
<details>
@@ -108,6 +110,8 @@ The plugin renders OpenViking status below the Claude Code input box: connection
| Plugin is not active | `ov.conf` / `ovcli.conf` cannot be found | Run [Step 1: Install](#step-1-install), or set `OPENVIKING_MEMORY_ENABLED=1` plus URL/API_KEY |
| Hooks run but recall is empty | Server is down or URL is wrong | `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` |
| MCP tools connect to `127.0.0.1` instead of remote | Missing shell function wrapper | Confirm `type claude` returns "shell function"; see [Step 1: Install](#step-1-install) |
+| `type claude` shows a path instead of a shell function (wrapper inactive) | The rc wasn't `source`d after install, or you launched from a terminal that didn't load it | Run `source ~/.zshrc` (or `~/.bashrc` on bash), or open a new terminal |
+| Launching via an alias (e.g. `cc`) injects no credentials | The alias *name* was listed in `OPENVIKING_CC_WRAP_EXTRA` (alias names are skipped), or the alias's target command isn't wrapped | Wrap the command the alias points to, not the alias: `alias cc=claude` needs nothing; for `alias cc=claude-custom`, add `claude-custom` |
| Remote auth returns 401 / 403 | API key is wrong or tenant headers are missing | Check `OPENVIKING_API_KEY`; for multi-tenant deployments also verify `OPENVIKING_ACCOUNT` / `OPENVIKING_USER` |
## Reference docs
diff --git a/docs/images/agents/en/codex.md b/docs/images/agents/en/codex.md
index ccf74280a..a3b3c8bcc 100644
--- a/docs/images/agents/en/codex.md
+++ b/docs/images/agents/en/codex.md
@@ -17,6 +17,8 @@ source ~/.openviking/openviking-repo/examples/codex-memory-plugin/setup-helper/w
codex # approve hooks once via /hooks on first launch
```
+> Launch Codex through a custom command? A wrapper script like `codex-custom`, or a multi-word launcher (a base command plus a sub-command) — list it at the installer's "Extra launch commands" step (or pass `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'`) to inject credentials there too.
+
<details>
<summary><b>Manual installation</b></summary>
@@ -68,6 +70,8 @@ For tuning options such as `OPENVIKING_RECALL_LIMIT` and `OPENVIKING_CAPTURE_ASS
| Symptom | Cause | Fix |
|---------|-------|-----|
| `MCP server is not logged in` | `OPENVIKING_API_KEY` is missing from the startup environment | Confirm the `codex()` function has been sourced and `ovcli.conf` contains an `api_key` |
+| `type codex` shows a path instead of a shell function (wrapper inactive) | The rc wasn't `source`d after install, or you launched from a terminal that didn't load it | Run `source ~/.zshrc` (or `~/.bashrc` on bash), or open a new terminal |
+| Launching via an alias (e.g. `cx`) injects no credentials | The alias *name* was listed in `OPENVIKING_CODEX_WRAP_EXTRA` (alias names are skipped), or the alias's target command isn't wrapped | Wrap the command the alias points to, not the alias: `alias cx=codex` needs nothing; for `alias cx=codex-custom`, add `codex-custom` |
| `4 hooks need review` | First-launch security approval is required | Type `/hooks` in Codex and approve them |
| `hook (failed) exited with code 1` after approval | Placeholders in the cache were not properly rendered | Rerun the one-line install script |
| Recall is empty | Server is unreachable or the URL is incorrect | Run `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` to test the connection |
diff --git a/docs/images/agents/zh/claude-code.md b/docs/images/agents/zh/claude-code.md
index 749a1f44d..928054adc 100644
--- a/docs/images/agents/zh/claude-code.md
+++ b/docs/images/agents/zh/claude-code.md
@@ -16,6 +16,8 @@ bash <(curl -fsSL https://raw.githubusercontent.com/volcengine/OpenViking/main/e
source ~/.openviking/openviking-repo/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
```
+> 通过自定义命令启动 Claude Code?例如包装脚本 `cc-custom`,或“基础命令 + 子命令”形式的多词启动器——在安装时的“Extra launch commands”一步填入(或运行脚本时传入 `OPENVIKING_CC_WRAP_EXTRA='cc-custom'`),即可让它们一并注入凭据。
+
使用一段时间后,即便在全新的对话中提及过往的话题,Claude Code 也能准确回忆起来。
<details>
@@ -112,6 +114,8 @@ type claude # 期望输出:claude is a shell function
| 插件未激活 | 未找到 `ov.conf` 或 `ovcli.conf` 配置文件 | 运行 [步骤 1:安装](#步骤-1安装),或手动设置 `OPENVIKING_MEMORY_ENABLED=1` 配合 URL/API_KEY 使用。 |
| Hook 已触发但召回结果为空 | 服务器未启动或 URL 配置错误 | 执行命令测试连通性:`curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` |
| MCP 工具连接到了 `127.0.0.1` 而非远程服务器 | 缺少 `claude` 函数封装 | 检查 `type claude` 的输出是否包含 "shell function";详情见 [步骤 1:安装](#步骤-1安装) |
+| `type claude` 显示的是路径而非 shell function(wrapper 未生效) | 安装后未 `source` rc,或在未加载该 rc 的终端里启动 | 执行 `source ~/.zshrc`(bash 用 `~/.bashrc`),或新开一个终端窗口 |
+| 通过别名(如 `cc`)启动,凭据未注入 | 把别名名填进了 `OPENVIKING_CC_WRAP_EXTRA`(别名会被跳过),或别名指向的命令未被封装 | 封装别名指向的真实命令而非别名本身:`alias cc=claude` 无需配置;`alias cc=claude-custom` 则把 `claude-custom` 填入 |
| 远程认证失败 (401 / 403) | API Key 错误或缺少租户 Header | 检查 `OPENVIKING_API_KEY` 是否正确;多租户环境下还需核对 `OPENVIKING_ACCOUNT` 和 `OPENVIKING_USER` |
diff --git a/docs/images/agents/zh/codex.md b/docs/images/agents/zh/codex.md
index 1cd8f4cae..69d30adcc 100644
--- a/docs/images/agents/zh/codex.md
+++ b/docs/images/agents/zh/codex.md
@@ -17,6 +17,8 @@ source ~/.openviking/openviking-repo/examples/codex-memory-plugin/setup-helper/w
codex # 首次启动需执行 /hooks 进行一次安全审批
```
+> 通过自定义命令启动 Codex?例如包装脚本 `codex-custom`,或“基础命令 + 子命令”形式的多词启动器——在安装时的“Extra launch commands”一步填入(或运行脚本时传入 `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'`),即可让它们一并注入凭据。
+
<details>
<summary><b>手动安装</b></summary>
@@ -71,6 +73,8 @@ type codex # 期望输出:codex is a shell function
| 现象 | 原因 | 解决方案 |
|------|------|------|
| `MCP server is not logged in` | 启动时 `OPENVIKING_API_KEY` 未注入环境变量 | 确认 `codex()` 函数已被 `source` 激活,且 `ovcli.conf` 中包含 `api_key` |
+| `type codex` 显示的是路径而非 shell function(wrapper 未生效) | 安装后未 `source` rc,或在未加载该 rc 的终端里启动 | 执行 `source ~/.zshrc`(bash 用 `~/.bashrc`),或新开一个终端窗口 |
+| 通过别名(如 `cx`)启动,凭据未注入 | 把别名名填进了 `OPENVIKING_CODEX_WRAP_EXTRA`(别名会被跳过),或别名指向的命令未被封装 | 封装别名指向的真实命令而非别名本身:`alias cx=codex` 无需配置;`alias cx=codex-custom` 则把 `codex-custom` 填入 |
| `4 hooks need review` | 首次启动触发的安全审批 | 在 Codex 中输入 `/hooks` 完成审批 |
| 审批后仍提示 `hook (failed) exited with code 1` | 缓存中的占位符未被正确替换 | 重新运行一次单行安装脚本 |
| 召回为空 | 服务器不可达或 URL 配置错误 | 运行 `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` 检查连接状态 |
diff --git a/docs/zh/agent-integrations/02-claude-code.md b/docs/zh/agent-integrations/02-claude-code.md
index 5f85050c8..5c7a9481f 100644
--- a/docs/zh/agent-integrations/02-claude-code.md
+++ b/docs/zh/agent-integrations/02-claude-code.md
@@ -18,6 +18,8 @@ bash <(curl -fsSL https://raw.githubusercontent.com/volcengine/OpenViking/main/e
source ~/.openviking/openviking-repo/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
```
+> 通过自定义命令启动 Claude Code?例如包装脚本 `cc-custom`,或“基础命令 + 子命令”形式的多词启动器——在安装时的“Extra launch commands”一步填入(或运行脚本时传入 `OPENVIKING_CC_WRAP_EXTRA='cc-custom'`),即可让它们一并注入凭据。
+
使用一段时间后,即便在全新的对话中提及过往的话题,Claude Code 也能准确回忆起来。
<details>
@@ -110,6 +112,8 @@ type claude # 期望输出:claude is a shell function
| 插件未激活 | 未找到 `ov.conf` 或 `ovcli.conf` 配置文件 | 运行 [安装脚本](#安装),或手动设置 `OPENVIKING_MEMORY_ENABLED=1` 配合 URL/API_KEY 使用。 |
| Hook 已触发但召回结果为空 | 服务器未启动或 URL 配置错误 | 执行命令测试连通性:`curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` |
| MCP 工具连接到了 `127.0.0.1` 而非远程服务器 | 缺少 `claude` 函数封装 | 检查 `type claude` 的输出是否包含 "shell function";详情见 [手动安装](#安装) |
+| `type claude` 显示的是路径而非 shell function(wrapper 未生效) | 安装后未 `source` rc,或在未加载该 rc 的终端里启动 | 执行 `source ~/.zshrc`(bash 用 `~/.bashrc`),或新开一个终端窗口 |
+| 通过别名(如 `cc`)启动,凭据未注入 | 把别名名填进了 `OPENVIKING_CC_WRAP_EXTRA`(别名会被跳过),或别名指向的命令未被封装 | 封装别名指向的真实命令而非别名本身:`alias cc=claude` 无需配置;`alias cc=claude-custom` 则把 `claude-custom` 填入 |
| 远程认证失败 (401 / 403) | API Key 错误或缺少租户 Header | 检查 `OPENVIKING_API_KEY` 是否正确;多租户环境下还需核对 `OPENVIKING_ACCOUNT` 和 `OPENVIKING_USER` |
## 参见
diff --git a/docs/zh/agent-integrations/04-codex.md b/docs/zh/agent-integrations/04-codex.md
index 3118d9a35..a64b70470 100644
--- a/docs/zh/agent-integrations/04-codex.md
+++ b/docs/zh/agent-integrations/04-codex.md
@@ -19,6 +19,8 @@ source ~/.openviking/openviking-repo/examples/codex-memory-plugin/setup-helper/w
codex # 首次启动需进入 /hooks 完成一次审批
```
+> 通过自定义命令启动 Codex?例如包装脚本 `codex-custom`,或“基础命令 + 子命令”形式的多词启动器——在安装时的“Extra launch commands”一步填入(或运行脚本时传入 `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'`),即可让它们一并注入凭据。
+
<details>
<summary><b>手动安装</b></summary>
@@ -70,6 +72,8 @@ type codex # 期望输出:codex is a shell function
| 现象 | 可能原因 | 修复方法 |
|------|------|------|
| `MCP server is not logged in` | 启动时环境变量中缺失 `OPENVIKING_API_KEY` | 确认已 source `codex()` 函数,且 `ovcli.conf` 中配置了 `api_key` |
+| `type codex` 显示的是路径而非 shell function(wrapper 未生效) | 安装后未 `source` rc,或在未加载该 rc 的终端里启动 | 执行 `source ~/.zshrc`(bash 用 `~/.bashrc`),或新开一个终端窗口 |
+| 通过别名(如 `cx`)启动,凭据未注入 | 把别名名填进了 `OPENVIKING_CODEX_WRAP_EXTRA`(别名会被跳过),或别名指向的命令未被封装 | 封装别名指向的真实命令而非别名本身:`alias cx=codex` 无需配置;`alias cx=codex-custom` 则把 `codex-custom` 填入 |
| `4 hooks need review` | 首次启动需要进行安全审批 | 在 Codex 终端内输入 `/hooks` 完成审批 |
| 审批后仍提示 `hook (failed) exited with code 1` | 缓存文件中的占位符未被正确渲染 | 重新执行一次一键安装脚本 |
| 召回结果为空 | 服务器不可达或 URL 配置错误 | 执行 `curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health"` 检查服务器状态 |
diff --git a/examples/claude-code-memory-plugin/README.md b/examples/claude-code-memory-plugin/README.md
index c5d664cd8..253d57ac6 100644
--- a/examples/claude-code-memory-plugin/README.md
+++ b/examples/claude-code-memory-plugin/README.md
@@ -127,7 +127,7 @@ claude() {
Re-source your rc (`source ~/.zshrc`, or `source ~/.bashrc` on bash) and restart `claude` — `/mcp` should then show your remote URL with valid auth.
-**Wrapping extra launch commands.** If you start Claude Code through a different command — a custom wrapper like `cc-custom`, or a multi-word launcher (a base command plus a sub-command) — the installer can wrap those too. Answer its "Extra launch commands" prompt, or pass `OPENVIKING_CC_WRAP_EXTRA='cc-custom'` when running it. The list is stored in the same rc marker block (read by the wrapper as `$OPENVIKING_CC_WRAP_EXTRA`); for a multi-word entry, only invocations whose leading args match the sub-command get credentials injected, so every *other* use of that command passes through untouched.
+**Wrapping extra launch commands.** If you start Claude Code through a different command — a custom wrapper like `cc-custom`, or a multi-word launcher (a base command plus a sub-command) — the installer can wrap those too. Answer its "Extra launch commands" prompt, or pass `OPENVIKING_CC_WRAP_EXTRA='cc-custom'` when running it. The list is stored in the same rc marker block (read by the wrapper as `$OPENVIKING_CC_WRAP_EXTRA`); for a multi-word entry, only invocations whose leading args match the sub-command get credentials injected, so every *other* use of that command passes through untouched. List the *real* launch command, never a shell alias of it: an alias expands to its target before the wrapper runs, so wrap what it points at — `alias cc=claude` already rides the base `claude` wrapper (add nothing), while `alias cc=claude-custom` is covered by listing `claude-custom`. Alias names are skipped if listed.
> **Why a function instead of `export`?** A globally exported API key leaks into every child process spawned from your shell — npm scripts, build tools, crash dumps, `/proc/<pid>/environ`. The function wrapper limits the secret to the `claude` process tree only.
>
diff --git a/examples/claude-code-memory-plugin/README_CN.md b/examples/claude-code-memory-plugin/README_CN.md
index 6c9b92ee0..a514e357f 100644
--- a/examples/claude-code-memory-plugin/README_CN.md
+++ b/examples/claude-code-memory-plugin/README_CN.md
@@ -127,6 +127,8 @@ claude() {
重新 source rc(`source ~/.zshrc`,bash 用户改成 `source ~/.bashrc`)后重启 `claude`——`/mcp` 应该显示远程 URL 且认证有效。
+**封装其他启动命令。** 如果你通过别的命令启动 Claude Code——比如自定义包装脚本 `cc-custom`,或“基础命令 + 子命令”形式的多词启动器——安装脚本也能一并封装:在它的“Extra launch commands”提示里填写,或运行时传入 `OPENVIKING_CC_WRAP_EXTRA='cc-custom'`。该列表存在同一段 rc 标记块里(wrapper 读取为 `$OPENVIKING_CC_WRAP_EXTRA`);对多词条目,只有前导参数匹配该子命令的调用才会注入凭据,该命令的其他用法原样放行。**填的是真实命令名,绝不是它的 shell 别名**:别名会在 wrapper 运行前先展开成目标命令,所以封装它指向的那个——`alias cc=claude` 本就走 base `claude` 封装(无需配置),而 `alias cc=claude-custom` 则把 `claude-custom` 填进去即可;别名名若被填入会被跳过。
+
> **为什么用 function 而不是 `export`?** 全局 export 的 API Key 会被该 shell 派生的所有子进程继承——npm 脚本、构建工具、崩溃 dump、`/proc/<pid>/environ` 都会带上。函数包装把秘钥限定在 `claude` 进程树内。
>
> 还没有 `ovcli.conf`?先按 [部署指南 → CLI 章节](../../docs/zh/guides/03-deployment.md#cli) 创建一份。
diff --git a/examples/claude-code-memory-plugin/setup-helper/wrapper.sh b/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
index e729eb058..bcf6bf6be 100644
--- a/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
+++ b/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
@@ -85,9 +85,19 @@ _openviking_define_wrappers() {
esac
_ov_head="${_ov_entry%% *}"
if [ "$_ov_head" = "$_ov_entry" ]; then _ov_sub=""; else _ov_sub="${_ov_entry#* }"; fi
+ # Reject empty, leading-`-` (would be misread as an option by `alias`
+ # below and `command` in the dispatcher), or any non-word-char head.
case "$_ov_head" in
- ''|*[!A-Za-z0-9_-]*) continue ;;
+ ''|-*|*[!A-Za-z0-9_-]*) continue ;;
esac
+ # A same-named shell alias (e.g. `alias cc=claude`) already routes through
+ # the base `claude` wrapper once it expands, so it needs no function here —
+ # and defining one is actively harmful: bash expands the alias mid-eval and
+ # clobbers the real wrapper, while zsh aborts with a parse error on every
+ # shell start. Skip alias names; they're covered for free.
+ if alias "$_ov_head" >/dev/null 2>&1; then
+ continue
+ fi
eval "${_ov_head}() { _openviking_dispatch \"$_ov_helper\" \"$_ov_head\" \"$_ov_sub\" \"\$@\"; }"
done
}
diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.md
index 375053630..95e657c4f 100644
--- a/examples/codex-memory-plugin/README.md
+++ b/examples/codex-memory-plugin/README.md
@@ -100,7 +100,7 @@ For **unauthenticated local OV** (`ovcli.conf` without `api_key`, or no ovcli.co
The `codex()` shell-function wrapper **re-renders this field on every codex launch** based on the currently-active `ovcli.conf` (the one `OPENVIKING_CLI_CONFIG_FILE` points at, falling back to `~/.openviking/ovcli.conf`). That means you can switch between authenticated and unauthenticated OV — e.g. to isolate a benchmark run from production memory — by just changing `OPENVIKING_CLI_CONFIG_FILE` before invoking `codex`, with no re-install needed. The wrapper also omits empty env-var assignments entirely (so `OPENVIKING_API_KEY=` is never passed to codex), keeping `env_http_headers` for identity (`X-OpenViking-Account` / `X-OpenViking-User`) intact.
-**Wrapping extra launch commands.** If you start Codex through a different command — a custom wrapper like `codex-custom`, or a multi-word launcher (a base command plus a sub-command) — the installer can wrap those too. Answer its "Extra launch commands" prompt, or pass `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'` when running it (the env-var form is also what to use when piping the installer through a non-interactive shell). The list is stored in the same rc marker block (read by the wrapper as `$OPENVIKING_CODEX_WRAP_EXTRA`); for a multi-word entry, only invocations whose leading args match the sub-command get the credential injection + `.mcp.json` re-render, so every *other* use of that command passes through untouched.
+**Wrapping extra launch commands.** If you start Codex through a different command — a custom wrapper like `codex-custom`, or a multi-word launcher (a base command plus a sub-command) — the installer can wrap those too. Answer its "Extra launch commands" prompt, or pass `OPENVIKING_CODEX_WRAP_EXTRA='codex-custom'` when running it (the env-var form is also what to use when piping the installer through a non-interactive shell). The list is stored in the same rc marker block (read by the wrapper as `$OPENVIKING_CODEX_WRAP_EXTRA`); for a multi-word entry, only invocations whose leading args match the sub-command get the credential injection + `.mcp.json` re-render, so every *other* use of that command passes through untouched. List the *real* launch command, never a shell alias of it: an alias expands to its target before the wrapper runs, so wrap what it points at — `alias cx=codex` already rides the base `codex` wrapper (add nothing), while `alias cx=codex-custom` is covered by listing `codex-custom`. Alias names are skipped if listed.
### Tuning the plugin
diff --git a/examples/codex-memory-plugin/setup-helper/wrapper.sh b/examples/codex-memory-plugin/setup-helper/wrapper.sh
index c998d4b7d..b915a0517 100644
--- a/examples/codex-memory-plugin/setup-helper/wrapper.sh
+++ b/examples/codex-memory-plugin/setup-helper/wrapper.sh
@@ -172,9 +172,19 @@ _openviking_define_wrappers() {
esac
_ov_head="${_ov_entry%% *}"
if [ "$_ov_head" = "$_ov_entry" ]; then _ov_sub=""; else _ov_sub="${_ov_entry#* }"; fi
+ # Reject empty, leading-`-` (would be misread as an option by `alias`
+ # below and `command` in the dispatcher), or any non-word-char head.
case "$_ov_head" in
- ''|*[!A-Za-z0-9_-]*) continue ;;
+ ''|-*|*[!A-Za-z0-9_-]*) continue ;;
esac
+ # A same-named shell alias (e.g. `alias cx=codex`) already routes through
+ # the base `codex` wrapper once it expands, so it needs no function here —
+ # and defining one is actively harmful: bash expands the alias mid-eval and
+ # clobbers the real wrapper, while zsh aborts with a parse error on every
+ # shell start. Skip alias names; they're covered for free.
+ if alias "$_ov_head" >/dev/null 2>&1; then
+ continue
+ fi
eval "${_ov_head}() { _openviking_dispatch \"$_ov_helper\" \"$_ov_head\" \"$_ov_sub\" \"\$@\"; }"
done
}