agentmux_srv_core/backend/skill_slugs.rs
1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The folder name each skill gets under an agent's `.claude/skills/`. `build_config_files` writes a skill's
5//! `SKILL.md` there, and a computer-use skill's other files must land in the same folder, so both ask here.
6
7use std::collections::HashSet;
8
9use crate::backend::agent_config::{unique_skill_slug, SKILL_TYPE_AGENT_SKILL};
10use crate::backend::storage::AgentSkill;
11
12/// The folder name (`.claude/skills/<slug>`) each skill gets: `Some` for an Agent Skill with a body, `None` for the
13/// rest. Slugs are made unique in the order given, so whatever writes a skill's files beside its `SKILL.md` must use
14/// this and not work the slug out again.
15pub(crate) fn agent_skill_slugs(skills: &[AgentSkill]) -> Vec<Option<String>> {
16 let mut used: HashSet<String> = HashSet::new();
17 skills
18 .iter()
19 .map(|s| (!s.content.is_empty() && s.skill_type == SKILL_TYPE_AGENT_SKILL).then(|| unique_skill_slug(&s.name, &mut used)))
20 .collect()
21}