Skip to main content
Glama
yamlParser.ts1.44 kB
/** * YAML rule parser * * Parses rules from YAML files */ import { Rule } from '../../model/rule.js'; /** * Simple YAML parser for rule files * For now, we'll use a basic JSON-like structure * In production, use a proper YAML library like 'yaml' or 'js-yaml' */ export function parseYamlRules(content: string, projectId: string): Rule[] { // For MVP, we'll require users to use JSON format in .yaml files // or we can add the 'yaml' package as a dependency try { // Try parsing as JSON first (works for simple YAML) const parsed = JSON.parse(content); const rules = Array.isArray(parsed) ? parsed : [parsed]; // Ensure each rule has required fields return rules.map((rule: any) => ({ id: rule.id || 'unknown', project: projectId, area: rule.area || 'general', title: rule.title || '', description: rule.description || '', severity: rule.severity || 'info', tags: rule.tags || [], rationale: rule.rationale, pattern: rule.pattern, appliesTo: rule.appliesTo, examples: rule.examples, })); } catch (error) { throw new Error(`Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`); } } // TODO: Add proper YAML parsing with 'yaml' package // import YAML from 'yaml'; // export function parseYamlRules(content: string, projectId: string): Rule[] { // const parsed = YAML.parse(content); // ... // }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/n8daniels/RulesetMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server