Files
Sprachmittler/docs/OPENCODE_V2.md
T

4.6 KiB

OpenCode 2.x notes

This kit is written for OpenCode 2.x in native V2 format. This page explains the choices, so you can adapt them without reintroducing V1 constructs. Checked against the OpenCode documentation on 2026-11-26.

Files and locations

File Purpose
opencode.json Project config: $schema, instructions, ordered permissions
AGENTS.md Project rules, loaded automatically
.opencode/agents/<name>.md Subagents: architect, swift-reviewer, test-engineer, translation-evaluator
.opencode/commands/<name>.md Slash commands: next, task, plan, verify, review, adr, status, manual-test, evaluate
.opencode/skills/<id>/SKILL.md Skills: translation-quality, selection-capture (the ID comes from the directory name)
scripts/opencode-check.sh make doctor: version check, V1-key scan, resolved config

opencode.jsonc would work as well; plain JSON is used so the doctor script can parse it with jq.

Permissions

  • Rules are { "action", "resource", "effect" } with effects allow, deny, ask. They are evaluated in order and the last matching rule wins; if nothing matches, OpenCode asks. Agent rules are appended after project and global rules, so an agent's shell * deny followed by narrow allows overrides the project's broader allows.
  • Wildcards: the documentation shows src/** as a resource example but does not define whether * crosses /. The kit therefore lists every folder rule twice (dir/* and dir/**), so nested files are covered either way. make doctor flags a dir/* rule without its dir/** twin.
  • The project config starts with shell *: ask, then allows build, test, read-only git and inspection commands; asks for git commit, ollama pull and codesign; denies git push, git reset --hard, rm -rf, sudo, ollama rm and xcrun notarytool.
  • edit is allowed in general but denied for the generated Sprachmittler.xcodeproj/* and for evaluation/corpus/*; recorded Ollama fixtures and the entitlements file ask first.
  • read is allowed in general, asks for *.env and *.env.*, allows *.env.example, and is denied for evaluation/corpus/* (private texts). The .env rules are repeated because the project's read * allow comes after OpenCode's built-in base policy and would otherwise override its .env prompts.
  • external_directory is set back to ask, because V2 allows it by default.
  • webfetch and websearch ask.
  • For machine-wide hard limits, add policies to your global config, e.g. { "action": "tool.use", "resource": "shell:sudo *", "effect": "deny" }. Policies can only deny and override project rules.

Agents

  • V2 frontmatter fields used: description, mode: subagent, steps, permissions (a YAML list of rules). The Markdown body is the system prompt.
  • No model is pinned, so agents inherit your session model. Pin one with model: provider/model or provider/model#variant if you want.
  • No temperature: V2 does not send agent temperature. Put sampling on a model variant in your global config if you need it.
  • An agent file that uses permissions is read as V2; V1 fields such as permission, tools or temperature in the same file would be ignored, so do not mix them.

Commands

  • Frontmatter fields used: description, optionally agent. $ARGUMENTS receives the text after the command.
  • /plan, /review and /evaluate name a mode: subagent agent, so V2 runs them in a background child session and reports the result back to your session. Add subagent: false to a command file if you prefer it in the foreground.
  • No command uses ! shell blocks, because those run outside the permission flow.
  • Command templates name files in backticks rather than @path, because V2 does not expand @path in stored templates; the agent reads the files itself.

Skills

  • translation-quality and selection-capture are loaded on demand by the skill tool. To restrict them, add skill permission rules, e.g. deny * and allow the two IDs.

Checking the setup

opencode --version            # must be 2.x
make doctor                   # runs scripts/opencode-check.sh
opencode debug config         # prints the resolved V2 configuration

Inside OpenCode, /status should list progress, and @architect should be offered as a subagent.

Not used on purpose

  • No MCP servers: the kit needs none, and every server widens the attack surface.
  • No todo tool settings: todos are off by default in V2 (experimental.todo); docs/PROGRESS.md is the task list.
  • No terminal or theme settings: those belong in the global ~/.config/opencode/cli.json.