Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

OpenCode Integration

OpenCode loads local TypeScript plugins from .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 generates a zero-dependency OpenCode guard plugin (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).

1. One-Command Setup (dmint init)

In your project directory, run:
# 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
What this generates:
  • .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.

2. How the OpenCode Plugin Works

Whenever OpenCode prepares to execute a built-in or MCP tool, 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.
  • Safe Built-In Session Tools: 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.

3. Approving & Retrying in OpenCode

  1. When OpenCode pauses on an 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
  2. Ask OpenCode to retry the tool call. 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.