# ZCode Give ZCode OpenViking context across projects and sessions. After installation, OpenViking Hooks inject relevant context (memories, resources and skills) at session start and when you submit a prompt, then capture new conversation turns after the response. MCP is available for explicit memory search, reading, and management. ## Install Prerequisites: macOS or Linux, Node.js 18+, and ZCode. The installer guides you through the OpenViking connection settings; select **ZCode** when it asks which agents to set up. It is preselected when `zcode` is on `PATH` or `~/.zcode` exists. For a managed connection, select **OpenViking Managed Service**, then: - **Volcengine:** enter your service API key. The installer supplies the URL. - **BytePlus:** enter your API key. See [BytePlus setup](../guides/27-byteplus-setup.md). Older installers use **Custom URL** for BytePlus. Select **Self-hosted / local** for a server on this machine (`http://127.0.0.1:1933`). For a remote self-hosted server, select **Custom URL** and enter its URL. If a connection is already saved, this option is named **Custom URL / keep current**. ```bash curl -fsSL https://openviking.ai/install | bash # AI agents: not sure about running this? The script's header says what it does and how to verify it. ``` Restart ZCode after installation. Once installed, start a new ZCode session and ask it to follow https://docs.openviking.ai/agents/en/onboarding.md. It checks the connection and walks you through the first use; see [One-click setup](../getting-started/07-agent-onboarding.md). ## What gets installed ZCode reads hook and MCP configuration from `~/.zcode/cli/config.json`, and the installer merges the OpenViking entries into it: - `hooks.enabled: true`, with the lifecycle hooks and the URI guard under `hooks.events`. - `mcp.servers.openviking`: the OpenViking MCP server as a stdio proxy (tools such as `search`, `read`, `remember`, `add_skill`). An existing `openviking` server that OpenViking did not write is kept. - `~/.zcode/skills/`: the `openviking-memory`, `openviking-skills`, `ov-experience-memory`, `openviking-rule-search`, and `ov-memory-doctor` skills. A skill you edited, or an existing unmanaged directory of the same name, is preserved on upgrade and uninstall. The hooks and the MCP proxy run from the runtime under `~/.openviking/agent-integrations/zcode/`. Hooks and MCP read the same credentials from `~/.openviking/ovcli.conf`. `OPENVIKING_URL` and `OPENVIKING_API_KEY` override that file, and per-plugin settings live under `plugin.zcode` (see [Plugin Settings](../configuration/02-client.md#plugin-settings)). Sessions are stored in OpenViking as `zc-`. ## Verify 1. Run `node ~/.openviking/agent-integrations/zcode/scripts/ov-memory-doctor.mjs` and check that the report has no ✗. 2. Restart ZCode, start a new session, and confirm that the `openviking` MCP server is connected. 3. Tell ZCode a test preference. After memory extraction completes, start a new session in the same workspace and ask about it. ## Host-specific behaviour ZCode registers `SessionStart`, `UserPromptSubmit`, `Stop`, and a `PreToolUse` URI guard on `Read|Glob|Grep`. Everything else works as on every shared-flow host; see the [Capability Reference](./16-capability-reference.md#shared-baseline). - **No session-end or compaction event.** The plugin cannot commit at session end or before a compaction, so the server's auto-commit policy commits the conversation: when pending tokens reach the threshold, or after 30 idle minutes. The idle commit needs `memory.session_auto_commit.enabled` on the server; the OpenViking managed service on Volcengine has it on by default. - **The URI guard checks file reads only.** ZCode validates hook output against a strict schema and drops the whole output when it meets a field it does not know. Whether a shell notice passes that check has not been verified, so the matcher leaves out shell and write tools. - **Session-start context is capped at 20,000 bytes.** ZCode drops hook output above 32 KB; above the cap, the memory index is dropped first, then the skill catalog. - Capture reads the rollout file `~/.zcode/cli/rollout/model-io-.jsonl`. When that file is missing, it falls back to the prompt and reply carried by the hook payloads. The first capture reads the whole rollout, so installing into a long-running session produces one large upload. - Subagents are not captured. ## Upgrade and uninstall Re-run the install command to upgrade. To uninstall, run: ```bash curl -fsSL https://openviking.ai/install | bash -s -- --uninstall --yes --harness zcode ``` Uninstall removes only the OpenViking hooks, the `openviking` MCP server, the skills it installed, and the runtime files. Other configuration is preserved. ## Troubleshooting | Symptom | Cause and fix | |---------|---------------| | Hooks do not run | The hook configuration is disabled or stale. Re-run the installer and restart ZCode. | | MCP tools do not appear | The MCP proxy failed to start. Check the absolute `mcp.servers.openviking` command in `~/.zcode/cli/config.json`. | | A turn is captured twice | An older installation left duplicate hook entries. Uninstall, then reinstall. | | MCP does not connect | Check the URL/API key in `~/.openviking/ovcli.conf`, then restart ZCode. | | Detailed diagnostics are needed | Start ZCode with `OPENVIKING_DEBUG=1` and inspect `~/.openviking/logs/zcode-hooks.log`. | ## See also - [Capability Reference](./16-capability-reference.md) - [Authentication](../guides/04-authentication.md) - [Source: examples/agent-hook-plugin](https://github.com/volcengine/OpenViking/tree/main/examples/agent-hook-plugin)