OpenCode
Every OpenCode session knows where your project stands, through one small plugin.
In OpenCode, a plugin gives every session the brief and saves your work when a turn finishes and
before a compaction. Type /gw to resume or save. Needs OpenCode 2.x.
npx groundwork-ai init --adapter opencode # or: npx groundwork-ai adapter add opencodeWhat happens when
| When | How | What happens |
|---|---|---|
| A session starts | The context hook | The brief is added to the system prompt, refreshed at most every 15 seconds |
| A turn ends | The session.idle event | A checkpoint. If the handoff is behind, a reminder to save rides on the next model call |
| Before a compaction | The compaction hook | A checkpoint, and the summary is told what to keep |
| The session ends | Nothing | OpenCode has no session-end hook |
You type /gw | Command | Resume from memory, or save |
Session start
The brief comes from .groundwork/hooks/session-start.mjs, the same script every adapter uses. It
is what npx groundwork-ai brief prints.
Files it writes
| Path | What it is |
|---|---|
.opencode/plugins/groundwork-memory.js | The plugin: the brief and the checkpoints |
.opencode/commands/gw.md | The /gw command |
OpenCode reads AGENTS.md itself. For non-interactive runs, use opencode run --standalone so the
project's plugin loads.
With the optional flow on
init --flow or flow on adds:
| Added | What it does |
|---|---|
/gw-approve, /gw-reject | Commands for you. Only a message whose first line is the command counts as an approval |
.opencode/agents/gw-*.md | Tester, implementer and reviewer subagents. The reviewer has edit: deny |
.opencode/plugins/groundwork-guards.js | Replaces the memory plugin. Before every tool call it runs the commit gate, protects Groundwork's own files, and runs your guards |
What it does not enforce:
- Who typed the approval. The plugin records prompts from your top-level session and ignores subagents. That tells a command from conversation. It doesn't prove who sent it.
- The model running an approval command. The commands say they are for the human, and the runner is told never to run them. Nothing stops it outright.
- Everything, when the config can't be read. Commits are blocked. Other calls go through with a warning.
Status
Built from OpenCode's 2.x plugin documentation. The compaction hook and the idle-event checkpoint have not yet been run inside a live session. If either is unavailable, the plugin warns and keeps the rest working.