"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/skills/index.ts
var index_exports = {};
__export(index_exports, {
  SkillRegistry: () => SkillRegistry
});
module.exports = __toCommonJS(index_exports);

// 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, "\\$&");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SkillRegistry
});
