MCPcopy Index your code
hub / github.com/continuedev/continue / createRuleBlockImpl

Function createRuleBlockImpl

core/tools/implementations/createRuleBlock.ts:17–50  ·  view source on GitHub ↗
(args, extras)

Source from the content-addressed store, hash-verified

15 Pick<RuleWithSource, "globs" | "regex" | "description" | "alwaysApply">;
16
17export 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};

Callers 2

callBuiltInToolFunction · 0.90

Calls 8

getStringArgFunction · 0.90
getOptionalStringArgFunction · 0.90
getBooleanArgFunction · 0.90
createRuleMarkdownFunction · 0.90
createRuleFilePathFunction · 0.90
getWorkspaceDirsMethod · 0.65
writeFileMethod · 0.65
openFileMethod · 0.65

Tested by

no test coverage detected