Elffuss BraidHub

kikocis/continue public

198ebda6cfd2 · 772 BRawPermalink
1import { ToolImpl } from ".";
2import { parseMarkdownRule } from "../../config/markdown/parseMarkdownRule";
3
4export const requestRuleImpl: ToolImpl = async (args, extras) => {
5 // Find the rule by name in the config
6 const rule = extras.config.rules.find((r) => r.name === args.name);
7
8 if (!rule || !rule.ruleFile) {
9 throw new Error(
10 `Rule with name "${args.name}" not found or has no file path`,
11 );
12 }
13
14 const fileContent = await extras.ide.readFile(rule.ruleFile);
15 const { markdown, frontmatter } = parseMarkdownRule(fileContent);
16
17 return [
18 {
19 name: frontmatter.name ?? "",
20 description: frontmatter.description ?? "",
21 content: markdown,
22 uri: {
23 type: "file",
24 value: rule.ruleFile,
25 },
26 },
27 ];
28};