opencode-c3-plugin
v0.2.0
Published
An opencode plugin that attaches a stable, opaque, non-PII user identifier to Anthropic API calls.
Readme
opencode-c3-plugin
An opencode plugin that automatically generates a stable, opaque metadata.user_id for every Anthropic API call made through opencode.
opencode does not set a user identifier by default. This plugin adds one — derived deterministically from the current project and session, so it stays consistent without exposing any personally identifiable information.
Install
Add the plugin to your opencode config (opencode.json or ~/.config/opencode/opencode.json):
{
"plugins": ["opencode-c3-plugin"]
}Or point at a local checkout:
{
"plugins": ["./path/to/opencode-c3-plugin/dist/index.js"]
}Then restart opencode.
What it does
On each chat turn that uses the @ai-sdk/anthropic provider, the plugin sets metadata.userId to a JSON value with three opaque fields:
{
"device_id": "<64-char hex>",
"account_uuid": "<uuid>",
"session_id": "<uuid>"
}device_idandaccount_uuidare derived from the opencode project id (stable per project).session_idis derived from the opencode session id (stable within a session).
All three are SHA-256 derivations — opaque, with no embedded PII. Non-Anthropic providers are left untouched, and an existing metadata.userId is never overwritten.
Configuration
To pin a fixed identifier instead of the derived one, set:
export OPENCODE_ANTHROPIC_USER_ID="your-opaque-id-here"The value must be opaque and contain no PII (UUIDs, prefixed tokens like user_abc123, or hex strings). An invalid value throws; an empty value is treated as unset.
Development
npm install
npm run typecheck && npm run test
npm run buildLicense
MIT — see LICENSE.
