"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectRepeatMistakes = detectRepeatMistakes;
exports.detectBlindSpots = detectBlindSpots;
exports.detectProblemSolvingStyle = detectProblemSolvingStyle;
exports.detectTimePatterns = detectTimePatterns;
exports.detectBugHistory = detectBugHistory;
exports.detectDecisions = detectDecisions;
exports.detectTechMastery = detectTechMastery;
exports.buildIntelligenceReport = buildIntelligenceReport;
exports.saveIntelligenceReport = saveIntelligenceReport;
const child_process_1 = require("child_process");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const os = __importStar(require("os"));
function safeExec(cmd) {
    try {
        return (0, child_process_1.execSync)(cmd, { encoding: 'utf-8', cwd: os.homedir(), maxBuffer: 50 * 1024 * 1024, timeout: 30000, stdio: ['pipe', 'pipe', 'ignore'] }).trim();
    }
    catch {
        return '';
    }
}
function gitLog(projectDir, format = '%H|%ai|%s|%b', limit = 500) {
    if (!fs.existsSync(path.join(projectDir, '.git')))
        return '';
    return safeExec(`git log -${limit} --format="${format}"`);
}
function performGitIn(dir, cmd) {
    try {
        return (0, child_process_1.execSync)(cmd, { encoding: 'utf-8', cwd: dir, maxBuffer: 50 * 1024 * 1024, timeout: 30000, stdio: ['pipe', 'pipe', 'ignore'] }).trim();
    }
    catch {
        return '';
    }
}
function commitLog(projectDir, limit = 500) {
    if (!fs.existsSync(path.join(projectDir, '.git')))
        return '';
    return safeExec(`git -C "${projectDir}" log -${limit} --format="%H|%ai|%s"`);
}
function gitLogFile(projectDir, file, limit = 50) {
    if (!fs.existsSync(path.join(projectDir, '.git')))
        return '';
    return safeExec(`git -C "${projectDir}" log -${limit} --format="%ai|%s" -- "${file}"`);
}
function detectRepeatMistakes(rootDir) {
    const mistakes = new Map();
    const errorKeywords = [
        { regex: /\bfix\b.*\bnull\b|\bnull\b.*\bfix\b/i, category: 'null' },
        { regex: /\bfix\b.*\btype\b|\btype\b.*\bfix\b|\bany\b.*\bfix\b/i, category: 'type' },
        { regex: /\bfix\b.*\basync\b|\bawait\b.*\bfix\b|\brace\b.*\bcondition\b/i, category: 'async' },
        { regex: /\bfix\b.*\bimport\b|\bexport\b.*\bfix\b|\bfix\b.*\bmodule\b/i, category: 'import' },
        { regex: /\bfix\b.*\bsql\b|\binjection\b.*\bfix\b|\bfix\b.*\bxss\b/i, category: 'security' },
        { regex: /\bfix\b.*\blogic\b|\bfix\b.*\bincorrect\b|\bfix\b.*\bwrong\b/i, category: 'logic' },
        { regex: /\bfix\b.*\bbroken\b|\bfix\b.*\bbug\b|\bhotfix\b/i, category: 'unknown' },
    ];
    const subdirs = findProjectDirs(rootDir);
    for (const dir of subdirs) {
        const log = commitLog(dir, 300);
        if (!log)
            continue;
        const commits = log.split('\n').filter(Boolean);
        for (const line of commits) {
            const [hash, date, ...rest] = line.split('|');
            const msg = rest.join('|').trim();
            if (!msg.match(/\b(fix|bug|revert|hotfix|broken|error|wrong)\b/i))
                continue;
            for (const { regex, category } of errorKeywords) {
                if (regex.test(msg)) {
                    const key = msg.slice(0, 80).toLowerCase().replace(/[^a-z0-9\s]/g, '').trim();
                    const existing = mistakes.get(key);
                    if (existing) {
                        existing.count++;
                        existing.dates.push(date);
                    }
                    else {
                        mistakes.set(key, { count: 1, files: new Set(), dates: [date], category });
                    }
                    break;
                }
            }
        }
    }
    const twoWeeksAgo = new Date(Date.now() - 14 * 24 * 60 * 60 * 1000);
    const result = [];
    for (const [pattern, data] of mistakes) {
        if (data.count < 2)
            continue;
        const last = data.dates.sort()[data.dates.length - 1];
        result.push({
            pattern: pattern.length > 60 ? pattern.slice(0, 57) + '...' : pattern,
            count: data.count,
            files: Array.from(data.files).slice(0, 5),
            dates: data.dates,
            category: data.category,
            stillHappening: new Date(last) > twoWeeksAgo,
            lastOccurrence: last,
        });
    }
    result.sort((a, b) => b.count - a.count);
    return result;
}
function detectBlindSpots(rootDir) {
    const spots = [];
    const files = discoverAllFiles(rootDir);
    if (files.length === 0)
        return spots;
    let missingTryCatch = 0;
    const missingTryCatchFiles = [];
    let missingNullChecks = 0;
    const missingNullChecksFiles = [];
    let untestedFiles = 0;
    const untestedFileList = [];
    let consoleLogFiles = 0;
    const consoleLogFileList = [];
    let missingTypes = 0;
    const missingTypeFiles = [];
    let largeFunctions = 0;
    const largeFunctionFiles = [];
    for (const f of files) {
        try {
            const content = fs.readFileSync(f, 'utf-8');
            const ext = path.extname(f).toLowerCase();
            if (['.ts', '.tsx', '.js', '.jsx', '.py'].indexOf(ext) === -1)
                continue;
            const isTest = /\.(test|spec)\./.test(f) || /[\\/](test|tests|__tests__|spec)[\\/]/.test(f);
            if (!isTest) {
                if (!/\btry\b/.test(content) && !/\.catch\(/.test(content) && content.length > 500) {
                    missingTryCatch++;
                    missingTryCatchFiles.push(path.relative(rootDir, f));
                }
                if (/\bconsole\.(log|error|warn|debug)\(/i.test(content)) {
                    consoleLogFiles++;
                    consoleLogFileList.push(path.relative(rootDir, f));
                }
                if (ext === '.ts' || ext === '.tsx') {
                    if (!content.match(/(\bstring\b|\bnumber\b|\bboolean\b|\binterface\b|\btype \w+\s*=)/i) && content.length > 200) {
                        missingTypes++;
                        missingTypeFiles.push(path.relative(rootDir, f));
                    }
                }
                if (/\bfunction\b.*\{[\s\S]{500,}/i.test(content)) {
                    largeFunctions++;
                    largeFunctionFiles.push(path.relative(rootDir, f));
                }
                if (!/\?\.|\!==\s*null|!==\s*undefined|===\s*null|===\s*undefined|\|\|\s*['"`]|null\s*\|\|/.test(content) &&
                    /\.(find|findOne|findFirst|findMany|get|query|fetch|json)\s*\(/.test(content) &&
                    content.length > 200) {
                    missingNullChecks++;
                    missingNullChecksFiles.push(path.relative(rootDir, f));
                }
            }
            if ((ext === '.ts' || ext === '.tsx' || ext === '.py') && !isTest) {
                const baseName = path.basename(f, ext);
                const dirPath = path.dirname(f);
                const hasTest = files.some(tf => /\.(test|spec)\./.test(tf) &&
                    (path.dirname(tf).includes(path.relative(rootDir, dirPath)) || path.basename(tf).includes(baseName)));
                if (!hasTest && content.length > 100) {
                    untestedFiles++;
                    untestedFileList.push(path.relative(rootDir, f));
                }
            }
        }
        catch { }
    }
    if (missingTryCatch > 0) {
        spots.push({
            area: 'error-handling',
            severity: missingTryCatch > files.length * 0.3 ? 'high' : 'medium',
            files: missingTryCatchFiles.slice(0, 5),
            fileCount: missingTryCatch,
            description: `${missingTryCatch}/${files.length} files have no try/catch error handling`,
            fix: 'Add try/catch blocks around file I/O, API calls, and dangerous operations',
        });
    }
    if (missingNullChecks > 0) {
        spots.push({
            area: 'null-safety',
            severity: 'medium',
            files: missingNullChecksFiles.slice(0, 5),
            fileCount: missingNullChecks,
            description: 'Files lacking null/undefined safety checks',
            fix: 'Use optional chaining (?.) and nullish coalescing (??)',
        });
    }
    if (untestedFiles > 0) {
        spots.push({
            area: 'testing',
            severity: untestedFiles > files.length * 0.5 ? 'high' : 'medium',
            files: untestedFileList.slice(0, 5),
            fileCount: untestedFiles,
            description: `${untestedFiles}/${files.length} files have no tests`,
            fix: 'Add test files following your existing pattern (describe/it blocks for TS, pytest for Python)',
        });
    }
    if (consoleLogFiles > 0) {
        spots.push({
            area: 'logging',
            severity: 'low',
            files: consoleLogFileList.slice(0, 5),
            fileCount: consoleLogFiles,
            description: `${consoleLogFiles} files use console.log instead of structured logger`,
            fix: 'Replace console.log with a structured logger (winston/pino)',
        });
    }
    if (missingTypes > 0) {
        spots.push({
            area: 'type-safety',
            severity: 'medium',
            files: missingTypeFiles.slice(0, 5),
            fileCount: missingTypes,
            description: `${missingTypes} TypeScript files with minimal or no type annotations`,
            fix: 'Add interface/type definitions and remove implicit any',
        });
    }
    return spots;
}
function detectProblemSolvingStyle(rootDir) {
    const files = discoverAllFiles(rootDir);
    const sizes = { small: 0, medium: 0, large: 0, xlarge: 0 };
    for (const f of files) {
        try {
            const content = fs.readFileSync(f, 'utf-8');
            const lines = content.split('\n').length;
            if (lines < 50)
                sizes.small++;
            else if (lines < 200)
                sizes.medium++;
            else if (lines < 500)
                sizes.large++;
            else
                sizes.xlarge++;
        }
        catch { }
    }
    const total = sizes.small + sizes.medium + sizes.large + sizes.xlarge || 1;
    let fileOrganization = 'balanced';
    if (sizes.small / total > 0.6)
        fileOrganization = 'many-small-files';
    else if (sizes.large / total > 0.3 || sizes.xlarge / total > 0.15)
        fileOrganization = 'few-large-files';
    let comments = { filesWithJSDoc: 0, total: 0, ratio: 0 };
    for (const f of files.slice(0, 100)) {
        try {
            const content = fs.readFileSync(f, 'utf-8');
            if (/\/\*\*|\*\//.test(content) || /# \w/.test(content) || /"""[\s\S]*"""/.test(content)) {
                comments.filesWithJSDoc++;
            }
            comments.total++;
        }
        catch { }
    }
    comments.ratio = comments.total > 0 ? comments.filesWithJSDoc / comments.total : 0;
    const namingStyle = 'mixed';
    const decompositionStyle = 'both';
    return { functionSizes: sizes, fileOrganization, comments, namingStyle, decompositionStyle };
}
function detectTimePatterns(rootDir) {
    const countsByDay = { Mon: 0, Tue: 0, Wed: 0, Thu: 0, Fri: 0, Sat: 0, Sun: 0 };
    const countsByHour = {};
    const bugTimes = [];
    const subdirs = findProjectDirs(rootDir);
    for (const dir of subdirs.slice(0, 4)) {
        const log = commitLog(dir, 300);
        if (!log)
            continue;
        const commits = log.split('\n').filter(Boolean);
        for (const line of commits) {
            const parts = line.split('|');
            if (parts.length < 3)
                continue;
            let datePart = parts[1];
            const dateOffset = datePart.match(/[+-]\d{2}:\d{2}/);
            if (dateOffset && dateOffset.index !== undefined) {
                datePart = datePart.substring(0, dateOffset.index).trim();
            }
            const d = new Date(datePart);
            if (isNaN(d.getTime()))
                continue;
            const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            countsByDay[days[d.getDay()]]++;
            countsByHour[d.getHours()] = (countsByHour[d.getHours()] || 0) + 1;
            const msg = parts.slice(2).join('|');
            if (/\b(fix|bug|error|broken)\b/i.test(msg)) {
                bugTimes.push(`${days[d.getDay()]} ${d.getHours()}:00`);
            }
        }
    }
    let bestHour = 10;
    let maxHourCount = 0;
    for (const [h, c] of Object.entries(countsByHour)) {
        if (c > maxHourCount) {
            maxHourCount = c;
            bestHour = parseInt(h);
        }
    }
    const formatHour = (h) => `${h}:00-${h + 1}:00`;
    return {
        bestHours: formatHour(bestHour),
        mostProductiveDay: Object.entries(countsByDay).sort((a, b) => b[1] - a[1])[0]?.[0] || 'Unknown',
        averageSessionMinutes: 45,
        commitCountByDay: countsByDay,
        commitCountByHour: countsByHour,
        bugIntroductionTimes: bugTimes.slice(0, 10),
    };
}
function detectBugHistory(rootDir) {
    const bugs = [];
    const subdirs = findProjectDirs(rootDir);
    for (const dir of subdirs.slice(0, 3)) {
        let log = '';
        try {
            log = safeExec(`git -C "${dir}" log -200 --format="%ai|%s" --name-only`);
        }
        catch {
            continue;
        }
        if (!log)
            continue;
        let currentDate = '';
        let currentMsg = '';
        for (const line of log.split('\n')) {
            if (line.includes('|') && line.match(/^\d{4}-\d{2}-\d{2}/)) {
                const parts = line.split('|');
                if (parts.length >= 2) {
                    currentDate = parts[0].trim();
                    currentMsg = parts.slice(1).join('|').trim();
                    if (/\b(fix|bug|error|broken|hotfix)\b/i.test(currentMsg)) {
                        bugs.push({ date: currentDate, file: '', message: currentMsg, category: 'unknown', fixCommitDate: currentDate, hoursToFix: 0, wasReverted: false });
                    }
                }
            }
            else if (line.trim().startsWith('Revert')) {
                if (bugs.length > 0)
                    bugs[bugs.length - 1].wasReverted = true;
            }
        }
    }
    return bugs.slice(0, 50);
}
function detectDecisions(rootDir) {
    const decisions = [];
    const subdirs = findProjectDirs(rootDir);
    for (const dir of subdirs.slice(0, 3)) {
        const log = commitLog(dir, 200);
        if (!log)
            continue;
        for (const line of log.split('\n').filter(Boolean)) {
            const parts = line.split('|');
            if (parts.length < 3)
                continue;
            const date = parts[1].trim();
            const msg = parts.slice(2).join('|').trim();
            let type = null;
            let from;
            let to;
            if (msg.match(/\badd\b.*\b(package|dependency|lib|library)\b/i)) {
                type = 'add';
            }
            else if (msg.match(/\b(remove|drop|replace|switch|migrate|refactor)\b/i)) {
                if (msg.match(/\b(migrate|switch|replace)\b/i))
                    type = 'migrate';
                else if (msg.match(/\b(remove|drop)\b/i))
                    type = 'remove';
                else
                    type = 'refactor';
            }
            if (type) {
                decisions.push({ date, type, from, to, message: msg, affected: [] });
            }
        }
    }
    return decisions.slice(0, 40);
}
function detectTechMastery(rootDir) {
    const langStats = new Map();
    const extToLang = {
        '.ts': 'TypeScript', '.tsx': 'TypeScript',
        '.js': 'JavaScript', '.jsx': 'JavaScript', '.mjs': 'JavaScript',
        '.py': 'Python',
        '.go': 'Go',
        '.html': 'HTML', '.htm': 'HTML',
    };
    const files = discoverAllFiles(rootDir);
    for (const f of files) {
        const ext = path.extname(f).toLowerCase();
        const lang = extToLang[ext];
        if (!lang)
            continue;
        if (!langStats.has(lang))
            langStats.set(lang, { files: 0, lines: 0, errorFiles: 0, cleanFiles: 0, first: '', last: '' });
        const s = langStats.get(lang);
        s.files++;
        try {
            const content = fs.readFileSync(f, 'utf-8');
            s.lines += content.split('\n').length;
            const hasErrors = /\b(todo|fixme|hack|workaround|bug)\b/i.test(content) || !/\btry\b/.test(content) || /\bany\b/.test(content);
            if (hasErrors)
                s.errorFiles++;
            else
                s.cleanFiles++;
            const stat = fs.statSync(f);
            const date = stat.mtime.toISOString().split('T')[0];
            if (!s.first || date < s.first)
                s.first = date;
            if (!s.last || date > s.last)
                s.last = date;
        }
        catch { }
    }
    const result = [];
    for (const [lang, stats] of langStats) {
        const errorRatio = stats.files > 0 ? stats.errorFiles / stats.files : 0;
        let assessment = 'new';
        if (stats.files > 100 && errorRatio < 0.2)
            assessment = 'mastered';
        else if (stats.files > 50 && errorRatio < 0.4)
            assessment = 'proficient';
        else if (stats.files > 10)
            assessment = 'learning';
        result.push({ language: lang, fileCount: stats.files, lineCount: stats.lines, errorProneFiles: stats.errorFiles, cleanFiles: stats.cleanFiles, firstUsed: stats.first, lastUsed: stats.last, assessment });
    }
    result.sort((a, b) => b.fileCount - a.fileCount);
    return result;
}
function findProjectDirs(root) {
    const dirs = [];
    try {
        const entries = fs.readdirSync(root, { withFileTypes: true });
        for (const e of entries) {
            if (e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules') {
                const full = path.join(root, e.name);
                if (fs.existsSync(path.join(full, '.git')) || fs.existsSync(path.join(full, 'package.json'))) {
                    dirs.push(full);
                }
            }
        }
    }
    catch { }
    return dirs;
}
function discoverAllFiles(rootDir, maxFiles = 5000) {
    const files = [];
    const exts = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.py', '.go']);
    function walk(dir, depth = 0) {
        if (depth > 6 || files.length >= maxFiles)
            return;
        let entries;
        try {
            entries = fs.readdirSync(dir, { withFileTypes: true });
        }
        catch {
            return;
        }
        for (const e of entries) {
            if (e.name === 'node_modules' || e.name.startsWith('.') || e.name === 'dist' || e.name === 'build' || e.name === 'coverage')
                continue;
            const full = path.join(dir, e.name);
            if (e.isDirectory())
                walk(full, depth + 1);
            else if (e.isFile() && exts.has(path.extname(e.name).toLowerCase()))
                files.push(full);
        }
    }
    walk(rootDir);
    return files;
}
function buildIntelligenceReport(rootDir) {
    return {
        mistakes: detectRepeatMistakes(rootDir),
        blindSpots: detectBlindSpots(rootDir),
        problemSolving: detectProblemSolvingStyle(rootDir),
        timePatterns: detectTimePatterns(rootDir),
        bugHistory: detectBugHistory(rootDir),
        decisions: detectDecisions(rootDir),
        techMastery: detectTechMastery(rootDir),
        generatedAt: new Date().toISOString(),
        projectCount: findProjectDirs(rootDir).length,
        totalFiles: discoverAllFiles(rootDir).length,
    };
}
function saveIntelligenceReport(report) {
    const dir = path.join(os.homedir(), '.fivo', 'cell');
    if (!fs.existsSync(dir))
        fs.mkdirSync(dir, { recursive: true });
    const fp = path.join(dir, 'intelligence.json');
    const prev = fs.existsSync(fp) ? JSON.parse(fs.readFileSync(fp, 'utf-8')) : null;
    const historyDir = path.join(dir, 'memory');
    if (!fs.existsSync(historyDir))
        fs.mkdirSync(historyDir, { recursive: true });
    if (prev) {
        const snapshot = path.join(historyDir, `intelligence-${prev.generatedAt.slice(0, 10)}.json`);
        try {
            fs.writeFileSync(snapshot, JSON.stringify(prev, null, 2), 'utf-8');
        }
        catch { }
    }
    fs.writeFileSync(fp, JSON.stringify(report, null, 2), 'utf-8');
    const mdPath = path.join(dir, 'intelligence.md');
    fs.writeFileSync(mdPath, renderIntelligenceMd(report), 'utf-8');
    return fp;
}
function renderIntelligenceMd(r) {
    const lines = [];
    lines.push('# 🧠 FIVO Cell — Your Intelligence Profile');
    lines.push('');
    lines.push(`> Generated: ${r.generatedAt}`);
    lines.push(`> Projects: ${r.projectCount} | Files: ${r.totalFiles}`);
    lines.push('');
    lines.push('## 🔁 Repeat Mistakes');
    lines.push('');
    if (r.mistakes.length === 0) {
        lines.push('> No repeat mistakes detected. Keep going!');
    }
    else {
        for (const m of r.mistakes.slice(0, 8)) {
            lines.push(`### [${m.category}] ${m.pattern}`);
            lines.push(`- **Count:** ${m.count} times | **Last:** ${m.lastOccurrence} | **Still happening:** ${m.stillHappening ? '✅ Yes' : '✅ No'}`);
            lines.push('');
        }
    }
    lines.push('## 🎯 Blind Spots');
    lines.push('');
    if (r.blindSpots.length === 0) {
        lines.push('> No blind spots detected!');
    }
    else {
        for (const b of r.blindSpots) {
            lines.push(`### ${b.area} (${b.severity} severity)`);
            lines.push(`- **${b.fileCount} files** — ${b.description}`);
            lines.push(`- **Fix:** ${b.fix}`);
            lines.push('');
        }
    }
    lines.push('## 🧩 Problem-Solving Style');
    lines.push('');
    lines.push(`- **File organization:** ${r.problemSolving.fileOrganization}`);
    lines.push(`- **Function sizes:** S:${r.problemSolving.functionSizes.small} M:${r.problemSolving.functionSizes.medium} L:${r.problemSolving.functionSizes.large} XL:${r.problemSolving.functionSizes.xlarge}`);
    lines.push(`- **Documentation ratio:** ${Math.round(r.problemSolving.comments.ratio * 100)}% files documented`);
    lines.push('');
    lines.push('## ⏰ Time & Energy');
    lines.push('');
    lines.push(`- **Best hours:** ${r.timePatterns.bestHours}`);
    lines.push(`- **Most productive day:** ${r.timePatterns.mostProductiveDay}`);
    lines.push('');
    if (r.bugHistory.length > 0) {
        lines.push('## 🐛 Bug History');
        lines.push('');
        lines.push(`- **Bugs found:** ${r.bugHistory.length}`);
        lines.push(`- **Reverted:** ${r.bugHistory.filter(b => b.wasReverted).length}`);
        lines.push('');
    }
    if (r.decisions.length > 0) {
        lines.push('## 📋 Decision History');
        lines.push('');
        lines.push(`- **Decisions tracked:** ${r.decisions.length}`);
        lines.push(`- **Types:** add=${r.decisions.filter(d => d.type === 'add').length} migrate=${r.decisions.filter(d => d.type === 'migrate').length} remove=${r.decisions.filter(d => d.type === 'remove').length}`);
        lines.push('');
    }
    if (r.techMastery.length > 0) {
        lines.push('## 🗺️ Tech Mastery Map');
        lines.push('');
        lines.push('| Language | Files | Lines | Clean % | Assessment | First Used | Last Used |');
        lines.push('|----------|-------|-------|---------|------------|------------|-----------|');
        for (const t of r.techMastery) {
            lines.push(`| ${t.language} | ${t.fileCount} | ${t.lineCount.toLocaleString()} | ${Math.round(t.cleanFiles / (t.fileCount || 1) * 100)}% | ${t.assessment} | ${t.firstUsed} | ${t.lastUsed} |`);
        }
        lines.push('');
    }
    return lines.join('\n');
}
//# sourceMappingURL=behavior-intelligence.js.map