OpenProgram Docs

Plugin runtime

A plugin is a manifest naming skills, commands, agents, hooks, MCP servers and provider directories. The host mounts them through one ProgramContext; no plugin code is imported and there is no plugin-only registry. Manifest forms, sources, trust: Skills and plugins. Model: Program Model.

Lifecycle

StepWhat happens
rescanBuilds Plugin records, with any code refusal as the error. Keeps a loaded plugin at the same root; a changed root deactivates it first. Enabled set: ~/.openprogram/plugins-enabled.json
load_plugin checkNo code, trust, compatibility, requires (dependencies load first)
ActivateProgramContext(name, root, options), owner plugin:<name>; manifest keys become effects. Any exception: ctx.dispose(), error kept on the plugin
After loadEmit plugin.enable, broadcast plugins:changed
unload_pluginEmit plugin.disable, then ctx.dispose()
reload_pluginUnload, rescan, load. Stays enabled if the new files fail

At startup _load_plugins in interfaces/server/server.py runs after the MCP servers, hands the loop to set_host_loop, and calls loader.load_enabled() on a thread: dependency order, each failure logged without stopping the others.

SourceLocation
npm~/.openprogram/plugins/node_modules/
Path~/.openprogram/plugins/<name>. install path <dir> symlinks it: edits apply on reload, uninstall removes only the link
Project pinsLater sources win a name clash

Effects

Manifest keyEffectHost registryUndo
skillsctx.skills(dir)skills plugin sourceUnregister the source
commandsctx.command(name, prompt, description)contrib["_commands"], read by the commands registry adapterCleared with the contributions
hooksctx.gate, ctx.on with a shell gate or notifierEventBus.subscribe_gate, subscribeThe subscription's disposer
mcpServersctx.mcp_server(name, config)add_server as <plugin>_<name> on the host loop; never in mcp_servers.jsonremove_server
providersctx.provider_root(dir)models/providers/catalog/plugin_dirs.py, behind provider.json lookups. Shipped directories win a clashRemove the root
agentsmanager.create as <plugin>-<name> when missingAgent registryNone: deleting an agent deletes its sessions

ctx.dispose() runs disposers in reverse, collects errors instead of stopping, and empties ctx.contributions, the per-kind record the Plugins page and plugin tool show. Defined in programs/_host/context.py.

Code is refused

extensions/plugins/manifest.py records keys naming code in code: python, module, setup, main, tools, client, web, sidebar, a module:name hooks value, an __init__.py beside a Hermes plugin.yaml. code_refusal names them and says to add an application.json and run openprogram programs install <dir>.

EntryRefusal
installer.installRefuses a path install, removes a git clone, uninstalls an npm package. pip is not a source
rescanLists the plugin with the refusal as its error
_check, _activateRaise PluginContainsCode (a PermissionError); the toggle route answers 403, code: "contains_code"

Hooks

AspectRule
Shapes (plugins/hooks.py)Inline or a JSON file. OpenProgram: {event: [{command, timeout, shell, args}]}, as in config.json; shell and args are optional (which shell runs a hook). Claude Code: {hooks: {PreToolUse: [{matcher, hooks: [{type: "command", command}]}]}}
CLAUDE_EVENTSPreToolUse → tool.before, PostToolUse → tool.after, UserPromptSubmit → chat.before_send, Stop → turn.stop, SessionStart → session.start
Substitution${CLAUDE_PLUGIN_ROOT} is the plugin directory; matcher is a regular expression over the event's tool
Execution (runtime/events/shell_hooks.py)Event as JSON on stdin. On a gate event, exit 2 denies with stderr as the reason; any other exit allows
SkippedUnknown events, non-command hook types, transform events
Event kind (runtime/events/registry.py)Behavior
notifyObservers; return values ignored
gateMay veto (tool.before, turn.stop)
transformEach rewriter gets (event, value) and returns the new value; None keeps it; one that raises is skipped

tool.result is a transform: _rewrite_tool_result joins the text blocks and replaces the text, keeping images and audio. Applications subscribe with ctx.transform; plugins cannot.

Self-description, tool, CLI

PartBehavior
extensions/plugins/inspect.pydescribe() from live registries: allowed and refused keys, each event with kind and hook eligibility, the Claude Code map, exposure tiers, every entry with owner, tier and approval flag. guide() is the same as text. Backs GET /api/plugins/inspect, openprogram plugins inspect [--json], the plugin tool
plugin tool (programs/tools/runtime/plugin.py)guide, inspect, list, install (link, trust as community, enable), enable, disable, reload, uninstall. Runs in the worker (_run_in_worker), requires approval, unavailable on chat channels and in plan mode. Code is refused with the same message
CLIenable, disable, install, uninstall, reload call the worker's HTTP API first, else edit the state files
WebNo UI from plugins: no routes or shell slots for Web modules, pages, sidebar rows. The plugins page lists contributions and refreshes on plugins:changed. A screen is an application's application.json UI

Implementation status

Implemented as described, except: auto-discovery of Claude Code's default directories (commands/, agents/, skills/, hooks/hooks.json) when the manifest omits them; Claude Code's prompt hook type; lspServers and outputStyles, parsed and ignored.

Last updated · 2026-11-25