MCPcopy Create free account
hub / github.com/microsoft/AI-Engineering-Coach / extractRuleMaps

Function extractRuleMaps

src/core/rule-parser.ts:281–313  ·  view source on GitHub ↗
(fm: ParsedFrontmatter)

Source from the content-addressed store, hash-verified

279}
280
281function extractRuleMaps(fm: ParsedFrontmatter): {
282 thresholds: Record<string, number>;
283 patterns: Record<string, string[]>;
284 fileTypes: Record<string, string[]>;
285} {
286 const rawThresholds = fm.thresholds as Record<string, number | string | string[]> | undefined;
287 const thresholds: Record<string, number> = {};
288 if (rawThresholds) {
289 for (const [k, v] of Object.entries(rawThresholds)) {
290 if (typeof v === 'number') thresholds[k] = v;
291 }
292 }
293
294 const patterns: Record<string, string[]> = {};
295 const rawPatterns = fm.patterns as Record<string, string | string[]> | undefined;
296 if (rawPatterns) {
297 for (const [k, v] of Object.entries(rawPatterns)) {
298 if (Array.isArray(v)) patterns[k] = v;
299 else if (typeof v === 'string') patterns[k] = [v];
300 }
301 }
302
303 const fileTypes: Record<string, string[]> = {};
304 const rawFileTypes = fm.fileTypes as Record<string, string | string[]> | undefined;
305 if (rawFileTypes) {
306 for (const [k, v] of Object.entries(rawFileTypes)) {
307 if (Array.isArray(v)) fileTypes[k] = v;
308 else if (typeof v === 'string') fileTypes[k] = [v];
309 }
310 }
311
312 return { thresholds, patterns, fileTypes };
313}
314
315const VALID_GROUPS = new Set(Object.keys(PRACTICE_GROUPS));
316const VALID_SEVERITIES = new Set<RuleSeverity>(['high', 'medium', 'low']);

Callers 1

parseRuleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected