Building Plugins
oxide-code (ox) keeps its Rust core (ox-core) minimal and exposes every major agent surface to out-of-process plugins. Plugins communicate with the host over stdio using newline-delimited JSON-RPC 2.0 (NDJSON), so you can write them in Rust, Python, TypeScript, Go, or any language that reads stdin and writes stdout.
See Plugin Protocol for the full wire specification and JSON schemas.
Why Build on ox
Section titled “Why Build on ox”- Zero language lock-in: Each plugin is a standalone executable spawned by the host over stdio NDJSON, with no Rust crate dependency on
ox-coreinternals. - One protocol for every surface: A single plugin process can provide tools, slash commands, lifecycle hooks, system prompt sections, attachment converters, compaction, and contextual hints.
- Declarative configuration: Users configure plugins under
[[plugins]]inconfig.toml, passing customenvvariables and an arbitraryconfigobject thatoxforwards ininitialize. - Safe defaults and graceful lifecycle: The host inherits plugin stderr for diagnostics, enforces per-request timeouts (
timeout_ms), sendsshutdownon exit, and terminates the child process on exit.
Configuring a Plugin
Section titled “Configuring a Plugin”Register a plugin executable in config.toml under [[plugins]]:
[[plugins]]name = "my-plugin"command = ["/path/to/my-plugin", "--stdio"]timeout_ms = 30000env = { MY_PLUGIN_MODE = "strict" }config = { retries = 3 }After spawning the process, ox sends initialize with protocol_version, config, and state_db_path. Your plugin responds with a PluginManifest declaring the capabilities it provides.
Extension Points
Section titled “Extension Points”Custom Tools
Section titled “Custom Tools”Declare tools with JSON Schema input_schema entries in PluginManifest.tools. When the model invokes a plugin tool, the host sends tool/call with name and arguments and returns { content, is_error } to the model.
Slash Commands and Overriding /stats
Section titled “Slash Commands and Overriding /stats”Declare slash commands in PluginManifest.commands (with optional default_keybinding) or serve them dynamically via command/list.
- Use
command/invoketo receive the raw argument string alongside runtimecontext(state_db_path,session_id,cwd,model, andprovider) and return{ content, description, mode }, wheremodeis"markdown","system", or"prompt". - Plugins can override the built-in
/statscommand by advertising a command namedstats. The host injectsOX_STATE_DBinto the plugin environment and passesstate_db_pathininitializeandcommand/invoke, allowing a custom/statsplugin to query$XDG_STATE_HOME/ox/state.dbdirectly.
Custom Compaction
Section titled “Custom Compaction”Set "compaction": true in PluginManifest to handle automatic and manual (/compact) conversation compaction via compaction/compact. The host sends the older messages, optional previous_summary, user focus, hook_guidance from PreCompact hooks, trigger, and active model. If a plugin declines or returns an error, ox falls back automatically to its built-in LLM summarizer.
Lifecycle Hooks
Section titled “Lifecycle Hooks”Subscribe to lifecycle events in PluginManifest.hooks with optional matcher and on_error fields. The host delivers hook/invoke with the same HookInput payload used by command hooks, letting your plugin inspect, block, or rewrite tool inputs.
System Prompt Sections
Section titled “System Prompt Sections”Inject domain-specific instructions into the system prompt by returning static prompt_sections in PluginManifest or implementing prompt/sections to compute sections dynamically for the current working directory (cwd).
Attachment Converters
Section titled “Attachment Converters”Advertise supported MIME types or wildcard patterns (such as "application/pdf" or "video/*") in PluginManifest.attachment_converters. When a model does not accept an attachment’s media type or size natively, the host calls attachment/convert with either inline data_base64 or a local file path, and your plugin returns wire-neutral ContentBlock items such as extracted text or rendered images.
Contextual TUI Hints
Section titled “Contextual TUI Hints”Surface lightweight, contextual tips in the TUI hint bar either statically through PluginManifest.hints or dynamically during a request with the host/emit_hint callback. To keep the interface uncluttered, ox enforces anti-abuse guardrails on plugin hints:
- Namespacing: Hint IDs are namespaced as
<plugin_name>:<id>so plugins cannot collide with built-in or third-party hints. - Sanitization: Hint text is sanitized before display.
- Priority clamping: Plugin hint priorities are clamped to the allowed plugin range.
- Rate-limiting: Per-hint show caps, cooldowns, and minimum intervals from
[tui.hints]apply automatically.
Host Callbacks
Section titled “Host Callbacks”While handling an in-flight request, a plugin can send JSON-RPC requests or notifications back to the host on stdout. See Plugin-to-Host Callbacks for parameter and result fields:
| Method | Purpose |
|---|---|
host/log |
Emit structured diagnostics (level, message, optional target) |
host/ask_permission |
Prompt the user through the host permission gate before sensitive work |
host/invoke_tool |
Call another registered tool through the host |
host/complete |
Request a one-shot LLM completion from the configured provider |
host/emit_hint |
Emit a dynamic contextual hint to the TUI hint bar |
Official Plugins
Section titled “Official Plugins”The workspace ships three official out-of-process plugins under plugins/:
ox-plugin-mcp: Bridges stdio and Streamable HTTP MCP servers as plugin tools.ox-plugin-stats: Overrides/statsby querying the SQLite state database and advertising a contextual TUI hint.ox-plugin-compaction: Implementscompaction/compactusing thehost/completecallback.
Next Steps
Section titled “Next Steps”- Plugin Protocol: Complete NDJSON-RPC 2.0 request, response, and callback schemas.
- MCP Plugin: Configuring
ox-plugin-mcpfor stdio and Streamable HTTP MCP servers. - Compaction: Automatic and manual compaction, preservation, and session boundaries.
- Hooks: Lifecycle hook events, matchers, and error policies.
- Configuration: Layering
config.tomland bundling plugins inpackage_roots.