@rehydra/opencode 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @rehydra/opencode
2
+
3
+ Prevent your coding agent from leaking secrets to LLM providers.
4
+
5
+ This plugin intercepts the conversation between [OpenCode](https://github.com/sst/opencode) and the LLM. Secrets from your `.env` files are replaced with placeholders before they leave your machine, and transparently restored before any tool (shell commands, file writes, etc.) executes locally.
6
+
7
+ The LLM never sees real secret values. Your tools run with them.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @rehydra/opencode
13
+ ```
14
+
15
+ Add to `opencode.json`:
16
+
17
+ ```json
18
+ {
19
+ "plugin": ["@rehydra/opencode"]
20
+ }
21
+ ```
22
+
23
+ By default, the plugin reads `.env` in your project root. Secrets with values of 4+ characters are detected and scrubbed.
24
+
25
+ ## Configuration
26
+
27
+ For custom settings, create `.opencode/plugins/rehydra.ts`:
28
+
29
+ ```typescript
30
+ import { createRehydraPlugin } from "@rehydra/opencode";
31
+
32
+ export default createRehydraPlugin({
33
+ // Scan multiple env files
34
+ envFiles: [".env", ".env.local", ".env.production"],
35
+
36
+ // Always redact these values, even if not in .env
37
+ redactValues: ["sk-live-abc123..."],
38
+
39
+ // Minimum value length to consider a secret (default: 4)
40
+ minValueLength: 6,
41
+
42
+ // Disable detection of specific PII types
43
+ disableTypes: ["URL", "IP_ADDRESS"],
44
+ });
45
+ ```
46
+
47
+ ## What gets detected
48
+
49
+ - Environment variable values from `.env` files
50
+ - API keys, tokens, and credentials (pattern-based)
51
+ - AWS access keys and secret keys
52
+ - JWTs, private keys, connection strings
53
+ - Any values passed via `redactValues`
54
+
55
+ ## How it works
56
+
57
+ The plugin uses five OpenCode hooks:
58
+
59
+ | Hook | What it does |
60
+ |---|---|
61
+ | `messages.transform` | Scrubs secrets from all message text before it reaches the LLM |
62
+ | `system.transform` | Tells the LLM to treat placeholders as real values |
63
+ | `tool.execute.before` | Restores real values in tool arguments before local execution |
64
+ | `tool.execute.after` | Restores real values in displayed tool output |
65
+ | `text.complete` | Restores real values in LLM response text shown to you |
66
+
67
+ Everything runs locally. No data leaves your machine except the scrubbed conversation sent to the LLM provider.
68
+
69
+ ## Logging
70
+
71
+ Plugin activity is logged to OpenCode's log directory (`~/.local/share/opencode/log/`). Run with `--log-level DEBUG` for detailed output.
72
+
73
+ ```
74
+ INFO service=rehydra scrubbed={"ENV_VAR_SECRET":2} messageCount=3 scrubbed 2 secret(s) from messages
75
+ INFO service=rehydra tool=bash callID=call_abc123 rehydrated PII tags in tool args
76
+ ```
77
+
78
+ ## Rehydra
79
+
80
+ This plugin is part of [Rehydra](https://github.com/rehydra-ai/rehydra-sdk), an open-source SDK for PII anonymization and rehydration. Rehydra combines regex-based pattern matching with NER-based detection and supports any LLM provider via fetch wrappers, proxy servers, or framework plugins.
81
+
82
+ Full documentation at [docs.rehydra.ai](https://docs.rehydra.ai).
83
+
84
+ ## License
85
+
86
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createRehydraPlugin, default } from "rehydra/opencode-plugin";
2
+ export type { RehydraPluginOptions } from "rehydra/opencode-plugin";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createRehydraPlugin, default } from "rehydra/opencode-plugin";
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@rehydra/opencode",
3
+ "version": "0.6.0",
4
+ "description": "Rehydra plugin for OpenCode — anonymizes secrets in LLM context using native plugin hooks",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "files": [
9
+ "index.js",
10
+ "index.d.ts",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "prepublishOnly": "cd ../.. && npm run build"
15
+ },
16
+ "keywords": [
17
+ "anonymization",
18
+ "pii",
19
+ "privacy",
20
+ "secrets",
21
+ "opencode",
22
+ "rehydra"
23
+ ],
24
+ "author": "",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/rehydra-ai/rehydra-sdk.git",
29
+ "directory": "packages/opencode-plugin"
30
+ },
31
+ "dependencies": {
32
+ "rehydra": "^0.6.0"
33
+ },
34
+ "engines": {
35
+ "node": ">=18.0.0"
36
+ }
37
+ }