@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.
120 lines • 4.96 kB
TypeScript
/**
* SkillManager - Refactored to extend BaseElementManager for shared CRUD logic.
* Maintains skill-specific behaviors such as trigger validation, import/export,
* and creation workflows while eliminating duplicated file handling code.
*/
import { BaseElementManager } from '../base/BaseElementManager.js';
import { Skill, SkillMetadata } from './Skill.js';
import { FileLockManager } from '../../security/fileLockManager.js';
import { PortfolioManager } from '../../portfolio/PortfolioManager.js';
import { ValidationRegistry } from '../../services/validation/ValidationRegistry.js';
import { SerializationService } from '../../services/SerializationService.js';
import { MetadataService } from '../../services/MetadataService.js';
import { FileOperationsService } from '../../services/FileOperationsService.js';
import { FileWatchService } from '../../services/FileWatchService.js';
export declare class SkillManager extends BaseElementManager<Skill> {
private metadataService;
private triggerValidationService;
private validationService;
private serializationService;
private activeSkillNames;
constructor(portfolioManager: PortfolioManager, fileLockManager: FileLockManager, fileOperationsService: FileOperationsService, validationRegistry: ValidationRegistry, serializationService: SerializationService, metadataService: MetadataService, fileWatchService?: FileWatchService, memoryBudget?: import('../../cache/CacheMemoryBudget.js').CacheMemoryBudget, backupService?: import('../../services/BackupService.js').BackupService);
protected getElementLabel(): string;
/**
* Create a new skill element and persist it to disk.
* FIX: Issue #20 - Add duplicate name checking
*/
create(data: Partial<SkillMetadata> & {
content?: string;
instructions?: string;
}): Promise<Skill>;
/**
* Import a skill from YAML or JSON input formats.
*/
importElement(data: string, format?: 'yaml' | 'json'): Promise<Skill>;
/**
* Export a skill to YAML or JSON.
*/
exportElement(element: Skill, format?: 'yaml' | 'json'): Promise<string>;
getFileExtension(): string;
/**
* Validate and normalize metadata parsed from frontmatter.
*/
protected parseMetadata(data: any): Promise<SkillMetadata>;
/**
* Create skill instance from metadata/content.
* Dual-field: detects v2 format (instructions in YAML frontmatter) vs v1 (body = instructions).
*/
protected createElement(metadata: SkillMetadata, bodyContent: string): Skill;
/**
* Serialize a skill to markdown with frontmatter.
* v2.0 format: instructions in YAML frontmatter, content as body.
*/
protected serializeElement(element: Skill): Promise<string>;
private buildDefaultBody;
/**
* Override list() to apply active status to skills
*/
list(): Promise<Skill[]>;
/**
* Activate a skill by name or identifier
*
* Issue #24 (LOW PRIORITY): Performance optimization using findByName()
* Issue #24 (LOW PRIORITY): Consistent error messages using ElementMessages
* Issue #24 (LOW PRIORITY): Cleanup trigger for memory leak prevention
*/
activateSkill(identifier: string): Promise<{
success: boolean;
message: string;
skill?: Skill;
}>;
/**
* Deactivate a skill by name or identifier
*
* Issue #24 (LOW PRIORITY): Performance optimization using findByName()
* Issue #24 (LOW PRIORITY): Consistent error messages using ElementMessages
*/
deactivateSkill(identifier: string): Promise<{
success: boolean;
message: string;
}>;
/**
* Get all active skills
*/
getActiveSkills(): Promise<Skill[]>;
/**
* Check if active set cleanup is needed and perform cleanup if necessary
*
* Issue #24 (LOW PRIORITY): Memory leak prevention
*
* CLEANUP STRATEGY:
* - Triggers when set reaches 90% of maximum capacity
* - Validates that all active skills still exist in portfolio
* - Removes stale references (skills that were deleted)
* - Logs cleanup operations for monitoring
*
* PERFORMANCE NOTES:
* - Only runs when threshold is reached (not on every activation)
* - Uses efficient Set operations
* - Minimal impact on activation performance
*
* @private
*/
private checkAndCleanupActiveSet;
/**
* Clean up stale entries from active skills set
*
* Issue #24 (LOW PRIORITY): Memory leak prevention
*
* Validates that all active skills still exist and removes orphaned references.
* This prevents memory leaks from deleted skills that weren't properly deactivated.
*
* @private
*/
private cleanupStaleActiveSkills;
/**
* Normalize and validate skill triggers.
*/
private validateAndProcessTriggers;
}
//# sourceMappingURL=SkillManager.d.ts.map