OpenCode
Run OpenCode with hard Statewright tool enforcement and live state model routing
OpenCode
Launch OpenCode through the shared executor:
node plugins/executor/statewright-exec.mjs \
--host opencode --workflow bugfix --cwd "$PWD" -- \
"Fix the failing tests"The executor injects the Statewright plugin and loopback MCP server through OPENCODE_CONFIG_CONTENT. The child process does not receive the remote Statewright API key.
The plugin uses OpenCode's native APIs to:
- enforce pre-tool policy before execution;
- account post-tool results to the active state;
- apply the state's provider/model and reasoning variant to outgoing messages;
- continue a nonfinal workflow in the same session through
session.prompt; - stop continuation while an approval is pending or the workflow is final.
OpenCode has no Claude-style UserPromptSubmit hook. State context therefore arrives through the initial prompt, tool results, same-session continuation prompts, and operator toasts. Tool enforcement and model routing remain native and enforced.