async function renderStandards() { const content = document.getElementById('pageContent'); content.innerHTML = `
`; try { const data = await api.getStandards(); const standards = data.standards || []; const index = data.index || ''; const container = document.getElementById('standardsContent'); let html = ''; if (index) { html += `
📐 Standards Index
${escapeHtml(index)}
`; } if (standards.length === 0) { html += '
📐
No standards defined
Run "Discover Patterns" to extract conventions from your codebase
'; } else { html += `
${standards.map(s => `
${s.name.replace(/-/g, ' ')}
${escapeHtml(s.content.slice(0, 300))}${s.content.length > 300 ? '...' : ''}
`).join('')}
`; } container.innerHTML = html; } catch (err) { document.getElementById('standardsContent').innerHTML = `
${escapeHtml(err.message)}
`; } } async function viewStandard(name) { let content = ''; try { const data = await api.getStandards(); const std = (data.standards || []).find(s => s.name === name); if (std) content = std.content; } catch {} showModal(`Standard: ${name.replace(/-/g, ' ')}`, `
${escapeHtml(content)}
`, ` `); } async function runDiscovery() { try { const r = await api.discoverStandards(); showToast(r.message || 'Discovery started', 'success'); } catch (err) { showToast(`Error: ${err.message}`, 'error'); } }