/** * Skill Storage Module - File I/O Operations for World-Level Agent Skills * * Purpose: * File-based storage for world-scoped skills following the Anthropic Agent Skills Protocol. * Each skill is a directory under `{world-dir}/skills/{skill-name}/` containing a `SKILL.md` * file with YAML frontmatter metadata and markdown body instructions. * * Features: * - SKILL.md parsing with YAML frontmatter extraction and validation * - Skill CRUD operations (import, read, list, delete, export) * - `.meta.json` write-time cache for fast metadata listing * - Cache fallback to SKILL.md parsing when cache is missing or corrupt * - Path traversal protection using resolve + startsWith guards * - Duplicate skill rejection via `skillExists()` check before import * - Content size and line-count validation with warnings * * Notes: * - Follows `agent-storage.ts` pattern: standalone module with explicit `rootPath` * - Uses `fs/promises` for all I/O, pure functions, no classes * - Skills are NOT tool calls — they follow the Anthropic Agent Skills Protocol * as a content/instruction protocol (app reads SKILL.md, injects into user message) * - Skill metadata limits: name max 64 chars (kebab-case), description max 256 chars * * Recent Changes: * - 2026-02-09: Initial implementation for world-level skills system */ import type { SkillMetadata, SkillData, WorldSkill, SkillValidationResult } from '../types.js'; /** * Get the skills root directory for a world. */ export declare function getSkillsDir(rootPath: string, worldId: string): string; /** * Get the directory path for a specific skill. */ export declare function getSkillDir(rootPath: string, worldId: string, skillName: string): string; /** * Get the SKILL.md file path for a specific skill. */ export declare function getSkillFilePath(rootPath: string, worldId: string, skillName: string): string; /** * Ensure the skills root directory exists. */ export declare function ensureSkillsDirectory(rootPath: string, worldId: string): Promise; /** * Ensure a specific skill directory exists. */ export declare function ensureSkillDirectory(rootPath: string, worldId: string, skillName: string): Promise; /** * Parse SKILL.md content into metadata (YAML frontmatter) and body content. * Supports standard YAML frontmatter delimited by `---` lines. * * @param raw - Raw file content of SKILL.md * @returns Parsed SkillData with metadata and content * @throws Error if frontmatter is missing or malformed */ export declare function parseSkillFile(raw: string): SkillData; /** * Extract just the metadata from a SKILL.md file (without body content). */ export declare function extractSkillMetadata(raw: string): SkillMetadata; /** * Validate skill metadata against protocol constraints. */ export declare function validateSkillMetadata(metadata: SkillMetadata): SkillValidationResult; /** * Validate skill content (SKILL.md body) for size and line count. */ export declare function validateSkillContent(content: string): SkillValidationResult; /** * Check if a skill exists in a world. */ export declare function skillExists(rootPath: string, worldId: string, skillName: string): Promise; /** * Save a SKILL.md file for a skill. */ export declare function saveSkillFile(rootPath: string, worldId: string, skillName: string, content: string): Promise; /** * Load a SKILL.md file content for a skill. */ export declare function loadSkillFile(rootPath: string, worldId: string, skillName: string): Promise; /** * Delete a skill directory and all its contents. */ export declare function deleteSkillFolder(rootPath: string, worldId: string, skillName: string): Promise; /** * List all skill folder names in a world's skills directory. */ export declare function listSkillFolders(rootPath: string, worldId: string): Promise; /** * Get a full WorldSkill object for a specific skill. */ export declare function getWorldSkill(rootPath: string, worldId: string, skillName: string): Promise; /** * Get just the metadata for a specific skill. */ export declare function getWorldSkillMetadata(rootPath: string, worldId: string, skillName: string): Promise; /** * List all WorldSkill objects in a world. */ export declare function listWorldSkills(rootPath: string, worldId: string): Promise; /** * List skill metadata for all skills in a world. * Uses `.meta.json` cache for fast listing; falls back to SKILL.md parsing. */ export declare function listWorldSkillsMetadata(rootPath: string, worldId: string): Promise; /** * Import a skill into a world from raw SKILL.md content. * Validates metadata, rejects duplicates, and regenerates cache. * * @throws {DuplicateSkillError} if skill with same name already exists * @throws {Error} if content is invalid */ export declare function importWorldSkill(rootPath: string, worldId: string, skillContent: string): Promise; /** * Export a skill's SKILL.md content as a raw string. */ export declare function exportWorldSkill(rootPath: string, worldId: string, skillName: string): Promise; /** * Delete a skill from a world and regenerate the metadata cache. */ export declare function deleteWorldSkill(rootPath: string, worldId: string, skillName: string): Promise; /** * Get total size (in bytes) of all SKILL.md files in a world. */ export declare function getWorldSkillsSize(rootPath: string, worldId: string): Promise; /** * Regenerate the `.meta.json` metadata cache from all SKILL.md files. */ export declare function regenerateMetaCache(rootPath: string, worldId: string): Promise; /** * Load the `.meta.json` metadata cache. * Returns null if cache is missing or corrupt. */ export declare function loadMetaCache(rootPath: string, worldId: string): Promise; //# sourceMappingURL=skill-storage.d.ts.map