Skip to content

OpenCode

Zentri supports OpenCode V2 only. zt start writes an OpenCode plugin and two skills into the session’s worktree, passes the rest of the kit as config in an environment variable, and starts opencode.

  1. Install OpenCode V2. Zentri was checked against v2.4.2.
  2. Set up the model provider you use with your own API key or account, as OpenCode documents. OpenCode reaches third-party models only through credentials you hold. Zentri never reads or stores them. See Bring your own credentials.
  3. Run zt doctor to check that opencode is on your PATH.
  4. Start a task from your repository.
Terminal window
zt start --agent opencode "add CSV export to the reports page"

The launcher runs:

Terminal window
opencode --standalone --prompt "<prompt>"

OpenCode takes the prompt as --prompt, not as the last argument. Attach with zt attach.

The launcher sets OPENCODE_CONFIG_CONTENT to this document. A document in that variable outranks your user and project config. Only managed config under /etc/opencode outranks it.

{
"mcp": {"servers": {"zentri": {
"type": "local",
"command": ["<zentri>", "mcp"],
"environment": {"ZENTRI_SERVER": "...", "ZENTRI_SESSION_ID": "...",
"ZENTRI_SESSION_TOKEN_FILE": "...", "ZENTRI_WORKTREE": "..."},
"codemode": false
}}},
"plugins": ["<worktree>/.zentri/opencode/plugin"],
"skills": ["<worktree>/.zentri/opencode/skills"],
"permissions": [{"action": "zentri_*", "resource": "*", "effect": "allow"}]
}
  • <worktree>/.zentri/opencode/plugin/ holds the plugin. It is embedded in the zentri binary, and the only value filled in is the path of that binary. It uses the Plugin.define form from @opencode/plugin, which the released OpenCode binary resolves to its own copy, so the folder needs no node_modules.
  • <worktree>/.zentri/opencode/skills/ holds the PRD and ADR skills, zentri-prd/SKILL.md and zentri-adr/SKILL.md.

No kit file holds the session token. zentri reads it from the file that ZENTRI_SESSION_TOKEN_FILE names.

Plugin hook Runs on What it does
execute.before edit, write, patch Runs zentri hook opencode pre-edit, which claims the files. It rejects the call when Zentri denies it, fails, or does not answer.
execute.after shell Runs post-shell, which claims the files the command changed and tells OpenCode to revert any that another session holds. It never throws.
context The session Runs session-start once, then prompt at most every 15 seconds, and adds notices to the system prompt.

OpenCode also gets the 13 MCP tools. The permissions entry allows every zentri_* tool.

The command the kit launches takes no model flag. When the model router picks a model for a session started with --credential api-key, zt start puts it in the config’s model key, as provider/model. A session on a subscription keeps OpenCode’s own model.

Terminal window
make sandbox-image AGENT=opencode
zt start --launcher openshell --agent opencode "add CSV export to the reports page"

The kit is managed config under read-only /etc. /etc/opencode/opencode.json names the plugin in /etc/opencode/zentri/plugin and the skills in /etc/opencode/zentri/skills. OpenCode loads it last, so it overrides user and project config. The image sets OPENCODE_DISABLE_MODELS_FETCH=1 and OPENCODE_DISABLE_AUTOUPDATE=1.

The policy lets /usr/local/bin/opencode reach api.anthropic.com and api.openai.com on port 443. A provider at another host needs a policy change. See OpenShell policies.

  • With local-dev, OpenCode runs as you. A shell call can write a held file. The post-shell hook catches it afterwards. It does not stop it.
  • The git pre-commit hook only warns, and git commit --no-verify skips it. Require the merge check for a hard gate.

OpenCode has not run with its kit. A Node driver tests the plugin’s hooks. These points are not verified:

  • that the plugin behaves the same inside a real OpenCode V2 session;
  • that OpenCode’s Node build resolves @opencode/plugin without node_modules.

OpenCode has not run inside an OpenShell sandbox either. The image builds and prints the pinned version. OpenCode V1 is not supported.