Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README_JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ OpenViking統合後:

👉 **[参照: OpenClawコンテキストプラグイン](examples/openclaw-plugin/README.md)**

👉 **[参照: OpenCodeメモリプラグインの例](examples/opencode-memory-plugin/README.md)**
👉 **[参照: OpenCode統合プラグイン](examples/opencode-plugin/README.md)**

👉 **[参照: Claude Codeメモリプラグインの例](examples/claude-code-memory-plugin/README.md)**

Expand Down
128 changes: 120 additions & 8 deletions docs/en/agent-integrations/08-community-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,130 @@ Provides auto-capture of group/DM conversations, semantic recall before each LLM
- Four auto-commit triggers: message count, token threshold, idle timeout, and process-exit flush
- Backfills platform message history on first venue encounter

## OpenCode plugins
## OpenCode plugin

Two OpenCode plugin variants exist with different design choices. Pick whichever matches your usage.
OpenViking provides one unified OpenCode plugin for repository context and long-term memory workflows.

### `opencode-memory-plugin` — explicit-tool variant
Source: [examples/opencode-plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-plugin)

Source: [examples/opencode-memory-plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-memory-plugin)
The plugin combines indexed repository context, OpenViking memory tools, session synchronization, lifecycle commit, and automatic recall through OpenCode plugin hooks. Use this plugin for both the former explicit-tool and context-injection use cases.

### Prerequisites

Exposes OpenViking memories as explicit OpenCode tools. The agent decides when to call them, and data is fetched on demand rather than pre-injected.
- [OpenCode](https://opencode.ai/)
- Node.js and npm
- An OpenViking HTTP server
- An OpenViking API key when your server requires authentication

### `opencode/plugin` — context-injection variant
Start your OpenViking server first:

Source: [examples/opencode/plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode/plugin)
```bash
openviking-server --config ~/.openviking/ov.conf
```

Injects indexed code repos into OpenCode's context and auto-starts the OpenViking server when needed.
In another terminal, check the service:

```bash
curl http://localhost:1933/health
```

### Install

If you are using the published package, add the plugin to `~/.config/opencode/opencode.json`. If package installation is not available in your environment yet, use the source install path below.

```json
{
"plugin": ["openviking-opencode-plugin"]
}
```

For development, debugging, or PR testing, install the plugin from this repository instead:

```bash
git clone https://github.com/volcengine/OpenViking.git
cd OpenViking
mkdir -p ~/.config/opencode/plugins/openviking
cp examples/opencode-plugin/wrappers/openviking.mjs ~/.config/opencode/plugins/openviking.mjs
cp examples/opencode-plugin/index.mjs examples/opencode-plugin/package.json ~/.config/opencode/plugins/openviking/
cp -r examples/opencode-plugin/lib ~/.config/opencode/plugins/openviking/
cd ~/.config/opencode/plugins/openviking
npm install
```

This source install creates the layout OpenCode can discover:

```text
~/.config/opencode/plugins/
├── openviking.mjs
└── openviking/
├── index.mjs
├── package.json
├── lib/
└── node_modules/
```

The top-level `openviking.mjs` is only a wrapper that forwards OpenCode's first-level plugin entry to the installed package directory.

### Configure

Create `~/.config/opencode/openviking-config.json`:

```json
{
"endpoint": "http://localhost:1933",
"apiKey": "",
"account": "",
"user": "",
"peerId": "",
"enabled": true,
"timeoutMs": 30000,
"repoContext": { "enabled": true, "cacheTtlMs": 60000 },
"autoRecall": {
"enabled": true,
"limit": 6,
"scoreThreshold": 0.15,
"maxContentChars": 500,
"preferAbstract": true,
"tokenBudget": 2000
}
}
```

Prefer environment variables for secrets:

```bash
export OPENVIKING_API_KEY="your-api-key-here"
export OPENVIKING_ACCOUNT="default" # optional, trusted-mode deployments only
export OPENVIKING_USER="opencode" # optional, trusted-mode deployments only
export OPENVIKING_PEER_ID="opencode" # optional, peer-scoped memory routing
```

Environment variables override `openviking-config.json`. `apiKey` is sent as `X-API-Key`; `account` and `user` are trusted-mode headers; `peerId` is sent as request-level `peer_id` for recall, search, and captured session messages.

### Verify

Restart OpenCode after installation. In an OpenCode session, the plugin should expose these tools:

- `memsearch`, `memread`, `membrowse`
- `memgrep`, `memglob`
- `memadd`, `memremove`, `memqueue`
- `memcommit`

Ask OpenCode to search or browse OpenViking memory, or request a manual session commit. Runtime state and errors are written to:

```bash
~/.config/opencode/openviking/openviking-memory.log
~/.config/opencode/openviking/openviking-session-map.json
```

### Troubleshooting

| Issue | What to check |
|-------|---------------|
| Plugin does not load | Confirm `~/.config/opencode/opencode.json` references `openviking-opencode-plugin`, or that `~/.config/opencode/plugins/openviking.mjs` exists for source installs |
| Tools call the wrong server | Check `endpoint` in `~/.config/opencode/openviking-config.json`, or set `OPENVIKING_PLUGIN_CONFIG` to the intended config path |
| 401 / 403 from OpenViking | Verify `OPENVIKING_API_KEY`; for trusted-mode deployments, also verify `OPENVIKING_ACCOUNT` and `OPENVIKING_USER` |
| Recall is empty | Confirm the OpenViking server has indexed memories/resources and that `autoRecall.enabled` is `true` |
| Local `memadd` fails | Pass a file path, not a directory; local directories are not uploaded automatically yet |

For all available tools, configuration fields, and runtime file details, see the [plugin README](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-plugin).
2 changes: 1 addition & 1 deletion docs/images/agents/en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"name": "OpenCode",
"tags": ["Plugin"],
"logo": "https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_sth/ljhwZthlaukjlkulzlp/agent_logo/OpenCode.png",
"summary": "Provides OpenCode plugins that can expose OpenViking either as model-selected tools or injected context.",
"summary": "Provides one unified OpenCode plugin for repository context, memory tools, session sync, and automatic recall.",
"detailPath": "https://docs.openviking.net/agents/en/opencode.md"
}
]
Expand Down
120 changes: 113 additions & 7 deletions docs/images/agents/en/opencode.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,119 @@
OpenCode has two plugin variants with different designs. Choose the one that matches how you want to use it.
OpenViking provides one unified OpenCode plugin for repository context and long-term memory workflows.

## Option 1: `opencode-memory-plugin` - Explicit tool version
## `opencode-plugin`

Source: [examples/opencode-memory-plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-memory-plugin)
Source: [examples/opencode-plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-plugin)

This variant exposes OpenViking memory as explicit tools through OpenCode's tool mechanism. The model decides when to call them, and data is fetched on demand.
The plugin combines indexed repository context, OpenViking memory tools, session synchronization, lifecycle commit, and automatic recall through OpenCode plugin hooks.

## Option 2: `opencode/plugin` - Context injection version
## Step 1: Prepare OpenViking

Source: [examples/opencode/plugin](https://github.com/volcengine/OpenViking/tree/main/examples/opencode/plugin)
Install OpenCode, Node.js/npm, and an OpenViking HTTP server. Start the server before launching OpenCode:

This variant injects indexed code repositories into OpenCode context and starts the OpenViking server automatically when needed.
```bash
openviking-server --config ~/.openviking/ov.conf
```

In another terminal, check the service:

```bash
curl http://localhost:1933/health
```

For remote or multi-tenant deployments, prepare an OpenViking API key.

## Step 2: Install the plugin

For a published package install, add the plugin to `~/.config/opencode/opencode.json`. If package installation is not available in your environment yet, use the source install path below.

```json
{
"plugin": ["openviking-opencode-plugin"]
}
```

For development, debugging, or PR testing, copy the plugin from the OpenViking repository:

```bash
git clone https://github.com/volcengine/OpenViking.git
cd OpenViking
mkdir -p ~/.config/opencode/plugins/openviking
cp examples/opencode-plugin/wrappers/openviking.mjs ~/.config/opencode/plugins/openviking.mjs
cp examples/opencode-plugin/index.mjs examples/opencode-plugin/package.json ~/.config/opencode/plugins/openviking/
cp -r examples/opencode-plugin/lib ~/.config/opencode/plugins/openviking/
cd ~/.config/opencode/plugins/openviking
npm install
```

The source install creates:

```text
~/.config/opencode/plugins/
├── openviking.mjs
└── openviking/
├── index.mjs
├── package.json
├── lib/
└── node_modules/
```

## Step 3: Configure the OpenViking connection

Create `~/.config/opencode/openviking-config.json`:

```json
{
"endpoint": "http://localhost:1933",
"apiKey": "",
"account": "",
"user": "",
"peerId": "",
"enabled": true,
"timeoutMs": 30000,
"repoContext": { "enabled": true, "cacheTtlMs": 60000 },
"autoRecall": {
"enabled": true,
"limit": 6,
"scoreThreshold": 0.15,
"maxContentChars": 500,
"preferAbstract": true,
"tokenBudget": 2000
}
}
```

Prefer environment variables for secrets:

```bash
export OPENVIKING_API_KEY="your-api-key-here"
export OPENVIKING_ACCOUNT="default" # optional, trusted-mode deployments only
export OPENVIKING_USER="opencode" # optional, trusted-mode deployments only
export OPENVIKING_PEER_ID="opencode" # optional, peer-scoped memory routing
```

Environment variables override the config file.

## Step 4: Verify

Restart OpenCode. The plugin should expose `memsearch`, `memread`, `membrowse`, `memgrep`, `memglob`, `memadd`, `memremove`, `memqueue`, and `memcommit`.

Ask OpenCode to browse OpenViking or commit the current session. Check runtime logs if anything looks wrong:

```bash
~/.config/opencode/openviking/openviking-memory.log
~/.config/opencode/openviking/openviking-session-map.json
```

## Troubleshooting

| Symptom | Fix |
|---------|-----|
| Plugin is not loaded | Check `~/.config/opencode/opencode.json` for package installs, or `~/.config/opencode/plugins/openviking.mjs` for source installs |
| Tools call the wrong server | Check `endpoint`, or set `OPENVIKING_PLUGIN_CONFIG` to the intended config path |
| 401 / 403 from OpenViking | Verify `OPENVIKING_API_KEY`; trusted-mode deployments also need `OPENVIKING_ACCOUNT` and `OPENVIKING_USER` |
| Recall is empty | Confirm OpenViking has memories/resources and `autoRecall.enabled` is `true` |

## Reference docs

- [Plugin README](https://github.com/volcengine/OpenViking/tree/main/examples/opencode-plugin) - full tool list, configuration fields, and runtime details
- [Deployment Guide](https://www.openviking.ai/en/guides/03-deployment) - setting up OpenViking server and CLI config
2 changes: 1 addition & 1 deletion docs/images/agents/zh/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"name": "OpenCode",
"tags": ["Plugin"],
"logo": "https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_sth/ljhwZthlaukjlkulzlp/agent_logo/OpenCode.png",
"summary": "提供两种 OpenCode 插件,可以模型自主选择使用,也可以注入上下文使用",
"summary": "提供一个统一 OpenCode 插件,支持仓库上下文、记忆工具、session 同步与自动 recall",
"detailPath": "https://docs.openviking.net/agents/zh/opencode.md"
}
]
Expand Down
Loading