-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: generate rule dialog #6421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a2adf2f
44094aa
0d8a1cc
2e691bf
fd94ef2
287839c
aaaa44f
15bbf19
e2a7d47
b13f1aa
f6ba92b
8ae963c
1b50ed5
0b20c4d
48b950b
9722eaa
2fb364d
6df32dd
2c4207b
8073dda
f582dc9
8332a71
b13bec5
e7e3540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
RomneyDa marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ export const createRuleBlock: Tool = { | |
function: { | ||
name: BuiltInToolNames.CreateRuleBlock, | ||
description: | ||
'Creates a "rule" that can be referenced in future conversations. This should be used whenever you want to establish code standards / preferences that should be applied consistently, or when you want to avoid making a mistake again. To modify existing rules, use the edit tool instead.', | ||
'Creates a "rule" that can be referenced in future conversations. This should be used whenever you want to establish code standards / preferences that should be applied consistently, or when you want to avoid making a mistake again. To modify existing rules, use the edit tool instead.\n\nRule Types:\n- Always: Include only "rule" (always included in model context)\n- Auto Attached: Include "rule", "globs", and/or "regex" (included when files match patterns)\n- Agent Requested: Include "rule" and "description" (AI decides when to apply based on description)\n- Manual: Include only "rule" (only included when explicitly mentioned using @ruleName)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change alwaysApply to a more readable "rule_type" arg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Patrick-Erichsen saving this change for later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm saw your comment |
||
parameters: { | ||
type: "object", | ||
required: ["name", "rule", "description"], | ||
|
@@ -30,7 +30,8 @@ export const createRuleBlock: Tool = { | |
}, | ||
description: { | ||
type: "string", | ||
description: "Short description of the rule", | ||
description: | ||
"Description of when this rule should be applied. Required for Agent Requested rules (AI decides when to apply). Optional for other types.", | ||
}, | ||
globs: { | ||
type: "string", | ||
|
@@ -42,6 +43,11 @@ export const createRuleBlock: Tool = { | |
description: | ||
"Optional regex patterns to match against file content. Rule applies only to files whose content matches the pattern (e.g. 'useEffect' for React hooks or '\\bclass\\b' for class definitions)", | ||
}, | ||
alwaysApply: { | ||
type: "boolean", | ||
description: | ||
"Whether this rule should always be applied. Set to false for Agent Requested and Manual rules. Omit or set to true for Always and Auto Attached rules.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,37 +5,26 @@ import { createRuleFilePath } from "../../config/markdown/utils"; | |
|
||
export type CreateRuleBlockArgs = Pick< | ||
Required<RuleWithSource>, | ||
"rule" | "description" | "alwaysApply" | "name" | ||
"rule" | "name" | ||
> & | ||
Pick<RuleWithSource, "globs" | "regex">; | ||
Pick<RuleWithSource, "globs" | "regex" | "description" | "alwaysApply">; | ||
|
||
export const createRuleBlockImpl: ToolImpl = async ( | ||
args: CreateRuleBlockArgs, | ||
{ name, rule, ...otherArgs }: CreateRuleBlockArgs, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the advantage over saying |
||
extras, | ||
) => { | ||
// Create options object with the fields that createRuleMarkdown expects | ||
const options: any = { | ||
description: args.description, | ||
globs: args.globs, | ||
}; | ||
|
||
// Add regex if provided | ||
if (args.regex) { | ||
options.regex = args.regex; | ||
} | ||
|
||
const fileContent = createRuleMarkdown(args.name, args.rule, options); | ||
const fileContent = createRuleMarkdown(name, rule, otherArgs); | ||
|
||
const [localContinueDir] = await extras.ide.getWorkspaceDirs(); | ||
const ruleFilePath = createRuleFilePath(localContinueDir, args.name); | ||
const ruleFilePath = createRuleFilePath(localContinueDir, name); | ||
|
||
await extras.ide.writeFile(ruleFilePath, fileContent); | ||
await extras.ide.openFile(ruleFilePath); | ||
|
||
return [ | ||
{ | ||
name: "New Rule Block", | ||
description: args.description || "", | ||
description: otherArgs.description || "", | ||
uri: { | ||
type: "file", | ||
value: ruleFilePath, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahaha it had a good run