Merge pull request #7725 from continuedev/tomasz/add-missing-invokable
improv: add invokable parsing
This commit is contained in:
commit
4d2d85e333
2 changed files with 62 additions and 0 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue