A simple OpenCode Plugin to block access to .env files.
On Linux, save env-protection.ts to ~/.config/opencode/plugin/env-protection.ts.
import type { Plugin } from "@opencode-ai/plugin"
export const EnvProtection = async ({ client, $ }) => {
return {
tool: {
execute: {
before: async (input, output) => {
if (input.tool === "read" && output.args.filePath.includes(".env")) {
throw new Error("Do not read .env files");
}
},
},
},
};
};dkarter ~Advanced Version
This is nice, gets the terminal bell (I have sound off, but I like to use the indication in tmux). Also Ping.aiff is louder it seems.