UNPKG

@dollhousemcp/mcp-server

Version:

DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.

108 lines 3.8 kB
/** * DollhouseToAnthropicConverter - Converts single-file DollhouseMCP skills to multi-file Anthropic Skills * * Based on the exact algorithm documented in: * business/documents/legal/evidence/anthropic-skills-decomposition-analysis.md (lines 108-163) * * Implements the mechanical transformation: * DollhouseMCP Skill (single .md file) → Anthropic Skill (directory with separated components) * * SECURITY MODEL: * - This is a FORMAT TRANSFORMER, not a security boundary * - Preserves content fidelity - no modification, sanitization, or validation * - YAML parsing uses CORE_SCHEMA to prevent deserialization attacks only * - Security validation happens at SkillManager.load() time, not conversion time * - Input skills should already be validated (they're from DollhouseMCP system) */ export interface AnthropicSkillStructure { 'SKILL.md': string; 'scripts/'?: Record<string, string>; 'reference/'?: Record<string, string>; 'themes/'?: Record<string, string>; 'examples/'?: Record<string, string>; 'metadata/'?: Record<string, string>; 'LICENSE.txt'?: string; } export declare class DollhouseToAnthropicConverter { private readonly schemaMapper; private readonly contentExtractor; constructor(); /** * Convert a DollhouseMCP skill (.md file) to Anthropic Skill format (directory structure) * * EXACT ALGORITHM from evidence/anthropic-skills-decomposition-analysis.md: * 1. Extract YAML frontmatter * 2. Simplify YAML (keep only name + description) * 3. Extract main instructions * 4. Extract embedded code blocks → scripts/ * 5. Extract reference sections → reference/ * 6. Extract templates → themes/ or examples/ * 7. Create SKILL.md with references * 8. Return directory structure */ convertSkill(skillContent: string, options?: { includelicense?: boolean; preserveComments?: boolean; }): Promise<AnthropicSkillStructure>; /** * Write the Anthropic skill structure to disk * REFACTORED: Simplified by extracting directory writing logic */ writeToDirectory(structure: AnthropicSkillStructure, outputDir: string): Promise<void>; /** * Ensure directory exists, creating it if necessary * REFACTORED: Extracted to reduce cognitive complexity */ private ensureDirectoryExists; /** * Write scripts directory with security considerations * REFACTORED: Extracted to reduce cognitive complexity */ private writeScriptsDirectory; /** * Write generic files directory (reference, themes, examples, metadata) * REFACTORED: Extracted to reduce cognitive complexity and reuse code */ private writeFilesDirectory; /** * Extract YAML frontmatter from markdown */ private extractYAMLFrontmatter; /** * Create SKILL.md content with simplified metadata and references */ private createSkillMD; /** * Extract main instructions (content before code blocks and special sections) */ private extractMainInstructions; /** * Extract documentation sections (Input Formats, Error Handling, etc.) */ private extractDocumentationSections; /** * Format script file with proper shebang and headers */ private formatScriptFile; /** * Get appropriate shebang for script language */ private getShebang; /** * Get script header comment */ private getScriptHeader; /** * Get file extension for language */ private getExtension; /** * Create slugified filename from title */ private slugify; /** * Create LICENSE.txt file */ private createLicenseFile; } //# sourceMappingURL=DollhouseToAnthropicConverter.d.ts.map