repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

Iteration 17: Fixed center-images.lua LaTeX corruption bug. The prior Image/Plain approach double-wrapped images inside Figure, producing malformed minipage/center LaTeX. Rewrote filter to return explicit filter tables, use topdown traversal, skip Figure children for LaTeX/Beamer, center only image-only paragraphs, and leave inline images unchanged. Verified clean LaTeX figures, centered no-alt image paragraphs, unchanged inline images, HTML styling, and 9/9 filters pass.

e5d7f73a27a32ab9c0a794ba2fb94554b4bcaba8

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Result: {"status":"keep","skill_quality":36}

Changed files (5)

.pi/autoresearch/session.jsonl

Modified
4 4 {"run":10,"commit":"4d2e499","metric":29,"metrics":{},"status":"keep","description":"Iteration 10: Added Programmatic Lua API subsection under Lua Filters covering pandoc.read/write, building Pandoc docs from scratch, file→transform→write pipelines, format conversion in Lua, and metadata access. Verified all programmatic examples with pandoc lua. Fixed expected HTML output for manual Header (no auto id). 9/9 filters pass.","timestamp":1780157777826,"segment":0,"confidence":null,"asi":{"hypothesis":"Add programmatic Lua API coverage for agents that need document processing in code, not shell; fix example accuracy against actual pandoc output","new_coverage":"pandoc.read, pandoc.write, build AST from scratch, doc:walk transform, file read/write, metadata access","examples_verified":"4 programmatic examples passed via pandoc lua","accuracy_fix":"manual Header output has no id unless attr set; corrected expected output","filters":"9/9 pass"}}
5 5 {"run":11,"commit":"df7626a","metric":30,"metrics":{},"status":"keep","description":"Iteration 11: Added pandoc-doctor.lua cross-platform diagnostics script and Decision Guide entry. Doctor reports pandoc/API version, OS/arch, reader/writer counts, key format support, common PDF engine availability, executable version, and markdown→html smoke test. Verified output, SKILL.md references, section refs, and 9/9 filters. Scripts: 6.","timestamp":1780157854132,"segment":0,"confidence":null,"asi":{"hypothesis":"Add environment diagnostics for agents debugging PDF engine/format/support failures; reduces troubleshooting friction without bloating main docs","doctor_checks":"version, API, OS/arch, readers/writers, important formats, PDF engines, executable, smoke test","validation":"doctor runs, key diagnostics present, no missing Decision Guide refs, 9/9 filters pass","scripts":6}}
6 6 {"run":12,"commit":"941acac","metric":31,"metrics":{},"status":"keep","description":"Iteration 12: Hardened wrapper scripts by replacing os.execute/string command construction with pandoc.pipe argv-list calls in batch-convert, md-to-pdf, web-to-md, and docx-to-md. Fixed batch pattern bug and changed web-to-md to preserve H1 instead of silently shifting it into metadata. Verified filenames with spaces, docx→md with spaces, web H1 preservation, 0 os.execute in scripts, 9/9 filters pass.","timestamp":1780157980678,"segment":0,"confidence":null,"asi":{"hypothesis":"Security/portability hardening: scripts were cross-platform but used shell command strings; argv-list pandoc.pipe avoids shell quoting bugs and handles spaces safely","fixed_bugs":"batch pattern invalid escape; web-to-md dropped H1 due shift-heading-level-by=-1","validation":"space-containing filenames convert; docx with spaces extracts; web H1 preserved; 0 os.execute; 9/9 filters","scripts_hardened":4}}
7 7 {"run":13,"commit":"9be664e","metric":32,"metrics":{},"status":"keep","description":"Iteration 13: Corrected diagram-filter.lua accuracy: removed misleading PlantUML support, made it explicitly Graphviz dot/graphviz only, fixed MIME types for PDF outputs (application/pdf), removed unused generate_image function, and improved graceful fallback diagnostic if dot is missing. Updated SKILL.md wording. Verified PlantUML blocks are ignored, dot blocks either generate or fall back unchanged, no PlantUML claims remain, 9/9 filters pass.","timestamp":1780158049033,"segment":0,"confidence":null,"asi":{"hypothesis":"Accuracy over breadth: misleading filter claims are harmful; make diagram-filter precise and robust rather than pretending to support PlantUML","fixed":"PlantUML claim removed, PDF mime fixed, unused function removed, missing-dot fallback clearer","validation":"plantuml ignored, dot fallback works without graphviz, skill wording accurate, 9/9 filters pass"}}
8 8 {"run":14,"commit":"f3839c9","metric":33,"metrics":{},"status":"keep","description":"Iteration 14: Fixed admonitions.lua quality/portability bug. Previous HTML path stringified content and lost formatting; LaTeX path crashed by returning nested block list and required undeclared tcolorbox. New filter preserves inner Markdown via pandoc.write for HTML and uses portable [NOTE]/[WARNING] labels for non-HTML. Verified HTML preserves bold/link/list, LaTeX/Markdown do not crash, and 9/9 filters pass.","timestamp":1780158116622,"segment":0,"confidence":null,"asi":{"hypothesis":"Fix broken/low-quality existing filter instead of adding content; admonitions are common and must preserve formatting across outputs","bugs_fixed":"HTML lost formatting; LaTeX crashed; tcolorbox dependency removed","validation":"HTML bold/list preserved, LaTeX and Markdown output stable, 9/9 filters pass","format_support":"styled HTML, portable fallback for other writers"}}
9 9 {"run":15,"commit":"44eb971","metric":34,"metrics":{},"status":"keep","description":"Iteration 15: Improved autolink.lua URL boundary handling. Previous filter included trailing prose punctuation in hrefs (e.g. https://example.com. linked with the period). Added trailing punctuation splitting for . , ; : ! ? ) ]. Verified period/comma/paren/question punctuation stay outside links, multiple URLs still work, 9/9 filters pass.","timestamp":1780158167127,"segment":0,"confidence":null,"asi":{"hypothesis":"Fix subtle but common URL autolinking bug; generated hrefs must not include sentence punctuation","bug_fixed":"trailing punctuation included in link target","validation":"period/comma/paren/question stripped; multiple URLs OK; 9/9 filters pass","changed_file":"references/filters/autolink.lua"}}
10 +{"run":16,"commit":"bf8645a","metric":35,"metrics":{},"status":"keep","description":"Iteration 16: Fixed extract-headings.lua to emit a real nested BulletList AST instead of escaped literal Markdown paragraphs. The filter now preserves heading hierarchy, creates actual internal links, handles skipped heading levels, and returns empty output for documents without headings. Verified Markdown list output, HTML nested ul/li output, link hrefs, and 9/9 filters pass.","timestamp":1780158253729,"segment":0,"confidence":null,"asi":{"hypothesis":"Fix existing filter correctness: escaped Markdown output is misleading; agents need real outline links/lists","bug_fixed":"extract-headings produced literal escaped '- [Heading](#id)' paragraphs instead of list/link AST","validation":"nested markdown list, HTML ul/li, internal hrefs, skipped levels, no-heading input, 9/9 filters","changed_file":"references/filters/extract-headings.lua"}}

extensions/autoresearch/assets/template.html

Modified
4 4 <!doctype html>
5 5 <html lang="en">
6 6 <head>
7 7 <meta charset="utf-8">
8 8 <meta name="viewport" content="width=device-width, initial-scale=1">
9 9 <title>__AUTORESEARCH_TITLE__</title>
10 + <script>
11 + (() => {
12 + const mode = localStorage.getItem("diff-review-theme") || "system";
13 + const systemLight = matchMedia("(prefers-color-scheme: light)").matches;
14 + document.documentElement.dataset.themeMode = mode;
15 + document.documentElement.dataset.theme = mode === "system" ? (systemLight ? "light" : "dark") : mode;
16 + })();
17 + </script>
10 18 <style>
11 - :root { color-scheme: dark; --bg:#0d1117; --panel:#161b22; --text:#c9d1d9; --muted:#8b949e; --line:#30363d; --good:#3fb950; --bad:#f85149; --warn:#d29922; --accent:#58a6ff; }
19 + :root {
20 + color-scheme: dark light;
22 + /* Nugu dark palette — shared with diff-review */
23 + --nugu-debug: #ed5eed;
24 + --nugu-error: #e46479;
25 + --nugu-warning: #9e9a69;
26 + --nugu-info: #3ec5dd;
27 + --nugu-content-normal: #ededed;
28 + --nugu-content-backdrop: #121212;
29 + --nugu-content-accent: #d151d1;
30 + --nugu-content-minor: #8b8b8b;
31 + --nugu-content-focus: #7ba1aa;
32 + --nugu-content-unfocus: #5d5d5d;
33 + --nugu-content-important-local: #b59ae4;
34 + --nugu-content-important-global: #dfd3f3;
35 + --nugu-ui-normal: #dbdbdb;
36 + --nugu-ui-backdrop: #242424;
37 + --nugu-ui-accent: #d86dd8;
38 + --nugu-ui-minor: #9d9d9d;
39 + --nugu-ui-focus: #9aabae;
40 + --nugu-ui-unfocus: #6f6f6f;
41 + --nugu-ui-important-local: #c9b6eb;
42 + --nugu-ui-important-global: #f3effb;
44 + --bg: var(--nugu-content-backdrop);
45 + --panel: color-mix(in srgb, var(--nugu-ui-backdrop) 86%, var(--nugu-content-backdrop));
46 + --panel-2: var(--nugu-ui-backdrop);
47 + --panel-3: color-mix(in srgb, var(--nugu-ui-backdrop) 72%, var(--nugu-content-backdrop));
48 + --fg: var(--nugu-content-normal);
49 + --fg-soft: var(--nugu-ui-normal);
50 + --muted: var(--nugu-ui-minor);
51 + --faint: var(--nugu-ui-unfocus);
52 + --accent: var(--nugu-ui-accent);
53 + --accent-2: var(--nugu-info);
54 + --focus: var(--nugu-ui-focus);
55 + --border: color-mix(in srgb, var(--nugu-ui-normal) 14%, transparent);
56 + --shadow: 0 18px 60px color-mix(in srgb, #000 45%, transparent);
57 + --radius: 12px;
58 + font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
59 + background: var(--bg);
60 + color: var(--fg);
61 + }
63 + :root[data-theme="light"] {
64 + color-scheme: light;
65 + --nugu-debug: #a112a1;
66 + --nugu-error: #c0223c;
67 + --nugu-warning: #242317;
68 + --nugu-info: #13616e;
69 + --nugu-content-normal: #121212;
70 + --nugu-content-backdrop: #ededed;
71 + --nugu-content-accent: #ae2eae;
72 + --nugu-content-minor: #3b3b3b;
73 + --nugu-content-focus: #184e5b;
74 + --nugu-content-unfocus: #6f6f6f;
75 + --nugu-content-important-local: #715696;
76 + --nugu-content-important-global: #4f3c69;
77 + --nugu-ui-normal: #242424;
78 + --nugu-ui-backdrop: #dbdbdb;
79 + --nugu-ui-accent: #922792;
80 + --nugu-ui-minor: #292929;
81 + --nugu-ui-focus: #15333b;
82 + --nugu-ui-unfocus: #5d5d5d;
83 + --nugu-ui-important-local: #604980;
84 + --nugu-ui-important-global: #3e2f53;
85 + --panel: color-mix(in srgb, var(--nugu-ui-backdrop) 72%, white);
86 + --panel-2: color-mix(in srgb, var(--nugu-ui-backdrop) 88%, white);
87 + --panel-3: color-mix(in srgb, var(--nugu-ui-backdrop) 55%, white);
88 + --border: color-mix(in srgb, var(--nugu-ui-normal) 16%, transparent);
89 + --shadow: 0 18px 60px color-mix(in srgb, #000 14%, transparent);
90 + }
12 92 * { box-sizing: border-box; }
13 - body { margin:0; background:var(--bg); color:var(--text); font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; }
14 - main { max-width:1180px; margin:0 auto; padding:24px; }
15 - header { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:16px; }
16 - h1 { margin:0; color:#fff; font-size:26px; }
17 - .meta { margin-top:6px; color:var(--muted); font-size:13px; }
18 - .grid { display:grid; grid-template-columns:2fr 1.2fr .8fr .8fr; gap:12px; margin:16px 0; }
19 - .card, .panel { background:var(--panel); border:1px solid var(--line); border-radius:12px; }
20 - .card { padding:14px; }
21 - .label { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.07em; }
22 - .value { margin-top:7px; font:700 24px ui-monospace,SFMono-Regular,Menlo,monospace; }
23 - .good { color:var(--good); } .bad { color:var(--bad); } .warn { color:var(--warn); } .muted { color:var(--muted); }
24 - .panel { overflow:hidden; margin-top:14px; }
25 - .chart-wrap { height:300px; padding:12px; }
26 - canvas { width:100%; height:100%; display:block; }
27 - table { width:100%; border-collapse:collapse; font-size:12px; }
28 - th, td { padding:10px; border-bottom:1px solid #222a33; text-align:left; vertical-align:top; }
29 - th { position:sticky; top:0; background:#11161c; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.05em; white-space:nowrap; }
30 - .mono { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
31 - .status { display:inline-block; padding:2px 7px; border-radius:999px; font-weight:700; font-size:11px; }
32 - .status.keep { color:var(--good); background:rgba(63,185,80,.15); }
33 - .status.discard { color:#ff9b95; background:rgba(248,81,73,.14); }
34 - .status.crash { color:var(--bad); background:rgba(248,81,73,.22); }
35 - .status.checks_failed { color:var(--warn); background:rgba(210,153,34,.18); }
36 - .best-row { background:rgba(63,185,80,.07); }
37 - .notice { padding:14px; color:var(--warn); }
38 - @media (max-width:850px) { .grid { grid-template-columns:1fr 1fr; } main { padding:14px; } }
93 + html, body { min-height: 100%; }
94 + body {
95 + margin: 0;
96 + background:
97 + radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 12%, transparent), transparent 28rem),
98 + var(--bg);
99 + color: var(--fg);
100 + font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
102 + button, select { font: inherit; }
103 + code, .mono, .value, table { font-family: "JetBrains Mono Nerd", "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
105 + #app {
106 + display: grid;
107 + grid-template-columns: minmax(0, 1fr) 360px;
108 + min-height: 100vh;
110 + #main { min-width: 0; }
111 + #topbar {
112 + display: flex;
113 + align-items: center;
114 + justify-content: space-between;
115 + gap: 14px;
116 + padding: 16px 18px 12px;
117 + border-bottom: 1px solid var(--border);
118 + background: color-mix(in srgb, var(--bg) 92%, var(--panel));
119 + position: sticky;
120 + top: 0;
121 + z-index: 3;
122 + backdrop-filter: blur(10px);
124 + .brand { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
125 + h1 { font-size: 22px; line-height: 1; margin: 0; letter-spacing: -0.03em; color: var(--nugu-content-important-global); }
126 + .subtitle {
127 + display: inline-flex;
128 + align-items: center;
129 + width: fit-content;
130 + margin-top: 7px;
131 + padding: 3px 8px;
132 + border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
133 + border-radius: 999px;
134 + background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent));
135 + color: color-mix(in srgb, var(--fg-soft) 72%, var(--muted));
136 + font-size: 12px;
137 + font-weight: 700;
139 + .theme-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
140 + .theme-label select {
141 + padding: 5px 8px;
142 + border: 1px solid var(--border);
143 + border-radius: 999px;
144 + background: color-mix(in srgb, var(--bg) 60%, var(--panel-2));
145 + color: var(--fg);
146 + outline: none;
148 + .theme-label select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
149 + #summary { color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 6px; }
151 + .content { padding: 16px 18px 24px; }
152 + .cards { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(160px, 1.3fr) minmax(110px, .7fr) minmax(110px, .7fr); gap: 12px; }
153 + .card, .panel, #drawer { border: 1px solid var(--border); background: color-mix(in srgb, var(--panel-3) 72%, transparent); border-radius: var(--radius); }
154 + .card { padding: 12px; min-width: 0; }
155 + .card-title { color: var(--nugu-content-important-global); font-weight: 800; font-size: 15px; margin-bottom: 8px; }
156 + .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; }
157 + .value { margin-top: 7px; color: var(--nugu-content-important-global); font-size: 24px; font-weight: 850; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
158 + .value.good { color: var(--nugu-info); }
159 + .value.bad { color: var(--nugu-error); }
160 + .panel { margin-top: 14px; overflow: hidden; }
161 + .chart-wrap { height: 320px; padding: 12px; background: color-mix(in srgb, var(--panel-2) 38%, transparent); }
162 + canvas { width: 100%; height: 100%; display: block; }
164 + #drawer {
165 + border-width: 0 0 0 1px;
166 + border-radius: 0;
167 + background: color-mix(in srgb, var(--panel) 95%, transparent);
168 + padding: 16px 14px;
169 + overflow-y: auto;
171 + .count-pill {
172 + display: inline-flex;
173 + align-items: center;
174 + justify-content: center;
175 + min-width: 24px;
176 + padding: 3px 9px;
177 + border-radius: 999px;
178 + border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
179 + background: color-mix(in srgb, var(--accent) 16%, transparent);
180 + color: var(--nugu-content-important-global);
181 + font-size: 12px;
182 + font-weight: 800;
184 + .stat-list { display: grid; gap: 8px; }
185 + .stat-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 62%, transparent); }
186 + .stat-row:last-child { border-bottom: 0; }
187 + .stat-row span:first-child { color: var(--muted); }
188 + .stat-row span:last-child { color: var(--fg); font-weight: 800; }
190 + table { width: 100%; border-collapse: collapse; font-size: 12px; }
191 + th, td { padding: 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 62%, transparent); text-align: left; vertical-align: top; }
192 + th { position: sticky; top: 63px; background: color-mix(in srgb, var(--bg) 92%, var(--panel)); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; z-index: 2; }
193 + td { color: color-mix(in srgb, var(--fg) 88%, var(--muted)); }
194 + .status { display: inline-block; padding: 2px 7px; border-radius: 999px; font-weight: 800; font-size: 11px; }
195 + .status.keep { color: var(--nugu-info); background: color-mix(in srgb, var(--nugu-info) 14%, transparent); border: 1px solid color-mix(in srgb, var(--nugu-info) 28%, var(--border)); }
196 + .status.discard { color: var(--nugu-warning); background: color-mix(in srgb, var(--nugu-warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--nugu-warning) 24%, var(--border)); }
197 + .status.crash, .status.checks_failed { color: var(--nugu-error); background: color-mix(in srgb, var(--nugu-error) 14%, transparent); border: 1px solid color-mix(in srgb, var(--nugu-error) 28%, var(--border)); }
198 + .best-row { background: color-mix(in srgb, var(--accent) 8%, transparent); }
199 + .good { color: var(--nugu-info); }
200 + .bad { color: var(--nugu-error); }
201 + .warn { color: var(--nugu-warning); }
202 + .muted { color: var(--muted); }
203 + .notice { padding: 14px; color: var(--nugu-warning); }
204 + #status {
205 + position: fixed;
206 + right: 16px;
207 + bottom: 14px;
208 + max-width: min(520px, calc(100vw - 32px));
209 + padding: 7px 10px;
210 + border: 1px solid var(--border);
211 + border-radius: 999px;
212 + background: color-mix(in srgb, var(--bg) 65%, var(--panel));
213 + box-shadow: var(--shadow);
214 + color: var(--muted);
215 + font-size: 12px;
216 + white-space: nowrap;
217 + overflow: hidden;
218 + text-overflow: ellipsis;
220 + #status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--muted); vertical-align: 1px; }
221 + #status.ok { color: var(--nugu-info); border-color: color-mix(in srgb, var(--nugu-info) 34%, var(--border)); }
222 + #status.ok::before { background: var(--nugu-info); box-shadow: 0 0 14px var(--nugu-info); }
223 + #status.error { color: var(--nugu-error); border-color: color-mix(in srgb, var(--nugu-error) 40%, var(--border)); }
224 + #status.error::before { background: var(--nugu-error); box-shadow: 0 0 14px var(--nugu-error); }
226 + @media (max-width: 980px) {
227 + #app { grid-template-columns: 1fr; }
228 + #drawer { border-width: 1px 0 0; }
229 + .cards { grid-template-columns: 1fr 1fr; }
230 + th { top: 0; }
232 + @media (max-width: 620px) {
233 + #topbar { align-items: flex-start; flex-direction: column; }
234 + .cards { grid-template-columns: 1fr; }
235 + .content { padding-inline: 12px; }
39 237 </style>
40 238 </head>
41 239 <body>
42 - <main>
43 - <header>
44 - <div>
45 - <h1 id="title">Autoresearch</h1>
46 - <div class="meta" id="meta">Loading session.jsonl…</div>
240 + <div id="app">
241 + <main id="main">
242 + <header id="topbar">
243 + <div class="brand">
244 + <div>
245 + <h1 id="title">Autoresearch</h1>
246 + <div class="subtitle">Pi × experiments</div>
247 + <div id="summary">Loading session.jsonl…</div>
248 + </div>
249 + </div>
250 + <label class="theme-label" aria-label="Theme mode">
251 + <span aria-hidden="true">◐</span>
252 + <select id="theme-mode" aria-label="Theme mode">
253 + <option value="system">system</option>
254 + <option value="dark">dark</option>
255 + <option value="light">light</option>
256 + </select>
257 + </label>
258 + </header>
260 + <div class="content">
261 + <section class="cards" aria-label="Experiment summary">
262 + <div class="card"><div class="label">Baseline → Best</div><div class="value" id="baseline-best">—</div></div>
263 + <div class="card"><div class="label">Improvement</div><div class="value good" id="improvement">—</div></div>
264 + <div class="card"><div class="label">Runs</div><div class="value" id="runs">0</div></div>
265 + <div class="card"><div class="label">Kept</div><div class="value" id="kept">0</div></div>
266 + </section>
268 + <section class="panel" aria-label="Metric chart"><div class="chart-wrap"><canvas id="chart"></canvas></div></section>
269 + <section class="panel" aria-label="Runs table">
270 + <table>
271 + <thead><tr><th>Run</th><th>Status</th><th id="metric-head">Metric</th><th>Δ baseline</th><th>Confidence</th><th>Commit</th><th>Description</th><th>Hypothesis</th><th>Next</th></tr></thead>
272 + <tbody id="rows"><tr><td colspan="9" class="notice">Waiting for runs…</td></tr></tbody>
273 + </table>
274 + </section>
47 275 </div>
48 - </header>
49 - <section class="grid">
50 - <div class="card"><div class="label">Baseline → Best</div><div class="value" id="baseline-best">—</div></div>
51 - <div class="card"><div class="label">Improvement</div><div class="value good" id="improvement">—</div></div>
52 - <div class="card"><div class="label">Runs</div><div class="value" id="runs">0</div></div>
53 - <div class="card"><div class="label">Kept</div><div class="value" id="kept">0</div></div>
54 - </section>
55 - <section class="panel"><div class="chart-wrap"><canvas id="chart"></canvas></div></section>
56 - <section class="panel">
57 - <table>
58 - <thead><tr><th>Run</th><th>Status</th><th id="metric-head">Metric</th><th>Δ baseline</th><th>Confidence</th><th>Commit</th><th>Description</th><th>Hypothesis</th><th>Next</th></tr></thead>
59 - <tbody id="rows"><tr><td colspan="9" class="notice">Waiting for runs…</td></tr></tbody>
60 - </table>
61 - </section>
62 - </main>
276 + </main>
278 + <aside id="drawer">
279 + <section class="card">
280 + <div class="card-title">Session</div>
281 + <div class="stat-list">
282 + <div class="stat-row"><span>metric</span><span id="side-metric">metric</span></div>
283 + <div class="stat-row"><span>direction</span><span id="side-direction">lower</span></div>
284 + <div class="stat-row"><span>baseline</span><span id="side-baseline">—</span></div>
285 + <div class="stat-row"><span>best run</span><span id="side-best-run">—</span></div>
286 + </div>
287 + </section>
288 + <section class="card">
289 + <div class="card-title">Outcomes <span class="count-pill" id="side-outcomes">0</span></div>
290 + <div class="stat-list">
291 + <div class="stat-row"><span>kept</span><span id="side-kept">0</span></div>
292 + <div class="stat-row"><span>discarded</span><span id="side-discarded">0</span></div>
293 + <div class="stat-row"><span>crashed / failed</span><span id="side-failed">0</span></div>
294 + </div>
295 + </section>
296 + </aside>
297 + </div>
298 + <div id="status" role="status" aria-live="polite">Loading</div>
63 300 <script>
64 - const VALID = new Set(['keep', 'discard', 'crash', 'checks_failed']);
65 - const COLORS = { text:'#c9d1d9', muted:'#8b949e', line:'#58a6ff', grid:'rgba(255,255,255,.08)', good:'#3fb950', bad:'#f85149' };
66 - let state = { config:{ name:'Autoresearch', metricName:'metric', metricUnit:'', bestDirection:'lower' }, runs:[] };
67 - let lastText = '';
301 + const VALID = new Set(["keep", "discard", "crash", "checks_failed"]);
302 + const COLORS = { line:"#d86dd8", info:"#3ec5dd", error:"#e46479", grid:"rgba(157,157,157,.18)", muted:"#9d9d9d" };
303 + let state = { config:{ name:"Autoresearch", metricName:"metric", metricUnit:"", bestDirection:"lower" }, runs:[] };
304 + let lastText = "";
69 306 start();
70 307 function start() {
308 + wireTheme();
71 309 refresh();
72 - if (typeof EventSource !== 'undefined') {
73 - const events = new EventSource('/events');
74 - events.addEventListener('jsonl-updated', refresh);
75 - events.onerror = () => setMeta('Live update disconnected; retrying via refresh.', true);
310 + if (typeof EventSource !== "undefined") {
311 + const events = new EventSource("/events");
312 + events.addEventListener("jsonl-updated", refresh);
313 + events.onerror = () => setStatus("Live update disconnected; waiting…", true);
77 - window.addEventListener('resize', () => drawChart());
315 + window.addEventListener("resize", drawChart);
318 + function wireTheme() {
319 + const select = document.getElementById("theme-mode");
320 + select.value = localStorage.getItem("diff-review-theme") || "system";
321 + select.addEventListener("change", () => {
322 + localStorage.setItem("diff-review-theme", select.value);
323 + applyTheme(select.value);
324 + });
325 + matchMedia("(prefers-color-scheme: light)").addEventListener("change", () => {
326 + if ((localStorage.getItem("diff-review-theme") || "system") === "system") applyTheme("system");
327 + });
329 + function applyTheme(mode) {
330 + const systemLight = matchMedia("(prefers-color-scheme: light)").matches;
331 + document.documentElement.dataset.themeMode = mode;
332 + document.documentElement.dataset.theme = mode === "system" ? (systemLight ? "light" : "dark") : mode;
333 + drawChart();
80 336 async function refresh() {
82 - const res = await fetch('session.jsonl', { cache:'no-store' });
83 - if (!res.ok) throw new Error('HTTP ' + res.status);
338 + const res = await fetch("session.jsonl", { cache:"no-store" });
339 + if (!res.ok) throw new Error("HTTP " + res.status);
84 340 const text = await res.text();
85 341 if (text === lastText) return;
86 342 lastText = text;
87 343 load(text);
88 344 } catch (err) {
89 - setMeta('Could not load session.jsonl: ' + err.message, true);
345 + setStatus("Could not load session.jsonl: " + err.message, true);
93 349 function load(text) {
94 - const entries = text.trim().split(/\n+/).filter(Boolean).map((line, i) => {
95 - try { return JSON.parse(line); } catch { throw new Error('invalid JSONL line ' + (i + 1)); }
350 + const trimmed = text.trim();
351 + if (!trimmed) throw new Error("empty session.jsonl");
352 + const entries = trimmed.split(/\n+/).filter(Boolean).map((line, i) => {
353 + try { return JSON.parse(line); } catch { throw new Error("invalid JSONL line " + (i + 1)); }
97 - const config = entries.find(x => x && x.type === 'config') || {};
355 + const config = entries.find(x => x && x.type === "config") || {};
98 356 state.config = {
99 - name: config.name || 'Autoresearch',
100 - metricName: config.metricName || 'metric',
101 - metricUnit: config.metricUnit || '',
102 - bestDirection: config.bestDirection === 'higher' ? 'higher' : 'lower',
357 + name: config.name || "Autoresearch",
358 + metricName: config.metricName || "metric",
359 + metricUnit: config.metricUnit || "",
360 + bestDirection: config.bestDirection === "higher" ? "higher" : "lower",
104 - state.runs = entries.filter(x => x && typeof x.run === 'number').map(normalizeRun);
362 + state.runs = entries.filter(x => x && typeof x.run === "number").map(normalizeRun);
105 363 render();
106 364 return {
107 365 run: Number.isFinite(Number(run.run)) ? Number(run.run) : i + 1,
108 366 metric: Number.isFinite(Number(run.metric)) ? Number(run.metric) : 0,
109 - status: VALID.has(run.status) ? run.status : 'discard',
110 - commit: run.commit || '', description: run.description || '', confidence: run.confidence,
111 - asi: run.asi && typeof run.asi === 'object' ? run.asi : {},
367 + status: VALID.has(run.status) ? run.status : "discard",
368 + commit: run.commit || "",
369 + description: run.description || "",
370 + confidence: run.confidence,
371 + asi: run.asi && typeof run.asi === "object" ? run.asi : {},
115 375 function render() {
116 - document.title = state.config.name;
117 - text('title', state.config.name);
118 - text('metric-head', state.config.metricName);
119 - setMeta(`${state.config.metricName}${state.config.metricUnit ? ' (' + state.config.metricUnit + ')' : ''} · ${state.config.bestDirection} is better · live`, false);
120 376 const baseline = state.runs[0]?.metric ?? null;
121 - const best = bestRun()?.metric ?? null;
122 - text('baseline-best', fmt(baseline) + ' → ' + fmt(best));
123 - const pct = improvement(baseline, best);
124 - text('improvement', pct == null ? '—' : pct.toFixed(1) + '%');
125 - text('runs', String(state.runs.length));
126 - text('kept', String(state.runs.filter(r => r.status === 'keep').length));
127 - renderRows(baseline);
377 + const best = bestRun();
378 + document.title = state.config.name;
379 + text("title", state.config.name);
380 + text("metric-head", state.config.metricName);
381 + text("summary", `${state.config.metricName}${state.config.metricUnit ? " (" + state.config.metricUnit + ")" : ""} · ${state.config.bestDirection} is better · live`);
382 + text("baseline-best", fmt(baseline) + " → " + fmt(best?.metric ?? null));
383 + const pct = improvement(baseline, best?.metric ?? null);
384 + const imp = document.getElementById("improvement");
385 + imp.textContent = pct == null ? "—" : pct.toFixed(1) + "%";
386 + imp.className = "value " + (pct == null || pct >= 0 ? "good" : "bad");
387 + text("runs", String(state.runs.length));
388 + text("kept", String(count("keep")));
389 + text("side-metric", state.config.metricName);
390 + text("side-direction", state.config.bestDirection);
391 + text("side-baseline", fmt(baseline));
392 + text("side-best-run", best ? "#" + best.run : "—");
393 + text("side-outcomes", String(state.runs.length));
394 + text("side-kept", String(count("keep")));
395 + text("side-discarded", String(count("discard")));
396 + text("side-failed", String(count("crash") + count("checks_failed")));
397 + renderRows(baseline, best);
128 398 drawChart();
399 + setStatus(`Ready · ${state.runs.length} runs`, false);
131 - function renderRows(baseline) {
132 - const best = bestRun();
133 - const rows = document.getElementById('rows');
134 - if (!state.runs.length) { rows.innerHTML = '<tr><td colspan="9" class="notice">No runs found in session.jsonl.</td></tr>'; return; }
402 + function renderRows(baseline, best) {
403 + const rows = document.getElementById("rows");
404 + if (!state.runs.length) {
405 + rows.innerHTML = '<tr><td colspan="9" class="notice">No runs found in session.jsonl.</td></tr>';
406 + return;
135 408 rows.innerHTML = state.runs.map(r => {
136 409 const delta = deltaPct(r.metric, baseline);
137 - return `<tr class="${best && r.run === best.run ? 'best-row' : ''}">
410 + return `<tr class="${best && r.run === best.run ? "best-row" : ""}">
138 411 <td class="mono">#${r.run}</td><td><span class="status ${esc(r.status)}">${esc(r.status)}</span></td>
139 - <td class="mono">${r.metric > 0 ? esc(fmt(r.metric)) : '—'}</td><td class="mono ${deltaClass(delta)}">${fmtDelta(delta)}</td>
412 + <td class="mono">${r.metric > 0 ? esc(fmt(r.metric)) : "—"}</td><td class="mono ${deltaClass(delta)}">${fmtDelta(delta)}</td>
140 413 <td class="mono">${fmtConfidence(r.confidence)}</td><td class="mono muted">${esc(r.commit)}</td>
141 - <td>${esc(r.description)}</td><td>${esc(r.asi.hypothesis || '')}</td><td>${esc(r.asi.next_action_hint || r.asi.next || '')}</td>
414 + <td>${esc(r.description)}</td><td>${esc(r.asi.hypothesis || "")}</td><td>${esc(r.asi.next_action_hint || r.asi.next || "")}</td>
142 415 </tr>`;
143 - }).join('');
416 + }).join("");
146 419 function drawChart() {
147 - const canvas = document.getElementById('chart');
420 + const canvas = document.getElementById("chart");
148 421 const rect = canvas.getBoundingClientRect();
149 422 const dpr = devicePixelRatio || 1;
150 - canvas.width = Math.max(1, Math.floor(rect.width * dpr)); canvas.height = Math.max(1, Math.floor(rect.height * dpr));
151 - const ctx = canvas.getContext('2d'); ctx.setTransform(dpr,0,0,dpr,0,0); ctx.clearRect(0,0,rect.width,rect.height);
152 - const runs = state.runs.filter(r => r.metric > 0); if (!runs.length) return;
153 - const values = runs.map(r => r.metric), minRaw = Math.min(...values), maxRaw = Math.max(...values), spread = maxRaw - minRaw || Math.max(1, maxRaw * .1);
423 + canvas.width = Math.max(1, Math.floor(rect.width * dpr));
424 + canvas.height = Math.max(1, Math.floor(rect.height * dpr));
425 + const ctx = canvas.getContext("2d");
426 + ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
427 + ctx.clearRect(0, 0, rect.width, rect.height);
428 + const runs = state.runs.filter(r => r.metric > 0);
429 + if (!runs.length) return;
430 + const css = getComputedStyle(document.documentElement);
431 + const lineColor = css.getPropertyValue("--accent").trim() || COLORS.line;
432 + const infoColor = css.getPropertyValue("--nugu-info").trim() || COLORS.info;
433 + const errorColor = css.getPropertyValue("--nugu-error").trim() || COLORS.error;
434 + const muted = css.getPropertyValue("--muted").trim() || COLORS.muted;
435 + const values = runs.map(r => r.metric);
436 + const minRaw = Math.min(...values), maxRaw = Math.max(...values), spread = maxRaw - minRaw || Math.max(1, maxRaw * .1);
154 437 const min = Math.max(0, minRaw - spread * .15), max = maxRaw + spread * .12, range = max - min || 1;
155 - const m = { l:56, r:18, t:14, b:28 }, w = rect.width - m.l - m.r, h = rect.height - m.t - m.b;
156 - const x = i => m.l + (runs.length === 1 ? w/2 : i * w/(runs.length - 1));
438 + const m = { l:60, r:18, t:14, b:28 }, w = rect.width - m.l - m.r, h = rect.height - m.t - m.b;
439 + const x = i => m.l + (runs.length === 1 ? w / 2 : i * w / (runs.length - 1));
157 440 const y = v => m.t + h - ((v - min) / range) * h;
158 - ctx.strokeStyle = COLORS.grid; ctx.fillStyle = COLORS.muted; ctx.font = '10px ui-monospace,monospace'; ctx.textAlign = 'right';
159 - for (let i=0;i<=4;i++) { const v = min + range * i / 4, yy = y(v); ctx.beginPath(); ctx.moveTo(m.l, yy); ctx.lineTo(rect.width - m.r, yy); ctx.stroke(); ctx.fillText(fmt(v), m.l - 8, yy + 3); }
160 - ctx.strokeStyle = COLORS.line; ctx.lineWidth = 2; ctx.beginPath(); runs.forEach((r,i) => i ? ctx.lineTo(x(i), y(r.metric)) : ctx.moveTo(x(i), y(r.metric))); ctx.stroke();
161 - runs.forEach((r,i) => { ctx.fillStyle = r.status === 'keep' ? COLORS.good : COLORS.bad; ctx.beginPath(); ctx.arc(x(i), y(r.metric), 4, 0, Math.PI*2); ctx.fill(); });
441 + ctx.strokeStyle = COLORS.grid;
442 + ctx.fillStyle = muted;
443 + ctx.font = '10px "JetBrains Mono", ui-monospace, monospace';
444 + ctx.textAlign = "right";
445 + for (let i = 0; i <= 4; i++) {
446 + const v = min + range * i / 4, yy = y(v);
447 + ctx.beginPath(); ctx.moveTo(m.l, yy); ctx.lineTo(rect.width - m.r, yy); ctx.stroke();
448 + ctx.fillText(fmt(v), m.l - 8, yy + 3);
450 + ctx.strokeStyle = lineColor;
451 + ctx.lineWidth = 2.5;
452 + ctx.lineJoin = "round";
453 + ctx.lineCap = "round";
454 + ctx.beginPath();
455 + runs.forEach((r, i) => i ? ctx.lineTo(x(i), y(r.metric)) : ctx.moveTo(x(i), y(r.metric)));
456 + ctx.stroke();
457 + runs.forEach((r, i) => {
458 + ctx.fillStyle = r.status === "keep" ? infoColor : errorColor;
459 + ctx.beginPath(); ctx.arc(x(i), y(r.metric), 4.5, 0, Math.PI * 2); ctx.fill();
460 + });
164 463 function bestRun() { return state.runs.filter(r => r.metric > 0).reduce((best, r) => !best || better(r.metric, best.metric) ? r : best, null); }
165 - function better(a,b) { return state.config.bestDirection === 'higher' ? a > b : a < b; }
166 - function improvement(base,best) { if (!base || best == null) return null; return state.config.bestDirection === 'higher' ? (best-base)/base*100 : (base-best)/base*100; }
464 + function better(a, b) { return state.config.bestDirection === "higher" ? a > b : a < b; }
465 + function improvement(base, best) { if (!base || best == null) return null; return state.config.bestDirection === "higher" ? (best - base) / base * 100 : (base - best) / base * 100; }
167 466 function deltaPct(value, base) { return !base || value <= 0 ? null : (value - base) / base * 100; }
168 - function deltaClass(d) { if (d == null || Math.abs(d) < .05) return 'muted'; return (state.config.bestDirection === 'higher' ? d > 0 : d < 0) ? 'good' : 'bad'; }
169 - function fmtDelta(d) { return d == null ? '—' : (Math.abs(d) < .05 ? '0%' : (d > 0 ? '+' : '') + d.toFixed(1) + '%'); }
170 - function fmt(v) { return v == null || Number.isNaN(v) ? '—' : Number(v).toLocaleString(undefined, { maximumFractionDigits: 2 }) + state.config.metricUnit; }
171 - function fmtConfidence(v) { return typeof v === 'number' ? v.toFixed(1) + '×' : '—'; }
467 + function deltaClass(d) { if (d == null || Math.abs(d) < .05) return "muted"; return (state.config.bestDirection === "higher" ? d > 0 : d < 0) ? "good" : "bad"; }
468 + function fmtDelta(d) { return d == null ? "—" : (Math.abs(d) < .05 ? "0%" : (d > 0 ? "+" : "") + d.toFixed(1) + "%"); }
469 + function fmt(v) { return v == null || Number.isNaN(v) ? "—" : Number(v).toLocaleString(undefined, { maximumFractionDigits: 2 }) + state.config.metricUnit; }
470 + function fmtConfidence(v) { return typeof v === "number" ? v.toFixed(1) + "×" : "—"; }
471 + function count(status) { return state.runs.filter(r => r.status === status).length; }
172 472 function text(id, value) { document.getElementById(id).textContent = value; }
173 - function setMeta(msg, warning) { const el = document.getElementById('meta'); el.textContent = msg; el.className = 'meta ' + (warning ? 'warn' : ''); }
174 - function esc(v) { return String(v).replace(/[&<>"']/g, ch => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[ch])); }
473 + function setStatus(msg, error) { const el = document.getElementById("status"); el.textContent = msg; el.className = error ? "error" : "ok"; }
474 + function esc(v) { return String(v).replace(/[&<>"']/g, ch => ({"&":"&amp;", "<":"&lt;", ">":"&gt;", '"':"&quot;", "'":"&#39;"}[ch])); }
175 475 </script>
176 476 </body>
177 477 </html>

skills/pandoc/SKILL.md

Modified
1129 1129 See `references/filters/` directory:
1131 1131 - `strong-to-smallcaps.lua` — Convert **bold** to SMALL CAPS
1132 -- `center-images.lua` — Center images in HTML/LaTeX
1132 +- `center-images.lua` — Center images in HTML and image-only LaTeX/Beamer paragraphs
1133 1133 - `meta-vars.lua` — Replace `%var%` placeholders with metadata values
1134 1134 - `extract-headings.lua` — Extract nested heading outline as real links/list items
1135 1135 - `add-meta-date.lua` — Auto-set date metadata

skills/pandoc/ideas.md

Modified
9 9 - Autolink filter (bare URLs → clickable links; strips trailing prose punctuation)
10 10 - Diagram filter (Graphviz `dot` code blocks via pandoc.pipe + mediabag pattern; graceful fallback if dot missing)
11 11 - Extract headings filter emits real nested BulletList links, not escaped Markdown text
12 +- Center images filter skips LaTeX Figure children to avoid corrupting generated figure output
12 13 - pdf-report.yaml and html-report.yaml defaults
13 14 - Cross-platform Lua scripts (batch-convert, md-to-pdf, docx-to-md, web-to-md, wordcount, doctor)
14 15 - pandoc.system.list_directory for portable dir listing

skills/pandoc/references/filters/center-images.lua

Modified
1 --- center-images.lua — Center images in HTML and LaTeX output
1 +-- center-images.lua — Center images in HTML and LaTeX/Beamer output
2 2 -- Usage: pandoc --lua-filter=center-images.lua doc.md -o out.html
3 +--
4 +-- HTML: adds CSS to Image elements.
5 +-- LaTeX/Beamer: wraps image-only paragraphs in a center environment.
6 +-- Figures are already centered by pandoc's LaTeX writer, so the filter skips
7 +-- their children to avoid corrupting figure/minipage output.
8 +-- Inline images inside text are left unchanged.
4 -if FORMAT:match 'html' then
5 - function Image(elem)
6 - elem.attributes.style = (elem.attributes.style or '')
7 - .. 'display:block; margin-left:auto; margin-right:auto;'
8 - return elem
10 +local function html_image(elem)
11 + local style = elem.attributes.style or ''
12 + if style ~= '' and not style:match(';%s*$') then
13 + style = style .. ';'
10 -elseif FORMAT:match 'latex' then
11 - function Image(elem)
15 + elem.attributes.style = style .. 'display:block;margin-left:auto;margin-right:auto;'
16 + return elem
17 +end
19 +local function center_if_image_only(block)
20 + if #block.content == 1 and block.content[1].t == 'Image' then
12 21 return {
13 - pandoc.RawInline('latex', '\\begin{center}'),
14 - elem,
15 - pandoc.RawInline('latex', '\\end{center}'),
22 + pandoc.RawBlock('latex', '\\begin{center}'),
23 + block,
24 + pandoc.RawBlock('latex', '\\end{center}'),
27 + return block
28 +end
30 +if FORMAT:match('html') then
31 + return { Image = html_image }
32 +elseif FORMAT:match('latex') or FORMAT:match('beamer') then
33 + return {
34 + traverse = 'topdown',
35 + -- Do not walk into Figure contents; pandoc's LaTeX writer already centers figures.
36 + Figure = function(fig) return fig, false end,
37 + Para = center_if_image_only,
38 + Plain = center_if_image_only,
39 + }
40 +else
41 + return {}