
opencode-tools
io.github.craft-agent/opencode-tools
OpenCode tools for coding agents: start, follow, steer and answer sessions from another harness.
Documentation
opencode-tools
OpenCode tools for coding agents: start, follow, steer and answer sessions from another harness.
| Harness | Delivery | Pinned by |
|---|---|---|
| Claude Code | plugin: MCP server and skills | the release tag, as the ref |
| Codex | plugin: MCP server and skills | the release tag, as the ref |
| Grok Build | plugin: MCP server and skills | the release tag, as @ref |
| Antigravity | plugin: MCP server and skills | the release tag's tree URL |
| Hermes Agent | native plugin (Python, calls the command line) | the release commit, as the SHA |
| other MCP host | MCP server from npm | the version in the package |
The tools need Node.js 24 or later and
OpenCode 2.4.2 or later, the version they are tested
against.
docs/conventions.md describes how the tools are named
and how they behave.
Install
Install from a release, never from the default branch: a release is a tag whose
commit carries the built dist/, and the default branch does not. In the
commands below, <version> is a release's version (1.2.3) and <sha> is the
commit its tag names:
gh api repos/craft-agent/opencode-tools/commits/v<version> --jq .sha
The package is not installed into OpenCode itself: the tools drive OpenCode from another harness, and a session they start cannot call them.
Claude Code
claude plugin marketplace add craft-agent/opencode-tools#v<version>
claude plugin install opencode-tools@opencode-tools
Codex
codex plugin marketplace add craft-agent/opencode-tools --ref v<version>
codex plugin add opencode-tools@opencode-tools
Codex turns - into _ in server names, so it shows the tools as
mcp__opencode_tools__opencode_*. It starts the MCP server in the plugin's
install directory and passes no roots, so the server takes each call's directory
from what Codex sends with the call: its sandbox state, which the server asks
for, else the one workspace it names.
The plugin declares default_tools_approval_mode = "writes": Codex asks before
every tool not marked read-only. A user's
[plugins."<plugin>".mcp_servers.<server>] setting can only tighten it. Setting
auto there yields prompt (reads asked too), since Codex treats auto and
writes as incomparable.
Grok Build
grok plugin install craft-agent/opencode-tools@v<version> --trust
Grok starts the MCP server in the session's working directory.
Antigravity
Install from the tree of the release tag, never from the default branch, which
has no built dist/; Antigravity clones the tag into
~/.gemini/config/plugins/opencode-tools.
agy plugin install https://github.com/craft-agent/opencode-tools/tree/v<version>
Hermes Agent
Hermes installs a commit, not a tag, and the plugin installs disabled:
hermes plugins install craft-agent/opencode-tools --ref <sha>
hermes plugins enable opencode-tools
If a Hermes gateway is already running, restart it (hermes gateway restart) to
load the plugin.
The plugin runs the Node it found when Hermes started. If a version manager
removes that version while Hermes runs, a call looks for Node again; when it
finds none, restart Hermes from a shell where node runs.
When the package's writes depend on another Hermes plugin, such as a guard
that blocks writes no one is there to approve, name it in require_plugins.
Hermes keeps loading this plugin when that one fails to import or register,
and treats a manifest's requires_plugins as advisory. With the setting,
while a named plugin is not loaded, every write is refused before it is
approved, even under --yolo, approvals.mode: off or a remembered answer,
naming the plugin that is missing. Reads still run.
plugins:
entries:
opencode-tools:
settings:
require_plugins: [write-guard]
Any other MCP host
Add the server to the host's MCP configuration. Flags go in args:
{
"mcpServers": {
"opencode-tools": {
"command": "npx",
"args": ["-y", "@craftsamo/opencode-tools@<version>", "--read-only"]
}
}
}
The OpenCode service
The tools reach the OpenCode service a person already runs, through
OpenCode's own client. When no service is running, a call starts one
(opencode serve --service) and leaves it running. A read does too, also
under read_only, and its result says so.
A call ends within wait_seconds of its start, 50 seconds unless you set it:
the service starting (up to 30 seconds), a directory loading and each request
(10 seconds) all draw on that one limit. A harness that ends a tool call
after a minute therefore never cuts one off. A call that runs out fails and
says what it was waiting for. The Hermes plugin ends a call 30 seconds after
the setting.
A service keeps the environment it was started with for every session it
later serves, a person's own included. So one the tools start is given only
what finds a person's programs and configuration: PATH, HOME, USER,
LOGNAME, SHELL, the locale (LANG, LANGUAGE, LC_ALL, LC_CTYPE,
LC_MESSAGES), TERM, TMPDIR, TZ, and XDG_CONFIG_HOME,
XDG_DATA_HOME, XDG_STATE_HOME, XDG_CACHE_HOME and XDG_RUNTIME_DIR.
Nothing else of the harness's environment goes with it.
A provider key that lives only in a shell variable therefore does not reach a service the tools start. Keep it in OpenCode's own service configuration, or start the service yourself before the tools need it: a running service is used as it is, and never restarted or stopped.
Asking about a directory opens it in OpenCode, as starting OpenCode there would: the service keeps it as a project and loads its configuration, which takes a moment the first time, and a few seconds in a service that has just started. The tools wait for that, for up to fifteen seconds.
Tools and skills
Each toolset comes with a skill that tells an agent how to use its tools, and
run with a second, opencode-brief, on writing the brief a run works from.
A skill names its toolset under metadata in its frontmatter
(metadata: { toolset: <name> }, written as a block). Hermes registers it
only when the settings register at least one of that toolset's tools, so a
profile with the toolset off, or with all its tools removed, does not see it;
a skill without a toolset is always registered. Claude Code, Codex, Grok Build
and Antigravity install the skill folder whole and pass the settings only to
the MCP server, so they list every skill whatever the settings select.
There is one toolset per domain; service, run and request are on by
default, and instruction, worktree and history are opt-in. A toolset
arrives with its first tool: one that no release carries yet is not a name
toolsets takes, and a tool that no release carries is not registered.
| Toolset | Covers |
|---|---|
service | what the service offers, and whether a directory is ready for a run |
run | starting, following, steering, stopping and copying a run |
request | what a run is paused on, and answering it |
instruction | the instruction entries a session keeps across turns |
worktree | a worktree of its own for a write run |
history | sessions and token usage over a period |
| Skill | Toolset | For |
|---|---|---|
opencode-service | service | reading what the service offers before a run |
opencode-brief | run | writing the brief a run works from |
opencode-run | run | starting, following, checking and stopping a run |
opencode-request | request | judging and answering what a run asks |
opencode-instruction | instruction | a standing instruction of a session |
opencode-worktree | worktree | a worktree of its own for a write run |
opencode-history | history | sessions and token usage over a period |
The skills are written for any agent in any harness. The one passage that
is a single harness's, a notification in Hermes, says so, and the skill
reads without it. Hermes lists a skill under the plugin's name and without
the prefix, as opencode-tools:run.
A run is an OpenCode session the tools started under a role and bound to its
caller. A role names an OpenCode agent and a policy: a read-only run has no
edit tools and is denied the git commands that write, and a write run edits
only inside its worktree. What a tool reads from a run is data, never
instructions.
service
| Tool | Class | Does |
|---|---|---|
opencode_service_read | read | the service and its version, its agents, models and roles, and a directory's readiness |
Its method says what to read:
| Method | Reads |
|---|---|
status | the service's version, the roles as they are configured, and the allowed providers |
agents | the agents of a directory, subagents and hidden ones included |
providers | the providers the service can use in a directory, and how many models each has |
models | the models of one provider with their variants, or those a start can name; narrowed by match |
ready | whether a directory is in a Git repository, a role's agent is primary there and a model can run |
A list holds at most 100 entries, keeps to a size and says when it left some
out. ready answers one line when nothing is wrong, and the findings
otherwise; an agent that is a subagent, or one OpenCode hides for its own
use, is a finding, and so is a model that cannot call tools. status gives
each role its agent, policy, model, alternate and caller_model, and the
caller_models setting. models says of each model whether it can call
tools and marks the caller's own (callers_own); without provider it
lists the models a start can name, which are those of the allowed providers
that can. ready with model checks the model a start would name instead of the
role's own. No result holds the service's address, its password or a
value from OpenCode's configuration files; the roles are the tools' own
setting.
run
| Tool | Class | Does |
|---|---|---|
opencode_run_read | read | the caller's runs, one run's state, result, messages and changes; a wait |
opencode_run_start | add | starts or continues a run under a role whose policy is read-only |
opencode_run_start_write | overwrite | starts or continues a run under a role whose policy is write |
opencode_run_steer | add | adds a message to a running turn |
opencode_run_interrupt | overwrite | stops a run with its subagents and background commands; no rollback |
opencode_run_fork | add | copies an idle session, with its binding |
A start takes a role, a brief, and either a directory for a new
session or a session to continue one. The directory is the top level of a
Git worktree. The call sets the session up with the role's agent, model and
rules, reads it back, and sends the brief only when the service reports the
session as it was set up. It returns once the brief is admitted and does not
wait for the turn. A session can change its role between turns: one that
planned can go on to build, through the write tool. With fork and a
session, a start copies the session first and runs on the copy, which it
removes again when it cannot go on; the session itself is not written to.
A start can name a model, written <provider>/<model> with an optional
#<variant>:
- It is checked before anything is created or changed: its provider is
one of
allowed_providers, or the model is the role's own model or alternate; OpenCode lists it; it can call tools; and the variant is one of the model's. A model that fails is refused, never replaced by another. - It stays its role's choice on the session, and on its forks, until another is named. Naming the model the role would run on anyway takes the choice away, so the role follows the settings again. OpenCode keeps a model on the session and takes none with a prompt, so a model for one turn is a change to the session.
- Every start resolves its role's model anew: the model named, else the
role's choice, else the role's
model, else the agent's own, else OpenCode's default.model_fromsays which. A session that planned on one model is built on the build role's. - A session something else moved to another model stays on it
(
model_frommoved): a plugin does that after a limit, or a person. Setting the role's model again would send the session back to a model that was refused. Amodelnamed for the turn is set all the same, and so is the model of a role that resolves to another. - Nothing switches to a role's
alternateby itself. A read of a run whose turn failed for a limit of its provider, or keeps retrying for one, sayslimitand names thealternate; the next start names it asmodel. - A subagent runs on its own agent's model, and on the run's only where its agent names none.
- A run is refused on a model its caller answers with, unless its role
says
caller_model: allow: the caller would otherwise check work its own model did. Thecaller_modelssetting names those models; no protocol tells a tool its caller's model, so a person writes it down, and under Hermes the plugin adds the conversation's own. With none known nothing is refused, andstatusshows the list as empty. Two names are the same model when they are equal without the provider, the case and a dated snapshot's suffix, or when OpenCode lists one as another name of the other, as it does a speed tier.
A run that works is corrected, stopped and copied by three tools, each of
which takes the run's session:
opencode_run_steernever starts a turn. OpenCode delivers a steer at the session's next step, after the tool calls in flight, and starts a turn with one sent to a session that has stopped. So the message is sent in the form that does not wake a session, a run with nothing active is refused (reasonnot_running), and a message whose turn ended before reading it is withdrawn. The result sayswhenthe run reads it:read,next_step, orafter_requestfor a run paused on a request of its own.opencode_run_interruptstops the whole run. OpenCode's own interrupt stops one session, and neither its subagents nor the commands it moved to the background; and the report of a subagent or a command that ends wakes the session that started it, also one that was just stopped. So what is below the run's own session is stopped first, the run's own session after it, and the call looks again until nothing is active, for 20 seconds at most (timed_out). The caller's unread messages are withdrawn and counted.- An interrupt rolls nothing back, and its result says so: files, commits and whatever left the machine stay as the run left them.
- Background commands are stopped through an experimental route of
OpenCode. On a service without it the sessions are stopped all the same
and the result says
background_unchecked. opencode_run_forkcopies an idle run's session: its history, in the same worktree, bound to the same caller and role. OpenCode copies a session's metadata as it is, so the tool writes the binding again without the mark of the start that made the source, reads the copy back, and removes it where that fails. A run with something active is refused: the copy would end on a brief without an answer. A read givesforked_fromfor a run that is a copy.
opencode_run_read follows a run by its method:
| Method | Reads |
|---|---|
list | the caller's runs, newest first, each with its role, directory, branch and state |
get | one run: its state, what it waits on and the result of its newest turn |
wait | the same, once the run hands back or the call's time is nearly over (timed_out) |
messages | the session's recent messages |
changes | the files the newest turn changed, with line counts, and their patches on request |
changes gives worktree_gone and no files once the worktree the turn ran
in was removed (see worktree).
A run's state is read from the service each time; the tools keep no record of a run. A run that has ended can run again with no start: when a command it left in the background ends, or a subagent of it does, OpenCode wakes the session with the report.
| State | Means |
|---|---|
running | a turn of the session, or of one of its subagents, is under way |
waiting | the run is paused on a permission request or a question |
completed | the newest turn ended |
failed | the newest turn ended in an error |
interrupted | the turn was stopped, or stopped without its end, which OpenCode takes up again at its start |
unknown | the session holds no turn, or a brief's admission could not be confirmed |
What the rules of a run stop, and what they cannot:
- Every run is denied pushing from a shell, publishing a package, reading
secret files, changing git configuration and hooks, discarding work by
force, a git command that names another repository (
-C,--git-dir,--work-tree,-c), these tools themselves, moving its own session, and making or removing a worktree (git worktree add,remove,moveandprune, and OpenCode's own tools for it). - A read-only run has no edit tools and is denied the git commands that write. A write run is denied every edit outside its worktree, and asks before it rewrites history, moves a branch or runs a package it downloads.
- Outside its worktree a run asks, but for the directories OpenCode
itself sends it to and a read-only run's
read_roots. - The rules are text OpenCode matches, not a sandbox. They stop a command
as it is plainly written. A read-only run keeps its shell, as OpenCode's
own
planagent does, and a shell command can still write a file. Read what a run changed before relying on it. - Starts made at the same moment in one worktree refuse each other, so that two never go through; call again after a moment.
request
| Tool | Class | Does |
|---|---|---|
opencode_request_read | read | what a run and its subagents are paused on, each with its whole command |
opencode_request_reply | overwrite | answers a permission request once or reject, or answers or declines a question |
A run pauses when its rules ask before a tool call, or when it puts a
question. opencode_request_read reads what it is paused on by its method:
| Method | Reads |
|---|---|
list | every permission request and question of the run's session and of its subagents' sessions |
get | one of them, and for an edit the patches of the files it would change |
A permission request comes with its text, what an approval lets run: the
whole command of a shell call, or another call's arguments as JSON. The
service's own request holds only the simple commands of a shell call, so the
text is read from the tool call in the session's messages. A question comes
with its fields: what was asked, the options and what each field takes.
opencode_request_reply takes the run's session and one to ten replies,
each a request and a decision:
| Decision | For | Carries |
|---|---|---|
once | a permission request | text, the request's text as the read gave |
reject | a permission request, or a question | reason, which the run reads |
answer | a question | answer, a value for each field answered |
- An approval is for the one call. OpenCode's third answer, which saves an approval for the whole project, is never sent.
- An approval repeats the request's text, and one that differs sends nothing. A harness that shows a call's arguments then shows what is approved, and no request is approved by its id alone.
- A rejection always carries a reason, and so does a declined question. The run reads it and goes on; without one OpenCode ends the turn.
- Some requests can only be rejected: one whose action matches
never_approve, one a subagent asked that the run's own rules ask about, and one whose text an approval's prompt cannot show whole (over 2000 characters, or holding characters that hide or reorder text). A question with a link to visit can only be declined. A person can still answer any of them in OpenCode. - Every reply of a call is checked before any is sent. Approvals and answers are then sent before rejections, since OpenCode rejects every other pending request of a step along with one.
- The result says what became of each reply (
sent,gone,failed,not_sent), names what a rejection took along, and carries the run's next state when it arrives within ten seconds.
instruction
| Tool | Class | Does |
|---|---|---|
opencode_instruction_read | read | the instruction entries of a session |
opencode_instruction_set | overwrite | sets an entry the session keeps across its turns |
opencode_instruction_remove | overwrite | removes an entry |
An instruction entry is a text OpenCode keeps on a session beside a key and puts in front of its agent at every turn. The agent is told once of an entry that is set, changed or removed: at the session's next step while it works, else at the head of its next turn. A brief does not have to repeat what an entry says.
- A caller's key is
opencode-tools.<name>, given whole, the name of lower-case letters, digits,_and-, at most 40 characters. A value is a text of at most 8000 characters, and a session holds at most 20 entries of the package. opencode-tools.noteis the operating note, which every start writes. A caller reads it, and can neither set nor remove it.- The tools show the package's entries only. A session can hold a
person's or a plugin's under other keys:
listcounts them and shows neither their keys nor their values. - An entry is a request to the agent, not a rule. Nothing stops a command that goes against it; what a run may not do is its ruleset's to deny.
- A subagent is not told. A subagent's session has no entries, so an entry reaches it only through the run that starts it. A fork has its source's entries.
- The entries are an experimental route of OpenCode. On a service
without it the three tools fail as
upstream_error, and the operating note goes at the head of each brief instead. - A set that changes nothing sends nothing and says so, and a remove of a key that is not there is no error.
worktree
| Tool | Class | Does |
|---|---|---|
opencode_worktree_enter | add | makes a worktree on a new branch and moves a run's session into it |
opencode_worktree_leave | overwrite | moves the sessions back, removes the worktree, deletes the branch once landed |
A session that planned in a checkout goes on as a write run in a worktree of
its own: opencode_worktree_enter, then opencode_run_start_write with the
same session. The tools make and remove the worktree with git themselves;
OpenCode's own worktree routes are not used, since what they do depends on
the plugins a setup has, and they make no branch.
- A worktree is
<worktree_root>/<repository>/<branch>, the branch with every/as-, and the repository named after the last part oforigin's URL, else after the main checkout's folder. The branch is new, and starts atorigin's default branch after a fetch (basedefault) or at the checkout's own commit (head). A fetch that fails is a warning. - A session is moved only while its run is at rest. OpenCode wakes a session it moves, and the wake takes up what waits for it: a run with something active, a turn with no end written, or anything in its inbox is refused, by the gate before anyone is asked.
- A failed enter leaves nothing behind: the session is moved back, and the worktree, the branch and the folders the call made are removed. Where the session cannot be brought back, nothing is removed under it, and the error names what is left.
- A move does not change what a read says. OpenCode runs an empty turn for a move; the tools note it in the session's binding, and a read gives the state and the result of the turn before. A move a person makes in OpenCode is not looked past.
opencode_worktree_leavechecks everything before it moves anything: the worktree is underworktree_root, is not the main checkout and is not locked, nothing runs in it, and it holds no modified, staged or untracked file. It moves the caller's sessions to the main checkout and counts the others, which their owners can still read and move.- A removal is never forced. Where git refuses, the sessions are moved back and the call can be made again. Files git ignores go with the worktree.
- A branch is deleted only once it has landed: its tip is an ancestor of
origin's default branch after a fetch, and it still points there. A branch that is kept comes back with the reason; one merged by squashing isnot_landed, since git cannot prove it landed. changesof a turn that ran in a removed worktree answersworktree_goneand no files: OpenCode reads a turn's files where the turn ran. The changes are on the branch.- Git runs with hooks off and with
PATH,HOMEand, for a fetch,SSH_AUTH_SOCK: nothing else of the harness reaches a repository.
history
| Tool | Class | Does |
|---|---|---|
opencode_history_read | read | the sessions of a period and their token usage, never their content |
Off by default. opencode_history_read reads every session the service
holds, of every directory and whoever started it: the caller's runs,
another caller's and a person's own. It is the one tool that does: every
other tool still answers that a session which is not the caller's does not
exist. Enabling the toolset is what allows it; it has no setting of its own.
listgives the sessions of a period, newest update first:fromup to but not includingto, each a date or an ISO 8601 date-time, ordays, the last N calendar days, in an IANAtimezonethat is the machine's by default. It keeps the sessions of adirectoryand those below it, of anagent, of amodel, of akind(rootby default,subagentorall), the caller'sown, and witharchivedthe archived ones too. A result that was cut says thenext_offsetto go on from.getreads one session and the sessions below it at any depth.usagetotals the tokens used in a period, by any ofmodel,agent,directory,kindandday(group_by). It counts the assistant messages created in the period, each under its own model and agent; a session's own totals, which a list shows, cover its whole life and are not used.- Usage is read one of two ways, and
sourcesays which. With nothing filtered and groups ofmodelanddayonly, the service's own statistics answer in seconds. Anything else, and a service without the statistics, reads every session's messages a few sessions at a time: a month on a machine in daily use took a minute, where the statistics took four seconds. Both count the same messages. - A result that could not read everything says so.
partialcomes withunread: the sessions or days not read before the call's time ended, and the messages still being written. The call succeeds, a session counts whole or not at all, and the newest are read first: a narrower period, or a longerwait_seconds, reads the rest. - No content is returned: no message, no tool call, no metadata. A
title comes only with
titles, a cost only withcosts; a cost is what the service recorded in US dollars and is 0 where a provider reports none. - Tokens are five parts that do not overlap:
input,output,reasoning,cache_readandcache_write. No sum of them is given. - Only the service is read, never its database, and the statistics are an experimental route of OpenCode: without it usage is counted from the messages.
Grants (grants)
Off by default. Delegates bounded writes for jobs where no person can answer.
| Tool | What it does | Class |
|---|---|---|
opencode_grant_create | ask a person to delegate one tool's writes within limits | administrative |
opencode_grant_read | list grants and their use, or read the usage log | read |
opencode_grant_revoke | remove a grant so no more calls run under it | overwrite |
Every write tool can be granted for its targets, calls per hour and expiry.
A tool adds what a grant can also limit by declaring bounds and giving
measure(args, context) in its spec: a ceiling (max), a yes or no
(allow), values from a list (oneOf) or the paths a value must sit under
(prefix); see the
conventions.
Hermes conversations
In Hermes a run belongs to the conversation that started it.
- A conversation is a chat, its thread and its sender, in one profile. It
keeps its runs after
/new, a compressed context or a gateway restart. Another chat, another thread, another sender or another profile does not see them, and two people in one group chat each see only the runs they started themselves. A session at the command line, in the TUI or in the desktop app is a conversation of its own. - A delegated subagent gets no tool. Every call it makes is refused, and it is told to hand what it needs back to the agent that delegated to it: it would otherwise answer a run's requests in its delegator's name.
- A session no person converses in gets no tool: another agent's request
(
a2a), a request to Hermes' API server, and a webhook. - Which profiles get the tools is Hermes' own setting. Enable the plugin
in each profile that should have them, with
hermes plugins enableunder that profile, and narrow its toolsets per platform withhermes tools. The package names no profile.
The plugin reads four Hermes modules outside the plugin context it is handed: the Node finder, the agent's working directory, its display language, and the session context, which is where a tool call's conversation is.
Notifications
A conversation in a chat can be told when a run it started stops, so the agent
does not hold a turn open waiting. It is off until you turn on two things:
the plugin's notify, and Hermes' own grant for the plugin to start a turn.
plugins:
entries:
opencode-tools:
allow_gateway_injection: true
settings:
notify: true
- When a call's result shows a run
running, in a chat on a messaging platform, the result also carriesnotification, and the agent ends its turn. At the run's next stop (completed, failed, interrupted, waiting on a request, or retrying its provider), or after 20 minutes without one, the conversation gets one notice, which starts a turn. - A notice says that it is a notification and not something a person typed, which run it is of, its state, the requests it waits on or the head of its reply, and what to read next. It has at most 4000 characters; a request is shown whole or counted as left out, never cut inside. You see the agent's answer to it, not the notice.
- One run has one notifier at a time, and a stop the agent has read itself is not told again. A gateway that restarts ends its notifiers; the agent's next read of a running run starts another. While it waits, a notifier asks the OpenCode service once a second.
- With
notifyon and Hermes' grant missing, a result still says a notification follows and none does; Hermes' log names the setting. - A session at the command line, in the TUI, in the desktop app or in an
editor, and a cron job, get no notification. They wait with
opencode_run_readmethodwait, withinwait_seconds. Hermes ends one tool call aftertimeouts.tools.sequential_callseconds, 420 by default, and the plugin ends a call 30 seconds afterwait_seconds, so keepwait_secondsat least 30 below Hermes' limit.
Adding a tool
- Write the spec in
src/core/<domain>/<verb>.tswithdefineTool: an ID<prefix>_<domain>_<verb>, a title and description, the Zod argument and output schemas, its toolset and write class, andexecute(args, context). A write tool also givestargets(args, context): what the call writes to, as a permission rule should name it. A tool whose settings can put some calls out of reach whatever the person answers givesgate(args, context), which throws for such a call; it is refused before anyone is asked, and beforeexecute. - Test it beside the spec (
<verb>.test.ts), calling it throughinvokeas the entry points do. A tool that runs a program is tested against a fake of that program onPATH; no test reaches a real service. - List it in
src/tools.ts. A new toolset goes intotoolsetsinsrc/project.ts(anddefaultToolsetswhen it is on by default), a setting of the package's own intooptions(andOPTIONSinproject.pywithconfig_schemainplugin.yaml), and a variable the tool reads besides the settings intotoolVariables. - Add or update the toolset's skill,
skills/<prefix>-<toolset>/SKILL.md, whose frontmatter names the toolset undermetadata. - Run
pnpm run build && pnpm run manifeststo list the tool inplugin.yamland its variables in Codex's manifest, then describe it under "Tools and skills".
docs/conventions.md has the rules each step follows.
A package declares each option as text, boolean, number, list, path,
paths or json, or as an object with type and optional bounds. For
example, in src/project.ts:
options: {
roles: "json",
wait_seconds: { type: "number", integer: true, min: 1, max: 3300 },
}
integer: true requires a whole number; min and max bound a number or
count a list or paths value's items. An object with only type means the
same as the type alone. A json value is a JSON object, and what it must
hold is checked in checkOptions in src/project.ts. Hermes's OPTIONS
mirrors the declarations on one line, with double quotes and Python's True
for integer:
OPTIONS: dict[str, str | dict[str, object]] = {"roles": "json", "wait_seconds": {"type": "number", "integer": True, "min": 1, "max": 3300}}
Reads and writes
Every read tool is named <prefix>_<domain>_read. Reads can run unasked;
writes are confirmed by the harness.
| Harness | Reads without asking |
|---|---|
| Claude Code | the rule mcp__plugin_opencode-tools_opencode-tools__*_read in permissions.allow of ~/.claude/settings.json |
| Codex | always; Codex runs tools that declare readOnlyHint unasked, as the read tools do |
| Grok Build | grok --allow 'MCPTool(opencode-tools__*_read)' --allow 'MCPTool(opencode_*_read)' (both rules; see below) |
| Antigravity | the rule mcp(opencode-tools_opencode-tools/<tool id>) in permissions.allow, one for each read tool |
| Hermes | always; the plugin asks only before a write |
Where a write is asked about, and where it is not:
- Codex asks before every write because of the plugin's approval mode.
Under
codex execit refuses with "MCP tool call requires approval, but approval policy is never". For bounded jobs, see Writes no one is there to approve. - Grok Build under
grok -prefuses a write it cannot ask about, unless it is allowed beforehand. - Grok Build calls the plugin's tools through its
use_tooltool, and the agent often names a tool without its server first. Grok checks the rules against the name as given, so the server-qualified rule alone does not match that first call. The second rule matches the short name; a write still matches neither. - Antigravity asks before any MCP tool no rule allows, reads included, and
names the plugin's server
opencode-tools_opencode-tools(plugin, then server).agy -prefuses a tool it cannot ask about. - Hermes
hermes chat -qrefuses a write it cannot ask about;hermes -zand--yoloskip approval, so writes then run unasked. For bounded jobs, see Writes no one is there to approve.
A call a tool's gate refuses never runs, whatever the answer. Hermes
refuses it before it asks, so no prompt shows it, and blocks it with the
tool's error. Claude Code, Codex, Grok Build and Antigravity draw their
own prompt before the MCP server sees the call, so they may still ask about
it; the server then refuses it.
Writes no one is there to approve
A grant limits a job's writes to one tool, for at most 90 days. The person
decides the rest: the targets (named ones, or * for any), the bounds the
tool declares (one left out is no limit) and the calls per hour (left out,
any number). Every call made under a grant is logged. A grant never
overrides the host's permissions. The
conventions give the
contract.
- In a session where a person answers, supply the key described under
Settings, turn on the
grantstoolset alongside the job's toolset, and ask the agent to delegate. It callsopencode_grant_create; the prompt shows the tool, targets, rate, days, every bound the tool declares (no limitfor one left out) and the reason. Approve once. - Set the same key and
unattendedfor the job only, for exampleOPENCODE_TOOLS_UNATTENDED=true. Otherwise grants are not checked. - Let the host allow the write tool in that run, as below. The grant still bounds each call.
- Revoke with
opencode_grant_revoke, or list grants and their use withopencode_grant_read.
What lets a write reach the package when no one can answer:
- Claude Code
claude -pneeds the tool in--allowedTools, asmcp__plugin_opencode-tools_opencode-tools__opencode_note_create. - Codex
codex execneedsapproval_mode = "approve"for that tool under the plugin's MCP server inconfig.toml([mcp_servers.<server>.tools.<tool>]), since the plugin's default asks before every write. - Grok Build
grok -pneeds both allow rules:--allow 'MCPTool(opencode-tools__opencode_note_create)'and--allow 'MCPTool(opencode_note_create)', for the qualified and short names described under Reads and writes. - Antigravity
agy -pneedsmcp(opencode-tools_opencode-tools/opencode_note_create)inpermissions.allow. - Hermes
hermes chat -qdenies byapprovals.single_query_modeunless allowed.-zand--yoloskip approvals and run the write; the grant is then the only bound.
Limits
- A run with every approval skipped (Hermes
-zor--yolo, an always-approve mode, or an explicitallowforopencode_grant_create) shows no prompt. A grant created there is not a person's answer, and it can be as wide as any target, no bound and no rate for 90 days: create grants only where the harness asks. - An earlier copy of the grants directory put back whole is not detected. Expiry, at most 90 days, bounds what it can restore.
- Anyone who can read the key can sign grants. Keep it where the agent's tools cannot read it.
A Hermes gateway keeps the environment it started with; see Settings before changing the job's variables.
Settings
Every entry point takes the same settings. A flag wins over its environment variable, and a setting in Hermes's configuration wins over the variable too.
| Setting | Flag | Variable | Meaning |
|---|---|---|---|
toolsets | --toolsets | OPENCODE_TOOLS_TOOLSETS | the toolsets that are on, or all; default those src/project.ts names |
read_only | --read-only | OPENCODE_TOOLS_READ_ONLY | registers no tool that writes; wins over every other setting |
unattended | --unattended | OPENCODE_TOOLS_UNATTENDED | no person can answer: a write runs only under a grant that covers it; off by default |
grants_dir | --grants-dir | OPENCODE_TOOLS_GRANTS_DIR | where grants and their use are kept; default $XDG_STATE_HOME/opencode-tools/grants, else ~/.local/state/opencode-tools/grants |
tools | --tools | OPENCODE_TOOLS_TOOLS | single tools to add by ID, whatever their toolset |
exclude_tools | --exclude-tools | OPENCODE_TOOLS_EXCLUDE_TOOLS | single tools to remove by ID; wins over tools and toolsets |
confirm | --confirm | OPENCODE_TOOLS_CONFIRM | MCP server only: harness (default) or elicitation, as the conventions say |
caller | --caller | OPENCODE_TOOLS_CALLER | MCP server and command line: whose runs these are, at most 200 characters; unset, the MCP client's name, else mcp, or cli |
language | --language | OPENCODE_TOOLS_LANGUAGE | Hermes only: the approval prompt's language, such as ja |
emoji | — | — | Hermes only: the emoji shown beside each toolset, by toolset name ("" for none) |
require_plugins | — | — | Hermes only: the plugins that must be loaded; while one is not, every write is refused before it is approved |
notify | — | — | Hermes only: true hands a run's next stop to the chat that started it; needs Hermes' allow_gateway_injection too; unset, off |
roles | --roles | OPENCODE_TOOLS_ROLES | the roles a run can start under, as JSON; unset, plan (read-only) and build (write), OpenCode's own agents |
rules | --rules | OPENCODE_TOOLS_RULES | permission rules of your own for a run, per policy, as JSON; unset, none |
note | --note | OPENCODE_TOOLS_NOTE | text added to what every run is told; unset, none |
never_approve | --never-approve | OPENCODE_TOOLS_NEVER_APPROVE | action patterns (* for any text) a request for which can only be rejected; unset, none |
read_roots | --read-roots | OPENCODE_TOOLS_READ_ROOTS | directories a read-only run may read outside its worktree; unset, none |
output_roots | --output-roots | OPENCODE_TOOLS_OUTPUT_ROOTS | where a run's output directory may sit; unset, a run has none |
protected_dirs | --protected-dirs | OPENCODE_TOOLS_PROTECTED_DIRS | checkouts no write run may start in; unset, none |
worktree_root | --worktree-root | OPENCODE_TOOLS_WORKTREE_ROOT | where a run's worktree is made, as an absolute path; unset, opencode-tools/worktrees under XDG_DATA_HOME, else ~/.local/share |
allowed_providers | --allowed-providers | OPENCODE_TOOLS_ALLOWED_PROVIDERS | the providers a start can name a model of, by id as OpenCode lists them; unset, a start can name none |
caller_models | --caller-models | OPENCODE_TOOLS_CALLER_MODELS | the models the calling agent answers with, each with or without its provider; unset, no run is refused for its model |
wait_seconds | --wait-seconds | OPENCODE_TOOLS_WAIT_SECONDS | how long one call may take as a whole, a wait included, in seconds; default 50, 1 to 3300 |
The settings from roles down are the package's own, and each arrives with
the tools that read it. roles and rules are maps: a mapping in Hermes's
configuration, and JSON text in a flag or a variable. A role names an
OpenCode agent and a policy, with an optional model, alternate,
caller_model and note:
{
"plan": { "agent": "plan", "policy": "read-only" },
"build": {
"agent": "build",
"policy": "write",
"model": "<provider>/<model>#<variant>",
"alternate": "<provider>/<model>"
}
}
A role's model is what its runs use; without one they use the agent's own
model, else the service's default. Its alternate is a second model for
when the first is refused for a limit: nothing switches to it by itself.
A role's own model and alternate need no entry in allowed_providers, which
says what else a start can name.
A role's name is a lowercase letter followed by up to 23 lowercase letters, digits or underscores, and there are at most 20 roles. A role that breaks the shape is refused when the settings are read, so no tool is registered until it is fixed.
Under Hermes each conversation is a caller of its own, and the plugin has no
caller setting. A conversation is its chat, thread and sender in one
profile: it keeps its runs after /new, a compressed context or a restart,
and another chat, thread, sender or profile does not see them. A call with no
conversation, as in a cron job, is its session. The plugin also passes the
model the session last answered with, added to caller_models, so the
refusal of the caller's own model works there with nothing configured, and
follows a fallback or a model changed in the middle of a conversation.
OPENCODE_TOOLS_GRANT_KEY is a variable only, never a flag or a setting. Use
at least 32 characters, for example from openssl rand -hex 32,
stored where the host keeps secrets. Without it no write runs while
unattended and no grant can be created. Codex forwards it alongside the
settings' variables, as described below.
Lists are comma-separated in a flag or a variable. A package's own settings,
listed in options in src/project.ts, take a row each here and are read the
same way. A path is trimmed; ~ and ~/… (also with the platform separator)
stand for the home directory (HOME when it is absolute, else the account's).
It must then be absolute and reaches the tool normalized,
without a filesystem check. paths is a list of such paths, comma-separated
in a flag or variable and a list in Hermes's configuration. Blank paths
and lists with no items after trimming and dropping blanks count as unset.
Bounds check only a given value, not an unset option. Refused values are
invalid_argument, naming the flag or variable and what it must be.
Hermes passes paths and lists to the command line, which checks the paths and
bounds. Where each harness reads them:
-
Hermes takes
plugins.entries.opencode-tools.settingsinconfig.yaml:plugins: entries: opencode-tools: settings: read_only: false exclude_tools: []Without a
languagesetting, the approval card follows Hermes's owndisplay.language(orHERMES_LANGUAGE), the language of its approval buttons, and else stays in English. The plugin passes its own environment to the command line it runs, so the variables work too. A running gateway keeps the environment it started with; restart it (hermes gateway restart) after changing one.The package has words in Japanese (
ja): the card of every write tool of therun,request,instructionandworktreetoolsets says what is about to happen, labels its facts and words what stands where the call names nothing (a model, a new session, a missing branch) in Japanese. What the call carries stays as written: a role, a policy, a state, a model, a branch, a path, and the whole of the brief, the message, the replies or the value. The grant tools' cards and every other language read English. -
Claude Code, Grok Build and Antigravity start the plugin's server without flags and pass it the client's environment, so set the variables in the environment the harness runs in.
-
Codex passes a plugin's MCP server only a few basic variables (such as
PATHandHOME) and those the plugin's manifest names, which are the variables above: set them in the environment Codex runs in. A variable the tools read besides the settings belongs intoolVariablesinsrc/project.ts;pnpm run manifestsadds it to the manifest after the settings' variables. To pass flags, or to give the server a variable the package does not name, add the server under[mcp_servers]in Codex'sconfig.tomlinstead of using the plugin: flags go inargs,env_varsnames the variables to forward from Codex's environment, andenvsets fixed values.[mcp_servers.opencode-tools] command = "npx" args = ["-y", "@craftsamo/opencode-tools@<version>", "--read-only"] env_vars = ["OPENCODE_TOOLS_TOOLSETS"]
Layout
src/project.ts— the package's name, tool ID prefix, setting prefix, toolsets, tool options and the other variables its tools read.src/core/— the tool contract and the tools, free of any harness and of the project's names.src/tools.ts— the list of every tool, which each entry point registers.src/words.ts— the translations of the tools' words, per language, joined from thewords.tsbeside each domain's tools, which the Hermes plugin uses in its approval prompts.src/mcp/— the MCP server, built todist/mcp.jsand run byopencode-tools.src/cli/— the command line the Hermes plugin calls, built todist/cli.jsand run byopencode-tools-cli.src/hermes/,plugin.yamland__init__.py— the Hermes plugin.skills/— a skill per toolset and one on briefing,skills/<name>/SKILL.md, which every harness that takes skills loads from the package or plugin root; the Hermes plugin loads only those of the toolsets that are on..claude-plugin/,.codex-plugin/,.agents/plugins/,.mcp.json,.antigravity-plugin/andmcp_config.json— the plugin manifests of the other harnesses. Codex reads.codex-plugin/plugin.json; a rootplugin.jsonwould make it load the plugin as an Agent Plugin, whose tool budget hides tools past a fixed size. The root.mcp.jsonis the configuration Grok Build reads (with${CLAUDE_PLUGIN_ROOT}, the variable both Grok Build and Claude Code expand); when working on this repository in Claude Code, decline the project MCP server it offers from that file.
How a release is made is in RELEASING.md.
License
@craftsamo/opencode-toolsnpm install @craftsamo/opencode-toolsRelated Servers
io.github.craft-agent/cloudflare-tools
Cloudflare tools for coding agents: zones, DNS, analytics, Workers, Pages, storage and tunnels.
io.github.craft-agent/discord-tools
Discord tools for coding agents: chats, messages, search, inbox, files, sends and roles.
io.github.craft-agent/git-tools
Git tools for coding agents: state, commits, rewrites and stacked branches, worktrees and pushing.