fix(frontmatter): expand nested brace globs in paths: correctly#1701
fix(frontmatter): expand nested brace globs in paths: correctly#1701adityachaudhary99 wants to merge 2 commits into
Conversation
expandBraces used the regex `^([^{]*)\{([^}]+)\}(.*)$`, whose `[^}]+` stops
at the first `}`, so nested brace groups were corrupted: `{a,{b,c}}` became
`["a}","b","c}"]` and `src/**/*.{js,{ts,tsx}}` produced stray `}` and broken
globs — silently breaking path-scoped skill / CLAUDE.md activation. Replace
the regex with a depth-aware scan that finds the matching close brace and
splits on top-level commas only, recursing as before. Unbalanced braces fall
back to the literal input. Adds frontmatterParser.test.ts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🧰 Additional context used📓 Path-based instructions (10)src/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
{src/services/**/*.ts,src/utils/**/*.ts}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,py,json,md}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.test.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.test.{ts,tsx,js}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{ts,tsx,js,jsx,py}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*⚙️ CodeRabbit configuration file
Files:
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}⚙️ CodeRabbit configuration file
Files:
**⚙️ CodeRabbit configuration file
Files:
🔇 Additional comments (2)
📝 WalkthroughWalkthrough
ChangesBalance-aware brace expansion rewrite
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
jatmn
left a comment
There was a problem hiding this comment.
I found an issue that needs to be addressed before this is ready.
Findings
- [P2] Preserve literal empty brace groups in path frontmatter
src/utils/frontmatterParser.ts:305
Empty brace groups were previously not considered expandable because the old regex required at least one character inside the braces, so patterns containing a literal{}segment stayed literal. With the new scanner,paths: "{}"becomes[""], and bothparseSkillPathsand the CLAUDE.md path parser filter that empty string and treat the file as having no path restriction, so a conditional skill or rule applies globally. The same collapse also retargets literal paths such assrc/{}file.tstosrc/file.ts, and broadenssrc/{}tosrc/, activating on the wrong files. Please keep empty brace groups literal, or otherwise avoid converting an empty brace expansion into a different or unrestricted path rule.
The balance-aware scanner expanded `{}` to a single empty alternative, so
`paths: "{}"` collapsed to [""]; parseSkillPaths and the CLAUDE.md path
parser drop that empty string and treat the file as having no path
restriction (activating everywhere). The previous regex required >=1 inner
char, so `{}` stayed literal. Restore that: treat an empty brace group as
literal while still expanding any later groups in the suffix. Adds tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jatmn
left a comment
There was a problem hiding this comment.
Thanks for the update. I rechecked the previously discussed paths and do not see any remaining actionable issues from my side.
@kevincodex1 LGTM
What & why
expandBracesused the regex^([^{]*)\{([^}]+)\}(.*)$, whose[^}]+stops at the first}, so nested brace groups in apaths:frontmatter glob were corrupted:{a,{b,c}}became["a}","b","c}"]andsrc/**/*.{js,{ts,tsx}}produced stray}and broken globs — silently breaking path-scoped skill / CLAUDE.md activation.Changes
Replaced the regex extraction with a depth-aware scan that finds the matching close brace and splits on top-level commas only, recursing as before. Unbalanced braces fall back to the literal input.
Checks
Added
src/utils/frontmatterParser.test.tscovering no-braces, single group, nested groups, nested globs, sibling groups, and the unbalanced-brace fallback.(Small self-contained bug fix with no existing issue.)
Summary by CodeRabbit
Bug Fixes
{}preservation for accurate glob generation.Tests