Skip to content

[Bug]: Glob pattern data loss in CopilotRule roundtrip conversion #5

Description

@flanny7

Hello, I always appreciate rulesync.

Problem

I found a data loss bug in CopilotRule.toRulesyncRule(). When converting a root rule with applyTo: "**", the value is normalized to "**/*" during conversion to a RulesyncRule, but this original value is never restored on the way back, causing the roundtrip to be non-idempotent.

Evidence

In src/features/rules/copilot-rule.ts around line 117–118:

if (this.isRoot()) {
  globs = ["**/*"];  // Always hardcoded — original "**" is lost
}

And in fromRulesyncRule() around line 160:

applyTo: rulesyncFrontmatter.globs?.length
  ? rulesyncFrontmatter.globs.join(",")
  : undefined,

The roundtrip results in:

Step Value
Input (applyTo) "**"
After toRulesyncRule (globs) ["**/*"]
After fromRulesyncRule (applyTo) "**/*"

The original "**" is permanently replaced with "**/*" after a single conversion cycle.

Reproduction Steps

  1. Create a CopilotRule with applyTo: "**" in frontmatter
  2. Call .toRulesyncRule() → observe globs: ["**/*"]
  3. Call CopilotRule.fromRulesyncRule() on the result → observe applyTo: "**/*" (not "**")

Expected Behavior

A roundtrip conversion should preserve the original glob value, or at minimum, the two values ("**" and "**/*") should be treated as equivalent throughout the pipeline.

Actual Behavior

"**" is silently replaced with "**/*", causing inconsistency when re-importing or re-syncing rules.

Your consideration would be appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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