From bc6e5867d76023e1d9b5af1e50710ea9d7eb3b0b Mon Sep 17 00:00:00 2001 From: dyoshikawa <34151621+dyoshikawa@users.noreply.github.com> Date: Fri, 24 Apr 2026 21:12:09 +0900 Subject: [PATCH] fix: drop root frontmatter when building CopilotRule --- src/features/rules/copilot-rule.test.ts | 13 +++++-------- src/features/rules/copilot-rule.ts | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/features/rules/copilot-rule.test.ts b/src/features/rules/copilot-rule.test.ts index bf874da96..52b5d646f 100644 --- a/src/features/rules/copilot-rule.test.ts +++ b/src/features/rules/copilot-rule.test.ts @@ -304,15 +304,15 @@ describe("CopilotRule", () => { rulesyncRule: original, }); - // Root Copilot file must have no applyTo when the rulesync rule had no globs. - expect(copilotRule.getFrontmatter().applyTo).toBeUndefined(); + // Root Copilot file must have no frontmatter. + expect(copilotRule.getFrontmatter()).toEqual({}); const reimported = copilotRule.toRulesyncRule(); const rf = reimported.getFrontmatter(); expect(rf.root).toBe(true); expect(rf.globs).toBeUndefined(); - expect(rf.description).toBe("Project overview"); + expect(rf.description).toBeUndefined(); expect(reimported.getBody()).toBe("Overview content"); }); @@ -407,10 +407,7 @@ describe("CopilotRule", () => { validate: true, }); - expect(copilotRule.getFrontmatter()).toEqual({ - description: "Root rule from rulesync", - applyTo: "**/*", - }); + expect(copilotRule.getFrontmatter()).toEqual({}); expect(copilotRule.getBody()).toBe("Root rulesync rule content"); expect(copilotRule.getRelativeDirPath()).toBe(".github"); expect(copilotRule.getRelativeFilePath()).toBe("copilot-instructions.md"); @@ -494,7 +491,7 @@ describe("CopilotRule", () => { validate: true, }); - expect(copilotRule.getFrontmatter().excludeAgent).toBe("coding-agent"); + expect(copilotRule.getFrontmatter()).toEqual({}); }); it("should use default baseDir when not provided", () => { diff --git a/src/features/rules/copilot-rule.ts b/src/features/rules/copilot-rule.ts index ee3fe625a..3b457c4bc 100644 --- a/src/features/rules/copilot-rule.ts +++ b/src/features/rules/copilot-rule.ts @@ -171,7 +171,7 @@ export class CopilotRule extends ToolRule { // Root file: .github/copilot-instructions.md (no frontmatter for root file) return new CopilotRule({ baseDir: baseDir, - frontmatter: copilotFrontmatter, + frontmatter: {}, body, relativeDirPath: paths.root.relativeDirPath, relativeFilePath: paths.root.relativeFilePath,