import type { Rule } from "../core/types.js"; import type { ConfigParser } from "./base.js"; import { nextRuleId, classifyRule, extractRuleBlocks } from "./base.js"; /** * Windsurf config parser. * Reads: .windsurfrules (plain markdown, one rule per line or bullets) */ export const windsurfParser: ConfigParser = { agent: "windsurf", filePatterns: [".windsurfrules"], parse(content: string, filePath: string): Rule[] { // Plain text: each line is a rule (like .cursorrules) const lines = content .split("\n") .map((l) => l.trim()) .filter((l) => l.length > 5 && !l.startsWith("#")); if (lines.length > 0 && !content.includes("\n- ") && !content.match(/^\d+\./m)) { // Plain line-per-rule format return lines.map((line) => ({ id: nextRuleId(), category: classifyRule(line), content: line, scope: "project" as const, source: { agent: "windsurf" as const, file: filePath }, status: "active" as const, })); } // Markdown-like format const blocks = extractRuleBlocks(content); return blocks.map((block) => ({ id: nextRuleId(), category: classifyRule(block), content: block, scope: "project" as const, source: { agent: "windsurf" as const, file: filePath }, status: "active" as const, })); }, };