Skip to content

feat: add gitignore-style negation patterns for workspace.files#7

Merged
christso merged 2 commits intomainfrom
feature/include-exclude-patterns
Jan 24, 2026
Merged

feat: add gitignore-style negation patterns for workspace.files#7
christso merged 2 commits intomainfrom
feature/include-exclude-patterns

Conversation

@christso
Copy link
Copy Markdown
Contributor

Summary

  • Add glob pattern matching with gitignore-style negation to workspace.files configuration
  • Patterns like **/*.md, !**/*.instructions.md, and re-inclusion work as expected
  • Object entries {source, dest} continue to work as explicit single-file mappings

Example Usage

workspace:
  source: ./config
  files:
    - "**/*.md"
    - "!**/*.instructions.md"
    - "important.instructions.md"  # re-include specific file

Changes

File Change
package.json Add fast-glob dependency
src/utils/glob-patterns.ts New file - pattern resolution utilities
src/core/transform.ts Update copyWorkspaceFiles() to handle globs
tests/unit/utils/glob-patterns.test.ts Unit tests (16 tests)
tests/unit/core/transform-glob.test.ts Integration tests (15 tests)

Test Plan

  • All 112 unit tests pass
  • Glob pattern matching works correctly
  • Negation exclusion works correctly
  • Re-inclusion after negation works correctly
  • Directory structure preserved when copying
  • Dry-run mode reports correct destinations
  • Backward compatible with literal paths and object entries

Add glob pattern matching with gitignore-style negation to workspace.files
configuration, allowing patterns like:
  - "**/*.md" to include all markdown files
  - "!**/*.instructions.md" to exclude instruction files
  - "important.instructions.md" to re-include specific files

Changes:
- Add fast-glob dependency for pattern matching
- Create src/utils/glob-patterns.ts with pattern resolution utilities
- Update copyWorkspaceFiles to process string patterns through glob resolver
- Object entries ({source, dest}) continue to work as explicit mappings
- Empty glob matches are silently ignored (consistent with gitignore)

Tests:
- Add unit tests for isGlobPattern, isNegationPattern, resolveGlobPatterns
- Add integration tests for copyWorkspaceFiles with glob patterns
- Remove non-null assertion in transform.ts (use fallback instead)
- Remove unused imports (mkdir in sync.ts, CONFIG_DIR in workspace.ts)
- Fix exactOptionalPropertyTypes issues by conditionally spreading
  optional properties only when they have values
@christso christso merged commit e563237 into main Jan 24, 2026
@christso christso deleted the feature/include-exclude-patterns branch January 24, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant