Jido.AI.Skill.Registry (Jido AI v2.2.0)

Copy Markdown View Source

ETS-backed registry for runtime-loaded skills.

Stores skill specs in an ETS table for fast lookup by name. Supports loading skills from directories at startup.

Lifecycle

Jido.AI.Skill.Registry supports two startup modes:

  1. Explicit startup via start_link/1 under your supervisor tree.
  2. Lazy startup via ensure_started/0, which is called automatically by public API functions.

This ensures consistent startup behavior regardless of supervision order.

Summary

Functions

Checks if a skill has been activated in this session.

Lists all registered skill specs.

Returns a specification to start this module under a supervisor.

Clears all registered skills.

Deactivates a skill, removing it from the activation table.

Checks if a skill is marked as durable.

Starts the registry unless it is already running.

Gets the activation context for an activated skill.

Lists all registered skill names.

Lists all activated skill names in the current session.

Loads all SKILL.md files from the given paths.

Looks up a skill by name.

Marks a skill as activated with its activation context.

Marks an activated skill as durable, protecting it from compaction.

Registers a skill spec in the registry.

Starts the registry.

Unmarks a durable skill, allowing it to be compacted.

Unregisters a skill by name.

Functions

activated?(name)

@spec activated?(String.t()) :: boolean()

Checks if a skill has been activated in this session.

all()

@spec all() :: [Jido.AI.Skill.Spec.t()]

Lists all registered skill specs.

The registry is lazily started on first access.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok | {:error, term()}

Clears all registered skills.

The registry is lazily started on first access.

deactivate(name)

@spec deactivate(String.t()) :: :ok | {:error, term()}

Deactivates a skill, removing it from the activation table.

Fails if the skill is marked as durable.

durable?(name)

@spec durable?(String.t()) :: boolean()

Checks if a skill is marked as durable.

ensure_started()

@spec ensure_started() :: :ok | {:error, term()}

Starts the registry unless it is already running.

get_activation_context(name)

@spec get_activation_context(String.t()) :: {:ok, map()} | {:error, :not_activated}

Gets the activation context for an activated skill.

Returns

  • {:ok, context} - Skill is activated, context returned
  • {:error, :not_activated} - Skill not found in activation table

list()

@spec list() :: [String.t()]

Lists all registered skill names.

The registry is lazily started on first access.

list_activated()

@spec list_activated() :: [String.t()]

Lists all activated skill names in the current session.

load_from_paths(paths)

@spec load_from_paths([String.t()]) :: {:ok, non_neg_integer()} | {:error, term()}

Loads all SKILL.md files from the given paths.

The registry is lazily started on first access.

lookup(name)

@spec lookup(String.t()) :: {:ok, Jido.AI.Skill.Spec.t()} | {:error, term()}

Looks up a skill by name.

mark_activated(name, context)

@spec mark_activated(String.t(), map()) :: :ok | {:error, term()}

Marks a skill as activated with its activation context.

Used by Jido.AI.Skill.Activation to track activated skills.

mark_durable(name)

@spec mark_durable(String.t()) :: :ok | {:error, term()}

Marks an activated skill as durable, protecting it from compaction.

Durable skills remain in the activation table until explicitly deactivated or the registry is cleared.

register(spec)

@spec register(Jido.AI.Skill.Spec.t()) :: :ok | {:error, term()}

Registers a skill spec in the registry.

start_link(opts \\ [])

Starts the registry.

unmark_durable(name)

@spec unmark_durable(String.t()) :: :ok | {:error, term()}

Unmarks a durable skill, allowing it to be compacted.

unregister(name)

@spec unregister(String.t()) :: :ok | {:error, term()}

Unregisters a skill by name.

The registry is lazily started on first access.