fix: missing patterns
This commit is contained in:
parent
3422fff607
commit
ff80ffeb3f
5 changed files with 18 additions and 4 deletions
|
|
@ -1,6 +1,3 @@
|
|||
import { Tool } from "../..";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const createRuleBlock: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Create Rule Block",
|
||||
|
|
@ -37,6 +34,11 @@ export const createRuleBlock: Tool = {
|
|||
description:
|
||||
"Optional file patterns to which this rule applies (e.g. ['**/*.{ts,tsx}'] or ['src/**/*.ts', 'tests/**/*.ts'])",
|
||||
},
|
||||
patterns: {
|
||||
type: "string",
|
||||
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)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export type CreateRuleBlockArgs = Pick<
|
|||
Required<RuleWithSource>,
|
||||
"rule" | "description" | "alwaysApply" | "name"
|
||||
> &
|
||||
Pick<RuleWithSource, "globs">;
|
||||
Pick<RuleWithSource, "globs" | "patterns">;
|
||||
|
||||
export const createRuleBlockImpl: ToolImpl = async (
|
||||
args: CreateRuleBlockArgs,
|
||||
|
|
@ -16,6 +16,7 @@ export const createRuleBlockImpl: ToolImpl = async (
|
|||
const fileContent = createRuleMarkdown(args.name, args.rule, {
|
||||
description: args.description,
|
||||
globs: args.globs,
|
||||
patterns: args.patterns,
|
||||
});
|
||||
|
||||
const [localContinueDir] = await extras.ide.getWorkspaceDirs();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ export function createRuleMarkdown(
|
|||
options: {
|
||||
description?: string;
|
||||
globs?: string | string[];
|
||||
patterns?: string | string[];
|
||||
alwaysApply?: boolean;
|
||||
} = {},
|
||||
): string {
|
||||
|
|
@ -44,6 +45,13 @@ export function createRuleMarkdown(
|
|||
typeof options.globs === "string" ? options.globs.trim() : options.globs;
|
||||
}
|
||||
|
||||
if (options.patterns) {
|
||||
frontmatter.patterns =
|
||||
typeof options.patterns === "string"
|
||||
? options.patterns.trim()
|
||||
: options.patterns;
|
||||
}
|
||||
|
||||
if (options.description) {
|
||||
frontmatter.description = options.description.trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { RuleObject } from "../schemas/index.js";
|
|||
|
||||
export interface RuleFrontmatter {
|
||||
globs?: RuleObject["globs"];
|
||||
patterns?: RuleObject["patterns"];
|
||||
name?: RuleObject["name"];
|
||||
description?: RuleObject["description"];
|
||||
alwaysApply?: RuleObject["alwaysApply"];
|
||||
|
|
@ -56,6 +57,7 @@ export function markdownToRule(
|
|||
name: frontmatter.name ?? packageIdentifierToDisplayName(id),
|
||||
rule: markdown,
|
||||
globs: frontmatter.globs,
|
||||
patterns: frontmatter.patterns,
|
||||
description: frontmatter.description,
|
||||
alwaysApply: frontmatter.alwaysApply,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ const ruleObjectSchema = z.object({
|
|||
rule: z.string(),
|
||||
description: z.string().optional(),
|
||||
globs: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
patterns: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
alwaysApply: z.boolean().optional(),
|
||||
});
|
||||
const ruleSchema = z.union([z.string(), ruleObjectSchema]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue