Elffuss BraidHub

kikocis/continue public

improv: add invokable parsing
Changeset4471e8ac2ed326ca1bdd587e9cc593cade70c51a256bf12db8d18aff7748149d
AuthorTomasz Stefaniak <tomasz.p.stefaniak@gmail.com> · 2025-09-12 12:54 -07:00
CommitterTomasz Stefaniak <tomasz.p.stefaniak@gmail.com> · 2025-09-12 12:54 -07:00
Parents235058a67062

Browse the files at this changeset

2 files changed

modified packages/config-yaml/src/markdown/markdownToRule.test.ts +60 −0
@@ -261,6 +261,66 @@
261261 const result = markdownToRule(content, mockId);
262262 expect(result.alwaysApply).toBe(false);
263263 });
264+
265+ it("should include invokable from frontmatter when true", () => {
266+ const content = `---
267+globs: "**/test/**/*.kt"
268+name: Test Rule
269+invokable: true
270+---
271+
272+# Test Rule
273+
274+This is an invokable rule.`;
275+
276+ const result = markdownToRule(content, mockId);
277+ expect(result.invokable).toBe(true);
278+ });
279+
280+ it("should include invokable from frontmatter when false", () => {
281+ const content = `---
282+globs: "**/test/**/*.kt"
283+name: Test Rule
284+invokable: false
285+---
286+
287+# Test Rule
288+
289+This is a non-invokable rule.`;
290+
291+ const result = markdownToRule(content, mockId);
292+ expect(result.invokable).toBe(false);
293+ });
294+
295+ it("should handle invokable with alwaysApply together", () => {
296+ const content = `---
297+alwaysApply: true
298+invokable: true
299+name: Test Rule
300+---
301+
302+# Test Rule
303+
304+This is a rule with both alwaysApply and invokable.`;
305+
306+ const result = markdownToRule(content, mockId);
307+ expect(result.alwaysApply).toBe(true);
308+ expect(result.invokable).toBe(true);
309+ });
310+
311+ it("should not include invokable when not in frontmatter", () => {
312+ const content = `---
313+globs: "**/test/**/*.kt"
314+name: Test Rule
315+---
316+
317+# Test Rule
318+
319+This is a rule without invokable property.`;
320+
321+ const result = markdownToRule(content, mockId);
322+ expect(result.invokable).toBeUndefined();
323+ });
264324 });
265325
266326 describe("getRuleName", () => {
modified packages/config-yaml/src/markdown/markdownToRule.ts +2 −0
@@ -12,6 +12,7 @@
1212 name?: RuleObject["name"];
1313 description?: RuleObject["description"];
1414 alwaysApply?: RuleObject["alwaysApply"];
15+ invokable?: RuleObject["invokable"];
1516 }
1617
1718 /**
@@ -115,6 +116,7 @@
115116 regex: frontmatter.regex,
116117 description: frontmatter.description,
117118 alwaysApply: frontmatter.alwaysApply,
119+ invokable: frontmatter.invokable,
118120 sourceFile: id.uriType === "file" ? id.fileUri : undefined,
119121 };
120122 }