Give operators a single, highest-priority prompt slot that sits in front of every agent/persona/mode prompt. OpenCode core builds the system prompt as agent prompt → environment → instruction (AGENTS.md). This plugin prepends one operator-controlled file so operating rules (AGENTS.md, model-preservation, verification steps) are treated as mandatory and not overridden by later persona prompts.
- Entry: default export with
idand asyncserver(ctx, options). - Prompt reader:
createPromptReaderresolves the configuredfile(home-expanded, absolute or relative toctx.directory), caches bymtimeMs, returns trimmed content. - Hook:
experimental.chat.system.transform(_input, output)runs at request time. Guards on emptyoutput.system, reads the prompt, strips any prior injected block, then prepends[START_MARKER, prompt, END_MARKER, existing]. - Idempotency:
stripPreviousInjectiononly strips when the start marker is at index 0, so repeated transforms/retries do not stack duplicates.
- Single-file plugin, zero dependencies, working smoke test.
- One commit (
fb0f871). Installed and wired in global~/.config/opencode/opencode.jsonplugin array. - Behavior verified: smoke test passes; ordering and idempotency hold.
- Transformed
system[]is in-memory only; not written to session storage (no on-disk per-session proof). - Only
output.system[0]is modified; assumes the lead block carries the agent prompt.
- Optional: multiple injection files / ordered blocks.
- Optional: per-agent or per-mode prompt selection.