diff --git a/packages/config-yaml/src/markdown/markdownToRule.test.ts b/packages/config-yaml/src/markdown/markdownToRule.test.ts index 7103e3e2c..9c49ca136 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.test.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.test.ts @@ -261,6 +261,66 @@ This is a rule with alwaysApply explicitly set to false.`; const result = markdownToRule(content, mockId); expect(result.alwaysApply).toBe(false); }); + + it("should include invokable from frontmatter when true", () => { + const content = `--- +globs: "**/test/**/*.kt" +name: Test Rule +invokable: true +--- + +# Test Rule + +This is an invokable rule.`; + + const result = markdownToRule(content, mockId); + expect(result.invokable).toBe(true); + }); + + it("should include invokable from frontmatter when false", () => { + const content = `--- +globs: "**/test/**/*.kt" +name: Test Rule +invokable: false +--- + +# Test Rule + +This is a non-invokable rule.`; + + const result = markdownToRule(content, mockId); + expect(result.invokable).toBe(false); + }); + + it("should handle invokable with alwaysApply together", () => { + const content = `--- +alwaysApply: true +invokable: true +name: Test Rule +--- + +# Test Rule + +This is a rule with both alwaysApply and invokable.`; + + const result = markdownToRule(content, mockId); + expect(result.alwaysApply).toBe(true); + expect(result.invokable).toBe(true); + }); + + it("should not include invokable when not in frontmatter", () => { + const content = `--- +globs: "**/test/**/*.kt" +name: Test Rule +--- + +# Test Rule + +This is a rule without invokable property.`; + + const result = markdownToRule(content, mockId); + expect(result.invokable).toBeUndefined(); + }); }); describe("getRuleName", () => { diff --git a/packages/config-yaml/src/markdown/markdownToRule.ts b/packages/config-yaml/src/markdown/markdownToRule.ts index f0489ced4..c4c78dbc9 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.ts @@ -12,6 +12,7 @@ export interface RuleFrontmatter { name?: RuleObject["name"]; description?: RuleObject["description"]; alwaysApply?: RuleObject["alwaysApply"]; + invokable?: RuleObject["invokable"]; } /** @@ -115,6 +116,7 @@ export function markdownToRule( regex: frontmatter.regex, description: frontmatter.description, alwaysApply: frontmatter.alwaysApply, + invokable: frontmatter.invokable, sourceFile: id.uriType === "file" ? id.fileUri : undefined, }; }