pub struct Catalogue {
pub prefix: String,
pub errors: BTreeMap<String, String>,
/* private fields */
}Expand description
The catalogue + body cache.
Fields§
§prefix: String§errors: BTreeMap<String, String>Discovery errors per server (surfaced in status, never fatal).
Implementations§
Source§impl Catalogue
impl Catalogue
pub fn new(prefix: &str, max_bytes: usize) -> Catalogue
Sourcepub fn discover(
&mut self,
server: &dyn SkillServer,
mode: Discover,
filter: Option<&str>,
) -> Vec<String>
pub fn discover( &mut self, server: &dyn SkillServer, mode: Discover, filter: Option<&str>, ) -> Vec<String>
(Re)discover the skills of one server. Later sources do not override an existing name (first source wins; a collision is logged by the caller). Returns the names discovered on this server.
Sourcepub fn forget_server(&mut self, server: &str)
pub fn forget_server(&mut self, server: &str)
Forget every skill of server (before a re-discovery).
pub fn get(&self, name: &str) -> Option<&SkillMeta>
pub fn names(&self) -> Vec<String>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn list_value(&self) -> Value
pub fn list_value(&self) -> Value
skills.list output.
Sourcepub fn render_catalogue(&self) -> Option<String>
pub fn render_catalogue(&self) -> Option<String>
The catalogue block for a prompt (names + descriptions), or None
when empty.
Sourcepub fn load(
&mut self,
name: &str,
arguments: Option<Value>,
servers: &dyn Fn(&str) -> Option<Arc<dyn SkillServer>>,
) -> Result<SkillBody, String>
pub fn load( &mut self, name: &str, arguments: Option<Value>, servers: &dyn Fn(&str) -> Option<Arc<dyn SkillServer>>, ) -> Result<SkillBody, String>
Fetch (or serve from cache) a skill body. servers resolves the source
server by name.
Sourcepub fn add_inline(&mut self, skills: &[InlineSkill]) -> Vec<String>
pub fn add_inline(&mut self, skills: &[InlineSkill]) -> Vec<String>
A cached body by hash.
Register the instruction’s :::skill definitions. Inline skills win a
name collision with discovered ones — the operator wrote them CLOSER to
this agent than any server did.
Sourcepub fn add_dir(&mut self, dir: &Path) -> (Vec<String>, Vec<String>)
pub fn add_dir(&mut self, dir: &Path) -> (Vec<String>, Vec<String>)
Register a LOCAL folder of skill files.
Two layouts, because both are in the wild: <dir>/<name>.md, and the
Agent Skill directory form <dir>/<name>/SKILL.md. Either may carry
YAML frontmatter (name, description); without it the file stem is
the name and the first paragraph is the description, so a plain
markdown file is a usable skill with no ceremony.
Registered as SkillSourceKind::Inline with the body already read:
a skill is prose, so there is nothing to fetch later and nothing that
can fail at load time. Like :::skill, a local file WINS a name
collision with a discovered one — the operator put it closer to this
agent than any server did.
pub fn body(&self, hash: &str) -> Option<&SkillBody>
Sourcepub fn evict_except(&mut self, keep: &[String])
pub fn evict_except(&mut self, keep: &[String])
Drop cached bodies whose hash is not in keep.
Sourcepub fn references(&self, text: &str) -> Vec<String>
pub fn references(&self, text: &str) -> Vec<String>
The @skill:<name> references in a text (deduplicated, in order).