continue-custom/core/tools/implementations/requestRule.ts
Patrick Erichsen 1a9910f49e fix imports
2025-06-16 09:24:10 -07:00

28 lines
757 B
TypeScript

import { parseMarkdownRule } from "@continuedev/config-yaml";
import { ToolImpl } from ".";
export const requestRuleImpl: ToolImpl = async (args, extras) => {
// Find the rule by name in the config
const rule = extras.config.rules.find((r) => r.name === args.name);
if (!rule || !rule.ruleFile) {
throw new Error(
`Rule with name "${args.name}" not found or has no file path`,
);
}
const fileContent = await extras.ide.readFile(rule.ruleFile);
const { markdown, frontmatter } = parseMarkdownRule(fileContent);
return [
{
name: frontmatter.name ?? "",
description: frontmatter.description ?? "",
content: markdown,
uri: {
type: "file",
value: rule.ruleFile,
},
},
];
};