@gandalfix/opencode-permission-export
v1.0.2
Published
OpenCode plugin to export granted permissions as config snippet
Readme
opencode-permission-export
OpenCode plugin that exports granted permissions as a config snippet.
Installation
npm install @gandalfix/opencode-permission-exportAdd to your opencode.json:
{
"plugin": ["@gandalfix/opencode-permission-export"]
}Usage
During an OpenCode session, the plugin tracks all permission requests. When you want to export the granted permissions:
export my permissionsor
run export-permissionsFormat Parameter
The tool accepts a format parameter with two options:
combined(default): Merges all permissions into a single config snippet with nested tool/pattern structureindividual: Outputs each permission as a separate config entry
Example with individual format:
export my permissions with individual formatOutput:
{"permission":{"bash":{"git status":"allow"}}}
{"permission":{"bash":{"npm run *":"allow"}}}
{"permission":{"edit":{"src/*.ts":"allow"}}}The tool outputs a JSON snippet you can copy into your opencode.json:
{
"permission": {
"bash": {
"git status": "allow",
"npm run *": "allow"
},
"edit": {
"src/*.ts": "allow"
}
}
}How It Works
- Hooks into
permission.askandpermission.repliedevents - Tracks which permissions were granted vs denied
- Generates valid OpenCode permission config syntax
- Only exports granted permissions (denied are noted but not included)
License
MIT
