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