.opencode/plugins/ (OpenCode v2) and .opencode/plugin/ (OpenCode v1) in your workspace, or ~/.config/opencode/plugins/ globally, firing the tool.execute.before lifecycle hook before any tool runs.dmint-guard.ts) wired to a dedicated .dmint/policies/opencode.policy.json that covers every built-in OpenCode tool (bash, read, write, edit, apply_patch, grep, glob, list, lsp, todowrite, todoread, question, skill, task, webfetch, websearch).dmint init)# Install in current project (.opencode/plugins/dmint-guard.ts & .opencode/plugin/dmint-guard.ts): dmint init --harness opencode # Or install globally (~/.config/opencode/plugins/dmint-guard.ts): dmint hook install --harness opencode --global
.dmint/policies/opencode.policy.json — Dedicated policy tailored to all OpenCode built-in tools..dmint/signing.key, .dmint/integrity.key, and .dmint/approvals.sqlite3..opencode/plugins/dmint-guard.ts (and .opencode/plugin/dmint-guard.ts) — The OpenCode tool.execute.before guard plugin pointing to .dmint/policies/opencode.policy.json.dmint-guard.ts invokes dmint hook run --harness opencode --policy "<workspace>/.dmint/policies/opencode.policy.json" synchronously over stdin:apply_patch Inspection: In OpenCode, apply_patch passes unified diffs in output.args.patchText with *** Add File:, *** Update File:, *** Delete File:, and *** Move to: headers. Dmint extracts and validates every file path in patchText.todowrite, todoread, question, grep, glob, list, lsp, and websearch are explicitly allowed in opencode.policy.json so OpenCode can manage task checklists and ask clarifying questions without friction.ALLOW (Exit 0): The hook returns cleanly and OpenCode runs the tool immediately.DENY (Exit 2): The plugin throws an Error with the exact Dmint policy code (DMT_POLICY_DENIED), halting execution before the tool runs.APPROVAL_REQUIRED (Exit 2 until approved): The plugin halts the tool and displays the approval ID (apr_...) and dmint approve <id> command directly in OpenCode.approval_required action (e.g., modifying src/index.ts via edit / apply_patch or running docker build via bash), run in your terminal:dmint pending dmint approve apr_... --by dev@company.com
dmint hook run automatically verifies the Ed25519 signature for the matching RFC 8785 fingerprint, consumes the approval (APPROVED -> CONSUMED), and allows the tool to run once.