Skip to main content

devboy_skills/
source.rs

1//! [`SkillSource`] trait — pluggable backends for skill discovery.
2//!
3//! The baseline implementation (see [`crate::embedded`]) ships SKILL.md
4//! files compiled into the binary. The trait is kept minimal so that
5//! external sources (a marketplace, a Langfuse-backed registry) can be
6//! added later without reshaping the CLI or the install lifecycle.
7
8use async_trait::async_trait;
9
10use crate::error::Result;
11use crate::skill::{Skill, SkillSummary};
12
13/// A pluggable backend that can enumerate and load skills.
14///
15/// Implementations must be cheap to `list` — the CLI calls `list` on
16/// every invocation of `devboy skills list`. `load` is allowed to be
17/// heavier (opening files, issuing network calls) because it is only
18/// called on explicit install / show.
19#[async_trait]
20pub trait SkillSource: Send + Sync {
21    /// Short identifier for this source ("embedded", "marketplace", …).
22    /// Used in error messages and in `devboy skills list --source …`.
23    fn name(&self) -> &'static str;
24
25    /// List all skills known to this source. Order is source-defined;
26    /// callers should sort if they need a deterministic display.
27    async fn list(&self) -> Result<Vec<SkillSummary>>;
28
29    /// Load the full `Skill` (frontmatter + body) for the named skill.
30    ///
31    /// Returns [`crate::error::SkillError::NotFound`] if the source does
32    /// not know about `name`.
33    async fn load(&self, name: &str) -> Result<Skill>;
34}