4.6 KiB
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 effectsallow,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'sshell * denyfollowed 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/*anddir/**), so nested files are covered either way.make doctorflags adir/*rule without itsdir/**twin. - The project config starts with
shell *: ask, then allows build, test, read-only git and inspection commands; asks forgit commit,ollama pullandcodesign; deniesgit push,git reset --hard,rm -rf,sudo,ollama rmandxcrun notarytool. editis allowed in general but denied for the generatedSprachmittler.xcodeproj/*and forevaluation/corpus/*; recorded Ollama fixtures and the entitlements file ask first.readis allowed in general, asks for*.envand*.env.*, allows*.env.example, and is denied forevaluation/corpus/*(private texts). The.envrules are repeated because the project'sread * allowcomes after OpenCode's built-in base policy and would otherwise override its.envprompts.external_directoryis set back toask, because V2 allows it by default.webfetchandwebsearchask.- For machine-wide hard limits, add
policiesto 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
modelis pinned, so agents inherit your session model. Pin one withmodel: provider/modelorprovider/model#variantif 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
permissionsis read as V2; V1 fields such aspermission,toolsortemperaturein the same file would be ignored, so do not mix them.
Commands
- Frontmatter fields used:
description, optionallyagent.$ARGUMENTSreceives the text after the command. /plan,/reviewand/evaluatename amode: subagentagent, so V2 runs them in a background child session and reports the result back to your session. Addsubagent: falseto 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@pathin stored templates; the agent reads the files itself.
Skills
translation-qualityandselection-captureare loaded on demand by theskilltool. To restrict them, addskillpermission 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.mdis the task list. - No terminal or theme settings: those belong in the global
~/.config/opencode/cli.json.