Skip to main content

Discovery & Entry Points

Kernle uses Python’s importlib.metadata entry points to discover installed components at runtime. This means plugins, stacks, models, and stack components can be installed as separate packages and automatically found by the core.

How It Works

  1. A package declares entry points in its pyproject.toml
  2. When the package is installed, Python’s metadata registry records the entry points
  3. Kernle’s discover_*() functions scan the registry for matching groups
  4. load_component() imports the class and returns it for instantiation

The Four Entry Point Groups

Registration Examples

Each entry point maps a name to a module:class reference:

Discovery Functions

The kernle.discovery module provides four targeted discovery functions plus a catch-all:

DiscoveredComponent

Every discovery result is a DiscoveredComponent dataclass:

How Entity Uses Discovery

When Entity.discover_plugins() is called, it:
  1. Calls discover_plugins() to scan the kernle.plugins entry point group
  2. Returns a list of PluginInfo for each discovered plugin (name, version, description, capabilities)
  3. The CLI kernle status command shows discovered plugins alongside loaded ones
Loading a discovered plugin is separate from discovering it:

How SQLiteStack Uses Discovery

SQLiteStack can auto-load stack components from entry points:
By default, SQLiteStack uses the 8 built-in components (from get_default_components()). But load_components_from_discovery() will also pick up third-party components installed via separate packages. If a component fails to load (import error, missing dependency), it logs a warning and skips that component — other components still load normally.

CLI Status Display

kernle status shows the current composition, including discovered components:

Building a Discoverable Package

To make your plugin, model, or component automatically discoverable:
  1. Implement the relevant protocol
  2. Add entry point registration to pyproject.toml
  3. Install the package (pip install . or pip install -e .)
  4. Kernle discovers it on next startup
After pip install kernle-mymodel, running discover_models() will include my-model in the results.