Skip to content

[Bug]: Root CopilotRule receives frontmatter object despite "no frontmatter" comment #7

@flanny7

Description

@flanny7

Hello, I always appreciate rulesync.

Problem

In CopilotRule.fromRulesyncRule(), there is a comment stating "no frontmatter for root file", yet a frontmatter object is still passed to the constructor when creating a root rule. The comment and the implementation are inconsistent.

Evidence

In src/features/rules/copilot-rule.ts around line 167–177:

if (root) {
  // Root file: .github/copilot-instructions.md (no frontmatter for root file)
  return new CopilotRule({
    baseDir: baseDir,
    frontmatter: copilotFrontmatter,  // ← passed despite the comment above
    body,
    relativeDirPath: paths.root.relativeDirPath,
    relativeFilePath: paths.root.relativeFilePath,
    validate,
    root,
  });
}

The frontmatter field is passed to the constructor, but when generating the file content (in getFileContent()), root files skip frontmatter serialization:

fileContent: rest.root ? body : stringifyFrontmatter(body, frontmatter),

So the frontmatter is silently discarded at serialization time. While this avoids visible breakage today, the code's intention is unclear and could become a bug source in future refactors.

Expected Behavior

Either:

  1. Root rules should pass frontmatter: undefined (or {}) explicitly to match the stated intent, or
  2. The comment should be updated to explain why frontmatter is provided but intentionally unused.

Your confirmation would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions