Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

Builder for a skills ResolvedRegistry. Downstream binaries (kglite-mcp-server, etc.) construct one of these in their boot path, layer in their bundled + operator-declared skills, then call Registry::finalise to get the resolved set ready for MCP prompts/list + prompts/get wiring.

See the module docs for the canonical usage pattern.

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

Construct an empty registry. Chain in add_bundled, merge_framework_defaults, layer_dirs, auto_detect_project_layer, and optionally with_predicate_evaluator, then call finalise().

Source

pub fn with_predicate_evaluator( self, evaluator: impl SkillPredicateEvaluator + 'static, ) -> Self

Register a domain-specific predicate evaluator for the applies_when: machinery. The evaluator only sees domain predicates (graph_has_node_type, graph_has_property); framework-internal ones (tool_registered, extension_enabled) are dispatched against the McpServer’s runtime state at serve_prompts time.

Without an evaluator, skills using domain predicates resolve to inactive (predicate Unknown → skill suppressed). This is the safe default: a typo’d predicate or a missing evaluator must not silently activate the wrong-domain skill.

Source

pub fn add_bundled(self, skill: BundledSkill) -> Self

Add a compile-time bundled skill. Typically called by downstream binaries with their own include_str!’d skills, once per custom tool.

Bundled skills sit at the bottom of the three-layer composition; later layers override them when names collide. Within the bundled set, the downstream binary’s skills win over framework defaults (the downstream calls add_bundled before or after merge_framework_defaults — order doesn’t matter; resolution dedupes by name with downstream-first priority).

Malformed bundled skills are reported at finalise() time via SkillError::BundledSkillInvalid. The framework’s own bundled-skill CI test should catch this for the library defaults; downstream binaries should write equivalent tests for their own bundled set.

Source

pub fn add_bundled_many( self, skills: impl IntoIterator<Item = BundledSkill>, ) -> Self

Add a batch of compile-time bundled skills.

Source

pub fn merge_framework_defaults(self) -> Self

Merge in the framework’s own bundled defaults (returned by library_bundled_skills). Idempotent — calling twice is harmless (later calls add duplicates which the finalise deduper drops, downstream-first).

Source

pub fn layer_dirs( self, source: &SkillsSource, yaml_path: &Path, ) -> Result<Self, SkillError>

Layer in skill directories declared in the manifest’s skills: field, walked in declaration order. Each path becomes a domain-pack-layer source; the bundled marker true is acknowledged but its skills are already in the bundled layer via add_bundled/merge_framework_defaults.

Path resolution uses the same conventions as the rest of the manifest (./foo relative to YAML dir, ~/foo home-relative, /foo absolute). Non-existent paths are reported as SkillError::PathNotFound at this call site so operators see typos immediately.

Source

pub fn auto_detect_project_layer(self, yaml_path: &Path) -> Self

Auto-detect the project layer at <basename>.skills/ adjacent to the manifest YAML. Always called; the directory is optional — if it doesn’t exist, the project layer is simply empty.

Source

pub fn finalise(self) -> Result<ResolvedRegistry, SkillError>

Resolve all three layers and return the final registry.

Resolution order per skill name: project > root layer (in declaration order) > bundled. The first source that contributes a skill with the given name wins; later sources are ignored for that name (no merging, no inheritance — full-file replacement).

At this point the framework:

Trait Implementations§

Source§

impl Debug for Registry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more