readthrough 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. readthrough/__init__.py +8 -0
  2. readthrough/__main__.py +3 -0
  3. readthrough/agents.py +344 -0
  4. readthrough/analyze.py +537 -0
  5. readthrough/assets/SKILL.md +86 -0
  6. readthrough/assets/defaults.toml +143 -0
  7. readthrough/assets/profile-reference.md +133 -0
  8. readthrough/assets/vendor/README.md +22 -0
  9. readthrough/assets/vendor/cose-base.js +3214 -0
  10. readthrough/assets/vendor/cytoscape-fcose.js +1549 -0
  11. readthrough/assets/vendor/cytoscape.min.js +31 -0
  12. readthrough/assets/vendor/layout-base.js +5230 -0
  13. readthrough/assets/vendor/licenses/cose-base-LICENSE +21 -0
  14. readthrough/assets/vendor/licenses/cytoscape-LICENSE +19 -0
  15. readthrough/assets/vendor/licenses/cytoscape-fcose-LICENSE +19 -0
  16. readthrough/assets/vendor/licenses/dompurify-LICENSE +202 -0
  17. readthrough/assets/vendor/licenses/layout-base-LICENSE +21 -0
  18. readthrough/assets/vendor/licenses/lucide-LICENSE +15 -0
  19. readthrough/assets/vendor/licenses/marked-LICENSE +44 -0
  20. readthrough/assets/vendor/lucide-icons.js +36 -0
  21. readthrough/assets/vendor/marked.umd.js +82 -0
  22. readthrough/assets/vendor/purify.min.js +7 -0
  23. readthrough/assets/web/dashboard.css +202 -0
  24. readthrough/assets/web/dashboard.html +48 -0
  25. readthrough/assets/web/dashboard.js +937 -0
  26. readthrough/assets/web/setup.css +57 -0
  27. readthrough/assets/web/setup.html +28 -0
  28. readthrough/assets/web/setup.js +342 -0
  29. readthrough/assets/web/theme.css +36 -0
  30. readthrough/assistants.py +699 -0
  31. readthrough/brief.py +145 -0
  32. readthrough/build.py +616 -0
  33. readthrough/ci.py +107 -0
  34. readthrough/cli.py +958 -0
  35. readthrough/config.py +533 -0
  36. readthrough/contract.py +394 -0
  37. readthrough/engine.py +230 -0
  38. readthrough/faults.py +92 -0
  39. readthrough/files.py +110 -0
  40. readthrough/forges/__init__.py +614 -0
  41. readthrough/forges/azure_devops.py +658 -0
  42. readthrough/forges/forgejo.py +300 -0
  43. readthrough/forges/github.py +487 -0
  44. readthrough/forges/gitlab.py +335 -0
  45. readthrough/ledger.py +61 -0
  46. readthrough/limits.py +26 -0
  47. readthrough/logs.py +169 -0
  48. readthrough/membership.py +76 -0
  49. readthrough/model.py +177 -0
  50. readthrough/onboard.py +551 -0
  51. readthrough/onboard_model.py +319 -0
  52. readthrough/process.py +169 -0
  53. readthrough/profile.py +699 -0
  54. readthrough/py.typed +0 -0
  55. readthrough/registry.py +157 -0
  56. readthrough/review.py +394 -0
  57. readthrough/rules.py +111 -0
  58. readthrough/runtimes/__init__.py +297 -0
  59. readthrough/runtimes/anthropic.py +278 -0
  60. readthrough/runtimes/copilot.py +313 -0
  61. readthrough/runtimes/openai.py +307 -0
  62. readthrough/serve.py +817 -0
  63. readthrough/study.py +327 -0
  64. readthrough/system.py +205 -0
  65. readthrough/terminals.py +168 -0
  66. readthrough/tuning.py +266 -0
  67. readthrough/usage.py +169 -0
  68. readthrough/web_setup.py +635 -0
  69. readthrough-0.4.0.dist-info/METADATA +123 -0
  70. readthrough-0.4.0.dist-info/RECORD +73 -0
  71. readthrough-0.4.0.dist-info/WHEEL +4 -0
  72. readthrough-0.4.0.dist-info/entry_points.txt +2 -0
  73. readthrough-0.4.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,57 @@
1
+ header{display:flex;align-items:center;gap:12px}
2
+ .btn.icon{padding:0 7px;height:26px}
3
+ .layout{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;padding:18px 20px;max-width:1500px}
4
+ .welcome{background:linear-gradient(135deg,color-mix(in srgb,var(--acc) 10%,var(--panel)),var(--panel) 70%)}
5
+ .welcome h2{font-size:17px;margin:0 0 6px}.welcome p{margin:0 0 10px;max-width:70ch}
6
+ .welcome ol{margin:0;padding-left:0;list-style:none;display:flex;flex-direction:column;gap:6px}
7
+ .welcome li{display:flex;gap:8px;align-items:baseline;color:var(--mut);font-size:13px}.welcome li b{color:var(--fg);font-weight:500}
8
+ .welcome .step{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--acc);color:var(--acc-fg);font-size:11.5px;font-weight:600;flex:none;position:relative;top:4px}
9
+ nav.repos{display:flex;flex-direction:column;gap:4px}
10
+ .ritem{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:8px;cursor:pointer;border:1px solid transparent;background:none;color:var(--fg);font:inherit;text-align:left}
11
+ .ritem:hover{background:var(--subtle)}.ritem.on{background:var(--acc-soft);border-color:color-mix(in srgb,var(--acc) 30%,transparent)}
12
+ .ritem .n{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
13
+ .dot{width:8px;height:8px;border-radius:50%;flex:none;background:var(--mut)}.dot.ok{background:var(--good)}.dot.todo{background:var(--warn)}
14
+ .card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px 16px;margin-bottom:14px;box-shadow:var(--shadow)}
15
+ .card h2{font-size:15px;margin:0 0 4px;display:flex;align-items:center;gap:8px}.card h2 .step{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:var(--subtle);border:1px solid var(--line);font-size:12px;color:var(--mut)}
16
+ .card h2 .step.done{background:var(--good);border-color:var(--good);color:#fff}.card h2 .step .ico.sm{margin:0;stroke-width:2.5}
17
+ .card.dim{opacity:.55;pointer-events:none}
18
+ .sub{color:var(--mut);font-size:13px;margin:0 0 10px}
19
+ .access .cred{display:inline-block;padding:0 7px;margin:1px 2px;border-radius:999px;background:var(--inset);border:1px solid var(--line);color:var(--fg);font-size:12px}
20
+ details.access{color:var(--mut);font-size:13px;margin:4px 0 10px}
21
+ details.access summary{cursor:pointer}details.access summary:hover .access-more{color:var(--acc)}
22
+ details.access summary:focus-visible{outline:2px solid var(--acc);outline-offset:3px;border-radius:3px}
23
+ details.access b{color:var(--fg);font-weight:500}
24
+ details.access p{margin:7px 0}details.access ol{margin:6px 0;padding-left:24px}
25
+ details.access li{margin:3px 0}
26
+ .row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:8px 0}
27
+ label.f{display:flex;flex-direction:column;gap:3px;font-size:12.5px;color:var(--mut);min-width:180px}
28
+ input[type=text],input[type=number],select,textarea{background:var(--panel);border:1px solid var(--line);color:var(--fg);padding:6px 10px;border-radius:6px;font:inherit}
29
+ input[type=text]{min-width:280px}input.wide{min-width:460px}
30
+ input:focus,select:focus,textarea:focus{outline:2px solid var(--acc);outline-offset:-1px;border-color:transparent}
31
+ .btn{background:var(--subtle);border:1px solid var(--line);color:var(--fg);border-radius:6px;padding:4px 11px;font:inherit;font-size:13px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
32
+ .btn:hover{border-color:var(--line-strong);text-decoration:none}.btn:disabled{opacity:.5;cursor:default}
33
+ .btn.primary{background:var(--acc);border-color:var(--acc);color:var(--acc-fg);font-weight:500}
34
+ .btn.danger{color:var(--bad);border-color:color-mix(in srgb,var(--bad) 45%,transparent)}
35
+ .msg{font-size:13px;padding:6px 10px;border-radius:6px;background:var(--inset);margin:8px 0}.msg.ok{color:var(--good)}.msg.err{color:var(--bad);background:color-mix(in srgb,var(--bad) 8%,var(--panel))}
36
+ .cli{font-size:12.5px;color:var(--mut);margin-top:8px}.cli code{background:var(--inset);padding:2px 6px;border-radius:4px;user-select:all}
37
+ .editor{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(300px,1fr);gap:16px}
38
+ textarea.toml{width:100%;min-height:520px;font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12.5px;line-height:1.45;white-space:pre;tab-size:2;resize:vertical}
39
+ textarea.toml[readonly]{background:var(--inset);color:var(--mut)}
40
+ .meter{height:10px;border-radius:5px;background:var(--subtle);border:1px solid var(--line);position:relative;overflow:hidden;margin:6px 0}
41
+ .meter span{display:block;height:100%;background:var(--good)}.meter span.low{background:var(--warn)}
42
+ .meter i{position:absolute;top:-2px;bottom:-2px;width:2px;background:var(--fg);opacity:.6}
43
+ .report h3{font-size:12px;color:var(--mut);text-transform:uppercase;letter-spacing:.06em;margin:14px 0 4px}
44
+ .report ul{margin:4px 0;padding-left:18px}.report li{margin:2px 0}
45
+ .problems li{color:var(--bad)}
46
+ .authors{width:100%;border-collapse:collapse;font-size:13px}.authors td{padding:3px 6px;border-bottom:1px solid var(--line)}.authors select{padding:1px 4px;font-size:12px}
47
+ .k-internal{color:var(--good)}.k-external,.k-first-time{color:var(--external)}.k-bot{color:var(--mut)}
48
+ .log{font-size:12.5px;color:var(--mut);background:var(--inset);border-radius:6px;padding:6px 10px;max-height:160px;overflow:auto;margin:8px 0}
49
+ .log div::before{content:"› ";color:var(--acc)}
50
+ .spin{width:12px;height:12px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--acc);animation:spin .8s linear infinite;display:inline-block}
51
+ @keyframes spin{to{transform:rotate(360deg)}}
52
+ .ro{display:grid;grid-template-columns:150px 1fr;gap:4px 12px;font-size:13px}.ro dt{color:var(--mut)}.ro dd{margin:0}
53
+ .toast{position:fixed;bottom:18px;left:50%;transform:translateX(-50%);background:var(--fg);color:var(--bg);padding:7px 14px;border-radius:6px;opacity:0;transition:opacity .2s;z-index:40;pointer-events:none}.toast.on{opacity:1}
54
+ .empty{color:var(--mut);padding:30px;text-align:center}
55
+ @media (prefers-reduced-transparency:reduce),(prefers-contrast:more){header{background:var(--bg);backdrop-filter:none;-webkit-backdrop-filter:none}}
56
+ @media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
57
+ @media (max-width:1000px){.layout{grid-template-columns:1fr}.editor{grid-template-columns:1fr}input.wide{min-width:0;width:100%}}
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <html lang="en" data-theme="light">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-__NONCE__'; style-src 'unsafe-inline'; img-src data: https:; connect-src 'self'; base-uri 'none'; form-action 'none'">
6
+ <title>readthrough · repos</title>
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='30' fill='%230969da'/%3E%3Ccircle cx='32' cy='32' r='20' fill='none' stroke='%23fff' stroke-opacity='.45' stroke-width='3'/%3E%3Cpath d='M32 32 L32 2 A30 30 0 0 1 58 17 Z' fill='%23fff' fill-opacity='.35'/%3E%3Ccircle cx='32' cy='32' r='3.5' fill='%23fff'/%3E%3C/svg%3E">
9
+ <style>
10
+ /*__READTHROUGH_CSS__*/
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <header>
15
+ <h1><span id="logo"></span><span class="brand">readthrough</span><span class="crumb"><span class="crumb-sep" aria-hidden="true">/</span><span class="switch static" id="where">Set up</span></span><small id="meta"></small></h1>
16
+ <div class="hactions"><span id="back"></span><button class="btn icon" id="theme"></button></div>
17
+ </header>
18
+ <div class="layout">
19
+ <nav class="repos" id="nav" aria-label="Repos"></nav>
20
+ <main id="main"><div class="empty">Checking your accounts and repos…</div></main>
21
+ </div>
22
+ <div class="toast" id="toast"></div>
23
+ <script nonce="__NONCE__">/*__READTHROUGH_ICONS__*/</script>
24
+ <script nonce="__NONCE__">
25
+ /*__READTHROUGH_APP__*/
26
+ </script>
27
+ </body>
28
+ </html>
@@ -0,0 +1,342 @@
1
+ const LIVE = /*__READTHROUGH_LIVE__*/null;
2
+ const $ = id => document.getElementById(id);
3
+ const esc = s => String(s ?? "").replace(/[&<>"']/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
4
+ const icon = (name, cls = "ico") => `<svg class="${cls}" viewBox="0 0 24 24" aria-hidden="true">${LUCIDE[name] || ""}</svg>`;
5
+ // The theme: the same three-way choice as the dashboard, remembered in the same place.
6
+ const THEMES = ["auto", "light", "dark"];
7
+ let themePref = localStorage.getItem("readthrough:theme") || "auto";
8
+ const darkQuery = matchMedia("(prefers-color-scheme: dark)");
9
+ function applyTheme(){
10
+ document.documentElement.dataset.theme = themePref === "auto" ? (darkQuery.matches ? "dark" : "light") : themePref;
11
+ $("theme").innerHTML = icon({auto: "sun-moon", light: "sun", dark: "moon"}[themePref]);
12
+ $("theme").title = {auto: "Theme: follows your OS", light: "Theme: light", dark: "Theme: dark"}[themePref] + ". Click to change.";
13
+ $("theme").setAttribute("aria-label", $("theme").title);
14
+ }
15
+ darkQuery.addEventListener("change", applyTheme);
16
+ $("theme").addEventListener("click", () => { themePref = THEMES[(THEMES.indexOf(themePref) + 1) % THEMES.length]; localStorage.setItem("readthrough:theme", themePref); applyTheme(); });
17
+ applyTheme();
18
+ $("logo").innerHTML = `<svg class="logo" viewBox="0 0 32 32" aria-hidden="true"><rect x="5.5" y="3.5" width="21" height="25" rx="3" fill="none" stroke="currentColor" stroke-opacity=".35"/><rect x="7.5" y="7.25" width="17" height="5.5" rx="2.75" fill="currentColor" fill-opacity=".16"/><g stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-opacity=".45"><line x1="10" y1="10" x2="21" y2="10"/><line x1="10" y1="14.5" x2="18" y2="14.5"/><line x1="10" y1="19" x2="21" y2="19"/><line x1="10" y1="23.5" x2="16" y2="23.5"/></g></svg>`;
19
+ function toast(msg){ const t = $("toast"); t.textContent = msg; t.classList.add("on"); clearTimeout(toast.t); toast.t = setTimeout(() => t.classList.remove("on"), 2600); }
20
+ async function api(path, body){
21
+ const opts = body === undefined ? {cache: "no-store"} : {method: "POST", headers: {"Content-Type": "application/json", "X-Readthrough-Token": LIVE.token}, body: JSON.stringify(body)};
22
+ const resp = await fetch(path, opts);
23
+ const data = await resp.json().catch(() => ({}));
24
+ if (!resp.ok) throw new Error(data.error || resp.statusText);
25
+ return data;
26
+ }
27
+ async function poll(job, onLog){
28
+ for (;;) {
29
+ const j = await api(`/api/setup/jobs/${job}`);
30
+ onLog(j.log);
31
+ if (j.status === "done") return j.result;
32
+ if (j.status === "error") throw new Error(j.error);
33
+ await new Promise(r => setTimeout(r, 900));
34
+ }
35
+ }
36
+ const slug = s => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "part";
37
+ const label = s => { const n = s.split("/").pop().replace(/[_-]+/g, " "); return n.charAt(0).toUpperCase() + n.slice(1); };
38
+ const KIND_LABEL = {internal: "internal", external: "external", "first-time": "first-time", bot: "bot", unknown: "unknown"};
39
+
40
+ // ---- state
41
+ // A repo is referred to by its slug (forge/owner/name) everywhere the server is involved; the sidebar and
42
+ // headings show its plain name, with the forge named only when it isn't GitHub.
43
+ const S = {state: null, sel: new URLSearchParams(location.search).get("repo") || null, w: null};
44
+ const same = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
45
+ const isSel = r => same(S.sel, r.slug) || same(S.sel, r.name);
46
+ const forgeOf = name => (S.state?.forges || []).find(f => f.name === name) || {name, label: name, shape: "owner/name", accounts: false, pr_noun: "pull request"};
47
+ const forgeTag = r => r.forge && r.forge !== "github" ? ` <span class="sub" style="margin:0;font-weight:400">on ${esc(r.forge_label)}</span>` : "";
48
+ async function load(){
49
+ S.state = await api(`/api/setup/state${S.sel ? `?repo=${encodeURIComponent(S.sel)}` : ""}`);
50
+ render();
51
+ }
52
+ function render(){
53
+ const st = S.state, repos = st.repos, onboarded = repos.filter(r => r.onboarded);
54
+ $("back").innerHTML = onboarded.length ? `<a class="btn" href="/">${icon("map")}Dashboards</a>` : "";
55
+ // Where you are, in the header: the repo being set up, or the first-run welcome.
56
+ const repo = st.repo;
57
+ $("where").textContent = S.sel && repo ? (repo.onboarded ? repo.name : `Set up ${repo.name}`) : onboarded.length ? "Set up a repo" : "Welcome";
58
+ $("meta").textContent = onboarded.length ? `${onboarded.length} repo${onboarded.length > 1 ? "s" : ""} onboarded` : "";
59
+ $("nav").innerHTML = repos.map(r => `<button class="ritem ${isSel(r) ? "on" : ""}" data-repo="${esc(r.slug)}"><span class="dot ${r.onboarded ? "ok" : "todo"}" title="${r.onboarded ? "Onboarded" : "Not onboarded yet"}"></span><span class="n">${esc(r.name)}${forgeTag(r)}</span>${same(st.settings.default_repo, r.cli_name) ? '<span style="font-size:11px;color:var(--mut)">default</span>' : ""}</button>`).join("")
60
+ + `<button class="ritem ${S.sel ? "" : "on"}" data-new>${icon("plus")}<span class="n">Onboard a repo</span></button>`
61
+ + (onboarded.length ? `<div style="margin-top:14px">${globalCard()}</div>` : ""); // nothing to set until a repo exists
62
+ if (!S.sel || !repo || !repo.onboarded) {
63
+ renderWizard(repo, {first: !onboarded.length});
64
+ if (!onboarded.length && !S.w.repo && !S.w.focused) { S.w.focused = true; $("w-repo")?.focus(); }
65
+ if (S.w.repo && !S.w.info && !S.w.tried) { S.w.tried = true; act({dataset: {act: "inspect"}}); }
66
+ } else renderSettings(repo);
67
+ }
68
+ // The first thing a newcomer sees: what readthrough does and what the three steps below will ask for.
69
+ function welcome(){
70
+ return `<div class="card welcome"><h2>Welcome to readthrough</h2>
71
+ <p>It lays a repo's open pull requests on a map of the repo's architecture, packs the reviewable ones into hour-long sessions, and gives each one a study brief with a quiz, so you understand a change before you review it. Three steps, about two minutes:</p>
72
+ <ol><li><span class="step">1</span><span><b>Which repo</b> and how to read it.</span></li>
73
+ <li><span class="step">2</span><span><b>Your clone</b>, for deep reviews and study. Optional for the map.</span></li>
74
+ <li><span class="step">3</span><span><b>Its architecture profile</b>: drafted for you, checked against recent changes, accepted by you.</span></li></ol></div>`;
75
+ }
76
+
77
+ // ---- global settings (in the side bar)
78
+ function globalCard(){
79
+ const st = S.state.settings, onboarded = S.state.repos.filter(r => r.onboarded);
80
+ return `<div class="card" style="padding:10px 12px"><h2 style="font-size:13px">${icon("settings", "ico sm")}Everywhere</h2>
81
+ <label class="f">Default repo<select id="g-default"><option value="">(none)</option>${onboarded.map(r => `<option value="${esc(r.slug)}" ${same(st.default_repo, r.cli_name) ? "selected" : ""}>${esc(r.cli_name)}</option>`).join("")}</select></label>
82
+ <label class="f" style="margin-top:6px">Refresh every (minutes)<input type="number" id="g-refresh" min="1" max="1440" value="${st.refresh_minutes}" style="width:90px"></label>
83
+ <div class="row"><button class="btn" data-act="save-global">Save</button></div>
84
+ <div class="cli" style="margin-top:4px">Port <b>${st.port}</b> (change it in <code>config.toml</code>, then restart the server)</div></div>`;
85
+ }
86
+
87
+ // ---- onboarding wizard
88
+ function renderWizard(repo, {first = false} = {}){
89
+ const w = S.w ||= {repo: repo?.name || "", forge: repo?.forge || "github", account: repo?.account || "", clone: repo?.clone || "", remote: repo?.remote || "", info: null, cloneInfo: null, toml: repo?.profile_text || "", report: null, log: [], busy: false, editable: true, source: repo?.source || null};
90
+ const accounts = S.state.accounts, forges = S.state.forges, forge = forgeOf(w.forge), rt = S.state.runtime || {};
91
+ const cli = `readthrough onboard ${w.repo || forge.shape.split(" ")[0]}${w.forge !== "github" ? ` --forge ${w.forge}` : ""}${w.account ? ` --account ${w.account}` : ""}${w.clone ? ` --clone "${w.clone}"` : ""}`;
92
+ const step = (n, done) => `<span class="step ${done ? "done" : ""}">${done ? icon("check", "ico sm") : n}</span>`;
93
+ const info = w.info;
94
+ const howRead = `<details class="access" id="w-access" ${w.accessOpen ? "open" : ""}>
95
+ <summary>Read-only access to <b>${esc(forge.label)}</b> <span class="access-more">· connection details</span></summary>
96
+ <p>Read through ${esc(forge.access || "its API")}.</p>
97
+ ${forge.credentials?.length ? `<ol>${forge.credentials.map(c => `<li>${esc(c)}</li>`).join("")}</ol>` : ""}
98
+ <p>Nothing is written to the repo, and readthrough never stores a token${forge.accounts ? "" : " or prompts you to sign in"}.</p></details>`;
99
+ $("main").innerHTML = `${first ? welcome() : ""}
100
+ <div class="card"><h2>${step(1, !!info)}Which repo?</h2>
101
+ ${howRead}
102
+ <div class="row"><label class="f">Where<select id="w-forge">${forges.map(f => `<option value="${esc(f.name)}" ${w.forge === f.name ? "selected" : ""} title="${esc(f.summary)}">${esc(f.label)}</option>`).join("")}</select></label>
103
+ <label class="f">Repo<input type="text" id="w-repo" placeholder="${esc(forge.shape.split(" ")[0])}" value="${esc(w.repo)}" autocomplete="off" spellcheck="false"></label>
104
+ ${forge.accounts ? `<label class="f">Account<select id="w-account"><option value="">gh's active account</option>${accounts.map(a => `<option ${w.account === a ? "selected" : ""}>${esc(a)}</option>`).join("")}</select></label>` : ""}
105
+ <button class="btn primary" data-act="inspect" style="align-self:flex-end">Check access</button></div>
106
+ ${info ? `<div class="msg ok">${icon("circle-check", "ico sm")}<b>${esc(info.full_name)}</b> on ${esc(info.forge_label)} · ${info.private ? "private" : "public"} · default branch <code>${esc(info.default_branch)}</code>${info.description ? ` · ${esc(info.description)}` : ""}<br><span class="sub" style="margin:0">Read as <code>${esc(info.auth)}</code>.</span></div>` : ""}
107
+ ${w.err1 ? `<div class="msg err">${esc(w.err1)}</div>` : ""}</div>
108
+
109
+ <div class="card ${info ? "" : "dim"}"><h2>${step(2, w.cloneInfo?.ok)}Your local clone</h2>
110
+ <p class="sub">Deep reviews and study sessions check PRs out next to it in their own worktrees; your checkout isn't touched. Optional for just the map.</p>
111
+ <div class="row"><label class="f">Path<input type="text" class="wide" id="w-clone" placeholder="C:\\Users\\you\\src\\repo" value="${esc(w.clone)}" spellcheck="false"></label>
112
+ <button class="btn" data-act="clone" style="align-self:flex-end">Check</button>
113
+ ${w.cloneInfo?.remotes?.length ? `<label class="f">Remote for PRs<select id="w-remote">${w.cloneInfo.remotes.map(r => `<option value="${esc(r.name)}" ${(w.remote || w.cloneInfo.detected) === r.name ? "selected" : ""}>${esc(r.name)} · ${esc(r.url)}</option>`).join("")}</select></label>` : ""}</div>
114
+ ${w.cloneInfo ? `<div class="msg ${w.cloneInfo.ok ? "ok" : ""}">${esc(w.cloneInfo.message)}</div>` : ""}${w.err2 ? `<div class="msg err">${esc(w.err2)}</div>` : ""}</div>
115
+
116
+ <div class="card ${info ? "" : "dim"}"><h2>${step(3, !!w.toml)}Its architecture profile</h2>
117
+ <p class="sub">The map, the contracts in each PR's brief, and the quiz questions all come from this. ${w.source ? `Found one: <b>${esc(w.source.label)}</b>.` : "There isn't one yet, so draft one."}</p>
118
+ <div class="row">${w.source ? `<button class="btn primary" data-act="draft" data-mode="source" ${w.busy ? "disabled" : ""}>Use ${w.source.kind === "shared" ? "the shared" : w.source.kind === "repo" ? "the repo's" : "the existing"} profile</button>` : ""}
119
+ <button class="btn ${w.source ? "" : "primary"}" data-act="draft" data-mode="plain" ${w.busy ? "disabled" : ""}>${icon("layers", "ico sm")}Draft from the file tree</button>
120
+ <button class="btn" data-act="draft" data-mode="model" ${w.busy || !rt.available ? "disabled" : ""} title="${esc(rt.available ? `${rt.describe} reads the code and docs and proposes a profile; each proposal is checked like Accept does` : rt.reason)}">${icon("sparkles", "ico sm")}Draft with a model${rt.available ? ` <span class="muted">(${esc(rt.name)})</span>` : ""}</button>
121
+ ${w.busy ? '<span class="spin"></span>' : ""}</div>
122
+ ${w.log.length ? `<div class="log" id="w-log">${w.log.map(l => `<div>${esc(l)}</div>`).join("")}</div>` : ""}${w.err3 ? `<div class="msg err">${esc(w.err3)}</div>` : ""}</div>
123
+
124
+ ${w.toml ? editorCard(w, "w", {onboarding: true}) : ""}
125
+ <div class="cli">Same thing from a terminal: <code>${esc(cli)}</code></div>`;
126
+ const log = $("w-log"); if (log) log.scrollTop = log.scrollHeight;
127
+ }
128
+
129
+ // ---- the profile editor with its live report (shared by onboarding and settings)
130
+ function editorCard(e, key, {onboarding = false, editable = true} = {}){
131
+ const r = e.report, ok = r?.valid && !r.problems.length;
132
+ const share = r?.valid ? Math.round(r.share * 100) : 0;
133
+ const report = !r ? '<p class="sub">Checking…</p>' : !r.valid ? `<div class="msg err">${esc(r.error)}</div>` : `
134
+ <div><b>${share}%</b> of ${r.total} ${esc(r.basis)} map to a component <span class="sub">(needs ${Math.round(r.need * 100)}%)</span></div>
135
+ <div class="meter"><span class="${share < r.need * 100 ? "low" : ""}" style="width:${share}%"></span><i style="left:${r.need * 100}%"></i></div>
136
+ ${r.problems.length ? `<h3>Before accepting</h3><ul class="problems">${r.problems.map(p => `<li>${esc(p)}</li>`).join("")}</ul>` : `<div class="msg ok">${icon("circle-check", "ico sm")}${onboarding ? "Ready to accept." : "All checks pass."}</div>`}
137
+ ${r.unmapped.length ? `<h3>Not mapped yet</h3><ul>${r.unmapped.map(([p, n]) => `<li><code>${esc(p)}</code> ${n} ${editable ? `<button class="btn" style="padding:0 6px;font-size:12px" data-act="add-comp" data-key="${key}" data-path="${esc(p)}" title="Add a component for this path to the profile">+ component</button>` : ""}</li>`).join("")}</ul>` : ""}
138
+ <h3>Busiest components</h3><div style="font-size:13px">${r.busiest.map(([l, n]) => `${esc(l)} <span class="sub">${n}</span>`).join(" · ")}</div>
139
+ <h3>Recent authors</h3>${authorsTable(r.authors, key)}`;
140
+ return `<div class="card"><h2>${onboarding ? `<span class="step ${ok ? "done" : ""}">${ok ? "âś“" : 4}</span>` : ""}${onboarding ? "Check it, edit it, accept it" : "Profile"}</h2>
141
+ <p class="sub">${editable ? "Edit the TOML on the left; the report re-checks as you type." : `This profile comes from <b>${esc(e.source?.label)}</b>. Customize it to make a local copy you can edit; yours then takes precedence.`}
142
+ <a href="https://github.com/spencrr/readthrough/blob/main/docs/profiles.md" target="_blank" rel="noopener">How to write a good one</a></p>
143
+ <div class="editor"><textarea class="toml" id="${key}-toml" spellcheck="false" ${editable ? "" : "readonly"}>${esc(e.toml)}</textarea><div class="report" id="${key}-report">${report}</div></div>
144
+ <div class="row">${editable ? `<button class="btn" data-act="save" data-key="${key}">Save draft</button>` : `<button class="btn primary" data-act="customize" data-key="${key}">Customize</button>`}
145
+ <button class="btn" data-act="preview" data-key="${key}" ${e.previewing ? "disabled" : ""}>${icon("external-link", "ico sm")}Preview the map</button>
146
+ ${onboarding ? `<button class="btn primary" data-act="accept" data-key="${key}" ${r?.valid ? "" : "disabled"} title="${ok ? "Finish onboarding and start the dashboard" : "Fix the items in the report first, or tick accept anyway"}">Accept and start</button>
147
+ ${r?.valid && r.problems.length ? `<label style="font-size:13px"><input type="checkbox" id="${key}-force"> accept anyway</label>` : ""}` : ""}
148
+ <button class="btn" data-act="upstream" data-key="${key}" title="Open the forge's new-file page for readthrough.toml so the maintainers can own this map">${icon("git-pull-request", "ico sm")}Propose upstream</button>
149
+ ${e.previewing ? '<span class="spin"></span>' : ""}</div></div>`;
150
+ }
151
+ function authorsTable(rows, key){
152
+ if (!rows.length) return '<p class="sub">No recent authors.</p>';
153
+ const repo = currentRepoView(), int = new Set(repo?.internal_authors || []), ext = new Set(repo?.external_authors || []);
154
+ const can = !!repo?.slug && S.state.repos.some(x => x.slug === repo.slug);
155
+ const sorted = [...rows].sort((a, b) => b[3] - a[3]);
156
+ const row = ([login, assoc, kind, n]) => {
157
+ const forced = int.has(login) ? "internal" : ext.has(login) ? "external" : "";
158
+ return `<tr><td title="${esc(assoc.toLowerCase())}, ${n} PR${n > 1 ? "s" : ""}">@${esc(login)} <span class="sub">${n}</span></td><td class="k-${esc(kind)}">${esc(KIND_LABEL[kind] || kind)}</td>
159
+ <td>${can ? `<select data-override="${esc(login)}" aria-label="Override for ${esc(login)}" title="Your own override, kept in config.toml">${["", "internal", "external"].map(v => `<option value="${v}" ${forced === v ? "selected" : ""}>${v || "auto"}</option>`).join("")}</select>` : ""}</td></tr>`; };
160
+ const counts = rows.reduce((m, r) => (m[r[2]] = (m[r[2]] || 0) + 1, m), {});
161
+ return `<p class="sub" style="margin:0 0 4px">${Object.entries(counts).map(([k, n]) => `<span class="k-${esc(k)}">${n} ${esc(KIND_LABEL[k] || k)}</span>`).join(" · ")}. Override anyone who's classified wrong.</p>
162
+ <table class="authors"><tbody>${sorted.slice(0, 12).map(row).join("")}</tbody></table>
163
+ ${sorted.length > 12 ? `<details><summary class="sub">${sorted.length - 12} more</summary><table class="authors"><tbody>${sorted.slice(12).map(row).join("")}</tbody></table></details>` : ""}`;
164
+ }
165
+ const currentRepoView = () => { const want = S.sel || S.w?.info?.slug || ""; return S.state.repos.find(r => same(want, r.slug) || same(want, r.name)); };
166
+ const editorState = key => key === "w" ? S.w : S.e;
167
+ let checkTimer = null;
168
+ function scheduleCheck(key){
169
+ clearTimeout(checkTimer);
170
+ checkTimer = setTimeout(async () => {
171
+ const e = editorState(key), repo = key === "w" ? e.info?.slug : S.sel;
172
+ if (!repo) return;
173
+ try { e.report = await api("/api/setup/check", {repo, toml: e.toml}); }
174
+ catch (err) { e.report = {valid: false, error: err.message}; }
175
+ const box = $(`${key}-report`);
176
+ if (box) { const html = editorCard(e, key, {onboarding: key === "w", editable: e.editable}); const tmp = document.createElement("div"); tmp.innerHTML = html; box.innerHTML = tmp.querySelector(".report").innerHTML; refreshButtons(key, tmp); }
177
+ }, 700);
178
+ }
179
+ function refreshButtons(key, tmp){
180
+ const row = $(`${key}-toml`)?.closest(".card")?.querySelector(".row:last-child"), fresh = tmp.querySelector(".row:last-child");
181
+ if (row && fresh) row.innerHTML = fresh.innerHTML;
182
+ const step = $(`${key}-toml`)?.closest(".card")?.querySelector("h2 .step"), freshStep = tmp.querySelector("h2 .step");
183
+ if (step && freshStep) step.outerHTML = freshStep.outerHTML;
184
+ }
185
+
186
+ // ---- settings for an onboarded repo
187
+ function renderSettings(repo){
188
+ const e = S.e && S.e.slug === repo.slug ? S.e : (S.e = {slug: repo.slug, toml: repo.profile_text, source: repo.source, editable: repo.editable, report: null, branch: null});
189
+ const accounts = S.state.accounts, forge = forgeOf(repo.forge);
190
+ $("main").innerHTML = `
191
+ <div class="card"><h2>${icon("git-pull-request")}${esc(repo.name)}${forgeTag(repo)} <span class="sub" style="margin:0;font-weight:400">onboarded ${new Date(repo.onboarded).toLocaleDateString()}</span>
192
+ <span style="flex:1"></span><a class="btn" href="/r/${esc(encodeURI(repo.slug))}/">${icon("map", "ico sm")}Open dashboard</a></h2></div>
193
+ <div class="card"><h2>${icon("terminal")}Where it comes from</h2>
194
+ <p class="sub access"><b>${esc(forge.label)}</b> is read through ${esc(forge.access || "its API")}${forge.credentials?.length ? `, as ${forge.credentials.map(c => `<span class="cred">${esc(c)}</span>`).join(" ")}` : ""}.${repo.auth ? ` Right now: <code>${esc(repo.auth)}</code>.` : ""}</p>
195
+ <div class="row">${forge.accounts ? `<label class="f">gh account<select id="s-account"><option value="">gh's active account</option>${accounts.map(a => `<option ${repo.account === a ? "selected" : ""}>${esc(a)}</option>`).join("")}</select></label>` : `<label class="f">Forge<input type="text" value="${esc(forge.label)}" readonly style="min-width:120px"></label>`}
196
+ <label class="f">Local clone<input type="text" class="wide" id="s-clone" value="${esc(repo.clone)}" spellcheck="false"></label>
197
+ <label class="f">Remote<input type="text" id="s-remote" value="${esc(repo.remote || "")}" placeholder="detected" style="min-width:120px"></label></div>
198
+ <div class="row"><button class="btn primary" data-act="save-source">Save</button><span class="sub" style="margin:0">Data lives in <code>${esc(repo.data_dir)}</code></span></div>
199
+ ${S.msgSource ? `<div class="msg ${S.msgSource.ok ? "ok" : "err"}">${esc(S.msgSource.text)}</div>` : ""}</div>
200
+ <div class="card"><h2>${icon("list-checks")}Reviewing</h2>
201
+ <div class="row"><label class="f">Session length (minutes)<input type="number" id="s-minutes" min="10" max="480" value="${repo.session_minutes}" style="width:110px"></label>
202
+ <label class="f">Most PRs to fetch<input type="number" id="s-limit" min="1" max="500" value="${repo.limit}" style="width:110px"></label>
203
+ <label class="f">Study model<input type="text" id="s-model" value="${esc(repo.study_model || "")}" placeholder="the runtime's default" style="min-width:200px"></label></div>
204
+ <div class="row"><button class="btn primary" data-act="save-review">Save</button></div>
205
+ ${S.msgReview ? `<div class="msg ${S.msgReview.ok ? "ok" : "err"}">${esc(S.msgReview.text)}</div>` : ""}</div>
206
+ ${editorCard(e, "e", {editable: e.editable})}
207
+ <div class="card"><h2>${icon("info")}Set from the command line only</h2>
208
+ <p class="sub">These change what the server launches or reads, so the browser can't edit them.</p>
209
+ <dl class="ro"><dt>agent_args</dt><dd><code>${esc(JSON.stringify(repo.agent_args))}</code></dd>
210
+ <dt>profile override</dt><dd>${repo.profile_override ? `<code>${esc(repo.profile_override)}</code>` : '<span class="sub">none</span>'}</dd></dl>
211
+ <div class="cli">Edit them with <code>readthrough config --edit</code>.</div></div>
212
+ <div class="card"><h2 style="color:var(--bad)">${icon("x")}Stop tracking</h2>
213
+ <p class="sub">Removes it from the config and stops serving it. Its data (ledger, study logs, worktrees) stays unless you also delete it.</p>
214
+ <div class="row"><label style="font-size:13px"><input type="checkbox" id="s-purge"> also delete its data and worktrees</label><button class="btn danger" data-act="remove">Remove ${esc(repo.name)}</button></div>
215
+ <div class="cli">Same as <code>readthrough remove ${esc(repo.cli_name)}</code> (add <code>--purge</code> to delete the data)</div></div>`;
216
+ if (!e.report) scheduleCheck("e");
217
+ }
218
+
219
+ // ---- actions
220
+ const val = id => $(id)?.value.trim() ?? "";
221
+ async function act(t){
222
+ const a = t.dataset.act, key = t.dataset.key, e = key ? editorState(key) : null;
223
+ const repoOf = () => key === "w" ? S.w.info?.slug : S.sel;
224
+ try {
225
+ if (a === "inspect") {
226
+ const w = S.w; w.repo = val("w-repo"); w.forge = val("w-forge") || w.forge; w.account = val("w-account"); w.err1 = null;
227
+ t.disabled = true;
228
+ w.info = await api("/api/setup/inspect", {repo: w.repo, forge: w.forge, account: w.account || null});
229
+ w.repo = w.info.full_name; w.clone ||= w.info.clone; w.source = w.info.source; w.toml = w.info.profile_text || ""; w.editable = true;
230
+ if (w.info.onboarded) { location.search = `?repo=${encodeURIComponent(w.info.slug)}`; return; }
231
+ if (w.clone) await act({dataset: {act: "clone"}});
232
+ if (w.toml) scheduleCheck("w");
233
+ return render();
234
+ }
235
+ if (a === "clone") {
236
+ const w = S.w; w.clone = val("w-clone") || w.clone; w.err2 = null;
237
+ try { w.cloneInfo = await api("/api/setup/clone", {repo: w.info.slug, clone: w.clone}); w.remote = w.cloneInfo.detected || ""; }
238
+ catch (err) { w.cloneInfo = null; w.err2 = err.message; }
239
+ return render();
240
+ }
241
+ if (a === "draft") {
242
+ const w = S.w; w.busy = true; w.err3 = null; w.log = []; w.remote = val("w-remote") || w.remote;
243
+ render();
244
+ const {job} = await api("/api/setup/draft", {repo: w.info.slug, account: w.account || null, clone: w.cloneInfo?.ok ? w.clone : null, remote: w.cloneInfo?.ok ? w.remote : null, mode: t.dataset.mode});
245
+ try {
246
+ const res = await poll(job, log => { if (log.length !== w.log.length) { w.log = log; const box = $("w-log"); if (box) { box.innerHTML = log.map(l => `<div>${esc(l)}</div>`).join(""); box.scrollTop = box.scrollHeight; } else render(); } });
247
+ w.toml = res.toml; w.report = res.report; w.editable = true;
248
+ S.state = await api(`/api/setup/state?repo=${encodeURIComponent(w.info.slug)}`);
249
+ } catch (err) { w.err3 = err.message; }
250
+ w.busy = false; return render();
251
+ }
252
+ if (a === "add-comp") {
253
+ const p = t.dataset.path, layer = (e.report.layers.find(l => l.source) || e.report.layers[0]).id;
254
+ const glob = /\.[A-Za-z0-9]+$/.test(p.split("/").pop()) ? p : `${p}/**`;
255
+ e.toml = e.toml.replace(/\s*$/, "\n") + `\n[[components]]\nid = "${slug(p)}"\nlabel = "${label(p)}"\nlayer = "${layer}"\npaths = ["${glob}"]\n# responsibility = "What this component is for."\n`;
256
+ $(`${key}-toml`).value = e.toml; scheduleCheck(key); return toast(`Added a component for ${p}. Move it into place and name it.`);
257
+ }
258
+ if (a === "save") {
259
+ await api("/api/setup/save", {repo: repoOf(), toml: e.toml});
260
+ return toast("Saved to your local profile");
261
+ }
262
+ if (a === "customize") { e.editable = true; return render(); }
263
+ if (a === "preview") {
264
+ e.previewing = true; render();
265
+ const win = window.open("about:blank", "_blank");
266
+ try { const {job} = await api("/api/setup/preview", {repo: repoOf(), toml: e.toml}); const res = await poll(job, () => {}); if (win) win.location = res.url; else location.href = res.url; }
267
+ catch (err) { if (win) win.close(); toast(err.message); }
268
+ e.previewing = false; return render();
269
+ }
270
+ if (a === "accept") {
271
+ t.disabled = true;
272
+ const res = await api("/api/setup/accept", {repo: repoOf(), toml: e.toml, force: !!$(`${key}-force`)?.checked});
273
+ toast("Onboarded. Building the dashboard…"); setTimeout(() => location.href = res.url, 900); return;
274
+ }
275
+ if (a === "upstream") {
276
+ const info = S.w?.info || await api("/api/setup/inspect", {repo: repoOf(), account: currentRepoView()?.account || null});
277
+ const base = info.propose_url;
278
+ if (!base) { await navigator.clipboard.writeText(e.toml); return toast(`Profile copied: add it to the repo as ${info.profile_path}`); }
279
+ const full = `${base}&value=${encodeURIComponent(e.toml)}`;
280
+ if (full.length < 7000) window.open(full, "_blank", "noopener");
281
+ else { await navigator.clipboard.writeText(e.toml); window.open(base, "_blank", "noopener"); toast(`Profile copied: paste it into the new file on ${info.forge_label}`); }
282
+ return;
283
+ }
284
+ if (a === "save-source" || a === "save-review") {
285
+ const values = a === "save-source" ? {account: val("s-account") || null, clone: val("s-clone") || null, remote: val("s-remote") || null}
286
+ : {session_minutes: val("s-minutes"), limit: val("s-limit"), study_model: val("s-model") || null};
287
+ const msgKey = a === "save-source" ? "msgSource" : "msgReview";
288
+ try { await api("/api/setup/settings", {repo: S.sel, values, version: S.state.settings.version}); S[msgKey] = {ok: true, text: "Saved. The dashboard picks it up within a few seconds."}; }
289
+ catch (err) { S[msgKey] = {ok: false, text: err.message}; }
290
+ S.state = await api(`/api/setup/state?repo=${encodeURIComponent(S.sel)}`); return render();
291
+ }
292
+ if (a === "save-global") {
293
+ await api("/api/setup/settings", {global: {default_repo: val("g-default"), refresh_minutes: val("g-refresh")}, version: S.state.settings.version});
294
+ toast("Saved"); return load();
295
+ }
296
+ if (a === "remove") {
297
+ const purge = $("s-purge").checked;
298
+ if (!confirm(`Stop tracking ${S.sel}${purge ? " and delete its data and worktrees" : ""}?`)) return;
299
+ await api("/api/setup/remove", {repo: S.sel, purge, version: S.state.settings.version});
300
+ location.search = ""; return;
301
+ }
302
+ } catch (err) {
303
+ toast(err.message);
304
+ if (a === "inspect") { S.w.err1 = err.message; S.w.info = null; render(); }
305
+ } finally { if (t.disabled !== undefined && a !== "accept") t.disabled = false; }
306
+ }
307
+ async function setOverride(login, kind){
308
+ const repo = currentRepoView(); if (!repo) return;
309
+ const int = new Set(repo.internal_authors), ext = new Set(repo.external_authors);
310
+ int.delete(login); ext.delete(login);
311
+ if (kind === "internal") int.add(login); if (kind === "external") ext.add(login);
312
+ try {
313
+ await api("/api/setup/settings", {repo: repo.slug, values: {internal_authors: [...int], external_authors: [...ext]}, version: S.state.settings.version});
314
+ S.state = await api(`/api/setup/state${S.sel ? `?repo=${encodeURIComponent(S.sel)}` : ""}`);
315
+ toast(`@${login} is ${kind || "classified automatically"} now`);
316
+ const key = S.sel && S.state.repo?.onboarded ? "e" : "w"; scheduleCheck(key);
317
+ } catch (err) { toast(err.message); }
318
+ }
319
+
320
+ document.addEventListener("click", ev => {
321
+ const t = ev.target.closest("[data-act],[data-repo],[data-new]");
322
+ if (!t) return;
323
+ if (t.dataset.repo) { history.pushState(null, "", `?repo=${encodeURIComponent(t.dataset.repo)}`); S.sel = t.dataset.repo; S.w = null; S.e = null; S.msgSource = S.msgReview = null; return load(); }
324
+ if (t.hasAttribute("data-new")) { history.pushState(null, "", location.pathname); S.sel = null; S.w = null; return load(); }
325
+ act(t);
326
+ });
327
+ document.addEventListener("input", ev => {
328
+ const id = ev.target.id;
329
+ if (id === "w-toml" || id === "e-toml") { const key = id[0]; editorState(key).toml = ev.target.value; scheduleCheck(key); }
330
+ if (id === "w-repo") { S.w.repo = ev.target.value; }
331
+ if (id === "w-clone") { S.w.clone = ev.target.value; }
332
+ });
333
+ document.addEventListener("toggle", ev => { if (ev.target.id === "w-access" && S.w) S.w.accessOpen = ev.target.open; }, true);
334
+ document.addEventListener("change", ev => {
335
+ if (ev.target.dataset.override !== undefined) return setOverride(ev.target.dataset.override, ev.target.value);
336
+ if (ev.target.id === "w-account") S.w.account = ev.target.value;
337
+ if (ev.target.id === "w-forge") { S.w.forge = ev.target.value; S.w.account = ""; S.w.info = null; S.w.err1 = null; render(); }
338
+ if (ev.target.id === "w-remote") S.w.remote = ev.target.value;
339
+ });
340
+ document.addEventListener("keydown", ev => { if (ev.key === "Enter" && ev.target.id === "w-repo") act({dataset: {act: "inspect"}, disabled: false}); });
341
+ addEventListener("popstate", () => { S.sel = new URLSearchParams(location.search).get("repo"); S.w = S.e = null; load(); });
342
+ load().catch(err => { $("main").innerHTML = `<div class="msg err">${esc(err.message)}</div>`; });
@@ -0,0 +1,36 @@
1
+ /* Shared by every page: color tokens, base elements, icons. Page CSS adds its own tokens and rules. */
2
+ :root,[data-theme=light]{--bg:#ffffff;--subtle:#f6f8fa;--panel:#ffffff;--inset:#f6f8fa;--line:#d1d9e0;--line-strong:#afb8c1;--fg:#1f2328;--mut:#59636e;--acc:#0969da;--acc-fg:#ffffff;--acc-soft:#ddf4ff;--good:#1a7f37;--warn:#9a6700;--bad:#d1242f;--external:#bc4c00;--glass-bg:rgba(255,255,255,.72);--glass-line:rgba(31,35,40,.12);--shadow:0 1px 3px rgba(31,35,40,.12)}
3
+ [data-theme=dark]{--bg:#22272e;--subtle:#2d333b;--panel:#2d333b;--inset:#1c2128;--line:#444c56;--line-strong:#545d68;--fg:#cdd9e5;--mut:#909dab;--acc:#539bf5;--acc-fg:#1c2128;--acc-soft:#2b3b52;--good:#57ab5a;--warn:#c69026;--bad:#e5534b;--external:#e0823d;--glass-bg:rgba(34,39,46,.72);--glass-line:rgba(205,217,229,.12);--shadow:none}
4
+ *{box-sizing:border-box}
5
+ body{margin:0;font:14px/1.5 -apple-system,"Segoe UI",system-ui,sans-serif;background:var(--bg);color:var(--fg)}
6
+ a{color:var(--acc);text-decoration:none}a:hover{text-decoration:underline}
7
+ code,.mono{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12.5px}
8
+ .ico{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:-3px;flex:none}
9
+ .ico.sm{width:13px;height:13px;vertical-align:-2px;margin-right:4px}
10
+ /* The header both pages share: the product first, then where you are, then the small print. */
11
+ header{position:sticky;top:0;z-index:5;background:var(--glass-bg);-webkit-backdrop-filter:saturate(1.6) blur(16px);backdrop-filter:saturate(1.6) blur(16px);border-bottom:1px solid var(--glass-line);padding:10px 20px}
12
+ h1{font-size:15px;margin:0;font-weight:400;flex:1;min-width:0;display:flex;align-items:center;gap:8px;white-space:nowrap;line-height:26px}
13
+ .logo{width:26px;height:26px;flex:none;color:var(--acc)}
14
+ .brand{font-weight:650;letter-spacing:-.01em;color:var(--fg)}
15
+ .crumb{display:inline-flex;align-items:center;gap:8px;min-width:0}
16
+ .crumb-sep{color:var(--line-strong);font-weight:300;font-size:17px;position:relative;top:-1px}
17
+ h1 small{color:var(--mut);font-size:12.5px;overflow:hidden;text-overflow:ellipsis;min-width:0;margin-left:4px}
18
+ /* The repo switcher: a quiet pill that opens the native select laid invisibly over it, so it's keyboard-reachable. */
19
+ .switch{position:relative;display:inline-flex;align-items:center;gap:5px;padding:0 8px;height:26px;border-radius:7px;font-weight:500;color:var(--fg);max-width:40vw}
20
+ .switch:not(.static){cursor:pointer}.switch:not(.static):hover{background:var(--glass-well)}
21
+ .switch .ico.sm{margin:0;color:var(--mut)}.switch-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
22
+ .switch select{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;margin:0}
23
+ .switch:has(select:focus-visible){outline:2px solid var(--acc);outline-offset:1px}
24
+ .hactions{display:flex;gap:8px;align-items:center;flex:none}
25
+ /* The live chip is a status, not a button. Live and refreshing pulse; warnings stay still. */
26
+ .live-status{display:inline-flex;align-items:center;gap:7px;height:26px;padding:0 10px 0 9px;border-radius:999px;font-size:12px;font-weight:500;color:var(--good);border:1px solid color-mix(in srgb,var(--good) 35%,transparent);background:color-mix(in srgb,var(--good) 9%,transparent);cursor:default;white-space:nowrap}
27
+ .live-status.busy{color:var(--acc);border-color:color-mix(in srgb,var(--acc) 35%,transparent);background:color-mix(in srgb,var(--acc) 9%,transparent)}
28
+ .live-status.off{color:var(--mut);border-color:var(--line);background:var(--subtle)}
29
+ .live-status.err{color:var(--bad);border-color:color-mix(in srgb,var(--bad) 35%,transparent);background:color-mix(in srgb,var(--bad) 8%,transparent)}
30
+ .live-status.stale{color:var(--warn);border-color:color-mix(in srgb,var(--warn) 35%,transparent);background:color-mix(in srgb,var(--warn) 8%,transparent)}
31
+ .ping{position:relative;width:7px;height:7px;border-radius:50%;background:currentColor;flex:none}
32
+ .live-status:not(.off):not(.err):not(.stale) .ping::after{content:"";position:absolute;inset:0;border-radius:50%;border:1.5px solid currentColor;animation:ping 2.4s ease-out infinite}
33
+ @keyframes ping{0%{transform:scale(1);opacity:.9}70%,100%{transform:scale(2.6);opacity:0}}
34
+ @keyframes spin{to{transform:rotate(360deg)}}
35
+ .btn.icon.busy .ico{animation:spin 1s linear infinite}
36
+ @media (prefers-reduced-motion: reduce){.live-status .ping::after,.btn.icon.busy .ico{animation:none}}