fix: include missing tool-specific fields in RulesyncRule.fromFile - #1368
Conversation
Add claudecode, copilot, and antigravity fields to the frontmatter object returned by fromFile, matching existing cursor field handling. Without this fix, tool-specific configurations in frontmatter were silently dropped during rule file parsing. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes RulesyncRule.fromFile so tool-specific frontmatter (claudecode, copilot, antigravity) is preserved when loading Rulesync rule files, preventing configuration from being silently dropped during generation.
Changes:
- Include
claudecode,copilot, andantigravityin the validated frontmatter object constructed byRulesyncRule.fromFile. - Add unit tests to verify
copilotandclaudecodefrontmatter loading from disk.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/features/rules/rulesync-rule.ts |
Ensures additional tool-specific frontmatter keys are carried through fromFile parsing/validation. |
src/features/rules/rulesync-rule.test.ts |
Adds regression tests for copilot and claudecode frontmatter loading behavior. |
| const validatedFrontmatter: RulesyncRuleFrontmatter = { | ||
| root: result.data.root ?? false, | ||
| localRoot: result.data.localRoot ?? false, | ||
| targets: result.data.targets ?? ["*"], | ||
| description: result.data.description, |
There was a problem hiding this comment.
validatedFrontmatter is still built by manually enumerating fields from result.data, which is easy to regress (this PR is fixing an omission). Consider constructing it by spreading result.data and then overriding only the fields that need defaults (e.g., root/localRoot/targets/globs) so newly-added frontmatter keys aren’t accidentally dropped again.
There was a problem hiding this comment.
This is a good suggestion, but the scope of this change would be significantly larger. I'd like to keep this PR focused on the bug fix.
| copilot: result.data.copilot, | ||
| antigravity: result.data.antigravity, |
There was a problem hiding this comment.
This change fixes antigravity frontmatter being dropped, but there’s no unit test here covering antigravity loading via RulesyncRule.fromFile. Adding a focused test (similar to the new copilot/claudecode cases) would prevent regressions and directly covers issue #1259.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| const validatedFrontmatter: RulesyncRuleFrontmatter = { | ||
| root: result.data.root ?? false, | ||
| localRoot: result.data.localRoot ?? false, | ||
| targets: result.data.targets ?? ["*"], | ||
| description: result.data.description, | ||
| globs: result.data.globs ?? [], | ||
| agentsmd: result.data.agentsmd, | ||
| claudecode: result.data.claudecode, | ||
| cursor: result.data.cursor, | ||
| copilot: result.data.copilot, | ||
| antigravity: result.data.antigravity, | ||
| }; |
There was a problem hiding this comment.
validatedFrontmatter is built with an object literal that explicitly assigns optional fields (agentsmd/cursor/claudecode/copilot/antigravity). When those keys are absent in the file, this forces them to exist as properties with undefined values in getFrontmatter(), which breaks existing strict toEqual assertions in this test suite and can also change the observable shape of the API. Consider constructing validatedFrontmatter by starting from result.data (so absent keys stay absent) and then overriding only the fields that need defaults (root/localRoot/targets/globs).
|
@yhorikawa Thank you! |
Summary
RulesyncRule.fromFileto includeclaudecode,copilot, andantigravitytool-specific fields when constructing the frontmatter objectcursorandagentsmdwere already included, but the other tool-specific fields were missingcopilotandclaudecodefrontmatter loadingBackground
When tool-specific configuration (e.g.,
copilot.excludeAgent,claudecode.paths) was defined in a rule file's frontmatter, these fields were not copied during thefromFileobject construction, so they were silently dropped and never reflected in the generated output.Related: #1259
Test plan
copilotfrontmatter configuration loadingclaudecodefrontmatter configuration loadingpnpm cicheckto verify quality🤖 Generated with Claude Code