OpenCode plugin for using CloakPipe as a privacy layer.
The plugin masks provider-bound prompt and tool-history text through CloakPipe, then restores placeholders in completed assistant text and local tool arguments.
If you use a different coding tool, similar CloakPipe integrations are also available for:
Claude Code hooks cannot replace the prompt before Claude Code sends it to the provider, so claude-cloakpipe uses a local Anthropic-compatible gateway.
OpenCode exposes provider-bound chat transform hooks. This plugin uses those hooks directly, so the MVP does not need a provider gateway.
- OpenCode prepares the message history for a provider call.
opencode-cloakpipehandlesexperimental.chat.messages.transformand calls CloakPipe/v1/pseudonymizefor text fields.- The provider receives placeholders instead of plaintext sensitive values.
- When assistant text completes,
experimental.text.completecalls CloakPipe/v1/rehydrateso local display is natural. - Before local tools run,
tool.execute.beforerehydrates tool args so shell commands and file edits use real local values.
Historical tool inputs and outputs are also masked before each provider call. OpenCode may store real local tool args and output, so this step prevents old local tool data from leaking in later turns.
OpenCode supports two standard plugin install paths:
- npm package config, managed by
opencode plugin <module>. - local plugin files under
.opencode/plugins/or~/.config/opencode/plugins/.
Use the npm path after this package is published:
opencode plugin opencode-cloakpipeInstall it globally for every project:
opencode plugin opencode-cloakpipe --globalOpenCode records npm plugins in opencode.json or ~/.config/opencode/opencode.json, then installs packages with Bun at startup. You can also edit config directly:
Pass plugin options with the tuple form:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
[
"opencode-cloakpipe",
{
"baseUrl": "http://127.0.0.1:3100/v1",
"strict": true,
"debug": false
}
]
]
}For local development, build this checkout and install a local plugin shim:
npm install
npm run build
npx opencode-cloakpipe installThe helper writes .opencode/plugins/opencode-cloakpipe.js, which OpenCode loads automatically at startup. Install the shim globally when you want this checkout available in every project:
npx opencode-cloakpipe install --globalInstall into a custom config directory when you launch OpenCode with OPENCODE_CONFIG_DIR:
npx opencode-cloakpipe install --config-dir /path/to/opencode-config-dir
OPENCODE_CONFIG_DIR=/path/to/opencode-config-dir opencodeRe-run the install helper after moving or rebuilding this checkout. Use --force if an older shim already exists.
You can still load the built file explicitly from opencode.json during development:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["file://../opencode-cloakpipe/dist/index.js"]
}Options in opencode.json override environment variables. Environment variables override defaults.
| Option | Environment variable | Default |
|---|---|---|
enabled |
OPENCODE_CLOAKPIPE_ENABLED |
true |
baseUrl |
OPENCODE_CLOAKPIPE_BASE_URL, then CLOAKPIPE_BASE_URL |
http://127.0.0.1:3100/v1 |
strict |
OPENCODE_CLOAKPIPE_STRICT |
true |
timeoutMs |
OPENCODE_CLOAKPIPE_TIMEOUT_MS |
30000 |
healthTimeoutMs |
OPENCODE_CLOAKPIPE_HEALTH_TIMEOUT_MS |
3000 |
debug |
OPENCODE_CLOAKPIPE_DEBUG |
false |
transformSystem |
OPENCODE_CLOAKPIPE_TRANSFORM_SYSTEM |
true |
restoreAssistantText |
OPENCODE_CLOAKPIPE_RESTORE_ASSISTANT_TEXT |
true |
restoreToolArgs |
OPENCODE_CLOAKPIPE_RESTORE_TOOL_ARGS |
true |
transformToolDefinitions |
OPENCODE_CLOAKPIPE_TRANSFORM_TOOL_DEFINITIONS |
false |
extraSkipKeys / skipKeys |
OPENCODE_CLOAKPIPE_EXTRA_SKIP_KEYS |
none |
skipKeys and extraSkipKeys add keys to the default skip list. The default list preserves structural and binary fields such as id, sessionID, type, role, url, data, and signature.
Check resolved config and CloakPipe health:
npm run build
npx opencode-cloakpipe doctorPrint non-secret config:
npx opencode-cloakpipe print-config- Provider-bound message history and system prompts are masked before transport.
- Historical tool inputs and outputs are masked before later provider calls.
- Assistant text and tool args are restored locally when the matching hooks run.
- Logs include hook names, status, and counts only. They must not include raw prompt text, tool output, or credentials.
- OpenCode local storage may still contain restored plaintext. Treat local-at-rest redaction as a separate mode, not part of this MVP.
- The key OpenCode hooks are currently experimental. Pin and test against the OpenCode version you use.
- Streaming deltas may briefly show placeholders until
experimental.text.completerestores the final text. - The MVP is text-first. It skips structural and binary-looking fields.
- CloakPipe must be running before strict-mode provider calls.
transformToolDefinitionsis off by default because rewriting tool descriptions can reduce tool clarity.
Run all checks:
npm test
npm run typecheckUseful files:
src/index.ts— plugin hooks.src/config.ts— option and env parsing.src/privacy.ts— CloakPipe HTTP client.src/transforms.ts— message, system, and tool-arg transforms.src/cli.ts— doctor command.tests/— Node test suite with a fake CloakPipe server.
{ "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-cloakpipe"] }