(args, extras)
| 15 | Pick<RuleWithSource, "globs" | "regex" | "description" | "alwaysApply">; |
| 16 | |
| 17 | export const createRuleBlockImpl: ToolImpl = async (args, extras) => { |
| 18 | const name = getStringArg(args, "name"); |
| 19 | const rule = getStringArg(args, "rule"); |
| 20 | |
| 21 | const description = getOptionalStringArg(args, "description"); |
| 22 | const regex = getOptionalStringArg(args, "regex"); |
| 23 | const globs = getOptionalStringArg(args, "globs"); |
| 24 | const alwaysApply = getBooleanArg(args, "alwaysApply", false); |
| 25 | |
| 26 | const fileContent = createRuleMarkdown(name, rule, { |
| 27 | alwaysApply, |
| 28 | description, |
| 29 | globs, |
| 30 | regex, |
| 31 | }); |
| 32 | |
| 33 | const [localContinueDir] = await extras.ide.getWorkspaceDirs(); |
| 34 | const ruleFilePath = createRuleFilePath(localContinueDir, name); |
| 35 | |
| 36 | await extras.ide.writeFile(ruleFilePath, fileContent); |
| 37 | await extras.ide.openFile(ruleFilePath); |
| 38 | |
| 39 | return [ |
| 40 | { |
| 41 | name: "New Rule Block", |
| 42 | description: description || "", |
| 43 | uri: { |
| 44 | type: "file", |
| 45 | value: ruleFilePath, |
| 46 | }, |
| 47 | content: `Rule created successfully`, |
| 48 | }, |
| 49 | ]; |
| 50 | }; |
no test coverage detected