~/groundwork

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 opencode

What happens when

WhenHowWhat happens
A session startsThe context hookThe brief is added to the system prompt, refreshed at most every 15 seconds
A turn endsThe session.idle eventA checkpoint. If the handoff is behind, a reminder to save rides on the next model call
Before a compactionThe compaction hookA checkpoint, and the summary is told what to keep
The session endsNothingOpenCode has no session-end hook
You type /gwCommandResume 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

PathWhat it is
.opencode/plugins/groundwork-memory.jsThe plugin: the brief and the checkpoints
.opencode/commands/gw.mdThe /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:

AddedWhat it does
/gw-approve, /gw-rejectCommands for you. Only a message whose first line is the command counts as an approval
.opencode/agents/gw-*.mdTester, implementer and reviewer subagents. The reviewer has edit: deny
.opencode/plugins/groundwork-guards.jsReplaces 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.

On this page