fix(build): remove broken heatmap string replacement
- build-standalone-fixed.cjs: removed renderHeatmap() replacement block - The replacement used string concatenation with '\'' which broke single quotes in generated HTML, causing SyntaxError: unexpected token - Original renderHeatmap() in index.html uses template literals (`...`) which are safe and already contain showCellDetail onclick handler - Rebuilt index.standalone.html from fixed source - Zero console errors, zero JS syntax errors verified on port 3003
This commit is contained in:
7003
agent-evolution/index.standalone.html
Normal file
7003
agent-evolution/index.standalone.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -93,116 +93,7 @@ async function init() {
|
||||
html = html.substring(0, initStart.index) + newInit + html.substring(endIdx);
|
||||
}
|
||||
|
||||
// ---------- Replace renderHeatmap function ----------
|
||||
const heatmapStartPattern = /function renderHeatmap\(\)\s*\{/;
|
||||
const heatmapStart = html.match(heatmapStartPattern);
|
||||
if (heatmapStart) {
|
||||
let brace = 0, inFn = false, endIdx = heatmapStart.index;
|
||||
for (let i = heatmapStart.index; i < html.length; i++) {
|
||||
if (html[i] === '{') { brace++; inFn = true; }
|
||||
else if (html[i] === '}') { brace--; if (inFn && brace === 0) { endIdx = i + 1; break; } }
|
||||
}
|
||||
|
||||
const newHeatmap = `// Render Heatmap (read from agentData.model_benchmarks)
|
||||
function renderHeatmap() {
|
||||
const agents = Object.entries(agentData.agents);
|
||||
if (agents.length === 0) return;
|
||||
|
||||
// Build unique model list from all agents
|
||||
const modelSet = new Set();
|
||||
const modelIfScores = {};
|
||||
agents.forEach(([_, a]) => {
|
||||
const model = a.current.model;
|
||||
if (model) {
|
||||
modelSet.add(model);
|
||||
// Try to get IF score from benchmark, default to 70
|
||||
modelIfScores[model] = a.current.benchmark?.instruction_following || 70;
|
||||
}
|
||||
});
|
||||
|
||||
// Build hmModels array
|
||||
const hmModels = [...modelSet].map(m => {
|
||||
// Extract short name from full model ID
|
||||
let shortName = m;
|
||||
if (m.includes('qwen3-coder')) shortName = 'Qwen3-Coder';
|
||||
else if (m.includes('glm-')) shortName = m.includes('5.1') ? 'GLM-5.1' : 'GLM-5';
|
||||
else if (m.includes('nemotron')) shortName = m.includes('nano') ? 'Nem. Nano' : 'Nem. Super';
|
||||
else if (m.includes('minimax')) shortName = 'MiniMax M2.5';
|
||||
else if (m.includes('kimi')) shortName = 'Kimi K2.6';
|
||||
else if (m.includes('deepseek')) shortName = 'DeepSeek V3';
|
||||
else if (m.includes('qwen3.5')) shortName = 'Qwen3.5';
|
||||
else if (m.includes('gemma4')) shortName = 'Gemma4';
|
||||
|
||||
// Provider
|
||||
let provider = 'Ollama';
|
||||
if (m.includes('cloud') || m.includes('ollama-cloud')) provider = 'Ollama Cloud';
|
||||
else if (m.includes('openrouter')) provider = 'OpenRouter';
|
||||
else if (m.includes('groq')) provider = 'Groq';
|
||||
|
||||
return {
|
||||
n: shortName,
|
||||
p: provider,
|
||||
if: modelIfScores[m] || 70,
|
||||
full: m
|
||||
};
|
||||
});
|
||||
|
||||
// Build hmAgents array with scores per model
|
||||
const hmAgents = agents.map(([name, agent]) => {
|
||||
const currentModel = agent.current.model;
|
||||
const currentIdx = hmModels.findIndex(m => m.full === currentModel);
|
||||
const fitScore = agent.current.benchmark?.fit_score || 70;
|
||||
|
||||
// Generate scores per model using hash-based randomization
|
||||
const scores = hmModels.map((m, idx) => {
|
||||
if (m.full === currentModel) return fitScore;
|
||||
// Hash-based pseudo-random score between 50-75
|
||||
const hash = (name + m.full).split('').reduce((a, c) => a + c.charCodeAt(0), 0);
|
||||
return 50 + (hash % 26);
|
||||
});
|
||||
|
||||
return {
|
||||
n: name,
|
||||
c: currentIdx,
|
||||
s: scores
|
||||
};
|
||||
});
|
||||
|
||||
// Render the table
|
||||
const t = document.getElementById('hmTable');
|
||||
let h = '<thead><tr><th class="hm-role">Agent</th>';
|
||||
hmModels.forEach(m => {
|
||||
const ifColor = m.if >= 85 ? '#00ff94' : m.if >= 75 ? '#facc15' : '#ff6b81';
|
||||
h += '<th style="writing-mode:vertical-lr;transform:rotate(180deg;max-width:32px;font-size:.56em;padding:3px 1px;">' +
|
||||
m.n + '<br>' +
|
||||
'<span style="color:' + (m.p.includes('Cloud') ? 'var(--accent-cyan)' : 'var(--accent-green)') + ';font-size:.85em">' + m.p + '</span><br>' +
|
||||
'<span style="color:' + ifColor + ';font-size:.9em;font-weight:700" title="Instruction Following score">IF:' + m.if + '</span>' +
|
||||
'</th>';
|
||||
});
|
||||
h += '</tr></thead><tbody>';
|
||||
|
||||
hmAgents.forEach(ag => {
|
||||
const mx = Math.max(...ag.s);
|
||||
h += '<tr><td class="hm-r">' + ag.n + '</td>';
|
||||
ag.s.forEach((s, j) => {
|
||||
const best = s === mx;
|
||||
const cur = j === ag.c;
|
||||
const ifLow = hmModels[j].if < 75;
|
||||
let marks = '';
|
||||
if (best) marks += '<span class="hm-star">★</span>';
|
||||
if (ifLow) marks += '<span class="hm-if-warn">⚠</span>';
|
||||
h += '<td style="background:' + hmColor(s) + ';color:' + hmText(s) + '" class="' + (cur ? 'hm-cur' : '') + '" title="' + ag.n + ' × ' + hmModels[j].n + ': ' + s + '"' +
|
||||
' onmouseover="showTT(event,\\\'' + ag.n + '\\\',\\\'' + hmModels[j].n + ' (' + hmModels[j].p + ')\\\',' + s + ',' + best + ',' + cur + ',' + hmModels[j].if + ')"' +
|
||||
' onmouseout="hideTT()"' +
|
||||
' onclick="showCellDetail(\'' + hmModels[j].full + '\', \'' + ag.n + '\')">' + s + marks + '</td>';
|
||||
});
|
||||
h += '</tr>';
|
||||
});
|
||||
t.innerHTML = h + '</tbody>';
|
||||
}`;
|
||||
|
||||
html = html.substring(0, heatmapStart.index) + newHeatmap + html.substring(endIdx);
|
||||
}
|
||||
// ---------- Heatmap: original renderHeatmap() in index.html is correct ----------
|
||||
|
||||
// ---------- Replace renderRecommendations function ----------
|
||||
const recStartPattern = /function renderRecommendations\(\)\s*\{/;
|
||||
|
||||
Reference in New Issue
Block a user