GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - khaosoi/opencode-redact: Two-way secret redaction plugin for OpenCode v2

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 
README.zh-TW.md
README.zh-TW.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

opencode-redact

Two-way secret redaction for OpenCode v2.

English · 繁體中文 · 简体中文

license

opencode-redact replaces API keys, tokens, passwords and other secrets in your OpenCode conversation with stable placeholders before they are sent to the model, then swaps them back just before a tool runs. The model never sees the secret; the tool still gets the real value.

Why

OpenCode v2 changed the plugin API, so V1 privacy plugins such as opencode-vibeguard no longer load — and v2 ships no built-in redaction. opencode-redact fills that gap with a small, dependency-free plugin written for the v2 hook API.

How it works

                    redact                     rehydrate
prompt ──▶ [REDACTED:aws-access-key:…] ──▶ model ──▶ tool input ──▶ real secret
           (prompt + context hooks)                 (execute.before hook)
  • prompt — redacts the text you type, before it is persisted.
  • context — redacts the system prompt, message history (including earlier tool output) and tool definitions right before the request is sent.
  • execute.before — swaps placeholders back to the real secret in the tool input, so the command that needs it still works.

Every secret becomes a stable token [REDACTED:<rule>:<fingerprint>]. The same secret always yields the same token, so the model can still refer to it.

Install

This fork is not published to npm (unlike the upstream project), so it can only be installed as a local plugin.

Global drop-in — copy src/index.ts to ~/.config/opencode/plugins/redact/index.ts. Global plugins are auto-loaded and need no config entry.

Project-level drop-in — copy src/index.ts to .opencode/plugins/redact.ts in the project.

Alternatively, point your config at a checkout of this repo:

// ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["/absolute/path/to/opencode-redact/src/index.ts"]
}

Restart OpenCode (or run opencode service restart) after copying or changing the file.

Detected secrets

Rule Matches
aws-access-key AKIA…, ASIA…, AGPA…, …
gcp-api-key AIza…
github-pat ghp_, gho_, ghu_, ghs_, ghr_
github-fine-grained github_pat_…
gitlab-pat glpat-…
openai-key sk-…, sk-proj-…
anthropic-key sk-ant-…
slack-token xoxb-, xoxa-, xoxp-, xoxr-, xoxs-
stripe-key sk_live_, sk_test_, rk_live_, rk_test_
npm-token npm_…
pypi-token pypi-…
jwt three dot-separated base64url segments starting eyJ
private-key PEM -----BEGIN … PRIVATE KEY----- blocks
credential password: …, api_key=…, secret=…, token: …

*KEY environment variables

At startup the plugin registers the values of every environment variable whose name ends in KEY (minimum 8 characters). Any occurrence of those exact values — pasted into the prompt, echoed by a tool (printenv) or shown in a file — is replaced before it reaches the model, and rehydrated just before a tool runs:

printenv STRIPE_KEY   →   the model sees [REDACTED:env-stripe-key:0000c281e114]

Tokens for seeded variables are deterministic fingerprints of the value and are re-registered on every plugin load, so placeholders from earlier history keep rehydrating across opencode service restart for as long as the variable remains in the environment.

Coverage & limits

Protected — your prompt, system prompt, message history (incl. tool output) and tool definitions on the way out; tool input on the way in.

Not protected

  • Secret formats not listed above.
  • Base64-encoded, encrypted or split secrets, and passwords with no key = value shape.
  • Large/binary strings (data: URIs, oversized base64) are skipped on purpose so images and files are never corrupted.
  • The vault is in-process: after a service restart, placeholders in old history can no longer be rehydrated.
  • Rehydration depends on the model echoing a placeholder verbatim.

Redaction guards what leaves your machine. It is one layer of defence, not a reason to paste real credentials into a conversation.

Compatibility

OpenCode v2.0.18+ (v2 prompt, context, tool.execute.before hooks) · Node 20+.

Development

npm install
npm run build     # tsc -> dist/
npm test          # build + node --test

Credits

This is a fork of opencode-redact by kk Cheng (@kkchengg), MIT-licensed. The two-way redaction design, the [REDACTED:<rule>:<fingerprint>] placeholder format, the detection rules, hooks, rehydration, and the deep-walking redactor are all the original author's work.

This fork's only addition so far is the *KEY environment-variable seeding (described above) and its tests. Everything else is upstream, unchanged.

License

MIT — © kk Cheng, the original opencode-redact author. The fork's additions inherit the same MIT licence.

About

Two-way secret redaction plugin for OpenCode v2

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.