Skip to main content
xbot
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

Plugin Cookbook

Hands-on recipes for building xbot plugins. Every recipe starts with a working example drawn from the real plugin code in this repository (plugin/examples/, plugins/xbot-genui, plugins/xbot-git-fancy) and explains the API behind it.

What you will learn

RecipeWhat you build
Quick Start: Script PluginA git-info status widget in bash — no compilation
Quick Start: Go PluginA native Go plugin with tools, hooks, and a context enricher
Quick Start: Stdio PluginA Python plugin speaking NDJSON over stdio
Quick Start: Web PluginA frontend ESM view panel
Script PluginsFull guide: widgets, env vars, triggers, sync hints
Go PluginsFull guide: PluginContext, SDK helpers, UI bridges
Stdio PluginsFull guide: protocol handlers in any language
Channel PluginsFull channel adapters: tools, prompts, web UI
Web PluginsType-as-contract frontend plugins with @xbot/plugin-api
ConfigurationDeclarative plugin settings with defaults
WidgetsStatus bar, info bar, and footer widgets
HooksLifecycle events: deny, ask, defer, allow
ToolsRegistering tools the agent can call
Event BusPlugin-to-plugin pub/sub
StoragePersistent per-plugin key-value state
PermissionsThe complete permission catalogue
DependenciesPlugin dependency graphs and activation order
DebuggingLogs, profiler, hot reload
TestingTestKit, mocks, and golden tests
PublishingDistribution, checksums, migration

The five-minute path

New to xbot plugins? Follow the four Quick Start recipes in order. They cover the four runtimes supported by plugin.NewCompositeRuntimeFactory() (plugin/runtime_factory.go):

switch manifest.Runtime {
case RuntimeNative:  // in-process Go
case RuntimeGRPC, RuntimeStdio: // external NDJSON process
case RuntimeScript: // periodic external script
}

Each runtime targets a different trade-off: script for zero-build widgets, native Go for tight integration, stdio for any language, and web for UI-only frontend extensions. A single plugin.json can combine them — see the built-in xbot.git-fancy plugin, which pairs a Go stdio backend with a React view.

Where plugins live

~/.xbot/plugins/<plugin-id>/
├── plugin.json      # manifest — id, runtime, entry, permissions, contributes
├── <entry file>     # main.sh / main.go / main.py / web/index.js
└── data/            # runtime storage (created automatically)