Skip to content

fix: include missing tool-specific fields in RulesyncRule.fromFile - #1368

Merged
dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
yhorikawa:fix/rulesync-rule-fromfile-missing-tool-fields
Mar 25, 2026
Merged

fix: include missing tool-specific fields in RulesyncRule.fromFile#1368
dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
yhorikawa:fix/rulesync-rule-fromfile-missing-tool-fields

Conversation

@yhorikawa

Copy link
Copy Markdown
Contributor

Summary

  • Fix RulesyncRule.fromFile to include claudecode, copilot, and antigravity tool-specific fields when constructing the frontmatter object
  • cursor and agentsmd were already included, but the other tool-specific fields were missing
  • Add tests to verify copilot and claudecode frontmatter loading

Background

When tool-specific configuration (e.g., copilot.excludeAgent, claudecode.paths) was defined in a rule file's frontmatter, these fields were not copied during the fromFile object construction, so they were silently dropped and never reflected in the generated output.

Related: #1259

Test plan

  • Add test for copilot frontmatter configuration loading
  • Add test for claudecode frontmatter configuration loading
  • Run pnpm cicheck to verify quality

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 24, 2026 14:14

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

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, and antigravity in the validated frontmatter object constructed by RulesyncRule.fromFile.
  • Add unit tests to verify copilot and claudecode frontmatter 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.

Comment on lines 159 to 163
const validatedFrontmatter: RulesyncRuleFrontmatter = {
root: result.data.root ?? false,
localRoot: result.data.localRoot ?? false,
targets: result.data.targets ?? ["*"],
description: result.data.description,

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +168 to +169
copilot: result.data.copilot,
antigravity: result.data.antigravity,

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fix: ba15674

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines 159 to 170
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,
};

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@dyoshikawa
dyoshikawa merged commit c93c07c into dyoshikawa:main Mar 25, 2026
10 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner

@yhorikawa Thank you!

@github-actions github-actions Bot mentioned this pull request Mar 25, 2026
2 tasks
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.

3 participants