"use strict";
// ============================================================
// teach-parser.ts — Free text → structured JSON parser
//
// Parses developer's free text input into structured data.
// Simple rule-based parsing — no ML needed.
// ============================================================
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTeachInput = parseTeachInput;
exports.profileToContextString = profileToContextString;
function parseTeachInput(rawText, section) {
    const lines = rawText.split('\n').filter(l => l.trim());
    const result = {};
    for (const line of lines) {
        // Remove numbering: "1. Minimal changes" → "Minimal changes"
        const cleaned = line.replace(/^\d+[\.\)]\s*/, '').replace(/^[-•]\s*/, '').trim();
        if (!cleaned)
            continue;
        // Convert to snake_case key
        const key = cleaned
            .toLowerCase()
            .replace(/[^a-z0-9]+/g, '_')
            .replace(/^_|_$/g, '');
        // Store both key and original text
        result[key] = cleaned;
    }
    return result;
}
function profileToContextString(profile) {
    if (Object.keys(profile).length === 0)
        return '';
    const lines = ['Developer Profile:'];
    for (const [section, data] of Object.entries(profile)) {
        const items = Object.values(data.structuredData);
        if (items.length > 0) {
            const sectionName = section.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
            lines.push(`  ${sectionName}: ${items.join(', ')}`);
        }
    }
    return lines.join('\n');
}
//# sourceMappingURL=teach-parser.js.map