Skip to main content

mellea.plugins.pluginset

PluginSet — composable groups of hooks and plugins.

Classes

CLASS PluginSet

A named, composable group of hook functions and plugin instances.

PluginSets are inert containers — they do not register anything themselves. Registration happens when they are passed to register() or start_session(plugins=[...]).

PluginSets can be nested: a PluginSet can contain other PluginSets.

PluginSets also support the context manager protocol for temporary activation::

with PluginSet("observability", [log_hook, audit_hook]): result, ctx = instruct("Summarize this", ctx, backend)

or async

async with PluginSet("guards", [safety_hook]): result, ctx = await ainstruct("Generate code", ctx, backend)

Args:

  • name: Human-readable label for this group.
  • items: Hook functions, plugin instances, or nested PluginSet instances.
  • priority: Optional priority override applied to all items in this set.

Methods:

FUNC flatten

flatten(self) -> list[tuple[Callable | Any, int | None]]

Recursively flatten nested PluginSets into (item, priority_override) pairs.

When this set has a priority, it overrides the priorities of all nested items — including items inside nested PluginSet instances.

Returns:

  • Flattened list of (item, priority_override) pairs.