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.
Set it up
Section titled “Set it up”- Install OpenCode V2. Zentri was checked against v2.4.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.
- Run
zt doctorto check thatopencodeis on yourPATH. - Start a task from your repository.
zt start --agent opencode "add CSV export to the reports page"The launcher runs:
opencode --standalone --prompt "<prompt>"OpenCode takes the prompt as --prompt, not as the last argument. Attach with zt attach.
What the kit holds
Section titled “What the kit holds”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 thezentribinary, and the only value filled in is the path of that binary. It uses thePlugin.defineform from@opencode/plugin, which the released OpenCode binary resolves to its own copy, so the folder needs nonode_modules.<worktree>/.zentri/opencode/skills/holds the PRD and ADR skills,zentri-prd/SKILL.mdandzentri-adr/SKILL.md.
No kit file holds the session token. zentri reads it from the file that ZENTRI_SESSION_TOKEN_FILE names.
What Zentri enforces
Section titled “What Zentri enforces”| 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.
Model routing
Section titled “Model routing”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.
In an OpenShell sandbox
Section titled “In an OpenShell sandbox”make sandbox-image AGENT=opencodezt 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.
What Zentri cannot enforce
Section titled “What Zentri cannot enforce”- With
local-dev, OpenCode runs as you. Ashellcall 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-verifyskips it. Require the merge check for a hard gate.
Limitations
Section titled “Limitations”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/pluginwithoutnode_modules.
OpenCode has not run inside an OpenShell sandbox either. The image builds and prints the pinned version. OpenCode V1 is not supported.
Related pages
Section titled “Related pages”- Agents
- File claims
- Model routing
- Vendor terms for OpenCode’s terms on third-party models
- CLI reference and Environment variables