'use strict';
const $app = document.getElementById('app');
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
// "#N" in escaped text becomes a link to PR N; not after '>', '=', '"', '/', '&' or a word character,
// so attributes, entities, URLs and existing link text stay as they are.
const MAX_PR = 15745; // shortcut: highest PR number in the data; the 41 unused numbers below it open a "not found" page
const prLinks = h => h.replace(/(^|[^\w&;\/>="])#(\d{1,5})\b/g, (m, pre, n) => +n >= 1 && +n <= MAX_PR ? `${pre}#${n}` : m);
// Escaped text with `code`, **bold** and PR links; everything else stays literal.
const rich = s => prLinks(esc(s).replace(/`([^`\n]+)`/g, '$1'))
.replace(/\*\*([^*\n]+)\*\*/g, '$1');
// Small Markdown renderer for agent-written text: every character is escaped first, so no raw HTML gets through.
const mdInline = s => {
const codes = []; // code spans go out first so nothing inside them is formatted
return prLinks(esc(s.replace(/`([^`\n]+)`/g, (_, c) => `\u0000${codes.push(c) - 1}\u0000`))
.replace(/\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/g, '$1'))
.replace(/\*\*([^*\n]+)\*\*/g, '$1')
.replace(/(^|[\s(])\*([^*\s][^*\n]*)\*/g, '$1$2')
.replace(/\u0000(\d+)\u0000/g, (_, i) => `${esc(codes[i])}`);
};
function md(src) {
const out = [], lines = String(src ?? '').split('\n');
let para = [], list = null;
const flush = () => {
if (para.length) out.push(`
${mdInline(para.join('\n'))}
`);
if (list) out.push(`${list}>`);
para = []; list = null;
};
for (let i = 0; i < lines.length; i++) {
const l = lines[i], item = l.match(/^\s*([-*+]|\d+[.)])\s+(.*)$/), h = l.match(/^(#{1,6})\s+(.*)$/);
if (/^\s*```/.test(l)) {
flush();
const code = [];
while (++i < lines.length && !/^\s*```/.test(lines[i])) code.push(lines[i]);
out.push(`
${esc(code.join('\n'))}
`);
} else if (h) { flush(); out.push(`
${mdInline(h[2])}
`); }
else if (item) {
const kind = /\d/.test(item[1]) ? 'ol' : 'ul';
if (para.length || list !== kind) { flush(); out.push(`<${kind}>`); list = kind; }
out.push(`
${mdInline(item[2])}
`);
} else if (/^>\s?/.test(l)) { flush(); out.push(`
${mdInline(l.replace(/^>\s?/, ''))}
`); }
else if (!l.trim()) flush();
else if (list && /^\s+\S/.test(l)) out[out.length - 1] = out[out.length - 1].replace(/<\/li>$/, ' ' + mdInline(l.trim()) + '');
else { if (list) flush(); para.push(l); }
}
flush();
return out.join('');
}
const time = t => t ? t.replace('T', ' ').slice(0, 19) : '';
const short = s => s ? s.slice(0, 7) : '';
const api = async url => {
const r = await fetch(url);
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).detail || r.statusText);
return r.json();
};
const errBox = e => `
${esc(e.message || e)}
`;
document.getElementById('theme').onclick = () => {
const dark = document.documentElement.dataset.theme
? document.documentElement.dataset.theme === 'dark'
: matchMedia('(prefers-color-scheme: dark)').matches;
document.documentElement.dataset.theme = dark ? 'light' : 'dark';
try { localStorage.setItem('theme', document.documentElement.dataset.theme); } catch (e) {}
if (window.redrawChart) window.redrawChart();
};
let navs = 0; // in-app navigations, so 'back' knows whether there is somewhere to go back to
function go(url) { navs++; history.pushState(null, '', url); route(); }
document.addEventListener('click', e => {
const a = e.target.closest('a[data-nav]');
if (a && !e.metaKey && !e.ctrlKey) { e.preventDefault(); go(a.getAttribute('href')); }
});
window.addEventListener('popstate', route);
function route() {
window.redrawChart = null; ex = null; $app.className = '';
const path = location.pathname, tab = path === '/' || path.startsWith('/agent/') ? 'agents' : path.startsWith('/commit') || path.startsWith('/pr/') ? 'commits' : '';
document.querySelectorAll('.maintabs a').forEach(a => a.setAttribute('aria-selected', a.dataset.tab === tab));
const p = location.pathname, m = p.match(/^\/commit\/([0-9a-f]+)/), mm = p.match(/^\/message\/(\d+)/), mp = p.match(/^\/pr\/(\d+)/);
if (m) return commitPage(m[1]);
if (mp) return prPage(+mp[1]);
if (p === '/data') return dataPage();
if (mm) return messagePage(+mm[1]);
const ma = p.match(/^\/agent\/([\w.-]+)/);
if (ma) return agentPage(decodeURIComponent(ma[1]));
if (p === '/commits') return homePage();
agentsHome();
}
// ---------- home: the explorer ----------
const DEFAULT_SHA = '24cbc0439e07fd015c0747ab3be6e782a42b5c5b'; // the final commit of the run
const BASELINES = [['SmolLM-1.7B', 40.6], ['SmolLM-360M', 26.6], ['SmolLM-135M', 10.1]];
let scoresP = null; // the score curve, fetched once
let ex = null; // explorer state: { sha, commit, seq, strip, view }
async function homePage() {
document.title = 'PyBot Data Explorer';
const params = new URLSearchParams(location.search);
$app.className = 'wide';
$app.innerHTML = `
`).join('');
},
};
async function sumDiff(el, ok, c) {
const d = await api(`/api/commits/${c.sha}/diff?patch=false`);
if (!ok()) return;
el.innerHTML = `
${plural(d.files.length, 'file')} · +${d3.sum(d.files, f => f.additions || 0)} −${d3.sum(d.files, f => f.deletions || 0)}
';
const x = w[i], { recs: all, end } = await lastTurns(x, 1200), recs = all.slice(-12);
if (!ok()) return;
box.innerHTML = (x.reconstructed ? RECON : '') + `
${esc(x.agent)} · last ${recs.length} turns before ${x.role === 'author' ? 'the merge' : 'the review'} (${time(end).slice(11, 16)}); click a turn to open it
· full trace → · trace file ↗
` + (recs.map(miniTurn).join('') || '
No turns in this window.
');
box.onclick = e => { const t = e.target.closest('.mturn'); if (t && !e.target.closest('a')) t.classList.toggle('open'); };
};
el.querySelector('.chips').onclick = e => { const b = e.target.closest('button'); if (b) show(+b.dataset.i).catch(err => box.innerHTML = errBox(err)); };
await show(0);
}
const callLine = p => `${esc(p.name)} ${esc(String(p.arguments?.command ?? p.arguments?.path ?? JSON.stringify(p.arguments || {})).replace(/^cd \S+ && /, ''))}`;
function oneTurn(rec) {
const parts = rec.message.content || [], call = parts.find(p => p.type === 'toolCall'), say = parts.find(p => p.type === 'text' && p.text.trim()) || parts.find(p => p.type === 'thinking');
return `${time(rec.timestamp).slice(11, 16)} ` + (call ? `${callLine(call)}` : esc(firstLine(say?.text ?? say?.thinking)));
}
function miniTurn(rec) {
const parts = rec.message.content || [];
return `
';
if (r.items.length > 6) {
list.insertAdjacentHTML('beforeend', ``);
list.querySelector('.more').onclick = e => { e.target.remove(); list.insertAdjacentHTML('beforeend', r.items.slice(6).map(card).join('')); };
}
}
async function tracesTab(panel, n) {
const w = await api(`/api/prs/${n}/traces`);
panel.innerHTML = `
The author's trace from ten minutes before the PR opened until it merged or closed, and each reviewer's trace within fifteen minutes of their review. Controller events are hidden.
${esc(p.author)} · ${esc(p.state)} · opened ${time(p.opened_ts).slice(0, 16)} · never merged
Loading…
`;
const panel = document.getElementById('panel');
try { await ({ reviews: reviewsTab, traces: tracesTab, messages: messagesTab }[tab] || reviewsTab)(panel, n); }
catch (e) { panel.innerHTML = errBox(e); }
}
// ---------- data sources ----------
const SOURCES = [
{ name: 'Agent traces', kind: 'Dataset', repo: 'HuggingFaceSwarms/pybot-traces', url: 'https://huggingface.co/datasets/HuggingFaceSwarms/pybot-traces',
what: 'Every agent\'s session log: 1,000 agents (3 rebuilt from the controller\'s event log, which may have gaps), 51.3M records, ~33 GB of Pi JSONL (session header, system/user/assistant/tool-result messages, controller events). README and Apache-2.0 licence in the dataset.',
layout: 'traces//.jsonl · traces/_manifest.jsonl (one row per agent)',
cmds: ['hf download HuggingFaceSwarms/pybot-traces --repo-type dataset --include "traces/_manifest.jsonl" --local-dir pybot-traces',
'hf download HuggingFaceSwarms/pybot-traces --repo-type dataset --include "traces/answers/*" --local-dir pybot-traces'] },
{ name: 'Message board', kind: 'Space', repo: 'HuggingFaceSwarms/pybot-msgboard', url: 'https://huggingface.co/spaces/HuggingFaceSwarms/pybot-msgboard',
viewer: 'https://huggingfaceswarms-pybot-msgboard.hf.space',
what: 'What the agents said to each other: 184,059 messages in 12 channels, channel docs and stored files, with a read-only viewer (shared links: /#msg/).',
layout: 'data/ (start with data/manifest.json) · web/reader.js decodes the message chunks',
cmds: ['hf download HuggingFaceSwarms/pybot-msgboard --repo-type space --local-dir pybot-msgboard'] },
{ name: 'Commits', kind: 'Dataset', repo: 'HuggingFaceSwarms/pybot-commits', url: 'https://huggingface.co/datasets/HuggingFaceSwarms/pybot-commits',
what: 'The chatbot\'s code with its full git history: 8,609 commits on a linear main up to 24cbc04, plus a few later commits that only change the dataset card.',
layout: 'a git repository; each commit page is /commit/, each file /blob//',
cmds: ['git clone https://huggingface.co/datasets/HuggingFaceSwarms/pybot-commits', 'git -C pybot-commits show 24cbc04 --stat'] },
{ name: 'PyBot Data Explorer tables', kind: 'Space', repo: 'HuggingFaceSwarms/pybot-explorer', url: 'https://huggingface.co/spaces/HuggingFaceSwarms/pybot-explorer/tree/main/data',
what: 'The SQLite files behind this site: PRs, reviews, commits with SmolTalkBench scores, board messages with full-text search, trace windows and PR-message links (explorer.sqlite), and the per-agent trace time index (traces.sqlite). The scripts that build them are in build/; the API (/docs) serves the same data.',
layout: 'data/explorer.sqlite · data/traces.sqlite · build/build_db.py · build/index_traces.py',
cmds: ['hf download HuggingFaceSwarms/pybot-explorer --repo-type space --include "data/*" --local-dir pybot-explorer'] },
];
function dataPage() {
document.title = 'Data · PyBot Data Explorer';
$app.innerHTML = `
Data sources
Where the data lives
Everything here is the scrubbed release data of the PyBot run, cut at commit 24cbc04
(2026-11-13 10:17 UTC). The message-board export runs about a day longer, to 2026-11-14 12:50 UTC.
Agents can use the API and llms.txt; each API answer carries a source link back to these repositories.
${m.thread_size} posts in this thread${m.thread_size > d.thread.length ? `; showing the first post and the ${d.thread.length - 1} replies nearest this one` : ''}.