/** * Skill data model and loading utilities for AgentSkills.io skills. * * This module defines the Skill class and provides static methods for * discovering, parsing, and loading skills from the filesystem, raw content, * or HTTPS URLs. Skills are directories containing a SKILL.md file with YAML * frontmatter metadata and markdown instructions. */ /** * Configuration for creating a Skill instance. */ export interface SkillConfig { /** Unique identifier for the skill (1-64 chars, lowercase alphanumeric + hyphens). */ name: string; /** Human-readable description of what the skill does. */ description: string; /** Full markdown instructions from the SKILL.md body. */ instructions?: string | undefined; /** Filesystem path to the skill directory, if loaded from disk. */ path?: string | undefined; /** List of tool names the skill is allowed to use. (Experimental: not yet enforced) */ allowedTools?: string[] | undefined; /** Additional key-value metadata from the SKILL.md frontmatter. */ metadata?: Record | undefined; /** License identifier (e.g., "Apache-2.0"). */ license?: string | undefined; /** Compatibility information string. */ compatibility?: string | undefined; } /** * Represents an agent skill with metadata and instructions. * * A skill encapsulates a set of instructions and metadata that can be * dynamically loaded by an agent at runtime. Skills support progressive * disclosure: metadata is shown upfront in the system prompt, and full * instructions are loaded on demand via a tool. * * Skills can be created directly or via convenience static methods: * * @example * ```typescript * // From a skill directory on disk * const skill = Skill.fromFile('./skills/my-skill') * * // From raw SKILL.md content * const skill = Skill.fromContent('---\nname: my-skill\n...') * * // Load all skills from a parent directory * const skills = Skill.fromDirectory('./skills/') * * // From an HTTPS URL * const skill = await Skill.fromUrl('https://example.com/SKILL.md') * ``` */ export declare class Skill { /** Unique identifier for the skill (1-64 chars, lowercase alphanumeric + hyphens). */ readonly name: string; /** Human-readable description of what the skill does. */ readonly description: string; /** Full markdown instructions from the SKILL.md body. */ readonly instructions: string; /** Filesystem path to the skill directory, if loaded from disk. */ readonly path: string | undefined; /** List of tool names the skill is allowed to use. (Experimental: not yet enforced) */ readonly allowedTools: string[] | undefined; /** Additional key-value metadata from the SKILL.md frontmatter. */ readonly metadata: Record; /** License identifier (e.g., "Apache-2.0"). */ readonly license: string | undefined; /** Compatibility information string. */ readonly compatibility: string | undefined; constructor(config: SkillConfig); /** * Load a single skill from a directory containing SKILL.md. * * Resolves the filesystem path, reads the file content, and delegates * to {@link fromContent} for parsing. After loading, sets the skill's * `path` and validates the skill name against the parent directory. * * @param skillPath - Path to the skill directory or the SKILL.md file itself. * @param options - Optional settings. When `strict` is true, throws on any validation issue; otherwise warns and loads anyway. * @returns A Skill instance populated from the SKILL.md file. */ static fromFile(skillPath: string, options?: { strict?: boolean; }): Skill; /** * Parse SKILL.md content into a Skill instance. * * Creates a Skill from raw SKILL.md content (YAML frontmatter + markdown body) * without requiring a file on disk. * * @example * ```typescript * const content = `--- * name: my-skill * description: Does something useful * --- * # Instructions * Follow these steps...` * * const skill = Skill.fromContent(content) * ``` * * @param content - Raw SKILL.md content with YAML frontmatter and markdown body. * @param options - Optional settings. When `strict` is true, throws on any validation issue; otherwise warns and loads anyway. * @returns A Skill instance populated from the parsed content. */ static fromContent(content: string, options?: { strict?: boolean; path?: string | undefined; }): Skill; /** * Load a skill by fetching its SKILL.md content from an HTTPS URL. * * Fetches the raw SKILL.md content over HTTPS and parses it using * {@link fromContent}. The URL must point directly to the raw file * content (not an HTML page). * * @example * ```typescript * const skill = await Skill.fromUrl( * 'https://raw.githubusercontent.com/org/repo/main/SKILL.md' * ) * ``` * * @param url - An `https://` URL pointing directly to raw SKILL.md content. * @param options - Optional settings. When `strict` is true, throws on any validation issue; otherwise warns and loads anyway. * @returns A Promise resolving to a Skill instance populated from the fetched SKILL.md content. * @throws If `url` is not an `https://` URL. * @throws If the SKILL.md content cannot be fetched. */ static fromUrl(url: string, options?: { strict?: boolean; }): Promise; /** * Load all skills from a parent directory containing skill subdirectories. * * Each subdirectory containing a SKILL.md file is treated as a skill. * Subdirectories without SKILL.md are silently skipped. * * @param skillsDir - Path to the parent directory containing skill subdirectories. * @param options - Optional settings. When `strict` is true, throws on any validation issue; otherwise warns and loads anyway. * @returns List of Skill instances loaded from the directory. */ static fromDirectory(skillsDir: string, options?: { strict?: boolean; }): Skill[]; } //# sourceMappingURL=skill.d.ts.map