// src/skills/registry.ts
var SkillRegistry = class {
  skills = /* @__PURE__ */ new Map();
  constructor(initial = []) {
    for (const s of initial) this.skills.set(s.id, s);
  }
  register(skill) {
    this.skills.set(skill.id, skill);
  }
  unregister(id) {
    this.skills.delete(id);
  }
  get(id) {
    return this.skills.get(id);
  }
  list() {
    return Array.from(this.skills.values()).filter((s) => !s.hidden);
  }
  listAll() {
    return Array.from(this.skills.values());
  }
  /** Match palette input like `/introduce` or `/translate en` to a skill id. */
  match(input) {
    const id = input.startsWith("/") ? input.slice(1).split(/\s+/)[0] : input.split(/\s+/)[0];
    return id ? this.skills.get(id) : void 0;
  }
  /** Extract args after the skill name. e.g. `/translate en` → 'en' */
  parseArgs(input) {
    const parts = (input.startsWith("/") ? input.slice(1) : input).split(/\s+/);
    return parts.slice(1).join(" ");
  }
  /** Resolve `{{var}}` placeholders in a PromptSkill template. */
  resolvePrompt(skill, vars = {}) {
    const merged = { ...skill.variables, ...vars };
    let out = skill.prompt;
    for (const [k, v] of Object.entries(merged)) {
      out = out.replace(new RegExp(`\\{\\{\\s*${escapeRegex(k)}\\s*\\}\\}`, "g"), v);
    }
    return out;
  }
};
function escapeRegex(s) {
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
export {
  SkillRegistry
};
