Agent permission rules are managed as layered chezmoi data, then rendered into OpenCode config.
Source files:
home/.chezmoidata/agent-permissions/*.yaml(overlays merged lexically)- schema:
schemas/agent-permissions.schema.json
Rendered output:
- OpenCode config via
home/dot_config/opencode/opencode.jsonc.tmpl
Each overlay contributes to:
agentPermissions:
kinds:
bash:
destinationType: namespaced
destinationKey: bash
supportsMatchMode: true
defaultMatchMode: exact
wildcardSuffix: " *"
external_directory:
destinationType: namespaced
destinationKey: external_directory
permission_key:
destinationType: top_level
rules:
- kind: bash
pattern: "git status"
op: allow
bashMatchMode: exactAndWithArgsAll rule types share the same schema. Kind routing is data-driven via agentPermissions.kinds.
agentPermissions.kinds controls where each rule kind is rendered:
destinationType: namespaced-> rule emits intopermission.<destinationKey>destinationType: top_level-> rule emits at top level ofpermissionsupportsMatchMode+defaultMatchMode+wildcardSuffixcontrol wildcard expansion behavior for that kind
Rules then reference a configured kind by kind.
Supported rule fields:
kind(required): key fromagentPermissions.kindspattern(required): match stringop(required):allow,ask, ordenyconditions(optional): key/value match against template data (for exampleprivate: false)bashMatchMode(optional,kind: bashonly):exact,withArgs, orexactAndWithArgs
Generates entries inside "permission"."bash".
bashMatchMode controls exact and wildcard emission:
exact->"pattern"withArgs->"pattern *"exactAndWithArgs-> both keys
This exists because OpenCode glob matching does not treat "cmd *" as equivalent to bare "cmd" for all cases.
Generates entries inside "permission"."external_directory":
- kind: external_directory
pattern: "~/.local/share/chezmoi/**"
op: allowGenerates top-level permission keys (same level as bash/external_directory), useful for MCP tool patterns:
- kind: permission_key
pattern: "atlassian_*"
op: ask
conditions:
private: falseUse the same split pattern as Brew and MCP:
00-base.yaml: shared defaults10-<profile>.yaml: personal/work/fork-specific rules
In this repo, Atlassian-specific permission keys live in home/.chezmoidata/agent-permissions/10-chipwolf.yaml.
- Render OpenCode config with
chezmoi execute-template. - Run test suite (
tests/source/chezmoi.bats). - Run
pre-commit run --all-filesbefore commit.