1119
}
1120
1121
>
export async function parseRuleFile(uri: URI, fileService: IFileService): Promise<{ name: string; description?: string; globs?: string[]; alwaysApply?: boolean }> {
pluginParsers.ts
1122
>
const nameFromFile = basename(uri).replace(/(\.instructions)?\.md$/i, '');
1123
>
try {
1124
>
const content = await fileService.readFile(uri);
1125
>
const frontmatter = parseFrontMatter(content.value.toString());
1126
>
const name = frontmatter?.getStringValue('name')?.trim() || nameFromFile;
1127
>
const description = frontmatter?.getStringValue('description')?.trim();
1128
>
const globs = frontmatter?.getStringArrayValue('globs') ?? frontmatter?.getStringArrayValue('applyTo') ?? frontmatter?.getStringArrayValue('paths') ?? undefined;
1129
>
const alwaysApply = frontmatter?.getBooleanValue('alwaysApply');
1130
>
return { name, description, globs, alwaysApply };
1131
>
} catch {
1132
return { name: nameFromFile };
1133
}
1135
1136
async function readHooks(