Skip to content

Wildcard#7

Merged
madkoo merged 4 commits into
mainfrom
wildcard
Mar 19, 2026
Merged

Wildcard#7
madkoo merged 4 commits into
mainfrom
wildcard

Conversation

@madkoo

@madkoo madkoo commented Mar 19, 2026

Copy link
Copy Markdown
Owner

This pull request adds support for glob patterns in the source field of manifest entries, allowing users to specify and synchronize multiple files or directories using wildcards. It also introduces new helper functions for glob detection and base path extraction, updates the workflow to run tests, and adds comprehensive tests for the new functionality.

Glob pattern support and sync improvements:

  • Added support for glob patterns (e.g., skills/canvas/**) in the source field of ManifestEntry, updating both the syncEntry and determineState logic to handle multiple file matches and preserve directory structure. (F82ead3fL17, Fb42b1acL58R58, src/types.tsL9-R9)
  • Introduced utility functions isGlobPattern and globBase in src/sync.ts to detect glob patterns and extract their non-glob base directory. (F82ead3fL17, tests/sync.test.tsR1-R152)
  • Updated the determineState function in src/commands/status.ts to check for missing, outdated, or current status across all files matched by a glob pattern. (Fb42b1acL58R58)

Testing and workflow:

  • Added comprehensive tests in tests/sync.test.ts and tests/status.test.ts to cover glob pattern matching, directory structure preservation, and edge cases for both syncing and status determination. [1] [2]
  • Updated package.json to add vitest as the test runner, include a test script, and added fast-glob as a dependency for glob matching. The CI workflow now runs tests as part of the build. [1] [2]

These changes significantly improve the flexibility and reliability of file synchronization by supporting advanced file selection patterns and ensuring correctness through automated testing.

Copilot AI review requested due to automatic review settings March 19, 2026 08:33
@madkoo madkoo merged commit c0d92cc into main Mar 19, 2026
6 checks passed
@madkoo madkoo deleted the wildcard branch March 19, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds glob-pattern support to manifest entry source paths so a single entry can sync and status-check multiple matched files while preserving relative structure under a computed “glob base”.

Changes:

  • Added glob expansion support to syncEntry and determineState (via fast-glob) plus helper utilities (isGlobPattern, globBase).
  • Added Vitest-based test suites covering glob behavior for sync and status.
  • Updated CI to run tests and added dependencies/scripts to support test execution.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/sync.test.ts New tests for glob detection/base extraction and sync behavior across multiple matched files.
tests/status.test.ts New tests for status determination across glob-matched files (missing/outdated/current).
src/types.ts Updated ManifestEntry.source documentation to include glob patterns.
src/sync.ts Implemented glob matching + copy logic; introduced isGlobPattern and globBase.
src/commands/status.ts Implemented glob-aware status checks; exported determineState for testing.
package.json Added fast-glob, vitest, and a test script.
package-lock.json Locked new dependencies; reflects updated dependency tree.
.github/workflows/ci.yml Added npm test step to CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sync.ts
Comment on lines +62 to +65
for (const absMatch of matches) {
const relPath = path.relative(absBase, absMatch);
const destFile = path.join(destPath, relPath);
const sourceDigest = fileHash(absMatch);
Comment thread src/sync.ts
Comment on lines +20 to +23
/** Returns true if the source path contains any glob metacharacter. */
export function isGlobPattern(source: string): boolean {
return /[*?[\]{}]/.test(source);
}
Comment thread src/commands/status.ts
Comment on lines +66 to +73
const matches = fg.sync(entry.source, { cwd: cacheDir, absolute: true, onlyFiles: true });
if (matches.length === 0) return 'missing';
for (const absMatch of matches) {
const relPath = path.relative(absBase, absMatch);
const destFile = path.join(destinationPath, relPath);
if (!fs.existsSync(destFile)) return 'missing';
const sourceDigest = fileHash(absMatch);
const destDigest = fileHash(destFile);
Comment thread src/commands/status.ts

// Glob pattern: expand and check each matched file
if (isGlobPattern(entry.source)) {
if (!fs.existsSync(cacheDir)) return 'missing';
Comment thread package.json
"vitest": "^4.0.0"
},
"engines": {
"node": ">=16.7.0"
Comment thread src/sync.ts
Comment on lines 49 to +51

// Glob pattern: expand matches and copy each file preserving relative structure
if (isGlobPattern(entry.source)) {
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.

2 participants