Module pattern

Module pattern 

Source
Expand description

Pattern-based dependency resolution for CCPM.

This module provides glob pattern matching functionality to support pattern-based dependencies in CCPM manifests. Pattern dependencies allow installation of multiple resources matching a glob pattern, enabling bulk operations on related resources.

§Pattern Syntax

CCPM uses standard glob patterns with the following support:

  • * matches any sequence of characters within a single path component
  • ** matches any sequence of path components (recursive matching)
  • ? matches any single character
  • [abc] matches any character in the set
  • [a-z] matches any character in the range
  • {foo,bar} matches either “foo” or “bar” (brace expansion)

§Examples

§Common Pattern Usage

# Install all agents in the agents/ directory
[agents]
ai-helpers = { source = "community", path = "agents/*.md", version = "v1.0.0" }

# Install all review-related agents recursively
review-tools = { source = "community", path = "**/review*.md", version = "v1.0.0" }

# Install specific agent categories
python-agents = { source = "community", path = "agents/python-*.md", version = "v1.0.0" }

§Security Considerations

Pattern matching includes several security measures:

  • Path Traversal Prevention: Patterns containing .. are rejected
  • Absolute Path Restriction: Patterns starting with / or containing drive letters are rejected
  • Symlink Safety: Pattern matching does not follow symlinks to prevent directory traversal
  • Input Validation: All patterns are validated before processing

§Performance

Pattern matching is optimized for typical repository structures:

  • Recursive Traversal: Uses walkdir for efficient directory traversal
  • Pattern Caching: Compiled glob patterns are reused across matches
  • Early Termination: Stops on first match when appropriate
  • Memory Efficient: Streaming approach for large directory trees

Structs§

PatternMatcher
Pattern matcher for resource discovery in repositories.
PatternResolver
Resolves pattern-based dependencies to concrete file paths.

Functions§

extract_resource_name
Extracts a resource name from a file path.
validate_pattern_safety
Validates that a pattern is safe and doesn’t contain path traversal attempts.