import { parse as parseToml } from "toml"; export function validateTomlConfig( configContent: string, configType: string ) { try { // Parse TOML const parsed = parseToml(configContent); // Validate based on type const issues: string[] = []; switch (configType) { case "home": if (!parsed.profile) issues.push("Missing 'profile' section"); if (!parsed.hero) issues.push("Missing 'hero' section"); break; case "projects": if (!Array.isArray(parsed.projects)) { issues.push("Missing or invalid 'projects' array"); } break; // ... more validations } if (issues.length === 0) { return { content: [{ type: "text" as const, text: `✅ Valid!\n\nParsed:\n\`\`\`json\n${JSON.stringify(parsed, null, 2)}\n\`\`\`` }] }; } else { return { content: [{ type: "text" as const, text: `⚠️ Issues:\n${issues.map(i => `- ${i}`).join('\n')}` }] }; } } catch (error) { return { content: [{ type: "text" as const, text: `❌ TOML Syntax Error:\n${error.message}` }], isError: true }; } }