@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.
67 lines • 2.46 kB
TypeScript
/**
* Pattern Matching Utilities
*
* Provides glob-like pattern matching for autonomy configuration,
* tool filtering, and other pattern-based matching needs.
*
* Supports:
* - * matches any sequence of characters
* - ? matches any single character
*
* @example
* ```typescript
* matchesPattern('deploy_prod', 'deploy_*'); // true
* matchesPattern('deploy_prod', 'deploy_???'); // false (only 3 chars after _)
* patternsConflict('deploy_*', 'deploy_prod'); // true
* ```
*/
/** Maximum allowed glob pattern length to prevent ReDoS (Issue #388) */
export declare const MAX_GLOB_PATTERN_LENGTH = 500;
/** Maximum allowed text length for pattern matching (Issue #388) */
export declare const MAX_PATTERN_MATCH_TEXT_LENGTH = 10000;
/**
* Convert a glob pattern to a RegExp (cached).
*
* Compiled regexes are cached in an LRU map (max 256 entries) to avoid
* recompilation on repeated pattern matching calls.
*
* @param pattern - Glob pattern with * and ? wildcards
* @returns RegExp that matches the pattern (never-matching if pattern exceeds length limit)
*/
export declare function globToRegex(pattern: string): RegExp;
/**
* Check if text matches a glob-like pattern
*
* @param text - The text to match against
* @param pattern - Glob pattern with * and ? wildcards
* @returns true if text matches the pattern
*/
export declare function matchesPattern(text: string, pattern: string): boolean;
/**
* Check if two patterns could potentially conflict
*
* Two patterns conflict if:
* 1. They are identical (exact match)
* 2. One pattern could match strings that the other pattern would also match
*
* This is used to detect configuration conflicts like:
* - requiresApproval: ['deploy_*'] with autoApprove: ['deploy_prod']
* → 'deploy_prod' matches 'deploy_*' → conflict
*
* @param patternA - First pattern
* @param patternB - Second pattern
* @returns Object with conflict status and details
*/
export declare function detectPatternConflict(patternA: string, patternB: string): {
conflicts: boolean;
reason?: string;
};
/**
* Find all conflicts between two sets of patterns
*
* @param patternsA - First set of patterns (e.g., requiresApproval)
* @param patternsB - Second set of patterns (e.g., autoApprove)
* @returns Array of conflict descriptions
*/
export declare function findPatternConflicts(patternsA: string[], patternsB: string[]): string[];
//# sourceMappingURL=patternMatcher.d.ts.map