Skip to content

feat(system): support wildcards in system files#10374

Merged
jdx merged 1 commit into
mainfrom
codex/system-files-wildcards
Jun 13, 2026
Merged

feat(system): support wildcards in system files#10374
jdx merged 1 commit into
mainfrom
codex/system-files-wildcards

Conversation

@jdx

@jdx jdx commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • expand wildcard source paths in [system.files] into concrete file requests
  • map matching * and ** captures into target paths
  • document wildcard usage and cover it in system-files e2e tests

Validation

  • cargo fmt --check
  • cargo test system::files
  • mise run test:e2e e2e/cli/test_system_files

This PR was generated by an AI coding assistant.


Note

Medium Risk
New glob-to-target mapping drives where mise system install writes under the home directory; logic bugs could place or skip files incorrectly, though mismatches are mostly warned and skipped.

Overview
Adds glob wildcard expansion for [system.files]: source paths may use *, **, ?, and […], and when multiple files match, the target key must use aligned wildcards so each match maps to a concrete install path (copy, symlink, etc. unchanged per expanded entry).

files_from_config now runs entries through expand_request instead of one FileRequest per TOML row. Invalid or empty globs warn and skip that entry (including “multiple sources, non-wildcard target”); a single match with a literal target still works. Implementation builds regex captures from the source pattern (including **/ matching zero directories and Windows path separators) and substitutes into the target pattern.

Docs and e2e cover *, ?, classes, **, empty-pattern behavior; unit tests cover expansion edge cases. The system-files e2e also sets chmod 644 on the SSH template output before permission-drift checks so the test is reliable.

Reviewed by Cursor Bugbot for commit 04db101. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Support for glob/wildcard patterns in system file entries: matched sources are expanded into concrete installs with mapped targets.
  • Documentation

    • Docs updated with examples and explicit rules for wildcard source→target expansion and pattern semantics.
  • Tests

    • End-to-end tests covering wildcard expansion, recursive patterns, empty-match behavior, and permission setup for drift detection.
  • Bug Fixes

    • Empty wildcard sources are skipped with warnings without blocking installs.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2fa352e0-70d8-4259-8b4a-747009245555

📥 Commits

Reviewing files that changed from the base of the PR and between 4210ca2 and 04db101.

📒 Files selected for processing (3)
  • docs/system-files.md
  • e2e/cli/test_system_files
  • src/system/files.rs
✅ Files skipped from review due to trivial changes (1)
  • docs/system-files.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • e2e/cli/test_system_files
  • src/system/files.rs

📝 Walkthrough

Walkthrough

The PR adds glob pattern expansion to [system.files]. Sources with *, **, ?, or [...] are expanded into concrete FileRequest entries; captured segments are substituted into target patterns. Helpers, core expansion, unit tests, docs, and e2e tests were added.

Changes

Glob Wildcard Expansion Feature

Layer / File(s) Summary
Glob/wildcard expansion helpers
src/system/files.rs
New imports (itertools, regex) and utilities: wildcard_regex, wildcard_captures, is_glob_pattern, read_glob_class, and expand_target_pattern. Unit tests validate *, ** (including zero-directory capture), ?, bracket classes, and Windows-separator handling.
Request expansion and file processor integration
src/system/files.rs
New expand_request enumerates glob::glob matches, warns on invalid/no matches, enforces single-match semantics when target has no globs, and emits per-match FileRequests by mapping captures into target patterns. files_from_config now inserts all expanded requests keyed by concrete targets.
Documentation and end-to-end validation
docs/system-files.md, e2e/cli/test_system_files
Docs add a ~/.config/*.toml example and explicit rules requiring matching wildcards in targets for multi-match sources. E2E tests create fixtures, append glob entries, run install, assert expanded concrete targets and skipped-empty-glob behavior, and set ~/.ssh/config permissions in a drift test.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • jdx/mise#10365: Both PRs touch the core [system.files] implementation in src/system/files.rs and relate to glob/wildcard expansion.

Poem

🐰 I hopped through globs where dotfiles hide,
Stars and brackets made captures glide,
Each match stitched into targets neat,
Files align — a rabbit's tidy feat! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(system): support wildcards in system files' directly and concisely describes the main feature addition: enabling wildcard pattern support in the system files configuration, which is the primary focus of all changes across documentation, tests, and implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jdx jdx marked this pull request as ready for review June 13, 2026 02:25
Comment thread src/system/files.rs Outdated
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds glob wildcard support to [system.files] entries, expanding matched source paths into individual FileRequest objects with target paths derived from positional wildcard captures. Both issues flagged in prior review rounds — ** silently dropping zero-directory matches and ?/[…] patterns failing to capture — are correctly resolved in this diff.

  • expand_request / wildcard_regex / expand_target_pattern: source patterns are expanded via glob::glob, captures are extracted with a hand-built regex that handles *, **, ?, and […], then mapped onto the target pattern positionally; the **/ zero-directory case is handled with the optional non-capturing group (?:(.*)/)?.
  • read_glob_class: shared helper consumed by both the regex builder and the target expander to keep character-class parsing consistent; [!…] negation is correctly translated to regex [^…].
  • e2e + docs: new test cases cover all four wildcard types (including zero-dir **/) and the no-match warn-skip path; documentation is accurate.

Confidence Score: 5/5

Safe to merge — wildcard expansion is additive (non-glob entries follow the original code path), conflicts and apply logic are unchanged, and both previously identified defects are corrected.

The new wildcard path is well-isolated: non-glob entries return immediately through the original FileRequest construction. The two concretely broken cases from prior review are directly fixed by the (?:(.*)/)? regex and the added ? and [ branches in wildcard_regex. Unit tests exercise all four wildcard types, the zero-dir case, and the Windows-separator round-trip; the e2e script confirms end-to-end behaviour including the warn-skip no-match path.

No files require special attention.

Important Files Changed

Filename Overview
src/system/files.rs Core wildcard expansion logic added: expand_request, wildcard_regex, wildcard_captures, expand_target_pattern, read_glob_class, and helpers. Properly handles *, **, ?, […], the zero-directory **/ case, and Windows separators. Both issues previously flagged in review threads have been correctly addressed.
e2e/cli/test_system_files Adds e2e coverage for *, ?, [ab], and **/ (including zero-dir) wildcard expansion, plus a no-match warn-skip path. Also adds a pre-test chmod 644 to set a known permission state before asserting drift detection.
docs/system-files.md Documents the new wildcard syntax with a concise rule block and TOML examples covering all four wildcard types; accurate and matches the implementation.

Reviews (3): Last reviewed commit: "feat(system): support wildcards in syste..." | Re-trigger Greptile

Comment thread src/system/files.rs
Comment thread src/system/files.rs
@jdx jdx force-pushed the codex/system-files-wildcards branch from 9bd2a38 to 7bd93b2 Compare June 13, 2026 02:29

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7bd93b2. Configure here.

Comment thread src/system/files.rs
@jdx jdx force-pushed the codex/system-files-wildcards branch from 7bd93b2 to 4210ca2 Compare June 13, 2026 02:31

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/system/files.rs`:
- Around line 261-265: The '**' regex capture used by wildcard_regex can be
empty which leaves the literal '/' from the pattern in the expansion and yields
paths with a double separator (e.g. "...//tool.toml"); add a unit test next to
test_recursive_wildcard_target_expansion that asserts expanding a pattern like
".../**/*.toml" can yield a direct child path ".../tool.toml". Fix
expand_target_pattern so when translating captures into the expanded PathBuf it
avoids inserting an extra '/' for empty '**' captures—either by skipping
insertion of the following separator when the capture is empty or by normalizing
the assembled PathBuf (removing empty components or using PathBuf::push
semantics) to prevent a double '/' in the resulting path. Ensure you reference
the wildcard_regex and expand_target_pattern functions when making changes and
update tests to cover the zero-depth expansion case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cdc830e4-b5ca-4f85-b827-a322283cc754

📥 Commits

Reviewing files that changed from the base of the PR and between 3e3ff2f and 9bd2a38.

📒 Files selected for processing (3)
  • docs/system-files.md
  • e2e/cli/test_system_files
  • src/system/files.rs

Comment thread src/system/files.rs

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/system/files.rs`:
- Around line 179-180: The glob expansion currently drops per-match GlobError
silently when building matches from glob::glob(&source_pattern); modify the
Ok(paths) arm so it iterates the Result<PathBuf, GlobError> values, logging a
warning for each Err (including the GlobError and the offending source_pattern
or path) and only collecting the successful PathBufs into matches (i.e., skip
errored entries rather than filter_map(|p| p.ok()) silently); reference the
glob::glob call, the source_pattern variable, and the matches binding to locate
where to add per-item logging and collection.
- Around line 258-325: Summary: Windows paths with backslashes break glob
parsing/expansion because wildcard_regex and expand_target_pattern only treat
'/' as the separator. Fix: normalize separators to a single canonical char
before processing and convert back when producing PathBuf. Concretely, in
wildcard_regex(pattern: &str) call a normalized let pattern =
pattern.replace('\\','/'); then build the regex from that normalized pattern (or
alternately treat separators in regex pieces as [\\/]); in
expand_target_pattern(pattern: &str, captures: &[String]) normalize the input
pattern the same way and also normalize each capture (replace('\\','/')) before
stitching into out; after composing out, convert it back to native separators if
needed (e.g. replace '/' with std::path::MAIN_SEPARATOR) or create PathBuf from
the normalized string so Windows tests for *.toml and **/*.toml pass. Also
ensure read_glob_class and any logic checking for '/' are applied to the
normalized string so the **/ zero-directories case behaves correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57bf1788-0aca-4387-87b3-4d0396b1090c

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd2a38 and 4210ca2.

📒 Files selected for processing (3)
  • docs/system-files.md
  • e2e/cli/test_system_files
  • src/system/files.rs
✅ Files skipped from review due to trivial changes (1)
  • docs/system-files.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/cli/test_system_files

Comment thread src/system/files.rs Outdated
Comment thread src/system/files.rs
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.5 x -- echo 17.7 ± 0.8 16.3 22.2 1.00
mise x -- echo 18.4 ± 1.1 16.6 30.6 1.04 ± 0.08

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.5 env 17.7 ± 0.7 16.1 20.8 1.00
mise env 18.2 ± 0.8 16.7 22.3 1.03 ± 0.06

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.5 hook-env 18.6 ± 0.8 16.7 22.6 1.00
mise hook-env 18.7 ± 0.8 17.3 22.5 1.01 ± 0.06

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.5 ls 14.7 ± 0.7 13.5 19.6 1.00
mise ls 15.4 ± 0.8 14.0 19.5 1.05 ± 0.07

xtasks/test/perf

Command mise-2026.6.5 mise Variance
install (cached) 128ms 131ms -2%
ls (cached) 56ms 58ms -3%
bin-paths (cached) 63ms 64ms -1%
task-ls (cached) 121ms 123ms -1%

@jdx jdx force-pushed the codex/system-files-wildcards branch from 4210ca2 to 04db101 Compare June 13, 2026 02:43
@jdx jdx merged commit 797611e into main Jun 13, 2026
35 checks passed
@jdx jdx deleted the codex/system-files-wildcards branch June 13, 2026 02:58
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