opencode-policyOpenCode plugin for blocked file patterns and prompt injection policies
20
47
近 7 天 9
34.9
生态多维模型
3 个月前
2026-04-24
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-policy@0.1.4"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-policy@0.1.4"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-policyopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode security plugin with:
You can review the full rule sets there and add or remove patterns to fit your workspace.
Unsafe tool patterns
Prompt injection patterns
Use it when you want stronger workspace safety out of the box: it helps prevent secret exposure, exfiltration, unsafe shell execution, reverse shells, denial-of-service commands, cross-workspace access, and common instruction-override attacks. Matching events are logged to .opencode/opencode-policy.log for review.
Simple install
opencode plugin opencode-policy@latest --global
Install from npm
Install the package:
npm install opencode-policy
Then add it to one of these OpenCode config files:
~/.config/opencode/opencode.jsonfor your useropencode.jsonin your project root for one project
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-policy"]
}
License
Thanks
Pattern research and source material were adapted in part from vakovalskii/topsha